:root {
  color-scheme: dark;
  --bg: #000;
  --panel: rgba(16, 17, 20, 0.72);
  --panel-solid: #121316;
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.18);
  --fg: #ebe8e1;
  --dim: #9a978f;
  --faint: #6c6a65;
  --accent: #f3e3bd;
  --accent-ink: #1b1608;
  --site: #8fd3ff;
  --err: #ff9b8a;
  --r: 14px;
  --gap: 12px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); overflow: hidden; }
body { font: 13px/1.45 var(--font); color: var(--fg); -webkit-font-smoothing: antialiased; font-variant-numeric: tabular-nums; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
canvas#moon { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; display: block; outline: none; touch-action: none; }

.panel {
  position: fixed; z-index: 2;
  background: var(--panel);
  -webkit-backdrop-filter: blur(16px) saturate(1.2); backdrop-filter: blur(16px) saturate(1.2);
  border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}
h2 { margin: 14px 0 6px; font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--dim); display: flex; justify-content: space-between; }
h2:first-child { margin-top: 0; }
h2 output { color: var(--fg); letter-spacing: 0; text-transform: none; font-weight: 500; }

/* Loading */
.loading { position: fixed; inset: 0; display: grid; place-items: center; color: var(--dim); letter-spacing: 0.04em; pointer-events: none; transition: opacity 0.6s; z-index: 1; }
.loading.done { opacity: 0; }
.progress { position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 5; pointer-events: none; opacity: 0; transition: opacity 0.8s; }
.progress.on { opacity: 1; }
.progress div { height: 100%; width: 0; background: linear-gradient(90deg, transparent, var(--accent)); transition: width 0.3s; }

/* Info */
.info { top: var(--gap); left: var(--gap); width: 300px; padding: 14px 16px 12px; }
.info-head { display: flex; gap: 12px; align-items: center; background: none; border: 0; padding: 0; text-align: left; width: 100%; cursor: default; }
.glyph { width: 44px; height: 44px; flex: none; transform: rotate(var(--tilt, 0deg)); }
.glyph-dark { fill: #26272b; }
.glyph-lit { fill: var(--accent); }
.phase-name { display: block; font-size: 19px; font-weight: 600; letter-spacing: -0.01em; }
.phase-sub { display: block; color: var(--dim); }
.when { margin: 10px 0 8px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.when b { font-weight: 500; }
.when small { display: block; color: var(--dim); font-size: 12px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; margin: 0; }
.stats dt { color: var(--dim); font-size: 11px; }
.stats dd { margin: 0; }
.events { list-style: none; margin: 10px 0 0; padding: 8px 0 0; border-top: 1px solid var(--line); display: grid; gap: 3px; }
.events li { display: grid; grid-template-columns: 16px 1fr auto; gap: 8px; align-items: center; }
.events li span:last-child { color: var(--dim); }
.events svg { width: 14px; height: 14px; }

/* Top bar */
.topbar { position: fixed; top: var(--gap); right: var(--gap); display: flex; gap: 8px; z-index: 3; }
.search { position: relative; }
.search svg { position: absolute; left: 11px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); fill: none; stroke: var(--dim); stroke-width: 1.6; pointer-events: none; }
.search input { width: 300px; height: 38px; padding: 0 12px 0 34px; border-radius: 19px; border: 1px solid var(--line); background: var(--panel); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); outline: none; }
.search input:focus { border-color: var(--line-strong); }
.search input::-webkit-search-cancel-button { filter: invert(0.6); }
.results { position: absolute; top: 44px; left: 0; right: 0; margin: 0; padding: 6px; list-style: none; background: var(--panel-solid); border: 1px solid var(--line); border-radius: 12px; display: none; max-height: 60vh; overflow: auto; }
.results.open { display: block; }
.results li { padding: 7px 10px; border-radius: 8px; cursor: pointer; display: flex; justify-content: space-between; gap: 10px; }
.results li small { color: var(--dim); white-space: nowrap; }
.results li[aria-selected="true"], .results li:hover { background: rgba(255, 255, 255, 0.07); }
.icon-btn { width: 38px; height: 38px; border-radius: 19px; border: 1px solid var(--line); background: var(--panel); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); display: grid; place-items: center; font-weight: 600; }
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: var(--fg); stroke-width: 1.5; stroke-linejoin: round; }
.icon-btn[aria-expanded="true"] { background: var(--accent); color: var(--accent-ink); }
.icon-btn[aria-expanded="true"] svg { stroke: var(--accent-ink); }

