:root {
  --bg: #0b1017;
  --panel: #121a24;
  --panel-2: #18222f;
  --line: #243243;
  --text: #e6edf5;
  --muted: #93a4b8;
  --measured: #45d6c8;
  --globe: #7fb4ff;
  --flat: #ffb224;
  --terminator: #ff7847;
  --observer: #ff5d6c;
  --own: #c79bff;
  --bad: #ff7d7d;
  --radius: 10px;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 0;
}

header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 24px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.brand h1 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0.01em;
}

.brand h1 a {
  color: inherit;
  text-decoration: none;
}

.brand p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}

#demos {
  /* The menu has a colour of its own, so that it reads as the way round the app and not as settings. */
  --nav: #252b4d;
  --nav-line: #47528f;
  --nav-hover: #2f3764;
  --nav-on: #4450ad;
  --tray: #12152b;
  --tray-line: #6b77cf;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  min-width: 0;
}

#demo-groups,
#demo-list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  max-width: 100%;
}

/* The lower row belongs to the heading that is open in the upper row. It is drawn as that heading's tray:
   boxed, set in from the bar, named after the heading, and pointed at by it. */
#demo-groups {
  padding-bottom: 9px;
}

#demo-list {
  align-self: stretch;
  padding: 4px 5px;
  border: 1px solid var(--tray-line);
  border-radius: 9px;
  background: var(--tray);
}

#demo-list button {
  padding: 4px 9px;
  font-size: 13px;
}

#demos button {
  background: var(--nav);
  border-color: var(--nav-line);
  color: #e2e5ff;
}

#demos button:hover {
  background: var(--nav-hover);
  border-color: #6471c4;
}

/* The demonstration or tour that is running, and "Take a tour". */
#demos button.active,
#demos button.primary {
  background: var(--nav-on);
  border-color: #8f9bf0;
  color: #fff;
}

/* The heading's name, at the start of its tray. It is left out where the bar has no room to spare for it. */
#demo-list .nav-label {
  display: none;
  flex: none;
  margin: 0 auto 0 4px;
  padding-right: 8px;
  white-space: nowrap;
}

@media (min-width: 1560px), (max-width: 720px) {
  #demo-list .nav-label {
    display: block;
  }
}

#demo-groups button.active,
#tour-start[aria-pressed='true'] {
  position: relative;
}

/* The pointer: a notch standing on the tray's top edge, under the middle of the open heading. */
#demo-groups button.active::after,
#tour-start[aria-pressed='true']::after {
  content: '';
  position: absolute;
  left: 50%;
  top: calc(100% + 2px);
  margin-left: -8px;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-bottom: 8px solid var(--tray-line);
}

/* A group is a tab: the one that is open is outlined, not filled like a running demonstration. */
#demo-groups button[data-group] {
  color: #c3c9f2;
}

#demo-groups button[data-group]:hover {
  color: #fff;
}

#demo-groups button[data-group].active {
  background: var(--tray);
  border-color: var(--tray-line);
  color: #fff;
  font-weight: 600;
}

.nav-label {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-right: 4px;
}

button,
select,
input[type='date'],
input[type='datetime-local'],
input[type='text'],
input[type='number'] {
  font: inherit;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 6px 10px;
}

button {
  cursor: pointer;
}

/* A link that looks and sits like a button. */
a.button {
  display: block;
  font: inherit;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 6px 10px;
  text-align: center;
  text-decoration: none;
}

a.button:hover {
  border-color: #3b516b;
  background: #1e2b3b;
}

a.button:focus-visible {
  outline: 2px solid var(--globe);
  outline-offset: 1px;
}

button:hover {
  border-color: #3b516b;
  background: #1e2b3b;
}

button.active,
button.primary {
  background: #1d4d8f;
  border-color: #2f6fc4;
}

button:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 2px solid var(--globe);
  outline-offset: 1px;
}

main {
  display: grid;
  grid-template-columns: var(--side-left, 270px) minmax(0, 1fr) var(--side-right, 350px);
  min-height: 0;
}

aside {
  overflow-y: auto;
  padding: 12px;
  background: var(--panel);
  min-height: 0;
}

#controls {
  border-right: 1px solid var(--line);
}

#results {
  border-left: 1px solid var(--line);
}

