:root {
  --bg: #0E1113;
  --surface: #16191C;
  --surface-raised: #1B1F22;
  --line: #262B2F;
  --text: #ECEFF0;
  --text-muted: #8B939A;
  --accent: #C6F135;
  --accent-dim: #7C8A2A;

  --z1: #4A5560; /* recovery */
  --z2: #3E7CB1; /* endurance */
  --z3: #4FA65B; /* tempo */
  --z4: #E0B03E; /* threshold */
  --z5: #E0743E; /* vo2 max */
  --z6: #C6453E; /* anaerobic */

  --font-display: "Oswald", sans-serif;
  --font-body: "Inter", sans-serif;
  --font-mono: "JetBrains Mono", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  height: 100%;
}

.hidden { display: none !important; }

/* ---------- Passcode screen ---------- */
.passcode-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.passcode-box {
  width: 100%;
  max-width: 320px;
  text-align: center;
}
.passcode-label {
  font-family: var(--font-display);
  letter-spacing: 0.12em;
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 24px;
}
#passcode-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 18px;
  padding: 14px 16px;
  text-align: center;
  letter-spacing: 0.2em;
  border-radius: 2px;
  margin-bottom: 12px;
}
#passcode-input:focus { outline: 2px solid var(--accent); }
#passcode-submit {
  width: 100%;
  background: var(--accent);
  color: #0E1113;
  border: none;
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: 0.08em;
  padding: 14px;
  border-radius: 2px;
  cursor: pointer;
}
.passcode-error { color: var(--z6); font-size: 13px; margin-top: 10px; min-height: 16px; }

/* ---------- App shell ---------- */
.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
  position: relative;
}

