/* ============================================================
   LEANPROTOCOL CLIENT APP — iOS DESIGN LANGUAGE
   Inspired by Whoop, Strava patterns. Brand colors intact.
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }

:root {
  /* Base colors (brand-locked) */
  --bg:         #0a1020;
  --bg2:        #131c33;
  --bg3:        #1c2843;
  --surface-1:  #1a253b;
  --surface-2:  #213049;
  --accent:     #22d3ee;
  --accent2:    #0891b2;
  --green:      #10b981;
  --green2:     #34d399;
  --red:        #ef4444;
  --red2:       #f87171;
  --gold:       #f59e0b;
  --purple:     #a78bfa;
  --pink:       #f9a8d4;
  --white:      #f1f5f9;
  --text:       #f1f5f9;
  --text-soft:  #cbd5e1;
  --muted:      #94a3b8;
  --muted-dim:  #7c8aa3;  /* nudged lighter for small-label contrast on the near-black bg */
  --border:     rgba(148,163,184,.14);
  --border-soft:rgba(148,163,184,.08);

  /* Geometry */
  --radius-sm:  10px;
  --radius:     18px;
  --radius-lg:  22px;
  --tab-h:      56px;
  --nav-h:      48px;

  /* Type scale */
  --display:    72px;
  --display-sm: 56px;
  --headline:   28px;
  --title:      18px;
  --body:       15px;
  --caption:    13px;
  --micro:      11px;

  /* Letter spacing */
  --ls-caps:    .14em;
  --ls-tight:   -.02em;
  --ls-display: -.035em;
}

html, body { height: 100%; height: 100dvh; height: var(--app-h, 100dvh); overflow: hidden; }
html { background: var(--bg); }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  background: var(--bg);
  color: var(--white);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv11','ss01';
  /* Native-app feel: no text selection / long-press callout on the UI chrome,
     and no rubber-band scroll chaining past content. Inputs re-enable selection
     in the rule below so typing/editing still works normally. */
  -webkit-user-select: none;
          user-select: none;
  -webkit-touch-callout: none;
  overscroll-behavior: none;
}

/* Re-enable selection + callout where the user actually edits or copies text. */
input, textarea, [contenteditable="true"] {
  -webkit-user-select: text;
          user-select: text;
  -webkit-touch-callout: default;
}

/* iOS active state utility — applied to all tappables */
.btn:active,
.toggle-btn:active,
.nav-action:active,
.tab-item:active,
.history-item:active,
.insight-card:active,
.metric-row:active { transform: scale(.97); }
button, .tappable { transition: transform .12s ease; }

/* ── SCREENS ─────────────────────────────────────────────── */
.screen { display: none; flex-direction: column; height: 100%; height: 100dvh; height: var(--app-h, 100dvh); }
.screen.active { display: flex; }

/* ── TOP NAV (respects iOS safe-area-inset-top, title truly centered) */
.top-nav {
  min-height: calc(var(--nav-h) + env(safe-area-inset-top));
  padding-top: env(safe-area-inset-top);
  background: rgba(10,16,32,.72);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
  position: relative;
  z-index: 20;
}
/* Title is absolutely centered so the gear can't push it off-balance */
.top-nav .nav-title {
  position: absolute;
  top: env(safe-area-inset-top);
  left: 0; right: 0;
  height: var(--nav-h);
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
  text-align: center;
}
.top-nav .nav-action {
  position: absolute;
  top: env(safe-area-inset-top);
  height: var(--nav-h);
  display: flex; align-items: center; justify-content: center;
  z-index: 2;
}
.top-nav .nav-action-left  { left: 8px;  right: auto; }
.top-nav .nav-action-right { right: 8px; left: auto; }
.top-nav .nav-back {
  position: absolute;
  top: env(safe-area-inset-top);
  left: 12px;
  height: var(--nav-h);
  display: flex; align-items: center;
  z-index: 2;
}
.nav-back {
  background: none; border: none; color: var(--accent);
  font-size: 20px; cursor: pointer; padding: 4px 8px 4px 0;
  line-height: 1;
}
.nav-title {
  font-weight: 700; font-size: 13px; flex: 1;
  text-align: center; text-transform: uppercase;
  letter-spacing: var(--ls-caps); color: var(--text-soft);
}
.nav-action {
  background: none; border: none; color: var(--text);
  cursor: pointer;
  width: 44px; height: 44px;                 /* HIG 44pt minimum touch target */
  display: flex; align-items: center; justify-content: center;
}
.nav-action-right { color: var(--accent); }  /* trailing add is the primary action */

/* ── SCROLLABLE CONTENT ──────────────────────────────────── */
.scroll-content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;   /* no rubber-band reveal / scroll chaining */
  padding: 18px 16px calc(var(--tab-h) + env(safe-area-inset-bottom, 20px) + 24px);
  /* Soft iOS-style fade so content melts under the nav AND above the tab bar.
     The bottom fade must complete at the tab-bar's top edge, not the very
     bottom of the scroll box (which sits hidden behind the fixed tab bar). */
  -webkit-mask-image: linear-gradient(to bottom,
    transparent 0, #000 16px,
    #000 calc(100% - var(--tab-h) - env(safe-area-inset-bottom, 20px) - 14px),
    transparent calc(100% - var(--tab-h) - env(safe-area-inset-bottom, 20px)));
          mask-image: linear-gradient(to bottom,
    transparent 0, #000 16px,
    #000 calc(100% - var(--tab-h) - env(safe-area-inset-bottom, 20px) - 14px),
    transparent calc(100% - var(--tab-h) - env(safe-area-inset-bottom, 20px)));
}
.scroll-content.no-tabs { padding-bottom: 24px; }

