/* =====================================================================
   de:brief — Design System CSS
   ---------------------------------------------------------------------
   Editorial-minimalist style for the de:brief platform. Warm neutral
   surfaces, restrained typography (serif for display, sans for UI),
   borders over shadows, density where it helps and whitespace where it
   doesn't.

   File order:
     1. Fonts
     2. Tokens (CSS variables)
     3. Reset & base
     4. Typography helpers
     5. Layout primitives
     6. Components (alphabetical):
        - Avatar
        - Badge / pill
        - Button
        - Canvas Composer strip (lean command bar — class is canvas-advisor-strip)
        - Canvas ghost block (pending Composer result)
        - Chat patterns
        - Citation chip & footnote (.cite, .fn)
        - Composer (chat input)
        - Data table
        - Evidence Trail panel
        - Filter chip
        - Form input
        - History item (sidebar)
        - Icon button
        - Nav (sidebar)
        - Overlay panel (slide-over)
        - Page header
        - Pinned-mini chip
        - Pinned trigger pill
        - Progress (inline)
        - Right-rail tabs
        - Split-evidence (collapsible)
        - Tabs

   Drop this file into any project and start composing with the classes
   below. Tokens are CSS variables so override at :root or scope as
   needed for dark mode (not provided here — the brand reads as a light
   surface).
   ===================================================================== */


/* ---------------------------------------------------------------------
   1. Fonts
   --------------------------------------------------------------------- */

@import url('https://fonts.googleapis.com/css2?family=Newsreader:ital,opsz,wght@0,6..72,400;0,6..72,500;1,6..72,400&family=Geist:wght@400;500;600&display=swap');


/* ---------------------------------------------------------------------
   2. Tokens
   --------------------------------------------------------------------- */

:root {
  /* Surfaces — warm off-white not cool gray. Four layers from page bg
     to nested context. White is reserved for content surfaces (cards,
     panels, slides) so it reads as content rather than chrome. */
  --bg:            #faf8f3;
  --surface:       #ffffff;
  --surface-muted: #f1eee6;
  --surface-deep:  #ebe7dd;

  /* Text — near-black plus two muted levels for hierarchy without
     resorting to color or weight changes. */
  --text:           #1a1715;
  --text-secondary: #6b6862;
  --text-tertiary:  #a09c92;

  /* Borders — three weights for default / hover / focus. Alpha-based so
     they sit naturally on any surface tone. */
  --border:        rgba(26, 23, 21, 0.08);
  --border-medium: rgba(26, 23, 21, 0.16);
  --border-strong: rgba(26, 23, 21, 0.32);

  /* Semantic — bg + fg pair per state. Use sparingly; saturated color
     should be a signal, not decoration. */
  --info-bg:    #e8f0f8;
  --info-fg:    #2c5783;
  --success-bg: #e6f0e2;
  --success-fg: #3b6d11;
  --warning-bg: #fbf1dc;
  --warning-fg: #854f0b;
  --warn-bg:    #fbf1dc;
  --warn-fg:    #854f0b;
  --danger-bg:  #fbe7e7;
  --danger-fg:  #a32d2d;

  /* Source category colors — cite dots, footnote chips, ev-num badges */
  --src-green: #3b6d11;  /* Brief / brand audit */
  --src-pink:  #993556;  /* FGD / qual transcripts */
  --src-blue:  #185FA5;  /* Cross-tabs / quant */
  --src-amber: #854f0b;  /* Older waves / archive */

  /* Accent — one primary action color. The text-near-black is the
     accent here; saturated brand colors break the editorial voice. */
  --accent: var(--text);

  /* Typography stacks. Don't substitute — Newsreader and Geist carry
     the brand voice. */
  --serif: 'Newsreader', 'Iowan Old Style', Charter, Georgia, serif;
  --sans:  'Geist', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --mono:  ui-monospace, 'SF Mono', Menlo, monospace;

  /* Radius scale. Pills/circles use 999px directly. */
  --r-sm: 4px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-xl: 16px;

  /* Shadows. Two values, both faint. If you need a third, reconsider. */
  --shadow-sm: 0 1px 2px rgba(26, 23, 21, 0.04);
  --shadow-md: 0 2px 8px rgba(26, 23, 21, 0.06);
}


/* ---------------------------------------------------------------------
   3. Reset & base
   --------------------------------------------------------------------- */

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button {
  font-family: inherit;
  cursor: pointer;
}

input, textarea, select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}


/* ---------------------------------------------------------------------
   4. Typography helpers
   --------------------------------------------------------------------- */

.t-display {
  font-family: var(--serif);
  font-size: 36px;
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.15;
}
.t-h1, .page-title {
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 500;
  letter-spacing: -0.01em;
}
.t-h2 {
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 500;
}
.t-h3 {
  font-size: 15px;
  font-weight: 500;
}
.t-body  { font-size: 14px; line-height: 1.5; }
.t-small { font-size: 13px; }
.t-caption { font-size: 12px; color: var(--text-secondary); }
.t-meta  { font-size: 12px; color: var(--text-tertiary); }
.t-label {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
}

.muted     { color: var(--text-secondary); }
.tertiary  { color: var(--text-tertiary); }


/* ---------------------------------------------------------------------
   5. Layout primitives
   --------------------------------------------------------------------- */

.row { display: flex; align-items: center; gap: 8px; }
.row-between { display: flex; align-items: center; justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 8px; }

.ic-sm { width: 14px; height: 14px; flex-shrink: 0; }
.ic    { width: 16px; height: 16px; flex-shrink: 0; }
.ic-lg { width: 18px; height: 18px; flex-shrink: 0; }


/* ---------------------------------------------------------------------
   6. Components (alphabetical)
   --------------------------------------------------------------------- */


/* --- Avatar --------------------------------------------------------- */

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  flex-shrink: 0;
}


