.weather-page {
  min-height: 100vh;
  background: var(--bg-color);
  color: var(--text-color);
  padding: 32px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", Roboto, sans-serif;
}

.weather-wrap { max-width: 1120px; margin: 0 auto; display: grid; gap: 18px; }

.weather-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.weather-header-left{
  display:flex;
  align-items:center;
  gap:14px;
  flex-wrap:wrap;
}

.weather-header-right{
  display:flex;
  align-items:center;
  gap:10px;
  flex-wrap:wrap;
}

.back-home{
  text-decoration:none;
  white-space:nowrap;
}

.weather-header h1 {
  margin: 0 0 6px;
  font-size: clamp(28px, 3vw, 40px);
  letter-spacing: -0.02em;
  color: var(--text-color);
}
.weather-header p { margin: 0; color: var(--secondary-text); }

.weather-panel {
  border-radius: var(--radius-xl);
  border: 1px solid color-mix(in srgb, var(--border-color) 70%, transparent);
  background: color-mix(in srgb, var(--content-bg) 40%, var(--bg-color));
  box-shadow: 0 18px 50px color-mix(in srgb, var(--shadow-color) 65%, transparent);
  padding: 18px;
}

.weather-controls { display: grid; gap: 12px; }

.weather-search { display: flex; gap: 10px; flex-wrap: wrap; }
.weather-search input {
  flex: 1;
  min-width: 240px;
  padding: 12px 12px;
  border-radius: var(--radius-md);
  border: 1px solid color-mix(in srgb, var(--border-color) 70%, transparent);
  background: color-mix(in srgb, var(--bg-color) 70%, #ffffff 2%);
  color: var(--text-color);
  outline: none;
}
.weather-search input::placeholder {
  color: color-mix(in srgb, var(--secondary-text) 85%, transparent);
}

.weather-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.btn {
  border: 1px solid color-mix(in srgb, var(--border-color) 75%, transparent);
  background: color-mix(in srgb, var(--bg-color) 60%, #ffffff 3%);
  color: var(--text-color);
  padding: 11px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: transform var(--transition-fast), background var(--transition-fast), border-color var(--transition-fast);
}
.btn:hover {
  border-color: color-mix(in srgb, var(--accent-color) 55%, var(--border-color));
  transform: translateY(-1px);
}
.btn.primary { background: var(--accent-color); color: #fff; border-color: transparent; }
.btn.primary:hover { background: var(--hover-color); }
.btn.ghost { background: transparent; }

.unit-pill{
  padding: 9px 12px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--border-color) 70%, transparent);
  background: color-mix(in srgb, var(--bg-color) 70%, #ffffff 2%);
  color: var(--secondary-text);
  font-size: 13px;
}

.weather-status { min-height: 22px; margin-top: 6px; color: var(--secondary-text); }

.weather-grid { margin-top: 12px; display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 920px) {
  .weather-grid { grid-template-columns: 1.1fr 0.9fr; align-items: start; }
  .weather-card.full { grid-column: 1 / -1; }
}

.weather-card {
  border-radius: var(--radius-lg);
  border: 1px solid color-mix(in srgb, var(--border-color) 70%, transparent);
  background: color-mix(in srgb, var(--content-bg) 40%, var(--bg-color));
  box-shadow: 0 12px 32px color-mix(in srgb, var(--shadow-color) 55%, transparent);
  padding: 16px;
  overflow: hidden;
}

.card-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.place { font-weight: 650; font-size: 18px; color: var(--text-color); }
.meta  { margin-top: 2px; font-size: 13px; color: var(--secondary-text); }
.icon { width: 64px; height: 64px; }

.temp-row { display: flex; align-items: baseline; gap: 14px; margin: 10px 0 6px; }
.temp { font-size: 54px; font-weight: 800; line-height: 1; color: var(--text-color); }
.feels{ color: var(--secondary-text); }

.explain{
  margin: 2px 0 10px;
  color: var(--secondary-text);
  font-size: 13px;
}

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid color-mix(in srgb, var(--border-color) 70%, transparent);
  background: color-mix(in srgb, var(--bg-color) 70%, #ffffff 2%);
}
.stat .k { color: var(--secondary-text); }
.stat .v { font-weight: 650; color: var(--text-color); }

.extras { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.pill {
  padding: 9px 12px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--border-color) 70%, transparent);
  background: color-mix(in srgb, var(--bg-color) 70%, #ffffff 2%);
  color: var(--secondary-text);
  font-size: 13px;
}

.card-title { font-weight: 750; color: var(--text-color); margin-bottom: 10px; }

.forecast { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (min-width: 520px){ .forecast{ grid-template-columns: repeat(4, 1fr); } }

.hour {
  text-align: center;
  padding: 10px;
  border-radius: var(--radius-md);
  border: 1px solid color-mix(in srgb, var(--border-color) 70%, transparent);
  background: color-mix(in srgb, var(--bg-color) 70%, #ffffff 2%);
}
.hour .h { font-size: 12px; color: var(--secondary-text); }
.hour .t { margin-top: 6px; font-weight: 800; color: var(--text-color); }
.hour img { width: 42px; height: 42px; }

.daily { display: grid; gap: 10px; }
.day {
  display: grid;
  grid-template-columns: 110px 1fr 160px;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid color-mix(in srgb, var(--border-color) 70%, transparent);
  background: color-mix(in srgb, var(--bg-color) 70%, #ffffff 2%);
}
@media (max-width: 560px){ .day{ grid-template-columns: 1fr; } }
.day .name { font-weight: 750; color: var(--text-color); }
.day .desc { color: var(--secondary-text); font-size: 13px; }
.day .range { justify-self: end; font-weight: 750; color: var(--text-color); }

.aqi-row{ display:flex; gap:10px; align-items:center; margin-bottom:10px; flex-wrap:wrap; }
.aqi-badge{
  padding: 9px 12px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--border-color) 70%, transparent);
  background: color-mix(in srgb, var(--bg-color) 70%, #ffffff 2%);
  font-weight: 750;
}
.aqi-text{ color: var(--secondary-text); }
.tiny-note{ margin-top:10px; color: var(--secondary-text); font-size: 12px; }

.foot { margin-top: 14px; color: var(--secondary-text); font-size: 13px; }

/* Map */
.map { height: 420px; border-radius: var(--radius-lg); overflow: hidden; }
.mapbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 10px;
}
.mapbar select, .modal-body select,
.compare-controls input, .favorites select {
  padding: 10px 10px;
  border-radius: var(--radius-md);
  border: 1px solid color-mix(in srgb, var(--border-color) 70%, transparent);
  background: color-mix(in srgb, var(--bg-color) 70%, #ffffff 2%);
  color: var(--text-color);
}

/* 1) Alerts + 13) Greeting + 14) Offline */
.banner{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:12px;
  padding: 12px 14px;
  border-radius: var(--radius-lg);
  border: 1px solid color-mix(in srgb, var(--border-color) 70%, transparent);
  background: color-mix(in srgb, var(--accent-color) 15%, var(--bg-color));
}
.banner.subtle{
  background: color-mix(in srgb, var(--content-bg) 55%, var(--bg-color));
}
.banner-left{ display:grid; gap:4px; }
.banner-title{ font-weight: 800; color: var(--text-color); }
.banner-text{ color: var(--secondary-text); }

/* 5) Favorites */
.favorites{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  flex-wrap:wrap;
  margin: 12px 0 6px;
  padding: 12px;
  border-radius: var(--radius-lg);
  border: 1px solid color-mix(in srgb, var(--border-color) 60%, transparent);
  background: color-mix(in srgb, var(--content-bg) 45%, var(--bg-color));
}
.favorites-left, .favorites-right{
  display:flex;
  gap:10px;
  align-items:center;
  flex-wrap:wrap;
}
.favorites-title{ font-weight: 800; color: var(--text-color); }

/* 2) Impact pills */
.impact{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  margin-top: 12px;
}
.impact .pill{
  border-radius: 999px;
}

/* 3) UV */
.uv-row{ display:flex; gap:12px; align-items:center; }
.uv-big{ font-size: 44px; font-weight: 900; color: var(--text-color); }
.uv-desc{ color: var(--secondary-text); }

/* 7) Sun bar */
.sunbar{ margin-top: 14px; }
.sunbar-row{
  display:flex;
  justify-content:space-between;
  color: var(--secondary-text);
  font-size: 12px;
  margin-bottom: 8px;
}
.sunbar-track{
  position: relative;
  height: 10px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--border-color) 60%, transparent);
  background: color-mix(in srgb, var(--bg-color) 75%, #ffffff 1%);
  overflow: hidden;
}
.sunbar-fill{
  position:absolute;
  height:100%;
  left:0; top:0;
  width: 0%;
  background: color-mix(in srgb, var(--accent-color) 55%, transparent);
}
.sunbar-dot{
  position:absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent-color);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent-color) 20%, transparent);
  left: 0%;
}