aside section {
  padding: 4px 0 14px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

aside section:last-child {
  border-bottom: 0;
  margin-bottom: 0;
}

h2 {
  margin: 0;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

/* The words of a heading are a button that folds its section away. */
.fold {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 0;
  margin: 0;
  padding: 2px 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
  text-align: left;
  cursor: pointer;
}

.fold:hover {
  border: 0;
  background: none;
  color: var(--text);
}

.fold::before {
  content: '';
  flex: none;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid currentColor;
  transition: transform 0.15s;
}

.fold[aria-expanded='false']::before {
  transform: rotate(-90deg);
}

aside section.folded {
  padding-bottom: 4px;
}

aside section.folded > :not(h2) {
  display: none !important;
}

/* The bar at the top of each sidebar: fold every section in it, or tuck the whole sidebar away at its edge. */
.side-head {
  position: sticky;
  top: -12px;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 6px;
  margin: -12px -12px 10px;
  padding: 8px 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.side-name {
  margin-right: auto;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

#results .side-name {
  margin-left: 4px;
}

.side-head button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  font-size: 12px;
  white-space: nowrap;
}

/* Tucked away: a strip at the edge of the screen, all of it the button that brings the sidebar back. */
@media (min-width: 1181px) and (min-height: 521px) {
  body.tuck-controls {
    --side-left: 34px;
  }
  body.tuck-results {
    --side-right: 34px;
  }
  body.tuck-controls #controls,
  body.tuck-results #results {
    padding: 0;
    overflow: hidden;
  }
  body.tuck-controls #controls > :not(.side-head),
  body.tuck-results #results > :not(.side-head),
  body.tuck-controls #controls .side-head > :not(.side-tuck),
  body.tuck-results #results .side-head > :not(.side-tuck) {
    display: none !important;
  }
  body.tuck-controls #controls .side-head,
  body.tuck-results #results .side-head {
    position: static;
    display: block;
    height: 100%;
    margin: 0;
    padding: 0;
    border: 0;
  }
  body.tuck-controls #controls .side-tuck,
  body.tuck-results #results .side-tuck {
    flex-direction: column;
    justify-content: flex-start;
    gap: 10px;
    width: 100%;
    height: 100%;
    padding: 12px 0;
    border: 0;
    border-radius: 0;
    background: none;
    color: var(--muted);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
  }
  body.tuck-controls #controls .side-tuck:hover,
  body.tuck-results #results .side-tuck:hover {
    background: var(--panel-2);
    color: var(--text);
  }
  /* The arrow goes first, at the top of the strip, and the name reads down it. */
  .side-tuck[aria-expanded='false'] .side-arrow {
    order: -1;
    font-size: 15px;
  }
  .side-tuck[aria-expanded='false'] .side-word {
    writing-mode: vertical-rl;
  }
}

/* "Take a tour" stays the main button; a ring shows while it is the tours that are listed beneath. */
#tour-start[aria-pressed='true'] {
  outline: 2px solid var(--tray-line);
  outline-offset: -1px;
}

/* Links to further down the page, on a phone only. */
#jump {
  display: none;
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.row > select,
.row > input[type='date'] {
  flex: 1;
  min-width: 0;
  max-width: 170px;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mini {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.mini input {
  width: 100%;
  min-width: 0;
}

.buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
}

.buttons button {
  padding: 6px 2px;
  font-size: 13px;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

input[type='range'] {
  width: 100%;
  accent-color: var(--globe);
}

output {
  font-variant-numeric: tabular-nums;
  color: var(--text);
  font-weight: 600;
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.4;
}

.hint a {
  color: var(--globe);
}

/* Anything marked hidden stays hidden, whatever its usual layout. */
[hidden] {
  display: none !important;
}

/* The sun-and-stars tool and the horizon tool each show only their own panels. */
body:not([data-mode='sky']) .sky-only,
body:not([data-mode='horizon']) .hz-only,
body:not([data-mode='flight']) .fl-only,
body:not([data-mode='space']) .sp-only,
body:not([data-mode='sky']):not([data-mode='space']) .clock-only {
  display: none;
}

/* ---------- views ---------- */

#views {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1.05fr) minmax(0, 1fr);
  gap: 8px;
  padding: 8px;
  min-height: 0;
  min-width: 0;
}

.view {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: #05080f;
  min-height: 0;
  min-width: 0;
  touch-action: none;
}

.view canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.view.sky canvas {
  cursor: grab;
}

/* The horizon and flight drawings are not dragged, so a finger on them scrolls the page. */
.view.hz,
.view.fl {
  touch-action: auto;
}

.view.hz canvas,
.view.fl canvas {
  cursor: default;
}

#views[data-mode='sky'] .view:is(.hz, .fl, .sp),
#views[data-mode='horizon'] .view:not(.hz),
#views[data-mode='flight'] .view:not(.fl),
#views[data-mode='space'] .view:not(.sp) {
  display: none;
}

/* The view from space is one picture, not a pair for each model, so it has the room of all four. */
.view.sp {
  grid-column: 1 / -1;
  grid-row: 2 / -1;
}

.view.sp canvas {
  cursor: grab;
}

