/* ==========================================================================
   theClimate — App chrome + component styles. A normal scrolling content
   page (not a fixed-viewport workbench like theDiff/theJsonFormatter) —
   the titlebar sticks, everything below it scrolls with the page; only the
   hourly strip gets its own horizontally-scrollable region.
   ========================================================================== */

/* ---------- Title bar ---------- */

.titlebar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 52px;
  padding: 0 16px;
  background: var(--titlebar-bg);
  border-bottom: 1px solid var(--border);
}

.titlebar .brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--text-1);
  text-decoration: none;
  flex-shrink: 0;
}

.titlebar .brand img {
  width: 26px;
  height: 26px;
  border-radius: 6px;
}

.titlebar .brand b {
  color: var(--accent-ink);
  font-weight: 800;
}

.tb-spacer {
  flex: 1;
}

.tb-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  font-size: 1rem;
  flex-shrink: 0;
  text-decoration: none;
}

.tb-icon-btn:hover {
  background: var(--bg-elevated);
  color: var(--text-1);
  border-color: var(--border);
}

.tb-icon-btn.active {
  color: var(--accent-ink);
  border-color: var(--accent-dim);
  background: var(--accent-dim);
}

/* ---------- Page container ---------- */

.page {
  max-width: 880px;
  margin: 0 auto;
  padding: 20px 16px 60px;
}

/* ---------- Location / search bar ---------- */

.location-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.current-location {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  color: var(--text-1);
  min-width: 0;
}

.current-location i {
  color: var(--accent-ink);
  flex-shrink: 0;
}

#currentLocationLabel {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#placeSearchWrap {
  position: relative;
  flex: 1;
  min-width: 180px;
}

#placeSearchInput {
  width: 100%;
  height: 38px;
  border: 1px solid var(--input-border);
  border-radius: 9px;
  background: var(--input-bg);
  color: var(--text-1);
  padding: 0 12px 0 34px;
  font-size: 0.9rem;
  font-family: inherit;
}

#placeSearchWrap::before {
  content: "\f002";
  font-family: FontAwesome;
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
  pointer-events: none;
}

#placeSearchResults {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 9px;
  box-shadow: var(--shadow-md);
  z-index: 40;
  max-height: 260px;
  overflow-y: auto;
}

.psr-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--text-1);
}

.psr-item:hover {
  background: var(--accent-dim);
}

.psr-name {
  font-weight: 700;
  font-size: 0.88rem;
}

.psr-region {
  font-size: 0.74rem;
  color: var(--text-3);
}

.psr-empty {
  padding: 12px;
  color: var(--text-3);
  font-size: 0.85rem;
}

.psr-attribution {
  padding: 6px 12px;
  font-size: 0.68rem;
  color: var(--text-3);
  border-top: 1px solid var(--border);
}

.psr-attribution a {
  color: var(--text-3);
  text-decoration: underline;
}

.use-location-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--card-bg);
  color: var(--text-1);
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

.use-location-btn:hover {
  border-color: var(--accent);
  color: var(--accent-ink);
}

.use-location-btn:disabled {
  opacity: 0.6;
  cursor: default;
}

/* ---------- Saved-locations strip ---------- */

.saved-locations-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 18px;
}

.saved-locations-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.manage-locations-btn[hidden] {
  display: none; /* a bare .manage-locations-btn{display:...} rule ties the UA [hidden]{display:none} rule in
                    specificity, and author styles win ties — so this explicit override is required, not optional */
}

.manage-locations-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px dashed var(--border);
  background: transparent;
  color: var(--text-2);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

.manage-locations-btn:hover {
  border-color: var(--accent);
  color: var(--accent-ink);
}

.add-current-btn {
  display: inline-flex;
  align-items: center;
  margin-left: auto; /* anchors this + the Manage button to the row's right edge regardless of pill count */
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--accent);
  background: var(--accent-dim);
  color: var(--accent-ink);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

.add-current-btn:hover:not(:disabled) {
  background: var(--accent);
  color: var(--accent-contrast-text);
}

.add-current-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.loc-pill-more {
  border-style: dashed;
  color: var(--text-3);
}

