/* ============================================================
   y&music - Layout & Responsive Grid
   Responsive across: Desktop (>1024px), iPad (768px-1024px), iPhone (<768px)
   Full support for iOS PWA Standalone & Safe Area Insets (Notch/Dynamic Island)
   ============================================================ */

:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --header-safe-top: var(--safe-top);
  --header-content-height: 58px;
  --header-height: calc(var(--header-content-height) + var(--header-safe-top));
}

/* Standalone PWA Mode (Home Screen WebApp on iPhone / iPad / Android) */
@media (display-mode: standalone), (display-mode: fullscreen) {
  :root {
    --header-safe-top: max(env(safe-area-inset-top, 0px), 44px);
    --header-height: calc(var(--header-content-height) + var(--header-safe-top));
  }
}

html.is-standalone,
html.is-ios.is-standalone {
  --header-safe-top: max(env(safe-area-inset-top, 0px), 44px);
  --header-height: calc(var(--header-content-height) + var(--header-safe-top));
}

#app {
  display: flex;
  flex-direction: column;
  width: 100vw;
  width: 100%;
  height: 100%;
  min-height: 100%;
  min-height: -webkit-fill-available;
  min-height: 100dvh;
  height: var(--app-height, 100dvh);
  position: relative;
  overflow: hidden;
}

/* App Body Layout */
.app-container {
  display: flex;
  flex: 1;
  width: 100%;
  height: 100%;
  min-height: 100%;
  min-height: -webkit-fill-available;
  position: relative;
  overflow: hidden;
  overflow-x: clip;
  min-height: 0;
}

/* ============================================================
   Desktop Sidebar (Left) - Floating Spatial Glass Architecture
   ============================================================ */
.sidebar-left {
  width: var(--sidebar-width);
  flex-shrink: 0;
  height: 100%;
  margin: 0;
  background: rgba(9, 11, 17, 0.9);
  backdrop-filter: blur(32px) saturate(180%);
  -webkit-backdrop-filter: blur(32px) saturate(180%);
  border: none;
  border-right: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 0;
  display: flex;
  flex-direction: column;
  padding: 22px 14px 14px 14px;
  box-sizing: border-box;
  z-index: 20;
  transition: all var(--transition-smooth);
  box-shadow: none;
}

.brand-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 10px 24px 10px;
  border-bottom: 1px solid var(--glass-border);
  margin-bottom: 20px;
}

.brand-logo {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 15px var(--accent-glow);
}

.brand-logo svg {
  width: 22px;
  height: 22px;
  fill: #fff;
}

.brand-name {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(180deg, #ffffff 40%, rgba(255, 255, 255, 0.7) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-name span {
  color: var(--accent-primary);
  -webkit-text-fill-color: var(--accent-primary);
}

/* Nav Menu */
.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 6px;
  list-style: none;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14.5px;
  font-weight: 500;
  transition: all var(--transition-fast);
  cursor: pointer;
}

.nav-link svg {
  width: 20px;
  height: 20px;
  stroke-width: 2;
  transition: stroke var(--transition-fast);
}

.nav-link i {
  font-size: 16px;
  width: 20px;
  text-align: center;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.nav-link:hover i {
  color: var(--text-primary);
}

.nav-link:hover {
  color: var(--text-primary);
  background: var(--glass-bg-hover);
  transform: translateX(3px);
}

.nav-link.active {
  color: var(--accent-primary);
  background: var(--accent-glass);
  border: 1px solid var(--glass-border-accent);
  box-shadow: none;
  font-weight: 700;
  position: relative;
}

.nav-link.active::before {
  content: "";
  position: absolute;
  left: -14px;
  top: 20%;
  bottom: 20%;
  width: 3px;
  border-radius: 999px;
  background: var(--accent-gradient);
  box-shadow: 0 0 10px var(--accent-glow);
}

.nav-link.active i {
  color: var(--accent-primary);
}

/* Library Section in Sidebar */
.sidebar-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-tertiary);
  padding: 24px 12px 10px 12px;
}

