/* Minimal by intent: hairlines instead of boxes, one accent for the plan, one
   warm tint for the high season, and type doing the work cards used to do.
   Series colours come from the validated data-viz palette. */

:root {
  color-scheme: light;
  --page: #fbfbfa;
  --surface: #ffffff;
  --ink: #141413;
  --ink-2: #4f4e4a;
  --ink-3: #6b6a65;            /* 5.2:1 on --page: the quietest text that still meets AA */
  --grid: #ecebe6;
  --axis: #d3d2cb;
  --border: rgba(20, 20, 19, 0.12);
  --accent: #256abf;
  --plan: #2a78d6;
  --base-line: #8c8b85;
  --base-fill: rgba(20, 20, 19, 0.07);
  --season: #f5efe3;
  --forcing: rgba(20, 20, 19, 0.16);
  --cases: #eb6834;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #121211;
    --surface: #1a1a19;
    --ink: #f4f3ee;
    --ink-2: #c3c2b7;
    --ink-3: #9b9a93;
    --grid: #262624;
    --axis: #3a3a37;
    --border: rgba(255, 255, 255, 0.12);
    --accent: #5b9cec;
    --plan: #3987e5;
    --base-line: #8c8b85;
    --base-fill: rgba(255, 255, 255, 0.08);
    --season: #26221b;
    --forcing: rgba(255, 255, 255, 0.2);
    --cases: #d95926;
  }
}

* { box-sizing: border-box; }
html { scroll-padding-top: 16px; }
body { margin: 0; background: var(--page); color: var(--ink); font: 15px/1.55 var(--font); }
a { color: var(--accent); text-underline-offset: 2px; }
p { margin: 0; }
h1, h2, h3 { margin: 0; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* -- header and intro ----------------------------------------------------- */

.top {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 24px; border-bottom: 1px solid var(--grid);
}
.brand { font-weight: 600; letter-spacing: -0.01em; }
.top nav { display: flex; gap: 20px; font-size: 14px; }
.top nav a { color: var(--ink-2); text-decoration: none; }
.top nav a:hover { color: var(--ink); text-decoration: underline; }

.page { max-width: 1200px; margin: 0 auto; padding: 0 24px; }
.intro { padding: 44px 0 32px; }
.intro h1 { font-size: 28px; line-height: 1.2; font-weight: 600; letter-spacing: -0.018em; max-width: 30ch; }
.claim { margin-top: 12px; color: var(--ink-2); font-size: 16px; max-width: 68ch; }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 56px; align-items: start; }
@media (max-width: 1040px) { .layout { grid-template-columns: minmax(0, 1fr); gap: 32px; } }

/* -- site bar ------------------------------------------------------------- */

.site-bar {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between;
  gap: 8px 20px; padding: 14px 0; border-top: 1px solid var(--grid); border-bottom: 1px solid var(--grid);
}
.site { font-size: 15px; }
.site-label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-3); margin-right: 6px; }
.tag {
  display: inline-block; margin-left: 6px; padding: 0 7px; border: 1px solid var(--axis);
  border-radius: 999px; font-size: 12px; color: var(--ink-2); vertical-align: 1px;
}
.loader > summary { cursor: pointer; color: var(--accent); font-size: 14px; list-style: none; }
.loader > summary::-webkit-details-marker { display: none; }
.loader[open] { flex-basis: 100%; }
.loader-body { padding: 12px 0 4px; display: grid; gap: 10px; max-width: 560px; }
.dropzone { border: 1px dashed var(--axis); border-radius: 6px; padding: 12px 14px; }
.dropzone.over { border-color: var(--accent); }
.dropzone label { display: block; font-size: 13.5px; color: var(--ink-2); margin-bottom: 8px; }
.paste summary { cursor: pointer; font-size: 14px; color: var(--ink-2); }
.paste textarea { width: 100%; margin: 8px 0; font: 13px/1.4 ui-monospace, monospace; }
.fine { font-size: 12.5px; color: var(--ink-3); }

/* -- controls ------------------------------------------------------------- */

