/* =============================================================================
 * Council of Experts — design system
 *
 * Lab-notebook aesthetic: paper-amber accent on off-white, restrained sans-serif
 * typography (Inter), monospace for numbers (JetBrains Mono). The visual
 * identity is "honest comparative research," not "marketing site."
 *
 * Reference: Distill.pub, Observable. No drop shadows, no gradients, generous
 * vertical rhythm, single column for prose, three-column grid for the A/B page.
 * ============================================================================= */

/* -----------------------------------------------------------------------------
 * Self-hosted fonts. No CDN; no Referer leak of prompt content via font CSS.
 * Inter is variable (one file, all weights). JetBrains Mono is single-weight
 * for monospace use (the variable woff2 isn't readily distributed; 400 is
 * all we need for code/numbers anyway).
 * -------------------------------------------------------------------------- */
@font-face {
  font-family: "Inter";
  src: url("/static/fonts/InterVariable.woff2") format("woff2-variations");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "JetBrains Mono";
  src: url("/static/fonts/JetBrainsMono-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/* -----------------------------------------------------------------------------
 * Design tokens. All colors / sizes / rhythm reference these so the visual
 * language can be tuned in one place.
 * -------------------------------------------------------------------------- */
:root {
  /* Palette — paper-warm neutrals + one amber accent */
  --color-bg:           #FAFAF7;  /* off-white, paper-like */
  --color-text:         #1A1A1A;  /* near-black */
  --color-text-soft:    #6B6B66;  /* warm gray for secondary copy */
  --color-text-faint:   #9A9A95;  /* very secondary (timestamps, hints) */
  --color-accent:       #C7793F;  /* paper-amber — links, active state, highlights */
  --color-accent-soft:  #E5C5A8;  /* faded amber — subtle backgrounds */
  --color-border:       #E5E2DC;  /* hairlines */
  --color-surface:      #F2EFE9;  /* slightly inset blocks (code, callouts) */
  --color-success:      #5A7A4F;  /* muted forest green — used sparingly */
  --color-warn:         #B5853A;  /* amber-leaning warn */
  --color-error:        #A0463A;  /* terracotta-leaning error */

  /* Type stack — sans for body and headings, mono for numbers/code */
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, "Menlo", monospace;

  /* Sizes — modular scale, restrained */
  --size-1: 0.75rem;   /* 12px — captions, footnotes */
  --size-2: 0.875rem;  /* 14px — meta */
  --size-3: 1rem;      /* 16px — body */
  --size-4: 1.125rem;  /* 18px — emphasized body */
  --size-5: 1.375rem;  /* 22px — h3 */
  --size-6: 1.75rem;   /* 28px — h2 */
  --size-7: 2.25rem;   /* 36px — h1 / display */

  /* Rhythm — 8px base grid */
  --space-0: 0;
  --space-1: 0.25rem;  /* 4px */
  --space-2: 0.5rem;   /* 8px */
  --space-3: 1rem;     /* 16px */
  --space-4: 1.5rem;   /* 24px */
  --space-5: 2rem;     /* 32px */
  --space-6: 3rem;     /* 48px */
  --space-7: 4rem;     /* 64px */

  /* Layout */
  --column-prose: 720px;     /* explainer pages */
  --column-wide: 1280px;     /* A/B page outer */
  --line-body: 1.6;          /* generous reading */
  --line-tight: 1.3;          /* headings */
}

/* -----------------------------------------------------------------------------
 * Reset / baseline
 * -------------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--size-3);
  line-height: var(--line-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

img,
svg {
  max-width: 100%;
  display: block;
}

a {
  color: var(--color-accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 100ms ease;
}

a:hover,
a:focus-visible {
  border-bottom-color: var(--color-accent);
}

/* -----------------------------------------------------------------------------
 * Typography
 * -------------------------------------------------------------------------- */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-body);
  font-weight: 600;
  line-height: var(--line-tight);
  margin: var(--space-5) 0 var(--space-3);
  letter-spacing: -0.01em;
}

h1 { font-size: var(--size-7); margin-top: 0; }
h2 { font-size: var(--size-6); }
h3 { font-size: var(--size-5); }
h4 { font-size: var(--size-4); }

p { margin: var(--space-3) 0; }

p + p {
  margin-top: var(--space-3);
}

small,
.text-small { font-size: var(--size-2); color: var(--color-text-soft); }

.text-soft { color: var(--color-text-soft); }
.text-faint { color: var(--color-text-faint); }
.text-accent { color: var(--color-accent); }

