/* ═══════════════════════════════════════════════════════════════════════════
   Forkful — fitness & calorie tracker · Design System
   Light · Coral + Berry · strict 4pt grid · OKLCH
   Albert Sans (UI) + Archivo expanded (metrics)
   ═══════════════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Albert+Sans:wght@400;500;600;700&family=Archivo:wdth,wght@125,600;125,700&display=swap');

:root {
  /* ── Neutrals (warm, near-white; NOT cream) ─────────────────────────── */
  --bg:          oklch(0.975 0.006 30);   /* app canvas behind cards       */
  --surface:     oklch(1 0 0);            /* cards, sheets                  */
  --surface-2:   oklch(0.972 0.005 30);   /* inset wells, inputs            */
  --ink:         oklch(0.22 0.018 25);    /* primary text — 14.5:1 on white */
  --ink-2:       oklch(0.41 0.016 25);    /* secondary text — 7.6:1         */
  --muted:       oklch(0.515 0.014 25);   /* tertiary — 4.7:1 on white      */
  --line:        oklch(0.912 0.006 30);   /* hairline border                */
  --line-2:      oklch(0.948 0.005 30);   /* faint divider                  */

  /* ── Brand + macro system (color carries meaning) ───────────────────── */
  --coral:       oklch(0.655 0.185 28);   /* primary / brand / carbs        */
  --coral-deep:  oklch(0.58 0.185 27);    /* pressed / text-on-tint (5.6:1) */
  --coral-tint:  oklch(0.955 0.035 32);   /* coral wash                     */
  --berry:       oklch(0.565 0.205 354);  /* protein                        */
  --berry-deep:  oklch(0.50 0.205 354);
  --berry-tint:  oklch(0.955 0.032 352);
  --teal:        oklch(0.70 0.105 195);   /* fat                            */
  --teal-deep:   oklch(0.52 0.085 197);
  --teal-tint:   oklch(0.955 0.03 196);
  --on-accent:   oklch(1 0 0);

  /* Functional status */
  --over:        oklch(0.60 0.205 25);    /* exceeded goal (deep coral-red) */
  --over-tint:   oklch(0.955 0.035 28);
  --warn:        oklch(0.78 0.145 70);
  --good:        oklch(0.62 0.13 162);    /* on-track / success check       */

  /* ── 4pt grid ───────────────────────────────────────────────────────── */
  --s1:  4px;
  --s2:  8px;
  --s3:  12px;
  --s4:  16px;
  --s5:  20px;
  --s6:  24px;
  --s7:  28px;
  --s8:  32px;
  --s10: 40px;
  --s12: 48px;
  --s16: 64px;

  /* ── Shape ──────────────────────────────────────────────────────────── */
  --r1: 8px;
  --r2: 12px;
  --r3: 16px;
  --r4: 20px;
  --r5: 28px;
  --r-full: 9999px;

  /* ── Type (fixed rem-equiv px scale; ~1.25 ratio) ───────────────────── */
  --font-ui:  'Albert Sans', system-ui, sans-serif;
  --font-num: 'Archivo', system-ui, sans-serif;

  --t-display: 40px;  --t-display-lh: 1.0;
  --t-metric:  28px;  --t-metric-lh:  1.05;
  --t-h1:      24px;  --t-h1-lh:      1.15;
  --t-h2:      19px;  --t-h2-lh:      1.2;
  --t-title:   16px;  --t-title-lh:   1.3;
  --t-body:    15px;  --t-body-lh:    1.45;
  --t-sm:      13px;  --t-sm-lh:      1.4;
  --t-xs:      12px;  --t-xs-lh:      1.3;

  /* ── Elevation ──────────────────────────────────────────────────────── */
  --shadow-sm: 0 1px 2px rgba(30, 12, 8, 0.05);
  --shadow-card: 0 1px 3px rgba(30, 12, 8, 0.05), 0 6px 16px -10px rgba(30, 12, 8, 0.12);
  --shadow-pop: 0 8px 28px -8px rgba(30, 12, 8, 0.22), 0 2px 8px rgba(30, 12, 8, 0.08);
  --shadow-fab: 0 8px 18px -6px rgba(30, 14, 10, 0.26);

  /* ── Motion ─────────────────────────────────────────────────────────── */
  --ease-out-quart: cubic-bezier(0.25, 1, 0.5, 1);
  --ease-out-quint: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-out-expo:  cubic-bezier(0.16, 1, 0.3, 1);

  /* ── Device chrome ──────────────────────────────────────────────────── */
  --surround:      oklch(0.17 0.012 30);
  --surround-glow: oklch(0.27 0.02 32);
  --device-hi:     oklch(0.34 0.008 40);
  --device-lo:     oklch(0.16 0.006 40);
  --device-edge:   oklch(0.46 0.010 40);
  --device-btn:    oklch(0.24 0.006 40);
  --r-screen: 46px;
  --r-device: 56px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  /* ── z-scale ────────────────────────────────────────────────────────── */
  --z-base: 1;
  --z-chrome: 6;
  --z-tabbar: 20;
  --z-fab: 21;
  --z-sheet-backdrop: 40;
  --z-sheet: 41;
  --z-toast: 60;
  --z-lang: 80;
}

/* ── Reset ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
*:focus { outline: none; }
*:focus-visible {
  outline: 2.5px solid var(--coral);
  outline-offset: 2px;
  border-radius: 6px;
}
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }
img, svg { display: block; }
input { font: inherit; }

.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;
}

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

/* ── Surround + device ──────────────────────────────────────────────────── */
html { height: 100%; }
body {
  min-height: 100vh;
  width: 100%;
  font-family: var(--font-ui);
  font-size: var(--t-body);
  line-height: var(--t-body-lh);
  color: var(--ink);
  background:
    radial-gradient(120% 90% at 50% 0%, var(--surround-glow) 0%, var(--surround) 60%);
  background-attachment: fixed;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.device-frame {
  position: relative;
  flex-shrink: 0;
  padding: 11px;
  border-radius: var(--r-device);
  background: linear-gradient(150deg, var(--device-hi) 0%, var(--device-lo) 52%, var(--device-hi) 100%);
  box-shadow:
    inset 0 0 0 1.5px var(--device-edge),
    inset 0 1px 1px rgba(255,255,255,0.18),
    0 1px 0 rgba(255,255,255,0.05),
    0 48px 90px -24px rgba(0,0,0,0.62),
    0 18px 44px -20px rgba(0,0,0,0.55);
}
.device-frame::before,
.device-frame::after {
  content: ""; position: absolute; width: 3px; border-radius: 2px;
  background: linear-gradient(90deg, var(--device-lo), var(--device-btn));
}
.device-frame::after  { right: -2px; top: 188px; height: 92px; }
.device-frame::before {
  left: -2px; top: 150px; height: 34px;
  box-shadow: 0 52px 0 0 var(--device-btn), 0 110px 0 0 var(--device-btn);
}

/* ── Screen ─────────────────────────────────────────────────────────────── */
.screen {
  position: relative;
  width: 390px;
  height: 844px;
  border-radius: var(--r-screen);
  overflow: hidden;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  isolation: isolate;
}

.dynamic-island {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  width: 122px; height: 35px; border-radius: var(--r-screen);
  background: #000; z-index: var(--z-chrome); pointer-events: none;
}

.status-bar {
  flex-shrink: 0; height: 54px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 32px 0 36px;
  position: relative; z-index: var(--z-chrome);
  color: var(--ink);
}
.status-time {
  font-size: 15px; font-weight: 600; letter-spacing: 0.2px;
  font-variant-numeric: tabular-nums;
}
.status-icons { display: flex; align-items: center; gap: 7px; }

.home-indicator {
  position: absolute; bottom: calc(8px + var(--safe-bottom)); left: 50%;
  transform: translateX(-50%);
  width: 134px; height: 5px; border-radius: 3px;
  background: rgba(20, 8, 6, 0.22); z-index: var(--z-chrome); pointer-events: none;
}

/* ── App body (scroll region) ───────────────────────────────────────────── */
.app-body {
  flex: 1; min-height: 0; width: 100%;
  overflow-y: auto; overflow-x: hidden;
  scrollbar-width: none; -ms-overflow-style: none;
  position: relative; z-index: var(--z-base);
}
.app-body::-webkit-scrollbar { display: none; }

/* ── Views (JS-switched screens) ────────────────────────────────────────── */
.view { display: none; }
.view.is-active { display: block; }

/* Tab views get the standard padding + clearance for the tab bar AND the
   floating FAB, so the last row can always scroll out from under it */
.view[data-tabbed] {
  padding: var(--s2) var(--s5) calc(160px + var(--safe-bottom));
}

/* Entrance for a freshly-shown tab view */
@keyframes view-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}
.view.is-active[data-tabbed] { animation: view-in 0.34s var(--ease-out-quint); }

