/* =============================================================================
   Baby Tracker — Design System (prototype)
   Author: Jim (UX/design authority). Pairs with DESIGN-DIRECTION.md.
   HTML5 / CSS3 only. Phone-first (390x844); works 375 / 430 / tablet / desktop.
   REV 5 identity: DARK · VIBRANT · MODERN (gradients, rings, floating pill nav).
   Dark-first, single theme. Build markup to the vocabulary in DESIGN-DIRECTION.md §7.
   ============================================================================= */

/* ---------------------------------------------------------------------------
   1. DESIGN TOKENS
   Light is defined on :root. Dark overrides only the color tokens under
   prefers-color-scheme: dark. Every color has a light definition on :root.
   --------------------------------------------------------------------------- */
:root {
  /* ---- Type — bold modern sans; oversized numerals for metrics (Rev 5) ---- */
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: var(--font-sans);   /* same family, heavy weight for big headings */
  --font-num: var(--font-sans);

  /* Fluid type — rem + clamp(); display is OVERSIZED for hero metrics */
  --fs-display: clamp(2.4rem, 1.5rem + 4vw, 3.6rem);   /* big metric / ring number */
  --fs-h1:      clamp(1.6rem, 1.35rem + 1.1vw, 2.05rem);
  --fs-h2:      clamp(1.25rem, 1.12rem + 0.6vw, 1.5rem);
  --fs-title:   clamp(1.05rem, 1rem + 0.25vw, 1.2rem);
  --fs-body: 1rem;
  --fs-sm: 0.875rem;
  --fs-xs: 0.78125rem;
  --lh-tight: 1.04;         /* tight for big numerals */
  --lh-body: 1.5;
  --tracking-eyebrow: 0.06em;
  --fw-regular: 400;
  --fw-medium: 500;
  --fw-semibold: 600;
  --fw-bold: 700;
  --fw-black: 800;

  /* Spacing (4px base) */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-10: 40px; --sp-12: 48px;

  /* Radius — large, modern rounded cards (Rev 5) */
  --r-sm: 10px; --r-md: 14px; --r-lg: 20px; --r-xl: 26px; --r-pill: 999px;

  /* Touch */
  --touch: 44px;
  --touch-lg: 56px;

  /* Elevation — depth + coloured glow on gradient elements (Rev 5) */
  --shadow-1: 0 2px 8px rgba(0,0,0,0.40);
  --shadow-2: 0 12px 30px rgba(0,0,0,0.50);
  --shadow-sheet: 0 -14px 44px rgba(0,0,0,0.62);
  --glow-green: 0 10px 28px rgba(40, 206, 156, 0.38);
  --glow-warm:  0 10px 28px rgba(255, 122, 110, 0.32);

  /* Motion */
  --ease-out: cubic-bezier(0.22, 0.61, 0.36, 1);
  --ease-in-out: cubic-bezier(0.45, 0, 0.2, 1);
  --dur-fast: 120ms;
  --dur: 200ms;
  --dur-slow: 320ms;
  --save-beat: 600ms;

  /* Layout */
  --app-max: 480px;
  --nav-h: 76px;           /* floating pill nav needs a little more room */
  --header-h: 60px;

  /* Dark rounded-tile MOSAIC — hero background texture (Rev 5) */
  --mosaic: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120'><rect width='120' height='120' fill='%230D0E12'/><g fill='none' stroke='%23181A22' stroke-width='1.5'><rect x='4' y='4' width='50' height='34' rx='9'/><rect x='60' y='4' width='56' height='50' rx='9'/><rect x='4' y='44' width='50' height='48' rx='9'/><rect x='60' y='60' width='56' height='32' rx='9'/><rect x='4' y='98' width='72' height='18' rx='8'/><rect x='82' y='98' width='34' height='18' rx='8'/></g><g fill='%23141620'><rect x='60' y='4' width='56' height='50' rx='9'/><rect x='4' y='44' width='50' height='48' rx='9'/></g></svg>");

  /* ---- DARK-FIRST palette (Rev 5) ---- */
  --bg: #0D0E12;           /* near-black canvas */
  --surface: #171921;      /* default card */
  --surface-2: #1F2230;
  --surface-3: #2A2E3D;
  --text: #F5F7FB;
  --text-2: #AEB4C4;       /* AA ~8:1 on surface */
  --text-3: #868DA0;       /* AA ~4.9:1 on surface */
  --border: #262A36;
  --border-strong: #3A3F4F;

  /* Signature = electric green gradient (the + FAB, active states) */
  --primary: #2FD39F;        /* bright mint — icon/text on dark */
  --primary-strong: #5BE3B8;
  --primary-ink: #06241B;    /* dark ink FOR text on green fills/gradients */
  --primary-soft: #123227;   /* dark green tint bg */

  --on-grad-ink: #0B1210;    /* near-black text placed on any bright gradient fill */

  /* Signature accent aliases = the electric green (Rev 5) — used by small brand marks */
  --accent: var(--primary);
  --accent-strong: var(--primary-strong);
  --accent-soft: var(--primary-soft);

  /* Gradient system (signature) */
  --grad-green:  linear-gradient(135deg, #21C99C 0%, #B7E85B 100%);   /* teal → lime (primary) */
  --grad-warm:   linear-gradient(135deg, #FF9A45 0%, #FF5D8F 100%);   /* orange → coral/pink */
  --grad-candy:  linear-gradient(135deg, #C86DD7 0%, #FF6FB5 100%);   /* magenta → pink */
  --grad-cool:   linear-gradient(135deg, #4C86FF 0%, #22D3A6 100%);   /* blue → teal */
  --grad-indigo: linear-gradient(135deg, #7C83FF 0%, #4C86FF 100%);   /* periwinkle → blue */

  /* Data / category colours — vibrant, mutually distinct (+ patterns for colour-blind) */
  --feed: #FF9A45;   --feed-soft: #2A1C10;   --feed-grad: linear-gradient(135deg, #FF9A45, #FF6A6A);
  --sleep: #8A90FF;  --sleep-soft: #191C31;  --sleep-grad: var(--grad-indigo);
  --nappy: #24C7D1;  --nappy-soft: #0E2A2D;  --nappy-grad: linear-gradient(135deg, #24C7D1, #3FE0AE);
  --other: #9AA2B6;  --other-soft: #20242E;

  /* Tiers (3-tier distinction) */
  --tier-pattern: #D98BEA;   /* magenta — calculated pattern (tier 2) */
  --tier-pattern-soft: #241528;
  --tier-guidance: #5AA0FF;  /* blue — general guidance (tier 3) */
  --tier-guidance-soft: #0F2138;
  --tier-guidance-surface: #10182B;

  --danger: #FF6B7A;   --danger-soft: #2C1519;
  --warning: #FFB547;  /* amber — a caution the parent can override (e.g. a >16 h sleep) */
  --success: #2FD39F;

  --focus-ring: 0 0 0 3px rgba(47, 211, 159, 0.55);
  --backdrop: rgba(4, 5, 9, 0.66);
}

/* ---------------------------------------------------------------------------
   2. RESET / BASE
   --------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  color: var(--text);
  background-color: var(--bg);   /* near-black; the tile mosaic is applied to hero zones only */
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, p, figure { margin: 0; }
/* Bold modern sans headings (Rev 5) */
h1, h2, h3 { font-family: var(--font-display); font-weight: var(--fw-bold); letter-spacing: -0.015em; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--primary); text-decoration: none; }
img, svg { max-width: 100%; display: block; }
:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--r-sm); }

/* Tabular figures keep data columns aligned */
.timer, .stat-tile__value, .total-item__value, .insight-card__value,
.timeline-row__time, .milestone__date, .stepper__value,
.glance-item__value, [data-num] { font-variant-numeric: tabular-nums lining; }

/* Oversized, heavy metric numerals (Rev 5 signature) */
.status-card .timer, .stat-tile__value, .insight-card__value, .ring__value {
  font-weight: var(--fw-black); letter-spacing: -0.02em;
}

/* Hero mosaic utility — put the dark rounded-tile texture behind a hero zone */
.hero-mosaic { background-image: var(--mosaic); background-size: 120px 120px; }

/* ---------------------------------------------------------------------------
   3. APP SHELL
   --------------------------------------------------------------------------- */
.app {
  min-height: 100dvh;
  max-width: var(--app-max);
  margin-inline: auto;
  background: var(--bg);
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
  position: relative;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: 0 var(--sp-4);
  padding-top: env(safe-area-inset-top, 0px);
  /* Anti-liquid-glass: solid warm surface + hairline rule, no blur/translucency (Rev 3) */
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.app-header__title { font-family: var(--font-display); font-size: var(--fs-title); font-weight: var(--fw-semibold); display: inline-flex; align-items: center; gap: var(--sp-2); }
/* Signature marigold "hand" — a small hand-set dot before the wordmark */
.app-header__title::before { content: ""; width: 7px; height: 7px; border-radius: var(--r-pill); background: var(--accent); flex: none; }
.app-header__title small { display: block; font-family: var(--font-sans); font-size: var(--fs-xs); color: var(--text-2); font-weight: var(--fw-regular); }
.app-header__avatar {
  width: var(--touch); height: var(--touch); min-width: var(--touch);
  border-radius: var(--r-pill);
  background: var(--primary-soft); color: var(--primary-strong);
  border: 1px solid var(--border);
  display: grid; place-items: center;
  font-weight: var(--fw-semibold);
}

.screen { padding: var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-4); }
.screen__header { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-3); }
.screen__title { font-size: var(--fs-h1); font-weight: var(--fw-bold); letter-spacing: -0.01em; }
.screen__body { display: flex; flex-direction: column; gap: var(--sp-4); }

.divider { height: 1px; background: var(--border); border: 0; margin: var(--sp-2) 0; }
.safe-bottom { padding-bottom: env(safe-area-inset-bottom, 0px); }

/* ---------------------------------------------------------------------------
   4. BOTTOM NAV  (→ becomes left sidebar on desktop, see §14)
   --------------------------------------------------------------------------- */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: var(--app-max);
  height: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  /* Anti-liquid-glass: solid surface + hairline, no blur (Rev 3) */
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 30;
}
.nav-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px;
  min-height: var(--touch);
  background: none; border: 0;
  color: var(--text-3);
  position: relative;
  padding: var(--sp-1);
}
.nav-item__icon { width: 24px; height: 24px; display: grid; place-items: center; }
.nav-item__label { font-size: var(--fs-xs); font-weight: var(--fw-medium); letter-spacing: 0.01em; }
.nav-item.is-active { color: var(--primary); }
.nav-item.is-active .nav-item__label { font-weight: var(--fw-semibold); }
/* Active marker = the signature marigold (Rev 3), icon/label stay evergreen */
.nav-item.is-active::before {
  content: ""; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 26px; height: 3px; border-radius: var(--r-pill); background: var(--accent);
  transition: width var(--dur) var(--ease-out);
}

