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

html { height: 100%; }

body {
  margin: 0;
  min-height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--fg);
  background: var(--sky, #79b8f3);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: color .6s ease;
}

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

button, input { font-family: inherit; }

a { color: inherit; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.shell {
  --gutter: 18px;
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 0 var(--gutter);
}

/* ---------- topbar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 0 12px;
}

.topbar::before {
  content: "";
  position: absolute;
  inset: -14px 0 0;
  z-index: -1;
  pointer-events: none;
  background: linear-gradient(180deg, var(--card-bg), transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  mask-image: linear-gradient(180deg, #000 58%, transparent);
  -webkit-mask-image: linear-gradient(180deg, #000 58%, transparent);
}

.search {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 50px;
  padding: 0 18px;
  border-radius: 999px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  box-shadow: 0 12px 34px rgba(8, 26, 48, .12);
  backdrop-filter: blur(24px) saturate(1.5);
  -webkit-backdrop-filter: blur(24px) saturate(1.5);
  transition: background-color .4s ease, border-color .4s ease, box-shadow .2s ease;
}

.search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 12px 34px rgba(8, 26, 48, .12), 0 0 0 3px var(--accent-soft);
}

.search-ico {
  width: 17px;
  height: 17px;
  flex: none;
  color: var(--muted);
}

.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--fg);
  font-size: 15px;
}

.search input::placeholder { color: var(--muted); }
.search input:focus-visible { outline: none; }

.search-results {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  right: 0;
  display: none;
  max-height: 336px;
  overflow-y: auto;
  padding: 6px;
  border-radius: 22px;
  background: var(--panel);
  border: 1px solid var(--card-border);
  box-shadow: 0 28px 60px rgba(6, 20, 38, .26);
  backdrop-filter: blur(26px);
  -webkit-backdrop-filter: blur(26px);
}

.search-results.open { display: block; }

.search-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 12px 15px;
  border: 0;
  border-radius: 15px;
  background: transparent;
  color: var(--fg);
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}

.search-item:hover,
.search-item.active { background: var(--item-hover); }

.search-item b { font-weight: 600; }

.search-item span {
  max-width: 48%;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-empty {
  padding: 14px 15px;
  color: var(--muted);
  font-size: 13.5px;
}

.icon-btn {
  width: 50px;
  height: 50px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--card-border);
  background: var(--card-bg);
  color: var(--fg);
  cursor: pointer;
  box-shadow: 0 12px 34px rgba(8, 26, 48, .1);
  backdrop-filter: blur(24px) saturate(1.5);
  -webkit-backdrop-filter: blur(24px) saturate(1.5);
  transition: background-color .2s ease, transform .15s ease;
}

.icon-btn:hover { background: var(--card-hover); }
.icon-btn:active { transform: scale(.94); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn.spin svg { animation: spin 1s linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- layout ---------- */

.main {
  display: flex;
  flex-direction: column;
}

/* ---------- hero ---------- */

.hero {
  padding: clamp(28px, 6vw, 54px) 0 0;
  text-align: center;
  animation: rise .6s cubic-bezier(.2, .7, .3, 1) both;
}

.hero-head {
  position: relative;
}

.city {
  margin: 0;
  font-size: clamp(23px, 4.6vw, 30px);
  font-weight: 600;
  letter-spacing: .02em;
  line-height: 1.25;
  word-break: break-word;
  text-shadow: var(--hero-shadow, none);
}

.geo-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--chip-bg);
  border: 1px solid var(--chip-border);
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .5px;
  vertical-align: middle;
  text-shadow: none;
}

.updated {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  text-shadow: var(--hero-shadow, none);
}

.hero-main {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(16px, 4vw, 32px);
  margin: clamp(18px, 4vw, 30px) 0 10px;
}

.temp {
  font-size: clamp(92px, 24vw, 150px);
  font-weight: 200;
  line-height: .82;
  letter-spacing: -.06em;
  font-variant-numeric: tabular-nums;
  text-shadow: var(--hero-shadow, none);
}

