:root {
  --accent: #be0203;
  --ink: #2a2a2a;
  --muted: #6f6a66;
  --line: #e7e1da;
  --bg: #f7f4f0;
  --card: #ffffff;
  --stage: #f1ede8;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(40, 30, 20, .06), 0 6px 24px rgba(40, 30, 20, .06);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 var(--font);
}
button { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* top */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 24px; background: var(--card); border-bottom: 1px solid var(--line);
}
.brand { color: var(--ink); text-decoration: none; font-weight: 600; }
.brand:hover { color: var(--accent); }
.topbar-title { font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.notice {
  margin: 0; padding: 10px 24px; text-align: center; font-size: 14px;
  background: color-mix(in srgb, var(--accent) 8%, white); color: color-mix(in srgb, var(--accent) 70%, black);
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 18%, white);
}

/* model picker */
.models {
  display: flex; gap: 10px; overflow-x: auto; padding: 16px 24px 6px;
  scroll-snap-type: x proximity; scrollbar-width: thin; scroll-padding-inline: 24px;
}
.model-group { display: flex; gap: 10px; align-items: stretch; }
.model-group + .model-group { padding-left: 10px; border-left: 1px solid var(--line); }
.model-group-label {
  writing-mode: vertical-rl; transform: rotate(180deg); font-size: 11px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--muted); align-self: center;
}
.model {
  flex: 0 0 auto; width: 148px; padding: 6px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--card); cursor: pointer; text-align: left; scroll-snap-align: start;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.model:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.model[aria-current="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.model img { width: 100%; height: auto; aspect-ratio: 3 / 2; object-fit: cover; border-radius: 8px; background: var(--stage); }
.model span { display: block; padding: 6px 2px 2px; font-size: 13px; font-weight: 600; line-height: 1.25; }

/* layout */
.layout {
  display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(340px, 1fr); gap: 24px;
  max-width: 1360px; margin: 0 auto; padding: 16px 24px 40px;
}
.stage-col { position: sticky; top: 16px; align-self: start; }
.stage {
  position: relative; width: 100%; aspect-ratio: 3 / 2; overflow: hidden;
  border-radius: var(--radius); background: var(--stage); box-shadow: var(--shadow);
}
.stage .layer { position: absolute; inset: 0; }
.stage .layer img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain;
  opacity: 0; transition: opacity .28s ease;
}
.stage .layer img.in { opacity: 1; }
.stage-loading {
  position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 14px;
  transition: opacity .2s;
}
.stage.ready .stage-loading { opacity: 0; pointer-events: none; }
.stage-meta { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; }
.stage-meta h1 { margin: 0; font: 600 26px/1.2 var(--serif); }
.tools { display: flex; flex-wrap: wrap; gap: 6px; }
.tool {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 11px; border: 1px solid var(--line);
  border-radius: 999px; background: var(--card); cursor: pointer; font-size: 13px; transition: border-color .15s;
}
.tool:hover { border-color: var(--ink); }
.tool svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* panel */
.panel {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px 22px;
  min-width: 0;
}
.steps {
  display: flex; gap: 6px; overflow-x: auto; margin: 0 -4px 14px; padding: 2px 4px 8px; list-style: none;
  scrollbar-width: thin;
}
.steps button {
  display: flex; align-items: center; gap: 6px; white-space: nowrap; padding: 6px 10px 6px 6px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--bg); cursor: pointer; font-size: 13px;
}
.steps button .n {
  display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%;
  background: var(--card); border: 1px solid var(--line); font-size: 11px; font-weight: 600;
}
.steps button[aria-current="step"] { border-color: var(--ink); background: var(--ink); color: #fff; }
.steps button[aria-current="step"] .n { background: #fff; color: var(--ink); border-color: #fff; }
.steps button.done .n { background: var(--accent); border-color: var(--accent); color: #fff; }

.step-head { margin-bottom: 10px; }
.step-count { margin: 0; font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.step-head h2 { margin: 2px 0 2px; font: 600 22px/1.25 var(--serif); }
.step-choice { margin: 0; color: var(--muted); min-height: 1.5em; }
.step-choice strong { color: var(--ink); font-weight: 600; }

.options { max-height: min(56vh, 560px); overflow-y: auto; padding: 4px 2px 8px; margin: 0 -2px; }
.group + .group { margin-top: 14px; }
.group h3 { margin: 0 0 8px; font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 10px 8px; }
.swatch {
  display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 4px 2px; border: 0;
  background: none; cursor: pointer; border-radius: 10px; text-align: center;
}
.swatch .chip {
  position: relative; width: 52px; height: 52px; border-radius: 50%; overflow: hidden;
  box-shadow: 0 0 0 1px var(--line); transition: box-shadow .15s, transform .15s; background: var(--stage);
}
.swatch .chip img { width: 100%; height: 100%; object-fit: cover; }
.swatch .chip.text { display: grid; place-items: center; font-size: 12px; font-weight: 600; }
.swatch:hover .chip { transform: scale(1.06); }
.swatch[aria-checked="true"] .chip { box-shadow: 0 0 0 2px var(--card), 0 0 0 4px var(--accent); }
.swatch[aria-checked="true"] .chip::after {
  content: ""; position: absolute; right: 2px; bottom: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 12l5 5 9-10' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 11px no-repeat;
  border: 1.5px solid #fff;
}
.swatch .label { font-size: 11.5px; line-height: 1.25; color: var(--muted); max-width: 84px; overflow-wrap: anywhere; }
.swatch[aria-checked="true"] .label { color: var(--ink); font-weight: 600; }

.step-nav { display: flex; justify-content: space-between; gap: 10px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 20px; border-radius: 999px;
  border: 1px solid var(--accent); background: var(--accent); color: #fff; font-weight: 600; cursor: pointer;
  text-decoration: none; transition: filter .15s;
}
.btn:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--ink); filter: none; }
.btn[disabled] { opacity: .35; pointer-events: none; }
.btn.wide { width: 100%; }

.summary { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.summary h2 { margin: 0 0 10px; font: 600 20px/1.25 var(--serif); }
.summary ul { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 2px; }
.summary li button {
  display: grid; grid-template-columns: 28px 1fr auto; align-items: center; gap: 10px; width: 100%;
  padding: 6px 8px; border: 0; border-radius: 8px; background: none; text-align: left; cursor: pointer;
}
.summary li button:hover { background: var(--bg); }
.summary li img, .summary li .dot { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; box-shadow: 0 0 0 1px var(--line); }
.summary li .k { font-size: 13px; color: var(--muted); }
.summary li .v { font-size: 13.5px; font-weight: 600; text-align: right; }
.fine { margin: 8px 0 0; font-size: 12px; color: var(--muted); text-align: center; }

.footer {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 18px; padding: 24px; font-size: 13px;
  color: var(--muted); border-top: 1px solid var(--line);
}
.footer a { color: inherit; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 999px; font-size: 14px;
  transition: opacity .2s, transform .2s; z-index: 10;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; gap: 14px; padding: 10px 16px 32px; }
  .stage-col { position: sticky; top: 0; z-index: 2; background: var(--bg); padding-top: 6px; margin: 0 -16px; padding: 6px 16px 8px; }
  .stage-meta { margin-top: 8px; }
  .stage-meta h1 { font-size: 20px; }
  .tool span { display: none; }
  .tool { padding: 8px; }
  .options { max-height: none; overflow: visible; }
  .models, .topbar, .notice { padding-left: 16px; padding-right: 16px; }
  .model { width: 120px; }
}
@media (max-width: 900px) and (max-height: 760px) {
  .stage { aspect-ratio: auto; height: 34vh; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
