:root {
  color-scheme: light dark;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

body {
  margin: 0;
  background: #0f172a;
  color: #e2e8f0;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px;
}

.header h1 {
  margin: 0;
  font-size: 2rem;
}

.header p {
  margin-top: 8px;
  color: #93c5fd;
}

.status {
  margin: 20px 0;
  padding: 14px 16px;
  border-radius: 10px;
  background: #1e293b;
}

.grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.card-link {
  text-decoration: none;
  color: inherit;
}

.card {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 12px;
  padding: 14px;
  transition: transform 0.14s ease, border-color 0.14s ease;
}

.card-link:hover .card {
  transform: translateY(-2px);
  border-color: #60a5fa;
}

.card h3 {
  margin: 0;
  font-size: 1.05rem;
}

.card p {
  margin: 8px 0;
  color: #cbd5e1;
}

.badge {
  display: inline-block;
  margin-top: 10px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}

.badge.ready {
  background: #14532d;
  color: #dcfce7;
}

.badge.pending {
  background: #78350f;
  color: #fef3c7;
}

.top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.back-link {
  color: #93c5fd;
  text-decoration: none;
}

.metric-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-bottom: 18px;
}

.metric-card {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 12px;
  padding: 12px;
}

.metric-label {
  margin: 0;
  color: #93c5fd;
  font-size: 0.86rem;
}

.metric-value {
  margin: 6px 0 0;
  font-size: 1.4rem;
  font-weight: 700;
}

.aux-value {
  font-size: 1rem;
  font-weight: 600;
}

.widget-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin-bottom: 18px;
}

/* Compact top moon widget */
#moon-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 280px));
  margin-bottom: 12px;
}

#moon-grid .widget-card {
  padding: 10px;
}

#moon-grid .moon-title {
  font-size: 0.95rem;
}

#moon-grid .moon-subtitle {
  font-size: 0.9rem;
}

#moon-grid .moon-phase-top {
  font-size: 1.2rem;
  font-weight: 800;
  margin-top: 6px;
}

#moon-grid .mini-widget {
  padding-top: 2px;
}

#moon-grid .mini-title {
  font-size: 0.95rem;
  font-weight: 800;
  color: #111827;
}

#moon-grid .mini-row {
  margin-top: 8px;
  display: inline-flex;
  gap: 10px;
  align-items: baseline;
  justify-content: center;
  font-weight: 800;
  color: #111827;
  font-size: 1rem;
  flex-wrap: wrap;
}

#moon-grid .mini-divider {
  color: #9ca3af;
  font-weight: 700;
}

#moon-grid .mini-forecast-widget .mini-forecast-row {
  margin-top: 8px;
  display: inline-flex;
  gap: 10px;
  align-items: baseline;
  justify-content: center;
  font-weight: 800;
  color: #111827;
  font-size: 1rem;
  flex-wrap: nowrap;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#moon-grid .mini-forecast-widget .mini-forecast-foot {
  margin-top: 10px;
  display: inline-flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  color: #4b5563;
  font-weight: 700;
}

/* Keep the compact forecast row from wrapping (prevents taller tiles). */
#moon-grid .mini-forecast-widget .mini-forecast-row > * {
  white-space: nowrap;
}

body.station-page .widget-card {
  background: #ffffff;
  border: 1px solid #dbe2ea;
  border-radius: 12px;
  padding: 12px;
}

.widget-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: #111827;
}

.widget-kicker {
  font-size: 0.95rem;
  font-style: italic;
  color: #6b7280;
  font-weight: 600;
  margin-top: 2px;
}

.widget-main {
  display: grid;
  place-items: center;
  text-align: center;
  padding: 10px 0 4px;
}

.widget-big {
  font-size: 2rem;
  font-weight: 700;
  color: #374151;
  margin: 8px 0 4px;
}

.widget-sub {
  font-size: 1.05rem;
  font-weight: 700;
  color: #4b5563;
}

.widget-row {
  display: inline-flex;
  gap: 10px;
  align-items: baseline;
  justify-content: center;
  font-weight: 800;
  color: #111827;
  font-size: 1.15rem;
}

.widget-icon {
  width: 64px;
  height: 64px;
}

.moon-icon {
  width: 68px;
  height: 68px;
}

/* Forecast widget (WeatherLink-like) */
.forecast-widget {
  padding-top: 2px;
}

.forecast-top {
  margin-bottom: 10px;
}

.forecast-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: #111827;
}

.forecast-subtitle {
  margin-top: 2px;
  font-size: 1rem;
  font-style: italic;
  color: #4b5563;
  font-weight: 600;
}

.forecast-mid {
  display: grid;
  place-items: center;
  text-align: center;
  padding: 10px 0 8px;
}

.forecast-period {
  font-size: 2rem;
  font-weight: 500;
  color: #374151;
  margin: 6px 0 4px;
}

.forecast-icon-wrap {
  width: 140px;
  height: 140px;
  display: grid;
  place-items: center;
  margin: 2px 0 10px;
}

