/* 天象 · 自适应布局：100% 正常显示，禁止横向撑破视口 */
:root {
  --ink: #e8f1f8;
  --muted: #9bb3c7;
  --line: rgba(232, 241, 248, 0.14);
  --card: rgba(12, 28, 44, 0.82);
  --accent: #5ec8ff;
  --accent-2: #ffc857;
  --danger: #ff7b72;
  --ok: #5ddea6;
  --warn: #f0b429;
  --radius: 12px;
  --pad: 12px;
  --max: 720px;
  --font: "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  margin: 0;
  width: 100%;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink);
  background: #061018;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

img, canvas, svg, video { max-width: 100%; height: auto; }

.sky {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(800px 400px at 20% 0%, rgba(94, 200, 255, 0.22), transparent 55%),
    linear-gradient(180deg, #0b1c2c 0%, #07131d 100%);
}

.top, .suggest, .status, main, .foot {
  width: 100%;
  max-width: var(--max);
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--pad);
  padding-right: var(--pad);
}

.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding-top: max(10px, env(safe-area-inset-top, 0px));
  padding-bottom: 4px;
}

.brand-mark {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  display: block;
  line-height: 1.2;
}
.brand-sub {
  display: none;
  color: var(--muted);
  font-size: 0.75rem;
}

.search {
  display: flex;
  gap: 6px;
  flex: 1 1 100%;
  min-width: 0;
  width: 100%;
}
.search input {
  flex: 1;
  min-width: 0;
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(8, 20, 32, 0.85);
  color: var(--ink);
  border-radius: 999px;
  padding: 9px 12px;
  font: inherit;
  font-size: 0.95rem;
  outline: none;
}
.search input:focus {
  border-color: rgba(94, 200, 255, 0.55);
}

.btn {
  border: 0;
  border-radius: 999px;
  padding: 9px 12px;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 650;
  cursor: pointer;
  background: linear-gradient(135deg, #5ec8ff, #3aa0e8);
  color: #041018;
  white-space: nowrap;
  flex-shrink: 0;
}
.btn.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}
.btn.sm { padding: 6px 10px; min-width: 36px; }

.suggest { padding-bottom: 0; }
.suggest-list {
  list-style: none;
  margin: 0;
  padding: 6px;
  background: #0f2436;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.suggest-list button {
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
}
.suggest-list button:hover { background: rgba(94, 200, 255, 0.12); }
.suggest-list small { color: var(--muted); margin-left: 6px; }

.status {
  color: var(--muted);
  font-size: 0.82rem;
  min-height: 1.2em;
  padding-top: 4px;
  padding-bottom: 4px;
}
.status.error { color: var(--danger); }

main {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 4px;
  padding-bottom: 20px;
}

.card {
  width: 100%;
  max-width: 100%;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  overflow: hidden;
}

.map-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.day-tabs, .map-actions, .chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  min-width: 0;
}
.tab, .chip, .btn, .hour, .day {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.tab, .chip {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink);
  border-radius: 999px;
  padding: 8px 12px;
  min-height: 36px;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}
.tab.active, .tab:hover, .chip.active, .chip:hover {
  border-color: rgba(94, 200, 255, 0.55);
  background: rgba(94, 200, 255, 0.14);
}
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  font-size: 0.8rem;
  cursor: pointer;
  user-select: none;
}

.map {
  width: 100%;
  height: 180px;
  max-width: 100%;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #0a1824;
  z-index: 0;
  touch-action: pan-x pan-y;
}
.map-hint {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.72rem;
}

.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background:
    linear-gradient(135deg, rgba(94, 200, 255, 0.12), transparent 55%),
    var(--card);
}
.hero-main { min-width: 0; flex: 1; }
.day-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(94, 200, 255, 0.16);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 650;
  margin-bottom: 4px;
}
.hero h1 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.meta {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.75rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.temp-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin-top: 6px;
}
.temp {
  font-size: 2.4rem;
  font-weight: 720;
  letter-spacing: -0.03em;
  line-height: 1;
}
.wcode { font-size: 0.95rem; font-weight: 600; }
.feels, .range { color: var(--muted); font-size: 0.8rem; margin-top: 2px; }
.hero-icon {
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 1.8rem;
  background: radial-gradient(circle at 35% 30%, rgba(255,255,255,.45), transparent 40%),
    rgba(94, 200, 255, 0.2);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  padding: 0;
  background: transparent;
  border: 0;
}
.metric {
  min-width: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
}
.metric .k { color: var(--muted); font-size: 0.7rem; }
.metric .v {
  font-size: 0.88rem;
  font-weight: 650;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sec-head { margin-bottom: 8px; }
.sec-head h2 { margin: 0; font-size: 0.95rem; }
.sec-head p { margin: 2px 0 0; color: var(--muted); font-size: 0.75rem; }

.chart-wrap {
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}
#hourlyChart {
  display: block;
  width: 100% !important;
  max-width: 100%;
  height: 120px;
}