/* ── TAB BAR (pinned to viewport bottom, glassmorphic) ───── */
.tab-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  /* height = icon row + home-indicator safe area. 20px fallback keeps
     icons off the screen edge even if env() hasn't resolved yet. */
  height: calc(var(--tab-h) + env(safe-area-inset-bottom, 20px));
  background: rgba(10,16,32,.78);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  backdrop-filter: saturate(180%) blur(24px);
  border-top: 1px solid var(--border-soft);
  display: flex;
  padding-bottom: env(safe-area-inset-bottom, 20px);
  z-index: 15;
}
.tab-item {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: flex-end;
  gap: 3px;
  background: none; border: none;
  color: var(--muted-dim);
  font-size: 10px; font-weight: 600;
  cursor: pointer;
  transition: color .2s;
  letter-spacing: .02em;
  padding: 6px 0 4px;
}
.tab-item.active { color: var(--accent); }
.tab-icon { width: 24px; height: 24px; line-height: 0; }
.tab-icon svg { width: 100%; height: 100%; display: block; }
.tab-icon { stroke: currentColor; }

/* ── ONBOARDING ──────────────────────────────────────────── */
#screen-onboard {
  background: var(--bg);
  justify-content: center;
  align-items: center;
}
.onboard-wrap {
  width: 100%; max-width: 420px;
  padding: 32px 24px;
  display: flex; flex-direction: column;
}
.onboard-logo { font-size: 32px; font-weight: 900; letter-spacing: -.02em; margin-bottom: 8px; }
.onboard-logo span { color: var(--accent); }
.onboard-step { display: none; }
.onboard-step.active { display: flex; flex-direction: column; gap: 20px; }
.onboard-title { font-size: 26px; font-weight: 800; line-height: 1.2; letter-spacing: var(--ls-tight); }
.onboard-sub { font-size: 14px; color: var(--muted); line-height: 1.6; }
.install-hero-icon {
  width: 64px; height: 64px; border-radius: 18px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(34,211,238,.10); border: 1px solid rgba(34,211,238,.22);
  color: var(--accent); margin-bottom: 4px;
}
.install-hero-icon svg { width: 32px; height: 32px; }
.step-dots { display: flex; gap: 6px; margin-bottom: 8px; }
.step-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border); transition: background .2s; }
.step-dot.active { background: var(--accent); }

/* ── FORM ELEMENTS ───────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.form-group label {
  font-size: 11px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: var(--ls-caps);
}
.form-group input,
.form-group select,
.form-group textarea {
  background: var(--surface-1);
  border: 1px solid var(--border);
  color: var(--white);
  font-size: 16px;
  padding: 14px 16px;
  border-radius: 14px;
  outline: none;
  width: 100%;
  transition: border-color .2s, background .2s;
  font-family: inherit;
  -webkit-appearance: none;
  appearance: none;
}
.form-group select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%2394a3b8' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 18px center;
  background-size: 12px;
  padding-right: 40px;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: var(--accent); background: var(--surface-2); }
.form-group input::placeholder,
.form-group textarea::placeholder { color: var(--muted-dim); }
.form-group textarea { resize: vertical; min-height: 88px; line-height: 1.5; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.form-hint { font-size: 12px; color: var(--muted); line-height: 1.5; }

/* iOS segmented control */
.toggle-group {
  display: flex;
  background: var(--bg3);
  border-radius: 12px;
  padding: 4px;
  gap: 4px;
  position: relative;
}
.toggle-btn {
  flex: 1;
  padding: 10px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .25s, color .25s, transform .12s;
  letter-spacing: -.01em;
}
.toggle-btn.active {
  background: var(--surface-2);
  color: var(--white);
  box-shadow: 0 1px 0 rgba(0,0,0,.18), 0 1px 4px rgba(0,0,0,.16);
}

