:root {
  --bg-0: #020a12;
  --bg-1: #0a1f31;
  --panel-bg: rgba(7, 19, 30, 0.78);
  --panel-border: rgba(125, 205, 225, 0.16);
  --panel-edge: rgba(170, 235, 245, 0.08);
  --txt-hi: #eef7fa;
  --txt-mid: #9fb6c3;
  --txt-low: #5f7886;
  --accent: #35e0d2;
  --accent-2: #2ee06e;
  --warn: #f6b93d;
  --mono: "Cascadia Mono", Consolas, "JetBrains Mono", monospace;
  --sans: "Segoe UI", Inter, system-ui, sans-serif;
}

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

html, body { height: 100%; overflow: hidden; }

body {
  font-family: var(--sans);
  color: var(--txt-hi);
  background:
    radial-gradient(120% 90% at 50% 30%, var(--bg-1) 0%, var(--bg-0) 70%);
  user-select: none;
}

#scene {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  display: block;
  outline: none;
  cursor: grab;
}
#scene:active { cursor: grabbing; }

#leaders {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 5;
}

/* ---------- entrance ---------- */
.ui-fade { opacity: 0; transform: translateY(6px); transition: opacity .9s ease, transform .9s ease; }
body.ready .ui-fade { opacity: 1; transform: none; }

/* ---------- glass / panels ---------- */
.glass, .panel {
  background: var(--panel-bg);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border: 1px solid var(--panel-border);
  box-shadow: 0 10px 34px rgba(0, 0, 0, .45), inset 0 1px 0 var(--panel-edge);
}

.panel {
  position: fixed;
  z-index: 10;
  border-radius: 10px;
  padding: 14px 16px;
  min-width: 230px;
  font-size: 13px;
}

.panel h3 {
  font-size: 14.5px;
  letter-spacing: .4px;
  margin-bottom: 10px;
  font-weight: 700;
}

.panel h4 {
  font-size: 12.5px;
  color: var(--txt-hi);
  margin: 11px 0 7px;
  font-weight: 700;
}

.panel .sub { color: var(--txt-low); font-size: 11px; margin: -4px 0 8px; }

.row {
  display: flex; justify-content: space-between; align-items: center;
  gap: 18px;
  padding: 2.5px 0;
  color: var(--txt-mid);
}
.row .val { color: var(--txt-hi); display: inline-flex; align-items: center; gap: 7px; }
.mono { font-family: var(--mono); font-size: 12.5px; letter-spacing: 0; }

