:root {
  --accent: #007aff;
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --glass-bg: rgba(255, 255, 255, 0.4);
  --glass-border: rgba(255, 255, 255, 0.6);
  --shadow: 0 16px 48px rgba(31, 38, 135, 0.16), 0 2px 10px rgba(0, 0, 0, 0.06);
  --glass-inset: inset 0 1px 1px rgba(255, 255, 255, 0.85),
    inset 0 -1px 1px rgba(255, 255, 255, 0.25);
  --radius: 24px;
  --bottombar-h: 128px;   /* kept in sync with #bottombar by app.js */
  --topbar-bottom: 86px;  /* #topbar bottom edge in px, kept in sync by app.js */
}

html, body {
  margin: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue",
    "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

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

.glass {
  position: relative;
  isolation: isolate;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.38), rgba(255, 255, 255, 0.2));
  backdrop-filter: blur(20px) saturate(180%) brightness(1.1);
  -webkit-backdrop-filter: blur(20px) saturate(180%) brightness(1.1);
  border-radius: var(--radius);
  box-shadow:
    0 26px 60px rgba(8, 16, 40, 0.28),
    0 8px 22px rgba(8, 16, 40, 0.14),
    0 2px 8px rgba(8, 16, 40, 0.09),
    0 0 0 0.5px rgba(8, 16, 40, 0.10),
    inset 0 1px 1px rgba(255, 255, 255, 0.65),
    inset 0 -1px 2px rgba(20, 20, 60, 0.12),
    inset 0 0 2.5px rgba(255, 255, 255, 0.3),
    inset 1.5px 0 1.5px -0.5px rgba(255, 130, 130, 0.1),
    inset -1.5px 0 1.5px -0.5px rgba(120, 160, 255, 0.12);
}

/* specular highlight + ambient refraction glow */
.glass::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background:
    radial-gradient(120% 90% at 15% -10%, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0) 45%),
    radial-gradient(140% 120% at 90% 110%, rgba(180, 200, 255, 0.16), rgba(255, 255, 255, 0) 50%);
  pointer-events: none;
  z-index: 1;
}

/* refracting edge: gradient rim light with subtle chromatic dispersion,
   brighter where light hits (simulated, consistent across browsers) */
.glass::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1.5px;
  background: conic-gradient(from 210deg at 50% 45%,
    rgba(255, 255, 255, 0.95),
    rgba(200, 220, 255, 0.28) 18%,
    rgba(255, 255, 255, 0.08) 42%,
    rgba(255, 255, 255, 0.12) 58%,
    rgba(255, 214, 228, 0.35) 76%,
    rgba(255, 255, 255, 0.85));
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
          mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
          mask-composite: exclude;
  pointer-events: none;
  z-index: 2;
}

.glass > * {
  position: relative;
  z-index: 3;
}

/* ---------- top control bar ---------- */
#topbar {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 8px 18px;
  z-index: 1000;
  max-width: calc(100% - 32px);
  flex-wrap: wrap;
}

/* brand block: model name over dataset name */
.brand {
  display: flex;
  flex-direction: column;
  gap: 1px;
  white-space: nowrap;
  user-select: none;
}

.brand-name {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.2px;
  line-height: 1.15;
  background: linear-gradient(135deg, #0a84ff, #5e5ce6);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-ds {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-2);
  opacity: 0.8;
}

.divider {
  width: 1px;
  align-self: stretch;
  margin: 4px 0;
  background: rgba(60, 60, 67, 0.14);
  border-radius: 1px;
}

.ctrl {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.ctrl > span {
  font-size: 11px;
  color: var(--text-2);
  letter-spacing: 0.3px;
}

#topbar select {
  appearance: none;
  -webkit-appearance: none;
  border: 0.5px solid rgba(255, 255, 255, 0.65);
  background:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' stroke='%236e6e73' stroke-width='1.5' fill='none' stroke-linecap='round'/></svg>")
    no-repeat right 10px center,
    linear-gradient(180deg, rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0.22));
  background-color: rgba(255, 255, 255, 0.22);
  color: var(--text);
  border-radius: 999px;
  padding: 5px 26px 5px 12px;
  font-size: 13px;
  cursor: pointer;
  outline: none;
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.7), 0 1px 3px rgba(0, 0, 0, 0.06);
  transition: box-shadow 0.15s ease, transform 0.12s ease;
}

#topbar select:hover {
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.9), 0 2px 6px rgba(0, 0, 0, 0.1);
}

#topbar select:focus {
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.28), inset 0 1px 1px rgba(255, 255, 255, 0.7);
}

/* segmented control (data source) */
.segmented {
  display: flex;
  background: rgba(255, 255, 255, 0.22);
  border: 0.5px solid rgba(255, 255, 255, 0.45);
  box-shadow: inset 0 1px 3px rgba(0, 0, 20, 0.08);
  border-radius: 999px;
  padding: 2px;
}

