:root{color-scheme:light;padding:env(safe-area-inset-top,0px) 0 env(safe-area-inset-bottom,0px)}body{margin:0;font:14px system-ui,sans-serif}img{max-width:100%}[hidden]{display:none!important}
/* Layout: one full-viewport stage (WebGL canvas) with an instrument rail of controls: left rail on wide screens, bottom sheet on phones. */
:root {
  color-scheme: dark;
  --stage: #0d1117; --panel: #151a22; --panel-2: #1c222c; --line: #2a323f; --ink: #e8ecf1; --ink-2: #9aa5b4; --ink-3: #6b7686;
  --accent: #f2b655; --accent-ink: #1a1408; --halo: rgba(8, 11, 16, 0.92); --good: #5fc7a0; --warn: #f08a6c; --panel-a: rgba(21, 26, 34, 0.965);
  --f-text: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-label: "IBM Plex Sans Condensed", "IBM Plex Sans", "Arial Narrow", system-ui, sans-serif;
  --f-data: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --rail: 336px; --r: 6px;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --stage: #e9ece8; --panel: #fbfbf8; --panel-2: #f0f2ee; --line: #d3d8d2; --ink: #171c22; --ink-2: #55606c; --ink-3: #838d98;
    --accent: #9a5b00; --accent-ink: #ffffff; --halo: rgba(240, 242, 238, 0.94); --good: #1f8a63; --warn: #b84a2b; --panel-a: rgba(251, 251, 248, 0.965);
  }
}
:root[data-theme="light"] {
  color-scheme: light;
  --stage: #e9ece8; --panel: #fbfbf8; --panel-2: #f0f2ee; --line: #d3d8d2; --ink: #171c22; --ink-2: #55606c; --ink-3: #838d98;
  --accent: #9a5b00; --accent-ink: #ffffff; --halo: rgba(240, 242, 238, 0.94); --good: #1f8a63; --warn: #b84a2b; --panel-a: rgba(251, 251, 248, 0.965);
}
html, body { height: 100%; }
body { background: var(--stage); color: var(--ink); font-family: var(--f-text); font-size: 14px; line-height: 1.45; overflow: hidden; -webkit-font-smoothing: antialiased; }
* { box-sizing: border-box; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#app { position: relative; height: 100%; overflow: hidden; }
#stage { position: absolute; inset: 0 0 0 var(--rail); }
#gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; cursor: grab; }
#gl:active { cursor: grabbing; }
#gl:focus-visible { outline: 2px solid var(--accent); outline-offset: -3px; }
#labels { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.lb { position: absolute; left: 0; top: 0; white-space: nowrap; font-family: var(--f-label); font-size: 12.5px; font-weight: 500; color: var(--ink);
  text-shadow: 0 0 3px var(--halo), 0 0 3px var(--halo), 0 0 6px var(--halo), 0 1px 1px var(--halo); will-change: transform; line-height: 1.1; }
.lb::before { content: ""; position: absolute; left: -3px; top: 50%; width: 5px; height: 5px; margin-top: -2.5px; border-radius: 50%; background: var(--ink); box-shadow: 0 0 0 1.5px var(--halo); }
.lb span { padding-left: 7px; }
.lb.l1 { font-size: 12px; font-weight: 600; letter-spacing: 0.09em; text-transform: uppercase; }
.lb.l3 { font-size: 11.5px; font-weight: 400; }
.lb.sel { color: var(--accent); font-weight: 600; }
.lb.sel::before { background: var(--accent); }
.lb.flip::before { left: auto; right: -3px; }
.lb.flip span { padding-left: 0; padding-right: 7px; }

/* top bar on the stage */
#top { position: absolute; left: 0; right: 0; top: 0; display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: space-between;
  padding: 10px max(16px, env(safe-area-inset-right, 0px)) 8px max(16px, env(safe-area-inset-left, 0px)); pointer-events: none; }
