:root {
  --bg: #fbfaf7;
  --panel: #ffffff;
  --ink: #23221f;
  --muted: #6d6a63;
  --line: #e2ded4;
  --accent: #185fa5;
  --accent-soft: #e6f1fb;
  --data: #0f6e56;
  --data-soft: #e1f5ee;
  --llm: #534ab7;
  --llm-soft: #eeedfe;
  --warn: #9a5b00;
  --bad: #a32020;
  --radius: 8px;
  --danger-soft: #fbeaea;
  --on-accent: #fff;
  --p1: #1f5fa8; --p1-soft: #eaf1fa; --p2: #a3500b; --p2-soft: #fbf0e6;
  --p3: #0f7a5a; --p3-soft: #e6f5ef; --p4: #6a3fb5; --p4-soft: #f1ecfb;
  --p5: #b0284f; --p5-soft: #fbe9ee; --p6: #0d7285; --p6-soft: #e3f3f6;
  --p7: #6b6b12; --p7-soft: #f3f3e0; --p8: #4a5563; --p8-soft: #eef0f2;
  color-scheme: light;
}

/* Dark theme: follows the system unless the header switch saved a choice
   (html[data-theme]). The same values appear twice for that reason. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16151a;
    --panel: #1e1d23;
    --ink: #ece9e3;
    --muted: #9b968d;
    --line: #33313a;
    --accent: #7db3e8;
    --accent-soft: #1b2c3f;
    --data: #6fd0b0;
    --data-soft: #12302a;
    --llm: #a9a2f5;
    --llm-soft: #241f42;
    --warn: #e2a640;
    --bad: #f08a8a;
    --danger-soft: #36191c;
    --logo-ink: #10151c;
    --on-accent: #10151c;
    --p1: #86b8ee; --p1-soft: #1a2636; --p2: #f0a868; --p2-soft: #33251a;
    --p3: #6fd0b0; --p3-soft: #14302a; --p4: #b9a2f2; --p4-soft: #261f3d;
    --p5: #f28fae; --p5-soft: #361a24; --p6: #6fcde0; --p6-soft: #132f36;
    --p7: #d2d27a; --p7-soft: #2b2b16; --p8: #b4bcc8; --p8-soft: #24272c;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #16151a;
  --panel: #1e1d23;
  --ink: #ece9e3;
  --muted: #9b968d;
  --line: #33313a;
  --accent: #7db3e8;
  --accent-soft: #1b2c3f;
  --data: #6fd0b0;
  --data-soft: #12302a;
  --llm: #a9a2f5;
  --llm-soft: #241f42;
  --warn: #e2a640;
  --bad: #f08a8a;
  --danger-soft: #36191c;
  --logo-ink: #10151c;
  --on-accent: #10151c;
  --p1: #86b8ee; --p1-soft: #1a2636; --p2: #f0a868; --p2-soft: #33251a;
  --p3: #6fd0b0; --p3-soft: #14302a; --p4: #b9a2f2; --p4-soft: #261f3d;
  --p5: #f28fae; --p5-soft: #361a24; --p6: #6fcde0; --p6-soft: #132f36;
  --p7: #d2d27a; --p7-soft: #2b2b16; --p8: #b4bcc8; --p8-soft: #24272c;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* ---------------------------------------------------------------- chrome */

