/* ============================================================
   Nivala — style.css
   Light-only theme per DESIGN.md. Tokens copied verbatim (§2).
   ============================================================ */

:root {
  color-scheme: light;

  /* ---- Surfaces (true hierarchy, not all #fff) ---- */
  --surface-page:   #f3f6f4;  /* app background plane, cool green-gray */
  --surface-card:   #ffffff;  /* cards, sheets, tab bar */
  --surface-inset:  #eef2ef;  /* input fills, skeleton base, wells, offline banner */
  --surface-sunken: #e7ece9;  /* pressed list rows, segmented-control track */
  --surface-scrim:  rgba(22,33,27,0.44);  /* behind bottom sheets */

  /* ---- Leaf-green brand scale ---- */
  --green-50:  #e7f6ee;
  --green-100: #d9efe3;
  --green-200: #b7e4cd;
  --green-300: #86d1ae;
  --green-400: #4cb98a;
  --green-500: #22a06b;
  --green-600: #17895b;
  --green-700: #0f7a4f;
  --green-800: #0c5c3c;
  --green-900: #0a3d28;

  /* ---- Metric colors (DATA ONLY) ---- */
  --metric-cal:     #0f7a4f;
  --metric-protein: #2a78d6;
  --metric-carbs:   #c98500;
  --metric-fat:     #db5c87;
  --track-cal:      #d9efe3;
  --track-protein:  #d5e6f9;
  --track-carbs:    #f4e3bf;
  --track-fat:      #f9dde8;

  /* ---- Ink (text) ---- */
  --ink-900: #16211b;
  --ink-600: #4d5a53;
  --ink-500: #647167;
  --ink-icon:#6d7a72;
  --ink-300: #8a948d;
  --ink-inverse: #ffffff;

  /* ---- Semantic ---- */
  --over-amber:      #b45309;
  --over-amber-deep: #92400e;
  --amber-50:        #fdf3e3;
  --error:           #b3261e;
  --error-deep:      #8c1d18;
  --error-50:        #fdecea;
  --water:           #2a78d6;
  --water-fill:      #cde2fb;

  /* ---- Lines & grid ---- */
  --border:    #e4e9e6;
  --divider:   #dbe3de;
  --grid:      #e4e9e6;

  /* ---- Elevation ---- */
  --shadow-1: 0 1px 2px rgba(22,33,27,.06), 0 2px 8px rgba(22,33,27,.05);
  --shadow-2: 0 4px 16px rgba(22,33,27,.14);

  /* ---- Radii ---- */
  --r-s: 8px;
  --r-m: 12px;
  --r-l: 16px;
  --r-xl: 24px;
  --r-full: 999px;

  /* ---- Spacing (4/8 scale) ---- */
  --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px; --s-5: 20px;
  --s-6: 24px; --s-8: 32px; --s-10: 40px; --s-12: 48px; --s-16: 64px;

  /* ---- Motion ---- */
  --ease-out: cubic-bezier(0.33, 1, 0.68, 1);
  --ease-std: cubic-bezier(0.4, 0, 0.2, 1);
  --t-fast: 150ms;
  --t-med:  250ms;
  --t-ring: 600ms;

  /* ---- Layout ---- */
  --page-pad: 16px;
  --content-max: 480px;
  --tabbar-h: 60px;
  --touch-min: 44px;
}

/* ============ Reset & base ============ */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--surface-page);
  color: var(--ink-900);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 22px;
  min-height: 100dvh;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
a { color: var(--green-700); text-decoration: none; }
ul, ol { list-style: none; }
img, svg, canvas { display: block; }
[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--green-700); outline-offset: 2px; }
:focus:not(:focus-visible) { outline: none; }

.icon { flex: 0 0 auto; }
/* directional glyphs mirror in RTL (ar) */
[dir="rtl"] .icon.chev { transform: scaleX(-1); }
/* The ar/hi files are stubs: untranslated strings fall back to English. In
   RTL each text run takes its direction from its own first letter, so an
   English fallback reads "300 of 2,556", not "of 2,556 300". */
[dir="rtl"] :is(.title, .title-xl, .body, .label, .caption, p, .appbar-sub) { unicode-bidi: plaintext; }
/* Same rule for the review sheet's Latin phrases: "1 katori ≈ 150 g" must not
   render as "katori ≈ 150 g 1", and "Wrong dish?" must keep its question mark
   at the end, in an RTL sheet. */
[dir="rtl"] :is(.unit-stepper-label, .fix-btn, .stepper .unit) { unicode-bidi: plaintext; }
/* metric dot (DESIGN 6.4): one definition everywhere it is used */
.mdot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; flex: 0 0 auto; }

/* ============ Type scale ============ */
.num-hero { font-size: 48px; line-height: 52px; font-weight: 800; letter-spacing: -0.02em; }
.num-l    { font-size: 28px; line-height: 32px; font-weight: 700; letter-spacing: -0.01em; }
.num-m    { font-size: 17px; line-height: 24px; font-weight: 700; }
.title-xl { font-size: 24px; line-height: 30px; font-weight: 700; }
.title    { font-size: 17px; line-height: 24px; font-weight: 600; }
.body     { font-size: 15px; line-height: 22px; font-weight: 400; }
.label    { font-size: 13px; line-height: 18px; font-weight: 500; }
.caption  { font-size: 11px; line-height: 14px; font-weight: 500; }
.num-live { font-variant-numeric: tabular-nums; }
.tnum     { font-variant-numeric: tabular-nums; }
.w600 { font-weight: 600; }
.ink-900 { color: var(--ink-900); }
.ink-600 { color: var(--ink-600); }
.ink-500 { color: var(--ink-500); }
.ink-300 { color: var(--ink-300); }
.amber   { color: var(--over-amber); }
.green   { color: var(--green-700); }

