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

:root {
  --bg: #dfe8f2;
  --surface: rgba(255, 255, 255, 0.84);
  --surface-strong: rgba(255, 255, 255, 0.94);
  --surface-soft: rgba(255, 255, 255, 0.58);
  --border: rgba(255, 255, 255, 0.72);
  --border-dark: rgba(0, 0, 0, 0.09);
  --text: #17202c;
  --text-2: #586273;
  --text-3: #8c97a8;
  --blue: #1a6fc4;
  --blue-light: #e8f3ff;
  --blue-mid: #4a90d9;
  --red: #c0392b;
  --red-light: #fff1ef;
  --green: #2d7a4f;
  --amber: #b45309;
  --shadow: 0 18px 50px rgba(21, 37, 62, 0.16);
  --shadow-soft: 0 10px 28px rgba(21, 37, 62, 0.11);
  --sidebar-w: 300px;
  --topbar-h: 58px;
  --chart-h: 284px;
  --radius-xl: 8px;
  --radius-lg: 8px;
  --radius-md: 8px;
  --radius-sm: 6px;
}

html,
body {
  height: 100%;
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  overflow: hidden;
}

body.split-chart-active {
  --chart-h: 360px;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: linear-gradient(to bottom, rgba(255,255,255,0.08), rgba(255,255,255,0.24));
  mix-blend-mode: normal;
}

button {
  font: inherit;
}

#app {
  height: 100vh;
  position: relative;
  overflow: hidden;
}

#topbar {
  position: absolute;
  top: 18px;
  left: 18px;
  right: auto;
  width: 300px;
  height: var(--topbar-h);
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 18px;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(22px) saturate(140%);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
}

#topbar .logo {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, #1a6fc4, #67b7f7);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 22px rgba(26, 111, 196, 0.35);
}

#topbar .logo svg {
  width: 18px;
  height: 18px;
}

#topbar h1 {
  font-size: 15px;
  line-height: 1;
  font-weight: 700;
  letter-spacing: 0;
}

#topbar .subtitle {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 4px;
}

#topbar .spacer {
  display: none;
}

#topbar .badge {
  font-size: 11px;
  font-family: 'DM Mono', monospace;
  background: rgba(232, 243, 255, 0.9);
  color: var(--blue);
  padding: 5px 9px;
  border-radius: 999px;
  font-weight: 500;
  border: 1px solid rgba(26, 111, 196, 0.12);
}

#topbar .data-badge {
  font-size: 11px;
  font-family: 'DM Mono', monospace;
  background: rgba(232, 245, 233, 0.9);
  color: var(--green);
  padding: 5px 9px;
  border-radius: 999px;
  font-weight: 500;
  border: 1px solid rgba(45, 122, 79, 0.14);
}

#cors-banner {
  position: fixed;
  top: 10px;
  left: 50%;
  z-index: 3000;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: min(720px, calc(100vw - 28px));
  padding: 11px 14px;
  border: 1px solid rgba(180, 83, 9, 0.24);
  border-radius: 8px;
  background: rgba(255, 248, 225, 0.96);
  box-shadow: var(--shadow-soft);
  color: #5a3b00;
  font-size: 12px;
  line-height: 1.45;
  transform: translateX(-50%);
}

#cors-banner code {
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(0,0,0,0.08);
}

#cors-banner .dismiss {
  margin-left: auto;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}

#cors-banner.hidden {
  display: none;
}

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

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

#map {
  width: 100%;
  height: 100%;
  background: #2796cb;
}

#story-panel {
  position: absolute;
  top: 18px;
  right: 72px;
  width: min(360px, calc(100vw - var(--sidebar-w) - 126px));
  z-index: 940;
  padding: 16px 17px;
  border-radius: 8px;
  background: rgba(255,255,255,0.86);
  border: 1px solid rgb(26 111 196 / 0.6);
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px) saturate(150%);
  -webkit-backdrop-filter: blur(24px) saturate(150%);
}

