:root {
  --bg: #1f2229;
  --card: #252932;
  --card-soft: #2c303a;
  --card-strong: #343944;
  --text: #f2f4f8;
  --muted: #aab0bc;
  --line: #3c414d;
  --accent: #fbbc04;
  --accent-2: #8ab4f8;
  --danger: #f28b82;
  --ok: #81c995;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, color-mix(in srgb, var(--accent), transparent 78%), transparent 34rem),
    linear-gradient(135deg, #191c22, var(--bg));
  color: var(--text);
  font-family:
    "Segoe UI",
    Tahoma,
    Geneva,
    Verdana,
    sans-serif;
}

body[data-weather-theme="clear"] {
  --accent: #fbbc04;
  --accent-2: #8ab4f8;
}

body[data-weather-theme="hot"] {
  --accent: #ff9f43;
  --accent-2: #ffd166;
}

body[data-weather-theme="rainy"] {
  --accent: #8ab4f8;
  --accent-2: #78d4ff;
}

body[data-weather-theme="stormy"] {
  --accent: #9ec5ff;
  --accent-2: #c7d8ff;
}

body[data-weather-theme="windy"],
body[data-weather-theme="humid"] {
  --accent: #78d4c8;
  --accent-2: #8ab4f8;
}

body[data-weather-theme="misty"] {
  --accent: #b7d7df;
  --accent-2: #8ab4f8;
}

body[data-weather-theme="hazy"] {
  --accent: #fdd663;
  --accent-2: #e7a84b;
}

body[data-weather-theme="dusty"] {
  --accent: #f28b82;
  --accent-2: #ffb4a8;
}

button,
a {
  font: inherit;
}

.weather-shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 24px 0;
}

.weather-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent 260px),
    var(--card);
  box-shadow: var(--shadow);
}

.weather-card > :not(.weather-media) {
  position: relative;
  z-index: 1;
}

.weather-media {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.weather-media img,
.weather-media video,
.weather-media__shade {
  position: absolute;
  inset: 0;
}

.weather-media img,
.weather-media video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.weather-media img {
  opacity: 1;
  transform: scale(1.02);
}

.weather-media video {
  opacity: 0;
  transform: scale(1.02);
  transition: opacity 500ms ease;
}

.weather-media__shade {
  background:
    radial-gradient(circle at 18% 15%, rgba(20, 28, 35, 0.42), transparent 28rem),
    linear-gradient(90deg, rgba(15, 20, 28, 0.88), rgba(25, 31, 42, 0.7) 46%, rgba(15, 20, 28, 0.9)),
    linear-gradient(180deg, rgba(18, 24, 31, 0.62), rgba(18, 24, 31, 0.84));
}

.weather-media[data-media="rain"] video {
  opacity: 1;
}

.weather-media[data-media="rain"] .weather-media__shade {
  background:
    linear-gradient(90deg, rgba(15, 20, 28, 0.82), rgba(30, 38, 52, 0.66) 48%, rgba(15, 20, 28, 0.88)),
    linear-gradient(180deg, rgba(37, 62, 91, 0.46), rgba(18, 24, 31, 0.82));
}

.weather-media[data-media="haze"] .weather-media__shade,
.weather-media[data-media="dust"] .weather-media__shade,
.weather-media[data-media="mist"] .weather-media__shade {
  background:
    radial-gradient(circle at 70% 15%, color-mix(in srgb, var(--accent), transparent 74%), transparent 24rem),
    linear-gradient(90deg, rgba(20, 18, 18, 0.84), rgba(38, 33, 28, 0.64) 48%, rgba(20, 18, 18, 0.88)),
    linear-gradient(180deg, color-mix(in srgb, var(--accent), transparent 90%), rgba(18, 24, 31, 0.84));
}

.topbar,
.now-layout,
.weather-tabs,
.trend-panel,
.forecast-strip,
.bottom-grid,
.status-footer {
  width: min(100%, 100%);
  padding-inline: clamp(18px, 3vw, 34px);
}

.topbar {
  min-height: 70px;
  display: flex;
  gap: 18px;
  align-items: center;
  justify-content: space-between;
}

.location-line {
  min-width: 0;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.pin {
  position: relative;
  width: 18px;
  height: 18px;
  margin-top: 4px;
  border: 2px solid var(--text);
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
}

.pin::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: var(--text);
}

.location-line strong,
.location-line span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.location-line strong {
  font-size: 1.04rem;
}

.location-line span {
  color: var(--muted);
  font-size: 0.88rem;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.refresh-button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--text);
  text-decoration: none;
}