/* ============ App shell ============ */
#app {
  max-width: var(--content-max);
  margin-inline: auto;
  padding-inline: var(--page-pad);
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 24px);
  min-height: 100dvh;
}
.appbar {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-2);
  min-height: 56px;
  padding-block: var(--s-3);
  position: sticky; top: 0; z-index: 10;
  background: var(--surface-page);
}
.appbar.scrolled { background: var(--surface-card); box-shadow: inset 0 -1px 0 var(--border); }
.appbar .appbar-title { color: var(--ink-900); font-size: 24px; line-height: 30px; font-weight: 700; }
.appbar-left { display: flex; align-items: center; gap: var(--s-1); min-width: 0; }
.appbar-titles { min-width: 0; }
.appbar .appbar-sub { color: var(--ink-500); margin-top: 2px; }
.appbar-action {
  width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center;
  color: var(--ink-icon); border-radius: var(--r-m);
}
.appbar-back {
  width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center;
  color: var(--ink-600); margin-inline-start: -12px; border-radius: var(--r-m);
}
.screen > * + * { margin-top: var(--s-6); }
.screen { padding-top: var(--s-1); }

/* ============ Splash ============ */
#splash {
  position: fixed; inset: 0; z-index: 100;
  background: var(--surface-page);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--s-4);
  transition: opacity var(--t-med) var(--ease-std);
}
#splash.fade { opacity: 0; pointer-events: none; }
#splash .wordmark { font-size: 24px; line-height: 30px; font-weight: 700; letter-spacing: -0.01em; color: var(--ink-900); }
#splash .leaf { color: var(--green-500); }

/* ============ Offline banner ============ */
#offline-banner {
  overflow: hidden;
  max-height: 0;
  transition: max-height 200ms var(--ease-std);
  background: var(--surface-inset);
  position: sticky; top: 0; z-index: 20;
}
#offline-banner.show { max-height: 36px; }
#offline-banner .inner {
  height: 36px; display: flex; align-items: center; justify-content: center; gap: var(--s-2);
  color: var(--ink-600);
  max-width: var(--content-max); margin-inline: auto; padding-inline: var(--page-pad);
}

/* ============ Operator announcement (from /api/me) ============ */
.announcement { position: relative; background: var(--green-50); color: var(--ink-900); border-bottom: 1px solid var(--green-200); }
.announcement.is-warning { background: var(--amber-50); border-bottom-color: #f1d7a8; }
.announcement.is-critical { background: var(--error-50); border-bottom-color: var(--error); }
.announcement .inner {
  display: flex; align-items: flex-start; gap: var(--s-2);
  max-width: var(--content-max); margin-inline: auto; padding: var(--s-2) var(--page-pad);
}
.announcement-text { flex: 1; min-width: 0; font-size: 14px; line-height: 20px; overflow-wrap: anywhere; }
.announcement-title { display: block; font-weight: 600; }
.announcement-body { display: block; color: var(--ink-600); white-space: pre-line; }
.announcement-close {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; margin: -6px -10px -6px 0; border: 0; border-radius: var(--r-m);
  background: none; color: var(--ink-600); cursor: pointer;
}
.announcement-close:active { background: var(--surface-sunken); }

/* ============ Tab bar & FAB ============ */
#tabbar {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 30;
  background: var(--surface-card);
  box-shadow: inset 0 1px 0 var(--border);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
}
#tabbar .tabs {
  max-width: var(--content-max); margin-inline: auto; height: var(--tabbar-h);
  display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; align-items: stretch;
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--ink-icon); min-height: var(--touch-min); position: relative;
}
.tab .caption { color: var(--ink-500); }
.tab.active { color: var(--green-700); }
.tab.active .caption { color: var(--green-700); font-weight: 600; }
.tab.active::after {
  content: ""; width: 4px; height: 4px; border-radius: var(--r-full);
  background: var(--green-500); position: absolute; bottom: 5px;
}
.tab-fab-slot { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; padding-bottom: 5px; position: relative; }
.fab {
  width: 56px; height: 56px; border-radius: var(--r-full);
  background: var(--green-500); color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-2);
  position: absolute; top: -28px;
  transition: transform var(--t-fast) var(--ease-std), background var(--t-fast) linear;
}
.fab:active { background: var(--green-600); transform: scale(0.96); }
.fab[aria-disabled="true"] { background: var(--surface-sunken); color: var(--ink-300); box-shadow: none; }
.tab-fab-slot .caption { color: var(--ink-500); }

