/* ── Reset & base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #080c14;
  --surface: rgba(10, 18, 32, 0.85);
  --border: rgba(80, 140, 220, 0.25);
  --accent: #4fa3e8;
  --accent-dim: rgba(79, 163, 232, 0.15);
  --text: #d8e8f8;
  --text-muted: #6a8faf;
  --h-color: #ff6b6b;
  --l-color: #4fa3e8;
  --radius: 8px;
  --font: 'Segoe UI', system-ui, sans-serif;
}

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
}

/* ── Canvas ── */
#globe {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* ── HUD top bar ── */
.hud-top {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 52px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  z-index: 100;
}

.logo {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--text);
  white-space: nowrap;
}

.search-wrap {
  position: relative;
  flex: 1;
  max-width: 320px;
}

.search-wrap input {
  width: 100%;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  padding: 6px 12px;
  outline: none;
  transition: border-color 0.2s;
}

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

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

.search-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: #0d1a2e;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  list-style: none;
  z-index: 200;
  max-height: 200px;
  overflow-y: auto;
}

.search-dropdown.hidden { display: none; }

.search-dropdown li {
  padding: 8px 12px;
  cursor: pointer;
  color: var(--text);
  transition: background 0.15s;
}

.search-dropdown li:hover { background: var(--accent-dim); }

.hud-time {
  margin-left: auto;
  color: var(--text-muted);
  font-size: 12px;
  white-space: nowrap;
}

/* ── Tooltip ── */
.tooltip {
  position: fixed;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 10px;
  font-size: 12px;
  color: var(--text);
  pointer-events: none;
  backdrop-filter: blur(8px);
  z-index: 150;
  white-space: nowrap;
}

.tooltip.hidden { display: none; }

/* ── Info panel ── */
.info-panel {
  position: fixed;
  top: 68px;
  right: 16px;
  width: 240px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  backdrop-filter: blur(16px);
  z-index: 100;
  transition: opacity 0.2s, transform 0.2s;
}

.info-panel.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateX(8px);
}

#panel-close {
  position: absolute;
  top: 10px; right: 12px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
}

#panel-close:hover { color: var(--text); }

.info-panel h2 {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 12px;
  padding-right: 20px;
  color: var(--accent);
}

.panel-grid { display: flex; flex-direction: column; gap: 8px; }

.panel-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(80,140,220,0.1);
}

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

.panel-item .label {
  color: var(--text-muted);
  font-size: 11px;
  white-space: nowrap;
}

.panel-item .value {
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  text-align: right;
}

/* ── Pressure legend ── */
.legend {
  position: fixed;
  bottom: 72px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 16px;
  font-size: 12px;
  backdrop-filter: blur(8px);
  z-index: 100;
}

.legend-h { color: var(--h-color); font-weight: 600; }
.legend-l { color: var(--l-color); font-weight: 600; }

/* ── Time slider bar ── */
.time-bar {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 8px 16px;
  backdrop-filter: blur(12px);
  z-index: 100;
  min-width: 320px;
}

.time-bar button {
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  font-size: 16px;
  padding: 2px 4px;
  border-radius: 4px;
  transition: background 0.15s;
}

.time-bar button:hover { background: var(--accent-dim); }

#time-slider {
  flex: 1;
  accent-color: var(--accent);
  cursor: pointer;
}

.time-label {
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  min-width: 36px;
  text-align: center;
}

/* ── Loading overlay ── */
.loading {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  transition: opacity 0.5s;
}

.loading.hidden {
  opacity: 0;
  pointer-events: none;
}

.loading-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  color: var(--text-muted);
}

.spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ── Pressure marker sprites ── */
.pressure-label {
  pointer-events: none;
  font-family: var(--font);
}

/* ── Mobile tweaks ── */
@media (max-width: 600px) {
  .info-panel { width: calc(100vw - 32px); right: 16px; }
  .time-bar { min-width: 280px; }
  .hud-top { gap: 10px; padding: 0 12px; }
  .search-wrap { max-width: 180px; }
}

@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; }
}

/* ── Home button ── */
.hud-btn {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  font-size: 16px;
  padding: 4px 8px;
  transition: background 0.15s;
  white-space: nowrap;
}
.hud-btn:hover { background: var(--accent-dim); border-color: var(--accent); }

/* ── Legend note ── */
.legend-note {
  color: var(--text-muted);
  font-size: 10px;
  align-self: center;
}

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  backdrop-filter: blur(4px);
}
.modal-overlay.hidden { display: none; }

.modal {
  background: #0d1a2e;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  width: 320px;
  max-width: calc(100vw - 32px);
}

.modal h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 6px;
}

.modal p {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.modal input {
  width: 100%;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  padding: 8px 12px;
  outline: none;
  margin-bottom: 8px;
}
.modal input:focus { border-color: var(--accent); }

.modal-error {
  font-size: 11px;
  color: #ff6b6b;
  min-height: 16px;
  margin-bottom: 12px;
}

.modal-buttons {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.btn-primary {
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  color: #fff;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  padding: 7px 16px;
  transition: opacity 0.15s;
}
.btn-primary:hover { opacity: 0.85; }

.btn-secondary {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  padding: 7px 16px;
  transition: border-color 0.15s;
}
.btn-secondary:hover { border-color: var(--accent); color: var(--text); }

/* ── Controls panel (top right toggles) ── */
.controls-panel {
  position: fixed;
  top: 68px;
  right: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  backdrop-filter: blur(12px);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
}

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

.toggle-row:hover { color: var(--text); }

/* ── Data footer ── */
.data-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 10px;
  color: var(--text-muted);
  background: rgba(8,12,20,0.7);
  padding: 4px 12px;
  z-index: 100;
  letter-spacing: 0.02em;
}

/* ── Crosshair — position controlled by JS on click ── */
.crosshair {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 90;
  transition: left 0.15s ease, top 0.15s ease;
}
.ch-ring {
  width: 28px; height: 28px;
  border: 1.5px solid rgba(255,255,255,0.55);
  border-radius: 50%;
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%,-50%);
}
.ch-dot {
  width: 4px; height: 4px;
  background: rgba(255,255,255,0.8);
  border-radius: 50%;
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%,-50%);
}
/* Tick marks */
.crosshair::before, .crosshair::after {
  content: '';
  position: absolute;
  background: rgba(255,255,255,0.45);
}
.crosshair::before { width: 1px; height: 12px; left: 50%; top: 50%; transform: translate(-50%, -50%) translateY(-20px); }
.crosshair::after  { height: 1px; width: 12px; top: 50%; left: 50%; transform: translate(-50%, -50%) translateX(-20px); }

/* Crosshair info bubble */
.crosshair-info {
  position: fixed;
  top: calc(50% + 26px);
  left: 50%;
  transform: translateX(-50%);
  transition: left 0.15s ease, top 0.15s ease;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 14px;
  font-size: 12px;
  pointer-events: none;
  backdrop-filter: blur(8px);
  z-index: 90;
  text-align: center;
  white-space: nowrap;
}
.crosshair-info .ch-place {
  color: var(--text);
  font-weight: 500;
  font-size: 12px;
}
.crosshair-info .ch-coords {
  color: var(--text-muted);
  font-size: 11px;
}
.crosshair-info.hidden { display: none; }
