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

body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }

#map {
  position: fixed;
  inset: 0;
}

#places-overlay {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9;
  pointer-events: none;
  font: 500 24px "DM Mono", ui-monospace, Menlo, monospace;
  letter-spacing: -0.4px;
  color: #fff;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.5);
  white-space: nowrap;
}

/* ── UI Stack ─────────────────────────────────────────────────────────────── */

#ui-stack {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
}

#detail-panel { width: 240px; }

#ui {
  background: rgba(10, 10, 20, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  overflow: hidden;
  color: #e2e8f0;
}

#ui-toggle {
  width: 100%;
  background: transparent;
  border: none;
  padding: 12px 16px;
  text-align: left;
  cursor: pointer;
}

#logo {
  font: 500 15px "DM Mono", ui-monospace, Menlo, monospace;
  letter-spacing: -0.2px;
  color: #fff;
}

#ui.collapsed #layers { display: none; }

/* ── Layer toggles ────────────────────────────────────────────────────────── */

#layers {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 16px 14px;
}

.layers-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
  margin: 4px 0;
}

#layers label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #cbd5e1;
  cursor: pointer;
  user-select: none;
}

#layers input[type="checkbox"] {
  appearance: none;
  width: 14px;
  height: 14px;
  border: 1.5px solid #475569;
  border-radius: 3px;
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
}

#layers input[type="checkbox"]:checked {
  background: #0a84ff;
  border-color: #0a84ff;
}

#layers input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 0px;
  width: 4px;
  height: 8px;
  border: 2px solid #fff;
  border-top: none;
  border-left: none;
  transform: rotate(45deg);
}

/* ── Popups ───────────────────────────────────────────────────────────────── */

.mapboxgl-popup-content {
  background: rgba(10, 10, 20, 0.92) !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  border-radius: 8px !important;
  padding: 10px 12px !important;
  color: #e2e8f0;
  backdrop-filter: blur(8px);
}

.mapboxgl-popup-tip { display: none; }

.popup-type {
  font-size: 12px;
  font-weight: 600;
  color: #0a84ff;
  text-transform: capitalize;
  margin-bottom: 2px;
}

.popup-time { font-size: 11px; color: #94a3b8; }
.popup-dur  { font-size: 11px; color: #64748b; margin-top: 2px; }

/* ── Detail panel ─────────────────────────────────────────────────────────── */

#detail-panel {
  position: relative;
  background: rgba(10, 10, 20, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 16px 18px;
  color: #fff;
}

#detail-panel.hidden { display: none; }

#detail-close {
  position: absolute;
  top: 10px;
  right: 12px;
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.5);
  font: 400 22px -apple-system, sans-serif;
  cursor: pointer;
  padding: 2px 8px;
  line-height: 1;
}
#detail-close:hover { color: #fff; }

.detail-title {
  font: 500 18px "DM Mono", ui-monospace, Menlo, monospace;
  letter-spacing: -0.3px;
  margin-bottom: 4px;
  padding-right: 24px;
}

.detail-subtitle {
  font: 300 12px "DM Mono", ui-monospace, Menlo, monospace;
  color: rgba(255, 255, 255, 0.6);
  margin-bottom: 18px;
}

.detail-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font: 400 12px "DM Mono", ui-monospace, Menlo, monospace;
  padding: 10px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.detail-row-label { color: rgba(255, 255, 255, 0.5); font-size: 10px; }
.detail-row-value { color: #fff; word-break: break-word; }

.detail-link {
  display: inline-block;
  margin-top: 16px;
  color: #0a84ff;
  text-decoration: none;
  font: 400 12px "DM Mono", ui-monospace, Menlo, monospace;
}
.detail-link:hover { text-decoration: underline; }

#detail-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

#detail-nav.hidden { display: none; }

#detail-nav button {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  color: #cbd5e1;
  cursor: pointer;
  font: 400 14px "DM Mono", ui-monospace, Menlo, monospace;
  padding: 4px 12px;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}

#detail-nav button:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.2);
  color: #fff;
}

#detail-nav button:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

#nav-position {
  font: 400 11px "DM Mono", ui-monospace, Menlo, monospace;
  color: rgba(255, 255, 255, 0.45);
}

/* ── Cluster label ────────────────────────────────────────────────────────── */

#cluster-label {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 6;
  pointer-events: none;
  transform: translate(-50%, calc(-100% - 4px));
  padding: 6px 12px;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  text-align: center;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.12s;
}

#cluster-label.visible { opacity: 1; }

#cluster-label-title {
  font: 500 12px "DM Mono", ui-monospace, Menlo, monospace;
  color: #fff;
  letter-spacing: -0.2px;
}

#cluster-label-sub {
  font: 300 10px "DM Mono", ui-monospace, Menlo, monospace;
  color: rgba(255, 255, 255, 0.7);
  margin-top: 1px;
}

/* ── Timeline ─────────────────────────────────────────────────────────────── */

#timeline {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  width: min(calc(100% - 32px), 960px);
  height: 120px;
  z-index: 8;
  padding: 10px 14px 8px;
  color: rgba(255, 255, 255, 0.7);
  user-select: none;
}

#timeline.hidden { display: none; }

#timeline-canvas {
  display: block;
  width: 100%;
  height: 100px;
  cursor: pointer;
  touch-action: none;
}

#timeline-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  font: 300 10px "DM Mono", ui-monospace, Menlo, monospace;
  color: rgba(255, 255, 255, 0.4);
  pointer-events: none;
}

/* ── Mapbox attribution ───────────────────────────────────────────────────── */

.mapboxgl-ctrl-attrib { font-size: 9px !important; }
