:root {
  /* Dark theme (default) - "maroon dark" */
  --bg: #12151c;
  --panel: #1b1f29;
  --panel-alt: #171a22;
  --border: #2a2e3a;
  --text: #f0e9e5;
  --text-dim: #9aa0ac;
  --text-faint: #676d7a;

  --accent: #c15b62;
  --accent-bg: #5c2a2e;
  --accent-text: #f3c9c9;

  --good: #5cbf8f;
  --good-bg: #2c4a3a;
  --good-text: #bfe3cc;

  --warn: #d3ab68;
  --warn-bg: #4a3a20;
  --warn-text: #f0d9ab;

  --bad: #d97b71;
  --bad-bg: #4a2620;
  --bad-text: #f0c4bc;

  /* Deeper, more muted tones for gauge fills specifically - the badge
     colors above (--good/--warn/--bad) stay bright since they're text on
     a background pill and need contrast; gauges are a filled bar and read
     better closer to the rest of the deep-maroon theme. */
  --gauge-good: #3d7f60;
  --gauge-warn: #8a6a3a;
  --gauge-bad: #8f4a44;
  --gauge-track: #2a2e3a;

  /* Dedicated chart-series palette - deliberately NOT reusing --accent/
     --good/--warn/--bad. --accent (maroon) and --bad (coral) sit too close
     in hue to tell apart as adjacent line colors on a chart; this 4-hue set
     (blue/green/amber/red) is chosen for mutual contrast first, semantic
     meaning second. */
  --chart-1: #5b9bff; /* blue */
  --chart-2: #4ecf9a; /* green */
  --chart-3: #e8b64a; /* amber */
  --chart-4: #f2705c; /* red/coral */

  --tag-long-bg: #f3efe6;
  --tag-long-text: #2a2621;

  --radius: 10px;
}

[data-theme="light"] {
  /* Light theme - "trackside cream" */
  --bg: #f3efe6;
  --panel: #fbfaf6;
  --panel-alt: #f7f3ea;
  --border: #e2dbc9;
  --text: #2a2621;
  --text-dim: #746c5c;
  --text-faint: #a39c8a;

  --accent: #7a2e2e;
  --accent-bg: #7a2e2e;
  --accent-text: #fbe9e5;

  --good: #1f3b30;
  --good-bg: #1f3b30;
  --good-text: #dcefe3;

  --warn: #8a6a2e;
  --warn-bg: #e9d9b0;
  --warn-text: #4a3a15;

  --bad: #8c3a2e;
  --bad-bg: #f3d9d0;
  --bad-text: #5c2018;

  --gauge-good: #2f5a45;
  --gauge-warn: #6b5122;
  --gauge-bad: #6e2d22;
  --gauge-track: #e2dbc9;

  /* Same reasoning as the dark-theme block above - darkened/desaturated
     enough for contrast against the cream background while staying
     distinguishable from each other. */
  --chart-1: #2f5aa8; /* blue */
  --chart-2: #1f6b4d; /* green */
  --chart-3: #8a6520; /* amber */
  --chart-4: #a83e2e; /* red/coral */

  --tag-long-bg: #12151c;
  --tag-long-text: #f0e9e5;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  transition: background 0.15s ease, color 0.15s ease;
}

/* Desktop layout: persistent left sidebar (page nav + on-page section jump
   links) beside a widened content column. Below --layout-breakpoint this
   collapses back to the original single-column layout with the existing
   top .site-nav bar handling page switching - the sidebar and its
   "on this page" list don't try to fit on a phone screen. */
.layout {
  display: flex;
  align-items: flex-start;
}
.wrap {
  max-width: 1280px;
  margin: 0 auto;
  padding: 28px 32px 60px;
  flex: 1 1 auto;
  min-width: 0;
}

