:root {
  --bg: #F6F7F9;
  --panel: #FFFFFF;
  --ink: #17202B;
  --muted: #5B6676;
  --line: #DDE2EA;
  --accent: #2F5BD3;
  --good: #1E8A5A;
  --bad: #C2412D;
  --warn: #A76A12;
  --font-sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-condensed: "IBM Plex Sans Condensed", "IBM Plex Sans", "Arial Narrow", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --gutter-left: max(16px, env(safe-area-inset-left));
  --gutter-right: max(16px, env(safe-area-inset-right));
  --radius: 6px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0F141B;
    --panel: #161D26;
    --ink: #E6EBF2;
    --muted: #97A3B4;
    --line: #263142;
    --accent: #7FA2FF;
    --good: #4CC08A;
    --bad: #F07A63;
    --warn: #E0A84A;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0F141B;
  --panel: #161D26;
  --ink: #E6EBF2;
  --muted: #97A3B4;
  --line: #263142;
  --accent: #7FA2FF;
  --good: #4CC08A;
  --bad: #F07A63;
  --warn: #E0A84A;
  color-scheme: dark;
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  overflow-x: hidden;
}

h1,
h2,
h3,
legend {
  font-family: var(--font-condensed);
  font-weight: 600;
  letter-spacing: 0;
  margin: 0;
}

h1 {
  font-size: 1.75rem;
  line-height: 1.15;
}

h2,
legend {
  font-size: 1.05rem;
}

h3 {
  font-size: 1rem;
}

p {
  margin: 0;
}

a {
  color: var(--accent);
}

button,
select,
input {
  font: inherit;
  color: inherit;
}

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

[hidden] {
  display: none !important;
}

.masthead {
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  padding: 20px var(--gutter-right) 16px var(--gutter-left);
}

.masthead-inner,
.bench {
  max-width: 1280px;
  margin: 0 auto;
}

.title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}

.badge {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: lowercase;
  border: 1px solid var(--warn);
  color: var(--warn);
  border-radius: 999px;
  padding: 1px 8px;
}

.theme-button {
  margin-left: auto;
}

.theme-button,
.quiet-button,
.preset {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 5px 10px;
  cursor: pointer;
  font-size: 0.85rem;
}

.theme-button:hover,
.quiet-button:hover,
.preset:hover {
  border-color: var(--accent);
}

.lede {
  color: var(--muted);
  margin-top: 6px;
  max-width: 68ch;
}

