* {
  box-sizing: border-box;
}

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

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

#panel {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 320px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  background: rgba(20, 26, 33, 0.92);
  color: #f2f5f7;
  border-radius: 12px;
  padding: 18px 18px 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(6px);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

#panel.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px);
}

#panel-close {
  position: absolute;
  top: 10px;
  right: 12px;
  background: none;
  border: none;
  color: #9fb0bd;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

#panel-close:hover {
  color: #fff;
}

#panel h2 {
  margin: 0 8px 2px 0;
  font-size: 18px;
}

.coords {
  color: #9fb0bd;
  font-size: 12px;
  margin-bottom: 10px;
}

.now-summary {
  display: flex;
  gap: 14px;
  margin-bottom: 10px;
  font-size: 13px;
}

.now-summary .stat {
  display: flex;
  flex-direction: column;
}

.now-summary .stat .value {
  font-size: 17px;
  font-weight: 600;
}

.now-summary .stat .label {
  color: #9fb0bd;
  font-size: 11px;
}

.chart-wrap {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 8px;
  padding: 8px;
}

.chart-title {
  font-size: 11px;
  color: #9fb0bd;
  margin: 10px 0 4px;
}

.tide-extremes {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin-top: 6px;
  font-size: 11px;
  color: #cfdbe4;
}

.tide-extremes .high {
  color: #fca5a5;
}

.tide-extremes .low {
  color: #93c5fd;
}

.tide-extremes b {
  color: #f2f5f7;
  font-weight: 600;
}

.spot-marker {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fdae61;
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.25);
  cursor: pointer;
}

#layer-switch {
  position: absolute;
  top: 16px;
  left: 60px;
  display: flex;
  background: rgba(20, 26, 33, 0.88);
  border-radius: 8px;
  padding: 3px;
  gap: 3px;
}

#layer-switch button {
  border: none;
  background: transparent;
  color: #9fb0bd;
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
}

#layer-switch button.active {
  background: #66c2a5;
  color: #0f172a;
  font-weight: 600;
}

.source-note {
  margin-top: 10px;
  font-size: 10px;
  color: #6f8494;
  line-height: 1.4;
}

#status-banner {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(20, 26, 33, 0.9);
  color: #f2f5f7;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 12px;
  z-index: 5;
}

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

#time-control {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  width: min(520px, calc(100vw - 240px));
  background: rgba(20, 26, 33, 0.88);
  color: #f2f5f7;
  padding: 10px 16px 12px;
  border-radius: 10px;
  text-align: center;
}

#time-control.hidden {
  display: none;
}

#time-label {
  font-size: 12px;
  margin-bottom: 6px;
  color: #cfdbe4;
}

#time-slider {
  width: 100%;
  accent-color: #66c2a5;
}

#legend {
  position: absolute;
  bottom: 104px;
  left: 16px;
  background: rgba(20, 26, 33, 0.85);
  color: #f2f5f7;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 12px;
}

.legend-title {
  margin-bottom: 6px;
  font-weight: 600;
}

.legend-scale {
  display: flex;
  width: 234px;
  height: 10px;
  border-radius: 4px;
  overflow: hidden;
}

.legend-scale span {
  flex: 1;
}

.legend-labels {
  display: flex;
  width: 234px;
  margin-top: 4px;
  color: #9fb0bd;
  font-size: 9px;
}

.legend-labels span {
  flex: 1;
  text-align: left;
}

.maplibregl-popup-content {
  background: rgba(20, 26, 33, 0.95);
  color: #f2f5f7;
  font-size: 12px;
}