/* It has no second pair of views to switch to. */
body[data-mode='space'] #view-tabs {
  display: none;
}

.label.space {
  font-size: 12px;
  color: #eef3f8;
}

.label.space.minor {
  font-size: 11px;
  color: var(--muted);
}

/* The buttons that move the camera in the view from space, when it is moving freely. Each works while it is held. */
.fly-pad {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 3;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.fly-pad button {
  padding: 6px 8px;
  font-size: 12px;
  background: rgba(8, 13, 20, 0.82);
  touch-action: none;
}

.fly-pad button.held {
  background: #1d4d8f;
  border-color: #2f6fc4;
}

@media (max-width: 720px) {
  /* Large enough for a thumb. */
  .fly-pad {
    top: 6px;
    right: 6px;
  }
  .fly-pad button {
    padding: 9px 7px;
  }
}

.sw.nose {
  background: #f2f6fa;
}

#view-bar {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

#mode-tabs {
  display: flex;
  gap: 6px;
}

#mode-tabs button {
  padding: 5px 12px;
}

/* A view's name, in its model's colour: blue for the globe and amber for the flat model, as in the tables. */
.view-title {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 3;
  padding: 3px 9px;
  border: 1px solid rgba(127, 180, 255, 0.45);
  border-radius: 6px;
  background: rgba(8, 13, 20, 0.82);
  color: var(--globe);
  font-weight: 650;
  font-size: 13px;
  pointer-events: none;
}

.view-title.flat {
  border-color: rgba(255, 178, 36, 0.45);
  color: var(--flat);
}

.view-title small {
  font-size: 12px;
  color: var(--muted);
  font-weight: 400;
  margin-left: 6px;
}

.legend {
  position: absolute;
  left: 8px;
  bottom: 8px;
  z-index: 3;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  padding: 4px 9px;
  border-radius: 6px;
  background: rgba(8, 13, 20, 0.78);
  font-size: 12px;
  color: var(--muted);
  pointer-events: none;
  max-width: calc(100% - 16px);
}

.sw {
  display: inline-block;
  width: 16px;
  height: 3px;
  border-radius: 2px;
  margin-right: 5px;
  vertical-align: middle;
}

.sw.measured {
  background: var(--measured);
}
.sw.flat {
  background: var(--flat);
}
.sw.terminator {
  background: var(--terminator);
}
.sw.own {
  background: var(--own);
}

.own-only {
  display: none;
}

.has-own .own-only {
  display: inline;
}

.labels {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 2;
}

.label {
  position: absolute;
  white-space: nowrap;
  font-size: 11px;
  line-height: 1;
  color: #dbe6f1;
  text-shadow:
    0 0 3px #000,
    0 0 6px #000;
  transform: translate(7px, -50%);
}

.label.city {
  opacity: 0.85;
}

.label.observer {
  color: var(--observer);
  font-weight: 700;
  font-size: 12px;
  transform: translate(9px, -120%);
}

.label.sun {
  color: #ffe2a0;
  font-weight: 600;
  font-size: 12px;
  transform: translate(12px, -50%);
}

.label.note {
  color: var(--muted);
  transform: translate(-50%, 8px);
}

/* The middle of the moon's shadow during an eclipse of the sun: named beneath its ring. */
.label.shadow {
  color: #fff;
  font-weight: 600;
  transform: translate(-50%, 16px);
}

.label.compass {
  font-size: 12px;
  font-weight: 700;
  transform: translate(-50%, 6px);
}

.label.compass.minor {
  font-weight: 400;
  opacity: 0.7;
}

.label.elev {
  opacity: 0.6;
  transform: translate(2px, -50%);
}

.label.measured {
  color: var(--measured);
  font-weight: 600;
  transform: translate(-50%, -50%);
}

.label.own {
  color: var(--own);
  font-weight: 600;
  transform: translate(16px, -50%);
}

.sky .label.sun {
  transform: translate(-50%, -50%);
}

