*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: 'IBM Plex Sans', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

a {
  color: var(--accent);
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}

.brand-logo {
  width: 2.5rem;
  height: 2.5rem;
  flex-shrink: 0;
  border-radius: 10px;
  object-fit: cover;
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.brand-title {
  font-family: 'IBM Plex Serif', Georgia, serif;
  font-weight: 600;
  letter-spacing: 0.02em;
  font-size: 1.15rem;
}

.brand-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.beta-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.28rem 0.65rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  line-height: 1.2;
  color: #fff;
  border: 1px solid #c62828;
  background: #d32f2f;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  user-select: none;
}

.settings-data-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.35rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: 44px;
  padding: 0.5rem 0.85rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  color: var(--text);
}

.btn-danger {
  background: color-mix(in srgb, var(--danger) 14%, var(--bg-elevated));
  border-color: color-mix(in srgb, var(--danger) 45%, var(--border));
  color: var(--danger);
  font-weight: 600;
}

.btn-danger:hover {
  background: color-mix(in srgb, var(--danger) 22%, var(--bg-elevated));
  border-color: color-mix(in srgb, var(--danger) 55%, var(--border));
}

.btn-danger:focus-visible {
  outline: 2px solid var(--danger);
  outline-offset: 2px;
}

.btn-ghost {
  background: transparent;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Panel actions: full width on phones; fixed max width, centered, on wide layouts (not header/nav) */
.panel .btn {
  display: flex;
  width: min(22rem, 100%);
  margin-left: auto;
  margin-right: auto;
  box-sizing: border-box;
}

.layout {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem 1.15rem calc(5.5rem + env(safe-area-inset-bottom));
}

/* Tonight dashboard: single vertical rhythm between blocks (strip had extra margin-bottom before). */
#dashboard-content {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

#dashboard-content > [data-metric='recommendation'] {
  margin: 0;
}

#dashboard-content > .panel {
  margin-bottom: 0;
}

/* Tonight: empty state — welcome + what the app does + Open Places */
.dashboard-empty__welcome {
  margin: 0 0 0.55rem;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text);
}

.dashboard-empty__about {
  margin: 0 0 0.65rem;
  line-height: 1.55;
  font-size: 0.95rem;
}

.dashboard-empty__about strong {
  font-weight: 600;
  color: var(--text);
}

.dashboard-empty__next {
  margin: 0 0 0.55rem;
  line-height: 1.5;
  font-size: 0.95rem;
}

.dashboard-empty__sub {
  margin: 0 0 1rem !important;
  font-size: 0.88rem;
  line-height: 1.5;
}

.dashboard-empty__cta {
  width: 100%;
  margin: 0;
  justify-content: center;
  gap: 0.45rem;
}

.panel {
  display: flow-root;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.25rem;
  margin-bottom: 1rem;
  min-width: 0;
  max-width: 100%;
}

.panel > h2:first-child {
  margin-top: 0;
}

.panel h2 {
  margin: 0 0 0.65rem;
  padding-top: 0.1rem;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.35;
}

.panel > p {
  margin: 0 0 0.55rem;
}

.panel > p:last-child {
  margin-bottom: 0;
}

/* Brief highlight when a metric updates after refresh */
[data-metric].metric-pulse {
  animation: metric-pulse-glow 0.65s ease-out 1;
}

@keyframes metric-pulse-glow {
  0% {
    box-shadow: 0 0 0 0 transparent;
  }
  40% {
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent);
  }
  100% {
    box-shadow: 0 0 0 0 transparent;
  }
}

.grid {
  display: grid;
  align-items: start;
  gap: 0.85rem;
}

/* Metric tiles share row height (same depth in each row) */
.grid.grid-3 {
  align-items: stretch;
}

@media (min-width: 700px) {
  .grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.stat {
  --stat-icon-w: clamp(3.25rem, 22%, 4.5rem);
  --stat-icon-gap: 0.85rem;
  /* Reserve one footnote line so cards with 2 text lines match depth of 3-line cards */
  --stat-footnote-line: calc(0.75rem * 1.45);

  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.35rem;
  padding: 1rem 1.15rem 1.1rem;
  border-radius: 12px;
  background: color-mix(in srgb, var(--bg) 65%, var(--bg-elevated));
  border: 1px solid var(--border);
  min-width: 0;
  height: 100%;
  align-self: stretch;
}

/* Icon column runs the full height of the label+value+footnote block; text sits beside it. */
.stat-head {
  display: flex;
  align-items: stretch;
  gap: var(--stat-icon-gap) 1rem;
  min-width: 0;
  flex: 1;
  min-height: 0;
}

.stat-icon {
  flex: 0 0 auto;
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--stat-icon-w);
  min-width: 3.25rem;
  padding: 0.35rem 0.25rem;
  border-radius: 10px;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, var(--bg-elevated));
  border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--border));
}