/* --- Badge / pill --------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  background: var(--surface-muted);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.badge .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.badge-info    { background: var(--info-bg);    color: var(--info-fg);    border-color: transparent; }
.badge-success { background: var(--success-bg); color: var(--success-fg); border-color: transparent; }
.badge-warning { background: var(--warning-bg); color: var(--warning-fg); border-color: transparent; }
.badge-danger  { background: var(--danger-bg);  color: var(--danger-fg);  border-color: transparent; }


/* --- Button --------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  background: var(--surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-muted); border-color: var(--border-strong); }
.btn:active { transform: translateY(0.5px); }

.btn-primary {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}
.btn-primary:hover { background: #2c2826; border-color: #2c2826; }

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover { background: var(--surface-muted); color: var(--text); }

.btn-sm { padding: 4px 9px; font-size: 12px; }


/* --- Canvas Composer strip (lean command bar, P5/A2c) ---------------- */
/* Class name retains "advisor" historical artifact; pattern is Composer. */

.canvas-advisor-strip {
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

/* Status row — only visible when an action just ran */
.strip-status {
  padding: 8px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  flex-shrink: 0;
  color: var(--text-secondary);
}
.strip-status.success { color: var(--success-fg); }
.strip-status.pending { color: var(--info-fg); font-style: italic; }
.strip-status .meta {
  margin-left: auto;
  color: var(--text-tertiary);
  font-size: 11px;
}

/* Suggested commands chips row */
.strip-suggested {
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 8px 16px;
  flex-shrink: 0;
  flex-wrap: wrap;
  background: var(--bg);
}
.strip-suggested-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  font-weight: 500;
  margin-right: 4px;
}

/* Input row */
.strip-composer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--surface);
}
.strip-composer-pin {
  width: 32px; height: 32px;
  border-radius: var(--r-md);
  background: var(--surface-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  cursor: pointer;
  color: var(--text-secondary);
  flex-shrink: 0;
}
.strip-composer-pin:hover { color: var(--text); background: var(--bg); }
.strip-composer-input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text-tertiary);
  font-family: var(--sans);
}
.strip-composer-send {
  width: 32px; height: 32px;
  border-radius: var(--r-md);
  background: var(--accent);
  color: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
}


/* --- Canvas ghost block (pending Composer result) ------------------- */

.canvas-ghost {
  background: var(--info-bg);
  border: 1.5px dashed var(--info-fg);
  border-radius: var(--r-md);
  padding: 12px 14px;
  margin: 12px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
}
.canvas-ghost-label {
  font-size: 10px;
  color: var(--info-fg);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}
.canvas-ghost-content {
  font-family: var(--serif);
  font-size: 14px;
  font-style: italic;
  color: var(--text);
  line-height: 1.55;
}
.canvas-ghost-meta {
  font-size: 11px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 5px;
}
.canvas-ghost-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-top: 4px;
  flex-wrap: wrap;
}


/* --- Chat patterns --------------------------------------------------- */

.chat-msg-user {
  align-self: flex-end;
  max-width: 85%;
  padding: 8px 14px;
  background: var(--surface-muted);
  border-radius: var(--r-md);
  font-size: 13px;
  line-height: 1.5;
}
.chat-msg-ai {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
  max-width: 100%;
  padding: 4px 0;
}
.chat-msg-ai strong { font-weight: 500; }
.chat-msg-ai.active-answer {
  background: var(--info-bg);
  border-left: 2px solid var(--info-fg);
  padding-left: 12px;
  margin-left: -14px;
  border-radius: 0 var(--r-md) var(--r-md) 0;
}


/* --- Citation chip (color-dotted, used in slide/memo prose) --------- */

.cite {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 7px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 11px;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  vertical-align: baseline;
}
.cite:hover { background: var(--surface); border-color: var(--border-medium); color: var(--text); }
.cite-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
}
.cite-dot-green { background: var(--src-green); }
.cite-dot-pink  { background: var(--src-pink); }
.cite-dot-blue  { background: var(--src-blue); }
.cite-dot-amber { background: var(--src-amber); }


/* --- Composer (chat input) ------------------------------------------ */

.composer {
  background: var(--surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  padding: 14px 16px 10px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.composer:focus-within {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}
.composer-input {
  width: 100%;
  border: none;
  outline: none;
  resize: none;
  background: transparent;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
}
.composer-input::placeholder { color: var(--text-tertiary); }
.composer-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
}
.composer-pills {
  display: flex;
  gap: 4px;
  align-items: center;
}
.composer-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
}
.composer-pill:hover { background: var(--surface); color: var(--text); }
.composer-pill.has-context {
  background: var(--info-bg);
  color: var(--info-fg);
  border-color: transparent;
}

/* Standalone send button — canonical for all composers (Advisor A1 + A2).
   Define the look + disabled state here so every send button is identical. */
.composer-send {
  width: 28px;
  height: 28px;
  border-radius: var(--r-md);
  background: var(--accent);
  color: var(--bg);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity .1s, background .1s, color .1s;
}
.composer-send svg { width: 13px; height: 13px; }
.composer-send:hover:not(:disabled) { opacity: .85; }
/* Obvious muted disabled state */
.composer-send:disabled,
.composer-send:disabled:hover {
  background: var(--surface-deep);
  color: var(--text-tertiary);
  cursor: not-allowed;
  opacity: 1;
}

/* Split send+arrow variant (unused today; kept for the canvas composer).
   Overrides the standalone sizing when wrapped in a .composer-send-group. */
