:root {
  --bg: #05070b;
  --panel: rgba(13, 17, 25, 0.88);
  --line: rgba(255, 255, 255, 0.12);
  --text: #e8edf3;
  --muted: #a3afbd;      /* 8.2:1 on --panel */
  --accent: #7cc4ff;     /* 9.6:1 on --panel */
  --accent-ink: #04121f;
  --warn: #ffb86b;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.4 var(--font); overflow: hidden; }
canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; outline: none; touch-action: none; }
canvas:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: fixed; left: 8px; top: -40px; z-index: 10; background: var(--accent); color: var(--accent-ink); padding: 6px 10px; border-radius: 4px; }
.skip:focus { top: 8px; }

button, select, input, .button {
  font: inherit; color: var(--text); background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line); border-radius: 6px; padding: 4px 9px; min-height: 30px;
}
button, .button { cursor: pointer; }
button:hover, .button:hover { background: rgba(255, 255, 255, 0.12); }
button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
button.icon { min-width: 32px; padding: 4px 6px; }
button.link { background: none; border: 0; color: var(--muted); text-decoration: underline; min-height: 0; padding: 0; }
input[type="range"] { padding: 0; width: 100%; accent-color: var(--accent); }
input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; }

.bar {
  position: fixed; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 12px;
  padding: 8px 12px; background: var(--panel); border-bottom: 1px solid var(--line); backdrop-filter: blur(6px); z-index: 2;
}
.brand { font-weight: 600; letter-spacing: 0.02em; white-space: nowrap; }
.time { display: flex; align-items: center; gap: 6px; flex: 1; justify-content: center; flex-wrap: wrap; }
.time input { font-family: var(--mono); }
.utc, .muted { color: var(--muted); }
.modes { display: flex; align-items: center; gap: 4px; }
.modes select:disabled { opacity: 0.5; }
.rate { display: flex; align-items: center; gap: 6px; color: var(--muted); }

.panel {
  position: fixed; top: 56px; left: 10px; bottom: 40px; width: 350px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px; display: flex; flex-direction: column; gap: 8px;
  backdrop-filter: blur(6px); z-index: 2; overflow: hidden;
}
.panel[hidden] { display: none; }
.tabs { display: flex; gap: 2px; flex-wrap: wrap; border-bottom: 1px solid var(--line); padding-bottom: 6px; }
.tabs [role="tab"] { border: 0; background: none; color: var(--muted); padding: 4px 7px; }
.tabs [role="tab"][aria-selected="true"] { color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); }
[role="tabpanel"] { display: flex; flex-direction: column; gap: 8px; min-height: 0; overflow: auto; }
[role="tabpanel"][hidden] { display: none; }
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.list li { display: flex; align-items: center; gap: 6px; }
.list li > button:first-child { flex: 1; text-align: left; background: none; border-color: transparent; }
.list li > button:first-child:hover { background: rgba(255, 255, 255, 0.08); }
.scroll { overflow: auto; min-height: 120px; max-height: 50vh; }
.row { display: flex; align-items: center; gap: 8px; }
.row > span:first-child { color: var(--muted); }
.row.check { gap: 6px; }
.stack { display: flex; flex-direction: column; gap: 4px; color: var(--muted); }
.stack input { color: var(--text); }
#data-form { display: flex; flex-direction: column; gap: 8px; }
.layer { border: 1px solid var(--line); border-radius: 8px; padding: 8px; display: grid; grid-template-columns: 90px 1fr; gap: 4px 8px; align-items: center; }
.layer h3 { grid-column: 1 / -1; margin: 0 0 2px; font-size: 13px; font-weight: 600; }
.layer label { color: var(--muted); }

.card {
  position: fixed; top: 56px; right: 10px; width: 360px; max-height: calc(100% - 100px); overflow: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px; z-index: 2; backdrop-filter: blur(6px);
}
.card header { justify-content: space-between; }
.card h2 { margin: 0; font-size: 15px; }
.card .small { flex-wrap: wrap; font-size: 12px; margin: 6px 0; }
.card .small label { display: flex; flex-direction: column; gap: 2px; color: var(--muted); }
#ro-lines { display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; margin: 6px 0 0; font-size: 12.5px; }
#ro-lines dt { color: var(--muted); }
#ro-lines dd { margin: 0; font-family: var(--mono); overflow-wrap: anywhere; }
.ro-desc { margin: 8px 0 0; font-size: 12.5px; white-space: pre-line; overflow-wrap: anywhere; max-height: 30vh; overflow: auto; }