.loc-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text-2);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

.loc-pill:hover {
  border-color: var(--accent);
}

.loc-pill.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.loc-pill .fa-star {
  color: var(--uv-high);
}

.loc-pill-menu {
  margin-left: 4px;
  opacity: 0.6;
  padding: 2px;
}

.loc-pill-menu:hover {
  opacity: 1;
}

/* ---------- Empty state ---------- */

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-2);
}

.empty-state i {
  font-size: 2.4rem;
  color: var(--text-3);
  margin-bottom: 12px;
  display: block;
}

/* ---------- Current-conditions hero card ---------- */

.hero-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}

.hero-top {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}

.hero-icon {
  font-size: 5.6rem;
  line-height: 1;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.hero-temp-block {
  min-width: 0;
}

.hero-temp {
  font-size: 3rem;
  font-weight: 800;
  font-family: "JetBrains Mono", monospace;
  line-height: 1;
  color: var(--text-1);
}

.hero-feels {
  color: var(--text-2);
  font-size: 0.9rem;
  margin-top: 4px;
}

.hero-condition-block {
  margin-left: auto;
  text-align: right;
}

.hero-condition {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text-1);
}

.hero-location {
  color: var(--text-2);
  font-size: 0.85rem;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--border-subtle);
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
  min-width: 0;
}

.stat-item i {
  color: var(--accent-ink);
  font-size: 1.1rem;
}

.stat-label {
  font-size: 0.7rem;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-value {
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--text-1);
  font-family: "JetBrains Mono", monospace;
}

.stat-item.stat-warn .stat-value {
  color: var(--uv-high);
}

.wind-arrow {
  display: inline-block;
  transition: transform 0.3s ease;
}

/* ---------- Hourly strip ---------- */

.section-title {
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-3);
  margin: 0 0 10px;
}

.hourly-strip,
.hour-strip-inner {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 6px;
  scrollbar-width: thin;
}

.hour-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 58px;
  padding: 12px 8px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  flex-shrink: 0;
}

.hc-time {
  font-size: 0.72rem;
  color: var(--text-2);
  font-weight: 700;
}

.hc-icon {
  font-size: 1.4rem;
}

.hc-temp {
  font-weight: 700;
  font-size: 0.85rem;
  font-family: "JetBrains Mono", monospace;
}

.hc-precip {
  font-size: 0.68rem;
  color: var(--precip);
}

.hourly-section {
  margin-bottom: 20px;
}

/* ---------- Daily list ---------- */

.daily-list {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
}

.day-row {
  display: grid;
  grid-template-columns: 70px 32px 1fr 90px 16px;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
}

.daily-list > :last-child.day-row,
.day-row:last-of-type {
  border-bottom: none;
}

.day-row:hover {
  background: var(--accent-dim);
}

.dr-name {
  font-weight: 700;
  font-size: 0.88rem;
}

.dr-icon {
  font-size: 1.3rem;
  text-align: center;
}

.dr-precip {
  font-size: 0.76rem;
  color: var(--precip);
}

.dr-temps {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.88rem;
}

.dr-high {
  font-weight: 700;
  color: var(--temp-hot);
}

.dr-low {
  color: var(--temp-cold);
}

.dr-chevron {
  color: var(--text-3);
  font-size: 0.75rem;
  transition: transform 0.15s ease;
}

.day-row[aria-expanded="true"] .dr-chevron {
  transform: rotate(180deg);
}

.day-detail {
  padding: 10px 16px 16px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--panel-bg);
}

/* ---------- Unit toggle + status footer ---------- */

.footer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
}

.unit-toggles {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.seg-control {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.seg-btn {
  border: none;
  background: var(--card-bg);
  color: var(--text-2);
  padding: 5px 10px;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
}

.seg-btn + .seg-btn {
  border-left: 1px solid var(--border);
}

.seg-btn.active {
  background: var(--accent-dim);
  color: var(--accent-ink);
}

.status-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-3);
  font-size: 0.78rem;
}

.refresh-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card-bg);
  color: var(--text-2);
  padding: 6px 12px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