/* ---------------------------------------------------------------------------
   5. BUTTONS
   --------------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  min-height: var(--touch); padding: 0 var(--sp-5);
  border-radius: var(--r-md); border: 1px solid transparent;
  font-size: var(--fs-body); font-weight: var(--fw-semibold);
  background: var(--surface-2); color: var(--text);
  transition: background .15s ease, transform .05s ease, box-shadow .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--primary); color: var(--primary-ink); }
.btn--primary:hover { background: var(--primary-strong); }
.btn--secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn--ghost { background: transparent; color: var(--primary); }
.btn--danger { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.btn--block { display: flex; width: 100%; }
.btn--lg { min-height: var(--touch-lg); font-size: var(--fs-title); border-radius: var(--r-lg); }

.icon-btn {
  width: var(--touch); height: var(--touch); min-width: var(--touch);
  display: grid; place-items: center;
  border-radius: var(--r-md); border: 0; background: transparent; color: var(--text-2);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* ---------------------------------------------------------------------------
   6. QUICK ACTIONS (Today)
   --------------------------------------------------------------------------- */
.quick-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--sp-3); }
.quick-action {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--sp-2);
  min-height: 84px; padding: var(--sp-3);
  border-radius: var(--r-lg); border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-1);
  transition: transform .05s ease, box-shadow .15s ease;
}
.quick-action:active { transform: translateY(1px); }
.quick-action__icon { width: 28px; height: 28px; display: grid; place-items: center; }
.quick-action__label { font-size: var(--fs-sm); font-weight: var(--fw-semibold); }
.quick-action--feed  .quick-action__icon { color: var(--feed); }
.quick-action--sleep .quick-action__icon { color: var(--sleep); }
.quick-action--nappy .quick-action__icon { color: var(--nappy); }
.quick-action--more  .quick-action__icon { color: var(--other); }
/* Sleep tile transformed into Wake Up when a session is running */
.quick-action--wake {
  background: var(--sleep); color: #fff; border-color: transparent;
  grid-column: span 1;
}
.quick-action--wake .quick-action__icon { color: #fff; }

/* ---------------------------------------------------------------------------
   7. CARDS · STATUS · STAT TILES · TOTALS
   --------------------------------------------------------------------------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-1);
}
.card--pad { padding: var(--sp-4); }

/* Hero status card */
.status-card {
  border-radius: var(--r-xl); padding: var(--sp-5);
  border: 1px solid var(--border); box-shadow: var(--shadow-1);
  display: flex; flex-direction: column; gap: var(--sp-1);
}
.status-card__state { font-size: var(--fs-sm); font-weight: var(--fw-semibold); letter-spacing: var(--tracking-eyebrow); text-transform: uppercase; color: var(--text-2); }
/* Hero duration: serif display (from base), lighter weight lets the serif breathe (Rev 3) */
.timer { font-size: var(--fs-display); font-weight: var(--fw-semibold); line-height: var(--lh-tight); letter-spacing: -0.01em; }
/* Journal-voice caption */
.status-card__meta { font-family: var(--font-display); font-style: italic; font-size: var(--fs-body); color: var(--text-2); }
.status-card--awake { background: var(--surface); }
.status-card--awake .status-card__state { color: var(--primary); }
/* Running-sleep state: unmistakable */
.status-card--sleeping {
  background: var(--sleep-soft);
  border-color: color-mix(in srgb, var(--sleep) 35%, transparent);
}
.status-card--sleeping .status-card__state { color: var(--sleep); }
.status-card--sleeping .timer { color: var(--sleep); }

/* Stat tiles (last feed / sleep / nappy) */
.stat-tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--sp-3) var(--sp-4); box-shadow: var(--shadow-1); }
.stat-tile__label { font-size: var(--fs-xs); font-weight: var(--fw-semibold); text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); }
.stat-tile__value { font-size: var(--fs-h2); font-weight: var(--fw-bold); line-height: var(--lh-tight); margin-top: 2px; }
.stat-tile__meta { font-size: var(--fs-sm); color: var(--text-2); }

/* Today totals — compact, not a dashboard */
.totals { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-2); background: var(--surface-2); border-radius: var(--r-lg); padding: var(--sp-3); }
.total-item { text-align: center; }
.total-item__value { font-size: var(--fs-title); font-weight: var(--fw-bold); font-variant-numeric: tabular-nums; }
.total-item__label { font-size: var(--fs-xs); color: var(--text-2); }

/* ---------------------------------------------------------------------------
   8. TIMELINE (Today + History)
   --------------------------------------------------------------------------- */
.timeline { display: flex; flex-direction: column; }
.timeline-row {
  display: grid; grid-template-columns: 52px 28px 1fr; align-items: center; gap: var(--sp-3);
  min-height: var(--touch); padding: var(--sp-3) var(--sp-2);
  border-bottom: 1px solid var(--border);
  width: 100%; text-align: left; background: none; border-left: 3px solid transparent;
}
.timeline-row:last-child { border-bottom: 0; }
.timeline-row__time { font-size: var(--fs-sm); color: var(--text-2); font-variant-numeric: tabular-nums; }
.timeline-row__icon { width: 28px; height: 28px; border-radius: var(--r-pill); display: grid; place-items: center; background: var(--surface-2); color: var(--other); }
.timeline-row__body { min-width: 0; }
.timeline-row__title { font-size: var(--fs-body); font-weight: var(--fw-medium); }
.timeline-row__meta { font-size: var(--fs-sm); color: var(--text-2); }
/* Subtle per-type differentiation (color-coded, not noisy) */
.timeline-row--feed  { border-left-color: var(--feed); }
.timeline-row--feed  .timeline-row__icon { background: var(--feed-soft); color: var(--feed); }
.timeline-row--sleep { border-left-color: var(--sleep); }
.timeline-row--sleep .timeline-row__icon { background: var(--sleep-soft); color: var(--sleep); }
.timeline-row--nappy { border-left-color: var(--nappy); }
.timeline-row--nappy .timeline-row__icon { background: var(--nappy-soft); color: var(--nappy); }
.timeline-row--other { border-left-color: var(--other); }

/* ---------------------------------------------------------------------------
   9. CHIPS · AMOUNT CHIPS · SEGMENTED · STEPPER · TIME-ADJUST · FIELDS
   --------------------------------------------------------------------------- */
.chip-group { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.chip {
  min-height: var(--touch); padding: 0 var(--sp-4);
  border-radius: var(--r-pill); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font-weight: var(--fw-medium);
  display: inline-flex; align-items: center; gap: var(--sp-2);
}
.chip.is-selected, .amount-chip.is-selected { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }

/* Big amount chips for the fast feed path */
.amount-chip {
  min-height: var(--touch-lg); min-width: 84px; flex: 1 1 84px;
  border-radius: var(--r-lg); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text);
  font-size: var(--fs-h2); font-weight: var(--fw-bold);
  display: inline-flex; align-items: center; justify-content: center;
}
.amount-chip--recent { min-height: var(--touch); font-size: var(--fs-body); font-weight: var(--fw-semibold); color: var(--text-2); }

/* Segmented control (Wet / Dirty / Both; offered/consumed toggles) */
.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; background: var(--surface-2); border-radius: var(--r-md); }
.segment {
  min-height: var(--touch); border: 0; border-radius: var(--r-sm);
  background: transparent; color: var(--text-2); font-weight: var(--fw-semibold);
}
.segment.is-selected { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }

/* Stepper (ml amounts, partial consumed) */
.stepper { display: inline-flex; align-items: center; gap: var(--sp-2); }
.stepper__btn { width: var(--touch); height: var(--touch); border-radius: var(--r-md); border: 1px solid var(--border-strong); background: var(--surface); font-size: var(--fs-h2); font-weight: var(--fw-bold); }
.stepper__value { min-width: 96px; text-align: center; font-size: var(--fs-h2); font-weight: var(--fw-bold); font-variant-numeric: tabular-nums; }

