/**
 * Dedicated mobile presentation shell.
 * Applies only under [data-studio-shell="mobile"].
 * Does not restyle the desktop shell.
 */

[data-studio-shell="mobile"] {
  --ms-header-h: 52px;
  --ms-nav-h: 58px;
  --ms-pad: 10px;
  --ms-gap: 8px;
  /* Skin theme tokens (overridden per data-skin below) */
  --ms-bg: #12100e;
  --ms-bg-2: #1a1510;
  --ms-panel: rgba(0, 0, 0, 0.28);
  --ms-text: #f4efe6;
  --ms-muted: rgba(244, 239, 230, 0.62);
  --ms-accent: #c4a35a;
  --ms-accent-2: #d4af37;
  --ms-accent-soft: rgba(196, 163, 90, 0.16);
  --ms-border: rgba(196, 163, 90, 0.35);
  --ms-border-soft: rgba(255, 255, 255, 0.1);
  --ms-nav-bg: rgba(12, 10, 9, 0.96);
  --ms-header-bg: linear-gradient(180deg, #1c1610 0%, #12100e 100%);
  --ms-btn-radius: 10px;
  --ms-glow: none;
  --ms-deck-label: var(--ms-accent);
  --ms-wave-bg: rgba(0, 0, 0, 0.35);
}

html[data-studio-shell="mobile"] body.studio-live,
[data-studio-shell="mobile"] body.studio-live,
[data-studio-shell="mobile"].studio-live {
  overflow: hidden !important;
  overflow-x: clip !important;
  overscroll-behavior-x: none;
  max-width: 100%;
}

/* Pre-studio account chrome on /online/mobile/ — keep compact so gate card stays reachable */
html[data-studio-shell="mobile"] .online-gate-top {
  gap: 0.45rem;
  padding: 0.45rem 0.75rem;
  padding-top: max(0.45rem, env(safe-area-inset-top, 0px));
}
html[data-studio-shell="mobile"] .brand-logo--gate {
  height: 36px;
  max-width: min(200px, 42vw);
}
html[data-studio-shell="mobile"] .online-gate-actions .btn {
  min-height: 36px;
  padding: 0.25rem 0.55rem;
  font-size: 0.78rem;
}
html[data-studio-shell="mobile"] .online-gate-main {
  padding: 1rem 0.75rem;
  align-content: start;
  place-items: start center;
}
html[data-studio-shell="mobile"] .gate-card h1 {
  font-size: clamp(1.55rem, 7vw, 2.2rem);
}

[data-studio-shell="mobile"] #studio-root {
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  overflow-x: clip;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

[data-studio-shell="mobile"] .mobile-studio-shell {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  background: var(--ms-bg);
  color: var(--ms-text);
  overflow-x: clip;
}

[data-studio-shell="mobile"] .ms-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  row-gap: 4px;
  gap: 6px;
  min-height: var(--ms-header-h);
  max-height: none;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  padding: 4px var(--ms-pad);
  padding-top: max(4px, env(safe-area-inset-top));
  padding-left: max(var(--ms-pad), env(safe-area-inset-left, 0px));
  padding-right: max(var(--ms-pad), env(safe-area-inset-right, 0px));
  border-bottom: 1px solid var(--ms-border);
  flex: 0 0 auto;
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--ms-header-bg);
  box-shadow: var(--ms-glow);
}