/* ============ Buttons ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  border-radius: var(--r-m); min-height: 48px; padding-inline: var(--s-5);
  font-size: 17px; line-height: 24px; font-weight: 600;
  transition: background var(--t-fast) linear, transform var(--t-fast) var(--ease-std);
  user-select: none;
}
.btn-primary { background: var(--green-700); color: #fff; width: 100%; }
.btn-primary:active { background: var(--green-800); }
.btn-primary:disabled, .btn[aria-busy="true"] { pointer-events: none; }
.btn-primary:disabled { background: var(--surface-sunken); color: var(--ink-300); }
.btn-secondary { background: var(--surface-card); border: 1px solid var(--green-700); color: var(--green-700); }
.btn-secondary:active { background: var(--green-50); }
.btn-ghost { background: none; color: var(--green-700); min-height: 44px; }
.btn-ghost:active { background: var(--green-50); }
.btn-destructive { background: none; color: var(--error); min-height: 44px; }
.btn-destructive:active { background: var(--error-50); }
.btn.is-loading { color: transparent; position: relative; }
.btn.is-loading::after {
  content: ""; position: absolute; width: 20px; height: 20px;
  border: 2.5px solid rgba(255,255,255,.35); border-top-color: #fff;
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
.btn-ghost.is-loading::after, .btn-secondary.is-loading::after { border-color: var(--green-100); border-top-color: var(--green-700); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ Inputs ============ */
.field { display: flex; flex-direction: column; gap: var(--s-2); }
.field > label { font-size: 13px; line-height: 18px; font-weight: 500; color: var(--ink-600); }
.input-wrap { position: relative; display: flex; align-items: center; }
.input {
  width: 100%; min-height: 48px;
  background: var(--surface-inset); border: 2px solid transparent; border-radius: var(--r-m);
  padding-inline: var(--s-4);
  color: var(--ink-900);
}
.input::placeholder { color: var(--ink-300); }
.input:focus { outline: none; border-color: var(--green-700); background: var(--surface-card); }
.input.error { border-color: var(--error); }
.input-wrap .input { padding-inline-end: 52px; }
/* no browser spinners: they collided with the unit suffix, and the steppers
   / keyboard are the input method */
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.input-suffix {
  position: absolute; inset-inline-end: var(--s-4);
  font-size: 13px; line-height: 18px; font-weight: 500; color: var(--ink-500); pointer-events: none;
}
.field-error {
  display: flex; align-items: center; gap: var(--s-1);
  font-size: 11px; line-height: 14px; font-weight: 500; color: var(--error-deep);
}
/* room for the chevron: a long option ("Open (acknowledged + in progress)",
   a long country name) never runs under it */
select.input { appearance: none; -webkit-appearance: none; padding-inline-end: 40px;
  text-overflow: ellipsis; }
.select-wrap { position: relative; }
.select-wrap::after {
  content: ""; position: absolute; inset-inline-end: 14px; top: 50%;
  width: 8px; height: 8px; border-inline-end: 1.5px solid var(--ink-500); border-bottom: 1.5px solid var(--ink-500);
  transform: translateY(-70%) rotate(45deg); pointer-events: none;
}

/* Segmented control */
.segmented {
  display: flex; background: var(--surface-sunken); border-radius: var(--r-m); padding: 3px; min-height: 44px;
}
.segmented .seg {
  flex: 1; border-radius: 9px; min-height: 38px;
  color: var(--ink-500); font-size: 13px; font-weight: 500;
  display: flex; align-items: center; justify-content: center;
}
.segmented .seg[aria-checked="true"] {
  background: var(--surface-card); box-shadow: var(--shadow-1);
  color: var(--ink-900); font-weight: 600;
}

/* Stepper */
.stepper { display: inline-flex; align-items: center; background: var(--surface-inset); border-radius: var(--r-full); height: 32px; }
.stepper button {
  width: 44px; height: 44px; margin-block: -6px;
  display: inline-flex; align-items: center; justify-content: center; color: var(--green-700);
}
.stepper input {
  width: 58px; text-align: center; background: none; border: 0;
  font-size: 15px; font-weight: 700; color: var(--ink-900);
  font-variant-numeric: tabular-nums;
}
.stepper input:focus { outline: none; }
.stepper .unit { font-size: 11px; color: var(--ink-500); margin-inline-end: 2px; }
.stepper button:disabled { color: var(--ink-300); cursor: default; }
.field > .stepper { align-self: flex-start; }

/* ============ Cards & rows ============ */
.card {
  background: var(--surface-card); border: 1px solid var(--border);
  border-radius: var(--r-l); box-shadow: var(--shadow-1);
  padding: var(--s-4);
}
.card.pressable:active { background: var(--surface-sunken); transform: scale(0.99); }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--s-3); }
.row-list > * + * { border-top: 1px solid var(--border); }
.list-row {
  min-height: 56px; display: flex; align-items: center; gap: var(--s-3);
  padding-block: var(--s-2); width: 100%; text-align: start;
}
.list-row .row-value { margin-inline-start: auto; color: var(--ink-500); display: inline-flex; align-items: center; gap: var(--s-2); }
.list-row .row-value.baseline { align-items: baseline; gap: var(--s-1); }
.list-row .row-value .num-m { color: var(--ink-900); }
.list-row:active { background: var(--surface-sunken); }
.icon-tile {
  width: 40px; height: 40px; border-radius: var(--r-m);
  background: var(--green-50); color: var(--green-700);
  display: flex; align-items: center; justify-content: center; flex: 0 0 auto;
}
.icon-tile.sm { width: 32px; height: 32px; }
.icon-tile.warn { background: var(--amber-50); color: var(--over-amber); }
.icon-tile.err { background: var(--error-50); color: var(--error); }