.refresh-button {
  padding: 0 16px;
  background: color-mix(in srgb, var(--accent), #242833 82%);
  cursor: pointer;
}

.refresh-button:disabled {
  cursor: wait;
  opacity: 0.74;
}

.refresh-button__icon {
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-left-color: transparent;
  border-radius: 50%;
}

.refresh-button.is-loading .refresh-button__icon {
  animation: spin 0.8s linear infinite;
}

.now-layout {
  padding-top: 14px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(310px, 0.68fr);
  gap: 28px;
  align-items: start;
}

.now-left {
  display: grid;
  grid-template-columns: 86px auto minmax(160px, 1fr);
  gap: 18px;
  align-items: center;
}

.weather-icon {
  position: relative;
  width: 86px;
  height: 74px;
}

.weather-icon__sun,
.weather-icon__cloud,
.weather-icon__drop,
.weather-icon__bolt,
.weather-icon__haze {
  position: absolute;
  display: block;
}

.weather-icon__sun {
  width: 54px;
  height: 54px;
  left: 16px;
  top: 4px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 30px color-mix(in srgb, var(--accent), transparent 35%);
}

.weather-icon__cloud {
  width: 70px;
  height: 31px;
  left: 5px;
  top: 29px;
  border-radius: 22px;
  background: linear-gradient(145deg, #f1f3f4, #aeb3bc);
}

.weather-icon__cloud::before,
.weather-icon__cloud::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  background: inherit;
}

.weather-icon__cloud::before {
  width: 38px;
  height: 38px;
  left: 28px;
  top: -22px;
}

.weather-icon__cloud::after {
  width: 42px;
  height: 42px;
  left: 8px;
  top: -18px;
}

.weather-icon__drop {
  width: 14px;
  height: 20px;
  top: 58px;
  border-radius: 12px 12px 14px 14px;
  background: #1a73e8;
  transform: rotate(35deg);
  opacity: 0;
}

.weather-icon__drop--one {
  left: 34px;
}

.weather-icon__drop--two {
  left: 56px;
}

.weather-icon__bolt {
  width: 16px;
  height: 28px;
  left: 42px;
  top: 48px;
  clip-path: polygon(45% 0, 100% 0, 62% 43%, 92% 43%, 28% 100%, 42% 55%, 8% 55%);
  background: #fbbc04;
  opacity: 0;
}

.weather-icon__haze {
  width: 68px;
  height: 4px;
  left: 7px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent), #ffffff 24%);
  opacity: 0;
}

.weather-icon__haze--one {
  top: 48px;
}

.weather-icon__haze--two {
  top: 61px;
  width: 54px;
}

.weather-icon[data-condition="clear"] .weather-icon__cloud,
.weather-icon[data-condition="hot"] .weather-icon__cloud {
  opacity: 0.18;
}

.weather-icon[data-condition="rainy"] .weather-icon__sun {
  opacity: 0.22;
}

.weather-icon[data-condition="rainy"] .weather-icon__drop {
  opacity: 1;
}

.weather-icon[data-condition="dusty"] .weather-icon__drop,
.weather-icon[data-condition="hazy"] .weather-icon__drop {
  opacity: 0;
}

.weather-icon[data-condition="dusty"] .weather-icon__haze,
.weather-icon[data-condition="hazy"] .weather-icon__haze {
  opacity: 1;
}

.weather-icon[data-condition="windy"] .weather-icon__haze--one,
.weather-icon[data-condition="windy"] .weather-icon__haze--two {
  opacity: 0.8;
}

.temperature-main {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.temperature-main strong {
  font-size: clamp(4.4rem, 9vw, 6.4rem);
  line-height: 0.9;
  font-weight: 500;
  letter-spacing: 0;
}

.temperature-main span {
  margin-top: 10px;
  color: var(--text);
  font-size: 1.45rem;
}

.quick-details {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.95rem;
}

.quick-details p {
  margin: 0;
  display: flex;
  gap: 8px;
  justify-content: space-between;
}

.quick-details strong {
  color: var(--text);
  font-weight: 600;
}

.quick-details b {
  font-weight: 600;
}

.now-summary {
  text-align: right;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
  overflow-wrap: anywhere;
}

.now-summary h1 {
  margin-bottom: 3px;
  font-size: clamp(1.7rem, 4vw, 2.5rem);
  line-height: 1.15;
}

.now-summary time {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
}

.now-summary h2 {
  margin-bottom: 8px;
  color: var(--text);
  font-size: 1.2rem;
}

.now-summary p:last-child {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.7;
}

.weather-tabs {
  margin-top: 22px;
  display: flex;
  gap: 26px;
  border-bottom: 1px solid var(--line);
}

.weather-tabs button {
  position: relative;
  padding: 0 0 12px;
  border: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-weight: 700;
}

.weather-tabs button:not(.is-active) {
  color: var(--muted);
}

.weather-tabs button:hover,
.weather-tabs button:focus-visible {
  color: var(--text);
}

.weather-tabs button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 5px;
}

