:root {
  --bg: #0b1218;
  --panel: #111b23;
  --panel-2: #16232d;
  --line: #22323e;
  --text: #e6edf2;
  --muted: #8fa1ae;
  --accent: #5fb4ff;
  --warn: #ffb35c;
  --ocean: #0d1923;
  --land: #1b2731;
  --coast: rgba(170, 190, 205, 0.55);
  --border: rgba(170, 190, 205, 0.28);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
a { color: var(--accent); }
button { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.pad { padding: 12px 16px; }

/* Header */
.top {
  display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 12px 20px; border-bottom: 1px solid var(--line);
}
.brand h1 { margin: 0; font-size: 19px; letter-spacing: 0.2px; }
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.tools { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.fresh { color: var(--muted); font-size: 13px; }
.units { position: relative; }
.units-btn {
  border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 4px 10px;
  cursor: pointer; font-size: 13px; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px;
}
.units-btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }
.units-panel {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 10; background: var(--panel);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; display: grid; gap: 8px;
  min-width: 210px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}
.units-panel[hidden] { display: none; }
.units-panel label { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 13px; }
.units-panel select {
  font: inherit; color: var(--text); background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 6px; padding: 3px 6px;
}

/* Layout: list | map | details */
.layout {
  flex: 1;
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr) 340px;
  min-height: 0;
}
.list { border-right: 1px solid var(--line); overflow-y: auto; max-height: calc(100vh - 120px); }
.details { border-left: 1px solid var(--line); overflow-y: auto; max-height: calc(100vh - 120px); padding: 16px 18px 24px; }
.stage { display: flex; flex-direction: column; min-width: 0; }

/* Highlight list */
.list h2 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.8px; color: var(--muted); margin: 16px 16px 6px; }
.entry {
  display: block; width: 100%; text-align: left; background: none; border: 0; cursor: pointer;
  padding: 10px 16px; border-left: 3px solid transparent;
}
.entry:hover { background: var(--panel); }
.entry[aria-current="true"] { background: var(--panel-2); border-left-color: var(--accent); }
.entry .t { font-weight: 600; font-size: 14px; display: block; }
.entry .w { color: var(--muted); font-size: 12.5px; display: block; margin-top: 2px; }

