/* ==========================================================================
   Sploonkie Sounds — Standalone Ambient Instrument Styles
   Native dark OLED atmospheres, matte recessed wells, hairline orbital glow
   ========================================================================== */

:root {
  --font-sans: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Segoe UI', system-ui, sans-serif;

  /* Focus defaults (warm amber/gold over obsidian charcoal — never brown smog) */
  --bg-0: #0a0a0c;
  --accent: #f5b971;
  --accent-rgb: 245, 185, 113;
  --accent-soft: #ffd7a8;

  --surface-glass: rgba(14, 15, 20, 0.76);
  --surface-well: rgba(6, 7, 11, 0.56);
  --surface-tile: rgba(255, 255, 255, 0.04);
  --surface-tile-hover: rgba(255, 255, 255, 0.08);
  --hairline: rgba(255, 255, 255, 0.085);
  --hairline-strong: rgba(255, 255, 255, 0.16);

  --text: #f3f5fa;
  --muted: rgba(235, 240, 250, 0.64);
  --muted-2: rgba(220, 226, 240, 0.42);
  --danger: #f87171;

  --radius-card: 24px;
  --radius-strip: 16px;
  --radius-well: 13px;
  --radius-pill: 999px;
  --tap: 48px;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

body[data-mode="focus"] {
  --bg-0: #0a0a0c;
  --accent: #f5b971;
  --accent-rgb: 245, 185, 113;
  --accent-soft: #ffd7a8;
}

body[data-mode="relax"] {
  --bg-0: #060c10;
  --accent: #5eead4;
  --accent-rgb: 94, 234, 212;
  --accent-soft: #a5f3fc;
}

body[data-mode="sleep"] {
  --bg-0: #030408;
  --accent: #818cf8;
  --accent-rgb: 129, 140, 248;
  --accent-soft: #a5b4fc;
}

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

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  background: var(--bg-0);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 280ms var(--ease-out);
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

button:focus-visible,
a:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.vh {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Full-bleed orbital + ambient canvas */
#ambient-stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
  pointer-events: none;
}

.noscript-note {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  margin: 0;
  padding: 10px 16px;
  border-radius: 12px;
  background: rgba(10, 12, 18, 0.92);
  border: 1px solid var(--hairline-strong);
}

/* Global floating toast — always visible regardless of drawer/tab state */
.app-toast {
  position: fixed;
  left: 50%;
  top: calc(max(12px, env(safe-area-inset-top)) + 54px);
  transform: translateX(-50%);
  z-index: 70;
  max-width: min(360px, calc(100vw - 32px));
  padding: 9px 16px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(var(--accent-rgb), 0.34);
  background: rgba(10, 12, 18, 0.88);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}

/* App Shell */
.app-shell {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100dvh;
  margin: 0 auto;
  padding-top: max(12px, env(safe-area-inset-top));
  padding-bottom: max(14px, env(safe-area-inset-bottom));
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Minimal Top Chrome */
.top-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  z-index: 5;
}

.top-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.back-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: var(--muted);
  text-decoration: none;
  background: rgba(255, 255, 255, 0.04);
  transition: color 180ms ease, background-color 180ms ease;
}

.back-link:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.1);
}

.brand-name {
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 40px;
  min-height: 40px;
  padding: 0 10px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--hairline);
  background: rgba(255, 255, 255, 0.045);
  color: var(--muted);
  cursor: pointer;
  transition: color 180ms ease, background-color 180ms ease, border-color 180ms ease, transform 120ms ease;
}

.icon-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.09);
  border-color: var(--hairline-strong);
}

.icon-btn:active {
  transform: scale(0.95);
}

.icon-btn-sm {
  min-width: 34px;
  min-height: 34px;
  padding: 0 8px;
}

/* Single persistent Mute button */
.mute-btn .icon-vol-off,
.mute-btn .mute-badge-text {
  display: none;
}

.mute-btn.is-muted {
  padding: 0 12px;
  border-color: rgba(var(--accent-rgb), 0.45);
  background: rgba(var(--accent-rgb), 0.16);
  color: var(--accent-soft);
  font-size: 12.5px;
  font-weight: 500;
}

.mute-btn.is-muted .icon-vol-on {
  display: none;
}

.mute-btn.is-muted .icon-vol-off,
.mute-btn.is-muted .mute-badge-text {
  display: inline-block;
}