#top > * { pointer-events: auto; }
.seg { display: inline-flex; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.seg button { background: none; border: 0; padding: 6px 10px; font-size: 12.5px; color: var(--ink-2); border-left: 1px solid var(--line); min-height: 32px; }
.seg button:first-child { border-left: 0; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.seg .cap { padding: 6px 8px 6px 10px; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); align-self: center; }
#views button { min-width: 34px; font-family: var(--f-data); font-size: 12px; }

/* control rail */
#rail { position: absolute; left: 0; top: 0; bottom: 0; width: var(--rail); background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; z-index: 5; }
#brand { padding: 14px 16px 10px max(16px, env(safe-area-inset-left, 0px)); border-bottom: 1px solid var(--line); }
#brand h1 { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: 0.01em; text-wrap: balance; }
#brand p { margin: 3px 0 0; font-size: 12px; color: var(--ink-2); }
#tabs { display: flex; border-bottom: 1px solid var(--line); }
#tabs button { flex: 1; background: none; border: 0; border-bottom: 2px solid transparent; padding: 9px 2px 7px; font-size: 12.5px; color: var(--ink-2); min-height: 38px; }
#tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
#pane { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 4px 16px 18px max(16px, env(safe-area-inset-left, 0px)); scrollbar-width: thin; }
.tabpane > h2, .modedet > h2 { font-size: 11px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3); margin: 16px 0 7px; }
.tabpane > h2:first-child { margin-top: 12px; }
.row { display: flex; align-items: center; gap: 10px; min-height: 34px; }
.row > label, .row > .nm { flex: 1; min-width: 0; }
.row .seg button { padding: 4px 9px; min-height: 28px; font-size: 12px; }
.hint { font-size: 12px; color: var(--ink-2); margin: 4px 0 8px; }
.sw { width: 11px; height: 11px; border-radius: 3px; flex: none; box-shadow: inset 0 0 0 1px rgba(128, 128, 128, 0.35); }
input[type="range"] { width: 100%; accent-color: var(--accent); min-height: 28px; margin: 0; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; flex: none; }
.chk { display: flex; align-items: center; gap: 9px; min-height: 32px; cursor: pointer; }
.chk small { color: var(--ink-3); font-family: var(--f-data); font-size: 11px; margin-left: auto; }
.rng { display: grid; grid-template-columns: 1fr auto; gap: 0 10px; align-items: center; }
.rng output { font-family: var(--f-data); font-size: 12px; color: var(--ink-2); min-width: 58px; text-align: right; font-variant-numeric: tabular-nums; }
.rng .ticks { grid-column: 1 / -1; display: flex; justify-content: space-between; font-size: 11px; color: var(--ink-3); margin-top: -3px; }
.mode { display: flex; gap: 10px; align-items: flex-start; padding: 7px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.mode:last-of-type { border-bottom: 0; }
.mode input { margin-top: 3px; }
.mode b { font-weight: 600; display: block; }
.mode span { font-size: 12px; color: var(--ink-2); }
.modedet { padding: 2px 0 10px 26px; border-bottom: 1px solid var(--line); }
.modedet:empty { display: none; }
.modedet > h2 { margin: 10px 0 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 4px; }
.chip { background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; font-size: 12px; font-family: var(--f-data); min-height: 28px; }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 500; }
details { border-top: 1px solid var(--line); }
details:last-of-type { border-bottom: 1px solid var(--line); }
summary { cursor: pointer; padding: 8px 0; font-weight: 500; display: flex; align-items: center; gap: 8px; list-style: none; min-height: 36px; }
summary::-webkit-details-marker { display: none; }
summary::before { content: "+"; font-family: var(--f-data); color: var(--ink-3); width: 10px; }
details[open] > summary::before { content: "\2212"; }
summary small { margin-left: auto; color: var(--ink-3); font-family: var(--f-data); font-size: 11px; }
.btn { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--r); padding: 6px 12px; min-height: 32px; font-size: 12.5px; }
.btn.pri { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.sys { display: block; width: 100%; text-align: left; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--r); padding: 9px 11px; margin: 0 0 7px; }
.sys b { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.sys span { display: block; font-size: 12px; color: var(--ink-2); margin-top: 2px; }
.sys[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.card h3 { font-size: 15px; margin: 14px 0 2px; font-weight: 600; text-wrap: balance; }
.card h4 { font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3); margin: 14px 0 5px; font-weight: 600; }
.card p { margin: 6px 0; max-width: 62ch; }
.card ul { margin: 6px 0; padding-left: 18px; }
.card li { margin: 3px 0; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 8px 0; font-size: 13px; }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; min-width: 0; overflow-wrap: anywhere; }
.kv dd.num { font-family: var(--f-data); font-size: 12.5px; }
.lam { display: grid; grid-template-columns: 1fr repeat(3, 48px); gap: 2px 4px; align-items: center; font-size: 11.5px; margin: 2px 0 8px; }
.lam b { font-family: var(--f-data); font-weight: 500; font-size: 10.5px; color: var(--ink-3); text-align: right; padding-right: 4px; }
.lam span { color: var(--ink-2); }
.lam i { font-style: normal; font-family: var(--f-data); font-variant-numeric: tabular-nums; text-align: right; padding: 1px 4px; border-radius: 3px; color: var(--ink); }
#sel details { margin-top: 8px; }
.bars { display: grid; grid-template-columns: auto 1fr auto; gap: 3px 8px; align-items: center; font-size: 12px; margin: 6px 0; }
.bars i { display: block; height: 7px; border-radius: 2px; background: var(--accent); min-width: 1px; }
.bars .trk { background: var(--panel-2); border-radius: 2px; }
.bars span:first-child { font-family: var(--f-data); color: var(--ink-2); }
.bars span:last-child { font-family: var(--f-data); color: var(--ink-3); font-size: 11px; }
.src { font-size: 12px; color: var(--ink-2); }
.src a, .card a { color: var(--accent); }
.flag { border-left: 3px solid var(--warn); padding: 2px 0 2px 10px; margin: 8px 0; font-size: 12.5px; }
#q { width: 100%; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--r); padding: 8px 10px; min-height: 38px; margin-top: 12px; }
#results button { display: block; width: 100%; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--line); padding: 8px 0; min-height: 40px; }
#results small { display: block; color: var(--ink-2); font-size: 12px; }

