:root {
  --bg: #f6f6f3;
  --surface: #ffffff;
  --ink: #16181b;
  --muted: #474c54;
  --line: #c6c8c2;
  --soft: #ecece7;
  --accent: #8a4600;
  --accent-ink: #ffffff;
  --focus: #0b5cad;
  --warn: #9a2a12;
  --r: 4px;
  --num: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --head: "Avenir Next", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121314;
    --surface: #1a1c1e;
    --ink: #ece9e2;
    --muted: #bdb9b0;
    --line: #3b3e42;
    --soft: #232528;
    --accent: #f0b25a;
    --accent-ink: #1a1206;
    --focus: #8cc4ff;
    --warn: #ff9a85;
  }
}
/* Red night view: everything dim red on black, for reading the phone at the telescope. */
body.night {
  --bg: #000000;
  --surface: #070000;
  --ink: #ff2a1a;
  --muted: #f01a0a;
  --line: #4a0a05;
  --soft: #140302;
  --accent: #ff2a1a;
  --accent-ink: #000000;
  --focus: #ff2a1a;
  --warn: #ff2a1a;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--accent); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid var(--focus); outline-offset: 2px;
}
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 0; background: var(--surface); padding: 8px 12px; z-index: 10; }
.skip:focus { left: 8px; }

.top { border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: 10px; padding: 12px 0; font: 700 19px/1 var(--head); color: var(--ink); text-decoration: none; letter-spacing: 0.01em; }
.brand-mark { width: 30px; height: 30px; }
.brand-mark .ring { fill: none; stroke: var(--ink); stroke-width: 2.2; }
.brand-mark .ticks { stroke: var(--ink); stroke-width: 2; }
.brand-mark .needle { stroke: var(--accent); stroke-width: 3; stroke-linecap: round; }

h1 { font: 750 clamp(27px, 4.2vw, 40px)/1.12 var(--head); margin: 22px 0 8px; letter-spacing: -0.01em; max-width: 24ch; }
h2 { font: 700 23px/1.25 var(--head); margin: 0 0 10px; }
h3 { font: 700 19px/1.3 var(--head); margin: 0; }
.lede { margin: 0 0 18px; max-width: 62ch; color: var(--muted); font-size: 18px; }

