:root {
  --nav: #17324d;
  --panel: #ffffff;
  --line: #d6dee8;
  --text: #1d2733;
  --muted: #64748b;
  --accent: #1976d2;
  --soft: #eef5fb;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  background: #f4f7fb;
  font-family: "Segoe UI", "Noto Sans TC", Arial, sans-serif;
}

.app-nav {
  min-height: 64px;
  background: var(--nav);
  color: #fff;
  padding: 10px 18px;
}

.navbar-brand {
  color: #fff;
  font-weight: 700;
}

.search-bar {
  width: min(820px, 100%);
}

.county-select {
  flex: 0 0 150px;
}

.icon-btn {
  align-items: center;
  display: inline-flex;
  flex: 0 0 42px;
  height: 38px;
  justify-content: center;
  padding: 0;
  width: 42px;
}

.icon-btn i {
  font-size: 18px;
  line-height: 1;
}

.floating-message {
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.18);
  left: 50%;
  margin: 0;
  max-width: min(420px, calc(100vw - 32px));
  opacity: 0;
  pointer-events: none;
  position: fixed;
  top: 78px;
  transform: translate(-50%, -12px);
  transition: opacity 180ms ease, transform 180ms ease;
  width: max-content;
  z-index: 1100;
}

.floating-message.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  height: calc(100vh - 64px);
}

.map-panel {
  min-width: 0;
  border-right: 1px solid var(--line);
}

#map {
  width: 100%;
  height: 100%;
}

.station-marker-shell {
  background: transparent;
  border: 0;
}

.station-marker {
  border: 2px solid #ffffff;
  border-radius: 50% 50% 50% 0;
  box-shadow: 0 3px 8px rgba(15, 23, 42, 0.28);
  display: block;
  height: 22px;
  transform: rotate(-45deg);
  transform-origin: center;
  width: 22px;
}

.station-marker::after {
  background: #ffffff;
  border-radius: 999px;
  content: "";
  display: block;
  height: 7px;
  margin: 5px;
  width: 7px;
}

.station-marker-default {
  background: #1976d2;
}

.station-marker-nearby {
  background: #d32f2f;
}

.map-layer-control,
.temperature-legend {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.14);
  color: var(--text);
  font-size: 13px;
  padding: 8px 10px;
}

.map-layer-control label {
  align-items: center;
  cursor: pointer;
  display: flex;
  gap: 6px;
  margin: 0;
  white-space: nowrap;
}

.temperature-legend {
  display: grid;
  gap: 5px;
}

.temperature-legend strong {
  font-size: 13px;
}

.temperature-legend span {
  align-items: center;
  display: flex;
  gap: 6px;
  white-space: nowrap;
}

.temperature-legend i {
  border: 1px solid rgba(15, 23, 42, 0.18);
  display: inline-block;
  height: 12px;
  width: 18px;
}

.info-panel {
  overflow-y: auto;
  padding: 16px;
  background: #edf2f7;
}

.weather-block {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 14px;
}

.block-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.block-heading.compact {
  margin-bottom: 10px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 13px;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.2;
}

.location-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 4px 0 8px;
}

.location-badge {
  font-size: 13px;
  font-weight: 600;
}

h2 {
  font-size: 18px;
}

.updated-at {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.metric {
  min-height: 78px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  padding: 12px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  margin-top: 6px;
  font-size: 26px;
}

.summary-box {
  margin-top: 12px;
  border-left: 4px solid var(--accent);
  background: #f8fbff;
  padding: 12px;
}

.summary-box span {
  font-weight: 700;
}

.summary-box p {
  margin: 6px 0 0;
  color: #334155;
}

.chart-frame {
  position: relative;
  height: 260px;
  margin-bottom: 12px;
  max-height: 32vh;
  min-height: 220px;
}

.chart-frame canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

.forecast-list {
  display: grid;
  gap: 8px;
}

.forecast-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}

.forecast-item span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.forecast-item strong {
  font-size: 16px;
}

.leaflet-popup-content {
  min-width: 180px;
}

.popup-title {
  font-weight: 700;
}

.popup-meta {
  color: var(--muted);
  margin: 2px 0 8px;
}

.popup-loading {
  color: var(--muted);
  font-size: 13px;
}

.popup-preview-grid {
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.popup-preview-grid div {
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px;
  text-align: center;
}

.popup-preview-grid span {
  color: var(--muted);
  display: block;
  font-size: 12px;
}

.popup-preview-grid strong {
  display: block;
  font-size: 13px;
  margin-top: 2px;
  white-space: nowrap;
}

@media (max-width: 920px) {
  .app-nav .container-fluid {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
  }

  .app-shell {
    grid-template-columns: 1fr;
    height: auto;
  }

  .map-panel {
    height: 52vh;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .info-panel {
    overflow: visible;
  }

  .chart-frame {
    height: 240px;
    max-height: none;
  }
}

@media (max-width: 520px) {
  .search-bar {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
  }

  .county-select {
    grid-column: 1 / -1;
    width: 100%;
  }

  .metric-grid {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 24px;
  }

  .chart-frame {
    height: 220px;
    min-height: 220px;
  }
}