.desktop-only-btn,
.studio-reopen-btn {
  display: none;
}

/* Workspace & Centered Focal Stage */
.workspace {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
}

.hero-stage {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding-bottom: 112px; /* clear unified bottom dock */
}

.hero {
  width: 100%;
  max-width: 440px;
  margin: auto 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 20px;
}

.hero-copy {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  transition: opacity 250ms var(--ease-out), transform 250ms var(--ease-out);
}

.hero-copy.is-switching {
  animation: hero-fade 260ms var(--ease-out);
}

@keyframes hero-fade {
  0% {
    opacity: 0.45;
    transform: translateY(4px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.mode-heading {
  margin: 0;
  font-size: clamp(32px, 6.8vw, 44px);
  font-weight: 300;
  letter-spacing: -0.025em;
  line-height: 1.08;
  color: var(--text);
}

.mode-summary {
  margin: 0;
  font-size: 14.5px;
  font-weight: 400;
  color: var(--muted);
}

.active-recipe {
  margin: 3px 0 0;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.045);
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

/* Tactile Play/Pause Centerpiece inside Orbital Halo */
.play-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 22px 0 18px;
}

.play-btn {
  position: relative;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  border: 1.5px solid rgba(var(--accent-rgb), 0.36);
  background: radial-gradient(
    circle at 32% 28%,
    rgba(255, 255, 255, 0.11),
    rgba(10, 12, 18, 0.72) 74%
  );
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    0 12px 38px rgba(0, 0, 0, 0.52),
    0 0 36px rgba(var(--accent-rgb), 0.14);
  transition:
    transform 180ms var(--ease-out),
    border-color 250ms ease,
    box-shadow 300ms ease;
}

.play-btn:hover {
  transform: scale(1.03);
  border-color: rgba(var(--accent-rgb), 0.65);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.2),
    0 16px 42px rgba(0, 0, 0, 0.58),
    0 0 46px rgba(var(--accent-rgb), 0.24);
}

.play-btn:active {
  transform: scale(0.95);
}

.play-btn .icon-play {
  transform: translateX(2px);
}

.play-btn .icon-pause {
  display: none;
}

.play-btn.is-playing {
  border-color: rgba(var(--accent-rgb), 0.68);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    0 16px 46px rgba(0, 0, 0, 0.56),
    0 0 54px rgba(var(--accent-rgb), 0.28);
}

.play-btn.is-playing .icon-play {
  display: none;
}

.play-btn.is-playing .icon-pause {
  display: block;
}

.hero-status-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

/* Unified Timer Capsule */
.timer-chip {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 40px;
  padding: 0 16px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--hairline);
  background: rgba(14, 16, 22, 0.56);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: color 200ms ease, border-color 200ms ease, background-color 200ms ease, transform 120ms ease;
}

.timer-chip:hover {
  color: var(--text);
  border-color: var(--hairline-strong);
  background: rgba(255, 255, 255, 0.08);
}

.timer-chip:active {
  transform: scale(0.97);
}

.timer-chip.is-active {
  color: var(--accent-soft);
  border-color: rgba(var(--accent-rgb), 0.44);
  background: rgba(var(--accent-rgb), 0.13);
}

.timer-chip svg {
  color: var(--accent);
  flex-shrink: 0;
}

.lockscreen-hero-status {
  margin: 0;
  font-size: 12px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--accent-soft);
  min-height: 18px;
}

/* ---------- Unified Mode & Scenes Dock (Phone Bottom <700px) ---------- */

.mode-dock {
  position: fixed;
  left: max(12px, env(safe-area-inset-left));
  right: max(12px, env(safe-area-inset-right));
  bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 15;
  display: flex;
  flex-direction: column-reverse;
  border-radius: 22px;
  background: rgba(10, 12, 18, 0.82);
  backdrop-filter: blur(26px) saturate(140%);
  -webkit-backdrop-filter: blur(26px) saturate(140%);
  border: 1px solid rgba(var(--accent-rgb), 0.22);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 14px 36px rgba(0, 0, 0, 0.5),
    0 0 24px rgba(var(--accent-rgb), 0.07);
  overflow: hidden;
  transition: border-color 260ms var(--ease-out), box-shadow 260ms var(--ease-out);
}

.mode-dock-primary {
  display: flex;
  align-items: stretch;
  gap: 4px;
  padding: 4px;
}

