:root {
  color-scheme: dark;
  font-family: Roboto, "Arial", sans-serif;
  background: #07131d;
  color: #f2f7f8;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  --night: #07131d;
  --panel: #102432;
  --mint: #76d6c2;
  --muted: #9bb0bc;
  --white: #f2f7f8;
  --yellow: #ffd740;
  --red: #ff5252;
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--night);
}

body { min-height: 100svh; }

.station {
  width: 100%;
  height: 100svh;
  min-height: 240px;
  display: flex;
  flex-direction: column;
  gap: clamp(6px, 1.2vh, 12px);
  padding: max(8px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  background: var(--night);
}

.toolbar {
  height: clamp(28px, 4.5vh, 42px);
  flex: 0 0 clamp(28px, 4.5vh, 42px);
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.wake-status {
  margin-right: 10px;
  color: var(--muted);
  font-size: clamp(11px, 1.4vw, 14px);
}

.wake-button {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px;
  border: 1px solid #274352;
  border-radius: 999px;
  background: var(--panel);
  color: var(--mint);
  font: 600 clamp(11px, 1.35vw, 14px)/1.1 Roboto, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

.wake-button[aria-pressed="true"] { border-color: #397368; }
.wake-icon { font-size: 1.15em; }

.forecast-grid {
  height: clamp(86px, 19vh, 150px);
  flex: 0 0 clamp(86px, 19vh, 150px);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(6px, 1.15vw, 12px);
}

.weather-card {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: clamp(3px, 1vw, 12px);
  padding: clamp(7px, 1.35vw, 18px);
  border-radius: clamp(12px, 1.8vw, 20px);
  background: var(--panel);
}

.temperature {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  color: var(--white);
  font-size: clamp(2rem, 8vw, 6.5rem);
  font-weight: 750;
  line-height: 1;
  letter-spacing: -0.09em;
  font-variant-numeric: tabular-nums;
}

.wind-block {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: 2px;
}

.time-label {
  color: var(--mint);
  font-size: clamp(10px, 1.55vw, 15px);
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.wind-speed {
  color: var(--white);
  font-size: clamp(1.35rem, 4.3vw, 3.1rem);
  font-weight: 750;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.wind-unit {
  color: var(--muted);
  font-size: clamp(9px, 1.2vw, 13px);
  line-height: 1;
}

.chart-panel {
  position: relative;
  min-height: 90px;
  flex: 1 1 auto;
  overflow: hidden;
  border-radius: clamp(12px, 1.8vw, 20px);
  background: var(--panel);
}

#precipitationChart {
  display: block;
  width: 100%;
  height: 100%;
}

.chart-message {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 16px;
  color: var(--muted);
  text-align: center;
  font-size: clamp(13px, 1.6vw, 18px);
  pointer-events: none;
}

.chart-message[hidden] { display: none; }

.retry-button {
  min-height: 36px;
  padding: 6px 14px;
  border: 1px solid #397368;
  border-radius: 999px;
  background: #14352f;
  color: var(--mint);
  font: 600 14px Roboto, Arial, sans-serif;
  pointer-events: auto;
}

@media (orientation: portrait) {
  .station { gap: 8px; }
  .toolbar { height: 34px; flex-basis: 34px; }
  .forecast-grid { height: clamp(100px, 14vh, 135px); flex-basis: clamp(100px, 14vh, 135px); }
  .weather-card { flex-direction: column; justify-content: center; gap: 6px; padding: 7px 4px; }
  .temperature { letter-spacing: -0.08em; }
  .wind-block { display: grid; grid-template-columns: auto auto; column-gap: 4px; align-items: baseline; }
  .time-label { grid-column: 1 / -1; }
  .wind-speed { font-size: clamp(1.1rem, 5vw, 1.7rem); }
  .wind-unit { font-size: 9px; }
}

@media (max-height: 420px) and (orientation: landscape) {
  .station { gap: 5px; padding-top: max(4px, env(safe-area-inset-top)); padding-bottom: max(4px, env(safe-area-inset-bottom)); }
  .toolbar { height: 25px; flex-basis: 25px; }
  .forecast-grid { height: 88px; flex-basis: 88px; }
  .weather-card { padding: 5px 10px; }
  .temperature { font-size: clamp(2rem, 8vw, 4rem); }
  .wind-speed { font-size: clamp(1.25rem, 4vw, 2rem); }
  .chart-panel { min-height: 70px; }
}
