/* ── BeWelly — design system ──────────────────────────────────
   Tokens below are docs/brand/tokens.css verbatim (style guide §2–4).
   Change them there first, then copy across; never use raw hex values
   in components. */

/* ==========================================================================
   BeWelly design tokens — v2.0 (October 2026) — green-led, matches the landing page
   Drop-in replacement for v1: same token names, new values, plus --color-warning-*.
   Every component must reference these variables, never raw hex values.
   Light is the default; dark applies via [data-theme="dark"] on <html>,
   or via the OS preference until the user toggles.
   Contrast ratios (WCAG 2.1) are noted where a pairing is load-bearing.
   ========================================================================== */

@import url("https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500..700&family=Inter:wght@400;500;600&display=swap");

:root {
  /* ---- Brand ---- */
  --brand-green:        #2D7A50;  /* the leaves — the brand colour */
  --brand-amber:        #E8963A;  /* the bowl — logo only, plus rare warmth moments */
  --brand-ink:          #1A1F1C;

  /* ---- Surfaces (from the landing page) ---- */
  --color-bg:           #F5F0EB;  /* page background */
  --color-surface:      #FFFFFF;  /* cards, nav, modals */
  --color-surface-2:    #EDE8E1;  /* insets, empty states, AI panel */
  --color-border:       #DDD8D1;  /* decorative card borders & dividers */
  --color-border-strong:#7D8783;  /* input borders — 3.7:1 on surface (WCAG 1.4.11) */

  /* ---- Text (green-grey, not brown) ---- */
  --color-text-primary:   #1A1F1C;  /* 16.7:1 on surface */
  --color-text-secondary: #4D5A52;  /* 7.2:1 on surface — labels, metadata */
  --color-text-tertiary:  #8A9490;  /* 3.1:1 — disabled & hint text ONLY, never content */

  /* ---- Accent (green) — the action colour ---- */
  --color-accent:        #2D7A50;  /* primary buttons, active chips, progress, nav underline */
  --color-accent-hover:  #205C3C;
  --color-on-accent:     #FFFFFF;  /* text/icons on accent — 5.2:1 (hover 7.9:1) */
  --color-accent-text:   #2D7A50;  /* links, active nav label — 5.2:1 surface, 4.6:1 bg */
  --color-accent-subtle: #E8F5EF;  /* hover tint, selected meal cells, today's column */
  --color-accent-border: #B8E0CB;  /* border of selected/tinted areas */
  --color-focus:         #2D7A50;  /* focus outline — ≥3:1 against bg */

  /* ---- Success (shares the green family) ---- */
  --color-success:        #2D7A50;
  --color-success-subtle: #E8F5EF;
  --color-success-text:   #205C3C;  /* green text on success-subtle — 7.1:1 */

  /* ---- Warning (the only amber in the UI) ---- */
  --color-warning:        #C96D1A;  /* icons & small fills — 3.7:1 */
  --color-warning-subtle: #FEF0E4;
  --color-warning-text:   #9A4D0A;  /* amber text on warning-subtle — 5.5:1 */

  /* ---- Destructive ---- */
  --color-destructive:        #C0392B;  /* 5.4:1 on surface */
  --color-destructive-subtle: #FDECEA;

  /* ---- Typography ---- */
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-ui:      "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  --text-xs:   12px;  /* section labels (caps), badges */
  --text-sm:   14px;  /* metadata, table cells, inputs */
  --text-base: 16px;  /* body copy */
  --text-lg:   18px;  /* card titles (Inter 600) */
  --text-xl:   24px;  /* h2 (Fraunces 600) */
  --text-2xl:  28px;  /* h1 (Fraunces 600) */
  --text-stat: 36px;  /* big numbers (Fraunces 600) */

  --leading-tight: 1.2;
  --leading-body:  1.5;
  --tracking-display: -0.02em;
  --tracking-label:    0.06em;

  /* ---- Spacing: 4px base, 8px rhythm ---- */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;

  /* ---- Radius ---- */
  --radius-sm:   6px;   /* small controls, calendar cells */
  --radius-md:   10px;  /* inputs */
  --radius-lg:   12px;  /* cards, buttons */
  --radius-xl:   16px;  /* modals, sheets */
  --radius-pill: 999px; /* badges, filter chips */

  /* ---- Elevation ---- */
  --shadow-card:  0 1px 3px rgba(26, 31, 28, 0.06);
  --shadow-float: 0 8px 24px rgba(26, 31, 28, 0.12);  /* popovers, modals */

  /* ---- Motion ---- */
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --duration-fast: 120ms;  /* hover, press */
  --duration-base: 200ms;  /* popovers, chevrons */

  /* ---- Layout ---- */
  --nav-height: 56px;
  --content-max: 1200px;
  --logo-height: 28px;     /* nav lockup height */
}