.segmented button {
  border: none;
  background: none;
  border-radius: 999px;
  padding: 4px 14px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

.segmented button.active {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(255, 255, 255, 0.82));
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.14), inset 0 1px 0.5px rgba(255, 255, 255, 0.9);
}

/* colorbar */
#colorbarWrap {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

#colorbarRow {
  display: flex;
  align-items: center;
  gap: 6px;
}

#autoRangeBtn {
  border: 0.5px solid rgba(255, 255, 255, 0.55);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0.2));
  color: var(--text);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 11px;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.7), 0 1px 3px rgba(0, 0, 0, 0.06);
  transition: box-shadow 0.15s ease, transform 0.12s ease;
}

#autoRangeBtn:hover {
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.9), 0 2px 6px rgba(0, 0, 0, 0.1);
  transform: translateY(-0.5px);
}

#autoRangeBtn:active {
  transform: translateY(0.5px) scale(0.97);
}

#colorbar {
  width: 160px;
  height: 10px;
  border-radius: 999px;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.12), 0 1px 0 rgba(255, 255, 255, 0.5);
}

#colorbarRow input {
  width: 52px;
  border: none;
  background: rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  font-size: 10.5px;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
  padding: 2px 4px;
  outline: none;
  text-align: center;
}

#colorbarRow input:focus {
  color: var(--text);
  background: rgba(255, 255, 255, 0.35);
  box-shadow: 0 0 0 2px rgba(0, 122, 255, 0.25);
}

#loading {
  font-size: 12px;
  color: var(--accent);
}

#loading:not([hidden])::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 5px;
  border: 1.5px solid rgba(0, 122, 255, 0.3);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: -1px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---------- liquid glass sliders ---------- */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 5px;
  border-radius: 999px;
  background: rgba(120, 120, 128, 0.28);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1), 0 0.5px 0 rgba(255, 255, 255, 0.5);
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffffff, #eef1f6 70%, #dde3ec);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.22), 0 0 0 0.5px rgba(0, 0, 0, 0.06),
    inset 0 1px 1px rgba(255, 255, 255, 0.9);
  cursor: pointer;
  transition: transform 0.15s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.12);
}

input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border: none;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffffff, #eef1f6 70%, #dde3ec);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.22), 0 0 0 0.5px rgba(0, 0, 0, 0.06);
  cursor: pointer;
}

#sizeSlider {
  width: 90px;
}

/* iOS-style toggle switch */
.switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.switch-track {
  position: absolute;
  inset: 0;
  border-radius: 12px;
  background: rgba(120, 120, 128, 0.28);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.12), inset 0 0 0 0.5px rgba(0, 0, 0, 0.04);
  transition: background 0.25s ease;
  cursor: pointer;
}

.switch-track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffffff, #eef1f6 70%, #dde3ec);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.25), inset 0 1px 1px rgba(255, 255, 255, 0.9);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.switch input:checked + .switch-track {
  background: #34c759;
}

.switch input:checked + .switch-track::after {
  transform: translateX(16px);
}

/* ---------- bottom time axis ---------- */
#bottombar {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  width: min(1240px, calc(100% - 32px));
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 7px;
  padding: 9px 16px 11px;
  box-sizing: border-box;
  z-index: 1000;
  --tl-lane-h: 18px;
  --tl-track-h: 26px;
  --tl-overview-h: 22px;
}
#bottombar.no-events { --tl-lane-h: 0px; }

#tlHead {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
  min-height: 34px;
}

#timeInfo {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 150px;
  line-height: 1.12;
}
#timeLabel {
  font-size: 14.5px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  white-space: nowrap;
  color: var(--text);
}
#timeSub {
  font-size: 10px;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: min(420px, 46vw);
}