.stat-icon .fa-solid {
  font-size: clamp(2.15rem, 5.5vw, 3rem);
  line-height: 1;
  opacity: 0.95;
}

.stat-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.28rem;
}

.stat-label {
  margin: 0;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  line-height: 1.3;
}

.stat-value {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

/* Third row: always present so two-line tiles match three-line tile depth */
.stat-footnote-slot {
  flex: 0 0 auto;
  min-height: var(--stat-footnote-line);
  margin-top: 0.12rem;
  padding-top: 0.08rem;
  line-height: 1.45;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.stat-footnote {
  margin: 0;
  padding: 0;
  font-size: inherit;
  line-height: inherit;
  color: inherit;
}

.score-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  gap: 0.65rem 1rem;
  align-items: start;
  min-width: 0;
}

/* Row 1: score ring | moon. Row 2: explanations span full width below both columns. */
.score-panel__ring {
  min-width: 0;
  grid-column: 1;
  grid-row: 1;
}

.score-panel .score-moon {
  grid-column: 2;
  grid-row: 1;
}

.score-panel .score-explanations {
  grid-column: 1 / -1;
  grid-row: 2;
  margin-top: 0;
}

.score-ring {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-width: 0;
}

.score-narrative {
  margin: 0;
}

.score-explanations {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 0;
  padding: 0.75rem 0.85rem;
  min-width: 0;
  border-radius: 10px;
  background: color-mix(in srgb, var(--bg) 55%, var(--bg-elevated));
  border: 1px solid var(--border);
}

.score-explanation {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.45;
}

.score-explanation__icon {
  flex: 0 0 1.15rem;
  width: 1.15rem;
  margin-top: 0.12rem;
  text-align: center;
  color: var(--accent, #6b9fff);
  opacity: 0.92;
}

.score-explanation__icon .fa-solid {
  font-size: 0.95rem;
}

.score-explanation__text {
  flex: 1;
  min-width: 0;
}

/* Space before warnings: padding avoids margin collapsing with the score grid above */
.score-warnings {
  margin-top: 0;
  padding-top: 1.5rem;
}

.score-warnings--icons {
  padding-left: 0;
  list-style: none;
}

.score-warning-item {
  display: flex;
  align-items: flex-start;
  gap: 0.45rem;
  margin: 0.35rem 0 0;
}

.score-warning-item:first-child {
  margin-top: 0;
}

.score-warning-item__icon {
  flex: 0 0 1rem;
  margin-top: 0.1rem;
  color: var(--warning);
  opacity: 0.95;
}

.score-warning-item__icon .fa-solid {
  font-size: 0.85rem;
}

.score-warning-item__text {
  flex: 1;
  min-width: 0;
}

.score-meta__row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.score-moon {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  flex-shrink: 0;
  gap: 0.35rem;
  /* Match moon glyph width so the caption centers under the icon, not a wide column */
  width: clamp(3.25rem, 14vw, 5.25rem);
  text-align: center;
}

.score-moon__glyph {
  display: block;
  font-size: clamp(2.75rem, 11vw, 5rem);
  line-height: 1;
  user-select: none;
  filter: var(--moon-emoji-filter, none);
}

/* Forecast day cards: same grayscale moon as score ring */
.moon-phase-emoji {
  display: inline-block;
  font-size: 1.15em;
  line-height: 1;
  vertical-align: middle;
  margin-left: 0.2em;
  filter: var(--moon-emoji-filter, none);
}

.score-moon__caption {
  display: block;
  margin: 0;
  width: 100%;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.25;
  text-align: center;
  text-wrap: balance;
}

.score-num {
  width: 4.5rem;
  height: 4.5rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 700;
  border: 2px solid var(--accent);
  box-shadow: 0 0 24px var(--moon-glow);
  font-variant-numeric: tabular-nums;
}

/* Match score ring stroke + glow to pill colours (see --score-pill-* in themes.css) */
.score-num--excellent {
  border-color: var(--score-pill-excellent);
  box-shadow: 0 0 22px color-mix(in srgb, var(--score-pill-excellent) 28%, transparent);
}
.score-num--good {
  border-color: var(--score-pill-good);
  box-shadow: 0 0 22px color-mix(in srgb, var(--score-pill-good) 26%, transparent);
}
.score-num--fair {
  border-color: var(--score-pill-fair);
  box-shadow: 0 0 22px color-mix(in srgb, var(--score-pill-fair) 26%, transparent);
}
.score-num--poor {
  border-color: var(--score-pill-poor);
  box-shadow: 0 0 22px color-mix(in srgb, var(--score-pill-poor) 28%, transparent);
}
.score-num--bad {
  border-color: var(--score-pill-bad);
  box-shadow: 0 0 22px color-mix(in srgb, var(--score-pill-bad) 30%, transparent);
}

.score-meta {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid var(--border);
}

.pill-excellent {
  background: color-mix(in srgb, var(--score-pill-excellent) 20%, transparent);
  color: var(--score-pill-excellent);
  border-color: color-mix(in srgb, var(--score-pill-excellent) 38%, var(--border));
}
.pill-good {
  background: color-mix(in srgb, var(--score-pill-good) 18%, transparent);
  color: var(--score-pill-good);
  border-color: color-mix(in srgb, var(--score-pill-good) 35%, var(--border));
}
.pill-fair {
  background: color-mix(in srgb, var(--score-pill-fair) 18%, transparent);
  color: var(--score-pill-fair);
  border-color: color-mix(in srgb, var(--score-pill-fair) 35%, var(--border));
}
.pill-poor {
  background: color-mix(in srgb, var(--score-pill-poor) 20%, transparent);
  color: var(--score-pill-poor);
  border-color: color-mix(in srgb, var(--score-pill-poor) 38%, var(--border));
}
.pill-bad {
  background: color-mix(in srgb, var(--score-pill-bad) 22%, transparent);
  color: var(--score-pill-bad);
  border-color: color-mix(in srgb, var(--score-pill-bad) 40%, var(--border));
}

.banner {
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--accent-soft);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.banner.warn {
  border-color: color-mix(in srgb, var(--danger) 35%, var(--border));
}

#toast.toast {
  position: fixed;
  left: 50%;
  bottom: calc(4.75rem + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 60;
  max-width: min(92vw, 22rem);
  margin: 0;
  text-align: center;
  pointer-events: none;
  box-shadow: 0 6px 28px rgba(0, 0, 0, 0.18);
}

#toast.toast--ok {
  border-color: color-mix(in srgb, var(--success) 45%, var(--border));
  background: color-mix(in srgb, var(--success) 14%, var(--bg-elevated));
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  display: flex;
  justify-content: space-around;
  gap: 0.25rem;
  padding: 0.4rem 0.5rem calc(0.4rem + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
}

.nav-btn {
  flex: 1;
  min-height: 48px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.72rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  border-radius: 10px;
  cursor: pointer;
}

.nav-btn[aria-current='page'] {
  color: var(--text);
  background: var(--accent-soft);
}

.nav-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.28rem;
  line-height: 1;
  opacity: 0.95;
}

.nav-icon .fa-solid {
  font-size: 1em;
}

.section-title {
  margin: 0 0 0.75rem;
  font-size: 1.05rem;
  font-family: 'IBM Plex Serif', Georgia, serif;
  overflow-wrap: anywhere;
  line-height: 1.25;
}

.hidden {
  display: none !important;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
}

.field label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.field input,
.field select {
  min-height: 44px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  padding: 0.45rem 0.65rem;
  font: inherit;
}

.field select {
  cursor: pointer;
}

/* Native select arrows are inconsistent; use a centered chevron that follows theme colors */
.field-select-wrap {
  position: relative;
  display: block;
}

.field-select-wrap select {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 2.5rem;
  cursor: pointer;
}

.field-select-icon {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  font-size: 0.72rem;
  line-height: 1;
  opacity: 0.95;
}

.field-select-icon .fa-solid {
  display: block;
}

/* Places: single centered column on phone through large tablet; saved list above add/search */
.view-locations {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.view-locations > * {
  width: 100%;
  max-width: min(34rem, 100%);
}

.locations-list {
  min-width: 0;
}

.locations-stack {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  width: 100%;
}

.locations-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
}

.locations-form .field {
  margin-bottom: 0;
}

.locations-gps-btn {
  margin-top: 0.75rem;
}

.loc-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  margin-bottom: 0.5rem;
}

