:root {
  --ground: #f4f1ec;
  --well: #ebe5dc;
  --card: #faf8f4;
  --ink: #1e1c19;
  --muted: #6d665d;
  --faint: #a59d92;
  --line: #ddd5ca;
  --accent: #3b4a39;
  --accent-ink: #f4f1ec;
  --warn: #8a4b1f;
  --warn-bg: #f6e9dc;
  --ok: #3b5a3a;
  --radius: 14px;
  --display: "Instrument Serif", "Iowan Old Style", Georgia, serif;
  --ui: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --composer-h: 76px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 15px/1.45 var(--ui);
  min-height: 100dvh;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------------------------------------------------------- header --- */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  background: color-mix(in srgb, var(--ground) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid transparent;
}
.top.scrolled { border-bottom-color: var(--line); }
.wordmark { font: 30px/1 var(--display); letter-spacing: -0.01em; margin: 0; }
.wordmark a { color: inherit; text-decoration: none; }
.bag-btn {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--line); background: var(--card);
  border-radius: 999px; padding: 8px 14px;
}
.bag-btn .count {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
  background: var(--accent); color: var(--accent-ink); font-size: 12px;
  display: inline-grid; place-items: center;
}
.bag-btn .count[data-n="0"] { background: var(--line); color: var(--muted); }

/* ------------------------------------------------------------ main --- */
main {
  max-width: 1180px; margin: 0 auto;
  padding: 8px 16px calc(var(--composer-h) + 40px);
}

.intro { padding: 12vh 4px 0; max-width: 560px; }
.intro h2 { font: 40px/1.05 var(--display); margin: 0 0 14px; letter-spacing: -0.01em; }
.intro p { color: var(--muted); margin: 0 0 22px; }
.examples { display: flex; flex-wrap: wrap; gap: 8px; }
.examples button {
  border: 1px solid var(--line); background: var(--card); border-radius: 999px;
  padding: 8px 14px; color: var(--ink); text-align: left;
}

.understood { padding: 14px 0 6px; }
.interp { font: 22px/1.25 var(--display); margin: 0 0 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--card); border: 1px solid var(--line); border-radius: 999px;
  padding: 5px 6px 5px 12px; font-size: 13px;
}
.chip button {
  border: 0; background: var(--well); width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center; font-size: 14px; line-height: 1; color: var(--muted);
}
.chip button:hover { background: var(--line); color: var(--ink); }
.start-over {
  margin-top: 8px; border: 0; background: none; padding: 4px 0;
  font-size: 13px; color: var(--muted); text-decoration: underline; text-underline-offset: 3px;
}
.start-over:hover { color: var(--ink); }
.suggest { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.suggest button {
  border: 1px dashed var(--faint); background: transparent; border-radius: 999px;
  padding: 5px 12px; font-size: 13px; color: var(--muted);
}
.note {
  margin: 14px 0; padding: 12px 14px; border-radius: var(--radius);
  background: var(--card); border: 1px solid var(--line); color: var(--muted);
}
.status { color: var(--muted); font-size: 13px; margin: 6px 0 0; min-height: 18px; }

/* ------------------------------------------------------------ grid --- */
.grid {
  list-style: none; margin: 16px 0 0; padding: 0;
  display: grid; gap: 18px 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
@media (min-width: 720px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 26px 18px; } }
@media (min-width: 1040px) { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

.card { position: relative; }
.card .open { all: unset; display: block; cursor: pointer; width: 100%; }
.card .well {
  aspect-ratio: 4 / 5; border-radius: var(--radius); overflow: hidden;
  background: var(--well);
}
.card img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  transition: transform .5s ease;
  /* Product shots on pure white take on the warm tile instead of glaring (R3). */
  mix-blend-mode: multiply;
}
.card .open:hover img { transform: scale(1.025); }
.card .meta { padding: 9px 2px 0; }
.card .brand {
  font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
}
.card .title {
  margin: 2px 0 0; font-size: 14px; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card .price { margin-top: 3px; font-variant-numeric: tabular-nums; }
.card .policy { font-size: 12px; color: var(--muted); margin-top: 2px; }
.card .actions {
  position: absolute; top: 8px; left: 8px; right: 8px;
  display: flex; justify-content: space-between; pointer-events: none;
}
.card .actions button {
  pointer-events: auto; width: 34px; height: 34px; border-radius: 50%; border: 0;
  background: color-mix(in srgb, var(--card) 88%, transparent); color: var(--ink);
  display: grid; place-items: center; font-size: 16px;
  box-shadow: 0 1px 2px rgb(0 0 0 / .08);
}
.card .actions .save[aria-pressed="true"] { color: #a33b2b; }
.card.leaving { opacity: 0; transform: scale(.97); transition: all .2s ease; }

/* -------------------------------------------------------- composer --- */
.composer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--ground) 70%, transparent);
}
.composer form {
  max-width: 720px; margin: 0 auto;
  display: flex; gap: 8px; align-items: flex-end;
  background: var(--card); border: 1px solid var(--line); border-radius: 22px;
  padding: 6px 6px 6px 16px; box-shadow: 0 6px 24px rgb(30 28 25 / .08);
}
.composer textarea {
  flex: 1; border: 0; outline: 0; background: transparent; resize: none;
  padding: 9px 0; max-height: 120px; line-height: 1.35;
}
.composer button {
  border: 0; background: var(--accent); color: var(--accent-ink);
  border-radius: 16px; padding: 10px 16px; white-space: nowrap;
}
.composer button:disabled { opacity: .5; cursor: default; }
.composer .surprise { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
/* On phones there's room for one button: Surprise me while the box is empty, Search once you type. */
@media (max-width: 560px) {
  .composer form:not(.typed) #send, .composer form.typed .surprise { display: none; }
}

/* ------------------------------------------------------- overlays --- */
.scrim {
  position: fixed; inset: 0; z-index: 40; background: rgb(30 28 25 / .35);
  opacity: 0; pointer-events: none; transition: opacity .2s ease;
}
.scrim.on { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; z-index: 50; background: var(--ground);
  left: 0; right: 0; bottom: 0; max-height: 92dvh; overflow: auto;
  border-radius: 20px 20px 0 0;
  transform: translateY(100%); transition: transform .28s cubic-bezier(.2,.8,.2,1);
}
.sheet.on { transform: none; }
@media (min-width: 900px) {
  .sheet {
    left: auto; top: 0; width: 480px; max-height: none; height: 100dvh;
    border-radius: 0; transform: translateX(100%);
  }
}
.sheet-head {
  position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between;
  align-items: center; padding: 12px 16px; background: var(--ground);
}
.sheet-head h2 { font: 24px/1 var(--display); margin: 0; }
.x { border: 0; background: var(--well); width: 34px; height: 34px; border-radius: 50%; font-size: 18px; }
.sheet-body { padding: 0 16px 28px; }

.gallery {
  display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x mandatory;
  margin: 0 -16px 14px; padding: 0 16px;
}
.gallery img {
  flex: 0 0 82%; aspect-ratio: 4 / 5; object-fit: cover; border-radius: var(--radius);
  background: var(--well); scroll-snap-align: start;
}
.d-brand { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.d-title { font: 26px/1.15 var(--display); margin: 4px 0 6px; }
.d-price { font-size: 17px; font-variant-numeric: tabular-nums; margin-bottom: 14px; }
.opt-label { font-size: 13px; color: var(--muted); margin: 14px 0 6px; }
.opts { display: flex; flex-wrap: wrap; gap: 6px; }
.opts button {
  border: 1px solid var(--line); background: var(--card); border-radius: 10px;
  padding: 8px 12px; min-width: 44px;
}
.opts button[aria-pressed="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.opts button:disabled { color: var(--faint); text-decoration: line-through; cursor: default; }
.policy-box {
  margin: 16px 0; padding: 12px 14px; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); font-size: 14px;
}
.policy-box p { margin: 0 0 4px; }
.policy-box .unverified { color: var(--warn); }
.policy-box a { color: var(--ink); }
.primary {
  width: 100%; border: 0; border-radius: 14px; padding: 14px; font-weight: 600;
  background: var(--accent); color: var(--accent-ink);
}
.primary:disabled { opacity: .45; cursor: default; }
.secondary {
  display: block; text-align: center; margin-top: 10px; color: var(--muted); font-size: 14px;
}
.desc { margin-top: 18px; color: var(--muted); font-size: 14px; white-space: pre-line; }
.desc summary { color: var(--ink); cursor: pointer; }
.live-note { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* ------------------------------------------------------------- bag --- */
.split {
  margin: 4px 0 14px; padding: 12px 14px; border-radius: var(--radius);
  background: var(--card); border: 1px solid var(--line);
}
.split strong { font-weight: 600; }
.brand-group { border-top: 1px solid var(--line); padding: 14px 0; }
.brand-group h3 { margin: 0 0 4px; font-size: 15px; }
.brand-group .policy { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.line { display: grid; grid-template-columns: 56px 1fr auto; gap: 10px; align-items: center; margin: 8px 0; }
.line img { width: 56px; aspect-ratio: 4 / 5; object-fit: cover; border-radius: 8px; background: var(--well); }
.line .lt { font-size: 14px; line-height: 1.3; }
.line .lv { font-size: 12px; color: var(--muted); }
.line .rm { border: 0; background: none; color: var(--muted); font-size: 13px; text-decoration: underline; }
.change { color: var(--warn); background: var(--warn-bg); border-radius: 10px; padding: 8px 10px; font-size: 13px; margin: 8px 0; }
.done-row { display: flex; gap: 8px; margin-top: 10px; }
.done-row button { flex: 1; border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 10px; }
.state-done { color: var(--ok); font-size: 13px; }
.disclosure { font-size: 12px; color: var(--muted); margin-top: 16px; }
.empty { color: var(--muted); }

footer { text-align: center; font-size: 12px; color: var(--faint); padding: 30px 0 0; }
footer a { color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