/* Mono — used for tokens, costs, latencies, codes, run-IDs */
code,
.mono {
  font-family: var(--font-mono);
  font-size: 0.92em;
}

code {
  background: var(--color-surface);
  padding: 0.05em 0.3em;
  border-radius: 2px;
}

pre {
  font-family: var(--font-mono);
  font-size: var(--size-2);
  line-height: 1.5;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 2px;
  padding: var(--space-3);
  overflow-x: auto;
  margin: var(--space-4) 0;
}

pre code {
  background: transparent;
  padding: 0;
}

blockquote {
  margin: var(--space-4) 0;
  padding: var(--space-1) var(--space-4);
  border-left: 3px solid var(--color-accent);
  color: var(--color-text-soft);
  font-style: italic;
}

hr {
  border: 0;
  border-top: 1px solid var(--color-border);
  margin: var(--space-5) 0;
}

ul, ol { padding-left: 1.4em; margin: var(--space-3) 0; }
li + li { margin-top: var(--space-2); }

/* -----------------------------------------------------------------------------
 * Layout shells
 * -------------------------------------------------------------------------- */

/* Single-column prose page (Process / Architecture) */
.column {
  max-width: var(--column-prose);
  margin: 0 auto;
  padding: var(--space-7) var(--space-4) var(--space-7);
}

/* Wide page — A/B testing, has a wider grid below the input area */
.wide {
  max-width: var(--column-wide);
  margin: 0 auto;
  padding: var(--space-6) var(--space-4) var(--space-7);
}

/* Comparison-column grid for the A/B page. Uses auto-fit so the grid
 * gracefully scales from 1 column (only local-council selected) to 5
 * columns (all baselines + both gpt-oss MoE modes) without needing a
 * separate class per column count. min(280px) keeps text readable;
 * stacks on narrow screens via the @media rule.
 *
 * Class name kept as `grid-3` for backwards-compatibility with the
 * existing markup; the rule is now generic. */
.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-3);
}

@media (max-width: 900px) {
  .grid-3 { grid-template-columns: 1fr; }
}

/* -----------------------------------------------------------------------------
 * Site header (shared across all pages)
 * -------------------------------------------------------------------------- */
.site-header {
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg);
  position: sticky;
  top: 0;
  z-index: 10;
}

.site-header__inner {
  max-width: var(--column-wide);
  margin: 0 auto;
  padding: var(--space-3) var(--space-4);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-4);
}

.brand {
  font-weight: 600;
  font-size: var(--size-4);
  color: var(--color-text);
  border-bottom: none;
  letter-spacing: -0.01em;
}

.brand:hover,
.brand:focus-visible {
  color: var(--color-accent);
  border-bottom: none;
}

.primary-nav {
  display: flex;
  gap: var(--space-4);
  font-size: var(--size-2);
}

.primary-nav a {
  color: var(--color-text-soft);
  border-bottom: none;
  padding: var(--space-1) 0;
}

.primary-nav a:hover {
  color: var(--color-text);
  border-bottom: none;
}

.primary-nav a.active {
  color: var(--color-text);
  border-bottom: 2px solid var(--color-accent);
}

/* -----------------------------------------------------------------------------
 * Site footer (shared)
 * -------------------------------------------------------------------------- */
.site-footer {
  border-top: 1px solid var(--color-border);
  margin-top: var(--space-7);
  padding: var(--space-5) var(--space-4);
  font-size: var(--size-2);
  color: var(--color-text-faint);
}

.site-footer__inner {
  max-width: var(--column-wide);
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
}

/* -----------------------------------------------------------------------------
 * Case fingerprint — three-segment bar showing which agents were consulted.
 * The distinctive visual element. Used in case lists, run cards, the report.
 *
 * Markup:
 *   <span class="fingerprint" aria-label="...">
 *     <span class="seg" data-seat="healthcare" data-on></span>
 *     <span class="seg" data-seat="legal" data-on></span>
 *     <span class="seg" data-seat="finance"></span>
 *   </span>
 * -------------------------------------------------------------------------- */
.fingerprint {
  display: inline-flex;
  gap: 2px;
  vertical-align: middle;
}

.fingerprint .seg {
  display: inline-block;
  width: 14px;
  height: 8px;
  background: var(--color-border);
  border-radius: 1px;
}

.fingerprint .seg[data-on] {
  background: var(--color-accent);
}

/* -----------------------------------------------------------------------------
 * Buttons
 * -------------------------------------------------------------------------- */
