:root {
  color-scheme: dark;
  font-family: Calibri, Carlito, Arial, sans-serif;
  background: #000;
  color: var(--ink);
  --paper: #141414;
  --ink: #fff;
  --accent: #ffdb3d;
  --fix-green: #0b351e;
  --line: var(--accent);
}
* { box-sizing: border-box; }
body { margin: 0; }
header {
  min-height: 70px; padding: .8rem max(1.2rem, calc((100% - 1120px)/2));
  padding-top: calc(.8rem + env(safe-area-inset-top, 0px));
  padding-bottom: 0;
  background: #000; color: var(--ink); display: flex; gap: 1rem;
  justify-content: center; align-items: center;
}
.mast { margin: 0; font-weight: 750; font-size: clamp(1.4rem, 3.75vw, 1.7rem); display: flex; flex-direction: column; align-items: center; gap: .2rem; text-align: center; }
.mark { display: block; object-fit: contain; width: clamp(6.5rem, 19vw, 8.75rem); height: auto; }
main { max-width: 1170px; padding: 0 1.2rem 2.5rem; margin: auto; text-align: center; }
body {
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.hero { padding: 0 0 .85rem; text-align: center; }
.hero p { margin-block: .2rem; }
.hero > .label, .hero .tagline { margin-block: 0; line-height: 1.2; }
.hero .label { color: var(--accent); font-size: 1.05rem; }
.sam-quote { margin: .25rem 0 0; color: var(--accent); }
.sam-label { margin: .1rem 0 0; color: var(--ink); font-size: 2.8rem; font-weight: 900; -webkit-text-stroke: .35px currentColor; }
.sam-brand { display: grid; justify-items: center; margin-bottom: -.55rem; }
.sam-graphic { display: block; object-fit: contain; }
.hero .tagline { max-width: 38rem; margin-inline: auto; font-size: 1rem; }
h2 { font: 550 1.7rem/1.12 Calibri, Carlito, Arial, sans-serif; margin: 0 0 .9rem; }
.observation-heading { font-size: 1rem; color: var(--accent); }
h2.observation-heading, .atmospheric-corrections h3 { font: 550 1.05rem/1.12 Calibri, Carlito, Arial, sans-serif; color: var(--ink); }
.observation-title { display: flex; justify-content: center; align-items: center; gap: .45rem; margin-bottom: .9rem; }
.observation-title h2 { display: flex; align-items: center; gap: .4rem; margin: 0; }
#altitude-heading, #reduction-heading { display: flex; align-items: center; justify-content: center; gap: .4rem; color: var(--accent); }
p, li { line-height: 1.5; }
p { margin: .65rem 0; }
.label { font-size: .82rem; font-weight: 750; letter-spacing: .14em; }
.workbench { display: grid; gap: 1rem; }
.position-inputs, .observation-fields, aside, form { display: grid; gap: 1rem; min-width: 0; }
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: clamp(1rem, 3vw, 1.6rem); min-width: 0; }
.live-gps[data-state="no-fix"] { background: #820e18; }
.live-gps[data-state="searching"] { background: #454545; }
.live-gps[data-state="fixed"] { background: var(--fix-green); }
.live-gps p { margin-block: .3rem; line-height: 1.3; }
#gps-status, #gps-fix-time { white-space: pre-line; }
#gps-heading, .gps-clock-display { color: var(--accent); }
#locate { justify-self: center; width: min(100%, 12rem); height: 3.5rem; padding-inline: .65rem; background: #fff; border: 1.5px solid #000; color: #000; opacity: 1; }
.live-gps[data-state="no-fix"] #locate { color: #b00020; }
.live-gps[data-state="fixed"] #locate { color: #007a2e; }
#gps-heading img { justify-self: end; }
#gps-heading { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: .4rem; margin-bottom: .4rem; font-size: 1.5rem; }
#sight button[type="submit"] { background: var(--fix-green); color: var(--ink); }
.gps-clock-display { font-size: 1.25rem; font-weight: 700; }
#gps-clock { color: var(--ink); font-size: 1.375rem; font-variant-numeric: tabular-nums; }
.live-gps .pair { margin-top: .6rem; }
.result { background: #1b1b1b; color: var(--ink); border-color: var(--line); }
.result .label { color: var(--accent); }
.compact-result { width: min(100%, 34rem); gap: .45rem; padding: .75rem; font-size: .9rem; }
.compact-result .result-heading { margin: 0; min-height: 2.25rem; align-content: center; font: 650 .9rem/1.25 Calibri, Carlito, Arial, sans-serif; }
.compact-result p { margin: .3rem 0; }
.compact-result dd { font-size: 1rem; }
.pair { display: grid; gap: .85rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.manual-coordinates { display: grid; grid-template-columns: minmax(0, 1fr); gap: .85rem; }
#position-inputs { background: var(--fix-green); }
#chart-freeze-time { justify-self: center; background: var(--fix-green); color: #fff; }
#chart-freeze-time[data-frozen="true"] { background: #a81e2d; }
#chart-location-heading:not([hidden]) {
  display: flex; align-items: center; justify-content: center; gap: .4rem;
  margin: 0; color: var(--accent); font-size: 1.05rem;
}
#chart-location-heading + #position-inputs { margin-top: -.55rem; }
.coordinate { display: grid; grid-template-columns: var(--coordinate-columns); --coordinate-columns: minmax(0, 1fr) 4.5rem 4.5rem 2.4rem minmax(0, 1fr); row-gap: .5rem; min-width: 0; margin: 0; padding: .65rem; border: 1px solid var(--line); border-radius: 7px; }
.coordinate-controls { grid-column: 1 / -1; display: grid; grid-template-columns: var(--coordinate-columns); min-width: 0; border-radius: 7px; background: #090909; box-shadow: inset 0 0 0 1px var(--line); }
.coordinate-controls > .fixed-number { grid-column: 2; }
.coordinate-minutes { display: contents; }
.coordinate-minutes > .fixed-number { grid-column: 3; }
.coordinate-controls :is(input, select) { border: 0; background: transparent; padding-inline: .2rem; }
.coordinate input { text-align: center; font-weight: 400; }
.coordinate-direction { grid-column: 4; align-self: center; justify-self: center; }
.coordinate-direction select { width: auto; max-width: 100%; padding-inline: 0; }
.coordinate-controls :is(input, select) { min-height: 42px; }
.coordinate legend { padding: 0 .3rem; font-size: .9rem; font-weight: 650; }
.sextant-entry, .sextant-controls {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(5rem, 24%);
}
.sextant-entry { row-gap: .35rem; }
.sextant-controls {
  grid-column: 1 / -1;
  border: 1px solid var(--line); border-radius: 7px; background: #090909;
}
.sextant-controls :is(input, select) { border: 0; background: transparent; }
.sextant-value { display: flex; align-items: center; justify-content: center; gap: .35rem; min-width: 0; }
.limb-control { display: grid; place-items: center; min-width: 0; border-inline-start: 1px solid var(--line); }
.limb-control select { width: auto; max-width: 100%; padding-inline: .2rem; }
.index-error { display: grid; gap: .35rem; align-content: end; }
.index-error .select-box,
#eye,
#eye + .fixed-number,
.atmospheric-corrections label > :is(input, .fixed-number) { width: min(100%, 10rem); justify-self: center; }
.index-error input { width: 6ch; border: 0; background: transparent; padding-inline: .2rem; }
select { text-align-last: center; }
.select-box { display: flex; justify-content: center; border: 1px solid var(--line); border-radius: 7px; background: #090909; }
.select-box select { width: auto; max-width: 100%; padding-inline: .2rem; border: 0; background: transparent; }
.position-source-box { align-items: center; gap: .35rem; }
.position-source { color: var(--accent); width: min(100%, 16rem); justify-self: center; }
.position-source-box::before { content: ''; width: 20px; height: 20px; flex: none; background: url(chart-icon.png) center / contain no-repeat; }
.position-source-box:has(option[value="gps"]:checked)::before { background-image: url(gps-icon.png); }
.atmospheric-corrections h3 { margin: 0; }
.atmospheric-corrections .pair { margin-top: .7rem; }
label { display: grid; gap: .35rem; align-content: end; font-size: .9rem; font-weight: 650; min-width: 0; }
#sight label:not(.live-toggle), #sight .coordinate legend { color: var(--accent); }
#sight #position-inputs :is(label, legend, select) { color: var(--ink); }
#sight #position-inputs .coordinate-caption { color: var(--accent); font-size: .8125rem; }
.coordinate-caption { justify-self: center; text-align: center; white-space: nowrap; }
.coordinate-caption:first-of-type { grid-column: 2; }
.coordinate-caption:last-of-type { grid-column: 3; }
@media (min-width: 460px) {
  .coordinate { grid-template-columns: max-content minmax(0, 1fr) max-content; gap: .45rem; align-items: center; }
  .coordinate-caption:first-of-type { grid-column: 1; grid-row: 1; }
  .coordinate-caption:last-of-type { grid-column: 3; grid-row: 1; }
  .coordinate-controls { grid-column: 2; grid-row: 1; }
}
input, select, button { font: inherit; text-align: center; min-height: 44px; border-radius: 7px; }
input, select { width: 100%; min-width: 0; background: #090909; color: var(--ink); border: 1px solid var(--line); padding: .55rem; }
#sextant-observation :is(input:not([type="checkbox"]), select), #sight-time-zone {
  font-size: 1rem; font-weight: 400; color: var(--ink); text-align: center;
}
.fixed-number {
  display: flex; align-items: center; justify-content: center; min-width: 0;
  border: 1px solid var(--line); border-radius: 7px; background: #090909;
  color: var(--ink); font-size: 1rem; font-weight: 400; white-space: pre;
}
#pressure + .fixed-number::before,
#temp + .fixed-number::before,
#eye + .fixed-number::before { content: ''; width: 20px; height: 20px; flex: none; margin-inline-end: .35rem; background: url(eye-icon.png) center / contain no-repeat; }
#pressure + .fixed-number::before { background-image: url(barometer-icon.png); }
#temp + .fixed-number::before { background-image: url(thermometer-icon.png); }
#index + .fixed-number::before { content: ''; width: 20px; height: 20px; flex: none; margin-inline-end: .35rem; background: url(index-error-icon.png) center / contain no-repeat; }
.fixed-number input { width: calc(var(--digits, 2) * 1ch + .2rem); padding-inline: .1rem; border: 0; background: transparent; }
#sight .fixed-number input.replace-value:focus { color: transparent; caret-color: var(--ink); }
.coordinate-controls .fixed-number, .sextant-controls .fixed-number, .index-error .fixed-number { border: 0; background: transparent; }
.index-error .fixed-number input { width: 1.25ch; padding-inline: 0; }
input::placeholder { color: #bbb; }
#body { color: var(--ink); font-size: 1.1875rem; }
#body optgroup { color: var(--accent); background: #000; font-size: .9375rem; }
#body option { color: var(--ink); font-size: .9375rem; }
#body-field .observation-heading { display: flex; align-items: center; justify-content: center; gap: .4rem; }
.celestial-icons { width: 2rem; height: 1.125rem; flex: none; background: url(celestial-bodies.png) left center / 200% 100% no-repeat; }
.celestial-icons-right { background-position: right center; }
#body-field .select-box, #body option { background: #000; }
.sight-date-box, .sight-time-box {
  display: flex; align-items: center; justify-content: center; gap: .25rem; padding-inline: .55rem;
  border: 1px solid var(--line); border-radius: 7px; background: #090909;
}
.sight-datetime input { width: auto; max-width: 100%; padding-inline: 0; border: 0; background: transparent; min-height: 42px; }
.sight-time-field { display: grid; min-width: 0; gap: .35rem; align-content: end; }
.sight-datetime { display: grid; gap: .85rem; }
.sight-time-box { white-space: nowrap; font-size: .9rem; font-weight: 650; }
#gps-sight-date { color: var(--ink); }
:is(#gps-sight-time, #gps-sight-date):not([hidden]) { display: inline-grid; place-items: center; min-height: 44px; padding: 0 .25rem; font-size: 1rem; font-variant-numeric: tabular-nums; }
.sight-datetime input::-webkit-calendar-picker-indicator { filter: brightness(0) saturate(100%) invert(88%) sepia(92%) saturate(721%) hue-rotate(333deg) brightness(103%) contrast(102%); }
.sight-time-box.has-picker input::-webkit-calendar-picker-indicator { display: none; }
#sight-time-picker { padding: 0 .15rem; flex: none; border: 0; background: transparent; color: var(--accent); }
#sight-time-picker svg { display: block; }
button { background: var(--accent); border: 1px solid var(--accent); color: #000; font-weight: 720; padding: .6rem 1rem; cursor: pointer; }
button.secondary { background: #202020; border-color: var(--line); color: var(--ink); }
button:hover { filter: brightness(.94); }
button:disabled { cursor: wait; opacity: .7; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
input:not([type="checkbox"]), select { -webkit-tap-highlight-color: transparent; }
::selection { background-color: transparent; text-shadow: none; text-decoration: underline; }
.feedback:empty, [hidden] { display: none; }
.feedback { margin: 0; }
.readings { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); margin: 1rem 0; gap: .8rem; }
.almanac-divider { border: 0; border-top: 1px solid var(--accent); margin: 1rem 0; }
.readings div { border-top: 1px solid var(--accent); padding-top: .55rem; }
.computed-detail { color: var(--accent); }
.computed-time { font-variant-numeric: tabular-nums; }
.computed-angle, .computed-azimuth { color: var(--accent); font-size: 1.25rem; font-weight: 700; }
#body-altitude #altitude-heading { min-height: 0; margin-bottom: 0; }
.celestial-body-panel { text-align: center; }
.celestial-body-panel :is(select, option) { text-align: center; text-align-last: center; }
#body-altitude { justify-self: center; row-gap: .2rem; text-align: center; }
#computed-altitude > p:first-of-type { margin-block: 0; }
#computed-altitude > .accent-divider { margin-block: .35rem; }
.altitude-scale meter { display: block; width: 100%; height: .8rem; accent-color: var(--accent); }
.altitude-scale { position: relative; margin: .45rem 0; }
.altitude-scale::before { content: ""; position: absolute; top: 0; left: 50%; width: 2px; height: .8rem; background: var(--ink); }
.altitude-scale-labels { display: grid; grid-template-columns: repeat(3, 1fr); color: var(--ink); font-size: .82rem; }
.altitude-scale-labels > :first-child { justify-self: start; }
.altitude-scale-labels > :last-child { justify-self: end; }
.live-toggle { display: inline-flex; justify-content: center; align-items: center; gap: .4rem; cursor: pointer; }
.live-toggle input { width: 1.05rem; min-height: 0; margin: 0; accent-color: var(--accent); }
@media (pointer: coarse) {
  input, select { font-size: 1rem; }
}
@media (min-width: 850px) and (orientation: landscape) and (pointer: coarse) {
  .observation-fields > .compact-result { width: 100%; }
}
dt { font-size: .9rem; }
dd { margin: .25rem 0 0; font: 1.2rem Calibri, Carlito, Arial, sans-serif; }
summary { cursor: pointer; font-weight: 650; }
ol { padding-left: 1.45rem; }
li + li { margin-top: .5rem; }
.panel a { color: var(--accent); }
.guide-panel { margin-top: 1rem; }
.reduce-sight-action { display: grid; gap: .35rem; }
.calculator-copyright { margin: 0; text-align: center; color: var(--ink); font-size: .7rem; }
.guide-panel .live-toggle { color: var(--ink); }
#guide-content { width: 100%; height: 65vh; margin-top: .75rem; border: 0; border-radius: 7px; }
@media (max-width: 440px) { .pair { grid-template-columns: 1fr; } }
@media (max-width: 440px) {
  .sight-datetime input { padding-inline: .15rem; }
  .sight-time-box { padding-inline: .2rem; gap: .15rem; }
}
.verdict { padding: .55rem .7rem; color: #000; border-radius: 5px; background: var(--accent); font-weight: 730; }
.verdict.green { background: #146c35; color: #fff; }
.verdict.orange { background: #ffad4d; color: #000; }
.verdict.red { background: #a91c29; color: #fff; }
.verdict.neutral { background: #eee; color: #000; }
#sight #close-results { justify-self: center; margin-top: 1rem; min-height: 1.75rem; padding: .15rem .45rem; font-size: .8125rem; }
.sight-stars { color: var(--accent); font-size: 1.25rem; letter-spacing: .12em; }

.sight-date-control { display: inline-flex; align-items: center; gap: .25rem; position: relative; }
#sight-date::-webkit-calendar-picker-indicator {
  position: absolute; inset-inline-start: 0; inset-block-start: 50%;
  transform: translateY(-50%); width: 20px; height: 1.5rem;
  margin: 0; padding: 0; opacity: 0; cursor: pointer;
}
.sight-date-icon {
  display: block; flex: none; position: relative; width: 13.33px; height: 11.33px; transform: translateY(1px);
  border: 2px solid var(--accent); border-radius: .15rem;
}
.sight-date-icon[hidden], #sight-time-picker[hidden],
#sight-date[readonly]::-webkit-calendar-picker-indicator,
#sight-time[readonly]::-webkit-calendar-picker-indicator { display: none; }
.sight-date-icon::before {
  content: ""; position: absolute; inset: -4px 1px auto; height: 4px;
  border-inline: 2px solid var(--accent);
}
.sight-date-icon::after {
  content: ""; position: absolute; inset: .125rem 0 auto; border-top: 2px solid var(--accent);
}
.sight-grade-divider { width: 3rem; margin-inline: auto; margin-bottom: 0; }

body {
  background: radial-gradient(ellipse at 50% 0, #241e09 0, #080808 23rem, #000 44rem);
  text-shadow: 0 1px 2px #000, 0 0 5px #0009;
}
input, button { text-shadow: inherit; }
select, option, #locate, .verdict:not(.green):not(.red), input:focus { text-shadow: none; }
header { background: transparent; }
.mast { letter-spacing: -.018em; text-shadow: 0 2px 12px #000; }
.hero { padding-bottom: 1.15rem; }
.hero::after, .sam-brand::after, .accent-divider {
  content: ""; display: block; width: 4rem; height: 2px; margin: .75rem auto 0;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
}
.accent-divider { border: 0; }
.mast > .accent-divider { margin-block: 0; }
.workbench > .accent-divider { margin-block: 0; }
#gps[hidden] + .accent-divider { display: none; }
.workbench > .panel, #sight > .panel, .guide-panel {
  background-image: linear-gradient(145deg, #ffffff0c, transparent 65%);
  box-shadow: 0 6px 18px #0007, inset 0 1px #ffffff1a;
}
.compact-result {
  background-image: linear-gradient(150deg, #ffdb3d0b, transparent 70%);
  box-shadow: inset 0 1px #ffffff13;
}
.gps-clock-display {
  width: fit-content; margin-inline: auto; padding: .35rem .85rem;
  border: 2px solid var(--accent); border-radius: 9px; background: #0004;
}
#sight button[type="submit"] {
  background-image: linear-gradient(180deg, #ffffff1a, transparent);
  box-shadow: 0 3px 10px #0006;
}
@media (prefers-reduced-motion: no-preference) {
  button { transition: filter 140ms ease, transform 140ms ease; }
  button:active:not(:disabled) { transform: translateY(1px); }
}

#chart-clock-display { margin-block: 0; padding: .2rem .65rem; font-size: .875rem; }
#chart-clock { color: var(--ink); font-size: 1.05rem; font-variant-numeric: tabular-nums; }
#pressure + .fixed-number > span:last-child { margin-inline-start: .3rem; }

#download-guide {
  background: transparent;
  border: 0;
  box-shadow: none;
  text-shadow: none;
  color: var(--accent);
  text-decoration: underline;
}

.guide-preview summary { cursor: pointer; color: var(--accent); text-shadow: none; padding: .65rem 0; min-height: 44px; }
.guide-preview iframe { display: block; width: 100%; height: 74vh; min-height: 320px; border: 0; background: white; }

.guide-preview .guide-close-label,
.guide-preview:not([open]) > iframe,
.guide-preview[open] .guide-open-label { display: none; }
.guide-preview[open] {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: #fff;
}
.guide-preview[open] > summary {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: .35rem 1rem;
  background: #0b0b0b;
}
.guide-preview[open] .guide-close-label { display: inline; }
.guide-preview[open] > iframe { height: 100%; min-height: 0; }
body:has(.guide-preview[open]) { overflow: hidden; }

.guide-preview > summary { display: block; list-style: none; }
.guide-preview > summary::-webkit-details-marker { display: none; }
.guide-preview:not([open]) .guide-open-label {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
}

.guide-preview:not([open]) > summary {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 .3rem;
  font-size: .86rem;
}
.guide-preview:not([open]) .guide-open-label { gap: .3rem; }

.guide-panel {
  width: fit-content;
  max-width: 100%;
  padding: .15rem .45rem;
  border-radius: 9px;
}
.guide-panel { margin-inline: auto; }
.guide-preview:not([open]) > summary { color: #fff; font-size: 1rem; }
