/* ============================================================
   Any Listen Web — Responsive Desktop & iPhone UI Enhancement v2
   Non-destructive overlay for /opt/any-listen/public/
   ============================================================ */

/* 1. True Full-Viewport Shell (Desktop & Mobile, Zero 8px Margin!) */
html,
html.web,
html.web:not(.fullscreen),
html.web.fullscreen {
  width: 100vw !important;
  height: 100dvh !important;
  min-width: 0 !important;
  min-height: 0 !important;
  max-width: 100vw !important;
  max-height: 100dvh !important;
  padding: 0 !important;
  margin: 0 !important;
  box-sizing: border-box !important;
  overflow: hidden !important;
  background-color: var(--color-content-background, #ffffff) !important;
  -webkit-tap-highlight-color: transparent;
}

body,
#body,
html.web body#body {
  position: fixed !important;
  inset: 0 !important;
  width: 100vw !important;
  height: 100dvh !important;
  min-width: 0 !important;
  min-height: 0 !important;
  max-width: 100vw !important;
  max-height: 100dvh !important;
  padding: 0 !important;
  margin: 0 !important;
  box-sizing: border-box !important;
  overflow: hidden !important;
  background-color: var(--color-content-background, #ffffff) !important;
}

html.web #root {
  width: 100% !important;
  height: 100% !important;
  min-width: 0 !important;
  min-height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}

/* Hide Electron window-frame buttons (minimize/maximize/fullscreen) on Web while KEEPING 退出登录 (.close) & 隐藏详情页 (∨) */
html.web .control.svelte-jb5pue button.fullscreen,
html.web .control.svelte-jb5pue button.min,
html.web .control.svelte-jb5pue button.max,
html.web .control.svelte-jb5pue button[aria-label*="最小化"],
html.web .control.svelte-jb5pue button[aria-label*="最大化"],
html.web .control.svelte-jb5pue button[title*="最小化"],
html.web .control.svelte-jb5pue button[title*="最大化"],
html.web .header.svelte-14jgc0t .control-btn button[aria-label*="最大化"],
html.web .header.svelte-14jgc0t .control-btn button[title*="最大化"],
html.web .header.svelte-14jgc0t .control-btn button[aria-label*="全屏"],
html.web .header.svelte-14jgc0t .control-btn button[title*="全屏"] {
  display: none !important;
}

/* 2. Desktop Polished Proportions (>= 768px) */
html.web #app-main.svelte-fm5c1i {
  width: 100% !important;
  height: 100% !important;
  min-width: 0 !important;
  min-height: 0 !important;
}

html.web .aside.svelte-1mbt8pj {
  width: 248px !important;
  min-width: 220px !important;
  max-width: 270px !important;
  border-right: 1px solid rgba(128, 128, 128, 0.12);
  padding-top: 4px;
}

html.web .aside-logo.svelte-18p7iss {
  padding: 16px 18px 12px !important;
}

html.web .aside-nav.svelte-15j5r14 {
  gap: 2px;
  padding: 0 10px !important;
}

html.web .link.svelte-15j5r14 {
  padding: 9px 12px !important;
  border-radius: 8px !important;
}

html.web .nav-name.svelte-15j5r14 {
  font-size: 0.875rem !important;
  font-weight: 500;
}

html.web .container.svelte-b9d5nj {
  padding: 6px 8px !important;
  border-radius: 8px !important;
}

/* Top Toolbar & Search */
html.web .toolbar.svelte-dhtsck {
  height: 56px !important;
  padding: 0 16px !important;
  gap: 10px;
  border-bottom: 1px solid rgba(128, 128, 128, 0.08);
}

html.web .left.svelte-dhtsck {
  margin-left: 0 !important;
  gap: 10px;
}

html.web .control.svelte-jb5pue {
  align-self: center !important;
  height: auto !important;
}

html.web .search-input.svelte-1hua9vn {
  width: min(460px, 60%) !important;
  height: 36px !important;
}

html.web .content.svelte-1hua9vn {
  border-radius: 10px !important;
}

html.web .content.svelte-1hua9vn .form {
  height: 36px !important;
}

html.web .content.svelte-1hua9vn .form input {
  padding: 0 10px !important;
  font-size: 0.875rem !important;
}

