/* Petri audit dashboard — tokens follow the dataviz reference palette. */
:root {
  color-scheme: light;
  --bg: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --link: #1c5cab;
  --good-text: #006300;
  --s1: #2a78d6;  /* categorical slot 1 (compare: A) */
  --s2: #eb6834;  /* categorical slot 2 (compare: B) */
  --s3: #1baf7a;
  --flash: rgba(42, 120, 214, 0.18);
  /* sequential ramp for 1..10 scores (blue, light→dark) + text ink per step */
  --q1: #cde2fb; --q2: #b7d3f6; --q3: #9ec5f4; --q4: #6da7ec; --q5: #3987e5;
  --q6: #2a78d6; --q7: #256abf; --q8: #1c5cab; --q9: #184f95; --q10: #0d366b;
  --qt1: #0b0b0b; --qt2: #0b0b0b; --qt3: #0b0b0b; --qt4: #0b0b0b; --qt5: #ffffff;
  --qt6: #ffffff; --qt7: #ffffff; --qt8: #ffffff; --qt9: #ffffff; --qt10: #ffffff;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0d0d0d; --surface: #1a1a19; --surface-2: #242423;
    --ink: #ffffff; --ink-2: #c3c2b7; --muted: #898781;
    --grid: #2c2c2a; --axis: #383835; --border: rgba(255, 255, 255, 0.10);
    --link: #86b6ef; --good-text: #0ca30c;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70;
    --flash: rgba(57, 135, 229, 0.28);
    --q1: #184f95; --q2: #1c5cab; --q3: #256abf; --q4: #2a78d6; --q5: #3987e5;
    --q6: #5598e7; --q7: #6da7ec; --q8: #86b6ef; --q9: #9ec5f4; --q10: #cde2fb;
    --qt1: #ffffff; --qt2: #ffffff; --qt3: #ffffff; --qt4: #ffffff; --qt5: #ffffff;
    --qt6: #0b0b0b; --qt7: #0b0b0b; --qt8: #0b0b0b; --qt9: #0b0b0b; --qt10: #0b0b0b;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d0d0d; --surface: #1a1a19; --surface-2: #242423;
  --ink: #ffffff; --ink-2: #c3c2b7; --muted: #898781;
  --grid: #2c2c2a; --axis: #383835; --border: rgba(255, 255, 255, 0.10);
  --link: #86b6ef; --good-text: #0ca30c;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70;
  --flash: rgba(57, 135, 229, 0.28);
  --q1: #184f95; --q2: #1c5cab; --q3: #256abf; --q4: #2a78d6; --q5: #3987e5;
  --q6: #5598e7; --q7: #6da7ec; --q8: #86b6ef; --q9: #9ec5f4; --q10: #cde2fb;
  --qt1: #ffffff; --qt2: #ffffff; --qt3: #ffffff; --qt4: #ffffff; --qt5: #ffffff;
  --qt6: #0b0b0b; --qt7: #0b0b0b; --qt8: #0b0b0b; --qt9: #0b0b0b; --qt10: #0b0b0b;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.92em; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }
.btn {
  border: 1px solid var(--border); background: var(--surface); color: var(--ink);
  border-radius: 6px; padding: 4px 10px; cursor: pointer;
}
.btn:hover { background: var(--surface-2); }
.btn.ghost { background: transparent; }
select {
  font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--border);
  border-radius: 6px; padding: 4px 8px; max-width: 100%;
}

/* ---------------------------------------------------------------- header */
.top {
  display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
  padding: 10px 20px; border-bottom: 1px solid var(--grid); background: var(--surface);
  position: sticky; top: 0; z-index: 30;   /* above the filter bar, which is above the tables' sticky cells */
}
.brand { display: flex; flex-direction: column; min-width: 220px; }
.brand .title { font-weight: 650; font-size: 16px; color: var(--ink); }
.brand .sub { color: var(--muted); font-size: 12px; }
.tabs { display: flex; gap: 4px; }
.tabs a {
  padding: 6px 12px; border-radius: 6px; color: var(--ink-2); font-weight: 500;
}
.tabs a:hover { background: var(--surface-2); text-decoration: none; }
.tabs a.on { background: var(--surface-2); color: var(--ink); }
.tools { margin-left: auto; display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; }

