/* Ember – minimal design system, dark by default with a light theme.
 *
 * Near-black canvas, white type, hairline dividers, one green accent and one red for warnings.
 * Big numbers are set light and large; everything else is quiet. Navigation is a floating pill.
 * The theme is chosen on the Profile page and stored per device (see /js/theme.js).
 *
 * Sections: font · tokens · base · navigation · page header · sections · type helpers · buttons ·
 * forms · tables · figures & meters · feedback · page-specific.
 */

/* ---------- Font (self-hosted Manrope, SIL Open Font License – see /fonts) ---------- */

@font-face {
  font-family: 'Manrope';
  font-style: normal;
  font-display: swap;
  font-weight: 200 800;
  src: url(/fonts/manrope-latin-wght-normal.woff2) format('woff2-variations');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Manrope';
  font-style: normal;
  font-display: swap;
  font-weight: 200 800;
  src: url(/fonts/manrope-latin-ext-wght-normal.woff2) format('woff2-variations');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ---------- Tokens ---------- */

:root {
  --bg: #0a0a0a;
  --surface: #141414;       /* inputs, pills, calendar */
  --surface-2: #1c1c1c;     /* hover */
  --line: #1f1f1f;          /* dividers */
  --line-2: #2a2a2a;        /* borders, tracks */
  --text: #fafafa;
  --text-2: #d4d4d4;
  --muted: #8a8a8a;         /* ≥ 4.5:1 on --bg */
  --faint: #404040;         /* non-text only */
  --placeholder: #5c5c5c;
  --accent: #4ade80;        /* protein, goals reached, focus */
  --cal: #fb923c;           /* calories */
  --cal-soft: rgba(251, 146, 60, 0.16);
  --glow: rgba(251, 146, 60, 0.13);
  --glow-2: rgba(74, 222, 128, 0.08);
  --accent-ink: #052e16;
  --accent-soft: rgba(74, 222, 128, 0.1);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.1);
  --primary-hover: #e5e5e5;
  --glass: rgba(23, 23, 23, 0.86);
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);

  --font: 'Manrope', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --t-hero: clamp(4.5rem, 19vw, 8.5rem);
  --t-figure: clamp(2rem, 5vw, 2.75rem);
  --t-h1: clamp(1.75rem, 3.6vw, 2.25rem);
  --t-body: 1rem;
  --t-small: 0.875rem;
  --t-label: 0.8125rem;

  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px; --s8: 64px; --s9: 96px;
  --r-sm: 12px;
  --r: 16px;
  --r-lg: 24px;
  --pill: 999px;
  --control-h: 46px;
  --tabbar-h: 60px;
  --tabbar-gap: 20px;
  --content-w: 1080px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

/* ---------- Colour palettes (Profile > Appearance, js/lib/palettes.js) ----------
   Each palette sets the calorie colour (--cal) and the protein/goal colour (--accent).
   Ember is the default above; the light-mode pairs are darker for contrast. */