/* Keep the first screen for the workspace — header must not dominate the viewport */
@media (max-width: 430px) {
  [data-studio-shell="mobile"] {
    --ms-header-h: 44px;
  }
  [data-studio-shell="mobile"] .ms-brand {
    font-size: 1rem;
    max-width: 34vw;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  [data-studio-shell="mobile"] .ms-skin-badge {
    max-width: 5.5rem;
    font-size: 0.58rem;
  }
  [data-studio-shell="mobile"] .ms-status {
    display: none;
  }
  [data-studio-shell="mobile"] .ms-header-btn {
    min-width: 2.4rem;
    padding: 0.2rem 0.35rem;
    font-size: 0.62rem;
  }
}

[data-studio-shell="mobile"] .ms-brand {
  font-family: "Bebas Neue", sans-serif;
  font-size: 1.15rem;
  letter-spacing: 0.04em;
  white-space: nowrap;
  color: var(--ms-accent-2);
}

[data-studio-shell="mobile"] .ms-skin-badge {
  display: inline-flex;
  align-items: center;
  min-height: 1.5rem;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  border: 1px solid var(--ms-border);
  background: var(--ms-accent-soft);
  color: var(--ms-accent-2);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  max-width: 7.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

[data-studio-shell="mobile"] .ms-status {
  font-size: 0.68rem;
  opacity: 0.75;
  margin-left: auto;
  max-width: 22vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  order: 5;
}

[data-studio-shell="mobile"] .ms-deck-switcher {
  display: flex;
  gap: 4px;
}

[data-studio-shell="mobile"] .ms-deck-chip {
  min-width: 2rem;
  min-height: 2rem;
  padding: 0 0.4rem;
}

[data-studio-shell="mobile"] .ms-deck-chip.is-active {
  outline: 2px solid var(--ms-accent-2);
  background: var(--ms-accent-soft);
  color: var(--ms-accent-2);
}

[data-studio-shell="mobile"] .ms-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
}

[data-studio-shell="mobile"] .ms-header-btn {
  min-height: 2rem;
  min-width: 2.75rem;
  padding: 0.25rem 0.45rem;
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 700;
  border: 1px solid var(--ms-border);
  border-radius: var(--ms-btn-radius);
  color: var(--ms-accent-2);
  background: var(--ms-accent-soft);
}

[data-studio-shell="mobile"] .ms-workspace {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  /* Vertical owner only — overflow:auto enabled iOS horizontal pan. */
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-x: none;
  overscroll-behavior-y: contain;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
  padding: var(--ms-pad);
  padding-left: max(var(--ms-pad), env(safe-area-inset-left, 0px));
  padding-right: max(var(--ms-pad), env(safe-area-inset-right, 0px));
  padding-bottom: calc(var(--ms-nav-h) + var(--ms-pad) + env(safe-area-inset-bottom));
}

[data-studio-shell="mobile"] .ms-panel {
  display: none;
  min-height: 0;
}

[data-studio-shell="mobile"][data-mobile-ws="deck1"] .ms-panel-deck[data-deck="deck1"],
[data-studio-shell="mobile"][data-mobile-ws="deck2"] .ms-panel-deck[data-deck="deck2"],
[data-studio-shell="mobile"][data-mobile-ws="deck3"] .ms-panel-deck[data-deck="deck3"],
[data-studio-shell="mobile"][data-mobile-ws="deck4"] .ms-panel-deck[data-deck="deck4"],
[data-studio-shell="mobile"][data-mobile-ws="mixer"] .ms-panel-mixer,
[data-studio-shell="mobile"][data-mobile-ws="music"] .ms-panel-library,
[data-studio-shell="mobile"][data-mobile-ws="library"] .ms-panel-library,
[data-studio-shell="mobile"][data-mobile-ws="sampler"] .ms-panel-sampler,
[data-studio-shell="mobile"][data-mobile-ws="fx"] .ms-panel-effects,
[data-studio-shell="mobile"][data-mobile-ws="effects"] .ms-panel-effects,
[data-studio-shell="mobile"][data-mobile-ws="more"] .ms-panel-more,
[data-studio-shell="mobile"][data-mobile-ws="settings"] .ms-panel-settings {
  /* !important beats UA [hidden] if a stale attribute remains after panel sync */
  display: block !important;
}

/* Default: show deck1 if no workspace attr yet */
[data-studio-shell="mobile"]:not([data-mobile-ws]) .ms-panel-deck[data-deck="deck1"] {
  display: block;
}

/* Must beat skin rules that hide legacy .mobile-bottom-nav on desktop. */
[data-studio-shell="mobile"] .ms-bottom-nav {
  position: fixed !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: auto !important;
  max-width: 100% !important;
  box-sizing: border-box;
  z-index: 80 !important; /* must stay above .swagg-audio-unlock (45) */
  display: grid !important;
  visibility: visible !important;
  opacity: 1 !important;
  pointer-events: auto !important;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 2px;
  min-height: var(--ms-nav-h);
  padding: 6px max(4px, env(safe-area-inset-right, 0px)) calc(6px + env(safe-area-inset-bottom)) max(4px, env(safe-area-inset-left, 0px));
  border-top: 1px solid var(--ms-border);
  background: var(--ms-nav-bg);
  backdrop-filter: blur(8px);
  box-shadow: var(--ms-glow);
}

[data-studio-shell="mobile"] .ms-nav-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ms-muted);
  font: inherit;
  font-size: 0.72rem;
  min-height: 44px;
  border-radius: var(--ms-btn-radius);
  opacity: 1;
}

[data-studio-shell="mobile"] .ms-nav-btn[aria-current="page"],
[data-studio-shell="mobile"] .ms-nav-btn.is-active {
  color: var(--ms-accent-2);
  background: var(--ms-accent-soft);
  box-shadow: inset 0 -2px 0 var(--ms-accent);
}

/* Hide desktop-only chrome inside mobile shell if any leaks through */
[data-studio-shell="mobile"] .lc-topbar,
[data-studio-shell="mobile"] .nn-topbar,
[data-studio-shell="mobile"] .perf-music-rail,
[data-studio-shell="mobile"] .classic-music-rail,
[data-studio-shell="mobile"] .lc-library,
[data-studio-shell="mobile"] .nn-library,
[data-studio-shell="mobile"] .up-next-rail,
[data-studio-shell="mobile"] .desktop-only {
  display: none !important;
}

/* ========== Dedicated mobile deck component ==========
   Overrides desktop .deck-body grid / platter-wrap that crush the turntable
   to ~0 width when mobile-perf-active is not applied. */