/* Dark theme — cool charcoal, matching the landing page hero */
[data-theme="dark"] {
  --brand-green:        #3DBD72;
  --brand-ink:          #E6EDF3;

  --color-bg:           #0D1117;
  --color-surface:      #161B22;
  --color-surface-2:    #1C2128;
  --color-border:       #30363D;
  --color-border-strong:#6E7681;  /* 3.5:1 on surface-2 */

  --color-text-primary:   #E6EDF3;  /* 14.6:1 on surface */
  --color-text-secondary: #8B949E;  /* 5.6:1 on surface */
  --color-text-tertiary:  #6E7681;

  --color-accent:        #3DBD72;
  --color-accent-hover:  #52D487;
  --color-on-accent:     #0D1117;  /* 7.9:1 */
  --color-accent-text:   #3DBD72;  /* 7.2:1 on surface */
  --color-accent-subtle: #0E2319;
  --color-accent-border: #1A4D30;
  --color-focus:         #3DBD72;

  --color-success:        #3DBD72;
  --color-success-subtle: #0E2319;
  --color-success-text:   #3DBD72;  /* 6.9:1 */

  --color-warning:        #E8963A;
  --color-warning-subtle: #2A1A08;
  --color-warning-text:   #E8963A;  /* 7.1:1 */

  --color-destructive:        #F85149;  /* 5.2:1 on surface */
  --color-destructive-subtle: #2A1214;

  --shadow-card:  none;
  --shadow-float: 0 8px 24px rgba(0, 0, 0, 0.5);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --brand-green:        #3DBD72;
    --brand-ink:          #E6EDF3;
    --color-bg:           #0D1117;
    --color-surface:      #161B22;
    --color-surface-2:    #1C2128;
    --color-border:       #30363D;
    --color-border-strong:#6E7681;
    --color-text-primary:   #E6EDF3;
    --color-text-secondary: #8B949E;
    --color-text-tertiary:  #6E7681;
    --color-accent:        #3DBD72;
    --color-accent-hover:  #52D487;
    --color-on-accent:     #0D1117;
    --color-accent-text:   #3DBD72;
    --color-accent-subtle: #0E2319;
    --color-accent-border: #1A4D30;
    --color-focus:         #3DBD72;
    --color-success:        #3DBD72;
    --color-success-subtle: #0E2319;
    --color-success-text:   #3DBD72;
    --color-warning:        #E8963A;
    --color-warning-subtle: #2A1A08;
    --color-warning-text:   #E8963A;
    --color-destructive:        #F85149;
    --color-destructive-subtle: #2A1214;
    --shadow-card:  none;
    --shadow-float: 0 8px 24px rgba(0, 0, 0, 0.5);
  }
}

@media (prefers-reduced-motion: reduce) {
  :root { --duration-fast: 0ms; --duration-base: 0ms; }
}

