:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #6b6a63; /* darkened from #898781: that was 3.5:1 on --surface, fails WCAG AA's 4.5:1 for normal text. Dark theme's --muted is unchanged, already passes at 4.85:1. */
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --wash: rgba(11, 11, 11, 0.05);
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --status-good: #0ca30c;
  --status-warning: #fab219;
  --status-serious: #ec835a;
  --status-critical: #d03b3b;
  --tooltip-bg: #ffffff;
  --shadow: 0 6px 24px rgba(11, 11, 11, 0.12);
  /* Flight markers: deliberately outside the series-1..6 hue family so they read as an
     annotation layer, not a 4th/5th data series. */
  --flight-arrival: #7c6fd1;
  --flight-departure: #0e8f8f;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --wash: rgba(255, 255, 255, 0.06);
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #008300;
    --tooltip-bg: #242423;
    --shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
    --flight-arrival: #a79ef0;
    --flight-departure: #2dd4d4;
  }
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* The browser's own [hidden] default is a normal-priority UA-stylesheet rule, so it loses to
   ANY author rule that sets display on the same element (e.g. .seg's display: inline-flex on
   #flights-group / #typical-group) regardless of selector specificity — author rules always
   beat user-agent rules at equal importance. Reasserted here so el.hidden = true actually
   hides things everywhere on the page, not just where no other rule happens to set display. */
[hidden] { display: none !important; }

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--page);
  color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  padding: 28px clamp(16px, 4vw, 48px) 40px;
  max-width: 1180px;
  margin-inline: auto;
}
h1 { font-size: 26px; font-weight: 650; letter-spacing: -0.01em; margin: 0; }
h2 { font-size: 16px; font-weight: 600; margin: 0; }
.sub { color: var(--ink-2); margin: 2px 0 0; font-size: 14px; }
a { color: inherit; text-decoration-color: var(--muted); }

.page-head {
  display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap;
  margin-bottom: 22px;
}
.source-line { margin: 0; color: var(--ink-2); font-size: 14px; text-align: right; }
.source-line .dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--status-good); margin-right: 6px; vertical-align: 1px;
}
.source-line .dot.bad { background: var(--status-critical); }
.source-line .dot.stale { background: var(--status-warning); }
/* Same content as the header's source-line, rendered a second time so it can sit below the
   tiles on mobile instead of the header — the header and the tiles section aren't siblings
   in a layout flex/grid `order` could reorder across. Only one of the two is ever visible;
   see the max-width media query below. */
.source-line-mobile { display: none; text-align: left; margin: 2px 0 18px; }

