:root {
  --glass: rgba(14, 18, 26, 0.36);
  --glass-hi: rgba(255, 255, 255, 0.14);
  --line: rgba(255, 255, 255, 0.09);
  --fg: rgba(255, 255, 255, 0.94);
  --dim: rgba(255, 255, 255, 0.56);
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --btn: 44px;
  --bottom: max(18px, calc(env(safe-area-inset-bottom) + 8px));
  --blur: blur(24px) saturate(1.4);
}

html, body { height: 100%; margin: 0; overflow: hidden; }

body {
  background: #0b0f14 center / cover no-repeat;
  image-rendering: pixelated;
  color: var(--fg);
  font: 500 12px/1.2 ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

body.idle { cursor: none; }

/* Large-viewport height so the scene also runs behind Safari's collapsing toolbars. */
canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  height: 100lvh;
  display: block;
  opacity: 0;
  transition: opacity 1.4s var(--ease);
}
canvas.ready { opacity: 1; }

button { font: inherit; }

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.start {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  color: #fff;
  cursor: pointer;
  outline: none;
  transition: opacity 0.7s var(--ease);
}
.orb {
  position: relative;
  width: 112px;
  height: 112px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  box-shadow: 0 24px 60px -24px rgba(0, 0, 0, 0.6);
  transition: scale 0.7s var(--ease), background 0.4s;
}
.orb svg { width: 38px; height: 38px; fill: currentColor; stroke: none; translate: 2px 0; }
.orb::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  border: 1px solid rgba(255, 255, 255, 0.4);
  animation: ripple 3.6s var(--ease) infinite;
}
.start:hover .orb { background: rgba(255, 255, 255, 0.16); scale: 1.04; }
.start:active .orb { scale: 0.97; }
.start:focus-visible .orb { outline: 2px solid rgba(255, 255, 255, 0.7); outline-offset: 6px; }
.started .start { opacity: 0; pointer-events: none; }
.started .orb { scale: 1.3; }

@keyframes ripple {
  from { scale: 1; opacity: 0.6; }
  to { scale: 1.6; opacity: 0; }
}

.ui { position: fixed; inset: 0; pointer-events: none; }

.dock, .mixer {
  position: fixed;
  left: 50%;
  background: var(--glass);
  border: 1px solid var(--line);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  box-shadow: 0 16px 48px -16px rgba(0, 0, 0, 0.5);
}

.dock {
  bottom: var(--bottom);
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
  border-radius: 999px;
  translate: -50% 0;
  pointer-events: auto;
  transition: opacity 0.8s var(--ease), translate 0.8s var(--ease);
}

.caption {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 28px);
  left: 0;
  right: 0;
  margin: 0;
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.85);
  text-shadow: 0 1px 14px rgba(0, 0, 0, 0.45);
  opacity: 0;
  translate: 0 -6px;
  transition: opacity 1.2s var(--ease), translate 1.2s var(--ease);
}
.caption.show { opacity: 1; translate: 0 0; }

body:not(.started) .dock,
.idle .dock { opacity: 0; translate: -50% 16px; pointer-events: none; }
.started .dock { transition-delay: 0.25s; }
.started.idle .dock { transition-delay: 0s; }
.idle .caption { opacity: 0; }

.btn, .seg button {
  position: relative;
  width: var(--btn);
  height: var(--btn);
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--dim);
  cursor: pointer;
  transition: color 0.3s, background 0.3s;
}
.btn:hover, .seg button:hover, .seg button[aria-checked="true"] { color: var(--fg); }
.btn:hover { background: rgba(255, 255, 255, 0.06); }
.btn:focus-visible, .seg button:focus-visible { outline: 2px solid rgba(255, 255, 255, 0.6); outline-offset: -3px; }

#toggle .i-play, .paused #toggle .i-pause { display: none; }
.paused #toggle .i-play { display: block; }
#mix[aria-expanded="true"] { color: var(--fg); background: var(--glass-hi); }

.seg { position: relative; display: flex; }
.seg::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: var(--btn);
  height: var(--btn);
  border-radius: 999px;
  background: var(--glass-hi);
  translate: calc(var(--i, 0) * 100%) 0;
  transition: translate 0.6s var(--ease);
}

.sep { width: 1px; height: 20px; margin: 0 4px; background: var(--line); }

.mixer {
  bottom: calc(var(--bottom) + var(--btn) + 22px);
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px 18px 14px;
  border-radius: 24px;
  opacity: 0;
  translate: -50% 12px;
  scale: 0.97;
  transform-origin: 50% 100%;
  transition: opacity 0.45s var(--ease), translate 0.6s var(--ease), scale 0.6s var(--ease);
}
.mixer.open { opacity: 1; translate: -50% 0; scale: 1; pointer-events: auto; }
.idle .mixer { opacity: 0; }

.groups { display: flex; gap: 14px; }
.about { margin: 0; padding-bottom: 8px; border-bottom: 1px solid var(--line); text-align: right; font-size: 10px; color: var(--dim); letter-spacing: 0.02em; }
.about a { color: var(--fg); text-decoration: none; }
.about a:hover, .about a:focus-visible { text-decoration: underline; outline: none; }

.group { display: flex; flex-direction: column; }
.group + .group { padding-left: 14px; border-left: 1px solid var(--line); }

h2 {
  margin: 0 0 14px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--dim);
}

.faders { display: flex; gap: 8px; }

.fader {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 46px;
}

/* Fill painted as a hard-stop background on the track itself: no clipped child, which iOS Safari can drop inside glass. */
@property --v { syntax: "<number>"; inherits: true; initial-value: 0; }

.track {
  --rail: rgba(255, 255, 255, 0.08);
  position: relative;
  width: 32px;
  height: clamp(96px, 17vh, 150px);
  border-radius: 12px;
  background: linear-gradient(to top, #d3d9e0 calc(var(--v) * 100%), var(--rail) 0);
  touch-action: none;
  cursor: ns-resize;
  outline: none;
  transition: --v 0.2s var(--ease), box-shadow 0.3s;
}
.track:hover, .active .track { --rail: rgba(255, 255, 255, 0.11); }
.active .track { transition: box-shadow 0.3s; }
.track:focus-visible { box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.6); }

.label {
  font-size: 11px;
  color: var(--dim);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  transition: color 0.3s;
}
.active .label { color: var(--fg); }

@media (max-width: 480px) {
  :root { --btn: 38px; }
  .dock { gap: 0; }
  .sep { margin: 0 2px; }
  .mixer { left: 12px; right: 12px; translate: 0 12px; padding: 12px 10px; }
  .groups { justify-content: space-between; gap: 0; }
  .about { padding-right: 4px; }
  .mixer.open { translate: 0 0; }
  .group + .group { padding-left: 8px; margin-left: 8px; }
  .faders { gap: 0; }
  .fader { width: 42px; }
  .track { width: 28px; height: clamp(84px, 12vh, 120px); }
  .label { font-size: 10px; }
  h2 { padding-left: 7px; }
}

/* Desktop: the mixer opens beside the toolbar, bottoms aligned, whenever there is room. */
.side .mixer { left: var(--x); bottom: var(--bottom); translate: 0 12px; transform-origin: 0 100%; }
.side .mixer.open { translate: 0 0; }

@media (prefers-reduced-motion: reduce) {
  *, ::before { transition-duration: 0.01s !important; animation: none !important; }
}
