/* Universe Engine: a full-screen 3D view with thin overlay panels. Desktop and laptop only. */
:root {
  --ink: #e9eef7; --dim: #9aa7bb; --line: rgba(160, 185, 230, 0.2); --glass: rgba(9, 13, 22, 0.74); --glass-2: rgba(20, 27, 42, 0.9);
  --accent: #8fc7ff; --warm: #ffd9a0; --hl: #ffb86b; --good: #8fe3b0; --bad: #ff9a8f; --v2028: #c9a6ff;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background: #000; color: var(--ink); font: 14px/1.45 var(--font); overflow: hidden; }
[hidden] { display: none !important; }
a { color: var(--accent); }
kbd { font: 11px var(--mono); padding: 1px 5px; border: 1px solid var(--line); border-radius: 4px; color: var(--dim); background: rgba(255, 255, 255, 0.04); }
h1, h2, h3, p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.app, .stage { position: fixed; inset: 0; }
.stage canvas { display: block; width: 100%; height: 100%; outline: none; cursor: grab; touch-action: none; }
.stage canvas:active { cursor: grabbing; }
.stage canvas:focus-visible { outline: none; box-shadow: inset 0 0 0 2px rgba(143, 199, 255, 0.5); }

.hud { position: absolute; z-index: 2; }
.eyebrow { font-size: 10.5px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--dim); }
.small { font-size: 12px; color: var(--dim); }
.mono { font-family: var(--mono); font-size: 11.5px; word-break: break-all; }
.tag { display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: 0.06em; padding: 0 6px; border-radius: 999px; border: 1px solid currentColor; vertical-align: middle; line-height: 15px; }
.tag.hl { color: var(--hl); }
.tag.y2028 { color: var(--v2028); }
.tag.beyond { color: var(--dim); }

.top-left { top: 14px; left: 18px; text-shadow: 0 1px 6px #000; }
.back { font-size: 12px; text-decoration: none; color: var(--dim); }
.back:hover { color: var(--ink); text-decoration: underline; }
.brand { font-size: 15px; font-weight: 600; letter-spacing: 0.28em; text-transform: uppercase; margin-top: 4px; }
.sys-line { font-size: 12px; color: var(--dim); margin-top: 2px; }

.toolbar { top: 12px; right: 16px; display: flex; gap: 4px; }
.tb, .btn, .seg button, .icon, .tabs button {
  background: var(--glass); border: 1px solid var(--line); border-radius: 7px; padding: 5px 11px; cursor: pointer;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); transition: background 0.15s, border-color 0.15s;
}
.tb:hover, .btn:hover, .seg button:hover, .icon:hover, .tabs button:hover { background: var(--glass-2); border-color: rgba(160, 185, 230, 0.45); }
.tb[aria-expanded="true"] { border-color: var(--accent); color: var(--accent); }
.btn { text-decoration: none; display: inline-block; color: var(--ink); }
.btn.ghost { background: transparent; }
.btn.tiny { padding: 1px 8px; font-size: 11.5px; }
.btn[aria-pressed="true"], .seg button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); background: rgba(40, 70, 110, 0.55); }
.btn[aria-pressed="true"]::before, .seg button[aria-pressed="true"]::before { content: "● "; font-size: 8px; vertical-align: 2px; }
.btn:disabled { opacity: 0.45; cursor: default; }
.icon { padding: 3px 9px; min-width: 30px; text-align: center; font-size: 13px; }
.icon.big { font-size: 12px; min-width: 38px; }
.seg { display: inline-flex; gap: 0; }
.seg button { border-radius: 0; margin-left: -1px; }
.seg button:first-child { border-radius: 7px 0 0 7px; margin-left: 0; }
.seg button:last-child { border-radius: 0 7px 7px 0; }

.pop, .info, .graph, .legend {
  background: var(--glass); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}
.pop { top: 52px; right: 16px; width: 300px; max-height: calc(100vh - 130px); overflow: auto; }
.pop h2, .info h2, .graph h2, .help h2 { font-size: 13px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; margin-bottom: 8px; }
.pop label { display: block; padding: 3px 0; cursor: pointer; }
.pop label kbd { float: right; }
.pop p { margin: 8px 0 0; }
.pop hr { border: 0; border-top: 1px solid var(--line); margin: 8px 0; }
.pop input[type="text"] { background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; width: 150px; }
.pop.wide { width: 340px; }
#star-list { max-height: 30vh; overflow: auto; margin: 6px 0; scrollbar-width: thin; }
#star-list .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 7px; box-shadow: 0 0 6px currentColor; background: currentColor; }
#star-detail .row { grid-template-columns: 1fr auto; }
#star-detail .work { grid-column: 1 / 3; background: rgba(255, 255, 255, 0.04); border-radius: 6px; padding: 4px 8px; font-size: 12.5px; overflow-x: auto; }
#star-detail h3 { font-size: 14px; margin: 10px 0 4px; }
.mode-pop { top: auto; bottom: 64px; right: auto; left: 50%; transform: translateX(-50%); width: 430px; }