:root[data-palette=ocean] { --cal: #60a5fa; --accent: #2dd4bf; --cal-soft: rgba(96, 165, 250, 0.16); --glow: rgba(96, 165, 250, 0.13); --glow-2: rgba(45, 212, 191, 0.08); --accent-soft: rgba(45, 212, 191, 0.1); }
:root[data-palette=berry] { --cal: #f472b6; --accent: #a78bfa; --cal-soft: rgba(244, 114, 182, 0.16); --glow: rgba(244, 114, 182, 0.13); --glow-2: rgba(167, 139, 250, 0.08); --accent-soft: rgba(167, 139, 250, 0.1); }
:root[data-palette=sunset] { --cal: #fb7185; --accent: #fbbf24; --cal-soft: rgba(251, 113, 133, 0.16); --glow: rgba(251, 113, 133, 0.13); --glow-2: rgba(251, 191, 36, 0.08); --accent-soft: rgba(251, 191, 36, 0.1); }
:root[data-palette=royal] { --cal: #fbbf24; --accent: #818cf8; --cal-soft: rgba(251, 191, 36, 0.16); --glow: rgba(251, 191, 36, 0.13); --glow-2: rgba(129, 140, 248, 0.08); --accent-soft: rgba(129, 140, 248, 0.1); }
:root[data-palette=lagoon] { --cal: #22d3ee; --accent: #a3e635; --cal-soft: rgba(34, 211, 238, 0.16); --glow: rgba(34, 211, 238, 0.13); --glow-2: rgba(163, 230, 53, 0.08); --accent-soft: rgba(163, 230, 53, 0.1); }
:root[data-palette=peach] { --cal: #fdba74; --accent: #86efac; --cal-soft: rgba(253, 186, 116, 0.16); --glow: rgba(253, 186, 116, 0.13); --glow-2: rgba(134, 239, 172, 0.08); --accent-soft: rgba(134, 239, 172, 0.1); }
:root[data-palette=mono] { --cal: #e5e5e5; --accent: #a3a3a3; --cal-soft: rgba(229, 229, 229, 0.16); --glow: rgba(229, 229, 229, 0.13); --glow-2: rgba(163, 163, 163, 0.08); --accent-soft: rgba(163, 163, 163, 0.1); }
/* The accent is also a background (switches, badges); Mono needs dark text on its light grey. */
:root[data-palette=mono] { --accent-ink: #0a0a0a; }

:root[data-theme=light] {
  --bg: #f6f6f4;
  --surface: #ffffff;
  --surface-2: #efefed;
  --line: #e6e5e2;
  --line-2: #d9d8d4;
  --text: #0a0a0a;
  --text-2: #2b2b2b;
  --muted: #6b6b68;
  --faint: #bdbcb8;
  --placeholder: #a3a29f;
  --accent: #15803d;
  --cal: #ea580c;
  --cal-soft: rgba(234, 88, 12, 0.14);
  --glow: rgba(249, 115, 22, 0.12);
  --glow-2: rgba(34, 197, 94, 0.08);
  --accent-ink: #ffffff;
  --accent-soft: rgba(21, 128, 61, 0.1);
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.08);
  --primary-hover: #262626;
  --glass: rgba(255, 255, 255, 0.86);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
  color-scheme: light;
}

:root[data-theme=light][data-palette=ocean] { --cal: #2563eb; --accent: #0f766e; --cal-soft: rgba(37, 99, 235, 0.14); --glow: rgba(37, 99, 235, 0.12); --glow-2: rgba(15, 118, 110, 0.08); --accent-soft: rgba(15, 118, 110, 0.1); }
:root[data-theme=light][data-palette=berry] { --cal: #db2777; --accent: #7c3aed; --cal-soft: rgba(219, 39, 119, 0.14); --glow: rgba(219, 39, 119, 0.12); --glow-2: rgba(124, 58, 237, 0.08); --accent-soft: rgba(124, 58, 237, 0.1); }
:root[data-theme=light][data-palette=sunset] { --cal: #e11d48; --accent: #b45309; --cal-soft: rgba(225, 29, 72, 0.14); --glow: rgba(225, 29, 72, 0.12); --glow-2: rgba(180, 83, 9, 0.08); --accent-soft: rgba(180, 83, 9, 0.1); }
:root[data-theme=light][data-palette=royal] { --cal: #b45309; --accent: #4f46e5; --cal-soft: rgba(180, 83, 9, 0.14); --glow: rgba(180, 83, 9, 0.12); --glow-2: rgba(79, 70, 229, 0.08); --accent-soft: rgba(79, 70, 229, 0.1); }
:root[data-theme=light][data-palette=lagoon] { --cal: #0891b2; --accent: #4d7c0f; --cal-soft: rgba(8, 145, 178, 0.14); --glow: rgba(8, 145, 178, 0.12); --glow-2: rgba(77, 124, 15, 0.08); --accent-soft: rgba(77, 124, 15, 0.1); }
:root[data-theme=light][data-palette=peach] { --cal: #c2410c; --accent: #3f7d4f; --cal-soft: rgba(194, 65, 12, 0.14); --glow: rgba(194, 65, 12, 0.12); --glow-2: rgba(63, 125, 79, 0.08); --accent-soft: rgba(63, 125, 79, 0.1); }
:root[data-theme=light][data-palette=mono] { --cal: #262626; --accent: #737373; --cal-soft: rgba(38, 38, 38, 0.14); --glow: rgba(38, 38, 38, 0.12); --glow-2: rgba(115, 115, 115, 0.08); --accent-soft: rgba(115, 115, 115, 0.1); }
:root[data-theme=light][data-palette=mono] { --accent-ink: #ffffff; }

/* ---------- Base ---------- */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); touch-action: pan-x pan-y; /* no double-tap or pinch zoom */ }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 var(--t-body)/1.55 var(--font);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  overflow-x: clip; /* decorative glows must never cause sideways scrolling */
}
h1, h2, h3, p, dl, dd, ol, ul { margin: 0; }
h1, h2, h3 { font-weight: 600; line-height: 1.2; letter-spacing: -0.02em; }
h2 { font-size: 1rem; }
h3 { font-size: var(--t-body); }
a { color: inherit; text-decoration: none; }
ul, ol { padding: 0; list-style: none; }
button { font: inherit; color: inherit; }
img, svg { display: block; }
.icon { flex-shrink: 0; }
::selection { background: var(--accent); color: var(--accent-ink); }

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

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

/* ---------- Navigation: floating pill ---------- */
/* Bottom of the screen on phones and tablets, top centre on desktop. */

.layout { min-height: 100dvh; }

.nav {
  position: fixed; z-index: 30;
  left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar-gap) + var(--safe-bottom));
  width: min(calc(100% - 32px), 520px);
}
.nav-brand, .nav-foot { display: none; }
.nav-list {
  display: flex; align-items: center; gap: 2px;
  height: var(--tabbar-h); padding: 6px;
  background: var(--glass);
  border: 1px solid var(--line-2); border-radius: var(--pill);
  backdrop-filter: blur(18px) saturate(140%); -webkit-backdrop-filter: blur(18px) saturate(140%);
  box-shadow: var(--shadow);
}
.nav-list { position: relative; }
.nav-list li { flex: 1; display: flex; height: 100%; position: relative; z-index: 1; }
.nav-link {
  flex: 1; display: flex; align-items: center; justify-content: center;
  border-radius: var(--pill);
  font-size: 0.875rem; font-weight: 500; color: var(--muted);
  transition: color 0.25s ease, transform 0.15s ease;
}
.nav-link:hover { color: var(--text); }
.nav-link:active { transform: scale(0.94); }
.nav-link.active { color: var(--bg); font-weight: 600; }
/* The white pill behind the active tab. Positioned from JS (app.js) and slides between tabs. */
.nav-indicator {
  position: absolute; z-index: 0; top: 6px; bottom: 6px; left: 0; width: 0;
  border-radius: var(--pill); background: var(--text); opacity: 0;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
}
.nav-indicator.animate { transition: transform 0.45s cubic-bezier(.34, 1.36, .64, 1), width 0.45s cubic-bezier(.34, 1.36, .64, 1); }
.nav-link .short { display: none; }
@media (max-width: 420px) {
  .nav-link .full { display: none; }
  .nav-link .short { display: inline; }
}

.page {
  width: 100%;
  max-width: calc(var(--content-w) + 2 * var(--s6));
  margin: 0 auto;
  padding: calc(var(--s7) + var(--safe-top)) var(--s5) calc(var(--tabbar-h) + var(--tabbar-gap) + var(--safe-bottom) + var(--s8));
}

@media (min-width: 1024px) {
  .nav { top: var(--s5); bottom: auto; width: auto; }
  .nav-list { height: 52px; padding: 5px; }
  .nav-indicator { top: 5px; bottom: 5px; }
  .nav-link { padding: 0 var(--s5); }
  .nav-brand {
    display: block; position: fixed; left: var(--s6); top: calc(var(--s5) + 14px); z-index: 30;
    font-weight: 700; letter-spacing: -0.02em; font-size: 1.0625rem;
  }
  .nav-brand span { color: var(--accent); }
  .page { padding: calc(var(--s9) + var(--s5)) var(--s6) var(--s9); }
}

/* ---------- Page header ---------- */

.ph {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
  gap: var(--s4) var(--s6);
  margin-bottom: var(--s7);
  position: relative; isolation: isolate;
  --ph-glow: var(--glow); --ph-glow-2: var(--glow-2);
}
/* Faint glow behind the title, like the one behind the calorie number on Today (tinted per page). */
.ph::before {
  content: ''; position: absolute; z-index: -1; inset: -70% 0 -50%; pointer-events: none; /* never wider than the page */
  background: radial-gradient(45% 55% at 25% 50%, var(--ph-glow), transparent 70%), radial-gradient(30% 40% at 65% 72%, var(--ph-glow-2), transparent 70%);
}
[data-tab=workouts] .ph { --ph-glow: var(--glow-2); --ph-glow-2: var(--glow); }
[data-tab=profile] .ph::before { opacity: 0.6; }
.ph-text { display: flex; flex-direction: column; gap: var(--s2); min-width: 0; max-width: 44rem; }
.ph h1 { font-size: var(--t-h1); letter-spacing: -0.03em; font-weight: 600; overflow-wrap: anywhere; }
.ph-lede { color: var(--muted); max-width: 36rem; white-space: pre-line; }
.ph-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }
@media (max-width: 639px) {
  .ph { margin-bottom: var(--s6); }
  .ph-actions { width: 100%; }
}

.eyebrow {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--s1) var(--s2);
  font-size: var(--t-label); font-weight: 500; color: var(--muted);
}
.eyebrow a { color: var(--text-2); }
.eyebrow a:hover { color: var(--text); }
.eyebrow .sep { color: var(--faint); }

/* ---------- Sections ---------- */

.sec { border-top: 1px solid var(--line); padding-top: var(--s5); }
.sec + .sec { margin-top: var(--s6); }
.sec-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--s1) var(--s4); margin-bottom: var(--s4); }
.sec-head h2 { font-size: 0.9375rem; font-weight: 600; }
.sec-meta { font-size: var(--t-small); color: var(--muted); }
.sec-meta a { color: var(--muted); transition: color 0.15s; }
.sec-meta a:hover { color: var(--text); }
.stack { display: flex; flex-direction: column; gap: var(--s4); }
.row { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }

/* ---------- Type helpers ---------- */

.muted { color: var(--muted); }
.small { font-size: var(--t-small); }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.label { font-size: var(--t-label); font-weight: 500; color: var(--muted); }
.pre-line { white-space: pre-line; }
.link { color: var(--text); text-decoration: underline; text-decoration-color: var(--faint); text-underline-offset: 3px; }
.link:hover { text-decoration-color: var(--text); }
.text-accent { color: var(--accent); }
.text-danger { color: var(--danger); }
.tag {
  display: inline-flex; align-items: center; vertical-align: middle;
  font-size: 0.75rem; font-weight: 600; line-height: 1;
  padding: 5px 9px; border-radius: var(--pill); background: var(--surface-2); color: var(--muted);
}
.tag-accent { color: var(--accent); background: var(--accent-soft); }
.tag-danger { color: var(--danger); background: var(--danger-soft); }
.tag-ink { color: var(--bg); background: var(--text); }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: 42px; padding: 0 var(--s5);
  font: 600 0.9375rem/1 var(--font);
  color: var(--text); background: var(--surface);
  border: 1px solid var(--line-2); border-radius: var(--pill);
  cursor: pointer; white-space: nowrap;
  transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.1s;
}
.btn:hover:not(:disabled) { background: var(--surface-2); border-color: var(--faint); }
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn-primary { background: var(--text); color: var(--bg); border-color: var(--text); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-quiet { background: transparent; border-color: transparent; color: var(--muted); padding: 0 var(--s3); }
.btn-quiet:hover:not(:disabled) { background: var(--surface-2); border-color: transparent; color: var(--text); }
.btn-danger { background: transparent; border-color: transparent; color: var(--danger); padding: 0 var(--s3); }
.btn-danger:hover:not(:disabled) { background: var(--danger-soft); border-color: transparent; }
.btn-danger.outlined { border-color: var(--danger); padding: 0 var(--s5); }
.btn-sm { min-height: 34px; padding: 0 var(--s4); font-size: 0.8125rem; }
.btn-lg { min-height: 54px; padding: 0 var(--s6); font-size: 1rem; }
.btn-block { width: 100%; }
@media (pointer: coarse) { .btn { min-height: var(--control-h); } .btn-sm { min-height: 40px; } }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 36px; height: 36px; flex-shrink: 0;
  border: 0; border-radius: 50%; background: transparent; color: var(--muted); cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.icon-btn:disabled { opacity: 0.3; cursor: default; }
.icon-btn.danger:hover:not(:disabled) { color: var(--danger); }
@media (pointer: coarse) { .icon-btn { width: 44px; height: 44px; } }

/* Switch (theme toggle) */
.switch-row + .switch-row { margin-top: var(--s2); }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); padding: var(--s3) var(--s4); background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r); cursor: pointer; }
.switch-row span { font-weight: 600; }
.switch {
  position: relative; width: 52px; height: 32px; flex-shrink: 0;
  border: 0; border-radius: var(--pill); background: var(--line-2); cursor: pointer; transition: background 0.2s;
}
.switch::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); transition: transform 0.2s cubic-bezier(.2,.7,.2,1);
}
.switch[aria-checked=true] { background: var(--accent); }
.switch[aria-checked=true]::after { transform: translateX(20px); }

/* ---------- Forms ---------- */

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label { font-size: var(--t-label); font-weight: 500; color: var(--muted); }
.field-hint { font-size: var(--t-label); color: var(--muted); }

input, select, textarea {
  width: 100%; min-height: var(--control-h);
  font: 500 16px/1.4 var(--font); /* 16px stops iOS zooming on focus */
  color: var(--text); background: var(--surface);
  border: 1px solid var(--line-2); border-radius: var(--r-sm);
  padding: 11px 14px;
  transition: border-color 0.15s, background 0.15s;
  appearance: none; -webkit-appearance: none;
}
input:hover, select:hover, textarea:hover { border-color: var(--faint); }
input:focus, select:focus, textarea:focus { border-color: var(--text); outline: none; }
input::placeholder, textarea::placeholder { color: var(--placeholder); }
input[type=number]::-webkit-outer-spin-button, input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; }
textarea { resize: vertical; }
select {
  padding-right: 36px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%238a8a8a' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
}
option { background: var(--surface); color: var(--text); }

.grid-2, .grid-3, .grid-4 { display: grid; gap: var(--s3); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 479px) { .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Segmented control (sign in / new profile) */
.tabs { display: flex; padding: 4px; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--pill); margin-bottom: var(--s6); }
.tabs button {
  flex: 1; min-height: 40px; background: none; border: 0; border-radius: var(--pill); cursor: pointer;
  font-weight: 600; font-size: 0.9375rem; color: var(--muted); transition: background 0.15s, color 0.15s;
}
.tabs button:hover { color: var(--text); }
.tabs button[aria-selected=true] { background: var(--text); color: var(--bg); }

/* Settings rows: description left, controls right */
.setting { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr); gap: var(--s4) var(--s7); padding: var(--s6) 0; border-top: 1px solid var(--line); }
.setting:first-of-type { border-top: 0; padding-top: 0; }
.setting-text { display: flex; flex-direction: column; gap: var(--s1); }
.setting-text h2 { font-size: 1rem; }
.setting-text p { color: var(--muted); font-size: var(--t-small); max-width: 22rem; }
.setting-body { max-width: 34rem; }
@media (max-width: 767px) { .setting { grid-template-columns: 1fr; gap: var(--s4); } }

