:root {
  color-scheme: dark;
  --bg: #080d13;
  --panel: #111923;
  --panel-strong: #162231;
  --line: #263446;
  --text: #f5f8fc;
  --muted: #91a1b4;
  --accent: #d9f56f;
  --high: #ff806f;
  --low: #72baff;
  --rain: #73c8ed;
  --danger: #ffb4a9;
}

* { box-sizing: border-box; }
html { background: var(--bg); }

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at 50% -100px, #1a3347 0, var(--bg) 380px);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", "Noto Sans JP", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, a { -webkit-tap-highlight-color: transparent; }

.weather-app {
  width: min(100%, 520px);
  margin: 0 auto;
  padding: max(22px, env(safe-area-inset-top)) 12px max(28px, env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 4px 4px 16px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .12em;
}

h1, h2, p { margin: 0; }
h1 { font-size: 23px; line-height: 1.2; }
h2 { font-size: 13px; line-height: 1.3; }

.refresh-button {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 42px;
  padding: 0 13px;
  border: 1px solid #405167;
  border-radius: 999px;
  background: #172231;
  color: var(--text);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.refresh-button svg {
  width: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.refresh-button:disabled { cursor: wait; opacity: .65; }
.refresh-button.is-loading svg { animation: spin .85s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.fetch-status {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  margin-bottom: 8px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(17, 25, 35, .88);
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #7f91a7; }
.fetch-status.fresh .status-dot { background: #7fe1a1; box-shadow: 0 0 0 3px rgba(127,225,161,.12); }
.fetch-status.loading .status-dot { background: #f6d36e; animation: pulse 1s ease-in-out infinite; }
.fetch-status.error { border-color: #653d3a; color: var(--danger); background: #261817; }
.fetch-status.error .status-dot { background: #ff806f; }
@keyframes pulse { 50% { opacity: .3; } }

.error-panel {
  margin: 8px 0;
  padding: 18px;
  border: 1px solid #70433f;
  border-radius: 12px;
  background: #281817;
  color: var(--danger);
}
.error-panel strong { font-size: 14px; }
.error-panel p { margin-top: 7px; font-size: 12px; line-height: 1.7; }

#weather-content { transition: opacity .2s ease; }
#weather-content.stale { opacity: .58; }

.current-card, .day-card, .hourly-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(17, 25, 35, .96);
}
.current-card { padding: 15px; }

.section-heading-row, .day-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
}
.section-heading-row > span, .day-title-row > span { font-size: 10px; }

.fresh-badge {
  padding: 3px 7px;
  border-radius: 999px;
  background: rgba(127, 225, 161, .12);
  color: #8be6a8;
  font-size: 9px !important;
  font-weight: 800;
}
.fresh-badge.stale { background: rgba(255,128,111,.12); color: var(--danger); }

.current-main { display: flex; align-items: center; gap: 18px; min-height: 108px; }
.weather-icon { white-space: nowrap; line-height: 1; }
.current-icon { min-width: 74px; font-size: 54px; text-align: center; }
.current-condition { color: var(--muted); font-size: 13px; font-weight: 650; }
.current-temperature { margin-top: 3px; font-size: 52px; font-weight: 760; letter-spacing: -.045em; line-height: .98; }
.current-temperature small { margin-left: 3px; font-size: 18px; font-weight: 650; letter-spacing: 0; }

.current-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 0;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.current-metrics div { text-align: center; }
.current-metrics div + div { border-left: 1px solid var(--line); }
.current-metrics dt { color: var(--muted); font-size: 10px; }
.current-metrics dd { margin: 4px 0 0; font-size: 12px; font-weight: 750; }

.day-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 8px; }
.day-card { min-width: 0; padding: 13px; }
.day-title-row h2 { color: var(--text); font-size: 14px; }
.day-summary { display: flex; align-items: center; gap: 7px; min-height: 58px; margin-top: 4px; }
.day-icon { flex: 0 0 auto; font-size: 31px; }
.day-summary strong { min-width: 0; font-size: 11px; line-height: 1.4; }
.temperatures { display: flex; gap: 10px; font-size: 13px; font-weight: 700; }
.temp-high { color: var(--high); }
.temp-low { color: var(--low); }
.rain-probability { margin-top: 10px; color: var(--muted); font-size: 10px; }
.rain-probability strong { color: var(--rain); font-size: 15px; }
.rain-window {
  min-height: 38px;
  margin-top: 8px;
  padding: 7px 8px;
  border-radius: 8px;
  background: #192635;
  color: #c7d7e8;
  font-size: 10px;
  font-weight: 650;
  line-height: 1.45;
}
.rain-window.wet { background: #122c3b; color: #99ddf6; }

.hourly-card { margin-top: 8px; padding: 14px 0 13px 14px; overflow: hidden; }
.hourly-card .section-heading-row { padding-right: 14px; }
.hourly-scroll {
  display: flex;
  gap: 7px;
  margin-top: 12px;
  padding: 0 14px 3px 0;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.hourly-scroll::-webkit-scrollbar { display: none; }
.hour-item {
  flex: 0 0 65px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-strong);
}
.hour-item.now { border-color: #728c44; background: #1d291f; }
.hour-item time { color: var(--muted); font-size: 10px; font-weight: 700; }
.hour-item .hour-icon { min-height: 24px; font-size: 22px; }
.hour-item .hour-temp { font-size: 12px; font-weight: 800; }
.hour-item .hour-pop { color: var(--rain); font-size: 10px; }

footer { padding: 18px 4px 0; color: #647489; font-size: 9px; line-height: 1.7; text-align: center; }
footer a { color: inherit; }

@media (max-width: 350px) {
  .weather-app { padding-inline: 8px; }
  .day-grid { grid-template-columns: 1fr; }
  .day-card { padding: 14px; }
  .rain-window { min-height: 0; }
}

@media (min-width: 700px) {
  .weather-app { width: min(100%, 900px); padding-inline: 24px; }
  .day-card { padding: 17px; }
  .current-card { padding: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