.temp .deg {
  display: inline-block;
  margin-left: 2px;
  font-size: .32em;
  font-weight: 300;
  letter-spacing: 0;
  vertical-align: top;
  transform: translateY(.12em);
}

.hero-weather {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.hero-weather svg {
  width: clamp(64px, 15vw, 88px);
  height: clamp(64px, 15vw, 88px);
  color: var(--fg);
  filter: drop-shadow(0 12px 26px rgba(6, 24, 44, .24));
}

.hero-weather p {
  margin: 0;
  font-size: clamp(15px, 3.5vw, 18px);
  font-weight: 600;
  letter-spacing: .06em;
  text-shadow: var(--hero-shadow, none);
}

.hero-range {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  text-shadow: var(--hero-shadow, none);
}

.hero-range .dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: currentColor;
  opacity: .6;
}

.sun-row {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 22px;
  color: var(--muted);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  text-shadow: var(--hero-shadow, none);
}

.sun-row span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 18px;
}

.sun-row span + span { border-left: 1px solid var(--divider); }

.sun-row svg {
  width: 16px;
  height: 16px;
  color: var(--accent);
}

/* ---------- bottom sheet ---------- */

.sheet {
  position: relative;
  margin: clamp(28px, 6vw, 48px) calc(var(--gutter) * -1) 0;
  padding: 14px var(--gutter) calc(28px + env(safe-area-inset-bottom, 0px));
  border-radius: 34px 34px 0 0;
  border: 1px solid var(--sheet-border);
  border-bottom: 0;
  background: var(--sheet-bg);
  box-shadow: var(--sheet-shadow);
  backdrop-filter: blur(30px) saturate(1.4);
  -webkit-backdrop-filter: blur(30px) saturate(1.4);
  animation: sheetRise .72s cubic-bezier(.2, .8, .2, 1) both;
}

.sheet-grip {
  width: 42px;
  height: 5px;
  margin: 0 auto 16px;
  border-radius: 999px;
  background: var(--divider);
}

.sheet-block + .sheet-block {
  margin-top: 8px;
  padding-top: 22px;
  border-top: 1px solid var(--divider);
}

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.card-head h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .04em;
}

.card-head span {
  color: var(--muted);
  font-size: 11.5px;
}

.empty-note {
  margin: 0;
  padding: 6px 0 10px;
  color: var(--muted);
  font-size: 13px;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

@keyframes sheetRise {
  from { opacity: 0; transform: translateY(34px); }
  to { opacity: 1; transform: none; }
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .sheet, .search, .icon-btn, .search-results, .hero-error { background: var(--panel); }
}

/* ---------- metrics ---------- */

.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.metric {
  min-width: 0;
  padding: 15px 18px;
  border-left: 1px solid var(--divider);
  border-top: 1px solid var(--divider);
}

.metric:nth-child(3n + 1) { border-left: 0; }
.metric:nth-child(-n + 3) { border-top: 0; }

.metric-label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 11.5px;
  letter-spacing: .04em;
  white-space: nowrap;
}

.metric-label svg {
  width: 14px;
  height: 14px;
  flex: none;
  color: var(--accent);
}

.metric strong {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 8px;
  overflow: hidden;
  color: var(--fg);
  font-size: 20px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric em {
  display: block;
  margin-top: 4px;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric-wind strong { font-size: 16px; }

.aqi-dot {
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: 50%;
  background: var(--aqi-color, #3bb273);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--aqi-color, #3bb273) 22%, transparent);
}

/* ---------- hourly strip ---------- */

.hourly-wrap {
  position: relative;
}

.hourly-nav {
  display: none;
  flex: none;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--accent-border);
  background: var(--accent-soft);
  color: var(--accent);
  cursor: pointer;
  transition: background-color .2s ease, opacity .2s ease;
}

.hourly-nav:hover:not(:disabled) { background: var(--chip-bg); }
.hourly-nav:disabled { opacity: .28; cursor: default; }
.hourly-nav svg { width: 18px; height: 18px; }

.hourly-scroll {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  overflow-y: hidden;
  margin: 0 calc(var(--gutter) * -1);
  padding: 0 var(--gutter) 6px;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 28px), transparent 100%);
  -webkit-mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 28px), transparent 100%);
}

