:root {
  --bg-top: #0b1330;
  --bg-bottom: #1a2550;
  --glass: rgba(255, 255, 255, 0.06);
  --glass-strong: rgba(255, 255, 255, 0.1);
  --border: rgba(255, 255, 255, 0.09);
  --text-main: rgba(255, 255, 255, 0.96);
  --text-dim: rgba(255, 255, 255, 0.55);
  --text-faint: rgba(255, 255, 255, 0.32);
  --accent: #5ac8fa;
  --rain: #6fb8ff;

  --col-w: 38px;
  --label-w: 84px;
  --row-h-date: 30px;
  --row-h-hour: 22px;
  --row-h-temp: 52px;
  --row-h-rain: 48px;

  /* 降雨强度提示色（苹果天气风格蓝色系） */
  --rain-1: rgba(90, 200, 250, 0.10);
  --rain-2: rgba(90, 200, 250, 0.20);
  --rain-3: rgba(47, 111, 224, 0.32);
  --rain-text: #7ec8ff;
  --rain-bar: #5ac8fa;
  --rain-bar-deep: #2f6fe0;

  /* 三城折线图颜色 */
  --city-guiyang: #5ac8fa;
  --city-xingyi: #ffd166;
  --city-tongren: #7ee787;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC",
    "Helvetica Neue", "Microsoft YaHei", sans-serif;
  color: var(--text-main);
  background: radial-gradient(1200px 800px at 20% -10%, #24356f 0%, transparent 60%),
    linear-gradient(180deg, var(--bg-top) 0%, var(--bg-bottom) 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 20px 40px;
  min-height: 100%;
}

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.title-group h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

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

.actions { display: flex; gap: 10px; }

.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--glass);
  color: var(--text-main);
  padding: 9px 16px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  backdrop-filter: blur(10px);
  transition: background 0.15s ease, transform 0.1s ease;
}
.btn:hover { background: var(--glass-strong); }
.btn:active { transform: scale(0.96); }
.btn-primary {
  background: linear-gradient(135deg, #4aa8ff, #2f6fe0);
  border-color: transparent;
}
.btn-primary:hover { filter: brightness(1.08); }

/* ---------- Summary cards ---------- */
.summary-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}

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

.summary-card {
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 16px 18px;
  backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.summary-left { display: flex; flex-direction: column; gap: 2px; }
.summary-city { font-size: 15px; font-weight: 700; }
.summary-desc { font-size: 12.5px; color: var(--text-dim); }
.summary-range { font-size: 12px; color: var(--text-faint); margin-top: 2px; }

.summary-right { display: flex; align-items: center; gap: 8px; }
.summary-icon { font-size: 30px; line-height: 1; }
.summary-temp { font-size: 30px; font-weight: 600; letter-spacing: -0.5px; }

/* ---------- Rain alert chips ---------- */
.rain-alert-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}
@media (max-width: 720px) {
  .rain-alert-row { grid-template-columns: 1fr; }
}
.rain-alert-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 14px;
  font-size: 12px;
  line-height: 1.6;
  background: rgba(255, 255, 255, 0.03);
}
.rain-alert-card.has-rain {
  background: rgba(255, 138, 101, 0.08);
  border-color: rgba(255, 138, 101, 0.28);
}
.rain-alert-card .ra-title {
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 3px;
}
.rain-alert-card .ra-item { color: var(--rain-text); }
.rain-alert-card.no-rain .ra-item { color: var(--text-dim); }

/* ---------- Board / timeline ---------- */
.board-wrap {
  border: 1px solid var(--border);
  border-radius: 20px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.035);
  backdrop-filter: blur(14px);
}

.board-legend {
  display: flex;
  gap: 18px;
  padding: 10px 16px;
  font-size: 11.5px;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
}

.board-sync {
  display: flex;
  flex-direction: column;
}

/* 表头单独区域：与下方城市数据分离，避免 sticky 表头遮挡贵阳第一行 */
.board-head-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
  border-bottom: 1px solid var(--border);
}
.board-head-scroll::-webkit-scrollbar { display: none; }

.board-head {
  display: grid;
  grid-template-rows: var(--row-h-date) var(--row-h-hour);
}

.board-body-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}
.board-body-scroll::-webkit-scrollbar { height: 8px; }
.board-body-scroll::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 4px;
}
.board-body-scroll::-webkit-scrollbar-track { background: transparent; }

.board-body {
  display: grid;
  grid-template-rows: repeat(3, var(--row-h-temp) var(--row-h-rain));
}

.cell {
  display: flex;
  align-items: center;
  border-right: 1px solid rgba(255, 255, 255, 0.05);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  min-width: 0;
}

/* corner + sticky label column */
.sticky-left {
  position: sticky;
  left: 0;
  z-index: 5;
  background: rgba(16, 22, 48, 0.92);
  border-right: 1px solid var(--border);
}

.sticky-top {
  /* 表头已拆到独立区域，此处保留类名兼容，不再使用 sticky */
  background: rgba(16, 22, 48, 0.92);
}

.corner {
  z-index: 8;
}

/* row 1: date header */
.date-cell {
  justify-content: flex-start;
  padding: 0 10px;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-main);
  border-left: 1px solid rgba(255, 255, 255, 0.1);
}
.date-cell .date-hi-lo {
  font-size: 10.5px;
  font-weight: 500;
  color: var(--text-dim);
}

/* row 2: hour header */
.hour-cell {
  justify-content: center;
  font-size: 9.5px;
  color: var(--text-faint);
  font-weight: 500;
  border-right: 1px dashed rgba(255, 255, 255, 0.06);
}
.hour-cell.major {
  color: var(--text-dim);
  font-weight: 700;
}