.story-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 11px;
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  text-transform: uppercase;
}

.story-badge {
  background: rgba(26,111,196,0.12);
  color: var(--blue);
  border-radius: 999px;
  padding: 2px 8px;
  font-weight: 500;
  letter-spacing: 0.04em;
}

#story-step-count {
  flex: 1;
  text-align: right;
  color: var(--text-3);
  margin-right: 2px;
}

#story-title {
  font-size: 16px;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: 0;
  color: var(--text);
  margin-top: 5px;
}

#story-copy {
  margin-top: 7px;
  color: var(--text-2);
  font-size: 12px;
  line-height: 1.48;
}

#story-progress {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 5px;
  margin-top: 14px;
}

.story-progress-dot {
  height: 4px;
  border-radius: 999px;
  background: rgba(0,0,0,0.09);
}

.story-progress-dot.active {
  background: var(--blue);
}

.story-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.story-btn,
.story-link,
.story-reopen {
  border: 1px solid rgba(26,111,196,0.18);
  border-radius: 999px;
  background: var(--blue);
  color: #fff;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  transition: transform 0.16s ease, background-color 0.16s ease, opacity 0.16s ease;
}

.story-btn {
  flex: 1;
  padding: 8px 12px;
}

.story-btn.secondary {
  background: rgba(255,255,255,0.74);
  color: var(--text-2);
  border-color: rgba(0,0,0,0.12);
}

.story-link {
  padding: 5px 9px;
  background: rgba(255,255,255,0.72);
  color: var(--blue);
  font-family: 'DM Sans', sans-serif;
  font-size: 11px;
}

.story-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  background: #155da6;
  color: #fff;
}

.story-btn.secondary:hover:not(:disabled),
.story-link:hover,
.story-reopen:hover {
  transform: translateY(-1px);
  background: rgba(255,255,255,0.94);
}

.story-btn.secondary:hover:not(:disabled) {
  color: var(--text);
  border-color: rgba(0,0,0,0.16);
}

.story-btn:disabled {
  opacity: 0.42;
  cursor: default;
}

.story-reopen {
  position: absolute;
  top: 18px;
  right: 210px;
  z-index: 940;
  width: 128px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border-radius: 8px;
  background: rgba(255,255,255,0.82);
  color: var(--blue);
  border: 1px solid rgba(26,111,196,0.22);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
}

/* ── Hall of Fame panel ─────────────────────────────── */

#hof-panel {
  position: absolute;
  top: 18px;
  right: 72px;
  width: min(360px, calc(100vw - var(--sidebar-w) - 126px));
  z-index: 940;
  padding: 16px 17px;
  border-radius: 8px;
  background: rgba(255,255,255,0.86);
  border: 1px solid rgba(212,160,23,0.35);
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px) saturate(150%);
  -webkit-backdrop-filter: blur(24px) saturate(150%);
}

.hof-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 11px;
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  text-transform: uppercase;
}

.hof-badge {
  background: rgba(212,160,23,0.13);
  color: #b45309;
  border-radius: 999px;
  padding: 2px 8px;
  font-weight: 500;
  letter-spacing: 0.04em;
}

#hof-step-count {
  flex: 1;
  text-align: right;
  color: var(--text-3);
  margin-right: 2px;
}

.hof-value-line {
  font-size: 30px;
  font-weight: 800;
  line-height: 1.1;
  color: var(--text);
  letter-spacing: -0.5px;
  min-height: 36px;
}

#hof-title {
  font-size: 16px;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: 0;
  color: var(--text);
  margin-top: 5px;
}

#hof-copy {
  margin-top: 7px;
  color: var(--text-2);
  font-size: 12px;
  line-height: 1.48;
}

#hof-progress {
  display: grid;
  gap: 5px;
  margin-top: 14px;
}

.hof-progress-dot {
  height: 4px;
  border-radius: 999px;
  background: rgba(0,0,0,0.09);
}