/* The observer's sky has a few options of its own, behind the three dots in its corner. They act on both skies. */
.view-menu {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.view-menu-button {
  display: grid;
  place-items: center;
  width: 32px;
  height: 26px;
  min-height: 0;
  padding: 0;
  border-color: #3b4c60;
  border-radius: 6px;
  background: rgba(8, 13, 20, 0.82);
}

.view-menu-button svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.view-menu-button[aria-expanded='true'] {
  border-color: var(--globe);
}

.view-menu-list {
  display: grid;
  gap: 2px;
  padding: 6px 12px 6px 10px;
  border: 1px solid #3b4c60;
  border-radius: 8px;
  background: rgba(11, 16, 23, 0.96);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
  font-size: 13px;
  white-space: nowrap;
}

.readout {
  position: absolute;
  left: 8px;
  top: 40px;
  z-index: 3;
  padding: 5px 9px;
  border-radius: 6px;
  background: rgba(8, 13, 20, 0.8);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
  max-width: calc(100% - 16px);
  line-height: 1.35;
  white-space: pre-line;
}

.scope {
  position: absolute;
  right: 8px;
  bottom: 8px;
  z-index: 3;
  width: 132px;
  pointer-events: none;
  text-align: center;
}

.scope-lens {
  position: relative;
  width: 120px;
  height: 120px;
  margin: 0 auto;
  border-radius: 50%;
  overflow: hidden;
  background: #020305;
  border: 2px solid #5b6b7e;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.6);
}

.scope-sun {
  position: absolute;
  left: 50%;
  top: 50%;
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

.scope-ground {
  position: absolute;
  left: 0;
  right: 0;
  height: 200%;
  background: #1b241a;
  border-top: 1px solid #55664f;
}

.scope-caption {
  margin-top: 4px;
  padding: 3px 4px;
  border-radius: 5px;
  background: rgba(8, 13, 20, 0.8);
  font-size: 11px;
  line-height: 1.25;
  color: var(--text);
}

/* ---------- results ---------- */

#demo-card {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
}

#demo-card h2 {
  color: var(--text);
  font-size: 15px;
  text-transform: none;
  letter-spacing: 0;
}

#demo-claim {
  margin: 0;
  padding: 6px 9px;
  border-left: 3px solid var(--flat);
  background: rgba(255, 178, 36, 0.07);
  border-radius: 0 6px 6px 0;
  line-height: 1.4;
  font-size: 13px;
}

#demo-claim span {
  display: block;
  color: var(--flat);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

#views.waiting .view {
  opacity: 0.3;
  transition: opacity 0.2s;
}

#tour-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

#tour-step {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.tour-buttons {
  display: flex;
  gap: 5px;
}

.tour-buttons button {
  padding: 4px 11px;
}

.tour-buttons button:disabled {
  opacity: 0.4;
  cursor: default;
}

#tour-ask {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 10px;
  border-left: 3px solid var(--measured);
  background: rgba(69, 214, 200, 0.07);
  border-radius: 0 6px 6px 0;
}

#tour-ask span {
  color: var(--measured);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

#tour-ask p {
  margin: 0;
  line-height: 1.4;
  font-size: 14px;
}

#tour-ask button {
  align-self: flex-start;
}

/* Controls that belong to the argument on show. */
#demo-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

#demo-controls output {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* A picture the argument on show draws for itself. */
#demo-canvas {
  display: block;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0b131d;
}

/* Choosing the steps of a tour. */
.pick-group {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin: 0 0 8px;
  padding: 6px 10px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.pick-group legend {
  padding: 0 4px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.pick-group label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  cursor: pointer;
}

/* The steps of a tour of one's own, in the order they will be shown. */
.pick-order-name {
  margin: 10px 0 4px !important;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.pick-order {
  margin: 0 0 10px;
  padding-left: 26px;
  font-size: 13px;
}

.pick-order li {
  padding: 2px 0;
}

.pick-order li > span {
  display: inline-block;
  min-width: 11em;
}

.pick-order button {
  min-width: 28px;
  padding: 1px 6px;
  font-size: 13px;
  line-height: 1.3;
}

.tour-list {
  margin: 0 0 8px;
  padding-left: 20px;
  line-height: 1.45;
}

.tour-list li {
  margin-bottom: 6px;
}

#demo-body:empty {
  display: none;
}

#demo-body p {
  margin: 0 0 8px;
  line-height: 1.45;
}

#demo-body p:last-child {
  margin-bottom: 0;
}

#demo-body .try {
  color: var(--muted);
  font-size: 12.5px;
}

b.m,
th.measured {
  color: var(--measured);
}
b.g,
th.globe {
  color: var(--globe);
}
b.f,
th.flat {
  color: var(--flat);
}
b.o,
th.own {
  color: var(--own);
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
  font-size: 13px;
}

