:root {
  --bg-void: #07080C;
  --bg-space: #0B0C12;
  --surface-1: #12141C;
  --surface-2: #171A24;
  --line: #252A38;
  --line-soft: #1B1F2B;
  --text-hi: #F5F7FB;
  --text-mid: #9AA4B8;
  --text-low: #5C6678;
  --accent: #F97316;
  --accent-soft: rgba(249,115,22,0.12);
  --ok: #34D399;
  --danger: #F43F5E;
  --font-ui: 'Inter', ui-sans-serif, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
  --topbar: 56px;
  --rail: 64px;
  --sidebar: 300px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg-void); color: var(--text-hi); font-family: var(--font-ui); font-size: 14px; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
[data-lucide], svg.lucide { stroke-width: 1.5; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- App grid ---------- */
#app { display: grid; grid-template-rows: var(--topbar) 1fr; grid-template-columns: var(--rail) auto 1fr; height: 100vh; width: 100vw; }
#app.sb-collapsed { --sidebar: 0px; }

/* ---------- Top bar ---------- */
.topbar { grid-column: 1 / -1; display: flex; align-items: center; gap: 16px; padding: 0 16px 0 18px; border-bottom: 1px solid var(--line-soft); background: var(--bg-void); position: relative; z-index: 30; }
.gsearch { flex: 1; max-width: 460px; margin: 0 auto; height: 34px; border: 1px solid var(--line); border-radius: 999px; display: flex; align-items: center; gap: 8px; padding: 0 8px 0 14px; color: var(--text-low); background: var(--bg-space); transition: border-color .15s; }
.gsearch:hover { border-color: var(--line-hover); color: var(--text-mid); }
.gsearch .lbl { flex: 1; text-align: left; font-size: 13px; }
.kbd { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-mid); border: 1px solid var(--line); border-radius: 5px; padding: 2px 6px; background: var(--surface-1); }
.tb-right { display: flex; align-items: center; gap: 8px; }
.livebadge { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-mid); padding: 0 12px; height: 32px; border-radius: 999px; border: 1px solid var(--line-soft); }
.livedot { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 0 rgba(52,211,153,.6); animation: live 2s infinite; }
@keyframes live { 0% { box-shadow: 0 0 0 0 rgba(52,211,153,.55); } 70% { box-shadow: 0 0 0 7px rgba(52,211,153,0); } 100% { box-shadow: 0 0 0 0 rgba(52,211,153,0); } }
.tbtn { height: 32px; min-width: 32px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--line); color: var(--text-mid); font-size: 12.5px; transition: background .15s, color .15s, border-color .15s; }
.tbtn:hover { background: var(--surface-2); color: var(--text-hi); }
.tbtn.icon { padding: 0; width: 32px; }
.tbtn.notify { border-color: rgba(249,115,22,.45); color: var(--text-hi); box-shadow: 0 0 0 1px rgba(249,115,22,.12) inset, 0 0 18px rgba(249,115,22,.12); }
.tbtn .count { min-width: 17px; height: 17px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 10.5px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; padding: 0 4px; }
.vaultsel { height: 32px; display: inline-flex; align-items: center; gap: 8px; padding: 0 10px 0 4px; border-radius: 999px; border: 1px solid var(--line); font-size: 12.5px; }
.vaultsel .av { width: 24px; height: 24px; border-radius: 50%; background: linear-gradient(135deg, #2b3245, #171a24); border: 1px solid var(--line); display: grid; place-items: center; font-size: 10px; font-weight: 600; color: var(--text-mid); }
.vaultsel .n { color: var(--text-low); font-family: var(--font-mono); font-size: 11px; }


/* ---------- Sidebar ---------- */
.sidebar { grid-row: 2; width: var(--sidebar); overflow: hidden; border-right: 1px solid var(--line-soft); background: var(--bg-void); display: flex; flex-direction: column; transition: width .25s ease; z-index: 15; }
.sb-inner { width: 300px; display: flex; flex-direction: column; height: 100%; min-height: 0; }
.sb-head { padding: 14px 14px 10px; display: flex; flex-direction: column; gap: 10px; }
.sb-title { display: flex; align-items: center; justify-content: space-between; }
.ptitle { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--text-low); font-weight: 600; }
.sb-acts { display: flex; gap: 2px; }
.gbtn { width: 26px; height: 26px; border-radius: 6px; display: inline-grid; place-items: center; color: var(--text-low); transition: background .15s, color .15s; }
.gbtn:hover { background: var(--surface-2); color: var(--text-hi); }
.gbtn svg { width: 15px; height: 15px; }
.sinput { height: 32px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface-1); display: flex; align-items: center; gap: 8px; padding: 0 10px; color: var(--text-low); }
.sinput svg { width: 14px; height: 14px; flex: none; }
.sinput input { flex: 1; min-width: 0; background: none; border: 0; outline: 0; font-size: 13px; color: var(--text-hi); }
.sinput input::placeholder { color: var(--text-low); }
.segtabs { display: flex; gap: 6px; }
.segtab { height: 24px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); font-size: 11.5px; color: var(--text-mid); }
.segtab.on { border-color: rgba(249,115,22,.5); color: var(--accent); background: var(--accent-soft); }
.ingestbar { margin: 0 14px 8px; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 11.5px; color: var(--text-mid); display: none; flex-direction: column; gap: 6px; background: var(--surface-1); }
.ingestbar.on { display: flex; }
.ingestbar .url { font-family: var(--font-mono); color: var(--text-hi); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 11px; }
.ingestbar .track { height: 2px; background: var(--line); border-radius: 2px; overflow: hidden; }
.ingestbar .track i { display: block; height: 100%; width: 0; background: #38BDF8; transition: width .2s linear; }
.tree { flex: 1; overflow-y: auto; padding: 0 8px 8px; min-height: 0; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.trow { position: relative; display: flex; align-items: center; gap: 8px; height: 30px; padding: 0 8px 0 6px; border-radius: 6px; font-size: 13px; color: var(--text-mid); cursor: pointer; user-select: none; width: 100%; text-align: left; }
.trow:hover { background: var(--surface-2); color: var(--text-hi); }
.trow .chev { width: 14px; height: 14px; color: var(--text-low); transition: transform .15s; flex: none; }
.trow.open .chev { transform: rotate(90deg); }
.trow .ti { width: 15px; height: 15px; flex: none; }
.trow .nm { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trow .ct { font-family: var(--font-mono); font-size: 11px; color: var(--text-low); }
.trow.leaf { padding-left: 28px; height: 28px; font-size: 12.5px; }
.trow.leaf .dot { width: 6px; height: 6px; border-radius: 50%; flex: none; }
.trow.sel { background: var(--surface-2); color: var(--text-hi); }
.trow.sel::before { content: ''; position: absolute; left: 0; top: 5px; bottom: 5px; width: 2px; border-radius: 2px; background: var(--c, var(--accent)); }
.trow.dim { opacity: .55; }
.tree .more { padding: 4px 8px 6px 28px; font-size: 11.5px; color: var(--text-low); }
.sb-foot { border-top: 1px solid var(--line-soft); padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 10px; }
.cap { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--text-mid); }
.capbar { height: 3px; border-radius: 3px; background: var(--line); overflow: hidden; }
.capbar i { display: block; height: 100%; width: 12%; background: var(--accent); }
.pbtn { height: 34px; border-radius: 8px; border: 1px solid var(--line); display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-size: 13px; color: var(--text-hi); background: var(--surface-1); transition: background .15s, border-color .15s; }
.pbtn:hover { background: var(--surface-2); border-color: var(--line-hover); }
.pbtn.primary { border-color: rgba(249,115,22,.55); background: var(--accent-soft); color: var(--accent-ink); }
.pbtn.primary:hover { background: rgba(249,115,22,.2); }
.pbtn svg { width: 15px; height: 15px; }

/* ---------- Stage ---------- */
.stage { grid-row: 2; position: relative; overflow: hidden; background: var(--bg-space); min-width: 0; }
.stage::before { content: ''; position: absolute; inset: 0; background: radial-gradient(60% 60% at 50% 48%, rgba(56,189,248,0.06), transparent 70%), radial-gradient(40% 35% at 50% 52%, rgba(167,139,250,0.05), transparent 70%); pointer-events: none; }
.stage::after { content: ''; position: absolute; inset: 0; pointer-events: none; opacity: .03; z-index: 1; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>"); }
#brain { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: default; }
#brain.grab { cursor: grabbing; }
#brain.pointer { cursor: pointer; }
#brain.link { cursor: crosshair; }
.ov { position: absolute; z-index: 5; }
.crumb { top: 14px; left: 16px; font-size: 12px; color: var(--text-low); display: flex; align-items: center; gap: 6px; }
.crumb b { color: var(--text-mid); font-weight: 500; }
.crumb svg { width: 12px; height: 12px; }
.ghosts { top: 10px; right: 14px; display: flex; gap: 6px; }
.ghost { width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--line); background: var(--overlay); color: var(--text-mid); display: grid; place-items: center; transition: background .15s, color .15s, border-color .15s; position: relative; }
.ghost:hover { color: var(--text-hi); background: var(--surface-2); }
.ghost.on { color: var(--accent); border-color: rgba(249,115,22,.45); background: var(--accent-soft); }
.ghost svg { width: 16px; height: 16px; }
.ghost[data-tip]:hover::after { content: attr(data-tip); position: absolute; top: 40px; right: 0; white-space: nowrap; font-size: 11px; color: var(--text-hi); background: var(--surface-2); border: 1px solid var(--line); padding: 4px 8px; border-radius: 6px; pointer-events: none; }
.layoutmenu { position: absolute; top: 40px; right: 0; width: 210px; background: var(--surface-1); border: 1px solid var(--line); border-radius: 10px; padding: 6px; display: none; z-index: 9; }
.layoutmenu.on { display: block; }
.lm { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px; border-radius: 6px; font-size: 12.5px; color: var(--text-mid); text-align: left; }
.lm:hover { background: var(--surface-2); color: var(--text-hi); }
.lm.on { color: var(--accent); }
.lm .k { margin-left: auto; }
.lm svg { width: 15px; height: 15px; }

/* filter bar */
.filters { top: 58px; left: 50%; transform: translateX(-50%); height: 40px; display: flex; align-items: center; gap: 4px; padding: 0 6px; border: 1px solid var(--line-soft); border-radius: 999px; background: var(--overlay); white-space: nowrap; max-width: calc(100% - 32px); overflow-x: auto; scrollbar-width: none; }
.chip { height: 28px; display: inline-flex; align-items: center; gap: 6px; padding: 0 8px; border-radius: 999px; font-size: 11.5px; color: var(--text-mid); position: relative; transition: background .15s, color .15s, opacity .15s; }
.chip:hover { background: var(--surface-2); color: var(--text-hi); }
.chip i { width: 7px; height: 7px; border-radius: 50%; background: var(--c); box-shadow: 0 0 8px var(--c); }
.chip.off { opacity: .4; }
.chip.off i { box-shadow: none; background: transparent; border: 1px solid var(--c); }
.chip.off::after { content: ''; position: absolute; left: 8px; right: 8px; top: 50%; height: 1px; background: var(--text-low); transform: rotate(-8deg); }
.fsep { width: 1px; height: 18px; background: var(--line); margin: 0 4px; }
.fsel { height: 28px; border-radius: 999px; border: 1px solid transparent; background: transparent; color: var(--text-mid); font-size: 11.5px; padding: 0 22px 0 10px; appearance: none; -webkit-appearance: none; cursor: pointer; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%235C6678' stroke-width='2'><path d='m6 9 6 6 6-6'/></svg>"); background-repeat: no-repeat; background-position: right 8px center; }
.fsel:hover { background-color: var(--surface-2); color: var(--text-hi); }
.fsel:disabled { opacity: .35; cursor: not-allowed; }
.fsel option { background: var(--surface-1); }
.ftog { height: 28px; padding: 0 10px; border-radius: 999px; font-size: 11.5px; color: var(--text-mid); display: inline-flex; align-items: center; gap: 6px; }
.ftog:hover { background: var(--surface-2); color: var(--text-hi); }
.ftog.on { background: var(--accent-soft); color: var(--accent); }
.ftog svg { width: 13px; height: 13px; }

/* legend */
.legend { left: 16px; bottom: 20px; border: 1px solid var(--line-soft); border-radius: 10px; background: var(--overlay); padding: 8px 10px; font-size: 11.5px; color: var(--text-mid); min-width: 150px; }
.legend .lh { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; }
.legend .lh svg { width: 13px; height: 13px; color: var(--text-low); transition: transform .2s; }
.legend.closed .lh svg { transform: rotate(180deg); }
.legend ul { list-style: none; margin: 8px 0 2px; padding: 0; display: grid; gap: 5px; }
.legend.closed ul { display: none; }
.legend li { display: flex; align-items: center; gap: 8px; }
.legend li svg { width: 12px; height: 12px; }
.legend li .n { margin-left: auto; color: var(--text-low); font-family: var(--font-mono); font-size: 10.5px; }
.legend .orph { border-top: 1px solid var(--line-soft); padding-top: 6px; margin-top: 2px; }
.legend .orph i { width: 10px; height: 10px; border-radius: 50%; border: 1px dashed var(--text-mid); display: inline-block; }

/* HUD */
.hud { left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; align-items: stretch; border-radius: 16px; border: 1px solid var(--glass-line); background: var(--glass); backdrop-filter: blur(14px) saturate(1.2); -webkit-backdrop-filter: blur(14px) saturate(1.2); box-shadow: 0 0 0 1px rgba(255,255,255,.02) inset, 0 12px 40px var(--shadow-c); }
.hud button { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 10px 22px; gap: 2px; }
.hud button + button { border-left: 1px solid var(--glass-line); }
.hud .v { font-family: var(--font-mono); font-size: 24px; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; }
.hud .l { font-size: 10px; letter-spacing: .14em; color: var(--text-mid); }
.hud .status { flex-direction: row; gap: 8px; font-size: 11px; letter-spacing: .14em; color: var(--text-hi); }
.hud .status i { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); animation: live 2s infinite; }
.hud .status.err i { background: var(--danger); animation: none; }
.hud button:hover .l { color: var(--text-hi); }
.agents { left: 50%; bottom: 100px; transform: translateX(-50%) translateY(8px); width: 440px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-1); padding: 12px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; }
.agents.on { opacity: 1; pointer-events: auto; transform: translateX(-50%); }
.agents .ag { display: grid; grid-template-columns: 10px 1fr auto; gap: 10px; align-items: center; padding: 6px 4px; font-size: 12.5px; color: var(--text-mid); border-bottom: 1px solid var(--line-soft); }
.agents .ag:last-child { border: 0; }
.agents .ag i { width: 7px; height: 7px; border-radius: 50%; }
.agents .ag .s { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-low); }
.agents .grid { display: grid; grid-template-columns: 1fr 1fr; column-gap: 16px; margin-top: 8px; }