.hof-progress-dot.active {
  background: #b45309;
}

.hof-open-btn {
  position: absolute;
  top: 18px;
  right: 72px;
  z-index: 940;
  width: 128px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border: 1px solid rgba(180,83,9,0.24);
  border-radius: 8px;
  background: rgba(255,255,255,0.82);
  color: #b45309;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  transition: transform 0.16s ease, background-color 0.16s ease, opacity 0.16s ease;
}

.hof-open-btn:hover {
  transform: translateY(-1px);
  background: rgba(255,255,255,0.94);
}

/* ── End Hall of Fame ───────────────────────────────── */

#station-marker-layer {
  position: absolute;
  inset: 0;
  z-index: 420;
  pointer-events: none;
}

.station-dom-marker {
  position: absolute;
  width: var(--marker-size, 18px);
  height: var(--marker-size, 18px);
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--marker-color, var(--blue));
  box-shadow:
    0 0 0 var(--marker-ring-size, 5px) var(--marker-ring-color, rgba(26,111,196,0.18)),
    0 8px 18px rgba(0,0,0,0.22);
  cursor: pointer;
  opacity: var(--marker-opacity, 1);
  pointer-events: auto;
  transform: translate(-50%, -50%);
  transition: transform 0.16s ease, background-color 0.16s ease, box-shadow 0.16s ease, width 0.16s ease, height 0.16s ease, opacity 0.16s ease;
}

.station-dom-marker::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: #fff;
}

.station-dom-marker:hover {
  transform: translate(-50%, -50%) scale(1.18);
}

.station-dom-marker.active {
  background: var(--marker-color, var(--red));
  box-shadow:
    0 0 0 calc(var(--marker-ring-size, 5px) + 2px) var(--marker-ring-color, rgba(192,57,43,0.22)),
    0 12px 26px rgba(0,0,0,0.28);
  transform: translate(-50%, -50%) scale(1.24);
}

.station-dom-marker.story-pulse {
  animation: markerPulse 1.8s ease-in-out infinite;
}

@keyframes markerPulse {
  0%, 100% {
    box-shadow:
      0 0 0 var(--marker-ring-size, 5px) var(--marker-ring-color, rgba(26,111,196,0.18)),
      0 8px 18px rgba(0,0,0,0.22);
  }
  50% {
    box-shadow:
      0 0 0 calc(var(--marker-ring-size, 5px) + 7px) rgba(255,255,255,0.16),
      0 10px 24px rgba(0,0,0,0.24);
  }
}

#sidebar {
  position: absolute;
  top: 92px;
  left: 18px;
  bottom: 18px;
  width: var(--sidebar-w);
  z-index: 900;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  border-radius: var(--radius-xl);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px) saturate(150%);
  -webkit-backdrop-filter: blur(24px) saturate(150%);
}

#sidebar::-webkit-scrollbar {
  width: 0;
}

.sb-section {
  padding: 17px 17px 0;
}

.sb-section + .sb-section {
  border-top: 1px solid rgba(0,0,0,0.055);
  margin-top: 15px;
  padding-top: 15px;
}

.sb-section:last-child {
  padding-bottom: 17px;
}

.sidebar-footer {
  margin-top: auto;
  padding-bottom: 17px;
}

.sb-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 11px;
}

#station-card {
  background: linear-gradient(135deg, rgba(26,111,196,0.15), rgba(255,255,255,0.72));
  border: 1px solid rgba(26,111,196,0.18);
  border-radius: 8px;
  padding: 15px;
  margin-bottom: 3px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.75);
}

#station-card .st-name {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0;
  color: var(--blue);
}

#station-card .st-meta {
  font-size: 12px;
  color: var(--text-2);
  margin-top: 6px;
  line-height: 1.55;
  white-space: pre-line;
}

#station-card .st-placeholder {
  font-size: 12px;
  color: var(--text-3);
  line-height: 1.5;
}