.mode-switcher {
  position: static;
  flex: 1 1 auto;
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 3px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  box-shadow: none;
}

.mode-btn {
  appearance: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 46px;
  padding: 4px 2px;
  border: 0;
  border-radius: 16px;
  background: transparent;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  transition: color 200ms ease, background-color 200ms ease, box-shadow 200ms ease, transform 120ms ease;
}

.mode-btn:hover {
  color: var(--text);
}

.mode-btn.is-active {
  color: var(--accent-soft);
  background: rgba(var(--accent-rgb), 0.16);
  box-shadow: inset 0 0 0 1px rgba(var(--accent-rgb), 0.26);
}

.dock-mix-btn {
  appearance: none;
  flex: 0 0 auto;
  min-width: 86px;
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 12px;
  border-radius: 16px;
  border: 1px solid rgba(var(--accent-rgb), 0.24);
  background: rgba(var(--accent-rgb), 0.09);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: none;
  transition: background-color 180ms ease, border-color 180ms ease, transform 120ms ease;
}

.dock-mix-btn:hover {
  background: rgba(var(--accent-rgb), 0.16);
  border-color: rgba(var(--accent-rgb), 0.48);
}

.dock-mix-btn:active {
  transform: scale(0.96);
}

.dock-mix-btn svg {
  color: var(--accent);
}

/* Attached Mode Scenes Tier */
.stage-scenes {
  width: 100%;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-bottom: 1px solid rgba(var(--accent-rgb), 0.14);
  background: rgba(var(--accent-rgb), 0.04);
  overflow-x: auto;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.stage-scenes::-webkit-scrollbar {
  display: none;
}

.stage-scenes > :first-child {
  margin-left: auto;
}

.stage-scenes > :last-child {
  margin-right: auto;
}

.stage-scenes.is-switching {
  animation: scenes-swap-up 220ms var(--ease-out);
}

@keyframes scenes-swap-up {
  0% {
    opacity: 0.4;
    transform: translateY(3px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes scenes-swap-down {
  0% {
    opacity: 0.4;
    transform: translateY(-3px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.stage-scene-chip {
  appearance: none;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 31px;
  padding: 0 10px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: rgba(255, 255, 255, 0.045);
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: color 180ms ease, border-color 180ms ease, background-color 180ms ease, transform 120ms ease;
}

.stage-scene-chip:hover {
  color: var(--accent-soft);
  border-color: rgba(var(--accent-rgb), 0.34);
  background: rgba(var(--accent-rgb), 0.1);
}

.stage-scene-chip:active {
  transform: scale(0.97);
}

.stage-scene-chip.is-active {
  color: var(--accent-soft);
  border-color: rgba(var(--accent-rgb), 0.48);
  background: rgba(var(--accent-rgb), 0.18);
  box-shadow: inset 0 0 0 1px rgba(var(--accent-rgb), 0.18);
}

.stage-scene-chip svg {
  flex-shrink: 0;
  color: var(--accent);
  opacity: 0.9;
}

.stage-scene-chip.is-active svg {
  opacity: 1;
}

.stage-scene-add {
  min-width: 31px;
  padding: 0 9px;
  justify-content: center;
  border-style: dashed;
  border-color: rgba(255, 255, 255, 0.16);
  color: var(--muted);
}

.stage-scene-add svg {
  color: currentColor;
}

@media (max-width: 380px) {
  .dock-mix-btn {
    min-width: 78px;
    padding: 0 9px;
    font-size: 12.5px;
  }
}

@media (max-height: 700px) {
  .hero {
    gap: 12px;
  }

  .play-wrap {
    margin: 10px 0 6px;
  }

  .play-btn {
    width: 88px;
    height: 88px;
  }
}

.tablet-dock {
  display: none;
}

/* ---------- Backdrop ---------- */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 25;
  background: rgba(3, 4, 9, 0.62);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

/* ---------- Sound Studio Inspector (#controls-panel) ---------- */

.controls-panel {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 35;
  width: 100%;
  max-height: min(88dvh, 720px);
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--hairline-strong);
  border-radius: 24px 24px 0 0;
  background: rgba(11, 13, 19, 0.92);
  backdrop-filter: blur(30px) saturate(140%);
  -webkit-backdrop-filter: blur(30px) saturate(140%);
  box-shadow: 0 -22px 60px rgba(0, 0, 0, 0.64);
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  transform: translateY(104%);
  visibility: hidden;
  pointer-events: none;
  transition: transform 280ms var(--ease-out), visibility 280ms linear;
}

.controls-panel:focus,
.modal-sheet:focus,
.modal-center:focus {
  outline: none;
}

.controls-panel.is-open {
  transform: translateY(0);
  visibility: visible;
  pointer-events: auto;
}

.panel-header {
  flex: 0 0 auto;
  padding: 10px 16px 10px;
  border-bottom: 1px solid var(--hairline);
}

.sheet-header {
  touch-action: none;
  cursor: grab;
}

.sheet-handle {
  display: block;
  width: 38px;
  height: 4px;
  margin: 0 auto 10px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.24);
}

.panel-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.studio-tabs {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 3px;
  padding: 3px;
  border-radius: 12px;
  background: var(--surface-well);
}

.studio-tab {
  appearance: none;
  min-height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: color 180ms ease, background-color 180ms ease;
}

.studio-tab:hover {
  color: var(--text);
}

.studio-tab.is-active {
  background: rgba(var(--accent-rgb), 0.18);
  color: var(--accent-soft);
}

.panel-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 10px 14px;
}

.studio-pane {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Paired Channel Strips inside Mix Tab */
.channel-strip {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 11px;
  border-radius: var(--radius-strip);
  background: rgba(255, 255, 255, 0.032);
  transition: opacity 200ms ease, background-color 200ms ease;
}

.channel-strip.is-inactive .sound-slider,
.channel-strip.is-inactive .slider-label {
  opacity: 0.48;
}

/* Faders & Quiet Hover/Drag Readouts */
.slider-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.slider-row-compact {
  gap: 2px;
}

.slider-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 20px;
}

.slider-head-right {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.slider-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
}

.slider-label svg {
  color: var(--accent);
  flex-shrink: 0;
}

.slider-sub-label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--muted);
}

.slider-val {
  font-size: 11.5px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--accent-soft);
  padding: 1px 7px;
  border-radius: var(--radius-pill);
  background: rgba(var(--accent-rgb), 0.14);
  opacity: 0;
  transform: translateY(1px);
  transition: opacity 180ms ease, transform 180ms ease;
  pointer-events: none;
}

.slider-row.is-dragging .slider-val,
.slider-row:focus-within .slider-val {
  opacity: 1;
  transform: translateY(0);
}

.pad-fade-pill {
  font-size: 11px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--accent-soft);
}

