/* ─── Design Tokens ────────────────────────────────────────────────────── */
:root {
  --bg:            #eceae4;
  --surface:       #ffffff;
  --surface-2:     #f7f6f3;
  --border:        #c8c5bc;
  --border-soft:   #d9d6ce;
  --text:          #111318;
  --text-2:        #454c59;
  --text-3:        #7a8394;
  --accent:        #1a56db;
  --accent-hover:  #1344b5;
  --accent-soft:   #eff4ff;
  --accent-border: #c7d9fc;
  --green:         #0d6640;
  --green-soft:    #e8f7f0;
  --green-border:  #b6e4ce;
  --amber:         #92400e;
  --amber-soft:    #fef3c7;
  --amber-border:  #fcd34d;
  --red:           #991b1b;
  --red-soft:      #fef2f2;
  --red-border:    #fca5a5;

  /* ── Label Palette (NON-interactive status/metadata) ─────────────────
   * CRITICAL RULE: These colors must NEVER use --accent. Accent color is
   * reserved for interactive elements (buttons, links). Label colors are
   * desaturated so users can tell at a glance: "colored + bordered = button,
   * flat muted = label". */
  --label-neutral-bg:  #eceae4;  /* same as --bg — flat, blends in */
  --label-neutral-fg:  #454c59;  /* --text-2 */
  --label-info-bg:     #eef2f5;  /* NOT accent-soft, just cool grey */
  --label-info-fg:     #475569;  /* slate, not blue */
  --label-success-bg:  #edf5ee;  /* very pale sage */
  --label-success-fg:  #2e6947;  /* muted forest */
  --label-warn-bg:     #f5efe2;  /* warm beige */
  --label-warn-fg:     #7a5a1a;  /* muted amber */
  --label-danger-bg:   #f5e9e9;  /* pale dusty rose */
  --label-danger-fg:   #8a2b2b;  /* muted brick */

  --shadow-sm:     0 1px 4px rgba(0,0,0,.10), 0 1px 2px rgba(0,0,0,.06);
  --shadow:        0 4px 14px rgba(0,0,0,.11), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg:     0 12px 32px rgba(0,0,0,.10), 0 4px 8px rgba(0,0,0,.05);
  --radius-sm:     8px;
  --radius:        12px;
  --radius-lg:     16px;
  --radius-xl:     22px;
  --font:          "Inter", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono:     ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --transition:    0.18s ease;
  --app-header-height: 66px;
  --app-shell-gap: 18px;
  --app-shell-offset: calc(var(--app-header-height) + var(--app-shell-gap));
  --z-app-shell:   140;
  --z-floating-actions: 110;
  --z-app-overlay: 210;
  --z-app-toast:   240;
  --bg-rgb:        236, 234, 228;
}

/* ─── Dark Theme ──────────────────────────────────────────────────────── */
[data-theme="dark"] {
  --bg:            #0f1117;
  --surface:       #1a1d27;
  --surface-2:     #22252f;
  --border:        #2e3140;
  --border-soft:   #262936;
  --text:          #e8eaf0;
  --text-2:        #b0b5c3;
  --text-3:        #6b7280;
  --accent:        #5b8def;
  --accent-hover:  #4a7de0;
  --accent-soft:   #1c2740;
  --accent-border: #2d4570;
  --green:         #34d399;
  --green-soft:    #0d2b1f;
  --green-border:  #1a4a35;
  --amber:         #fbbf24;
  --amber-soft:    #2a2008;
  --amber-border:  #4a3a12;
  --red:           #f87171;
  --red-soft:      #2a1515;
  --red-border:    #4a2020;

  /* Dark-mode label palette — darker muted tones, still no accent */
  --label-neutral-bg:  #2a2d37;
  --label-neutral-fg:  #b0b5c3;
  --label-info-bg:     #2b3140;
  --label-info-fg:     #9aa5b8;
  --label-success-bg:  #1a2e22;
  --label-success-fg:  #6ea88a;
  --label-warn-bg:     #2e2818;
  --label-warn-fg:     #c9a570;
  --label-danger-bg:   #2e1f1f;
  --label-danger-fg:   #d08a8a;

  --shadow-sm:     0 1px 3px rgba(0,0,0,.25);
  --shadow:        0 4px 12px rgba(0,0,0,.3);
  --shadow-lg:     0 12px 32px rgba(0,0,0,.4);
  --bg-rgb:        15, 17, 23;
}

[data-theme="dark"] header {
  background: rgba(26,29,39,0.92);
}

[data-theme="dark"] .risk-card.risk-high { background: var(--red-soft); }
[data-theme="dark"] .risk-card.risk-med  { background: var(--amber-soft); }
[data-theme="dark"] .risk-card.risk-low  { background: var(--green-soft); }

[data-theme="dark"] #citation-panel {
  background: var(--surface);
}

[data-theme="dark"] .card {
  border-color: #3d4155;
  box-shadow: 0 2px 8px rgba(0,0,0,.35);
}

[data-theme="dark"] .brand-lockup-light {
  display: none;
}

[data-theme="dark"] .brand-lockup-dark {
  display: block;
}

/* Dark-mode badge overrides removed — the new label palette uses CSS
 * variables that automatically apply dark theme. No need for per-variant
 * overrides. Colored dots remain the same hue in both themes. */

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:            #0f1117;
    --surface:       #1a1d27;
    --surface-2:     #22252f;
    --border:        #2e3140;
    --border-soft:   #262936;
    --text:          #e8eaf0;
    --text-2:        #b0b5c3;
    --text-3:        #6b7280;
    --accent:        #5b8def;
    --accent-hover:  #4a7de0;
    --accent-soft:   #1c2740;
    --accent-border: #2d4570;
    --green:         #34d399;
    --green-soft:    #0d2b1f;
    --green-border:  #1a4a35;
    --amber:         #fbbf24;
    --amber-soft:    #2a2008;
    --amber-border:  #4a3a12;
    --red:           #f87171;
    --red-soft:      #2a1515;
    --red-border:    #4a2020;
    --shadow-sm:     0 1px 3px rgba(0,0,0,.25);
    --shadow:        0 4px 12px rgba(0,0,0,.3);
    --shadow-lg:     0 12px 32px rgba(0,0,0,.4);
  }
  :root:not([data-theme="light"]) header { background: rgba(26,29,39,0.92); }
  :root:not([data-theme="light"]) .risk-card.risk-high { background: var(--red-soft); }
  :root:not([data-theme="light"]) .risk-card.risk-med  { background: var(--amber-soft); }
  :root:not([data-theme="light"]) .risk-card.risk-low  { background: var(--green-soft); }
  :root:not([data-theme="light"]) #citation-panel { background: var(--surface); }
  :root:not([data-theme="light"]) .card { border-color: #3d4155; box-shadow: 0 2px 8px rgba(0,0,0,.35); }
  :root:not([data-theme="light"]) .brand-lockup-light { display: none; }
  :root:not([data-theme="light"]) .brand-lockup-dark { display: block; }
}

/* ─── Theme Toggle ────────────────────────────────────────────────────── */
.theme-toggle {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 32px; height: 32px;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  color: var(--text-3);
  transition: all var(--transition);
}
.theme-toggle:hover { background: var(--surface-2); color: var(--text); }

/* ─── Reset & Base ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: var(--app-shell-offset);
}

body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { line-height: 1.25; font-weight: 650; letter-spacing: -0.02em; }
h2 { font-size: 1.55rem; }
h3 { font-size: 1.15rem; }
h4 { font-size: 0.97rem; }

p { margin: 0; }
ul, ol { padding-left: 1.25rem; }

/* ─── Header ───────────────────────────────────────────────────────────── */
header {
  position: sticky;
  top: 0;
  z-index: var(--z-app-shell);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 1.5rem;
  height: 52px;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-soft);
  box-shadow: 0 1px 0 rgba(0,0,0,.04);
}

header h1 {
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1;
}

.brand-link {
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.brand-link:hover {
  text-decoration: none;
}

.brand-lockup-set {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
}

.brand-lockup {
  display: block;
  width: auto;
  height: 28px;
}

.brand-lockup-dark {
  display: none;
}

nav {
  display: flex;
  align-items: center;
  gap: 0.2rem;
}

nav a {
  color: var(--text-2);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.3rem 0.65rem;
  border-radius: var(--radius-sm);
  transition: background var(--transition), color var(--transition);
}

nav a:hover {
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
}

nav a.nav-active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
  border: 1px solid var(--accent-border);
}

.nav-muted {
  color: var(--text-3) !important;
  font-size: 0.8rem !important;
}

/* ─── Main Layout ──────────────────────────────────────────────────────── */
main {
  max-width: 760px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
  position: relative;
  z-index: 0;
}

main.wide { max-width: 1060px; }
main.coach-view { max-width: 1500px; }
main.brief-view { max-width: 1020px; }

/* ─── Cards ────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.4rem 1.5rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1rem;
}

.card-flat {
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
}

.card-hero {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-bottom: 3px solid var(--accent);
  border-radius: var(--radius-xl);
  padding: 2rem 2rem 1.75rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.25rem;
}

/* ─── Section Headers ──────────────────────────────────────────────────── */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.section-head h3 { margin: 0; }

