/* ==========================================================================
   Orrery interface styles

   Styled as an instrument: hairline rules, graduated scales, dotted leaders,
   near-square plates. The one accent marks only what is live or chosen.
   Hit targets stay touch-sized even where the drawn shape is smaller.
   ========================================================================== */

/* Self-hosted, so the page loads nothing from a third party. Inter for the
   interface and Jost for names, titles and headline figures. */
@font-face {
  font-family: "Inter";
  src: url("public/fonts/inter.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "Jost";
  src: url("public/fonts/jost.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --bg: #04050a;
  /* Plates: the one surface. Translucent where the scene should show through,
     solid where a list has to be read. */
  --plate: rgba(8, 9, 13, 0.62);
  --plate-solid: rgba(9, 10, 14, 0.97);
  --hover: rgba(255, 255, 255, 0.05);
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);

  --text: #eeece6;
  --text-dim: rgba(238, 236, 230, 0.62);
  --text-faint: rgba(238, 236, 230, 0.5);

  --accent: #f3bd6e;
  --accent-soft: rgba(243, 189, 110, 0.14);
  --sun: #ffd9a0;

  --radius: 3px;
  --gap: 12px;
  --edge: 18px;

  --font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI",
          Roboto, "Helvetica Neue", Arial, sans-serif;
  --display: Jost, var(--font);
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;

  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

::selection { background: var(--accent-soft); color: var(--text); }

sup {
  font-size: 0.7em;
  line-height: 0;
  vertical-align: 0.5em;
  margin-left: 0.05em;
}

#viewport {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  outline: none;
  touch-action: none;
}

/* The UI layer never eats pointer events except where a control actually is. */
.ui {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
  padding: var(--edge);
  padding-top: max(var(--edge), env(safe-area-inset-top));
  padding-bottom: max(var(--edge), env(safe-area-inset-bottom));
  /* A phone on its side puts the notch at one end. */
  padding-left: max(var(--edge), env(safe-area-inset-left));
  padding-right: max(var(--edge), env(safe-area-inset-right));
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: var(--gap);
}
.ui > * { pointer-events: auto; }
.ui[hidden] { display: none; }

/* The top and bottom controls sit straight on the scene, not on plates. A
   soft fade at each edge is all they need to stay legible. */
.ui::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    linear-gradient(to bottom, rgba(3, 4, 8, 0.6), rgba(3, 4, 8, 0) 120px),
    linear-gradient(to top, rgba(3, 4, 8, 0.7), rgba(3, 4, 8, 0) 150px);
}

/* --- shared primitives --------------------------------------------------- */

.panel {
  background: var(--plate);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

svg[aria-hidden="true"] { fill: none; stroke: currentColor; stroke-width: 1.5; flex: none; }

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 36px;
  min-width: 36px;
  padding: 0 10px;
  border-radius: var(--radius);
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 500;
  transition: color 0.15s var(--ease), background 0.15s var(--ease);
}
.btn:hover { color: var(--text); }
.btn:disabled { opacity: 0.3; pointer-events: none; }
.btn[hidden] { display: none; }
/* On: the control lights, with a small index under it. */
.btn[aria-pressed="true"],
.btn.is-active { color: var(--accent); }
.btn[aria-pressed="true"]::after,
.btn.is-active::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 3px;
  width: 3px;
  height: 3px;
  margin-left: -1.5px;
  border-radius: 50%;
  background: currentColor;
}
.btn--icon { padding: 0; width: 36px; }
.btn svg { width: 18px; height: 18px; }
.btn--text { padding: 0; min-height: 32px; color: var(--text-faint); font-weight: 400; }
.btn--text:hover { color: var(--text); }

:where(button, a, select, input, [tabindex]):focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 2px;
}

/* A controller moves focus from across the room, so its ring is heavier and
   glows. Matched on :focus, since focus moved by script is not always
   :focus-visible. Any other input takes the class away again. */
.is-gamepad :where(button, a, input, [tabindex]):focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  box-shadow: 0 0 0 6px rgba(243, 189, 110, 0.16);
}
/* Rows that fill a list, and regions that fill a panel, keep the ring inside. */
.is-gamepad :where(.picker__option, .moment, .info__header, .help__body):focus {
  outline-offset: -2px;
  box-shadow: none;
  background: var(--hover);
  color: var(--text);
}
/* No pointer while a controller is in use. */
.is-gamepad #viewport { cursor: none !important; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* The small label used for every section. */
.section-title,
.picker__group,
.info__kind {
  font-family: var(--display);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-faint);
}

/* --- loading screen ------------------------------------------------------ */

.loading {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: var(--bg);
  transition: opacity 0.7s var(--ease), visibility 0.7s;
}
.loading.is-done { opacity: 0; visibility: hidden; }

.loading__inner { text-align: center; width: min(220px, 70vw); }

/* A small working orrery: three rings turning in the ratio of Mercury, Venus
   and Earth's years, each planet starting where it stood on 1 January 2000. */