.hourly-scroll::-webkit-scrollbar { display: none; }

.hour-item {
  flex: 0 0 auto;
  min-width: 66px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 14px 8px;
  border-radius: 20px;
  text-align: center;
  scroll-snap-align: start;
}

.hour-item.now {
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent-border);
}

.hour-time {
  color: var(--muted);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}

.hour-item.now .hour-time {
  color: var(--accent);
  font-weight: 600;
}

.hour-icon {
  width: 28px;
  height: 28px;
  color: var(--fg);
}

.hour-temp {
  font-size: 17px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.hour-item.now .hour-temp { color: var(--accent); }

/* ---------- daily ---------- */

.daily-list {
  display: flex;
  flex-direction: column;
}

.day-row {
  display: grid;
  grid-template-columns: 78px 30px 64px minmax(130px, 1fr);
  align-items: center;
  gap: 14px;
  padding: 14px 2px;
  border-top: 1px solid var(--divider);
}

.day-row:first-child { border-top: 0; }
.day-row.today .day-name b { color: var(--accent); }

.day-name {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.day-name b {
  font-size: 14.5px;
  font-weight: 600;
  white-space: nowrap;
}

.day-name em {
  color: var(--muted);
  font-size: 11.5px;
  font-style: normal;
  font-variant-numeric: tabular-nums;
}

.day-icon svg {
  display: block;
  width: 28px;
  height: 28px;
  color: var(--fg);
}

.day-cond {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.day-range {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.day-range .lo,
.day-range .hi {
  min-width: 28px;
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.day-range .lo { color: var(--muted); }
.day-range .hi { color: var(--fg); font-weight: 600; }

.bar {
  position: relative;
  flex: 1;
  min-width: 40px;
  height: 5px;
  border-radius: 999px;
  background: var(--divider);
  overflow: hidden;
}

.bar i {
  position: absolute;
  top: 0;
  bottom: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #59b7f5, #f6c445, #f0854a);
}

/* ---------- states ---------- */

.hero-error {
  padding: 38px 24px 34px;
  border-radius: 30px;
  background: var(--sheet-bg);
  border: 1px solid var(--sheet-border);
  box-shadow: var(--sheet-shadow);
  backdrop-filter: blur(30px) saturate(1.4);
  -webkit-backdrop-filter: blur(30px) saturate(1.4);
}

.hero-error .city { font-size: 24px; }

.error-msg {
  margin: 10px 0 20px;
  color: var(--muted);
  font-size: 14px;
}

.error-hint {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.6;
}

.btn {
  min-height: 44px;
  padding: 10px 28px;
  border-radius: 999px;
  border: 1px solid var(--accent-border);
  background: var(--accent-soft);
  color: var(--fg);
  font-size: 14.5px;
  cursor: pointer;
  transition: background-color .2s ease;
}

.btn:hover { background: var(--item-hover); }

.sk {
  display: block;
  position: relative;
  overflow: hidden;
  border-radius: 10px;
  background: var(--sk-base);
}

#heroCard .sk {
  margin-left: auto;
  margin-right: auto;
}

.sk-note {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 12.5px;
  letter-spacing: .4px;
  text-shadow: var(--hero-shadow, none);
}

.sk::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .3), transparent);
  animation: shimmer 1.4s infinite;
}

@keyframes shimmer {
  from { transform: translateX(-100%); }
  to { transform: translateX(100%); }
}

/* ---------- footer / overlays ---------- */

.foot {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 26px;
  padding: 18px 2px 0;
  border-top: 1px solid var(--divider);
  color: var(--muted);
  font-size: 11.5px;
}

.foot-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 6px 18px;
}