/* ---------- Tables ---------- */

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; }
.table th {
  text-align: left; font-size: var(--t-label); font-weight: 500; color: var(--muted);
  padding: 0 var(--s3) var(--s3); border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table td { padding: 14px var(--s3); border-bottom: 1px solid var(--line); vertical-align: top; color: var(--text-2); }
.table th:first-child, .table td:first-child { padding-left: 0; }
.table th:last-child, .table td:last-child { padding-right: 0; }
.table td:first-child { color: var(--text); }
.table .n { text-align: right; white-space: nowrap; }
.table .actions { text-align: right; white-space: nowrap; width: 1%; padding-top: 8px; padding-bottom: 8px; }
.table td.actions.block { white-space: normal; width: 17rem; }
.table td.actions.block .btn { margin: 2px 0 2px 2px; }
.table .actions > * { display: inline-flex; vertical-align: middle; }
.table tbody tr.linked { cursor: pointer; transition: background 0.12s; }
.table tbody tr.linked:hover { background: var(--surface-2); }
.table .group td { padding-top: var(--s5); padding-bottom: var(--s2); font-size: var(--t-label); font-weight: 600; color: var(--muted); border-bottom-color: transparent; }
.table .group td:first-child { color: var(--text-2); }
.table .cell-title, .ex-list .cell-title { font-weight: 600; color: var(--text); }
.table .cell-sub, .ex-list .cell-sub { display: block; color: var(--muted); font-size: var(--t-small); margin-top: 2px; }
.table tr.editing td { background: var(--surface); padding: var(--s4); }
.table tfoot td { border-bottom: 0; padding-top: var(--s4); font-weight: 600; color: var(--text); }
.table-fixed { table-layout: fixed; }
.table-fixed .c-idx { width: 2.75rem; } .table-fixed .c-sr { width: 9rem; } .table-fixed .c-w { width: 7rem; } .table-fixed .c-r { width: 6rem; }

/* Below 640px, rows in .table-stack become compact blocks; numeric cells sit inline with labels. */
@media (max-width: 639px) {
  .table-fixed { table-layout: auto; }
  .table-stack thead { display: none; }
  .table-stack, .table-stack tbody, .table-stack tr, .table-stack td { display: block; width: 100%; }
  .table-stack tr { position: relative; padding: var(--s3) 0; border-bottom: 1px solid var(--line); }
  .table-stack td { border: 0; padding: 2px 0; text-align: left; }
  .table-stack td.n { display: inline-block; width: auto; margin-right: var(--s4); font-size: var(--t-small); }
  .table-stack td[data-label]::before { content: attr(data-label) ' '; color: var(--muted); font-weight: 500; }
  .table-stack td:first-child { padding-right: 5.5rem; }
  .table-stack td.actions { position: absolute; top: 6px; right: 0; width: auto; padding: 0; }
  .table-stack td.actions.block { position: static; padding-top: var(--s2); display: flex; flex-wrap: wrap; gap: var(--s1); }
  .table-stack tr.group { padding-top: var(--s5); border-bottom: 0; }
  .table-stack tr.editing { padding: 0; }
  .table-stack tfoot, .table-stack .hide-sm, .table-stack td.hide-sm { display: none; }
}
@media (min-width: 640px) { .only-sm { display: none; } }

/* ---------- Figures & meters ---------- */

.figures { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.figure { display: flex; flex-direction: column; gap: var(--s2); padding: var(--s5) var(--s5) var(--s5) 0; min-width: 0; }
.figure + .figure { border-left: 1px solid var(--line); padding-left: var(--s5); padding-right: 0; }
.figure-value { display: flex; align-items: baseline; flex-wrap: wrap; gap: 2px var(--s2); }
.figure-value strong { font-size: var(--t-figure); font-weight: 500; letter-spacing: -0.04em; line-height: 1; }
.figure-value span { font-size: var(--t-small); color: var(--muted); font-weight: 500; }
.figure-note { font-size: var(--t-small); color: var(--muted); }
.label.dot-cal::before, .label.dot-protein::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 7px; vertical-align: 1px; background: var(--cal); }
.label.dot-protein::before { background: var(--accent); }
.figure-note strong { color: var(--text); font-weight: 600; }
.figure.compact .figure-value strong { font-size: clamp(1.625rem, 3.4vw, 2rem); }

.meter { position: relative; height: 3px; background: var(--line-2); border-radius: 2px; overflow: hidden; }
.meter-fill { height: 100%; background: var(--cal); border-radius: 2px; transition: width 0.6s cubic-bezier(.2,.7,.2,1); }
.meter.protein .meter-fill { background: var(--accent); }
.meter.over .meter-fill { background: var(--danger); }
.meter.protein.over .meter-fill { background: var(--accent); }

/* Bar chart */
.chart { --h: 120px; --axis: 16px; display: grid; grid-template-columns: repeat(var(--cols, 7), minmax(0, 1fr)); gap: 10px; position: relative; }
.chart-col { display: flex; flex-direction: column; gap: var(--s2); min-width: 0; }
.chart-bar-wrap { position: relative; height: var(--h); display: flex; align-items: flex-end; }
.chart-bar { width: 100%; background: var(--cal-soft); min-height: 3px; border-radius: 6px; transition: height 0.6s cubic-bezier(.2,.7,.2,1); }
.chart-col.today .chart-bar { background: var(--cal); }
.chart-bar.over { background: var(--danger-soft); box-shadow: inset 0 0 0 1px var(--danger); }
.chart-col.today .chart-bar.over { background: var(--danger); box-shadow: none; }
.chart-goal { position: absolute; left: 0; right: 0; height: 0; z-index: 1; border-top: 1px dashed var(--muted); opacity: 0.6; pointer-events: none; }
.chart-goal span { position: absolute; right: 0; bottom: 4px; font-size: 0.6875rem; color: var(--muted); background: var(--bg); padding-left: 6px; }
.chart-x { height: var(--axis); display: flex; justify-content: center; align-items: center; gap: 5px; font-size: 0.75rem; color: var(--muted); font-weight: 500; }
.chart-col.today .chart-x { color: var(--text); }
.chart-mark { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
.chart-legend { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s5); margin-top: var(--s4); font-size: var(--t-label); color: var(--muted); }
.chart-legend span { display: inline-flex; align-items: center; gap: var(--s2); }
.swatch { width: 10px; height: 10px; display: inline-block; border-radius: 3px; background: var(--line-2); }
.swatch.ink { background: var(--cal); }
.swatch.signal { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.swatch.over { background: var(--danger); }
.swatch.goal { width: 14px; height: 0; border-radius: 0; border-top: 1px dashed var(--muted); background: none; }

/* ---------- Feedback ---------- */

.loading { position: relative; height: 2px; overflow: hidden; background: var(--line); border-radius: 1px; margin-top: var(--s2); }
.loading::after {
  content: ''; position: absolute; inset: 0 auto 0 0; width: 30%;
  background: var(--text); border-radius: 1px; animation: loading 1s ease-in-out infinite;
}
@keyframes loading { from { transform: translateX(-100%); } to { transform: translateX(340%); } }
.splash { min-height: 70dvh; display: grid; place-items: center; }
.splash .loading { width: 96px; }

.empty { padding: var(--s3) 0; max-width: 28rem; }
.empty h3 { font-size: 0.9375rem; font-weight: 600; margin-bottom: var(--s1); }
.empty p { color: var(--muted); font-size: var(--t-small); }
.empty .row { margin-top: var(--s4); }

.notice { padding: var(--s3) var(--s4); font-size: var(--t-small); color: var(--danger); background: var(--danger-soft); border-radius: var(--r-sm); }

.error-state { max-width: 32rem; display: flex; flex-direction: column; gap: var(--s3); align-items: flex-start; padding-top: var(--s6); }
.error-state h1 { font-size: var(--t-h1); }

.toast {
  position: fixed; z-index: 50;
  left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + var(--tabbar-gap) + var(--safe-bottom) + var(--s3));
  max-width: min(30rem, calc(100% - 2rem));
  padding: var(--s3) var(--s5);
  background: var(--text); color: var(--bg);
  font-size: 0.9375rem; font-weight: 600; border-radius: var(--pill);
  box-shadow: var(--shadow);
  animation: toast-in 0.2s ease-out;
}
.toast.error { background: var(--danger); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }
@media (min-width: 1024px) { .toast { bottom: var(--s6); } }

/* ---------- Dashboard ---------- */

.today-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--s5); }
.today-date { font-size: var(--t-small); color: var(--muted); font-weight: 500; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--cal-soft), var(--accent-soft)); border: 1px solid var(--line-2);
  color: var(--text); font-weight: 600; font-size: 0.9375rem;
  transition: border-color 0.15s;
}
.avatar:hover { border-color: var(--cal); }

.hero { position: relative; isolation: isolate; text-align: center; padding: var(--s5) 0 var(--s6); }
.hero::before {
  content: ''; position: absolute; z-index: -1; inset: -12% 0 15%;
  background: radial-gradient(50% 55% at 50% 45%, var(--glow), transparent 70%), radial-gradient(30% 40% at 80% 70%, var(--glow-2), transparent 70%);
  pointer-events: none;
}
.hero-label { font-size: var(--t-small); color: var(--muted); font-weight: 500; }
.hero-value { font-size: var(--t-hero); font-weight: 200; letter-spacing: -0.06em; line-height: 0.95; margin: var(--s3) 0 var(--s2); }
.hero-sub { color: var(--muted); font-weight: 500; }
.hero-sub b { color: var(--cal); font-weight: 600; }
.hero-sub b.over { color: var(--danger); }
.hero-sub b.ahead { color: var(--accent); }
.hero-sub b.ahead.far { color: var(--cal); } /* gaining, but far over: calm, not alarming */
.hero .meter { margin-top: var(--s6); }
.hero-cta { margin-top: var(--s5); }

.week-dots { display: flex; gap: 8px; margin-top: var(--s3); }
.week-dots i { width: 12px; height: 12px; border-radius: 50%; background: var(--line-2); }
.week-dots i.logged { background: var(--cal); }
.week-dots i.hit { background: var(--accent); }
.week-dots i.today { box-shadow: 0 0 0 2px var(--bg), 0 0 0 3px var(--muted); }

.dash { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0; }
.dash-main > * + * { margin-top: var(--s6); }
.dash-side { margin-top: var(--s6); }
@media (min-width: 1024px) {
  .dash { grid-template-columns: minmax(0, 6fr) minmax(0, 5fr); gap: var(--s8); align-items: start; }
  .dash-side { margin-top: 0; }
  .dash .hero { text-align: left; padding-top: 0; }
}

.feed li { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s4); padding: 13px 0; border-bottom: 1px solid var(--line); }
.feed li:last-child { border-bottom: 0; }
.feed .feed-main { min-width: 0; }
.feed .feed-title { color: var(--text); font-weight: 500; }
.feed a.feed-title:hover { color: var(--accent); }
.feed .feed-meta { display: block; font-size: var(--t-label); color: var(--muted); margin-top: 1px; }
.feed .num { color: var(--muted); font-size: 0.9375rem; }