/* ── BUTTONS ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; padding: 16px 22px; border-radius: 16px;
  font-weight: 700; font-size: 16px; cursor: pointer; border: none;
  transition: background .2s, transform .12s, border-color .2s;
  width: 100%;
  letter-spacing: -.01em;
}
.btn-primary {
  background: var(--accent); color: #02283a;
  box-shadow: 0 8px 22px -8px rgba(34,211,238,.55);
}
.btn-primary:hover { background: #5be6f5; }
.btn-ghost {
  background: var(--surface-1); color: var(--white);
  border: 1px solid var(--border);
}
.btn-ghost:hover { border-color: var(--accent); }
.btn-green { background: var(--green); color: #03261a; }
.btn-danger {
  background: rgba(239,68,68,.10); color: var(--red2);
  border: 1px solid rgba(239,68,68,.22);
}
.btn-sm { padding: 10px 16px; font-size: 14px; width: auto; }
.btn-whatsapp {
  background: #25D366; color: #fff; width: 100%;
  box-shadow: 0 8px 20px -8px rgba(37,211,102,.55);
}
.btn svg { flex-shrink: 0; }

/* ── CARDS (shared base) ─────────────────────────────────── */
.card {
  background: linear-gradient(180deg, var(--surface-2) 0%, var(--surface-1) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 1px 0 rgba(255,255,255,.02) inset;
}

/* ── COACH CONTACT CARD ──────────────────────────────────── */
.coach-contact-card {
  background: linear-gradient(180deg, var(--surface-2), var(--surface-1));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  text-align: center;
}
.coach-contact-label {
  font-size: 11px; font-weight: 700;
  color: var(--muted); margin-bottom: 14px;
  text-transform: uppercase; letter-spacing: var(--ls-caps);
}

/* ── CHECK-IN LOCKED STATE ───────────────────────────────── */
.checkin-lock-wrap {
  display: flex; flex-direction: column;
  align-items: center; text-align: center;
  padding: 48px 20px 32px;
}
.checkin-lock-icon {
  width: 56px; height: 56px; margin-bottom: 22px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(34,211,238,.08);
  border: 1px solid rgba(34,211,238,.18);
  border-radius: 16px;
  color: var(--accent);
}
.checkin-lock-icon svg { width: 28px; height: 28px; }
.checkin-lock-title { font-size: 22px; font-weight: 800; margin-bottom: 12px; letter-spacing: var(--ls-tight); }
.checkin-lock-sub { font-size: 14px; color: var(--muted); line-height: 1.6; margin-bottom: 28px; max-width: 280px; }

/* ══════════════════════════════════════════════════════════
   DASHBOARD
   ══════════════════════════════════════════════════════════ */

/* Hero header (greeting) */
.dash-header {
  padding: 4px 4px 18px;
  margin-bottom: 4px;
}
.dash-greeting { font-size: 13px; color: var(--muted); font-weight: 500; }
.dash-name {
  font-size: 28px; font-weight: 800;
  letter-spacing: var(--ls-tight); margin-top: 2px;
}
.dash-date {
  font-size: 11px; color: var(--muted-dim); margin-top: 6px;
  text-transform: uppercase; letter-spacing: var(--ls-caps); font-weight: 600;
}

/* ── HERO TRUTH CARD (tracking-focused, tappable for quick weight) */
.hero-truth-card {
  background:
    radial-gradient(120% 80% at 50% -10%, rgba(34,211,238,.10), transparent 60%),
    linear-gradient(180deg, var(--surface-2) 0%, var(--surface-1) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 20px 26px;
  margin-bottom: 18px;
  position: relative;
  overflow: hidden;
  text-align: center;
}
button.hero-truth-card {
  width: 100%;
  color: inherit;
  font: inherit;
  cursor: pointer;
  transition: transform .12s, border-color .2s;
}
button.hero-truth-card:active { transform: scale(.985); }
button.hero-truth-card.hero-empty {
  border-color: rgba(34,211,238,.32);
  box-shadow: 0 0 0 3px rgba(34,211,238,.06);
}
.hero-weight.hero-cta {
  display: inline-flex; align-items: center; gap: 12px;
  font-size: 48px; color: var(--accent);
}
.hero-weight.hero-cta .cta-plus {
  display: inline-flex; align-items: center; justify-content: center;
  width: 52px; height: 52px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  font-weight: 700; line-height: 1;
}
.hero-weight.hero-cta .cta-plus svg { width: 26px; height: 26px; display: block; }

/* Symptom chips (Log tab) */
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  background: var(--surface-1);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 14px; font-weight: 600;
  padding: 10px 14px; border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
  transition: background .15s, border-color .15s, color .15s, transform .12s;
}
.chip:active { transform: scale(.96); }
.chip.active {
  background: rgba(34,211,238,.14);
  border-color: var(--accent);
  color: var(--accent);
}

/* First-run welcome card */
.welcome-card {
  position: relative;
  background: linear-gradient(180deg, rgba(34,211,238,.10), rgba(34,211,238,.03));
  border: 1px solid rgba(34,211,238,.35);
  border-radius: 16px;
  padding: 18px 18px 16px;
  margin-bottom: 16px;
}
.welcome-card-title { font-size: 18px; font-weight: 800; color: var(--white); margin-bottom: 8px; }
.welcome-card-body { font-size: 14px; color: var(--muted); line-height: 1.6; margin-bottom: 14px; }
.welcome-card-body strong { color: var(--accent); font-weight: 700; }
.welcome-card-x {
  position: absolute; top: 6px; right: 6px;
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: none; border: none; color: var(--muted); cursor: pointer;
}
.welcome-card-x svg { width: 16px; height: 16px; }
.hero-day {
  font-size: 12px;
  font-weight: 800;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: var(--ls-caps);
  margin-bottom: 18px;
}
.hero-day-label { opacity: .8; }
.hero-day #hero-day-n { font-size: 14px; }
.hero-weight {
  font-size: 88px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: var(--ls-display);
  color: var(--white);
  margin: 4px 0 8px;
}
.hero-weight .unit {
  font-size: 26px;
  font-weight: 700;
  color: var(--muted);
  margin-left: 4px;
  letter-spacing: -.01em;
}
.hero-weight-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: var(--ls-caps);
  margin-bottom: 16px;
}
.hero-delta {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-soft);
  padding: 10px 16px;
  background: rgba(0,0,0,.18);
  border-radius: 12px;
  display: inline-block;
}
.hero-delta.down { color: var(--green2); }
.hero-delta.up   { color: var(--muted); }

