/* NSFWBench theme v2: tokens and components for every page. Page layouts live in site.css (production)
   and explore.css (the /explore/ prototypes).
   Direction: research leaderboard. Flat surfaces, 1px borders, monochrome chrome, one restrained teal
   accent for selection, focus and data. Sentence-case labels, one heading per block. Dark by default,
   light via the header toggle. */

@font-face {
  font-family: "Newsreader";
  src: url("../fonts/newsreader-display-500-latin.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root, [data-theme="dark"] {
  color-scheme: dark;
  --bg: #0c0e0f;
  --bg-2: #0f1213;
  --surface: #131617;
  --surface-2: #181c1e;
  --hover: #1b2022;
  --border: #22282a;
  --border-2: #2e3639;
  --text: #e7eaea;
  --text-2: #b3bbbd;
  --muted: #869195;
  --faint: #5f6a6e;
  --accent: #2dd4bf;
  --accent-2: #14b8a6;
  --accent-soft: rgba(45, 212, 191, .1);
  --accent-line: rgba(45, 212, 191, .38);
  --on-accent: #032320;
  --warn: #d4a45e;
  --danger: #e27b6f;
  --track: #1f2527;
  --scrim: rgba(6, 8, 9, .72);
  --shadow: 0 12px 32px rgba(0, 0, 0, .45), 0 0 0 1px var(--border-2);
  --viewport: #0f1113;
}
[data-theme="light"] {
  color-scheme: light;
  --bg: #f7f8f8;
  --bg-2: #ffffff;
  --surface: #ffffff;
  --surface-2: #f2f4f4;
  --hover: #edf0f0;
  --border: #e2e6e6;
  --border-2: #d0d7d7;
  --text: #111516;
  --text-2: #3b4547;
  --muted: #637073;
  --faint: #8b9699;
  --accent: #0f766e;
  --accent-2: #0d9488;
  --accent-soft: rgba(13, 148, 136, .09);
  --accent-line: rgba(13, 148, 136, .4);
  --on-accent: #ffffff;
  --warn: #92650f;
  --danger: #b0433a;
  --track: #e5e9e9;
  --scrim: rgba(20, 24, 25, .4);
  --shadow: 0 12px 32px rgba(20, 30, 32, .12), 0 0 0 1px var(--border-2);
}
:root {
  --sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --serif: "Newsreader", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --r: 8px;
  --r-lg: 12px;
  --header-h: 56px;
  --wrap: 1320px;
  --pad: 24px;
}

/* ---------- base ---------- */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}
main { flex: 1; }
a { color: inherit; }
img, svg { display: block; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.num, .tnum { font-variant-numeric: tabular-nums; }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 var(--pad); }
.serif, .x-title h1, .x-title h2 { font-family: var(--serif); font-weight: 500; font-synthesis: none; letter-spacing: -.01em; }
.muted { color: var(--muted); }
.kicker { color: var(--muted); font-size: 12.5px; font-weight: 500; }
[hidden] { display: none !important; }

/* ---------- header / footer ---------- */

.x-header { position: sticky; top: 0; z-index: 50; background: var(--bg); border-bottom: 1px solid var(--border); }
.x-nav { display: flex; align-items: center; gap: 20px; height: var(--header-h); }
.wm { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); flex: none; }
.wm-mark { width: 18px; height: 14px; }
.wm-mark circle { fill: var(--faint); }
.wm-mark circle.on { fill: var(--accent); }
.wm-text { font: 600 15px/1 var(--sans); letter-spacing: .01em; }
.wm-text span { font: 500 15px/1 var(--mono); color: var(--text-2); letter-spacing: -.02em; margin-left: 1px; }
.wm-tag { padding: 3px 7px; border: 1px solid var(--border-2); border-radius: 999px; color: var(--muted); font: 500 11px/1 var(--mono); }
.x-links { display: flex; gap: 2px; margin: 0; padding: 0; list-style: none; }
.x-links a { display: block; padding: 7px 10px; border-radius: 6px; color: var(--muted); text-decoration: none; font-weight: 500; white-space: nowrap; }
.x-links a:hover { color: var(--text); background: var(--hover); }
.x-links a[aria-current="page"] { color: var(--text); background: var(--surface-2); }
.x-spacer { flex: 1; }
.x-tools { display: flex; align-items: center; gap: 8px; }
.x-tools .x-menu-btn { display: none; }
.x-drawer { display: none; }
.x-footer { margin-top: 72px; border-top: 1px solid var(--border); color: var(--faint); font-size: 12.5px; }
.x-footer .wrap { display: flex; flex-wrap: wrap; gap: 8px 24px; justify-content: space-between; padding-top: 22px; padding-bottom: 28px; }
.x-footer a { color: var(--muted); }