.loc-item.active {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 25%, transparent);
}

.muted {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Night timeline: in-flow flex segments (sum 100%) — full width on all viewports */
.night-timeline {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  margin-top: 0.75rem;
}

.night-timeline__track {
  display: flex;
  flex-direction: row;
  width: 100%;
  min-width: 0;
  height: 56px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.night-timeline__seg {
  min-width: 0;
  height: 100%;
  flex-shrink: 0;
}

.night-timeline__seg--civil {
  background: color-mix(in srgb, var(--accent) 22%, var(--bg-elevated));
}

.night-timeline__seg--between {
  background: color-mix(in srgb, var(--accent) 32%, var(--bg-elevated));
}

.night-timeline__seg--astro {
  background: color-mix(in srgb, var(--accent) 58%, var(--bg-elevated));
}

.night-timeline__labels {
  position: relative;
  width: 100%;
  min-width: 0;
  min-height: 6.5rem;
  margin-top: 0.65rem;
  padding: 0 0.35rem;
  box-sizing: border-box;
}

/* In-flow shim so the label strip always spans full panel width (only abs children otherwise). */
.night-timeline__labels::before {
  content: '';
  display: block;
  width: 100%;
  height: 0;
}

.night-timeline__label {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  text-align: center;
  max-width: min(6.5rem, 26vw);
  min-width: 0;
  font-size: 0.72rem;
  line-height: 1.25;
  color: var(--text-muted);
  overflow-wrap: anywhere;
}

/* Centered markers: keep within card; --nl set inline as percentage */
.night-timeline__label--edge-mid {
  left: clamp(14%, var(--nl, 50%), 86%);
  transform: translateX(-50%);
}

.night-timeline__label--edge-start {
  left: 0;
  transform: none;
  align-items: flex-start;
  text-align: left;
  max-width: min(48%, 11rem);
}

.night-timeline__label--edge-end {
  left: auto;
  right: 0;
  transform: none;
  align-items: flex-end;
  text-align: right;
  max-width: min(48%, 11rem);
}

.night-timeline__label--r0 {
  top: 0;
}

.night-timeline__label--r1 {
  top: 1.85rem;
}

.night-timeline__label--r2 {
  top: 3.65rem;
}

.night-timeline__name {
  font-weight: 600;
  color: var(--text);
  font-size: 0.78rem;
}

.night-timeline__time {
  font-variant-numeric: tabular-nums;
  font-size: 0.68rem;
}

.night-timeline__tick {
  width: 1px;
  height: 8px;
  background: color-mix(in srgb, var(--accent) 65%, var(--border));
  margin-bottom: 0.1rem;
  flex-shrink: 0;
}

/* Narrow viewports: list layout — no overlap, nothing past card edges */
@media (max-width: 720px) {
  .night-timeline__labels {
    position: static;
    min-height: 0;
    padding: 0;
    margin-top: 0.75rem;
  }

  .night-timeline__labels::before {
    display: none;
  }

  .night-timeline__label,
  .night-timeline__label--edge-start,
  .night-timeline__label--edge-end,
  .night-timeline__label--edge-mid {
    position: static;
    left: auto;
    right: auto;
    transform: none;
    max-width: 100%;
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem 0.75rem;
    padding: 0.45rem 0;
    border-bottom: 1px solid var(--border);
    text-align: left;
  }

  .night-timeline__label:last-child {
    border-bottom: none;
  }

  .night-timeline__label--r0,
  .night-timeline__label--r1,
  .night-timeline__label--r2 {
    top: auto;
  }

  .night-timeline__tick {
    display: none;
  }

  .night-timeline__name {
    flex: 1 1 8rem;
    min-width: 0;
  }

  .night-timeline__time {
    flex-shrink: 0;
  }
}

/* 48 h cloud chart: Y axis, grid, midnight lines, level baseline */
.cloud-chart {
  margin-top: 0.5rem;
}

.cloud-chart__plot-row {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 0.35rem;
  width: 100%;
  min-width: 0;
}

.cloud-chart__y-axis,
.cloud-chart__y-spacer {
  width: 2.35rem;
  flex-shrink: 0;
  box-sizing: border-box;
}

.cloud-chart__y-axis {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: var(--cloud-plot-h, 72px);
  padding-right: 0.2rem;
  font-size: 0.6rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  line-height: 1;
  text-align: right;
}

.cloud-chart__y-spacer {
  align-self: stretch;
}

.cloud-chart__plot-area {
  position: relative;
  flex: 1;
  min-width: 0;
}

.cloud-chart__overlay {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: var(--cloud-plot-h, 72px);
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.cloud-chart__h-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 0;
  border-top: 1px dashed color-mix(in srgb, var(--border) 88%, transparent);
}

.cloud-chart__midnight {
  position: absolute;
  top: 0;
  bottom: 0;
  border-left: 1px dashed color-mix(in srgb, var(--accent) 50%, var(--border));
  margin-left: -0.5px;
  opacity: 0.9;
}

.cloud-chart__plot {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 2px;
  align-items: stretch;
  height: var(--cloud-plot-h, 72px);
  border-bottom: 1px solid var(--border);
  box-sizing: border-box;
}

.cloud-chart__cell {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.cloud-chart__bar {
  width: 100%;
  min-height: 2px;
  border-radius: 3px 3px 0 0;
  background: var(--chart-line);
  opacity: 0.65;
}

.cloud-chart__times-row,
.cloud-chart__days-row {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 0.35rem;
  width: 100%;
  min-width: 0;
}

.cloud-chart__times-row {
  margin-top: 0.4rem;
}

.cloud-chart__times {
  display: flex;
  gap: 2px;
  flex: 1;
  min-width: 0;
  min-height: 1.15em;
  align-items: flex-start;
}

.cloud-chart__time-cell {
  flex: 1;
  min-width: 0;
  text-align: center;
}

.cloud-chart__time-tick {
  font-size: 0.62rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.cloud-chart__days {
  display: flex;
  flex: 1;
  min-width: 0;
  margin-top: 0.45rem;
  padding-top: 0.45rem;
  border-top: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
  gap: 0;
}

.cloud-chart__day-side {
  flex-shrink: 0;
  min-width: 0;
  text-align: center;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.03em;
}

@media (max-width: 380px) {
  .cloud-chart__y-axis,
  .cloud-chart__y-spacer {
    width: 2rem;
    font-size: 0.55rem;
  }
}

.hourly-row {
  display: grid;
  grid-template-columns: 3.5rem repeat(7, 1fr);
  gap: 0.25rem;
  font-size: 0.72rem;
  align-items: end;
  margin-bottom: 0.35rem;
}

.hourly-bar {
  background: color-mix(in srgb, var(--chart-line) 35%, var(--bg-elevated));
  border-radius: 4px;
  min-height: 4px;
}

.day-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.65rem 0.75rem;
  margin-bottom: 0.5rem;
}

.day-card h3 {
  margin: 0 0 0.35rem;
  font-size: 0.95rem;
}

.day-card__line {
  margin: 0.35rem 0 0;
  font-size: 0.88rem;
  line-height: 1.45;
}

.day-card__extras {
  margin: 0.35rem 0 0;
  font-size: 0.8rem;
  line-height: 1.4;
}

.day-card--clickable {
  cursor: pointer;
}

.day-card--clickable:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* <dialog> uses the top layer; without explicit color, UA can paint CanvasText (often black) on dark surfaces */
.forecast-day-dialog {
  border: none;
  padding: 0;
  max-width: calc(100vw - 1.5rem);
  width: min(36rem, 100vw - 1.5rem);
  background: transparent;
  color: var(--text);
}

.forecast-day-dialog::backdrop {
  background: color-mix(in srgb, var(--bg) 65%, #000);
  backdrop-filter: blur(3px);
}

.forecast-day-dialog__surface {
  display: flex;
  flex-direction: column;
  max-height: min(90vh, 52rem);
  overflow: hidden;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.42);
  color: var(--text);
}

.forecast-day-dialog__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  color: var(--text);
}

.forecast-day-dialog__title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  font-family: inherit;
  line-height: 1.3;
  color: var(--text);
}

.forecast-day-dialog__body {
  padding: 0.65rem 1rem 1rem;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  color: var(--text);
}

.settings-modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.about-dialog-brand {
  display: flex;
  justify-content: center;
  margin: 0 0 1rem;
}

.about-dialog-brand img {
  width: 5.5rem;
  height: 5.5rem;
  border-radius: 1.15rem;
  border: 1px solid var(--border);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.14);
}