.dot {
  width: 8px; height: 8px; border-radius: 50%; display: inline-block;
  background: var(--accent-2);
  box-shadow: 0 0 8px var(--accent-2);
}
.dot.lime { background: #9fe05a; box-shadow: 0 0 6px #9fe05a; }

.foot {
  margin-top: 10px; padding-top: 9px;
  border-top: 1px solid rgba(125, 205, 225, 0.12);
  color: var(--txt-low); font-size: 11.5px;
}

/* battery */
.batt {
  position: relative; display: inline-block;
  width: 22px; height: 11px;
  border: 1.5px solid #9fe05a; border-radius: 2.5px;
}
.batt::after {
  content: ""; position: absolute; right: -4px; top: 2.5px;
  width: 2.5px; height: 4px; background: #9fe05a; border-radius: 1px;
}
.batt i {
  position: absolute; left: 1px; top: 1px; bottom: 1px;
  width: 80%;
  background: #9fe05a; border-radius: 1px;
  transition: width .6s ease;
}

/* ---------- nav ---------- */
.nav {
  position: fixed; top: 0; left: 0; right: 0;
  height: 54px;
  display: flex; align-items: center;
  padding: 0 22px;
  gap: 26px;
  z-index: 20;
  border-left: none; border-right: none; border-top: none;
  border-radius: 0;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-name {
  color: #f2f7fa;
  font-size: 17.5px;
  font-weight: 600;
  letter-spacing: .2px;
}
.nav nav { display: flex; gap: 6px; flex: 1; height: 100%; }
.nav nav a {
  display: flex; align-items: center;
  padding: 0 18px;
  color: var(--txt-mid);
  text-decoration: none;
  font-size: 14px;
  position: relative;
  transition: color .25s;
}
.nav nav a:hover { color: var(--txt-hi); }
.nav nav a.active {
  color: var(--accent);
  background: rgba(53, 224, 210, 0.07);
}
.nav nav a.active::after {
  content: ""; position: absolute; left: 12px; right: 12px; bottom: 0;
  height: 2px; background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}
.clock {
  display: flex; align-items: center; gap: 8px;
  color: var(--txt-hi); font-size: 15px;
  font-family: var(--mono);
}

/* ---------- legend ---------- */
#legend {
  position: fixed; left: 26px; top: 50%;
  transform: translateY(-58%);
  z-index: 12;
  border-radius: 12px;
  padding: 16px 14px;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
body.ready #legend { transform: translateY(-58%); }
.lg-label { font-size: 12.5px; color: var(--txt-mid); }

/* globe on/off switch above the slider */
.lg-toggle {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  cursor: pointer; user-select: none; margin-bottom: 2px;
}
.lg-toggle input { display: none; }
.lg-switch {
  position: relative;
  width: 34px; height: 18px;
  border-radius: 10px;
  background: #152a3a;
  border: 1px solid rgba(125, 205, 225, 0.3);
  transition: background .25s, border-color .25s;
}
.lg-switch::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 12px; height: 12px; border-radius: 50%;
  background: #7fa9bb;
  transition: transform .25s, background .25s, box-shadow .25s;
}
.lg-toggle input:checked + .lg-switch {
  background: rgba(53, 224, 210, 0.3);
  border-color: rgba(53, 224, 210, 0.6);
}
.lg-toggle input:checked + .lg-switch::after {
  transform: translateX(16px);
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}
.lg-tog-label { font-size: 10.5px; color: var(--txt-mid); letter-spacing: .3px; }
.lg-track {
  position: relative;
  width: 13px; height: 300px;
  border-radius: 8px;
  background: linear-gradient(to bottom, #46f0a4 0%, #1fc98e 22%, #0e8f7e 45%, #0a5b62 68%, #06303f 88%, #041d2b 100%);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.12), 0 0 18px rgba(46,224,110,.18);
  cursor: pointer;
}
.lg-knob {
  position: absolute; left: 50%; top: 38%;
  width: 20px; height: 20px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: #07131e;
  border: 2.5px solid #fff;
  box-shadow: 0 0 12px rgba(70, 240, 164, .8);
  cursor: grab;
}
.lg-knob::after {
  content: ""; position: absolute; inset: 4px;
  border-radius: 50%; background: var(--accent-2);
  box-shadow: 0 0 8px var(--accent-2);
}
.lg-bubble {
  position: absolute; left: 26px; top: 50%;
  transform: translateY(-50%);
  white-space: nowrap;
  background: #0c2230;
  border: 1px solid rgba(125,205,225,.25);
  padding: 4px 9px; border-radius: 6px;
  font-family: var(--mono); font-size: 12px;
  color: var(--txt-hi);
  box-shadow: 0 4px 14px rgba(0,0,0,.4);
}

/* ---------- right rail: stacked panels clear of the 3D scene ---------- */
.right-rail {
  position: fixed;
  top: 76px;
  right: 26px;
  bottom: 18px;
  width: 312px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  z-index: 10;
  pointer-events: none;          /* gaps let orbit-drag through */
  overflow: hidden;
}
.right-rail .panel {
  position: relative;            /* stack inside the rail, not fixed */
  pointer-events: auto;
  flex-shrink: 0;
}

/* ---------- station panel ---------- */
.station { min-width: 270px; }
.station header { display: flex; justify-content: space-between; align-items: flex-start; }
.station .x {
  background: none; border: none; color: var(--txt-low);
  font-size: 19px; cursor: pointer; line-height: 1; padding: 0 0 0 10px;
}
.station .x:hover { color: var(--txt-hi); }
.cta {
  margin-top: 13px;
  width: 100%;
  display: flex; align-items: center; justify-content: center; gap: 9px;
  background: linear-gradient(180deg, #45ecdd, #23c9bb);
  color: #03242b;
  font-weight: 700; font-size: 13.5px;
  border: none; border-radius: 8px;
  padding: 10px 12px;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(53, 224, 210, .35);
  transition: filter .2s, transform .15s;
}
.cta:hover { filter: brightness(1.1); }
.cta:active { transform: scale(.98); }

/* ---------- layer panel ---------- */
.layer { min-width: 300px; }
.layer .sub { font-size: 11.5px; color: var(--txt-mid); }
#roseCanvas { width: 280px; height: 235px; display: block; margin: 4px auto 0; }
.lp-legend {
  display: flex; align-items: center; gap: 7px; justify-content: flex-end;
  color: var(--txt-mid); font-size: 11.5px;
}

/* ---------- tile zoom chip ---------- */
.zoom-chip {
  position: fixed;
  left: 26px;
  bottom: 18px;
  z-index: 12;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  color: var(--txt-mid);
  letter-spacing: .4px;
  pointer-events: none;
}

/* ---------- tooltips ---------- */
.tooltip {
  position: fixed; z-index: 9;
  background: rgba(10, 24, 36, 0.85);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 9px 13px;
  font-size: 12.5px;
  color: var(--txt-mid);
  line-height: 1.55;
  box-shadow: 0 8px 26px rgba(0,0,0,.45);
  white-space: nowrap;
}
.tooltip b { color: var(--txt-hi); font-weight: 600; }
.tooltip.wide { line-height: 1.6; }

/* ---------- tooltip close (×) ---------- */
.tip-x {
  position: absolute; top: 4px; right: 7px;
  background: none; border: none;
  color: var(--txt-low); font-size: 17px;
  line-height: 1; padding: 2px; cursor: pointer;
  z-index: 2;
}
.tip-x:hover { color: var(--txt-hi); }
#chlTip, #moorTip { padding-right: 30px; }
#buoyCard h3, .layer h3 { padding-right: 20px; }

.hidden { display: none !important; }
