/* ============================================================
 * Gesher · chat-first UI · canon stylesheet
 *
 * Locked tokens (docs/CANON.md):
 *   --paper #fbf8f1 · --ink #1f1a14 · --orange #ed7611 · --purple #6b46c1
 * Fonts: Inter (UI) + IBM Plex Mono (data/provenance) ONLY.
 * Motifs: section eyebrows, orange left-stripe sections, italic-purple flourish.
 * Vanilla CSS, no framework.
 * ============================================================ */

:root {
  --paper: #fbf8f1;
  --paper-2: #f3ecdf;
  --ink: #1f1a14;
  --ink-soft: #5b5347;
  --ink-faint: #8a8175;
  --orange: #ed7611;
  --orange-soft: #fbe7d2;
  --orange-line: #f3c79a;
  --purple: #6b46c1;
  --purple-soft: #ece6fa;
  --blue: #2563b8;
  --blue-soft: #e6eef9;
  --line: #e4dccd;
  --card: #ffffff;
  --danger: #b4341f;
  --ok: #2f7d4f;
  /* R5 · outline readiness lights (match wireframe screen 5) */
  --green: #2f9e44;
  --grey: #adb5bd;
  --flash: #fff3bf;

  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(31, 26, 20, 0.06);
  --shadow-md: 0 6px 24px rgba(31, 26, 20, 0.10);

  --font-ui: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--purple); }

/* ---- wordmark ---------------------------------------------------------- */
.wordmark {
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.wordmark em {
  font-style: italic;
  color: var(--orange);
  font-weight: 700;
}

/* ---- eyebrow ----------------------------------------------------------- */
.eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--orange);
  margin: 0 0 8px;
}
.eyebrow::before { content: "\00a7\00a0"; }

/* italic-purple flourish */
.flourish { font-style: italic; color: var(--purple); }

/* ---- buttons ----------------------------------------------------------- */
.btn {
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 600;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  border-radius: var(--r-md);
  padding: 10px 18px;
  cursor: pointer;
  transition: transform 0.06s ease, opacity 0.15s ease;
}
.btn:hover { opacity: 0.92; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--orange); border-color: var(--orange); color: #fff; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--paper-2); opacity: 1; }
.btn-sm { padding: 6px 12px; font-size: 13px; }

/* ---- form fields ------------------------------------------------------- */
.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 5px;
}
.field input, .field textarea {
  width: 100%;
  font-family: var(--font-ui);
  font-size: 15px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 10px 12px;
}
.field input:focus, .field textarea:focus {
  outline: none;
  border-color: var(--orange);
  box-shadow: 0 0 0 3px var(--orange-soft);
}
.field .hint { font-size: 12px; color: var(--ink-faint); margin-top: 5px; }
.field--mono input { font-family: var(--font-mono); }

/* ============================================================
 * AUTH
 * ============================================================ */
.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 4px solid var(--orange);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
  padding: 32px 30px;
}
.auth-card h1 { font-size: 26px; margin: 0 0 4px; }
.auth-card .sub { color: var(--ink-soft); margin: 0 0 22px; font-size: 14px; }
.auth-tabs { display: flex; gap: 4px; margin-bottom: 20px; background: var(--paper-2); padding: 4px; border-radius: var(--r-md); }
.auth-tab {
  flex: 1; text-align: center; padding: 8px; font-size: 13px; font-weight: 600;
  color: var(--ink-soft); border-radius: var(--r-sm); cursor: pointer; border: none; background: transparent;
  font-family: var(--font-ui);
}
.auth-tab.active { background: var(--card); color: var(--ink); box-shadow: var(--shadow-sm); }
.auth-card .btn { width: 100%; margin-top: 6px; }
.auth-foot { margin-top: 18px; font-size: 12px; color: var(--ink-faint); text-align: center; }

/* ============================================================
 * PROJECT PICKER
 * ============================================================ */
.shell-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px; border-bottom: 1px solid var(--line);
  background: var(--paper); position: sticky; top: 0; z-index: 10;
}
.shell-bar .wordmark { font-size: 20px; }
.shell-bar .bar-left { display: flex; align-items: center; gap: 18px; min-width: 0; }
.shell-bar .right { display: flex; align-items: center; gap: 14px; }

/* top-level nav (QA6): Chat | Projects */
.topnav { display: flex; gap: 4px; }
.topnav-tab {
  font-family: var(--font-ui); font-size: 14px; font-weight: 600; color: var(--ink-soft);
  background: transparent; border: 1px solid transparent; border-radius: 999px;
  padding: 5px 14px; cursor: pointer; white-space: nowrap;
}
.topnav-tab:hover { color: var(--ink); background: var(--paper-2); }
.topnav-tab.active { color: var(--purple); background: var(--purple-soft); border-color: var(--purple-soft); }
.user-chip {
  font-size: 13px; color: var(--ink-soft);
  display: flex; align-items: center; gap: 8px;
}
.user-chip .avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--purple-soft); color: var(--purple);
  display: grid; place-items: center; font-weight: 700; font-size: 12px;
}

.projects-wrap { max-width: 1040px; margin: 0 auto; padding: 36px 24px 80px; }
.projects-head { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 24px; gap: 16px; flex-wrap: wrap; }
.projects-head h2 { font-size: 24px; margin: 0; }
.projects-head .sub { color: var(--ink-soft); font-size: 14px; margin: 2px 0 0; }

.proj-grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}
.proj-card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 18px 18px 16px;
  cursor: pointer; transition: border-color 0.12s ease, transform 0.06s ease, box-shadow 0.12s ease;
  position: relative; text-align: left;
}
.proj-card:hover { border-color: var(--orange-line); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.proj-card .code { font-family: var(--font-mono); font-size: 11px; color: var(--ink-faint); letter-spacing: 0.04em; }
.proj-card h3 { font-size: 17px; margin: 4px 0 10px; line-height: 1.3; }
.proj-card .chips { display: flex; flex-wrap: wrap; gap: 6px; min-height: 22px; }
.chip {
  font-family: var(--font-mono); font-size: 11px;
  background: var(--paper-2); border: 1px solid var(--line);
  border-radius: 999px; padding: 3px 9px; color: var(--ink-soft); white-space: nowrap;
}
.chip.warn { background: var(--orange-soft); border-color: var(--orange-line); color: #9a4d09; }
.chip.muted { color: var(--ink-faint); }
.proj-card .meta { font-size: 11px; color: var(--ink-faint); margin-top: 12px; }

/* new-project card */
.proj-card.new {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border-style: dashed; border-color: var(--orange-line); background: transparent;
  min-height: 132px; color: var(--orange); font-weight: 600; gap: 6px;
}
.proj-card.new .plus { font-size: 26px; line-height: 1; }
.proj-card.new:hover { background: var(--orange-soft); }

/* empty state */
.empty-cta {
  grid-column: 1 / -1;
  background: var(--card); border: 1px dashed var(--orange-line);
  border-radius: var(--r-lg); padding: 40px 28px; text-align: center;
}
.empty-cta h3 { font-size: 20px; margin: 0 0 8px; }
.empty-cta p { color: var(--ink-soft); max-width: 460px; margin: 0 auto 20px; }

/* ============================================================
 * ROOM SHELL (G2)
 * ============================================================ */
.room-view { height: 100vh; display: flex; flex-direction: column; }
.room-bar { position: static; flex: none; }
.room-bar .bar-left { display: flex; align-items: center; gap: 18px; min-width: 0; }

/* top-bar switchers */
.switch { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.switch-label {
  font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--ink-faint);
}
.switch-select {
  font-family: var(--font-ui); font-size: 13px; font-weight: 600; color: var(--ink);
  background-color: var(--card); border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 5px 26px 5px 9px; cursor: pointer; appearance: none; -webkit-appearance: none;
  max-width: 240px; text-overflow: ellipsis;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6'><path d='M1 1l4 4 4-4' fill='none' stroke='%238a8175' stroke-width='1.5'/></svg>");
  background-repeat: no-repeat; background-position: right 9px center;
}
.switch-select.mono { font-family: var(--font-mono); }
.switch-select:focus { outline: none; border-color: var(--orange); box-shadow: 0 0 0 3px var(--orange-soft); }

/* two-column shell: rail | thread */
.room-shell {
  flex: 1; min-height: 0; position: relative;
  display: grid; grid-template-columns: var(--rail-w, 440px) 1fr;
  transition: grid-template-columns 0.15s ease;
}
.room-shell.rail-collapsed { grid-template-columns: 44px 1fr; }
/* drag-to-resize the rail to any width (persisted). Disabled while collapsed/narrow. */
.room-shell.resizing { transition: none; user-select: none; cursor: col-resize; }
.rail-resizer {
  position: absolute; top: 0; bottom: 0; left: var(--rail-w, 440px);
  width: 8px; margin-left: -4px; z-index: 3; cursor: col-resize; background: transparent;
}
.rail-resizer:hover, .room-shell.resizing .rail-resizer { background: var(--orange-soft); }
.room-shell.rail-collapsed .rail-resizer { display: none; }
@media (max-width: 720px) { .rail-resizer { display: none; } }

/* knowledge rail */
.rail {
  border-right: 1px solid var(--line); background: var(--paper);
  position: relative; overflow-y: auto; min-height: 0;
}
.rail-toggle {
  position: absolute; top: 10px; right: 8px; z-index: 2;
  width: 24px; height: 24px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--card); color: var(--ink-soft);
  cursor: pointer; font-size: 15px; line-height: 1; display: grid; place-items: center;
}
.rail-toggle:hover { background: var(--paper-2); }
.rail-body { padding: 16px 16px 28px; }
.room-shell.rail-collapsed .rail-body { display: none; }
.rail-head h3 { margin: 2px 0 0; font-size: 16px; }
.rail-head .sub { color: var(--ink-soft); font-size: 12px; margin: 4px 0 0; }
.rail-empty { margin-top: 18px; color: var(--ink-soft); }
.rail-empty p { margin: 0 0 8px; }
.rail-empty .hint { font-size: 12px; color: var(--ink-faint); }
.rail-empty .btn { margin-top: 10px; }

/* R1 · rail tabs (Record | Files) */
.rail-tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.rail-tab {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.1em;
  text-transform: uppercase; padding: 5px 12px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--card); color: var(--ink-soft);
  cursor: pointer;
}
.rail-tab:hover { background: var(--paper-2); }
.rail-tab.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.rail-tab:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; }

