:root {
  --bg: #0a0b0f;
  --bg-2: #101219;
  --panel: #14161f;
  --panel-2: #1a1d28;
  --line: #262a38;
  --line-2: #333849;
  --text: #e7e9f0;
  --text-2: #d4d7e2;
  --dim: #9aa0b4;
  --dim-2: #666c82;
  --accent: #6ea8fe;
  --accent-2: #8b7dff;
  --good: #4ade80;
  --warn: #fbbf24;
  --hot: #fb7185;
  --on-accent: #0a0b0f;
  --warn-line: rgb(92,74,42);          /* opaque: translucent 1px borders trip a Chrome paint bug */
  --scrim: rgba(6,7,12,0.88);
  --scrim-2: rgba(5,6,10,0.7);
  --mono: "SF Mono", "JetBrains Mono", "Fira Code", ui-monospace, Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, system-ui, sans-serif;
}

/* light palette — JS stamps data-theme (auto follows the system) */
:root[data-theme="light"] {
  --bg: #f4f5f9;
  --bg-2: #eceef5;
  --panel: #ffffff;
  --panel-2: #f0f2f8;
  --line: #d8dce7;
  --line-2: #c2c8d7;
  --text: #191c26;
  --text-2: #2b303f;
  --dim: #596174;
  --dim-2: #8a92a6;
  --accent: #2e6ee8;
  --accent-2: #6d5ce0;
  --good: #158a43;
  --warn: #a3670a;
  --hot: #d43d56;
  --on-accent: #ffffff;
  --warn-line: rgb(224,196,142);
  --scrim: rgba(238,240,247,0.9);
  --scrim-2: rgba(233,236,244,0.78);
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

body {
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(110,168,254,0.07), transparent 60%),
    radial-gradient(900px 500px at 0% 110%, rgba(139,125,255,0.06), transparent 60%),
    var(--bg);
}

button { font-family: inherit; cursor: pointer; }
kbd {
  font-family: var(--mono);
  font-size: 11px;
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 1px 6px;
  color: var(--dim);
  min-width: 18px;
  display: inline-block;
  text-align: center;
}