#tip { position: absolute; left: 0; top: 0; pointer-events: none; background: var(--panel-a); border: 1px solid var(--line); border-radius: 4px; padding: 3px 8px; font-size: 12px; font-family: var(--f-label); white-space: nowrap; z-index: 2; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25); }
.pth { display: block; width: 100%; text-align: left; background: none; border: 0; border-top: 1px solid var(--line); padding: 8px 0 8px 2px; }
.pth b { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.pth span { display: block; font-size: 12.5px; color: var(--ink-2); margin: 2px 0 0 17px; }
.pth small { display: block; font-size: 11px; color: var(--ink-3); margin: 2px 0 0 17px; font-family: var(--f-data); }
.pth[aria-pressed="true"] { box-shadow: inset 3px 0 0 var(--accent); padding-left: 9px; }
.dsrc { padding: 8px 0; border-top: 1px solid var(--line); }
.dsrc b { display: block; font-weight: 600; }
.dsrc span { display: block; font-size: 12.5px; color: var(--ink-2); margin-top: 2px; }
.dsrc small { display: block; font-size: 11px; color: var(--ink-3); font-family: var(--f-data); margin-top: 2px; }
.tabpane ul { padding-left: 18px; margin: 6px 0; }
.tabpane li { margin: 4px 0; }
.tabpane ul.src li { margin: 2px 0; }
.lk { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; font-size: 12.5px; margin: 4px 0; }
.lk > span { color: var(--ink-2); min-width: 72px; }
.lnk { background: none; border: 0; padding: 2px 0; color: var(--ink); font-family: var(--f-data); font-size: 12px; text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; text-align: left; min-height: 24px; }
.lnk:hover { text-decoration-color: var(--accent); }
.bars .lnk { color: var(--ink-2); }
select.pick { width: 100%; background: var(--panel-2); color: var(--ink); border: 1px solid var(--line); border-radius: var(--r); padding: 8px 10px; min-height: 38px; font: inherit; }
.lgh { display: block; font-weight: 600; margin: 0 0 4px; background: none; border: 0; padding: 0; text-align: left; font-size: inherit; }
#legend .lgh:not(:first-child) { margin-top: 8px; }
#legend { max-height: 60%; overflow-y: auto; scrollbar-width: thin; }

/* selection card and legend on the stage */
#sel { position: absolute; right: max(16px, env(safe-area-inset-right, 0px)); bottom: 14px; width: min(340px, calc(100% - 28px)); max-height: 62%; overflow-y: auto;
  background: var(--panel-a); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28); scrollbar-width: thin; }