.body-list { list-style: none; margin: 0; padding: 0; }
.body-list button { display: flex; width: 100%; justify-content: space-between; gap: 8px; background: none; border: 0; border-radius: 6px; padding: 3px 8px; cursor: pointer; text-align: left; }
.body-list button:hover { background: rgba(255, 255, 255, 0.07); }
.body-list button[aria-current="true"] { background: rgba(60, 100, 150, 0.4); color: var(--warm); }
.body-list .moon button { padding-left: 24px; font-size: 13px; color: var(--dim); }
.body-list .kind { color: var(--dim); font-size: 11.5px; }
.body-list .gone { text-decoration: line-through; opacity: 0.5; }

.info { top: 52px; left: 18px; width: 372px; max-height: calc(100vh - 150px); display: flex; flex-direction: column; }
.info-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.info-head h2 { font-size: 17px; letter-spacing: 0.06em; text-transform: none; margin: 0; }
.info-actions { margin: 8px 0; display: flex; gap: 4px; }
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.tabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; padding: 5px 12px; color: var(--dim); backdrop-filter: none; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.pane { overflow: auto; padding-right: 4px; scrollbar-width: thin; scrollbar-color: rgba(160, 185, 230, 0.3) transparent; }
.pane h3 { font-size: 10.5px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--dim); margin: 12px 0 2px; font-weight: 600; }
.pane h3:first-child { margin-top: 4px; }
.pane p { margin: 6px 0; }
.row { display: grid; grid-template-columns: 1fr auto 26px; align-items: baseline; gap: 2px 8px; padding: 3px 0; border-bottom: 1px solid rgba(160, 185, 230, 0.08); }
.row .k { color: var(--dim); }
.row .v { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.row .alt { grid-column: 1 / 3; text-align: right; font-size: 11.5px; color: var(--dim); font-variant-numeric: tabular-nums; margin-top: -3px; }
.row .fx { border: 1px solid var(--line); background: none; border-radius: 5px; padding: 0 5px; font: italic 12px Georgia, serif; cursor: pointer; color: var(--accent); }
.row .fx[aria-expanded="true"] { background: rgba(60, 100, 150, 0.45); }
.row .work { grid-column: 1 / 4; background: rgba(255, 255, 255, 0.04); border-radius: 6px; padding: 4px 8px; font-size: 12.5px; overflow-x: auto; }
.row .work p { margin: 4px 0; color: var(--dim); font-size: 12px; }
.row .work mjx-container { margin: 4px 0 !important; }
.note { font-size: 12px; color: var(--dim); border-left: 2px solid var(--line); padding-left: 8px; margin: 8px 0; }
.note.warn { border-left-color: var(--hl); color: var(--ink); }
.pane .links { font-size: 12px; color: var(--dim); }
.pane input[type="range"] { width: 100%; accent-color: var(--accent); }
.pane .ctrl { margin: 10px 0; }
.pane .ctrl label { display: flex; justify-content: space-between; }
.pane .ctrl output { font-variant-numeric: tabular-nums; color: var(--warm); }
.pane .btn-row { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0; }
.status { padding: 6px 10px; border-radius: 6px; background: rgba(255, 255, 255, 0.05); margin: 8px 0; }
.status.good { box-shadow: inset 3px 0 0 var(--good); }
.status.bad { box-shadow: inset 3px 0 0 var(--bad); }
canvas.chart { width: 100%; height: auto; display: block; margin: 6px 0; }

.graph { right: 16px; top: 52px; width: 380px; max-height: calc(100vh - 130px); overflow: auto; }
.graph canvas { width: 100%; height: auto; display: block; }
.graph table, .keys { border-collapse: collapse; width: 100%; font-size: 12px; }
.graph td, .graph th { padding: 2px 6px; text-align: right; border-bottom: 1px solid rgba(160, 185, 230, 0.1); font-variant-numeric: tabular-nums; }
.graph th:first-child, .graph td:first-child { text-align: left; }
.graph details { margin-top: 6px; font-size: 12px; }
.graph details > div { max-height: 150px; overflow: auto; }

.legend { left: 18px; bottom: 96px; width: 300px; max-height: 46vh; overflow: auto; font-size: 12px; padding: 8px 12px; }
.legend h3 { font-size: 10.5px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--dim); margin: 6px 0 3px; }
.legend h3:first-child { margin-top: 0; }
.legend .bar { height: 10px; border-radius: 3px; margin: 3px 0 1px; }
.legend .ticks { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--dim); font-variant-numeric: tabular-nums; }
.app.info-open .legend { left: 402px; bottom: 64px; }
.legend .arrow { display: flex; align-items: center; gap: 8px; margin: 3px 0; }
.legend .arrow svg { flex: none; }
.legend p { margin: 3px 0; color: var(--dim); }

