:root {
  color-scheme: dark;
  --color-teal: #13110c;
  --color-booth: #211c12;
  --color-rule: #4b4127;
  --rule-hover: #6b5a2e;
  --color-tungsten: #f7d154;
  --accent-hover: #ffe18a;
  --color-ivory: #fbf5e8;
  --color-haze: #b8ab8b;
  --deep: #0d0c08;
  --mid: #1a160d;
  --low: #110f09;
  --glow: 130 100 38;
  --shade: 36 28 12;
  --panel: #100e09;
  --accent: var(--color-tungsten);
  --series-1: #f7d154;
  --series-2: #d9a84e;
  --series-3: #c78d42;
  --series-4: #b8ab8b;
  --series-5: #8e815d;
  --series-6: #6d6247;
  --series-7: #4f4734;
}

body { overflow-x: hidden; }
[id] { scroll-margin-top: calc(var(--header) + 1.5rem); }

.eyebrow, .micro, .table-note, .status {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.eyebrow { color: var(--color-tungsten); }

.hero {
  display: flex;
  align-items: center;
  min-height: min(100svh, 58rem);
  padding-top: calc(var(--header) + clamp(4rem, 10vh, 8rem));
  padding-bottom: clamp(4rem, 8vh, 7rem);
}
.hero h1 { max-width: 15ch; margin-top: 1rem; }
.hero-sub { max-width: 48rem; margin-top: 1.5rem; }
.hero-actions { margin-top: 2rem; }

.hero-meta {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  width: min(100%, 70rem);
  margin-top: clamp(3rem, 8vh, 6rem);
  padding: 1.25rem 1.5rem;
}
.run-meta div { min-width: 0; padding: 0 1rem; border-inline-start: 1px solid var(--color-rule); }
.run-meta div:first-child { padding-inline-start: 0; border-inline-start: 0; }
.run-meta dt { color: var(--color-haze); font-family: var(--font-mono); font-size: 0.7rem; text-transform: uppercase; }
.run-meta dd { margin-top: 0.35rem; overflow-wrap: anywhere; font-family: var(--font-mono); font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.hero-stats { width: min(100%, 70rem); margin-top: 2rem; }
.hero-stats .stat { text-align: center; }

.status { margin: 1.25rem 0 0; color: var(--color-haze); text-transform: none; }
.status[data-state="ok"] { color: var(--color-tungsten); }
.status[data-state="error"] { color: var(--color-alert); }

.section-head { margin-bottom: 2rem; }
.section-head > div { min-width: 0; }
.section-head h2 { margin-top: 0.6rem; }
.section-head > p:last-child { max-width: 34rem; }
.panel, .card { box-shadow: 0 18px 50px rgb(0 0 0 / 0.12); }

.table-shell { max-width: 100%; overflow-x: auto; border: 1px solid var(--color-rule); background: var(--panel); }
table { width: 100%; min-width: 980px; border-collapse: collapse; font-family: var(--font-mono); font-size: 0.78rem; font-variant-numeric: tabular-nums; }
th, td { padding: 0.9rem 1rem; border-bottom: 1px solid var(--color-rule); text-align: right; white-space: nowrap; }
th:first-child, td:first-child { position: sticky; left: 0; z-index: 2; text-align: left; background: var(--panel); }
th { color: var(--color-haze); font-size: 0.68rem; text-transform: uppercase; }
th button { min-height: 44px; margin: -0.7rem -0.8rem; padding: 0.7rem 0.8rem; border: 0; background: transparent; color: inherit; text-transform: inherit; }
th button::after { content: " ↕"; color: var(--series-5); }
th button:hover { color: var(--color-ivory); }
th[aria-sort="ascending"] button::after { content: " ↑"; color: var(--color-ivory); }
th[aria-sort="descending"] button::after { content: " ↓"; color: var(--color-ivory); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--color-booth); }
tbody tr.winner td { color: var(--color-tungsten); background: var(--color-booth); }
tbody tr.winner td:first-child::after { content: " best"; margin-left: 0.5rem; color: var(--color-tungsten); font-size: 0.62rem; text-transform: uppercase; }
.table-note { margin-top: 0.75rem; text-transform: none; }

.chart-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
figure { min-width: 0; margin: 0; padding: 1.25rem; border: 1px solid var(--color-rule); border-radius: var(--r); background: var(--color-booth); }
figcaption { margin-bottom: 0.75rem; font-family: var(--font-mono); font-size: 0.78rem; }
.chart { display: block; width: 100%; height: auto; color: var(--color-haze); }
.chart text { fill: var(--color-haze); font-family: var(--font-mono); font-size: 12px; }
.chart .axis { stroke: var(--color-rule); }
.chart .axis-label { fill: var(--color-ivory); }

.controls { display: grid; grid-template-columns: auto minmax(180px, 1fr) auto minmax(180px, 1fr); gap: 0.75rem; align-items: center; }
.control { min-height: 3.25rem; }
.text-view { min-height: 11rem; max-height: 32rem; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.8; }
.chunk-span { background: color-mix(in srgb, var(--color-tungsten) 22%, transparent); color: var(--color-ivory); }
.chunk-span[data-overlap="true"] { background: color-mix(in srgb, var(--color-tungsten) 48%, transparent); }

.failure-question { margin: 1.5rem 0 0.75rem; font-family: var(--font-mono); }
.failure-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.failure-grid .card { min-width: 0; }
.failure-grid .h3 { margin-bottom: 0.5rem; }
pre { margin-top: 1rem; white-space: pre-wrap; overflow-wrap: anywhere; }

.live-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(18rem, 0.65fr); gap: 1rem; align-items: start; text-align: start; }
.live-grid > .card { min-width: 0; }
.field + .field { margin-top: 1.25rem; }
.field p { margin-top: 0.5rem; color: var(--color-haze); font-size: 0.8rem; }
.button-row { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1rem; }
.btn-danger { border-color: var(--color-alert); color: var(--color-alert); }
.btn-danger:hover:not(:disabled) { border-color: var(--color-alert); background: color-mix(in srgb, var(--color-alert) 10%, transparent); }
.file-control { padding-block: 0.7rem; }
code { color: var(--color-tungsten); font-family: var(--font-mono); }
.run-monitor dl { margin-top: 1.5rem; }
.run-monitor dl div { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 1rem; padding: 0.8rem 0; border-bottom: 1px solid var(--color-rule); }
.run-monitor dl dt { color: var(--color-haze); font-size: 0.72rem; }
.run-monitor dl dd { margin: 0; font-family: var(--font-mono); font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.live-results { margin-top: 1rem; }

.prose { max-width: 38rem; }
.method-cards { margin-top: clamp(3rem, 5vw, 4.5rem); }
.method-cards .card { min-width: 0; }
.method-cards .h3 { margin-bottom: 0.75rem; }
.method-cards p { color: var(--soft); }
.site-footer { border-top: 1px solid var(--color-rule); }
.site-footer p { margin: 0; }

@media (max-width: 899px) {
  .hero { min-height: auto; }
  .hero-meta { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem 0; }
  .run-meta div:nth-child(3) { padding-inline-start: 0; border-inline-start: 0; }
  .chart-grid, .failure-grid { grid-template-columns: 1fr; }
  .live-grid { grid-template-columns: 1fr; }
  .controls { grid-template-columns: 1fr 2fr; }
}

@media (max-width: 639px) {
  .hero-meta { grid-template-columns: 1fr; }
  .run-meta div, .run-meta div:nth-child(3) { padding-inline: 0; border-inline-start: 0; }
  .hero-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .controls { grid-template-columns: 1fr; }
  .controls .control { margin-bottom: 0.35rem; }
}
