/* ============================================================================
   GLP-1 Wellness Companion — layout and components.
   Colour comes exclusively from css/tokens.css. Nothing below hard-codes a hex
   except pure white/black inside coloured pills, where the pairing is fixed.
   ========================================================================= */

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  font-size: var(--step-0);
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  background-image: var(--wash);
  background-attachment: fixed;
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

img, svg { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }

:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }

.shell { width: min(100% - 2rem, var(--shell)); margin-inline: auto; }

.skip-link {
  position: absolute; left: -9999px; top: 8px; z-index: 100;
  background: var(--brand); color: var(--on-brand);
  padding: 10px 18px; border-radius: var(--r-pill); font-weight: 700;
}
.skip-link:focus { left: 16px; }

/* ── Boot cloak ──────────────────────────────────────────────────────── */

/* While .booting is on <html> the shell is hidden and only the splash shows.
   `visibility` rather than `display` so nothing reflows when it lifts. */
.splash { display: none; }

.booting .topbar,
.booting main,
.booting footer.disclaimer,
.booting [data-install-banner] { visibility: hidden; }

.booting .splash {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--sp-4);
  position: fixed; inset: 0; z-index: 60;
  background: var(--bg);
  background-image: var(--wash);
}
.splash-mark {
  display: grid; place-items: center; width: 62px; height: 62px;
  border-radius: 20px; color: var(--on-brand);
  background: linear-gradient(140deg, var(--brand), var(--accent));
  box-shadow: var(--shadow-md);
}
.splash-word {
  font-family: var(--font-display);
  font-size: var(--step-1); font-weight: 700; color: var(--ink);
  letter-spacing: -.01em;
}
@media (prefers-reduced-motion: no-preference) {
  .booting .splash-mark { animation: splashPulse 1.4s ease-in-out infinite; }
}
@keyframes splashPulse {
  0%, 100% { transform: scale(1);    opacity: 1; }
  50%      { transform: scale(1.09); opacity: .78; }
}

.noscript-card {
  max-width: 46ch; margin: 22vh auto; padding: var(--sp-5); text-align: center;
  background: var(--surface); border: 1px solid var(--danger);
  border-radius: var(--r-lg); color: var(--ink);
}
.noscript-card p { color: var(--ink-soft); font-size: var(--step--1); margin-top: 6px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ── Top bar ─────────────────────────────────────────────────────────── */

.topbar {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-3); min-height: 68px; padding-block: var(--sp-2);
}

.brand { display: flex; align-items: center; gap: var(--sp-3); text-align: left; }
.brand-mark {
  display: grid; place-items: center; width: 42px; height: 42px;
  border-radius: 14px; color: var(--on-brand);
  background: linear-gradient(140deg, var(--brand), var(--accent));
  box-shadow: var(--shadow-md);
  flex-shrink: 0;
}
.brand-text strong {
  display: block; font-family: var(--font-display);
  font-size: var(--step-1); font-weight: 700; letter-spacing: -.01em; line-height: 1.15;
}
.brand-text small { display: block; color: var(--ink-soft); font-size: var(--step--1); font-weight: 500; }

.topbar-actions { display: flex; align-items: center; gap: var(--sp-2); flex-shrink: 0; }

.btn-icon {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 40px; padding: 0 var(--sp-3);
  border: 1px solid var(--line); border-radius: var(--r-pill);
  background: var(--surface-2); color: var(--ink);
  font-size: var(--step--1); font-weight: 700;
  transition: background .18s var(--ease), border-color .18s var(--ease);
}
.btn-icon:hover { background: var(--surface-3); border-color: var(--line-strong); }
.btn-icon[data-action="install"] { border-color: var(--brand); color: var(--brand); }

/* ── Tabs ────────────────────────────────────────────────────────────── */

.tabs { padding-bottom: var(--sp-2); }
.tabs-scroll {
  display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none;
  padding-bottom: 2px;
}
.tabs-scroll::-webkit-scrollbar { display: none; }