/* ── App header ─────────────────────────────────────────────────────────── */
.app-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--s3) 0 var(--s5);
}
.app-greeting { display: flex; flex-direction: column; gap: 2px; }
.app-greeting .eyebrow {
  font-size: var(--t-sm); color: var(--muted); font-weight: 500;
}
.app-greeting h1 {
  font-size: var(--t-h1); line-height: var(--t-h1-lh); font-weight: 700;
  letter-spacing: -0.02em; color: var(--ink);
}
.header-actions { display: flex; align-items: center; gap: var(--s2); }

.icon-btn {
  width: 40px; height: 40px; border-radius: var(--r-full);
  background: var(--surface); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-2);
  transition: background 0.16s, color 0.16s, transform 0.12s var(--ease-out-quint);
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn:active { transform: scale(0.92); }

.avatar-btn {
  width: 40px; height: 40px; border-radius: var(--r-full);
  background: var(--coral);
  color: var(--on-accent);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: var(--t-sm); letter-spacing: 0.02em;
  transition: transform 0.12s var(--ease-out-quint);
}
.avatar-btn:active { transform: scale(0.92); }

/* ── Date strip ─────────────────────────────────────────────────────────── */
.date-strip {
  display: flex; gap: var(--s2);
  overflow-x: auto; scrollbar-width: none;
  margin: 0 calc(-1 * var(--s5)) var(--s5);
  padding: var(--s1) var(--s5) var(--s3);
}
.date-strip::-webkit-scrollbar { display: none; }
.day-pill {
  flex: 0 0 auto; width: 46px;
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  padding: var(--s3) 0;
  border-radius: var(--r3);
  background: transparent; border: 1px solid transparent;
  transition: background 0.16s, border-color 0.16s, transform 0.12s var(--ease-out-quint);
}
.day-pill .dow {
  font-size: var(--t-xs); font-weight: 500; color: var(--muted);
}
.day-pill .dnum {
  font-family: var(--font-num); font-weight: 700; font-size: 17px;
  color: var(--ink-2); line-height: 1;
}
.day-pill .ddot {
  width: 5px; height: 5px; border-radius: 50%; background: var(--coral); opacity: 0;
}
.day-pill[aria-pressed="true"] {
  background: var(--ink); border-color: var(--ink);
}
.day-pill[aria-pressed="true"] .dow,
.day-pill[aria-pressed="true"] .dnum { color: var(--on-accent); }
.day-pill[aria-pressed="true"] .ddot { opacity: 1; background: var(--on-accent); }
.day-pill:not([aria-pressed="true"]):hover { background: var(--surface); border-color: var(--line); }
.day-pill:active { transform: scale(0.95); }

/* ── Bento grid ─────────────────────────────────────────────────────────── */
.bento {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--s3);
}
.tile {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r4);
  padding: var(--s5);
  box-shadow: var(--shadow-card);
  position: relative;
}
.tile--span2 { grid-column: 1 / -1; }
.tile-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: var(--s4);
}
.tile-label {
  font-size: var(--t-sm); font-weight: 600; color: var(--ink-2);
  letter-spacing: -0.005em;
}
.tile-sub { font-size: var(--t-xs); color: var(--muted); font-weight: 500; }

/* metric number helper */
.metric {
  font-family: var(--font-num); font-weight: 700;
  font-stretch: 125%;            /* expanded grotesque for data */
  letter-spacing: -0.01em; color: var(--ink);
  font-variant-numeric: tabular-nums;
}