/* Single-accent capsule faders */
.sound-slider {
  --fill: 50%;
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 36px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}

.sound-slider:focus {
  outline: none;
}

.sound-slider:focus-visible::-webkit-slider-thumb {
  box-shadow: 0 0 0 2px var(--bg-0), 0 0 0 4px var(--accent);
}

.sound-slider::-webkit-slider-runnable-track {
  height: 10px;
  border-radius: var(--radius-pill);
  background: linear-gradient(
    90deg,
    rgba(var(--accent-rgb), 0.78) 0%,
    rgba(var(--accent-rgb), 0.78) var(--fill),
    rgba(255, 255, 255, 0.1) var(--fill),
    rgba(255, 255, 255, 0.1) 100%
  );
  transition: opacity 180ms ease;
}

.sound-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 20px;
  margin-top: -5px;
  border-radius: 7px;
  background: #f5f7fc;
  border: 1px solid rgba(0, 0, 0, 0.28);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.55);
  transition: transform 140ms ease, background-color 140ms ease;
}

.sound-slider:hover::-webkit-slider-thumb {
  background: #ffffff;
}

.sound-slider:active::-webkit-slider-thumb {
  transform: scale(1.1);
}

.sound-slider::-moz-range-track {
  height: 10px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.1);
}

.sound-slider::-moz-range-progress {
  height: 10px;
  border-radius: var(--radius-pill);
  background: rgba(var(--accent-rgb), 0.78);
}

.sound-slider::-moz-range-thumb {
  width: 14px;
  height: 20px;
  border-radius: 7px;
  background: #f5f7fc;
  border: 1px solid rgba(0, 0, 0, 0.28);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.55);
}

/* Matte Recessed Control Wells (No Wireframe Boxes!) */
.well-seg {
  display: grid;
  gap: 3px;
  padding: 3px;
  border-radius: var(--radius-well);
  background: var(--surface-well);
}

