/* ADF website: shared tokens and components, then one block per view.
   Layout: sticky case header, then the current view. */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef1f5;
  --line: #dde2ea;
  --fg: #18202c;
  --muted: #5b6676;
  --faint: #8a94a3;
  --accent: #1f5fa8;
  --accent-soft: #e3edf8;
  --accent-fg: #ffffff;
  --test: #c2581b;
  --base: #1f5fa8;
  --pos: #b23a2e;
  --neg: #2b62a3;
  --shadow: 0 1px 2px rgba(20, 30, 50, .06), 0 4px 14px rgba(20, 30, 50, .06);
  --font: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --r: 8px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f141b; --surface: #161d27; --surface-2: #1d2632; --line: #2a3442;
    --fg: #e4e9f0; --muted: #a0abba; --faint: #6f7b8c;
    --accent: #6ea8ec; --accent-soft: #1b2b40; --accent-fg: #0b1220;
    --test: #f08a4b; --base: #6ea8ec; --pos: #f08178; --neg: #7fb0ee;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 18px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f141b; --surface: #161d27; --surface-2: #1d2632; --line: #2a3442;
  --fg: #e4e9f0; --muted: #a0abba; --faint: #6f7b8c;
  --accent: #6ea8ec; --accent-soft: #1b2b40; --accent-fg: #0b1220;
  --test: #f08a4b; --base: #6ea8ec; --pos: #f08178; --neg: #7fb0ee;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 18px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--fg);
  font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
img { max-width: 100%; display: block; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.mono { font-family: var(--mono); }
.tnum { font-variant-numeric: tabular-nums; }

/* ---------- header ---------- */
.hdr {
  position: sticky; top: 0; z-index: 20;
  background: var(--surface); border-bottom: 1px solid var(--line);
  padding: 10px max(16px, env(safe-area-inset-right, 0px)) 10px max(16px, env(safe-area-inset-left, 0px));
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px;
}
.brand { display: flex; align-items: baseline; gap: 8px; text-decoration: none; color: var(--fg); }
.brand b { font-weight: 700; letter-spacing: .02em; font-size: 16px; }
.brand span { color: var(--muted); font-size: 13px; }
.cases { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; flex: 1 1 380px; }
.case {
  display: inline-flex; align-items: center; gap: 8px; min-width: 0; max-width: 100%;
  border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px 3px 4px;
  background: var(--surface-2); font-size: 12.5px;
}
.case .tag {
  font-size: 10.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  padding: 1px 7px; border-radius: 999px; color: var(--accent-fg);
}
.case.test .tag { background: var(--test); }
.case.base .tag { background: var(--base); }
.case .nm { font-family: var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.case .yr { color: var(--muted); white-space: nowrap; }
.hdr-right { display: flex; align-items: center; gap: 8px; margin-left: auto; flex-wrap: wrap; }
.nav { display: flex; gap: 2px; flex-wrap: wrap; }
.nav a {
  text-decoration: none; color: var(--muted); padding: 5px 9px; border-radius: 6px; font-size: 13px;
}
.nav a:hover { background: var(--surface-2); color: var(--fg); }
.nav a[aria-current="page"] { color: var(--fg); background: var(--accent-soft); font-weight: 600; }

select, input[type="search"], input[type="text"] {
  font: inherit; color: var(--fg); background: var(--surface);
  border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; max-width: 100%;
}
.btn {
  font: inherit; font-size: 13px; color: var(--fg); background: var(--surface);
  border: 1px solid var(--line); border-radius: 6px; padding: 5px 10px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { border-color: var(--faint); }
.btn.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.btn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--fg); }

/* ---------- tabs & chips ---------- */
.tabs { display: flex; gap: 2px; overflow-x: auto; border-bottom: 1px solid var(--line); scrollbar-width: thin; }
.tab {
  font: inherit; background: none; border: 0; border-bottom: 2px solid transparent;
  padding: 8px 12px; color: var(--muted); cursor: pointer; white-space: nowrap; font-size: 13.5px;
}
.tab:hover { color: var(--fg); }
.tab[aria-selected="true"] { color: var(--fg); border-bottom-color: var(--accent); font-weight: 600; }
.tab.dim { color: var(--faint); }
.tab .n { font-size: 11px; color: var(--faint); margin-left: 4px; font-weight: 400; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; background: var(--surface); flex-wrap: wrap; }
.seg button {
  font: inherit; font-size: 12.5px; font-family: var(--mono); letter-spacing: .02em;
  border: 0; background: none; color: var(--fg); padding: 5px 11px; cursor: pointer;
  border-right: 1px solid var(--line);
}
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-fg); }
.seg button:disabled { color: var(--faint); cursor: not-allowed; text-decoration: line-through; background: var(--surface-2); }

