* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #070d1f;
  --panel-bg: rgba(8, 14, 32, 0.78);
  --panel-border: rgba(94, 140, 255, 0.25);
  --title: #7fb0ff;
  --text: #cfe0ff;
  --muted: #6b82b8;
  --value: #e8f0ff;
  --vehicle: #9fb4dd;
}

[data-theme="light"] {
  --bg: #aac6e4;
  --panel-bg: rgba(244, 248, 255, 0.85);
  --panel-border: rgba(40, 80, 170, 0.3);
  --title: #2456c4;
  --text: #1e2a44;
  --muted: #5a6c92;
  --value: #101a33;
  --vehicle: #41507a;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  font-family: "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  color: var(--text);
}

#scene { position: fixed; inset: 0; display: block; }

.panel {
  position: fixed;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 12px 14px;
  backdrop-filter: blur(6px);
  font-size: 12px;
  user-select: none;
  z-index: 10;
}

.panel-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--title);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 10px;
  min-width: 0;
}

.toolbar { margin-left: auto; display: inline-flex; gap: 6px; }
.tool-btn {
  background: none;
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  color: var(--title);
  font: inherit;
  font-size: 11px;
  padding: 2px 7px;
  cursor: pointer;
  letter-spacing: 0;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}
.tool-btn:hover { border-color: var(--title); }
#btn-github svg { display: block; }

.collapse-btn {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--title);
  font: inherit;
  font-size: 12px;
  line-height: 1;
  padding: 0 2px;
  cursor: pointer;
}
.collapse-btn:hover { color: var(--value); }
.panel.collapsed .panel-body { display: none; }
.panel.collapsed .panel-title { margin-bottom: 0; }

#dashboard { top: 16px; left: 16px; min-width: 230px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  letter-spacing: 1px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid currentColor;
}
.badge .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: currentColor;
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: 0.25; } }
.badge.live { color: #4ade80; }
.badge.mock { color: #fb923c; }
.badge.off  { color: #64748b; animation: none; }

.stat-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 2px 0;
}
.stat-label { color: var(--muted); }
.stat-value { color: var(--value); font-weight: 600; font-variant-numeric: tabular-nums; }

#legend { top: 16px; right: 16px; }
.legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 4px;
  margin: 0 -4px;
  border-radius: 5px;
  white-space: nowrap;
  cursor: pointer;
}
.legend-row:hover { background: rgba(127, 176, 255, 0.12); }
.legend-row.off { opacity: 0.32; }
.legend-row.off .legend-chip { box-shadow: none; }
.legend-chip {
  width: 10px; height: 10px;
  border-radius: 3px;
  flex: none;
  border: 1px solid rgba(0, 0, 0, 0.25);
  box-shadow: 0 0 6px currentColor;
}
.legend-vehicle { color: var(--vehicle); min-width: 84px; }
.legend-proto { color: var(--value); font-weight: 600; }
.legend-hint { color: var(--muted); font-size: 10px; margin-top: 7px; letter-spacing: 0.5px; }

#log { bottom: 16px; left: 16px; width: 250px; }
#log-rows { max-height: 170px; overflow: hidden; }
.log-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 1.5px 0;
  font-variant-numeric: tabular-nums;
  animation: slide-in 0.25s ease-out;
}
@keyframes slide-in { from { opacity: 0; transform: translateX(-8px); } }
.log-proto { font-weight: 700; min-width: 52px; }
.log-bytes { color: var(--vehicle); min-width: 64px; text-align: right; }
.log-dir { color: var(--muted); }

#hint {
  bottom: 16px; right: 16px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.5px;
}

#detail {
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  min-width: 280px;
  border-color: rgba(127, 176, 255, 0.55);
  box-shadow: 0 0 40px rgba(40, 80, 200, 0.35);
}
#detail .panel-title { justify-content: space-between; }
#detail-close {
  background: none;
  border: none;
  color: var(--title);
  font-size: 16px;
  cursor: pointer;
  line-height: 1;
}
#detail-close:hover { color: var(--value); }
.hidden { display: none; }

#tooltip {
  position: fixed;
  z-index: 20;
  pointer-events: none;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 8px 10px;
  font-family: inherit;
  font-size: 11px;
  line-height: 1.55;
  backdrop-filter: blur(6px);
  white-space: nowrap;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
}
#tt-title { font-weight: 700; letter-spacing: 1px; }
#tt-route { color: var(--value); font-variant-numeric: tabular-nums; }
#tt-meta { color: var(--muted); }

/* ---------------- mobile ---------------- */
@media (max-width: 700px) {
  .panel { padding: 8px 10px; font-size: 11px; border-radius: 8px; }
  .panel-title { font-size: 11px; letter-spacing: 1px; margin-bottom: 6px; gap: 6px; }
  #dashboard { top: 10px; left: 10px; min-width: 0; max-width: 46vw; }
  #dashboard .stat-row { gap: 8px; }
  #legend { top: 10px; right: 10px; max-width: 48vw; }
  .legend-vehicle { min-width: 0; flex: 1; }
  #log { bottom: 10px; left: 10px; width: min(220px, 60vw); }
  #log-rows { max-height: 110px; }
  #hint { display: none; }
  #detail { min-width: 0; width: min(330px, 92vw); }
}