.tab {
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
  min-height: 38px; padding: 0 var(--sp-4);
  border-radius: var(--r-pill); border: 1px solid transparent;
  color: var(--ink-soft); font-size: var(--step--1); font-weight: 700;
  transition: all .18s var(--ease);
}
.tab:hover { background: var(--surface-2); color: var(--ink); }
.tab[aria-selected="true"] {
  background: var(--brand); color: var(--on-brand);
  box-shadow: 0 4px 12px color-mix(in srgb, var(--brand) 32%, transparent);
}
.tab-emoji { font-size: 1em; }

/* ── Layout primitives ───────────────────────────────────────────────── */

main { padding-block: var(--sp-6) var(--sp-7); }
.stack   { display: flex; flex-direction: column; gap: var(--sp-6); }
.stack-s { display: flex; flex-direction: column; gap: var(--sp-3); }

/* minmax(0, …) throughout on purpose. A bare `1fr` is `minmax(auto, 1fr)`, and
   that `auto` floor stops a track shrinking below its content's min-content
   width — so one wide child (four buttons reading "None / Mild / Mod / Severe")
   silently pushes the whole grid past the viewport and the page scrolls
   sideways. Capping the floor at 0 makes the track obey the container instead. */
.grid { display: grid; gap: var(--sp-4); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(min(190px, 100%), 1fr)); }
.grid > * { min-width: 0; }

/* Slightly translucent so the drifting petals read *through* the layout rather
   than only in the gutters. 92% keeps body text above 15:1 in both themes —
   the tint change is imperceptible, the depth is not. */
.card {
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(10px) saturate(1.15);
  -webkit-backdrop-filter: blur(10px) saturate(1.15);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  box-shadow: var(--shadow-sm);
}
.card-lg { padding: var(--sp-6); border-radius: var(--r-xl); }

.card-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--sp-3); margin-bottom: var(--sp-4);
}
.card-head h2, .card-head h3 { font-size: var(--step-1); font-weight: 700; letter-spacing: -.01em; }
.card-head p { color: var(--ink-soft); font-size: var(--step--1); margin-top: 2px; }

.hero {
  border-radius: var(--r-xl);
  padding: var(--sp-6);
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--brand-soft) 92%, transparent),
    color-mix(in srgb, var(--accent-soft) 80%, transparent));
  border: 1px solid var(--line);
}
.hero h1 {
  font-family: var(--font-display);
  font-size: var(--step-3); font-weight: 700; letter-spacing: -.02em; line-height: 1.1;
}
.hero p { color: var(--ink-soft); margin-top: var(--sp-2); max-width: 60ch; }
.hero-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-5); }

.eyebrow {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--step--1); font-weight: 800; text-transform: uppercase;
  letter-spacing: .07em; color: var(--brand); margin-bottom: var(--sp-2);
}

.muted { color: var(--ink-soft); }
.tiny  { font-size: var(--step--1); }
.center { text-align: center; }

/* ── Buttons ─────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 var(--sp-5);
  border-radius: var(--r-pill); border: 1px solid transparent;
  font-size: var(--step-0); font-weight: 700;
  transition: transform .12s var(--ease), background .18s var(--ease), box-shadow .18s var(--ease);
}
.btn:active { transform: scale(.97); }
.btn-primary {
  background: var(--brand); color: var(--on-brand);
  box-shadow: 0 6px 16px color-mix(in srgb, var(--brand) 30%, transparent);
}
.btn-primary:hover { background: var(--brand-strong); }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-soft { background: var(--surface-2); color: var(--ink); border-color: var(--line); }
.btn-soft:hover { background: var(--surface-3); }
.btn-danger { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }
.btn-sm { min-height: 36px; padding: 0 var(--sp-4); font-size: var(--step--1); }
.btn-block { width: 100%; }

.icon-btn {
  display: grid; place-items: center; width: 34px; height: 34px;
  border-radius: 10px; color: var(--ink-faint);
}
.icon-btn:hover { background: var(--danger-soft); color: var(--danger); }

/* ── Forms ───────────────────────────────────────────────────────────── */