.settings-copyright {
  margin: 1.25rem 0 0.5rem;
  font-size: 0.82rem;
  text-align: center;
}

.people-card {
  margin-bottom: 1.15rem;
}

.people-card:last-child {
  margin-bottom: 0;
}

.people-card__name {
  margin: 0 0 0.4rem;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text);
}

.app-dialog-prose {
  font-size: 0.9rem;
  line-height: 1.55;
}

.app-dialog-prose p {
  margin: 0 0 0.85rem;
}

.app-dialog-prose p:last-child {
  margin-bottom: 0;
}

.app-dialog-prose ul.credits-dialog__list {
  margin: 0 0 0.85rem;
  padding-left: 1.15rem;
}

.app-dialog-prose ul.credits-dialog__list li {
  margin-bottom: 0.45rem;
}

.app-dialog-prose ul.credits-dialog__list:last-child {
  margin-bottom: 0;
}

.app-dialog-prose__h {
  margin: 1rem 0 0.35rem;
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.app-dialog-prose__h:first-of-type {
  margin-top: 0.35rem;
}

.app-dialog-prose__foot {
  margin-top: 1rem !important;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  font-size: 0.82rem;
}

.forecast-day-dialog__body .panel {
  margin-bottom: 0;
}

.forecast-day-dialog .muted {
  color: var(--text-muted);
}

.forecast-day-dialog .score-warning-item__text {
  color: var(--text);
}

.forecast-day-dialog .score-warning-item__icon {
  color: var(--warning);
}

.forecast-day-dialog .score-num {
  color: var(--text);
}

.clear-cache-dialog__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
  align-items: center;
  margin-top: 1.15rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

@media (max-width: 520px) {
  .clear-cache-dialog__actions {
    flex-direction: column-reverse;
    align-items: stretch;
  }

  .clear-cache-dialog__actions .btn {
    width: 100%;
    justify-content: center;
  }
}

.forecast-day-dialog .score-moon__caption {
  color: var(--text-muted);
}

/* Forecast: highlight “best night” panel */
.panel.forecast-best-panel {
  background: color-mix(in srgb, rgb(34, 197, 94) 11%, var(--bg-elevated));
  border-color: color-mix(in srgb, rgb(34, 197, 94) 28%, var(--border));
}

.forecast-best-panel h2 {
  margin-top: 0;
}

.forecast-best-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem 0.65rem;
  margin: 0 0 0.5rem;
  font-size: 1rem;
  line-height: 1.45;
}

