* { box-sizing: border-box; }
:root {
  --bg: #fafafa;
  --fg: #222;
  --muted: #777;
  --accent: #2861a4;
  --good: #2a7a3b;
  --bad: #c2424a;
  --border: #e2e2e2;
  --card: #fff;
  --pill: #eef2f7;
  --pill-strong: #d6e4f5;
  --warn: #f4b41a;
}

html, body {
  margin: 0; padding: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px; line-height: 1.45;
  background: var(--bg); color: var(--fg);
}

header {
  padding: 1rem 1.5rem; border-bottom: 1px solid var(--border);
  background: var(--card);
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 1rem;
}
header h1 { margin: 0; font-size: 1.15rem; font-weight: 600; }
header .meta { margin: 0; color: var(--muted); }
header a { color: var(--accent); text-decoration: none; }
header a:hover { text-decoration: underline; }

aside.filters {
  position: fixed; top: 64px; left: 0; bottom: 0;
  width: 280px; padding: 1rem; overflow-y: auto;
  background: var(--card); border-right: 1px solid var(--border);
  font-size: 13px;
}
aside h2 { margin: 0 0 0.5rem; font-size: 0.9rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
aside fieldset { border: 1px solid var(--border); border-radius: 4px; margin: 0 0 0.75rem; padding: 0.5rem 0.6rem; }
aside legend { padding: 0 0.4rem; font-size: 0.78rem; color: var(--muted); }
aside label { display: block; padding: 0.15rem 0; cursor: pointer; }
aside select, aside input[type="text"], aside input[type="number"] {
  width: 100%; padding: 0.3rem; border: 1px solid var(--border);
  border-radius: 3px; font: inherit; background: var(--bg);
}
aside input[type="number"] { width: 5.5rem; display: inline-block; }

main {
  margin-left: 280px; padding: 1.25rem 1.5rem 4rem;
}
main .loader { color: var(--muted); padding: 2rem; text-align: center; }

.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 5px; padding: 1rem 1.25rem; margin: 0 0 1rem;
}
.card .title { font-size: 1.02rem; font-weight: 600; margin: 0 0 0.25rem; }
.card .byline { color: var(--muted); margin: 0 0 0.5rem; }
.card .abstract { font-size: 13px; color: #333; margin: 0.4rem 0 0.7rem; }
.card .abstract.collapsed { max-height: 4.5rem; overflow: hidden; position: relative; }
.card .abstract.collapsed::after {
  content: ""; position: absolute; bottom: 0; left: 0; right: 0; height: 1.4rem;
  background: linear-gradient(to bottom, transparent, var(--card));
}
.card .toggle { color: var(--accent); cursor: pointer; font-size: 12px; }
.card .badges { margin: 0.4rem 0; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.badge {
  background: var(--pill); color: #335; padding: 0.1rem 0.5rem; border-radius: 999px;
  font-size: 11px; font-weight: 500; white-space: nowrap;
}
.badge.training { background: var(--pill-strong); color: #234; }

.preds { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 0.6rem; }
@media (max-width: 720px) {
  .preds { grid-template-columns: 1fr; }
  main, footer { margin-left: 0; padding-top: 8rem; }
  aside.filters { position: static; width: 100%; height: auto; }
}

.preds h4 { margin: 0 0 0.4rem; font-size: 0.85rem; color: #333; font-weight: 600; }
.pred-pair { display: grid; grid-template-columns: 1fr 0.85fr; gap: 0.75rem; }
.pred-pair h5 { margin: 0 0 0.25rem; font-size: 0.7rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }
.preds .row { display: flex; align-items: center; gap: 0.4rem; padding: 0.12rem 0; font-size: 13px; }
.preds .name { flex: 1; color: #555; }
.preds .prob { font-variant-numeric: tabular-nums; color: #555; min-width: 3.4em; text-align: right; }
.preds .bar { width: 60px; height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.preds .bar > span { display: block; height: 100%; background: var(--accent); }

/* Status colors on the model's top-1 prediction */
.preds .row.top1.match .name,
.preds .row.top1.match .prob { color: var(--good); font-weight: 600; }
.preds .row.top1.match .bar > span { background: var(--good); }
.preds .row.top1.partial .name,
.preds .row.top1.partial .prob { color: #b07700; font-weight: 600; }
.preds .row.top1.partial .bar > span { background: var(--warn); }
.preds .row.top1.partial { background: #fff8e6; border-radius: 3px; }
.preds .row.top1.miss .name,
.preds .row.top1.miss .prob { color: var(--bad); font-weight: 600; }
.preds .row.top1.miss .bar > span { background: var(--bad); }
.preds .row.top1.miss { background: #fdeeee; border-radius: 3px; }

.preds .llm-side { font-size: 13px; padding-left: 0.5rem; border-left: 2px solid var(--pill-strong); }
.preds .llm-side .row { color: #555; }
.preds .llm-side .llm-row { padding: 0.12rem 0; }
.preds .llm-side .llm-top1 .name { color: #234; font-weight: 600; }
.preds .llm-side .conf-line { font-size: 11px; color: var(--muted); margin-top: 0.3rem; }

.author-card .author-meta {
  color: #444;
  font-size: 13px;
  margin: 0.45rem 0 0.65rem;
}
.author-card .author-meta div { margin-bottom: 0.2rem; }
.author-papers {
  margin: 0.85rem 0 0 1.15rem;
  padding: 0;
  color: #333;
  font-size: 13px;
}
.author-papers li { margin-bottom: 0.35rem; padding-left: 0.1rem; }
.author-papers .paper-title { display: block; }
.author-papers .paper-meta {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.legend-pill { display: inline-block; width: 0.7em; height: 0.7em; border-radius: 50%;
               vertical-align: -1px; margin: 0 1px 0 4px; }
.legend-pill.match { background: var(--good); }
.legend-pill.partial { background: var(--warn); }
.legend-pill.miss { background: var(--bad); }

#agreement-fs label.match::before,
#agreement-fs label.partial::before,
#agreement-fs label.miss::before {
  content: ""; display: inline-block; width: 0.6em; height: 0.6em; border-radius: 50%;
  margin-right: 5px; vertical-align: 0;
}
#agreement-fs label.match::before { background: var(--good); }
#agreement-fs label.partial::before { background: var(--warn); }
#agreement-fs label.miss::before { background: var(--bad); }

.show-more { display: block; margin: 1rem auto 0; padding: 0.5rem 1rem;
             background: var(--accent); color: #fff; border: 0; border-radius: 4px;
             cursor: pointer; font: inherit; }
.show-more:disabled { background: var(--muted); cursor: default; }

footer { margin-left: 280px; padding: 1rem 1.5rem; color: var(--muted); font-size: 12px; }
footer code { background: var(--pill); padding: 0 4px; border-radius: 2px; }

.empty { text-align: center; color: var(--muted); padding: 3rem 1rem; }

/* ==== Header nav (explorer page) ===== */
.header-titles { display: flex; flex-direction: column; gap: 0.15rem; }
.header-titles nav { display: flex; flex-wrap: wrap; gap: 0.4rem 1rem; font-size: 12px; }
.header-titles nav a { color: var(--muted); }
.header-titles nav a.active { color: var(--accent); font-weight: 600; }

/* ==== "Hard case" badge ===== */
.badge.active { background: #fde8d4; color: #8a4400; }

/* ==== Home page ==================================================== */
body.home {
  background: var(--bg);
  font-family: ui-sans-serif, system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  color: var(--fg);
}
.home-header {
  padding: 1.5rem 2rem;
  border-bottom: 1px solid var(--border);
  background: var(--card);
}
.home-header h1 {
  margin: 0 0 0.5rem; font-size: 1.4rem; font-weight: 600;
  max-width: 920px;
}
.home-header nav { display: flex; flex-wrap: wrap; gap: 0.6rem 1.25rem; font-size: 0.95rem; }
.home-header nav a { color: var(--muted); text-decoration: none; }
.home-header nav a:hover { text-decoration: underline; }
.home-header nav a.active { color: var(--accent); font-weight: 600; }

.home-main {
  max-width: 880px; margin: 0 auto; padding: 2rem 1.5rem 4rem;
  font-size: 15px; line-height: 1.6;
}
.home-main section { margin-bottom: 2.5rem; }
.home-main h2 { font-size: 1.2rem; font-weight: 600; margin: 0 0 0.75rem;
                border-bottom: 1px solid var(--border); padding-bottom: 0.3rem; }
.home-main h3 { font-size: 1rem; font-weight: 600; margin: 0 0 0.4rem; }
.home-main .section-subhead { margin-top: 1.5rem; }
.home-main p { margin: 0 0 0.9rem; }
.home-main ul { margin: 0 0 0.9rem 1.25rem; padding: 0; }
.home-main li { margin-bottom: 0.5rem; }
.home-main code { background: var(--pill); padding: 0 4px; border-radius: 2px;
                  font-size: 0.92em; }

.lede { font-size: 1.05rem; color: #2a2a2a; }

/* ==== Bar charts ===== */
.charts { display: grid; grid-template-columns: 1fr; gap: 1.5rem;
          margin-top: 1rem; }
@media (min-width: 800px) {
  .charts { grid-template-columns: 1fr 1fr; }
}
.chart-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 6px; padding: 1rem 1.25rem;
}
.chart-card h3 { margin-bottom: 0.1rem; }
.chart-sub { color: var(--muted); margin: 0 0 1rem; font-size: 0.9rem; }
.bars { display: flex; flex-direction: column; gap: 0.5rem; }
.bar-row { display: flex; align-items: center; gap: 0.6rem; }
.bar-label { width: 9.5em; font-size: 0.9rem; color: #444;
             text-align: right; flex-shrink: 0; }
.bar-row .bar { flex: 1; height: 14px;
                background: #f0f1f3; border-radius: 3px; overflow: hidden; }
.bar-row .bar .fill { display: block; height: 100%; }
.bar-row .bar .fill.baseline { background: #b9b9b9; }
.bar-row .bar .fill.ours { background: var(--accent); }
.bar-row .bar .fill.ours-strong { background: #234d80; }
.bar-val { width: 3em; text-align: right; font-variant-numeric: tabular-nums;
           font-size: 0.9rem; color: #333; flex-shrink: 0; }
.bucket-bars .bar-label { width: 10.8em; }
.bucket-bars .bar-val { width: 4.2em; }
.bar-count { color: var(--muted); font-size: 0.82em; white-space: nowrap; }
.chart-note { font-size: 0.85rem; color: var(--muted); margin: 0.9rem 0 0; }
.concentration-charts { grid-template-columns: 1fr; }
.chart-wide { overflow: hidden; }
.viz-frame {
  width: 100%;
  overflow-x: auto;
}
.viz-svg {
  width: 100%;
  min-width: 680px;
  height: auto;
  display: block;
}
@media (max-width: 640px) {
  .viz-svg { min-width: 0; }
}
.viz-axis,
.viz-grid {
  stroke: #d9dee4;
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}
.viz-axis { stroke: #89939e; }
.viz-axis-label {
  fill: var(--muted);
  font-size: 12px;
}
.viz-axis-title {
  fill: #444;
  font-size: 12px;
  font-weight: 600;
}
.viz-x-label {
  fill: #555;
  font-size: 11px;
  text-anchor: start;
}
.viz-bar {
  fill: var(--accent);
}
.viz-bar:hover {
  fill: #1d4a82;
}
.viz-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 3;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.viz-dot {
  fill: #fff;
  stroke: var(--accent);
  stroke-width: 2;
}
.compact-table {
  min-width: 0;
}
.concentration-table-card {
  margin-top: 1rem;
}

.cta {
  display: inline-block; background: var(--accent); color: #fff;
  padding: 0.6rem 1.2rem; border-radius: 4px; text-decoration: none;
  font-weight: 600;
  margin: 0.2rem;
}
.cta:hover { background: #1d4a82; }
.cta-secondary { background: #4a6572; }
.cta-secondary:hover { background: #344c57; }

.home-footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem 2rem; max-width: 880px; margin: 2rem auto 0;
  font-size: 0.85rem; color: var(--muted);
}
.home-footer code { background: var(--pill); padding: 0 4px; border-radius: 2px; }

/* ==== Department browser ========================================== */
.dept-summary {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}
.dept-summary h2 {
  margin: 0 0 0.25rem;
  font-size: 1.05rem;
}
.dept-summary p {
  margin: 0;
  color: #444;
}
.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(125px, 1fr));
  gap: 0.75rem;
  margin-top: 0.85rem;
}
.summary-grid div {
  background: #f7f8fa;
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0.55rem 0.65rem;
}
.summary-grid strong {
  display: block;
  font-size: 1.15rem;
  line-height: 1.2;
}
.summary-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}
.summary-grid-compact {
  grid-template-columns: repeat(4, minmax(150px, 1fr));
}
.summary-grid .summary-primary {
  background: #eef5fc;
  border-color: #cfe0f0;
}
.summary-grid .summary-primary strong {
  color: var(--accent);
  font-size: 1.3rem;
}
.active-filter {
  margin-top: 0.35rem;
  color: #333;
}
.filter-warning {
  display: block;
  color: #8a6500;
  font-weight: 600;
  margin-top: 0.2rem;
}
.summary-footnote {
  margin-top: 0.75rem;
  color: var(--muted);
  font-size: 12px;
}
.browser-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}
.source-note {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin: 0 0 1rem;
}
.source-note div {
  background: #f7f8fa;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.7rem 0.85rem;
}
.source-note strong,
.source-note span {
  display: block;
}
.source-note span {
  color: var(--muted);
  font-size: 12px;
  margin-top: 0.2rem;
}
.browser-panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem;
}
.browser-panel h3 {
  margin: 0 0 0.15rem;
  font-size: 1rem;
}
.panel-note {
  color: var(--muted);
  font-size: 12px;
  margin: 0 0 0.75rem;
}
.filter-note {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  margin: 0.45rem 0 0;
}
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 5px;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.browser-panel .data-table { min-width: 1220px; }
.browser-panel .roster-table { min-width: 1500px; }
.browser-panel .candidate-table { min-width: 1450px; }
.data-table th,
.data-table td {
  padding: 0.45rem 0.55rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}
.data-table th {
  background: #f4f6f8;
  color: #444;
  font-weight: 600;
  white-space: nowrap;
}
.data-table tr:last-child td { border-bottom: 0; }
.table-title {
  font-weight: 600;
  color: #2d2d2d;
}
.table-sub {
  color: var(--muted);
  font-size: 11px;
  margin-top: 0.08rem;
}
.dept-cell {
  max-width: 260px;
  white-space: normal;
}
.chip-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}
.prob-chip {
  display: inline-block;
  background: #f4f6f8;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.12rem 0.32rem;
  white-space: nowrap;
}
.prob-chip strong {
  color: #333;
  font-weight: 600;
}
.mini-list {
  margin: 0;
  padding-left: 1.1rem;
  min-width: 180px;
}
.mini-list li {
  margin-bottom: 0.25rem;
}
.work-list {
  min-width: 260px;
  max-width: 380px;
}
.work-list a {
  font-weight: 600;
}
.metric-stack {
  display: grid;
  grid-template-columns: repeat(2, minmax(70px, 1fr));
  gap: 0.25rem;
  min-width: 160px;
}
.metric-stack div {
  background: #f7f8fa;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.25rem 0.35rem;
}
.metric-stack strong,
.metric-stack span {
  display: block;
}
.metric-stack span {
  color: var(--muted);
  font-size: 10px;
}
.pub-details summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 600;
  white-space: nowrap;
}
.pub-details[open] summary {
  margin-bottom: 0.35rem;
}
.status-badge {
  display: inline-block;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.status-good { background: #e6f3e8; color: var(--good); }
.status-info { background: #e8f1fb; color: #245b8f; }
.status-warn { background: #fff4d6; color: #8a6500; }
.status-muted { background: var(--pill); color: #566; }

@media (max-width: 900px) {
  .summary-grid,
  .source-note { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 520px) {
  .summary-grid,
  .source-note { grid-template-columns: 1fr; }
  .data-table { font-size: 11px; }
}

/* ==== Duplicate explorer + overview =============================== */
.dup-card { padding: 0.75rem 1rem; }
.dup-card .title { font-size: 0.95rem; margin-bottom: 0.4rem; }
.tier-tag { font-size: 11px; background: var(--pill-strong); color: #234;
            padding: 1px 6px; border-radius: 3px; }

table.dup-mem { border-collapse: collapse; width: 100%; font-size: 12.5px; margin-top: 0.3rem; }
table.dup-mem th { text-align: left; color: var(--muted); font-weight: 600;
                   border-bottom: 1px solid var(--border); padding: 4px 6px; }
table.dup-mem td { padding: 4px 6px; vertical-align: top;
                   border-bottom: 1px dashed #f0f0f0; }
table.dup-mem tr.canon td { background: #f6fbf7; font-weight: 600; }
table.dup-mem code { font-size: 11px; }
table.dup-mem a { color: var(--accent); }

.dup-edges { margin-top: 0.5rem; font-size: 12px; }
.dup-edges summary { cursor: pointer; color: var(--muted); }

/* Tier examples on the overview page */
.tier-examples h4.tier-h { margin: 1.4rem 0 0.4rem; font-size: 0.95rem; }
.dup-cluster.small { background: var(--card); border: 1px solid var(--border);
                     border-radius: 5px; padding: 0.5rem 0.75rem;
                     margin-bottom: 0.6rem; }
.dup-cluster.small .dup-meta { font-size: 11.5px; color: var(--muted); margin-bottom: 0.2rem; }

/* Tier table on overview */
table.tier-table { border-collapse: collapse; width: 100%; font-size: 13px; margin: 0.5rem 0; }
table.tier-table th, table.tier-table td {
  border-bottom: 1px solid var(--border); padding: 6px 8px; text-align: left;
}
table.tier-table th { color: var(--muted); font-weight: 600; }
table.tier-table code { font-size: 12px; }

/* ==== Code-disclosure blocks on overview pages ===================== */
.home-main pre {
  background: #f5f7fa;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.75rem 0.9rem;
  margin: 0.5rem 0 1rem;
  overflow-x: auto;
  font-size: 12.5px;
  line-height: 1.45;
}
.home-main pre code {
  background: transparent;
  padding: 0;
  border-radius: 0;
  font-size: inherit;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.code-details {
  margin: 1rem 0 0;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--card);
  padding: 0.5rem 0.85rem;
}
.code-details > summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 600;
  list-style: revert;
  padding: 0.15rem 0;
}
.code-details[open] > summary {
  margin-bottom: 0.5rem;
  border-bottom: 1px dashed var(--border);
  padding-bottom: 0.4rem;
}
.code-details ol { margin: 0 0 0.6rem 1.25rem; }
