:root {
  /* Without this, native form controls (inputs, selects, scrollbars) fall
     back to following the OS's own light/dark preference independent of
     this app's explicit data-theme toggle -- the likely cause of a
     confirmed bug where turning Dark Mode back OFF still left some text
     pale/washed-out (an OS set to dark still painting native widgets dark,
     with this app's now-light CSS text color on top -- low contrast either
     way). Keeping this in sync with the attribute-gated toggle below
     means both always agree, matching the three-state --theme pattern
     already used for every other token in this file. */
  color-scheme: light;
  --forest: #1f5138;
  --leaf: #3a7d44;
  --sage: #8bab8a;
  --moss: #c8dcc5;
  --cream: #faf6ee;
  --sand: #f0e9d8;
  --bark: #5c4a36;
  --sun: #e0a83e;
  --coral: #d97757;
  --ink: #22301f;
  --ink-soft: #4c5c47;
  --white: #ffffff;
  --danger: #b3452c;
  --ok: #2f7a4d;
  --warn: #b8862f;
  --border: #dfe6d8;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(31, 81, 56, 0.08);

  /* Spacing scale -- used by the new accordion/settings-grid/exclude-picker
     components below. The ~20 pre-existing hardcoded px values scattered
     through the rest of this file are NOT swept onto this scale here --
     that's a larger, separate cleanup, out of scope for this pass. */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 28px;

  /* Type scale -- same scoping rule: applied to the new accordion
     component and .page-title, not retrofitted across the file's ~20
     existing hardcoded font-sizes. */
  --fs-xs: 11.5px;
  --fs-sm: 12.5px;
  --fs-base: 14.5px;
  --fs-md: 16px;
  --fs-lg: 19px;
  --fs-xl: 22px;
  --fs-2xl: 28px;

  /* Consolidated status-color triplets -- the same background/color/border
     values are hand-copied verbatim across ~28 selectors today (badges,
     claim pills, freshness pills, confidence banners, score circles,
     insight banners). These -fg tokens are PINNED constants, not
     re-exports of --ok/--warn/--danger: none of those 28 selectors get a
     dark-mode override today, and their backgrounds stay fixed light
     literals in dark mode too -- if -fg tracked a brighter dark-mode
     --ok, "good" badges would go low-contrast against their own
     unchanged light background. Pinning keeps this a zero-visual-change
     consolidation; badge dark-mode contrast generally is a separate,
     real, out-of-scope issue for a later pass. */
  --status-good-bg: #e4f3e6;
  --status-good-fg: #2f7a4d;
  --status-good-border: #bfe3c4;
  --status-warn-bg: #fbf1dd;
  --status-warn-fg: #b8862f;
  --status-warn-border: #f0dba9;
  --status-neutral-bg: #f2ede4;
  --status-neutral-fg: #4c5c47;
  --status-neutral-border: #dfe6d8;
  --status-bad-bg: #f6e3dc;
  --status-bad-fg: #b3452c;
  --status-bad-border: #e8c2b3;

  /* Trust Shield tokens: a distinct gold/silver/bronze metaphor for
     evidence STRENGTH (how well-documented a claim is), separate from the
     green/amber/red status tokens above which mean good/caution/bad. A
     bronze (community-reported) shield isn't "bad" -- it's just weaker
     evidence -- so it deliberately does not reuse --status-bad-*. */
  --shield-gold: #c9971f;
  --shield-gold-bg: #faf1dc;
  --shield-silver: #8a95a6;
  --shield-silver-bg: #eef1f4;
  --shield-bronze: #b5722f;
  --shield-bronze-bg: #f5ece1;
  /* Was #b7bdb0 -- measured at only 1.92:1 against this badge's own
     background, far under WCAG AA's 4.5:1 for normal text (every sibling
     shield color here is noticeably darker/more saturated; this one was
     the outlier). Darkened to match the family's contrast level. */
  --shield-neutral: #5c6456;
  --shield-neutral-bg: #f2f1ec;
  --shield-alert: #b3452c;
  --shield-alert-bg: #f6e3dc;
}

[data-theme="dark"] {
  color-scheme: dark;
  --forest: #7fd9a8;
  --leaf: #6fbf7d;
  --sage: #4c6b4e;
  --moss: #2b3b2a;
  --cream: #182018;
  --sand: #1f2a1e;
  --bark: #cbb896;
  --sun: #e8bb5e;
  --coral: #e39073;
  --ink: #eef3ea;
  /* Bumped from #c3cfbe -- found via live review to read as washed-out/
     pale (almost greenish) against this theme's dark backgrounds, making
     secondary text ("From product label", disclaimer lines, etc.) hard to
     read sitewide. Closer to --ink now while staying visibly secondary to
     it (not competing with bold/primary text). */
  --ink-soft: #d6e0d0;
  --white: #202b1f;
  --border: #33422f;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
  /* Missing until now -- any direct color:var(--ok/--warn/--danger) usage
     (e.g. .compat-yes/.compat-no/.compat-ask) rendered unreadably
     dark-on-near-black in dark mode without these. Deliberately NOT used
     by the pinned --status-*-fg tokens above -- see the comment there. */
  --danger: #e2735c;
  --ok: #5fcf85;
  --warn: #e0ac4e;

  --shield-gold: #e0b843;
  --shield-gold-bg: #3a3320;
  --shield-silver: #a8b0bd;
  --shield-silver-bg: #2b2f36;
  --shield-bronze: #d19a63;
  --shield-bronze-bg: #362a1f;
  /* Was #6b746a -- measured at only 2.95:1 against this badge's own dark
     background, under WCAG AA's 4.5:1. Lightened to match. */
  --shield-neutral: #9aa392;
  --shield-neutral-bg: #262c24;
  --shield-alert: #e2735c;
  --shield-alert-bg: #3a2620;
}

* { box-sizing: border-box; }

/* Accessibility text-size setting (profile.php "Settings" card). Applied
   as `zoom` on body rather than converting this file's many hardcoded-px
   font-size rules to rem -- zoom scales the whole box model (text AND the
   buttons/badges/paddings sized around that text) together, so scaled
   text never overflows a fixed-size control. This genuinely covers every
   page/tab/nav (body wraps everything below the header), not just chips. */
[data-text-size="large"] body { zoom: 1.15; }
[data-text-size="xlarge"] body { zoom: 1.3; }

/* NOT applied when text-size zoom is active (below) -- found via live
   testing that zoom'ing body wider than the viewport, combined with
   .container's margin:0 auto centering, pushes roughly half the overflow
   off the LEFT edge; hiding overflow at the html level then silently
   clipped that into invisibility instead of leaving it reachable by
   scrolling (every line of text read as missing its first 1-2 letters).
   Default (no zoom) case keeps the clip, since that's what actually fixes
   the unrelated off-screen-tooltip bleed this rule exists for. */
html { overflow-x: clip; }
html[data-text-size="large"], html[data-text-size="xlarge"] { overflow-x: auto; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--cream);
  color: var(--ink);
  padding-bottom: 76px;
  /* Clip sideways overflow without creating a scroll container that
     prevents the mobile header and desktop navigation from sticking. */
  overflow-x: clip;
}

a { color: var(--leaf); }

.app-header {
  position: -webkit-sticky;
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--forest);
  color: var(--white);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