.composer-send-group {
  display: flex;
  align-items: stretch;
  border-radius: var(--r-md);
  overflow: hidden;
}
.composer-send-group .composer-send {
  width: 36px;
  height: 32px;
  border-radius: 0;
  border-right: 1px solid rgba(255,255,255,0.15);
}
.composer-send-arrow {
  width: 24px;
  height: 32px;
  background: var(--accent);
  color: var(--bg);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.composer-send-arrow:hover { background: #2c2826; }

.composer-hint {
  margin-top: 12px;
  text-align: center;
  font-size: 12px;
  color: var(--text-tertiary);
}


/* --- Data table ----------------------------------------------------- */

.table-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 0;
}
.table-search {
  flex: 1;
  max-width: 360px;
  padding: 7px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: 13px;
  color: var(--text);
  outline: none;
}
.table-search:focus { border-color: var(--border-strong); }

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  font-size: 13px;
}
.data-table th {
  padding: 10px 14px;
  text-align: left;
  font-weight: 500;
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.data-table th.sorted { color: var(--text); }
.data-table .sort-ind { color: var(--text-tertiary); margin-left: 4px; }
.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr { cursor: pointer; }
.data-table tbody tr:hover { background: var(--surface-muted); }
.data-table .col-primary { font-weight: 500; }
.data-table .col-tertiary { color: var(--text-tertiary); font-size: 12px; }


/* --- Evidence Trail panel ------------------------------------------- */

.evidence-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}
.evidence-head {
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.evidence-head-title {
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
  letter-spacing: -0.01em;
}
.evidence-head-meta {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 3px;
  font-style: italic;
}
.evidence-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px 16px;
}
.evidence-source-group {
  margin-bottom: 14px;
}
.evidence-source-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 4px 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
}
.evidence-source-head .ev-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.evidence-source-meta {
  margin-left: auto;
  font-size: 10px;
  color: var(--text-tertiary);
  font-weight: 400;
}
.evidence-citation {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 10px 12px;
  margin: 4px 0;
  cursor: pointer;
  transition: border-color 0.1s;
}
.evidence-citation:hover {
  border-color: var(--border-strong);
  background: var(--surface);
}
.evidence-citation.numbered {
  display: flex;
  align-items: flex-start;
  gap: 0;
}
.evidence-citation.numbered .ev-citation-body {
  flex: 1;
  min-width: 0;
}
.evidence-citation-ref {
  font-size: 10px;
  color: var(--text-tertiary);
  font-weight: 500;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 4px;
}
.evidence-citation-quote {
  font-size: 12px;
  line-height: 1.55;
  color: var(--text);
  font-family: var(--serif);
  font-style: italic;
}
.evidence-citation-usage {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px dashed var(--border);
  display: flex;
  align-items: center;
  gap: 4px;
}
.evidence-citation-usage .arrow {
  color: var(--text-tertiary);
}

