:root {
  --sky: #0f1c2e;
  --sky-2: #15263c;
  --rule: #29405e;
  --ink: #ece6d6;
  --muted: #97a6bd;
  --sun: #f2b84b;
  --sun-dim: #9a7a43;
  --shade: #5d6f8c;
  --bad: #e58a7a;
  --font: "Barlow Semi Condensed", "Roboto Condensed", "Arial Narrow", system-ui, sans-serif;
  color-scheme: dark;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
:root.night {
  --sky: #0a0202;
  --sky-2: #140404;
  --rule: #3a0f0b;
  --ink: #ff5a45;
  --muted: #a9372b;
  --sun: #ff7a55;
  --sun-dim: #8a2a1d;
  --shade: #5c1a14;
  --bad: #ff5a45;
}
*, *::before, *::after { box-sizing: inherit; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--sky); color: var(--ink); }
body {
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
button {
  background: var(--sun); color: var(--sky); border: 0; border-radius: 999px;
  padding: .4em 1em; font-weight: 600; cursor: pointer;
}
button.quiet { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1px var(--rule); }
button:hover { filter: brightness(1.08); }
:focus-visible { outline: 2px solid var(--sun); outline-offset: 2px; }
input, select {
  background: var(--sky-2); border: 1px solid var(--rule); border-radius: 6px; padding: .3em .5em;
}

.top {
  display: flex; align-items: center; gap: 1rem 1.5rem; flex-wrap: wrap;
  padding: 1rem clamp(1rem, 4vw, 2.5rem); border-bottom: 1px solid var(--rule);
}
.top h1 { margin: 0; font-size: 1.6rem; font-weight: 700; letter-spacing: .01em; }
.loc { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; flex: 1; }
#locLabel { color: var(--muted); }
.manual {
  display: flex; gap: .8rem; flex-wrap: wrap; align-items: end;
  padding: 1rem clamp(1rem, 4vw, 2.5rem); border-bottom: 1px solid var(--rule);
}
.manual label { display: grid; gap: .2rem; color: var(--muted); font-size: .9rem; }
.manual input { width: 9rem; color: var(--ink); }

main { padding: 0 clamp(1rem, 4vw, 2.5rem) 3rem; max-width: 1200px; margin: 0 auto; }
h2 { font-size: 1.15rem; font-weight: 600; margin: 0; }
.status { max-width: 62ch; padding: 2rem 0 1rem; color: var(--muted); }
.status.error { color: var(--bad); }

/* Hero: the sky chart is the centrepiece */
.hero {
  display: grid; grid-template-columns: minmax(280px, 520px) 1fr; gap: 2rem 3rem;
  align-items: start; padding: 2rem 0 1.5rem;
}
.sky { margin: 0; }
.compass svg { width: 100%; height: auto; display: block; }
.legend { display: flex; flex-wrap: wrap; gap: .3rem 1.2rem; font-size: .85rem; color: var(--muted); margin-top: .6rem; justify-content: center; }
.sw { display: inline-block; width: 22px; height: 0; vertical-align: middle; margin-right: .4rem; border-top: 4px solid var(--sun); }
.sw.dim { border-top: 3px solid var(--sun-dim); }
.sw.shade { border-top: 2px dashed var(--shade); }

.detail .when { font-size: clamp(1.9rem, 4.5vw, 2.8rem); font-weight: 700; line-height: 1.05; margin: 0; }
.detail .sub { color: var(--muted); margin: .3rem 0 1rem; font-size: 1.05rem; }
.stars { color: var(--sun); letter-spacing: .08em; font-size: 1.35rem; white-space: nowrap; }
.stars .off { color: var(--rule); }
.verdict { display: flex; align-items: baseline; gap: .8rem; flex-wrap: wrap; margin-bottom: 1.2rem; }
.verdict .word { font-weight: 600; }
.look { font-size: 1.15rem; max-width: 46ch; margin: 0 0 1.4rem; }
.events { width: 100%; border-collapse: collapse; margin-bottom: 1.2rem; }
.events th, .events td { text-align: left; padding: .35rem .6rem .35rem 0; border-bottom: 1px solid var(--rule); font-weight: 400; }
.events th { color: var(--muted); font-weight: 500; }
.events tr.key td { color: var(--sun); }
.events tr.shadow td { color: var(--shade); }
:root.night .events tr.shadow td { color: var(--muted); }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: .9rem 1.2rem; margin: 0 0 1.2rem; }
.facts div { display: grid; }
.facts dt { color: var(--muted); font-size: .85rem; }
.facts dd { margin: 0; font-size: 1.2rem; font-weight: 600; }
.actions { display: flex; gap: .6rem; flex-wrap: wrap; }
.countdown { color: var(--sun); font-weight: 600; }

