/* Tree of Content — futuristic dark, organic glow. */
:root {
  --bg0: #04060a; --bg1: #0a1018; --panel: rgba(13, 20, 30, 0.82);
  --line: rgba(120, 160, 200, 0.14); --ink: #dfe7ee; --dim: #7d8b99;
  --accent: #39d98a; --cyan: #35c4dc; --amber: #e8b83f; --red: #e8563f;
  --violet: #9a6bff; --gold: #ffd979;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  font-size: 15px;
}
* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; }
body {
  background: radial-gradient(ellipse 120% 90% at 50% 110%, #0c1a16 0%, var(--bg1) 45%, var(--bg0) 100%);
  color: var(--ink);
  font-family: "Avenir Next", "Segoe UI", system-ui, sans-serif;
  overflow: hidden;
}
button { font: inherit; cursor: pointer; }
input, textarea, select { font: inherit; color: var(--ink); }

/* ---------- shell ---------- */
#stage { position: fixed; inset: 0; }
#stars { position: fixed; inset: 0; pointer-events: none; opacity: 0.6; }
#treeSvg { position: fixed; inset: 0; width: 100%; height: 100%; }

#topbar {
  position: fixed; top: 0; left: 0; right: 0; height: 58px; z-index: 40;
  display: flex; align-items: center; gap: 18px; padding: 0 22px;
  background: linear-gradient(180deg, rgba(4,6,10,0.9), rgba(4,6,10,0));
}
#brand {
  font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; font-size: 15px;
  background: linear-gradient(90deg, var(--accent), var(--cyan), var(--violet));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  cursor: pointer; user-select: none;
}
#crumb { color: var(--dim); font-size: 13px; letter-spacing: 0.06em; }
#crumb b { color: var(--ink); font-weight: 600; }
#liveDot {
  margin-left: auto; display: flex; align-items: center; gap: 8px;
  color: var(--dim); font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase;
}
#liveDot::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 12px var(--accent);
  animation: pulse 2.2s var(--ease) infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.45; transform: scale(0.75); } }
#userChip { color: var(--dim); font-size: 13px; }
#userChip b { color: var(--ink); }

/* ---------- forest (channel picker) ---------- */
#forest {
  position: fixed; inset: 0; z-index: 30; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 40px;
  transition: opacity 0.5s var(--ease), transform 0.5s var(--ease);
}
#forest.hidden { opacity: 0; transform: scale(1.06); pointer-events: none; }
#forestTitle { text-align: center; }
#forestTitle h1 {
  font-size: 44px; font-weight: 700; letter-spacing: 0.18em; text-transform: uppercase;
  background: linear-gradient(90deg, var(--accent), var(--cyan) 50%, var(--violet));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
#forestTitle p { color: var(--dim); margin-top: 10px; letter-spacing: 0.28em; text-transform: uppercase; font-size: 12px; }
#channelRow { display: flex; gap: 26px; flex-wrap: wrap; justify-content: center; }
.chCard {
  width: 240px; padding: 26px 22px 20px; border-radius: 18px; border: 1px solid var(--line);
  background: var(--panel); backdrop-filter: blur(12px); text-align: center;
  transition: transform 0.35s var(--ease), border-color 0.35s, box-shadow 0.35s;
  cursor: pointer; position: relative; overflow: hidden;
}
.chCard:hover { transform: translateY(-6px); border-color: var(--c); box-shadow: 0 18px 50px -18px var(--c); }
.chCard .glyph { height: 110px; margin-bottom: 14px; }
.chCard h3 { font-size: 17px; letter-spacing: 0.06em; }
.chCard .meta { color: var(--dim); font-size: 12.5px; margin-top: 8px; display: flex; justify-content: center; gap: 12px; }
.chCard .meta b { color: var(--ink); }
.chCard.add { display: flex; align-items: center; justify-content: center; color: var(--dim); font-size: 15px; border-style: dashed; min-height: 228px; }
.chCard.add:hover { color: var(--ink); }

/* ---------- side panel ---------- */
#panel {
  position: fixed; top: 58px; right: 0; bottom: 0; width: 480px; z-index: 35;
  background: var(--panel); backdrop-filter: blur(16px); border-left: 1px solid var(--line);
  transform: translateX(102%); transition: transform 0.45s var(--ease);
  display: flex; flex-direction: column;
}
#panel.open { transform: translateX(0); }
#panelHead { padding: 18px 20px 12px; border-bottom: 1px solid var(--line); }
#panelHead .row1 { display: flex; align-items: center; gap: 10px; }
#panelHead h2 { font-size: 18px; flex: 1; }
.typeBadge {
  font-size: 10.5px; letter-spacing: 0.12em; text-transform: uppercase; padding: 3px 9px;
  border-radius: 20px; border: 1px solid var(--line); color: var(--dim);
}
#panelClose { background: none; border: none; color: var(--dim); font-size: 20px; }
#panelClose:hover { color: var(--ink); }
#srcMeta { color: var(--dim); font-size: 12.5px; margin-top: 6px; display: flex; gap: 14px; align-items: center; }
#srcMeta a { color: var(--cyan); text-decoration: none; }
#pauseBtn { background: none; border: 1px solid var(--line); border-radius: 8px; color: var(--dim); padding: 2px 10px; font-size: 12px; }

