@property --accent { syntax: '<color>'; inherits: true; initial-value: #8fd3ff; }
@property --accent2 { syntax: '<color>'; inherits: true; initial-value: #ffb3d9; }

:root {
  --bg: #0a0a0c;
  --accent: #8fd3ff;
  --accent2: #ffb3d9;
  --panel-top: rgba(12, 17, 30, 0.9);
  --panel-bot: rgba(5, 8, 15, 0.88);
  --panel: var(--panel-bot);
  --panel-solid: #0a0e18;
  --well: color-mix(in oklab, var(--accent) 9%, transparent);
  --well-2: color-mix(in oklab, var(--accent) 16%, transparent);
  --line: color-mix(in oklab, var(--accent) 20%, transparent);
  --line-2: color-mix(in oklab, var(--accent) 34%, transparent);
  --text: #eef1f6;
  --dim: color-mix(in oklab, var(--accent) 18%, #a4adbd);
  --faint: color-mix(in oklab, var(--accent) 14%, #7d8699);
  --on-accent: #0a0a0c;
  --warn: #f2b35c;
  --bad: #ff7d8c;
  --sans: "Instrument Sans", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --serif: "Instrument Serif", Georgia, "Times New Roman", serif;
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace;
  --r: 10px;
  --r-s: 6px;
  --gap: 12px;
  --top-h: 56px;
  --hud-h: 58px;
  --cat-w: 272px;
  --ctl-w: 340px;
  color-scheme: dark;
  transition: --accent 1.2s ease, --accent2 1.2s ease;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

button, input, select { font: inherit; color: inherit; }
sup, sub { font-size: 0.72em; line-height: 0; }
button { cursor: pointer; }
.hidden { display: none !important; }

canvas#view {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
  touch-action: none;
  outline: none;
}
canvas#view.grabbing { cursor: grabbing; }

#vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.45), transparent 120px),
    linear-gradient(0deg, rgba(0, 0, 0, 0.45), transparent 120px);
  z-index: 1;
  transition: opacity 0.4s ease;
}

#reticle {
  position: fixed;
  left: 50%;
  top: 50%;
  width: 28px;
  height: 28px;
  margin: -14px 0 0 -14px;
  pointer-events: none;
  z-index: 2;
  opacity: 0;
  transition: opacity 0.3s ease;
}
body.reticle #reticle { opacity: 0.8; }
#reticle i { position: absolute; background: #fff; mix-blend-mode: difference; }
#reticle i:nth-child(1) { left: 13px; top: 0; width: 2px; height: 8px; }
#reticle i:nth-child(2) { left: 13px; bottom: 0; width: 2px; height: 8px; }
#reticle i:nth-child(3) { top: 13px; left: 0; height: 2px; width: 8px; }
#reticle i:nth-child(4) { top: 13px; right: 0; height: 2px; width: 8px; }

.panel {
  position: fixed;
  background: linear-gradient(180deg, var(--panel-top), var(--panel-bot));
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: 0 18px 50px -20px rgba(0, 0, 0, 0.8);
  z-index: 10;
  transition: transform 0.45s cubic-bezier(.2, .8, .2, 1), opacity 0.35s ease;
}
body.glass .panel {
  background: linear-gradient(180deg, rgba(14, 20, 36, 0.62), rgba(6, 9, 18, 0.58));
  backdrop-filter: blur(16px) saturate(1.35);
  -webkit-backdrop-filter: blur(16px) saturate(1.35);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  border-bottom: 1px solid var(--line);
}
.panel-head .count { font: 500 12px var(--mono); color: var(--dim); }

.scroll {
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--line-2) transparent;
}
.scroll::-webkit-scrollbar { width: 8px; }
.scroll::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 4px; border: 2px solid transparent; background-clip: padding-box; }

:is(.icon-btn, .btn, .seg button, .chip, .card, .pal, .fx, .tab, .sec-head, .toggle, select.sel):focus-visible,
input[type=range]:focus-visible, .val:focus-visible, .textfield:focus-visible, .xy:focus-visible, .dial:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