/* ---- Base ---- */
html { color-scheme: light; }
[data-theme="dark"] { color-scheme: dark; }
body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text-primary);
  font-family: var(--font-ui);
  font-size: var(--text-base);
  line-height: var(--leading-body);
  -webkit-font-smoothing: antialiased;
}
h1, h2, .display {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: var(--tracking-display);
  line-height: var(--leading-tight);
}
h1 { font-size: var(--text-2xl); }
h2 { font-size: var(--text-xl); }
h3 { font-family: var(--font-ui); font-size: var(--text-lg); font-weight: 600; line-height: var(--leading-tight); }
.label { font-size: var(--text-xs); font-weight: 600; letter-spacing: var(--tracking-label); text-transform: uppercase; color: var(--color-text-secondary); }
.stat  { font-family: var(--font-display); font-size: var(--text-stat); font-weight: 600; letter-spacing: var(--tracking-display); line-height: 1; font-variant-numeric: lining-nums tabular-nums; }
a { color: var(--color-accent-text); text-underline-offset: 2px; }
:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }

[data-theme="dark"] .modal-overlay { background: rgba(0,0,0,0.75); }

/* ── Smooth theme switching ──────────────────────────────── */
.theme-transitioning,
.theme-transitioning * {
  transition:
    background-color 0.22s ease,
    border-color     0.22s ease,
    color            0.18s ease,
    box-shadow       0.22s ease !important;
}

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

/* ── Reset & base ────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* `hidden` must win over component display rules (flex, grid). */
[hidden] { display: none !important; }

body {
  font-family: var(--font-ui);
  background: var(--color-bg);
  color: var(--color-text-primary);
  min-height: 100vh;
  font-size: var(--text-base);
  line-height: var(--leading-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Nav (style guide §5) ────────────────────────────────── */
nav {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  height: var(--nav-height);
  padding: 0 var(--space-6);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

nav .brand {
  display: flex;
  align-items: center;
  padding: 14px 14px 14px 0;  /* clear space: half the mark's height */
  flex-shrink: 0;
}

/* One of four logo files shows, by theme and width (nav.js). */
nav .brand img { display: none; height: var(--logo-height); width: auto; }
nav .brand .logo-light { display: block; }
[data-theme="dark"] nav .brand .logo-light { display: none; }
[data-theme="dark"] nav .brand .logo-dark  { display: block; }
@media (max-width: 640px) {
  nav .brand .logo-light,
  [data-theme="dark"] nav .brand .logo-dark  { display: none; }
  nav .brand .mark-light                     { display: block; }
  [data-theme="dark"] nav .brand .mark-light { display: none; }
  [data-theme="dark"] nav .brand .mark-dark  { display: block; }
}

.nav-menu { display: flex; align-items: stretch; align-self: stretch; gap: var(--space-1); }

.nav-link {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 0 var(--space-3);
  background: none;
  border: 0;
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-secondary);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: color var(--duration-fast) var(--ease-out);
}
.nav-link:hover { color: var(--color-text-primary); }
.nav-link.active { color: var(--color-text-primary); }
.nav-link.active::after {
  content: '';
  position: absolute;
  left: var(--space-3);
  right: var(--space-3);
  bottom: 0;
  height: 3px;
  border-radius: 2px 2px 0 0;
  background: var(--color-accent);
}

.nav-group { position: relative; display: flex; }
.nav-group-trigger .icon { transition: transform var(--duration-base) var(--ease-out); }
.nav-group.open .nav-group-trigger .icon { transform: rotate(180deg); }
.nav-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + var(--space-1));
  left: 0;
  min-width: 200px;
  padding: var(--space-1);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-float);
}
.nav-group.open .nav-dropdown { display: block; }
.nav-dropdown a {
  display: block;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  color: var(--color-text-primary);
  text-decoration: none;
}
.nav-dropdown a:hover  { background: var(--color-surface-2); }
.nav-dropdown a.active { background: var(--color-accent-subtle); color: var(--color-accent-text); font-weight: 500; }

.nav-actions { margin-left: auto; display: flex; align-items: center; gap: var(--space-2); }
.nav-household { max-width: 220px; }
.nav-household-name { overflow: hidden; text-overflow: ellipsis; }