/* Scene tabs, share and save */
.scenebar {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--line);
  background: var(--panel); min-width: 0;
}
.scene-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.8px; white-space: nowrap; }
.tabs { position: relative; display: flex; gap: 6px; overflow-x: auto; flex: 1; min-width: 0; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  display: flex; align-items: center; gap: 7px; flex: 0 0 auto; max-width: 300px;
  border: 1px solid var(--line); background: var(--bg); border-radius: 999px; padding: 4px 12px 4px 5px;
  cursor: pointer; font-size: 13px; text-align: left;
}
.tab .n {
  display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  background: var(--panel-2); font-size: 12px; font-weight: 700; flex: none;
}
.tab .tt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tab:hover { border-color: var(--muted); }
.tab[aria-selected="true"] { border-color: var(--accent); background: var(--panel-2); }
.tab[aria-selected="true"] .n { background: var(--accent); color: #04121f; }
.actions { display: flex; gap: 6px; flex: none; }
.act {
  display: inline-flex; align-items: center; gap: 5px; height: 32px; padding: 0 10px;
  border: 1px solid var(--line); background: var(--panel-2); border-radius: 8px; cursor: pointer; font-size: 13px;
}
.act[hidden] { display: none; }
.act svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.save, .video { position: relative; }
.video[hidden] { display: none; }
.recording {
  position: absolute; inset: 0; z-index: 30; display: grid; place-items: center; font-size: 16px;
  background: rgba(8, 14, 19, 0.92); color: var(--text);
}
.recording[hidden] { display: none; }
.save[hidden] { display: none; }
.save-panel {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; width: 270px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 10px; padding: 12px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  display: grid; gap: 8px; font-size: 13px;
}
.save-panel[hidden] { display: none; }
.save-panel p { margin: 0; }
.save-panel button {
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px; width: 100%;
  border: 1px solid var(--line); background: var(--panel-2); border-radius: 8px; padding: 8px 10px; cursor: pointer;
}
.save-panel button[hidden] { display: none; }
.save-panel small { color: var(--muted); }
.notice {
  position: absolute; z-index: 5; top: 12px; left: 50%; transform: translateX(-50%); max-width: min(520px, calc(100% - 120px));
  background: rgba(8, 14, 19, 0.92); border: 1px solid var(--accent); padding: 8px 14px; border-radius: 8px;
  font-size: 13.5px; text-align: center; cursor: pointer;
}
.details .archived {
  background: var(--panel-2); border-left: 3px solid var(--warn); padding: 8px 10px; border-radius: 4px; font-size: 13.5px;
}

/* Map */
.map {
  position: relative; flex: 1; min-height: 420px; overflow: hidden;
  background: var(--ocean); touch-action: none; cursor: grab;
}
.map.dragging { cursor: grabbing; }
.map canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.caption {
  position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%);
  max-width: min(640px, calc(100% - 32px)); background: rgba(8, 14, 19, 0.82);
  padding: 8px 14px; border-radius: 8px; font-size: 14.5px; text-align: center; pointer-events: none;
  backdrop-filter: blur(6px);
}
.readout {
  position: absolute; background: rgba(8, 14, 19, 0.9); border: 1px solid var(--line);
  padding: 5px 9px; border-radius: 6px; font-size: 13px; pointer-events: none; white-space: nowrap;
  transform: translate(-50%, calc(-100% - 10px));
}
.status {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  background: rgba(8, 14, 19, 0.85); padding: 6px 12px; border-radius: 6px; font-size: 13px; color: var(--muted);
}
.legend {
  position: absolute; top: 12px; left: 12px; background: rgba(8, 14, 19, 0.82);
  padding: 8px 10px 6px; border-radius: 8px; font-size: 12px; pointer-events: none; min-width: 200px;
}
.legend .lt { font-weight: 600; margin-bottom: 4px; }
.legend canvas { position: static; display: block; width: 200px; height: 10px; border-radius: 2px; }
.legend .scale { position: relative; height: 16px; width: 200px; color: var(--muted); margin-top: 2px; }
.legend .scale span { position: absolute; top: 0; transform: translateX(-50%); white-space: nowrap; font-variant-numeric: tabular-nums; }
.legend .scale span[style^="left:0.0%"] { transform: none; }
.legend .note { color: var(--muted); margin-top: 3px; }
.zoom { position: absolute; right: 12px; top: 12px; display: flex; flex-direction: column; gap: 4px; }
.zoom button {
  width: 36px; height: 36px; padding: 0; border-radius: 8px; border: 1px solid var(--line);
  background: rgba(8, 14, 19, 0.85); color: var(--text); cursor: pointer;
  display: grid; place-items: center; -webkit-appearance: none; appearance: none;
}
.zoom button[hidden] { display: none; }
.zoom svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.zoom .exit { display: none; }
.full .zoom .enter { display: none; }
.full .zoom .exit { display: inline; }

