/* =========================================================================
   Diet tracker
   Mobile-first, designed against a 380px viewport held in one hand, standing
   in a dining hall line.

   The SHAPE is MyFitnessPal's, because that is the shape Jacob already reads
   without thinking: a calorie ring, the Goal − Food = Remaining line under it,
   macro bars, then the day cut into four meals.

   The SKIN is OS SYSTEM's, the same one the workout tracker wears, so the two
   apps look like siblings on a home screen. That means FATHOM's colour law:

     greys and whites plus --glow. No chromatic accents.

   MyFitnessPal carries "over budget" in red and "good" in green. Those hues
   are not available here, so the same information is carried by WEIGHT, by a
   glow ring, and by a hairline over-mark on the bar. The one sanctioned
   chromatic pixel is --error, and it is spent on exactly two things: a day
   past the sugar line, and a destructive button.

   There is no food, calorie or target number in this file, and there must
   never be. Foods live in data/foods.json, targets in data/goals.json.
   ========================================================================= */

/* ---------- fonts ------------------------------------------------------- */

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  src: url('../assets/fonts/inter-latin-400-normal.woff2') format('woff2');
  font-display: swap;
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 500;
  src: url('../assets/fonts/inter-latin-500-normal.woff2') format('woff2');
  font-display: swap;
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 600;
  src: url('../assets/fonts/inter-latin-600-normal.woff2') format('woff2');
  font-display: swap;
}

/* ---------- tokens ------------------------------------------------------ */

:root {
  --void: #000000;
  --abyss: #030408;
  --current: #0a0e16;

  --bg: #030408;
  --panel: rgba(255, 255, 255, 0.03);
  --panel-2: rgba(255, 255, 255, 0.055);
  --line: rgba(255, 255, 255, 0.09);
  --edge: rgba(255, 255, 255, 0.14);
  --spec: rgba(255, 255, 255, 0.30);

  --ink: #edf2f7;
  --muted: #8a98a8;
  --faint: #55606e;

  --glow: rgba(200, 225, 255, 0.55);
  --glow-strong: rgba(200, 225, 255, 0.85);
  --error: #ff3b47;

  --font-body: 'Inter', 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;

  --t-xs: 0.6875rem;
  --t-sm: 0.8125rem;
  --t-md: 0.9375rem;
  --t-lg: 1.125rem;
  --t-xl: 1.375rem;
  --t-2xl: 1.75rem;
  --t-3xl: 2.25rem;

  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 28px;

  --r-1: 10px;
  --r-2: 14px;
  --r-3: 18px;

  --tap: 44px;
  --bar: 58px;

  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --fast: 140ms;
  --med: 220ms;

  color-scheme: dark;
}

/* ---------- reset ------------------------------------------------------- */

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
}

body {
  font-family: var(--font-body);
  font-size: var(--t-md);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

h1, h2, h3, p, dl, dd, dt, ul, li { margin: 0; padding: 0; }
ul { list-style: none; }

button, input, select {
  font: inherit;
  color: inherit;
}

button { cursor: pointer; }

:focus-visible {
  outline: 2px solid var(--glow-strong);
  outline-offset: 2px;
  border-radius: var(--s-1);
}

.hidden { display: none !important; }

.skip {
  position: absolute;
  left: -9999px;
}
.skip:focus {
  left: var(--s-3);
  top: var(--s-3);
  z-index: 100;
  background: var(--current);
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-1);
}

.boot {
  padding: var(--s-6) var(--s-4);
  color: var(--muted);
  text-align: center;
}

/* ---------- shell ------------------------------------------------------- */

.app {
  min-height: 100dvh;
  padding-bottom: calc(var(--bar) + env(safe-area-inset-bottom) + var(--s-4));
}

.main {
  padding: var(--s-3) var(--s-3) 0;
  max-width: 640px;
  margin: 0 auto;
}

.view {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}

/* ---------- topbar ------------------------------------------------------ */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: stretch;
  gap: var(--s-1);
  padding: calc(env(safe-area-inset-top) + var(--s-2)) var(--s-2) var(--s-2);
  background: linear-gradient(to bottom, var(--abyss) 65%, rgba(3, 4, 8, 0));
  backdrop-filter: blur(12px);
}

