/* SciTra run archive — quiet neutral theme with light and dark modes.
   Light is the default; dark follows the OS unless the viewer picks a theme (data-theme on <html>). */
:root {
  color-scheme: light;
  --width: 2200px;
  --bg: #f6f6f4;
  --surface: #ffffff;
  --surface-2: #f1f1ee;
  --border: #e3e2de;
  --border-strong: #cfcdc7;
  --text: #1d1f22;
  --text-2: #4a4f57;
  --muted: #6b7079;
  --accent: #3c6a96;
  --accent-text: #ffffff;
  --accent-soft: #e9f0f7;
  --accent-line: #c9d8e8;
  --code-bg: #f6f6f3;
  --row-hover: #f8f8f6;
  --user-bubble: #eaf0f6;
  /* Status steps are fixed and always paired with a text label. */
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --good-soft: rgba(12, 163, 12, 0.09);
  --warning-soft: rgba(250, 178, 25, 0.13);
  --critical-soft: rgba(208, 59, 59, 0.09);
  --radius: 10px;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --bg: #141517;
    --surface: #1b1c1f;
    --surface-2: #222326;
    --border: #2d2f33;
    --border-strong: #3e4146;
    --text: #e7e6e3;
    --text-2: #bab9b4;
    --muted: #91959c;
    --accent: #8db0d4;
    --accent-text: #141517;
    --accent-soft: rgba(141, 176, 212, 0.12);
    --accent-line: rgba(141, 176, 212, 0.32);
    --code-bg: #17181a;
    --row-hover: #202124;
    --user-bubble: #23303d;
    --good-soft: rgba(12, 163, 12, 0.16);
    --warning-soft: rgba(250, 178, 25, 0.14);
    --critical-soft: rgba(208, 59, 59, 0.18);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #141517;
  --surface: #1b1c1f;
  --surface-2: #222326;
  --border: #2d2f33;
  --border-strong: #3e4146;
  --text: #e7e6e3;
  --text-2: #bab9b4;
  --muted: #91959c;
  --accent: #8db0d4;
  --accent-text: #141517;
  --accent-soft: rgba(141, 176, 212, 0.12);
  --accent-line: rgba(141, 176, 212, 0.32);
  --code-bg: #17181a;
  --row-hover: #202124;
  --user-bubble: #23303d;
  --good-soft: rgba(12, 163, 12, 0.16);
  --warning-soft: rgba(250, 178, 25, 0.14);
  --critical-soft: rgba(208, 59, 59, 0.18);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; color: var(--text); background: var(--bg); font: 14px/1.55 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-underline-offset: 2px; }
code { font-family: var(--mono); font-size: 0.92em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
h1 { margin: 0; font-size: 1.75rem; font-weight: 600; line-height: 1.2; letter-spacing: -0.015em; }
h1:focus, .page:focus { outline: none; }
.muted { color: var(--muted); }
.note { margin: 0; font-size: 0.8125rem; color: var(--muted); }

/* Header */
.demo-banner { display: flex; gap: 0.75rem; align-items: center; padding: 0.5rem 1.5rem; border-bottom: 1px solid var(--border); background: var(--warning-soft); font-size: 0.8125rem; }
#demo-banner[hidden] { display: none; }
.demo-banner p { margin: 0; }
.demo-tag { padding: 0.15rem 0.45rem; border: 1px solid var(--border-strong); border-radius: 4px; font-size: 0.75rem; font-weight: 600; }
.masthead {
  position: sticky; top: 0; z-index: 10; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0.5rem 1rem;
  padding: 0.75rem max(clamp(1.5rem, 3vw, 3rem), calc((100% - var(--width)) / 2 + 3rem)); border-bottom: 1px solid var(--border); background: var(--surface);
}
.brand { display: flex; align-items: center; gap: 0.75rem; }
.brand-logo { display: block; flex: none; border-radius: 50%; }
.brand-logo img { display: block; width: 34px; height: 34px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 1px var(--border); }
.brand-logo:hover img { box-shadow: 0 0 0 2px var(--accent-line); }
.brand-sub { padding-left: 0.75rem; border-left: 1px solid var(--border); color: var(--text); font-size: 0.9375rem; font-weight: 600; text-decoration: none; }
.brand-sub:hover { color: var(--accent); }
.masthead-end { display: flex; align-items: center; gap: 0.75rem; }
.viewer { display: flex; align-items: center; gap: 0.6rem; font-size: 0.8125rem; color: var(--muted); }
.viewer code { color: var(--text); }
.theme-toggle { display: inline-flex; padding: 2px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); }
.theme-toggle button { padding: 0.25rem 0.55rem; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font: 500 0.75rem var(--sans); cursor: pointer; }
.theme-toggle button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 0 0 1px var(--border); }

