:root {
  --void: #080511;
  --void-rgb: 8, 5, 17;
  --ink: #f7f3ff;
  --muted: #a49ab8;
  --faint: #6e647f;
  --accent: #b59cff;
  --accent-bright: #d9ceff;
  --cyan: #4df8ff;
  --panel: rgba(13, 9, 24, 0.84);
  --panel-strong: rgba(18, 13, 32, 0.96);
  --line: rgba(255, 255, 255, 0.11);
  --line-bright: rgba(255, 255, 255, 0.2);
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
  --radius-lg: 24px;
  --radius-md: 15px;
  --topbar-height: 72px;
  --panel-width: 370px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  width: 100%;
  min-width: 280px;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--void);
}

body {
  color: var(--ink);
  overscroll-behavior: none;
}

button,
input,
select {
  font: inherit;
}

button,
select,
input[type="range"],
input[type="checkbox"],
input[type="color"] {
  cursor: pointer;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
.stage:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 3px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.38;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 12px;
  left: 12px;
  padding: 10px 14px;
  border-radius: 10px;
  color: #080511;
  background: var(--cyan);
  font-weight: 750;
  transform: translateY(-180%);
  transition: transform 160ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

.app-shell {
  position: relative;
  isolation: isolate;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(circle at 42% 42%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 30%),
    radial-gradient(circle at 18% 76%, rgba(77, 248, 255, 0.055), transparent 28%),
    var(--void);
}

.app-shell::before {
  position: fixed;
  z-index: -1;
  inset: 0;
  pointer-events: none;
  content: "";
  opacity: 0.24;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.16'/%3E%3C/svg%3E");
  mix-blend-mode: soft-light;
}

.topbar {
  position: fixed;
  z-index: 30;
  top: 0;
  right: 0;
  left: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--topbar-height);
  padding: 12px max(18px, env(safe-area-inset-right)) 12px max(18px, env(safe-area-inset-left));
  pointer-events: none;
}

.topbar::after {
  position: absolute;
  z-index: -1;
  inset: 0 0 -28px;
  content: "";
  pointer-events: none;
  background: linear-gradient(to bottom, rgba(var(--void-rgb), 0.94), rgba(var(--void-rgb), 0));
}

.brand,
.toolbar {
  pointer-events: auto;
}

.brand {
  display: inline-flex;
  gap: 11px;
  align-items: center;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid rgba(181, 156, 255, 0.58);
  border-radius: 12px;
  color: var(--accent-bright);
  background:
    linear-gradient(145deg, rgba(181, 156, 255, 0.2), rgba(77, 248, 255, 0.05)),
    rgba(13, 9, 24, 0.82);
  box-shadow: inset 0 0 18px rgba(181, 156, 255, 0.12), 0 0 24px rgba(181, 156, 255, 0.09);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.05em;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.brand-copy strong {
  font-size: 15px;
  font-weight: 720;
  letter-spacing: -0.015em;
}

.brand-copy small {
  margin-top: 4px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.toolbar {
  display: flex;
  gap: 7px;
  align-items: center;
}

.icon-button,
.action-button,
.controls-button,
.panel-close,
.secondary-button,
.primary-button,
.mobile-dock button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(15, 11, 27, 0.76);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.035);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease, transform 160ms ease;
}

.icon-button:hover,
.action-button:hover,
.controls-button:hover,
.panel-close:hover,
.secondary-button:hover:not(:disabled),
.mobile-dock button:hover {
  border-color: var(--line-bright);
  background: rgba(28, 21, 47, 0.9);
  transform: translateY(-1px);
}

.icon-button:active,
.action-button:active,
.controls-button:active,
.panel-close:active,
.secondary-button:active,
.mobile-dock button:active {
  transform: translateY(0) scale(0.97);
}

.icon-button {
  display: grid;
  width: 40px;
  padding: 0;
  place-items: center;
  color: #d8d0e8;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 16px;
}

.icon-button[aria-pressed="true"] {
  border-color: rgba(77, 248, 255, 0.42);
  color: var(--cyan);
  background: rgba(77, 248, 255, 0.08);
}