.scale-line { left: 18px; bottom: 58px; font-size: 12px; color: var(--dim); text-shadow: 0 1px 4px #000; display: flex; gap: 10px; align-items: center; }
.scale-line strong { color: var(--warm); font-weight: 600; }

.timebar { left: 50%; bottom: 14px; transform: translateX(-50%); display: flex; align-items: center; gap: 5px; padding: 6px 10px; border-radius: 12px; background: var(--glass); border: 1px solid var(--line); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); white-space: nowrap; }
.timebar .icon, .timebar .seg button { backdrop-filter: none; background: rgba(255, 255, 255, 0.04); }
.warp { min-width: 104px; text-align: center; font-variant-numeric: tabular-nums; color: var(--warm); }
.date { min-width: 150px; text-align: center; font-variant-numeric: tabular-nums; color: var(--dim); font-size: 12.5px; }
.sep { width: 1px; height: 20px; background: var(--line); margin: 0 4px; }
.drift { font-size: 12px; font-variant-numeric: tabular-nums; color: var(--dim); min-width: 150px; }
.drift.warn { color: var(--hl); }
#mode-info { font: italic 600 13px Georgia, serif; border-radius: 50%; min-width: 26px; padding: 2px 0; }

.toast { left: 50%; top: 70px; transform: translateX(-50%); max-width: 520px; padding: 9px 16px; border-radius: 10px; background: var(--glass-2); border: 1px solid var(--line); text-align: center; }
.notice { right: 16px; bottom: 4px; font-size: 10.5px; color: rgba(154, 167, 187, 0.75); margin: 0; text-shadow: 0 1px 3px #000; }
.notice a { color: inherit; }

.intro { position: absolute; inset: 0; z-index: 5; background: #000; display: grid; place-items: center; transition: opacity 1.4s ease; }
.intro.gone { opacity: 0; pointer-events: none; }
.intro-in { text-align: center; }
.intro-title { font-size: 34px; font-weight: 300; letter-spacing: 0.5em; text-transform: uppercase; margin: 14px 0 22px 0.5em; animation: rise 1.6s ease both; }
.intro-status { color: var(--dim); min-height: 1.5em; }
.intro-bar { width: 220px; height: 2px; background: rgba(255, 255, 255, 0.12); margin: 14px auto 22px; border-radius: 2px; overflow: hidden; }
.intro-bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.3s; }
@keyframes rise { from { opacity: 0; letter-spacing: 0.9em; } to { opacity: 1; letter-spacing: 0.5em; } }

.help { background: var(--glass-2); color: var(--ink); border: 1px solid var(--line); border-radius: 12px; width: min(900px, 92vw); max-height: 88vh; padding: 18px 22px; }
.help::backdrop { background: rgba(0, 0, 0, 0.6); }
.help-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 26px; }
.help h3 { font-size: 10.5px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--dim); margin: 14px 0 6px; }
.help p, .help li { font-size: 13px; }
.help ul { margin: 6px 0; padding-left: 18px; }
.help li { margin: 4px 0; }
.keys th { text-align: left; font-weight: 400; padding: 3px 10px 3px 0; white-space: nowrap; }
.keys td { padding: 3px 0; color: var(--dim); }

.gate { min-height: 100%; display: grid; place-items: center; padding: 24px; background: radial-gradient(ellipse at 50% 30%, #18243d 0%, #05070c 70%); overflow: auto; position: fixed; inset: 0; }
.gate-box { max-width: 460px; }
.gate h1 { font-size: 24px; font-weight: 500; line-height: 1.25; margin: 10px 0 14px; }
.gate p { margin: 12px 0; color: var(--dim); font-size: 15px; }
.gate .btn { margin: 4px 6px 4px 0; }

@media (max-height: 760px) {
  .info { max-height: calc(100vh - 130px); width: 352px; }
  body { font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