#data-status {
  margin-top: 9px;
  padding: 7px 9px;
  border-radius: 8px;
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  line-height: 1.45;
  border: 1px solid rgba(255,255,255,0.55);
}

#data-status.loading {
  color: var(--blue);
  background: rgba(232, 243, 255, 0.72);
}

#data-status.ok {
  color: var(--green);
  background: rgba(232, 245, 233, 0.72);
}

#data-status.err {
  color: var(--red);
  background: rgba(255, 241, 239, 0.78);
}

.loading-spinner {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-left: 5px;
  border: 2px solid rgba(26,111,196,0.22);
  border-top-color: var(--blue);
  border-radius: 50%;
  vertical-align: -1px;
  animation: spin 0.7s linear infinite;
}

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

.station-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 11px;
}

.station-badges span {
  font-size: 10px;
  font-family: 'DM Mono', monospace;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.72);
  color: var(--blue);
  border: 1px solid rgba(26,111,196,0.16);
}

.metric-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.metric-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.18s ease;
  font-size: 13px;
  color: var(--text-2);
  user-select: none;
}

.metric-pill:hover {
  background: rgba(255,255,255,0.68);
  transform: translateY(-1px);
}

.metric-pill.active {
  background: rgba(26,111,196,0.12);
  border-color: rgba(26,111,196,0.25);
  color: var(--blue);
  font-weight: 700;
  box-shadow: 0 8px 22px rgba(26,111,196,0.12);
}

.metric-pill .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 4px rgba(0,0,0,0.04);
}

.metric-pill .avail-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  background: rgba(0,0,0,0.12);
  box-shadow: none;
}

.metric-pill .avail-dot.yes {
  background: var(--green);
}

.metric-pill .unit {
  margin-left: auto;
  font-size: 11px;
  font-family: 'DM Mono', monospace;
  color: var(--text-3);
}

.res-group {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.res-btn {
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid rgba(0,0,0,0.12);
  font-size: 12px;
  font-family: 'DM Mono', monospace;
  color: var(--text-2);
  background: rgba(255,255,255,0.65);
  cursor: pointer;
  transition: all 0.16s ease;
}

.res-btn:hover {
  transform: translateY(-1px);
  background: rgba(255,255,255,0.9);
}

.res-btn.active {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
  box-shadow: 0 8px 20px rgba(26,111,196,0.25);
}

.time-group {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}

.time-btn {
  padding: 7px 11px;
  border-radius: 999px;
  border: 1px solid rgba(0,0,0,0.12);
  font-size: 12px;
  font-family: 'DM Mono', monospace;
  color: var(--text-2);
  background: rgba(255,255,255,0.65);
  cursor: pointer;
  transition: all 0.16s ease;
  user-select: none;
}

.time-btn:hover {
  transform: translateY(-1px);
  background: rgba(255,255,255,0.9);
}

.time-btn.active {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
  box-shadow: 0 8px 20px rgba(26,111,196,0.25);
}

.time-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}

.time-nav-btn {
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid rgba(0,0,0,0.12);
  font-size: 14px;
  font-family: 'DM Mono', monospace;
  color: var(--text-2);
  background: rgba(255,255,255,0.65);
  cursor: pointer;
  transition: all 0.16s ease;
  user-select: none;
  line-height: 1;
}

.time-nav-btn:hover:not(:disabled) {
  background: rgba(255,255,255,0.9);
  transform: translateY(-1px);
}

.time-nav-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.time-nav-label {
  flex: 1;
  text-align: center;
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  color: var(--text-3);
}

.compare-btn {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 7px 11px;
  border-radius: 999px;
  border: 1px solid rgba(0,0,0,0.12);
  font-size: 12px;
  font-family: 'DM Mono', monospace;
  color: var(--text-2);
  background: rgba(255,255,255,0.65);
  cursor: pointer;
  transition: all 0.16s ease;
  text-align: center;
}