.action-button,
.controls-button {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  padding: 0 13px;
  color: #ded6ed;
  font-size: 12px;
  font-weight: 680;
}

.controls-button {
  border-color: rgba(181, 156, 255, 0.34);
  color: var(--accent-bright);
  background: rgba(181, 156, 255, 0.1);
}

.stage {
  position: absolute;
  z-index: 1;
  inset: 0;
  overflow: hidden;
  touch-action: none;
  cursor: grab;
}

.stage[data-dragging="true"] {
  cursor: grabbing;
}

.stage:focus-visible {
  outline-offset: -4px;
}

.webgl-mount,
.webgl-mount canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

.webgl-mount {
  z-index: 1;
}

.webgl-mount canvas {
  image-rendering: auto;
}

.stage-glow {
  position: absolute;
  z-index: 0;
  top: 50%;
  left: 45%;
  width: min(64vw, 720px);
  aspect-ratio: 1;
  border-radius: 999px;
  pointer-events: none;
  background: radial-gradient(circle, color-mix(in srgb, var(--accent) 11%, transparent), transparent 66%);
  filter: blur(32px);
  transform: translate(-50%, -50%);
  transition: background 400ms ease;
}

.stage[data-pulsing="true"] .stage-glow {
  animation: stage-pulse 600ms var(--ease);
}

@keyframes stage-pulse {
  0%, 100% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  38% { opacity: 1.8; transform: translate(-50%, -50%) scale(1.18); }
}

.stage-vignette {
  position: absolute;
  z-index: 2;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(var(--void-rgb), 0.28), transparent 20%, transparent 72%, rgba(var(--void-rgb), 0.38)),
    radial-gradient(circle at 45% 48%, transparent 34%, rgba(var(--void-rgb), 0.28) 78%, rgba(var(--void-rgb), 0.58) 100%);
}

.preset-rail {
  position: absolute;
  z-index: 8;
  top: 92px;
  left: max(20px, env(safe-area-inset-left));
  display: flex;
  gap: 8px;
  max-width: calc(100vw - var(--panel-width) - 72px);
  padding: 3px;
  overflow-x: auto;
  pointer-events: auto;
  scrollbar-width: none;
}

.preset-rail::-webkit-scrollbar {
  display: none;
}

.preset-chip {
  flex: 0 0 auto;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(10, 7, 18, 0.54);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  transition: color 160ms ease, border-color 160ms ease, background 160ms ease;
}

.preset-chip:hover,
.preset-chip[aria-pressed="true"] {
  border-color: rgba(181, 156, 255, 0.42);
  color: var(--accent-bright);
  background: rgba(181, 156, 255, 0.09);
}

.scene-badge {
  position: absolute;
  z-index: 8;
  top: 50%;
  left: 22px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  color: rgba(239, 232, 255, 0.42);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 8px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  writing-mode: vertical-rl;
  transform: translateY(-50%) rotate(180deg);
}

.scene-badge i {
  display: block;
  width: 1px;
  height: 34px;
  background: linear-gradient(var(--accent), transparent);
}

.interaction-hint {
  position: absolute;
  z-index: 10;
  bottom: 52px;
  left: 50%;
  display: flex;
  gap: 9px;
  align-items: center;
  max-width: calc(100vw - var(--panel-width) - 44px);
  margin: 0;
  padding: 9px 10px 9px 14px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 999px;
  color: rgba(225, 216, 242, 0.7);
  background: rgba(10, 7, 18, 0.62);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9px;
  letter-spacing: 0.03em;
  pointer-events: auto;
  transform: translateX(calc(-50% - var(--panel-width) / 3));
  transition: opacity 220ms ease, transform 220ms var(--ease);
}

.interaction-hint[hidden] {
  display: none;
}

.interaction-hint button {
  display: grid;
  width: 24px;
  height: 24px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.06);
}

.touch-hint {
  display: none;
}

