/* ── V3 Design Tokens ──────────────────────────────────────────────────────── */
/* CSS custom properties for the WhoopDash design system. All color, spacing,
   and typography values flow from these tokens so the theme is maintainable
   from a single source of truth. */
:root {
  /* Background depth levels (darkest → lightest) */
  --bg-body: #0a0f1a;
  --bg-hero: #0f172a;
  --bg-card: #111827;
  --border: #1e293b;
  --border-hover: #3b82f680;

  /* Text hierarchy */
  --text-primary: #e2e8f0;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --text-faint: #475569;

  /* Status colors */
  --green: #22c55e;
  --yellow: #eab308;
  --red: #ef4444;

  /* Data colors */
  --blue: #3b82f6;
  --purple: #a855f7;
  --cyan: #06b6d4;
  --orange: #f97316;
  --pink: #f472b6;

  /* Semantic aliases */
  --accent: var(--blue);
  --success: var(--green);
  --warning: var(--yellow);
  --danger: var(--red);

  /* Card hierarchy */
  --card-radius: 12px;
  --card-radius-sm: 8px;
  --card-padding: 16px 20px;

  /* Spacing scale */
  --gap-xs: 4px;
  --gap-sm: 8px;
  --gap-md: 12px;
  --gap-lg: 16px;
  --gap-xl: 20px;
  --gap-2xl: 24px;

  /* Typography — Plus Jakarta Sans for headers (athletic, premium feel),
     DM Sans for body (clean data density). Avoids generic Inter. */
  --font-display: 'Plus Jakarta Sans', system-ui, sans-serif;
  --font: 'DM Sans', system-ui, sans-serif;
  --fs-xs: 9px;
  --fs-sm: 10px;
  --fs-body: 12px;
  --fs-md: 13px;
  --fs-lg: 14px;
  --fs-xl: 18px;
  --fs-2xl: 22px;
  --fs-hero: 28px;
  --ls-tight: -0.02em;
  --ls-wide: 0.05em;
  --ls-wider: 0.08em;
}

/* ── Reset & Base ─────────────────────────────────────────────────────────── */
* { margin: 0; padding: 0; box-sizing: border-box; }
body { background: var(--bg-body); color: var(--text-primary); font-family: var(--font); padding: 20px; }
.container { max-width: 1200px; margin: 0 auto; }

/* ── Focus States (keyboard accessibility) ─────────────────────────────── */
/* Custom focus ring that matches the dark theme instead of browser default */
.tab:focus-visible, .filter-btn:focus-visible, .rating-btn:focus-visible,
.sync-btn:focus-visible, .collapse-toggle:focus-visible, .entry-btn:focus-visible,
.plan-toggle-btn:focus-visible, .week-day:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}
.coach-input:focus-visible { outline: none; } /* uses border-color change instead */

/* ── Header ───────────────────────────────────────────────────────────────── */
.header { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--gap-md); }
.header-left { display: flex; align-items: center; gap: var(--gap-md); }
.logotype { height: 44px; width: auto; }
.subtitle { color: var(--text-muted); font-size: var(--fs-body); }
/* Screen-reader only text (for logotype accessibility) */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

h1 { font-size: var(--fs-xl); font-weight: 700; letter-spacing: var(--ls-tight); font-family: var(--font-display); }
/* Display font on key values that need personality */
.readiness-recovery-value, .gauge-value, .goal-current, .stat-value,
.spark-value, .micro-value, .peak-metric-current { font-family: var(--font-display); }

/* ── Sync Indicator ───────────────────────────────────────────────────────── */
.sync-bar { display: flex; align-items: center; gap: var(--gap-md); margin-bottom: var(--gap-md); padding: 8px 16px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--card-radius-sm); font-size: var(--fs-body); }
.sync-bar.stale { border-color: var(--yellow); background: #eab30808; }
.sync-time { color: var(--text-muted); flex: 1; }
.sync-stale { color: var(--yellow); font-weight: 500; }
.sync-btn { padding: 3px 10px; border-radius: 4px; border: 1px solid var(--border); background: transparent; color: var(--text-muted); font-size: var(--fs-sm); font-weight: 500; cursor: pointer; transition: all 0.15s; display: flex; align-items: center; gap: 6px; }
.sync-btn:hover { border-color: var(--blue); color: var(--blue); }
.sync-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Section Dividers ─────────────────────────────────────────────────────── */
.section-divider { border-top: 1px solid var(--border); margin: var(--gap-lg) 0; padding-top: var(--gap-sm); }
.section-divider-label { font-size: 11px; text-transform: uppercase; letter-spacing: var(--ls-wider); color: var(--text-dim); font-weight: 600; margin-bottom: var(--gap-sm); font-family: var(--font-display); border-left: 3px solid var(--blue); padding-left: var(--gap-sm); }

/* ── Tab Navigation (V3: underline style) ─────────────────────────────────── */
/* Underline tabs replace the old pill/button style. Active tab gets a blue
   bottom border; inactive tabs are dim text. This matches the V3 mockup design
   and feels lighter than the filled-pill approach. */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: var(--gap-xl); }