[data-studio-shell="mobile"] .ms-panel-deck {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

[data-studio-shell="mobile"] .ms-panel-deck .deck,
[data-studio-shell="mobile"] .deck.deck-mobile {
  display: flex !important;
  flex-direction: column !important;
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  height: auto !important;
  max-height: none !important;
  overflow: visible !important;
  gap: 0.55rem !important;
  padding: 0.35rem 0.15rem 0.75rem !important;
  box-sizing: border-box;
  container-type: normal;
}

[data-studio-shell="mobile"] .deck.deck-mobile .deck-body,
[data-studio-shell="mobile"] .deck.deck-mobile .deck-main,
[data-studio-shell="mobile"] .deck.deck-mobile .deck-platter-wrap {
  display: contents;
}

[data-studio-shell="mobile"] .md-header {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  width: 100%;
  min-width: 0;
}

[data-studio-shell="mobile"] .md-header-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
  width: 100%;
}

[data-studio-shell="mobile"] .md-track-block {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
  width: 100%;
}

[data-studio-shell="mobile"] .md-track-block .track-title {
  font-weight: 700;
  font-size: 1rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

[data-studio-shell="mobile"] .md-track-block .track-artist {
  font-size: 0.8rem;
  opacity: 0.75;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

[data-studio-shell="mobile"] .deck.deck-mobile .deck-label,
[data-studio-shell="mobile"] .md-header .deck-label {
  color: var(--ms-deck-label);
  letter-spacing: 0.08em;
}

[data-studio-shell="mobile"] .deck.deck-mobile .btn-gold,
[data-studio-shell="mobile"] .deck.deck-mobile .btn-play-primary,
[data-studio-shell="mobile"] .ms-panel-library .btn-gold,
[data-studio-shell="mobile"] .ms-skins .ms-skin-btn.is-active {
  border-color: var(--ms-border);
  color: var(--ms-accent-2);
  background: var(--ms-accent-soft);
  box-shadow: var(--ms-glow);
}

[data-studio-shell="mobile"] .md-waveform,
[data-studio-shell="mobile"] .mobile-waveform {
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  height: 56px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--ms-wave-bg);
  border: 1px solid var(--ms-border-soft);
  box-shadow: inset 0 0 0 1px var(--ms-accent-soft);
}

[data-studio-shell="mobile"] .md-waveform .waveform-canvas,
[data-studio-shell="mobile"] .mobile-waveform .waveform-canvas {
  width: 100% !important;
  height: 56px !important;
  display: block;
}

[data-studio-shell="mobile"] .md-turntable-wrap,
[data-studio-shell="mobile"] .mobile-turntable {
  display: flex !important;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  margin: 0 auto;
  overflow: visible !important;
}

/* Kill desktop grid that creates an implicit 2nd column and crushes the platter. */
[data-studio-shell="mobile"] .deck.deck-mobile .deck-platter-wrap,
[data-studio-shell="mobile"] .md-turntable-wrap {
  grid-template-columns: none !important;
}

[data-studio-shell="mobile"] .deck.deck-mobile .turntable,
[data-studio-shell="mobile"] .md-turntable-wrap .turntable {
  --tt-w: min(86vw, 320px) !important;
  --tt-h: calc(var(--tt-w) * 819 / 1024) !important;
  width: var(--tt-w) !important;
  max-width: 100% !important;
  min-width: 180px !important;
  flex: 0 0 auto !important;
  grid-column: auto !important;
  grid-row: auto !important;
  margin: 0 auto;
}

[data-studio-shell="mobile"] .deck.deck-mobile .tt-chassis {
  width: 100% !important;
  height: var(--tt-h) !important;
  max-width: 100%;
}

[data-studio-shell="mobile"] .deck.deck-mobile .tt-exact,
[data-studio-shell="mobile"] .deck.deck-mobile .tt-arm {
  max-width: 100%;
  object-fit: contain;
}

[data-studio-shell="mobile"] .md-bpm-row {
  width: 100%;
  min-width: 0;
}

[data-studio-shell="mobile"] .md-bpm-row .deck-bpm-side,
[data-studio-shell="mobile"] .deck.deck-mobile .deck-bpm-side {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: wrap !important;
  align-items: stretch;
  justify-content: center;
  gap: 0.35rem;
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  grid-column: auto !important;
}

[data-studio-shell="mobile"] .md-bpm-row .tt-bpm-panel {
  flex: 1 1 100%;
  min-height: 2.6rem;
  text-align: center;
}

[data-studio-shell="mobile"] .md-bpm-row .deck-bpm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
  width: 100%;
}

[data-studio-shell="mobile"] .md-bpm-row .tt-speed-nudge {
  display: flex;
  gap: 0.35rem;
  width: 100%;
  justify-content: center;
}

[data-studio-shell="mobile"] .md-transport,
[data-studio-shell="mobile"] .mobile-primary-transport {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: 0.4rem !important;
  width: 100% !important;
  max-width: 100% !important;
}

[data-studio-shell="mobile"] .md-transport .btn,
[data-studio-shell="mobile"] .md-transport .file-btn,
[data-studio-shell="mobile"] .md-secondary .btn {
  min-height: 44px;
  width: 100%;
  justify-content: center;
  box-sizing: border-box;
}

