/* --- Self-hosted variable fonts --- */
@font-face {
  font-family: 'Newsreader';
  src: url('/fonts/Newsreader-VariableFont_wght.woff2') format('woff2-variations');
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Newsreader';
  src: url('/fonts/Newsreader-Italic-VariableFont_wght.woff2') format('woff2-variations');
  font-weight: 200 800;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: 'Geist';
  src: url('/fonts/Geist-VariableFont_wght.woff2') format('woff2-variations');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'JetBrains Mono';
  src: url('/fonts/JetBrainsMono-VariableFont_wght.woff2') format('woff2-variations');
  font-weight: 100 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'JetBrains Mono';
  src: url('/fonts/JetBrainsMono-Italic-VariableFont_wght.woff2') format('woff2-variations');
  font-weight: 100 800;
  font-style: italic;
  font-display: swap;
}

/* ============================================================
   GEEF.ATELIER — design system
   "Atelier Noir" base. Palette swappable via .palette-* on <html>.
   ============================================================ */

/* ---------- Tokens: Atelier Noir (default, dark) ---------- */
:root, html.palette-noir {
  /* Surfaces — warm anthracite with subtle warm chroma */
  --bg-deep:        oklch(0.145 0.008 60);
  --bg:             oklch(0.182 0.008 60);
  --surface:        oklch(0.218 0.009 60);
  --surface-2:      oklch(0.255 0.010 60);
  --surface-3:      oklch(0.295 0.011 60);

  /* Hairlines & dividers */
  --hairline:       oklch(0.36 0.010 60);
  --hairline-soft:  oklch(0.28 0.009 60);
  --hairline-strong:oklch(0.46 0.012 60);

  /* Text — warm cream */
  --ink:            oklch(0.945 0.012 85);
  --ink-2:          oklch(0.82 0.012 80);
  --ink-3:          oklch(0.62 0.012 80);
  --ink-4:          oklch(0.48 0.010 70);

  /* Hero — aged gold ink */
  --hero:           oklch(0.81 0.13 78);
  --hero-deep:      oklch(0.66 0.14 60);
  --hero-soft:      oklch(0.81 0.13 78 / 0.16);
  --on-hero:        oklch(0.18 0.012 60);

  /* Status colors (carry shape too, see --shape-*) */
  --st-pending:     oklch(0.72 0.02 80);
  --st-running:     oklch(0.80 0.14 78);
  --st-completed:   oklch(0.76 0.10 152);
  --st-failed:      oklch(0.66 0.17 25);
  --st-aborted:     oklch(0.55 0.040 50);

  /* Severity */
  --sv-critical:    oklch(0.64 0.19 25);
  --sv-major:       oklch(0.75 0.14 55);
  --sv-minor:       oklch(0.82 0.12 95);
  --sv-info:        oklch(0.70 0.04 235);

  /* Editorial paper — used for "final manuscript" sheet */
  --paper:          oklch(0.93 0.015 85);
  --paper-2:        oklch(0.89 0.018 85);
  --paper-ink:      oklch(0.20 0.010 60);
  --paper-ink-2:    oklch(0.38 0.012 60);
  --paper-rule:     oklch(0.78 0.022 70);

  /* Type */
  --font-display:   "Newsreader", "Source Serif Pro", Georgia, serif;
  --font-ui:        "Geist", "Söhne", system-ui, sans-serif;
  --font-mono:      "JetBrains Mono", ui-monospace, Menlo, monospace;

  --grain-opacity:  0.18;

  /* Brand marks */
  --brand-mark:     url('/img/brand/mark-light.png');
  --hero-mark:      url('/img/brand/mark-light.png');
}

/* ---------- Palette: Vellum (light warm parchment) ---------- */
html.palette-vellum {
  --bg-deep:        oklch(0.90 0.018 85);
  --bg:             oklch(0.945 0.014 85);
  --surface:        oklch(0.97 0.012 85);
  --surface-2:      oklch(0.99 0.008 85);
  --surface-3:      oklch(0.92 0.018 85);

  --hairline:       oklch(0.74 0.022 70);
  --hairline-soft:  oklch(0.83 0.018 75);
  --hairline-strong:oklch(0.55 0.025 60);

  --ink:            oklch(0.21 0.012 60);
  --ink-2:          oklch(0.36 0.012 60);
  --ink-3:          oklch(0.50 0.012 60);
  --ink-4:          oklch(0.62 0.012 60);

  --hero:           oklch(0.46 0.13 35);   /* deep bordeaux-ink */
  --hero-deep:      oklch(0.36 0.14 30);
  --hero-soft:      oklch(0.46 0.13 35 / 0.10);
  --on-hero:        oklch(0.97 0.010 85);

  --st-pending:     oklch(0.55 0.018 70);
  --st-running:     oklch(0.48 0.14 35);
  --st-completed:   oklch(0.46 0.12 152);
  --st-failed:      oklch(0.50 0.18 25);
  --st-aborted:     oklch(0.45 0.030 50);

  --sv-critical:    oklch(0.48 0.20 25);
  --sv-major:       oklch(0.62 0.16 55);
  --sv-minor:       oklch(0.70 0.13 90);
  --sv-info:        oklch(0.50 0.05 235);

  --paper:          oklch(0.97 0.012 85);
  --paper-2:        oklch(0.93 0.018 85);
  --paper-ink:      oklch(0.18 0.010 60);
  --paper-ink-2:    oklch(0.36 0.012 60);
  --paper-rule:     oklch(0.78 0.022 70);

  --grain-opacity:  0.10;

  /* Brand marks */
  --brand-mark:     url('/img/brand/mark-dark.png');
  --hero-mark:      url('/img/brand/mark-dark.png');
}

/* ---------- Palette: Petrol (cool deep teal) ---------- */
html.palette-petrol {
  --bg-deep:        oklch(0.155 0.025 220);
  --bg:             oklch(0.195 0.028 218);
  --surface:        oklch(0.235 0.030 216);
  --surface-2:      oklch(0.275 0.032 214);
  --surface-3:      oklch(0.315 0.034 213);

  --hairline:       oklch(0.40 0.032 215);
  --hairline-soft:  oklch(0.32 0.030 216);
  --hairline-strong:oklch(0.52 0.040 215);

  --ink:            oklch(0.945 0.018 200);
  --ink-2:          oklch(0.82 0.020 205);
  --ink-3:          oklch(0.62 0.022 210);
  --ink-4:          oklch(0.48 0.024 215);

  --hero:           oklch(0.78 0.13 190);   /* cyan ink */
  --hero-deep:      oklch(0.62 0.14 195);
  --hero-soft:      oklch(0.78 0.13 190 / 0.18);
  --on-hero:        oklch(0.16 0.025 220);

  --st-pending:     oklch(0.70 0.025 215);
  --st-running:     oklch(0.78 0.13 190);
  --st-completed:   oklch(0.76 0.11 158);
  --st-failed:      oklch(0.68 0.17 22);
  --st-aborted:     oklch(0.55 0.04 230);

  --sv-critical:    oklch(0.66 0.20 22);
  --sv-major:       oklch(0.76 0.15 55);
  --sv-minor:       oklch(0.82 0.13 95);
  --sv-info:        oklch(0.72 0.06 230);

  --paper:          oklch(0.93 0.020 200);
  --paper-2:        oklch(0.88 0.025 200);
  --paper-ink:      oklch(0.20 0.025 220);
  --paper-ink-2:    oklch(0.36 0.028 218);
  --paper-rule:     oklch(0.74 0.030 210);

  --grain-opacity:  0.15;

  /* Brand marks */
  --brand-mark:     url('/img/brand/mark-sand.png');
  --hero-mark:      url('/img/brand/mark-sand.png');
}

/* ---------- Reset + base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html {
  font-family: var(--font-ui);
  font-size: 15px;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body {
  background:
    radial-gradient(circle at 12% 8%, color-mix(in oklch, var(--hero) 7%, transparent) 0%, transparent 38%),
    radial-gradient(circle at 92% 92%, color-mix(in oklch, var(--hero) 5%, transparent) 0%, transparent 42%),
    var(--bg);
  min-height: 100vh;
  position: relative;
}

/* Subtle paper-grain on the body */
body::before {
  content: "";
  pointer-events: none;
  position: fixed;
  inset: 0;
  opacity: var(--grain-opacity);
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0.55 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  z-index: 1;
}

/* ============================================================
   Typography utilities
   ============================================================ */
.t-display   { font-family: var(--font-display); font-weight: 400; letter-spacing: -0.012em; }
.t-mono      { font-family: var(--font-mono); }
.t-eyebrow   { font-family: var(--font-ui); font-weight: 500; text-transform: uppercase; letter-spacing: 0.16em; font-size: 11px; color: var(--ink-3); }
.t-caption   { font-size: 12px; color: var(--ink-3); }

/* Blazor FocusOnNavigate moves focus to the page <h1> for screen-reader
   announcement. The heading is not keyboard-reachable (tabindex=-1), so its
   default focus ring is visual noise on load — suppress it. */
h1[tabindex="-1"]:focus { outline: none; }

/* ============================================================
   App layout
   ============================================================ */
.app {
  position: relative;
  z-index: 2;
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

/* ---- Top nav (the atelier signboard) ---- */
.nav {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 24px;
  padding: 18px 32px;
  border-bottom: 1px solid var(--hairline-soft);
  background: color-mix(in oklch, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.nav-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
}
.nav-brand .wordmark {
  font-family: var(--font-display);
  font-size: 20px;
  letter-spacing: -0.01em;
  display: flex;
  align-items: baseline;
  gap: 2px;
}
.nav-brand .wordmark .dot {
  color: var(--hero);
  font-family: var(--font-mono);
  font-weight: 500;
}
.nav-brand .wordmark .atelier {
  font-style: italic;
  color: var(--ink-2);
}
.nav-brand .brand-mark {
  width: 28px;
  height: 28px;
  background-image: var(--brand-mark);
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}
.nav-links { display: flex; gap: 4px; align-items: center; }
.nav-link {
  font-size: 13px;
  color: var(--ink-2);
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  letter-spacing: 0.005em;
  transition: color .18s, background .18s;
  user-select: none;
}
.nav-link:hover { color: var(--ink); background: color-mix(in oklch, var(--surface) 60%, transparent); }
.nav-link.active { color: var(--ink); }
.nav-link.active::after {
  content: "";
  display: block;
  height: 1px;
  background: var(--hero);
  margin-top: 4px;
}

/* ---- Crew dropdown group ---- */
.nav-group {
  position: relative;
}
.nav-group-trigger {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: none;
  border: none;
  font-family: inherit;
}
.nav-group-chevron {
  font-size: 9px;
  color: var(--ink-3);
  transition: transform .2s;
  line-height: 1;
}
.nav-group.open .nav-group-chevron { transform: rotate(180deg); }
.nav-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  padding: 6px;
  min-width: 170px;
  z-index: 200;
  box-shadow: 0 8px 24px rgba(0,0,0,.14);
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.nav-dropdown .nav-link {
  white-space: nowrap;
  border-radius: 7px;
  font-size: 13px;
}
.nav-dropdown-sep {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding: 8px 12px 3px;
  margin-top: 4px;
}

/* Global live indicator (running runs anywhere) */
.global-pulse {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--ink-2);
  padding: 6px 12px;
  border: 1px solid var(--hairline-soft);
  border-radius: 999px;
  cursor: pointer;
}
.global-pulse .dot {
  width: 7px; height: 7px;
  background: var(--st-running);
  border-radius: 50%;
  position: relative;
  box-shadow: 0 0 0 0 color-mix(in oklch, var(--st-running) 60%, transparent);
  animation: pulse 1.8s ease-out infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 color-mix(in oklch, var(--st-running) 60%, transparent); }
  70%  { box-shadow: 0 0 0 8px color-mix(in oklch, var(--st-running) 0%, transparent); }
  100% { box-shadow: 0 0 0 0 color-mix(in oklch, var(--st-running) 0%, transparent); }
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 12px;
}
.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px 6px 6px;
  border-radius: 999px;
  border: 1px solid var(--hairline-soft);
  cursor: pointer;
  font-size: 12px;
  color: var(--ink-2);
  transition: border-color .18s;
}
.user-chip:hover { border-color: var(--hairline-strong); color: var(--ink); }
.user-chip .av {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--surface-3);
  display: grid; place-items: center;
  font-family: var(--font-display);
  font-size: 11px;
  color: var(--hero);
}
.user-menu-dd {
  position: absolute;
  top: 56px;
  right: 28px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  min-width: 200px;
  padding: 6px;
  z-index: 50;
  box-shadow: 0 18px 50px -20px color-mix(in oklch, black 50%, transparent);
}
.user-menu-dd .item {
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-2);
}
.user-menu-dd .item:hover { background: var(--surface-2); color: var(--ink); }
.user-menu-dd .sep { height: 1px; background: var(--hairline-soft); margin: 4px 0; }

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.005em;
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid var(--hairline);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background .18s, border-color .18s, color .18s, transform .12s;
  user-select: none;
}
.btn:hover { border-color: var(--hairline-strong); background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn.primary {
  background: var(--hero);
  color: var(--on-hero);
  border-color: color-mix(in oklch, var(--hero) 60%, black);
}
.btn.primary:hover {
  background: color-mix(in oklch, var(--hero) 92%, white);
}
.btn.ghost { background: transparent; }
.btn.danger {
  color: var(--st-failed);
  border-color: color-mix(in oklch, var(--st-failed) 35%, var(--hairline));
}
.btn.danger:hover { background: color-mix(in oklch, var(--st-failed) 10%, transparent); }
.btn.small { padding: 6px 10px; font-size: 12px; }

/* ============================================================
   Status badge — color + shape mark (color-blind safe)
   ============================================================ */
.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  padding: 4px 10px 4px 8px;
  border-radius: 999px;
  border: 1px solid currentColor;
  background: color-mix(in oklch, currentColor 10%, transparent);
}
.status .glyph {
  width: 9px; height: 9px;
  display: inline-block;
  flex-shrink: 0;
}
.status.pending   { color: var(--st-pending); }
.status.running   { color: var(--st-running); }
.status.completed { color: var(--st-completed); }
.status.failed    { color: var(--st-failed); }
.status.aborted   { color: var(--st-aborted); }

