/* RadioGate Explorer — dark technical theme, self-contained (no external fonts). */
:root {
  --bg: #0c1016; --bg2: #11161f; --panel: #151b26; --panel2: #1a2130;
  --line: #232c3b; --line2: #2c3648; --text: #dfe6f0; --muted: #8593a8;
  --accent: #4f9dff; --accent2: #37c9a8; --warn: #f0a531;
  --bad: #f2596b; --good: #37c9a8; --purple: #c86bfa;
  --radius: 12px; --mono: ui-monospace, "SF Mono", "Cascadia Code", Consolas, monospace;
  --sans: system-ui, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font-family: var(--sans); font-size: 14px; line-height: 1.5; }
body.no-scroll { overflow: hidden; }
code, .mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.accent { color: var(--accent); }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: .2px; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }

#app { display: grid; grid-template-columns: 264px 1fr; height: 100vh; }

/* sidebar */
#sidebar { background: linear-gradient(180deg, var(--bg2), var(--bg)); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 18px 14px; }
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 6px 16px; }
.brand-mark { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; font-weight: 800; letter-spacing: .5px;
  background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #04121a; box-shadow: 0 6px 18px -6px var(--accent); }
.brand-title { font-weight: 750; font-size: 16px; }
.brand-sub { color: var(--muted); font-size: 12px; letter-spacing: 2px; text-transform: uppercase; }
#nav { display: flex; flex-direction: column; gap: 3px; margin-top: 6px; }
.nav-item { display: flex; align-items: center; gap: 11px; padding: 9px 11px; border-radius: 9px; color: var(--muted); transition: .15s; }
.nav-item:hover { background: var(--panel); color: var(--text); }
.nav-item.active { background: var(--panel2); color: var(--text); box-shadow: inset 2px 0 0 var(--accent); }
.nav-ic { width: 18px; text-align: center; opacity: .9; }
.nav-label { flex: 1; }
.nav-count { font-size: 11px; color: var(--muted); background: var(--panel2); padding: 1px 7px; border-radius: 20px; }
.side-foot { margin-top: auto; padding: 12px 6px 2px; border-top: 1px solid var(--line); }
#stat-line { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
#stat-line b { color: var(--text); }
.hint { font-size: 11px; color: var(--muted); line-height: 1.4; }

/* main */
#main { overflow: auto; padding: 30px 34px 60px; }
.page-head { margin-bottom: 20px; }
.page-head h1 { font-size: 26px; }
.page-sub { color: var(--muted); margin: 8px 0 0; max-width: 900px; }
.lede { color: var(--text); max-width: 860px; font-size: 15px; }
.empty { color: var(--muted); padding: 40px; text-align: center; border: 1px dashed var(--line2); border-radius: var(--radius); background: var(--panel); }

/* chips */
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; padding: 3px 9px; border-radius: 20px; background: var(--panel2); border: 1px solid var(--line2); color: var(--text); }
.chip.cfg { font-family: var(--mono); font-size: 11px; color: var(--accent2); }
.chip.st { font-family: var(--mono); font-size: 11px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 7px; }
.frame-chip { border-color: color-mix(in srgb, var(--accent) 40%, var(--line2)); color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--panel2)); }
.frame-chip:hover { background: color-mix(in srgb, var(--accent) 22%, var(--panel2)); }
.link-chip:hover { border-color: var(--accent); color: var(--accent); }