.button {
  display: inline-block;
  font-family: var(--font-body);
  font-size: var(--size-3);
  font-weight: 500;
  background: var(--color-accent);
  color: white;
  border: none;
  border-radius: 2px;
  padding: var(--space-2) var(--space-4);
  cursor: pointer;
  transition: background 100ms ease;
  border-bottom: none;
}

.button:hover,
.button:focus-visible {
  background: #B5692E;  /* one shade darker than --color-accent */
  border-bottom: none;
}

.button[disabled] {
  background: var(--color-text-faint);
  cursor: not-allowed;
}

.button.secondary {
  background: transparent;
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.button.secondary:hover {
  background: var(--color-surface);
}

/* -----------------------------------------------------------------------------
 * Form elements
 * -------------------------------------------------------------------------- */
input[type="text"],
textarea,
select {
  font-family: var(--font-body);
  font-size: var(--size-3);
  background: var(--color-bg);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 2px;
  padding: var(--space-2) var(--space-3);
  width: 100%;
}

textarea {
  min-height: 120px;
  resize: vertical;
  line-height: var(--line-body);
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--color-accent);
}

label {
  display: block;
  font-size: var(--size-2);
  color: var(--color-text-soft);
  margin-bottom: var(--space-1);
  font-weight: 500;
}

/* -----------------------------------------------------------------------------
 * Cards / panels — used for case listings, comparison columns, etc.
 * -------------------------------------------------------------------------- */
.card {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 2px;
  padding: var(--space-4);
}

.card__title {
  font-size: var(--size-4);
  font-weight: 600;
  margin: 0 0 var(--space-2);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* Expand button (⤢) shown to the right of each card title. Clicking it
 * pops the column into a centered modal at ~1100px wide / 90vh tall so
 * long outputs are readable without horizontal cramping. */
.card__expand {
  margin-left: auto;
  background: transparent;
  border: 1px solid transparent;
  color: var(--color-text-soft);
  cursor: pointer;
  font-size: var(--size-3);
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 2px;
  line-height: 1;
  transition: color 100ms ease, background 100ms ease, border-color 100ms ease;
}

.card__expand:hover,
.card__expand:focus-visible {
  color: var(--color-accent);
  background: var(--color-surface);
  border-color: var(--color-border);
  outline: none;
}

.card__meta {
  font-size: var(--size-1);
  color: var(--color-text-faint);
  font-family: var(--font-mono);
}

/* -----------------------------------------------------------------------------
 * Budget bar (shown in header on the A/B page)
 * -------------------------------------------------------------------------- */
.budget {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--size-1);
  color: var(--color-text-soft);
  font-family: var(--font-mono);
}

.budget__track {
  width: 100px;
  height: 4px;
  background: var(--color-border);
  border-radius: 2px;
  overflow: hidden;
}

.budget__fill {
  height: 100%;
  background: var(--color-accent);
  transition: width 200ms ease;
}

/* When budget is at zero, the bar is fully gray and the label says "paused" */
.budget[data-paused] .budget__fill {
  background: var(--color-text-faint);
}

/* -----------------------------------------------------------------------------
 * Status pills (for run state, mode state, etc.)
 * -------------------------------------------------------------------------- */
.pill {
  display: inline-block;
  font-size: var(--size-1);
  font-family: var(--font-mono);
  padding: 0.1em 0.5em;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text-soft);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.pill[data-status="running"] { color: var(--color-accent); border-color: var(--color-accent-soft); }