/* Shape marks — explicit, not relying on color alone */
.status.pending   .glyph { border: 1.5px solid currentColor; border-radius: 50%; box-sizing: border-box; }
.status.running   .glyph {
  background: currentColor;
  border-radius: 50%;
  position: relative;
  animation: dotpulse 1.6s ease-out infinite;
}
@keyframes dotpulse {
  0%   { box-shadow: 0 0 0 0 currentColor; }
  70%  { box-shadow: 0 0 0 5px color-mix(in oklch, currentColor 0%, transparent); }
  100% { box-shadow: 0 0 0 0 color-mix(in oklch, currentColor 0%, transparent); }
}
.status.completed .glyph {
  background: currentColor;
  clip-path: polygon(0% 50%, 35% 100%, 100% 5%, 86% 0%, 35% 80%, 12% 38%);
  height: 8px;
}
.status.failed    .glyph {
  background: currentColor;
  clip-path: polygon(15% 0%, 50% 35%, 85% 0%, 100% 15%, 65% 50%, 100% 85%, 85% 100%, 50% 65%, 15% 100%, 0% 85%, 35% 50%, 0% 15%);
}
.status.aborted   .glyph {
  border: 1.5px solid currentColor;
  border-radius: 50%;
  position: relative;
  box-sizing: border-box;
}
.status.aborted   .glyph::after {
  content: "";
  position: absolute;
  inset: -1px;
  border-top: 1.5px solid currentColor;
  transform: rotate(45deg);
  transform-origin: center;
  width: 100%;
  height: 0;
  top: 50%;
}

/* Larger header status */
.status-lg { padding: 6px 14px 6px 12px; font-size: 12px; }
.status-lg .glyph { width: 11px; height: 11px; }

/* ============================================================
   Severity — for findings, in the margin
   ============================================================ */
.severity {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.severity .mark {
  width: 10px; height: 10px;
  flex-shrink: 0;
}
.severity.critical { color: var(--sv-critical); }
.severity.major    { color: var(--sv-major); }
.severity.minor    { color: var(--sv-minor); }
.severity.info     { color: var(--sv-info); }
/* Shape marks for severity */
.severity.critical .mark { background: currentColor; clip-path: polygon(50% 0%, 100% 100%, 0% 100%); }
.severity.major    .mark { background: currentColor; clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%); }
.severity.minor    .mark { background: currentColor; border-radius: 50%; }
.severity.info     .mark { background: currentColor; clip-path: polygon(0 35%, 100% 35%, 100% 65%, 0 65%); }

/* ============================================================
   Generic cards / sheets
   ============================================================ */
.sheet {
  background: var(--surface);
  border: 1px solid var(--hairline-soft);
  border-radius: 4px;
  position: relative;
}
.sheet-edge::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  background:
    linear-gradient(180deg, color-mix(in oklch, var(--hero) 0%, transparent) 0%, transparent 1px, transparent calc(100% - 1px), color-mix(in oklch, var(--hero) 0%, transparent) 100%);
}

/* ============================================================
   LOGIN
   ============================================================ */
.login-stage {
  min-height: calc(100vh - 0px);
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: stretch;
}
.login-left {
  position: relative;
  overflow: hidden;
  border-right: 1px solid var(--hairline-soft);
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  padding: 36px 44px;
  background:
    radial-gradient(ellipse at 20% 80%, color-mix(in oklch, var(--hero) 10%, transparent), transparent 60%),
    radial-gradient(ellipse at 80% 30%, color-mix(in oklch, var(--hero) 6%, transparent), transparent 55%);
}
.login-left .brand-row {
  display: flex; align-items: center; gap: 12px;
  z-index: 2;
}
.login-hero-mark {
  width: 240px;
  height: 240px;
  background-image: var(--hero-mark);
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  margin-bottom: 32px;
  z-index: 2;
}
.login-left .quote {
  align-self: center;
  max-width: 460px;
  font-family: var(--font-display);
  font-size: 30px;
  line-height: 1.25;
  font-weight: 300;
  color: var(--ink);
  letter-spacing: -0.014em;
  z-index: 2;
}
.login-left .quote em { color: var(--hero); font-style: italic; }
.login-left .colophon {
  font-size: 11px;
  color: var(--ink-3);
  font-family: var(--font-mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  z-index: 2;
  display: flex; gap: 18px; align-items: center;
}
/* Animated ink-drop background — pure CSS */
.ink-pool {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  filter: blur(60px);
  opacity: 0.5;
}
.ink-pool span {
  position: absolute;
  display: block;
  border-radius: 50%;
  background: var(--hero);
  mix-blend-mode: screen;
  animation: drift 18s ease-in-out infinite;
}
html.palette-vellum .ink-pool span { mix-blend-mode: multiply; opacity: 0.35; }
.ink-pool span:nth-child(1) { width: 320px; height: 320px; left: -40px; top: 30%; animation-delay: 0s; }
.ink-pool span:nth-child(2) { width: 240px; height: 240px; right: 5%; top: 10%; animation-delay: -6s; opacity: 0.6; }
.ink-pool span:nth-child(3) { width: 200px; height: 200px; left: 40%; bottom: -30px; animation-delay: -12s; opacity: 0.5; }
@keyframes drift {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33%      { transform: translate(28px, -20px) scale(1.08); }
  66%      { transform: translate(-22px, 18px) scale(0.94); }
}

.login-right {
  display: grid;
  place-items: center;
  padding: 36px 44px;
  background: var(--bg-deep);
}
.login-card {
  width: 100%;
  max-width: 360px;
}
.login-card h1 {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 400;
  margin: 0 0 4px;
  letter-spacing: -0.01em;
}
.login-card p.sub {
  color: var(--ink-3);
  font-size: 13px;
  margin: 0 0 28px;
}
.field {
  display: grid;
  gap: 6px;
  margin-bottom: 16px;
}
.field label {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-3);
}
.field input {
  font-family: var(--font-ui);
  font-size: 14px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--hairline-soft);
  border-radius: 6px;
  padding: 11px 12px;
  outline: none;
  transition: border-color .18s, background .18s;
}
.field input:focus { border-color: var(--hero); background: var(--surface-2); }
.error-banner {
  background: color-mix(in oklch, var(--sv-critical) 12%, transparent);
  border: 1px solid color-mix(in oklch, var(--sv-critical) 45%, transparent);
  color: var(--sv-critical);
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 12px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ============================================================
   WELCOME / LANDING
   ============================================================ */
.welcome {
  max-width: 1180px;
  margin: 0 auto;
  padding: 56px 32px 80px;
  display: grid;
  gap: 40px;
}
.welcome-hero {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 48px;
  align-items: end;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--hairline-soft);
}
.welcome-hero h1 {
  font-family: var(--font-display);
  font-size: 64px;
  font-weight: 300;
  line-height: 1.02;
  letter-spacing: -0.02em;
  margin: 0;
  color: var(--ink);
}
.welcome-hero h1 em { font-style: italic; color: var(--hero); }
.welcome-hero .meta {
  text-align: right;
}
.welcome-hero .meta .greeting {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 10px;
}
.welcome-hero .meta .today {
  font-family: var(--font-display);
  font-size: 18px;
  color: var(--ink-2);
  font-style: italic;
}

.welcome-cta {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 24px;
}
.cta-card {
  position: relative;
  padding: 32px 32px 28px;
  background: var(--surface);
  border: 1px solid var(--hairline-soft);
  border-radius: 4px;
  cursor: pointer;
  overflow: hidden;
  transition: border-color .18s, transform .18s;
}
.cta-card:hover { border-color: var(--hairline-strong); }
.cta-card .glyph-stamp {
  position: absolute;
  right: -20px; top: -20px;
  width: 140px; height: 140px;
  border: 1px solid var(--hero);
  border-radius: 50%;
  opacity: 0.18;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 80px;
  color: var(--hero);
  transition: transform .6s ease;
}
.cta-card:hover .glyph-stamp { transform: rotate(8deg) scale(1.05); }
.cta-card .eyebrow { color: var(--hero); }
.cta-card h2 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 32px;
  margin: 10px 0 6px;
  letter-spacing: -0.012em;
}
.cta-card p {
  color: var(--ink-2);
  font-size: 14px;
  line-height: 1.55;
  max-width: 44ch;
  margin: 0;
}
.cta-card .arrow { margin-top: 22px; font-family: var(--font-mono); color: var(--hero); font-size: 13px; }

.welcome-side {
  display: grid;
  gap: 16px;
}
.stat-tile {
  padding: 18px 20px;
  border: 1px solid var(--hairline-soft);
  border-radius: 4px;
  background: var(--surface);
}
.stat-tile .label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 6px;
}
.stat-tile .value {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 400;
  letter-spacing: -0.01em;
}
.stat-tile .delta { font-size: 11px; color: var(--ink-3); margin-top: 4px; }

.recent-list {
  display: grid;
  gap: 0;
  border-top: 1px solid var(--hairline-soft);
}
.recent-row {
  display: grid;
  grid-template-columns: 110px 1fr auto auto;
  align-items: center;
  gap: 24px;
  padding: 16px 4px;
  border-bottom: 1px solid var(--hairline-soft);
  cursor: pointer;
  transition: background .15s;
}
.recent-row:hover { background: color-mix(in oklch, var(--surface) 70%, transparent); }
.recent-row .when {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: 0.05em;
}
.recent-row .briefing-snip {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 400;
  color: var(--ink);
  letter-spacing: -0.005em;
}
.recent-row .meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
}

