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

/* Tokens — normative source: DESIGN.md */
:root {
  --bg: #f6f7f8;
  --surface: #ffffff;
  --surface-sunken: #eef0f2;
  --text: #1f2328;
  --text-muted: #59636e;
  --border: #d9dee3;
  --border-strong: #b9c0c7;
  --primary: #e8590c;
  --primary-hover: #d9480f;
  --primary-soft: #fff0e6;
  --navy: #1e4670;
  --p1: #c9313d;
  --p1-soft: #fdecee;
  --p2: #b45309;
  --p2-soft: #fef3e2;
  --p3: #59636e;
  --done: #1a7f4b;
  --done-soft: #e7f5ee;
  --doing: #1d6fc2;
  --doing-soft: #e8f1fb;
  --blocked: #6b46c1;
  --blocked-soft: #f1ecfb;
  --snippet: #1a7f4b;
  --overlay: #00000059;
  --ring: #e8590c2e;
  --code-bg: #22272e;
  --code-ink: #e6edf3;
  --radius: 8px;
  --radius-md: 6px;
  --radius-sm: 4px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'SF Mono', 'Cascadia Code', 'Fira Code', monospace;
  /* semantic z scale: dropdown → sticky → modal-backdrop → modal → toast → tooltip */
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-backdrop: 300;
  --z-modal: 310;
  --z-toast: 400;
  --z-tooltip: 500;
}

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

/* Type utilities — the ramp is 12 / 14 / 15 / 20 (see DESIGN.md) */
.meta { font-size: 12px; color: var(--text-muted); }
.hint { font-size: 12px; color: var(--text-muted); }
.page-title { font-size: 20px; font-weight: 650; letter-spacing: -0.01em; line-height: 1.3; }
.section-title { font-size: 15px; font-weight: 600; }

/* Login */
.login-modal-backdrop { position: fixed; inset: 0; background: var(--overlay); z-index: var(--z-backdrop); align-items: center; justify-content: center; }
.login-modal-box { background: var(--surface); color: var(--text); padding: 24px; border-radius: var(--radius); box-shadow: var(--shadow-lg); max-width: 360px; width: 90%; }
.login-modal-error { color: var(--p1); font-size: 12px; margin-top: 8px; }

/* Header */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  height: 48px;
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 16px;
}
.header-logo { font-size: 15px; font-weight: 650; color: var(--navy); letter-spacing: -0.01em; }
.header-logo span { color: var(--primary); }
.header-spacer { flex: 1; }
.header-nav { display: flex; gap: 2px; align-items: center; }
.header-nav a {
  padding: 6px 14px;
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  transition: color 0.15s, background 0.15s;
}
.header-nav a:hover { color: var(--text); background: var(--surface-sunken); }
.header-nav a.active { color: var(--primary); background: var(--primary-soft); }
.header-nav a:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.alerts-badge {
  background: var(--p1);
  color: #ffffff;
  border-radius: var(--radius);
  padding: 1px 7px;
  font-size: 12px;
  font-weight: 600;
  margin-left: 4px;
}
.alerts-badge.badge-review { background: var(--primary); }
.alerts-badge.badge-memory { background: var(--blocked); }

/* "More" dropdown in the header */
.nav-more { position: relative; }
.nav-more-btn {
  padding: 6px 14px; border-radius: var(--radius-md); border: none; background: transparent;
  color: var(--text-muted); font-size: 14px; font-weight: 500; font-family: var(--font);
  cursor: pointer; transition: color 0.15s, background 0.15s;
}
.nav-more-btn:hover { color: var(--text); background: var(--surface-sunken); }
.nav-more-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.nav-more-menu {
  position: absolute; top: 100%; right: 0; margin-top: 6px; min-width: 190px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-md); z-index: var(--z-dropdown); padding: 4px; text-align: left;
}
.nav-more-menu a, .nav-more-menu button {
  display: block; width: 100%; text-align: left; padding: 7px 10px; border: none; background: transparent;
  border-radius: var(--radius-sm); color: var(--text); font-size: 14px; font-family: var(--font);
  text-decoration: none; cursor: pointer;
}
.nav-more-menu a:hover, .nav-more-menu button:hover { background: var(--surface-sunken); }
.nav-more-menu .meta { padding: 7px 10px 4px; }

