:root {
  --panel-bg: rgba(15, 23, 42, 0.92);
  --panel-border: rgba(148, 163, 184, 0.35);
  --text: #f8fafc;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent-dim: #0ea5e9;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino,
    Georgia, serif;
}

.app-shell {
  display: flex;
  height: 100%;
  min-height: 0;
}

.map-wrap {
  flex: 1;
  position: relative;
  min-width: 0;
  min-height: 0;
}

#map {
  width: 100%;
  height: 100%;
  background: #f0f0ee;
}

.leaflet-labels-pane .maplibregl-canvas {
  background: transparent;
}

.leaflet-labels-pane,
.leaflet-labels-pane .leaflet-gl-layer {
  overflow: visible;
}

.panel {
  position: relative;
  flex: 0 0 min(320px, 38vw);
  align-self: flex-start;
  z-index: 1000;
  max-height: calc(100% - 24px);
  overflow-y: auto;
  margin: 12px 0 12px 12px;
  padding: 14px 16px 16px;
  background: var(--panel-bg);
  color: var(--text);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(8px);
}

.title {
  margin: 0 0 4px;
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.subtitle {
  margin: 0 0 14px;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.35;
}

.section-label {
  margin: 0 0 6px;
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.toggle-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.toggle-row .toggle-btn {
  min-width: 0;
}

.toggle-btn {
  flex: 1;
  padding: 8px 10px;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--text);
  background: rgba(30, 41, 59, 0.9);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.toggle-btn:hover {
  border-color: var(--accent);
  color: #fff;
}

.toggle-btn.is-active {
  background: linear-gradient(145deg, var(--accent-dim), #0369a1);
  border-color: transparent;
  color: #fff;
}

.voronoi-toggle-wrap {
  margin-bottom: 14px;
}

.voronoi-toggle-wrap.is-disabled {
  opacity: 0.45;
  pointer-events: none;
}

.voronoi-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--muted);
  cursor: pointer;
}

.voronoi-toggle input {
  accent-color: var(--accent);
  cursor: pointer;
}

.voronoi-hover-tip {
  position: fixed;
  z-index: 2000;
  pointer-events: none;
  display: none;
  max-width: 260px;
  padding: 6px 8px;
  font-size: 0.78rem;
  line-height: 1.35;
  color: #0f172a;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.18);
}

.voronoi-hover-tip.is-visible {
  display: block;
}

.hour-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.hour-label strong {
  color: var(--text);
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
}

.slider-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.play-btn {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  padding: 0;
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
  color: var(--text);
  background: rgba(30, 41, 59, 0.9);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  transition: background 0.15s, border-color 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.play-btn:hover {
  border-color: var(--accent);
}

.play-btn.is-playing {
  background: linear-gradient(145deg, var(--accent-dim), #0369a1);
  border-color: transparent;
}

#hour-slider,
#marker-size-slider {
  flex: 1;
  margin: 0;
  accent-color: var(--accent);
}

.search-row {
  margin-bottom: 14px;
}

.station-search {
  width: 100%;
  padding: 7px 10px;
  font: inherit;
  font-size: 0.82rem;
  color: var(--text);
  background: rgba(30, 41, 59, 0.9);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  outline: none;
  transition: border-color 0.15s;
}

.station-search::placeholder {
  color: var(--muted);
}

.station-search:focus {
  border-color: var(--accent);
}

.data-provenance {
  margin: 8px 0 0;
  font-size: 0.67rem;
  color: var(--muted);
  line-height: 1.4;
  opacity: 0.7;
}

.legend {
  margin-top: 4px;
}

.legend-bar {
  height: 10px;
  border-radius: 4px;
  background: linear-gradient(
    90deg,
    #1d4ed8 0%,
    #e2e8f0 50%,
    #b91c1c 100%
  );
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.legend-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  font-size: 0.68rem;
  color: var(--muted);
}

.legend-caption {
  margin: 8px 0 0;
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.4;
}

.status {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  padding: 8px 14px;
  font-size: 0.8rem;
  color: var(--text);
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}

.status.is-visible {
  opacity: 1;
}

.leaflet-tooltip.station-tip {
  background: rgba(15, 23, 42, 0.95);
  color: #f8fafc;
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  font-family: system-ui, sans-serif;
  font-size: 0.78rem;
  max-width: 260px;
}

.leaflet-tooltip.station-tip strong {
  display: block;
  margin-bottom: 4px;
  font-size: 0.85rem;
}

.chart-modal {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
}

.chart-modal.is-open {
  pointer-events: auto;
  opacity: 1;
  visibility: visible;
}

.chart-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  cursor: pointer;
}

.chart-modal__dialog {
  position: relative;
  z-index: 1;
  width: min(640px, calc(100vw - 32px));
  max-height: min(480px, calc(100vh - 48px));
  padding: 16px 18px 18px;
  background: #fafaf9;
  color: #0f172a;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 12px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25);
}

.chart-modal__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.chart-modal__title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1.25;
  font-family: system-ui, sans-serif;
}

.chart-modal__subtitle {
  margin: 0 0 10px;
  font-size: 0.8rem;
  color: #475569;
  font-family: system-ui, sans-serif;
}

.chart-modal__close {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  margin: -6px -8px 0 0;
  padding: 0;
  font: inherit;
  font-size: 1.5rem;
  line-height: 1;
  color: #64748b;
  cursor: pointer;
  background: transparent;
  border: none;
  border-radius: 8px;
}

.chart-modal__close:hover {
  color: #0f172a;
  background: rgba(15, 23, 42, 0.06);
}

.chart-modal__canvas-wrap {
  position: relative;
  height: min(320px, 42vh);
  width: 100%;
}

.chart-modal__canvas-wrap canvas {
  display: block;
  max-width: 100%;
}

.arrow-icon {
  background: none;
  border: none;
}