/* ============================================================
   NEW RUN
   ============================================================ */
.newrun {
  max-width: 880px;
  margin: 0 auto;
  padding: 56px 32px 80px;
}
.newrun .head {
  margin-bottom: 32px;
}
.newrun .head h1 {
  font-family: var(--font-display);
  font-weight: 300;
  font-size: 46px;
  margin: 6px 0 8px;
  letter-spacing: -0.018em;
}
.newrun .head .helper {
  color: var(--ink-3);
  font-size: 14px;
  max-width: 62ch;
  font-style: italic;
  font-family: var(--font-display);
}

.briefing-wrap {
  position: relative;
  border: 1px solid var(--hairline-soft);
  border-radius: 4px;
  background: var(--surface);
  padding: 4px;
  transition: border-color .25s, transform .25s, box-shadow .25s;
}
.briefing-wrap:focus-within {
  border-color: var(--hero);
  box-shadow: 0 0 0 1px color-mix(in oklch, var(--hero) 35%, transparent),
              0 30px 80px -40px color-mix(in oklch, var(--hero) 35%, transparent);
}
.briefing-wrap textarea {
  width: 100%;
  display: block;
  min-height: 220px;
  resize: vertical;
  border: none;
  outline: none;
  background: transparent;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 17px;
  line-height: 1.55;
  padding: 22px 26px 60px;
  letter-spacing: -0.004em;
}
.briefing-wrap textarea::placeholder { color: var(--ink-4); font-style: italic; }

.briefing-corner {
  position: absolute;
  bottom: 14px;
  left: 26px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: 0.06em;
  display: flex;
  align-items: center;
  gap: 10px;
}
.briefing-corner .ready-pip {
  width: 6px; height: 6px;
  background: var(--ink-4);
  border-radius: 50%;
  transition: background .25s;
}
.briefing-wrap.has-content .briefing-corner .ready-pip { background: var(--hero); }

.config-toggle {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--ink-3);
  cursor: pointer;
  margin: 18px 4px 8px;
  display: inline-flex;
  gap: 8px;
  align-items: center;
}
.config-toggle:hover { color: var(--ink); }
.config-toggle .caret { transition: transform .2s; }
.config-toggle.open .caret { transform: rotate(90deg); }
.config-area {
  border: 1px dashed var(--hairline);
  border-radius: 4px;
  background: var(--bg);
  padding: 12px 14px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-2);
}
.config-area textarea {
  width: 100%;
  min-height: 140px;
  background: transparent;
  border: none;
  outline: none;
  color: var(--ink-2);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
  resize: vertical;
}

.newrun-actions {
  margin-top: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}
.newrun-actions .left-hint {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: 0.04em;
}

/* The 'press' marks — decorative hint of the crew */
.press-row {
  display: flex;
  gap: 28px;
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid var(--hairline-soft);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: 0.04em;
}
.press-row .crew {
  display: flex;
  align-items: center;
  gap: 10px;
}
.press-row .crew .mark {
  width: 22px; height: 22px;
  border: 1px solid var(--hairline-strong);
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  color: var(--hero);
  font-size: 11px;
}

/* ============================================================
   RUNS LIST
   ============================================================ */
.runs {
  max-width: 1180px;
  margin: 0 auto;
  padding: 40px 32px 80px;
}
.runs-head {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 24px;
  margin-bottom: 24px;
}
.runs-head h1 {
  font-family: var(--font-display);
  font-weight: 300;
  font-size: 42px;
  letter-spacing: -0.016em;
  margin: 6px 0 0;
}
.runs-head .sub {
  color: var(--ink-3);
  font-size: 13px;
  font-style: italic;
  font-family: var(--font-display);
  margin-top: 4px;
}

.filters {
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--hairline-soft);
  border-radius: 999px;
  background: var(--surface);
}
.filter-pill {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 999px;
  cursor: pointer;
  color: var(--ink-2);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background .18s, color .18s;
  font-family: var(--font-ui);
}
.filter-pill .count {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-3);
}
.filter-pill:hover { color: var(--ink); }
.filter-pill.active {
  background: var(--surface-3);
  color: var(--ink);
}
.filter-pill.active .count { color: var(--hero); }

/* Run cards as envelopes — wide, hairlined, with a wax-stamp gold disc */
.runs-grid {
  display: grid;
  gap: 0;
  margin-top: 16px;
  border-top: 1px solid var(--hairline-soft);
}
.run-row {
  display: grid;
  grid-template-columns: 28px 130px 1fr auto auto;
  gap: 24px;
  align-items: center;
  padding: 22px 12px;
  border-bottom: 1px solid var(--hairline-soft);
  cursor: pointer;
  position: relative;
  transition: background .15s, padding .2s;
  background: linear-gradient(to right, transparent, transparent);
}
.run-row.has-delete {
  grid-template-columns: 28px 130px 1fr auto auto auto;
}
.run-row:hover {
  background: color-mix(in oklch, var(--surface) 60%, transparent);
}
.run-delete-inline {
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1;
  padding: 4px 8px;
  border: 1px solid transparent;
  border-radius: 3px;
  background: transparent;
  color: var(--ink-4);
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s, color .15s, border-color .15s, background .15s;
}
.run-row:hover .run-delete-inline {
  opacity: 1;
}
.run-delete-inline:hover {
  color: var(--st-failed);
  border-color: var(--st-failed);
  background: color-mix(in oklch, var(--st-failed) 8%, transparent);
}
.run-row::before {
  content: "";
  position: absolute;
  left: 0; top: 50%;
  width: 0; height: 1px;
  background: var(--hero);
  transition: width .25s ease;
  transform: translateY(-50%);
}
.run-row:hover::before { width: 16px; }

.run-stamp {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 1px solid currentColor;
  display: grid; place-items: center;
  position: relative;
  background: color-mix(in oklch, currentColor 8%, transparent);
}
.run-stamp.pending   { color: var(--st-pending); }
.run-stamp.running   { color: var(--st-running); }
.run-stamp.completed { color: var(--st-completed); }
.run-stamp.failed    { color: var(--st-failed); }
.run-stamp.aborted   { color: var(--st-aborted); }
.run-stamp .inner {
  width: 9px; height: 9px;
}
/* running gets pulsing dot */
.run-stamp.running .inner {
  background: currentColor; border-radius: 50%;
  animation: dotpulse 1.6s ease-out infinite;
}
.run-stamp.completed .inner {
  background: currentColor;
  clip-path: polygon(0% 50%, 35% 100%, 100% 5%, 86% 0%, 35% 80%, 12% 38%);
  height: 8px;
}
.run-stamp.pending .inner { border: 1.5px solid currentColor; border-radius: 50%; box-sizing: border-box; }
.run-stamp.failed .inner {
  background: currentColor;
  clip-path: polygon(15% 0%, 50% 35%, 85% 0%, 100% 15%, 65% 50%, 100% 85%, 85% 100%, 50% 65%, 15% 100%, 0% 85%, 35% 50%, 0% 15%);
}
.run-stamp.aborted .inner {
  border: 1.5px solid currentColor;
  border-radius: 50%;
  position: relative;
  box-sizing: border-box;
}

.run-row .when {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: 0.05em;
}
.run-row .when .full { display: block; color: var(--ink-4); margin-top: 2px; font-size: 10px; }

.run-row .body {
  display: grid;
  gap: 4px;
}
.run-row .body .title {
  font-family: var(--font-display);
  font-size: 17px;
  color: var(--ink);
  letter-spacing: -0.006em;
  font-weight: 400;
  line-height: 1.35;
}
.run-row .body .tags {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--ink-3);
  display: flex;
  gap: 14px;
}
.run-row .progress {
  display: flex;
  gap: 4px;
  align-items: center;
}
.run-row .progress .pip {
  width: 10px; height: 10px;
  border-radius: 50%;
  border: 1px solid var(--hairline-strong);
  background: transparent;
}
.run-row .progress .pip.done { background: var(--hero); border-color: var(--hero); }
.run-row .progress .pip.active { background: var(--hero); border-color: var(--hero); animation: dotpulse 1.4s ease-out infinite; }

.run-row .open-link {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  transition: color .18s, transform .2s;
}
.run-row:hover .open-link { color: var(--hero); transform: translateX(2px); }

.empty-state {
  padding: 80px 24px;
  text-align: center;
  border: 1px dashed var(--hairline);
  border-radius: 6px;
  background:
    repeating-linear-gradient(45deg,
      transparent 0px,
      transparent 12px,
      color-mix(in oklch, var(--ink) 4%, transparent) 12px,
      color-mix(in oklch, var(--ink) 4%, transparent) 13px);
  margin-top: 24px;
}
.empty-state h3 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 22px;
  margin: 6px 0;
}
.empty-state p { color: var(--ink-3); font-size: 14px; max-width: 46ch; margin: 0 auto 22px; font-style: italic; font-family: var(--font-display); }

.floating-new {
  position: fixed;
  right: 28px;
  bottom: 28px;
  z-index: 20;
}

/* ============================================================
   RUN DETAIL — THE HEART
   ============================================================ */
.detail {
  max-width: 1240px;
  margin: 0 auto;
  padding: 32px 32px 80px;
  display: grid;
  gap: 36px;
}

/* Breadcrumb */
.crumb {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.crumb a { color: var(--ink-3); cursor: pointer; }
.crumb a:hover { color: var(--ink); }
.crumb .sep { color: var(--ink-4); }
.crumb .id { color: var(--hero); }

/* --- Run header --- */
.run-header {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 32px;
  align-items: start;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--hairline-soft);
}
.run-header .status-line {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}
.run-header h1 {
  font-family: var(--font-display);
  font-weight: 300;
  font-size: 32px;
  letter-spacing: -0.012em;
  line-height: 1.18;
  margin: 0 0 18px;
  max-width: 64ch;
}
.run-header .briefing-block {
  position: relative;
  padding-left: 22px;
  border-left: 1px solid var(--hairline);
  color: var(--ink-2);
  font-family: var(--font-display);
  font-size: 15px;
  line-height: 1.55;
  max-width: 78ch;
}
.run-header .briefing-block::before {
  content: "BRIEFING";
  position: absolute;
  top: -2px;
  left: 22px;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.2em;
  color: var(--ink-3);
  background: var(--bg);
  padding: 0 8px;
  transform: translateY(-50%);
}

.run-meta {
  display: grid;
  gap: 14px;
  min-width: 230px;
}
.run-meta .row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  font-size: 12px;
  padding: 7px 0;
  border-bottom: 1px solid var(--hairline-soft);
}
.run-meta .row:last-child { border-bottom: none; }
.run-meta .label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.run-meta .val { font-family: var(--font-mono); color: var(--ink-2); }
.run-meta .actions { display: flex; gap: 8px; margin-top: 8px; }

/* --- THE PRESS — pipeline visualization --- */
.press {
  display: flex;
  align-items: stretch;
  gap: 0;
  padding: 28px 8px 22px;
  border-bottom: 1px solid var(--hairline-soft);
  position: relative;
}

/* Press: two-part layout with Grounding + Iteration stages */
.press-grounding {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  flex-shrink: 0;
}

.press-divider {
  width: 1px;
  background: var(--hairline-soft);
  align-self: stretch;
  margin: 8px 12px;
  flex-shrink: 0;
}

