/* AUTO-GENERATED by build_css.py — do not edit this file.
   Source files live under styles/NN-name.css.
   Concatenated in numeric order from: 00-base.css, 01-home.css, 02-topbar-nav.css, 03-manuscript.css, 04-design-pipeline.css, 05-capture-activity.css, 06-workflow.css, 07-chat.css. */

/* ==== 00-base.css ==== */
/* 00-base.css — resets, root vars, body base
   Sourced from styles.css lines 1..46. Concatenated by build_css.py. */

  .login-screen {
    position: fixed; inset: 0; background: #0b0c10; z-index: 9999;
    display: flex; align-items: center; justify-content: center; padding: 20px;
  }
  .login-box {
    max-width: 360px; width: 100%; text-align: center;
  }
  .login-box h1 {
    font-size: 26px; font-weight: 800; margin: 0 0 6px;
    background: linear-gradient(135deg, #ecedf2, #7eb0ff);
    -webkit-background-clip: text; background-clip: text; color: transparent;
  }
  .login-box .sub { color: #7a7f8f; font-size: 13px; margin-bottom: 28px; }
  .login-box input {
    width: 100%; background: #161922; color: #ecedf2;
    border: 1px solid #2a2f42; border-radius: 10px;
    padding: 14px; font-size: 16px; margin-bottom: 10px;
    font-family: inherit;
  }
  .login-box input:focus { outline: none; border-color: #7eb0ff; box-shadow: 0 0 0 3px rgba(126,176,255,0.15); }
  .login-box button {
    width: 100%; background: linear-gradient(135deg, #7eb0ff, #5e97f0);
    color: #0b0c10; border: 0; border-radius: 10px;
    padding: 14px; font-size: 15px; font-weight: 700; cursor: pointer;
    min-height: 50px; margin-top: 4px;
  }
  .login-box .err { color: #f07878; font-size: 13px; margin-top: 10px; display: none; }
  :root {
    --bg: #0b0c10; --bg2: #0e1015;
    --panel: #161922; --panel2: #1c2030; --panel3: #242839;
    --border: #2a2f42; --border2: #353a50;
    --text: #ecedf2; --text2: #c0c4d0; --muted: #7a7f8f;
    --accent: #7eb0ff; --accent2: #5e97f0;
    --ok: #6dd082; --warn: #f0c068; --fail: #f07878; --running: #7eb0ff;
    --nav-h: calc(56px + env(safe-area-inset-bottom));
    --fab-h: calc(56px + env(safe-area-inset-bottom));
    --radius: 14px; --radius-sm: 10px;
    --shadow: 0 4px 16px rgba(0,0,0,.35); --shadow-sm: 0 2px 6px rgba(0,0,0,.25);
  }
  * { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
  html, body {
    margin: 0; padding: 0; background: var(--bg); color: var(--text);
    font: 15px/1.55 -apple-system, BlinkMacSystemFont, system-ui, "Segoe UI", sans-serif;
    -webkit-text-size-adjust: 100%; -webkit-font-smoothing: antialiased;
  }
  body { padding-bottom: calc(var(--nav-h) + 16px); }

/* ==== 01-home.css ==== */
/* 01-home.css — home screen project picker
   Sourced from styles.css lines 47..88. Concatenated by build_css.py. */

  body.has-fab { padding-bottom: calc(var(--nav-h) + var(--fab-h) + 20px); }
  body.on-home { padding-bottom: 20px; }
  .wrap { max-width: 960px; margin: 0 auto; padding: 14px 14px 0; }

  /* ---- Project picker (home screen) ---- */
  .home-header {
    text-align: center; padding: 24px 0 12px;
  }
  .home-header h1 {
    font-size: 22px; font-weight: 800; letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--text) 0%, var(--accent) 100%);
    -webkit-background-clip: text; background-clip: text; color: transparent;
    margin: 0 0 4px;
  }
  .home-header .sub { color: var(--muted); font-size: 13px; }

  .project-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px; padding: 12px 0;
  }
  .project-card {
    background: var(--panel); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 16px 14px;
    cursor: pointer; transition: transform .08s, box-shadow .12s;
    min-height: 130px; display: flex; flex-direction: column;
    justify-content: space-between;
  }
  .project-card:active { transform: scale(0.97); box-shadow: var(--shadow); }
  .project-card .short {
    width: 36px; height: 36px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; font-weight: 800; color: #0b0c10;
    margin-bottom: 10px;
  }
  .project-card .name { font-size: 14px; font-weight: 700; line-height: 1.3; }
  .project-card .stats { font-size: 11px; color: var(--muted); margin-top: 4px; }

  /* Flow pill inside a regular project tile — indicates attached flow. */
  .project-tile-flow-pill {
    display: inline-block;
    margin-top: 6px;
    padding: 2px 7px;
    border-radius: 10px;
    font-size: 10.5px;
    font-weight: 600;
    color: #d2b0ff;
    background: rgba(210, 176, 255, 0.10);
    border: 1px solid rgba(210, 176, 255, 0.28);
    cursor: pointer;
  }
  .project-tile-flow-pill:hover { background: rgba(210, 176, 255, 0.18); }

  /* "Resume → ..." line: leading prompt on every tile so the writer
     knows the next action without remembering. Tap routes to the
     specific phase view (event.stopPropagation in the handler). */
  .project-tile-resume {
    margin-top: 6px;
    padding: 5px 9px;
    background: rgba(126,176,255,0.10);
    border: 1px solid rgba(126,176,255,0.28);
    border-radius: 6px;
    font-size: 11.5px; font-weight: 600;
    color: var(--accent);
    cursor: pointer;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .project-tile-resume:hover { background: rgba(126,176,255,0.18); }

  /* "Write next chapter" — manuscript-first entry. Distinct color so
     the writer's eye finds it even with the flow pill nearby. */
  .project-tile-write {
    margin-top: 6px;
    padding: 5px 9px;
    background: rgba(109,208,130,0.10);
    border: 1px solid rgba(109,208,130,0.28);
    border-radius: 6px;
    font-size: 11.5px; font-weight: 600;
    color: var(--ok);
    cursor: pointer;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .project-tile-write:hover { background: rgba(109,208,130,0.18); }

  /* Sketch-mode tile: writing-first entry. Distinguished gradient
     border so it reads as the "fastest path to writing". */
  .project-card-sketch {
    border: 1px solid rgba(126,176,255,0.35);
    background: linear-gradient(180deg,
      var(--panel) 60%,
      rgba(126,176,255,0.05) 80%,
      rgba(210,176,255,0.04));
  }
  .project-card-sketch .name {
    background: linear-gradient(135deg, #7eb0ff, #d2b0ff);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    font-weight: 800;
  }

  /* Atelier Flow tile — distinguished from regular project tiles. */
  .project-card-flow {
    border-color: rgba(210, 176, 255, 0.30);
    background: linear-gradient(180deg, var(--panel) 70%, rgba(210,176,255,0.04));
  }
  .project-card-flow .short { color: #2a1b3a; }
  .flow-badge {
    display: inline-block; padding: 1px 5px; border-radius: 3px;
    font-size: 9px; font-weight: 700; letter-spacing: 0.5px;
    background: #3a2a4a; color: #d2b0ff; vertical-align: 1px;
    margin-right: 2px;
  }
  .project-card-new-flow {
    border-style: dashed; opacity: 0.85;
  }
  .project-card-new-flow:hover { opacity: 1; }
  .project-card-new-flow .short {
    font-size: 22px; font-weight: 400;
  }

  /* New Flow picker rows (inside modal) */
  .flow-pick-row {
    display: flex; align-items: center; gap: 10px;
    padding: 10px; border-radius: 8px; cursor: pointer;
    border: 1px solid transparent;
  }
  .flow-pick-row:hover { background: rgba(126,176,255,0.06); border-color: rgba(126,176,255,0.18); }
  .flow-pick-row .short {
    width: 40px; height: 40px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 13px; color: #0b0c10;
    flex-shrink: 0;
  }
  .flow-pick-row.flow-pick-new { border-style: dashed; border-color: rgba(139,148,158,0.4); margin-top: 8px; }
  .flow-pick-row.flow-pick-new:hover { border-color: rgba(210,176,255,0.4); }
  .at-pill {
    display: inline-block; padding: 4px 9px; border-radius: 12px;
    font-size: 11px; font-weight: 600; letter-spacing: .02em;
    white-space: nowrap; cursor: default;
  }


/* ==== 02-topbar-nav.css ==== */
/* 02-topbar-nav.css — topbar, chapter detail editor, bottom nav + source chip
   Sourced from styles.css lines 89..428. Concatenated by build_css.py. */

  /* ---- Topbar (inside project) ---- */
  .topbar {
    display: flex; align-items: center; gap: 8px; margin-bottom: 4px;
  }
  .topbar .brand {
    font-size: 14px; margin: 0; font-weight: 700; letter-spacing: -0.01em;
    -webkit-background-clip: text; background-clip: text; color: transparent;
    flex-shrink: 0; cursor: pointer;
  }
  .topnav {
    flex: 1; display: flex; background: var(--panel2);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 3px; gap: 3px;
  }
  .topnav button {
    flex: 1; background: transparent; color: var(--muted); border: 0;
    padding: 8px 4px; font-size: 12px; font-weight: 600; cursor: pointer;
    border-radius: 7px; min-height: 38px; position: relative;
    transition: color .15s, background .12s;
  }
  .topnav button.active { background: var(--panel3); color: var(--text); }
  .topnav button .badge {
    position: absolute; top: 2px; right: 6px;
    min-width: 14px; height: 14px; padding: 0 3px;
    border-radius: 7px; background: var(--fail); color: #fff;
    font-size: 9px; line-height: 14px; font-weight: 700;
  }
  .subtitle { color: var(--muted); font-size: 12px; margin-bottom: 14px; }
  @media (max-width: 380px) { .topbar .brand { display: none; } }

  h2 { font-size: 11px; text-transform: uppercase; letter-spacing: .12em;
       color: var(--muted); font-weight: 700; margin: 16px 0 10px; }
  .muted { color: var(--muted); font-size: 12px; }

  .card {
    background: var(--panel); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 14px;
    margin-bottom: 14px; box-shadow: var(--shadow-sm);
  }
  .card h2:first-child { margin-top: 0; }

  nav.bottom {
    position: fixed; bottom: 0; left: 0; right: 0;
    background: rgba(22, 25, 34, 0.92);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
    display: flex; z-index: 50;
    padding-bottom: env(safe-area-inset-bottom);
  }
  nav.bottom button {
    flex: 1; background: transparent; border: 0; color: var(--muted);
    padding: 10px 4px; font-size: 11px; cursor: pointer;
    position: relative; min-height: 56px; font-weight: 600;
    transition: color .15s;
  }
  nav.bottom button.active { color: var(--accent); }
  nav.bottom button.active::before {
    content: ''; position: absolute; top: 0; left: 50%;
    transform: translateX(-50%); width: 32px; height: 3px;
    background: var(--accent); border-radius: 0 0 3px 3px;
  }
  nav.bottom .icon { display: block; font-size: 20px; margin-bottom: 2px; }
  nav.bottom .badge {
    position: absolute; top: 6px; right: 18%;
    min-width: 16px; height: 16px; padding: 0 4px;
    border-radius: 8px; background: var(--fail); color: #fff;
    font-size: 10px; line-height: 16px; font-weight: 700;
  }

  .list { display: flex; flex-direction: column; }
  .row {
    padding: 12px 4px; border-bottom: 1px solid var(--border); cursor: pointer;
    display: flex; justify-content: space-between; align-items: center; gap: 10px;
    min-height: 52px; transition: background .12s;
  }
  .row:last-child { border-bottom: 0; }
  .row:active { background: var(--panel2); }
  .row .title { flex: 1; min-width: 0; }
  .row .title .name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
  .row .title .sub { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }
  .pill {
    display: inline-block; padding: 3px 10px; border-radius: 12px;
    font-size: 10px; font-weight: 700; text-transform: uppercase;
    letter-spacing: .04em; white-space: nowrap; flex-shrink: 0;
  }
  .pill.draft { background: rgba(255,255,255,.06); color: var(--muted); }
  .pill.pending_review, .pill.pending_verify, .pill.pending_verification { background: rgba(240,192,104,.18); color: var(--warn); }
  .pill.verification_failed { background: rgba(240,120,120,.18); color: var(--fail); }
  .pill.published, .pill.done { background: rgba(109,208,130,.18); color: var(--ok); }
  .pill.failed, .pill.needs_attention { background: rgba(240,120,120,.18); color: var(--fail); }
  .pill.running, .pill.queued { background: rgba(126,176,255,.18); color: var(--running); }
  .pill.clickable { cursor: pointer; transition: filter .15s; user-select: none; }
  .pill.clickable:active { filter: brightness(1.3); }

  .input, input[type=text], input[type=number], input[type=url] {
    background: var(--bg2); color: var(--text);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 11px 13px; font-size: 16px; min-height: 44px;
    font-family: inherit; width: 100%;
  }
  .input:focus, input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(126,176,255,0.15); }
  label.field { display: block; font-size: 11px; text-transform: uppercase;
                letter-spacing: .08em; color: var(--muted); font-weight: 700; margin-bottom: 6px; }

  .jump { display: flex; gap: 8px; margin-bottom: 10px; }
  .jump input { flex: 1; }
  .jump .btn { min-height: 44px; padding: 0 16px; }

  .search {
    display: flex; align-items: center; gap: 8px;
    background: var(--bg2); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 0 12px; margin-bottom: 10px;
  }
  .search::before { content: '\2315'; color: var(--muted); font-size: 18px; }
  .search input {
    flex: 1; background: transparent; border: 0; color: var(--text);
    padding: 11px 0; font-size: 15px; min-height: 44px; outline: none;
  }

  /* ---- Chapter detail v3 — chrome-less editor + bottom sheet menu ---- */
  /* In ch-editing mode, hide every non-editor distraction */
  body.ch-editing nav.bottom,
  body.ch-editing #project_screen > .topbar,
  body.ch-editing .fab { display: none !important; }
  body.ch-editing { padding-bottom: 0; }

  /* Editor fills the viewport with generous reading margins.
     top padding = status pill height + breathing room + safe-area */
  .editor {
    width: 100%;
    height: 100dvh; min-height: 100dvh;
    background: var(--bg); color: var(--text2);
    border: 0; border-radius: 0;
    padding: calc(54px + env(safe-area-inset-top)) 18px 110px;
    resize: none;
    font: 16px/1.65 Georgia, ui-serif, Cambria, "Times New Roman", serif;
    -webkit-appearance: none;
    caret-color: var(--accent);
  }
  .editor:focus { outline: none; }
  .editor::placeholder { color: var(--muted); font-style: italic; }

  /* Floating status pill — top-right, subtle */
  .ch-float-status {
    position: fixed; top: calc(12px + env(safe-area-inset-top));
    right: 12px; z-index: 45;
    background: rgba(22,25,34,0.78);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    color: var(--muted); padding: 6px 12px;
    border-radius: 20px;
    font-size: 11.5px; font-weight: 500;
    border: 1px solid var(--border);
    cursor: pointer; user-select: none;
    min-height: 28px;
    display: flex; align-items: center;
    max-width: 55vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .ch-float-status:active { background: var(--panel2); }
  .dirty-pulse { color: var(--accent); }
  .dirty-pulse::before {
    content: "●"; margin-right: 5px;
    animation: pulse 1.4s ease-in-out infinite;
  }
  @keyframes pulse { 0%,100%{opacity:.5} 50%{opacity:1} }

  /* Floating menu button — bottom-right, thumb-reachable */
  .ch-menu-fab {
    position: fixed;
    bottom: calc(18px + env(safe-area-inset-bottom));
    right: 18px; z-index: 45;
    width: 56px; height: 56px; border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    color: #0b0c10; border: 0; cursor: pointer;
    font-size: 24px; font-weight: 800; line-height: 1;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 6px 18px rgba(0,0,0,0.45), 0 2px 4px rgba(0,0,0,0.3);
    transition: transform .08s;
  }
  .ch-menu-fab:active { transform: scale(0.94); }

  /* Bottom sheet — slides up from the edge of the screen */
  .ch-sheet {
    position: fixed; inset: 0; z-index: 100;
    background: rgba(0,0,0,0.55);
    display: flex; align-items: flex-end; justify-content: center;
    animation: fade-in 0.18s ease-out;
  }
  @keyframes fade-in { from { opacity: 0 } to { opacity: 1 } }
  .ch-sheet-body {
    position: relative; width: 100%; max-width: 560px;
    background: var(--panel);
    border-top-left-radius: 20px; border-top-right-radius: 20px;
    padding: 10px 16px calc(22px + env(safe-area-inset-bottom));
    max-height: 85dvh; overflow-y: auto;
    animation: sheet-up 0.22s cubic-bezier(0.2, 0.9, 0.3, 1);
    box-shadow: 0 -8px 30px rgba(0,0,0,0.5);
  }
  @keyframes sheet-up {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }
  .ch-sheet-grip {
    width: 36px; height: 4px; border-radius: 2px;
    background: var(--border2); margin: 2px auto 14px;
  }
  .ch-sheet-head {
    display: flex; align-items: center; gap: 8px;
    margin-bottom: 14px;
  }
  .ch-title-sheet {
    flex: 1; font-size: 16px; font-weight: 700; letter-spacing: -0.01em;
    color: var(--text);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    text-align: center; padding: 0 4px;
  }
  .ch-close-sheet {
    background: var(--panel2); color: var(--muted); border: 1px solid var(--border);
    border-radius: 50%; cursor: pointer;
    width: 36px; height: 36px; padding: 0;
    font-size: 20px; line-height: 1;
    display: flex; align-items: center; justify-content: center;
  }
  .ch-close-sheet:active { background: var(--panel3); }
  .ch-sheet-row {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 0; border-bottom: 1px solid var(--border);
  }
  .ch-sheet-nav {
    display: flex; gap: 8px; margin: 12px 0 6px;
  }
  .ch-sheet-actions {
    display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
    margin-top: 14px;
  }
  .editor-meta {
    display: flex; justify-content: space-between; align-items: center;
    margin-top: 2px; font-size: 11px; color: var(--muted);
  }

  .reader {
    background: var(--panel); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 16px;
    font-size: 15.5px; line-height: 1.8; color: var(--text2);
  }
  .reader p { margin: 0 0 0.9em 0; }
  .reader p:last-child { margin-bottom: 0; }

  /* Source-reader chip + bottom-nav bar. Both the top ch chip and the
     bottom nav are minimal — no fixed sticky header, no back arrow.
     The tree (bottom-nav Manuscript button) is the way back. */
  .src-chip {
    display: inline-block; font-size: 12px; font-weight: 700;
    color: var(--muted); padding: 4px 10px; margin: 0 0 10px 0;
    background: var(--panel); border: 1px solid var(--border);
    border-radius: 999px; letter-spacing: 0.04em;
  }
  .src-nav {
    display: flex; align-items: center; gap: 10px;
    margin-top: 16px; padding: 10px 0 max(16px, env(safe-area-inset-bottom));
  }
  .src-nav .btn { flex: 0 0 auto; min-width: 88px; }
  .src-nav-meta {
    flex: 1; text-align: center; font-size: 11px; color: var(--muted);
  }

  .refpanel summary {
    cursor: pointer; padding: 12px 14px;
    background: var(--panel); border: 1px solid var(--border);
    border-radius: var(--radius-sm); font-size: 13px; color: var(--text2);
    list-style: none; min-height: 44px; display: flex; align-items: center; font-weight: 500;
  }
  .refpanel summary::before { content: '\25B8'; display: inline-block; margin-right: 8px; color: var(--muted); transition: transform .2s; }
  .refpanel[open] summary::before { transform: rotate(90deg); }
  .refpanel summary::-webkit-details-marker { display: none; }
  .refpanel[open] summary { border-radius: var(--radius-sm) var(--radius-sm) 0 0; border-bottom-color: transparent; }
  .refpanel .body {
    background: var(--panel); border: 1px solid var(--border);
    border-top: 0; border-radius: 0 0 var(--radius-sm) var(--radius-sm); padding: 14px;
    font-size: 14px; line-height: 1.75; color: var(--muted); max-height: 50vh; overflow: auto;
  }

  .diffview {
    background: var(--panel); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 16px;
    font-size: 15px; line-height: 1.85; white-space: pre-wrap; word-wrap: break-word;
  }
  .diffview ins.add { background: rgba(109,208,130,.32); color: #d8f5df; text-decoration: none; padding: 1px 3px; border-radius: 3px; }
  .diffview del.rm { background: rgba(240,120,120,.28); color: #f7dede; text-decoration: line-through; padding: 1px 3px; border-radius: 3px; }

  .fab {
    position: fixed; bottom: var(--nav-h); left: 0; right: 0;
    background: rgba(22, 25, 34, 0.95);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
    padding: 10px 12px; padding-bottom: calc(10px + env(safe-area-inset-bottom));
    display: flex; gap: 8px; z-index: 40;
  }
  .fab .btn { flex: 1; min-height: 44px; font-size: 13px; }

  .btn {
    background: var(--panel2); color: var(--text);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 10px 16px; font-size: 14px; cursor: pointer;
    min-height: 44px; font-weight: 600;
    transition: background .12s, transform .05s;
  }
  .btn:active { transform: scale(0.98); background: var(--panel3); }
  .btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #0b0c10; border-color: var(--accent); }
  .btn.primary:active { background: var(--accent2); }
  .btn.danger { border-color: rgba(240,120,120,.4); color: var(--fail); }
  .btn:disabled { opacity: 0.4; cursor: default; transform: none; }
  .btnbar { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
  .back { color: var(--accent); background: transparent; border: 0; padding: 8px 0; cursor: pointer; font-size: 14px; font-weight: 500; margin-bottom: 4px; min-height: 36px; }

  .toast {
    position: fixed; bottom: calc(20px + env(safe-area-inset-bottom));
    left: 50%; transform: translateX(-50%);
    background: #2a2f42; color: var(--text);
    padding: 11px 18px; border-radius: 24px;
    font-size: 13px; font-weight: 500; z-index: 100;
    box-shadow: 0 6px 20px rgba(0,0,0,.5);
    max-width: calc(100vw - 32px); text-align: center;
    border: 1px solid var(--border2);
    animation: toast-in .25s ease-out;
  }
  .toast.success { background: rgba(109,208,130,.95); color: #0b0c10; border-color: transparent; }
  .toast.error { background: rgba(240,120,120,.95); color: #0b0c10; border-color: transparent; }
  .toast.info { background: rgba(126,176,255,.95); color: #0b0c10; border-color: transparent; }
  @keyframes toast-in { from { opacity: 0; transform: translateX(-50%) translateY(8px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }

  .toast.toast-action {
    display: inline-flex; align-items: center; gap: 12px;
    padding: 10px 12px 10px 18px;
    text-align: left;
    max-width: min(560px, calc(100vw - 32px));
  }
  .toast-action-btn {
    background: rgba(0,0,0,0.18); color: inherit;
    border: 1px solid rgba(0,0,0,0.25);
    padding: 6px 12px; border-radius: 16px;
    font: inherit; font-weight: 600; cursor: pointer;
    white-space: nowrap;
  }
  .toast-action-btn:hover:not(:disabled) { background: rgba(0,0,0,0.28); }
  .toast-action-btn:disabled { opacity: 0.6; cursor: default; }
  .toast-close-btn {
    background: transparent; color: inherit;
    border: 0; cursor: pointer; font-size: 18px;
    padding: 0 4px; line-height: 1;
  }
  .toast-close-btn:hover { opacity: 0.7; }

  .chaptergrid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr));
    gap: 6px; margin-top: 8px;
  }
  .chaptergrid button {
    aspect-ratio: 1; background: var(--bg2); color: var(--text2);
    border: 1px solid var(--border); border-radius: 8px; font-size: 12px;
    font-weight: 600; cursor: pointer; padding: 0; min-height: 48px;
  }
  .chaptergrid button:active { background: var(--panel2); transform: scale(0.96); }

/* ==== 03-manuscript.css ==== */
/* 03-manuscript.css — manuscript tree, chapter grid, reader, narrow-phone tweaks
   Sourced from styles.css lines 429..704. Concatenated by build_css.py. */

  /* Manuscript source toggle (Adapted / Original) — sits above the tree */
  .ms-source-toggle { display: flex; gap: 2px; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 3px; margin: 0 0 12px; }
  .ms-source-toggle button { flex: 1; background: transparent; color: var(--muted); border: 0; padding: 9px 14px; font-size: 13px; font-weight: 700; cursor: pointer; border-radius: 7px; font-family: inherit; min-height: 36px; transition: background 0.12s; }
  .ms-source-toggle button.active { background: var(--accent); color: var(--bg); }
  .ms-source-toggle button:not(.active):active { background: var(--panel2); color: var(--text); }
  /* File-explorer tree for manuscript (VS Code-inspired). Mobile-first
     dense rows with comfortable tap targets; scales cleanly to desktop
     via max-width on the container. */
  .ms-tree { font: 14px/1.4 -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif; color: var(--text); background: var(--bg); border-radius: 8px; overflow: hidden; }
  .ms-tree-head { display: flex; align-items: center; gap: 6px; padding: 8px 10px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); border-bottom: 1px solid var(--border); }
  .ms-tree-head .title { flex: 1; }
  .ms-tree-head .search { flex-shrink: 0; min-width: 0; display: flex; align-items: center; }
  .ms-tree-head input { background: var(--panel2); border: 1px solid var(--border); color: var(--text); font-size: 12px; padding: 4px 8px; border-radius: 14px; width: 100px; outline: 0; }
  .ms-tree-head input:focus { border-color: var(--accent); width: 140px; }
  .ms-tree-actions { display: flex; gap: 4px; }
  .ms-tree-actions button { background: transparent; border: 0; color: var(--muted); padding: 4px 6px; cursor: pointer; font-size: 14px; border-radius: 4px; }
  .ms-tree-actions button:hover, .ms-tree-actions button:active { background: var(--panel); color: var(--text); }
  .ms-tree-body { max-height: 65vh; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 4px 0 8px; }
  .ms-node { display: flex; align-items: center; gap: 6px; padding: 7px 10px; cursor: pointer; font-size: 14px; min-height: 36px; position: relative; -webkit-tap-highlight-color: transparent; border-radius: 0; user-select: none; }
  .ms-node:active { background: var(--panel2); }
  .ms-node:hover { background: var(--panel); }
  .ms-node.level-0 { font-weight: 600; color: var(--text); }
  .ms-node.level-1 { padding-left: 28px; }
  .ms-node.level-2 { padding-left: 46px; font-weight: 400; color: var(--text2); }
  .ms-node.level-3 { padding-left: 64px; font-weight: 400; color: var(--text2); }
  .ms-node.level-4 { padding-left: 82px; font-weight: 400; color: var(--text2); }
  /* Design-tab tree extensions — search input + chapter grid + deeper icons */
  .design-search { display: flex; gap: 6px; margin: 0 0 10px; align-items: center; }
  .design-search input {
    flex: 1; background: var(--panel2); border: 1px solid var(--border);
    border-radius: 8px; padding: 8px 12px; color: var(--text);
    font-size: 13px; font-family: inherit;
  }
  .design-search input:focus { outline: none; border-color: var(--accent); }
  .design-search button {
    width: 32px; height: 32px; background: var(--panel2); border: 1px solid var(--border);
    border-radius: 8px; color: var(--muted); font-size: 18px; cursor: pointer;
  }
  .design-search button:hover { color: var(--text); }
  /* Compact chapter grid — used when a folder has many ch-NNN.md files */
  .ch-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(58px, 1fr));
    gap: 4px; padding: 6px 6px 10px 46px;
  }
  .ch-grid button {
    padding: 6px 4px; background: var(--panel2); border: 1px solid var(--border);
    border-radius: 6px; color: var(--text2); font-size: 11px; font-family: inherit;
    cursor: pointer; min-height: 32px;
  }
  .ch-grid button:hover { border-color: var(--accent); color: var(--text); }
  .ch-grid button.open-chapter { border-color: var(--accent); }
  .ms-node .caret { flex-shrink: 0; width: 16px; height: 16px; color: var(--muted); display: flex; align-items: center; justify-content: center; transition: transform 0.15s; font-size: 10px; }
  .ms-node.open > .caret { transform: rotate(90deg); }
  .ms-node.no-caret .caret { visibility: hidden; }
  .ms-node .node-icon { flex-shrink: 0; width: 16px; height: 16px; display: inline-flex; align-items: center; justify-content: center; color: var(--muted); }
  .ms-node.level-0 .node-icon { color: #e0c068; }
  .ms-node.level-1 .node-icon { color: #7eb0ff; }
  .ms-node.level-2 .node-icon { color: var(--muted); }
  .ms-node .node-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .ms-node .node-meta { flex-shrink: 0; font-size: 11px; color: var(--muted); margin-left: 8px; }
  .ms-node .node-badge { flex-shrink: 0; min-width: 16px; height: 16px; padding: 0 5px; border-radius: 8px; font-size: 10px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
  .ms-node .status-dot { flex-shrink: 0; width: 8px; height: 8px; border-radius: 50%; margin-left: 4px; }
  .ms-node .status-dot.draft { background: var(--accent); }
  .ms-node .status-dot.pending_review { background: var(--warn); }
  .ms-node .status-dot.published { background: var(--ok); }
  .ms-node .status-dot.needs_tweak { background: var(--fail); }
  .ms-node .comment-dot { flex-shrink: 0; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); margin-left: 4px; }
  /* VS Code-style git-state colors applied to the label text.
     Modified = orange; Added/New = green; Dimmed = already-covered
     source chapters (like gitignored). */
  .ms-node.modified > .node-label { color: #e0a04a; }
  .ms-node.added    > .node-label { color: #6dd082; }
  .ms-node.dim      > .node-label { color: var(--muted); }
  .ms-node.modified > .node-meta,
  .ms-node.added    > .node-meta { color: inherit; opacity: 0.7; }
  .ms-node .state-letter { flex-shrink: 0; font-size: 10px; font-weight: 700; width: 14px; text-align: center; color: var(--muted); margin-left: 4px; }
  .ms-node.modified .state-letter { color: #e0a04a; }
  .ms-node.added    .state-letter { color: #6dd082; }
  /* Folder inline action icons — appear on hover (desktop) and always
     on mobile folder rows when expanded. Keep them small + muted so
     they don't compete with the folder label. */
  .ms-folder-actions { display: inline-flex; align-items: center; gap: 2px; margin-left: 6px; opacity: 0; transition: opacity 0.12s; }
  .ms-node.open > .ms-folder-actions { opacity: 1; }
  .ms-node:hover > .ms-folder-actions { opacity: 1; }
  @media (pointer: coarse) {
    .ms-folder-actions { opacity: 0.8; }
  }
  .ms-folder-actions button { width: 22px; height: 22px; padding: 0; background: transparent; border: 0; color: var(--muted); cursor: pointer; border-radius: 4px; display: inline-flex; align-items: center; justify-content: center; }
  .ms-folder-actions button:hover, .ms-folder-actions button:active { background: var(--panel); color: var(--text); }
  .ms-folder-actions svg { width: 14px; height: 14px; }
  .ms-children { display: none; }
  .ms-node.open + .ms-children { display: block; }
  .ms-empty-children { padding: 8px 16px; font-size: 12px; color: var(--muted); font-style: italic; }
  /* Hint on desktop — container centered with a max-width for comfort */
  @media (min-width: 720px) {
    .ms-tree { max-width: 620px; margin: 0 auto; }
    .ms-tree-body { max-height: 75vh; }
  }
  /* Quick-add/new buttons row */
  .ms-actions-row { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--border); }
  .ms-actions-row .btn { flex: 1; }
  /* Bottom-sheet "Move to..." picker */
  .move-sheet { position: fixed; inset: 0; background: rgba(10,12,18,0.55); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); z-index: 40; display: flex; flex-direction: column; justify-content: flex-end; }
  .move-sheet.hidden { display: none; }
  .move-panel { background: var(--bg); border-top: 1px solid var(--border); border-radius: 22px 22px 0 0; display: flex; flex-direction: column; max-height: 75dvh; padding-bottom: env(safe-area-inset-bottom); animation: cap-slide 0.22s cubic-bezier(0.2, 0.9, 0.3, 1); }
  .move-panel h3 { margin: 14px 16px 4px; font-size: 15px; }
  .move-panel .muted { padding: 0 16px 10px; font-size: 12px; color: var(--muted); }
  .move-panel .move-list { flex: 1; overflow-y: auto; padding: 0 8px 12px; }
  .move-item { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 10px; cursor: pointer; margin: 4px 0; min-height: 48px; }
  .move-item:active, .move-item:hover { background: var(--panel); }
  .move-item.current { background: rgba(126,176,255,0.1); border-left: 3px solid var(--accent); }
  .move-item .mi-ic { color: #e0c068; }
  .move-item.arc .mi-ic { color: #7eb0ff; padding-left: 24px; }
  .move-item.clear .mi-ic { color: var(--muted); }
  .move-item .mi-label { flex: 1; color: var(--text); font-size: 14px; }
  .move-panel .mv-footer { padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); display: flex; gap: 8px; }
  /* Adapted-chapter grid — status-colored tiles. Used by the Chapters
     card in manuscript list view. Replaces the flat row list. */
  .adapted-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(74px, 1fr)); gap: 8px; margin-top: 10px; }
  .adapted-tile { aspect-ratio: 1; border-radius: 10px; display: flex; flex-direction: column; align-items: center; justify-content: center; font-weight: 700; cursor: pointer; position: relative; text-align: center; padding: 6px 4px; background: var(--panel); border: 1px solid var(--border); color: var(--text); font-size: 18px; overflow: hidden; }
  .adapted-tile:active { transform: scale(0.96); }
  .adapted-tile .tile-num { font-size: 18px; font-weight: 800; letter-spacing: -0.02em; }
  .adapted-tile .tile-wc { font-size: 9px; color: var(--muted); margin-top: 2px; font-weight: 500; }
  .adapted-tile .tile-status-dot { position: absolute; top: 5px; right: 5px; width: 8px; height: 8px; border-radius: 50%; }
  .adapted-tile .tile-comment-dot { position: absolute; top: 5px; left: 5px; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
  .adapted-tile.draft          { background: linear-gradient(135deg, var(--panel), rgba(126,176,255,0.04)); border-color: rgba(126,176,255,0.35); color: var(--text); }
  .adapted-tile.draft .tile-status-dot         { background: var(--accent); }
  .adapted-tile.pending_review { background: linear-gradient(135deg, var(--panel), rgba(240,192,104,0.06)); border-color: rgba(240,192,104,0.5); color: var(--text); }
  .adapted-tile.pending_review .tile-status-dot { background: var(--warn); }
  .adapted-tile.published      { background: linear-gradient(135deg, var(--panel), rgba(109,208,130,0.08)); border-color: rgba(109,208,130,0.5); color: var(--text); }
  .adapted-tile.published .tile-status-dot     { background: var(--ok); }
  .adapted-tile.needs_tweak    { background: linear-gradient(135deg, var(--panel), rgba(240,120,120,0.06)); border-color: rgba(240,120,120,0.45); color: var(--text); }
  .adapted-tile.needs_tweak .tile-status-dot   { background: var(--fail); }
  /* Legend row beneath the grid */
  .adapted-legend { display: flex; gap: 10px; flex-wrap: wrap; font-size: 10px; color: var(--muted); margin-top: 10px; padding: 0 2px; }
  .adapted-legend .lg-item { display: inline-flex; align-items: center; gap: 4px; }
  .adapted-legend .lg-dot { width: 8px; height: 8px; border-radius: 50%; }
  /* List-mode toggle inside the Chapters card */
  .adapted-mode { display: flex; align-items: center; gap: 4px; background: var(--panel2); border: 1px solid var(--border); border-radius: 8px; padding: 2px; margin-left: auto; }
  .adapted-mode button { background: transparent; color: var(--muted); border: 0; padding: 4px 10px; font-size: 11px; font-weight: 600; cursor: pointer; border-radius: 6px; font-family: inherit; }
  .adapted-mode button.active { background: var(--accent); color: var(--bg); }
  .chapters-card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
  .chapters-card-head h2 { margin: 0 !important; }
  /* Swipe-to-approve — overlays shown as user drags. Only active inside
     adapted_view (fullscreen chapter editor). */
  .swipe-hint { position: fixed; top: 50%; transform: translateY(-50%); background: var(--bg); padding: 20px; border-radius: 18px; font-size: 14px; font-weight: 700; pointer-events: none; z-index: 30; opacity: 0; transition: opacity 0.15s; text-align: center; max-width: 220px; }
  .swipe-hint.show { opacity: 1; }
  .swipe-hint.approve { right: 10%; background: rgba(109,208,130,0.95); color: var(--bg); box-shadow: 0 8px 24px rgba(109,208,130,0.4); }
  .swipe-hint.reject { left: 10%; background: rgba(240,120,120,0.95); color: var(--bg); box-shadow: 0 8px 24px rgba(240,120,120,0.4); }
  .swipe-hint.tweak { left: 50%; top: 30%; transform: translate(-50%, 0); background: rgba(240,192,104,0.95); color: var(--bg); box-shadow: 0 8px 24px rgba(240,192,104,0.4); }
  /* Paragraph comments — inline pin + hover affordance */
  .reader p, .reader blockquote { position: relative; }
  .reader p.has-comment, .reader blockquote.has-comment { background: rgba(126,176,255,0.06); border-radius: 6px; padding: 4px 8px; margin-left: -8px; }
  .reader p.has-comment::before { content: '\1F4AC'; position: absolute; left: -22px; top: 2px; font-size: 14px; opacity: 0.6; }
  /* Paragraph comment modal */
  .pc-excerpt { background: var(--bg2); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 12px; color: var(--text2); margin-bottom: 10px; max-height: 120px; overflow-y: auto; line-height: 1.5; }
  .pc-existing { margin-bottom: 10px; }
  .pc-existing .pc-row { padding: 6px 0; border-top: 1px solid var(--border); font-size: 12px; }
  .pc-existing .pc-row:first-child { border-top: 0; }
  .pc-existing .pc-meta { color: var(--muted); font-size: 10px; margin-bottom: 2px; }
  .pc-existing .pc-text { color: var(--text); line-height: 1.45; }
  .pc-existing .pc-actions { margin-top: 4px; display: flex; gap: 8px; }
  .pc-existing .pc-actions button { font-size: 10px; color: var(--muted); background: transparent; border: 1px solid var(--border); border-radius: 6px; padding: 2px 8px; cursor: pointer; font-family: inherit; }
  /* Chapter mode toggle (Read / Edit) */
  .ch-mode-bar { position: fixed; top: 10px; left: 50%; transform: translateX(-50%); display: flex; gap: 2px; background: var(--panel); border: 1px solid var(--border); border-radius: 18px; padding: 3px; z-index: 20; box-shadow: 0 4px 12px rgba(0,0,0,0.3); }
  .ch-mode-bar button { background: transparent; color: var(--muted); border: 0; padding: 6px 16px; font-size: 12px; font-weight: 700; cursor: pointer; border-radius: 15px; font-family: inherit; min-height: 30px; }
  .ch-mode-bar button.active { background: var(--accent); color: var(--bg); }
  .ch-mode-bar .correct-btn { background: rgba(240,192,104,0.15); color: var(--warn); margin-left: 6px; border-left: 1px solid var(--border); padding-left: 14px; }
  .ch-mode-bar .correct-btn:active { background: rgba(240,192,104,0.3); }
  .ch-mode-bar .correct-btn:disabled { opacity: 0.5; }
  /* Reader — styled paragraph view */
  .chapter-reader { max-width: 760px; margin: 0 auto; padding: 58px 18px 120px; font: 17px/1.75 -apple-system, system-ui, sans-serif; color: var(--text); }
  .chapter-reader h1 { font-size: 22px; font-weight: 700; margin: 0 0 20px; color: var(--text); border-bottom: 1px solid var(--border); padding-bottom: 12px; }
  .chapter-reader .cr-para { margin: 0 0 1.1em; padding: 4px 8px; margin-left: -8px; border-radius: 6px; position: relative; cursor: pointer; transition: background 0.12s; -webkit-tap-highlight-color: transparent; user-select: none; }
  .chapter-reader .cr-para.has-comments { background: rgba(126,176,255,0.07); border-left: 2px solid var(--accent); padding-left: 10px; margin-left: -12px; }
  .chapter-reader .cr-para:active { background: rgba(126,176,255,0.12); }
  .chapter-reader .cr-para .cr-count { display: none; position: absolute; top: 4px; right: 4px; background: var(--accent); color: var(--bg); font-size: 10px; font-weight: 700; padding: 1px 5px; border-radius: 8px; line-height: 1.4; }
  .chapter-reader .cr-para.has-comments .cr-count { display: inline-block; }
  .chapter-reader .empty { padding: 40px 20px; text-align: center; color: var(--muted); }
  .pager { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; gap: 8px; }
  .pager button { background: var(--panel2); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 14px; font-size: 13px; cursor: pointer; min-height: 40px; }
  .pager button:disabled { opacity: 0.3; }
  .pager .info { color: var(--muted); font-size: 12px; text-align: center; flex: 1; }

  .tabbed { display: none; }
  .tabbed.active { display: block; }

  /* ---- Narrow-phone tightening (≤ 400px) ---- */
  @media (max-width: 400px) {
    .wrap { padding: 10px 10px 0; }
    .card { padding: 12px; margin-bottom: 10px; }
    .project-grid { gap: 8px; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
    .project-card { padding: 12px 10px; min-height: 110px; }
    .project-card .short { width: 30px; height: 30px; font-size: 12px; margin-bottom: 6px; }
    .project-card .name { font-size: 13px; }
    .project-card .stats { font-size: 10px; }
    .at-pill { padding: 3px 8px; font-size: 10.5px; }
    .topbar { gap: 6px; }
    .topnav button { font-size: 11px; padding: 7px 2px; }
    .row { padding: 10px 2px; }
    .row .title .sub { font-size: 10.5px; }
    .btn { font-size: 13px; min-height: 42px; padding: 9px 14px; }
    .btn.primary { font-size: 14.5px; }
    .btnbar { gap: 6px; margin: 10px 0; }
    h2 { margin: 12px 0 8px; }
    nav.bottom button { font-size: 10px; padding: 8px 2px; min-height: 52px; }
    nav.bottom .icon { font-size: 18px; }
  }

  /* ---- Approve/Reject on narrow screens: stack + full-width tap targets ---- */
  @media (max-width: 440px) {
    .approval-row { flex-wrap: wrap !important; }
    .approval-row .approval-btns { width: 100%; display: flex; gap: 6px; margin-top: 6px; }
    .approval-row .approval-btns .btn { flex: 1; min-height: 40px; font-size: 13px; }
  }

  /* ---- Audit finding row hover/expanded state ---- */
  details.audit-finding[open] > summary {
    background: var(--panel2);
    border-bottom-color: transparent;
  }
  details.audit-finding > summary::-webkit-details-marker { display: none; }
  details.audit-finding[open] > summary span:last-child { transform: rotate(180deg); display: inline-block; }

  .modal-bg {
    position: fixed; inset: 0; background: rgba(0,0,0,.65);
    z-index: 200; display: flex; align-items: flex-end; justify-content: center;
    padding: 20px; padding-bottom: calc(20px + env(safe-area-inset-bottom));
  }
  .modal {
    background: var(--panel); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 18px; width: 100%; max-width: 440px;
    box-shadow: var(--shadow); animation: modal-in .25s ease-out;
  }
  @keyframes modal-in { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
  .modal h3 { margin: 0 0 14px 0; font-size: 16px; }
  .modal .field-group { margin-bottom: 12px; }
  @media (min-width: 600px) { .modal-bg { align-items: center; } }
  .empty { padding: 32px 16px; text-align: center; color: var(--muted); font-size: 13px; }
  .empty .icon { font-size: 36px; margin-bottom: 8px; opacity: 0.5; }

  .sticky-head {
    position: sticky; top: 0; z-index: 30;
    background: rgba(11, 12, 16, 0.92);
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    margin: -14px -14px 8px -14px; padding: 6px 10px;
    border-bottom: 1px solid var(--border);
  }
  .sticky-head .back { margin: 0; padding: 4px 0; font-size: 13px; min-height: 28px; }
  .sticky-head .chapter-head { margin-bottom: 0; gap: 4px; }
  .sticky-head .chapter-head .title { font-size: 14px; }
  .sticky-head .navbtn { min-width: 36px; min-height: 36px; padding: 6px 10px; font-size: 18px; }

  .wc-bar { height: 4px; background: var(--bg2); border-radius: 2px; overflow: hidden; margin-top: 8px; }
  .wc-bar .fill { height: 100%; background: linear-gradient(90deg, var(--muted), var(--accent)); transition: width .25s; }
  .wc-bar.ok .fill { background: linear-gradient(90deg, var(--accent), var(--ok)); }
  .wc-bar.over .fill { background: var(--warn); }

  .iconbtn {
    background: var(--panel2); border: 1px solid var(--border);
    color: var(--text); border-radius: var(--radius-sm); padding: 8px 12px;
    min-height: 38px; min-width: 40px; font-size: 14px; cursor: pointer; font-weight: 600;
  }
  .iconbtn:active { background: var(--panel3); }

  .popover {
    position: absolute; top: 44px; right: 0;
    background: var(--panel); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 14px;
    box-shadow: var(--shadow); z-index: 60; min-width: 240px;
  }
  .popover .row-set { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); }
  .popover .row-set:last-child { border-bottom: 0; }
  .popover label { font-size: 13px; color: var(--text2); font-weight: 500; }
  .popover select { background: var(--bg2); color: var(--text); border: 1px solid var(--border); padding: 6px 10px; border-radius: 6px; font-size: 13px; }


/* ==== 04-design-pipeline.css ==== */
/* 04-design-pipeline.css — design editor, TOC, questions, pipeline, orchestrator chat
   Sourced from styles.css lines 705..944. Concatenated by build_css.py. */

  body.in-view .topbar, body.in-view .subtitle { display: none; }
  body.in-view .wrap { padding-top: 0; }
  /* User feedback 2026-04-21: topbar (project brand + Aa settings) is
     useless and eats screen real estate everywhere. Hide globally on
     the project screen. Home is reachable via the bottom nav "Home"
     button. */
  #project_screen > .topbar, #project_screen > .subtitle { display: none; }
  #project_screen .wrap { padding-top: 8px; }

  /* Structured editor */
  .sec-editor { padding: 0 0 80px 0; max-width: 760px; margin: 0 auto; }
  .sec-card { margin-bottom: 20px; border-bottom: 1px solid var(--border); padding-bottom: 16px; }
  .sec-h1 { width: 100%; background: transparent; border: 0; color: var(--text); font: 700 24px/1.3 -apple-system, system-ui, sans-serif; padding: 8px 0; outline: none; background: linear-gradient(135deg, var(--text), var(--accent)); -webkit-background-clip: text; background-clip: text; color: transparent; }
  .sec-h2 { width: 100%; background: transparent; border: 0; color: var(--text); font: 700 19px/1.3 -apple-system, system-ui, sans-serif; padding: 8px 0; outline: none; }
  .sec-h3 { width: 100%; background: transparent; border: 0; color: var(--accent); font: 700 16px/1.3 -apple-system, system-ui, sans-serif; padding: 6px 0; outline: none; }
  .sec-subhead { width: 100%; background: transparent; border: 0; color: var(--text); font: 600 15px/1.4 -apple-system, system-ui, sans-serif; padding: 4px 0; outline: none; }
  .sec-para { width: 100%; background: transparent; border: 0; color: var(--text2); font: 15px/1.7 -apple-system, system-ui, sans-serif; padding: 4px 0; outline: none; resize: none; overflow: hidden; min-height: 28px; }
  .sec-li { display: flex; gap: 6px; align-items: flex-start; padding: 2px 0; }
  .sec-li::before { content: '\2022'; color: var(--accent); font-weight: 700; flex-shrink: 0; margin-top: 2px; }
  .sec-li textarea { flex: 1; background: transparent; border: 0; color: var(--text2); font: 15px/1.6 -apple-system, system-ui, sans-serif; padding: 0; outline: none; resize: none; overflow: hidden; min-height: 24px; }
  .sec-quote { border-left: 3px solid var(--accent); padding-left: 12px; margin: 6px 0; }
  .sec-quote textarea { width: 100%; background: transparent; border: 0; color: var(--text2); font: italic 15px/1.6 -apple-system, system-ui, sans-serif; padding: 0; outline: none; resize: none; overflow: hidden; min-height: 24px; }
  .sec-hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }
  .sec-code { width: 100%; background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 12px; font: 13px/1.6 ui-monospace, monospace; resize: none; overflow: hidden; min-height: 40px; outline: none; margin: 8px 0; }
  .sec-h1:focus, .sec-h2:focus, .sec-h3:focus { box-shadow: inset 0 -2px 0 var(--accent); }
  .sec-para:focus, .sec-li textarea:focus, .sec-quote textarea:focus { background: rgba(126,176,255,0.04); border-radius: 4px; }

  .segbar { display: inline-flex; background: var(--panel2); border-radius: 8px; padding: 3px; gap: 3px; }
  .segbar button { background: transparent; color: var(--muted); border: 0; padding: 6px 12px; font-size: 12px; font-weight: 600; cursor: pointer; border-radius: 6px; min-height: 32px; }
  .segbar button.active { background: var(--panel3); color: var(--text); }

  .linediff { font: 13px/1.65 ui-monospace, monospace; background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius-sm); overflow-x: auto; padding: 0; margin: 10px 0; }
  .diff-line { padding: 1px 12px; white-space: pre-wrap; word-break: break-all; min-height: 20px; }
  .diff-line.add { background: rgba(109,208,130,.15); border-left: 3px solid var(--ok); color: #c8f0cc; }
  .diff-line.del { background: rgba(240,120,120,.12); border-left: 3px solid var(--fail); color: #f0cbcb; text-decoration: line-through; }
  .diff-line.hunk { background: rgba(126,176,255,.08); color: var(--accent); font-weight: 600; font-size: 11px; padding: 4px 12px; }
  .diff-line.ctx { color: var(--muted); }

  .md-preview { max-width: 760px; margin: 0 auto; padding: 8px 4px 80px; font: 16px/1.75 -apple-system, system-ui, sans-serif; color: var(--text); }
  .md-preview h1, .md-preview h2, .md-preview h3 { font-weight: 700; line-height: 1.3; color: var(--text); margin: 1.8em 0 0.6em; }
  .md-preview h1 { font-size: 26px; margin-top: 0.4em; padding-bottom: 10px; border-bottom: 1px solid var(--border); background: linear-gradient(135deg, var(--text), var(--accent)); -webkit-background-clip: text; background-clip: text; color: transparent; }
  .md-preview h2 { font-size: 21px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
  .md-preview h3 { font-size: 18px; color: var(--accent); }
  .md-preview p { margin: 0 0 1em; color: var(--text2); }
  .md-preview strong { color: var(--text); }
  .md-preview ul, .md-preview ol { padding-left: 1.4em; margin: 0 0 1em; color: var(--text2); }
  .md-preview li { margin: 0.3em 0; }
  .md-preview blockquote { margin: 1em 0; padding: 8px 14px; border-left: 3px solid var(--accent); background: var(--panel); border-radius: 0 8px 8px 0; color: var(--text2); font-style: italic; }
  .md-preview code { background: var(--panel2); padding: 2px 6px; border-radius: 4px; font: 13px/1.5 ui-monospace, monospace; color: var(--warn); }
  .md-preview pre { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 14px; overflow-x: auto; margin: 1em 0; }
  .md-preview pre code { background: transparent; padding: 0; color: var(--text); }
  .md-preview hr { border: 0; border-top: 1px solid var(--border); margin: 2em 0; }
  .md-preview table { width: 100%; border-collapse: collapse; margin: 1em 0; font-size: 14px; }
  .md-preview th, .md-preview td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
  .md-preview th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em; }
  .md-preview .tbl-scroll { margin: 1em -8px; padding: 0 8px 4px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .md-preview .tbl-scroll table { margin: 0; min-width: 480px; }
  .md-preview img { max-width: 100%; height: auto; border-radius: 8px; margin: 0.6em 0; border: 1px solid var(--border); }
  .md-preview a.wiki-link { color: var(--accent); text-decoration: none; border-bottom: 1px dashed rgba(126,176,255,0.35); padding-bottom: 1px; }
  .md-preview a.wiki-link:active { background: rgba(126,176,255,0.1); }
  .md-preview a.wiki-link.missing { color: var(--warn); border-bottom-color: rgba(240,192,104,0.4); }
  .md-preview h1, .md-preview h2, .md-preview h3 { scroll-margin-top: calc(var(--nav-h) + 80px); }
  /* TOC drawer (bottom-sheet feel on mobile) */
  .toc-bar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px; padding: 6px 10px; background: var(--bg); border-bottom: 1px solid var(--border); font-size: 12px; color: var(--muted); overflow: hidden; }
  .toc-bar .crumb { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .toc-bar .crumb .seg { color: var(--text2); }
  .toc-bar .crumb .sep { color: var(--muted); margin: 0 4px; }
  .toc-bar .toc-btn { background: var(--panel); border: 1px solid var(--border); color: var(--text); padding: 4px 10px; border-radius: 14px; font-size: 12px; font-weight: 600; cursor: pointer; }
  .toc-bar .toc-btn:active { background: var(--panel2); }
  .toc-panel { display: none; background: var(--panel); border-bottom: 1px solid var(--border); max-height: 50vh; overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .toc-panel.open { display: block; }
  .toc-panel ol { list-style: none; padding: 6px 0; margin: 0; }
  .toc-panel li { padding: 0; }
  .toc-panel li a { display: block; padding: 9px 14px; color: var(--text2); text-decoration: none; border-left: 2px solid transparent; font-size: 14px; }
  .toc-panel li a:active { background: var(--panel2); }
  .toc-panel li.lvl2 a { padding-left: 14px; color: var(--text); font-weight: 600; }
  .toc-panel li.lvl3 a { padding-left: 28px; font-size: 13px; }
  .toc-panel li.lvl4 a { padding-left: 40px; font-size: 12px; color: var(--muted); }
  .toc-panel li.active a { border-left-color: var(--accent); background: var(--bg2); color: var(--text); }
  /* Grouped design list */
  .doc-group { margin: 0 0 16px; }
  .doc-group .group-head { display: flex; align-items: center; gap: 8px; padding: 8px 12px 4px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
  .doc-group .group-head .count { color: var(--text2); font-weight: 500; text-transform: none; letter-spacing: 0; }
  .doc-group .group-head .ic { font-size: 14px; color: var(--accent); }
  .doc-row { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-top: 1px solid var(--border); cursor: pointer; min-height: 56px; }
  .doc-row:first-child { border-top: 0; }
  .doc-row:active { background: var(--panel2); }
  .doc-row .doc-name { flex: 1; min-width: 0; }
  .doc-row .doc-name .title { font-weight: 600; color: var(--text); font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .doc-row .doc-name .sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
  .doc-row .pill { flex-shrink: 0; }
  /* Wiki toolbar on read mode */
  .wiki-toolbar { display: flex; gap: 8px; padding: 8px 10px; background: var(--bg2); border-bottom: 1px solid var(--border); }
  .wiki-toolbar button { flex: 1; background: var(--panel); border: 1px solid var(--border); color: var(--text); padding: 10px; border-radius: 8px; font-size: 13px; font-weight: 600; min-height: 42px; cursor: pointer; }
  .wiki-toolbar button.primary { background: var(--accent); color: var(--bg); border-color: var(--accent); }
  .wiki-toolbar button:active { transform: scale(0.97); }
  /* Questions banner + quiz */
  .questions-banner { display: flex; align-items: center; gap: 12px; padding: 14px 16px; margin: 0 0 14px; background: linear-gradient(135deg, #2a1f3a, #1f2a3a); border: 1px solid #4a3a6a; border-radius: 12px; cursor: pointer; min-height: 60px; }
  .questions-banner:active { transform: scale(0.99); background: linear-gradient(135deg, #32274a, #273347); }
  .questions-banner .q-ic { width: 36px; height: 36px; border-radius: 50%; background: var(--accent); color: var(--bg); display: flex; align-items: center; justify-content: center; font-size: 18px; font-weight: 800; flex-shrink: 0; }
  .questions-banner .q-body { flex: 1; min-width: 0; }
  .questions-banner .q-title { font-weight: 700; color: var(--text); font-size: 15px; }
  .questions-banner .q-sub { font-size: 12px; color: var(--text2); margin-top: 2px; }
  .questions-banner .q-chev { font-size: 24px; color: var(--muted); flex-shrink: 0; }
  .q-opt { display: block; width: 100%; padding: 14px 14px; margin: 0 0 8px; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; color: var(--text); text-align: left; font-size: 15px; font-weight: 500; cursor: pointer; min-height: 50px; font-family: inherit; }
  .q-opt:active { background: var(--panel2); transform: scale(0.99); }
  .q-opt.selected { border-color: var(--accent); background: rgba(126,176,255,0.10); box-shadow: 0 0 0 2px rgba(126,176,255,0.20) inset; }
  .q-opt .opt-label { font-weight: 600; color: var(--text); }
  .q-opt .opt-detail { display: block; font-size: 12px; color: var(--text2); margin-top: 3px; font-weight: 400; line-height: 1.45; }
  .q-opt.other-opt { border-style: dashed; color: var(--accent); }
  /* Jobs-tab inline question cards */
  .q-card { padding: 14px; margin: 0 0 14px; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; }
  .q-card:last-child { margin-bottom: 0; }
  .q-card .q-title { font-weight: 700; font-size: 15px; color: var(--text); margin-bottom: 6px; }
  .q-card .q-context { font-size: 13px; color: var(--text2); line-height: 1.5; margin-bottom: 12px; white-space: pre-wrap; }
  .q-card .q-options { display: flex; flex-direction: column; margin-bottom: 10px; }
  .q-card .q-other-wrap { margin: 0 0 10px; }
  .q-card .q-other-text { width: 100%; padding: 10px; background: var(--panel2); border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-family: inherit; font-size: 14px; box-sizing: border-box; resize: vertical; }
  .q-card .q-other-text:focus { outline: none; border-color: var(--accent); }
  .q-card .q-actions { display: flex; gap: 8px; justify-content: flex-end; }
  .q-card .q-actions .btn { flex: 0 0 auto; min-width: 90px; }
  /* Pipeline status strip */
  .pipeline-strip { display: flex; align-items: center; gap: 10px; padding: 10px 14px; margin: 0 0 10px; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; cursor: pointer; min-height: 52px; }
  .pipeline-strip:active { background: var(--panel2); transform: scale(0.99); }
  .pipeline-strip .ps-led { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex-shrink: 0; box-shadow: 0 0 0 3px rgba(122,127,143,0.15); }
  .pipeline-strip.running .ps-led { background: var(--ok); box-shadow: 0 0 0 3px rgba(109,208,130,0.20); animation: pulse 1.6s ease-in-out infinite; }
  .pipeline-strip.pending .ps-led { background: var(--warn); box-shadow: 0 0 0 3px rgba(240,192,104,0.20); }
  .pipeline-strip.failed .ps-led { background: var(--fail); box-shadow: 0 0 0 3px rgba(240,120,120,0.20); }
  @keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: 0.5 } }
  .pipeline-strip .ps-body { flex: 1; min-width: 0; }
  .pipeline-strip .ps-title { font-weight: 600; color: var(--text); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .pipeline-strip .ps-sub { font-size: 11px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .pipeline-strip .ps-chev { color: var(--muted); font-size: 18px; flex-shrink: 0; transition: transform 0.15s; }
  .pipeline-strip.open .ps-chev { transform: rotate(90deg); }
  .pipeline-detail { margin: -6px 0 14px; padding: 10px 14px; background: var(--bg2); border: 1px solid var(--border); border-radius: 10px; font-size: 12px; color: var(--text2); }
  .pipeline-detail h4 { margin: 8px 0 4px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 700; }
  .pipeline-detail .task-row { display: flex; gap: 8px; align-items: baseline; padding: 4px 0; border-top: 1px solid var(--border); }
  .pipeline-detail .task-row:first-of-type { border-top: 0; }
  .pipeline-detail .task-kind { font-weight: 600; color: var(--text); font-size: 12px; }
  .pipeline-detail .task-meta { color: var(--muted); font-size: 11px; flex-shrink: 0; margin-left: auto; }
  .pipeline-detail .task-out { color: var(--text2); font-size: 11px; line-height: 1.45; margin-top: 2px; }
  .pipeline-detail .task-err { color: var(--fail); font-size: 11px; line-height: 1.45; margin-top: 2px; }
  .pipeline-detail .status-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; vertical-align: middle; margin-right: 4px; }
  .pipeline-detail .status-dot.done { background: var(--ok); }
  .pipeline-detail .status-dot.failed { background: var(--fail); }
  .pipeline-detail .status-dot.running { background: var(--running); }
  .pipeline-detail .status-dot.pending { background: var(--warn); }
  /* Orchestrator tab — chat UI (ChatGPT-mobile-inspired) */
  #tab_orchestrator { padding: 0 !important; }
  .orch-topbar { display: flex; align-items: center; gap: 8px; padding: 6px 10px 6px 14px; border-bottom: 1px solid var(--border); background: var(--bg); min-height: 40px; }
  .orch-session-label { flex: 1; min-width: 0; font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .orch-topbar-actions { display: flex; gap: 2px; flex-shrink: 0; }
  .orch-icon-btn { width: 36px; height: 36px; background: transparent; border: 0; color: var(--text2); display: flex; align-items: center; justify-content: center; cursor: pointer; border-radius: 50%; transition: background 0.12s; padding: 0; }
  .orch-icon-btn:hover, .orch-icon-btn:active { background: var(--panel); color: var(--text); }
  /* Session list rows */
  .session-row { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); cursor: pointer; min-height: 60px; }
  .session-row:active { background: var(--panel2); }
  .session-row.current { background: rgba(126,176,255,0.1); border-left: 3px solid var(--accent); padding-left: 11px; }
  .session-row .sess-body { flex: 1; min-width: 0; }
  .session-row .sess-title { font-weight: 600; color: var(--text); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .session-row .sess-meta { font-size: 11px; color: var(--muted); margin-top: 3px; }
  .session-row .sess-actions { flex-shrink: 0; display: flex; align-items: center; gap: 4px; }
  .session-row .sess-ic { color: var(--muted); font-size: 10px; background: var(--panel2); padding: 2px 6px; border-radius: 8px; }
  /* Fixed full-screen flex column. Bottom inset includes the bottom
     nav PLUS the soft-keyboard height (--kbd-height) so the composer
     stays visible above the keyboard on mobile. --kbd-height is
     updated by the visualViewport listener in orchInstallKbdTracker(). */
  #tab_orchestrator.active { display: flex !important; flex-direction: column; position: fixed; inset: 0 0 calc(var(--nav-h) + var(--kbd-height, 0px)) 0; background: var(--bg); z-index: 2; }
  /* When keyboard is open, hide the bottom nav so it doesn't poke
     through under the keyboard (purely cosmetic). */
  body.kbd-open #bottom_nav { visibility: hidden; }
  body.kbd-open #tab_orchestrator.active { bottom: var(--kbd-height, 0px); }
  #orch_shell { display: flex; flex-direction: column; height: 100%; min-height: 0; }
  #orch_thread { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 12px 14px 14px; scroll-padding-bottom: 120px; overscroll-behavior: contain; }
  #orch_thread .empty-orch { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; color: var(--muted); text-align: center; padding: 0 28px; }
  #orch_thread .empty-orch .eo-ic { font-size: 40px; margin-bottom: 14px; color: var(--accent); opacity: 0.8; }
  #orch_thread .empty-orch .eo-title { font-size: 16px; color: var(--text); font-weight: 600; margin-bottom: 6px; }
  #orch_thread .empty-orch .eo-sub { font-size: 13px; color: var(--muted); max-width: 260px; line-height: 1.55; }
  .orch-msg { margin: 10px 0; max-width: 88%; padding: 10px 14px; border-radius: 18px; font-size: 15px; line-height: 1.55; word-wrap: break-word; }
  .orch-msg.anim-in { animation: orch-in 0.18s ease-out; }
  @keyframes orch-in { from { opacity: 0; transform: translateY(4px) } to { opacity: 1; transform: none } }
  .orch-msg .orch-role { display: none; }
  .orch-msg .orch-time { display: none; font-size: 10px; color: var(--muted); margin-top: 4px; text-align: right; }
  .orch-msg:hover .orch-time, .orch-msg:active .orch-time { display: block; }
  .orch-msg.user { background: linear-gradient(135deg, #3b5a8a, #2a4068); color: #ecedf2; margin-left: auto; border-bottom-right-radius: 6px; box-shadow: 0 1px 2px rgba(0,0,0,0.15); }
  .orch-msg.assistant { background: transparent; color: var(--text); margin-right: auto; padding: 2px 0 12px; max-width: 100%; border-radius: 0; }
  .orch-msg.assistant:not(:last-child) { border-bottom: 1px solid var(--border); margin-bottom: 14px; }
  .orch-msg.assistant.pending { color: var(--muted); font-style: italic; }
  .orch-msg.assistant.failed { color: var(--fail); }
  .orch-msg.assistant .typing { display: inline-flex; align-items: center; gap: 4px; padding: 4px 0; }
  .orch-msg.assistant .typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: typing 1.1s ease-in-out infinite; }
  .orch-msg.assistant .typing span:nth-child(2) { animation-delay: 0.15s; }
  .orch-msg.assistant .typing span:nth-child(3) { animation-delay: 0.30s; }
  @keyframes typing { 0%,80%,100% { opacity: 0.3; transform: scale(0.8) } 40% { opacity: 1; transform: scale(1) } }
  .orch-tool { display: flex; align-items: center; gap: 6px; margin: 4px 0 6px; font-size: 12px; color: var(--muted); font-style: italic; }
  .orch-tool .tool-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: pulse-dot 1.4s ease-in-out infinite; }
  @keyframes pulse-dot { 0%,100% { opacity: 0.4 } 50% { opacity: 1 } }
  .orch-msg.assistant.streaming .md-preview::after { content: '\25AE'; color: var(--accent); margin-left: 4px; animation: caret-blink 1.1s steps(1) infinite; vertical-align: baseline; }
  @keyframes caret-blink { 0%,50% { opacity: 1 } 51%,100% { opacity: 0 } }
  .orch-actions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
  .orch-action { font-size: 11px; color: var(--muted); background: transparent; border: 1px solid var(--border); border-radius: 6px; padding: 3px 8px; cursor: pointer; font-family: inherit; }
  .orch-action:hover, .orch-action:active { color: var(--text); background: var(--panel); }
  .orch-action.stop { color: var(--fail); border-color: rgba(240,120,120,0.4); }
  .orch-action.stop:active { background: rgba(240,120,120,0.15); }
  .orch-msg .orch-time { display: block !important; font-size: 10px; color: var(--muted); margin-top: 6px; text-align: left; }
  .orch-msg.user .orch-time { text-align: right; color: rgba(236,237,242,0.6); }
  .orch-cost { font-size: 10px; color: var(--muted); margin-top: 2px; font-family: ui-monospace, monospace; }
  /* Conversation starters */
  .orch-starters { display: flex; flex-direction: column; gap: 10px; margin-top: 20px; max-width: 300px; width: 100%; }
  .orch-starter { padding: 12px 14px; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; color: var(--text); text-align: left; font-size: 13px; line-height: 1.4; cursor: pointer; transition: border-color 0.12s; font-family: inherit; }
  .orch-starter:active, .orch-starter:hover { border-color: var(--accent); background: var(--panel2); }
  .orch-starter .starter-label { font-weight: 600; display: block; margin-bottom: 3px; }
  .orch-starter .starter-hint { color: var(--muted); font-size: 11px; }
  /* Scroll-to-bottom FAB */
  .orch-fab { position: absolute; right: 14px; bottom: calc(82px + env(safe-area-inset-bottom)); width: 40px; height: 40px; border-radius: 50%; background: var(--panel); border: 1px solid var(--border); color: var(--text); display: none; align-items: center; justify-content: center; cursor: pointer; z-index: 3; box-shadow: 0 4px 12px rgba(0,0,0,0.35); }
  .orch-fab.show { display: flex; }
  .orch-fab:active { transform: scale(0.94); }
  .orch-fab .fab-badge { position: absolute; top: -3px; right: -3px; min-width: 16px; height: 16px; border-radius: 8px; background: var(--accent); color: var(--bg); font-size: 10px; font-weight: 700; display: flex; align-items: center; justify-content: center; padding: 0 4px; }
  .orch-msg.assistant .orch-copy { display: none; margin-top: 6px; font-size: 11px; color: var(--muted); background: var(--panel); border: 1px solid var(--border); border-radius: 6px; padding: 3px 8px; cursor: pointer; }
  .orch-msg.assistant:hover .orch-copy, .orch-msg.assistant:active .orch-copy { display: inline-block; }
  .orch-msg .md-preview { font-size: 15px; padding: 0; line-height: 1.6; margin: 0; }
  .orch-msg .md-preview > *:first-child { margin-top: 0; }
  .orch-msg .md-preview > *:last-child { margin-bottom: 0; }
  .orch-msg .md-preview h1, .orch-msg .md-preview h2, .orch-msg .md-preview h3 { font-size: 15px; font-weight: 700; margin: 0.8em 0 0.3em; border: 0; padding: 0; background: none; color: var(--text); -webkit-text-fill-color: var(--text); }
  .orch-msg .md-preview p { margin: 0 0 0.55em; color: var(--text); }
  .orch-msg .md-preview ul, .orch-msg .md-preview ol { margin: 0 0 0.55em; padding-left: 1.3em; color: var(--text); }
  .orch-msg .md-preview li { margin: 0.15em 0; }
  .orch-msg .md-preview pre { margin: 0.6em 0; padding: 10px 12px; font-size: 12px; border-radius: 10px; }
  .orch-msg .md-preview code { font-size: 13px; color: var(--warn); }
  /* Composer — pill shape with inline send icon */
  #orch_composer { flex: 0 0 auto; padding: 8px 10px calc(10px + env(safe-area-inset-bottom)); background: linear-gradient(to bottom, transparent, var(--bg) 8px); position: relative; }
  .orch-compose-pill { display: flex; align-items: flex-end; gap: 8px; background: var(--panel); border: 1px solid var(--border); border-radius: 22px; padding: 6px 6px 6px 14px; transition: border-color 0.12s, box-shadow 0.12s; }
  .orch-compose-pill:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(126,176,255,0.12); }
  #orch_input { flex: 1; background: transparent; border: 0; outline: 0; color: var(--text); padding: 9px 2px; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, Roboto, Helvetica, Arial, sans-serif; font-size: 15px; line-height: 1.4; resize: none; min-height: 24px; max-height: 160px; overflow-y: auto; }
  #orch_input::placeholder { color: var(--muted); }
  .orch-send-ic { width: 34px; height: 34px; min-width: 34px; flex-shrink: 0; border: 0; border-radius: 50%; background: var(--accent); color: var(--bg); display: flex; align-items: center; justify-content: center; cursor: pointer; transition: transform 0.08s, background 0.12s; padding: 0; }
  .orch-send-ic:active { transform: scale(0.94); }
  .orch-send-ic:disabled { background: var(--panel2); color: var(--muted); cursor: default; }
  .orch-send-ic svg { display: block; }
  #badge_orchestrator:not(:empty) { margin-left: 4px; background: var(--accent); color: var(--bg); font-size: 10px; padding: 1px 6px; border-radius: 10px; font-weight: 700; }

/* ==== 05-capture-activity.css ==== */
/* 05-capture-activity.css — capture FAB, quick-capture sheet, nav badges, activity, design editing mode
   Sourced from styles.css lines 945..1042. Concatenated by build_css.py. */

  /* Global floating capture button. Bottom-right, above any
     context-specific FAB already on screen. --capture-bottom-offset
     defaults to the nav height; chapter/design views bump it higher
     via body classes so the + never overlaps the menu/save FAB. */
  .global-fabs { position: fixed; right: 14px; bottom: calc(var(--nav-h) + 12px + var(--capture-bottom-offset, 0px)); display: flex; flex-direction: column; gap: 10px; z-index: 8; transition: bottom 0.18s; }
  body.on-orch .global-fabs { display: none !important; }
  body.ch-editing { --capture-bottom-offset: 64px; }         /* push above ch-menu-fab */
  body.design-editing { --capture-bottom-offset: 64px; }     /* push above fab_design */
  .gfab { width: 48px; height: 48px; border-radius: 50%; border: 0; color: var(--bg); display: flex; align-items: center; justify-content: center; cursor: pointer; box-shadow: 0 6px 16px rgba(0,0,0,0.4); position: relative; transition: transform 0.08s; }
  .gfab:active { transform: scale(0.94); }
  .gfab.capture-fab { background: var(--accent); }
  /* Quick-capture — full-sheet elegant overlay. Slides up from
     the bottom, takes most of the viewport so the user has real
     room to type. Mirrors the orchestrator tab's clean chrome. */
  .capture-sheet { position: fixed; inset: 0; background: rgba(10, 12, 18, 0.55); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); z-index: 40; display: flex; flex-direction: column; justify-content: flex-end; }
  .capture-panel { background: var(--bg); border-top: 1px solid var(--border); border-radius: 22px 22px 0 0; display: flex; flex-direction: column; height: 88dvh; max-height: 88vh; animation: cap-slide 0.22s cubic-bezier(0.2, 0.9, 0.3, 1); padding-bottom: env(safe-area-inset-bottom); }
  @keyframes cap-slide { from { transform: translateY(100%) } to { transform: translateY(0) } }
  .capture-head { flex: 0 0 auto; display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
  .capture-title { flex: 1; font-weight: 700; font-size: 16px; color: var(--text); text-align: center; }
  .capture-close { background: transparent; border: 0; color: var(--muted); font-size: 28px; line-height: 1; padding: 0 6px; cursor: pointer; min-width: 40px; }
  .capture-close:active { color: var(--text); }
  .capture-save { background: var(--accent); color: var(--bg); border: 0; border-radius: 16px; padding: 7px 18px; font-size: 13px; font-weight: 700; cursor: pointer; min-height: 34px; }
  .capture-save:active { transform: scale(0.96); }
  .capture-save:disabled { opacity: 0.5; }
  .capture-textarea { flex: 1; width: 100%; background: transparent; border: 0; outline: 0; color: var(--text); padding: 18px 20px 0; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, Roboto, Helvetica, Arial, sans-serif; font-size: 17px; line-height: 1.55; resize: none; min-height: 0; }
  .capture-textarea::placeholder { color: var(--muted); white-space: pre-line; }
  .capture-footer { flex: 0 0 auto; padding: 12px 20px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); background: var(--bg2); }
  .capture-hint { font-size: 11px; color: var(--muted); }
  /* Nav badges — visible on tab buttons when there's new/pending work */
  .bottom button .nav-badge { display: none; position: absolute; top: 4px; right: calc(50% - 20px); min-width: 16px; height: 16px; border-radius: 8px; background: var(--accent); color: var(--bg); font-size: 10px; font-weight: 700; align-items: center; justify-content: center; padding: 0 4px; line-height: 1; }
  .bottom button .nav-badge.show { display: inline-flex; }
  .bottom button .nav-badge.dot { min-width: 8px; height: 8px; padding: 0; font-size: 0; border-radius: 50%; }
  .bottom button .nav-badge.amber { background: var(--warn); }
  .bottom button .nav-badge.fail { background: var(--fail); }
  /* Home activity feed */
  .activity-head { display: flex; align-items: baseline; justify-content: space-between; margin: 18px 0 8px; padding: 0 2px; }
  .activity-head h2 { font-size: 14px; font-weight: 700; color: var(--text); margin: 0; text-transform: uppercase; letter-spacing: 0.06em; }
  .activity-head .filter { font-size: 11px; color: var(--muted); }
  .act-card { display: flex; gap: 10px; padding: 10px 12px; margin: 0 0 8px; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; cursor: pointer; min-height: 56px; align-items: flex-start; }
  .act-card:active { background: var(--panel2); transform: scale(0.99); }
  .act-card.needs-you { border-left: 3px solid var(--warn); }
  .act-card.in-flight { border-left: 3px solid var(--accent); }
  .act-card.info { border-left: 3px solid var(--border); }
  .act-ic { width: 28px; height: 28px; border-radius: 50%; background: var(--panel2); display: flex; align-items: center; justify-content: center; font-size: 14px; flex-shrink: 0; color: var(--accent); margin-top: 2px; }
  .act-card.needs-you .act-ic { color: var(--warn); }
  .act-card.in-flight .act-ic { color: var(--accent); }
  .act-body { flex: 1; min-width: 0; }
  .act-title-row { display: flex; align-items: baseline; gap: 8px; }
  .act-title { font-weight: 600; color: var(--text); font-size: 14px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .act-ago { font-size: 11px; color: var(--muted); flex-shrink: 0; }
  .act-detail { font-size: 12px; color: var(--text2); margin-top: 3px; line-height: 1.4; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .act-proj { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin-right: 6px; }
  .activity-empty { padding: 40px 20px; text-align: center; color: var(--muted); font-size: 13px; background: var(--panel); border: 1px dashed var(--border); border-radius: 10px; }

  body.focus-mode nav.bottom, body.focus-mode .fab, body.focus-mode .sticky-head .navbtn,
  body.focus-mode .sticky-head .subtitle, body.focus-mode #title_input, body.focus-mode .field-row,
  body.focus-mode .refpanel, body.focus-mode .wc-bar, body.focus-mode #diff_container,
  body.focus-mode label.field { display: none !important; }
  body.focus-mode { padding-bottom: 20px; }
  body.focus-mode .wrap { padding: 0; max-width: 780px; }
  body.focus-mode .editor { min-height: calc(100vh - 120px); border-radius: 0; border-left: 0; border-right: 0; padding: 24px 28px; font-size: 17px; line-height: 1.9; }
  body.focus-mode #focus_exit { display: inline-block !important; }
  #focus_exit { display: none; position: fixed; top: 14px; right: 14px; z-index: 100; }

  #design_edit_view .sticky-head { padding: 4px 10px; display: flex; align-items: center; gap: 8px; }
  #design_edit_view .sticky-head .back { margin: 0; padding: 4px 0; }
  #design_edit_view .sticky-head .design-meta { flex: 1; min-width: 0; font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #design_edit_view .sticky-head .design-meta .sub { font-weight: 400; color: var(--muted); font-size: 11px; }
  /* Design editing mode — chrome-less, same pattern as chapter editor */
  body.design-editing nav.bottom,
  body.design-editing #project_screen > .topbar,
  body.design-editing .fab { display: none !important; }
  body.design-editing { padding-bottom: 0; }
  body.design-editing .wrap { padding: 0; }

  /* Fill-viewport editors — one visible at a time */
  .design-editor {
    width: 100%;
    height: 100dvh; min-height: 100dvh;
    background: var(--bg); color: var(--text); border: 0; border-radius: 0;
    padding: calc(54px + env(safe-area-inset-top)) 18px 110px;
    resize: none; outline: none;
    font: 15px/1.72 ui-monospace, SFMono-Regular, Menlo, monospace;
    -webkit-appearance: none;
    caret-color: var(--accent);
  }
  .design-editor:focus { outline: none; }
  body.design-editing .md-preview,
  body.design-editing .sec-editor {
    min-height: calc(100dvh - 120px);
    padding: calc(54px + env(safe-area-inset-top)) 18px 110px;
  }
  body.design-editing #design_preview.md-preview {
    background: var(--bg);
    font: 16px/1.65 Georgia, ui-serif, Cambria, "Times New Roman", serif;
    color: var(--text2);
  }


/* ==== 06-workflow.css ==== */
/* 06-workflow.css — Atelier Flow UI (all wf-* classes)
   Sourced from styles.css lines 1043..1275. Concatenated by build_css.py. */

  /* ========== Workflow (Atelier Flow) ========== */
  .wf-row {
    display: flex; align-items: center; gap: 12px;
    padding: 8px 4px; border-radius: 8px; cursor: pointer;
    border-bottom: 1px solid var(--border);
  }
  .wf-row:last-child { border-bottom: 0; }
  .wf-row:hover { background: var(--panel2); }
  .wf-row-left { flex: 1; min-width: 0; }
  .wf-title { font-weight: 600; font-size: 0.92em; margin-bottom: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .wf-sub { color: var(--muted); font-size: 0.78em; }
  .wf-bar { width: 80px; height: 4px; background: var(--panel3); border-radius: 2px; overflow: hidden; flex-shrink: 0; }
  .wf-bar-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--ok)); transition: width 200ms ease; }

  body.on-workflow { padding: 0 14px 80px; padding-top: env(safe-area-inset-top); }
  body.on-workflow #bottom_nav,
  body.on-workflow #global_fabs { display: none !important; }
  .wf-head {
    display: flex; align-items: center; gap: 12px;
    padding: 14px 0 12px; border-bottom: 1px solid var(--border); margin-bottom: 14px;
  }
  .wf-back {
    background: var(--panel); border: 1px solid var(--border);
    color: var(--text); width: 36px; height: 36px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3em; cursor: pointer; flex-shrink: 0;
  }
  .wf-head-titles { min-width: 0; flex: 1; }
  .wf-head-title { font-weight: 700; font-size: 1.1em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .wf-head-sub { color: var(--muted); font-size: 0.82em; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .wf-phase-pill {
    display: inline-block; margin-top: 6px;
    padding: 3px 10px; border-radius: 999px;
    background: rgba(126,176,255,0.12);
    border: 1px solid rgba(126,176,255,0.30);
    color: var(--accent);
    font-size: 0.78em; font-weight: 600;
    letter-spacing: 0.01em;
  }
  /* Phase navigator strip — clickable pills 1..11 above the title.
     Past phases = green/done; current = filled accent; future = dim
     but still clickable (jump-ahead). The "viewing" pill — the one
     the writer is browsing read-only — gets a ring so they remember
     they're not on the live phase. */
  .wf-phase-strip {
    display: flex; gap: 4px; flex-wrap: wrap;
    margin-top: 8px;
  }
  .wf-strip-pill {
    width: 26px; height: 26px;
    border-radius: 50%;
    background: var(--panel2);
    border: 1px solid var(--border);
    color: var(--muted);
    font-size: 0.78em; font-weight: 600;
    cursor: pointer; padding: 0;
    display: flex; align-items: center; justify-content: center;
    transition: transform 100ms ease;
  }
  .wf-strip-pill:hover { transform: scale(1.08); }
  .wf-strip-pill.past {
    background: rgba(109,208,130,0.10);
    border-color: rgba(109,208,130,0.40);
    color: var(--ok);
  }
  .wf-strip-pill.actual {
    background: var(--accent);
    border-color: var(--accent);
    color: #0b0c10;
  }
  .wf-strip-pill.viewing {
    box-shadow: 0 0 0 2px var(--accent);
  }
  .wf-strip-pill.future {
    opacity: 0.55;
  }
  .wf-viewing-banner {
    margin: 8px 0 14px;
    padding: 10px 14px;
    border-radius: 10px;
    background: rgba(126,176,255,0.08);
    border: 1px solid rgba(126,176,255,0.30);
    color: var(--text);
    font-size: 0.88em;
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  }
  .wf-banner-back {
    background: transparent; border: 1px solid var(--accent);
    color: var(--accent); padding: 4px 10px;
    border-radius: 6px; cursor: pointer;
    font-size: 0.92em; font-weight: 600;
  }
  .wf-banner-back:hover { background: rgba(126,176,255,0.12); }

  /* Phase 4 builder — per-book / per-arc controls. */
  .wf-p4-card {
    margin-bottom: 14px; padding: 14px;
    background: var(--panel); border: 1px solid var(--border);
    border-radius: 10px;
  }
  .wf-p4-card.wf-p4-empty {
    background: linear-gradient(180deg, var(--panel) 70%, rgba(126,176,255,0.04));
    border-style: dashed;
  }
  .wf-p4-card.wf-p4-layout {
    border-color: rgba(126,176,255,0.30);
    background: linear-gradient(180deg, var(--panel) 70%, rgba(126,176,255,0.04));
  }
  .wf-p4-card.wf-p4-book {
    border-color: rgba(210,176,255,0.25);
  }
  .wf-p4-card-head {
    display: flex; justify-content: space-between; align-items: baseline;
    gap: 10px; margin-bottom: 8px;
  }
  .wf-p4-card-head h3 { margin: 0; font-size: 1em; }
  .wf-p4-pill {
    font-size: 0.72em; font-weight: 700;
    padding: 2px 8px; border-radius: 999px;
    background: rgba(180,180,180,0.18); color: var(--muted);
    text-transform: uppercase; letter-spacing: 0.04em;
  }
  .wf-p4-pill.pending { background: rgba(126,176,255,0.18); color: var(--accent); }
  .wf-p4-pill.accepted { background: rgba(109,208,130,0.18); color: var(--ok); }
  .wf-p4-pill.rejected { background: rgba(240,120,120,0.16); color: var(--fail); }

  .wf-p4-thesis { color: var(--muted); font-size: 0.92em; margin-bottom: 10px; }
  .wf-p4-body, .wf-p4-arc-body { font-size: 0.92em; line-height: 1.5; margin-bottom: 8px; }

  .wf-p4-arcs-list { margin: 8px 0; }
  .wf-p4-arc {
    margin: 8px 0; padding: 10px 12px;
    background: var(--panel2); border: 1px solid var(--border);
    border-radius: 8px;
  }
  .wf-p4-arc-head {
    display: flex; justify-content: space-between; align-items: baseline;
    gap: 8px; margin-bottom: 6px;
  }

  .wf-p4-actions {
    display: flex; gap: 6px; flex-wrap: wrap;
    margin-top: 8px;
  }
  .wf-p4-actions .btn.small { padding: 5px 12px; font-size: 0.86em; }

  .wf-p4-arc-gen {
    margin-top: 12px; padding-top: 12px;
    border-top: 1px dashed var(--border);
  }
  .wf-p4-seed {
    display: block; width: 100%;
    margin-bottom: 8px; padding: 8px 10px;
    background: var(--panel2); border: 1px solid var(--border); border-radius: 6px;
    color: var(--text); font: inherit; font-size: 0.92em; line-height: 1.4;
    resize: vertical; min-height: 50px;
  }
  .wf-skip-phase {
    flex-shrink: 0;
    padding: 8px 12px; border-radius: 8px;
    background: var(--panel2); color: var(--accent);
    border: 1px solid var(--accent);
    font-size: 0.82em; font-weight: 600;
    cursor: pointer; white-space: nowrap;
    align-self: center;
  }
  .wf-skip-phase:hover { background: rgba(126,176,255,0.10); }
  @media (max-width: 480px) {
    /* On phone, the back arrow + title fill the row; tuck the skip
       button onto its own line below the head. */
    .wf-head { flex-wrap: wrap; }
    .wf-skip-phase { flex-basis: 100%; margin-top: 4px; align-self: stretch; text-align: center; }
  }
  .wf-body { max-width: 720px; margin: 0 auto; }

  .wf-stepper {
    display: flex; align-items: center; gap: 6px;
    padding: 8px 4px 20px; overflow-x: auto;
  }
  .wf-step {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    min-width: 64px; padding: 8px; border-radius: 10px;
    background: var(--panel); border: 1px solid var(--border); cursor: pointer;
    flex-shrink: 0;
  }
  .wf-step.active { border-color: var(--accent); background: var(--panel2); }
  .wf-step.done { border-color: var(--ok); }
  .wf-step-dot {
    width: 20px; height: 20px; border-radius: 50%;
    background: var(--panel3); color: var(--ok);
    display: flex; align-items: center; justify-content: center;
    font-size: 0.85em; font-weight: 700;
  }
  .wf-step.done .wf-step-dot { background: rgba(109,208,130,0.18); }
  .wf-step.active .wf-step-dot { background: rgba(126,176,255,0.22); color: var(--accent); }
  .wf-step-label { font-size: 0.82em; font-weight: 600; }
  .wf-step-sub { font-size: 0.7em; color: var(--muted); }
  .wf-step-sep { flex: 1; min-width: 6px; height: 1px; background: var(--border); }

  .wf-chapter-head { margin-bottom: 14px; }
  .wf-chapter-head h2 { margin: 0 0 4px 0; font-size: 1.3em; }
  .wf-chapter-sub { color: var(--muted); font-size: 0.88em; }

  .wf-qna { display: flex; flex-direction: column; gap: 14px; }

  .wf-card {
    background: var(--panel); border: 1px solid var(--border);
    border-radius: 12px; padding: 14px;
  }
  .wf-card[data-status="answered"] { border-color: var(--accent); }
  .wf-card[data-status="committed"] { border-color: var(--ok); background: linear-gradient(135deg, var(--panel), rgba(109,208,130,0.04)); }
  .wf-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 6px; }
  .wf-card-title { font-weight: 600; font-size: 0.98em; line-height: 1.3; }
  .wf-card-context { color: var(--muted); font-size: 0.82em; margin-bottom: 10px; }

  .wf-pill {
    font-size: 0.66em; padding: 2px 8px; border-radius: 10px;
    letter-spacing: 0.5px; text-transform: uppercase; white-space: nowrap;
    flex-shrink: 0;
  }
  .wf-pill.answered { background: rgba(126,176,255,0.15); color: var(--accent); }
  .wf-pill.committed { background: rgba(109,208,130,0.16); color: var(--ok); }
  .wf-pill.skipped { background: rgba(180,180,180,0.18); color: var(--muted); }

  .wf-skip {
    background: transparent;
    border: 1px solid var(--border2); border-radius: 6px;
    color: var(--muted); font-size: 0.8em; cursor: pointer;
    padding: 5px 10px;
  }
  .wf-skip:hover { background: var(--panel2); color: var(--text); }

  .wf-suggest {
    background: rgba(210,176,255,0.10);
    border: 1px solid rgba(210,176,255,0.40);
    color: #d2b0ff;
    border-radius: 6px;
    font-size: 0.8em; font-weight: 600;
    cursor: pointer; padding: 5px 10px;
  }
  .wf-suggest:hover { background: rgba(210,176,255,0.20); }

  .wf-card-actions {
    display: flex; flex-wrap: wrap; gap: 6px;
    margin-top: 10px;
  }

  .wf-suggestion {
    margin-top: 10px; padding: 10px 12px;
    background: rgba(210,176,255,0.06);
    border: 1px solid rgba(210,176,255,0.30);
    border-radius: 8px;
    font-size: 0.88em;
  }
  .wf-suggestion-head {
    font-weight: 700; font-size: 0.78em; letter-spacing: 0.04em;
    color: #d2b0ff; text-transform: uppercase; margin-bottom: 4px;
  }
  .wf-suggestion-body { color: var(--text); margin-bottom: 4px; }
  .wf-suggestion-why { color: var(--muted); font-size: 0.92em; margin-bottom: 8px; }
  .wf-suggestion-actions { display: flex; gap: 6px; }
  .wf-suggestion-actions .btn { padding: 5px 10px; font-size: 0.85em; }

  .wf-opts { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
  .wf-opt {
    text-align: left; background: var(--panel2); border: 1px solid var(--border);
    color: var(--text); padding: 10px 12px; border-radius: 8px; cursor: pointer;
    font: inherit;
  }
  .wf-opt:hover:not(:disabled) { background: var(--panel3); border-color: var(--border2); }
  .wf-opt.picked { border-color: var(--accent); background: rgba(126,176,255,0.08); }
  .wf-opt:disabled { cursor: default; opacity: 0.75; }
  .wf-opt-label { font-weight: 600; font-size: 0.92em; }
  .wf-opt-blurb { color: var(--muted); font-size: 0.82em; margin-top: 2px; }
  .wf-opt-other { font-style: italic; }

  .wf-other-input {
    width: 100%; margin-top: 8px; padding: 10px 14px;
    background: var(--panel2); border: 1px solid var(--accent); border-radius: 8px;
    color: var(--text); font: inherit; line-height: 1.55;
    /* Height is JS-managed via wbAutoGrow. Starts at ~1.5 lines so an
       empty field doesn't dominate the screen, then grows with content
       up to ~20 lines, then scrolls internally. */
    resize: none;
    min-height: 56px;
    overflow-y: hidden;
  }

  .wf-clear {
    margin-top: 8px; background: transparent; border: 0;
    color: var(--muted); font-size: 0.8em; cursor: pointer; padding: 4px 0;
  }
  .wf-clear:hover { color: var(--fail); }

  .wf-edit {
    margin-top: 10px; padding: 6px 12px;
    background: transparent; border: 1px solid var(--accent);
    color: var(--accent); border-radius: 6px;
    font-size: 0.82em; font-weight: 600; cursor: pointer;
  }
  .wf-edit:hover { background: rgba(126,176,255,0.10); }

  .wf-quickstart-row {
    display: flex; flex-direction: column; gap: 6px;
    margin: 8px 0 14px;
  }
  .wf-smartstart {
    width: 100%; padding: 14px;
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(126,176,255,0.18), rgba(210,176,255,0.16));
    border: 1px solid rgba(210,176,255,0.55);
    color: var(--text);
    font-size: 0.96em; font-weight: 700;
    cursor: pointer; text-align: center;
  }
  .wf-smartstart:hover { background: linear-gradient(135deg, rgba(126,176,255,0.28), rgba(210,176,255,0.24)); }
  .wf-quickstart {
    display: block; width: 100%;
    padding: 8px; border-radius: 8px;
    background: transparent;
    border: 1px dashed rgba(180,180,180,0.32);
    color: var(--muted);
    font-size: 0.85em;
    cursor: pointer; text-align: center;
  }
  .wf-quickstart:hover { background: var(--panel2); color: var(--text); }

  .wf-submit {
    display: block; width: 100%; margin: 20px 0 40px;
    padding: 14px; font-size: 1em; min-height: 48px;
  }
  .wf-submit:disabled { opacity: 0.5; cursor: not-allowed; }
  .wf-locked {
    margin: 20px 0 40px; padding: 14px; text-align: center;
    background: rgba(109,208,130,0.08); border: 1px solid rgba(109,208,130,0.3);
    color: var(--ok); border-radius: 10px; font-weight: 600;
  }
  .wf-panel {
    padding: 18px; background: var(--panel); border: 1px solid var(--border);
    border-radius: 12px;
  }
  .wf-panel h3 { margin-top: 0; }

  /* Child questions (AI-spawned follow-ups) */
  .wf-child {
    margin-left: 18px; padding-left: 14px;
    border-left: 2px solid var(--accent);
    margin-top: 10px; margin-bottom: 4px;
  }
  .wf-child .wf-card {
    background: linear-gradient(135deg, var(--panel), rgba(126,176,255,0.04));
  }

  /* Follow-up generation banner */
  .wf-expansion-banner {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; margin-bottom: 12px;
    background: rgba(126,176,255,0.08);
    border: 1px solid rgba(126,176,255,0.25);
    border-radius: 8px; color: var(--accent);
    font-size: 0.88em;
  }
  .wf-spinner {
    width: 14px; height: 14px; border-radius: 50%;
    border: 2px solid rgba(126,176,255,0.25);
    border-top-color: var(--accent);
    animation: wf-spin 0.8s linear infinite;
    flex-shrink: 0;
  }
  @keyframes wf-spin { to { transform: rotate(360deg); } }

  /* Waiting-card shown only when the user advances past the last
     loaded question AND a follow-up is still being generated. This is
     the only visible indicator of background AI work in the app. */
  .wf-card-loading {
    display: flex; align-items: center; justify-content: center;
    min-height: 180px;
    opacity: 0.7;
  }
  .wf-loading-inner {
    display: flex; flex-direction: column; align-items: center;
    gap: 12px;
    color: var(--muted, #8b949e);
    font-size: 0.92em;
  }
  .wf-loading-inner .wf-spinner {
    width: 24px; height: 24px;
    border-width: 3px;
  }

  /* Single-question nav (one card at a time). */
  .wf-qna-single {
    animation: wf-card-in 0.18s ease-out;
    min-height: 180px;
  }
  @keyframes wf-card-in {
    from { opacity: 0; transform: translateX(6px); }
    to   { opacity: 1; transform: translateX(0); }
  }
  .wf-nav-row {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 10px;
    margin-top: 16px;
    margin-bottom: 12px;
  }
  .wf-nav-row .btn { min-width: 86px; }
  .wf-nav-row .wf-nav-prev { justify-self: start; }
  .wf-nav-row .wf-nav-next { justify-self: end; }
  .wf-nav-counter {
    text-align: center;
    font-size: 0.82em;
    color: var(--muted, #8b949e);
    font-weight: 600;
    letter-spacing: 0.02em;
  }
  .wf-nav-counter-sub {
    font-weight: 400;
    opacity: 0.75;
  }
  .wf-jump-unanswered {
    display: block;
    margin: 8px auto 0;
    background: rgba(126,176,255,0.12);
    color: var(--accent, #7eb0ff);
    border: 1px solid rgba(126,176,255,0.28);
  }
  .wf-saving-tag {
    display: inline-block;
    margin-left: 8px;
    padding: 2px 8px;
    background: rgba(240,192,104,0.15);
    color: #f0c068;
    border: 1px solid rgba(240,192,104,0.3);
    border-radius: 10px;
    font-size: 0.62em;
    font-weight: 600;
    letter-spacing: 0.04em;
    vertical-align: middle;
    animation: wf-pulse 1.6s ease-in-out infinite;
  }
  @keyframes wf-pulse {
    0%, 100% { opacity: 0.65; }
    50%      { opacity: 1; }
  }

  /* Phase-3 design review */
  .wf-review-head { margin-bottom: 14px; }
  .wf-review-head h2 { margin: 0 0 4px; font-size: 1.3em; }

  .wf-review-section { margin-bottom: 22px; }
  .wf-review-section-head {
    font-size: 0.78em; letter-spacing: 0.6px; text-transform: uppercase;
    color: var(--muted); padding: 0 0 8px; border-bottom: 1px solid var(--border);
    margin-bottom: 10px;
  }
  .wf-review-card {
    background: var(--panel); border: 1px solid var(--border);
    border-radius: 12px; padding: 14px; margin-bottom: 12px;
  }
  .wf-review-card[data-status="accepted"] {
    border-color: var(--ok);
    background: linear-gradient(135deg, var(--panel), rgba(109,208,130,0.04));
  }
  .wf-review-meta { font-size: 0.76em; margin: 2px 0 10px; }
  .wf-review-body {
    font-size: 0.95em; line-height: 1.55; color: var(--text);
    margin-bottom: 8px;
  }
  .wf-review-body p { margin: 0 0 8px; }
  .wf-review-body p:last-child { margin-bottom: 0; }
  .wf-review-notes {
    font-size: 0.85em; color: var(--text2);
    padding: 8px 10px; background: var(--panel2);
    border-left: 3px solid var(--accent); border-radius: 4px;
    margin-bottom: 10px;
  }
  .wf-review-actions {
    display: flex; gap: 8px; flex-wrap: wrap;
    padding-top: 10px; border-top: 1px solid var(--border);
  }
  .wf-review-actions .btn { min-height: 36px; padding: 6px 12px; font-size: 0.88em; }
  .wf-history {
    margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--border);
  }
  .wf-history summary { font-size: 0.82em; cursor: pointer; padding: 4px 0; }
  .wf-history-entry {
    margin-top: 8px; padding: 8px 10px; background: var(--panel2);
    border-radius: 6px; font-size: 0.84em; opacity: 0.85;
  }
  .wf-history-body { margin-top: 4px; color: var(--text2); }
  .wf-briefs-wrap { margin-top: 12px; }
  .wf-briefs-wrap summary { font-size: 0.82em; }

  /* Phase-6 blueprint viewer */
  .wf-bp-tree { margin-bottom: 16px; }
  .wf-bp-meta { font-size: 0.78em; padding: 4px 0 10px; border-bottom: 1px solid var(--border); margin-bottom: 10px; }
  .wf-bp-meta a { color: var(--accent); }
  .wf-bp-group { margin-bottom: 12px; }
  .wf-bp-group-head { font-size: 0.74em; text-transform: uppercase; letter-spacing: 0.6px; color: var(--muted); margin-bottom: 4px; }
  .wf-bp-file {
    display: flex; justify-content: space-between; align-items: center;
    width: 100%; text-align: left; font: inherit; font-size: 0.88em;
    padding: 8px 10px; margin-bottom: 2px; border-radius: 6px;
    background: var(--panel2); border: 1px solid var(--border); color: var(--text);
    cursor: pointer;
  }
  .wf-bp-file:hover { background: var(--panel3); }
  .wf-bp-file.active { border-color: var(--accent); background: rgba(126,176,255,0.08); }
  .wf-bp-size { font-size: 0.78em; }
  .wf-bp-viewer {
    padding: 14px; background: var(--panel); border: 1px solid var(--border);
    border-radius: 10px; margin-top: 4px;
  }
  .wf-bp-filepath {
    font-family: ui-monospace, SFMono-Regular, monospace;
    font-size: 0.78em; color: var(--muted); margin-bottom: 10px;
    padding-bottom: 6px; border-bottom: 1px solid var(--border);
  }
  .wf-bp-content { font-size: 0.92em; line-height: 1.6; }
  .wf-bp-content p { margin: 0 0 10px; }
  .wf-bp-content h2, .wf-bp-content h3 { margin: 14px 0 6px; }

  /* Phase-7 chapter-plan cards */
  .wf-ch-card { padding: 14px; }
  .wf-ch-meta { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0 12px; }
  .wf-ch-chip {
    font-size: 0.74em; padding: 3px 10px; border-radius: 12px;
    background: var(--panel2); color: var(--text2); border: 1px solid var(--border);
    white-space: nowrap;
  }
  .wf-ch-chip.reg-tension     { background: rgba(240,120,120,0.12); color: #f0b0b0; border-color: rgba(240,120,120,0.3); }
  .wf-ch-chip.reg-quiet       { background: rgba(126,176,255,0.10); color: #bcd2ff; border-color: rgba(126,176,255,0.25); }
  .wf-ch-chip.reg-political   { background: rgba(196,164,255,0.12); color: #d8c0ff; border-color: rgba(196,164,255,0.28); }
  .wf-ch-chip.reg-discovery   { background: rgba(109,208,130,0.12); color: #b5e8c2; border-color: rgba(109,208,130,0.28); }
  .wf-ch-chip.reg-emotional   { background: rgba(240,192,104,0.12); color: #f0d28f; border-color: rgba(240,192,104,0.28); }
  .wf-ch-chip.reg-action      { background: rgba(255,140,80,0.12); color: #ffb78a; border-color: rgba(255,140,80,0.28); }
  .wf-ch-block { margin-top: 10px; }
  .wf-ch-h {
    font-size: 0.72em; letter-spacing: 0.6px; text-transform: uppercase;
    color: var(--muted); margin-bottom: 4px;
  }
  .wf-ch-list {
    margin: 0 0 4px; padding-left: 20px; font-size: 0.9em; line-height: 1.5;
  }
  .wf-ch-list li { margin: 2px 0; }
  .wf-ch-minor {
    font-size: 0.84em; color: var(--text2); margin-top: 8px;
    padding: 6px 10px; background: var(--panel2);
    border-radius: 6px;
  }

  /* Phase-8 chapter-draft cards */
  .wf-draft-card { padding: 14px; }
  .wf-draft-meta { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0 12px; }
  .wf-gate-chip {
    font-size: 0.76em; padding: 3px 10px; border-radius: 12px;
    border: 1px solid var(--border); background: var(--panel2);
  }
  .wf-gate-chip.ok {
    background: rgba(109,208,130,0.10); color: #b5e8c2;
    border-color: rgba(109,208,130,0.25);
  }
  .wf-gate-chip.fail {
    background: rgba(240,120,120,0.10); color: #f0b0b0;
    border-color: rgba(240,120,120,0.25);
  }
  .wf-draft-prose { margin: 10px 0; padding: 10px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
  .wf-draft-prose summary { cursor: pointer; font-size: 0.82em; padding: 4px 0; }
  .wf-draft-body {
    margin-top: 12px; font: 16px/1.7 Georgia, ui-serif, Cambria, serif;
    color: var(--text2); max-height: 600px; overflow-y: auto;
    padding: 4px 8px;
  }
  .wf-draft-body p {
    margin: 0 0 1em;
    text-indent: 1.4em;
  }
  .wf-draft-body p:first-child { text-indent: 0; }

  /* Red-team flags (Phase 10 + Phase 11 shared styling) */
  .wf-redteam {
    padding: 10px 12px; margin: 10px 0;
    background: rgba(240,192,104,0.10);
    border: 1px solid rgba(240,192,104,0.28);
    border-radius: 8px; color: var(--warn);
    font-size: 0.86em;
  }
  .wf-redteam ul { margin: 6px 0 0; padding-left: 20px; }
  .wf-redteam li { margin: 4px 0; color: var(--text2); }
  .wf-redteam-clean {
    background: rgba(109,208,130,0.08); color: var(--ok);
    border-color: rgba(109,208,130,0.22);
  }
  .wf-redteam-muted {
    background: var(--panel2); color: var(--muted);
    border-color: var(--border);
  }

  /* Phase-11 propagation patches */
  .wf-p11-section { margin-bottom: 18px; }
  .wf-p11-section-head {
    font-size: 0.72em; letter-spacing: 0.6px; text-transform: uppercase;
    color: var(--muted); padding-bottom: 6px; border-bottom: 1px solid var(--border);
    margin-bottom: 10px;
  }
  .wf-p11-card {
    padding: 12px 14px; background: var(--panel); border: 1px solid var(--border);
    border-radius: 10px; margin-bottom: 10px;
  }
  .wf-p11-card[data-status="applied"]  { border-color: var(--ok); }
  .wf-p11-card[data-status="rejected"] { opacity: 0.65; }
  .wf-p11-card[data-status="blocked_by_seal"] { border-color: var(--warn); }
  .wf-p11-plan {
    font-size: 0.85em; color: var(--text2);
    padding: 8px 10px; background: var(--panel2);
    border-left: 3px solid var(--accent); border-radius: 4px;
    margin: 8px 0;
  }

  /* Phase-10 publish + impact modal */
  .wf-p10-row {
    padding: 12px 14px; background: var(--panel); border: 1px solid var(--border);
    border-radius: 10px; margin-bottom: 10px;
  }
  .wf-p10-row-head {
    display: flex; justify-content: space-between; align-items: center; gap: 10px;
  }
  .wf-p10-row-title { font-weight: 600; font-size: 0.95em; }

  .wf-modal-overlay {
    position: fixed; inset: 0; z-index: 600;
    background: rgba(6,7,12,0.76);
    display: flex; align-items: flex-start; justify-content: center;
    padding: 30px 14px 14px; overflow-y: auto;
  }
  .wf-modal {
    width: 100%; max-width: 720px;
    background: var(--panel); border: 1px solid var(--border);
    border-radius: 14px; padding: 16px;
  }
  .wf-modal-head {
    display: flex; justify-content: space-between; align-items: flex-start; gap: 10px;
    margin-bottom: 12px;
  }
  .wf-modal-title { font-weight: 700; font-size: 1.05em; }

  .wf-tiers { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }
  .wf-tier-chip {
    font-size: 0.78em; padding: 3px 10px; border-radius: 10px;
    background: var(--panel2); color: var(--text2); border: 1px solid var(--border);
  }
  .wf-tier-chip.crit { background: rgba(240,120,120,0.14); color: #f0b0b0; border-color: rgba(240,120,120,0.35); }
  .wf-tier-chip.high { background: rgba(240,150,120,0.12); color: #f0c090; border-color: rgba(240,150,120,0.30); }
  .wf-tier-chip.med  { background: rgba(240,192,104,0.12); color: #f0d28f; border-color: rgba(240,192,104,0.28); }
  .wf-tier-chip.low  { background: rgba(126,176,255,0.10); color: #bcd2ff; border-color: rgba(126,176,255,0.25); }

  .wf-edges-list { max-height: 320px; overflow-y: auto; padding-right: 4px; margin-bottom: 12px; }
  .wf-edge-row {
    display: flex; gap: 10px; align-items: flex-start;
    padding: 8px 0; border-bottom: 1px solid var(--border);
  }
  .wf-edge-row:last-child { border-bottom: 0; }
  .wf-edge-sev { flex-shrink: 0; width: 78px; }
  .wf-edge-body { flex: 1; min-width: 0; }
  .wf-edge-title { font-size: 0.9em; }
  .wf-edge-overlap { font-size: 0.76em; color: var(--muted); margin-top: 3px; font-style: italic; }
  .wf-sev {
    display: inline-block; padding: 1px 7px; border-radius: 6px;
    font-size: 0.68em; font-weight: 700; letter-spacing: 0.6px;
  }
  .wf-sev.crit { background: rgba(240,120,120,0.18); color: #f0b0b0; }
  .wf-sev.high { background: rgba(240,150,120,0.16); color: #f0c090; }
  .wf-sev.med  { background: rgba(240,192,104,0.16); color: #f0d28f; }
  .wf-sev.low  { background: rgba(126,176,255,0.14); color: #bcd2ff; }

  .wf-modal-actions {
    display: flex; justify-content: flex-end; gap: 8px;
    padding-top: 10px; border-top: 1px solid var(--border);
  }

  /* Phase-9 reader, edit, diff */
  .wf-p9-row {
    padding: 12px 14px; background: var(--panel); border: 1px solid var(--border);
    border-radius: 10px; margin-bottom: 10px;
  }
  .wf-p9-row-head {
    display: flex; justify-content: space-between; align-items: center; gap: 10px;
  }
  .wf-p9-row-title { font-weight: 600; font-size: 0.95em; }

  .wf-p9-overlay {
    position: fixed; inset: 0; z-index: 500;
    background: var(--bg); overflow-y: auto;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .wf-p9-bar {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px; border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 2; background: var(--bg);
  }
  .wf-p9-bar-title { flex: 1; min-width: 0; }
  .wf-p9-bar-ch { font-weight: 700; font-size: 1em; }

  .wf-p9-history { margin: 10px 14px; }
  .wf-p9-hist-row { padding: 4px 0; font-size: 0.84em; }

  .wf-p9-reader {
    max-width: 720px; margin: 0 auto; padding: 20px 18px 80px;
    font: 17px/1.7 Georgia, ui-serif, Cambria, serif;
    color: var(--text2);
  }
  .wf-p9-reader p {
    margin: 0 0 1em;
    text-indent: 1.4em;
  }
  .wf-p9-reader p:first-child { text-indent: 0; }

  .wf-p9-textarea {
    display: block; width: calc(100% - 36px); max-width: 900px;
    margin: 16px auto 10px; padding: 14px;
    min-height: 65vh;
    background: var(--panel2); border: 1px solid var(--border);
    border-radius: 8px; color: var(--text);
    font: 15px/1.6 ui-monospace, SFMono-Regular, monospace;
    resize: vertical;
  }
  .wf-p9-edit-actions {
    display: flex; gap: 8px; max-width: 900px;
    margin: 0 auto 20px; padding: 0 18px;
  }

  .wf-p9-diff-head {
    max-width: 900px; margin: 14px auto 8px; padding: 0 18px;
    font-size: 0.9em;
  }
  .wf-p9-diff {
    max-width: 900px; margin: 0 auto 14px; padding: 12px 18px;
    background: var(--panel); border: 1px solid var(--border);
    border-radius: 8px; color: var(--text2);
    font: 13px/1.55 ui-monospace, SFMono-Regular, monospace;
    white-space: pre-wrap; word-wrap: break-word;
    overflow-x: auto; max-height: 60vh;
  }
  .wf-diff-head { color: var(--muted); font-weight: 700; }
  .wf-diff-hunk { color: #8abbff; }
  .wf-diff-add  { color: #b5e8c2; background: rgba(109,208,130,0.08); display: inline-block; width: 100%; }
  .wf-diff-del  { color: #f0b0b0; background: rgba(240,120,120,0.08); display: inline-block; width: 100%; }
  .wf-diff-ctx  { color: var(--muted); }

  /* Pacing warnings */
  .wf-warnings {
    padding: 10px 12px; margin-bottom: 12px;
    background: rgba(240,192,104,0.10);
    border: 1px solid rgba(240,192,104,0.28);
    border-radius: 8px; color: var(--warn);
    font-size: 0.88em;
  }
  .wf-warnings ul { margin: 6px 0 0; padding-left: 20px; }
  .wf-warnings li { margin: 2px 0; }

  /* Phase-2 brief rows */
  .wf-brief-row {
    padding: 6px 0; border-bottom: 1px solid var(--border);
  }
  .wf-brief-row:last-child { border-bottom: 0; }
  .wf-brief-q { font-size: 0.86em; color: var(--muted); margin-bottom: 2px; }
  .wf-brief-a { font-size: 0.92em; color: var(--text); }

/* ==== 07-chat.css ==== */
/* ============================================================
   Chat sidebar — design assistant.
   Desktop: fixed right rail, 400px.
   Mobile (<1024px): full-screen overlay.
   ============================================================ */

.chat-toggle {
  position: fixed;
  bottom: 84px;            /* sits above the bottom nav */
  right: 16px;
  width: 48px; height: 48px;
  border-radius: 50%;
  background: var(--accent, #7eb0ff);
  color: #0b0c10;
  border: none;
  font-size: 22px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.35);
  z-index: 90;
  transition: transform 0.15s ease;
}
.chat-toggle:hover { transform: translateY(-2px); }
.chat-toggle-icon { line-height: 1; }

.chat-sidebar {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 400px;
  max-width: 100vw;
  background: var(--panel, #161b22);
  border-left: 1px solid var(--border, #30363d);
  display: flex;
  flex-direction: column;
  z-index: 100;
  box-shadow: -4px 0 16px rgba(0,0,0,0.45);
  animation: chat-slide-in 0.18s ease-out;
}
@keyframes chat-slide-in {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}

@media (max-width: 1023px) {
  .chat-sidebar { width: 100vw; border-left: none; }
}

/* ---- Header ---- */
.chat-head {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border, #30363d);
  background: var(--panel-strong, #0d1117);
}
.chat-back {
  background: transparent; border: none;
  color: var(--muted, #8b949e);
  font-size: 22px; line-height: 1;
  cursor: pointer; padding: 0 6px;
}
.chat-back:hover { color: var(--text, #c9d1d9); }
.chat-session-select {
  flex: 1; min-width: 0;
  background: var(--panel, #161b22);
  color: var(--text, #c9d1d9);
  border: 1px solid var(--border, #30363d);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 13px;
}
.chat-new-btn {
  background: rgba(126,176,255,0.15);
  color: var(--accent, #7eb0ff);
  border: 1px solid rgba(126,176,255,0.30);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px; font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.chat-new-btn:hover { background: rgba(126,176,255,0.25); }

/* ---- Body / messages ---- */
.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  font-size: 14px;
  line-height: 1.5;
}
.chat-empty {
  color: var(--muted, #8b949e);
  text-align: center;
  font-size: 13px;
  padding: 32px 16px;
}
.chat-msg {
  margin-bottom: 14px;
  animation: chat-msg-in 0.16s ease-out;
}
@keyframes chat-msg-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.chat-msg-user .chat-msg-body {
  background: rgba(126,176,255,0.10);
  border: 1px solid rgba(126,176,255,0.22);
  border-radius: 10px;
  padding: 8px 12px;
  margin-left: 32px;
}
.chat-msg-assistant .chat-msg-body {
  background: transparent;
  padding: 4px 0;
  color: var(--text, #c9d1d9);
}
.chat-msg-error {
  color: var(--fail, #f08080);
  font-size: 13px;
  background: rgba(240,120,120,0.06);
  border: 1px solid rgba(240,120,120,0.25);
  border-radius: 6px;
  padding: 6px 10px;
}
.chat-msg-body p { margin: 0 0 8px; }
.chat-msg-body p:last-child { margin-bottom: 0; }
.chat-msg-body code {
  background: rgba(255,255,255,0.06);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 12.5px;
  font-family: ui-monospace, Consolas, monospace;
}
.chat-code {
  background: #0d1117;
  border: 1px solid var(--border, #30363d);
  border-radius: 6px;
  padding: 10px 12px;
  margin: 6px 0;
  overflow-x: auto;
  font-size: 12px;
  line-height: 1.45;
}
.chat-code code { background: transparent; padding: 0; }

/* ---- Rich rendering: headings, lists, tables, blockquotes ---- */
.chat-msg-body .chat-h {
  font-size: 14.5px;
  font-weight: 700;
  margin: 12px 0 6px;
  color: var(--text, #c9d1d9);
}
.chat-msg-body h1.chat-h { font-size: 17px; }
.chat-msg-body h2.chat-h { font-size: 15.5px; }
.chat-msg-body h3.chat-h { font-size: 14.5px; }
.chat-msg-body .chat-ul,
.chat-msg-body .chat-ol {
  margin: 6px 0 6px 22px;
  padding: 0;
}
.chat-msg-body .chat-ul li,
.chat-msg-body .chat-ol li { margin-bottom: 3px; }
.chat-msg-body .chat-quote {
  border-left: 3px solid rgba(126,176,255,0.35);
  margin: 8px 0;
  padding: 4px 12px;
  color: var(--muted, #8b949e);
  font-style: italic;
}
.chat-msg-body .chat-table {
  border-collapse: collapse;
  margin: 10px 0;
  font-size: 12.5px;
  width: 100%;
}
.chat-msg-body .chat-table th,
.chat-msg-body .chat-table td {
  border: 1px solid var(--border, #30363d);
  padding: 5px 8px;
  text-align: left;
}
.chat-msg-body .chat-table th { background: rgba(255,255,255,0.04); font-weight: 600; }
.chat-msg-body .chat-link { color: var(--accent, #7eb0ff); text-decoration: underline; }
.chat-msg-body .chat-icode {
  background: rgba(255,255,255,0.06);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 12.5px;
  font-family: ui-monospace, Consolas, monospace;
}
.chat-code-lang {
  font-size: 10.5px;
  color: var(--muted, #8b949e);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
  margin-bottom: 4px;
}

/* ---- Thinking blocks ---- */
.chat-thinking-block {
  margin: 6px 0 10px;
  background: rgba(126,176,255,0.04);
  border: 1px solid rgba(126,176,255,0.15);
  border-radius: 6px;
}
.chat-thinking-block summary {
  padding: 6px 10px;
  cursor: pointer;
  font-size: 12px;
  color: var(--muted, #8b949e);
  font-weight: 600;
  letter-spacing: 0.02em;
  user-select: none;
}
.chat-thinking-block summary:hover { color: var(--accent, #7eb0ff); }
.chat-thinking-block[open] summary { border-bottom: 1px solid rgba(126,176,255,0.15); }
.chat-thinking-block .chat-thinking-body {
  padding: 8px 12px;
  font-size: 12.5px;
  color: var(--muted, #8b949e);
  line-height: 1.55;
  font-style: italic;
}
.chat-think-icon { margin-right: 4px; opacity: 0.7; }

/* ---- Tool blocks (Claude-Code-style expandable) ---- */
.chat-tool-block {
  margin: 6px 0;
  border: 1px solid var(--border, #30363d);
  border-radius: 6px;
  background: var(--panel, #161b22);
}
.chat-tool-block summary {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px;
  cursor: pointer;
  user-select: none;
  font-size: 12.5px;
  list-style: none;
}
.chat-tool-block summary::-webkit-details-marker { display: none; }
.chat-tool-block summary::before {
  content: '▸';
  color: var(--muted, #8b949e);
  font-size: 9px;
  flex-shrink: 0;
}
.chat-tool-block[open] summary::before { content: '▾'; }
.chat-tool-name {
  font-weight: 700;
  color: #d2b0ff;
  font-family: ui-monospace, Consolas, monospace;
}
.chat-tool-summary {
  flex: 1; min-width: 0;
  color: var(--muted, #8b949e);
  font-family: ui-monospace, Consolas, monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-tool-status {
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 700;
}
.chat-tool-status-pending { color: var(--muted, #8b949e); }
.chat-tool-status-ok      { color: #7ecd90; }
.chat-tool-status-err     { color: #f08080; }
.chat-tool-block-err { border-color: rgba(240,120,120,0.30); }
.chat-tool-body {
  padding: 8px 10px;
  border-top: 1px solid var(--border, #30363d);
  font-size: 11.5px;
}
.chat-tool-input,
.chat-tool-result {
  background: #0d1117;
  border: 1px solid var(--border, #30363d);
  border-radius: 4px;
  padding: 8px;
  margin: 4px 0;
  overflow-x: auto;
  max-height: 320px;
  overflow-y: auto;
  font-size: 11px;
  line-height: 1.45;
  white-space: pre;
}
.chat-tool-input code,
.chat-tool-result code { color: var(--text, #c9d1d9); }
.chat-tool-running {
  color: var(--muted, #8b949e);
  font-style: italic;
  padding: 6px 0;
}
.chat-tool-trunc {
  font-size: 10.5px;
  color: var(--muted, #8b949e);
  margin-top: 4px;
  font-style: italic;
}

/* ---- Cost / tokens footer per assistant turn ---- */
.chat-cost-footer {
  font-size: 10.5px;
  color: var(--muted, #8b949e);
  margin-top: 6px;
  letter-spacing: 0.02em;
  font-family: ui-monospace, Consolas, monospace;
}

/* ---- Thinking indicator ---- */
.chat-thinking {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 14px;
  color: var(--muted, #8b949e);
  font-size: 12px;
  border-top: 1px solid var(--border, #30363d);
}

/* ---- Footer / input ---- */
.chat-foot {
  border-top: 1px solid var(--border, #30363d);
  padding: 10px 12px;
  display: flex; flex-direction: column; gap: 8px;
  background: var(--panel-strong, #0d1117);
}
.chat-foot textarea {
  width: 100%;
  background: var(--panel, #161b22);
  color: var(--text, #c9d1d9);
  border: 1px solid var(--border, #30363d);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  /* Height is JS-managed via wbAutoGrow; no manual resize handle to avoid
     fighting the auto-grow. The textarea grows from ~3 lines to ~14, then
     scrolls internally past the cap. */
  resize: none;
  min-height: 72px;
  line-height: 1.45;
  font-family: inherit;
  overflow-y: hidden;
}
.chat-foot textarea:focus {
  outline: none;
  border-color: var(--accent, #7eb0ff);
}
.chat-foot textarea.chat-input-slashy {
  border-color: #d2b0ff;
  box-shadow: 0 0 0 2px rgba(210,176,255,0.18);
  background: rgba(210,176,255,0.04);
  font-family: ui-monospace, Consolas, monospace;
}

/* Slash command hint dropdown — appears above the textarea while in slash mode. */
.chat-slash-hint {
  background: var(--panel, #161b22);
  border: 1px solid rgba(210,176,255,0.30);
  border-radius: 8px;
  margin-bottom: 6px;
  overflow: hidden;
  box-shadow: 0 4px 10px rgba(0,0,0,0.30);
}
.chat-slash-row {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px;
  cursor: pointer;
  font-size: 12.5px;
  border-left: 3px solid transparent;
}
.chat-slash-row:hover,
.chat-slash-row.active {
  background: rgba(210,176,255,0.10);
  border-left-color: #d2b0ff;
}
.chat-slash-row code {
  color: #d2b0ff;
  font-weight: 700;
  background: transparent;
  padding: 0;
  font-family: ui-monospace, Consolas, monospace;
  flex-shrink: 0;
  min-width: 70px;
}
.chat-slash-hint-text {
  color: var(--muted, #8b949e);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-foot-row {
  display: flex; align-items: center; gap: 8px;
}
.chat-model-select {
  flex: 1;
  background: var(--panel, #161b22);
  color: var(--muted, #8b949e);
  border: 1px solid var(--border, #30363d);
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 12px;
}
.chat-send {
  min-width: 80px;
}

/* Insert-context button — pre-fills input with current view phrase. */
.chat-ctx-btn {
  background: rgba(126,176,255,0.10);
  color: var(--accent, #7eb0ff);
  border: 1px solid rgba(126,176,255,0.25);
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.chat-ctx-btn:hover { background: rgba(126,176,255,0.18); }

/* Clickable file refs inside chat markdown — paths in inline code. */
.chat-file-ref {
  cursor: pointer;
  color: var(--accent, #7eb0ff);
  border-bottom: 1px dotted rgba(126,176,255,0.4);
}
.chat-file-ref:hover {
  background: rgba(126,176,255,0.15);
  border-bottom-style: solid;
}

