/* Design system from mockups — load after app.css */
:root {
  color-scheme: dark;
  --bg: #0b1020;
  --card: #131a2e;
  --card2: #182140;
  --line: #243052;
  --text: #e5e7eb;
  --muted: #8b93a7;
  --ex: #22c55e;
  --good: #84cc16;
  --fair: #eab308;
  --poor: #f97316;
  --bad: #ef4444;
  --accent: #7aa2ff;
}

/* Native <select> lists: keep dark in open dropdowns (Windows/Chrome) */
select,
select option,
select optgroup {
  background-color: #0f172a;
  color: #e2e8f0;
}
select:focus,
select:focus-visible {
  outline-color: #7aa2ff;
}
select option:checked,
select option:hover,
select option:focus {
  background-color: #1e293b;
  color: #e2e8f0;
}
.loc-pills .pill-set-default {
  border-color: #7aa2ff;
  border-width: 1.5px;
  color: #dbe7ff;
  background: rgba(122, 162, 255, 0.22);
  font-weight: 650;
  box-shadow: 0 0 0 1px rgba(122, 162, 255, 0.25);
}

body {
  background: var(--bg) !important;
  color: var(--text);
  font: 15px/1.45 Inter, system-ui, "Segoe UI", sans-serif;
  font-variant-numeric: tabular-nums;
}