.press-iteration {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  align-items: center;
  flex: 1;
  position: relative;
}
.press::before {
  content: "PIPELINE — THE CREW AT WORK";
  position: absolute;
  top: -8px;
  left: 8px;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.22em;
  color: var(--ink-3);
  background: var(--bg);
  padding: 0 8px;
}
.stage {
  position: relative;
  padding: 4px 18px;
  text-align: center;
}
.stage .role {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.stage .name {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 400;
  margin-top: 6px;
  letter-spacing: -0.005em;
  color: var(--ink-2);
}
.stage .desc {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 12px;
  color: var(--ink-3);
  margin-top: 4px;
}
.stage.active .name { color: var(--hero); }
.stage.done .name { color: var(--ink); }
.stage .seal {
  width: 36px; height: 36px;
  border: 1px solid var(--hairline-strong);
  border-radius: 50%;
  display: grid; place-items: center;
  margin: 0 auto 10px;
  font-family: var(--font-display);
  font-size: 16px;
  color: var(--ink-3);
  background: var(--surface);
  position: relative;
  z-index: 2;
  transition: color .25s, border-color .25s, background .25s;
}
.stage.done .seal {
  color: var(--hero);
  border-color: var(--hero);
  background: color-mix(in oklch, var(--hero) 12%, var(--surface));
}
.stage.active .seal {
  color: var(--on-hero);
  background: var(--hero);
  border-color: var(--hero);
  box-shadow: 0 0 0 0 color-mix(in oklch, var(--hero) 60%, transparent);
  animation: pulse 1.8s ease-out infinite;
}

/* ink ribbon between stages */
.press .ribbon {
  position: absolute;
  top: 38px;
  height: 1px;
  background: var(--hairline);
  overflow: hidden;
}
.press .ribbon::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  background: var(--hero);
  width: var(--ink, 0%);
  transition: width 1.2s ease;
}
.press .ribbon.r1 { left: calc(16.66% + 26px); right: calc(50% + 26px); }
.press .ribbon.r2 { left: calc(50% + 26px); right: calc(16.66% + 26px); }

/* --- ITERATIONS PANELS --- */
.iters {
  display: grid;
  gap: 22px;
}
.iter {
  border: 1px solid var(--hairline-soft);
  border-radius: 4px;
  background: var(--surface);
  overflow: hidden;
  transition: border-color .2s;
}
.iter.active { border-color: var(--hero); box-shadow: 0 24px 60px -40px color-mix(in oklch, var(--hero) 60%, transparent); }
.iter-head {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 18px;
  align-items: center;
  padding: 14px 22px;
  cursor: pointer;
  border-bottom: 1px solid transparent;
  transition: background .15s, border-color .2s;
}
.iter-head:hover { background: var(--surface-2); }
.iter.open .iter-head { border-bottom-color: var(--hairline-soft); }
.iter-head .num {
  font-family: var(--font-display);
  font-size: 22px;
  color: var(--ink-2);
  letter-spacing: -0.01em;
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.iter-head .num .label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.iter-head .summary {
  font-family: var(--font-display);
  font-size: 15px;
  color: var(--ink-2);
  font-style: italic;
}
.iter-head .summary .arrow { color: var(--hero); margin: 0 8px; font-style: normal; }
.iter-head .findings-count {
  display: flex;
  gap: 8px;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
}
.iter-head .findings-count .pill {
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid currentColor;
}
.iter-head .findings-count .pill.crit { color: var(--sv-critical); }
.iter-head .findings-count .pill.maj  { color: var(--sv-major); }
.iter-head .findings-count .pill.min  { color: var(--sv-minor); }
.iter-head .findings-count .pill.inf  { color: var(--sv-info); }

.iter-head .caret { transition: transform .25s; color: var(--ink-3); }
.iter.open .iter-head .caret { transform: rotate(90deg); color: var(--hero); }

.iter-body {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 0;
  max-height: 0;
  overflow: hidden;
  transition: max-height .35s ease;
}
.iter.open .iter-body { max-height: 2000px; }

.artifact {
  border-right: 1px solid var(--hairline-soft);
  font-family: var(--font-display);
  font-size: 15px;
  line-height: 1.62;
  color: var(--ink);
  max-height: 640px;
  overflow-y: auto;
  min-width: 0;
  min-height: 0;
  position: relative;
}
.artifact-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 22px;
  background: color-mix(in oklch, var(--surface) 92%, transparent);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--hairline-soft);
}
.artifact .md.prose {
  padding: 22px 32px 30px 32px;
  min-width: 0;
}

/* --- Rendered Markdown typography --- */
.md {
  overflow-wrap: anywhere;
  word-break: break-word;
}
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md h1, .md h2, .md h3, .md h4, .md h5, .md h6 {
  font-family: var(--font-display);
  font-weight: 500;
  letter-spacing: -0.008em;
  line-height: 1.25;
  margin: 26px 0 8px;
}
.md h1 { font-size: 26px; font-weight: 400; }
.md h2 { font-size: 21px; }
.md h3 { font-size: 18px; }
.md h4, .md h5, .md h6 { font-size: 15px; }
.md p { margin: 0 0 12px; }
.md ul, .md ol { margin: 0 0 12px; padding-left: 24px; }
.md li { margin-bottom: 5px; line-height: 1.6; }
.md li > ul, .md li > ol { margin: 5px 0 0; }
.md a { color: var(--hero-deep); text-decoration: underline; text-underline-offset: 2px; }
.md em { font-style: italic; }
.md strong { font-weight: 600; }
.md hr { border: 0; border-top: 1px solid var(--hairline-soft); margin: 22px 0; }
.md blockquote {
  margin: 12px 0;
  padding: 4px 16px;
  border-left: 3px solid var(--hero);
  color: var(--ink-2);
  font-style: italic;
}
.md code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: 3px;
}
.md pre {
  background: var(--bg-deep);
  border: 1px solid var(--hairline-soft);
  border-radius: 4px;
  padding: 14px 16px;
  margin: 0 0 14px;
  overflow-x: auto;
  white-space: pre;
}
.md pre code {
  background: none;
  padding: 0;
  font-size: 12.5px;
  line-height: 1.55;
}
.md table {
  border-collapse: collapse;
  width: 100%;
  margin: 0 0 14px;
  font-size: 13.5px;
  display: block;
  overflow-x: auto;
}
.md th, .md td {
  border: 1px solid var(--hairline-soft);
  padding: 6px 10px;
  text-align: left;
}
.md th { background: var(--surface-2); font-weight: 600; }
.md img { max-width: 100%; height: auto; border-radius: 4px; }
.md.prose em { color: var(--hero); }

/* Findings — margin / annotation style */
.findings {
  padding: 22px 22px 22px 22px;
  background: var(--bg-deep);
  position: relative;
  max-height: 640px;
  overflow-y: auto;
  min-width: 0;
  min-height: 0;
}
.findings::before {
  content: "MARGIN NOTES";
  display: block;
  margin-bottom: 16px;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.2em;
  color: var(--ink-3);
}
.finding {
  position: relative;
  padding: 0 0 18px 18px;
  margin-bottom: 14px;
  border-left: 2px solid currentColor;
  border-bottom: 1px dashed var(--hairline-soft);
}
.finding:last-child { border-bottom: none; padding-bottom: 6px; margin-bottom: 0; }
.finding.crit { color: var(--sv-critical); }
.finding.maj  { color: var(--sv-major); }
.finding.min  { color: var(--sv-minor); }
.finding.inf  { color: var(--sv-info); }
.finding .top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.finding .reviewer {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.finding .msg {
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 13.5px;
  line-height: 1.55;
}
.finding .resolved {
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--st-completed);
  display: inline-flex; align-items: center; gap: 6px;
}

/* --- Iteration → Iteration evolution rail --- */
.evolution {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 24px;
  background: var(--bg);
  border-top: 1px solid var(--hairline-soft);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: 0.06em;
}
.evolution strong { color: var(--hero); font-weight: 500; font-family: var(--font-mono); }

/* --- Final manuscript --- */
.manuscript-wrap {
  margin-top: 8px;
  position: relative;
}
.manuscript-wrap .head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
  margin-bottom: 14px;
}
.manuscript-wrap .head h2 {
  font-family: var(--font-display);
  font-weight: 300;
  font-size: 32px;
  margin: 0;
  letter-spacing: -0.012em;
}
.manuscript-wrap .head .sub {
  color: var(--ink-3);
  font-style: italic;
  font-family: var(--font-display);
  font-size: 13px;
}
.manuscript-wrap .head .actions { display: flex; gap: 8px; }

.manuscript {
  background: var(--paper);
  color: var(--paper-ink);
  padding: 64px 92px 80px;
  border-radius: 2px;
  position: relative;
  font-family: var(--font-display);
  box-shadow:
    0 1px 0 var(--paper-2),
    0 2px 0 var(--paper),
    0 3px 0 var(--paper-2),
    0 40px 80px -40px color-mix(in oklch, black 40%, transparent);
}
.manuscript::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.1  0 0 0 0 0.08  0 0 0 0 0.06  0 0 0 0.25 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  opacity: 0.5;
  mix-blend-mode: multiply;
  border-radius: inherit;
}
.manuscript > * { position: relative; }
.manuscript .colophon {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--paper-ink-2);
  margin-bottom: 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--paper-rule);
  padding-bottom: 14px;
}
.manuscript h1.title {
  font-family: var(--font-display);
  font-weight: 300;
  font-size: 44px;
  line-height: 1.08;
  letter-spacing: -0.02em;
  margin: 0 0 28px;
  color: var(--paper-ink);
  max-width: 28ch;
}
.manuscript h2 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 20px;
  margin: 28px 0 10px;
  letter-spacing: -0.005em;
}
.manuscript p {
  font-size: 16px;
  line-height: 1.72;
  margin: 0 0 14px;
  max-width: 65ch;
  color: var(--paper-ink);
}
.manuscript .math {
  font-family: var(--font-mono);
  font-size: 14px;
  background: var(--paper-2);
  border-left: 2px solid var(--hero-deep);
  padding: 10px 14px;
  display: block;
  margin: 10px 0 14px;
  color: var(--paper-ink);
}
.manuscript em { font-style: italic; }
.manuscript strong { font-weight: 600; }
.manuscript ul, .manuscript ol { padding-left: 22px; margin: 8px 0 14px; max-width: 64ch; }
.manuscript li { margin-bottom: 6px; line-height: 1.6; font-size: 15px; }
.manuscript .body-text { color: var(--paper-ink); }
.manuscript .body-text h1 {
  font-family: var(--font-display);
  font-weight: 300;
  font-size: 40px;
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin: 0 0 26px;
  color: var(--paper-ink);
}
.manuscript .body-text h2 { color: var(--paper-ink); }
.manuscript .body-text h3 { font-size: 17px; margin: 22px 0 8px; }
.manuscript .body-text a { color: var(--hero-deep); }
.manuscript .body-text code {
  background: var(--paper-2);
  color: var(--paper-ink);
}
.manuscript .body-text pre {
  background: var(--paper-2);
  border-color: var(--paper-rule);
}
.manuscript .body-text pre code { color: var(--paper-ink); }
.manuscript .body-text blockquote {
  border-left-color: var(--hero-deep);
  color: var(--paper-ink-2);
}
.manuscript .body-text th { background: var(--paper-2); }
.manuscript .body-text th, .manuscript .body-text td { border-color: var(--paper-rule); }
.manuscript .drop {
  float: left;
  font-family: var(--font-display);
  font-size: 64px;
  line-height: 0.85;
  font-weight: 400;
  padding: 6px 10px 0 0;
  color: var(--hero-deep);
}
.manuscript .signature {
  margin-top: 36px;
  border-top: 1px solid var(--paper-rule);
  padding-top: 18px;
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--paper-ink-2);
}

