:root {
  --bg: #050507;
  --glass: rgba(13, 13, 19, 0.58);
  --glass-strong: rgba(16, 16, 24, 0.82);
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.18);
  --text: #eeecf4;
  --muted: #9b98aa;
  --faint: #5f5c6e;
  --a1: #c77dff;
  --a2: #4cc9f0;
  --radius: 18px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --display: 'Unbounded', ui-sans-serif, system-ui, sans-serif;
  --ui: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --gutter: 24px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--ui);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button {
  touch-action: manipulation;
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--a2);
  outline-offset: 2px;
}

#gl {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  display: block;
  touch-action: none;
  cursor: crosshair;
}

/* ------------------------------------------------------------------ chrome */

.brand, .toolbar, #panel, #dock {
  transition: opacity 0.7s var(--ease), transform 0.7s var(--ease);
}

body.idle .brand,
body.idle .toolbar,
body.idle #panel,
body.idle #dock { opacity: 0; pointer-events: none; }
body.idle #gl { cursor: none; }
body.idle #dock { transform: translate(-50%, 12px); }

body.ui-hidden .brand,
body.ui-hidden .toolbar,
body.ui-hidden #panel,
body.ui-hidden #dock { opacity: 0; pointer-events: none; }
body.ui-hidden #dock { transform: translate(-50%, 24px); }
body.ui-hidden #gl { cursor: none; }

.glass {
  background: var(--glass);
}

/* ------------------------------------------------------------------- brand */

.brand {
  position: fixed;
  top: calc(var(--gutter) + env(safe-area-inset-top));
  left: calc(var(--gutter) + env(safe-area-inset-left));
  pointer-events: none;
  user-select: none;
  text-shadow: 0 1px 18px rgba(0, 0, 0, 0.55);
}

.wordmark {
  font-family: var(--display);
  font-weight: 700;
  font-size: 22px;
  letter-spacing: -0.02em;
  background: linear-gradient(100deg, var(--a1), var(--a2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 14px color-mix(in srgb, var(--a1) 45%, transparent));
  transition: filter 0.6s;
}

.mode-title {
  margin-top: 18px;
  opacity: 0;
  transform: translateY(8px);
  filter: blur(8px);
}
.mode-title.show {
  animation: title-in 1.1s var(--ease) forwards;
}
@keyframes title-in {
  to { opacity: 1; transform: none; filter: blur(0); }
}
.mode-title h1 {
  margin: 0;
  font-family: var(--display);
  font-weight: 300;
  font-size: clamp(26px, 3.4vw, 44px);
  letter-spacing: -0.02em;
  line-height: 1.05;
}
.mode-title p {
  margin: 8px 0 0;
  color: rgba(238, 236, 244, 0.72);
  font-size: 14px;
}

/* ----------------------------------------------------------------- toolbar */

.toolbar {
  position: fixed;
  top: calc(var(--gutter) + env(safe-area-inset-top));
  right: calc(var(--gutter) + env(safe-area-inset-right));
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 5px;
  border-radius: 999px;
  background: var(--glass);
  border: 1px solid var(--line);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
  z-index: 5;
}

.tool {
  height: 36px;
  min-width: 36px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--muted);
  transition: color 0.2s, background 0.2s;
}
.tool:hover { color: var(--text); background: rgba(255, 255, 255, 0.07); }
.tool svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.tool svg .dot { fill: currentColor; stroke: none; }
.tool[aria-pressed='true'] {
  color: var(--text);
  background: linear-gradient(120deg, color-mix(in srgb, var(--a1) 40%, transparent), color-mix(in srgb, var(--a2) 40%, transparent));
}
.tool-panel { padding: 0 14px 0 11px; font-weight: 500; font-size: 13px; }
body.panel-open .tool-panel { color: var(--text); background: rgba(255, 255, 255, 0.1); }
.tool-sep { width: 1px; height: 20px; background: var(--line); margin: 0 4px; }

/* ------------------------------------------------------------------- panel */

#panel {
  position: fixed;
  top: calc(var(--gutter) + 62px + env(safe-area-inset-top));
  right: calc(var(--gutter) + env(safe-area-inset-right));
  bottom: 132px;
  width: 316px;
  border-radius: var(--radius);
  background: var(--glass);
  border: 1px solid var(--line);
  backdrop-filter: blur(24px) saturate(150%);
  -webkit-backdrop-filter: blur(24px) saturate(150%);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  overflow: hidden;
  z-index: 4;
}
body:not(.panel-open) #panel {
  opacity: 0;
  transform: translateX(24px) scale(0.98);
  pointer-events: none;
}

#panel-body {
  height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 6px 18px 18px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