/* ---- overview / map ---- */
.legend { display: flex; flex-wrap: wrap; gap: 18px; margin: 4px 0 18px; }
.legend-item { font-size: 13px; }
.dot, .legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 7px; vertical-align: middle; }
.map-wrap { position: relative; }
.map-svg { position: absolute; inset: 0; pointer-events: none; z-index: 0; overflow: visible; }
.conn { fill: none; stroke: var(--line2); stroke-width: 1.4; opacity: .5; }
.conn.on { stroke: var(--accent); opacity: .95; stroke-width: 2; }
.conn.off { opacity: .08; }
.map-bands { position: relative; z-index: 1; display: flex; flex-direction: column; gap: 14px; }
.band { border: 1px solid var(--line); border-left: 3px solid var(--layer); border-radius: var(--radius); background: linear-gradient(180deg, var(--panel), var(--bg2)); padding: 12px 14px; }
.band-title { display: flex; align-items: baseline; gap: 12px; margin-bottom: 10px; }
.band-name { font-weight: 700; color: var(--layer); }
.band-tag { color: var(--muted); font-size: 12px; }
.band-row { display: flex; flex-wrap: wrap; gap: 10px; }
.node-card { text-align: left; width: 210px; background: var(--panel2); border: 1px solid var(--line2); border-top: 2px solid var(--layer); border-radius: 10px; padding: 10px 12px; transition: .15s; }
.node-card:hover { transform: translateY(-2px); border-color: var(--layer); box-shadow: 0 8px 22px -12px var(--layer); }
.node-card.dim { opacity: .28; }
.node-card.hot { border-color: var(--layer); box-shadow: 0 0 0 2px color-mix(in srgb, var(--layer) 55%, transparent); }
.node-card.linked { border-color: var(--accent); }
.nc-name { font-weight: 650; margin-bottom: 3px; }
.nc-role { font-size: 12px; color: var(--muted); line-height: 1.35; min-height: 32px; }
.nc-lang { font-size: 11px; color: var(--layer); margin-top: 6px; font-family: var(--mono); }
.map-hint { margin: 14px 2px 0; font-size: 12px; }
.stats-strip { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 26px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 18px; min-width: 120px; }
.stat-n { font-size: 26px; font-weight: 750; color: var(--accent); }
.stat-l { font-size: 12px; color: var(--muted); }

/* ---- drawer ---- */
.drawer { position: fixed; inset: 0; z-index: 50; }
.drawer-scrim { position: absolute; inset: 0; background: rgba(4, 7, 12, .6); backdrop-filter: blur(2px); }
.drawer-panel { position: absolute; top: 0; right: 0; height: 100%; width: min(620px, 94vw); background: var(--bg2); border-left: 1px solid var(--line2); box-shadow: -20px 0 60px -20px #000; overflow: auto; padding: 26px 28px; animation: slideIn .18s ease; }
@keyframes slideIn { from { transform: translateX(30px); opacity: .4; } to { transform: none; opacity: 1; } }
.drawer-close { position: absolute; top: 14px; right: 16px; font-size: 24px; line-height: 1; background: none; color: var(--muted); border: none; }
.drawer-close:hover { color: var(--text); }
.detail-kicker { text-transform: uppercase; letter-spacing: 1.5px; font-size: 11px; color: var(--accent); margin-bottom: 6px; }
.detail h2 { font-size: 22px; margin-bottom: 6px; }
.detail-role { color: var(--muted); }
.kv { display: flex; flex-direction: column; gap: 6px; margin: 16px 0; }
.kv-item { display: grid; grid-template-columns: 130px 1fr; gap: 10px; font-size: 13px; }
.kv-k { color: var(--muted); }
.kv-v { font-family: var(--mono); font-size: 12px; word-break: break-word; }
.d-section { margin-top: 20px; }
.d-section h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin-bottom: 10px; }
.bullets { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; }
.bullets.check { list-style: none; padding-left: 0; }
.bullets.check li { position: relative; padding-left: 24px; }
.bullets.check li::before { content: "✓"; position: absolute; left: 0; color: var(--good); font-weight: 700; }

/* ---- protocol ---- */
.toolbar { margin-bottom: 16px; }
.search { width: 100%; max-width: 460px; background: var(--panel); border: 1px solid var(--line2); border-radius: 9px; padding: 9px 13px; color: var(--text); }
.search:focus { outline: none; border-color: var(--accent); }
.group-h { font-size: 14px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin: 22px 0 12px; }
.cards { display: flex; flex-wrap: wrap; gap: 12px; }
.frame-card { text-align: left; width: 250px; background: var(--panel); border: 1px solid var(--line); border-radius: 11px; padding: 13px 14px; transition: .15s; }
.frame-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 10px 26px -16px var(--accent); }
.fc-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.fc-kind { font-weight: 700; }
.fc-code { font-family: var(--mono); font-size: 11px; color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--panel2)); padding: 1px 7px; border-radius: 6px; }
.fc-code.alt { color: var(--warn); background: color-mix(in srgb, var(--warn) 12%, var(--panel2)); }
.fc-dir { font-size: 12px; color: var(--accent2); font-family: var(--mono); margin-bottom: 6px; }
.fc-when { font-size: 12px; color: var(--muted); min-height: 48px; }
.fc-foot { display: flex; justify-content: space-between; margin-top: 8px; font-size: 11px; }