.tab { padding: 8px 20px; border: none; border-bottom: 2px solid transparent; cursor: pointer; font-size: var(--fs-md); font-weight: 500; font-family: var(--font); background: transparent; color: var(--text-dim); transition: color 0.15s, border-color 0.15s; }
.tab:hover { color: var(--text-muted); }
.tab.active { color: var(--blue); font-weight: 600; border-bottom-color: var(--blue); }

/* ── Micro Readiness Bar (persistent across tabs except Today) ─────────── */
/* Slim strip showing recovery %, key metrics, and status at a glance.
   Hidden on Today tab where the full readiness card provides the same info. */
.micro-bar { display: none; align-items: center; gap: var(--gap-sm); padding: 6px var(--gap-lg); margin-bottom: var(--gap-md); background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--card-radius-sm); font-size: 11px; color: var(--text-muted); }
.micro-bar.visible { display: flex; }
.micro-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.micro-value { font-size: var(--fs-lg); font-weight: 700; }
.micro-sep { color: var(--text-faint); }
.micro-metric { color: var(--text-secondary); font-weight: 500; }
.micro-rec { font-weight: 600; color: var(--text-muted); }

.section { display: none; }
.section.active { display: block; }

/* ── Card Hierarchy ───────────────────────────────────────────────────────── */
/* Three card tiers from V3 mockups: hero (featured), standard, subtle.
   Hero cards get a blue-tinted border and shadow for visual prominence.
   Standard cards are the workhorse. Subtle cards are low-contrast supporting info. */
.card-hero { background: var(--bg-hero); border: 1px solid #3b82f640; border-radius: var(--card-radius); padding: var(--gap-xl) var(--gap-2xl); box-shadow: 0 4px 24px rgba(0,0,0,0.3); margin-bottom: var(--gap-lg); }
.card, .chart-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--card-radius); padding: var(--card-padding); transition: border-color 0.2s, box-shadow 0.2s; }
.chart-card:hover { border-color: #1e293b80; box-shadow: 0 2px 12px rgba(0,0,0,0.15); }
.chart-wrap { position: relative; }
.card-subtle { background: var(--bg-hero); border: 1px solid var(--border); border-radius: var(--card-radius-sm); padding: 10px 12px; font-size: var(--fs-body); color: var(--text-muted); }

/* ── Bento Grid Layouts ───────────────────────────────────────────────────── */
/* Asymmetric and symmetric grid patterns from V3 mockups. These complement
   the existing .chart-grid (1fr 1fr) and .stats-grid (repeat 5). */
.bento-2-1 { display: grid; grid-template-columns: 2fr 1fr; gap: var(--gap-lg); margin-bottom: var(--gap-lg); }
.bento-1-1 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap-lg); margin-bottom: var(--gap-lg); }
.bento-1-1-1 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--gap-lg); margin-bottom: var(--gap-lg); }

/* ── Collapsible Sections ─────────────────────────────────────────────────── */
/* Reusable expand/collapse pattern. JS toggles .open on .collapse-content.
   Toggle link styled as blue text to indicate interactivity. */
