:root {
  --bg: #070b10; --panel: rgba(15, 23, 32, .86); --line: #1f2a36; --text: #e6edf3; --muted: #8b98a5;
  --ok: #22c55e; --warn: #f59e0b; --bad: #ef4444; --idle: #64748b; --blue: #3b82f6;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", sans-serif; }
body {
  min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(56, 189, 248, .10), transparent 60%),
    radial-gradient(900px 500px at 110% 10%, rgba(243, 128, 32, .08), transparent 60%),
    radial-gradient(900px 600px at 50% 120%, rgba(59, 130, 246, .10), transparent 60%),
    var(--bg);
}
a { color: #7dd3fc; }
.hidden { display: none !important; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 26px 8px; flex-wrap: wrap; }
.title { display: flex; gap: 14px; align-items: center; }
.title h1 { margin: 0; font-size: 22px; letter-spacing: .2px; }
.title p { margin: 2px 0 0; color: var(--muted); }
.back { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--line); color: var(--text); text-decoration: none; background: var(--panel); }
.back:hover { border-color: #38bdf8; }
.tools { display: flex; gap: 10px; align-items: center; }
.live-pill, .chip { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); color: var(--text); font-size: 12px; }
.chip { cursor: pointer; }
.chip.on { border-color: #2563eb; }
.live-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--idle); box-shadow: 0 0 0 0 rgba(34,197,94,.6); }
.live-pill.ok .dot { background: var(--ok); animation: ping 2s infinite; }
.live-pill.warn .dot { background: var(--warn); }
@keyframes ping { 0% { box-shadow: 0 0 0 0 rgba(34,197,94,.55); } 100% { box-shadow: 0 0 0 10px rgba(34,197,94,0); } }
.signin { margin: 4px 26px; padding: 8px 12px; border: 1px solid #3a2a0a; background: rgba(245, 158, 11, .08); color: #fcd34d; border-radius: 10px; }
.legend { display: flex; flex-wrap: wrap; gap: 8px; padding: 6px 26px 0; }
.legend button { display: inline-flex; align-items: center; gap: 8px; background: var(--panel); border: 1px solid var(--line); color: var(--text); border-radius: 999px; padding: 5px 12px; cursor: pointer; font-size: 12px; transition: opacity .2s, border-color .2s; }
.legend button i { width: 18px; height: 3px; border-radius: 2px; display: inline-block; }
.legend button.off { opacity: .35; }
.legend button:hover { border-color: #334155; }
.stage { position: relative; padding: 6px 18px 0; }
svg#stack { width: 100%; height: auto; display: block; max-height: calc(100vh - 170px); }
.zone rect { fill: url(#zoneFill); stroke-width: 1.2; stroke-dasharray: 2 6; }
.zone text { font-size: 12px; font-weight: 700; letter-spacing: 1.6px; text-transform: uppercase; }
.edge path.base { fill: none; stroke-width: 2; opacity: .28; transition: opacity .2s, stroke-width .2s; }
.edge path.flow { fill: none; stroke-width: 2.2; stroke-dasharray: 3 11; opacity: .9; animation: dash 1.4s linear infinite; }
.edge path.flow.rev { animation-direction: reverse; }
.edge circle { filter: url(#glow); }
.edge text { font-size: 11px; fill: #cbd5e1; opacity: 0; transition: opacity .2s; paint-order: stroke; stroke: #070b10; stroke-width: 4px; pointer-events: none; }
.paused .edge path.flow { animation-play-state: paused; }
.paused .edge circle { display: none; }
@keyframes dash { to { stroke-dashoffset: -28; } }
.node { cursor: pointer; transition: opacity .2s; }
.node .halo { opacity: .0; transition: opacity .25s; }
.node .disc { fill: url(#nodeFill); stroke: #263241; stroke-width: 1.4; transition: stroke .2s, transform .2s; }
.node:hover .disc, .node.sel .disc { stroke: #7dd3fc; }
.node:hover .halo, .node.sel .halo { opacity: .55; }
.node .label { font-size: 13px; font-weight: 650; fill: #f1f5f9; text-anchor: middle; }
.node .sub { font-size: 11px; fill: var(--muted); text-anchor: middle; }
.node .status { stroke: #070b10; stroke-width: 3; }
.node .status.ok { fill: var(--ok); } .node .status.warn { fill: var(--warn); } .node .status.bad { fill: var(--bad); } .node .status.idle { fill: var(--idle); }
.node .status.ok.pulse { animation: beat 2.4s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes beat { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.35); } }
.node .badge rect { fill: #0b2a3a; stroke: #0ea5e9; }
.node .badge text { font-size: 10px; font-weight: 700; fill: #7dd3fc; text-anchor: middle; }
.dim .node:not(.hl) { opacity: .28; }
.dim .edge:not(.hl) { opacity: .12; }
.dim .edge.hl path.base { opacity: .75; stroke-width: 3; }
.dim .edge.hl text { opacity: 1; }
.tip { position: absolute; pointer-events: none; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font-size: 12px; max-width: 280px; backdrop-filter: blur(8px); box-shadow: 0 10px 30px rgba(0,0,0,.4); }
.tip b { display: block; font-size: 13px; margin-bottom: 2px; }
.drawer { position: absolute; top: 6px; right: 18px; width: 360px; max-height: calc(100% - 12px); overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 18px; backdrop-filter: blur(12px); box-shadow: 0 20px 60px rgba(0,0,0,.5); animation: slide .2s ease-out; }
@keyframes slide { from { transform: translateX(14px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer .close { float: right; background: none; border: 1px solid var(--line); color: var(--muted); border-radius: 8px; cursor: pointer; padding: 2px 8px; }
.drawer .head { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; }
.drawer .head svg { width: 40px; height: 40px; }
.drawer h2 { margin: 0; font-size: 17px; }
.drawer .sub { color: var(--muted); font-size: 12px; }
.drawer h3 { font-size: 11px; letter-spacing: 1.4px; text-transform: uppercase; color: var(--muted); margin: 16px 0 6px; }
.drawer .addr { display: flex; gap: 6px; align-items: center; }
.drawer code { background: #0b1016; border: 1px solid var(--line); padding: 4px 8px; border-radius: 8px; font-size: 12px; word-break: break-all; flex: 1; }
.drawer .copy { background: #0b1016; border: 1px solid var(--line); color: var(--text); border-radius: 8px; padding: 4px 8px; cursor: pointer; font-size: 11px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; border: 1px solid var(--line); }
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--idle); }
.pill.ok::before { background: var(--ok); } .pill.warn::before { background: var(--warn); } .pill.bad::before { background: var(--bad); }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 4px 10px; font-size: 12px; }
.kv div:nth-child(odd) { color: var(--muted); }
.conns { list-style: none; padding: 0; margin: 0; }
.conns li { display: flex; gap: 8px; align-items: center; padding: 4px 0; font-size: 12px; cursor: pointer; }
.conns li i { width: 14px; height: 3px; border-radius: 2px; flex: none; }
.conns li:hover { color: #7dd3fc; }
.sessions { font-size: 12px; margin: 0; padding-left: 16px; }
.foot { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 6px 26px 18px; color: var(--muted); font-size: 11px; }
.foot code { font-size: 11px; }
@media (max-width: 900px) { .drawer { position: fixed; inset: auto 10px 10px 10px; width: auto; max-height: 60vh; } }
.node:focus { outline: none; }
.node:focus-visible .disc { stroke: #7dd3fc; stroke-width: 2.4; }

/* ---------- Brain Map additions ---------- */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; background: var(--panel); }
.seg button { background: none; border: 0; color: var(--muted); padding: 6px 16px; cursor: pointer; font-size: 13px; font-weight: 600; }
.seg button.on { background: linear-gradient(180deg, #12324a, #0d2233); color: #e0f2fe; }
.view.hidden { display: none !important; }
.bsearch { display: flex; gap: 8px; align-items: center; margin: 6px 26px 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); flex-wrap: wrap; }
.bsearch .lens { color: #7dd3fc; font-size: 18px; padding: 0 4px; }
.bsearch input { flex: 1; min-width: 220px; background: transparent; border: 0; color: var(--text); font-size: 15px; outline: none; }
.bsearch select { background: #0b1016; color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; }
.bsearch button { background: #2563eb; color: white; border: 0; border-radius: 8px; padding: 7px 14px; cursor: pointer; font-weight: 600; }
.bsearch .hint { width: 100%; color: var(--muted); font-size: 11px; padding-left: 30px; }
.brain-stage { height: calc(100vh - 215px); min-height: 560px; }
canvas#brain { width: 100%; height: 100%; display: block; cursor: default; }
.blegend { display: flex; flex-wrap: wrap; gap: 14px; padding: 4px 26px; color: var(--muted); font-size: 12px; }
.blegend span { display: inline-flex; align-items: center; gap: 6px; }
.blegend i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; box-shadow: 0 0 8px currentColor; }
.results { list-style: none; padding: 0; margin: 0; }
.results li { padding: 9px 10px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; cursor: pointer; background: rgba(11, 16, 22, .6); }
.results li:hover { border-color: #38bdf8; }
.results .rp { font-size: 11px; color: #7dd3fc; font-family: ui-monospace, Menlo, monospace; word-break: break-all; }
.results .rt { font-weight: 650; margin: 2px 0; }
.results .rs { font-size: 12px; color: #aab6c3; white-space: pre-wrap; max-height: 5.6em; overflow: hidden; }
.kindtag { font-size: 10px; text-transform: uppercase; letter-spacing: 1px; padding: 1px 6px; border-radius: 6px; border: 1px solid var(--line); color: var(--muted); margin-left: 6px; }
.note { white-space: pre-wrap; font-size: 12px; background: #0b1016; border: 1px solid var(--line); border-radius: 10px; padding: 10px; max-height: 52vh; overflow: auto; }
.statgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; background: rgba(11,16,22,.6); }
.stat b { display: block; font-size: 18px; }
.stat span { font-size: 11px; color: var(--muted); }
.bar { height: 6px; border-radius: 6px; background: #1f2a36; overflow: hidden; margin-top: 4px; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, #0ea5e9, #22c55e); }
.mini { width: 100%; border-collapse: collapse; font-size: 12px; }
.mini td, .mini th { padding: 4px 6px; border-bottom: 1px solid var(--line); text-align: left; }
.linkbtn { background: #0b1016; border: 1px solid var(--line); color: var(--text); border-radius: 8px; padding: 5px 10px; cursor: pointer; font-size: 12px; margin: 4px 6px 0 0; }
.linkbtn:hover { border-color: #38bdf8; }
.list { list-style: none; padding: 0; margin: 0; font-size: 12px; }
.list li { padding: 5px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.list li:hover { color: #7dd3fc; }
.list li small { color: var(--muted); }