/* ---------- Pages / tabs ---------- */
.page { display: none; }
.page.page-active { display: block; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: calc(env(safe-area-inset-top) + 16px) 20px 12px;
  position: sticky;
  top: 0;
  background: linear-gradient(to bottom, var(--bg) 80%, transparent);
  z-index: 5;
}
.brand {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.brand span { color: var(--accent); }
.conn-status {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.conn-status.ok { color: var(--z3); }
.conn-status.error { color: var(--z6); }

.main { padding: 8px 16px 0; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 3px;
}

/* ---------- Hero / FTP gauge ---------- */
.hero {
  position: relative; /* anchors an optional top-right .info-btn/.info-popover */
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 20px;
}
.hero-gauge {
  position: relative;
  width: 220px;
  height: 220px;
}
.ftp-ring { width: 100%; height: 100%; }
.hero-center {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.ftp-value {
  font-family: var(--font-display);
  font-size: 56px;
  font-weight: 700;
  line-height: 1;
  color: var(--accent);
}
.ftp-unit {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-top: 6px;
}
.hero-meta {
  margin-top: 18px;
  text-align: center;
  width: 100%;
}
.ftp-confidence {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.ftp-note {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.4;
  max-width: 320px;
  margin: 0 auto;
}
/* ---------- Info button / popover ---------- */
/* Reusable "(i) button in a widget's top-right corner" pattern - reach for
   this for any future widget that needs a short explanation tucked away
   rather than always-visible. Requires the containing widget to have
   `position: relative` (already true of `.hero`). */
.info-btn {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface-raised);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 12px;
  font-style: italic;
  line-height: 1;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s ease, border-color 0.15s ease;
  z-index: 6;
}
.info-btn:active,
.info-btn.active {
  color: var(--accent);
  border-color: var(--accent-dim);
}
.info-popover {
  position: absolute;
  top: 42px;
  right: 14px;
  width: 220px;
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 12px 14px;
  font-family: var(--font-body);
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-muted);
  text-align: left;
  z-index: 5;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
}
.info-popover.hidden { display: none; }

/* ---------- Training load classification scale ---------- */
.load-scale {
  width: 100%;
  margin-top: 16px;
}
.load-scale-track {
  position: relative;
  display: flex;
  height: 8px;
  border-radius: 4px;
  overflow: visible;
  background: var(--surface-raised);
}
.load-scale-seg {
  height: 100%;
  opacity: 0.35;
  transition: opacity 0.15s ease;
}
.load-scale-seg.active { opacity: 1; }
.load-scale-seg-1 { background: var(--z6); border-radius: 4px 0 0 4px; }
.load-scale-seg-2 { background: var(--z5); }
.load-scale-seg-3 { background: var(--z2); }
.load-scale-seg-4 { background: var(--accent); border-radius: 0 4px 4px 0; }
.load-scale-marker {
  position: absolute;
  top: -4px;
  width: 2px;
  height: 16px;
  background: var(--text);
  transform: translateX(-1px);
  transition: left 0.2s ease;
}
.load-scale-marker.hidden { display: none; }
.load-scale-labels {
  display: flex;
  margin-top: 8px;
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  text-transform: uppercase;
}
.load-scale-labels span { flex: 1; text-align: center; }
.load-scale-labels span:first-child { text-align: left; }
.load-scale-labels span:last-child { text-align: right; }

.zone-legend {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
}
.zone-chip {
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
}
.zone-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* ---------- Dashboard progress widget ---------- */
.progress-widget {
  padding: 16px 16px 18px;
  margin-bottom: 20px;
}
.progress-ring-wrap {
  position: relative;
  width: 190px;
  height: 190px;
  margin: 4px auto 18px;
}
.progress-ring { width: 100%; height: 100%; }
.progress-ring-track {
  fill: none;
  stroke: var(--line);
}
.progress-ring-arc {
  fill: none;
  stroke: var(--accent);
}
.progress-ring-arc.complete { stroke: var(--z3); }
.progress-ring-tick {
  stroke: var(--text-muted);
  stroke-width: 2;
}
.progress-ring-center {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.progress-ring-value {
  font-family: var(--font-display);
  font-size: 34px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}
.progress-ring-pct {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
  letter-spacing: 0.04em;
}
.progress-targets {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.progress-target {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 4px 2px;
}
.progress-target-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}
.progress-target-dot.maintaining { background: var(--text-muted); }
.progress-target-dot.average { background: var(--accent); }
.progress-target-label {
  flex: 1;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 11px;
}
.progress-target-value { color: var(--text); }
.progress-target.reached .progress-target-value { color: var(--z3); }

/* ---------- Overview ---------- */
.section-label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  margin: 0 4px 10px;
}
.overview {
  padding: 16px 16px 18px;
  margin-bottom: 20px;
}
.overview-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.stat-card {
  /* Nested inside the .overview card itself, so these use the "raised"
     surface tone rather than their own separate border - avoids a
     card-within-a-card look now that .overview is one bordered tile. */
  background: var(--surface-raised);
  border-radius: 3px;
  padding: 14px 16px;
}
.stat-card-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 8px;
}
.stat-row {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 3px 0;
}
.stat-row .v { color: var(--text); }
.stat-row .k { color: var(--text-muted); }

/* ---------- Progress page date range selector ---------- */
.range-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}
.range-tab {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.03em;
  padding: 9px 4px;
  border-radius: 3px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.range-tab:active { opacity: 0.8; }
.range-tab.active {
  color: var(--accent);
  border-color: var(--accent-dim);
  background: var(--surface-raised);
}

/* ---------- Progress page: single-widget grouping ---------- */
/* Wraps the range selector + weekly chart + week-detail tile in one bordered
   widget (see CLAUDE.md / DECISIONS.md) now that the Progress page has grown
   additional widgets (FTP trend, HR zones) alongside it. */
.progress-widget-group {
  padding: 16px 16px 18px;
  margin-bottom: 20px;
}
.widget-divider {
  border-top: 1px solid var(--line);
  margin: 18px 0;
}

/* ---------- Progress page: HR Zone Analysis widget ---------- */
/* Same padding/margin as the other Progress-page widgets (.progress-widget-
   group, .hero) - previously relied on bare .card with no padding of its
   own, which squashed the section label and doubled up borders with the
   nested .hr-zones-list box below. */
.hr-zone-analysis {
  padding: 16px 16px 18px;
  margin-bottom: 20px;
}

/* ---------- Weekly chart ---------- */
.weekly {
  padding: 14px 16px 16px;
  margin-bottom: 20px;
}
.weekly-svg {
  width: 100%;
  height: auto;
  margin-top: 4px;
}
.weekly-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 4px;
}
.weekly-tab, .ftp-trend-tab, .best-efforts-tab {
  flex: 1;
  background: var(--surface-raised);
  border: 1px solid var(--line);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 8px 6px;
  border-radius: 3px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.weekly-tab:active, .ftp-trend-tab:active, .best-efforts-tab:active { opacity: 0.8; }
.weekly-tab.active, .ftp-trend-tab.active, .best-efforts-tab.active {
  color: var(--accent);
  border-color: var(--accent-dim);
}
.weekly-bar { fill: var(--accent); }
.weekly-bar.empty { fill: var(--line); }
.weekly-avg-line { stroke: var(--text-muted); stroke-width: 1; stroke-dasharray: 4 3; }
.weekly-avg-label {
  fill: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 8px;
}
.weekly-axis { stroke: var(--line); stroke-width: 1; }
.weekly-gridline { stroke: var(--line); stroke-width: 0.5; }
.weekly-tick {
  fill: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 9px;
}

.weekly-x-tick {
  stroke: #999;
  stroke-width: 1;
  opacity: 0.6;
}

.weekly-x-label {
  fill: #999;
  font-size: 10px;
}

.weekly-month-label {
  fill: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.weekly-month-divider {
  stroke: var(--line);
  stroke-opacity: 0.8;
  stroke-width: 1;
}

.weekly-point {
  r: 3.5px;
  cursor: pointer;
  transition: r 0.15s ease, fill 0.15s ease, stroke-width 0.15s ease;
}
.weekly-point-hit {
  fill: transparent;
  cursor: pointer;
}
.weekly-point.selected {
  r: 6.5px;
  fill: var(--text);
  stroke: var(--accent);
  stroke-width: 3px;
}
.weekly-point-halo {
  fill: var(--accent);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, r 0.15s ease;
  r: 8px;
}
.weekly-point-halo.visible {
  opacity: 0.22;
  r: 13px;
}

/* ---------- Week detail tile ---------- */
.week-detail {
  padding: 14px 16px 16px;
  margin-bottom: 20px;
}
.week-detail-range {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text);
  margin: -2px 0 12px 0;
}
.week-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}
.week-stat {
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 12px 8px;
  text-align: center;
}
.week-stat-value {
  font-family: var(--font-mono);
  font-size: 17px;
  color: var(--accent);
}
.week-stat-label {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 5px;
}