button { font: inherit; color: inherit; cursor: pointer; }
button.link {
  border: 0; background: none; padding: 0; color: var(--accent); font-size: inherit;
}
button.link:hover:not(:disabled) { text-decoration: underline; text-underline-offset: 2px; }
button.link:disabled { color: var(--ink-3); cursor: default; }
button.primary {
  border: 0; border-radius: 4px; padding: 6px 14px; background: var(--ink); color: var(--page); font-weight: 600;
}
input[type="number"], input[type="text"], input[type="date"], textarea {
  font: inherit; color: inherit; background: var(--surface);
  border: 1px solid var(--axis); border-radius: 4px; padding: 5px 8px; max-width: 100%;
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* -- figures -------------------------------------------------------------- */

.figures {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr));
  gap: 20px 36px; padding: 26px 0 6px;
}
.figures.stale .figure:not(.lead) { opacity: 0.45; }
.figure-label { font-size: 13px; color: var(--ink-2); }
.figure-value { font-size: 30px; line-height: 1.15; font-weight: 600; letter-spacing: -0.02em; margin-top: 2px; }
.figure-note { font-size: 13px; color: var(--ink-3); margin-top: 2px; }
.figure.empty .figure-value { color: var(--ink-3); font-weight: 400; }
.status { font-size: 13px; color: var(--ink-3); min-height: 20px; padding: 6px 0 18px; }
.status.busy { color: var(--ink); }
.message {
  margin: 14px 0 0; padding: 10px 14px; border-left: 2px solid var(--accent);
  background: var(--surface); font-size: 14px;
}
.message.error { border-left-color: var(--cases); }
.message p + p, .message p + details { margin-top: 6px; }
.message button { margin: 8px 8px 0 0; border: 1px solid var(--axis); background: var(--surface); border-radius: 4px; padding: 4px 10px; }
.message pre { white-space: pre-wrap; font-size: 12px; color: var(--ink-3); }

/* -- chart ---------------------------------------------------------------- */

.chart-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 8px 16px; }
.chart-head h2 { font-size: 16px; font-weight: 600; }
.axis-note { font-size: 13px; font-weight: 400; color: var(--ink-3); margin-left: 6px; }
.views { display: inline-flex; border: 1px solid var(--axis); border-radius: 5px; overflow: hidden; }
.views button { border: 0; background: none; padding: 3px 11px; font-size: 13px; color: var(--ink-2); }
.views button + button { border-left: 1px solid var(--axis); }
.views button[aria-pressed="true"] { background: var(--ink); color: var(--page); }

.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 12.5px; color: var(--ink-2); margin: 10px 0 2px; }
.key { display: inline-block; vertical-align: middle; margin-right: 6px; }
.key-base { width: 16px; height: 9px; background: var(--base-fill); border-top: 1.5px solid var(--base-line); }
.key-plan { width: 16px; height: 0; border-top: 2px solid var(--plan); }
.key-season { width: 14px; height: 11px; background: var(--season); border: 1px solid var(--axis); border-radius: 2px; }

.canvas { margin-top: 4px; }
.lanes { position: relative; }
.lane svg { display: block; width: 100%; }
.lane text, .mini text { font-family: var(--font); }
.lane .tick { font-size: 11.5px; fill: var(--ink-3); font-variant-numeric: tabular-nums; }
.lane .season-label { font-size: 12px; fill: var(--ink-2); font-weight: 500; }
.lane .stale { opacity: 0.35; }
.crosshair { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--ink-3); opacity: 0.55; pointer-events: none; }

.readout { font-size: 13px; color: var(--ink-2); min-height: 20px; margin-top: 6px; padding-left: var(--gutter, 0); font-variant-numeric: tabular-nums; }
.readout .sep { margin: 0 7px; color: var(--ink-3); }
.readout .plan-ink { color: var(--plan); }
.readout-hint { color: var(--ink-3); }
.hint { font-size: 12.5px; color: var(--ink-3); margin-top: 10px; }

/* -- schedule rows, aligned to the chart's gutter ------------------------- */

