/* ==================== FONT ==================== */
@font-face {
  font-family: "Vazirmatn";
  src: url("fonts/Vazirmatn-VariableFont_wght.ttf") format("truetype-variations");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* ==================== TOKENS ==================== */
:root {
  --text: #eef3ff; --muted: #9aabc9;
  --card: rgba(255,255,255,.06); --card-2: rgba(255,255,255,.09);
  --border: rgba(255,255,255,.1); --accent: #5b8dff;
  --bg-1: #0b1220; --bg-2: #0e1930; --bg-3: #0b1220;
  --radius: 18px; --shadow: 0 8px 30px rgba(0,0,0,.25);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}
body[data-theme="clear-day"]   { --bg-1:#1b3d80; --bg-2:#2d6bd6; --bg-3:#6fa8ff; --text:#fff; --muted:#d7e4ff; --card:rgba(255,255,255,.12); --card-2:rgba(255,255,255,.18); --border:rgba(255,255,255,.22); }
body[data-theme="clear-night"] { --bg-1:#050816; --bg-2:#0b1a3a; --bg-3:#050816; --text:#e8eefc; --muted:#7f92b8; }
body[data-theme="cloudy-day"]  { --bg-1:#364152; --bg-2:#5a6b82; --bg-3:#8a9bb0; --text:#f1f5ff; --muted:#c5cfe1; }
body[data-theme="cloudy-night"]{ --bg-1:#0a1122; --bg-2:#1a2438; --bg-3:#0a1122; }
body[data-theme="cloudy"]      { --bg-1:#2a3345; --bg-2:#48546b; --bg-3:#6b7a94; }
body[data-theme="fog"]         { --bg-1:#4a5160; --bg-2:#6a7285; --bg-3:#8f97a8; --text:#f5f7fb; --muted:#d0d6e2; }
body[data-theme="drizzle"]     { --bg-1:#1c2739; --bg-2:#2f4258; --bg-3:#425973; }
body[data-theme="rain"]        { --bg-1:#0e1727; --bg-2:#1e3050; --bg-3:#2c4a6e; }
body[data-theme="snow"]        { --bg-1:#394a63; --bg-2:#6a7f9c; --bg-3:#a9bdd6; --text:#fff; --muted:#dfe8f5; }
body[data-theme="thunder"]     { --bg-1:#0a0f1e; --bg-2:#1b2140; --bg-3:#0a0f1e; }

/* ==================== BASE ==================== */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; min-height: 100vh;
  color: var(--text);
  font-family: "Vazirmatn", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
  -webkit-font-smoothing: antialiased;
}
body {
  background:
    radial-gradient(1200px 700px at 80% -10%, rgba(255,255,255,.08), transparent 60%),
    linear-gradient(160deg, var(--bg-1) 0%, var(--bg-2) 45%, var(--bg-3) 100%);
  background-attachment: fixed;
  transition: background 900ms ease, color 400ms ease;
  overflow-x: hidden;
  overscroll-behavior-y: contain;
}
body::before, body::after {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  transition: opacity 600ms ease;
}
body[data-theme="clear-night"]::before {
  opacity: 1;
  background-image:
    radial-gradient(1.2px 1.2px at 12% 18%, #ffffffcc, transparent 60%),
    radial-gradient(1px 1px at 28% 42%, #ffffffaa, transparent 60%),
    radial-gradient(1.4px 1.4px at 55% 12%, #ffffffcc, transparent 60%),
    radial-gradient(1px 1px at 72% 35%, #ffffffaa, transparent 60%),
    radial-gradient(1.2px 1.2px at 88% 22%, #ffffffcc, transparent 60%),
    radial-gradient(1px 1px at 40% 72%, #ffffff88, transparent 60%);
  animation: twinkle 4s ease-in-out infinite alternate;
}
@keyframes twinkle { from { opacity: .55; } to { opacity: 1; } }
body[data-theme="rain"]::before, body[data-theme="drizzle"]::before {
  opacity: .35;
  background: repeating-linear-gradient(105deg, transparent 0 22px, rgba(255,255,255,.07) 22px 23px);
  animation: rain-fall .6s linear infinite;
}
@keyframes rain-fall { from { background-position: 0 0; } to { background-position: -120px 120px; } }
body[data-theme="snow"]::before {
  opacity: .7;
  background-image:
    radial-gradient(2px 2px at 15% 10%, #ffffffcc, transparent 60%),
    radial-gradient(2px 2px at 42% 30%, #ffffffcc, transparent 60%),
    radial-gradient(2px 2px at 72% 14%, #ffffffcc, transparent 60%),
    radial-gradient(2px 2px at 88% 48%, #ffffffcc, transparent 60%);
  animation: snow-fall 7s linear infinite;
}
@keyframes snow-fall { from { transform: translateY(-8px); } to { transform: translateY(24px); } }
body[data-theme="fog"]::before {
  opacity: .35;
  background: radial-gradient(circle at 50% 40%, rgba(255,255,255,.35), transparent 60%);
}
body[data-theme="thunder"]::before {
  opacity: .15;
  background: radial-gradient(circle at 50% 20%, rgba(255,255,255,.4), transparent 55%);
  animation: flash 6s ease-in-out infinite;
}
@keyframes flash {
  0%,92%,100% { opacity: .12; } 94% { opacity: .5; } 96% { opacity: .12; } 98% { opacity: .6; }
}

/* ==================== APP ==================== */
.app {
  position: relative; z-index: 1;
  max-width: 720px; margin: 0 auto;
  padding:
    calc(16px + var(--safe-top))
    calc(16px + var(--safe-right))
    calc(20px + var(--safe-bottom))
    calc(16px + var(--safe-left));
}

/* ==================== BRAND ==================== */
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  margin-bottom: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.brand::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg,
    rgba(91,141,255,.16) 0%,
    transparent 45%,
    rgba(251,191,36,.10) 100%);
  pointer-events: none;
}
.brand__logo {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(91,141,255,.25), rgba(251,191,36,.18));
  border: 1px solid rgba(255,255,255,.15);
  color: #fff;
  position: relative;
  z-index: 1;
  box-shadow: 0 4px 14px rgba(91,141,255,.25);
}
.brand__logo svg { filter: drop-shadow(0 1px 3px rgba(0,0,0,.3)); }
.brand__text { flex: 1; min-width: 0; position: relative; z-index: 1; }
.brand__name {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
  line-height: 1.1;
  background: linear-gradient(90deg, #ffffff 0%, #c9d8ff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: #fff;
}
.brand__tagline {
  margin: 3px 0 0;
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}
.brand__meta {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--muted);
  padding: 4px 9px;
  border-radius: 20px;
  background: rgba(74,222,128,.12);
  border: 1px solid rgba(74,222,128,.25);
  position: relative;
  z-index: 1;
}
.brand__dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: #4ade80; box-shadow: 0 0 8px #4ade80;
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .4; } }

.topbar { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; }
.icon-btn {
  background: var(--card); backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border); color: var(--text);
  border-radius: 12px; padding: 10px 12px; font-family: inherit;
  font-size: 15px; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 44px; min-height: 44px;
  transition: transform 150ms ease, background 200ms ease, opacity 200ms ease;
}
.icon-btn:hover:not(:disabled) { background: var(--card-2); }
.icon-btn:active:not(:disabled) { transform: scale(.95); }
.icon-btn:disabled { opacity: .5; cursor: not-allowed; }

.search { position: relative; flex: 1; }
.search input {
  width: 100%; padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--card);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  color: var(--text); font-family: inherit;
  font-size: 16px;
  outline: none; min-height: 44px;
  transition: border-color 200ms ease;
}
.search input::placeholder { color: var(--muted); }
.search input:focus { border-color: var(--accent); }

.suggestions {
  position: absolute; top: calc(100% + 6px); right: 0; left: 0;
  margin: 0; padding: 6px; list-style: none;
  background: rgba(15,22,40,.94); backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border); border-radius: 12px;
  max-height: 300px; overflow-y: auto; z-index: 20; display: none;
  box-shadow: var(--shadow);
}
.suggestions.open { display: block; }
.suggestions li {
  padding: 10px 12px; border-radius: 8px; cursor: pointer;
  font-size: 14px; color: #eaf0fb;
  display: flex; align-items: center; gap: 8px;
  min-height: 44px;
}
.suggestions li:hover, .suggestions li.active { background: rgba(255,255,255,.08); }
.suggestions li .flag { font-size: 18px; }
.suggestions li .meta { color: #9aabc9; font-size: 12px; margin-right: auto; }
.suggestions .section-label {
  font-size: 11px; color: #7f92b8; padding: 8px 12px 4px;
  text-transform: uppercase; letter-spacing: .5px;
  cursor: default;
}
.suggestions .section-label:hover { background: none; }
.suggestions .empty { color: #9aabc9; padding: 12px; cursor: default; }
.suggestions .empty:hover { background: none; }

/* ==================== CITY TABS ==================== */
.city-tabs {
  display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 10px;
  scrollbar-width: none;
}
.city-tabs::-webkit-scrollbar { display: none; }
.city-tab {
  flex-shrink: 0; display: flex; align-items: center; gap: 8px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: 10px 14px; cursor: pointer;
  font-size: 13px; font-family: inherit; color: var(--text);
  transition: background 200ms ease, border-color 200ms ease, transform 150ms ease;
  user-select: none; -webkit-user-select: none;
  touch-action: manipulation;
  min-height: 40px;
}
.city-tab:hover { background: var(--card-2); }
.city-tab:active { transform: scale(.97); }
.city-tab.active { background: var(--card-2); border-color: var(--accent); }
.city-tab.menu-open { border-color: var(--accent); }
.city-tab .close {
  background: none; border: none; color: var(--muted); cursor: pointer;
  padding: 0; line-height: 1; display: inline-flex;
  width: 20px; height: 20px;
  align-items: center; justify-content: center;
  border-radius: 50%;
}
.city-tab .close:hover { color: #ef4444; background: rgba(239,68,68,.15); }
.city-tab--add { color: var(--accent); border-style: dashed; }
.city-tab--add:hover { background: rgba(91,141,255,.15); }

/* ==================== TAB CONTEXT MENU ==================== */
.tab-menu {
  position: fixed; z-index: 80; min-width: 190px;
  padding: 6px;
  background: rgba(15,22,40,.96);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0,0,0,.5);
  display: flex; flex-direction: column; gap: 2px;
  opacity: 0; transform: scale(.92) translateY(-6px);
  transition: opacity 180ms ease, transform 180ms cubic-bezier(.22,1,.36,1);
  transform-origin: top center;
}
.tab-menu.show { opacity: 1; transform: scale(1) translateY(0); }
.tab-menu button {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 10px 12px;
  background: none; border: none; border-radius: 8px;
  color: var(--text); font-family: inherit; font-size: 13px;
  cursor: pointer; text-align: right;
  transition: background 150ms ease;
  min-height: 44px;
}
.tab-menu button:hover:not(:disabled) { background: rgba(255,255,255,.08); }
.tab-menu button:disabled { opacity: .35; cursor: not-allowed; }
.tab-menu button svg { color: var(--muted); flex-shrink: 0; }
.tab-menu button.danger { color: #f87171; }
.tab-menu button.danger svg { color: #f87171; }
.tab-menu button.danger:hover:not(:disabled) { background: rgba(239,68,68,.15); }

/* ==================== PULL TO REFRESH ==================== */
.ptr {
  position: fixed;
  top: calc(12px + var(--safe-top));
  left: 50%; width: 42px; height: 42px;
  border-radius: 50%;
  background: rgba(15,22,40,.9);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  z-index: 60; pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -60px) scale(.7);
  transition: opacity 200ms ease, transform 200ms ease;
  will-change: transform, opacity;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
.ptr.ready { color: #4ade80; }
.ptr.refreshing svg { animation: ptr-spin 700ms linear infinite; }
@keyframes ptr-spin { to { transform: rotate(360deg); } }

/* ==================== CARDS ==================== */
.card {
  background: var(--card); backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 12px; font-size: 14px; font-weight: 500; color: var(--muted); }
.muted { color: var(--muted); font-size: 13px; margin: 2px 0 0; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.section-head h2 { margin: 0; }
.btn-ghost {
  background: var(--card-2); border: 1px solid var(--border);
  color: var(--text); border-radius: 8px; padding: 8px 14px;
  font-family: inherit; font-size: 12px; cursor: pointer;
  min-height: 36px;
}
.btn-ghost:hover { background: rgba(255,255,255,.14); }

/* ==================== HERO ==================== */
.hero__place h1 { margin: 0; font-size: 20px; font-weight: 700; }
.hero__now { display: flex; align-items: center; gap: 16px; margin-top: 14px; flex-wrap: wrap; }
.icon { display: flex; align-items: center; }
.wi { width: 28px; height: 28px; display: block; filter: drop-shadow(0 2px 6px rgba(0,0,0,.25)); }
.wi-lg { width: 72px; height: 72px; }
.wi-sm { width: 24px; height: 24px; }
.temp { font-size: 60px; font-weight: 800; line-height: 1; letter-spacing: -1px; }
.temp .unit { font-size: 26px; color: var(--muted); margin-right: 2px; font-weight: 500; }
.desc { display: flex; flex-direction: column; }
.desc p { margin: 0; }
.desc #desc { font-weight: 500; font-size: 15px; }
.updated { margin-top: 12px; font-size: 12px; display: flex; align-items: center; gap: 6px; }
.updated::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: #4ade80; box-shadow: 0 0 8px #4ade80;
  animation: pulse 2s ease-in-out infinite;
  flex-shrink: 0;
}
.updated.stale::before { background: #fbbf24; box-shadow: 0 0 8px #fbbf24; animation: none; }

/* ==================== STATS ==================== */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.stat {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 10px 6px; border-radius: 12px; background: var(--card-2);
}
.stat span { font-size: 12px; color: var(--muted); }
.stat b { font-size: 15px; font-weight: 600; }

/* ==================== CHART ==================== */
.chart-wrap { width: 100%; }
.chart-wrap svg { display: block; width: 100%; height: auto; }

/* ==================== AQI ==================== */
.aqi-status {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; background: rgba(239,68,68,.12);
  border: 1px solid rgba(239,68,68,.3); border-radius: 10px;
  font-size: 12px; color: #fca5a5; margin-bottom: 12px;
}
.aqi-row { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.aqi-badge {
  width: 72px; height: 72px; border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--card-2);
  border: 2px solid var(--aqi-color, #4ade80);
  color: var(--aqi-color, #4ade80);
  transition: border-color 400ms ease, color 400ms ease;
  flex-shrink: 0;
}
.aqi-badge span { font-size: 22px; font-weight: 700; line-height: 1; }
.aqi-badge small { font-size: 10px; opacity: .7; margin-top: 2px; }
.aqi-info { flex: 1; }
.aqi-label { margin: 0; font-weight: 600; font-size: 15px; }
.aqi-info .muted { margin-top: 4px; font-size: 12px; line-height: 1.5; }
.pollutants { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.pollutants .p {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 4px; background: var(--card-2); border-radius: 10px;
}
.pollutants .p span { font-size: 11px; color: var(--muted); }
.pollutants .p b { font-size: 13px; font-weight: 600; }

/* ==================== SUN ARC ==================== */
.sun-arc { margin-bottom: 18px; }
.sun-arc__track { position: relative; height: 6px; background: var(--card-2); border-radius: 6px; }
.sun-arc__fill {
  height: 100%; background: linear-gradient(90deg, #fbbf24, #f97316);
  border-radius: 6px; width: 0%; transition: width 700ms ease;
}
.sun-arc__dot {
  position: absolute; top: 50%; width: 14px; height: 14px;
  background: #fbbf24; border-radius: 50%;
  transform: translate(50%, -50%); box-shadow: 0 0 12px #fbbf24;
  transition: right 700ms ease; right: 0%;
}
.sun-arc__labels {
  display: flex; justify-content: space-between; margin-top: 10px;
  font-size: 12px; color: var(--muted); align-items: center;
}
.sun-arc__labels b { color: var(--text); font-weight: 600; }

/* ==================== UV ==================== */
.uv-row { display: flex; align-items: center; gap: 16px; }
.uv-meter { flex: 1; }
.uv-meter__bar {
  position: relative; height: 8px; border-radius: 8px;
  background: linear-gradient(90deg, #4ade80, #a3e635, #fbbf24, #f97316, #ef4444, #a855f7);
}
.uv-meter__marker {
  position: absolute; top: 50%; width: 14px; height: 14px;
  background: #fff; border: 2px solid var(--bg-1); border-radius: 50%;
  transform: translate(-50%, -50%); transition: right 700ms ease; right: 0%;
  box-shadow: 0 2px 6px rgba(0,0,0,.4);
}
.uv-meter__scale {
  display: flex; justify-content: space-between; margin-top: 6px;
  font-size: 11px; color: var(--muted);
}
.uv-value { text-align: center; min-width: 56px; }
.uv-value b { display: block; font-size: 22px; font-weight: 700; line-height: 1; }
.uv-value small { font-size: 11px; color: var(--muted); }
.moon-info {
  margin: 14px 0 0; padding-top: 12px; border-top: 1px solid var(--border);
  font-size: 13px; color: var(--muted);
}

/* ==================== WIND ==================== */
.wind-row { display: flex; align-items: center; gap: 16px; }
.wind-compass { width: 110px; flex-shrink: 0; color: var(--accent); }
.compass { width: 100%; height: auto; }
.compass-label { font-size: 8px; fill: var(--muted); font-family: inherit; }
#windArrow { transition: transform 700ms cubic-bezier(.22,1,.36,1); transform-origin: 50px 50px; }
.wind-details { flex: 1; }
.wind-main { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.wind-main b { font-size: 28px; font-weight: 700; }
.wind-details p { margin: 2px 0; font-size: 12px; }

/* ==================== HOURLY ==================== */
.hourly {
  display: flex; gap: 10px; overflow-x: auto; padding-bottom: 6px;
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
}
.hourly::-webkit-scrollbar { height: 6px; }
.hourly::-webkit-scrollbar-thumb { background: var(--border); border-radius: 6px; }
.hourly .h {
  min-width: 72px; text-align: center; padding: 12px 8px; border-radius: 12px;
  background: var(--card-2); display: flex; flex-direction: column;
  align-items: center; gap: 6px;
  transition: transform 200ms ease;
  scroll-snap-align: start;
}
.hourly .h:hover { transform: translateY(-2px); }
.hourly .h small { color: var(--muted); font-size: 12px; }
.hourly .h b { font-weight: 600; font-size: 14px; }
.hourly .h.now { border: 1px solid var(--accent); background: rgba(91,141,255,.12); }

/* ==================== DAILY ==================== */
.daily { display: flex; flex-direction: column; gap: 8px; }
.daily .d {
  display: grid; grid-template-columns: 76px 32px 1fr auto;
  align-items: center; gap: 10px; padding: 10px 12px;
  background: var(--card-2); border-radius: 12px; font-size: 14px;
}
.daily .d.today { border: 1px solid var(--accent); }
.daily .d .bar {
  height: 6px; border-radius: 6px;
  background: linear-gradient(90deg, #60a5fa, #fbbf24, #f97316);
  min-width: 20px; transition: margin 400ms ease;
}
.daily .d .range { color: var(--muted); font-size: 13px; font-weight: 500; }
.daily .d .day-name { font-weight: 500; }

/* ==================== RADAR ==================== */
.radar-map {
  width: 100%; height: 280px;
  border-radius: 14px; overflow: hidden;
  background: var(--card-2);
  margin-bottom: 12px; position: relative;
}
.radar-placeholder {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 8px; color: var(--muted); font-size: 12px;
  pointer-events: none;
}
.radar-placeholder svg { opacity: .5; }
.radar-map .leaflet-container { background: #0b1220; font-family: inherit; }
.radar-map .leaflet-control-attribution {
  background: rgba(0,0,0,.5) !important;
  color: #ccc !important; font-size: 9px !important;
}
.radar-map .leaflet-control-attribution a { color: #90b4ff !important; }
.radar-time { font-size: 12px; font-variant-numeric: tabular-nums; }
.radar-controls { display: flex; align-items: center; gap: 8px; }
.radar-controls .icon-btn { padding: 8px 10px; min-width: 40px; min-height: 40px; }
.radar-attribution { margin-right: auto; font-size: 10px; color: var(--muted); }
.radar-attribution a { color: var(--accent); text-decoration: none; }
.radar-attribution a:hover { text-decoration: underline; }

/* ==================== HISTORY ==================== */
.select-mini {
  background: var(--card-2); border: 1px solid var(--border);
  color: var(--text); border-radius: 8px; padding: 8px 10px;
  font-family: inherit; font-size: 12px; cursor: pointer; outline: none;
  min-height: 36px;
}
.select-mini option { background: #0d1526; color: #eef3ff; }
.history-stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 12px;
}
.history-stats .hs {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 10px 6px; background: var(--card-2); border-radius: 10px; text-align: center;
}
.history-stats .hs span { font-size: 11px; color: var(--muted); }
.history-stats .hs b { font-size: 14px; font-weight: 600; }

/* ==================== MODEL COMPARISON ==================== */
.model-legend { display: flex; gap: 12px; font-size: 11px; color: var(--muted); }
.legend-item { display: flex; align-items: center; gap: 5px; }
.legend-item i { width: 10px; height: 3px; border-radius: 2px; display: inline-block; }
.model-diff { text-align: center; margin-top: 8px; font-size: 12px; line-height: 1.6; }
.model-diff b { color: var(--text); font-weight: 600; }

/* ==================== REVEAL ==================== */
@keyframes reveal { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
.reveal { animation: reveal .55s cubic-bezier(.22,1,.36,1) both; }
.content .reveal:nth-child(1) { animation-delay: 0s; }
.content .reveal:nth-child(2) { animation-delay: .04s; }
.content .reveal:nth-child(3) { animation-delay: .08s; }
.content .reveal:nth-child(4) { animation-delay: .12s; }
.content .reveal:nth-child(5) { animation-delay: .16s; }
.content .reveal:nth-child(6) { animation-delay: .2s; }
.content .reveal:nth-child(7) { animation-delay: .24s; }
.content .reveal:nth-child(8) { animation-delay: .28s; }
.content .reveal:nth-child(9) { animation-delay: .32s; }
.content .reveal:nth-child(10) { animation-delay: .36s; }
.content .reveal:nth-child(11) { animation-delay: .4s; }
.content .reveal:nth-child(12) { animation-delay: .44s; }

/* ==================== STATE MACHINE ==================== */
.main > * { display: none; }
body[data-state="loading"] #skeleton { display: block; }
body[data-state="ready"]   #content  { display: block; }
body[data-state="error"]   #error    { display: flex; }
body[data-state="refreshing"] #content { display: block; opacity: .6; pointer-events: none; transition: opacity 200ms ease; }

/* ==================== SKELETON ==================== */
.skeleton { padding-top: 2px; }
.sk-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; margin-bottom: 14px;
  backdrop-filter: blur(10px);
}
.sk-line, .sk-block, .sk-circle {
  background: linear-gradient(90deg, rgba(255,255,255,.06), rgba(255,255,255,.14), rgba(255,255,255,.06));
  background-size: 200% 100%; animation: shimmer 1.4s ease-in-out infinite; border-radius: 10px;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.sk-line { height: 14px; margin-bottom: 10px; }
.sk-line:last-child { margin-bottom: 0; }
.sk-w40 { width: 40%; } .sk-w30 { width: 30%; } .sk-w25 { width: 25%; }
.sk-h40 { height: 44px; } .sk-h100 { height: 100px; }
.sk-block { height: 54px; border-radius: 12px; }
.sk-circle { width: 64px; height: 64px; border-radius: 50%; flex-shrink: 0; }
.sk-hero-row { display: flex; align-items: center; gap: 16px; margin-top: 14px; }
.sk-hero-row .sk-line { flex: 1; margin-bottom: 0; }
.sk-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.sk-stats .sk-block { height: 64px; }

/* ==================== ERROR ==================== */
.error-state {
  flex-direction: column; align-items: center; text-align: center;
  padding: 40px 20px; background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); backdrop-filter: blur(14px);
  animation: reveal .4s ease both;
}
.error-icon {
  width: 64px; height: 64px; display: flex; align-items: center; justify-content: center;
  border-radius: 50%; background: rgba(239,68,68,.15); color: #f87171; margin-bottom: 12px;
}
.error-state h3 { margin: 0 0 6px; font-size: 17px; font-weight: 600; }
.error-state p { margin: 0 0 16px; }
.btn-primary {
  background: var(--accent); color: #fff; border: none; border-radius: 12px;
  padding: 12px 22px; font-family: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: transform 150ms ease, filter 200ms ease, opacity 200ms ease;
  min-height: 44px;
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn-primary:active:not(:disabled) { transform: scale(.96); }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; }

/* ==================== PANELS ==================== */
.backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  z-index: 90; opacity: 0; transition: opacity 250ms ease;
}
.backdrop.show { opacity: 1; }
.panel {
  position: fixed; top: 0; bottom: 0; right: 0; width: min(380px, 90vw);
  background: #0d1526; border-left: 1px solid var(--border);
  z-index: 100; transform: translateX(100%);
  transition: transform 300ms cubic-bezier(.22,1,.36,1);
  display: flex; flex-direction: column; overflow: hidden;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}
.panel.show { transform: translateX(0); }
.panel__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px; border-bottom: 1px solid var(--border);
}
.panel__head h3 { margin: 0; font-size: 16px; font-weight: 600; }
.panel__body { padding: 16px; overflow-y: auto; flex: 1; }
.field { margin-bottom: 20px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.seg {
  display: flex; gap: 4px; padding: 4px;
  background: rgba(255,255,255,.04); border: 1px solid var(--border);
  border-radius: 12px;
}
.seg button {
  flex: 1; padding: 10px 8px; border: none; background: transparent;
  color: var(--text); font-family: inherit; font-size: 12px;
  border-radius: 8px; cursor: pointer; transition: background 200ms ease;
  min-height: 40px;
}
.seg button:hover { background: rgba(255,255,255,.06); }
.seg button.active { background: var(--accent); color: #fff; font-weight: 600; }
.btn-danger {
  width: 100%; padding: 12px; background: rgba(239,68,68,.15);
  color: #f87171; border: 1px solid rgba(239,68,68,.3);
  border-radius: 12px; font-family: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: background 200ms ease;
  min-height: 44px;
}
.btn-danger:hover { background: rgba(239,68,68,.25); }

.shortcuts-help ul {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: 6px;
  font-size: 12px; color: var(--muted);
}
.shortcuts-help li { display: flex; align-items: center; gap: 6px; }
.shortcuts-help kbd {
  display: inline-block; padding: 2px 6px;
  background: rgba(255,255,255,.08);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
  font-family: ui-monospace, monospace;
  font-size: 11px; color: var(--text);
  min-width: 20px; text-align: center;
}
.panel-footer {
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  margin: 24px 0 4px;
  opacity: 0.7;
}

/* ==================== FOOTER ==================== */
.site-footer {
  position: relative;
  margin-top: 40px;
  padding: 32px 20px 20px;
  background: linear-gradient(180deg,
    rgba(255,255,255,.04) 0%,
    rgba(255,255,255,.02) 60%,
    rgba(0,0,0,.15) 100%);
  border: 1px solid var(--border);
  border-radius: 24px;
  overflow: hidden;
  z-index: 1;
}
.footer__glow {
  position: absolute;
  top: -60px;
  left: 50%;
  transform: translateX(-50%);
  width: 60%;
  height: 120px;
  background: radial-gradient(ellipse at center,
    rgba(91,141,255,.22) 0%, transparent 70%);
  pointer-events: none;
  filter: blur(20px);
}

.footer__top {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: center;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 1;
}
.footer__brand { display: flex; align-items: center; gap: 14px; }
.footer__brand-logo {
  width: 52px; height: 52px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: 14px;
  background: linear-gradient(135deg,
    rgba(91,141,255,.28) 0%, rgba(251,191,36,.18) 100%);
  border: 1px solid rgba(255,255,255,.15);
  color: #fff;
  box-shadow: 0 6px 18px rgba(91,141,255,.25);
}
.footer__brand-logo svg { filter: drop-shadow(0 2px 4px rgba(0,0,0,.3)); }
.footer__brand-text h3 {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -.5px;
  background: linear-gradient(90deg, #fff 0%, #c9d8ff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.footer__brand-text p {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

.footer__newsletter { min-width: 0; }
.footer__newsletter-label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
  font-weight: 500;
}
.footer__newsletter-row {
  display: flex;
  gap: 8px;
  background: rgba(0,0,0,.25);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 4px;
  transition: border-color 200ms ease;
}
.footer__newsletter-row:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(91,141,255,.15);
}
.footer__newsletter-row input {
  flex: 1;
  min-width: 0;
  background: none;
  border: none;
  outline: none;
  padding: 8px 12px;
  color: var(--text);
  font-family: inherit;
  font-size: 16px;
}
.footer__newsletter-row input::placeholder { color: var(--muted); }
.footer__newsletter-row button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 150ms ease, filter 200ms ease;
  min-height: 36px;
  flex-shrink: 0;
}
.footer__newsletter-row button:hover { filter: brightness(1.1); }
.footer__newsletter-row button:active { transform: scale(.95); }
.footer__newsletter-note {
  font-size: 11px;
  margin: 6px 0 0;
  min-height: 14px;
  color: var(--muted);
  transition: color 200ms ease;
}
.footer__newsletter-note.ok { color: #4ade80; }
.footer__newsletter-note.err { color: #f87171; }

.footer__grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
  padding: 28px 0;
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 1;
}
.footer__col h4 {
  margin: 0 0 14px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: .3px;
}
.footer__col ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.footer__col a {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  transition: color 180ms ease, transform 180ms ease;
  padding: 2px 0;
}
.footer__col a:hover {
  color: var(--text);
  transform: translateX(-3px);
}
.footer__col a .ext {
  opacity: .5;
  transition: opacity 180ms ease;
}
.footer__col a:hover .ext { opacity: 1; }

.footer__bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 0 18px;
  flex-wrap: wrap;
  position: relative;
  z-index: 1;
}
.footer__social { display: flex; gap: 8px; }
.social-btn {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: var(--card-2);
  border: 1px solid var(--border);
  color: var(--muted);
  text-decoration: none;
  transition: transform 180ms ease, color 180ms ease,
              background 180ms ease, border-color 180ms ease;
}
.social-btn:hover {
  color: var(--text);
  background: rgba(91,141,255,.18);
  border-color: rgba(91,141,255,.4);
  transform: translateY(-2px);
}
.social-btn:active { transform: translateY(0) scale(.95); }

.footer__theme {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: rgba(0,0,0,.25);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.theme-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 11px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 180ms ease, color 180ms ease;
  min-height: 32px;
}
.theme-btn:hover { color: var(--text); background: rgba(255,255,255,.05); }
.theme-btn.active {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

.footer__totop {
  width: 42px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: var(--card-2);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  transition: transform 180ms ease, background 180ms ease, opacity 180ms ease;
  opacity: 0;
  pointer-events: none;
}
.footer__totop.visible {
  opacity: 1;
  pointer-events: auto;
}
.footer__totop:hover {
  background: rgba(91,141,255,.2);
  border-color: rgba(91,141,255,.4);
  transform: translateY(-3px);
}
.footer__totop:active { transform: translateY(0) scale(.95); }

.footer__legal {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
  position: relative;
  z-index: 1;
}
.footer__legal p {
  margin: 0;
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.6;
}
.footer__legal b { color: var(--text); font-weight: 700; }
.footer__made { display: inline-flex; align-items: center; gap: 5px; }
.footer__made .heart {
  color: #ef4444;
  animation: heart-beat 1.6s ease-in-out infinite;
  display: inline-block;
}
@keyframes heart-beat {
  0%, 100% { transform: scale(1); }
  20% { transform: scale(1.2); }
  40% { transform: scale(1); }
  60% { transform: scale(1.15); }
}

/* ==================== CONTACT MODAL ==================== */
.contact-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  transition: opacity 250ms ease;
}
.contact-modal.show { opacity: 1; }

.contact-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.contact-modal__panel {
  position: relative;
  width: 100%;
  max-width: 440px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  background: #0d1526;
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
  transform: scale(.92) translateY(10px);
  opacity: 0;
  transition: transform 300ms cubic-bezier(.22, 1, .36, 1),
              opacity 300ms ease;
  z-index: 1;
}
.contact-modal.show .contact-modal__panel {
  transform: scale(1) translateY(0);
  opacity: 1;
}

.contact-modal__head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: #0d1526;
  z-index: 2;
  border-radius: 20px 20px 0 0;
}
.contact-modal__icon {
  width: 46px;
  height: 46px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: linear-gradient(135deg,
    rgba(91, 141, 255, 0.25),
    rgba(251, 191, 36, 0.18));
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
}
.contact-modal__head > div:nth-child(2) {
  flex: 1;
  min-width: 0;
}
.contact-modal__head h3 {
  margin: 0 0 2px;
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
}
.contact-modal__head p {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}
.contact-modal__close {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: var(--card-2);
  border: 1px solid var(--border);
  color: var(--muted);
  cursor: pointer;
  transition: color 180ms ease, background 180ms ease, transform 150ms ease;
}
.contact-modal__close:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.3);
}
.contact-modal__close:active { transform: scale(.92); }

.contact-modal__body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.contact-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--card-2);
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  font-family: inherit;
  text-align: right;
  transition: transform 180ms ease,
              border-color 180ms ease,
              background 180ms ease;
  min-height: 60px;
  width: 100%;
}
.contact-item:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  background: rgba(91, 141, 255, 0.1);
}
.contact-item:active {
  transform: translateY(0) scale(.98);
}
.contact-item__icon {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
}
.contact-item__text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.contact-item__text small {
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
}
.contact-item__text b {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  word-break: break-all;
  font-variant-numeric: tabular-nums;
  letter-spacing: .3px;
}
.contact-item__action {
  flex-shrink: 0;
  color: var(--muted);
  opacity: .5;
  transition: opacity 180ms ease, transform 180ms ease;
}
.contact-item:hover .contact-item__action {
  opacity: 1;
  transform: translateX(-3px);
  color: var(--accent);
}

.contact-modal__foot {
  padding: 14px 20px 18px;
  border-top: 1px solid var(--border);
  text-align: center;
}
.contact-modal__foot p {
  margin: 0;
  font-size: 11.5px;
  color: var(--muted);
}

@media (max-width: 480px) {
  .contact-modal { padding: 12px; align-items: flex-end; }
  .contact-modal__panel {
    max-width: 100%;
    border-radius: 20px 20px 12px 12px;
    transform: translateY(30px);
  }
  .contact-modal.show .contact-modal__panel { transform: translateY(0); }
  .contact-modal__head { padding: 16px; }
  .contact-modal__body { padding: 14px; }
  .contact-item { padding: 12px 14px; min-height: 56px; }
  .contact-item__text b { font-size: 13px; }
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 720px) {
  .footer__top { grid-template-columns: 1fr; gap: 20px; }
  .footer__grid { grid-template-columns: repeat(2, 1fr); gap: 22px; }
}
@media (max-width: 420px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .sk-stats { grid-template-columns: repeat(2, 1fr); }
  .temp { font-size: 48px; }
  .wi-lg { width: 56px; height: 56px; }
  .daily .d { grid-template-columns: 64px 28px 1fr auto; gap: 8px; font-size: 13px; }
  .pollutants { grid-template-columns: repeat(2, 1fr); }
  .wind-row { flex-direction: column; text-align: center; }
  .radar-map { height: 220px; }
  .history-stats { grid-template-columns: repeat(2, 1fr); }

  .brand { padding: 12px 14px; gap: 10px; }
  .brand__logo { width: 40px; height: 40px; }
  .brand__logo svg { width: 28px; height: 28px; }
  .brand__name { font-size: 20px; }
  .brand__tagline { font-size: 11px; }
  .brand__meta { display: none; }
}
@media (max-width: 480px) {
  .site-footer { padding: 26px 16px 16px; border-radius: 20px; }
  .footer__brand-logo { width: 44px; height: 44px; }
  .footer__brand-text h3 { font-size: 19px; }
  .footer__brand-text p { font-size: 11px; }
  .footer__bottom { flex-direction: column; align-items: stretch; gap: 14px; }
  .footer__social { justify-content: center; }
  .footer__theme { justify-content: center; }
  .theme-btn span { display: none; }
  .theme-btn { min-width: 36px; justify-content: center; }
  .footer__totop { align-self: center; opacity: 1; pointer-events: auto; }
  .footer__legal { flex-direction: column; text-align: center; gap: 6px; }
}

/* ==================== REDUCED MOTION ==================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

/* ==================== SCROLLBAR ==================== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.2); }