.forecast-best-score {
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}

.forecast-best-note {
  margin: 0.45rem 0 0;
  font-size: 0.85rem;
  line-height: 1.45;
}

hr.section-rule {
  border: none;
  border-top: 1px solid var(--border);
  margin: 0.35rem 0 1rem;
  width: 100%;
}

/* Tonight tab: verdict strip, countdowns, dew, planets, ISS */
.tonight-strip {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  padding: 0.75rem 0.9rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  margin-bottom: 0;
  background: var(--panel-bg, rgba(255, 255, 255, 0.02));
}

.tonight-strip__badge {
  display: inline-flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.35rem;
  flex-shrink: 0;
  width: fit-content;
  max-width: 100%;
}

.tonight-strip__eyebrow {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.75;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
}

.tonight-strip__verdict {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  width: 100%;
  box-sizing: border-box;
  font-weight: 700;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.2rem 0.55rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
}

.tonight-strip__verdict-icon {
  font-size: 0.95em;
  opacity: 0.95;
}

.tonight-strip__text {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.5;
  flex: 1;
  min-width: 0;
}

/* Whole-card tint by verdict (semantic colors from themes.css) */
.tonight-strip--go {
  background: color-mix(in srgb, var(--success) 13%, var(--bg-elevated));
  border-color: color-mix(in srgb, var(--success) 42%, var(--border));
}

