/* Observatory: the sky is the page. A centred welcome greets you and then steps aside; everything else floats,
   quietly; the formula opens on request inside the selected object's details. */
:root { --bg: #03070e; --ink: #c4cfdd; --line: #8fa6c6; --muted: #9a9384; --accent: #ffcf8a; --warn: #e09a86;
  --edge: rgba(143, 166, 198, 0.18); --edge-strong: rgba(143, 166, 198, 0.42); --accent-edge: rgba(255, 207, 138, 0.5); --accent-fill: rgba(255, 207, 138, 0.1);
  --btn-bg: rgba(8, 14, 24, 0.72); --input-bg: rgba(3, 7, 14, 0.6); --track: rgba(143, 166, 198, 0.3);
  --font-ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  --font-display: "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif; --glass: rgba(6, 11, 20, 0.78); color-scheme: dark;
  --ease: cubic-bezier(.2, .7, .2, 1); }
html, body { height: 100%; overflow: hidden; }
.stage { position: fixed; inset: 0; }

/* Welcome: one large centred heading on arrival. It never intercepts pointer input, and fades out in place
   (opacity only, ~1.8 s) at the first click or tap. The Orbits wordmark is the permanent top-left identity. */
.intro { position: fixed; left: 50%; top: 19%; transform: translate(-50%, -50%); width: min(1120px, 94vw); text-align: center; pointer-events: none; z-index: 2;
  opacity: 1; transition: opacity 1.8s cubic-bezier(.4, 0, .2, 1); }
.intro.fading { opacity: 0; }
.intro[hidden] { display: none; }
.intro:focus { outline: none; } .intro:focus-visible h1 { outline: 1px solid var(--accent-edge); outline-offset: 10px; border-radius: 6px; }
.intro h1 { font: 200 clamp(36px, 5.6vw, 66px)/1.1 var(--font-display); letter-spacing: 0.01em; margin: 0; color: #dfe6ef;
  text-shadow: 0 0 36px rgba(3, 7, 14, 0.95), 0 0 12px rgba(3, 7, 14, 0.9); }
.wordmark { position: fixed; left: max(22px, env(safe-area-inset-left)); top: max(20px, env(safe-area-inset-top)); display: flex; align-items: center; gap: 10px;
  font: 400 17px/1 var(--font-display); letter-spacing: 0.14em; color: var(--ink); z-index: 3;
  /* a button (it brings the welcome back) that still looks like the wordmark; padding gives a ≥ 32 px target without moving it */
  background: none; border: 1px solid transparent; border-radius: 10px; padding: 7px 8px; margin: -8px 0 0 -9px; min-height: 32px; cursor: pointer; }