/* 10) Compare */
.compare-controls{
  display:grid;
  grid-template-columns: 1fr 1fr auto;
  gap:10px;
}
@media (max-width: 760px){
  .compare-controls{ grid-template-columns: 1fr; }
}
.compare-grid{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}
@media (max-width: 760px){
  .compare-grid{ grid-template-columns: 1fr; }
}
.compare-box{
  border-radius: var(--radius-lg);
  border: 1px solid color-mix(in srgb, var(--border-color) 60%, transparent);
  background: color-mix(in srgb, var(--bg-color) 72%, #ffffff 1%);
  padding: 12px;
}
.compare-title{ font-weight: 900; color: var(--text-color); margin-bottom: 6px; }
.compare-line{ color: var(--secondary-text); font-size: 13px; margin-top: 4px; }

/* 11) History */
.history-grid{
  display:grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
@media (max-width: 760px){
  .history-grid{ grid-template-columns: 1fr; }
}
.history-box{
  border-radius: var(--radius-lg);
  border: 1px solid color-mix(in srgb, var(--border-color) 60%, transparent);
  background: color-mix(in srgb, var(--bg-color) 72%, #ffffff 1%);
  padding: 12px;
}
.history-label{ color: var(--secondary-text); font-size: 12px; }
.history-value{ font-weight: 900; color: var(--text-color); margin-top: 6px; }

/* Modal */
.modal { position: fixed; inset: 0; display: grid; place-items: center; z-index: 9999; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.55); }
.modal-card {
  position: relative;
  width: min(720px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  overflow: auto;
  border-radius: var(--radius-xl);
  border: 1px solid color-mix(in srgb, var(--border-color) 70%, transparent);
  background: color-mix(in srgb, var(--content-bg) 55%, var(--bg-color));
  box-shadow: 0 22px 70px rgba(0,0,0,0.45);
}
.modal-head {
  display:flex; justify-content: space-between; align-items:center;
  padding: 14px 16px;
  border-bottom: 1px solid color-mix(in srgb, var(--border-color) 60%, transparent);
}
.modal-title { font-weight: 800; color: var(--text-color); }
.modal-body { padding: 14px 16px; display: grid; gap: 14px; }

.setting {
  display: grid;
  gap: 8px;
  padding: 12px;
  border-radius: var(--radius-lg);
  border: 1px solid color-mix(in srgb, var(--border-color) 60%, transparent);
  background: color-mix(in srgb, var(--bg-color) 70%, #ffffff 2%);
}
.setting-label { font-weight: 700; color: var(--text-color); }
.setting-control { display:flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.stack{
  display:grid;
  gap:6px;
}

.chip {
  border: 1px solid color-mix(in srgb, var(--border-color) 75%, transparent);
  background: color-mix(in srgb, var(--bg-color) 60%, #ffffff 3%);
  color: var(--text-color);
  padding: 9px 12px;
  border-radius: 999px;
  cursor: pointer;
}
.chip.is-active {
  border-color: color-mix(in srgb, var(--accent-color) 75%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-color) 22%, transparent);
}

/* Switch */
.switch { position: relative; display: inline-block; width: 52px; height: 30px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; cursor: pointer; inset: 0;
  background: rgba(255,255,255,0.15);
  border: 1px solid color-mix(in srgb, var(--border-color) 70%, transparent);
  transition: .2s;
  border-radius: 999px;
}
.slider:before {
  position: absolute; content: "";
  height: 24px; width: 24px; left: 3px; top: 2px;
  background: var(--text-color);
  transition: .2s;
  border-radius: 50%;
}
.switch input:checked + .slider {
  background: color-mix(in srgb, var(--accent-color) 55%, transparent);
  border-color: color-mix(in srgb, var(--accent-color) 70%, transparent);
}
.switch input:checked + .slider:before { transform: translateX(22px); }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -0.5px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* CRITICAL: make hidden attribute actually hide modal (and any hidden banners) */
.modal[hidden] { display: none !important; }
.banner[hidden] { display: none !important; }


/* ===========================================
   Responsive polish — makes it fit ALL devices
   Put this at the VERY bottom of your CSS
   =========================================== */

/* Safer sizing everywhere */
*, *::before, *::after { box-sizing: border-box; }
img, svg { max-width: 100%; height: auto; }

/* Page padding that scales instead of snapping */
.weather-page { padding: clamp(14px, 3vw, 32px); }

/* Header: don’t force the two sides to fight each other */
.weather-header { flex-wrap: wrap; align-items: flex-start; }
.weather-header-left,
.weather-header-right { width: 100%; justify-content: space-between; }
@media (min-width: 720px) {
  .weather-header-left,
  .weather-header-right { width: auto; }
  .weather-header { align-items: center; }
}

/* Search + actions: always wrap cleanly, never overflow */
.weather-search input { width: 100%; min-width: 0; }
.weather-search,
.weather-actions { width: 100%; }
@media (min-width: 720px) {
  .weather-search { flex-wrap: nowrap; }
  .weather-actions { width: auto; }
}

/* Buttons: slightly denser on small screens */
@media (max-width: 480px) {
  .btn { padding: 10px 11px; }
  .unit-pill { padding: 8px 10px; font-size: 12px; }
}

/* Main grid: your 920px breakpoint is fine; add a mid one too */
.weather-grid { grid-template-columns: 1fr; }
@media (min-width: 740px) {
  .weather-grid { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 920px) {
  .weather-grid { grid-template-columns: 1.1fr 0.9fr; }
}

/* Big temp text scales down gracefully */
.temp { font-size: clamp(34px, 7vw, 54px); }
.icon { width: clamp(44px, 9vw, 64px); height: clamp(44px, 9vw, 64px); }

/* Stats: stack on narrow screens */
.stats { grid-template-columns: 1fr 1fr; }
@media (max-width: 520px) {
  .stats { grid-template-columns: 1fr; }
}

/* Forecast grid: auto-fit makes it “just work” on any width */
.forecast {
  grid-template-columns: repeat(auto-fit, minmax(84px, 1fr));
}

/* Daily rows: stop hard-coding widths that break phones */
.day {
  grid-template-columns: minmax(90px, 120px) 1fr minmax(120px, 160px);
}
@media (max-width: 560px) {
  .day { grid-template-columns: 1fr; }
  .day .range { justify-self: start; }
}

/* Compare: already stacks at 760px, but make controls bulletproof */
.compare-controls input,
.mapbar select, .modal-body select,
.favorites select {
  width: 100%;
  min-width: 0;
}

/* Compare/history grids: use minmax so they shrink nicely */
.compare-grid {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.history-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

/* Map: responsive height so it’s not massive on mobile */
.map { height: clamp(260px, 50vh, 420px); }

/* Modal: add breathing room on tiny screens */
.modal-card { width: min(720px, calc(100vw - 18px)); }
@media (max-width: 420px) {
  .modal-body { padding: 12px; }
  .modal-head { padding: 12px; }
}

/* Pills + long text: avoid overflow */
.pill, .unit-pill, .aqi-badge {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Optional: reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
  .btn { transition: none; }
}