.field { display: flex; flex-direction: column; gap: 5px; }
.field label, .label {
  font-size: var(--step--1); font-weight: 700; color: var(--ink-soft);
}
.input, input[type="text"], input[type="number"], input[type="date"],
input[type="time"], select, textarea {
  width: 100%; min-height: var(--tap);
  padding: 10px var(--sp-3);
  background: var(--surface-2); color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  font-size: var(--step-0);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
textarea { min-height: 76px; resize: vertical; line-height: 1.5; }
.input:focus, input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: var(--ring);
}
/* The native picker glyph is near-invisible on a dark field in WebKit. */
:root[data-theme="dark"] input[type="date"]::-webkit-calendar-picker-indicator,
:root[data-theme="dark"] input[type="time"]::-webkit-calendar-picker-indicator {
  filter: invert(1) brightness(1.6);
}

.check { display: flex; align-items: center; gap: var(--sp-3); cursor: pointer; }
.check input { width: 20px; height: 20px; min-height: 0; accent-color: var(--brand); flex-shrink: 0; }

.chip-row { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  min-height: 34px; padding: 0 var(--sp-3);
  border: 1px solid var(--line-strong); border-radius: var(--r-pill);
  background: var(--surface); color: var(--ink-soft);
  font-size: var(--step--1); font-weight: 600;
  transition: all .15s var(--ease);
}
.chip:hover { border-color: var(--brand); color: var(--ink); }
.chip[aria-pressed="true"] {
  background: var(--brand); color: var(--on-brand); border-color: var(--brand);
}
.chip-static { pointer-events: none; background: var(--surface-2); }

/* ── Stats ───────────────────────────────────────────────────────────── */

.stat {
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(10px) saturate(1.15);
  -webkit-backdrop-filter: blur(10px) saturate(1.15);
  border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--sp-4);
}
.stat-label {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-size: var(--step--1); font-weight: 700; color: var(--ink-soft);
  text-transform: uppercase; letter-spacing: .05em;
}
.stat-value {
  font-family: var(--font-display);
  font-size: var(--step-2); font-weight: 700; line-height: 1.1; margin-top: 6px;
  letter-spacing: -.02em;
}
.stat-unit { font-size: var(--step--1); font-weight: 600; color: var(--ink-soft); }
.stat-note { font-size: var(--step--1); color: var(--ink-soft); margin-top: 4px; }
.stat-icon { font-size: 1.1rem; }

.v-brand { color: var(--brand); }
.v-accent { color: var(--accent); }
.v-mint  { color: var(--mint); }
.v-amber { color: var(--amber); }
.v-danger{ color: var(--danger); }

/* ── Progress bars ───────────────────────────────────────────────────── */

.bar { height: 10px; background: var(--surface-3); border-radius: var(--r-pill); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: inherit; transition: width .45s var(--ease); }
.bar-brand > span { background: linear-gradient(90deg, var(--brand), var(--accent)); }
.bar-mint  > span { background: var(--mint); }
.bar-info  > span { background: var(--info); }

/* ── Notices ─────────────────────────────────────────────────────────── */

.notice {
  display: flex; gap: var(--sp-3); align-items: flex-start;
  padding: var(--sp-4); border-radius: var(--r-md);
  border: 1px solid; font-size: var(--step--1); line-height: 1.5;
}
.notice strong { display: block; margin-bottom: 2px; }
.notice-info  { background: var(--info-soft);   border-color: var(--info);   color: var(--ink); }
.notice-mint  { background: var(--mint-soft);   border-color: var(--mint);   color: var(--ink); }
.notice-amber { background: var(--amber-soft);  border-color: var(--amber);  color: var(--ink); }
.notice-danger{ background: var(--danger-soft); border-color: var(--danger); color: var(--ink); }
.notice-icon { font-size: 1.15rem; line-height: 1; flex-shrink: 0; }

.empty {
  text-align: center; padding: var(--sp-7) var(--sp-4);
  border: 1.5px dashed var(--line-strong); border-radius: var(--r-lg);
  color: var(--ink-soft);
}
.empty-emoji { font-size: 2rem; display: block; margin-bottom: var(--sp-2); }

