:root {
  color-scheme: light;
  --bg: #f4f5f1;
  --surface: #ffffff;
  --surface-2: #eceee9;
  --ink: #151a19;
  --muted: #64706c;
  --line: #ccd2cd;
  --line-strong: #9da9a3;
  --accent: #087f6a;
  --accent-soft: #d9eee8;
  --warm: #b95f1c;
  --danger: #a83737;
  --shadow: 0 16px 40px rgba(24, 38, 33, 0.08);
  --radius: 6px;
  --provider-deepseek: #008f78;
  --provider-anthropic: #b35d2e;
  --provider-openai: #202624;
  --provider-kimi: #3b61c4;
  --provider-xai: #8c3ea8;
  --provider-google: #ca8a0a;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111513;
  --surface: #181d1b;
  --surface-2: #202724;
  --ink: #edf1ed;
  --muted: #9da8a2;
  --line: #34403a;
  --line-strong: #56635d;
  --accent: #49c9aa;
  --accent-soft: #173e35;
  --warm: #e28b4c;
  --danger: #ec7777;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.25);
  --provider-openai: #d8dedb;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Avenir Next", Avenir, "Helvetica Neue", sans-serif;
  font-size: 14px;
  letter-spacing: 0;
  min-width: 320px;
}

button, input, select { font: inherit; letter-spacing: 0; }
button, select { cursor: pointer; }

.topbar {
  min-height: 84px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 14px clamp(20px, 4vw, 64px);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand-block, .topbar-meta, .freshness, .control-band, .section-heading {
  display: flex;
  align-items: center;
}

.brand-block { gap: 13px; }
.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  background: var(--ink);
  color: var(--bg);
  border-radius: 3px;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
  font-weight: 700;
}

h1, h2, h3, p { margin-top: 0; }
h1, h2 {
  font-family: "Iowan Old Style", "Baskerville", serif;
  letter-spacing: 0;
}

h1 { margin-bottom: 0; font-size: 25px; line-height: 1; }
h2 { margin-bottom: 0; font-size: clamp(22px, 2.4vw, 34px); line-height: 1.15; font-weight: 600; }
h3 { margin-bottom: 14px; font-size: 13px; text-transform: uppercase; color: var(--muted); }