/* Chips & badges */
.chip {
  display: inline-flex; align-items: center; gap: var(--s-1);
  border-radius: var(--r-full); padding: 3px 10px; min-height: 24px;
  background: var(--green-50); color: var(--green-800);
  font-size: 11px; line-height: 14px; font-weight: 600;
}
.chip .icon { color: #b45309; }
.chip-neutral { background: var(--surface-inset); color: var(--ink-600); }
.badge {
  display: inline-flex; align-items: center; border-radius: var(--r-s);
  height: 20px; padding-inline: 6px;
  font-size: 11px; line-height: 14px; font-weight: 600;
}
.badge-high { background: var(--green-50); color: var(--green-800); }
.badge-med  { background: var(--amber-50); color: var(--over-amber-deep); }
.badge-low  { background: var(--surface-inset); color: var(--ink-600); }

/* Banners */
.banner { display: flex; gap: var(--s-3); padding: var(--s-3); align-items: flex-start; text-align: start; }
/* never nest cards (DESIGN 6.3): a banner inside a card becomes an inset well */
.card .card.banner { box-shadow: none; border: 0; background: var(--surface-inset); }
/* quiet AI-estimates caption: glyph inline with the text */
.disclaimer { display: flex; align-items: flex-start; justify-content: center; gap: var(--s-1); text-align: start; }
.banner .banner-body { color: var(--ink-600); margin-top: 2px; }

/* ============ Toast ============ */
#toast-root {
  position: fixed; inset-inline: 0;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 12px);
  display: flex; justify-content: center; z-index: 60; pointer-events: none;
  padding-inline: var(--page-pad);
}
.toast {
  background: var(--ink-900); color: #fff;
  font-size: 13px; line-height: 18px; font-weight: 500;
  border-radius: var(--r-m); padding: 10px 16px; max-width: 358px;
  display: flex; align-items: center; gap: var(--s-2);
  animation: toast-in var(--t-med) var(--ease-out);
  pointer-events: auto;
}
.toast .icon { color: var(--green-300); }
.toast.out { opacity: 0; transition: opacity 200ms linear; }
@keyframes toast-in { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ============ Skeletons ============ */
.skel {
  background: var(--surface-inset); border-radius: var(--r-s);
  position: relative; overflow: hidden;
}
.skel::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, var(--surface-sunken), transparent);
  animation: shimmer 1.2s linear infinite;
}
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
.skel-line { height: 12px; }
.skel-ring { border-radius: 50%; }

/* ============ Empty state ============ */
.empty {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  gap: var(--s-3); padding: var(--s-8) var(--s-4);
}
.empty-icon {
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--green-50); color: var(--green-700);
  display: flex; align-items: center; justify-content: center; flex: 0 0 auto;
}
.empty-icon.sm { width: 40px; height: 40px; }
/* a scan that could not be read is a heads-up: amber, never red or green */
.empty-icon.warn { background: var(--amber-50); color: var(--over-amber); }
.empty .body { color: var(--ink-600); max-width: 280px; }

/* ============ Rings ============ */
.hero-card { padding: var(--s-6); }
.ring-wrap { position: relative; width: 216px; margin-inline: auto; }
.ring-center {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px; text-align: center;
}
.ring-progress { transition: stroke-dashoffset var(--t-ring) var(--ease-out), stroke 200ms linear; }
.macro-row { display: flex; justify-content: space-between; margin-top: var(--s-5); gap: var(--s-2); }
.macro-ring { display: flex; flex-direction: column; align-items: center; gap: var(--s-1); flex: 1; text-align: center; }
.macro-ring .ring-wrap { width: 88px; }
.macro-ring .macro-name { color: var(--ink-600); }
.macro-ring .macro-of { color: var(--ink-500); }
.macro-ring .macro-over { color: var(--over-amber); font-weight: 600; }

/* ============ Chart ============ */
.chart-card .readout { margin-top: var(--s-2); color: var(--ink-600); min-height: 18px; }
.chart-holder { position: relative; margin-top: var(--s-3); }
.chart-holder canvas { width: 100%; height: 168px; touch-action: manipulation; }
.chart-empty {
  position: absolute; inset: 0 0 36px 0; display: flex;
  align-items: center; justify-content: center; text-align: center; pointer-events: none;
}
/* the empty-week message sits on a card-colored plate so the grid and goal
   line behind it stay visible without striking through the text */
.chart-empty-inner {
  display: flex; flex-direction: column; align-items: center; gap: var(--s-1);
  background: var(--surface-card); border-radius: var(--r-m); padding: var(--s-2) var(--s-4);
  pointer-events: auto;
}
.chart-table { width: 100%; border-collapse: collapse; margin-top: var(--s-3); }
.chart-table th {
  text-align: start; font-size: 11px; line-height: 14px; font-weight: 500; color: var(--ink-500);
  padding-block: var(--s-2); border-bottom: 1px solid var(--divider);
}
.chart-table td {
  font-size: 13px; line-height: 18px; font-weight: 500; color: var(--ink-600);
  font-variant-numeric: tabular-nums;
  padding-block: var(--s-2); border-bottom: 1px solid var(--border);
}
.chart-table td:not(:first-child), .chart-table th:not(:first-child) { text-align: end; }