.sidebar-playlists {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.playlist-nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  border: none;
}

.playlist-nav-item:hover {
  background: rgba(255,255,255,0.07);
  color: var(--text-primary);
}

.playlist-nav-item.active {
  color: var(--accent-secondary);
  background: var(--accent-glass);
  border: 1px solid var(--glass-border-accent);
  font-weight: 600;
}

/* Sidebar playlists container: import button pinned to the bottom,
   no dead empty space below it */
#sidebarPlaylistsContainer {
  display: flex;
  flex-direction: column;
  flex: 1;
}

#sidebarPlaylistsContainer > div:last-child {
  margin-top: auto !important;
  position: sticky;
  bottom: 0;
  background: transparent;
  border: none !important;
  padding-bottom: 2px;
}

/* Import-by-code button: themed to match (was white/purple foreign) */
#sidebarImportCodeBtn {
  justify-content: center !important;
  color: var(--accent-primary) !important;
  background: var(--accent-glass) !important;
  border: 1px solid var(--glass-border-accent) !important;
  border-radius: 12px !important;
  padding: 9px 10px !important;
  transition: filter 0.2s ease, transform 0.15s ease;
}

#sidebarImportCodeBtn:hover {
  filter: brightness(1.2);
}

#sidebarImportCodeBtn:active {
  transform: scale(0.97);
}

/* Import button — filled gold CTA */
#sidebarImportCodeBtn {
  background: var(--accent-gradient) !important;
  color: #0b0a07 !important;
  border: none !important;
  border-radius: 999px !important;
  padding: 11px 10px !important;
  font-weight: 800 !important;
  box-shadow: none !important;
}

#sidebarImportCodeBtn:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

#sidebarImportCodeBtn i {
  font-size: 13px;
}

/* ============================================================
   Main Content Area
   ============================================================ */
.main-viewport {
  flex: 1;
  min-width: 0;
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  background: transparent;
}

/* Top Glass Header */
.app-header {
  height: var(--header-height);
  min-height: var(--header-height);
  padding-top: var(--header-safe-top);
  padding-left: max(26px, var(--safe-left));
  padding-right: max(26px, var(--safe-right));
  padding-bottom: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--theme-header-bg, rgba(8, 10, 14, 0.65));
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  border-bottom: 1px solid var(--theme-sidebar-border, rgba(255,255,255,0.07));
  z-index: 5000 !important;
  gap: 16px;
  box-sizing: border-box;
  box-shadow: 0 2px 20px rgba(0,0,0,0.35);
  transition: background var(--transition-smooth), border-color var(--transition-smooth);
}

.search-box-wrapper {
  flex: 1;
  min-width: 0;
  max-width: 440px;
  position: relative;
  display: flex;
  align-items: center;
}

.search-box-wrapper svg,
.search-box-wrapper .search-box-icon {
  position: absolute;
  left: 14px;
  font-size: 14px;
  color: var(--text-tertiary);
  pointer-events: none;
}

.search-input {
  width: 100%;
  min-width: 0;
  height: 38px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: var(--radius-full);
  padding: 0 16px 0 40px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13.5px;
  outline: none;
  transition: all var(--transition-fast);
}

.search-input:focus {
  background: rgba(255, 255, 255, 0.09);
  border-color: rgba(255, 255, 255, 0.25);
  box-shadow: 0 0 16px rgba(255, 255, 255, 0.08);
}

.search-input::placeholder {
  color: var(--text-tertiary);
}

