:root {
  --bg: #0a0d13; --panel: #121722; --panel-2: #1a2030; --line: #262e40;
  --text: #e6e9ef; --muted: #98a1b3; --accent: #7cc4ff; --r: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); overflow: hidden; font-size: 14px; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

#sky { position: fixed; inset: 0; }
#labels { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
#labels span { position: absolute; transform: translate(-50%, -50%); white-space: nowrap; text-shadow: 0 0 3px var(--bg), 0 0 6px var(--bg), 0 0 10px var(--bg); }
#labels span.disc { font-size: 18px; font-weight: 700; text-transform: uppercase; letter-spacing: .12em; }
#labels span.cl { font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: .07em; opacity: .85; }

.bar { position: fixed; top: 12px; left: 12px; right: 12px; display: flex; gap: 10px; align-items: center; pointer-events: none; z-index: 5; }
.bar > * { pointer-events: auto; }
.brand { font-weight: 650; padding: 8px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); white-space: nowrap; color: var(--text); }
.tabs { display: flex; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 3px; }
.tabs a { padding: 6px 12px; border-radius: 7px; color: var(--muted); white-space: nowrap; display: flex; align-items: center; gap: 6px; }
.tabs a:hover { text-decoration: none; color: var(--text); }
.tabs a.on { background: var(--panel-2); color: var(--text); }
.tabs a i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.search { position: relative; flex: 0 1 340px; min-width: 0; }
#q { width: 100%; padding: 9px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); outline: none; }
#q:focus { border-color: var(--accent); }
#results { position: absolute; top: calc(100% + 4px); left: 0; right: 0; margin: 0; padding: 4px; list-style: none; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); max-height: 60vh; overflow: auto; }
#results li { padding: 7px 9px; border-radius: 6px; cursor: pointer; display: flex; gap: 2px; align-items: baseline; }
#results li.on, #results li:hover { background: var(--panel-2); }
#results li small { color: var(--muted); margin-left: auto; padding-left: 8px; white-space: nowrap; }
.iconbtn { width: 36px; height: 36px; flex: none; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); font-weight: 700; color: var(--muted); }
.iconbtn:hover { color: var(--text); }