/* ---------- Splash ---------- */
#splash {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 26px; z-index: 40;
  transition: opacity .35s ease;
}
#splash.hide { opacity: 0; pointer-events: none; }
.brand {
  font-family: var(--mono);
  font-weight: 600;
  letter-spacing: -0.5px;
  display: flex; align-items: center; gap: 12px;
}
.brand .logo {
  width: 34px; height: 34px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 40px rgba(110,168,254,0.4);
}
.brand h1 { font-size: 30px; font-weight: 700; }
.brand .tag { color: var(--dim); font-size: 13px; font-family: var(--sans); font-weight: 400; }
#splash .sub { color: var(--dim); max-width: 460px; text-align: center; line-height: 1.55; font-size: 14px; }
.idea-box {
  width: min(640px, 90vw);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 8px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  transition: border-color .2s;
}
.idea-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(110,168,254,0.12), 0 20px 60px rgba(0,0,0,0.5); }
#ideaInput {
  width: 100%; min-height: 84px; resize: none;
  background: transparent; border: none; outline: none;
  color: var(--text); font-size: 16px; line-height: 1.5;
  padding: 12px; font-family: var(--sans);
}
.idea-row { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px 4px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip-seed {
  font-size: 12px; color: var(--dim);
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 20px; padding: 4px 11px; transition: all .15s;
}
.chip-seed:hover { color: var(--text); border-color: var(--accent); }
.btn-go {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--on-accent); font-weight: 700; border: none;
  border-radius: 9px; padding: 10px 18px; font-size: 14px;
  display: flex; align-items: center; gap: 8px;
  transition: transform .1s, box-shadow .2s;
}
.btn-go:hover { transform: translateY(-1px); box-shadow: 0 8px 24px rgba(110,168,254,0.35); }
.btn-go:disabled { opacity: .5; transform: none; cursor: default; }
/* library of previous explorations */
#library { width: min(680px, 100%); margin-top: 26px; }
.lib-title { font-size: 11px; font-family: var(--mono); text-transform: uppercase; letter-spacing: .8px; color: var(--dim-2); margin-bottom: 8px; }
.lib-row {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px; margin: 6px 0;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; cursor: pointer;
  transition: border-color .12s, background .12s;
}
.lib-row:hover { border-color: var(--accent); background: var(--panel-2); }
.lib-txt { flex: 1; min-width: 0; }
.lib-idea { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lib-meta { font-size: 11.5px; color: var(--dim); font-family: var(--mono); margin-top: 2px; }
.lib-del { background: none; border: none; color: var(--dim-2); font-size: 13px; padding: 4px 7px; border-radius: 6px; }
.lib-del:hover { color: var(--hot); background: var(--panel-2); }

.btn-reverse {
  background: none; color: var(--warn); font-weight: 600;
  border: 1px solid rgba(251,191,36,0.35); border-radius: 9px;
  padding: 10px 14px; font-size: 13px; transition: border-color .15s;
}
.btn-reverse:hover { border-color: var(--warn); }

/* ---------- App shell ---------- */
#app { display: none; height: 100%; grid-template-columns: 300px 1fr 360px; grid-template-rows: 52px 1fr; }
#app.show { display: grid; }
body.ld-collapsed #app { grid-template-columns: 300px 1fr 36px; }

header {
  grid-column: 1 / 4;
  display: flex; align-items: center; gap: 16px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  background: var(--scrim-2);
  backdrop-filter: blur(10px);
}
header .brand-mini { font-family: var(--mono); font-weight: 700; font-size: 15px; display: flex; gap: 9px; align-items: center; }
header .brand-mini .logo { width: 20px; height: 20px; border-radius: 6px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
header .idea-txt { color: var(--dim); font-size: 13px; max-width: 40vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
header .spacer { flex: 1; }
.global-cov { display: flex; align-items: center; gap: 9px; font-size: 12px; color: var(--dim); }
.global-cov .bar { width: 120px; }
.hbtn {
  background: var(--panel-2); border: 1px solid var(--line-2); color: var(--text);
  border-radius: 8px; padding: 6px 12px; font-size: 13px; display: flex; align-items: center; gap: 7px;
  transition: all .15s;
}
.hbtn:hover { border-color: var(--accent); }
.hbtn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: var(--on-accent); font-weight: 700; border: none; }

/* ---------- Sidebar / map ---------- */
#sidebar {
  border-right: 1px solid var(--line);
  background: var(--bg-2);
  overflow-y: auto;
  padding: 12px 8px 40px;
}
.side-title { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--dim-2); padding: 6px 8px 10px; display: flex; justify-content: space-between; }
.map-node {
  border-radius: 8px; padding: 7px 9px; margin: 1px 0; cursor: pointer;
  border: 1px solid transparent; position: relative;
  transition: background .12s;
}
.map-node:hover { background: var(--panel); }
.map-node.current { background: var(--panel-2); border-color: var(--line-2); }
.map-node.current::before {
  content: ""; position: absolute; left: -8px; top: 8px; bottom: 8px; width: 3px;
  background: linear-gradient(var(--accent), var(--accent-2)); border-radius: 3px;
}
.map-node .mn-q { font-size: 12.5px; line-height: 1.35; color: var(--text); }
.map-node.open .mn-q { color: var(--dim); }
.map-node .mn-chosen { font-size: 11px; color: var(--accent); margin-top: 3px; display: flex; gap: 5px; align-items: center; }
.map-node .mn-chosen::before { content: "→"; color: var(--dim-2); }
.map-branch-label {
  font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--dim-2); padding: 12px 8px 4px; display: flex; align-items: center; gap: 8px;
}
.map-branch-label .bar { flex: 1; }

/* ---------- Main / node ---------- */
#main { position: relative; overflow-y: auto; padding: 34px 40px 120px; }
.breadcrumb { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; color: var(--dim-2); font-size: 12px; margin-bottom: 22px; font-family: var(--mono); }
.breadcrumb .bc { color: var(--dim); }
.breadcrumb .sep { color: var(--line-2); }
.breadcrumb .bc.branch { color: var(--accent-2); }