.section-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  border-radius: 999px;
  padding: 0.18rem 0.6rem;
  display: inline-block;
  margin-bottom: 0.6rem;
}

/* ─── Forms ────────────────────────────────────────────────────────────── */
label { display: block; }

.field-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 0.4rem;
}

input, textarea, select {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 0.65rem 0.85rem;
  font: inherit;
  font-size: 0.95rem;
  background: var(--surface);
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(26,86,219,0.12);
}

textarea { min-height: 90px; resize: vertical; }

/* ─── Buttons ──────────────────────────────────────────────────────────── */
button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: none;
  border-radius: var(--radius);
  padding: 0.6rem 1rem;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
}

/* ---------- Button System (Linear/Stripe/Vercel-inspired) ----------
 * All buttons share these traits to be obviously interactive:
 *   - min-height 36px (hit target + visual weight)
 *   - font-weight 600 (bolder than any badge/tag)
 *   - shadow elevation on rest (subtle)
 *   - hover: elevates via shadow + translateY(-1px)
 *   - active: presses via translateY(0) + reduced shadow
 * Badges/chips/tags LACK all of these to be clearly non-interactive. */

.btn-primary,
.btn-secondary,
.btn-ghost {
  min-height: 36px;
  font-weight: 600;
  letter-spacing: -0.005em;
  transition: transform 0.12s ease, box-shadow 0.15s ease,
              background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 2px rgba(26,86,219,0.25), 0 2px 8px rgba(26,86,219,0.12);
  width: 100%;
  padding: 0.7rem 1rem;
  font-size: 0.95rem;
  border: none;
}

.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 2px 4px rgba(26,86,219,0.3), 0 6px 14px rgba(26,86,219,0.22);
  transform: translateY(-1px);
}
.btn-primary:active {
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(26,86,219,0.25);
}

.btn-secondary {
  background: var(--surface);
  color: var(--accent);
  border: 1px solid var(--accent-border, var(--accent));
  width: auto;
  padding: 0.5rem 0.9rem;
  font-size: 0.875rem;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.btn-secondary:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-hover);
  box-shadow: 0 2px 6px rgba(26,86,219,0.15);
  transform: translateY(-1px);
}
.btn-secondary:active {
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

/* Ghost: still clearly a button (has border + weight + shadow) but lowest-intent */
.btn-ghost {
  background: var(--surface);
  color: var(--text-2);
  border: 1px solid var(--border);
  width: auto;
  padding: 0.5rem 0.9rem;
  font-size: 0.875rem;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}

.btn-ghost:hover {
  background: var(--surface-2);
  border-color: var(--text-3);
  color: var(--text);
  box-shadow: 0 2px 4px rgba(0,0,0,0.06);
  transform: translateY(-1px);
}
.btn-ghost:active {
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}

.btn-link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  color: var(--accent);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.35rem 0.65rem;
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  text-decoration: none;
  transition: all var(--transition);
  width: auto;
}

.btn-link:hover { background: var(--accent-soft); text-decoration: none; }

button:disabled, .btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* ---------- Tag System (non-interactive status/metadata labels) ----------
 * Use .tag for ALL non-clickable pills: Effort, Impact, WEB, contextual,
 * medium relevance, validate, burden, etc. These MUST look different from
 * buttons to prevent user confusion about what is clickable.
 * Rule: no border, no hover, cursor: default. Pill shape, solid muted fill. */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.6rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  border-radius: 12px;
  border: none;
  cursor: default;
  background: var(--surface-2);
  color: var(--text-2);
  line-height: 1.4;
  user-select: none;
}

.tag-neutral { background: var(--surface-2); color: var(--text-2); }
.tag-info    { background: var(--accent-soft); color: var(--accent); }
.tag-success { background: rgba(22,163,74,0.12); color: #16803f; }
.tag-warning { background: rgba(217,119,6,0.14); color: #b6550b; }
.tag-danger  { background: rgba(220,38,38,0.12); color: #b91c1c; }

[data-theme="dark"] .tag-success { background: rgba(22,163,74,0.2); color: #4ade80; }
[data-theme="dark"] .tag-warning { background: rgba(217,119,6,0.25); color: #fbbf24; }
[data-theme="dark"] .tag-danger  { background: rgba(220,38,38,0.22); color: #f87171; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .tag-success { background: rgba(22,163,74,0.2); color: #4ade80; }
  :root:not([data-theme="light"]) .tag-warning { background: rgba(217,119,6,0.25); color: #fbbf24; }
  :root:not([data-theme="light"]) .tag-danger  { background: rgba(220,38,38,0.22); color: #f87171; }
}

/* ─── Badges & Chips ───────────────────────────────────────────────────── */
/* Badge: NON-interactive status/metadata label.
 * Must look clearly different from buttons:
 *   - SMALLER (under 22px vs button 36px+)
 *   - LIGHTER font-weight (500 vs button 600)
 *   - NO shadow (buttons have shadow elevation)
 *   - NO hover transform (buttons lift on hover)
 *   - NO border by default (buttons always have border or bg)
 *   - cursor: default (not pointer)
 *   - NOT clickable in any way */
.badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.68rem;
  font-weight: 500;
  padding: 0.12rem 0.5rem;
  border-radius: 4px;
  border: none;
  cursor: default;
  user-select: none;
  line-height: 1.5;
  box-shadow: none;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge:hover {
  cursor: default;
  transform: none;
  box-shadow: none;
}

/* Badge variants — all use desaturated label palette, NO accent, NO border. */
.badge-neutral { background: var(--label-neutral-bg); color: var(--label-neutral-fg); }
.badge-blue    { background: var(--label-info-bg); color: var(--label-info-fg); }
.badge-green   { background: var(--label-success-bg); color: var(--label-success-fg); }
.badge-amber   { background: var(--label-warn-bg); color: var(--label-warn-fg); }
.badge-red     { background: var(--label-danger-bg); color: var(--label-danger-fg); }

/* Chip: like badge, NON-interactive. Smaller than buttons, no shadow, no hover. */
.chip {
  display: inline-flex;
  align-items: center;
  font-size: 0.72rem;
  font-weight: 500;
  padding: 0.15rem 0.55rem;
  border-radius: 4px;
  border: none;
  color: var(--text-3);
  background: var(--surface-2);
  cursor: default;
  user-select: none;
  box-shadow: none;
  line-height: 1.5;
}

.chip:hover {
  cursor: default;
  transform: none;
  box-shadow: none;
}

/* Active stage chip — does NOT use accent (reserved for buttons).
 * Instead, uses darker neutral + bolder weight to signal "current stage". */
.chip.active {
  background: var(--label-neutral-bg);
  color: var(--text);
  font-weight: 700;
}

.chip-row { display: flex; flex-wrap: wrap; gap: 0.35rem; }

/* ─── Status Pills ─────────────────────────────────────────────────────── */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.76rem;
  font-weight: 600;
  padding: 0.22rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-2);
  background: var(--surface-2);
  text-transform: capitalize;
}

.status-pill::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-3);
  flex-shrink: 0;
}

.status-running::before  { background: #fff; animation: pulse 1.4s infinite; }
.status-completed::before, .status-partial::before { background: #fff; }
.status-failed_terminal::before, .status-failed_recoverable::before { background: #f59e0b; }

.status-running   { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; animation: pill-glow 1.8s ease-in-out infinite; }
.status-completed, .status-partial { background: var(--green); border-color: var(--green); color: #fff; font-weight: 700; }
.status-failed_terminal, .status-failed_recoverable { background: var(--amber-soft); border-color: var(--amber-border); color: var(--amber); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}
@keyframes pill-glow {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.4); }
  50% { opacity: 0.85; box-shadow: 0 0 12px 4px rgba(37, 99, 235, 0.3); }
}

/* ─── Progress (prominent, readable) ──────────────────────────────────── */
.progress-track {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: var(--border-soft);
  overflow: hidden;
  margin: 0.5rem 0 0.5rem;
  border: 1px solid var(--border);
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent) 0%, #60a5fa 100%);
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 10px rgba(37,99,235,0.35);
}

/* Large, prominent % indicator — hero-size metric, bold accent color */
.progress-pct-large {
  font-size: 2.75rem;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: -0.03em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

/* ─── Research Progress (sticky + flow) ────────────────────────────────── */
/* Pin BELOW the app header so the entire card stays visible while scrolling.
   Was top:0 + z-index:20, which put it under the app-header (z-index: 140 at
   var(--z-app-shell)) so only the bottom stage label peeked out. */
.brief-metrics-bar#progress-card {
  position: sticky;
  top: var(--app-shell-offset);
  z-index: calc(var(--z-app-shell) - 1);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  backdrop-filter: blur(6px);
}

[data-theme="dark"] .brief-metrics-bar#progress-card {
  background: var(--surface);
  box-shadow: 0 2px 12px rgba(0,0,0,0.25);
}

/* Flow-style stage display: stages connected by arrows, NOT clickable-looking */
.stage-flow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0;
  margin: 0.5rem 0 0.25rem;
  font-size: 0.78rem;
  line-height: 1.4;
}

.stage-flow-item {
  padding: 0.2rem 0.5rem;
  color: var(--text-3);
  font-weight: 500;
  white-space: nowrap;
  transition: all 0.25s ease;
  cursor: default;
  user-select: none;
}

.stage-flow-item.completed {
  color: var(--green);
}
.stage-flow-item.active {
  color: var(--accent);
  font-weight: 700;
  background: var(--accent-soft);
  border-radius: 4px;
}

.stage-flow-sep {
  color: var(--text-3);
  margin: 0 0.15rem;
  font-weight: 400;
  user-select: none;
}

/* Keep legacy .stage-chips class for backward compat but restyle as flow */
.stage-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0;
  margin-bottom: 0.5rem;
  font-size: 0.78rem;
}

/* ─── Content Blocks ───────────────────────────────────────────────────── */
.clean-list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.clean-list li {
  padding: 0.75rem 0.9rem;
  border-left: 3px solid var(--accent-border);
  background: var(--surface-2);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.93rem;
  line-height: 1.55;
}

.mini-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
}