/* ---------- Food log ---------- */

.food { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: var(--s8); align-items: start; }
.food-main > * + * { margin-top: var(--s6); }
.food-aside { position: sticky; top: calc(var(--s9) + var(--s4)); }
.food-aside-toggle { display: none; }
@media (min-width: 1024px) { .food-main { grid-column: 1; grid-row: 1; } .food-aside { grid-column: 2; grid-row: 1; } }
@media (max-width: 1023px) {
  .food { grid-template-columns: 1fr; gap: 0; }
  .food-aside { position: static; display: none; margin-bottom: var(--s6); }
  .food.calendar-open .food-aside { display: block; }
  .food-aside-toggle { display: inline-flex; }
}

.datebar { display: flex; align-items: center; gap: var(--s1); background: var(--surface); border: 1px solid var(--line); border-radius: var(--pill); padding: 3px; }
.datebar-label { min-width: 6.5rem; text-align: center; font-weight: 600; font-size: 0.9375rem; }
.datebar .btn { margin-left: var(--s1); }

.entry-form { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.3fr) auto; gap: var(--s3); align-items: end; }
.entry-form .btn { min-height: var(--control-h); }
@media (max-width: 767px) {
  .entry-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .entry-form > :first-child { grid-column: 1 / -1; }
  .entry-form > :last-child { grid-column: 1 / -1; }
}
.entry-form.inline { grid-template-columns: minmax(0, 3fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.3fr) auto auto; }
@media (max-width: 767px) { .entry-form.inline { grid-template-columns: repeat(2, minmax(0, 1fr)); } .entry-form.inline > :nth-last-child(2), .entry-form.inline > :last-child { grid-column: auto; } }

.quick { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); margin-top: var(--s4); }
.quick .label { margin-right: var(--s1); }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 34px; padding: 0 var(--s4);
  font: 500 0.8125rem/1 var(--font); color: var(--text-2);
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--pill); cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.chip:hover:not(:disabled) { border-color: var(--faint); color: var(--text); }
.chip:disabled { opacity: 0.45; }
.chip .num { color: var(--cal); font-size: 0.75rem; }
@media (pointer: coarse) { .chip { min-height: 40px; } }

/* Calendar */
.calendar { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--s4) var(--s4) var(--s5); }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--s2); padding-left: var(--s2); }
.cal-head h2 { font-size: 0.9375rem; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; }
.cal-weekdays span { text-align: center; font-size: 0.6875rem; font-weight: 600; color: var(--muted); padding: var(--s2) 0; }
.cal-cell {
  position: relative; height: 40px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font: 500 0.8125rem/1 var(--font); color: var(--text-2);
  background: transparent; border: 0; border-radius: var(--r-sm); cursor: pointer;
}
.cal-cell.cal-blank { cursor: default; }
.cal-cell:not(.cal-blank):hover { background: var(--surface-2); }
.cal-cell.future { color: var(--faint); }
.cal-cell.today { color: var(--text); font-weight: 700; }
.cal-cell.selected { background: var(--text); color: var(--bg); font-weight: 700; }
.cal-cell.selected:hover { background: var(--primary-hover); }
.cal-dot { width: 5px; height: 5px; border-radius: 50%; }
.cal-cell.logged .cal-dot, .cal-dot.logged { background: var(--cal); }
.cal-cell.hit .cal-dot, .cal-dot.hit { background: var(--accent); }
.cal-cell.selected.logged .cal-dot { background: var(--bg); }
.cal-legend { display: flex; gap: var(--s4); margin-top: var(--s3); padding-left: var(--s2); font-size: 0.75rem; color: var(--muted); }
.cal-legend span { display: inline-flex; align-items: center; gap: 6px; }
.cal-summary { margin-top: var(--s2); padding-left: var(--s2); font-size: var(--t-label); color: var(--muted); }
.cal-today { margin: var(--s3) 0 0 var(--s2); }

/* ---------- Workouts ---------- */

.day-head { display: flex; align-items: baseline; gap: var(--s3); }
.day-index { font-size: var(--t-label); font-weight: 600; color: var(--accent); }
.day-notes { color: var(--muted); font-size: var(--t-small); margin: calc(-1 * var(--s2)) 0 var(--s4); }

.editor-day { border-top: 1px solid var(--line); padding-top: var(--s5); }
.editor-day + .editor-day { margin-top: var(--s6); }
.editor-day-head { display: flex; align-items: center; gap: var(--s2); margin-bottom: var(--s3); }
.editor-day-head .day-index { width: 2rem; }
.editor-day-head input { font-size: 1.125rem; font-weight: 600; background: transparent; border-color: transparent; padding-left: 0; }
.editor-day-head input:hover { border-color: var(--line-2); padding-left: 14px; }
.editor-day-head input:focus { padding-left: 14px; border-color: var(--text); }
.ex-row { display: grid; grid-template-columns: 2rem minmax(0, 1fr) auto; gap: var(--s2); align-items: center; padding: 3px 0; max-width: 40rem; }
.ex-row .ex-n { font-size: var(--t-label); color: var(--muted); text-align: right; padding-right: var(--s2); }
.ex-row input { min-height: 44px; padding: 8px 12px; font-size: 16px; border-radius: 10px; }
.ex-ctrl { display: flex; }
@media (max-width: 899px) {
  .ex-row { grid-template-columns: minmax(0, 1fr) auto; }
  .ex-row .ex-n { display: none; }
}
/* Plan view when exercises are just names */
.ex-list { list-style: none; margin: 0; padding: 0; }
.ex-list li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 var(--s3); padding: var(--s3) 0; border-bottom: 1px solid var(--line); }
.ex-list .ex-n { width: 2rem; font-size: var(--t-label); color: var(--muted); font-variant-numeric: tabular-nums; }
.ex-list .cell-sub { flex-basis: 100%; padding-left: calc(2rem + var(--s3)); }
.editor-foot {
  position: sticky; bottom: calc(var(--tabbar-h) + var(--tabbar-gap) + var(--safe-bottom) + var(--s3));
  margin-top: var(--s6); padding: var(--s2);
  display: flex; gap: var(--s2); justify-content: flex-end;
  background: var(--glass); border: 1px solid var(--line-2); border-radius: var(--pill);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); box-shadow: var(--shadow);
}
@media (min-width: 1024px) { .editor-foot { bottom: var(--s5); max-width: 22rem; margin-left: auto; } }
@media (max-width: 639px) { .editor-foot .btn-primary { flex: 1; } }

/* ---------- Calculator ---------- */

.calc { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: var(--s8); align-items: start; }
.calc-result { position: sticky; top: calc(var(--s9) + var(--s4)); }
@media (max-width: 899px) { .calc { grid-template-columns: 1fr; gap: var(--s6); } .calc-result { position: static; } }
.calc-empty { font-size: 1.25rem; font-weight: 500; letter-spacing: -0.02em; line-height: 1.35; max-width: 22rem; color: var(--text-2); margin-top: var(--s2); }
.breakdown { margin-top: var(--s4); }
.breakdown div { display: flex; justify-content: space-between; gap: var(--s4); padding: 13px 0; border-bottom: 1px solid var(--line); font-size: 0.9375rem; }
.breakdown dt { color: var(--muted); }
.breakdown dd { text-align: right; color: var(--text); font-weight: 500; }
.calc-apply { margin-top: var(--s5); display: flex; flex-direction: column; gap: var(--s3); align-items: flex-start; }

/* ---------- Welcome ---------- */

.welcome { min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); }
.welcome-intro {
  display: flex; flex-direction: column; justify-content: space-between; gap: var(--s8);
  padding: calc(var(--s7) + var(--safe-top)) var(--s8) var(--s7);
  border-right: 1px solid var(--line);
}
.welcome-intro .nav-brand, .setup-top .nav-brand { display: block; position: static; font-weight: 700; letter-spacing: -0.02em; font-size: 1.0625rem; }
.welcome-intro .nav-brand span, .setup-top .nav-brand span { color: var(--accent); }
.welcome-intro h1 { font-size: clamp(3rem, 7vw, 5.5rem); line-height: 0.98; letter-spacing: -0.055em; font-weight: 300; max-width: 11ch; }
.welcome-intro h1 em { font-style: normal; color: var(--accent); }
.welcome-points { display: grid; max-width: 28rem; }
.welcome-points li { padding: var(--s3) 0; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.9375rem; }
.welcome > main { display: flex; align-items: center; justify-content: center; min-width: 0; }
.welcome-form { display: flex; flex-direction: column; padding: var(--s8); max-width: 480px; width: 100%; }
.welcome-form h2 { font-size: 1.5rem; letter-spacing: -0.03em; margin-bottom: var(--s1); }
.welcome-form > .muted { margin-bottom: var(--s5); }
.welcome-foot {
  position: fixed; right: var(--s5); bottom: calc(var(--s4) + var(--safe-bottom));
  display: flex; align-items: center; gap: var(--s4);
}
.link-btn { background: none; border: 0; padding: var(--s2) 0; color: var(--muted); font: inherit; font-size: var(--t-label); font-weight: 500; cursor: pointer; }
.link-btn:hover { color: var(--text); text-decoration: underline; }
.admin-link {
  font-size: var(--t-label); font-weight: 500; color: var(--muted);
  padding: var(--s2) var(--s4); border-radius: var(--pill); border: 1px solid var(--line-2);
  transition: color 0.15s, border-color 0.15s;
}
.admin-link:hover { color: var(--text); border-color: var(--faint); }
@media (max-width: 899px) {
  .welcome { grid-template-columns: 1fr; }
  .welcome-intro { border-right: 0; border-bottom: 1px solid var(--line); padding: calc(var(--s6) + var(--safe-top)) var(--s5) var(--s6); gap: var(--s6); }
  .welcome-intro h1 { font-size: clamp(2.75rem, 13vw, 3.75rem); }
  .welcome-form { padding: var(--s6) var(--s5) var(--s7); max-width: none; }
  .welcome-foot { position: static; flex-wrap: wrap; margin: 0 var(--s5) calc(var(--s6) + var(--safe-bottom)); justify-self: start; }
}

/* ---------- First-run setup ---------- */