/* city label cell (spans temp + rain rows) */
.city-label {
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 3px;
  padding: 0 12px;
  border-right: 1px solid var(--border);
}
.city-label .cl-name { font-size: 12.5px; font-weight: 700; display: flex; align-items: center; gap: 5px; }
.city-label .cl-name .dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.city-label .cl-now { display: flex; align-items: center; gap: 3px; font-size: 10.5px; color: var(--text-dim); }
.city-label .cl-now span.ic { font-size: 13px; }

/* temperature row cell */
.tcell {
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 1px;
  padding: 3px 1px;
  border-right: 1px dashed rgba(255, 255, 255, 0.05);
}
.tcell .ic { font-size: 16px; line-height: 1; }
.tcell .tp { font-size: 11.5px; font-weight: 600; letter-spacing: -0.3px; }

/* rain row cell: 苹果天气风格竖条 + 概率 */
.rcell {
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: 1px;
  padding: 2px 1px 4px;
  position: relative;
  border-right: 1px dashed rgba(255, 255, 255, 0.05);
}
.rcell .bar-track {
  width: 10px;
  height: 26px;
  display: flex;
  align-items: flex-end;
  border-radius: 2px;
  overflow: hidden;
  background:
    repeating-linear-gradient(
      180deg,
      transparent 0,
      transparent calc(25% - 0.5px),
      rgba(255, 255, 255, 0.07) calc(25% - 0.5px),
      rgba(255, 255, 255, 0.07) 25%
    );
}
.rcell .bar-fill {
  width: 100%;
  background: linear-gradient(180deg, var(--rain-bar), var(--rain-bar-deep));
  border-radius: 2px 2px 0 0;
  opacity: 0.92;
}
.rcell .rn-pop {
  font-size: 8px;
  color: var(--rain-text);
  font-weight: 600;
  line-height: 1;
  display: flex;
  align-items: center;
  gap: 1px;
}
.rcell .rn-pop::before {
  content: "💧";
  font-size: 7px;
  opacity: 0.7;
}
.rcell .rn-mm {
  font-size: 7px;
  color: var(--text-faint);
  line-height: 1;
}

/* 降雨强度：为该小时对应的 temp + rain 两格都加上背景提示，方便扫一眼避开 */
.rain-lvl-1 { background: var(--rain-1); }
.rain-lvl-2 { background: var(--rain-2); }
.rain-lvl-3 { background: var(--rain-3); }

.now-col {
  background: rgba(90, 200, 250, 0.1);
  box-shadow: inset 1px 0 0 rgba(90, 200, 250, 0.5), inset -1px 0 0 rgba(90, 200, 250, 0.5);
}
.now-col.hour-cell,
.now-col.date-cell {
  background: rgba(90, 200, 250, 0.16);
}
.now-col.rain-lvl-1 { background: color-mix(in srgb, var(--rain-1) 70%, rgba(90, 200, 250, 0.16)); }
.now-col.rain-lvl-2 { background: color-mix(in srgb, var(--rain-2) 70%, rgba(90, 200, 250, 0.16)); }
.now-col.rain-lvl-3 { background: color-mix(in srgb, var(--rain-3) 70%, rgba(90, 200, 250, 0.16)); }

/* 表头小圆点：提示该小时至少一座城市有明显降雨 */
.hour-cell { position: relative; }
.hour-cell .rain-dot {
  position: absolute;
  bottom: 2px;
  left: 50%;
  transform: translateX(-50%);
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--rain-bar);
}

/* ---------- Temperature trend chart ---------- */
.chart-section {
  margin-top: 20px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.035);
  backdrop-filter: blur(14px);
  padding: 16px 0 6px;
}

.chart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px 12px;
  flex-wrap: wrap;
  gap: 8px;
}
.chart-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}
.chart-legend {
  display: flex;
  gap: 14px;
  font-size: 12px;
  color: var(--text-dim);
}
.chart-legend .lg-item { display: flex; align-items: center; gap: 6px; }
.chart-legend .lg-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

.chart-wrap {
  display: flex;
  align-items: stretch;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.chart-axis {
  position: relative;
  width: var(--label-w);
  flex: 0 0 var(--label-w);
  background: rgba(16, 22, 48, 0.4);
  border-right: 1px solid var(--border);
}
.chart-axis .ax-label {
  position: absolute;
  right: 10px;
  transform: translateY(-50%);
  font-size: 10.5px;
  color: var(--text-faint);
}

.chart-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
  flex: 1 1 auto;
}
.chart-scroll::-webkit-scrollbar { height: 8px; }
.chart-scroll::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 4px;
}
.chart-scroll::-webkit-scrollbar-track { background: transparent; }

#tempChart { display: block; }

/* ---------- Footer ---------- */
.foot-note {
  margin-top: 16px;
  font-size: 11.5px;
  color: var(--text-faint);
  text-align: center;
  line-height: 1.6;
}
.foot-note a { color: var(--accent); text-decoration: none; }
.foot-note a:hover { text-decoration: underline; }

/* ---------- Loading overlay ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 12, 28, 0.72);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  z-index: 50;
  backdrop-filter: blur(6px);
  transition: opacity 0.25s ease;
}
.overlay.hidden { opacity: 0; pointer-events: none; }
.overlay p { color: var(--text-dim); font-size: 13px; margin: 0; }

.spinner {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.18);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error-box {
  background: rgba(255, 90, 90, 0.12);
  border: 1px solid rgba(255, 90, 90, 0.35);
  color: #ffb3b3;
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 13px;
  max-width: 420px;
  text-align: center;
}