/* Quick weight modal date label */
.quick-weight-date {
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--ls-caps);
  margin-top: -10px;
}
.modal-quick h2 { margin-bottom: 4px; }

/* Legacy classes kept harmless in case templates still reference them */
.hero-ring-card {
  background:
    radial-gradient(120% 80% at 50% -10%, rgba(34,211,238,.10), transparent 60%),
    linear-gradient(180deg, var(--surface-2) 0%, var(--surface-1) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 20px 28px;
  margin-bottom: 18px;
  position: relative;
  overflow: hidden;
}
.hero-ring-wrap {
  position: relative;
  width: 260px; height: 260px;
  margin: 0 auto;
  display: flex; align-items: center; justify-content: center;
}
.hero-ring-wrap svg.ring-svg {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  transform: rotate(-90deg);
}
.hero-ring-wrap .ring-track {
  fill: none;
  stroke: rgba(148,163,184,.16);
  stroke-width: 10;
}
.hero-ring-wrap .ring-progress {
  fill: none;
  stroke: var(--accent);
  stroke-width: 10;
  stroke-linecap: round;
  filter: drop-shadow(0 0 8px rgba(34,211,238,.5));
  transition: stroke-dashoffset 1s cubic-bezier(.25,.8,.25,1);
}
.hero-ring-center {
  position: relative;
  text-align: center;
  z-index: 2;
  padding: 0 30px;
}
.hero-ring-brand {
  font-size: 11px; font-weight: 700; color: var(--accent);
  text-transform: uppercase; letter-spacing: var(--ls-caps);
  margin-bottom: 4px; opacity: .8;
}
.hero-ring-value {
  font-size: var(--display); font-weight: 800;
  letter-spacing: var(--ls-display); line-height: .96;
  color: var(--white);
}
.hero-ring-value .unit { font-size: 28px; font-weight: 700; color: var(--muted); margin-left: 2px; }
.hero-ring-sub {
  font-size: 11px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: var(--ls-caps);
  margin-top: 8px;
}
.hero-ring-segments {
  display: flex; gap: 6px; justify-content: center;
  margin-top: 12px;
}
.ring-seg {
  width: 26px; height: 4px; border-radius: 100px;
  background: var(--bg3);
}
.ring-seg.active { background: var(--green); }

/* Hero footer row beneath ring */
.hero-ring-footer {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 18px; padding: 14px 16px;
  background: rgba(0,0,0,.18);
  border-radius: 14px;
}
.hrf-block { text-align: center; flex: 1; }
.hrf-label { font-size: 10px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: var(--ls-caps); }
.hrf-value { font-size: 18px; font-weight: 800; margin-top: 4px; letter-spacing: var(--ls-tight); }
.hrf-value.green { color: var(--green2); }
.hrf-value.red { color: var(--red2); }
.hrf-divider { width: 1px; height: 28px; background: var(--border); }

/* ── INSIGHT CARD (Whoop bottom card with thin border + arrow CTA) */
.insight-card {
  background: linear-gradient(180deg, var(--surface-2), var(--surface-1));
  border: 1.5px solid rgba(34,211,238,.30);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 18px;
  cursor: pointer;
}
.insight-card.green-border { border-color: rgba(16,185,129,.34); }
.insight-card.amber-border { border-color: rgba(245,158,11,.32); }
.insight-text {
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-soft);
}
.insight-text strong { color: var(--white); font-weight: 700; }
.insight-cta {
  font-size: 11px; font-weight: 800; letter-spacing: var(--ls-caps);
  color: var(--accent); margin-top: 12px;
  display: inline-flex; align-items: center; gap: 6px;
  text-transform: uppercase;
}
.insight-cta:after { content: "→"; font-size: 14px; }

