:root {
  --bg: #0b1020; --panel: #121a2e; --panel2: #18223a; --line: #24304d; --text: #dbe3f0; --muted: #8592ab;
  --accent: #38bdf8; --accent2: #6366f1; --ok: #22c55e; --warn: #f59e0b; --bad: #ef4444; --violet: #a78bfa;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 13px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; } a:hover { text-decoration: underline; }
h3 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); display: flex; gap: 8px; align-items: center; }
h4 { margin: 14px 0 6px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.muted { color: var(--muted); } .small { font-size: 12px; } .hidden { display: none !important; }
.err { color: var(--bad); }
code, pre { font-family: "JetBrains Mono", ui-monospace, Menlo, monospace; font-size: 12px; }

.btn, button { background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 7px 12px; cursor: pointer; font: inherit; }
.btn:hover, button:hover { border-color: var(--accent); }
.btn:disabled, button:disabled { opacity: .45; cursor: default; }
.btn.primary { background: linear-gradient(135deg, var(--accent2), var(--accent)); border: none; color: #fff; font-weight: 600; }
.btn.ghost { background: transparent; } .btn.small { padding: 3px 9px; font-size: 12px; }
input, select, textarea { background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; font: inherit; width: 100%; }
textarea { resize: vertical; font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }

/* login */
.login-body { display: flex; align-items: center; justify-content: center; }
.login-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 28px; width: 340px; display: flex; flex-direction: column; gap: 12px; }
.login-card label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); }
.login-card button { background: linear-gradient(135deg, var(--accent2), var(--accent)); border: none; color: #fff; font-weight: 600; padding: 9px; }

/* header */
.topbar { height: 50px; display: flex; align-items: center; gap: 24px; padding: 0 16px; border-bottom: 1px solid var(--line); background: var(--panel); }
.brand { font-weight: 800; letter-spacing: .12em; font-size: 15px; color: #fff; }
.brand span { font-weight: 400; letter-spacing: 0; color: var(--muted); }
.tabs { display: flex; gap: 4px; }
.tabs button { background: transparent; border: none; color: var(--muted); padding: 6px 12px; border-radius: 6px; }
.tabs button.active { background: var(--panel2); color: #fff; }
.who { margin-left: auto; display: flex; gap: 12px; align-items: center; color: var(--muted); }
.spend { color: var(--ok); font-family: ui-monospace, monospace; }

main { height: calc(100vh - 50px); }
.tab-pane { display: none; height: 100%; }
.tab-pane.active { display: flex; }

/* triage */
#pane-triage { gap: 1px; background: var(--line); }
.col { background: var(--bg); padding: 14px; overflow: auto; display: flex; flex-direction: column; gap: 10px; }
.col.left { width: 23%; min-width: 260px; }
.col.mid { width: 34%; }
.col.right { flex: 1; }
#alert { flex: 1; min-height: 240px; }
.row { display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seg button { border: none; border-radius: 0; background: transparent; color: var(--muted); }
.seg button.active { background: var(--accent2); color: #fff; }
.chk { display: flex; gap: 6px; align-items: center; color: var(--muted); white-space: nowrap; }
.chk input { width: auto; }
.meter { font-family: ui-monospace, monospace; color: var(--muted); font-size: 12px; min-height: 18px; }

.trace { display: flex; flex-direction: column; gap: 6px; overflow: auto; flex: 1; }
.t-status { color: var(--muted); font-size: 12px; }
.t-error { color: var(--bad); background: #2a1216; border: 1px solid #5b1d25; padding: 6px 8px; border-radius: 6px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.card-h { font-weight: 600; font-size: 12px; margin-bottom: 4px; color: #fff; }
.card.tool { border-left: 3px solid var(--accent2); }
.card.tool-res { border-left: 3px solid var(--accent); }
.card.frame { border-left: 3px solid var(--warn); }
.round { background: var(--accent2); color: #fff; border-radius: 4px; padding: 0 5px; font-size: 11px; margin-right: 4px; }
.args { display: block; color: var(--muted); white-space: pre-wrap; word-break: break-all; }
.why { color: var(--muted); font-size: 11px; margin-left: 18px; }
.tchip { display: inline-block; background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 0 8px; margin: 2px 3px 2px 0; font-size: 11px; }
.tchip.proto { border-color: var(--warn); color: var(--warn); } .tchip.dom { border-color: var(--violet); color: var(--violet); }
.tchip.msg { color: var(--accent); } .tchip.met { color: var(--ok); }
ul.links { margin: 0; padding-left: 16px; } ul.links li { margin: 2px 0; }

.hyp-board { display: flex; flex-direction: column; gap: 4px; }
.hyp { border-radius: 6px; padding: 5px 8px; font-size: 12px; border: 1px solid var(--line); background: var(--panel); }
.hyp .hid { font-weight: 700; color: #fff; } .hyp .hst { float: right; text-transform: uppercase; font-size: 10px; font-weight: 700; }
.hyp.open { border-left: 4px solid var(--warn); } .hyp.open .hst { color: var(--warn); }
.hyp.supported { border-left: 4px solid var(--ok); } .hyp.supported .hst { color: var(--ok); }
.hyp.refuted { border-left: 4px solid var(--bad); opacity: .7; } .hyp.refuted .hst { color: var(--bad); }

.badge { display: inline-block; font-size: 10px; text-transform: uppercase; letter-spacing: .05em; padding: 1px 7px; border-radius: 10px; background: var(--panel2); border: 1px solid var(--line); color: var(--text); }
.cov-full { background: #0f2e1d; border-color: var(--ok); color: var(--ok); }
.cov-partial { background: #2e2410; border-color: var(--warn); color: var(--warn); }
.cov-none { background: #2e1013; border-color: var(--bad); color: var(--bad); }
.dom-security { color: var(--violet); border-color: var(--violet); } .dom-noc { color: var(--accent); border-color: var(--accent); }

.chip { display: inline-block; background: #172554; border: 1px solid #1e40af; color: #93c5fd; border-radius: 10px; padding: 0 7px; font-size: 11px; font-family: ui-monospace, monospace; white-space: nowrap; cursor: pointer; }
.chip:hover { background: #1e3a8a; text-decoration: none; }
.chip.dead { background: var(--panel2); border-color: var(--line); color: var(--muted); cursor: default; }

.md { font-size: 13.5px; line-height: 1.6; }
.md h1, .md h2, .md h3 { color: #fff; text-transform: none; letter-spacing: 0; font-size: 16px; margin: 16px 0 6px; display: block; }
.md h1 { font-size: 19px; } .md h3 { font-size: 14px; }
.md table { border-collapse: collapse; margin: 8px 0; font-size: 12px; }
.md th, .md td { border: 1px solid var(--line); padding: 4px 7px; vertical-align: top; }
.md th { background: var(--panel2); }
.md code { background: var(--panel2); padding: 0 4px; border-radius: 3px; }
.md pre { background: var(--panel2); padding: 8px; border-radius: 6px; overflow: auto; }
.md blockquote { border-left: 3px solid var(--line); margin: 6px 0; padding-left: 10px; color: var(--muted); }

/* drawer */
.drawer { position: fixed; top: 50px; right: 0; bottom: 0; width: 560px; max-width: 95vw; background: var(--panel); border-left: 1px solid var(--line);
  transform: translateX(100%); transition: transform .18s ease; z-index: 20; display: flex; flex-direction: column; box-shadow: -10px 0 30px rgba(0,0,0,.4); }
.drawer.open { transform: none; }
.drawer-head { display: flex; justify-content: space-between; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.drawer-nav { display: flex; gap: 6px; }
.drawer-body { padding: 12px 16px; overflow: auto; flex: 1; }
.drawer-body h2 { margin: 4px 0; font-size: 17px; color: #fff; }
.crumb { color: var(--muted); font-size: 11px; }
.meta, .parent { margin: 4px 0; }
.sec-text { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 8px; }
.ents { display: flex; flex-wrap: wrap; gap: 4px; }
.echip { background: #2e1065; border: 1px solid #6d28d9; color: #ddd6fe; border-radius: 10px; padding: 0 7px; font-size: 11px; cursor: pointer; }
.echip b { color: #a78bfa; font-weight: 600; }

/* graph */
#pane-graph { flex-direction: column; }
.graph-bar { display: flex; gap: 8px; align-items: center; padding: 8px 14px; border-bottom: 1px solid var(--line); background: var(--panel); }
.graph-bar input { width: 300px; }
#cy { flex: 1; background: radial-gradient(circle at 50% 40%, #111a33, var(--bg)); }
.legend { display: flex; gap: 6px; align-items: center; color: var(--muted); font-size: 12px; }
.lg { display: inline-block; width: 11px; height: 11px; margin-left: 6px; }
.lg.doc { background: #f59e0b; border-radius: 2px; } .lg.sec { background: #38bdf8; border-radius: 50%; } .lg.ent { background: #a78bfa; transform: rotate(45deg); }

/* chat */
.chat-wrap { display: flex; flex-direction: column; width: 100%; max-width: 980px; margin: 0 auto; padding: 14px; gap: 8px; }
.chat-log { flex: 1; overflow: auto; display: flex; flex-direction: column; gap: 10px; }
.msg { padding: 10px 14px; border-radius: 10px; max-width: 88%; }
.msg.user { align-self: flex-end; background: #1e1b4b; border: 1px solid #3730a3; white-space: pre-wrap; }
.msg.assistant { align-self: flex-start; background: var(--panel); border: 1px solid var(--line); }
.chat-trace { min-height: 18px; font-size: 12px; }
.chat-form { display: flex; gap: 8px; }
.chat-form textarea { height: 70px; font-family: inherit; font-size: 13px; }
.col-btns { display: flex; flex-direction: column; gap: 6px; }

/* library */
.lib { display: flex; width: 100%; gap: 1px; background: var(--line); }
.lib-left { flex: 1.3; background: var(--bg); padding: 14px; overflow: auto; }
.lib-right { flex: 1; background: var(--bg); padding: 14px; overflow: auto; }
.drop { border: 2px dashed var(--line); border-radius: 10px; padding: 22px; text-align: center; color: var(--muted); margin-bottom: 10px; }
.drop.over { border-color: var(--accent); background: #0c1a33; }
.link { color: var(--accent); cursor: pointer; }
.job { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; }
.job.done { border-color: var(--ok); } .job.error { border-color: var(--bad); }
.bar { height: 4px; background: var(--panel2); border-radius: 2px; margin: 6px 0; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent2), var(--accent)); transition: width .4s; }
.tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.tbl th { text-align: left; color: var(--muted); font-weight: 500; border-bottom: 1px solid var(--line); padding: 6px; position: sticky; top: 0; background: var(--bg); }
.tbl td { border-bottom: 1px solid #1a2440; padding: 6px; vertical-align: top; }
.tbl tr.clickable { cursor: pointer; } .tbl tr.clickable:hover td { background: var(--panel); }
.trunc { max-width: 460px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toc ul { list-style: none; padding-left: 14px; margin: 0; }
.toc > ul { padding-left: 0; }
.toc li { margin: 1px 0; }
.toc .num { color: var(--muted); font-family: ui-monospace, monospace; font-size: 11px; margin-right: 4px; }
#pane-history { padding: 14px; overflow: auto; display: none; }
#pane-history.active { display: block; }