/* R1 · Files tab */
.files-head h3 { margin: 2px 0 0; font-size: 16px; }
.files-bar {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 8px; margin: 14px 0 10px;
}
.files-count {
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--ink-faint);
}
.files-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.files-filter {
  width: 100%; font-family: var(--font-ui); font-size: 13px; color: var(--ink);
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 8px 10px; margin-bottom: 12px;
}
.files-filter:focus { outline: none; border-color: var(--orange); box-shadow: 0 0 0 3px var(--orange-soft); }
.new-folder-form { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 12px; }
.new-folder-form input {
  flex: 1; min-width: 0; font-family: var(--font-ui); font-size: 13px; color: var(--ink);
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-md); padding: 8px 10px;
}
.new-folder-form input:focus { outline: none; border-color: var(--orange); box-shadow: 0 0 0 3px var(--orange-soft); }

.files-tree { display: flex; flex-direction: column; gap: 8px; }
.files-folder { border: 1px solid var(--line); border-radius: var(--r-md); background: var(--card); overflow: hidden; }
.folder-row {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  padding: 9px 12px; font-size: 13px; font-weight: 600; color: var(--ink);
  background: none; border: none; cursor: pointer;
}
.folder-row.static { cursor: default; }
.folder-row:not(.static):hover { background: var(--paper-2); }
.folder-row .caret { font-size: 11px; color: var(--ink-faint); width: 12px; flex: none; }
.folder-row .folder-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-row .count { font-family: var(--font-mono); font-size: 11px; color: var(--ink-faint); font-weight: 400; margin-left: auto; flex: none; }
.folder-row:focus-visible { outline: 2px solid var(--orange); outline-offset: -2px; }

.file-row {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 8px 12px 8px 26px; font-size: 12.5px; color: var(--ink);
  border-top: 1px dashed var(--line); position: relative;
}
.files-folder.unfiled { border-style: dashed; }
.file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; flex: 1 1 auto; min-width: 60px; }
.chip.kind { font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.08em; flex: none; }
.chip.rev {
  font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.06em; flex: none;
  background: var(--blue-soft); border: 1px solid var(--blue); color: var(--blue); font-weight: 700;
  border-radius: 999px; padding: 1px 7px;
}
.file-acts { display: flex; align-items: center; gap: 4px; margin-left: auto; flex: none; }
.file-acts .sep { color: var(--ink-faint); font-size: 11px; }
.file-act {
  font-size: 11px; color: var(--ink-soft); background: none; border: none; cursor: pointer;
  padding: 2px 3px; border-radius: 4px;
}
.file-act:hover { color: var(--orange); text-decoration: underline; }
.file-act:focus-visible { outline: 2px solid var(--orange); outline-offset: 1px; }

.move-menu {
  position: absolute; right: 12px; top: 100%; z-index: 20; min-width: 140px; max-width: 220px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-md);
  box-shadow: var(--shadow-md); padding: 4px; display: flex; flex-direction: column; gap: 2px;
}
.move-opt {
  text-align: left; font-size: 12.5px; color: var(--ink); background: none; border: none;
  border-radius: var(--r-sm); padding: 7px 9px; cursor: pointer;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.move-opt:hover { background: var(--paper-2); }
.move-empty { font-size: 12px; color: var(--ink-faint); padding: 7px 9px; }

.files-empty { margin-top: 14px; color: var(--ink-soft); }
.files-empty p { margin: 0 0 8px; }
.files-empty .hint { font-size: 12px; color: var(--ink-faint); }

/* R1 · files command reply card in the chat thread */
.msg-bubble.files-note { border-left: 3px solid var(--blue); }
.files-note-cap {
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--blue); margin-bottom: 6px;
}

/* chat thread */
/* min-width:0 is load-bearing: .thread is the 1fr grid track in .room-shell.
   Grid items default to min-width:auto, so without this the track refuses to
   shrink below the composer's intrinsic width and the whole room overflows
   horizontally on narrow phones (QA1). */