/* Evidence number badge */
.ev-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 11px;
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
  margin-right: 8px;
  border: 1px solid transparent;
  line-height: 1;
}
.ev-num.color-green { background: rgba(59, 109, 17, 0.12);  color: #2d5510; border-color: rgba(59, 109, 17, 0.3); }
.ev-num.color-pink  { background: rgba(153, 53, 86, 0.12);  color: #6e2540; border-color: rgba(153, 53, 86, 0.3); }
.ev-num.color-blue  { background: rgba(24, 95, 165, 0.12);  color: #134471; border-color: rgba(24, 95, 165, 0.3); }
.ev-num.color-amber { background: rgba(133, 79, 11, 0.12);  color: #5e3909; border-color: rgba(133, 79, 11, 0.3); }


/* --- Filter chip ---------------------------------------------------- */

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  background: var(--surface);
  border: 1px solid var(--border-medium);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
}
.chip:hover { color: var(--text); }
.chip.active {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}
.chip .muted { font-weight: 400; opacity: 0.7; }


/* --- Footnote chip (numbered citation in answers) ------------------- */

.fn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 16px;
  padding: 0 5px;
  margin: 0 1px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  position: relative;
  top: -1px;
  color: var(--text-secondary);
  line-height: 1;
  font-family: var(--sans);
  transition: all 0.1s;
}
.fn:hover { transform: translateY(-1px); }
.fn.color-green { background: rgba(59, 109, 17, 0.10);  color: #2d5510; border-color: rgba(59, 109, 17, 0.3); }
.fn.color-pink  { background: rgba(153, 53, 86, 0.10);  color: #6e2540; border-color: rgba(153, 53, 86, 0.3); }
.fn.color-blue  { background: rgba(24, 95, 165, 0.10);  color: #134471; border-color: rgba(24, 95, 165, 0.3); }
.fn.color-amber { background: rgba(133, 79, 11, 0.10);  color: #5e3909; border-color: rgba(133, 79, 11, 0.3); }
.fn.active { box-shadow: 0 0 0 2px var(--info-fg); }


/* --- Form input ----------------------------------------------------- */

.input {
  width: 100%;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--r-md);
  font-size: 13px;
  color: var(--text);
  outline: none;
  transition: border-color 0.12s;
}
.input:focus { border-color: var(--border-strong); }
.input::placeholder { color: var(--text-tertiary); }


/* --- History item (sidebar Recent list) ----------------------------- */

.history-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.history-item {
  padding: 6px 12px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--r-sm);
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 4px;
  position: relative;
}
.history-item:hover { background: var(--surface-muted); color: var(--text); }
.history-tag {
  color: var(--text-tertiary);
  margin-right: 4px;
  flex-shrink: 0;
}
.history-item-text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.history-item-menu-btn {
  opacity: 0;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-tertiary);
  padding: 2px 4px;
  border-radius: var(--r-sm);
  flex-shrink: 0;
  transition: opacity 0.1s, background 0.1s;
}
.history-item:hover .history-item-menu-btn,
.history-item:has(.history-item-menu.open) .history-item-menu-btn {
  opacity: 1;
}
.history-item-menu-btn:hover { background: var(--bg); color: var(--text); }

.history-item-menu {
  position: absolute;
  top: 28px;
  right: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.10);
  padding: 4px;
  z-index: 50;
  min-width: 140px;
  display: none;
}
.history-item-menu.open { display: block; }
.history-menu-item {
  padding: 7px 10px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}
.history-menu-item:hover { background: var(--surface-muted); }
.history-menu-item.danger { color: #b94343; }
.history-menu-item.danger:hover { background: rgba(185, 67, 67, 0.08); }
.history-menu-item svg { flex-shrink: 0; }


/* --- Icon button ---------------------------------------------------- */

.icon-btn {
  width: 28px;
  height: 28px;
  border-radius: var(--r-md);
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:hover { background: var(--surface-muted); color: var(--text); }


/* --- Nav (sidebar) -------------------------------------------------- */

.sidebar {
  background: var(--bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  width: 240px;
  height: 100vh;
  flex-shrink: 0;
}
.sidebar-head {
  padding: 16px 16px 12px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 500;
}
.nav-section {
  padding: 4px 8px;
}
.nav-section + .nav-section { border-top: 1px solid var(--border); padding-top: 12px; }
.nav-label {
  font-size: 11px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 6px 12px 8px;
}
.nav-label.collapsible {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
}
.nav-label.collapsible:hover { color: var(--text-secondary); }
.nav-label .chev {
  color: var(--text-tertiary);
  transition: transform 0.15s;
}
.nav-section.collapsed .nav-label .chev { transform: rotate(-90deg); }
.nav-section.collapsed .history-list { display: none; }

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: var(--r-md);
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
}
.nav-item:hover { background: var(--surface-muted); color: var(--text); }
.nav-item.active {
  background: var(--surface-muted);
  color: var(--text);
  font-weight: 500;
}
.nav-item-left { display: flex; align-items: center; gap: 10px; }
.nav-item-count {
  font-size: 11px;
  color: var(--text-tertiary);
  font-weight: 500;
}

.sidebar-foot {
  margin-top: auto;
  padding: 8px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  gap: 8px;
  border-top: 1px solid var(--border);
  margin: 8px;
}
.user-info { display: flex; flex-direction: column; line-height: 1.3; }
.user-name { font-size: 13px; font-weight: 500; }
.user-org { font-size: 11px; color: var(--text-tertiary); }


/* --- Overlay panel (slide-over) ------------------------------------- */

.overlay-bg {
  position: fixed;
  inset: 0;
  background: rgba(26, 23, 21, 0.32);
  display: flex;
  align-items: stretch;
  justify-content: flex-end;
  z-index: 100;
}
.overlay-panel {
  width: 480px;
  max-width: 90vw;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-md);
}
.overlay-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.overlay-title {
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 500;
}
.overlay-body { flex: 1; overflow-y: auto; padding: 16px 20px; }
.overlay-foot {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
}


/* --- Page header (sticky) ------------------------------------------ */

.page-head {
  padding: 18px 32px 14px;
  min-height: 60px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 10;
}
.breadcrumb {
  font-size: 13px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}
.breadcrumb-sep { color: var(--text-tertiary); }
.breadcrumb-current { color: var(--text); font-weight: 500; }
.head-actions { display: flex; gap: 8px; align-items: center; }


/* --- Pinned-mini chip (inline pinned indicator) -------------------- */

.pinned-mini {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 6px 2px 7px;
  background: var(--surface);
  border: 1px solid var(--border-medium);
  border-radius: 999px;
  font-size: 11px;
  color: var(--text);
  cursor: pointer;
}
.pinned-mini:hover { border-color: var(--border-strong); }
.pinned-mini .x {
  color: var(--text-tertiary);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  margin-left: 1px;
  opacity: 0.6;
}
.pinned-mini:hover .x { opacity: 1; }


/* --- Pinned trigger pill (page-head Pinned drawer button) ---------- */

.pinned-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 8px;
  background: var(--info-bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  font-weight: 500;
}
.pinned-trigger:hover { border-color: var(--border-strong); }
.pinned-trigger .count {
  background: var(--text);
  color: var(--bg);
  border-radius: 999px;
  padding: 1px 7px;
  font-size: 10px;
  font-weight: 600;
}


/* --- Progress (inline) --------------------------------------------- */

.progress-inline {
  display: flex;
  align-items: center;
  gap: 8px;
}
.progress-inline-bar {
  height: 4px;
  width: 56px;
  background: var(--surface-deep);
  border-radius: 2px;
  overflow: hidden;
  flex-shrink: 0;
}
.progress-inline-bar > div { height: 100%; background: var(--text); }
.progress-inline-text {
  font-size: 12px;
  color: var(--text-tertiary);
  white-space: nowrap;
}


/* --- Right-rail tabs (toggle between two views in a rail) ---------- */

.rail-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}
.rail-tab {
  padding: 11px 16px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.rail-tab:hover { color: var(--text); }
.rail-tab.active {
  color: var(--text);
  border-bottom-color: var(--text);
  font-weight: 500;
  background: var(--surface);
}
.rail-tab .count {
  font-size: 10px;
  background: var(--surface-muted);
  padding: 1px 6px;
  border-radius: 999px;
  color: var(--text-secondary);
  font-weight: 500;
}
.rail-tab.active .count {
  background: var(--text);
  color: var(--bg);
}
.rail-content {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}


/* --- Split-evidence (collapsible bottom panel for L2/P4) ----------- */

.split-evidence {
  border-top: 2px solid var(--border-strong);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  max-height: 50%;
  overflow: hidden;
}
.split-evidence.collapsed {
  max-height: 40px;
}
.split-evidence.collapsed .split-evidence-body {
  display: none;
}
.split-evidence-head {
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  background: var(--bg);
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 500;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  height: 40px;
}
.split-evidence-head:hover { background: var(--surface-muted); }
.split-evidence-head .se-meta {
  margin-left: auto;
  color: var(--text-tertiary);
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  font-size: 11px;
}
.split-evidence-head .se-chevron {
  color: var(--text-tertiary);
  transition: transform 0.15s;
}
.split-evidence.collapsed .se-chevron {
  transform: rotate(-90deg);
}
.split-evidence-body {
  flex: 1;
  overflow-y: auto;
  background: var(--surface);
}
.split-evidence-context {
  padding: 10px 16px 8px;
  background: var(--info-bg);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-secondary);
  font-style: italic;
  line-height: 1.45;
}
.split-evidence-context strong {
  color: var(--text);
  font-style: normal;
  font-weight: 500;
}


/* --- Suggested action chip (used in canvas Advisor strip) --------- */

.suggested-action {
  padding: 4px 10px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 11px;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
}
.suggested-action:hover {
  background: var(--surface);
  border-color: var(--border-medium);
  color: var(--text);
}


/* --- Tabs (sub-views under a page-head) ---------------------------- */

.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  padding: 0 32px;
  background: var(--bg);
}
.tab {
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.active {
  color: var(--text);
  border-bottom-color: var(--text);
}


/* --- Pipeline stage rail (Pipeline tab, Issue #16) ---------------- */

.pipeline-scroll-wrap {
  overflow-x: auto;
  flex-shrink: 0;
  padding: 20px 32px 0;
}
.pipeline-rail {
  display: flex;
  align-items: stretch;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow-x: auto;
  overflow-y: hidden;
  background: var(--surface);
}
.pipeline-stage {
  flex: 1 1 100px;
  min-width: 100px;
  padding: 12px 14px;
  background: var(--surface-muted);
  border-right: 1px solid var(--border);
  cursor: pointer;
  transition: background 120ms;
  text-decoration: none;
  color: inherit;
  display: block;
  position: relative;
}
.pipeline-stage:last-child { border-right: none; }
.pipeline-stage:hover { background: var(--surface-deep); }
.pipeline-stage.is-complete { background: var(--surface); }
.pipeline-stage.is-complete:hover { background: var(--surface-muted); }
.pipeline-stage.is-active {
  background: var(--info-bg);
  border-color: var(--info-fg);
}
.pipeline-stage.is-active:hover { background: #dce8f2; }
.pipeline-stage.is-review-pending { background: var(--warning-bg); }
.pipeline-stage.is-review-pending:hover { background: #f5e4c4; }
.pipeline-stage.is-failed { background: var(--danger-bg); }
.pipeline-stage.is-failed:hover { background: #f3d4d4; }
/* Not-done states (#62) — same neutral surface; told apart by marker, not hue. */
.pipeline-stage.is-queued { background: var(--surface); }
.pipeline-stage.is-queued .stage-status { color: var(--text-secondary); }
.pipeline-stage.is-upcoming { background: var(--surface); }
.pipeline-stage.is-upcoming .stage-status { color: var(--text-tertiary); }
.pipeline-stage.is-outdated {
  background: var(--surface-muted);
  border-style: dashed;
}
.pipeline-stage.is-outdated:hover { background: var(--surface-deep); }
.pipeline-stage.is-outdated .stage-status { color: var(--text-secondary); }
.pipeline-stage.is-skipped { background: var(--surface); opacity: 0.6; }
.pipeline-stage.is-skipped .stage-status { color: var(--text-tertiary); }
.pipeline-stage.is-stopped { background: var(--surface-muted); }            /* #69 user-stopped */
.pipeline-stage.is-stopped .stage-status { color: var(--text-secondary); }
.pipeline-stage .stage-glyph { font-size: 12px; line-height: 1; }
.pipeline-stage.is-selected {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  z-index: 1;
}
.pipeline-stage .stage-num {
  font-size: 11px;
  color: var(--text-tertiary);
  font-weight: 500;
  margin-bottom: 4px;
}
.pipeline-stage .stage-name {
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
  line-height: 1.3;
  color: var(--text);
  overflow-wrap: anywhere;
}
.pipeline-stage .stage-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 500;
  padding: 1px 5px;
  border-radius: 3px;
  margin-bottom: 4px;
  background: var(--warning-bg);
  color: var(--warning-fg);
}
.pipeline-stage .stage-tag.optional {
  background: var(--surface-deep);
  color: var(--text-tertiary);
}
.pipeline-stage .stage-status {
  font-size: 11px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 4px;
}
.pipeline-stage.is-complete .stage-status { color: var(--success-fg); }
.pipeline-stage.is-review-pending .stage-status { color: var(--warning-fg); }
.pipeline-stage.is-active .stage-status { color: var(--info-fg); }
.pipeline-stage.is-failed .stage-status { color: var(--danger-fg); }
.pipeline-stage .stage-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  display: inline-block;
  flex-shrink: 0;
}
/* Upcoming = hollow dot (vs Queued's solid dot) — "not yet" vs "imminent". */
.pipeline-stage .stage-dot.is-hollow {
  background: transparent;
  border: 1.5px solid currentColor;
}


/* --- Codebook-in-Pipeline shell (Issue #16) ----------------------- */

.cb-shell {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  display: grid;
  grid-template-columns: 1fr 300px;
  overflow: hidden;
  min-height: 480px;
}
.cb-main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}
.cb-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  overflow-x: auto;
  overflow-y: hidden;
  background: var(--surface);
}
.cb-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  text-decoration: none;
}
.cb-tab:hover { color: var(--text); }
.cb-tab.active {
  color: var(--text);
  border-bottom-color: var(--text);
}
.sdot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.sdot-pending  { background: var(--text-tertiary); }
.sdot-edited   { background: var(--warning-fg); }
.sdot-reapprove { background: var(--warning-fg); }
.sdot-approved { background: var(--success-fg); }
.sdot-rejected { background: var(--danger-fg); }
.cb-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px 22px;
}
.cb-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--surface);
}
.cb-side {
  background: var(--surface-muted);
  padding: 16px;
  border-left: 1px solid var(--border);
  overflow-y: auto;
}
.cb-side-section { margin-bottom: 18px; }
.cb-side-section:last-child { margin-bottom: 0; }
.cb-side-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  margin-bottom: 6px;
  font-weight: 500;
}
.cb-side-text {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}
.cb-side-text .muted { color: var(--text-tertiary); }
.cb-side-btn {
  width: 100%;
  justify-content: center;
}
.cb-progress-bar {
  height: 6px;
  background: var(--surface-deep);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 6px;
}
.cb-progress-fill {
  height: 100%;
  background: var(--success-fg);
  border-radius: 3px;
  transition: width 200ms;
}
.cb-log-list { display: flex; flex-direction: column; gap: 0; }
.cb-log-entry {
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 8px;
  font-size: 12px;
}
.cb-log-entry:last-child { border-bottom: none; }
.cb-log-time {
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
}
.cb-log-msg { color: var(--text-secondary); }