/* ── METRIC LIST (Whoop "Hours vs Needed" rows) ─────────── */
/* Separate cards with the same 10px gap as the History list (not a grouped block) */
.metric-list {
  display: flex; flex-direction: column; gap: 10px;
  margin-bottom: 18px;
}
.metric-row {
  display: flex; align-items: center;
  padding: 15px 16px;
  gap: 12px;
  background: linear-gradient(180deg, var(--surface-2), var(--surface-1));
  border: 1px solid var(--border);
  border-radius: 14px;
  cursor: default;
}
.metric-icon {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted);
  flex-shrink: 0;
  background: rgba(148,163,184,.08);
  border-radius: 10px;
}
.metric-icon svg { width: 18px; height: 18px; stroke: currentColor; fill: none; }
.nav-action svg { width: 22px; height: 22px; stroke: currentColor; fill: none; }
.metric-label {
  font-size: 11px; font-weight: 700; color: var(--text-soft);
  text-transform: uppercase; letter-spacing: .07em;
  flex: 1 1 auto;
  min-width: 0;
  line-height: 1.25;
}
.metric-bar-wrap {
  flex: 0 0 56px; display: flex; align-items: center;
  gap: 3px;
}
.metric-seg {
  flex: 1; height: 6px; background: var(--bg3); border-radius: 100px;
}
.metric-seg.fill-poor { background: var(--gold); }
.metric-seg.fill-ok { background: var(--muted); }
.metric-seg.fill-good { background: var(--green); }
.metric-seg.fill-bad { background: var(--red); }
.metric-value {
  font-size: 20px; font-weight: 800; letter-spacing: var(--ls-tight);
  text-align: right; flex: 0 0 auto; white-space: nowrap;
  padding-left: 6px;
}
.metric-value .small { font-size: 13px; color: var(--muted); font-weight: 600; margin-left: 2px; }
.metric-delta {
  font-size: 12px; font-weight: 700; margin-left: 6px;
}
.metric-delta.up { color: var(--green2); }
.metric-delta.down { color: var(--red2); }

/* ── DASHBOARD CHART CARD ────────────────────────────────── */
.chart-card {
  background: linear-gradient(180deg, var(--surface-2), var(--surface-1));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 18px;
}
.chart-card .chart-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px;
}
.chart-card h3 {
  font-size: 12px; font-weight: 700; color: var(--text-soft);
  text-transform: uppercase; letter-spacing: var(--ls-caps);
}
.chart-card .chart-hero {
  font-size: 36px; font-weight: 800; letter-spacing: var(--ls-display);
  line-height: 1; margin-top: 6px;
}
.chart-card .chart-hero .unit { font-size: 14px; color: var(--muted); margin-left: 4px; font-weight: 600; }
.chart-card .chart-delta {
  font-size: 12px; font-weight: 700; color: var(--muted);
  margin-top: 6px;
}
.chart-card .chart-delta.up { color: var(--green2); }
.chart-card .chart-delta.down { color: var(--muted); }
/* Fixed-height wrapper constrains the Chart.js canvas (maintainAspectRatio:false
   needs a height-bounded parent or the canvas grows without limit). */
.chart-canvas-wrap { position: relative; height: 180px; width: 100%; }
.chart-canvas-wrap canvas { display: block; }

/* ── WEEKLY AVERAGES CARD ────────────────────────────────── */
.week-avg-card {
  background: linear-gradient(180deg, var(--surface-2), var(--surface-1));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 18px;
}
.week-avg-card h3 {
  font-size: 12px; font-weight: 700; color: var(--text-soft);
  text-transform: uppercase; letter-spacing: var(--ls-caps); margin-bottom: 14px;
}
.week-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-soft);
}
.week-row:last-child { border-bottom: none; }
.week-label { font-size: 13px; font-weight: 600; color: var(--text-soft); }
.week-days { font-size: 11px; color: var(--muted-dim); margin-left: 4px; font-weight: 500; }
.week-avg { font-size: 18px; font-weight: 800; letter-spacing: var(--ls-tight); }
.week-delta { font-size: 13px; font-weight: 700; text-align: right; margin-left: 12px; }
.week-delta.loss { color: var(--green2); }
.week-delta.gain { color: var(--muted); }
.week-delta.neutral { color: var(--muted); }