.daynav {
  flex: none;
  width: var(--tap);
  background: none;
  border: none;
  color: var(--muted);
  font-size: var(--t-xl);
  line-height: 1;
  border-radius: var(--r-1);
  transition: color var(--fast) var(--ease);
}
.daynav:hover { color: var(--ink); }
.daynav.is-off,
.daynav:disabled { color: var(--faint); cursor: default; }

.daybtn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  background: none;
  border: none;
  padding: var(--s-1) 0;
  border-radius: var(--r-1);
}

.tb-eyebrow {
  font-size: var(--t-xs);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--faint);
}

.tb-title {
  font-size: var(--t-lg);
  font-weight: 600;
  letter-spacing: 0.01em;
}

.topsum {
  font-size: var(--t-xs);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ---------- cards ------------------------------------------------------- */

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-3);
  padding: var(--s-4);
  backdrop-filter: blur(10px);
}

.card-title {
  font-size: var(--t-xs);
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: var(--s-3);
}

.card-note {
  font-size: var(--t-sm);
  color: var(--muted);
}
.card-note.faint { color: var(--faint); }
.card-note.stray { padding: 0 var(--s-2); }

.card-error { border-color: rgba(255, 59, 71, 0.35); }

/* ---------- the ring ---------------------------------------------------- */

.ring-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-3);
  padding-top: var(--s-5);
}

.ring-wrap {
  position: relative;
  width: 168px;
  height: 168px;
}

.ring {
  width: 100%;
  height: 100%;
  color: var(--glow-strong);
  filter: drop-shadow(0 0 10px rgba(200, 225, 255, 0.18));
}

.ring.is-over {
  color: var(--ink);
  filter: drop-shadow(0 0 14px rgba(255, 255, 255, 0.28));
}

.ring-arc { transition: stroke-dasharray var(--med) var(--ease); }

.ring-mid {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.ring-num {
  font-size: var(--t-3xl);
  font-weight: 600;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.ring-num.is-over { color: var(--ink); }

.ring-cap {
  font-size: var(--t-xs);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--faint);
}

.budget {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  width: 100%;
}

.budget-cell { text-align: center; min-width: 56px; }

.budget-val {
  font-size: var(--t-lg);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.budget-val.is-over { color: var(--ink); font-weight: 600; }

.budget-lab {
  font-size: var(--t-xs);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
}

.budget-op { color: var(--faint); font-size: var(--t-sm); }

.flagline {
  font-size: var(--t-sm);
  color: var(--error);
  text-align: center;
  padding-top: var(--s-1);
}

/* ---------- macro bars -------------------------------------------------- */

.bars {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}

.bar-row {
  display: grid;
  grid-template-columns: 58px 1fr auto;
  align-items: center;
  gap: var(--s-3);
}

.bar-lab {
  font-size: var(--t-sm);
  color: var(--muted);
}

.bar-track {
  position: relative;
  height: 6px;
  background: var(--panel-2);
  border-radius: 3px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--glow);
  transition: width var(--med) var(--ease);
}

/* Over the ceiling. No red — a brighter, harder edge instead, which reads at
   a glance without breaking the colour law. */
.bar-row.is-over .bar-fill {
  background: var(--ink);
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.35);
}
.bar-over {
  position: absolute;
  inset: 0 0 0 auto;
  width: 3px;
  background: var(--ink);
}

/* Protein and fiber are floors, not ceilings: filling them is the goal, so
   a full bar must not look like a warning. */
.bar-row.is-floor.is-over .bar-fill {
  background: var(--glow-strong);
  box-shadow: 0 0 8px rgba(200, 225, 255, 0.4);
}
.bar-row.is-floor.is-over .bar-over { display: none; }
.bar-row.is-floor.is-under .bar-fill { background: var(--faint); }