/* Header Actions (Spotify / Apple Music macOS Luxury Design) */
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-header-action {
  height: 36px;
  padding: 0 14px;
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 9999px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 12.5px;
  font-weight: 550;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-header-action i {
  font-size: 13.5px;
  color: rgba(255, 255, 255, 0.68);
  transition: color 0.2s ease, transform 0.2s ease;
}

.btn-header-action:hover {
  background: rgba(255, 255, 255, 0.10);
  border-color: rgba(255, 255, 255, 0.20);
  color: #ffffff;
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.btn-header-action:hover i {
  color: #ffffff;
  transform: scale(1.08);
}

.btn-header-action:active {
  transform: scale(0.96);
}

.btn-header-upload {
  height: 36px;
  padding: 0 16px;
  border-radius: 9999px;
  font-size: 12.5px;
  font-weight: 600;
  gap: 7px;
  background: var(--accent-gradient);
  color: #ffffff;
  border: 1px solid var(--glass-border-accent);
  box-shadow: 0 4px 14px var(--accent-glow);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-header-upload i {
  font-size: 13.5px;
}

.btn-header-upload:hover {
  transform: translateY(-1px) scale(1.02);
  box-shadow: 0 6px 20px var(--accent-glow-strong);
}

.btn-header-upload:active {
  transform: scale(0.96);
}

/* Main Content Scrollable */
.content-scrollable {
  position: relative;
  z-index: 1;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 24px 36px 140px 36px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}

.content-scrollable::-webkit-scrollbar {
  width: 8px;
}

.content-scrollable::-webkit-scrollbar-track {
  background: transparent;
}

.content-scrollable::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 4px;
}

.content-scrollable::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.35);
}

/* ============================================================
   Right Sidebar (Friends Activity / Jam) - Hidden by default for expansive layout
   ============================================================ */
.sidebar-right {
  display: none !important;
}

/* Mobile & Tablet Specific Elements */
.mobile-bottom-nav {
  display: none;
}

.mobile-header-brand {
  display: none;
}

/* ============================================================
   RESPONSIVE BREAKPOINTS: iPad & Tablet (<=1024px)
   ============================================================ */
@media (max-width: 1024px) {
  :root {
    --sidebar-width: 200px;
    --friends-sidebar-width: 0px;
  }

  .sidebar-right {
    display: none;
  }

  .content-scrollable {
    padding: 20px 20px 160px 20px;
  }

  .header-actions #headerTransferBtn span,
  .header-actions #headerWrappedBtn span,
  .header-actions #headerImportUrlBtn span {
    display: none;
  }

  .header-actions #headerTransferBtn,
  .header-actions #headerWrappedBtn,
  .header-actions #headerImportUrlBtn {
    padding: 8px;
    min-width: 36px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    justify-content: center;
  }
}

/* ============================================================
   RESPONSIVE BREAKPOINTS: Small tablet (<=1100px) — icon rail
   ============================================================ */
@media (max-width: 1100px) {
  .sidebar-left {
    width: 78px;
    padding: 18px 10px 12px;
  }
  .sidebar-left .brand-header {
    padding: 0 0 16px 0;
    margin-bottom: 14px;
    justify-content: center;
  }
  .sidebar-left .brand-header .brand-wordmark {
    font-size: 24px;
  }
  .sidebar-left .brand-header .letter-music {
    display: none;
  }
  .sidebar-left .nav-link {
    justify-content: center;
    gap: 0;
    padding: 11px 0;
  }
  .sidebar-left .nav-link span {
    display: none;
  }
  .sidebar-left .sidebar-section-title,
  .sidebar-left .sidebar-playlists {
    display: none;
  }
  #sidebarImportCodeBtn {
    font-size: 0 !important;
    justify-content: center !important;
    padding: 8px 0 !important;
  }
}

.mobile-nav-dock-wrapper {
  display: none;
}

/* ============================================================
   RESPONSIVE BREAKPOINTS: iPhone & Mobile (<=768px)
   ============================================================ */
