:root {
  --bg: #ffffff;
  --surface: #f5f6f7;
  --text: #1b1d21;
  --muted: #555b66;
  --line: #e1e4e8;
  --line-strong: #b9bfc8;
  --link: #1f56b3;
  --pos: #2563b0;
  --neg: #b0460f;
  --control: #8a919c;
  --series: #2a3340;
  --series2: #0e7f7a;
  --zero: #6f7681;
  --track: #a9b0ba;
  --hover: #f3f6fb;
  --warn-bg: #fff4d6;
  --warn-text: #6e4400;
  --bad-bg: #fde8e4;
  --bad-text: #9b2c12;
  --ok-bg: #e6f2ea;
  --ok-text: #1f6b3a;
  --focus: #1f56b3;
  --serif: Charter, "Bitstream Charter", "Iowan Old Style", "Sitka Text", Cambria, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  /* Type scale: 13 / 14 / 15 / 17 / 24 / 30 */
  --fs-xs: 13px;
  --fs-s: 14px;
  --fs-m: 15px;
  --fs-l: 17px;
  --fs-h2: 24px;
  --fs-h1: 30px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171a;
    --surface: #1e2125;
    --text: #e8eaed;
    --muted: #a7adb7;
    --line: #2d3137;
    --line-strong: #4a5059;
    --link: #8db4f5;
    --pos: #6aa3f0;
    --neg: #f0884f;
    --control: #6f7782;
    --series: #dfe3ea;
    --series2: #45c2b8;
    --zero: #9aa0aa;
    --track: #5c636d;
    --hover: #1d2229;
    --warn-bg: #3a2e12;
    --warn-text: #f2cf7a;
    --bad-bg: #3d1f18;
    --bad-text: #f5a58c;
    --ok-bg: #173022;
    --ok-text: #8fd6a6;
    --focus: #8db4f5;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
.facts .fail { display: block; font-weight: 400; color: var(--warn-text); }
html { scroll-padding-top: 56px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: var(--fs-m)/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--link); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 2px; }

h1, h2 { font-family: var(--serif); font-weight: 700; line-height: 1.2; margin: 0; letter-spacing: -0.005em; }
h1 { font-size: var(--fs-h1); }
h2 { font-size: var(--fs-h2); }
h3 { font-size: 16px; font-weight: 600; line-height: 1.3; margin: 24px 0 6px; }
p { margin: 0 0 12px; }

.wrap { max-width: 1120px; margin: 0 auto; padding-left: 24px; padding-right: 24px; }

.skip { position: absolute; left: 8px; top: -60px; background: var(--bg); padding: 8px 12px; z-index: 20; }
.skip:focus { top: 8px; }

/* Header */
.top-inner { display: grid; grid-template-columns: 1fr auto; gap: 32px; padding-top: 32px; padding-bottom: 20px; align-items: end; }
.lede { color: var(--muted); max-width: 640px; margin: 8px 0 0; font-size: var(--fs-l); }
.facts { display: grid; grid-template-columns: repeat(3, auto); gap: 4px 28px; margin: 0; }
.facts dt { color: var(--muted); font-size: var(--fs-s); }
.facts dd { margin: 2px 0 0; font-weight: 600; white-space: nowrap; }
.facts dd a { color: var(--text); }