.group { padding: 14px 0 12px; border-bottom: 1px solid var(--line); }
.group:last-child { border-bottom: 0; }
.group h2 {
  margin: 0 0 12px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.note { margin: 10px 0 0; font-size: 12px; line-height: 1.5; color: var(--muted); }

/* dials */
.dials {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px 2px;
}
.dial {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2px 0 4px;
  border-radius: 12px;
  cursor: ns-resize;
  user-select: none;
  touch-action: none;
}
.dial svg { width: 56px; height: 56px; overflow: visible; }
.dial-face {
  fill: rgba(255, 255, 255, 0.045);
  stroke: rgba(255, 255, 255, 0.1);
  stroke-width: 1;
  transition: fill 0.2s;
}
.dial:hover .dial-face, .dial.active .dial-face { fill: rgba(255, 255, 255, 0.09); }
.dial-track { fill: none; stroke: rgba(255, 255, 255, 0.1); stroke-width: 3; stroke-linecap: round; }
.dial-fill {
  fill: none;
  stroke: var(--a2);
  stroke-width: 3;
  stroke-linecap: round;
  filter: drop-shadow(0 0 4px color-mix(in srgb, var(--a2) 70%, transparent));
}
.dial-tick { stroke: var(--text); stroke-width: 2.2; stroke-linecap: round; }
.dial-label { margin-top: 2px; font-size: 11.5px; color: var(--text); }
.dial-value {
  font-size: 10.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  min-height: 14px;
}
.dial:focus-visible { outline-offset: -2px; }

/* sliders */
.slider { margin-top: 12px; user-select: none; }
.slider-head {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  margin-bottom: 8px;
}
.slider-value { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 11px; }
.slider-track {
  position: relative;
  height: 22px;
  cursor: pointer;
  touch-action: none;
  border-radius: 999px;
}
.slider-track::before {
  content: '';
  position: absolute;
  left: 0; right: 0; top: 50%;
  height: 4px;
  transform: translateY(-50%);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
}
.slider-fill {
  position: absolute;
  top: 50%;
  height: 4px;
  transform: translateY(-50%);
  border-radius: 999px;
  background: linear-gradient(90deg, var(--a1), var(--a2));
  box-shadow: 0 0 10px color-mix(in srgb, var(--a2) 50%, transparent);
}
.slider-thumb {
  position: absolute;
  top: 50%;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transform: translate(-50%, -50%);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
  transition: transform 0.15s var(--ease);
}
.slider.active .slider-thumb, .slider-track:hover .slider-thumb { transform: translate(-50%, -50%) scale(1.15); }

/* palettes */
.palettes {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 5px;
  margin-bottom: 14px;
}
.swatch {
  aspect-ratio: 1;
  border-radius: 50%;
  border: 2px solid transparent;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.15);
  transition: transform 0.2s var(--ease), border-color 0.2s;
}
.swatch:hover { transform: scale(1.12); }
.swatch.on { border-color: #fff; transform: scale(1.12); }

/* -------------------------------------------------------------------- dock */

#dock {
  position: fixed;
  left: 50%;
  bottom: calc(var(--gutter) + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(1060px, calc(100vw - 2 * var(--gutter)));
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px;
  border-radius: 20px;
  background: var(--glass);
  border: 1px solid var(--line);
  backdrop-filter: blur(24px) saturate(150%);
  -webkit-backdrop-filter: blur(24px) saturate(150%);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  z-index: 4;
}

#dock-list {
  flex: 1;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
  padding: 2px;
  mask-image: linear-gradient(90deg, transparent, #000 18px, #000 calc(100% - 18px), transparent);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 18px, #000 calc(100% - 18px), transparent);
}
#dock-list::-webkit-scrollbar { display: none; }

.mode {
  flex: 0 0 auto;
  width: 104px;
  scroll-snap-align: center;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  padding: 5px 5px 7px;
  border-radius: 13px;
  color: var(--muted);
  transition: background 0.25s, color 0.25s;
}
.dock-label:first-child { margin-left: 12px; }
.mode:last-child { margin-right: 12px; }
.dock-label {
  flex: 0 0 auto;
  align-self: stretch;
  display: flex;
  align-items: center;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  padding: 0 4px;
  margin-left: 8px;
  border-right: 1px solid var(--line);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}
.mode:hover { background: rgba(255, 255, 255, 0.06); color: var(--text); }
.mode.on { background: rgba(255, 255, 255, 0.1); color: var(--text); }
.thumb {
  position: relative;
  display: block;
  height: 58px;
  border-radius: 9px;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}
.thumb img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.6s, transform 0.5s var(--ease);
}
.thumb img.loaded { opacity: 1; }
.mode:hover .thumb img { transform: scale(1.06); }
.mode.on .thumb { box-shadow: 0 0 0 2px var(--text), 0 0 18px color-mix(in srgb, var(--a1) 60%, transparent); }
.mode-name {
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
}

.dock-arrow {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--muted);
  transition: background 0.2s, color 0.2s;
}
.dock-arrow:hover { background: rgba(255, 255, 255, 0.08); color: var(--text); }
.dock-arrow svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ------------------------------------------------------------ toast, help */

#toast {
  position: fixed;
  left: 50%;
  bottom: 150px;
  transform: translate(-50%, 10px);
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--glass-strong);
  border: 1px solid var(--line);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  font-size: 13px;
  white-space: nowrap;
  max-width: calc(100vw - 32px);
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s, transform 0.35s var(--ease);
  z-index: 8;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