#topbar {
  top: var(--gap);
  left: var(--gap);
  right: var(--gap);
  height: var(--top-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px 0 14px;
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex: none; }
.logo { width: 26px; height: 26px; flex: none; overflow: visible; }
.logo-ring { fill: none; stroke: var(--accent); stroke-width: 1.5; opacity: 0.8; }
.logo-tick { stroke: var(--accent); stroke-width: 1.5; opacity: 0.6; }
.logo-body { fill: var(--accent); }
.brand-text { font-size: 15px; font-weight: 600; letter-spacing: 0.01em; }

.now-viewing {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 0;
  white-space: nowrap;
}
.nv-code { font: 500 12px var(--mono); color: var(--on-accent); background: var(--accent); padding: 2px 7px; border-radius: 4px; }
.nv-name {
  font: italic 400 24px/1 var(--serif);
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.005em;
}

.top-actions { display: flex; align-items: center; gap: 2px; flex: none; }
.top-actions .sep { width: 1px; height: 22px; background: var(--line-2); margin: 0 6px; }

.icon-btn {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: var(--r-s);
  background: transparent;
  color: var(--dim);
  transition: color 0.15s, background 0.15s;
}
.icon-btn svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-btn:hover { color: var(--text); background: var(--well-2); }
.icon-btn.on { color: var(--on-accent); background: var(--accent); }
.icon-btn.on:hover { color: var(--on-accent); background: var(--accent); }
#btn-controls { display: none; }

#catalog {
  top: calc(var(--gap) * 2 + var(--top-h));
  left: var(--gap);
  bottom: calc(var(--gap) * 2 + var(--hud-h));
  width: var(--cat-w);
  display: flex;
  flex-direction: column;
}
body.cat-closed #catalog { transform: translateX(calc(-100% - 24px)); opacity: 0; pointer-events: none; }

#catalog-list {
  flex: 1;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.card {
  position: relative;
  flex: none;
  height: 92px;
  border-radius: var(--r-s);
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--well);
  cursor: pointer;
  text-align: left;
  padding: 0;
  color: var(--text);
  transition: border-color 0.2s, transform 0.2s;
}
.card canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.5s ease;
}
.card.ready canvas { opacity: 1; }
.card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, 0.07) 50%, transparent 70%);
  background-size: 250% 100%;
  animation: shimmer 1.6s linear infinite;
}
.card.ready::before { display: none; }
.card::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.35), transparent 40%),
    linear-gradient(90deg, rgba(0, 0, 0, 0.85) 0%, rgba(0, 0, 0, 0.45) 55%, rgba(0, 0, 0, 0.05) 100%);
  pointer-events: none;
}
.c-code, .c-name, .c-desc, .c-key { position: absolute; z-index: 2; pointer-events: none; }
.c-code { left: 10px; top: 8px; font: 500 11px var(--mono); color: var(--accent); }
.c-key {
  right: 8px;
  top: 7px;
  font: 500 11px/1 var(--mono);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 4px;
  padding: 3px 5px;
  min-width: 20px;
  text-align: center;
  background: rgba(0, 0, 0, 0.55);
}
.c-name { left: 10px; bottom: 26px; font-size: 15px; font-weight: 600; line-height: 1.2; text-shadow: 0 1px 6px #000; }
.c-desc { left: 10px; right: 10px; bottom: 9px; font: 12px/1.3 var(--mono); color: rgba(241, 238, 232, 0.8); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-shadow: 0 1px 4px #000; }
.card:hover { border-color: var(--line-2); transform: translateX(2px); }
.card.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.card.active .c-name { color: #fff; }
.card.unsupported { opacity: 0.4; cursor: not-allowed; }

@keyframes shimmer { from { background-position: 150% 0; } to { background-position: -100% 0; } }

#controls {
  top: calc(var(--gap) * 2 + var(--top-h));
  right: var(--gap);
  bottom: calc(var(--gap) * 2 + var(--hud-h));
  width: var(--ctl-w);
  display: flex;
  flex-direction: column;
}
body.ctl-closed #controls { transform: translateX(calc(100% + 24px)); opacity: 0; pointer-events: none; }

#tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-bottom: 1px solid var(--line);
  padding: 6px 6px 0;
}
.tab {
  position: relative;
  border: 0;
  background: none;
  padding: 10px 0 11px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--dim);
  border-radius: var(--r-s) var(--r-s) 0 0;
  transition: color 0.15s;
}
.tab::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: -1px;
  height: 2px;
  background: var(--accent);
  opacity: 0;
  transition: opacity 0.2s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); font-weight: 600; }
.tab.active::after { opacity: 1; }