.compare-btn:hover {
  background: rgba(255,255,255,0.9);
}

.compare-btn.active {
  background: rgba(124,90,240,0.08);
  border-color: rgba(124,90,240,0.35);
  color: #7c5af0;
}

#compare-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
  padding: 8px 10px;
  background: rgba(124,90,240,0.05);
  border: 1px solid rgba(124,90,240,0.18);
  border-radius: 8px;
}

.compare-card-inner {
  min-width: 0;
}

.compare-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.compare-meta {
  font-size: 10px;
  color: var(--text-3);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.remove-compare-btn {
  flex-shrink: 0;
  padding: 3px 7px;
  border-radius: 999px;
  border: 1px solid rgba(0,0,0,0.10);
  background: rgba(255,255,255,0.7);
  color: var(--text-3);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.14s ease;
}

.remove-compare-btn:hover {
  background: rgba(192,57,43,0.08);
  border-color: rgba(192,57,43,0.25);
  color: var(--red);
}

#layout-switcher {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.layout-btn {
  flex: 1;
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid rgba(0,0,0,0.12);
  font-size: 12px;
  font-family: 'DM Mono', monospace;
  color: var(--text-2);
  background: rgba(255,255,255,0.65);
  cursor: pointer;
  transition: all 0.16s ease;
}

.layout-btn:hover {
  background: rgba(255,255,255,0.9);
}

.layout-btn.active {
  background: #7c5af0;
  border-color: #7c5af0;
  color: #fff;
  box-shadow: 0 8px 20px rgba(124,90,240,0.25);
}

.station-dom-marker.compare {
  background: #7c5af0;
  box-shadow:
    0 0 0 7px rgba(124,90,240,0.22),
    0 12px 26px rgba(0,0,0,0.28);
  transform: translate(-50%, -50%) scale(1.24);
}

.time-hint {
  margin-top: 11px;
  font-size: 11px;
  color: var(--text-3);
  line-height: 1.5;
  padding: 9px 10px;
  background: rgba(255,255,255,0.5);
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.55);
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 12px;
  color: var(--text-2);
  margin-bottom: 7px;
}

.legend-line {
  width: 24px;
  height: 3px;
  border-radius: 999px;
  flex-shrink: 0;
}

.legend-line.dashed {
  background: repeating-linear-gradient(to right, var(--red) 0, var(--red) 5px, transparent 5px, transparent 9px);
}

.source-note {
  margin-top: 12px;
  padding-top: 11px;
  border-top: 1px solid rgba(0,0,0,0.055);
  color: var(--text-3);
  font-size: 10px;
  line-height: 1.5;
}

#chart-panel {
  position: absolute;
  left: calc(var(--sidebar-w) + 40px);
  right: 18px;
  bottom: 18px;
  height: var(--chart-h);
  z-index: 800;
  border-radius: var(--radius-xl);
  background: rgba(255,255,255,0.86);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px) saturate(150%);
  -webkit-backdrop-filter: blur(24px) saturate(150%);
  display: flex;
  flex-direction: column;
  padding: 17px 21px 13px;
}

.year-scrubber {
  margin: -2px 0 10px;
  padding: 9px 11px 8px;
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255,255,255,0.76), rgba(248,251,255,0.58));
  border: 1px solid rgba(21,37,62,0.08);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.72), 0 8px 20px rgba(21,37,62,0.07);
}

.year-scrubber-head,
.year-scrubber-bounds {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--text-3);
  font-family: 'DM Mono', monospace;
  font-size: 10px;
}

.year-scrubber-head strong {
  min-width: 46px;
  padding: 3px 7px;
  border-radius: 999px;
  color: var(--text);
  font-size: 12px;
  text-align: center;
  background: rgba(255,255,255,0.72);
  border: 1px solid rgba(21,37,62,0.08);
}

#year-range {
  --scrub-progress: 100%;
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 20px;
  margin: 7px 0 4px;
  background: transparent;
  cursor: pointer;
}