.collapse-toggle { cursor: pointer; display: flex; align-items: center; gap: 6px; font-size: var(--fs-body); font-weight: 600; color: var(--blue); padding: 8px 0; border: none; background: none; font-family: var(--font); transition: color 0.15s; }
.collapse-toggle:hover { color: #60a5fa; }
/* Animated collapse: max-height transition instead of display toggle.
   Uses a generous max-height that covers most content sizes. */
.collapse-content { max-height: 0; overflow: hidden; transition: max-height 0.35s ease-out, opacity 0.25s ease; opacity: 0; }
.collapse-content.open { max-height: 3000px; opacity: 1; transition: max-height 0.5s ease-in, opacity 0.3s ease; }

/* ── Readiness Card ───────────────────────────────────────────────────────── */
.readiness-card { background: var(--bg-card); border: 2px solid var(--tt-color); border-radius: var(--card-radius); padding: 0; margin-bottom: var(--gap-lg); overflow: hidden; }
.readiness-today { display: flex; align-items: center; gap: var(--gap-2xl); flex-wrap: wrap; padding: var(--gap-lg) var(--gap-2xl); }
.readiness-today-left { display: flex; align-items: center; gap: var(--gap-lg); flex-shrink: 0; }
/* Recovery dot with breathing pulse — the dashboard's visual signature */
.readiness-dot { width: 14px; height: 14px; border-radius: 50%; box-shadow: 0 0 8px var(--tt-color-glow); flex-shrink: 0; animation: pulse 2.5s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 6px var(--tt-color-glow); transform: scale(1); }
  50% { box-shadow: 0 0 20px var(--tt-color-glow), 0 0 40px var(--tt-color-glow); transform: scale(1.15); }
}
/* Micro bar dot gets a smaller pulse */
.micro-dot { animation: pulse-sm 2.5s ease-in-out infinite; }
@keyframes pulse-sm {
  0%, 100% { box-shadow: none; }
  50% { box-shadow: 0 0 8px var(--tt-color-glow); }
}
.readiness-recovery { text-align: center; }
.readiness-recovery-value { font-size: var(--fs-hero); font-weight: 700; color: var(--tt-color); line-height: 1; }
.readiness-recovery-label { font-size: var(--fs-xs); color: var(--text-muted); text-transform: uppercase; letter-spacing: var(--ls-wide); margin-top: 2px; }
.readiness-metrics { display: flex; flex: 1; justify-content: space-evenly; flex-wrap: wrap; }
.readiness-metric { text-align: center; min-width: 65px; }
.readiness-metric-value { font-size: 16px; font-weight: 600; }
.readiness-metric-label { font-size: var(--fs-sm); color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.readiness-metric-delta { font-size: var(--fs-xs); }
.readiness-rec { flex-shrink: 0; width: 300px; font-size: var(--fs-md); color: var(--text-secondary); line-height: 1.5; border-left: 1px solid var(--border); padding-left: var(--gap-xl); }
.readiness-rec-title { font-size: var(--fs-sm); color: var(--text-muted); text-transform: uppercase; letter-spacing: var(--ls-wide); margin-bottom: 4px; }
.strain-context { display: flex; align-items: center; gap: var(--gap-lg); padding: var(--gap-sm) var(--gap-2xl); background: var(--bg-body); border-top: 1px solid var(--border); font-size: 11px; color: var(--text-muted); flex-wrap: wrap; }
.strain-breakdown { display: flex; align-items: center; gap: 6px; }
.strain-label { color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.04em; font-size: var(--fs-xs); }
.strain-workout { color: var(--green); font-weight: 600; }
.strain-sep { color: var(--text-faint); }
.strain-passive { color: var(--yellow); font-weight: 600; }
.strain-activity { display: flex; align-items: center; gap: 4px; color: var(--text-secondary); font-size: 11px; }
.strain-activity-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--blue); flex-shrink: 0; }
.strain-no-activity { color: var(--text-faint); font-style: italic; font-size: 11px; }
.readiness-7d { display: grid; grid-template-columns: repeat(5, 1fr); padding: 10px var(--gap-2xl); background: var(--bg-hero); border-top: 1px solid var(--border); font-size: var(--fs-body); }
.readiness-7d-metric { text-align: center; }
.readiness-7d-value { font-weight: 600; color: var(--text-secondary); }
.readiness-7d-label { font-size: var(--fs-xs); color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.04em; }
.readiness-7d-vs { font-size: var(--fs-xs); color: var(--text-faint); }

/* ── Stats Grid ───────────────────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: var(--gap-md); margin: 0 0 20px 0; }
.stat-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--card-radius); padding: var(--card-padding); }
.stat-label { color: var(--text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: var(--ls-wide); }
.stat-value { font-size: 24px; font-weight: 600; line-height: 1.3; }
.stat-value span { font-size: var(--fs-md); color: var(--text-muted); font-weight: 400; }

/* ── Trend Badges ─────────────────────────────────────────────────────────── */
.trend-badge { font-size: var(--fs-xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; margin-left: 4px; vertical-align: middle; }
.trend-badge.stable { color: var(--text-dim); }

/* ── Sparkline Grid ───────────────────────────────────────────────────────── */
.sparkline-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: var(--gap-sm); margin-bottom: var(--gap-lg); }
.spark-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; cursor: pointer; transition: border-color 0.15s; }
.spark-card:hover { border-color: var(--border-hover); }
.spark-card.active { border-color: var(--blue); }
.spark-detail { grid-column: 1 / -1; background: var(--bg-hero); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; }
.spark-detail canvas { height: 120px !important; max-height: 120px; }
.spark-annotation { font-size: 11px; color: var(--text-dim); margin-top: 6px; }
.spark-label { font-size: var(--fs-xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); }
/* Value row: value + unit + delta inline, sparkline chart right-aligned */
.spark-row { display: flex; align-items: flex-end; justify-content: space-between; margin-top: 4px; }
.spark-value { font-size: 18px; font-weight: 700; color: var(--text-primary); line-height: 1; }
.spark-delta { font-size: var(--fs-sm); font-weight: 600; margin-left: 4px; }
.spark-delta.good, .spark-delta.up { color: var(--green); }
.spark-delta.bad, .spark-delta.down { color: var(--red); }
.spark-delta.flat { color: var(--text-muted); }
.spark-chart { width: 72px; height: 28px; flex-shrink: 0; }
.spark-canvas { height: 36px !important; width: 100% !important; }