.sec-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 4px;
  gap: 12px;
}
.sec-title {
  font-size: 15px;
  font-weight: 500;
  font-family: var(--serif);
}
.sec-purpose {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-bottom: 16px;
  line-height: 1.5;
}

/* Pipeline per-stage detail — MAIN panel (Issue #16). Padded, status-free. */
.pipeline-step-main {
  flex: 1;
  overflow-y: auto;
  padding: 20px 22px;
}
.pipeline-step-title {
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 500;
  line-height: 1.3;
  margin-bottom: 6px;
  color: var(--text);
}
.pipeline-step-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 20px;
}
.pipeline-step-eyebrow {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  font-weight: 500;
  margin-bottom: 10px;
}
.pipeline-output-list { display: flex; flex-direction: column; margin-bottom: 22px; }
.pipeline-output-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.pipeline-output-row:last-child { border-bottom: none; }
.pipeline-output-label { color: var(--text-secondary); }
.pipeline-output-value {
  color: var(--text);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.pipeline-step-substeps { display: flex; flex-direction: column; gap: 8px; }
.pipeline-substep { padding: 14px 16px; }
.pipeline-substep-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 4px;
}
.pipeline-substep-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Pipeline detail SIDE panel — per-step model dropdowns + rerun (Issue #16). */
.cb-side-models { display: flex; flex-direction: column; gap: 10px; }
.cb-side-model-name { font-size: 11px; color: var(--text-secondary); margin-bottom: 4px; }
.cb-side-select {
  width: 100%;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  background-color: var(--surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--r-sm);
  padding: 6px 28px 6px 9px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23a09c92' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  transition: border-color 120ms, box-shadow 120ms;
}
.cb-side-select:hover { border-color: var(--border-strong); }
.cb-side-select:focus {
  outline: none;
  border-color: var(--src-green);
  box-shadow: 0 0 0 2px rgba(59, 109, 17, 0.14);
}
.cb-side-rerun { border-top: 1px solid var(--border); padding-top: 16px; }
.cb-side-rerun-btn {
  gap: 6px;
  color: var(--src-green);
  background: var(--surface);
  border-color: var(--border-medium);
}
.cb-side-rerun-btn:hover {
  background: var(--success-bg);
  border-color: var(--success-fg);
  color: var(--success-fg);
}
.cb-side-rerun-hint {
  font-size: 11px;
  color: var(--text-tertiary);
  line-height: 1.4;
  text-align: center;
  margin-top: 7px;
}

/* Codebook JSON section — readable view + structured editor (Issue #16). */
.cbj-toolbar { display: flex; justify-content: flex-end; gap: 6px; margin-bottom: 12px; }
.cbj-save { background: var(--src-green); color: #fff; border-color: var(--src-green); }
.cbj-save:hover { background: #2f5a0e; border-color: #2f5a0e; }
.cbj-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; margin-bottom: 12px; }
.cbj-card:last-child { margin-bottom: 0; }
.cbj-card-head { padding: 9px 14px; border-bottom: 1px solid var(--border); background: var(--surface-muted); }
.cbj-card-title { font-size: 12px; font-weight: 600; color: var(--text); }
.cbj-card-body { padding: 6px 14px; }
.cbj-sub { border-left: 2px solid var(--border); padding-left: 14px; margin: 10px 0 4px; }
.cbj-sub-title { font-size: 11px; font-weight: 600; color: var(--text-secondary); text-transform: capitalize; letter-spacing: 0.02em; margin-bottom: 6px; }
.cbj-select {
  appearance: none; -webkit-appearance: none; cursor: pointer; padding-right: 28px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23a09c92' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center;
}
.cbj-row { display: flex; gap: 14px; padding: 8px 0; border-bottom: 1px solid var(--border); align-items: flex-start; }
.cbj-row:last-child { border-bottom: none; }
.cbj-key { font-size: 12px; font-weight: 500; color: var(--text-secondary); width: 168px; flex-shrink: 0; padding-top: 3px; }
.cbj-val { font-size: 13px; color: var(--text); flex: 1; min-width: 0; word-break: break-word; line-height: 1.55; }
.cbj-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 0; }
.cbj-chip { font-size: 12px; background: var(--surface-deep); color: var(--text-secondary); padding: 2px 10px; border-radius: 999px; }
.cbj-table { width: 100%; border-collapse: collapse; }
.cbj-table th { text-align: left; font-size: 11px; font-weight: 500; color: var(--text-tertiary); padding: 6px 8px 6px 0; white-space: nowrap; }
.cbj-table td { font-size: 12px; color: var(--text); padding: 6px 8px 6px 0; border-top: 1px solid var(--border); vertical-align: top; }
.cbj-input {
  width: 100%; box-sizing: border-box;
  font-family: var(--sans); font-size: 13px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-medium);
  border-radius: var(--r-sm); padding: 6px 9px;
}
.cbj-input:focus { outline: none; border-color: var(--src-green); box-shadow: 0 0 0 2px rgba(59,109,17,0.12); }
textarea.cbj-input { resize: vertical; min-height: 36px; line-height: 1.5; }
.cbj-cell { font-size: 12px; padding: 4px 7px; }
.cbj-editrow { display: flex; gap: 6px; align-items: center; padding: 3px 0; }
.cbj-add {
  font-size: 12px; color: var(--src-green); background: none; border: none;
  cursor: pointer; font-weight: 500; padding: 8px 0 2px; font-family: var(--sans);
}
.cbj-add:hover { text-decoration: underline; }
.cbj-rm { color: var(--text-tertiary); background: none; border: none; cursor: pointer; font-size: 15px; line-height: 1; padding: 2px 5px; flex-shrink: 0; }
.cbj-rm:hover { color: var(--danger-fg); }