#filters { display: flex; gap: 8px; padding: 12px 20px; flex-wrap: wrap; align-items: center; }
.chip {
  border: 1px solid var(--line); background: transparent; color: var(--dim);
  padding: 4px 12px; border-radius: 20px; font-size: 12.5px; letter-spacing: 0.04em;
  transition: all 0.25s var(--ease);
}
.chip.on { color: #06131c; font-weight: 700; border-color: transparent; }
.chip.on[data-f=""] { background: rgba(120,160,200,0.2) !important; color: var(--ink); border-color: rgba(120,160,200,0.4); }
#searchBox {
  flex: 1; min-width: 120px; background: rgba(0,0,0,0.25); border: 1px solid var(--line);
  border-radius: 8px; padding: 5px 10px; font-size: 13px; outline: none;
}
#itemList { flex: 1; overflow-y: auto; padding: 4px 12px 20px; }
#itemList::-webkit-scrollbar { width: 8px; }
#itemList::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }

.item {
  border: 1px solid transparent; border-radius: 12px; padding: 10px 12px; margin: 6px 0;
  transition: background 0.25s, border-color 0.25s; cursor: pointer;
}
.item:hover, .item.sel { background: rgba(255,255,255,0.035); border-color: var(--line); }
.item .t { font-size: 14px; line-height: 1.35; }
.item .sub { display: flex; gap: 12px; align-items: center; color: var(--dim); font-size: 12px; margin-top: 5px; }
.dotStatus { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.stars { display: inline-flex; gap: 2px; }
.stars span { color: #3a4653; font-size: 14px; transition: color 0.15s, transform 0.15s; }
.stars span.on { color: var(--gold); text-shadow: 0 0 8px rgba(255,217,121,0.5); }
.stars span:hover { transform: scale(1.25); }
.item .body {
  display: none; margin-top: 10px; color: #b9c4cf; font-size: 13px; line-height: 1.55;
  white-space: pre-wrap; max-height: 260px; overflow-y: auto;
  border-top: 1px dashed var(--line); padding-top: 10px;
}
.item.sel .body { display: block; }
.actRow { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.actRow button {
  border: 1px solid var(--line); background: transparent; color: var(--dim);
  border-radius: 8px; padding: 4px 11px; font-size: 12px; transition: all 0.2s var(--ease);
}
.actRow button:hover { color: var(--ink); border-color: var(--dim); }
.actRow button.on { color: #04110a; font-weight: 700; }
.usedIn { margin-top: 8px; display: flex; gap: 6px; }
.usedIn input { flex: 1; background: rgba(0,0,0,0.25); border: 1px solid var(--line); border-radius: 8px; padding: 4px 9px; font-size: 12.5px; outline: none; }

/* ---------- ticker ---------- */
#ticker {
  display: flex; flex-direction: column; gap: 5px; overflow: hidden; max-height: 108px;
  mask-image: linear-gradient(180deg, #000 70%, transparent);
}
.tick {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 7px 12px; font-size: 12.5px; color: var(--dim); backdrop-filter: blur(8px);
  animation: tickIn 0.5s var(--ease);
}
.tick b { color: var(--ink); font-weight: 600; }
.tick .k { letter-spacing: 0.1em; text-transform: uppercase; font-size: 10px; margin-right: 8px; }
@keyframes tickIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ---------- fab + modals ---------- */
#fab {
  position: fixed; right: 26px; bottom: 24px; z-index: 36; width: 54px; height: 54px;
  border-radius: 50%; border: none; font-size: 26px; color: #04110a; font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--cyan));
  box-shadow: 0 10px 30px -8px var(--accent); transition: transform 0.3s var(--ease);
}
#fab:hover { transform: rotate(90deg) scale(1.08); }
#fab.hidden, #panel.hiddenFully { display: none; }

.modalWrap {
  position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center;
  background: rgba(2,4,7,0.7); backdrop-filter: blur(6px);
  opacity: 0; pointer-events: none; transition: opacity 0.3s var(--ease);
}
.modalWrap.open { opacity: 1; pointer-events: auto; }
.modal {
  width: 420px; background: var(--bg1); border: 1px solid var(--line); border-radius: 18px;
  padding: 26px; transform: translateY(16px); transition: transform 0.35s var(--ease);
}
.modalWrap.open .modal { transform: none; }
.modal h3 { letter-spacing: 0.1em; text-transform: uppercase; font-size: 14px; margin-bottom: 18px; color: var(--dim); }
.modal label { display: block; font-size: 12px; color: var(--dim); margin: 12px 0 5px; letter-spacing: 0.06em; }
.modal input, .modal select, .modal textarea {
  width: 100%; background: rgba(0,0,0,0.3); border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 12px; outline: none; transition: border-color 0.25s;
}
.modal input:focus, .modal textarea:focus { border-color: var(--accent); }
.typeGrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.typeGrid button {
  border: 1px solid var(--line); background: transparent; border-radius: 10px; color: var(--dim);
  padding: 9px 4px; font-size: 11.5px; letter-spacing: 0.04em; transition: all 0.2s;
}
.typeGrid button.on { border-color: var(--accent); color: var(--accent); box-shadow: 0 0 14px -6px var(--accent); }
.modal .go {
  margin-top: 22px; width: 100%; border: none; border-radius: 12px; padding: 11px;
  font-weight: 700; letter-spacing: 0.08em; color: #04110a;
  background: linear-gradient(90deg, var(--accent), var(--cyan));
}
.modal .err { color: var(--red); font-size: 12.5px; margin-top: 10px; min-height: 16px; }

/* ---------- login ---------- */
#gate { z-index: 80; }
#gate .modal { text-align: center; }
#gate h1 {
  font-size: 26px; letter-spacing: 0.22em; text-transform: uppercase; margin-bottom: 6px;
  background: linear-gradient(90deg, var(--accent), var(--cyan), var(--violet));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
#gate p { color: var(--dim); font-size: 12px; letter-spacing: 0.14em; margin-bottom: 16px; }

/* ---------- svg tree ---------- */
.branch { cursor: pointer; }
.branch path.limb {
  fill: none; stroke-linecap: round;
  transition: filter 0.3s var(--ease), stroke 0.3s;
}
.branch:hover path.limb, .branch.sel path.limb { filter: drop-shadow(0 0 10px var(--c)); }
.branch text {
  fill: #93a3b3; font-size: 12.5px; letter-spacing: 0.05em; pointer-events: none;
  transition: fill 0.3s;
}
.branch:hover text, .branch.sel text { fill: #eaf2f8; }
.leaf { transition: r 0.4s var(--ease); }
.sway { transform-origin: var(--ox) var(--oy); animation: sway var(--dur) ease-in-out infinite alternate; }
@keyframes sway { from { transform: rotate(-0.7deg); } to { transform: rotate(0.7deg); } }
.pulseDot { filter: drop-shadow(0 0 6px currentColor); }
#tooltip {
  position: fixed; z-index: 50; pointer-events: none; background: var(--panel);
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; font-size: 12.5px;
  color: var(--dim); backdrop-filter: blur(10px); opacity: 0; transition: opacity 0.2s;
  max-width: 260px;
}
#tooltip b { color: var(--ink); }
#tooltip .cnt { display: flex; gap: 10px; margin-top: 4px; }

/* ---------- organism canvas + HUD ---------- */
#organism { position: fixed; inset: 0; pointer-events: none; }
#hudTop { margin-left: auto; color: var(--dim); font-size: 11px; letter-spacing: 0.14em; }
#hudTop b { color: var(--ink); font-weight: 600; }
#hudTop + #liveDot { margin-left: 18px; }
#hud {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 33; height: 150px;
  display: grid; grid-template-columns: 1.3fr 1fr 0.9fr 0.7fr; gap: 1px;
  background: var(--line); border-top: 1px solid var(--line);
}
#hud .hudPanel {
  background: rgba(4,7,11,0.88); backdrop-filter: blur(10px); padding: 10px 16px; overflow: hidden;
}
#hud h4 {
  font-size: 9.5px; letter-spacing: 0.22em; text-transform: uppercase; color: var(--dim);
  margin-bottom: 8px; font-weight: 600;
}
.tick { background: none; border: none; padding: 2px 0; backdrop-filter: none; animation: tickIn 0.4s var(--ease); }
#pressureBars { display: flex; flex-direction: column; gap: 4px; }
.pRow { display: grid; grid-template-columns: 120px 1fr 34px; gap: 8px; align-items: center; font-size: 10.5px; color: var(--dim); }
.pRow .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: 0.04em; }
.pRow .bar { height: 4px; border-radius: 2px; background: rgba(255,255,255,0.06); overflow: hidden; }
.pRow .bar i { display: block; height: 100%; border-radius: 2px; background: var(--bc, var(--accent)); width: 0; transition: width 1s var(--ease); box-shadow: 0 0 8px var(--bc, var(--accent)); }
.pRow .n { text-align: right; color: var(--ink); font-variant-numeric: tabular-nums; }
#topoWrap { display: flex; gap: 14px; align-items: center; }
#donut { width: 92px; height: 92px; }
#donut circle { fill: none; stroke-width: 9; transition: stroke-dasharray 1s var(--ease); }
#topoLegend { font-size: 10.5px; color: var(--dim); display: flex; flex-direction: column; gap: 3px; }
#topoLegend i { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; }
#counterWrap { display: flex; flex-direction: column; justify-content: center; height: 100px; }
#bigCount {
  font-size: 44px; font-weight: 700; letter-spacing: 0.02em; line-height: 1;
  font-variant-numeric: tabular-nums; color: var(--ink); text-shadow: 0 0 22px rgba(53,196,220,0.35);
}
#counterSub { color: var(--dim); font-size: 11px; margin-top: 6px; letter-spacing: 0.08em; }
#counterSub span { color: var(--ink); }
/* organism overlay labels */
.branch .lbl { fill: #5f7183; font-size: 11.5px; letter-spacing: 0.06em; opacity: 0; transition: opacity 0.4s, fill 0.3s; pointer-events: none; }
.branch .lbl.show { opacity: 0.75; }
.branch.hov .lbl, .branch.sel .lbl { opacity: 1; fill: #eef4f9; }
.branch .hit { pointer-events: stroke; cursor: pointer; }
#tooltip .note { margin-top: 5px; color: #8fa0b0; font-style: italic; }
#panel { z-index: 45; }
@media (max-width: 1100px) { #hud { grid-template-columns: 1fr 1fr; height: auto; } }

/* ---------- clean limbs + chips ---------- */
.branch .limbSoft { fill: none; opacity: 0.16; stroke-linecap: round; transition: opacity 0.25s; }
.branch .limbCore { fill: none; opacity: 0.34; stroke-width: 1.1; stroke-linecap: round; transition: opacity 0.25s; }
.branch.hov .limbSoft, .branch.sel .limbSoft { opacity: 0.42; }
.branch.hov .limbCore, .branch.sel .limbCore { opacity: 0.9; filter: drop-shadow(0 0 6px currentColor); }
.branch.paused { opacity: 0.45; }
.chip { cursor: pointer; }
.chipBg { fill: rgba(9, 14, 21, 0.92); stroke-opacity: 0.35; transition: all 0.25s var(--ease); }
.branch.hov .chipBg, .branch.sel .chipBg { stroke-opacity: 1; fill: rgba(14, 22, 32, 0.98); }
.chipTxt { fill: #c3cfda; font-size: 11px; letter-spacing: 0.03em; }
.branch.hov .chipTxt, .branch.sel .chipTxt { fill: #f2f7fb; }
.chipCnt { fill: #fff; font-size: 10.5px; font-weight: 700; }
.sectorLbl { fill: #5a6b7c; font-size: 9.5px; letter-spacing: 0.3em; opacity: 0.75; }

/* ---------- navigation rail ---------- */
#rail {
  position: fixed; top: 58px; left: 0; bottom: 150px; width: 252px; z-index: 32;
  background: rgba(5, 8, 13, 0.86); backdrop-filter: blur(12px);
  border-right: 1px solid var(--line); display: none; flex-direction: column;
}
#rail.show { display: flex; }
#railSearch {
  margin: 12px 12px 8px; background: rgba(0,0,0,0.3); border: 1px solid var(--line);
  border-radius: 9px; padding: 7px 11px; font-size: 12.5px; outline: none;
}
#railList { flex: 1; overflow-y: auto; padding: 0 6px 12px; }
#railList::-webkit-scrollbar { width: 6px; }
#railList::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }
.railGroup { margin-top: 10px; }
.railGroup h5 {
  font-size: 9px; letter-spacing: 0.24em; text-transform: uppercase; color: var(--dim);
  padding: 4px 10px; font-weight: 600;
}
.railRow {
  display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 8px;
  font-size: 12.5px; color: #b9c5d0; cursor: pointer; transition: background 0.2s;
}
.railRow:hover, .railRow.sel { background: rgba(255,255,255,0.05); color: #eef4f9; }
.railRow .nm { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.railRow .ct {
  font-size: 10.5px; color: var(--ink); background: rgba(255,255,255,0.07);
  border-radius: 9px; padding: 1px 7px; font-variant-numeric: tabular-nums;
}
.railRow .ct.zero { color: #55636f; background: transparent; }
.railRow .st { width: 6px; height: 6px; border-radius: 50%; flex: none; }

/* ================= audit round 1 ================= */
/* gate privacy (B13) */
body.locked #topbar, body.locked #forest, body.locked #hud, body.locked #fab,
body.locked #rail, body.locked #panel { visibility: hidden; }
/* hidden modals unreachable by keyboard (B8) */
.modalWrap { visibility: hidden; }
.modalWrap.open { visibility: visible; }
.modalX {
  position: absolute; top: 14px; right: 16px; background: none; border: none;
  color: var(--dim); font-size: 16px; padding: 4px;
}
.modalX:hover { color: var(--ink); }
.modal { position: relative; }
.modalSub { color: var(--dim); font-size: 12.5px; margin: -10px 0 6px; }
.modal .go:disabled { opacity: 0.35; cursor: not-allowed; }

/* crumb back affordance (#9) */
#crumbBack { cursor: pointer; color: var(--dim); transition: color 0.2s; }
#crumbBack:hover { color: var(--ink); }
#crumb .sep { opacity: 0.4; margin: 0 4px; }
#brand { cursor: pointer; }

/* story body reading (#4) */
.item .body { display: none; margin-top: 10px; }
.item.sel .body { display: block; }
.item .bodyText {
  color: #c7d2dc; font-size: 15px; line-height: 1.6; white-space: pre-wrap;
  max-height: min(46vh, 420px); overflow-y: auto; overscroll-behavior: contain;
  border-top: 1px dashed var(--line); padding-top: 12px;
  -webkit-mask-image: linear-gradient(#000 calc(100% - 48px), transparent);
  mask-image: linear-gradient(#000 calc(100% - 48px), transparent);
}
.origLink { display: inline-block; margin-top: 6px; color: var(--cyan); font-size: 12.5px; text-decoration: none; }

/* grading controls (#5, #6) */
.stickyActs {
  position: sticky; bottom: 0; background: rgba(11,17,25,0.97);
  padding: 10px 0 4px; margin-top: 8px; border-top: 1px solid var(--line);
}
.stBtn {
  border: 1px solid var(--sc); background: transparent; color: var(--sc);
  border-radius: 8px; padding: 4px 11px; font-size: 12px; transition: all 0.22s var(--ease);
}
.stBtn:hover { background: color-mix(in srgb, var(--sc) 18%, transparent); }
.stBtn.on { background: var(--sc); color: #06131c; font-weight: 700; }
.dotStatus { transition: background 0.25s var(--ease); }
.stName { min-width: 56px; }
.who { opacity: 0.75; }
.stars span.pre { color: #b9a35c; }
.item { border-bottom: 1px solid rgba(120,160,200,0.08); border-radius: 10px; padding: 9px 12px; margin: 2px 0; }

/* sort + result count */
#sortSel {
  background: rgba(0,0,0,0.3); border: 1px solid var(--line); border-radius: 8px;
  padding: 4px 8px; font-size: 12px; color: var(--dim); outline: none;
}
#resultCount { color: var(--dim); font-size: 11.5px; letter-spacing: 0.04em; }
.emptyMsg { color: var(--dim); text-align: center; padding: 40px 20px; font-size: 13px; }
.moreBtn {
  display: block; margin: 12px auto; border: 1px solid var(--line); background: transparent;
  color: var(--dim); border-radius: 10px; padding: 7px 18px; font-size: 12.5px;
}
.moreBtn:hover { color: var(--ink); border-color: var(--dim); }

/* toast (#5) */
#toast {
  position: fixed; left: 50%; bottom: 168px; transform: translate(-50%, 16px); z-index: 70;
  background: rgba(10,16,24,0.96); border: 1px solid var(--line); border-radius: 12px;
  padding: 9px 16px; font-size: 13px; color: var(--ink); display: flex; gap: 14px; align-items: center;
  opacity: 0; pointer-events: none; transition: opacity 0.3s var(--ease), transform 0.3s var(--ease);
  backdrop-filter: blur(10px); box-shadow: 0 10px 34px rgba(0,0,0,0.5);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
#toast button { background: none; border: none; color: var(--cyan); font-size: 13px; font-weight: 600; }

/* cascade rows */
.tick .k { color: var(--accent); }
.tick .when { float: right; opacity: 0.5; font-size: 10px; }
#ticker { mask-image: none; max-height: 118px; }

/* HUD odds & ends (#11) */
.hudEmpty { color: #55636f; font-size: 11.5px; padding: 8px 0; font-style: italic; }
.donutN { fill: var(--ink); font-size: 15px; font-weight: 700; }
#hud { grid-template-columns: 1.2fr 1fr 1fr 0.8fr; }
#fab { bottom: 170px; background: linear-gradient(135deg, var(--channel, var(--accent)), var(--cyan)); box-shadow: 0 10px 30px -8px var(--channel, var(--accent)); }

/* rail scroll fade (#10) */
#railList { -webkit-mask-image: linear-gradient(180deg, transparent 0, #000 18px, #000 calc(100% - 14px), transparent); mask-image: linear-gradient(180deg, transparent 0, #000 18px, #000 calc(100% - 14px), transparent); }

/* sector labels never intercept clicks (#2) */
.sectorLbl { pointer-events: none; }
/* dimmed branches during rail search (#10) */
.branch.dim { opacity: 0.13; pointer-events: none; }
.branch { transition: opacity 0.25s var(--ease); }
/* leader lines from displaced chips (#1) */
.leader { stroke: rgba(160,190,215,0.22); stroke-width: 1; }

/* ================= audit round 2 ================= */
/* A — the story must be readable: uncap the card, let bodyText own the height,
   and shrink the sticky block to just the five status buttons, fully opaque */
.item .body { max-height: none; overflow: visible; }
.item .bodyText { padding-bottom: 12px; }
.stickyActs {
  position: sticky; bottom: 0; z-index: 2;
  background: #0b1119; backdrop-filter: blur(8px);
  border-top: 1px solid rgba(120,160,200,0.14);
  padding: 8px 0 6px; margin-top: 8px;
}
.usedIn { margin-top: 10px; }

/* B — star clear is felt, not just claimed */
.stars span.clr { animation: starPop 0.16s var(--ease); color: #3a4653 !important; text-shadow: none !important; }
@keyframes starPop { 0% { transform: scale(1); } 50% { transform: scale(0.8); } 100% { transform: scale(1); } }

/* L — one active treatment for the whole filter group */
.chip.on[data-f=""] {
  background: #93a3b3 !important; color: #06131c !important;
  border-color: transparent; font-weight: 700;
}

/* 6 — toast lives where the hand is: panel corner, countdown hairline */
#toast {
  left: auto; right: 24px; bottom: 24px; transform: translateY(14px);
  overflow: hidden;
}
#toast.show { transform: none; }
#toast::after {
  content: ""; position: absolute; left: 0; bottom: 0; height: 2px;
  background: var(--cyan); width: 0;
}
#toast.show::after { animation: toastCount 5s linear forwards; }
@keyframes toastCount { from { width: 100%; } to { width: 0; } }

/* F — the cascade never slices a row */
#ticker {
  overflow-y: auto; max-height: 106px; padding-right: 4px;
  -webkit-mask-image: linear-gradient(#000 calc(100% - 20px), transparent);
  mask-image: linear-gradient(#000 calc(100% - 20px), transparent);
}
#ticker::-webkit-scrollbar { width: 4px; }
#ticker::-webkit-scrollbar-thumb { background: var(--line); border-radius: 2px; }

/* I — channel attribution dots in forest-scope pressure rows */
.chDot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; margin-right: 5px; vertical-align: 1px; }

/* 7 — the forest carries information; close the dead band above the cards */
#forest { padding-bottom: 140px; gap: 30px; }
.chCard .prog { height: 4px; border-radius: 2px; background: rgba(255,255,255,0.07); margin-top: 12px; overflow: hidden; }
.chCard .prog i { display: block; height: 100%; background: var(--c); border-radius: 2px; box-shadow: 0 0 8px var(--c); transition: width 1s var(--ease); }
.chCard .progLbl { color: var(--dim); font-size: 11px; margin-top: 5px; letter-spacing: 0.04em; }

/* ================= audit round 3 ================= */
/* NEW-1/2 — kill the pre-wrap slab; the grading row sits statically after the inputs */
.item .body { white-space: normal; }
.stickyActs { position: static; padding: 8px 0 2px; background: transparent; backdrop-filter: none; }

/* stacked status segments on channel cards; meta never wraps unevenly */
.chCard .prog { display: flex; gap: 1px; }
.chCard .prog i { flex: none; transition: width 1s var(--ease); box-shadow: none; }
.chCard .meta { white-space: nowrap; gap: 10px; font-size: 12px; }

/* the cascade never wraps, so it can never slice */
.tick { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.legendSub { color: #55636f; font-size: 10px; margin-top: 4px; letter-spacing: 0.06em; }

/* toast clears the last card's grading row and the HUD readout */
#toast { bottom: 90px; }

/* chips live on a top SVG layer now — their states no longer come from .branch */
.chip.hov .chipBg, .chip.sel .chipBg { stroke-opacity: 1; fill: rgba(14, 22, 32, 0.98); }
.chip.hov .chipTxt, .chip.sel .chipTxt { fill: #f2f7fb; }
.chip.dim { opacity: 0.13; pointer-events: none; transition: opacity 0.25s var(--ease); }

/* ================= story identity & hierarchy ================= */
/* who is this story about — instantly scannable */
.eyebrow { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.coChip {
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--channel, var(--accent));
  border: 1px solid color-mix(in srgb, var(--channel, var(--accent)) 45%, transparent);
  background: color-mix(in srgb, var(--channel, var(--accent)) 10%, transparent);
  border-radius: 6px; padding: 1.5px 8px;
}
.eyebrow .yr { font-size: 10.5px; color: var(--dim); letter-spacing: 0.06em; font-variant-numeric: tabular-nums; }
.item .t { font-size: 14.5px; line-height: 1.4; font-weight: 550; }

/* where am i — channel path above the branch name */
#panelPath {
  display: flex; align-items: center; gap: 7px; margin-bottom: 6px;
  font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--dim); font-weight: 600;
}
#panelPath i { width: 7px; height: 7px; border-radius: 50%; flex: none; }
#panelPath .pathTag { text-transform: none; letter-spacing: 0.04em; font-weight: 400; color: #66757f; }

/* channel niche — forest card + crumb */
.chNiche { color: var(--dim); font-size: 11px; letter-spacing: 0.05em; margin-top: 4px; line-height: 1.4; }
.crumbTag { color: #66757f; font-size: 11px; margin-left: 10px; letter-spacing: 0.04em; }

/* ================= test prompts (AI Emperor) ================= */
.promptPanel {
  margin-top: 10px; border: 1px solid rgba(192, 132, 252, 0.4); border-radius: 10px;
  background: rgba(192, 132, 252, 0.06); padding: 10px 12px;
}
.promptHead { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 7px; }
.promptHead span { font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase; color: #c084fc; font-weight: 700; }
.copyBtn, .copyMini {
  border: 1px solid rgba(192, 132, 252, 0.55); background: rgba(192, 132, 252, 0.12); color: #e3d0ff;
  border-radius: 8px; padding: 4px 11px; font-size: 12px; font-weight: 600; transition: all 0.2s var(--ease); flex: none;
}
.copyBtn:hover, .copyMini:hover { background: #c084fc; color: #16092a; }
.copyBtn.did, .copyMini.did { background: var(--accent); border-color: var(--accent); color: #06131c; }
.copyMini { padding: 1px 8px; font-size: 10.5px; margin-left: auto; }
.promptBody {
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 11.5px; line-height: 1.5; color: #d2c6e6;
  white-space: pre-wrap; max-height: 260px; overflow-y: auto; padding-right: 6px;
  -webkit-mask-image: linear-gradient(#000 calc(100% - 28px), transparent); mask-image: linear-gradient(#000 calc(100% - 28px), transparent);
}
.promptBody::-webkit-scrollbar { width: 5px; } .promptBody::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }

/* ================= reel briefs (picked story × AI tools) ================= */
.briefPanel {
  margin-top: 10px; border: 1px solid rgba(255, 176, 46, 0.35); border-radius: 10px;
  background: rgba(255, 176, 46, 0.06); padding: 10px 12px;
}
.briefHead {
  font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--amber); font-weight: 700; margin-bottom: 7px;
}
.briefBody { font-size: 12.5px; line-height: 1.55; color: #d7dee6; white-space: pre-wrap; }

/* ================= grim ai grading ================= */
.aiB {
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.05em; padding: 1px 8px;
  border-radius: 10px; font-variant-numeric: tabular-nums; flex: none;
}
.aiB.hi  { color: #0a1a10; background: var(--accent); box-shadow: 0 0 10px -3px var(--accent); }
.aiB.mid { color: #1a1204; background: var(--amber); }
.aiB.lo  { color: #dfe7ee; background: rgba(224,99,122,0.28); border: 1px solid rgba(224,99,122,0.5); }
.aiPanel {
  margin-top: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: rgba(0,0,0,0.22);
}
.aiHead { font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--dim); margin-bottom: 8px; }
.aiHead b { font-size: 13px; letter-spacing: 0; }
.aiHead b.hi { color: var(--accent); } .aiHead b.mid { color: var(--amber); } .aiHead b.lo { color: #e0637a; }
.aiGrid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 18px; }
.aiRow { display: grid; grid-template-columns: 72px 1fr 18px; gap: 8px; align-items: center; font-size: 11px; color: var(--dim); }
.aiRow b { color: var(--ink); text-align: right; font-variant-numeric: tabular-nums; }
.aiBar { height: 4px; border-radius: 2px; background: rgba(255,255,255,0.06); overflow: hidden; }
.aiBar i { display: block; height: 100%; border-radius: 2px; }
.aiBar i.hi { background: var(--accent); } .aiBar i.mid { background: var(--amber); } .aiBar i.lo { background: #e0637a; }
.aiNote { margin-top: 8px; font-size: 12px; color: #9fb0bf; font-style: italic; line-height: 1.45; }

/* the gate is the first screen — it deserves the identity */
#gate .modal {
  width: 460px; padding: 30px 34px 34px;
  border-color: rgba(57, 217, 138, 0.28);
  box-shadow: 0 0 90px -24px rgba(57, 217, 138, 0.45), 0 30px 80px rgba(0, 0, 0, 0.6);
  background: linear-gradient(180deg, #0a1219, #070c12);
}
#gateGlyph { height: 118px; margin-bottom: 6px; }
#gate label { text-align: left; }

/* ================= audit round 5 ================= */
/* S6/#3 — the forest survives a laptop: grid, not flex-centre; overflow scrolls instead of escaping */
#forest { justify-content: safe center; overflow-y: auto; padding: 74px 16px 170px; gap: 30px; }
#channelRow {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 20px;
  width: min(100%, 1560px); justify-content: center;
}
.chCard { width: auto; }
.chCard.add { min-height: 0; }
@media (max-height: 820px) { .chCard .glyph { height: 84px; } #forestTitle h1 { font-size: 34px; } #forest { padding-top: 66px; } }

/* #2 — the five status buttons float over the story again (pre-wrap slab is gone since round 3) */
.item.sel .stickyActs { position: sticky; bottom: 0; z-index: 2; background: #0b1119; backdrop-filter: blur(8px); }

/* #9 — the panel gets its own lane: the HUD and the FAB step aside while you grade */
body.panelOpen #hud { right: 480px; }
body.panelOpen #fab { right: 506px; }
#hud, #fab { transition: right 0.45s var(--ease); }

/* #7/S12 — unrated stars are outlines at readable contrast; ★ means one thing per line */
.stars span { color: #55636f; }
.stars.rated span:not(.on) { color: #55636f; }

/* S11 — company chip is an identity, not a citation */
.coChip { max-width: 210px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* S13 — leader lines readable; chips show 0 quietly */
.leader { stroke: rgba(160, 190, 215, 0.45); }
.chipCnt.zero { fill: #6a7887; font-weight: 500; }

/* prompt pending state — the button is never silently missing */
.copyMini.pending { border-style: dashed; opacity: 0.7; cursor: default; }
.copyMini.pending:hover { background: rgba(192, 132, 252, 0.12); color: #e3d0ff; }
.promptPanel.pending { border-style: dashed; background: rgba(192, 132, 252, 0.03); }
.pendingBtn { border-style: dashed; opacity: 0.75; cursor: default; }
.promptNote { font-size: 12px; color: #9f92b5; line-height: 1.5; font-style: italic; }

/* toast: breathing room before the undo button */
#toast > span { margin-right: 4px; }
#toast button { margin-left: 6px; }

/* Source evidence and candidate review sit beside, never replace, human grades. */
.queueBtn { width:100%; margin:8px 0 16px; padding:12px 10px; border:1px solid #375950; border-radius:8px; background:#102a24; color:#9fe4cc; text-align:left; font-size:12px; }
.readinessBadge { font-size:10px; color:#bbc8d3; border:1px solid #3c4a59; border-radius:5px; padding:2px 5px; }
.item .sub { flex-wrap:wrap; gap:7px 10px; }
.item .sub > span, .item .sub > button { flex-shrink:0; }
.item .sub .stars { margin-left:auto; }
.qualityPanel { margin:16px 0; padding:14px; border:1px solid #34443e; border-radius:8px; background:#0c1b19; color:#b6c8c3; font-size:12px; line-height:1.6; overflow-wrap:anywhere; }
.qualityHead { display:flex; justify-content:space-between; gap:10px; flex-wrap:wrap; color:#a5ecd5; }
.qualityPanel p { margin:9px 0; }
.qualityMeaning { color:#8caaa0; }
.item .bodyText { -webkit-mask-image:none; mask-image:none; }
.evidenceChecks summary { cursor:pointer; color:#b4d2c9; }
.evidenceChecks div { margin:4px 0; }
.privatePrompt summary { padding:12px; cursor:pointer; color:#a99ac5; font-size:12px; }
.qualityDims { display:flex; flex-wrap:wrap; gap:5px 12px; margin:12px 0; }
.qualityPanel dl { display:grid; grid-template-columns:75px 1fr; gap:5px 10px; }
.qualityPanel dt { color:#7e9c92; } .qualityPanel dd { margin:0; }
.qualityPanel ul { padding-left:18px; margin:10px 0; }
.evidenceLinks { display:flex; flex-direction:column; gap:7px; }
.evidenceLinks a { color:#98d9f4; }
.reviewFilter { display:flex; align-items:center; gap:6px; color:var(--dim); font-size:11px; }
.reviewFilter input { width:auto; }
#readinessSel { max-width:190px; font-size:11px; background:#0b1520; color:#a9bac9; border:1px solid #2c3b49; border-radius:5px; padding:6px; }
@media (max-width:600px) {
  #topbar { padding:0 12px; gap:12px; }
  #brand { font-size:12px; white-space:nowrap; }
  #hudTop, #userChip, #liveDot, #crumb .crumbTag { display:none; }
  #crumb { white-space:nowrap; overflow:hidden; text-overflow:ellipsis; font-size:11px; }
  #panel { width:100%; max-width:100vw; }
  #panelHead, #filters { padding-left:12px; padding-right:12px; }
  #forest { overflow:auto; }
  body.panelOpen #hud, body.panelOpen #fab { display:none; }
  .qualityPanel dl { grid-template-columns:65px 1fr; }
}
