/* ---- tokens ------------------------------------------------------------ */
:root {
  --ground: #101a1f;
  --panel: #16242a;
  --panel-hi: #1c2f36;
  --rule: #273c44;
  --rule-soft: #1e3038;
  --paper: #e4edeb;
  --muted: #8aa3a8;
  --accent: #35c9d6;
  --accent-dim: #2a7f8b;
  --limit: #ffc857;
  --critical: #ff6b6b;
  --psd: #b07cf0;
  --pass: #5be08c;

  --gut: clamp(1rem, 3vw, 2.5rem);
  --maxw: 1280px;

  --sans: 'Archivo', system-ui, sans-serif;
  --mono: 'Roboto Mono', ui-monospace, monospace;
}

*, *::before, *::after { box-sizing: border-box; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--paper);
  font-family: var(--sans);
  font-variation-settings: 'wdth' 100;
  font-size: 16px;
  line-height: 1.55;
  overflow-x: hidden;
}

h1, h2, h3 { margin: 0; font-weight: 600; line-height: 1.15; }

/* Wide industrial setting, like an equipment nameplate. */
.display {
  font-variation-settings: 'wdth' 118;
  letter-spacing: -0.01em;
}

.readout {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum' 1;
}

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

.shell { max-width: var(--maxw); margin: 0 auto; padding: 0 var(--gut); }

/* ---- masthead ---------------------------------------------------------- */
.masthead {
  border-bottom: 1px solid var(--rule);
  background: linear-gradient(var(--panel), var(--ground));
}

.masthead-inner {
  display: flex;
  align-items: baseline;
  gap: 1rem 1.5rem;
  flex-wrap: wrap;
  padding-block: 1.1rem 1rem;
}

.wordmark {
  font-size: 1.05rem;
  font-variation-settings: 'wdth' 125;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--paper);
}

.wordmark span { color: var(--accent); }

.masthead-sub {
  color: var(--muted);
  font-size: 0.9rem;
  margin-right: auto;
}

/* Band selector reads as instrument front-panel switches. */
.bandswitch { display: flex; gap: 0; border: 1px solid var(--rule); border-radius: 3px; overflow: hidden; }

.bandswitch button {
  font: inherit;
  font-size: 0.86rem;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-right: 1px solid var(--rule);
  padding: 0.45rem 0.9rem;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}

.bandswitch button:last-child { border-right: 0; }
.bandswitch button:hover { background: var(--panel-hi); color: var(--paper); }
.bandswitch button[aria-pressed='true'] { background: var(--accent); color: #06171b; font-weight: 600; }

/* ---- standing disclaimer ----------------------------------------------- */
.disclaimer {
  background: #1d1a12;
  border-bottom: 1px solid #3a3524;
}

.disclaimer p {
  margin: 0;
  padding: 0.7rem 0 0.75rem;
  border-left: 3px solid var(--limit);
  padding-left: 0.85rem;
  color: #e8dfc6;
  font-size: 0.83rem;
  line-height: 1.5;
  max-width: 92ch;
}

.disclaimer strong { color: var(--limit); }

/* ---- hero -------------------------------------------------------------- */
.hero { padding-block: clamp(1.5rem, 4vw, 2.75rem) 0; }

.hero-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.hero-title { font-size: clamp(1.45rem, 3.4vw, 2.1rem); max-width: 22ch; }
.hero-title em { font-style: normal; color: var(--accent); }

.hero-note { color: var(--muted); font-size: 0.88rem; max-width: 38ch; }

.plot-frame {
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--panel);
  padding: 1rem 1rem 0.5rem;
  position: relative;
}

.plot-frame svg { display: block; width: 100%; height: auto; }