#year-range:focus {
  outline: none;
}

#year-range:focus-visible::-webkit-slider-thumb {
  box-shadow: 0 0 0 4px rgba(26,111,196,0.16), 0 4px 12px rgba(21,37,62,0.20);
}

#year-range:focus-visible::-moz-range-thumb {
  box-shadow: 0 0 0 4px rgba(26,111,196,0.16), 0 4px 12px rgba(21,37,62,0.20);
}

#year-range::-webkit-slider-runnable-track {
  height: 7px;
  border-radius: 999px;
  background:
    linear-gradient(
      90deg,
      transparent 0%,
      transparent var(--scrub-progress),
      rgba(21,37,62,0.11) var(--scrub-progress),
      rgba(21,37,62,0.11) 100%
    ),
    linear-gradient(
      90deg,
      rgb(166 215 255) 0%,
      rgb(67 148 239) 52%,
      rgb(26 111 196) 100%
    );
  box-shadow: inset 0 1px 2px rgba(21,37,62,0.16);
}

#year-range::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  margin-top: -5.5px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: linear-gradient(180deg, #fff, #eef4fb);
  box-shadow: 0 4px 12px rgba(21,37,62,0.20);
}

#year-range::-moz-range-track {
  height: 7px;
  border-radius: 999px;
  background:
    linear-gradient(
      90deg,
      transparent 0%,
      transparent var(--scrub-progress),
      rgba(21,37,62,0.11) var(--scrub-progress),
      rgba(21,37,62,0.11) 100%
    ),
    linear-gradient(
      90deg,
      rgba(26,111,196,0.82) 0%,
      rgba(74,144,217,0.82) 52%,
      rgba(192,57,43,0.82) 100%
    );
  box-shadow: inset 0 1px 2px rgba(21,37,62,0.16);
}

#year-range::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: linear-gradient(180deg, #fff, #eef4fb);
  box-shadow: 0 4px 12px rgba(21,37,62,0.20);
}

#chart-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 11px;
}

#chart-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0;
}

#chart-meta {
  font-size: 11px;
  color: var(--text-3);
  font-family: 'DM Mono', monospace;
  white-space: nowrap;
}

#chart-svg-wrap {
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
}

#chart-empty {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  justify-content: center;
  min-height: 0;
  color: var(--text-3);
  font-size: 12px;
  font-style: italic;
  border-radius: 8px;
  background: rgba(255,255,255,0.48);
  border: 1px dashed rgba(0,0,0,0.12);
}

.hidden {
  display: none !important;
}

.maplibregl-ctrl-top-right {
  top: 8px;
  right: 8px;
}

.maplibregl-ctrl-top-left {
  top: 10px;
  left: 325px;
}

.maplibregl-ctrl-bottom-right {
  right: 18px;
  bottom: calc(var(--chart-h) + 35px);
}