/* ── Calorie ring tile ──────────────────────────────────────────────────── */
.cal-tile { display: flex; align-items: center; gap: var(--s6); }
.cal-ring { position: relative; width: 156px; height: 156px; flex-shrink: 0; }
.cal-ring-chart { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.cal-ring-center {
  position: absolute; inset: 0; z-index: 2;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1px;
  pointer-events: none;
}
.cal-ring-center .big {
  font-family: var(--font-num); font-weight: 700; font-stretch: 125%;
  font-size: var(--t-display); line-height: 1; color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.cal-ring-center .unit { font-size: var(--t-xs); color: var(--muted); font-weight: 500; }
.cal-side { display: flex; flex-direction: column; gap: var(--s4); flex: 1; min-width: 0; }
.cal-stat { display: flex; flex-direction: column; gap: 2px; }
.cal-stat .k {
  display: flex; align-items: center; gap: 6px;
  font-size: var(--t-xs); color: var(--muted); font-weight: 500;
}
.cal-stat .k .dot { width: 8px; height: 8px; border-radius: 50%; }
.cal-stat .v { font-family: var(--font-num); font-weight: 700; font-size: 18px; color: var(--ink);
  font-variant-numeric: tabular-nums; }
.dot--eaten { background: var(--coral); }
.dot--burned { background: var(--teal); }

/* over-budget chip inside ring tile */
.over-chip {
  display: none; align-items: center; gap: 5px;
  margin-top: var(--s2);
  padding: 4px 10px; border-radius: var(--r-full);
  background: var(--over-tint); color: var(--over);
  font-size: var(--t-xs); font-weight: 700; letter-spacing: 0.01em;
  width: fit-content;
}
.cal-ring.is-over ~ .cal-side .over-chip { display: inline-flex; }

/* ── Macro bars ─────────────────────────────────────────────────────────── */
.macros { display: flex; flex-direction: column; gap: var(--s4); }
.macro { display: flex; flex-direction: column; gap: var(--s2); }
.macro-top { display: flex; align-items: baseline; justify-content: space-between; }
.macro-name { font-size: var(--t-sm); font-weight: 600; color: var(--ink-2); }
.macro-val { font-family: var(--font-num); font-weight: 700; font-size: var(--t-sm); color: var(--ink);
  font-variant-numeric: tabular-nums; }
.macro-val .goal { color: var(--muted); font-weight: 600; }
.macro-track {
  height: 8px; border-radius: var(--r-full); background: var(--surface-2);
  overflow: hidden;
}
.macro-fill {
  height: 100%; border-radius: var(--r-full); width: 0;
  transition: width 0.6s var(--ease-out-expo);
}
.macro--carbs   .macro-fill { background: var(--coral); }
.macro--protein .macro-fill { background: var(--berry); }
.macro--fat     .macro-fill { background: var(--teal); }

/* ── Small stat tiles (steps / water / streak / weight) ─────────────────── */
.stat-tile { display: flex; flex-direction: column; gap: var(--s2); }
.stat-tile .stat-top { display: flex; align-items: center; justify-content: space-between; }
.stat-icon {
  width: 32px; height: 32px; border-radius: var(--r2);
  display: flex; align-items: center; justify-content: center;
}
.stat-icon--steps { background: var(--teal-tint); color: var(--teal-deep); }
.stat-icon--water { background: oklch(0.95 0.04 230); color: oklch(0.5 0.13 245); }
.stat-icon--streak { background: var(--coral-tint); color: var(--coral-deep); }
.stat-icon--weight { background: var(--berry-tint); color: var(--berry-deep); }
.stat-value {
  font-family: var(--font-num); font-weight: 700; font-stretch: 125%;
  font-size: var(--t-metric); line-height: 1; color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.stat-value .su { font-size: var(--t-sm); color: var(--muted); font-weight: 700; margin-left: 2px; }
.stat-name { font-size: var(--t-sm); color: var(--muted); font-weight: 500; }
.stat-meter { height: 6px; border-radius: var(--r-full); background: var(--surface-2); overflow: hidden; margin-top: 2px; }
.stat-meter > i { display: block; height: 100%; border-radius: var(--r-full); transition: width 0.6s var(--ease-out-expo); }
.stat-tile--steps .stat-meter > i { background: var(--teal); }
.stat-tile--water .stat-meter > i { background: oklch(0.6 0.13 245); }

/* water add control */
.water-add {
  position: absolute; top: var(--s5); right: var(--s5);
  width: 28px; height: 28px; border-radius: var(--r-full);
  background: oklch(0.95 0.04 230); color: oklch(0.45 0.14 245);
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.12s var(--ease-out-quint), background 0.16s;
}
.water-add:hover { background: oklch(0.92 0.05 230); }
.water-add:active { transform: scale(0.85); }

/* ── Section header ─────────────────────────────────────────────────────── */
.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin: var(--s7) 0 var(--s4);
}
.section-head h2 {
  font-size: var(--t-h2); font-weight: 700; letter-spacing: -0.015em; color: var(--ink);
}
.section-link { font-size: var(--t-sm); font-weight: 600; color: var(--coral-deep); }
.section-link:hover { text-decoration: underline; text-underline-offset: 2px; }

/* ── Meals ──────────────────────────────────────────────────────────────── */
.meals { display: flex; flex-direction: column; gap: var(--s3); }
.meal {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r4); overflow: hidden;
  box-shadow: var(--shadow-card);
}
.meal-row {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s4) var(--s5);
  width: 100%; text-align: left;
}
.meal-emoji {
  width: 42px; height: 42px; border-radius: var(--r2);
  display: flex; align-items: center; justify-content: center; font-size: 21px;
  background: var(--surface-2); flex-shrink: 0;
}
.meal-info { flex: 1; min-width: 0; }
.meal-name { font-size: var(--t-title); font-weight: 600; color: var(--ink); }
.meal-meta { font-size: var(--t-sm); color: var(--muted); margin-top: 1px; }
.meal-kcal {
  font-family: var(--font-num); font-weight: 700; font-size: var(--t-title); color: var(--ink-2);
  font-variant-numeric: tabular-nums; flex-shrink: 0;
}
.meal-kcal .u { font-size: var(--t-xs); color: var(--muted); font-weight: 600; margin-left: 2px; }
.meal-add {
  width: 32px; height: 32px; border-radius: var(--r-full); flex-shrink: 0;
  background: var(--coral-tint); color: var(--coral-deep);
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.12s var(--ease-out-quint), background 0.16s;
}
.meal-add:hover { background: oklch(0.93 0.05 32); }
.meal-add:active { transform: scale(0.85) rotate(90deg); }

/* logged items inside a meal */
.meal-items { display: flex; flex-direction: column; }
.meal-item {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s3) var(--s5);
  border-top: 1px solid var(--line-2);
  animation: item-in 0.32s var(--ease-out-quint);
}
@keyframes item-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: none; }
}
.meal-item .mi-name { flex: 1; font-size: var(--t-sm); color: var(--ink-2); font-weight: 500; }
.meal-item .mi-portion { font-size: var(--t-xs); color: var(--muted); }
.meal-item .mi-kcal { font-family: var(--font-num); font-weight: 700; font-size: var(--t-sm); color: var(--ink-2);
  font-variant-numeric: tabular-nums; }
.meal-empty {
  padding: var(--s3) var(--s5) var(--s4);
  border-top: 1px solid var(--line-2);
  font-size: var(--t-sm); color: var(--muted);
}

/* flash when a meal receives a new item */
@keyframes meal-flash {
  0%   { background: var(--coral-tint); }
  100% { background: var(--surface); }
}
.meal.just-logged { animation: meal-flash 0.9s var(--ease-out-quart); }

/* ── Tab bar + center FAB ───────────────────────────────────────────────── */
.tab-bar {
  position: absolute; left: 0; right: 0; bottom: 0;
  height: calc(76px + var(--safe-bottom));
  padding: var(--s2) var(--s4) calc(var(--s4) + var(--safe-bottom));
  background: oklch(1 0 0 / 0.82);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-top: 1px solid var(--line);
  display: flex; align-items: flex-start; justify-content: space-around;
  z-index: var(--z-tabbar);
}
.tab-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding-top: 6px; color: var(--muted);
  transition: color 0.16s;
}
.tab-item svg { width: 24px; height: 24px; }
.tab-item .tab-label { font-size: 10px; font-weight: 600; letter-spacing: 0.01em; }
.tab-item[aria-current="page"] { color: var(--coral); }
.tab-item:hover { color: var(--ink-2); }
.tab-item[aria-current="page"]:hover { color: var(--coral); }

/* Floating action button — bottom-right, above the tab bar.
   Right inset equals its float height above the bar for symmetric breathing. */
.tab-fab {
  position: absolute; right: 20px;
  bottom: calc(76px + var(--safe-bottom) + 20px);
  width: 56px; height: 56px; border-radius: var(--r-full);
  background: var(--coral);
  color: var(--on-accent);
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-fab);
  z-index: var(--z-fab);
  transition: transform 0.18s var(--ease-out-quint), box-shadow 0.18s;
}
.tab-fab:hover { background: var(--coral-deep); transform: translateY(-2px) scale(1.04); box-shadow: 0 12px 26px -8px rgba(30, 14, 10, 0.3); }
.tab-fab:active { transform: scale(0.92); }
.tab-fab svg { width: 25px; height: 25px; }