/* Buttons */
.btn {
  padding: 7px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: background 0.15s, border-color 0.15s;
}
.btn:hover { background: var(--surface-sunken); border-color: var(--border-strong); }
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.btn-primary { background: var(--primary); color: #ffffff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-danger { color: var(--p1); border-color: var(--border); }
.btn-danger:hover { background: var(--p1-soft); border-color: var(--p1); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.busy { position: relative; color: transparent !important; }
.btn.busy::after {
  content: ''; position: absolute; inset: 0;
  margin: auto; width: 12px; height: 12px;
  border: 2px solid transparent; border-top-color: currentColor;
  border-radius: 50%; animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

input, textarea, select {
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-family: var(--font);
  background: var(--surface);
  color: var(--text);
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--ring);
}
input::placeholder, textarea::placeholder { color: var(--text-muted); }
textarea { resize: vertical; min-height: 80px; }
input[type="checkbox"] {
  width: 15px; height: 15px; flex-shrink: 0; padding: 0;
  accent-color: var(--primary); cursor: pointer;
}
input[type="checkbox"]:focus { box-shadow: none; outline: 2px solid var(--primary); outline-offset: 2px; }

/* Board */
.board-container { padding: 20px; height: calc(100vh - 48px); display: flex; flex-direction: column; }
.board-toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; }
.board-columns { display: flex; gap: 14px; flex: 1; overflow-x: auto; padding-bottom: 4px; scroll-snap-type: x mandatory; }
.board-column {
  width: 272px; min-width: 272px; flex-shrink: 0;
  display: flex; flex-direction: column;
  background: transparent;
  scroll-snap-align: start;
}
@media (max-width: 600px) {
  .board-column { width: 86vw; min-width: 86vw; }
}
.column-header {
  padding: 10px 12px 8px;
  font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px;
  color: var(--text-muted);
  display: flex; justify-content: space-between; align-items: center;
}
.column-count {
  min-width: 22px; height: 22px; border-radius: var(--radius);
  background: var(--surface-sunken); color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; padding: 0 7px;
}
.column-body {
  flex: 1; overflow-y: auto;
  padding: 2px 2px 8px;
  border-radius: var(--radius);
  background: var(--surface-sunken);
  transition: background 0.15s;
}

/* Inbox triage: pending intake proposals awaiting a human ✓/✕. Dashed border =
   not yet real; sits above the column body so it can't be drag-sorted. */
.column-proposals { padding: 2px 2px 6px; }
.proposal-mini {
  display: flex; align-items: stretch; gap: 6px;
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 8px 8px 8px 12px;
  margin-bottom: 7px;
}
.proposal-mini-body { flex: 1; min-width: 0; cursor: pointer; }
/* Orange = a brand-new task; blue = an addition to a task already on the board */
.proposal-mini-kind { font-size: 12px; font-weight: 600; color: var(--primary); margin-bottom: 2px; }
.proposal-mini.addition .proposal-mini-kind { color: var(--doing); }
.proposal-mini-title { font-size: 14px; font-weight: 500; line-height: 1.4; }
.proposal-mini-detail { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.proposal-mini-actions { display: flex; flex-direction: column; gap: 4px; justify-content: center; }
.proposal-mini-actions button {
  border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius-sm);
  width: 26px; height: 24px; cursor: pointer; font-size: 12px; line-height: 1;
  display: flex; align-items: center; justify-content: center; color: var(--text-muted);
}
.proposal-mini-actions button.ok:hover { background: var(--done-soft); color: var(--done); border-color: var(--done); }
.proposal-mini-actions button.no:hover { background: var(--p1-soft); color: var(--p1); border-color: var(--p1); }
.proposal-mini-actions button:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.column-body.drag-over { background: var(--primary-soft); }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 7px;
  box-shadow: var(--shadow);
  transition: box-shadow 0.15s;
  cursor: grab;
}
.card:hover { box-shadow: var(--shadow-md); }
.card:active { cursor: grabbing; }
.card.sortable-ghost { opacity: 0.35; background: var(--border); }
.card.sortable-drag { box-shadow: var(--shadow-lg); transform: rotate(1.5deg); }
.card-inner { cursor: pointer; }
.card-header { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.card-priority {
  font-size: 12px; font-weight: 600; padding: 0 6px; border-radius: var(--radius-sm); line-height: 1.6;
}
.card-priority.p1 { background: var(--p1-soft); color: var(--p1); }
.card-priority.p2 { background: var(--p2-soft); color: var(--p2); }
.card-priority.p3 { background: var(--surface-sunken); color: var(--text-muted); }
.card-area { font-size: 12px; color: var(--text-muted); }
.card-title { font-size: 14px; font-weight: 500; line-height: 1.4; margin-bottom: 4px; }
.card-footer { font-size: 12px; color: var(--text-muted); display: flex; gap: 8px; align-items: center; }
.card-id { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); }
.card-due { color: var(--p1); font-weight: 600; }
.card-blocked { font-size: 12px; color: var(--blocked); margin-top: 3px; font-style: italic; }

