:root {
  --bg: #f5f6f3;
  --surface: #ffffff;
  --surface-2: #f0f2ee;
  --border: #e1e4dd;
  --text: #1c211e;
  --muted: #69716b;
  --accent: #1f7a5a;
  --accent-ink: #ffffff;
  --accent-soft: #e3f1ea;
  --warn: #9a5b00;
  --warn-soft: #fff3df;
  --promo: #b42318;
  --promo-soft: #fdecea;
  --shadow: 0 1px 2px rgba(20, 30, 25, .05), 0 4px 16px rgba(20, 30, 25, .05);
  --radius: 14px;
  --font: ui-sans-serif, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111513;
    --surface: #191e1b;
    --surface-2: #212823;
    --border: #2c342f;
    --text: #e8ece9;
    --muted: #9aa49d;
    --accent: #4cc493;
    --accent-ink: #0b1a13;
    --accent-soft: #1b3229;
    --warn: #f3b562;
    --warn-soft: #33281a;
    --promo: #ff8a80;
    --promo-soft: #3a1f1d;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; line-height: 1.25; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 13px; }

/* ── Top bar ─────────────────────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 18px 28px; border-bottom: 1px solid var(--border); background: var(--surface);
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo { width: 40px; height: 40px; border-radius: 10px; display: block; }
.brand h1 { font-size: 20px; letter-spacing: -.01em; }
.tagline { margin: 0; color: var(--muted); font-size: 13px; }
.status {
  display: flex; gap: 8px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted);
}
.pill {
  padding: 4px 10px; border-radius: 999px; background: var(--surface-2);
  border: 1px solid var(--border); white-space: nowrap;
}
.pill.ok { color: var(--accent); background: var(--accent-soft); border-color: transparent; }
.pill button { border: 0; background: none; color: var(--accent); cursor: pointer; padding: 0; }

/* ── Layout ──────────────────────────────────────────────────────────────── */
.layout {
  display: grid; grid-template-columns: minmax(340px, 440px) 1fr; gap: 24px;
  padding: 24px 28px 48px; max-width: 1380px; margin: 0 auto;
}
.column { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; padding: 16px; }
  .topbar { padding: 14px 16px; }
}

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.card-head h2 { font-size: 17px; }
.step {
  width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 13px;
}
.field-label { display: block; font-size: 13px; color: var(--muted); margin: 14px 0 6px; }

/* ── Controls ────────────────────────────────────────────────────────────── */
.segmented {
  display: inline-flex; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap;
}
.segmented button {
  border: 0; background: none; padding: 6px 12px; border-radius: 7px; cursor: pointer;
  color: var(--muted);
}
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); font-weight: 600; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--border); background: var(--surface); border-radius: 999px;
  padding: 6px 12px; cursor: pointer; display: inline-flex; gap: 6px; align-items: center;
}
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.chip:disabled { opacity: .45; cursor: not-allowed; }

.money-input {
  display: inline-flex; align-items: center; border: 1px solid var(--border);
  border-radius: 10px; padding: 0 10px; background: var(--surface);
}
.money-input span { color: var(--muted); }
.money-input input { border: 0; outline: 0; background: none; width: 80px; padding: 8px 6px; }

.switch { display: flex; align-items: center; gap: 10px; margin-top: 16px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; }
.switch .track {
  width: 38px; height: 22px; border-radius: 999px; background: var(--border); position: relative;
  transition: background .15s;
}
.switch .thumb {
  position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; transition: transform .15s;
}
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track .thumb { transform: translateX(16px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }

button.primary, button.secondary, button.ghost {
  border-radius: 10px; padding: 10px 16px; cursor: pointer; font-weight: 600;
  border: 1px solid transparent;
}
button.primary { background: var(--accent); color: var(--accent-ink); }
button.primary:disabled { opacity: .6; cursor: progress; }
button.secondary { background: var(--accent-soft); color: var(--accent); }
button.ghost { background: none; border: 1px dashed var(--border); color: var(--muted); }
button.ghost:hover { border-color: var(--accent); color: var(--accent); }
button.wide { width: 100%; margin-top: 18px; padding: 13px; font-size: 16px; }
button.icon {
  border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 20px;
  width: 30px; height: 30px; border-radius: 8px;
}
button.icon:hover { background: var(--surface-2); color: var(--text); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.tabs button {
  border: 0; background: none; padding: 8px 12px; cursor: pointer; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }

textarea {
  width: 100%; border: 1px solid var(--border); border-radius: 10px; padding: 12px;
  background: var(--surface); resize: vertical; outline: 0;
}
textarea:focus { border-color: var(--accent); }
.row-end { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 10px; }

/* ── Item boxes ──────────────────────────────────────────────────────────── */
.boxes { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.box {
  display: grid; grid-template-columns: 22px 1fr auto auto 30px; gap: 6px 8px; align-items: center;
  grid-template-areas: "num text text text remove" ". . qty unit .";
  border: 1px solid var(--border); border-radius: 12px; padding: 8px 8px 8px 10px;
  background: var(--surface);
}
.box .box-num { grid-area: num; }
.box .box-text { grid-area: text; }
.box .qty { grid-area: qty; }
.box .unit { grid-area: unit; }
.box .remove { grid-area: remove; }
.box:focus-within { border-color: var(--accent); }
.box-num { color: var(--muted); font-size: 12px; font-weight: 600; text-align: center; }
.box-text { border: 0; outline: 0; background: none; min-width: 0; padding: 6px 2px; }
.qty { display: flex; align-items: center; background: var(--surface-2); border-radius: 8px; }
.qty-btn { border: 0; background: none; width: 28px; height: 30px; cursor: pointer; color: var(--muted); font-size: 16px; }
.qty-btn:hover { color: var(--text); }
.qty-input {
  width: 44px; text-align: center; border: 0; background: none; outline: 0; padding: 4px 0;
  -moz-appearance: textfield;
}
.qty-input::-webkit-inner-spin-button { -webkit-appearance: none; }
.unit { border: 1px solid var(--border); border-radius: 8px; background: var(--surface); padding: 5px 4px; }
.add { width: 100%; }

/* ── Results ─────────────────────────────────────────────────────────────── */
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.plan {
  text-align: left; border: 1px solid var(--border); border-radius: 12px; background: var(--surface);
  padding: 14px; cursor: pointer; display: flex; flex-direction: column; gap: 4px; position: relative;
}
.plan.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.plan .label { font-size: 13px; color: var(--muted); }
.plan .total { font-size: 24px; font-weight: 700; letter-spacing: -.02em; }
.plan .stores { font-size: 13px; }
.plan .save { font-size: 13px; color: var(--accent); font-weight: 600; }
.badge {
  position: absolute; top: 10px; right: 10px; font-size: 11px; font-weight: 700;
  background: var(--accent); color: var(--accent-ink); padding: 2px 8px; border-radius: 999px;
}
.tag { font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 6px; }
.tag.promo { background: var(--promo-soft); color: var(--promo); }
.tag.flag { background: var(--surface-2); color: var(--muted); }

.store-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; margin-top: 16px; }
.store-col { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.store-col header {
  display: flex; justify-content: space-between; align-items: baseline; padding: 12px 14px;
  background: var(--surface-2); font-weight: 700;
}
.line { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 10px 14px; border-top: 1px solid var(--border); }
.line .item { font-size: 12px; color: var(--muted); }
.line .product { font-size: 14px; }
.line .cost { font-weight: 700; text-align: right; }
.line .calc { font-size: 12px; color: var(--muted); text-align: right; }

.notice { margin-top: 14px; padding: 10px 14px; border-radius: 10px; background: var(--warn-soft); color: var(--warn); font-size: 14px; }

.matches { display: flex; flex-direction: column; gap: 10px; }
details.match { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
details.match summary {
  list-style: none; cursor: pointer; padding: 12px 14px; display: flex; justify-content: space-between; gap: 10px;
}
details.match summary::-webkit-details-marker { display: none; }
details.match summary .count { color: var(--muted); font-size: 13px; white-space: nowrap; }
details.match[open] summary { border-bottom: 1px solid var(--border); }
.cand { display: grid; grid-template-columns: 22px 40px 1fr auto; gap: 10px; align-items: center; padding: 9px 14px; }
.cand + .cand { border-top: 1px dashed var(--border); }
.cand input { width: 16px; height: 16px; accent-color: var(--accent); }
.cand .name { font-size: 14px; }
.cand .meta { font-size: 12px; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.cand .price { text-align: right; font-weight: 600; white-space: nowrap; }
.cand .price small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }

.loading { display: flex; align-items: center; gap: 12px; color: var(--muted); }
.spinner {
  width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--border);
  border-top-color: var(--accent); animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.section-title { font-size: 15px; margin: 0 0 4px; }

.thumb { width: 40px; height: 40px; border-radius: 8px; object-fit: contain; background: #fff; display: block; }
span.thumb { background: var(--surface-2); }
.line .size { font-size: 12px; color: var(--muted); white-space: nowrap; }
details.match.none summary .count { color: var(--warn); font-weight: 600; }
details.match summary::after { content: "▾"; color: var(--muted); }
details.match[open] summary::after { content: "▴"; }
details.match summary > span:first-child { flex: 1; min-width: 0; }
.spinner.small { width: 14px; height: 14px; margin-left: auto; }
.results.updating .plans, .results.updating .store-grid { opacity: .55; transition: opacity .15s; }
.pill button:disabled { opacity: .5; cursor: progress; }
code { background: var(--surface-2); padding: 1px 5px; border-radius: 5px; font-size: 13px; }
@media (max-width: 520px) {
  /* Phones: photo beside the name, the price and the stores' prices under it. */
  .cand { grid-template-columns: 18px 44px 1fr; gap: 4px 10px; padding: 10px; align-items: start; }
  .cand .thumb { width: 44px; height: 44px; grid-row: span 2; }
  .cand input { margin-top: 14px; grid-row: span 2; }
  .cand .price { grid-column: 3; text-align: left; display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; }
  .cand .price small { display: inline; }
  .cand .store-prices { flex-basis: 100%; }
  .cand .store-prices a, .cand .store-prices span { white-space: normal; }
  .status { font-size: 12px; }
  .pill { white-space: normal; }
}
.nothing { padding: 10px 14px; font-size: 14px; }

/* Choosing products: nothing pre-ticked, best matches bold */
.matches-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.matches-head .section-title { margin: 0; }
.sort { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.sort select { font: inherit; color: var(--text); padding: 4px 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.cand .name { font-weight: 400; }
.cand.best .name { font-weight: 700; }
.cand:not(.best) .name { color: var(--muted); }
details.match.chosen summary .count { color: var(--accent); font-weight: 600; }

/* Small quantity stepper inside a summary or a plan line */
.mini-qty { display: inline-flex; align-items: center; gap: 2px; margin-left: 6px; padding: 1px 2px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); font-size: 12px;
  color: var(--text); vertical-align: middle; }
.mini-qty span { min-width: 34px; text-align: center; font-weight: 600; }
.mini-qty button { border: 0; background: none; color: var(--muted); font: inherit; font-size: 14px;
  width: 22px; height: 22px; border-radius: 6px; cursor: pointer; line-height: 1; }
.mini-qty button:hover { background: var(--surface); color: var(--text); }
.tag.guess { background: var(--surface-2); color: var(--muted); font-weight: 600; margin-left: 4px; }
.line.provisional .product { color: var(--muted); }
.copy-list { border: 1px solid var(--border); background: var(--surface); color: var(--accent); font: inherit;
  font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 8px; margin-right: 8px; cursor: pointer; }
.copy-list:hover { background: var(--surface-2); }
.cand-divider { padding: 8px 14px 4px; font-size: 12px; font-weight: 600; color: var(--muted);
  border-top: 1px solid var(--border); background: var(--surface-2); }

/* ── Basket: remove, add a product, shop at a store ─────────────────────── */
.store-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 10px 14px; border-top: 1px solid var(--border); }
button.small, a.button.small { padding: 6px 12px; font-size: 13px; }
.copy-list { margin-right: 0; }
.remove-item { border: 0; background: none; color: var(--muted); font: inherit; font-size: 12px; cursor: pointer;
  padding: 0 4px; margin-left: 4px; text-decoration: underline; text-underline-offset: 2px; }
.remove-item:hover { color: var(--promo); }
.add-product { display: flex; gap: 8px; margin: 10px 0; }
.add-product input { flex: 1; min-width: 0; padding: 9px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.add-cand { grid-template-columns: 40px 1fr auto; border-top: 1px dashed var(--border); }
a.button { display: inline-flex; align-items: center; justify-content: center; border-radius: 10px; padding: 10px 16px;
  font-weight: 600; text-decoration: none; }
a.button.primary { background: var(--accent); color: var(--accent-ink); }

dialog.shop { width: min(720px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog.shop::backdrop { background: rgba(15, 20, 17, .45); }
.shop-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 18px 20px 6px; }
.shop-head h2 { font-size: 18px; }
.shop-intro { padding: 0 20px; margin: 4px 0 10px; }
.shop-lines { padding: 0 8px; overflow-y: auto; max-height: calc(100vh - 260px); }
.shop-line { display: grid; grid-template-columns: 22px 40px 1fr auto auto; gap: 10px; align-items: center; padding: 10px 12px;
  border-radius: 10px; }
.shop-line + .shop-line { border-top: 1px dashed var(--border); }
.shop-line input { width: 18px; height: 18px; accent-color: var(--accent); }
.shop-line .name { display: block; font-size: 14px; }
.shop-line .meta { font-size: 12px; color: var(--muted); }
.shop-line .amount { font-weight: 700; font-size: 15px; white-space: nowrap; }
.shop-line.next { background: var(--accent-soft); }
.shop-line.done .name { text-decoration: line-through; color: var(--muted); }
.shop-foot { display: flex; justify-content: space-between; gap: 10px; padding: 14px 20px 18px; border-top: 1px solid var(--border); margin-top: 8px; }
@media (max-width: 520px) {
  .shop-line { grid-template-columns: 22px 40px 1fr auto; }
  .shop-line [data-shop-open] { grid-column: 3 / -1; justify-self: start; }
}

/* ── Store conflicts: never drop an item silently ───────────────────────── */
.tag.elsewhere { background: var(--warn-soft); color: var(--warn); }
.conflict { margin: 0; padding: 12px 14px; background: var(--warn-soft); color: var(--text); font-size: 14px;
  border-bottom: 1px solid var(--border); }
.fix-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.missing-block { margin-top: 14px; border: 1px solid var(--warn); border-radius: 12px; background: var(--warn-soft); overflow: hidden; }
.missing-block h4 { margin: 0; padding: 10px 14px 4px; font-size: 13px; color: var(--warn); text-transform: uppercase; letter-spacing: .04em; }
.missing-line { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 10px 14px; align-items: start; }
.missing-line + .missing-line { border-top: 1px solid var(--border); }
.missing-line .reason { font-size: 13px; color: var(--muted); margin-top: 2px; }
.missing-line .fix-actions { grid-column: 1 / -1; margin-top: 2px; }
.missing-line .remove-item { grid-row: 1; grid-column: 2; }
.notice.ok-note { background: var(--accent-soft); color: var(--accent); border-color: transparent; margin-bottom: 12px; }
.missing-note { color: var(--warn); }
/* Every store's price on a product row: a tick covers all of them. */
.store-prices { display: grid; gap: 1px; margin-top: 2px; }
.store-prices span { display: block; font-size: 12px; font-weight: 400; color: var(--muted); white-space: nowrap; }
.store-prices span.cheapest { color: var(--text); font-weight: 600; }
.store-prices span.checked { display: inline; color: var(--accent); font-weight: 700; margin-right: 3px; }
.store-prices a { display: block; font-size: 12px; font-weight: 400; color: var(--muted); white-space: nowrap; }
.store-prices a.cheapest { color: var(--text); font-weight: 600; }
.store-prices a:hover { color: var(--accent); }
.alternatives-note { padding: 10px 14px; background: var(--accent-soft); font-size: 13px; border-bottom: 1px solid var(--border); }
.alternatives-note button { margin-left: 6px; }
.price .total-for { display: block; font-size: 11px; font-weight: 400; color: var(--muted); }

.cart-fill { margin: 0 20px 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2, transparent); }
.cart-fill h3 { margin: 0 0 6px; font-size: 1rem; }
.cart-fill ol { margin: 0; padding-left: 20px; display: grid; gap: 6px; }
.cart-fill .bookmarklet { display: inline-block; padding: 2px 10px; border-radius: 999px; border: 1px dashed currentColor; font-weight: 600; text-decoration: none; cursor: grab; }

/* ── Brand chip on an item, and its picker ─────────────────────────────────── */
.box { grid-template-areas: "num text text text remove" ". chip qty unit ."; }
.box .brand-chip { grid-area: chip; justify-self: start; }
.brand-chip {
  border: 1px dashed var(--border); background: none; border-radius: 999px; padding: 4px 10px;
  font-size: 12px; color: var(--muted); cursor: pointer; max-width: 100%; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.brand-chip:hover { color: var(--text); border-color: var(--muted); }
.brand-chip.set { border-style: solid; border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.brand-mode { font-weight: 400; opacity: .8; }
.brand-menu {
  position: absolute; z-index: 50; width: 320px; max-width: calc(100vw - 16px); max-height: 420px;
  display: flex; flex-direction: column; gap: 8px; padding: 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .14);
}
.brand-menu[hidden] { display: none; }
.brand-menu-head { font-size: 13px; }
.brand-filter { border: 1px solid var(--border); border-radius: 8px; padding: 7px 9px; background: var(--surface); color: var(--text); }
.brand-modes { display: flex; gap: 4px; background: var(--surface-2); border-radius: 8px; padding: 3px; }
.brand-modes button { flex: 1; border: 0; background: none; border-radius: 6px; padding: 5px; font-size: 12px; cursor: pointer; color: var(--muted); }
.brand-modes button.active { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }
.brand-options { overflow-y: auto; display: flex; flex-direction: column; }
.brand-option {
  display: flex; justify-content: space-between; align-items: baseline; gap: 10px; text-align: left;
  border: 0; background: none; padding: 7px 8px; border-radius: 8px; cursor: pointer; color: var(--text);
}
.brand-option:hover { background: var(--surface-2); }
.brand-option.current { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.brand-option small { color: var(--muted); font-weight: 400; white-space: nowrap; }

/* ── Phase 1: language, delivery, saved lists, footer ───────────────────────── */
.topbar-end { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.lang { display: flex; background: var(--surface-2); border-radius: 8px; padding: 3px; }
.lang button { border: 0; background: none; padding: 4px 9px; border-radius: 6px; cursor: pointer; color: var(--muted); font-weight: 600; font-size: 12px; }
.lang button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.select { width: 100%; border: 1px solid var(--border); border-radius: 10px; padding: 9px 10px; background: var(--surface); color: var(--text); font: inherit; }
.chip small { font-weight: 400; color: var(--muted); }
.chip.muted-chip { opacity: .75; }
.plan .fees-note { display: block; }
.plan.short { border-style: dashed; }
.left-out { margin: 0 0 10px; }
.prices-note { margin: 14px 0 0; }
.charges { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; padding: 6px 16px 0; font-size: 12.5px; color: var(--muted); }
.charges strong { color: var(--text); font-weight: 600; }
.charges a { text-decoration: none; }
.short-note { margin: 8px 16px 0; }
.store-col > .hint { margin: 6px 16px 0; }
.lists-actions { margin-left: auto; }
.saved-lists { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; margin-bottom: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.saved-list { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 4px 0; }
.saved-actions { display: flex; gap: 8px; padding-top: 4px; }
.ok-text { color: var(--accent); }
.site-foot { max-width: 1380px; margin: 0 auto; padding: 0 28px 40px; color: var(--muted); font-size: 12.5px; }
.site-foot p { margin: 4px 0; }
@media (max-width: 520px) {
  .topbar { padding: 14px 16px; }
  .topbar-end { width: 100%; justify-content: space-between; }
  .site-foot { padding: 0 16px 32px; }
}
.legal { max-width: 760px; margin: 0 auto; padding: 32px 20px 56px; line-height: 1.6; }
.legal h1 { font-size: 26px; margin: 10px 0 4px; }
.legal h2 { font-size: 17px; margin: 26px 0 6px; }
.legal ul { padding-left: 20px; }
.saved-lists[hidden] { display: none; }
#shopping { display: grid; grid-template-columns: 1fr 1fr; }
#shopping button { text-align: center; }
@media (max-width: 520px) { .status .pill { font-size: 11.5px; } }

/* Sign-in (beta) */
.signin { display: grid; place-items: start center; padding: 48px 16px; }
.signin[hidden], .layout[hidden] { display: none; }
.signin-card { width: min(420px, 100%); display: grid; gap: 12px; }
.signin-card form { display: grid; gap: 8px; }
.signin-card form[hidden] { display: none; }
.signin-card input { font: inherit; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; }
.signin-card input#code { letter-spacing: 0.3em; font-size: 20px; text-align: center; }
.account { display: flex; gap: 6px; align-items: center; }
.account-menu { position: relative; }
.account-menu summary { cursor: pointer; list-style: none; }
.account-menu summary::-webkit-details-marker { display: none; }
.account-panel { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; display: grid; gap: 8px;
  min-width: 220px; padding: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.08); }
.account-panel a { color: var(--accent); text-decoration: none; font-size: 14px; }
.account-panel .danger { color: var(--promo); }
.legal-table { width: 100%; border-collapse: collapse; font-size: 14px; margin: 8px 0 16px; }
.legal-table th, .legal-table td { border-bottom: 1px solid var(--border); padding: 8px 6px; text-align: left; vertical-align: top; }
@media (max-width: 640px) { .legal-table, .legal-table tbody, .legal-table tr, .legal-table td { display: block; }
  .legal-table thead { display: none; } .legal-table tr { border-bottom: 1px solid var(--border); padding: 6px 0; }
  .legal-table td { border: 0; padding: 2px 0; } }
@media (max-width: 720px) { .account-panel { left: 0; right: auto; } }

/* Pages: one step at a time */
.layout.pages { display: block; max-width: 760px; }
.layout.pages .page { display: flex; flex-direction: column; gap: 20px; }
.layout.pages .page[hidden] { display: none; }
.layout.pages .results-page { max-width: none; }
.layout.pages:has(.results-page:not([hidden])) { max-width: 1180px; }
.stepper { display: flex; gap: 6px; margin: 0 0 18px; overflow-x: auto; }
.stepper button { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border: 1px solid var(--border);
  border-radius: 999px; background: var(--surface); color: var(--muted); font: inherit; font-size: 14px; cursor: pointer;
  white-space: nowrap; }
.stepper button .step { width: 22px; height: 22px; font-size: 12px; }
.stepper button.active { color: var(--text); border-color: var(--accent); font-weight: 600; }
.stepper button.done { color: var(--accent); }
.stepper button:disabled { opacity: .45; cursor: default; }
.page-actions { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 20px; }
.page-toolbar { display: flex; gap: 8px; flex-wrap: wrap; }
.summary-line { margin: -4px 0 12px; color: var(--muted); font-size: 14px; }
button.link { background: none; border: 0; padding: 0 0 0 6px; color: var(--accent); font: inherit; cursor: pointer;
  text-decoration: underline; }
.list-head { display: flex; justify-content: space-between; align-items: center; margin-top: 18px; }
#freeText { width: 100%; }
@media (max-width: 520px) { .stepper button span:not(.step) { display: none; } .stepper button.active span { display: inline; } }
.layout.pages[hidden] { display: none; }
.tag.differs { background: var(--warn-soft); color: var(--warn); border-color: transparent; }

/* Page 4: each item with the product it uses now; a running total at the bottom */
.match-title { display: flex; flex-direction: column; gap: 8px; min-width: 0; flex: 1; }
.current { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 400; min-width: 0; }
.current .thumb { width: 36px; height: 36px; flex: none; }
.current-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.current-text .tag { margin-left: 6px; }
.current-text small { color: var(--muted); font-size: 12px; }
.tag.suggested { background: var(--surface-2); color: var(--muted); border-color: transparent; }
.tag.mine { background: var(--accent-soft); color: var(--accent); border-color: transparent; font-weight: 600; }
details.match summary::after, details.match[open] summary::after { content: none; }
details.match summary .count { white-space: nowrap; color: var(--accent); font-size: 13px; }
.choose-bar { position: sticky; bottom: 0; z-index: 10; display: flex; justify-content: space-between; align-items: center;
  gap: 12px; padding: 12px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: 0 -6px 20px rgb(0 0 0 / 0.06); font-size: 14px; }
.choose-bar strong { margin-left: 4px; }
@media (max-width: 520px) {
  details.match summary { flex-wrap: wrap; }
  details.match summary > span.match-title:first-child { flex: 1 1 100%; }
  details.match summary .count { margin-left: 46px; }
  .choose-bar { flex-direction: column; align-items: stretch; text-align: center; gap: 8px; }
}

/* Page 5: one store or several, asked plainly first */
.how-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin-top: 12px; }
.how-option { position: relative; display: flex; flex-direction: column; gap: 6px; text-align: left; padding: 16px;
  border: 1px solid var(--border); border-radius: 14px; background: var(--surface); font: inherit; color: var(--text);
  cursor: pointer; }
.how-option:hover { border-color: var(--accent); }
.how-option.recommended { border: 2px solid var(--accent); }
.how-option .badge { position: static; align-self: flex-start; transform: none; }
.how-title { font-weight: 700; font-size: 16px; }
.how-stores { color: var(--muted); font-size: 14px; }
.how-total { font-size: 26px; font-weight: 700; }
.how-total small { font-size: 12px; font-weight: 400; color: var(--muted); }
.how-save { color: var(--accent); font-weight: 600; font-size: 14px; }
.how-cost { color: var(--warn); font-size: 13px; }
.how-pick { margin-top: 6px; color: var(--accent); font-weight: 600; }
.how-chosen { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 12px; margin-bottom: 12px; border-radius: 10px; background: var(--accent-soft); font-size: 14px; }
.same-kind { display: block; font-size: 12px; font-weight: 400; color: var(--warn); }
.item-sort { margin: 4px 14px 8px; }

/* Page 5: a short preview of what each way buys where */
.how-preview { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; padding-top: 10px;
  border-top: 1px dashed var(--border); font-size: 13px; }
.preview-store { display: flex; flex-direction: column; gap: 2px; }
.preview-head { display: flex; justify-content: space-between; font-weight: 700; font-size: 14px; }
.preview-line { display: flex; justify-content: space-between; gap: 10px; color: var(--muted); }
.preview-line span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-more { color: var(--muted); font-style: italic; }
/* Page 6: a tab per store on phones */
.store-tabs { display: none; gap: 8px; overflow-x: auto; margin: 0 0 12px; }
.store-tabs a { flex: none; padding: 8px 12px; border-radius: 999px; border: 1px solid var(--border);
  color: var(--text); text-decoration: none; font-size: 14px; font-weight: 600; background: var(--surface); }
@media (max-width: 720px) { .store-tabs { display: flex; position: sticky; top: 0; z-index: 5; background: var(--surface); padding: 6px 0; } }
.how-options .how-option:only-child { max-width: 560px; }
#final .store-col { scroll-margin-top: 60px; }