.node-card { max-width: 760px; }
.node-meta { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.branch-tag {
  font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--accent-2); background: rgba(139,125,255,0.1); border: 1px solid rgba(139,125,255,0.25);
  padding: 3px 9px; border-radius: 20px;
}
.speed-badge {
  font-family: var(--mono); font-size: 11px; padding: 3px 9px; border-radius: 20px;
  display: flex; align-items: center; gap: 5px; border: 1px solid var(--line-2); color: var(--dim);
  transition: opacity .3s;
}
.speed-badge.instant { color: var(--good); border-color: rgba(74,222,128,0.3); background: rgba(74,222,128,0.07); }

/* replay-review verdicts */
.verdict-chip {
  font-family: var(--mono); font-size: 11px; padding: 3px 9px; border-radius: 20px;
  border: 1px solid var(--line-2); text-transform: lowercase;
}
.verdict-chip.v-sound { color: var(--good); border-color: rgba(74,222,128,0.35); background: rgba(74,222,128,0.08); }
.verdict-chip.v-weak { color: var(--warn); border-color: rgba(251,191,36,0.35); background: rgba(251,191,36,0.08); }
.verdict-chip.v-risky { color: var(--hot); border-color: rgba(251,113,133,0.4); background: rgba(251,113,133,0.1); }
.verdict-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-left: 7px; vertical-align: middle; }
.verdict-dot.v-sound { background: var(--good); }
.verdict-dot.v-weak { background: var(--warn); box-shadow: 0 0 6px rgba(251,191,36,0.5); }
.verdict-dot.v-risky { background: var(--hot); box-shadow: 0 0 6px rgba(251,113,133,0.6); }
.review {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 12px;
  max-width: 760px; margin: -8px 0 22px; padding: 12px 14px; border-radius: 10px;
  background: var(--panel); border: 1px solid var(--line); border-left-width: 3px;
  animation: pop .3s backwards;
}
.review.v-sound { border-left-color: var(--good); }
.review.v-weak { border-left-color: var(--warn); }
.review.v-risky { border-left-color: var(--hot); }
.review .rv-tag { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .5px; }
.review.v-sound .rv-tag { color: var(--good); }
.review.v-weak .rv-tag { color: var(--warn); }
.review.v-risky .rv-tag { color: var(--hot); }
.review .rv-note { color: var(--text); font-size: 13.5px; flex: 1 1 300px; line-height: 1.45; }
.review .rv-better { font-size: 12.5px; color: var(--accent); font-family: var(--mono); }

/* external reviewer annotations & proposed branches */
.review .rv-author {
  font-family: var(--mono); font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .6px; color: var(--accent-2); background: rgba(139,125,255,0.12);
  border-radius: 5px; padding: 2px 7px;
}
.altbranch {
  max-width: 760px; margin: -8px 0 22px; border: 1px dashed var(--warn-line);
  border-radius: 10px; background: rgba(240,180,90,0.05); animation: pop .3s backwards;
}
.alt-head { display: flex; align-items: center; gap: 10px; padding: 11px 14px; cursor: pointer; }
.alt-head .alt-label { font-size: 13.5px; color: var(--text); flex: 1; }
.alt-head .alt-expand { font-size: 11.5px; color: var(--warn); font-family: var(--mono); white-space: nowrap; }
.alt-chain { border-top: 1px dashed var(--warn-line); padding: 10px 14px 12px 26px; }
.alt-step { margin: 8px 0; }
.alt-step .alt-q { font-size: 12.5px; color: var(--dim); }
.alt-step .alt-take { font-size: 13px; font-weight: 600; margin-top: 1px; }
.alt-step .alt-why { font-size: 12px; color: var(--dim); margin-top: 1px; font-style: italic; }

.map-ghost {
  margin: 1px 0 1px 14px; padding: 5px 9px; font-size: 12px; color: var(--warn);
  border-left: 2px dashed var(--warn-line); cursor: pointer; border-radius: 0 8px 8px 0;
}
.map-ghost:hover { background: var(--panel); }

