:root {
  color-scheme: dark;
  --bg: #0f1419;
  --panel: #1a2332;
  --text: #e8eef7;
  --muted: #8fa3bf;
  --accent: #5eb1ff;
  --error: #ff7b7b;
  --border: #2a3a52;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: radial-gradient(circle at top, #172033 0%, var(--bg) 55%);
  color: var(--text);
}

.layout {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  max-width: none;
  padding: 1rem 1.25rem 1.25rem;
}

.header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 0.75rem;
  flex-shrink: 0;
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.75rem;
  color: var(--accent);
}

h1 {
  margin: 0.25rem 0 0;
  font-size: clamp(1.5rem, 4vw, 2rem);
}

.subtle {
  color: var(--muted);
  margin: 0;
  font-size: 0.85rem;
  text-align: right;
}

.charts-section {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
}

.charts-header {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
  flex-shrink: 0;
}

.chart-range-tabs {
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: 100%;
}

.chart-range-divider {
  width: 1px;
  align-self: stretch;
  margin: 0.15rem 0.2rem;
  background: var(--border);
}

.range-hint {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
  text-align: right;
  max-width: 28rem;
}

.range-hint.hidden {
  display: none;
}

.chart-controls {
  display: flex;
  gap: 0.35rem;
  padding: 0.25rem;
  background: rgba(15, 20, 25, 0.55);
  border: 1px solid var(--border);
  border-radius: 999px;
}

.chart-metric-tabs {
  margin-bottom: 0.75rem;
  flex-shrink: 0;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  margin-bottom: 0.75rem;
  flex-shrink: 0;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: none;
  background: transparent;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
  padding: 0.15rem 0.35rem;
  border-radius: 6px;
}

.legend-item.is-off {
  opacity: 0.4;
  text-decoration: line-through;
}

.legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.2);
}

.chart-range-btn,
.chart-metric-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  font: inherit;
  cursor: pointer;
}

.chart-range-btn:hover,
.chart-metric-btn:hover {
  color: var(--text);
  background: rgba(94, 177, 255, 0.12);
}

.chart-range-btn.is-active,
.chart-metric-btn.is-active {
  color: var(--text);
  background: rgba(94, 177, 255, 0.22);
}

.chart-metric-btn[data-metric="tempF"].is-active {
  background: rgba(251, 113, 133, 0.28);
  color: #fecdd3;
}

.chart-metric-btn[data-metric="humidity"].is-active {
  background: rgba(56, 189, 248, 0.28);
  color: #bae6fd;
}

.chart-metric-btn[data-metric="windSpeedMph"].is-active {
  background: rgba(167, 139, 250, 0.28);
  color: #ddd6fe;
}

.chart-panel {
  display: flex;
  flex-direction: column;
  background: linear-gradient(145deg, rgba(26, 35, 50, 0.95), rgba(20, 28, 40, 0.98));
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  overflow: hidden;
}

.chart-wrap {
  position: relative;
  height: clamp(220px, 34vh, 340px);
  flex-shrink: 0;
}

#trend-chart {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

.chart-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  flex-shrink: 0;
}

.chart-stat {
  background: rgba(15, 20, 25, 0.45);
  border: 1px solid var(--border);
  border-left: 3px solid var(--stat-color);
  border-radius: 8px;
  padding: 0.45rem 0.65rem;
  min-width: 120px;
}

.chart-stat-label {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
}

.chart-stat-value {
  display: block;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--stat-color, var(--text));
}

.chart-stat-range {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
}

.wind-dominance-stat {
  min-width: 112px;
  max-width: 120px;
}

.wind-dominance-mini {
  display: block;
  width: 72px;
  height: 72px;
  margin: 0.15rem 0;
}

.chart-tooltip {
  position: absolute;
  top: 8px;
  transform: translateX(-50%);
  background: rgba(15, 20, 25, 0.95);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
  font-size: 0.8rem;
  color: var(--text);
  pointer-events: none;
  white-space: nowrap;
  z-index: 2;
}

.chart-tooltip.hidden {
  display: none;
}

.tip-time {
  color: var(--muted);
  margin-bottom: 0.25rem;
  font-size: 0.75rem;
}

.tip-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.error-banner {
  background: rgba(255, 123, 123, 0.15);
  border: 1px solid var(--error);
  color: #ffd5d5;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  flex-shrink: 0;
}

.hidden {
  display: none;
}

.rain-section {
  margin-top: 1.25rem;
  flex-shrink: 0;
}

.rain-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.rain-header h2 {
  margin: 0;
  font-size: 1.25rem;
}

.rain-subtitle {
  margin: 0.25rem 0 0;
  font-size: 0.8rem;
}

.rain-year-tabs {
  flex-shrink: 0;
}

.rain-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.rain-stat {
  flex: 1 1 140px;
}

.rain-panels {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.rain-panel {
  min-height: 0;
}

.rain-panel-title {
  margin: 0 0 0.25rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--muted);
}

.rain-events-hint {
  margin: 0 0 0.65rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.rain-chart-wrap {
  position: relative;
  height: 220px;
}

.rain-chart-wrap--rose {
  height: 280px;
  cursor: pointer;
}

.rain-chart-wrap canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.rain-extremes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.rain-extreme-card {
  background: linear-gradient(145deg, rgba(26, 35, 50, 0.95), rgba(20, 28, 40, 0.98));
  border: 1px solid var(--border);
  border-left: 3px solid var(--extreme-color, var(--accent));
  border-radius: 12px;
  padding: 0.85rem 1rem;
}

.rain-extreme-card h4 {
  margin: 0 0 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 600;
}

.rain-extreme-amount {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--extreme-color, var(--accent));
}

@media (max-width: 900px) {
  .rain-panels,
  .rain-extremes {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .header {
    flex-direction: column;
  }

  .subtle {
    text-align: left;
  }

  .chart-wrap {
    height: clamp(200px, 42vw, 280px);
  }
}