/* a11y visually-hidden text (screen-reader only) — #96 R4-8 section status labels */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* #96 S-4 config-review human-catch widgets (pillar-scale, stacking, focal) */
.qw-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 12px 14px; margin-bottom: 14px; }
.qw-head { margin-bottom: 10px; }
.qw-title { font-size: 12px; font-weight: 600; color: var(--text); }
.qw-sub { display: block; font-size: 12px; color: var(--text-secondary); margin-top: 3px; line-height: 1.5; }
.qw-table th, .qw-table td { padding-right: 14px; }
.qw-ok { color: var(--success-fg); font-weight: 600; }
.qw-bad { color: var(--danger-fg); font-weight: 600; }
.qw-unknown { color: var(--text-tertiary); }
.qw-flag { color: var(--danger-fg); font-weight: 600; }
.qw-note { font-size: 11.5px; color: var(--text-tertiary); margin-top: 8px; line-height: 1.5; }
.qw-focal { display: flex; flex-wrap: wrap; gap: 8px; }
.qw-focal-chip { font-size: 12px; background: var(--success-bg); color: var(--success-fg); padding: 2px 10px; border-radius: 999px; font-weight: 600; }
.qw-panel { margin-top: 10px; }
.qw-panel-name { font-size: 11px; font-weight: 600; color: var(--text-secondary); text-transform: capitalize; letter-spacing: 0.02em; margin-bottom: 5px; }
.qw-stack { list-style: none; padding: 0; margin: 0; }
.qw-stack li { font-size: 13px; color: var(--text); padding: 4px 0; border-bottom: 1px solid var(--border); }
.qw-stack li:last-child { border-bottom: none; }
.qw-pos { display: inline-block; min-width: 20px; height: 20px; line-height: 20px; text-align: center; font-size: 11px; font-weight: 600; background: var(--surface-deep); color: var(--text-secondary); border-radius: 999px; margin-right: 8px; }
.cb-roe-head { display: flex; align-items: center; gap: 8px; }
.cb-roe-label { font-weight: 600; }
.cb-roe-objrow { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.cb-roe-num { font-size: 11px; font-family: var(--mono, monospace); color: var(--text-tertiary); width: 30px; flex-shrink: 0; }
.cb-sl-deck { font-size: 13px; font-weight: 600; color: var(--text-secondary); margin: 4px 0 10px; }
.cb-sl-deckblock { margin-bottom: 16px; }
.cb-sl-deckrow { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.cb-sl-decktitle { font-weight: 600; }
.cb-cm-title { font-family: var(--serif); font-size: 16px; font-weight: 500; color: var(--text); margin-bottom: 8px; }
.cb-cm-meta { font-size: 12px; color: var(--text-secondary); line-height: 1.6; }
.cb-cm-note { font-size: 12px; color: var(--text-tertiary); font-style: italic; margin-bottom: 10px; }

/* Activity log (Issue #16) — codebook rail + pipeline step side panel. */
.act-list { display: flex; flex-direction: column; gap: 12px; }
.act-entry { display: flex; gap: 8px; }
.act-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; margin-top: 5px; background: var(--text-tertiary); }
.act-dot.approved, .act-dot.completed { background: var(--success-fg); }
.act-dot.edited   { background: var(--warning-fg); }
.act-dot.rejected, .act-dot.failed { background: var(--danger-fg); }
.act-dot.reran, .act-dot.started { background: var(--text-secondary); }
.act-body { min-width: 0; }
.act-head { font-size: 12.5px; color: var(--text); line-height: 1.35; }
.act-verb { font-weight: 600; }
.act-verb.approved, .act-verb.completed { color: var(--success-fg); }
.act-verb.edited   { color: var(--warning-fg); }
.act-verb.rejected, .act-verb.failed { color: var(--danger-fg); }
.act-verb.reran, .act-verb.started { color: var(--text-secondary); }
.act-sub { font-size: 11.5px; color: var(--text-tertiary); margin-top: 1px; word-break: break-word; }
.act-time { border-bottom: 1px dotted var(--text-tertiary); cursor: help; }
.act-empty { font-size: 12px; color: var(--text-tertiary); font-style: italic; }

/* Output artifact → Advisor-access toggle (the "eye"), staff-only (Issue #16). */
.output-vis-btn {
  background: none; border: none; cursor: pointer; padding: 3px;
  display: inline-flex; align-items: center; border-radius: var(--r-sm);
  color: var(--text-tertiary);
}
.output-vis-btn:hover { color: var(--text-secondary); background: var(--surface-muted); }
.output-vis-btn:disabled { opacity: 0.5; cursor: default; }
.output-vis-btn .vis-off { display: none; }
.output-vis-btn.is-excluded .vis-on { display: none; }
.output-vis-btn.is-excluded .vis-off { display: inline; }
.output-vis-btn.is-excluded { color: var(--danger-fg); }
.output-file-row.is-excluded .output-file-name { color: var(--text-tertiary); }

/* Projects list — v1.1c wireframe (Issue #16). */
.page-title { font-family: var(--serif); font-size: 20px; font-weight: 500; line-height: 1.2; color: var(--text); letter-spacing: -0.01em; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; display: inline-block; }
.list-toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.list-toolbar-search {
  flex: 1; height: 34px; padding: 0 12px; box-sizing: border-box;
  border: 1px solid var(--border-medium); border-radius: var(--r-md);
  font-size: 13px; font-family: var(--sans); background: var(--surface); color: var(--text);
}
.list-toolbar-search:focus { outline: none; border-color: var(--src-green); box-shadow: 0 0 0 2px rgba(59,109,17,0.10); }
.list-toolbar-meta { font-size: 12px; color: var(--text-tertiary); white-space: nowrap; }
.data-table .col-open { font-weight: 500; color: var(--text); }
.data-table tbody tr:hover .col-open { text-decoration: underline; }
.data-table .col-open-cell { width: 40px; text-align: right; }
.data-table .row-open-btn { color: var(--text-tertiary); display: inline-flex; }
.data-table tbody tr:hover .row-open-btn { color: var(--text); }

/* Rendered codebook document (Issue #16). */
.cb-doc { font-size: 13.5px; line-height: 1.65; color: var(--text); }
.cb-doc h1 { font-family: var(--serif); font-size: 18px; font-weight: 500; margin: 0 0 12px; }
.cb-doc h2 { font-size: 15px; font-weight: 600; margin: 22px 0 9px; padding-bottom: 5px; border-bottom: 1px solid var(--border); }
.cb-doc h3 { font-size: 13.5px; font-weight: 600; margin: 16px 0 5px; }
.cb-doc h4 { font-size: 12.5px; font-weight: 600; margin: 12px 0 4px; color: var(--text-secondary); }
.cb-doc p { margin: 0 0 9px; }
.cb-doc ul, .cb-doc ol { margin: 0 0 9px; padding-left: 20px; }
.cb-doc li { margin-bottom: 3px; }
.cb-doc strong { font-weight: 600; }
.cb-doc code { font-size: 12px; background: var(--surface-muted); border-radius: 3px; padding: 1px 5px; font-family: var(--mono, monospace); }
.cb-doc pre { background: var(--surface-muted); border: 1px solid var(--border); border-radius: var(--r-md); padding: 12px 14px; overflow-x: auto; margin: 0 0 12px; }
.cb-doc pre code { background: none; padding: 0; font-size: 12px; line-height: 1.5; }
.cb-doc table { border-collapse: collapse; width: 100%; margin: 0 0 12px; font-size: 12.5px; }
.cb-doc th, .cb-doc td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; vertical-align: top; }
.cb-doc th { background: var(--surface-muted); font-weight: 600; }
.cb-doc hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.ds-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  flex-shrink: 0;
}
.ds-badge-success { background: var(--success-bg); color: var(--success-fg); }
.ds-badge-warning { background: var(--warning-bg); color: var(--warning-fg); }
.ds-badge-danger  { background: var(--danger-bg);  color: var(--danger-fg);  }
.ds-badge-info    { background: var(--info-bg);    color: var(--info-fg);    }
.ds-badge-pending {
  background: var(--surface-deep);
  color: var(--text-tertiary);
}
/* Pipeline step states (#62) — no new hue; distinguished by tint + marker. */
.ds-badge-queued {
  background: var(--surface-deep);
  color: var(--text-secondary);
}
.ds-badge-upcoming {
  background: var(--surface-deep);
  color: var(--text-tertiary);
}
.ds-badge-outdated {
  background: var(--surface-muted);
  color: var(--text-secondary);
  border: 1px dashed var(--border-medium);
}

