:root {
  --ink: #1c1a17;
  --ink-2: #26231f;
  --ink-3: #35312b;
  --line: #48433b;
  --paper: #f6f3ec;
  --paper-dim: #c9c2b4;
  --accent: #e4502f;
  --accent-hover: #f0633f;
  --pass: #3aa36b;
  --warn: #d89b1d;
  --weak: #e0553f;
  --store-light: #ffffff;
  --store-dark: #0f1111;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--ink);
  color: var(--paper);
  font: 15px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--serif); font-weight: 600; margin: 0; letter-spacing: 0.005em; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }

button, input, select { font: inherit; color: inherit; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

[hidden] { display: none !important; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 20px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--paper); text-decoration: none; font: 600 22px var(--serif); }
.tagline { margin: 0; color: var(--paper-dim); font-family: var(--serif); font-style: italic; font-weight: 400; font-size: 16px; }
.topbar .btn-accent { margin-left: auto; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 16px;
  border-radius: 8px; border: 1px solid var(--line);
  background: var(--ink-3); color: var(--paper);
  cursor: pointer; font-weight: 600; font-size: 14px;
  transition: background-color .15s, border-color .15s;
}
.btn:hover { border-color: var(--paper-dim); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--paper); color: var(--ink); border-color: var(--paper); }
.btn-primary:hover:not(:disabled) { background: #fff; }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ghost { background: transparent; }
.btn-small { min-height: 34px; padding: 0 12px; font-size: 13px; }

/* ---------- layout ---------- */
.layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 24px;
  padding: 24px 28px 8px;
  max-width: 1600px; margin: 0 auto;
}
.rail { display: flex; flex-direction: column; gap: 16px; }
.stage { min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.share { grid-column: 1 / -1; }

.panel {
  background: var(--ink-2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; display: flex; flex-direction: column; gap: 12px;
}
.panel-head { display: flex; align-items: baseline; justify-content: space-between; }
.count { font-variant-numeric: tabular-nums; color: var(--paper-dim); font-size: 13px; }

/* ---------- drop zones ---------- */
.drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  border: 1.5px dashed var(--line); border-radius: 8px;
  padding: 18px 12px; text-align: center; cursor: pointer;
  color: var(--paper-dim); font-size: 13px;
  transition: border-color .15s, background-color .15s;
}
.drop strong { color: var(--paper); font-size: 15px; }
.drop:hover, .drop.is-over { border-color: var(--accent); background: rgba(228, 80, 47, .08); }
.drop-own { min-height: 180px; position: relative; }
.drop-empty { display: flex; flex-direction: column; gap: 4px; }
.drop-preview { max-height: 220px; max-width: 100%; border-radius: 2px; box-shadow: 0 4px 18px rgba(0,0,0,.45); }
.drop-own.has-image { border-style: solid; padding: 12px; }

.comp-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px 6px; }
.comp-list li { position: relative; }
.comp-list img { width: 100%; aspect-ratio: 2 / 3; object-fit: cover; border-radius: 2px; display: block; }
.comp-num {
  position: absolute; left: 0; bottom: 0; min-width: 16px; padding: 1px 3px; border-radius: 0 3px 0 2px;
  background: rgba(28, 26, 23, .85); color: var(--paper); font: 600 10.5px/14px var(--sans); text-align: center;
  font-variant-numeric: tabular-nums;
}
/* 20px visible dot inside the thumbnail corner; ::before widens the hit area to 32px. */
.comp-remove {
  position: absolute; top: 2px; right: 2px; width: 20px; height: 20px; border-radius: 50%;
  border: 1px solid var(--line); background: rgba(28, 26, 23, .9); color: var(--paper);
  font-size: 14px; line-height: 1; cursor: pointer; padding: 0;
  display: flex; align-items: center; justify-content: center;
}
.comp-remove::before { content: ""; position: absolute; inset: -6px; }
.comp-remove:hover, .comp-remove:focus-visible { background: var(--accent); border-color: var(--accent); }

.field-error { margin: 0; color: #ffb3a3; font-size: 13px; }
.file-errors { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 2px; }

.privacy {
  margin: 0; padding: 12px 14px; border-left: 3px solid var(--accent);
  background: var(--ink-2); border-radius: 0 8px 8px 0; font-size: 13.5px; color: var(--paper);
}
.rail .btn-ghost { align-self: flex-start; }

/* ---------- toolbar ---------- */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; }
.toolbar-secondary { padding-bottom: 4px; }
.seg { display: inline-flex; background: var(--ink-2); border: 1px solid var(--line); border-radius: 8px; padding: 3px; }
.seg button {
  border: 0; background: transparent; border-radius: 6px; padding: 7px 12px; cursor: pointer;
  font-size: 13.5px; color: var(--paper-dim); min-height: 34px;
}
.seg button[aria-checked="true"] { background: var(--paper); color: var(--ink); font-weight: 600; }
.seg button:hover:not([aria-checked="true"]) { color: var(--paper); }
.seg small { font-variant-numeric: tabular-nums; opacity: .7; margin-left: 4px; }