.wordmark:hover { color: #dfe6ef; } .wordmark:focus { outline: none; } .wordmark:focus-visible { border-color: var(--accent-edge); }
.wordmark .mark { width: 15px; height: 15px; border-radius: 50%; border: 1px solid var(--line); position: relative; flex: none; }
.wordmark .mark::after { content: ""; position: absolute; width: 4px; height: 4px; border-radius: 50%; background: var(--accent); right: -3px; top: 2px; box-shadow: 0 0 6px rgba(255, 207, 138, 0.7); }

.presets { position: fixed; right: 20px; top: 20px; display: flex; gap: 2px; flex-wrap: wrap; justify-content: flex-end; max-width: 58vw; z-index: 3; }
.presets .preset { background: none; border-color: transparent; color: var(--muted); padding: 6px 10px; }
.presets .preset[aria-pressed="true"] { color: var(--accent); border-color: transparent; }
/* the formula: a collapsed disclosure directly under "Strongest pull" in the selected object's details */
.derived .drow { display: contents; }
.derived .formula-row { grid-column: 1 / -1; margin: 2px 0 4px; }
.formula-toggle { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 4px 10px 4px 8px; margin: 0; background: none; border: 1px solid var(--edge);
  border-radius: 999px; color: var(--line); font: inherit; font-size: 0.95em; cursor: pointer; }
.formula-toggle:hover { color: var(--ink); border-color: var(--edge-strong); }
.formula-toggle:focus-visible { outline: none; border-color: var(--accent-edge); color: var(--ink); }
.formula-toggle .chev { width: 7px; height: 7px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: translateY(-2px) rotate(45deg); transition: transform .2s var(--ease); }
.formula-toggle[aria-expanded="true"] { color: var(--accent); border-color: var(--accent-edge); }
.formula-toggle[aria-expanded="true"] .chev { transform: translateY(1px) rotate(-135deg); }
.formula-panel { margin-top: 6px; padding: 4px 10px; border: 1px solid var(--edge); border-radius: 12px; background: rgba(3, 7, 14, 0.45); text-align: left; overflow-x: auto; }
.formula-panel[hidden] { display: none; }
.formula-panel .katex { font-size: 0.92em; }
@media (prefers-reduced-motion: reduce) { .formula-toggle .chev { transition: none; } }
.card { position: fixed; right: 20px; top: 76px; width: 312px; max-height: calc(100vh - 210px); overflow-y: auto; background: var(--glass); border: 1px solid var(--edge);
  border-radius: 16px; padding: 14px 16px 8px; backdrop-filter: blur(6px); z-index: 3; }
.card[data-empty="true"] { display: none; }
.card .btn.primary { color: var(--accent); }
.objects { position: fixed; left: 20px; bottom: 96px; max-width: 280px; z-index: 3; }
.objects summary { cursor: pointer; color: var(--muted); list-style: none; padding: 6px 0; min-height: 32px; }
.objects summary::before { content: "○ "; color: var(--line); }
.objects .list { display: grid; gap: 4px; max-height: 40vh; overflow-y: auto; padding-top: 6px; }
.objects .body-chip { background: var(--glass); }
.body-crash-guard {}
body:has(.crash:not([hidden])) .status { visibility: hidden; }
.status { position: fixed; left: 50%; top: 104px; transform: translateX(-50%); max-width: min(720px, 70vw); text-align: center; pointer-events: none; color: var(--muted); }

.banner { position: fixed; left: 50%; top: 18px; transform: translateX(-50%); width: min(600px, calc(100vw - 40px)); background: var(--glass); border: 1px solid var(--accent-edge);
  border-radius: 14px; padding: 10px 14px; backdrop-filter: blur(8px); z-index: 5; }
.crash { position: fixed; left: 50%; top: 92px; transform: translateX(-50%); display: flex; align-items: center; gap: 10px; max-width: min(620px, calc(100vw - 32px));
  background: var(--glass); border: 1px solid rgba(224, 154, 134, 0.35); border-radius: 999px; padding: 6px 6px 6px 14px; backdrop-filter: blur(8px); z-index: 4;
  font-size: 13.5px; transition: opacity .6s; }
.crash[hidden] { display: none; } .crash.leaving { opacity: 0; }
.crash .crash-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--warn); flex: none; }
.crash .close { margin: 0; width: 30px; height: 30px; font-size: 17px; }

.under { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); width: min(720px, calc(100vw - 32px)); display: grid; justify-items: center; gap: 4px; pointer-events: none; text-align: center; }
.under > * { pointer-events: auto; }
.under .tip { background: var(--glass); border: 1px solid var(--edge); border-radius: 999px; padding: 4px 6px 4px 14px; }
.under .state { color: var(--accent); font-size: 13px; }
.under .help, .under .predict-note { margin: 0; font-size: 12.5px; color: var(--muted); pointer-events: none; }
.under .predict-note:empty, .under .help:empty { display: none; }

.dock { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); display: flex; align-items: center; gap: 10px; padding: 8px 10px; max-width: calc(100vw - 24px);
  background: var(--glass); border: 1px solid var(--edge); border-radius: 999px; backdrop-filter: blur(8px); z-index: 4; }