.hourly-scroll {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 8px 0 2px;
  max-width: 100%;
}
.hour {
  flex: 0 0 64px;
  text-align: center;
  padding: 8px 4px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.04);
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.hour.active, .hour:hover {
  border-color: rgba(94, 200, 255, 0.5);
  background: rgba(94, 200, 255, 0.12);
}
.hour .h { color: var(--muted); font-size: 0.72rem; }
.hour .t { font-weight: 650; font-size: 0.9rem; }
.hour .p { color: var(--accent); font-size: 0.7rem; }
.hour .ico { font-size: 1.1rem; margin: 2px 0; }

.daily {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
}
.day {
  display: grid;
  grid-template-columns: 56px 28px minmax(0, 1fr) 52px 48px;
  gap: 6px;
  align-items: center;
  width: 100%;
  max-width: 100%;
  padding: 8px 4px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.day:nth-child(odd) { background: rgba(255, 255, 255, 0.03); }
.day.active, .day:hover {
  border-color: rgba(94, 200, 255, 0.5);
  background: rgba(94, 200, 255, 0.12);
}
.day .name { font-weight: 600; font-size: 0.88rem; }
.day .sub { color: var(--muted); font-size: 0.72rem; }
.bar {
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, #3aa0e8, #ffc857);
  max-width: 100%;
}
.day .hi { font-weight: 650; text-align: right; font-size: 0.88rem; }
.day .lo { color: var(--muted); text-align: right; font-size: 0.8rem; }
.day .rain { color: var(--accent); font-size: 0.72rem; text-align: right; line-height: 1.25; }

.split {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
.aqi-score {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 8px;
}
.aqi-score .n { font-size: 1.6rem; font-weight: 720; line-height: 1; }
.pollutants {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}
.pollutant {
  min-width: 0;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 8px;
  padding: 8px;
}
.pollutant .k { color: var(--muted); font-size: 0.7rem; }
.pollutant .v { font-weight: 650; font-size: 0.85rem; }

.sun-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.sun-item {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 10px;
  padding: 10px;
}
.sun-item .k { color: var(--muted); font-size: 0.75rem; }
.sun-item .v { font-size: 1rem; font-weight: 650; margin-top: 2px; }
.sun-track {
  margin-top: 10px;
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, #1a3550, #ffc857 45%, #5ec8ff 70%, #1a3550);
  position: relative;
}
.sun-track .dot {
  position: absolute;
  top: 50%;
  width: 12px;
  height: 12px;
  margin: -6px 0 0 -6px;
  border-radius: 50%;
  background: #fff;
}

.detail {
  margin-top: 8px;
  padding: 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.detail .k { color: var(--muted); font-size: 0.72rem; }
.detail .v { font-weight: 650; font-size: 0.88rem; }

.foot {
  color: var(--muted);
  font-size: 0.72rem;
  padding-bottom: 16px;
}
.foot a { color: var(--accent); }

.leaflet-container {
  width: 100% !important;
  height: 100% !important;
  background: #0a1824;
  font: inherit;
}
.leaflet-control-zoom a {
  background: #0f2436 !important;
  color: #e8f1f8 !important;
  border-color: rgba(232, 241, 248, 0.15) !important;
}

@media (min-width: 640px) {
  :root { --pad: 16px; }
  .brand-sub { display: block; }
  .search { flex: 1 1 280px; width: auto; max-width: 420px; }
  .map { height: 240px; }
  .metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .split { grid-template-columns: 1fr 1fr; }
  .detail { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .temp { font-size: 2.8rem; }
  .hero-icon { width: 64px; height: 64px; font-size: 2rem; }
}

@media (min-width: 900px) {
  :root { --max: 800px; }
  .map { height: 280px; }
}

@media (max-width: 380px) {
  .day { grid-template-columns: 48px 24px minmax(0, 1fr) 44px; }
  .day .rain { display: none; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .temp { font-size: 2.1rem; }
}