/* ── Chart Grid & Cards ───────────────────────────────────────────────────── */
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap-md); }
.chart-card.full { grid-column: span 2; }
.chart-title { color: var(--text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: var(--ls-wider); font-weight: 500; margin-bottom: var(--gap-md); }
.chart-note { color: var(--text-muted); font-size: 11px; margin-top: var(--gap-sm); line-height: 1.5; }
canvas { max-height: 250px; }
/* Bento charts get a taller limit so they fill more of the card, but
   still have a ceiling to prevent infinite-growth resize loops */
.bento-2-1 canvas, .bento-1-1 canvas { max-height: 300px; }

/* ── Tier Bars ────────────────────────────────────────────────────────────── */
.tier-group { display: flex; gap: var(--gap-2xl); justify-content: center; padding-top: var(--gap-sm); }
.tier { text-align: center; }
.tier-bar { width: 160px; height: 24px; border-radius: 6px; overflow: hidden; display: flex; }
.tier-labels { display: flex; justify-content: space-between; font-size: var(--fs-sm); color: var(--text-muted); margin-top: 4px; width: 160px; }

/* ── Recovery Table ───────────────────────────────────────────────────────── */
.recovery-table { width: 100%; font-size: var(--fs-body); border-collapse: collapse; }
.recovery-table th { text-align: left; color: var(--text-muted); font-weight: 500; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.recovery-table td { padding: 6px 8px; border-bottom: 1px solid var(--border); }

/* ── Adherence ────────────────────────────────────────────────────────────── */
.adherence-row { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--border); font-size: var(--fs-body); }
.adherence-check { width: 18px; height: 18px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; flex-shrink: 0; }
.adherence-check.pass { background: #22c55e33; color: var(--green); }
.adherence-check.fail { background: #ef444433; color: var(--red); }

/* ── Goals ─────────────────────────────────────────────────────────────────── */
.goal-card { display: flex; align-items: center; gap: var(--gap-lg); padding: 12px 16px; background: var(--bg-hero); border-radius: var(--card-radius-sm); margin-bottom: var(--gap-sm); }
.goal-current { font-size: var(--fs-hero); font-weight: 700; min-width: 80px; }
.goal-target { font-size: var(--fs-body); color: var(--text-muted); }
.goal-trend { font-size: var(--fs-lg); font-weight: 600; }

/* ── Plan Cards ───────────────────────────────────────────────────────────── */
.plan-section { margin-bottom: var(--gap-lg); }
.plan-toggle { display: flex; gap: var(--gap-xs); background: var(--border); border-radius: var(--card-radius-sm); padding: 3px; width: fit-content; margin-bottom: var(--gap-md); }
.plan-toggle-btn { padding: 6px 16px; border-radius: 6px; border: none; cursor: pointer; font-size: var(--fs-body); font-weight: 500; background: transparent; color: var(--text-muted); transition: all 0.15s; font-family: var(--font); }
.plan-toggle-btn.active { background: var(--blue); color: #fff; }
.plan-cards { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap-md); }
.plan-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--card-radius); padding: var(--card-padding); transition: border-color 0.15s, opacity 0.15s; }
.plan-card.suggested { border-color: var(--border-hover); }
.plan-card.dimmed { opacity: 0.5; }
.plan-card-title { font-size: var(--fs-lg); font-weight: 600; margin-bottom: 10px; display: flex; align-items: center; gap: var(--gap-sm); }
.plan-card-title .badge { font-size: var(--fs-xs); padding: 2px 8px; border-radius: 10px; background: #3b82f620; color: var(--blue); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.plan-exercise { display: flex; gap: 10px; padding: 6px 0; border-bottom: 1px solid #1e293b12; font-size: var(--fs-body); }
.plan-exercise:last-child { border-bottom: none; }
.plan-exercise-name { font-weight: 500; color: var(--text-primary); min-width: 140px; }
.plan-exercise-detail { color: var(--text-muted); flex: 1; }
.plan-exercise-duration { color: var(--text-dim); min-width: 70px; text-align: right; font-size: 11px; }
.plan-notes { font-size: 11px; color: var(--text-dim); margin-top: var(--gap-sm); padding-top: var(--gap-sm); border-top: 1px solid var(--border); font-style: italic; }
.plan-prediction { font-size: 11px; color: var(--text-muted); margin-top: var(--gap-sm); padding-top: var(--gap-sm); border-top: 1px solid var(--border); }
.plan-prediction.actual { color: var(--green); }
.pred-basis { color: var(--text-dim); font-size: var(--fs-sm); margin-left: 6px; }
.plan-progress { margin-top: 10px; padding: 10px 14px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--card-radius-sm); }
.progress-header { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 6px; }
.progress-item { font-size: var(--fs-body); color: var(--text-secondary); padding: 3px 0; display: flex; align-items: center; gap: 6px; }
.progress-check { color: var(--green); font-weight: bold; }
.progress-dot { color: var(--text-dim); }
.progress-item.overridden { color: var(--text-muted); font-style: italic; }
.progress-item.overridden .progress-check { color: var(--yellow); }
.progress-banner { margin-top: 6px; padding: 4px 10px; background: rgba(34,197,94,0.1); border-radius: 6px; color: var(--green); font-size: 11px; text-align: center; }
.plan-context { display: flex; gap: var(--gap-sm); flex-wrap: wrap; margin-top: var(--gap-sm); }
.plan-context-note { font-size: 11px; padding: 3px 10px; border-radius: 12px; background: var(--border); color: var(--text-muted); }

/* ── Peak Fitness ─────────────────────────────────────────────────────────── */
/* Hero-level treatment: blue-tinted border + shadow for visual prominence */
.peak-card { background: var(--bg-hero); border: 1px solid #3b82f640; border-radius: var(--card-radius); padding: var(--gap-xl) var(--gap-2xl); box-shadow: 0 4px 24px rgba(0,0,0,0.3); margin-bottom: var(--gap-lg); }
.peak-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--gap-md); }
.peak-title { font-size: 11px; text-transform: uppercase; letter-spacing: var(--ls-wider); color: var(--text-muted); font-weight: 500; }
.peak-period { font-size: var(--fs-body); color: var(--text-dim); }
.peak-metrics { display: flex; gap: var(--gap-2xl); flex-wrap: wrap; justify-content: center; }
.peak-metric { flex: 1; min-width: 140px; }
.peak-metric-row { display: flex; align-items: center; gap: var(--gap-sm); margin-bottom: 4px; }
.peak-metric-label { font-size: var(--fs-sm); color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.peak-metric-current { font-size: var(--fs-xl); font-weight: 600; }
.peak-metric-peak { font-size: 11px; color: var(--text-dim); }
.peak-bar { height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; margin-top: 6px; }
.peak-bar-fill { height: 100%; border-radius: 4px; transition: width 0.3s; box-shadow: 0 0 6px rgba(0,0,0,0.3); }

/* ── Protocol Rules ───────────────────────────────────────────────────────── */
.protocol-rules { background: var(--bg-hero); border: 1px solid var(--border); border-radius: var(--card-radius); padding: var(--card-padding); margin-bottom: var(--gap-md); }
.protocol-rules-title { font-size: var(--fs-md); font-weight: 600; margin-bottom: 10px; }
.protocol-rule { display: flex; align-items: flex-start; gap: var(--gap-sm); padding: 5px 0; font-size: var(--fs-body); color: var(--text-secondary); }
.protocol-rule-icon { color: var(--blue); font-size: 11px; margin-top: 1px; flex-shrink: 0; }

/* ── Filter Bar ───────────────────────────────────────────────────────────── */
.filter-bar { display: flex; align-items: center; gap: var(--gap-sm); margin-bottom: var(--gap-lg); padding: 6px 12px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--card-radius-sm); font-size: var(--fs-body); flex-wrap: wrap; }
/* Connected filter button group — seamless pill strip with no double borders */
.filter-group { display: flex; }
.filter-group .filter-btn { border-radius: 0; margin-left: -1px; position: relative; }
.filter-group .filter-btn:first-child { border-radius: 6px 0 0 6px; margin-left: 0; }
.filter-group .filter-btn:last-child { border-radius: 0 6px 6px 0; }
.filter-group .filter-btn.active { z-index: 1; }
.filter-btn { padding: 5px 14px; border-radius: 6px; border: 1px solid var(--border); background: var(--bg-card); color: var(--text-dim); font-size: 11px; font-weight: 600; cursor: pointer; transition: all 0.15s; font-family: var(--font); }
.filter-btn.active { background: #1e3a5f; color: var(--blue); border-color: var(--blue); }
.filter-btn:hover { border-color: var(--border-hover); z-index: 1; }
.filter-dates { display: flex; align-items: center; gap: var(--gap-xs); margin-left: var(--gap-sm); }
.filter-date-input { background: var(--bg-hero); border: 1px solid var(--border); border-radius: 4px; color: var(--text-primary); font-size: 11px; padding: 3px 8px; }

/* ── Coach / Form Inputs ──────────────────────────────────────────────────── */
.coach-input { background: var(--bg-hero); border: 1px solid var(--border); border-radius: 6px; color: var(--text-primary); padding: 8px 12px; font-size: var(--fs-md); width: 100%; box-sizing: border-box; font-family: var(--font); }
.coach-input:focus { border-color: var(--blue); outline: none; }
textarea.coach-input { resize: vertical; min-height: 60px; }
select.coach-input { cursor: pointer; }
.coach-form-row { display: flex; gap: var(--gap-sm); margin-top: var(--gap-sm); align-items: center; flex-wrap: wrap; }
.coach-label { font-size: 11px; color: var(--text-muted); margin-bottom: 4px; display: block; }
.coach-hint { color: var(--text-dim); font-size: var(--fs-body); margin-bottom: 10px; }
.coach-saved { color: var(--green); font-size: 11px; display: none; margin-left: var(--gap-sm); }
.coach-saved.show { display: inline; }

/* ── Rating Buttons ───────────────────────────────────────────────────────── */
.rating-group { display: flex; gap: var(--gap-xs); }
.rating-btn { width: 36px; height: 36px; border-radius: var(--card-radius-sm); border: 1px solid var(--border); background: var(--bg-card); color: var(--text-muted); cursor: pointer; font-size: var(--fs-lg); font-weight: 600; transition: all 0.15s; }
.rating-btn:hover { border-color: var(--border-hover); }
.rating-btn.active { background: var(--blue); color: #fff; border-color: var(--blue); }

/* ── Override Items ───────────────────────────────────────────────────────── */
.override-item { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; background: var(--bg-hero); border: 1px solid var(--border); border-radius: 6px; margin-bottom: 6px; font-size: var(--fs-body); }
.override-remove { background: none; border: none; color: var(--red); cursor: pointer; font-size: var(--fs-lg); padding: 0 4px; }

/* ── Week Planner ─────────────────────────────────────────────────────────── */
.week-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: var(--gap-xs); }
.week-label { grid-column: 1 / -1; color: var(--text-dim); font-size: var(--fs-sm); text-transform: uppercase; letter-spacing: 0.5px; margin: 6px 0 2px; }
.week-label:first-child { margin-top: 0; }
.week-day { text-align: center; padding: 6px 2px; border-radius: 6px; border: 1px solid var(--border); font-size: var(--fs-sm); cursor: pointer; transition: all 0.15s; }
.week-day:hover { border-color: var(--border-hover); }
.week-day.past { opacity: 0.35; pointer-events: none; cursor: default; }
.week-day.today { border-color: var(--blue); box-shadow: 0 0 0 1px #3b82f640; }
.week-day .day-label { color: var(--text-dim); font-size: var(--fs-xs); text-transform: uppercase; }
.week-day .day-num { font-size: var(--fs-md); font-weight: 600; margin: 2px 0; }
.week-day .day-type { font-size: var(--fs-xs); min-height: 14px; }
.week-day.planned-gym { background: #22c55e20; border-color: #22c55e60; }
.week-day.planned-gym .day-type { color: var(--green); }
.week-day.planned-pilates { background: #a855f720; border-color: #a855f760; }
.week-day.planned-pilates .day-type { color: var(--purple); }
.week-day.planned-rest { background: #3b82f620; border-color: #3b82f660; }
.week-day.planned-rest .day-type { color: var(--blue); }
.week-day.planned-home { background: #eab30820; border-color: #eab30860; }
.week-day.planned-home .day-type { color: var(--yellow); }
.week-day.planned-massage { background: #f472b620; border-color: #f472b660; }
.week-day.planned-massage .day-type { color: var(--pink); }

/* ── Feedback & Events ────────────────────────────────────────────────────── */
.feedback-item { padding: 6px 10px; background: var(--bg-hero); border: 1px solid var(--border); border-radius: 6px; margin-bottom: 4px; font-size: var(--fs-body); display: flex; justify-content: space-between; align-items: center; }
.event-item { padding: 6px 10px; background: var(--bg-hero); border: 1px solid var(--border); border-radius: 6px; margin-bottom: 4px; font-size: var(--fs-body); display: flex; justify-content: space-between; align-items: center; }
.entry-actions { display: flex; gap: var(--gap-xs); flex-shrink: 0; margin-left: var(--gap-sm); }
.entry-btn { background: none; border: 1px solid #334155; color: var(--text-dim); cursor: pointer; border-radius: 4px; width: 22px; height: 22px; font-size: 11px; display: flex; align-items: center; justify-content: center; padding: 0; transition: all 0.15s; }
.entry-btn:hover { border-color: var(--blue); color: var(--text-primary); }

/* ── Hero Graph (uses .card-hero wrapper, canvas height set inline) ───── */
.hero-context { display: flex; gap: var(--gap-lg); font-size: 11px; color: var(--text-muted); margin-top: var(--gap-sm); flex-wrap: wrap; }
.hero-context-item { display: flex; align-items: center; gap: 4px; }

/* ── Why? Panel ───────────────────────────────────────────────────────────── */
/* Badges need padding from the readiness card border so they don't crowd it */
.why-badges { display: flex; gap: 6px; margin-top: var(--gap-sm); padding: var(--gap-sm) var(--gap-2xl); flex-wrap: wrap; }
.why-badge { font-size: var(--fs-sm); padding: 2px 8px; border-radius: 10px; text-transform: uppercase; letter-spacing: 0.03em; font-weight: 600; }
.why-badge.green { background: #22c55e20; color: var(--green); }
.why-badge.amber { background: #eab30820; color: var(--yellow); }
.why-badge.red { background: #ef444420; color: var(--red); }
.why-badge.blue { background: #3b82f620; color: var(--blue); }
.why-panel { max-height: 0; overflow: hidden; transition: max-height 0.3s ease; }
.why-panel.open { max-height: 400px; }
.why-header { cursor: pointer; display: flex; align-items: center; gap: 6px; font-size: var(--fs-body); font-weight: 600; color: var(--text-muted); padding: 8px 0; user-select: none; }
.why-header:hover { color: var(--text-primary); }
.why-chevron { transition: transform 0.2s; font-size: var(--fs-sm); }
.why-header.open .why-chevron { transform: rotate(90deg); }
.why-row { display: flex; align-items: center; gap: var(--gap-md); padding: 4px 0; font-size: var(--fs-body); border-bottom: 1px solid var(--border); }
.why-row:last-child { border-bottom: none; }
.why-row-label { flex: 1; color: var(--text-secondary); }
.why-row-value { min-width: 80px; color: var(--text-muted); text-align: right; }
.why-row-adj { min-width: 60px; font-weight: 600; text-align: right; }

/* ── Why Table (V3: replaces expandable panel with always-visible table) ──── */
/* 4-column layout: Factor | Current | Baseline | Adjustment. Server-side data,
   JS populates the tbody. Summary row shows net/predicted/actual below. */
.why-table { width: 100%; font-size: var(--fs-body); border-collapse: collapse; }
.why-table th { text-align: left; font-size: var(--fs-xs); font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: var(--ls-wide); padding: 6px 12px; border-bottom: 1px solid var(--border); }
.why-table td { padding: 8px 12px; border-bottom: 1px solid #1e293b20; color: var(--text-secondary); }
.why-table .why-val { font-weight: 600; color: var(--text-primary); }
.adj-positive { color: var(--green); font-weight: 600; }
.adj-negative { color: var(--red); font-weight: 600; }
.adj-neutral { color: var(--text-muted); font-weight: 600; }
.why-summary { display: flex; gap: var(--gap-xl); padding: 10px 12px; background: var(--bg-body); border-radius: var(--card-radius-sm); margin-top: var(--gap-sm); font-size: var(--fs-body); color: var(--text-muted); flex-wrap: wrap; }

/* ── Status Gauges (V3: color bars + zone indicators) ─────────────────────── */
/* Gauge cards show a large value, a label, a color gradient bar indicating
   the current position within the range, and an optional explainer. */
.gauge-card { text-align: center; padding: var(--gap-xl) var(--gap-2xl); background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--card-radius); }
.gauge-value { font-size: 28px; font-weight: 700; line-height: 1.1; }
.gauge-label { font-size: var(--fs-sm); font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; margin-top: 6px; }
.gauge-sub { font-size: 11px; color: var(--text-dim); margin-top: 4px; }
.gauge-explainer { font-size: var(--fs-sm); color: var(--text-dim); font-style: italic; margin-top: 10px; line-height: 1.4; }
/* Gradient color bar showing position within a range */
.color-bar { height: 6px; border-radius: 3px; margin-top: 14px; position: relative; }
.color-bar-dot { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--text-primary); position: absolute; top: -3px; transform: translateX(-50%); }
/* ACWR segmented bar: blue (detraining) | green (optimal) | yellow (caution) | red (danger) */
.acwr-bar { display: flex; height: 6px; border-radius: 3px; margin-top: 14px; overflow: visible; position: relative; }
.acwr-seg { height: 100%; }
.acwr-arrow { position: absolute; top: -8px; transform: translateX(-50%); font-size: 10px; color: var(--text-primary); }
/* Progress bar for plan completion */
.progress-bar-bg { height: 6px; border-radius: 3px; background: var(--border); margin-top: 14px; overflow: hidden; }
.progress-bar-fill { height: 100%; border-radius: 3px; background: var(--green); transition: width 0.3s; }

/* ── Impact Highlights Strip ──────────────────────────────────────────────── */
/* Shows top recovery helper and biggest watch-out from activity impact data.
   Sits at the bottom of the readiness card as a quick at-a-glance summary. */
.impact-strip { display: flex; align-items: center; gap: var(--gap-lg); padding: var(--gap-sm) var(--gap-2xl); background: var(--bg-body); border-top: 1px solid var(--border); font-size: 11px; color: var(--text-muted); flex-wrap: wrap; }
.impact-strip-item { display: flex; align-items: center; gap: var(--gap-xs); }
.impact-strip-label { font-weight: 600; text-transform: uppercase; font-size: var(--fs-xs); letter-spacing: 0.04em; }

/* ── Forecast Row ─────────────────────────────────────────────────────────── */
.forecast-row { padding: var(--gap-sm) var(--gap-2xl); background: var(--bg-hero); border-top: 1px solid var(--border); font-size: 11px; color: var(--text-muted); display: flex; align-items: center; gap: var(--gap-sm); flex-wrap: wrap; }
.forecast-icon { font-size: var(--fs-md); }

/* ── Event Log Table ──────────────────────────────────────────────────────── */
.event-table { width: 100%; border-collapse: collapse; font-size: var(--fs-body); }
.event-th { text-align: left; color: var(--text-dim); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: var(--ls-wide); padding: 4px 8px 6px; border-bottom: 1px solid var(--border); }
.event-td { padding: 6px 8px; border-bottom: 1px solid var(--bg-card); vertical-align: middle; }
.event-badge { display: inline-block; padding: 2px 8px; border-radius: 10px; color: #fff; font-size: var(--fs-sm); font-weight: 600; text-transform: capitalize; white-space: nowrap; }
.event-dates { white-space: nowrap; color: var(--text-secondary); }
.event-loc { color: var(--text-muted); font-size: 11px; }
.event-notes { color: var(--text-muted); max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.event-actions { white-space: nowrap; text-align: right; }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .container { padding: 12px; }
  .sparkline-grid { grid-template-columns: repeat(2, 1fr); }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .chart-grid { grid-template-columns: 1fr; }
  .chart-card.full { grid-column: span 1; }
  .chart-card { padding: 12px 14px; }
  .readiness-today { flex-direction: column; gap: var(--gap-md); }
  .readiness-rec { border-left: none; border-top: 1px solid var(--border); padding-left: 0; padding-top: var(--gap-md); width: auto; }
  .readiness-7d { grid-template-columns: repeat(3, 1fr); gap: var(--gap-sm); }
  .plan-cards { grid-template-columns: 1fr; }
  /* Hide the non-selected plan card on mobile — no room for both */
  .plan-card.dimmed { display: none; }
  .peak-metrics { flex-direction: column; }
  /* Underline tabs scroll horizontally on mobile */
  .tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    /* Tabs: INCREASE padding on mobile for bigger tap targets (WCAG 44px min) */
  .tab { padding: 10px 14px; font-size: var(--fs-body); white-space: nowrap; }
  .strain-context { flex-direction: column; align-items: flex-start; gap: var(--gap-sm); padding: 8px 14px; }
  .tier-group { flex-direction: column; align-items: center; gap: var(--gap-md); }
  h1 { font-size: 20px; }
  .logotype { height: 32px; }
  .filter-bar { flex-wrap: wrap; }
  .spark-detail { grid-column: 1 / -1; }
  .hero-context { flex-direction: column; gap: 6px; }
  .event-table { font-size: 11px; }
  .event-loc { display: none; }
  .event-th:nth-child(3) { display: none; }
  /* Bento grids collapse to single column on mobile */
  .bento-2-1, .bento-1-1, .bento-1-1-1 { grid-template-columns: 1fr; }
  /* Why table scrolls horizontally on mobile */
  .why-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  /* Gauge grid collapses to single column */
  .gauge-grid { grid-template-columns: 1fr !important; }
  /* Impact strip wraps */
  .impact-strip { padding: var(--gap-sm) 14px; }
  .forecast-row { padding: var(--gap-sm) 14px; }
  /* Micro bar: hide separators, tighter spacing on mobile */
  .micro-bar { font-size: 10px; gap: 6px; flex-wrap: wrap; }
  .micro-sep { display: none; }
  .why-badges { padding-left: 14px; padding-right: 14px; }
  /* ── Header: mobile compact layout ──
     Problem: logo + subtitle + sync text + button overflow on narrow screens.
     Fix: hide subtitle (data is on Today tab), stack header vertically so
     logo row and sync row each get full width. */
  .header { flex-direction: column; align-items: stretch; gap: 6px; }
  .header-left { gap: var(--gap-sm); }
  .logotype { height: 28px; }
  .subtitle { display: none; }
  /* Override inline font-size on syncBar */
  #syncBar { font-size: 10px !important; justify-content: flex-end; }
  /* ── Stats grid: 5 cards → last card spans full width instead of orphan ── */
  .stats-grid .stat-card:last-child:nth-child(odd) { grid-column: 1 / -1; }
  /* ── HR Zones: force canvas height on mobile ──
     Chart.js reads the canvas element's CSS height when maintainAspectRatio
     is false. Using !important to override Chart.js inline style injection. */
  #chtHRZones { height: 250px !important; max-height: 250px; }
  /* ── Touch targets: WCAG AA requires 44x44px minimum ── */
  .filter-btn { padding: 8px 14px; }
  .entry-btn { width: 32px; height: 32px; font-size: 13px; }
  .rating-btn { width: 44px; height: 44px; }
  .week-day { padding: 8px 4px; }
  .collapse-toggle { padding: 10px 8px; }
  /* ── Form inputs: full width on narrow screens ── */
  .coach-form-row { flex-direction: column; align-items: stretch; }
  .coach-form-row .coach-input { width: 100% !important; flex: 1 !important; }
  /* ── Event notes: allow wrapping instead of truncating ── */
  .event-notes { white-space: normal; max-width: none; }
}