/* Time adjust — secondary, out of the normal path */
.time-adjust { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.time-adjust .chip { min-height: var(--touch); }

/* Fields */
.field { display: flex; flex-direction: column; gap: var(--sp-1); }
.field__label { font-size: var(--fs-sm); font-weight: var(--fw-semibold); color: var(--text-2); }
.field__input {
  min-height: var(--touch); padding: 0 var(--sp-3);
  border-radius: var(--r-md); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font-size: var(--fs-body);
}
.field__input:focus-visible { border-color: var(--primary); }
.field__hint { font-size: var(--fs-xs); color: var(--text-3); }

/* ---------------------------------------------------------------------------
   10. SHEETS · MODALS · TOASTS · SAVE STATE
   --------------------------------------------------------------------------- */
.sheet-backdrop {
  position: fixed; inset: 0; background: var(--backdrop); z-index: 40;
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  width: 100%; max-width: var(--app-max);
  background: var(--surface); border-radius: var(--r-xl) var(--r-xl) 0 0;
  box-shadow: var(--shadow-sheet);
  padding: var(--sp-3) var(--sp-4) calc(var(--sp-5) + env(safe-area-inset-bottom, 0px));
  display: flex; flex-direction: column; gap: var(--sp-4);
  /* bt-35: FIT the visual viewport (dynamic vh minus insets) — the chrome never
     scrolls; only .sheet__body does, so there is never an outer page scrollbar. */
  max-height: calc(100dvh - env(safe-area-inset-top, 0px) - var(--sp-3));
  overflow: hidden;
  animation: sheet-up .22s ease;
}
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet__handle { flex: none; width: 40px; height: 4px; border-radius: var(--r-pill); background: var(--border-strong); margin: 0 auto var(--sp-1); }
.sheet__header { flex: none; display: flex; align-items: center; justify-content: space-between; }
.sheet__title { font-size: var(--fs-h2); font-weight: var(--fw-bold); }
/* bt-35: body is the ONLY scroll region; min-height:0 lets it shrink inside the flex cap */
.sheet__body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; display: flex; flex-direction: column; gap: var(--sp-4); }
.sheet__footer { flex: none; display: flex; gap: var(--sp-3); }

/* Centered modal — reserved for genuinely destructive confirmation */
.modal {
  position: fixed; inset: 0; z-index: 50; background: var(--backdrop);
  display: grid; place-items: center; padding: var(--sp-5);
}
/* bt-35: cap the card to the viewport; its body scrolls if a confirmation is long */
.modal > .card { max-width: 360px; width: 100%; padding: var(--sp-5); display: flex; flex-direction: column; gap: var(--sp-3); max-height: calc(100dvh - var(--sp-8)); overflow-y: auto; overscroll-behavior: contain; }
.modal__title { font-size: var(--fs-h2); font-weight: var(--fw-bold); }
.modal__body { font-size: var(--fs-body); color: var(--text-2); }
.modal__actions { display: flex; gap: var(--sp-3); margin-top: var(--sp-2); }

/* Toast (Saved · Undo / Deleted · Undo) */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--nav-h) + var(--sp-4) + env(safe-area-inset-bottom, 0px));
  z-index: 60; max-width: calc(var(--app-max) - var(--sp-8));
  display: flex; align-items: center; gap: var(--sp-4);
  padding: var(--sp-3) var(--sp-4); border-radius: var(--r-pill);
  background: var(--text); color: var(--bg); box-shadow: var(--shadow-2);
  font-size: var(--fs-sm); font-weight: var(--fw-medium);
}
.toast--undo .btn { min-height: var(--touch); padding: 0 var(--sp-3); background: transparent; color: var(--bg); text-decoration: underline; font-weight: var(--fw-semibold); }

/* Save status — quiet on success, clear on failure */
.save-status { display: inline-flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-sm); font-weight: var(--fw-medium); }
.save-status__dot { width: 8px; height: 8px; border-radius: var(--r-pill); background: var(--text-3); }
.save-status--saving { color: var(--text-2); }
.save-status--saving .save-status__dot { background: var(--text-3); animation: pulse 1s ease-in-out infinite; }
.save-status--saved { color: var(--success); }
.save-status--saved .save-status__dot { background: var(--success); }
.save-status--error { color: var(--danger); font-weight: var(--fw-semibold); }
.save-status--error .save-status__dot { background: var(--danger); }
@keyframes pulse { 0%,100% { opacity: .4; } 50% { opacity: 1; } }

/* ---------------------------------------------------------------------------
   11. THE 3-TIER SYSTEM  (DESIGN-DIRECTION §3)
   Tier 1 recorded · Tier 2 pattern · Tier 3 guidance — never share styling.
   --------------------------------------------------------------------------- */
.tier-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--fs-xs); font-weight: var(--fw-semibold);
  padding: 3px var(--sp-2); border-radius: var(--r-pill);
  letter-spacing: .02em;
}
.tier-badge::before { content: ""; width: 8px; height: 8px; border-radius: 2px; }
.tier-badge--recorded { background: var(--primary-soft); color: var(--primary-strong); }
.tier-badge--recorded::before { background: var(--primary); border-radius: var(--r-pill); }
.tier-badge--pattern { background: var(--tier-pattern-soft); color: var(--tier-pattern); }
.tier-badge--pattern::before { background: var(--tier-pattern); }
.tier-badge--guidance { background: var(--tier-guidance-soft); color: var(--tier-guidance); }
.tier-badge--guidance::before { background: var(--tier-guidance); border-radius: 50% 50% 50% 0; }

/* Tier 2 — calculated pattern (analytical, cool plum, left accent bar) */
.insight-card {
  background: var(--surface); border: 1px solid var(--border);
  border-left: 4px solid var(--tier-pattern);
  border-radius: var(--r-lg); padding: var(--sp-4);
  box-shadow: var(--shadow-1);
  display: flex; flex-direction: column; gap: var(--sp-2);
}
.insight-card__label { font-size: var(--fs-sm); color: var(--text-2); font-weight: var(--fw-medium); }
.insight-card__value { font-size: var(--fs-h1); font-weight: var(--fw-bold); font-variant-numeric: tabular-nums; }
.insight-card__body { font-size: var(--fs-body); color: var(--text); }

/* Tier 3 — general guidance (warm editorial parchment; clearly not data) */
.guidance-card {
  background: var(--tier-guidance-surface);
  border: 1px solid color-mix(in srgb, var(--tier-guidance) 30%, transparent);
  border-radius: var(--r-lg); padding: var(--sp-4);
  display: flex; flex-direction: column; gap: var(--sp-2);
}
.guidance-card__eyebrow { font-size: var(--fs-xs); font-weight: var(--fw-semibold); text-transform: uppercase; letter-spacing: .05em; color: var(--tier-guidance); }
.guidance-card__title { font-size: var(--fs-title); font-weight: var(--fw-semibold); }
.guidance-card__note { font-size: var(--fs-sm); color: var(--text-2); font-style: italic; }

/* ---------------------------------------------------------------------------
   12. GROWTH CHART
   --------------------------------------------------------------------------- */
.metric-tabs { display: inline-flex; gap: 4px; padding: 4px; background: var(--surface-2); border-radius: var(--r-md); }
.metric-tab { min-height: var(--touch); padding: 0 var(--sp-4); border: 0; border-radius: var(--r-sm); background: transparent; color: var(--text-2); font-weight: var(--fw-semibold); }
.metric-tab.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }

.chart {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: var(--sp-4); box-shadow: var(--shadow-1);
  display: flex; flex-direction: column; gap: var(--sp-3);
}
.chart__scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.chart__canvas { min-width: 320px; width: 100%; height: 240px; display: block; }

.chart-legend { display: flex; flex-wrap: wrap; gap: var(--sp-3); font-size: var(--fs-sm); color: var(--text-2); }
.legend-item { display: inline-flex; align-items: center; gap: var(--sp-2); }
.legend-item__swatch { width: 22px; height: 0; border-top-width: 3px; border-top-style: solid; }
.legend-item--measured .legend-item__swatch { border-top-color: var(--primary); border-top-width: 4px; }
.legend-item--reference .legend-item__swatch { border-top-color: var(--text-3); border-top-style: dashed; }
.legend-item--band .legend-item__swatch { height: 12px; border-top: 0; border-radius: 3px; background: var(--primary-soft); }

/* Plain-language readout — percentile as position, never a score */
.chart-readout { display: flex; flex-direction: column; gap: var(--sp-1); }
.trajectory-chip {
  align-self: flex-start;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px var(--sp-3); border-radius: var(--r-pill);
  background: var(--primary-soft); color: var(--primary-strong);
  font-size: var(--fs-sm); font-weight: var(--fw-semibold);
}
.percentile-note { font-size: var(--fs-sm); color: var(--text-2); }

/* ---------------------------------------------------------------------------
   13. DEVELOPMENT / MILESTONES
   --------------------------------------------------------------------------- */
.guidance-section { display: flex; flex-direction: column; gap: var(--sp-3); }
.guidance-area { display: flex; flex-direction: column; gap: var(--sp-2); }

.milestone {
  display: grid; grid-template-columns: 28px 1fr auto; align-items: center; gap: var(--sp-3);
  min-height: var(--touch); padding: var(--sp-2) 0;
  border-bottom: 1px solid var(--border); width: 100%; text-align: left; background: none;
}
.milestone:last-child { border-bottom: 0; }
.milestone__status { width: 24px; height: 24px; border-radius: var(--r-pill); display: grid; place-items: center; border: 2px solid var(--border-strong); }
.milestone__status--done { background: var(--success); border-color: var(--success); color: #fff; }
.milestone__status--notyet { background: transparent; border-color: var(--border-strong); }
.milestone__status--unassessed { border-style: dashed; color: var(--text-3); }
.milestone__label { font-size: var(--fs-body); }
.milestone__date { font-size: var(--fs-sm); color: var(--text-2); font-variant-numeric: tabular-nums; }
.milestone__custom { font-size: var(--fs-xs); color: var(--tier-guidance); font-weight: var(--fw-semibold); }

/* ---------------------------------------------------------------------------
   14. HISTORY DATE-NAV · EMPTY STATE · UTILITIES
   --------------------------------------------------------------------------- */
.date-nav { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.date-nav__btn { min-height: var(--touch); min-width: var(--touch); padding: 0 var(--sp-3); border-radius: var(--r-md); border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font-weight: var(--fw-medium); }
.date-nav__label { font-size: var(--fs-title); font-weight: var(--fw-semibold); text-align: center; }

.empty-state {
  text-align: center; padding: var(--sp-10) var(--sp-5);
  display: flex; flex-direction: column; align-items: center; gap: var(--sp-3);
  color: var(--text-2);
}
.empty-state__icon { width: 48px; height: 48px; color: var(--text-3); }
.empty-state__title { font-size: var(--fs-title); font-weight: var(--fw-semibold); color: var(--text); }
.empty-state__hint { font-size: var(--fs-sm); max-width: 32ch; }

.badge { display: inline-flex; align-items: center; padding: 2px var(--sp-2); border-radius: var(--r-pill); font-size: var(--fs-xs); font-weight: var(--fw-semibold); background: var(--surface-2); color: var(--text-2); }
.u-muted { color: var(--text-2); }
.u-center { text-align: center; }
.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; }

/* ---------------------------------------------------------------------------
   15. RESPONSIVE
   Primary 390. Tighten at 375; roomier at 430+; tablet/desktop richer.
   --------------------------------------------------------------------------- */
@media (max-width: 380px) {
  /* --fs-display now scales via clamp(); no fixed override needed here */
  .screen { padding: var(--sp-3); }
  .quick-actions { gap: var(--sp-2); }
  .quick-action { min-height: 76px; }
}

@media (min-width: 431px) and (max-width: 767px) {
  .amount-chip { min-width: 96px; }
}

/* Tablet: two-column content where it helps; wider column */
@media (min-width: 768px) {
  :root { --app-max: 720px; }
  .stat-row, .insights-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); }
  .chart__canvas { height: 300px; }
}