.schedule { display: grid; gap: 3px; margin: 6px 0 0; }
.sched-row { display: grid; grid-template-columns: var(--gutter, 148px) minmax(0, 1fr); padding-right: var(--right, 16px); align-items: center; }
.sched-label {
  display: grid; justify-items: end; gap: 0; padding: 2px 12px 2px 0;
  border: 0; background: none; text-align: right;
}
.sched-name { font-size: 13px; font-weight: 500; }
.sched-meta { font-size: 11.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.sched-label:hover .sched-name { text-decoration: underline; text-underline-offset: 2px; }
.sched-track { position: relative; height: 30px; cursor: copy; touch-action: pan-y; border-bottom: 1px solid var(--grid); }
.sched-track .forcing { position: absolute; inset: 0; width: 100%; height: 100%; }
.tl-empty { position: absolute; left: 8px; top: 50%; transform: translateY(-50%); font-size: 12px; color: var(--ink-3); pointer-events: none; }
.tl-block {
  position: absolute; top: 0; bottom: 0; width: 24px; margin-left: -12px;
  padding: 0; border: 0; background: none; display: grid; place-items: center; cursor: grab; border-radius: 4px;
}
.tl-pin { display: block; width: 4px; height: 20px; border-radius: 2px; background: var(--ink-2); }
.tl-block:hover .tl-pin, .tl-block:focus-visible .tl-pin { background: var(--ink); height: 24px; }
.tl-block.dragging { cursor: grabbing; z-index: 3; }
.tl-flag {
  position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); white-space: nowrap;
  font-size: 12px; padding: 1px 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 4px;
}

.canvas.narrow .sched-row { grid-template-columns: minmax(0, 1fr); padding-left: var(--gutter); }
.canvas.narrow .sched-label { justify-items: start; text-align: left; padding: 6px 0 2px; grid-auto-flow: column; gap: 8px; justify-content: start; align-items: baseline; }
.canvas.narrow .sched-track { height: 40px; }
@media (pointer: coarse) { .tl-block { width: 44px; margin-left: -22px; } }

.drivers { margin-top: 12px; }
.driver-label { font-size: 12px; color: var(--ink-3); margin: 10px 0 2px; padding-left: var(--gutter, 0); }

/* -- toolbar and the rest ------------------------------------------------- */

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; font-size: 13.5px; margin: 18px 0 8px; }
.toolbar .sep { width: 1px; height: 14px; background: var(--axis); }
.toggle { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); }

.more { margin-top: 16px; border-bottom: 1px solid var(--grid); }
.more details { border-top: 1px solid var(--grid); }
.more summary { cursor: pointer; padding: 11px 0; font-size: 14px; color: var(--ink-2); }
.more details[open] summary { color: var(--ink); }
.more details > :not(summary) { margin-bottom: 14px; }

.plan-table, #data-table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
.plan-table th, .plan-table td, #data-table th, #data-table td { text-align: left; padding: 5px 8px; border-bottom: 1px solid var(--grid); }
.plan-table th, #data-table th { font-weight: 600; color: var(--ink-2); font-size: 12.5px; }
.plan-table { table-layout: fixed; }
.plan-table td:last-child, .plan-table th:last-child { width: 80px; }
.plan-table button { border: 0; background: none; color: var(--accent); padding: 0; }
#data-table td { white-space: nowrap; font-variant-numeric: tabular-nums; }
#data-table td:not(:first-child), #data-table th:not(:first-child) { text-align: right; }
#data-table caption { caption-side: bottom; text-align: left; font-size: 12px; color: var(--ink-3); padding-top: 8px; }
.table-scroll { max-height: 360px; overflow: auto; }
#data-table thead th { position: sticky; top: 0; background: var(--page); }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; font-size: 13.5px; }
.row-actions button { border: 0; background: none; color: var(--accent); padding: 0; }
.export-body { display: grid; gap: 10px; }
.export-field { display: grid; gap: 4px; font-size: 13px; color: var(--ink-2); max-width: 320px; }
.export-actions { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: 13.5px; }

/* -- popover -------------------------------------------------------------- */