[data-theme="dark"] .app-header { color: #10170f; }

.app-header .brand {
  font-weight: 800;
  font-size: 18px;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--white);
  text-decoration: none;
}
[data-theme="dark"] .app-header .brand { color: #10170f; }

.location-chip {
  background: rgba(255,255,255,0.24);
  border: none;
  color: inherit;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
/* Dark mode's header is a bright mint green (same --forest token the light
   header uses for its background, just swapped) with dark text -- the
   semi-transparent white "bubbles" (zip chip, notifications, theme toggle)
   can read as washed-out against it without a defining edge. A dark-green
   border (--moss) gives each one a visible boundary, requested specifically
   for dark mode -- light mode's header is already dark, so its bubbles
   already stand out against it and don't need one. */
[data-theme="dark"] .location-chip,
[data-theme="dark"] .header-icon-btn {
  border: 1.5px solid var(--moss);
}

.container { max-width: 720px; margin: 0 auto; padding: 14px 14px calc(64px + 16px + env(safe-area-inset-bottom, 0px)); }
/* .save-btn (product.php/place.php) floats fixed above the bottom nav at
   its own extra height -- without this, the last bit of page content
   (e.g. a closed accordion right before the end of the page) sits behind
   the floating button instead of being visible above it. :has() has wide
   enough modern-browser support (Chrome/Edge/Safari all 2023+) for this
   app's target audience. */
.container:has(.save-btn) { padding-bottom: calc(76px + 50px + 16px + env(safe-area-inset-bottom, 0px)); }

.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}

/* By-Product cards (Shop tab): a more clearly defined box than the
   generic .card -- bigger padding and a dark-green (--forest) outline, so
   it's obvious which product's prices/links belong to which card. */
.product-price-card {
  padding: 18px;
  border: 2px solid var(--forest);
  border-radius: calc(var(--radius) + 2px);
}
[data-theme="dark"] .product-price-card { border-color: var(--leaf); }
.view-product-link { display: flex; align-items: center; justify-content: center; gap: 6px; }

.chip-row { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 10px; scrollbar-width: thin; }
.chip {
  flex: none;
  border: 1px solid var(--border);
  background: var(--white);
  color: var(--ink-soft);
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.chip.active { background: var(--leaf); border-color: var(--leaf); color: #fff; font-weight: 600; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--sand);
  color: var(--ink-soft);
  font-weight: 600;
  white-space: nowrap;
}
.badge.confidence-high { background: var(--status-good-bg); color: var(--status-good-fg); border-color: var(--status-good-border); }
.badge.confidence-medium { background: var(--status-warn-bg); color: var(--status-warn-fg); border-color: var(--status-warn-border); }
.badge.confidence-low, .badge.confidence-needs_evidence { background: var(--status-neutral-bg); color: var(--status-neutral-fg); border-color: var(--status-neutral-border); }
.badge.evidence-certified_verified { background: var(--status-good-bg); color: var(--status-good-fg); border-color: var(--status-good-border); }
.badge.evidence-organic_claim_documented { background: var(--status-warn-bg); color: var(--status-warn-fg); border-color: var(--status-warn-border); }
.badge.evidence-community_reported { background: var(--status-neutral-bg); color: var(--status-neutral-fg); }
.badge.evidence-no_claim_found { background: var(--status-neutral-bg); color: var(--status-neutral-fg); }
.badge.evidence-contradicted { background: var(--status-bad-bg); color: var(--status-bad-fg); border-color: var(--status-bad-border); }
.badge.evidence-claim_documented { background: var(--status-warn-bg); color: var(--status-warn-fg); border-color: var(--status-warn-border); }
.badge.confirm-ingredient_label { background: var(--status-neutral-bg); color: var(--status-neutral-fg); }
.badge.confirm-business_attested { background: var(--status-good-bg); color: var(--status-good-fg); border-color: var(--status-good-border); }

.evidence-why { margin-top: 6px; }
.evidence-why summary { cursor: pointer; font-size: 13px; font-weight: 700; color: var(--leaf); list-style: none; }
.evidence-why summary::-webkit-details-marker { display: none; }
.evidence-why[open] summary .caret { display: inline-block; transform: rotate(180deg); }
.evidence-why-body { margin-top: 6px; padding: 10px 12px; background: var(--sand); border-radius: 10px; }
.evidence-why-body p { margin: 0 0 4px; }
.evidence-why-body p:last-child { margin-bottom: 0; }
.freshness { font-weight: 700; padding: 2px 8px; border-radius: 999px; font-size: 12px; }
.freshness-fresh { background: var(--status-good-bg); color: var(--status-good-fg); }
.freshness-aging { background: var(--status-warn-bg); color: var(--status-warn-fg); }
.freshness-stale { background: #f5e3d2; color: #a5661f; }
.freshness-old, .freshness-unknown { background: var(--status-neutral-bg); color: var(--status-neutral-fg); }
.freshness-accepted { background: var(--status-good-bg); color: var(--status-good-fg); }
.freshness-not_accepted { background: var(--status-neutral-bg); color: var(--status-neutral-fg); }

.exclude-row { border-bottom: 1px solid var(--border); padding-bottom: 10px; margin-bottom: 10px; }
.exclude-row:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.exclude-row .toggle-pill { display: inline-flex; }
.exclude-detail-panel { margin-top: 8px; padding: 10px 12px; background: var(--sand); border-radius: 10px; }
.exclude-detail-panel .tile-row { margin-bottom: 8px; }
.exclude-summary {
  display: flex; align-items: center; gap: 8px; width: 100%;
  background: none; border: none; padding: 0; margin: 0; font: inherit; color: inherit;
  cursor: pointer; text-align: left;
}
.exclude-summary-icon { font-size: 16px; }
.exclude-summary-label { font-weight: 700; font-size: 13.5px; flex: 1; }
.exclude-summary-chevron { color: var(--ink-soft); font-size: 16px; flex: none; }

/* Compact severity picker (render_toggle_pill_grid_compact_severity()) --
   deliberately thin, not a full .card with padding/border/shadow, since
   the whole point is to stop every picked item from permanently adding a
   big block to the page. Collapses to one line once answered. */
.severity-compact-panel { margin-top: 4px; padding: 6px 2px; border-bottom: 1px solid var(--border); }
.severity-compact-panel:last-child { border-bottom: none; }
.severity-summary {
  display: flex; align-items: baseline; gap: 6px; width: 100%;
  background: none; border: none; padding: 2px 0; margin: 0; font: inherit; color: inherit;
  cursor: pointer; text-align: left;
}
.severity-summary-change { color: var(--leaf); font-size: 11.5px; font-weight: 700; margin-left: auto; }
.severity-picker-row { padding: 2px 0; }
.severity-opt { font-size: 12px; padding: 6px 8px; flex: 1; text-align: center; }
.food-rules-row { padding: 8px 0; border-bottom: 1px solid var(--border); }
.food-rules-row:last-child { border-bottom: none; }
.food-rules-row-label { font-size: 12.5px; font-weight: 700; color: var(--ink-soft); margin-bottom: 6px; }
.food-rules-row-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.food-rule-chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--sand); border: 1px solid var(--border); border-radius: 999px;
  padding: 4px 6px 4px 12px; font-size: 13px;
}
.food-rule-chip-label { background: none; border: none; padding: 0; margin: 0; font: inherit; color: var(--ink); cursor: pointer; }
.food-rule-chip-remove { background: none; border: none; padding: 2px 6px; margin: 0; cursor: pointer; color: var(--ink-soft); font-size: 12px; border-radius: 999px; }
.food-rule-chip-remove:hover { background: var(--white); color: var(--danger); }
.badge.snap-verified_official, .badge.snap-merchant_confirmed { background: #e2eef8; color: #2b5f8a; border-color: #c4dcef; }
.badge.snap-community_reported { background: var(--status-neutral-bg); color: var(--ink-soft); }
.badge.coating-clear { background: var(--status-good-bg); color: var(--status-good-fg); border-color: var(--status-good-border); }
.badge.coating-uses { background: var(--status-bad-bg); color: var(--status-bad-fg); }
.badge.coating-unknown { background: var(--status-neutral-bg); color: var(--status-neutral-fg); }
.badge.hidden-gem { background: #f3e2ee; color: #8a3d74; border-color: #e6c6dc; }
/* Deliberately distinct from the green evidence/confidence badges above --
   this means the business pays to actively maintain its listing, not that
   Sourced has verified any specific claim. Never a trust upgrade. */
.badge-business-verified { background: #e8e6f7; color: #4a3b8a; border-color: #d0cbee; }
/* Deliberately its own color, distinct from both the green evidence
   badges and the purple Verified-business badge -- a sponsor buys a
   labeled promotion, never a trust or evidence signal. */
.badge-sponsored { background: #fbecd1; color: #8a5a00; border-color: #f0dba9; }

/* Claim Detective's own palette -- deliberately distinct from the
   evidence/confidence badges above. This decodes marketing language on
   packaging in general, independent of anything in Sourced's own
   product-evidence database, so it must never be confused with a
   Sourced-issued trust grade. */
.claim-regulated { background: var(--status-good-bg); color: var(--status-good-fg); border-color: var(--status-good-border); }
.claim-loosely_regulated { background: var(--status-warn-bg); color: var(--status-warn-fg); border-color: var(--status-warn-border); }
.claim-unregulated { background: var(--status-neutral-bg); color: var(--status-neutral-fg); border-color: var(--border); }

.business-response { margin-top: 8px; padding: 8px 10px; background: var(--sand); border-radius: 8px; border-left: 3px solid #8a7bc4; }
.business-response strong { font-size: 13px; }

.spend-bar-track { height: 8px; border-radius: 4px; background: var(--sand); overflow: hidden; margin-top: 4px; }
.spend-bar-fill { height: 100%; background: var(--leaf); border-radius: 4px; }

.place-card { display: block; text-decoration: none; color: inherit; }
.place-card h3 { margin: 0 0 2px; font-size: 16.5px; color: var(--ink); }
.place-card .meta { font-size: 13px; color: var(--ink-soft); margin-bottom: 8px; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--leaf);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 11px 16px;
  font-size: 14.5px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
}
.btn.secondary { background: var(--white); color: var(--leaf); border: 1.5px solid var(--leaf); }
.btn.secondary.checked { background: var(--moss); border-color: var(--leaf); }
.btn.ghost { background: transparent; color: var(--ink-soft); border: 1.5px solid var(--border); }
.btn.block { width: 100%; }
.btn.danger { background: var(--coral); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 700; font-size: 13.5px; margin-bottom: 5px; color: var(--ink); }
.field input[type=text], .field input[type=email], .field input[type=password], .field input[type=tel],
.field input[type=number], .field select, .field textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 14.5px;
  background: var(--white);
  color: var(--ink);
  font-family: inherit;
}
.field .hint { font-size: 12px; color: var(--ink-soft); margin-top: 4px; }

.upload-card {
  display: flex; align-items: center; gap: 12px;
  border: 1.5px dashed var(--leaf); border-radius: 12px;
  padding: 16px; cursor: pointer; background: var(--cream);
}
@media (hover: hover) { .upload-card:hover { background: var(--moss); } }
.upload-card-icon { font-size: 28px; flex: none; }
.upload-card-text { font-size: 13.5px; color: var(--ink); line-height: 1.4; }

.toggle-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.toggle-pill {
  border: 1.5px solid var(--border);
  border-radius: 999px;
  padding: 8px 13px;
  font-size: 13.5px;
  cursor: pointer;
  user-select: none;
  background: var(--white);
}
.toggle-pill input { display: none; }
.toggle-pill.checked, .toggle-pill:has(input:checked) { background: var(--moss); border-color: var(--leaf); font-weight: 700; }

.tabs { display: flex; gap: 4px; border-bottom: 1.5px solid var(--border); margin-bottom: 14px; overflow-x: auto; }
.tab-btn {
  border: none;
  background: none;
  padding: 10px 12px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink-soft);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
}
.tab-btn.active { color: var(--leaf); border-color: var(--leaf); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--white);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 30;
}
.bottom-nav a {
  flex: 1;
  text-align: center;
  padding: 9px 4px 8px;
  font-size: 11px;
  color: var(--ink-soft);
  text-decoration: none;
}
.bottom-nav a .icon { display: block; font-size: 19px; margin-bottom: 2px; }
.bottom-nav a .icon.icon-svg { display: flex; justify-content: center; }
.bottom-nav a .icon.icon-svg svg { display: block; }
.bottom-nav a.active { color: var(--leaf); font-weight: 700; }

.section-title { font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.03em; color: var(--ink-soft); margin: 18px 0 8px; }
summary.section-title { cursor: pointer; list-style: none; user-select: none; }
summary.section-title::-webkit-details-marker { display: none; }
@media (hover: hover) { summary.section-title:hover { color: var(--leaf); } }

.notice {
  background: var(--sand);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 12.5px;
  color: var(--ink-soft);
  line-height: 1.5;
}
.notice.warn { background: #fbf1dd; border-color: #f0dba9; }
.notice strong { color: var(--ink); }

.confidence-banner {
  border-radius: 10px;
  padding: 10px 12px;
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 4px;
}
.confidence-banner.confidence-high { background: var(--status-good-bg); color: var(--status-good-fg); }
.confidence-banner.confidence-medium { background: var(--status-warn-bg); color: var(--status-warn-fg); }
.confidence-banner.confidence-low, .confidence-banner.confidence-needs_evidence { background: var(--status-neutral-bg); color: var(--ink-soft); }

.center-hero { text-align: center; padding: 30px 20px; }
.center-hero .logo { font-size: 48px; }
.center-hero h1 { font-size: 26px; margin: 10px 0 4px; color: var(--forest); }
[data-theme="dark"] .center-hero h1 { color: var(--forest); }
.center-hero p { color: var(--ink-soft); font-size: 15px; }

.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; gap: 8px; align-items: center; }
.row.between { justify-content: space-between; }
.small { font-size: 12.5px; color: var(--ink-soft); }
.muted { color: var(--ink-soft); }

hr.divider { border: none; border-top: 1px solid var(--border); margin: 14px 0; }

/* isolation:isolate contains Leaflet's own internal panes/controls (which
   use z-index values up to ~1000) inside this box's own stacking context --
   without it, those panes compete directly with the page's sticky header
   (z-index:20) in the global stacking order and can render on top of it
   while scrolling, since Leaflet's container is otherwise just a plain
   block box with no stacking context of its own. */
.map-wrap { border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); margin-bottom: 12px; position: relative; isolation: isolate; z-index: 0; }
#leaflet-map { width: 100%; height: 280px; background: var(--moss); }

.switch-view { display: flex; gap: 6px; }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(20,30,18,0.5);
  /* Centered at every width, not just desktop -- a bottom-anchored sheet
     on a tall phone/tablet viewport reads as "stuck near the bottom of
     the screen" rather than a centered dialog. */
  display: flex; align-items: center; justify-content: center; padding: 20px;
  /* Leaflet's own controls/panes (public/home.php's map view) go up to
     z-index:1000 internally and don't sit inside any stacking context that
     would contain them -- a modal at z-index:50 could render UNDER the
     map's zoom controls/markers, making them visually "leak through" and
     intercept clicks meant for the modal. 2000 is safely above Leaflet's
     own maximum. */
  z-index: 2000;
}
.modal-sheet {
  background: var(--white); border-radius: 18px; padding: 20px;
  width: 100%; max-width: 720px; max-height: 85vh; overflow-y: auto;
  box-shadow: 0 12px 40px rgba(0,0,0,0.25);
}
.modal-close-btn {
  background: var(--sand); border: none; color: var(--ink-soft);
  width: 30px; height: 30px; border-radius: 50%; font-size: 14px;
  cursor: pointer; flex: none; display: inline-flex; align-items: center; justify-content: center;
}
@media (hover: hover) { .modal-close-btn:hover { background: var(--moss); color: var(--ink); } }
[hidden] { display: none !important; }