/* ---------- controls ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 34px; padding: 0 12px;
  border: 1px solid var(--border-2); border-radius: var(--r);
  background: var(--surface); color: var(--text);
  font-weight: 500; font-size: 13.5px; white-space: nowrap; text-decoration: none;
  transition: background-color .15s, border-color .15s;
}
.btn:hover { background: var(--hover); }
.btn svg { width: 16px; height: 16px; flex: none; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--text); border-color: var(--text); color: var(--bg); }
.btn-primary:hover { background: var(--text-2); border-color: var(--text-2); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--hover); color: var(--text); }
.btn-sm { height: 28px; padding: 0 9px; font-size: 12.5px; border-radius: 7px; }
.btn-lg { height: 44px; padding: 0 18px; font-size: 15px; }
.btn-sm svg { width: 14px; height: 14px; }
.btn-icon { width: 34px; padding: 0; }
.btn-icon.btn-sm { width: 28px; }
.btn-light { background: var(--surface-2); }
.btn .count { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent-soft); color: var(--accent); font: 600 11px/18px var(--sans); font-variant-numeric: tabular-nums; }
.btn[aria-expanded="true"] { border-color: var(--accent-line); background: var(--surface-2); }
.btn .caret { width: 14px; height: 14px; color: var(--muted); }
.linkish { padding: 0; border: 0; background: none; color: var(--text-2); text-decoration: underline; text-decoration-color: var(--border-2); text-underline-offset: 3px; font-size: 13px; }
.linkish:hover { color: var(--text); text-decoration-color: var(--muted); }

.input, .select {
  height: 34px; padding: 0 11px;
  border: 1px solid var(--border-2); border-radius: var(--r);
  background: var(--bg-2); color: var(--text);
  font-size: 13.5px;
}
.input::placeholder { color: var(--faint); }
.input:focus, .select:focus { outline: none; border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }
.select { padding-right: 30px; appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 15px) 50%, calc(100% - 10px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.search { position: relative; display: flex; align-items: center; }
.search svg { position: absolute; left: 10px; width: 15px; height: 15px; color: var(--faint); pointer-events: none; }
.search .input { width: 100%; padding-left: 32px; }
.search kbd { position: absolute; right: 8px; padding: 2px 6px; border: 1px solid var(--border-2); border-radius: 5px; color: var(--faint); font: 500 11px/1.2 var(--mono); pointer-events: none; }
.search .input:focus ~ kbd, .search .input:not(:placeholder-shown) ~ kbd { display: none; }
input[type="search"]::-webkit-search-cancel-button { filter: grayscale(1) opacity(.6); }

.cb { display: inline-flex; align-items: center; gap: 9px; min-width: 0; cursor: pointer; }
.cb input { position: absolute; opacity: 0; width: 16px; height: 16px; margin: 0; pointer-events: none; }
.cb-box { position: relative; flex: none; width: 16px; height: 16px; border: 1px solid var(--border-2); border-radius: 4px; background: var(--bg-2); transition: background-color .12s, border-color .12s; }
.cb input:checked + .cb-box, .cb input:indeterminate + .cb-box { background: var(--accent-2); border-color: var(--accent-2); }
.cb input:checked + .cb-box::after { content: ""; position: absolute; left: 4.5px; top: 1.5px; width: 5px; height: 9px; border: solid var(--on-accent); border-width: 0 2px 2px 0; transform: rotate(45deg); }
.cb input:indeterminate + .cb-box::after { content: ""; position: absolute; left: 3px; right: 3px; top: 6.5px; height: 2px; background: var(--on-accent); border-radius: 1px; }
.cb input:focus-visible + .cb-box { outline: 2px solid var(--accent); outline-offset: 2px; }
.cb-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.seg { display: inline-flex; padding: 2px; border: 1px solid var(--border-2); border-radius: var(--r); background: var(--bg-2); }
.seg button, .seg a { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border: 0; border-radius: 6px; background: none; color: var(--muted); font-size: 13px; font-weight: 500; text-decoration: none; white-space: nowrap; }
.seg button svg, .seg a svg { width: 15px; height: 15px; }
.seg [aria-pressed="true"], .seg [aria-current="page"], .seg [aria-selected="true"] { background: var(--surface-2); color: var(--text); box-shadow: 0 0 0 1px var(--border-2); }

.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; height: 26px; padding: 0 6px 0 10px; border: 1px solid var(--border-2); border-radius: 999px; background: var(--surface); color: var(--text-2); font-size: 12.5px; }
.chip:hover { border-color: var(--muted); color: var(--text); }
.chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip small { color: var(--faint); font-size: 12px; }
.chip svg { width: 13px; height: 13px; flex: none; color: var(--muted); }

.badge { display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 7px; border: 1px solid var(--border-2); border-radius: 5px; color: var(--muted); font-size: 11.5px; font-weight: 500; white-space: nowrap; }
.st::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.st-judged { color: var(--text-2); }
.st-judged::before { background: var(--accent-2); }
.st-pending { color: var(--muted); border-style: dashed; }
.st-pending::before { background: transparent; box-shadow: inset 0 0 0 1.5px var(--muted); }
.st-refused { color: var(--warn); }
.st-failed { color: var(--danger); }
.badge-example { border-style: dashed; color: var(--faint); }

/* ---------- scores ---------- */

