html,
body {
  margin: 0;
  min-height: 100%;
  background: #000;
}

body {
  min-height: 100svh;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: #f4fbff;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

canvas {
  width: min(1024px, 100vmin);
  height: min(1024px, 100vmin);
  display: block;
}

.controls-shell {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 10;
  display: flex;
  align-items: flex-start;
  gap: 0;
  transform: translateX(0);
  transition: transform 260ms ease;
}

.controls-shell.is-collapsed {
  transform: translateX(calc(100% - 28px));
}

.controls-toggle {
  width: 28px;
  height: 36px;
  display: grid;
  place-items: center;
  margin: 30px 0 0;
  padding: 0;
  border: 1px solid rgba(130, 255, 236, 0.24);
  border-right: 0;
  border-radius: 12px 0 0 12px;
  background: rgba(4, 10, 14, 0.72);
  box-shadow:
    0 0 18px rgba(0, 255, 210, 0.10),
    inset 0 0 14px rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(14px);
  cursor: pointer;
  transition:
    border-color 180ms ease,
    box-shadow 180ms ease,
    transform 220ms ease;
}

.controls-toggle:hover {
  border-color: rgba(244, 251, 255, 0.42);
  box-shadow:
    0 0 18px rgba(32, 255, 202, 0.18),
    inset 0 0 14px rgba(255, 255, 255, 0.06);
}

.controls-toggle:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.78);
  outline-offset: 3px;
}

.controls-toggle-icon {
  width: 0;
  height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 9px solid rgba(244, 251, 255, 0.86);
  filter: drop-shadow(0 0 8px rgba(32, 255, 202, 0.35));
  transition: transform 220ms ease;
}

.controls-shell.is-collapsed .controls-toggle-icon {
  transform: rotate(180deg);
}

.visual-controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: stretch;
  margin: 0;
  padding: 12px;
  border: 1px solid rgba(130, 255, 236, 0.24);
  border-left-color: rgba(130, 255, 236, 0.18);
  border-radius: 24px;
  background: rgba(4, 10, 14, 0.72);
  box-shadow:
    0 0 24px rgba(0, 255, 210, 0.12),
    inset 0 0 18px rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(14px);
  opacity: 1;
  transition: opacity 180ms ease;
}

.controls-shell.is-collapsed .visual-controls {
  pointer-events: none;
  opacity: 0;
}

.toggle-row {
  display: grid;
  grid-template-columns: repeat(2, max-content);
  gap: 12px;
  align-items: center;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 28px;
  cursor: pointer;
  user-select: none;
}

.toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle-switch {
  position: relative;
  width: 40px;
  height: 22px;
  flex: 0 0 auto;
  border: 1px solid rgba(244, 251, 255, 0.24);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.42);
  transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.toggle-switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #d7e5eb;
  box-shadow: 0 0 10px rgba(215, 229, 235, 0.32);
  transition: transform 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.toggle input:checked + .toggle-switch {
  border-color: rgba(243, 243, 243, 0.7);
  background: linear-gradient(90deg, rgba(32, 255, 202, 0.42), rgba(255, 73, 226, 0.46));
  box-shadow:
    0 0 16px rgba(255, 73, 226, 0.24),
    inset 0 0 10px rgba(255, 255, 255, 0.16);
}

.toggle input:checked + .toggle-switch::after {
  transform: translateX(18px);
  background: #fff;
  box-shadow: 0 0 14px rgba(255, 255, 255, 0.76);
}

.toggle input:focus-visible + .toggle-switch {
  outline: 2px solid rgba(255, 255, 255, 0.78);
  outline-offset: 3px;
}

.toggle-text {
  color: rgba(244, 251, 255, 0.82);
  font-size: 12px;
  line-height: 1;
  letter-spacing: 0;
}

.slider {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;    /* pushes the whole group right */
}

.slider-text {
  color: rgba(244, 251, 255, 0.82);
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
}

.slider input[type="range"] {
  --progress: 50%;
  appearance: none;
  -webkit-appearance: none;
  width: 120px;
  height: 22px;
  background: transparent;
  cursor: pointer;
}

/* ---------- Track ---------- */

.slider input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  border: 1px solid rgba(244, 251, 255, 0.18);
  background:
    linear-gradient(
      90deg,
      rgba(44, 116, 255, 0.70) 0%,
      rgba(44, 116, 255, 0.70) var(--progress),
      rgba(255,255,255,0.08) var(--progress),
      rgba(255,255,255,0.08) 100%
    );
  box-shadow:
    inset 0 0 10px rgba(0,0,0,0.42),
    0 0 8px rgba(44,116,255,0.18);
}

.slider input[type="range"]::-moz-range-track {
  height: 6px;
  border-radius: 999px;
  border: 1px solid rgba(244, 251, 255, 0.18);
  background: rgba(255,255,255,0.08);
  box-shadow:
    inset 0 0 10px rgba(0,0,0,0.42),
    0 0 8px rgba(44,116,255,0.18);
}

.slider input[type="range"]::-moz-range-progress {
  height: 6px;
  border-radius: 999px;
  background: rgba(44,116,255,0.70);
}

/* ---------- Thumb ---------- */

.slider input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  margin-top: -6px;
  width: 16px;
  height: 16px;
  border: 1px solid rgba(255,255,255,0.55);
  border-radius: 50%;
  background: #d7e5eb;
  box-shadow:
    0 0 12px rgba(215,229,235,0.35),
    0 0 18px rgba(44,116,255,0.25);
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

.slider input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: 1px solid rgba(255,255,255,0.55);
  border-radius: 50%;
  background: #d7e5eb;
  box-shadow:
    0 0 12px rgba(215,229,235,0.35),
    0 0 18px rgba(44,116,255,0.25);
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

/* ---------- Hover ---------- */

.slider input[type="range"]:hover::-webkit-slider-thumb,
.slider input[type="range"]:hover::-moz-range-thumb {
  transform: scale(1.08);
  box-shadow:
    0 0 18px rgba(44,116,255,0.45),
    0 0 24px rgba(32,255,202,0.18);
}

/* ---------- Active ---------- */

.slider input[type="range"]:active::-webkit-slider-thumb,
.slider input[type="range"]:active::-moz-range-thumb {
  transform: scale(1.14);
  background: #fff;
  box-shadow:
    0 0 18px rgba(255,255,255,0.8),
    0 0 26px rgba(44,116,255,0.45);
}

/* ---------- Focus ---------- */

.slider input[type="range"]:focus-visible {
  outline: none;
}

.slider input[type="range"]:focus-visible::-webkit-slider-runnable-track,
.slider input[type="range"]:focus-visible::-moz-range-track {
  border-color: rgba(243,243,243,0.7);
}

@media (max-width: 560px) {
  .controls-shell {
    top: 10px;
    right: 10px;
  }

  .visual-controls {
    border-radius: 20px;
  }

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