.refresh-btn:hover {
  color: var(--accent-ink);
  border-color: var(--accent);
}

.privacy-note {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--success);
  font-weight: 700;
  font-size: 0.75rem;
}

/* ---------- Alerts (derived from the forecast — never an official warning) ---------- */

.alerts-section[hidden] {
  display: none; /* .alerts-section's own display:flex ties the UA [hidden] rule in specificity — author wins ties, so this override is required */
}

.alerts-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 18px;
}

.alert-chip {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid;
}

.alert-chip.level-warning {
  background: var(--warning-dim);
  border-color: var(--warning);
  color: var(--text-1);
}

.alert-chip.level-danger {
  background: var(--danger-dim);
  border-color: var(--danger);
  color: var(--text-1);
}

.alert-chip i.alert-icon {
  font-size: 1.1rem;
  margin-top: 2px;
  flex-shrink: 0;
}

.alert-chip.level-warning i.alert-icon { color: var(--warning); }
.alert-chip.level-danger i.alert-icon { color: var(--danger); }

.alert-title {
  font-weight: 800;
  font-size: 0.9rem;
}

.alert-message {
  font-size: 0.82rem;
  color: var(--text-2);
  margin-top: 2px;
}

.alert-footnote {
  font-size: 0.7rem;
  color: var(--text-3);
  margin-top: 4px;
  font-style: italic;
}

/* ---------- Forecast view tabs ---------- */

.content-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  margin-bottom: 14px;
}

.content-tabs::-webkit-scrollbar {
  display: none;
}

.content-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card-bg);
  color: var(--text-2);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

.content-tab:hover {
  border-color: var(--accent);
  color: var(--accent-ink);
}

.content-tab.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.content-panes {
  margin-bottom: 4px;
}

.content-pane {
  animation: pane-fade-in 0.15s ease;
}

@keyframes pane-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ---------- Next Hour precipitation timeline ---------- */

.nh-info {
  color: var(--text-3);
  font-size: 0.78rem;
  font-weight: 400;
  cursor: help;
}

.next-hour-timeline {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.mh-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.mh-bar-track {
  width: 100%;
  max-width: 28px;
  height: 70px;
  display: flex;
  align-items: flex-end;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.mh-bar {
  width: 100%;
  height: var(--h, 6%);
  min-height: 2px;
  position: relative;
  background: linear-gradient(180deg, var(--precip) 0%, var(--accent) 140%);
  transition: height 0.4s ease;
  animation: liquid-fill-rise 0.7s ease-out;
}

.mh-bar::before {
  content: "";
  position: absolute;
  top: -3px;
  left: -50%;
  width: 200%;
  height: 6px;
  background-image: radial-gradient(ellipse 10px 6px at center, rgba(255, 255, 255, 0.6) 0%, transparent 70%);
  background-size: 24px 6px;
  background-repeat: repeat-x;
  animation: liquid-wave-scroll 1.8s linear infinite;
}

@keyframes liquid-fill-rise {
  from { height: 0%; }
  to { height: var(--h, 6%); }
}

@keyframes liquid-wave-scroll {
  from { background-position-x: 0; }
  to { background-position-x: 24px; }
}

.mh-time {
  font-size: 0.68rem;
  color: var(--text-3);
  font-family: "JetBrains Mono", monospace;
  white-space: nowrap; /* "11:45AM" must not wrap to two lines in its narrow column */
}

.next-hour-summary {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-1);
  margin: 0;
}

.next-hour-resolution-note {
  display: flex;
  gap: 6px;
  align-items: flex-start;
  font-size: 0.78rem;
  color: var(--text-3);
  margin: 8px 0 0;
  line-height: 1.5;
}

.next-hour-resolution-note i {
  margin-top: 2px;
  flex-shrink: 0;
}

/* ---------- Health & Activities ---------- */

.pane-subtitle {
  font-size: 0.82rem;
  color: var(--text-2);
  margin: -6px 0 16px;
  line-height: 1.5;
  max-width: 640px;
}

.health-aqi-banner {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 20px;
  margin-bottom: 18px;
}

.health-aqi-value {
  font-size: 2.2rem;
  font-weight: 800;
  font-family: "JetBrains Mono", monospace;
  line-height: 1;
}

.health-aqi-value.aqi-good { color: var(--aqi-good); }
.health-aqi-value.aqi-moderate { color: var(--aqi-moderate); }
.health-aqi-value.aqi-sensitive { color: var(--aqi-sensitive); }
.health-aqi-value.aqi-unhealthy { color: var(--aqi-unhealthy); }
.health-aqi-value.aqi-very-unhealthy { color: var(--aqi-very-unhealthy); }
.health-aqi-value.aqi-hazardous { color: var(--aqi-hazardous); }

.health-aqi-label {
  font-size: 1rem;
  color: var(--text-1);
  font-weight: 800;
}

.health-aqi-sub {
  font-size: 0.74rem;
  color: var(--text-3);
  margin-top: 2px;
}

.health-groups {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}

.health-group {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 18px;
}

.hg-title {
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--text-1);
}

