:root {
  color-scheme: dark;
  font: 13px/1.4 ui-monospace, SFMono-Regular, Consolas, monospace;
  background: #080f1d;
  color: #e5efff;
  --muted: #a6b7cd;
  --line: #2c3c54;
  --active: #80e2d8;
  --panel: #101a2a;
}
* { box-sizing: border-box; }
body { margin: 0; overflow: hidden; }
[hidden] { display: none !important; }
main { position: relative; height: 100vh; height: 100dvh; display: grid; grid-template: auto minmax(0,1fr) auto / minmax(0,1fr); }
main > header, main > footer, main > .scene, main > aside, #pre-panel { grid-column: 1; }
header, footer { position: relative; background: var(--panel); padding: .45rem .7rem; }
header {
  grid-row: 1; display: flex; align-items: center; flex-wrap: wrap; gap: .4rem .65rem;
  justify-content: space-between; border-bottom: 1px solid var(--line);
  padding-top: max(.45rem, env(safe-area-inset-top));
  padding-inline: max(.7rem, env(safe-area-inset-left)) max(.7rem, env(safe-area-inset-right));
}
header strong { font-size: 1.05rem; white-space: nowrap; letter-spacing: .04em; }
header small { margin-left: .5rem; font-weight: 400; color: var(--muted); }
nav, .actions, .timeline, .legend { display: flex; gap: .35rem; align-items: center; min-width: 0; }
nav, .legend { flex-wrap: wrap; }
button, select { font: inherit; color: inherit; background: #15243a; border: 1px solid var(--line); border-radius: 3px; padding: .3rem .5rem; cursor: pointer; }
button:hover, button[aria-pressed=true], button[aria-expanded=true] { border-color: var(--active); color: var(--active); }
button:focus-visible, input:focus-visible, summary:focus-visible, canvas:focus-visible { outline: 2px solid var(--active); outline-offset: -2px; }
#gear { font-size: 1.15rem; }
#beam-control { display: flex; align-items: center; gap: .3rem; margin: 0; }
.scene { grid-row: 2; position: relative; min-height: 0; min-width: 0; overflow: hidden; }
.scene > canvas { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
.scene > canvas:active { cursor: grabbing; }
#hint { position: absolute; left: .7rem; bottom: .35rem; color: var(--muted); font-size: .73rem; pointer-events: none; }
#zoom-tools { position: absolute; right: .7rem; bottom: 1.6rem; display: flex; gap: .25rem; }
#zoom-tools button { min-width: 2.8rem; min-height: 2.8rem; font-size: 1.2rem; }
#loading { position: absolute; z-index: 3; top: 50%; left: 50%; transform: translate(-50%,-50%); background: var(--panel); padding: .85rem 1rem; border: 1px solid var(--line); width: min(90%,340px); }
progress { display: block; width: 100%; height: .65rem; margin-top: .65rem; accent-color: var(--active); }
footer {
  grid-row: 3; border-top: 1px solid var(--line); display: grid; gap: .3rem;
  padding-bottom: max(.45rem, env(safe-area-inset-bottom));
  padding-inline: max(.7rem, env(safe-area-inset-left)) max(.7rem, env(safe-area-inset-right));
}
.timeline input { flex: 1; min-width: 0; margin: 0 .15rem; }
.timeline output { min-width: 17ch; text-align: right; }
.legend { font-size: .8rem; color: var(--muted); }
.legend i { width: 75px; height: 7px; }
.legend label { margin: 0 .25rem 0 0; }
#eload-legend { display: inline-flex; align-items: center; gap: .25rem; }
#eload-legend i { width: 45px; background: linear-gradient(90deg,#20427d,#32a2c0,#b3fff0); }
aside, #pre-panel, #radar-inset { background: var(--panel); border: 1px solid var(--line); }
aside, #pre-panel { grid-row: 2; position: relative; z-index: 2; min-height: 0; max-height: calc(100% - 1rem); overflow: auto; overscroll-behavior: contain; padding: .75rem; margin: .5rem; }
aside { align-self: start; justify-self: end; width: min(350px,calc(100% - 1rem)); }
#pre-panel { align-self: end; justify-self: start; width: min(540px,calc(100% - 1rem)); }
aside h2 { font-size: 1rem; margin: 0 0 .6rem; }
label { display: block; margin: .6rem 0; }
label input[type=range] { display: block; width: 100%; margin: .25rem 0; }
input { accent-color: var(--active); }
output, a { color: var(--active); }
aside output { display: block; }
#readout, .note { color: var(--muted); font-size: .84rem; }
#readout { border-block: 1px solid var(--line); padding: .5rem 0; margin: .6rem 0; }
details { margin-top: .6rem; }
summary { cursor: pointer; }
.steps button { display: block; width: 100%; text-align: left; margin-top: .4rem; }
.steps span, .steps strong { display: block; }
.steps span, #pre-panel p { color: var(--muted); font-size: .82rem; }
.pre-header { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
#pre-chart { display: block; width: 100%; height: auto; }
#pre-results { width: 100%; font-size: .8rem; border-collapse: collapse; }
#pre-results caption { text-align: left; margin: .5rem 0 .25rem; color: var(--active); }
#pre-results th, #pre-results td { text-align: left; padding: .25rem .15rem; border-bottom: 1px solid var(--line); }
#radar-inset { position: absolute; top: .5rem; left: .5rem; width: min(355px,calc(100% - 1rem)); padding: .5rem .6rem; font-size: .73rem; }
#radar-inset p { margin: .2rem 0; color: var(--muted); }
.radar-main { display: grid; grid-template-columns: 3.4ch minmax(0,1fr); gap: .45rem; margin: .45rem .3rem 1.1rem 0; }
.radar-range, .radar-field { position: relative; height: clamp(65px,18dvh,155px); }
.radar-range span { position: absolute; right: 0; transform: translateY(-50%); color: var(--muted); }
.radar-range span:nth-child(1) { top: 0; }
.radar-range span:nth-child(2) { top: 26.32%; }
.radar-range span:nth-child(3) { top: 52.63%; }
.radar-range span:nth-child(4) { top: 78.95%; }
.radar-range span:nth-child(5) { top: 100%; }
#radar-chart { display: block; height: 100%; width: 100%; cursor: crosshair; touch-action: manipulation; }
#radar-cursor { position: absolute; top: 0; bottom: 0; border-left: 1px solid #fff; pointer-events: none; }
#radar-times { position: relative; color: var(--muted); }
#radar-times span { position: absolute; transform: translateX(-50%); }
#radar-times span:first-child { transform: none; }
#radar-times span:last-child { transform: translateX(-100%); }
.radar-units { display: flex; align-items: center; gap: .3rem; color: var(--muted); }
.radar-units span:first-child { margin-right: auto; }
.radar-units i { width: 48px; height: 6px; }
@media (max-width: 680px) {
  header small { display: none; }
  header nav { order: 3; flex-basis: 100%; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  header nav button { white-space: nowrap; flex: 0 0 auto; }
  header button, header select, .timeline button { min-height: 34px; }
  .timeline input { min-height: 32px; }
  .timeline output { min-width: auto; font-size: 10px; }
  .legend { gap: .22rem .3rem; }
  #meaning { min-width: 0; }
  #hint { display: none; }
  #zoom-tools { bottom: .5rem; }
  #radar-inset { width: min(290px,calc(100% - 1rem)); }
}
@media (max-height: 470px) and (orientation: landscape) {
  header button, header select, .timeline button { min-height: 27px; }
  .timeline input { min-height: 26px; }
  #radar-inset { top: .25rem; }
}
@media (max-width: 380px) and (orientation: portrait) {
  .timeline { display: grid; grid-template-columns: auto auto minmax(0,1fr); gap: .12rem .35rem; }
  .timeline output { grid-row: 1; grid-column: 3; }
  .timeline input { grid-row: 2; grid-column: 1 / -1; width: 100%; min-height: 24px; margin: 0; }
}
.phone-label { display: none; }
@media (max-width: 680px) {
  .wide-label { display: none; }
  .phone-label { display: inline; }
}
/* Scientific labels are LaTeX paths rendered by Rustplotlib WebAssembly. */
:root { font-family: Georgia, 'Times New Roman', serif; font-size: 15px; }
#radar-inset { width: min(476px,calc(100% - 1rem)); padding: .45rem; }
.scientific-plot { position: relative; width: 460px; background: black; margin: .3rem auto; }
.scientific-plot canvas { position: absolute; display: block; }
.plot-frame, .plot-lines { inset: 0; width: 100%; height: 100%; }
.plot-lines { pointer-events: none; }
.plot-data { cursor: crosshair; touch-action: manipulation; }
.color-scale { width: 300px; height: 72px; display: block; background: black; }
.legend { gap: .25rem .65rem; }
#meaning { font-size: .8rem; }
#pre-panel { width: min(500px,calc(100% - 1rem)); }
.pre-key span:nth-child(1) { color: #56c9bc; }
.pre-key span:nth-child(2) { color: #ffbe70; }
.pre-key span:nth-child(3) { color: #b4a0e8; }
@media(max-width:680px) {
  #radar-inset { width: 316px; max-width: calc(100% - .5rem); left: .25rem; }
  .legend { flex-wrap: wrap; }
  .color-scale { margin: 0 auto; }
}
#pre-panel { justify-self: end; }
@media (max-width: 1100px) {
  #radar-inset { width: 316px; }
  #pre-panel { width: 340px; }
}
@media (max-width: 680px) {
  body { overflow: auto; }
  main { height: auto; min-height: 100dvh; display: flex; flex-direction: column; }
  header { order: 0; }
  .scene { order: 1; height: 650px; flex: none; }
  #pre-panel { order: 2; width: calc(100% - 1rem); max-height: none; }
  footer { order: 3; }
  aside { position: absolute; top: 90px; right: 0; max-height: 520px; }
}
/* Compact desktop overlays and one-handed phone controls. */
main { height: 100dvh; display: grid; grid-template: auto minmax(0,1fr) auto / minmax(0,1fr); }
body { overflow: hidden; }
.scene { height: auto; }
#colorbars { position: absolute; bottom: 72px; left: 50%; transform: translateX(-50%); display: flex; gap: 8px; pointer-events: none; z-index: 1; }
#colorbars .color-scale { width: 250px; height: 60px; opacity: .82; border-radius: 5px; }
#meaning { display: none; }
#hint { bottom: 76px; }
.legend { margin: 0; }
#radar-inset { max-height: calc(100% - 85px); overflow: auto; }
.radar-heading, .settings-heading { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.radar-heading button { padding: 0 .5rem; font-size: 1.2rem; }
.settings-heading h2 { margin: 0; }
.settings-heading button { min-width: 44px; min-height: 44px; font-size: 1.3rem; }
.settings-group { display: none; }
aside { position: absolute; top: 0; right: 0; width: 360px; max-height: calc(100% - 1rem); border-radius: 8px; z-index: 5; }
aside h3 { margin: 1rem 0 .4rem; color: var(--muted); font-size: .9rem; font-weight: normal; }
@media (max-width: 1100px) { #colorbars .color-scale { width: 225px; height: 54px; } }
body.phone main { display: block; height: 100dvh; min-height: 0; }
body.phone .scene { position: absolute; inset: 0; height: auto; }
body.phone header { position: absolute; top: max(12px,env(safe-area-inset-top)); right: max(12px,env(safe-area-inset-right)); border: 0; padding: 0; background: none; z-index: 6; }
body.phone header > strong { display: none; }
body.phone footer { position: absolute; bottom: max(18px,env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); padding: 0; background: none; border: 0; z-index: 4; }
body.phone #play { min-width: 110px; min-height: 48px; border-radius: 24px; background: #101a2ae8; }
body.phone #gear { width: 48px; height: 48px; border-radius: 50%; background: #101a2ae8; }
body.phone #hint, body.phone #zoom-tools { display: none !important; }
body.phone aside { position: absolute; top: calc(72px + env(safe-area-inset-top, 0px)); bottom: calc(78px + env(safe-area-inset-bottom, 0px)); right: 10px; left: 10px; width: auto; margin: 0; max-height: none; padding: 14px; background: #101a2af5; -webkit-overflow-scrolling: touch; }
body.phone .settings-group { display: block; border-bottom: 1px solid var(--line); padding-bottom: 12px; }
body.phone .settings-group h3 { margin-top: .7rem; }
body.phone #views { display: flex; flex-wrap: wrap; overflow: visible; gap: 6px; margin-bottom: 8px; }
body.phone button, body.phone select { min-height: 44px; }
body.phone #time { display: block; width: 100%; min-height: 44px; margin: 0; }
body.phone #tRead { display: block; text-align: left; font-size: 1rem; }
body.phone #colorbars { position: static; transform: none; display: flex; flex-direction: column; align-items: center; gap: 8px; margin-top: 12px; }
body.phone #colorbars .color-scale { width: min(300px,100%); height: auto; aspect-ratio: 300/72; opacity: 1; margin: 0; }
body.phone #radar-inset { top: calc(72px + env(safe-area-inset-top, 0px)); left: 8px; width: min(316px,calc(100% - 16px)); max-height: calc(100% - 155px); }
body.phone #radar-plot { height: 215px !important; overflow: hidden; }
body.phone .wide-label { display: none; }
body.phone .phone-label { display: inline; }

#latitude-labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
#latitude-labels canvas { position: absolute; width: 52px; height: 22px; transform: translate(-50%,-50%); opacity: .85; border-radius: 3px; }

body.phone select, body.phone button, body.phone input { font-size: 16px; }
body.phone #settings { position: fixed; top: 72px; bottom: 78px; height: calc(100dvh - 150px); max-height: calc(100dvh - 150px); }
body.phone #radar-plot .plot-frame, body.phone #radar-plot .plot-lines { height: 300px; }

/* The scales belong to the scene and stay within its own bounds. */
body:not(.phone) #colorbars {
  position: absolute; left: 12px; right: 112px; bottom: 12px; transform: none;
  width: auto; max-width: 620px; display: grid; grid-template-columns: repeat(2,minmax(0,1fr));
  gap: 10px; overflow: hidden; padding: 0; align-items: end;
}
body:not(.phone) #colorbars .color-scale { width: 100%; max-width: 300px; min-width: 0; height: auto; aspect-ratio: 300/72; margin: 0; }
body:not(.phone) #hint { bottom: 94px; }
body:not(.phone) #zoom-tools { bottom: 12px; }
#latitude-labels canvas { opacity: 1; }
