@font-face {
  font-family: Orbitron;
  src: url("https://mess.engineering/font/Orbitron-VariableFont_wght.ttf") format("truetype");
  font-weight: 100 900;
  font-display: swap;
}

@font-face {
  font-family: Inter;
  src: url("https://mess.engineering/font/Inter-VariableFont_opsz,wght.ttf") format("truetype");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --bg: #0b0f14;
  --text: #f4f7fb;
  --muted: #98a4b3;
  --line: rgba(255, 255, 255, 0.1);
  --panel: rgba(11, 15, 20, 0.72);
  --donner: #ffc53d;
  --dampf: #00fff2;
  --blitz: #ff5a4f;
  --unsettled: #b388ff;
  --axis-x: #5b8cff;
  --axis-y: #e8c547;
  --axis-z: #3ecf8e;
  --radius: 16px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  color: var(--text);
  background: var(--bg);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
}

/*
 * Overlay chrome only. A viewport-sized fixed root paints over the
 * WebGL canvas (0×0 canvas or no orbit) and, as a WebXR DOM overlay,
 * covers passthrough. Stay `absolute` until AR so nested `fixed` HUD
 * (Play, stack) is still viewport-relative on iOS. Children are fixed.
 */
.xr-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  z-index: 2;
  overflow: visible;
  pointer-events: none;
  background: none;
}

#view {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  display: block;
  touch-action: none;
  cursor: default;
}

#view[data-cursor="pointer"] {
  cursor: pointer;
}

#view[data-cursor="frame"],
#view[data-cursor="drag"] {
  cursor: move;
}

.brand,
.hud-rail,
.controls-root,
.fold-bar,
.legal,
.fps-chip {
  position: fixed;
  z-index: 2;
  pointer-events: auto;
  touch-action: manipulation;
}

.brand {
  top: calc(12px + var(--safe-t));
  left: calc(12px + var(--safe-l));
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px 8px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  backdrop-filter: blur(12px);
}

.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: linear-gradient(135deg, rgba(255, 197, 61, 0.2), rgba(0, 255, 242, 0.12));
  font-family: Orbitron, sans-serif;
  font-weight: 700;
  color: var(--donner);
}

.brand h1 {
  margin: 0;
  font-family: Orbitron, sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.14em;
}

.tagline {
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
}

.hud-rail {
  top: calc(12px + var(--safe-t));
  right: calc(12px + var(--safe-r));
  bottom: calc(52px + var(--safe-b));
  left: auto;
  width: max-content;
  max-width: calc(100% - 24px - var(--safe-l) - var(--safe-r));
  display: flex;
  flex-direction: row;
  align-items: stretch;
  justify-content: flex-end;
  gap: 8px;
  pointer-events: none;
}

.gizmo-col {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  flex: 0 0 144px;
  width: 144px;
  align-self: flex-start;
  pointer-events: none;
}

.gizmo-slot {
  position: relative;
  flex: 0 0 144px;
  width: 144px;
  height: 144px;
  pointer-events: none;
}

.gizmo-hit {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: auto;
  touch-action: none;
  cursor: pointer;
  /* iOS skips hit-testing fully transparent nodes */
  background: rgba(0, 0, 0, 0.01);
}

.btn-show-planes {
  appearance: none;
  pointer-events: auto;
  margin: 0;
  padding: 4px 8px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  backdrop-filter: blur(12px);
  color: var(--muted);
  font-family: Orbitron, sans-serif;
  font-size: 0.58rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}

.btn-show-planes.is-on {
  border-color: rgba(0, 255, 242, 0.45);
  color: var(--dampf);
  box-shadow: 0 0 8px rgba(0, 255, 242, 0.2);
}

body.is-ar .gizmo-col,
body.is-ar .gizmo-slot,
body.is-ar .gizmo-hit {
  display: none !important;
  pointer-events: none;
}

