:root {
  --page-bg: #0a0e17;
  --frame-bg: #131b2c;
  --card-bg: #1a2437;
  --card-bg-alt: #212c42;
  --border: #2b3752;
  --text: #edf1fb;
  --text-dim: #8993ac;
  --text-faint: #57617e;
  --green: #34d399;
  --green-dim: #1c5c46;
  --blue: #4da6ff;
  --blue-dim: #1c3a5c;
  --amber: #f5b942;
  --minor: #3fb950;
  --moderate: #e3b341;
  --severe: #f0883e;
  --extreme: #f85149;
  --radius: 14px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--page-bg);
  color: var(--text);
  min-height: 100vh;
  padding: 28px 16px;
}

.frame {
  max-width: 1320px;
  margin: 0 auto;
  background: var(--frame-bg);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 30px 80px -30px rgba(0,0,0,0.7), 0 0 0 1px rgba(255,255,255,0.03);
}

.frame-accent {
  height: 4px;
  /* 2026-10-22: same deeper green / blue / amber as the AIWXStudio logo's color bar */
  background: linear-gradient(90deg, #0fcf8a, #2b8cff 60%, #ffaa14);
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-icon {
  font-size: 30px;
  line-height: 1;
}

.brand h1 {
  font-size: 19px;
  margin: 0;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.subtitle {
  margin: 2px 0 0;
  color: var(--text-dim);
  font-size: 12.5px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.clock {
  font-size: 19px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.date {
  color: var(--text-dim);
  font-size: 12.5px;
  border-left: 1px solid var(--border);
  padding-left: 16px;
}

.updated {
  color: var(--text-faint);
  font-size: 11.5px;
  border-left: 1px solid var(--border);
  padding-left: 16px;
}

.refresh-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--green);
  cursor: pointer;
  transition: transform 0.4s ease, background 0.2s ease;
}
.refresh-btn:hover { background: var(--card-bg-alt); }
.refresh-btn.spinning svg { animation: spin 0.8s linear; }
@keyframes spin { to { transform: rotate(360deg); } }

.error-banner {
  background: rgba(248, 81, 73, 0.12);
  border: 1px solid rgba(248, 81, 73, 0.4);
  color: #ffb4ae;
  padding: 10px 16px;
  margin: 18px 28px 0;
  border-radius: 10px;
  font-size: 13px;
}

/* Dashboard grid */
.dashboard {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
  padding: 24px 28px;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}

.tile-title {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-dim);
  margin: 0 0 14px;
  font-weight: 700;
}

.tile-loading {
  color: var(--text-faint);
  font-size: 13px;
  padding: 30px 0;
  text-align: center;
}

.tile-link {
  display: inline-block;
  margin-top: 14px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--blue);
  text-decoration: none;
}
.tile-link:hover { text-decoration: underline; }
.tile-link + .tile-link { margin-top: 4px; }

/* Row 1: tiles */
.tile { grid-column: span 1; min-height: 172px; display: flex; flex-direction: column; }

.tile-info {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.tile-info-icon {
  font-size: 26px;
  background: var(--card-bg-alt);
  border-radius: 10px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.tile-info-name { font-size: 16px; font-weight: 700; }
.tile-info-meta { font-size: 12px; color: var(--text-dim); margin-top: 4px; }

.tile-body {
  display: flex;
  align-items: center;
  gap: 12px;
}
.tile-cond-icon { width: 46px; height: 46px; }
.tile-big-num {
  font-size: 34px;
  font-weight: 800;
  line-height: 1;
}
.tile-big-num .unit { font-size: 15px; font-weight: 600; color: var(--text-dim); }
.tile-cond-text { font-size: 12.5px; color: var(--text-dim); max-width: 90px; line-height: 1.35; }

.wind-body { flex-direction: column; align-items: stretch; gap: 14px; }

/* Gauge (dew point) */
.gauge-wrap {
  position: relative;
  width: 108px;
  height: 108px;
  margin: 2px auto 0;
}
.gauge { width: 100%; height: 100%; transform: rotate(-90deg); }
.gauge-bg {
  fill: none;
  stroke: var(--card-bg-alt);
  stroke-width: 12;
}
.gauge-center {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.gauge-value { font-size: 24px; font-weight: 800; }

/* Wind vane */
.vane-wrap {
  position: relative;
  width: 130px;
  height: 130px;
  margin: 2px auto 0;
}
.wind-vane { width: 100%; height: 100%; }
.vane-ring { fill: none; stroke: var(--card-bg-alt); stroke-width: 2; }
.vane-inner-ring { fill: none; stroke: var(--card-bg-alt); stroke-width: 1; }
.vane-tick-major { stroke: var(--text-faint); stroke-width: 2; }
.vane-tick-minor { stroke: var(--border); stroke-width: 1.5; }
.vane-label {
  fill: var(--text-dim);
  font-size: 10px;
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: middle;
}
#windNeedle {
  transform-origin: 60px 60px;
  transition: transform 0.6s ease, opacity 0.3s ease;
  filter: drop-shadow(0 0 5px rgba(77, 166, 255, 0.5));
}
.needle-arrow { fill: var(--blue); }
.vane-center {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.vane-speed { font-size: 24px; font-weight: 800; text-align: center; line-height: 1.1; }
.vane-speed .unit { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-dim); margin-top: 1px; }

/* Row 2: charts */
.chart-tile { grid-column: span 1; }
.chart-tile-wide { grid-column: span 3; }

.chart-tile-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.chart-tile-sub { font-size: 11px; color: var(--text-faint); margin-bottom: 14px; }

.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 110px;
}
.bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  gap: 6px;
}
.bar-col-fill {
  width: 100%;
  max-width: 16px;
  background: linear-gradient(180deg, var(--blue), rgba(77,166,255,0.25));
  border-radius: 4px 4px 2px 2px;
  min-height: 3px;
}
.bar-col-pct { font-size: 10px; color: var(--text-faint); }
.bar-col-label { font-size: 10px; color: var(--text-faint); }

.area-chart-wrap { width: 100%; }
.area-chart-wrap svg { width: 100%; height: 170px; display: block; }
.axis-label { font-size: 9px; fill: var(--text-faint); }
.temp-point-label { font-size: 9px; font-weight: 700; fill: var(--text); }
.grid-line { stroke: var(--border); stroke-width: 1; stroke-dasharray: 3 4; }
.temp-line { fill: none; stroke: var(--amber); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.temp-dot { fill: var(--amber); }

/* Today / Tonight */
.period-card { grid-column: span 2; }

.period-body {
  display: flex;
  align-items: center;
  gap: 14px;
}

.period-icon {
  width: 54px;
  height: 54px;
  flex-shrink: 0;
}

.period-temp {
  font-size: 26px;
  font-weight: 800;
}

.period-text {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.4;
  margin-top: 4px;
}

/* 7-day forecast */
.forecast-card { grid-column: span 4; }

.forecast-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 12px;
}

.forecast-day {
  background: var(--card-bg-alt);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 10px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transition: border-color 0.2s ease;
}
.forecast-day:hover { border-color: var(--blue); }

.forecast-day-name {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.forecast-day img { width: 42px; height: 42px; }

.forecast-day-temps { font-size: 13px; display: flex; gap: 6px; }
.forecast-hi { font-weight: 700; color: var(--text); opacity: 0.8; }
.forecast-lo { color: var(--text-faint); }

.forecast-day-desc {
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.3;
  min-height: 28px;
}

/* Alerts */
.alerts-card { grid-column: span 4; }

.alerts-header { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.alerts-header .tile-title { margin-bottom: 0; }

.alert-count {
  background: var(--card-bg-alt);
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 999px;
  min-width: 20px;
  text-align: center;
}
.alert-count.has-alerts { background: rgba(248, 81, 73, 0.18); color: #ffb4ae; }

.alerts-sub { font-size: 12px; color: var(--text-faint); margin: 0 0 14px; line-height: 1.5; }

.alerts-list {
  max-height: 420px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-right: 6px;
}
.alerts-list::-webkit-scrollbar { width: 8px; }
.alerts-list::-webkit-scrollbar-track { background: transparent; }
.alerts-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }

.alerts-empty { color: var(--text-faint); font-size: 13px; text-align: center; padding: 24px 0; }

.alert-item {
  border: 1px solid var(--border);
  border-left: 4px solid var(--moderate);
  border-radius: 10px;
  background: var(--card-bg-alt);
  padding: 12px 14px;
  cursor: pointer;
}
.alert-item[data-severity="Minor"] { border-left-color: var(--minor); }
.alert-item[data-severity="Moderate"] { border-left-color: var(--moderate); }
.alert-item[data-severity="Severe"] { border-left-color: var(--severe); }
.alert-item[data-severity="Extreme"] { border-left-color: var(--extreme); }

.alert-item-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.alert-event { font-size: 14px; font-weight: 700; }
.alert-time { font-size: 11px; color: var(--text-faint); white-space: nowrap; }
.alert-area { font-size: 12px; color: var(--text-dim); margin-top: 3px; }
.alert-desc { font-size: 12.5px; color: var(--text-dim); line-height: 1.5; margin-top: 10px; white-space: pre-line; display: none; }
.alert-item.expanded .alert-desc { display: block; }
.alert-toggle-hint { font-size: 11px; color: var(--blue); margin-top: 8px; }

/* Footer */
.footer {
  text-align: center;
  font-size: 12px;
  color: var(--text-faint);
  line-height: 1.6;
  padding: 6px 28px 22px;
}
.footer a { color: var(--blue); }

/* Responsive */
@media (max-width: 1080px) {
  .dashboard { grid-template-columns: repeat(2, 1fr); }
  .chart-tile-wide { grid-column: span 2; }
  .period-card, .forecast-card, .alerts-card { grid-column: span 2; }
  .forecast-row { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 680px) {
  body { padding: 12px 8px; }
  .dashboard { grid-template-columns: 1fr; padding: 18px 16px; }
  .chart-tile-wide, .period-card, .forecast-card, .alerts-card, .tile, .chart-tile { grid-column: 1 / 2; }
  .forecast-row { grid-template-columns: repeat(2, 1fr); }
  .topbar { padding: 14px 16px; }
  .date, .updated { padding-left: 10px; }
}