/* Snippet box */
.snippet-box input { width: 240px; }

/* Board search/filter */
.board-search { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.board-search input { width: 200px; }
.board-search-count { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.card-dim { opacity: 0.2; }

/* Toast — the single notification surface: bottom-right, one at a time */
.snippet-toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--text); color: #ffffff; padding: 10px 18px;
  border-radius: var(--radius); font-size: 14px;
  box-shadow: var(--shadow-lg); z-index: var(--z-toast); max-width: 380px;
  display: flex; align-items: center; gap: 8px;
}
.snippet-toast .undo-btn { color: #ffffff; cursor: pointer; margin-left: 4px; font-weight: 600; text-decoration: underline; white-space: nowrap; }
.snippet-toast .toast-icon { font-weight: 700; flex-shrink: 0; }
.snippet-toast .toast-icon.ok { color: #6ee7a8; }
.snippet-toast .toast-icon.err { color: #ff8f98; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: var(--overlay);
  z-index: var(--z-backdrop); display: flex; align-items: center; justify-content: center;
}
.modal {
  background: var(--surface); border-radius: var(--radius); padding: 24px;
  max-width: 680px; width: 92%; max-height: 85vh; overflow-y: auto;
  box-shadow: var(--shadow-lg); position: relative; z-index: var(--z-modal);
}
.modal h2 { font-size: 20px; font-weight: 650; letter-spacing: -0.01em; margin-bottom: 16px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

/* Task page — capped width; long text additionally sits in a readable measure */
.task-page { max-width: 1100px; margin: 0 auto; padding: 24px 32px; }
.task-prose { max-width: 72ch; }
/* Flat sections: hairline top border + small uppercase label, no boxes */
.task-section { padding-top: 14px; border-top: 1px solid var(--border); margin-bottom: 20px; }
.task-section-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.task-section-label {
  font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px;
  color: var(--text-muted);
}
/* Quiet inline action — visible but not a boxed button */
.quiet-action {
  border: none; background: transparent; color: var(--text-muted); cursor: pointer;
  font-size: 12px; font-family: var(--font); padding: 2px 6px; border-radius: var(--radius-sm);
}
.quiet-action:hover { color: var(--text); background: var(--surface-sunken); }
.quiet-action:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.quiet-action:disabled { opacity: 0.55; cursor: not-allowed; }
.task-actions-row { display: flex; gap: 6px; margin-bottom: 20px; align-items: center; }
/* Read-only info line: status + dates + block control */
.task-info-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.task-waiting { font-size: 12px; color: var(--blocked); font-weight: 600; }
.block-control { display: inline-flex; gap: 6px; align-items: center; }
.block-control input { width: 160px; font-size: 12px; }
/* Editable properties, clearly separated from the info line */
.task-props { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; padding: 12px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.task-prop { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--text-muted); }
.task-prop select, .task-prop input { font-size: 14px; color: var(--text); width: auto; min-width: 90px; }
.task-danger-zone { display: flex; align-items: center; gap: 12px; margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--border); }
.task-page-header { margin-bottom: 20px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.task-page-back { color: var(--text-muted); text-decoration: none; font-size: 14px; display: inline-block; width: 100%; margin-bottom: 8px; }
.task-page-back:hover { color: var(--primary); }
.task-page-title { font-size: 20px; font-weight: 650; line-height: 1.3; letter-spacing: -0.01em; }
.task-meta-bar {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  padding: 14px 0; border-bottom: 1px solid var(--border); margin-bottom: 20px;
}
.task-meta-tag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 10px; border-radius: var(--radius-md);
  font-size: 12px; background: var(--surface); border: 1px solid var(--border);
  color: var(--text-muted);
}
.task-meta-tag select, .task-meta-tag input {
  border: none; background: transparent; font-size: 12px; padding: 0;
  width: auto; box-shadow: none; color: var(--text);
}
.task-meta-tag select:focus, .task-meta-tag input:focus { box-shadow: none; }
.status-badge {
  font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: var(--radius-sm);
  text-transform: uppercase; letter-spacing: 0.4px; display: inline-block;
}
.status-badge.todo { background: var(--surface-sunken); color: var(--text-muted); }
.status-badge.doing { background: var(--doing-soft); color: var(--doing); }
.status-badge.blocked { background: var(--blocked-soft); color: var(--blocked); }
.status-badge.done { background: var(--done-soft); color: var(--done); }
.status-badge.backlog { background: var(--surface-sunken); color: var(--text-muted); }
.task-two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start; }
@media (max-width: 800px) { .task-two-col { grid-template-columns: 1fr; } }
/* Chat follows the page as you scroll the notes column */
.chat-panel { position: sticky; top: 16px; align-self: start; }
.chat-panel .chat-messages { max-height: calc(100vh - 220px); }

/* Notes — a flat feed with hairline dividers; only the compose box looks like an input */
.notes-panel h3, .chat-panel h3 { font-size: 15px; font-weight: 600; margin-bottom: 12px; }
.note-compose { display: flex; gap: 8px; padding-bottom: 12px; margin-bottom: 6px; border-bottom: 1px solid var(--border); }
.note-item {
  padding: 10px 2px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.note-item:last-child { border-bottom: none; }
.note-item.kind-user .note-meta { color: var(--doing); }
.note-item.kind-snippet .note-meta { color: var(--done); }
.note-item.kind-ai .note-meta { color: var(--navy); }
.note-item.kind-research .note-meta { color: var(--blocked); }
.note-item.kind-system { font-style: italic; font-size: 12px; color: var(--text-muted); padding-top: 4px; padding-bottom: 4px; }
.note-item .note-body { white-space: pre-wrap; max-width: 72ch; }
.note-meta { font-size: 12px; font-weight: 500; color: var(--text-muted); margin-bottom: 3px; }

/* Chat */
.chat-messages { overflow-y: auto; max-height: 500px; padding: 4px 0; }
.chat-msg {
  padding: 8px 12px; margin-bottom: 6px; border-radius: var(--radius);
  font-size: 14px; line-height: 1.5;
}
.chat-msg.user { background: var(--doing-soft); margin-left: 20px; }
.chat-msg.assistant { background: var(--surface-sunken); margin-right: 20px; }
.chat-msg small { color: var(--text-muted); font-size: 12px; font-weight: 600; }
.context-used { margin-top: 6px; font-size: 12px; }
.context-used summary { color: var(--text-muted); cursor: pointer; }
.context-used pre {
  font-size: 12px; background: var(--surface-sunken); padding: 8px; border-radius: var(--radius-sm);
  overflow-x: auto; margin-top: 4px; white-space: pre-wrap; word-break: break-all;
}
.chat-input-row { display: flex; gap: 8px; margin-top: 10px; }

/* Research inline — collapsed behind a toggle; instructions are often long prompts */
.research-bar { display: flex; flex-direction: column; gap: 6px; margin-bottom: 20px; max-width: 72ch; }
.research-bar span { font-size: 12px; color: var(--text-muted); }
.research-bar textarea { min-height: 56px; font-size: 14px; }
.research-bar-actions { display: flex; gap: 8px; align-items: center; }
/* Note actions appear quietly on hover */
.note-actions { display: flex; gap: 6px; margin-top: 4px; opacity: 0; transition: opacity 0.15s; }
.note-item:hover .note-actions { opacity: 1; }
.note-actions button {
  border: none; background: transparent; color: var(--text-muted); cursor: pointer;
  font-size: 12px; font-family: var(--font); padding: 1px 4px; border-radius: var(--radius-sm);
}
.note-actions button:hover { color: var(--text); background: var(--surface-sunken); }
.note-actions button.danger:hover { color: var(--p1); background: var(--p1-soft); }
/* AI-generated content sits on a sunken surface (same vocabulary as chat bubbles) */
.research-output {
  background: var(--surface-sunken);
  border-radius: var(--radius); padding: 14px; margin-bottom: 20px;
  font-size: 14px; max-height: 320px; overflow-y: auto; line-height: 1.6;
  max-width: 72ch;
}

/* Confirm dialog (Done, force-undo, deletes) */
.done-confirm {
  position: fixed; inset: 0; background: var(--overlay);
  z-index: var(--z-backdrop); display: flex; align-items: center; justify-content: center;
}
.done-confirm-box {
  background: var(--surface); padding: 28px 36px; border-radius: var(--radius);
  text-align: center; box-shadow: var(--shadow-lg); position: relative; z-index: var(--z-modal);
}
.done-confirm-box p { font-size: 15px; font-weight: 500; margin-bottom: 16px; }
.done-confirm-box .btn { margin: 0 4px; }

/* Ask page */
.ask-page { max-width: 720px; margin: 0 auto; padding: 32px 24px; }
.ask-page h2 { font-size: 20px; font-weight: 650; letter-spacing: -0.01em; margin-bottom: 4px; }
.ask-checkbox { display: flex; align-items: center; gap: 6px; font-size: 14px; margin: 12px 0; }
.ask-result {
  margin-top: 20px; padding: 18px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 14px; line-height: 1.7; white-space: pre-wrap;
}
.ask-citation {
  display: inline-block; font-size: 12px; color: var(--navy);
  background: var(--doing-soft); padding: 2px 7px; border-radius: var(--radius-sm);
  cursor: pointer; margin: 0 2px;
}
.ask-citation:hover { background: var(--surface-sunken); }
.ask-citation { cursor: pointer; }
/* Ask conversation (persistent multi-turn) — flat, so it can't be mistaken for
   an input; the messages themselves are tinted bubbles */
.ask-conversation {
  min-height: 200px; padding: 4px 0;
  max-height: calc(100vh - 320px); overflow-y: auto;
}

/* Rendered HTML report — normal white-space (pre-wrap belongs to plain text) */
.report-view {
  margin-top: 20px; padding: 18px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 14px; line-height: 1.6;
}
.report-view h1, .report-view h2, .report-view h3 { margin: 12px 0 6px; font-weight: 600; line-height: 1.3; font-size: 15px; }
.report-view p { margin: 4px 0 8px; }
.report-view ul, .report-view ol { margin: 4px 0 8px; padding-left: 20px; }
.report-view li { margin-bottom: 2px; }

/* Persistent pointer to unreviewed background intakes (also the reload-recovery path) */
.pending-intake-chip {
  position: fixed; bottom: 24px; left: 24px; z-index: var(--z-toast);
  background: var(--primary-soft); color: var(--primary);
  border: 1px solid var(--primary); border-radius: var(--radius);
  padding: 8px 14px; font-size: 12px; font-weight: 600; cursor: pointer;
  box-shadow: var(--shadow-md);
}
.pending-intake-chip:hover { background: var(--primary); color: #ffffff; }

/* Review + History pages (shared list styles) */
.alerts-page { max-width: 760px; margin: 0 auto; padding: 32px 24px; }
.alerts-page h2 { font-size: 20px; font-weight: 650; letter-spacing: -0.01em; margin-bottom: 4px; }
.page-sub { font-size: 14px; color: var(--text-muted); margin-bottom: 20px; }
.alert-section { margin-bottom: 24px; }
.alert-section h3 { font-size: 15px; font-weight: 600; margin-bottom: 10px; }
.alert-item {
  padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius);
  margin-bottom: 5px; font-size: 14px; display: flex; justify-content: space-between;
  align-items: center; background: var(--surface); gap: 8px;
}
.alert-item:hover { background: var(--surface-sunken); }
.evidence-quote {
  margin: 4px 0 0 0; padding: 6px 10px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: 12px; color: var(--text-muted);
  background: var(--surface-sunken); white-space: pre-wrap;
}
.op-chip {
  font-size: 12px; font-weight: 600; padding: 1px 7px; border-radius: var(--radius-sm);
  background: var(--surface-sunken); color: var(--text); white-space: nowrap;
}
.op-chip.op-risky { background: var(--p2-soft); color: var(--p2); }

/* Proposal review cards (intake review page): three quiet lines —
   what (head) · why (rationale) · how sure (tags) */
.proposal-card {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 12px; margin-bottom: 8px; background: var(--surface);
}
.proposal-card.structural { border-color: var(--p2); }
.proposal-head { display: flex; gap: 8px; align-items: center; min-width: 0; }
.proposal-target {
  font-size: 14px; font-weight: 600; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.proposal-title-input { flex: 1; font-weight: 600; font-size: 14px; }
.proposal-rationale { font-size: 12px; color: var(--text-muted); margin-top: 6px; line-height: 1.5; }
.proposal-tags { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.proposal-tag {
  font-size: 12px; padding: 0 7px; border-radius: var(--radius-sm); line-height: 1.7;
  background: var(--surface-sunken); color: var(--text-muted);
}
.proposal-tag.warn { background: var(--p2-soft); color: var(--p2); }
.proposal-fields { display: flex; gap: 8px; font-size: 12px; margin-top: 8px; }
.proposal-fields select { font-size: 12px; padding: 4px 8px; width: auto; }

/* Placeholder / loading */
.placeholder { color: var(--text-muted); font-style: italic; text-align: center; padding: 32px; }
.loading { color: var(--text-muted); text-align: center; padding: 48px; font-size: 14px; }
.hidden { display: none !important; }

/* Empty states teach the next action */
.empty-state {
  padding: 24px; text-align: center; color: var(--text-muted); font-size: 14px;
  border: 1px dashed var(--border); border-radius: var(--radius); margin-bottom: 12px;
  background: var(--surface);
}

/* Per-proposal actions on the review page. Right-aligned in the tag row so the card
   still reads top-down: what · why · how sure · what to do about it. */
.proposal-card-actions { margin-left: auto; display: inline-flex; gap: 6px; align-items: center; }
.proposal-card-actions .btn-sm { padding: 3px 10px; font-size: 12px; }

/* Origin of a task created from intake: the evidence it was seeded with. Quiet — it is
   context, not instruction. The description below it is what to act on. */
.task-origin {
  margin: 0 0 14px 0; padding: 8px 12px;
  border-left: 2px solid var(--border); background: var(--surface-sunken);
  border-radius: var(--radius-sm);
}
.task-origin-label {
  display: block; font-size: 11px; font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase; color: var(--text-muted); margin-bottom: 3px;
}
.task-origin-text { font-size: 13px; line-height: 1.55; color: var(--text); }
.task-origin-text p { margin: 0 0 4px 0; }
.task-origin .meta { font-size: 11px; }

/* Client switcher. Chrome, not content — stays quiet next to the nav. */
.client-switcher { display: flex; align-items: center; gap: 6px; margin-right: 10px; }
.client-switcher select {
  padding: 5px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font-size: 13px; font-family: var(--font);
  max-width: 200px;
}
.client-add-quiet {
  border: 1px solid var(--border); background: transparent; color: var(--text-muted);
  border-radius: var(--radius-sm); padding: 4px 8px; font-size: 12px; cursor: pointer;
  font-family: var(--font); margin-right: 10px;
}
.client-add-quiet:hover { background: var(--surface-sunken); color: var(--text); }
.client-add { display: inline-flex; align-items: center; gap: 4px; }
.client-add input {
  padding: 5px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font-size: 13px; font-family: var(--font); width: 150px;
}
.client-add .btn { padding: 4px 10px; font-size: 12px; }

/* What's new — release notes read from CHANGELOG.md. Quiet by default; the only
   coloured element is the version/deploy mismatch, which is genuinely actionable. */
.release { margin-bottom: 22px; }
.release-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 6px; }
.release-head h3 { margin: 0; font-size: 15px; }
.release-date { color: var(--text-muted); font-size: 12px; }
.release-running {
  font-size: 11px; padding: 1px 6px; border-radius: 999px;
  border: 1px solid var(--border); color: var(--text-muted);
}
.release-section { margin: 8px 0 0 0; }
.release-section h4 {
  margin: 0 0 4px 0; font-size: 12px; font-weight: 600;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em;
}
.release-section ul { margin: 0 0 0 18px; padding: 0; }
.release-section li { font-size: 13px; line-height: 1.55; margin-bottom: 2px; }
.update-mismatch {
  padding: 10px 14px; margin-bottom: 16px; font-size: 13px; line-height: 1.5;
  border: 1px solid var(--border); border-left: 3px solid var(--p1);
  border-radius: var(--radius); background: var(--surface);
}
.release-howto {
  margin: 24px 0 16px 0; padding: 12px 14px; font-size: 13px; line-height: 1.55;
  border: 1px dashed var(--border); border-radius: var(--radius); color: var(--text-muted);
}
.update-gap-why { margin: 4px 0 8px 0; color: var(--text-muted); font-size: 12px; }
.update-gap-list { margin: 0 0 0 18px; padding: 0; }
.update-gap-list li { font-size: 12px; line-height: 1.6; color: var(--text-muted); }
.update-gap-list code { font-size: 11px; }
.release-howto h4 { margin: 0 0 4px 0; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.release-howto p { margin: 0; }
.release-howto code, .update-mismatch code {
  font-size: 12px; padding: 1px 4px; border-radius: var(--radius-sm);
  background: var(--surface-sunken); border: 1px solid var(--border);
}

/* Recovery banner for analyses that crashed. States a fact and offers one action —
   the paste is safe, so this is not an alarm. Muted, not the P1 accent. */
.failed-intake { margin-bottom: 12px; }
.failed-intake-row {
  padding: 10px 14px; border: 1px solid var(--border); border-left: 3px solid var(--p1);
  border-radius: var(--radius); margin-bottom: 6px; font-size: 14px;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  background: var(--surface);
}
.failed-intake-row .meta {
  display: block; color: var(--text-muted); font-size: 12px; margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60ch;
}
.failed-intake-row button { flex-shrink: 0; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: var(--radius-sm); }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* Markdown rendered content */
.chat-msg.assistant h1, .chat-msg.assistant h2, .chat-msg.assistant h3, .chat-msg.assistant h4,
.research-output h1, .research-output h2, .research-output h3, .research-output h4,
.note-item h1, .note-item h2, .note-item h3, .note-item h4,
.ask-result h1, .ask-result h2, .ask-result h3, .ask-result h4 {
  margin: 12px 0 6px 0;
  font-weight: 600;
  line-height: 1.3;
}
.chat-msg.assistant h1, .research-output h1, .ask-result h1 { font-size: 15px; }
.chat-msg.assistant h2, .research-output h2, .ask-result h2 { font-size: 15px; }
.chat-msg.assistant h3, .research-output h3, .ask-result h3 { font-size: 14px; }
.chat-msg.assistant h4, .research-output h4, .ask-result h4 { font-size: 14px; }

.chat-msg.assistant p, .research-output p, .note-item p, .ask-result p {
  margin: 4px 0 8px 0;
}

.chat-msg.assistant ul, .chat-msg.assistant ol,
.research-output ul, .research-output ol,
.note-item ul, .note-item ol,
.ask-result ul, .ask-result ol {
  margin: 4px 0 8px 0;
  padding-left: 20px;
}
.chat-msg.assistant li, .research-output li, .note-item li, .ask-result li {
  margin-bottom: 2px;
}

.chat-msg.assistant pre, .research-output pre, .note-item pre, .ask-result pre {
  background: var(--code-bg);
  color: var(--code-ink);
  padding: 12px 14px;
  border-radius: var(--radius-md);
  font-size: 12px;
  font-family: var(--font-mono);
  overflow-x: auto;
  margin: 8px 0;
  line-height: 1.5;
}

.chat-msg.assistant code, .research-output code, .note-item code, .ask-result code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--surface-sunken);
  padding: 2px 5px;
  border-radius: var(--radius-sm);
}

.chat-msg.assistant pre code, .research-output pre code, .note-item pre code, .ask-result pre code {
  background: none;
  padding: 0;
}

.chat-msg.assistant a, .research-output a, .note-item a, .ask-result a {
  color: var(--navy);
  text-decoration: underline;
}
.chat-msg.assistant a:hover, .research-output a:hover, .note-item a:hover, .ask-result a:hover {
  color: var(--primary);
}

.chat-msg.assistant strong, .research-output strong, .note-item strong, .ask-result strong {
  font-weight: 600;
}

.chat-msg.assistant em, .research-output em, .note-item em, .ask-result em {
  font-style: italic;
}

/* Memory page */
.memory-page { max-width: 800px; margin: 0 auto; padding: 32px 24px; }
.memory-page h2 { font-size: 20px; font-weight: 650; letter-spacing: -0.01em; margin-bottom: 4px; }
.memory-section { margin-bottom: 28px; }
.memory-section h3 { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.memory-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 20px;
}
.memory-item {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 6px;
  background: var(--surface);
}
.memory-item.pending { border-color: var(--p2); background: var(--p2-soft); }
.memory-content { font-size: 14px; line-height: 1.5; margin-bottom: 6px; }
.memory-meta { display: flex; gap: 6px; flex-wrap: wrap; font-size: 12px; }
.memory-tag {
  background: var(--surface-sunken);
  border-radius: var(--radius-sm);
  padding: 1px 7px;
  font-weight: 500;
  color: var(--text-muted);
  font-size: 12px;
}
.memory-tag.always { background: var(--doing-soft); color: var(--navy); font-weight: 600; }
/* Scope controls on a memory card: click to flip, select to re-file */
button.memory-toggle { border: 1px solid var(--border); cursor: pointer; font-family: var(--font); }
button.memory-toggle:hover { border-color: var(--border-strong); }
.memory-area-select {
  width: auto; font-size: 12px; padding: 1px 4px; border-radius: var(--radius-sm);
  background: var(--surface-sunken); border: 1px solid transparent; color: var(--text-muted);
}
.memory-area-select:hover { border-color: var(--border-strong); }
.memory-source { color: var(--text-muted); font-style: italic; }
.memory-actions { display: flex; gap: 6px; margin-top: 8px; }

/* Form fields (recurring create dialog) */
.form-field { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--text-muted); margin-bottom: 10px; }
.form-field input, .form-field select, .form-field textarea { font-size: 14px; color: var(--text); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }

/* Recurrence seed notes */
.seed-notes { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.seed-note { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 8px; background: var(--surface-sunken); border-radius: var(--radius-sm); font-size: 12px; margin-bottom: 4px; }

/* Linked tasks strip */
.linked-strip { margin-bottom: 20px; }
.link-group { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-bottom: 6px; font-size: 12px; }
.link-group-label { font-weight: 600; color: var(--text-muted); margin-right: 4px; min-width: fit-content; }
.link-chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--surface-sunken); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 2px 6px 2px 8px;
  font-size: 12px; white-space: nowrap;
}
.link-chip a { color: var(--navy); text-decoration: none; font-weight: 500; }
.link-chip a:hover { text-decoration: underline; }
.link-chip-status {
  font-size: 12px; font-weight: 600; padding: 0 4px; border-radius: var(--radius-sm);
}
.link-chip-status.todo { background: var(--surface-sunken); color: var(--text-muted); }
.link-chip-status.doing { background: var(--doing-soft); color: var(--doing); }
.link-chip-status.blocked { background: var(--blocked-soft); color: var(--blocked); }
.link-chip-status.done { background: var(--done-soft); color: var(--done); }
.link-chip-status.backlog { background: var(--surface-sunken); color: var(--text-muted); }
.link-chip-dir { font-style: italic; color: var(--text-muted); font-size: 12px; }
.link-chip-x {
  cursor: pointer; color: var(--text-muted); font-size: 12px; padding: 0 2px;
  border-radius: 50%; line-height: 1;
}
.link-chip-x:hover { color: var(--p1); background: var(--p1-soft); }