@media (pointer: coarse) {
  .gizmo-col,
  .gizmo-slot,
  .gizmo-hit {
    display: none !important;
    pointer-events: none;
  }
}

.fps-chip {
  display: none;
  top: calc(12px + var(--safe-t));
  right: calc(12px + var(--safe-r));
  margin: 0;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  backdrop-filter: blur(12px);
  color: var(--dampf);
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  cursor: pointer;
}

.fps-chip[aria-expanded="true"] {
  border-color: rgba(0, 255, 242, 0.45);
}

.hud-time {
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  flex: 0 0 auto;
  width: 9.2rem;
  min-width: 8.4rem;
  min-height: 0;
  gap: 8px;
}

.hud-cards {
  width: 10.5rem;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.hud-engine {
  pointer-events: auto;
  margin: 0;
  padding: 8px 10px 10px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  backdrop-filter: blur(12px);
}

.sheet-fold {
  appearance: none;
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-align: left;
  cursor: pointer;
}

.sheet-fold:hover,
.sheet-fold:focus-visible {
  color: var(--text);
  outline: none;
}

.fold-meter {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  min-width: 0;
}

.fold-meter .sheet-fold {
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
}

.fold-fps {
  margin: 0;
  flex: 0 0 auto;
  color: var(--dampf);
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 0.72rem;
  line-height: 1.2;
  white-space: nowrap;
}

#hud-view-fps {
  display: none;
}

body.hud-view-collapsed #hud-view-fps {
  display: block;
}

body.hud-view-collapsed .hud-engine .hud-spark,
body.hud-view-collapsed .hud-engine .hud-stats,
body.hud-view-collapsed .hud-engine .hud-dev,
body.hud-view-collapsed .hud-engine .hud-dev-note {
  display: none;
}

body.hud-view-collapsed .hud-engine {
  padding: 6px 10px;
  width: auto;
  align-self: flex-end;
}

.hud-spark {
  display: block;
  width: 100%;
  height: 32px;
  margin: 4px 0 6px;
}

.hud-stats {
  margin: 0;
  padding: 0;
  min-width: 0;
  border: 0;
  background: none;
  color: var(--dampf);
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 0.72rem;
  line-height: 1.45;
  white-space: pre;
}

.view-bench {
  margin-top: 2px;
  font-size: 0.58rem;
  overflow: visible;
}

.hud-dev {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--line);
  font-size: 0.62rem;
  letter-spacing: 0.04em;
}

.hud-dev-note {
  margin: 0;
  font-size: 0.58rem;
  color: var(--muted);
}

.stack-block {
  pointer-events: none;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  gap: 6px;
}

.stack-block .stack,
.stack-block .loop-axes {
  pointer-events: auto;
}

.stack {
  pointer-events: auto;
  flex: 1 1 auto;
  min-height: 140px;
  width: 100%;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 4px;
  margin: 0;
  padding: 2px 0 4px;
  border: 0;
  background: none;
  opacity: 0.4;
  transition: opacity 0.15s ease;
}

.stack:hover,
.stack:focus-within {
  opacity: 0.92;
}

.stack-axis {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1 1 0;
  min-width: 2.5rem;
  gap: 4px;
}

.stack-axis.is-z {
  flex: 1.25 1 0;
  min-width: 3.1rem;
}