.render-stats {
  position: absolute;
  z-index: 10;
  top: 142px;
  left: max(20px, env(safe-area-inset-left));
  display: grid;
  grid-template-columns: repeat(3, auto);
  gap: 5px 12px;
  padding: 9px 11px;
  border: 1px solid rgba(77, 248, 255, 0.14);
  border-radius: 10px;
  color: rgba(201, 250, 255, 0.66);
  background: rgba(5, 13, 19, 0.62);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 8px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.render-stats[hidden] {
  display: none;
}

.render-stats b {
  color: var(--cyan);
  font-variant-numeric: tabular-nums;
}

.stage-status {
  position: absolute;
  z-index: 8;
  bottom: 20px;
  left: max(20px, env(safe-area-inset-left));
  display: flex;
  gap: 8px;
  align-items: center;
  color: rgba(206, 196, 225, 0.45);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 8px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  pointer-events: none;
}

.status-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #6dffb2;
  box-shadow: 0 0 9px rgba(109, 255, 178, 0.64);
}

.status-divider {
  width: 1px;
  height: 9px;
  background: rgba(255, 255, 255, 0.12);
}

.webgl-error {
  position: absolute;
  z-index: 40;
  top: 50%;
  left: 45%;
  width: min(420px, calc(100vw - 32px));
  padding: 24px;
  border: 1px solid rgba(255, 128, 158, 0.28);
  border-radius: var(--radius-lg);
  background: var(--panel-strong);
  box-shadow: var(--shadow);
  text-align: center;
  transform: translate(-50%, -50%);
}

.webgl-error[hidden] {
  display: none;
}

.webgl-error strong {
  font-size: 18px;
}

.webgl-error p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.webgl-error button {
  min-height: 42px;
  padding: 0 18px;
  border: 0;
  border-radius: 12px;
  color: #100a1c;
  background: var(--accent-bright);
  font-weight: 750;
}

.control-panel {
  position: fixed;
  z-index: 25;
  top: calc(var(--topbar-height) + 10px);
  right: max(14px, env(safe-area-inset-right));
  bottom: max(14px, env(safe-area-inset-bottom));
  display: flex;
  width: min(var(--panel-width), calc(100vw - 28px));
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(145deg, rgba(181, 156, 255, 0.045), transparent 30%),
    var(--panel);
  box-shadow: var(--shadow), inset 0 1px rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(28px) saturate(130%);
  -webkit-backdrop-filter: blur(28px) saturate(130%);
  pointer-events: auto;
  transform: translateX(0);
  transition: transform 360ms var(--ease), opacity 220ms ease;
}

.control-panel[data-open="false"] {
  opacity: 0;
  pointer-events: none;
  transform: translateX(calc(100% + 24px));
}

.panel-header {
  display: flex;
  flex: 0 0 auto;
  align-items: flex-start;
  justify-content: space-between;
  padding: 21px 20px 16px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--cyan);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.panel-header h1,
.dialog-header h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 640;
  letter-spacing: -0.025em;
}

.panel-close {
  width: 34px;
  min-height: 34px;
  padding: 0;
  color: var(--muted);
  font-size: 20px;
}

#controlsForm {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  scrollbar-color: rgba(181, 156, 255, 0.24) transparent;
  scrollbar-width: thin;
}

#controlsForm::-webkit-scrollbar {
  width: 5px;
}

#controlsForm::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(181, 156, 255, 0.22);
}

.control-section {
  border-bottom: 1px solid var(--line);
}

.section-heading {
  display: flex;
  width: 100%;
  min-height: 47px;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  border: 0;
  color: #eee8f8;
  background: transparent;
  font-size: 11px;
  font-weight: 720;
  letter-spacing: 0.08em;
  text-align: left;
  text-transform: uppercase;
}

.section-heading:hover {
  background: rgba(255, 255, 255, 0.025);
}

.section-heading b {
  margin-right: 9px;
  color: var(--faint);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 8px;
}

.section-heading > span:last-child {
  color: var(--faint);
  transition: transform 180ms ease;
}

.section-heading[aria-expanded="false"] > span:last-child {
  transform: rotate(0deg);
}

.section-body {
  display: grid;
  gap: 14px;
  padding: 3px 20px 20px;
}

.section-body[hidden] {
  display: none;
}

.field,
.range-field {
  display: grid;
  gap: 7px;
}