.stack-cards {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.snapshot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr));
  gap: 0.7rem;
}

.snapshot-cell {
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 0.85rem 0.95rem;
  min-height: 112px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.snapshot-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-3);
}

.snapshot-value {
  font-size: 0.95rem;
  font-weight: 650;
  color: var(--text);
  line-height: 1.45;
  margin-top: 0.35rem;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.snapshot-meta {
  margin-top: 0.55rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  min-width: 0;
}

.snapshot-note-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.55rem;
  margin-top: 0.7rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.snapshot-note {
  color: var(--text-3);
  font-size: 0.78rem;
  line-height: 1.45;
  margin: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.signal-stack {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.signal-card,
.contradiction-card,
.unknown-card {
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  box-shadow: var(--shadow-sm);
}

.signal-head,
.contradiction-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.8rem;
}

.signal-title,
.contradiction-title {
  font-size: 0.95rem;
  font-weight: 650;
  color: var(--text);
}

.signal-summary {
  margin-top: 0.32rem;
  color: var(--text-2);
  font-size: 0.84rem;
  line-height: 1.5;
}

.signal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.7rem;
}

.signal-support {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.7rem;
}

.signal-detail {
  margin-top: 0.55rem;
  color: var(--text-2);
  font-size: 0.83rem;
  line-height: 1.5;
}

.contradiction-meta {
  margin-top: 0.45rem;
  color: var(--text-3);
  font-size: 0.82rem;
  line-height: 1.45;
}

.unknown-card {
  border-left: 3px solid #2563eb;
}

.score-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.45rem;
}

/* Score chips — status labels, NOT buttons.
 * Flat, no border, smaller font, cursor:default. Uses label palette only. */
.score-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.15rem 0.55rem;
  border-radius: 4px;
  border: none;
  background: var(--label-neutral-bg);
  color: var(--label-neutral-fg);
  font-size: 0.7rem;
  font-weight: 500;
  white-space: normal;
  line-height: 1.5;
  max-width: 100%;
  overflow-wrap: anywhere;
  text-align: left;
  cursor: default;
  user-select: none;
  box-shadow: none;
}

.score-chip:hover { cursor: default; transform: none; box-shadow: none; }

.score-good {
  background: var(--label-success-bg);
  color: var(--label-success-fg);
}

.score-mid {
  background: var(--label-warn-bg);
  color: var(--label-warn-fg);
}

.score-risk {
  background: var(--label-danger-bg);
  color: var(--label-danger-fg);
}

/* score-neutral was previously using --accent — the #1 cause of user
 * confusion. Now uses the true neutral label palette. */
.score-neutral {
  background: var(--label-neutral-bg);
  color: var(--label-neutral-fg);
}

/* Priority dot system — semantic color signal for "Must do now" etc.
 * Use as: <span class="tier-dot tier-dot-urgent"></span> Must do now
 * The dot carries the semantic weight; the text stays neutral grey. */
.tier-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--label-neutral-fg);
  flex-shrink: 0;
  margin-right: 0.4rem;
  vertical-align: middle;
}
.tier-dot-urgent  { background: #d97706; }  /* amber — "must do now" */
.tier-dot-soon    { background: #64748b; }  /* slate — "next step" */
.tier-dot-optional { background: #a8a29e; }  /* stone — "optional" */

[data-theme="dark"] .tier-dot-urgent   { background: #fbbf24; }
[data-theme="dark"] .tier-dot-soon     { background: #94a3b8; }
[data-theme="dark"] .tier-dot-optional { background: #78716c; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .tier-dot-urgent   { background: #fbbf24; }
  :root:not([data-theme="light"]) .tier-dot-soon     { background: #94a3b8; }
  :root:not([data-theme="light"]) .tier-dot-optional { background: #78716c; }
}

.fact-row .score-chip-row {
  margin-top: 0.55rem;
}

/* ─── Action Table ─────────────────────────────────────────────────────── */
.action-row {
  display: grid;
  grid-template-columns: 2rem 1fr auto;
  gap: 0.75rem;
  align-items: start;
  padding: 0.85rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.action-rank {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
  padding-top: 1px;
}

.action-meta {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-top: 0.35rem;
}

.action-note {
  margin-top: 0.35rem;
  color: var(--text-3);
  font-size: 0.78rem;
  line-height: 1.5;
}

.action-tier {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-bottom: 0.9rem;
}

.action-tier-label {
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-3);
}

/* ─── Competitor Grid ──────────────────────────────────────────────────── */
.competitor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.7rem;
}

.competitor-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
}

/* ─── Risk Cards ───────────────────────────────────────────────────────── */
.risk-card {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 0.8rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
}

.risk-card.risk-high {
  border-left: 3px solid var(--red);
  background: var(--red-soft);
}

.risk-card.risk-med {
  border-left: 3px solid var(--amber);
  background: var(--amber-soft);
}

.risk-card.risk-low {
  border-left: 3px solid var(--green);
  background: var(--green-soft);
}

.section-show-more {
  width: auto;
  align-self: flex-start;
  padding: 0.42rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  background: var(--surface);
  color: var(--text-2);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color var(--transition), color var(--transition), background var(--transition);
}

.section-show-more:hover {
  border-color: var(--accent-border);
  color: var(--accent);
  background: var(--accent-soft);
}

/* ─── Citations ────────────────────────────────────────────────────────── */
.cite {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.68rem;
  font-weight: 700;
  width: 18px; height: 18px;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--accent-border);
  cursor: help;
  vertical-align: super;
  line-height: 1;
  text-decoration: none;
  margin-left: 1px;
  transition: all var(--transition);
}

.cite:hover {
  background: var(--accent);
  color: #fff;
  text-decoration: none;
}

/* ─── Evidence List ────────────────────────────────────────────────────── */
.evidence-list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.evidence-list li {
  font-size: 0.875rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.evidence-list a { font-weight: 500; }

/* ─── Inline Forms (open questions) ───────────────────────────────────── */
.inline-form {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

.inline-form label { font-size: 0.9rem; font-weight: 500; color: var(--text-2); }

/* ─── Assist Row ───────────────────────────────────────────────────────── */
.assist-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  margin: 0.5rem 0 0.9rem;
}

/* ─── Brief Hero (landing) ─────────────────────────────────────────────── */
.search-hero {
  text-align: center;
  padding: 1.5rem 1rem 1rem;
}

.search-hero h2 {
  font-size: 1.75rem;
  font-weight: 750;
  letter-spacing: -0.04em;
  color: var(--text);
  margin-bottom: 0.3rem;
}

.search-hero p {
  color: var(--text-3);
  font-size: 0.925rem;
  max-width: 480px;
  margin: 0 auto 1rem;
}

.search-box {
  position: relative;
  max-width: 640px;
  margin: 0 auto;
}

.search-box textarea {
  min-height: 80px;
  font-size: 1rem;
  padding: 1rem 1.1rem;
  border-radius: var(--radius-lg);
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow);
  resize: none;
  line-height: 1.5;
}

.search-box textarea:focus {
  box-shadow: 0 0 0 3px rgba(26,86,219,0.12), var(--shadow);
}

.search-box-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.6rem;
  gap: 0.75rem;
}

.search-submit {
  padding: 0.6rem 1.4rem;
  font-size: 0.9rem;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  border: none;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: 0 1px 3px rgba(26,86,219,0.3);
  width: auto;
  white-space: nowrap;
}

.search-submit:hover { background: var(--accent-hover); }
.search-submit:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; pointer-events: none; }

/* ─── Brief List (recent runs) ─────────────────────────────────────────── */
.brief-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.brief-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.brief-list-item:hover {
  border-color: #cbc8c0;
  box-shadow: var(--shadow-sm);
}

.brief-list-prompt {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.brief-list-meta {
  font-size: 0.8rem;
  color: var(--text-3);
  margin-top: 0.15rem;
}

.brief-list-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

/* ─── Row Actions ──────────────────────────────────────────────────────── */
.row-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

/* ─── Warning / Recovery ───────────────────────────────────────────────── */
.warning-card {
  border-color: var(--amber-border);
  background: linear-gradient(145deg, var(--amber-soft), var(--surface));
}

/* ─── Table ────────────────────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { padding: 0.5rem 0.65rem; text-align: left; border: 1px solid var(--border); }
th { background: var(--surface-2); font-weight: 600; font-size: 0.82rem; }

/* ─── Misc ─────────────────────────────────────────────────────────────── */
.muted { color: var(--text-3); font-size: 0.875rem; }
.mono { font-family: var(--font-mono); font-size: 0.82rem; color: var(--text-2); }
.label-strong { font-weight: 650; }
.subtle-link { color: var(--text-3) !important; font-size: 0.875rem; }

.divider {
  height: 1px;
  background: var(--border-soft);
  margin: 1.25rem 0;
}

pre {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-2);
  background: var(--surface-2);
  padding: 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

details summary {
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-2);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  user-select: none;
  padding: 0.1rem 0;
}

details summary::-webkit-details-marker { display: none; }

details summary::before {
  content: "";
  width: 0;
  height: 0;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-left: 6px solid var(--text-3);
  transition: transform var(--transition);
}

details[open] summary::before { transform: rotate(90deg); }

details > *:not(summary) { margin-top: 0.85rem; }

/* Hero on brief results */
.brief-result-hero {
  padding: 1.5rem 1.75rem;
}

.brief-result-hero h2 {
  font-size: 1.35rem;
  color: var(--text);
  margin-bottom: 0.3rem;
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
}

.brief-brand-subtitle {
  color: var(--text-3);
  font-size: 0.82rem;
  line-height: 1.45;
  margin: 0.4rem 0 0.55rem;
  max-width: 34rem;
}

.brief-result-hero .idea-text {
  color: var(--text-3);
  font-size: 0.9rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Research paper header */
.brief-paper-header {
  text-align: center;
  padding: 1.5rem 0 1rem;
}
.brief-paper-type {
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1.2rem;
}
.brief-paper-title {
  font-size: 1.55rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--text-1);
  margin-bottom: 0.5rem;
}
.brief-paper-subtitle {
  font-size: 0.92rem;
  color: var(--text-3);
  margin-bottom: 0.5rem;
}
.brief-paper-date {
  font-size: 0.82rem;
  color: var(--text-3);
  margin-bottom: 1rem;
}
.brief-paper-brand {
  font-size: 0.72rem;
  color: var(--text-3);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-soft);
}

/* Research paper body text justification */
.brief-main .card p,
.brief-main .clean-list li,
.brief-main .signal-summary,
.brief-main .signal-detail,
.brief-main .stack-card-body {
  text-align: justify;
  text-justify: inter-word;
}

/* Floating actions */
.floating-actions {
  display: none;
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  flex-direction: column;
  gap: 0.5rem;
  z-index: var(--z-floating-actions);
}

.copy-btn {
  position: static;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 0.6rem 1.1rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  width: auto;
  transition: all var(--transition);
}

.copy-btn:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: 0 16px 40px rgba(0,0,0,.15); }
.copy-btn:active { transform: translateY(0); }

