:root{
  --bg:#f4f6f9; --card:#fff; --ink:#1a2230; --muted:#6b7688; --line:#e4e8ee;
  --brand:#1f5fbf; --brand-dk:#1a53a8; --green:#1a9e5f; --amber:#d9a021; --red:#d24b4b;
  --shadow:0 1px 3px rgba(20,30,50,.06),0 1px 2px rgba(20,30,50,.04);
}
*{box-sizing:border-box}
html,body{margin:0}
body{font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;
  background:var(--bg);color:var(--ink);font-size:14px}

/* top bar */
.topbar{display:flex;align-items:center;justify-content:space-between;
  padding:12px 20px;background:var(--card);border-bottom:1px solid var(--line)}
.brand{font-weight:800;font-size:17px;letter-spacing:-.3px;display:flex;align-items:center;gap:8px}
.brand-sub{font-weight:500;font-size:11.5px;color:var(--muted);letter-spacing:0;margin-left:6px}
.logo{width:18px;height:18px;border-radius:5px;background:var(--brand);
  box-shadow:8px 8px 0 -3px rgba(31,95,191,.45);display:inline-block}
.top-right{display:flex;align-items:center;gap:10px}
.badge{font-size:11.5px;font-weight:700;color:var(--brand);background:#eef4fc;
  border-radius:20px;padding:4px 11px}