.well-seg-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.well-seg-5 {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.well-grid-3x2 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  border-radius: var(--radius-well);
  background: var(--surface-well);
}

.well-btn,
.well-icon-btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  min-height: 36px;
  padding: 4px 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 160ms ease, background-color 160ms ease, border-color 160ms ease, transform 120ms ease;
}

.well-icon-btn {
  flex-direction: column;
  gap: 3px;
  min-height: 46px;
  font-size: 11px;
}

.well-btn:hover,
.well-icon-btn:hover {
  color: var(--text);
  background: var(--surface-tile-hover);
}

.well-btn:active,
.well-icon-btn:active {
  transform: scale(0.96);
}

.well-btn.is-active,
.well-icon-btn.is-active {
  background: rgba(var(--accent-rgb), 0.16);
  border-color: rgba(var(--accent-rgb), 0.44);
  color: var(--accent-soft);
}

.well-icon-btn.is-active svg {
  color: var(--accent);
}

.well-btn.is-loading {
  opacity: 0.72;
  animation: chip-pulse 800ms ease-in-out infinite;
}

.well-btn.is-auditioning {
  border-color: rgba(var(--accent-rgb), 0.85);
  box-shadow: 0 0 14px rgba(var(--accent-rgb), 0.24);
}

@keyframes chip-pulse {
  0%, 100% {
    opacity: 0.65;
  }
  50% {
    opacity: 1;
  }
}

/* Lock-screen Switch Row (Mobile & Tablet only) */
.lock-screen-row {
  padding: 10px 12px;
  border-radius: var(--radius-strip);
  background: rgba(255, 255, 255, 0.032);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lock-screen-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.switch-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.switch-title-row {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.switch-title-row svg {
  color: var(--accent);
  flex-shrink: 0;
}

.switch-label {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
}

.switch-sub,
.switch-desc {
  margin: 0;
  font-size: 11.5px;
  line-height: 1.35;
  color: var(--muted);
}

.status-pill {
  padding: 1px 7px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  background: rgba(var(--accent-rgb), 0.16);
  color: var(--accent-soft);
}

.lockscreen-progress-track {
  width: 100%;
  height: 3px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.lockscreen-progress-bar {
  width: 0%;
  height: 100%;
  border-radius: var(--radius-pill);
  background: var(--accent);
  transition: width 160ms linear;
}

/* Switch Control */
.switch-btn {
  position: relative;
  flex: 0 0 auto;
  width: 46px;
  height: 27px;
  padding: 0;
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.11);
  cursor: pointer;
  transition: background-color 220ms ease, border-color 220ms ease;
}

.switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 21px;
  height: 21px;
  border-radius: 50%;
  background: #f5f7fc;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
  transition: transform 220ms var(--ease-out);
}

.switch-btn[aria-checked="true"] {
  background: rgba(var(--accent-rgb), 0.34);
  border-color: rgba(var(--accent-rgb), 0.65);
}

.switch-btn[aria-checked="true"] .switch-thumb {
  transform: translateX(19px);
  background: var(--accent-soft);
}

/* Tone & Scenes Panes */
.pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.pane-label {
  margin: 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}

.text-action-btn {
  appearance: none;
  padding: 4px 10px;
  min-height: 28px;
  border-radius: var(--radius-pill);
  border: 0;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: color 160ms ease, background-color 160ms ease;
}

.text-action-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.12);
}

.text-action-btn.is-accent {
  color: var(--accent-soft);
  background: rgba(var(--accent-rgb), 0.18);
}

.text-action-btn.is-danger {
  color: var(--danger);
  background: rgba(248, 113, 113, 0.12);
}

.tune-row {
  display: grid;
  grid-template-columns: 1fr 1.35fr;
  gap: 10px;
  align-items: end;
}

.tune-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field-caption {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}

.select-input {
  width: 100%;
  min-height: 42px;
  padding: 0 11px;
  border-radius: var(--radius-well);
  border: 0;
  background: var(--surface-well);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}

.macro-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius-strip);
  background: rgba(255, 255, 255, 0.032);
}

/* Scene Cards */
.scene-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.scene-group-label {
  margin: 8px 2px 0;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--muted-2);
}

.scene-card {
  appearance: none;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-strip);
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: background-color 180ms ease, border-color 180ms ease, transform 120ms ease;
}