table.data th,
table.data td {
  text-align: right;
  padding: 4px 4px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

/* The name of a row may wrap, so that the columns of numbers always fit the panel. */
table.data th:first-child,
table.data td:first-child {
  text-align: left;
  color: var(--muted);
  font-weight: 400;
  white-space: normal;
}

table.data thead th {
  font-size: 12px;
  white-space: normal;
}

/* Beside the name of a row the "i" takes no room on its line, so it is never left on a line of its own.
   The cell keeps the room for it on the right. */
table.data td:first-child:has(.info) {
  padding-right: 23px;
}

table.data td:first-child .info {
  margin-right: -19px;
}

/* A row of bearings: each may put its compass point on a second line. */
table.data tr.brk td {
  white-space: normal;
}

/* Wording that depends on how the views are laid out: four at once, or one pair at a time. */
.on-phone {
  display: none;
}

td.bad {
  color: var(--bad);
  font-weight: 600;
}

td.good {
  color: var(--measured);
  font-weight: 600;
}

td.dim {
  color: var(--muted);
}

.bar-row {
  display: grid;
  grid-template-columns: 96px 1fr 58px;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 13px;
}

.bar-track {
  height: 10px;
  border-radius: 5px;
  background: var(--panel-2);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 5px;
  min-width: 2px;
}

.bar-value {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

/* ---------- own measurements ---------- */

.own-form {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 10px;
}

.own-form .form-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.own-form .fields {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.own-form .fields[hidden],
#air-fields[hidden] {
  display: none;
}

#air-fields .mini {
  flex-wrap: wrap;
  gap: 2px 6px;
}

.own-form input,
.own-form select {
  background: var(--panel);
}

.own-form .row > input[type='number'] {
  width: 84px;
  flex: none;
}

.own-form .row > input[type='text'] {
  flex: 1;
  min-width: 0;
  max-width: 190px;
}

.own-form input[type='datetime-local'] {
  flex: 1;
  min-width: 0;
}

.own-form #m-zone {
  flex: none;
  max-width: 150px;
}

.own-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.own-list:empty {
  display: none;
}

.own-card {
  border: 1px solid var(--line);
  border-left: 3px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.own-card.shown {
  border-left-color: var(--own);
  background: rgba(199, 155, 255, 0.06);
}

.own-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.own-head b {
  display: block;
}

.own-head small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  display: block;
}

.own-actions {
  display: flex;
  gap: 4px;
  flex: none;
}

.own-actions button {
  padding: 3px 8px;
  font-size: 12.5px;
}

#own-summary {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#own-summary:empty {
  display: none;
}

#own-summary .bar-row {
  margin-bottom: 0;
}

#fit-chart {
  width: 100%;
  height: 150px;
  display: block;
}

details summary {
  cursor: pointer;
  font-weight: 600;
}

details p {
  line-height: 1.5;
  color: #c9d5e2;
  margin: 8px 0 0;
}

code {
  font-family: ui-monospace, 'Cascadia Code', Consolas, monospace;
  font-size: 12px;
  background: var(--panel-2);
  padding: 1px 4px;
  border-radius: 4px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  background: #1d4d8f;
  padding: 8px 14px;
  border-radius: 8px;
  z-index: 10;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.5);
}

/* ---------- stars and routes ---------- */

.sw.route {
  background: #f2f6fa;
}

.route-only {
  display: none;
}

.has-route .route-only {
  display: inline;
}

.label.star {
  color: #f4f7ff;
  font-weight: 600;
  transform: translate(-50%, -50%);
}

.label.route {
  color: #f2f6fa;
  font-weight: 600;
  font-size: 12px;
  transform: translate(8px, -50%);
}

.label.route.distance {
  transform: translate(-50%, -160%);
  background: rgba(8, 13, 20, 0.7);
  padding: 3px 6px;
  border-radius: 5px;
  text-shadow: none;
}

.route-pick select {
  flex: 1;
  min-width: 0;
  max-width: none;
}

.route-pick button {
  flex: none;
  padding: 4px 9px;
}

#route-detail {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#route-detail th:first-child {
  color: var(--text);
  font-weight: 600;
}

#route-table td:first-child {
  padding-left: 0;
  white-space: normal;
}

#route-table button {
  padding: 3px 7px;
  font-size: 12.5px;
  text-align: left;
}

#route-table tr.active button {
  background: #1d4d8f;
  border-color: #2f6fc4;
}

#star-fit-bars .bar-row:last-child {
  margin-bottom: 0;
}

/* The magnified sun has nothing to say while a star is being followed. The moon's inset stays. */
.has-stars:not(.has-moon) .scope {
  display: none;
}

.scope-moon {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: none;
}

#view-tabs {
  display: none;
}

/* Running the time: always in sight above the views, at the far end of the bar from the tools. */
#play-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

/* Only the sun-and-stars tool and the view from space have a time to run. */
body:not([data-mode='sky']):not([data-mode='space']) #play-bar {
  display: none;
}

#play-bar button,
#play-bar select {
  padding: 5px 12px;
}

#play-bar button {
  min-width: 70px;
}

/* Play is the one button that sets things moving, so it is the one that is green. */
button.play {
  background: #15803f;
  border-color: #3fd07c;
  color: #fff;
  font-weight: 600;
}

button.play:hover {
  background: #1a9a4c;
  border-color: #6be59d;
}

