:root {
  /* Base colors */
  --bg-primary: #0a0a0b;
  --bg-secondary: #141416;
  --bg-tertiary: #1c1c1f;
  --bg-card: #18181b;
  color-scheme: dark;

  /* Text */
  --text-primary: #e4e4e7;
  --text-secondary: #a1a1aa;
  --text-muted: #8b8b93;   /* 5.24:1 on --bg-card (was #52525b, 2.29:1) */

  /* Status colors */
  --accent-active: #22c55e;
  --accent-warning: #f59e0b;
  --accent-danger: #ef4444;
  /* Was #3b82f6 until 24 sep 2026; green by the owner's call, and deliberately the SAME
     value as --accent-active above, not a near-miss shade. Two consequences to know
     before touching it: the speed chart reads this token (charts.js), and "info" and
     "active" no longer contrast with each other — focus rings, primary buttons and the
     online dot are now one colour. If something ever needs to be visibly *not* a status
     green, it needs its own token rather than this one moved back. */
  --accent-info: #22c55e;
  /* For solid fills that carry white text. --accent-danger only reaches
     3.76:1 against #fff; this is 4.83:1. Same value in both themes —
     white has to stay white on a filled alarm control. */
  --accent-danger-fill: #dc2626;
  /* Accent used as *text* on its own pale tint. The accent itself is ~2.3:1 there in
     light theme, so light overrides this with a deeper shade that clears 4.5:1. Dark
     theme needs no shift, so it just points at the accent.
     (Read #3b82f6 for "the accent" before 24 sep 2026 — the contrast problem it
     describes is unchanged by the move to green, only the hex differs.) */
  --accent-info-text: var(--accent-info);
  /* Same for green: #22c55e as text on its own tint is ~2.3:1 on a light panel. */
  --accent-active-text: var(--accent-active);

  /* Semantic colors that were already load-bearing in components.css and JS but
     had never been named. Same values, now addressable. */
  --accent-stale: #eab308;   /* telemetry past its freshness window */
  --accent-beacon: #06b6d4;  /* buddy beacon / link state */
  --accent-buddy: #8b5cf6;   /* peer riders, waypoints */

  /* Trail gradient */
  --trail-start: #6366f1;
  --trail-end: #22c55e;

  /* Borders */
  --border-primary: #27272a;
  --border-subtle: rgba(255, 255, 255, 0.06);

  /* Glow effects */
  --glow-active: 0 0 20px rgba(34, 197, 94, 0.3);
  --glow-danger: 0 0 20px rgba(239, 68, 68, 0.3);

  /* Spacing */
  --spacing-xs: 0.25rem;
  --spacing-sm: 0.5rem;
  --spacing-md: 1rem;
  --spacing-lg: 1.5rem;
  --spacing-xl: 2rem;

  /* Border radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;

  /* Typography */
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Consolas', monospace;
  --font-sans: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Inter', system-ui, sans-serif;
  /* Numerals: mono, kept deliberately so live-updating digits don't jitter. */
  --font-numeric: 'JetBrains Mono', 'SF Mono', 'Consolas', monospace;

  /* Type scale — role-based. Components not yet migrated still carry their own
     ad-hoc sizes; there were ~25 distinct ones before this. */
  --text-caption: 11px;
  --text-footnote: 13px;
  --text-body: 15px;
  --text-title: 17px;

  /* ── Glass material ──────────────────────────────────────────────────────
     One recipe: a translucent tint over a blurred backdrop, a hairline top
     stroke to catch light, and a soft ambient shadow. The blur is what
     separates chrome from map, which is why these panels no longer need to be
     the opaque slabs they were. */
  --glass-tint: rgba(24, 24, 27, 0.62);
  --glass-tint-strong: rgba(24, 24, 27, 0.78);
  --glass-stroke: rgba(255, 255, 255, 0.10);
  /* Surfaces nested *inside* glass. Glass-on-glass reads as mud, so a control
     sitting on a glass panel uses a plain translucent wash instead. */
  --glass-inner: rgba(255, 255, 255, 0.08);
  --glass-inner-strong: rgba(255, 255, 255, 0.14);
  --glass-blur: 20px;
  --glass-saturate: 180%;

  /* Elevation */
  --elev-chip: 0 1px 3px rgba(0, 0, 0, 0.28), 0 6px 20px rgba(0, 0, 0, 0.22);

  /* Motion */
  --ease-standard: cubic-bezier(0.4, 0, 0.2, 1);
  --dur-fast: 120ms;
  --dur-base: 240ms;

  /* Safe-area insets. These only resolve to non-zero once index.html asks for
     viewport-fit=cover — without that they are 0 on every notched device. */
  --inset-top: env(safe-area-inset-top, 0px);
  --inset-bottom: env(safe-area-inset-bottom, 0px);
  --inset-left: env(safe-area-inset-left, 0px);
  --inset-right: env(safe-area-inset-right, 0px);

  /* Height of the fixed mobile tab bar: 14px top padding + the 56px
     min-height of a .tab-btn + its bottom padding + the 1px hairline.
     Anything that has to end above the bar subtracts this. */
  --tabbar-height: calc(71px + max(14px, var(--inset-bottom)));

  /* Aliases for tokens that components.css already referenced but that were
     never defined. Four of them had no fallback, so those borders and radii
     resolved to nothing at all. Declared as references so they follow the
     theme automatically. */
  --bg: var(--bg-primary);
  --bg-hover: var(--bg-tertiary);
  --border: var(--border-primary);
  --border-color: var(--border-primary);
  --radius: var(--radius-md);
  --accent-primary: var(--accent-info);
}

/* ═══ Light Theme ═══ */
[data-theme="light"] {
  /* Base colors */
  --bg-primary: #f4f4f5;
  --bg-secondary: #e4e4e7;
  --bg-tertiary: #d4d4d8;
  --bg-card: #ffffff;
  color-scheme: light;

  /* Text */
  --text-primary: #18181b;
  --text-secondary: #52525b;
  --text-muted: #6b6b76;   /* 5.26:1 on white (was #a1a1aa, 2.56:1) */

  /* Borders */
  --border-primary: #d4d4d8;
  --border-subtle: rgba(0, 0, 0, 0.06);

  /* Glow effects — subtler on light */
  --glow-active: 0 0 12px rgba(34, 197, 94, 0.2);
  --glow-danger: 0 0 12px rgba(239, 68, 68, 0.2);

  /* Glass — a white scrim rather than a dark one, and much softer shadows.
     The stroke goes near-opaque white so the top edge still reads as a lit
     bevel against a bright map. */
  --glass-tint: rgba(255, 255, 255, 0.68);
  --glass-tint-strong: rgba(255, 255, 255, 0.82);
  --glass-stroke: rgba(255, 255, 255, 0.9);
  --accent-info-text: #15803d;
  --accent-active-text: #15803d;

  --glass-inner: rgba(0, 0, 0, 0.05);
  --glass-inner-strong: rgba(0, 0, 0, 0.09);

  --elev-chip: 0 1px 2px rgba(0, 0, 0, 0.10), 0 6px 20px rgba(0, 0, 0, 0.12);
}
