:root {
  color-scheme: light;
  --ink: #16211c;
  --muted: #66736c;
  --paper: #f8f6ef;
  --panel: #fffdf7;
  --line: #d8d0be;
  --accent: #0d6b5f;
  --accent-dark: #074c44;
  --gold: #c08a25;
  --danger: #a23f2a;
  --shadow: 0 24px 60px rgba(50, 42, 23, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(22, 33, 28, 0.04) 1px, transparent 1px),
    linear-gradient(180deg, rgba(22, 33, 28, 0.04) 1px, transparent 1px),
    radial-gradient(circle at 18% 12%, rgba(192, 138, 37, 0.18), transparent 30%),
    var(--paper);
  background-size: 28px 28px, 28px 28px, auto, auto;
  font-family: "Yu Gothic", "Yu Gothic UI", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
}

button,
input {
  font: inherit;
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0;
}

.workbench {
  border: 1px solid var(--line);
  background: rgba(255, 253, 247, 0.92);
  box-shadow: var(--shadow);
}

.masthead {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding: 28px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--gold);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(32px, 5vw, 62px);
  font-weight: 700;
  line-height: 0.96;
  letter-spacing: 0;
}

h2 {
  font-size: 18px;
  line-height: 1.3;
}

.privacy-note {
  max-width: 260px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
  text-align: right;
}

.control-grid {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(300px, 420px);
  gap: 20px;
  padding: 28px;
}

.drop-zone {
  position: relative;
  display: grid;
  min-height: 260px;
  place-items: center;
  align-content: center;
  gap: 12px;
  padding: 28px;
  border: 2px dashed #a9a08c;
  background: #f1eadb;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.drop-zone.is-dragging {
  border-color: var(--accent);
  background: #e5f0eb;
  transform: translateY(-2px);
}

.drop-zone input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.drop-zone__mark {
  display: grid;
  width: 56px;
  height: 56px;
  place-items: center;
  border: 1px solid var(--ink);
  color: var(--ink);
  font-size: 38px;
  line-height: 1;
}

.drop-zone__title {
  font-size: 24px;
  font-weight: 700;
}

.drop-zone__text {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
  text-align: center;
}

.settings {
  display: grid;
  align-content: start;
  gap: 22px;
  padding: 24px;
  border-left: 5px solid var(--accent);
  background: var(--panel);
}

.field {
  display: grid;
  gap: 10px;
}

.field__label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.segments {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--line);
}

.segments label {
  min-width: 0;
}

.segments input {
  position: absolute;
  opacity: 0;
}

.segments span {
  display: grid;
  min-height: 44px;
  place-items: center;
  border-right: 1px solid var(--line);
  background: #faf7ed;
  cursor: pointer;
  font-weight: 700;
}

.segments label:last-child span {
  border-right: 0;
}

.segments input:checked + span {
  color: #fff;
  background: var(--accent);
}

.number-row {
  display: grid;
  grid-template-columns: 1fr 72px auto;
  align-items: center;
  gap: 10px;
}

input[type="range"] {
  accent-color: var(--accent);
}

input[type="number"] {
  width: 100%;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  background: #fff;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 10px;
  margin-top: 4px;
}

.button {
  min-height: 46px;
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 700;
  transition: transform 140ms ease, opacity 140ms ease, background 140ms ease;
}

.button:not(:disabled):hover {
  transform: translateY(-1px);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.button--primary {
  color: #fff;
  background: var(--accent);
}

.button--primary:not(:disabled):hover {
  background: var(--accent-dark);
}

.button--secondary {
  color: var(--ink);
  border-color: var(--line);
  background: #fff;
}

.status-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 28px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
}

.results {
  display: grid;
  gap: 16px;
  padding: 28px;
}

.empty-state {
  display: grid;
  min-height: 150px;
  place-items: center;
  border: 1px solid var(--line);
  color: var(--muted);
  background: #fbf8ef;
}

.empty-state[hidden] {
  display: none;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 14px;
}

.tile {
  display: grid;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  background: #fff;
}

.tile__preview {
  display: grid;
  aspect-ratio: 16 / 10;
  place-items: center;
  overflow: hidden;
  background: #ede5d4;
}

.tile__preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.tile__name {
  overflow-wrap: anywhere;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.45;
}

.tile__meta {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.tile__download {
  min-height: 36px;
  border: 1px solid var(--accent);
  color: var(--accent);
  background: #fff;
  cursor: pointer;
  font-weight: 700;
}

.is-error {
  color: var(--danger);
}

@media (max-width: 760px) {
  .shell {
    width: min(100% - 20px, 1180px);
    padding: 10px 0;
  }

  .masthead,
  .control-grid {
    padding: 18px;
  }

  .masthead,
  .status-row {
    align-items: start;
    flex-direction: column;
  }

  .privacy-note {
    text-align: left;
  }

  .control-grid {
    grid-template-columns: 1fr;
  }

  .drop-zone {
    min-height: 210px;
  }

  .settings,
  .results {
    padding: 18px;
  }
}