#tlChips { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 21px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .2px;
  white-space: nowrap;
  background: rgba(255, 255, 255, .52);
  border: .5px solid rgba(255, 255, 255, .7);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, .8), 0 1px 2px rgba(0, 0, 0, .05);
  color: #33415c;
}
.chip[hidden] { display: none; }
.chip.kind-history { background: rgba(58, 134, 255, .16); color: #185bb3; }
.chip.kind-retro { background: rgba(95, 143, 206, .17); color: #2f557f; }
.chip.kind-forecast { background: rgba(242, 140, 30, .18); color: #8a4a05; }
.chip.ghost { background: rgba(255, 255, 255, .28); color: var(--text-2); font-weight: 500; }
.chip.event { background: rgba(255, 59, 48, .14); color: #a1160f; border-color: rgba(255, 120, 110, .4); }

#tlCtrl { display: flex; align-items: center; gap: 3px; margin-left: auto; flex-wrap: nowrap; }
#tlCtrl .tl-sep { width: 1px; height: 16px; background: rgba(60, 60, 67, .14); margin: 0 3px; }
#tlCtrl button, #eventListBtn {
  height: 26px;
  min-width: 26px;
  padding: 0 7px;
  border-radius: 7px;
  border: .5px solid rgba(255, 255, 255, 0.65);
  background: linear-gradient(180deg, rgba(255, 255, 255, .62), rgba(255, 255, 255, .3));
  color: var(--text);
  font-size: 11px;
  font-weight: 550;
  line-height: 1;
  cursor: pointer;
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, .8), 0 1px 2px rgba(0, 0, 0, .06);
  transition: background .15s ease, transform .12s ease, box-shadow .15s ease;
}
#tlCtrl button:hover, #eventListBtn:hover {
  background: #fff;
  box-shadow: inset 0 1px 1px #fff, 0 2px 6px rgba(0, 0, 0, .1);
}
#tlCtrl button:active, #eventListBtn:active { transform: translateY(1px); }
#tlCtrl button:disabled { opacity: .35; cursor: default; transform: none; }
#eventListBtn { display: flex; align-items: center; gap: 5px; padding: 0 10px; }
#eventListBtn[hidden] { display: none; }
#eventListBtn .cnt { font-variant-numeric: tabular-nums; color: var(--text-2); font-size: 10px; }

#tcLegend {
  flex-shrink: 0;
  font-size: 9.5px;
  font-weight: 500;
  color: var(--text-2);
  display: flex;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
  cursor: default;
}
#tcLegend i { display: inline-block; width: 7px; height: 7px; border-radius: 2px; margin-left: 2px; }
#tcLegend .c1 { background: #ffd60a; }
#tcLegend .c3 { background: #ff9500; }
#tcLegend .c8 { background: #ff3b30; }
#tcLegend .c9 { background: #a855f7; }
#tcLegend .c10 { background: #db2777; }
#tcLegend .cw { background: linear-gradient(90deg, #0ea5e9, #f77f00, #d62828); }
#tcLegend .lg-sep { width: 1px; height: 10px; background: rgba(60,60,67,.18); margin: 0 2px; }

#sliderWrap {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  gap: 2px;
}

/* --- timeline: event lane + data segments + playhead --- */
#timeline {
  position: relative;
  width: 100%;
  flex: none;
  height: calc(var(--tl-lane-h) + var(--tl-track-h));
  border-radius: 7px;
  cursor: crosshair;
  outline: none;
  background: rgba(120, 130, 145, 0.13);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.14);
  touch-action: none;
}
#timeline:focus-visible { box-shadow: 0 0 0 2px #3a86ff55, inset 0 1px 3px rgba(0,0,0,.14); }