/* --- Reconnect modal --- */
#blazor-error-ui { display: none; }
.reconnect {
  position: fixed;
  bottom: 28px; left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--ink-2);
  z-index: 40;
  box-shadow: 0 20px 50px -20px color-mix(in oklch, black 50%, transparent);
}
.reconnect .spinner {
  width: 12px; height: 12px;
  border: 1.5px solid var(--hairline-strong);
  border-top-color: var(--hero);
  border-radius: 50%;
  animation: spin 1.1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Loading state — inkwell --- */
.loading-stage {
  display: grid;
  place-items: center;
  padding: 120px 24px;
}
.inkwell {
  width: 64px; height: 64px;
  border: 1px solid var(--hairline-strong);
  border-radius: 50%;
  position: relative;
  overflow: hidden;
  background: var(--surface);
}
.inkwell::before {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 100%;
  background: var(--hero);
  animation: fill 1.6s ease-in-out infinite;
}
@keyframes fill {
  0%, 100% { transform: translateY(80%); }
  50%      { transform: translateY(30%); }
}
.loading-stage .label {
  margin-top: 18px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-3);
}

/* --- Style guide page --- */
.guide {
  max-width: 1180px;
  margin: 0 auto;
  padding: 56px 32px 80px;
}
.guide section { margin-bottom: 56px; }
.guide h2 {
  font-family: var(--font-display);
  font-weight: 300;
  font-size: 28px;
  letter-spacing: -0.012em;
  margin: 0 0 18px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--hairline-soft);
}
.swatch-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
}
.swatch {
  border: 1px solid var(--hairline-soft);
  border-radius: 4px;
  overflow: hidden;
  background: var(--surface);
}
.swatch .chip {
  height: 78px;
  position: relative;
}
.swatch .label {
  padding: 8px 10px;
  display: grid;
  gap: 2px;
}
.swatch .name { font-family: var(--font-mono); font-size: 11px; color: var(--ink-2); }
.swatch .val { font-family: var(--font-mono); font-size: 10px; color: var(--ink-3); letter-spacing: 0.04em; }

.type-row {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 24px;
  padding: 16px 0;
  border-bottom: 1px solid var(--hairline-soft);
  align-items: baseline;
}
.type-row:last-child { border-bottom: none; }
.type-row .ttl {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
}

/* --- Misc small bits --- */
.kbd {
  font-family: var(--font-mono);
  font-size: 10px;
  border: 1px solid var(--hairline);
  border-bottom-width: 2px;
  padding: 1px 5px;
  border-radius: 4px;
  color: var(--ink-2);
  background: var(--surface);
}

.scroll-x-hide::-webkit-scrollbar { width: 8px; height: 8px; }
.scroll-x-hide::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 999px; }
.scroll-x-hide::-webkit-scrollbar-track { background: transparent; }

/* ── z-index layers ─────────────────────────────────────── */
:root {
    --z-modal: 1000;
}

/* ── crew-badge ─────────────────────────────────────────── */
.crew-badge {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    background: var(--surface-2);
    color: var(--ink-2);
    border: 1px solid var(--hairline);
    white-space: nowrap;
}

/* ── disabled-action (for read-only system profile buttons) */
.disabled-action {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}

/* ── collapsible sections ───────────────────────────────── */
.collapsible-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    user-select: none;
    color: var(--ink-2);
    font-size: 0.875rem;
}

.collapsible-header:hover {
    color: var(--ink);
}

.collapsible-body {
    margin-top: 0.75rem;
}

/* ── Crew UI — shared page layout ───────────────────────── */
.crew-index,
.crew-templates-index,
.crew-profiles-index,
.studio-page,
.user-management,
.learnings-index {
    max-width: 1180px;
    margin: 0 auto;
    padding: 40px 32px 80px;
}

.studio-subtitle {
    color: var(--ink-2);
    font-size: 0.9375rem;
    margin: 0;
}

/* ── Studio — analyzing step ─────────────────────────────── */
.studio-analyzing {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
    padding: 3rem 1rem;
    text-align: center;
}

.analyzing-spinner {
    width: 2.5rem;
    height: 2.5rem;
    border: 3px solid color-mix(in oklch, var(--hero) 25%, transparent);
    border-top-color: var(--hero);
    border-radius: 50%;
    animation: studio-spin 0.9s linear infinite;
}

@keyframes studio-spin {
    to { transform: rotate(360deg); }
}

.analyzing-status {
    margin: 0.4rem 0 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--ink);
}

.analyzing-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0;
    font-size: 0.85rem;
    color: var(--ink-2);
}

.analyzing-model {
    font-family: var(--font-mono, monospace);
    padding: 0.15rem 0.5rem;
    background: var(--surface-2, var(--surface));
    border: 1px solid var(--hairline);
    border-radius: 6px;
}

.analyzing-elapsed {
    font-variant-numeric: tabular-nums;
    color: var(--ink-3);
}

@media (prefers-reduced-motion: reduce) {
    .analyzing-spinner { animation-duration: 2.5s; }
}

/* ── Studio — analysis model section ─────────────────────── */
.studio-model-section {
    margin: 1rem 0 1.5rem;
    border: 1px solid var(--hairline);
    border-radius: 10px;
    background: var(--surface-2, var(--surface));
}

.studio-model-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    cursor: pointer;
    list-style: none;
    user-select: none;
}

.studio-model-summary::-webkit-details-marker {
    display: none;
}

.studio-model-summary::before {
    content: "▸";
    color: var(--ink-3);
    font-size: 0.75rem;
    transition: transform 0.15s;
}

.studio-model-section[open] .studio-model-summary::before {
    transform: rotate(90deg);
}

.studio-model-summary-label {
    flex: 1;
    font-size: 0.8125rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--ink-3);
}

.studio-model-summary-value {
    font-family: var(--font-mono, monospace);
    font-size: 0.8125rem;
    color: var(--ink-2);
}

.studio-model-body {
    padding: 0.5rem 1rem 1rem;
    border-top: 1px solid var(--hairline);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.studio-max-tokens-input {
    width: 160px;
    padding: 0.5rem 0.625rem;
    background: var(--surface);
    border: 1px solid var(--hairline-strong);
    border-radius: 6px;
    font-size: 0.875rem;
    color: var(--ink);
    font-family: inherit;
}

.studio-max-tokens-input:focus {
    outline: none;
    border-color: var(--hero);
    box-shadow: 0 0 0 2px color-mix(in oklch, var(--hero) 20%, transparent);
}

.studio-save-default {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    font-size: 0.875rem;
    color: var(--ink-2);
    cursor: pointer;
}

.studio-save-default input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    accent-color: var(--hero);
    cursor: pointer;
}

/* ══ Studio — Edit/Create step ════════════════════════════════ */
.studio-edit {
    max-width: 900px;
    margin: 0 auto;
    padding-bottom: 7rem; /* room for sticky action bar */
}

.studio-edit > h2 {
    margin: 0 0 0.35rem;
    font-size: 1.5rem;
}

.edit-hint {
    color: var(--ink-2);
    font-size: 0.9375rem;
    margin: 0 0 1.5rem;
}

/* Sections as cards */
.edit-section {
    border: 1px solid var(--hairline);
    border-radius: 12px;
    background: var(--surface);
    padding: 1.25rem 1.35rem 1.1rem;
    margin-bottom: 1.25rem;
}

.edit-section > h3 {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    margin: 0 0 1rem;
    padding-bottom: 0.7rem;
    border-bottom: 1px solid var(--hairline-soft);
    font-size: 0.8125rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ink-2);
}

.optional-label {
    font-size: 0.75rem;
    font-weight: 400;
    letter-spacing: 0;
    text-transform: none;
    color: var(--ink-3);
}

/* Slot row = the collapsible card + its action toolbar */
.slot-row { margin-bottom: 0.85rem; }
.slot-row .studio-slot { margin-bottom: 0; }

.slot-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.35rem;
    margin-top: 0.35rem;
}

.slot-add-actions { margin-top: 0.5rem; }

/* Collapsible slot card */
.studio-slot {
    border: 1px solid var(--hairline);
    border-radius: 10px;
    background: var(--surface-2, var(--surface));
    margin-bottom: 0.85rem;
    overflow: hidden;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.studio-slot.is-open {
    border-color: color-mix(in oklch, var(--hero) 35%, var(--hairline));
    box-shadow: 0 1px 3px color-mix(in oklch, var(--ink) 8%, transparent);
}
.studio-slot--invalid {
    border-color: color-mix(in oklch, var(--sv-critical) 55%, transparent) !important;
}

/* Header is a full-width clickable button */
.studio-slot-header {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    width: 100%;
    padding: 0.7rem 0.9rem;
    background: transparent;
    border: none;
    cursor: pointer;
    text-align: left;
    font: inherit;
    color: var(--ink);
}
.studio-slot-header:hover { background: color-mix(in oklch, var(--hero) 5%, transparent); }

.slot-chevron {
    color: var(--ink-3);
    font-size: 0.7rem;
    width: 0.8rem;
    flex-shrink: 0;
}

.studio-slot-label {
    font-weight: 600;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.slot-summary {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--ink-2);
    font-size: 0.875rem;
}

.slot-mode-pill {
    flex-shrink: 0;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    padding: 0.12rem 0.5rem;
    border-radius: 999px;
}
.slot-mode-pill.is-existing {
    background: color-mix(in oklch, var(--ink-3) 14%, transparent);
    color: var(--ink-2);
}
.slot-mode-pill.is-new {
    background: color-mix(in oklch, var(--hero) 16%, transparent);
    color: var(--hero-deep, var(--hero));
}

.slot-invalid-dot {
    flex-shrink: 0;
    width: 1.05rem;
    height: 1.05rem;
    border-radius: 50%;
    background: var(--sv-critical);
    color: var(--on-hero, #fff);
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1.05rem;
    text-align: center;
}

.studio-slot-body {
    padding: 0.9rem 0.9rem 1rem;
    border-top: 1px solid var(--hairline-soft);
}

/* Segmented mode toggle */
.studio-slot-toggle {
    display: inline-flex;
    margin-bottom: 1rem;
    border: 1px solid var(--hairline-strong, var(--hairline));
    border-radius: 8px;
    overflow: hidden;
    background: var(--surface);
}
.studio-slot-toggle .toggle-btn {
    padding: 0.4rem 0.9rem;
    border: none;
    background: transparent;
    color: var(--ink-2);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.studio-slot-toggle .toggle-btn + .toggle-btn { border-left: 1px solid var(--hairline-soft); }
.studio-slot-toggle .toggle-btn.active {
    background: var(--hero);
    color: var(--on-hero, #fff);
}

/* Two-column field grid inside a create-new slot */
.slot-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 1rem;
}
.slot-fields .field { margin-bottom: 0.9rem; }
.slot-fields .field--full { grid-column: 1 / -1; }

/* Reasoning hint boxes — subtle, not dominating */
.field-reasoning {
    margin-top: 0.35rem;
    padding: 0.45rem 0.6rem;
    background: color-mix(in oklch, var(--st-completed, var(--hero)) 8%, transparent);
    border-left: 2px solid color-mix(in oklch, var(--st-completed, var(--hero)) 45%, transparent);
    border-radius: 0 6px 6px 0;
    font-size: 0.8rem;
    color: var(--ink-2);
    line-height: 1.45;
}
.field-reasoning.overall-reasoning {
    background: color-mix(in oklch, var(--hero) 7%, transparent);
    border-left-color: color-mix(in oklch, var(--hero) 45%, transparent);
}

/* Inputs/selects/textarea consistency inside slots, template section & all crew editors */
.studio-edit select,
.studio-edit textarea,
.studio-slot select,
.studio-slot textarea,
.crew-editor select,
.crew-editor textarea,
.crew-editor input[type="text"],
.crew-editor input[type="email"],
.crew-editor input[type="number"],
.crew-editor input[type="password"],
.crew-editor input[type="url"] {
    font-family: var(--font-ui);
    font-size: 14px;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--hairline-soft);
    border-radius: 6px;
    padding: 10px 12px;
    outline: none;
    width: 100%;
    box-sizing: border-box;
    transition: border-color 0.18s, background 0.18s;
}
.studio-edit select:focus,
.studio-edit textarea:focus,
.studio-slot select:focus,
.studio-slot textarea:focus,
.crew-editor select:focus,
.crew-editor textarea:focus,
.crew-editor input:focus { border-color: var(--hero); background: var(--surface-2); }
.crew-editor input:disabled,
.crew-editor select:disabled,
.crew-editor textarea:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background: color-mix(in oklch, var(--ink-3) 6%, var(--surface));
}

.checkbox-field label {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    text-transform: none;
    letter-spacing: 0;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--ink);
    cursor: pointer;
}
.checkbox-field input[type="checkbox"] {
    width: 1rem; height: 1rem; accent-color: var(--hero); cursor: pointer;
}