#sel .x { position: absolute; right: 6px; top: 6px; background: none; border: 0; width: 32px; height: 32px; font-size: 18px; color: var(--ink-2); }
#sel h3 { margin: 0 30px 2px 0; font-size: 15.5px; font-weight: 600; text-wrap: balance; }
#sel .sub { color: var(--ink-2); font-size: 12.5px; }
#legend { position: absolute; left: max(16px, env(safe-area-inset-left, 0px)); bottom: 14px; max-width: min(300px, 46%); background: var(--panel-a); border: 1px solid var(--line); border-radius: var(--r); padding: 8px 11px; font-size: 12px; }
#legend b { font-weight: 600; display: block; margin-bottom: 4px; }
#legend .it { display: flex; align-items: center; gap: 7px; margin: 2px 0; }
#legend .ramp { height: 9px; border-radius: 2px; margin: 4px 0 2px; }
#legend .ax { display: flex; justify-content: space-between; color: var(--ink-2); font-size: 11px; }
#hud { position: absolute; right: max(16px, env(safe-area-inset-right, 0px)); top: 52px; display: flex; gap: 6px; align-items: flex-start; pointer-events: none; z-index: 2; }
#compass { pointer-events: auto; cursor: pointer; border-radius: 50%; display: block; }
#minimap { display: block; }
#orient { position: absolute; right: max(16px, env(safe-area-inset-right, 0px)); top: calc(56px + var(--hudh, 0px)); font-family: var(--f-data); font-size: 11px; color: var(--ink-2); text-align: right; pointer-events: none; }
#load { position: absolute; inset: 0; display: grid; place-items: center; background: var(--stage); z-index: 4; text-align: center; padding: 20px; }
#load .bar { width: min(260px, 70vw); height: 3px; background: var(--line); border-radius: 2px; overflow: hidden; margin: 12px auto 0; }
#load .bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.2s; }
#load p { color: var(--ink-2); margin: 0; }
#load.err p { color: var(--warn); max-width: 44ch; }
#sheetbtn { display: none; }