.bytes { display: flex; flex-wrap: wrap; gap: 6px; }
.byte-cell { min-width: 76px; background: var(--panel2); border: 1px solid var(--line2); border-top: 2px solid var(--accent); border-radius: 8px; padding: 8px 9px; }
.byte-top { display: flex; justify-content: space-between; gap: 6px; align-items: baseline; }
.byte-name { font-weight: 650; font-size: 12px; word-break: break-word; }
.byte-size { font-family: var(--mono); font-size: 10px; color: var(--accent); }
.byte-type { font-family: var(--mono); font-size: 11px; color: var(--accent2); margin: 2px 0; }
.byte-desc { font-size: 11px; color: var(--muted); line-height: 1.35; }
.size-note { color: var(--muted); font-size: 13px; }

/* ---- scenarios ---- */
.scen-layout { display: grid; grid-template-columns: 300px 1fr; gap: 20px; align-items: start; }
.scen-list { display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; max-height: calc(100vh - 130px); overflow: auto; padding-right: 4px; }
.scen-cat { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin: 12px 4px 4px; }
.scen-item { text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; transition: .12s; }
.scen-item:hover { border-color: var(--line2); }
.scen-item.active { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--panel)); }
.si-title { font-weight: 600; font-size: 13px; }
.si-trigger { font-size: 11px; color: var(--muted); margin-top: 2px; }
.scen-stage { min-height: 300px; }
.scen-head h2 { font-size: 20px; }
.scen-trigger { color: var(--muted); margin: 6px 0 14px; }
.lanes { display: grid; grid-template-columns: repeat(var(--n), 1fr); gap: 8px; margin-bottom: 6px; position: sticky; top: 0; background: var(--bg); padding: 6px 0; z-index: 2; }
.lane-head { text-align: center; font-size: 12px; font-weight: 600; color: var(--text); background: var(--panel2); border: 1px solid var(--line2); border-radius: 8px; padding: 7px 4px; }
.player { display: flex; align-items: center; gap: 8px; margin: 10px 0 14px; }
.ctrl { background: var(--panel2); border: 1px solid var(--line2); border-radius: 8px; padding: 7px 13px; font-size: 13px; }
.ctrl:hover { border-color: var(--accent); }
.ctrl.primary { background: var(--accent); color: #04121a; border-color: var(--accent); font-weight: 600; }
.pos { margin-left: auto; color: var(--muted); font-family: var(--mono); font-size: 12px; }
.flow { display: flex; flex-direction: column; gap: 10px; }
.step { display: grid; grid-template-columns: 30px 1fr; gap: 10px; padding: 8px; border-radius: 10px; border: 1px solid transparent; transition: .15s; }
.step.active { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 9%, var(--panel)); }
.step.done { opacity: .62; }
.step-n { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-family: var(--mono); background: var(--panel2); border: 1px solid var(--line2); color: var(--muted); }
.step.active .step-n { background: var(--accent); color: #04121a; border-color: var(--accent); }
.step-body { display: grid; grid-template-columns: repeat(var(--n), 1fr); align-items: center; row-gap: 6px; }
.arrow { grid-row: 1; grid-column: calc(var(--lo) + 1) / calc(var(--hi) + 1); position: relative; display: flex; flex-direction: column; align-items: center; padding: 0 6px; min-height: 34px; justify-content: center; }
.arrow-label { font-size: 12px; font-weight: 600; text-align: center; margin-bottom: 3px; }
.arrow-line { position: relative; width: 100%; height: 2px; background: var(--accent2); border-radius: 2px; }
.arrow.r .arrow-line::after, .arrow.l .arrow-line::after { content: ""; position: absolute; top: 50%; width: 0; height: 0; border: 5px solid transparent; }
.arrow.r .arrow-line::after { right: -1px; transform: translateY(-50%); border-left-color: var(--accent2); }
.arrow.l .arrow-line::after { left: -1px; transform: translateY(-50%); border-right-color: var(--accent2); }
.arrow .frame-chip { margin-top: 5px; }
.step-meta { grid-row: 2; grid-column: 1 / -1; }
.data-pills { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 4px; }
.pill { font-size: 11px; font-family: var(--mono); background: var(--panel2); border: 1px solid var(--line2); border-radius: 6px; padding: 2px 7px; color: var(--text); }
.pill b { color: var(--accent2); font-weight: 600; }
.step-note { font-size: 12px; color: var(--muted); }
.branches { display: flex; flex-direction: column; gap: 7px; }
.branch { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 11px; font-size: 13px; }
.branch-cond { color: var(--warn); }
.branch-arrow { color: var(--muted); }

/* ---- states ---- */
.sm-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px; }
.sm-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.sm-head h2 { font-size: 17px; }
.sm-states { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.sm-state { width: 150px; border-radius: 9px; padding: 9px 10px; border: 1px solid var(--line2); background: var(--panel2); border-top: 2px solid var(--muted); }
.sm-state.k-start { border-top-color: var(--accent); } .sm-state.k-good { border-top-color: var(--good); }
.sm-state.k-warn { border-top-color: var(--warn); } .sm-state.k-bad { border-top-color: var(--bad); }
.sm-name { font-family: var(--mono); font-size: 12px; font-weight: 650; }
.sm-desc { font-size: 11px; color: var(--muted); margin-top: 3px; }
.sm-trans { display: flex; flex-direction: column; gap: 5px; }
.sm-tr { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; font-size: 12px; }
.tr-on { color: var(--muted); font-family: var(--mono); font-size: 11px; }
.tr-act { color: var(--accent2); font-family: var(--mono); font-size: 11px; }

/* ---- security ---- */
.sec-layers { display: flex; flex-direction: column; gap: 8px; }
.sec-layer { display: grid; grid-template-columns: 260px 1fr; gap: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 9px; padding: 10px 13px; }
.sl-link { font-weight: 600; }
.sl-prot { color: var(--muted); }
.prim { width: 240px; background: var(--panel); border: 1px solid var(--line); border-top: 2px solid var(--purple); border-radius: 10px; padding: 12px; }
.prim-name { font-weight: 650; }
.prim-role { font-size: 12px; color: var(--muted); margin: 4px 0 6px; }
.steps-ol { padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.envelope { background: var(--panel2); border: 1px solid var(--line2); border-radius: 9px; padding: 12px 14px; }
.envelope code { color: var(--accent2); word-break: break-all; }
.envelope .muted { margin-top: 6px; font-size: 12px; }
.note-box { margin-top: 18px; background: color-mix(in srgb, var(--warn) 10%, var(--panel)); border: 1px solid color-mix(in srgb, var(--warn) 40%, var(--line2)); border-radius: 9px; padding: 11px 14px; font-size: 13px; }

/* ---- subsystems ---- */
.sub-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px; }
.sub-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.sub-head h2 { font-size: 18px; }
.sub-sum { color: var(--muted); margin: 6px 0 14px; max-width: 820px; }
.algos { display: flex; flex-direction: column; gap: 14px; }
.algo { border-left: 2px solid var(--line2); padding-left: 14px; }
.algo-name { font-weight: 650; margin-bottom: 4px; }
.algo-steps { padding-left: 18px; margin: 6px 0 8px; display: flex; flex-direction: column; gap: 4px; font-size: 13px; }

/* ---- config ---- */
.cfg-group { margin-bottom: 22px; }
.cfg-table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.cfg-table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); padding: 9px 14px; background: var(--bg2); border-bottom: 1px solid var(--line); }
.cfg-table td { padding: 9px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.cfg-table tr:last-child td { border-bottom: none; }
.cfg-table code { color: var(--accent); font-size: 12px; }
.cfg-val { font-family: var(--mono); color: var(--accent2); white-space: nowrap; }
.cfg-val .unit { color: var(--muted); }
.cfg-desc { color: var(--text); font-size: 13px; }
.cfg-desc .src { color: var(--muted); font-size: 11px; }

/* ---- glossary ---- */
.glossary { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 12px; }
.gl-item { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 13px 15px; }
.gl-term { font-weight: 650; color: var(--accent); margin-bottom: 5px; }
.gl-def { font-size: 13px; color: var(--muted); }

/* ---- api ---- */
.group-h.ch-http { color: var(--accent); }
.group-h.ch-ws { color: var(--accent2); }
.group-h.ch-proxy { color: var(--purple); }
.api-holder { display: flex; flex-direction: column; }
.api-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.api-card { text-align: left; background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--line2); border-radius: 11px; padding: 13px 15px; transition: .15s; }
.api-card.ch-http { border-left-color: var(--accent); }
.api-card.ch-ws { border-left-color: var(--accent2); }
.api-card.ch-proxy { border-left-color: var(--purple); }
.api-card:hover { transform: translateY(-2px); box-shadow: 0 10px 26px -16px #000; border-color: var(--line2); }
.ac-top { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; }
.ac-method { font-family: var(--mono); font-size: 10px; font-weight: 700; letter-spacing: .5px; padding: 2px 7px; border-radius: 6px; background: var(--panel2); color: var(--text); border: 1px solid var(--line2); }
.ac-method.m-get { color: var(--accent2); border-color: color-mix(in srgb, var(--accent2) 40%, var(--line2)); }
.ac-method.m-post { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, var(--line2)); }
.ac-method.m-ws { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, var(--line2)); }
.ac-method.m-options { color: var(--muted); }
.ac-dir { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.ac-name { font-weight: 700; font-size: 14px; margin-bottom: 5px; word-break: break-word; }
.ac-purpose { font-size: 12px; color: var(--muted); min-height: 42px; line-height: 1.4; }
.ac-foot { display: flex; justify-content: space-between; gap: 8px; margin-top: 9px; font-size: 11px; }
.ac-foot span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* api drawer */
.api-detail h2 .ac-method { font-size: 12px; vertical-align: middle; margin-right: 4px; }
.json-wrap { margin: 14px 0; }
.json-title { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin-bottom: 6px; }
.json-pre { margin: 0; background: #0a0e14; border: 1px solid var(--line2); border-radius: 9px; padding: 12px 14px; overflow-x: auto; }
.json-pre code { font-family: var(--mono); font-size: 12px; color: #b7c6dd; white-space: pre; line-height: 1.5; }
.api-fields { display: flex; flex-direction: column; gap: 9px; }
.af-item { border-left: 2px solid var(--line2); padding-left: 12px; }
.af-head { display: flex; align-items: baseline; gap: 8px; }
.af-k { color: var(--accent); font-size: 12px; }
.af-t { font-family: var(--mono); font-size: 11px; color: var(--accent2); }
.af-desc { font-size: 12px; color: var(--muted); margin-top: 2px; }
.api-errs { display: flex; flex-direction: column; gap: 6px; }
.ae-item { display: grid; grid-template-columns: minmax(140px, auto) 1fr; gap: 10px; align-items: baseline; }
.ae-code { color: var(--bad); font-size: 12px; }
.ae-when { font-size: 12px; color: var(--muted); }

/* responsive */
@media (max-width: 1000px) {
  #app { grid-template-columns: 1fr; }
  #sidebar { position: sticky; top: 0; z-index: 20; height: auto; flex-direction: row; align-items: center; padding: 10px; overflow-x: auto; }
  .brand { padding: 0 10px 0 4px; } #nav { flex-direction: row; } .side-foot { display: none; }
  .scen-layout { grid-template-columns: 1fr; } .scen-list { position: static; max-height: none; }
}