/* ─── Responsive ───────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  header { padding: 0 1rem; }
  .brand-lockup-set { min-height: 26px; }
  .brand-lockup { height: 26px; }
  main { padding: 1.25rem 0.85rem 3rem; }
  .search-hero { padding: 1.75rem 0 1.5rem; }
  .search-hero h2 { font-size: 1.5rem; }
  .card { padding: 1rem 1.1rem; }
  .card-hero { padding: 1.25rem 1.25rem 1.1rem; }
  .assist-row { flex-direction: column; }
  .row-actions { flex-direction: column; align-items: flex-start; }
  .brief-list-item { flex-wrap: wrap; }
  .action-row { grid-template-columns: 2rem 1fr; }
  .action-row .action-meta { grid-column: 1 / -1; }
  .signal-head,
  .contradiction-head { flex-direction: column; }
  .snapshot-grid { grid-template-columns: 1fr; }
  .copy-btn { bottom: 1rem; right: 1rem; }
  .competitor-grid { grid-template-columns: 1fr; }
}

/* ─── Finding Actions (dig deeper / save) ──────────────────────────────── */
/* ALWAYS visible — was opacity:0 hover-only, invisible on touch devices
 * and users didn't know dig-deeper existed. */
.finding-actions {
  opacity: 1;
  transition: opacity var(--transition);
}

/* On hover: no visibility change (already visible), but allow subtle emphasis */
li:hover .finding-actions,
.action-row:hover .finding-actions,
.competitor-card:hover .finding-actions,
.risk-card:hover .finding-actions {
  opacity: 1;
}

/* ─── Topic suggestion buttons ─────────────────────────────────────────── */
.topic-btn:hover {
  border-color: var(--accent-border) !important;
  background: var(--accent-soft) !important;
  color: var(--accent) !important;
}