.layers { margin: 2px 0 12px; padding: 8px 9px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
.layers-title { font-size: 10.5px; font-family: var(--mono); text-transform: uppercase; letter-spacing: .8px; color: var(--dim-2); margin-bottom: 6px; }
.layer-row { display: flex; align-items: center; gap: 8px; padding: 3px 0; font-size: 12.5px; color: var(--text); cursor: pointer; }
.layer-row input { accent-color: var(--accent); }
.layer-txt { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.layer-live { font-size: 10px; color: var(--good); font-family: var(--mono); animation: blink 1.4s infinite; }

.question { font-size: 27px; font-weight: 650; line-height: 1.28; letter-spacing: -0.4px; margin-bottom: 6px; }
.q-hint { color: var(--dim); font-size: 13px; margin-bottom: 24px; }

/* cross-branch constraint chips pinned by the compiler */
.constraints { display: flex; flex-direction: column; gap: 6px; max-width: 760px; margin: -12px 0 20px; }
.cchip {
  display: flex; align-items: baseline; gap: 10px; font-size: 13px; line-height: 1.45;
  color: var(--text); background: rgba(240,180,90,0.07); border: 1px solid var(--warn-line);
  border-radius: 9px; padding: 8px 12px; animation: pop .3s backwards;
}
.cchip .ctag { flex: none; font-family: var(--mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--warn); }

.options { display: flex; flex-direction: column; gap: 10px; margin-bottom: 26px; }
.option {
  position: relative;
  display: flex; gap: 14px; align-items: flex-start;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 15px 16px; cursor: pointer;
  transition: transform .08s, border-color .12s, background .12s;
  animation: pop .28s cubic-bezier(.2,.7,.3,1) backwards;
}
/* peek: ghost of the prefetched next node, shown on hover */
.peek {
  position: absolute; top: calc(100% + 6px); left: 38px; right: 8px; z-index: 6;
  background: var(--bg-2); border: 1px dashed var(--line-2);
  border-radius: 10px; padding: 10px 14px; pointer-events: none;
  box-shadow: 0 14px 34px rgba(0,0,0,0.55); animation: pop .16s backwards;
}
.peek .pk-tag { font-family: var(--mono); font-size: 10px; color: var(--good); text-transform: uppercase; letter-spacing: .5px; }
.peek .pk-q { font-size: 13.5px; font-weight: 600; margin: 5px 0 7px; line-height: 1.35; }
.peek .pk-opt { font-size: 12px; color: var(--dim); margin: 2px 0; }
.option:hover { border-color: var(--line-2); background: var(--panel-2); }
.option.sel { border-color: var(--accent); background: rgba(110,168,254,0.06); transform: translateX(3px); }
.option .num {
  flex: none; width: 26px; height: 26px; border-radius: 7px;
  background: var(--panel-2); border: 1px solid var(--line-2);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 13px; font-weight: 700; color: var(--dim);
  transition: all .12s;
}
.option:hover .num, .option.sel .num { color: var(--accent); border-color: var(--accent); }

/* autopilot: countdown fill on the option about to self-accept */
.option.auto-counting { position: relative; overflow: hidden; border-color: var(--accent); }
.option.auto-counting::after {
  content: ""; position: absolute; left: 0; bottom: 0; height: 2px; width: 100%;
  background: var(--accent); transform-origin: left; transform: scaleX(0);
  animation: autofill 1.4s linear forwards;
}
@keyframes autofill { to { transform: scaleX(1); } }
.nav-pick { display: inline-flex; align-items: center; gap: 3px; }
.nav-opt {
  background: none; border: 1px solid var(--line-2); color: var(--dim);
  font-size: 11px; font-family: var(--mono); padding: 2px 8px; border-radius: 12px; cursor: pointer;
}
.nav-opt:hover { color: var(--text); }
.nav-opt.active { color: var(--accent); border-color: var(--accent); }

#autoBadge { display: none; }
body.autopilot #autoBadge { display: inline-flex; animation: blink 1.4s infinite; }
.option .otxt { flex: 1; }
.option .olabel { font-weight: 600; font-size: 15.5px; line-height: 1.35; }
.option .otrade { color: var(--dim); font-size: 13.5px; line-height: 1.45; margin-top: 4px; }
/* opaque border (rgba(139,125,255,.45) pre-blended over the panel) — Chrome
   renders 1px translucent borders on these rows as thick mitred bands */
.option.rec { border-color: rgb(74,68,132); }
.option.rec .num { color: var(--accent-2); border-color: var(--accent-2); }
.option.rec.sel { border-color: var(--accent); }
.rec-tag {
  font-family: var(--mono); font-size: 10px; color: var(--accent-2);
  border: 1px solid rgba(139,125,255,0.35); background: rgba(139,125,255,0.1);
  border-radius: 20px; padding: 1px 8px; margin-left: 9px; vertical-align: middle; white-space: nowrap;
}
.stakes-chip {
  font-family: var(--mono); font-size: 11px; padding: 3px 9px; border-radius: 20px;
  border: 1px solid var(--line-2); color: var(--dim); text-transform: lowercase;
}
.stakes-chip.stakes-low { color: var(--dim-2); }
.stakes-chip.stakes-high { color: var(--warn); border-color: rgba(251,191,36,0.3); }
.option .prefetch-dot {
  flex: none; width: 7px; height: 7px; border-radius: 50%; margin-top: 8px;
  background: var(--line-2); transition: background .3s, box-shadow .3s;
}
.option .prefetch-dot.ready { background: var(--good); box-shadow: 0 0 8px rgba(74,222,128,0.6); }

@keyframes pop { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.node-foot { display: flex; gap: 26px; align-items: center; max-width: 760px; margin-top: 8px; flex-wrap: wrap; }
.conf { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--dim); }
.conf .bar { width: 160px; }

/* progress bar */
.bar { height: 5px; border-radius: 4px; background: var(--panel-2); overflow: hidden; position: relative; }
.bar > i { position: absolute; inset: 0; width: 0%; border-radius: 4px; transition: width .5s cubic-bezier(.2,.7,.3,1); display: block; }
.bar > i.lo { background: linear-gradient(90deg, var(--hot), var(--warn)); }
.bar > i.mid { background: linear-gradient(90deg, var(--warn), var(--accent)); }
.bar > i.hi { background: linear-gradient(90deg, var(--accent), var(--good)); }

/* ground chips */
.ground { max-width: 760px; margin-top: 26px; padding-top: 22px; border-top: 1px solid var(--line); }
.ground .gt { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--dim-2); margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.ground .gt .sim { color: var(--warn); font-size: 10px; border: 1px solid rgba(251,191,36,0.3); border-radius: 4px; padding: 1px 5px; }
.gchips { display: flex; gap: 8px; flex-wrap: wrap; }
.gchip {
  font-family: var(--mono); font-size: 12px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 7px; padding: 6px 10px;
  animation: pop .3s backwards;
}
.gchip .k { color: var(--dim); }
.gchip .v { color: var(--good); font-weight: 600; }
.gchip.injected { border-color: rgba(139,125,255,0.4); }
.gchip.injected .v { color: var(--accent-2); }

/* freetext */
.inject-wrap { max-width: 760px; margin-top: 20px; }
.inject {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 3px 6px 3px 14px;
  transition: border-color .15s;
}
.inject:focus-within { border-color: var(--accent-2); }
.inject .pfx { color: var(--dim-2); font-family: var(--mono); font-size: 13px; }
#injectInput { flex: 1; background: transparent; border: none; outline: none; color: var(--text); font-size: 14px; padding: 10px 0; }
.inject small { color: var(--dim-2); font-size: 11px; padding-right: 6px; }

/* thinking shimmer */
.skeleton { max-width: 760px; }
.sk-opt { height: 68px; border-radius: 12px; background: linear-gradient(90deg, var(--panel) 25%, var(--panel-2) 50%, var(--panel) 75%); background-size: 200% 100%; animation: shimmer 1.1s infinite; margin-bottom: 10px; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.thinking-tag { color: var(--accent); font-family: var(--mono); font-size: 12px; margin-bottom: 18px; display: flex; align-items: center; gap: 8px; }
.thinking-tag .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .3; } }

/* ---------- keybar ---------- */
.keybar {
  position: fixed; bottom: 0; left: 300px; right: 0;
  display: flex; gap: 18px; align-items: center;
  padding: 9px 40px; font-size: 12px; color: var(--dim-2);
  background: var(--scrim); backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
}
.keybar .k { display: flex; align-items: center; gap: 6px; }

/* ---------- doc overlay ---------- */
#docOverlay {
  position: fixed; inset: 0; z-index: 50;
  background: var(--scrim-2); backdrop-filter: blur(6px);
  display: none; align-items: flex-start; justify-content: center;
  padding: 40px 20px; overflow-y: auto;
}
#docOverlay.show { display: flex; }
.doc-modal {
  width: min(860px, 100%); background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; box-shadow: 0 30px 80px rgba(0,0,0,0.6); overflow: hidden;
  animation: pop .3s backwards;
}
.doc-head { display: flex; align-items: center; gap: 12px; padding: 16px 24px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); }
.doc-head h3 { font-size: 15px; font-weight: 600; }
.doc-head .spacer { flex: 1; }
.doc-head .meta { font-size: 12px; color: var(--dim); font-family: var(--mono); }
.proj-tabs { display: flex; gap: 2px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 2px; }
.proj-tab { background: none; border: none; color: var(--dim); font-size: 12px; padding: 4px 10px; border-radius: 6px; cursor: pointer; white-space: nowrap; }
.proj-tab:hover { color: var(--text); }
.proj-tab.active { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.doc-body { padding: 20px 40px 50px; line-height: 1.65; font-size: 15px; overflow-wrap: break-word; }
.doc-body h1 { font-size: 26px; margin: 20px 0 12px; letter-spacing: -0.4px; }
.doc-body h2 { font-size: 20px; margin: 26px 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.doc-body h3 { font-size: 16px; margin: 20px 0 8px; color: var(--accent); }
.doc-body p { margin: 10px 0; color: var(--text-2); }
.doc-body ul, .doc-body ol { margin: 10px 0 10px 24px; }
.doc-body ul ul, .doc-body ul ol, .doc-body ol ul, .doc-body ol ol { margin: 4px 0 4px 22px; }
.doc-body li { margin: 5px 0; color: var(--text-2); }
.doc-body ul ul li, .doc-body ol ul li { margin: 2px 0; }
.doc-body strong { color: var(--text); }
.doc-body code { font-family: var(--mono); font-size: 13px; background: var(--panel-2); padding: 2px 6px; border-radius: 5px; color: var(--accent); }
.doc-body pre { background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px; padding: 14px; overflow-x: auto; margin: 12px 0; }
.doc-body pre code { background: none; padding: 0; color: var(--text); }
.doc-body table { border-collapse: collapse; margin: 12px 0; width: 100%; }
.doc-body th, .doc-body td { border: 1px solid var(--line); padding: 7px 11px; text-align: left; font-size: 13.5px; }
.doc-body th { background: var(--panel-2); }
.doc-body blockquote { border-left: 3px solid var(--accent-2); padding-left: 14px; color: var(--dim); margin: 12px 0; }
.doc-cursor { display: inline-block; width: 8px; height: 17px; background: var(--accent); vertical-align: text-bottom; animation: blink .9s infinite; }

.iconbtn { background: none; border: none; color: var(--dim); font-size: 18px; padding: 4px 8px; border-radius: 6px; }
.iconbtn:hover { color: var(--text); background: var(--panel-2); }

/* live doc pane */
#livedoc {
  border-left: 1px solid var(--line); background: var(--bg-2);
  overflow-y: auto; overflow-x: hidden; min-width: 0;
}
.ld-head {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  position: sticky; top: 0; background: var(--bg-2); border-bottom: 1px solid var(--line); z-index: 2;
}
.ld-title { font-size: 11px; font-family: var(--mono); text-transform: uppercase; letter-spacing: .8px; color: var(--dim); }
.ld-hint { font-size: 10.5px; color: var(--dim-2); margin-left: auto; white-space: nowrap; }
.ld-toggle {
  background: none; border: 1px solid var(--line-2); color: var(--dim); border-radius: 6px;
  font-size: 12px; padding: 2px 7px; cursor: pointer; transition: transform .2s;
}
.ld-toggle:hover { color: var(--text); border-color: var(--accent); }
body.ld-collapsed #livedoc .ld-title, body.ld-collapsed #livedoc .ld-hint, body.ld-collapsed #ldBody { display: none; }
body.ld-collapsed .ld-toggle { transform: rotate(180deg); }
body.ld-collapsed .ld-head { justify-content: center; padding: 10px 4px; }
#ldBody { padding: 10px 14px 30px; }
.ld-sec { margin-bottom: 18px; }
.ld-h {
  font-size: 11px; font-family: var(--mono); text-transform: uppercase; letter-spacing: .6px;
  color: var(--accent); margin-bottom: 6px;
}
.ld-line { display: flex; gap: 8px; font-size: 12.5px; line-height: 1.55; color: var(--dim); margin: 1px 0; }
.ld-line + .ld-line { margin-top: 6px; }
.ld-txt { flex: 1; min-width: 0; white-space: pre-wrap; overflow-wrap: break-word; }
.ld-gut { flex: none; width: 3px; border-radius: 2px; align-self: stretch; }
.ld-gut.g-add { background: var(--good); }
.ld-gut.g-del { background: var(--hot); }
.ld-gut.g-add.g-del { background: linear-gradient(var(--good) 50%, var(--hot) 50%); }
.ld-add { color: rgb(94,222,138); font-weight: 600; }

/* force graph overlay */
#graphOverlay {
  position: fixed; inset: 0; display: none; z-index: 55;
  background: var(--scrim); backdrop-filter: blur(3px);
}
#graphOverlay.show { display: block; animation: pop .18s backwards; }
#graphCanvas { width: 100%; height: 100%; cursor: grab; }
#graphCanvas:active { cursor: grabbing; }
.g-legend {
  position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%);
  font-size: 12px; color: var(--dim); background: var(--panel); border: 1px solid var(--line);
  border-radius: 20px; padding: 7px 16px; white-space: nowrap;
}