.validation-error {
    color: var(--sv-critical);
    font-size: 0.78rem;
}
.validation-panel {
    margin: 1rem 0;
    padding: 0.75rem 1rem;
    background: color-mix(in oklch, var(--sv-critical) 10%, transparent);
    border: 1px solid color-mix(in oklch, var(--sv-critical) 40%, transparent);
    border-radius: 8px;
    color: var(--sv-critical);
    font-size: 0.875rem;
}

/* Small ghost buttons used for slot actions */
.btn.btn-sm {
    padding: 0.3rem 0.6rem;
    font-size: 0.78rem;
}
.btn.btn-sm.danger { color: var(--sv-critical); }
.btn.btn-sm.danger:hover { background: color-mix(in oklch, var(--sv-critical) 12%, transparent); }

/* Sticky action bar always reachable */
.edit-actions {
    position: sticky;
    bottom: 0;
    display: flex;
    gap: 0.75rem;
    padding: 1rem 0.25rem;
    margin-top: 1rem;
    background: linear-gradient(to top, var(--bg) 70%, transparent);
    z-index: 5;
}

.crew-editor {
    max-width: 760px;
    margin: 0 auto;
    padding: 40px 32px 96px;
}

/* ══ Crew editors — unified design (applies to every /crew editor) ══ */

/* The form body is a clean card panel… */
.crew-editor form {
    background: var(--surface);
    border: 1px solid var(--hairline);
    border-radius: 12px;
    padding: 1.5rem 1.5rem 0.5rem;
}
/* …unless the editor already groups its content into .edit-section cards,
   in which case the form is transparent and the sections are the cards. */
.crew-editor form:has(.edit-section),
.crew-editor form:has(.template-meta-section) {
    background: transparent;
    border: none;
    padding: 0;
}

.crew-editor .field { margin-bottom: 1.1rem; }
.crew-editor .field > small,
.crew-editor .form-hint,
.crew-editor .field-hint {
    font-size: 0.8rem;
    color: var(--ink-3);
    line-height: 1.45;
}

/* Opt-in two-column field grid */
.field-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 1rem;
}
.field-grid .field--full { grid-column: 1 / -1; }

/* Checkboxes & inline checkbox labels */
.crew-editor input[type="checkbox"] {
    width: 1rem; height: 1rem; accent-color: var(--hero); cursor: pointer;
}
.form-checkbox-label,
.crew-editor .checkbox-field label {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    cursor: pointer;
    font-size: 0.875rem;
}

/* Radio groups (evaluation strategy, advisor mode/trigger) */
.crew-editor .radio-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.crew-editor .radio-option {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--hairline-soft);
    border-radius: 8px;
    cursor: pointer;
    font-weight: 400;
    font-size: 0.875rem;
    transition: border-color 0.15s, background 0.15s;
}
.crew-editor .radio-option:hover { border-color: var(--hairline-strong, var(--hairline)); }
.crew-editor .radio-option:has(input:checked) {
    border-color: var(--hero);
    background: color-mix(in oklch, var(--hero) 7%, transparent);
}
.crew-editor .radio-option input[type="radio"] { accent-color: var(--hero); }
.crew-editor .radio-option .radio-description {
    display: block;
    font-size: 0.78rem;
    color: var(--ink-3);
    margin-top: 0.1rem;
}

/* Collapsible "Advanced" sections */
.crew-editor .collapsible-section {
    border: 1px solid var(--hairline);
    border-radius: 10px;
    margin: 1.25rem 0;
    background: var(--surface-2, var(--surface));
}
.crew-editor .collapsible-header {
    padding: 0.7rem 0.95rem;
    cursor: pointer;
    font-size: 0.8125rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--ink-2);
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.crew-editor .collapsible-header::-webkit-details-marker { display: none; }
.crew-editor .collapsible-header::before {
    content: "▸"; color: var(--ink-3); font-size: 0.7rem; transition: transform 0.15s;
}
.crew-editor .collapsible-section[open] .collapsible-header::before { transform: rotate(90deg); }
.crew-editor .collapsible-body { padding: 0.25rem 0.95rem 0.6rem; border-top: 1px solid var(--hairline-soft); }

/* Validation summary from EditForm */
.crew-editor .validation-summary,
.crew-editor .validation-errors {
    margin: 0 0 1rem;
    padding: 0.7rem 0.95rem;
    list-style: none;
    background: color-mix(in oklch, var(--sv-critical) 10%, transparent);
    border: 1px solid color-mix(in oklch, var(--sv-critical) 40%, transparent);
    border-radius: 8px;
    color: var(--sv-critical);
    font-size: 0.85rem;
}
.crew-editor .validation-message { color: var(--sv-critical); font-size: 0.78rem; }

/* Sticky action footer — always reachable */
.crew-editor .editor-actions,
.crew-editor .form-actions {
    position: sticky;
    bottom: 0;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin: 1.5rem 0 0;
    padding: 0.9rem 0;
    background: linear-gradient(to top, var(--bg) 72%, transparent);
    z-index: 5;
}
.crew-editor .btn.danger {
    margin-left: auto;
    color: var(--sv-critical);
}
.crew-editor .btn.danger:hover { background: color-mix(in oklch, var(--sv-critical) 12%, transparent); }

/* ── Pipeline-Stage Sections (CrewTemplateEditor) ───────────── */

/* Shared card base for both meta and pipeline sections — same as .edit-section */
.template-meta-section,
.pipeline-stage-section {
    border: 1px solid var(--hairline);
    border-radius: 12px;
    background: var(--surface);
    padding: 1.25rem 1.5rem 1.25rem;
    margin-bottom: 1.25rem;
}

.template-meta-section h3 {
    margin: 0 0 1rem;
    font-size: 0.8125rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ink-2);
}

/* Pipeline stage: numbered header row */
.pipeline-stage-header {
    display: flex;
    align-items: flex-start;
    gap: 0.875rem;
    margin-bottom: 1.1rem;
    padding-bottom: 0.9rem;
    border-bottom: 1px solid var(--hairline-soft);
}

.stage-num-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 50%;
    background: var(--hero-soft);
    color: var(--hero);
    font-weight: 700;
    font-size: 0.78rem;
    margin-top: 0.05rem;
}

.pipeline-stage-header-text h3 {
    margin: 0 0 0.15rem;
    font-size: 0.875rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: none;
    color: var(--ink);
}

.pipeline-stage-desc {
    margin: 0;
    font-size: 0.78rem;
    color: var(--ink-3);
    line-height: 1.4;
}

/* ── Unified Profile Picker ───────────────────────────────── */
.profile-picker-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
}

.picker-col-label {
    margin: 0 0 0.5rem;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-3);
}

/* Pool (available) column */
.picker-pool-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    text-align: left;
    padding: 0.45rem 0.7rem;
    margin-bottom: 0.3rem;
    background: var(--surface-2);
    border: 1px solid var(--hairline-soft);
    border-radius: 7px;
    cursor: pointer;
    font-size: 0.83rem;
    color: var(--ink-2);
    transition: border-color 0.12s, color 0.12s, background 0.12s;
}

.picker-pool-item:hover {
    border-color: var(--hero);
    color: var(--ink);
    background: var(--hero-soft);
}

.picker-add-icon {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--hero);
    opacity: 0.65;
    flex-shrink: 0;
    line-height: 1;
    transition: opacity 0.12s;
}

.picker-pool-item:hover .picker-add-icon { opacity: 1; }

/* Active (selected) column */
.picker-active-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.625rem;
    margin-bottom: 0.3rem;
    background: var(--hero-soft);
    border: 1px solid color-mix(in oklch, var(--hero) 28%, transparent);
    border-radius: 7px;
    font-size: 0.83rem;
}

.picker-item-rank {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--hero);
    min-width: 1.1rem;
    text-align: right;
    flex-shrink: 0;
}

.picker-item-name {
    flex: 1;
    color: var(--ink);
    font-size: 0.83rem;
    line-height: 1.3;
}

.picker-item-meta {
    font-size: 0.75rem;
    color: var(--ink-3);
}

.picker-item-controls {
    display: flex;
    gap: 0.2rem;
    flex-shrink: 0;
}

.picker-empty-state {
    font-size: 0.8rem;
    color: var(--ink-4);
    margin: 0.5rem 0 0;
    font-style: italic;
}

/* Fields inside pipeline stage sections have no bottom margin (card padding is enough) */
.pipeline-stage-section > .field:last-child { margin-bottom: 0; }

/* ── Provider-Type Selector (GroundingProviderEditor) ─────── */
.provider-type-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.provider-type-card {
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--hairline);
    border-radius: 8px;
    background: var(--surface-2);
    cursor: pointer;
    text-align: left;
    font-size: 0.82rem;
    color: var(--ink-2);
    line-height: 1.35;
    transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.provider-type-card:hover:not([disabled]) {
    border-color: var(--hero);
    background: var(--hero-soft);
}

.provider-type-card.active {
    border-color: var(--hero);
    background: var(--hero-soft);
    color: var(--hero);
}

.provider-type-card[disabled] { opacity: 0.7; cursor: default; }

.provider-type-card .ptc-label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
}

.provider-type-card .ptc-desc {
    display: block;
    font-size: 0.73rem;
    color: var(--ink-3);
    margin-top: 0.15rem;
}

.provider-type-card.active .ptc-desc {
    color: color-mix(in oklch, var(--hero) 65%, var(--ink-3));
}

.provider-type-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.3rem 0.75rem;
    border-radius: 999px;
    background: var(--hero-soft);
    border: 1px solid color-mix(in oklch, var(--hero) 28%, transparent);
    color: var(--hero);
    font-size: 0.82rem;
    font-weight: 700;
    margin-top: 0.25rem;
}

.provider-type-hidden-select {
    position: absolute;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    width: 1px;
    height: 1px;
    overflow: hidden;
    white-space: nowrap;
}

.crew-index h1 {
    margin-bottom: 1.5rem;
}

/* ── Crew UI — page header ───────────────────────────────── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.page-header h1 {
    margin: 0;
    font-size: 1.75rem;
}

/* ── Knowledge doc list ─────────────────────────────────── */
.knowledge-doc-list {
    display: flex;
    flex-direction: column;
    border-top: 1px solid var(--hairline-soft);
    margin-top: 8px;
}
.knowledge-doc-card {
    display: grid;
    grid-template-columns: 44px 1fr auto;
    gap: 16px;
    align-items: center;
    padding: 18px 12px;
    border-bottom: 1px solid var(--hairline-soft);
    position: relative;
    transition: background .15s;
}
.knowledge-doc-card:hover {
    background: color-mix(in oklch, var(--surface) 60%, transparent);
}
.knowledge-doc-type-badge {
    font-family: var(--font-mono);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 5px 6px;
    border-radius: 3px;
    background: color-mix(in oklch, var(--hero) 10%, var(--surface));
    color: var(--hero);
    border: 1px solid color-mix(in oklch, var(--hero) 22%, transparent);
    text-align: center;
    line-height: 1;
    justify-self: start;
}
.knowledge-doc-main {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0;
}
.knowledge-doc-header {
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
}
.knowledge-doc-title {
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 400;
    letter-spacing: -0.005em;
    color: var(--ink);
    text-decoration: none;
    transition: color .15s;
}
.knowledge-doc-title:hover { color: var(--hero); }
.knowledge-doc-filename {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--ink-4);
    letter-spacing: 0.04em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.knowledge-doc-description {
    font-size: 13px;
    color: var(--ink-3);
    line-height: 1.5;
}
.knowledge-doc-footer {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 2px;
}
.knowledge-doc-meta {
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ink-4);
}
.knowledge-doc-delete {
    font-family: var(--font-mono);
    font-size: 14px;
    line-height: 1;
    padding: 5px 9px;
    border: 1px solid transparent;
    border-radius: 3px;
    background: transparent;
    color: var(--ink-4);
    cursor: pointer;
    opacity: 0;
    transition: opacity .15s, color .15s, border-color .15s, background .15s;
    align-self: center;
}
.knowledge-doc-card:hover .knowledge-doc-delete { opacity: 1; }
.knowledge-doc-delete:hover {
    color: var(--st-failed);
    border-color: var(--st-failed);
    background: color-mix(in oklch, var(--st-failed) 8%, transparent);
}