.bar-num {
  font-size: var(--t-sm);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.bar-now { color: var(--ink); }
.bar-of { color: var(--faint); }

.extras {
  display: flex;
  gap: var(--s-4);
  margin-top: var(--s-4);
  padding-top: var(--s-3);
  border-top: 1px solid var(--line);
}

.extra {
  display: flex;
  align-items: baseline;
  gap: var(--s-1);
  font-size: var(--t-sm);
}
.extra-lab { color: var(--muted); }
.extra-val { font-variant-numeric: tabular-nums; }
.extra-of { color: var(--faint); font-size: var(--t-xs); }

/* ---------- meals ------------------------------------------------------- */

.meal { padding: var(--s-3) var(--s-3) var(--s-2); }

.meal-head {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  min-height: var(--tap);
}

.meal-name {
  flex: 1;
  font-size: var(--t-xs);
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.meal-kcal {
  font-size: var(--t-sm);
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.meal-add {
  flex: none;
  width: var(--tap);
  height: var(--tap);
  margin-right: calc(var(--s-2) * -1);
  background: none;
  border: none;
  color: var(--muted);
  font-size: var(--t-xl);
  line-height: 1;
  border-radius: 50%;
  transition: color var(--fast) var(--ease), background var(--fast) var(--ease);
}
.meal-add:hover { color: var(--ink); background: var(--panel-2); }

.meal-empty {
  font-size: var(--t-sm);
  color: var(--faint);
  padding: 0 0 var(--s-2);
}

.entries {
  display: flex;
  flex-direction: column;
}

.entry {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  border-top: 1px solid var(--line);
}

.entry-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  min-height: var(--tap);
  padding: var(--s-2) 0;
  background: none;
  border: none;
  text-align: left;
}

.entry-name {
  font-size: var(--t-md);
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

.entry-sub {
  font-size: var(--t-xs);
  color: var(--faint);
}

.entry-kcal {
  font-size: var(--t-md);
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.est-mark {
  font-size: 0.5625rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 4px;
  line-height: 1.3;
}

.dayempty {
  font-size: var(--t-sm);
  color: var(--faint);
  text-align: center;
  padding: var(--s-4) var(--s-4) 0;
}

/* ---------- pills ------------------------------------------------------- */

.pillrow {
  display: flex;
  gap: var(--s-2);
}
.pillrow-wrap { flex-wrap: wrap; margin: var(--s-3) 0; }
.pillrow-tight { flex-wrap: wrap; margin-top: var(--s-3); }

.pill {
  flex: 1;
  min-height: 38px;
  padding: 0 var(--s-3);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: var(--t-sm);
  white-space: nowrap;
  transition: all var(--fast) var(--ease);
}
.pillrow-wrap .pill { flex: none; }

.pill:hover { color: var(--ink); border-color: var(--edge); }

.pill.is-on {
  color: var(--ink);
  background: var(--panel-2);
  border-color: var(--glow);
  box-shadow: 0 0 0 1px rgba(200, 225, 255, 0.12), 0 0 12px rgba(200, 225, 255, 0.1);
}

/* ---------- tiles ------------------------------------------------------- */

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
  gap: var(--s-2);
}

.tile {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--r-1);
  padding: var(--s-3) var(--s-2);
  text-align: center;
}
.tile.is-warn { border-color: var(--edge); }

.tile-val {
  font-size: var(--t-xl);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.tile-unit { font-size: var(--t-xs); color: var(--faint); margin-left: 2px; }

.tile-lab {
  font-size: var(--t-xs);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 2px;
}

.tile-sub { font-size: var(--t-xs); color: var(--faint); }

/* ---------- charts ------------------------------------------------------ */

.chart { width: 100%; }

.chart-svg { display: block; width: 100%; }

.cbar { fill: var(--glow); }
.cbar.is-over { fill: var(--ink); }

.ctick {
  fill: var(--faint);
  font-size: 10px;
  font-family: var(--font-body);
}

.wline {
  stroke: var(--glow-strong);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.wdot { fill: var(--ink); }

.chart-key {
  font-size: var(--t-xs);
  color: var(--faint);
  margin-top: var(--s-2);
}

.dotgrid {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.dot {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  background: var(--panel-2);
  border: 1px solid var(--line);
}
.dot.is-on {
  background: var(--glow);
  border-color: transparent;
}

/* ---------- body page --------------------------------------------------- */

.weighrow {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-3);
  padding: var(--s-2) 0 var(--s-3);
}

.wbtn {
  width: var(--tap);
  height: var(--tap);
  border-radius: 50%;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: var(--t-lg);
  line-height: 1;
}
.wbtn:hover { color: var(--ink); border-color: var(--edge); }

.weightbox {
  width: 130px;
  background: none;
  border: none;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  font-size: var(--t-3xl);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  text-align: center;
  padding: 0 0 var(--s-1);
  -moz-appearance: textfield;
}
.weightbox::-webkit-outer-spin-button,
.weightbox::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.weightbox:focus { outline: none; border-bottom-color: var(--glow); }

.weighunit { color: var(--faint); font-size: var(--t-md); }

.goalbar {
  position: relative;
  height: 8px;
  background: var(--panel-2);
  border-radius: 4px;
  margin-bottom: var(--s-4);
  overflow: hidden;
}
.goalbar-fill {
  height: 100%;
  background: var(--glow);
  border-radius: 4px;
  transition: width var(--med) var(--ease);
}
/* Where a straight line to December says he should be today. */
.goalbar-pace {
  position: absolute;
  top: -2px;
  bottom: -2px;
  width: 2px;
  background: var(--ink);
  opacity: 0.65;
}

.habits {
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
}

.habit {
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

.habit-btn {
  flex: 1;
  display: flex;
  align-items: center;
  gap: var(--s-3);
  min-height: var(--tap);
  padding: var(--s-1) 0;
  background: none;
  border: none;
  text-align: left;
}

.habit-box {
  font-size: var(--t-lg);
  color: var(--faint);
  line-height: 1;
  transition: color var(--fast) var(--ease), text-shadow var(--fast) var(--ease);
}
.habit.is-on .habit-box {
  color: var(--glow-strong);
  text-shadow: 0 0 10px rgba(200, 225, 255, 0.5);
}

.habit-text { display: flex; flex-direction: column; gap: 1px; }
.habit-name { font-size: var(--t-md); }
.habit.is-on .habit-name { color: var(--muted); }
.habit-note { font-size: var(--t-xs); color: var(--faint); }

.habit-week { display: flex; gap: 3px; flex: none; }

.hdot {
  width: 6px;
  height: 14px;
  border-radius: 2px;
  background: var(--panel-2);
}
.hdot.is-on { background: var(--glow); }
.hdot.is-today { box-shadow: 0 0 0 1px var(--edge); }

/* ---------- foods page -------------------------------------------------- */

.foodlist {
  display: flex;
  flex-direction: column;
  margin-top: var(--s-3);
}

.frow {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  border-top: 1px solid var(--line);
}

.frow-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  min-height: var(--tap);
  padding: var(--s-2) 0;
  background: none;
  border: none;
  text-align: left;
}

.frow-name {
  font-size: var(--t-md);
  display: flex;
  align-items: center;
  gap: var(--s-2);
  flex-wrap: wrap;
}

.frow-sub {
  font-size: var(--t-xs);
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

.btnrow {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
  margin-top: var(--s-3);
}

/* ---------- buttons ----------------------------------------------------- */

.btn {
  min-height: var(--tap);
  padding: 0 var(--s-4);
  border-radius: var(--r-1);
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--ink);
  font-size: var(--t-sm);
  transition: all var(--fast) var(--ease);
}
.btn:hover { border-color: var(--edge); }
.btn:disabled { opacity: 0.4; cursor: default; }

.btn-primary {
  background: rgba(200, 225, 255, 0.12);
  border-color: var(--glow);
  color: var(--ink);
  font-weight: 500;
}
.btn-primary:hover:not(:disabled) {
  background: rgba(200, 225, 255, 0.18);
  box-shadow: 0 0 16px rgba(200, 225, 255, 0.14);
}

.btn-quiet { background: var(--panel); color: var(--muted); }
.btn-quiet:hover { color: var(--ink); }

.btn-danger { color: var(--error); border-color: rgba(255, 59, 71, 0.3); }
.btn-danger:hover { border-color: rgba(255, 59, 71, 0.55); }

.wide { width: 100%; margin-top: var(--s-2); }

/* ---------- the microphone FAB ------------------------------------------ */

.fab {
  position: fixed;
  right: var(--s-4);
  bottom: calc(var(--bar) + env(safe-area-inset-bottom) + var(--s-3));
  z-index: 30;
  display: flex;
  align-items: center;
  gap: var(--s-2);
  height: 52px;
  padding: 0 var(--s-5) 0 var(--s-4);
  border-radius: 26px;
  border: 1px solid var(--glow);
  background: rgba(10, 14, 22, 0.92);
  backdrop-filter: blur(12px);
  color: var(--ink);
  font-size: var(--t-md);
  font-weight: 500;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.6), 0 0 18px rgba(200, 225, 255, 0.12);
  transition: transform var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}
.fab:hover { transform: translateY(-2px); box-shadow: 0 6px 28px rgba(0, 0, 0, 0.6), 0 0 24px rgba(200, 225, 255, 0.2); }
.fab:active { transform: translateY(0); }

.fab-glyph {
  font-size: 10px;
  color: var(--glow-strong);
  text-shadow: 0 0 8px rgba(200, 225, 255, 0.8);
}

/* ---------- tab bar ----------------------------------------------------- */

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 25;
  display: flex;
  height: calc(var(--bar) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(3, 4, 8, 0.92);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
}

.tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: var(--faint);
  font-size: var(--t-xs);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  transition: color var(--fast) var(--ease);
  position: relative;
}
.tab:hover { color: var(--muted); }

.tab.is-active { color: var(--ink); }
.tab.is-active::after {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 22px;
  height: 2px;
  background: var(--glow-strong);
  box-shadow: 0 0 8px rgba(200, 225, 255, 0.6);
}

/* ---------- the add sheet ----------------------------------------------- */

.sheet {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.sheet-scrim {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(3px);
}

.sheet-panel {
  position: relative;
  width: 100%;
  max-width: 640px;
  max-height: 92dvh;
  display: flex;
  flex-direction: column;
  background: var(--current);
  border: 1px solid var(--edge);
  border-bottom: none;
  border-radius: var(--r-3) var(--r-3) 0 0;
  box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.7);
  animation: rise var(--med) var(--ease);
}

@keyframes rise {
  from { transform: translateY(16px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .sheet-panel { animation: none; }
  * { transition-duration: 1ms !important; }
}

.sheet-head {
  display: flex;
  align-items: center;
  padding: var(--s-3) var(--s-3) var(--s-2) var(--s-4);
  border-bottom: 1px solid var(--line);
}

.sheet-title {
  flex: 1;
  font-size: var(--t-xs);
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.sheet-x {
  width: var(--tap);
  height: var(--tap);
  background: none;
  border: none;
  color: var(--muted);
  font-size: var(--t-xl);
  line-height: 1;
  border-radius: 50%;
}
.sheet-x:hover { color: var(--ink); background: var(--panel-2); }

.sheet-body {
  flex: 1;
  overflow-y: auto;
  scrollbar-gutter: stable;
  padding: var(--s-4);
  padding-bottom: calc(env(safe-area-inset-bottom) + var(--s-4));
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
}
/* A flex column shrinks its children before it will overflow, which silently
   squashes the review list instead of scrolling it. This is the workout
   tracker's WEEK bug; one rule prevents it. */
.sheet-body > * { flex: none; }

.sheet-error {
  font-size: var(--t-sm);
  color: var(--error);
}

.sheet-notice {
  font-size: var(--t-sm);
  color: var(--muted);
}

/* --- microphone block --- */

.mic-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-3);
}

.mic {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-2);
  width: 100%;
  padding: var(--s-5) var(--s-4);
  border-radius: var(--r-2);
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  transition: all var(--med) var(--ease);
}
.mic:hover { border-color: var(--edge); color: var(--ink); }

.mic-glyph {
  width: 34px;
  height: 34px;
  color: var(--muted);
  transition: color var(--med) var(--ease);
}

.mic-label { font-size: var(--t-sm); }

.mic.is-live {
  border-color: var(--glow);
  background: rgba(200, 225, 255, 0.06);
  color: var(--ink);
}
.mic.is-live .mic-glyph {
  color: var(--glow-strong);
  animation: pulse 1.5s var(--ease) infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; filter: drop-shadow(0 0 6px rgba(200, 225, 255, 0.5)); }
  50% { opacity: 0.55; filter: drop-shadow(0 0 14px rgba(200, 225, 255, 0.9)); }
}

.mic-hint,
.mic-unsupported {
  font-size: var(--t-sm);
  color: var(--faint);
  text-align: center;
}

.heard {
  font-size: var(--t-md);
  color: var(--ink);
  text-align: center;
  padding: var(--s-2) var(--s-3);
  background: var(--panel-2);
  border-radius: var(--r-1);
  width: 100%;
}
.heard.is-live { color: var(--muted); font-style: italic; }

/* --- typing --- */

.typerow { display: flex; gap: var(--s-2); }

.typebox {
  flex: 1;
  min-height: var(--tap);
  width: 100%;
  padding: 0 var(--s-3);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-1);
  color: var(--ink);
  font-size: var(--t-md);
}
.typebox::placeholder { color: var(--faint); }
.typebox:focus { outline: none; border-color: var(--glow); }