#tlSegs, #tlGaps {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--tl-track-h);
  overflow: hidden;
  border-radius: 0 0 7px 7px;
}
#bottombar.no-events #tlSegs,
#bottombar.no-events #tlGaps { border-radius: 7px; }
#tlGaps { background: transparent; }
.tl-gap {
  position: absolute;
  top: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: repeating-linear-gradient(135deg,
    rgba(110, 120, 135, 0.16) 0 5px, rgba(110, 120, 135, 0.04) 5px 10px);
  font-size: 8px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: rgba(70, 80, 95, .5);
  white-space: nowrap;
}
.tl-seg {
  position: absolute;
  top: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  font-size: 8.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  user-select: none;
  pointer-events: none;
  opacity: 0.94;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.35);
}
.tl-seg.history { background: linear-gradient(180deg, #7fb6ff 0%, #2f7bff 100%); color: #0d2c56; }
.tl-seg.retro   { background: linear-gradient(180deg, #a9c9f2 0%, #5f8fce 100%); color: #1f3f63; }
.tl-seg.forecast{ background: linear-gradient(180deg, #ffc46b 0%, #f28c1e 100%); color: #6d3900; }

#eventLane {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: var(--tl-lane-h);
  border-radius: 7px 7px 0 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 2;
  border-bottom: 1px solid rgba(60, 70, 90, .08);
  box-sizing: border-box;
}
#bottombar.no-events #eventLane { display: none; }
.ev-band {
  position: absolute;
  bottom: 1px;
  height: 4px;
  min-width: 2px;
  border-radius: 999px;
  opacity: .84;
  cursor: pointer;
  pointer-events: auto;
  transition: opacity .15s ease, transform .15s ease;
}
.ev-band:hover { opacity: 1; transform: scaleY(1.7); }
.ev-band.sig1 { background: #ffd60a; }
.ev-band.sig3 { background: #ff9500; }
.ev-band.sig8 { background: #ff3b30; }
.ev-band.sig9 { background: #a855f7; }
.ev-band.sig10 { background: #db2777; }
.ev-pin {
  position: absolute;
  bottom: 5px;
  width: 0;
  height: 12px;
  transform: translateX(-50%);
  pointer-events: none;
  z-index: 3;
}
.ev-pin i {
  position: absolute;
  left: -4px;
  bottom: 0;
  width: 8px;
  height: 8px;
  border-radius: 3px;
  transform: rotate(45deg);
  background: var(--pin, #0ea5e9);
  box-shadow: 0 0 0 1.5px rgba(255,255,255,.92), 0 1px 3px rgba(0,0,0,.3);
  cursor: pointer;
  pointer-events: auto;
  transition: transform .15s ease, box-shadow .15s ease;
}
.ev-pin i:hover { transform: rotate(45deg) scale(1.25); }
.ev-pin.minor i {
  width: 6px;
  height: 6px;
  left: -3px;
  border-radius: 50%;
  transform: none;
}
.ev-pin.minor i:hover { transform: scale(1.3); }
.ev-pin.selected i {
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--pin, #0ea5e9), 0 2px 6px rgba(0,0,0,.35);
}
.ev-pin .lbl {
  position: absolute;
  left: 7px;
  bottom: 1px;
  font-size: 9px;
  font-weight: 600;
  color: #2b3345;
  white-space: nowrap;
  text-shadow: 0 1px 0 rgba(255,255,255,.85);
  pointer-events: none;
}
.ev-cluster {
  position: absolute;
  bottom: 4px;
  transform: translateX(-50%);
  height: 14px;
  padding: 0 5px;
  border-radius: 999px;
  background: #2b3345;
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  line-height: 14px;
  cursor: pointer;
  pointer-events: auto;
  box-shadow: 0 1px 3px rgba(0,0,0,.3);
  z-index: 3;
}
#tlSelWindow {
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 1;
  border-radius: 5px;
  background: rgba(255, 170, 40, .12);
  border-left: 1px solid rgba(230, 140, 20, .55);
  border-right: 1px solid rgba(230, 140, 20, .55);
  pointer-events: none;
}
#tlInitMark {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 0;
  border-left: 1.5px dashed rgba(178, 112, 0, .78);
  pointer-events: none;
  z-index: 4;
}
#tlInitMark span {
  position: absolute;
  top: 1px;
  left: 3px;
  padding: 1px 4px;
  border-radius: 4px;
  background: rgba(255, 244, 222, .92);
  color: #9a5a00;
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: .3px;
  white-space: nowrap;
  box-shadow: 0 1px 2px rgba(0,0,0,.12);
}
#tlHover {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  margin-left: -.5px;
  z-index: 3;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(255,255,255,.95), rgba(255,255,255,.2));
  box-shadow: 0 0 0 1px rgba(20, 30, 50, .35);
}
#tlHover::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  border: 4px solid transparent;
  border-top-color: #fff;
}

#tlHandle {
  position: absolute;
  top: -3px;
  bottom: -3px;
  width: 2px;
  margin-left: -1px;
  border-radius: 2px;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(24, 34, 48, 0.6), 0 1px 5px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  z-index: 5;
  transition: left .08s linear;
}
#tlHandle::before {
  content: "";
  position: absolute;
  top: -3px;
  left: 50%;
  transform: translateX(-50%);
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(24, 34, 48, 0.55), 0 0 0 3px rgba(255,255,255,.25);
}
#bottombar.scrubbing #tlHandle { transition: none; }

#tlTicks {
  position: relative;
  height: 15px;
  margin-top: 1px;
  font-size: 9px;
  color: var(--text-2);
  cursor: grab;
  user-select: none;
  touch-action: none;
}
#tlTicks.dragging { cursor: grabbing; }
#tlTicks .tick {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
}
#tlTicks .tick i {
  display: block;
  width: 1px;
  height: 4px;
  background: rgba(90, 105, 125, 0.55);
  margin-bottom: 1px;
}
#tlTicks .tick.major i { height: 7px; background: rgba(60, 75, 95, 0.8); }
#tlTicks .tick span { white-space: nowrap; }