.scene-card:hover {
  background: var(--surface-tile-hover);
}

.scene-card:active {
  transform: scale(0.985);
}

.scene-card.is-active {
  background: rgba(var(--accent-rgb), 0.14);
  border-color: rgba(var(--accent-rgb), 0.44);
}

.scene-card-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.scene-card-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

.scene-card-recipe {
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.scene-card-tag {
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  flex-shrink: 0;
}

.scene-card.is-active .scene-card-tag {
  background: rgba(var(--accent-rgb), 0.22);
  color: var(--accent-soft);
}

.preset-inline-form {
  display: flex;
  align-items: center;
  gap: 6px;
}

.text-input {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 36px;
  padding: 0 11px;
  border-radius: 10px;
  border: 1px solid var(--hairline);
  background: var(--surface-well);
  color: var(--text);
  font-size: 13px;
}

.preset-manage-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.preset-manage-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
}

.share-scene-btn {
  appearance: none;
  margin-top: 2px;
  width: 100%;
  min-height: 44px;
  padding: 0 14px;
  border-radius: var(--radius-well);
  border: 1px solid rgba(var(--accent-rgb), 0.34);
  background: rgba(var(--accent-rgb), 0.12);
  color: var(--accent-soft);
  font-size: 13px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: background-color 180ms ease, border-color 180ms ease, transform 120ms ease;
}

.share-scene-btn:hover {
  background: rgba(var(--accent-rgb), 0.2);
  border-color: rgba(var(--accent-rgb), 0.56);
}

.share-scene-btn:active {
  transform: scale(0.985);
}

/* Pinned Studio Footer (Master + Auto Mode) */
.panel-footer {
  flex: 0 0 auto;
  padding: 10px 16px 12px;
  border-top: 1px solid var(--hairline);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.auto-footer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* ---------- Unified Timers Dialog & Centered Shortcuts Modal ---------- */

.modal-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 45;
  width: 100%;
  border-top: 1px solid var(--hairline-strong);
  border-radius: 24px 24px 0 0;
  background: rgba(11, 13, 19, 0.94);
  backdrop-filter: blur(30px) saturate(140%);
  -webkit-backdrop-filter: blur(30px) saturate(140%);
  box-shadow: 0 -22px 60px rgba(0, 0, 0, 0.68);
  padding-bottom: max(18px, env(safe-area-inset-bottom));
}

.dialog-title {
  margin: 0;
  font-size: 16px;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.modal-sheet-body {
  padding: 14px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

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

.inline-countdown {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.countdown-text {
  font-size: 13px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--accent-soft);
}

.dialog-hint {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

/* Centered Shortcuts Modal (never overlaps desktop sliders) */
.modal-center {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 50;
  width: min(380px, calc(100vw - 32px));
  padding: 18px 20px;
  border-radius: var(--radius-card);
  border: 1px solid var(--hairline-strong);
  background: rgba(12, 14, 20, 0.94);
  backdrop-filter: blur(30px) saturate(140%);
  -webkit-backdrop-filter: blur(30px) saturate(140%);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.72);
}

.modal-center-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.shortcuts-list {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.shortcut-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}

.shortcut-row dt {
  display: flex;
  align-items: center;
  gap: 4px;
}

.shortcut-row dd {
  margin: 0;
  color: var(--muted);
}

kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 7px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--hairline);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  color: var(--text);
}

/* Touch screens >= 48px primary tap targets on mobile */
@media (max-width: 1023px) {
  .well-btn {
    min-height: 44px;
  }
  .well-icon-btn {
    min-height: 50px;
  }
  .sound-slider {
    height: 42px;
  }
}

/* ---------- Tablet Layout (700px - 1023px: full-width canvas + floating dock + centered dialogs) ---------- */