.topbar {
  display: flex; align-items: center; gap: .9rem 1.25rem;
  padding: .55rem 1.25rem;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
  flex-wrap: wrap;
}
.brand {
  display: inline-flex; align-items: center; gap: .55rem;
  font-weight: 700; font-size: 1.02rem; letter-spacing: .01em; color: var(--ink); text-decoration: none;
}
.logo { width: 30px; height: 30px; flex: none; }
.logo-bg { fill: var(--accent); }
.logo-mark { stroke: var(--logo-ink, #fff); }
.logo-fill { fill: var(--logo-ink, #fff); fill-opacity: .25; }
.logo-node { fill: var(--logo-ink, #fff); }
.brand:hover .logo-bg { filter: brightness(1.1); }

.tabs { display: flex; gap: .25rem; flex: 1; flex-wrap: wrap; }
.tabs a {
  color: var(--muted); text-decoration: none; font-size: .92rem; font-weight: 550;
  padding: .4rem .75rem; border-radius: 6px; white-space: nowrap;
}
.tabs a:hover { color: var(--ink); background: var(--bg); }
.tabs a.active { color: var(--accent); background: var(--accent-soft); }

.theme-toggle {
  margin: 0; padding: 0; width: 34px; height: 34px; flex: none;
  display: inline-grid; place-items: center;
  background: transparent; color: var(--muted); border: 1px solid var(--line); border-radius: 999px;
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); filter: none; }
.theme-toggle svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}

@media (max-width: 700px) {
  .topbar { padding: .5rem 1rem; gap: .5rem .75rem; }
  .tabs { order: 3; flex-basis: 100%; gap: .15rem; }
  .tabs a { padding: .3rem .45rem; font-size: .84rem; }
  .cluster-pill { margin-left: auto; }
}

.crumbs { font-size: .84rem; color: var(--muted); margin: -.4rem 0 .9rem; display: flex; flex-wrap: wrap; gap: .35rem; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--accent); text-decoration: underline; }
.crumbs .sep { opacity: .6; }

.cluster-pill {
  font-size: .8rem; padding: .25rem .6rem; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
  border: 1px solid transparent; white-space: nowrap;
}
.cluster-pill.warn { background: transparent; color: var(--warn); border-color: var(--warn); }
.cluster-pill.bad  { background: transparent; color: var(--bad);  border-color: var(--bad); }

main { max-width: 1080px; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }

h1 { font-size: 1.5rem; margin: 0 0 .35rem; }
h2 { font-size: 1.05rem; margin: 2rem 0 .75rem; }
.sub { color: var(--muted); margin: 0 0 1.5rem; font-size: .92rem; }

/* ---------------------------------------------------------------- panels */

.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1rem 1.15rem; margin-bottom: 1rem;
}

/* Brief highlight when the corpus cards are refreshed in place after an ingest. */
@keyframes panel-flash {
  from { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
  to   { border-color: var(--line); box-shadow: 0 0 0 3px transparent; }
}

.grid { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }

.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem .95rem; }
.stat .label { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
.stat .value { font-size: 1.45rem; font-weight: 600; margin-top: .15rem; font-variant-numeric: tabular-nums; }
.stat .note { color: var(--muted); font-size: .8rem; }

/* ---------------------------------------------------------------- tables */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: .55rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
td a { color: var(--accent); }
tbody tr:last-child td { border-bottom: none; }

/* ---------------------------------------------------------------- badges */

.badge {
  display: inline-block; padding: .12rem .5rem; border-radius: 999px;
  font-size: .76rem; font-weight: 600; white-space: nowrap;
}
.badge.succeeded { background: var(--data-soft); color: var(--data); }
.badge.running   { background: var(--accent-soft); color: var(--accent); }
.badge.pending   { background: var(--line); color: var(--muted); }
.badge.failed    { background: transparent; color: var(--bad); border: 1px solid var(--bad); }
.badge.cancelled { background: transparent; color: var(--muted); border: 1px solid var(--line); }

.mode { font-size: .78rem; color: var(--llm); background: var(--llm-soft); padding: .12rem .5rem; border-radius: 999px; }

/* ---------------------------------------------------------------- forms */

label { display: block; font-size: .85rem; color: var(--muted); margin: .9rem 0 .3rem; }
input[type=text], input[type=file], select, textarea {
  width: 100%; padding: .5rem .6rem; font: inherit;
  background: var(--bg); color: var(--ink);
  border: 1px solid var(--line); border-radius: 6px;
}
textarea { min-height: 8rem; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .86rem; }
button {
  margin-top: 1rem; padding: .5rem 1.1rem; font: inherit; font-weight: 600;
  background: var(--accent); color: var(--on-accent); border: none; border-radius: 6px; cursor: pointer;
}
button:hover { filter: brightness(1.08); }
.hint { color: var(--muted); font-size: .82rem; margin-top: .3rem; }

/* ---------------------------------------------------------------- trace */

pre {
  background: var(--bg); border: 1px solid var(--line); border-radius: 6px;
  padding: .8rem; overflow-x: auto; font-size: .84rem; line-height: 1.5;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.answer { white-space: pre-wrap; line-height: 1.65; }

.event { border-left: 3px solid var(--line); padding: .5rem 0 .5rem .8rem; margin-bottom: .5rem; }
.event.llm_call  { border-left-color: var(--llm); }
.event.tool_call { border-left-color: var(--data); }
.event.retrieval { border-left-color: var(--accent); }
.event.error     { border-left-color: var(--bad); }
.event .meta { color: var(--muted); font-size: .78rem; display: flex; gap: .75rem; flex-wrap: wrap; }
.event .body { margin-top: .3rem; white-space: pre-wrap; font-size: .88rem; }

details summary { cursor: pointer; color: var(--muted); font-size: .84rem; margin-top: .3rem; }
.thinking { color: var(--muted); font-style: italic; white-space: pre-wrap; font-size: .85rem; }

.empty { color: var(--muted); font-style: italic; padding: .5rem 0; }

/* ---------------------------------------------------------------- about / hero */

.hero { padding: 1rem 0 2rem; border-bottom: 1px solid var(--line); margin-bottom: 2rem; }
.hero h1 { font-size: 2rem; margin-bottom: .6rem; }
.lede { font-size: 1.08rem; line-height: 1.6; color: var(--ink); max-width: 62ch; margin-bottom: 1.4rem; }
.prose { line-height: 1.7; max-width: 68ch; color: var(--ink); }
.prose.muted-note { color: var(--muted); font-size: .88rem; margin-top: 1rem; }

.cta-row { display: flex; gap: .6rem; flex-wrap: wrap; }
.btn {
  display: inline-block; padding: .55rem 1.1rem; border-radius: 6px; text-decoration: none;
  font-size: .92rem; font-weight: 600; border: 1px solid var(--line); color: var(--ink);
  background: var(--panel);
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); color: var(--on-accent); }
.btn.ghost { background: transparent; }

.feature-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.feature { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; }
.feature-icon { font-size: 1.5rem; }
.feature h3 { font-size: 1rem; margin: .5rem 0 .4rem; }
.feature p { color: var(--muted); font-size: .9rem; line-height: 1.55; }

.steps { max-width: 68ch; line-height: 1.6; padding-left: 1.2rem; }
.steps li { margin: .5rem 0; }

/* ---------------------------------------------------------------- forms, extended */

.two-col { display: grid; gap: 1rem; grid-template-columns: 1fr 1fr; }
@media (max-width: 620px) { .two-col { grid-template-columns: 1fr; } }
label.check { display: flex; align-items: center; gap: .5rem; cursor: pointer; }
label.check input { width: auto; }
input[type=number] { width: 100%; padding: .5rem .6rem; font: inherit; background: var(--bg); color: var(--ink); border: 1px solid var(--line); border-radius: 6px; }
.req { color: var(--bad); }
.hint-inline { color: var(--muted); font-weight: 400; font-size: .78rem; }
textarea.short { min-height: 4.5rem; font-family: inherit; font-size: .9rem; }
button.primary { background: var(--accent); }

/* roleplay agent builder */
.agents-head { display: flex; align-items: center; justify-content: space-between; margin-top: 1rem; }
.agents-head h3 { font-size: 1rem; }
.add-agent, .remove-agent {
  margin: 0; padding: .3rem .7rem; font-size: .82rem; font-weight: 600;
  background: transparent; color: var(--accent); border: 1px solid var(--accent); border-radius: 6px;
}
.remove-agent { color: var(--muted); border-color: var(--line); }
.remove-agent:hover { color: var(--bad); border-color: var(--bad); filter: none; }
.agent-card { border: 1px solid var(--line); border-radius: var(--radius); padding: .5rem 1rem 1rem; margin-top: .8rem; background: var(--bg); }
.agent-card-head { display: flex; align-items: center; justify-content: space-between; margin-top: .3rem; }
.agent-num { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.agent-actions { display: flex; gap: .4rem; }
.agent-card.has-error { border-color: var(--bad); }
.agent-card.has-warning { border-color: var(--warn); }
.agent-more summary { margin-top: .9rem; }
.private-tag { font-size: .7rem; color: var(--warn); border: 1px solid var(--warn); border-radius: 999px; padding: 0 .4rem; margin-left: .3rem; font-weight: 600; }
button:disabled { opacity: .55; cursor: progress; }

/* cast files, AI drafting and checks */
.cast-toolbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-top: .6rem; }
.small-btn {
  margin: 0; padding: .3rem .7rem; font-size: .82rem; font-weight: 600;
  background: transparent; color: var(--accent); border: 1px solid var(--accent); border-radius: 6px;
}
.agent-actions .small-btn { color: var(--muted); border-color: var(--line); }
.small-btn:hover { filter: none; background: var(--accent-soft); }
.small-link { font-size: .82rem; color: var(--accent); }
.cast-drop { border: 1px dashed var(--line); border-radius: var(--radius); padding: .6rem .8rem; margin-top: .8rem; }
.cast-drop.dragging { border-color: var(--accent); background: var(--accent-soft); }
.drop-hint { color: var(--muted); font-size: .82rem; margin: 0; }
.draft-panel { border: 1px solid var(--line); border-radius: var(--radius); padding: .2rem 1rem 1rem; margin-top: .8rem; background: var(--bg); }
.cast-toolbar label { margin: 0; }
.draft-panel select { width: auto; }
.source-choice { display: flex; flex-wrap: wrap; gap: .3rem 1.2rem; }
.source-choice label { margin: 0; }
.source-input { margin-top: .6rem; }
.source-input .cast-toolbar input[type=text] { flex: 1; min-width: 14rem; width: auto; }
.source-preview { border-left: 3px solid var(--data); background: var(--panel); padding: .5rem .8rem; margin-top: .8rem; border-radius: 0 6px 6px 0; }
.source-title { font-weight: 600; font-size: .92rem; }
.source-meta { font-size: .8rem; color: var(--muted); margin-top: .1rem; }
.source-excerpt { font-size: .85rem; color: var(--muted); margin: .4rem 0 0; line-height: 1.5; }
.source-note { margin-top: .6rem; }
.cast-messages { margin-top: .8rem; }
.cast-msg-head { margin: .2rem 0 .4rem; font-size: .88rem; }
.issue-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .35rem; }
.issue { font-size: .86rem; line-height: 1.45; }
.issue-level { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; border: 1px solid currentColor; border-radius: 999px; padding: 0 .45rem; }
.issue.error .issue-level { color: var(--bad); }
.issue.warning .issue-level { color: var(--warn); }
.issue.suggestion .issue-level { color: var(--accent); }
.issue.note .issue-level { color: var(--data); }

/* run page: moderator interventions and private notes */
.event.moderator-note { border-left-color: var(--warn); }
dl.ledger { margin: .4rem 0 0; font-size: .84rem; }
dl.ledger dt { color: var(--muted); font-weight: 600; margin-top: .3rem; }
dl.ledger dd { margin: 0 0 0 .8rem; white-space: pre-wrap; }

/* ---------------------------------------------------------------- legal sources */

.source-topic .topic-head h3 { font-size: 1.02rem; margin: 0; }
.source-topic .topic-head { margin-bottom: .5rem; }
.provider { border-top: 1px solid var(--line); padding: 1rem 0 .4rem; }
.provider:first-of-type { border-top: none; }
.provider.unavailable { opacity: .7; }
.provider-name { font-weight: 650; }
.provider-home { text-decoration: none; color: var(--muted); font-size: .8rem; margin-left: .3rem; }
.provider-blurb { color: var(--muted); font-size: .86rem; margin-top: .2rem; line-height: 1.5; max-width: 70ch; }
.provider-note { font-size: .82rem; color: var(--muted); margin: .4rem 0; }
.provider-note.warn { color: var(--warn); }

.source-search { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-top: .6rem; }
.source-search input[name=q] { flex: 1; min-width: 12rem; }
.source-search button { margin: 0; }
.corpus-inline { display: inline-flex; align-items: center; gap: .4rem; font-size: .82rem; color: var(--muted); margin: 0; }
.corpus-inline input { width: auto; }

.source-results { margin-top: .6rem; }
.hit-list { display: flex; flex-direction: column; gap: .1rem; }
.hit { display: flex; gap: .6rem; padding: .55rem .5rem; border-radius: 6px; cursor: pointer; align-items: start; }
.hit:hover { background: var(--bg); }
.hit input { width: auto; margin-top: .25rem; }
.hit-body { display: flex; flex-direction: column; gap: .15rem; }
.hit-title { font-size: .92rem; font-weight: 550; }
.hit-meta { font-size: .78rem; color: var(--muted); }
.hit-snippet { font-size: .84rem; color: var(--muted); line-height: 1.5; }
.hit-link { font-size: .78rem; color: var(--accent); text-decoration: none; width: fit-content; }
.snip-flag { font-size: .7rem; color: var(--warn); border: 1px solid var(--warn); border-radius: 999px; padding: 0 .4rem; font-weight: 600; }
.hit-mark { font-weight: 700; }
.hit-ingested .hit-mark { color: var(--data); }
.hit-duplicate .hit-mark { color: var(--muted); }
.hit-empty .hit-mark, .hit-error .hit-mark { color: var(--bad); }

.ingest-bar { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin-top: .6rem; padding-top: .6rem; border-top: 1px dashed var(--line); }
.ingest-bar button { margin: 0; }
.ingest-status { font-size: .82rem; color: var(--muted); }

/* ---------------------------------------------------------------- experiment page */

.exp-description { max-width: 75ch; margin: -.8rem 0 1.2rem; }
.mode-blurb { color: var(--muted); font-size: .9rem; margin: 0 0 .9rem; max-width: 75ch; }
.fact-grid { display: grid; gap: .7rem 1.5rem; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.fact-label, .person-label, .source-label { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; }
.fact-value { font-size: 1.05rem; font-weight: 600; margin-top: .1rem; }
.fact-note { color: var(--muted); font-size: .78rem; }
.config-details { margin-top: 1rem; }
.config-details pre { margin-top: .5rem; max-height: 24rem; }

.notice { border-left: 3px solid var(--accent); background: var(--accent-soft); padding: .55rem .85rem; border-radius: 0 6px 6px 0; font-size: .9rem; margin: 0 0 1rem; }
.notice a { color: var(--accent); }
.notice.bad { border-left-color: var(--bad); background: transparent; color: var(--bad); }
.notice ul { margin: .3rem 0; padding-left: 1.2rem; }

.scenario-text { white-space: pre-wrap; line-height: 1.7; max-width: 75ch; }
.source-card { margin-top: 1rem; border-left: 3px solid var(--data); background: var(--bg); padding: .45rem .85rem; border-radius: 0 6px 6px 0; }
.source-card a { color: var(--accent); }

.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.cast-grid { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); align-items: start; margin-bottom: 1rem; }
.person-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .85rem 1rem; }
.person-name { font-weight: 650; font-size: 1rem; }
.person-role { color: var(--muted); font-size: .86rem; margin-top: .1rem; line-height: 1.45; }
.person-field { margin-top: .65rem; }
.person-text { font-size: .9rem; line-height: 1.55; white-space: pre-wrap; margin-top: .1rem; }
.person-list { margin: .2rem 0 0; padding-left: 1.1rem; font-size: .9rem; line-height: 1.5; }
.person-more { margin-top: .7rem; }
.private-block { margin-top: .9rem; padding-top: .5rem; border-top: 1px dashed var(--warn); }
.private-head { font-size: .8rem; color: var(--warn); font-weight: 600; }

textarea.tall { min-height: 9rem; }
textarea.doc-text { min-height: 14rem; font-family: inherit; font-size: .9rem; }
.pacing { margin-top: .9rem; }
.estimate { color: var(--muted); font-size: .85rem; margin: .7rem 0 0; }
.load-row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-bottom: .5rem; }
.load-row input[type=text] { flex: 1; min-width: 14rem; width: auto; }
label.file-btn { display: inline-block; margin: 0; cursor: pointer; color: var(--accent); }
.launch-row { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-top: 1rem; }
.launch-row button { margin: 0; }
.launch-error { color: var(--bad); font-size: .9rem; margin: .9rem 0 0; }
.advanced { margin-top: 1.1rem; }
.run-summary { color: var(--muted); font-size: .86rem; min-width: 18rem; }
td.nowrap { white-space: nowrap; }
.mode-blurb a, .hint a, .feature a { color: var(--accent); }