/* ── MACRO CARD (Today's Macros) ─────────────────────────── */
.macro-card {
  background: linear-gradient(180deg, var(--surface-2), var(--surface-1));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 18px;
}
.macro-card .section-head { margin-bottom: 18px; }
.macro-row { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.macro-row:last-child { margin-bottom: 0; }
.macro-label {
  font-size: 11px; font-weight: 700; width: 64px; flex-shrink: 0;
  text-transform: uppercase; letter-spacing: var(--ls-caps); color: var(--text-soft);
}
.macro-bar-wrap {
  flex: 1; height: 16px; background: var(--bg3);
  border-radius: 8px; overflow: hidden;
  position: relative;
}
/* On-track band: 85–115% of target on a 0–140% scale = 60.7%–82.1% of the track.
   Wider + taller than before so it's easy to see and forgiving to land in. */
.macro-bar-wrap::before {
  content: ''; position: absolute; top: 0; bottom: 0;
  left: 60.7%; width: 21.4%;
  background: rgba(16,185,129,.20);
  border-left: 1px dashed rgba(255,255,255,.45);
  border-right: 1px dashed rgba(255,255,255,.45);
  z-index: 0;
}
.macro-bar { position: relative; z-index: 1; height: 100%; border-radius: 8px; transition: width .6s cubic-bezier(.25,.8,.25,1); }
.macro-bar.protein { background: var(--accent); }
.macro-bar.carbs { background: var(--gold); }
.macro-bar.fat { background: var(--purple); }
.macro-bar.cals { background: var(--green); }
.macro-nums {
  font-size: 12px; color: var(--muted); width: 86px;
  text-align: right; flex-shrink: 0; font-weight: 600;
}
.macro-hint {
  font-size: 11px; color: var(--muted); line-height: 1.5;
  margin-top: 16px; padding-top: 14px;
  border-top: 1px solid var(--border-soft);
}

/* (FAB removed — "add a meal" is now the iOS top-bar trailing "+" action) */

.no-data-msg {
  text-align: center; padding: 48px 20px;
  color: var(--muted); font-size: 14px; line-height: 1.6;
}
.no-data-msg .icon {
  width: 56px; height: 56px; margin: 0 auto 16px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(148,163,184,.08);
  border-radius: 16px;
  color: var(--muted);
}
.no-data-msg .icon svg { width: 26px; height: 26px; }

/* ══════════════════════════════════════════════════════════
   INSTALL PROMPT (browser only) + HOW-TO
   ══════════════════════════════════════════════════════════ */
.install-banner {
  display: flex; align-items: center; gap: 12px;
  background: linear-gradient(180deg, rgba(34,211,238,.12), rgba(34,211,238,.05));
  border: 1px solid rgba(34,211,238,.28);
  border-radius: 16px; padding: 12px 12px 12px 14px; margin-bottom: 16px;
}
.install-banner-icon {
  width: 34px; height: 34px; flex-shrink: 0; color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  background: rgba(34,211,238,.12); border-radius: 10px;
}
.install-banner-icon svg { width: 18px; height: 18px; }
.install-banner-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.install-banner-txt strong { font-size: 13px; font-weight: 700; }
.install-banner-txt span { font-size: 11px; color: var(--muted); }
.install-banner-btn {
  background: var(--accent); color: #02283a; border: none;
  font-size: 12px; font-weight: 800; padding: 8px 12px; border-radius: 100px;
  cursor: pointer; flex-shrink: 0; transition: transform .12s;
}
.install-banner-btn:active { transform: scale(.94); }
.install-banner-x {
  background: none; border: none; color: var(--muted-dim);
  font-size: 14px; cursor: pointer; flex-shrink: 0;
  width: 40px; height: 40px; margin-right: -6px;        /* larger touch target */
  display: flex; align-items: center; justify-content: center;
}
.install-os {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 14px; padding: 16px 16px 14px; margin-bottom: 14px;
}
.install-os-title {
  font-size: 13px; font-weight: 800; margin-bottom: 12px;
  display: flex; align-items: center; gap: 8px;
}
.install-os-title span {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: var(--accent); background: rgba(34,211,238,.12);
  padding: 2px 8px; border-radius: 100px;
}
.install-steps { margin: 0; padding-left: 20px; }
.install-steps li { font-size: 13px; color: var(--text-soft); line-height: 1.55; margin-bottom: 8px; }
.install-steps li strong { color: var(--white); }
.install-note { font-size: 11px; color: var(--muted); margin-top: 6px; font-style: italic; }

/* ══════════════════════════════════════════════════════════
   LOG TAB — ALL-DAY FOOD DIARY
   ══════════════════════════════════════════════════════════ */
.log-day-switch {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 16px;
}
.log-day-label { font-size: 20px; font-weight: 800; letter-spacing: var(--ls-tight); }
.log-day-switch input[type="date"] {
  background: var(--surface-1); border: 1px solid var(--border);
  color: var(--text-soft); font-size: 16px; font-family: inherit;
  padding: 8px 12px; border-radius: 10px; outline: none;
  -webkit-appearance: none; appearance: none;
}

/* Running daily totals card */
.daytotal-card {
  background:
    radial-gradient(120% 90% at 50% -10%, rgba(34,211,238,.10), transparent 60%),
    linear-gradient(180deg, var(--surface-2) 0%, var(--surface-1) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 20px 18px;
  margin-bottom: 18px;
}
.dt-cals-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.dt-cals-num { font-size: 44px; font-weight: 800; line-height: 1; letter-spacing: var(--ls-display); }
.dt-cals-target { font-size: 16px; font-weight: 700; color: var(--muted); letter-spacing: -.01em; }
.dt-cals-label {
  font-size: 11px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: var(--ls-caps); margin-top: 6px;
}
.dt-cals-remaining { font-size: 13px; font-weight: 700; color: var(--text-soft); white-space: nowrap; padding-bottom: 4px; }

.dt-cals-bar {
  height: 10px; background: var(--bg3); border-radius: 100px;
  overflow: hidden; margin: 12px 0 16px;
}
.dt-cals-fill { height: 100%; border-radius: 100px; transition: width .5s cubic-bezier(.25,.8,.25,1), background .3s; }
.dt-cals-fill.zone-empty { background: var(--muted-dim); }
.dt-cals-fill.zone-fill  { background: var(--accent); }  /* still building — neutral, not alarming */
.dt-cals-fill.zone-good  { background: var(--green); }   /* landed in the target zone */

.dt-macros { display: flex; gap: 10px; }
.dt-macro {
  flex: 1; background: rgba(0,0,0,.18); border-radius: 14px;
  padding: 12px 8px; text-align: center;
}
.dt-macro-val { font-size: 20px; font-weight: 800; letter-spacing: var(--ls-tight); }
.dt-macro-tgt { font-size: 12px; font-weight: 600; color: var(--muted); margin-left: 2px; }
.dt-macro-lbl {
  font-size: 10px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: var(--ls-caps); margin-top: 4px;
}
.dt-flag {
  margin-top: 14px; padding: 10px 12px;
  background: rgba(245,158,11,.10); border: 1px solid rgba(245,158,11,.24);
  border-radius: 12px; font-size: 12px; color: var(--gold); line-height: 1.5;
}

/* Meal list */
.meal-list { display: flex; flex-direction: column; gap: 10px; }
.meal-empty {
  text-align: center; padding: 22px 18px; color: var(--muted);
  font-size: 13px; line-height: 1.6;
  background: var(--surface-1); border: 1px dashed var(--border);
  border-radius: var(--radius);
}
.meal-empty strong { color: var(--text-soft); }
.meal-row {
  display: flex; align-items: center; gap: 12px;
  background: linear-gradient(180deg, var(--surface-2), var(--surface-1));
  border: 1px solid var(--border); border-radius: 14px;
  padding: 12px 12px 12px 16px;
}
.meal-row-main { flex: 1; min-width: 0; }
.meal-row-title { font-size: 14px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.meal-flag {
  font-size: 9px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase;
  color: var(--gold); background: rgba(245,158,11,.14);
  padding: 2px 7px; border-radius: 100px;
}
.meal-row-sub { font-size: 12px; color: var(--muted); margin-top: 3px; font-weight: 500; }
.meal-row-cals { font-size: 18px; font-weight: 800; letter-spacing: var(--ls-tight); white-space: nowrap; }
.meal-row-cals span { font-size: 11px; color: var(--muted); font-weight: 600; }
/* 44pt tap target (HIG) with the visible circle drawn at 28px via radial-gradient */
.meal-del {
  background: radial-gradient(circle, rgba(148,163,184,.10) 0 14px, transparent 14.5px);
  border: none; color: var(--muted);
  width: 44px; height: 44px; flex-shrink: 0;
  font-size: 13px; cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: transform .12s;
  margin-right: -8px; /* offset the wider target so it doesn't push the row */
}
.meal-del:active { background: radial-gradient(circle, rgba(239,68,68,.22) 0 14px, transparent 14.5px); color: var(--red2); transform: scale(.92); }
.btn-add-meal { color: var(--accent); border-color: rgba(34,211,238,.28); }

/* ══════════════════════════════════════════════════════════
   HISTORY
   ══════════════════════════════════════════════════════════ */
.history-list { display: flex; flex-direction: column; gap: 10px; }
.history-item {
  background: linear-gradient(180deg, var(--surface-2), var(--surface-1));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex; align-items: center; gap: 16px;
  cursor: pointer;
  transition: border-color .2s, transform .12s;
}
.history-item:hover { border-color: rgba(34,211,238,.30); }
.history-date-block {
  text-align: center; flex-shrink: 0; width: 48px;
  background: rgba(0,0,0,.18);
  border-radius: 12px;
  padding: 8px 4px;
}
.history-month {
  font-size: 9px; color: var(--muted); text-transform: uppercase;
  font-weight: 800; letter-spacing: var(--ls-caps);
}
.history-day { font-size: 22px; font-weight: 800; line-height: 1.05; letter-spacing: var(--ls-tight); }
.history-info { flex: 1; min-width: 0; }
.history-weight { font-size: 22px; font-weight: 800; letter-spacing: var(--ls-tight); }
.history-weight .unit { font-size: 13px; color: var(--muted); margin-left: 3px; font-weight: 600; }
.history-macros { font-size: 12px; color: var(--muted); margin-top: 4px; font-weight: 500; }
.history-tags { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.htag {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10px; font-weight: 700; padding: 4px 9px; border-radius: 100px;
  text-transform: uppercase; letter-spacing: .04em;
  white-space: nowrap;
}
.htag svg { width: 11px; height: 11px; flex-shrink: 0; }
.htag-training { background: rgba(34,211,238,.12); color: var(--accent); }
.htag-rest     { background: rgba(148,163,184,.10); color: var(--muted); }
.htag-sleep    { background: rgba(167,139,250,.12); color: #a78bfa; }
.htag-cardio   { background: rgba(245,158,11,.12);  color: #f59e0b; }
.history-chevron { color: var(--muted-dim); font-size: 20px; flex-shrink: 0; }

/* ══════════════════════════════════════════════════════════
   CHECK-IN
   ══════════════════════════════════════════════════════════ */
.checkin-summary {
  background: linear-gradient(180deg, var(--surface-2), var(--surface-1));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 18px;
}
.checkin-summary h3 {
  font-size: 12px; font-weight: 700; color: var(--text-soft);
  margin-bottom: 14px; text-transform: uppercase; letter-spacing: var(--ls-caps);
}
.checkin-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-soft);
}
.checkin-row:last-child { border-bottom: none; }
.checkin-key { font-size: 13px; color: var(--text-soft); font-weight: 500; }
.checkin-val { font-size: 16px; font-weight: 800; letter-spacing: var(--ls-tight); }

/* ══════════════════════════════════════════════════════════
   SETTINGS
   ══════════════════════════════════════════════════════════ */
.settings-section { margin-bottom: 26px; }
.settings-label {
  font-size: 11px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: var(--ls-caps);
  margin-bottom: 10px; padding-left: 4px;
}

/* ══════════════════════════════════════════════════════════
   MODALS
   ══════════════════════════════════════════════════════════ */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(2,8,20,.78);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  z-index: 200;
  align-items: flex-end; justify-content: center;
  padding: 0;
}
.modal-overlay.open { display: flex; }
.modal-confirm { text-align: center; }
.modal-confirm h2 { margin-bottom: 4px; }
.confirm-message { font-size: 14px; color: var(--muted); line-height: 1.6; margin: 10px 0 22px; }
.modal {
  position: relative;
  display: flex; flex-direction: column;
  background: var(--bg2);
  border-top: 1px solid var(--border);
  border-radius: 24px 24px 0 0;
  padding: 18px 20px calc(20px + env(safe-area-inset-bottom, 20px));
  width: 100%; max-width: 520px;
  max-height: 92vh; overflow-y: auto;
}
.modal-handle { width: 40px; height: 5px; background: rgba(148,163,184,.32); border-radius: 3px; margin: 0 auto 18px; }
.modal h2 {
  font-size: 22px; font-weight: 800; margin-bottom: 18px;
  letter-spacing: var(--ls-tight);
}
/* Sticky close: stays pinned to the top-right while the sheet scrolls */
.modal-close {
  position: sticky; top: -2px; order: -1; align-self: flex-end;
  margin: -4px -4px -40px 0;
  z-index: 6;
  background: rgba(33,48,73,.92);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  border: none; color: var(--text-soft); font-size: 17px; cursor: pointer;
  width: 44px; height: 44px; border-radius: 50%;       /* HIG 44pt target */
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  transition: background .15s;
  flex-shrink: 0;
}
.modal-close:active { background: rgba(148,163,184,.28); transform: scale(.94); }
.modal-close svg { width: 18px; height: 18px; }
.install-banner-x svg { width: 15px; height: 15px; }
.meal-del svg { width: 16px; height: 16px; }

/* ── TOAST ───────────────────────────────────────────────── */
#toast {
  position: fixed; bottom: calc(var(--tab-h) + env(safe-area-inset-bottom, 20px) + 18px); left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--white); padding: 12px 22px; border-radius: 100px;
  font-size: 13px; font-weight: 600; z-index: 300;
  transition: opacity .3s, transform .3s; opacity: 0; pointer-events: none; white-space: nowrap;
  box-shadow: 0 10px 30px rgba(0,0,0,.4);
}
#toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

/* ── UTILITIES ───────────────────────────────────────────── */
.tag {
  display: inline-block;
  background: rgba(34,211,238,.12); color: var(--accent);
  font-size: 10px; font-weight: 800; letter-spacing: var(--ls-caps);
  text-transform: uppercase; padding: 4px 14px; border-radius: 100px;
  border: 1px solid rgba(34,211,238,.22);
}
.tag.green { background: rgba(16,185,129,.12); color: var(--green); border-color: rgba(16,185,129,.22); }
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.section-head h3 {
  font-size: 12px; font-weight: 700; color: var(--text-soft);
  text-transform: uppercase; letter-spacing: var(--ls-caps);
}
.section-head a {
  font-size: 12px; color: var(--accent); cursor: pointer;
  font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
}
.section-head a:after { content: " ›"; }

/* Delta arrow utility */
.delta-up:before { content: "▲ "; font-size: 9px; }
.delta-down:before { content: "▼ "; font-size: 9px; }
.green-text { color: var(--green2); }
.red-text { color: var(--red2); }

/* ── REDUCED MOTION (HIG: respect the system setting) ────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
  .btn:active, .toggle-btn:active, .nav-action:active, .tab-item:active,
  .history-item:active, .insight-card:active, .metric-row:active,
  button.hero-truth-card:active, .meal-del:active, .modal-close:active,
  .install-banner-btn:active { transform: none !important; }
}

/* ── Google Sign-In + consent (onboarding / restore) ───────────── */
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 50px; }
.pw-toggle {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  color: var(--muted);
  cursor: pointer;
}
.pw-toggle svg { width: 20px; height: 20px; }

.ob-or {
  display: flex;
  align-items: center;
  text-align: center;
  color: var(--muted-dim);
  font-size: 13px;
  margin: 14px 0;
}
.ob-or::before, .ob-or::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border, #2a3950);
}
.ob-or span { padding: 0 12px; white-space: nowrap; }

.consent-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 14px 2px 4px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
  text-align: left;
  cursor: pointer;
}
.consent-row input[type="checkbox"] {
  width: 20px;
  height: 20px;
  margin: 0;
  flex: 0 0 auto;
  accent-color: var(--accent);
}

/* ── Sign in with Google button ────────────────────────────────── */
.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  background: #ffffff;
  color: #1f2329;
  font-weight: 700;
  border: none;
}
.btn-google:active { background: #f1f3f4; }
.btn-google .g-logo {
  display: inline-block;
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}