/* The moment on show: its date, its time of day, and the jumps to sunrise and the rest. A row of its own under the tools. */
#time-bar {
  flex: 1 1 100%;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

body:not([data-mode='sky']):not([data-mode='space']) #time-bar {
  display: none;
}

#time-bar input[type='date'] {
  flex: none;
  padding: 4px 8px;
}

.time-field {
  flex: 1 1 120px;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  margin: 0 4px;
}

.time-field input {
  flex: 1;
  min-width: 50px;
  margin: 0;
}

#time-label {
  font-weight: 600;
  white-space: nowrap;
}

#solar-time {
  margin-right: 2px;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

#jump-buttons {
  display: flex;
  gap: 6px;
}

#time-bar button {
  padding: 5px 10px;
}

#time-jump {
  display: none;
}

/* Where the bar has the room, the time controls go on the same line as the tools, between them and Play. */
@media (min-width: 1900px) {
  #view-bar {
    flex-wrap: nowrap;
  }
  #time-bar {
    order: 1;
    flex: 1 1 0;
    margin: 0 10px;
  }
  #play-bar {
    order: 2;
    margin-left: 0;
  }
}

@media (min-width: 1340px) and (min-height: 521px) {
  body.tuck-controls.tuck-results #view-bar {
    flex-wrap: nowrap;
  }
  body.tuck-controls.tuck-results #time-bar {
    order: 1;
    flex: 1 1 0;
    margin: 0 10px;
  }
  body.tuck-controls.tuck-results #play-bar {
    order: 2;
    margin-left: 0;
  }
}

/* ---------- over the horizon ---------- */

.qty .num {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12.5px;
}

.qty .num input {
  width: 82px;
  padding: 4px 6px;
  text-align: right;
}

.buttons.two {
  grid-template-columns: 1fr 1fr;
}

.buttons.three {
  grid-template-columns: 1fr 1fr 1fr;
}

.group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#hz-weather .form-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

#hz-weather .row > input {
  width: 84px;
  flex: none;
}

#fl-notice p,
#hz-flat-needs p {
  margin: 0 0 8px;
  line-height: 1.45;
}

#fl-notice p:last-child,
#hz-flat-needs p:last-child {
  margin-bottom: 0;
}

.own-card .verdict {
  margin: 0;
  line-height: 1.4;
  font-size: 13px;
}

.own-card > button {
  align-self: flex-start;
  padding: 4px 9px;
  font-size: 12.5px;
}

#hz-sunsets .row > input[type='number'] {
  width: 84px;
  flex: none;
}

#hz-sunsets .mini {
  flex-wrap: wrap;
  gap: 2px 6px;
}

#hz-sight {
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-left: 3px solid var(--globe);
  padding: 2px 0 2px 9px;
}

#hz-sight .hint {
  margin: 0;
}

body[data-mode='flight'] #kml-section {
  display: none;
}

.kml-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.kml-item small {
  display: block;
  color: var(--muted);
}

.kml-item button.active {
  border-color: var(--globe);
  color: var(--text);
}

#hz-view-note {
  border-left: 3px solid var(--line);
  padding: 2px 0 2px 9px;
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--muted);
}

#hz-view-note p {
  margin: 0 0 5px;
}

#hz-view-note a {
  color: var(--globe);
}

#hz-air th:first-child {
  text-align: left;
}

/* ---------- info boxes ---------- */

/* A label that carries an info button keeps its control at a usable width. */
#refraction {
  min-width: 128px;
  flex: none;
}

.info {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  padding: 0;
  margin-left: 3px;
  border-radius: 50%;
  border: 1px solid #4a607a;
  background: transparent;
  color: var(--muted);
  font: italic 600 11px/1 Georgia, 'Times New Roman', serif;
  text-transform: none;
  letter-spacing: 0;
  vertical-align: 1px;
  cursor: pointer;
  flex: none;
  position: relative;
}

.info:hover,
.info[aria-expanded='true'] {
  background: #1d4d8f;
  border-color: #2f6fc4;
  color: var(--text);
}

.info.as-text {
  cursor: default;
  vertical-align: 0;
  margin: 0 1px;
}

#info-box {
  position: fixed;
  z-index: 20;
  width: 360px;
  max-width: calc(100vw - 16px);
  max-height: min(78vh, 640px);
  overflow-y: auto;
  background: var(--panel-2);
  border: 1px solid #3b516b;
  border-radius: var(--radius);
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.6);
  padding: 12px 14px 14px;
  font-size: 13px;
  line-height: 1.45;
}

.info-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.info-title {
  font-size: 14px;
}

.info-close {
  flex: none;
  padding: 0 8px;
  font-size: 16px;
  line-height: 24px;
}

.info-body p,
#all-maths-body p {
  margin: 0 0 8px;
  line-height: 1.45;
  color: var(--text);
}