/* ---------------------------------------------------------------- about: method notes */

.method-notes { list-style: none; padding: 0; margin: 0; max-width: 75ch; display: grid; gap: .6rem; }
.method-notes li { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .85rem 1rem; }
.method-title { font-weight: 650; }
.method-meta { color: var(--muted); font-size: .84rem; margin-top: .15rem; }
.method-meta a { color: var(--accent); }
.method-blurb { color: var(--muted); font-size: .9rem; line-height: 1.55; margin: .45rem 0 0; }

/* ---------------------------------------------------------------- shared: titles, actions, danger */

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.title-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.title-row h1 { margin-bottom: .35rem; }
.title-row form { margin: 0; }
.head-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
a.small-btn { display: inline-block; text-decoration: none; }
.small-btn.quiet { color: var(--muted); border-color: var(--line); }
.small-btn.quiet:hover { color: var(--ink); background: var(--bg); }
.small-btn.danger { color: var(--bad); border-color: var(--bad); background: transparent; }
.small-btn.danger:hover { background: var(--danger-soft); }
.small-btn:disabled { cursor: not-allowed; }
button.danger { background: var(--bad); color: var(--on-accent); }
button.danger:disabled { opacity: .45; cursor: not-allowed; }

td.actions-cell { width: 1%; }
.row-actions { display: flex; gap: .4rem; justify-content: flex-end; white-space: nowrap; }
.row-actions form { margin: 0; }
.icon { width: 1em; height: 1em; vertical-align: -.12em; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn {
  margin: 0; padding: .2rem .45rem; font-size: .9rem; line-height: 1.2; font-weight: 400;
  background: transparent; color: var(--muted); border: 1px solid transparent; border-radius: 6px;
}
.icon-btn:hover { border-color: var(--bad); color: var(--bad); background: var(--danger-soft); filter: none; }
.link-btn {
  margin: 0 0 0 .4rem; padding: 0; background: none; border: none; color: var(--accent);
  font: inherit; font-weight: 650; text-decoration: underline; cursor: pointer;
}
.link-btn:hover { filter: none; }
.notice.undo, .notice.bad-soft { display: block; }
.notice.bad-soft { border-left-color: var(--bad); background: var(--danger-soft); }

.danger-zone { border-color: var(--bad); }
.danger-zone p { margin-top: 0; max-width: 75ch; }
.plain-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }
.plain-list a { color: var(--accent); margin-right: .4rem; }