.field-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 10px;
  font-weight: 620;
  letter-spacing: 0.045em;
}

.field-label output {
  color: var(--accent-bright);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9px;
  font-variant-numeric: tabular-nums;
}

select,
input[type="text"] {
  width: 100%;
  min-height: 41px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 11px;
  color: #eee8f8;
  background: rgba(255, 255, 255, 0.045);
  font-size: 11px;
  transition: border-color 160ms ease, background 160ms ease;
}

select:hover,
input[type="text"]:hover {
  border-color: rgba(181, 156, 255, 0.32);
  background: rgba(255, 255, 255, 0.065);
}

select {
  padding-right: 34px;
}

.custom-glyph-field small {
  color: var(--faint);
  font-size: 9px;
  line-height: 1.45;
}

.color-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.color-row label {
  display: grid;
  gap: 6px;
  color: var(--faint);
  font-size: 8px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

input[type="color"] {
  width: 100%;
  height: 38px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
}

input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

input[type="color"]::-webkit-color-swatch {
  border: 0;
  border-radius: 7px;
}

input[type="color"]::-moz-color-swatch {
  border: 0;
  border-radius: 7px;
}

.range-field input[type="range"] {
  width: 100%;
  height: 18px;
  margin: 0;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
}

.range-field input[type="range"]::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(181, 156, 255, 0.76), rgba(77, 248, 255, 0.34));
}

.range-field input[type="range"]::-moz-range-track {
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(181, 156, 255, 0.76), rgba(77, 248, 255, 0.34));
}

.range-field input[type="range"]::-webkit-slider-thumb {
  width: 14px;
  height: 14px;
  margin-top: -5.5px;
  border: 2px solid #181025;
  border-radius: 50%;
  appearance: none;
  -webkit-appearance: none;
  background: var(--accent-bright);
  box-shadow: 0 0 0 2px rgba(181, 156, 255, 0.18), 0 0 14px rgba(181, 156, 255, 0.35);
}

.range-field input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border: 2px solid #181025;
  border-radius: 50%;
  background: var(--accent-bright);
  box-shadow: 0 0 0 2px rgba(181, 156, 255, 0.18);
}

.range-legend {
  display: flex;
  justify-content: space-between;
  color: var(--faint);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 7px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.switch-row {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  min-height: 43px;
}

.switch-row > span {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 3px;
}

.switch-row b {
  color: #ded6ed;
  font-size: 10px;
  font-weight: 640;
}

.switch-row small {
  color: var(--faint);
  font-size: 8px;
  line-height: 1.4;
}

.switch-row input[type="checkbox"] {
  position: relative;
  width: 34px;
  height: 20px;
  flex: 0 0 auto;
  margin: 0;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  appearance: none;
  -webkit-appearance: none;
  background: rgba(255, 255, 255, 0.06);
  transition: background 180ms ease, border-color 180ms ease;
}

.switch-row input[type="checkbox"]::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  content: "";
  background: #8e849f;
  transition: transform 180ms var(--ease), background 180ms ease;
}

.switch-row input[type="checkbox"]:checked {
  border-color: rgba(181, 156, 255, 0.56);
  background: rgba(181, 156, 255, 0.25);
}

.switch-row input[type="checkbox"]:checked::after {
  background: var(--accent-bright);
  box-shadow: 0 0 10px rgba(181, 156, 255, 0.55);
  transform: translateX(14px);
}

.export-options {
  display: grid;
  gap: 8px;
  padding-top: 2px;
}

.compact-switch {
  min-height: 36px;
}

.panel-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 18px 20px 22px;
}

.secondary-button {
  min-height: 40px;
  padding: 0 10px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 650;
  letter-spacing: 0.03em;
}

.panel-footer {
  display: flex;
  min-height: 36px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  border-top: 1px solid var(--line);
  color: rgba(169, 157, 189, 0.48);
  background: rgba(3, 2, 7, 0.24);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 7px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.mobile-dock {
  display: none;
}

.help-dialog {
  width: min(520px, calc(100vw - 28px));
  max-height: calc(100dvh - 32px);
  padding: 0;
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: var(--radius-lg);
  color: var(--ink);
  background:
    linear-gradient(145deg, rgba(181, 156, 255, 0.06), transparent 34%),
    rgba(14, 10, 25, 0.97);
  box-shadow: 0 32px 100px rgba(0, 0, 0, 0.68);
}

.help-dialog::backdrop {
  background: rgba(3, 2, 8, 0.72);
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
}

.help-dialog form {
  padding: 22px;
}

.dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
}