#tlOverview {
  position: relative;
  height: var(--tl-overview-h);
  border-radius: 5px;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(120,130,145,.09), rgba(120,130,145,.16));
  box-shadow: inset 0 1px 2px rgba(0,0,0,.10);
  cursor: crosshair;
  touch-action: none;
}
#ovSpark { position: absolute; inset: 0; width: 100%; height: 100%; display: block; pointer-events: none; }
#ovSegs { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; pointer-events: none; }
#ovSegs .ov-seg { position: absolute; top: 0; bottom: 0; opacity: .8; }
#ovSegs .ov-seg.history { background: #3a86ff; }
#ovSegs .ov-seg.retro { background: #5f8fce; }
#ovSegs .ov-seg.forecast { background: #f28c1e; }
#ovEvents { position: absolute; inset: 0; pointer-events: none; }
#ovEvents .ov-ev {
  position: absolute;
  bottom: 3px;
  width: 2.5px;
  margin-left: -1.25px;
  height: 8px;
  border-radius: 1px;
  background: var(--ev, #ff3b30);
  opacity: .8;
  pointer-events: auto;
  cursor: pointer;
  transition: height .12s ease, opacity .12s ease;
}
#ovEvents .ov-ev.major { width: 3px; height: 12px; opacity: .95; }
#ovEvents .ov-ev:hover, #ovEvents .ov-ev.selected { height: 14px; opacity: 1; }
#ovEvents .ov-ev.selected { box-shadow: 0 0 0 1px #fff; }
#ovYears { position: absolute; inset: 0; pointer-events: none; font-size: 8px; color: rgba(70,80,95,.62); }
#ovYears .yr { position: absolute; top: 1px; padding-left: 2px; border-left: 1px solid rgba(90,105,125,.16); }
#ovInit { position: absolute; top: 0; bottom: 3px; width: 0; border-left: 1px dashed rgba(178,112,0,.8); pointer-events: none; }
#ovWindow {
  position: absolute;
  top: 0;
  bottom: 0;
  border-radius: 4px;
  border: 1.5px solid rgba(255,255,255,.98);
  background: rgba(58,134,255,.14);
  box-shadow: 0 0 0 1px rgba(25,50,95,.38), 0 1px 4px rgba(0,0,0,.18),
              0 0 0 100vmax rgba(25,35,55,.07);
  pointer-events: none;
}
#ovWindow.dragging { cursor: grabbing; }
#ovWindow.full { background: transparent; box-shadow: none; border-color: rgba(255,255,255,.45); }
#ovWindow.full i { display: none; }
#ovWindow i {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 6px;
  height: 16px;
  border-radius: 3px;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(25,50,95,.45), 0 1px 3px rgba(0,0,0,.2);
}
#ovWindow i.l { left: -3px; cursor: ew-resize; }
#ovWindow i.r { right: -3px; cursor: ew-resize; }

#tlTip {
  position: absolute;
  bottom: calc(100% + 7px);
  z-index: 40;
  max-width: min(320px, 82vw);
  padding: 7px 10px;
  border-radius: 9px;
  background: rgba(28, 32, 40, .9);
  color: #fff;
  font-size: 10.5px;
  line-height: 1.45;
  white-space: normal;
  pointer-events: none;
  box-shadow: 0 10px 30px rgba(0,0,0,.3);
  border: .5px solid rgba(255,255,255,.18);
  transform: translateX(-50%);
  backdrop-filter: blur(10px);
}
#tlTip[hidden] { display: none; }
#tlTip .t1 { font-weight: 700; font-size: 11px; }
#tlTip .t2 { color: rgba(255,255,255,.74); font-variant-numeric: tabular-nums; }
#tlTip .t3 { color: rgba(255,255,255,.56); font-size: 9.5px; margin-top: 1px; }
#tlTip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: rgba(28,32,40,.9);
}