/* Sticky section nav */
.navbar { position: sticky; top: 0; z-index: 10; background: var(--bg); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
nav { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
nav::-webkit-scrollbar { display: none; }
nav a {
  color: var(--muted); text-decoration: none; font-size: var(--fs-m); white-space: nowrap;
  padding: 11px 10px 9px; border-bottom: 2px solid transparent;
}
nav a:first-child { margin-left: -10px; }
nav a:hover { color: var(--text); }
nav a[aria-current] { color: var(--text); border-bottom-color: var(--text); }

/* Sections */
main { padding-bottom: 24px; }
section { padding: 44px 0; border-top: 1px solid var(--line); }
.notice + section { border-top: 0; padding-top: 20px; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px 16px; flex-wrap: wrap; margin-bottom: 8px; }
.sub { color: var(--muted); margin: 4px 0 16px; max-width: 720px; }
.caption { color: var(--muted); font-size: var(--fs-s); margin: 4px 0 0; }
.count-line { color: var(--muted); font-size: var(--fs-s); margin: 0 0 8px; }
.meta { font-family: var(--mono); font-size: var(--fs-xs); color: var(--muted); }

.notice { margin: 20px 0 8px; padding: 2px 0 2px 14px; border-left: 3px solid var(--warn-text); }
.notice strong { color: var(--warn-text); }

/* Controls */
button, .button, select, input[type=search] {
  font: inherit; font-size: var(--fs-m); color: var(--text); background: var(--bg);
  border: 1px solid var(--control); border-radius: 6px; min-height: 36px;
}
button, .button { padding: 6px 14px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
button:hover, .button:hover { background: var(--surface); }
select { padding: 6px 10px; cursor: pointer; }
input[type=search] { padding: 6px 10px; width: 100%; }
input::placeholder { color: var(--muted); opacity: 1; }
.control { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); }
.control.grow { flex: 1 1 260px; max-width: 420px; }
.check { display: inline-flex; gap: 8px; align-items: center; cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 0; }
.filters { display: flex; flex-wrap: wrap; gap: 12px 24px; margin: 8px 0 12px; }
.link-button { border: 0; background: none; padding: 4px 2px; margin: -4px -2px; min-height: 0; color: var(--link); text-decoration: underline; text-underline-offset: 3px; font: inherit; }
.link-button:hover { background: none; text-decoration-thickness: 2px; }

.tag {
  display: inline-block; font-size: var(--fs-s); font-weight: 600; line-height: 1.4;
  padding: 1px 7px; border-radius: 4px; white-space: nowrap;
  background: var(--surface); color: var(--muted);
}
.tag-warn { background: var(--warn-bg); color: var(--warn-text); }
.tag-bad { background: var(--bad-bg); color: var(--bad-text); }
.tag-ok { background: var(--ok-bg); color: var(--ok-text); }

/* Tables */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
thead th { font-size: var(--fs-s); font-weight: 600; color: var(--muted); border-bottom-color: var(--line-strong); white-space: nowrap; vertical-align: bottom; }
th:first-child, td:first-child { padding-left: 0; }
th:last-child, td:last-child { padding-right: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-scroll { overflow-x: auto; }
tr.changed td { background: var(--hover); }

/* Claims table */
.claims tbody th, .claims td { padding-top: 14px; padding-bottom: 14px; vertical-align: middle; font-weight: 400; }
.claims tbody th { width: 40%; text-align: left; }
.claims tbody tr:last-child > *, .stack tbody tr:last-child > *, .hist tbody tr:last-child > * { border-bottom: 0; }
.ev:last-child { border-bottom: 0; }
.claim-id { font-family: var(--mono); font-size: var(--fs-s); color: var(--text); width: 36px; }
.claim-title { display: block; font-size: var(--fs-s); color: var(--muted); font-weight: 600; }
.claim-statement { display: block; font-family: var(--serif); font-size: var(--fs-l); line-height: 1.35; margin-top: 2px; }
.level-cell { white-space: nowrap; }
.level-num { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.level-num.pos { color: var(--pos); }
.level-num.neg { color: var(--neg); }
.level-num.zero { color: var(--zero); }
.level-label { display: block; font-size: var(--fs-s); color: var(--muted); }
.claims .num, .claims .ev-count { white-space: nowrap; }
.claims .open { white-space: nowrap; width: 1%; }
.axis-head { display: flex; justify-content: space-between; max-width: 280px; padding: 0 4px; font-variant-numeric: tabular-nums; font-weight: 400; }
.bar-cell { width: 290px; min-width: 220px; }
.unc { white-space: nowrap; }
.bar { width: 100%; max-width: 280px; display: block; }
.bar .track { fill: var(--track); }
.bar .tick { stroke: var(--bg); stroke-width: 1.5; }
.bar .mid { stroke: var(--text); stroke-width: 2; }
.bar .fill-pos { fill: var(--pos); }
.bar .fill-neg { fill: var(--neg); }
.bar .dot-zero { fill: var(--zero); stroke: var(--bg); stroke-width: 2; }
.bar .base { fill: var(--bg); stroke: var(--text); stroke-width: 2; }
.key-diamond { display: inline-block; width: 9px; height: 9px; border: 2px solid var(--text); transform: rotate(45deg); margin: 0 6px 0 2px; vertical-align: 0; }
.bar-axis { display: none; }
.phone-only { display: none; }

/* Chart */
.chart svg { display: block; width: 100%; height: auto; }
.chart .grid { stroke: var(--line); }
.chart .axis-text { fill: var(--muted); font-size: 13px; }
.chart .unit { fill: var(--muted); font-size: 13px; }
.chart .lab { font-size: 13px; font-weight: 600; }
.chart .lab-avg { fill: var(--series); }
.chart .lab-tank { fill: var(--series2); }
.chart .lab-ref, .chart .lab-cut { fill: var(--muted); font-weight: 400; }
.chart svg:focus-visible { outline-offset: 4px; }
.chart .ref { stroke: var(--muted); stroke-dasharray: 5 4; stroke-width: 1.25; }
.chart .ref-text { fill: var(--muted); font-size: 13px; }
.chart .line { fill: none; stroke: var(--series); stroke-width: 2.5; }
.chart .pt { fill: var(--series); stroke: var(--bg); stroke-width: 2; }
.chart .val { fill: var(--text); font-size: 13px; font-weight: 600; }
.chart .bar-econ { fill: var(--series); opacity: 0.8; }
details { margin-top: 10px; }
summary { cursor: pointer; color: var(--link); width: fit-content; padding: 4px 0; min-height: 24px; }
details[open] > summary { margin-bottom: 8px; }
.subsection { margin-top: 24px; }
.subsection + .subsection { margin-top: 48px; }
.subsection h3 { margin: 0; }
.subsection .caption { max-width: 760px; }
.chart-hint { margin-top: 0; }
#transitRaw table, #raw table, #scenarioResult table { max-width: 560px; }

.chart .daily { fill: none; stroke: var(--series); stroke-width: 1; opacity: 0.35; }
.chart .event { stroke: var(--muted); stroke-dasharray: 2 3; }
.chart .gap { fill: var(--surface); }
.chart .cutoff { stroke-dasharray: 3 3; }
.nav-btn { min-height: 32px; padding: 2px 10px; font-size: var(--fs-s); }
#detailMeta { display: flex; align-items: center; gap: 10px; }
.narrow-only { display: none; }
.legend { list-style: none; display: flex; flex-wrap: wrap; gap: 4px 18px; padding: 0; margin: 4px 0 8px; font-size: var(--fs-s); color: var(--muted); }
.legend .k { display: inline-block; width: 18px; height: 0; border: 0; border-top: 2.5px solid var(--series); vertical-align: 4px; margin-right: 6px; }
.legend .k-daily { border-top-width: 1px; opacity: 0.6; }
.legend .k-tank { border-top: 2.5px dashed var(--series2); }
.legend .k-ref { border-top: 1.5px dashed var(--muted); }
.legend .k-cut { width: 0; height: 12px; border-top: 0; border-left: 1.5px solid var(--text); vertical-align: -1px; }
.chart .avg { fill: none; stroke: var(--series); stroke-width: 2.5; }
.chart .tank { fill: none; stroke: var(--series2); stroke-width: 2; stroke-dasharray: 6 3; }
.chart .cutoff { stroke: var(--text); stroke-width: 1; }
.chart .hover-line { stroke: var(--muted); stroke-width: 1; }
.chart .hover-dot { fill: var(--series); stroke: var(--bg); stroke-width: 2; }
.readout { font-variant-numeric: tabular-nums; margin: 0 0 4px; min-height: 1.55em; }
.readout b { font-size: var(--fs-l); }
#tHit { touch-action: pan-y; }
.readout .tk { color: var(--series2); font-weight: 600; }

/* Evidence */
.ev { border-bottom: 1px solid var(--line); padding: 18px 0; display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 0 32px; }
.ev-aside { margin: 0; font-size: var(--fs-s); display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; align-content: start; padding-top: 2px; }
.ev-aside dt { color: var(--muted); font-size: var(--fs-xs); }
.ev-aside .dirs { display: block; }
.ev-aside dd { margin: 0 0 6px; }
.ev details { grid-column: 1 / -1; }
.ev:first-child { border-top: 1px solid var(--line-strong); }
.ev-top { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; font-size: var(--fs-s); color: var(--muted); }
.ev-claims { font-weight: 600; color: var(--text); }
.ev-title { font-family: var(--serif); font-size: var(--fs-l); font-weight: 700; margin: 6px 0 4px; line-height: 1.35; }
.ev-title a { color: var(--text); text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 4px; }
.ev-title a:hover { color: var(--link); text-decoration-color: currentColor; }
.ext { font-family: var(--sans); font-size: var(--fs-s); color: var(--muted); font-weight: 400; }
.ev p { margin: 0; }
.ev .source { font-size: var(--fs-s); color: var(--muted); margin-top: 6px; }
.ev.flash { background: var(--hover); box-shadow: -12px 0 0 var(--hover), 12px 0 0 var(--hover); }
.dir-support { color: var(--pos); font-weight: 600; }
.dir-challenge { color: var(--neg); font-weight: 600; }
.dir-other { color: var(--muted); font-weight: 600; }
dl.kv { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 6px 16px; margin: 0; font-size: var(--fs-s); }
#detailContent dl.kv { font-size: var(--fs-m); }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; overflow-wrap: anywhere; }
.empty { color: var(--muted); padding: 16px 0; }

/* Reference sections are quieter than the main content. */
section.ref h2 { font-size: 21px; }
section.ref { padding: 36px 0; }
.hist td:first-child { white-space: nowrap; }
.hist summary { white-space: nowrap; }
.hist details { margin: 0; }
.hist summary { font-size: var(--fs-s); }

/* Method */
.method { display: grid; grid-template-columns: 1fr 1fr; gap: 0 48px; }
.method h3:first-child { margin-top: 8px; }

.scale-table { margin-bottom: 12px; }
.scale-table td:first-child { font-variant-numeric: tabular-nums; width: 90px; }
cite { font-style: italic; }

footer { padding-bottom: 40px; }
.foot { display: flex; gap: 8px 20px; flex-wrap: wrap; padding-top: 20px; border-top: 1px solid var(--line); }

/* Dialog */
dialog {
  width: min(720px, calc(100% - 32px)); max-height: 88vh; padding: 0;
  border: 1px solid var(--line-strong); border-radius: 10px; background: var(--bg); color: var(--text);
}
dialog::backdrop { background: rgb(10 12 16 / 55%); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 24px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--bg); z-index: 1; }
#detailContent { padding: 20px 24px 28px; }
#detailContent h2 { margin-bottom: 6px; }
.statement { font-family: var(--serif); font-size: var(--fs-l); margin-bottom: 16px; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 32px; padding: 12px 0; margin-bottom: 8px; border-block: 1px solid var(--line); }
.detail-grid .k { display: block; font-size: var(--fs-s); color: var(--muted); }
.detail-grid .v { display: block; font-weight: 600; }
#detailContent ul { padding-left: 20px; margin: 0; }
#detailContent .bar-axis { display: flex; justify-content: space-between; max-width: 280px; font-size: var(--fs-xs); color: var(--muted); padding: 0 4px; }
/* Fade at the bottom edge shows that the dialog scrolls. */
dialog::after { content: ""; position: sticky; bottom: 0; display: block; height: 14px; margin-top: -14px; background: linear-gradient(transparent, var(--bg)); pointer-events: none; }
#detailContent li { margin-bottom: 4px; }

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

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

/* Tablet */
@media (max-width: 900px) {
  .top-inner { grid-template-columns: 1fr; gap: 16px; }
  .method { grid-template-columns: 1fr; }
  .chart-layout { grid-template-columns: 1fr; gap: 12px; }
  .claims tbody th { width: auto; }
}

/* Phone: tables become labelled stacks */
/* Up to 900 px the claims table becomes one card per claim; wider tables do not fit. */
@media (max-width: 900px) {
  .claims thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .claims tr {
    display: grid; grid-template-columns: auto 1fr minmax(112px, auto); gap: 8px 10px;
    grid-template-areas: "id main main" "bar bar level" "meta meta open";
    padding: 16px 0; border-bottom: 1px solid var(--line);
  }
  .claims tbody th, .claims td { border: 0; padding: 0; width: auto; }
  .claims .claim-id { grid-area: id; padding-top: 2px; }
  .claims .claim-main { grid-area: main; }
  .claims .bar-cell { grid-area: bar; align-self: center; }
  .claims .level-cell { grid-area: level; text-align: right; }
  .claims .base-cell, .claims .delta, .claims .ev-count { display: none; }
  .claims .meta-cell { grid-area: meta; display: block; font-size: var(--fs-s); color: var(--muted); align-self: center; }
  .claims .open { grid-area: open; width: auto; text-align: right; }
  .claims .level-cell { min-width: 0; }
  .claims .unc { display: none; }
  .claims .open button { min-height: 44px; padding: 4px 14px; }
  .bar { max-width: 340px; }
  .bar-axis { display: flex; justify-content: space-between; max-width: 340px; font-size: var(--fs-xs); color: var(--muted); padding: 0 4px; }
}

@media (max-width: 640px) {
  .narrow-only { display: list-item; }
  /* History: one line per entry, rationale below. */
  .stack.hist tr { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 10px; }
  .stack.hist td { display: inline; padding: 0; }
  .stack.hist td:last-child { flex-basis: 100%; }
  .stack.hist .h-date { order: 3; color: var(--muted); font-size: var(--fs-s); }
  .stack.hist .h-type { order: 2; color: var(--muted); font-size: var(--fs-s); }
  .stack.hist .lead { order: 1; }
  .stack.hist td:last-child { order: 4; }
  /* Coverage: name and state on one line. */
  .stack.gaps-table tr { display: flex; flex-wrap: wrap; gap: 0 10px; align-items: baseline; }
  .stack.gaps-table td { display: inline; }
  .stack.gaps-table .g-state { color: var(--muted); font-size: var(--fs-s); }
  .stack.gaps-table td:last-child { flex-basis: 100%; }
  .wrap { padding-left: 16px; padding-right: 16px; }
  .top-inner { padding-top: 24px; }
  :root { --fs-h1: 26px; --fs-h2: 22px; }
  section { padding: 32px 0; }
  .phone-only { display: inline; }

  /* Fade at the right edge shows that the nav scrolls. */
  nav { mask-image: linear-gradient(to right, #000 82%, transparent); -webkit-mask-image: linear-gradient(to right, #000 82%, transparent); padding-right: 48px; }

  button, .button, select, input[type=search] { min-height: 44px; }
  .control.grow { flex-basis: 100%; max-width: none; }

  .stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .facts { grid-template-columns: repeat(3, auto); gap: 4px 16px; font-size: var(--fs-s); }
  .facts dd { white-space: normal; }
  .chart .avg, .chart .tank { stroke-width: 1.75; }

  .stack tr { display: block; padding: 12px 0; border-bottom: 1px solid var(--line); }
  .stack td { display: block; border: 0; padding: 2px 0; text-align: left; }
  .stack td[data-label]::before { content: attr(data-label); display: block; color: var(--muted); font-size: var(--fs-xs); }
  .stack td.lead { font-weight: 600; }
  .stack td.lead::before { content: none; }

  .ev { grid-template-columns: 1fr; }
  .ev-aside { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 2px 14px; }
  .ev-aside dt { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .ev-aside dd { margin: 0; }
  .ev-aside .dirs { display: inline; }
  .detail-grid { grid-template-columns: 1fr; }
  dl.kv { grid-template-columns: 1fr; gap: 0; }
  dl.kv dd { margin-bottom: 10px; }
  .dialog-head, #detailContent { padding-left: 16px; padding-right: 16px; }
}
@media (min-width: 901px) {
  .meta-cell { display: none; }
  .claims .level-cell { padding-right: 20px; }
}

/* Motion: short, purposeful, and only when the reader has not asked for reduced motion. */
@media (prefers-reduced-motion: no-preference) {
  .bar .grow { transform-box: fill-box; transform: scaleX(0); transition: transform 600ms cubic-bezier(0.2, 0.8, 0.2, 1); }
  .bar .grow.from-left { transform-origin: left center; }
  .bar .grow.from-right { transform-origin: right center; }
  .in .bar .grow { transform: scaleX(1); }
  .chart .draw { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 1100ms cubic-bezier(0.3, 0.7, 0.2, 1) forwards; }
  @keyframes draw { to { stroke-dashoffset: 0; } }
  dialog[open] { animation: dialog-in 180ms ease-out; }
  dialog[open]::backdrop { animation: fade-in 180ms ease-out; }
  @keyframes dialog-in { from { opacity: 0; transform: translateY(8px) scale(0.99); } }
  @keyframes fade-in { from { opacity: 0; } }
  details[open] > :not(summary) { animation: fade-in 160ms ease-out; }
  nav a { transition: color 150ms, border-color 150ms; }
  .ev { transition: background-color 600ms ease-out, box-shadow 600ms ease-out; }
  summary::marker { transition: color 150ms; }
}