.deal-card { border: 2px solid var(--forest); border-radius: calc(var(--radius) + 2px); padding: 18px; margin-bottom: 14px; }
[data-theme="dark"] .deal-card { border-color: var(--leaf); }
.deal-price-cols { display: flex; gap: 8px; margin: 10px 0; }
.deal-price-cols div { flex: 1; text-align: center; background: var(--sand); border-radius: 8px; padding: 8px 4px; }
.deal-price-cols .label { font-size: 10.5px; color: var(--ink-soft); display: block; }
.deal-price-cols .value { font-size: 15px; font-weight: 800; }
.deal-meta { display: flex; gap: 10px; flex-wrap: wrap; font-size: 11px; color: var(--ink-soft); margin: 6px 0; }

.scan-viewport { position: relative; border-radius: var(--radius); overflow: hidden; background: #000; }
.scan-viewport video { width: 100%; display: block; max-height: 320px; object-fit: cover; }
/* A wide, short "letterbox" box instead of a near-square one -- real
   barcodes are wide rectangles, and the old near-square 20% inset made
   alignment harder than it needed to be. Widened and enlarged so there's
   more forgiving room to frame a barcode without having to get unusually
   close; the detection code below crops to this exact same region (kept
   in sync via SCAN_ROI_INSET_X/Y), so a bigger guide box also means a
   bigger actual scan area, not just a bigger-looking one. */
.scan-frame { position: absolute; left: 6%; right: 6%; top: 30%; bottom: 30%; border: 3px solid var(--sun); border-radius: 12px; pointer-events: none; }

.scan-placeholder {
  background: var(--moss); border-radius: var(--radius);
  padding: 36px 20px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.scan-placeholder-icon { width: 64px; height: 40px; color: var(--forest); margin-bottom: 6px; }
.scan-placeholder-title { font-weight: 800; font-size: var(--fs-lg); color: var(--ink); }
.manual-search-input { flex: 1; padding: 11px 12px; border: 1.5px solid var(--border); border-radius: 10px; }
.photo-preview-wrap { margin-top: var(--space-3); }
.photo-preview-img { max-width: 160px; border-radius: 10px; border: 1px solid var(--border); display: block; margin-bottom: var(--space-2); }
.scan-fallback-link { margin-top: var(--space-2); }
.recent-scan-tile { flex: none; width: 110px; padding: var(--space-2); text-align: center; }
.recent-scan-tile .icon-avatar { margin: 0 auto var(--space-2); object-fit: contain; background: var(--white); }

.compat-yes { color: var(--ok); font-weight: 700; }
.compat-no { color: var(--danger); font-weight: 700; }
.compat-ask { color: var(--warn); font-weight: 700; }

textarea { resize: vertical; }

.tooltip-info { cursor: help; border-bottom: 1px dotted var(--ink-soft); }

.accordion-header {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-2);
  padding: 14px; cursor: pointer; list-style: none; user-select: none;
  font-weight: 800; font-size: var(--fs-md); color: var(--ink);
}
.accordion-body { padding: 0 14px 14px; border-top: 1px solid var(--border); }

@media (min-width: 760px) {
  .bottom-nav { max-width: 720px; left: 50%; transform: translateX(-50%); border-radius: 16px 16px 0 0; }
  .accordion-header { padding: 16px 20px; }
  .accordion-body { padding: 0 20px 20px; }
  .tile-row { gap: 12px; }
  .tile-option { padding: 16px 10px; }
  .tile-option .tile-label { font-size: var(--fs-base); }
}

/* ===== Desktop top navigation =====
   A full-width bar living OUTSIDE .container's own max-width (a direct
   sibling of <main>, not inside it), shown only at desktop widths, where it
   replaces both the mobile sticky .app-header and the .bottom-nav tab bar --
   the primary nav becomes a normal top bar instead of an app-style bottom
   dock once there's room for one. Reuses the same forest/white tokens the
   mobile header already uses, just applied to a wider bar with inline nav
   links. */
/* color set once on .app-topnav itself (not per link/chip) so every child
   -- brand, nav links, location chip, icon buttons -- inherits a readable
   color automatically, the same pattern .app-header already relies on.
   Without this, .location-chip/.header-icon-btn's `color:inherit` fell
   through past .app-topnav to the page's own --ink token instead, which
   is a LIGHT color in dark mode -- rendered as near-invisible text on the
   light-green dark-mode bar (--forest inverts to a light mint in dark
   mode, since it doubles as a text-color token elsewhere). */
.app-topnav { display: none; color: var(--white); }
[data-theme="dark"] .app-topnav { color: #10170f; }
.topnav-inner {
  max-width: 1100px; margin: 0 auto; padding: 12px 24px;
  display: flex; align-items: center; gap: 24px;
}
.topnav-brand {
  font-weight: 800; font-size: 18px; color: inherit; text-decoration: none;
  display: flex; align-items: center; gap: 6px; white-space: nowrap;
}
.topnav-links { display: flex; align-items: center; gap: 4px; flex: 1; }
.topnav-link {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 14px; border-radius: 10px;
  font-size: 14px; font-weight: 700; color: inherit;
  opacity: 0.92; text-decoration: none; white-space: nowrap;
}
@media (hover: hover) { .topnav-link:hover { opacity: 1; background: rgba(255,255,255,0.14); } }
.topnav-link.active { opacity: 1; background: rgba(255,255,255,0.26); }
@media (hover: hover) { [data-theme="dark"] .topnav-link:hover { background: rgba(0,0,0,0.1); } }
[data-theme="dark"] .topnav-link.active { background: rgba(0,0,0,0.1); }
.topnav-actions { display: flex; align-items: center; gap: 10px; flex: none; }

@media (min-width: 900px) {
  .app-topnav {
    display: block;
    background: var(--forest);
    box-shadow: 0 1px 0 rgba(0,0,0,0.08);
    position: -webkit-sticky;
    position: sticky; top: 0; z-index: 20;
  }
  .app-header, .bottom-nav { display: none; }
  .container { padding-bottom: 14px; }
  .container:has(.save-btn) { padding-bottom: calc(20px + 50px + 16px); }
}

/* ---------------------------------------------------------------------
   Additive design-system extensions (v2 visual refresh)
   --------------------------------------------------------------------- */

.header-icon-btn {
  background: rgba(255,255,255,0.15);
  border: none;
  color: inherit;
  width: 34px; height: 34px;
  border-radius: 999px;
  font-size: 15px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}
.header-icons { display: flex; gap: 6px; align-items: center; }
.notif-badge {
  position: absolute; top: -2px; right: -2px;
  background: var(--status-bad-fg); color: #fff;
  font-size: 10px; font-weight: 700; line-height: 1;
  min-width: 15px; height: 15px; border-radius: 999px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 3px;
}

.search-bar-link {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 10px 14px;
  color: var(--ink-soft);
  font-size: 14px;
  text-decoration: none;
  margin-bottom: 10px;
}

.home-search-form {
  position: relative;
  margin-bottom: 10px;
}
.home-search-input {
  display: block;
  width: 100%;
  box-sizing: border-box;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 10px 36px 10px 14px;
  color: var(--ink);
  font-size: 14px;
  font-family: inherit;
  outline: none;
}
.home-search-input:focus { border-color: var(--leaf); box-shadow: 0 0 0 2px rgba(111,191,125,0.2); }
.home-search-clear {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-soft);
  font-size: 15px;
  text-decoration: none;
  line-height: 1;
}
.pill-filter-input {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 13px;
  font-family: inherit;
  color: var(--ink);
  outline: none;
}
.pill-filter-input:focus { border-color: var(--leaf); }

.icon-avatar {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  flex: none;
  background: var(--moss);
}
.icon-avatar.sm { width: 30px; height: 30px; font-size: 14px; border-radius: 8px; }
.icon-avatar.lg { width: 64px; height: 64px; font-size: 30px; border-radius: 16px; }

.card-with-icon { display: flex; gap: 10px; align-items: flex-start; }
.card-with-icon .card-body { flex: 1; min-width: 0; }

.back-link { display: inline-flex; align-items: center; gap: 4px; color: var(--leaf); font-weight: 700; text-decoration: none; font-size: 14px; margin-bottom: 8px; }

/* iOS-style toggle switch (keeps existing checkbox markup working) */
.switch-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); gap: 10px; }
.switch-row:last-child { border-bottom: none; }
.switch-row .switch-label { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.switch {
  position: relative; display: inline-block; width: 44px; height: 25px; flex: none;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; cursor: pointer; inset: 0;
  background: var(--border); border-radius: 999px; transition: 0.15s;
}
.switch .slider::before {
  content: ""; position: absolute; height: 19px; width: 19px; left: 3px; top: 3px;
  background: white; border-radius: 50%; transition: 0.15s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.switch input:checked + .slider { background: var(--leaf); }
.switch input:checked + .slider::before { transform: translateX(19px); }

.tile-row { display: flex; gap: 8px; }
.tile-option {
  flex: 1;
  min-width: 0;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 12px 8px;
  text-align: center;
  background: var(--white);
  cursor: pointer;
}
.tile-option input { display: none; }
.tile-option .tile-icon { font-size: 20px; display: block; margin-bottom: 4px; }
.tile-option .tile-label { font-weight: 700; font-size: 13.5px; display: block; overflow-wrap: break-word; }
.tile-option .tile-sub { font-size: 11px; color: var(--ink-soft); }
.tile-option.checked, .tile-option:has(input:checked) { background: var(--moss); border-color: var(--leaf); }

.score-circle {
  width: 56px; height: 56px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 800; flex: none;
  background: var(--status-good-bg); color: var(--status-good-fg);
  border: 3px solid var(--status-good-border);
}
.score-circle.low { background: var(--status-bad-bg); color: var(--status-bad-fg); border-color: #eec4b7; }
.score-circle.mid { background: var(--status-warn-bg); color: var(--status-warn-fg); border-color: var(--status-warn-border); }

.ingredient-row { display: flex; align-items: center; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--border); gap: 8px; font-size: 13.5px; }
.ingredient-row-wrap:last-child .ingredient-row { border-bottom: none; }
.ingredient-row-wrap .evidence-why { margin-bottom: 8px; }

.compare-pair { display: flex; gap: 8px; }
.compare-pair .side { flex: 1; border-radius: 12px; padding: 12px; border: 1.5px solid var(--border); }
.compare-pair .side.organic { background: var(--moss); border-color: var(--leaf); }
.compare-pair .side.conventional { background: var(--sand); }
.compare-pair .side .kind { font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.03em; color: var(--ink-soft); }
.compare-pair .side .pname { font-weight: 800; font-size: 12.5px; margin: 2px 0; text-transform: uppercase; letter-spacing: 0.02em; }
.compare-pair .side .pprice { font-size: 18px; font-weight: 800; }
.compare-pair .side .punit { font-size: 11px; color: var(--ink-soft); }
.compare-pair .side .punit-main { font-size: 19px; font-weight: 800; margin-top: 2px; }
.compare-pair .side .pprice-sub { font-size: 11px; color: var(--ink-soft); margin-top: 2px; }
.compare-pair .side .unit-price-line { font-size: 11.5px; color: var(--ink-soft); margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--border); }

.insight-banner { border-radius: 10px; padding: 9px 11px; font-size: 12.5px; font-weight: 700; margin: 8px 0; }
.insight-banner.good { background: var(--status-good-bg); color: var(--status-good-fg); }
.insight-banner.caution { background: var(--status-warn-bg); color: var(--status-warn-fg); }
.insight-banner.neutral { background: var(--sand); color: var(--ink-soft); }

.road-mode-banner {
  background: var(--forest); color: var(--white); border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: 10px;
}
[data-theme="dark"] .road-mode-banner { color: #10170f; }
.road-mode-banner strong { display: block; margin-bottom: 2px; }
.road-mode-banner .chip { background: rgba(255,255,255,0.18); border-color: transparent; color: inherit; }
.road-mode-banner .chip.active { background: #fff; border-color: #fff; color: var(--forest); font-weight: 700; }

.drawer-panel { border: 1.5px solid var(--border); border-radius: var(--radius); padding: 12px; margin-bottom: 10px; background: var(--white); }
.drawer-panel .section-title:first-child { margin-top: 0; }

.verify-score-card { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.verify-score-card:last-child { border-bottom: none; }
.verify-score-card .vs-icon { width: 34px; height: 34px; border-radius: 9px; background: var(--moss); display: flex; align-items: center; justify-content: center; flex: none; }
.verify-score-card .vs-title { font-weight: 700; font-size: 13.5px; }
.verify-score-card .vs-desc { font-size: 12px; color: var(--ink-soft); }
.verify-score-card .vs-tag { font-size: 11px; font-weight: 800; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }

@media (min-width: 900px) {
  .container { max-width: 980px; }
  .cards-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }
  .cards-grid .card, .cards-grid > a.card { margin-bottom: 0; }

  .modal-sheet { max-height: 80vh; }

  /* Pairs settings-style cards side by side on a wider viewport (Budget
     Mode/Search Radius, Settings/Notifications) -- the primary accordions
     (Hard Excludes/Diet Preferences/Certifications) deliberately stay
     single-column full-width at every size, since they're sequential
     reading tasks, not a settings grid. */
  .settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }
  .settings-grid > .card, .settings-grid > form.card { margin-bottom: 0; }
}

/* Term definition tooltips (onboarding/profile toggle-pills + glossary links).
   Hover on desktop, tap-to-focus on mobile/touch -- both use the same
   :hover/:focus CSS so no separate JS is needed for the interaction itself. */
.toggle-pill { position: relative; }
.info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px; height: 16px;
  margin-left: 4px;
  border-radius: 50%;
  border: none;
  background: none;
  color: var(--leaf);
  font-size: 12px;
  line-height: 1;
  cursor: help;
  padding: 0;
  vertical-align: -1px;
  position: relative;
}
.info-tooltip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  width: min(220px, calc(100vw - 24px));
  max-width: calc(100vw - 24px);
  background: var(--forest);
  color: #fff;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.45;
  text-align: left;
  padding: 10px 12px;
  border-radius: 10px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.25);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.12s ease;
  z-index: 60;
  white-space: normal;
}
[data-theme="dark"] .info-tooltip { color: #10170f; }
.info-tooltip-text { display: block; }
.info-tooltip a { display: inline-block; margin-top: 8px; color: #bfe3c4; font-weight: 700; text-decoration: none; }
[data-theme="dark"] .info-tooltip a { color: #10170f; text-decoration: underline; }
.info-icon:hover .info-tooltip, .info-icon:focus .info-tooltip { opacity: 1; visibility: visible; }
.info-tooltip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: var(--arrow-left, 50%);
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--forest);
}

.term-hint { font-size: 11.5px; color: var(--ink-soft); font-style: italic; }

/* Grocery list "mark as bought" control -- a real bordered checkbox look,
   not an emoji glyph (some emoji render too faintly/inconsistently at small
   sizes to read as a checkbox, especially on mobile). */
.check-box-btn {
  width: 32px; height: 32px; min-width: 32px; flex: none;
  border: 2px solid var(--ink-soft);
  border-radius: 8px;
  background: var(--white);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; padding: 0;
}
.check-box-btn .check-mark { opacity: 0; font-size: 19px; line-height: 1; font-weight: 900; color: #fff; }
.check-box-btn.checked { background: var(--ok); border-color: var(--ok); }
.check-box-btn.checked .check-mark { opacity: 1; }

/* Benefits filter toggle: deliberately NOT styled like the sort chips above
   it (different shape, different color family) so it doesn't read as "one
   more option in the same set" -- it's a separate filter panel, and can be
   on/off independently of whatever sort is selected. */
.filter-toggle-btn {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%; text-align: left;
  background: var(--white); border: 1.5px solid var(--leaf); color: var(--forest);
  border-radius: 10px; padding: 11px 14px; font-size: 13.5px; font-weight: 700;
  cursor: pointer; margin-bottom: 10px;
}
.filter-toggle-btn.active { background: var(--leaf); border-color: var(--leaf); color: #fff; }
.filter-toggle-caret { font-size: 11px; flex: none; }

.lang-switcher-dropdown { position: relative; display: inline-block; margin: 14px auto; text-align: center; width: 100%; }
.lang-switcher-inline { margin: 0; width: auto; text-align: left; }
.lang-switcher-toggle {
  background: var(--white); border: 1.5px solid var(--border); color: var(--ink);
  border-radius: 999px; padding: 7px 14px; font-size: 12.5px; font-weight: 700; cursor: pointer;
}
.lang-switcher-menu {
  position: absolute; top: calc(100% + 4px); left: 0; z-index: 30;
  background: var(--white); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow); padding: 6px; display: flex; flex-direction: column; gap: 2px; min-width: 140px;
  /* Never wider than the viewport minus a little breathing room, regardless
     of which edge it's anchored to -- the fixed min-width above was the
     actual cause of it "floating off the page" on a narrow phone/tablet
     width when its toggle button sits near the container's right edge
     (every current usage: onboarding/welcome's header controls, Profile's
     language row -- both right-aligned via justify-content:space-between). */
  max-width: calc(100vw - 32px);
}
/* Every real usage of the inline variant (onboarding/welcome header, the
   text-size "Aa" menu next to it, Profile's language row) has its toggle
   button sitting at or near the right edge of a flex row -- anchoring the
   menu's LEFT edge there means it opens further right, off the visible
   viewport on a narrow screen. Anchoring the RIGHT edge instead means it
   opens back toward the left, staying on-screen regardless of width. */
.lang-switcher-inline .lang-switcher-menu { left: auto; right: 0; }
.lang-switcher-btn {
  background: none; border: none; color: var(--ink); text-align: left;
  border-radius: 6px; padding: 8px 10px; font-size: 13.5px; font-weight: 600; cursor: pointer; width: 100%;
}
@media (hover: hover) { .lang-switcher-btn:hover { background: var(--sand); } }
.lang-switcher-btn.active { background: var(--moss); color: var(--forest); font-weight: 800; }

.onboarding-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; gap: 10px;
}
.onboarding-header-brand { font-weight: 800; font-size: 16px; color: var(--forest); display: flex; align-items: center; gap: 8px; }
.onboarding-header-back { color: var(--ink); text-decoration: none; font-size: 18px; }
.onboarding-header-controls { display: flex; align-items: center; gap: 8px; }

.onb-progress { margin: 0 16px 10px; height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; }
.onb-progress-fill { height: 100%; background: var(--leaf); border-radius: 2px; transition: width 0.2s ease; }
/* Kept for any old markup still referencing it -- no longer used by onboarding.php. */
.onb-seg { flex: 1; height: 3px; border-radius: 2px; background: var(--border); }
.onb-seg.done { background: var(--leaf); }

.budget-opt {
  display: flex; align-items: center; gap: 14px;
  padding: 13px 16px; border-radius: 12px;
  border: 1.5px solid var(--border);
  cursor: pointer; margin-bottom: 8px;
}
.budget-opt.active { border-color: var(--leaf); background: var(--moss); }
.budget-opt-emoji { font-size: 24px; flex: none; }
.budget-opt-label { font-size: 16px; font-weight: 700; color: var(--ink); }
.budget-opt-desc { font-size: 14px; color: var(--ink-soft); }

.location-opt {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 14px 16px; border-radius: 12px; border: 1.5px solid var(--border);
  background: var(--white); cursor: pointer; text-align: left; margin-bottom: 12px;
}
.location-opt.active { border-color: var(--leaf); background: var(--moss); }
.location-opt-icon {
  width: 42px; height: 42px; border-radius: 10px; background: var(--moss);
  display: flex; align-items: center; justify-content: center; flex: none; font-size: 18px;
}

.onb-summary-row {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 10px 0; border-bottom: 1px solid var(--border); gap: 12px;
}
.onb-summary-row:last-child { border-bottom: none; }
.onb-summary-label { font-size: 13px; color: var(--ink-soft); font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; flex-shrink: 0; }
.onb-summary-value { font-size: 14.5px; color: var(--ink); font-weight: 600; text-align: right; }

/* ---------------------------------------------------------------------
   Visual/UX redesign Phase 1: accordion component + page-title +
   settings-grid. Built on the native <details>/<summary> pattern
   summary.section-title (above) already proves works with zero JS.
   --------------------------------------------------------------------- */

.page-title { font-size: var(--fs-2xl); font-weight: 800; margin: 4px 0 4px; color: var(--ink); }

/* A readable section-divider heading (e.g. "Allergens -- Hard Excludes") --
   replaces the old .small.muted.uppercase convention for these specific
   headings, which rendered at 12.5px and was reported hard to read. Keeps
   full-strength ink color (not muted) and a real heading size so someone
   can tell what they're choosing at a glance. */
.onb-heading { font-size: 17px; font-weight: 800; color: var(--ink); margin: 18px 0 6px; line-height: 1.3; }
.onb-heading:first-child { margin-top: 0; }

.accordion-section {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: var(--space-3);
}
.accordion-header::-webkit-details-marker { display: none; }
/* (hover: hover) excludes touchscreens -- without it, a tap on a phone
   triggers :hover with no real pointer to "unhover" it afterward, so the
   beige highlight stays stuck on an accordion after it's been tapped open,
   not just during the tap itself. */
@media (hover: hover) {
  .accordion-header:hover { background: var(--sand); border-radius: var(--radius); }
}
.accordion-title-wrap { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.accordion-subtitle { font-size: var(--fs-xs); font-weight: 500; color: var(--ink-soft); }
.accordion-count { font-size: 11px; font-weight: 700; background: var(--moss); color: var(--forest); padding: 2px 9px; border-radius: 999px; margin-left: auto; flex: none; }
/* Previously forced near-black text here in dark mode (#10170f) -- correct
   against a bright accent-colored background elsewhere, but wrong here:
   .accordion-count's background is --moss, which is itself dark in dark
   mode, so that override produced unreadable near-black-on-dark-green text
   (confirmed via live review). The un-overridden color: var(--forest) --
   a light mint green in dark mode -- already reads correctly here. */
.accordion-caret { font-size: 12px; color: var(--ink-soft); transition: transform 0.15s ease; flex: none; }
.accordion-section[open] > .accordion-header .accordion-caret { transform: rotate(180deg); }
.accordion-section--caution { border-color: var(--status-warn-border); }
.accordion-section--caution > .accordion-header .accordion-count { background: var(--status-warn-bg); color: var(--status-warn-fg); }

/* Trust Shield -- an at-a-glance evidence-STRENGTH indicator (separate
   metaphor from the good/caution/bad status tokens): solid gold =
   certified/verified, silver outline+check = documented claim, dashed
   bronze = community-reported, thin neutral = no claim on file, red
   alert = evidence contradicts the claim. */
.trust-shield-wrap { display: inline-flex; align-items: center; gap: 6px; }
.trust-shield { width: 30px; height: 34px; flex: none; }
.trust-shield-label { font-size: var(--fs-sm); font-weight: 700; }
.trust-shield--gold .trust-shield-icon { fill: var(--shield-gold); stroke: var(--shield-gold); }
.trust-shield--gold .trust-shield-mark { stroke: var(--shield-gold-bg); }
.trust-shield--gold .trust-shield-label { color: var(--shield-gold); }
.trust-shield--silver .trust-shield-icon { fill: var(--shield-silver-bg); stroke: var(--shield-silver); }
.trust-shield--silver .trust-shield-mark { stroke: var(--shield-silver); }
.trust-shield--silver .trust-shield-label { color: var(--shield-silver); }
.trust-shield--bronze .trust-shield-icon { fill: var(--shield-bronze-bg); stroke: var(--shield-bronze); stroke-dasharray: 3 2; }
.trust-shield--bronze .trust-shield-mark { stroke: var(--shield-bronze); }
.trust-shield--bronze .trust-shield-label { color: var(--shield-bronze); }
.trust-shield--neutral .trust-shield-icon { fill: var(--shield-neutral-bg); stroke: var(--shield-neutral); stroke-dasharray: 2 2; }
.trust-shield--neutral .trust-shield-mark { display: none; }
.trust-shield--neutral .trust-shield-label { color: var(--shield-neutral); }
.trust-shield--alert .trust-shield-icon { fill: var(--shield-alert-bg); stroke: var(--shield-alert); }
.trust-shield--alert .trust-shield-mark { stroke: var(--shield-alert); }
.trust-shield--alert .trust-shield-label { color: var(--shield-alert); }
.trust-shield-sm .trust-shield { width: 20px; height: 23px; }
.trust-shield-sm .trust-shield-label { font-size: var(--fs-xs); }

/* Save list star button: gold fill when at least one list is saved. */
.save-list-star-btn.list-saved svg { fill: var(--sun); stroke: var(--sun); }
/* Per-saved-list favorite star: gold fill when that list is favorited. */
.list-favorite-star-btn.favorited svg { fill: var(--sun); stroke: var(--sun); }

/* Save/Saved toggle star -- outline when unsaved, filled gold when saved. */
/* Restyled from a small inline secondary button into the prominent,
   full-width "★ Save This Place" action the reference app uses -- fixed
   near the bottom so it's reachable while scrolling a long place page,
   pinned above the mobile bottom-nav (76px) and given a lower, unobtrusive
   spot on desktop where there's no bottom-nav to clear. */
.btn.save-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(76px + env(safe-area-inset-bottom, 0px));
  width: calc(100% - 28px); max-width: 680px;
  padding: 14px; border-radius: 13px; font-size: 15px; font-weight: 700;
  background: var(--forest); color: var(--white); border: none; z-index: 15;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
}
[data-theme="dark"] .btn.save-btn { color: #10170f; }
.save-star { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linejoin: round; }
.save-btn--saved .save-star { fill: var(--sun); stroke: var(--sun); }
@media (min-width: 1024px) { .btn.save-btn { bottom: 20px; } }

/* ===== Place page: quick actions / info block / call script =====
   Ported from the reference app's place-detail.php layout. */
.quick-actions { display: flex; gap: 8px; margin-bottom: 14px; }
.quick-action-btn {
  flex: 1; padding: 12px; border-radius: 10px; background: var(--sand);
  border: none; font-size: 14.5px; font-weight: 700; color: var(--ink); cursor: pointer; text-align: center; text-decoration: none;
}
@media (hover: hover) { .quick-action-btn:hover { background: var(--moss); } }
.info-block { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; padding: 14px; background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); }
.call-script { background: var(--moss); border: 1px solid var(--leaf); border-radius: 10px; padding: 12px; font-size: 14.5px; line-height: 1.6; font-style: italic; }

/* Wraps the severity + scope tile-rows together so they collapse/reveal
   as one unit once an exclusion has a saved answer (see
   render_exclude_detail_panel() in app/ui_helpers.php). */
.exclude-picker-group .tile-row + .tile-row { margin-top: var(--space-2); }

/* Stacks on mobile (default block children); pairs up ≥900px, see the
   900px media query above. */
.settings-grid > * { margin-bottom: var(--space-3); }
.settings-grid > *:last-child { margin-bottom: 0; }

/* ===== Accessibility & Display toggles =====
   Same html[data-x] pattern as data-theme/data-text-size above -- header.php
   stamps these from diet_profiles once per request, so every page picks
   them up automatically with no per-page wiring. */
[data-higher-contrast="1"] {
  --ink-soft: #2c3a27;
  --border: #b9c4ac;
  --muted-border: #b9c4ac;
}
/* A @media (prefers-color-scheme: dark) rule used to live here, meant to
   fix the light-mode override above unconditionally winning even in real
   dark mode. It introduced a worse bug: this app's dark mode is driven
   ENTIRELY by the explicit data-theme="dark" attribute (set server-side
   from the saved toggle) -- there is no other prefers-color-scheme
   handling anywhere in this stylesheet for the base palette, so the page
   background/text stay fully light whenever that attribute is absent,
   regardless of the OS's own color-scheme setting. The media query fired
   purely off the OS preference, so anyone with an OS set to dark but this
   app's dark mode OFF got dark-mode-appropriate near-white text
   (--ink-soft: #e9f0e5) painted onto the real, still-light page --
   reading as "text almost invisible," confirmed live. The attribute
   selector below already handles real dark mode correctly and
   unconditionally (it wins by specificity over the light-mode rule above
   whenever data-theme="dark" is actually present) -- no media query
   needed at all. */
[data-theme="dark"][data-higher-contrast="1"] {
  --ink-soft: #e9f0e5;
  --border: #5c6e56;
  --muted-border: #5c6e56;
}
[data-reduced-motion="1"] *,
[data-reduced-motion="1"] *::before,
[data-reduced-motion="1"] *::after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
  scroll-behavior: auto !important;
}
[data-underline-links="1"] a { text-decoration: underline; }