.hg-question {
  font-size: 0.74rem;
  color: var(--text-3);
  margin: 2px 0 12px;
}

.hg-items {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hg-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-subtle);
}

.hg-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.hg-name {
  font-size: 0.85rem;
  color: var(--text-2);
}

.hg-rating {
  font-size: 0.74rem;
  font-weight: 800;
  padding: 3px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.hg-rating.r-good { background: var(--success-dim); color: var(--success); }
.hg-rating.r-ideal { background: var(--accent-dim); color: var(--accent-ink); }
.hg-rating.r-fair { background: var(--warning-dim); color: var(--warning); }
.hg-rating.r-poor { background: var(--danger-dim); color: var(--danger); }
.hg-rating.r-extreme { background: var(--alert-dim); color: var(--alert); }

/* ---------- Radar ---------- */

.radar-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
}

#radarMapContainer {
  width: 100%;
  height: 360px;
  border-radius: 10px;
  background: var(--panel-bg);
}

.radar-controls[hidden] {
  display: none; /* .radar-controls's own display:flex ties the UA [hidden] rule in specificity — author wins ties, so this override is required */
}

.radar-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.radar-play-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--accent);
  color: var(--accent-contrast-text);
  cursor: pointer;
}

.radar-frame-label {
  font-size: 0.8rem;
  font-family: "JetBrains Mono", monospace;
  color: var(--text-2);
}

.radar-error {
  font-size: 0.8rem;
  color: var(--warning);
  margin: 10px 2px 0;
}

/* ---------- Manage locations modal ---------- */

.locations-add-btn {
  width: 100%;
  justify-content: center;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.locations-manage-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.locations-manage-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel-bg);
}

.lmr-drag {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex-shrink: 0;
}

.lmr-drag button {
  width: 22px;
  height: 18px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-3);
  font-size: 0.7rem;
  cursor: pointer;
}

.lmr-drag button:hover:not(:disabled) {
  background: var(--accent-dim);
  color: var(--accent-ink);
}

.lmr-drag button:disabled {
  opacity: 0.3;
  cursor: default;
}

.lmr-body {
  flex: 1;
  min-width: 0;
}

.lmr-name {
  font-weight: 700;
  font-size: 0.88rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lmr-coords {
  font-size: 0.72rem;
  color: var(--text-3);
  font-family: "JetBrains Mono", monospace;
}

.lmr-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.lmr-actions button {
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
}

.lmr-actions button:hover {
  background: var(--accent-dim);
  color: var(--accent-ink);
}

.lmr-actions button.lmr-default.is-default {
  color: var(--uv-high);
}

.lmr-actions button.lmr-remove:hover {
  background: var(--danger-dim);
  color: var(--danger);
}

.locations-empty-note {
  color: var(--text-3);
  font-size: 0.85rem;
  text-align: center;
  padding: 20px 0;
}

/* ---------- Ambient weather-reactive background ---------- */

#weatherBg {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
  transition: background 0.6s ease;
}

/* Dark theme ("Storm Front") scene washes — tuned against the dark --bg-page. */
#weatherBg.scene-clear-day {
  background: radial-gradient(1200px 700px at 50% -10%, rgba(246, 196, 83, 0.28) 0%, transparent 62%), var(--bg-page);
}