.stack-axis-label {
  font-family: Orbitron, sans-serif;
  font-size: 0.54rem;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.stack-axis.is-active .stack-axis-label {
  color: var(--axis);
}

.stack-axis.is-loop .stack-axis-label {
  color: var(--axis);
  box-shadow: 0 1px 0 var(--axis);
}

.stack-axis.is-active .stack-rail {
  background: color-mix(in srgb, var(--axis) 40%, transparent);
}

.stack-axis[data-axis="x"] {
  --axis: var(--axis-x);
}

.stack-axis[data-axis="y"] {
  --axis: var(--axis-y);
}

.stack-axis[data-axis="z"] {
  --axis: var(--axis-z);
}

body:not(.is-inspect) .stack-axis:not(.is-z) {
  display: none;
}

body.is-ar .stack-axis:not(.is-z) {
  display: none !important;
}

.inspect-transport {
  pointer-events: auto;
  flex: 0 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.inspect-transport .btn-play,
.inspect-transport .btn-loop-run {
  width: 100%;
}

.btn-loop-run {
  border-color: rgba(0, 255, 242, 0.35);
  color: var(--dampf);
}

.btn-loop-run.is-live {
  border-color: rgba(255, 197, 61, 0.45);
  color: var(--donner);
}

.inspect-transport .field {
  padding: 0 2px;
}

.conway-live {
  pointer-events: none;
  margin: 0;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--dampf);
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 0.62rem;
  line-height: 1.35;
  white-space: pre;
}

body.is-ar .loop-axes,
body.is-ar .inspect-transport,
body.is-ar .conway-live {
  display: none !important;
}

.transport {
  position: static;
  pointer-events: auto;
  flex: 0 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stack-name,
.slice-axes,
.loop-axes {
  font-family: Orbitron, sans-serif;
  font-size: 0.58rem;
  letter-spacing: 0.12em;
  color: var(--dampf);
}

.loop-axes {
  pointer-events: auto;
  width: 100%;
  display: flex;
  gap: 4px;
}

.btn-loop {
  appearance: none;
  margin: 0;
  padding: 2px 6px;
  flex: 1 1 0;
  min-width: 0;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--muted);
  font-family: Orbitron, sans-serif;
  font-size: 0.54rem;
  letter-spacing: 0.08em;
  cursor: pointer;
}

.btn-loop.is-on {
  color: var(--axis, var(--dampf));
  border-color: color-mix(in srgb, var(--axis, var(--dampf)) 55%, transparent);
  box-shadow: 0 0 8px color-mix(in srgb, var(--axis, var(--dampf)) 28%, transparent);
}

.btn-loop[data-axis="x"] {
  --axis: var(--axis-x);
}

.btn-loop[data-axis="y"] {
  --axis: var(--axis-y);
}

.btn-loop[data-axis="z"] {
  --axis: var(--axis-z);
}

.btn-shade.is-on {
  border-color: rgba(0, 255, 242, 0.55);
  color: var(--dampf);
  box-shadow: 0 0 8px rgba(0, 255, 242, 0.25);
}

.shade-modes {
  margin: 6px 0 2px;
}

.field > .shade-modes {
  margin: 0;
}

.stack-cap {
  color: var(--muted);
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 0.58rem;
  text-align: center;
  line-height: 1;
}

.stack-track {
  position: relative;
  flex: 1 1 auto;
  width: 100%;
  min-height: 80px;
  touch-action: none;
  user-select: none;
}

.stack-rail {
  position: absolute;
  left: 18px;
  top: 0;
  bottom: 0;
  width: 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  pointer-events: none;
}

.stack-slab {
  position: absolute;
  left: 18px;
  width: 3px;
  top: calc(var(--near) * 100%);
  height: calc((var(--far) - var(--near)) * 100%);
  min-height: 4px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--axis, var(--donner)) 80%, transparent);
  box-shadow: 0 0 8px color-mix(in srgb, var(--axis, var(--donner)) 35%, transparent);
  pointer-events: none;
}

body:not(.is-inspect) .stack-slab,
body:not(.is-inspect) .z-clip {
  display: none;
}

.z-handle {
  --frac: 0;
  position: absolute;
  top: calc(var(--frac) * 100%);
  transform: translateY(-50%);
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.4);
  cursor: ns-resize;
  z-index: 2;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.z-handle::after {
  content: "";
  position: absolute;
  inset: -10px;
}

.z-handle:focus-visible {
  outline: 1px solid var(--dampf);
  outline-offset: 2px;
}