/* Form */
.setup { display: grid; gap: 0 32px; }
@media (min-width: 900px) {
  .setup { grid-template-columns: 1fr 1fr; }
  .setup > .block:nth-child(3) { grid-column: 2; grid-row: 1 / span 2; }
  .setup > .more { grid-column: 1 / -1; }
}
.block { padding: 14px 0 16px; border-top: 2px solid var(--ink); }
.bh { font: 700 19px/1.2 var(--head); margin: 0 0 10px; }
.place-now { margin: 0 0 10px; font-size: 18px; }
.place-now .coord { color: var(--muted); font-family: var(--num); font-size: 16px; white-space: nowrap; }
.f { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.f > span { font-weight: 600; font-size: 16px; }
input[type=text], input[type=search], input[type=date], input[type=time], select {
  font: inherit; font-size: 17px; color: var(--ink); background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); padding: 9px 10px; min-height: 46px; width: 100%; min-width: 0;
}
input::placeholder { color: var(--muted); opacity: 0.85; }
.when { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 640px) and (max-width: 899px) { .when { grid-template-columns: 1.4fr 1.2fr 0.8fr 1fr; } }
.combo { position: relative; }
.pick-list {
  position: absolute; z-index: 5; left: 0; right: 0; top: calc(100% + 2px); margin: 0; padding: 4px 0; list-style: none;
  background: var(--surface); border: 1px solid var(--ink); border-radius: var(--r); max-height: 320px; overflow-y: auto;
  box-shadow: 0 6px 18px rgb(0 0 0 / 0.18);
}
.pick-list li { padding: 9px 12px; cursor: pointer; line-height: 1.35; }
.pick-list li[aria-selected=true] { background: var(--soft); }
.pick-list li.none { cursor: default; color: var(--muted); }
.pick-list .reg { display: block; color: var(--muted); font-size: 16px; }
.row-btns { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-start; margin-top: 12px; }
.btn {
  font: 600 16px/1.2 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--surface);
  border: 1px solid var(--ink); border-radius: var(--r); padding: 11px 16px; min-height: 44px; cursor: pointer;
}
.btn:hover { background: var(--soft); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.quiet { border-color: var(--line); }
.btn.danger { background: var(--warn); border-color: var(--warn); color: var(--surface); }
.btn.icon { padding: 8px 12px; font-size: 16px; border-color: var(--line); }
.btn[aria-pressed=true] { background: var(--ink); color: var(--bg); }
.inline-more { margin-top: 12px; }
.inline-more > summary, .more > summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; list-style: none; }
.inline-more > summary::-webkit-details-marker, .more > summary::-webkit-details-marker { display: none; }
.inline-more > summary::before, .more > summary::before { content: ""; flex: none; width: 0; height: 0; margin-right: 10px; border-left: 7px solid currentColor; border-top: 5px solid transparent; border-bottom: 5px solid transparent; transition: transform .15s; }
.inline-more[open] > summary::before, .more[open] > summary::before { transform: rotate(90deg); }
.inline-more[open] > summary { margin-bottom: 8px; }
.coords, .own { display: grid; gap: 10px; }
@media (min-width: 520px) { .coords { grid-template-columns: 1fr 1fr; } .coords .btn { grid-column: 1; justify-self: start; } .coords .tz-f { grid-column: 1 / -1; } }
@media (min-width: 520px) { .own { grid-template-columns: 1fr 1fr 1fr; } .own .btn { justify-self: start; } }
.note { color: var(--muted); font-size: 16px; margin: 10px 0 0; }
.msg { margin: 8px 0 0; font-size: 16px; }
.msg:empty { display: none; }
.msg.warn { color: var(--warn); font-weight: 600; }
.chosen { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.chosen li { display: inline-flex; align-items: center; gap: 2px; padding-left: 12px; border: 1px solid var(--line); border-radius: 22px; background: var(--surface); min-height: 44px; max-width: 100%; }
.chosen .c-name { min-width: 0; overflow-wrap: anywhere; line-height: 1.25; padding: 4px 0; }
.chosen .x { flex: none; width: 44px; height: 42px; border: 0; background: none; color: var(--ink); cursor: pointer; border-radius: 22px; display: grid; place-items: center; }
.chosen .x:hover { background: var(--soft); }
.chosen .x svg { width: 16px; height: 16px; stroke: currentColor; stroke-width: 2; }
.ask { margin-top: 12px; padding: 12px; border: 1px solid var(--warn); border-radius: var(--r); }
.ask p { margin: 0 0 10px; }
.ask .btn { margin-right: 8px; }
.earlier-list { list-style: none; padding: 0; margin: 0; }
.earlier-list li { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--line); }
.earlier-list span { min-width: 0; overflow-wrap: anywhere; flex: 1 1 220px; }
.more { border-top: 2px solid var(--ink); padding: 6px 0 14px; }
.more-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); }
.checks { display: flex; flex-direction: column; justify-content: flex-end; gap: 4px; }
.chk { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.chk input { width: 22px; height: 22px; margin: 0; accent-color: var(--accent); }

/* Result */
.result { margin-top: 18px; padding-top: 16px; border-top: 4px double var(--ink); }
.res-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px 16px; }
.res-head h2 { margin: 0; font-size: 26px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.sky { margin: 12px 0 4px; }
.sky p { margin: 0 0 4px; max-width: 80ch; }
.key { color: var(--muted); font-size: 16px; margin: 6px 0 14px; max-width: 80ch; }
.cards { display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 270px), 1fr)); align-items: start; }
.empty { color: var(--muted); }
.card { background: var(--surface); border: 1px solid var(--line); border-top: 3px solid var(--ink); padding: 12px 14px 10px; min-width: 0; }
.card h3 { overflow-wrap: anywhere; }
.card .tid { font-family: var(--num); }
.card .tname { font-weight: 600; }
.card .tsub { margin: 2px 0 6px; color: var(--muted); font-size: 16px; line-height: 1.35; }
.card .best { margin: 0 0 8px; font-size: 16px; line-height: 1.4; }
.card .zen { margin: -4px 0 8px; font-size: 16px; line-height: 1.4; font-weight: 600; }
.card table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.card th { text-align: right; font-size: 16px; color: var(--muted); font-weight: 600; padding: 2px 4px; border-bottom: 1px solid var(--ink); }
.card th:first-child { text-align: left; }
.card td { padding: 3px 4px; border-bottom: 1px solid var(--soft); vertical-align: baseline; }
.card td.tm { white-space: nowrap; font-size: 16px; }
.card td.n { text-align: right; font: 700 21px/1.2 var(--num); white-space: nowrap; }
.card tr.peak td.n { color: var(--accent); }
body.night .card tr.peak td { box-shadow: inset 0 2px var(--ink), inset 0 -2px var(--ink); }
.card tr.low td { color: var(--muted); }
.card tr.low td.n { font-weight: 500; }
.card .lowtag { font: italic 500 15px/1 system-ui, sans-serif; }
.card tr.down td { color: var(--muted); font-style: italic; font-size: 16px; }
.card tr.down td:last-child { text-align: right; }
.card tr.down td.tm { white-space: normal; }
.card td.tm .rep { white-space: normal; }
body.night .card, body.night input, body.night select { background: var(--surface); }
body.night .lede, body.night .about { color: var(--muted); }
body.night .pick-list { box-shadow: none; }
body.night .btn.primary, body.night .btn[aria-pressed=true] { background: var(--soft); color: var(--ink); border-color: var(--ink); }

