:root {
  --bg: #f4f1ea; --card: #fffdf8; --ink: #1d221f; --muted: #66706a; --line: #e2ddd0;
  --brand: #1f3a2e; --brand-2: #2f5a45; --accent: #c98f3c; --gold: #e8c26a;
  --ok: #2e7d4f; --warn: #b7791f; --bad: #b3261e; --okbg: #e3f1e8; --warnbg: #fbf0d9; --badbg: #fae3e1;
  --radius: 14px; --shadow: 0 1px 2px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.04);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #121614; --card: #1b201d; --ink: #e9ece9; --muted: #9aa49e; --line: #2c332f;
    --brand: #8fc4a5; --brand-2: #6fa486; --okbg: #183022; --warnbg: #33290f; --badbg: #3a1714; --shadow: none; }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink);
  padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
a { color: var(--brand-2); }
h1 { font-size: 1.5rem; margin: .2rem 0 1rem; }
h2 { font-size: 1.1rem; margin: 1.4rem 0 .6rem; }
h3 { font-size: 1rem; margin: 0 0 .3rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

header.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 1rem;
  background: #1f3a2e; color: #fff; padding: .6rem 1rem; padding-top: calc(.6rem + env(safe-area-inset-top)); }
.brand { display: flex; align-items: center; gap: .5rem; color: #fff; text-decoration: none; font-weight: 700; font-size: 1.1rem; }
.tabs { display: none; gap: .2rem; margin-left: auto; }
.tabs a { color: #dfe9e3; text-decoration: none; padding: .4rem .75rem; border-radius: 99px; }
.tabs a.on { background: rgba(255,255,255,.16); color: #fff; }
nav.bottom { position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; display: flex; background: var(--card);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
nav.bottom a { flex: 1; display: flex; flex-direction: column; align-items: center; padding: .45rem 0 .5rem; text-decoration: none;
  color: var(--muted); font-size: .75rem; }
nav.bottom .ic { font-size: 1.3rem; line-height: 1.2; }
nav.bottom a.on { color: var(--brand-2); font-weight: 600; }
nav.bottom a.scanbtn .ic { background: var(--accent); color: #fff; border-radius: 50%; width: 44px; height: 44px; display: grid;
  place-items: center; margin-top: -18px; box-shadow: 0 2px 8px rgba(0,0,0,.2); }
@media (min-width: 900px) {
  .tabs { display: flex; }
  nav.bottom { display: none; }
  body { padding-bottom: 2rem; }
}

main { max-width: 980px; margin: 0 auto; padding: 1rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); margin-bottom: .8rem; }
.grid { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.grid2 { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.stat { text-align: left; text-decoration: none; color: inherit; display: block; }
.stat b { display: block; font-size: 1.9rem; line-height: 1.1; }
.stat.bad b { color: var(--bad); } .stat.warn b { color: var(--warn); } .stat.ok b { color: var(--ok); }

.row { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: .7rem; padding: .7rem .2rem; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .name { font-weight: 600; overflow-wrap: anywhere; }
.list li.click { cursor: pointer; }
.qty { font-variant-numeric: tabular-nums; font-weight: 700; min-width: 2.5ch; text-align: right; }

.pill { display: inline-block; padding: .1rem .55rem; border-radius: 99px; font-size: .78rem; font-weight: 600; background: var(--line); color: var(--ink); white-space: nowrap; }
.pill.ok { background: var(--okbg); color: var(--ok); } .pill.warn { background: var(--warnbg); color: var(--warn); } .pill.bad { background: var(--badbg); color: var(--bad); }

button, .btn { font: inherit; border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 10px;
  padding: .55rem .95rem; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: .35rem; min-height: 42px; }
button.primary, .btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
@media (prefers-color-scheme: dark) { button.primary, .btn.primary { color: #0d1410; } }
button.danger { color: var(--bad); }
button.sm { padding: .25rem .6rem; min-height: 34px; font-size: .9rem; }
button:disabled { opacity: .5; cursor: default; }
input, select, textarea { font: inherit; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--ink); min-height: 42px; width: 100%; }
label { display: block; font-size: .85rem; color: var(--muted); margin: .6rem 0 .2rem; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.seg { display: flex; background: var(--line); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { flex: 1; border: 0; background: transparent; border-radius: 9px; min-height: 44px; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.seg.mode button.on[data-m="use"] { background: #b3261e; color: #fff; }
.seg.mode button.on[data-m="add"] { background: #2e7d4f; color: #fff; }
.seg.mode button.on[data-m="move"] { background: #c98f3c; color: #fff; }
.chips { display: flex; gap: .4rem; overflow-x: auto; padding-bottom: .3rem; }
.chips button { border-radius: 99px; white-space: nowrap; min-height: 36px; }
.chips button.on { background: var(--brand); color: #fff; border-color: var(--brand); }

#reader { width: 100%; max-width: 520px; margin: .6rem auto; border-radius: var(--radius); overflow: hidden; background: #000; }
#reader:empty { display: none; }
#reader video { width: 100% !important; display: block; }
.cam-view { position: relative; aspect-ratio: 4 / 3; background: #000; }
.cam-view video { position: absolute; inset: 0; width: 100%; height: 100% !important; object-fit: cover; }
.cam-frame { position: absolute; left: 5%; right: 5%; top: 25%; bottom: 25%; border: 3px solid rgba(255,255,255,.9); border-radius: 10px; box-shadow: 0 0 0 999px rgba(0,0,0,.28); transition: border-color .15s; pointer-events: none; }
.cam-frame.hit { border-color: #34c759; }
.cam-frame.paused { border-color: rgba(255,255,255,.35); }
.cam-hint { margin: .4rem .8rem .6rem; color: #ddd; }
.scanbox { text-align: center; }
.last-scan { border-left: 5px solid var(--ok); }
.last-scan.err { border-left-color: var(--bad); }
.last-scan.add { border-left-color: var(--ok); }
.last-scan.move { border-left-color: var(--accent); }
.big-name { font-size: 1.15rem; font-weight: 700; }
.thumb { width: 48px; height: 48px; object-fit: contain; border-radius: 8px; background: #fff; flex: none; }

dialog { border: 0; border-radius: var(--radius); padding: 0; width: min(560px, 94vw); max-height: 90vh; background: var(--card); color: var(--ink); }
dialog::backdrop { background: rgba(0,0,0,.45); }
#modal-body { padding: 1.1rem; }
.modal-actions { display: flex; gap: .5rem; justify-content: flex-end; margin-top: 1rem; flex-wrap: wrap; }

#toast { position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 50;
  background: #1d221f; color: #fff; padding: .7rem 1rem; border-radius: 12px; display: none; align-items: center; gap: .8rem;
  box-shadow: 0 4px 16px rgba(0,0,0,.3); max-width: 92vw; }
#toast.show { display: flex; }
#toast button { background: transparent; color: var(--gold); border: 0; font-weight: 700; min-height: 0; padding: .2rem .4rem; }
.empty { text-align: center; color: var(--muted); padding: 1.5rem; }
.meal .tags { margin-top: .4rem; }
.check { flex: none !important; width: 26px !important; height: 26px; min-height: 0; flex: none; accent-color: var(--brand-2); }
li.done .name { text-decoration: line-through; color: var(--muted); }
.notice { background: var(--warnbg); color: var(--ink); border-radius: 12px; padding: .8rem 1rem; margin: .6rem 0; font-size: .92rem; }
@media print {
  header.top, nav.bottom, .noprint { display: none !important; }
  body { background: #fff; padding: 0; } .card { box-shadow: none; border: 0; }
}
label.row { flex-wrap: nowrap; align-items: flex-start; }
label.row span { flex: 1; }

/* ---- v2: snapshot, tiles, tags, list builder ---- */
.seg.mode button { font-size: .9rem; padding: 0 .2rem; }
.seg.mode button.on[data-m="bulk"] { background: #2f5a45; color: #fff; }
.seg.mode button.on[data-m="info"] { background: #44546a; color: #fff; }
.small-seg { padding: 2px; }
.small-seg button { min-height: 36px; padding: 0 .7rem; font-size: 1.05rem; }
.chips.wrap { flex-wrap: wrap; overflow: visible; }
.chips a.chip, .chips .needbtn { display: inline-flex; gap: .3rem; align-items: center; padding: .4rem .75rem; border-radius: 99px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); text-decoration: none; white-space: nowrap; font-size: .9rem; min-height: 36px; }
.chips a.chip.bad { border-color: var(--bad); color: var(--bad); background: var(--badbg); }
.chips a.chip.warn { border-color: var(--warn); color: var(--warn); background: var(--warnbg); }
.chips .needbtn.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.tag { display: inline-block; padding: .12rem .55rem; border-radius: 99px; font-size: .78rem; background: #e7efe9; color: #2f5a45;
  margin: .15rem .2rem 0 0; text-decoration: none; white-space: nowrap; }
.tag.bad { background: var(--badbg); color: var(--bad); } .tag.warn { background: var(--warnbg); color: var(--warn); } .tag.ok { background: var(--okbg); color: var(--ok); }
@media (prefers-color-scheme: dark) { .tag { background: #20342a; color: #a9d4ba; } }
.tagbtn { min-height: 32px; padding: .2rem .65rem; border-radius: 99px; font-size: .85rem; margin: 0 .3rem .3rem 0; }
.tagbtn.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.locgrid { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.loccard { text-decoration: none; color: inherit; display: flex; flex-direction: column; gap: .35rem; margin: 0; }
.loccard h3 { margin: 0; }
.mini-stats { display: flex; gap: .25rem; flex-wrap: wrap; margin-top: auto; }
.bigcount { padding: .6rem 0; } .bigcount b { display: block; font-size: 2.4rem; line-height: 1; } .bigcount span { font-size: .85rem; color: var(--muted); }
.ring { position: relative; width: 112px; height: 112px; margin: .2rem auto; }
.ring svg { width: 100%; height: 100%; }
.ring circle { fill: none; stroke-width: 10; } .ring .track { stroke: var(--line); }
.ring .bar { stroke-linecap: round; } .ring.ok .bar { stroke: var(--ok); } .ring.warn .bar { stroke: #d39b2a; } .ring.bad .bar { stroke: var(--bad); }
.ring-text { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring-text b { font-size: 1.7rem; line-height: 1; } .ring-text b small { font-size: .9rem; color: var(--muted); font-weight: 600; } .ring-text span { font-size: .72rem; color: var(--muted); }
.listlink { text-decoration: none; color: inherit; margin-top: .7rem; }
.timeline { display: block; text-decoration: none; color: inherit; }
.tl-row { display: grid; grid-template-columns: 7.5rem 1fr 2.5rem; align-items: center; gap: .5rem; margin: .35rem 0; font-size: .9rem; }
.tl-row b { text-align: right; font-variant-numeric: tabular-nums; }
.tl-bar { height: 12px; background: var(--line); border-radius: 99px; overflow: hidden; }
.tl-bar i { display: block; height: 100%; border-radius: 99px; background: #8aa39a; min-width: 2px; }
.tl-bar i.ok { background: var(--ok); } .tl-bar i.warn { background: #d39b2a; } .tl-bar i.bad { background: var(--bad); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: .6rem; }
.tile { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: .55rem .5rem .5rem;
  text-align: center; border-bottom: 5px solid var(--ok); cursor: pointer; }
.tile.warn { border-bottom-color: #d39b2a; } .tile.bad { border-bottom-color: var(--bad); }
.tile .thumb { margin: 0 auto; display: block; }
.tile .badge { position: absolute; top: .35rem; right: .35rem; background: var(--brand); color: #fff; border-radius: 99px; min-width: 1.6rem;
  padding: 0 .35rem; font-weight: 700; font-size: .85rem; line-height: 1.6rem; }
@media (prefers-color-scheme: dark) { .tile .badge { color: #0d1410; } }
.tile.bad .badge { background: var(--bad); color: #fff; }
.tname { font-size: .8rem; font-weight: 600; line-height: 1.2; margin-top: .35rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tsub { font-size: .72rem; color: var(--muted); }
.thumb.icon { display: inline-grid; place-items: center; background: var(--line); border-radius: 10px; flex: none; }
.fab { position: fixed; right: 18px; bottom: calc(92px + env(safe-area-inset-bottom)); width: 54px; height: 54px; border-radius: 50%;
  background: var(--brand); color: #fff; display: grid; place-items: center; font-size: 1.8rem; text-decoration: none; box-shadow: 0 3px 10px rgba(0,0,0,.25); z-index: 5; }
@media (min-width: 900px) { .fab { bottom: 28px; } }
dl.info { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem .8rem; margin: .4rem 0; }
dl.info div { min-width: 0; } dl.info dt { font-size: .75rem; color: var(--muted); } dl.info dd { margin: 0; font-size: .9rem; overflow-wrap: anywhere; }
.savebar { position: sticky; bottom: calc(70px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--bg) 30%); padding: .8rem 0 .4rem; z-index: 4; }
.savebar button { width: 100%; justify-content: center; min-height: 50px; font-size: 1.05rem; }
@media (min-width: 900px) { .savebar { bottom: 0; } }
.qtyin { width: 3.6rem; min-height: 36px; padding: .2rem .4rem; text-align: center; flex: none; }
.stepper { display: flex; flex-direction: column; align-items: center; gap: .15rem; }
.stepper button { min-height: 30px; width: 36px; justify-content: center; padding: 0; }
ul.bulk li { align-items: flex-start; }
.warnbtn { background: var(--warnbg); border-color: var(--warn); color: var(--warn); font-weight: 600; }
.locset { border-bottom: 1px solid var(--line); padding-bottom: .6rem; margin-bottom: .6rem; }
details summary { cursor: pointer; color: var(--brand-2); }
#modal-body h2 { font-size: 1rem; margin: 1.1rem 0 .4rem; }

/* first run */
.welcome { max-width: 560px; margin: 0 auto; text-align: left; }
.welcome > img { display: block; margin: 1rem auto .5rem; }
.welcome h1 { text-align: center; }
.center { text-align: center; }
.tplgrid { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.tpl { display: flex; flex-direction: column; align-items: flex-start; gap: .2rem; text-align: left; padding: .8rem; height: auto;
  background: var(--card); border: 2px solid var(--line); border-radius: var(--radius); color: var(--ink); }
.tpl.on { border-color: var(--accent); background: var(--warnbg); }
button.big { width: 100%; padding: .9rem; font-size: 1.05rem; margin: .4rem 0 1rem; }
.linklike { color: var(--brand-2); text-decoration: underline; cursor: pointer; }
.row.wrap { flex-wrap: wrap; }
@media (max-width: 360px) { .tplgrid { grid-template-columns: 1fr; } }

/* ================= v3 theme: the pantry look ================= */
:root {
  --bg: #f5efe3; --card: #fffcf5; --ink: #20261f; --muted: #6b7268; --line: #e4dccb;
  --brand: #1d3b2f; --brand-2: #2c5a45; --accent: #c8862e; --gold: #e8c26a;
  --wood: #b98a56; --wood-2: #8f653a; --wood-hi: #d3a877;
  --radius: 18px; --shadow: 0 1px 2px rgba(60,40,10,.06), 0 6px 18px rgba(60,40,10,.06);
  --display: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #10140f; --card: #1a1f19; --ink: #ecebe3; --muted: #9da496; --line: #2b322a;
    --brand: #8fc4a5; --brand-2: #7fb898; --wood: #6b4c2c; --wood-2: #4a3420; --wood-hi: #86623c; --shadow: none; }
}
body { background: var(--bg); -webkit-font-smoothing: antialiased; }
h1, h2, h3, .brand, .big-name { font-family: var(--display); letter-spacing: -.01em; }
h1 { font-size: 1.75rem; } h2 { font-size: 1.2rem; margin-top: 1.6rem; } h3 { font-size: 1.08rem; }
header.top { background: linear-gradient(180deg, #17322a, #1d3b2f); box-shadow: 0 1px 0 rgba(0,0,0,.2); }
.brand { font-size: 1.25rem; }
.card { border-radius: var(--radius); }
button, .btn, input, select, textarea { border-radius: 12px; }
button.primary, .btn.primary { background: linear-gradient(180deg, #2c5a45, #1d3b2f); border-color: #1d3b2f; color: #fff; box-shadow: 0 2px 6px rgba(29,59,47,.25); }
@media (prefers-color-scheme: dark) { button.primary, .btn.primary { color: #fff; } }
.chips button.on, .tagbtn.on, .chips .needbtn.on { background: #1d3b2f; border-color: #1d3b2f; color: #fff; }
.tile .badge { background: #1d3b2f; color: #fff; }
.fab { background: linear-gradient(180deg, #d4963a, #b9772a); }

nav.bottom { border-top: 0; box-shadow: 0 -2px 16px rgba(40,30,10,.1); border-radius: 20px 20px 0 0; }
nav.bottom .ic { display: grid; place-items: center; height: 26px; }
nav.bottom a { font-size: .72rem; gap: .1rem; }
nav.bottom a.scanbtn .ic { width: 54px; height: 54px; margin-top: -26px; background: linear-gradient(180deg, #d99a3d, #b9772a);
  border: 4px solid var(--bg); box-shadow: 0 4px 12px rgba(150,90,20,.35); }
nav.bottom a.scanbtn .ic svg { width: 26px; height: 26px; }

/* hero */
.hero { display: flex; align-items: center; gap: 1rem; padding: 1.1rem 1.2rem; border-radius: 24px; color: #fff; text-decoration: none; margin-bottom: 1rem;
  background: radial-gradient(120% 140% at 0% 0%, #2f6a50 0%, #1d3b2f 55%, #142a22 100%); box-shadow: 0 10px 28px rgba(20,42,34,.28); position: relative; overflow: hidden; }
.hero::after { content: ""; position: absolute; right: -40px; top: -40px; width: 180px; height: 180px; border-radius: 50%; background: rgba(232,194,106,.12); }
.hero .supplyjar { flex: none; filter: drop-shadow(0 6px 10px rgba(0,0,0,.25)); }
.hero-text { flex: 1; min-width: 0; position: relative; z-index: 1; }
.eyebrow { text-transform: uppercase; letter-spacing: .09em; font-size: .7rem; font-weight: 700; color: var(--gold); }
.hero-num { font-family: var(--display); font-size: 3.4rem; line-height: 1; font-weight: 700; }
.hero-num small { font-size: 1rem; font-weight: 500; opacity: .85; font-family: system-ui, sans-serif; }
.hero-sub { opacity: .85; font-size: .9rem; margin-bottom: .6rem; }
.hero-note { font-size: .75rem; opacity: .7; margin-top: .35rem; }
.waterbar { display: grid; grid-template-columns: auto 1fr auto; gap: .5rem; align-items: center; font-size: .78rem; }
.waterbar i { height: 8px; border-radius: 99px; background: rgba(255,255,255,.18); overflow: hidden; display: block; }
.waterbar i b { display: block; height: 100%; background: #6fc0ee; border-radius: 99px; min-width: 3px; }
.hero.stats { justify-content: space-around; text-align: center; }
.hero.stats b { display: block; font-family: var(--display); font-size: 2.4rem; line-height: 1.05; }
.hero.stats span { font-size: .78rem; opacity: .85; }

/* use-first scroller */
.scroller { display: flex; gap: .6rem; overflow-x: auto; padding: .1rem .1rem .5rem; scroll-snap-type: x proximity; margin: 0 -1rem; padding-left: 1rem; padding-right: 1rem; }
.scroller::-webkit-scrollbar { display: none; }
.soon { flex: none; width: 124px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: .7rem .6rem; text-align: center;
  scroll-snap-align: start; box-shadow: var(--shadow); cursor: pointer; }
.soon .thumb { margin: 0 auto .3rem; display: grid; }
.soon .pill { margin-top: .3rem; }

/* shelves */
.shelfcard { padding: 0; overflow: hidden; }
.shelfhead { padding: .9rem 1rem .5rem; text-decoration: none; color: inherit; align-items: flex-start; flex-wrap: nowrap; }
.shelfhead h3 { margin: 0; }
.shelfhead .mini-stats { justify-content: flex-end; margin: 0; }
.shelf { --row: 118px; display: grid; grid-template-columns: repeat(4, 1fr); grid-auto-rows: var(--row); padding: 0 .5rem;
  background:
    repeating-linear-gradient(to bottom, transparent 0 78px, var(--wood-hi) 78px 80px, var(--wood) 80px 88px, var(--wood-2) 88px 91px, rgba(0,0,0,.07) 91px 96px, transparent 96px var(--row)),
    linear-gradient(180deg, color-mix(in srgb, var(--wood) 9%, var(--card)), var(--card)); }
.slot { display: flex; flex-direction: column; align-items: center; text-decoration: none; color: inherit; min-width: 0; }
.slot .stack { height: 79px; display: flex; align-items: flex-end; justify-content: center; position: relative; }
.slot .stack .vessel { margin: 0 -7px; filter: drop-shadow(0 1px 0 rgba(0,0,0,.18)); }
.slot .stack .gone { opacity: .28; filter: grayscale(1); display: flex; }
.slot .count { position: absolute; top: 2px; right: -10px; min-width: 1.5rem; padding: 0 .3rem; line-height: 1.5rem; border-radius: 99px; font-size: .78rem; text-align: center;
  background: #1d3b2f; color: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); font-variant-numeric: tabular-nums; }
.slot .count.warn { background: #c8862e; } .slot .count.bad { background: var(--bad); }
.slot .slabel { margin-top: 20px; font-size: .68rem; font-weight: 600; color: var(--muted); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 .15rem; }
.shelf.empty { grid-template-columns: auto 1fr; align-items: start; }
.slot.ghost { opacity: .35; filter: grayscale(1); width: 80px; }
.shelfcta { align-self: start; margin-top: 26px; font-weight: 600; }
@media (min-width: 700px) { .shelf { grid-template-columns: repeat(8, 1fr); } }

.thumb.icon { background: color-mix(in srgb, var(--wood) 16%, var(--card)); border-radius: 12px; }
.thumb { border-radius: 12px; }
.listlink svg { color: var(--accent); }
#catf { margin: .2rem 0 .5rem; } #catf:empty { display: none; }
.tl-row .tl-l svg { flex: none; }

/* welcome */
.welcome-art { border-radius: 24px; overflow: hidden; margin: .5rem 0 1rem; border: 1px solid var(--line); background: var(--card); }
.welcome-art .shelf { pointer-events: none; }
.welcome h1 { font-size: 2rem; margin-bottom: .4rem; }
.tpl { border-radius: 16px; }
.tpl.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--card)); }

/* v4: bare first-run screen, spending, receipt review */
body.bare .top .tabs, body.bare .bottom { display: none; }
body.bare { padding-bottom: 0; }
.spend-nums { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin-bottom: .7rem; }
.spend-nums div { display: flex; flex-direction: column; }
.spend-nums b { font-family: var(--display, inherit); font-size: 1.25rem; }
.spend-nums span { font-size: .78rem; color: var(--muted); }
.spend-nums .bad b { color: var(--bad); }
.list.receipt li { align-items: flex-start; }
.list.receipt select { width: 100%; }
.spend .tl-row { grid-template-columns: 6rem 1fr auto; }
.spend .tl-row b { min-width: 4.2rem; }
[hidden] { display: none !important; }
#toast { width: max-content; max-width: calc(100vw - 32px); }

/* v6: iOS-style buttons, menus and icons (Ionic action sheet, Ionicons). */
.ion-ic { display: inline-flex; width: 1.25em; height: 1.25em; flex: none; }
.ion-ic svg { width: 100%; height: 100%; }
.ionicon { fill: currentColor; stroke: currentColor; }
.ionicon-fill-none { fill: none; }
.ionicon-stroke-width { stroke-width: 32px; }
nav.bottom .ic .ion-ic { width: 25px; height: 25px; }
nav.bottom a.scanbtn .ic .ion-ic { width: 28px; height: 28px; }
button, .btn { border-radius: 12px; min-height: 44px; font-weight: 500; -webkit-tap-highlight-color: transparent; user-select: none;
  transition: opacity .12s, transform .12s; }
button:active:not(:disabled), .btn:active { opacity: .55; transform: scale(.98); }
button.sm { min-height: 34px; border-radius: 10px; }
button.primary, .btn.primary { font-weight: 600; }
button.tinted, .btn.tinted { border-color: transparent; background: color-mix(in srgb, var(--brand-2) 14%, transparent); color: var(--brand-2); font-weight: 600; }
button.danger { border-color: transparent; background: color-mix(in srgb, var(--bad) 12%, transparent); font-weight: 600; }
.scanbox .row { gap: .5rem; } .scanbox button { min-width: 0; }
.seg { border-radius: 11px; padding: 2px; } .seg button { border-radius: 9px; min-height: 40px; }
.small-seg button { min-height: 34px; padding: .2rem .7rem; }
.ilist { background: var(--card); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; margin: 0 0 1.2rem; }
.irow { display: flex; align-items: center; gap: .8rem; padding: .7rem .9rem; min-height: 56px; color: var(--ink); text-decoration: none; position: relative; }
.irow + .irow::before { content: ""; position: absolute; left: 3.6rem; right: 0; top: 0; border-top: 1px solid var(--line); }
.irow:active { background: var(--line); }
.irow .grow { display: flex; flex-direction: column; min-width: 0; } .irow b { font-weight: 600; }
.irow-ic { width: 34px; height: 34px; border-radius: 9px; background: #1d3b2f; color: #fff; display: grid; place-items: center; flex: none; }
.irow-ic .ion-ic { width: 20px; height: 20px; } .irow > .ion-ic { color: var(--muted); width: 18px; height: 18px; }
ion-action-sheet { --background: var(--card); --color: var(--ink); --button-color: var(--brand-2); --button-background-selected: var(--line);
  --ion-color-danger: var(--bad); --ion-font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.irow .grow { flex: 1; }
:root { --ion-color-primary: var(--brand-2); }
ion-action-sheet.action-sheet-ios { --button-color: var(--brand-2); --background: var(--card); --color: var(--muted); }
:root { --ion-overlay-background-color: var(--card); --ion-background-color: var(--card); --ion-text-color: var(--ink); --ion-color-danger: var(--bad); }
ion-action-sheet .action-sheet-group, ion-action-sheet .action-sheet-button { background: var(--card) !important; }
ion-action-sheet .action-sheet-title { color: var(--muted) !important; }

/* Scan: what are you doing? One row of icon buttons, the chosen one filled in its own colour. */
.modes { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: .4rem; }
.modes button { flex-direction: column; gap: .25rem; padding: .55rem .1rem .5rem; min-height: 68px; min-width: 0; border-radius: 14px;
  border: 1px solid var(--line); background: var(--card); color: var(--muted); font-size: .78rem; font-weight: 600; line-height: 1.1; justify-content: center; }
.modes .mode-ic { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; color: var(--mc); background: color-mix(in srgb, var(--mc) 14%, transparent); }
.modes .mode-ic .ion-ic { width: 20px; height: 20px; }
.modes button[data-m="use"] { --mc: #b3261e; } .modes button[data-m="add"] { --mc: #2e7d4f; } .modes button[data-m="bulk"] { --mc: #1f6f6b; }
.modes button[data-m="move"] { --mc: #b9772a; } .modes button[data-m="info"] { --mc: #55627a; }
.modes button.on { background: var(--mc); border-color: var(--mc); color: #fff; box-shadow: 0 3px 10px color-mix(in srgb, var(--mc) 30%, transparent); }
.modes button.on .mode-ic { background: rgba(255,255,255,.2); color: #fff; }
#modehelp { margin: .6rem .2rem .2rem; font-size: .95rem; }

/* ================= v5 theme: matte tiles =================
   Warm paper, ink, flat matte status colors, no gradients or glows.
   Each item is one small tile: teal = good, mustard = expiring, brick = expired, empty = out. */
:root {
  --bg: #f3efe7; --card: #fbf9f4; --ink: #1f2421; --muted: #66625a; --line: #e2dcd0; --deep: #ece6da;
  --brand: #1f2421; --brand-2: #1f2421; --accent: #d49a2e; --gold: #d49a2e;
  --good: #4e7d8a; --soon: #d49a2e; --past: #a8432c; --empty: #8c8578;
  --ok: #3f6b77; --warn: #8a5f12; --bad: #a8432c; --okbg: #e3ecee; --warnbg: #f6ead2; --badbg: #f5e2dc;
  --radius: 22px; --shadow: none;
  --display: "Bricolage Grotesque", system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #1a1c1b; --card: #232624; --ink: #ece8e0; --muted: #a9a49a; --line: #343835; --deep: #2b2e2c;
  --brand: #ece8e0; --brand-2: #ece8e0; --good: #6d9eab; --soon: #d9a647; --past: #c4664d; --empty: #8c8578;
  --ok: #8dbcc8; --warn: #e2b766; --bad: #e08b73; --okbg: #24343a; --warnbg: #3a3020; --badbg: #3d2620; color-scheme: dark; } }
:root[data-theme="dark"] {
  --bg: #1a1c1b; --card: #232624; --ink: #ece8e0; --muted: #a9a49a; --line: #343835; --deep: #2b2e2c;
  --brand: #ece8e0; --brand-2: #ece8e0; --good: #6d9eab; --soon: #d9a647; --past: #c4664d; --empty: #8c8578;
  --ok: #8dbcc8; --warn: #e2b766; --bad: #e08b73; --okbg: #24343a; --warnbg: #3a3020; --badbg: #3d2620; color-scheme: dark; }

body { font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
h1, h2, h3, .brand, .big-name { font-family: var(--display); letter-spacing: -.01em; font-weight: 800; }
h1 { font-size: 1.9rem; line-height: 1.1; } h2 { font-size: 1.15rem; font-weight: 700; } h3 { font-weight: 700; }
header.top { background: var(--bg); color: var(--ink); box-shadow: none; border-bottom: 1px solid var(--line); }
header.top .brand { color: var(--ink); }
.tabs a { color: var(--muted); } .tabs a.on { background: var(--ink); color: var(--bg); }
body::before { background: var(--bg) !important; }
.card { box-shadow: none; }
button.primary, .btn.primary { background: var(--ink); border-color: var(--ink); color: var(--bg); box-shadow: none; }
:root[data-theme="dark"] button.primary, :root[data-theme="dark"] .btn.primary { color: var(--bg); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) button.primary, :root:not([data-theme="light"]) .btn.primary { color: var(--bg); } }
.chips button.on, .tagbtn.on, .chips .needbtn.on { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.seg button.on { box-shadow: none; }
.tile .badge, .slot .count { background: var(--ink); color: var(--bg); box-shadow: none; }
.fab { background: var(--ink); color: var(--bg); box-shadow: none; }
.tag { background: var(--deep); color: var(--ink); }
:root[data-theme="dark"] .tag { background: var(--deep); color: var(--ink); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tag { background: var(--deep); color: var(--ink); } }
.thumb.icon { background: var(--deep); }
.tile { border-bottom-color: var(--good); } .tile.warn { border-bottom-color: var(--soon); } .tile.bad { border-bottom-color: var(--past); }
.tl-bar i { background: var(--empty); } .tl-bar i.ok { background: var(--good); } .tl-bar i.warn { background: var(--soon); } .tl-bar i.bad { background: var(--past); }
.ring.ok .bar { stroke: var(--good); } .ring.warn .bar { stroke: var(--soon); } .ring.bad .bar { stroke: var(--past); }
.listlink svg { color: var(--ink); }
#toast { background: var(--ink); color: var(--bg); box-shadow: none; }
#toast button { color: var(--soon); }

nav.bottom { background: var(--card); border-top: 1px solid var(--line); box-shadow: none; border-radius: 0; }
nav.bottom a.on { color: var(--ink); }
nav.bottom a.scanbtn .ic { background: var(--ink); color: var(--bg); border: 4px solid var(--card); box-shadow: none; }

/* tiles: one per item */
.t { display: inline-block; width: 12px; height: 12px; border-radius: 3px; background: var(--good); flex: none; }
.t.warn { background: var(--soon); } .t.bad { background: var(--past); }
.t.out { background: transparent; box-shadow: inset 0 0 0 1.5px var(--empty); }

/* home */
.today { margin: .4rem 0 1rem; } .today h1 { margin: .2rem 0 0; }
.house { background: var(--card); border: 1px solid var(--line); border-radius: 28px; padding: .9rem .9rem .6rem; }
.roof { display: block; width: 100%; height: 22px; } .roof path { fill: none; stroke: var(--line); stroke-width: 2; stroke-linejoin: round; }
.floor { display: block; text-decoration: none; color: inherit; padding: .7rem .5rem .8rem; border-radius: 18px; }
.floor + .floor { margin-top: .4rem; }
.floor.deep { background: var(--deep); padding: .8rem .75rem .9rem; }
.floor-head { display: flex; justify-content: space-between; align-items: baseline; gap: .6rem; margin-bottom: .6rem; }
.floor-head h3 { margin: 0; font-size: 1.15rem; }
.floor-status { font-size: .8rem; font-weight: 600; color: var(--warn); text-align: right; }
.floor-status.ok { color: var(--ok); }
.floor-days { font-size: .8rem; color: var(--muted); white-space: nowrap; }
.floor-days b { font-family: var(--display); font-size: 1.4rem; color: var(--ink); }
.tilegrid { display: grid; grid-template-columns: repeat(auto-fill, 12px); gap: 7px; }
.gauge { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px; margin: .8rem 0 .4rem; }
.gauge i { height: 7px; border-radius: 2px; background: var(--line); } .gauge i.on { background: var(--good); }
.floor.deep .gauge i { background: color-mix(in srgb, var(--line) 70%, var(--muted)); } .floor.deep .gauge i.on { background: var(--good); }
.legend { display: flex; flex-wrap: wrap; gap: .4rem 1rem; padding: .7rem .4rem 0; font-size: .78rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: .4rem; } .legend .t { width: 10px; height: 10px; }
.soon { box-shadow: none; text-align: left; border-radius: 20px; width: 136px; }
.soon .t { display: block; margin-bottom: .5rem; }
.pill.warn { color: var(--warn); } .pill.bad { color: var(--bad); }
.chips a.chip.bad { border-color: var(--line); color: var(--bad); background: var(--badbg); }
.chips a.chip.warn { border-color: var(--line); color: var(--warn); background: var(--warnbg); }
.tilegrid > .small { grid-column: 1 / -1; }

/* ================= v7: usability fixes (from the simulated usability run, test/usability) =================
   Messages show over the header, not over the buttons at the bottom; every control is at least 44px. */
#toast { top: calc(.5rem + env(safe-area-inset-top)); bottom: auto; font-size: .95rem; cursor: pointer; }
#toast button { min-height: 44px; padding: 0 .6rem; }
button.sm, .btn.sm { min-height: 44px; }
.seg button { min-height: 44px; }
input, select { min-height: 44px; }
.chips .chip, .chips button, .tagbtn { min-height: 44px; }
.stepper button { min-width: 48px; min-height: 48px; font-size: 1.2rem; }

/* item sheet: the two things people do most, as big labelled buttons */
.onhand { display: grid; gap: .6rem; margin: .4rem 0 .2rem; }
.onhand-row { display: grid; grid-template-columns: 1fr 1fr; align-items: center; gap: .5rem; padding: .6rem .7rem;
  background: var(--deep, var(--line)); border-radius: 16px; }
.onhand-row .where { font-weight: 600; grid-column: 1 / -1; } .onhand-row .where b { font-family: var(--display, inherit); font-size: 1.3rem; margin-right: .3rem; }
.onhand-row button { min-height: 48px; padding: 0 1rem; font-weight: 700; }
.onhand-move { margin-top: .2rem; width: 100%; justify-content: center; }
details.more-opts { margin: .8rem 0; } details.more-opts > summary { cursor: pointer; color: var(--muted); font-weight: 600; min-height: 44px; display: flex; align-items: center; }

/* pantry list: one-tap Used on each row */
.list li .usebtn { min-height: 44px; min-width: 64px; padding: 0 .7rem; font-weight: 700; flex: none; }

/* scan screen: one big camera button; the rest tucked under "Other ways" */
.scanbox #cam { width: 100%; min-height: 64px; font-size: 1.15rem; border-radius: 18px; }
.scanbox details.other { margin-top: .7rem; }
.scanbox details.other > summary { text-align: center; color: var(--muted); font-weight: 600; min-height: 44px; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.scanbox details.other .row { justify-content: center; flex-wrap: wrap; }

/* welcome: the picture is decoration only; Start stays on screen */
.welcome-art, .welcome-art * { pointer-events: none; }
@media (max-height: 760px) { .welcome-art { display: none; } }
.welcome #go { position: sticky; bottom: calc(.8rem + env(safe-area-inset-bottom)); z-index: 5; box-shadow: 0 0 0 .8rem var(--bg); }

/* the pop-up message sits over the header in one line, and taps go through it except on Undo */
#toast { pointer-events: none; white-space: nowrap; max-width: calc(100vw - 24px); min-height: 44px; padding: 0 .4rem 0 1rem; }
#toast span { overflow: hidden; text-overflow: ellipsis; }
#toast.long { white-space: normal; padding: .6rem 1rem; line-height: 1.35; }
#toast button { pointer-events: auto; }

/* dialogs: the Save / Done buttons stay in view while the rest scrolls */
#modal-body > .modal-actions:last-child { position: sticky; bottom: -1.1rem; background: var(--card); padding: .7rem 0 1.1rem; margin-bottom: -1.1rem; z-index: 3; }

/* list rows: the name never gets squeezed into a sliver; with large text the controls wrap under it instead */
.list li { flex-wrap: wrap; }
.list li > .grow { flex: 1 1 8rem; min-width: 8rem; }
.qtyin { min-height: 44px; }
#opts { padding: .4rem 1rem; } #opts .field-row { margin: .5rem 0; } #opts details.more-opts { margin: 0; }
#inv { padding-bottom: 84px; } /* the round + button never covers the last row's Used button */

/* Fonts ship with the app (SIL Open Font License, see ui/fonts), so they work with no connection. */
@font-face { font-family: "Inter"; font-style: normal; font-display: swap; font-weight: 100 900; src: url(fonts/inter-latin-wght-normal.woff2) format("woff2-variations"); }
@font-face { font-family: "Bricolage Grotesque"; font-style: normal; font-display: swap; font-weight: 200 800; src: url(fonts/bricolage-grotesque-latin-opsz-normal.woff2) format("woff2-variations"); }

/* ================= v8: painted artwork and purpose-built buttons =================
   Pictures are matte gouache/paper illustrations made once with OpenAI image generation (art/prompts.json).
   Buttons get a flat "lip" along the bottom edge so they read as pressable without gloss or glow. */
img.art, img.scene { display: block; object-fit: contain; user-select: none; -webkit-user-drag: none; }
img.vessel { display: inline-block; vertical-align: middle; }
.thumb.icon { display: inline-grid; place-items: center; overflow: hidden; border-radius: 16px; }
.thumb.icon img.vessel { width: 92% !important; height: 92% !important; }

/* buttons */
button, .btn { transition: transform .08s ease, box-shadow .08s ease, background-color .15s ease; }
button.primary, .btn.primary { box-shadow: inset 0 -3px 0 rgba(0,0,0,.28); font-weight: 700; letter-spacing: .005em; }
button.tinted, .btn.tinted, .usebtn, .modal-actions button:not(.primary), .onhand-row button:not(.primary) { box-shadow: inset 0 -3px 0 rgba(0,0,0,.08); }
button:active:not(:disabled), .btn:active { transform: translateY(1px); box-shadow: none; }
.scanbox #cam { min-height: 68px; border-radius: 20px; justify-content: center; gap: .6rem; }
.fab { box-shadow: inset 0 -3px 0 rgba(0,0,0,.3); }
nav.bottom a.scanbtn .ic { box-shadow: inset 0 -3px 0 rgba(0,0,0,.3); }

/* scan: illustrated mode cards */
.modes { gap: .5rem; }
.modes button { min-height: 104px; padding: .5rem .2rem .55rem; border-radius: 20px; gap: .35rem; font-size: .85rem; color: var(--ink);
  box-shadow: inset 0 -3px 0 var(--line); }
.modes .mode-art { display: grid; place-items: center; width: 60px; height: 60px; border-radius: 18px; background: var(--deep); }
.modes .mode-art img { width: 54px; height: 54px; }
.modes button[data-m="use"] { --mc: var(--past); } .modes button[data-m="add"] { --mc: #5f7d55; }
.modes button[data-m="bulk"] { --mc: var(--good); } .modes button[data-m="move"] { --mc: var(--soon); }
.modes button.on:has(.mode-art) { background: color-mix(in srgb, var(--mc) 13%, var(--card)); border: 2px solid var(--mc); color: var(--ink);
  box-shadow: inset 0 -3px 0 var(--mc); }
.modes button.on .mode-art { background: color-mix(in srgb, var(--mc) 22%, var(--card)); }

/* home: painted tiles, place pictures */
.floor-head { align-items: center; }
.floor-art { width: 88px; height: 59px; object-fit: contain; flex: none; margin: -.2rem 0; }
.tilegrid.painted { grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px; }
.tilegrid.painted .t { width: auto; height: auto; aspect-ratio: 1; display: grid; place-items: center; border-radius: 12px;
  background: var(--deep); box-shadow: inset 0 -4px 0 var(--good); }
.floor.deep .tilegrid.painted .t { background: var(--card); }
.tilegrid.painted .t img { width: 78%; height: 78%; margin-bottom: 2px; }
.tilegrid.painted .t.warn { box-shadow: inset 0 -4px 0 var(--soon); background: var(--warnbg); }
.tilegrid.painted .t.bad { box-shadow: inset 0 -4px 0 var(--past); background: var(--badbg); }
.tilegrid.painted .t.out { background: transparent; box-shadow: inset 0 0 0 1.5px var(--empty); }
.tilegrid.painted .t.out img { opacity: .35; filter: grayscale(1); }
.tilegrid.painted .t.more { background: transparent; box-shadow: inset 0 0 0 1.5px var(--line); font-size: .8rem; font-weight: 700; color: var(--muted); }
.soon { position: relative; box-shadow: inset 0 -4px 0 var(--soon); }
.soon.bad { box-shadow: inset 0 -4px 0 var(--past); }
.soon-art { display: grid; place-items: center; width: 72px; height: 72px; border-radius: 18px; background: var(--deep); margin-bottom: .5rem; }
.soon-art img { width: 62px; height: 62px; }
.soon .tname { font-weight: 700; line-height: 1.2; }

/* scenes: welcome picture and empty states */
.welcome-art.painted { margin: .2rem -.4rem .2rem; }
.welcome-art.painted img.scene { width: 100%; max-width: 440px; height: auto; margin: 0 auto; aspect-ratio: 3 / 2; }
.tpl { display: flex; flex-direction: column; align-items: flex-start; gap: .2rem; }
.tpl img.tpl-art { width: 100%; height: 72px; object-fit: contain; margin: 0 0 .4rem; }
.empty.card { text-align: center; }
.empty.card img.scene { width: min(260px, 80%); height: auto; aspect-ratio: 3 / 2; margin: 0 auto .6rem; }
.emptyli { flex-direction: column; text-align: center; gap: .3rem; padding: .8rem 0 !important; }
img.scene.sm { width: 160px; height: auto; aspect-ratio: 3 / 2; margin: 0 auto; }
@media (prefers-reduced-motion: reduce) { button, .btn { transition: none; } }
.floor-head { flex-wrap: wrap; row-gap: .3rem; }
.floor-head .floor-status { flex-basis: 100%; text-align: left; order: 3; }
.floor-art { width: 76px; height: 51px; }
.welcome-art.painted { display: block !important; }
@media (max-height: 760px) { .welcome-art.painted img.scene { max-height: 170px; width: auto; } }
.emptyli img.scene.sm { width: 150px !important; height: 100px !important; max-width: none; }
.floor-head > .grow { flex: 1 1 0; min-width: 0; }
.welcome-art.painted { background: none !important; border: 0 !important; box-shadow: none !important; padding: 0 !important; }

/* ================= v9: purpose themes =================
   Chosen in setup ("What will you use it for?") and in Settings. Each keeps the matte look and only shifts the paper,
   the accent (active tab, scan button, selected cards) and the pictures. Kitchen is the default. */
:root { --pa: #3f6b77; --pa-ink: #fff; }
:root[data-purpose="prep"] { --bg: #eeede6; --card: #f9f9f4; --deep: #e5e4da; --line: #dcdace; --pa: #5b6b3a; }
:root[data-purpose="homestead"] { --bg: #f5eee2; --card: #fcf8f0; --deep: #efe4d2; --line: #e6d9c3; --pa: #a4532f; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --pa: #8dbcc8; --pa-ink: #1a1c1b; }
  :root:not([data-theme="light"])[data-purpose="prep"] { --bg: #1b1c18; --card: #24261f; --deep: #2c2e26; --line: #363929; --pa: #a9b77e; }
  :root:not([data-theme="light"])[data-purpose="homestead"] { --bg: #1d1a17; --card: #27221d; --deep: #302923; --line: #3c332a; --pa: #d9875f; }
}
nav.bottom a.on { color: var(--pa); }
nav.bottom a.scanbtn .ic { background: var(--pa); color: var(--pa-ink); }
.tpl.on { border-color: var(--pa) !important; background: color-mix(in srgb, var(--pa) 9%, var(--card)) !important; }
.house { border-top: 4px solid var(--pa); }
.today { display: flex; align-items: center; gap: .6rem; }
.today > .grow { flex: 1; min-width: 0; }
.today-sub { margin-top: .3rem; font-weight: 600; color: var(--muted); }
img.today-art { width: 116px; height: 78px; object-fit: contain; flex: none; }
.purposes { display: grid; gap: .6rem; }
.purposes .tpl { display: grid; grid-template-columns: 112px 1fr; grid-template-rows: auto 1fr; column-gap: .8rem; align-items: center; text-align: left; padding: .6rem .8rem; }
.purposes .tpl img.purpose-art { grid-row: 1 / 3; width: 112px; height: 75px; object-fit: contain; margin: 0; }
.purposes .tpl b { align-self: end; font-size: 1.05rem; } .purposes .tpl span { align-self: start; }

/* ================= v10: suggested supplies ================= */
.hh h4 { margin: .8rem 0 .2rem; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.hh h4:first-child { margin-top: 0; }
.hh-row { display: flex; align-items: center; gap: .6rem; padding: .35rem 0; border-bottom: 1px solid var(--line); }
.hh-row:last-of-type { border-bottom: 0; }
.hh-row .grow { display: flex; flex-direction: column; flex: 1 1 auto; min-width: 0; }
.hh-step { display: flex; align-items: center; gap: .2rem; flex: none; }
.hh-step button { width: 44px; min-height: 44px; padding: 0; justify-content: center; font-size: 1.3rem; border-radius: 12px; }
.hh-step output { min-width: 2ch; text-align: center; font-weight: 700; font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.seg.terms { margin: .4rem 0 .8rem; }
.seg.terms button { font-size: .8rem; padding: 0 .1rem; min-width: 0; white-space: nowrap; letter-spacing: -.01em; }
.stiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin-bottom: .4rem; }
.stile { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: .6rem .65rem; display: flex; flex-direction: column; gap: .15rem; min-width: 0; }
.stile b { font-size: 1.35rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stile b span { font-size: .78rem; font-weight: 600; color: var(--muted); }
.sbar { display: block; height: 6px; border-radius: 3px; background: var(--deep); overflow: hidden; margin-top: .3rem; }
.sbar i { display: block; height: 100%; background: var(--good); border-radius: 3px; }
.stile.warn .sbar i, .sbar i.partial { background: var(--soon); }
.stile.bad .sbar i, .sbar i.none { background: var(--past); }
li.sl { align-items: flex-start; flex-wrap: nowrap; }
li.sl .check { margin-top: .15rem; }
li.sl .grow { flex: 1 1 0; min-width: 0; }
li.sl .chips { margin-top: .3rem; }
li.sl.s-ok .name { color: var(--muted); }
.sright { display: flex; flex-direction: column; align-items: flex-end; gap: .35rem; flex: none; }
.snum { font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--muted); }
.snum b { color: var(--ink); font-size: 1.05rem; }
.sright button.sm { white-space: nowrap; font-size: .8rem; }
ul.srcs { margin: .2rem 0 .6rem; padding-left: 1.1rem; }
ul.srcs li { margin: .25rem 0; font-size: .9rem; }
.supcount { text-align: right; font-variant-numeric: tabular-nums; display: flex; flex-direction: column; align-items: flex-end; }
.supcount b { font-size: 1.15rem; white-space: nowrap; }
.supplink .grow { min-width: 0; }
.hhcard { padding-top: .7rem; padding-bottom: .7rem; }
#wterm { margin-bottom: 0; }
/* household form: one row per person or pet */
.pp { border: 1px solid var(--line); border-radius: 12px; padding: .5rem .6rem; margin: 0 0 .5rem; background: var(--bg); }
.pp-grid { display: grid; grid-template-columns: 3.3rem 1.15fr 1.15fr 44px; gap: .4rem; align-items: end; }
.pp.pet .pp-grid { grid-template-columns: 1fr 1fr 44px; }
.pp-grid label { font-size: .75rem; margin: 0 0 .15rem; }
.pp-grid input, .pp-grid select { width: 100%; min-width: 0; margin: 0; padding-left: .5rem; padding-right: .3rem; }
.pp > select { width: 100%; margin: .4rem 0 0; }
.pp-x { width: 44px; min-height: 44px; padding: 0; justify-content: center; border-radius: 12px; }
.pp-x:disabled { opacity: .35; }
.pp-fix { gap: .45rem; align-items: center; color: var(--ink); min-height: 40px; flex-wrap: nowrap; margin: .3rem 0 0; }
.pp-fix span { line-height: 1.15; }
.pp-k { margin-top: .3rem; }
.hh > .hh-body > button.sm { margin: 0 0 .3rem; }
/* the working behind each line */
details.swork { margin-top: .35rem; }
details.swork summary { cursor: pointer; font-size: .82rem; color: var(--muted); min-height: 28px; display: flex; align-items: center; }
details.swork p { margin: .3rem 0 0; overflow-wrap: anywhere; }
.tag.plain { background: var(--line); color: var(--muted); }
li.sl .chips .tag { margin-right: .3rem; }
ul.hhneeds { list-style: none; padding: 0; margin: .4rem 0; }
ul.hhneeds li { display: flex; gap: .5rem; padding: .3rem 0; border-bottom: 1px solid var(--line); font-size: .9rem; }
ul.hhneeds li .grow { flex: 1 1 auto; min-width: 0; }
ul.hhneeds li b { white-space: nowrap; font-variant-numeric: tabular-nums; }
/* first-run setup: one question per screen, with a progress bar, Back and Skip */
.ob .ob-top { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; min-height: 44px; margin: .2rem 0 .3rem; }
.ob .ob-top > :first-child { justify-self: start; } .ob .ob-top > :last-child { justify-self: end; }
.ob .ob-top button.linklike { border: 0; background: none; box-shadow: none; text-decoration: none; color: var(--pa); font-weight: 600; padding: 0 .2rem; display: inline-flex; align-items: center; gap: .1rem; min-height: 44px; }
.ob .ob-top .ion-ic { width: 20px; height: 20px; }
.ob-prog { display: flex; gap: 4px; margin: 0 0 1rem; }
.ob-prog i { flex: 1; height: 5px; border-radius: 3px; background: var(--line); }
.ob-prog i.on { background: var(--pa); }
.ob h2 { font-size: 1.45rem; margin: .2rem 0 .5rem; }
.ob h3 { margin: 1rem 0 .5rem; }
.ob-tiles { display: grid; gap: .6rem; }
.ob-tile { display: flex; align-items: center; gap: .8rem; text-align: left; padding: .75rem .8rem; min-height: 72px; height: auto; border-radius: 16px; width: 100%; }
.ob-tile .grow { display: flex; flex-direction: column; gap: .15rem; flex: 1; min-width: 0; }
.ob-tile b { font-size: 1.05rem; font-weight: 600; }
.ob-tile img.ob-art { width: 64px; height: 64px; object-fit: contain; flex: none; }
.ob-tile > .ion-ic { color: var(--muted); width: 18px; height: 18px; flex: none; }
.ob-tile.on { border-color: var(--pa); background: color-mix(in srgb, var(--pa) 9%, var(--card)); }
.ob-have { margin-top: 1.2rem; }
.ob-have h3 { margin-top: 0; }
.ob-links { display: grid; gap: .5rem; }
.ob-links > * { width: 100%; justify-content: center; text-align: center; }
.ob #go { width: 100%; margin-top: 1rem; position: sticky; bottom: calc(.8rem + env(safe-area-inset-bottom)); z-index: 5; box-shadow: 0 0 0 .8rem var(--bg); }
.ob .savebar { bottom: env(safe-area-inset-bottom); }
.ob .welcome-art.painted img.scene { max-height: 190px; width: auto; }
.ob[data-step="start"] h1 { margin-top: .2rem; }
.ob #oblist li { align-items: center; gap: .7rem; }
.ob #oblist li label { cursor: pointer; color: var(--ink); font-size: 1rem; font-weight: 400; margin: 0; text-transform: none; letter-spacing: 0; }
.ob #oblist li label .name { font-weight: 600; }
.ob button.big { justify-content: center; text-align: center; }
.ob #obcode { text-transform: uppercase; letter-spacing: .05em; }
.ob form .row button { flex: 1; }