/* ---------- Progress page: Best Efforts widget ---------- */
.best-efforts-list { margin-top: 4px; }
.best-effort-item { border-top: 1px solid var(--line); }
.best-effort-item:first-child { border-top: none; }
.best-effort-summary {
  width: 100%;
  display: flex;
  flex-direction: column;
  background: none;
  border: none;
  padding: 12px 4px;
  cursor: pointer;
  text-align: left;
  color: var(--text);
  font-family: var(--font-body);
}
.best-effort-item.empty .best-effort-summary { cursor: default; opacity: 0.5; }
.best-effort-summary-top {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
}
.best-effort-label {
  flex: 1;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
}
.best-effort-value-wrap { text-align: right; }
.best-effort-value {
  display: block;
  font-family: var(--font-mono);
  font-size: 15px;
  color: var(--accent);
}
.best-effort-date {
  display: block;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
}
/* Distance/avg-speed line under a distance-mode summary row - power mode
   never renders this element, so its rows stay visually unchanged. */
.best-effort-sub {
  display: flex;
  gap: 12px;
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}
.best-effort-caret {
  color: var(--text-muted);
  font-size: 11px;
  width: 12px;
  text-align: center;
  transition: transform 0.15s ease;
}
.best-effort-item.expanded .best-effort-caret { transform: rotate(180deg); }
.best-effort-ranked { padding: 0 4px 12px; }
.best-effort-ranked.hidden { display: none; }
.best-effort-rank-row {
  display: flex;
  flex-direction: column;
  padding: 8px 10px;
  border-radius: 3px;
  background: var(--surface-raised);
  margin-bottom: 6px;
  cursor: pointer;
  transition: background 0.15s ease;
}
.best-effort-rank-row:last-child { margin-bottom: 0; }
.best-effort-rank-row:active, .best-effort-rank-row:hover { background: var(--line); }
.best-effort-rank-top {
  display: flex;
  align-items: center;
  gap: 10px;
}
.best-effort-rank-num {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  width: 14px;
}
.best-effort-rank-value {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text);
  flex: 1;
}
.best-effort-rank-date {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}
/* Distance/avg-speed line under a distance-mode rank row - indented to
   align under the value column rather than the rank number (14px num
   width + 10px gap from .best-effort-rank-top). */
.best-effort-rank-sub {
  display: flex;
  gap: 10px;
  margin-top: 4px;
  padding-left: 24px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
}

