:root {
  --bg: #03060c;
  --panel-bg: rgba(11, 18, 32, 0.78);
  --panel-border: rgba(148, 163, 184, 0.2);
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent-strong: #0284c7;
  --live: #22c55e;
  --paused: #f59e0b;
  --radius: 12px;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.small { font-size: 11.5px; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

#globe-container {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: grab;
}

#globe-container:active {
  cursor: grabbing;
}

/* Loading Overlay */
#loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(3, 6, 12, 0.85);
  backdrop-filter: blur(6px);
  transition: opacity 0.3s ease;
}

.loader-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 24px 32px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
}

.spinner {
  width: 30px;
  height: 30px;
  border: 3px solid rgba(56, 189, 248, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Shared Glass Panel */
.panel {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  backdrop-filter: blur(12px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

/* Top HUD */
.hud-top {
  position: fixed;
  top: 14px;
  left: 14px;
  right: 14px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 16px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  backdrop-filter: blur(12px);
  pointer-events: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand h1 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.status-dot.live {
  background: var(--live);
  box-shadow: 0 0 10px var(--live);
}

.status-dot.paused {
  background: var(--paused);
  box-shadow: 0 0 10px var(--paused);
}

.pill {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.8px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(34, 197, 94, 0.16);
  color: var(--live);
  border: 1px solid rgba(34, 197, 94, 0.35);
}

.pill.paused {
  background: rgba(245, 158, 11, 0.16);
  color: var(--paused);
  border-color: rgba(245, 158, 11, 0.35);
}

.hud-stats {
  display: flex;
  align-items: center;
  gap: 20px;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.stat-label {
  font-size: 9.5px;
  letter-spacing: 0.7px;
  color: var(--muted);
}

.stat-value {
  font-size: 13px;
  font-weight: 600;
}

/* Sidebar */
.sidebar {
  position: fixed;
  top: 72px;
  left: 14px;
  bottom: 76px;
  width: 280px;
  z-index: 15;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.22s ease;
}

.sidebar.collapsed {
  transform: translateX(-310px);
}

.reopen-btn {
  position: fixed;
  top: 72px;
  left: 14px;
  z-index: 15;
  padding: 8px 12px;
  color: var(--text);
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--panel-border);
}

.panel-header h2 {
  font-size: 13.5px;
  font-weight: 600;
}

.sidebar-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.group-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
}

.inline-actions {
  display: flex;
  gap: 4px;
  font-size: 11px;
  color: var(--muted);
}

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 11px;
}

.link-btn:hover { text-decoration: underline; }

/* Search */
.search-wrap {
  position: relative;
}

#search-input {
  width: 100%;
  padding: 7px 26px 7px 10px;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
  background: rgba(15, 23, 42, 0.85);
  color: var(--text);
  font-size: 12.5px;
  outline: none;
}

#search-input:focus {
  border-color: var(--accent);
}

.clear-btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--muted);
  font-size: 16px;
  cursor: pointer;
  line-height: 1;
}

.search-results {
  max-height: 150px;
  overflow-y: auto;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: rgba(10, 16, 30, 0.96);
}

.search-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 9px;
  cursor: pointer;
  border-bottom: 1px solid rgba(148, 163, 184, 0.1);
}

.search-item:last-child { border-bottom: none; }
.search-item:hover { background: rgba(56, 189, 248, 0.15); }

/* Regime Chips */
.chip-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 9px;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
  background: rgba(15, 23, 42, 0.6);
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  transition: all 0.15s ease;
}

.chip.active {
  background: rgba(56, 189, 248, 0.18);
  border-color: rgba(56, 189, 248, 0.55);
  color: var(--text);
}

.chip-count {
  font-size: 10.5px;
  opacity: 0.75;
}

/* Category List */
.category-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px;
  border-radius: 6px;
  cursor: pointer;
}

.cat-row:hover {
  background: rgba(148, 163, 184, 0.1);
}

.cat-left {
  display: flex;
  align-items: center;
  gap: 7px;
}

.cat-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Range & Toggles */
input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
}

.toggle-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.color-mode-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
}

.segmented {
  display: flex;
  border: 1px solid var(--panel-border);
  border-radius: 7px;
  overflow: hidden;
}

.seg-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 4px 9px;
  font-size: 11.5px;
  cursor: pointer;
}

.seg-btn.active {
  background: var(--accent-strong);
  color: #fff;
}

/* Right Inspector */
.inspector {
  position: fixed;
  top: 72px;
  right: 14px;
  width: 270px;
  z-index: 15;
  padding-bottom: 12px;
}

.inspector-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  padding: 12px 14px;
}

.metric {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.metric-label {
  font-size: 9.5px;
  letter-spacing: 0.6px;
  color: var(--muted);
}

.metric-value {
  font-size: 13px;
  font-weight: 600;
}

.inspector-meta {
  padding: 0 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  border-top: 1px solid var(--panel-border);
  padding-top: 10px;
}

.inspector-actions {
  padding: 4px 14px 0;
  display: flex;
  gap: 8px;
}

/* Bottom Playback Bar */
.playback-bar {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
}

.divider {
  width: 1px;
  height: 20px;
  background: var(--panel-border);
}

.btn {
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
  background: rgba(30, 41, 59, 0.75);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn:hover {
  background: rgba(51, 65, 85, 0.9);
}

.btn.primary {
  background: var(--accent-strong);
  border-color: var(--accent);
  color: #fff;
}

.btn.primary:hover {
  background: #0369a1;
}

.icon-btn {
  background: none;
  border: 1px solid transparent;
  color: var(--muted);
  font-size: 16px;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:hover {
  color: var(--text);
  background: rgba(148, 163, 184, 0.14);
}

.speed-group {
  display: flex;
  gap: 3px;
}

.speed-btn {
  padding: 5px 8px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.speed-btn:hover {
  color: var(--text);
  background: rgba(148, 163, 184, 0.12);
}

.speed-btn.active {
  background: rgba(56, 189, 248, 0.2);
  border-color: rgba(56, 189, 248, 0.5);
  color: var(--accent);
}

/* Hover Tooltip */
.tooltip {
  position: fixed;
  z-index: 30;
  pointer-events: none;
  padding: 5px 9px;
  border-radius: 6px;
  background: rgba(10, 16, 30, 0.92);
  border: 1px solid rgba(56, 189, 248, 0.4);
  font-size: 11.5px;
  white-space: nowrap;
}

@media (max-width: 720px) {
  .hide-mobile { display: none; }
  .sidebar { width: 250px; }
  .inspector { width: 230px; }
}
