/* Multilingual Codec Leaderboard: design tokens + layout. Light/dark are both selected palettes. */
:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --text: #14171c;
  --text-2: #4a5160;
  --muted: #7a8191;
  --border: #e3e6eb;
  --border-strong: #d0d5dd;
  --accent: #2a78d6;
  --accent-ink: #1c5cab;
  --accent-soft: rgba(42, 120, 214, 0.10);
  --tint: 42, 120, 214;          /* "better" tint in table cells (single hue) */
  --warn: #b26f00;
  --warn-soft: rgba(237, 161, 0, 0.14);
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
  --radius: 12px;
  --gold: #c99a06; --silver: #8a93a3; --bronze: #b0703a;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --bg: #0f1115; --surface: #171a20; --surface-2: #1e222a; --text: #eceef2; --text-2: #b9bec9; --muted: #8a90a0;
    --border: #2a2f39; --border-strong: #3a404c; --accent: #3987e5; --accent-ink: #86b6ef; --accent-soft: rgba(57, 135, 229, 0.16);
    --tint: 57, 135, 229; --warn: #f0b440; --warn-soft: rgba(240, 180, 64, 0.14);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1115; --surface: #171a20; --surface-2: #1e222a; --text: #eceef2; --text-2: #b9bec9; --muted: #8a90a0;
  --border: #2a2f39; --border-strong: #3a404c; --accent: #3987e5; --accent-ink: #86b6ef; --accent-soft: rgba(57, 135, 229, 0.16);
  --tint: 57, 135, 229; --warn: #f0b440; --warn-soft: rgba(240, 180, 64, 0.14);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.55 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.shell { max-width: 1480px; margin: 0 auto; padding: 0 24px; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
h1, h2, h3 { letter-spacing: -0.01em; }

/* ---------------------------------------------------------------- hero */
.hero { padding: 28px 0 18px; }
.hero-top { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.eyebrow { margin: 0 0 6px; font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent); }
h1 { font-size: 1.75rem; line-height: 1.2; margin: 0 0 6px; font-weight: 700; }
.lede { margin: 0; color: var(--text-2); max-width: 820px; }
.hero-actions { display: flex; gap: 8px; align-items: center; }
.btn {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: 9px;
  font: inherit; font-size: 13px; font-weight: 500; cursor: pointer; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
}
.btn:hover { border-color: var(--border-strong); text-decoration: none; }
.btn.icon { min-width: 34px; padding: 0 12px; justify-content: center; }
.btn.icon svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-top: 20px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; box-shadow: var(--shadow); min-width: 0; }
.stat .k { font-size: 12px; color: var(--muted); font-weight: 500; }
.stat .v { font-size: 1.35rem; font-weight: 650; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat .s { font-size: 12px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------------------------------------------------------------- tabs */
.tabs {
  position: sticky; top: 0; z-index: 30; display: flex; gap: 2px; padding: 8px 0; margin-bottom: 4px;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none;
}
.tabs button {
  background: none; border: 0; border-radius: 8px; padding: 7px 14px; color: var(--text-2);
  font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap;
}
.tabs button:hover { background: var(--surface-2); color: var(--text); }
.tabs button.active { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
main { padding: 14px 0 32px; }
.tab { display: none; }
.tab.active { display: block; }

/* ---------------------------------------------------------------- cards & toolbar */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 14px; box-shadow: var(--shadow); }
.toolbar { display: flex; flex-direction: column; gap: 12px; }
.toolbar-row { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; }
.field { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); font-weight: 500; }
.field.grow { flex: 1; }
.field.grow select { flex: 1; max-width: 520px; }
.field-label { font-size: 13px; color: var(--text-2); font-weight: 500; }
select, input[type=search], .dropdown summary {
  font: inherit; font-size: 13px; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 9px; padding: 0 10px; height: 34px;
}
select:focus, input:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.search { position: relative; display: inline-flex; align-items: center; flex: 1 1 240px; max-width: 360px; }
.search svg { position: absolute; left: 10px; width: 16px; height: 16px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; }
.search input { width: 100%; padding-left: 32px; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: none; font: inherit; font-size: 12.5px; font-weight: 500; color: var(--text-2); padding: 4px 11px; border-radius: 7px; cursor: pointer; white-space: nowrap; }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); font-weight: 600; }
fieldset { border: 0; padding: 0; margin: 0; display: flex; align-items: center; gap: 8px; }
legend { float: left; font-size: 13px; color: var(--text-2); font-weight: 500; padding: 0; margin-right: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips label {
  display: inline-flex; align-items: center; padding: 3px 10px; border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); cursor: pointer; font-size: 12.5px; color: var(--text-2); user-select: none;
}
.chips label:hover { border-color: var(--border-strong); }
.chips label:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-ink); font-weight: 500; }
.chips input { display: none; }
.chips.langs { padding-top: 2px; }
details.more > summary { cursor: pointer; font-size: 13px; font-weight: 500; color: var(--accent); list-style: none; width: fit-content; }
details.more > summary::before { content: "＋ "; }
details.more[open] > summary::before { content: "－ "; }
details.more[open] > summary { margin-bottom: 12px; }
details.more .toolbar-row + .toolbar-row { margin-top: 12px; }
.dropdown { position: relative; }
.dropdown summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 4px; }
.dropdown summary::after { content: "▾"; margin-left: 6px; color: var(--muted); }
.dropdown[open] .checklist {
  position: absolute; z-index: 40; top: 40px; left: 0; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px; max-height: 380px; overflow: auto; min-width: 260px; box-shadow: 0 12px 32px rgba(0,0,0,.18);
}
.checklist label { display: flex; gap: 8px; padding: 4px 6px; color: var(--text); font-size: 13px; align-items: center; border-radius: 6px; cursor: pointer; }
.checklist label:hover { background: var(--surface-2); }
.checklist .clear { margin-bottom: 6px; font: inherit; font-size: 12px; padding: 4px 10px; border-radius: 7px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; }
.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); cursor: pointer; user-select: none; }
.switch input { display: none; }
.switch span { width: 30px; height: 18px; border-radius: 999px; background: var(--border-strong); position: relative; transition: background .15s; flex: none; }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(12px); }
.toggles { gap: 10px 22px; }