/* Desktop: bottom-nav becomes a left sidebar; content offset & centered */
@media (min-width: 1024px) {
  :root { --app-max: 860px; }
  .app { max-width: none; padding-left: 232px; padding-bottom: var(--sp-6); }
  .app > .screen, .app > .app-header { max-width: var(--app-max); margin-inline: auto; }
  /* The header sits inside the sidebar-offset .app column, so it only needs its
     own gutter here — the 232px offset comes from .app's padding-left. */
  .app > .app-header { padding-left: var(--sp-6); }

  .bottom-nav {
    left: 0; transform: none; top: 0; bottom: 0;
    width: 216px; max-width: none; height: 100dvh;
    grid-template-columns: 1fr; grid-auto-rows: max-content;
    align-content: start; gap: 4px;
    padding: var(--sp-6) var(--sp-3);
    border-top: 0; border-right: 1px solid var(--border);
  }
  .nav-item { flex-direction: row; justify-content: flex-start; gap: var(--sp-3); min-height: var(--touch); padding: 0 var(--sp-3); border-radius: var(--r-md); }
  .nav-item__label { font-size: var(--fs-body); }
  .nav-item.is-active { background: var(--primary-soft); }
  .nav-item.is-active::before { top: 50%; left: 0; transform: translateY(-50%); width: 3px; height: 22px; }
}

/* ---------------------------------------------------------------------------
   16. MOTION PREFERENCE
   --------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

/* ===========================================================================
   17. REV 2 (bt-17) — subtype color tokens (DESIGN-DIRECTION §9)
   Added as a second :root block so the bt-12 tokens above are untouched.
   Bars are non-text graphics (WCAG ≥3:1 vs surface). Milk = base --feed and
   Nap = base --sleep by design, so a single-subtype category reads as its color.
   --------------------------------------------------------------------------- */
:root {
  /* Rev 5 vibrant subtypes — distinct hues WITHIN each single-category chart,
     always paired with the §22 non-colour pattern + a word label (colour-blind safe). */
  --nappy-wet: #24C7D1;      /* cyan  (category base) */
  --nappy-dirty: #FFB03A;    /* amber */
  --nappy-both: #8A90FF;     /* periwinkle */
  --feed-milk: var(--feed);  /* orange (category base) */
  --feed-solids: #B7E85B;    /* lime */
  --sleep-nap: var(--sleep); /* periwinkle (category base) */
  --sleep-night: #4C86FF;    /* blue */
}

/* ---------------------------------------------------------------------------
   18. REV 2 — centered raised + launcher (.nav-fab)
   --------------------------------------------------------------------------- */
.nav-fab {
  align-self: center; justify-self: center;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  width: 60px; height: 60px; margin-top: -18px;
  border: 0; border-radius: var(--r-pill);
  background: var(--primary); color: var(--primary-ink);
  box-shadow: var(--shadow-2);
  transition: transform .05s ease, background .15s ease;
}
.nav-fab:hover { background: var(--primary-strong); }
.nav-fab:active { transform: translateY(1px); }
.nav-fab__icon { font-size: 30px; line-height: 1; font-weight: var(--fw-bold); }
.nav-fab__label { font-size: 10px; font-weight: var(--fw-semibold); letter-spacing: .02em; }

/* ---------------------------------------------------------------------------
   19. REV 2 — Feed sheet: mode toggle, amount wheel, subtype, solids
   --------------------------------------------------------------------------- */
.feed-mode { margin-bottom: var(--sp-1); }
.milk-subtype { max-width: none; }   /* bt-171 L1: full width, like the Milk|Solids toggle */

.consumed-differs { align-self: flex-start; padding-left: 0; padding-right: 0; }
.feed-recents { display: flex; flex-direction: column; gap: var(--sp-1); }

.solids-input, .nappy-note {
  width: 100%; padding: var(--sp-3);
  border-radius: var(--r-md); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: inherit; resize: vertical;
}
.solids-input { min-height: 96px; }
.nappy-note { min-height: 72px; }
.solids-input:focus-visible, .nappy-note:focus-visible { border-color: var(--primary); }
.char-count { display: block; text-align: right; font-size: var(--fs-xs); color: var(--text-3); margin-top: 4px; }

/* bt-47: the post-save nappy note pill (.note-add) is retired — the note is now an
   inline collapsed field inside the nappy sheet before Save. */
.nappy-note-toggle { align-self: flex-start; min-height: var(--touch); padding-left: 0; padding-right: 0; color: var(--text-2); }
.nappy-note-toggle:hover { color: var(--text); }
.nappy-note-wrap { display: flex; flex-direction: column; gap: var(--sp-2); }

/* ---------------------------------------------------------------------------
   20. REV 2 — History controls + category selector + bar charts (tier-1)
   --------------------------------------------------------------------------- */
