:root {
  --space: #02040a;
  --navy: #071428;
  --ocean: #0c3b66;
  --glass: rgba(7, 16, 32, 0.78);
  --line: rgba(125, 211, 252, 0.22);
  --atm: #7dd3fc;
  --atm-dim: #4aa3d8;
  --gold: #f4d35e;
  --gold-2: #ffe08a;
  --heat: #ff5a36;
  --text: #e8f4ff;
  --muted: #8aa4bf;
  --danger: #ef4444;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
  --radius: 18px;
  --font: "Figtree", "Helvetica Neue", sans-serif;
  --display: "Syne", "Arial Black", sans-serif;
  --serif: "Cormorant Garamond", Georgia, serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--space); color: var(--text); font-family: var(--font); overflow: hidden; }
button, input, select { font-family: inherit; }
button { cursor: pointer; }
img { max-width: 100%; display: block; }

#globe-view,
#map-view {
  position: fixed;
  inset: 0;
}
#map-view { opacity: 0; pointer-events: none; z-index: 2; background: var(--space); }
#globe-view { z-index: 1; background: var(--space); }
body.is-map #map-view { opacity: 1; pointer-events: auto; }
body.is-map #globe-view { opacity: 0; visibility: hidden; pointer-events: none; }
body.is-map .orbit-chrome { opacity: 0; pointer-events: none; }

#globe { width: 100%; height: 100%; }
#map { width: 100%; height: 100%; background: var(--space); }

.vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at center, transparent 42%, rgba(2, 4, 10, 0.55) 100%),
    linear-gradient(180deg, rgba(2, 4, 10, 0.35) 0%, transparent 18%, transparent 78%, rgba(2, 4, 10, 0.72) 100%);
  z-index: 2;
}

.orbit-chrome { position: absolute; inset: 0; z-index: 3; pointer-events: none; }
.orbit-chrome > * { pointer-events: auto; }

.topbar {
  position: absolute;
  top: 22px;
  left: 22px;
  right: 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
  color: inherit;
}
.brand-mark {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 0 0 1px rgba(244, 211, 94, 0.45), 0 0 28px rgba(125, 211, 252, 0.28);
}
.wordmark {
  font-family: var(--display);
  font-weight: 800;
  letter-spacing: 0.14em;
  font-size: 22px;
  line-height: 1;
}
.wordmark .gold { color: var(--gold); }
.tagline {
  font-family: var(--serif);
  font-style: italic;
  font-size: 13px;
  color: var(--atm);
  margin-top: 6px;
  letter-spacing: 0.02em;
}

.ghost-btn,
.gold-btn {
  border: 0;
  border-radius: 999px;
  padding: 12px 22px;
  font-weight: 600;
  letter-spacing: 0.04em;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}
.ghost-btn {
  background: rgba(7, 20, 40, 0.55);
  color: var(--text);
  border: 1px solid var(--line);
  backdrop-filter: blur(12px);
}
.gold-btn {
  background: linear-gradient(180deg, var(--gold-2), var(--gold));
  color: #1a1403;
  box-shadow: 0 8px 30px rgba(244, 211, 94, 0.28);
}
.gold-btn:hover, .ghost-btn:hover { transform: translateY(-1px); }
.gold-btn:active, .ghost-btn:active { transform: translateY(0); }

.hero-copy {
  position: absolute;
  left: 50%;
  bottom: 48px;
  transform: translateX(-50%);
  text-align: center;
  width: min(720px, calc(100% - 40px));
}
.hero-copy h1 {
  font-family: var(--display);
  font-size: clamp(28px, 4vw, 52px);
  letter-spacing: 0.08em;
  margin: 0 0 10px;
  font-weight: 800;
  text-shadow: 0 10px 40px rgba(0,0,0,0.65);
}
.hero-copy p {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 16px;
}
.hero-actions { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }

.loader {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 4;
  background: var(--space);
  transition: opacity 0.6s ease;
}
.loader.hide { opacity: 0; pointer-events: none; }
.loader-inner { text-align: center; }
.loader-ring {
  width: 72px;
  height: 72px;
  margin: 0 auto 18px;
  border-radius: 50%;
  border: 2px solid rgba(125, 211, 252, 0.2);
  border-top-color: var(--gold);
  animation: spin 1.1s linear infinite;
  box-shadow: 0 0 24px rgba(244, 211, 94, 0.2);
}
.loader p { color: var(--muted); letter-spacing: 0.18em; text-transform: uppercase; font-size: 12px; }
@keyframes spin { to { transform: rotate(360deg); } }

.sidebar {
  position: absolute;
  top: 16px;
  left: 16px;
  width: min(400px, calc(100vw - 24px));
  max-height: calc(100vh - 32px);
  overflow: auto;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  padding: 16px;
  z-index: 1000;
}
.sidebar::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(125, 211, 252, 0.25); border-radius: 8px; }

.header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin: -16px -16px 16px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(12, 59, 102, 0.35), transparent);
  border-radius: var(--radius) var(--radius) 0 0;
}
.header .brand-mark { width: 48px; height: 48px; }
.header .wordmark { font-size: 18px; }