/* The gutter stays reserved so a scrollbar appearing does not rewrap the waypoint chips. */
.tab-body { flex: 1; padding: 4px 8px 20px 16px; scrollbar-gutter: stable; }

.sec { margin-top: 14px; }
.sec-head {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  border: 0;
  background: none;
  padding: 8px 0 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  text-align: left;
  border-radius: 4px;
}
.sec-head::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, var(--line-2), transparent); }
.sec-head .chev { width: 12px; height: 12px; transition: transform 0.2s; fill: none; stroke: var(--accent); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sec.collapsed .sec-head .chev { transform: rotate(-90deg); }
.sec.collapsed .sec-body { display: none; }
.sec-body { display: flex; flex-direction: column; gap: 12px; padding-top: 4px; }

.intro {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: var(--r-s);
  background: linear-gradient(90deg, color-mix(in oklab, var(--accent) 18%, transparent), color-mix(in oklab, var(--accent) 6%, transparent));
  border-left: 3px solid var(--accent);
}
.intro .formula { font: 500 15px/1.4 var(--mono); color: var(--accent); margin-bottom: 6px; }
.intro p { margin: 0; color: var(--dim); font-size: 13.5px; line-height: 1.5; max-width: 40ch; }

.ctl { display: flex; flex-direction: column; gap: 6px; }
.ctl-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.ctl-top label { font-size: 13.5px; color: var(--text); }
.ctl-top output, .ctl-top .val {
  font: 13px var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--dim);
  min-width: 52px;
  text-align: right;
  border: 0;
  border-bottom: 1px solid transparent;
  background: transparent;
  padding: 0;
  outline: none;
  cursor: text;
  user-select: text;
  -webkit-user-select: text;
}
.ctl-top .val:hover { color: var(--text); }
.ctl-top .val:focus { color: var(--text); border-bottom-color: var(--accent); outline: none; }
.ctl.disabled, .toggle.disabled { opacity: 0.4; pointer-events: none; }

input[type=range] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 20px;
  margin: 0;
  background: transparent;
  cursor: pointer;
  --p: 50%;
}
input[type=range]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--accent) var(--p), color-mix(in oklab, var(--accent) 30%, rgba(255, 255, 255, 0.08)) var(--p));
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  margin-top: -6px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  transition: transform 0.15s;
}
input[type=range]:hover::-webkit-slider-thumb { transform: scale(1.1); }
input[type=range]:active::-webkit-slider-thumb { transform: scale(1.2); }
input[type=range]::-moz-range-track { height: 4px; border-radius: 2px; background: color-mix(in oklab, var(--accent) 30%, rgba(255, 255, 255, 0.08)); }
input[type=range]::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--accent); }
input[type=range]::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--accent); border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5); }

.toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13.5px;
  cursor: pointer;
  border-radius: 4px;
}
.toggle .sw {
  position: relative;
  width: 36px;
  height: 20px;
  flex: none;
  border-radius: 10px;
  background: color-mix(in oklab, var(--accent) 30%, rgba(255, 255, 255, 0.1));
  transition: background 0.2s;
}
.toggle .sw::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text);
  transition: transform 0.2s cubic-bezier(.2, .8, .2, 1), background 0.2s;
}
.toggle.on .sw { background: var(--accent); }
.toggle.on .sw::after { transform: translateX(16px); background: var(--on-accent); }
.toggle.disabled { opacity: 0.4; pointer-events: none; }