.eyebrow, .section-kicker {
  margin-bottom: 5px;
  color: var(--accent);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.topbar-meta { gap: 18px; }
.freshness { gap: 8px; color: var(--muted); font-size: 12px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.icon-button {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font-size: 18px;
}
.icon-button:hover { border-color: var(--line-strong); transform: translateY(-1px); }

main { width: min(1440px, 100%); margin: 0 auto; }
section { padding: 38px clamp(20px, 4vw, 64px); border-bottom: 1px solid var(--line); }

.brief-band {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(320px, 0.7fr);
  gap: clamp(32px, 6vw, 100px);
  min-height: 210px;
  align-items: end;
}
.brief-copy h2 { max-width: 840px; }
.brief-verdict { max-width: 900px; margin: 12px 0 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.brief-stats { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 2px solid var(--ink); }
.stat-cell { padding: 16px 8px 4px 0; border-right: 1px solid var(--line); }
.stat-cell:last-child { padding-left: 14px; border-right: 0; }
.stat-cell:nth-child(2) { padding-left: 14px; }
.stat-label { display: block; color: var(--muted); font-size: 11px; margin-bottom: 8px; }
.stat-cell strong { font-family: "SFMono-Regular", Consolas, monospace; font-size: 22px; }

.control-band {
  padding-top: 18px;
  padding-bottom: 18px;
  gap: 14px;
  background: var(--surface-2);
  position: sticky;
  top: 84px;
  z-index: 10;
}
.search-field {
  min-width: 260px;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.search-field input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--ink); }
.search-field input::placeholder { color: var(--muted); }
.segmented { display: grid; grid-template-columns: repeat(3, minmax(120px, 1fr)); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.segment { min-height: 38px; padding: 0 13px; border: 0; border-right: 1px solid var(--line); background: var(--surface); color: var(--muted); font-size: 12px; }
.segment:last-child { border-right: 0; }
.segment.active { background: var(--ink); color: var(--bg); }
.select-field { height: 40px; display: flex; align-items: center; gap: 8px; padding: 0 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--muted); font-size: 12px; }
.select-field select { border: 0; outline: 0; background: transparent; color: var(--ink); }

.section-heading { justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.section-heading h2 { font-size: 25px; }
.section-note { max-width: 520px; margin: 0; text-align: right; color: var(--muted); font-size: 12px; line-height: 1.6; }

.chart-wrap {
  position: relative;
  width: 100%;
  height: clamp(340px, 42vw, 520px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}
#modelChart { display: block; width: 100%; height: 100%; }
.chart-tooltip {
  position: absolute;
  pointer-events: none;
  max-width: 220px;
  padding: 9px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--ink);
  color: var(--bg);
  box-shadow: var(--shadow);
  font-size: 11px;
  line-height: 1.5;
  transform: translate(12px, -50%);
}
.chart-tooltip strong { display: block; font-size: 12px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 9px 18px; margin-top: 16px; }
.legend-item { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 11px; }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; }

.table-shell { overflow-x: auto; border-top: 2px solid var(--ink); }
table { width: 100%; min-width: 1120px; border-collapse: collapse; }
th { padding: 12px 14px 12px 0; border-bottom: 1px solid var(--line-strong); color: var(--muted); font-size: 10px; text-align: left; text-transform: uppercase; }
td { padding: 17px 14px 17px 0; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr { transition: background 150ms ease; }
tbody tr:hover, tbody tr.selected { background: var(--accent-soft); }
tbody tr { cursor: pointer; }
.model-cell { display: flex; align-items: center; gap: 12px; min-width: 220px; }
.provider-glyph { width: 32px; height: 32px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 3px; color: white; font-family: "SFMono-Regular", Consolas, monospace; font-size: 10px; font-weight: 800; }
.model-name { display: block; font-weight: 700; }
.model-variant { display: block; max-width: 220px; margin-top: 3px; color: var(--muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.index-score { font-family: "Iowan Old Style", Baskerville, serif; font-size: 23px; font-weight: 700; }
.mono { font-family: "SFMono-Regular", Consolas, monospace; font-size: 12px; }
.metric-source-link { display: inline-flex; flex-direction: column; gap: 3px; color: inherit; text-decoration: none; }
.metric-source-link:hover, .metric-source-link:focus-visible { color: var(--accent); }
.metric-source-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.metric-source-domain { font-family: "SFMono-Regular", Consolas, monospace; font-size: 8px; font-weight: 500; text-transform: none; white-space: nowrap; }
.speed-value { white-space: nowrap; }
.speed-unit { color: var(--muted); font-size: 9px; }
.modality-list { display: flex; gap: 4px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; min-height: 22px; padding: 2px 7px; border: 1px solid var(--line); border-radius: 3px; color: var(--muted); font-size: 10px; text-transform: uppercase; }

.aa-breakdown-section { background: var(--surface-2); }
.aa-breakdown-heading { align-items: flex-end; }
.aa-score-controls { display: flex; align-items: center; gap: 10px; }
.aa-score-label { color: var(--muted); font-size: 11px; }
.score-segmented { display: grid; grid-template-columns: repeat(2, minmax(118px, 1fr)); border: 1px solid var(--line-strong); border-radius: var(--radius); overflow: hidden; }
.score-segment { min-height: 36px; padding: 0 11px; border: 0; border-right: 1px solid var(--line); background: var(--surface); color: var(--muted); font-size: 11px; }
.score-segment:last-child { border-right: 0; }
.score-segment.active { background: var(--ink); color: var(--bg); }
.score-segment:focus-visible { position: relative; z-index: 2; outline: 3px solid color-mix(in srgb, var(--accent) 65%, transparent); outline-offset: -3px; }
.aa-breakdown-note { max-width: 980px; margin: -8px 0 20px; color: var(--muted); font-size: 11px; line-height: 1.6; }
.aa-breakdown-shell { overflow-x: auto; border-top: 2px solid var(--ink); background: var(--surface); }
.aa-breakdown-table { min-width: 1280px; table-layout: fixed; }
.aa-breakdown-table tbody tr { cursor: default; }
.aa-breakdown-table th, .aa-breakdown-table td { padding: 12px 10px; border-right: 1px solid var(--line); }
.aa-breakdown-table tr > :last-child { border-right: 0; }
.aa-dimension-column, .aa-dimension-cell { position: sticky; left: 0; width: 260px; background: var(--surface); z-index: 3; }
.aa-dimension-column { z-index: 5; }
.aa-model-head { width: 145px; padding: 6px !important; background: var(--surface); text-align: center; }
.aa-model-head.selected { background: var(--accent-soft); }
.aa-model-button { width: 100%; min-height: 58px; padding: 6px; border: 0; background: transparent; color: var(--ink); }
.aa-model-button span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; font-weight: 700; }
.aa-model-button strong { display: block; margin-top: 6px; color: var(--accent); font-family: "SFMono-Regular", Consolas, monospace; font-size: 10px; }
.aa-model-button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.aa-dimension-cell { text-align: left; }
.aa-dimension-cell a { display: inline-flex; align-items: center; gap: 4px; color: var(--ink); font-size: 12px; text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
.aa-dimension-cell a:hover { color: var(--accent); text-decoration-color: var(--accent); }
.aa-dimension-cell > strong { display: block; margin-top: 5px; color: var(--accent); font-size: 10px; }
.aa-dimension-cell > span { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; font-weight: 400; line-height: 1.4; }
.aa-score-cell { position: relative; height: 82px; overflow: hidden; background: var(--surface); text-align: center; }
.aa-score-fill { position: absolute; left: 0; bottom: 0; width: calc(var(--aa-score) * 1%); height: 100%; background: var(--accent); opacity: 0.1; }
.aa-score-cell strong, .aa-score-cell > span:last-child { position: relative; z-index: 1; display: block; }
.aa-score-cell strong { font-family: "SFMono-Regular", Consolas, monospace; font-size: 16px; }
.aa-score-cell > span:last-child { margin-top: 5px; color: var(--muted); font-size: 9px; white-space: nowrap; }
.aa-score-cell.is-best .aa-score-fill { background: var(--warm); opacity: 0.16; }
.aa-score-cell.is-best > span:last-child { color: var(--warm); font-weight: 700; }
.aa-score-cell.selected { box-shadow: inset 0 0 0 2px var(--accent); }
.aa-score-cell.is-empty { color: var(--muted); }

.evidence-grid { display: grid; grid-template-columns: 1.2fr 0.8fr; gap: 60px; }
.source-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.source-link {
  position: relative;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  min-height: 118px;
  padding: 15px 16px 14px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  box-shadow: 0 3px 0 transparent;
  transition: background 150ms ease, border-color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}
.source-link--independent { border-left-color: var(--warm); }
.source-link:hover { background: var(--accent-soft); border-color: var(--accent); box-shadow: 0 4px 0 color-mix(in srgb, var(--accent) 22%, transparent); transform: translateY(-2px); }
.source-link--independent:hover { border-color: var(--warm); box-shadow: 0 4px 0 color-mix(in srgb, var(--warm) 22%, transparent); }
.source-link:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 65%, transparent); outline-offset: 3px; }
.source-main { min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 7px; }
.source-heading { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; line-height: 1.35; }
.source-heading strong { font-weight: 700; }
.source-arrow { flex: 0 0 auto; color: var(--accent); font-family: "SFMono-Regular", Consolas, monospace; font-size: 16px; line-height: 1; transition: transform 150ms ease; }
.source-link--independent .source-arrow { color: var(--warm); }
.source-link:hover .source-arrow { transform: translate(2px, -2px); }
.source-description { color: var(--muted); font-size: 11px; line-height: 1.45; }
.source-evidence { margin-right: 6px; color: var(--ink); font-weight: 700; }
.source-domain { color: var(--muted); font-family: "SFMono-Regular", Consolas, monospace; font-size: 10px; }
.source-meta { display: flex; flex: 0 0 auto; flex-direction: column; align-items: flex-end; gap: 7px; }
.source-type { display: inline-flex; align-items: center; min-height: 22px; padding: 3px 7px; border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--line)); border-radius: 3px; color: var(--accent); font-family: "SFMono-Regular", Consolas, monospace; font-size: 9px; font-weight: 700; white-space: nowrap; }
.source-link--independent .source-type { border-color: color-mix(in srgb, var(--warm) 55%, var(--line)); color: var(--warm); }
.source-checked { color: var(--muted); font-family: "SFMono-Regular", Consolas, monospace; font-size: 9px; white-space: nowrap; }
.caveat-list { margin: 0; padding: 0; list-style: none; counter-reset: caveat; }
.caveat-list li { counter-increment: caveat; position: relative; padding: 0 0 15px 38px; color: var(--muted); line-height: 1.55; }
.caveat-list li::before { content: counter(caveat, decimal-leading-zero); position: absolute; left: 0; top: 0; color: var(--warm); font-family: "SFMono-Regular", Consolas, monospace; font-size: 10px; }

footer { display: flex; justify-content: space-between; gap: 20px; max-width: 1440px; margin: 0 auto; padding: 20px clamp(20px, 4vw, 64px) 42px; color: var(--muted); font-size: 10px; font-family: "SFMono-Regular", Consolas, monospace; }
.error-state { position: fixed; inset: auto 20px 20px; z-index: 50; display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; border: 1px solid var(--danger); border-radius: var(--radius); background: var(--surface); color: var(--danger); box-shadow: var(--shadow); }
.error-state[hidden] { display: none; }

@media (max-width: 980px) {
  .brief-band { grid-template-columns: 1fr; }
  .brief-band { min-height: auto; }
  .control-band { flex-wrap: wrap; top: 73px; }
  .search-field { min-width: calc(100% - 160px); }
  .segmented { width: 100%; order: 3; }
  .evidence-grid { grid-template-columns: 1fr; gap: 34px; }
}

@media (max-width: 640px) {
  .topbar { min-height: 70px; padding: 12px 16px; }
  .brand-mark { width: 38px; height: 38px; }
  h1 { font-size: 21px; }
  .freshness { display: none; }
  section { padding: 30px 16px; }
  .brief-band { gap: 30px; }
  .brief-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stat-cell strong { font-size: 17px; }
  .control-band { position: static; top: auto; padding-top: 12px; padding-bottom: 12px; }
  .search-field { min-width: 100%; }
  .select-field { width: 100%; justify-content: space-between; }
  .segmented { grid-template-columns: 1fr; }
  .segment { border-right: 0; border-bottom: 1px solid var(--line); }
  .segment:last-child { border-bottom: 0; }
  .section-heading { align-items: flex-start; flex-direction: column; gap: 8px; }
  .section-note { max-width: 100%; text-align: left; }
  .chart-wrap { height: 370px; }
  .aa-score-controls { width: 100%; justify-content: space-between; }
  .score-segmented { min-width: 0; grid-template-columns: repeat(2, minmax(104px, 1fr)); }
  .score-segment { padding: 0 8px; }
  .aa-breakdown-note { margin-top: 0; }
  .aa-dimension-column, .aa-dimension-cell { width: 210px; }
  .source-list { grid-template-columns: 1fr; }
  .source-link { min-height: 0; }
  .source-heading { font-size: 12px; }
  .source-description { max-width: 28ch; }
  footer { padding-left: 16px; padding-right: 16px; }
}

@media (prefers-reduced-motion: no-preference) {
  .brief-copy, .brief-stats, .chart-wrap, .table-shell, .aa-breakdown-shell { animation: rise 500ms ease both; }
  .brief-stats { animation-delay: 70ms; }
  .chart-wrap { animation-delay: 120ms; }
  .table-shell { animation-delay: 170ms; }
  @keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
}