.search-wrap { display: flex; gap: 8px; margin-bottom: 8px; }
.search {
  flex: 1;
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(2, 4, 10, 0.55);
  color: var(--text);
  font-size: 15px;
  margin-bottom: 0;
  outline: none;
}
.search:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(244, 211, 94, 0.18); }
.search-go, .search-clear {
  border-radius: 12px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  background: var(--navy);
  color: var(--text);
  font-weight: 600;
  font-size: 13px;
}
.search-go { background: linear-gradient(180deg, var(--gold-2), var(--gold)); color: #1a1403; border: 0; }
.search-hints { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.search-hints button {
  background: rgba(2, 4, 10, 0.35);
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
}
.search-hints button:hover { color: var(--text); border-color: var(--gold); }

.controls { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.controls select, .controls button {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(2, 4, 10, 0.45);
  color: var(--text);
}
.controls button { background: var(--navy); }

.panel h3 { margin: 0 0 6px; font-size: 18px; }
.panel p { margin: 0 0 12px; color: var(--muted); font-size: 14px; }
.item {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(125, 211, 252, 0.12);
  padding: 12px;
  margin-bottom: 8px;
  border-radius: 12px;
  cursor: pointer;
  transition: 0.18s ease;
}
.item:hover { transform: translateX(3px); border-color: rgba(244, 211, 94, 0.4); background: rgba(244, 211, 94, 0.06); }
.item strong { display: block; margin-bottom: 4px; }
.item small { color: var(--muted); }
.badge {
  display: inline-block;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 7px;
  border-radius: 999px;
  margin-right: 6px;
  border: 1px solid var(--line);
  color: var(--gold);
}
.badge.violent { color: #fecaca; border-color: rgba(239, 68, 68, 0.4); }
.badge.property { color: var(--atm); }

.legend {
  position: absolute;
  bottom: 20px;
  right: 20px;
  background: var(--glass);
  border: 1px solid var(--line);
  padding: 12px 14px;
  border-radius: 12px;
  z-index: 1000;
  font-size: 13px;
  backdrop-filter: blur(12px);
  line-height: 1.6;
}
.legend-title { font-weight: 700; margin-bottom: 4px; letter-spacing: 0.04em; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; }

.back-globe {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 1000;
}

.footer-logo { text-align: center; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.footer-logo img { width: 72px; height: 72px; border-radius: 50%; margin: 0 auto 8px; }
.footer-tagline { font-family: var(--serif); font-style: italic; color: var(--muted); font-size: 13px; margin: 0; }
.source-note { font-size: 11px; color: var(--muted); line-height: 1.4; margin: 8px 0 0; }
a.source { color: var(--gold); text-decoration: none; margin-left: 6px; }
a.source:hover { text-decoration: underline; }
.leaflet-popup-content a { color: var(--gold); }

.drawer {
  position: absolute;
  top: 16px;
  right: 16px;
  width: min(420px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow: auto;
  z-index: 1100;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}
.drawer[hidden] { display: none; }
.drawer-close {
  float: right;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
}
.drawer-media { margin: 8px 0 14px; min-height: 0; }
.drawer-media img,
.drawer-media iframe {
  width: 100%;
  border-radius: 12px;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: #050814;
  border: 0;
}
.drawer-media .preview-fallback {
  border-radius: 12px;
  padding: 28px 16px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  font-size: 13px;
}
.drawer-kicker {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
  margin: 0 0 6px;
}
.drawer h2 { font-size: 20px; line-height: 1.25; margin: 0 0 8px; }
.drawer-meta { color: var(--muted); font-size: 13px; margin: 0 0 10px; }
.drawer-summary { margin: 0 0 16px; color: var(--text); font-size: 14px; line-height: 1.5; }
.drawer-source { display: inline-block; text-decoration: none; }
.item.active { border-color: rgba(244, 211, 94, 0.55); background: rgba(244, 211, 94, 0.08); }

.leaflet-control-attribution {
  background: rgba(2, 4, 10, 0.7) !important;
  color: var(--muted) !important;
}
.leaflet-control-attribution a { color: var(--atm) !important; }
.leaflet-tooltip { background: var(--navy); color: var(--text); border: 1px solid var(--line); }

@media (max-width: 720px) {
  .topbar { align-items: center; gap: 8px; }
  .brand { min-width: 0; }
  .brand-mark { width: 40px; height: 40px; }
  .wordmark { font-size: 14px; letter-spacing: 0.08em; }
  .tagline { display: none; }
  .topbar .gold-btn { display: none; }
  .hero-copy { bottom: 22px; }
  .hero-copy h1 { font-size: 28px; letter-spacing: 0.1em; line-height: 1.05; }
  .hero-copy p { font-size: 13px; padding: 0 12px; }
  .gold-btn, .ghost-btn { padding: 10px 14px; font-size: 13px; }
  .sidebar { top: auto; bottom: 0; left: 0; right: 0; width: 100%; max-height: 48vh; border-radius: 18px 18px 0 0; }
  .legend { display: none; }
  .back-globe { top: 12px; right: 12px; padding: 8px 12px; font-size: 12px; }
  .search-wrap { flex-wrap: wrap; }
  .drawer {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-height: 62vh;
    border-radius: 18px 18px 0 0;
  }
  body.drawer-open .sidebar { display: none; }
}
