:root {
  --bg: #f6f7f9; --panel: #ffffff; --text: #1d2330; --muted: #677085;
  --border: #d9dde5; --accent: #1f6feb; --accent-soft: #e3edfd;
  --node: #e8590c; --refl: #1f6feb; --dot: #98a0ae;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #11151c; --panel: #181d26; --text: #e6e9ef; --muted: #939bab;
    --border: #2b3240; --accent: #5b9bff; --accent-soft: #1d2a40;
    --node: #ff8a3d; --refl: #5b9bff; --dot: #5d6575;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.4 system-ui, sans-serif; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: baseline; gap: 12px; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.topbar h1 { font-size: 18px; margin: 0; }
.muted { color: var(--muted); }
.layout { flex: 1; display: grid; grid-template-columns: 340px 1fr; min-height: 0; }
.sidebar { background: var(--panel); border-right: 1px solid var(--border); overflow-y: auto; padding: 12px 16px; }
.tabs { display: flex; gap: 4px; margin-bottom: 8px; }
.tabs button { flex: 1; padding: 6px; border: 1px solid var(--border); background: var(--bg); color: var(--text); border-radius: 6px; cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
#search { width: 100%; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); }
.check { display: block; margin: 8px 0; color: var(--muted); }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; gap: 8px; align-items: baseline; padding: 6px 8px; border-radius: 6px; cursor: pointer; }
.list li:hover, .list li:focus { background: var(--accent-soft); outline: none; }
.list li.channel { padding-left: 24px; }
.list .id { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 3.2em; }
.list .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .count { color: var(--muted); font-variant-numeric: tabular-nums; }
.tag { font-size: 11px; color: var(--muted); border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; }
.back { background: none; border: none; color: var(--accent); cursor: pointer; padding: 0; margin-bottom: 8px; font: inherit; }
.info h2 { font-size: 16px; margin: 4px 0; }
.info p { margin: 2px 0; }
.map-wrap { position: relative; min-height: 0; }
#map { position: absolute; inset: 0; }
.detail { position: absolute; top: 12px; right: 12px; bottom: 12px; width: min(340px, calc(100% - 24px)); overflow-y: auto; z-index: 1000; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 12px 16px; box-shadow: 0 4px 16px rgb(0 0 0 / .2); }
.detail .close { float: right; background: none; border: none; font-size: 20px; cursor: pointer; color: var(--muted); }
.detail dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 8px 0; }
.detail dt { color: var(--muted); }
.detail dd { margin: 0; overflow-wrap: anywhere; }
a, .linkish { color: var(--accent); }
.linkish { background: none; border: none; padding: 0; font: inherit; cursor: pointer; text-decoration: underline; text-align: left; }
.error { position: fixed; bottom: 16px; left: 16px; right: 16px; padding: 12px; background: #b42318; color: #fff; border-radius: 8px; z-index: 2000; }
@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; grid-template-rows: auto 60vh; }
  .sidebar { border-right: none; border-bottom: 1px solid var(--border); max-height: 40vh; }
}