.setup { min-height: 100dvh; display: flex; flex-direction: column; max-width: 640px; margin: 0 auto; padding: calc(var(--s4) + var(--safe-top)) var(--s5) calc(var(--s5) + var(--safe-bottom)); }
.setup-top { display: flex; align-items: center; gap: var(--s4); min-height: 44px; }
.setup-step-count { font-size: var(--t-small); font-weight: 600; color: var(--muted); margin-left: auto; }
.setup-progress { height: 3px; background: var(--line-2); border-radius: 2px; margin-top: var(--s3); overflow: hidden; }
.setup-progress div { height: 100%; background: var(--accent); border-radius: 2px; transition: width 0.4s ease; }
.setup-body { flex: 1; padding: 11vh 0 var(--s6); display: flex; flex-direction: column; gap: var(--s2); }
.setup-body h1 { font-size: clamp(1.875rem, 6vw, 2.5rem); letter-spacing: -0.035em; line-height: 1.1; }
.setup-hint { color: var(--muted); font-size: 1.0625rem; margin-bottom: var(--s5); max-width: 32rem; }
.setup-body.forward { animation: step-in 0.3s ease-out both; }
.setup-body.back { animation: step-in-back 0.3s ease-out both; }
@keyframes step-in { from { opacity: 0; transform: translateX(16px); } }
@keyframes step-in-back { from { opacity: 0; transform: translateX(-16px); } }

.choices { display: flex; flex-direction: column; gap: var(--s2); }
.setup-buddy { display: flex; flex-direction: column; gap: var(--s4); }
.choice {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: var(--s4);
  width: 100%; text-align: left; padding: var(--s4) var(--s5);
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r);
  cursor: pointer; transition: background 0.15s, border-color 0.15s;
}
.choice:hover { border-color: var(--faint); }
.choice[aria-checked=true] { border-color: var(--text); }
.choice strong { display: block; font-weight: 600; font-size: 1rem; }
.choice .choice-hint { display: block; color: var(--muted); font-size: var(--t-small); margin-top: 2px; }
.choice-box { width: 20px; height: 20px; border: 1.5px solid var(--faint); border-radius: 50%; display: grid; place-items: center; transition: border-color 0.15s; }
.choice[aria-checked=true] .choice-box { border-color: var(--accent); }
.choice[aria-checked=true] .choice-box::after { content: ''; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }

.big-number { display: flex; align-items: baseline; gap: var(--s3); border-bottom: 1px solid var(--line-2); transition: border-color 0.15s; }
.big-number:focus-within { border-color: var(--text); }
.big-number input {
  border: 0; padding: 0 0 var(--s2); min-height: 0; background: transparent; border-radius: 0;
  font-size: clamp(4rem, 18vw, 6.5rem); font-weight: 200; letter-spacing: -0.06em; line-height: 1;
}
.big-number span { font-size: 1.125rem; color: var(--muted); font-weight: 500; }
.setup-range { font-size: var(--t-small); color: var(--muted); margin-top: var(--s2); }
.setup-range.error { color: var(--danger); }
.setup-intro li { padding: var(--s3) 0; border-top: 1px solid var(--line); color: var(--text-2); }
.setup-intro li:last-child { border-bottom: 1px solid var(--line); }
.target-input { display: flex; align-items: baseline; gap: var(--s2); }
.target-input input {
  border: 0; border-bottom: 1px dashed var(--faint); border-radius: 0; padding: 0 0 4px; min-height: 0; background: transparent;
  font-size: var(--t-figure); font-weight: 400; letter-spacing: -0.04em; width: 100%; min-width: 0;
}
.target-input input:focus { border-bottom: 1px solid var(--text); }
.target-input span { font-size: var(--t-small); color: var(--muted); }
.setup-foot { position: sticky; bottom: calc(var(--s3) + var(--safe-bottom)); display: flex; gap: var(--s2); padding-top: var(--s3); background: linear-gradient(transparent, var(--bg) 30%); }
.setup-foot .btn-primary { flex: 1; }

/* ---------- Admin ---------- */

.admin { max-width: calc(var(--content-w) + 2 * var(--s6)); margin: 0 auto; padding: calc(var(--s7) + var(--safe-top)) var(--s6) var(--s9); }
.admin-gate { max-width: 400px; padding-top: 10vh; display: flex; flex-direction: column; gap: var(--s4); }
.admin-gate h1 { font-size: var(--t-h1); letter-spacing: -0.03em; }
.admin-gate ol { counter-reset: point; }
.admin-gate ol li { display: grid; grid-template-columns: 1.75rem 1fr; padding: var(--s3) 0; border-top: 1px solid var(--line); font-size: 0.9375rem; color: var(--text-2); }
.admin-gate ol li::before { counter-increment: point; content: counter(point); color: var(--accent); font-weight: 600; }
.admin-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin-bottom: var(--s7); }
.admin-summary .figure + .figure { border-left: 1px solid var(--line); padding-left: var(--s5); }
.create-form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: var(--s3); align-items: start; }
.create-form .btn { margin-top: 23px; min-height: var(--control-h); }
@media (max-width: 639px) { .create-form { grid-template-columns: 1fr; } .create-form .btn { margin-top: 0; } }
.reset-form { display: flex; flex-wrap: wrap; gap: var(--s3); align-items: end; }
.reset-form .field { flex: 1 1 16rem; }
@media (max-width: 1023px) { .admin { padding: calc(var(--s6) + var(--safe-top)) var(--s5) var(--s8); } }

/* Numbered steps (profile install instructions) */
.steps-list { counter-reset: point; }
.steps-list li { display: grid; grid-template-columns: 1.75rem 1fr; padding: var(--s3) 0; border-top: 1px solid var(--line); font-size: 0.9375rem; color: var(--text-2); }
.steps-list li::before { counter-increment: point; content: counter(point); color: var(--accent); font-weight: 600; }

/* ---------- Motion preferences ---------- */

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

/* ---------- Cards ---------- */

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: var(--s4) 18px; min-width: 0; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s2); }
.card-head h2 { font-size: 1rem; font-weight: 700; }
.card-meta { font-size: var(--t-small); color: var(--muted); font-weight: 500; }
.card-label { font-size: var(--t-small); color: var(--muted); font-weight: 600; }
.card-list > * + * { border-top: 1px solid var(--line); }
.card-row {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3); width: 100%; min-height: 52px;
  padding: var(--s2) 0; background: none; border: 0; color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
.card-row + .card-row { border-top: 1px solid var(--line); }
.card-row-label { min-width: 0; font-weight: 500; }
.card-row-value { display: inline-flex; align-items: center; gap: var(--s1); color: var(--muted); font-size: 0.9375rem; white-space: nowrap; }
.card-row .icon { color: var(--faint); flex: none; }
.card-row.danger .card-row-label { color: var(--danger); }
.card-row:active { opacity: 0.6; }
.group-label { font-size: var(--t-label); font-weight: 600; color: var(--muted); margin: var(--s5) var(--s1) var(--s2); }
.group-label:first-child { margin-top: 0; }
.cards > * + * { margin-top: var(--s3); }
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s3); }
.tile-value { display: flex; align-items: baseline; gap: 6px; margin: 6px 0 var(--s3); }
.tile-value strong { font-size: 1.75rem; font-weight: 600; letter-spacing: -0.03em; line-height: 1; }
.tile-value span { font-size: var(--t-small); color: var(--muted); }

/* ---------- Bottom sheet (scanner, forms) ---------- */

.sheet-backdrop {
  position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; justify-content: center;
  background: rgba(0, 0, 0, 0.55); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  animation: fade-in 0.18s ease-out;
}
.sheet-backdrop.closing { animation: fade-out 0.18s ease-in forwards; }
/* set by openSheet() while the keyboard (or zoom) changes the visible area */
.sheet-backdrop.fit-viewport { top: var(--vv-top); bottom: auto; height: var(--vv-height); }
.sheet-backdrop.fit-viewport .sheet { max-height: calc(var(--vv-height) - var(--s3)); }
.sheet {
  width: min(100%, 520px); max-height: 92dvh; overflow-y: auto;
  background: var(--bg); border: 1px solid var(--line-2); border-bottom: 0;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  padding: var(--s4) var(--s5) calc(var(--s6) + var(--safe-bottom));
  box-shadow: var(--shadow);
  animation: sheet-up 0.28s cubic-bezier(.2, .8, .2, 1);
}
@media (min-width: 640px) {
  .sheet-backdrop { align-items: center; }
  .sheet { border-radius: var(--r-lg); border-bottom: 1px solid var(--line-2); padding-bottom: var(--s6); }
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--s4); }
.sheet-head h2 { font-size: 1.125rem; }
.sheet-body { display: flex; flex-direction: column; gap: var(--s4); }
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } }

.scan-view { position: relative; aspect-ratio: 4 / 3; border-radius: var(--r); overflow: hidden; background: #000; }
.scan-video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-frame {
  position: absolute; inset: 28% 12%; border-radius: var(--r-sm);
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.35); border: 2px solid rgba(255, 255, 255, 0.85);
}
.scan-frame::after {
  content: ''; position: absolute; left: 6%; right: 6%; top: 50%; height: 2px; background: var(--cal);
  box-shadow: 0 0 12px var(--cal); animation: scan-line 1.6s ease-in-out infinite alternate;
}
@keyframes scan-line { from { transform: translateY(-34px); } to { transform: translateY(34px); } }
.scan-status { font-size: var(--t-small); color: var(--muted); }
.scan-status.error { color: var(--danger); }
.scan-manual { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--s2); align-items: end; }
.scan-manual .btn { min-height: var(--control-h); }
.scan-result { display: flex; flex-direction: column; gap: var(--s1); }
.scan-result h3 { font-size: 1.25rem; letter-spacing: -0.02em; }
.scan-totals { margin: var(--s1) 0; }
.grams-input { display: flex; align-items: center; gap: 6px; }
.grams-input input { width: 6.5rem; min-height: 38px; padding: 7px 12px; }
.grams-input span { color: var(--muted); font-size: var(--t-small); }
.scan-credit { margin-top: var(--s2); }

/* ---------- Food suggestions ---------- */

