:root {
  --bg: #0f1b2d;
  --panel: #ffffff;
  --ink: #1b2733;
  --muted: #5b6b7b;
  --accent: #d7263d;
  --accent2: #1b6ca8;
  --warn-bg: #fff4e5;
  --warn-border: #f0a000;
  --shadow: 0 6px 24px rgba(15, 27, 45, .12);
  --radius: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, #0f1b2d 0%, #1b3a5c 280px, #eef2f6 280px, #eef2f6 100%);
  min-height: 100vh;
}

header {
  max-width: 980px;
  margin: 0 auto;
  padding: 48px 20px 24px;
  color: #fff;
}
header h1 { margin: 0 0 8px; font-size: clamp(1.6rem, 4vw, 2.4rem); }
header .sub { margin: 0; max-width: 640px; color: #cdd9e5; line-height: 1.5; }

main { max-width: 980px; margin: 0 auto; padding: 0 20px 48px; }

.card {
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
}

#locate-btn {
  font-size: 1.05rem;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 999px;
  padding: 14px 26px;
  cursor: pointer;
  transition: transform .08s ease, background .2s ease;
}
#locate-btn:hover { background: #b51e31; }
#locate-btn:active { transform: scale(.97); }
#locate-btn:disabled { opacity: .6; cursor: progress; }

.hint { margin: 16px 0 0; color: var(--muted); }
.hint select {
  margin-left: 6px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid #cdd5dd;
  font-size: .95rem;
  max-width: 100%;
}

#map-toggle {
  margin-left: 8px;
  font-size: .9rem;
  font-weight: 600;
  color: var(--accent2);
  background: #eef4fa;
  border: 1px solid #cbddee;
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  transition: background .15s ease;
}
#map-toggle:hover { background: #dceaf6; }

.map-wrap { margin-top: 16px; }
#map {
  height: 420px;
  width: 100%;
  border-radius: 12px;
  border: 1px solid #cdd5dd;
}
.map-wrap .leaflet-marker-active {
  filter: hue-rotate(140deg) saturate(1.6);
}

.status { margin: 12px 0 0; color: var(--muted); min-height: 1.2em; }

.warning {
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  border-left-width: 6px;
  border-radius: 12px;
  padding: 16px 20px;
  color: #6b4a00;
  line-height: 1.5;
}

.station-head { border-bottom: 1px solid #eef2f6; padding-bottom: 12px; margin-bottom: 20px; }
.station-head h2 { margin: 0 0 4px; }
.station-meta { margin: 0; color: var(--muted); }
.station-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
#permalink-btn {
  font-size: .85rem;
  font-weight: 600;
  color: var(--accent2);
  background: #eef4fa;
  border: 1px solid #cbddee;
  border-radius: 999px;
  padding: 6px 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s ease;
}
#permalink-btn:hover { background: #dceaf6; }

.period-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}
.period {
  background: #f4f7fa;
  border-radius: 12px;
  padding: 14px;
  text-align: center;
}
.period .label { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.period .val { font-size: 1.7rem; font-weight: 700; margin: 6px 0 2px; }
.period .unit { font-size: .8rem; color: var(--muted); }

.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}
.chart-box { margin: 0; }
.chart-wide { grid-column: 1 / -1; }
.chart-box figcaption { font-weight: 600; margin-bottom: 8px; font-size: .95rem; }
.chart-box canvas { width: 100% !important; height: 240px !important; }

footer {
  text-align: center;
  padding: 24px 20px 40px;
  color: var(--muted);
  font-size: .85rem;
}

.hidden { display: none; }

@media (max-width: 720px) {
  .chart-grid { grid-template-columns: 1fr; }
  .period-grid { grid-template-columns: 1fr; }
}

/* Raw Data Panel Styles */
.button-group {
  margin: 1rem 0;
}

.raw-data-content {
  margin-top: 1rem;
}

#raw-data-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
}

#raw-data-table th,
#raw-data-table td {
  border: 1px solid #ddd;
  padding: .5rem;
  text-align: center;
}

#raw-data-table th {
  background-color: #f2f2f2;
  font-weight: bold;
}