/* Indexing status badge colours */
.indexed-badge {
    color: var(--st-completed) !important;
    border-color: color-mix(in oklch, var(--st-completed) 28%, transparent) !important;
    background: color-mix(in oklch, var(--st-completed) 8%, transparent) !important;
}
.not-indexed-badge {
    color: var(--ink-3) !important;
}

.knowledge-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 1.5rem;
}

/* ── Knowledge doc detail ───────────────────────────────── */
.kdoc-meta-card {
    background: var(--surface);
    border: 1px solid var(--hairline);
    border-radius: 10px;
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.25rem;
}
.kdoc-meta-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--hairline-soft);
    flex-wrap: wrap;
}
.kdoc-filename {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--ink-3);
    flex: 1;
    letter-spacing: 0.03em;
}
.kdoc-meta-grid {
    display: grid;
    grid-template-columns: 110px 1fr;
    gap: 0.6rem 1rem;
    align-items: start;
}
.kdoc-key {
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-4);
    padding-top: 3px;
}
.kdoc-val {
    font-size: 13px;
    color: var(--ink-2);
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    line-height: 1.5;
}
.kdoc-section {
    background: var(--surface);
    border: 1px solid var(--hairline);
    border-radius: 10px;
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.25rem;
}
.kdoc-section-title {
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.10em;
    text-transform: uppercase;
    color: var(--ink-4);
    margin-bottom: 0.75rem;
}
.kdoc-section-body {
    font-size: 14px;
    color: var(--ink-2);
    line-height: 1.65;
}
.kdoc-content-preview {
    font-family: var(--font-mono);
    font-size: 11.5px;
    color: var(--ink-3);
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 340px;
    overflow-y: auto;
    padding: 2px 0;
}
.kdoc-content-preview::-webkit-scrollbar { width: 6px; }
.kdoc-content-preview::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 99px; }
.kdoc-content-preview::-webkit-scrollbar-track { background: transparent; }
.kdoc-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

/* ── Crew UI — tables ────────────────────────────────────── */
.crew-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.crew-table th,
.crew-table td {
    padding: 0.625rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--hairline);
}

.crew-table th {
    font-weight: 600;
    color: var(--ink-2);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.crew-table-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

/* ── Crew UI — editor form fields ───────────────────────── */
.crew-form {
    display: flex;
    flex-direction: column;
}

.form-row {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    margin-bottom: 1.25rem;
}

.form-row label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--ink-2);
}

.form-input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--hairline-strong);
    border-radius: 6px;
    background: var(--surface);
    color: var(--ink);
    font-size: 0.875rem;
    font-family: inherit;
    box-sizing: border-box;
}

.form-input:focus {
    outline: none;
    border-color: var(--hero);
    box-shadow: 0 0 0 2px color-mix(in oklch, var(--hero) 20%, transparent);
}

textarea.form-input {
    resize: vertical;
    min-height: 4rem;
}

.form-hint {
    font-size: 0.8125rem;
    color: var(--ink-2);
    margin-top: 0.125rem;
}

.form-actions,
.editor-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1.5rem;
}

/* ── Crew UI — info / status banners ────────────────────── */
.info-banner {
    padding: 0.75rem 1rem;
    background: color-mix(in oklch, var(--hero) 8%, var(--surface));
    border: 1px solid color-mix(in oklch, var(--hero) 30%, transparent);
    border-radius: 6px;
    font-size: 0.875rem;
    color: var(--ink-2);
    margin-bottom: 1.5rem;
}

/* ── Crew UI — hub index sections ───────────────────────── */
.crew-section {
    margin-bottom: 2rem;
    padding: 1.25rem;
    background: var(--surface-2, var(--bg-2));
    border-radius: 8px;
    border: 1px solid var(--hairline);
}

.crew-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.crew-section-header h2 {
    margin: 0;
    font-size: 1.125rem;
}

.crew-item-list {
    list-style: none;
    padding: 0;
    margin: 0 0 0.5rem 0;
}

.crew-item-list li {
    padding: 0.375rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border-bottom: 1px solid var(--hairline);
}

.crew-item-list li:last-child {
    border-bottom: none;
}

.view-all-link {
    font-size: 0.8125rem;
    color: var(--ink-2);
}

.view-all-link:hover {
    color: var(--ink);
}

/* ── Crew UI — radio groups (template editor) ───────────── */
.radio-group {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.radio-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-weight: normal;
}

/* ── Crew UI — misc utilities ────────────────────────────── */
.text-muted {
    color: var(--ink-2);
    font-size: 0.875rem;
    font-style: italic;
}

/* ── FileDropZone ────────────────────────────────────────── */
.file-drop-zone {
    border: 2px dashed var(--hairline-strong);
    border-radius: 8px;
    padding: 1.5rem 1rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    background: var(--surface-2, var(--bg-2));
    margin-bottom: 0.5rem;
}

.file-drop-zone:hover {
    border-color: var(--hero);
    background: color-mix(in oklch, var(--hero) 4%, var(--surface));
}

.file-drop-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.375rem;
    cursor: pointer;
    color: var(--ink-2);
    font-size: 0.875rem;
}

.file-drop-icon {
    font-size: 1.5rem;
    color: var(--ink-2);
    line-height: 1;
}

.file-drop-hint {
    font-size: 0.8125rem;
    color: var(--ink-2);
    opacity: 0.7;
}

.file-drop-list {
    list-style: none;
    margin: 0 0 0.5rem;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.file-drop-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.625rem;
    background: var(--surface);
    border: 1px solid var(--hairline);
    border-radius: 6px;
    font-size: 0.875rem;
}

.file-drop-name {
    flex: 1;
    color: var(--ink);
    font-family: var(--font-mono, monospace);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-drop-size {
    color: var(--ink-2);
    white-space: nowrap;
}

.file-drop-remove {
    padding: 2px 6px;
    font-size: 1rem;
    line-height: 1;
    flex-shrink: 0;
}

.file-drop-errors {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.file-drop-error {
    font-size: 0.8125rem;
    color: var(--st-failed, #dc2626);
    padding: 0.25rem 0.5rem;
    background: color-mix(in oklch, var(--st-failed, #dc2626) 8%, transparent);
    border-radius: 4px;
}

/* ── Attachment section on New.razor ─────────────────────── */
.attachment-section {
    margin-bottom: 1.25rem;
}

.attachment-section > label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--ink-2);
    margin-bottom: 0.5rem;
}

/* ── RunAttachmentsList ───────────────────────────────────── */
.run-attachments {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--surface-2, var(--bg-2));
    border: 1px solid var(--hairline);
    border-radius: 8px;
}

.run-attachments-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.run-attachment-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.625rem;
    background: var(--surface);
    border: 1px solid var(--hairline);
    border-radius: 6px;
}

.run-attachment-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    overflow: hidden;
}

.run-attachment-title {
    font-size: 0.875rem;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.run-attachment-meta {
    font-size: 0.8125rem;
    color: var(--ink-2);
}

/* ── Citation badges (GroundingSection) ──────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.125rem 0.5rem;
    border-radius: 999px;
    white-space: nowrap;
}

.badge-knowledge-base {
    background: color-mix(in oklch, var(--hero) 12%, transparent);
    color: var(--hero);
    border: 1px solid color-mix(in oklch, var(--hero) 30%, transparent);
}

.badge-attachment {
    background: color-mix(in oklch, #f59e0b 12%, transparent);
    color: #b45309;
    border: 1px solid color-mix(in oklch, #f59e0b 30%, transparent);
}

/* ── Admin UI — alerts ───────────────────────────────────── */
.alert {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    font-size: 0.875rem;
    margin-bottom: 1rem;
    border: 1px solid transparent;
}
.alert-danger {
    background: color-mix(in oklch, #ef4444 10%, var(--surface));
    border-color: color-mix(in oklch, #ef4444 35%, transparent);
    color: color-mix(in oklch, #ef4444 70%, var(--ink-1));
}
.alert-success {
    background: color-mix(in oklch, #22c55e 10%, var(--surface));
    border-color: color-mix(in oklch, #22c55e 35%, transparent);
    color: color-mix(in oklch, #22c55e 60%, var(--ink-1));
}

/* ── Admin UI — user/client list rows ───────────────────── */
.users-list {
    border: 1px solid var(--hairline);
    border-radius: 8px;
    overflow: hidden;
}
.user-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--hairline);
    background: var(--surface);
    transition: background 0.1s;
}
.user-row:last-child {
    border-bottom: none;
}
.user-row.editing {
    display: block;
    padding: 0;
}
.user-row:not(.editing):hover {
    background: var(--surface-2, var(--surface));
}
.user-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    min-width: 0;
}
.user-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}
.user-name {
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--ink-1);
}
.user-meta {
    font-size: 0.8125rem;
    color: var(--ink-3);
}
.delete-confirm-text {
    font-size: 0.8125rem;
    color: var(--ink-2);
}
.empty-state-inline {
    padding: 1.5rem 1rem;
    text-align: center;
    color: var(--ink-3);
    font-size: 0.875rem;
    font-style: italic;
}

/* ── Admin UI — badge variants ───────────────────────────── */
.badge-admin {
    background: color-mix(in oklch, var(--hero) 12%, transparent);
    color: var(--hero);
    border: 1px solid color-mix(in oklch, var(--hero) 30%, transparent);
}
.badge-inactive {
    background: color-mix(in oklch, #ef4444 10%, transparent);
    color: color-mix(in oklch, #ef4444 70%, var(--ink-1));
    border: 1px solid color-mix(in oklch, #ef4444 30%, transparent);
}

/* ── Admin UI — inline form (UserForm / create-client-form) ─ */
.user-form {
    padding: 1.25rem 1rem;
    background: var(--surface-2, var(--surface));
    border-bottom: 1px solid var(--hairline);
}
.user-form h3 {
    margin: 0 0 1rem;
    font-size: 1rem;
    font-weight: 600;
}
.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-bottom: 0.875rem;
}
.form-group label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--ink-2);
}
.form-group.form-check {
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
}
.form-group.form-check label {
    font-size: 0.875rem;
    color: var(--ink-1);
    font-weight: 400;
}
.form-control {
    width: 100%;
    padding: 0.5rem 0.625rem;
    background: var(--surface);
    border: 1px solid var(--hairline-strong);
    border-radius: 6px;
    font-size: 0.875rem;
    color: var(--ink-1);
    font-family: inherit;
    box-sizing: border-box;
    transition: border-color 0.15s;
}
.form-control:focus {
    outline: none;
    border-color: var(--hero);
    box-shadow: 0 0 0 2px color-mix(in oklch, var(--hero) 20%, transparent);
}
textarea.form-control {
    resize: vertical;
    min-height: 80px;
}

/* ── Site Settings admin form ────────────────────────────── */
.settings-page-wrap {
    max-width: 680px;
}
.settings-notice {
    padding: 0.875rem 1rem;
    background: color-mix(in oklch, var(--sv-minor) 12%, var(--surface));
    border: 1px solid color-mix(in oklch, var(--sv-minor) 40%, transparent);
    border-radius: 8px;
    font-size: 0.875rem;
    color: var(--ink-2);
    line-height: 1.5;
    margin-bottom: 1.75rem;
}
.settings-notice strong { color: var(--ink); }
.settings-form fieldset {
    border: 1px solid var(--hairline);
    border-radius: 10px;
    padding: 1.25rem 1.5rem 0.5rem;
    margin-bottom: 1.25rem;
    background: var(--surface-2, var(--surface));
}
.settings-form fieldset legend {
    padding: 0 0.5rem;
    font-size: 0.8125rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--ink-3);
}
.settings-form .form-group input,
.settings-form .form-group textarea {
    width: 100%;
    padding: 0.5rem 0.625rem;
    background: var(--surface);
    border: 1px solid var(--hairline-strong);
    border-radius: 6px;
    font-size: 0.875rem;
    color: var(--ink);
    font-family: inherit;
    box-sizing: border-box;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.settings-form .form-group input:focus,
.settings-form .form-group textarea:focus {
    outline: none;
    border-color: var(--hero);
    box-shadow: 0 0 0 2px color-mix(in oklch, var(--hero) 20%, transparent);
}
.settings-form .form-row {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 0;
}
.settings-form .form-row .form-group { flex: 1; margin-bottom: 0.875rem; }
.settings-form .field-help {
    font-size: 0.8rem;
    color: var(--ink-3);
    margin-top: 0.2rem;
    line-height: 1.4;
}
.settings-form .required { color: var(--sv-critical); }
.settings-legal-accept {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    background: color-mix(in oklch, var(--hero) 6%, var(--surface));
    border: 1px solid color-mix(in oklch, var(--hero) 25%, transparent);
    border-radius: 8px;
    margin-bottom: 1.25rem;
    cursor: pointer;
}
.settings-legal-accept input[type="checkbox"] {
    margin-top: 0.15rem;
    flex-shrink: 0;
    width: 1rem;
    height: 1rem;
    accent-color: var(--hero);
    cursor: pointer;
}
.settings-legal-accept-label {
    font-size: 0.875rem;
    color: var(--ink-2);
    line-height: 1.5;
}
.settings-legal-accept-label strong { color: var(--ink); }

/* ── Profile / Template read-only detail view ────────────── */
.profile-detail {
    display: grid;
    grid-template-columns: min(10rem, 30%) 1fr;
    margin: 0 0 1.5rem;
    border: 1px solid var(--hairline);
    border-radius: 8px;
    overflow: hidden;
}

.profile-detail dt {
    padding: 0.6875rem 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--ink-2);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--surface-2, var(--bg-2));
    border-right: 1px solid var(--hairline);
    border-bottom: 1px solid var(--hairline);
}