/* ============ Stat tiles ============ */
.tiles { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--s-2); }
.tile {
  background: var(--surface-card); border: 1px solid var(--border); border-radius: var(--r-m);
  box-shadow: var(--shadow-1); padding: var(--s-3);
  display: flex; flex-direction: column; gap: 2px;
}
.tile .tile-label { color: var(--ink-500); }
.tile .tile-unit { color: var(--ink-500); font-weight: 500; font-size: 11px; }

/* ============ Meal card ============ */
.meal-card { display: flex; flex-direction: column; gap: var(--s-2); min-height: 88px; width: 100%; text-align: start; transition: background var(--t-fast) linear, transform var(--t-fast) var(--ease-std); }
.meal-top { display: flex; align-items: center; gap: var(--s-3); }
.meal-title-wrap { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; }
.meal-time { color: var(--ink-500); display: inline-flex; align-items: center; gap: var(--s-1); }
.meal-kcal { margin-inline-start: auto; text-align: end; display: flex; align-items: baseline; gap: 3px; flex: 0 0 auto; }
.meal-kcal .caption { color: var(--ink-500); }
.meal-summary {
  /* two lines before the ellipsis: one line hid every item after the first
     long name ("Masala oats with peanuts and veg...") on a 360 px phone */
  color: var(--ink-600); overflow: hidden; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2;
  padding-inline-start: 52px;
}
.meal-macros { display: flex; gap: var(--s-3); padding-inline-start: 52px; align-items: center; }
.meal-macros span.caption { color: var(--ink-600); font-variant-numeric: tabular-nums; display: inline-flex; align-items: center; gap: 4px; }
.meal-chevron { color: var(--ink-300); display: inline-flex; margin-inline-start: -4px; margin-inline-end: -6px; }
.meal-pending { color: var(--ink-500); }

/* ============ Water ============ */
.water-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); }
.water-head .label { display: block; margin-top: 2px; }
.water-steppers { display: flex; gap: var(--s-1); margin-inline-end: -10px; }
/* DESIGN 6.7: eight contiguous 44x44 targets = 352 px, so the row bleeds
   into the card padding (324 px content + 2 x 14 px) */
.water-glasses { display: grid; grid-template-columns: repeat(var(--water-cols, 8), 44px); justify-content: center; margin: var(--s-2) -14px 0; border-radius: var(--r-m); }
/* under 390 px eight 44 px drops no longer fit: balanced rows of <= 6
   (2 x 4 for the default goal) instead of 7 + a lone drop */
@media (max-width: 389px) { .water-glasses { grid-template-columns: repeat(var(--water-cols-narrow, 4), 44px); } }
.water-glass { width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; color: var(--ink-300); }
.water-glass.filled { color: var(--water); }
.water-glass.filled .icon { animation: pop var(--t-fast) var(--ease-out); }
.water-glass.filled svg { fill: var(--water-fill); }
@keyframes pop { from { transform: scale(0.8); } to { transform: scale(1); } }
.water-btn { width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; color: var(--green-700); border-radius: var(--r-full); }
.water-btn:disabled { color: var(--ink-300); }

/* ============ Bottom sheets ============ */
#sheet-root .scrim {
  position: fixed; inset: 0; background: var(--surface-scrim); z-index: 40;
  opacity: 0; transition: opacity 200ms linear;
}
#sheet-root .scrim.show { opacity: 1; }
.sheet {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 50;
  background: var(--surface-card);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  box-shadow: var(--shadow-2);
  max-height: 92dvh; display: flex; flex-direction: column;
  max-width: var(--content-max); margin-inline: auto;
  transform: translateY(100%);
  transition: transform var(--t-med) var(--ease-std);
}
.sheet.show { transform: none; }
.sheet:focus { outline: none; }
.sheet-handle { width: 36px; height: 4px; border-radius: var(--r-full); background: var(--divider); margin: 8px auto 0; flex: 0 0 auto; }
.sheet-body { overflow-y: auto; padding: var(--s-4); padding-bottom: var(--s-2); }
.sheet-cta {
  padding: var(--s-3) var(--s-4) calc(16px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border); background: var(--surface-card); flex: 0 0 auto;
}
.sheet-title-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--s-3); }

/* ============ Scan ============ */
.scan-option { display: flex; align-items: center; gap: var(--s-3); min-height: 56px; width: 100%; text-align: start; padding-block: var(--s-2); }
.scan-option:active { background: var(--surface-sunken); }
.scan-option-chev { margin-inline-start: auto; color: var(--ink-300); display: inline-flex; }
.scan-thumb {
  width: 100%; max-height: 45dvh; object-fit: contain;
  background: var(--surface-inset); border-radius: var(--r-l);
}
.scan-stages { display: flex; flex-direction: column; gap: var(--s-3); margin-top: var(--s-5); }
.scan-stage { display: flex; align-items: center; gap: var(--s-3); color: var(--ink-500); }
.scan-stage.active { color: var(--ink-900); }
.scan-stage.done { color: var(--ink-600); }
.scan-stage .stage-dot { width: 16px; height: 16px; display: inline-flex; align-items: center; justify-content: center; }
.scan-stage.active .stage-dot::after {
  content: ""; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--green-100); border-top-color: var(--green-700);
  animation: spin 0.8s linear infinite;
}
.scan-stage.done .stage-dot { color: var(--green-700); }
.scan-leaf { color: var(--green-500); margin-inline: auto; animation: leafpulse 1.6s var(--ease-std) infinite; }
@keyframes leafpulse { 0%,100% { opacity: 1; } 50% { opacity: 0.45; } }