/* ===== Profile: flat list-row layout =====
   A lighter-weight sibling to .accordion-section -- no card border/shadow,
   just a plain row with a bottom divider, used on profile.php in place of
   the boxed accordion look. Built on the same <details>/<summary> pattern
   (zero JS either way), just styled minimally so a page full of them reads
   as one continuous settings list instead of a stack of separate cards. */
.profile-section { margin-top: 26px; }
.profile-section:first-of-type { margin-top: 18px; }
.profile-section-title {
  font-size: var(--fs-xs); font-weight: 800; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--ink-soft); margin: 0 0 2px;
}
.profile-row { border-bottom: 1px solid var(--border); }
.profile-row > summary {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 14px 0; cursor: pointer; list-style: none; user-select: none;
}
.profile-row > summary::-webkit-details-marker { display: none; }
.profile-row > summary:hover .profile-row-edit { text-decoration: underline; }
.profile-row-main { flex: 1; min-width: 0; }
.profile-row-title { font-weight: 700; color: var(--leaf); font-size: var(--fs-md); }
.profile-row-value { color: var(--ink); font-size: var(--fs-md); font-weight: 600; margin-top: 2px; }
.profile-row-value .more-link { color: var(--leaf); font-weight: 700; text-decoration: underline; }
.profile-row-edit { color: var(--leaf); font-weight: 700; font-size: var(--fs-base); flex: none; }
.profile-row-body { padding: 0 0 18px; }
.profile-row-static { padding: 14px 0; border-bottom: 1px solid var(--border); }
.profile-row-static:last-child { border-bottom: none; }
.profile-edit-toggle {
  display: block; width: 100%; text-align: center; padding: 12px;
  background: var(--sage); color: var(--forest); font-weight: 700;
  border: none; border-radius: 10px; cursor: pointer; font-size: var(--fs-base);
}
[data-theme="dark"] .profile-edit-toggle { color: #10170f; }
/* ===== Search pill (search.php) =====
   Ported from the reference app's own search-bar pattern (a rounded pill
   input with an inline magnifying-glass icon + clear button, plus a
   separate rounded "Search" button) onto this app's own tokens -- same
   visual language, no new colors introduced. */
.search-header { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.search-pill {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px;
  background: var(--white); border: 1.5px solid var(--border); border-radius: 999px;
  padding: 5px 6px 5px 16px; min-height: 46px; color: var(--ink-soft);
}
.search-pill:focus-within { border-color: var(--leaf); }
.search-pill svg { flex: none; }
.search-input { flex: 1; min-width: 0; border: none; outline: none; background: none; font: inherit; font-size: 15px; color: var(--ink); padding: 8px 0; }
.search-clear-x {
  flex: none; width: 28px; height: 28px; border-radius: 50%; border: none;
  background: var(--sand); color: var(--ink-soft); font-size: 14px; line-height: 1;
  display: flex; align-items: center; justify-content: center; text-decoration: none; cursor: pointer;
}
.search-pill-btn {
  flex: none; background: var(--forest); color: var(--white); border: none; border-radius: 999px;
  padding: 12px 20px; min-height: 46px; font-size: 14.5px; font-weight: 700; cursor: pointer;
}
[data-theme="dark"] .search-pill-btn { color: #10170f; }

.profile-danger-btn {
  display: block; width: 100%; text-align: center; padding: 12px;
  background: var(--status-bad-bg); color: var(--status-bad-fg); font-weight: 700;
  border: 1px solid var(--status-bad-border); border-radius: 10px; cursor: pointer; font-size: var(--fs-base);
}

/* ===== Home: "For You" personalized shortcuts (home.php) =====
   Each card is a real /search.php?q= link built from the user's own hard
   excludes/diet styles/certs -- never a specific product/place claim, so
   there's nothing here that can be factually wrong regardless of what the
   search turns up. */
.foryou-row { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }
.foryou-card {
  flex: none; display: flex; flex-direction: column; align-items: center; gap: 6px;
  width: 96px; padding: 12px 8px; border-radius: 12px;
  background: var(--white); border: 1px solid var(--border);
  text-decoration: none; color: var(--ink); text-align: center;
}
.foryou-emoji { font-size: 24px; }
.foryou-label { font-size: 12px; font-weight: 700; line-height: 1.3; }
.foryou-row { margin-bottom: var(--space-4, 20px); }

/* Chrome/Edge overlay a native "download image" icon on hover for any
   sufficiently large <img> -- not something this app renders, but
   confusing on promotional imagery (e.g. the Shop Events card) since it
   looks like a real download affordance when nothing is downloadable
   without purchase. Suppressing it is a supported, standards-track CSS
   property (not a hack), applied site-wide so no future image needs this
   repeated per-page. */
img { -webkit-user-drag: none; }



/* Native dialog keeps filter help keyboard accessible above the map. */
.filter-help-dialog {
  width: min(720px, calc(100% - 32px)); max-height: 85vh;
  box-sizing: border-box; overflow-y: auto; padding: 24px;
  border: 1px solid var(--moss); border-radius: 18px;
  background: var(--white); color: var(--ink);
  box-shadow: 0 12px 40px rgba(0,0,0,.25);
}
.filter-help-dialog::backdrop { background: rgba(20,30,18,.5); }
.filter-help-rules { padding-left: 22px; }
.filter-help-rules li { margin-bottom: 12px; }

/* Top place filters expand vertically on small screens. */
.home-quick-toggle { display: none; }
.home-quick-filters .chip-row { flex-wrap: wrap; overflow-x: visible; }
@media (max-width: 759px) {
  .home-quick-toggle { display: flex; margin-bottom: 12px; }
  .home-quick-options { display: none; }
  .home-quick-toggle[aria-expanded="true"] + .home-quick-options { display: block; }
  .home-quick-toggle[aria-expanded="true"] .home-quick-caret { transform: rotate(180deg); }
  .home-quick-filters .chip { white-space: normal; max-width: 100%; box-sizing: border-box; }
}

/* Search filters and recent searches wrap without horizontal scrollbars. */
.search-page .chip-row { flex-wrap: wrap; overflow-x: visible; }
.search-page .chip { white-space: normal; max-width: 100%; overflow-wrap: anywhere; box-sizing: border-box; }

.search-page .search-header { flex-wrap: wrap; }

.search-web-result { overflow-wrap: anywhere; }

/* Shopping sections and controls stay inside the viewport. */
.shop-page .chip-row { flex-wrap: wrap; overflow-x: visible; }
.shop-page .chip { max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
.shop-sections { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 145px), 1fr)); gap: 8px; }
.shop-sections .chip { text-align: center; }
.resource-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); gap: 14px; }
.resource-grid .card { margin: 0; min-width: 0; overflow-wrap: anywhere; }