.suggest { position: relative; min-width: 0; scroll-margin-top: var(--s5); }
.suggest-list {
  position: absolute; z-index: 25; top: calc(100% + 6px); left: 0; right: 0; min-width: min(100%, 320px);
  max-height: 340px; overflow-y: auto; padding: 6px;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r);
  box-shadow: var(--shadow); animation: fade-in 0.12s ease-out;
}
@media (min-width: 768px) { .suggest-list { right: auto; width: max(100%, 380px); } }
.suggest-group { font-size: 0.75rem; font-weight: 600; color: var(--muted); padding: 8px 10px 4px; }
.suggest-option {
  display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3);
  padding: 10px; border-radius: 10px; cursor: pointer;
}
.suggest-option:hover, .suggest-option[aria-selected=true] { background: var(--surface-2); }
.suggest-name { font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggest-meta { font-size: var(--t-label); color: var(--muted); white-space: nowrap; }

.portion-row {
  grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s2) var(--s4);
  padding: var(--s3) var(--s4); background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r);
  animation: fade-in 0.15s ease-out;
}
@media (min-width: 768px) { .entry-form:not(.inline) .portion-row { grid-row: 2; } }
.portion-food { font-size: var(--t-small); color: var(--muted); }
.portion-food strong { color: var(--text); font-weight: 600; }
.portion-controls { display: flex; align-items: center; gap: var(--s2); }
.portion-grams { white-space: nowrap; }
@media (max-width: 767px) {
  .portion-controls { width: 100%; }
  .portion-controls select { flex: 1; min-width: 0; }
}
.portion-controls input { width: 5.5rem; min-height: 40px; padding: 8px 12px; }
.portion-controls select { width: auto; min-height: 40px; padding-top: 8px; padding-bottom: 8px; }

/* ---------- Loading skeletons & reveal ---------- */

/* Only shown if loading takes longer than ~120 ms, so fast loads don't flicker. */
.skeleton { display: flex; flex-direction: column; gap: var(--s4); animation: fade-in 0.25s ease-out 0.12s both; }
.sk {
  height: 14px; border-radius: 8px;
  background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 40%, var(--surface) 80%) 0 0 / 300% 100%;
  animation: shimmer 1.3s ease-in-out infinite;
}
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
.sk.w-15 { width: 15%; } .sk.w-20 { width: 20%; } .sk.w-30 { width: 30%; } .sk.w-35 { width: 35%; } .sk.w-40 { width: 40%; }
.sk.w-50 { width: 50%; } .sk.w-55 { width: 55%; } .sk.w-60 { width: 60%; } .sk.w-100 { width: 100%; }
.sk.h-sm { height: 12px; } .sk.h-lg { height: 30px; border-radius: 10px; } .sk.h-xl { height: clamp(64px, 14vw, 110px); border-radius: 16px; }
.sk.h-line { height: 3px; } .sk.h-block { height: 96px; border-radius: var(--r); } .sk.h-input { height: var(--control-h); border-radius: var(--r-sm); }
.sk.circle { width: 38px; height: 38px; border-radius: 50%; }
.sk.pill { width: 112px; height: 42px; border-radius: var(--pill); }
.sk-top { display: flex; justify-content: space-between; align-items: center; }
.sk-head { display: flex; flex-direction: column; gap: var(--s3); margin-bottom: var(--s4); }
.sk-hero { display: flex; flex-direction: column; align-items: center; gap: var(--s3); padding: var(--s5) 0; }
@media (min-width: 1024px) { .sk-hero { align-items: flex-start; max-width: 55%; } }
.sk-pair { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s4); }
.sk-row { display: flex; justify-content: space-between; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--line); }
.sk-gap { margin-top: var(--s4); }

/* Pieces of a freshly loaded page rise in one after another (--i is set by reveal() in ui.js). */
.piece { animation: rise 0.42s cubic-bezier(.2, .8, .2, 1) both; animation-delay: calc(var(--i, 0) * 35ms); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
.share-notice {
  font-size: var(--t-small); line-height: 1.45; color: var(--text-2);
  padding: var(--s3) var(--s4); border-radius: var(--r-sm);
  background: var(--cal-soft); border: 1px solid color-mix(in srgb, var(--cal) 35%, transparent);
}
.share-notice strong { color: var(--cal); }
.product-form { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1.4fr) repeat(3, minmax(0, 1fr)); gap: var(--s3); align-items: end; }
.product-form > .row { grid-column: 1 / -1; justify-content: flex-end; }
@media (max-width: 767px) { .product-form { grid-template-columns: repeat(2, minmax(0, 1fr)); } .product-form > :first-child { grid-column: 1 / -1; } }

/* ---------- Streak fox (views/fox.js) ---------- */

.hero-row { display: flex; align-items: flex-end; justify-content: center; gap: 2px; }
@media (min-width: 1024px) { .dash .hero-row { justify-content: flex-start; } }
.hero-row .hero-value { margin-bottom: var(--s2); }