/* ── Toast ──────────────────────────────────────────────────────────────── */
.toast-wrap {
  position: absolute; left: 0; right: 0; bottom: calc(104px + var(--safe-bottom));
  display: flex; justify-content: center; z-index: var(--z-toast);
  pointer-events: none; padding: 0 var(--s5);
}
.toast {
  display: flex; align-items: center; gap: var(--s2);
  padding: 11px var(--s4) 11px var(--s3);
  border-radius: var(--r-full);
  background: var(--ink); color: var(--on-accent);
  font-size: var(--t-sm); font-weight: 600;
  box-shadow: var(--shadow-pop);
  opacity: 0; transform: translateY(14px) scale(0.96);
  transition: opacity 0.22s var(--ease-out-quint), transform 0.32s var(--ease-out-expo);
}
.toast.is-shown { opacity: 1; transform: none; }
.toast-check {
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--good); color: #fff;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}

/* ── Offline banner (low connectivity) ──────────────────────────────────── */
.offline-banner {
  display: none; align-items: center; gap: var(--s2);
  margin: 0 0 var(--s4);
  padding: 10px var(--s4);
  border-radius: var(--r3);
  background: var(--warn); color: oklch(0.30 0.08 70);
  font-size: var(--t-sm); font-weight: 600;
}
body.is-offline .offline-banner { display: flex; animation: item-in 0.3s var(--ease-out-quint); }
.offline-banner svg { flex-shrink: 0; }

/* ── Language dropdown (top-right, outside the device) ──────────────────── */
.lang-switcher {
  position: fixed; left: calc(50% + 234px); top: calc(50% - 422px);
  z-index: var(--z-lang);
}
.lang-switcher > summary { list-style: none; cursor: pointer; }
.lang-switcher > summary::-webkit-details-marker { display: none; }
.lang-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 12px; border-radius: var(--r-full);
  background: rgba(255,255,255,0.10); border: 1px solid rgba(255,255,255,0.22);
  color: rgba(255,255,255,0.86);
  font-size: 12px; font-weight: 600; letter-spacing: 0.5px; white-space: nowrap;
  user-select: none; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 2px 10px rgba(0,0,0,0.22);
  transition: background 0.16s, box-shadow 0.16s;
}
.lang-btn:hover, .lang-switcher[open] .lang-btn {
  background: rgba(255,255,255,0.18); box-shadow: 0 4px 16px rgba(0,0,0,0.28);
}
.lang-chevron { flex-shrink: 0; opacity: 0.7; transition: transform 0.2s ease; }
.lang-switcher[open] .lang-chevron { transform: rotate(180deg); }
.lang-dropdown {
  position: absolute; top: calc(100% + 8px); left: 0; min-width: 156px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; overflow: hidden;
  box-shadow: 0 12px 36px rgba(0,0,0,0.30), 0 2px 8px rgba(0,0,0,0.14);
  animation: lang-in 0.15s ease;
}
@keyframes lang-in { from { opacity: 0; transform: translateY(-5px) scale(0.97); } to { opacity: 1; transform: none; } }
.lang-option {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 11px 14px; font-size: 13px; font-weight: 500; color: var(--ink);
  text-align: left; transition: background 0.1s;
}
.lang-option + .lang-option { border-top: 1px solid var(--line); }
.lang-option:hover { background: var(--surface-2); }
.lang-option.active { font-weight: 700; }
.lang-flag { font-size: 15px; line-height: 1; }
.lang-check { margin-left: auto; color: var(--coral); opacity: 0; }
.lang-option.active .lang-check { opacity: 1; }

/* ── Add sheet (bottom sheet over the screen) ───────────────────────────── */
.sheet-backdrop {
  position: absolute; inset: 0;
  background: rgba(20, 8, 6, 0.42);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  opacity: 0; visibility: hidden;
  transition: opacity 0.28s var(--ease-out-quart), visibility 0.28s;
  z-index: var(--z-sheet-backdrop);
}
.sheet-backdrop.is-open { opacity: 1; visibility: visible; }

.sheet {
  position: absolute; left: 0; right: 0; bottom: 0;
  height: 93%;
  background: var(--surface);
  border-radius: var(--r5) var(--r5) 0 0;
  z-index: var(--z-sheet);
  display: flex; flex-direction: column;
  transform: translateY(101%);
  transition: transform 0.44s var(--ease-out-expo);
  box-shadow: 0 -14px 44px rgba(20, 8, 6, 0.22);
  overflow: hidden;
}
.sheet.is-open { transform: none; }
.sheet-grip { width: 38px; height: 5px; border-radius: 3px; background: var(--line); margin: 10px auto 2px; flex-shrink: 0; }
.sheet-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
  padding: var(--s3) var(--s5) var(--s4); flex-shrink: 0;
}
.sheet-title { font-size: var(--t-h2); font-weight: 700; letter-spacing: -0.015em; color: var(--ink); }
.sheet-title .to { color: var(--coral-deep); }
.sheet-close {
  width: 34px; height: 34px; border-radius: var(--r-full);
  background: var(--surface-2); color: var(--ink-2); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.16s, transform 0.12s var(--ease-out-quint);
}
.sheet-close:hover { background: var(--line); }
.sheet-close:active { transform: scale(0.9); }
.sheet-body { flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: none; padding: 0 var(--s5) var(--s6); }
.sheet-body::-webkit-scrollbar { display: none; }

/* search */
.search {
  display: flex; align-items: center; gap: var(--s3);
  height: 50px; padding: 0 var(--s4);
  background: var(--surface-2); border: 1.5px solid var(--line);
  border-radius: var(--r3); margin-bottom: var(--s4);
  transition: border-color 0.16s;
}
.search:focus-within { border-color: var(--coral); }
.search svg { color: var(--muted); flex-shrink: 0; }
.search input { flex: 1; min-width: 0; border: none; background: none; outline: none; font-size: var(--t-body); color: var(--ink); }
.search input::placeholder { color: var(--muted); }
.search .barcode {
  width: 32px; height: 32px; border-radius: var(--r2); flex-shrink: 0;
  background: var(--surface); border: 1px solid var(--line); color: var(--ink-2);
  display: flex; align-items: center; justify-content: center;
  transition: background 0.16s, transform 0.12s var(--ease-out-quint);
}
.search .barcode:hover { background: var(--surface-2); }
.search .barcode:active { transform: scale(0.9); }