/* ─── Legacy shims (keep old class names working) ──────────────────────── */
.premium-shell { max-width: 760px; margin-left: auto; margin-right: auto; }
.brief-hero { }
.brief-card { }
.kicker { }
.section-head { }
.progress-wrap { }
.progress-bar { }
.brief-details { margin: 0.55rem 0 0.9rem; }
.brief-list-item p { margin: 0; }
.warning-text { color: var(--amber); font-weight: 600; }
.success-text { color: var(--green); font-weight: 600; }
.inline-check { display: flex; align-items: center; gap: 0.5rem; }
.inline-check input { width: auto; margin-top: 0; }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
.compact-grid { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.hero { border-left: 4px solid var(--accent); background: linear-gradient(180deg, var(--accent-soft), var(--surface) 60%); }

/* ─── Named Citations ──────────────────────────────────────────────────── */
.cite-named {
  display: inline-block;
  vertical-align: middle;
  font-size: 0.68rem;
  padding: 0.15rem 0.4rem;
  border-radius: 7px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  margin-left: 0.2rem;
  min-width: 42px;
  text-align: center;
  letter-spacing: 0.02em;
  transition: background var(--transition);
}
.cite-named:hover { background: var(--accent-border); }

/* ─── Source Type Badges ───────────────────────────────────────────────── */
/* Tiny metadata labels (WEB, YT, etc.) — desaturated to avoid competing
 * with buttons. Each variant uses a small colored dot to signal type, but
 * keeps a neutral fill/text so they clearly read as labels, not buttons. */
.badge-src {
  font-size: 0.65rem;
  padding: 0.08rem 0.4rem;
  border-radius: 3px;
  border: none;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-right: 0.3rem;
  vertical-align: middle;
  background: var(--label-neutral-bg);
  color: var(--label-neutral-fg);
  cursor: default;
  user-select: none;
  line-height: 1.5;
}
.badge-src:hover { cursor: default; transform: none; box-shadow: none; }

/* Source-type variants: use a subtle colored dot to signal type.
 * Background + text stay in the neutral label palette. */
.badge-src::before {
  content: "";
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  margin-right: 0.35rem;
  vertical-align: middle;
  background: var(--label-neutral-fg);
}
.badge-web::before      { background: #3b82f6; }  /* blue dot */
.badge-yt::before       { background: #ef4444; }  /* red dot */
.badge-article::before  { background: #22c55e; }  /* green dot */
.badge-academic::before { background: #8b5cf6; }  /* purple dot */
.badge-hn::before       { background: #f97316; }  /* orange dot */
.badge-reddit::before   { background: #ef4444; }  /* red dot */

/* Remove accent from these variants — dot carries the meaning now */
.badge-web { background: var(--label-neutral-bg); color: var(--label-neutral-fg); }
.badge-yt { background: var(--label-neutral-bg); color: var(--label-neutral-fg); }
.badge-article { background: var(--label-neutral-bg); color: var(--label-neutral-fg); }
.badge-academic { background: var(--label-neutral-bg); color: var(--label-neutral-fg); }
.badge-hn { background: var(--label-neutral-bg); color: var(--label-neutral-fg); }
.badge-reddit { background: var(--label-neutral-bg); color: var(--label-neutral-fg); }

/* ─── TL;DR Card ───────────────────────────────────────────────────────── */
.card-tldr {
  border-left: 4px solid var(--accent);
  background: linear-gradient(135deg, var(--accent-soft) 0%, var(--surface) 100%);
}

/* ─── Research Trajectory ──────────────────────────────────────────────── */
.trajectory-step {
  display: flex;
  gap: 0.75rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border-soft);
}
.trajectory-step:last-child { border-bottom: none; }
.trajectory-clickable:hover { background: var(--accent-soft); border-radius: var(--radius); }
.trajectory-toggle:hover { color: var(--accent) !important; }
.trajectory-num {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.trajectory-body { flex: 1; min-width: 0; }
.trajectory-stage {
  font-weight: 600;
  font-size: 0.88rem;
  text-transform: capitalize;
  color: var(--text-2);
}
.trajectory-panel {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: var(--surface-2);
  padding: 0.85rem 0.9rem;
}

/* ─── API Explainer Cards ──────────────────────────────────────────────── */
.api-card {
  padding: 0.75rem 0.85rem;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
}
.api-card-label {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text);
  margin-bottom: 0.25rem;
}

.back-link {
  display: inline-block;
  font-size: 0.85rem;
  color: var(--text-3);
  text-decoration: none;
  margin-bottom: 0.75rem;
  transition: color 0.15s;
}
.back-link:hover { color: var(--accent); }

/* ─── Brief 2-Column Layout ───────────────────────────────────────────── */
.brief-layout {
  display: block;
}
.brief-main { min-width: 0; }
.brief-sidebar {
  display: none;
}
.brief-sidebar .trajectory-step {
  border-bottom: none;
  padding: 0 0 0.5rem 0;
  position: relative;
}
.brief-sidebar .trajectory-step::before {
  content: "";
  position: absolute;
  left: 12px;
  top: 26px;
  bottom: -2px;
  width: 2px;
  background: var(--border-soft);
}
.brief-sidebar .trajectory-step:last-child::before { display: none; }
.brief-sidebar .trajectory-num {
  width: 24px; height: 24px;
  font-size: 0.7rem;
  z-index: 1;
}
.brief-sidebar .trajectory-stage {
  font-size: 0.8rem;
}
.brief-sidebar .trajectory-body .muted {
  font-size: 0.72rem !important;
}
@media (max-width: 900px) {
  .brief-sidebar {
    position: static;
    max-height: none;
    order: -1;
  }
}

/* ─── Open Question Suggestion Chips ──────────────────────────────────── */
.oq-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.3rem;
}
.oq-chip {
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--accent-border);
  border-radius: 999px;
  padding: 0.25rem 0.7rem;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  width: auto;
}
.oq-chip:hover {
  background: var(--accent);
  color: #fff;
}

/* ─── Fact Numbers ────────────────────────────────────────────────────── */
.fact-num {
  color: var(--accent);
  font-weight: 700;
  font-size: 0.9rem;
  margin-right: 0.15rem;
}
.fact-sources {
  display: inline-flex;
  gap: 0.2rem;
  vertical-align: middle;
  margin-right: 0.3rem;
}
/* ─── Branch Tree ──────────────────────────────────────────────────────── */
.ecosystem-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(260px, 1fr);
  gap: 0.95rem;
  margin-top: 0.65rem;
}
.ecosystem-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-top: 0.75rem;
}
.ecosystem-graph-wrap {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: linear-gradient(160deg, var(--surface-2) 0%, var(--surface) 100%);
  padding: 0.9rem 0.95rem;
}
.ecosystem-graph {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.ecosystem-node {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.3rem 0;
  line-height: 1.3;
}
.ecosystem-connector {
  color: var(--text-3);
  font-family: var(--font-mono);
  min-width: 1.1rem;
  flex-shrink: 0;
  margin-top: 0.1rem;
}
.ecosystem-square {
  width: 11px;
  height: 11px;
  border-radius: 3px;
  background: var(--border);
  border: 2px solid var(--text-3);
  flex-shrink: 0;
  margin-top: 0.2rem;
}
.ecosystem-square.current {
  background: var(--accent);
  border-color: var(--accent-hover);
  box-shadow: 0 0 0 2px var(--accent-soft);
}
.ecosystem-square.status-completed,
.ecosystem-square.status-partial {
  background: var(--green);
  border-color: var(--green);
}
.ecosystem-square.status-running {
  background: var(--accent);
  border-color: var(--accent-hover);
}
.ecosystem-square.status-failed_recoverable,
.ecosystem-square.status-failed_terminal {
  background: var(--amber);
  border-color: var(--amber);
}
.ecosystem-topic-wrap {
  min-width: 0;
  flex: 1 1 auto;
}
.ecosystem-topic {
  font-size: 0.85rem;
  color: var(--text-2);
  text-decoration: none;
  font-weight: 600;
}
.ecosystem-topic:hover {
  color: var(--accent);
  text-decoration: underline;
}
.ecosystem-topic.current {
  color: var(--accent);
  font-weight: 700;
}
.ecosystem-meta-row {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-top: 0.15rem;
}
.ecosystem-meta {
  color: var(--text-3);
  font-size: 0.74rem;
}
.ecosystem-rel {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border: 1px solid var(--border-soft);
  color: var(--text-3);
  padding: 0.04rem 0.35rem;
  border-radius: 999px;
  margin-left: 0.35rem;
}
.ecosystem-rel.current {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--accent);
}
.ecosystem-detail {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: var(--surface-2);
  padding: 0.85rem 0.9rem;
}
.ecosystem-empty {
  color: var(--text-3);
  font-size: 0.82rem;
  padding: 0.35rem 0.25rem;
}
.branch-compare-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.8rem;
  margin-top: 0.9rem;
}
.branch-compare-summary {
  grid-column: 1 / -1;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 0.95rem 1rem;
}
.branch-compare-summary-head {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  flex-wrap: wrap;
}
.branch-compare-summary-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
}
.branch-compare-summary-copy,
.branch-compare-summary-note {
  margin-top: 0.25rem;
  color: var(--text-3);
  font-size: 0.8rem;
  line-height: 1.5;
}
.branch-compare-card {
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.95rem 1rem;
  box-shadow: var(--shadow-sm);
}
.branch-compare-head {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.branch-compare-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.35;
}
.branch-compare-subtitle {
  margin-top: 0.2rem;
  color: var(--text-3);
  font-size: 0.8rem;
  line-height: 1.45;
}
.branch-compare-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 0.65rem;
  color: var(--text-3);
  font-size: 0.76rem;
}
.branch-compare-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem;
  margin-top: 0.75rem;
}
.branch-compare-metric {
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.branch-compare-metric span {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-3);
}
.branch-compare-metric strong {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.86rem;
  color: var(--text);
}
.branch-compare-section {
  margin-top: 0.75rem;
}

.branch-compare-details {
  margin-top: 0.85rem;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.45);
}

.branch-compare-details summary {
  font-size: 0.8rem;
}
.branch-compare-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-3);
  margin-bottom: 0.28rem;
}
.branch-compare-section ul {
  margin: 0;
  padding-left: 1rem;
  color: var(--text-2);
  font-size: 0.8rem;
  line-height: 1.5;
}
.branch-compare-action {
  color: var(--text);
  font-size: 0.83rem;
  line-height: 1.5;
}
.branch-compare-copy {
  margin-top: 0.22rem;
  color: var(--text-3);
  font-size: 0.76rem;
  line-height: 1.45;
}
.ref-warning {
  margin-top: 0.7rem;
  padding: 0.55rem 0.7rem;
  background: #fff7ed;
  border: 1px solid #fdba74;
  border-radius: var(--radius-sm);
  color: #9a3412;
  font-size: 0.78rem;
  font-weight: 600;
}
@media (max-width: 900px) {
  .ecosystem-layout {
    grid-template-columns: 1fr;
  }
  .ecosystem-toolbar {
    align-items: flex-start;
  }
  .branch-compare-metrics {
    grid-template-columns: 1fr;
  }
}

a.src-tile-link {
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
}
a.src-tile-link:hover {
  transform: scale(1.08);
  box-shadow: 0 1px 4px rgba(0,0,0,.12);
}
.fact-sources .badge-src {
  font-size: 0.6rem;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}

/* ─── Library Page ────────────────────────────────────────────────────── */
.library-items {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.library-item {
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  transition: border-color var(--transition);
}
.library-item:hover {
  border-color: var(--border);
}
.library-item-title {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text);
  line-height: 1.35;
  margin-bottom: 0.2rem;
}
.library-item-snippet {
  font-size: 0.8rem;
  color: var(--text-3);
  line-height: 1.4;
  margin-bottom: 0.3rem;
}
.library-item-meta {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.75rem;
  color: var(--text-3);
}
.library-item-meta a {
  color: var(--accent);
  text-decoration: none;
}
.library-item-meta a:hover {
  text-decoration: underline;
}
.section-badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
  margin-top: 0.15rem;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--accent-border);
}
.section-whats_true, .section-fact {
  background: var(--green-soft);
  color: var(--green);
  border-color: var(--green-border);
}
.section-action, .section-actions {
  background: var(--amber-soft);
  color: var(--amber);
  border-color: var(--amber-border);
}
.section-risk, .section-risks {
  background: var(--red-soft);
  color: var(--red);
  border-color: var(--red-border);
}

/* Production polish overrides */
.app-header {
  position: sticky;
  top: 0;
  height: auto;
  min-height: 66px;
  padding: 0;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 10px 28px rgba(17, 19, 24, 0.06);
  z-index: var(--z-app-shell);
  isolation: isolate;
}

.app-header-bar {
  max-width: 1180px;
  margin: 0 auto;
  padding: 1.3rem 1.65rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
}

.app-brand-cluster {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
}

.app-nav {
  gap: 0.3rem;
}

.brand-link {
  padding: 0.2rem 0.1rem;
  display: inline-flex;
  align-items: center;
  gap: 1rem;
  color: var(--text);
  min-width: 0;
}

.brand-symbol-set {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  height: auto;
  flex: 0 0 auto;
  border-radius: 12px;
  padding: 6px 12px;
  background: linear-gradient(180deg, rgba(255,255,255,0.88), rgba(247,244,238,0.92));
  border: 1px solid var(--border-soft);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.72);
  overflow: hidden;
}

.brand-symbol {
  height: 52px;
  width: auto;
  max-width: none;
  display: block;
  object-fit: contain;
}

.brand-wordmark {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  min-width: 0;
  gap: 0.15rem;
}

.brand-product-name {
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.1;
  color: var(--text);
  letter-spacing: -0.02em;
}

