:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface-1: #fcfcfb;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --critical: #d03b3b;
  --series-direct: #2a78d6;
  --series-errand: #eb6834;
  --series-long: #1baf7a;
  --series-median: #0b0b0b;
  --band: rgba(11, 11, 11, 0.10);
  --band-usual: rgba(42, 120, 214, 0.10);
  --band-long: rgba(27, 175, 122, 0.10);
  --reference: #898781;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface-1: #1a1a19;
    --text-primary: #f0efec;
    --text-secondary: #c3c2b7;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --series-direct: #3987e5;
    --series-errand: #d95926;
    --series-long: #199e70;
    --series-median: #f0efec;
    --band: rgba(240, 239, 236, 0.12);
    --band-usual: rgba(57, 135, 229, 0.12);
    --band-long: rgba(25, 158, 112, 0.12);
  }
}

body {
  margin: 0 auto;
  padding: 24px;
  background: var(--page);
  color: var(--text-primary);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

h1 { font-size: 1.5rem; margin: 0 0 16px; }
h2 { font-size: 1.1rem; margin: 0; }

.subtitle { margin: 4px 0 12px; color: var(--text-secondary); font-size: 0.9rem; }

.status { color: var(--text-secondary); font-size: 0.9rem; }

footer { margin-top: 24px; color: var(--text-muted); font-size: 0.8rem; }

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}

/* Charts follow the window width, keeping their proportions, but never get
   too low to read or taller than the window. */
.chart { position: relative; aspect-ratio: 3 / 1; min-height: 240px; max-height: 80vh; }

summary { cursor: pointer; font-weight: 600; }

table { border-collapse: collapse; width: 100%; margin-top: 12px; font-size: 0.9rem; }
th { text-align: left; color: var(--text-secondary); font-weight: 600; }
th, td { padding: 4px 8px; border-bottom: 1px solid var(--grid); }
.num { text-align: right; font-variant-numeric: tabular-nums; }

h2.section { margin: 32px 0 8px; }
h3 { font-size: 0.9rem; font-weight: 600; color: var(--text-secondary); margin: 8px 0 4px; }

.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
/* Lets the columns shrink below the width their canvases were drawn at. */
.pair > div { min-width: 0; }
@media (max-width: 640px) { .pair { grid-template-columns: 1fr; } }
.chart.small { aspect-ratio: 2 / 1; min-height: 200px; }

/* Shared legend for the day charts, matching their marks. */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  list-style: none;
  padding: 0;
  margin: 0 0 12px;
  color: var(--text-secondary);
  font-size: 0.85rem;
}
.legend li { display: flex; align-items: center; gap: 6px; }
.key { display: inline-block; }
.key-direct { width: 10px; height: 10px; border-radius: 50%; background: var(--series-direct); }
.key-long { width: 10px; height: 10px; border-radius: 50%; background: var(--series-long); }
.key-errand { width: 6px; height: 6px; border-radius: 50%; border: 2px solid var(--series-errand); }
.key-median { width: 16px; height: 2px; background: var(--series-median); }
.key-band { width: 16px; height: 10px; background: var(--band); }
/* A route's median line across its middle-half band. */
.key-route {
  width: 16px;
  height: 10px;
  background: linear-gradient(var(--route-line) 0 0) center / 100% 2px no-repeat, var(--route-band);
}
.key-route.usual { --route-line: var(--series-direct); --route-band: var(--band-usual); }
.key-route.long { --route-line: var(--series-long); --route-band: var(--band-long); }
.key-reference { width: 16px; height: 2px; background: var(--reference); }