.popover {
  position: fixed; z-index: 20; width: min(300px, calc(100vw - 16px));
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 14px; box-shadow: 0 8px 28px rgba(0, 0, 0, 0.14); font-size: 14px;
}
.popover h4 { margin: 0 0 10px; font-size: 14px; }
.popover-field { display: grid; gap: 4px; font-size: 13px; color: var(--ink-2); margin-bottom: 10px; }
.popover-field input { width: 100%; }
.popover-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 10px; }
.popover-row input[type="number"] { width: 60px; }
.popover-row button { border: 1px solid var(--axis); background: none; border-radius: 4px; padding: 2px 8px; }
.popover-actions { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-top: 4px; }
.popover-actions button:not(.primary) { border: 0; background: none; color: var(--accent); padding: 0; }
.popover-series { margin-top: 12px; border-top: 1px solid var(--grid); padding-top: 8px; }
.popover-series summary { cursor: pointer; color: var(--accent); font-size: 13.5px; }
.popover-series > button { border: 0; background: none; color: var(--accent); padding: 0; }
.popover .help { font-size: 12.5px; color: var(--ink-3); margin-bottom: 8px; }

/* -- track record --------------------------------------------------------- */

.track { border-left: 1px solid var(--grid); padding-left: 28px; }
@media (max-width: 1040px) { .track { border-left: 0; padding-left: 0; border-top: 1px solid var(--grid); padding-top: 18px; } }
.track-heading { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-3); font-weight: 600; }
.track-lede { font-size: 13.5px; color: var(--ink-2); margin: 6px 0 4px; }
.story { padding: 18px 0; border-bottom: 1px solid var(--grid); }
.story-kicker { font-size: 12.5px; color: var(--ink-3); }
.story-title { font-size: 16px; line-height: 1.3; font-weight: 600; margin: 3px 0 12px; letter-spacing: -0.005em; }
.mini { display: block; overflow: visible; max-width: 420px; }
.mini .mini-label { font-size: 9.5px; fill: var(--ink-3); }
.mini .mini-tick { font-size: 9.5px; fill: var(--ink-3); }
.stories { display: grid; }
@media (max-width: 1040px) {
  .stories { grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); column-gap: 32px; }
}
.story-body { font-size: 13.5px; color: var(--ink-2); margin-top: 10px; }
.story-foot { margin-top: 8px; font-size: 13.5px; }
.story-source { font-size: 11.5px; color: var(--ink-3); margin-top: 8px; }
.story-source a { color: var(--ink-3); }
.track-fine { font-size: 12.5px; color: var(--ink-3); padding-top: 14px; }

/* -- about and footer ----------------------------------------------------- */

.about { margin-top: 48px; padding: 22px 0; border-top: 1px solid var(--grid); }
.limitations { font-size: 14px; color: var(--ink-2); max-width: 82ch; }
.about details { margin-top: 10px; }
.about summary { cursor: pointer; color: var(--accent); font-size: 14px; }
.about-list { max-width: 82ch; font-size: 14px; }
.about-list dt { font-weight: 600; margin-top: 12px; }
.about-list dd { margin: 2px 0 0; color: var(--ink-2); }
.foot { padding: 18px 24px 44px; border-top: 1px solid var(--grid); color: var(--ink-3); font-size: 12.5px; }
.foot p { max-width: 1152px; margin: 0 auto; }
.foot .cite { margin-top: 6px; }
.foot a { color: var(--ink-3); }

[hidden] { display: none !important; }

@media (max-width: 640px) {
  .top, .page { padding-left: 16px; padding-right: 16px; }
  .figures { grid-template-columns: 1fr 1fr; gap: 16px 20px; }
  .figure.lead { grid-column: 1 / -1; }
  .intro { padding: 28px 0 22px; }
  .intro h1 { font-size: 23px; }
  .figure-value { font-size: 26px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

@media (forced-colors: active) {
  .tl-pin { background: ButtonText; }
  .key, .lane .stale { forced-color-adjust: none; }
}

@media print {
  :root { color-scheme: light; }
  body { background: #fff; color: #000; font-size: 11px; }
  .top nav, .loader, .toolbar, .hint, .more, .readout, .views, #message, .track, .about details { display: none !important; }
  .layout { display: block; }
  .intro { padding: 0 0 10px; }
  .intro h1 { font-size: 18px; }
  .figure-value { font-size: 20px; }
  .lanes { break-inside: avoid; }
}