.brand-qu  { color: #2563eb; }
.brand-re  { color: #16a34a; }
.brand-dec { color: #ea580c; }

[data-theme="dark"] .brand-qu  { color: #5b8def; }
[data-theme="dark"] .brand-re  { color: #34d399; }
[data-theme="dark"] .brand-dec { color: #fbbf24; }

.hero-slogan {
  font-size: 0.85rem;
  color: var(--text-3);
  text-align: center;
  margin: 0 auto 0.65rem;
  max-width: 480px;
  line-height: 1.5;
}

.brand-artifact-name {
  font-size: 0.82rem;
  line-height: 1.2;
  color: var(--text-3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

main.brief-view {
  max-width: 1180px;
}

.brief-result-hero {
  padding: 1.95rem 2.15rem;
}

.brief-result-hero .section-label {
  margin-bottom: 0.75rem;
}

.brief-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 1.2rem;
  align-items: start;
}

.brief-main {
  min-width: 0;
  order: 1;
}

.brief-sidebar {
  display: flex;
  flex-direction: column;
  gap: 0.95rem;
  min-width: 0;
  order: 2;
  position: sticky;
  top: var(--app-shell-offset);
  z-index: 1;
}

.brief-summary-rail-card {
  padding: 1.2rem;
  background: var(--surface);
  border: 2px solid var(--accent);
  border-radius: 14px;
  max-width: 320px;
  box-shadow: var(--shadow);
}

.brief-summary-rail-card .section-label {
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.summary-rail-head h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.3rem;
}

.summary-rail-head p {
  font-size: 0.82rem;
  line-height: 1.5;
}

.summary-rail-status {
  margin-top: 0.75rem;
  font-size: 0.82rem;
  line-height: 1.55;
}

.summary-rail-grid {
  display: grid;
  gap: 0.55rem;
  margin-top: 0.85rem;
}

.summary-rail-item {
  padding: 0.72rem 0.78rem;
  border-radius: 12px;
  border: 1px solid var(--border-soft);
  background: var(--surface-2);
}

.summary-rail-item dt {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 0.2rem;
}

.summary-rail-item dd {
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text);
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: normal;
  max-height: 4.2em;
  overflow: hidden;
  cursor: pointer;
  transition: max-height 0.25s ease;
}
.summary-rail-item dd.expanded { max-height: none; }

.brief-action-rail-card {
  padding: 0.95rem 1rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  max-width: 320px;
  box-shadow: var(--shadow);
}

.brief-action-rail-head h3 {
  font-size: 0.98rem;
  margin-bottom: 0.24rem;
}

.brief-action-rail-head p {
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--text-2);
}

.brief-action-rail-actions {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-top: 0.85rem;
}

.brief-action-rail-actions .btn-secondary:disabled,
.brief-action-rail-actions .btn-ghost:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}
.brief-action-rail-actions .btn-secondary,
.brief-action-rail-actions .btn-ghost {
  width: 100%;
  justify-content: center;
}

.summary-rail-nav {
  display: grid;
  gap: 0.3rem;
  margin-top: 0.9rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border-soft);
}

.summary-rail-nav a {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.42rem 0.55rem;
  border-radius: 10px;
  color: var(--text-2);
  background: transparent;
  font-size: 0.84rem;
  text-decoration: none;
}

.summary-rail-nav a:hover {
  background: var(--surface-2);
  text-decoration: none;
}

#decision-coach-surface,
#brief-framing-panel,
#brief-decision-card,
#brief-clarification-panel,
.brief-result-hero,
#decision-snapshot-card,
#signals-card,
#contradictions-card,
#unknowns-card,
#whats-true-card,
#actions-card,
#ecosystem-card,
#trajectory-card,
#branch-compare-panel,
#brief-action-rail,
#related-briefs-card {
  scroll-margin-top: var(--app-shell-offset);
}

.brief-layout .card {
  margin-bottom: 1.15rem;
}

#decision-snapshot-card {
  background: linear-gradient(180deg, var(--accent-soft), var(--surface) 55%);
  border-color: var(--accent-border);
}

.snapshot-grid {
  gap: 0.85rem;
}

.snapshot-cell {
  padding: 1rem 1rem 0.95rem;
  min-height: 0;
}

.snapshot-note-row {
  margin-top: 0.9rem;
  padding: 0.85rem 1rem;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
}

.signal-card,
.contradiction-card,
.unknown-card {
  padding: 0.85rem 0.95rem;
  box-shadow: none;
}

.trajectory-panel,
.ecosystem-detail,
.ecosystem-graph-wrap {
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
}

.branch-compare-grid {
  gap: 0.95rem;
}

.branch-compare-summary {
  padding: 1.05rem 1.1rem;
}

.branch-compare-summary-copy {
  color: var(--text-2);
}

.branch-compare-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.65rem;
  margin-top: 0.85rem;
}

.branch-compare-summary-cell {
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  background: var(--surface);
  padding: 0.72rem 0.78rem;
}

.branch-compare-summary-cell span {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-3);
  margin-bottom: 0.2rem;
}

.branch-compare-summary-cell p {
  font-size: 0.82rem;
  line-height: 1.48;
  color: var(--text);
}

.branch-compare-card {
  padding: 0.88rem 0.95rem;
  box-shadow: none;
}

.branch-compare-meta {
  margin-top: 0.15rem;
  font-size: 0.74rem;
}

.branch-compare-metrics {
  margin-top: 0.15rem;
  gap: 0.35rem;
}

.branch-compare-metric {
  padding: 0.48rem 0.58rem;
}

.branch-compare-metric strong {
  font-size: 0.82rem;
}

.branch-compare-section {
  margin-top: 0.28rem;
}

.branch-compare-action {
  font-size: 0.8rem;
  line-height: 1.45;
}

.branch-compare-copy {
  margin-top: 0.12rem;
  font-size: 0.74rem;
  color: var(--text-2);
}

.citation-panel {
  display: none;
  position: fixed;
  top: 0;
  right: 0;
  width: 380px;
  height: 100vh;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -4px 0 24px rgba(0,0,0,.1);
  z-index: var(--z-app-overlay);
  overflow-y: auto;
  padding: 1.5rem;
}

.brief-toast {
  display: none;
  position: fixed;
  bottom: 4.5rem;
  right: 1.5rem;
  background: #1a1d23;
  color: #fff;
  padding: 0.55rem 1rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  z-index: var(--z-app-toast);
  transition: opacity 0.3s;
  max-width: min(320px, calc(100vw - 2rem));
}
[data-theme="dark"] .brief-toast {
  background: #e8eaf0;
  color: #111318;
}

.branch-compare-details {
  margin-top: 0.18rem;
  padding: 0.68rem 0.78rem;
}

.branch-compare-details summary {
  color: var(--text-2);
  font-weight: 600;
}

#decision-coach-surface .card-flat,
#brief-framing-panel,
#brief-decision-card,
#brief-clarification-panel {
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border-color: var(--border-soft);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06);
}

#brief-framing-panel {
  padding: 1.1rem 1.15rem !important;
}

.intake-framing-card {
  min-height: 168px;
  padding: 1rem 1rem 1.05rem;
  border-radius: 16px;
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
}

.intake-framing-card.is-selected {
  background: linear-gradient(180deg, var(--accent-soft), var(--surface));
  box-shadow: 0 10px 22px rgba(26, 86, 219, 0.08);
}

#decision-coach-export-actions {
  border-radius: 16px !important;
  background: linear-gradient(180deg, var(--surface), var(--surface-2)) !important;
  border-color: var(--border-soft) !important;
}

.decision-coach-hero-notes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.9rem;
}

.decision-coach-panel {
  border-radius: 16px !important;
}

.decision-coach-grid-cell {
  background: linear-gradient(180deg, var(--surface), var(--surface-2)) !important;
}

.decision-coach-action-bar {
  padding-top: 0.25rem;
}

.decision-coach-action-buttons .btn-ghost,
.decision-coach-action-buttons .search-submit {
  min-width: 138px;
  justify-content: center;
}