@media (min-width: 700px) and (max-width: 1023px) {
  .app-shell {
    padding-left: max(24px, env(safe-area-inset-left));
    padding-right: max(24px, env(safe-area-inset-right));
  }

  .app-toast {
    top: calc(max(12px, env(safe-area-inset-top)) + 100px);
  }

  .top-bar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: start;
    gap: 10px;
    min-height: 48px;
  }

  .top-left,
  .top-actions {
    min-height: 44px;
  }

  .top-left {
    justify-self: start;
  }

  .brand-name {
    font-size: 13.5px;
  }

  .top-actions {
    justify-self: end;
  }

  .mode-dock {
    position: static;
    left: auto;
    right: auto;
    bottom: auto;
    justify-self: center;
    flex-direction: column;
    width: fit-content;
    min-width: 332px;
    max-width: min(460px, calc(100vw - 348px));
    border-radius: 22px;
    background: rgba(12, 14, 20, 0.74);
  }

  .dock-mix-btn {
    display: none;
  }

  .mode-dock-primary {
    padding: 4px;
    gap: 0;
  }

  .mode-switcher {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 3px;
  }

  .mode-btn {
    flex-direction: row;
    gap: 6px;
    min-height: 36px;
    padding: 0 12px;
    border-radius: 17px;
    font-size: 13px;
  }

  .stage-scenes {
    border-bottom: 0;
    border-top: 1px solid rgba(var(--accent-rgb), 0.14);
    padding: 5px 7px 6px;
    gap: 5px;
  }

  .stage-scenes.is-switching {
    animation: scenes-swap-down 220ms var(--ease-out);
  }

  .stage-scene-chip {
    min-height: 29px;
    padding: 0 9px;
    font-size: 12px;
  }

  .stage-scene-add {
    min-width: 29px;
    padding: 0 8px;
  }

  .hero-stage {
    padding-bottom: 72px;
  }

  .tablet-dock {
    position: fixed;
    left: 50%;
    bottom: max(18px, env(safe-area-inset-bottom));
    transform: translateX(-50%);
    z-index: 15;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px;
    border-radius: var(--radius-pill);
    background: rgba(12, 14, 20, 0.8);
    backdrop-filter: blur(26px) saturate(140%);
    -webkit-backdrop-filter: blur(26px) saturate(140%);
    border: 1px solid var(--hairline-strong);
    box-shadow: 0 14px 40px rgba(0, 0, 0, 0.52);
  }

  .tablet-dock-btn {
    appearance: none;
    min-height: 40px;
    padding: 0 16px;
    border: 0;
    border-radius: var(--radius-pill);
    background: transparent;
    color: var(--muted);
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    transition: color 180ms ease, background-color 180ms ease;
  }

  .tablet-dock-btn:hover {
    color: var(--text);
    background: rgba(var(--accent-rgb), 0.14);
  }

  .tablet-dock-sep {
    width: 1px;
    height: 20px;
    background: var(--hairline);
    margin: 0 2px;
  }

  /* Centered glass sheets on iPad / Tablet instead of edge-pinned strips */
  .controls-panel {
    left: 50%;
    right: auto;
    bottom: 50%;
    width: min(520px, calc(100vw - 48px));
    max-height: min(86dvh, 760px);
    border: 1px solid var(--hairline-strong);
    border-radius: var(--radius-card);
    padding-bottom: 0;
    box-shadow: 0 28px 80px rgba(0, 0, 0, 0.68);
    transform: translate(-50%, 58%);
  }

  .controls-panel:focus,
.modal-sheet:focus,
.modal-center:focus {
  outline: none;
}

.controls-panel.is-open {
    transform: translate(-50%, 50%);
  }

  .modal-sheet {
    left: 50%;
    right: auto;
    bottom: auto;
    top: 50%;
    width: min(440px, calc(100vw - 48px));
    border: 1px solid var(--hairline-strong);
    border-radius: var(--radius-card);
    padding-bottom: 16px;
    transform: translate(-50%, -50%);
    box-shadow: 0 28px 80px rgba(0, 0, 0, 0.68);
  }

  .mobile-only-handle {
    display: none;
  }
}

/* ---------- Desktop Layout (>= 1024px) ---------- */