[data-studio-shell="mobile"] .md-secondary {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: 0.35rem;
  width: 100%;
}

[data-studio-shell="mobile"] .md-hotcues {
  display: grid !important;
  grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  gap: 0.35rem;
  width: 100%;
}

[data-studio-shell="mobile"] .md-hotcues .btn {
  min-height: 42px;
}

[data-studio-shell="mobile"] .md-loops {
  display: grid !important;
  grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  gap: 0.3rem;
  width: 100%;
}

[data-studio-shell="mobile"] .md-pitch,
[data-studio-shell="mobile"] .mobile-pitch {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  width: 100%;
  min-width: 0;
}

[data-studio-shell="mobile"] .md-pitch-row,
[data-studio-shell="mobile"] .md-pitch-coarse {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  width: 100%;
}

[data-studio-shell="mobile"] .md-pitch .pitch-slider,
[data-studio-shell="mobile"] .mobile-pitch .pitch-slider {
  flex: 1 1 auto;
  width: 100% !important;
  min-width: 0 !important;
  max-width: none !important;
}

[data-studio-shell="mobile"] .md-mix,
[data-studio-shell="mobile"] .mobile-deck-mix-controls {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: 0.45rem;
  width: 100%;
  align-items: start;
}

[data-studio-shell="mobile"] .md-mix .control-knob {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  width: 100%;
  min-width: 0;
  margin: 0;
}

[data-studio-shell="mobile"] .md-mix .control-knob input[type="range"] {
  width: 100% !important;
  max-width: 100% !important;
}

[data-studio-shell="mobile"] .md-eq-panel {
  grid-column: 1 / -1;
  width: 100%;
}

[data-studio-shell="mobile"] .md-eq-toggle {
  width: 100%;
  min-height: 42px;
  list-style: none;
  cursor: pointer;
}

[data-studio-shell="mobile"] .md-eq-toggle::-webkit-details-marker {
  display: none;
}

[data-studio-shell="mobile"] .md-eq-body {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.4rem;
  margin-top: 0.4rem;
}

[data-studio-shell="mobile"] .md-advanced {
  width: 100%;
  min-width: 0;
}

[data-studio-shell="mobile"] .md-advanced .deck-adv-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.3rem;
}

[data-studio-shell="mobile"] .md-advanced .deck-fx-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

/* Hide floating admin Diagnostics over the deck; use More entry instead. */
[data-studio-shell="mobile"] #swagg-perf-launcher {
  display: none !important;
}

/* Phone landscape: keep turntable usable, tighten gaps */
@media (orientation: landscape) and (max-height: 520px) {
  [data-studio-shell="mobile"] .deck.deck-mobile .turntable,
  [data-studio-shell="mobile"] .md-turntable-wrap .turntable {
    --tt-w: min(42vh, 220px) !important;
  }
  [data-studio-shell="mobile"] .md-transport {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  }
  [data-studio-shell="mobile"] .md-waveform,
  [data-studio-shell="mobile"] .mobile-waveform {
    height: 44px;
  }
  [data-studio-shell="mobile"] .md-waveform .waveform-canvas {
    height: 44px !important;
  }
}

[data-studio-shell="mobile"] .ms-panel-mixer [data-el="mixer"] {
  position: static !important;
  width: 100% !important;
  max-width: 100% !important;
  inset: auto !important;
  transform: none !important;
  box-shadow: none;
}

[data-studio-shell="mobile"] .ms-panel-library .library-list,
[data-studio-shell="mobile"] .ms-panel-library .lib-table {
  display: block;
  width: 100%;
  overflow-x: auto;
}

[data-studio-shell="mobile"] .ms-more-actions {
  display: grid;
  gap: 8px;
}

/* —— Skins: always-visible picker in More (no dropdown) —— */
[data-studio-shell="mobile"] .ms-skins {
  display: grid;
  gap: 8px;
  margin: 0 0 14px;
  padding: 12px;
  border: 1px solid rgba(212, 175, 55, 0.28);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.22);
}

[data-studio-shell="mobile"] .ms-skins-title {
  margin: 0;
  font-size: 0.95rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent-gold, #d4af37);
}

[data-studio-shell="mobile"] .ms-skins-lead {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.35;
  opacity: 0.72;
}

[data-studio-shell="mobile"] .ms-skins-list {
  display: grid;
  gap: 8px;
}

[data-studio-shell="mobile"] .ms-skin-btn {
  display: grid !important;
  grid-template-columns: 0.75rem minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  min-height: 52px;
  text-align: left;
  padding: 0.65rem 0.75rem !important;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
}

[data-studio-shell="mobile"] .ms-skin-btn.is-active {
  border-color: rgba(212, 175, 55, 0.7);
  background: rgba(212, 175, 55, 0.14);
  box-shadow: inset 0 0 0 1px rgba(212, 175, 55, 0.25);
}

