/* Stock-Up · Bright Ledger. Confident chrome, evidence up front. DESIGN.md has the rules.
   Every color and font below is a token; rules further down only ever name a token.
   Contrast (WCAG): text pairs are 4.5:1 or better, marks and meters 3:1 or better, in both themes. */

/* The two faces, self-hosted (DESIGN.md, "Typography"). The build adds each file's content hash. */
@font-face { font-family: "Besley"; font-weight: 400 900; font-style: normal; font-display: swap; src: url("/fonts/besley.woff2?v=f6acafeade") format("woff2"); }
@font-face { font-family: "Hanken Grotesk"; font-weight: 100 900; font-style: normal; font-display: swap; src: url("/fonts/hanken-grotesk.woff2?v=1f21c6eaa0") format("woff2"); }

:root {
  color-scheme: light;
  --page: #faf9f6;
  --surface: #fefefc;
  --surface-2: #f2f0eb;
  --ink: #131b34;
  --ink-2: #454d61;
  --muted: #646a79;
  --grid: #e6e4de;
  --axis: #c2c4cc;
  --border: rgba(19, 27, 52, 0.12);
  --band: #1a3bc9;
  --on-band: #fafcff;
  --on-band-2: #d0defd;
  --mark: #5edb81;
  --accent: #1f43d9;
  --accent-ink: #1a3bc9;
  --on-accent: #ffffff;
  --series-1: #2867e4;
  --series-2: #e86518;
  --series-3: #00a677;
  --good: #009d3a;
  --good-solid: #007b28;
  --good-ink: #00601c;
  --warning: #c37700;
  --warning-ink: #7e4b00;
  --serious: #e65909;
  --serious-solid: #c73700;
  --serious-ink: #a42400;
  --critical: #d42325;
  --critical-ink: #b00c15;
  --wash-good: #d9fadf;
  --wash-accent: #e5f0ff;
  --wash-serious: #ffe9dd;
  --dip-flood: #bdefc9;
  --band-2: #425ed3;
  --band-field: #3552cf;
  --band-line: #5d75d9;
  --accent-hover: #1735b1;
  --on-solid: #ffffff;
  --edge-good: #8dca93;
  --edge-accent: #7b9eef;
  --edge-warning: #e0b487;
  --edge-serious: #f8a887;
  --serious-on-ink: #e65909;
  --focus: var(--accent-ink);
  --shadow-lift: 0 8px 28px rgba(10, 15, 28, 0.26);
  --radius-xs: 4px;
  --radius-s: 8px;
  --radius: 12px;
  --radius-l: 16px;
  --radius-pill: 999px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 28px;
  --space-8: 32px;
  --space-9: 40px;
  --tap-min: 44px;
  --font-sans: "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Besley", ui-serif, "New York", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --dur-press: 80ms;
  --dur: 120ms;
  --dur-flash: 1.6s;
  --mark-shape: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Cpath d='M10 23H23L32 42L41 23H54' fill='none' stroke='%23000' stroke-width='6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

/* Dark follows the device setting. The dark values are written once, here. */
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #0a0f1c;
    --surface: #131928;
    --surface-2: #1e2537;
    --ink: #ebeef5;
    --ink-2: #bdc4d5;
    --muted: #9098ab;
    --grid: #232b3e;
    --axis: #343d54;
    --border: rgba(235, 238, 245, 0.12);
    --band: #0d1f5b;
    --on-band: #f7f8fc;
    --on-band-2: #bbcbec;
    --mark: #5edb81;
    --accent: #3a66ed;
    --accent-ink: #93b5ff;
    --on-accent: #ffffff;
    --series-1: #568ef9;
    --series-2: #f27636;
    --series-3: #2dc08e;
    --good: #0fbd59;
    --good-solid: #007b28;
    --good-ink: #5edb81;
    --warning: #e5a323;
    --warning-ink: #f0ba59;
    --serious: #f3743f;
    --serious-solid: #c73700;
    --serious-ink: #fd9a73;
    --critical: #ed4b43;
    --critical-ink: #fb8276;
    --wash-good: #11331b;
    --wash-accent: #1b2b56;
    --wash-serious: #462314;
    --dip-flood: #17512c;
    --band-2: #374678;
    --band-field: #29396e;
    --band-line: #53608b;
    --accent-hover: #2e52c2;
    --on-solid: #ffffff;
    --edge-good: #206e47;
    --edge-accent: #28428e;
    --edge-warning: #7e6238;
    --edge-serious: #874c3d;
    --serious-on-ink: #c73700;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; overflow-x: clip; }
::selection { background: var(--wash-accent); color: var(--ink); }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 15px/1.5 var(--font-sans);
  overflow-x: clip;
}
a { color: var(--accent-ink); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
h1, h2, h3 { line-height: 1.2; margin: 0; }
h1 { font-family: var(--font-display); font-size: 2rem; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 1.05rem; font-weight: 600; }
p { margin: 0; }
.sub { display: block; color: var(--ink-2); font-size: 0.85rem; font-weight: 400; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--radius-xs); }
.top :focus-visible, .auth > :focus-visible { outline-color: var(--on-band); }