/* tooltip */
.tip { position: absolute; z-index: 8; pointer-events: none; width: 280px; border: 1px solid var(--glass-line); border-radius: 10px; background: var(--glass); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); padding: 10px 12px; opacity: 0; transform: translateY(4px); transition: opacity .12s, transform .12s; }
.tip.on { opacity: 1; transform: none; }
.tip .tt { font-size: 10px; letter-spacing: .14em; text-transform: uppercase; display: flex; align-items: center; gap: 6px; }
.tip .tt svg { width: 12px; height: 12px; }
.tip .th { font-size: 13.5px; font-weight: 600; margin: 4px 0 4px; line-height: 1.35; }
.tip .tx { font-size: 12px; color: var(--text-mid); line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tip .tm { margin-top: 6px; font-size: 10.5px; color: var(--text-low); display: flex; gap: 10px; }

/* inspector */
.inspector { position: absolute; top: 0; right: 0; bottom: 0; width: 380px; z-index: 12; background: var(--panel-solid); border-left: 1px solid var(--line); display: flex; flex-direction: column; transform: translateX(102%); transition: transform .28s cubic-bezier(.2,.7,.2,1); }
.inspector.on { transform: none; }
.ins-head { padding: 16px 18px 14px; border-bottom: 1px solid var(--line-soft); }
.ins-type { display: flex; align-items: center; gap: 7px; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; }
.ins-type svg { width: 13px; height: 13px; }
.ins-type .x { margin-left: auto; }
.ins-title { font-size: 16px; font-weight: 600; line-height: 1.4; margin: 8px 0 4px; text-wrap: pretty; }
.ins-path { font-family: var(--font-mono); font-size: 11px; color: var(--text-low); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ins-meta { display: grid; grid-template-columns: repeat(4,1fr); border-bottom: 1px solid var(--line-soft); }
.ins-meta div { padding: 12px 0 12px 18px; display: flex; flex-direction: column; gap: 3px; }
.ins-meta div + div { border-left: 1px solid var(--line-soft); padding-left: 12px; }
.ins-meta b { font-family: var(--font-mono); font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }
.ins-meta span { font-size: 10px; color: var(--text-low); letter-spacing: .04em; }
.ins-tabs { display: flex; gap: 2px; padding: 0 12px; border-bottom: 1px solid var(--line-soft); }
.ins-tab { padding: 11px 8px; font-size: 12.5px; color: var(--text-low); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.ins-tab:hover { color: var(--text-hi); }
.ins-tab.on { color: var(--text-hi); border-color: var(--accent); }
.ins-body { flex: 1; overflow-y: auto; padding: 16px 18px; font-size: 14px; line-height: 1.65; color: var(--text-mid); scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.ins-body h4 { margin: 0 0 6px; font-size: 11px; letter-spacing: .14em; color: var(--text-low); text-transform: uppercase; font-weight: 600; }
.ins-body p { margin: 0 0 12px; }
.ins-body .tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.ins-body .tag { font-family: var(--font-mono); font-size: 11px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--text-mid); }
.ins-body .linkbtn { color: var(--accent-ink); font-size: 12.5px; display: inline-flex; gap: 6px; align-items: center; }
.syn { display: grid; grid-template-columns: 16px 1fr 56px; gap: 10px; align-items: center; padding: 8px 6px; border-radius: 6px; cursor: pointer; font-size: 12.5px; }
.syn:hover { background: var(--surface-2); }
.syn svg { width: 14px; height: 14px; color: var(--text-low); }
.syn .sn { color: var(--text-hi); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.syn .sr { font-size: 10.5px; color: var(--text-low); display: block; }
.syn .wb { height: 3px; border-radius: 3px; background: var(--line); overflow: hidden; }
.syn .wb i { display: block; height: 100%; }
.syn.contra .sr { color: var(--danger); }
.src { border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-bottom: 10px; cursor: pointer; }
.src:hover { background: var(--surface-2); }
.src .d { font-family: var(--font-mono); font-size: 11px; color: var(--text-low); }
.src .t { color: var(--text-hi); font-size: 13px; margin-top: 2px; line-height: 1.45; }
.hist { position: relative; padding-left: 18px; }
.hist::before { content: ''; position: absolute; left: 4px; top: 6px; bottom: 6px; width: 1px; background: var(--line); }
.hist .h { position: relative; padding: 0 0 14px; font-size: 12.5px; }
.hist .h::before { content: ''; position: absolute; left: -18px; top: 6px; width: 9px; height: 9px; border-radius: 50%; background: var(--surface-1); border: 1px solid var(--text-low); }
.hist .h:first-child::before { border-color: var(--accent); background: var(--accent-soft); }
.hist .h b { color: var(--text-hi); font-weight: 500; }
.hist .h span { display: block; font-family: var(--font-mono); font-size: 10.5px; color: var(--text-low); }
.ins-foot { border-top: 1px solid var(--line-soft); padding: 12px 18px 16px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ins-foot .pbtn:first-child { grid-column: 1 / -1; }
.conf { display: flex; align-items: center; gap: 8px; }
.conf .bar { flex: 1; height: 3px; background: var(--line); border-radius: 3px; overflow: hidden; }
.conf .bar i { display: block; height: 100%; background: #60A5FA; }

/* reader */
.reader { position: absolute; inset: 24px; z-index: 14; display: none; justify-content: center; }
.reader.on { display: flex; }
.reader .card { width: min(720px, 100%); height: 100%; background: var(--surface-1); border: 1px solid var(--line); border-radius: 10px; display: flex; flex-direction: column; overflow: hidden; }
.reader .rh { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line-soft); font-family: var(--font-mono); font-size: 11.5px; color: var(--text-low); }
.reader .rh .x { margin-left: auto; }
.reader .rb { flex: 1; overflow-y: auto; padding: 28px 40px 40px; color: var(--text-mid); line-height: 1.7; font-size: 14.5px; }
.reader h1 { color: var(--text-hi); font-size: 24px; line-height: 1.3; font-weight: 600; margin: 0 0 18px; text-wrap: pretty; }
.reader h3 { color: var(--text-hi); font-size: 14px; font-weight: 600; margin: 24px 0 8px; }
.reader pre { font-family: var(--font-mono); font-size: 12px; background: var(--bg-space); border: 1px solid var(--line-soft); border-radius: 8px; padding: 12px 14px; color: var(--text-mid); white-space: pre-wrap; margin: 0 0 18px; }
.reader .wl { color: var(--link); cursor: pointer; }
.reader .wl:hover { text-decoration: underline; }
.reader ul { padding-left: 18px; }

/* modal search */
.scrim { position: absolute; inset: 0; z-index: 40; background: var(--scrim); display: none; align-items: flex-start; justify-content: center; padding-top: 12vh; }
.scrim.on { display: flex; }
.palette { width: 600px; max-width: calc(100vw - 32px); background: var(--surface-1); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; box-shadow: 0 30px 80px var(--shadow-c); }
.palette .pin { display: flex; align-items: center; gap: 10px; padding: 0 16px; height: 52px; border-bottom: 1px solid var(--line-soft); color: var(--text-low); }
.palette .pin input { flex: 1; background: none; border: 0; outline: 0; font-size: 15px; color: var(--text-hi); }
.palette .res { max-height: 420px; overflow-y: auto; padding: 6px; }
.palette .ri { display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; align-items: center; width: 100%; padding: 8px 10px; border-radius: 8px; text-align: left; }
.palette .ri.on, .palette .ri:hover { background: var(--surface-2); }
.palette .ri .th { width: 28px; height: 28px; border-radius: 7px; display: grid; place-items: center; background: color-mix(in oklab, var(--c) 14%, transparent); color: var(--c); border: 1px solid color-mix(in oklab, var(--c) 30%, transparent); }
.palette .ri .th svg { width: 14px; height: 14px; }
.palette .ri .t1 { font-size: 13.5px; color: var(--text-hi); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette .ri .t1 mark { background: none; color: var(--accent); }
.palette .ri .t2 { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-low); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette .ri .k { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-low); }
.palette .empty { padding: 18px 16px 8px; font-size: 13px; color: var(--text-mid); }
.palette .pf { display: flex; gap: 16px; padding: 10px 16px; border-top: 1px solid var(--line-soft); font-size: 11px; color: var(--text-low); }

/* keys overlay */
.keys { width: 520px; background: var(--surface-1); border: 1px solid var(--line); border-radius: 12px; padding: 20px 22px; }
.keys h3 { margin: 0 0 14px; font-size: 11px; letter-spacing: .14em; color: var(--text-low); font-weight: 600; }
.keys dl { display: grid; grid-template-columns: 140px 1fr; gap: 10px 16px; margin: 0; font-size: 13px; }
.keys dt { text-align: right; }
.keys dd { margin: 0; color: var(--text-mid); }

/* popovers */
.relpop { position: absolute; z-index: 30; width: 220px; background: var(--surface-1); border: 1px solid var(--line); border-radius: 10px; padding: 6px; display: none; box-shadow: 0 16px 40px var(--shadow-c); }
.relpop.on { display: block; }
.relpop .ph { font-size: 11px; color: var(--text-low); padding: 6px 8px 8px; line-height: 1.4; }
.relpop button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 8px; border-radius: 6px; font-size: 12.5px; color: var(--text-mid); }
.relpop button:hover { background: var(--surface-2); color: var(--text-hi); }
.relpop button svg { width: 14px; height: 14px; }
.actionbar { position: absolute; z-index: 20; display: none; align-items: center; gap: 4px; padding: 5px; border-radius: 12px; background: var(--surface-1); border: 1px solid var(--line); box-shadow: 0 16px 40px var(--shadow-c); }
.actionbar.on { display: flex; }
.actionbar .cnt { font-family: var(--font-mono); font-size: 11.5px; color: var(--text-mid); padding: 0 10px 0 8px; border-right: 1px solid var(--line); margin-right: 2px; }
.actionbar button { height: 30px; padding: 0 10px; border-radius: 7px; font-size: 12.5px; color: var(--text-mid); display: inline-flex; align-items: center; gap: 6px; }
.actionbar button:hover { background: var(--surface-2); color: var(--text-hi); }
.actionbar button svg { width: 14px; height: 14px; }
.notifs { position: absolute; top: 48px; right: 150px; width: 340px; z-index: 50; background: var(--surface-1); border: 1px solid var(--line); border-radius: 12px; padding: 8px; display: none; box-shadow: 0 20px 50px var(--shadow-c); }
.notifs.on { display: block; }
.notifs .nh { padding: 6px 8px 8px; }
.notifs button { display: grid; grid-template-columns: 18px 1fr; gap: 10px; text-align: left; width: 100%; padding: 9px 8px; border-radius: 8px; font-size: 12.5px; color: var(--text-mid); line-height: 1.45; }
.notifs button:hover { background: var(--surface-2); }
.notifs button b { color: var(--text-hi); font-weight: 500; display: block; }
.notifs button svg { width: 15px; height: 15px; margin-top: 2px; }
.notifs button span { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-low); }

/* states */
.boot { inset: 0; display: flex; align-items: flex-end; justify-content: center; padding-bottom: 120px; pointer-events: none; font-family: var(--font-mono); font-size: 12px; color: var(--text-mid); letter-spacing: .04em; transition: opacity .4s; }
.boot.off { opacity: 0; }
.banner { top: 104px; left: 50%; transform: translateX(-50%); display: none; align-items: center; gap: 10px; height: 32px; padding: 0 6px 0 12px; border-radius: 999px; border: 1px solid rgba(244,63,94,.4); background: rgba(244,63,94,.1); font-size: 12px; color: var(--bad-ink); }
.banner.on { display: flex; }
.banner svg { width: 14px; height: 14px; }
.banner button { height: 22px; padding: 0 10px; border-radius: 999px; background: rgba(244,63,94,.18); color: var(--bad-ink); font-size: 11.5px; }
.emptyst { inset: 0; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 14px; text-align: center; pointer-events: none; padding-top: 140px; }
.emptyst.on { display: flex; }
.emptyst p { margin: 0; color: var(--text-mid); font-size: 13.5px; max-width: 340px; line-height: 1.6; }
.emptyst .pbtn { pointer-events: auto; padding: 0 16px; }
.toast { position: absolute; z-index: 60; left: 50%; bottom: 104px; transform: translateX(-50%) translateY(10px); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 8px 16px; font-size: 12.5px; color: var(--text-hi); white-space: nowrap; }
.toast.on { opacity: 1; transform: translateX(-50%); }
.fps { top: 104px; right: 14px; font-family: var(--font-mono); font-size: 11px; color: var(--text-mid); background: var(--overlay); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; line-height: 1.6; display: none; min-width: 150px; }
.fps.on { display: block; }
.fps b { color: var(--ok); font-size: 18px; font-weight: 600; }

/* list view (a11y alternative) */
.listview { position: absolute; inset: 104px 16px 96px; z-index: 6; display: none; background: var(--panel-solid); border: 1px solid var(--line); border-radius: 10px; overflow: auto; }
.listview.on { display: block; }
.listview table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.listview th { position: sticky; top: 0; background: var(--surface-1); text-align: left; font-size: 10.5px; letter-spacing: .12em; color: var(--text-low); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); text-transform: uppercase; }
.listview td { padding: 8px 12px; border-bottom: 1px solid var(--line-soft); color: var(--text-mid); }
.listview tr:hover td { background: var(--surface-2); color: var(--text-hi); cursor: pointer; }
.listview td.mono { font-size: 11.5px; }

/* tweaks */
.tweaks { position: fixed; right: 16px; bottom: 16px; z-index: 100; width: 260px; background: var(--surface-1); border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: none; box-shadow: 0 20px 60px var(--shadow-c); }
.tweaks.on { display: block; }
.tweaks h5 { margin: 0 0 12px; display: flex; justify-content: space-between; align-items: center; font-size: 12px; font-weight: 600; }
.tweaks .tr { margin-bottom: 12px; }
.tweaks .tr > label { display: block; font-size: 10.5px; letter-spacing: .12em; color: var(--text-low); text-transform: uppercase; margin-bottom: 6px; }
.tweaks .seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.tweaks .seg button { font-size: 11.5px; padding: 6px 4px; color: var(--text-mid); }
.tweaks .seg button + button { border-left: 1px solid var(--line); }
.tweaks .seg button.on { background: var(--accent-soft); color: var(--accent); }
.tweaks .chk { display: flex; align-items: center; justify-content: space-between; font-size: 12.5px; color: var(--text-mid); padding: 3px 0; }

/* responsive */
@media (max-width: 1023px) {
  #app { grid-template-columns: var(--rail) 1fr; }
  .sidebar { position: fixed; left: var(--rail); top: var(--topbar); bottom: 0; width: 300px; transform: translateX(-110%); transition: transform .25s; z-index: 35; }
  #app.sb-open .sidebar { transform: none; }
  .stage { grid-column: 2; }
  .inspector { top: auto; left: 0; width: auto; height: 70vh; border-left: 0; border-top: 1px solid var(--line); border-radius: 14px 14px 0 0; transform: translateY(102%); }
  .livebadge, .vaultsel .nm { display: none; }
  .filters { overflow-x: auto; scrollbar-width: none; justify-content: flex-start; }
}
@media (max-width: 639px) {
  :root { --rail: 0px; }
  #app { grid-template-columns: 1fr; }
  .stage { grid-column: 1; }
  .sidebar { left: 0; }
  .gsearch .lbl, .gsearch .kbd, .tbtn.notify .t { display: none; }
  .gsearch { flex: 0 0 34px; padding: 0; justify-content: center; margin: 0 0 0 auto; }
  .ghosts .ghost:nth-child(n+4) { display: none; }
  .legend { display: none; }
  .hud .full { display: none; }
  .hud .mini { display: flex !important; }
  .agents { width: calc(100vw - 24px); }
  .agents .grid { grid-template-columns: 1fr; }
}
.hud .mini { display: none !important; font-family: var(--font-mono); font-size: 13px; flex-direction: row; gap: 8px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: 0s !important; }
}
.reduced *, .reduced *::before, .reduced *::after { animation: none !important; }