.z-clip {
  left: 2px;
  width: 14px;
  height: 10px;
  border-radius: 2px;
  background: var(--axis, var(--donner));
  box-shadow: 0 0 8px color-mix(in srgb, var(--axis, var(--donner)) 40%, transparent);
}

.z-focus {
  left: 14px;
  width: 22px;
  height: 16px;
  border-radius: 3px;
  background: var(--axis, var(--dampf));
  box-shadow: 0 0 10px color-mix(in srgb, var(--axis, var(--dampf)) 50%, transparent);
  z-index: 3;
}

.z-focus:disabled,
.stack-range:disabled + .z-focus {
  opacity: 0.45;
  cursor: default;
}

.stack-ticks {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 8px;
  pointer-events: none;
}

.stack-tick {
  --frac: 0;
  position: absolute;
  right: 0;
  top: calc(var(--frac) * 100%);
  width: 4px;
  height: 1px;
  background: rgba(0, 255, 242, 0.4);
  transform: translateY(-50%);
}

.stack-tick.is-major {
  width: 8px;
  background: rgba(0, 255, 242, 0.8);
}

.stack-tick.is-mid {
  width: 10px;
  height: 2px;
  background: var(--donner);
}

.stack-thumb-time {
  --frac: 0;
  position: absolute;
  left: 40px;
  top: calc(var(--frac) * 100%);
  transform: translateY(-50%);
  color: var(--dampf);
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 0.62rem;
  line-height: 1;
  pointer-events: none;
  text-shadow: 0 0 8px rgba(11, 15, 20, 0.95);
}

.stack-range {
  position: absolute;
  left: 10px;
  top: 0;
  bottom: 0;
  height: 100%;
  width: 22px;
  margin: 0;
  writing-mode: vertical-lr;
  direction: ltr;
  -moz-orient: vertical;
  appearance: none;
  background: transparent;
  cursor: ns-resize;
  opacity: 0;
  pointer-events: none;
  z-index: 1;
}

.stack-range:disabled {
  opacity: 0.45;
  cursor: default;
}

.stack-range::-webkit-slider-runnable-track {
  width: 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
}

.stack-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 8px;
  margin-left: -4.5px;
  border-radius: 2px;
  background: var(--dampf);
  border: 1px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 0 8px rgba(0, 255, 242, 0.45);
}

.stack-range::-moz-range-track {
  width: 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
}

.stack-range::-moz-range-thumb {
  width: 12px;
  height: 8px;
  border-radius: 2px;
  background: var(--dampf);
  border: 1px solid rgba(255, 255, 255, 0.35);
}

.fold-bar {
  display: none;
  bottom: calc(12px + var(--safe-b));
  left: calc(12px + var(--safe-l));
  right: calc(12px + var(--safe-r));
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
}

.fold {
  display: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--text);
  font-family: Orbitron, sans-serif;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  padding: 10px 14px;
  pointer-events: auto;
}

.controls-root {
  top: calc(76px + var(--safe-t));
  left: calc(12px + var(--safe-l));
  width: min(280px, calc(100vw - 24px - var(--safe-l) - var(--safe-r)));
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  max-height: calc(100dvh - 140px);
  overflow: auto;
}

.controls {
  flex: 0 0 auto;
  width: 100%;
  max-height: none;
  overflow: visible;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sheet-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.controls.is-collapsed .sheet-body {
  display: none;
}

body.is-loading .controls.is-collapsed {
  gap: 8px;
}

.source-load {
  display: none;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--dampf);
  font-family: Orbitron, sans-serif;
  font-size: 0.58rem;
  letter-spacing: 0.1em;
}

body.is-loading .source-load {
  display: flex !important;
}

.load-overlay {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 4;
  display: none;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--dampf);
  font-family: Orbitron, sans-serif;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  pointer-events: none;
}

body.is-loading .load-overlay {
  display: flex !important;
}

.load-spin {
  width: 0.9rem;
  height: 0.9rem;
  flex: 0 0 auto;
  border: 2px solid var(--line);
  border-top-color: var(--dampf);
  border-radius: 50%;
  animation: load-spin 0.7s linear infinite;
}

