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

:root {
  --bg-dark: #0D1217;
  --panel-bg: rgba(19, 25, 32, 0.94);
  --card-bg: rgba(24, 32, 42, 0.92);
  --bar-bg: rgba(30, 38, 50, 0.94);
  --border-subtle: rgba(255, 255, 255, 0.12);
  --emerald: #10B981;
  --emerald-light: #34D399;
  --sky: #38BDF8;
  --blue: #3B82F6;
  --amber: #FBBF24;
  --text-primary: #F8FAFC;
  --text-muted: #94A3B8;
}

html, body, #cesiumContainer {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-dark);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Inter, sans-serif;
}

.cesium-viewer-bottom,
.cesium-viewer-toolbar,
.cesium-viewer-animationContainer,
.cesium-viewer-timelineContainer,
.cesium-credit-logoContainer,
.cesium-credit-textContainer {
  display: none !important;
}

.hidden {
  display: none !important;
}

/* Top HUD */
.hud-top {
  position: fixed;
  top: 14px;
  left: 16px;
  right: 76px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.hud-top > * {
  pointer-events: auto;
}

.search-bar {
  position: relative;
  max-width: 520px;
  height: 48px;
  background: var(--bar-bg);
  border: 1px solid var(--border-subtle);
  border-radius: 24px;
  padding: 0 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
}

.icon-badge {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #0F261E;
  border: 1px solid rgba(5, 150, 105, 0.65);
  color: var(--emerald-light);
  display: grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
}

.icon-badge svg {
  width: 18px;
  height: 18px;
}

.search-input-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.search-icon {
  width: 17px;
  height: 17px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.search-input-wrap input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 13.5px;
  min-width: 0;
}

.search-input-wrap input::placeholder {
  color: var(--text-muted);
}

.go-btn {
  background: rgba(16, 185, 129, 0.18);
  color: var(--emerald-light);
  border: 1px solid rgba(16, 185, 129, 0.45);
  border-radius: 14px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.go-btn:hover {
  background: rgba(16, 185, 129, 0.3);
}

.preset-dropdown {
  position: absolute;
  top: 54px;
  left: 0;
  right: 0;
  background: var(--panel-bg);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.55);
}

.preset-item {
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 13px;
}

.preset-item:last-child {
  border-bottom: none;
}

.preset-item:hover {
  background: rgba(56, 189, 248, 0.12);
}

.preset-item-coords {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  color: var(--text-muted);
}

/* Status Chips */
.status-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border-radius: 20px;
  background: rgba(22, 31, 42, 0.92);
  border: 1px solid var(--border-subtle);
  font-size: 11.5px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.chip-emerald {
  border-color: rgba(52, 211, 153, 0.4);
}

.dot-blue {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 0 6px var(--blue);
}

.dot-emerald {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--emerald-light);
  box-shadow: 0 0 6px var(--emerald-light);
}

.chip-label-blue {
  color: #60A5FA;
  font-weight: 700;
  letter-spacing: 0.4px;
}

.chip-label-muted {
  color: #CBD5E1;
  font-weight: 600;
}

.chip-sep {
  color: rgba(255, 255, 255, 0.2);
}

.chip-mono {
  color: #CBD5E1;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* Tour Banner */
.tour-banner {
  max-width: 520px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  border-radius: 18px;
  background: rgba(26, 20, 11, 0.92);
  border: 1px solid rgba(245, 158, 11, 0.65);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
}

.tour-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--amber);
  flex-shrink: 0;
}