.pill[data-status="completed"] { color: var(--color-success); border-color: #B5C7AB; }
.pill[data-status="refused"] { color: var(--color-warn); border-color: #D9C4A0; }
.pill[data-status="failed"] { color: var(--color-error); border-color: #D9B5AD; }

/* -----------------------------------------------------------------------------
 * Utility helpers
 * -------------------------------------------------------------------------- */
.stack > * + * { margin-top: var(--space-3); }
.stack-lg > * + * { margin-top: var(--space-5); }

.flex { display: flex; gap: var(--space-3); align-items: center; }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); }

.hidden { display: none !important; }

.text-mono { font-family: var(--font-mono); }
.text-center { text-align: center; }

/* -----------------------------------------------------------------------------
 * Inspector — per-phase transparency panel at the bottom of a result column.
 * Renders the system prompt, the model's reasoning (thinking blocks), and the
 * raw output for each phase of a deliberation. Default collapsed; expand to
 * read the full audit trail.
 * -------------------------------------------------------------------------- */

/* Beautified top-of-column body — used by the Results page in place of a
 * <pre> dump. Inherits the column's font-size scale and renders the limited
 * markdown the beautifier emits (h4-h6 headings, paragraphs, ul/ol, strong,
 * em, code) at a density that matches the surrounding card chrome. Max
 * height + scroll preserves the at-a-glance comparison layout. */
.result-body {
  font-family: var(--font-body);
  font-size: var(--size-2);
  line-height: 1.6;
  max-height: 520px;
  overflow: auto;
  /* Pad the right edge so the scrollbar doesn't crowd content; keep left
   * flush so paragraphs align with the column's edge. */
  padding-right: var(--space-2);
}
.result-body > *:first-child { margin-top: 0; }
.result-body > *:last-child  { margin-bottom: 0; }
.result-body p {
  margin: 0 0 var(--space-3) 0;
}
.result-body .md-heading {
  font-family: var(--font-body);
  font-weight: 600;
  letter-spacing: -0.005em;
  line-height: 1.3;
  color: var(--color-text);
  margin: var(--space-4) 0 var(--space-2) 0;
}
.result-body h4.md-heading {
  font-size: var(--size-3);
  /* The amber accent on h4 makes Tensions / Synthesis section anchors
   * pop visually — these are the structural beats of every response. */
  color: var(--color-accent);
  letter-spacing: 0.01em;
  text-transform: uppercase;
  font-size: var(--size-2);
  border-bottom: 1px solid var(--color-border);
  padding-bottom: var(--space-1);
}
.result-body h5.md-heading { font-size: var(--size-2); }
.result-body h6.md-heading { font-size: var(--size-1); color: var(--color-text-soft); }
.result-body ul,
.result-body ol {
  margin: 0 0 var(--space-3) 0;
  padding-left: var(--space-5);
}
.result-body li {
  margin-bottom: var(--space-2);
}
.result-body li:last-child {
  margin-bottom: 0;
}
.result-body strong {
  color: var(--color-text);
  font-weight: 600;
}
.result-body em {
  color: var(--color-text);
  font-style: italic;
}
.result-body code {
  font-family: var(--font-mono);
  font-size: 0.92em;
  background: var(--color-bg-soft, rgba(0,0,0,0.04));
  padding: 0 0.25em;
  border-radius: 3px;
}

/* --------------------------------------------------------------------------
 * Rubric highlights — interactive evidence locator on the Results page.
 *
 * Clicking a rubric row in the analysis table toggles a highlight color
 * across all matches of that rubric's regex patterns in the three column
 * bodies. Multiple rubrics can be active simultaneously; each gets a
 * distinct color slot via the [data-color-slot] attribute on the <mark>.
 *
 * The chip strip above the rubric tables mirrors the active set with a
 * matching color swatch so the connection is visually obvious.
 * -------------------------------------------------------------------------- */
/* Six soft, paper-amber-compatible highlight colors. The bg variant is
 * the actual mark; the accent variant is the small left-border / swatch
 * used on chips and active rubric rows so the same color reads at multiple
 * scales without losing identity. */
mark.rubric-mark {
  border-radius: 2px;
  padding: 0 0.15em;
  margin: 0 -0.05em;
  color: inherit;
  /* Smooth out the chunky default <mark> look; the goal is "highlighter
   * passed over the text" not "search result box". */
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}
mark.rubric-mark[data-color-slot="amber"] { background-color: rgba(199, 121, 63, 0.28); }
mark.rubric-mark[data-color-slot="sage"]  { background-color: rgba(120, 158, 102, 0.30); }
mark.rubric-mark[data-color-slot="blue"]  { background-color: rgba(110, 152, 196, 0.30); }
mark.rubric-mark[data-color-slot="rose"]  { background-color: rgba(206, 122, 130, 0.30); }
mark.rubric-mark[data-color-slot="lilac"] { background-color: rgba(168, 152, 200, 0.32); }
mark.rubric-mark[data-color-slot="sand"]  { background-color: rgba(192, 174, 124, 0.34); }

/* Rubric row — feels clickable; left-edge color swatch when active.
 * `aria-pressed` flips on the click handler so screen-readers see the
 * toggle state too. */
.rubric-row {
  cursor: pointer;
  transition: background-color 0.12s ease;
  /* 3px-wide left border that becomes the color swatch when active.
   * Always present (transparent at rest) so row width doesn't shift
   * on toggle. */
  border-left: 3px solid transparent;
}
.rubric-row:hover {
  background-color: rgba(0, 0, 0, 0.03);
}
.rubric-row[aria-pressed="true"] {
  background-color: rgba(0, 0, 0, 0.02);
}
.rubric-row[data-color-slot="amber"] { border-left-color: rgba(199, 121, 63, 0.85); }
.rubric-row[data-color-slot="sage"]  { border-left-color: rgba(120, 158, 102, 0.85); }
.rubric-row[data-color-slot="blue"]  { border-left-color: rgba(110, 152, 196, 0.85); }
.rubric-row[data-color-slot="rose"]  { border-left-color: rgba(206, 122, 130, 0.85); }
.rubric-row[data-color-slot="lilac"] { border-left-color: rgba(168, 152, 200, 0.85); }
.rubric-row[data-color-slot="sand"]  { border-left-color: rgba(192, 174, 124, 0.95); }
.rubric-row td:first-child {
  /* Keep the inner padding consistent regardless of border state. */
  padding-left: var(--space-2) !important;
}

/* Rubric controls bar — chip strip + Clear-all button. Hidden when no
 * rubrics are active so it doesn't take up vertical space at rest. */
.rubric-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-3);
  padding: var(--space-2) var(--space-3);
  background: var(--color-bg-soft, rgba(0, 0, 0, 0.025));
  border: 1px solid var(--color-border);
  border-radius: 4px;
  font-size: var(--size-2);
}
.rubric-controls.hidden { display: none; }
.rubric-controls__label {
  color: var(--color-text-soft);
  font-weight: 500;
  margin-right: var(--space-1);
}
.rubric-controls__chips {
  display: inline-flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  flex: 1 1 auto;
}
.rubric-controls__clear {
  /* Reset native button chrome — use the design system's understated
   * pseudo-link look so the bar reads as a row of typographic actions
   * rather than a form. */
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: 3px;
  padding: var(--space-1) var(--space-2);
  font: inherit;
  color: var(--color-text-soft);
  cursor: pointer;
}
.rubric-controls__clear:hover {
  color: var(--color-text);
  border-color: var(--color-text-soft);
}