#eventPanel {
  position: absolute;
  right: 0;
  bottom: calc(100% + 9px);
  z-index: 39;
  width: min(400px, 100%);
  max-height: min(360px, 60vh);
  display: flex;
  flex-direction: column;
  padding: 10px 12px 8px;
  border-radius: 16px;
  box-sizing: border-box;
  background: linear-gradient(135deg, rgba(255,255,255,.985), rgba(248,250,255,.965));
  border: .5px solid rgba(255,255,255,.95);
  box-shadow: 0 18px 50px rgba(20,30,60,.24), inset 0 1px 1px #fff;
  backdrop-filter: blur(26px) saturate(150%);
}
#eventPanel[hidden] { display: none; }
#evpHead { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; font-size: 12px; font-weight: 650; }
#evpTitle { flex: 1; white-space: nowrap; }
#evpFilter button { padding: 2px 9px; font-size: 10.5px; }
#evpClose {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: .5px solid rgba(255,255,255,.7);
  background: rgba(255,255,255,.5);
  color: var(--text-2);
  cursor: pointer;
  line-height: 1;
}
#evpClose:hover { background: #fff; }
#evpList { flex: 1 1 auto; min-height: 40px; overflow-y: auto; margin: 0 -4px; padding: 0 4px; }
.evp-year {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 4px 2px 3px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .4px;
  color: var(--text-2);
  background: linear-gradient(180deg, rgba(250,251,255,.98), rgba(250,251,255,.88));
}
.evp-row {
  display: grid;
  grid-template-columns: 58px 1fr auto;
  align-items: center;
  gap: 7px;
  width: 100%;
  padding: 5px 6px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  text-align: left;
  color: var(--text);
  font-size: 11px;
  cursor: pointer;
}
.evp-row:hover, .evp-row:focus-visible { background: rgba(58,134,255,.10); outline: none; }
.evp-row.selected { background: rgba(255,170,40,.16); }
.evp-date { color: var(--text-2); font-variant-numeric: tabular-nums; font-size: 10px; }
.evp-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.evp-name .sub { display: block; font-weight: 400; color: var(--text-2); font-size: 9.5px; }
.evp-peak { text-align: right; font-variant-numeric: tabular-nums; font-size: 10.5px; white-space: nowrap; }
.evp-peak .sig {
  display: inline-block;
  margin-left: 4px;
  padding: 0 4px;
  border-radius: 4px;
  color: #fff;
  font-size: 8.5px;
  font-weight: 700;
  vertical-align: 1px;
}
.evp-peak .sig1 { background: #d9a900; }
.evp-peak .sig3 { background: #e07b00; }
.evp-peak .sig8 { background: #e0241a; }
.evp-peak .sig9 { background: #8f3fd6; }
.evp-peak .sig10 { background: #b81b62; }
#evpFoot {
  padding-top: 5px;
  margin-top: 4px;
  border-top: .5px solid rgba(60,60,67,.12);
  font-size: 9px;
  color: var(--text-2);
}

#playBtn {
  width: 36px;
  height: 36px;
  flex: none;
  border: 0.5px solid rgba(255, 255, 255, 0.5);
  border-radius: 50%;
  background: linear-gradient(180deg, #4da3ff, #007aff);
  color: #fff;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(0, 122, 255, 0.45),
    inset 0 1px 1px rgba(255, 255, 255, 0.5);
  transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.15s ease;
}

#playBtn:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 18px rgba(0, 122, 255, 0.55),
    inset 0 1px 1px rgba(255, 255, 255, 0.6);
}

#playBtn:active {
  transform: scale(0.94);
}

#playBtn.playing {
  background: linear-gradient(180deg, #ff6b61, #ff3b30);
  box-shadow: 0 4px 14px rgba(255, 59, 48, 0.45),
    inset 0 1px 1px rgba(255, 255, 255, 0.45);
}

/* ---------- side panel ---------- */
#sidepanel {
  position: absolute;
  top: calc(var(--topbar-bottom, 86px) + 8px);
  right: 16px;
  width: min(400px, calc(100% - 32px));
  max-height: calc(100% - var(--bottombar-h, 128px) - 114px);
  overflow-y: auto;
  z-index: 1100;
  padding: 14px 16px 16px;
  box-sizing: border-box;
}

#panelHeader {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  font-size: 13.5px;
  margin-bottom: 10px;
}

#panelClose {
  border: 0.5px solid rgba(255, 255, 255, 0.55);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0.2));
  color: var(--text-2);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.7), 0 1px 3px rgba(0, 0, 0, 0.06);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

#panelClose:hover {
  transform: scale(1.08);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.9), 0 2px 6px rgba(0, 0, 0, 0.12);
}

#panelActions {
  display: flex;
  align-items: center;
  gap: 6px;
}

#rmseToggle {
  height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  border: 0.5px solid rgba(255, 255, 255, 0.6);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0.2));
  color: var(--text-2);
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.7), 0 1px 3px rgba(0, 0, 0, 0.06);
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}
#rmseToggle:hover { background: #fff; color: var(--text); }
#rmseToggle.active {
  background: linear-gradient(180deg, #4da3ff, #007aff);
  border-color: rgba(0, 122, 255, 0.6);
  color: #fff;
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.4), 0 2px 6px rgba(0, 122, 255, 0.35);
}
#rmseToggle[hidden] { display: none; }

#tsChartWrap {
  position: relative;
  height: 260px;
}
#tsChart {
  display: block;
  width: 100%;
  height: 100%;
}
#rmseChart {
  width: 100%;
  height: 260px;
}

#tsRange {
  width: fit-content;
  margin-bottom: 8px;
  font-size: 10px;
}
#tsRange button {
  padding: 2px 9px;
  font-size: 10.5px;
}
#tsRange button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
#panelHeader #panelTitle {
  flex: 1;
  min-width: 0;
  line-height: 1.3;
}

/* ---------- overtopping layer (HK) ---------- */
.ot-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
#otCtrl select {
  font-size: 12px;
  padding: 4px 22px 4px 10px;
}
#otCtrl[hidden] {
  display: none;
}