.tonight-strip--wait {
  background: color-mix(in srgb, var(--warning) 13%, var(--bg-elevated));
  border-color: color-mix(in srgb, var(--warning) 42%, var(--border));
}

.tonight-strip--skip {
  background: color-mix(in srgb, var(--danger) 14%, var(--bg-elevated));
  border-color: color-mix(in srgb, var(--danger) 40%, var(--border));
}

.tonight-strip--go .tonight-strip__verdict {
  border-color: color-mix(in srgb, var(--success) 50%, var(--border));
  color: color-mix(in srgb, var(--success) 92%, var(--text));
  background: color-mix(in srgb, var(--bg-elevated) 55%, transparent);
}

.tonight-strip--wait .tonight-strip__verdict {
  border-color: color-mix(in srgb, var(--warning) 50%, var(--border));
  color: color-mix(in srgb, var(--warning) 88%, var(--text));
  background: color-mix(in srgb, var(--bg-elevated) 55%, transparent);
}

.tonight-strip--skip .tonight-strip__verdict {
  border-color: color-mix(in srgb, var(--danger) 48%, var(--border));
  color: color-mix(in srgb, var(--danger) 88%, var(--text));
  background: color-mix(in srgb, var(--bg-elevated) 55%, transparent);
}

@media (max-width: 520px) {
  .tonight-strip {
    flex-direction: column;
    align-items: stretch;
  }

  .tonight-strip__badge {
    align-self: flex-start;
  }
}