.forecast-icon {
  width: 120px;
  height: 120px;
}

.forecast-stats {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 1.25rem;
  font-weight: 800;
  color: #111827;
}

.forecast-divider {
  color: #9ca3af;
  font-weight: 700;
}

.forecast-desc {
  margin-top: 6px;
  font-size: 1.05rem;
  font-weight: 700;
  color: #4b5563;
}

.forecast-foot {
  margin-top: 10px;
  font-size: 0.85rem;
  color: #9ca3af;
  font-weight: 600;
}

/* Sunrise/Sunset widget */
.sun-widget {
  padding-top: 2px;
}

.sun-top {
  margin-bottom: 10px;
}

.sun-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: #111827;
}

.sun-subtitle {
  margin-top: 2px;
  font-size: 1rem;
  font-style: italic;
  color: #4b5563;
  font-weight: 600;
}

.sun-mid {
  display: grid;
  place-items: center;
  text-align: center;
  padding: 10px 0 8px;
}

.sun-time {
  font-size: 2.4rem;
  font-weight: 500;
  color: #374151;
  margin: 6px 0;
}

.sun-graphic {
  width: 100%;
  max-width: 420px;
  display: grid;
  place-items: center;
}

.sun-svg {
  width: 100%;
  height: 180px;
}

/* Moon Phase widget (WeatherLink-like) */
.moon-widget {
  padding-top: 2px;
}

.moon-top {
  margin-bottom: 10px;
}

.moon-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: #111827;
}

.moon-phase-top {
  font-size: 2rem;
  font-weight: 800;
  color: #374151;
  margin: 10px 0 2px;
}

.controls {
  margin-bottom: 14px;
}

.controls select {
  background: #0b1220;
  color: #e2e8f0;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 8px 10px;
}

.windrose-controls {
  display: inline-flex;
  gap: 6px;
  padding: 6px;
  border-radius: 12px;
  border: 1px solid #dbe2ea;
  background: #ffffff;
  margin: 0 0 10px;
  align-self: flex-start;
}

.seg-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: #374151;
  font-weight: 800;
  font-size: 0.9rem;
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
}

.seg-btn:hover {
  background: #f3f4f6;
}

.seg-btn.is-active {
  background: #111827;
  color: #ffffff;
}

.chart-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

/* Slightly narrower tiles to avoid “too wide” charts */
@media (min-width: 900px) {
  body.station-page .chart-grid {
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  }
}

.chart-card {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 12px;
  padding: 10px;
}

.chart-card h3 {
  margin: 4px 0 10px;
  font-size: 0.96rem;
}

.chart-subtext {
  margin: -6px 0 10px;
  color: #6b7280;
  font-size: 0.9rem;
  font-weight: 600;
}

.chart-card canvas {
  width: 100%;
  min-height: 220px;
  display: block;
  margin: 0 auto;
}

body.station-page {
  background: #eef0f3;
  color: #111827;
}

body.station-page .container {
  max-width: 1100px;
}

body.station-page .header p {
  color: #4b5563;
}

body.station-page .status {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  color: #374151;
}

body.station-page .metric-card,
body.station-page .chart-card {
  background: #ffffff;
  border: 1px solid #dbe2ea;
}

body.station-page .chart-card {
  display: flex;
  flex-direction: column;
}

body.station-page .chart-card canvas {
  /* Let Chart.js control aspect; we just provide height */
  flex: 0 0 auto;
  width: 100%;
  height: 240px;
  max-height: 240px;
  min-height: 0;
  margin: auto;
}

/* Give key charts more vertical room */
body.station-page #temp-chart {
  height: 280px;
  max-height: 280px;
}

body.station-page #pressure-chart {
  height: 280px;
  max-height: 280px;
}

@media (min-width: 900px) {
  body.station-page .chart-card-wide {
    grid-column: span 2;
  }
}

body.station-page .metric-label {
  color: #6b7280;
}

body.station-page .metric-value {
  color: #111827;
}

body.station-page .back-link {
  color: #2563eb;
}

.windrose-legend {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 12px;
  padding: 8px 6px 2px;
}

.windrose-wrap {
  position: relative;
}

.windrose-tooltip {
  position: absolute;
  left: 0;
  top: 0;
  transform: translate(-9999px, -9999px);
  background: #374151;
  color: #ffffff;
  border-radius: 8px;
  padding: 12px 14px;
  min-width: 180px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  pointer-events: none;
  z-index: 5;
}

.windrose-tooltip-title {
  font-size: 1.05rem;
  font-weight: 800;
  margin-bottom: 8px;
}

.windrose-tooltip-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1rem;
  font-weight: 600;
}

.windrose-tooltip-swatch {
  width: 6px;
  height: 26px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.35);
}

.windrose-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: 8px;
  padding: 10px 12px;
  font-weight: 700;
  color: #ffffff;
}

.windrose-swatch {
  width: 14px;
  height: 22px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.45);
}