/* segmented */
.segmented { display: flex; gap: 4px; background: var(--surface-2); border-radius: var(--r-full); padding: 4px; margin-bottom: var(--s5); }
.seg {
  flex: 1; padding: 8px 4px; border-radius: var(--r-full);
  font-size: var(--t-sm); font-weight: 600; color: var(--muted);
  transition: background 0.18s var(--ease-out-quart), color 0.18s;
}
.seg[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

.list-label { font-size: var(--t-sm); font-weight: 600; color: var(--muted); margin-bottom: var(--s2); }

/* food row */
.food-row {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s3) 0; width: 100%; text-align: left;
  border-bottom: 1px solid var(--line-2);
}
.food-emoji {
  width: 42px; height: 42px; border-radius: var(--r2); flex-shrink: 0;
  background: var(--surface-2); display: flex; align-items: center; justify-content: center; font-size: 21px;
}
.food-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.food-name { font-size: var(--t-title); font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.food-meta { font-size: var(--t-sm); color: var(--muted); margin-top: 1px; }
.food-kcal { font-family: var(--font-num); font-weight: 700; font-size: var(--t-title); color: var(--ink-2); font-variant-numeric: tabular-nums; flex-shrink: 0; }
.food-kcal .u { font-size: var(--t-xs); color: var(--muted); font-weight: 600; margin-left: 2px; }
.food-quick {
  width: 34px; height: 34px; border-radius: var(--r-full); flex-shrink: 0;
  background: var(--coral); color: var(--on-accent);
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.14s var(--ease-out-quint), background 0.16s;
}
.food-quick:hover { background: var(--coral-deep); }
.food-quick:active { transform: scale(0.82); }
.food-quick.added { background: var(--good); }
.food-empty { padding: var(--s8) var(--s4); text-align: center; color: var(--muted); font-size: var(--t-sm); }

/* barcode scanning overlay */
.scan-state {
  display: none; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--s4); padding: var(--s12) var(--s4); text-align: center;
}
.scan-state.is-on { display: flex; }
.scan-frame {
  width: 150px; height: 150px; border-radius: var(--r4); position: relative;
  background: var(--surface-2);
  box-shadow: inset 0 0 0 2px var(--line);
}
.scan-frame::before {
  content: ""; position: absolute; left: 12px; right: 12px; top: 14px; height: 2px;
  background: var(--coral); border-radius: 2px;
  box-shadow: 0 0 12px 1px oklch(0.655 0.185 28 / 0.6);
  animation: scan-sweep 1.5s var(--ease-out-quart) infinite alternate;
}
@keyframes scan-sweep { from { transform: translateY(0); } to { transform: translateY(120px); } }
.scan-state p { font-size: var(--t-sm); color: var(--muted); }

/* ── Food detail panel (slides over the sheet) ──────────────────────────── */
.fdetail {
  position: absolute; inset: 0; background: var(--surface); z-index: 2;
  transform: translateX(100%); transition: transform 0.38s var(--ease-out-expo);
  display: flex; flex-direction: column;
}
.fdetail.is-open { transform: none; }
.fdetail-head { display: flex; align-items: center; gap: var(--s3); padding: var(--s5); flex-shrink: 0; }
.fdetail-back {
  width: 38px; height: 38px; border-radius: var(--r-full);
  background: var(--surface-2); color: var(--ink); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.16s, transform 0.12s var(--ease-out-quint);
}
.fdetail-back:hover { background: var(--line); }
.fdetail-back:active { transform: scale(0.9); }
.fdetail-body { flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: none; padding: 0 var(--s5) var(--s5); }
.fdetail-body::-webkit-scrollbar { display: none; }

.fd-hero { display: flex; align-items: center; gap: var(--s4); margin-bottom: var(--s6); }
.fd-emoji { width: 60px; height: 60px; border-radius: var(--r3); background: var(--surface-2); display: flex; align-items: center; justify-content: center; font-size: 30px; flex-shrink: 0; }
.fd-title { font-size: var(--t-h1); font-weight: 700; letter-spacing: -0.02em; color: var(--ink); line-height: 1.15; }
.fd-sub { font-size: var(--t-sm); color: var(--muted); margin-top: 2px; }

/* kcal hero */
.fd-kcal {
  display: flex; align-items: baseline; justify-content: center; gap: 6px;
  padding: var(--s5) 0 var(--s3);
}
.fd-kcal .n { font-family: var(--font-num); font-weight: 700; font-stretch: 125%; font-size: 48px; line-height: 1; color: var(--coral); font-variant-numeric: tabular-nums; }
.fd-kcal .u { font-size: var(--t-title); font-weight: 700; color: var(--muted); }

/* nutrition cells */
.nutri { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s3); margin-bottom: var(--s6); }
.nutri-cell { background: var(--surface-2); border-radius: var(--r3); padding: var(--s4) var(--s2); text-align: center; }
.nutri-k { display: flex; align-items: center; justify-content: center; gap: 5px; font-size: var(--t-xs); font-weight: 500; color: var(--muted); }
.nutri-k .dot { width: 7px; height: 7px; border-radius: 50%; }
.nutri-k.carbs .dot { background: var(--coral); }
.nutri-k.protein .dot { background: var(--berry); }
.nutri-k.fat .dot { background: var(--teal); }
.nutri-val { font-family: var(--font-num); font-weight: 700; font-stretch: 125%; font-size: 21px; color: var(--ink); margin-top: 4px; font-variant-numeric: tabular-nums; }

/* field label */
.fd-flabel { font-size: var(--t-sm); font-weight: 600; color: var(--ink-2); margin-bottom: var(--s3); }

/* stepper */
.stepper { display: flex; align-items: center; justify-content: center; gap: var(--s6); margin-bottom: var(--s6); }
.step-btn {
  width: 46px; height: 46px; border-radius: var(--r-full);
  background: var(--surface); border: 1.5px solid var(--line); color: var(--ink);
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.1s var(--ease-out-quint), background 0.16s, border-color 0.16s;
}
.step-btn:hover { background: var(--surface-2); border-color: var(--ink-2); }
.step-btn:active { transform: scale(0.85); background: var(--coral-tint); border-color: var(--coral); }
.step-btn:disabled { opacity: 0.4; pointer-events: none; }
.step-readout { text-align: center; min-width: 96px; }
.step-val { font-family: var(--font-num); font-weight: 700; font-stretch: 125%; font-size: var(--t-metric); color: var(--ink); line-height: 1; font-variant-numeric: tabular-nums; }
.step-unit { font-size: var(--t-xs); color: var(--muted); font-weight: 600; margin-top: 3px; }

/* serving segmented (smaller) */
.serving-seg { display: flex; gap: var(--s2); flex-wrap: wrap; margin-bottom: var(--s7); }
.serving-chip {
  padding: 8px 14px; border-radius: var(--r-full);
  background: var(--surface-2); border: 1.5px solid transparent; color: var(--ink-2);
  font-size: var(--t-sm); font-weight: 600;
  transition: background 0.16s, border-color 0.16s, color 0.16s, transform 0.1s var(--ease-out-quint);
}
.serving-chip:active { transform: scale(0.94); }
.serving-chip[aria-pressed="true"] { background: var(--coral-tint); border-color: var(--coral); color: var(--coral-deep); }

/* meal target segmented */
.meal-seg { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s2); margin-bottom: var(--s7); }
.meal-chip {
  display: flex; align-items: center; gap: var(--s2); padding: 11px var(--s3);
  border-radius: var(--r3); background: var(--surface-2); border: 1.5px solid transparent;
  font-size: var(--t-sm); font-weight: 600; color: var(--ink-2);
  transition: background 0.16s, border-color 0.16s, color 0.16s;
}
.meal-chip .e { font-size: 16px; }
.meal-chip[aria-pressed="true"] { background: var(--coral-tint); border-color: var(--coral); color: var(--coral-deep); }