/* Disposition score pills — live CDS + ALR shown in A/B page column
 * meta line after a run completes. The CDS pill is amber-accented
 * (it's the primary metric); the ALR pill uses the soft border-only
 * style so two pills don't compete visually. Hover for full formula. */
.dispo-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
}
.dispo-pill {
  /* `position: relative` is the anchor for the ::after tooltip;
   * without it the absolutely-positioned tooltip would attach to the
   * card or even the viewport. */
  position: relative;
  display: inline-block;
  padding: 0.1em 0.6em;
  border-radius: 999px;
  font-size: 0.85em;
  font-weight: 500;
  letter-spacing: 0.02em;
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text-soft);
  cursor: help;
  white-space: nowrap;
}
.dispo-pill--cds {
  border-color: var(--color-accent);
  color: var(--color-accent);
  background: rgba(199, 121, 63, 0.06);
}
.dispo-pill:hover {
  border-color: var(--color-text);
  color: var(--color-text);
}

/* Custom tooltip via ::after. Instant appearance (no native title delay)
 * and respects \n via white-space: pre-line so the multi-line formula
 * descriptions render correctly. Positioned above the pill with a small
 * gap; pointer-events: none means hovering the tooltip itself doesn't
 * cause flicker (the tooltip can't intercept the hover). */
.dispo-pill[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-text);
  color: var(--color-bg);
  padding: 0.6em 0.85em;
  border-radius: 4px;
  font-size: 0.85em;
  font-weight: 400;
  letter-spacing: 0;
  line-height: 1.45;
  white-space: pre-line;
  text-align: left;
  width: max-content;
  max-width: 320px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  z-index: 100;
  /* Slight elevation so the tooltip reads as floating above the page. */
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* Small downward-pointing triangle so the tooltip visually anchors
 * to its pill. */
.dispo-pill[data-tooltip]::before {
  content: "";
  position: absolute;
  bottom: calc(100% + 2px);
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--color-text);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  z-index: 100;
}

.dispo-pill[data-tooltip]:hover::after,
.dispo-pill[data-tooltip]:hover::before {
  opacity: 1;
}

/* Cabinet badge — shows up in a column header's meta row for pathway-3
 * swap runs (hybrid cabinets). Reads "Opus · Legal" or similar so a
 * reader scanning the grid sees which phase got the swap without having
 * to open the inspector. Uniform cabinets (all-local or all-Opus) omit
 * the badge entirely. */
.cabinet-badge {
  display: inline-block;
  padding: 0 0.5em;
  border-radius: 3px;
  border: 1px solid var(--color-accent);
  color: var(--color-accent);
  background: rgba(199, 121, 63, 0.08);
  font-size: 0.92em;
  font-weight: 500;
  letter-spacing: 0.02em;
  cursor: help;
}