@media (max-width: 768px) {
  :root {
    --header-safe-top: env(safe-area-inset-top, 0px);
    --header-content-height: 56px;
    --header-height: calc(var(--header-content-height) + var(--header-safe-top));
    --bottom-player-height: 64px;
    --bottom-nav-height: 56px;
  }

  @media (display-mode: standalone) {
    :root {
      --header-safe-top: max(env(safe-area-inset-top, 0px), 48px);
      --header-height: calc(var(--header-content-height) + var(--header-safe-top));
    }
  }

  .sidebar-left, .sidebar-right {
    display: none !important;
  }

  .mobile-header-brand {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
  }

  .mobile-header-brand .brand-logo {
    width: 28px;
    height: 28px;
    border-radius: 8px;
  }

  .mobile-header-brand .brand-name {
    font-size: 15px;
  }

  .app-header {
    position: relative;
    z-index: 1000;
    padding-top: var(--header-safe-top);
    padding-left: max(16px, var(--safe-left));
    padding-right: max(16px, var(--safe-right));
    padding-bottom: 0;
    gap: 8px;
    height: var(--header-height);
    min-height: var(--header-height);
    box-sizing: border-box;
    backdrop-filter: blur(12px) saturate(160%) !important;
    -webkit-backdrop-filter: blur(12px) saturate(160%) !important;
    flex-shrink: 0;
  }

  .search-box-wrapper {
    max-width: none;
    flex: 1;
    min-width: 0;
  }

  .search-input {
    height: 36px;
    font-size: 13px;
    padding: 0 10px 0 34px;
    border-radius: 18px;
  }

  .search-box-wrapper svg {
    left: 12px;
    width: 14px;
    height: 14px;
  }

  /* Hide text labels on header buttons, hide transfer, url import, wrapped & duplicate boost on mobile */
  .header-actions .btn span,
  .btn-header-action span,
  .btn-header-upload span {
    display: none;
  }

  .header-actions #headerWrappedBtn,
  .header-actions #headerBoostToggleBtn,
  .header-actions #headerImportUrlBtn {
    display: none !important;
  }

  .header-actions #headerTransferBtn {
    display: flex !important;
    color: #1ed760;
  }

  .header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
  }

  .btn-header-action,
  .btn-header-upload,
  .header-actions #headerAddMusicBtn {
    padding: 0;
    min-width: 36px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
  }

  @media (max-width: 600px) {
    .search-box-wrapper {
      display: none !important;
    }
    .app-header {
      justify-content: space-between !important;
    }
  }

  /* User profile widget compact */
  .user-profile-btn .user-header-name,
  .user-profile-btn .user-chevron {
    display: none;
  }

  .user-profile-btn {
    padding: 2px !important;
  }

  .user-dropdown-menu {
    right: 0;
    left: auto;
    width: min(230px, calc(100vw - 24px));
    min-width: 0;
    max-height: calc(100dvh - var(--header-height) - 24px);
    overflow-y: auto;
    overscroll-behavior: contain;
    background: rgba(16, 17, 23, 0.98);
    z-index: 1100;
  }

  .app-container {
    height: 100%;
    position: relative;
  }

  .content-scrollable {
    padding: 14px 14px calc(140px + env(safe-area-inset-bottom, 20px)) 14px !important;
    -webkit-overflow-scrolling: touch;
    box-sizing: border-box;
  }

  /* Mobile Floating Glass Dock (iOS 18 Liquid Glass Island) */
  .mobile-nav-dock-wrapper {
    display: flex !important;
    align-items: center;
    justify-content: center;
    gap: 8px;
    position: fixed;
    bottom: max(18px, calc(env(safe-area-inset-bottom, 0px) - 4px));
    left: max(12px, env(safe-area-inset-left, 12px));
    right: max(12px, env(safe-area-inset-right, 12px));
    max-width: 440px;
    margin: 0 auto;
    z-index: 40;
    pointer-events: auto;
  }

  .mobile-nav-dock-wrapper::before {
    content: "";
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(120px + env(safe-area-inset-bottom, 0px));
    background: linear-gradient(to top, var(--bg-main, #08080a) 40%, rgba(8, 8, 10, 0.85) 65%, transparent 100%);
    pointer-events: none;
    z-index: -1;
  }

  .mobile-bottom-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex: 1;
    height: 52px;
    padding: 3px 5px;
    background: rgba(18, 18, 24, 0.78);
    backdrop-filter: blur(36px) saturate(210%);
    -webkit-backdrop-filter: blur(36px) saturate(210%);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 9999px;
    box-shadow: 
      0 14px 36px rgba(0, 0, 0, 0.6),
      0 2px 8px rgba(0, 0, 0, 0.25),
      inset 0 1px 1px rgba(255, 255, 255, 0.2);
    overflow: hidden;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    gap: 3px;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease, border-color 0.25s ease;
  }

  /* Active Scrubbing / Long-Press Drag Mode (Apple Music Fluid Island) */
  .mobile-bottom-nav.is-scrubbing {
    transform: scale(1.025);
    border-color: rgba(var(--accent-rgb, 230, 57, 86), 0.42) !important;
    box-shadow: 
      0 18px 45px rgba(0, 0, 0, 0.65),
      0 0 24px rgba(var(--accent-rgb, 230, 57, 86), 0.32),
      inset 0 1px 1px rgba(255, 255, 255, 0.35) !important;
  }

  .mobile-bottom-nav.is-scrubbing .mobile-tab-btn {
    transition: 
      flex 0.2s cubic-bezier(0.2, 0.9, 0.3, 1), 
      padding 0.2s cubic-bezier(0.2, 0.9, 0.3, 1), 
      background 0.15s ease, 
      border-color 0.15s ease, 
      box-shadow 0.18s ease !important;
  }

  .mobile-bottom-nav.is-scrubbing .mobile-tab-btn span {
    transition: 
      max-width 0.2s cubic-bezier(0.2, 0.9, 0.3, 1), 
      opacity 0.15s ease, 
      margin-inline-start 0.2s cubic-bezier(0.2, 0.9, 0.3, 1) !important;
  }

  .mobile-nav-search-btn {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(18, 18, 24, 0.78);
    backdrop-filter: blur(36px) saturate(210%);
    -webkit-backdrop-filter: blur(36px) saturate(210%);
    border: 1px solid rgba(255, 255, 255, 0.14);
    box-shadow: 
      0 14px 36px rgba(0, 0, 0, 0.6),
      0 2px 8px rgba(0, 0, 0, 0.25),
      inset 0 1px 1px rgba(255, 255, 255, 0.2);
    color: #ffffff;
    font-size: 16.5px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.2s ease, box-shadow 0.2s ease;
  }

  .mobile-nav-search-btn:active {
    transform: scale(0.9);
    background: rgba(45, 42, 58, 0.92);
  }

  .mobile-tab-btn {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 0;
    flex: 1 1 0px;
    min-width: 38px;
    height: 44px;
    background: transparent;
    border: 1px solid transparent;
    color: rgba(255, 255, 255, 0.58);
    cursor: pointer;
    padding: 0 4px;
    border-radius: 9999px;
    -webkit-tap-highlight-color: transparent;
    position: relative;
    transition: 
      flex 0.32s cubic-bezier(0.34, 1.56, 0.64, 1), 
      padding 0.32s cubic-bezier(0.34, 1.56, 0.64, 1), 
      background 0.25s ease, 
      border-color 0.25s ease, 
      box-shadow 0.25s ease, 
      transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), 
      color 0.25s ease;
  }

  .mobile-tab-btn svg,
  .mobile-tab-btn i {
    font-size: 17px;
    margin: 0;
    flex-shrink: 0;
    color: rgba(255, 255, 255, 0.58);
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), color 0.2s ease;
  }

  .mobile-tab-btn span {
    max-width: 0;
    opacity: 0;
    margin-inline-start: 0;
    transform: scale(0.85);
    overflow: hidden;
    white-space: nowrap;
    pointer-events: none;
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: -0.2px;
    color: #ffffff;
    transition: 
      max-width 0.32s cubic-bezier(0.34, 1.56, 0.64, 1), 
      opacity 0.22s ease, 
      margin-inline-start 0.32s cubic-bezier(0.34, 1.56, 0.64, 1), 
      transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
  }

  /* Expanding Active Pill (Apple Music iOS 18 Dynamic Floating Island) */
  .mobile-tab-btn.active {
    flex: 1.35 0 auto !important;
    min-width: 68px;
    padding: 0 10px !important;
    background: rgba(255, 255, 255, 0.12) !important;
    border: 1px solid rgba(255, 255, 255, 0.22) !important;
    box-shadow: 
      0 4px 16px rgba(0, 0, 0, 0.35), 
      inset 0 1px 1px rgba(255, 255, 255, 0.28) !important;
    color: #ffffff !important;
  }

  .mobile-tab-btn.active svg,
  .mobile-tab-btn.active i {
    color: #ffffff !important;
    transform: scale(1.08);
  }

  .mobile-tab-btn.active span {
    max-width: 60px;
    opacity: 1;
    margin-inline-start: 5px;
    transform: scale(1);
    color: #ffffff !important;
  }

  .mobile-tab-btn:active {
    transform: scale(0.92) !important;
  }

  /* --- Hero Banner Mobile --- */
  .hero-banner {
    padding: 22px 18px;
    border-radius: var(--radius-md);
    margin-bottom: 22px;
    flex-direction: column;
    align-items: flex-start;
  }

  .hero-banner::after {
    width: 200px;
    height: 200px;
    top: -30%;
    right: -10%;
  }

  .hero-title {
    font-size: 22px;
  }

  .hero-desc {
    font-size: 13px;
  }

  .hero-actions {
    flex-wrap: wrap;
    gap: 8px;
  }

  .hero-actions .btn {
    font-size: 12.5px;
    padding: 8px 14px;
  }

  /* --- Cards Grid Mobile --- */
  .cards-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 24px;
    width: 100%;
  }

  .music-card {
    padding: 10px;
    height: 100%;
    display: flex;
    flex-direction: column;
  }

  .card-img-wrapper {
    width: 100%;
    aspect-ratio: 1/1;
    margin-bottom: 8px;
    border-radius: 10px;
    overflow: hidden;
  }

  .card-img-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  .card-title {
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .card-subtitle {
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* --- Track Rows Mobile (Flex Layout) --- */
  .track-row {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    gap: 12px;
    border-radius: 10px;
  }

  .track-num-cell,
  .track-number-cell,
  .track-album-cell {
    display: none !important;
  }

  .track-title-info {
    display: flex !important;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
    overflow: hidden;
  }

  .track-thumbnail {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
  }

  .track-thumbnail img {
    width: 44px;
    height: 44px;
    object-fit: cover;
    display: block;
  }

  .track-meta-text {
    display: flex !important;
    flex-direction: column;
    min-width: 0;
    flex: 1;
    overflow: hidden;
  }

  .track-title-cell {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: inline-flex;
    align-items: center;
    max-width: 100%;
  }

  .track-artist-cell {
    font-size: 12px;
    color: var(--text-tertiary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: inline-block !important;
    width: fit-content !important;
    max-width: 100% !important;
    align-self: flex-start !important;
    margin-top: 2px;
  }

  .track-duration-cell {
    display: flex !important;
    align-items: center;
    justify-content: flex-end;
    font-size: 12px;
    color: var(--text-tertiary);
    min-width: 42px;
    margin-right: 6px;
    flex-shrink: 0;
  }

  .track-actions-cell {
    display: flex !important;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    min-width: max-content;
  }

  .track-actions-cell [data-queue-track] {
    display: none !important;
  }

  .track-actions-cell .btn-icon {
    width: 32px !important;
    height: 32px !important;
    font-size: 14px;
  }

  /* --- Section Headers Mobile --- */
  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .section-title {
    font-size: 17px;
  }

  /* --- Modals Mobile --- */
  .modal-box {
    max-width: 95vw;
    max-height: 90vh;
    margin: 10px;
    padding: 20px;
  }

  .auth-modal-box {
    max-width: 95vw;
  }

  /* --- Playlist View Mobile --- */
  .playlist-sort-select {
    font-size: 11px;
    padding: 5px 30px 5px 10px;
  }
}

/* ============================================================
   RESPONSIVE BREAKPOINTS: Very Small Screens (<=400px)
   ============================================================ */
@media (max-width: 400px) {
  .cards-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .hero-title {
    font-size: 19px;
  }

  .hero-banner {
    padding: 16px 14px;
  }

  .content-scrollable {
    padding: 10px 10px calc(210px + env(safe-area-inset-bottom, 24px)) 10px !important;
  }

  .header-actions #headerWrappedBtn,
  .header-actions #headerImportUrlBtn {
    display: none;
  }

  .header-actions #headerTransferBtn {
    display: flex !important;
    color: #1ed760;
  }
}