/* Layers */
.layers { top: 62px; right: var(--gap); width: 264px; padding: 14px 16px; max-height: calc(100dvh - 62px - 120px); overflow: auto; display: none; }
.layers.open { display: block; }
.seg { display: flex; background: rgba(255, 255, 255, 0.05); border-radius: 9px; padding: 3px; gap: 3px; }
.seg button { flex: 1; border: 0; background: none; padding: 6px 4px; border-radius: 7px; color: var(--dim); }
.seg button.on { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.toggle { display: flex; align-items: center; gap: 10px; padding: 5px 0; cursor: pointer; }
.toggle input { appearance: none; -webkit-appearance: none; width: 30px; height: 18px; border-radius: 9px; background: rgba(255, 255, 255, 0.14); position: relative; flex: none; margin: 0; transition: background 0.15s; cursor: pointer; }
.toggle input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 7px; background: #fff; transition: transform 0.15s; }
.toggle input:checked { background: var(--accent); }
.toggle input:checked::after { transform: translateX(12px); background: var(--accent-ink); }
.toggle small { color: var(--faint); margin-left: 4px; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
.credits { color: var(--faint); font-size: 11px; margin: 14px 0 0; line-height: 1.5; }
#data-used { display: block; margin-top: 6px; color: var(--dim); }

/* Feature card */
.card { left: var(--gap); bottom: 112px; width: 320px; padding: 14px 16px; }
.card-kind { color: var(--dim); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; }
.card h3 { margin: 2px 0 6px; font-size: 22px; font-weight: 600; letter-spacing: -0.01em; }
.card-origin { margin: 0 0 10px; color: #d6d2c8; }
.card-facts { display: grid; gap: 4px; margin: 0 0 12px; }
.card-facts div { display: grid; grid-template-columns: 70px 1fr; }
.card-facts dt { color: var(--dim); }
.card-facts dd { margin: 0; }
.card-actions { display: flex; align-items: center; gap: 14px; }
.card-actions a { color: var(--dim); text-decoration: none; }
.card-actions a:hover { color: var(--fg); }
.primary { border: 0; background: var(--accent); color: var(--accent-ink); font-weight: 600; padding: 8px 14px; border-radius: 9px; }
.secondary { border: 1px solid var(--line-strong); background: none; padding: 7px 12px; border-radius: 9px; }
.close { position: absolute; top: 8px; right: 10px; border: 0; background: none; color: var(--dim); font-size: 20px; line-height: 1; padding: 4px; }

/* Cursor readout */
.cursor { position: fixed; right: var(--gap); bottom: 112px; z-index: 2; color: var(--dim); font-size: 12px; text-align: right; pointer-events: none; text-shadow: 0 1px 3px #000; }
.cursor b { color: var(--fg); font-weight: 500; }

/* Time bar */
.timebar { left: 50%; bottom: var(--gap); transform: translateX(-50%); width: min(820px, calc(100vw - 2 * var(--gap))); padding: 10px 12px; display: flex; gap: 12px; align-items: center; }
.play { width: 44px; height: 44px; border-radius: 22px; border: 0; background: var(--accent); flex: none; display: grid; place-items: center; }
.play svg { width: 18px; height: 18px; fill: var(--accent-ink); }
.time-main { flex: 1; min-width: 0; }
.time-row { display: flex; align-items: center; gap: 8px; }
.date { border: 0; background: none; padding: 2px 4px; border-radius: 6px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.date:hover { background: rgba(255, 255, 255, 0.07); }
#date-input { background: var(--panel-solid); border: 1px solid var(--line-strong); border-radius: 6px; padding: 2px 6px; }
.speeds { display: flex; gap: 2px; margin-left: auto; }
.speeds button, .now { border: 0; background: none; color: var(--dim); padding: 3px 7px; border-radius: 6px; font-size: 12px; white-space: nowrap; }
.speeds button.on { color: var(--accent-ink); background: var(--accent); font-weight: 600; }
.now { border: 1px solid var(--line-strong); color: var(--fg); }
.now.live { border-color: transparent; color: var(--accent); }
.tape { display: block; width: 100%; height: 34px; margin-top: 6px; cursor: ew-resize; touch-action: none; }

/* Labels */
#labels { position: fixed; inset: 0; pointer-events: none; z-index: 1; overflow: hidden; }
.lbl { position: absolute; left: 0; top: 0; white-space: nowrap; font-size: 12px; color: rgba(245, 241, 232, 0.92); text-shadow: 0 0 3px #000, 0 0 6px rgba(0, 0, 0, 0.8); pointer-events: none; will-change: transform, opacity; padding: 2px 4px; transform-origin: 0 0; }
.lbl::before { content: ""; display: inline-block; width: 4px; height: 4px; border-radius: 2px; background: currentColor; margin-right: 5px; vertical-align: 2px; }
.lbl.big::before { display: none; }
.lbl.sea { font-style: italic; letter-spacing: 0.12em; text-transform: uppercase; font-size: 11px; color: rgba(220, 230, 245, 0.85); }
.lbl.site { color: var(--site); font-weight: 600; }
.lbl.site::before { width: 6px; height: 6px; border-radius: 1px; transform: rotate(45deg); }
.lbl:hover { color: #fff; }
.lbl.sel { color: var(--accent); }

/* Credits link: the corner beside the time bar, or just above it once the bar
   fills the width */
.corner-link {
  position: fixed; right: var(--gap); bottom: var(--gap); z-index: 2;
  padding: 3px 10px; border-radius: 999px; font-size: 11px; letter-spacing: 0.02em; color: var(--dim); text-decoration: none;
  /* Readable over sunlit ground: the panels' glass */
  background: var(--panel); border: 1px solid var(--line);
  -webkit-backdrop-filter: blur(16px) saturate(1.2); backdrop-filter: blur(16px) saturate(1.2);
}
.corner-link:hover { color: var(--fg); border-color: var(--line-strong); }
@media (max-width: 1023px) {
  .corner-link { bottom: calc(var(--gap) + 92px); }
  .cursor { bottom: 136px; }
}

/* Help and errors */
.help { top: 50%; left: 50%; transform: translate(-50%, -50%); width: min(420px, calc(100vw - 32px)); padding: 18px 20px; z-index: 6; }
.help h3 { margin: 0 0 10px; }
.help dl { margin: 0; display: grid; gap: 4px; }
.help dl div { display: grid; grid-template-columns: 120px 1fr; }
.help dt { font-family: var(--mono); color: var(--accent); font-size: 12px; }
.help dd { margin: 0; color: #d6d2c8; }
.error { top: 50%; left: 50%; transform: translate(-50%, -50%); width: min(520px, calc(100vw - 32px)); padding: 18px 20px; color: var(--err); z-index: 7; }
.credits a { color: var(--dim); }
.credits a:hover { color: var(--fg); }

/* No WebGPU: a still frame and an explanation, in place of the interface */
body.unsupported-on > :not(.unsupported):not(script) { display: none !important; }
.unsupported { position: fixed; inset: 0; overflow-y: auto; display: grid; place-items: center; padding: 32px 16px; }
.unsupported-inner { display: grid; grid-template-columns: minmax(0, 320px) minmax(0, 400px); gap: 48px; align-items: center; }
.unsupported img { width: 100%; height: auto; display: block; }
.unsupported h1 { margin: 0 0 14px; font-size: 24px; line-height: 1.25; font-weight: 600; letter-spacing: -0.01em; text-wrap: balance; }
.unsupported p { margin: 0 0 12px; font-size: 15px; line-height: 1.55; color: #d6d2c8; text-wrap: pretty; }
.unsupported p + p { color: var(--dim); }
.unsupported details { margin: 18px 0 0; font-size: 12px; color: var(--faint); }
.unsupported summary { cursor: pointer; }
.unsupported code { display: block; margin-top: 6px; font: 12px/1.5 var(--mono); color: var(--dim); overflow-wrap: anywhere; }
.unsupported-links { margin-top: 22px !important; font-size: 13px !important; }
.unsupported a { color: var(--accent); text-decoration: none; }
.unsupported a:hover { text-decoration: underline; }
@media (max-width: 720px) {
  .unsupported-inner { grid-template-columns: 1fr; gap: 24px; justify-items: center; text-align: center; max-width: 420px; }
  .unsupported img { width: min(220px, 60vw); }
}

/* Phones */
@media (max-width: 720px) {
  :root { --gap: 10px; }
  .info { width: auto; right: var(--gap); padding: 10px 12px; }
  .info-head { cursor: pointer; }
  .info.collapsed .info-body { display: none; }
  .glyph { width: 36px; height: 36px; }
  .phase-name { font-size: 16px; }
  .topbar { top: auto; bottom: 128px; right: var(--gap); left: var(--gap); }
  .search { flex: 1; }
  .search input { width: 100%; }
  .results { top: auto; bottom: 44px; }
  .layers { top: auto; bottom: 178px; left: var(--gap); right: var(--gap); width: auto; max-height: 55dvh; }
  .card { left: var(--gap); right: var(--gap); width: auto; bottom: 178px; }
  .cursor { display: none; }
  .timebar { padding: 8px 10px; gap: 10px; }
  .play { width: 40px; height: 40px; }
  .speeds button:first-child, .speeds button:last-child { display: none; }
  .corner-link { bottom: calc(var(--gap) + 88px); padding: 2px 9px; }
}

/* Credits page */
html.page, html.page body { height: auto; overflow: auto; }
.doc { max-width: 680px; margin: 0 auto; padding: 40px 20px 80px; font-size: 15px; line-height: 1.6; }
.doc a { color: var(--accent); text-decoration: none; }
.doc a:hover { text-decoration: underline; }
.doc .back { display: inline-block; margin-bottom: 36px; font-size: 13px; color: var(--dim); }
.doc h1 { margin: 0 0 12px; font-size: 32px; line-height: 1.15; font-weight: 600; letter-spacing: -0.02em; }
.doc .lede { margin: 0 0 8px; font-size: 17px; color: #d6d2c8; text-wrap: pretty; }
.doc section { margin-top: 44px; }
.doc h2 { margin: 0 0 14px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.doc p { margin: 0 0 8px; text-wrap: pretty; }
.sources { margin: 0; display: grid; gap: 20px; }
.sources div { display: grid; grid-template-columns: 170px 1fr; gap: 16px; }
.sources dt { font-weight: 600; color: var(--fg); }
.sources dd { margin: 0; color: #d6d2c8; }
.doc .cite { font-size: 13px; line-height: 1.55; color: var(--dim); overflow-wrap: anywhere; }
.doc .note { margin-top: 18px; font-size: 13px; color: var(--faint); }
@media (max-width: 720px) {
  .doc { padding-top: 28px; }
  .doc h1 { font-size: 28px; }
  .sources div { grid-template-columns: 1fr; gap: 4px; }
}