.page { max-width: var(--width); margin: 0 auto; padding: 2rem clamp(1.5rem, 3vw, 3rem) 3rem; }
.colophon { max-width: var(--width); margin: 0 auto; padding: 1.25rem clamp(1.5rem, 3vw, 3rem) 2rem; border-top: 1px solid var(--border); color: var(--muted); font-size: 0.75rem; }

/* Labels: sentence case, small, muted */
.eyebrow, .field label, .scope legend, .facts dt, .status-card h3, .score-label, .tool-label, .provenance dt, .tile dt {
  font-size: 0.75rem; font-weight: 500; color: var(--muted); letter-spacing: 0;
}
.eyebrow { margin: 0 0 0.35rem; }
.page-head { margin-bottom: 1.25rem; }
.list-summary { margin: 0.35rem 0 0; color: var(--muted); font-size: 0.875rem; }
.lede { max-width: 70ch; margin: 0.5rem 0 0; color: var(--text-2); }

/* Controls */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-bottom: 1rem; }
.toolbar-search { flex: 1 1 22rem; max-width: 36rem; }
.toolbar-select select { width: auto; min-width: 9.5rem; max-width: 16rem; }
.toolbar .button--quiet { border-color: transparent; color: var(--text-2); }
.toolbar .button--quiet:hover:not(:disabled) { border-color: var(--border); }
.toolbar .button[hidden] { display: none; }
.field { display: flex; flex-direction: column; gap: 0.3rem; min-width: 0; }
input[type="search"], select {
  width: 100%; min-height: 2.25rem; padding: 0.4rem 0.6rem; border: 1px solid var(--border-strong); border-radius: 8px;
  background-color: var(--surface); color: var(--text); font: inherit; font-size: 0.875rem;
}
input[type="search"]::placeholder { color: var(--muted); }
input[type="search"]:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
select {
  appearance: none; padding-right: 2rem; background-repeat: no-repeat; background-size: 5px 5px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) 52%, calc(100% - 10px) 52%;
}
.scope { min-width: max-content; margin: 0; padding: 0; border: 0; }
.scope legend { padding: 0; margin-bottom: 0.3rem; }
.scope-options { display: flex; padding: 2px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface-2); }
.scope-option { position: relative; }
.scope-option input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.scope-option span { display: block; padding: 0.35rem 0.8rem; border-radius: 6px; color: var(--text-2); font-size: 0.8125rem; line-height: 1.3rem; white-space: nowrap; }
.scope-option input:checked + span { background: var(--surface); color: var(--text); font-weight: 550; box-shadow: 0 0 0 1px var(--border-strong); }
.scope-option input:focus-visible + span { outline: 2px solid var(--accent); }
.button {
  display: inline-flex; align-items: center; justify-content: center; min-height: 2.25rem; padding: 0.45rem 0.85rem;
  border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); color: var(--text);
  font: 500 0.8125rem/1.2 var(--sans); text-decoration: none; cursor: pointer;
}
.button:hover:not(:disabled) { background: var(--surface-2); }
.button:disabled { color: var(--muted); background: transparent; border-color: var(--border); cursor: not-allowed; }
.button--quiet { background: transparent; }
.button--primary, .archive-status > .button:first-child { border-color: var(--accent); background: var(--accent); color: var(--accent-text); }
.button--primary:hover:not(:disabled), .archive-status > .button:first-child:hover { background: var(--accent); filter: brightness(1.08); }
.link-button { padding: 0; border: 0; background: none; color: var(--accent); font: 500 0.8125rem var(--sans); cursor: pointer; }
.link-button:hover { text-decoration: underline; }

