* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }

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

#top-bar {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  background: rgba(255,255,255,0.92);
  padding: 8px 18px;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  text-align: center;
  pointer-events: none;
}
#top-bar h1 { margin: 0; font-size: 16px; }
#top-bar .subtitle { margin: 2px 0 0; font-size: 11px; color: #555; }

.panel {
  position: absolute;
  z-index: 5;
  background: rgba(255,255,255,0.95);
  border-radius: 8px;
  padding: 10px 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  font-size: 12px;
}
.panel-title { font-weight: 600; margin-bottom: 6px; }
.panel.hidden { display: none; }

#layer-panel { top: 80px; left: 10px; min-width: 140px; }
#legend { bottom: 20px; left: 10px; }
#loading { top: 130px; right: 10px; }
#loading.hidden { display: none; }

#search-panel { top: 12px; right: 10px; width: 220px; padding: 0; background: transparent; box-shadow: none; }
#search-input {
  width: 100%;
  padding: 9px 12px;
  border-radius: 8px;
  border: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  font-size: 13px;
  background: rgba(255,255,255,0.95);
}
#search-input:focus { outline: 2px solid #1565c0; }
.search-results {
  margin-top: 4px;
  background: rgba(255,255,255,0.98);
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  max-height: 260px;
  overflow-y: auto;
}
.search-results.hidden { display: none; }
.search-result-item {
  padding: 8px 12px;
  font-size: 12px;
  cursor: pointer;
  border-bottom: 1px solid rgba(0,0,0,0.06);
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover, .search-result-item.active { background: #eef4fb; }
.search-result-place { font-weight: 600; background: #f5faf1; }
.search-result-place:hover { background: #e8f4e0; }
.search-result-empty { padding: 8px 12px; font-size: 12px; color: #888; }

#zoom-hint {
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
  font-weight: 600;
}
#zoom-hint.hidden { display: none; }

#forecast-panel {
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  min-width: 320px;
}

/* --- Mobile layout: same panels, repositioned so nothing overlaps on a
   narrow screen. Top row = compact title + search; forecast controls move
   to a full-width bottom bar (the primary interaction while zoomed in);
   layer toggles + legend collapse into small tap-to-expand panels in the
   remaining bottom corners. */
@media (max-width: 640px) {
  #top-bar {
    top: 8px;
    left: 8px;
    transform: none;
    max-width: 46vw;
    padding: 6px 10px;
    text-align: left;
  }
  #top-bar h1 { font-size: 13px; line-height: 1.25; }
  #top-bar .subtitle { display: none; }

  #search-panel { top: 8px; right: 8px; left: auto; width: 48vw; }
  #search-input { padding: 8px 10px; font-size: 12px; }

  #zoom-hint { top: 64px; left: 8px; right: 8px; transform: none; width: auto; text-align: center; font-size: 12px; }

  #loading { top: 64px; right: 8px; font-size: 11px; }

  #forecast-panel {
    top: auto;
    bottom: 8px;
    left: 8px;
    right: 8px;
    transform: none;
    min-width: 0;
    width: auto;
  }

  #layer-panel {
    top: auto;
    bottom: 100px;
    left: 8px;
    min-width: 0;
    max-width: 40vw;
    font-size: 11px;
    padding: 8px 10px;
  }
  #layer-panel .panel-title { font-size: 11px; margin-bottom: 4px; }
  #layer-panel .layer-row { gap: 4px; }

  #legend {
    bottom: 100px;
    left: auto;
    right: 8px;
    max-width: 38vw;
    font-size: 10px;
    padding: 8px 10px;
  }
  #legend .panel-title { font-size: 11px; margin-bottom: 4px; }
  #legend .legend-row { gap: 5px; margin: 2px 0; }
}

.layer-row { display: flex; align-items: center; gap: 6px; cursor: pointer; }