/* Stat tiles */
.tiles {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px;
  margin-bottom: 18px;
}
.tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 16px 18px 14px; display: grid; gap: 6px;
  border-top: 3px solid var(--lot-color, var(--axis));
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.tile:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.tile-stale .tile-mid, .tile-stale .meter, .tile-stale .hour-bars { opacity: 0.5; }
.stale-note {
  display: flex; gap: 8px; align-items: flex-start; font-size: 12px; line-height: 1.35; color: var(--ink-2);
  padding: 6px 10px; border-radius: 8px;
  background: color-mix(in oklab, var(--status-warning) 14%, var(--surface));
  border: 1px solid color-mix(in oklab, var(--status-warning) 45%, var(--surface));
}
.stale-note.stale-offline {
  background: color-mix(in oklab, var(--status-critical) 10%, var(--surface));
  border-color: color-mix(in oklab, var(--status-critical) 40%, var(--surface));
}
.stale-note .glyph { flex: none; font-size: 12px; line-height: 1.35; }
.stale-note strong { display: block; color: var(--ink); font-weight: 600; }
.tile .label { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--ink-2); font-size: 14px; }
.tile .detail { color: var(--ink-2); font-size: 13px; display: flex; justify-content: space-between; gap: 8px; }
.tile .info {
  color: var(--muted); font-size: 12px; margin: 6px 0 0; padding-top: 6px;
  border-top: 1px solid var(--border); display: grid; gap: 2px;
}
/* Middle row: ring | free-of-total count | trend. */
.tile-mid { display: flex; align-items: center; gap: 12px; margin: 2px 0; }
.tile-ring { flex: none; }
.tile-value { flex: 1; min-width: 0; }
.tile-value .value-main { display: block; font-size: 38px; font-weight: 600; line-height: 1.05; letter-spacing: -0.02em; }
.tile-value .value-main small { display: block; font-size: 14px; font-weight: 500; color: var(--ink-2); letter-spacing: 0; margin-top: 2px; }
.tile-trend { flex: none; }
/* Direction is carried by glyph shape + word, not color, so contrast holds in both themes. */
.tile .trend { display: flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 600; color: var(--ink-2); white-space: nowrap; }
.tile .trend-steady { font-weight: 500; }
.chip {
  display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600;
  padding: 2px 8px; border-radius: 999px; color: var(--ink);
  background: color-mix(in oklab, var(--chip-color) 18%, var(--surface));
  border: 1px solid color-mix(in oklab, var(--chip-color) 45%, var(--surface));
}
.chip .glyph { color: var(--chip-color); font-size: 11px; }
.meter { height: 6px; border-radius: 3px; background: color-mix(in oklab, var(--chip-color) 22%, var(--surface)); overflow: hidden; margin-top: 4px; }
.meter > span { display: block; height: 100%; background: var(--chip-color); border-radius: 3px; }
.ring-track { fill: none; stroke: var(--grid); stroke-width: 8; }
.ring-value { fill: none; stroke-width: 8; stroke-linecap: round; transition: stroke-dasharray 0.3s ease; }
.ring-label { fill: var(--ink); font-size: 15px; font-weight: 650; font-variant-numeric: tabular-nums; }
.hour-bars {
  display: flex; align-items: flex-end; gap: 2px; height: 40px; margin-top: 4px;
  border-bottom: 1px solid var(--border); padding-bottom: 1px;
}
.hour-bars .bar { flex: 1; background: var(--lot-color, var(--axis)); border-radius: 1px 1px 0 0; min-height: 2px; opacity: 0.7; }
.hour-bars .bar:last-child { opacity: 1; } /* the current hour */
.hour-bars .bar-empty { background: var(--grid); opacity: 1; }

/* Flag-shaped tooltip for hour bars: a small pointed tail under a centered, two-line label.
   position:fixed + appended to <body> so it floats above every tile regardless of scroll or
   any tile's own hover transform/stacking context. */
.bar-tooltip {
  position: fixed; transform: translate(-50%, -100%); z-index: 50; pointer-events: none;
  background: var(--tooltip-bg); border: 1px solid var(--border); border-radius: 6px;
  box-shadow: var(--shadow); padding: 6px 10px; text-align: center; white-space: nowrap;
}
.bar-tooltip::before, .bar-tooltip::after {
  content: ""; position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
  border: 6px solid transparent;
}
.bar-tooltip::before { border-top-color: var(--border); }
.bar-tooltip::after { border-top-color: var(--tooltip-bg); margin-top: -1px; }
.bar-tooltip .bt-hour { color: var(--ink-2); font-size: 11px; }
.bar-tooltip .bt-value { color: var(--ink); font-size: 13px; font-weight: 650; font-variant-numeric: tabular-nums; }

/* Footer: the old inline "about this data" callout now lives behind a disclosure so the page
   ends with the flight board, not a wall of caveats. */
.page-foot { margin-top: 8px; padding-top: 4px; }
.about-data {
  background: var(--wash); border: 1px solid var(--border); border-left: 3px solid var(--axis);
  border-radius: 8px; padding: 12px 16px; color: var(--ink-2); font-size: 13px; line-height: 1.5;
}
.about-data summary { cursor: pointer; font-weight: 600; color: var(--ink); }
.about-data[open] summary { margin-bottom: 8px; }
.about-data p { margin: 6px 0; }
.about-data p:last-child { margin-bottom: 0; }
.about-data strong { color: var(--ink); }
.tracker-status { margin-top: 10px; }
.tracker-error { display: block; margin-top: 4px; font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--ink-2); }
.flights-col td .sched { display: block; color: var(--muted); font-size: 11px; }
/* Status colors as a dot, not text color: the orange and green fail contrast as text on the light theme. */
.flights-col td[class^="status-"] { font-weight: 600; }
.flights-col td[class^="status-"]::before {
  content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  margin-right: 6px; vertical-align: 1px; background: var(--dot-color);
}
.flights-col td.status-delayed { --dot-color: var(--status-serious); }
.flights-col td.status-early { --dot-color: var(--status-good); }
.flights-col td.status-canceled { --dot-color: var(--status-critical); }
.built-by { margin: 14px 0 0; color: var(--muted); font-size: 13px; text-align: center; }
.built-by a { color: inherit; }