/* ── Primary button + sticky add bar ────────────────────────────────────── */
.fd-foot { flex-shrink: 0; padding: var(--s4) var(--s5) calc(var(--s5) + var(--safe-bottom)); box-shadow: 0 -1px 0 var(--line); }
.btn-primary {
  width: 100%; height: 54px; border-radius: var(--r3);
  background: var(--coral); color: var(--on-accent);
  font-family: var(--font-ui); font-size: var(--t-title); font-weight: 700;
  display: flex; align-items: center; justify-content: center; gap: var(--s2);
  transition: transform 0.12s var(--ease-out-quint), background 0.2s var(--ease-out-quart);
}
.btn-primary:hover { background: var(--coral-deep); }
.btn-primary:active { transform: scale(0.97); }
.btn-primary.is-success { background: var(--good); pointer-events: none; }
.btn-primary .add-label,
.btn-primary .done-label { display: inline-flex; align-items: center; gap: var(--s2); }
.btn-primary .done-label { display: none; }
.btn-primary.is-success .add-label { display: none; }
.btn-primary.is-success .done-label { display: inline-flex; }

/* celebration burst over the ring */
.burst { position: absolute; width: 8px; height: 8px; border-radius: 50%; pointer-events: none; opacity: 0; }

/* ═══════════════════════════════════════════════════════════════════════════
   PROGRESS
   ═══════════════════════════════════════════════════════════════════════════ */
.chart-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r4); padding: var(--s5); box-shadow: var(--shadow-card); margin-bottom: var(--s4); }
.chart-head { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: var(--s5); }
.chart-head .lbl { font-size: var(--t-sm); font-weight: 600; color: var(--ink-2); }
.chart-head .big { font-family: var(--font-num); font-weight: 700; font-stretch: 125%; font-size: var(--t-metric); color: var(--ink); line-height: 1; font-variant-numeric: tabular-nums; }
.chart-head .big .su { font-size: var(--t-sm); color: var(--muted); font-weight: 700; }
.chart-head .delta { font-size: var(--t-sm); font-weight: 700; }
.chart-head .delta.down { color: var(--good); }

/* weight line chart */
.wchart { width: 100%; height: 132px; }
.wchart .grid-line { stroke: var(--line-2); stroke-width: 1; }
.wchart .area { fill: url(#wArea); opacity: 0.9; }
.wchart .line { fill: none; stroke: var(--coral); stroke-width: 3.5; stroke-linecap: round; stroke-linejoin: round; }
.wchart .dot { fill: var(--surface); stroke: var(--coral); stroke-width: 3; }
.wchart .dot-last { fill: var(--coral); stroke: var(--surface); stroke-width: 3; }
.wchart .xlab { font-family: var(--font-ui); font-size: 10px; font-weight: 600; fill: var(--muted); }

/* weekly calorie bars */
.weekbars { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s2); height: 150px; position: relative; padding-top: var(--s4); }
.weekbar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: var(--s2); height: 100%; justify-content: flex-end; }
.weekbar-track { width: 100%; max-width: 26px; flex: 1; display: flex; align-items: flex-end; }
.weekbar-fill { width: 100%; border-radius: var(--r-full); background: var(--coral); height: 0; transition: height 0.6s var(--ease-out-expo); min-height: 4px; }
.weekbar.over .weekbar-fill { background: var(--over); }
.weekbar.today .weekbar-fill { background: var(--coral); box-shadow: 0 0 0 2px var(--coral-tint); }
.weekbar-day { font-size: var(--t-xs); font-weight: 600; color: var(--muted); }
.weekbar.today .weekbar-day { color: var(--coral-deep); }

/* progress mini stat strip */
.mini-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s3); margin-bottom: var(--s4); }
.mini-stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r3); padding: var(--s4); box-shadow: var(--shadow-card); }
.mini-stat .v { font-family: var(--font-num); font-weight: 700; font-stretch: 125%; font-size: var(--t-h2); color: var(--ink); line-height: 1; font-variant-numeric: tabular-nums; }
.mini-stat .k { font-size: var(--t-xs); color: var(--muted); font-weight: 600; margin-top: 4px; }

/* goal progress bar */
.goalbar-row { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: var(--s3); }
.goalbar-track { height: 9px; border-radius: var(--r-full); background: var(--surface-2); overflow: hidden; }
.goalbar-fill { height: 100%; border-radius: var(--r-full); background: var(--coral); width: 0; transition: width 0.7s var(--ease-out-expo); }

/* ═══════════════════════════════════════════════════════════════════════════
   RECIPES
   ═══════════════════════════════════════════════════════════════════════════ */
.cat-track { display: flex; gap: var(--s2); overflow-x: auto; scrollbar-width: none; margin: 0 calc(-1 * var(--s5)) var(--s5); padding: var(--s1) var(--s5); }
.cat-track::-webkit-scrollbar { display: none; }
.cat-chip { flex: 0 0 auto; padding: 9px 16px; border-radius: var(--r-full); background: var(--surface); border: 1.5px solid var(--line); font-size: var(--t-sm); font-weight: 600; color: var(--ink-2); white-space: nowrap; transition: background 0.16s, border-color 0.16s, color 0.16s, transform 0.1s var(--ease-out-quint); }
.cat-chip:active { transform: scale(0.95); }
.cat-chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--on-accent); }

.recipe-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); }
.recipe-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r4); overflow: hidden; box-shadow: var(--shadow-card); display: flex; flex-direction: column; text-align: left; transition: transform 0.16s var(--ease-out-quint), box-shadow 0.16s; }
.recipe-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-pop); }
.recipe-card:active { transform: translateY(0) scale(0.98); }
.recipe-hero { aspect-ratio: 3/2; display: flex; align-items: center; justify-content: center; font-size: 40px; position: relative; }
.recipe-hero .fav { position: absolute; top: 8px; right: 8px; width: 26px; height: 26px; border-radius: var(--r-full); background: rgba(255,255,255,0.85); color: var(--coral); display: flex; align-items: center; justify-content: center; }
.recipe-hero--1 { background: var(--coral-tint); }
.recipe-hero--2 { background: var(--berry-tint); }
.recipe-hero--3 { background: var(--teal-tint); }
.recipe-hero--4 { background: oklch(0.95 0.045 85); }
.recipe-body { padding: var(--s3) var(--s4) var(--s4); display: flex; flex-direction: column; gap: 6px; flex: 1; }
.recipe-name { font-size: var(--t-sm); font-weight: 600; color: var(--ink); line-height: 1.3; }
.recipe-meta { display: flex; align-items: center; gap: var(--s3); margin-top: auto; }
.recipe-meta span { display: inline-flex; align-items: center; gap: 4px; font-size: var(--t-xs); color: var(--muted); font-weight: 500; }
.recipe-meta .kcal { font-family: var(--font-num); font-weight: 700; color: var(--ink-2); }

/* ═══════════════════════════════════════════════════════════════════════════
   RECIPE DETAIL — Direction A (Log-first): full-screen push over Recipes
   ═══════════════════════════════════════════════════════════════════════════ */
.recipe-detail {
  position: absolute; inset: 0; z-index: var(--z-sheet);
  background: var(--bg); display: flex; flex-direction: column;
  transform: translateX(100%); visibility: hidden;
  transition: transform 0.4s var(--ease-out-expo), visibility 0.4s;
}
.recipe-detail.is-open { transform: none; visibility: visible; }

.rc-scroll { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; scrollbar-width: none; }
.rc-scroll::-webkit-scrollbar { display: none; }
.rc-pad { padding: 0 var(--s5); }