/* ---------------------------------------------------------------- legal sources: corpora, tabs, picker */

.corpus-grid { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.corpus-card {
  display: flex; flex-direction: column; gap: .2rem; text-decoration: none; color: var(--ink);
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .85rem 1rem;
}
.corpus-card:hover { border-color: var(--accent); }
.corpus-name { font-weight: 650; font-size: 1rem; }
.corpus-stats { font-size: .88rem; }
.corpus-meta { color: var(--muted); font-size: .8rem; }
.corpus-open { color: var(--accent); font-size: .84rem; font-weight: 600; margin-top: .3rem; }
#corpus-panel.flash .corpus-card { animation: panel-flash 1.1s ease-out; }

.subtabs { display: flex; flex-wrap: wrap; gap: .2rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; }
.subtabs button {
  margin: 0 0 -1px; padding: .55rem .95rem; font-size: .92rem; font-weight: 600; white-space: nowrap;
  background: transparent; color: var(--muted); border: 1px solid transparent; border-bottom: none;
  border-radius: 6px 6px 0 0;
}
.subtabs button:hover { color: var(--ink); filter: none; }
.subtabs button.active { color: var(--accent); background: var(--panel); border-color: var(--line); }

.corpus-picker { display: inline-flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.corpus-picker select { width: auto; min-width: 11rem; }
.corpus-picker .corpus-new { width: 14rem; }
.corpus-picker .corpus-new[hidden] { display: none; }
form .corpus-picker { display: flex; }

/* corpus inspection: retrieval probe and document passages */
.probe-results { margin-top: .8rem; display: grid; gap: .6rem; }
.passage { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .7rem .9rem; margin-bottom: .6rem; }
.probe-results .passage { background: var(--bg); margin: 0; }
.passage-head { display: flex; justify-content: space-between; gap: 1rem; font-size: .82rem; color: var(--muted); font-weight: 600; margin-bottom: .35rem; }
.passage-head a { color: var(--accent); }
.passage-score { font-weight: 500; white-space: nowrap; }
.passage-text { white-space: pre-wrap; font-size: .9rem; line-height: 1.6; }
.passage:target { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* about: logo beside the title */
.hero-title { display: flex; align-items: center; gap: .8rem; }
.hero-title .logo { width: 48px; height: 48px; }

/* ---------------------------------------------------------------- web links */

.link-results { list-style: none; margin: .5rem 0 0; padding: 0; display: grid; gap: .45rem; }
.link-result { display: flex; gap: .5rem; align-items: baseline; font-size: .88rem; }
.link-result > span:last-child { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.link-result a { color: var(--accent); }
.link-url { overflow-wrap: anywhere; font-size: .86rem; }
.link-url a { color: var(--accent); }
.link-status { font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.link-result.added .hit-mark, .link-result.updated .hit-mark { color: var(--data); }
.link-result.unchanged .hit-mark, .link-result.exists .hit-mark { color: var(--muted); }
.link-result.error .hit-mark { color: var(--bad); }
.check-cell { font-size: .84rem; white-space: nowrap; }
.check-cell .link-result { display: inline-flex; white-space: normal; }
td.check-cell .provider-note { margin: 0; white-space: normal; }
.add-links-panel { margin-top: 1rem; }
#check-all-result:not(:empty) { margin-bottom: .8rem; }
.link-panel .fact-grid { grid-template-columns: 2fr 1fr 1fr; }
@media (max-width: 620px) { .link-panel .fact-grid { grid-template-columns: 1fr; } }
.cta-row button.btn { margin: 0; font: inherit; font-size: .92rem; font-weight: 600; cursor: pointer; }

/* ---------------------------------------------------------------- run page */

.run-id { font-size: .95rem; font-weight: 500; color: var(--muted); margin-left: .3rem; }
.export-form { display: flex; align-items: center; gap: .7rem; flex-wrap: wrap; margin: 0 0 0 auto; }
.export-form label.check { margin: 0; font-size: .82rem; }
.jump { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; margin: -.4rem 0 1.2rem; }
.jump a { font-size: .82rem; color: var(--muted); text-decoration: none; border: 1px solid var(--line);
          border-radius: 999px; padding: .15rem .65rem; background: var(--panel); }
.jump a:hover { color: var(--accent); border-color: var(--accent); }

/* Model-written Markdown: summary, turns, moderator notes. */
.md { line-height: 1.65; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 .7rem; }
.md h3 { font-size: 1.12rem; margin: 1.2rem 0 .5rem; }
.md h4 { font-size: 1rem; margin: 1.1rem 0 .4rem; }
.md h5, .md h6 { font-size: .92rem; margin: .9rem 0 .35rem; }
.md ul, .md ol { margin: 0 0 .7rem; padding-left: 1.4rem; }
.md li { margin: .25rem 0; }
.md li > ul { margin: .2rem 0 0; }
.md blockquote { margin: 0 0 .7rem; padding-left: .8rem; border-left: 3px solid var(--line); color: var(--muted); }
.md hr { border: none; border-top: 1px solid var(--line); margin: 1rem 0; }
.md code { font-size: .88em; background: var(--bg); border: 1px solid var(--line); border-radius: 4px; padding: 0 .25rem; }
.md table { margin: .3rem 0 .8rem; }
.md a { color: var(--accent); }
.cite { color: var(--accent); font-weight: 600; font-size: .9em; }
a.turn-ref { color: var(--accent); text-decoration: none; border-bottom: 1px dotted currentColor; }
.summary-panel { padding: 1.2rem 1.4rem; max-width: 80ch; }

.setup-panel > summary { font-weight: 600; color: var(--ink); font-size: .92rem; margin: 0; }
.setup-panel .scenario-text { margin-top: .8rem; }
.setup-cast { margin: 1rem 0 0; }

.notes-toggle { margin: 0; font-size: .82rem; }
.speaker-legend { display: flex; flex-wrap: wrap; gap: .45rem; margin-bottom: 1rem; }
.speaker-chip {
  margin: 0; display: inline-flex; align-items: center; gap: .45rem; padding: .3rem .75rem;
  font-size: .85rem; font-weight: 650; border-radius: 999px; cursor: pointer;
  color: var(--c); background: var(--c-soft); border: 1px solid var(--c);
}
.speaker-chip:hover { filter: none; }
.speaker-chip .dot { width: .6rem; height: .6rem; border-radius: 50%; background: var(--c); }
.speaker-chip .chip-meta { font-weight: 500; font-size: .76rem; opacity: .85; }
.speaker-chip[aria-pressed="false"] { background: transparent; color: var(--muted); border-color: var(--line); text-decoration: line-through; }
.speaker-chip[aria-pressed="false"] .dot { background: var(--line); }

.transcript { display: grid; gap: .7rem; }
.turn { --c: var(--ink); --c-soft: var(--panel);
        background: var(--c-soft); border: 1px solid var(--line); border-left: 4px solid var(--c);
        border-radius: 0 var(--radius) var(--radius) 0; padding: .75rem 1rem .6rem; scroll-margin-top: 5rem; }
.turn:target { box-shadow: 0 0 0 3px var(--accent-soft); }
.turn-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: .2rem .6rem; margin-bottom: .45rem; }
.turn-name { font-weight: 700; color: var(--c); }
.turn-meta { font-size: .78rem; color: var(--muted); }
.turn-anchor { margin-left: auto; color: var(--muted); text-decoration: none; font-size: .8rem; opacity: 0; }
.turn:hover .turn-anchor { opacity: 1; }
.turn-body { font-size: .94rem; }
.turn-extra { margin-top: .4rem; }
.turn-extra summary { margin-top: 0; }
.turn.moderator { --c: var(--warn); --c-soft: transparent; border-style: dashed; border-left-style: solid; margin-left: 1.5rem; }
.turn.moderator .turn-body { font-size: .9rem; font-style: italic; }
.source-list { list-style: none; margin: .4rem 0 0; padding: 0; display: grid; gap: .25rem; font-size: .84rem; }
.source-list a { color: var(--accent); }
.source-list li:not(.cited) { opacity: .8; }

.c1 { --c: var(--p1); --c-soft: var(--p1-soft); } .c2 { --c: var(--p2); --c-soft: var(--p2-soft); }
.c3 { --c: var(--p3); --c-soft: var(--p3-soft); } .c4 { --c: var(--p4); --c-soft: var(--p4-soft); }
.c5 { --c: var(--p5); --c-soft: var(--p5-soft); } .c6 { --c: var(--p6); --c-soft: var(--p6-soft); }
.c7 { --c: var(--p7); --c-soft: var(--p7-soft); } .c8 { --c: var(--p8); --c-soft: var(--p8-soft); }
.speaker-chip.moderator { --c: var(--warn); --c-soft: transparent; }

.trace-wrap > summary { font-size: .88rem; margin: 0 0 .6rem; }
@media (max-width: 620px) { .turn.moderator { margin-left: 0; } }
a.cite { text-decoration: none; } a.cite:hover { text-decoration: underline; }

/* ---------------------------------------------------------------- library versions and citations */

.corpus-version { font-size: .75rem; font-weight: 600; color: var(--muted); margin-left: .25rem; }
.citation-list { margin: 0; padding-left: 1.6rem; display: grid; gap: .55rem; font-size: .9rem; line-height: 1.5; }
.citation-list .cite-title { color: var(--ink); text-decoration: none; }
.citation-list .cite-title:hover { color: var(--accent); text-decoration: underline; }
.citation-list .cite-url { display: block; font-size: .8rem; color: var(--accent); overflow-wrap: anywhere; }
.change-note { font-size: .86rem; min-width: 16rem; }
.doc-cite { font-size: .9rem; line-height: 1.55; }
.doc-cite a { color: var(--accent); overflow-wrap: anywhere; }
.doc-cite .fact-note a { margin-right: .15rem; }

/* ---------------------------------------------------------------- choosing several libraries */

.library-picker { display: grid; gap: .3rem; margin: .2rem 0 .3rem; max-height: 16rem; overflow-y: auto;
                  padding: .5rem .7rem; border: 1px solid var(--line); border-radius: 8px; }
.library-picker .lib-option, .lib-row label.check { font-size: .9rem; margin: 0; padding: .15rem 0; }
.lib-name { font-weight: 600; overflow-wrap: anywhere; }
.lib-rows { display: grid; gap: .35rem; margin: .2rem 0 .3rem; }
.lib-row { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .8rem; }
.lib-row label.check { flex: 1 1 14rem; margin: 0; }
.lib-row select { width: auto; max-width: 100%; flex: 0 1 22rem; margin: 0; }
.lib-row select[hidden] { display: none; }
.lib-more > summary { font-size: .86rem; color: var(--accent); cursor: pointer; margin: .3rem 0; }
.lib-tag { font-size: .78rem; color: var(--muted); white-space: nowrap; }
.ref-list { margin: 0; padding-left: 1.6rem; display: grid; gap: .7rem; font-size: .9rem; line-height: 1.5; }
.ref-list .ref-uses { font-size: .8rem; color: var(--muted); }
.ref-list .ref-uses .cite { margin-right: .1rem; }
.hidden-libs { margin-top: .8rem; }
.crawl-rules { margin: .8rem 0; font-size: .86rem; }
.crawl-rules > summary { cursor: pointer; font-weight: 600; }
.crawl-rules ol { margin: .4rem 0; padding-left: 1.3rem; display: grid; gap: .3rem; line-height: 1.45; }
.crawl-plan ul { margin: .3rem 0 .6rem; padding-left: 1.2rem; font-size: .88rem; display: grid; gap: .25rem; }
.crawl-sample { font-size: .8rem; overflow-wrap: anywhere; }
.crawl-bar { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin: .3rem 0 .5rem; }
.crawl-bar span { display: block; height: 100%; background: var(--accent); transition: width .4s; }
.crawl-history { margin-top: 1rem; font-size: .86rem; }
.rename-panel input[type=text] { flex: 1 1 18rem; }
.doc-optional { margin: .9rem 0 .4rem; }
.doc-optional > summary { cursor: pointer; font-weight: 600; font-size: .92rem; }
.bulk-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .9rem; margin: 0 0 .6rem; }
.bulk-bar label.check { margin: 0; font-size: .88rem; }
.select-cell { width: 1.6rem; }
.select-cell input { width: auto; }
.crawl-time { font-size: .86rem; margin: 0 0 .4rem; }
.link-result.unreadable .hit-mark { color: var(--warn); }
.crawl-history .link-btn { overflow-wrap: anywhere; text-align: left; }
.hidden-libs > summary { font-size: .88rem; color: var(--muted); cursor: pointer; }
.corpus-card.is-hidden { opacity: .75; }
.inline-form { display: inline; margin: 0; }
.exhibit-list { margin: 0; padding-left: 0; list-style: none; display: grid; gap: .6rem; font-size: .9rem; }
.exhibit-list li { border-left: 3px solid var(--c, var(--line)); padding-left: .6rem; }
.exhibit-list a { color: var(--accent); }
.exhibit-list details summary { font-size: .8rem; color: var(--muted); }
.disclosed-note { font-size: .82rem; color: var(--muted); margin: .3rem 0 0; }
.lib-row.case-file input:disabled { opacity: .6; }
.lib-summary { font-size: .86rem; color: var(--muted); margin: 0 0 .6rem; }

/* ---------------------------------------------------------------- accounts */

.count-badge { display: inline-block; min-width: 1.2rem; padding: 0 .35rem; margin-left: .2rem; border-radius: 999px;
               background: var(--bad); color: var(--on-accent); font-size: .72rem; font-weight: 700; text-align: center; }
.user-menu { position: relative; }
.user-menu > summary { list-style: none; display: flex; align-items: center; gap: .45rem; cursor: pointer; margin: 0;
                       color: var(--ink); font-size: .88rem; font-weight: 600; }
.user-menu > summary::-webkit-details-marker { display: none; }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: inline-grid; place-items: center;
          background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: .85rem; }
.user-menu-body { position: absolute; right: 0; top: calc(100% + .5rem); z-index: 20; min-width: 16rem;
                  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
                  box-shadow: 0 8px 24px rgb(0 0 0 / .12); padding: .8rem .9rem; display: grid; gap: .5rem; font-size: .88rem; }
.user-menu-body .small-btn { justify-self: start; }
@media (max-width: 700px) { .user-name { display: none; } }
.status-card { max-width: 38rem; margin: 3rem auto; padding: 1.6rem 1.8rem; }
.status-card h1 { margin-bottom: .8rem; }
.static-field { margin: .35rem 0 0; padding: .5rem 0; font-weight: 600; }
.inline-form { display: inline-flex; gap: .35rem; align-items: center; margin: 0; }
.inline-form select { width: auto; padding: .25rem .4rem; }

/* ---------------------------------------------------------------- agent activity (run page) */
.activity-wrap > summary { cursor: pointer; color: var(--muted); margin-bottom: .5rem; }
.activity-bar { display: flex; flex-wrap: wrap; gap: .4rem 1rem; align-items: baseline; margin-bottom: .5rem; }
.activity-status { color: var(--accent); font-weight: 550; }
.activity-meta { color: var(--muted); font-size: .85rem; }
.ctx-meter { position: relative; height: 8px; border-radius: 4px; background: var(--line); overflow: visible; }
.ctx-fill { height: 100%; width: 0; border-radius: 4px; background: var(--accent); transition: width .4s; }
.ctx-fill.near { background: var(--bad); }
.ctx-mark { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--bad); }
.activity-list { list-style: none; padding: 0; margin: .8rem 0 0; display: grid; gap: .45rem; }
.activity-list > li { padding: .45rem .65rem; border-radius: 6px; border-left: 3px solid var(--line); }
.activity-step { background: var(--accent-soft); border-left-color: var(--accent) !important; }
.activity-result { margin-left: 1.2rem; }
.activity-note { margin-left: 1.2rem; color: var(--muted); font-size: .9rem; }
.activity-note.bad { color: var(--bad); border-left-color: var(--bad) !important; }
.activity-head-line { display: flex; flex-wrap: wrap; gap: .2rem .6rem; align-items: baseline; }
.activity-num, .activity-tool { font-weight: 650; white-space: nowrap; }
.activity-what { flex: 1 1 18rem; overflow-wrap: anywhere; }
.activity-items { margin: .3rem 0 0 1.1rem; padding: 0; font-size: .88rem; }
.activity-items .muted { color: var(--muted); list-style: none; }
.activity-reasoning > summary { cursor: pointer; color: var(--muted); font-size: .85rem; margin-top: .25rem; }
.activity-more { white-space: pre-wrap; font-size: .85rem; max-height: 22rem; overflow: auto;
  padding: .5rem; margin-top: .3rem; border: 1px solid var(--line); border-radius: 6px; }

.inline-field { display: flex; align-items: baseline; gap: .5rem; }

/* ---------------------------------------------------------------- research plan */
.plan-head { margin-top: 1.2rem; }
.plan-actions { display: flex; flex-wrap: wrap; gap: .4rem 1rem; align-items: center; }
.plan-subs { padding-left: 1.4rem; display: grid; gap: .5rem; }
.plan-sub textarea { min-height: 3.2rem; }
.plan-sub-foot { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.plan-libs { display: grid; gap: .2rem; }
.plan-panel > summary { cursor: pointer; }
.plan-list { padding-left: 1.4rem; }
.finding > summary { cursor: pointer; }
.finding { margin-bottom: .5rem; }
.stop-form { display: flex; flex-wrap: wrap; gap: .4rem 1rem; align-items: center; margin: .6rem 0; }
.danger-btn { background: var(--bad); color: #fff; border: 0; border-radius: 6px; padding: .45rem .9rem; font-weight: 600; cursor: pointer; }
.plan-lib { align-items: baseline; }
.plan-lib .lib-name { white-space: nowrap; }