/* ============================================================
   RESPONSIVE BREAKPOINTS: Small phones (<=480px)
   6-tab dock + floating player must fit 360-393px widths
   ============================================================ */
@media (max-width: 480px) {
  .mobile-nav-dock-wrapper {
    left: max(8px, env(safe-area-inset-left, 8px));
    right: max(8px, env(safe-area-inset-right, 8px));
    gap: 6px;
  }
  .mobile-bottom-nav {
    height: 52px;
    padding: 3px 4px;
    gap: 2px;
  }
  .mobile-tab-btn {
    height: 42px;
    min-width: 32px;
    padding: 0 4px;
  }
  .mobile-tab-btn svg,
  .mobile-tab-btn i {
    font-size: 15px;
  }
  .mobile-tab-btn.active {
    min-width: 78px;
    padding: 0 10px !important;
  }
  .mobile-tab-btn.active span {
    font-size: 11px;
    letter-spacing: -0.3px;
  }
  .mobile-nav-search-btn {
    width: 48px;
    height: 48px;
    font-size: 15px;
  }
  /* Free header space: search overlay + avatar stay, transfer hides */
  .header-actions #headerTransferBtn {
    display: none !important;
  }
}

/* ============================================================
   PLAYLIST OVERVIEW & MOBILE QUICK SWITCHER
   ============================================================ */