.label { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.kbd {
  font-family: var(--mono); font-size: 11px; border: 1px solid var(--line); border-bottom-width: 2px;
  border-radius: 4px; padding: 0 5px; color: var(--muted); background: var(--surface);
}
.hint { color: var(--muted); font-size: 12px; display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; }

/* ---------- thumbnails ---------- */
.thumb {
  display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: var(--fg);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 6px; cursor: pointer; text-align: left; font: inherit; min-width: 0;
}
.thumb:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.thumb .ph { background: #fff; border-radius: 4px; overflow: hidden; aspect-ratio: 16 / 10; display: grid; place-items: center; }
.thumb .ph img { width: 100%; height: 100%; object-fit: contain; }
.thumb .cap { display: flex; justify-content: space-between; gap: 6px; font-size: 12.5px; padding: 0 2px 2px; }
.thumb .cap b { font-family: var(--mono); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thumb .cap span { color: var(--muted); font-family: var(--mono); font-size: 11.5px; white-space: nowrap; }
.missing {
  border: 1px dashed var(--line); border-radius: var(--r); display: grid; place-items: center;
  color: var(--faint); font-size: 12px; background: transparent; aspect-ratio: 16 / 10;
}

/* plot images keep a white ground: matplotlib output is drawn on white */
.plot { background: #fff; border-radius: 6px; }

/* ---------- lightbox ---------- */
.lb {
  position: fixed; inset: 0; z-index: 50; background: rgba(8, 12, 18, .88);
  display: grid; grid-template-rows: auto 1fr auto;
  padding: max(10px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) max(10px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
  color: #e8edf3;
}
.lb-top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.lb-top .t { font-family: var(--mono); font-size: 14px; min-width: 0; overflow-wrap: anywhere; }
.lb-top .t small { color: #9fb0c3; margin-left: 8px; font-family: var(--font); }
.lb-top .sp { flex: 1; }
.lb button, .lb a.lbbtn {
  font: inherit; font-size: 13px; color: #e8edf3; background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .18); border-radius: 6px; padding: 5px 10px; cursor: pointer; text-decoration: none;
}
.lb button:hover, .lb a.lbbtn:hover { background: rgba(255, 255, 255, .16); }
.lb-stage { position: relative; display: grid; place-items: center; min-height: 0; padding: 10px 0; }
.lb-stage img { max-height: 100%; max-width: 100%; object-fit: contain; background: #fff; border-radius: 6px; }
.lb-prev, .lb-next { position: absolute; top: 50%; transform: translateY(-50%); font-size: 22px !important; padding: 10px 14px !important; }
.lb-prev { left: 0; } .lb-next { right: 0; }
.lb-strip { display: flex; gap: 6px; overflow-x: auto; padding-top: 6px; scrollbar-width: thin; }
.lb-strip img { height: 56px; width: auto; border-radius: 3px; opacity: .55; cursor: pointer; background: #fff; border: 2px solid transparent; }
.lb-strip img.on { opacity: 1; border-color: #6ea8ec; }

/* ---------- tables ---------- */
.tblwrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
table.data { border-collapse: collapse; width: 100%; font-size: 13px; }
table.data th, table.data td { padding: 6px 10px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
table.data th:first-child, table.data td:first-child, table.data th:nth-child(2), table.data td:nth-child(2) { text-align: left; }
table.data th { position: sticky; top: 0; background: var(--surface-2); font-weight: 600; cursor: pointer; user-select: none; }
table.data td { font-variant-numeric: tabular-nums; font-family: var(--mono); font-size: 12.5px; }
table.data tr:hover td { background: var(--accent-soft); }
table.data .pos { color: var(--pos); } table.data .neg { color: var(--neg); }

.mock-note {
  font-size: 12px; color: var(--muted); border: 1px dashed var(--line); border-radius: 6px;
  padding: 6px 10px; background: var(--surface);
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- header extras ---------- */
.brand span.ti { color: var(--fg); font-weight: 600; font-size: 14px; }
.links { position: relative; }
.links summary { list-style: none; cursor: pointer; }
.links summary::-webkit-details-marker { display: none; }
.links .menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; min-width: 190px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow);
  padding: 6px; display: flex; flex-direction: column;
}
.links .menu a { padding: 6px 10px; border-radius: 6px; text-decoration: none; color: var(--fg); font-size: 13px; }
.links .menu a:hover { background: var(--surface-2); }
.nav button {
  font: inherit; font-size: 13px; background: none; border: 0; cursor: pointer;
  color: var(--muted); padding: 5px 9px; border-radius: 6px;
}
.nav button:hover { background: var(--surface-2); color: var(--fg); }
.nav button[aria-current="page"] { color: var(--fg); background: var(--accent-soft); font-weight: 600; }
.wrap { padding: 12px max(16px, env(safe-area-inset-right, 0px)) 40px max(16px, env(safe-area-inset-left, 0px)); display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; }
.row .sp { flex: 1; }
.size { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.empty { padding: 40px 0; text-align: center; color: var(--muted); }

/* ---------- explorer ---------- */
.ex { display: grid; grid-template-columns: 270px minmax(0, 1fr); min-height: calc(100vh - var(--hdrh, 58px)); }
.ex-side {
  border-right: 1px solid var(--line); background: var(--surface);
  position: sticky; top: var(--hdrh, 58px); height: calc(100vh - var(--hdrh, 58px)); overflow: auto;
  padding: 12px 10px 24px max(12px, env(safe-area-inset-left, 0px));
  display: flex; flex-direction: column; gap: 10px;
}
.ex-side input { width: 100%; }
.grp summary {
  list-style: none; cursor: pointer; display: flex; justify-content: space-between; align-items: center;
  padding: 6px; border-radius: 6px; font-weight: 600; font-size: 13px;
}
.grp summary::-webkit-details-marker { display: none; }
.grp summary:hover { background: var(--surface-2); }
.grp summary .n { color: var(--faint); font-weight: 400; font-size: 12px; }
.grp summary::before { content: "▸"; color: var(--faint); margin-right: 6px; transition: transform .15s; display: inline-block; }
.grp[open] summary::before { transform: rotate(90deg); }
.grp summary .l { flex: 1; }
.vars { display: flex; flex-direction: column; padding: 2px 0 6px 18px; }
.vars button {
  font: inherit; font-family: var(--mono); font-size: 12.5px; text-align: left; background: none; border: 0;
  color: var(--fg); padding: 3px 8px; border-radius: 5px; cursor: pointer;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.vars button:hover { background: var(--surface-2); }
.vars button[aria-current="true"] { background: var(--accent); color: var(--accent-fg); }
.ex-main { min-width: 0; padding: 0 max(16px, env(safe-area-inset-right, 0px)) 32px 20px; display: flex; flex-direction: column; gap: 14px; }
.vt { display: flex; flex-direction: column; min-width: 0; }
.vt h1 { font-family: var(--mono); font-size: 22px; margin: 0; line-height: 1.2; overflow-wrap: anywhere; }
.vt .crumbs { color: var(--muted); font-size: 12.5px; }
.viewer { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 10px; box-shadow: var(--shadow); }
.viewer img { margin: 0 auto; max-height: calc(100vh - var(--hdrh, 58px) - 210px); width: auto; cursor: zoom-in; }
.strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.strip .thumb[aria-current="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.sidetoggle { display: none; }
@media (max-width: 820px) {
  .ex { grid-template-columns: 1fr; }
  .ex-side { position: static; height: auto; max-height: 50vh; border-right: 0; border-bottom: 1px solid var(--line); padding-inline: 16px; }
  .ex-side.collapsed { display: none; }
  .sidetoggle { display: inline-flex; }
  .ex-main { padding-left: max(16px, env(safe-area-inset-left, 0px)); }
  .viewer img { max-height: none; }
}

/* ---------- gallery ---------- */
.ga-controls {
  position: sticky; top: var(--hdrh, 58px); z-index: 10; background: var(--bg);
  display: flex; flex-direction: column; gap: 10px; padding-bottom: 10px; border-bottom: 1px solid var(--line);
}
.jump { display: flex; flex-wrap: wrap; gap: 6px; }
.jump a {
  font-size: 12px; text-decoration: none; color: var(--muted); border: 1px solid var(--line);
  border-radius: 999px; padding: 2px 10px; background: var(--surface);
}
.jump a:hover { color: var(--fg); border-color: var(--accent); }
.ga section h2 { margin: 18px 0 10px; font-size: 15px; display: flex; align-items: baseline; gap: 8px; scroll-margin-top: 220px; }
.ga section h2 .n { color: var(--faint); font-weight: 400; font-size: 12px; }
.ga-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--tw, 240px), 1fr)); gap: 12px; }

/* ---------- grid (matrix) ---------- */
.mx { overflow: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); max-height: calc(100vh - var(--hdrh, 58px) - 130px); }
.mx table { border-collapse: separate; border-spacing: 0; }
.mx th, .mx td { padding: 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.mx thead th { position: sticky; top: 0; z-index: 3; background: var(--surface-2); font-family: var(--mono); font-size: 12.5px; font-weight: 600; text-align: center; white-space: nowrap; }
.mx thead th:first-child { left: 0; z-index: 4; text-align: left; font-family: var(--font); }
.mx tbody th {
  position: sticky; left: 0; z-index: 2; background: var(--surface); text-align: left;
  font-family: var(--mono); font-size: 12.5px; font-weight: 600; white-space: nowrap; padding-right: 14px; border-right: 1px solid var(--line);
}
.mx tr.cat th { background: var(--accent-soft); font-family: var(--font); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 5px 8px; }
.mx tr.cat td { background: var(--accent-soft); }
.cell { width: var(--cw, 180px); }
.cell .thumb { padding: 3px; }
.cell .thumb .cap { display: none; }
.cell .missing { width: 100%; font-size: 11px; }
.mx tbody tr:not(.cat):hover th { color: var(--accent); }

/* ---------- compare ---------- */
.presets { display: flex; flex-wrap: wrap; gap: 6px; }
.panes { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pane { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 10px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.pane .sel { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.pane .sel select { flex: 1 1 120px; min-width: 0; }
.who { font-weight: 700; font-size: 12px; width: 22px; height: 22px; border-radius: 50%; display: inline-grid; place-items: center; color: var(--accent-fg); flex: none; }
.who.a { background: var(--test); } .who.b { background: var(--base); }
.pane .desc { font-family: var(--mono); font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.stage { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 10px; }
.stack { position: relative; margin: 0 auto; max-width: 1400px; touch-action: none; }
.stack img { width: 100%; }
.stack .top { position: absolute; inset: 0; }
.stack .bar { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--accent); pointer-events: none; }
.stack .tagA, .stack .tagB { position: absolute; top: 8px; }
.stack .tagA { left: 8px; } .stack .tagB { right: 8px; }
.swipe { width: 100%; max-width: 1400px; display: block; margin: 8px auto 0; }
@media (max-width: 760px) { .panes { grid-template-columns: 1fr; } }

/* ---------- run info ---------- */
.info { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 20px; max-width: 1000px; overflow-wrap: anywhere; }
.info p, .info a { color: var(--fg) !important; }
.info a { text-decoration: none; }