.weather-tabs .is-active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 3px;
  border-radius: 999px;
  background: var(--accent);
}

.trend-panel {
  padding-top: 20px;
  --chart-accent: var(--accent);
}

.trend-panel[data-chart="pm25"] {
  --chart-accent: #81c995;
}

.trend-panel[data-chart="humidity"] {
  --chart-accent: #78d4c8;
}

.trend-panel[data-chart="rainfall"] {
  --chart-accent: #8ab4f8;
}

.trend-panel[data-chart="wind"] {
  --chart-accent: #c7d8ff;
}

.trend-heading {
  margin-bottom: 8px;
  display: flex;
  gap: 16px;
  align-items: end;
  justify-content: space-between;
}

.trend-heading h2 {
  margin-bottom: 0;
  font-size: 1.18rem;
}

.trend-heading > p {
  max-width: 540px;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.55;
  text-align: right;
}

.trend-chart {
  min-height: 138px;
}

.trend-chart svg {
  display: block;
  width: 100%;
  height: auto;
}

.trend-area {
  fill: color-mix(in srgb, var(--chart-accent), transparent 72%);
}

.trend-line {
  fill: none;
  stroke: var(--chart-accent);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.trend-dot {
  fill: var(--chart-accent);
}

.trend-label,
.trend-value {
  fill: var(--muted);
  font-family: inherit;
  font-size: 13px;
}

.trend-value {
  fill: var(--text);
  font-weight: 700;
}

.trend-empty {
  margin: 0;
  padding: 42px 0;
  color: var(--muted);
  text-align: center;
}

.forecast-strip {
  padding-top: 18px;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}

.forecast-card,
.history-panel,
.stats-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card-soft);
}

.forecast-card {
  --level-color: #8a93a3;
  position: relative;
  overflow: hidden;
  min-height: 132px;
  padding: 14px 13px;
  display: grid;
  align-content: space-between;
  gap: 8px;
  border-color: color-mix(in srgb, var(--level-color), var(--line) 58%);
  background:
    linear-gradient(145deg, color-mix(in srgb, var(--level-color), transparent 82%), rgba(44, 48, 58, 0.94)),
    var(--card-soft);
}

.forecast-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: var(--level-color);
  opacity: 0.95;
}

.forecast-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 16% 8%, color-mix(in srgb, var(--level-color), transparent 62%), transparent 8rem),
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent 50%);
  pointer-events: none;
}

.forecast-card > * {
  position: relative;
  z-index: 1;
}

.forecast-card--active {
  background:
    linear-gradient(145deg, color-mix(in srgb, var(--level-color), transparent 72%), var(--card-strong)),
    var(--card-strong);
}

.forecast-card span,
.forecast-card small,
.forecast-card p {
  color: var(--muted);
}

.forecast-card span {
  font-weight: 800;
}

.forecast-card strong {
  color: var(--text);
  font-size: clamp(2rem, 4vw, 3.1rem);
  line-height: 0.95;
}

.forecast-card p {
  margin: 0;
  min-height: 38px;
  font-size: 0.88rem;
  line-height: 1.45;
}

.forecast-card[data-level="very-good"] {
  --level-color: #4aa3ff;
}

.forecast-card[data-level="good"],
.forecast-card[data-level="comfortable"],
.forecast-card[data-level="no-rain"],
.forecast-card[data-level="calm"] {
  --level-color: #81c995;
}

.forecast-card[data-level="cool"],
.forecast-card[data-level="windy"],
.forecast-card[data-level="light-rain"] {
  --level-color: #8ab4f8;
}

.forecast-card[data-level="moderate"],
.forecast-card[data-level="dry-air"],
.forecast-card[data-level="humid"],
.forecast-card[data-level="hot"],
.forecast-card[data-level="strong-wind"],
.forecast-card[data-level="moderate-rain"] {
  --level-color: #fdd663;
}

.forecast-card[data-level="unhealthy-sensitive"],
.forecast-card[data-level="very-humid"],
.forecast-card[data-level="heavy-rain"] {
  --level-color: #ffad66;
}

.forecast-card[data-level="unhealthy"],
.forecast-card[data-level="very-hot"],
.forecast-card[data-level="storm-wind"] {
  --level-color: #f28b82;
}