.table-bar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 0.5rem 1rem; margin-bottom: 0.5rem; }
.result-status { margin: 0; color: var(--muted); font-size: 0.8125rem; }
.cache-controls { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.35rem 1rem; color: var(--muted); font-size: 0.8125rem; }

/* Run table */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.run-table { width: 100%; border-collapse: collapse; font-size: 0.84375rem; }
.run-table thead th { padding: 0.6rem 0.85rem; border-bottom: 1px solid var(--border); background: var(--surface-2); color: var(--muted); font-size: 0.75rem; font-weight: 500; text-align: left; white-space: nowrap; }
.run-table td, .run-table tbody th { padding: 0.7rem 0.85rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; font-weight: 400; }
.run-table tbody tr { cursor: pointer; }
.run-table tbody tr:hover { background: var(--row-hover); }
.run-table tbody tr:last-child > * { border-bottom: 0; }
.run-table time { display: block; white-space: nowrap; color: var(--text); }
.cell-sub { display: block; color: var(--muted); font-size: 0.75rem; white-space: nowrap; }
.agent-cell { display: inline-flex; align-items: flex-start; gap: 0.5rem; }
.agent-cell .agent-logo { margin-top: 2px; }
.agent-label { display: block; }
.result { display: inline-flex; align-items: center; gap: 0.5rem; }
.result-score { font-family: var(--mono); font-size: 0.8125rem; font-variant-numeric: tabular-nums; color: var(--text-2); }
.run-table th:nth-child(1) { width: 34%; }
.cell-run { min-width: 14rem; }
.run-link { display: block; color: var(--text); font-weight: 550; text-decoration: none; }
.run-link:hover { color: var(--accent); text-decoration: underline; }
.run-id { display: block; margin-top: 0.1rem; color: var(--muted); font-size: 0.75rem; overflow-wrap: anywhere; }
.tag { display: inline-block; margin-top: 0.3rem; padding: 0.05rem 0.4rem; border: 1px solid var(--border-strong); border-radius: 4px; color: var(--text-2); font-size: 0.6875rem; }
.tag--you { margin: 0 0 0 0.35rem; border-color: var(--accent-line); color: var(--accent); background: var(--accent-soft); }
.contributor { display: inline-flex; align-items: center; gap: 0.45rem; }
.avatar { flex: none; width: 1.375rem; height: 1.375rem; border-radius: 50%; background: var(--surface-2); box-shadow: 0 0 0 1px var(--border); }
.contributor-link { color: var(--text); text-decoration: none; }
.contributor-link:hover { color: var(--accent); text-decoration: underline; }
.agent { display: block; }
.model { color: var(--muted); font-size: 0.75rem; overflow-wrap: anywhere; }
time { font-variant-numeric: tabular-nums; }
.score { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.score.is-na { color: var(--muted); }

/* Status chips: colored mark plus text label */
.chip { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.15rem 0.55rem; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-2); color: var(--text-2); font-size: 0.75rem; font-weight: 500; white-space: nowrap; }
.chip-mark { flex: none; width: 0.45rem; height: 0.45rem; border-radius: 50%; background: var(--border-strong); }
.chip--outcome.is-passed { border-color: transparent; background: var(--good-soft); color: var(--text); }
.chip--outcome.is-passed .chip-mark { background: var(--good); }
.chip--outcome.is-failed { border-color: transparent; background: var(--critical-soft); color: var(--text); }
.chip--outcome.is-failed .chip-mark { background: var(--critical); }
.chip--outcome.is-error { border-color: transparent; background: var(--warning-soft); color: var(--text); }
.chip--outcome.is-error .chip-mark { background: var(--warning); border-radius: 1px; transform: rotate(45deg); }
.chip--index { background: transparent; }
.chip--index .chip-mark { border-radius: 2px; }
.chip--index.is-indexed .chip-mark { background: var(--accent); }
.chip--index.is-pending { border-style: dashed; color: var(--muted); }
.chip--index.is-pending .chip-mark { background: transparent; border: 1px solid currentColor; }
.chip--index.is-failed .chip-mark { background: var(--critical); }