.history-controls {
  position: sticky; top: var(--header-h); z-index: 15;
  display: flex; flex-direction: column; gap: var(--sp-2);
  padding: var(--sp-2) 0; background: var(--bg);
}
.category-select {
  display: flex; gap: var(--sp-2); overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 2px;
}
.category-chip {
  min-height: var(--touch); padding: 0 var(--sp-4); white-space: nowrap;
  border-radius: var(--r-pill); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font-weight: var(--fw-medium);
  display: inline-flex; align-items: center; gap: 6px;
}
.category-chip::before { content: ""; width: 10px; height: 10px; border-radius: var(--r-pill); background: var(--other); }
.category-chip--feed::before  { background: var(--feed); }
.category-chip--sleep::before { background: var(--sleep); }
.category-chip--nappy::before { background: var(--nappy); }
.category-chip.is-selected { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.category-chip.is-selected::before { background: var(--primary-ink); }

.bar-chart {
  display: flex; flex-direction: column; gap: var(--sp-3);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: var(--sp-4); box-shadow: var(--shadow-1);
}
.bar-chart__scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.bar-chart__plot { display: flex; align-items: flex-end; gap: var(--sp-3); height: 180px; min-width: min-content; }
.bar-chart__bar {
  display: flex; flex-direction: column-reverse; justify-content: flex-start;
  width: 36px; min-width: 36px; height: 100%;
  background: var(--surface-2); border-radius: var(--r-sm); overflow: hidden;
}
.bar-chart__xaxis { display: flex; gap: var(--sp-3); min-width: min-content; }
.bar-chart__daylabel { width: 36px; min-width: 36px; text-align: center; font-size: var(--fs-xs); color: var(--text-2); }
.bar-chart__yaxis { font-size: var(--fs-xs); color: var(--text-3); }
.bar-seg { width: 100%; border-top: 1px solid var(--surface); }
.bar-seg--wet    { background: var(--nappy-wet); }
.bar-seg--dirty  { background: var(--nappy-dirty); }
.bar-seg--both   { background: var(--nappy-both); }
.bar-seg--milk   { background: var(--feed-milk); }
.bar-seg--solids { background: var(--feed-solids); }
.bar-seg--nap    { background: var(--sleep-nap); }
.bar-seg--night  { background: var(--sleep-night); }

/* Subtype legend swatches — filled squares (same tokens as the bars) */
.chart-legend .legend-item--wet .legend-item__swatch,
.chart-legend .legend-item--dirty .legend-item__swatch,
.chart-legend .legend-item--both .legend-item__swatch,
.chart-legend .legend-item--milk .legend-item__swatch,
.chart-legend .legend-item--solids .legend-item__swatch,
.chart-legend .legend-item--nap .legend-item__swatch,
.chart-legend .legend-item--night .legend-item__swatch {
  height: 12px; border-top: 0; border-radius: 3px;
}
.legend-item--wet .legend-item__swatch    { background: var(--nappy-wet); }
.legend-item--dirty .legend-item__swatch  { background: var(--nappy-dirty); }
.legend-item--both .legend-item__swatch   { background: var(--nappy-both); }
.legend-item--milk .legend-item__swatch   { background: var(--feed-milk); }
.legend-item--solids .legend-item__swatch { background: var(--feed-solids); }
.legend-item--nap .legend-item__swatch    { background: var(--sleep-nap); }
.legend-item--night .legend-item__swatch  { background: var(--sleep-night); }

/* ---------------------------------------------------------------------------
   21. REV 2 — desktop: the + becomes a "＋ Log" button atop the sidebar
   --------------------------------------------------------------------------- */
@media (min-width: 1024px) {
  .nav-fab {
    /* bt-54 #1: the sidebar inherits mobile DOM order (Home, History, +Log, Growth,
       Insights). Pull +Log to the top of the grid at desktop only — mobile order is
       untouched because this lives in the ≥1024 block. */
    order: -1;
    flex-direction: row; width: 100%; height: var(--touch-lg);
    margin: 0 0 var(--sp-3) 0; border-radius: var(--r-md); gap: var(--sp-2);
    /* bt-50: own the green-gradient + dark ink here (the mobile §25 gradient is now
       scoped to <1024, so the desktop Log button must carry it itself). */
    background: var(--grad-green); color: var(--on-grad-ink); border: 0;
    align-self: stretch; justify-self: stretch; box-shadow: none;
  }
  .nav-fab:hover { background: var(--grad-green); filter: brightness(1.05); }
  .nav-fab__icon { font-size: 22px; }
  .nav-fab__label { font-size: var(--fs-body); }
}

/* ===========================================================================
   22. REV 3 — VISUAL IDENTITY refinements
   Warm keepsake-journal identity. Anti-liquid-glass (solid surfaces, hairlines),
   purposeful motion (believable saving beat), and M-05: chart subtypes carry a
   NON-COLOUR differentiator (etched pattern) so they never rely on colour alone.
   =========================================================================== */

/* --- Believable saving beat (Rev 3, principle 2) ---------------------------
   JS must hold `.save-status--saving` for at least var(--save-beat) before
   flipping to `--saved`, so the write *feels* like it happened. On success the
   state is quiet and self-clears; on failure it is loud and persistent.
   `.save-status--saved` fades out; `--error` never auto-hides. */
.save-status--saved { animation: save-settle var(--dur-slow) var(--ease-out); }
@keyframes save-settle { from { opacity: 0; transform: translateY(2px); } to { opacity: 1; transform: none; } }

/* --- Buttons: a touch more tactility (crafted, not templated) --------------- */
.btn { transition: background var(--dur) var(--ease-out), transform var(--dur-fast) var(--ease-out), box-shadow var(--dur) var(--ease-out); }
.btn--primary { box-shadow: var(--shadow-1); }
.btn--lg { letter-spacing: 0.005em; }

/* --- Cards: hairline-first depth (shadows already whisper via tokens) ------- */
.card, .stat-tile, .quick-action, .insight-card, .chart, .bar-chart { transition: box-shadow var(--dur) var(--ease-out), transform var(--dur-fast) var(--ease-out); }

/* --- Sheet: gentle, purposeful entrance ------------------------------------ */
.sheet { animation: sheet-up var(--dur-slow) var(--ease-out); }

/* --- M-05: chart subtypes get an etched pattern layered over the colour -----
   Within any one category chart the subtypes differ by BOTH hue and texture,
   so colour-blind readers can still separate them; legend swatches mirror it. */
.bar-seg--dirty,
.bar-seg--night {
  background-image: repeating-linear-gradient(45deg,
    rgba(255,255,255,0.30) 0 3px, transparent 3px 7px);
}
.bar-seg--both {
  background-image:
    repeating-linear-gradient(45deg,  rgba(255,255,255,0.28) 0 2px, transparent 2px 6px),
    repeating-linear-gradient(-45deg, rgba(255,255,255,0.28) 0 2px, transparent 2px 6px);
}
.bar-seg--solids {
  background-image: radial-gradient(rgba(255,255,255,0.42) 1.2px, transparent 1.3px);
  background-size: 7px 7px;
}
/* Legend swatches mirror the pattern so the mapping is teachable */
.legend-item--dirty .legend-item__swatch,
.legend-item--night .legend-item__swatch {
  background-image: repeating-linear-gradient(45deg, rgba(255,255,255,0.35) 0 2px, transparent 2px 5px);
}
.legend-item--both .legend-item__swatch {
  background-image:
    repeating-linear-gradient(45deg,  rgba(255,255,255,0.32) 0 1.5px, transparent 1.5px 4px),
    repeating-linear-gradient(-45deg, rgba(255,255,255,0.32) 0 1.5px, transparent 1.5px 4px);
}
.legend-item--solids .legend-item__swatch {
  background-image: radial-gradient(rgba(255,255,255,0.5) 1px, transparent 1.1px);
  background-size: 5px 5px;
}

/* --- Empty states get a warm, personal voice (serif + accent) -------------- */
.empty-state__title { font-size: var(--fs-h2); }
.empty-state__icon { color: var(--accent); }

/* --- Reduced-motion still shows the state change, just without movement ----- */
@media (prefers-reduced-motion: reduce) {
  .save-status--saved { animation: none; }
  .sheet { animation: none; }
}

/* ===========================================================================
   23. REV 4 — History charts (entry-level, sized, clickable), de-cramped
   controls, and Home merged into History·Today. (Human feedback)
   Design-system CSS; the data model / click wiring / nav array are prototype.js
   (see DESIGN-DIRECTION §11.4). Locked product decisions untouched.
   =========================================================================== */

/* --- Charts: every segment is ONE entry, sized by magnitude, and CLICKABLE -- */
.bar-chart__plot { align-items: flex-end; min-height: 180px; height: auto; }
.bar-chart__bar {
  width: 40px; min-width: 40px; height: auto;   /* JS sets per-entry segment px heights; column grows to fit */
  background: var(--surface-2); border-radius: var(--r-sm); overflow: hidden;
}
.bar-chart__bar--day { width: 88px; min-width: 88px; }   /* Day view = one larger column */

/* .bar-seg is now an interactive <button> that opens the event detail sheet */
.bar-seg {
  display: block; width: 100%; padding: 0; border: 0;
  border-top: 1px solid var(--surface);
  min-height: 16px;                 /* floor so a tiny feed / short nap stays visible + tappable */
  cursor: pointer; color: inherit;
  transition: filter var(--dur-fast) var(--ease-out);
}
.bar-seg:first-child { border-top: 0; }            /* bottom-most (column-reverse) */
.bar-seg:hover { filter: brightness(1.06) saturate(1.04); }
.bar-seg:active { filter: brightness(0.95); }
/* inset ring so focus shows even though the column clips overflow */
.bar-seg:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 2px var(--surface), inset 0 0 0 4px var(--primary);
  position: relative; z-index: 2;
}
.bar-chart__caption { font-size: var(--fs-sm); color: var(--text-2); text-align: center; }

/* --- De-cramped controls -------------------------------------------------- */
/* View toggle (List | Charts) lives in the screen header, beside the title */
.screen__header { align-items: center; }
.view-toggle {
  display: inline-flex; gap: 2px; padding: 3px;
  background: var(--surface-2); border-radius: var(--r-md);
}
.view-toggle__btn {
  min-height: var(--touch); min-width: 46px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 0 var(--sp-3); border: 0; border-radius: var(--r-sm);
  background: transparent; color: var(--text-2);
  font-size: var(--fs-sm); font-weight: var(--fw-semibold);
}
.view-toggle__btn.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }
.view-toggle__btn svg, .view-toggle__btn .nav-item__icon { width: 20px; height: 20px; }

/* Day/Week and Category are each a full-width segmented on their own line —
   no side-by-side cramming, no horizontally-scrolling chip row */
.history-controls { gap: var(--sp-3); }
.history-controls .segmented { width: 100%; }

/* --- Home merged into History·Today: the live status block sits on top ------ */
.history-today-hero { display: flex; flex-direction: column; gap: var(--sp-4); }
.history-today-hero + * { margin-top: var(--sp-2); }

@media (min-width: 768px) {
  .bar-chart__bar { width: 52px; min-width: 52px; }
}

/* ===========================================================================
   24. BT-21 — HOME = family hub: baby hero · glance strip · message board ·
   appointments. All MOCKED in the prototype. Rev 3 keepsake aesthetic.
   (Design + component CSS; Andy builds index.html/prototype.js.)
   =========================================================================== */
.home-hub { display: flex; flex-direction: column; gap: var(--sp-5); }
.hub-section { display: flex; flex-direction: column; gap: var(--sp-3); }
.hub-section__head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
.hub-section__title { font-family: var(--font-display); font-size: var(--fs-h2); font-weight: var(--fw-semibold); }

/* ① Baby hero — the keepsake heart (photo is the ONE Phase-2 exception) */
.baby-hero {
  display: flex; flex-direction: column; align-items: center; gap: var(--sp-2);
  padding: var(--sp-6) var(--sp-4) var(--sp-5);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-xl); box-shadow: var(--shadow-1); text-align: center;
}
.baby-hero__photo {
  width: 116px; height: 116px; border-radius: var(--r-pill); object-fit: cover;
  border: 3px solid var(--surface); box-shadow: var(--shadow-2); background: var(--surface-2);
}
.baby-hero__name { font-family: var(--font-display); font-size: var(--fs-h1); font-weight: var(--fw-semibold); }
.baby-hero__meta { font-family: var(--font-display); font-style: italic; font-size: var(--fs-body); color: var(--text-2); }
.baby-hero__meta::after { /* marigold hand-mark */ content: ""; display: block; width: 40px; height: 3px; border-radius: var(--r-pill); background: var(--accent); margin: var(--sp-3) auto 0; }

/* ② Today-at-a-glance strip — compact daily status, taps through to History */
.glance-strip {
  display: flex; align-items: center; flex-wrap: wrap; gap: var(--sp-1);
  width: 100%; text-align: left; cursor: pointer;
  padding: var(--sp-3) var(--sp-2);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-1);
}
.glance-item { display: flex; align-items: baseline; gap: 6px; padding: 0 var(--sp-3); position: relative; }
.glance-item + .glance-item::before { content: ""; position: absolute; left: 0; top: 50%; transform: translateY(-50%); width: 1px; height: 60%; background: var(--border); }
.glance-item__value { font-weight: var(--fw-semibold); font-variant-numeric: tabular-nums lining; }
.glance-item__label { font-size: var(--fs-xs); color: var(--text-3); text-transform: uppercase; letter-spacing: var(--tracking-eyebrow); }
.glance-item--status .glance-item__value { color: var(--primary); }
.glance-strip.is-sleeping .glance-item--status .glance-item__value { color: var(--sleep); }
/* bt-146: single-category glance — segmented toggle + focused-category tint */
.glance-toggle { margin-bottom: var(--sp-2); }
.glance-item__icon { margin-right: 4px; }
.glance-strip .glance-item--sleep .glance-item__value { color: var(--sleep); }
.glance-strip .glance-item--feed  .glance-item__value { color: var(--feed); }
.glance-strip .glance-item--nappy .glance-item__value { color: var(--nappy); }