.side-nav {
  flex: 0 0 208px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 26px 16px 20px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.side-nav-brand {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.01em;
  padding: 0 6px;
}
.side-nav-pages {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.side-nav-pages a {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  text-decoration: none;
  padding: 8px 10px;
  border-radius: 8px;
}
.side-nav-pages a:hover { background: var(--panel-alt); color: var(--text); }
.side-nav-pages a.active { color: var(--accent-text); background: var(--accent-bg); }
.side-nav-sections {
  border-top: 1px solid var(--border);
  padding-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.side-nav-sections-label {
  font-size: 10px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0 10px 6px;
}
.side-nav-sections a {
  font-size: 12.5px;
  color: var(--text-dim);
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 6px;
  border-left: 2px solid transparent;
}
.side-nav-sections a:hover { color: var(--text); background: var(--panel-alt); }

/* Below this width the sidebar can't fit alongside readable content, so it
   disappears entirely and the top .site-nav bar (in .sticky-header) takes
   over page switching, same as before the sidebar existed. */
@media (max-width: 999px) {
  .side-nav { display: none; }
  .layout { display: block; }
  .wrap { max-width: 900px; padding: 28px 20px 60px; }
}
@media (min-width: 1000px) {
  .site-nav { display: none; }
}

a { color: var(--accent); }
code {
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 0.85em;
}

/* Sticky header - nav + page-header stay pinned while the rest of the page scrolls */
.sticky-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--bg);
  padding-bottom: 14px;
  padding-top: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
}
.sticky-header .site-nav { margin-bottom: 16px; }

/* Cascading section sub-headers - each section's own heading sticks just below
   the main sticky-header while you scroll through that section, then gets
   pushed out by the next section's heading once you scroll past it. Height of
   .sticky-header is measured in JS and written to --sticky-header-height so
   these line up under it with no gap regardless of header content length. */
.panel-subheader {
  position: sticky;
  top: var(--sticky-header-height, 96px);
  z-index: 10;
  background: var(--panel);
  margin: -18px -18px 12px;
  padding: 16px 18px 10px;
  border-radius: var(--radius) var(--radius) 0 0;
}
.category-subheader {
  position: sticky;
  top: var(--sticky-header-height, 96px);
  z-index: 10;
  background: var(--panel);
  margin: 0 -18px;
  padding: 10px 18px 8px;
}
.sticky-header .page-header { margin-bottom: 0; }

/* Anchor targets for the sidebar's "on this page" jump links - keeps the
   jumped-to section clear of the sticky header instead of landing underneath it. */
.panel[id],
.kpi-strip[id],
.chart-panel[id],
.exercise-category[id] {
  scroll-margin-top: calc(var(--sticky-header-height, 96px) + 14px);
}

/* Header */
.page-header {
  margin-bottom: 22px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.page-header-text { flex: 1; min-width: 0; }
.eyebrow {
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  text-transform: uppercase;
  margin-bottom: 6px;
}
.page-header h1 {
  margin: 0 0 6px;
  font-size: 28px;
  letter-spacing: -0.01em;
}
.header-meta {
  color: var(--text-dim);
  font-size: 13.5px;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.header-meta strong { color: var(--text); }

.theme-toggle {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 2px;
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 20px;
  padding: 3px;
}
.theme-toggle button {
  border: none;
  background: transparent;
  color: var(--text-faint);
  font-size: 11px;
  padding: 5px 10px;
  border-radius: 16px;
  cursor: pointer;
  font-weight: 600;
}
.theme-toggle button.active { background: var(--accent-bg); color: var(--accent-text); }

.header-controls {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
}
.btn-signout {
  flex: 0 0 auto;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text-faint);
  font-size: 11px;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: 20px;
  cursor: pointer;
}
.btn-signout:hover { color: var(--text); border-color: var(--text-faint); }

/* Auth gate - full-screen overlay shown until someone signs in */
.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.auth-card {
  width: 100%;
  max-width: 320px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.auth-title { font-size: 19px; font-weight: 700; letter-spacing: -0.01em; }
.auth-sub { color: var(--text-dim); font-size: 13px; margin-bottom: 8px; }
.auth-card input {
  background: var(--panel-alt);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
}
.auth-card input:focus { outline: 1px solid var(--accent); border-color: var(--accent); }
.auth-card button[type="submit"] {
  margin-top: 6px;
  background: var(--accent-bg);
  color: var(--accent-text);
  border: none;
  border-radius: 8px;
  padding: 11px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.auth-card button[type="submit"]:disabled { opacity: 0.6; cursor: default; }
.auth-error { color: var(--accent); font-size: 12.5px; min-height: 15px; }

/* KPI strip */
.kpi-strip {
  display: grid;
  gap: 10px;
  margin-bottom: 10px;
}
.kpi-strip-primary {
  grid-template-columns: repeat(3, 1fr);
}
.kpi-strip-secondary {
  grid-template-columns: repeat(5, 1fr);
  margin-bottom: 18px;
}
.kpi-strip-quad {
  grid-template-columns: repeat(4, 1fr);
  margin-bottom: 18px;
}
.kpi-strip-quad .kpi-card { padding: 16px 16px 14px; }
.kpi-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 14px 12px;
  position: relative;
}
.kpi-strip-primary .kpi-card { padding: 18px 18px 16px; }
.kpi-strip-secondary .kpi-card { padding: 12px 12px 10px; }

/* KPI tooltips - coaching context/takeaways per metric. Hover on desktop;
   tap toggles .tooltip-open on touch devices (wired in app.js/trends.js). */
.kpi-card[data-tooltip] { cursor: help; }
.kpi-info-icon {
  position: absolute;
  top: 8px;
  right: 9px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid var(--text-faint);
  color: var(--text-faint);
  font-size: 9.5px;
  font-weight: 700;
  line-height: 12px;
  text-align: center;
  font-style: normal;
  user-select: none;
}
.kpi-card[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  bottom: 100%;
  transform: translateX(-50%) translateY(4px);
  margin-bottom: 10px;
  width: 230px;
  max-width: 75vw;
  background: var(--panel-alt);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 11.5px;
  font-weight: 400;
  line-height: 1.5;
  text-transform: none;
  letter-spacing: normal;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.12s ease, transform 0.12s ease;
  z-index: 50;
  pointer-events: none;
}
.kpi-card[data-tooltip]::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 100%;
  transform: translateX(-50%) translateY(4px);
  margin-bottom: 3px;
  border: 6px solid transparent;
  border-top-color: var(--panel-alt);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.12s ease;
  z-index: 50;
}
.kpi-card[data-tooltip]:hover::after,
.kpi-card[data-tooltip]:hover::before,
.kpi-card[data-tooltip].tooltip-open::after,
.kpi-card[data-tooltip].tooltip-open::before {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}
.kpi-value {
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.01em;
}
.kpi-strip-primary .kpi-value { font-size: 27px; }
.kpi-strip-secondary .kpi-value { font-size: 25px; }
.kpi-value small { font-size: 12.5px; font-weight: 500; color: var(--text-dim); }
.kpi-strip-secondary .kpi-value small { font-size: 13px; }
/* Training status shows a word ("Unproductive"), not a short number - sized
   down from the numeric secondary-row values so long statuses still fit,
   but still noticeably bigger than before. */
.kpi-value-status { font-size: 19px; text-transform: capitalize; }
.kpi-label {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 3px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.kpi-flag {
  display: inline-block;
  margin-top: 8px;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 20px;
  font-weight: 600;
}
.kpi-flag.good { background: var(--good-bg); color: var(--good-text); }
.kpi-flag.warn { background: var(--warn-bg); color: var(--warn-text); }
.kpi-flag.bad { background: var(--bad-bg); color: var(--bad-text); }

.kpi-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  gap: 6px;
}
.kpi-spark { flex: 0 0 auto; line-height: 0; }
.sparkline { display: block; }

.kpi-pace-range {
  font-size: 10.5px;
  color: var(--text-dim);
  margin-top: 4px;
  white-space: nowrap;
}

/* Cards with a sparkline (Resting HR, Lactate threshold) - the sparkline
   sits inline, vertically centered next to its number, instead of alone in
   a footer row below everything else where it used to look disconnected
   from the rest of the card. */
.kpi-card-spark {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.kpi-card-main { flex: 1 1 auto; min-width: 0; }
.kpi-card-spark .kpi-spark { margin-top: 2px; }

/* Bar gauge (VO2max, Load tolerance) - a slim horizontal bar with colored
   range segments and a small triangle marking the current reading, instead
   of the old semicircular speedometer, to take up less vertical space. */
.kpi-card-gauge { text-align: left; }
.kpi-gauge { margin: 10px 0 2px; line-height: 0; }
.gauge-svg { display: block; width: 100%; height: auto; }
.kpi-card-gauge .kpi-flag { margin-top: 2px; }

.status-dots { display: flex; gap: 3px; align-items: center; }
.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
}
.status-dot.good { background: var(--good); }
.status-dot.warn { background: var(--warn); }
.status-dot.bad { background: var(--bad); }

@media (max-width: 640px) {
  .kpi-strip-primary { grid-template-columns: repeat(3, 1fr); }
  .kpi-strip-secondary { grid-template-columns: repeat(2, 1fr); }
  .kpi-strip-quad { grid-template-columns: repeat(2, 1fr); }
  .kpi-strip-primary .kpi-value { font-size: 18px; }
  .kpi-strip-primary .kpi-card { padding: 12px 10px 10px; }
}

/* Panels */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 18px 20px;
  margin-bottom: 14px;
}
.panel h2 { margin: 0 0 6px; font-size: 17px; }
.panel-kicker {
  font-size: 10.5px;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  text-transform: uppercase;
  margin-bottom: 4px;
}
.panel-sub { color: var(--text-dim); font-size: 13px; margin: 0 0 14px; }

/* Top-level page nav (multi-page site) */
.site-nav {
  display: flex;
  gap: 6px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.site-nav a {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-dim);
  text-decoration: none;
  border: 1px solid var(--border);
  background: var(--panel);
  padding: 6px 12px;
  border-radius: 20px;
}
.site-nav a.active { color: var(--accent-text); background: var(--accent-bg); border-color: transparent; }

/* Week nav - prev/next arrows stepping one week at a time */
.week-nav-panel { padding: 10px 14px; }
.week-nav {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
}
.week-nav-controls {
  display: flex;
  align-items: center;
  gap: 16px;
}
.week-nav-arrow {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--panel-alt);
  color: var(--text);
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.week-nav-arrow:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.week-nav-arrow:disabled { opacity: 0.3; cursor: default; }
.week-nav-current {
  flex: 0 1 auto;
  text-align: center;
  min-width: 168px;
}
.wn-num {
  display: block;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text);
}
.wn-current-badge {
  margin-left: 7px;
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--good);
}
.wn-label {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 2px;
}
.week-nav-today {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  flex: 0 0 auto;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-faint);
  font-size: 11px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 20px;
  cursor: pointer;
}
.week-nav-today:hover { color: var(--text); border-color: var(--text-faint); }