.playlist-card-item {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 12px;
  cursor: pointer;
  transition: all 0.25s ease;
  position: relative;
  display: flex;
  flex-direction: column;
}

.playlist-card-item:hover,
.playlist-card-item:active {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.18);
  transform: translateY(-2px);
}

.playlist-card-item.smart-card:hover,
.playlist-card-item.smart-card:active {
  border-color: rgba(var(--accent-rgb, 223, 183, 108), 0.4);
}

.playlist-card-quick-play-btn:hover {
  transform: scale(1.1);
  filter: brightness(1.1);
}

.playlist-quick-switcher:focus {
  border-color: var(--accent-primary) !important;
}

@media (max-width: 480px) {
  .playlists-cards-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
  }
  .smart-playlists-grid {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }
}

/* ============================================================
   GUARANTEED iOS PWA STANDALONE CLEARANCE (Share to Home Screen)
   status-bar-style = black-translucent -> status bar is transparent
   and overlaps page content. We fix the visible black strip by:
   1) painting a ::before over the status-bar zone in the header colour
   2) making the header background fully opaque at the top
   ============================================================ */

/* 1. Remove artificial top overlay / shadow so header theme flows seamlessly to top edge */
html.is-standalone body::before,
html.is-ios.is-standalone body::before {
  display: none !important;
  content: none !important;
}