.bottom-grid {
  padding-top: 18px;
  padding-bottom: 20px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 0.82fr);
  gap: 14px;
}

.history-panel,
.stats-panel {
  padding: 18px;
}

.pm25-short-advice {
  width: fit-content;
  max-width: 100%;
  margin: 12px 0 0 auto;
  padding: 8px 12px;
  border: 1px solid color-mix(in srgb, var(--accent), var(--line) 54%);
  border-radius: 999px;
  background: rgba(20, 24, 31, 0.52);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.45;
}

.history-summary {
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.55;
}

.history-list {
  overflow-x: auto;
  padding-bottom: 2px;
}

.history-table {
  min-width: 540px;
  display: grid;
  gap: 7px;
}

.history-row {
  --history-color: #8a93a3;
  min-height: 36px;
  display: grid;
  grid-template-columns: 56px repeat(6, minmax(44px, 1fr));
  gap: 6px;
  align-items: center;
  padding: 7px 8px;
  border: 1px solid color-mix(in srgb, var(--history-color), var(--line) 62%);
  border-left-width: 4px;
  border-radius: 8px;
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--history-color), transparent 88%), transparent 42%),
    #20242d;
}

.history-row[data-level="very-good"] {
  --history-color: #4aa3ff;
}

.history-row[data-level="good"] {
  --history-color: #81c995;
}

.history-row[data-level="moderate"] {
  --history-color: #fdd663;
}

.history-row[data-level="unhealthy-sensitive"] {
  --history-color: #ffad66;
}

.history-row[data-level="unhealthy"] {
  --history-color: #f28b82;
}

.history-row--head {
  min-height: 28px;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

.history-date {
  color: var(--muted);
  font-size: 0.82rem;
}

.history-row span,
.history-row strong {
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

.history-row span {
  font-weight: 700;
}

.history-row strong {
  color: var(--text);
  font-size: 0.86rem;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.history-row strong:first-of-type {
  color: var(--history-color);
}

.panel-heading {
  margin-bottom: 14px;
}

.panel-heading h2 {
  margin-bottom: 0;
  font-size: 1.25rem;
}

.stats-list {
  display: grid;
  gap: 12px;
}

.stat-row {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr) 150px;
  gap: 10px;
  align-items: center;
}

.stat-row span {
  color: var(--muted);
  font-size: 0.86rem;
}

.stat-bar {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #20242d;
}

.stat-bar i {
  display: block;
  width: var(--bar-width, 0%);
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.stat-values {
  color: var(--text);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.status-footer {
  min-height: 54px;
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.88rem;
}

.status-footer div {
  display: flex;
  gap: 9px;
  align-items: center;
}

.status-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--accent);
}

.status-dot.is-ok {
  background: var(--ok);
}

.status-dot.is-error {
  background: var(--danger);
}

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

@media (prefers-reduced-motion: reduce) {
  .refresh-button.is-loading .refresh-button__icon {
    animation: none;
  }
}

@media (max-width: 920px) {
  .topbar,
  .now-layout,
  .bottom-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .now-left {
    grid-template-columns: 78px auto;
  }

  .quick-details {
    grid-column: 1 / -1;
  }

  .now-summary {
    text-align: left;
  }

  .trend-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .trend-heading > p {
    text-align: left;
  }

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

  .pm25-short-advice {
    margin-left: 0;
    margin-right: auto;
  }
}

@media (max-width: 560px) {
  .weather-shell {
    width: min(100% - 16px, 460px);
    padding: 8px 0;
  }

  .topbar,
  .now-layout,
  .weather-tabs,
  .trend-panel,
  .forecast-strip,
  .bottom-grid,
  .status-footer {
    padding-inline: 14px;
  }

  .refresh-button {
    width: 100%;
  }

  .now-left {
    grid-template-columns: 70px minmax(0, 1fr);
    gap: 12px;
  }

  .weather-icon {
    width: 70px;
    transform: scale(0.82);
    transform-origin: left center;
  }

  .temperature-main strong {
    font-size: 4.1rem;
  }

  .weather-tabs {
    gap: 18px;
    overflow-x: auto;
  }

  .forecast-strip {
    grid-template-columns: 1fr;
  }

  .forecast-card strong {
    font-size: 2.2rem;
  }

  .stat-row {
    grid-template-columns: 1fr;
  }

  .history-table {
    min-width: 540px;
  }

  .stat-values {
    text-align: left;
  }

  .quick-details p {
    justify-content: flex-start;
    flex-wrap: wrap;
  }
}