/* Map style switcher, under the zoom buttons. */
.layers { position: relative; }
.layers-panel {
  position: absolute; right: calc(100% + 8px); top: 0; display: flex; gap: 6px; padding: 6px;
  background: rgba(8, 14, 19, 0.92); border: 1px solid var(--line); border-radius: 10px;
}
.layers-panel[hidden] { display: none; }
.zoom .layers-panel button {
  width: 64px; height: auto; padding: 4px 4px 3px; display: grid; gap: 3px; justify-items: center;
  font-size: 11.5px; border-radius: 8px; border: 1px solid transparent; background: none;
}
.zoom .layers-panel button[aria-checked="true"] { border-color: var(--accent); background: var(--panel-2); }
.sw { width: 54px; height: 36px; border-radius: 5px; border: 1px solid rgba(255, 255, 255, 0.15); display: block; }
.sw-dark { background: linear-gradient(135deg, #1b2731 0 45%, #0d1923 45%); }
.sw-light { background: linear-gradient(135deg, #eceee8 0 45%, #c4d3de 45%); }
.sw-satellite { background: #1d3b5a url("https://gibs.earthdata.nasa.gov/wmts/epsg3857/best/BlueMarble_ShadedRelief_Bathymetry/default/GoogleMapsCompatible_Level8/3/2/4.jpeg") center / cover; }

/* Help */
.help {
  width: min(680px, calc(100% - 32px)); max-height: calc(100vh - 48px); padding: 0; border: 1px solid var(--line);
  border-radius: 12px; background: var(--panel); color: var(--text); box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
}
.help::backdrop { background: rgba(0, 0, 0, 0.55); }
.help-head {
  display: flex; justify-content: space-between; align-items: center; padding: 14px 18px;
  border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel);
}
.help-head h2 { margin: 0; font-size: 18px; }
.help-close { border: 0; background: none; font-size: 26px; line-height: 1; cursor: pointer; color: var(--muted); padding: 0 4px; }
.help-body { padding: 4px 18px 18px; font-size: 14.5px; }
.help-body h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.8px; color: var(--muted); margin: 18px 0 6px; }
.help-body p { margin: 0 0 8px; }
.help-body ul { margin: 0; padding-left: 18px; }
.help-body li { margin-bottom: 5px; }
#helpBtn svg { stroke-width: 1.5; }

/* Full screen: the map and timeline fill the screen. */
.stage.full { position: fixed; inset: 0; z-index: 50; background: var(--bg); height: 100vh; height: 100dvh; }
.stage.full .map { min-height: 0; }
.stage.full .timeline { padding-bottom: max(10px, env(safe-area-inset-bottom)); }

/* Timeline */
.timeline {
  display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-top: 1px solid var(--line);
  background: var(--panel);
}
.play, .speed {
  border: 1px solid var(--line); background: var(--panel-2); border-radius: 8px; cursor: pointer;
  height: 34px; min-width: 40px;
}
.track { flex: 1; position: relative; }
.track input { width: 100%; accent-color: var(--accent); }
.ticks { position: relative; height: 8px; }
.ticks i { position: absolute; top: 0; width: 1px; height: 6px; background: var(--muted); opacity: 0.6; }
.ticks i.loaded { background: var(--accent); opacity: 0.9; }
.when { font-variant-numeric: tabular-nums; font-size: 13px; min-width: 190px; text-align: right; }
.when small { display: block; color: var(--muted); font-size: 11.5px; }

/* Details */
.details h2 { margin: 0 0 4px; font-size: 19px; line-height: 1.3; }
.details .where { color: var(--muted); margin: 0 0 10px; font-size: 13.5px; }
.details h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.8px; color: var(--muted); margin: 18px 0 6px; }
.details p { margin: 0 0 10px; }
.details ul { margin: 0; padding-left: 18px; }
.details li { margin-bottom: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 12px; }
.chip { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); }
.evidence .k { color: var(--muted); font-size: 12px; text-transform: uppercase; margin-right: 4px; }

.foot {
  display: flex; flex-wrap: wrap; gap: 6px 18px; padding: 10px 20px; border-top: 1px solid var(--line);
  color: var(--muted); font-size: 12px;
}

/* Narrow screens: list as a scroller on top, details under the map */
@media (max-width: 1100px) {
  .layout { grid-template-columns: 240px minmax(0, 1fr); flex: none; }
  .list { max-height: 560px; }
  .map { min-height: 480px; }
  .details { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--line); max-height: none; overflow: visible; }
}
@media (max-width: 720px) {
  .top { padding: 10px 16px; }
  .brand p { display: none; }
  .units-panel { left: 0; right: auto; }
  .scene-label { display: none; }
  .scenebar { padding: 6px 8px; gap: 6px; }
  .act span { display: none; }
  .act { padding: 0 8px; }
  .tab { max-width: 170px; }
  .layout { display: flex; flex-direction: column; flex: none; }
  .layout > * { flex: none; }
  .list {
    display: flex; overflow-x: auto; overflow-y: hidden; border-right: 0; border-bottom: 1px solid var(--line);
    max-height: none; scrollbar-width: none;
  }
  .list h2 { display: none; }
  .entry { flex: 0 0 auto; width: auto; max-width: 230px; border-left: 0; border-bottom: 3px solid transparent; padding: 8px 12px; }
  .entry[aria-current="true"] { border-bottom-color: var(--accent); }
  .entry .w { display: none; }
  .map { min-height: 62vh; }
  .legend { min-width: 0; padding: 6px 8px 4px; font-size: 11px; }
  .legend canvas, .legend .scale { width: 140px; }
  .legend .note { display: none; }
  .legend .note.credit { display: block; }
  .when { min-width: 0; font-size: 12px; }
  .timeline { gap: 8px; padding: 8px 12px; }
  .details { padding: 14px 16px 20px; }
  .foot { padding: 10px 16px; }
}