@keyframes load-spin {
  to {
    transform: rotate(360deg);
  }
}

.sheet-label {
  margin: 0 0 2px;
  font-family: Orbitron, sans-serif;
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.panel-view .rail-fold,
[data-slot="view"] .sheet-label,
.hud-engine .sheet-label {
  color: var(--dampf);
}

[data-slot="encoding"] .sheet-label {
  color: var(--donner);
}

.is-hidden {
  display: none;
}

.inspect-only {
  display: none;
}

body.is-inspect .inspect-only {
  display: block;
}

body.is-inspect #depth-field {
  display: none;
}

body.is-software .fps-chip,
body.is-software .fold-fps {
  color: var(--blitz);
}

body.is-software .fps-chip {
  border-color: rgba(255, 90, 79, 0.55);
}

#random-fill-field {
  display: none;
}

body.pattern-random #random-fill-field {
  display: flex;
}

.source-play {
  grid-template-columns: 1fr auto;
  align-items: stretch;
}

.sheet-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sheet-body > .sheet-block + .sheet-block {
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.source-stats {
  margin: 4px 0 0;
  padding: 8px 0 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.75rem;
}

.stab-ramp {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stab-ramp[hidden] {
  display: none;
}

.stab-hint,
.read-hint {
  font-size: 0.68rem;
  line-height: 1.35;
}

.btn-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.btn-row > :last-child:nth-child(odd) {
  grid-column: 1 / -1;
}

.btn-row-one {
  grid-template-columns: 1fr;
}

.btn {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-family: Orbitron, sans-serif;
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  cursor: pointer;
}

.btn:hover,
.btn:focus-visible {
  border-color: rgba(255, 197, 61, 0.45);
  outline: none;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn:active {
  transform: translateY(1px);
}

.btn-play {
  width: 100%;
  border-color: rgba(255, 197, 61, 0.35);
  color: var(--donner);
}

.btn-ar,
.btn-ar-search,
.btn-ar-reset,
.btn-xr-exit {
  width: 100%;
}

.btn-ar {
  border-color: rgba(0, 255, 242, 0.4);
  color: var(--dampf);
}

.btn-ar-search {
  border-color: rgba(0, 255, 242, 0.45);
  color: var(--dampf);
}

.btn-ar-search.is-on {
  border-color: var(--donner);
  color: var(--donner);
  background: rgba(255, 197, 61, 0.12);
}

.btn-ar-reset {
  border-color: rgba(255, 197, 61, 0.45);
  color: var(--donner);
}

.btn-xr-exit {
  border-color: rgba(255, 90, 79, 0.45);
  color: var(--blitz);
}

html.is-ar,
body.is-ar {
  background: transparent;
}

html.is-ar .xr-overlay {
  position: fixed;
  inset: 0;
  width: auto;
  height: auto;
  background: none;
}

body.is-ar .brand,
body.is-ar .fold-bar,
body.is-ar .controls,
body.is-ar .hud-engine,
body.is-ar .fps-chip {
  backdrop-filter: none;
}

body.is-ar .brand,
body.is-ar .fold-bar,
body.is-ar .controls-root,
body.is-ar .fps-chip,
body.is-ar .legal,
body.is-ar .hud-cards {
  display: none !important;
}

body.is-ar .hud-rail {
  pointer-events: none;
}

body.is-ar .hud-time,
body.is-ar .stack,
body.is-ar .transport,
body.is-ar .ar-size,
body.is-ar .ar-yaw,
body.is-ar .ar-height,
body.is-ar .ar-stand {
  pointer-events: auto;
}

body.is-ar .stack-axis:not(.is-z) {
  display: none !important;
}

.ar-size,
.ar-yaw,
.ar-height,
.ar-stand {
  display: none;
}

body.is-ar.is-ar-placed .ar-size,
body.is-ar.is-ar-placed .ar-yaw,
body.is-ar.is-ar-placed .ar-height {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 4px 6px 2px;
  color: var(--dampf);
  font-family: Orbitron, sans-serif;
  font-size: 0.58rem;
  letter-spacing: 0.08em;
}

body.is-ar .ar-stand {
  display: none !important;
}

body.is-ar:not(.is-ar-placed) .stack,
body.is-ar:not(.is-ar-placed) .btn-play {
  display: none !important;
}

body.is-ar.is-ar-placed .ar-size input,
body.is-ar.is-ar-placed .ar-yaw input,
body.is-ar.is-ar-placed .ar-height input {
  flex: 1 1 auto;
  min-width: 0;
  accent-color: var(--donner);
}

.btn-stand {
  appearance: none;
  margin: 0;
  padding: 4px 10px;
  min-width: 32px;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  font-family: Orbitron, sans-serif;
  font-size: 0.72rem;
  font-weight: 700;
}

#ar-stand-x { color: var(--axis-x); }
#ar-stand-y { color: var(--axis-y); }
#ar-stand-z { color: var(--axis-z); }

.btn-stand.is-on {
  border-color: var(--donner);
  color: var(--donner);
  background: rgba(255, 197, 61, 0.12);
}

.btn-play.is-live {
  border-color: rgba(0, 255, 242, 0.4);
  color: var(--dampf);
}

.btn-edit.is-on,
#btn-wolke-connect.is-on {
  border-color: rgba(255, 197, 61, 0.55);
  color: var(--donner);
  background: rgba(255, 197, 61, 0.08);
}

.btn-parallax.is-on {
  border-color: rgba(0, 255, 242, 0.5);
  color: var(--dampf);
  background: rgba(0, 255, 242, 0.08);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.75rem;
  color: var(--muted);
}

.field span {
  font-family: Orbitron, sans-serif;
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.field em {
  font-style: normal;
  color: var(--text);
}

.field input,
.field select {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111720;
  color: var(--text);
  font: inherit;
  padding: 0 8px;
}

.field input[type="range"] {
  padding: 0;
  accent-color: var(--donner);
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.78rem;
}

.check input {
  width: 18px;
  height: 18px;
  accent-color: var(--donner);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin: 2px 0 0;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-size: 0.72rem;
}

#source-conway {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#source-count,
body.source-count #source-count {
  display: none;
}

body.source-count #source-conway {
  display: none;
}

.encoding-count {
  display: none;
}

body.source-count .encoding-count.hint {
  display: flex;
}

body.source-count .encoding-count.field {
  display: flex;
}

body.source-count .cmap-scale {
  display: flex;
}

.cmap-scale {
  display: none;
  flex-direction: column;
  gap: 4px;
}

.cmap-bar {
  height: 8px;
  border-radius: 2px;
  width: 100%;
}

.cmap-ticks {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--muted);
}