/* ---------- Recent rides ---------- */
.recent { margin-bottom: 12px; }
.recent-list {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 3px;
  overflow: hidden;
}
.ride-row {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background 0.15s ease;
}
.ride-row:last-child { border-bottom: none; }
.ride-row:active, .ride-row:hover { background: var(--surface-raised); }
.ride-row-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.ride-row-sub {
  display: flex;
  gap: 12px;
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}
.ride-date {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  width: 64px;
  flex-shrink: 0;
}
.ride-name { flex: 1; font-size: 13px; padding: 0 10px; }
.ride-power {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--accent);
  text-align: right;
  width: 70px;
  flex-shrink: 0;
}
.empty-state {
  padding: 24px 16px;
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
}

.load-more-btn {
  width: 100%;
  margin-top: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 12px;
  border-radius: 3px;
  cursor: pointer;
  transition: background 0.15s ease;
}
.load-more-btn:hover,
.load-more-btn:active {
  background: var(--surface-raised);
}

/* ---------- Settings page ---------- */
.settings-page {
  padding: 16px 16px 18px;
  margin-bottom: 20px;
}
.settings-action {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 0;
}
.settings-action-copy {
  flex: 1;
  min-width: 0;
}
.settings-action-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 3px;
}
.settings-action-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}
.settings-action-btn {
  /* .load-more-btn is full-width by default; here it sits inline next to
     the row's description text instead. */
  width: auto;
  flex-shrink: 0;
  margin-top: 0;
  padding: 10px 16px;
}
.settings-action-status {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  min-height: 14px;
  margin: -4px 0 4px;
}
.settings-action-status.ok { color: var(--z3); }
.settings-action-status.error { color: var(--z6); }

/* ---------- Settings page: Best Efforts reindex progress ---------- */
/* Swaps in for the "Redownload all Wahoo data" row while a run is active
   (see renderBestEffortsSettingsTile in app.js) - deliberately reuses the
   surrounding .settings-page card rather than introducing a separate card
   component, so it reads as the same row changing state, not a different
   widget appearing. */
.reindex-progress {
  padding: 10px 0 14px;
}
.reindex-progress-label {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
}
.reindex-progress-count {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.reindex-progress-bar-wrap {
  width: 100%;
  height: 8px;
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 8px;
}
.reindex-progress-bar {
  height: 100%;
  background: var(--accent);
  transition: width 0.3s ease;
}
.reindex-progress-meta {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}
.reindex-progress-current {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 8px;
}

/* ---------- Progress page: Best Efforts indexing hint ---------- */
.best-efforts-indexing-hint {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 8px 10px;
  margin-bottom: 10px;
}
.best-efforts-indexing-hint.hidden { display: none; }
.connect-banner {
  position: fixed;
  top: 0; left: 0; right: 0;
  background: var(--z5);
  color: #14100A;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  z-index: 20;
}
.connect-btn {
  background: #14100A;
  color: var(--z5);
  padding: 6px 12px;
  border-radius: 2px;
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
}

/* ---------- Ride detail overlay ---------- */
.ride-detail {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 30;
  max-width: 480px;
  margin: 0 auto;
  overflow-y: auto;
}
.ride-detail-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(env(safe-area-inset-top) + 16px) 16px 12px;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 2;
}
.ride-detail-close {
  background: none;
  border: none;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 13px;
  cursor: pointer;
  padding: 4px 0;
}
.ride-detail-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
}
.ride-detail-map-wrap {
  margin: 0 16px 16px;
  border-radius: 3px;
  overflow: hidden;
  border: 1px solid var(--line);
}
.ride-map {
  width: 100%;
  height: 240px;
  background: var(--surface);
}
.ride-detail-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 0 16px 24px;
}
.ride-detail-highlight-banner {
  margin: -12px 16px 20px;
  padding: 10px 12px;
  background: var(--surface-raised);
  border: 1px solid var(--accent-dim);
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.03em;
  color: var(--accent);
  text-align: center;
}
.ride-detail-highlight-banner.hidden { display: none; }
.ride-stat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 14px 16px;
  text-align: center;
}
.ride-stat-value {
  font-family: var(--font-mono);
  font-size: 20px;
  color: var(--accent);
}
.ride-stat-label {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 4px;
}

/* ---------- Heart rate zones ---------- */
/* Wraps an .activity-graph.card tile (see index.html), matching the same
   card pattern as the activity performance graphs below it - horizontal
   page padding lives here, the card border/background lives on the child. */