.profile-detail dd {
    margin: 0;
    padding: 0.6875rem 1rem;
    font-size: 0.875rem;
    color: var(--ink);
    border-bottom: 1px solid var(--hairline);
    word-break: break-word;
}

.profile-detail dt:last-of-type,
.profile-detail dd:last-child {
    border-bottom: none;
}

.system-prompt-view {
    font-family: var(--font-mono, monospace);
    font-size: 0.8rem;
    line-height: 1.55;
    white-space: pre-wrap;
    overflow-x: auto;
    max-height: 380px;
    overflow-y: auto;
    margin: 0;
    background: var(--surface-2, var(--bg-2));
    border: 1px solid var(--hairline);
    border-radius: 5px;
    padding: 0.75rem;
    color: var(--ink-2);
}

.profile-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    padding: 0;
    margin: 0;
    list-style: none;
}

.profile-chip {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.625rem;
    background: var(--surface-2, var(--bg-2));
    border: 1px solid var(--hairline);
    border-radius: 4px;
    font-size: 0.8125rem;
    color: var(--ink-2);
    white-space: nowrap;
}

.profile-chip-label {
    font-size: 0.75rem;
    color: var(--ink-3, var(--ink-2));
    margin-left: 0.375rem;
    opacity: 0.7;
}

/* ============================================================
   Docs Viewer — /docs and /docs/{slug}
   ============================================================ */
.docs-page {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 0;
    min-height: calc(100vh - 60px);
    align-items: start;
}
@media (max-width: 860px) {
    .docs-page {
        grid-template-columns: 1fr;
    }
}

/* Sidebar */
.docs-sidebar {
    position: sticky;
    top: 60px;
    height: calc(100vh - 60px);
    overflow-y: auto;
    border-right: 1px solid var(--hairline-soft);
    padding: 24px 0;
}
.docs-sidebar-header {
    padding: 0 20px 12px;
}
.docs-sidebar-label {
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--ink-3);
}
.docs-nav {
    display: flex;
    flex-direction: column;
}
.docs-nav-item {
    display: block;
    padding: 7px 20px;
    font-size: 13px;
    color: var(--ink-2);
    text-decoration: none;
    border-left: 2px solid transparent;
    transition: background .12s, color .12s, border-color .12s;
    line-height: 1.4;
}
.docs-nav-item:hover {
    background: var(--surface-2);
    color: var(--ink);
}
.docs-nav-item.active {
    border-left-color: var(--hero);
    color: var(--hero);
    background: color-mix(in oklch, var(--hero) 8%, transparent);
    font-weight: 500;
}
@media (max-width: 860px) {
    .docs-sidebar {
        position: static;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--hairline-soft);
        padding: 16px 0;
    }
    .docs-nav { flex-direction: row; flex-wrap: wrap; gap: 2px; padding: 0 12px; }
    .docs-nav-item { padding: 5px 10px; border-left: none; border-bottom: 2px solid transparent; }
    .docs-nav-item.active { border-bottom-color: var(--hero); border-left: none; }
}

/* Toolbar */
.docs-content {
    padding: 32px 48px;
    min-width: 0;
}
@media (max-width: 860px) {
    .docs-content { padding: 24px 18px; }
}
.docs-toolbar {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 20px;
}
.lang-toggle {
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ink-3);
    text-decoration: none;
    padding: 3px 7px;
    border-radius: 3px;
    transition: background .12s, color .12s;
}
.lang-toggle:hover { color: var(--ink); background: var(--surface-2); }
.lang-toggle.active {
    color: var(--hero);
    background: color-mix(in oklch, var(--hero) 10%, transparent);
    font-weight: 600;
}
.lang-sep { color: var(--ink-3); font-size: 12px; }

/* Markdown body — doc rendering */
.markdown-body {
    max-width: 800px;
}
.markdown-body h1 {
    font-family: var(--font-display);
    font-size: clamp(22px, 2.4vw, 32px);
    font-weight: 400;
    letter-spacing: -0.014em;
    color: var(--ink);
    margin: 0 0 24px;
    border-bottom: 1px solid var(--hairline-soft);
    padding-bottom: 12px;
    line-height: 1.2;
}
.markdown-body h2 {
    font-family: var(--font-display);
    font-size: 19px;
    font-weight: 500;
    color: var(--ink);
    margin: 36px 0 12px;
    border-bottom: 1px solid var(--hairline-soft);
    padding-bottom: 5px;
}
.markdown-body h3 {
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 500;
    color: var(--ink-2);
    margin: 24px 0 8px;
}
.markdown-body h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--ink-2);
    margin: 20px 0 6px;
}
.markdown-body p {
    font-size: 14.5px;
    line-height: 1.75;
    color: var(--ink-2);
    margin: 0 0 14px;
}
.markdown-body ul, .markdown-body ol {
    padding-left: 22px;
    margin: 0 0 14px;
}
.markdown-body li {
    font-size: 14.5px;
    line-height: 1.7;
    color: var(--ink-2);
    margin-bottom: 4px;
}
.markdown-body code {
    font-family: var(--font-mono);
    font-size: 12.5px;
    background: var(--surface-2);
    border: 1px solid var(--hairline-soft);
    border-radius: 3px;
    padding: 1px 5px;
    color: var(--ink);
}
.markdown-body pre {
    background: var(--surface-2);
    border: 1px solid var(--hairline-soft);
    border-radius: 4px;
    padding: 16px 20px;
    overflow-x: auto;
    margin: 0 0 16px;
}
.markdown-body pre code {
    font-family: var(--font-mono);
    font-size: 12.5px;
    background: none;
    border: none;
    padding: 0;
    color: var(--ink);
}
.markdown-body table {
    border-collapse: collapse;
    width: 100%;
    margin: 0 0 16px;
    font-size: 13.5px;
}
.markdown-body th {
    font-weight: 600;
    color: var(--ink);
    background: var(--surface-2);
    text-align: left;
    padding: 8px 12px;
    border: 1px solid var(--hairline-soft);
}
.markdown-body td {
    color: var(--ink-2);
    padding: 7px 12px;
    border: 1px solid var(--hairline-soft);
    vertical-align: top;
}
.markdown-body tr:nth-child(even) td { background: color-mix(in oklch, var(--surface) 40%, transparent); }
.markdown-body a { color: var(--hero); text-decoration: underline; text-underline-offset: 2px; }
.markdown-body blockquote {
    border-left: 3px solid var(--hero);
    margin: 0 0 14px;
    padding: 8px 16px;
    background: color-mix(in oklch, var(--hero) 5%, transparent);
    border-radius: 0 4px 4px 0;
}
.markdown-body blockquote p { margin: 0; color: var(--ink-2); }
.markdown-body hr {
    height: 1px;
    border: none;
    background: var(--hairline-soft);
    margin: 24px 0;
}

.docs-not-found {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.docs-not-found h1 {
    font-family: var(--font-display);
    font-size: 28px;
    font-weight: 300;
    color: var(--ink);
    margin: 0;
}

/* ── Learnings Index ─────────────────────────────────────── */
.learning-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.learning-card {
    border: 1px solid var(--hairline);
    border-radius: 10px;
    background: var(--surface);
    overflow: hidden;
    transition: border-color 0.15s;
}

.learning-card:hover {
    border-color: var(--hairline-strong);
}

.learning-card.expanded {
    border-color: var(--hero);
}

.learning-card-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    cursor: pointer;
    flex-wrap: wrap;
}

.status-badge {
    display: inline-block;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    flex-shrink: 0;
}

.status-badge.status-proposed {
    background: color-mix(in oklch, var(--hero) 15%, var(--surface));
    color: var(--hero);
}

.status-badge.status-approved {
    background: color-mix(in oklch, oklch(0.7 0.15 145) 15%, var(--surface));
    color: oklch(0.55 0.15 145);
}

.status-badge.status-rejected {
    background: color-mix(in oklch, var(--sv-fail) 15%, var(--surface));
    color: var(--sv-fail);
}

.learning-domain {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--ink-2);
    flex-shrink: 0;
    font-family: var(--font-mono);
}

.learning-preview {
    flex: 1;
    font-size: 0.875rem;
    color: var(--ink);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.learning-date {
    font-size: 0.8rem;
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}

.learning-actions {
    display: flex;
    gap: 0.375rem;
    flex-shrink: 0;
}

.learning-card-detail {
    padding: 1rem 1rem 1.25rem;
    border-top: 1px solid var(--hairline);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: var(--surface-2, var(--surface));
}

.learning-text pre,
.learning-card-detail pre {
    white-space: pre-wrap;
    word-break: break-word;
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    background: var(--surface);
    border: 1px solid var(--hairline);
    border-radius: 6px;
    padding: 0.75rem 1rem;
    margin: 0.375rem 0 0;
}

.learning-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1.5rem;
    font-size: 0.8125rem;
    color: var(--ink-2);
}