body.source-count .encoding-conway {
  display: none;
}

.file-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.file-btn input {
  display: none;
}

.legend li {
  display: flex;
  align-items: center;
  gap: 6px;
}

.swatch {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  display: inline-block;
}

.swatch.still {
  background: var(--donner);
}

.swatch.osc {
  background: var(--dampf);
}

.swatch.flow {
  background: var(--blitz);
}

.swatch.unsettled {
  background: var(--unsettled);
}

.swatch.base,
.swatch.warmup {
  background: #8a9aa8;
}

.legal {
  right: calc(12px + var(--safe-r));
  bottom: calc(10px + var(--safe-b));
  color: var(--muted);
  font-size: 0.7rem;
}

.legal a:hover {
  color: var(--donner);
}

.legal .btn-link {
  color: var(--muted);
  font-size: inherit;
  text-decoration: none;
}

.legal .btn-link:hover {
  color: var(--donner);
}

.btn-link {
  display: inline;
  padding: 0;
  border: 0;
  background: none;
  color: var(--dampf);
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.btn-link:hover {
  color: var(--donner);
}

.source-welcome,
.source-blurb,
.source-cite {
  margin: 0 0 8px;
}

.source-cite {
  font-size: 0.68rem;
}

.about-dialog {
  width: min(420px, calc(100vw - 32px));
  max-height: min(80vh, 640px);
  padding: 16px 18px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #111720;
  color: var(--text);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
}

.about-dialog::backdrop {
  background: rgba(7, 10, 14, 0.62);
}

.about-dialog h2 {
  margin: 0 0 8px;
  font-family: Orbitron, sans-serif;
  font-size: 0.85rem;
  letter-spacing: 0.12em;
}

.about-dialog h3 {
  margin: 12px 0 6px;
  font-family: Orbitron, sans-serif;
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.about-dialog p,
.about-dialog li {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

.about-dialog ul {
  margin: 0 0 8px;
  padding-left: 1.1em;
}

.about-dialog a {
  color: var(--dampf);
}

.about-dialog .btn {
  margin-top: 8px;
}

body.is-ar .about-dialog {
  display: none;
}

@media (max-width: 720px), (pointer: coarse) and (max-height: 520px) {
  .fold-bar {
    display: flex;
    z-index: 3;
  }

  .fold {
    display: block;
  }

  .fps-chip {
    display: block;
    z-index: 3;
  }

  .legal {
    display: none;
  }

  .controls-root {
    top: auto;
    left: calc(12px + var(--safe-l));
    right: calc(12px + var(--safe-r));
    bottom: 0;
    width: auto;
    max-height: none;
    overflow: visible;
    pointer-events: none;
    background: none;
    gap: 0;
  }

  /* iOS native <select> ignores pointer-events:auto on the panel when an
   * ancestor is none. Open sheets must lift that ancestor. */
  .controls-root:has(.is-open) {
    pointer-events: auto;
  }

  body:has(.controls.is-open) .stack {
    visibility: hidden;
    pointer-events: none;
  }

  .controls {
    position: absolute;
    left: 0;
    right: 0;
    bottom: calc(118px + var(--safe-b));
    flex: none;
    width: auto;
    max-height: min(62dvh, calc(100dvh - 132px - var(--safe-t) - var(--safe-b)));
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    transform: translateY(100dvh);
    pointer-events: none;
    touch-action: pan-y;
    transition: transform 0.22s ease;
  }

  .controls.is-open {
    transform: none;
    pointer-events: auto;
    touch-action: pan-y;
  }

  .controls.is-collapsed .sheet-body {
    display: flex;
  }

  .controls.is-collapsed {
    padding: 12px;
    gap: 8px;
  }

  .hud-rail {
    top: auto;
    left: calc(12px + var(--safe-l));
    right: calc(12px + var(--safe-r));
    bottom: calc(56px + var(--safe-b));
    width: auto;
    flex-direction: column;
    align-items: stretch;
    pointer-events: none;
  }

  .hud-cards {
    display: none;
    position: fixed;
    top: calc(48px + var(--safe-t));
    right: calc(12px + var(--safe-r));
    width: 8.6rem;
    z-index: 3;
    pointer-events: auto;
  }

  .gizmo-col,
  .gizmo-slot,
  .gizmo-hit {
    display: none !important;
  }

  .sheet-fold {
    pointer-events: none;
    cursor: default;
  }

  body.hud-view-open .hud-cards {
    display: flex;
  }

  .hud-stats {
    font-size: 0.64rem;
  }

  .hud-spark {
    height: 24px;
  }

  .hud-time {
    flex: 1 1 auto;
    flex-direction: row;
    flex-wrap: wrap;
    width: 100%;
    min-width: 0;
    min-height: 0;
    align-items: center;
  }

  body.is-ar.is-ar-placed .ar-size,
  body.is-ar.is-ar-placed .ar-yaw,
  body.is-ar.is-ar-placed .ar-height {
    order: -1;
  }

  .stack {
    flex-direction: column;
    width: 100%;
    min-height: 0;
    height: auto;
    padding: 0 4px;
    gap: 2px;
  }

  .stack-axis {
    flex-direction: row;
    width: 100%;
    min-width: 0;
    height: 40px;
    gap: 6px;
  }

  .stack-axis.is-z {
    min-width: 0;
  }

  .stack-axis-label {
    order: 0;
    flex: 0 0 auto;
    width: 0.9rem;
  }

  .stack-name {
    display: none;
  }

  .stack-cap {
    order: 1;
    flex: 0 0 auto;
  }

  .stack-track {
    order: 2;
    flex: 1 1 auto;
    min-height: 44px;
    height: 48px;
    width: auto;
  }

  .stack-rail {
    left: 0;
    right: 0;
    top: 16px;
    bottom: auto;
    width: auto;
    height: 3px;
  }

  .stack-slab {
    left: calc((1 - var(--far)) * 100%);
    width: calc((var(--far) - var(--near)) * 100%);
    top: 16px;
    height: 3px;
    min-height: 0;
    min-width: 4px;
  }

  .z-handle {
    top: 8px;
    left: calc((1 - var(--frac)) * 100%);
    transform: translateX(-50%);
    cursor: ew-resize;
  }

  .z-handle::after {
    inset: -16px -14px;
  }

  .z-clip {
    top: 28px;
    width: 18px;
    height: 16px;
  }

  .z-focus {
    top: 4px;
    left: calc((1 - var(--frac)) * 100%);
    width: 24px;
    height: 24px;
  }

  .stack-ticks {
    left: 0;
    right: 0;
    top: auto;
    bottom: 8px;
    width: auto;
    height: 8px;
  }

  .stack-tick {
    top: auto;
    right: auto;
    bottom: 0;
    left: calc((1 - var(--frac)) * 100%);
    width: 1px;
    height: 4px;
    transform: translateX(-50%);
  }

  .stack-tick.is-major {
    width: 1px;
    height: 8px;
  }

  .stack-tick.is-mid {
    width: 2px;
    height: 10px;
    background: var(--donner);
  }

  .stack-thumb-time {
    left: calc((1 - var(--frac)) * 100%);
    top: 0;
    transform: translate(-50%, -100%);
  }

  .stack-range {
    left: 0;
    right: 0;
    top: 10px;
    bottom: auto;
    width: 100%;
    height: 14px;
    writing-mode: horizontal-tb;
    direction: rtl;
    cursor: ew-resize;
    pointer-events: none;
  }

  .stack-range::-webkit-slider-runnable-track {
    width: 100%;
    height: 3px;
  }

  .stack-range::-webkit-slider-thumb {
    width: 8px;
    height: 12px;
    margin-left: 0;
    margin-top: -4.5px;
  }

  .stack-range::-moz-range-track {
    width: 100%;
    height: 3px;
  }

  .inspect-transport {
    width: 100%;
    flex-direction: row;
    align-items: center;
    gap: 8px;
  }

  .inspect-transport .btn-play,
  .inspect-transport .btn-loop-run {
    width: auto;
    min-width: 5.5rem;
  }

  .inspect-transport .field {
    flex: 1 1 auto;
    min-width: 0;
  }

  .conway-live {
    width: 100%;
  }

  .transport {
    position: fixed;
    left: 50%;
    bottom: calc(12px + var(--safe-b));
    transform: translateX(-50%);
    width: auto;
    z-index: 4;
    flex-direction: row;
    align-items: center;
    gap: 8px;
  }

  .transport .btn-play,
  .transport .btn-ar,
  .transport .btn-ar-search,
  .transport .btn-ar-reset,
  .transport .btn-xr-exit {
    min-width: 4.6rem;
    width: auto;
    flex-shrink: 0;
  }

  .brand h1 {
    font-size: 0.82rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .controls {
    transition: none;
  }
}