@media (max-width: 1024px) {
  .brief-layout {
    grid-template-columns: 1fr;
  }

  .brief-sidebar {
    position: static;
    order: -1;
  }

  .summary-rail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .branch-compare-summary-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  :root {
    --app-shell-offset: 0px;
  }

  .app-header,
  header {
    position: static;
  }

  .app-header-bar {
    padding: 0.72rem 1rem;
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .app-brand-cluster {
    flex-direction: row;
    align-items: flex-start;
    gap: 0.55rem;
  }

  .brand-link {
    gap: 0.58rem;
  }

  .brand-symbol-set {
    padding: 3px 6px;
    border-radius: 8px;
  }

  .brand-wordmark {
    gap: 0.04rem;
  }

  .brand-product-name {
    font-size: 0.88rem;
  }

  .brand-artifact-name {
    font-size: 0.64rem;
    white-space: normal;
  }

  .summary-rail-grid {
    grid-template-columns: 1fr;
  }

  .brief-action-rail-actions .btn-secondary,
  .brief-action-rail-actions .btn-ghost {
    flex: 1 1 160px;
  }

  .floating-actions {
    display: none;
  }

  .brief-toast {
    left: 1rem;
    right: 1rem;
    bottom: 1rem;
    max-width: none;
  }

  .decision-coach-action-bar,
  .decision-coach-action-buttons {
    width: 100%;
  }

  .decision-coach-action-buttons {
    justify-content: stretch;
  }

  .decision-coach-action-buttons .btn-ghost,
  .decision-coach-action-buttons .search-submit {
    flex: 1 1 180px;
  }

  .branch-compare-summary {
    padding: 0.92rem;
  }

  .branch-compare-summary-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.55rem;
  }

  .branch-compare-card {
    padding: 0.78rem 0.84rem;
  }

  .branch-compare-meta,
  .branch-compare-copy {
    display: none;
  }

  .branch-compare-section {
    margin-top: 0.18rem;
  }

  .trajectory-panel {
    padding: 0.75rem 0.8rem;
  }

  .trajectory-step {
    gap: 0.55rem;
    padding: 0.45rem 0;
  }

  .trajectory-body .muted {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .ecosystem-toolbar {
    align-items: flex-start;
  }
}

@media (max-width: 640px) {
  .app-header {
    min-height: 60px;
  }

  .brand-link {
    gap: 0.45rem;
  }

  .brand-product-name {
    font-size: 0.88rem;
  }

  main.brief-view {
    max-width: 100%;
  }

  .brief-result-hero {
    padding: 1.35rem 1.25rem 1.2rem;
  }
}

/* ─── Dark Mode: Brief View & Sample Brief Fixes ─────────────────────── */
/* Fix hardcoded white / light backgrounds that break in dark mode.       */
/* Uses both [data-theme] and prefers-color-scheme to match existing      */
/* patterns in this file.                                                 */

[data-theme="dark"] .card,
[data-theme="dark"] .card-flat,
[data-theme="dark"] .card-hero {
  background: var(--surface);
  color: var(--text);
}

[data-theme="dark"] .brief-result-hero {
  background: linear-gradient(145deg, var(--accent-soft) 0%, var(--surface) 60%);
}

[data-theme="dark"] .snapshot-grid,
[data-theme="dark"] .snapshot-cell { background: var(--surface-2); }
[data-theme="dark"] .signal-card { background: var(--surface-2); border-color: var(--border); }
[data-theme="dark"] .fact-row { background: var(--surface-2); }
[data-theme="dark"] .brief-summary-rail-card { background: var(--surface-2); border-color: var(--accent-soft); }

/* Override inline styles that use hardcoded light colors */
[data-theme="dark"] [style*="background:#fff"],
[data-theme="dark"] [style*="background: #fff"],
[data-theme="dark"] [style*="background:white"],
[data-theme="dark"] [style*="background: white"],
[data-theme="dark"] [style*="background:#f8fafc"],
[data-theme="dark"] [style*="background:#f0f7ff"],
[data-theme="dark"] [style*="background:#fffbeb"],
[data-theme="dark"] [style*="background:linear-gradient(135deg,#f0f7ff"],
[data-theme="dark"] [style*="background:linear-gradient(135deg,#fffbeb"],
[data-theme="dark"] [style*="background:linear-gradient(135deg,#eff6ff"] {
  background: var(--surface-2) !important;
}

[data-theme="dark"] [style*="color:#1a1a2e"],
[data-theme="dark"] [style*="color:#111318"],
[data-theme="dark"] [style*="color:#334155"],
[data-theme="dark"] [style*="color:#1e293b"] {
  color: var(--text) !important;
}

[data-theme="dark"] [style*="color:#475569"],
[data-theme="dark"] [style*="color:#64748b"] {
  color: var(--text-2) !important;
}

[data-theme="dark"] [style*="border-color:#e2e8f0"],
[data-theme="dark"] [style*="border:1px solid #e2e8f0"] {
  border-color: var(--border) !important;
}

[data-theme="dark"] input,
[data-theme="dark"] textarea,
[data-theme="dark"] select {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}

/* ─── Decision Coach dark-mode overrides ─────────────────────────────── */
[data-theme="dark"] .decision-coach-summary-surface {
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-2) 100%) !important;
  box-shadow: 0 18px 44px rgba(0,0,0,.3), inset 0 1px 0 rgba(255,255,255,0.04) !important;
}

[data-theme="dark"] .decision-coach-panel.decision-commit-card {
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-2) 100%) !important;
  box-shadow: 0 12px 24px rgba(0,0,0,.25), inset 0 1px 0 rgba(255,255,255,0.04) !important;
}

[data-theme="dark"] .question-tightening-panel {
  background: var(--surface-2) !important;
  border-color: var(--border) !important;
}

[data-theme="dark"] .question-tightening-panel.is-active {
  background: linear-gradient(180deg, var(--accent-soft) 0%, var(--surface-2) 100%) !important;
  border-color: var(--accent-border) !important;
  box-shadow: 0 10px 18px rgba(0,0,0,.2) !important;
}

[data-theme="dark"] .question-tightening-recovery {
  background: var(--amber-soft) !important;
  border-color: var(--amber-border) !important;
}

[data-theme="dark"] .intake-framing-card.is-recommended {
  background: linear-gradient(180deg, var(--accent-soft) 0%, var(--surface) 100%) !important;
  border-color: var(--accent-border) !important;
  box-shadow: 0 8px 18px rgba(0,0,0,.2) !important;
}

[data-theme="dark"] .intake-framing-card.is-selected {
  background: linear-gradient(180deg, var(--accent-soft) 0%, var(--surface-2) 100%) !important;
  border-color: var(--accent-border) !important;
  box-shadow: 0 10px 22px rgba(0,0,0,.25) !important;
}

[data-theme="dark"] .decision-history-card {
  background: var(--surface-2) !important;
}

[data-theme="dark"] .decision-coach-outer-rail {
  background: var(--surface) !important;
  border-color: var(--border) !important;
}

[data-theme="dark"] .question-tightening-card {
  background: var(--surface) !important;
  border-color: var(--border) !important;
}

[data-theme="dark"] .btn-secondary {
  background: var(--surface) !important;
  color: var(--accent) !important;
  border-color: var(--accent-border) !important;
}
[data-theme="dark"] .btn-secondary:hover {
  background: var(--accent-soft) !important;
  color: var(--accent-hover) !important;
  border-color: var(--accent) !important;
}
[data-theme="dark"] .btn-ghost {
  background: var(--surface) !important;
  color: var(--text-2) !important;
  border-color: var(--border) !important;
}
[data-theme="dark"] .btn-ghost:hover {
  background: var(--surface-2) !important;
  color: var(--text) !important;
  border-color: var(--text-3) !important;
}