.badge.warn{color:#9a6b12;background:#fdf6e6}
.badge.alt{color:#6b4bbf;background:#f2eefc}

/* layout */
.layout{display:grid;grid-template-columns:320px 1fr;gap:0;align-items:start}
.side{border-right:1px solid var(--line);min-height:calc(100vh - 53px);
  background:var(--card);padding:16px}
.side-block{margin-bottom:22px}
.side-block h3{font-size:11px;text-transform:uppercase;letter-spacing:.6px;
  color:var(--muted);margin:0 0 10px}
.content{padding:24px 28px;max-width:1000px}

/* inputs / buttons */
.in{width:100%;border:1px solid var(--line);border-radius:9px;padding:9px 11px;
  font:inherit;color:var(--ink);background:#fbfcfe;margin-bottom:8px}
.in:focus{outline:none;border-color:var(--brand);background:#fff}
.ta{resize:vertical;line-height:1.45}
.row{display:flex;gap:8px}
.btn{font:inherit;cursor:pointer;border-radius:9px;padding:8px 14px;
  border:1px solid var(--line);background:#fff;color:var(--ink);font-weight:600}
.btn:hover:not(:disabled){border-color:#c9d2df}
.btn.small{padding:6px 11px;font-size:12.5px}
.btn.primary{background:var(--brand);color:#fff;border-color:var(--brand)}
.btn.primary:hover:not(:disabled){background:var(--brand-dk)}
.btn.ok{background:var(--green);color:#fff;border-color:var(--green)}
.btn.ok:hover:not(:disabled){filter:brightness(.95)}
.btn:disabled{opacity:.5;cursor:default}
.grow{flex:1}
.muted{color:var(--muted)}
.hidden{display:none !important}

/* project list */
.proj-list{list-style:none;margin:0;padding:0}
.proj-list li{padding:0}
.proj-item{display:flex;justify-content:space-between;align-items:center;gap:8px;
  width:100%;text-align:left;border:1px solid var(--line);background:#fafbfd;
  border-radius:9px;padding:9px 11px;margin-bottom:6px;cursor:pointer;font:inherit}
.proj-item:hover{border-color:var(--brand);background:#f2f7fd}
.proj-item.on{border-color:var(--brand);background:#eef4fc}
.proj-item .nm{font-weight:700}
.proj-item .pg{font-size:11px;color:var(--muted);white-space:nowrap}

/* stage nav */
.stage-nav{list-style:none;margin:0;padding:0;counter-reset:st}
.stage-nav li{display:flex;align-items:center;gap:9px;padding:8px 10px;border-radius:9px;
  margin-bottom:4px;cursor:pointer;border:1px solid transparent}
.stage-nav li:hover:not(.locked){background:#f2f7fd}
.stage-nav li.on{background:#eef4fc;border-color:#cfe0f6}
.stage-nav li.locked{opacity:.5;cursor:not-allowed}
.stage-nav .sn-num{width:22px;height:22px;border-radius:50%;flex:none;display:grid;
  place-items:center;font-size:11.5px;font-weight:700;background:#e7ecf3;color:var(--muted)}
.stage-nav li.approved .sn-num{background:var(--green);color:#fff}
.stage-nav li.draft .sn-num{background:var(--amber);color:#fff}
.stage-nav .sn-t{font-size:12.5px;line-height:1.25}

/* stage view */
.empty-state{color:var(--muted);max-width:560px}
.empty-state h2{color:var(--ink);margin:8px 0}
.stage-head{display:flex;justify-content:space-between;align-items:flex-start;gap:16px;
  flex-wrap:wrap;margin-bottom:14px}
.stage-eyebrow{font-size:11.5px;font-weight:700;text-transform:uppercase;
  letter-spacing:.5px;color:var(--muted)}
.stage-head h2{margin:3px 0 0;font-size:24px;letter-spacing:-.4px}
.stage-actions{display:flex;gap:8px;flex-wrap:wrap}
.questions{background:#f2f6fc;border:1px solid #d9e6f8;border-radius:11px;
  padding:12px 15px;margin-bottom:16px}
.q-h{font-weight:700;font-size:12.5px;margin-bottom:6px}
.questions ul{margin:0;padding-left:18px}
.questions li{margin:3px 0;color:#3a4658}
.source{font-size:11.5px;color:var(--muted);margin-bottom:10px}
.stale{background:#fdf6e6;border:1px solid #f0e0b8;color:#9a6b12;border-radius:10px;
  padding:9px 13px;margin-bottom:12px;font-size:12.5px;font-weight:600}

/* the interview */
.chat{display:flex;flex-direction:column;gap:10px;margin-bottom:18px}
.turn{background:var(--card);border:1px solid var(--line);border-radius:12px;padding:14px 16px}
.turn.done{background:#fbfcfe;padding:11px 14px}
.turn.live{box-shadow:var(--shadow);border-color:#cfe0f6}
.turn.editing{border-color:var(--amber);background:#fffdf7}
.turn-q{font-weight:700;line-height:1.45;display:flex;gap:7px;align-items:baseline}
.turn-why{color:var(--muted);font-size:12.5px;margin-top:4px;line-height:1.45}
.turn-hint{color:var(--muted);font-size:11.5px;margin-top:8px}
.turn-a{color:#3a4658;line-height:1.45;margin:5px 0 8px}
.turn .tag{flex:none;font-size:10px;font-weight:800;text-transform:uppercase;letter-spacing:.5px;
  color:var(--brand);background:#eef4fc;border-radius:20px;padding:2px 8px}
.btn.ghost{border-color:transparent;background:none;color:var(--brand);padding:2px 0;
  font-size:12px;text-decoration:underline}
.btn.ghost:hover:not(:disabled){border-color:transparent;color:var(--brand-dk)}

.opts{display:flex;flex-wrap:wrap;gap:8px;margin:10px 0 4px}
.opt{display:flex;flex-direction:column;gap:2px;text-align:left;cursor:pointer;font:inherit;
  border:1px solid var(--line);background:#fbfcfe;border-radius:10px;padding:8px 12px;
  max-width:100%;flex:1 1 240px}
.opt:hover{border-color:var(--brand);background:#f2f7fd}
.opt.on{border-color:var(--brand);background:#eef4fc;box-shadow:inset 0 0 0 1px var(--brand)}
.opt-l{font-weight:600;line-height:1.35}
.opt-d{font-size:11.5px;color:var(--muted);line-height:1.35}

.own{width:100%;margin-top:9px;border:1px solid var(--line);border-radius:10px;padding:9px 11px;
  font:inherit;color:var(--ink);background:#fff;resize:vertical;line-height:1.45}
.own:focus{outline:none;border-color:var(--brand)}
.turn-bar{display:flex;align-items:center;gap:8px;margin-top:10px}
.warn-note{font-size:11.5px;color:#9a6b12}
.chat-end{color:var(--muted);font-size:12.5px;text-align:center;padding:2px 0}

/* AI is working — the model calls take seconds to a minute and stream nothing,
   so say what it is doing and count the seconds rather than spin in silence. */
@keyframes spin{to{transform:rotate(360deg)}}
.spinner{width:14px;height:14px;flex:none;display:inline-block;border-radius:50%;
  border:2px solid #d7e2f2;border-top-color:var(--brand);animation:spin .7s linear infinite}
.busy{display:flex;align-items:center;gap:9px;background:#f2f6fc;border:1px solid #d9e6f8;
  border-radius:11px;padding:10px 14px;margin-bottom:14px;font-weight:600;font-size:13px}
.busy-s{margin-left:auto;color:var(--muted);font-weight:600;font-variant-numeric:tabular-nums}

@keyframes pulse{0%,100%{opacity:1}50%{opacity:.45}}
.turn.pending{border-style:dashed}
.turn.pending .turn-q{color:var(--muted);font-weight:600}
.opt.skel{height:38px;background:#eef1f6;border-color:transparent;cursor:default;
  animation:pulse 1.3s ease-in-out infinite}
.opt.skel:nth-child(2){animation-delay:.15s}
.opt.skel:nth-child(3){animation-delay:.3s}
.opt.skel:nth-child(4){animation-delay:.45s}
.opt.skel:hover{border-color:transparent;background:#eef1f6}

/* the stage's critic */
.critique{border:1px solid var(--line);border-left:4px solid var(--muted);border-radius:12px;
  background:var(--card);padding:13px 16px;margin-bottom:14px}
.critique.pass{border-left-color:var(--green)}
.critique.revise{border-left-color:var(--amber)}
.critique.reject{border-left-color:var(--red)}
.critique.stale-c{background:#fbfcfe}
.cr-head{display:flex;align-items:baseline;gap:9px;flex-wrap:wrap}
.cr-verdict{font-size:10.5px;font-weight:800;letter-spacing:.7px;border-radius:20px;
  padding:2px 9px;background:#eef1f6;color:#41506a}
.critique.pass .cr-verdict{background:#e8f6ee;color:#13723f}
.critique.revise .cr-verdict{background:#fdf6e6;color:#9a6b12}
.critique.reject .cr-verdict{background:#fbecec;color:#a52f2f}
.cr-sum{font-weight:600;line-height:1.4}
.cr-who{font-size:11.5px;color:var(--muted);margin-top:4px}
.cr-stale{font-size:12px;color:#9a6b12;margin-top:8px;font-weight:600}
.cr-sub{font-size:11px;text-transform:uppercase;letter-spacing:.6px;color:var(--muted);
  margin:12px 0 4px}
.cr-none{color:var(--green);font-size:12.5px;margin-top:8px;font-weight:600}
.cr-list{list-style:none;margin:10px 0 0;padding:0}
.cr-list.plain{list-style:disc;padding-left:20px;color:#3a4658}
.cr-list.plain li{margin:3px 0;line-height:1.45}
.cr-f{border-top:1px solid var(--line);padding:9px 0}
.cr-f:first-child{border-top:none;padding-top:2px}
.cr-sev{display:inline-block;font-size:10px;font-weight:800;text-transform:uppercase;
  letter-spacing:.5px;border-radius:20px;padding:2px 7px;margin-right:7px;
  background:#eef1f6;color:#41506a}
.cr-f.high .cr-sev{background:#fbecec;color:#a52f2f}
.cr-f.medium .cr-sev{background:#fdf6e6;color:#9a6b12}
.cr-d{color:#3a4658;line-height:1.45;margin-top:4px}
.cr-fix{display:flex;align-items:flex-start;gap:10px;margin-top:6px}
.cr-fix-t{color:var(--brand);line-height:1.45;font-size:13px;flex:1}
.cr-fix .btn{flex:none}
.cr-applied{flex:none;font-size:11.5px;font-weight:700;color:var(--green);white-space:nowrap}
.cr-f.done{opacity:.6}
.cr-f.done b{text-decoration:line-through;text-decoration-color:var(--muted)}

/* markdown render */
.md{background:var(--card);border:1px solid var(--line);border-radius:12px;
  padding:20px 24px;box-shadow:var(--shadow);min-height:120px}
.md:empty::before{content:"No document yet — answer the interview, then compose it.";color:var(--muted)}
.md h1,.md h2,.md h3{letter-spacing:-.2px;margin:18px 0 8px}
.md h1{font-size:22px} .md h2{font-size:18px} .md h3{font-size:15px}
.md h2:first-child,.md h1:first-child{margin-top:0}
.md p,.md li{line-height:1.55}
.md table{width:100%;border-collapse:collapse;font-size:13px;margin:10px 0}
.md th,.md td{border:1px solid var(--line);padding:7px 9px;text-align:left;vertical-align:top}
.md th{background:#f6f8fb;color:#41506a;font-weight:700}
.md code{background:#f1f4f8;border-radius:5px;padding:1px 5px;font-size:12.5px}
.md pre{background:#f6f8fb;border:1px solid var(--line);border-radius:9px;
  padding:12px;overflow:auto}
.md pre code{background:none;padding:0}
.md .mermaid{background:#fbfcfe;border:1px solid var(--line);border-radius:10px;
  padding:14px;margin:12px 0;text-align:center;overflow:auto}
.md blockquote{border-left:3px solid var(--brand);margin:10px 0;padding:2px 14px;
  color:var(--muted);background:#f7faff}

/* editor */
.editor{width:100%;min-height:420px;border:1px solid var(--line);border-radius:12px;
  padding:16px;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;
  font-size:13px;line-height:1.5;color:var(--ink);background:#fff;resize:vertical}
.editbar{display:flex;align-items:center;gap:8px;margin-top:10px}

/* toast */
.toast{position:fixed;bottom:20px;left:50%;transform:translateX(-50%);
  background:#1a2230;color:#fff;padding:10px 16px;border-radius:9px;
  box-shadow:0 8px 24px -8px rgba(0,0,0,.4);font-size:13px;z-index:50}
.toast.err{background:var(--red)}

@media (max-width:820px){
  .layout{grid-template-columns:1fr}
  .side{min-height:auto;border-right:none;border-bottom:1px solid var(--line)}
}