#otLegend {
  position: absolute;
  right: 16px;
  top: calc(var(--topbar-bottom, 86px) + 8px);   /* top-right, under the top bar */
  width: 236px;
  z-index: 900;
  padding: 12px 14px 11px;
  box-sizing: border-box;
  font-size: 12px;
  color: var(--text-2);
  /* the site-wide .glass effect washes out over the white ocean (38% white on
     white); give the small card a cool tint + brighter rim so the frosted
     "liquid glass" reads even against a plain sea */
  background: linear-gradient(135deg,
      rgba(238, 245, 255, 0.58),
      rgba(214, 227, 246, 0.26));
  backdrop-filter: blur(22px) saturate(190%) brightness(1.03);
  -webkit-backdrop-filter: blur(22px) saturate(190%) brightness(1.03);
  border: 0.5px solid rgba(255, 255, 255, 0.6);
  box-shadow:
    0 26px 60px rgba(8, 16, 40, 0.28),
    0 8px 22px rgba(8, 16, 40, 0.14),
    0 2px 8px rgba(8, 16, 40, 0.09),
    0 0 0 0.5px rgba(8, 16, 40, 0.10),
    inset 0 1px 1px rgba(255, 255, 255, 0.8),
    inset 0 -1px 2px rgba(20, 20, 60, 0.10),
    inset 0 0 2.5px rgba(255, 255, 255, 0.35);
}
@media (min-width: 1180px) {
  /* the bar is only half the viewport wide, so the corner has room next to it */
  #otLegend {
    top: 22px;
  }
}

#otLegend[hidden] {
  display: none;
}
.ot-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.ot-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}
.ot-src {
  font-size: 11px;
  color: var(--text-2);
}
.ot-ramp {
  height: 10px;
  border-radius: 3px;
  overflow: hidden;
}
#otRamp {
  display: block;
  width: 100%;
  height: 9px;
}
.ot-ticks {
  position: relative;
  height: 12px;
  margin: 2px 2px 0;
  font-variant-numeric: tabular-nums;
}
.ot-ticks span {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  font-size: 10px;
  line-height: 1;
}
.ot-foot {
  margin-top: 6px;
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--text);
}
.ot-classes {
  margin-top: 5px;
  font-size: 10.5px;
  line-height: 1.35;
  color: var(--text-2);
}
.ot-classes b {
  color: var(--text);
  font-weight: 600;
}
.ot-actions {
  display: flex;
  gap: 6px;
  margin-top: 7px;
}
.ot-actions button {
  flex: 1;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  border: 0.5px solid rgba(255, 255, 255, 0.6);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0.2));
  color: var(--text);
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.7), 0 1px 3px rgba(0, 0, 0, 0.06);
}
.ot-actions button:hover {
  background: #fff;
}
.ot-note {
  margin-top: 6px;
  font-size: 10px;
  color: var(--text-2);
  opacity: 0.85;
}

#otPane[hidden] {
  display: none;
}
#otChartWrap {
  position: relative;
  height: 250px;
}
#otChart {
  display: block;
  width: 100%;
  height: 100%;
}

/* ⚠ overtopping hotspot markers */
.ot-warn-icon {
  background: none;
  border: none;
}
.ot-warn {
  display: block;
  cursor: pointer;
  transform-origin: 50% 100%;
  transition: transform 0.12s ease;
}
.ot-warn-emoji {
  display: block;
  font-size: 22px;
  line-height: 1;
  filter: drop-shadow(0 1px 2.5px rgba(15, 25, 55, 0.45));
}
.ot-warn.hot .ot-warn-emoji {
  filter: drop-shadow(0 1px 2.5px rgba(15, 25, 55, 0.45))
          drop-shadow(0 0 3px rgba(229, 72, 77, 0.55));
}
.ot-warn:hover { transform: scale(1.16); }

/* tooltip on the overtopping segments (Leaflet): same frosted glass look */
.leaflet-tooltip.ot-tip {
  background: linear-gradient(135deg,
      rgba(255, 255, 255, 0.82),
      rgba(232, 241, 255, 0.62));
  backdrop-filter: blur(14px) saturate(170%);
  -webkit-backdrop-filter: blur(14px) saturate(170%);
  border: 0.5px solid rgba(255, 255, 255, 0.75);
  border-radius: 10px;
  box-shadow:
    0 14px 32px rgba(8, 16, 40, 0.26),
    0 3px 10px rgba(8, 16, 40, 0.10),
    0 0 0 0.5px rgba(8, 16, 40, 0.08),
    inset 0 1px 1px rgba(255, 255, 255, 0.85);
  color: var(--text);
  font-size: 12px;
  line-height: 1.4;
  padding: 7px 9px;
  white-space: nowrap;
}
.leaflet-tooltip.ot-tip::before {
  display: none;
}

.node-layer {
  pointer-events: none;
}

.ot-canvas {
  pointer-events: none;
}

/* ---------- Leaflet controls ---------- */
.leaflet-bar {
  border: 0.5px solid var(--glass-border) !important;
  border-radius: 14px !important;
  overflow: hidden;
  box-shadow: var(--shadow), var(--glass-inset) !important;
}

.leaflet-bar a {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.35), rgba(255, 255, 255, 0.15)) !important;
  backdrop-filter: blur(22px) saturate(180%) brightness(1.12);
  -webkit-backdrop-filter: blur(22px) saturate(180%) brightness(1.12);
  color: var(--text) !important;
  border-bottom: 0.5px solid rgba(255, 255, 255, 0.5) !important;
  width: 32px !important;
  height: 32px !important;
  line-height: 32px !important;
}