/* --- top bar & tabs ------------------------------------------------------- */
.top { background: var(--band); color: var(--on-band); }
.top-inner, .tabs, main, .foot { max-width: 1080px; margin: 0 auto; padding-left: var(--space-4); padding-right: var(--space-4); }
.top-inner { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-4); align-items: baseline; justify-content: space-between; padding-top: 14px; }
.brand { color: var(--on-band); text-decoration: none; font-family: var(--font-display); font-weight: 700; font-size: 1.25rem; letter-spacing: -0.01em; }
/* The mark, "the dip": a price line that drops, with a green dot at the low. The line is a mask so it
   takes the text color; the dot is a second piece so it can keep its own. Same shapes as favicon.svg. */
.brand, .auth-brand { position: relative; padding-left: 1.6em; }
.brand::before, .auth-brand::before {
  content: ""; position: absolute; left: 0; top: 50%; width: 1.35em; height: 1.35em; transform: translateY(-50%);
  background: currentColor; -webkit-mask: var(--mark-shape) center / contain no-repeat; mask: var(--mark-shape) center / contain no-repeat;
}
.brand::after, .auth-brand::after {
  content: ""; position: absolute; left: 0.675em; top: 50%; width: 0.3em; height: 0.3em; border-radius: 50%;
  transform: translate(-50%, calc(-50% + 0.211em));
  background: var(--mark); box-shadow: 0 0 0 0.075em var(--band);
}
.auth-brand::after { background: var(--good); box-shadow: 0 0 0 0.075em var(--surface); }
.sync { color: var(--on-band-2); font-size: 0.85rem; }
.tabs { display: flex; gap: var(--space-1); overflow-x: auto; margin-top: var(--space-2); scrollbar-width: none; }
.tabs a {
  color: var(--on-band-2); text-decoration: none; padding: 10px var(--space-3) var(--space-2); border-bottom: 3px solid transparent;
  white-space: nowrap; font-weight: 500; transition: color var(--dur) var(--ease-out);
}
.tabs a:hover { color: var(--on-band); }
/* Results and Runs check on the agent; they sit last and a size down from the everyday tabs. */
.tabs a.minor { font-size: 0.85em; }
.tabs a[aria-current="page"] { color: var(--on-band); font-weight: 600; border-bottom-color: var(--on-band); }
.count {
  display: inline-block; min-width: 1.4em; padding: 0 6px; margin-left: 2px; border-radius: var(--radius-pill);
  background: var(--band-2); color: var(--on-band); font-size: 0.8rem; font-weight: 600;
  text-align: center; font-variant-numeric: tabular-nums;
}
.tabs a[aria-current="page"] .count { background: var(--on-band); color: var(--band); }

main { padding-top: var(--space-7); padding-bottom: var(--space-9); }
.intro { margin-bottom: var(--space-5); }
.lede { color: var(--ink-2); margin-top: 6px; max-width: 62ch; }
.crumb { font-size: 0.85rem; margin-bottom: var(--space-1); }
.foot {
  display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); justify-content: space-between;
  color: var(--ink-2); font-size: 0.8rem; padding-top: var(--space-4); padding-bottom: var(--space-8); border-top: 1px solid var(--border);
}
.empty { color: var(--ink-2); padding: var(--space-6) 0; }

