/* Groceries — "Crisp" design system (spec §3). All color via CSS custom props;
   light + dark tokens for the L/D/A toggle. Fluid full-viewport fill, safe areas. */

:root {
  --bg:      #FFFFFF;
  --surface: #FBFCFD;
  --ink:     #111826;
  --muted:   #8892A2;
  --accent:  #16A75C;
  --accent-press: #128A4C;
  --accent-tint: #E7F5EE;
  --accent-ink: #FFFFFF;   /* text on accent fills */
  --line:    #EDF0F3;
  --chip:    #F4F7F9;
  --danger:  #E0533D;
  --danger-tint: #FBE9E6;
  --gold:    #B0832A;
  --glass:   rgba(255,255,255,0.82);
  --radius:  16px;
  --radius-pill: 999px;
  --shadow:  0 6px 20px rgba(20,27,46,.07);
  --shadow-lg: 0 12px 40px rgba(20,27,46,.14);
  /* Data section categorical palette — validated (CVD + normal-vision + contrast)
     against this surface via dataviz skill's validate_palette.js. Fixed order,
     never cycled or reassigned per-filter. --chart-other is the neutral "Other"
     bucket, not a validated hue slot. */
  --chart-1: #16A75C;  /* green  — reuses accent */
  --chart-2: #2E6FE0;  /* blue */
  --chart-3: #B0832A;  /* gold   — reuses --gold */
  --chart-4: #7B5FE0;  /* violet */
  --chart-other: #C7CDD6;
  /* Second residence accent (DC) — reuses --chart-2 blue so it's visually distinct
     from Clara Ranch's green everywhere the residence switcher shows up. */
  --dc: #2E6FE0;
  --dc-tint: #E8F0FE;
}
:root[data-theme="dark"] {
  --bg:      #0E1420;
  --surface: #161D2B;
  --ink:     #EAF0F7;
  --muted:   #8FA0B4;
  --accent:  #1FB865;
  --accent-press: #17945028;
  --accent-tint: #12291E;
  --accent-ink: #08130C;
  --line:    #243043;
  --chip:    #1C2635;
  --danger:  #FF6B5D;
  --danger-tint: #2C1815;
  --gold:    #D8AE5A;
  --glass:   rgba(14,20,32,0.82);
  --shadow:  0 10px 26px rgba(0,0,0,.42);
  --shadow-lg: 0 16px 44px rgba(0,0,0,.55);
  --chart-1: #189358;
  --chart-2: #3987E5;
  --chart-3: #C98500;
  --chart-4: #9085E9;
  --chart-other: #3A4557;
  --dc: #3987E5;
  --dc-tint: #142236;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;              /* app shell owns scrolling; never scroll body sideways */
  overscroll-behavior-y: none;
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- App shell: full-bleed chrome, centered fluid content ---------- */
/* Content max width — chrome (header/tabbar) spans the full viewport; the
   content column centers within it so wide PC screens never strand a narrow
   column against edge-to-edge bars (§3). */
:root { --content-max: 1200px; --tab-max: 720px; }
#app { display: flex; flex-direction: column; height: 100dvh; width: 100%; }
.header {
  position: sticky; top: 0; z-index: 20;
  padding: calc(env(safe-area-inset-top) + 12px) max(16px, env(safe-area-inset-left)) 12px max(16px, env(safe-area-inset-right));
  background: var(--glass); backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
/* Build badge. Tiny on purpose. The light --muted (#8892A2) is only 3.14:1 on white, so
   light uses a fixed #5F6B7C: 5.41:1 on the white header, 5.03:1 over a chip blurred under
   the glass. Dark uses --muted: 6.89:1 on the page, 5.70:1 over a chip. The PIN screen
   paints --bg, the same numbers. Failure red: fixed #B3261E in light (6.54:1; the light
   --danger is 3.84:1), --danger in dark (6.59:1). Two instances share this base rule:
   #app-version sits inline in the header next to L/D/A (David's placement, 2026-09-25);
   .pin is a fixed top-left corner overlay on the PIN gate, which the header instance
   can't reach since #pin-screen is a separate full-viewport layer above it. */
.app-version {
  pointer-events: none;
  font: 500 9px/9px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: .2px; color: #5F6B7C; white-space: nowrap;
}
:root[data-theme="dark"] .app-version { color: var(--muted); }
.app-version.fail { color: #B3261E; font-weight: 700; }
:root[data-theme="dark"] .app-version.fail { color: var(--danger); }
.app-version.pin {
  position: fixed; z-index: 250;   /* above the PIN screen's own z-index:200 */
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  left: max(16px, env(safe-area-inset-left, 0px));
}
/* The header row (wordmark + L/D/A + search + menu icons) already runs edge-to-edge on a
   phone with no slack (§3 — verified tight at 375px pre-badge). Rather than risk the ~90px
   inline badge forcing horizontal scroll on a narrow phone, it drops off below the width
   where the header stops having room; the PIN-gate instance (above) still always shows the
   build regardless of width, so "which build loaded" stays answerable either way. */
@media (max-width: 430px) { #app-version { display: none; } }
.hbar { display: flex; align-items: center; gap: 10px; width: 100%; max-width: var(--content-max); margin: 0 auto; }
.wordmark { font-weight: 700; letter-spacing: -0.03em; font-size: 22px; color: var(--ink); }
.hbar .spacer { flex: 1; }

/* Residence switcher — always visible, governs which house's list/pantry/trips/
   run-out/spend you're looking at AND where new data (receipts/photos/paste) lands. */
.res-bar { display: flex; gap: 8px; width: 100%; max-width: var(--content-max); margin: 10px auto 0; }
.res-bar button {
  flex: 1; border: 1px solid var(--line); background: var(--chip); color: var(--muted);
  font-family: inherit; font-weight: 700; font-size: 13px; padding: 8px 10px;
  border-radius: var(--radius-pill); cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  transition: background .15s, color .15s, border-color .15s;
}
.res-bar button[data-res="clara_ranch"].on { background: var(--accent-tint); color: var(--accent); border-color: transparent; }
.res-bar button[data-res="dc"].on { background: var(--dc-tint); color: var(--dc); border-color: transparent; }
/* Same house colors reused wherever a residence toggle appears outside the header (e.g. receipt review). */
#rc-res button[data-res="dc"].on { background: var(--dc-tint); color: var(--dc); }

main {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 16px max(16px, env(safe-area-inset-right)) 96px max(16px, env(safe-area-inset-left));
}
.screen { display: none; width: 100%; max-width: var(--content-max); margin: 0 auto; }
.screen.active { display: block; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------- Bottom tab bar (List · Frequents · Camera · Search · Pantry) ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; justify-content: center;
  padding: 6px max(8px, env(safe-area-inset-right)) calc(env(safe-area-inset-bottom) + 6px) max(8px, env(safe-area-inset-left));
  background: var(--glass); backdrop-filter: saturate(1.4) blur(12px);
  border-top: 1px solid var(--line);
}
.tabinner { display: flex; align-items: flex-end; justify-content: space-around; width: 100%; max-width: var(--tab-max); }
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  min-height: 52px; padding: 6px 2px; border: 0; background: none; cursor: pointer;
  color: var(--muted); font-size: 11px; font-weight: 600; font-family: inherit;
}
.tab svg { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 2; }
.tab.active { color: var(--accent); }
.tab.camera { flex: 0 0 auto; }
.tab.camera .fab {
  width: 58px; height: 58px; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink);
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-lg); margin-top: -18px; transition: transform .12s;
}
.tab.camera .fab svg { width: 28px; height: 28px; stroke: currentColor; }
.tab.camera:active .fab { transform: scale(.94); }

/* ---------- Cards, sections ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); margin-bottom: 12px;
}
.section-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 18px 4px 8px; }
.muted { color: var(--muted); }
.hairline { height: 1px; background: var(--line); border: 0; margin: 4px 0; }

/* ---------- Buttons, pills, chips ---------- */
.btn {
  appearance: none; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font-family: inherit; font-size: 15px; font-weight: 600; border-radius: var(--radius-pill);
  padding: 11px 18px; min-height: 44px; cursor: pointer; transition: transform .1s, background .15s;
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.primary:active { background: var(--accent-press); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--accent); }
.btn.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn[disabled] { opacity: .55; pointer-events: none; }
.btn.sm { min-height: 36px; padding: 7px 13px; font-size: 14px; }
.btn.block { width: 100%; }
.iconbtn { width: 40px; height: 40px; border-radius: var(--radius-pill); border: 1px solid var(--line); background: var(--surface); color: var(--ink); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.iconbtn svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; }

.chip { display: inline-flex; align-items: center; gap: 5px; background: var(--chip); color: var(--ink); border-radius: var(--radius-pill); padding: 4px 11px; font-size: 13px; font-weight: 600; }
.chip.accent { background: var(--accent-tint); color: var(--accent); }
.chip.danger { background: var(--danger-tint); color: var(--danger); }
.pricechip { background: var(--chip); color: var(--ink); border-radius: 8px; padding: 3px 8px; font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- Segmented (L/D/A) ---------- */
.seg { display: inline-flex; background: var(--chip); border-radius: var(--radius-pill); padding: 3px; }
.seg button { border: 0; background: none; font-family: inherit; font-size: 13px; font-weight: 700; color: var(--muted); padding: 6px 11px; border-radius: var(--radius-pill); cursor: pointer; min-width: 34px; }
.seg button.on { background: var(--bg); color: var(--accent); box-shadow: var(--shadow); }

/* ---------- List rows ---------- */
.list-group { margin-bottom: 6px; }
.list-row {
  display: flex; align-items: center; gap: 12px; padding: 13px 6px; border-bottom: 1px solid var(--line);
}
.list-row:last-child { border-bottom: 0; }
.check {
  width: 26px; height: 26px; min-width: 26px; border-radius: 50%; border: 2px solid var(--line);
  display: flex; align-items: center; justify-content: center; cursor: pointer; transition: .12s;
}
.check svg { width: 15px; height: 15px; stroke: #fff; fill: none; stroke-width: 3; opacity: 0; }
.list-row.done .check { background: var(--accent); border-color: var(--accent); }
.list-row.done .check svg { opacity: 1; }
.list-row.done .row-name { text-decoration: line-through; color: var(--muted); }
.row-main { flex: 1; min-width: 0; }
.row-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { font-size: 13px; color: var(--muted); }
.row-thumb { width: 42px; height: 42px; min-width: 42px; border-radius: 10px; object-fit: cover; background: var(--chip); }

/* Marks a thumbnail as an AI-generated stand-in (no real product photo was
   found) — reused on any small thumbnail; the product-detail page uses a
   bigger labeled ".chip" version instead since there's room to spell it out. */
.ai-badge {
  position: absolute; bottom: -3px; right: -3px; z-index: 1;
  background: var(--surface); border: 1px solid var(--line); border-radius: 50%;
  width: 16px; height: 16px; display: inline-flex; align-items: center; justify-content: center;
  font-size: 9px; line-height: 1; cursor: help;
}
.qty { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--muted); font-size: 14px; }

/* ---------- Inputs ---------- */
input, textarea, select {
  font-family: inherit; font-size: 16px; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; width: 100%;
}
input:focus, textarea:focus, select:focus, button:focus-visible, .tab:focus-visible, .check:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
.addbar { display: flex; gap: 8px; align-items: center; }
.addbar input { flex: 1; }

/* ---------- Grid (frequents / products) ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.prodcard { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px; cursor: pointer; display: flex; flex-direction: column; gap: 6px; }
.prodcard .thumb { width: 100%; aspect-ratio: 1; border-radius: 10px; object-fit: cover; background: var(--chip); display: flex; align-items: center; justify-content: center; color: var(--muted); }

/* Actual shelf photos (Pantry) — recall the real picture, not just the AI item list. */
.photo-tile { position: relative; aspect-ratio: 1; border-radius: 14px; overflow: hidden; background: var(--chip); cursor: pointer; }
.photo-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-tile .cap {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 20px 8px 6px;
  background: linear-gradient(to top, rgba(0,0,0,.72), transparent);
  color: #fff; font-size: 11px; font-weight: 700; line-height: 1.3;
}
.photo-tile .loc-chip { position: absolute; top: 6px; left: 6px; background: rgba(0,0,0,.55); color: #fff; font-size: 10px; font-weight: 700; padding: 3px 8px; border-radius: var(--radius-pill); text-transform: capitalize; }
.prodcard .name { font-weight: 700; font-size: 14px; line-height: 1.25; }

/* ---------- Sparkline (spend / price) ---------- */
.spark { display: flex; align-items: flex-end; gap: 3px; height: 46px; }
.spark span { flex: 1; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 3px; opacity: .85; }

/* ---------- Sheet / modal ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(10,15,25,.42); z-index: 50; display: none; align-items: flex-end; justify-content: center; }
.sheet-backdrop.open { display: flex; animation: fade .18s ease; }
.sheet {
  background: var(--bg); width: 100%; max-width: 620px; max-height: 90dvh; overflow-y: auto;
  border-radius: 20px 20px 0 0; padding: 18px max(18px, env(safe-area-inset-left)) calc(env(safe-area-inset-bottom) + 20px);
  box-shadow: var(--shadow-lg); animation: slideup .22s cubic-bezier(.2,.7,.3,1);
}
@media (min-width: 640px) { .sheet-backdrop { align-items: center; } .sheet { border-radius: 20px; max-height: 86dvh; } }
@keyframes slideup { from { transform: translateY(100%); } to { transform: none; } }
.sheet h2 { margin: 4px 0 14px; font-size: 20px; letter-spacing: -0.02em; }
.sheet-grip { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 0 auto 12px; }

/* ---------- Empty states ---------- */
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty .big { font-size: 40px; margin-bottom: 10px; }
.empty p { max-width: 320px; margin: 6px auto 16px; }

/* ---------- Toast ---------- */
#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom) + 88px); z-index: 90; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: var(--ink); color: var(--bg); padding: 11px 18px; border-radius: var(--radius-pill); font-size: 14px; font-weight: 600; box-shadow: var(--shadow-lg); animation: fade .2s; max-width: 90vw; }
.toast.err { background: var(--danger); color: #fff; }

/* ---------- Segmented row of stats ---------- */
.stats { display: flex; gap: 10px; }
.stat { flex: 1; text-align: center; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 6px; }
.stat .v { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .l { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* bars for spend-by-store */
.bar-row { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.bar-row .lab { width: 92px; font-size: 13px; font-weight: 600; text-transform: capitalize; }
.bar-track { flex: 1; height: 12px; background: var(--chip); border-radius: 6px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 6px; }
.bar-row .val { width: 74px; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; font-size: 13px; }

.spin { width: 18px; height: 18px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: rot .7s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes rot { to { transform: rotate(360deg); } }

/* PIN keypad (break-glass) */
#pin-screen { position: fixed; inset: 0; background: var(--bg); z-index: 200; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 24px; }
#pin-screen.show { display: flex; }
.pin-dots { display: flex; gap: 12px; }
.pin-dots i { width: 14px; height: 14px; border-radius: 50%; background: var(--line); }
.pin-dots i.f { background: var(--accent); }
#pin-screen { touch-action: manipulation; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; padding-top: max(24px, env(safe-area-inset-top)); padding-bottom: max(24px, env(safe-area-inset-bottom)); gap: clamp(12px, 2.5vh, 22px); }
#pin-screen.busy .pin-dots i.f { animation: pinpulse .9s ease-in-out infinite; }
@keyframes pinpulse { 50% { opacity: .35; } }
#pin-screen.bad .pin-dots { animation: pinshake .35s; }
@keyframes pinshake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
#pin-msg { min-height: 1.3em; font-size: 16px !important; color: var(--ink); text-align: center; }
.keypad { display: grid; grid-template-columns: repeat(3, clamp(64px, 22vw, 84px)); gap: clamp(10px, 2vh, 16px); touch-action: manipulation; }
.keypad button { height: clamp(64px, 10vh, 84px); border-radius: 50%; border: 1px solid var(--line); background: var(--surface); font-size: clamp(26px, 4vh, 32px); font-weight: 600; color: var(--ink); cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.keypad button:active { background: var(--chip); }
.keypad button:disabled { opacity: .5; }
.keypad .pin-del { border: none; background: transparent; font-size: 24px; }

/* ---------- Data section chart primitives ---------- */
/* Stacked monthly bars (category mix, new-vs-repeat). Each .stackbar-col is one
   month, divided into flex segments (2px surface gaps between fills per dataviz spec). */
.stackbar-row { display: flex; align-items: flex-end; gap: 6px; height: 90px; }
.stackbar-col { flex: 1; display: flex; flex-direction: column-reverse; min-width: 8px; height: 100%; border-radius: 3px 3px 0 0; overflow: hidden; gap: 2px; cursor: default; }
.stackbar-col span { display: block; width: 100%; min-height: 2px; }
.stackbar-labels { display: flex; gap: 6px; margin-top: 6px; }
.stackbar-labels span { flex: 1; text-align: center; font-size: 10px; color: var(--muted); }

.legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 10px; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); font-weight: 600; }
.legend-dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }

/* Day-of-week 7-bar chart */
.dow-row { display: flex; gap: 8px; align-items: flex-end; height: 90px; }
.dow-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 6px; }
.dow-bar { width: 100%; max-width: 34px; background: var(--chart-1); border-radius: 4px 4px 2px 2px; min-height: 3px; }
.dow-col.peak .dow-bar { background: var(--accent); }
.dow-label { font-size: 11px; font-weight: 700; color: var(--muted); }

/* Calendar heatmap: weeks as columns, days as rows, own horizontal scroll (never page scroll) */
.heatmap-wrap { overflow-x: auto; padding: 2px 2px 8px; -webkit-overflow-scrolling: touch; }
.heatmap-grid { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 13px); gap: 3px; width: max-content; }
.heatmap-cell { width: 13px; height: 13px; border-radius: 3px; background: var(--chip); cursor: default; }
.heatmap-legend { display: flex; align-items: center; gap: 4px; margin-top: 8px; font-size: 11px; color: var(--muted); }
.heatmap-legend .heatmap-cell { width: 11px; height: 11px; }

/* Price history explorer mini line/dot chart */
.linechart { position: relative; height: 90px; display: flex; align-items: flex-end; gap: 2px; }
.linechart .dot-col { flex: 1; position: relative; height: 100%; display: flex; align-items: flex-end; }
.linechart .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--chart-1); margin: 0 auto; box-shadow: 0 0 0 2px var(--surface); }

.data-seg-nav { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; margin-bottom: 4px; }
.data-seg-nav button { flex: 0 0 auto; border: 1px solid var(--line); background: var(--surface); color: var(--muted); font-family: inherit; font-weight: 700; font-size: 13px; padding: 8px 14px; border-radius: var(--radius-pill); cursor: pointer; white-space: nowrap; }
.data-seg-nav button.on { background: var(--accent); color: var(--accent-ink); border-color: transparent; }

.hero-stat { text-align: center; padding: 10px 8px 4px; }
.hero-stat .v { font-size: 34px; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.hero-stat .l { font-size: 13px; color: var(--muted); margin-top: 2px; }

/* ---------- Stores (2026-10-18) ---------- */
.stores-wrap { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); align-items: start; }
.stores-wrap > .seg, .stores-wrap > details { grid-column: 1 / -1; }
.store-seg { display: flex; flex-wrap: wrap; gap: 6px; }
/* His other regular stores (2026-10-18): one picker grouped Missouri / DC instead of 16 chips. */
.store-pick { grid-column: 1 / -1; display: block; }
/* A store without the aisle cards fills the row: details left, hours and departments right; stacked on a phone. */
.store-card.wide { grid-column: 1 / -1; }
/* Shopping at Schnucks: groups in walking order; mapped aisles get the tint (ink on accent-tint 16:1 light, 13:1 dark),
   approximate departments plain ink on surface (17:1 light, 14:1 dark). */
/* Schnucks map (2026-10-25). Fits a phone: every row wraps, nothing is wider than its card. */
.sm-wrap { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr)); align-items: start; }
.sm-wrap > .sm-areas { grid-column: 1 / -1; }
.sm-note { font-size: 12px; margin: 6px 0 0; }
/* --muted is 3.14:1 on the light surface; ink at 75% is about 8.5:1 light and 8.2:1 dark (as the Stores screen). */
.sm-wrap .muted, .sm-wrap .row-sub, .sm-wrap .section-title { color: var(--ink); opacity: .75; }
.sm-wrap .sm-price.sale { opacity: 1; }
.sm-area { border-top: 1px solid var(--line); }
.sm-area summary { display: flex; align-items: center; gap: 10px; padding: 10px 2px; cursor: pointer; list-style: none; min-width: 0; }
.sm-area summary::-webkit-details-marker { display: none; }
.sm-walk { flex: 0 0 28px; height: 28px; border-radius: 50%; background: var(--accent-tint); color: var(--ink); font-weight: 800; font-size: 13px; display: flex; align-items: center; justify-content: center; }
.sm-sum { flex: 1; min-width: 0; font-size: 14px; overflow-wrap: anywhere; }
.sm-body { padding: 0 2px 10px 38px; max-height: min(60vh, 560px); overflow-y: auto; overscroll-behavior: contain; }
.sm-side { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; margin: 10px 0 2px; }
.sm-item { padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 14px; min-width: 0; }
.sm-name { overflow-wrap: anywhere; }
.sm-meta { font-size: 13px; overflow-wrap: anywhere; }
.sm-price { font-weight: 700; }
.sm-price.sale { color: var(--danger); }
.sm-empty { font-size: 13px; padding: 4px 0 8px; }
.sm-results { margin-top: 8px; max-height: min(50vh, 460px); overflow-y: auto; overscroll-behavior: contain; }
.sm-hit { font-size: 14px; padding: 6px 0; overflow-wrap: anywhere; }
#sm-src { flex-wrap: wrap; max-width: 100%; }
#sm-src button { white-space: normal; }
.shop-list { display: grid; gap: 4px; max-height: min(60vh, 520px); overflow-y: auto; overscroll-behavior: contain; }
.shop-group { display: grid; grid-template-columns: minmax(96px, 34%) 1fr; gap: 8px; padding: 6px 8px; border-radius: 10px; font-size: 14px; color: var(--ink); }
.shop-group.mapped { background: var(--accent-tint); }
.shop-label { font-weight: 700; overflow-wrap: anywhere; }
.shop-items { overflow-wrap: anywhere; }
.store-card.wide .store-body { display: grid; gap: 4px 24px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); align-items: start; }
.store-card.wide .store-hours > .hours-grid:first-of-type, .store-card.wide .store-hours > .hours-short:first-child + .hours-grid { margin-top: 0; }
.store-pick select { width: 100%; font: inherit; font-size: 16px; font-weight: 600; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
/* Status line: ink on a tint, never colored text. ink on accent-tint 16:1 light, 13:1 dark; on danger-tint
   15:1 light, 14:1 dark; on chip 16:1 light, 13:1 dark (same pairs as .hours-grid .today and .store-answer). */
.store-status { margin: 0 0 8px; padding: 7px 10px; border-radius: 10px; font-size: 14px; font-weight: 700; color: var(--ink); background: var(--chip); overflow-wrap: anywhere; }
.store-status.open { background: var(--accent-tint); }
.store-status.closed { background: var(--danger-tint); }
.store-note { margin-top: 8px; padding: 8px 10px; border-radius: 10px; background: var(--chip); color: var(--ink); font-size: 13px; overflow-wrap: anywhere; }
.dept { margin-top: 8px; border-top: 1px solid var(--line); padding-top: 6px; }
.dept > summary { cursor: pointer; font-size: 14px; font-weight: 700; color: var(--ink); padding: 4px 0; }
.store-conf { margin-top: 8px; font-size: 12px; color: var(--ink); opacity: .75; overflow-wrap: anywhere; }   /* ink at 75%: about 8:1 light, 9:1 dark */
.store-conf.conf-low { opacity: 1; background: var(--danger-tint); padding: 6px 8px; border-radius: 8px; }
.store-head { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
.store-icon { font-size: 28px; line-height: 1; }
.store-line { display: flex; align-items: center; gap: 6px; padding: 3px 0; font-size: 14px; }
.store-line > a, .store-line > span { min-width: 0; overflow-wrap: anywhere; }
/* Links: ink text, accent underline. Contrast ink on surface 17:1 light, 14:1 dark (accent text would be 3.1:1). */
.store-line a, .store-answer a, .stores-wrap .row-sub a { color: var(--ink); text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 2px; overflow-wrap: anywhere; }
.copy-btn { width: 28px; height: 28px; border: 0; flex: 0 0 auto; }
.hours-grid { display: grid; grid-template-columns: 1fr; gap: 2px; margin-top: 8px; font-size: 13px; }
.hours-grid > div { display: flex; justify-content: space-between; padding: 2px 8px; border-radius: 8px; }
.hours-grid > div.today { background: var(--accent-tint); color: var(--ink); font-weight: 700; }   /* ink on #E7F5EE 16:1; on #12291E 13:1 */
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.store-answer { margin-top: 10px; padding: 10px 12px; border-radius: 12px; background: var(--chip); color: var(--ink); font-size: 14px; line-height: 1.45; overflow-wrap: anywhere; }   /* ink on chip: 16:1 light, 13:1 dark */
.store-answer.err { background: var(--danger-tint); color: var(--ink); }   /* ink on #FBE9E6 15:1; on #2C1815 14:1 (danger text on chip would be 3.6:1) */
/* --muted measures 2.9 to 3.2:1 on these surfaces; on this screen secondary text is ink at 75% (about 8:1 light, 9:1 dark). */
.stores-wrap .muted, .stores-wrap .row-sub, .aisle-cat { color: var(--ink); opacity: .75; }
.store-answer p { margin: 0; }
.answer-pic { display: block; max-width: 100%; max-height: 180px; border-radius: 10px; margin: 0 0 8px; object-fit: contain; background: #fff; }
.aisle-list { max-height: min(52vh, 460px); overflow-y: auto; overscroll-behavior: contain; }
.aisle-cat { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; padding: 10px 2px 2px; }
.aisle-num { display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 15px; }
.aisle-form { display: grid; grid-template-columns: 1fr 70px 70px auto; gap: 6px; margin-top: 8px; }
.aisle-form input { min-width: 0; }
@media (max-width: 420px) { .aisle-form { grid-template-columns: 1fr 1fr; } .aisle-form input:first-child { grid-column: 1 / -1; } }
.aisle-add { margin-top: 6px; }
.aisle-add summary { cursor: pointer; font-weight: 600; font-size: 14px; padding: 6px 0; }
.aisle-add.drag { outline: 2px dashed var(--accent); outline-offset: 4px; border-radius: 10px; }
.drop-hint { font-size: 12px; text-align: center; padding: 6px; }
.hours-edit { display: grid; grid-template-columns: 90px 1fr 1fr; gap: 6px; align-items: center; }
.hours-edit label { margin: 0; }
/* The store map: department blocks by aisle. Ink on chip 16:1 light, 13:1 dark; the aisle numbers in ink too. */
.layout-list { max-height: min(48vh, 420px); overflow-y: auto; overscroll-behavior: contain; }
.layout-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 6px; padding: 4px 0 6px; }
.layout-cell { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; padding: 6px 8px; border-radius: 10px; border: 1px solid var(--line); background: var(--chip); color: var(--ink); text-align: left; font: inherit; cursor: pointer; min-width: 0; }
.layout-cell.approx { border-style: dashed; }
.layout-aisles { font-weight: 800; font-size: 13px; }
.layout-dept { font-size: 12px; line-height: 1.25; overflow-wrap: anywhere; }
.layout-approx { font-size: 10px; text-transform: uppercase; letter-spacing: .4px; opacity: .75; }

/* On a phone the week collapses to two lines (today, then the week), so the screen needs less scrolling. */
.hours-short { display: none; font-size: 13px; line-height: 1.5; margin-top: 6px; padding: 6px 8px; border-radius: 8px; background: var(--accent-tint); color: var(--ink); }
@media (max-width: 600px) { .hours-short { display: block; } .hours-grid { display: none; } }
.list-order-pick { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 4px 4px 0; font-size: 13px; }

/* ---------- Store section (2026-10-26): Schnucks floor plan, pins, path, find, trips, layout ----------
   Fills the space between header and tab bar (height set in storeplan.js), no page scroll: map above the panel on
   a phone, map beside the panel from 900px. Only the panel scrolls, inside itself.
   Contrast (computed 2026-10-26): aisle labels --ink on --chip 16.51 light, 13.28 dark; department labels --ink on
   --accent-tint 15.81 light, 13.44 dark; aisle categories at .8 opacity 8.99 / 9.03; step numbers #fff on #0E7A3F
   5.42 (both themes); callout --bg on --ink 17.76 / 16.06; row meta at .72 opacity 6.95 / 8.18 (6.66 / 7.61 on
   the tint); group counts at .6 opacity 4.63 / 6.09; photo captions #C9D1DD on the dark overlay 12.55. */
/* The Store screen uses the whole window (David, 2026-10-26: "we could use more of the screen"): no 1200px column. */
#screen-storemap { max-width: none; }
.sp { display: flex; flex-direction: column; gap: 10px; min-height: 420px; }
.sp-top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.sp-title { font-weight: 800; font-size: 18px; display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.sp-title .muted { font-weight: 600; font-size: 13px; color: var(--ink); opacity: .7; }
.sp-draft { font-size: 11px; }
.sp-modes { flex: 1 1 auto; overflow-x: auto; scrollbar-width: none; max-width: 100%; }
.sp-modes::-webkit-scrollbar { display: none; }
.sp-modes button { white-space: nowrap; }
.sp-body { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 10px; }
.sp-mapwrap { position: relative; flex: 0 0 auto; aspect-ratio: 1000 / 640; max-height: 58%; align-self: center; width: 100%;
  border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); overflow: hidden; }
.sp-svg { display: block; width: 100%; height: 100%; touch-action: none; user-select: none; -webkit-user-select: none; cursor: grab; }
.sp[data-mode="path"] .sp-svg { cursor: crosshair; }
.sp[data-mode="layout"] .sp-svg { cursor: move; }
.sp-panel { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 2px 2px 8px; }
@media (min-width: 900px) {
  /* the map takes every pixel left of the panel, full height; the plan scales to fit inside it */
  .sp-body { flex-direction: row; }
  .sp-mapwrap { flex: 1 1 auto; aspect-ratio: auto; height: 100%; max-height: none; align-self: stretch; width: auto; min-width: 0; }
  .sp-panel { flex: 0 0 clamp(320px, 26vw, 420px); }
}
.sp-zoom { position: absolute; right: 8px; top: 8px; display: flex; flex-direction: column; gap: 6px; }
.sp-zoom .iconbtn { width: 36px; height: 36px; background: var(--glass); border: 1px solid var(--line); border-radius: 10px; font-size: 18px; color: var(--ink); }
@media (max-width: 600px) { .sp-zoom { right: 4px; top: 4px; gap: 4px; } .sp-zoom .iconbtn { width: 28px; height: 28px; font-size: 15px; border-radius: 8px; opacity: .85; } }
.sp-hint { position: absolute; left: 10px; bottom: 10px; background: var(--ink); color: var(--bg); font-size: 12px; font-weight: 700; padding: 5px 10px; border-radius: 999px; pointer-events: none; }
.sp-hint[hidden] { display: none; }

/* the plan */
.sp-floor { fill: var(--bg); stroke: var(--line); stroke-width: 3; }
.sp-area rect { stroke: var(--line); stroke-width: 2; transition: fill .15s; }
.sp-area.aisle rect { fill: var(--chip); }
.sp-area.dept rect { fill: var(--accent-tint); }
.sp-area.on rect { stroke: var(--accent); stroke-width: 5; }
.sp[data-mode="layout"] .sp-area { cursor: grab; }
.sp[data-mode="layout"] .sp-area.on rect { filter: drop-shadow(0 6px 10px rgba(0,0,0,.18)); }
.sp-labels text { fill: var(--ink); text-anchor: middle; pointer-events: none; font-family: inherit; paint-order: stroke; stroke: var(--bg); stroke-width: 4px; stroke-linejoin: round; }
.sp-aisle-n { font-size: 28px; font-weight: 800; }
.sp-aisle-cat { font-size: 11px; opacity: .8; }
.sp-dept-emoji { font-size: 30px; }
.sp-dept-label { font-size: 17px; font-weight: 700; }
.sp-handle { fill: var(--accent); stroke: var(--bg); stroke-width: 2; cursor: nwse-resize; }
.sp-ent rect { fill: var(--gold); }
.sp-ent text { fill: var(--ink); font-size: 14px; font-weight: 700; text-anchor: middle; pointer-events: none; }
.sp-walkline { fill: none; stroke: var(--dc); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; opacity: .28; pointer-events: none; }
.sp-walkline.strong { opacity: .85; stroke-width: 6; }
.sp-walkhead { fill: none; stroke: var(--dc); stroke-width: 2; }
.sp-walkarrow { fill: none; stroke: var(--dc); stroke-width: 3.5; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.sp-pin { fill: var(--accent); stroke: var(--bg); stroke-width: 2; cursor: pointer; fill-opacity: .88; }
.sp-pin.name { fill: var(--gold); }
.sp-pin.sign { fill: var(--muted); }
.sp-pin.on { stroke: var(--ink); stroke-width: 5; }
.sp-step circle { fill: #0E7A3F; stroke: var(--bg); stroke-width: 3; }
.sp-step text { fill: #fff; font-size: 14px; font-weight: 800; text-anchor: middle; pointer-events: none; }
.sp-route { fill: none; stroke: var(--dc); stroke-width: 7; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 16 12; animation: sp-march 1s linear infinite; pointer-events: none; }
.sp-arrowhead { fill: var(--dc); }
@keyframes sp-march { to { stroke-dashoffset: -28; } }
.sp-target { fill: var(--danger); stroke: var(--bg); stroke-width: 3; }
.sp-target-ring { fill: none; stroke: var(--danger); stroke-width: 4; transform-box: fill-box; transform-origin: center; animation: sp-pulse 1.4s ease-out infinite; }
@keyframes sp-pulse { from { transform: scale(.6); opacity: 1; } to { transform: scale(2.4); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .sp-route, .sp-target-ring { animation: none; } }
.sp-callout rect { fill: var(--ink); }
.sp-callout text { fill: var(--bg); font-size: 16px; font-weight: 700; text-anchor: middle; }

/* the panel */
.sp-sec { display: grid; gap: 8px; }
.sp-lead { font-size: 14px; margin: 2px 2px 4px; color: var(--ink); opacity: .85; }
.sp-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--ink); opacity: .75; }
.sp-legend { display: flex; gap: 12px; font-size: 12px; color: var(--ink); opacity: .85; flex-wrap: wrap; }
.sp-legend .lg { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; vertical-align: -1px; }
.lg.shelf { background: var(--accent); } .lg.name { background: var(--gold); } .lg.sign { background: var(--muted); }
.sp-group { border-top: 1px solid var(--line); padding: 6px 0 4px; }
.sp-group-h { font-size: 13px; font-weight: 800; margin: 2px 2px 4px; color: var(--ink); }
.sp-group-h .muted { color: var(--ink); opacity: .6; font-weight: 600; }
.sp-row { display: flex; flex-direction: column; align-items: flex-start; width: 100%; text-align: left; background: none; border: 0; border-radius: 10px;
  padding: 7px 8px; font: inherit; color: var(--ink); cursor: pointer; min-width: 0; }
.sp-row:hover, .sp-row.on { background: var(--accent-tint); }
.sp-row:active { transform: scale(.99); }
.sp-row-name { font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.sp-row-meta { font-size: 12px; color: var(--ink); opacity: .72; overflow-wrap: anywhere; }
.sp-card { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 40px 12px 12px; box-shadow: var(--shadow); display: grid; gap: 6px; margin-bottom: 8px; }
.sp-card-name { font-weight: 800; font-size: 16px; overflow-wrap: anywhere; }
.sp-card-where { font-size: 14px; font-weight: 600; color: var(--ink); overflow-wrap: anywhere; }
.sp-card-meta { font-size: 13px; color: var(--ink); opacity: .75; overflow-wrap: anywhere; }
.sp-x { position: absolute; top: 6px; right: 6px; width: 32px; height: 32px; border: 0; border-radius: 50%; background: var(--chip); color: var(--ink); cursor: pointer; font-size: 14px; }
.sp-thumb { width: 56px; height: 56px; object-fit: cover; border-radius: 10px; float: right; }
.sp-area-scroll { max-height: 260px; overflow-y: auto; overscroll-behavior: contain; }
.sp-order { margin: 0 0 4px 22px; padding: 0; font-size: 14px; display: grid; gap: 3px; }
.sp-step-row { display: flex; align-items: center; gap: 8px; padding: 5px 2px; border-radius: 8px; }
.sp-step-row.flash { background: var(--accent-tint); }
.sp-step-row .sp-row-name { flex: 1; font-weight: 500; }
.sp-num { flex: 0 0 24px; height: 24px; border-radius: 50%; background: #0E7A3F; color: #fff; font-size: 12px; font-weight: 800; display: flex; align-items: center; justify-content: center; }
.sp-num.off { background: var(--chip); color: var(--ink); }
.sp-unplaced summary { cursor: pointer; font-size: 13px; font-weight: 700; padding: 6px 2px; }
#sp-trip { width: 100%; }

/* the shelf photo, zoomed to the spot */
.sp-photo { position: fixed; inset: 0; z-index: 120; background: rgba(8,12,20,.86); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  padding: calc(env(safe-area-inset-top) + 12px) max(12px, env(safe-area-inset-right)) calc(env(safe-area-inset-bottom) + 12px) max(12px, env(safe-area-inset-left)); }
.sp-photo-top, .sp-photo-foot { width: min(100%, 900px); display: flex; align-items: center; gap: 10px; color: #F4F6FA; font-size: 14px; }
.sp-photo-top > div { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.sp-photo-top .muted, .sp-photo-foot .muted { color: #C9D1DD; }
.sp-photo-x { flex: 0 0 auto; width: 40px; height: 40px; border-radius: 50%; background: rgba(255,255,255,.14); color: #fff; border: 0; font-size: 18px; }
.sp-photo-frame { position: relative; width: min(100%, 900px); max-height: calc(100dvh - 190px); overflow: hidden; border-radius: 14px; background: #000; }
.sp-photo-inner { position: absolute; inset: 0; transform-origin: 0 0; transition: transform .9s cubic-bezier(.2,.7,.2,1); }
.sp-photo-inner img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sp-photo-box { position: absolute; border: 3px solid #FFD43B; border-radius: 10px; box-shadow: 0 0 0 9999px rgba(0,0,0,.28); animation: sp-glow 1.6s ease-in-out infinite alternate; }
@keyframes sp-glow { from { border-color: #FFD43B; } to { border-color: #FF8A3D; } }
.sp-photo-foot .btn { flex: 0 0 auto; }