@media (min-width: 1024px) {
  .app-shell {
    max-width: 1440px;
    padding-top: max(16px, env(safe-area-inset-top));
    padding-bottom: max(18px, env(safe-area-inset-bottom));
    padding-left: max(28px, env(safe-area-inset-left));
    padding-right: max(28px, env(safe-area-inset-right));
  }

  .app-toast {
    top: calc(max(16px, env(safe-area-inset-top)) + 104px);
  }

  .top-bar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: start;
    gap: 12px;
    min-height: 48px;
  }

  .top-left,
  .top-actions {
    min-height: 46px;
  }

  .top-left {
    justify-self: start;
  }

  .top-actions {
    justify-self: end;
  }

  .mode-dock {
    position: static;
    left: auto;
    right: auto;
    bottom: auto;
    justify-self: center;
    flex-direction: column;
    width: fit-content;
    min-width: 400px;
    max-width: min(540px, calc(100vw - 380px));
    border-radius: 22px;
    background: rgba(12, 14, 20, 0.72);
  }

  .mode-dock-primary {
    padding: 4px;
    gap: 0;
  }

  .mode-switcher {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 3px;
  }

  .mode-btn {
    flex-direction: row;
    gap: 7px;
    min-height: 38px;
    padding: 0 16px;
    border-radius: 17px;
    font-size: 13.5px;
  }

  .stage-scenes {
    border-bottom: 0;
    border-top: 1px solid rgba(var(--accent-rgb), 0.14);
    padding: 6px 8px 7px;
    gap: 6px;
  }

  .stage-scenes.is-switching {
    animation: scenes-swap-down 220ms var(--ease-out);
  }

  .stage-scene-chip {
    min-height: 30px;
    padding: 0 11px;
    gap: 6px;
    font-size: 12.5px;
  }

  .stage-scene-add {
    min-width: 30px;
    padding: 0 9px;
  }

  .dock-mix-btn,
  .tablet-dock,
  .mobile-only-btn,
  .mobile-only-handle,
  .lock-screen-row {
    display: none !important;
  }

  .desktop-only-btn {
    display: inline-flex;
  }

  .workspace {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 392px;
    gap: 28px;
    align-items: stretch;
    padding-top: 12px;
    transition: grid-template-columns 240ms var(--ease-out);
  }

  body.panel-collapsed .workspace {
    grid-template-columns: minmax(0, 1fr) 0px;
    gap: 0;
  }

  .hero-stage {
    padding-bottom: 18px;
  }

  .mode-heading {
    font-size: clamp(40px, 4.2vw, 54px);
  }

  .mode-summary {
    font-size: 15.5px;
  }

  .play-btn {
    width: 108px;
    height: 108px;
  }

  .play-wrap {
    margin: 28px 0 20px;
  }

  /* Persistent Floating Glass Studio Card on Right */
  .controls-panel {
    position: static;
    width: 392px;
    height: 100%;
    max-height: none;
    border: 1px solid var(--hairline);
    border-radius: var(--radius-card);
    background: var(--surface-glass);
    padding-bottom: 0;
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.07),
      0 24px 64px rgba(0, 0, 0, 0.45);
    transform: none !important;
    visibility: visible !important;
    pointer-events: auto !important;
    overflow: hidden;
    transition: none;
  }

  body.panel-collapsed .controls-panel {
    display: none;
  }

  /* Compact Floating Reopen Pill when Desktop Studio is hidden (zero black pillar) */
  body.panel-collapsed .studio-reopen-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    position: fixed;
    right: max(28px, env(safe-area-inset-right));
    bottom: max(24px, env(safe-area-inset-bottom));
    z-index: 20;
    min-height: 42px;
    padding: 0 16px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--hairline-strong);
    background: rgba(12, 14, 20, 0.72);
    backdrop-filter: blur(24px) saturate(135%);
    -webkit-backdrop-filter: blur(24px) saturate(135%);
    color: var(--text);
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.48);
    transition: background-color 180ms ease, border-color 180ms ease, transform 120ms ease;
  }

  body.panel-collapsed .studio-reopen-btn:hover {
    background: rgba(var(--accent-rgb), 0.16);
    border-color: rgba(var(--accent-rgb), 0.45);
  }

  body.panel-collapsed .studio-reopen-btn svg {
    color: var(--accent);
  }

  .sheet-header {
    cursor: default;
    touch-action: auto;
  }

  .panel-header {
    padding: 12px 16px;
  }

  .panel-scroll {
    padding: 12px 16px;
  }

  .sound-slider {
    height: 32px;
  }

  .modal-sheet {
    left: 50%;
    right: auto;
    bottom: auto;
    top: 50%;
    width: min(440px, calc(100vw - 48px));
    border: 1px solid var(--hairline-strong);
    border-radius: var(--radius-card);
    padding-bottom: 16px;
    transform: translate(-50%, -50%);
    box-shadow: 0 28px 80px rgba(0, 0, 0, 0.7);
  }
}

/* ---------- Reduced Motion ---------- */

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