/* --- buttons -------------------------------------------------------------- */
button {
  font: inherit; font-size: 0.9rem; font-weight: 500; color: var(--ink); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-s); padding: 7px 13px; cursor: pointer;
  transition: background-color var(--dur) var(--ease-out), transform var(--dur-press) var(--ease-out);
}
button:hover { background: var(--surface-2); }
button:active { transform: translateY(1px); }
button.primary { background: var(--accent); color: var(--on-accent); border-color: transparent; font-weight: 600; }
button.primary:hover { background: var(--accent-hover); }
button.quiet { border-color: transparent; background: transparent; color: var(--ink-2); }
button.quiet:hover { color: var(--ink); background: var(--surface-2); }
/* A link out to a store, drawn as a button. */
a.button {
  display: inline-flex; align-items: center; gap: 6px; font-size: 0.9rem; font-weight: 600; color: var(--accent-ink);
  background: var(--surface); border: 1px solid var(--accent-ink); border-radius: var(--radius-s); padding: 7px 13px;
  text-decoration: none; white-space: nowrap; transition: background-color var(--dur) var(--ease-out);
}
a.button:hover { background: var(--surface-2); }
input, select {
  font: inherit; font-size: 0.9rem; color: var(--ink); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-s); padding: 6px var(--space-2);
}
input:focus-visible, select:focus-visible { border-color: var(--focus); }
input[type="number"] { width: 5.5em; }

/* --- cards ---------------------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 460px), 1fr)); gap: var(--space-4); }
.deal { padding: 18px 18px var(--space-4); display: flex; flex-direction: column; gap: 14px; }
/* The head of a live card is a tinted band, like a shelf tag: the color says what kind of card it is,
   and the badge inside says it again in words. */
