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

html, body {
  height: 100%;
  background: #000;
  color: #e0e0e0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
}

/* --- Map --- */

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

/* --- Sidebar --- */

.sidebar {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 48px;
  width: 280px;
  z-index: 10;
  display: flex;
  transition: transform 0.3s ease;
}

.sidebar:not(.open) {
  transform: translateX(-280px);
}

.sidebar-content {
  flex: 1;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(12px);
  padding: 24px 20px;
  overflow-y: auto;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-toggle {
  position: absolute;
  right: -32px;
  top: 12px;
  width: 32px;
  height: 40px;
  background: rgba(0, 0, 0, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-left: none;
  border-radius: 0 6px 6px 0;
  color: #aaa;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
}

.sidebar-toggle:hover {
  color: #fff;
}

.chevron {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  transition: transform 0.3s;
}

.sidebar:not(.open) .chevron {
  transform: rotate(-135deg);
}

h1 {
  font-size: 18px;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 4px;
}

h1 sub {
  font-size: 0.75em;
}

.subtitle {
  font-size: 12px;
  color: #888;
  margin-bottom: 4px;
}

.mode-note {
  font-size: 11px;
  color: #777;
  font-style: italic;
  margin-bottom: 24px;
}

.control-group {
  margin-bottom: 20px;
}

.control-group label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #888;
  margin-bottom: 8px;
}

/* --- Button group --- */

.button-group {
  display: flex;
  gap: 0;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.btn {
  flex: 1;
  padding: 7px 0;
  background: transparent;
  color: #aaa;
  border: none;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn:not(:last-child) {
  border-right: 1px solid rgba(255, 255, 255, 0.15);
}

.btn.active {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.btn:hover:not(.active) {
  background: rgba(255, 255, 255, 0.06);
  color: #ccc;
}

/* --- Legend --- */

.legend {
  margin-top: 4px;
}

.legend-gradient {
  height: 12px;
  border-radius: 3px;
  background: linear-gradient(to right,
    #e85555,
    #d94040,
    #c43030,
    #a52020,
    #8b1a1a,
    #6b1010,
    #4a0c0c,
    #c43c2d,
    #e06830,
    #f0a030,
    #f8d040,
    #fff06a,
    #c8f0ff,
    #7ecbff,
    #3a8fd4,
    #1a5a9e,
    #0e3a6e,
    #061a3a,
    #000000
  );
}

.legend-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: #888;
  margin-top: 4px;
}

/* --- Toggle row --- */

.toggle-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.toggle-row input[type="checkbox"] {
  margin: 0;
  accent-color: #8ab4f8;
}

.toggle-row label {
  display: inline;
  text-transform: none;
  letter-spacing: 0;
  color: #aaa;
  font-size: 13px;
  line-height: 1;
  margin-bottom: 0;
  cursor: pointer;
}

/* --- Popup --- */

.maplibregl-popup-content {
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(12px);
  color: #e0e0e0;
  font-size: 13px;
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.maplibregl-popup-tip {
  display: none;
}

/* --- Credits --- */

.credits {
  margin-top: auto;
  padding-top: 20px;
  font-size: 11px;
  color: #666;
  line-height: 1.6;
}

.credits a {
  color: #8ab4f8;
  text-decoration: none;
}

.credits a:hover {
  text-decoration: underline;
}

/* --- Bottom bar --- */

#bottom-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 48px;
  background: rgba(0, 0, 0, 0.9);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 16px;
  z-index: 10;
}

.controls {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.ctrl-btn {
  width: 32px;
  height: 32px;
  background: transparent;
  border: none;
  color: #aaa;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.ctrl-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.play-btn {
  width: 36px;
  height: 36px;
}

.month-label {
  font-size: 14px;
  color: #e0e0e0;
  margin-left: 8px;
  min-width: 140px;
}

/* --- Timeline slider --- */

.timeline-wrap {
  flex: 1;
  display: flex;
  align-items: center;
}

#timeline {
  width: 100%;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

#timeline::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.5);
}

#timeline::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  border: none;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.5);
}

/* --- MapLibre controls --- */

.maplibregl-ctrl-group {
  background: rgba(0, 0, 0, 0.8) !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
}

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

.maplibregl-ctrl-group button + button {
  border-top-color: rgba(255, 255, 255, 0.1) !important;
}

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

.maplibregl-ctrl-group button .maplibregl-ctrl-icon {
  filter: invert(1);
}

.maplibregl-ctrl-bottom-right {
  bottom: 52px;
}

/* --- Responsive --- */

@media (max-width: 600px) {
  .sidebar {
    width: 240px;
  }
  .sidebar:not(.open) {
    transform: translateX(-240px);
  }
  .month-label {
    font-size: 12px;
    min-width: 100px;
  }
}