/* Individual chip in the active-rubric strip. data-color-slot picks the
 * swatch via a thin left border so it matches the highlight in the text. */
.rubric-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 0.15rem 0.5rem 0.15rem 0.4rem;
  background: var(--color-bg, #fff);
  border: 1px solid var(--color-border);
  border-left-width: 3px;
  border-radius: 3px;
  cursor: pointer;
  color: var(--color-text);
  line-height: 1.4;
}
.rubric-chip:hover { border-color: var(--color-text-soft); }
.rubric-chip[data-color-slot="amber"] { border-left-color: rgba(199, 121, 63, 0.85); }
.rubric-chip[data-color-slot="sage"]  { border-left-color: rgba(120, 158, 102, 0.85); }
.rubric-chip[data-color-slot="blue"]  { border-left-color: rgba(110, 152, 196, 0.85); }
.rubric-chip[data-color-slot="rose"]  { border-left-color: rgba(206, 122, 130, 0.85); }
.rubric-chip[data-color-slot="lilac"] { border-left-color: rgba(168, 152, 200, 0.85); }
.rubric-chip[data-color-slot="sand"]  { border-left-color: rgba(192, 174, 124, 0.95); }
.rubric-chip__close {
  color: var(--color-text-soft);
  font-size: 1.05em;
  line-height: 1;
}
.rubric-chip:hover .rubric-chip__close { color: var(--color-text); }

.inspector {
  margin-top: var(--space-4);
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-border);
  font-size: var(--size-2);
}

.inspector > summary {
  cursor: pointer;
  color: var(--color-text-soft);
  font-weight: 500;
  padding: var(--space-1) 0;
  user-select: none;
  list-style: none;
}
.inspector > summary::-webkit-details-marker { display: none; }
.inspector > summary::before {
  content: "▸";
  display: inline-block;
  width: 1.2em;
  color: var(--color-accent);
  transition: transform 100ms ease;
}
.inspector[open] > summary::before {
  transform: rotate(90deg);
}
.inspector > summary:hover { color: var(--color-text); }

.inspector__content {
  margin-top: var(--space-3);
  padding-left: var(--space-3);
  border-left: 1px solid var(--color-border);
}

/* One phase inside the inspector */
.phase {
  margin-top: var(--space-4);
  padding-top: var(--space-3);
  border-top: 1px dashed var(--color-border);
}
.phase:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.phase__title {
  font-size: var(--size-3);
  font-weight: 600;
  margin: 0 0 var(--space-2);
  color: var(--color-text);
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.phase__meta {
  font-family: var(--font-mono);
  font-size: var(--size-1);
  color: var(--color-text-faint);
  font-weight: 400;
  letter-spacing: 0;
}

/* Nested disclosures inside a phase: System prompt / Reasoning / Output */
.phase__detail {
  margin-top: var(--space-2);
}

.phase__detail > summary {
  cursor: pointer;
  font-size: var(--size-1);
  color: var(--color-text-soft);
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: var(--space-1) 0;
  list-style: none;
  user-select: none;
}
.phase__detail > summary::-webkit-details-marker { display: none; }
.phase__detail > summary::before {
  content: "+";
  display: inline-block;
  width: 1em;
  color: var(--color-accent);
  font-weight: 600;
}
.phase__detail[open] > summary::before {
  content: "−";
}
.phase__detail > summary:hover { color: var(--color-text); }

/* Content blocks inside a phase__detail. All mono, all preformatted, but
 * styled so they're visually distinguishable at a glance:
 *  - prompt-block   : the system instruction the model received (muted, inset)
 *  - thinking-block : the model's chain-of-thought (faint amber tint, italic)
 *  - output-block   : the model's user-facing answer (neutral)
 */
.prompt-block,
.thinking-block,
.output-block {
  font-family: var(--font-mono);
  font-size: var(--size-1);
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  margin: var(--space-2) 0 var(--space-3);
  padding: var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: 2px;
  overflow-x: auto;
  max-height: 320px;  /* keeps very long blocks from dominating the column */
  overflow-y: auto;
}

.prompt-block {
  background: var(--color-surface);
  color: var(--color-text-soft);
}

.thinking-block {
  background: #FBF6EE;  /* very faint amber tint */
  border-color: var(--color-accent-soft);
  color: var(--color-text-soft);
  font-style: italic;
}

.output-block {
  background: var(--color-bg);
  color: var(--color-text);
}

/* -----------------------------------------------------------------------------
 * Live stream — teleprompter shown inside a running column. Updates token-by-
 * token via SSE; thinking blocks (delimited by inline <think>...</think>) get
 * the same faint amber italic treatment as the inspector's reasoning blocks
 * so the visual language is consistent between live and post-run views.
 * -------------------------------------------------------------------------- */
.live-stream {
  margin-top: var(--space-3);
  max-height: 360px;
  overflow-y: auto;
  padding: var(--space-3);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 2px;
  font-family: var(--font-body);
  font-size: var(--size-2);
  line-height: 1.55;
}

.live-stream__phase {
  margin-top: var(--space-3);
}
.live-stream__phase:first-child { margin-top: 0; }

.live-stream__phase-label {
  font-family: var(--font-mono);
  font-size: var(--size-1);
  color: var(--color-text-soft);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: var(--space-1);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* Pulsing amber dot beside the actively-generating phase. */
.live-stream__phase-label[data-active]::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-accent);
  animation: live-stream-pulse 1.2s ease-in-out infinite;
}