.day-tabs { display: flex; gap: 4px; margin-bottom: 8px; }
.day-tab {
  flex: 1;
  text-align: center;
  padding: 5px 4px;
  border-radius: 6px;
  border: 1px solid #ccc;
  background: #f5f5f5;
  cursor: pointer;
  font-size: 11px;
  line-height: 1.3;
  user-select: none;
}
.day-tab .weekday { display: block; font-weight: 600; }
.day-tab .daynum { display: block; color: #777; font-size: 10px; }
.day-tab.active { background: #1565c0; border-color: #1565c0; color: #fff; }
.day-tab.active .daynum { color: #d7e8fb; }

.hour-row { display: flex; align-items: center; gap: 8px; }
.hour-row input[type="range"] { flex: 1; }
.hour-label { font-weight: 600; font-variant-numeric: tabular-nums; min-width: 42px; text-align: right; }

.legend-row { display: flex; align-items: center; gap: 8px; margin: 3px 0; }
.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; border: 1px solid rgba(0,0,0,0.3); }
.line { width: 22px; height: 0; border-top: 3px solid; display: inline-block; }
.wind-sample { border-color: #616161; }
.wave-sample { border-color: #1565c0; }

/* --- beach marker --- */
.beach-marker { position: relative; width: 0; height: 0; cursor: pointer; }

.marker-circle {
  position: absolute;
  left: 50%; top: 50%;
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 3px rgba(0,0,0,0.6);
  transform: translate(-50%, -50%);
}

.arrow-pivot { position: absolute; left: 50%; top: 50%; width: 0; height: 0; }

.arrow-shape {
  position: absolute;
  bottom: 0; left: 50%;
  width: 0; height: 0;
  transform: translateX(-50%);
}
.arrow-shape.wind {
  border-left: 3px solid transparent;
  border-right: 3px solid transparent;
  border-bottom: 15px solid rgba(97,97,97,0.9);
}
.arrow-shape.wave {
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-bottom: 22px solid rgba(21,101,192,0.85);
}

.marker-label {
  position: absolute;
  top: 12px; left: 50%;
  transform: translate(-50%, 0);
  white-space: nowrap;
  font-size: 10px;
  background: rgba(255,255,255,0.85);
  padding: 1px 4px;
  border-radius: 4px;
  pointer-events: none;
}

/* --- Beaufort badge, one per named bay --- */
.beaufort-badge { position: relative; width: 0; height: 0; }
.beaufort-gauge {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: 40px; height: 30px;
  overflow: visible;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.55));
  cursor: default;
}
.gauge-track { fill: none; stroke: rgba(255,255,255,0.85); stroke-width: 6; stroke-linecap: round; }
.gauge-value { fill: none; stroke-width: 6; stroke-linecap: round; }
.gauge-text {
  font-size: 13px;
  font-weight: 700;
  fill: #fff;
  text-anchor: middle;
  paint-order: stroke;
  stroke: rgba(0,0,0,0.55);
  stroke-width: 2px;
  stroke-linejoin: round;
}

/* --- sea-region overview: sparse Beaufort + wave arrow per named sea/gulf --- */
.sea-region-marker { position: relative; width: 0; height: 0; }

.sea-region-gauge {
  width: 54px; height: 40px;
}
.sea-region-gauge .gauge-text { font-size: 15px; }

.arrow-shape.sea-region-wave {
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 30px solid rgba(21,101,192,0.85);
}

.sea-region-label {
  position: absolute;
  top: 34px; left: 50%;
  transform: translate(-50%, 0);
  white-space: nowrap;
  font-size: 11px;
  font-weight: 600;
  background: rgba(255,255,255,0.9);
  padding: 2px 6px;
  border-radius: 4px;
  pointer-events: none;
}

.beach-popup h3 { margin: 0 0 6px; font-size: 14px; }
.beach-popup p { margin: 3px 0; font-size: 12px; }
.sev-badge {
  display: inline-block;
  color: #fff;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 11px;
}