/* Week detail */
.week-detail-head {
  position: sticky;
  top: var(--sticky-header-height, 96px);
  z-index: 10;
  background: var(--panel);
  margin: -18px -18px 14px;
  padding: 18px 18px 12px;
  border-radius: var(--radius) var(--radius) 0 0;
}
.week-detail-head .block-pill {
  display: inline-block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent-text);
  background: var(--accent-bg);
  padding: 3px 9px;
  border-radius: 20px;
  margin-bottom: 8px;
}
.week-detail-head h2 { font-size: 19px; margin: 0 0 4px; }
.week-detail-head .focus { color: var(--text-dim); font-size: 13.5px; }
.week-target { color: var(--text-dim); font-size: 13px; margin-top: 6px; }

.day-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}
.day-card {
  border: 1px solid var(--border);
  background: var(--panel-alt);
  border-radius: 8px;
  padding: 12px 13px;
}
.day-card-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  row-gap: 2px;
  margin-bottom: 8px;
  cursor: pointer;
  user-select: none;
}
.day-card.is-collapsed .day-card-head { margin-bottom: 0; }
.day-name { font-weight: 650; font-size: 13.5px; }
.day-name-group { display: flex; align-items: center; gap: 6px; }
.day-chevron {
  display: inline-block;
  color: var(--text-faint);
  font-size: 10px;
  transition: transform 0.15s ease;
}
.day-card.is-collapsed .day-chevron { transform: rotate(-90deg); }
.day-date { color: var(--text-faint); font-size: 11.5px; }
.day-weather {
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  cursor: help;
}
.day-summary { color: var(--text-faint); font-size: 11.5px; }
.day-card.is-today { border-color: var(--accent); }
.day-card.is-collapsed .day-grid-inner { display: none; }

