:root {
  --bg: #0B0F14;
  --panel: #141A20;
  --cream: #F7F4EE;
  --muted: #9AA3AD;
  --sage: #3D6B5A;
  --sage2: #8FBFA9;
  --line: #1e262e;
  --radius: 12px;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html, body {
  margin: 0; min-height: 100%;
  background: var(--bg); color: var(--cream);
  font-family: "IBM Plex Sans", system-ui, sans-serif;
}
html.embed, html.embed body { height: 100%; overflow: hidden; }

a { color: var(--sage2); text-decoration: none; }
a:hover { color: var(--cream); }

header.app-bar {
  position: sticky; top: 0; z-index: 1000;
  display: flex; align-items: center; gap: 14px;
  padding: 12px 18px;
  background: rgba(11,15,20,.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
header.app-bar img.wordmark { height: 32px; width: auto; display: block; }
header.app-bar .sub {
  color: var(--muted); font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
}
header.app-bar nav { margin-left: auto; display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
header.app-bar nav a {
  font-size: 12px; color: var(--muted); letter-spacing: .04em;
}
header.app-bar nav a:hover { color: var(--cream); }

.open-full { display: none; }
html.embed .open-full {
  display: inline-flex; align-items: center; gap: .35rem;
  position: fixed; top: 8px; right: 8px; z-index: 4000;
  background: var(--sage); color: var(--cream); text-decoration: none;
  font-size: .72rem; font-weight: 600; letter-spacing: .05em; text-transform: uppercase;
  padding: .55rem .85rem; border-radius: 999px;
  border: 1px solid rgba(143,191,169,.35);
  box-shadow: 0 6px 18px rgba(0,0,0,.35);
}
html.embed header.app-bar { padding-right: 9.5rem; }
html.embed header.app-bar img.wordmark { height: 22px; }
html.embed header.app-bar .sub { display: none; }

.stage {
  display: grid;
  grid-template-columns: minmax(280px, 420px) minmax(0, 1fr);
  min-height: calc(100vh - 57px);
}
.story {
  position: relative; z-index: 2;
  padding: 28px 22px 80px;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, #0B0F14 0%, #0e141a 100%);
}
.story .intro h1 {
  margin: 0 0 8px;
  font-family: Syne, "IBM Plex Sans", sans-serif;
  font-size: 1.55rem; font-weight: 700; letter-spacing: -.02em;
}
.story .intro p {
  margin: 0 0 28px; color: var(--muted); font-size: 14px; line-height: 1.5;
}
.beat {
  min-height: 72vh;
  display: flex; flex-direction: column; justify-content: center;
  padding: 24px 0;
  border-top: 1px solid transparent;
  opacity: .38;
  transition: opacity .35s ease;
}
.beat.active { opacity: 1; }
.beat .idx {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--sage2); margin-bottom: 10px;
}
.beat h2 {
  margin: 0 0 10px;
  font-family: Syne, sans-serif;
  font-size: 1.28rem; font-weight: 700; letter-spacing: -.015em;
}
.beat p {
  margin: 0; color: var(--muted); font-size: 14.5px; line-height: 1.55; max-width: 34rem;
}

.map-pane {
  position: sticky; top: 57px; height: calc(100vh - 57px);
  background: #0d1218;
}
#map { width: 100%; height: 100%; background: #0d1218; }

.map-overlay {
  position: absolute; z-index: 500; left: 14px; top: 14px;
  pointer-events: none; max-width: min(360px, 72%);
}
.map-overlay .chip {
  display: inline-block;
  background: rgba(11,15,20,.86);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
}
.map-overlay h3 {
  margin: 0; font-family: Syne, sans-serif; font-size: 15px; font-weight: 700;
  text-shadow: 0 1px 10px rgba(0,0,0,.55);
}
.map-overlay span {
  display: block; margin-top: 3px; color: var(--muted); font-size: 11.5px;
}

.legend {
  position: absolute; z-index: 500; left: 14px; bottom: 28px;
  background: rgba(11,15,20,.88); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 10px 7px;
  min-width: 150px; max-width: 210px;
  opacity: 0; transition: opacity .35s ease; pointer-events: none;
}
.legend.visible { opacity: 1; }
.legend h4 {
  margin: 0 0 6px; font-size: 10px; letter-spacing: .12em;
  text-transform: uppercase; color: var(--muted); font-weight: 500;
}
.barscale { display: flex; height: 8px; border-radius: 999px; overflow: hidden; margin: 2px 0 5px; border: 1px solid rgba(0,0,0,.2); }
.barscale i { flex: 1; }
.leg-range {
  display: flex; justify-content: space-between;
  font-family: "IBM Plex Mono", monospace; font-size: 10px; color: var(--muted);
}
.swatch { display: flex; align-items: center; gap: 8px; margin: 3px 0; font-size: 11px; color: var(--cream); }
.swatch b { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: 0 0 auto; border: 1.5px solid rgba(247,244,238,.45); }

.scrubber {
  position: absolute; z-index: 500; right: 14px; top: 50%;
  transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 10px; align-items: center;
}
.scrubber button {
  appearance: none; width: 10px; height: 10px; border-radius: 50%;
  border: 1px solid rgba(143,191,169,.45);
  background: transparent; padding: 0; cursor: pointer;
  transition: background .2s, transform .2s;
}
.scrubber button[aria-current="true"] {
  background: var(--sage2); transform: scale(1.25);
  border-color: var(--sage2);
}
.scrubber button:hover { background: rgba(143,191,169,.35); }

footer.page-foot {
  border-top: 1px solid var(--line);
  padding: 12px 18px;
  color: var(--muted); font-size: 11px; line-height: 1.45;
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
footer.page-foot b { color: var(--cream); font-weight: 500; }

.leaflet-container { background: #0d1218; font-family: "IBM Plex Sans", system-ui, sans-serif; }
.leaflet-control-zoom a {
  background: var(--panel) !important; color: var(--cream) !important;
  border-color: var(--line) !important;
}
.leaflet-control-attribution {
  background: rgba(11,15,20,.82) !important; color: var(--muted) !important;
  font-size: 9px !important;
}
.leaflet-control-attribution a { color: var(--sage2) !important; }

@media (max-width: 900px) {
  .stage { grid-template-columns: 1fr; }
  .map-pane {
    position: relative; top: 0; height: 52vh; order: -1;
    border-bottom: 1px solid var(--line);
  }
  .story { border-right: 0; padding-top: 18px; }
  .beat { min-height: 48vh; }
  .scrubber { top: auto; bottom: 18px; right: 12px; transform: none; flex-direction: row; }
}

html.embed .stage { height: calc(100% - 48px); min-height: 0; }
html.embed .story { overflow: auto; padding: 16px 14px 40px; }
html.embed .map-pane { height: 100%; top: 0; }
html.embed footer.page-foot { display: none; }

.story .intro .cue {
  margin: -8px 0 24px;
  color: var(--sage2, #8FBFA9);
  font-size: 13px; line-height: 1.45;
  padding: 8px 10px;
  border-left: 2px solid var(--sage, #3D6B5A);
  background: rgba(61,107,90,.12);
  border-radius: 0 8px 8px 0;
}
.overlay-hint {
  display: block; margin-top: 4px;
  color: var(--sage2, #8FBFA9); font-size: 11px;
}
.readout {
  margin-top: 8px; pointer-events: none;
  background: rgba(11,15,20,.9);
  border: 1px solid var(--line, #1e262e);
  border-radius: 10px; padding: 8px 10px;
  font-size: 12.5px; line-height: 1.4;
  max-width: 260px;
}
.readout[hidden] { display: none !important; }
.readout .meta { display: block; margin-top: 3px; color: var(--muted, #9AA3AD); font-size: 11px; }