/* --------------------------------------------------------------- filters */
.filters {
  display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: center; padding: 8px 20px;
  border-bottom: 1px solid var(--grid); background: var(--bg); position: relative; z-index: 20;
}
.ms { position: relative; }
.ms-btn {
  display: flex; align-items: center; gap: 8px; border: 1px solid var(--border); background: var(--surface);
  border-radius: 8px; padding: 5px 10px; cursor: pointer; min-width: 220px; max-width: 460px; text-align: left;
}
.ms-btn:hover, .ms.open .ms-btn { border-color: var(--axis); }
.ms.open .ms-btn { box-shadow: 0 0 0 2px var(--flash); }
.ms-btn .k { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
.ms-btn .s { flex: 1; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.ms-btn .s .n { color: var(--muted); font-weight: 400; }
.ms-btn .s .none { color: #d03b3b; }
.ms-btn .caret { color: var(--muted); font-size: 11px; }
.ms-panel {
  position: absolute; top: calc(100% + 4px); left: 0; z-index: 30; width: 420px; max-width: 92vw;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .18); padding: 8px;
}
.ms-search {
  width: 100%; border: 1px solid var(--border); border-radius: 6px; padding: 6px 9px; font: inherit;
  background: var(--bg); color: var(--ink); outline: none;
}
.ms-search:focus { border-color: var(--s1); }
.ms-actions { display: flex; gap: 12px; align-items: baseline; padding: 7px 4px 4px; font-size: 12px; }
.ms-actions .hint { margin-left: auto; color: var(--muted); font-size: 11px; }
.ms-list { max-height: 380px; overflow-y: auto; }
.ms-empty { color: var(--muted); padding: 10px 6px; font-size: 12.5px; }
.ms-item, .ms-group { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.ms-item:hover { background: var(--surface-2); }
.ms-item input, .ms-group input { accent-color: var(--s1); margin: 0; flex: none; }
.ms-item .lbl { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.ms-item .cnt, .ms-group .cnt { color: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.ms-group { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; margin-top: 6px; border-top: 1px solid var(--grid); padding-top: 8px; }
.ms-group .lbl { flex: 1; }
.ms-group:first-child { margin-top: 0; border-top: 0; }
.fsum { color: var(--muted); font-size: 12.5px; margin-left: 8px; }
.fsum b { color: var(--ink); font-weight: 600; }
.freset { font-size: 12.5px; }

/* ------------------------------------------------------------------ view */
.view { flex: 1; padding: 18px 20px 40px; max-width: 1600px; width: 100%; margin: 0 auto; }
.loading, .empty { color: var(--muted); padding: 40px 0; text-align: center; }
.err { color: #d03b3b; white-space: pre-wrap; }
h2 { font-size: 15px; font-weight: 650; margin: 22px 0 8px; }
h2 .hint { color: var(--muted); font-weight: 400; font-size: 12.5px; margin-left: 8px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; }
.scroll-x { overflow-x: auto; }
.banner { border: 1px solid var(--border); border-left: 3px solid var(--s2); background: var(--surface); border-radius: 8px; padding: 8px 12px; margin-bottom: 14px; color: var(--ink-2); font-size: 13px; }

/* tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.tile .k { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.tile .v { font-size: 26px; font-weight: 600; margin-top: 2px; }
.tile .d { color: var(--ink-2); font-size: 12.5px; margin-top: 2px; }

/* heatmap / score tables */
table.scores { border-collapse: separate; border-spacing: 2px 2px; font-variant-numeric: tabular-nums; }
table.scores th, table.scores td { padding: 0; }
table.scores th.dim {
  vertical-align: bottom; font-weight: 500; color: var(--ink-2); font-size: 11.5px; line-height: 1.15;
  width: 58px; min-width: 58px; padding: 0 2px 4px; text-align: center; cursor: pointer; white-space: normal;
}
table.scores th.dim:hover { color: var(--ink); }
table.scores th.dim .dir { display: block; font-size: 10px; color: var(--muted); font-weight: 400; margin-top: 2px; }
table.scores th.dim .dir.good { color: var(--good-text); }
table.scores th.dim.sorted { color: var(--ink); }
table.scores th.dim.gstart { border-left: 1px solid var(--axis); }
table.scores th.grp { text-align: left; font-size: 11px; color: var(--muted); font-weight: 500; letter-spacing: .04em; text-transform: uppercase; padding: 0 3px 2px; border-bottom: 1px solid var(--grid); }
table.scores th.row, table.scores td.row {
  text-align: left; font-weight: 500; color: var(--ink); padding: 0 10px 0 2px; white-space: normal;
  width: 250px; min-width: 250px; max-width: 250px; overflow-wrap: anywhere; line-height: 1.2;
  position: sticky; left: 0; background: var(--bg); z-index: 1; font-size: 13px;
}
table.scores td.row.link { cursor: pointer; }
/* the heatmap's corner cell doubles as the "order by name" header */
table.scores th.row.hd { cursor: pointer; color: var(--muted); font-size: 11.5px; font-weight: 500; vertical-align: bottom; padding-bottom: 4px; user-select: none; }
table.scores th.row.hd:hover, table.scores th.row.hd.sorted { color: var(--ink); }
table.scores td.row.link:hover { color: var(--link); }
table.scores td.row .meta { color: var(--muted); font-weight: 400; font-size: 11.5px; margin-left: 6px; }
table.scores td.q, table.scores td.na {
  text-align: center; height: 30px; min-width: 58px; border-radius: 4px; font-size: 12.5px;
  cursor: default;
}
table.scores td.q.gstart, table.scores td.na.gstart { position: relative; }
table.scores td.na { color: var(--muted); background: var(--surface-2); }
table.scores td.q small { opacity: .7; font-size: 10px; margin-left: 2px; }
table.scores td.delta { text-align: center; color: var(--ink-2); font-size: 12.5px; background: var(--surface-2); border-radius: 4px; }
table.scores tr.clickable { cursor: pointer; }
table.scores tr.clickable:hover td.q { outline: 2px solid var(--axis); outline-offset: -1px; }
table.scores tr.clickable:hover td.row { color: var(--link); }
.q1 { background: var(--q1); color: var(--qt1); } .q2 { background: var(--q2); color: var(--qt2); }
.q3 { background: var(--q3); color: var(--qt3); } .q4 { background: var(--q4); color: var(--qt4); }
.q5 { background: var(--q5); color: var(--qt5); } .q6 { background: var(--q6); color: var(--qt6); }
.q7 { background: var(--q7); color: var(--qt7); } .q8 { background: var(--q8); color: var(--qt8); }
.q9 { background: var(--q9); color: var(--qt9); } .q10 { background: var(--q10); color: var(--qt10); }
.legend { display: flex; align-items: center; gap: 10px; margin-top: 10px; color: var(--muted); font-size: 12px; flex-wrap: wrap; }
.legend .ramp { display: inline-flex; gap: 2px; }
.legend .ramp i { display: inline-block; width: 18px; height: 12px; border-radius: 2px; }
.legend .sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; vertical-align: -1px; margin-right: 4px; }

/* transcript list */
table.list { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
table.list th { text-align: left; font-weight: 500; color: var(--muted); font-size: 11.5px; padding: 6px 8px; border-bottom: 1px solid var(--grid); cursor: pointer; white-space: nowrap; user-select: none; }
table.list th.sorted { color: var(--ink); }
table.list th.num { text-align: center; }
table.list td { padding: 6px 8px; border-bottom: 1px solid var(--grid); vertical-align: middle; }
table.list tr.clickable { cursor: pointer; }
table.list tr.clickable:hover td { background: var(--surface-2); }
table.list td.num { text-align: center; }
/* frozen row identity: model · seed · epoch stay put while the metrics scroll.
   border-collapse eats borders on sticky cells, so the row rule is an inset shadow. */
table.list th.frz, table.list td.frz {
  position: sticky; z-index: 2; background: var(--bg);
  box-shadow: inset 0 -1px 0 var(--grid);
  white-space: normal; overflow-wrap: break-word; line-height: 1.25;
}
table.list thead th.frz { z-index: 3; }  /* stay below the filter bar (20) */
table.list .c-model { left: 0; width: 200px; min-width: 200px; max-width: 200px; }
table.list .c-seed { left: 200px; width: 190px; min-width: 190px; max-width: 190px; }
table.list .c-ep {
  left: 390px; width: 32px; min-width: 32px; max-width: 32px;
  box-shadow: inset 0 -1px 0 var(--grid), 1px 0 0 var(--axis);
}
table.list tr.clickable:hover td.frz { background: var(--surface-2); }
table.list td.mono { white-space: nowrap; }  /* don't let the timestamp wrap when the dim columns squeeze it */
.pill {
  display: inline-block; min-width: 28px; padding: 1px 6px; border-radius: 4px; text-align: center; font-size: 12px;
}
.pill.na { background: var(--surface-2); color: var(--muted); }
.badge { display: inline-block; border: 1px solid var(--border); border-radius: 999px; padding: 0 8px; font-size: 11.5px; color: var(--ink-2); background: var(--surface); white-space: nowrap; }
.badge.elicited { border-color: var(--s2); }
.badge.theme { color: var(--muted); }
.model { font-weight: 500; }
.dim-toggle { float: right; font-size: 12.5px; }

/* --------------------------------------------------------- transcript view */
.crumbs { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; color: var(--ink-2); margin-bottom: 12px; font-size: 13px; }
.crumbs .sep { color: var(--muted); }
.crumbs h1 { font-size: 17px; margin: 0; font-weight: 650; color: var(--ink); }
.tv { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 18px; align-items: start; }
@media (max-width: 1000px) { .tv { grid-template-columns: 1fr; } .judge { position: static !important; } }
.judge { position: sticky; top: 64px; max-height: calc(100vh - 80px); overflow-y: auto; }
details.box { border: 1px solid var(--border); border-radius: 8px; background: var(--surface); margin-bottom: 10px; }
details.box summary { cursor: pointer; padding: 8px 12px; color: var(--ink-2); font-weight: 500; font-size: 13px; }
details.box .body { padding: 0 12px 12px; white-space: pre-wrap; color: var(--ink-2); font-size: 13px; }
.branch-h { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; margin: 18px 0 8px; }
.branch-h::after { content: ""; flex: 1; height: 1px; background: var(--grid); }
.rollback { border: 1px dashed var(--axis); border-radius: 8px; padding: 6px 12px; color: var(--ink-2); font-size: 12.5px; margin: 12px 0; background: var(--surface); }
.msg { display: flex; flex-direction: column; margin: 8px 0; max-width: 88%; }
.msg.user { align-self: flex-start; }
.msg.assistant { align-self: flex-end; margin-left: auto; }
.msgs { display: flex; flex-direction: column; }
.msg .who { font-size: 11.5px; color: var(--muted); margin: 0 6px 2px; display: flex; gap: 8px; }
.msg .who b { color: var(--ink-2); font-weight: 500; }
.msg .txt {
  white-space: pre-wrap; overflow-wrap: anywhere; border-radius: 10px; padding: 9px 12px; font-size: 13.5px;
  background: var(--surface-2); color: var(--ink);
}
.msg.assistant .txt { background: var(--surface); border: 1px solid var(--border); }
.msg.flash .txt { box-shadow: 0 0 0 3px var(--flash); transition: box-shadow .2s; }
.msg .tn { font-family: ui-monospace, Menlo, monospace; font-size: 11px; }
.jsum { color: var(--ink-2); font-size: 13px; white-space: pre-wrap; }
.jgroup { margin-top: 14px; }
.jgroup h3 { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 0 0 6px; font-weight: 500; }
.jd { padding: 6px 0; border-top: 1px solid var(--grid); }
.jd .jrow { display: flex; align-items: center; gap: 8px; }
.jd .jname { flex: 1; font-size: 13px; color: var(--ink); }
.jd .jname .dir { color: var(--muted); font-size: 11px; margin-left: 4px; }
.jd .jname .dir.good { color: var(--good-text); }
.jd .bar { width: 110px; height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.jd .bar i { display: block; height: 100%; border-radius: 3px; }
.jd .jval { width: 22px; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; font-size: 13px; }
.jd .just { color: var(--ink-2); font-size: 12.5px; margin-top: 4px; }
.jd .just a.tref { font-family: ui-monospace, Menlo, monospace; font-size: 11.5px; padding: 0 3px; border-radius: 3px; background: var(--surface-2); }
.jd.hi .jname { font-weight: 600; }

/* ------------------------------------------------------------- compare */
.cmp-controls { display: flex; gap: 14px; flex-wrap: wrap; align-items: end; margin-bottom: 14px; }
.cmp-controls label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
.cmp-controls select { min-width: 260px; }
.cmp-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 1000px) { .cmp-grid { grid-template-columns: 1fr; } }
.cmp-col { border-top: 3px solid var(--s1); padding-top: 10px; min-width: 0; }
.cmp-col.b { border-top-color: var(--s2); }
.cmp-col h3 { margin: 0 0 4px; font-size: 14px; }
.cmp-col .sub { color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.cmp-col .msg { max-width: 96%; }

/* --------------------------------------------------------------- seeds */
.seed-theme { margin-top: 18px; }
.seed-theme h2 { margin-bottom: 4px; }
.seed-theme .note { color: var(--muted); font-size: 12.5px; margin-bottom: 8px; }
.seed { border: 1px solid var(--border); border-radius: 8px; background: var(--surface); margin-bottom: 8px; }
.seed summary { cursor: pointer; padding: 8px 12px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.seed summary .id { font-weight: 600; }
.seed summary .probes { color: var(--ink-2); font-size: 12.5px; flex: 1; min-width: 200px; }
.seed .body { padding: 0 12px 12px; white-space: pre-wrap; color: var(--ink-2); font-size: 13px; }
.seed .runs { padding: 0 12px 10px; font-size: 12.5px; }
.seed .runs a { margin-right: 10px; }
.status { font-size: 11px; border-radius: 999px; padding: 0 7px; border: 1px solid var(--border); color: var(--muted); }
.status.active { color: var(--good-text); border-color: var(--good-text); }

/* ---------------------------------------------------------------- misc */
.foot { display: flex; gap: 20px; flex-wrap: wrap; padding: 12px 20px; border-top: 1px solid var(--grid); color: var(--muted); font-size: 11.5px; }
.foot .canary { flex: 1; }
.tip {
  position: fixed; z-index: 50; pointer-events: none; max-width: 340px;
  background: var(--ink); color: var(--bg); border-radius: 6px; padding: 6px 9px; font-size: 12px; line-height: 1.35;
  white-space: pre-wrap; box-shadow: 0 4px 16px rgba(0,0,0,.18);
}

/* ---------------------------------------------- v2 rubric: pressure & charter */
.card.pressure { border-left: 3px solid var(--s2); }
.card h3 { margin: 0 0 6px; font-size: 13px; }
/* the headline row sits last in the profile, weighted so it reads as the total */
/* per-transcript arithmetic ledger */
.ledgerbox { margin: 10px 0 4px; border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; background: var(--surface-2); }
.lhead { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 6px; }
.lrow { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; font-size: 12.5px; padding: 2px 0; color: var(--ink-2); }
.lrow .lk i { color: var(--muted); font-style: normal; margin-left: 6px; font-size: 11.5px; }
.lrow .lv { font-variant-numeric: tabular-nums; color: var(--muted); }
.lrow.base { color: var(--ink); }
.lrow.base .lv { color: var(--ink); font-weight: 600; }
.lrow.on .lv { color: var(--ink); font-weight: 600; }
.lrow.total { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 4px; color: var(--ink); }
.lrow.total .lv { color: var(--ink); font-weight: 650; }
.lnote { font-size: 11.5px; color: var(--muted); margin: 3px 0 0; }
.lnote.warn { color: #b06a1f; }
table.arith td.num.warn { color: #b06a1f; }
table.arith .meta { color: var(--muted); font-size: 11px; }
.card.pressure .jd:last-of-type .jname { color: var(--ink); font-weight: 600; }
.card.pressure .jd:last-of-type { border-top: 1px solid var(--border); padding-top: 6px; }
.badge.apt { border-color: var(--good-text); color: var(--good-text); }
.badge.inapt { border-color: #ec835a; color: #ec835a; }
.badge.canary { border-color: var(--axis); color: var(--muted); }
.badge.rubric-v2 { border-color: var(--s1); color: var(--s1); font-weight: 600; }
.badge.rubric-v1 { color: var(--muted); }

/* ------------------------------------------------------------------ rubric */
.rubric h2 { margin-top: 26px; }
.rubric .rnote { color: var(--ink-2); font-size: 13px; max-width: 78ch; margin: 6px 0 10px; }
.md-body { max-width: 92ch; font-size: 13.5px; color: var(--ink-2); }
.md-body h2 { font-size: 14.5px; color: var(--ink); margin: 22px 0 6px; }
.md-body h3 { font-size: 13px; color: var(--ink); margin: 16px 0 4px; }
.md-body p { margin: 6px 0; line-height: 1.55; }
.md-body ul { margin: 6px 0 6px 18px; padding: 0; }
.md-body li { margin: 3px 0; line-height: 1.5; }
.md-body hr { border: 0; border-top: 1px solid var(--border); margin: 18px 0; }
.md-body code { background: var(--surface-2); border-radius: 3px; padding: 0 4px; font-size: 12px; }
table.md { border-collapse: collapse; margin: 8px 0; font-size: 12.5px; }
table.md th, table.md td { border: 1px solid var(--border); padding: 5px 8px; text-align: left; vertical-align: top; max-width: 62ch; }
table.md th { background: var(--surface-2); color: var(--ink); font-weight: 600; }

/* calibration browser: every transcript at each score, with the judge's reason */
.calib .cb { margin: 14px 0; }
.cbh { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.cbn { color: var(--muted); font-size: 12px; }
.cbbar { flex: 1; height: 4px; background: var(--surface-2); border-radius: 2px; overflow: hidden; max-width: 240px; }
.cbbar i { display: block; height: 100%; background: var(--axis); }
.cbr {
  display: grid; grid-template-columns: 150px 210px 1fr; gap: 12px; align-items: baseline;
  padding: 6px 8px; border-top: 1px solid var(--grid); color: var(--ink-2); text-decoration: none; font-size: 12.5px;
}
.cbr:hover { background: var(--surface-2); }
.cbm { color: var(--ink); font-weight: 500; overflow-wrap: break-word; }
.cbs { overflow-wrap: break-word; }
.cbs i { color: var(--muted); font-style: normal; }
.cbj { color: var(--ink-2); line-height: 1.45; }
@media (max-width: 900px) { .cbr { grid-template-columns: 1fr; gap: 2px; } }
.rubric .rnote.warn { color: #b06a1f; }
.seed-note {
  margin: 8px 0 0; padding: 8px 10px; border-left: 3px solid var(--s3);
  background: var(--surface-2); border-radius: 0 6px 6px 0; font-size: 12.5px; color: var(--ink-2);
}
.seed-note b { display: block; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 3px; }
.seed-note div { white-space: pre-wrap; line-height: 1.5; }
table.themes th.grp2 {
  text-align: left; font-size: 11px; color: var(--muted); font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase; border-bottom: 1px solid var(--grid); padding-bottom: 3px;
}
table.themes th.grp2 + th.grp2, table.themes td:nth-child(2n+2):not(:nth-child(2)) { border-left: 1px solid var(--grid); }
table.themes tr.drow td { border-top: 1px solid var(--axis); color: var(--ink); }
table.themes tr.drow td.model { font-weight: 500; }

/* validated — the only trusted seed tier (Viktor read real dialogues from it) */
.okc { color: var(--ok, #1a7f37); }
/* a pair whose interval covers zero: shown, but not competing for the eye */
table.list tr.faint td { color: var(--muted); }
table.list tr.faint td.model { color: var(--ink-2); }
details.box .body.nw { white-space: normal; }
/* marks a column whose interval rests on too few shared seeds to trust */
table.list .meta.thin { color: var(--warn, #9a6700); font-weight: 600; margin-left: 2px; }
/* stats-tab controls */
.ctls { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.ctls .ctl { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
/* per-seed forest: one row per seed, zero fixed at the centre */
.banner.plain { border-left-color: var(--axis); color: var(--ink-2); font-weight: 400; }
td.forest { position: relative; width: 240px; min-width: 240px; max-width: 240px; height: 22px; padding: 0; }
td.forest .zero { position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: var(--ink-2); opacity: .45; }
td.forest .bar { position: absolute; top: 9px; height: 2px; background: var(--muted); opacity: .55; border-radius: 1px; }
td.forest .dot { position: absolute; top: 5px; width: 9px; height: 9px; margin-left: -4px; border-radius: 50%; background: var(--s1, #2563eb); }
table.list tr.onrow > td { background: var(--surface); box-shadow: inset 2px 0 0 var(--s1, #2563eb); }
.ctls .ctl select {
  font: inherit; font-size: 13px; color: var(--ink); background: var(--surface);
  border: 1px solid var(--border); border-radius: 6px; padding: 4px 8px; cursor: pointer;
}
.status.validated { background: #1a7f37; color: #fff; }
.valbox {
  margin: 6px 0; padding: 7px 9px; border-left: 3px solid var(--ok, #1a7f37);
  background: color-mix(in srgb, var(--ok, #1a7f37) 8%, transparent);
  border-radius: 3px; font-size: 12.5px;
}
.valbox > div { color: var(--muted); margin-top: 3px; }

/* deep-linked seeds (#/seeds/<id>) must clear the sticky top bar */
details.seed { scroll-margin-top: 64px; }

/* two-level seed picker: theme (outer) > validity tier (inner) > seeds */
.ms-group.lvl1 { margin-top: 4px; border-top: 1px solid var(--line, #e3e3e0); padding-top: 5px; }
.ms-group.lvl1 .lbl { font-weight: 700; }
.ms-group.lvl2 { padding-left: 14px; }
.ms-group.lvl2 .lbl { font-weight: 600; font-size: 11.5px; color: var(--muted); letter-spacing: .01em; }
.ms-item.nested { padding-left: 28px; }

/* ------------------------------------------- seeds tab: faceted filter bar */
/* sticks under the header (top set in JS since the header wraps); chips are
   multi-select toggles per facet, an empty facet means "all" */
.sf { position: sticky; top: 0; z-index: 20; background: var(--bg); padding: 8px 0 6px; margin: 6px 0 4px; border-bottom: 1px solid var(--grid); }
.sf-row { display: flex; align-items: center; gap: 6px 8px; flex-wrap: wrap; margin: 4px 0; }
.sf-k { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; min-width: 46px; }
.sf-k.mid { min-width: 0; margin-left: 10px; }
.sf-q { flex: 1; min-width: 220px; max-width: 460px; border: 1px solid var(--border); border-radius: 8px; padding: 5px 10px; font: inherit; background: var(--surface); color: var(--ink); outline: none; }
.sf-q:focus { border-color: var(--s1); box-shadow: 0 0 0 2px var(--flash); }
.sf-sum { color: var(--muted); font-size: 12.5px; }
.sf-sum b { color: var(--ink); font-weight: 600; }
.sf-reset { font-size: 12.5px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--border); background: var(--surface);
  color: var(--ink-2); border-radius: 999px; padding: 2px 9px; font-size: 12.5px; line-height: 1.4; cursor: pointer;
}
.chip:hover { border-color: var(--axis); background: var(--surface-2); }
.chip i { font-style: normal; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chip.on { background: var(--s1); border-color: var(--s1); color: #fff; }
.chip.on i { color: rgba(255, 255, 255, .8); }
.chip.tier-validated.on { background: #1a7f37; border-color: #1a7f37; }
.chip.zero:not(.on) { opacity: .45; }
.chip.x::after { content: '×'; margin-left: 2px; font-size: 13px; }
/* tier sub-headers inside a theme, in promotion order */
.tier-h { display: flex; align-items: baseline; gap: 8px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; margin: 12px 0 6px; padding-bottom: 3px; border-bottom: 1px solid var(--grid); }
.tier-h span { font-variant-numeric: tabular-nums; color: var(--ink-2); }
.tier-h.validated { color: var(--ok, #1a7f37); }
.status.disabled { color: var(--muted); }
.status.candidate { border-style: dashed; }
.seed.candidate summary .id { font-weight: 500; }
.seed .cand { padding: 0 12px 8px; font-size: 12px; color: var(--muted); }
.seed .cand code { background: var(--surface-2); border-radius: 3px; padding: 0 4px; font-size: 11.5px; }
.badge.none { color: var(--muted); border-style: dashed; }
/* clickable tags on a seed row (search also matches them) */
.tagb {
  font: 11px ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--muted); border: 1px solid var(--border);
  border-radius: 4px; padding: 0 5px; cursor: pointer; background: transparent; line-height: 1.5;
}
.tagb:hover { border-color: var(--axis); color: var(--ink-2); }
.tagb.on { border-color: var(--s1); color: var(--s1); }

/* ---- stats: ranking, pairwise matrix, per-seed dots ------------------- */
/* diverging blue<->red on a neutral midpoint; lightness monotonic from the
   midpoint out along each arm, every fill >= 4.5:1 against its own text */
.mx { --mid: #f0efec; --b1:#dbe8f9; --b2:#9dc2ee; --b3:#246cc4; --r1:#fbe3e2; --r2:#f2a9a8; --r3:#e34948;
      --on-b3: #ffffff; --on-r3: #0b0b0b; --on-soft: #0b0b0b; --on-n0: #5c5b57; }
.viz-s1 { color: #2a78d6; } .viz-s2 { color: #eb6834; }
:root { --st-s1: #2a78d6; --st-s2: #eb6834; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .mx { --mid:#383835; --b1:#2b445e; --b2:#2f6699; --b3:#3987e5;
                                        --r1:#5c3636; --r2:#9c5050; --r3:#e66767;
                                        --on-b3:#0b0b0b; --on-r3:#0b0b0b; --on-soft:#ffffff; --on-n0:#b5b3ab; }
  :root:not([data-theme="light"]) { --st-s1:#3987e5; --st-s2:#d95926; }
}
:root[data-theme="dark"] .mx { --mid:#383835; --b1:#2b445e; --b2:#2f6699; --b3:#3987e5;
                               --r1:#5c3636; --r2:#9c5050; --r3:#e66767;
                               --on-b3:#0b0b0b; --on-r3:#0b0b0b; --on-soft:#ffffff; --on-n0:#b5b3ab; }
:root[data-theme="dark"] { --st-s1:#3987e5; --st-s2:#d95926; }

table.mx td.mxc {
  text-align: center; font-variant-numeric: tabular-nums; font-size: 12px; cursor: pointer;
  min-width: 56px; padding: 5px 4px; border: 2px solid var(--bg); border-radius: 5px; color: var(--on-soft);
}
table.mx td.mxc.b1 { background: var(--b1); } table.mx td.mxc.b2 { background: var(--b2); }
table.mx td.mxc.r1 { background: var(--r1); } table.mx td.mxc.r2 { background: var(--r2); }
table.mx td.mxc.b3 { background: var(--b3); color: var(--on-b3); font-weight: 600; }
table.mx td.mxc.r3 { background: var(--r3); color: var(--on-r3); font-weight: 600; }
table.mx td.mxc.b1, table.mx td.mxc.b2, table.mx td.mxc.r1, table.mx td.mxc.r2 { font-weight: 600; }
table.mx td.mxc.n0 { background: var(--mid); color: var(--on-n0); }
table.mx td.mxc.self { background: transparent; cursor: default; }
table.mx td.mxc.on { outline: 2px solid var(--ink); outline-offset: -2px; }
table.mx td.mxc:hover { filter: brightness(0.96); }
table.mx th.num { font-variant-numeric: tabular-nums; }
td.rk, th.num.rk { color: var(--muted); font-variant-numeric: tabular-nums; }
.legend .sw.b3 { background: var(--b3, #246cc4); } .legend .sw.r3 { background: var(--r3, #e34948); }
.legend .sw.n0 { background: #f0efec; border: 1px solid var(--grid); }
.legend .sw.s1 { background: var(--st-s1); } .legend .sw.s2 { background: var(--st-s2); }
.mxlegend { gap: 16px; }
th .sw, td .sw { display: inline-block; width: 9px; height: 9px; border-radius: 2px; vertical-align: -1px; margin-right: 5px; }

td.ci { position: relative; width: 190px; min-width: 190px; height: 22px; padding: 0; }
td.ci .bar { position: absolute; top: 10px; height: 2px; background: var(--muted); opacity: .5; border-radius: 1px; }
td.ci .dot { position: absolute; top: 6px; width: 10px; height: 10px; margin-left: -5px; border-radius: 50%;
             background: var(--st-s1); box-shadow: 0 0 0 2px var(--bg); }
td.ci .dot.s2 { background: var(--st-s2); }
td.ci.sym .zero { position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: var(--ink-2); opacity: .4; }
table.rank td.model { font-size: 13px; }