.session {
  display: flex;
  gap: 10px;
  padding: 7px 0;
  border-top: 1px solid var(--border);
}
.session:first-child { border-top: none; padding-top: 0; }
.session-check {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  border-radius: 5px;
  border: 1.5px solid var(--text-faint);
  margin-top: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  cursor: default;
  user-select: none;
}
.session-check.checkable { cursor: pointer; }
.session-check.checkable:hover { border-color: var(--accent); }
.session-check.done { background: var(--good); border-color: var(--good); color: var(--panel); }
.session-check.done.auto { background: var(--accent); border-color: var(--accent); color: var(--panel); }
.session-no-check { width: 18px; flex: 0 0 auto; }
.session-body { flex: 1; min-width: 0; }
.session-title-row {
  display: flex;
  gap: 8px;
  align-items: baseline;
  flex-wrap: wrap;
}
.session-title { font-weight: 600; font-size: 13.5px; }
.session-tag {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 1px 6px;
  border-radius: 20px;
  background: var(--panel);
  color: var(--text-dim);
  border: 1px solid var(--border);
}
.session-tag.kind-race { background: var(--bad-bg); color: var(--bad-text); border-color: transparent; }
.session-tag.kind-long { background: var(--tag-long-bg); color: var(--tag-long-text); border-color: transparent; }
.session-tag.kind-tempo, .session-tag.kind-intervals, .session-tag.kind-mp { background: var(--warn-bg); color: var(--warn-text); border-color: transparent; }