.info-body h4,
#all-maths-body h4 {
  margin: 10px 0 4px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

h4.globe {
  color: var(--globe);
}

h4.flat {
  color: var(--flat);
}

.steps {
  margin: 0 0 10px;
  border-top: 1px solid var(--line);
}

/* One line of working: what it is, then how it is found, with the value on the right. The words always keep
   at least half the width. A value too long for the other half goes on to more lines. */
.step {
  display: grid;
  grid-template-columns: minmax(50%, 1fr) auto;
  gap: 1px 12px;
  padding: 5px 0;
  border-bottom: 1px solid var(--line);
}

.step span {
  color: var(--muted);
}

.step code {
  grid-column: 1;
  justify-self: start;
  white-space: normal;
  overflow-wrap: anywhere;
}

.step b {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: center;
  text-align: right;
  font-variant-numeric: tabular-nums;
  text-wrap: balance;
}

/* A view that has been switched off, and the room the others then share: as many rows as are needed, and the
   whole width for a view left alone on its row. */
.view.off {
  display: none !important;
}

#views[data-fewer] {
  grid-template-rows: auto;
  grid-auto-rows: minmax(0, 1fr);
}

.view.span {
  grid-column: 1 / -1;
}

#setup-name {
  flex: 1;
  min-width: 0;
  max-width: 190px;
}

.info-code {
  color: var(--muted);
  font-size: 12px;
}

#all-maths-body h3 {
  margin: 16px 0 6px;
  font-size: 13.5px;
  color: var(--text);
}

.hint:empty {
  display: none;
}

@media (max-width: 720px) {
  /* A sheet along the bottom, so the views stay in sight above it. */
  #info-box {
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    width: auto;
    max-width: none;
    max-height: 46vh;
    border-radius: var(--radius) var(--radius) 0 0;
    border-width: 1px 0 0;
  }
}

/* ---------- touch screens ---------- */

@media (pointer: coarse) {
  a.button {
    min-height: 40px;
    font-size: 16px;
    line-height: 26px;
  }
  button,
  select,
  input[type='date'],
  input[type='datetime-local'],
  input[type='text'],
  input[type='number'] {
    min-height: 40px;
    font-size: 16px; /* stops phones zooming the page when a field is tapped */
  }
  .buttons button {
    font-size: 14px;
  }
  input[type='range'] {
    height: 34px;
  }
  .check {
    min-height: 36px;
  }
  /* A finger gets a larger button for the sky's options than a mouse does. */
  .view-menu-button {
    width: 40px;
    height: 34px;
  }
  .view-menu-list {
    font-size: 15px;
  }
  .check input {
    width: 20px;
    height: 20px;
  }
  .info {
    width: 22px;
    height: 22px;
    min-height: 0;
    font-size: 14px;
    margin-left: 5px;
  }
  table.data td:first-child:has(.info) {
    padding-right: 31px;
  }
  table.data td:first-child .info {
    margin-right: -27px;
  }
  /* A finger gets more of the "i" to hit than is drawn. */
  .info::after {
    content: '';
    position: absolute;
    inset: -5px -10px;
  }
  .fold,
  .side-head button {
    min-height: 36px;
  }
  .info-close {
    min-height: 32px;
  }
  .own-actions button,
  #route-table button,
  .route-pick button {
    min-height: 36px;
    font-size: 14px;
  }
  details summary {
    padding: 8px 0;
  }
}

/* ---------- narrow screens ---------- */

/* The page scrolls, and the views stay pinned at the top so a change to any
   control can be watched as it is made. */
@media (max-width: 1180px), (max-height: 520px) {
  body {
    display: block;
  }
  main {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
  #views {
    grid-column: 1 / -1;
    order: -1;
    position: sticky;
    top: 0;
    z-index: 5;
    background: var(--bg);
    height: 66vh;
    height: 66svh;
    max-height: 720px;
    grid-template-rows: auto minmax(0, 1fr) minmax(0, 1fr);
    border-bottom: 1px solid var(--line);
  }
  aside {
    overflow: visible;
  }
  /* The sidebars are beneath the views here, so tucking one away would give the views nothing. */
  .side-tuck {
    display: none !important;
  }
  .side-head {
    position: static;
  }
  #controls {
    border-right: 1px solid var(--line);
  }
  #results {
    border-left: 0;
  }
}