.typego { flex: none; }

/* --- review rows --- */

.review { display: flex; flex-direction: column; gap: var(--s-2); }

.review-title {
  font-size: var(--t-xs);
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.irow {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: 'main num' 'acts acts';
  gap: var(--s-2);
  padding: var(--s-3);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-1);
}

.irow-main { grid-area: main; min-width: 0; }
.irow-num { grid-area: num; text-align: right; }
.irow-acts { grid-area: acts; display: flex; gap: var(--s-2); }

.irow-name {
  font-size: var(--t-md);
  display: flex;
  align-items: center;
  gap: var(--s-2);
  flex-wrap: wrap;
}

.irow-sub { font-size: var(--t-xs); color: var(--faint); }
.irow-warn { color: var(--muted); }

.irow-kcal {
  font-size: var(--t-lg);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.irow-macro { font-size: var(--t-xs); color: var(--faint); font-variant-numeric: tabular-nums; }

.ibtn {
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: var(--r-1);
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--muted);
  font-size: var(--t-md);
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.ibtn:hover { color: var(--ink); border-color: var(--edge); }
.ibtn svg { width: 18px; height: 18px; }
.ibtn-x { margin-left: auto; }
.ibtn-x:hover { color: var(--error); border-color: rgba(255, 59, 71, 0.4); }

/* --- unknown --- */

.urow {
  padding: var(--s-3);
  background: var(--panel);
  border: 1px solid rgba(255, 59, 71, 0.25);
  border-radius: var(--r-1);
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}

.urow-name { font-size: var(--t-md); }
.urow-note { font-size: var(--t-xs); color: var(--muted); }
.urow-acts { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.urow-acts .btn { min-height: 38px; padding: 0 var(--s-3); flex: 1; }

/* --- recents --- */

.recents { display: flex; flex-direction: column; gap: var(--s-2); }

.chiprow { display: flex; flex-wrap: wrap; gap: var(--s-2); }

.chip {
  min-height: 38px;
  padding: 0 var(--s-3);
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  font-size: var(--t-sm);
}
.chip:hover { color: var(--ink); border-color: var(--edge); }

/* --- footer --- */

.sheet-foot {
  position: sticky;
  bottom: calc(env(safe-area-inset-bottom) * -1 - var(--s-4));
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3) 0 0;
  margin-top: auto;
  background: var(--current);
  border-top: 1px solid var(--line);
}

.foot-sum { flex: 1; }

.foot-kcal {
  font-size: var(--t-xl);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.foot-unit { font-size: var(--t-xs); color: var(--faint); margin-left: var(--s-1); }
.foot-macro { font-size: var(--t-xs); color: var(--faint); }

.foot-go { flex: none; }

/* ---------- popovers and dialogs ---------------------------------------- */

.pop {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s-4);
}

.pop-scrim {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
}

.pop-panel {
  position: relative;
  width: 100%;
  max-width: 440px;
  max-height: 86dvh;
  overflow-y: auto;
  scrollbar-gutter: stable;
  padding: var(--s-4);
  background: var(--current);
  border: 1px solid var(--edge);
  border-radius: var(--r-2);
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.8);
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}
.pop-panel > * { flex: none; }

