/* Night sky. Page colors are tokens (light/dark); the sky chart itself is always a night sky. */
:root {
  --bg: #f3f4f8;
  --panel: #ffffff;
  --line: #d9dde8;
  --text: #182033;
  --muted: #5b6579;
  --accent: #3b5bcc;
  --btn: #eef0f6;
  --btn-on: #dfe5fb;
  --input-bg: #f8f9fc;
  --warn: #9a4a00;
  --shadow: 0 1px 3px rgba(20, 30, 60, 0.06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0d18; --panel: #121729; --line: #252c45; --text: #dfe4f2; --muted: #8d97b0; --accent: #8fa8ff;
    --btn: #1b2238; --btn-on: #27315a; --input-bg: #0d1120; --warn: #ffb36b; --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0a0d18; --panel: #121729; --line: #252c45; --text: #dfe4f2; --muted: #8d97b0; --accent: #8fa8ff;
  --btn: #1b2238; --btn-on: #27315a; --input-bg: #0d1120; --warn: #ffb36b; --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, sans-serif;
}

.top {
  display: flex; align-items: center; gap: 8px;
  max-width: 1200px; margin: 0 auto; padding: 12px 16px 4px;
}
h1 { font-size: 20px; margin: 0; flex: 1; }
h2 { font-size: 16px; margin: 0 0 8px; }
h3 { font-size: 16px; margin: 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.hub-link { color: var(--muted); font-size: 13px; text-decoration: none; }
.hub-link:hover { color: var(--text); text-decoration: underline; }
/* "All projects" only on the hosted site (where ../ is the homepage), not from disk or in the app */
html.hosted:not(.installed) .hub-link[hidden] { display: inline; }

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  grid-template-areas: "sky controls" "sky moon" "sky tonight" "sky about";
  grid-template-rows: auto auto auto 1fr;
  align-items: start;
  gap: 14px;
  max-width: 1200px; margin: 0 auto; padding: 8px 16px 32px;
}
.controls { grid-area: controls; }
.sky { grid-area: sky; position: sticky; top: 8px; }
.moon { grid-area: moon; }
.tonight { grid-area: tonight; }
.about { grid-area: about; }

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; min-width: 0; box-shadow: var(--shadow);
}
.note, .muted { color: var(--muted); }
.note { font-size: 13px; margin: 6px 0 0; }
.about p { font-size: 13.5px; color: var(--muted); margin: 6px 0; }

/* controls */
.row { display: flex; gap: 8px; align-items: flex-end; margin-bottom: 8px; flex-wrap: wrap; }
label { display: flex; flex-direction: column; gap: 3px; font-size: 13px; color: var(--muted); min-width: 0; }
label.grow { flex: 1 1 180px; }
.coords label { flex: 1 1 120px; }
input, select {
  font: inherit; font-size: 15px; color: var(--text); background: var(--input-bg);
  border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; min-width: 0; width: 100%;
}
input[type="range"] { padding: 0; border: 0; background: transparent; accent-color: var(--accent); }
input[type="checkbox"] { width: auto; accent-color: var(--accent); }
button {
  font: inherit; font-size: 14px; color: var(--text); background: var(--btn);
  border: 1px solid var(--line); border-radius: 6px; padding: 7px 12px; cursor: pointer;
}
button:hover { border-color: var(--accent); }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
#pwa-install { margin-top: 10px; width: 100%; }

/* sky */
.sky-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.sky-head h2 { margin: 0; font-variant-numeric: tabular-nums; }
.facing { display: flex; align-items: center; gap: 4px; }
.facing .note { margin: 0 4px 0 0; }
.facing button { padding: 4px 9px; font-size: 13px; min-width: 2.2rem; }
.facing button[aria-pressed="true"] { background: var(--btn-on); border-color: var(--accent); font-weight: 600; }
.sky-wrap {
  position: relative;
  width: min(100%, max(300px, calc(100vh - 250px)));
  margin: 0 auto;
}
#sky { display: block; width: 100%; aspect-ratio: 1; touch-action: manipulation; }
.tip {
  position: absolute; pointer-events: none; white-space: nowrap;
  background: rgba(10, 14, 28, 0.9); color: #eef2ff; border: 1px solid rgba(160, 180, 230, 0.4);
  border-radius: 6px; padding: 3px 8px; font-size: 13px;
}
.timebar { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.timebar #play { flex: none; width: 2.6rem; padding: 6px 0; }
.timebar input { flex: 1; }
.timebar select { flex: none; width: auto; font-size: 13px; padding: 5px 4px; }
.scale { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin: 0 92px 0 50px; }
.toggles { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 8px; }
label.check { flex-direction: row; align-items: center; gap: 6px; font-size: 14px; color: var(--text); }

.details { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 10px; min-height: 5.5em; }
.details p { margin: 4px 0; font-size: 14px; }
.details .warn { color: var(--warn); }
dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 6px 0 0; font-size: 14px; }
dt { color: var(--muted); }
dd { margin: 0; font-variant-numeric: tabular-nums; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25); }

/* moon */
.moon-row { display: flex; gap: 14px; align-items: center; }
#moonPic { width: 104px; height: 104px; flex: none; }
.moon dl { flex: 1; margin: 0; font-size: 13.5px; }

/* tonight */
.sun-times { margin: 0 0 10px; }
.tonight-list { list-style: none; margin: 0; padding: 0; }
.tonight-list li { padding: 7px 0; border-top: 1px solid var(--line); }
.tonight-list li.off { opacity: 0.72; }
.tonight-list button {
  display: flex; align-items: center; gap: 7px; flex-wrap: wrap; width: 100%; text-align: left;
  background: none; border: 0; padding: 0; font-size: 14.5px;
}
.tonight-list button:hover b { text-decoration: underline; }
.tonight-list .muted { font-size: 13px; }
.tonight-list .desc { display: block; font-size: 13.5px; margin: 2px 0 0 17px; }

.pwa-toast {
  position: fixed; left: 50%; bottom: 1rem; transform: translateX(-50%); z-index: 60;
  display: flex; gap: .8rem; align-items: center; max-width: calc(100% - 2rem);
  padding: .6rem .7rem .6rem 1rem; border-radius: 12px;
  background: var(--panel); color: var(--text); border: 1px solid var(--line); box-shadow: 0 6px 24px rgba(0, 0, 0, .18);
}

/* phone / narrow: one column: controls, sky, tonight, moon, about */
@media (max-width: 820px) {
  .layout { grid-template-columns: minmax(0, 1fr); grid-template-areas: "controls" "sky" "tonight" "moon" "about"; grid-template-rows: none; gap: 12px; }
  .sky { position: static; }
  .sky-wrap { width: 100%; }
  .card { padding: 10px 12px; }
}
@media (max-width: 420px) {
  .scale { margin: 0 80px 0 46px; font-size: 10px; }
  .scale span:nth-child(2n) { visibility: hidden; }
  .sky { padding-inline: 8px; }
}