.nav-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: var(--radius-lg);
  background: transparent;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-out), color var(--duration-fast) var(--ease-out);
}
.nav-icon-btn:hover { background: var(--color-surface-2); color: var(--color-text-primary); }
.nav-menu-toggle { display: none; }

.nav-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-pill);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  color: var(--color-text-primary);
  font-size: var(--text-xs);
  font-weight: 600;
  text-decoration: none;
}
.nav-avatar:hover { border-color: var(--color-border-strong); }

/* On tablets the household name gives way so the nav fits; the icon stays. */
@media (max-width: 1023px) {
  nav { padding: 0 var(--space-4); }
  .nav-household-name { display: none; }
  nav .nav-signout { padding: 0 var(--space-3); }
}

/* Under 768px the menu items move behind the menu button. */
@media (max-width: 767px) {
  nav { padding: 0 var(--space-4); }
  .nav-menu-toggle { display: inline-flex; }
  nav .nav-signout { display: none; }
  .nav-household-name { display: none; }
  .nav-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    gap: 0;
    padding: var(--space-2) var(--space-4) var(--space-4);
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    box-shadow: var(--shadow-float);
  }
  nav.nav-open .nav-menu { display: flex; }
  .nav-link { min-height: 44px; padding: 0 var(--space-3); border-radius: var(--radius-sm); }
  .nav-link.active { background: var(--color-accent-subtle); }
  .nav-link.active::after { display: none; }
  .nav-group { flex-direction: column; }
  .nav-group-trigger { display: none; }
  .nav-dropdown { display: block; position: static; min-width: 0; padding: 0; border: 0; box-shadow: none; background: none; }
  .nav-dropdown a { min-height: 44px; display: flex; align-items: center; color: var(--color-text-secondary); }
  /* Sign out lives in the menu on small screens. */
  nav.nav-open .nav-signout { display: inline-flex; position: absolute; top: calc(100% + 8px); right: var(--space-4); }
}

/* ── Page layout ─────────────────────────────────────────── */
main {
  max-width: var(--content-max);
  margin: var(--space-10) auto;
  padding: 0 var(--space-6);
}

/* Type (style guide §3): Fraunces for moments, Inter for work. */
h1 {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 600;
  letter-spacing: var(--tracking-display);
  line-height: var(--leading-tight);
  margin-bottom: var(--space-2);
  color: var(--color-text-primary);
}

.subtitle {
  color: var(--color-text-secondary);
  margin-bottom: var(--space-6);
  font-size: var(--text-sm);
}

/* Section label: 12/600 caps, secondary. */
.section-label,
.card h2 {
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-4);
}

.tabular { font-variant-numeric: tabular-nums; }

/* ── Cards (§5) ──────────────────────────────────────────── */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  margin-bottom: var(--space-4);
  box-shadow: var(--shadow-card);
}
.card-clickable { cursor: pointer; transition: background var(--duration-fast) var(--ease-out), border-color var(--duration-fast) var(--ease-out); }
.card-clickable:hover { background: var(--color-accent-subtle); border-color: var(--color-accent-border); }
.card-selected { border: 2px solid var(--color-accent); }

/* ── Inputs (§5): 40px, strong border, 10px radius, focus ring ── */
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="color"]),
select,
textarea {
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  color: var(--color-text-primary);
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  transition: border-color var(--duration-fast) var(--ease-out), box-shadow var(--duration-fast) var(--ease-out);
}
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="color"]),
select { min-height: 40px; padding: 0 var(--space-3); }
textarea { padding: var(--space-2) var(--space-3); }
input::placeholder, textarea::placeholder { color: var(--color-text-tertiary); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--color-focus);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-accent) 25%, transparent);
}
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--color-destructive); }
.field-error { display: flex; align-items: center; gap: var(--space-1); margin-top: var(--space-1); font-size: var(--text-xs); color: var(--color-destructive); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--color-accent); }

.form-row {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-bottom: var(--space-3);
}
.form-row input,
.form-row select,
.form-row textarea { flex: 1; min-width: 140px; }