.leaflet-bar a:hover {
  background: rgba(255, 255, 255, 0.55) !important;
}

.leaflet-control-attribution {
  background: rgba(255, 255, 255, 0.45) !important;
  backdrop-filter: blur(12px) saturate(160%);
  font-size: 10px !important;
  border-radius: 10px 0 0 0;
}

/* ---------- responsive: medium screens (small laptop / tablet landscape) ---------- */
@media (max-width: 1100px) {
  #topbar {
    gap: 12px;
    padding: 8px 16px;
  }

  #colorbar {
    width: 130px;
  }

  #tcLegend {
    display: none;
  }

  #issuedChip {
    display: none;
  }

  #timeSub {
    max-width: 340px;
  }

  #otLegend {
    width: 214px;
  }
}

/* ---------- responsive: tablets / small windows ---------- */
@media (max-width: 860px) {
  #topbar {
    top: 10px;
    gap: 10px;
    padding: 8px 14px;
    max-height: calc(100% - 110px);
    overflow-y: auto;
  }

  .ctrl > span {
    font-size: 10px;
  }

  #topbar select,
  .segmented button {
    font-size: 12px;
  }

  #sizeSlider {
    width: 70px;
  }

  .divider {
    display: none;
  }

  #otCtrl select {
    font-size: 11px;
    padding: 3px 20px 3px 8px;
  }

  #otLegend {
    left: auto;
    right: 10px;
    top: calc(var(--topbar-bottom, 96px) + 8px);
    bottom: auto;
    width: 204px;
    padding: 9px 11px;
    font-size: 11px;
  }

  .ot-actions button {
    font-size: 9px;
  }

  #otChartWrap {
    height: 210px;
  }

  #bottombar {
    bottom: 12px;
    gap: 6px;
    padding: 8px 12px 10px;
    width: calc(100% - 24px);
    --tl-lane-h: 16px;
    --tl-track-h: 24px;
    --tl-overview-h: 20px;
  }

  #tlHead {
    gap: 7px;
    min-height: 30px;
  }

  #timeSub {
    max-width: 52vw;
  }

  #tlCtrl button,
  #eventListBtn {
    height: 24px;
    min-width: 24px;
    padding: 0 6px;
  }

  #tcLegend {
    display: none;
  }

  .ev-pin .lbl {
    display: none;
  }

  #sidepanel {
    top: auto;
    bottom: calc(var(--bottombar-h, 120px) + 12px);
    left: 12px;
    right: 12px;
    width: auto;
    max-height: min(52%, 420px);
  }

  #tsChartWrap {
    height: 220px;
  }
  #rmseChart {
    height: 220px;
  }
}

/* ---------- responsive: phones / very narrow windows ---------- */
@media (max-width: 620px) {
  #issuedChip {
    display: none;
  }

  #timeLabel {
    min-width: 0;
    font-size: 12px;
  }

  #timeSub {
    font-size: 9px;
    max-width: 58vw;
  }

  #bottombar {
    gap: 5px;
    padding: 7px 10px 9px;
    bottom: 10px;
    --tl-lane-h: 15px;
    --tl-track-h: 22px;
    --tl-overview-h: 18px;
  }

  #tlHead {
    gap: 5px;
    min-height: 28px;
  }

  #tlChips .chip {
    height: 19px;
    padding: 0 6px;
    font-size: 9px;
  }

  #tlCtrl {
    gap: 2px;
  }

  #tlCtrl button {
    min-width: 22px;
    height: 22px;
    padding: 0 4px;
    font-size: 10px;
  }

  #tlCtrl .tl-sep {
    display: none;
  }

  #eventListBtn {
    height: 22px;
    padding: 0 7px;
    font-size: 10px;
  }

  #eventPanel {
    width: 100%;
    max-height: 52vh;
  }

  #playBtn {
    width: 30px;
    height: 30px;
  }

  #colorbar {
    width: 110px;
  }

  #colorbarRow input {
    width: 44px;
    font-size: 9.5px;
  }

  #sidepanel {
    bottom: calc(var(--bottombar-h, 120px) + 8px);
    max-height: min(50%, 380px);
    padding: 10px 12px 12px;
  }

  #otLegend {
    width: 188px;
    font-size: 10.5px;
    padding: 8px 10px;
  }

  .ot-note {
    display: none;
  }

  #otChartWrap {
    height: 190px;
  }

}

/* ---------- responsive: short windows (any width) ---------- */
@media (max-height: 640px) {
  #tsChartWrap {
    height: 180px;
  }
  #rmseChart {
    height: 180px;
  }
  #otChartWrap {
    height: 168px;
  }

  #sidepanel {
    top: 76px;
    max-height: calc(100% - var(--bottombar-h, 120px) - 90px);
  }

  #topbar {
    max-height: calc(100% - 100px);
    overflow-y: auto;
  }
}