.seg {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 3px;
  border-radius: var(--r-s);
  background: var(--well);
  border: 1px solid var(--line);
}
.seg button {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  border-radius: 4px;
  padding: 6px 8px;
  background: transparent;
  color: var(--dim);
  font-size: 13px;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.seg button:hover { color: var(--text); background: var(--well-2); }
.seg button.active { color: var(--on-accent); background: var(--accent); font-weight: 600; }

.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-s);
  background: var(--well);
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.btn:hover { background: var(--well-2); border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--on-accent); border-color: transparent; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.on { color: var(--on-accent); background: var(--accent); border-color: transparent; }
.btn.grow { flex: 1; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  background: transparent;
  padding: 5px 12px;
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.chip:hover { background: var(--well-2); border-color: var(--accent); }
.chip.active { color: var(--on-accent); background: var(--accent); border-color: transparent; font-weight: 600; }
.chip .deep { font: 500 10.5px var(--mono); color: var(--accent2); padding: 1px 3px; }
.chip .deep.ultra { color: var(--warn); }
.chip .deep.hyper { color: var(--bad); }
.chip.active .deep { color: var(--on-accent); opacity: 0.75; }

.dz-card { width: min(94vw, 700px); }
.dz-tabs { display: flex; gap: 4px; padding: 8px 14px 0; border-bottom: 1px solid var(--line); }
.dz-tabs button {
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  padding: 8px 12px 7px;
  font: 600 10.5px var(--mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
}
.dz-tabs button:hover { color: var(--dim); }
.dz-tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
.dz-body { padding: 4px 18px 18px; font-size: 12.5px; line-height: 1.55; color: var(--dim); user-select: text; -webkit-user-select: text; }
.dz-body p { margin: 8px 0; }
.dz-body b { color: var(--text); }
.dz-sec h3 { font: 600 10px var(--mono); letter-spacing: 0.2em; text-transform: uppercase; color: var(--accent); margin: 20px 0 6px; }
.dz-status { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 12px 0 4px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: rgba(150, 190, 255, 0.03); }
.dz-status.live { border-color: var(--accent2); box-shadow: inset 3px 0 0 var(--accent2); }
.dz-status .btn:disabled { opacity: 0.4; pointer-events: none; }
.dz-fig { margin: 6px 0; padding: 10px; border: 1px solid var(--line); border-radius: 6px; background: rgba(3, 5, 10, 0.55); }
.dz-fig figcaption { margin-top: 6px; font-size: 11px; color: var(--faint); }
.dz-svg { display: block; width: 100%; height: auto; overflow: visible; }
.dz-svg text { font-family: var(--mono); }
.dz-in { font-size: 9.5px; font-weight: 700; fill: var(--bg); text-anchor: middle; letter-spacing: 0.06em; }
.dz-lbl { font-size: 10px; fill: var(--dim); text-anchor: middle; }
.dz-exp { font-size: 0.72em; }
.dz-cap { font-size: 10px; fill: var(--faint); }
.dz-tick { stroke: var(--line-2); }
.dz-mark { fill: var(--text); }
.dz-here { font-size: 10.5px; fill: var(--text); }
.dz-row { font-size: 10px; fill: var(--dim); text-anchor: end; }
.dz-pix { stroke: var(--text); stroke-width: 1.5; }
.dz-snap { stroke: rgba(150, 190, 255, 0.35); }
.dz-val { fill: var(--accent); }
.dz-ref-path { fill: none; stroke: var(--accent); stroke-opacity: 0.35; stroke-width: 1.2; }
.dz-pix-path { fill: none; stroke: var(--accent2); stroke-opacity: 0.3; stroke-width: 1.2; stroke-dasharray: 3 3; }
.dz-ref { fill: var(--accent); }
.dz-pixdot { fill: var(--accent2); }
.dz-delta { stroke: var(--text); stroke-width: 1.4; stroke-dasharray: 2 2; }
.dz-z { font-size: 9.5px; fill: var(--dim); }
.dz-key { font-size: 10.5px; fill: var(--text); }
.dz-key.dim { fill: var(--faint); }
.dz-step { opacity: 0.45; animation-name: dz-pulse; animation-iteration-count: infinite; animation-timing-function: ease-out; }
@keyframes dz-pulse { 0% { opacity: 1; } 11% { opacity: 1; } 30%, 100% { opacity: 0.45; } }
.dz-box { fill: rgba(150, 190, 255, 0.04); stroke: var(--line-2); }
.dz-box.hot { stroke: var(--accent); }
.dz-box-a { font-size: 9.5px; font-weight: 700; letter-spacing: 0.16em; fill: var(--accent); }
.dz-box-b { font-size: 11.5px; fill: var(--text); }
.dz-box-c { font-size: 10px; fill: var(--faint); }
.dz-arrow { fill: none; stroke: var(--dim); stroke-width: 1.4; }
.dz-formula { margin: 6px 0; padding: 8px 12px; font: 13px var(--mono); color: var(--text); background: rgba(150, 190, 255, 0.05); border-radius: 5px; }
.dz-digits { font: 14px var(--mono); overflow-wrap: anywhere; }
.dz-digits .hi, .dz-parts .hi { color: var(--accent); }
.dz-digits .lo, .dz-parts .lo { color: var(--accent2); }
.dz-parts { display: flex; flex-wrap: wrap; gap: 4px 22px; margin-top: 6px; font: 11px var(--mono); }
@media (prefers-reduced-motion: reduce) { .dz-step { animation: none; opacity: 1; } }

.learn-btn {
  display: inline-flex;
  align-items: center;
  margin-left: 6px;
  gap: 8px;
  height: 34px;
  padding: 0 12px 0 10px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-s);
  background: transparent;
  color: var(--text);
  font: italic 400 17px/1 var(--serif);
  white-space: nowrap;
  transition: border-color 0.15s, background 0.15s;
}
.learn-btn svg { width: 17px; height: 17px; flex: none; fill: none; stroke: var(--accent); stroke-width: 1.6; stroke-linejoin: round; }
.learn-btn:hover { background: var(--well-2); border-color: var(--accent); }

.fx-card { width: min(94vw, 720px); }
.fx-tabs { overflow-x: auto; scrollbar-width: none; }
.fx-tabs button { white-space: nowrap; position: relative; }
.fx-tabs button.here::after { content: ""; position: absolute; top: 6px; right: 2px; width: 5px; height: 5px; border-radius: 50%; background: var(--accent2); }
.fx-body { font-size: 13px; }
.fx-body > p:first-child, .fx-formula + p { color: var(--text); }
.fx-formula { margin: 18px 0 4px; font: italic 400 34px/1.15 var(--serif); color: var(--text); text-align: center; letter-spacing: 0.01em; }
.fx-formula sup, .fx-formula sub { font-size: 0.62em; line-height: 0; margin: 0 0.08em; }
.dz-sec .fx-formula { margin: 8px 0 2px; font-size: 26px; text-align: left; }
.fx-fig { padding: 0; overflow: hidden; }
.fx-canvas { display: block; width: 100%; height: auto; touch-action: pan-y; }
.fx-canvas:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.fx-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin: 6px 0; }
.fx-var { margin: 0; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: rgba(3, 5, 10, 0.55); }
.fx-thumb { display: block; width: 100%; aspect-ratio: 10 / 7; background: #04060c; }
.fx-var figcaption { display: flex; flex-direction: column; gap: 3px; padding: 8px 10px 10px; }
.fx-var-name { font: italic 400 18px/1.1 var(--serif); color: var(--text); }
.fx-var-formula { font: 11px var(--mono); color: var(--accent); }
.fx-var-what { font-size: 11.5px; line-height: 1.4; color: var(--dim); }
.fx-fams { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.fx-fam {
  display: grid;
  grid-template-columns: 128px 1fr;
  gap: 2px 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(150, 190, 255, 0.03);
  color: var(--dim);
  text-align: left;
  font: inherit;
  transition: border-color 0.15s, background 0.15s;
}
.fx-fam:hover { border-color: var(--accent); background: var(--well); }
.fx-fam-name { grid-row: span 2; font: italic 400 20px/1.1 var(--serif); color: var(--text); }
.fx-fam-what { color: var(--text); }
.fx-fam-list { font-size: 11.5px; color: var(--faint); }

.textfield {
  width: 100%;
  border: 1px solid var(--line-2);
  border-radius: var(--r-s);
  background: var(--well);
  padding: 8px 10px;
  font: 14px var(--mono);
  letter-spacing: 0.12em;
  color: var(--text);
  outline: none;
  user-select: text;
  -webkit-user-select: text;
}
.textfield:focus { border-color: var(--accent); }
.textfield.bad { border-color: var(--bad); color: var(--bad); }

.xy {
  position: relative;
  width: 100%;
  aspect-ratio: 1.35;
  border: 1px solid var(--line-2);
  border-radius: var(--r-s);
  overflow: hidden;
  background: #0d0d10;
  cursor: crosshair;
  touch-action: none;
}
.xy canvas { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0.85; }
.xy .grid {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(rgba(255, 255, 255, 0.07) 1px, transparent 1px) 0 0 / 25% 25%,
    linear-gradient(90deg, rgba(255, 255, 255, 0.07) 1px, transparent 1px) 0 0 / 25% 25%;
  pointer-events: none;
}
.xy .axis-x, .xy .axis-y { position: absolute; background: rgba(255, 255, 255, 0.25); pointer-events: none; }
.xy .axis-x { left: 0; right: 0; height: 1px; }
.xy .axis-y { top: 0; bottom: 0; width: 1px; }
.xy .dot {
  position: absolute;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: var(--accent);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
  pointer-events: none;
}
.xy .xy-read {
  position: absolute;
  right: 6px;
  bottom: 6px;
  font: 12px var(--mono);
  color: var(--text);
  background: rgba(10, 10, 12, 0.8);
  padding: 2px 6px;
  border-radius: 4px;
  pointer-events: none;
}

.dial-row { display: flex; align-items: center; gap: 14px; }
.dial {
  position: relative;
  width: 56px;
  height: 56px;
  flex: none;
  border-radius: 50%;
  border: 1px solid var(--line-2);
  background: var(--well);
  cursor: grab;
  touch-action: none;
}
.dial::before { content: ""; position: absolute; inset: 6px; border-radius: 50%; border: 1px dashed rgba(255, 255, 255, 0.14); }
.dial .needle {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 22px;
  height: 2px;
  margin-top: -1px;
  transform-origin: 0 50%;
  background: var(--text);
}
.dial .needle::after {
  content: "";
  position: absolute;
  right: -3px;
  top: -3px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}
.dial-row .ctl { flex: 1; }

.pal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pal {
  position: relative;
  height: 40px;
  border-radius: var(--r-s);
  border: 1px solid var(--line);
  overflow: hidden;
  padding: 0;
  background: #000;
  transition: border-color 0.15s;
}
.pal canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.pal span {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 500;
  color: #fff;
  text-align: left;
  background: linear-gradient(0deg, rgba(0, 0, 0, 0.75), rgba(0, 0, 0, 0));
}
.pal:hover { border-color: rgba(255, 255, 255, 0.35); }
.pal.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }

.fx-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.fx {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: var(--r-s);
  background: var(--well);
  padding: 10px 4px 8px;
  font-size: 12.5px;
  color: var(--dim);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.fx svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.fx:hover { color: var(--text); background: var(--well-2); }
.fx.active { color: var(--on-accent); background: var(--accent); border-color: transparent; font-weight: 600; }

.stats {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 14px;
  padding: 12px;
  border-radius: var(--r-s);
  background: var(--well);
  border: 1px solid var(--line);
  font-size: 12.5px;
  margin: 0;
}
.stats dt { color: var(--dim); }
.stats dd { color: var(--text); }
.stats dd { margin: 0; font-family: var(--mono); font-size: 12px; color: var(--text); text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note { color: var(--dim); font-size: 13px; line-height: 1.5; margin: 0; max-width: 42ch; }
.note b { color: var(--text); font-weight: 600; }

.maps { display: flex; flex-direction: column; gap: 10px; }
.map-card {
  border: 1px solid var(--line);
  border-radius: var(--r-s);
  padding: 10px 11px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  background: var(--well);
}
.map-card .map-title { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; }
.map-card .swatch { width: 12px; height: 12px; border-radius: 3px; }
select.sel {
  width: 100%;
  border: 1px solid var(--line-2);
  border-radius: var(--r-s);
  background: var(--panel-solid);
  padding: 7px 8px;
  font-size: 13px;
  outline: none;
}

#hud {
  left: var(--gap);
  right: var(--gap);
  bottom: var(--gap);
  height: var(--hud-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 16px;
  z-index: 15;
}
.readouts, .perf { display: flex; align-items: center; gap: 20px; flex: none; }
.ro { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.ro label { font-size: 11.5px; color: var(--dim); line-height: 1.2; }
#ro-mag { color: var(--accent); }
.ro span { font: 13px/1.3 var(--mono); font-variant-numeric: tabular-nums; color: var(--text); white-space: nowrap; }
.readouts .ro span { min-width: 84px; }
#ro-a, #ro-b { min-width: 136px; }

.signal { width: 64px; height: 4px; border-radius: 2px; background: color-mix(in oklab, var(--accent) 30%, rgba(255, 255, 255, 0.08)); overflow: hidden; }
.signal i { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.15s linear, opacity 0.4s; }
#depth-gauge {
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: 50%;
  transform: translateX(-50%);
  width: min(1100px, calc(100% - 2 * var(--hud-side, 0px)));
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px 0 2px;
  border: 1px solid var(--line);
  border-radius: var(--r-s);
  background: rgba(150, 190, 255, 0.03);
  transition: border-color 0.15s, background 0.15s;
}
#depth-gauge:hover, #depth-gauge:focus-visible { border-color: var(--accent); background: rgba(150, 190, 255, 0.08); outline: none; }
.dg-track { position: relative; flex: 1; min-width: 0; align-self: stretch; }
.dg-track svg { position: absolute; left: 0; top: 50%; width: 100%; height: 50px; transform: translateY(-50%); }
.dg-more { display: flex; align-items: center; gap: 5px; flex: none; font-size: 11.5px; color: var(--dim); white-space: nowrap; }
.dg-more svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
#depth-gauge:hover .dg-more, #depth-gauge:focus-visible .dg-more { color: var(--text); }

#titlecard {
  position: fixed;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%);
  z-index: 30;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  width: min(90vw, 720px);
  text-shadow: 0 2px 24px rgba(0, 0, 0, 0.9), 0 0 2px rgba(0, 0, 0, 0.9);
}
#titlecard.show { animation: tc-in 2.8s cubic-bezier(.2, .8, .2, 1) forwards; }
@keyframes tc-in {
  0% { opacity: 0; transform: translate(-50%, -48%); }
  14% { opacity: 1; transform: translate(-50%, -50%); }
  74% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -52%); }
}
.tc-code { display: inline-block; font: 500 13px var(--mono); color: var(--on-accent); background: var(--accent); padding: 3px 9px; border-radius: 4px; margin-bottom: 14px; text-shadow: none; }
.tc-name { font: italic 400 clamp(44px, 8vw, 88px)/1 var(--serif); color: #fff; letter-spacing: -0.005em; text-shadow: 0 2px 24px rgba(0, 0, 0, 0.9), 0 0 60px color-mix(in oklab, var(--accent) 70%, transparent); }
.tc-formula { margin-top: 16px; font: 17px var(--mono); color: var(--accent); }
.tc-blurb { margin-top: 8px; font-size: 16px; color: rgba(237, 234, 227, 0.85); max-width: 46ch; margin-left: auto; margin-right: auto; }

#toasts {
  position: fixed;
  left: 50%;
  bottom: calc(var(--gap) * 2 + var(--hud-h) + 8px);
  transform: translateX(-50%);
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}
.toast {
  font-size: 13.5px;
  color: var(--text);
  background: var(--panel-solid);
  border: 1px solid var(--line-2);
  border-left: 3px solid var(--accent);
  border-radius: var(--r-s);
  padding: 9px 14px;
  box-shadow: 0 10px 30px -8px #000;
  animation: toast 2.8s ease forwards;
}
.toast.warn { border-left-color: var(--warn); }
@keyframes toast {
  0% { opacity: 0; transform: translateY(8px); }
  10%, 82% { opacity: 1; transform: none; }
  100% { opacity: 0; transform: translateY(-4px); }
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.55);
  animation: fade 0.2s ease;
}
.modal .modal-card { position: relative; width: min(92vw, 760px); max-height: 86vh; overflow: auto; }
.help-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 32px; padding: 8px 20px 4px; }
.help-grid h3 { font-size: 14px; font-weight: 600; color: var(--accent); margin: 14px 0 8px; }
.help-grid dl { display: grid; grid-template-columns: 124px 1fr; gap: 7px 12px; margin: 0; font-size: 13.5px; }
.help-grid dt { font: 12.5px var(--mono); color: var(--text); }
.help-grid dd { margin: 0; color: var(--dim); }
.help-foot { padding: 6px 20px 18px; color: var(--dim); font-size: 13px; margin: 8px 0 0; max-width: 70ch; }
@keyframes fade { from { opacity: 0; } }