.foot a { color: var(--fg); text-decoration: none; border-bottom: 1px solid currentColor; }

.friend-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 16px;
  line-height: 1.7;
}

.friend-links a {
  color: var(--muted);
  border-bottom: 0;
}

.friend-links a:hover { color: var(--fg); }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(28px + env(safe-area-inset-bottom, 0px));
  z-index: 50;
  max-width: calc(100vw - 40px);
  padding: 11px 18px;
  border-radius: 14px;
  background: rgba(14, 26, 42, .92);
  color: #fff;
  font-size: 13.5px;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 14px);
  transition: opacity .25s ease, transform .25s ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.progress {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 60;
  width: 0;
  height: 3px;
  background: var(--accent);
  opacity: 0;
  transition: opacity .3s ease;
}

.progress.on {
  opacity: 1;
  animation: progress 1.6s ease-in-out infinite;
}

@keyframes progress {
  0% { width: 6%; }
  55% { width: 68%; }
  100% { width: 92%; }
}

.noscript {
  position: fixed;
  left: 50%;
  top: 22px;
  z-index: 99;
  transform: translateX(-50%);
  padding: 12px 18px;
  border-radius: 14px;
  background: rgba(14, 26, 42, .92);
  color: #fff;
  font-size: 14px;
}

/* ---------- responsive ---------- */

@media (max-width: 560px) {
  .shell { --gutter: 13px; }
  .topbar { gap: 8px; padding: 11px 0 10px; }
  .search { height: 46px; padding: 0 15px; }
  .icon-btn { width: 46px; height: 46px; }

  .hero { padding-top: 24px; }
  .hero-main { margin-top: 16px; }
  .updated { font-size: 11.5px; }
  .sun-row { margin-top: 18px; font-size: 12px; }
  .sun-row span { padding: 0 14px; }

  .sheet {
    margin-top: 24px;
    padding-top: 12px;
    border-radius: 30px 30px 0 0;
  }

  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric { padding: 13px 14px; }
  .metric:nth-child(3n + 1) { border-left: 1px solid var(--divider); }
  .metric:nth-child(2n + 1) { border-left: 0; }
  .metric:nth-child(-n + 3) { border-top: 1px solid var(--divider); }
  .metric:nth-child(-n + 2) { border-top: 0; }
  .metric strong { font-size: 18px; margin-top: 6px; }

  .hour-item { min-width: 62px; padding: 12px 7px; border-radius: 18px; }
  .hour-icon { width: 26px; height: 26px; }

  .day-row {
    grid-template-columns: 62px 28px minmax(110px, 1fr);
    gap: 12px;
    padding: 12px 0;
  }
  .day-cond { display: none; }
  .day-icon svg { width: 25px; height: 25px; }
  .day-name b { font-size: 13.5px; }
  .day-range .lo, .day-range .hi { min-width: 26px; font-size: 13px; }

  .foot-meta { justify-content: center; text-align: center; }
}

@media (max-width: 360px) {
  .search input { font-size: 14px; }
  .day-row { grid-template-columns: 56px 25px minmax(100px, 1fr); gap: 9px; }
  .hour-item { min-width: 58px; }
}

@media (min-width: 900px) {
  .shell {
    --gutter: 26px;
    max-width: 790px;
    padding-bottom: 56px;
  }

  .hero { padding-top: 42px; }

  .sheet {
    max-width: 720px;
    margin: clamp(36px, 6vh, 56px) auto 0;
    padding: 16px 30px 32px;
    border-radius: 36px;
    border-bottom: 1px solid var(--sheet-border);
  }

  .hourly-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .hourly-wrap .hourly-scroll {
    flex: 1;
    min-width: 0;
    margin: 0;
    padding: 0 6px 6px;
    mask-image: none;
    -webkit-mask-image: none;
  }

  .hourly-nav { display: grid; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
  .fx { display: none; }
  .sk::after { display: none; }
}