/* ── Buttons (§5): 40px (44 on touch), 12px radius, Inter 14/600 ── */
.btn {
  min-height: 40px;
  padding: 0 var(--space-5);
  border: 1px solid transparent;
  border-radius: var(--radius-lg);
  cursor: pointer;
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--duration-fast) var(--ease-out), border-color var(--duration-fast) var(--ease-out), color var(--duration-fast) var(--ease-out);
}
@media (pointer: coarse) { .btn { min-height: 44px; } }
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

/* Primary: the one main action per view. */
.btn-primary { background: var(--color-accent); color: var(--color-on-accent); }
.btn-primary:hover { background: var(--color-accent-hover); }

/* Secondary: Edit, Cancel, Prev/Next, Generate variation. */
.btn-secondary { background: var(--color-surface); border-color: var(--color-border-strong); color: var(--color-text-primary); }
.btn-secondary:hover { background: var(--color-surface-2); }

/* Ghost: Clear all, Select all, low-priority links. */
.btn-ghost { background: transparent; color: var(--color-text-secondary); }
.btn-ghost:hover { background: var(--color-surface-2); color: var(--color-text-primary); }

/* Destructive: delete and irreversible actions only. */
.btn-destructive { background: var(--color-surface); border-color: var(--color-destructive); color: var(--color-destructive); }
.btn-destructive:hover { background: var(--color-destructive-subtle); }

.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; pointer-events: none; }

/* ── Badges and filter chips (§5): fully rounded, 24px, 12/500 ── */
.badge, .filter-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  height: 24px;
  padding: 0 10px;
  border-radius: var(--radius-pill);
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
}
.badge svg, .filter-chip svg { width: 12px; height: 12px; }
.badge         { background: var(--color-surface-2); color: var(--color-text-secondary); }
.badge-ai      { background: var(--color-accent-subtle); color: var(--color-accent-text); }
.badge-review  { background: var(--color-warning-subtle); color: var(--color-warning-text); }
.badge-success { background: var(--color-success-subtle); color: var(--color-success-text); }
.filter-chip { background: var(--color-surface); border: 1px solid var(--color-border-strong); color: var(--color-text-primary); cursor: pointer; transition: background var(--duration-fast) var(--ease-out); }
.filter-chip:hover { background: var(--color-surface-2); }
.filter-chip.active { background: var(--color-accent); border-color: var(--color-accent); color: var(--color-on-accent); }

/* ── Lists ───────────────────────────────────────────────── */
ul.item-list { list-style: none; }

ul.item-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.9rem;
}

ul.item-list li:last-child { border-bottom: none; }

ul.item-list .item-name { flex: 1; }
ul.item-list .item-meta { color: var(--color-text-secondary); font-size: 0.82rem; }

ul.item-list li.checked .item-name {
  text-decoration: line-through;
  color: var(--color-text-secondary);
}

/* ── Empty states (§5): inset, centred, icon + heading + one action ── */
.empty, .empty-state {
  background: var(--color-surface-2);
  border-radius: var(--radius-lg);
  padding: var(--space-8) var(--space-6);
  text-align: center;
  color: var(--color-text-secondary);
  font-size: var(--text-sm);
}
.empty-state svg { width: 32px; height: 32px; color: var(--color-text-secondary); margin-bottom: var(--space-3); }
.empty-state h3 { font-family: var(--font-ui); font-size: var(--text-base); font-weight: 600; color: var(--color-text-primary); margin-bottom: var(--space-1); }
.empty-state p { margin-bottom: var(--space-4); }

/* ── Hero (home page) ────────────────────────────────────── */
.hero {
  text-align: center;
  padding: 56px 20px 36px;
}

.hero h1 { font-size: 2.2rem; margin-bottom: 10px; }
.hero p  { color: var(--color-text-secondary); margin-bottom: 40px; }

.nav-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}

.nav-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 26px 20px;
  text-decoration: none;
  color: var(--color-text-primary);
  box-shadow: var(--shadow-card);
  transition: background var(--duration-fast) var(--ease-out), border-color var(--duration-fast) var(--ease-out);
  text-align: center;
}