#boot {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 50% 45%, color-mix(in oklab, var(--accent) 14%, var(--bg)), var(--bg) 65%);
  transition: opacity 0.7s ease;
}
#boot.done { opacity: 0; pointer-events: none; }
.boot-card { width: min(88vw, 440px); text-align: center; }
.boot-logo { width: 52px; height: 52px; overflow: visible; animation: spin 8s linear infinite; }
.boot-logo .logo-tick { transform-origin: 16px 16px; }
@keyframes spin { to { transform: rotate(360deg); } }
.boot-title { margin-top: 18px; font: italic 400 40px/1 var(--serif); }
.boot-sub { font-size: 13px; color: var(--dim); margin-top: 8px; }
.boot-bar { margin: 24px auto 16px; width: 220px; height: 3px; background: rgba(255, 255, 255, 0.12); overflow: hidden; border-radius: 2px; }
.boot-bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.3s ease; }
#boot-log {
  margin: 0 auto;
  min-height: 7.5em;
  text-align: left;
  display: inline-block;
  font: 12px/1.6 var(--mono);
  color: var(--dim);
  white-space: pre-wrap;
}
#boot-log b { color: var(--accent); font-weight: 500; }
#boot-log em { color: var(--bad); font-style: normal; }

body.booting #topbar, body.booting #catalog, body.booting #controls, body.booting #hud { opacity: 0; }
body.ui-hidden #topbar { transform: translateY(-140%); opacity: 0; }
body.ui-hidden #hud { transform: translateY(140%); opacity: 0; }
body.ui-hidden #catalog { transform: translateX(calc(-100% - 24px)); opacity: 0; pointer-events: none; }
body.ui-hidden #controls { transform: translateX(calc(100% + 24px)); opacity: 0; pointer-events: none; }
body.ui-hidden #vignette { opacity: 0; }