.maplibregl-ctrl-group {
  border: 1px solid rgba(255,255,255,0.75) !important;
  border-radius: 8px !important;
  overflow: hidden;
  box-shadow: var(--shadow-soft) !important;
  background: rgba(255,255,255,0.76) !important;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.maplibregl-ctrl-group button {
  background-color: rgba(255,255,255,0.78) !important;
}

.maplibregl-ctrl-group button:hover {
  background-color: #fff !important;
}

.maplibregl-ctrl-attrib {
  font-size: 9px !important;
  background: rgba(255,255,255,0.66) !important;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.maplibregl-popup {
  z-index: 1200;
  max-width: 340px !important;
}

.maplibregl-popup-content {
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  color: var(--text);
  background: rgba(255,255,255,0.93);
  border: 1px solid rgba(255,255,255,0.78);
  border-radius: 10px;
  padding: 11px 14px;
  box-shadow: 0 10px 32px rgba(0,0,0,0.18);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.maplibregl-popup-tip {
  border-top-color: rgba(255,255,255,0.93) !important;
}

.rec-popup {
  min-width: 300px;
}

.rec-popup h3 {
  margin: 0 0 3px;
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
}

.rec-popup .rp-sub {
  color: var(--text-3);
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  margin-bottom: 2px;
}

.rec-popup .rp-note {
  color: var(--text-3);
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  margin-top: 8px;
  padding-top: 7px;
  border-top: 1px solid rgba(0,0,0,0.07);
}

.rec-popup table {
  width: 100%;
  margin-top: 10px;
  border-collapse: collapse;
}

.rec-popup tr + tr td {
  border-top: 1px solid rgba(0,0,0,0.05);
}

.rec-popup td {
  padding: 5px 0;
  font-size: 11.5px;
  vertical-align: middle;
}

.rec-popup .rp-label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-2);
}

.rec-popup .rp-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.rec-popup .rp-val {
  text-align: right;
  font-family: 'DM Mono', monospace;
  font-weight: 600;
  font-size: 12px;
  padding-left: 10px;
  white-space: nowrap;
}

.rec-popup .rp-when {
  text-align: right;
  color: var(--text-3);
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  padding-left: 8px;
  white-space: nowrap;
}

#records-drawer {
  position: fixed;
  left: calc(var(--sidebar-w) + 40px);
  right: 18px;
  bottom: calc(var(--chart-h) + 32px);
  z-index: 850;
  filter: drop-shadow(0 12px 28px rgba(21, 37, 62, 0.12));
}

#records-handle {
  width: 100%;
  min-height: 43px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px 7px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255,255,255,0.82);
  color: var(--text);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(20px) saturate(145%);
  -webkit-backdrop-filter: blur(20px) saturate(145%);
  cursor: pointer;
}

#records-handle:hover {
  background: rgba(255,255,255,0.92);
}

.rh-title {
  margin-right: 4px;
  color: var(--text-3);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.rh-pills {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.rh-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid rgba(0,0,0,0.06);
  background: rgba(255,255,255,0.64);
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  white-space: nowrap;
}

.rh-pill-lbl {
  color: var(--text-3);
}

.rh-pill-val {
  color: var(--text);
  font-weight: 500;
}

.rh-pill.hot  { border-color: rgba(192,57,43,0.20);  background: rgba(220,53,34,0.06);  }
.rh-pill.hot  .rh-pill-val { color: #c0392b; }

.rh-pill.cold { border-color: rgba(26,111,196,0.20); background: rgba(26,111,196,0.06); }
.rh-pill.cold .rh-pill-val { color: #1a6fc4; }

.rh-pill.wet  { border-color: rgba(26,111,196,0.18); background: rgba(26,111,196,0.05); }
.rh-pill.wet  .rh-pill-val { color: #1a6fc4; }

.rh-pill.wind { border-color: rgba(45,122,79,0.18); background: rgba(45,122,79,0.05); }
.rh-pill.wind .rh-pill-val { color: #2d7a4f; }

.rh-pill.sun  { border-color: rgba(180,83,9,0.18);   background: rgba(180,83,9,0.05);   }
.rh-pill.sun  .rh-pill-val { color: #b45309; }

.rh-chevron {
  margin-left: auto;
  color: var(--text-3);
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  transition: transform 0.2s ease;
}

#records-drawer.open .rh-chevron {
  transform: rotate(180deg);
}

#records-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease;
}

#records-drawer.open #records-body {
  max-height: 308px;
  overflow-y: auto;
}

#records-body-inner {
  margin-top: 8px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255,255,255,0.88);
  backdrop-filter: blur(20px) saturate(145%);
  -webkit-backdrop-filter: blur(20px) saturate(145%);
}

.rec-section-title {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 4px 0 9px;
  color: var(--text-3);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.rec-section-title::after {
  content: "";
  height: 1px;
  flex: 1;
  background: rgba(0,0,0,0.07);
}

.records-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  gap: 8px;
}

.record-card {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 9px 10px;
  border: 1px solid rgba(0,0,0,0.07);
  border-radius: 8px;
  background: rgba(255,255,255,0.62);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: transform 0.14s ease, box-shadow 0.14s ease;
}

.record-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(21, 37, 62, 0.11);
}