.pop-title { font-size: var(--t-lg); font-weight: 500; }
.pop-note { font-size: var(--t-sm); color: var(--muted); }
.pop-acts { display: flex; gap: var(--s-2); justify-content: flex-end; }

.swaplist {
  display: flex;
  flex-direction: column;
  max-height: 42dvh;
  overflow-y: auto;
}

.swapitem {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  min-height: var(--tap);
  padding: var(--s-2) 0;
  background: none;
  border: none;
  border-top: 1px solid var(--line);
  text-align: left;
  font-size: var(--t-sm);
}
.swapitem:hover { color: var(--ink); }
.swapkcal { color: var(--faint); font-size: var(--t-xs); font-variant-numeric: tabular-nums; white-space: nowrap; }
.swapnone { font-size: var(--t-sm); color: var(--faint); padding: var(--s-3) 0; }

.nutgrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(78px, 1fr));
  gap: var(--s-2);
}

.nutcell {
  background: var(--panel-2);
  border-radius: var(--r-1);
  padding: var(--s-2);
  text-align: center;
}
.nutcell dt { font-size: var(--t-xs); color: var(--faint); text-transform: uppercase; letter-spacing: 0.1em; }
.nutcell dd { font-size: var(--t-md); font-variant-numeric: tabular-nums; margin-top: 2px; }