.workout-download {
  font-size: 10px;
  font-weight: 600;
  text-decoration: none;
  color: var(--accent-text);
  background: var(--accent-bg);
  padding: 2px 8px;
  border-radius: 20px;
  white-space: nowrap;
}
.workout-download:hover { opacity: 0.85; }
.session-meta { color: var(--text-dim); font-size: 12.5px; margin-top: 2px; }
.session-details { color: var(--text-dim); font-size: 12.5px; margin-top: 4px; }
.session-note {
  margin-top: 5px;
  font-size: 12px;
  color: var(--text-dim);
  background: var(--panel);
  border-left: 2px solid var(--accent);
  padding: 5px 8px;
  border-radius: 0 4px 4px 0;
}
.session-actual {
  margin-top: 5px;
  font-size: 12px;
  color: var(--good);
}
.exercise-list { margin: 2px 0 0; padding-left: 0; list-style: none; font-size: 12.5px; color: var(--text-dim); }
.exercise-list li { padding: 2px 0; }
.exercise-list b { color: var(--text); }

/* PT / prehab reference page */
.exercise-category { margin-bottom: 22px; }
.exercise-category:last-child { margin-bottom: 0; }
.exercise-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.exercise-card {
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.exercise-card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.exercise-card-name { font-weight: 650; font-size: 14.5px; }
.exercise-card-prescription {
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
}
.exercise-card-howto { font-size: 13px; color: var(--text-dim); line-height: 1.55; }
.exercise-card-foot { margin-top: 8px; }
.exercise-card-equipment {
  font-size: 11px;
  color: var(--text-faint);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2px 9px;
  display: inline-block;
}
.exercise-card-cue {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-dim);
  background: var(--panel);
  border-left: 2px solid var(--accent);
  padding: 5px 8px;
  border-radius: 0 4px 4px 0;
}

@media (max-width: 640px) {
  .exercise-grid { grid-template-columns: 1fr; }
}

/* Workout files repository page */
.workout-week-group { margin-bottom: 22px; }
.workout-week-group:last-child { margin-bottom: 0; }
.workout-week-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 14px;
}
.workout-week-head .panel-kicker { flex-basis: 100%; margin-bottom: 0; }
.workout-week-head h2 { margin: 0; font-size: 16px; flex: 1; min-width: 0; }
.btn-zip {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-text);
  background: var(--accent-bg);
  border: none;
  padding: 7px 13px;
  border-radius: 20px;
  cursor: pointer;
  white-space: nowrap;
}
.btn-zip:hover { opacity: 0.85; }
.btn-zip:disabled { opacity: 0.6; cursor: default; }
.workout-download-all { margin-bottom: 18px; }
.btn-zip-all { background: var(--good-bg); color: var(--good-text); }

.workout-file-list { display: flex; flex-direction: column; gap: 6px; }
.workout-file-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
}
.workout-file-row:hover { border-color: var(--accent); }
.workout-file-date { font-size: 12px; color: var(--text-faint); flex: 0 0 auto; min-width: 78px; }
.workout-file-name { font-size: 13.5px; font-weight: 600; flex: 1; min-width: 0; }
.workout-file-dl { font-size: 11.5px; color: var(--accent); flex: 0 0 auto; }

@media (max-width: 640px) {
  .workout-week-head h2 { flex-basis: 100%; }
  .workout-file-row { flex-wrap: wrap; }
}

/* Coach notes */
.coach-notes .panel-kicker { color: var(--accent); }
.coach-notes h2 { font-size: 17px; }
.coach-note-item {
  display: flex;
  gap: 10px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
  font-size: 13.5px;
  color: var(--text-dim);
}
.coach-note-item:first-child { border-top: none; }
.coach-note-num {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent-bg);
  color: var(--accent-text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
}