@media (max-width: 1080px) { #legend { bottom: auto; top: 56px; } }
@media (max-width: 860px) {
  :root { --rail: 0px; }
  #tabs button { font-size: 12px; padding-left: 0; padding-right: 0; }
  #stage { inset: 0; }
  #app.open #stage { bottom: var(--sheet, 50%); }
  #rail { top: auto; left: 0; right: 0; bottom: 0; width: auto; height: var(--sheet, 50%); border-right: 0; border-top: 1px solid var(--line); border-radius: 12px 12px 0 0; transform: translateY(100%); transition: transform 0.22s ease; box-shadow: 0 -12px 30px rgba(0, 0, 0, 0.3); }
  #app.open #rail { transform: none; }
  #brand { display: none; }
  #pane { padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  #sheetbtn { display: inline-flex; align-items: center; gap: 6px; position: absolute; left: 50%; transform: translateX(-50%); bottom: 12px; z-index: 3; background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 999px; padding: 9px 18px; font-weight: 600; min-height: 40px; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35); }
  #app.open #sheetbtn { bottom: 8px; background: var(--panel-2); color: var(--ink); border: 1px solid var(--line); box-shadow: none; padding: 5px 14px; min-height: 30px; font-weight: 500; font-size: 12px; }
  #sel { left: max(10px, env(safe-area-inset-left, 0px)); right: max(10px, env(safe-area-inset-right, 0px)); width: auto; bottom: 62px; max-height: 40%; }
  #app.open #sel { bottom: 44px; max-height: 46%; }
  #legend { bottom: auto; top: 96px; max-width: 46%; font-size: 11px; padding: 6px 8px; }
  #perf { top: auto; bottom: 62px; font-size: 10px; }
  #orient { display: none; }
  #hud { right: max(10px, env(safe-area-inset-right, 0px)); gap: 4px; }
  #top { gap: 6px; }
  .seg .cap { display: none; }
}
@media (prefers-reduced-motion: reduce) { #rail { transition: none; } }
/* fingers need larger targets than a mouse pointer */
@media (pointer: coarse) {
  #legend { top: 112px; }
  .seg button, .row .seg button { min-height: 40px; padding-left: 12px; padding-right: 12px; }
  .chip { min-height: 40px; min-width: 40px; padding: 6px 12px; }
  .chk { min-height: 44px; }
  input[type="checkbox"], input[type="radio"] { width: 20px; height: 20px; }
  input[type="range"] { min-height: 40px; }
  #tabs button { min-height: 44px; }
  .lnk { min-height: 36px; }
  select.pick { min-height: 44px; }
  #sel .x { width: 44px; height: 44px; }
  .btn { min-height: 40px; }
}
#tour { position: absolute; left: 50%; transform: translateX(-50%); bottom: 14px; width: min(520px, calc(100% - 32px)); background: var(--panel-a); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; z-index: 3; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28); }
#tour .th { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
#tour .th span { font-family: var(--f-data); font-size: 12px; color: var(--ink-2); }
#tour p { margin: 6px 0 8px; font-size: 13px; line-height: 1.45; }
#tour .chips { margin: 0; }
.rowf { display: flex; gap: 8px; align-items: center; margin: 6px 0; }
.rowf .txt, .rowf .lnk { flex: 1 1 auto; min-width: 0; }
.txt { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--r); padding: 7px 10px; min-height: 36px; color: var(--ink); font: inherit; }
.out { width: 100%; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--r); color: var(--ink); font-family: var(--f-data); font-size: 11px; padding: 6px; resize: vertical; }
button:disabled { opacity: 0.45; cursor: default; }
#pane input[type=file] { display: block; width: 100%; max-width: 100%; font-size: 12px; margin: 6px 0; color: var(--ink-2); }
#app.barred #sel { bottom: calc(var(--barh, 130px) + 24px); max-height: calc(100% - var(--barh, 130px) - 96px); }
@media (min-width: 1081px) { #app.barred #legend { bottom: calc(var(--barh, 130px) + 24px); } }
@media (max-width: 860px) { #tour { bottom: 62px; } #app.open #tour { bottom: 44px; } #app.barred #sel { display: none; } }
#perf { position: absolute; left: 50%; top: 56px; transform: translateX(-50%); font-family: var(--f-data); font-size: 11px; line-height: 1.5; color: var(--ink); background: var(--panel-a); border: 1px solid var(--line); border-radius: 4px; padding: 5px 9px; white-space: pre; pointer-events: none; z-index: 2; max-width: calc(100% - 32px); overflow: hidden; }

/* site edition only */
.nojs { position: fixed; inset: 0; z-index: 99; display: grid; place-items: center; margin: 0; padding: 24px; text-align: center; background: var(--stage); color: var(--ink); }