@media (max-width: 1280px) {
  :root { --cat-w: 248px; --ctl-w: 316px; }
  .readouts .ro:nth-child(4) { display: none; }
  .dg-more span { display: none; }
}

@media (max-width: 1080px) {
  .readouts .ro span { min-width: 64px; }
  #ro-a, #ro-b { min-width: 108px; }
  .nv-name { font-size: 21px; }
}

@media (max-width: 960px) {
  .learn-btn span { display: none; }
  .learn-btn { width: 38px; padding: 0; justify-content: center; border-color: transparent; }
}

@media (max-width: 860px) {
  :root { --gap: 8px; --top-h: 50px; --hud-h: 48px; }
  .brand-text, .nv-code { display: none; }
  .now-viewing { justify-content: flex-start; }
  .nv-name { font-size: 20px; }
  #btn-controls { display: grid; }
  #btn-link, #btn-full, #btn-help, .top-actions .sep { display: none; }
  .icon-btn { width: 36px; height: 36px; }

  #catalog {
    top: auto;
    bottom: calc(var(--gap) * 2 + var(--hud-h));
    left: var(--gap);
    right: var(--gap);
    width: auto;
    height: 116px;
  }
  #catalog .panel-head { display: none; }
  #catalog-list { flex-direction: row; overflow-x: auto; overflow-y: hidden; padding: 7px; gap: 7px; }
  .card { width: 160px; height: 100px; }
  .c-key { display: none; }
  .card:hover { transform: none; }
  body.cat-closed #catalog, body:not(.ctl-closed) #catalog { transform: translateY(calc(100% + 80px)); opacity: 0; pointer-events: none; }

  #controls {
    top: auto;
    left: var(--gap);
    right: var(--gap);
    width: auto;
    height: min(62vh, 560px);
    bottom: calc(var(--gap) * 2 + var(--hud-h));
    z-index: 25;
  }
  body.ctl-closed #controls { transform: translateY(calc(100% + 80px)); }
  #hud { padding: 0 12px; gap: 10px; }
  .readouts { gap: 12px; }
  #ro-a, #ro-b { max-width: 34vw; overflow: hidden; text-overflow: ellipsis; }
  .readouts .ro:nth-child(n+3) { display: none; }
  .perf .ro:nth-child(3), .signal { display: none; }
  #depth-gauge { position: static; transform: none; width: auto; align-self: stretch; margin: 3px 0; padding: 0 8px; }
  .dg-track { display: none; }
  .help-grid { grid-template-columns: 1fr; }
  .fx-fam { grid-template-columns: 1fr; }
  .fx-grid { grid-template-columns: 1fr 1fr; }
  .fx-fam-name { grid-row: auto; }
  .fx-formula { font-size: 28px; }
  #titlecard { top: 34%; }
  .tc-name { font-size: clamp(36px, 11vw, 60px); }
}

@media (prefers-reduced-motion: reduce) {
  .boot-logo { animation: none; }
  .card::before { animation: none; }
  .panel, .tab::after, .toggle .sw::after, .card, .icon-btn { transition: none; }
  #titlecard.show { animation-duration: 2s; }
}