/* ── Tables ──────────────────────────────────────────────────────────── */

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-md); }
table { width: 100%; border-collapse: collapse; font-size: var(--step--1); }
thead th {
  text-align: left; padding: var(--sp-3); white-space: nowrap;
  background: var(--surface-2); color: var(--ink-soft);
  font-weight: 800; text-transform: uppercase; letter-spacing: .05em;
  font-size: var(--step--1);
}
tbody td { padding: var(--sp-3); border-top: 1px solid var(--line); vertical-align: middle; }
tbody tr:hover { background: var(--surface-2); }
.td-strong { font-weight: 700; white-space: nowrap; }

.tag {
  display: inline-block; padding: 3px 9px; border-radius: var(--r-pill);
  font-size: var(--step--1); font-weight: 700; white-space: nowrap;
  background: var(--surface-2); border: 1px solid var(--line-strong); color: var(--ink);
}
.tag-mint  { background: var(--mint-soft);   border-color: var(--mint);   color: var(--mint); }
.tag-amber { background: var(--amber-soft);  border-color: var(--amber);  color: var(--amber); }
.tag-danger{ background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.tag-brand { background: var(--brand-soft);  border-color: var(--brand);  color: var(--brand); }

/* ── Body map ────────────────────────────────────────────────────────── */

.bodymap-layout { display: grid; gap: var(--sp-5); grid-template-columns: 1.15fr .85fr; align-items: start; }
@media (max-width: 900px) { .bodymap-layout { grid-template-columns: 1fr; } }

.bodymap-stage {
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: var(--sp-3);
  /* The viewBox is 360×420, so an unconstrained stage renders a ~770px-tall
     figure on desktop and pushes everything else off the fold. */
  max-width: 440px; margin-inline: auto; width: 100%;
}
.bodymap-svg { width: 100%; height: auto; }

/* The figure has to separate clearly from the stage behind it — a blush fill
   on a blush panel reads as an empty box. */
.bm-body path, .bm-body ellipse {
  fill: color-mix(in srgb, var(--brand) 17%, var(--surface));
  stroke: color-mix(in srgb, var(--brand) 42%, var(--surface));
  stroke-width: 1.2; stroke-linejoin: round;
}
.bm-hair ellipse, .bm-hair path {
  fill: color-mix(in srgb, var(--brand) 34%, var(--surface));
  stroke: none;
}

.bm-lead { stroke: var(--line-strong); stroke-width: 1; stroke-dasharray: 3 3; fill: none; opacity: .8; }

.bm-zone { cursor: pointer; }
.bm-zone-fill { stroke: var(--surface); stroke-width: 2; transition: all .2s var(--ease); }
.bm-zone.is-ready   .bm-zone-fill { fill: var(--mint); }
.bm-zone.is-resting .bm-zone-fill { fill: var(--amber); }
.bm-zone.is-avoid   .bm-zone-fill { fill: var(--danger); }
.bm-zone:hover .bm-zone-fill { stroke: var(--ink-soft); }
.bm-zone.is-selected .bm-zone-fill { stroke: var(--ink); stroke-width: 3.5; }
.bm-zone-num { fill: #fff; font: 800 12px var(--font-sans); text-anchor: middle; pointer-events: none; }

.bm-pulse { fill: none; stroke: var(--accent); stroke-width: 2.5; opacity: .85; }
@media (prefers-reduced-motion: no-preference) {
  .bm-pulse { animation: bmPulse 2.4s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
}
@keyframes bmPulse {
  0%, 100% { opacity: .85; transform: scale(1); }
  50%      { opacity: .35; transform: scale(1.14); }
}

.bm-pill { cursor: pointer; }
.bm-pill rect { fill: var(--surface); stroke: var(--line-strong); stroke-width: 1.4; transition: all .18s var(--ease); }
.bm-pill.is-ready   rect { stroke: var(--mint); }
.bm-pill.is-resting rect { stroke: var(--amber); }
.bm-pill.is-avoid   rect { stroke: var(--danger); }
.bm-pill:hover rect { fill: var(--surface-2); }
.bm-pill.is-selected rect { fill: var(--brand); stroke: var(--brand); }
.bm-pill.is-selected .bm-pill-label,
.bm-pill.is-selected .bm-pill-sub { fill: var(--on-brand); }
.bm-pill-label { fill: var(--ink); font: 700 12px var(--font-sans); text-anchor: middle; pointer-events: none; }
.bm-pill-sub   { fill: var(--ink-soft); font: 600 9px var(--font-sans); text-anchor: middle; pointer-events: none; }

/* Below 640px the eight pills collide, so they are dropped and the numbered
   dots pair with a tappable legend list underneath instead. */
.bodymap-legend { display: none; }
@media (max-width: 640px) {
  .bm-pill, .bm-lead { display: none; }
  .bodymap-legend { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: var(--sp-4); }
}
.legend-item {
  display: flex; align-items: center; gap: 8px; text-align: left;
  min-height: var(--tap); padding: 6px var(--sp-3);
  border: 1px solid var(--line-strong); border-radius: var(--r-md);
  background: var(--surface); font-size: var(--step--1);
}
.legend-item[aria-pressed="true"] { border-color: var(--brand); background: var(--brand-soft); }
.legend-dot {
  display: grid; place-items: center; width: 24px; height: 24px; flex-shrink: 0;
  border-radius: 50%; color: #fff; font-weight: 800; font-size: 11px;
}
.legend-dot.is-ready { background: var(--mint); }
.legend-dot.is-resting { background: var(--amber); }
.legend-dot.is-avoid { background: var(--danger); }
.legend-text strong { display: block; font-weight: 700; line-height: 1.2; }
.legend-text small { color: var(--ink-soft); }

.status-key { display: flex; flex-wrap: wrap; gap: var(--sp-4); font-size: var(--step--1); }
.status-key span { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-soft); }
.status-key i { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }

.subspot-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px;
  width: 130px; padding: 7px; background: var(--surface-2);
  border: 1px solid var(--line-strong); border-radius: var(--r-md);
}
.subspot {
  aspect-ratio: 1; border-radius: 7px; border: 1px solid var(--line-strong);
  background: var(--surface); display: grid; place-items: center;
}
.subspot span { width: 7px; height: 7px; border-radius: 50%; background: var(--line-strong); }
.subspot.is-last { border-color: var(--amber); background: var(--amber-soft); }
.subspot.is-selected { border-color: var(--brand); background: var(--brand); }
.subspot.is-selected span { background: var(--on-brand); }

/* ── Water cups ──────────────────────────────────────────────────────── */

.cups { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 8px; }
.cup {
  aspect-ratio: 1; border-radius: var(--r-md);
  border: 1px solid var(--line-strong); background: var(--surface-2);
  display: grid; place-items: center; font-size: 1.35rem;
  transition: all .18s var(--ease); filter: grayscale(1) opacity(.45);
}
.cup.is-full { background: var(--info-soft); border-color: var(--info); filter: none; }
.cup:hover { transform: translateY(-2px); }

/* ── Scale 0–3 ───────────────────────────────────────────────────────── */

.scale { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; }
.scale button {
  min-height: 38px; border-radius: var(--r-sm);
  border: 1px solid var(--line-strong); background: var(--surface);
  font-size: var(--step--1); font-weight: 700; color: var(--ink-soft);
  transition: all .15s var(--ease);
}
.scale button[aria-pressed="true"] { color: #fff; border-color: transparent; }
.scale button[aria-pressed="true"][data-v="0"] { background: var(--ink-faint); }
.scale button[aria-pressed="true"][data-v="1"] { background: var(--amber); }
.scale button[aria-pressed="true"][data-v="2"] { background: color-mix(in srgb, var(--amber) 55%, var(--danger)); }
.scale button[aria-pressed="true"][data-v="3"] { background: var(--danger); }

.symptom-cell {
  padding: var(--sp-3); border: 1px solid var(--line);
  border-radius: var(--r-md); background: var(--surface-2);
}
.symptom-cell .label { display: block; margin-bottom: 7px; color: var(--ink); }

.slider-row { display: flex; align-items: center; gap: var(--sp-3); }
input[type="range"] { flex: 1; accent-color: var(--brand); min-height: 0; }
.slider-out {
  min-width: 46px; text-align: center; font-weight: 800;
  padding: 5px 9px; border-radius: var(--r-sm);
  background: var(--brand-soft); color: var(--brand);
}

/* ── Recipes ─────────────────────────────────────────────────────────── */

.recipe-grid { display: grid; gap: var(--sp-4); grid-template-columns: repeat(auto-fill, minmax(258px, 1fr)); }
.recipe-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); overflow: hidden;
  display: flex; flex-direction: column;
  transition: transform .2s var(--ease), box-shadow .2s var(--ease);
}
.recipe-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.recipe-photo { position: relative; aspect-ratio: 16/10; background: var(--surface-3); overflow: hidden; }
.recipe-photo img { width: 100%; height: 100%; object-fit: cover; }