.slider { display: flex; align-items: center; gap: 10px; font-size: 13.5px; color: var(--paper-dim); }
.slider output { color: var(--paper); font-variant-numeric: tabular-nums; }
.slider input { accent-color: var(--accent); width: 160px; }
.slider-small input { width: 110px; }
.toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; min-height: 34px; }
.toggle input { accent-color: var(--accent); width: 18px; height: 18px; }

/* ---------- surface ---------- */
.surface {
  position: relative; border-radius: var(--radius); min-height: 300px;
  padding: 28px 24px 34px; overflow: hidden;
  background: var(--store-light); color: #0f1111;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.06);
}
.surface[data-bg="dark"] { background: var(--store-dark); color: #e6e6e6; box-shadow: inset 0 0 0 1px rgba(255,255,255,.08); }
.shelf { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 22px 16px; }
.shelf-item { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.shelf-item img { display: block; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.surface[data-bg="dark"] .shelf-item img { box-shadow: none; }
.shelf-item .meta { height: 8px; width: 70%; border-radius: 4px; background: currentColor; opacity: .12; }
.shelf-item .meta + .meta { width: 45%; }
.shelf-item.is-own .tag {
  font: 700 10px/1 var(--sans); letter-spacing: .08em; color: #fff; background: var(--accent);
  padding: 3px 6px; border-radius: 3px;
}
.surface.hide-tag .tag { visibility: hidden; }

.shelf-empty { display: flex; flex-direction: column; align-items: center; gap: 18px; padding: 24px 12px; text-align: center; color: #565959; }
.surface[data-bg="dark"] .shelf-empty { color: #a8adad; }
.steps {
  list-style: none; margin: 0; padding: 0; counter-reset: step;
  display: grid; grid-template-columns: repeat(3, minmax(0, 180px)); gap: 20px; text-align: left;
}
.steps li { counter-increment: step; display: flex; flex-direction: column; gap: 2px; font-size: 14px; line-height: 1.4; }
.steps li::before {
  content: counter(step); width: 24px; height: 24px; border-radius: 50%; margin-bottom: 6px;
  background: var(--accent); color: #fff; font: 700 13px/24px var(--sans); text-align: center;
}
.steps strong { color: #0f1111; font-family: var(--serif); font-size: 17px; }
.surface[data-bg="dark"] .steps strong { color: #f2f2f2; }
.shelf-empty .btn-primary { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.shelf-empty .btn-primary:hover { background: var(--ink-3); }
.surface[data-bg="dark"] .shelf-empty .btn-primary { background: var(--paper); border-color: var(--paper); color: var(--ink); }
.ghosts { display: flex; gap: 14px; align-items: flex-end; }
.spot { display: inline-flex; align-items: center; gap: 6px; }
.spot .slider { margin-right: 4px; }
.btn-icon { width: 34px; padding: 0; font-size: 16px; }
.ghosts i { width: 64px; height: 96px; border-radius: 2px; background: currentColor; opacity: .1; }
.ghosts i.you { background: var(--accent); opacity: .5; }

.note { margin: 0; font-size: 13px; color: var(--paper-dim); }
.note-inline { font-size: 13px; color: var(--paper-dim); }

/* ---------- checks ---------- */
.checks { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 8px; }
.check {
  background: var(--ink-2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; display: flex; flex-direction: column; gap: 6px;
}
.check .score { margin: 0; display: flex; align-items: baseline; gap: 10px; }
.check [data-score] { font: 600 28px/1.1 var(--serif); font-variant-numeric: tabular-nums; }
.check [data-verdict] { font-size: 12.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.check[data-state="pass"] { border-color: var(--pass); }
.check[data-state="pass"] [data-verdict] { color: var(--pass); }
.check[data-state="warn"] { border-color: var(--warn); }
.check[data-state="warn"] [data-verdict] { color: var(--warn); }
.check[data-state="weak"] { border-color: var(--weak); }
.check[data-state="weak"] [data-verdict] { color: var(--weak); }
.check .explain { margin: 0; font-size: 13.5px; color: var(--paper-dim); }
.band { font-size: 13px; color: var(--paper-dim); display: flex; align-items: center; gap: 8px; }
.band select { background: var(--ink-3); border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; }

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; margin-top: 6px; }

/* ---------- share ---------- */
.share {
  display: grid; grid-template-columns: minmax(260px, 360px) minmax(0, 1fr); gap: 24px; align-items: start;
  margin-top: 20px; padding: 24px; background: var(--ink-2); border: 1px solid var(--line); border-radius: var(--radius);
}
.share-copy { display: flex; flex-direction: column; gap: 14px; }
.share-copy p { margin: 0; color: var(--paper-dim); }
.share-inputs { display: flex; gap: 12px; }
.mini-slot {
  position: relative; width: 96px; height: 144px; border-radius: 6px; border: 1.5px dashed var(--line);
  display: flex; align-items: center; justify-content: center; padding: 6px; text-align: center; font-size: 12px; color: var(--paper-dim);
}
.mini-slot img { max-width: 100%; max-height: 100%; border-radius: 2px; }
.mini-slot.has-image { border-style: solid; }
.mini-label {
  position: absolute; top: -9px; left: -9px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent); color: #fff; font: 700 12px/22px var(--sans); text-align: center;
}
.text-field { display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; color: var(--paper-dim); }
.text-field input {
  background: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px; color: var(--paper);
}
#share-canvas { width: 100%; height: auto; border-radius: 8px; background: #111; display: block; }
.share .btn-primary { align-self: flex-start; }

.guide { max-width: 1100px; margin: 40px auto 0; padding: 32px 28px 0; border-top: 1px solid var(--line); }
.guide h2 { font-size: 28px; }
.guide .guide-lede { max-width: 68ch; margin: 10px 0 24px; color: var(--paper-dim); font-size: 16px; }
.guide-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 24px 32px; }
.guide h3 { font-size: 18px; margin-bottom: 6px; }
.guide p { margin: 0; }
.guide-grid p { color: var(--paper-dim); }
.guide em { color: var(--paper); font-style: normal; font-weight: 600; }

.foot { padding: 24px 28px 36px; color: var(--paper-dim); font-size: 13px; text-align: center; }
.foot p { margin: 0; }

/* ---------- dialog ---------- */
dialog {
  border: 1px solid var(--line); border-radius: 14px; padding: 0; max-width: 460px; width: calc(100% - 32px);
  background: var(--ink-2); color: var(--paper);
}
dialog::backdrop { background: rgba(10, 9, 8, .7); }
.dialog-body { padding: 24px; display: flex; flex-direction: column; gap: 12px; }
.dialog-body h2 { display: flex; align-items: baseline; gap: 10px; font-size: 24px; }
.dialog-body .price { color: var(--accent); }
.dialog-body p { margin: 0; }
.dialog-body ul { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; }
.lp-status { padding: 10px 12px; background: var(--ink); border-radius: 8px; font-size: 14px; }
.dialog-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 6px; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .checks { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; padding: 16px; }
  .topbar { padding: 12px 16px; flex-wrap: wrap; gap: 8px 16px; }
  .tagline { order: 3; width: 100%; font-size: 14px; }
  .share { grid-template-columns: 1fr; padding: 16px; }
  .surface { padding: 20px 14px 24px; }
  .comp-list { grid-template-columns: repeat(8, 1fr); }
  /* Your cover, then the lineup, then comps right under it; checks and the rest follow. */
  .layout { gap: 14px; }
  .rail, .stage { display: contents; }
  .rail > .panel:first-child { order: 1; }
  .stage > * { order: 4; }
  .stage > .toolbar, .stage > .surface, .stage > .surface + .note { order: 2; }
  .rail > .panel:nth-child(2) { order: 3; }
  .privacy { order: 5; }
  #sample-btn { order: 6; justify-self: start; }
  .share { order: 7; margin-top: 4px; }
  .drop-own { min-height: 120px; }
  .drop-preview { max-height: 160px; }
  .guide { padding: 24px 16px 0; margin-top: 24px; }
  .guide h2 { font-size: 24px; }
}
@media (max-width: 520px) {
  .comp-list { grid-template-columns: repeat(6, 1fr); }
  .steps { grid-template-columns: 1fr; gap: 12px; }
  .steps li { display: grid; grid-template-columns: 24px 1fr; column-gap: 10px; }
  .steps li::before { grid-row: span 2; margin: 0; }
  .ghosts { display: none; }
  /* The arrow buttons move your cover on phones; the slider would force extra rows. */
  .spot input[type="range"] { display: none; }
  .toolbar { gap: 10px 14px; }
  #size-group { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .shelf { gap: 18px 12px; }
  .slider input { width: 120px; }
  .seg button { padding: 7px 9px; font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
