:root {
  --bg: #11151a;
  --panel: rgba(20, 25, 31, 0.92);
  --panel-solid: #161b21;
  --line: #2a323c;
  --text: #e4e1da;
  --muted: #8d949c;
  --accent: #d9a441;
  --good: #5fbf6a;
  --bad: #e0574a;
  --font: 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); font: 14px/1.4 var(--font); }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

#app { display: grid; grid-template: "top top" auto "stage side" 1fr / 1fr 340px; height: 100dvh; }
#top {
  grid-area: top; display: flex; align-items: center; gap: 16px; padding: 8px 16px;
  background: var(--panel-solid); border-bottom: 1px solid var(--line); min-width: 0;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; min-width: 0; }
#hostname { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.up { background: var(--good); box-shadow: 0 0 6px var(--good); }
.dot.down { background: var(--bad); }
.stats { display: flex; gap: 14px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.stats #s-online { color: var(--text); }
.modes { margin-left: auto; display: flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; flex: none; }
.modes button { padding: 4px 12px; color: var(--muted); }
.modes button.on { background: var(--accent); color: #1a1408; font-weight: 600; }
.icon { font-size: 18px; padding: 2px 6px; display: none; }

#stage { grid-area: stage; position: relative; overflow: hidden; min-width: 0; }
#view, #view canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#view canvas { cursor: grab; }
#view canvas.drag { cursor: grabbing; }
.panel {
  position: absolute; background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; backdrop-filter: blur(4px);
}
#layers { top: 12px; left: 12px; display: flex; flex-direction: column; gap: 2px; font-size: 13px; user-select: none; }
#layers label { display: flex; gap: 6px; align-items: center; cursor: pointer; }
#coords { bottom: 12px; left: 12px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
#banner {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%); padding: 6px 14px; border-radius: 6px;
  background: rgba(120, 30, 24, 0.92); border: 1px solid var(--bad); font-size: 13px; max-width: calc(100% - 32px);
}
#tip {
  position: absolute; pointer-events: none; background: var(--panel-solid); border: 1px solid var(--line);
  border-radius: 6px; padding: 6px 9px; font-size: 13px; max-width: 260px; z-index: 5;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
}
#tip b { color: var(--accent); }
#tip .m { color: var(--muted); }

#side { grid-area: side; display: flex; flex-direction: column; background: var(--panel-solid); border-left: 1px solid var(--line); min-height: 0; }
.tabs { display: flex; border-bottom: 1px solid var(--line); flex: none; }
.tabs button { flex: 1; padding: 9px 4px; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); }
.tabs span { color: var(--muted); font-size: 12px; }
.tab { display: none; flex: 1; overflow-y: auto; min-height: 0; }
.tab.on { display: block; }

#feed { list-style: none; margin: 0; padding: 8px 12px; }
#feed li { padding: 3px 0; overflow-wrap: anywhere; }
#feed time { color: var(--muted); font-size: 12px; margin-right: 6px; font-variant-numeric: tabular-nums; }
#feed .title { color: var(--muted); margin-right: 4px; }
#feed .name { font-weight: 600; cursor: pointer; }
#feed .sys { color: var(--muted); font-style: italic; }
#feed .join .sys { color: var(--good); }
#feed .death .sys { color: #d98a80; }
#feed .empty { color: var(--muted); }

.list { list-style: none; margin: 0; padding: 4px 0; }
.list li { display: flex; align-items: center; gap: 10px; padding: 7px 14px; cursor: pointer; border-left: 3px solid transparent; }
.list li:hover { background: rgba(255, 255, 255, 0.04); }
.list li.follow { border-left-color: var(--accent); background: rgba(217, 164, 65, 0.08); }
.list .sw { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.list .main { flex: 1; min-width: 0; }
.list .main div:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .sub { color: var(--muted); font-size: 12px; }
.list .grid { color: var(--muted); font-variant-numeric: tabular-nums; }
.list .empty { color: var(--muted); cursor: default; }

/* 3D labels (CSS2DRenderer) */
.l3 { font: 600 12px var(--font); color: #fff; text-shadow: 0 0 3px #000, 0 0 2px #000; white-space: nowrap; pointer-events: none; }
.l3.mon { font-weight: 500; color: #f1e6c8; }
.l3.ev { color: #ffd27a; }

@media (max-width: 760px) {
  #app { grid-template: "top" auto "stage" 1fr / 1fr; }
  #top { gap: 10px; padding: 8px 12px; }
  .stats #s-fps, .stats #s-time { display: none; }
  .icon { display: block; }
  #side {
    position: fixed; left: 0; right: 0; bottom: 0; height: 55dvh; z-index: 10; border-left: 0;
    border-top: 1px solid var(--line); border-radius: 12px 12px 0 0; transform: translateY(100%);
    transition: transform 0.2s ease; box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.5);
  }
  #side.open { transform: none; }
  #layers { font-size: 12px; padding: 6px 8px; }
}