.tour-caption {
  flex: 1;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stop-btn {
  background: rgba(239, 68, 68, 0.22);
  border: 1px solid rgba(239, 68, 68, 0.6);
  color: #FCA5A5;
  font-size: 10.5px;
  font-weight: 800;
  padding: 3px 10px;
  border-radius: 10px;
  cursor: pointer;
}

/* Loading Pill */
.loading-pill {
  position: fixed;
  top: 72px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 25;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  border-radius: 20px;
  background: rgba(15, 26, 34, 0.94);
  border: 1px solid rgba(16, 185, 129, 0.5);
  color: var(--emerald-light);
  font-size: 12px;
  font-weight: 600;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
}

.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(52, 211, 153, 0.25);
  border-top-color: var(--emerald-light);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Right Toolbar */
.right-toolbar {
  position: fixed;
  right: 16px;
  top: 16px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tool-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bar-bg);
  border: 1px solid var(--border-subtle);
  color: #E2E8F0;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
  transition: transform 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.tool-btn svg {
  width: 20px;
  height: 20px;
}

.tool-btn:hover {
  transform: scale(1.05);
  border-color: rgba(56, 189, 248, 0.6);
  color: var(--sky);
}

.tool-btn.active {
  border-color: var(--sky);
  color: var(--sky);
  background: rgba(15, 35, 52, 0.95);
}

/* Layers Drawer */
.layers-panel {
  position: fixed;
  top: 70px;
  right: 72px;
  width: min(370px, calc(100vw - 88px));
  max-height: calc(100vh - 140px);
  z-index: 30;
  background: var(--panel-bg);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.65);
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 800;
}

.panel-title svg {
  width: 18px;
  height: 18px;
}

.close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.close-btn:hover {
  color: #fff;
}

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

.card {
  background: var(--card-bg);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.6px;
  color: var(--text-muted);
}

.url-row {
  display: flex;
  gap: 6px;
}

.url-row input {
  flex: 1;
  min-width: 0;
  background: #0D1217;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  padding: 6px 8px;
  color: var(--text-primary);
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.btn-primary-sm,
.btn-ghost-sm {
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
}

.btn-primary-sm {
  background: var(--emerald);
  color: #042F2E;
}

.btn-ghost-sm {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.12);
  color: var(--text-muted);
}

.scheme-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
}

.segmented-sm {
  display: flex;
  background: #0D1217;
  border-radius: 8px;
  padding: 2px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.seg-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
}

.seg-btn.active {
  background: rgba(56, 189, 248, 0.2);
  color: var(--sky);
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
}

.toggle-title {
  font-size: 13px;
  font-weight: 600;
}

.toggle-sub {
  font-size: 11px;
  color: var(--text-muted);
}

.toggle-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--emerald);
  cursor: pointer;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
  background: #0D1217;
  padding: 4px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.terrain-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 7px 6px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.terrain-btn.active {
  background: rgba(16, 185, 129, 0.22);
  color: var(--emerald-light);
}

.preset-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.btn-outline {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #E2E8F0;
  border-radius: 9px;
  padding: 7px 8px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
}

.btn-outline:hover {
  border-color: var(--sky);
  color: var(--sky);
}

/* Bottom Telemetry Bar */
.hud-bottom {
  position: fixed;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  pointer-events: none;
}

.bottom-pill {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  border-radius: 22px;
  background: var(--panel-bg);
  border: 1px solid var(--border-subtle);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55);
}

.telemetry-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.t-label {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.6px;
  color: var(--text-muted);
}

.t-val {
  font-size: 12px;
  font-weight: 700;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.t-div {
  width: 1px;
  height: 22px;
  background: rgba(255, 255, 255, 0.1);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 72px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  background: rgba(15, 26, 34, 0.96);
  border: 1px solid rgba(56, 189, 248, 0.45);
  color: #E2E8F0;
  padding: 8px 16px;
  border-radius: 16px;
  font-size: 12.5px;
  font-weight: 500;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
}

@media (max-width: 640px) {
  .hud-top {
    right: 68px;
  }
  .layers-panel {
    right: 12px;
    left: 12px;
    width: auto;
    top: 68px;
  }
  .bottom-pill {
    gap: 8px;
    padding: 7px 12px;
  }
  .t-val {
    font-size: 11px;
  }
}