.shortcut-grid {
  display: grid;
  grid-template-columns: minmax(100px, 1fr) auto 22px auto;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 11px;
}

kbd {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  justify-content: center;
  padding: 0 9px;
  border: 1px solid var(--line-bright);
  border-bottom-color: rgba(255, 255, 255, 0.32);
  border-radius: 7px;
  color: #e9e2f5;
  background: rgba(255, 255, 255, 0.055);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9px;
  white-space: nowrap;
}

.dialog-note {
  margin: 24px 0;
  padding: 14px;
  border-left: 2px solid rgba(77, 248, 255, 0.48);
  color: var(--muted);
  background: rgba(77, 248, 255, 0.035);
  font-size: 10px;
  line-height: 1.6;
}

.primary-button {
  width: 100%;
  border: 0;
  color: #0d0817;
  background: linear-gradient(135deg, var(--accent-bright), #8ffbff);
  font-size: 11px;
  font-weight: 760;
}

.toast {
  position: fixed;
  z-index: 100;
  bottom: max(22px, env(safe-area-inset-bottom));
  left: 50%;
  max-width: min(420px, calc(100vw - 28px));
  padding: 11px 16px;
  border: 1px solid rgba(77, 248, 255, 0.26);
  border-radius: 999px;
  color: #dfffff;
  background: rgba(7, 20, 27, 0.92);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
  font-size: 10px;
  font-weight: 620;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, 16px);
  transition: opacity 180ms ease, transform 280ms var(--ease);
}

.toast[data-visible="true"] {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 940px) {
  :root {
    --panel-width: 344px;
  }

  .desktop-action {
    display: none;
  }

  .preset-rail {
    max-width: calc(100vw - 42px);
  }

  .interaction-hint {
    max-width: calc(100vw - 40px);
    transform: translateX(-50%);
  }
}