.nav-card:hover {
  border-color: var(--color-accent);
  background: var(--color-accent-subtle);
}

.nav-card .icon { font-size: 1.75rem; margin-bottom: 10px; }
.nav-card h3    { font-family: var(--font-display); font-size: 0.9rem; font-weight: 700; letter-spacing: -0.01em; }
.nav-card p     { font-size: 0.78rem; color: var(--color-text-secondary); margin-top: 4px; }

/* ── Weight chart placeholder ────────────────────────────── */
.chart-area {
  background: var(--color-surface);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-lg);
  height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-secondary);
  font-size: 0.875rem;
  margin-bottom: 16px;
}

/* ── Upload zone ─────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-lg);
  padding: 32px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--duration-fast) var(--ease-out), background var(--duration-fast) var(--ease-out);
  min-height: 160px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  user-select: none;
}

.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--color-accent);
  background: var(--color-accent-subtle);
}

.upload-zone p { color: var(--color-text-secondary); font-size: 0.875rem; }

/* ── Loading spinner ─────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--color-accent);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Review form sections ────────────────────────────────── */
.form-section { margin-bottom: 22px; }


/* ── Ingredient table ────────────────────────────────────── */
.ingredient-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.ingredient-table th {
  text-align: left;
  color: var(--color-text-secondary);
  font-weight: 600;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 4px 10px 8px 0;
  border-bottom: 1px solid var(--color-border);
}

.ingredient-table td { padding: 4px 8px 4px 0; }

.ingredient-table input {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-family: var(--font-ui);
  background: var(--color-surface);
  color: var(--color-text-primary);
  transition: border-color var(--duration-fast) var(--ease-out), background var(--duration-fast) var(--ease-out);
}

.ingredient-table input:focus {
  outline: none;
  border-color: var(--color-accent);
  background: var(--color-surface-2);
}

/* ── Step rows ───────────────────────────────────────────── */
.step-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 8px;
}

.step-num {
  min-width: 26px;
  height: 26px;
  background: var(--color-accent);
  color: var(--color-on-accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 7px;
}

.step-row textarea {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-family: var(--font-ui);
  resize: vertical;
  background: var(--color-surface);
  color: var(--color-text-primary);
  transition: border-color var(--duration-fast) var(--ease-out), background var(--duration-fast) var(--ease-out);
}

.step-row textarea:focus {
  outline: none;
  border-color: var(--color-accent);
  background: var(--color-surface-2);
}

/* ── Recipe grid ─────────────────────────────────────────── */
.recipes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));  /* 3 columns on desktop */
  gap: var(--space-4);
}

.recipe-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-out), border-color var(--duration-fast) var(--ease-out);
  background: var(--color-surface);
}

.recipe-card { box-shadow: var(--shadow-card); }
.recipe-card:hover {
  background: var(--color-accent-subtle);
  border-color: var(--color-border-strong);
}

.recipe-card-body { padding: var(--space-4); }

.recipe-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 9px;
  gap: 6px;
}

.recipe-card-header-right {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  flex-shrink: 0;
}