/* hero (reuses .recipe-hero--1..4 gradients for the tapped card's color) */
.rc-hero { position: relative; width: 100%; aspect-ratio: 16 / 11; display: grid; place-items: center; }
.rc-hero .dish { font-size: 92px; filter: drop-shadow(0 8px 18px rgba(40,12,8,0.18)); }
.rc-float { position: absolute; top: calc(env(safe-area-inset-top, 0px) + 50px); display: flex; gap: var(--s2); z-index: 3; }
.rc-float.left { left: var(--s4); }
.rc-float.right { right: var(--s4); }
.rc-fbtn {
  width: 38px; height: 38px; border-radius: var(--r-full);
  background: rgba(255,255,255,0.9); color: var(--ink);
  display: grid; place-items: center; backdrop-filter: blur(6px);
  box-shadow: var(--shadow-sm); transition: transform 0.12s var(--ease-out-quint), background 0.16s;
}
.rc-fbtn:hover { background: #fff; }
.rc-fbtn:active { transform: scale(0.9); }
.rc-fbtn.is-on { background: var(--coral); color: var(--on-accent); }

/* title block */
.rc-titleblock { padding-top: var(--s5); }
.rc-titleblock h1 { font-size: var(--t-h1); line-height: var(--t-h1-lh); font-weight: 700; letter-spacing: -0.022em; color: var(--ink); }
.rc-meta-line { display: flex; align-items: center; gap: var(--s2); margin-top: var(--s3); font-size: var(--t-sm); color: var(--muted); font-weight: 500; }
.rc-meta-line .mi { display: inline-flex; align-items: center; gap: 5px; }
.rc-meta-line .sep { width: 3px; height: 3px; border-radius: 50%; background: var(--line); }

/* tag chips */
.rc-tags { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s4); }
.rc-tag { padding: 6px 12px; border-radius: var(--r-full); border: 1px solid var(--line); background: var(--surface); font-size: var(--t-xs); font-weight: 600; color: var(--ink-2); }
.rc-tag--accent { background: var(--coral-tint); border-color: transparent; color: var(--coral-deep); }

/* section heading */
.rc-sec { margin-top: var(--s7); }
.rc-sec-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: var(--s4); }
.rc-sec-head h2 { font-size: var(--t-h2); font-weight: 700; letter-spacing: -0.015em; color: var(--ink); }
.rc-sec-head .note { font-size: var(--t-sm); color: var(--muted); font-weight: 500; }

/* nutrition: calorie ring + macro bars */
.rc-nutri-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r4);
  box-shadow: var(--shadow-card); padding: var(--s5);
  display: flex; align-items: center; gap: var(--s5);
}
.rc-cring {
  position: relative; width: 116px; height: 116px; border-radius: 50%; flex-shrink: 0;
  background: conic-gradient(from -90deg, var(--coral) var(--p), var(--surface-2) 0);
  display: grid; place-items: center;
}
.rc-cring-hole { position: absolute; inset: 12px; background: var(--surface); border-radius: 50%; }
.rc-cring-txt { position: relative; text-align: center; }
.rc-cring-txt b { display: block; font-family: var(--font-num); font-weight: 700; font-stretch: 125%; font-size: 30px; line-height: 1; color: var(--ink); font-variant-numeric: tabular-nums; }
.rc-cring-txt span { font-size: var(--t-xs); color: var(--muted); font-weight: 500; }
.rc-macro-list { flex: 1; display: flex; flex-direction: column; gap: var(--s4); }
.rc-macro { display: flex; flex-direction: column; gap: 6px; }
.rc-macro-top { display: flex; align-items: baseline; justify-content: space-between; }
.rc-macro-k { display: inline-flex; align-items: center; gap: 6px; font-size: var(--t-sm); font-weight: 600; color: var(--ink-2); }
.rc-macro-k .dot { width: 8px; height: 8px; border-radius: 50%; }
.rc-macro-v { font-family: var(--font-num); font-weight: 700; font-size: var(--t-sm); color: var(--ink); font-variant-numeric: tabular-nums; }
.rc-macro-track { height: 7px; border-radius: var(--r-full); background: var(--surface-2); overflow: hidden; }
.rc-macro-track i { display: block; height: 100%; border-radius: var(--r-full); transition: width 0.5s var(--ease-out-expo); }
.dot--carbs, .fill--carbs { background: var(--coral); }
.dot--protein, .fill--protein { background: var(--berry); }
.dot--fat, .fill--fat { background: var(--teal); }

/* servings stepper */
.rc-serv {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
  background: var(--surface-2); border-radius: var(--r3); padding: var(--s2) var(--s3); margin-bottom: var(--s4);
}
.rc-serv .lab { font-size: var(--t-sm); font-weight: 600; color: var(--ink-2); padding-left: 6px; }
.rc-serv .ctl { display: flex; align-items: center; gap: var(--s3); }
.rc-sbtn {
  width: 34px; height: 34px; border-radius: var(--r-full); background: var(--surface); border: 1px solid var(--line);
  color: var(--ink); display: grid; place-items: center; transition: transform 0.1s var(--ease-out-quint), background 0.15s;
}
.rc-sbtn:hover { background: var(--coral-tint); }
.rc-sbtn:active { transform: scale(0.86); }
.rc-sbtn:disabled { opacity: 0.4; pointer-events: none; }
.rc-serv-val { font-family: var(--font-num); font-weight: 700; font-stretch: 125%; font-size: var(--t-title); color: var(--ink); min-width: 18px; text-align: center; font-variant-numeric: tabular-nums; }

/* ingredients */
.rc-ings { display: flex; flex-direction: column; }
.rc-ing { display: flex; align-items: center; gap: var(--s3); padding: var(--s3) 0; border-bottom: 1px solid var(--line-2); }
.rc-ing:last-child { border-bottom: none; }
.rc-ing-thumb { width: 40px; height: 40px; border-radius: var(--r2); background: var(--surface-2); display: grid; place-items: center; font-size: 20px; flex-shrink: 0; }
.rc-ing-name { flex: 1; font-size: var(--t-body); color: var(--ink); font-weight: 500; }
.rc-amt { font-family: var(--font-num); font-weight: 700; font-size: var(--t-sm); color: var(--ink-2); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* directions */
.rc-steps { display: flex; flex-direction: column; gap: var(--s5); }
.rc-step { display: grid; grid-template-columns: 28px 1fr; gap: var(--s3); }
.rc-step-n { width: 28px; height: 28px; border-radius: 50%; background: var(--ink); color: var(--on-accent); display: grid; place-items: center; font-family: var(--font-num); font-weight: 700; font-size: 13px; }
.rc-step p { font-size: var(--t-body); line-height: 1.5; color: var(--ink-2); padding-top: 3px; }

/* sticky foot reuses .btn-primary */
.rc-foot { flex-shrink: 0; padding: var(--s4) var(--s5) calc(var(--s5) + var(--safe-bottom)); box-shadow: 0 -1px 0 var(--line); background: var(--surface); }

/* ═══════════════════════════════════════════════════════════════════════════
   PROFILE
   ═══════════════════════════════════════════════════════════════════════════ */
.profile-head { display: flex; align-items: center; gap: var(--s4); padding: var(--s2) 0 var(--s6); }
.profile-avatar { width: 64px; height: 64px; border-radius: var(--r-full); background: var(--coral); color: var(--on-accent); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: var(--t-h2); flex-shrink: 0; }
.profile-name { font-size: var(--t-h1); font-weight: 700; letter-spacing: -0.02em; color: var(--ink); }
.profile-sub { font-size: var(--t-sm); color: var(--muted); margin-top: 2px; }
.profile-goalpill { display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; padding: 4px 10px; border-radius: var(--r-full); background: var(--coral-tint); color: var(--coral-deep); font-size: var(--t-xs); font-weight: 700; }

.goal-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s3); margin-bottom: var(--s6); }
.goal-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r3); padding: var(--s4) var(--s3); text-align: center; box-shadow: var(--shadow-card); }
.goal-card .gv { font-family: var(--font-num); font-weight: 700; font-stretch: 125%; font-size: var(--t-h2); color: var(--ink); line-height: 1; font-variant-numeric: tabular-nums; }
.goal-card .gv .su { font-size: var(--t-xs); color: var(--muted); font-weight: 700; }
.goal-card .gk { font-size: var(--t-xs); color: var(--muted); font-weight: 600; margin-top: 5px; }