@media (max-width: 640px) {
  :root {
    --topbar-height: 62px;
  }

  .topbar {
    min-height: var(--topbar-height);
    padding-top: max(8px, env(safe-area-inset-top));
    padding-right: 10px;
    padding-left: 12px;
  }

  .brand-mark {
    width: 36px;
    height: 36px;
    border-radius: 11px;
  }

  .brand-copy small,
  .toolbar .icon-button:not(#playButton):not(#helpButton),
  .controls-button {
    display: none;
  }

  .toolbar {
    gap: 5px;
  }

  .icon-button {
    width: 38px;
    min-height: 38px;
  }

  .preset-rail {
    top: calc(var(--topbar-height) + 14px);
    right: 0;
    left: 0;
    max-width: none;
    padding: 2px 14px 8px;
  }

  .scene-badge,
  .stage-status {
    display: none;
  }

  .stage-glow {
    left: 50%;
    width: 105vw;
  }

  .stage-vignette {
    background: radial-gradient(circle at 50% 46%, transparent 34%, rgba(var(--void-rgb), 0.22) 76%, rgba(var(--void-rgb), 0.52) 100%);
  }

  .interaction-hint {
    bottom: calc(77px + env(safe-area-inset-bottom));
    max-width: calc(100vw - 24px);
    padding-left: 12px;
    font-size: 8px;
    white-space: nowrap;
  }

  .pointer-hint {
    display: none;
  }

  .touch-hint {
    display: inline;
  }

  .render-stats {
    top: 116px;
    left: 14px;
  }

  .control-panel {
    top: auto;
    right: 6px;
    bottom: calc(6px + env(safe-area-inset-bottom));
    left: 6px;
    width: auto;
    max-height: min(82dvh, 720px);
    border-radius: 22px;
    transform: translateY(0);
  }

  .control-panel[data-open="false"] {
    transform: translateY(calc(100% + 18px));
  }

  .panel-header {
    padding: 18px 17px 14px;
  }

  .panel-header::before {
    position: absolute;
    top: 6px;
    left: 50%;
    width: 34px;
    height: 3px;
    border-radius: 99px;
    content: "";
    background: rgba(255, 255, 255, 0.19);
    transform: translateX(-50%);
  }

  .section-heading {
    min-height: 49px;
    padding: 0 17px;
  }

  .section-body {
    gap: 16px;
    padding-right: 17px;
    padding-bottom: 20px;
    padding-left: 17px;
  }

  select,
  input[type="text"] {
    min-height: 44px;
  }

  .switch-row {
    min-height: 46px;
  }

  .panel-actions {
    padding-right: 17px;
    padding-left: 17px;
  }

  .panel-footer {
    padding: 0 17px;
  }

  .mobile-dock {
    position: fixed;
    z-index: 20;
    right: 10px;
    bottom: max(10px, env(safe-area-inset-bottom));
    left: 10px;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    min-height: 57px;
    padding: 5px;
    border: 1px solid rgba(255, 255, 255, 0.11);
    border-radius: 18px;
    background: rgba(12, 8, 22, 0.82);
    box-shadow: 0 18px 45px rgba(0, 0, 0, 0.42);
    backdrop-filter: blur(24px) saturate(130%);
    -webkit-backdrop-filter: blur(24px) saturate(130%);
    transition: transform 300ms var(--ease), opacity 200ms ease;
  }

  body[data-panel-open="true"] .mobile-dock {
    opacity: 0;
    pointer-events: none;
    transform: translateY(120%);
  }

  .mobile-dock button {
    display: flex;
    min-height: 47px;
    flex-direction: column;
    gap: 2px;
    align-items: center;
    justify-content: center;
    padding: 0 2px;
    border: 0;
    color: var(--muted);
    background: transparent;
    box-shadow: none;
    font-size: 8px;
    letter-spacing: 0.04em;
  }

  .mobile-dock button span:first-child {
    color: var(--accent-bright);
    font-size: 16px;
  }

  .help-dialog form {
    padding: 18px;
  }

  .shortcut-grid {
    grid-template-columns: 1fr auto;
  }

  .shortcut-grid span:nth-child(4n + 3),
  .shortcut-grid span:nth-child(4n + 4) {
    display: none;
  }

  .toast {
    bottom: calc(82px + env(safe-area-inset-bottom));
  }
}

@media (max-width: 360px) {
  .brand-copy strong {
    font-size: 13px;
  }

  .brand-copy small {
    display: none;
  }

  .interaction-hint {
    max-width: calc(100vw - 14px);
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .panel-header h1 {
    font-size: 18px;
  }
}

@media (hover: none), (pointer: coarse) {
  button,
  select,
  input {
    -webkit-tap-highlight-color: transparent;
  }

  .touch-hint {
    display: inline;
  }

  .pointer-hint {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

@media (prefers-contrast: more) {
  :root {
    --muted: #d1c8df;
    --faint: #aaa0b9;
    --line: rgba(255, 255, 255, 0.28);
  }

  .control-panel,
  .mobile-dock {
    background: #100b1d;
  }
}

.error-page {
  display: grid;
  min-height: 100%;
  padding: 24px;
  place-items: center;
  overflow: auto;
  background:
    radial-gradient(circle at 50% 40%, rgba(181, 156, 255, 0.13), transparent 34%),
    var(--void);
}

.error-page main {
  width: min(520px, 100%);
  text-align: center;
}

.error-page .brand-mark {
  width: 70px;
  height: 70px;
  margin: 0 auto 28px;
  border-radius: 20px;
  font-size: 15px;
}

.error-page h1 {
  margin: 0 0 14px;
  font-size: clamp(32px, 8vw, 62px);
  letter-spacing: -0.055em;
}

.error-page p:not(.eyebrow) {
  max-width: 440px;
  margin: 0 auto 28px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

.error-page .primary-button {
  display: inline-flex;
  width: auto;
  min-height: 44px;
  align-items: center;
  padding: 0 20px;
  text-decoration: none;
}