.plot-legend {
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
  padding: 0.65rem 0.25rem 0.5rem;
  border-top: 1px solid var(--rule-soft);
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.plot-caption {
  margin: 0;
  padding: 0 0.25rem 0.85rem;
  color: var(--muted);
  font-size: 0.82rem;
  max-width: 88ch;
}

.legend-key { display: inline-flex; align-items: center; gap: 0.45rem; }

.swatch { width: 14px; height: 10px; border-radius: 2px; flex: none; }
.swatch-accent { background: var(--accent); }
.swatch-dim { background: var(--accent-dim); }
.swatch-limit { height: 0; width: 16px; border-top: 2px dashed var(--limit); }
.swatch-planned { height: 0; width: 16px; border-top: 2px dotted var(--paper); }
.swatch-psd { background: var(--psd); border-radius: 50%; width: 10px; height: 10px; }
.swatch-bad { background: repeating-linear-gradient(135deg, var(--critical) 0 3px, transparent 3px 6px); border: 1px solid var(--critical); }

/* ---- ruling ------------------------------------------------------------ */
/* The status channel is the left bar plus the glyph and the word, never
   colour on its own. */
.ruling {
  border: 1px solid var(--rule);
  border-top: 0;
  border-left: 4px solid var(--rule);
  background: var(--panel-hi);
  padding: 1rem 1.15rem 1.1rem;
  display: grid;
  gap: 0.9rem 1.5rem;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.ruling[data-state='pass'] { border-left-color: var(--pass); }
.ruling[data-state='fail'] { border-left-color: var(--critical); }

.ruling-main { display: flex; align-items: center; gap: 0.85rem; min-width: 0; }

.ruling-glyph {
  flex: none;
  width: 2rem; height: 2rem;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 2px solid currentColor;
  font-size: 1.05rem; font-weight: 700;
  color: var(--muted);
}

.ruling[data-state='pass'] .ruling-glyph { color: var(--pass); }
.ruling[data-state='fail'] .ruling-glyph { color: var(--critical); }

.ruling-word {
  margin: 0;
  font-size: clamp(1.4rem, 3.6vw, 1.95rem);
  font-variation-settings: 'wdth' 122;
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.05;
  color: var(--muted);
}

.ruling[data-state='pass'] .ruling-word { color: var(--pass); }
.ruling[data-state='fail'] .ruling-word { color: var(--critical); }

.ruling-caveat { margin: 0.2rem 0 0; color: var(--muted); font-size: 0.83rem; }

.ruling-figures { display: flex; gap: 1.5rem; flex-wrap: wrap; }
.ruling-figures dt { color: var(--muted); font-size: 0.74rem; margin-bottom: 0.15rem; }
.ruling-figures dd { margin: 0; font-size: 1.05rem; font-variant-numeric: tabular-nums; }

.ruling-routes {
  grid-column: 1 / -1;
  margin: 0;
  padding-top: 0.75rem;
  border-top: 1px solid var(--rule-soft);
  color: var(--muted);
  font-size: 0.83rem;
}

.ruling-routes b { font-weight: 600; }
.route-open { color: var(--pass); }
.route-shut { color: var(--critical); }

@media (max-width: 640px) {
  .ruling { grid-template-columns: 1fr; align-items: start; }
}

/* ---- headline verdict -------------------------------------------------- */
.verdict {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
  border-top: 0;
  border-radius: 0 0 4px 4px;
}

.verdict > div { background: var(--panel); padding: 0.9rem 1.1rem 1rem; }

.verdict dt { color: var(--muted); font-size: 0.78rem; margin: 0 0 0.25rem; }

.verdict dd { margin: 0; }

.verdict-big {
  font-size: clamp(1.9rem, 5vw, 2.6rem);
  line-height: 1;
  font-weight: 500;
  letter-spacing: -0.02em;
}

.verdict-big .unit { font-size: 0.42em; color: var(--muted); margin-left: 0.3em; letter-spacing: 0; }

.verdict-sub { color: var(--muted); font-size: 0.85rem; margin-top: 0.3rem; }

.verdict-bind { color: var(--limit); font-weight: 600; font-size: 1.02rem; }

/* ---- workbench layout -------------------------------------------------- */
.workbench {
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
  gap: clamp(1.25rem, 3vw, 2.25rem);
  padding-block: clamp(1.75rem, 4vw, 2.75rem) 3rem;
  align-items: start;
}

@media (max-width: 860px) {
  .workbench { grid-template-columns: 1fr; }
  .controls { position: static !important; }
}

.controls {
  position: sticky;
  top: 1rem;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--panel);
}

.control-group { padding: 1rem 1.1rem 1.15rem; border-bottom: 1px solid var(--rule-soft); }
.control-group:last-child { border-bottom: 0; }

.control-group > h3 {
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 500;
  margin-bottom: 0.85rem;
}

.field { margin-bottom: 0.85rem; }
.field:last-child { margin-bottom: 0; }

.field > label {
  display: block;
  font-size: 0.85rem;
  margin-bottom: 0.3rem;
  color: var(--paper);
}

.field-hint { color: var(--muted); font-size: 0.76rem; margin-top: 0.3rem; }

select, input[type='number'] {
  width: 100%;
  font: inherit;
  font-size: 0.9rem;
  font-family: var(--mono);
  color: var(--paper);
  background: var(--ground);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 0.42rem 0.55rem;
}

select { font-family: var(--sans); }

input[type='range'] { width: 100%; accent-color: var(--accent); }

.checkrow { display: flex; align-items: flex-start; gap: 0.55rem; font-size: 0.85rem; }
.checkrow input { accent-color: var(--accent); margin-top: 0.25rem; flex: none; }

.sf-scale { display: flex; gap: 3px; }

.sf-scale button {
  flex: 1;
  font: inherit;
  font-family: var(--mono);
  font-size: 0.8rem;
  padding: 0.4rem 0;
  color: var(--muted);
  background: var(--ground);
  border: 1px solid var(--rule);
  border-radius: 2px;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}

.sf-scale button:hover { background: var(--panel-hi); color: var(--paper); }
.sf-scale button[aria-pressed='true'] { background: var(--accent); border-color: var(--accent); color: #06171b; font-weight: 700; }

details.advanced summary {
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--muted);
  padding: 0.85rem 1.1rem;
  list-style-position: inside;
}

details.advanced summary:hover { color: var(--paper); }
details.advanced[open] summary { border-bottom: 1px solid var(--rule-soft); }
details.advanced .control-group { border-bottom: 0; }

/* ---- results ----------------------------------------------------------- */
.results { display: grid; gap: clamp(1.25rem, 3vw, 1.75rem); min-width: 0; }

.section-head { margin-bottom: 0.85rem; }
.section-head h2 { font-size: 1.1rem; }
.section-head p { margin: 0.3rem 0 0; color: var(--muted); font-size: 0.88rem; max-width: 62ch; }

.paths { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0.9rem; }

/* The left bar is the status channel: it carries the verdict, not decoration. */
.path {
  border: 1px solid var(--rule);
  border-left: 3px solid var(--rule);
  border-radius: 3px;
  background: var(--panel);
  padding: 0.9rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.path[data-state='chosen'] { border-left-color: var(--accent); background: var(--panel-hi); }
.path[data-state='legal'] { border-left-color: var(--accent-dim); }
.path[data-state='blocked'] { border-left-color: var(--critical); }
.path[data-state='blocked'] .path-value { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--critical); }

.path-name { font-size: 0.95rem; font-weight: 600; }
.path-cite { font-family: var(--mono); font-size: 0.74rem; color: var(--muted); }
.path-value { font-family: var(--mono); font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.path-value .unit { font-size: 0.5em; color: var(--muted); margin-left: 0.25em; }
.path-why { font-size: 0.83rem; color: var(--muted); margin-top: auto; padding-top: 0.2rem; }

.tag {
  align-self: flex-start;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.12rem 0.45rem;
  border-radius: 2px;
  border: 1px solid currentColor;
}

.tag-chosen { color: var(--accent); }
.tag-ok { color: var(--accent-dim); }
.tag-blocked { color: var(--critical); }

/* ---- data tables ------------------------------------------------------- */
.panel {
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--panel);
  overflow: hidden;
}

table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }

caption { text-align: left; padding: 0.85rem 1rem; color: var(--muted); font-size: 0.83rem; border-bottom: 1px solid var(--rule-soft); }

th, td { text-align: left; padding: 0.55rem 1rem; border-bottom: 1px solid var(--rule-soft); }
tbody tr:last-child td { border-bottom: 0; }

th { font-weight: 500; color: var(--muted); font-size: 0.8rem; }

td.num, th.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
th.num { font-family: var(--sans); }

tr.row-governing th, tr.row-governing td { background: rgba(53, 201, 214, 0.07); color: var(--paper); }
tr.row-governing th { font-weight: 600; }

td.flag-ok { color: var(--accent); }
td.flag-bad { color: var(--critical); }

.delta { color: var(--limit); }

/* ---- footer ------------------------------------------------------------ */
.colophon {
  border-top: 1px solid var(--rule);
  background: var(--panel);
  padding-block: 1.75rem 2.5rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.colophon h2 { font-size: 0.95rem; color: var(--paper); margin-bottom: 0.5rem; }
.colophon p { max-width: 74ch; margin: 0 0 0.9rem; }
.colophon ul { margin: 0 0 0.9rem; padding-left: 1.1rem; max-width: 74ch; }
.colophon li { margin-bottom: 0.25rem; }

.caution {
  border-left: 3px solid var(--limit);
  padding: 0.65rem 0 0.65rem 0.9rem;
  color: var(--paper);
  max-width: 74ch;
  margin-bottom: 1.25rem;
}

.caution p { margin: 0 0 0.7rem; max-width: none; }
.caution p:last-child { margin-bottom: 0; }
.caution strong { color: var(--limit); }

/* ---- chart internals --------------------------------------------------- */
.grid-line { stroke: var(--rule-soft); stroke-width: 1; }
.axis-line { stroke: var(--rule); stroke-width: 1; }
.axis-text { fill: var(--muted); font-family: var(--mono); font-size: 11px; }
.axis-title { fill: var(--muted); font-family: var(--sans); font-size: 11px; }
.limit-line { stroke: var(--limit); stroke-width: 2; stroke-dasharray: 7 5; }
.limit-label { fill: var(--limit); font-family: var(--mono); font-size: 11px; }
.bar { fill: var(--accent-dim); transition: fill 140ms ease; }
.bar.is-selected { fill: var(--accent); }
.bar.is-blocked { fill: url(#hatch); stroke: var(--critical); stroke-width: 1; }
/* Keep the selection readable even when the bar is hatched. */
.bar.is-selected.is-blocked { stroke: var(--accent); stroke-width: 2.5; }
.bar-label { fill: var(--paper); font-family: var(--mono); font-size: 11px; text-anchor: middle; }
.psd-line { fill: none; stroke: var(--psd); stroke-width: 2; stroke-linejoin: round; }
.psd-dot { fill: var(--psd); stroke: var(--panel); stroke-width: 2; }
.psd-label { fill: var(--psd); font-family: var(--mono); font-size: 11px; }
.planned-line { stroke: var(--paper); stroke-width: 1.5; stroke-dasharray: 3 4; opacity: 0.85; }
.planned-label { fill: var(--paper); font-family: var(--mono); font-size: 11px; }
.hit { fill: transparent; cursor: pointer; }

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

/* SVG text scales with the viewBox, so bump it up when the plot is small. */
@media (max-width: 620px) {
  .axis-text, .limit-label, .bar-label { font-size: 17px; }
  .axis-title { font-size: 16px; }
  .psd-dot { r: 7; }
  .bar-label { font-size: 15px; }
}

.tooltip {
  position: fixed;
  pointer-events: none;
  z-index: 20;
  background: var(--ground);
  border: 1px solid var(--accent-dim);
  border-radius: 3px;
  padding: 0.5rem 0.65rem;
  font-size: 0.8rem;
  line-height: 1.45;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity 100ms ease;
  max-width: 240px;
}

.tooltip[data-show='true'] { opacity: 1; }
.tooltip b { font-family: var(--mono); font-weight: 500; color: var(--accent); }

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