.ffgrid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-2);
}

.ff { display: flex; flex-direction: column; gap: var(--s-1); }
.ff-label { font-size: var(--t-xs); color: var(--muted); letter-spacing: 0.08em; text-transform: uppercase; }
.ff-input {
  min-height: 40px;
  padding: 0 var(--s-2);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-1);
  color: var(--ink);
  font-size: var(--t-md);
}
.ff-input:focus { outline: none; border-color: var(--glow); }

/* dom.js dialogs */
.dialog {
  background: var(--current);
  color: var(--ink);
  border: 1px solid var(--edge);
  border-radius: var(--r-2);
  padding: var(--s-4);
  max-width: 380px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.8);
}
.dialog::backdrop { background: rgba(0, 0, 0, 0.75); }
.dialog-title { font-size: var(--t-lg); font-weight: 500; margin-bottom: var(--s-2); }
.dialog-body { font-size: var(--t-sm); color: var(--muted); display: flex; flex-direction: column; gap: var(--s-2); }
.dialog-actions { display: flex; gap: var(--s-2); justify-content: flex-end; margin-top: var(--s-4); }

/* ---------- toast ------------------------------------------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--bar) + env(safe-area-inset-bottom) + 72px);
  transform: translateX(-50%);
  z-index: 70;
  padding: var(--s-2) var(--s-4);
  background: rgba(10, 14, 22, 0.96);
  border: 1px solid var(--edge);
  border-radius: 999px;
  font-size: var(--t-sm);
  color: var(--ink);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
  animation: rise var(--fast) var(--ease);
  pointer-events: none;
  white-space: nowrap;
}

/* ---------- fatal ------------------------------------------------------- */

.fatal {
  max-width: 480px;
  margin: 0 auto;
  padding: var(--s-6) var(--s-4);
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}
.fatal-kicker { font-size: var(--t-xs); letter-spacing: 0.2em; text-transform: uppercase; color: var(--error); }
.fatal-title { font-size: var(--t-xl); font-weight: 500; }
.fatal-line { font-size: var(--t-sm); color: var(--muted); }
.fatal-code {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--r-1);
  padding: var(--s-3);
  font-size: var(--t-sm);
  overflow-x: auto;
}
.fatal .btn { align-self: flex-start; }

/* ---------- wider screens ----------------------------------------------- */

@media (min-width: 560px) {
  .main { padding: var(--s-4) var(--s-4) 0; }
  .irow {
    grid-template-columns: 1fr auto auto;
    grid-template-areas: 'main num acts';
    align-items: center;
  }
  .irow-acts { justify-content: flex-end; }
  .ibtn-x { margin-left: 0; }
}

/* ---------- the laptop link (Foods -> Data) ----------------------------- */

.syncblock {
  margin-top: var(--s-4);
  padding-top: var(--s-3);
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}