.pager { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding-top: 1rem; }
.pager-status { color: var(--muted); font-size: 0.8125rem; }

/* States */
.empty, .state { margin-top: 1rem; padding: 2rem 1.5rem; border: 1px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface); text-align: center; }
.state-title { margin: 0 0 0.35rem; font-size: 1rem; font-weight: 600; color: var(--text); }
.empty p, .state p { max-width: 60ch; margin: 0 auto 0.75rem; color: var(--text-2); }
.state .code { max-width: 60ch; margin: 0 auto; text-align: left; white-space: pre-wrap; }
.state--warn { border-color: var(--warning); }
.state--fail { border-color: var(--critical); }
.callout { margin: 1rem 0 0; padding: 0.75rem 1rem; border: 1px solid var(--border); border-left: 3px solid var(--warning); border-radius: 8px; background: var(--warning-soft); }
.callout p { margin: 0 0 0.2rem; font-size: 0.875rem; }
.callout-title { font-weight: 600; }
.code {
  max-width: 100%; margin: 0.5rem 0 0; padding: 0.7rem 0.85rem; overflow-x: auto; border: 1px solid var(--border); border-radius: 8px;
  background: var(--code-bg); color: var(--text); font: 0.8125rem/1.55 var(--mono); white-space: pre; tab-size: 2;
}
.placeholder { padding: 2rem 1rem; border: 1px dashed var(--border-strong); border-radius: var(--radius); text-align: center; }
.placeholder p { margin: 0; color: var(--text-2); }

/* Run detail */
.back-link { display: inline-block; margin-bottom: 1rem; color: var(--muted); font-size: 0.8125rem; text-decoration: none; }
.back-link:hover { color: var(--accent); }
.run-head { display: grid; gap: 0.5rem; margin-bottom: 1rem; }
.run-head .eyebrow { margin: 0; }
.run-id--large { color: var(--muted); font-size: 0.8125rem; overflow-wrap: anywhere; }
.status-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.75rem; }
.score-readout { display: inline-flex; align-items: baseline; gap: 0.4rem; padding-left: 0.75rem; border-left: 1px solid var(--border); }
.facts { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); margin: 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.facts > div { min-width: 0; padding: 0.75rem 1rem; }
.facts > div + div { border-left: 1px solid var(--border); }
.facts dd { margin: 0.25rem 0 0; font-size: 0.875rem; overflow-wrap: anywhere; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem; margin: 1rem 0; }
.archive-status { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem; margin: 0 0 1.25rem; }
.archive-status progress { flex: 1 1 16rem; height: 0.375rem; accent-color: var(--accent); }
.archive-status .state { flex-basis: 100%; }