.settings { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r4); overflow: hidden; box-shadow: var(--shadow-card); margin-bottom: var(--s4); }
.set-row { display: flex; align-items: center; gap: var(--s3); padding: var(--s4) var(--s5); width: 100%; text-align: left; }
.set-row + .set-row { border-top: 1px solid var(--line-2); }
.set-ico { width: 34px; height: 34px; border-radius: var(--r2); background: var(--surface-2); color: var(--ink-2); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.set-label { flex: 1; font-size: var(--t-body); font-weight: 500; color: var(--ink); }
.set-val { font-size: var(--t-sm); color: var(--muted); font-weight: 500; }
.set-row[role="button"] .set-chev { color: var(--muted); flex-shrink: 0; }
.set-row[role="button"]:hover { background: var(--surface-2); }

/* toggle switch — physical snap */
.switch { position: relative; width: 46px; height: 28px; border-radius: var(--r-full); background: var(--line); flex-shrink: 0; transition: background 0.22s var(--ease-out-quart); }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform 0.26s var(--ease-out-expo); }
.switch[aria-checked="true"] { background: var(--coral); }
.switch[aria-checked="true"]::after { transform: translateX(18px); }
.switch:active::after { width: 26px; }

.signout { width: 100%; padding: var(--s4); border-radius: var(--r3); background: var(--surface); border: 1px solid var(--line); color: var(--over); font-weight: 600; font-size: var(--t-body); transition: background 0.16s; }
.signout:hover { background: var(--over-tint); }

/* ═══════════════════════════════════════════════════════════════════════════
   ONBOARDING (first-run overlay)
   ═══════════════════════════════════════════════════════════════════════════ */
.onb {
  position: absolute; inset: 0; z-index: 50; background: var(--bg);
  display: flex; flex-direction: column;
  opacity: 0; visibility: hidden; transition: opacity 0.3s, visibility 0.3s;
}
.onb.is-open { opacity: 1; visibility: visible; }
.onb-top { display: flex; align-items: center; justify-content: space-between; padding: var(--s10) var(--s5) var(--s4); flex-shrink: 0; }
.onb-dots { display: flex; gap: 6px; }
.onb-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--line); transition: width 0.25s var(--ease-out-quint), background 0.25s; }
.onb-dot.active { width: 22px; border-radius: 4px; background: var(--coral); }
.onb-skip { font-size: var(--t-sm); font-weight: 600; color: var(--muted); }
.onb-skip:hover { color: var(--ink); }
.onb-body { flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: none; padding: var(--s4) var(--s6) var(--s6); }
.onb-step { display: none; }
.onb-step.is-active { display: block; animation: view-in 0.34s var(--ease-out-quint); }
.onb-art { width: 96px; height: 96px; border-radius: var(--r5); display: flex; align-items: center; justify-content: center; font-size: 46px; margin: var(--s6) 0 var(--s6); background: var(--coral-tint); }
.onb-h { font-size: var(--t-h1); font-weight: 700; letter-spacing: -0.02em; color: var(--ink); line-height: 1.2; text-wrap: balance; }
.onb-p { font-size: var(--t-body); color: var(--muted); margin-top: var(--s3); max-width: 30ch; }
.onb-opts { display: flex; flex-direction: column; gap: var(--s3); margin-top: var(--s6); }
.onb-opt { display: flex; align-items: center; gap: var(--s3); padding: var(--s4) var(--s5); border-radius: var(--r3); background: var(--surface); border: 1.5px solid var(--line); text-align: left; transition: border-color 0.16s, background 0.16s, transform 0.1s var(--ease-out-quint); }
.onb-opt:active { transform: scale(0.98); }
.onb-opt[aria-pressed="true"] {
  border-color: var(--coral);
  background: var(--coral-tint);
}
.onb-opt .e { font-size: 22px; }
.onb-opt .t { flex: 1; display: flex; flex-direction: column; gap: 1px; }
.onb-opt .ot { font-size: var(--t-title); font-weight: 600; color: var(--ink); }
.onb-opt .os { font-size: var(--t-sm); color: var(--muted); }
.onb-opt .chk { width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--line); flex-shrink: 0; display: flex; align-items: center; justify-content: center; color: #fff; }
.onb-opt[aria-pressed="true"] .chk { background: var(--coral); border-color: var(--coral); }
.onb-result-ring { width: 150px; height: 150px; margin: var(--s6) auto var(--s4); position: relative; }
.onb-ring-chart { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.onb-result-num { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.onb-result-num .n { font-family: var(--font-num); font-weight: 700; font-stretch: 125%; font-size: var(--t-display); color: var(--ink); }
.onb-result-num .u { font-size: var(--t-xs); color: var(--muted); font-weight: 500; }
.onb-foot { flex-shrink: 0; padding: var(--s4) var(--s6) calc(var(--s6) + var(--safe-bottom)); }

/* ── Hardening: disabled state + long-text resilience ───────────────────── */
/* Real disabled styling for the primary button. Scoped with :not(.is-success)
   so the green "Added ✓" success morph still wins when the button is both
   disabled (double-submit guard) and showing success. */
.btn-primary:disabled:not(.is-success) {
  background: var(--surface-2);
  color: var(--muted);
  cursor: not-allowed;
}
.btn-primary:disabled:not(.is-success):hover { background: var(--surface-2); transform: none; }

/* Long food / meal names shouldn't break the layout */
.fd-title { overflow-wrap: break-word; }
.meal-item .mi-name { overflow-wrap: anywhere; }

/* ── Full-bleed on real phones ──────────────────────────────────────────── */
@media (max-width: 430px) {
  body { padding: 0; background: var(--bg); }
  .device-frame { padding: 0; border-radius: 0; box-shadow: none; }
  .device-frame::before, .device-frame::after { display: none; }
  .screen { width: 100vw; height: 100vh; height: 100dvh; border-radius: 0; }
  .status-bar { padding-top: env(safe-area-inset-top, 0px); }
  .lang-switcher { left: auto; right: 14px; top: calc(env(safe-area-inset-top, 0px) + 12px); }
  .lang-dropdown { left: auto; right: 0; }
}