/* KPI-ish inline blocks used in retro / race-log panels */
.mini-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.mini-stat { background: var(--panel-alt); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }
.mini-stat .v { font-size: 19px; font-weight: 650; }
.mini-stat .l { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.04em; margin-top: 2px; }

table.simple { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.simple th {
  text-align: left;
  color: var(--text-faint);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 10.5px;
  letter-spacing: 0.04em;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
}
table.simple td { padding: 7px 8px; border-bottom: 1px solid var(--border); color: var(--text-dim); }
table.simple tr:last-child td { border-bottom: none; }
table.simple td.strong { color: var(--text); font-weight: 600; }

.chart-panel { position: relative; }
.chart-panel canvas { width: 100% !important; height: 320px !important; }
@media (max-width: 640px) {
  .chart-panel canvas { height: 240px !important; }
}

/* Custom legend (replaces Chart.js's built-in one, which ate into plot
   space and looked cramped) - a simple row of colored dot + label chips
   sitting between the panel description and the chart itself. Built in JS
   (renderCharts()) since the dataset colors and labels already live there. */
.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin-bottom: 10px;
}
.chart-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-dim);
  position: relative;
}
.chart-legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: 0 0 auto;
}

/* Recent-readings tooltip on hoverable legend chips (HRV/RHR/ATL/CTL/ACWR) -
   same visual language as the KPI card tooltips (.kpi-card[data-tooltip]),
   but anchored to open below-left instead of centered-above: these chips
   sit right under the panel header with little room above, and near the
   left/right panel edges where a centered bubble would overflow. Content is
   rebuilt every render from the live data (see seriesTooltip() in app.js),
   so it's never stale copy. */
.chart-legend-item-hoverable { cursor: help; }
.chart-legend-item-hoverable .kpi-info-icon { position: static; margin-left: 1px; }
.chart-legend-item-hoverable[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 0;
  top: 100%;
  transform: translateY(-4px);
  margin-top: 10px;
  width: 240px;
  max-width: 80vw;
  background: var(--panel-alt);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 11.5px;
  font-weight: 400;
  line-height: 1.5;
  text-transform: none;
  letter-spacing: normal;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.12s ease, transform 0.12s ease;
  z-index: 50;
  pointer-events: none;
}
.chart-legend-item-hoverable[data-tooltip]::before {
  content: "";
  position: absolute;
  left: 10px;
  top: 100%;
  transform: translateY(-4px);
  margin-top: 3px;
  border: 6px solid transparent;
  border-bottom-color: var(--panel-alt);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.12s ease;
  z-index: 50;
}
.chart-legend-item-hoverable[data-tooltip]:hover::after,
.chart-legend-item-hoverable[data-tooltip]:hover::before,
.chart-legend-item-hoverable[data-tooltip].tooltip-open::after,
.chart-legend-item-hoverable[data-tooltip].tooltip-open::before {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.page-footer {
  text-align: center;
  color: var(--text-faint);
  font-size: 11.5px;
  margin-top: 30px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

@media (max-width: 640px) {
  .mini-grid { grid-template-columns: repeat(1, 1fr); }
  .wrap { padding: 18px 12px 40px; }
  .page-header h1 { font-size: 23px; }
  .page-header { flex-wrap: wrap; }
}

/* Completion trends - calendar heatmap */
.cal-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 11.5px;
  color: var(--text-dim);
  margin-bottom: 14px;
}
.cal-legend span { display: flex; align-items: center; gap: 5px; }
.cal-grid { display: flex; flex-direction: column; gap: 5px; }
.cal-row { display: flex; align-items: center; gap: 10px; }
.cal-row-label {
  flex: 0 0 auto;
  min-width: 92px;
  font-size: 11.5px;
  color: var(--text-dim);
  font-weight: 600;
}
.cal-row-label small { font-weight: 400; color: var(--text-faint); text-transform: capitalize; }
.cal-row-cells { display: flex; gap: 4px; flex-wrap: wrap; }
.cal-cell {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  display: inline-block;
  border: 1px solid var(--border);
}
.cal-full { background: var(--good); border-color: var(--good); }
.cal-partial { background: var(--warn); border-color: var(--warn); }
.cal-none { background: var(--bad); border-color: var(--bad); }
.cal-rest { background: var(--panel-alt); }
.cal-upcoming { background: transparent; border-style: dashed; }

@media (max-width: 640px) {
  .cal-row { flex-wrap: wrap; }
  .cal-row-label { min-width: 100%; }
}