/* Phones: one pair of views at a time, chosen with the two buttons above them. */
@media (max-width: 720px), (max-height: 520px) {
  header {
    padding: 8px 12px;
    gap: 6px 16px;
  }
  .brand p {
    font-size: 12px;
  }
  .on-wide {
    display: none;
  }
  .on-phone {
    display: inline;
  }
  #demos {
    align-items: stretch;
    max-width: 100%;
  }
  #demo-groups,
  #demo-list {
    flex-wrap: nowrap;
    justify-content: flex-start;
    overflow-x: auto;
    scrollbar-width: thin;
  }
  #demos button {
    flex: none;
  }
  #views {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) minmax(0, 1fr);
    height: 66vh;
    height: 66svh;
    gap: 6px;
    padding: 6px;
  }
  #view-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    flex: 1 1 260px;
  }
  #mode-tabs {
    flex: 1 1 260px;
  }
  /* On a phone the two groups of time controls are taken apart and laid out afresh. Play ends the row that
     switches between the pairs of views. Under it are the date, the jumps as one short list, and the speed.
     The time of day has a row to itself, so that its slider is long enough to use. */
  #view-tabs {
    flex: 1 1 190px;
  }
  #play-bar,
  #time-bar {
    display: contents;
  }
  #view-bar #view-tabs button,
  #view-bar #btn-play {
    padding: 4px 6px;
    font-size: 13px;
    white-space: nowrap;
  }
  #view-tabs {
    order: 1;
  }
  #view-bar #btn-play {
    order: 2;
    flex: none;
    min-width: 54px;
  }
  #date {
    order: 3;
  }
  #time-jump {
    order: 4;
  }
  #speed {
    order: 5;
  }
  .time-field {
    order: 6;
    flex: 1 1 100%;
    margin: 0;
  }
  #jump-buttons {
    display: none;
  }
  /* These keep the size of type that stops a phone zooming the page when one is tapped. */
  #view-bar #date,
  #view-bar #time-jump,
  #view-bar #speed {
    min-height: 34px;
    padding: 4px 4px;
  }
  #view-bar #date {
    flex: 1 1 130px;
    min-width: 0;
  }
  #view-bar #time-jump {
    display: block;
    flex: none;
  }
  #view-bar #speed {
    flex: none;
  }
  #view-bar #time {
    height: 28px;
  }
  #mode-tabs button {
    flex: 1;
    white-space: nowrap;
  }
  #view-bar #mode-tabs button {
    font-size: 13px;
    padding: 4px 4px;
  }
  #view-bar button {
    min-height: 34px;
    padding: 4px 8px;
    font-size: 14px;
  }
  #views[data-pair='outside'] .view.sky,
  #views[data-pair='sky'] .view:not(.sky) {
    display: none;
  }
  /* The view from space is the only one of its tool, whichever pair was last on show. */
  #views[data-mode='space'] .view.sp {
    display: block;
  }
  .view-title small {
    display: none;
  }
  .view-title {
    font-size: 12px;
    padding: 2px 7px;
    top: 6px;
    left: 6px;
  }
  .legend {
    font-size: 12px;
    left: 6px;
    bottom: 6px;
    gap: 2px 10px;
    padding: 3px 7px;
  }
  .readout {
    top: 32px;
    left: 6px;
    font-size: 12px;
    padding: 4px 7px;
  }
  .scope {
    transform: scale(0.6);
    transform-origin: bottom right;
    right: 6px;
    bottom: 6px;
  }
  .scope-caption {
    font-size: 13px;
  }
}

/* One column: the explanation of the current demonstration comes straight after
   the views, then the controls, then the rest of the results. */
@media (max-width: 720px) {
  main {
    display: flex;
    flex-direction: column;
    background: var(--panel);
  }
  aside {
    display: contents;
  }
  aside section {
    order: 3;
    margin: 0 12px 12px;
  }
  #controls section,
  #controls .side-head {
    order: 2;
  }
  .side-head {
    order: 3;
    margin: 0 12px 12px;
    padding: 6px 0;
    border-top: 1px solid var(--line);
    border-bottom: 0;
  }
  #results .side-name {
    margin-left: 0;
  }
  #demo-card {
    order: 1;
    margin-top: 12px;
  }
  #jump {
    order: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin: 0 12px 12px;
  }
  /* Scrolling to a section stops with it just beneath the pinned views. */
  aside section,
  .side-head {
    scroll-margin-top: calc(66vh + 6px);
    scroll-margin-top: calc(66svh + 6px);
  }
  /* Once a step's question has been answered it makes room for the answer. */
  #demo-card.answered #tour-ask {
    display: none;
  }
  #views {
    order: 0;
  }
}

/* Where there is very little height, the line under the name gives its room to the views. */
@media (max-height: 520px) {
  .brand p {
    display: none;
  }
}

/* A phone on its side: the two views sit next to each other instead. */
@media (max-height: 520px) and (orientation: landscape) {
  #views {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    height: 78vh;
    height: 78svh;
  }
}

/* ---------- less motion ---------- */

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