/* Every recipe declares a local photo path. Where the file isn't there yet the
   <img> onerror flips this class on, and a designed illustrated tile takes over
   — never a broken-image icon. Drop the jpg in and it silently becomes a photo,
   no code change. See assets/recipes/MISSING_PHOTOS.md. */
.recipe-photo.is-fallback {
  display: grid; place-items: center;
  /* --tint is set per category below, so thirteen fallbacks don't read as one
     repeated tile. */
  --tint: var(--brand);
  background:
    radial-gradient(circle at 22% 22%, color-mix(in srgb, var(--tint) 30%, transparent), transparent 55%),
    radial-gradient(circle at 78% 76%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 55%),
    linear-gradient(135deg,
      color-mix(in srgb, var(--tint) 16%, var(--surface)),
      color-mix(in srgb, var(--accent) 14%, var(--surface)));
}
.recipe-photo.is-fallback[data-cat="Breakfast"]          { --tint: #E8A33D; }
.recipe-photo.is-fallback[data-cat="Lunch"]              { --tint: var(--mint); }
.recipe-photo.is-fallback[data-cat="Dinner"]             { --tint: var(--accent); }
.recipe-photo.is-fallback[data-cat="Snacks & Smoothies"] { --tint: #2E9BC9; }
.recipe-photo.is-fallback[data-cat="Desserts"]           { --tint: var(--brand); }
/* Fine botanical lattice, so the tile reads as designed rather than empty. */
.recipe-photo.is-fallback::before {
  content: ''; position: absolute; inset: 0;
  background-image:
    radial-gradient(color-mix(in srgb, var(--brand) 30%, transparent) 1px, transparent 1px);
  background-size: 15px 15px;
  opacity: .4;
  mask-image: radial-gradient(ellipse at 50% 50%, transparent 28%, #000 72%);
  -webkit-mask-image: radial-gradient(ellipse at 50% 50%, transparent 28%, #000 72%);
}
.recipe-photo.is-fallback::after {
  content: attr(data-emoji);
  position: relative;
  font-size: clamp(2.4rem, 8vw, 3.4rem);
  line-height: 1;
  filter: drop-shadow(0 6px 14px color-mix(in srgb, var(--brand) 34%, transparent));
}
.recipe-badges {
  position: absolute; inset-inline: 10px; bottom: 10px;
  display: flex; justify-content: space-between; gap: 6px;
}
.badge {
  padding: 3px 9px; border-radius: var(--r-pill);
  font-size: 11px; font-weight: 800; backdrop-filter: blur(6px);
}
.badge-p { background: var(--mint); color: #fff; }
.badge-k { background: rgba(0,0,0,.62); color: #fff; }
.recipe-body { padding: var(--sp-4); flex: 1; display: flex; flex-direction: column; gap: 7px; }
.recipe-body h3 { font-size: var(--step-0); font-weight: 700; line-height: 1.3; }
.recipe-meta { display: flex; justify-content: space-between; font-size: var(--step--1); color: var(--ink-soft); font-weight: 600; }
.recipe-cat { color: var(--brand); text-transform: uppercase; letter-spacing: .05em; font-weight: 800; }
.recipe-foot { padding: 0 var(--sp-4) var(--sp-4); display: flex; gap: 7px; }
.recipe-foot .btn { flex: 1; }
.pick-btn {
  width: var(--tap); min-height: var(--tap); flex: 0 0 var(--tap);
  border: 1px solid var(--line-strong); border-radius: var(--r-pill);
  display: grid; place-items: center; font-size: 1.05rem;
}
.pick-btn[aria-pressed="true"] { background: var(--mint); border-color: var(--mint); color: #fff; }

.tag-mini {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 11px; font-weight: 700; color: var(--ink-soft);
  background: var(--surface-2); border: 1px solid var(--line);
  padding: 2px 7px; border-radius: var(--r-pill);
}

.toolbar { display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: center; justify-content: space-between; }
.search { position: relative; flex: 1; min-width: 190px; max-width: 300px; }
.search input { padding-left: 36px; }
.search::before { content: '🔍'; position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-size: .85rem; }

/* ── Modal ───────────────────────────────────────────────────────────── */

.modal-root { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: var(--sp-4); }
.modal-root[hidden] { display: none; }
.modal-scrim { position: absolute; inset: 0; background: rgba(20, 8, 20, .55); backdrop-filter: blur(4px); }
.modal-panel {
  position: relative; width: min(100%, 620px); max-height: min(88dvh, 780px);
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-xl); box-shadow: var(--shadow-lg); overflow: hidden;
}
.modal-panel.is-wide { width: min(100%, 860px); }
.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--line); flex-shrink: 0;
}
.modal-head h2 { font-size: var(--step-1); font-weight: 700; }
.modal-x { width: 36px; height: 36px; border-radius: 50%; background: var(--surface-2); color: var(--ink-soft); font-weight: 700; }
.modal-x:hover { background: var(--danger-soft); color: var(--danger); }
.modal-body { padding: var(--sp-5); overflow-y: auto; }
.modal-photo { width: 100%; aspect-ratio: 16/9; object-fit: cover; }

/* ── Photo upload ────────────────────────────────────────────────────── */

.photo-drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; text-align: center;
  aspect-ratio: 16/9; width: 100%;
  border: 2px dashed var(--line-strong); border-radius: var(--r-md);
  background: var(--surface-2); color: var(--ink-soft);
  cursor: pointer; overflow: hidden; position: relative;
  transition: border-color .18s var(--ease), background .18s var(--ease);
}
.photo-drop:hover { border-color: var(--brand); background: var(--brand-soft); }
.photo-drop strong { color: var(--ink); font-size: var(--step-0); }
.photo-drop-icon { font-size: 1.9rem; line-height: 1; }
.photo-drop.has-photo { border-style: solid; border-color: var(--brand); padding: 0; }
.photo-drop.has-photo img { width: 100%; height: 100%; object-fit: cover; }
.photo-drop-hint {
  position: absolute; inset-inline: 0; bottom: 0;
  padding: 6px; font-size: var(--step--1); font-weight: 700;
  color: #fff; background: linear-gradient(to top, rgba(0,0,0,.65), transparent);
}

.photo-controls { margin-top: 10px; padding-top: 14px; border-top: 1px solid var(--line); }

/* ── Install banner ──────────────────────────────────────────────────── */

.install-banner {
  position: relative; z-index: 1;
  display: flex; align-items: center; gap: var(--sp-4);
  margin-top: var(--sp-4); padding: var(--sp-4);
  border: 1px solid var(--brand); border-radius: var(--r-lg);
  background: color-mix(in srgb, var(--brand-soft) 92%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: var(--shadow-sm);
}
.install-icon { font-size: 1.7rem; line-height: 1; flex-shrink: 0; }
.install-copy { flex: 1; min-width: 0; }
.install-copy strong { display: block; font-size: var(--step-0); }
.install-copy p { font-size: var(--step--1); color: var(--ink-soft); margin-top: 2px; }
.install-actions { display: flex; gap: 8px; flex-shrink: 0; }

@media (max-width: 620px) {
  .install-banner { flex-wrap: wrap; }
  .install-actions { width: 100%; }
  .install-actions .btn { flex: 1; }
}

/* ── Toast ───────────────────────────────────────────────────────────── */

.toast-root {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%); z-index: 120;
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none; width: min(92vw, 440px);
}
.toast {
  padding: 12px var(--sp-5); border-radius: var(--r-pill);
  background: var(--ink); color: var(--surface);
  font-size: var(--step--1); font-weight: 700; box-shadow: var(--shadow-lg);
  text-align: center;
}
.toast.is-danger { background: var(--danger); color: #fff; }
.toast.is-mint { background: var(--mint); color: #fff; }
@media (prefers-reduced-motion: no-preference) {
  .toast { animation: toastIn .28s var(--ease); }
  @keyframes toastIn { from { opacity: 0; transform: translateY(10px); } }
}

/* ── Onboarding ──────────────────────────────────────────────────────── */

.steps { display: flex; gap: 6px; justify-content: center; margin-top: var(--sp-3); }
.steps i { width: 8px; height: 8px; border-radius: var(--r-pill); background: var(--line-strong); transition: all .3s var(--ease); }
.steps i.on { width: 26px; background: var(--brand); }

.feature-row { display: flex; gap: var(--sp-3); align-items: flex-start; padding: var(--sp-3); border-radius: var(--r-md); background: var(--surface-2); }
.feature-row .fi { font-size: 1.4rem; line-height: 1; }
.feature-row strong { display: block; font-size: var(--step-0); }
.feature-row p { font-size: var(--step--1); color: var(--ink-soft); }

.seg { display: flex; gap: 4px; padding: 4px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-pill); }
.seg button { flex: 1; min-height: 38px; border-radius: var(--r-pill); font-size: var(--step--1); font-weight: 700; color: var(--ink-soft); }
.seg button[aria-pressed="true"] { background: var(--brand); color: var(--on-brand); }

/* ── Charts ──────────────────────────────────────────────────────────── */

.chart-wrap { width: 100%; overflow-x: auto; }
.chart { width: 100%; height: auto; min-width: 300px; }
.ch-grid { stroke: var(--line); stroke-width: 1; stroke-dasharray: 4 4; }
.ch-axis { fill: var(--ink-faint); font: 600 10px var(--font-sans); }
.ch-line { fill: none; stroke: var(--brand); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.ch-area { fill: var(--brand); opacity: .12; }
.ch-dot  { fill: var(--brand); stroke: var(--surface); stroke-width: 2; }
.ch-goal { stroke: var(--mint); stroke-width: 2; stroke-dasharray: 6 4; }
.ch-goal-label { fill: var(--mint); font: 700 10px var(--font-sans); }
.ch-cycle { fill: var(--danger); opacity: .13; }
.ch-shot  { stroke: var(--accent); stroke-width: 1.5; stroke-dasharray: 3 3; opacity: .7; }
.ch-bar   { fill: var(--accent); }
.ch-label { fill: var(--ink-soft); font: 700 10px var(--font-sans); }

/* ── Footer ──────────────────────────────────────────────────────────── */

.disclaimer { padding-bottom: var(--sp-7); }
.disclaimer-card {
  display: flex; gap: var(--sp-3); align-items: flex-start;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: var(--sp-4);
  font-size: var(--step--1); color: var(--ink-soft); line-height: 1.55;
}
.disclaimer-card strong { color: var(--ink); }
.disclaimer-icon { font-size: 1.3rem; line-height: 1; }
.colophon { text-align: center; color: var(--ink-faint); font-size: var(--step--1); margin-top: var(--sp-4); }

/* ── Responsive ──────────────────────────────────────────────────────── */

@media (max-width: 720px) {
  .btn-icon-text { display: none; }
  .btn-icon { padding: 0 12px; }
  .brand-text small { display: none; }
  .card { padding: var(--sp-4); }
  .card-lg { padding: var(--sp-4); }
  .hero { padding: var(--sp-5); }
  main { padding-block: var(--sp-4) var(--sp-6); }
  .stack { gap: var(--sp-4); }
  .modal-panel { max-height: 92dvh; }
  .modal-body { padding: var(--sp-4); }
}

/* Two symptoms side by side leaves ~33px per rating button, which neither fits
   "Severe" nor makes a tappable target. One per row gives each button ~80px. */
@media (max-width: 620px) {
  .symptom-grid { grid-template-columns: minmax(0, 1fr) !important; }
  .scale button { min-height: var(--tap); }
}

@media (max-width: 400px) {
  .bodymap-legend { grid-template-columns: 1fr; }
  .grid-4, .grid-3 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important; animation-iteration-count: 1 !important;
    transition-duration: .001ms !important; scroll-behavior: auto !important;
  }
}