#weatherBg.scene-clear-night {
  background: radial-gradient(900px 600px at 80% -10%, rgba(147, 197, 253, 0.22) 0%, transparent 62%), var(--bg-page);
}

#weatherBg.scene-cloudy {
  background: linear-gradient(180deg, rgba(148, 163, 184, 0.1) 0%, transparent 40%), var(--bg-page);
}

#weatherBg.scene-fog {
  background: radial-gradient(1200px 800px at 50% 20%, rgba(203, 213, 225, 0.22) 0%, transparent 72%), var(--bg-page);
  animation: fog-pulse 8s ease-in-out infinite;
}

#weatherBg.scene-rain,
#weatherBg.scene-thunderstorm {
  /* A moody overcast wash, not a repeating diagonal-stripe texture — the
     falling-raindrop particles (.bg-raindrop) do the actual "rain" reading,
     same discrete-particle approach as snow, rather than a busy wallpaper
     hatching pattern scrolling across the whole viewport. */
  background: radial-gradient(1300px 800px at 50% 0%, rgba(71, 85, 105, 0.28) 0%, transparent 65%), var(--bg-page);
}

#weatherBg.scene-thunderstorm::after {
  content: "";
  position: absolute;
  inset: 0;
  background: #fff;
  opacity: 0;
  animation: storm-flash 13s ease-in-out infinite;
}

body.theme-light #weatherBg.scene-thunderstorm::after {
  background: #1e293b; /* a light page brightening further isn't perceptible as a "flash" — darken instead */
}

#weatherBg.scene-snow {
  background: linear-gradient(180deg, rgba(224, 242, 254, 0.08) 0%, transparent 40%), var(--bg-page);
}

/* Extreme cold + no active precipitation (e.g. a dry Antarctic winter day) — an
   icy ambient tint so it still reads as bitterly cold, without fabricating
   snowfall that genuinely isn't in the forecast. */
#weatherBg.scene-frost {
  background: radial-gradient(1300px 800px at 50% 0%, rgba(186, 230, 253, 0.2) 0%, transparent 65%), var(--bg-page);
}

/* Light theme ("Clear Skies") scene washes — the same scenes need their own
   tuning here, not just a shared rgba set, since the same overlay color
   reads completely differently against a near-white page than a near-black
   one (the original bug this section fixes: snow/clouds/rain were invisible
   or looked wrong in light mode). */
body.theme-light #weatherBg.scene-clear-day {
  background: radial-gradient(1200px 700px at 50% -10%, rgba(250, 204, 21, 0.22) 0%, transparent 62%), var(--bg-page);
}

body.theme-light #weatherBg.scene-clear-night {
  background: radial-gradient(900px 600px at 80% -10%, rgba(59, 130, 246, 0.14) 0%, transparent 62%), var(--bg-page);
}

body.theme-light #weatherBg.scene-cloudy {
  background: linear-gradient(180deg, rgba(71, 85, 105, 0.12) 0%, transparent 45%), var(--bg-page);
}

body.theme-light #weatherBg.scene-fog {
  background: radial-gradient(1200px 800px at 50% 20%, rgba(100, 116, 139, 0.16) 0%, transparent 72%), var(--bg-page);
}

body.theme-light #weatherBg.scene-rain,
body.theme-light #weatherBg.scene-thunderstorm {
  background: radial-gradient(1300px 800px at 50% 0%, rgba(51, 65, 85, 0.14) 0%, transparent 65%), var(--bg-page);
}

body.theme-light #weatherBg.scene-snow {
  background: linear-gradient(180deg, rgba(2, 132, 199, 0.08) 0%, transparent 40%), var(--bg-page);
}

body.theme-light #weatherBg.scene-frost {
  background: radial-gradient(1300px 800px at 50% 0%, rgba(2, 132, 199, 0.14) 0%, transparent 65%), var(--bg-page);
}

.bg-particles {
  position: absolute;
  inset: 0;
}

