:root {
  --fg: #fff;
  --fg-2: rgba(255,255,255,.78);
  --fg-3: rgba(255,255,255,.56);
  --card: rgba(255,255,255,.13);
  --card-brd: rgba(255,255,255,.18);
  --card-hover: rgba(255,255,255,.2);
  --pop: #1b2433;
  --radius: 20px;
  --font: ui-sans-serif, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --sky-a: #3a7bd5; --sky-b: #6fb1fc; --sky-c: #a8d4ff;
}

body[data-sky="clear-day"]    { --sky-a:#1f6fd1; --sky-b:#4fa3f7; --sky-c:#9fd2ff; }
body[data-sky="clear-night"]  { --sky-a:#070b22; --sky-b:#16204a; --sky-c:#2c3a72; }
body[data-sky="cloudy-day"]   { --sky-a:#4c6584; --sky-b:#7690ad; --sky-c:#a9bdd2; }
body[data-sky="cloudy-night"] { --sky-a:#11161f; --sky-b:#252e3d; --sky-c:#3b475b; }
body[data-sky="rain"]         { --sky-a:#273445; --sky-b:#3d5068; --sky-c:#5f7690; }
body[data-sky="storm"]        { --sky-a:#14131f; --sky-b:#2c2a40; --sky-c:#4a4566; }
body[data-sky="snow"]         { --sky-a:#5d7896; --sky-b:#8ea7c2; --sky-c:#cbd9e8; }
body[data-sky="fog"]          { --sky-a:#5a6470; --sky-b:#7f8994; --sky-c:#b2b9c0; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--fg);
  background: var(--sky-a);
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}
.sky {
  position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(1200px 700px at 85% -10%, rgba(255,255,255,.18), transparent 60%),
    linear-gradient(180deg, var(--sky-a) 0%, var(--sky-b) 55%, var(--sky-c) 100%);
  transition: background 1s ease;
}
a { color: inherit; }
button { font: inherit; color: inherit; }

/* ---------- top bar ---------- */
.topbar {
  max-width: 1120px; margin: 0 auto; padding: 18px 16px 10px;
  display: flex; align-items: center; gap: 14px;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 19px; text-decoration: none; letter-spacing: -.01em; white-space: nowrap; }
.search { position: relative; flex: 1; max-width: 520px; margin-left: auto; }
.search input {
  width: 100%; height: 44px; padding: 0 46px 0 40px;
  border-radius: 14px; border: 1px solid var(--card-brd);
  background: rgba(255,255,255,.16); color: var(--fg);
  font: inherit; font-size: 15px; outline: none;
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  transition: background .2s, border-color .2s;
}
.search input::placeholder { color: var(--fg-3); }
.search input:focus { background: rgba(255,255,255,.24); border-color: rgba(255,255,255,.45); }
.search input::-webkit-search-cancel-button { display: none; }
.search-ic { position: absolute; z-index: 1; left: 12px; top: 12px; width: 20px; height: 20px; color: var(--fg-2); pointer-events: none; }
.icon-btn {
  position: absolute; right: 4px; top: 4px; width: 36px; height: 36px;
  display: grid; place-items: center; border: 0; border-radius: 10px;
  background: transparent; cursor: pointer; color: var(--fg-2);
}
.icon-btn:hover { background: rgba(255,255,255,.16); color: var(--fg); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn.busy svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.results {
  position: absolute; left: 0; right: 0; top: 50px; z-index: 20;
  list-style: none; margin: 0; padding: 6px;
  background: #fff; color: var(--pop); border-radius: 14px;
  box-shadow: 0 18px 50px rgba(0,0,0,.28);
}
.results li {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 9px; cursor: pointer;
}
.results li[aria-selected="true"], .results li:hover { background: #eef3fb; }
.results .flag { font-size: 20px; width: 26px; text-align: center; }
.results .nm { font-weight: 600; }
.results .sub { color: #6b7686; font-size: 13px; }
.results .empty { color: #6b7686; cursor: default; }
.results .empty:hover { background: none; }

.units { display: flex; background: rgba(255,255,255,.14); border: 1px solid var(--card-brd); border-radius: 12px; padding: 3px; }
.units button { border: 0; background: transparent; padding: 6px 10px; border-radius: 9px; cursor: pointer; font-weight: 600; font-size: 14px; color: var(--fg-2); }
.units button[aria-pressed="true"] { background: rgba(255,255,255,.92); color: var(--pop); }

.recent { max-width: 1120px; margin: 0 auto; padding: 0 16px; display: flex; gap: 8px; flex-wrap: wrap; min-height: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 8px 6px 12px; border-radius: 999px; font-size: 13px;
  background: rgba(255,255,255,.12); border: 1px solid var(--card-brd); cursor: pointer;
}
.chip:hover { background: var(--card-hover); }
.chip .x { border: 0; background: none; cursor: pointer; color: var(--fg-3); padding: 0 2px; font-size: 15px; line-height: 1; }
.chip .x:hover { color: var(--fg); }
.chip.active { background: rgba(255,255,255,.28); }

/* ---------- layout ---------- */
main { max-width: 1120px; margin: 0 auto; padding: 14px 16px 8px; display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.card {
  background: var(--card); border: 1px solid var(--card-brd); border-radius: var(--radius);
  backdrop-filter: blur(18px) saturate(1.2); -webkit-backdrop-filter: blur(18px) saturate(1.2);
  padding: 18px 20px; min-width: 0;
}
.span-2 { grid-column: 1 / -1; }
.card h2 {
  margin: 0 0 12px; font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--fg-3);
  display: flex; align-items: center; gap: 6px;
}
.card h2 svg { width: 14px; height: 14px; }

/* hero */
.hero { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr auto; gap: 8px 24px; padding: 24px 28px; align-items: center; }
.hero .place { font-size: 26px; font-weight: 700; letter-spacing: -.01em; margin: 0; }
.hero .meta { color: var(--fg-2); font-size: 14px; margin-top: 2px; }
.hero .now { display: flex; align-items: center; gap: 12px; margin: 10px 0 4px; }
.hero .temp { font-size: clamp(72px, 13vw, 116px); font-weight: 250; line-height: 1; letter-spacing: -.04em; }
.hero .now svg { width: clamp(80px, 13vw, 120px); height: auto; filter: drop-shadow(0 6px 18px rgba(0,0,0,.18)); }
.hero .cond { font-size: 20px; font-weight: 500; }
.hero .hl { color: var(--fg-2); margin-top: 2px; }
.hero .summary {
  grid-column: 1 / -1; margin-top: 10px; padding-top: 14px; border-top: 1px solid var(--card-brd);
  color: var(--fg-2); font-size: 15px;
}
.hero .side { text-align: right; align-self: start; display: grid; gap: 6px; justify-items: end; }
.fav {
  border: 1px solid var(--card-brd); background: rgba(255,255,255,.1); border-radius: 10px;
  padding: 6px 10px; cursor: pointer; font-size: 13px; display: inline-flex; gap: 6px; align-items: center;
}
.fav:hover { background: var(--card-hover); }
.fav svg { width: 14px; height: 14px; }

/* hourly */
.hourly-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px 4px; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.3) transparent; }
.hourly { position: relative; }
.hourly svg.curve { display: block; overflow: visible; }
.hcols { display: flex; }
.hcol { width: 58px; flex: none; text-align: center; font-size: 13px; }
.hcol .t { color: var(--fg-2); }
.hcol.now .t { color: var(--fg); font-weight: 700; }
.hcol .ic { height: 34px; margin: 4px 0 2px; }
.hcol .ic svg { width: 34px; height: 34px; }
.hcol .p { color: #a9dcff; font-size: 12px; height: 16px; font-weight: 600; }
.curve .lbl { fill: #fff; font-size: 13px; font-weight: 600; text-anchor: middle; }

/* daily */
.days { list-style: none; margin: 0; padding: 0; }
.day {
  display: grid; grid-template-columns: 64px 34px 40px 36px 1fr 36px; align-items: center; gap: 8px;
  padding: 9px 0; border-top: 1px solid rgba(255,255,255,.12); font-size: 15px;
}
.day:first-child { border-top: 0; }
.day .dn { font-weight: 600; }
.day .ic svg { width: 32px; height: 32px; display: block; }
.day .p { color: #a9dcff; font-size: 12px; font-weight: 600; }
.day .lo { color: var(--fg-3); text-align: right; }
.day .hi { text-align: right; font-weight: 600; }
.bar { position: relative; height: 6px; border-radius: 6px; background: rgba(0,0,0,.18); }
.bar i { position: absolute; top: 0; bottom: 0; border-radius: 6px; }
.bar b { position: absolute; top: 50%; width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: 50%; background: #fff; border: 2px solid rgba(0,0,0,.25); }

/* tiles */
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; align-content: start; }
.tile { padding: 14px 16px; min-height: 128px; display: flex; flex-direction: column; }
.tile h2 { margin-bottom: 8px; }
.tile .v { font-size: 28px; font-weight: 500; letter-spacing: -.01em; line-height: 1.15; }
.tile .v small { font-size: 15px; color: var(--fg-2); font-weight: 400; margin-left: 2px; }
.tile .d { color: var(--fg-2); font-size: 13px; margin-top: auto; padding-top: 8px; }
.meter { height: 5px; border-radius: 5px; margin-top: 10px; position: relative; }
.meter b { position: absolute; top: 50%; width: 9px; height: 9px; margin: -4.5px 0 0 -4.5px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 2px rgba(0,0,0,.25); }
.meter.uv  { background: linear-gradient(90deg, #4ade80, #facc15 30%, #fb923c 55%, #ef4444 75%, #a855f7); }
.meter.aqi { background: linear-gradient(90deg, #50f0e6, #50ccaa 20%, #f0e641 40%, #ff5050 60%, #960032 80%, #7d2181); }
.wind { display: flex; align-items: center; gap: 12px; }
.compass { width: 46px; height: 46px; flex: none; }
.sunarc { width: 100%; height: 46px; margin-top: 4px; overflow: visible; }

/* states */
.msg { grid-column: 1 / -1; text-align: center; padding: 40px 20px; }
.msg h2 { justify-content: center; font-size: 14px; }
.msg button { margin-top: 12px; border: 0; background: #fff; color: var(--pop); padding: 9px 18px; border-radius: 10px; font-weight: 600; cursor: pointer; }
.skeleton { min-height: 230px; display: block; }
.sk { background: linear-gradient(90deg, rgba(255,255,255,.1), rgba(255,255,255,.22), rgba(255,255,255,.1)); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 10px; }
.sk-line { height: 18px; margin: 10px 0; }
.sk-big { height: 96px; width: 220px; margin: 16px 0; }
.w40 { width: 40%; } .w60 { width: 60%; }
@keyframes shimmer { to { background-position: -200% 0; } }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: rgba(20,24,34,.92); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,.3); z-index: 50; max-width: calc(100vw - 32px);
}

.foot { max-width: 1120px; margin: 0 auto; padding: 14px 16px 28px; color: var(--fg-3); font-size: 12px; text-align: center; }

@media (max-width: 820px) {
  main { grid-template-columns: minmax(0, 1fr); }
  .hero { padding: 20px; grid-template-columns: 1fr; }
  .hero .side { justify-items: start; text-align: left; grid-row: 3; }
}
@media (max-width: 560px) {
  .topbar { flex-wrap: wrap; gap: 10px; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
  .units { margin-left: auto; }
  .hero .place { font-size: 22px; }
  .day { grid-template-columns: 50px 30px 34px 32px 1fr 32px; gap: 6px; font-size: 14px; }
  .tile { min-height: 118px; padding: 12px 14px; }
  .tile .v { font-size: 24px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