.toast {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 20; display: flex; gap: 12px; align-items: center;
  background: var(--ink); color: var(--bg); padding: 8px 8px 8px 16px; border-radius: var(--r); max-width: calc(100vw - 32px);
}
.toast[hidden] { display: none; }
.toast .btn { background: var(--bg); color: var(--ink); border-color: var(--bg); }

/* About */
.about { margin-top: 44px; }
.about section { margin-bottom: 30px; max-width: 72ch; }
.about p, .about li { max-width: 72ch; }
.steps { padding-left: 1.4em; }
.steps li { margin-bottom: 8px; }
.faq h3 { font-size: 18px; margin: 18px 0 4px; }
.faq p { margin: 0; }
.sources { color: var(--muted); font-size: 16px; max-width: 80ch; }

.foot { margin-top: 40px; padding: 22px 0 30px; border-top: 1px solid var(--line); color: var(--muted); font-size: 16px; }
.sb-footer p { margin: 0 0 10px; overflow-wrap: anywhere; }
.sb-more a, .sb-privacy a, .sb-credit a { color: var(--accent); }

.sheet { display: none; }

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }

/* Paper: only the sheet prints, black on white, big numbers. */
@page { margin: 11mm 10mm; }
.th-prt { display: none; }

@media print {
  :root, body.night {
    --bg: #fff; --surface: #fff; --ink: #000; --muted: #333; --line: #888; --soft: #ccc; --accent: #000;
  }
  body { background: #fff; color: #000; font-size: 10.5pt; }
  .top, main > .wrap, .foot, .toast, .skip { display: none !important; }
  .sheet { display: block; }
  .sh-wrap { width: 100%; border-collapse: collapse; }
  .sh-wrap > thead > tr > td, .sh-wrap > tbody > tr > td { padding: 0; }
  .sh-wrap h2 { font: 700 14pt/1.2 var(--head); margin: 0 0 4pt; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0 12pt; }
  .sh-wrap h2 .sh-night { font-weight: 600; font-size: 11pt; align-self: flex-end; }
  .sh-head p { margin: 0 0 1pt; font-size: 9pt; line-height: 1.25; }
  .sh-head .sh-key { margin-bottom: 5pt; }
  .sh-cards { display: flex; flex-wrap: wrap; gap: 6pt 9pt; align-items: flex-start; }
  .sh-cards > .card { flex: 0 0 calc((100% - 18pt) / 3); }
  .sheet .card { border: 1px solid #000; border-top: 2.5pt solid #000; padding: 5pt 6pt 4pt; break-inside: avoid; page-break-inside: avoid; }
  .sheet .card h3 { font-size: 12pt; line-height: 1.2; }
  .sheet .card.tall { break-inside: auto; page-break-inside: auto; }
  .sheet .card .th-scr { display: none; }
  .sheet .card .th-prt { display: inline; font-weight: 700; }
  .sheet .card .tsub { font-size: 8pt; margin: 0 0 1pt; color: #333; line-height: 1.2; }
  .sheet .card .best { font-size: 8pt; margin: 0 0 2pt; line-height: 1.2; }
  .sheet .card .zen { font-size: 8pt; margin: -1pt 0 2pt; line-height: 1.2; font-weight: 700; }
  .sheet .card th { font-size: 8.5pt; color: #000; padding: 1pt 2pt; border-bottom: 1px solid #000; }
  .sheet .card td { padding: 0.2pt 2pt; border-bottom: 0.5pt solid #bbb; line-height: 1; }
  .sheet .card td.tm { font-size: 10pt; }
  .sheet .card td.n { font-size: 12pt; line-height: 1; color: #000; }
  .sheet .card tr.peak td { border-top: 1.5pt solid #000; border-bottom: 1.5pt solid #000; }
  .sheet .card tr.peak td.n { color: #000; }
  .sheet .card tr.low td, .sheet .card tr.down td { color: #444; }
  .sheet .card tr.low td.n { font-weight: 400; }
  .sheet .card .lowtag { font-size: 8pt; }
  .sheet .card tr.down td { font-size: 8.5pt; }
}
