:root {
  --bg: #0e1116;
  --panel: #171c24;
  --line: #262d38;
  --text: #e6eaf0;
  --muted: #8b97a8;
  --ok: #46d17f;
  --warn: #e5a13a;
  --danger: #f2564b;
  --auth: #6fb3f2;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
}

#app {
  max-width: 40rem;
  margin: 0 auto;
  /* viewport-fit=cover lets the layout run under the notch and home indicator,
     so pad by whichever is larger: the design gutter or the device's safe area. */
  padding-top: max(1.5rem, env(safe-area-inset-top));
  padding-right: max(1.1rem, env(safe-area-inset-right));
  padding-bottom: max(3rem, env(safe-area-inset-bottom));
  padding-left: max(1.1rem, env(safe-area-inset-left));
}

.top {
  display: flex;
  align-items: center;
  gap: .6rem;
  margin: 0 0 1.5rem;
}
.masthead {
  font-size: .8rem;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0;
}
.masthead span { opacity: .55; }

/* ---- warnings sit above the altitude figure on purpose ---- */
.warnings { display: grid; gap: .6rem; margin-bottom: 1.25rem; }
.warning {
  border-radius: .6rem;
  padding: .8rem .9rem;
  font-size: .9rem;
  border: 1px solid;
  display: flex;
  gap: .6rem;
  align-items: flex-start;
}
.warning.warn { background: #2a2113; border-color: #5b4718; color: #f0cd8d; }
.warning.error { background: #2d1614; border-color: #6d2822; color: #f5a9a2; }
.warning-icon { flex: none; font-weight: 700; }

/* ---- headline ---- */
.altitude { margin-bottom: 1.75rem; }
.altitude-label {
  margin: 0;
  font-size: .78rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
}
.altitude-value {
  margin: .2rem 0 0;
  font-size: clamp(3.4rem, 17vw, 5.2rem);
  font-weight: 700;
  line-height: 1.02;
  letter-spacing: -.03em;
  color: var(--ok);
}
.altitude-value.restricted { color: var(--warn); }
.altitude-value.none { color: var(--danger); font-size: clamp(2.4rem, 11vw, 3.6rem); }
.altitude-value .unit { font-size: .34em; font-weight: 600; color: var(--muted); margin-left: .28em; letter-spacing: .01em; }

.reasons { list-style: none; margin: .9rem 0 0; padding: 0; display: grid; gap: .55rem; }
.reasons li {
  border-left: 3px solid var(--warn);
  padding: .1rem 0 .1rem .7rem;
  font-size: .92rem;
}
.reasons .reason-name { color: var(--muted); font-size: .85rem; }

.coords {
  margin: 0;
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: .01em;
}
.coords-dms {
  margin: .15rem 0 0;
  font-size: .85rem;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}
.accuracy { margin: .45rem 0 0; font-size: .82rem; color: var(--muted); }
.accuracy.caution { color: var(--warn); }

/* ---- lists ---- */
.panel { margin-bottom: 1.6rem; }
.panel h2 {
  font-size: .78rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 .7rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: .6rem;
}

.copy, .refresh {
  margin-left: auto;
  background: var(--panel);
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: .4rem;
  min-height: 32px;
  padding: .25rem .7rem;
  font: inherit;
  font-size: .7rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  cursor: pointer;
  touch-action: manipulation;
}
.copy:hover, .refresh:hover { border-color: #3a4453; color: var(--text); }
.refresh:disabled { opacity: .5; cursor: default; }

/* ---- pull to refresh ----
   Sits below the notch. Hidden by default; the script moves it down with the finger. */
.pull {
  position: fixed;
  top: calc(env(safe-area-inset-top) + .5rem);
  left: 50%;
  z-index: 10;
  transform: translate(-50%, -150%);
  opacity: 0;
  pointer-events: none;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: .35rem .9rem;
  font-size: .78rem;
  color: var(--muted);
  white-space: nowrap;
  transition: transform .2s ease, opacity .2s ease;
}
.pull.dragging { transition: none; }
.pull.ready, .pull.active { color: var(--text); }
.pull.active { transform: translate(-50%, 0); opacity: 1; }
@media (prefers-reduced-motion: reduce) { .pull { transition: none; } }
.panel.dim { opacity: .62; }

.zones { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.zone {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: .6rem;
  padding: .7rem .8rem;
  display: grid;
  grid-template-columns: 4.6rem 1fr;
  gap: .1rem .8rem;
  align-items: baseline;
}
.zone-dist { font-variant-numeric: tabular-nums; font-weight: 600; font-size: .95rem; }
.zone-dir {
  grid-column: 1;
  font-size: .74rem;
  letter-spacing: .1em;
  color: var(--muted);
  font-weight: 600;
}
.zone-name { grid-column: 2; grid-row: 1; font-size: .95rem; }
.zone-meta { grid-column: 2; grid-row: 2; font-size: .8rem; color: var(--muted); }
.tag {
  display: inline-block;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .06em;
  padding: .1rem .38rem;
  border-radius: .25rem;
  margin-right: .4rem;
  vertical-align: .05em;
}
.tag.prohibited { background: #3a1714; color: #ff8b81; }
.tag.auth { background: #16283c; color: var(--auth); }
.tag.temp { background: #2a2113; color: #f0cd8d; }

.source-link {
  color: var(--auth);
  text-decoration: underline;
  text-underline-offset: .15em;
  text-decoration-color: color-mix(in srgb, var(--auth) 45%, transparent);
}

/* ---- conditions ----
   Colour-coded, but deliberately never as large as the altitude figure: the ceiling is a
   legal limit and this is only whether the air is worth flying in. */
.verdict {
  margin: 0 0 .6rem;
  font-size: 1.05rem;
  font-weight: 650;
  color: var(--muted);
}
.verdict::before {
  content: "";
  display: inline-block;
  width: .6rem;
  height: .6rem;
  border-radius: 50%;
  margin-right: .5rem;
  background: currentColor;
  vertical-align: .05em;
}
.verdict.ok { color: var(--ok); }
.verdict.caution { color: var(--warn); }
.verdict.unsafe { color: var(--danger); }

.wx-reasons { list-style: none; margin: 0 0 .85rem; padding: 0; display: grid; gap: .4rem; }
.wx-reasons li {
  border-left: 3px solid var(--warn);
  padding: .1rem 0 .1rem .6rem;
  font-size: .86rem;
  line-height: 1.45;
}

.wx-now {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .5rem;
  margin-bottom: .7rem;
}
.wx-tile {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: .5rem;
  padding: .55rem .6rem;
  display: grid;
  gap: .12rem;
  min-width: 0;
}
.wx-tile-label {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}
.wx-tile-value {
  font-size: 1.15rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.wx-tile-unit { font-size: .62em; font-weight: 600; color: var(--muted); margin-left: .18em; }
.wx-tile-detail { font-size: .74rem; color: var(--muted); }

.wx-aloft { margin: 0 0 .8rem; font-size: .84rem; line-height: 1.5; }
.wx-aloft.muted { font-size: .8rem; }

/* The strip scrolls inside itself so the page body never gains a horizontal scrollbar. */
.wx-scroll { overflow-x: auto; margin: 0 -.15rem; padding: 0 .15rem .2rem; }
.wx-strip {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: .35rem;
  min-width: min-content;
}
.wx-slot {
  flex: none;
  width: 3.6rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: 2px solid var(--muted);
  border-radius: .45rem;
  padding: .4rem .3rem;
  display: grid;
  gap: .1rem;
  justify-items: center;
  font-variant-numeric: tabular-nums;
}
.wx-slot.ok { border-top-color: var(--ok); }
.wx-slot.caution { border-top-color: var(--warn); }
.wx-slot.unsafe { border-top-color: var(--danger); }
.wx-slot-time { font-size: .7rem; color: var(--muted); }
.wx-slot-wind { font-size: .95rem; font-weight: 650; }
.wx-slot-gust { font-size: .68rem; color: var(--muted); }
.wx-slot-rain { font-size: .68rem; color: var(--auth); }

.wx-window { margin: .7rem 0 0; font-size: .86rem; color: var(--ok); }
.wx-note { margin: .6rem 0 0; font-size: .74rem; color: var(--muted); line-height: 1.55; }
.wx-note.caution { color: var(--warn); }

.muted { color: var(--muted); font-weight: 400; letter-spacing: 0; text-transform: none; }

.status { color: var(--muted); font-size: .92rem; }

/* A non-blocking note: the answer on screen is still shown, just not fresh. It sits
   above the altitude figure, because it qualifies it. */
.notice {
  background: #2a2113;
  border: 1px solid #5b4718;
  color: #f0cd8d;
  border-radius: .6rem;
  padding: .8rem .9rem;
  font-size: .88rem;
  margin: 0 0 1.25rem;
}
.retry {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: .5rem;
  /* At least a 44px target, per touch guidance. */
  min-height: 44px;
  padding: .7rem 1.25rem;
  font: inherit;
  font-size: .95rem;
  cursor: pointer;
  touch-action: manipulation;
}
.retry:hover { border-color: #3a4453; }

.footer {
  margin-top: 2.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  font-size: .76rem;
  color: var(--muted);
  line-height: 1.65;
}
.footer a { color: var(--auth); }