/* ---------------------------------------------------------------- tables */
.table-meta { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 2px 2px 8px; }
.table-wrap { overflow: auto; max-height: 76vh; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
table { border-collapse: separate; border-spacing: 0; width: 100%; font-variant-numeric: tabular-nums; }
th, td { padding: 8px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; text-align: right; }
tbody tr:last-child td { border-bottom: 0; }
th {
  position: sticky; top: 0; z-index: 2; background: var(--surface-2); font-weight: 600; font-size: 12px;
  color: var(--text-2); cursor: pointer; user-select: none; letter-spacing: 0.01em;
}
th:hover { color: var(--text); }
th.sorted { color: var(--accent-ink); }
th.sorted::after { content: " ↓"; }
th.sorted.asc::after { content: " ↑"; }
th .dir { color: var(--muted); font-weight: 400; margin-left: 3px; font-size: 11px; }
td.l, th.l { text-align: left; }
td.codec { position: sticky; left: 0; background: var(--surface); z-index: 1; }
th.codec { position: sticky; left: 0; z-index: 3; }
tbody tr:hover td { background-image: linear-gradient(var(--accent-soft), var(--accent-soft)); }
.lb td.codec { min-width: 260px; max-width: 360px; white-space: normal; }
.cname { font-weight: 600; color: var(--text); cursor: pointer; }
.cname:hover { color: var(--accent); }
.cfam { display: block; font-size: 12px; color: var(--muted); margin-top: 1px; }
.badge { display: inline-block; font-size: 11px; font-weight: 500; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--border); color: var(--text-2); background: var(--surface-2); margin-left: 4px; vertical-align: 1px; }
.warn-dot { display: inline-flex; width: 16px; height: 16px; border-radius: 50%; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; color: #fff; background: var(--warn); margin-left: 4px; vertical-align: 1px; cursor: help; }
.rank { display: inline-flex; width: 26px; height: 26px; border-radius: 50%; align-items: center; justify-content: center; font-weight: 600; font-size: 12.5px; color: var(--text-2); }
.rank.r1, .rank.r2, .rank.r3 { color: #fff; }
.rank.r1 { background: var(--gold); } .rank.r2 { background: var(--silver); } .rank.r3 { background: var(--bronze); }
.scorecell { display: flex; align-items: center; gap: 10px; justify-content: flex-end; }
.scorecell b { font-weight: 650; min-width: 42px; }
.bar { width: 72px; height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; flex: none; }
.bar i { display: block; height: 100%; border-radius: 999px; background: var(--accent); }
td.num-dim { color: var(--muted); }
.gt { margin-top: 10px; }

/* ---------------------------------------------------------------- plots / detail */
.plot-card { padding: 8px; }
.plot { min-height: 420px; }
.plot.tall { min-height: 620px; }
.dhead { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.dhead h2 { margin: 0; font-size: 1.3rem; }
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px 20px; margin-top: 14px; }
.kv div { min-width: 0; overflow-wrap: anywhere; }
.kv .k { display: block; font-size: 12px; color: var(--muted); font-weight: 500; }
.warn { background: var(--warn-soft); border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent); padding: 10px 14px; border-radius: 10px; margin: 12px 0 0; color: var(--text); }
.warn strong { color: var(--warn); }
.subs { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-top: 14px; }
.sub { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }
.sub .k { font-size: 12px; color: var(--muted); }
.sub .v { font-size: 1.15rem; font-weight: 650; }
.prose { max-width: 960px; padding: 20px 28px; }
.prose h2 { margin-top: 0; }
.prose h3 { margin: 22px 0 6px; font-size: 1.02rem; }
.prose li { margin-bottom: 5px; }
pre { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 14px; overflow: auto; }
code { font-family: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace; font-size: 12.5px; }
footer { padding: 4px 0 28px; }
.tip {
  position: fixed; z-index: 100; max-width: 380px; padding: 8px 11px; border-radius: 9px; font-size: 12.5px; line-height: 1.45;
  background: var(--text); color: var(--bg); box-shadow: 0 8px 24px rgba(0,0,0,.2); pointer-events: none;
}

@media (max-width: 720px) {
  .shell { padding: 0 16px; }
  h1 { font-size: 1.3rem; }
  .hero { padding-top: 18px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lb td.codec { min-width: 180px; }
  .bar { display: none; }
  .prose { padding: 16px; }
}