.bg-star {
  position: absolute;
  width: 2.5px;
  height: 2.5px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 4px 1px rgba(255, 255, 255, 0.6);
  animation: star-twinkle 3s ease-in-out infinite;
}

body.theme-light .bg-star {
  background: #1e3a5f;
  box-shadow: none;
}

.bg-cloud {
  position: absolute;
  width: 440px;
  height: 150px;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(148, 163, 184, 0.32), transparent);
  filter: blur(6px);
  top: 10%;
  animation: cloud-drift 60s linear infinite;
}

body.theme-light .bg-cloud {
  background: radial-gradient(closest-side, rgba(71, 85, 105, 0.22), transparent);
}

.bg-raindrop {
  position: absolute;
  top: -20px;
  width: 1.5px;
  /* A gradient fade top-to-bottom so it reads as a falling streak, not a hard-edged bar. */
  background: linear-gradient(180deg, transparent 0%, #7dd3fc 40%, #38bdf8 100%);
  border-radius: 2px;
  animation-name: raindrop-fall;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
}

body.theme-light .bg-raindrop {
  background: linear-gradient(180deg, transparent 0%, #0284c7 40%, #0369a1 100%);
}

.bg-cloud-0 { top: 8%; animation-duration: 70s; }
.bg-cloud-1 { top: 35%; animation-duration: 95s; animation-delay: -20s; }
.bg-cloud-2 { top: 60%; animation-duration: 80s; animation-delay: -45s; }

.bg-flake {
  position: absolute;
  top: -10px;
  border-radius: 50%;
  background: #e0f2fe; /* solid, no glow — a glowing dot reads as a twinkling star, not falling snow */
  animation-name: flake-fall;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
}

body.theme-light .bg-flake {
  background: #0369a1;
  opacity: 0.6;
}

.bg-frost-sparkle {
  position: absolute;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #bae6fd;
  box-shadow: 0 0 5px 1px rgba(186, 230, 253, 0.7);
  animation: star-twinkle 4s ease-in-out infinite;
}

body.theme-light .bg-frost-sparkle {
  background: #0369a1;
  box-shadow: none;
  opacity: 0.5;
}

@keyframes star-twinkle {
  0%, 100% { opacity: 0.2; }
  50% { opacity: 1; }
}

@keyframes cloud-drift {
  from { transform: translateX(-30vw); }
  to { transform: translateX(130vw); }
}

@keyframes flake-fall {
  0% { transform: translateY(-10px) translateX(0) rotate(0deg); }
  50% { transform: translateY(50vh) translateX(-16px) rotate(180deg); }
  100% { transform: translateY(100vh) translateX(20px) rotate(360deg); }
}

@keyframes raindrop-fall {
  from { transform: translateY(-20px) translateX(0); }
  to { transform: translateY(100vh) translateX(-14px); }
}

@keyframes fog-pulse {
  0%, 100% { opacity: 0.85; }
  50% { opacity: 1; }
}

@keyframes storm-flash {
  0%, 96%, 100% { opacity: 0; }
  97% { opacity: 0.12; }
  98% { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  #weatherBg,
  #weatherBg::after,
  .bg-star,
  .bg-cloud,
  .bg-flake,
  .bg-frost-sparkle,
  .bg-raindrop {
    animation: none !important;
  }
}

/* ---------- Weather-icon coloring (near-universal conventions, kept separate from brand accent) ---------- */

.wi-day-sunny, .wi-day-sunny-overcast { color: #f6c453; }
.wi-night-clear, .wi-night-alt-partly-cloudy { color: #93c5fd; }
.wi-day-cloudy, .wi-cloudy, .wi-night-alt-cloudy { color: #94a3b8; }
.wi-day-fog, .wi-night-fog { color: #a1a1aa; }
.wi-rain, .wi-rain-wind, .wi-showers, .wi-sprinkle, .wi-rain-mix { color: var(--precip); }
.wi-snow, .wi-snow-wind { color: #e0f2fe; }
.wi-thunderstorm, .wi-storm-showers { color: #a78bfa; }

/* Extreme cold + dry (see weather-background.js's "frost" scene) — a modifier
   on top of whatever base glyph color above, so the same accurate clear/
   cloudy/fog shape reads as icy-cold rather than an ordinary mild day. */
.wi-frost { color: #7dd3fc !important; }
body.theme-light .wi-frost { color: #0369a1 !important; }
.wi-na { color: var(--text-3); }

/* ---------- Icon motion — condition icons feel alive, not static clip-art ----------
   Each animation is on a DIFFERENT property per icon family so multiple can never
   fight each other, and critically: the wind-direction arrow's rotation is set via
   inline style from real data (app.js) — nothing here animates `transform` on it,
   only `opacity`, so the actual wind direction is never overridden by a CSS animation
   (a real conflict that would otherwise silently break the compass reading). */

@keyframes icon-sun-glow {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 0 2px rgba(246, 196, 83, 0.35)); }
  50% { transform: scale(1.07); filter: drop-shadow(0 0 9px rgba(246, 196, 83, 0.8)); }
}
@keyframes icon-glow-pulse { 0%, 100% { opacity: 0.85; transform: scale(1); } 50% { opacity: 1; transform: scale(1.06); } }
@keyframes icon-drift-sway { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(3px); } }
@keyframes icon-fall-bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(3px); } }
@keyframes icon-sway-drift { 0%, 100% { transform: translateX(-2px) rotate(-4deg); } 50% { transform: translateX(2px) rotate(4deg); } }
@keyframes icon-flash-pulse { 0%, 90%, 100% { opacity: 1; } 93% { opacity: 0.4; } 96% { opacity: 1; } 98% { opacity: 0.5; } }
@keyframes icon-idle-opacity { 0%, 100% { opacity: 0.75; } 50% { opacity: 1; } }

.wi-day-sunny, .wi-day-sunny-overcast { display: inline-block; animation: icon-sun-glow 3.2s ease-in-out infinite; }
.wi-night-clear, .wi-night-alt-partly-cloudy { animation: icon-glow-pulse 4s ease-in-out infinite; }
.wi-day-cloudy, .wi-cloudy, .wi-night-alt-cloudy, .wi-day-fog, .wi-night-fog { animation: icon-drift-sway 5s ease-in-out infinite; }
.wi-rain, .wi-rain-wind, .wi-showers, .wi-sprinkle, .wi-rain-mix, .wi-storm-showers { animation: icon-fall-bounce 1.3s ease-in-out infinite; }
.wi-snow, .wi-snow-wind { animation: icon-sway-drift 3s ease-in-out infinite; }
.wi-thunderstorm { animation: icon-flash-pulse 4s ease-in-out infinite; }

/* Hero stat icons (humidity/wind/precip/pressure/UV/visibility/sunrise/sunset) —
   opacity-only, so it layers safely on top of the wind arrow's data-driven rotation. */
.stat-item > i.fa {
  display: inline-block;
  animation: icon-idle-opacity 2.6s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  .wi-day-sunny, .wi-day-sunny-overcast,
  .wi-night-clear, .wi-night-alt-partly-cloudy,
  .wi-day-cloudy, .wi-cloudy, .wi-night-alt-cloudy, .wi-day-fog, .wi-night-fog,
  .wi-rain, .wi-rain-wind, .wi-showers, .wi-sprinkle, .wi-rain-mix, .wi-storm-showers,
  .wi-snow, .wi-snow-wind, .wi-thunderstorm,
  .stat-item > i.fa,
  .mh-bar,
  .mh-bar::before {
    animation: none !important;
  }
}

/* ---------- Modal / confirm dialog (shared contract with extra.js) ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  background: var(--bg-overlay);
  padding: 16px;
}

.modal-backdrop.open {
  display: flex;
}

.app-modal {
  width: min(560px, 94vw);
  max-height: 86vh;
  overflow-y: auto;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
}

.app-modal.wide {
  width: min(760px, 94vw);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  font-weight: 800;
  font-size: 1.02rem;
}

.modal-body {
  padding: 18px;
  color: var(--text-2);
  line-height: 1.55;
}

.modal-body h3 {
  color: var(--text-1);
  font-size: 0.95rem;
  margin: 18px 0 8px;
}

.modal-body h3:first-child {
  margin-top: 0;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 18px;
  border-top: 1px solid var(--border);
}

.btn {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card-bg);
  color: var(--text-1);
  padding: 8px 16px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
}

.btn:hover {
  border-color: var(--accent);
}

.btn.accent {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast-text);
}

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

.about-feature-list {
  list-style: none;
  padding: 0;
  margin: 0 0 16px;
}

.about-feature-list li {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 5px 0;
  font-size: 0.86rem;
}

.about-feature-list i {
  color: var(--success);
  margin-top: 3px;
  flex-shrink: 0;
}

.faq-q {
  font-weight: 700;
  color: var(--text-1);
  margin: 14px 0 2px;
}

/* ---------- Menu (shared contract with extra.js) ---------- */

.menu {
  position: fixed;
  z-index: 1100;
  display: none;
  flex-direction: column;
  min-width: 170px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-md);
  padding: 6px;
}

.menu.open {
  display: flex;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  border: none;
  background: transparent;
  color: var(--text-1);
  padding: 8px 10px;
  border-radius: 7px;
  font-size: 0.85rem;
  text-align: left;
  cursor: pointer;
}

.menu-item:hover {
  background: var(--accent-dim);
}

.menu-item.danger {
  color: var(--danger);
}

.menu-item .mi-check {
  display: none;
  margin-left: auto;
}

.menu-item.checked .mi-check {
  display: inline-block;
}

.menu-sep {
  height: 1px;
  background: var(--border);
  margin: 4px 2px;
}

.menu-label {
  padding: 4px 10px;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-3);
}

/* ---------- Toasts ---------- */

.toast-stack {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 1200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(380px, 92vw);
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-left: 4px solid var(--text-3);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.84rem;
  color: var(--text-1);
  box-shadow: var(--shadow-md);
}

.toast.success { border-left-color: var(--success); }
.toast.warning { border-left-color: var(--warning); }
.toast.danger { border-left-color: var(--danger); }
.toast.info { border-left-color: var(--accent); }

.toast span {
  flex: 1;
}

.toast-action {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--accent-ink);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
}

.toast-close {
  border: none;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  flex-shrink: 0;
}

/* ---------- Busy overlay ---------- */

.busy-overlay {
  position: fixed;
  inset: 0;
  z-index: 1300;
  display: none;
  align-items: center;
  justify-content: center;
  background: var(--bg-overlay);
}

.busy-overlay.active {
  display: flex;
}

.busy-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: var(--text-1);
  font-weight: 700;
  font-size: 0.88rem;
}

.busy-card .spinner-ring {
  width: 34px;
  height: 34px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ==========================================================================
   Mobile — lessons paid for on theEdito/theDiff, applied from day one
   ========================================================================== */

@media (max-width: 760px) {
  .titlebar .brand span.brand-word {
    display: none; /* keep just the mark on very narrow titlebars */
  }

  .page {
    padding: 14px 12px 40px;
  }

  #placeSearchInput {
    font-size: 16px; /* stop iOS Safari auto-zoom on focus */
  }

  .hero-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .hero-condition-block {
    margin-left: 0;
    text-align: left;
  }

  .day-row {
    grid-template-columns: 56px 26px 1fr 76px 14px;
    padding: 10px 12px;
    gap: 6px;
  }

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

  .health-groups {
    grid-template-columns: 1fr;
  }

  #radarMapContainer {
    height: 280px;
  }

  .mh-bar-track {
    height: 50px;
  }

  .mh-time {
    font-size: 0.6rem;
  }
}

@media (max-width: 480px) {
  .use-location-btn span {
    display: none; /* icon-only on the narrowest screens; title/aria-label carry the text */
  }

  .hero-icon {
    font-size: 4.2rem;
  }

  .hero-temp {
    font-size: 2.4rem;
  }

  .loc-pill span.loc-pill-label-full {
    display: none;
  }

  .manage-locations-btn span,
  .add-current-btn span {
    display: none; /* icon-only on the narrowest screens; title carries the text */
  }

  .content-tab span,
  .content-tab {
    font-size: 0.76rem;
    padding: 0 10px;
  }
}