.score { display: inline-flex; align-items: baseline; gap: 1px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.score b { font-weight: 600; font-size: 15px; color: var(--text); }
.score small { color: var(--faint); font-size: 11.5px; }
.score.none b { color: var(--faint); font-weight: 500; }
.bar { position: relative; display: block; height: 4px; border-radius: 2px; background: var(--track); overflow: hidden; }
.bar i { position: absolute; inset: 0 auto 0 0; border-radius: 2px; background: var(--accent-2); }
.axes { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.axis { display: grid; gap: 4px; min-width: 0; }
.axis-top { display: flex; justify-content: space-between; gap: 4px; color: var(--muted); font-size: 11.5px; }
.axis-top b { color: var(--text-2); font-weight: 600; font-variant-numeric: tabular-nums; }
.rank { font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 600; }
.rank.top { color: var(--accent); }

/* ---------- embeds (markup from assets/js/embeds.js) ---------- */

.embed { position: relative; aspect-ratio: 1 / 1; overflow: hidden; background: var(--viewport); isolation: isolate; container-type: inline-size; }
.embed > .thumb, .embed > .poster, .embed > iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.embed > .thumb { object-fit: cover; }
.embed > iframe { opacity: 0; transition: opacity .3s ease; background: transparent; }
.embed > iframe.ready { opacity: 1; }
.embed.passive > iframe { pointer-events: none; }
.embed.ready > .thumb, .embed.ready > .poster { visibility: hidden; }
.poster { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; background: var(--viewport); color: #6b767a; font-size: 12px; }
.poster-mark { width: 30%; aspect-ratio: 1; border: 1px solid #2a3134; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #6b767a; }
.embed.loading .poster-mark { animation: xPulse 1.6s ease-in-out infinite; }
@keyframes xPulse { 50% { opacity: .4; } }
.failed { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 12px; text-align: center; background: var(--viewport); color: #8a9599; font-size: 12px; }
.failed::before { content: ""; width: 22px; height: 22px; margin-bottom: 4px; border: 1.5px solid currentColor; border-radius: 50%; background: linear-gradient(45deg, transparent 46%, currentColor 46% 54%, transparent 54%); color: #e27b6f; opacity: .8; }
.failed.refused::before { background: linear-gradient(90deg, transparent 30%, currentColor 30% 70%, transparent 70%) center / 100% 1.5px no-repeat; color: #d4a45e; }
.failed strong { color: #d7dcdd; font-size: 13px; font-weight: 600; }
.failed span { max-width: 26ch; }
@container (max-width: 150px) { .failed span { display: none; } .failed { font-size: 11px; } }
.embed-hint { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); padding: 4px 9px; border-radius: 6px; background: rgba(12, 14, 15, .82); color: #cfd5d6; font-size: 11.5px; white-space: nowrap; pointer-events: none; animation: xHint 2.6s ease forwards; }
@keyframes xHint { 0%, 70% { opacity: 1; } 100% { opacity: 0; } }

/* ---------- popovers, sheets, modal, toast ---------- */

.pop-wrap { position: relative; }
.pop {
  position: absolute; z-index: 60; top: calc(100% + 6px); left: 0;
  width: 320px; max-width: calc(100vw - 32px); max-height: min(70vh, 560px);
  display: flex; flex-direction: column;
  border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow);
  overflow: hidden;
}
.pop.align-right { left: auto; right: 0; }
.pop-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 14px 10px; border-bottom: 1px solid var(--border); }
.pop-head h2 { font-size: 13px; font-weight: 600; }
.pop-body { padding: 10px 14px; overflow-y: auto; overscroll-behavior: contain; }
.pop-foot { display: flex; justify-content: space-between; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--border); }
.pop-close { display: none; }
.scrim { position: fixed; inset: 0; z-index: 55; background: var(--scrim); }
.opt-list { display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; }
.opt { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 4px; border-radius: 6px; }
.opt:hover { background: var(--hover); }
.opt .n { color: var(--faint); font-size: 12px; font-variant-numeric: tabular-nums; }

.modal { position: fixed; inset: 0; z-index: 80; display: flex; align-items: center; justify-content: center; padding: 24px; background: var(--scrim); animation: xFade .15s ease; }
@keyframes xFade { from { opacity: 0; } }
.modal-box { width: min(980px, 100%); max-height: calc(100vh - 48px); display: flex; flex-direction: column; border-radius: var(--r-lg); background: var(--bg-2); box-shadow: var(--shadow); overflow: hidden; }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px 14px 20px; border-bottom: 1px solid var(--border); }
.modal-head h2 { flex: 1; min-width: 0; font: 500 21px/1.2 var(--serif); font-synthesis: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-head h2 small { display: block; margin-bottom: 3px; color: var(--muted); font: 500 12.5px/1.2 var(--sans); }
.modal-head h2 small .tag { margin-left: 8px; font-family: var(--mono); font-size: 11.5px; }
.modal-head .actions { display: flex; gap: 6px; }
.modal-body { padding: 20px; overflow-y: auto; overscroll-behavior: contain; }
.prompt-text { margin: 0; white-space: pre-wrap; word-wrap: break-word; color: var(--text-2); font: 13px/1.62 var(--mono); }
.toast { position: fixed; left: 50%; bottom: 24px; z-index: 90; transform: translate(-50%, 12px); padding: 9px 14px; border-radius: var(--r); background: var(--text); color: var(--bg); font-size: 13px; font-weight: 500; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- content notice (replaces the age gate) ---------- */

html.gate body > :not(.notice):not(.x-header) { visibility: hidden; }
html.gate .x-header .x-tools, html.gate .x-header .x-links, html.gate .x-menu-btn { visibility: hidden; }
.notice { position: fixed; inset: var(--header-h) 0 0; z-index: 70; display: flex; align-items: flex-start; justify-content: center; padding: 12vh 20px 40px; background: var(--bg); overflow-y: auto; }
.notice-box { width: min(520px, 100%); }
.notice-box h2 { margin: 10px 0 14px; font: 500 32px/1.15 var(--serif); font-synthesis: none; letter-spacing: -.01em; }
.notice-box p { color: var(--text-2); font-size: 15px; line-height: 1.6; }
.notice-box p + p { margin-top: 10px; }
.notice-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 26px; }
.notice-actions .btn { height: 40px; padding: 0 16px; font-size: 14px; }
.notice-fine { margin-top: 18px !important; color: var(--faint) !important; font-size: 12.5px !important; }

/* ---------- page heads, toolbars, empty state, pager ---------- */

.x-title { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 24px; padding: 36px 0 20px; }
.x-title h1 { font-size: clamp(28px, 3.4vw, 38px); line-height: 1.1; }
.x-title .lead { max-width: 64ch; margin-top: 8px; color: var(--text-2); font-size: 15px; }
.x-meta { margin-top: 10px; color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.x-meta b { color: var(--text-2); font-weight: 600; }
.x-meta .sep { margin: 0 6px; color: var(--faint); }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.toolbar .grow { flex: 1; }
.result-line { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; min-height: 28px; margin: 14px 0 12px; color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.result-line b { color: var(--text-2); font-weight: 600; }
.empty { display: grid; justify-items: center; gap: 10px; padding: 64px 20px; border: 1px dashed var(--border-2); border-radius: var(--r-lg); text-align: center; }
.empty h2 { font: 500 22px/1.2 var(--serif); font-synthesis: none; }
.empty p { max-width: 44ch; color: var(--muted); }
.empty .chips { justify-content: center; margin-top: 6px; }
.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px; margin-top: 24px; }
.pager button, .pager span { min-width: 32px; height: 32px; padding: 0 8px; border: 1px solid transparent; border-radius: 7px; background: none; color: var(--text-2); font-variant-numeric: tabular-nums; }
.pager button:hover { background: var(--hover); }
.pager button[aria-current="page"] { border-color: var(--border-2); background: var(--surface-2); color: var(--text); font-weight: 600; }
.pager button[disabled] { opacity: .4; cursor: default; }
.pager span { display: inline-flex; align-items: center; justify-content: center; color: var(--faint); }
.load-more { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-top: 20px; color: var(--muted); font-size: 12.5px; }

/* ---------- test matrix (3 subjects x 4 styles) ---------- */

.matrix { display: grid; grid-template-columns: 64px repeat(4, minmax(0, 1fr)); gap: 3px; font-size: 11.5px; }
.matrix .mh { color: var(--muted); font-size: 11.5px; text-align: center; padding-bottom: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.matrix .mr { display: flex; align-items: center; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.matrix label { position: relative; display: flex; align-items: center; justify-content: center; height: 30px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg-2); color: var(--text-2); font-variant-numeric: tabular-nums; cursor: pointer; }
.matrix label:hover { border-color: var(--border-2); background: var(--hover); }
.matrix input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.matrix input:checked + span { color: var(--text); font-weight: 600; }
.matrix label:has(input:checked) { border-color: var(--accent-line); background: var(--accent-soft); }
.matrix label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 1px; }
.matrix label.zero span { color: var(--faint); }
.matrix-all { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.matrix-all label { flex: 1; display: flex; align-items: center; justify-content: space-between; height: 30px; padding: 0 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg-2); color: var(--text-2); cursor: pointer; position: relative; }
.matrix-all label:has(input:checked) { border-color: var(--accent-line); background: var(--accent-soft); color: var(--text); font-weight: 600; }
.matrix-all label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 1px; }
.matrix-all input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }

/* ---------- lab -> model tree ---------- */

.tree { margin: 0; padding: 0; list-style: none; }
.tree ul { margin: 0 0 4px; padding: 0 0 0 26px; list-style: none; }
.tree-row { position: relative; display: flex; align-items: center; gap: 4px; min-height: 30px; padding: 0 2px; border-radius: 6px; }
.tree-row:hover { background: var(--hover); }
.tree-toggle { flex: none; width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center; padding: 0; border: 0; border-radius: 5px; background: none; color: var(--faint); }
.tree-toggle:hover { color: var(--text); background: var(--surface-2); }
.tree-toggle svg { width: 13px; height: 13px; transition: transform .15s; }
.tree-toggle[aria-expanded="true"] svg { transform: rotate(90deg); }
.tree-row .cb { flex: 1; padding: 5px 0; }
.tree-count { flex: none; min-width: 22px; color: var(--faint); font-size: 12px; text-align: right; font-variant-numeric: tabular-nums; }
.tree-only { position: absolute; right: 30px; height: 22px; padding: 0 7px; border: 1px solid var(--border-2); border-radius: 5px; background: var(--surface); color: var(--text-2); font-size: 11.5px; opacity: 0; pointer-events: none; }
.tree-row:hover .tree-only, .tree-only:focus-visible { opacity: 1; pointer-events: auto; }
.tree-only:hover { color: var(--text); border-color: var(--muted); }
.tree .zero .cb-label, .tree .zero .tree-count { color: var(--faint); }
.tree-more { margin: 6px 0 0 28px; }
.tree-empty { padding: 10px 4px; color: var(--muted); font-size: 13px; }
@media (hover: none) { .tree-only { position: static; opacity: 1; pointer-events: auto; } }

/* ---------- run detail (modal from the grid, inline row in the table) ---------- */
/* --media caps the embed's side; the rail gets the rest, never under 280px. */

.detail { display: grid; grid-template-columns: minmax(0, var(--media, 560px)) minmax(280px, 1fr); gap: 28px; align-items: start; }
.detail-media { min-width: 0; }
.detail .embed { border-radius: var(--r); border: 1px solid var(--border); }
.detail-side { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.detail-grade:empty, .detail-hist:empty { display: none; }
.detail h3 { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 8px; color: var(--text-2); font-size: 13px; font-weight: 600; }
.detail h3 span { color: var(--faint); font-size: 12px; font-weight: 400; font-variant-numeric: tabular-nums; }
/* 168px is the modal's margin, head and padding, so the square embed fits the viewport height. */
.modal-box.modal-detail { --media: min(760px, calc(100vh - 168px)); width: min(100%, calc(var(--media) + 440px)); }

.detail-head { display: grid; justify-items: start; gap: 10px; }
.detail-test { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; min-width: 0; color: var(--muted); font-size: 12.5px; }
.detail-test b { color: var(--text); font-size: 15px; font-weight: 600; }
.detail-test .badge { margin-left: 2px; }
.detail-example { color: var(--faint); }
.detail-example::before { content: "·"; margin-right: 8px; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 6px; }

.detail-grade { display: grid; gap: 10px; }
.detail-score { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.detail-score .score b { font-size: 30px; }
.detail-score .score small { font-size: 14px; }
.detail-note { font-size: 13px; }

.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; margin: 0; border: 1px solid var(--border); border-radius: var(--r); background: var(--border); overflow: hidden; }
.facts > div { min-width: 0; padding: 8px 12px 9px; background: var(--surface); }
.facts .wide { grid-column: 1 / -1; }
.facts dt { color: var(--faint); font-size: 11.5px; line-height: 1.3; }
.facts dd { margin: 2px 0 0; color: var(--text); font-size: 13px; line-height: 1.35; overflow-wrap: anywhere; }
.facts .id dd { font: 12.5px/1.35 var(--mono); }

.detail .matrix { grid-template-columns: 72px repeat(4, minmax(0, 1fr)); }
.detail .matrix label { height: 28px; }
.detail .matrix label span { display: flex; flex-direction: column; align-items: center; line-height: 1.1; }
.detail .matrix label.zero { border-style: dashed; border-color: var(--border); background: transparent; cursor: default; }
.detail .matrix label.zero input { cursor: default; }
.detail .matrix label.has span::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--faint); }
.detail .matrix label.has:hover span::before { background: var(--muted); }
.detail .matrix label.has:has(input:checked) span::before { background: var(--accent); }
.detail .matrix label.ref span { color: var(--warn); }
.detail .matrix label.fail span { color: var(--danger); }

.hist { margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--border); }
.hist li { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.hist .d { color: var(--faint); }

/* ---------- cards (A grid, B cards view) ---------- */

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.card { position: relative; display: flex; flex-direction: column; min-width: 0; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface); overflow: hidden; transition: border-color .15s; }
.card:hover, .card:focus-within { border-color: var(--border-2); }
.card .embed { border-bottom: 1px solid var(--border); }
.card-flags { position: absolute; top: 8px; left: 8px; right: 8px; z-index: 2; display: flex; justify-content: space-between; gap: 6px; pointer-events: none; }
.card-flags .badge { background: rgba(12, 14, 15, .78); border-color: rgba(255, 255, 255, .12); color: #c9d0d1; }
.card-flags .rank-badge { height: 22px; padding: 0 7px; border-radius: 5px; display: inline-flex; align-items: center; background: rgba(12, 14, 15, .78); color: #e7eaea; font: 600 12px/1 var(--sans); font-variant-numeric: tabular-nums; }
.card-flags .rank-badge.top { color: #5eead4; }
.card-body { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; padding: 12px 14px 14px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.card-head .score { flex: none; }
.card-name { display: block; width: 100%; min-width: 0; padding: 0; border: 0; background: none; color: var(--text); font-weight: 600; font-size: 14.5px; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-name::after { content: ""; position: absolute; inset: 0; z-index: 1; }
.card-name:focus-visible { outline: none; }
.card-name:focus-visible::after { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: var(--r); }
.card-lab { display: block; margin-top: 1px; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-titles { flex: 1 1 auto; min-width: 0; }
.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--faint); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.card-foot .cb { position: relative; z-index: 2; color: var(--text-2); font-size: 12px; }

/* ---------- per-test leaderboard table ---------- */

.lb-wrap { border: 1px solid var(--border); border-radius: var(--r-lg); overflow: clip; background: var(--surface); }
.lb { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 13px; font-variant-numeric: tabular-nums; }
.lb th, .lb td { padding: 9px 8px; border-bottom: 1px solid var(--border); text-align: center; }
.lb thead th { color: var(--muted); font-size: 12px; font-weight: 500; background: var(--bg-2); }
.lb thead tr:first-child th { padding-bottom: 2px; border-bottom: 0; }
.lb tbody tr:last-child td { border-bottom: 0; }
.lb tbody tr:hover td { background: var(--hover); }
.lb .c-model { text-align: left; }
.lb .c-model .card-name { position: static; font-size: 13.5px; }
.lb .c-model .card-name::after { display: none; }
.lb .c-model small { display: block; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb .col-cmp { width: 40px; }
.lb .col-rank { width: 44px; }
.lb .col-model { width: 230px; }
.lb .col-overall { width: 104px; }
.lb .col-n { width: 56px; }
.lb .t { color: var(--text-2); }
.lb .t.none { color: var(--faint); }
.lb .t.bad { color: var(--danger); }
.lb .t.ref { color: var(--warn); }
.lb .t.hi { color: var(--accent); font-weight: 600; }
.lb .overall { display: grid; gap: 4px; justify-items: stretch; }
.lb .cb { justify-content: center; }
.lb-legend { margin-top: 10px; color: var(--faint); font-size: 12px; }
.lb .col-t { width: auto; }
@media (max-width: 1180px) { .lb .col-t, .lb .t, .lb .th-sub { display: none; } }
@media (max-width: 640px) {
  .lb .col-cmp, .lb .c-cmp { display: none; }
  .lb .col-model { width: auto; }
  .lb .col-overall { width: 84px; }
  .lb .col-n { width: 48px; }
  .lb .col-rank { width: 34px; }
}

/* ---------- gallery tiles ---------- */

.gal { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.tile { position: relative; border-radius: var(--r); overflow: hidden; border: 1px solid var(--border); background: var(--surface); }
.tile .card-name { position: absolute; inset: 0; z-index: 2; width: 100%; opacity: 0; font-size: 0; }
.tile .card-name:focus-visible { opacity: 1; outline: 2px solid var(--accent); outline-offset: -2px; }
.tile-cap { position: absolute; left: 0; right: 0; bottom: 0; z-index: 1; display: grid; gap: 1px; padding: 18px 9px 7px; background: linear-gradient(transparent, rgba(8, 10, 11, .86)); color: #e7eaea; font-size: 12px; pointer-events: none; }
.tile-cap b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-cap > span { display: flex; justify-content: space-between; gap: 6px; color: #a9b2b4; font-size: 11px; font-variant-numeric: tabular-nums; }
.tile-cap > span em { flex: 1; min-width: 0; font-style: normal; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-cap > span > span { flex: none; }
@media (max-width: 640px) { .gal { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ---------- facet sidebar layout (Board, Gallery) ---------- */

.facet-layout { display: grid; grid-template-columns: 264px minmax(0, 1fr); gap: 32px; align-items: start; }
.facets {
  position: sticky; top: calc(var(--header-h) + 16px);
  max-height: calc(100vh - var(--header-h) - 32px);
  display: flex; flex-direction: column;
  border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--bg-2);
}
.facets-head { display: none; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 16px 12px; border-bottom: 1px solid var(--border); }
.facets-head h2 { margin-right: auto; font-size: 15px; font-weight: 600; }
.facets-body { padding: 14px 16px 16px; overflow-y: auto; overscroll-behavior: contain; }
.facet + .facet { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }
.facet h3, .pop-section h3, .pop-h { margin-bottom: 8px; color: var(--text-2); font-size: 13px; font-weight: 600; }
.facet .tree-search { margin-bottom: 8px; }
.facets-foot { display: none; }
.results { min-width: 0; }
.results-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; min-height: 34px; }
.results-bar .chips { flex: 1; min-width: 0; }
.results-bar .tools { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.filter-btn { display: none; }
.sort-label { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12.5px; }
.result-line:focus { outline: none; }
.pop-section + .pop-section { margin-top: 14px; }

@media (max-width: 900px) {
  .facet-layout { grid-template-columns: minmax(0, 1fr); }
  .filter-btn { display: inline-flex; }
  .results-bar .chips { order: 3; flex-basis: 100%; }
  .facets { display: none; }
  .facets.open {
    display: flex; position: fixed; z-index: 70; left: 0; right: 0; bottom: 0; top: auto;
    max-height: 88vh; border-radius: var(--r-lg) var(--r-lg) 0 0; border-bottom: 0; box-shadow: var(--shadow);
  }
  .facets.open .facets-head { display: flex; }
  .facets.open .facets-foot { display: flex; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); }
  .facets-foot .btn { flex: 1; height: 40px; }
}

/* ---------- ranked table (Board table view, Concept C) ---------- */

.rt-wrap { container: rt / inline-size; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); overflow: clip; }
.rt-wrap.is-empty { border: 0; background: none; }
.rtable { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 13px; font-variant-numeric: tabular-nums; }
.rtable th, .rtable td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: right; vertical-align: middle; }
.rtable tbody tr:last-child td { border-bottom: 0; }
.rtable thead th { position: sticky; top: var(--header-h); z-index: 3; padding-top: 10px; padding-bottom: 10px; background: var(--bg-2); color: var(--muted); font-size: 12px; font-weight: 500; white-space: nowrap; }
.rtable th button { display: inline-flex; align-items: center; gap: 4px; padding: 0; border: 0; background: none; color: inherit; font: inherit; }
.rtable th button:hover, .rtable th[aria-sort] button { color: var(--text); }
.rtable th button svg { width: 12px; height: 12px; opacity: 0; }
.rtable th[aria-sort] button svg { opacity: 1; }
.rtable .rt-left { text-align: left; }
.rtable .col-rank { width: 46px; }
.rtable .col-thumb { width: 60px; }
.rtable .col-overall { width: 140px; }
.rtable .col-axis { width: 62px; }
.rtable .col-n { width: 68px; }
.rtable .col-status { width: 160px; }
.rtable .col-date { width: 80px; }
.rtable .col-exp { width: 44px; }
.rt-row { cursor: pointer; }
.rt-row:hover td { background: var(--hover); }
.rt-row.open td { background: var(--surface-2); border-bottom-color: transparent; }
.rt-row td { height: 56px; }
.rt-thumb-box { position: relative; display: block; width: 40px; height: 40px; margin-left: auto; border-radius: 6px; overflow: hidden; background: var(--viewport); }
.rt-thumb-box img { width: 100%; height: 100%; object-fit: cover; }
.rt-thumb-box .glyph { position: absolute; inset: 0; display: grid; place-items: center; color: #7d888c; font-size: 10.5px; }
.rt-name { display: block; max-width: 100%; padding: 0; border: 0; background: none; color: var(--text); font-weight: 600; font-size: 13.5px; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rt-name:hover { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--border-2); }
.rt-sub { display: block; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rt-sub .st-inline { display: none; }
.rt-overall { display: grid; gap: 5px; }
.rt-overall .score { justify-self: end; }
.rt-status-wrap { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; }
.rt-toks { font-size: 12px; line-height: 1.45; }
.rt-toks .tok { white-space: nowrap; }
.rt-toks .tok-judged { color: var(--text-2); }
.rt-toks .tok-pending { color: var(--muted); }
.rt-toks .tok-refused { color: var(--warn); }
.rt-toks .tok-failed { color: var(--danger); }
.rt-toks .sep { color: var(--faint); }
.rt-exp-ico { display: inline-flex; width: 26px; height: 26px; align-items: center; justify-content: center; border-radius: 6px; color: var(--muted); }
.rt-exp-ico svg { width: 15px; height: 15px; transition: transform .15s; }
.rt-row.open .rt-exp-ico svg { transform: rotate(90deg); }
.rt-row:hover .rt-exp-ico { color: var(--text); background: var(--surface-2); }
.rt-detail-row > td { padding: 18px 20px 22px; background: var(--surface-2); text-align: left; }
.rt-detail-row .detail { --media: min(600px, calc(100vh - 200px)); }
.rt-dim { color: var(--faint); }
.hover-card { position: fixed; z-index: 65; width: 264px; padding: 8px; border-radius: var(--r-lg); background: var(--bg-2); box-shadow: var(--shadow); pointer-events: none; }
.hover-card .embed { border-radius: 8px; }
.hover-card p { display: flex; justify-content: space-between; gap: 8px; margin-top: 7px; padding: 0 2px; font-size: 12.5px; }
.hover-card p b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* .rt-lean: no score or axis columns, so status and date keep their room longer. */
@container rt (max-width: 999px) {
  .rtable:not(.rt-lean) .col-date, .rtable:not(.rt-lean) .rt-date { display: none; }
}
@container rt (max-width: 899px) {
  .rtable:not(.rt-lean) .col-status, .rtable:not(.rt-lean) .rt-status { display: none; }
  .rtable:not(.rt-lean) .rt-sub .st-inline { display: inline; }
}
@container rt (max-width: 639px) {
  .rt-lean .col-date, .rt-lean .rt-date { display: none; }
}
@container rt (max-width: 479px) {
  .rt-lean .col-status, .rt-lean .rt-status { display: none; }
  .rt-lean .rt-sub .st-inline { display: inline; }
}
@container rt (max-width: 759px) {
  .rtable .col-axis, .rtable .rt-axis { display: none; }
  .rt-detail-row .detail { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .rt-detail-row .detail .embed { max-width: 560px; margin-inline: auto; }
}
@container rt (max-width: 559px) {
  .rtable th, .rtable td { padding: 8px 6px; }
  .rtable .col-rank { width: 30px; }
  .rtable .col-thumb { width: 48px; }
  .rtable .col-overall { width: 84px; }
  .rtable .col-n, .rtable .rt-n { display: none; }
  .rtable .col-exp { width: 30px; }
  .rt-overall .bar { display: none; }
  .rt-detail-row > td { padding: 14px 12px 18px; }
}

/* ---------- responsive ---------- */

@media (max-width: 900px) {
  :root { --pad: 16px; }
  .x-links, .x-tools .hide-sm { display: none; }
  .x-tools .x-menu-btn { display: inline-flex; }
  .x-drawer.open { display: block; position: absolute; top: var(--header-h); left: 0; right: 0; padding: 8px var(--pad) 16px; border-bottom: 1px solid var(--border); background: var(--bg); box-shadow: 0 16px 24px rgba(0, 0, 0, .25); }
  .x-drawer .x-links { display: grid; }
  .x-drawer .x-links a { padding: 10px 8px; font-size: 15px; }
  .x-drawer .x-drawer-tools { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; padding-top: 12px; border-top: 1px solid var(--border); }
  .detail { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .detail .embed { max-width: max(320px, calc(100vh - 200px)); margin-inline: auto; }
}
@media (max-width: 640px) {
  .x-title { padding: 24px 0 14px; }
  .x-title .lead { font-size: 14px; }
  .modal { padding: 0; align-items: flex-end; }
  .modal-box { max-height: 92vh; border-radius: var(--r-lg) var(--r-lg) 0 0; }
  .modal-body { padding: 16px; }
  .modal-head h2 { font-size: 18px; }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .notice-box h2 { font-size: 27px; }
  .notice { padding-top: 8vh; }
  /* popovers become bottom sheets */
  .pop, .pop.align-right { position: fixed; left: 0; right: 0; top: auto; bottom: 0; width: auto; max-width: none; max-height: 82vh; border-radius: var(--r-lg) var(--r-lg) 0 0; }
  .pop-close { display: inline-flex; }
  .pop-body { padding: 12px 16px; }
  .opt, .tree-row { min-height: 40px; }
  .results-bar:has(.pop:not([hidden])) { z-index: 60; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