/* Controls: now live in the viz card's own header, upper-left, in place of a title. */
.viz-controls { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.card-head-right { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; }
.seg { display: inline-flex; background: var(--page); border: 1px solid var(--border); border-radius: 9px; padding: 3px; gap: 2px; }
.seg button {
  font: inherit; font-size: 13px; font-weight: 500; color: var(--ink-2); background: transparent; border: 0;
  padding: 5px 11px; border-radius: 6px; cursor: pointer;
}
.seg button:hover { background: var(--wash); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--surface); }
.seg button:focus-visible { outline: 2px solid var(--series-1); outline-offset: 1px; }
.seg button:disabled { color: var(--muted); cursor: not-allowed; opacity: 0.6; }
.seg button:disabled:hover { background: transparent; }
.typical-group { font-size: 12px; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px 12px; margin-bottom: 18px; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 8px; }
.legend { list-style: none; margin: 0; padding: 0; display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--ink-2); }
.legend li { display: inline-flex; align-items: center; gap: 7px; }
.legend .key { width: 18px; height: 2px; background: var(--c); border-radius: 1px; }
.legend .key-dashed { background: none; border-top: 2px dashed var(--c); height: 0; }

.chart-wrap { position: relative; }
#chart { display: block; width: 100%; height: 340px; overflow: visible; }
#chart:focus-visible { outline: 2px solid var(--series-1); outline-offset: 4px; border-radius: 4px; }
.chart-wrap.loading { opacity: 0.55; transition: opacity 0.15s; }
.gridline { stroke: var(--grid); stroke-width: 1; }
/* Outage bands: a neutral wash with a dashed edge, not a hue, so they read as "no data here"
   and never as another series. */