[data-studio-shell="mobile"] .ms-skin-swatch {
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 2px;
  background: var(--skins-swatch, #d4af37);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.15);
}

[data-studio-shell="mobile"] .ms-skin-copy {
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
  min-width: 0;
}

[data-studio-shell="mobile"] .ms-skin-name {
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

[data-studio-shell="mobile"] .ms-skin-blurb {
  font-size: 0.7rem;
  line-height: 1.3;
  opacity: 0.65;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
}

[data-studio-shell="mobile"] .ms-skin-state {
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 800;
  color: var(--accent-gold, #d4af37);
  white-space: nowrap;
}

[data-studio-shell="mobile"] .ms-panel-settings .skin-chooser {
  grid-template-columns: 1fr !important;
  gap: 0.65rem;
}

[data-studio-shell="mobile"] .ms-panel-settings .skin-card-actions .btn {
  min-height: 44px;
}

/* —— Cloud Music: touch-friendly library + cards —— */
[data-studio-shell="mobile"] .ms-panel-library .lib-hero-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

[data-studio-shell="mobile"] .ms-panel-library .lib-hero-actions .btn {
  min-height: 46px;
  width: 100%;
}

[data-studio-shell="mobile"] .ms-panel-library .lib-nav {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  gap: 0.35rem 0.75rem;
  padding-bottom: 0.45rem;
  scrollbar-width: thin;
}

[data-studio-shell="mobile"] .ms-panel-library .lib-nav-tab {
  flex: 0 0 auto;
  min-height: 40px;
  white-space: nowrap;
}

[data-studio-shell="mobile"] .ms-panel-library .cloud-page {
  padding: 0 0 1.25rem;
}

[data-studio-shell="mobile"] .ms-panel-library .cloud-cards,
[data-studio-shell="mobile"] .ms-panel-library .cloud-cards--hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

[data-studio-shell="mobile"] .ms-panel-library .cloud-card {
  min-width: 0;
  padding: 12px;
}

[data-studio-shell="mobile"] .ms-panel-library .cloud-card-actions {
  display: grid;
  gap: 8px;
}

[data-studio-shell="mobile"] .ms-panel-library .cloud-card-actions .btn {
  min-height: 46px;
  width: 100%;
}

[data-studio-shell="mobile"] .ms-panel-library .cloud-browser {
  margin-top: 12px;
}

[data-studio-shell="mobile"] .ms-panel-library .cloud-browser-head {
  flex-wrap: wrap;
}

[data-studio-shell="mobile"] .ms-panel-library .cloud-toolbar {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

[data-studio-shell="mobile"] .ms-panel-library .cloud-toolbar .btn,
[data-studio-shell="mobile"] .ms-panel-library .cloud-row-import,
[data-studio-shell="mobile"] .ms-panel-library .add-music-options .btn {
  min-height: 44px;
}

[data-studio-shell="mobile"] .ms-panel-library .cloud-row {
  min-height: 48px;
  gap: 8px;
}

[data-studio-shell="mobile"] .ms-panel-library .add-music-modal {
  z-index: 120;
  padding: 0.75rem;
  padding-bottom: calc(0.75rem + var(--ms-nav-h) + env(safe-area-inset-bottom));
}

[data-studio-shell="mobile"] .ms-panel-library .add-music-card {
  width: min(100%, 28rem);
}

[data-studio-shell="mobile"] .ms-view-override {
  display: grid;
  gap: 6px;
  margin-top: 12px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
}

[data-studio-shell="mobile"] .ms-view-override h4 {
  margin: 0 0 4px;
  font-size: 0.85rem;
}

/* Phone landscape: keep nav compact; workspace scrolls */
@media (orientation: landscape) and (max-height: 520px) {
  [data-studio-shell="mobile"] {
    --ms-header-h: 44px;
    --ms-nav-h: 48px;
  }
  [data-studio-shell="mobile"] .ms-bottom-nav {
    min-height: 48px;
  }
  [data-studio-shell="mobile"] .ms-nav-btn {
    min-height: 40px;
    font-size: 0.68rem;
  }
}

/* Pad grid for sampler workspace */
[data-studio-shell="mobile"] .ms-panel-sampler .pads-soon-grid,
[data-studio-shell="mobile"] .ms-panel-sampler .sampler-pads {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

@media (min-width: 420px) {
  [data-studio-shell="mobile"] .ms-panel-sampler .pads-soon-grid,
  [data-studio-shell="mobile"] .ms-panel-sampler .sampler-pads {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

/* ========== Per-skin mobile appearance (shared layout, distinct look) ========== */

/* Classic — warm brown / traditional turntable console */
html[data-studio-shell="mobile"][data-skin="swagg-classic"] {
  --ms-bg: #16110c;
  --ms-bg-2: #241a12;
  --ms-panel: rgba(40, 28, 16, 0.45);
  --ms-text: #f3ebd4;
  --ms-muted: rgba(243, 235, 212, 0.62);
  --ms-accent: #c4a35a;
  --ms-accent-2: #e0c07a;
  --ms-accent-soft: rgba(196, 163, 90, 0.18);
  --ms-border: rgba(196, 163, 90, 0.42);
  --ms-border-soft: rgba(196, 163, 90, 0.22);
  --ms-nav-bg: rgba(18, 13, 9, 0.97);
  --ms-header-bg: linear-gradient(180deg, #2a1f14 0%, #16110c 100%);
  --ms-btn-radius: 8px;
  --ms-glow: none;
  --ms-deck-label: #e0c07a;
  --ms-wave-bg: rgba(20, 14, 8, 0.55);
}

html[data-studio-shell="mobile"][data-skin="swagg-classic"] .mobile-studio-shell {
  background:
    radial-gradient(120% 70% at 50% -10%, rgba(196, 163, 90, 0.16), transparent 55%),
    linear-gradient(180deg, #1c1510 0%, #120e0a 100%);
}

html[data-studio-shell="mobile"][data-skin="swagg-classic"] .ms-panel-deck .deck.deck-mobile {
  border: 1px solid var(--ms-border-soft);
  border-radius: 12px;
  padding: 0.55rem 0.4rem 0.85rem !important;
  background: linear-gradient(180deg, rgba(48, 34, 20, 0.55), rgba(18, 13, 9, 0.35));
}

/* Library Console — flat black pro console, sharp gold */
html[data-studio-shell="mobile"][data-skin="swagg-library-console"] {
  --ms-bg: #000000;
  --ms-bg-2: #050505;
  --ms-panel: #0a0a0a;
  --ms-text: #f3ebd4;
  --ms-muted: rgba(240, 230, 200, 0.5);
  --ms-accent: #d4af37;
  --ms-accent-2: #e8c85a;
  --ms-accent-soft: rgba(212, 175, 55, 0.12);
  --ms-border: rgba(212, 175, 55, 0.45);
  --ms-border-soft: rgba(212, 175, 55, 0.22);
  --ms-nav-bg: #000000;
  --ms-header-bg: #000000;
  --ms-btn-radius: 2px;
  --ms-glow: none;
  --ms-deck-label: #d4af37;
  --ms-wave-bg: #050505;
}

html[data-studio-shell="mobile"][data-skin="swagg-library-console"] .mobile-studio-shell {
  background: #000 !important;
}

html[data-studio-shell="mobile"][data-skin="swagg-library-console"] .ms-header,
html[data-studio-shell="mobile"][data-skin="swagg-library-console"] .ms-bottom-nav {
  border-color: rgba(212, 175, 55, 0.42) !important;
}

html[data-studio-shell="mobile"][data-skin="swagg-library-console"] .ms-brand {
  letter-spacing: 0.12em;
  font-size: 1.05rem;
}

html[data-studio-shell="mobile"][data-skin="swagg-library-console"] .ms-panel-deck .deck.deck-mobile {
  border: 1px solid rgba(212, 175, 55, 0.28);
  border-radius: 0;
  background: #050505;
  padding: 0.5rem 0.35rem 0.8rem !important;
}

html[data-studio-shell="mobile"][data-skin="swagg-library-console"] .ms-skin-badge,
html[data-studio-shell="mobile"][data-skin="swagg-library-console"] .ms-header-btn,
html[data-studio-shell="mobile"][data-skin="swagg-library-console"] .ms-nav-btn {
  border-radius: 2px;
}

html[data-studio-shell="mobile"][data-skin="swagg-library-console"] .md-hotcues .btn {
  border-radius: 2px;
  border-color: rgba(212, 175, 55, 0.35);
}

/* Neon Nights — cyan / hot gold club energy */
html[data-studio-shell="mobile"][data-skin="swagg-neon-nights"] {
  --ms-bg: #050508;
  --ms-bg-2: #101018;
  --ms-panel: rgba(16, 16, 28, 0.85);
  --ms-text: #f4f4f8;
  --ms-muted: rgba(220, 220, 235, 0.55);
  --ms-accent: #00d1ff;
  --ms-accent-2: #ffb800;
  --ms-accent-soft: rgba(0, 209, 255, 0.14);
  --ms-border: rgba(255, 184, 0, 0.45);
  --ms-border-soft: rgba(0, 209, 255, 0.28);
  --ms-nav-bg: rgba(5, 5, 12, 0.96);
  --ms-header-bg: linear-gradient(180deg, #141422 0%, #050508 100%);
  --ms-btn-radius: 12px;
  --ms-glow: 0 0 18px rgba(0, 209, 255, 0.18);
  --ms-deck-label: #ffb800;
  --ms-wave-bg: rgba(0, 209, 255, 0.08);
}

html[data-studio-shell="mobile"][data-skin="swagg-neon-nights"] .mobile-studio-shell {
  background:
    radial-gradient(110% 80% at 50% 0%, #1a1230 0%, #050508 58%),
    #050508 !important;
}

html[data-studio-shell="mobile"][data-skin="swagg-neon-nights"] .ms-brand {
  color: #ffb800;
  text-shadow: 0 0 12px rgba(255, 184, 0, 0.45);
}

html[data-studio-shell="mobile"][data-skin="swagg-neon-nights"] .ms-skin-badge {
  border-color: rgba(0, 209, 255, 0.55);
  color: #00d1ff;
  background: rgba(0, 209, 255, 0.12);
  box-shadow: 0 0 12px rgba(0, 209, 255, 0.25);
}

html[data-studio-shell="mobile"][data-skin="swagg-neon-nights"] .ms-nav-btn[aria-current="page"],
html[data-studio-shell="mobile"][data-skin="swagg-neon-nights"] .ms-nav-btn.is-active {
  color: #00d1ff;
  background: rgba(0, 209, 255, 0.14);
  box-shadow: inset 0 -2px 0 #ffb800, 0 0 12px rgba(0, 209, 255, 0.25);
}

html[data-studio-shell="mobile"][data-skin="swagg-neon-nights"] .ms-panel-deck .deck.deck-mobile {
  border: 1px solid rgba(0, 209, 255, 0.28);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(30, 20, 55, 0.65), rgba(8, 8, 16, 0.55));
  box-shadow: 0 0 24px rgba(180, 77, 255, 0.12);
  padding: 0.55rem 0.45rem 0.9rem !important;
}

html[data-studio-shell="mobile"][data-skin="swagg-neon-nights"] .btn-play-primary {
  border-color: rgba(255, 184, 0, 0.65) !important;
  color: #ffb800 !important;
  background: rgba(255, 184, 0, 0.14) !important;
  box-shadow: 0 0 14px rgba(255, 184, 0, 0.28);
}

html[data-studio-shell="mobile"][data-skin="swagg-neon-nights"] .md-hotcues .btn {
  border-color: rgba(0, 209, 255, 0.4);
  box-shadow: 0 0 8px rgba(0, 209, 255, 0.15);
}

/* --- Deck track reconnection (mobile) --- */
html[data-studio-shell="mobile"] .music-restore-banner {
  position: sticky;
  top: 0;
  z-index: 50;
  padding: 0.7rem 0.85rem;
  background: linear-gradient(180deg, rgba(48, 34, 18, 0.98), rgba(28, 20, 12, 0.96));
  border-bottom: 1px solid rgba(212, 168, 75, 0.55);
  color: #f3e6d0;
}
html[data-studio-shell="mobile"] .music-restore-banner[hidden] { display: none !important; }
html[data-studio-shell="mobile"] .music-restore-banner-inner {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.45rem;
}
html[data-studio-shell="mobile"] .music-restore-banner-title {
  margin: 0;
  font-weight: 700;
  font-size: 0.9rem;
  color: #d4a84b;
}
html[data-studio-shell="mobile"] .music-restore-banner-msg {
  margin: 0;
  font-size: 0.8rem;
  color: rgba(243, 230, 208, 0.88);
}
html[data-studio-shell="mobile"] .music-restore-banner .btn {
  min-height: 2.6rem;
}

html[data-studio-shell="mobile"] .deck-recovery {
  --deck-recovery-bg: rgba(40, 28, 18, 0.94);
  --deck-recovery-border: rgba(212, 168, 75, 0.55);
  --deck-recovery-accent: #d4a84b;
  --deck-recovery-text: #f3e6d0;
  --deck-recovery-muted: rgba(243, 230, 208, 0.8);
  margin: 0.4rem 0 0.5rem;
  padding: 0.6rem 0.65rem;
  border: 1px solid var(--deck-recovery-border);
  border-radius: 12px;
  background: var(--deck-recovery-bg);
  color: var(--deck-recovery-text);
  max-width: 100%;
  box-sizing: border-box;
}
html[data-studio-shell="mobile"] .deck-recovery[hidden] { display: none !important; }
html[data-studio-shell="mobile"] .deck-recovery-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.5rem;
}
html[data-studio-shell="mobile"] .deck-recovery[data-state="reconnecting"] [data-act="deck-reconnect"],
html[data-studio-shell="mobile"] .deck-recovery[data-state="reconnecting"] [data-act="deck-choose-file"],
html[data-studio-shell="mobile"] .deck-recovery[data-state="offline"] [data-act="deck-reconnect"],
html[data-studio-shell="mobile"] .deck-recovery[data-state="offline"] [data-act="deck-choose-file"] {
  display: none !important;
}
html[data-studio-shell="mobile"] .deck-recovery-actions .btn {
  min-height: 2.6rem;
  flex: 1 1 calc(50% - 0.4rem);
}
html[data-studio-shell="mobile"] .deck-conn-chip {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 0.12rem 0.35rem;
  border-radius: 999px;
  border: 1px solid var(--deck-recovery-border, rgba(212,168,75,0.55));
  color: var(--deck-recovery-accent, #d4a84b);
}
html[data-studio-shell="mobile"] .ms-deck-chip.needs-reconnect,
html[data-studio-shell="mobile"] .mobile-deck-chip.needs-reconnect {
  box-shadow: inset 0 0 0 1px rgba(212, 168, 75, 0.85);
  position: relative;
}
html[data-studio-shell="mobile"] .ms-deck-chip.needs-reconnect::after,
html[data-studio-shell="mobile"] .mobile-deck-chip.needs-reconnect::after {
  content: "";
  position: absolute;
  top: 0.2rem;
  right: 0.25rem;
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  background: #d4a84b;
}
html[data-studio-shell="mobile"][data-skin="swagg-neon-nights"] .deck-recovery {
  --deck-recovery-bg: rgba(18, 12, 36, 0.95);
  --deck-recovery-border: rgba(0, 209, 255, 0.5);
  --deck-recovery-accent: #00d1ff;
}
html[data-studio-shell="mobile"][data-skin="swagg-library-console"] .deck-recovery {
  --deck-recovery-bg: rgba(24, 28, 34, 0.96);
  --deck-recovery-border: rgba(120, 190, 255, 0.45);
  --deck-recovery-accent: #7ec8ff;
}

/* ========== iOS / iPadOS WebKit: native document scroll fallback ==========
 * Real Safari cannot reliably nest-scroll .ms-workspace when ancestors use
 * height:100dvh + overflow:hidden. Document/body becomes the sole vertical owner.
 * Android/desktop mobile shell keeps the workspace scroll owner above.
 */
html.is-ios-webkit[data-studio-shell="mobile"] {
  height: auto !important;
  min-height: 100% !important;
  max-height: none !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: none;
  overscroll-behavior-y: auto;
}

html.is-ios-webkit[data-studio-shell="mobile"] body,
html.is-ios-webkit[data-studio-shell="mobile"] body.studio-live {
  position: static !important;
  height: auto !important;
  min-height: 100% !important;
  max-height: none !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: none;
  overscroll-behavior-y: auto;
  max-width: 100%;
}

html.is-ios-webkit[data-studio-shell="mobile"] #studio-root,
html.is-ios-webkit[data-studio-shell="mobile"] body.studio-live #studio-root {
  position: relative !important;
  height: auto !important;
  max-height: none !important;
  min-height: 100svh;
  min-height: 100dvh;
  overflow: visible !important;
  overflow-x: hidden !important;
  width: 100%;
  max-width: 100%;
}

html.is-ios-webkit[data-studio-shell="mobile"] .mobile-studio-shell {
  position: relative !important;
  display: flex !important;
  flex-direction: column !important;
  height: auto !important;
  max-height: none !important;
  min-height: 100svh;
  min-height: 100dvh;
  overflow: visible !important;
  overflow-x: hidden !important;
  transform: none !important;
  contain: none !important;
}

html.is-ios-webkit[data-studio-shell="mobile"] .ms-header {
  position: sticky;
  top: 0;
  z-index: 40;
  flex: 0 0 auto;
}

html.is-ios-webkit[data-studio-shell="mobile"] .ms-workspace {
  flex: 0 0 auto !important;
  height: auto !important;
  max-height: none !important;
  min-height: 0 !important;
  overflow-x: hidden !important;
  overflow-y: visible !important;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: auto;
  padding-bottom: calc(var(--ms-nav-h) + var(--ms-pad) + env(safe-area-inset-bottom, 0px));
}

html.is-ios-webkit[data-studio-shell="mobile"] .ms-panel,
html.is-ios-webkit[data-studio-shell="mobile"] .ms-panel-deck,
html.is-ios-webkit[data-studio-shell="mobile"] .ms-panel-library,
html.is-ios-webkit[data-studio-shell="mobile"] .ms-panel-effects,
html.is-ios-webkit[data-studio-shell="mobile"] .ms-panel-more,
html.is-ios-webkit[data-studio-shell="mobile"] .ms-panel-settings,
html.is-ios-webkit[data-studio-shell="mobile"] .ms-panel-sampler,
html.is-ios-webkit[data-studio-shell="mobile"] .panel-page,
html.is-ios-webkit[data-studio-shell="mobile"] .main-stage {
  height: auto !important;
  max-height: none !important;
  overflow-y: visible !important;
  overflow-x: hidden !important;
}

/* Sticky bottom nav — stays in document flow (no fixed overlay trap) */
html.is-ios-webkit[data-studio-shell="mobile"] .ms-bottom-nav {
  position: sticky !important;
  left: auto !important;
  right: auto !important;
  bottom: 0 !important;
  width: 100% !important;
  max-width: 100% !important;
  transform: none !important;
  z-index: 80 !important;
}

/* Audio unlock: sticky in document flow — never fixed, never fullscreen */
html.is-ios-webkit[data-studio-shell="mobile"] .swagg-audio-unlock {
  position: sticky !important;
  top: calc(env(safe-area-inset-top, 0px) + 8px) !important;
  bottom: auto !important;
  left: 0 !important;
  right: 0 !important;
  transform: none !important;
  margin: 8px auto !important;
  z-index: 45;
  width: max-content;
  max-width: min(22rem, calc(100% - 1.5rem));
  pointer-events: auto;
  touch-action: manipulation;
}