.tabs { display: flex; gap: 0.25rem; overflow-x: auto; border-bottom: 1px solid var(--border); }
.tabs [role="tab"] {
  margin-bottom: -1px; padding: 0.6rem 0.9rem; border: 0; border-bottom: 2px solid transparent; background: none;
  color: var(--muted); font: 500 0.875rem var(--sans); white-space: nowrap; cursor: pointer;
}
.tabs [role="tab"]:hover { color: var(--text); }
.tabs [role="tab"][aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.tabs [role="tab"]:focus-visible { outline-offset: -2px; }
.panel { padding-top: 1.25rem; }
.panel h2 { display: flex; align-items: baseline; gap: 0.6rem; margin: 1.75rem 0 0.6rem; font-size: 1rem; font-weight: 600; }
.count { color: var(--muted); font-size: 0.8125rem; font-weight: 400; }
.summary { max-width: 72ch; margin: 0 0 1.25rem; color: var(--text-2); }
.status-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.status-card { padding: 0.9rem 1rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.status-card h3 { margin: 0 0 0.5rem; }
.status-card p { margin: 0.6rem 0 0; color: var(--text-2); font-size: 0.875rem; }
.provenance { display: grid; grid-template-columns: 12rem minmax(0, 1fr); margin: 0; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.provenance dt, .provenance dd { margin: 0; padding: 0.55rem 1rem; border-bottom: 1px solid var(--border); }
.provenance dt:last-of-type, .provenance dd:last-of-type { border-bottom: 0; }
.provenance dd { font-size: 0.875rem; overflow-wrap: anywhere; }
.link-list { display: flex; flex-direction: column; gap: 0.2rem; }

/* Evaluation */
.score-panel { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.25rem 1rem; padding: 1rem 1.1rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.score-panel p { margin: 0; }
.score-panel-value { font-size: 2.25rem; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.score-panel-value.is-na { font-size: 1.25rem; color: var(--muted); }
.checks ul { margin: 0; padding: 0; list-style: none; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.check { display: grid; grid-template-columns: 1.75rem minmax(0, 1fr); gap: 0.5rem; padding: 0.65rem 1rem; border-bottom: 1px solid var(--border); }
.check:last-child { border-bottom: 0; }
.check-mark { display: grid; place-items: center; width: 1.25rem; height: 1.25rem; border-radius: 50%; font-size: 0.7rem; font-weight: 700; }
.check.is-pass .check-mark { color: var(--good); background: var(--good-soft); }
.check.is-fail .check-mark { color: var(--critical); background: var(--critical-soft); }
.check-label { margin: 0; font-weight: 500; }
.check-name { color: var(--muted); font-size: 0.75rem; }
.check-message { margin: 0.2rem 0 0; color: var(--text-2); font-size: 0.875rem; }

/* Files */
.file-controls { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.75rem 1rem; margin-bottom: 1rem; }
.file-controls .field--search { flex: 1 1 16rem; }
.files { display: grid; grid-template-columns: minmax(14rem, 19rem) minmax(0, 1fr); align-items: start; gap: 1rem; }
.file-list ul { margin: 0; padding: 0; list-style: none; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.file-button {
  display: flex; flex-direction: column; gap: 0.15rem; width: 100%; padding: 0.55rem 0.8rem; border: 0; border-bottom: 1px solid var(--border);
  border-left: 2px solid transparent; background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
.file-list li:last-child .file-button { border-bottom: 0; }
.file-button:hover { background: var(--row-hover); }
.file-button[aria-current="true"] { border-left-color: var(--accent); background: var(--accent-soft); }
.file-path { font-size: 0.8125rem; overflow-wrap: anywhere; }
.file-meta { color: var(--muted); font-size: 0.75rem; }
.preview { min-width: 0; padding: 0.9rem 1rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.preview-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5rem; padding-bottom: 0.6rem; border-bottom: 1px solid var(--border); }
.preview-head code { font-size: 0.8125rem; overflow-wrap: anywhere; }
.preview-text { max-height: 36rem; }
.preview-image { display: block; max-width: 100%; height: auto; margin: 0.75rem auto 0; border: 1px solid var(--border); border-radius: 6px; background: #fff; }
.preview .note { margin-top: 0.6rem; }
.session-files { display: grid; gap: 0; margin: 0.5rem 0 0; padding: 0; list-style: none; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }

/* Session transcript as a chat */
.panel-bar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0.75rem; color: var(--text-2); font-size: 0.875rem; }
.panel-bar p { margin: 0; }
.toggle { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.8125rem; }
.transcript-wrap { margin-top: 1rem; }
.transcript { display: flex; flex-direction: column; gap: 1rem; margin: 0; padding: 1.25rem; list-style: none; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.transcript-sentinel { height: 1px; }
.chat-row { display: flex; align-items: flex-start; gap: 0.65rem; max-width: min(56rem, 88%); }
.chat-row:focus { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 12px; }
.chat-row--user { align-self: flex-end; flex-direction: row-reverse; }
.chat-row--assistant, .chat-row--tools { align-self: flex-start; }
.chat-row--tools { width: min(56rem, 88%); }
.chat-row--context { align-self: center; max-width: min(56rem, 92%); }
.chat-row.is-new { animation: chat-in 0.28s ease-out both; }
@keyframes chat-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.chat-avatar {
  display: grid; flex: none; place-items: center; width: 28px; height: 28px; margin-top: 2px; border: 1px solid var(--border); border-radius: 50%;
  background: var(--surface); color: var(--text-2); font: 600 0.75rem/1 var(--sans);
}
img.chat-avatar { padding: 0; object-fit: cover; }
.chat-avatar--assistant { border-color: var(--accent-line); background: var(--accent-soft); color: var(--accent); }
.chat-avatar--tools { border-radius: 8px; font-family: var(--mono); font-size: 0.6875rem; color: var(--muted); }
.message { min-width: 0; padding: 0.7rem 0.95rem; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
.message--user { border-color: var(--accent-line); border-top-right-radius: 4px; background: var(--user-bubble); }
.message--assistant { border-top-left-radius: 4px; }
.message-head { display: flex; align-items: baseline; gap: 0.6rem; margin-bottom: 0.3rem; }
.message-head .message-time { margin-left: auto; }
.role { color: var(--muted); font-size: 0.75rem; font-weight: 600; }
.message--assistant .role { color: var(--accent); }
.message-time { color: var(--muted); font-size: 0.75rem; font-variant-numeric: tabular-nums; }
.message-text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.message-text + .message-text, .message .code + .message-text { margin-top: 0.6rem; }
.message .code { margin: 0.5rem 0; max-height: 28rem; overflow: auto; }
.message-body.is-clamped { position: relative; max-height: 22rem; overflow: hidden; }
.message-body.is-clamped::after { content: ""; position: absolute; inset: auto 0 0; height: 4rem; background: linear-gradient(transparent, var(--bubble-fade, var(--surface))); pointer-events: none; }
.message--user .message-body.is-clamped::after { --bubble-fade: var(--user-bubble); }
.message-expand { margin-top: 0.4rem; padding: 0; border: 0; background: none; color: var(--accent); font: 500 0.8125rem var(--sans); cursor: pointer; }
.message-expand:hover { text-decoration: underline; }
.inline-code { padding: 0.05rem 0.3rem; border-radius: 4px; background: var(--surface-2); font-size: 0.85em; }
.message--user .inline-code { background: var(--surface); }

.message--tools { flex: 1; padding: 0; overflow: hidden; border-radius: 10px; }
.tools-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; padding: 0.5rem 0.85rem; border-bottom: 1px solid var(--border); background: var(--surface); }
.tools-head .message-time { margin-left: auto; }
.tools-summary { min-width: 0; color: var(--muted); font-size: 0.75rem; }
.tool-steps { margin: 0; padding: 0.25rem 0; list-style: none; }
.tool-step summary { display: flex; align-items: center; gap: 0.55rem; padding: 0.35rem 0.85rem 0.35rem 1.6rem; position: relative; list-style: none; cursor: pointer; font-size: 0.8125rem; }
.tool-step summary::-webkit-details-marker { display: none; }
.tool-step summary::before {
  content: ""; position: absolute; left: 0.85rem; top: 50%; width: 0.35rem; height: 0.35rem; margin-top: -0.2rem;
  border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); transform: rotate(-45deg); transition: transform 0.15s;
}
.tool-step details[open] > summary::before { transform: rotate(45deg); }
.tool-step summary:hover { background: var(--row-hover); }
.tool-step summary .message-time { margin-left: auto; }
.tool-step + .tool-step { border-top: 1px dashed var(--border); }
.tool-name { flex: none; font-size: 0.8125rem; font-weight: 600; }
.tool-preview { min-width: 0; overflow: hidden; color: var(--muted); font-size: 0.75rem; text-overflow: ellipsis; white-space: nowrap; }
.exit { flex: none; padding: 0.05rem 0.35rem; border-radius: 4px; background: var(--surface-2); color: var(--muted); font: 0.6875rem var(--mono); }
.exit.is-ok { color: var(--text-2); background: var(--good-soft); }
.exit.is-bad { color: var(--text); background: var(--critical-soft); }
.tool-body { padding: 0 0.85rem 0.75rem 1.6rem; }
.tool-body .code { max-height: 24rem; overflow: auto; }
.tool-label { margin: 0.6rem 0 0; }
.message--context { padding: 0; border-style: dashed; border-radius: 8px; background: transparent; }
.message--context summary { display: flex; gap: 0.75rem; justify-content: space-between; padding: 0.35rem 0.8rem; list-style: none; cursor: pointer; font-size: 0.75rem; }
.message--context summary::-webkit-details-marker { display: none; }
.message--context .code { max-height: 20rem; margin: 0 0.8rem 0.8rem; overflow: auto; }
.message .tag, .tool-step .tag { margin: 0; }
.load-more { display: flex; margin: 0.75rem auto 0; }
.load-more[hidden], .end-mark[hidden] { display: none; }
.end-mark { margin: 0.75rem 0 0; color: var(--muted); font-size: 0.8125rem; text-align: center; }
.panel > .note:last-child { margin-top: 1.25rem; }

/* Archive loading overlay: the page stays visible behind a soft blur */
.archive-overlay {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 1.5rem;
  background: color-mix(in srgb, var(--bg) 50%, transparent); backdrop-filter: blur(16px) saturate(105%); -webkit-backdrop-filter: blur(16px) saturate(105%);
  animation: overlay-in 0.25s ease-out both;
}
@keyframes overlay-in { from { opacity: 0; } to { opacity: 1; } }
.archive-overlay-card {
  display: grid; justify-items: center; gap: 0.75rem; width: min(26rem, 100%); padding: 1.75rem 1.75rem 1.5rem;
  border: 1px solid var(--border); border-radius: 16px; background: var(--surface);
  box-shadow: 0 24px 60px -24px rgba(0, 0, 0, 0.35); text-align: center;
}
.loader { position: relative; display: grid; place-items: center; width: 96px; height: 96px; margin-bottom: 0.25rem; }
.loader > * { grid-area: 1 / 1; }
.archive-overlay-logo { position: relative; z-index: 1; width: 48px; height: 48px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 1px var(--border); animation: breathe 2.4s ease-in-out infinite; }
@keyframes breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(0.93); } }
.loader-ring, .loader-orbit, .loader-sweep { display: none; }
/* Orbit: three dots circling the logo at staggered speeds */
.is-orbit .loader-orbit { display: block; position: relative; width: 84px; height: 84px; }
.loader-orbit i { position: absolute; inset: 0; animation: orbit 1.8s cubic-bezier(0.55, 0.15, 0.45, 0.85) infinite; }
.loader-orbit i::before { content: ""; position: absolute; top: 0; left: 50%; width: 7px; height: 7px; margin-left: -3.5px; border-radius: 50%; background: var(--accent); }
.loader-orbit i:nth-child(2) { animation-delay: -0.18s; opacity: 0.65; }
.loader-orbit i:nth-child(3) { animation-delay: -0.36s; opacity: 0.35; }
@keyframes orbit { to { transform: rotate(360deg); } }
/* Ripple: rings expanding from the logo */
.is-ripple .loader-ring { display: block; width: 52px; height: 52px; border: 1.5px solid var(--accent); border-radius: 50%; animation: ripple 2.2s ease-out infinite; }
.is-ripple .loader-ring:nth-child(2) { animation-delay: 1.1s; }
@keyframes ripple { from { transform: scale(0.95); opacity: 0.7; } to { transform: scale(1.85); opacity: 0; } }
/* Sweep: an arc tracing the rim */
.is-sweep .loader-sweep { display: block; width: 72px; height: 72px; border-radius: 50%; border: 2px solid var(--border); border-top-color: var(--accent); border-right-color: var(--accent-line); animation: orbit 1.1s linear infinite; }
.archive-overlay-tip { min-height: 1.3em; margin: -0.25rem 0 0; color: var(--text-2); font-size: 0.8125rem; }
.archive-overlay-tip.is-swap { animation: tip-in 0.35s ease-out; }
@keyframes tip-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.archive-overlay-title { margin: 0.25rem 0 0; font-weight: 600; }
.archive-overlay-run { margin: 0; max-width: 100%; overflow: hidden; color: var(--muted); font-size: 0.75rem; text-overflow: ellipsis; white-space: nowrap; }
.archive-overlay progress { width: 100%; height: 0.375rem; accent-color: var(--accent); }

/* Agent marks */
.agent-name { display: inline-flex; align-items: center; gap: 0.4rem; }
.agent-logo { display: inline-block; flex: none; width: 16px; height: 16px; }
.agent-logo--openai, .icon-user { background: currentColor; -webkit-mask: var(--icon) center / contain no-repeat; mask: var(--icon) center / contain no-repeat; }
.agent-logo--openai { --icon: url("./icons/openai.svg"); color: var(--text); }
.icon-user { --icon: url("./icons/user.svg"); display: block; width: 15px; height: 15px; }
.chat-avatar--user { color: var(--text-2); }
.chat-avatar--assistant.has-logo { border-color: var(--border); background: var(--surface); }
.chat-avatar .agent-logo { width: 16px; height: 16px; }
.archive-overlay .note { font-variant-numeric: tabular-nums; }
body.is-archive-loading { overflow: hidden; }

/* Responsive */
@media (max-width: 1100px) {
  .facts { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .facts > div:nth-child(3n + 1) { border-left: 0; }
  .facts > div:nth-child(n + 4) { border-top: 1px solid var(--border); }
}
@media (max-width: 860px) {
  .run-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .run-table, .run-table tbody { display: block; }
  .run-table tbody tr { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem 1rem; padding: 0.9rem; border-bottom: 1px solid var(--border); }
  .run-table td, .run-table tbody th { display: block; padding: 0; border: 0; }
  .run-table tbody th { grid-column: 1 / -1; }
  .run-table td::before { content: attr(data-label); display: block; margin-bottom: 0.1rem; color: var(--muted); font-size: 0.6875rem; }
  .status-cards, .files { grid-template-columns: minmax(0, 1fr); }
  .provenance { grid-template-columns: minmax(0, 1fr); }
  .provenance dt { padding-bottom: 0; border-bottom: 0; }
  .chat-row, .chat-row--tools, .chat-row--context { max-width: 100%; width: 100%; }
}
@media (max-width: 560px) {
  .page { padding: 1.5rem 1rem 2.5rem; }
  .masthead, .colophon { padding-left: 1rem; padding-right: 1rem; }
  .toolbar-search { flex-basis: 100%; max-width: none; }
  .toolbar-select { flex: 1 1 9rem; }
  .toolbar-select select { width: 100%; }
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .facts > div:nth-child(n) { border-left: 0; border-top: 1px solid var(--border); }
  .facts > div:nth-child(2n) { border-left: 1px solid var(--border); }
  .facts > div:nth-child(-n + 2) { border-top: 0; }
  .score-readout { padding-left: 0; border-left: 0; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* Sign-in */
.auth { display: grid; place-items: center; min-height: calc(100vh - 12rem); padding: 2rem 0; }
.auth-card {
  display: grid; justify-items: center; gap: 0.9rem; width: min(26rem, 100%); padding: 2.25rem 2rem 1.75rem;
  border: 1px solid var(--border); border-radius: 16px; background: var(--surface); text-align: center;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 16px 40px -24px rgba(0, 0, 0, 0.25);
}
.auth-logo { width: 72px; height: 72px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 1px var(--border); }
.auth-card h1 { font-size: 1.375rem; }
.auth-lede { max-width: 32ch; margin: -0.35rem 0 0.35rem; color: var(--text-2); }
.auth-button { gap: 0.55rem; width: 100%; min-height: 2.75rem; font-size: 0.9375rem; }
.icon-github { --icon: url("./icons/github.svg"); display: inline-block; width: 18px; height: 18px; background: currentColor; -webkit-mask: var(--icon) center / contain no-repeat; mask: var(--icon) center / contain no-repeat; }
.auth-note { max-width: 34ch; margin: 0.1rem 0 0; color: var(--muted); font-size: 0.8125rem; }
.auth-link { color: var(--accent); font-size: 0.8125rem; text-decoration: none; }
.auth-link:hover { text-decoration: underline; }
.auth-error { width: 100%; margin: 0; text-align: left; white-space: pre-wrap; }
.auth-spinner { width: 22px; height: 22px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: orbit 0.9s linear infinite; }
.is-auth .colophon { display: none; }