/* ③ Parent message board — "Between us" (mocked thread + compose + notify) */
.msg-board {
  display: flex; flex-direction: column; gap: var(--sp-3);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: var(--sp-4); box-shadow: var(--shadow-1);
}
.msg-thread { display: flex; flex-direction: column; gap: var(--sp-2); }
.msg { max-width: 82%; padding: var(--sp-2) var(--sp-3); border-radius: var(--r-lg); }
.msg__meta { font-size: var(--fs-xs); color: var(--text-3); margin-bottom: 2px; }
.msg__text { font-size: var(--fs-body); }
.msg--theirs { align-self: flex-start; background: var(--surface-2); border-bottom-left-radius: var(--r-sm); }
.msg--mine { align-self: flex-end; background: var(--primary-soft); border-bottom-right-radius: var(--r-sm); }
.msg--mine .msg__meta { text-align: right; }
.msg-compose { display: flex; align-items: center; gap: var(--sp-2); }
.msg-compose__input {
  flex: 1; min-width: 0; min-height: var(--touch); padding: 0 var(--sp-4);
  border-radius: var(--r-pill); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: inherit;
}
.msg-compose__input:focus-visible { border-color: var(--primary); }
.msg-compose__notify {
  width: var(--touch); height: var(--touch); min-width: var(--touch);
  display: grid; place-items: center; border-radius: var(--r-pill);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2);
}
.msg-compose__notify[aria-pressed="true"] {
  background: var(--accent-soft); color: var(--accent-strong);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
}
.msg-compose__send { min-height: var(--touch); }   /* compose with .btn .btn--primary */

/* ④ Calendar / appointments — "Coming up" (calm, list-first, mocked) */
.appointments { display: flex; flex-direction: column; gap: var(--sp-2); }
.appt {
  display: grid; grid-template-columns: 48px 1fr auto; align-items: center; gap: var(--sp-3);
  width: 100%; text-align: left; min-height: var(--touch);
  padding: var(--sp-2) var(--sp-3); border-radius: var(--r-md);
  border: 1px solid var(--border); background: var(--surface);
}
.appt__date {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: 48px; height: 48px; border-radius: var(--r-md);
  background: var(--primary-soft); color: var(--primary-strong);
}
.appt__day { font-family: var(--font-display); font-size: var(--fs-title); font-weight: var(--fw-bold); line-height: 1; }
.appt__mon { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.06em; }
.appt__title { font-weight: var(--fw-medium); }
.appt__meta { font-size: var(--fs-sm); color: var(--text-2); }
.appt-add { align-self: flex-start; }   /* .btn .btn--ghost */

/* ===========================================================================
   25. REV 5 — dark/vibrant/modern re-skin (matches CleanModern.JPG).
   Overrides earlier component styling; structural classes/vocab unchanged so
   Andy's markup still maps. Dark canvas · gradient accents · large rounded
   cards · floating pill nav with green-gradient + FAB · rings · gradient chips.
   AA kept (dark ink on bright gradients; light text on dark surfaces).
   =========================================================================== */