.record-card.static {
  cursor: default;
}

.record-card.static:hover,
.record-card:disabled:hover {
  transform: none;
  box-shadow: none;
}

.record-card:disabled {
  cursor: default;
  opacity: 0.66;
}

.record-card.empty {
  opacity: 0.72;
}

.record-card.trend {
  grid-column: -2 / -1;
}

.record-card.hot {
  border-color: rgba(192,57,43,0.28);
  background: linear-gradient(135deg, rgba(220,53,34,0.08) 0%, rgba(255,120,50,0.04) 100%);
}

.record-card.cold {
  border-color: rgba(26,111,196,0.25);
  background: linear-gradient(135deg, rgba(26,111,196,0.08) 0%, rgba(100,180,255,0.04) 100%);
}

.record-card.wet {
  border-color: rgba(26,111,196,0.20);
  background: rgba(26,111,196,0.06);
}

.record-card.wind {
  border-color: rgba(45,122,79,0.22);
  background: rgba(45,122,79,0.06);
}

.record-card.sun {
  border-color: rgba(180,83,9,0.22);
  background: rgba(180,83,9,0.06);
}

.record-card.hot  .rc-value { color: #c0392b; }
.record-card.cold .rc-value { color: #1a6fc4; }
.record-card.wet  .rc-value { color: #1a6fc4; }
.record-card.wind .rc-value { color: #2d7a4f; }
.record-card.sun  .rc-value { color: #b45309; }
.record-card.empty .rc-value { color: var(--text-3); }

.rc-label {
  color: var(--text-3);
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
}

.rc-value {
  font-family: 'DM Mono', monospace;
  font-size: 14px;
  font-weight: 500;
}

.rc-when {
  color: var(--text-3);
  font-family: 'DM Mono', monospace;
  font-size: 10px;
}

.rec-loading {
  grid-column: 1 / -1;
  color: var(--text-3);
  font-size: 11px;
  padding: 8px 0;
}

.rec-loading.is-error {
  color: var(--red);
}

@media (max-width: 850px) {
  #topbar {
    left: 12px;
    right: auto;
    top: 12px;
    width: min(318px, calc(100vw - 70px));
  }

  #sidebar {
    left: 12px;
    right: 12px;
    top: 84px;
    bottom: auto;
    width: auto;
    max-height: 44vh;
    border-radius: 8px;
  }

  #chart-panel {
    left: 12px;
    right: 12px;
    bottom: 12px;
    height: 250px;
  }

  #story-panel {
    left: 12px;
    right: 12px;
    top: auto;
    bottom: calc(250px + 74px);
    width: auto;
    padding: 13px 14px;
  }

  #story-title {
    font-size: 16px;
  }

  #story-copy {
    font-size: 11px;
  }

  .story-reopen {
    top: 76px;
    right: 148px;
    bottom: auto;
  }

  #topbar .badge {
    display: none;
  }

  #topbar .data-badge {
    display: none;
  }

  #records-drawer {
    left: 12px;
    right: 12px;
    bottom: calc(250px + 26px);
  }

  #records-handle {
    overflow: hidden;
  }

  .rh-pill {
    padding: 4px 7px;
  }

  .records-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #hof-panel {
    left: 12px;
    right: 12px;
    top: auto;
    bottom: calc(250px + 74px + 48px);
    width: auto;
    padding: 13px 14px;
  }

  #hof-title {
    font-size: 15px;
  }

  #hof-copy {
    font-size: 11px;
  }

  .hof-open-btn {
    top: 76px;
    right: 12px;
    bottom: auto;
  }

  .maplibregl-ctrl-top-right {
    top: 12px;
    right: 12px;
  }
}