.deal:not(.done) { overflow: hidden; }
.deal:not(.done) .deal-head { margin: -18px -18px 0; padding: 14px 18px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.deal--stock_up { border-color: var(--edge-good); }
.deal--capped { border-color: var(--edge-accent); }
.deal--low_supply { border-color: var(--edge-serious); }
.deal--stock_up:not(.done) .deal-head { background: var(--wash-good); }
.deal--capped:not(.done) .deal-head { background: var(--wash-accent); }
.deal--low_supply:not(.done) .deal-head { background: var(--wash-serious); }
.deal.done { border: 1px dashed var(--axis); color: var(--ink-2); padding: var(--space-4) 18px; }
.deal.done strong { color: var(--ink); }
.deal.done { flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; }
.undo { padding: 2px var(--space-2); text-decoration: underline; text-underline-offset: 2px; }
.evidence { margin-top: 10px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.evidence dd { font-weight: 500; }
.evidence dd .sub { display: block; }
.deal-head h2 { font-family: var(--font-display); font-size: 1.5rem; font-weight: 650; letter-spacing: -0.01em; margin-top: 10px; }
.deal-head h2 a { color: var(--ink); text-decoration: none; }
.deal-head h2 a:hover { text-decoration: underline; }
.where { color: var(--ink-2); font-size: 0.85rem; margin-top: 2px; }
.where a { color: var(--ink-2); }
.badge {
  display: inline-flex; gap: 6px; align-items: center; font-size: 0.8rem; font-weight: 600;
  padding: 3px 10px; border-radius: var(--radius-pill); color: var(--ink); background: var(--surface);
}
.tag {
  display: inline-flex; align-items: center; font-size: 0.8rem; font-weight: 600; margin-left: 6px;
  padding: 2px 10px; border-radius: var(--radius-pill); color: var(--ink-2); border: 1px solid var(--border);
}
.badge--stock_up { background: var(--good-solid); color: var(--on-solid); }
.badge--capped { background: var(--accent); color: var(--on-accent); }
.badge--low_supply { background: var(--serious-solid); color: var(--on-solid); }

.price-row { display: flex; flex-wrap: wrap; gap: var(--space-3) var(--space-5); align-items: flex-end; justify-content: space-between; }
/* The decision is the largest thing on a card; the shelf price is evidence beneath it. */
.decision { display: flex; flex-wrap: wrap; gap: 10px var(--space-5); align-items: center; justify-content: space-between; }
.decision .big { font-size: 1.9rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.decision .unit { margin-top: var(--space-1); }
.price .shelf { font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.price .per, .decision .per { color: var(--ink-2); }
.deal .price-row { border-top: 1px solid var(--grid); padding-top: 14px; }
.unit { font-variant-numeric: tabular-nums; }
/* The saving is the one loud number on a card. */
.unit strong { background: var(--wash-good); color: var(--good-ink); padding: 1px 7px; border-radius: var(--radius-s); white-space: nowrap; }
.pct { color: var(--ink-2); font-size: 0.85rem; }
/* The price chart: the first evidence under the decision. Green only where a dip is live. */
.dip { flex: 1 1 100%; margin: 0; min-width: 0; }
.dip-key { display: flex; justify-content: space-between; align-items: flex-end; gap: var(--space-3); margin-bottom: var(--space-2); font-size: 0.8125rem; line-height: 1.3; font-variant-numeric: tabular-nums; }
.dip-usual { color: var(--muted); display: flex; align-items: center; gap: 6px; min-width: 0; }
.dip-usual::before { content: ""; flex: none; width: 18px; border-top: 1.5px dashed var(--muted); }
.dip-now { flex: none; text-align: right; white-space: nowrap; }
.dip-now b { font-size: 1.125rem; }
.dip-now--live { color: var(--good-ink); }
.dip-plot { position: relative; height: 140px; margin-right: var(--space-2); border-bottom: 1px solid var(--axis); }
svg.dip-svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; overflow: visible; }
svg.dip-svg .past { fill: var(--surface-2); }
svg.dip-svg .flood { fill: var(--dip-flood); }
svg.dip-svg .ref { stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 5 4; vector-effect: non-scaling-stroke; }
svg.dip-svg .line { fill: none; stroke: var(--accent-ink); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.dip-dot { position: absolute; width: 12px; height: 12px; border-radius: var(--radius-pill); transform: translate(-50%, -50%); background: var(--surface); border: 2.5px solid var(--accent-ink); }
.dip-dot--live { width: 14px; height: 14px; border: 0; background: var(--good); box-shadow: 0 0 0 3px var(--surface); }
.dip-months { position: relative; height: 1.5em; margin-right: var(--space-2); font-size: 0.8rem; color: var(--muted); }
.dip-months span { position: absolute; top: var(--space-1); transform: translateX(-50%); }

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px var(--space-4); margin: 0; }
.facts div { min-width: 0; }
.facts dt { color: var(--muted); font-size: 0.8rem; font-weight: 500; }
.facts dd { margin: 2px 0 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.facts dd .sub { display: inline; font-weight: 400; }
.reason { line-height: 1.45; }
.rationale { color: var(--ink-2); font-size: 0.9rem; padding: 10px var(--space-3); background: var(--surface-2); border-radius: var(--radius-s); }
.rationale .label { display: block; color: var(--muted); font-size: 0.8rem; font-weight: 600; }
.actions { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
/* How many packs "Bought it" will log: one fewer, the number, one more. */
.packs { display: inline-flex; align-items: center; gap: var(--space-1); }
.actions .packs button { flex: 0 0 auto; min-width: 36px; padding-inline: 0; font-weight: 600; }
.packs button[disabled] { cursor: default; }
.packs-n { min-width: 7ch; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; }

/* What could make the cards wrong or missing. Amber is "watch this"; the icon and heading say so too. */
.notice { padding: 14px 18px; margin-bottom: var(--space-6); border-color: var(--edge-warning); }
.notice h2 { font-size: 1rem; font-weight: 650; color: var(--warning-ink); }
.notice ul { margin: var(--space-2) 0 0; padding-left: 18px; }
.notice li { margin: var(--space-1) 0; line-height: 1.45; }
.notice .sub { margin-top: var(--space-2); }
.stale { color: var(--warning-ink); font-size: 0.85rem; font-weight: 600; margin-top: 6px; }

/* One section per store: the trip, what it costs and what it saves. */
.trip + .trip { margin-top: var(--space-7); }
.trip-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px var(--space-3); margin-bottom: 10px; }
.trip-head h2 { font-size: 1.125rem; font-weight: 700; }
.trip-head .sub { display: inline; font-variant-numeric: tabular-nums; }

.skips { margin-top: var(--space-7); }
.skips ul { margin: var(--space-2) 0 0; padding-left: 18px; color: var(--ink-2); }
.skips li { margin: var(--space-1) 0; }
.buy-at { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* --- tables --------------------------------------------------------------- */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 10px var(--space-3); border-bottom: 1px solid var(--grid); vertical-align: top; }
thead th { background: var(--surface-2); color: var(--ink-2); font-size: 0.8rem; font-weight: 600; white-space: nowrap; }
tbody tr:last-child > * { border-bottom: none; }
tbody th { font-weight: 600; }
th.num, td.num { text-align: right; }
td.gain { color: var(--good-ink); }
td.loss { color: var(--critical-ink); }

.pantry tbody th a { color: var(--ink); text-decoration: none; }
.pantry tbody th a:hover { text-decoration: underline; }
.pantry td, .pantry th { vertical-align: middle; }
.days { display: flex; align-items: center; gap: var(--space-2); }
.meter { display: inline-block; width: 64px; height: 8px; border-radius: var(--radius-xs); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--border); overflow: hidden; flex: none; }
.meter > span { display: block; height: 100%; border-radius: var(--radius-xs); }
.meter--good > span { background: var(--good); }
.meter--warning > span { background: var(--warning); }
.meter--critical > span { background: var(--critical); }
.conf { font-weight: 600; text-transform: capitalize; }
.update { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.count-form { display: flex; gap: 6px; align-items: center; }
.count-form label, .count-unit { color: var(--ink-2); white-space: nowrap; }
.count-form select { max-width: 11em; }
tr.flash > * { animation: flash var(--dur-flash) ease-out; }
@keyframes flash { from { background: var(--wash-good); } to { background: transparent; } }

/* --- review --------------------------------------------------------------- */
.review-group { margin-bottom: var(--space-6); }
.review-list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 10px; }
.review-item { display: flex; flex-wrap: wrap; gap: var(--space-3) var(--space-5); justify-content: space-between; align-items: center; padding: 14px var(--space-4); }
.review-item .title { font-weight: 600; }
.review-item.done { color: var(--ink-2); border-style: dashed; }
.review-item.done .sub { display: inline; }

/* --- item, experiment ----------------------------------------------------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: var(--space-3); margin-bottom: var(--space-5); }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px var(--space-4); }
.tile-label { color: var(--ink-2); font-size: 0.85rem; }
.tile-value { font-size: 1.7rem; font-weight: 700; letter-spacing: -0.015em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.panel { margin-top: var(--space-6); }
.panel > h2 { margin-bottom: var(--space-1); }
.panel > .sub { margin-bottom: 10px; max-width: 72ch; }
.panel > .table-wrap, .panel > .chart-wrap { margin-top: 10px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px var(--space-4); list-style: none; margin: var(--space-2) 0 0; padding: 0; color: var(--ink-2); font-size: 0.85rem; }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.swatch.ring { background: transparent; border: 2px solid var(--ink); }
.settings { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; margin-top: 10px; }
.settings label { color: var(--ink-2); display: inline-flex; gap: 6px; align-items: center; }
.settings input[type="text"] { width: 11em; }
.pills { display: flex; flex-wrap: wrap; gap: var(--space-2); list-style: none; padding: 0; margin: 10px 0 0; }
.pills li { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-pill); padding: var(--space-1) var(--space-3); font-weight: 600; font-variant-numeric: tabular-nums; }
.pills .sub { display: inline; margin-right: var(--space-1); }
.status { font-weight: 600; }
/* Never color alone: each status carries a glyph before its word. */
.status::before { display: inline-block; width: 1.1em; }
.status--ok { color: var(--good-ink); }
.status--ok::before { content: "✓"; }
.status--partial { color: var(--warning-ink); }
.status--partial::before { content: "!"; }
.status--failed { color: var(--critical-ink); }
.status--failed::before { content: "✕"; }

/* --- charts --------------------------------------------------------------- */
.chart-wrap { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px var(--space-2) var(--space-1); }
svg.chart { width: 100%; height: auto; display: block; overflow: visible; }
svg.chart .grid { stroke: var(--grid); stroke-width: 1; }
svg.chart .axis { stroke: var(--axis); stroke-width: 1; }
svg.chart .ref { stroke: var(--ink-2); stroke-width: 1; opacity: 0.7; }
svg.chart .today { stroke: var(--axis); stroke-width: 1; }
svg.chart .tick { fill: var(--muted); font-size: 11px; font-family: var(--font-sans); font-variant-numeric: tabular-nums; }
svg.chart .pt { stroke: var(--surface); stroke-width: 2; }
svg.chart .paid { fill: none; stroke: var(--ink); stroke-width: 2; }
svg.chart .line { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
svg.chart .line.projected { opacity: 0.4; }
svg.chart .wash { fill: var(--series-1); opacity: 0.1; }
svg.chart .dot { fill: var(--series-1); stroke: var(--surface); stroke-width: 2; }
svg.chart .xhair { stroke: var(--axis); stroke-width: 1; pointer-events: none; }
svg.chart .focus-ring { fill: none; stroke: var(--ink); stroke-width: 2; pointer-events: none; }
.chart-tip {
  position: absolute; pointer-events: none; z-index: 2; white-space: nowrap;
  background: var(--ink); color: var(--surface); font-size: 0.8rem; padding: 5px var(--space-2); border-radius: var(--radius-s);
  font-variant-numeric: tabular-nums;
}

@media (max-width: 560px) {
  h1 { font-size: 1.55rem; }
  .decision .big { font-size: 1.6rem; }
  .decision a.button { flex: 1 1 100%; justify-content: center; min-height: var(--tap-min); }
  .actions button { flex: 1 1 auto; }

  /* Pantry on a phone: each row is a small card, so the count box is on screen, not a scroll away.
     The column heads are hidden from view and each cell carries its own label instead. */
  .pantry, .pantry tbody, .pantry tbody th, .pantry tbody td { display: block; }
  .pantry thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .pantry tbody tr { display: grid; grid-template-columns: 1fr 1fr; gap: 10px var(--space-4); padding: 14px var(--space-3); border-bottom: 1px solid var(--grid); }
  .pantry tbody tr:last-child { border-bottom: none; }
  .pantry tbody tr > * { padding: 0; border-bottom: none; text-align: left; min-width: 0; }
  .pantry tbody th, .pantry .update-cell, .pantry td[colspan] { grid-column: 1 / -1; }
  .pantry tbody th { font-size: 1rem; }
  .pantry td[data-label]::before { content: attr(data-label); display: block; color: var(--muted); font-size: 0.8rem; font-weight: 400; }
  .pantry .meter { flex: 1 1 auto; max-width: 96px; }
  .pantry tr.flash { animation: flash var(--dur-flash) ease-out; }
  .pantry tr.flash > * { animation: none; }
  .pantry .count-form { flex: 1 1 100%; }
  .pantry .update > button { flex: 1 1 100%; }
  .pantry .count-form { flex-wrap: wrap; }
  .pantry .count-form label { flex: 1 1 7em; display: flex; align-items: center; gap: 6px; }
  .pantry .count-form select { flex: 1 1 8em; max-width: none; }
  .pantry .count-form input { flex: 1 1 auto; min-width: 0; width: auto; }
  .pantry .update button, .pantry .count-form input, .pantry .count-form select { min-height: var(--tap-min); }
}

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

@media (forced-colors: active) {
  .meter > span, .swatch { forced-color-adjust: none; }
}

/* --- static page additions (web/app.js, web/signin.js) ---------------------------- */
[hidden] { display: none !important; }
.loading { color: var(--ink-2); padding: var(--space-6) 0; }
.foot button.quiet { font-size: 0.8rem; padding: 0; color: var(--muted); text-decoration: underline; text-underline-offset: 2px; }
.foot button.quiet:hover { background: transparent; color: var(--ink); }
button[disabled] { opacity: 0.6; cursor: progress; }
.saved { color: var(--good-ink); }
.saved [aria-hidden] { margin-right: var(--space-1); }
.form-note { font-size: 0.85rem; color: var(--ink-2); }
.form-note.bad { color: var(--critical-ink); }
.problem { display: flex; flex-wrap: wrap; gap: 10px var(--space-4); align-items: center; padding: var(--space-4) 18px; }

/* Toasts: a short line after a tap, bottom center. */
.toasts {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 20;
  display: grid; gap: var(--space-2); width: min(440px, calc(100% - 32px)); pointer-events: none;
}
.toast {
  background: var(--ink); color: var(--surface); border-radius: var(--radius-s); padding: 10px 14px;
  font-size: 0.9rem; box-shadow: var(--shadow-lift); pointer-events: auto;
}
.toast [aria-hidden] { margin-right: 6px; }
.toast--error [aria-hidden] { color: var(--serious-on-ink); }

/* Sign-in screen: one card in the middle of the page. */
.auth { min-height: 100vh; display: grid; padding: var(--space-6) var(--space-4); background: var(--band); }
.auth-card {
  margin: auto; width: 100%; max-width: 380px; display: grid; gap: 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-l); padding: var(--space-6) var(--space-6);
  box-shadow: var(--shadow-lift);
}
.auth-brand { color: var(--accent-ink); font-family: var(--font-display); font-weight: 700; font-size: 1.25rem; letter-spacing: -0.01em; }
.auth-h { font-family: var(--font-display); font-size: 1.5rem; font-weight: 650; letter-spacing: -0.015em; }
.auth-h:focus { outline: none; }
.auth-muted { color: var(--ink-2); }
.auth-small { color: var(--ink-2); font-size: 0.85rem; }
.auth-bad { color: var(--critical-ink); font-size: 0.85rem; font-weight: 500; }
.auth-field { display: grid; gap: 6px; color: var(--ink-2); font-size: 0.85rem; font-weight: 500; }
.auth-field input { width: 100%; font-size: 1rem; padding: var(--space-2) 10px; }
.auth-field input[aria-invalid="true"] { border-color: var(--critical); box-shadow: 0 0 0 1px var(--critical); }
.auth-card button.primary { width: 100%; min-height: 40px; }
.auth-row { display: flex; flex-wrap: wrap; gap: 10px var(--space-4); align-items: center; }
.auth-addr { font-weight: 600; overflow-wrap: anywhere; }
.auth-link { padding: 0; border: 0; background: none; color: var(--accent-ink); text-decoration: underline; text-underline-offset: 2px; }
.auth-link:hover { background: none; }
@media (max-width: 560px) { .auth-card { padding: 18px var(--space-4); } }

/* Household: the header switcher (only for someone in several) and the Household tab. */
.hh:empty { display: none; }
.hh-pick { display: inline-flex; gap: var(--space-2); align-items: baseline; color: var(--on-band-2); font-size: 0.85rem; }
.hh-pick select {
  background: var(--band-field); color: var(--on-band);
  border-color: var(--band-line); max-width: 16em;
}
.hh-pick option { color: var(--ink); background: var(--surface); }
.hh-card { padding: var(--space-4) 18px; }
.hh-card > h2 { margin-bottom: 6px; }
.hh-card > p + .actions, .hh-card > p + .settings { margin-top: 10px; }
.hh-card .settings input[type="email"] { width: 16em; }
.hh-members { list-style: none; padding: 0; margin: 0; }
.hh-members li { display: flex; flex-wrap: wrap; gap: var(--space-1) 10px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--grid); }
.hh-members .sub { display: inline; }
.hh-members button { margin-left: auto; }
code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 0.85em; overflow-wrap: anywhere; }
.secret { margin-top: 14px; padding: var(--space-3) 14px; border-radius: var(--radius-s); background: var(--wash-accent); display: grid; gap: 10px; }
.secret-row { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.secret-row input { flex: 1 1 18em; min-width: 0; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 0.8rem; }
.secret-parts { display: grid; grid-template-columns: auto 1fr; gap: var(--space-1) var(--space-3); margin: 0; }
.secret-parts dt { color: var(--ink-2); }
.secret-parts dd { margin: 0; }

/* Touch: every control is at least --tap-min tall. Text-style buttons are left alone. */
@media (pointer: coarse) {
  button, a.button, input, select { min-height: var(--tap-min); }
  .actions .packs button { min-width: var(--tap-min); }
  .foot button.quiet, .auth-link, .undo { min-height: 0; }
}