/* Review items */
.review-item { display: flex; flex-direction: column; gap: var(--s-2); padding-block: var(--s-3); }
.review-item + .review-item { border-top: 1px solid var(--border); }
.review-head { display: flex; align-items: flex-start; gap: var(--s-3); }
.review-name { min-width: 0; flex: 1; }
.review-name .caption { color: var(--ink-500); }
.review-meta { display: flex; align-items: center; flex-wrap: wrap; gap: var(--s-2); }
/* DESIGN 8.2: right column = kcal (num-m) with the macro mini-row under it */
.review-kcal { text-align: end; flex: 0 0 auto; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; padding-top: 10px; }
.review-kcal-num { white-space: nowrap; }
.review-macros { gap: var(--s-2); }
/* The unit stepper ("1 katori ≈ 150 g") plus "Wrong dish?" plus the delete
   button do not fit in one 328 px line on a 360 px phone: the actions wrap
   under the stepper, kept at the end of their line, instead of the delete
   button being clipped by the sheet edge. */
.review-controls { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); row-gap: 4px; }
.review-spacer { flex: 1 1 auto; }
.review-actions { display: inline-flex; align-items: center; gap: var(--s-2); flex: 0 0 auto; margin-inline-start: auto; }
.review-totals { border: 0; margin: 0 0 var(--s-2); padding: 0; }
.review-totals-right { display: flex; align-items: baseline; gap: var(--s-3); }
.review-remove { width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; color: var(--ink-icon); border-radius: var(--r-m); flex: 0 0 auto; margin-inline-end: -10px; }
.totals-bar { display: flex; align-items: baseline; justify-content: space-between; border-top: 1px solid var(--divider); padding-top: var(--s-3); margin-top: var(--s-2); }
.mini-macros { display: flex; gap: var(--s-3); }
.mini-macros span { display: inline-flex; align-items: center; gap: 4px; color: var(--ink-600); font-variant-numeric: tabular-nums; }
.day-macros { margin-top: -4px; }

/* Paywall */
.paywall { text-align: center; position: relative; }
.paywall-close { position: absolute; inset-inline-end: -10px; top: -8px; }
.paywall .leaf { color: var(--green-500); margin-inline: auto; }
.paywall-meter { display: flex; justify-content: center; gap: var(--s-2); margin-block: var(--s-3); align-items: center; }
.paywall-meter .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--green-100); }
.paywall-meter .dot.used { background: var(--green-500); }
.paywall-promo { margin-top: var(--s-2); }
.promo-row { display: flex; gap: var(--s-2); }
.promo-row .input { flex: 1; min-width: 0; }
.paywall-benefits { text-align: start; display: flex; flex-direction: column; gap: var(--s-3); margin-block: var(--s-4); }
.paywall-benefits li { display: flex; align-items: center; gap: var(--s-3); }
.paywall-benefits .icon { color: var(--green-700); }
.paywall-price { display: flex; align-items: baseline; justify-content: center; gap: var(--s-1); }

/* ============ Auth / profile ============ */
.auth-screen { display: flex; flex-direction: column; justify-content: center; min-height: calc(100dvh - 140px); gap: var(--s-4); }
.auth-logo { display: flex; flex-direction: column; align-items: center; gap: var(--s-2); margin-bottom: var(--s-4); }
.auth-logo .leaf { color: var(--green-500); }
.form { display: flex; flex-direction: column; gap: var(--s-4); }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3); }
.target-preview { text-align: center; padding: var(--s-4); }
.target-preview .banner { text-align: start; }
.target-preview .num-l { color: var(--ink-900); }
.macro-pills { display: flex; justify-content: center; gap: var(--s-4); margin-top: var(--s-2); }
.macro-pills span { display: inline-flex; align-items: center; gap: 5px; color: var(--ink-600); font-size: 13px; font-weight: 500; }

/* Settings */
.screen > .settings-group-title { color: var(--ink-500); margin-top: var(--s-8); }
.screen > .settings-group-title:first-child { margin-top: 0; }
.screen > .settings-group-title + .card { margin-top: var(--s-2); }
.masked-key { color: var(--ink-500); font-variant-numeric: tabular-nums; }