.thread { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.thread-scroll { flex: 1; overflow-y: auto; padding: 32px 28px; }
.thread-empty { max-width: 640px; }
.thread-empty h2 { font-size: 24px; margin: 4px 0 10px; }
.thread-empty-lead { color: var(--ink-soft); margin: 0 0 20px; }
.thread-steps { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.thread-steps li {
  background: var(--card); border: 1px solid var(--line); border-left: 3px solid var(--orange-line);
  border-radius: var(--r-md); padding: 12px 14px; color: var(--ink-soft); font-size: 14px;
  display: flex; align-items: center; gap: 10px;
}
.thread-steps strong { color: var(--ink); }
.step-tag {
  margin-left: auto; flex: none; font-family: var(--font-mono); font-size: 10px;
  color: var(--ink-faint); border: 1px solid var(--line); border-radius: 999px; padding: 1px 7px;
}

/* composer */
.composer {
  display: flex; align-items: flex-end; gap: 10px; flex: none;
  padding: 14px 20px; border-top: 1px solid var(--line); background: var(--paper);
}
.composer-file {
  font-family: var(--font-ui); font-size: 13px; font-weight: 600; white-space: nowrap; flex: none;
  border: 1px dashed var(--orange-line); background: var(--orange-soft); color: #9a4d09;
  border-radius: var(--r-md); padding: 9px 12px; cursor: pointer;
}
.composer-file:hover { background: var(--orange-line); }
.composer textarea {
  flex: 1; min-width: 0; resize: none; font-family: var(--font-ui); font-size: 15px; color: var(--ink);
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 10px 12px; max-height: 160px; line-height: 1.4;
}
.composer textarea:focus { outline: none; border-color: var(--orange); box-shadow: 0 0 0 3px var(--orange-soft); }
.composer-send { flex: none; }

/* drag-drop overlay (G3) */
.thread { position: relative; }
.thread-drop {
  position: absolute; inset: 10px; z-index: 20; display: none;
  border: 2px dashed var(--orange); border-radius: var(--r-lg);
  background: rgba(251, 231, 210, 0.86); backdrop-filter: blur(1px);
  place-items: center; pointer-events: none;
}
.thread-drop.active { display: grid; }
.thread-drop-inner { font-weight: 600; color: #9a4d09; font-size: 16px; }

/* ============================================================
 * GENERAL CHAT SURFACE (QA6 · standalone, no project)
 * ============================================================ */
.chat-view { height: 100vh; display: flex; flex-direction: column; }
.chat-view .shell-bar { position: static; flex: none; }
/* min-width:0 so the column never forces horizontal overflow on phones (QA1) */
.chat-surface {
  flex: 1; min-height: 0; min-width: 0; width: 100%; max-width: 880px;
  margin: 0 auto; display: flex; flex-direction: column;
}
.chat-head {
  flex: none; display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; padding: 22px 28px 14px; border-bottom: 1px solid var(--line);
}
.chat-head h2 { font-size: 20px; margin: 2px 0 4px; }
.chat-head .eyebrow { color: var(--purple); }
.chat-head .sub { color: var(--ink-soft); font-size: 13px; margin: 0; max-width: 560px; }
.chat-disc { flex: none; }
.linkish {
  background: none; border: none; padding: 0; cursor: pointer;
  color: var(--purple); font: inherit; font-weight: 600; text-decoration: underline;
}
.chat-thread { flex: 1; min-height: 0; min-width: 0; display: flex; flex-direction: column; }
/* the chat surface owns its own thread-scroll (id reused so the shared
   append/render helpers work) */
.chat-thread .thread-scroll { flex: 1; }
.chat-composer { max-width: 880px; width: 100%; margin: 0 auto; }
.chat-disclaimer {
  flex: none; margin: 0; padding: 6px 20px 12px; text-align: center;
  font-size: 11px; color: var(--ink-faint); background: var(--paper);
}
.chat-empty .chat-examples { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.example-chip {
  font-family: var(--font-ui); font-size: 14px; font-weight: 500; text-align: left;
  background: var(--card); border: 1px solid var(--line); border-left: 3px solid var(--purple);
  border-radius: var(--r-md); padding: 10px 14px; cursor: pointer; color: var(--ink-soft);
  max-width: 100%;
}
.example-chip:hover { border-color: var(--purple); color: var(--ink); background: var(--purple-soft); }

/* upload / extract cards (G3) */
.upload-card {
  background: var(--card); border: 1px solid var(--line); border-left: 3px solid var(--orange-line);
  border-radius: var(--r-md); padding: 12px 14px; margin: 0 0 14px; max-width: 680px;
}
.upload-card.done { border-left-color: var(--ok); }
.upload-card.error { border-left-color: var(--danger); }
.uc-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 6px; }
.uc-file { font-weight: 600; font-size: 14px; word-break: break-word; }
.uc-size { font-family: var(--font-mono); font-size: 11px; color: var(--ink-faint); flex: none; }
.uc-body { font-size: 14px; color: var(--ink-soft); }
.uc-status { color: var(--ink-soft); }
.uc-elapsed { font-family: var(--font-mono); }
.uc-pct { font-family: var(--font-mono); font-weight: 600; color: #9a4d09; }
/* SPEC-ASYNC-EXTRACTION · async per-page extraction progress bar */
.uc-bar { margin-top: 6px; height: 5px; border-radius: 3px; background: var(--line, #e7e2d8); overflow: hidden; }
.uc-bar-fill { height: 100%; background: #9a4d09; border-radius: 3px; transition: width .35s ease; }
.uc-result { margin: 0 0 4px; color: var(--ink); }
.uc-result strong { font-family: var(--font-mono); }
.uc-result .uc-conf { color: #9a4d09; }
.uc-disc { margin: 0; font-size: 12px; color: var(--ink-faint); }
.uc-err { margin: 0 0 8px; color: var(--danger); }
.uc-retry { margin-top: 2px; }

/* R2 · folder multi-upload — batch card + proposed-filing table */
.msg-bubble.batch-card { border-left: 3px solid var(--blue); }
.batch-card p { margin: 0 0 6px; font-size: 14px; color: var(--ink-soft); }
.batch-card p strong { font-family: var(--font-mono); color: var(--ink); }
.batch-progress {
  height: 6px; background: var(--blue-soft); border-radius: 999px;
  overflow: hidden; margin: 8px 0;
}
.batch-progress i { display: block; height: 100%; background: var(--blue); transition: width 0.3s ease; }
.batch-card .secline { font-size: 12px; color: var(--ink-faint); }
.prop-table {
  width: 100%; border-collapse: collapse; margin: 8px 0; font-size: 13px;
  table-layout: fixed;
}
.prop-table th, .prop-table td {
  text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line);
  word-break: break-word; vertical-align: top;
}
.prop-table th {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--ink-faint); font-weight: 600;
}
.prop-table td:first-child { font-family: var(--font-mono); white-space: nowrap; }
.prop-folder { font-weight: 600; color: var(--blue); }
.prop-unfiled { color: var(--ink-faint); font-weight: 400; font-style: italic; }
.prop-folder-input {
  width: 100%; box-sizing: border-box; padding: 4px 6px; font: inherit;
  border: 1px solid var(--blue); border-radius: var(--r-sm); background: var(--card);
}
.prop-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.batch-failures { margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--line); }
.batch-fail-cap { font-size: 12px; color: var(--danger); margin: 0 0 4px; }
.batch-fail-row { font-size: 12px; color: var(--ink-soft); margin: 0 0 2px; }
/* R2-followup-A · skipped duplicates ("already in the project") */
.batch-dupes { margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--line); }
.batch-dupe-cap { font-size: 12px; color: var(--ink-soft); margin: 0 0 6px; }
.batch-dupe-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 4px;
  font-size: 12px; color: var(--ink-soft);
}
.batch-dupe-name { flex: 1 1 60%; min-width: 0; word-break: break-word; }
.batch-dupe-status { font-size: 12px; color: var(--blue); }

/* R4 · proposed photo-appendix card */
.msg-bubble.appendix-card { border-left: 3px solid var(--blue); }
.appendix-card p { margin: 0 0 6px; font-size: 14px; color: var(--ink-soft); }
.appendix-card .secline { font-size: 12px; color: var(--ink-faint); }
.ap-title-input {
  font: inherit; font-weight: 700; color: var(--ink); padding: 1px 5px;
  border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--card);
  min-width: 140px; max-width: 100%;
}
.appendix-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 8px 0;
}
.appendix-grid .gph {
  border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden;
  background: var(--card); min-width: 0;
}
.appendix-grid .gph-img {
  height: 56px; background: var(--blue-soft);
  border-bottom: 1px solid var(--line);
}
.appendix-grid .gph-cap {
  display: block; width: 100%; box-sizing: border-box; padding: 4px 6px;
  font: inherit; font-size: 12px; border: 0; background: transparent; color: var(--ink-soft);
}
.appendix-grid .gph-cap:focus { outline: 2px solid var(--blue); outline-offset: -2px; }
.seg-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.btn.seg { background: var(--card); border: 1px solid var(--line); color: var(--ink-soft); }
.btn.seg.seg-on {
  background: var(--blue-soft); border-color: var(--blue); color: var(--blue); font-weight: 700;
}
.ap-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.ap-letter-note { margin-top: 8px; }
@media (max-width: 360px) { .appendix-grid { grid-template-columns: 1fr; } }

/* rail counts (G3) — the field list itself lands in G4 */
.rail-counts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 14px 0 6px; }
.rail-counts .count {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 8px 10px; display: flex; flex-direction: column; gap: 1px;
}
.rail-counts .count.warn { background: var(--orange-soft); border-color: var(--orange-line); }
.rail-counts .n { font-family: var(--font-mono); font-size: 18px; font-weight: 600; color: var(--ink); }
.rail-counts .count.warn .n { color: #9a4d09; }
.rail-counts .k { font-size: 11px; color: var(--ink-faint); }
.rail-note { font-size: 12px; color: var(--ink-faint); margin: 8px 0 0; }
.rail-note.warn { color: #9a4d09; }
.step-tag.done { color: var(--ok); border-color: var(--ok); }
.rail-loading { padding: 20px; display: grid; place-items: center; }

/* conflicts block (G4) — pinned at top, orange-tinted */
.conflicts-block {
  margin: 14px 0 6px; background: var(--orange-soft);
  border: 1px solid var(--orange-line); border-radius: var(--r-md); padding: 10px 10px 4px;
}
.cb-head { margin: 0 0 8px; font-size: 12px; font-weight: 700; color: #9a4d09; letter-spacing: 0.01em; }
.conflict { background: var(--card); border: 1px solid var(--orange-line); border-radius: var(--r-sm); padding: 9px 10px; margin-bottom: 8px; }
.conflict.resolving { opacity: 0.5; }
.cf-field { margin: 0 0 6px; font-family: var(--font-mono); font-size: 12px; font-weight: 600; color: var(--ink); word-break: break-word; }
.cf-side { display: flex; gap: 7px; align-items: flex-start; margin-bottom: 4px; }
.cf-tag { flex: none; width: 16px; height: 16px; border-radius: 50%; background: var(--paper-2); color: var(--ink-soft); font-size: 10px; font-weight: 700; display: grid; place-items: center; margin-top: 1px; }
.cf-meta { display: flex; flex-direction: column; min-width: 0; }
.cf-val { font-size: 13px; color: var(--ink); word-break: break-word; }
.cf-src { font-family: var(--font-mono); font-size: 10px; color: var(--ink-faint); }
.cf-actions { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.cf-actions .btn { padding: 4px 9px; font-size: 12px; }

/* R3 · revision updates — blue, above the orange conflicts */
.revupd-block {
  margin: 14px 0 6px; background: var(--blue-soft);
  border: 1px solid var(--blue); border-radius: var(--r-md); padding: 10px 10px 4px;
}
.ru-head { margin: 0 0 8px; font-size: 12px; font-weight: 700; color: var(--blue); letter-spacing: 0.01em; }
.revupd { background: var(--card); border: 1px solid var(--blue); border-radius: var(--r-sm); padding: 9px 10px; margin-bottom: 8px; }
.revupd.resolving { opacity: 0.5; }
.ru-field { margin: 0 0 5px; font-family: var(--font-mono); font-size: 12px; font-weight: 600; color: var(--ink); word-break: break-word; }
.ru-change { margin: 0; font-size: 13px; color: var(--ink); word-break: break-word; }
.ru-rev { display: inline-block; font-family: var(--font-mono); font-size: 10px; font-weight: 700; color: var(--ink-soft); background: var(--paper-2); border-radius: 4px; padding: 1px 5px; }
.ru-rev.ru-new { background: var(--blue-soft); color: var(--blue); }
.ru-actions { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.ru-actions .btn { padding: 4px 9px; font-size: 12px; }

/* R3 · "looks like a revision" stack proposal + revision-history expander */
.msg-bubble.revstack-card { border-left: 3px solid var(--blue); }
.revstack-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.file-history { padding: 6px 10px 8px 16px; border-left: 2px solid var(--blue-soft); margin: 0 0 6px; }
.fh-head { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-faint); margin: 0 0 6px; }
.fh-empty { font-size: 12px; color: var(--ink-soft); margin: 0; }
.fh-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 12px; padding: 3px 0; }
.fh-rev { font-family: var(--font-mono); font-weight: 700; color: var(--blue); }
.fh-name { min-width: 0; word-break: break-word; color: var(--ink); }
.fh-when { color: var(--ink-faint); font-size: 11px; }
.fh-superseded { font-size: 10px; color: var(--ink-faint); text-transform: uppercase; letter-spacing: 0.05em; }
.fh-current { font-size: 10px; }

/* field list (G4 · grouped in QA2) */
.field-list { margin-top: 14px; }
.fl-group { margin-bottom: 14px; }
.fl-group:last-child { margin-bottom: 0; }
.fl-head { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-faint); margin: 0 0 6px; }
.fl-hint { font-size: 11px; color: var(--ink-faint); margin: 0 0 6px; font-style: italic; }

/* clickable count tile (jumps to the field list) */
.rail-counts .count-link { font: inherit; text-align: left; cursor: pointer; }
.rail-counts .count-link:hover { border-color: var(--orange-line); }
.field-row { border-bottom: 1px solid var(--line); }
.fr-summary {
  width: 100%; display: flex; align-items: center; gap: 8px; text-align: left;
  background: transparent; border: none; cursor: pointer; padding: 8px 2px; font-family: var(--font-ui);
}
.fr-summary:hover { background: var(--paper-2); }
.fr-name { font-size: 12px; color: var(--ink-soft); flex: none; max-width: 42%; word-break: break-word; }
.fr-value { font-size: 13px; color: var(--ink); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fr-flag { flex: none; font-family: var(--font-mono); font-size: 11px; }
.fr-flag.eng { color: var(--purple); }
.fr-flag.warn { color: #9a4d09; }
.fr-flag.corr { color: var(--ok); }
.fr-detail { padding: 6px 4px 12px; }
.fr-prov-head { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-faint); margin: 0 0 6px; }
.fr-src { margin-bottom: 7px; display: flex; flex-direction: column; gap: 2px; }
.fr-src-doc { font-family: var(--font-mono); font-size: 11px; color: var(--ink-soft); }
.fr-src-quote { font-size: 12px; color: var(--ink-faint); font-style: italic; line-height: 1.4; }
.fr-edit { display: flex; gap: 6px; margin-top: 8px; }
.fr-edit-input { flex: 1; min-width: 0; font-family: var(--font-ui); font-size: 13px; color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 6px 8px; }
.fr-edit-input:focus { outline: none; border-color: var(--orange); box-shadow: 0 0 0 3px var(--orange-soft); }
.fr-save { flex: none; }
.fr-edit-note { font-size: 11px; color: var(--ink-faint); margin: 6px 0 0; }

/* chat messages (G5) */
.msg { display: flex; margin: 0 0 16px; max-width: 760px; }
.msg.user { justify-content: flex-end; }
.msg-bubble {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 12px 14px; font-size: 15px; line-height: 1.55; max-width: 88%;
}
.msg.user .msg-bubble { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.msg.assistant .msg-bubble { color: var(--ink-soft); }
/* project-sourced prose gets the canon orange left-stripe */
.msg-bubble.project { border-left: 3px solid var(--orange); max-width: 100%; }
.msg-bubble.error { border-left: 3px solid var(--danger); }
.msg-status { color: var(--ink-soft); }
.draft-prose { color: var(--ink); white-space: normal; }

/* SD1 · live-reveal draft — phase line above the prose as it streams in */
.live-draft .live-phase {
  display: flex; align-items: center; gap: 7px;
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--ink-soft); margin-bottom: 8px;
}
.live-draft .live-prose:empty { min-height: 1.1em; }
/* soft caret while prose is still arriving */
.live-draft .live-prose::after {
  content: "▍"; color: var(--orange); opacity: 0.7;
  animation: lpblink 1s steps(1) infinite; margin-left: 1px;
}
@keyframes lpblink { 50% { opacity: 0; } }

/* inline highlights */
mark.hl-confirm { background: var(--orange-soft); color: #9a4d09; border-radius: 3px; padding: 0 3px; font-weight: 500; }
mark.hl-conflict { background: var(--purple-soft); color: var(--purple); border-radius: 3px; padding: 0 3px; font-weight: 500; }

/* engineer-to-confirm chips */
.draft-confirm { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 13px; }
.dc-head { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: #9a4d09; margin-right: 6px; }
.dc-chip { display: inline-block; font-family: var(--font-mono); font-size: 11px; background: var(--orange-soft); border: 1px solid var(--orange-line); border-radius: 999px; padding: 2px 8px; color: #9a4d09; margin: 2px 2px 0 0; }

/* SD2 · citation-QA trust beat */
.cite-qa { margin-top: 12px; }
.cite-qa-chip { display: inline-flex; align-items: center; gap: 5px; font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.02em; border-radius: 999px; padding: 3px 10px; }
.cite-qa-chip.ok { background: #e6f3ec; border: 1px solid #bfe0cd; color: var(--ok); }
.cite-qa-chip.warn { background: var(--orange-soft); border: 1px solid var(--orange-line); color: #9a4d09; }
.cite-qa-flags { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.cite-qa-flag { font-size: 12px; line-height: 1.4; padding-left: 10px; border-left: 2px solid var(--orange-line); }
.cite-qa-flag.err { border-left-color: var(--orange); }
.cqf-cite { font-family: var(--font-mono); font-size: 11px; color: var(--ink); background: var(--orange-soft); border-radius: 4px; padding: 1px 5px; }
.cqf-msg { color: var(--ink-soft); }
.cqf-fix { font-family: var(--font-mono); font-size: 11px; color: var(--ok); white-space: nowrap; }

/* SD3 · clickable inline citation superscripts + provenance popover */
.cite-ref { display: inline-block; font-family: var(--font-mono); font-size: 9px; line-height: 1; font-weight: 600; color: var(--purple); background: var(--purple-soft); border-radius: 4px; padding: 1px 4px; margin-left: 2px; cursor: pointer; vertical-align: super; user-select: none; }
.cite-ref:hover, .cite-ref:focus { background: var(--purple); color: #fff; outline: none; }
.cite-num { display: inline-block; font-family: var(--font-mono); font-size: 10px; font-weight: 600; color: var(--purple); background: var(--purple-soft); border-radius: 4px; padding: 0 5px; margin-right: 4px; }
.cite-pop { position: absolute; z-index: 90; width: 320px; max-width: calc(100vw - 16px); background: var(--paper, #fbf8f1); border: 1px solid var(--purple-soft); border-left: 3px solid var(--purple); border-radius: 8px; box-shadow: 0 8px 28px rgba(31,26,20,0.18); padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; }
.cite-pop::before { content: ''; position: absolute; top: -8px; left: var(--arrow-x, 16px); transform: translateX(-50%); width: 0; height: 0; border: 8px solid transparent; border-bottom: 8px solid var(--purple-soft); border-top: none; }
.cite-pop::after { content: ''; position: absolute; top: -6px; left: var(--arrow-x, 16px); transform: translateX(-50%); width: 0; height: 0; border: 7px solid transparent; border-bottom: 7px solid var(--paper, #fbf8f1); border-top: none; }
.cite-pop-src { font-family: var(--font-mono); font-size: 11px; color: var(--ink-soft); }
.cite-pop-fact { font-size: 13px; color: var(--ink); }
.cite-pop-quote { font-size: 12px; color: var(--ink-faint); font-style: italic; line-height: 1.4; }

/* citations panel (collapsible) */
.draft-cites { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 8px; }
.draft-cites summary { cursor: pointer; font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--purple); }
.cite { margin: 8px 0 0; padding-left: 10px; border-left: 2px solid var(--purple-soft); display: flex; flex-direction: column; gap: 2px; cursor: pointer; }
.cite:hover { border-left-color: var(--purple); }
.cite-fact { font-size: 13px; color: var(--ink); }
.cite-src { font-family: var(--font-mono); font-size: 11px; color: var(--ink-soft); }
.cite-quote { font-size: 12px; color: var(--ink-faint); font-style: italic; line-height: 1.4; }

/* per-turn export (G6) */
.draft-actions { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.draft-export { font-size: 13px; }

/* ---- G5b · general-guidance turns (NOT project-sourced) ----------------
 * Deliberately distinct from project prose: purple left-stripe (never the
 * orange project stripe), an explicit "not sourced from your docs" eyebrow,
 * no citations panel, no DOCX export. An engineer must never mistake general
 * knowledge for a project-sourced fact. */
.msg-bubble.general { border-left: 3px solid var(--purple); max-width: 100%; }
.general-eyebrow {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--purple); margin: 0 0 8px;
  display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap;
}
.general-eyebrow::before { content: "\00a7\00a0"; }
.general-eyebrow .ge-note { color: var(--ink-faint); text-transform: none; letter-spacing: 0; font-size: 11px; }
.general-prose { color: var(--ink); white-space: normal; }
/* 1.5 · brain-loop provenance tags — inline claim-origin labels */
.prov-tag { display: inline-block; font-size: 10px; font-weight: 600; padding: 1px 4px; border-radius: 3px; vertical-align: middle; margin-left: 2px; letter-spacing: .02em; line-height: 1.4; }
.prov-project  { background: var(--orange-soft); color: var(--orange); }
.prov-standard { background: var(--blue-soft);   color: var(--blue); }
.prov-general  { background: var(--purple-soft); color: var(--purple); }
.prov-unverified { background: #fff3cd; color: #6b4c00; }
.general-standards { margin-top: 12px; padding-top: 8px; border-top: 1px solid var(--line); font-size: 13px; }
.gs-head { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--purple); margin-right: 6px; }
.gs-chip { display: inline-block; font-family: var(--font-mono); font-size: 11px; background: var(--purple-soft); border: 1px solid var(--purple-soft); border-radius: 999px; padding: 2px 8px; color: var(--purple); margin: 2px 2px 0 0; }
/* K2/K3 · drawing/spec catalogue lookup chips on a general-chat turn */
.general-drawings { margin-top: 12px; padding-top: 8px; border-top: 1px solid var(--line); }
.gd-head { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--purple); margin-bottom: 6px; }
.gd-row { font-size: 13px; padding: 3px 0; }
.gd-row.gd-top { font-weight: 600; }
.gd-link { color: var(--purple); text-decoration: none; border-bottom: 1px solid var(--purple-soft); }
.gd-link:hover { border-bottom-color: var(--purple); }
.gd-dl { font-family: var(--font-mono); font-size: 10px; color: var(--purple); margin-left: 6px; opacity: 0.75; }
.gd-nolink { color: var(--ink-soft, #6b6b78); }
.gd-nolink em { font-style: italic; opacity: 0.8; }
.gd-foot { font-size: 11px; color: var(--ink-soft, #6b6b78); margin-top: 6px; }
/* PV3 · MRWA server-side fetched document attachment */
.pv3-attachment { margin-top: 10px; }
.pv3-dl-btn { display: inline-block; background: var(--purple); color: #fff; font-size: 13px; font-weight: 600; padding: 7px 14px; border-radius: 6px; text-decoration: none; }
.pv3-dl-btn:hover { opacity: 0.88; }
.pv3-att-note { font-size: 11px; color: var(--ink-soft, #6b6b78); margin-top: 4px; }
/* GP-2 · "Verify at source" chips for KB-grounded general answers */
.general-sources { margin-top: 12px; padding-top: 8px; border-top: 1px solid var(--line); font-size: 13px; }
.gs-verify { display: inline-block; font-family: var(--font-mono); font-size: 11px; color: var(--purple); border: 1px solid var(--purple-soft); border-radius: 999px; padding: 2px 8px; text-decoration: none; margin: 2px 2px 0 0; }
.gs-verify:hover { background: var(--purple-soft); }
/* Cited but no harvested link yet (library URL backfill pending) — muted, not
   clickable-looking, so it reads as "this was cited" not "click me". */
.gs-verify--nolink { color: var(--ink-soft, #6b7280); border-style: dashed; cursor: help; }
.gs-verify--nolink:hover { background: transparent; }
/* corpus-freshness v1 · superseded-edition warning chip — amber/danger-toned so the
   engineer verifies against the current edition. Mirrors the gs-verify pill shape. */
.gs-superseded { display: inline-block; font-family: var(--font-mono); font-size: 11px; color: var(--danger); background: var(--orange-soft, #fdf1e3); border: 1px solid var(--danger); border-radius: 999px; padding: 2px 8px; margin: 2px 2px 0 0; cursor: help; }

/* PF-B · report-template offer in the general chat */
.template-offer .to-title { font-size: 15px; margin: 2px 0 8px; }
.template-offer .to-jx-note { font-size: 12px; color: var(--orange); background: var(--orange-soft, #fdf1e3); border-radius: 8px; padding: 7px 10px; margin: 0 0 10px; }
.template-offer .to-block { margin-top: 12px; padding-top: 8px; border-top: 1px solid var(--line); }
.template-offer .to-head { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--purple); margin-bottom: 6px; }
.template-offer .to-sections { margin: 0; padding-left: 20px; font-size: 13px; }
.template-offer .to-sections li { margin: 3px 0; }
.template-offer .to-sec-title { font-weight: 600; }
.template-offer .to-sec-guide { color: var(--ink-faint); }
.template-offer .to-list { margin: 0; padding-left: 18px; font-size: 13px; }
.template-offer .to-list li { margin: 2px 0; }
.template-offer .to-download { margin-top: 14px; }

/* ============================================================
 * MODAL
 * ============================================================ */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(31, 26, 20, 0.42);
  display: grid; place-items: center; padding: 24px; z-index: 50;
}
.modal {
  width: 100%; max-width: 440px; background: var(--card);
  border-radius: var(--r-lg); box-shadow: var(--shadow-md);
  border-top: 4px solid var(--orange); padding: 26px 26px 22px;
}
.modal h3 { margin: 0 0 16px; font-size: 19px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }

/* ============================================================
 * TOASTS / MISC
 * ============================================================ */
#toasts { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--ink); color: var(--paper); padding: 11px 18px;
  border-radius: var(--r-md); font-size: 14px; box-shadow: var(--shadow-md);
  animation: toast-in 0.18s ease;
}
.toast.error { background: var(--danger); }
.toast.ok { background: var(--ok); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.spinner {
  width: 16px; height: 16px; border: 2px solid var(--orange-line);
  border-top-color: var(--orange); border-radius: 50%; display: inline-block;
  animation: spin 0.7s linear infinite; vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

.center-load { min-height: 60vh; display: grid; place-items: center; color: var(--ink-faint); }

/* ---- responsive (down to ~380px) -------------------------------------- */

/* Room: below 720px the rail keeps a 44px strip; expanding it slides an
   overlay over the thread so the chat keeps full width on narrow screens. */
/* the off-canvas dismiss backdrop — only ever visible while the rail is open as
   a mobile overlay; sits above the thread, below the rail (QA1). */
.rail-backdrop { display: none; }

@media (max-width: 720px) {
  .room-shell, .room-shell.rail-collapsed { grid-template-columns: 44px 1fr; }
  .room-shell:not(.rail-collapsed) .rail {
    position: absolute; top: 0; bottom: 0; left: 0; width: 280px; max-width: 86vw;
    z-index: 30; box-shadow: var(--shadow-md);
  }
  .room-shell:not(.rail-collapsed) .rail-backdrop:not([hidden]) {
    display: block; position: absolute; inset: 0; z-index: 25;
    background: rgba(31, 26, 20, 0.32);
  }
  .room-bar .bar-left { gap: 12px; }
  .switch-select { max-width: 130px; }
  .thread-scroll { padding: 24px 18px; }
  .composer { padding: 12px 14px; }
  /* QA6 chat surface: stack the head, keep 0 horizontal overflow */
  .shell-bar .bar-left { gap: 12px; }
  .chat-head { flex-direction: column; align-items: stretch; gap: 10px; padding: 16px 16px 12px; }
  .chat-disc { align-self: flex-start; }
}

/* very narrow phones (~320px): tighten the top bar so switchers + sign-out fit
   without forcing horizontal scroll. */
@media (max-width: 360px) {
  .shell-bar { padding: 10px 12px; }
  .room-bar .bar-left { gap: 9px; }
  .switch-select { max-width: 92px; padding: 5px 22px 5px 7px; }
  .shell-bar .right { gap: 8px; }
  .thread-scroll { padding: 20px 14px; }
  /* QA6: drop the wordmark + name so Chat|Projects + sign-out always fit */
  .shell-bar .bar-left { gap: 8px; }
  .shell-bar .wordmark { display: none; }
  .topnav-tab { padding: 5px 10px; font-size: 13px; }
  .chat-composer { padding: 12px 14px; }
  /* R1 · Files tab — keep rows clean on the narrowest phones */
  .file-row { padding-left: 18px; gap: 5px; }
  .files-bar { gap: 6px; }
  .file-acts { margin-left: 0; }
  /* R2 · composer now carries two upload buttons (+ doc / + folder) — tighten
     so they + textarea + Send still fit at ~320px with 0 horizontal overflow. */
  .composer { gap: 6px; padding: 12px 10px; }
  .composer-file { padding: 8px 8px; font-size: 12px; }
}

@media (max-width: 480px) {
  .shell-bar { padding: 12px 16px; }
  .projects-wrap { padding: 24px 16px 60px; }
  .proj-grid { grid-template-columns: 1fr; }
  .auth-card { padding: 26px 22px; }
  .user-chip .label { display: none; }
  .room-bar .wordmark { display: none; }    /* reclaim space for switchers */
  .switch-select { max-width: 108px; }
}

/* ---- PD2 · Generate report (rail action + in-thread progress) ---------- */
.btn-block { display: block; width: 100%; }
.rail-report { padding: 12px 14px 4px; border-top: 1px solid var(--line); margin-top: 8px; }
.rail-report .hint { font-size: 12px; color: var(--ink-faint); margin: 8px 2px 0; }

.report-card { min-width: 0; }
.report-eyebrow { font-size: 11px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--purple); font-weight: 600; margin: 0 0 8px; }
.report-pick { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.report-pick .switch-select { max-width: 100%; }
.report-card .hint { font-size: 12px; color: var(--ink-soft); margin: 8px 0; }
.report-err { color: var(--danger); font-size: 13px; }

.report-progress { min-width: 0; }
.report-eyebrow2 { font-weight: 600; margin: 0 0 6px; font-size: 14px; }
.report-status { font-size: 13px; color: var(--ink-soft); margin: 0 0 10px; }
.report-status code, .report-card code { font-family: var(--font-mono); font-size: 12px;
  background: var(--orange-soft); color: var(--orange); padding: 1px 5px; border-radius: var(--r-sm); }
.report-secs { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.report-row { display: flex; align-items: flex-start; gap: 8px; font-size: 13px;
  color: var(--ink-faint); line-height: 1.4; }
.report-row.current { color: var(--ink); font-weight: 600; }
.report-row.done { color: var(--ink-soft); }
.report-tick { flex: 0 0 auto; width: 14px; text-align: center; color: var(--ink-faint); }
.report-row.done .report-tick { color: var(--ok); }
.report-row.current .report-tick { color: var(--purple); }
.report-outline-sum { font-size: 12px; color: var(--ink-soft); margin: 0 0 10px;
  padding: 6px 10px; background: var(--purple-soft, rgba(124,92,196,0.08));
  border-left: 3px solid var(--purple); border-radius: var(--r-sm); }
.report-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

/* PD3 · review-readiness audit checklist */
.report-audit { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--orange-line); min-width: 0; }
.audit-status { font-size: 13px; font-weight: 600; margin: 0 0 6px; }
.audit-status .audit-count { font-weight: 400; color: var(--ink-soft); font-size: 12px; }
.audit-ready { color: var(--ok); }
.audit-blocked { color: var(--danger); }
.audit-blockers { margin: 0 0 8px; padding-left: 18px; list-style: disc; }
.audit-blockers li { color: var(--danger); font-size: 12px; margin: 2px 0; }
.audit-items { margin: 4px 0 10px; }
.audit-items > summary { cursor: pointer; font-size: 12px; color: var(--purple); }
.audit-list { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.audit-item { display: flex; align-items: flex-start; gap: 6px; font-size: 12px; flex-wrap: wrap; min-width: 0; }
.audit-item .ai-mark { flex: 0 0 auto; width: 12px; text-align: center; }
.audit-item .ai-label { color: var(--ink); }
.audit-item .ai-detail { color: var(--ink-soft); flex-basis: 100%; padding-left: 18px; }
.ai-ok .ai-mark { color: var(--ok); }
.ai-ok .ai-label { color: var(--ink-soft); }
.ai-blk .ai-mark, .ai-blk .ai-label { color: var(--danger); }
.ai-warn .ai-mark, .ai-warn .ai-label { color: var(--orange); }
.ai-info .ai-mark { color: var(--ink-faint); }
.report-markready { margin-top: 2px; }

/* GM-2 · report sign-off / finalisation gate */
.report-signoff { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--orange-line); min-width: 0; }
.signoff-badge { font-size: 13px; margin: 0; }
.signoff-tick { color: var(--ok); font-weight: 700; }
.signoff-form { display: flex; flex-direction: column; gap: 8px; }
.signoff-label { font-size: 12px; color: var(--ink-soft); margin: 0; }
.signoff-name, .signoff-note { width: 100%; box-sizing: border-box; padding: 6px 8px; border: 1px solid var(--line); border-radius: 4px; font-size: 13px; font-family: inherit; background: var(--paper); color: var(--ink); }
.signoff-name:focus, .signoff-note:focus { outline: none; border-color: var(--purple); }
.signoff-form-btns { display: flex; gap: 8px; }

/* PD4 · post-generation verification */
.report-verify { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--orange-line); min-width: 0; }
.verify-status { font-size: 13px; font-weight: 600; margin: 0 0 6px; }
.verify-status .verify-count { font-weight: 400; color: var(--ink-soft); font-size: 12px; }
.verify-ok { color: var(--ok); }
.verify-flagged { color: var(--orange); }
.verify-items { margin: 4px 0 6px; }
.verify-items > summary { cursor: pointer; font-size: 12px; color: var(--purple); }
.verify-list { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; gap: 5px; }
.verify-item { display: flex; flex-direction: column; gap: 2px; font-size: 12px; min-width: 0; padding-left: 8px; border-left: 2px solid var(--orange-line); }
.verify-item.vf-bad { border-left-color: var(--danger); }
.verify-item .vf-val { font-weight: 600; color: var(--ink); }
.vf-bad .vf-val { color: var(--danger); }
.verify-item .vf-sentence { color: var(--ink-soft); }

/* ===========================================================================
   R5 · THE OUTLINE INTERFACE (wireframe screen 5) — takes over the rail as a
   mode. Readiness dots (green/orange/grey), drag handle + keyboard reorder,
   click-to-rename, mode pills, per-section expand, footer contract.
   =========================================================================== */
.outline-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.outline-head .rail-title {
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--ink-soft); min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.outline-list { margin-top: 10px; }
.o-rowwrap { min-width: 0; }
.o-row {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--card);
  margin-bottom: 6px; font-size: 13px; min-width: 0;
}
.o-row.flash { background: var(--flash); transition: background 0.5s ease; }
.o-row.dragging { opacity: 0.5; }
.o-row.drag-over { border-color: var(--orange); box-shadow: 0 -2px 0 var(--orange) inset; }
.o-row .drag { color: var(--grey); font-size: 13px; letter-spacing: -1px; cursor: grab; flex: none; }
.o-mvs { display: inline-flex; flex-direction: column; gap: 1px; flex: none; }
.o-mv {
  border: 1px solid var(--line); background: var(--card); color: var(--ink-soft);
  font-size: 8px; line-height: 1; padding: 1px 3px; border-radius: 3px; cursor: pointer;
}
.o-mv:hover { border-color: var(--orange); color: var(--orange); }
.o-row .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.o-row .dot.g { background: var(--green); }
.o-row .dot.o { background: var(--orange); }
.o-row .dot.x { background: var(--grey); }
.o-num { font-family: var(--font-mono); font-size: 11px; color: var(--ink-soft); width: 18px; flex: none; }
.o-title {
  border: none; background: transparent; font: inherit; color: var(--ink);
  text-align: left; padding: 2px 4px; border-radius: 4px; cursor: text;
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.o-title:hover { background: var(--paper-2); }
.o-rename {
  font: inherit; padding: 2px 6px; border: 1px solid var(--orange);
  border-radius: 4px; background: var(--card); color: var(--ink); min-width: 0; flex: 1;
}
.o-row .pill {
  margin-left: auto; flex: none; font-family: var(--font-mono); font-size: 10px;
  letter-spacing: 0.06em; border-radius: 5px; padding: 2px 8px;
  border: 1px solid var(--line); color: var(--ink-soft);
}
.o-row .pill.fill { background: var(--ink); color: #fff; border-color: var(--ink); }
.o-row .pill.blank { background: var(--card); }
.o-row .tag {
  font-family: var(--font-mono); font-size: 9.5px; background: var(--ink);
  color: #fff; border-radius: 4px; padding: 1px 6px; flex: none;
}
.o-expand {
  border: 1px dashed var(--orange-line); border-radius: 8px; padding: 9px 12px;
  font-size: 12.5px; margin: -2px 0 8px 26px; background: var(--orange-soft);
  color: var(--ink-soft); min-width: 0;
}
.o-expand.grey { border-color: var(--line); background: var(--paper-2); }
.o-expand b { color: var(--ink); }
.o-expand-note { margin: 6px 0 0; font-size: 11.5px; color: var(--ink-faint); }
.o-expand .mono-val { font-family: var(--font-mono); font-size: 11px; color: var(--danger); }
.o-footer {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line);
  font-size: 12.5px; color: var(--ink-soft); flex-wrap: wrap;
}
.o-summary { font-family: var(--font-mono); font-size: 11px; min-width: 0; }
.o-footer-btns { display: flex; gap: 8px; align-items: center; flex: none; }
.o-footer .btn-primary { flex: none; }
@media (max-width: 380px) {
  .o-footer { flex-direction: column; align-items: stretch; }
  .o-footer-btns { flex-direction: column-reverse; }
  .o-footer .btn-primary, .o-footer .btn-ghost { width: 100%; }
  .o-row { gap: 6px; padding: 7px 8px; }
}

/* GM-3 · firm settings panel */
.settings-overlay {
  position: fixed; inset: 0; background: rgba(31,26,20,0.45); z-index: 9000;
  display: flex; align-items: flex-start; justify-content: flex-end;
}
.settings-panel {
  background: var(--paper); width: min(420px, 100vw); height: 100vh;
  overflow-y: auto; box-shadow: -4px 0 24px rgba(31,26,20,.18);
  display: flex; flex-direction: column;
}
.settings-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px 14px; border-bottom: 1px solid var(--orange-line);
}
.settings-title { font-size: 16px; font-weight: 700; margin: 0; }
.settings-body { padding: 16px 20px; flex: 1; }
.settings-loading, .settings-err { color: var(--ink-soft); font-size: 13px; }
.settings-form { display: flex; flex-direction: column; gap: 0; }
.settings-section { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-soft); margin: 16px 0 6px; font-weight: 600; }
.settings-row { display: flex; flex-direction: column; gap: 3px; margin-bottom: 10px; }
.settings-row label { font-size: 12px; color: var(--ink-soft); font-weight: 500; }
.settings-input {
  width: 100%; box-sizing: border-box; padding: 7px 9px;
  border: 1px solid var(--line, #d9d2c9); border-radius: 4px;
  font-size: 13px; font-family: inherit; background: var(--paper); color: var(--ink);
}
.settings-input:focus { outline: none; border-color: var(--purple); }
.settings-footer { display: flex; align-items: center; gap: 12px; margin-top: 8px; padding-top: 12px; border-top: 1px solid var(--orange-line); }
.settings-status { font-size: 12px; color: var(--ink-soft); }
/* EN5 · BYO standards license attestation section */
.settings-license-section { margin-top: 8px; padding-top: 4px; }
.license-status { font-size: 13px; margin: 4px 0 10px; padding: 6px 10px; border-radius: 6px; }
.license-attested { background: var(--green-soft, #eaf6ee); color: var(--green, #1e7e34); border: 1px solid var(--green-soft, #c3e6cb); }
.license-not-attested { background: var(--paper-alt, #f5f4f1); color: var(--ink-soft); border: 1px solid var(--line); }
.license-notes-input { resize: vertical; min-height: 44px; font-family: inherit; }

/* CMP3 · EA competency evidence panel (per-report) */
.report-competency { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--purple-soft); min-width: 0; }
.cmp-header { font-size: 13px; font-weight: 600; margin: 0 0 6px; color: var(--ink); }
.cmp-count { font-weight: 400; color: var(--ink-soft); font-size: 12px; }
.cmp-items { margin: 4px 0 8px; }
.cmp-items > summary { cursor: pointer; font-size: 12px; color: var(--purple); }
.cmp-unit { margin: 8px 0 4px; }
.cmp-unit-name { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); margin: 6px 0 4px; }
.cmp-hit { margin: 6px 0; padding: 6px 8px; border-left: 2px solid var(--purple-soft); background: var(--paper); border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.cmp-hit-title { font-size: 12px; font-weight: 600; margin: 0 0 2px; display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
.cmp-id { color: var(--purple); font-family: var(--font-mono); font-size: 11px; }
.cmp-badge { font-size: 10px; font-weight: 700; padding: 1px 5px; border-radius: 3px; letter-spacing: .04em; }
.cmp-strong { background: #d4edda; color: #155724; }
.cmp-partial { background: var(--blue-soft); color: var(--blue); }
.cmp-review { background: var(--orange-soft); color: #7a4100; }
.cmp-section-label { font-size: 11px; color: var(--ink-soft); margin: 2px 0; }
.cmp-quote { font-size: 12px; color: var(--ink); margin: 4px 0 0 0; padding: 4px 10px; border-left: 2px solid var(--line); font-style: italic; }
.cmp-advisory { font-size: 11px; color: var(--ink-soft); margin: 4px 0 0; }

/* CMP4 · EA coach portfolio view */
.ea-coach-wrap { max-width: 860px; margin: 0 auto; padding: 36px 24px 80px; }
.ea-coach-head { margin-bottom: 24px; }
.ea-coach-head h2 { font-size: 24px; margin: 0; }
.ea-coach-head .eyebrow { color: var(--purple); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; margin: 0 0 4px; }
.ea-coach-head .sub { color: var(--ink-soft); font-size: 14px; margin: 4px 0 0; max-width: 540px; }
.ea-coach-records { display: flex; flex-direction: column; gap: 10px; }
.ea-coach-record { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; }
.ea-coach-det { }
.ea-coach-summary { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px 16px; padding: 14px 16px; cursor: pointer; list-style: none; font-size: 14px; }
.ea-coach-summary::-webkit-details-marker { display: none; }
.ea-coach-summary::before { content: "▸"; color: var(--purple); margin-right: 4px; flex: 0 0 auto; transition: transform .15s; }
details.ea-coach-det[open] .ea-coach-summary::before { transform: rotate(90deg); }
.ea-coach-doc { font-weight: 600; color: var(--ink); }
.ea-coach-coverage { font-size: 12px; color: var(--purple); }
.ea-coach-date { font-size: 12px; color: var(--ink-faint); margin-left: auto; }
.ea-coach-hits { padding: 0 16px 12px; border-top: 1px solid var(--line); }
.ea-coach-no-hits { padding: 8px 16px; font-size: 12px; color: var(--ink-soft); }
.ea-coach-dl { margin: 0 16px 12px; }
.ea-coach-empty { color: var(--ink-soft); font-size: 14px; padding: 32px 0; text-align: center; }
.ea-coach-err { color: var(--danger); font-size: 13px; padding: 16px 0; }
@media (max-width: 600px) {
  .ea-coach-wrap { padding: 20px 16px 60px; }
  .ea-coach-summary { flex-direction: column; gap: 4px; }
  .ea-coach-date { margin-left: 0; }
}

/* G6 · Map panel */
.map-panel-wrap { display: flex; height: calc(100vh - 52px); overflow: hidden; }
.map-sidebar { width: 280px; flex: 0 0 280px; border-right: 1px solid var(--line); overflow-y: auto; background: var(--paper); display: flex; flex-direction: column; }
.map-sidebar-head { padding: 16px; border-bottom: 1px solid var(--line); }
.map-sidebar-head h3 { margin: 0 0 2px; font-size: 15px; }
.map-sidebar-project { font-size: 12px; color: var(--purple); font-weight: 500; }
.map-layer-list { padding: 12px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.map-layer-chip { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink); cursor: pointer; }
.map-layer-chip input { accent-color: var(--purple); }
.map-no-project, .map-no-layers, .map-err, .map-no-results { font-size: 13px; color: var(--ink-soft); padding: 8px 0; }
.map-err { color: var(--danger, #c0392b); }
.map-query-results { border-top: 1px solid var(--line); padding: 12px; }
.map-query-results h4 { margin: 0 0 8px; font-size: 13px; font-weight: 600; }
.map-result-item { font-size: 12px; color: var(--ink); padding: 6px 0; border-bottom: 1px solid var(--line); }
.map-result-type { font-family: "IBM Plex Mono", monospace; color: var(--purple); margin-right: 6px; }
.map-result-attrs { color: var(--ink-soft); }
.map-container { flex: 1; min-width: 0; }
.map-unavailable { padding: 32px; color: var(--ink-soft); font-size: 14px; }
@media (max-width: 700px) {
  .map-panel-wrap { flex-direction: column; }
  .map-sidebar { width: 100%; flex: 0 0 auto; max-height: 200px; border-right: none; border-bottom: 1px solid var(--line); }
  .map-container { flex: 1; min-height: 300px; }
}
.map-cite-btn { font-size: 11px; padding: 2px 6px; margin-left: 8px; vertical-align: middle; }
.map-cited-prose { font-size: 12px; color: var(--ink-soft); font-style: italic; margin-top: 4px; padding: 4px 8px; border-left: 2px solid var(--purple); }
.btn-xs { padding: 2px 6px; font-size: 11px; }

/* ============================================================
 * ORDER OF PRECEDENCE — governing-documents ladder
 * (create-flow step 2 + the ⚖ room panel). Tier colours per approved mockup.
 * ============================================================ */
.prec-modal { max-width: 560px; }
.prec-open-btn { font-size: 15px; line-height: 1; padding: 6px 10px; }

.prec-lead { color: var(--ink-soft); font-size: 13.5px; margin: 0 0 16px; }
.prec-sub { color: var(--ink-faint); font-size: 12.5px; margin: 0 0 16px; }
.prec-head h3 { margin: 0 0 4px; font-size: 18px; }

/* govern-step selects */
.prec-field-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.prec-field { flex: 1; min-width: 140px; }
.prec-field label {
  display: block; font-family: var(--font-mono); font-size: 10px;
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-faint); margin-bottom: 5px;
}
.prec-select {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--paper); color: var(--ink); font-size: 14px; font-weight: 500; font-family: inherit;
}
.prec-select:focus { outline: none; border-color: var(--orange); box-shadow: 0 0 0 3px var(--orange-soft); }

/* ladder */
.prec-ladder { display: flex; flex-direction: column; gap: 8px; }
.prec-rung {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--r-md); background: var(--paper);
}
.prec-rung.contract { border-color: var(--orange-line); background: var(--orange-soft); }
.prec-rank {
  font-family: var(--font-mono); font-size: 13px; font-weight: 700;
  width: 20px; text-align: center; color: var(--ink-soft); flex: none;
}
.prec-doc-icon { font-size: 15px; width: 20px; text-align: center; flex: none; }
.prec-doc-name { flex: 1; min-width: 0; font-size: 14px; font-weight: 600; color: var(--ink); }
.prec-meta {
  display: block; font-family: var(--font-mono); font-size: 10.5px;
  font-weight: 400; color: var(--ink-faint); margin-top: 1px;
}
.prec-tier {
  font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 0.1em;
  text-transform: uppercase; font-weight: 600; padding: 3px 8px; border-radius: 999px;
  white-space: nowrap; flex: none;
}
.prec-tier.contract  { background: var(--orange); color: #fff; }
.prec-tier.authority { background: var(--blue-soft); color: var(--blue); border: 1px solid var(--blue); }
.prec-tier.guide     { background: var(--purple-soft); color: var(--purple); border: 1px solid var(--purple); }
.prec-tier.standard  { background: #eceae6; color: var(--ink-soft); border: 1px solid var(--grey); }
.prec-bump { display: flex; flex-direction: column; gap: 1px; flex: none; }
.prec-bump button {
  font-size: 9px; line-height: 1; padding: 1px 3px; border: none; background: none;
  color: var(--ink-faint); cursor: pointer;
}
.prec-bump button:hover:not(:disabled) { color: var(--orange); }
.prec-bump button:disabled { opacity: 0.3; cursor: default; }

/* actions row (Save / Add / Skip / Propose) */
.prec-actions { display: flex; gap: 10px; align-items: center; margin-top: 18px; flex-wrap: wrap; }
.prec-skip-link {
  background: none; border: none; color: var(--ink-soft); font: inherit; font-size: 13px;
  text-decoration: underline; text-underline-offset: 2px; cursor: pointer; padding: 4px;
}
.prec-skip-link:hover { color: var(--orange); }

/* inline "+ Add contract document" form */
.prec-add-form {
  margin-top: 16px; border: 1px dashed var(--orange-line); border-radius: var(--r-md);
  background: var(--paper); padding: 14px;
}
.prec-add-form[hidden] { display: none; }
.prec-add-form h4 {
  margin: 0 0 10px; font-size: 12px; font-family: var(--font-mono);
  letter-spacing: 0.06em; text-transform: uppercase; color: #9a4d09;
}
.prec-radio-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.prec-radio {
  font-family: var(--font-mono); font-size: 11.5px; padding: 5px 11px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink-soft); cursor: pointer;
}
.prec-radio.on { border-color: var(--orange); background: var(--orange-soft); color: #9a4d09; font-weight: 600; }
.prec-slot-note { font-size: 12px; color: var(--ink-soft); margin: 8px 0 12px; }
.prec-slot-note b { color: #9a4d09; }
.prec-add-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* optional file attach inside the add-contract-document form */
.prec-file-field { margin-bottom: 12px; }
.prec-file-opt { font-weight: 400; color: var(--ink-faint); font-size: 11.5px; }
.prec-file-row { display: flex; gap: 10px; align-items: center; margin-top: 6px; }
.prec-file-name {
  font-size: 12px; color: var(--ink-soft); min-width: 0; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.prec-add-status {
  font-size: 12px; color: var(--ink-soft); margin: 4px 0 12px;
  display: flex; align-items: center; gap: 6px;
}
.prec-add-status[hidden] { display: none; }
.prec-add-err { color: var(--danger, #b3261e); }

/* a rung linked to an uploaded project doc */
.prec-linked { color: var(--orange); font-family: inherit; font-size: 11px; font-weight: 600; }

@media (max-width: 480px) {
  .prec-field { min-width: 100%; }
}

/* ── ENGINE markdown rendering (clear + legible — Adina 2026-07-18) ─────────── */
.general-prose .md-p { margin: 0 0 10px; line-height: 1.62; }
.general-prose .md-p:last-child { margin-bottom: 0; }
.general-prose .md-h { font-weight: 700; color: var(--ink); margin: 16px 0 6px; line-height: 1.3; }
.general-prose .md-h1, .general-prose .md-h2 { font-size: 16px; }
.general-prose .md-h3 { font-size: 14.5px; }
.general-prose .md-h4, .general-prose .md-h5, .general-prose .md-h6 {
  font-size: 12px; font-family: var(--font-mono); letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--ink-soft);
}
.general-prose .md-list { margin: 0 0 10px; padding-left: 22px; }
.general-prose .md-list li { margin: 3px 0; line-height: 1.55; }
.general-prose code {
  font-family: var(--font-mono); font-size: 12.5px; background: var(--paper-2);
  border-radius: 4px; padding: 1px 5px;
}
.general-prose .md-code {
  font-family: var(--font-mono); font-size: 12.5px; background: var(--paper-2);
  border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px 12px;
  overflow-x: auto; margin: 0 0 10px; white-space: pre;
}
.general-prose .md-tablewrap { overflow-x: auto; margin: 0 0 12px; }
.general-prose .md-table { border-collapse: collapse; font-size: 13px; min-width: 60%; }
.general-prose .md-table th {
  text-align: left; font-family: var(--font-mono); font-size: 10.5px;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-soft);
  border-bottom: 2px solid var(--line); padding: 5px 10px 5px 0;
}
.general-prose .md-table td { border-bottom: 1px solid var(--line); padding: 6px 10px 6px 0; vertical-align: top; }