.gap-band { fill: var(--wash); stroke: var(--axis); stroke-width: 1; stroke-dasharray: 3 3; }
.gap-label { fill: var(--ink-2); font-size: 11px; font-weight: 600; }
.gap-sub { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.baseline { stroke: var(--axis); stroke-width: 1; }
.threshold { stroke: var(--axis); stroke-width: 1; }
.tick-label { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.note-label { fill: var(--muted); font-size: 11px; }
.series { fill: none; stroke-width: 4; stroke-linejoin: round; stroke-linecap: round; transition: opacity 0.15s; }
/* Baseline reference lines: same lot color, faint and dashed so the real reading always reads
   as the foreground line. Two distinct dash rhythms so day + same-weekday stay tellable apart
   when both are on at once. */
.series.typical { stroke-width: 1.5; pointer-events: none; }
.series.typical-day { opacity: 0.4; stroke-dasharray: 6 4; }
.series.typical-dow { opacity: 0.6; stroke-dasharray: 1.5 3.5; }
/* Hovering a stat tile applies this to every other lot's lines. Overrides whatever opacity
   the line already had (full-strength main line or a faint typical baseline alike) so the
   hovered lot reads as clearly stronger than either. */
.series.dimmed { opacity: 0.3 !important; }
/* Flight markers: thin dashed verticals, quiet enough to sit behind the lot lines. Direction
   is told apart by color and by the native <title> tooltip on hover, not by dash rhythm —
   two different dash patterns at this thinness read as noise, not signal. */
.flight-line { stroke-width: 1; opacity: 0.55; stroke-dasharray: 3 3; pointer-events: stroke; cursor: help; }
.flight-arrival { stroke: var(--flight-arrival); }
.flight-departure { stroke: var(--flight-departure); }
.end-marker { stroke: var(--surface); stroke-width: 2; }
.end-label { fill: var(--ink-2); font-size: 12px; }
.crosshair { stroke: var(--ink-2); stroke-width: 1; pointer-events: none; }
.hover-dot { stroke: var(--surface); stroke-width: 2; pointer-events: none; }
.hit { fill: transparent; cursor: crosshair; }

.tooltip {
  position: absolute; top: 8px; pointer-events: none; z-index: 2;
  background: var(--tooltip-bg); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow);
  padding: 8px 10px; font-size: 12px; min-width: 190px;
}
.tooltip .when { color: var(--ink-2); margin-bottom: 6px; }
.tooltip .row { display: grid; grid-template-columns: 14px auto 1fr; gap: 6px; align-items: center; padding: 1px 0; white-space: nowrap; }
.tooltip .row .k { height: 2px; background: var(--c); border-radius: 1px; }
.tooltip .row .v { font-weight: 650; color: var(--ink); font-variant-numeric: tabular-nums; }
.tooltip .row .n { color: var(--ink-2); }

.empty { color: var(--ink-2); font-size: 14px; margin: 8px 0 12px; }

/* Table */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { text-align: right; padding: 6px 10px; border-bottom: 1px solid var(--grid); white-space: nowrap; font-variant-numeric: tabular-nums; }
th { color: var(--ink-2); font-weight: 600; position: sticky; top: 0; background: var(--surface); }
th:first-child, td:first-child { text-align: left; }
th .key { display: inline-block; width: 12px; height: 2px; background: var(--c); border-radius: 1px; margin-right: 6px; vertical-align: middle; }
/* Flights table is almost entirely text (airline, city, status), not numbers, so left-align
   every column rather than fighting the readings table's numeric-right default. */
/* Flights board is almost entirely text (airline, city, status), not numbers, so left-align
   every column rather than fighting the readings table's numeric-right default. */
.flights-table th, .flights-table td { text-align: left; }
.flights-table tfoot td { color: var(--muted); font-size: 12px; white-space: normal; border-bottom: none; }

.flights-cols { display: flex; gap: 24px; flex-wrap: wrap; }
.flights-col { flex: 1; min-width: 280px; }
.flights-col h3 { display: flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600; color: var(--ink-2); margin: 0 0 8px; }
.flights-col .flight-icon { flex: none; }


@media (max-width: 560px) {
  body { padding-top: 20px; }
  .tile-value .value-main { font-size: 32px; }
  #chart { height: 280px; }
  .source-line { display: none; }
  .source-line-mobile { display: block; }
}
@media print {
  body { background: #fff; color: #000; }
  .controls, .tooltip { display: none !important; }
  .card, .tile { break-inside: avoid; box-shadow: none; }
}

/* API docs page (api.html): reading width, code blocks that scroll instead of widening the page. */
.docs { max-width: 760px; }
.docs main > p, .docs main > h2 { margin: 0 0 12px; }
.docs main > h2 { margin-top: 28px; }
.docs code { font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; }
.docs pre {
  background: var(--wash); border: 1px solid var(--border); border-radius: 8px;
  padding: 12px 14px; margin: 0 0 16px; overflow-x: auto;
}
.docs .table-wrap { overflow-x: auto; margin: 0 0 16px; }
.docs table { border-collapse: collapse; width: 100%; font-size: 14px; }
.docs th, .docs td { text-align: left; vertical-align: top; padding: 6px 10px 6px 0; border-bottom: 1px solid var(--grid); }
.docs th { color: var(--ink-2); font-weight: 600; }
.docs th, .docs td { white-space: normal; background: none; }
.docs td:first-child { white-space: nowrap; }
.docs h2 code { font-size: inherit; font-weight: 600; }
.data-link { margin: 14px 0 0; font-size: 13px; text-align: center; }

.docs .usage { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.docs .agents {
  border: 1px solid var(--border); border-left: 3px solid var(--axis); border-radius: 8px;
  padding: 14px 16px 2px; margin: 0 0 20px; background: var(--surface);
}
.docs .agents p { margin: 6px 0 10px; color: var(--ink-2); font-size: 14px; }
.docs .agents-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.docs .agents h2 { margin: 0; }
.docs #copy-prompt {
  font: inherit; font-size: 13px; font-weight: 600; color: var(--ink);
  background: var(--wash); border: 1px solid var(--border); border-radius: 6px;
  padding: 6px 12px; cursor: pointer; min-height: 32px;
}
.docs #copy-prompt:hover { border-color: var(--axis); }
.docs #agent-prompt { max-height: 320px; overflow: auto; }
.docs #agent-prompt code { white-space: pre-wrap; }