/* Header — large bold title, no rule/dot */
.app-header { background: var(--bg); border-bottom: 0; }
.app-header__title { font-size: var(--fs-h1); font-weight: var(--fw-black); letter-spacing: -0.02em; }
.app-header__title::before { display: none; }
.app-header__title small { color: var(--text-2); }
.app-header__avatar { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.screen__title { font-weight: var(--fw-black); letter-spacing: -0.02em; }

/* Buttons — primary = green gradient with dark ink + glow */
.btn { background: var(--surface-2); color: var(--text); }
.btn--primary { background: var(--grad-green); color: var(--on-grad-ink); border: 0; box-shadow: var(--glow-green); }
.btn--primary:hover { background: var(--grad-green); filter: brightness(1.05); }
.btn--secondary { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
.btn--ghost { background: transparent; color: var(--primary); }

/* Cards — soft depth; large radius cascades from tokens. Gradient card variants. */
.card--grad-green { background: var(--grad-green); color: var(--on-grad-ink); border: 0; box-shadow: var(--glow-green); }
.card--grad-warm  { background: var(--grad-warm);  color: var(--on-grad-ink); border: 0; box-shadow: var(--glow-warm); }
.card--grad-candy { background: var(--grad-candy); color: var(--on-grad-ink); border: 0; }
.card--grad-cool  { background: var(--grad-cool);  color: var(--on-grad-ink); border: 0; }
[class*="card--grad"] .stat-tile__label,
[class*="card--grad"] .stat-tile__meta,
[class*="card--grad"] .u-muted { color: rgba(11,18,16,0.72); }

/* Floating pill bottom nav + green-gradient raised FAB (the reference nav).
   bt-50: these Rev-5 mobile-pill rules are now MOBILE-ONLY (<1024px). Previously
   unscoped, they sat after the ≥1024 sidebar block and re-painted the desktop nav
   as a centred pill (overlapping content), hid the active marker, and reverted the
   FAB to a circle. Scoping them here lets the §14/§21 sidebar rules win at ≥1024. */
@media (max-width: 1023px) {
  .bottom-nav {
    left: 50%; transform: translateX(-50%);
    bottom: calc(env(safe-area-inset-bottom, 0px) + var(--sp-3));
    width: min(var(--app-max), calc(100% - var(--sp-6)));
    height: 64px; padding: 0 var(--sp-2);
    background: var(--surface-2); border: 1px solid var(--border);
    border-radius: var(--r-pill); box-shadow: var(--shadow-2);
    align-items: center;
  }
  .nav-item { color: var(--text-3); gap: 2px; }
  .nav-item.is-active { color: var(--primary); }
  .nav-item.is-active::before { display: none; }
  .nav-item.is-active .nav-item__icon { filter: drop-shadow(0 0 8px rgba(47,211,159,0.55)); }
  .nav-fab {
    width: 60px; height: 60px; margin-top: -22px;
    background: var(--grad-green); color: var(--on-grad-ink);
    border: 3px solid var(--bg); box-shadow: var(--glow-green);
  }
  .nav-fab:hover { background: var(--grad-green); filter: brightness(1.05); }
}

/* Quick actions — glossy gradient tiles per category (dark ink on the bright fills) */
.quick-action { background: var(--surface); border-color: var(--border); }
.quick-action--feed  { background: var(--feed-grad);  border: 0; }
.quick-action--sleep { background: var(--sleep-grad); border: 0; }
.quick-action--nappy { background: var(--nappy-grad); border: 0; }
.quick-action--wake  { background: var(--sleep-grad); border: 0; }
.quick-action--more  { background: var(--surface-2); border-color: var(--border); }
.quick-action--feed, .quick-action--sleep, .quick-action--nappy, .quick-action--wake { color: var(--on-grad-ink); box-shadow: var(--shadow-1); }
.quick-action--feed  .quick-action__icon, .quick-action--sleep .quick-action__icon,
.quick-action--nappy .quick-action__icon, .quick-action--wake  .quick-action__icon,
.quick-action--feed  .quick-action__label, .quick-action--sleep .quick-action__label,
.quick-action--nappy .quick-action__label, .quick-action--wake  .quick-action__label { color: var(--on-grad-ink); }

/* Status hero */
.status-card--awake .status-card__state { color: var(--primary); }
.status-card--sleeping { background: var(--sleep-soft); border-color: color-mix(in srgb, var(--sleep) 45%, transparent); }
.status-card--sleeping .status-card__state, .status-card--sleeping .timer { color: var(--sleep); }
.status-card__meta { font-family: var(--font-sans); font-style: normal; }

/* Ring — circular gradient progress for NEUTRAL metrics ONLY (non-diagnostic;
   never a "score" for the baby). Set --pct (0–100) inline. */
.ring__wrap { display: flex; flex-direction: column; align-items: center; gap: var(--sp-2); }
.ring {
  --pct: 60; position: relative; width: 132px; height: 132px; border-radius: 50%;
  background: conic-gradient(from -90deg, #21C99C 0%, #B7E85B calc(var(--pct) * 1%), var(--surface-2) 0);
  display: grid; place-items: center;
}
.ring::before { content: ""; position: absolute; inset: 13px; border-radius: 50%; background: var(--surface); }
.ring__value { position: relative; font-size: var(--fs-h1); font-weight: var(--fw-black); }
.ring__label { position: relative; font-size: var(--fs-xs); color: var(--text-2); }

/* Day chips (Su–Sa week strip) — gradient active pill */
.day-chips { display: grid; grid-template-columns: repeat(7, 1fr); gap: var(--sp-1); }
.day-chip {
  min-height: var(--touch); display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; border: 0; background: transparent; color: var(--text-2); border-radius: var(--r-md);
}
.day-chip__dow { font-size: var(--fs-xs); color: var(--text-3); }
.day-chip__num { font-size: var(--fs-body); font-weight: var(--fw-bold); font-variant-numeric: tabular-nums; }
.day-chip.is-active { background: var(--grad-green); color: var(--on-grad-ink); box-shadow: var(--glow-green); }
.day-chip.is-active .day-chip__dow { color: rgba(11,18,16,0.7); }

/* Segmented / toggles / chips — dark track, gradient active */
.segment.is-selected,
.view-toggle__btn.is-active,
.metric-tab.is-active,
.chip.is-selected,
.amount-chip.is-selected,
.category-chip.is-selected { background: var(--grad-green); color: var(--on-grad-ink); border-color: transparent; box-shadow: none; }
.category-chip.is-selected::before { background: var(--on-grad-ink); }

/* Bar charts — dark track; bars use the vibrant subtype tokens + §22 patterns */
.bar-chart__bar { background: var(--surface-2); }

/* Tiers — keep the 3-tier distinction, restyled for dark/vibrant */
.trajectory-chip { background: var(--primary-soft); color: var(--primary-strong); }
.guidance-card { border-color: color-mix(in srgb, var(--tier-guidance) 35%, transparent); }

/* Baby hero — mosaic behind the photo with a scrim so the name stays legible */
.baby-hero {
  background-color: var(--surface); background-image: var(--mosaic); background-size: 120px 120px;
  position: relative; overflow: hidden;
}
.baby-hero::before { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(13,14,18,0.15), var(--surface) 84%); }
.baby-hero > * { position: relative; z-index: 1; }
.baby-hero__photo { border-color: var(--surface-2); }

/* Message board — my bubble uses the dark green tint, light text */
.msg--mine { background: var(--primary-soft); }
.msg--mine .msg__text, .msg--theirs .msg__text { color: var(--text); }
.msg-compose__notify[aria-pressed="true"] {
  background: var(--primary-soft); color: var(--primary);
  border-color: color-mix(in srgb, var(--primary) 45%, transparent);
}

/* Appointment date block reads as a vibrant tag */
.appt__date { background: var(--primary-soft); color: var(--primary-strong); }

/* ===========================================================================
   26. BT-20 — small fixes: timeline subtype dot (M-05) + long-text overflow
   guards (Dwight bt-13 minor). No component redesign; overflow-wrap only.
   =========================================================================== */
.subtype-dot { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 6px; vertical-align: middle; flex: none; }
.timeline-row__title, .timeline-row__meta, .msg__text, .appt__title, .appt__meta { overflow-wrap: anywhere; word-break: break-word; }

/* ===========================================================================
   27. BT-24 — History redesign (§13): 7-day overview + per-day small-multiples.
   Rev-5 tokens; tier-1 recorded (no plum). Andy-owned.
   =========================================================================== */
.day-overview { display: flex; flex-direction: column; gap: var(--sp-2); }
.day-row {
  display: grid; grid-template-columns: 64px 1fr 1fr 1fr; align-items: center; gap: var(--sp-2);
  width: 100%; text-align: left; min-height: var(--touch);
  padding: var(--sp-2) var(--sp-3); border: 1px solid var(--border);
  border-radius: var(--r-md); background: var(--surface); color: var(--text);
}
.day-row:hover { border-color: var(--border-strong); }
.day-row__label { font-weight: var(--fw-semibold); }
.day-stat { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.day-stat__value { font-weight: var(--fw-semibold); font-variant-numeric: tabular-nums lining; display: inline-flex; align-items: center; gap: 5px; }
.day-stat__value::before { content: ""; width: 8px; height: 8px; border-radius: var(--r-pill); flex: none; background: var(--other); }
.day-stat--feed  .day-stat__value::before { background: var(--feed); }
.day-stat--sleep .day-stat__value::before { background: var(--sleep); }
.day-stat--nappy .day-stat__value::before { background: var(--nappy); }
.day-stat__delta { font-size: var(--fs-xs); color: var(--text-3); }
.day-stat__delta.is-up { color: var(--success); }
.day-stat__delta.is-down { color: var(--text-2); }

.daybars { display: flex; flex-direction: column; gap: var(--sp-2); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--sp-4); box-shadow: var(--shadow-1); }
.daybars__caption { font-size: var(--fs-sm); color: var(--text-2); }
.daybars__plot { display: flex; align-items: flex-end; gap: var(--sp-2); height: 130px; }
.daybar { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; padding: 0; border: 0; background: transparent; cursor: pointer; border-radius: var(--r-sm); }
.daybar:focus-visible { box-shadow: var(--focus-ring); }
.daybar:hover .daybar__fill { filter: brightness(1.06); }
.daybar__fill { display: flex; flex-direction: column-reverse; width: 100%; min-height: 10px; border-radius: var(--r-sm) var(--r-sm) 0 0; overflow: hidden; }
.daybar__fill .bar-seg { min-height: 0; }               /* override §23 16px per-entry floor */
.daybar--empty::after { content: "—"; display: block; text-align: center; color: var(--text-3); font-size: var(--fs-sm); }
.daybar--today .daybar__fill { box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 45%, transparent); }
.daybars__xaxis { display: flex; gap: var(--sp-2); }
/* .daybars__xaxis .bar-chart__daylabel sizing is set in §29 (bt-39 no-floor fix) */
.bar-chart__daylabel.is-today { color: var(--primary); font-weight: var(--fw-semibold); }
/* .history-timeline-link + .day-detail retired in bt-34 (folded into .entries-list) */

/* ===========================================================================
   28. BT-24 — Sleep entry (§14): "Still asleep" sentinel + layout. (The times are
   horizontal scrubbers since bt-179 — see section 35.) Andy-owned.
   =========================================================================== */
.sleep-start, .sleep-awake { display: flex; flex-direction: column; gap: var(--sp-2); }
/* bt-178: live read-out of the exact span being saved ("Yesterday 19:00 → Today 05:00 · 10h") */
.sleep-span { margin: 0; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.sleep-span:empty { display: none; }
/* Sleep sheet message line: an error (red) or, for a >16 h sleep, an overridable warning (amber). */
.sleep-msg { color: var(--danger); }
.sleep-msg.is-warning { color: var(--warning); font-weight: var(--fw-semibold); }
.time-wheel__sentinel { width: 100%; min-height: var(--touch); border-radius: var(--r-md); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font-weight: var(--fw-semibold); }
.time-wheel__sentinel.is-selected { background: var(--grad-green); color: var(--on-grad-ink); border-color: transparent; box-shadow: var(--glow-green); }
.is-dim { opacity: .45; transition: opacity var(--dur) var(--ease-out); }

/* ===========================================================================
   29. BT-33 / BT-34 — History: per-ENTRY bar segments (exact hairline seam),
   always-on filterable entries list, and the segment→entry highlight.
   Built to Jim's amended DESIGN-DIRECTION §13.2 / §13.2a / §13.4 / §13.5.
   Andy-owned (css/js/html this pass). =========================================== */

/* Columns are px-driven now (JS floors each entry at 14px), so let them size to
   content and sit on the baseline. The daybar is a role="group" of segment
   buttons; the x-axis day label jumps the list to that day. */
.daybars__plot { height: auto; min-height: 148px; align-items: flex-end; }
.daybar { height: auto; cursor: default; }
.daybar__fill { height: auto; min-height: 0; }

/* §13.2a EXACT divider: a #0D0E12 hairline seam between stacked entries. Border
   (not gap) so total stacked height still equals total magnitude. Sibling combinator
   is DOM-order; earliest is appended first (bottom in column-reverse), so every
   entry except the bottom one gets the seam. Only the visual TOP gets a radius. */
.daybar__fill .bar-seg { border-top: 0; border-radius: 0; }
.daybar__fill .bar-seg + .bar-seg { border-top: 1px solid var(--bg); }
.daybar__fill .bar-seg:last-child { border-radius: var(--r-sm) var(--r-sm) 0 0; }   /* visual top (column-reverse) */
/* Keep the seam legible where a pattern (dirty/night/both/solids) would swallow it */
.daybar__fill .bar-seg--dirty + .bar-seg,
.daybar__fill .bar-seg--night + .bar-seg,
.daybar__fill .bar-seg--both + .bar-seg,
.daybar__fill .bar-seg--solids + .bar-seg,
.daybar__fill .bar-seg + .bar-seg--dirty,
.daybar__fill .bar-seg + .bar-seg--night,
.daybar__fill .bar-seg + .bar-seg--both,
.daybar__fill .bar-seg + .bar-seg--solids {
  box-shadow: inset 0 1px 0 var(--bg), inset 0 2px 0 color-mix(in srgb, #FFFFFF 12%, transparent);  /* whisper bevel under the dark line */
}
.daybar__fill .bar-seg:focus-visible {
  outline: none; box-shadow: inset 0 0 0 2px var(--surface), inset 0 0 0 4px var(--primary);
  position: relative; z-index: 2;
}

/* Chart title + legend swatches double as filter entry points */
.daybars__title { text-align: left; background: transparent; border: 0; color: var(--text); cursor: pointer; padding: 0; }
.daybars__title:hover { color: var(--primary); }
.daybars__title:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--r-sm); }
button.legend-item { background: transparent; border: 0; cursor: pointer; font: inherit; color: var(--text-2); padding: 2px 4px; border-radius: var(--r-sm); }
button.legend-item:hover { color: var(--text); }
button.legend-item:focus-visible { outline: none; box-shadow: var(--focus-ring); }

/* x-axis day label = "jump to this day in the list" button */
.daybars__xaxis .bar-chart__daylabel {
  /* bt-39 #2: drop the 36px width floor so 7 labels never overflow at 320px.
     bt-41: labels are compact ("W19"/"Now") and CENTERED — text-align:center + no
     ellipsis so each renders fully; overflow:hidden stays only as a page-safety guard
     (compact text fits, so it never actually clips). */
  flex: 1 1 0; min-width: 0; width: auto; text-align: center;
  border: 0; background: transparent; color: var(--text-2);
  font-size: var(--fs-xs); padding: var(--sp-1) 1px; min-height: 32px; cursor: pointer; border-radius: var(--r-sm);
  overflow: hidden; white-space: nowrap;
}
.daybars__xaxis .bar-chart__daylabel:hover { color: var(--text); }
.daybars__xaxis .bar-chart__daylabel:focus-visible { outline: none; box-shadow: var(--focus-ring); }
/* keep bars + labels aligned and inside 320px: same responsive gap on both rows */
.daybars__plot, .daybars__xaxis { gap: clamp(2px, 1.2vw, var(--sp-2)); }
/* bt-41: extra headroom on the narrowest phones so the compact labels never clip */
@media (max-width: 360px) {
  .daybars { padding: var(--sp-3); }
  .daybars__xaxis .bar-chart__daylabel { font-size: 0.72rem; letter-spacing: -0.2px; }
}

/* bt-44: the persistent .entries-list + .list-filter/.filter-chip were removed
   (logs now open in a dismissible sheet). Only the day separator + the highlight
   are reused inside that sheet. */
.entries-list__daysep { font-size: var(--fs-sm); color: var(--text-2); font-weight: var(--fw-semibold); margin: var(--sp-3) 0 var(--sp-1); }

/* §13.5 EXACT selected-entry highlight (in the log sheet, never colour-only): mint
   wash + inset mint ring (shape cue) + leading marker + bold label + aria-current. */
.timeline-row.is-highlighted {
  position: relative;
  background: var(--primary-soft);
  box-shadow: inset 0 0 0 1.5px var(--primary);
  border-radius: var(--r-sm);
  padding-left: 22px;
  scroll-margin: 96px 0;
  transition: background var(--dur) var(--ease-out);
}
.timeline-row.is-highlighted::before {
  content: "▸"; position: absolute; left: 7px; top: 50%; transform: translateY(-50%);
  color: var(--primary); font-weight: var(--fw-bold);
}
.timeline-row.is-highlighted .timeline-row__title { font-weight: var(--fw-bold); }
@media (prefers-reduced-motion: reduce) { .timeline-row.is-highlighted { transition: none; } }

/* ===========================================================================
   30. BT-39 — document scroll lock while any dialog is open (stack-aware).
   JS (openSheet/closeEntry) toggles these on the FIRST open / LAST close and
   restores window.scrollY. position:fixed body also stops iOS background scroll.
   =========================================================================== */
html.scroll-locked-html { overflow: hidden; }
body.scroll-locked { position: fixed; left: 0; right: 0; width: 100%; overflow: hidden; }
.glance-strip__title { font-size: var(--fs-sm); font-weight: var(--fw-semibold); color: var(--text-2); margin-bottom: var(--sp-2); }

/* ===========================================================================
   31. BT-44 / BT-43 §13.4 — dismissible LOG SHEET (built on .sheet).
   =========================================================================== */
.log-sheet__types { position: sticky; top: 0; z-index: 1; background: var(--surface); padding-bottom: var(--sp-2); margin-bottom: 0; }
.log-sheet__types .segmented { width: 100%; }
.log-sheet__content { display: flex; flex-direction: column; }

/* ===========================================================================
   32. BT-45 — Feed sheet (and any wheel sheet) SHRINKS TO FIT short viewports.
   Milk shows an amount wheel (+ an optional 2nd "consumed" wheel) + subtype +
   recents + adjust-time + save; on short phones that forced .sheet__body to
   scroll. Compact the wheel to 3 detents + tighten sheet spacing so the common
   states fit at 360x640 / 320x568; the bt-35 max-height guard stays as fallback.
   =========================================================================== */
@media (max-height: 680px) {
  .sheet__body { gap: var(--sp-3); }
  .sheet { padding-top: var(--sp-2); }
  .field { gap: 2px; }
}

/* ===========================================================================
   33. BT-54 #2 — Milk + Milk-partial (two-wheel) fit at 320×568 AND 360×640
   with NO inner scroll. Beyond §32's 3-detent wheels + §-detent-36 (≤640), the
   two-wheel partial state still overran the shortest phones, so tighten the
   shared sheet chrome and, on the very shortest, drop detents again + hide the
   redundant Recent-amount shortcut (the wheel still sets any value). The 44px
   slider (wheel viewport ≥96px) and the 180 round-trip are unaffected — only
   the visual detent height shrinks, and the wheel JS reads the live detent.
   =========================================================================== */
@media (max-height: 640px) {
  .sheet { gap: var(--sp-2); padding-top: var(--sp-2);
           padding-bottom: calc(var(--sp-3) + env(safe-area-inset-bottom, 0px)); }
  .sheet__handle { margin-bottom: 0; }
  .sheet__body { gap: var(--sp-2); }
  .field { gap: 2px; }
}
@media (max-height: 600px) {
  .feed-recents { display: none; }         /* redundant shortcut — the stepper chips cover it */
}


/* ===========================================================================
   35. BT-179 — horizontal SCRUB control for every time + amount entry (feed,
   nappy, sleep, wake, edit). A ruler scrolls under a fixed centre mark; the value
   and a subtle date ("Yesterday · Wed 24 Sep") sit above it. Left = earlier.
   Replaces the bt-168 steppers + chips and the Today/Yesterday toggles.
   =========================================================================== */
.scrub { position: relative; display: flex; flex-direction: column; gap: var(--sp-1); min-width: 0; }
/* bt-179 amend: the date above a time is tappable — a transparent native date input sits over
   it, so a parent can jump to ANY past day (the ▾ hints at it). */
.scrub__date { position: absolute; top: 0; left: 50%; transform: translateX(-50%); z-index: 1; width: 72%; height: 26px; margin: 0; padding: 0; border: 0; opacity: 0; cursor: pointer; }
.scrub--time .scrub__top { padding: 2px var(--sp-2); border-radius: var(--r-sm); }
.scrub--time .scrub__top::after { content: " ▾"; }
.scrub__date:focus-visible + .scrub__head .scrub__top { box-shadow: var(--focus-ring); color: var(--text); }
/* bt-179 FINAL: a future time is allowed but never silent — the value + date turn amber. */
.scrub.is-future .scrub__main, .scrub.is-future .scrub__top { color: var(--warning); }
/* The feed panel stacks time / milk type / amount / Save with the sheet body's own rhythm. */
.feed-panel { display: flex; flex-direction: column; gap: var(--sp-4); }
.scrub__head { display: flex; flex-direction: column; align-items: center; line-height: 1.15; }
.scrub__top { font-size: var(--fs-xs); color: var(--text-3); letter-spacing: .02em; }
.scrub__top:empty { display: none; }
.scrub__main { font-size: var(--fs-h2); font-weight: var(--fw-bold); font-variant-numeric: tabular-nums; }
.scrub__window { position: relative; border-radius: var(--r-md); }
.scrub__window:has(.scrub__viewport:focus-visible) { box-shadow: var(--focus-ring); }
.scrub__viewport {
  display: flex; height: 48px; overflow-x: auto; overflow-y: hidden;
  border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--border);
  scrollbar-width: none; overscroll-behavior-x: contain; touch-action: pan-x;
  cursor: grab; -webkit-user-select: none; user-select: none; outline: none;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 14%, #000 86%, transparent);
          mask-image: linear-gradient(90deg, transparent, #000 14%, #000 86%, transparent);
}
.scrub__viewport::-webkit-scrollbar { display: none; }
.scrub.is-dragging .scrub__viewport { cursor: grabbing; }
/* Half-width pads let both ends of the ruler reach the centre mark. */
.scrub__pad { flex: 0 0 50%; }
/* Ticks: minor (5 min / 10 ml) + major (hour / 50 ml), aligned by --*-x from JS. */
.scrub__track {
  position: relative; flex: 0 0 auto; height: 100%;
  background-image: linear-gradient(90deg, var(--text-2) 2px, transparent 2px), linear-gradient(90deg, var(--border-strong) 1px, transparent 1px);
  background-size: var(--major-w) 42%, var(--minor-w) 22%;
  background-position: var(--major-x) 100%, var(--minor-x) 100%;
  background-repeat: repeat-x;
}
.scrub__label { position: absolute; top: 4px; transform: translateX(-50%); font-size: var(--fs-xs); color: var(--text-3); font-variant-numeric: tabular-nums; white-space: nowrap; pointer-events: none; }
.scrub__label.is-strong { color: var(--text); font-weight: var(--fw-semibold); }
.scrub__mark { position: absolute; top: 44%; bottom: -3px; left: 50%; width: 3px; margin-left: -1.5px; border-radius: 2px; background: var(--primary); pointer-events: none; }

/* ===========================================================================
   36. BT-150 — self-service account screens (sign-up / login / forgot / reset /
   accept-invite) reuse .screen/.card/.field/.btn. These add the inline text-link
   row under the primary action and the invite-result layout.
   =========================================================================== */
.auth-links { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--sp-2) var(--sp-4); margin-top: var(--sp-3); }
.auth-link { background: none; border: 0; padding: var(--sp-1); color: var(--primary); font: inherit; font-weight: var(--fw-semibold); cursor: pointer; min-height: var(--touch); }
.auth-link:hover { text-decoration: underline; }
.auth-link:focus-visible { box-shadow: var(--focus-ring); border-radius: var(--r-sm); outline: none; }
.invite-result { display: flex; flex-direction: column; gap: var(--sp-2); margin-top: var(--sp-3); }