.status {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex; gap: 14px; align-items: center; padding: 6px 12px;
  background: var(--panel); border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); z-index: 2;
}
.attrib { margin-left: auto; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.metrics { position: fixed; right: 10px; bottom: 40px; margin: 0; padding: 8px 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; font: 12px/1.45 var(--mono); z-index: 2; }
.toasts { position: fixed; left: 50%; bottom: 48px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; z-index: 5; }
.toast { background: #2a1d0d; border: 1px solid var(--warn); color: #ffe2bf; border-radius: 8px; padding: 6px 12px; max-width: 70vw; }
.hint { position: fixed; left: 50%; top: 64px; transform: translateX(-50%); margin: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; z-index: 3; }
.scale { position: fixed; left: 14px; bottom: 40px; z-index: 2; pointer-events: none; font-size: 12px; color: #eee; text-shadow: 0 0 3px #000, 0 0 2px #000; }
.scale div { height: 5px; border: 1.5px solid #eee; border-top: none; margin-top: 2px; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.8); }
.list .moons { margin-left: 14px; flex: 1 0 100%; }
.list li:has(> .moons) { flex-wrap: wrap; }
.drop canvas { box-shadow: inset 0 0 0 3px var(--accent); }
dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 10px; }
dialog::backdrop { background: rgba(0, 0, 0, 0.5); }
#keys-list { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; }
#keys-list dt { font-family: var(--mono); }
#keys-list dd { margin: 0; color: var(--muted); }

.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; align-items: end; }
.grid3 button { grid-column: 1 / -1; }
.num { width: 5em; }
.table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.table th, .table td { text-align: left; padding: 3px 6px; border-bottom: 1px solid var(--line); }
.table tbody tr { cursor: pointer; }
.table tbody tr:hover, .table tbody tr:focus { background: rgba(255, 255, 255, 0.06); outline: none; }

@media (max-width: 760px) {
  .panel { width: auto; right: 10px; top: auto; height: 45%; }
  .card { width: auto; left: 10px; }
  .brand { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
@media (forced-colors: active) {
  button[aria-pressed="true"], .tabs [role="tab"][aria-selected="true"] { outline: 2px solid CanvasText; }
}

.nav { position: fixed; right: 14px; bottom: 40px; z-index: 2; display: grid; grid-template-columns: repeat(3, 34px); grid-template-rows: repeat(3, 34px); gap: 2px; }
.nav button { width: 34px; height: 34px; padding: 6px; border-radius: 17px; background: rgba(20, 22, 28, 0.78); border: 1px solid rgba(255, 255, 255, 0.18); color: #eee; cursor: pointer; }
.nav button:hover { background: rgba(40, 44, 54, 0.9); }
.nav button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.nav svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.nav .compass svg path { fill: #bbb; stroke: none; }
.nav .compass svg path.n { fill: #e5484d; }
#nav-tilt-up { grid-column: 2; grid-row: 1; }
#nav-left { grid-column: 1; grid-row: 2; }
#nav-north { grid-column: 2; grid-row: 2; }
#nav-right { grid-column: 3; grid-row: 2; }
#nav-tilt-down { grid-column: 2; grid-row: 3; }

/* Charts */
#chart { top: auto; bottom: 150px; width: 480px; }
#chart svg { width: 100%; height: auto; display: block; }
#chart .axis { stroke: var(--line); }
#chart .tick { fill: var(--muted); font-size: 10px; }
#chart .series { fill: none; stroke: var(--accent); stroke-width: 1.6; }
#chart .grid { stroke: rgba(255, 255, 255, 0.06); }
#chart-summary { margin: 6px 0; font-family: var(--mono); }
#rec[aria-pressed="true"] { background: #c0392b; color: #fff; }

/* Timeline */
.timeline {
  position: fixed; left: 370px; right: 130px; bottom: 40px; max-height: 40vh; overflow: auto; z-index: 2;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; backdrop-filter: blur(6px);
}
.timeline header { justify-content: space-between; gap: 10px; }
.timeline h2 { margin: 0; font-size: 13px; }
.tl-rows { position: relative; display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }
.tl-row { display: grid; grid-template-columns: 150px 1fr; align-items: center; gap: 8px; font-size: 12px; }
.tl-row > span { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-track { position: relative; height: 18px; background: rgba(255, 255, 255, 0.05); border-radius: 4px; cursor: pointer; }
.tl-bar { position: absolute; top: 2px; height: 14px; min-width: 3px; border-radius: 3px; background: var(--accent); }
.tl-bar.eclipse { background: #8a94a6; }
.tl-bar.conjunction { background: var(--warn); }
.tl-cursor { position: absolute; top: 0; bottom: 0; width: 2px; background: #fff; pointer-events: none; margin-left: 158px; }
@media (max-width: 800px) { .timeline { left: 10px; right: 130px; } .tl-row { grid-template-columns: 90px 1fr; } }