.side { position: fixed; top: 64px; right: 12px; bottom: 12px; width: 400px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); overflow: auto; z-index: 6; padding: 16px; }
.close { position: sticky; float: right; top: 0; width: 30px; height: 30px; border: 0; background: var(--panel-2); border-radius: 50%; font-size: 18px; line-height: 1; z-index: 2; margin: -4px -4px 0 6px; }
.side h2 { margin: 0 0 4px; font-size: 21px; line-height: 1.25; }
.side h3 { margin: 20px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.side h3 small { font-weight: 400; margin-left: 4px; }
.desc { margin: 0 0 8px; color: var(--muted); }
.meta { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { border: 1px solid var(--line); background: var(--panel-2); border-radius: 999px; padding: 3px 9px; font-size: 12px; color: #c9cfda; cursor: pointer; }
.pill:not([data-cons]) { cursor: default; }
.pill.lv1 { color: #8fe3b0; } .pill.lv2 { color: #9cc9ff; } .pill.lv3 { color: #d7a8ff; }
.who { color: var(--muted); font-size: 13px; margin: 10px 0 0; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; flex: none; }
.dot.big { width: 12px; height: 12px; }
.sum { font-size: 15px; line-height: 1.55; margin: 12px 0 0; }
.why { font-size: 14px; line-height: 1.5; margin: 10px 0 0; color: #c9cfda; }
.why b { color: var(--text); font-weight: 600; }
.fbox { margin: 14px 0 0; padding: 4px 12px 8px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; overflow-x: auto; }
.fbox .note { margin: 0; }
.formula { font-size: 15px; }
.formula .katex-display { margin: .6em 0; }
.img { display: block; margin: -4px 0 14px; border-radius: 8px; overflow: hidden; background: #f3f4f6; }
.img img { display: block; width: 100%; max-height: 220px; object-fit: contain; }
.acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.btn { border: 1px solid #35507a; background: #1b2a44; color: #cfe5ff; border-radius: 8px; padding: 7px 12px; font-size: 13px; }
.btn:hover { background: #22365a; text-decoration: none; }
.btn.ghost { border-color: var(--line); background: var(--panel-2); color: var(--text); }
.chip { border: 1px solid var(--line); background: var(--panel-2); border-radius: 999px; padding: 4px 10px; font-size: 13px; }
.rel { list-style: none; margin: 0; padding: 0; }
.rel li { padding: 6px 8px; border-radius: 6px; cursor: pointer; display: flex; flex-wrap: wrap; align-items: center; }
.rel li:hover { background: var(--panel-2); }
.rel li .nm { flex: 1; min-width: 0; }
.rel li small { flex-basis: 100%; color: var(--muted); font-size: 12px; margin: 1px 0 0 15px; line-height: 1.35; }
.rel li.off .nm::after { content: " ↗"; color: var(--muted); }
.rel .tag { font-size: 11px; color: var(--muted); margin-left: 8px; }
.rel.simlist li { padding: 4px 8px; color: #c2c8d3; }
.rel.bridges .nm { display: flex; align-items: center; flex-wrap: wrap; gap: 0 2px; }
.rel.bridges .arr { color: var(--muted); margin: 0 6px; }
ol.rel.path { counter-reset: s; }
ol.rel.path li::before { counter-increment: s; content: counter(s); width: 22px; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12px; }
ol.rel.path li small { margin-left: 37px; }
.links { display: flex; flex-wrap: wrap; gap: 6px; }
.links a { border: 1px solid var(--line); background: var(--panel-2); border-radius: 6px; padding: 5px 9px; font-size: 13px; color: var(--text); }
.links a:hover { border-color: var(--accent); text-decoration: none; }
.note { color: var(--muted); font-size: 12.5px; line-height: 1.5; }
.ext { font-size: 13px; line-height: 1.55; color: #c2c8d3; white-space: pre-line; }
details.more summary { cursor: pointer; color: var(--muted); font-size: 13px; margin-top: 18px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(70px, 1fr)); gap: 6px; margin: 12px 0; }
.stats div { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px; font-size: 12px; color: var(--muted); }
.stats b { display: block; font-size: 18px; color: var(--text); font-variant-numeric: tabular-nums; }

.controls { position: fixed; left: 12px; top: 64px; z-index: 4; display: flex; flex-direction: column; gap: 8px; max-height: calc(100% - 80px); width: 250px; }
.controls details { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 8px 10px; overflow: auto; flex: none; }
.controls details#legendBox { flex: 0 1 auto; min-height: 0; }
.controls summary { cursor: pointer; font-weight: 600; font-size: 13px; }
#legend { list-style: none; margin: 8px 0 2px; padding: 0; }
#legend li { display: flex; align-items: center; padding: 3px 4px; border-radius: 6px; cursor: pointer; font-size: 13px; }
#legend li:hover { background: var(--panel-2); }
#legend li.off { opacity: .35; }
#legend li small { margin-left: auto; padding-left: 6px; color: var(--muted); font-variant-numeric: tabular-nums; }
#legend .lh { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; cursor: default; padding: 8px 4px 2px; }
#legend .lh:first-child { padding-top: 0; }
#legend .hint { color: var(--muted); font-size: 11px; cursor: default; }
#levels { display: flex; gap: 4px; margin-top: 8px; }
.seg { flex: 1; border: 1px solid var(--line); background: none; border-radius: 6px; padding: 5px 4px; font-size: 12px; color: var(--muted); }
.seg.on { background: var(--panel-2); color: var(--text); border-color: #3a4560; }
#etypes { margin-top: 6px; }
#etypes label { display: flex; align-items: center; gap: 7px; font-size: 13px; padding: 4px 0; cursor: pointer; }
#etypes label.sep { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 8px; }
.ln { display: inline-block; width: 18px; height: 0; border-top: 2px solid; }

#loading { position: fixed; inset: 0; display: grid; place-items: center; color: var(--muted); z-index: 10; background: var(--bg); }

@media (max-width: 1100px) { .brand { display: none; } }
@media (max-width: 760px) {
  .bar { top: 8px; left: 8px; right: 8px; flex-wrap: wrap; gap: 6px; }
  .tabs { order: 2; flex: 1 1 100%; }
  .tabs a { flex: 1; justify-content: center; padding: 6px 4px; font-size: 13px; }
  .tabs a i { display: none; }
  .search { flex: 1; }
  .controls { top: 104px; left: 8px; width: auto; max-width: 70%; max-height: calc(100% - 120px); }
  .controls details:not([open]) { padding: 6px 10px; }
  .side { top: auto; left: 0; right: 0; bottom: 0; width: auto; max-height: 60vh; border-radius: 14px 14px 0 0; padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
}