.ride-detail-hr-zones {
  padding: 0 16px 10px;
}
.hr-zones-list {
  /* No border/background of its own - it's always nested inside a .card
     container now (either .hr-zone-analysis on the Progress page, or the
     .activity-graph.card wrapper here), which already provides the border. */
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.hr-zone-row {
  display: grid;
  /* Label column widened from 110px so "Zone 2 - Endurance" (the longest
     name + description strings) fits on one line instead of wrapping - see
     the `white-space: nowrap` on .hr-zone-name below, which is what
     actually guarantees this now rather than just hoping it fits. */
  grid-template-columns: 126px 1fr 46px 34px;
  align-items: center;
  gap: 8px;
}
.hr-zone-label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.01em;
}
.hr-zone-name {
  white-space: nowrap;
}
.hr-zone-range {
  font-size: 9px;
  opacity: 0.7;
}
.hr-zone-bar-wrap {
  background: var(--surface-raised);
  border-radius: 2px;
  height: 8px;
  overflow: hidden;
}
.hr-zone-bar {
  height: 100%;
  border-radius: 2px;
  background: var(--accent);
}
.hr-zone-row:nth-child(1) .hr-zone-bar { background: var(--z1); }
.hr-zone-row:nth-child(2) .hr-zone-bar { background: var(--z2); }
.hr-zone-row:nth-child(3) .hr-zone-bar { background: var(--z3); }
.hr-zone-row:nth-child(4) .hr-zone-bar { background: var(--z4); }
.hr-zone-row:nth-child(5) .hr-zone-bar { background: var(--z5); }
.hr-zone-time {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text);
  text-align: right;
}
.hr-zone-pct {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  text-align: right;
}

/* ---------- Activity detail performance graphs ---------- */
.ride-detail-graphs {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0 16px 24px;
}
.activity-graph {
  padding: 12px 14px 10px;
}
.activity-graph-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;
}
.activity-graph-label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.activity-graph-svg {
  width: 100%;
  height: 84px;
  display: block;
}
.activity-graph-gridline { stroke: var(--line); stroke-width: 0.5; }
.activity-graph-tick {
  fill: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 8px;
}
.activity-graph-elevation {
  fill: none;
  stroke: var(--text-muted);
  stroke-width: 1.25;
  stroke-opacity: 0.35;
}
/* Shaded band marking a Best Efforts time window - see buildLineGraphSvg's
   highlightRange param in app.js. Drawn first (behind the gridlines/line),
   so a low opacity fill is enough to read as a highlight without
   obscuring the data on top of it. */
.activity-graph-highlight {
  fill: var(--accent);
  opacity: 0.16;
}
.activity-graph-stats {
  display: flex;
  gap: 16px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}
.activity-graph-stat {
  display: flex;
  align-items: baseline;
  gap: 5px;
  font-family: var(--font-mono);
  font-size: 12px;
}
.activity-graph-stat .k {
  color: var(--text-muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.activity-graph-stat .v { color: var(--text); }

/* ---------- Ask AI chat page ---------- */
.chat-page {
  padding: 14px 16px 16px;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 220px);
}
.chat-log {
  flex: 1;
  min-height: 240px;
  overflow-y: auto;
  padding: 4px 0 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.chat-msg {
  font-size: 13px;
  line-height: 1.4;
  padding: 8px 12px;
  border-radius: 8px;
  max-width: 85%;
}
.chat-msg-assistant {
  background: var(--surface-raised);
  color: var(--text);
  align-self: flex-start;
}
.chat-msg-user {
  background: var(--accent-dim);
  color: var(--text);
  align-self: flex-end;
}
.chat-form {
  display: flex;
  gap: 8px;
  padding: 12px 0 0;
  border-top: 1px solid var(--line);
}
#chat-input {
  flex: 1;
  background: var(--surface-raised);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 13px;
}
.chat-form button {
  background: var(--accent);
  color: #0E1113;
  border: none;
  padding: 10px 16px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}

/* ---------- Bottom navigation ---------- */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  background: var(--surface-raised);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 25;
}
.nav-tab {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 4px 8px;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  transition: color 0.15s ease;
}
.nav-icon {
  width: 22px;
  height: 22px;
}
.nav-tab.active {
  color: var(--accent);
}
.nav-tab:active {
  opacity: 0.75;
}

@media (prefers-reduced-motion: reduce) {
  .nav-tab, .weekly-point, .weekly-point-halo { transition: none; }
}