/* what-if fork overlay */
#wiOverlay {
  position: fixed; inset: 0; display: none; align-items: center; justify-content: center;
  background: var(--scrim-2); backdrop-filter: blur(4px); z-index: 60; padding: 40px 20px;
}
#wiOverlay.show { display: flex; }
.wi-modal {
  width: min(880px, 100%); background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; box-shadow: 0 30px 80px rgba(0,0,0,0.6); animation: pop .3s backwards;
}
.wi-cols { display: flex; gap: 14px; padding: 18px 22px 6px; }
.wi-col {
  flex: 1; background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 16px; min-height: 150px;
}
.wi-col.wi-winner { border-color: var(--good); box-shadow: 0 0 0 1px rgba(74,222,128,0.25); }
.wi-head { font-weight: 650; font-size: 14.5px; margin-bottom: 10px; color: var(--accent); }
.wi-step { margin: 9px 0; }
.wi-q { font-size: 12.5px; color: var(--dim); line-height: 1.4; }
.wi-take { font-size: 13px; font-weight: 600; margin-top: 2px; }
.wi-wait { font-size: 12px; color: var(--dim-2); font-family: var(--mono); animation: blink 1.2s infinite; }
.wi-verdict { padding: 10px 22px 20px; font-size: 13px; color: var(--dim); }
.wi-verdict .wi-why { color: var(--text); font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.wi-verdict .wi-risk { margin: 2px 0; }

/* toast */
#toast {
  position: fixed; bottom: 56px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--panel-2); border: 1px solid var(--line-2); color: var(--text);
  padding: 10px 18px; border-radius: 10px; font-size: 13px; z-index: 60;
  opacity: 0; transition: all .25s; pointer-events: none; box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 6px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }
