:root {
  --bg: #f6f5f1; --panel: #fff; --ink: #1c1e1b; --muted: #5f645c; --line: #e2e0d8;
  --accent: #2c6a37; --accent-ink: #fff; --accent-soft: #e5f0e6; --warn: #9b2c2c; --warn-soft: #fbeaea;
  --bogo: #b3261e; --multi: #8a4b00; --coupon: #1f5aa6; --clearance: #6a2c91; --sale: #2c6a37; --drop: #006b74;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141613; --panel: #1d201c; --ink: #e9e9e4; --muted: #a3a89e; --line: #33372f;
    --accent: #74c281; --accent-ink: #0f1f10; --accent-soft: #223424; --warn: #f19a9a; --warn-soft: #3a2222;
    --bogo: #f2867d; --multi: #e6a65a; --coupon: #86b4f0; --clearance: #c7a0e2; --sale: #74c281; --drop: #62c9d2;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }   /* author display rules (button, .badge) must not un-hide */
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
h1 { font-size: 22px; line-height: 1.25; margin: 6px 0 12px; }
h1 small { color: var(--muted); font-weight: 400; font-size: 15px; }
h2 { font-size: 18px; margin: 22px 0 8px; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 8px; top: 8px; background: var(--panel); padding: 8px; z-index: 10; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* header */
.top { background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.bar { display: flex; align-items: center; gap: 10px; padding: 10px 16px 4px; max-width: 980px; margin: 0 auto; flex-wrap: wrap; }
.brand { font-weight: 750; color: var(--accent); text-decoration: none; font-size: 18px; margin-right: auto; padding: 8px 0; }
.zipform { display: flex; align-items: center; gap: 6px; }
.zipform label { color: var(--muted); font-size: 14px; }
.zipform input { width: 4.6em; }
.zipform .place { color: var(--muted); font-size: 13px; }
/* main tabs: a row under the header on wide screens, a bottom tab bar on phones (thumb reach) */
.tabs { display: flex; gap: 4px; padding: 4px 10px 6px; max-width: 980px; margin: 0 auto; }
.tabs a { color: var(--ink); text-decoration: none; padding: 8px 10px; border-radius: 8px; white-space: nowrap; }
.tabs a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.tabs .ico { display: none; }
@media (max-width: 759px) {
  .top { position: static; }                        /* header scrolls away: more room for deals */
  .bar { padding: 8px 16px; }
  .brand { font-size: 17px; }
  .tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; max-width: none; margin: 0; gap: 0;
          padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); background: var(--panel);
          border-top: 1px solid var(--line); box-shadow: 0 -2px 10px rgba(0,0,0,.06); }
  .tabs a { flex: 1 1 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
            min-height: 52px; padding: 4px 2px; font-size: 12px; border-radius: 10px; position: relative; }
  .tabs .ico { display: block; font-size: 19px; line-height: 1.1; font-weight: 700; }
  .tabs .badge { position: absolute; top: 2px; left: calc(50% + 8px); }
  body { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
}
body { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
button:active, .button:active, .tabs a:active, .chip span:active { opacity: .75; }
.badge { display: inline-block; min-width: 1.4em; padding: 0 5px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: 12px; text-align: center; }
.badge[hidden] { display: none; }

main { max-width: 980px; margin: 0 auto; padding: 12px 16px 40px; }
.foot { max-width: 980px; margin: 0 auto; padding: 0 16px 30px; color: var(--muted); font-size: 13px; }

/* controls */
input, select, button, .button { font: inherit; font-size: 16px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--ink); min-width: 0; min-height: 42px; }
button, .button { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); cursor: pointer; text-decoration: none; display: inline-block; }
button.secondary { background: var(--panel); color: var(--accent); }
button.link { background: none; border: none; color: var(--muted); padding: 4px; min-height: 0; text-decoration: underline; font-size: 14px; }
button:disabled { opacity: .6; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.row > input { flex: 1 1 180px; }
.row.two > .field { flex: 1 1 140px; }

.filters { display: flex; flex-direction: column; gap: 8px; margin: 8px 0; }
.searchrow { display: flex; gap: 8px; }
.searchrow input { flex: 1 1 auto; }
.ftoggle { flex: 0 0 auto; white-space: nowrap; }
.fmore { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.fmore select { width: 100%; }
@media (max-width: 759px) {
  .js-filters .fmore { display: none; }            /* phones: dropdowns fold under "Filter & sort" */
  .js-filters .fmore.open { display: grid; }
}
@media (min-width: 760px) {
  .filters { flex-direction: row; flex-wrap: wrap; }
  .searchrow { flex: 1 1 220px; }
  .ftoggle { display: none !important; }
  .fmore { display: flex; flex-wrap: wrap; }
  .fmore select { width: auto; flex: 0 1 auto; }
}
.more-row { margin: 14px 0; }
.button.wide { display: block; width: 100%; text-align: center; }
.button.secondary { background: var(--panel); color: var(--accent); }
li.anchor { list-style: none; height: 0; scroll-margin-top: 16px; }
.count { color: var(--muted); font-size: 14px; margin: 6px 0 10px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 12px 0; }
.card.off { opacity: .7; }
.welcome h1 { margin-top: 0; }
.welcome .row input { max-width: 12em; }
.empty { text-align: center; }
.hint { color: var(--muted); font-size: 14px; margin: 4px 0; }
.opt { color: var(--muted); font-weight: 400; }
.flash { background: var(--accent-soft); border-left: 4px solid var(--accent); padding: 10px 12px; border-radius: 6px; margin: 8px 0; }
.flash.warn { background: var(--warn-soft); border-left-color: var(--warn); }
.note { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--accent); padding: 10px 14px; border-radius: 8px; }
.progress ul { list-style: none; padding: 0; margin: 6px 0 0; display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 14px; }
.progress .done { color: var(--accent); } .progress .wait { color: var(--muted); } .progress .fail { color: var(--warn); }

/* forms */
.field { margin-bottom: 12px; }
.field label, .lookup > label { display: block; font-weight: 600; margin-bottom: 4px; }
.field input, .field select { width: 100%; }
.field.invalid input { border-color: var(--warn); }
.err { color: var(--warn); font-size: 14px; margin: 4px 0 0; }
.lookup .row input { flex: 1 1 200px; }
video[data-scan-video] { width: 100%; max-height: 260px; margin-top: 10px; border-radius: 8px; background: #000; }
button.primary { width: 100%; font-weight: 600; }

/* add a deal */
.addform .field input { font-size: 17px; }
.scanbig { width: 100%; min-height: 52px; font-size: 17px; font-weight: 650; margin-bottom: 12px; }
.chips { border: 0; padding: 0; margin: 4px 0 14px; display: flex; flex-wrap: wrap; gap: 8px; }
.chips legend { font-weight: 600; margin-bottom: 6px; padding: 0; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chip span { display: inline-block; padding: 9px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); min-height: 42px; line-height: 22px; cursor: pointer; }
.chip input:checked + span { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.chip input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }
.chips .other { flex: 1 1 160px; }
.chips.invalid .other { border-color: var(--warn); }
.chips .err { flex-basis: 100%; }
.field.short input { max-width: 10em; }
.lookup-status.found { color: var(--accent); font-weight: 600; }
details.more { border-top: 1px solid var(--line); margin: 6px 0 14px; padding-top: 6px; }
details.more summary { cursor: pointer; padding: 10px 0; font-weight: 600; }

/* deal cards */
.deals { list-style: none; padding: 0; margin: 0; }
.deal { display: grid; grid-template-columns: 72px 1fr auto; grid-template-areas: "img body price" "img actions actions";
        gap: 4px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 10px; }
.deal:target { box-shadow: 0 0 0 3px var(--accent); }
.deal.watched { border-color: var(--accent); }
.deal img, .noimg { grid-area: img; width: 72px; height: 72px; object-fit: contain; border-radius: 8px; background: #fff; }
.noimg { background: var(--line); }
.deal .body { grid-area: body; min-width: 0; }
.deal .price { grid-area: price; text-align: right; white-space: nowrap; }
.deal .actions { grid-area: actions; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
.product { font-size: 16px; font-weight: 650; margin: 2px 0; overflow-wrap: anywhere; }
.product a { color: var(--ink); text-decoration: none; display: block; padding: 6px 0; margin: -4px 0; }
.product a:hover { text-decoration: underline; }
.meta, .text, .why { color: var(--muted); font-size: 14px; margin: 2px 0; overflow-wrap: anywhere; }
.why { font-size: 13px; }
.now { font-size: 20px; font-weight: 750; }
.now small { font-size: 13px; font-weight: 500; color: var(--muted); }
.sub, .was { color: var(--muted); font-size: 13px; }
.was { text-decoration: line-through; }
.off { color: var(--bogo); font-weight: 650; font-size: 14px; }
.tags { display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; }
.tag { display: inline-block; font-size: 12px; font-weight: 650; padding: 1px 8px; border-radius: 999px; border: 1px solid currentColor; }
.type-bogo { color: var(--bogo); } .type-multi { color: var(--multi); } .type-coupon { color: var(--coupon); }
.type-clearance { color: var(--clearance); } .type-sale { color: var(--sale); } .type-price_drop { color: var(--drop); }
.gf-certified { color: var(--accent); background: var(--accent-soft); }
.gf-labeled, .gf-gf_brand { color: var(--muted); }
.gf-unknown { color: var(--warn); }
.tag.watch { color: var(--accent); }
.ends { font-size: 12px; color: var(--muted); }
.ends.soon { color: var(--bogo); font-weight: 650; }
button.save { min-height: 36px; padding: 6px 12px; font-size: 14px; background: var(--panel); color: var(--accent); }
button.save.on { background: var(--accent); color: var(--accent-ink); }
details.report summary { cursor: pointer; color: var(--muted); font-size: 14px; padding: 6px 2px; }
details.report form { margin-top: 6px; }
details.report fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin: 0 0 8px; }
details.report label { display: block; font-size: 14px; padding: 3px 0; }
details.report input[type="radio"] { min-height: 0; }

.deal { scroll-margin-top: 16px; }
@media (max-width: 560px) {
  .product a, .product { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
  .deal { grid-template-columns: 56px 1fr; grid-template-areas: "img body" "price price" "actions actions"; }
  .deal img, .noimg { width: 56px; height: 56px; }
  .deal .price { text-align: left; display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
}

/* list */
.store-group h2 { border-bottom: 1px solid var(--line); padding-bottom: 4px; }
.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.checklist label { display: flex; gap: 10px; align-items: center; font-weight: 600; cursor: pointer; }
.checklist input[type="checkbox"] { width: 22px; height: 22px; min-height: 0; }
.checklist .item-meta { display: block; margin-left: 32px; color: var(--muted); font-size: 14px; }
.checklist li.done .item { text-decoration: line-through; color: var(--muted); }
.checklist li.gone .item { color: var(--muted); }

/* guides */
.crumbs { font-size: 14px; color: var(--muted); margin: 0 0 4px; }
/* stand-alone links get a finger-sized target (>= 32 px tall) */
.crumbs a, .more-guides li a, .sources-list a { display: inline-block; padding: 7px 0; }
.crumbs a { padding: 7px 4px; }
.guide-list h2 a { display: block; padding: 6px 0; }
.guide { max-width: 44em; }
.guide h1 { font-size: 26px; }
.guide h2 { margin-top: 26px; }
.guide p, .guide li { line-height: 1.6; }
.guide ul:not(.plain) { padding-left: 1.2em; }
.brand-list { columns: 2 12em; padding-left: 1.2em; }
.guide-list { list-style: none; padding: 0; }
.guide-list h2 { margin: 0 0 6px; font-size: 18px; }
.guide-list h2 a { color: var(--ink); }
.draft-note ul { margin: 6px 0 0; padding-left: 1.2em; font-size: 14px; }
.draft-note p { margin: 0; }
.cta { max-width: 44em; }
.sources-list { font-size: 14px; padding-left: 1.2em; }
.foot p { margin: 4px 0; }

/* misc */
.sources { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.sources .card { margin: 0; }
.watch-item h2 small { color: var(--muted); font-weight: 400; }
form.inline { display: inline; margin-left: 8px; }
ul.plain { padding-left: 0; list-style: none; } ul.plain li { margin: 6px 0; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr.bad td { color: var(--warn); }
@media (max-width: 560px) { table { display: block; overflow-x: auto; } }