/* =============================================================================
   bt-159 — entry edit sheet, honest save state, History "earlier days"
   ============================================================================= */
/* The `hidden` attribute must always win over component display rules (the edit
   sheet toggles its Milk/Solids and "Woke up" sections with it). */
[hidden] { display: none !important; }
/* An entry the server hasn't confirmed yet — quiet, but visible (never looks "saved"). */
.badge--pending { background: var(--surface-2); color: var(--text-3); font-weight: var(--fw-medium); }
.day-overview__more { margin-top: var(--sp-3); }

/* ---- bt-167 H1: live "Between us" delivery states ---- */
.msg--failed { outline: 1px solid var(--danger); }
.msg--failed .msg__meta { color: var(--danger); }
.msg__retry { margin-top: var(--sp-1); min-height: 44px; }
.msg-empty { margin: 0; }

/* ---- bt-169 P8: the child's photo (settings field + header avatar) ---- */
.photo-field__row { display: flex; align-items: center; gap: var(--sp-3); }
.photo-field__img { width: 72px; height: 72px; flex: 0 0 72px; border-radius: 50%; object-fit: cover; border: 2px solid var(--border-strong); background: var(--surface-2); }
.photo-field__actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.photo-field .field__hint.is-error { color: var(--danger); }
.app-header__avatar.has-photo { padding: 0; overflow: hidden; }
.app-header__avatar-img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; display: block; }
.baby-hero__photo { object-fit: cover; }