/* Live-activity indicators (#64) — pulsing dot + spinner shown while a step
   is actively running, so a static "Running" badge reads as live work. */
.live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  display: inline-block;
  flex-shrink: 0;
  margin-right: 5px;
  animation: ds-pulse 1.4s ease-in-out infinite;
}
/* (a) The rail's active-step dot pulses too — matches the step-detail pill and
   the standard (Running marker = pulsing dot on BOTH surfaces). */
.pipeline-stage.is-active .stage-dot {
  animation: ds-pulse 1.4s ease-in-out infinite;
}
@keyframes ds-pulse {
  0%, 100% { opacity: 1;    transform: scale(1); }
  50%      { opacity: 0.3;  transform: scale(0.6); }
}
.ds-spin {
  transform-origin: center;
  animation: ds-spin 0.7s linear infinite;
}
@keyframes ds-spin { to { transform: rotate(360deg); } }
/* (b) Static markers inside step-detail STATUS pills — mirror the rail markers
   so both surfaces match per state (Queued solid dot, Upcoming hollow dot). */
.ds-badge .b-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  display: inline-block;
  margin-right: 5px;
  flex-shrink: 0;
}
.ds-badge .b-dot.is-hollow { background: transparent; border: 1.5px solid currentColor; }
.ds-badge svg { flex-shrink: 0; }
@media (prefers-reduced-motion: reduce) {
  .live-dot, .ds-spin, .pipeline-stage.is-active .stage-dot { animation: none; }
}


/* --- Codebook AI-Generated Objectives card + accordions (Issue #16) - */

.cb-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px;
}
.cb-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}
.cb-card-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.cb-model-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  background: var(--info-bg);
  color: var(--info-fg);
  border: 1px solid #b9d2e8;
}
.cb-accordion-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.cb-accordion {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--surface);
}
.cb-accordion-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  cursor: pointer;
  user-select: none;
  list-style: none;
}
.cb-accordion-head::-webkit-details-marker { display: none; }
.cb-accordion-head:hover { background: var(--surface-muted); }
.cb-accordion-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}
.cb-accordion-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.cb-obj-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  background: #f3e8ff;
  color: #7e22ce;
}
.cb-accordion-chev {
  color: var(--text-tertiary);
  transition: transform 200ms;
}
.cb-accordion[open] .cb-accordion-chev {
  transform: rotate(180deg);
}
.cb-accordion-body {
  border-top: 1px solid var(--border);
  padding: 4px 16px 10px;
}
.cb-obj-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.cb-obj-row:last-child { border-bottom: none; }
.cb-obj-num {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-tertiary);
  flex-shrink: 0;
  width: 32px;
  padding-top: 2px;
}
.cb-obj-text {
  flex: 1;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.55;
}