/* 2. Extend the header to cover the full status-bar + content zone */
html.is-standalone .app-header,
html.is-ios.is-standalone .app-header {
  padding-top: max(env(safe-area-inset-top, 0px), 48px) !important;
  height: calc(56px + max(env(safe-area-inset-top, 0px), 48px)) !important;
  min-height: calc(56px + max(env(safe-area-inset-top, 0px), 48px)) !important;
  padding-bottom: 0 !important;
  margin-top: 0 !important;
}

html.is-standalone .sidebar-left,
html.is-ios.is-standalone .sidebar-left {
  padding-top: calc(20px + max(env(safe-area-inset-top, 0px), 44px)) !important;
}

/* ============================================================
   Mobile Quick Search Overlay — Spotify-style slide-down
   ============================================================ */
.mobile-search-overlay {
  position: fixed;
  inset: 0;
  z-index: 9800;
  background: rgba(8, 8, 16, 0.72);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.mobile-search-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.mobile-search-overlay-inner {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  transform: translateY(-18px);
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

.mobile-search-overlay.open .mobile-search-overlay-inner {
  transform: translateY(0);
}

/* Search bar row */
.mobile-search-bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px 10px;
  padding-top: calc(14px + env(safe-area-inset-top, 0px));
  flex-shrink: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.mobile-search-field-wrap {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

.mobile-search-field-icon {
  position: absolute;
  left: 14px;
  color: rgba(255, 255, 255, 0.45);
  font-size: 15px;
  pointer-events: none;
  z-index: 1;
}

.mobile-search-field-input {
  width: 100%;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  padding: 12px 44px 12px 42px;
  color: #ffffff;
  font-size: 16px;
  font-weight: 500;
  font-family: inherit;
  outline: none;
  transition: border-color 0.18s ease, background 0.18s ease;
  -webkit-appearance: none;
}

.mobile-search-field-input::placeholder {
  color: rgba(255, 255, 255, 0.38);
}

.mobile-search-field-input:focus {
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.13);
}

.mobile-search-field-clear {
  position: absolute;
  right: 10px;
  width: 28px;
  height: 28px;
  background: rgba(255, 255, 255, 0.15);
  border: none;
  border-radius: 50%;
  color: rgba(255, 255, 255, 0.75);
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}

.mobile-search-field-clear:active {
  background: rgba(255, 255, 255, 0.25);
}

.mobile-search-cancel-btn {
  background: transparent;
  border: none;
  color: var(--accent-primary, #a78bfa);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 2px;
  white-space: nowrap;
  font-family: inherit;
  flex-shrink: 0;
}

.mobile-search-cancel-btn:active {
  opacity: 0.7;
}

/* Results scroll area */
.mobile-search-results-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 0 120px;
  -webkit-overflow-scrolling: touch;
}

.mobile-search-results-scroll .track-list {
  padding: 0 8px;
}

.mobile-search-results-scroll .section-header {
  padding: 0 16px;
  margin-top: 8px;
}

.mobile-search-results-scroll .section-title {
  font-size: 15px !important;
}

/* Quick results section labels */
.mobile-search-section-label {
  font-size: 12px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.45);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 14px 16px 6px;
}

/* Artist quick card in overlay */
.mobile-search-artist-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  cursor: pointer;
  border-radius: 12px;
  margin: 0 8px;
  transition: background 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.mobile-search-artist-row:active {
  background: rgba(255, 255, 255, 0.08);
}

.mobile-search-artist-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: rgba(255,255,255,0.06);
}

.mobile-search-artist-name {
  font-size: 14px;
  font-weight: 600;
  color: #fff;
}

.mobile-search-artist-sub {
  font-size: 12px;
  color: rgba(255,255,255,0.45);
  margin-top: 1px;
}

/* Empty / loading state */
.mobile-search-empty {
  text-align: center;
  padding: 48px 24px;
  color: rgba(255,255,255,0.38);
  font-size: 14px;
  line-height: 1.6;
}

.mobile-search-empty i {
  font-size: 36px;
  margin-bottom: 14px;
  display: block;
  color: rgba(255,255,255,0.18);
}