/* Song List Rows — Better Hierarchy & Clickability */
html.web .container.svelte-1dhc9l1 {
  padding: 6px 10px !important;
  border-radius: 8px !important;
  font-size: 0.875rem !important;
  cursor: pointer;
}

html.web .name-left.svelte-1dhc9l1 > .name {
  font-size: 0.9rem !important;
  font-weight: 500;
}

html.web .name-right.svelte-1dhc9l1 .play-btn,
html.web .auto-hide-btns.svelte-1dhc9l1 button {
  min-width: 32px;
  min-height: 32px;
  border-radius: 6px !important;
}

/* Bottom Player Bar — Frosted Glass & Easier Controls */
html.web .player.svelte-18mk1p6 {
  height: 76px !important;
  border-top: 1px solid rgba(128, 128, 128, 0.12);
}

html.web .bg.svelte-18mk1p6 {
  border-radius: 0 !important;
  backdrop-filter: blur(18px) !important;
  -webkit-backdrop-filter: blur(18px) !important;
  opacity: 0.94 !important;
}

html.web .player-inner.svelte-18mk1p6 {
  padding: 0 14px 0 8px !important;
  gap: 6px;
}

html.web .container.svelte-1mq6s44 {
  gap: 14px !important;
}

html.web .btn.svelte-1mq6s44 {
  padding: 6px !important;
  border-radius: 50%;
}

html.web .btn.svelte-1mq6s44:hover {
  background-color: var(--color-primary-background-hover, rgba(79, 98, 208, 0.12));
}

html.web .slider-content.svelte-12lutbp {
  height: 6px !important;
}

/* Play Detail Overlay — Full-Viewport & Easy-to-Tap Collapse Button */
html.web .play-detail.svelte-1npbac6 {
  border-radius: 0 !important;
}

html.web .header.svelte-14jgc0t .control-btn button {
  width: 44px !important;
  height: 44px !important;
  border-radius: 10px;
  margin: 4px;
}

/* Mobile Menu Button (hidden on Desktop) */
#al-mobile-menu-btn {
  display: none;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  margin: 0;
  border: none;
  border-radius: 10px;
  background: var(--color-primary-light-300-alpha-700, rgba(79, 98, 208, 0.12));
  color: var(--color-primary-font, #4f62d0);
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.15s ease;
}

#al-mobile-menu-btn:active {
  transform: scale(0.94);
}

/* Drawer Backdrop — mounted INSIDE #app-main below .aside (z-index 60) */
#al-drawer-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(15, 18, 30, 0.45);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity 0.25s ease;
}

#al-drawer-backdrop.open {
  display: block;
  opacity: 1;
}

/* ============================================================
   3. iPhone & Mobile Responsive Layout (< 768px)
   ============================================================ */