.loading__orbit {
  position: relative;
  width: 88px;
  height: 88px;
  margin: 0 auto 34px;
}
.loading__sun {
  position: absolute;
  inset: 50% auto auto 50%;
  width: 8px;
  height: 8px;
  margin: -4px 0 0 -4px;
  border-radius: 50%;
  background: var(--sun);
  box-shadow: 0 0 18px 5px rgba(255, 217, 160, 0.3);
}
.loading__ring {
  position: absolute;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 50%;
  transform: rotate(var(--start));
  animation: orbit var(--period) linear infinite;
}
.loading__ring::before {
  content: "";
  position: absolute;
  top: calc(var(--size) / -2);
  left: 50%;
  width: var(--size);
  height: var(--size);
  margin-left: calc(var(--size) / -2);
  border-radius: 50%;
  background: var(--color);
}
.loading__ring--1 { inset: 30px; --period: 0.96s; --size: 3px;   --color: #b3aba2; --start: -162deg; }
.loading__ring--2 { inset: 18px; --period: 2.46s; --size: 4px;   --color: #e3c996; --start: -92deg; }
.loading__ring--3 { inset: 4px;  --period: 4s;    --size: 4.5px; --color: #6aa6ff; --start: -10deg; }
@keyframes orbit {
  from { transform: rotate(var(--start)); }
  to { transform: rotate(calc(var(--start) - 360deg)); }
}

.loading__title {
  margin: 0;
  font-family: var(--display);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.5em;
  text-transform: uppercase;
  /* Letter-spacing trails the last glyph. This keeps the word optically centred. */
  margin-right: -0.5em;
}
.loading__track {
  height: 1px;
  margin-top: 26px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}
.loading__bar {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.3s var(--ease);
}
.loading__status {
  margin: 12px 0 0;
  min-height: 1.4em;
  color: var(--text-faint);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

/* --- top bar ------------------------------------------------------------- */

.topbar {
  grid-row: 1;
  /* Its menus hang over the info panel below, which comes later in the page. */
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: var(--gap);
}
.topbar__group { display: flex; align-items: center; gap: 0; }
.topbar__end { justify-self: end; display: flex; gap: var(--gap); }
/* The actions are bare: no plate, just the controls on the sky. */
.topbar__actions.panel {
  background: none;
  border: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.topbar__divider { width: 1px; height: 16px; margin: 0 6px; background: var(--line-strong); }

/* Star-system atlas. */
.systems-button { gap: 8px; white-space: nowrap; }
/* Only shown when a headset is available. It has a label because in a
   headset's browser it's the way in. */
.topbar__vr { padding: 0 10px 0 8px; gap: 8px; }
.systems {
  color: var(--text); background: var(--plate-solid);
  /* Clear of a notch at either end of a phone on its side. */
  width: min(880px, calc(100vw - 32px - env(safe-area-inset-left) - env(safe-area-inset-right))); max-width: none;
  height: min(790px, calc(100dvh - 40px)); max-height: none;
  margin: auto; padding: 0; border: 1px solid var(--line-strong);
  border-radius: var(--radius); box-shadow: 0 28px 100px #0009;
}
.systems[open] { display: flex; flex-direction: column; }
.systems::backdrop { background: #020409b8; backdrop-filter: blur(9px); }
.systems__header { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 26px 28px 18px; }
.systems__header .section-title { color: var(--accent); margin: 0 0 4px; }
.systems h2 { font: 400 clamp(25px, 4vw, 36px)/1.2 var(--display); margin: 0; }
.systems__count { color: var(--text-dim); margin: 10px 0 0; font-size: 12px; }
.systems__tools { display: flex; gap: 12px; padding: 0 28px 18px; border-bottom: 1px solid var(--line); }
.systems__tools input, .systems__tools select {
  font: inherit; color: var(--text); background: #12141b; border: 1px solid var(--line-strong);
  border-radius: var(--radius); padding: 10px 12px; min-height: 44px; min-width: 0;
}
.systems__tools input { flex: 1; width: 100%; }
.systems__tools input::placeholder { color: var(--text-dim); }
.systems__scroll { overflow: auto; min-height: 0; flex: 1; padding: 20px 28px; overscroll-behavior: contain; }
.systems__home { display: flex; gap: 14px; align-items: center; padding: 14px 16px; border: 1px solid var(--line-strong); text-decoration: none; color: var(--text); }
.systems__home > span:first-child { color: var(--sun); font-size: 30px; }
.systems__home > span:nth-child(2) { flex: 1; }
.systems__home > span:last-child { color: var(--accent); font-size: 12px; }
.systems__home strong { font-family: var(--display); font-size: 19px; font-weight: 500; }
.systems__home small { display: block; font-size: 11px; color: var(--text-dim); }
.systems__results { color: var(--text-dim); font-size: 11px; margin: 20px 0 10px; }
.systems__list { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.systems__card { display: flex; align-items: center; gap: 14px; min-width: 0; padding: 16px 12px; color: var(--text); text-decoration: none; border: 1px solid var(--line); transition: background .15s, border-color .15s; }
.systems__card:hover, .systems__home:hover { background: var(--hover); border-color: var(--accent); }
.systems__card[aria-current] { border-color: var(--accent); background: var(--accent-soft); }
.systems__card > div { min-width: 0; }
.systems__card h3 { font: 500 20px/1.25 var(--display); margin: 0 0 5px; overflow-wrap: anywhere; }
.systems__card p { font-size: 12px; color: var(--text-dim); margin: 0; }
.systems__card small { font-size: 11px; color: var(--text-dim); }
.systems__arrow { margin-left: auto; color: var(--accent); }
.systems__card:hover .systems__arrow { transform: translateX(2px); }
.systems__arrow { transition: transform .15s; }
.systems__glyph { position: relative; width: 64px; height: 64px; flex: 0 0 64px; }
.systems__glyph::before { content: ''; position: absolute; inset: 28px; border-radius: 50%; background: var(--star-color); box-shadow: 0 0 15px var(--star-color); }
.systems__glyph i { position: absolute; inset: calc(20px - var(--orbit) * 5px); border: 1px solid #eeece629; border-radius: 50%; transform: rotate(calc(var(--orbit) * 71deg)); }
.systems__glyph i::after { content: ''; position: absolute; left: 50%; top: -2px; width: 3px; height: 3px; border-radius: 50%; background: var(--text-dim); }
.systems__footer { padding: 14px 28px 18px; border-top: 1px solid var(--line); display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 10px; font-size: 11px; }
.systems__footer a, .info__provenance a, .info__unmodeled a { color: var(--accent); text-underline-offset: 3px; }
.systems__footer > div { color: var(--text-dim); }
/* Taller to tap than the line it sits on (WCAG 2.5.8). */
.systems__footer > div > a { display: inline-block; padding: 5px 0; }
.systems__footer .btn { font-size: 11px; }
.systems__status, .systems__note { grid-column: 1 / -1; margin: 2px 0; color: var(--text-dim); }
.systems__status { color: var(--text); }
.info__provenance { font-size: 11px; color: var(--text-dim); border-top: 1px solid var(--line); margin-top: 16px; padding-top: 12px; overflow-wrap: anywhere; }
.info__provenance:empty { display: none; }
.info__provenance p { margin: 8px 0; }
.info__unmodeled { margin-top: 12px; font-size: 11px; color: var(--text-dim); }
.info__hidden-stars { margin: 10px 0 0; font-size: 11px; color: var(--text-dim); }
.info__unmodeled summary { cursor: pointer; min-height: 36px; color: var(--text); }
.is-exoplanet .info__title { overflow-wrap: anywhere; }
@media (max-width: 1000px) { .systems-button > span { display: none; } }
@media (max-width: 720px) {
  .picker, .picker__button { min-width: 0; max-width: 100%; }
  .picker__label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .systems { width: calc(100vw - 16px - env(safe-area-inset-left) - env(safe-area-inset-right)); height: calc(100dvh - 20px); }
  .systems__header { padding: 18px 16px 14px; }
  .systems__tools { padding: 0 16px 12px; flex-wrap: wrap; gap: 8px; }
  .systems__tools input { flex-basis: 100%; }
  .systems__tools select { width: 100%; }
  .systems__scroll { padding: 14px 16px; }
  .systems__list { grid-template-columns: 1fr; }
  .systems__footer { padding: 10px 16px; grid-template-columns: 1fr; }
  .systems__home > span:last-child { display: none; }
}
/* A short screen (a phone on its side, a laptop window, a zoomed page) cannot
   spare a fixed header and footer. Pinned, they left the list only a sliver.
   So the whole atlas scrolls, and only the title, the search and the close
   button stay put, in one compact bar. */
@media (max-height: 700px) {
  .systems { height: calc(100dvh - 16px); scroll-padding-top: 84px; }
  .systems[open] { display: block; overflow-y: auto; overscroll-behavior: contain; }
  .systems__top {
    position: sticky; top: 0; z-index: 1;
    display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "title tools close";
    align-items: center; gap: 10px 16px; padding: 10px 16px;
    background: var(--plate-solid); border-bottom: 1px solid var(--line);
  }
  .systems__header { display: contents; }
  .systems__header > div { grid-area: title; min-width: 0; }
  .systems__header > .btn { grid-area: close; }
  .systems__header .section-title { display: none; }
  .systems h2 { font-size: 22px; line-height: 1.15; white-space: nowrap; }
  .systems__count { margin: 2px 0 0; white-space: nowrap; }
  .systems__tools { grid-area: tools; padding: 0; border: 0; flex-wrap: wrap; gap: 8px; }
  /* The search takes the spare width, and the menu fills a line only when it wraps onto its own. */
  .systems__tools input { flex: 1000 1 150px; }
  .systems__tools select { flex: 1 0 auto; width: auto; }
  .systems__scroll { overflow: visible; padding: 14px 16px; }
  .systems__results { margin-top: 14px; }
  .systems__footer { padding: 12px 16px 14px; }
}
/* A phone on its side is wide enough for two columns, even under 720px. */
@media (max-height: 700px) and (min-width: 560px) {
  .systems__list { grid-template-columns: 1fr 1fr; }
}
/* Too narrow for all of it on one line: the title and the close button, then the tools. */
@media (max-height: 700px) and (max-width: 639px) {
  .systems { scroll-padding-top: 180px; }
  .systems__top { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "title close" "tools tools"; }
}

.brand {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-height: 40px;
  padding: 0 8px 0 0;
  color: var(--text);
  user-select: none;
}
.brand__word {
  font-family: var(--display);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  opacity: 0.8;
  transition: opacity 0.2s var(--ease);
}
.brand:hover .brand__word { opacity: 1; }
.brand__mark { overflow: visible; transition: transform 0.9s var(--ease); }
.brand:hover .brand__mark { transform: rotate(-60deg); }
.brand__orbit { fill: none; stroke: currentColor; stroke-width: 1; opacity: 0.5; }
.brand__sun { fill: var(--sun); }
.brand__planet { fill: currentColor; }

/* --- body picker --------------------------------------------------------- */

.picker { position: relative; }

/* Reads as a title with a caret, not a button. */
.picker__button {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 4px;
}
.picker__swatch {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex: none;
}
.picker__label {
  font-family: var(--display);
  font-size: 17px;
  font-weight: 450;
  letter-spacing: 0.02em;
  background: linear-gradient(currentColor, currentColor) left bottom / 0 1px no-repeat;
  padding-bottom: 1px;
  transition: background-size 0.3s var(--ease);
}
.picker__button:hover .picker__label,
.picker.is-open .picker__label { background-size: 100% 1px; }
.picker__chevron {
  display: flex;
  color: var(--text-faint);
  transition: transform 0.2s var(--ease), color 0.15s var(--ease);
}
.picker__button:hover .picker__chevron { color: var(--text); }
.picker.is-open .picker__chevron { transform: rotate(180deg); }

.picker__menu,
.when {
  background: var(--plate-solid);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
  animation: unfold 0.18s var(--ease);
}
@keyframes unfold {
  from { opacity: 0; transform: translate(var(--unfold-x, 0), -4px); }
}

.picker__menu {
  --unfold-x: -50%;
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  width: min(248px, 86vw);
  max-height: min(64vh, 480px);
  max-height: min(64dvh, 480px);
  overflow-y: auto;
  padding: 4px 0;
}
.picker__menu[hidden] { display: none; }

.picker__group {
  padding: 14px 16px 5px;
  font-size: 10.5px;
}
.picker__option {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  min-height: 32px;
  padding: 0 16px;
  text-align: left;
  font-size: 13.5px;
  color: var(--text-dim);
  transition: background 0.12s var(--ease), color 0.12s var(--ease);
}
.picker__option:hover,
.picker__option:focus-visible { background: var(--hover); color: var(--text); outline: none; }
/* The current body carries an index mark at the menu's edge. */
.picker__option[aria-selected="true"] { color: var(--text); }
.picker__option[aria-selected="true"]::before {
  content: "";
  position: absolute;
  left: 0;
  top: 9px;
  bottom: 9px;
  width: 2px;
  background: var(--accent);
}
.picker__option-meta { margin-left: auto; font-size: 11.5px; color: var(--text-faint); }
.picker__option-meta kbd { font-size: 10.5px; }
.picker__option--overview { margin-bottom: 2px; }
/* The whole system: a ring round a Sun, where a body would have a dot. */
.picker__ring,
.picker__swatch.is-ring {
  position: relative;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  flex: none;
  border: 1px solid rgba(255, 255, 255, 0.45);
  background: transparent !important;
}
.picker__ring { margin: 0 -2px; }
.picker__ring::after,
.picker__swatch.is-ring::after {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: var(--sun);
}

/* --- info panel ---------------------------------------------------------- */

.info {
  grid-row: 2;
  align-self: start;
  justify-self: start;
  width: min(300px, calc(100vw - 2 * var(--edge)));
  max-height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.info[hidden] { display: none; }
.info.is-collapsed .info__body { display: none; }

.info__header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 16px 18px 0 20px;
  text-align: left;
  cursor: pointer;
}
.info__title {
  margin: 0;
  font-family: var(--display);
  font-size: 30px;
  font-weight: 350;
  letter-spacing: 0.01em;
  line-height: 1.1;
}
.info__kind {
  padding: 6px 20px 16px;
  font-size: 10.5px;
}
/* A short rule in the body's own colour: the one place it appears as an accent. */
.info__kind::before {
  content: "";
  display: inline-block;
  width: 16px;
  height: 1px;
  margin: 0 10px 3px 0;
  vertical-align: middle;
  background: var(--body-color, #fff);
  box-shadow: 0 0 6px var(--body-color, #fff);
}
.info__link {
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  color: var(--text-dim);
  border-bottom: 1px solid var(--line-strong);
  transition: color 0.15s var(--ease), border-color 0.15s var(--ease);
}
.info__link:hover { color: var(--text); border-color: var(--accent); }
.info__toggle { display: flex; margin: 10px 0 0 auto; color: var(--text-faint); }
.info__toggle svg { transition: transform 0.2s var(--ease); }
.info.is-collapsed .info__toggle svg { transform: rotate(-90deg); }
.info__header:hover .info__toggle { color: var(--text); }

.info__body {
  padding: 0 20px 18px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}
.info__blurb {
  margin: 0 0 16px;
  font-size: 13px;
  line-height: 1.62;
  color: var(--text-dim);
  text-wrap: pretty;
}
.info__facts { margin: 0; display: grid; }

/* Tables are set like an almanac: label, dotted leader, figure. */
.info__fact,
.info__live-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 3px 0;
  font-size: 12.5px;
}
.info__fact::after,
.info__live-row::after {
  content: "";
  order: 1;
  flex: 1;
  min-width: 12px;
  border-bottom: 1px dotted rgba(255, 255, 255, 0.16);
  transform: translateY(-3px);
}
.info__fact dt,
.info__live-row span:first-child { color: var(--text-faint); flex: none; }
.info__fact dd,
.info__live-row span:last-child {
  order: 2;
  margin: 0;
  text-align: right;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.info__live {
  margin: 0 0 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
  display: grid;
}
.info__live:empty { display: none; }
/* Live figures carry the accent. */
.info__live-row span:last-child { color: var(--accent); }

/* The orbit, face-on and to scale. */
.info__diagram {
  margin: 0 0 14px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 217, 160, 0.05), transparent 60%),
    repeating-linear-gradient(to right, rgba(255, 255, 255, 0.025) 0 1px, transparent 1px 16px),
    repeating-linear-gradient(to bottom, rgba(255, 255, 255, 0.025) 0 1px, transparent 1px 16px);
}
.info__diagram:empty { display: none; }
.info__diagram svg { display: block; overflow: visible; }
.orbit-path { fill: none; stroke: rgba(255, 255, 255, 0.13); stroke-width: 1; }
.orbit-path.is-own { stroke: rgba(255, 255, 255, 0.3); }
.orbit-travelled {
  fill: none;
  stroke: var(--body-color, #fff);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.85;
}
.orbit-primary { filter: drop-shadow(0 0 3px rgba(255, 217, 160, 0.6)); }
.orbit-body { fill: var(--body-color, #fff); stroke: #0a0b0f; stroke-width: 1.5; }
.orbit-halo { fill: none; stroke: var(--body-color, #fff); stroke-width: 1; opacity: 0.3; }
.orbit-neighbour { stroke: #0a0b0f; stroke-width: 1; opacity: 0.8; }
.orbit-label { fill: var(--text-faint); font-size: 10px; letter-spacing: 0.04em; font-family: var(--font); }

.info__system:empty { display: none; }
.info__system .section-title { margin-top: 18px; font-size: 10.5px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 28px;
  padding: 0 10px 0 9px;
  border-radius: 2px;
  border: 1px solid var(--line-strong);
  font-size: 12px;
  color: var(--text-dim);
  transition: border-color 0.15s var(--ease), color 0.15s var(--ease);
}
.chip:hover { border-color: rgba(255, 255, 255, 0.3); color: var(--text); }
.chip[aria-current="true"] { border-color: var(--accent); color: var(--text); }
.chip__dot { width: 6px; height: 6px; border-radius: 50%; flex: none; }

/* --- time bar ------------------------------------------------------------ */

/* Bare, like the top bar: a readout and a dial along the bottom edge. */
.timebar {
  grid-row: 3;
  justify-self: center;
  position: relative;
  display: flex;
  align-items: center;
  gap: 2px;
  max-width: calc(100vw - 2 * var(--edge));
}
.timebar.panel {
  background: none;
  border: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.timebar__date {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  align-self: stretch;
  padding: 2px 12px 2px 4px;
  min-width: 128px;
  line-height: 1.25;
  text-align: right;
}
.timebar__date-main {
  font-family: var(--display);
  font-size: 16px;
  font-weight: 450;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  background: linear-gradient(currentColor, currentColor) right bottom / 0 1px no-repeat;
  transition: background-size 0.3s var(--ease);
}
.timebar__date:hover .timebar__date-main,
.timebar.is-open .timebar__date-main { background-size: 100% 1px; }
.timebar__date-sub {
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

/* The rate dial: a hairline scale graduated at each named rate, with a
   needle for a thumb. The longer mark is one day a second. */
.timebar__scale {
  position: relative;
  display: flex;
  align-items: center;
  width: 176px;
  margin: 0 12px 0 6px;
}
.timebar__ticks {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 0;
  pointer-events: none;
}
.timebar__tick {
  position: absolute;
  /* The thumb is 3px wide, so its centre travels 1.5px in from each end. */
  left: calc(1.5px + var(--at) * (100% - 3px));
  top: 3px;
  width: 1px;
  height: 4px;
  background: rgba(255, 255, 255, 0.28);
}
.timebar__tick.is-major { height: 7px; background: rgba(255, 255, 255, 0.45); }
.timebar__slider { width: 100%; margin: 0; }
/* Where the rate readout has no room (a phone), the rate rides above the
   needle while it moves. */
.timebar__bubble {
  position: absolute;
  bottom: calc(100% + 4px);
  left: calc(1.5px + var(--at, 0) * (100% - 3px));
  display: none;
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--plate-solid);
  font-size: 12px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, 3px);
  transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
}
.timebar__bubble.is-showing { opacity: 1; transform: translate(-50%, 0); }

.timebar__rate {
  min-width: 78px;
  text-align: left;
  font-size: 12px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.timebar__divider { width: 1px; height: 18px; margin: 0 8px; background: var(--line-strong); }

/* --- flight hud ---------------------------------------------------------- */

.hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9;
  opacity: 0;
  transition: opacity 0.3s var(--ease);
}
.hud.is-active { opacity: 1; }

.hud__reticle {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 40px;
  height: 40px;
  margin: -20px 0 0 -20px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 50%;
}
.hud__reticle::before,
.hud__reticle::after {
  content: "";
  position: absolute;
  background: rgba(255, 255, 255, 0.4);
}
.hud__reticle::before { left: -10px; width: 6px; top: 50%; height: 1px; box-shadow: 54px 0 rgba(255, 255, 255, 0.4); }
.hud__reticle::after { top: -10px; height: 6px; left: 50%; width: 1px; box-shadow: 0 54px rgba(255, 255, 255, 0.4); }

.hud__aim {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 5px;
  height: 5px;
  margin: -2.5px 0 0 -2.5px;
  background: var(--accent);
  border-radius: 50%;
  will-change: transform;
}

.hud__controls {
  position: absolute;
  left: max(var(--edge), env(safe-area-inset-left));
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.hud.is-active .hud__controls > * { pointer-events: auto; }

.hud__throttle {
  width: 56px;
  padding: 12px 6px;
  text-align: center;
  cursor: ns-resize;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.hud__throttle-track {
  height: 110px;
  width: 1px;
  margin: 10px auto;
  background: rgba(255, 255, 255, 0.14);
  position: relative;
  overflow: visible;
  /* Graduated like the rate dial: a mark every quarter. */
  box-shadow: -3px 0 0 -0px transparent;
}
.hud__throttle-track::before {
  content: "";
  position: absolute;
  inset: 0 -4px;
  background: repeating-linear-gradient(to top, rgba(255, 255, 255, 0.25) 0 1px, transparent 1px 25%);
}
.hud__throttle-fill {
  position: absolute;
  bottom: 0;
  left: -1px;
  right: -1px;
  background: var(--accent);
  height: 0%;
}
.hud__speed {
  font-family: var(--display);
  font-size: 15px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.hud__speed-unit { font-size: 10px; color: var(--text-faint); letter-spacing: 0.12em; }

.hud.is-boosting .hud__reticle { border-color: var(--accent); }
.hud.is-boosting .hud__speed { color: var(--accent); }

/* Touch only: a keyboard has Shift. */
.hud__boost {
  display: none;
  width: 56px;
  padding: 0;
  font-size: 12px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.hud__boost.is-active { background: var(--accent); color: #000; }

/* The body you are nearest, just under the reticle. */
.hud__near {
  position: absolute;
  top: calc(50% + 40px);
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 10px;
  text-align: center;
  font-size: 12px;
  line-height: 1.35;
  white-space: nowrap;
}
.hud__near-name { font-family: var(--display); font-weight: 500; }
.hud__near-distance { color: var(--text-dim); font-variant-numeric: tabular-nums; }

/* Where you are headed, mirroring the throttle on the other side. */
.hud__dest {
  position: absolute;
  right: max(var(--edge), env(safe-area-inset-right));
  top: 50%;
  transform: translateY(-50%);
  width: 156px;
  padding: 10px 6px 6px;
  text-align: center;
}
.hud.is-active .hud__dest { pointer-events: auto; }
.hud__dest-row { display: flex; align-items: center; justify-content: space-between; }
.hud__dest-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--display);
  font-size: 15px;
  font-weight: 500;
}
.hud__dest.is-empty .hud__dest-name { color: var(--text-faint); }
.hud__dest-distance {
  margin-bottom: 4px;
  font-size: 12px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.hud__autopilot { width: 100%; border-top: 1px solid var(--line); border-radius: 0; }

/* The destination, bracketed when it is in view. */
.hud__bracket {
  position: absolute;
  left: 0;
  top: 0;
  display: none;
  translate: -50% -50%;
  border: 1px dashed var(--accent);
  border-radius: 50%;
  opacity: 0.8;
}
.hud__bracket.is-visible { display: block; }
.hud__bracket-label {
  position: absolute;
  top: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  font-size: 11.5px;
  font-weight: 500;
  color: var(--accent);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.9);
  white-space: nowrap;
}
/* When the destination is out of view, an arrow round the reticle points the way to turn. */
.hud__pointer {
  position: absolute;
  left: 0;
  top: 0;
  display: none;
  width: 0;
  height: 0;
  margin: -9px 0 0 -6px;
  border-top: 9px solid transparent;
  border-bottom: 9px solid transparent;
  border-left: 14px solid var(--accent);
  transform-origin: 6px 9px;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.8));
}
.hud__pointer.is-visible { display: block; }
.hud.is-autopilot .hud__reticle { border-color: var(--accent); }

.hud__notice {
  position: absolute;
  top: calc(50% - 90px);
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(100vw - 2 * var(--edge));
  padding: 6px 14px;
  font-size: 12px;
  text-align: center;
  opacity: 0;
  transition: opacity 0.3s var(--ease);
}
.hud__notice.is-visible { opacity: 1; }

.hud__prompt {
  position: absolute;
  top: calc(50% + 100px);
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 14px;
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.2s var(--ease);
}
.hud__prompt.is-visible { opacity: 1; }

/* Where a drag-to-steer started, and how far it has been pushed. */
.hud__stick {
  position: absolute;
  left: 0;
  top: 0;
  width: 140px;
  height: 140px;
  margin: -70px 0 0 -70px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 50%;
  display: none;
}
.hud__stick.is-visible { display: block; }
.hud__stick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 36px;
  height: 36px;
  margin: -18px 0 0 -18px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.4);
}

.hud__hint {
  /* Below the body picker rather than above the time bar, which owns the
     bottom centre and would otherwise sit on top of it. Fades once read. */
  position: absolute;
  top: 76px;
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(100vw - 2 * var(--edge));
  padding: 6px 14px;
  font-size: 12px;
  color: var(--text-dim);
  text-align: center;
  white-space: nowrap;
  opacity: 0;
}
.hud.is-active .hud__hint { animation: hint 7s var(--ease) forwards; }
@keyframes hint {
  0%, 100% { opacity: 0; }
  6%, 85% { opacity: 1; }
}
/* Without motion there is no fade, so the hint just stays. */
body.reduce-motion .hud.is-active .hud__hint { animation: none; opacity: 1; }
/* Hide the mouse's instructions while a controller is flying. Its legend says the rest. */
.is-gamepad .hud__hint,
.is-gamepad .hud__prompt { display: none; }
@media (prefers-reduced-motion: reduce) {
  .hud.is-active .hud__hint { animation: none; opacity: 1; }
}

/* --- distant-body markers ------------------------------------------------ */

.markers {
  position: fixed;
  inset: 0;
  z-index: 8;
  pointer-events: none;
  contain: layout;
}

.marker {
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  align-items: center;
  gap: 7px;
  /* The transform positions the marker, and the margin keeps the dot on the body. */
  margin: -9px 0 0 -9px;
  padding: 3px 8px 3px 3px;
  pointer-events: auto;
  white-space: nowrap;
  will-change: transform, opacity;
}

.marker__dot {
  width: 5px;
  height: 5px;
  margin: 0 0.5px;
  border-radius: 50%;
  flex: none;
  transition: box-shadow 0.15s var(--ease);
}
.marker:hover .marker__dot { box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.14); }
/* Keep in step with measureText() in src/ui/Markers.js. */
.marker__label {
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--text-dim);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.9);
  transition: color 0.15s var(--ease);
}
.marker:hover .marker__label { color: var(--text); }

/* Decluttered: the name is hidden, but the dot still marks the body and can be clicked. */
.marker.is-crowded .marker__label { display: none; }
.marker.is-crowded:hover .marker__label { display: inline; }

/* Moons, shown only while their own system is in view. */
.marker--moon .marker__dot { width: 4px; height: 4px; margin: 0 1px; }
.marker--moon .marker__label { font-size: 10.5px; font-weight: 400; color: var(--text-faint); }

/* --- hover tooltip ------------------------------------------------------- */

.tooltip {
  position: fixed;
  z-index: 11;
  padding: 3px 9px;
  font-family: var(--display);
  font-size: 13px;
  font-weight: 450;
  letter-spacing: 0.02em;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -150%);
  transition: opacity 0.12s var(--ease);
  white-space: nowrap;
}
.tooltip.is-visible { opacity: 1; }

/* --- settings drawer ----------------------------------------------------- */

.drawer {
  position: fixed;
  top: max(var(--edge), env(safe-area-inset-top));
  right: max(var(--edge), env(safe-area-inset-right));
  bottom: max(var(--edge), env(safe-area-inset-bottom));
  z-index: 20;
  width: min(300px, calc(100vw - 2 * var(--edge)));
  display: flex;
  flex-direction: column;
  background: var(--plate-solid);
  opacity: 0;
  visibility: hidden;
  transform: translateX(10px);
  transition: transform 0.25s var(--ease), opacity 0.25s var(--ease), visibility 0.25s;
}
.drawer.is-open { opacity: 1; visibility: visible; transform: none; }

.drawer__header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 10px 10px 20px;
  border-bottom: 1px solid var(--line);
}
.drawer__title {
  margin: 0;
  font-family: var(--display);
  font-size: 19px;
  font-weight: 400;
  letter-spacing: 0.02em;
}
.drawer__close { margin-left: auto; }
.drawer__body {
  padding: 0 20px 18px;
  overflow-y: auto;
  flex: 1;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

.field { padding: 9px 0; }
.field__row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.field__label { font-size: 13.5px; }
.field__hint { margin: 3px 0 0; font-size: 12px; color: var(--text-faint); line-height: 1.45; }
.field__value { font-size: 12.5px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.drawer__body > .field:last-child { margin-top: 14px; padding-top: 16px; border-top: 1px solid var(--line); }
.drawer__section[hidden] { display: none; }
.drawer__section > .section-title:first-child { margin-top: 24px; }
.drawer__footer { display: flex; flex-wrap: wrap; align-items: center; column-gap: 20px; }
.drawer__controls { display: none; gap: 8px; }
.drawer__controls svg { width: 15px; height: 15px; }
.drawer__reset.is-confirming { color: var(--accent); }
.install { margin-top: 6px; }
.install[hidden] { display: none; }
.install__button { gap: 8px; }
.install__button svg { width: 15px; height: 15px; }

.section-title { margin: 24px 0 4px; }
.section-title:first-child { margin-top: 16px; }

/* toggle: a squared slide switch, lit when on */
.switch {
  position: relative;
  width: 32px;
  height: 18px;
  flex: none;
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  transition: border-color 0.18s var(--ease), background 0.18s var(--ease);
}
/* An 18px switch is too small a target on its own, so this widens the hit area. */
.switch::before { content: ""; position: absolute; inset: -13px -8px; }
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 10px;
  height: 10px;
  border-radius: 1px;
  background: rgba(255, 255, 255, 0.45);
  transition: transform 0.18s var(--ease), background 0.18s var(--ease);
}
.switch[aria-checked="true"] { border-color: var(--accent); background: var(--accent-soft); }
.switch[aria-checked="true"]::after { transform: translateX(14px); background: var(--accent); }

/* range: a hairline track and a needle */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 26px;
  margin: 2px 0 0;
  background: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 1px;
  background: rgba(255, 255, 255, 0.2);
}
input[type="range"]::-moz-range-track {
  height: 1px;
  background: rgba(255, 255, 255, 0.2);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 3px;
  height: 16px;
  margin-top: -7.5px;
  border-radius: 1px;
  background: var(--accent);
  border: none;
  box-shadow: 0 0 8px rgba(243, 189, 110, 0.45);
  transition: transform 0.15s var(--ease);
}
input[type="range"]:active::-webkit-slider-thumb { transform: scaleY(1.25); }
input[type="range"]::-moz-range-thumb {
  width: 3px;
  height: 16px;
  border: none;
  border-radius: 1px;
  background: var(--accent);
  box-shadow: 0 0 8px rgba(243, 189, 110, 0.45);
}

/* segmented control: words, the chosen one underlined */
.segmented { display: inline-flex; gap: 2px; }
.segmented button {
  position: relative;
  min-height: 28px;
  padding: 0 7px;
  font-size: 12.5px;
  color: var(--text-faint);
  transition: color 0.15s var(--ease);
}
.segmented button:hover { color: var(--text); }
.segmented button[aria-pressed="true"] { color: var(--text); }
.segmented button[aria-pressed="true"]::after {
  content: "";
  position: absolute;
  left: 7px;
  right: 7px;
  bottom: 3px;
  height: 1px;
  background: var(--accent);
}

/* --- help overlay -------------------------------------------------------- */

.help {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: var(--edge);
  background: rgba(2, 3, 8, 0.62);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s var(--ease), visibility 0.2s;
}
.help.is-open { opacity: 1; visibility: visible; }

.help__card {
  width: min(620px, 100%);
  max-height: min(82vh, 640px);
  max-height: min(82dvh, 640px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--plate-solid);
}
.help__body {
  padding: 4px 20px 14px;
  overflow-y: auto;
  columns: 2 240px;
  column-gap: 36px;
  scrollbar-width: thin;
}
.help__body > div { break-inside: avoid; }
/* Margins vanish at a column break but padding does not, so both columns start level. */
.help__body .section-title { margin: 0; padding: 14px 0 6px; }
.keyrow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 4px 0;
  font-size: 13px;
}
.keyrow__desc { color: var(--text-dim); }
.keyrow__keys { display: flex; gap: 4px; flex: none; }
kbd {
  display: inline-block;
  min-width: 20px;
  padding: 0 5px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 3px;
  font-family: var(--font);
  font-size: 11px;
  font-weight: 500;
  line-height: 17px;
  text-align: center;
  color: var(--text);
}

/* Controller buttons: face buttons and sticks are round, as they are in the
   hand. The D-pad is drawn rather than spelled. See src/ui/padGlyphs.js. */
.pad { display: inline-flex; align-items: center; justify-content: center; gap: 0; }
.pad--face,
.pad--stick {
  width: 20px;
  min-width: 20px;
  height: 20px;
  padding: 0;
  border-width: 1px;
  border-radius: 50%;
  line-height: 18px;
}
/* A stick is a button with a ring round it. */
.pad--stick { margin: 0 3px; outline: 1px solid var(--line-strong); outline-offset: 2px; }
.pad svg { width: 13px; height: 13px; stroke-width: 1.6; }
.pad--dpad { min-width: 0; padding: 0; border: none; }
.pad--dpad svg { width: 21px; height: 21px; }
.pad--dpad path { fill: currentColor; stroke: none; opacity: 0.3; }
.pad--dpad path.pad__lit { opacity: 1; }
.pad-group { display: inline-flex; align-items: center; gap: 4px; }

.help__footer {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px 14px;
  border-top: 1px solid var(--line);
}
.help__note { font-size: 12px; color: var(--text-faint); line-height: 1.45; }
.help__source { margin-left: auto; flex: none; text-decoration: none; }

/* --- stats readout ------------------------------------------------------- */

.stats {
  position: fixed;
  bottom: 76px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 12;
  padding: 4px 12px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
  pointer-events: none;
  white-space: nowrap;
}
.stats[hidden] { display: none; }

/* --- going somewhere in time --------------------------------------------- */

.when {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 0;
  z-index: 5;
  width: min(380px, calc(100vw - 2 * var(--edge)));
  max-height: min(72vh, 600px);
  max-height: min(72dvh, 600px);
  overflow-y: auto;
  padding: 2px 16px 12px;
  animation-name: rise;
}
.when[hidden] { display: none; }
.when .section-title { margin: 16px 0 8px; font-size: 10.5px; }
.when__form { display: flex; gap: 6px; }
.when__input {
  flex: 1;
  min-width: 0;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color-scheme: dark;
  transition: border-color 0.15s var(--ease);
}
.when__input:focus { border-color: var(--accent); outline: none; }
.when__input--time { flex: 0 0 132px; }
.when__go {
  padding: 0 16px;
  background: var(--accent);
  color: #1a1206;
  font-weight: 600;
}
.when__go:hover { color: #1a1206; background: #f7cd8d; }
.when__hint { margin: 7px 0 0; font-size: 11.5px; color: var(--text-faint); }

.when__moments { display: grid; margin: 0 -16px; }
.moment {
  display: grid;
  grid-template-columns: 88px 1fr;
  column-gap: 12px;
  padding: 8px 16px;
  text-align: left;
  transition: background 0.12s var(--ease);
}
.moment:hover,
.moment:focus-visible { background: var(--hover); outline: none; }
.moment__date {
  grid-row: span 2;
  padding-top: 1px;
  font-size: 12px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}
.moment:hover .moment__date { color: var(--accent); }
.moment__title { font-size: 13.5px; color: var(--text); }
.moment__note { font-size: 12px; line-height: 1.45; color: var(--text-dim); }

.when__footer {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  padding: 12px 0 0;
  border-top: 1px solid var(--line);
}
.when__copy { gap: 8px; font-size: 12.5px; }
.when__copy svg { width: 15px; height: 15px; }
.when__status { margin-left: auto; font-size: 12px; color: var(--accent); }

/* --- first-visit hint ---------------------------------------------------- */

/* Plain words on the sky, not a toast. */
.hint {
  position: fixed;
  left: 50%;
  bottom: calc(max(var(--edge), env(safe-area-inset-bottom)) + 64px);
  z-index: 11;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: calc(100vw - 2 * var(--edge));
  padding: 6px 4px;
  font-size: 12.5px;
  color: var(--text-dim);
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.9);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, 6px);
  transition: opacity 0.5s var(--ease), transform 0.5s var(--ease);
}
.hint.panel {
  background: none;
  border: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.hint[hidden] { display: none; }
.hint.is-visible { opacity: 1; transform: translate(-50%, 0); }
.hint__dot { width: 3px; height: 3px; border-radius: 50%; background: var(--accent); opacity: 0.7; }
/* The same place, for a sentence about something that went wrong. */
.hint--notice { width: max-content; max-width: min(520px, calc(100vw - 2 * var(--edge))); white-space: normal; text-align: center; color: var(--text); }

/* --- install suggestion -------------------------------------------------- */

/* A small plate in the corner, clear of the info panel and the time bar. */
.toast {
  position: fixed;
  right: max(var(--edge), env(safe-area-inset-right));
  bottom: calc(max(var(--edge), env(safe-area-inset-bottom)) + 64px);
  z-index: 11;
  display: flex;
  align-items: center;
  gap: 4px;
  max-width: calc(100vw - 2 * var(--edge));
  padding: 8px 6px 8px 16px;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.4s var(--ease), transform 0.4s var(--ease);
}
.toast[hidden] { display: none; }
.toast.is-visible { opacity: 1; transform: none; }
.toast__text { margin-right: 8px; line-height: 1.35; }
.toast__title { font-family: var(--display); font-size: 14px; font-weight: 500; }
.toast__note { font-size: 12px; color: var(--text-dim); }
.toast__install { color: var(--accent); }
.toast__install:hover { color: var(--sun); }
.toast__install svg { width: 15px; height: 15px; }
.toast__close svg { width: 16px; height: 16px; }
/* On a phone both share the top of the screen with the menus. An open menu is
   what is being read, so they hide until it closes. */
body:has(.picker.is-open, .timebar.is-open) :is(.toast, .hint) {
  opacity: 0;
  visibility: hidden;
}

/* --- controller legend --------------------------------------------------- */

/* Which buttons do what, down the right-hand side under the top bar. Words on
   the sky like the first-visit hint, each line ending in its buttons. */
.padbar {
  position: fixed;
  top: calc(max(var(--edge), env(safe-area-inset-top)) + 58px);
  right: max(var(--edge), env(safe-area-inset-right));
  z-index: 11;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  max-width: calc(100vw - 2 * var(--edge));
  font-size: 12.5px;
  color: var(--text-dim);
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.9);
  pointer-events: none;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.5s var(--ease), transform 0.5s var(--ease);
}
.padbar[hidden] { display: none; }
.padbar.is-visible { opacity: 1; transform: none; }
.padbar__title {
  margin-bottom: 2px;
  font-family: var(--display);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.padbar__title.is-news { color: var(--accent); letter-spacing: 0.08em; }
.padbar__list { display: contents; }
.padbar__row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-height: 24px;
  white-space: nowrap;
}
/* Over the scene there is no plate behind them, so the glyphs bring their own. */
.padbar .pad { background: rgba(8, 9, 13, 0.55); text-shadow: none; }
.padbar .pad--dpad { background: none; filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.9)); }
/* In flight the right-hand side is the destination's, so the legend takes
   the place of the mouse's hint, across the top under the body picker. */
.padbar.is-flight {
  top: calc(max(var(--edge), env(safe-area-inset-top)) + 64px);
  right: auto;
  left: 50%;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: center;
  column-gap: 18px;
  width: max-content;
  /* Narrow enough to break four and three rather than six and one. */
  max-width: min(480px, calc(100vw - 2 * var(--edge)));
  transform: translate(-50%, -4px);
}
.padbar.is-flight.is-visible { transform: translateX(-50%); }
.padbar.is-flight .padbar__title { flex-basis: 100%; text-align: center; }
/* Buttons first when they read across in a row. */
.padbar.is-flight .padbar__row { flex-direction: row-reverse; gap: 7px; }
/* A phone on its side has the destination panel just below, so only one line
   of the essentials shows. The rest are in the controls list. */
@media (max-height: 500px) {
  .padbar.is-flight { max-width: calc(100vw - 2 * var(--edge)); flex-wrap: nowrap; }
  .padbar.is-flight .padbar__title,
  .padbar .padbar__row.is-extra { display: none; }
}

/* --- fallbacks ----------------------------------------------------------- */

.fallback {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-content: center;
  text-align: center;
  padding: 24px;
  background: var(--bg);
}
.fallback[hidden] { display: none; }
.fallback h1 {
  font-family: var(--display);
  font-size: 20px;
  font-weight: 400;
  letter-spacing: 0.02em;
  margin: 0 0 8px;
}
.fallback p { margin: 4px 0; color: var(--text-dim); max-width: 42ch; }
.fallback__hint { font-size: 13px; color: var(--text-faint); }

/* --- responsive ---------------------------------------------------------- */

@media (max-width: 720px) {
  :root { --edge: 10px; --gap: 8px; }

  .brand { display: none; }
  .topbar { grid-template-columns: auto 1fr; }
  .picker { justify-self: start; }
  .picker__menu { left: 0; transform: none; --unfold-x: 0; }
  .info {
    justify-self: stretch;
    align-self: end;
    width: auto;
    max-height: 40vh;
    max-height: 40dvh;
  }
  .info__header { padding: 12px 14px 0 16px; }
  .info__kind { padding: 4px 16px 12px; }
  .info__title { font-size: 24px; }
  .info__body { padding: 0 16px 14px; }
  /* Down here the panel opens upward as a sheet, and the chevron shows which way. */
  .info.is-collapsed .info__toggle svg { transform: rotate(180deg); }
  .topbar__vr-label { display: none; }
  .topbar__vr { padding: 0; width: 36px; }
  .topbar__divider { display: none; }
  /* The folded info panel owns the space above the time bar on a phone. */
  .hint {
    top: calc(max(var(--edge), env(safe-area-inset-top)) + 54px);
    bottom: auto;
    font-size: 12px;
    gap: 8px;
  }
  .hint span:nth-child(n + 4) { display: none; }
  /* Likewise the toast, which only comes once the hint has gone. */
  .toast {
    top: calc(max(var(--edge), env(safe-area-inset-top)) + 54px);
    bottom: auto;
    left: max(var(--edge), env(safe-area-inset-left));
    transform: translateY(-6px);
  }
  .toast__text { flex: 1; min-width: 0; }
  .timebar { width: 100%; justify-content: space-between; }
  .timebar__date { min-width: 0; padding-left: 0; align-items: flex-start; text-align: left; }
  .timebar__date-main { font-size: 15px; }
  .timebar__rate { display: none; }
  .timebar__bubble { display: block; }
  .timebar__scale { flex: 1; width: auto; min-width: 60px; margin: 0 8px; }
  .timebar__divider { display: none; }
  .picker__button { min-height: 40px; }
  .picker__label { font-size: 16px; }
  .marker__label { font-size: 10.5px; }
  .hud__hint { white-space: normal; }
  .padbar { top: calc(max(var(--edge), env(safe-area-inset-top)) + 52px); }
  .padbar.is-flight { top: calc(max(var(--edge), env(safe-area-inset-top)) + 52px); }
  /* Clear of the reticle. The info panel that lives down here is hidden in flight. */
  .hud__dest { top: auto; bottom: 76px; transform: none; }
}

@media (max-width: 420px) {
  .timebar__date-sub { display: none; }
  /* The date on a line of its own, and the time and Go share the next. */
  .when__form { flex-wrap: wrap; }
  .when__input { flex: 1 1 100%; }
  .when__input--time { flex: 1 1 auto; }
}
/* Four touch targets and the body's name are all a phone's top bar can hold,
   so Controls moves into Settings (and ? still opens it). */
@media (max-width: 400px) {
  .topbar__help { display: none; }
  .drawer__controls { display: inline-flex; }
}
@media (max-width: 360px) {
  .timebar__date-main { font-size: 14px; }
  /* One touch target too many for the top bar. A headset is not going to be
     driven from a phone this narrow. */
  .topbar__vr { display: none; }
  .timebar__scale { margin: 0 4px; }
  .picker__button { gap: 7px; }
  .picker__label { font-size: 15px; }
}

/* Fingers are blunter than pointers, so on a touch screen every control gets
   the full 44px (WCAG 2.5.5), whatever it draws. */
@media (pointer: coarse) {
  .btn { min-height: 44px; min-width: 44px; }
  .hud__boost { display: inline-flex; height: 56px; }
  .hud__throttle-track { height: 150px; }
  .hud__dest { width: 184px; }
  /* Beats the narrower phone layout's 40px, which came first. */
  .picker__button { min-height: 44px; }
}
/* A phone on its side: the full-height lever would run up into the top bar. */
@media (pointer: coarse) and (max-height: 500px) {
  .hud__throttle-track { height: 72px; }
  .btn--icon { width: 44px; }
  .btn--text { min-height: 44px; }
  .picker__option { min-height: 44px; }
  .chip { min-height: 36px; }
  .segmented button { min-height: 40px; }
  .timebar__date { min-height: 44px; }
  input[type="range"] { height: 44px; }
  .picker__button { min-height: 44px; }
}

/* Asked for more contrast: dimmer tiers step up, and the plates go solid. */
@media (prefers-contrast: more) {
  :root {
    --text-dim: rgba(238, 236, 230, 0.85);
    --text-faint: rgba(238, 236, 230, 0.72);
    --line: rgba(255, 255, 255, 0.22);
    --line-strong: rgba(255, 255, 255, 0.4);
    --plate: rgba(6, 7, 10, 0.94);
  }
  .ui::before {
    background:
      linear-gradient(to bottom, rgba(3, 4, 8, 0.85), rgba(3, 4, 8, 0) 140px),
      linear-gradient(to top, rgba(3, 4, 8, 0.9), rgba(3, 4, 8, 0) 170px);
  }
}

/* Asked for less transparency: no frosted glass, just solid plates. */
@media (prefers-reduced-transparency: reduce) {
  :root { --plate: rgba(8, 9, 13, 0.96); }
  .panel, .help { backdrop-filter: none; -webkit-backdrop-filter: none; }
}

/* The same plates, for a device that cannot hold its frame rate even at the
   lowest render scale (src/core/Viewport.js). A backdrop blur over a canvas
   that changes every frame is recomputed every frame. */
:root.is-constrained { --plate: rgba(8, 9, 13, 0.96); }
.is-constrained .panel, .is-constrained .help { backdrop-filter: none; -webkit-backdrop-filter: none; }

/* Windows High Contrast and similar: the system picks the colours, so the
   shapes that were drawn only with fills get real borders. */
@media (forced-colors: active) {
  .panel, .picker__menu, .when, .chip, kbd { border: 1px solid CanvasText; }
  .switch { border-color: ButtonText; }
  .switch::after { background: ButtonText; forced-color-adjust: none; }
  .switch[aria-checked="true"]::after { background: Highlight; }
  .timebar__tick, .loading__bar { background: CanvasText; forced-color-adjust: none; }
  .picker__option[aria-selected="true"]::before,
  .segmented button[aria-pressed="true"]::after,
  .btn.is-active::after,
  .btn[aria-pressed="true"]::after { background: Highlight; forced-color-adjust: none; }
  input[type="range"]::-webkit-slider-thumb { background: ButtonText; }
  .ui::before { display: none; }
}

/* Honour the OS setting, and the in-app override that mirrors it. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
body.reduce-motion *,
body.reduce-motion *::before,
body.reduce-motion *::after {
  animation-duration: 0.01ms !important;
  transition-duration: 0.01ms !important;
}