/* Search & Add */
.search-wrap { position: sticky; top: 56px; z-index: 5; background: var(--surface-page); padding-block: var(--s-2); }
.search-row { position: relative; display: flex; align-items: center; }
.search-row .icon { position: absolute; inset-inline-start: 14px; color: var(--ink-icon); pointer-events: none; }
.search-row .input { padding-inline-start: 46px; }
.search-clear { position: absolute; inset-inline-end: 2px; width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; color: var(--ink-icon); }
.staple-chips { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.staple-chips button {
  background: var(--green-50); color: var(--green-800); border-radius: var(--r-full);
  padding: 8px 14px; font-size: 13px; font-weight: 500; min-height: 44px;
}
.food-row { display: flex; align-items: center; gap: var(--s-3); min-height: 56px; width: 100%; }
.food-main { min-width: 0; flex: 1; text-align: start; display: flex; flex-direction: column; padding-block: var(--s-2); }
.food-main .caption { color: var(--ink-500); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.food-add-btn {
  width: 44px; height: 44px; border-radius: var(--r-full);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--green-700); background: var(--green-50);
}
.portion-chips { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.portion-chips button {
  background: var(--surface-inset); color: var(--ink-600); border-radius: var(--r-full);
  padding: 8px 14px; font-size: 13px; font-weight: 500; min-height: 44px;
}
.portion-chips button[aria-pressed="true"] { background: var(--green-50); color: var(--green-800); font-weight: 600; }
.portion-chips button:disabled { color: var(--ink-300); cursor: default; }
.portion-preview { margin-top: var(--s-3); }

/* Install card */
.install-card { display: flex; align-items: center; gap: var(--s-3); }
.install-actions { margin-inline-start: auto; display: flex; gap: var(--s-2); align-items: center; }

/* Utility */
.spread { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); }
.stack-2 > * + * { margin-top: var(--s-2); }
.stack-3 > * + * { margin-top: var(--s-3); }
.stack-4 > * + * { margin-top: var(--s-4); }
.center { text-align: center; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px;
  clip: rect(0 0 0 0); overflow: hidden; white-space: nowrap;
}

/* ============ Reduced motion ============ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---- WEDGE additions: contract card, recal card, unit stepper, fix flow ---- */
.contract-dots { display: flex; gap: var(--s-2); align-items: center; margin-block: var(--s-1); }
.contract-dots .cdot {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--green-100); border: 1px solid var(--green-200);
}
.contract-dots .cdot.filled { background: var(--green-500); border-color: var(--green-500); }
.contract-dots .cdot.today { box-shadow: 0 0 0 2px var(--surface-card), 0 0 0 3.5px var(--green-700); }

.recal-locked { min-height: 44px; padding-inline: 0; justify-content: space-between; width: 100%; }

.unit-stepper { display: inline-flex; align-items: center; gap: var(--s-1); }
.unit-stepper button {
  width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center;
  color: var(--ink-600); border-radius: var(--r-m);
}
.unit-stepper button:active { background: var(--surface-sunken); }
.unit-stepper button:disabled { color: var(--ink-300); cursor: default; }
.unit-stepper-label { font-size: 15px; line-height: 22px; font-weight: 700; color: var(--ink-900); min-width: 104px; text-align: center; white-space: nowrap; }

.fix-wrap { display: flex; flex-direction: column; gap: var(--s-2); }
.fix-btn { min-height: 44px; padding-inline: var(--s-2); font-size: 13px; line-height: 18px; flex: 0 0 auto; }
.fix-row { display: flex; gap: var(--s-2); align-items: center; }
.fix-row .input { flex: 1; }
.fix-corrected { color: var(--green-700); font-weight: 600; }

.reveal-screen { display: flex; flex-direction: column; gap: var(--s-4); justify-content: center; min-height: calc(100dvh - 200px); }
.reveal-screen .leaf { color: var(--green-500); margin-inline: auto; }

.review-name-btn { min-height: 44px; display: flex; align-items: center; text-align: start; padding: 0; }
/* a ghost action that starts a card's text column lines up with that text */
.btn-ghost.btn-inline { padding-inline: 0; margin-top: var(--s-1); }

/* ---- Security & privacy round: consent, recovery code, Privacy & security ---- */
/* the index.html icon sprite: hidden by class (CSP style-src 'self', no inline styles) */
.svg-sprite { display: none; }

.link { color: var(--green-700); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.link:active { color: var(--green-800); }

/* checkbox + label (signup consent, "I've saved my recovery code") */
.check-row { display: flex; align-items: flex-start; gap: var(--s-3); min-height: 44px; }
.check-row input[type="checkbox"] {
  width: 22px; height: 22px; margin-top: 1px; flex: 0 0 auto;
  accent-color: var(--green-700); cursor: pointer;
}
.check-row label { font-size: 13px; line-height: 20px; font-weight: 500; color: var(--ink-600); cursor: pointer; padding-block: 1px; }

.auth-forgot { align-self: center; display: inline-flex; align-items: center; min-height: 44px; padding-inline: var(--s-2); font-size: 15px; text-decoration: none; }

.mono, .recovery-code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; }
.recovery-code {
  background: var(--surface-inset); border: 1px dashed var(--green-300); border-radius: var(--r-m);
  padding: var(--s-4); text-align: center;
  font-size: 19px; line-height: 28px; font-weight: 700; letter-spacing: 0.04em; color: var(--ink-900);
  user-select: all; -webkit-user-select: all; overflow-wrap: anywhere;
}
.btn-row { display: flex; gap: var(--s-2); }
.btn-row .btn { flex: 1 1 0; min-width: 0; padding-inline: var(--s-3); font-size: 15px; }