@media (max-width: 767px) {
  /* Safe-area top padding on toolbar */
  html.web .toolbar.svelte-dhtsck {
    height: calc(56px + env(safe-area-inset-top, 0px)) !important;
    padding: env(safe-area-inset-top, 0px) 12px 0 12px !important;
  }

  #al-mobile-menu-btn {
    display: inline-flex;
  }

  html.web .left.svelte-dhtsck {
    width: 100% !important;
    min-width: 0 !important;
  }

  html.web .search-input.svelte-1hua9vn {
    flex: 1 1 auto !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    height: 38px !important;
  }

  /* Prevent iOS Safari zoom on input focus (>= 16px) */
  html.web input,
  html.web textarea,
  html.web select {
    font-size: 16px !important;
  }

  /* Slide-Out Drawer Sidebar — MUST stack ABOVE #al-drawer-backdrop (z-index 50) */
  html.web .aside.svelte-1mbt8pj {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    bottom: 0 !important;
    z-index: 60 !important;
    width: min(82vw, 300px) !important;
    min-width: 0 !important;
    max-width: 300px !important;
    padding-top: env(safe-area-inset-top, 0px) !important;
    padding-bottom: env(safe-area-inset-bottom, 0px) !important;
    background-color: var(--color-content-background, #ffffff) !important;
    box-shadow: 6px 0 28px rgba(0, 0, 0, 0.22) !important;
    transform: translateX(-105%);
    transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1) !important;
  }

  html.web.al-drawer-open .aside.svelte-1mbt8pj {
    transform: translateX(0) !important;
  }

  /* Main content takes full 100% width */
  html.web #app-main.svelte-fm5c1i > :not(.aside.svelte-1mbt8pj):not(#al-drawer-backdrop) {
    width: 100% !important;
    max-width: 100vw !important;
    min-width: 0 !important;
  }

  /* Playlist Header compact on mobile */
  html.web .header.svelte-1mi6kna {
    padding: 10px 12px !important;
    gap: 10px;
    align-items: center;
  }

  html.web .left.svelte-1mi6kna {
    width: 68px !important;
    height: 68px !important;
    flex: none !important;
  }

  html.web .right.svelte-1mi6kna {
    padding-left: 4px !important;
    min-width: 0 !important;
  }

  html.web .control-btns.svelte-1mi6kna {
    margin-top: 8px !important;
    gap: 8px;
  }

  /* Hide desktop table column headers (# / 歌曲名 / 艺术家 / 专辑) on mobile */
  html.web .header.svelte-1s24m03 {
    display: none !important;
  }

  /* Song List Rows — Clean Touch-Friendly Rows */
  html.web .container.svelte-1dhc9l1 {
    padding: 6px 10px !important;
    gap: 10px !important;
  }

  html.web .container.svelte-1dhc9l1 > .list-item-cell.svelte-1dhc9l1:not(.name-cell):not(.auto) {
    display: none !important;
  }

  html.web .name-cell.svelte-1dhc9l1 {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    width: auto !important;
  }

  html.web .name-right.svelte-1dhc9l1 {
    margin: 0 2px !important;
  }

  html.web .name-right.svelte-1dhc9l1 .play-btn,
  html.web .auto-hide-btns.svelte-1dhc9l1 button {
    min-width: 36px;
    min-height: 36px;
  }

  /* Mobile Mini-Player Bar at Bottom — ZERO overlap, Apple Music layout */
  html.web .player.svelte-18mk1p6 {
    height: calc(68px + env(safe-area-inset-bottom, 0px)) !important;
    padding-bottom: env(safe-area-inset-bottom, 0px) !important;
    contain: layout style !important;
  }

  html.web .player-inner.svelte-18mk1p6 {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 68px !important;
    padding: 0 10px 0 8px !important;
    gap: 8px !important;
    contain: layout style !important;
    justify-content: space-between !important;
  }

  /* Defeat centerControl absolute centering on narrow mobile screens */
  html.web .player-inner.svelte-18mk1p6 > * {
    position: static !important;
    left: auto !important;
    right: auto !important;
    top: auto !important;
    transform: none !important;
  }

  /* Keep ONLY Cover + Title/Status + Prev/Play/Next in the 390px mini-bar */
  html.web .player-inner.svelte-18mk1p6 > *:not(.container.svelte-vc07ip):not(.container.svelte-b7rucv):not(.container.svelte-1mq6s44):not(:has(.container.svelte-vc07ip)):not(:has(.container.svelte-b7rucv)):not(:has(.container.svelte-1mq6s44)) {
    display: none !important;
  }

  /* Also hide any sibling timer/status/volume/mode/like inside nested wrappers of mini-bar */
  html.web .player-inner.svelte-18mk1p6 .middle-play-progress,
  html.web .player-inner.svelte-18mk1p6 .slider.svelte-12lutbp,
  html.web .player-inner.svelte-18mk1p6 .container.svelte-19bnt2s,
  html.web .player-inner.svelte-18mk1p6 .btn.svelte-14da0i2,
  html.web .player-inner.svelte-18mk1p6 .icon.svelte-u5t4wl {
    display: none !important;
  }

  html.web .container.svelte-vc07ip {
    padding: 8px 0 !important;
    width: 52px !important;
    height: 68px !important;
    flex: none !important;
  }

  html.web .container.svelte-b7rucv {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    padding-right: 4px !important;
    cursor: pointer;
  }

  html.web .name.svelte-b7rucv {
    font-size: 0.92rem !important;
    font-weight: 600 !important;
    color: var(--color-font) !important;
  }

  html.web .status-text.svelte-b7rucv {
    font-size: 0.78rem !important;
    color: var(--color-font-label) !important;
  }

  html.web .container.svelte-1mq6s44 {
    flex: none !important;
    gap: 4px !important;
    padding: 0 !important;
    margin-left: auto !important;
  }

  html.web .btn.svelte-1mq6s44 {
    min-width: 38px !important;
    min-height: 38px !important;
    align-items: center;
    justify-content: center;
  }

  /* Full-Screen Now Playing / Lyrics View on iPhone (Vertical Stack with Visible Cover!) */
  html.web .play-detail.svelte-1npbac6 {
    padding-top: env(safe-area-inset-top, 0px) !important;
    padding-bottom: env(safe-area-inset-bottom, 0px) !important;
    contain: layout style !important;
  }

  html.web .header.svelte-14jgc0t {
    flex: 0 0 46px !important;
  }

  html.web .player-detail-main.svelte-qg9s0d {
    flex-direction: column !important;
    align-items: center !important;
    padding: 0 16px 6px !important;
    gap: 10px !important;
  }

  /* Override contain: strict on .left-info so cover + song info actually have height! */
  html.web .left-info.svelte-1jg4ywo {
    contain: layout style !important;
    flex: 0 0 auto !important;
    width: 100% !important;
    height: auto !important;
    padding: 2px 8px 4px !important;
    gap: 8px !important;
    --content-width: 156px !important;
  }

  html.web .cover.svelte-19zh82w,
  html.web .cover.svelte-1bvklo {
    contain: layout style !important;
    width: 156px !important;
    height: 156px !important;
    max-width: 156px !important;
    margin: 0 auto !important;
  }

  /* Full-Width Readable Lyrics Below Cover */
  html.web .right-lyric.svelte-1vhqzi0 {
    width: 100% !important;
    flex: 1 1 auto !important;
    min-height: 160px !important;
  }

  html.web .lyric.svelte-1a8znui {
    --play-detail-lrc-font-size: 16px !important;
    text-align: center !important;
  }

  /* Now Playing Footer Controls & Progress Bar — ALL buttons fit cleanly in 390px! */
  html.web .footer.svelte-1ulzzfa {
    height: auto !important;
    min-height: 108px !important;
    padding-bottom: max(8px, env(safe-area-inset-bottom, 0px)) !important;
    contain: layout style !important;
  }

  html.web .footer-content.svelte-1ulzzfa {
    padding: 4px 12px 10px !important;
    gap: 6px !important;
  }

  html.web .footer-content.svelte-1ulzzfa .middle-play-progress {
    display: flex !important;
    width: 100% !important;
  }

  html.web .control.svelte-1ulzzfa {
    align-items: center !important;
    justify-content: space-between !important;
    width: 100% !important;
  }

  html.web .side.svelte-1ulzzfa {
    padding-top: 0 !important;
    min-width: 0 !important;
  }

  html.web .right.svelte-1ulzzfa {
    padding-left: 0 !important;
    margin-left: 0 !important;
  }

  html.web .container.svelte-1dr27ul {
    padding: 0 6px !important;
    gap: 10px !important;
  }

  html.web .footer-content.svelte-1ulzzfa .container.svelte-19bnt2s {
    gap: 8px !important;
  }

  /* Hide desktop volume control in iPhone detail footer (iPhone uses physical volume keys) */
  html.web .footer-content.svelte-1ulzzfa button[aria-label*="音量"],
  html.web .footer-content.svelte-1ulzzfa button[title*="音量"],
  html.web .footer-content.svelte-1ulzzfa .icon.svelte-u5t4wl,
  html.web .footer-content.svelte-1ulzzfa .slider.svelte-12lutbp {
    display: none !important;
  }

  /* Responsive Modals & Settings */
  html.web .content.svelte-b9z104 {
    max-width: calc(100vw - 24px) !important;
    max-height: 86dvh !important;
    min-width: 0 !important;
    border-radius: 14px !important;
  }

  html.web .main.svelte-1f88bl7,
  html.web .main.svelte-3wb85q {
    min-width: 0 !important;
    width: 100% !important;
  }

  html.web .aside.svelte-1prdvvi {
    width: 105px !important;
    min-width: 90px !important;
  }

  html.web .source-list.svelte-fuwb0q {
    width: 72px !important;
    min-width: 64px !important;
    margin-left: 4px !important;
  }

  html.web .list-item.svelte-phn7ew,
  html.web .list-item.svelte-1dphj55 {
    min-width: 0 !important;
  }

  html.web .list-container.svelte-1jsvf7n ul {
    grid-template-columns: 1fr !important;
    padding: 0 10px 12px !important;
  }
}