.fox {
  position: relative; flex-shrink: 0; width: clamp(80px, 22vw, 116px); padding: 0; margin: 0 0 var(--s1) var(--s5);
  background: none; border: 0; cursor: pointer; color: inherit; -webkit-tap-highlight-color: transparent;
  animation: fox-in 0.5s cubic-bezier(.3, 1.4, .5, 1) both;
}
/* The fox head drawings live in public/img/fox/<mood>.svg (vector, one per mood). */
.fox-figure { position: relative; display: block; transform-origin: 70% 95%; animation: fox-breathe 4.5s ease-in-out infinite; }
.fox-img { display: block; width: 100%; height: auto; aspect-ratio: 310 / 428; user-select: none; -webkit-user-drag: none; }
/* Accessories (rewards) drawn on top, in the same coordinates as the fox (js/lib/fox-items.js) */
.fox-items { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.fox[data-mood=angry] .fox-img { filter: saturate(1.15) hue-rotate(-6deg); }
.fox[data-mood=sleepy] .fox-img { filter: brightness(0.92); }
.fox[data-mood=sleepy] .fox-figure { animation-duration: 6s; }
.fox[data-mood=sad] .fox-figure { rotate: 3deg; }

@keyframes fox-in { from { opacity: 0; transform: translateY(6px) scale(0.92); } }
@keyframes fox-breathe { 50% { translate: 0 -1px; scale: 1.008; } }
/* Movements played now and then by views/fox.js (act-*), and "hop" when tapped */
@keyframes fox-hop { 30% { transform: translateY(-5px) rotate(-3deg); } 60% { transform: translateY(0) rotate(1deg); } }
@keyframes fox-glance { 25%, 70% { transform: rotate(-6deg); } }
@keyframes fox-lean { 30%, 75% { transform: translateX(-3px) rotate(-8deg); } }
@keyframes fox-huff { 20% { transform: scale(1.05) rotate(-2deg); } 40% { transform: scale(0.98); } 60% { transform: scale(1.03) rotate(1deg); } }
@keyframes fox-droop { 35%, 70% { transform: translateY(2px) rotate(5deg); } }
.fox.act-hop .fox-figure { animation: fox-hop 0.6s cubic-bezier(.3, 1.4, .5, 1), fox-breathe 4.5s ease-in-out infinite; }
.fox.act-glance .fox-figure { animation: fox-glance 1.2s ease-in-out, fox-breathe 4.5s ease-in-out infinite; }
.fox.act-lean .fox-figure { animation: fox-lean 1.2s ease-in-out, fox-breathe 4.5s ease-in-out infinite; }
.fox.act-huff .fox-figure { animation: fox-huff 0.7s ease-out, fox-breathe 4.5s ease-in-out infinite; }
.fox.act-droop .fox-figure { animation: fox-droop 1.2s ease-in-out, fox-breathe 4.5s ease-in-out infinite; }

/* Sleepy: a small "z" drifting up */
.fox-z {
  position: absolute; top: 4%; right: 2%; font-size: 0.75rem; font-weight: 700; color: var(--muted);
  pointer-events: none; animation: fox-z 3s ease-out infinite;
}
@keyframes fox-z { 0% { opacity: 0; transform: translate(0, 6px) scale(0.8); } 30% { opacity: 1; } 100% { opacity: 0; transform: translate(8px, -14px) scale(1.1); } }

@media (prefers-reduced-motion: reduce) { .fox, .fox .fox-figure, .fox-z { animation: none !important; } }

/* Streak label and speech bubble */
.fox-streak { display: block; margin-top: 2px; font-size: 0.6875rem; font-weight: 600; color: var(--muted); text-align: center; white-space: nowrap; }
.fox-bubble {
  position: absolute; z-index: 5; right: 0; bottom: calc(100% + 6px); width: max-content; max-width: min(220px, 70vw);
  padding: var(--s2) var(--s3); border-radius: var(--r-sm); background: var(--text); color: var(--bg);
  font-size: var(--t-label); font-weight: 600; line-height: 1.35; text-align: left;
  opacity: 0; transform: translateY(4px) scale(0.96); transform-origin: bottom right; pointer-events: none;
  transition: opacity 0.18s, transform 0.18s;
}
.fox-bubble::after { content: ''; position: absolute; right: 26px; top: 100%; border: 6px solid transparent; border-top-color: var(--text); }
.fox.talking .fox-bubble { opacity: 1; transform: none; }

/* Today's question: the fox asks in its bubble, you answer with one of the small reply bubbles */
.fox-wrap { position: relative; flex-shrink: 0; }
.fox-ask {
  position: absolute; z-index: 6; right: 0; bottom: calc(100% - 4px); width: max-content; max-width: min(250px, 78vw);
  display: flex; flex-direction: column; align-items: flex-end; gap: var(--s2);
  opacity: 0; transform: translateY(6px) scale(0.94); transform-origin: bottom right; pointer-events: none;
  transition: opacity 0.2s, transform 0.25s cubic-bezier(.3, 1.4, .5, 1);
}
.fox-wrap.asking .fox-ask { opacity: 1; transform: none; pointer-events: auto; }
.fox-ask-q {
  position: relative; order: 2; margin: 0; padding: var(--s2) var(--s3); border-radius: var(--r-sm);
  background: var(--text); color: var(--bg); font-size: 0.875rem; font-weight: 700; line-height: 1.35;
}
.fox-ask-q::after { content: ''; position: absolute; right: 26px; top: 100%; border: 6px solid transparent; border-top-color: var(--text); }
.fox-replies { order: 1; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.fox-reply {
  position: relative; min-height: 34px; padding: 0 var(--s3); border-radius: 16px 16px 4px 16px;
  background: var(--surface); color: var(--text); border: 1.5px solid var(--cal); box-shadow: 0 2px 8px rgb(0 0 0 / 0.12);
  font: inherit; font-size: 0.8125rem; font-weight: 600; cursor: pointer;
  animation: fox-reply-in 0.3s cubic-bezier(.3, 1.4, .5, 1) both;
}
.fox-reply:nth-child(2) { animation-delay: 0.08s; }
.fox-reply:nth-child(3) { animation-delay: 0.16s; }
.fox-wrap:not(.asking) .fox-reply { animation: none; }
.fox-reply:active { transform: scale(0.95); }
.fox-reply:disabled { opacity: 0.6; }
@keyframes fox-reply-in { from { opacity: 0; transform: translateY(6px) scale(0.85); } }

/* ---------- Today as cards (views/dashboard.js) ---------- */

@media (max-width: 1023px) { .hide-sm { display: none !important; } }
@media (min-width: 1024px) { .show-sm { display: none !important; } }
.dash-main.cards > * + *, .dash-side.cards > * + * { margin-top: var(--s3); }
.hero-card {
  padding: var(--s5) var(--s5) var(--s5);
  background: radial-gradient(90% 100% at 25% 15%, var(--glow), transparent 70%), radial-gradient(50% 60% at 90% 90%, var(--glow-2), transparent 70%), var(--surface);
}
.hero-card .hero-row { justify-content: space-between; align-items: flex-end; gap: var(--s3); }
.hero-card .hero-value { font-size: clamp(3.5rem, 17vw, 5.5rem); margin: var(--s2) 0 var(--s2); }
.hero-card .hero-row .hero-value { margin-bottom: var(--s2); }
.hero-card .meter { margin-top: var(--s4); }
.hero-card .fox { margin: 0 0 0 var(--s2); width: clamp(76px, 21vw, 110px); }
.hero-card .fox-streak { display: none; } /* the streak has its own tile */
.hero-card.no-buddy { text-align: center; }
.tile .meter { margin-top: var(--s1); }
.tile .week-dots { margin-top: var(--s1); gap: 6px; }
.tile .week-dots i { width: 13px; height: 13px; }
.card-empty { padding: var(--s3) 0 var(--s1); font-size: 0.9375rem; }
.card-foot { margin-top: var(--s3); font-size: var(--t-small); color: var(--muted); }
.card .chart { margin-top: var(--s4); }
.card .chart-goal span { background: var(--surface); }
.card-head a { color: var(--muted); }

/* ---------- Food as cards (views/food.js) ---------- */

.text-cal { color: var(--cal); }
@media (max-width: 379px) { .hide-xs { display: none; } }
@media (max-width: 767px) { .ph { margin-bottom: var(--s5); } }
.food-main.cards > * + * { margin-top: var(--s3); }
.week-strip { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.week-strip a {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: var(--s2) 0; border-radius: 16px;
  color: var(--muted); font-size: 0.8125rem; font-weight: 500; transition: background 0.15s, color 0.15s;
}
.week-strip b { color: var(--text); font-size: 1.0625rem; font-weight: 600; }
.week-strip a:hover { background: var(--surface); }
.week-strip a.on { background: var(--text); color: var(--bg); }
.week-strip a.on b { color: var(--bg); }
.food-sum { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s5); padding: var(--s2) var(--s1) var(--s1); }
.food-sum p { color: var(--muted); font-size: 0.9375rem; margin-bottom: var(--s2); }
.food-sum b { font-size: 1.375rem; font-weight: 700; letter-spacing: -0.02em; }
.food-actions { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: var(--s2); }
/* phones: Add food on its own row, Describe and Scan side by side below */
@media (max-width: 599px) {
  .food-actions { grid-template-columns: 1fr 1fr; }
  .food-actions .btn-primary { grid-column: 1 / -1; }
}
.food-actions .btn { gap: var(--s2); }
.meal-card { padding-bottom: var(--s2); }
.entry-row {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3); width: 100%; min-height: 54px;
  padding: var(--s2) 0; background: none; border: 0; border-top: 1px solid var(--line); color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
.card-head + .entry-row { border-top: 0; }
.entry-row:active { opacity: 0.6; }
.entry-name { min-width: 0; font-weight: 500; overflow-wrap: anywhere; }
.entry-name small { display: block; color: var(--muted); font-size: var(--t-label); font-weight: 500; margin-top: 1px; }
.entry-kcal { color: var(--text-2); font-variant-numeric: tabular-nums; font-weight: 600; }
.empty-card { text-align: center; padding: var(--s5); }
/* The entry form inside a sheet: food name full width, numbers side by side, buttons full width. */
.entry-form.in-sheet { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: end; }
.entry-form.in-sheet > :first-child, .entry-form.in-sheet > .btn, .entry-form.in-sheet > .suggest, .entry-form.in-sheet > .portion-row { grid-column: 1 / -1; }
.entry-form.in-sheet .portion-row { grid-row: auto; }
.sheet .quick { margin-top: 0; }
.entry-form.in-sheet > .field:has(select) { grid-column: 1 / -1; }
[data-tab=food] .ph { flex-wrap: nowrap; align-items: center; }

/* ---------- Profile as cards (views/profile.js) ---------- */

.who { display: flex; align-items: center; gap: var(--s4); margin: var(--s2) 0 var(--s6); }
.who h1 { font-size: var(--t-h1); font-weight: 700; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.avatar.avatar-lg { width: 60px; height: 60px; font-size: 1.5rem; flex: none; }
.profile-groups { max-width: 36rem; }
.switch-row.in-card { background: none; border: 0; border-radius: 0; padding: var(--s2) 0; min-height: 56px; }
.switch-row.in-card span { font-weight: 500; }
.delete-profile { display: flex; margin: var(--s6) auto 0; }

/* ---------- Workouts and Calc as cards ---------- */

.plan-card { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); color: var(--text); padding: var(--s4) 18px; transition: border-color 0.15s; }
.plan-card:hover { border-color: var(--line-2); }
.plan-card:active { opacity: 0.7; }
.plan-card .icon { color: var(--faint); flex: none; }
.plan-card-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.plan-card-title { font-weight: 600; font-size: 1.0625rem; display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.plan-card-sub { color: var(--muted); font-size: var(--t-small); }
.day-card .sec-head { margin-bottom: var(--s2); }
.day-card .ex-list li:last-child { border-bottom: 0; }
.day-card .table-wrap { margin: 0 -4px; }
.calc .card { padding: var(--s5) 18px; }
.calc-result.card .figures { border-top: 0; }
.sk.sk-card { border-radius: 22px; margin-top: var(--s3); }
.sk.h-card-lg { height: 196px; }
.sk.h-card-md { height: 170px; }
.sk.h-card-sm { height: 116px; margin-top: 0; }
.sk-pair:has(.sk-card) { margin-top: var(--s3); gap: var(--s3); }
.sk.sk-round { border-radius: 999px; margin-top: var(--s3); }
[data-tab=food] .ph-text { flex: 1 1 auto; } [data-tab=food] .ph-actions { flex: none; width: auto; }

/* ---------- Appearance: palette picker (views/profile.js) ---------- */

.palette-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s2); }
.palette-tile {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: var(--s3) var(--s4) var(--s3);
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px; color: var(--text);
  font: inherit; text-align: left; cursor: pointer; transition: border-color 0.15s, box-shadow 0.15s;
}
.palette-tile:hover { border-color: var(--line-2); }
.palette-tile[aria-checked=true] { border-color: var(--text); box-shadow: 0 0 0 1px var(--text); }
.palette-tile strong { font-size: 0.9375rem; font-weight: 700; margin-top: var(--s2); }
.palette-tile small { color: var(--muted); font-size: var(--t-label); }
.palette-dots { display: flex; gap: 5px; }
.palette-dots i { width: 24px; height: 24px; border-radius: 50%; }
.palette-dots .pd-light, :root[data-theme=light] .palette-dots .pd-dark { display: none; }
:root[data-theme=light] .palette-dots .pd-light { display: block; }
.sheet .group-label { margin-top: var(--s2); }

/* ---------- Appearance tabs and the fox's wardrobe (views/profile.js) ---------- */

.seg { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; padding: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--pill); }
.seg-tab { min-height: 40px; border: 0; border-radius: var(--pill); background: none; color: var(--muted); font: inherit; font-weight: 600; cursor: pointer; transition: background 0.15s, color 0.15s; }
.seg-tab[aria-selected=true] { background: var(--text); color: var(--bg); }
.tab-panel { display: flex; flex-direction: column; gap: var(--s3); }
.buddy-preview { display: flex; flex-direction: column; align-items: center; gap: var(--s2); padding: var(--s3) 0 0; }
.buddy-preview .fox-figure { width: 120px; animation: fox-breathe 4.5s ease-in-out infinite; }
.wardrobe-hint { margin-top: calc(var(--s2) * -1); }
.wardrobe { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s2); }
.wardrobe-item {
  position: relative; display: flex; align-items: center; gap: var(--s3); padding: var(--s3); min-width: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px; color: var(--text); font: inherit; text-align: left;
}
.wardrobe-item.owned { cursor: pointer; transition: border-color 0.15s, box-shadow 0.15s; }
.wardrobe-item.owned:hover { border-color: var(--line-2); }
.wardrobe-item.wearing { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.wardrobe-fox { flex: none; width: 46px; }
.wardrobe-fox .fox-figure { animation: none; }
.wardrobe-item.locked .wardrobe-fox { filter: grayscale(1) brightness(0.55); opacity: 0.6; }
.wardrobe-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.wardrobe-text strong { font-size: 0.9375rem; display: flex; align-items: center; gap: var(--s1); flex-wrap: wrap; }
.wardrobe-text small { color: var(--muted); font-size: var(--t-label); line-height: 1.3; }
.wardrobe-progress { display: flex; align-items: center; gap: var(--s2); margin-top: 2px; }
.wardrobe-progress .meter { flex: 1; }
.wardrobe-lock { position: absolute; top: 8px; right: 10px; font-size: 0.75rem; opacity: 0.7; }
.tag.tag-new { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
@media (max-width: 379px) { .wardrobe { grid-template-columns: 1fr; } }
.admin-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: var(--s2); }
.admin-item { display: flex; align-items: center; gap: var(--s3); padding: var(--s2) var(--s3); border: 1px solid var(--line); border-radius: 14px; }
.admin-item .wardrobe-text { flex: 1; }
.admin-item:not(.owned) .wardrobe-fox { filter: grayscale(1) brightness(0.6); opacity: 0.6; }
.wardrobe-progress .meter, .wardrobe-progress .meter-fill { display: block; }
.wardrobe-item.locked .wardrobe-text { padding-right: 14px; }

/* ---------- Stats picture sheet (views/share-card.js) ---------- */

.share-track {
  display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory; scroll-padding: 0 15%;
  padding: 0 15%; margin: 0 calc(var(--s5) * -1); scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.share-track::-webkit-scrollbar { display: none; }
.share-slide { flex: 0 0 70%; max-width: 300px; scroll-snap-align: center; aspect-ratio: 9 / 16; border-radius: 18px; overflow: hidden; background: var(--surface); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35); }
.share-slide img { display: block; width: 100%; height: 100%; }
.share-placeholder { width: 100%; height: 100%; background: linear-gradient(110deg, var(--surface) 30%, var(--surface-2) 50%, var(--surface) 70%); background-size: 200% 100%; animation: shimmer 1.3s ease-in-out infinite; }
.share-dots { display: flex; justify-content: center; gap: 8px; }
.share-dot { width: 8px; height: 8px; padding: 0; border: 0; border-radius: 50%; background: var(--line-2); cursor: pointer; transition: width 0.2s, background 0.2s; }
.share-dot[aria-selected=true] { width: 22px; border-radius: 8px; background: var(--text); }
.share-caption { text-align: center; color: var(--muted); font-size: var(--t-small); margin-top: calc(var(--s2) * -1); }
.share-actions { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); }
.share-actions .btn { gap: var(--s2); }
.share-actions .loading { grid-column: 1 / -1; }