/* Card title (§3): Inter 18/600, two lines then an ellipsis. */
.recipe-card-name {
  font-size: var(--text-lg);
  font-weight: 600;
  line-height: var(--leading-tight);
  margin-bottom: var(--space-2);
  color: var(--color-text-primary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.recipe-card-meta {
  font-variant-numeric: tabular-nums;
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.recipe-card-tags {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  margin-top: 6px;
}

/* Neutral tag pill (same as .badge). */
.recipe-tag {
  display: inline-flex; align-items: center; gap: var(--space-1);
  height: 24px; padding: 0 10px; border-radius: var(--radius-pill);
  background: var(--color-surface-2); color: var(--color-text-secondary);
  font-size: var(--text-xs); font-weight: 500;
}

/* ── Recipe detail modal ─────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.40);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px 60px;
  z-index: 100;
  overflow-y: auto;
}

.modal-box {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 28px;
  max-width: 640px;
  width: 100%;
  position: relative;
  box-shadow: var(--shadow-float);
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: none;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--color-text-secondary);
  padding: 4px 8px;
  border-radius: var(--radius-md);
  line-height: 1;
  transition: color var(--duration-fast) var(--ease-out), background var(--duration-fast) var(--ease-out);
}
.modal-close:hover { color: var(--color-text-primary); background: var(--color-surface-2); }

/* ── Mobile font size (prevent iOS auto-zoom) ────────────── */
@media (max-width: 640px) {
  body { font-size: 16px; }
}

/* ── Dashboard stats ─────────────────────────────────────── */
.dash-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}

.dash-stat {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 20px 16px;
  text-align: center;
  box-shadow: var(--shadow-card);
}

.dash-stat-icon  { font-size: 1.4rem; margin-bottom: 8px; display: flex; justify-content: center; }
.dash-stat-value {
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--color-text-primary);
  margin-bottom: 4px;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.025em;
}
.dash-stat-label {
  font-size: 0.68rem;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}
.dash-stat-sub { font-size: 0.73rem; color: var(--color-text-secondary); margin-top: 3px; }

/* ── Skeleton / shimmer loading state ───────────────────── */
.loading {
  color: transparent !important;
  background: linear-gradient(
    90deg,
    var(--color-border) 25%,
    var(--color-surface-2) 50%,
    var(--color-border) 75%
  );
  background-size: 200% 100%;
  border-radius: var(--radius-md);
  animation: shimmer 1.4s infinite;
  user-select: none;
  min-width: 48px;
  display: inline-block;
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .loading { animation: none; background: var(--color-border); }
}

/* ── Confidence badges ───────────────────────────────────── */
.estimate-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 7px 12px;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  color: var(--color-text-secondary);
  margin-top: 8px;
}
.conf-chip {
  padding: 2px 8px;
  border-radius: 8px;
  font-size: 0.7rem;
  font-weight: 700;
}
.conf-high   { background: var(--color-success-subtle); color: var(--color-success); }
.conf-medium { background: color-mix(in srgb, var(--color-accent) 12%, transparent); color: var(--color-accent-text); }
.conf-low    { background: var(--color-destructive-subtle); color: var(--color-destructive); }

/* ── Apple Health row ────────────────────────────────────── */
.health-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.health-card {
  flex: 1;
  min-width: 160px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}
.health-card-icon { flex-shrink: 0; display: flex; align-items: center; color: var(--color-text-secondary); }
.health-card-body { flex: 1; min-width: 0; }
.health-card-value {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--color-text-primary);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.health-card-label {
  font-size: 0.68rem;
  color: var(--color-text-secondary);
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}
.health-card-sub { font-size: 0.76rem; color: var(--color-text-secondary); margin-top: 2px; }

.health-bar-fill-track {
  height: 4px;
  background: var(--color-border);
  border-radius: 2px;
  margin-top: 7px;
  overflow: hidden;
}
.health-card-bar {
  height: 4px;
  background: var(--color-border);
  border-radius: 2px;
  margin-top: 7px;
  overflow: hidden;
}
.health-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.5s ease;
}

/* ── Meal plan health context banner ─────────────────────── */
.health-context-bar {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  align-items: center;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  margin-bottom: 14px;
}
.health-context-bar.sleep-poor {
  background: var(--color-destructive-subtle);
  border: 1px solid color-mix(in srgb, var(--color-destructive) 22%, transparent);
  color: var(--color-destructive);
}
.health-context-bar.sleep-fair {
  background: color-mix(in srgb, var(--color-accent) 9%, transparent);
  border: 1px solid color-mix(in srgb, var(--color-accent) 22%, transparent);
  color: var(--color-accent-text);
}
.health-context-bar.active-high {
  background: var(--color-success-subtle);
  border: 1px solid color-mix(in srgb, var(--color-success) 22%, transparent);
  color: var(--color-success);
}