.ico {
  width: 18px;
  height: 18px;
  flex: none;
  vertical-align: middle;
  display: inline-block;
  stroke-width: 2;
}
.ico-lg { width: 48px; height: 48px; }
.score-ring { display: block; flex: none; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 3px 10px;
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  vertical-align: middle;
}
.p-ex { background: rgba(34, 197, 94, 0.18); color: #22c55e; }
.p-good { background: rgba(132, 204, 22, 0.18); color: #84cc16; }
.p-fair { background: rgba(234, 179, 8, 0.18); color: #eab308; }
.p-poor { background: rgba(249, 115, 22, 0.18); color: #f97316; }
.p-bad { background: rgba(239, 68, 68, 0.25); color: #fca5a5; }
.veto-why {
  font-size: 11px;
  color: #fca5a5;
  margin-left: 6px;
  white-space: nowrap;
  font-weight: 500;
}

.tz-pill {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 14px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}
.tz-pill b { color: var(--text); }

.loc-pills { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.loc-pills a,
.loc-pills button,
.loc-pills .pill-loc {
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--line);
  font-size: 13px;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  font-family: inherit;
  appearance: none;
  line-height: 1.2;
}
.loc-pills .on,
.loc-pills span.on {
  background: rgba(122, 162, 255, 0.14);
  border-color: #7aa2ff;
  color: #c7d6ff;
}

.forecast-head {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.forecast-head h2 { margin: 0; font-size: 22px; }
.forecast-head h2 small { color: var(--muted); font-weight: 400; font-size: 14px; margin-left: 8px; }

/* Night cards — 3 visible, horizontal scroll for the rest */
.night-rail {
  display: flex;
  align-items: stretch;
  gap: 6px;
}
.night-nav {
  flex: none;
  width: 36px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--card2);
  color: var(--text);
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
}
.night-nav:hover { border-color: #64748b; }
.night-scroller {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  flex: 1;
  min-width: 0;
  padding: 10px 2px 10px;
  -webkit-overflow-scrolling: touch;
}
.night-scroller .card.night {
  flex: 0 0 calc((100% - 28px) / 3);
  scroll-snap-align: start;
  max-width: calc((100% - 28px) / 3);
}
@media (max-width: 900px) {
  .night-scroller .card.night {
    flex: 0 0 100%;
    max-width: 100%;
  }
  .night-nav { display: none; }
}
.card.night {
  padding: 16px;
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  min-width: 0;
  overflow: visible;
}
.card.night.good-night {
  border: 1.5px solid #22c55e;
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.1), 0 10px 40px rgba(34, 197, 94, 0.08);
}
.card.night.fair-night {
  border: 1.5px solid #eab308;
  box-shadow: 0 0 0 4px rgba(234, 179, 8, 0.12), 0 8px 28px rgba(234, 179, 8, 0.06);
}
.card.night.muted-night { opacity: 0.92; }
.card.night.fair-night.muted-night { opacity: 1; }
.card.night .top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.card.night .date { font-size: 20px; font-weight: 700; }
.card.night .sub { color: var(--muted); font-size: 13px; }
.card.night .wx { width: 48px; height: 48px; flex: none; }
.card.night .wx .ico { width: 48px; height: 48px; }
.card.night .mid { display: flex; align-items: center; gap: 18px; margin: 16px 0; }
.card.night .win { font-size: 14px; min-width: 0; }
.card.night .win b { font-size: 18px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card.night .win .win-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card.night .ring-tip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  margin-left: 4px;
  border-radius: 50%;
  border: 1px solid #64748b;
  color: #94a3b8;
  font-size: 10px;
  font-weight: 700;
  cursor: help;
  vertical-align: middle;
}
/* Stats follow card width (not viewport) — moon always full row */
.card.night {
  container-type: inline-size;
  container-name: night-card;
}
.card.night .facts {
  display: grid;
  grid-template-columns: 0.7fr 0.85fr 1.55fr; /* Cloud/Wind tighter, Moon roomy */
  gap: 8px;
  margin: 12px 0;
  align-items: stretch;
}
.card.night .fact-moon {
  grid-column: auto;
}
.card.night .fact {
  background: var(--card2);
  border-radius: 10px;
  padding: 8px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 4px;
  text-align: center;
  font-size: 12px;
  min-width: 0;
  overflow: hidden;
  min-height: 0;
  height: 100%;
}
.card.night .fact .fact-ico {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  margin: 2px 0;
}
.card.night .fact .fact-ico .ico,
.card.night .fact .ico {
  width: 26px;
  height: 26px;
  flex: none;
}
.card.night .fact-val {
  min-width: 0;
  width: 100%;
  overflow: hidden;
}
.card.night .fact-k {
  display: block;
  width: 100%;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.02em;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card.night .fact b {
  display: block;
  font-size: 13px;
  line-height: 1.25;
  white-space: normal;
  overflow: hidden;
  word-break: break-word;
}
.card.night .fact-moon .moon-copy {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: 100%;
  min-width: 0;
}
.card.night .fact-moon .moon-title,
.card.night .fact-moon b.moon-title {
  display: flex;
  flex-direction: column; /* phase + % on two lines */
  align-items: center;
  justify-content: center;
  flex-wrap: nowrap;
  gap: 1px;
  font-size: 13px;
  line-height: 1.2;
  white-space: normal !important;
  overflow: visible !important;
  word-break: normal !important;
  overflow-wrap: normal !important;
  max-width: 100%;
  min-width: 0;
}
.card.night .fact-moon .moon-phase {
  flex: none;
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
  text-align: center;
  line-height: 1.15;
  max-width: 100%;
  font-weight: 600;
}
.card.night .fact-moon .moon-ill {
  flex: none;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 14px;
}
.card.night .fact-moon .moon-rs {
  display: flex;
  flex-wrap: wrap; /* ↑+1 … may wrap; stays inside tile */
  justify-content: center;
  gap: 0 0.45em;
  margin-top: 2px;
  font-size: 12.5px;
  color: #e5e7eb;
  line-height: 1.3;
  letter-spacing: 0;
  overflow: visible;
  white-space: normal;
  max-width: 100%;
}
.card.night .fact-moon .moon-rs span {
  flex: none;
  white-space: nowrap;
}
.card.night .night-blurb {
  margin: 0 0 8px;
  font-size: 12px;
  line-height: 1.35;
  color: var(--muted);
}
.card.night .fact-wind .wind-at {
  font-size: 11px;
  color: #94a3b8;
  margin-top: 1px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.card.night .fact-wind .wind-dir {
  font-size: 12px;
  color: #d7dce8;
  margin-top: 2px;
  white-space: normal;
  overflow: hidden;
}
.card.night .fact-moon .moon-above { display: none; }
.card.night .bar {
  display: flex;
  gap: 2px;
  height: 28px;
  align-items: flex-end;
  margin-top: 6px;
}
.card.night .bar span { flex: 1; border-radius: 2px; min-width: 2px; background: #243052; }
.no-win-note { color: var(--muted); font-size: 13px; margin-top: 4px; }
.card.night .win b.win-miss { color: #cbd5e1 !important; font-weight: 600; }
.card.night .fact[title], .card.night .fact-moon { cursor: help; }

.no-window-banner {
  display: none !important; /* cards carry per-night empty state; no giant banner */
}

/* Meteogram */
/* Conditions / profiles — three stacked full-width rows */
.profile-stack {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.profile-stack .profile-row {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}
.profile-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-start;
}
.profile-chip {
  display: inline-flex;
  flex: 0 1 auto;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card2);
  width: max-content;
  max-width: 100%;
}
.profile-chip.on {
  border-color: #7aa2ff;
  box-shadow: 0 0 0 1px rgba(122, 162, 255, 0.35);
}
.profile-chip-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  width: 100%;
}

.meteogram-card {
  margin-top: 22px;
  padding: 18px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  min-height: 360px;
  max-width: 100%;
  overflow-x: hidden;
  box-sizing: border-box;
}
.meteogram-leg {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
  margin: 4px 0 12px;
}
.meteogram-leg i {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  vertical-align: -2px;
  margin-right: 5px;
}
.meteogram-leg .leg-score i { margin-right: 2px; }
.meteogram-leg .leg-score i:last-of-type { margin-right: 5px; }
.mg-frame {
  display: flex;
  align-items: flex-start;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}
.mg-ylabels {
  flex: none;
  width: 138px;
  position: relative;
  z-index: 2;
  background: var(--card);
  pointer-events: none;
  color: #c4cad8;
}
.mg-rlabels {
  flex: none;
  width: 72px;
  position: relative;
  z-index: 2;
  background: var(--card);
  pointer-events: none;
  color: #e5e7eb;
  border-left: 1px solid rgba(255,255,255,0.06);
}
.mg-rlabels .mg-rband {
  position: absolute;
  left: 0;
  right: 0;
  box-sizing: border-box;
  padding: 2px 6px 0 8px;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.mg-rlabels .mg-rnow {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: #e5e7eb;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.25;
  max-width: 100%;
}
.mg-rlabels .mg-rtick {
  position: absolute;
  left: 8px;
  right: 4px;
  font-size: 12px;
  color: #9aa3b8;
  transform: translateY(-50%);
  text-align: left;
  white-space: nowrap;
}
.mg-ylabels .mg-band-lab {
  position: absolute;
  left: 0;
  width: 134px;
  padding: 2px 6px 0 0;
  box-sizing: border-box;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.mg-ylabels .mg-band-lab strong {
  display: block;
  font-size: 14px;
  font-weight: 700;
  color: #e5e7eb;
}
.mg-ylabels .mg-band-lab .u { color: #e5e7eb; font-size: 15px; }
.mg-ylabels .mg-band-lab .hint {
  display: block;
  margin-top: 4px;
  font-size: 14px;
  line-height: 1.2;
  color: #e5e7eb;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mg-ylabels .mg-ytick {
  position: absolute;
  right: 4px;
  font-size: 14px;
  color: #e5e7eb;
  transform: translateY(-50%);
}
.mg-rlabels .mg-ytick,
.mg-rlabels .mg-nowv {
  font-size: 14px !important;
}
.mg-scroll {
  position: relative;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  cursor: grab;
}
.mg-scroll.is-dragging { cursor: grabbing; }
#meteogram-svg {
  display: block;
  /* width/height set in px by JS — do not stretch */
  max-width: none;
  height: auto !important;
  min-height: 0 !important;
  font-size: 13px;
  touch-action: pan-x;
  vertical-align: top;
}

/* Hourly table */
.hourly-card {
  margin-top: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  max-width: 100%;
}
.hourly-scroll {
  width: 100%;
  max-width: 100%;
  max-height: 640px;
  overflow-x: auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.hourly-card table {
  width: 100%;
  min-width: 960px;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: auto;
}
.hourly-card th {
  position: sticky;
  top: 0;
  background: var(--card);
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  z-index: 2;
  white-space: nowrap;
}
.hourly-card th small {
  text-transform: none;
  font-weight: 400;
  color: #5b647a;
  margin-left: 4px;
}
.hourly-card td {
  padding: 8px 14px;
  border-bottom: 1px solid #1d2642;
  vertical-align: middle;
  height: 38px;
  white-space: nowrap;
  font-size: 14px;
}
.hourly-card td.score-cell { position: relative; white-space: nowrap; }
.hourly-card tr.nh td {
  background: #182140;
  font-weight: 600;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  height: auto;
  white-space: normal;
}
.hourly-card tr.nh .muted { font-weight: 400; }
.hourly-card tr.day-collapse td {
  color: #7b8296;
  font-size: 13px;
  background: #0f1528;
  font-style: italic;
  white-space: normal;
}
.hourly-card tr.veto td { color: #9aa3b5; }
.hourly-card .cb {
  display: inline-block;
  width: 56px;
  height: 6px;
  background: #243052;
  border-radius: 3px;
  margin-right: 8px;
  vertical-align: middle;
  overflow: hidden;
}
.hourly-card .cb i {
  display: block;
  height: 100%;
  background: #cbd5e1;
  border-radius: 3px;
}
.hourly-card .tag {
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 6px;
  background: #0b1020;
  border: 1px solid var(--line);
  color: #c4cad8;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.hourly-card .veto-why {
  font-size: 14px;
  color: #f0b4b4;
  margin-left: 6px;
  white-space: normal;
}
.cell-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

/* Score tooltip — fixed via JS so overflow:auto on .hourly-card cannot clip it */
.score-cell { cursor: help; }
.score-tip {
  display: none;
  position: fixed;
  z-index: 4000;
  background: #1f2a4d;
  border: 1px solid #3b4a7a;
  border-radius: 10px;
  padding: 12px 14px;
  width: 280px;
  max-width: calc(100vw - 16px);
  font-size: 13px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
  white-space: normal;
  color: var(--text);
  pointer-events: none;
}
.score-tip.is-open { display: block; }
.score-tip .row { display: flex; justify-content: space-between; padding: 2px 0; gap: 12px; }
.score-tip .y { color: #86efac; }
.score-tip .n { color: #fca5a5; }
.score-tip .foot {
  border-top: 1px solid #3b4a7a;
  margin-top: 6px;
  padding-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.meteogram-tip {
  position: fixed;
  z-index: 4000;
  min-width: 240px;
  max-width: min(360px, 92vw);
  padding: 10px 12px;
  border-radius: 10px;
  background: #1f2a4d;
  border: 1px solid #3b4a7a;
  box-shadow: 0 12px 28px rgba(0,0,0,.45);
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
  pointer-events: none;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.meteogram-tip b { display: block; margin-bottom: 6px; font-size: 14px; }
.meteogram-tip .tip-muted { color: #9aa3b8; font-size: 12px; }
.meteogram-tip .tip-wx { margin: 0 0 8px; }
.meteogram-tip .tip-bd { border-top: 1px solid #3b4a7a; padding-top: 6px; margin-top: 2px; }
.meteogram-tip .tip-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 0;
  font-size: 13px;
}
.meteogram-tip .tip-row span:last-child {
  flex: none;
  font-variant-numeric: tabular-nums;
  color: #86efac;
}
.meteogram-tip .tip-row.tip-weak span:last-child { color: #fbbf24; }
.meteogram-tip .tip-row.tip-weak span:first-child { color: #fde68a; }
.card.night .cbar { cursor: help; }
@container night-card (max-width: 360px) {
  .card.night .facts { grid-template-columns: 0.65fr 0.8fr 1.6fr; }
  .card.night .fact-moon { grid-column: auto; }
  .card.night .fact-moon .moon-rs { font-size: 12px; }
}
@container night-card (max-width: 280px) {
  .card.night .facts { grid-template-columns: 1fr; }
  .card.night .fact-moon .moon-title { font-size: 13px; }
  .card.night .fact-moon .moon-rs { font-size: 12px; }
}
.card.night .moon-copy {
  min-width: 0;
  flex: 1;
}
.card.night .bar {
  align-items: flex-end;
  height: 78px;
  gap: 2px;
}
.card.night .bar .cbar,
.card.night .bar span.cbar {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  min-height: 3px;
  border-radius: 3px 3px 0 0;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.06);
}
.card.night .bar .cbar .pct,
.card.night .bar span.cbar i.pct {
  position: absolute;
  left: 50%;
  top: -20px;
  transform: translateX(-50%);
  font-size: 16px !important;
  font-weight: 800 !important;
  font-style: normal !important;
  color: #e8edf7 !important;
  white-space: nowrap;
  letter-spacing: 0;
  line-height: 1;
}
.card.night .bar .cbar .pct.dark,
.card.night .bar span.cbar i.pct.dark { color: #0f172a !important; top: 2px; }
.card.night .bar span.cbar i.pct.tight { font-size: 13px !important; letter-spacing: -0.03em; }
.card.night .bar-scale {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  color: #7b8296;
  margin-top: 2px;
}
.card.night .barl {
  display: flex;
  gap: 2px;
  font-size: 12px !important;
  color: #a8b0c4;
  margin-top: 6px;
}
.card.night .barl .cbar-h {
  flex: 1 1 0;
  min-width: 0;
  text-align: center;
  overflow: hidden;
  text-overflow: clip;
  font-variant-numeric: tabular-nums;
  font-size: 12px !important;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.hourly-card th:nth-child(7),
.hourly-card td:nth-child(7) {
  min-width: 7.5rem;
  white-space: nowrap;
}

.card.night {
  min-width: 0;
}

@media (max-width: 430px) {
  .forecast-head { flex-direction: column; align-items: flex-start; }
  .card.night .facts { grid-template-columns: 1fr; }
  .hourly-card td, .hourly-card th { padding: 8px 10px; }
}