/* ---------- Home-screen guide (views/install-guide.js) ---------- */

.install-guide { display: flex; flex-direction: column; gap: var(--s3); }
.install-note { margin-top: calc(var(--s1) * -1); }
.install-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s3); }
.install-step { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: var(--s4); display: flex; flex-direction: column; gap: var(--s3); }
.install-step-head { display: flex; gap: var(--s3); align-items: flex-start; }
.install-step-head strong { display: block; font-size: 1rem; }
.install-step-head p { color: var(--muted); font-size: var(--t-small); margin-top: 2px; }
.install-num { flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--cal); color: #1a0b02; font-weight: 800; font-size: 0.875rem; }
.install-shot { display: block; width: min(100%, 260px); height: auto; margin: 0 auto; border-radius: 14px; border: 1px solid var(--line-2); }
.install-shot.wide { width: 100%; }
.install-icon { align-self: center; width: 64px; height: 64px; border-radius: 18px; display: grid; place-items: center; background: var(--surface-2); font-size: 1.75rem; font-weight: 700; }
.setup-body .install-guide { margin-top: var(--s2); }

/* ---------- Support (views/profile.js, views/admin.js) ---------- */

.support-attach { display: flex; }
.support-shot { display: flex; align-items: flex-end; gap: var(--s2); }
.support-shot:empty { display: none; }
.support-shot img { max-width: 140px; max-height: 220px; border-radius: 12px; border: 1px solid var(--line-2); }
.support-done { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--s3); padding: var(--s5) 0 var(--s2); }
.support-done-icon { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); font-size: 1.6rem; font-weight: 800; }
.support-done .btn { align-self: stretch; margin-top: var(--s3); }
.admin-tabs { max-width: 22rem; margin-bottom: var(--s6); }
.ticket { border: 1px solid var(--line); border-radius: 18px; padding: var(--s4); background: var(--surface); }
.ticket + .ticket { margin-top: var(--s3); }
.ticket.closed { opacity: 0.6; }
.ticket-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); margin-bottom: var(--s2); }
.ticket-head strong { font-size: 1rem; }
.ticket-meta { color: var(--muted); font-size: var(--t-small); }
.ticket-msg { white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text-2); }
.ticket-shot { margin-top: var(--s3); }
.ticket-shot img { max-width: min(100%, 360px); border-radius: 12px; border: 1px solid var(--line-2); display: block; }
.ticket-actions { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s3); }

/* ---------- Forecast and the fox's daily question (views/dashboard.js) ---------- */

.forecast { margin-top: var(--s3); font-size: var(--t-small); color: var(--text-2); font-weight: 600; }
.forecast span { color: var(--muted); font-weight: 500; }
.forecast.high { color: var(--cal); }
.question-card { display: flex; flex-direction: column; gap: var(--s3); transition: opacity 0.4s, transform 0.4s; }
.question-card.fade-away { opacity: 0; transform: translateY(-6px); }
.question-head { display: flex; gap: var(--s3); align-items: center; }
.question-head h2 { font-size: 1.0625rem; font-weight: 700; margin-top: 2px; }
.question-fox { font-size: 1.75rem; }
.question-answers { display: flex; flex-wrap: wrap; gap: var(--s2); }
.question-answers .chip { min-height: 40px; padding: 0 var(--s4); font-size: 0.9375rem; }
.question-thanks { color: var(--text-2); }
.personality-grid { display: grid; gap: var(--s2); }
.personality-tile { display: flex; flex-direction: column; gap: 2px; padding: var(--s3) var(--s4); background: var(--surface); border: 1px solid var(--line); border-radius: 16px; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.personality-tile strong { font-size: 0.9375rem; }
.personality-tile small { color: var(--muted); font-size: var(--t-label); }
.personality-tile[aria-checked=true] { border-color: var(--text); box-shadow: 0 0 0 1px var(--text); }
.fox-noticed { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--s2); }
.fox-noticed li { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: var(--s3) var(--s4); color: var(--text-2); }

/* Buddy picker (views/buddy-picker.js): setup and Profile → Buddy */
.buddy-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s2); }
@media (min-width: 768px) { .sheet .buddy-grid, .setup .buddy-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.buddy-tile {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: var(--s3) var(--s2) var(--s3);
  background: var(--surface); border: 1.5px solid var(--line); border-radius: 18px; color: var(--text);
  font: inherit; text-align: center; cursor: pointer; transition: border-color 0.15s, transform 0.15s, background 0.15s;
}
.buddy-tile img { width: 64px; height: auto; margin-bottom: var(--s1); transition: transform 0.25s cubic-bezier(.3, 1.4, .5, 1); }
.buddy-tile strong { font-size: 0.9375rem; }
.buddy-tile small { color: var(--muted); font-size: 0.75rem; line-height: 1.3; }
.buddy-tile:active { transform: scale(0.97); }
.buddy-tile[aria-checked=true] { border-color: var(--cal); background: var(--cal-soft); }
.buddy-tile[aria-checked=true] img { transform: scale(1.08) rotate(-3deg); }

/* Describe your food (views/food-describe.js) */
.describe-sheet { display: flex; flex-direction: column; gap: var(--s3); }
.describe-input {
  width: 100%; min-height: 96px; padding: var(--s3); resize: vertical; border-radius: 14px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; font-size: 1rem; line-height: 1.4;
}
.describe-input:focus { outline: none; border-color: var(--cal); }
.describe-sheet .btn { gap: var(--s2); }
.describe-quote { color: var(--text-2); font-style: italic; }
.describe-busy { display: flex; align-items: center; gap: var(--s3); color: var(--text-2); font-weight: 600; }
.describe-busy .spinner { width: 20px; height: 20px; border-radius: 50%; border: 2.5px solid var(--line); border-top-color: var(--cal); animation: describe-spin 0.8s linear infinite; }
@keyframes describe-spin { to { transform: rotate(360deg); } }
.describe-sheet .form-error { color: var(--danger); font-weight: 600; }
.describe-items { display: grid; gap: var(--s2); }
.describe-item { display: grid; gap: 6px; padding: var(--s3); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.describe-item-top { display: flex; align-items: center; gap: var(--s2); }
.describe-name { flex: 1; min-width: 0; background: none; border: 0; border-bottom: 1px dashed var(--line); color: var(--text); font: inherit; font-weight: 700; padding: 2px 0; }
.describe-name:focus { outline: none; border-bottom-color: var(--cal); }
.describe-item-bottom { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }
.describe-stepper { display: inline-flex; align-items: center; gap: 4px; padding: 3px; border: 1px solid var(--line); border-radius: 999px; background: var(--bg); }
.describe-stepper .icon-btn { width: 34px; height: 34px; border-radius: 50%; font-size: 1.25rem; font-weight: 600; line-height: 1; }
.describe-amount { min-width: 76px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.describe-values { font-weight: 700; font-variant-numeric: tabular-nums; }
.describe-source { color: var(--muted); font-size: 0.75rem; }
.describe-total { font-weight: 800; font-size: 1.0625rem; text-align: right; }

/* Impressum and privacy policy (views/legal.js) */
.legal { display: flex; flex-direction: column; gap: var(--s2); color: var(--text-2); line-height: 1.55; }
.legal-h { margin-top: var(--s3); color: var(--text); font-size: 1rem; font-weight: 700; }
.legal-list { margin: 0; padding-left: 1.2em; display: grid; gap: 6px; }
.legal a { color: var(--cal); }

/* Agreeing to the terms (sign-up and views/terms-gate.js) */
.agree { display: flex; align-items: flex-start; gap: var(--s3); color: var(--text-2); font-size: 0.9375rem; line-height: 1.45; cursor: pointer; }
.agree input[type=checkbox] { appearance: auto; -webkit-appearance: checkbox; width: 22px; height: 22px; min-height: 0; padding: 0; margin: 1px 0 0; border-radius: 4px; flex-shrink: 0; accent-color: var(--cal); }
.link-btn.inline { padding: 0; font-size: inherit; color: var(--cal); text-decoration: underline; }
.terms-gate { max-width: 560px; margin: 0 auto; padding: calc(var(--s6) + var(--safe-top)) var(--s5) calc(var(--s7) + var(--safe-bottom)); display: flex; flex-direction: column; gap: var(--s4); }
.terms-gate h1 { font-size: 2rem; letter-spacing: -0.03em; margin-top: var(--s4); }
.terms-gate-form { display: flex; flex-direction: column; gap: var(--s4); margin-top: var(--s3); padding-top: var(--s4); border-top: 1px solid var(--line); }
