html, body {
  margin: 0;
  height: 100%;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

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

/* --- control panel (top right) --- */

#panel {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 5;
  width: 280px;
  background: rgba(255, 255, 255, 0.94);
  border-radius: 8px;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.3);
  padding: 10px;
  box-sizing: border-box;
}

#panel-header {
  display: flex;
  gap: 6px;
}

#var-select {
  flex: 1;
  font-size: 14px;
  padding: 4px;
}

#panel-toggle {
  border: none;
  background: none;
  cursor: pointer;
  font-size: 14px;
  padding: 2px 6px;
}

#panel.collapsed #panel-body {
  display: none;
}

#search-row {
  position: relative;
  margin-top: 8px;
}

#search {
  width: 100%;
  box-sizing: border-box;
  font-size: 13px;
  padding: 5px 8px;
  border: 1px solid #ccc;
  border-radius: 5px;
}

#search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 10;
  margin: 2px 0 0;
  padding: 0;
  list-style: none;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 5px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  max-height: 220px;
  overflow-y: auto;
}

#search-results li {
  padding: 6px 8px;
  font-size: 13px;
  cursor: pointer;
}

#search-results li small {
  color: #777;
}

#search-results li:hover,
#search-results li.active {
  background: #eaf2ea;
}

#legend {
  width: 100%;
  height: 14px;
  margin-top: 10px;
  border-radius: 3px;
}

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

#opacity-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #444;
  margin-top: 8px;
}

#opacity-row input {
  flex: 1;
}

#smooth-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #444;
  margin-top: 6px;
  cursor: pointer;
}

#readout {
  margin-top: 8px;
  font-size: 13px;
  color: #222;
  min-height: 1.2em;
}

#readout b {
  font-size: 15px;
}

#var-desc {
  margin-top: 8px;
  font-size: 11px;
  line-height: 1.4;
  color: #666;
}

#var-desc:empty {
  display: none;
}

/* --- timeline (bottom) --- */

#timeline {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(720px, calc(100% - 24px));
  background: rgba(255, 255, 255, 0.94);
  border-radius: 8px;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.3);
  padding: 8px 12px;
  box-sizing: border-box;
}

#timeline button {
  border: 1px solid #ccc;
  background: #fff;
  border-radius: 5px;
  cursor: pointer;
  font-size: 13px;
  padding: 4px 8px;
  white-space: nowrap;
}

#timeline button:hover {
  background: #f0f0f0;
}

#time-slider {
  flex: 1;
  min-width: 100px;
}

#time-label {
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  min-width: 11em;
  text-align: right;
}

@media (max-width: 640px) {
  #panel {
    width: calc(100% - 20px);
  }

  #time-label {
    min-width: 0;
    font-size: 11px;
  }
}