/* ─── Brief View dark-mode overrides ─────────────────────────────────── */
[data-theme="dark"] .brief-summary-rail-card {
  background: var(--surface) !important;
  border-color: var(--accent-border) !important;
  box-shadow: 0 4px 12px rgba(0,0,0,.3) !important;
}
[data-theme="dark"] .brief-summary-rail-card .section-label { color: var(--accent) !important; }
[data-theme="dark"] .summary-rail-head h3 { color: var(--text) !important; }
[data-theme="dark"] .summary-rail-item {
  background: var(--surface-2) !important;
  border-color: var(--border) !important;
}
[data-theme="dark"] .summary-rail-item dd { color: var(--text) !important; }
[data-theme="dark"] .brief-action-rail-card {
  background: var(--surface) !important;
  box-shadow: 0 16px 34px rgba(0,0,0,.3) !important;
}
[data-theme="dark"] .exec-dashboard { background: var(--accent-soft) !important; border-color: var(--accent-border) !important; }
[data-theme="dark"] .exec-dashboard h3 { color: var(--accent) !important; }
[data-theme="dark"] .exec-dashboard [data-dashboard] { color: var(--text) !important; }
[data-theme="dark"] .brief-view .card-tldr { background: var(--surface-2) !important; }
[data-theme="dark"] .brief-action-rail-actions .btn-secondary { background: var(--surface) !important; color: var(--accent) !important; border-color: var(--accent-border) !important; }
[data-theme="dark"] .brief-action-rail-actions .btn-ghost { background: var(--surface) !important; color: var(--text-2) !important; border-color: var(--border) !important; }
[data-theme="dark"] .brief-view .brief-main .section-label { color: var(--text) !important; }
[data-theme="dark"] #brief-next-action-card { background: var(--accent-soft) !important; border-color: var(--accent-border) !important; }
[data-theme="dark"] #brief-next-action-card h3 { color: var(--accent) !important; }
[data-theme="dark"] #brief-next-action-card p { color: var(--text) !important; }
[data-theme="dark"] #brief-assumptions-card { background: var(--amber-soft) !important; border-color: var(--amber-border) !important; }
[data-theme="dark"] #brief-assumptions-card h3 { color: var(--amber) !important; }
[data-theme="dark"] #brief-assumptions-card ul { color: var(--text-2) !important; }
[data-theme="dark"] #brief-assumptions-card p { color: var(--text-3) !important; }
/* Catch all inline light backgrounds in brief view */
[data-theme="dark"] .brief-view [style*="color:#1e293b"],
[data-theme="dark"] .brief-view [style*="color:#1a1a2e"],
[data-theme="dark"] .brief-view [style*="color:#475569"],
[data-theme="dark"] .brief-view [style*="color:#334155"] { color: var(--text-2) !important; }
[data-theme="dark"] .brief-view [style*="background:#f0f7ff"],
[data-theme="dark"] .brief-view [style*="background:#fffbeb"],
[data-theme="dark"] .brief-view [style*="background:#f8fafc"],
[data-theme="dark"] .brief-view [style*="background:linear-gradient(135deg,#f0f7ff"],
[data-theme="dark"] .brief-view [style*="background:linear-gradient(135deg,#fffbeb"],
[data-theme="dark"] .brief-view [style*="background:linear-gradient(135deg,#eff6ff"] { background: var(--surface-2) !important; }
/* Badge dark overrides */
[data-theme="dark"] .badge-neutral { background: #1e293b !important; color: #94a3b8 !important; border-color: #334155 !important; }
/* Dark-mode badge overrides removed — label palette auto-swaps via CSS vars */
/* Warning/info card borders */
[data-theme="dark"] .brief-list-item { border-color: var(--border) !important; }

/* Same overrides for prefers-color-scheme auto-dark */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .card,
  :root:not([data-theme="light"]) .card-flat,
  :root:not([data-theme="light"]) .card-hero {
    background: var(--surface);
    color: var(--text);
  }

  :root:not([data-theme="light"]) .brief-result-hero {
    background: linear-gradient(145deg, var(--accent-soft) 0%, var(--surface) 60%);
  }

  :root:not([data-theme="light"]) .snapshot-grid,
  :root:not([data-theme="light"]) .snapshot-cell { background: var(--surface-2); }
  :root:not([data-theme="light"]) .signal-card { background: var(--surface-2); border-color: var(--border); }
  :root:not([data-theme="light"]) .fact-row { background: var(--surface-2); }
  :root:not([data-theme="light"]) .brief-summary-rail-card { background: var(--surface-2); border-color: var(--accent-soft); }

  :root:not([data-theme="light"]) [style*="background:#fff"],
  :root:not([data-theme="light"]) [style*="background: #fff"],
  :root:not([data-theme="light"]) [style*="background:white"],
  :root:not([data-theme="light"]) [style*="background: white"],
  :root:not([data-theme="light"]) [style*="background:#f8fafc"],
  :root:not([data-theme="light"]) [style*="background:#f0f7ff"],
  :root:not([data-theme="light"]) [style*="background:#fffbeb"],
  :root:not([data-theme="light"]) [style*="background:linear-gradient(135deg,#f0f7ff"],
  :root:not([data-theme="light"]) [style*="background:linear-gradient(135deg,#fffbeb"],
  :root:not([data-theme="light"]) [style*="background:linear-gradient(135deg,#eff6ff"] {
    background: var(--surface-2) !important;
  }

  :root:not([data-theme="light"]) [style*="color:#1a1a2e"],
  :root:not([data-theme="light"]) [style*="color:#111318"],
  :root:not([data-theme="light"]) [style*="color:#334155"],
  :root:not([data-theme="light"]) [style*="color:#1e293b"] {
    color: var(--text) !important;
  }

  :root:not([data-theme="light"]) [style*="color:#475569"],
  :root:not([data-theme="light"]) [style*="color:#64748b"] {
    color: var(--text-2) !important;
  }

  :root:not([data-theme="light"]) [style*="border-color:#e2e8f0"],
  :root:not([data-theme="light"]) [style*="border:1px solid #e2e8f0"] {
    border-color: var(--border) !important;
  }

  :root:not([data-theme="light"]) input,
  :root:not([data-theme="light"]) textarea,
  :root:not([data-theme="light"]) select {
    background: var(--surface-2);
    color: var(--text);
    border-color: var(--border);
  }

  /* Decision Coach auto-dark */
  :root:not([data-theme="light"]) .decision-coach-summary-surface {
    background: linear-gradient(180deg, var(--surface) 0%, var(--surface-2) 100%) !important;
    box-shadow: 0 18px 44px rgba(0,0,0,.3), inset 0 1px 0 rgba(255,255,255,0.04) !important;
  }
  :root:not([data-theme="light"]) .decision-coach-panel.decision-commit-card {
    background: linear-gradient(180deg, var(--surface) 0%, var(--surface-2) 100%) !important;
    box-shadow: 0 12px 24px rgba(0,0,0,.25), inset 0 1px 0 rgba(255,255,255,0.04) !important;
  }
  :root:not([data-theme="light"]) .question-tightening-panel { background: var(--surface-2) !important; border-color: var(--border) !important; }
  :root:not([data-theme="light"]) .question-tightening-panel.is-active {
    background: linear-gradient(180deg, var(--accent-soft) 0%, var(--surface-2) 100%) !important;
    border-color: var(--accent-border) !important;
  }
  :root:not([data-theme="light"]) .question-tightening-recovery { background: var(--amber-soft) !important; border-color: var(--amber-border) !important; }
  :root:not([data-theme="light"]) .intake-framing-card.is-recommended {
    background: linear-gradient(180deg, var(--accent-soft) 0%, var(--surface) 100%) !important;
    border-color: var(--accent-border) !important;
  }
  :root:not([data-theme="light"]) .intake-framing-card.is-selected {
    background: linear-gradient(180deg, var(--accent-soft) 0%, var(--surface-2) 100%) !important;
    border-color: var(--accent-border) !important;
  }
  :root:not([data-theme="light"]) .decision-history-card { background: var(--surface-2) !important; }
  :root:not([data-theme="light"]) .decision-coach-outer-rail { background: var(--surface) !important; border-color: var(--border) !important; }
  :root:not([data-theme="light"]) .question-tightening-card { background: var(--surface) !important; border-color: var(--border) !important; }
  :root:not([data-theme="light"]) .btn-secondary { background: var(--surface) !important; color: var(--accent) !important; border-color: var(--accent-border) !important; }
  :root:not([data-theme="light"]) .btn-secondary:hover { background: var(--accent-soft) !important; color: var(--accent-hover) !important; border-color: var(--accent) !important; }
  :root:not([data-theme="light"]) .btn-ghost { background: var(--surface) !important; color: var(--text-2) !important; border-color: var(--border) !important; }
  :root:not([data-theme="light"]) .btn-ghost:hover { background: var(--surface-2) !important; color: var(--text) !important; border-color: var(--text-3) !important; }

  /* Brief View auto-dark */
  :root:not([data-theme="light"]) .brief-summary-rail-card { background: var(--surface) !important; border-color: var(--accent-border) !important; box-shadow: 0 4px 12px rgba(0,0,0,.3) !important; }
  :root:not([data-theme="light"]) .brief-summary-rail-card .section-label { color: var(--accent) !important; }
  :root:not([data-theme="light"]) .summary-rail-head h3 { color: var(--text) !important; }
  :root:not([data-theme="light"]) .summary-rail-item { background: var(--surface-2) !important; border-color: var(--border) !important; }
  :root:not([data-theme="light"]) .summary-rail-item dd { color: var(--text) !important; }
  :root:not([data-theme="light"]) .brief-action-rail-card { background: var(--surface) !important; box-shadow: 0 16px 34px rgba(0,0,0,.3) !important; }
  :root:not([data-theme="light"]) .exec-dashboard { background: var(--accent-soft) !important; border-color: var(--accent-border) !important; }
  :root:not([data-theme="light"]) .exec-dashboard h3 { color: var(--accent) !important; }
  :root:not([data-theme="light"]) .exec-dashboard [data-dashboard] { color: var(--text) !important; }
  :root:not([data-theme="light"]) .brief-view .card-tldr { background: var(--surface-2) !important; }
  :root:not([data-theme="light"]) .brief-view .brief-main .section-label { color: var(--text) !important; }
  :root:not([data-theme="light"]) #brief-next-action-card { background: var(--accent-soft) !important; border-color: var(--accent-border) !important; }
  :root:not([data-theme="light"]) #brief-next-action-card h3 { color: var(--accent) !important; }
  :root:not([data-theme="light"]) #brief-next-action-card p { color: var(--text) !important; }
  :root:not([data-theme="light"]) #brief-assumptions-card { background: var(--amber-soft) !important; border-color: var(--amber-border) !important; }
  :root:not([data-theme="light"]) #brief-assumptions-card h3 { color: var(--amber) !important; }
  :root:not([data-theme="light"]) #brief-assumptions-card ul { color: var(--text-2) !important; }
  :root:not([data-theme="light"]) .brief-view [style*="color:#1e293b"],
  :root:not([data-theme="light"]) .brief-view [style*="color:#1a1a2e"],
  :root:not([data-theme="light"]) .brief-view [style*="color:#475569"],
  :root:not([data-theme="light"]) .brief-view [style*="color:#334155"] { color: var(--text-2) !important; }
  :root:not([data-theme="light"]) .brief-view [style*="background:#f0f7ff"],
  :root:not([data-theme="light"]) .brief-view [style*="background:#fffbeb"],
  :root:not([data-theme="light"]) .brief-view [style*="background:#f8fafc"],
  :root:not([data-theme="light"]) .brief-view [style*="background:linear-gradient(135deg,#f0f7ff"],
  :root:not([data-theme="light"]) .brief-view [style*="background:linear-gradient(135deg,#fffbeb"],
  :root:not([data-theme="light"]) .brief-view [style*="background:linear-gradient(135deg,#eff6ff"] { background: var(--surface-2) !important; }
}