.dock .controls { display: flex; align-items: center; gap: 6px; }
.dock .sep { width: 1px; height: 26px; background: var(--edge); }
.add-btn { color: var(--accent); border-color: var(--accent-edge); font-weight: 600; display: inline-flex; gap: 6px; align-items: center; min-height: 44px; padding: 6px 16px; }
.addmenu { position: relative; }
.addmenu .menu { position: absolute; left: 0; bottom: 56px; width: 300px; background: #060c16; border: 1px solid var(--edge-strong); border-radius: 16px; padding: 6px; display: grid; gap: 2px; box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5); }
.view { position: relative; } .view summary { list-style: none; } .view summary::-webkit-details-marker { display: none; }
.view .pop { position: absolute; right: 0; bottom: 54px; width: 350px; max-height: 70vh; overflow-y: auto; background: #060c16; border: 1px solid var(--edge); border-radius: 16px; padding: 14px 16px; }
.gravity { display: grid; grid-template-columns: 1fr auto 64px; gap: 4px 10px; align-items: center; } .gravity .g-label, .gravity .hint, .gravity .err { grid-column: 1 / -1; } .gravity .g-out { color: var(--accent); }
/* elapsed simulated time sits directly under the time rate, inside the dock */
.rate-col { display: grid; gap: 1px; line-height: 1.15; } .rate-col .clock { color: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; white-space: nowrap; opacity: 0.85; }
.under .slowed { margin: 0; color: var(--accent); font-size: 12.5px; } .under .slowed:empty { display: none; }
.dock[hidden] { display: none; }
.dock-hide { width: 36px; height: 36px; min-height: 36px; padding: 0; display: inline-grid; place-items: center; color: var(--muted); font-size: 17px; line-height: 1; }
.dock-show { position: fixed; left: 50%; bottom: max(14px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 4; min-height: 36px; padding: 6px 14px;
  background: var(--glass); border: 1px solid var(--edge); border-radius: 999px; color: var(--muted); font: inherit; font-size: 13px; cursor: pointer; backdrop-filter: blur(8px); }
.dock-show:hover, .dock-hide:hover { color: var(--ink); } .dock-show[hidden] { display: none; }
.dock-show { display: inline-flex; align-items: center; gap: 6px; }
.credits { position: fixed; left: 50%; bottom: 4px; transform: translateX(-50%); margin: 0; font-size: 10.5px; line-height: 14px; color: var(--muted); opacity: 0.7;
  white-space: nowrap; max-width: calc(100vw - 16px); overflow: hidden; text-overflow: ellipsis; z-index: 3; }
.credits a { color: inherit; text-decoration: none; } .credits a:hover, .credits a:focus-visible { color: var(--ink); text-decoration: underline; }
body.dock-hidden .credits { display: none; }
body.dock-hidden .under { bottom: 60px; } body.dock-hidden .objects { bottom: 60px; }
@media (max-width: 1100px) { .under { bottom: 120px; } .objects { bottom: 130px; } }
@media (max-height: 520px) and (min-width: 600px) { /* phone landscape */
  .intro { top: 20%; } .intro h1 { font-size: 34px; } .wordmark { top: 12px; font-size: 15px; }
  .status { display: none; } body:has(.under .tip:not([hidden])) .objects { display: none; }
  .card { top: 60px; max-height: calc(100vh - 140px); width: 280px; } .presets { top: 10px; left: auto; max-width: 60vw; flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto; scrollbar-width: none; } .presets .preset { flex: none; }
  .dock { bottom: 19px; padding: 4px 8px; } .under { bottom: 76px; } .objects { bottom: 76px; } .credits { bottom: 2px; font-size: 10px; line-height: 13px; }
  .dock .view .long { display: none; } .dock .rate input { width: 110px; } .dock { gap: 8px; }
  .crash { top: 56px; left: 16px; transform: none; max-width: calc(100vw - 330px); border-radius: 14px; }
  body:has(.card[data-empty="false"]) .under .tip, body:has(.card[data-empty="false"]) .objects { display: none; }
  .under { left: 16px; transform: none; width: calc(100vw - 330px); justify-items: start; }
}
@media (max-width: 760px) {
  .intro { top: 20%; width: 92vw; } .intro h1 { font-size: 36px; }
  .measure { left: 6px; right: 6px; top: 96px; width: auto; } body:has(.measure:not([hidden])) .crash { top: 172px; }
  .wordmark { top: max(14px, env(safe-area-inset-top)); left: max(14px, env(safe-area-inset-left)); font-size: 15px; }
  .presets { top: 52px; left: 6px; right: 6px; max-width: none; justify-content: flex-start; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .presets .preset { flex: none; }
    /* two-row dock: add, play and speed; then reset, undo, measure and view (a zero-height break item splits the rows) */
  .dock { left: 6px; right: 6px; transform: none; bottom: 22px; border-radius: 20px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 8px; }
  .dock .controls { display: contents; }
  .dock .addmenu { order: 1; } .add-btn { min-height: 44px; padding: 6px 12px; }
  .dock .btn.play { order: 2; } .dock .time { order: 3; flex: 1; min-width: 0; justify-content: flex-end; }
  .rate { min-width: 0; } .rate input { width: auto; flex: 1; min-width: 50px; } .rate-out { min-width: 0; font-size: 12px; }
  .dock .sep { display: block; order: 4; flex-basis: 100%; height: 0; width: auto; background: none; }
  .dock [data-act="reset"] { order: 5; } .dock [data-act="undo"] { order: 6; } .dock .measure-btn { order: 7; } .dock .view { order: 8; } .dock .dock-hide { order: 9; flex: none; }
  .dock [data-act="reset"], .dock [data-act="undo"], .dock .measure-btn, .dock .view { flex: 1; }
  .dock .view > summary { width: 100%; text-align: center; } .dock .view .long { display: none; }
  .dock [data-act="reset"], .dock [data-act="undo"], .dock .measure-btn, .dock .view > summary { padding: 6px 8px; font-size: 14px; }
  .card { left: 6px; right: 6px; width: auto; top: auto; bottom: 138px; max-height: 36vh; padding: 10px 12px 2px; }
  .status { top: 96px; bottom: auto; left: 12px; right: 12px; transform: none; max-width: none; font-size: 12.5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  body:has(.card[data-empty="false"]) .status, body:has(.card[data-empty="false"]) .objects, body:has(.card[data-empty="false"]) .under { display: none; }
  .objects { bottom: 142px; left: 12px; } body:has(.under .tip:not([hidden])) .objects { display: none; }
  .under { bottom: 142px; } .under .help { display: none; }
  .crash { top: 100px; border-radius: 14px; }
  .addmenu .menu { position: fixed; left: 8px; right: 8px; bottom: 138px; width: auto; }
  .view .pop { position: fixed; left: 8px; right: 8px; bottom: 138px; width: auto; max-height: 56vh; }
  .credits { font-size: 10px; } .rate-col .clock { font-size: 11px; }
  body.dock-hidden .card { bottom: 64px; max-height: 50vh; }
}
body.welcome-on .status, body:has(.measure:not([hidden])) .status { visibility: hidden; }
.measure-btn[aria-pressed="true"] { color: var(--accent); border-color: var(--accent-edge); }
.measure { position: fixed; left: 20px; top: 64px; width: min(400px, calc(100vw - 40px)); background: var(--glass); border: 1px solid var(--accent-edge); border-radius: 14px;
  padding: 8px 8px 8px 12px; backdrop-filter: blur(8px); z-index: 4; }
.measure[hidden] { display: none; }
.measure .m-row { display: flex; align-items: center; gap: 6px; } .measure select { flex: 1; min-width: 0; width: auto; min-height: 36px; }
.measure .m-link { color: var(--accent); } .measure .close { margin: 0; width: 34px; height: 34px; }
.measure .m-out { margin: 6px 2px 0; color: var(--accent); font-variant-numeric: tabular-nums; font-size: 14px; } .measure .m-out:empty { display: none; }
.measure .m-note { margin: 4px 2px 0; color: var(--muted); font-size: 12.5px; } .measure .m-note:empty { display: none; }
@media (prefers-reduced-motion: reduce) { .intro, .crash { transition: none !important; } }
@media (max-width: 760px) { .measure { left: 6px; right: 6px; top: 96px; width: auto; } }
@media (max-height: 520px) and (min-width: 600px) { .measure { top: 56px; } }