.btn-block { width: 100%; }
.cta-gap { margin-top: var(--s-2); }
.btn-danger { background: var(--error); color: #fff; width: 100%; }
.btn-danger:active { background: var(--error-deep); }
.btn-danger:disabled { background: var(--surface-sunken); color: var(--ink-300); pointer-events: none; }
.btn-danger.is-loading::after { border-color: rgba(255,255,255,.35); border-top-color: #fff; }
.danger-text { color: var(--error); }

.sheet-para { margin-top: var(--s-3); }
.sheet-body > .icon-tile { margin-bottom: var(--s-1); }

/* a settings row with a caption under its title */
.row-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.row-text .caption { color: var(--ink-500); }
a.list-row { color: inherit; }

.banner-warn { background: var(--amber-50); border-color: #f1d7a8; box-shadow: none; }
.banner-warn .btn-inline { margin-top: var(--s-1); }

.key-status { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); padding: var(--s-2) var(--s-3); border-radius: var(--r-m); background: var(--surface-inset); }
.key-warn { color: var(--over-amber-deep); }
.screen > .banner-warn + .card { margin-top: var(--s-2); }

/* ---- Legal-compliance round: signup facts, health-data consent, wellness,
   support card, AI labels, reports, complaints, paywall terms ---- */

/* "AI estimate" / "AI-generated" (C9): small, quiet, never alarming */
.ai-label {
  display: inline-flex; align-items: center; gap: 3px; vertical-align: middle;
  border-radius: var(--r-s); padding: 1px 6px; min-height: 18px;
  background: var(--surface-inset); color: var(--ink-600);
  font-size: 11px; line-height: 14px; font-weight: 600; white-space: nowrap;
}
.ai-label .icon { color: var(--green-700); }
.review-title-row { display: flex; align-items: center; flex-wrap: wrap; gap: var(--s-2); }
.fix-corrected .ai-label { margin-top: 2px; }

/* not-a-medical-device + when to ask a doctor (profile, About) */
.wellness-note {
  display: flex; align-items: flex-start; gap: var(--s-2);
  padding: var(--s-3); border-radius: var(--r-m); background: var(--surface-inset);
}
.wellness-note > .icon { color: var(--ink-icon); margin-top: 1px; }
.wellness-note.stack-2 { display: block; }
.profile-underweight-note { color: var(--ink-600); }

/* signup: the short-notice link and the notice table */
.auth-notice-link { align-self: flex-start; min-height: 44px; display: inline-flex; align-items: center; font-size: 13px; }
.notice-table-wrap { overflow-x: auto; }
.notice-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.notice-table th, .notice-table td {
  text-align: start; vertical-align: top; padding: var(--s-2) var(--s-2) var(--s-2) 0;
  border-bottom: 1px solid var(--border); font-size: 12px; line-height: 17px; overflow-wrap: anywhere;
}
.notice-table th { color: var(--ink-500); font-weight: 600; border-bottom-color: var(--divider); }
.notice-table td { color: var(--ink-600); }
.notice-table td:first-child { color: var(--ink-900); font-weight: 500; width: 40%; }
.notice-table th:first-child { width: 40%; }
.notice-links { font-size: 13px; }

/* #/health-consent */
.hc-screen { justify-content: flex-start; padding-block: var(--s-4); }
.hc-head { display: flex; align-items: center; justify-content: space-between; }
.hc-lang { min-height: 44px; padding-inline: var(--s-3); font-weight: 600; }
.hc-notice-link { align-self: flex-start; min-height: 44px; display: inline-flex; align-items: center; font-size: 13px; text-align: start; }
.hc-later { margin-top: var(--s-2); box-shadow: none; }
.hc-later-links .link, .hc-links .link { font-size: 13px; }
.hc-later-links button.link { min-height: 32px; }

/* support card (N-19): warm, calm; two call buttons, a quiet "Not now" */
.support-card { border-color: var(--green-200); background: var(--green-50); }
.support-head { display: flex; align-items: center; gap: var(--s-3); }
.support-head .icon-tile { background: var(--surface-card); }
.support-actions { display: flex; flex-wrap: wrap; gap: var(--s-2); }
/* each number stays on one line; on a narrow phone the second call button
   takes its own full-width row instead of wrapping "1-800-891-4416" */
.support-actions .btn { flex: 1 1 auto; width: auto; white-space: nowrap; text-decoration: none; }
@media (max-width: 319px) { .support-actions .btn { white-space: normal; } }

/* "Report this estimate" */
.report-wrap { margin-top: var(--s-2); }
.report-panel { margin-top: var(--s-2); }
.report-inline { padding: var(--s-3); border-radius: var(--r-m); background: var(--surface-inset); }
.report-text { min-height: 88px; padding-block: var(--s-3); resize: vertical; line-height: 22px; }

/* complaints (Settings > Help & complaints) */
.complaint-ack { margin-top: var(--s-2); }
.complaint-copy, .ticket-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.complaint-copy {
  padding: var(--s-3); border-radius: var(--r-m); background: var(--surface-inset);
  font: 13px/20px ui-monospace, "SF Mono", Menlo, Consolas, monospace; color: var(--ink-900);
}
.ticket-row { padding: var(--s-3); border-radius: var(--r-m); background: var(--surface-inset); }
.ticket-row > * + * { margin-top: var(--s-1); }
.ticket-text { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.helpline-row { min-height: 0; padding-block: var(--s-3); }
.about-links { font-size: 13px; line-height: 28px; }

/* paywall (C8): price, renewal and refund terms in plain view */
.paywall-price { margin-top: var(--s-2); color: var(--ink-900); }
.paywall-terms { margin-top: var(--s-2); text-align: center; }
.paywall-terms .link { font-size: 11px; }

/* weigh-in sheet: recent weigh-ins, each deletable (N-35) */
.weight-recent { margin-top: var(--s-4); }
.weight-row {
  display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: var(--s-3);
  min-height: 44px; border-top: 1px solid var(--border);
}
.weight-row .weight-delete { min-height: 44px; }