/* Horizon panorama */
.horizon { grid-column: 1 / -1; margin: 0; }
.horizon svg { width: 100%; height: auto; display: block; }
.horizon text { font-family: var(--font); fill: var(--muted); }
.horizon .card { fill: var(--ink); font-weight: 700; }
.hzctl { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; margin-top: .5rem; color: var(--muted); font-size: .9rem; }
.hzctl label { display: flex; align-items: center; gap: .4rem; }
.hzctl select { min-height: 36px; color: var(--ink); max-width: 100%; }
.filebtn {
  display: inline-flex; align-items: center; min-height: 36px; padding: .25em .9em;
  border-radius: 999px; box-shadow: inset 0 0 0 1px var(--rule); color: var(--ink);
  font-size: .85rem; font-weight: 600; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.filebtn:hover { background: var(--sky-2); }
.vh { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; opacity: 0; }
.vh:focus-visible + .filebtn { outline: 2px solid var(--sun); outline-offset: 2px; }
@media (pointer: coarse) { .hzctl select, .filebtn { min-height: 44px; } }
.horizon figcaption { color: var(--muted); font-size: .85rem; margin-top: .4rem; }

/* Live strip */
.live { border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); padding: 1rem 0; display: flex; gap: 1rem 2rem; align-items: baseline; flex-wrap: wrap; }
.live dl { display: flex; flex-wrap: wrap; gap: .5rem 2rem; margin: 0; }
.live dl div { display: grid; }
.live dt { color: var(--muted); font-size: .8rem; }
.live dd { margin: 0; font-weight: 600; }

/* Pass list */
.passbar { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: .6rem 1.5rem; padding: 1.5rem 0 .6rem; }
.controls { display: flex; gap: 1.2rem; flex-wrap: wrap; color: var(--muted); font-size: .95rem; align-items: center; }
.controls label { display: flex; align-items: center; gap: .4rem; }
.night-group { margin-top: 1.2rem; }
.night-group h3 { font-size: .95rem; font-weight: 600; color: var(--muted); margin: 0 0 .2rem; padding-bottom: .3rem; border-bottom: 1px solid var(--rule); }
.row {
  display: grid; width: 100%; text-align: left; align-items: center;
  grid-template-columns: 7.5rem 7rem 4.5rem 4.5rem 4.5rem 1fr;
  gap: .5rem 1rem; padding: .55rem .5rem; border: 0; border-bottom: 1px solid var(--rule);
  border-radius: 0; background: transparent; color: var(--ink); font-weight: 400;
}
.row:hover { background: var(--sky-2); filter: none; }
.row[aria-current="true"] { background: var(--sky-2); box-shadow: inset 3px 0 0 var(--sun); }
.row .t { font-weight: 600; }
.row .stars { font-size: 1rem; }
.row .m, .row .muted { color: var(--muted); }
.row.invisible { color: var(--muted); }
.row.invisible .t { font-weight: 500; }
.head-row { display: grid; grid-template-columns: 7.5rem 7rem 4.5rem 4.5rem 4.5rem 1fr; gap: 1rem; padding: .4rem .5rem; color: var(--muted); font-size: .8rem; }
.empty { color: var(--muted); padding: 1rem 0; max-width: 60ch; }

.foot { color: var(--muted); font-size: .85rem; margin-top: 2.5rem; max-width: 80ch; }
.foot p { margin: .3rem 0; }
.warn { color: var(--bad); }

/* SVG chart text */
.compass text { font-family: var(--font); fill: var(--muted); }
.compass .card { fill: var(--ink); font-weight: 700; }

@media (max-width: 820px) {
  .top { gap: .6rem 1rem; }
  .top h1 { flex: 1; }
  .loc { order: 3; flex-basis: 100%; }
  .loc button, #btnNight { font-size: .9rem; padding: .35em .8em; }
  #locLabel { flex-basis: 100%; }
  .hero { grid-template-columns: 1fr; padding-top: 1rem; }
  .events { font-size: .9rem; }
  .events td, .events th { padding-right: .45rem; white-space: nowrap; }
  .events td:first-child { white-space: normal; }
  .sky { max-width: 460px; margin: 0 auto; width: 100%; }
  .row, .head-row { grid-template-columns: 1fr auto; }
  .row > :nth-child(n+3), .head-row { display: none; }
  .row .mobile { display: block; grid-column: 1 / -1; color: var(--muted); font-size: .9rem; }
}
.row .mobile { display: none; }
@media (max-width: 820px) { .row .mobile { display: block; } }
@media (prefers-reduced-motion: no-preference) {
  .track-lit { stroke-dasharray: var(--len); stroke-dashoffset: var(--len); animation: draw 1.4s ease-out forwards; }
  @keyframes draw { to { stroke-dashoffset: 0; } }
}