@keyframes live-stream-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.35; transform: scale(0.7); }
}

.live-stream__text {
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--color-text);
}

/* Inline thinking span — same visual language as the inspector's
 * .thinking-block but inline (display: inline so it flows with the
 * surrounding speech). */
.live-stream__thinking {
  font-style: italic;
  color: var(--color-text-soft);
  background: #FBF6EE;
  padding: 0.05em 0.25em;
  border-radius: 2px;
}

/* Phase event footer — small monospace log of plan-done / pause / dispatch
 * events under the live teleprompter, for users who want to follow the
 * orchestration flow as well as the token stream. */
.live-stream__phase-events {
  margin-top: var(--space-3);
  padding-top: var(--space-2);
  border-top: 1px dashed var(--color-border);
  font-family: var(--font-mono);
  font-size: var(--size-1);
  color: var(--color-text-faint);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.live-stream__phase-event::before {
  content: "·";
  margin-right: 0.4em;
  color: var(--color-accent);
}

/* -----------------------------------------------------------------------------
 * Column expander modal — popped open via the ⤢ button in a card header.
 * Renders a copy of the selected column at full width so long outputs
 * (especially the planner's step-back reasoning + JSON, and the synthesis)
 * are readable. Closed via × button, backdrop click, or ESC.
 *
 * Lives in #overlay-root (sibling of <main>) so its fixed positioning
 * doesn't get clipped by ancestor `overflow` rules.
 * -------------------------------------------------------------------------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
}

.overlay__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(26, 26, 26, 0.45);
  backdrop-filter: blur(2px);
  cursor: pointer;
}

.overlay__panel {
  position: relative;
  width: 100%;
  max-width: 1100px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: var(--space-5) var(--space-5) var(--space-5);
  box-shadow: 0 8px 32px rgba(26, 26, 26, 0.15);
}

/* The inner card inside the overlay panel — strip its own border since the
 * panel already has one, and let it span the full panel width. */
.overlay__panel .card {
  border: none;
  padding: 0;
  background: transparent;
}

/* Live-stream gets more vertical room when expanded — the whole point of
 * popping out a column is to see more at once. */
.overlay__panel .live-stream {
  max-height: 60vh;
}

/* Same for the inspector's per-phase content blocks. */
.overlay__panel .prompt-block,
.overlay__panel .thinking-block,
.overlay__panel .output-block {
  max-height: 50vh;
}

.overlay__close {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: 2px;
  cursor: pointer;
  color: var(--color-text-soft);
  font-family: var(--font-body);
  font-size: var(--size-5);
  line-height: 1;
  width: 2rem;
  height: 2rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 100ms ease, background 100ms ease, border-color 100ms ease;
}

.overlay__close:hover,
.overlay__close:focus-visible {
  color: var(--color-text);
  background: var(--color-surface);
  border-color: var(--color-text-soft);
  outline: none;
}

/* The expand button is meaningless inside the overlay — hide it on the
 * already-expanded view to avoid a self-referential UI. */
.overlay__panel .card__expand {
  display: none;
}

/* Body scroll lock when an overlay is open (toggled by app.js).
 * Prevents the page underneath from scrolling behind the modal. */
body.has-overlay {
  overflow: hidden;
}

/* --------------------------------------------------------------------------
 * Disposition lens — the paper's five behavior families color-coded inside
 * the output columns. Marks reuse the rubric slot hues but add a solid
 * underline so lens marks stay distinguishable from rubric highlights when
 * both are active. Family↔color mapping is FIXED (see results.js), unlike
 * rubric slots which rotate by toggle order.
 * -------------------------------------------------------------------------- */
mark.disp-mark {
  border-radius: 2px;
  padding: 0 0.15em;
  margin: 0 -0.05em;
  color: inherit;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
  border-bottom: 2px solid transparent;
}
mark.disp-mark[data-color-slot="amber"] { background-color: rgba(199, 121, 63, 0.24); border-bottom-color: rgba(199, 121, 63, 0.9); }
mark.disp-mark[data-color-slot="sage"]  { background-color: rgba(120, 158, 102, 0.26); border-bottom-color: rgba(120, 158, 102, 0.9); }
mark.disp-mark[data-color-slot="blue"]  { background-color: rgba(110, 152, 196, 0.26); border-bottom-color: rgba(110, 152, 196, 0.9); }
mark.disp-mark[data-color-slot="rose"]  { background-color: rgba(206, 122, 130, 0.26); border-bottom-color: rgba(206, 122, 130, 0.9); }
mark.disp-mark[data-color-slot="lilac"] { background-color: rgba(168, 152, 200, 0.28); border-bottom-color: rgba(168, 152, 200, 0.9); }

#disposition-lens .disp-lens__head { margin-bottom: var(--space-3); }

.disp-lens__chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.disp-chip {
  position: relative;
  font: inherit;
  font-size: var(--size-2);
  padding: 0.3em 0.85em;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  transition: border-color 0.12s ease, background-color 0.12s ease;
}
.disp-chip:hover { border-color: var(--color-text); }
.disp-chip:focus-visible { outline: 2px solid var(--color-text); outline-offset: 2px; }

.disp-chip--active[data-color-slot="amber"] { background-color: rgba(199, 121, 63, 0.24); border-color: rgba(199, 121, 63, 0.9); }
.disp-chip--active[data-color-slot="sage"]  { background-color: rgba(120, 158, 102, 0.26); border-color: rgba(120, 158, 102, 0.9); }
.disp-chip--active[data-color-slot="blue"]  { background-color: rgba(110, 152, 196, 0.26); border-color: rgba(110, 152, 196, 0.9); }
.disp-chip--active[data-color-slot="rose"]  { background-color: rgba(206, 122, 130, 0.26); border-color: rgba(206, 122, 130, 0.9); }
.disp-chip--active[data-color-slot="lilac"] { background-color: rgba(168, 152, 200, 0.28); border-color: rgba(168, 152, 200, 0.9); }

/* Per-column tally strip injected under each column title when the lens is
 * on. Zero counts stay visible but dimmed — "this column emitted none" is
 * the finding, not noise. */
.disp-tally {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: var(--space-2) 0 var(--space-3);
}
.disp-tally__item {
  position: relative;
  font-size: var(--size-2);
  font-variant-numeric: tabular-nums;
  padding: 0.1em 0.55em;
  border-radius: 3px;
  border-bottom: 2px solid transparent;
}
.disp-tally__item[data-color-slot="amber"] { background-color: rgba(199, 121, 63, 0.18); border-bottom-color: rgba(199, 121, 63, 0.85); }
.disp-tally__item[data-color-slot="sage"]  { background-color: rgba(120, 158, 102, 0.20); border-bottom-color: rgba(120, 158, 102, 0.85); }
.disp-tally__item[data-color-slot="blue"]  { background-color: rgba(110, 152, 196, 0.20); border-bottom-color: rgba(110, 152, 196, 0.85); }
.disp-tally__item[data-color-slot="rose"]  { background-color: rgba(206, 122, 130, 0.20); border-bottom-color: rgba(206, 122, 130, 0.85); }
.disp-tally__item[data-color-slot="lilac"] { background-color: rgba(168, 152, 200, 0.22); border-bottom-color: rgba(168, 152, 200, 0.85); }
.disp-tally__item--zero { opacity: 0.45; }

/* Instant tooltips for lens chips + tally items — same mechanism as the
 * .dispo-pill tooltips above (::after bubble, no native-title delay). */
.disp-chip[data-tooltip]::after,
.disp-tally__item[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-text);
  color: var(--color-bg);
  padding: 0.6em 0.85em;
  border-radius: 4px;
  font-size: 0.85em;
  font-weight: 400;
  line-height: 1.45;
  white-space: pre-line;
  text-align: left;
  width: max-content;
  max-width: 320px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.disp-chip[data-tooltip]:hover::after,
.disp-tally__item[data-tooltip]:hover::after {
  opacity: 1;
}