/* Link picker */
.link-picker {
  margin-bottom: 20px; padding: 10px; max-width: 72ch;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.link-picker-results {
  margin-top: 8px; max-height: 200px; overflow-y: auto;
  border: 1px solid var(--border); border-radius: var(--radius);
}
.link-picker-item {
  padding: 7px 10px; cursor: pointer; font-size: 14px;
  border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 6px;
}
.link-picker-item:last-child { border-bottom: none; }
.link-picker-item:hover { background: var(--surface-sunken); }

.cost-popover {
  position: absolute; top: 100%; left: 0; margin-top: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-md); padding: 10px 12px; min-width: 240px; z-index: var(--z-dropdown);
  font-size: 12px; color: var(--text);
}
.cost-popover-header { display: flex; justify-content: space-between; align-items: center; font-weight: 600; margin-bottom: 6px; }
.cost-popover-close { cursor: pointer; color: var(--text-muted); font-size: 14px; line-height: 1; }
.cost-popover-row { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; color: var(--text-muted); }
.cost-popover-empty { color: var(--text-muted); }

.intake-spinner {
  width: 14px; height: 14px; flex-shrink: 0;
  border: 2px solid var(--border); border-top-color: var(--primary);
  border-radius: 50%; animation: spin 0.7s linear infinite;
}

/* Reduced motion: state changes become instant; essential progress spinners stay */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; }
  .card.sortable-drag { transform: none; }
  [style*="animation:pulse"], [style*="animation: pulse"] { animation: none !important; }
}