.dataset-switch {
  display: inline-flex;
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.dataset-switch label {
  position: relative;
  padding: 6px 14px;
  cursor: pointer;
  font-size: 0.9rem;
}

.dataset-switch label + label {
  border-left: 1px solid var(--line);
}

.dataset-switch input {
  position: absolute;
  opacity: 0;
  inset: 0;
  margin: 0;
  cursor: pointer;
}

.dataset-switch label:has(input:checked) {
  background: var(--accent);
  color: var(--panel);
}

.dataset-switch label:has(input:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.bench {
  display: grid;
  grid-template-columns: minmax(0, 340px) minmax(0, 1fr);
  gap: 28px;
  padding: 24px var(--gutter-right) 48px var(--gutter-left);
  align-items: start;
}

.controls {
  border-right: 1px solid var(--line);
  padding-right: 20px;
}

.jump-link {
  display: none;
  font-size: 0.9rem;
}

.control-block {
  border: 0;
  margin: 0;
  padding: 0 0 18px;
  min-width: 0;
}

.control-block + .control-block {
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.control-block h2,
.control-block legend {
  margin-bottom: 10px;
  padding: 0;
}

.control-block legend {
  float: left;
  width: 100%;
}

.control-block legend + * {
  clear: both;
}

.presets {
  display: grid;
  gap: 8px;
}

.preset-row {
  display: grid;
  grid-template-columns: 9.5rem 1fr;
  gap: 10px;
  align-items: center;
}

.preset {
  text-align: left;
}

.preset-text {
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.35;
}

.preset[aria-pressed="true"] {
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.filters {
  display: grid;
  gap: 10px;
}

.field {
  display: grid;
  gap: 3px;
  font-size: 0.85rem;
  color: var(--muted);
}

.field select {
  width: 100%;
  max-width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
}

.field-inline {
  display: inline-grid;
  margin: 4px 0 12px;
  min-width: min(100%, 300px);
}

.switch-row {
  padding: 8px 0;
}

.switch-row + .switch-row {
  border-top: 1px dashed var(--line);
}

.switch-label {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: start;
  cursor: pointer;
}

.switch-text {
  display: grid;
  gap: 1px;
}

.switch-name {
  font-weight: 500;
}

.switch-summary {
  color: var(--muted);
  font-size: 0.85rem;
}

input[role="switch"] {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  width: 36px;
  height: 20px;
  margin: 2px 0 0;
  border-radius: 999px;
  border: 1px solid var(--muted);
  background: var(--bg);
  cursor: pointer;
  flex: none;
  transition: background-color 140ms ease, border-color 140ms ease;
}

input[role="switch"]::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 140ms ease, background-color 140ms ease;
}

input[role="switch"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}

input[role="switch"]:checked::before {
  transform: translateX(16px);
  background: var(--panel);
}

.info {
  margin: 4px 0 0 46px;
  font-size: 0.85rem;
}

.info summary {
  color: var(--accent);
  cursor: pointer;
  width: max-content;
}

.info p {
  margin-top: 4px;
  color: var(--ink);
  max-width: 60ch;
}

.share {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.share-status {
  font-size: 0.85rem;
  color: var(--muted);
}

.results {
  display: grid;
  gap: 28px;
  min-width: 0;
}

.status-line {
  color: var(--muted);
  font-size: 0.9rem;
}

.status-error {
  color: var(--bad);
}

.dataset-note {
  display: grid;
  gap: 8px;
  border-left: 3px solid var(--accent);
  padding: 10px 14px;
  background: var(--panel);
  font-size: 0.9rem;
}

.dataset-note p {
  max-width: 72ch;
}

.hard-kinds {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 2px;
}

.hard-kinds li {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 2px 12px;
  border-bottom: 1px dashed var(--line);
  padding: 3px 0;
}

.hard-count {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.8rem;
  color: var(--muted);
}

.method > * + * {
  margin-top: 6px;
}

.notices {
  display: grid;
  gap: 8px;
}

.notices:empty {
  display: none;
}

.notice {
  border-left: 3px solid var(--line);
  padding: 8px 12px;
  background: var(--panel);
  font-size: 0.9rem;
}

.notice-warn {
  border-left-color: var(--warn);
}

.panel {
  border-top: 2px solid var(--ink);
  padding-top: 12px;
  min-width: 0;
}

.panel-head {
  display: grid;
  gap: 4px;
  margin-bottom: 14px;
}

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

.readouts {
  display: grid;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.strip {
  padding: 16px;
  display: grid;
  gap: 10px;
  min-width: 0;
}

.strip + .strip {
  border-top: 1px solid var(--line);
}

.strip-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 12px;
}

.strip-head h3 {
  font-size: 1.15rem;
}

.strip-head p {
  color: var(--muted);
  font-size: 0.85rem;
  flex: 1 1 18rem;
}

.pill {
  font-family: var(--font-condensed);
  font-weight: 600;
  font-size: 0.82rem;
  border-radius: 999px;
  padding: 1px 10px;
  border: 1px solid currentColor;
  white-space: nowrap;
}

.pill-safe {
  color: var(--good);
}

.pill-review {
  color: var(--warn);
}

.pill-risky {
  color: var(--panel);
  background: var(--bad);
  border-color: var(--bad);
}

.pill-none {
  color: var(--muted);
}

.verdict {
  font-size: 1.02rem;
  font-weight: 500;
  max-width: 70ch;
}

.stack-bar {
  display: block;
  width: 100%;
  height: 18px;
  border-radius: 3px;
}

.seg-good {
  fill: var(--good);
}

.seg-bad {
  fill: var(--bad);
}

.seg-warn {
  fill: var(--warn);
}

.seg-empty {
  fill: var(--line);
}

.count-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.count-cell {
  display: grid;
  gap: 1px;
  align-content: start;
  min-width: 0;
  border-top: 3px solid var(--line);
  padding-top: 6px;
}

.count-tp {
  border-top-color: var(--good);
}

.count-fp {
  border-top-color: var(--bad);
}

.count-fn {
  border-top-color: var(--warn);
}

.count-big {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 1.6rem;
  font-weight: 500;
  line-height: 1.15;
}

.count-label {
  font-family: var(--font-condensed);
  font-weight: 600;
  font-size: 0.92rem;
}

.count-hint {
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.3;
}

.count-raw {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.75rem;
  color: var(--muted);
}

.plain-scores {
  color: var(--muted);
  font-size: 0.85rem;
}

.plain-scores strong {
  color: var(--ink);
  font-family: var(--font-mono);
  font-weight: 500;
}

.technical summary {
  cursor: pointer;
  color: var(--accent);
  font-size: 0.85rem;
  width: max-content;
  max-width: 100%;
}

.technical[open] {
  display: grid;
  gap: 10px;
}

.technical[open] summary {
  margin-bottom: 2px;
}

.technical-row h4 {
  font-family: var(--font-condensed);
  font-weight: 500;
  font-size: 0.85rem;
  margin: 0 0 6px;
  color: var(--muted);
}

.how-to-read {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 16px;
  background: var(--panel);
}

.how-to-read summary {
  cursor: pointer;
}

.how-to-read h2 {
  display: inline;
  font-size: 0.95rem;
}

.how-to-read ul {
  margin: 6px 0 0;
  padding-left: 18px;
  display: grid;
  gap: 4px;
  font-size: 0.88rem;
}

.word-good {
  color: var(--good);
}

.word-bad {
  color: var(--bad);
}

.word-warn {
  color: var(--warn);
}

.changes {
  border-left: 3px solid var(--accent);
  padding: 4px 0 4px 14px;
  display: grid;
  gap: 6px;
}

.changes:empty {
  display: none;
}

.changes h2 {
  font-size: 1.05rem;
}

.changes ul {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 4px;
}

.changes p,
.changes li {
  max-width: 75ch;
}

.swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 4px;
  vertical-align: baseline;
}

.swatch-bad {
  background: var(--bad);
}

.swatch-warn {
  background: var(--warn);
  margin-left: 8px;
}

.metric-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.metric {
  display: grid;
  gap: 2px;
  align-content: start;
  min-width: 0;
}

.metric + .metric {
  border-left: 1px solid var(--line);
  padding-left: 12px;
}

.metric-label {
  font-family: var(--font-condensed);
  font-weight: 500;
  font-size: 0.8rem;
  color: var(--muted);
}

.metric-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 1.15rem;
  font-weight: 500;
  line-height: 1.2;
}

.metric-range {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.75rem;
  color: var(--muted);
}

.chip {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.75rem;
  border: 1px solid currentColor;
  border-radius: 999px;
  padding: 0 7px;
  white-space: nowrap;
}

.chip-good {
  color: var(--good);
}

.chip-bad {
  color: var(--bad);
}

.chip-same {
  color: var(--muted);
  border-color: var(--line);
}

.impact {
  min-width: 0;
}

.impact-chart {
  display: block;
  max-width: 100%;
  font-family: var(--font-sans);
}

.impact-chart .bar-label {
  font-size: 13px;
  fill: var(--ink);
}

.impact-chart .bar-value,
.impact-chart .tick {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  fill: var(--muted);
}

.impact-chart .axis-zero {
  stroke: var(--muted);
  stroke-width: 1;
}

.impact-chart .bar-bad {
  fill: var(--bad);
}

.impact-chart .bar-warn {
  fill: var(--warn);
}

.impact-key {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.82rem;
}

.board-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px 24px;
  margin-bottom: 16px;
}

.board-controls .switch-row {
  align-self: start;
}

.slider-row {
  display: grid;
  gap: 4px;
  align-content: start;
}

.slider-label {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-weight: 500;
}

.slider-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}

.slider-help {
  color: var(--muted);
  font-size: 0.8rem;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  margin: 4px 0;
}

.methods .method + .method {
  margin-top: 14px;
}

.method h3 {
  margin-bottom: 4px;
}

.method p {
  max-width: 72ch;
  color: var(--ink);
}

@media (max-width: 880px) {
  .bench {
    grid-template-columns: minmax(0, 1fr);
    gap: 20px;
  }

  .controls {
    border-right: 0;
    border-top: 1px solid var(--line);
    padding-top: 16px;
    padding-right: 0;
  }

  .results {
    order: -1;
  }

  .jump-link {
    display: inline-block;
    margin-bottom: 12px;
  }
}

@media (max-width: 480px) {
  h1 {
    font-size: 1.45rem;
  }

  .metric-row {
    gap: 8px;
  }

  .metric + .metric {
    padding-left: 8px;
  }

  .metric-value {
    font-size: 1rem;
  }

  .chip {
    font-size: 0.68rem;
    padding: 0 5px;
  }

  .strip {
    padding: 12px;
  }

  .count-row {
    gap: 8px;
  }

  .count-big {
    font-size: 1.3rem;
  }
}

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