.panel--whats-next .panel-heading-row {
  margin-bottom: 0.25rem;
}

.panel--whats-next .panel-lead {
  margin: 0 0 0.65rem;
  font-size: 0.8rem;
  line-height: 1.45;
}

.countdown-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
  gap: 0.65rem;
  margin: 0;
  padding: 0;
}

.panel--whats-next .countdown-row {
  margin-bottom: 0.25rem;
}

.countdown-chip {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  padding: 0.55rem 0.65rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.12);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.countdown-chip:hover {
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.18);
}

.countdown-chip__icon {
  flex-shrink: 0;
  width: 1.35rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.95rem;
  padding-top: 0.1rem;
}

.countdown-chip__body {
  min-width: 0;
  flex: 1;
}

.countdown-chip__title {
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.25;
  margin-bottom: 0.15rem;
  color: var(--text, inherit);
}

.countdown-chip__value {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.countdown-chip__detail {
  font-size: 0.72rem;
  line-height: 1.35;
  margin-top: 0.2rem;
}

.dew-stats {
  margin: 0 0 0.55rem;
  font-size: 0.85rem;
  line-height: 1.5;
}

.dew-nudge {
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.45;
}

.bortle-expectation {
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.5;
}

ul.planet-row {
  list-style: none;
  padding-left: 0;
  margin: 0;
}

.planet-row__item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}

.planet-row__item:last-child {
  margin-bottom: 0;
}

.planet-row__glyph {
  flex: 0 0 auto;
  font-size: 1.45rem;
  line-height: 1.1;
  color: var(--accent);
}

.planet-row__main {
  flex: 1;
  min-width: 0;
}

.planet-row__line1 {
  margin: 0 0 0.28rem;
  line-height: 1.35;
}

.planet-row__line2 {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem 1rem;
  font-size: 0.78rem;
  margin: 0;
}

.planet-row__ev {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.planet-row__ev .fa-solid {
  font-size: 0.72rem;
  opacity: 0.88;
}

.panel-heading-with-icon {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.panel-heading-icon {
  color: var(--accent);
  font-size: 1.05em;
}

.iss-block__lead {
  margin: 0;
}

.iss-block__icon {
  color: var(--accent);
  margin-right: 0.15rem;
}

.iss-block__story {
  margin: 0.55rem 0 0;
  font-size: 0.88rem;
  line-height: 1.55;
}

.iss-block__story strong {
  font-weight: 600;
}

.planet-row__note {
  margin: 1.5rem 0 0;
  padding-top: 0.85rem;
  font-size: 0.78rem;
  line-height: 1.5;
}

.iss-note {
  margin: 0.35rem 0 0;
  font-size: 0.78rem;
}

.panel--compact h2 {
  font-size: 1rem;
}

.tag {
  display: inline-block;
  font-size: 0.7rem;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  margin-right: 0.35rem;
}

.list-plain {
  margin: 0;
  padding-left: 1.1rem;
}

kbd {
  font: inherit;
  font-size: 0.85em;
  border: 1px solid var(--border);
  padding: 0.1rem 0.35rem;
  border-radius: 6px;
}

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