#help {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 9;
}
#help[hidden] { display: none; }
.help-card {
  width: min(440px, 100%);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  padding: 26px 26px 22px;
  border-radius: 22px;
  background: var(--glass-strong);
  border: 1px solid var(--line);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}
.help-card h2 { margin: 0 0 16px; font-family: var(--display); font-weight: 500; font-size: 20px; }
.help-card dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 9px 18px;
  margin: 0 0 18px;
  font-size: 13px;
}
.help-card dt { white-space: nowrap; color: var(--muted); }
.help-card dd { margin: 0; }
.help-card p { color: var(--muted); font-size: 13px; line-height: 1.55; margin: 0 0 12px; }
kbd {
  display: inline-block;
  min-width: 22px;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line-strong);
  font-family: var(--ui);
  font-size: 11.5px;
  text-align: center;
  color: var(--text);
}

.pill {
  margin-top: 6px;
  padding: 10px 20px;
  border-radius: 999px;
  background: #fff;
  color: #0a0a0f;
  font-weight: 600;
  font-size: 13px;
  transition: transform 0.2s var(--ease), box-shadow 0.3s;
}
.pill:hover { transform: translateY(-1px); box-shadow: 0 8px 30px color-mix(in srgb, var(--a1) 55%, transparent); }

/* ------------------------------------------------------------------ splash */

#splash {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: radial-gradient(ellipse at center, rgba(5, 5, 7, 0.35), rgba(5, 5, 7, 0.85));
  backdrop-filter: blur(26px) saturate(160%);
  -webkit-backdrop-filter: blur(26px) saturate(160%);
  z-index: 10;
  transition: opacity 0.9s var(--ease), backdrop-filter 0.9s var(--ease), -webkit-backdrop-filter 0.9s var(--ease);
}
#splash.gone {
  opacity: 0;
  backdrop-filter: blur(0);
  -webkit-backdrop-filter: blur(0);
  pointer-events: none;
}
.splash-inner { text-align: center; animation: rise 1.4s var(--ease) both; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); filter: blur(10px); } }
.splash-mark {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(72px, 16vw, 168px);
  letter-spacing: -0.05em;
  line-height: 1;
  background: linear-gradient(100deg, var(--a1), var(--a2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 40px color-mix(in srgb, var(--a1) 50%, transparent));
}
.splash-line { margin: 18px 0 28px; font-size: 16px; color: rgba(238, 236, 244, 0.85); }
.pill-big { padding: 14px 38px; font-size: 15px; }
.splash-warn { margin: 28px 0 0; font-size: 12px; color: var(--muted); }

#nogl, #nojs {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
  line-height: 1.6;
  color: var(--muted);
  background: var(--bg);
  z-index: 20;
}
#nogl[hidden] { display: none; }
#nogl p { max-width: 420px; }

/* ------------------------------------------------------------------ mobile */

@media (max-width: 760px) {
  :root { --gutter: 12px; }
  .wordmark { font-size: 18px; }
  .mode-title { margin-top: 10px; }
  .mode-title p { font-size: 12.5px; }
  .toolbar { top: auto; right: 50%; transform: translateX(50%); bottom: calc(118px + env(safe-area-inset-bottom)); }
  body.idle .toolbar, body.ui-hidden .toolbar { transform: translateX(50%); }
  .tool { height: 34px; min-width: 34px; }
  .tool-panel span { display: none; }
  .tool-panel { padding: 0; }
  #btn-full, #btn-help { display: none; }
  #panel {
    top: auto;
    left: 12px;
    right: 12px;
    width: auto;
    bottom: calc(166px + env(safe-area-inset-bottom));
    height: 52dvh;
  }
  body:not(.panel-open) #panel { transform: translateY(16px); }
  .mode { width: 84px; }
  .thumb { height: 48px; }
  .dock-arrow { display: none; }
  #toast { bottom: calc(220px + env(safe-area-inset-bottom)); }
}

@media (max-width: 380px) {
  .tool-sep { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .mode-title.show, .splash-inner { animation-duration: 0.01s; }
}

/* ------------------------------------------------------------ sound, tour */

#btn-sound .mute { display: none; }
#btn-sound[aria-pressed='false'] .wave { display: none; }
#btn-sound[aria-pressed='false'] .mute { display: inline; }
#btn-sound[aria-pressed='true'] { background: none; color: var(--muted); }
#btn-sound[aria-pressed='true']:hover { color: var(--text); background: rgba(255, 255, 255, 0.07); }

/* the way back after hiding everything */
.show-ui {
  position: fixed;
  right: calc(16px + env(safe-area-inset-right));
  bottom: calc(16px + env(safe-area-inset-bottom));
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: none;
  place-items: center;
  background: rgba(10, 10, 16, 0.4);
  border: 1px solid var(--line);
  color: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  opacity: 0.35;
  transition: opacity 0.3s;
  z-index: 6;
}
.show-ui:hover, .show-ui:focus-visible { opacity: 1; }
.show-ui svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }
body.ui-hidden .show-ui { display: grid; }

@media (pointer: coarse) {
  .dial svg { width: 60px; height: 60px; }
  .slider-track { height: 30px; }
  .slider-thumb { width: 22px; height: 22px; }
}
