/* Responsive Design - 响应式设计 */

/* ============================================
   Phone Fluid Design (320px → 430px)
   Uses clamp() for smooth scaling across all iPhones
   320px: iPhone SE 1st / iPod touch 7
   375px: iPhone SE 2/3, 12 mini, 6/7/8
   390px: iPhone 12/13/14
   393px: iPhone 14 Pro / 15 / 16
   414px: iPhone XR / 11 / 6+/7+/8+
   430px: iPhone 14 Pro Max / 15/16 Pro Max
   ============================================ */

@media (max-width: 768px) {
    /* -- Fluid Design Tokens: min @320px → max @430px -- */
    :root {
        /* Track covers (normal): 38px → 50px */
        --track-cover-size: clamp(38px, calc(3.09px + 10.91vw), 50px);
        /* Track covers (current-playing): 85px → 120px */
        --track-cover-playing: clamp(85px, calc(-16.82px + 31.82vw), 120px);
        /* Track title max-width: 70px → 120px */
        --track-title-maxw: clamp(70px, calc(-75.45px + 45.45vw), 120px);
        /* Track title font-size: 12px → 14px */
        --track-title-fs: clamp(12px, calc(6.18px + 1.82vw), 14px);
        /* Current-playing title font-size: 15px → 18px */
        --track-title-playing-fs: clamp(15px, calc(6.27px + 2.73vw), 18px);
        /* Full-player artwork: 200px → 300px */
        --fp-artwork-size: clamp(200px, calc(-90.91px + 90.91vw), 300px);
        /* Full-player title: 15px → 17px */
        --fp-title-fs: clamp(15px, calc(9.18px + 1.82vw), 17px);
        /* Full-player artist: 11px → 13px */
        --fp-artist-fs: clamp(11px, calc(5.18px + 1.82vw), 13px);
        /* Full-player play/pause: 50px → 56px */
        --fp-playbtn-size: clamp(50px, calc(32.55px + 5.45vw), 56px);
        /* Bottom nav height: 50px → 60px */
        --bottom-nav-h: clamp(50px, calc(20.91px + 9.09vw), 60px);
        --bottom-nav-offset: calc(var(--bottom-nav-h) + var(--safe-area-bottom));
        --content-bottom-space: calc(var(--bottom-nav-offset) + 100px);
        /* Control button size: 32px → 44px */
        --control-btn-size: clamp(32px, calc(3.09px + 10.91vw), 44px);
        /* Nav icon font-size: 24px → 30px */
        --nav-icon-fs: clamp(24px, calc(6.55px + 5.45vw), 30px);
        /* Nav label font-size: 7px → 9px */
        --nav-label-fs: clamp(7px, calc(1.18px + 1.82vw), 9px);
        /* Drag handle width: 20px → 28px */
        --drag-handle-w: clamp(20px, calc(-3.27px + 7.27vw), 28px);
        /* Player bar cover: 32px → 40px */
        --playerbar-cover: clamp(32px, calc(8.73px + 7.27vw), 40px);
        /* Modal close button: 32px → 36px */
        --modal-close-size: clamp(32px, calc(20.36px + 3.64vw), 36px);
        /* Track playlist-name max-width: 50px → 80px */
        --track-plname-maxw: clamp(50px, calc(-37.27px + 27.27vw), 80px);
    }

    /* ---- 基础布局 ---- */
    .tab-content, #tree {
        padding-top: calc(clamp(4px, 1.5vw, 8px) + var(--safe-area-top));
        padding-right: max(clamp(4px, 1.5vw, 8px), var(--safe-area-right));
        padding-bottom: var(--content-bottom-space);
        padding-left: max(clamp(4px, 1.5vw, 8px), var(--safe-area-left));
    }
    h1 { font-size: clamp(16px, 4vw, 18px); }

    /* ---- 本地文件卡片 ---- */
    .local-card-grid {
        grid-template-columns: repeat(auto-fill, minmax(clamp(100px, 30vw, 150px), 1fr));
        gap: clamp(4px, 1.5vw, 8px);
    }
    .local-card {
        flex-direction: column;
        text-align: center;
        padding: clamp(6px, 1.5vw, 8px);
        border-radius: clamp(6px, 2vw, 8px);
    }
    .local-card-icon {
        width: clamp(32px, 9vw, 40px);
        height: clamp(32px, 9vw, 40px);
        font-size: clamp(16px, 4.5vw, 20px);
    }
    .local-card-title { font-size: clamp(11px, 2.8vw, 12px); }
    .local-card-meta { font-size: clamp(9px, 2.5vw, 11px); }

    /* ---- 播放列表 ---- */
    .playlist-track-item {
        gap: clamp(6px, 1.8vw, 10px);
        padding: clamp(6px, 1.5vw, 10px);
        margin-bottom: clamp(3px, 1vw, 6px);
        border-radius: clamp(6px, 2vw, 8px);
    }
    .track-cover {
        width: var(--track-cover-size);
        height: var(--track-cover-size);
        min-width: var(--track-cover-size);
        border-radius: clamp(4px, 1.2vw, 6px);
    }
    .playlist-track-item.current-playing .track-cover {
        width: var(--track-cover-playing);
        height: var(--track-cover-playing);
        border-radius: clamp(8px, 2.5vw, 12px);
    }
    .track-title {
        font-size: var(--track-title-fs);
        max-width: var(--track-title-maxw);
        line-height: 1.3;
    }
    .playlist-track-item.current-playing .track-title {
        font-size: var(--track-title-playing-fs);
        max-width: 100%;
        -webkit-line-clamp: 2;
        max-height: clamp(45px, 12vw, 60px);
        line-height: 1.4;
    }
    .track-type { font-size: clamp(9px, 2.3vw, 11px); padding: 2px 4px; }
    .track-progress { font-size: clamp(9px, 2.3vw, 9px); }
    .track-info { gap: clamp(2px, 0.7vw, 6px); }
    .track-meta { gap: clamp(3px, 1vw, 6px); font-size: clamp(10px, 2.7vw, 12px); }
    .track-playlist-name { max-width: var(--track-plname-maxw); font-size: clamp(10px, 2.7vw, 12px); }
    .track-menu-btn {
        width: clamp(26px, 7vw, 32px);
        height: clamp(26px, 7vw, 32px);
        padding: 2px;
    }

    /* ---- 拖拽手柄 ---- */
    .drag-handle {
        width: var(--drag-handle-w);
        height: clamp(36px, 10vw, 48px);
        min-width: var(--drag-handle-w);
        opacity: 0.6;
    }
    .drag-handle svg {
        width: clamp(12px, 3.5vw, 18px);
        height: clamp(12px, 3.5vw, 18px);
    }

    /* ---- 歌单管理卡片 ---- */
    .playlist-item {
        padding: clamp(8px, 2.5vw, 12px) clamp(10px, 3vw, 14px);
        gap: clamp(8px, 2.5vw, 12px);
        border-radius: clamp(8px, 2.5vw, 12px);
    }
    .playlist-icon {
        width: clamp(38px, 10.5vw, 46px);
        height: clamp(38px, 10.5vw, 46px);
        font-size: clamp(17px, 4.5vw, 20px);
    }
    .playlist-name { font-size: clamp(13px, 3.5vw, 15px); line-height: 1.3; }
    .playlist-count { font-size: clamp(11px, 2.8vw, 12px); }
    .playlist-actions {
        gap: clamp(8px, 2.2vw, 12px);
    }
    .playlist-action-btn {
        width: clamp(40px, 10.5vw, 44px);
        height: clamp(40px, 10.5vw, 44px);
        min-width: 40px;
        min-height: 40px;
        border-radius: 12px;
        border-width: 1.5px;
        box-shadow: 0 3px 10px rgba(0, 0, 0, 0.15);
    }
    .playlist-action-btn svg {
        width: clamp(18px, 4.8vw, 21px);
        height: clamp(18px, 4.8vw, 21px);
    }
    #playlistsModal .playlist-action-btn.edit {
        background: linear-gradient(145deg, rgba(56, 189, 248, 0.2) 0%, rgba(14, 116, 144, 0.18) 100%);
        border-color: rgba(56, 189, 248, 0.5);
        color: #67e8f9;
    }
    #playlistsModal .playlist-action-btn.delete {
        background: linear-gradient(145deg, rgba(248, 113, 113, 0.2) 0%, rgba(153, 27, 27, 0.16) 100%);
        border-color: rgba(248, 113, 113, 0.55);
        color: #fca5a5;
    }
    #playlistsModal .playlist-action-btn.edit:active,
    #playlistsModal .playlist-action-btn.delete:active {
        transform: scale(0.94);
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
    }
    .default-badge { font-size: clamp(9px, 2.5vw, 11px); padding: clamp(2px, 0.6vw, 3px) clamp(5px, 1.5vw, 7px); }

    .track-seq {
        right: clamp(6px, 2vw, 10px);
        bottom: clamp(6px, 2vw, 10px);
        font-size: clamp(9px, 2.5vw, 11px);
        padding: clamp(2px, 0.7vw, 4px) clamp(5px, 1.3vw, 6px);
    }

    /* ---- 底部导航栏 ---- */
    .bottom-nav {
        height: var(--bottom-nav-offset);
        padding: 0 clamp(2px, 0.7vw, 8px) var(--safe-area-bottom);
        padding-left: max(clamp(2px, 0.7vw, 8px), var(--safe-area-left));
        padding-right: max(clamp(2px, 0.7vw, 8px), var(--safe-area-right));
    }
    .history-modal { bottom: var(--bottom-nav-offset); }
    .nav-item { padding: clamp(3px, 1vw, 4px) clamp(1px, 0.5vw, 4px); gap: clamp(1px, 0.5vw, 3px); }
    .nav-icon { font-size: var(--nav-icon-fs); }
    .nav-label { font-size: var(--nav-label-fs); }

    /* ---- 按钮 (iOS 44px touch target) ---- */
    button {
        padding: clamp(8px, 2.3vw, 10px) clamp(10px, 2.8vw, 12px);
        font-size: clamp(11px, 2.8vw, 12px);
        border-radius: 6px;
        min-height: clamp(38px, 10.5vw, 44px);
    }

    /* ---- 标签页 ---- */
    .tab-btn {
        padding: clamp(8px, 2.5vw, 10px);
        font-size: clamp(11px, 2.8vw, 12px);
    }

    /* ---- 模态框 ---- */
    .modal-header, .playlists-modal-header, .search-modal-header,
    .history-modal-header, .youtube-search-modal-header, .now-playing-header {
        padding-top: calc(clamp(10px, 2.8vw, 12px) + var(--safe-area-top));
        padding-right: max(clamp(10px, 2.8vw, 12px), var(--safe-area-right));
        padding-bottom: clamp(10px, 2.8vw, 12px);
        padding-left: max(clamp(10px, 2.8vw, 12px), var(--safe-area-left));
    }
    .modal-title, .playlists-modal-header h2,
    .search-modal-header h3, .history-modal-header h3 {
        font-size: clamp(16px, 4.2vw, 18px);
    }
    .modal-close, .history-modal-close,
    .playlists-back-btn, .playlists-add-btn,
    .search-modal-back, .full-player-back, .now-playing-close {
        width: var(--modal-close-size);
        height: var(--modal-close-size);
        font-size: clamp(16px, 4.2vw, 20px);
    }

    .search-modal-back, .playlists-close-btn {
        width: auto;
        min-width: 44px;
        min-height: 44px;
        height: auto;
        padding: 0 clamp(10px, 2.8vw, 14px);
        border-radius: 999px;
        gap: 6px;
        background: linear-gradient(135deg, var(--accent-color, #1e90ff), var(--accent-color-hover, #1565c0));
        color: #fff;
        box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
        font-size: clamp(13px, 3.2vw, 15px);
        font-weight: 600;
    }

    .search-modal-back .search-modal-back-icon {
        font-size: clamp(16px, 4vw, 18px);
    }

    .search-modal-back:active, .playlists-close-btn:active {
        transform: translateY(1px) scale(0.98);
    }

    /* ---- 歌单管理模态框：手机优化 ---- */
    .playlists-modal-header {
        gap: 10px;
    }

    /* 关闭按钮移至左侧，对齐搜索页面返回按钮 */
    .playlists-close-btn {
        order: -1;
        border: none;
        cursor: pointer;
        display: inline-flex;
        align-items: center;
        margin-left: 0;
    }

    /* 新建按钮：手机端也变为胶囊样式 */
    .playlists-add-btn {
        order: 1;
        width: auto;
        min-width: 44px;
        min-height: 44px;
        height: auto;
        padding: 0 clamp(10px, 2.8vw, 14px);
        border-radius: 999px;
        margin-left: 0;
        background: rgba(255, 255, 255, 0.1);
        border: 1px solid rgba(255, 255, 255, 0.15);
        font-size: clamp(13px, 3.2vw, 15px);
        font-weight: 600;
        gap: 5px;
    }

    .playlists-add-btn:hover {
        background: rgba(255, 255, 255, 0.18);
        transform: none;
    }

    .playlists-add-btn:active {
        transform: translateY(1px) scale(0.98);
    }

    .playlists-add-btn svg {
        width: clamp(16px, 4vw, 18px);
        height: clamp(16px, 4vw, 18px);
        flex-shrink: 0;
    }

    .playlists-modal-header h2 {
        order: 0;
        font-size: clamp(15px, 4vw, 18px);
    }

    .modal-body, .playlists-modal-body, .search-modal-body,
    .history-modal-body {
        padding: clamp(8px, 2.5vw, 12px);
        padding-bottom: clamp(60px, 16vw, 70px);
    }

    /* ---- 播放栏 ---- */
    .player-bar {
        gap: clamp(6px, 2vw, 10px);
        padding: clamp(3px, 1vw, 6px) clamp(5px, 1.5vw, 6px);
    }
    .player-cover {
        width: var(--playerbar-cover);
        height: var(--playerbar-cover);
        border-radius: clamp(4px, 1.2vw, 6px);
    }
    .player-info { gap: 2px; }
    .player-title { font-size: clamp(11px, 3vw, 13px); }
    .player-artist { font-size: clamp(9px, 2.3vw, 10px); }

    /* ---- 播放控制 ---- */
    .footer-controls-left, .footer-controls-right { gap: clamp(4px, 1.3vw, 6px); }
    .control-btn {
        width: var(--control-btn-size);
        height: var(--control-btn-size);
        min-width: var(--control-btn-size);
        min-height: var(--control-btn-size);
        font-size: clamp(13px, 3.5vw, 16px);
        padding: 0;
    }
    .play-pause-large {
        width: clamp(42px, 11.5vw, 48px);
        height: clamp(42px, 11.5vw, 48px);
        font-size: clamp(16px, 4.2vw, 18px);
    }

    /* ---- 全屏播放器 ---- */
    .full-player { padding: clamp(8px, 2.5vw, 12px); }
    .full-player-artwork-container {
        width: min(var(--fp-artwork-size), 95vw);
        height: min(var(--fp-artwork-size), 95vw);
    }
    .full-player-artwork-placeholder { font-size: clamp(60px, 18vw, 80px); }
    .full-player-info { padding: clamp(8px, 2.5vw, 16px) 0; }
    .full-player-title { font-size: var(--fp-title-fs); margin-bottom: clamp(4px, 1vw, 8px); }
    .full-player-artist { font-size: var(--fp-artist-fs); }
    .full-player-playlist { font-size: clamp(10px, 2.5vw, 13px); }
    .full-player-progress-section { padding: clamp(8px, 2.5vw, 16px) 0; }
    .full-player-progress-bar { height: clamp(4px, 1.2vw, 5px); margin-bottom: clamp(6px, 2vw, 10px); }
    .full-player-progress-thumb { width: clamp(12px, 3.5vw, 14px); height: clamp(12px, 3.5vw, 14px); }
    .full-player-time { font-size: clamp(11px, 2.8vw, 13px); }
    .full-player-controls-grid { gap: clamp(12px, 3.5vw, 16px); padding: clamp(8px, 2.5vw, 24px) 0; }
    .full-player-control-btn { font-size: clamp(16px, 4.2vw, 18px); }
    .full-player-play-pause {
        width: var(--fp-playbtn-size);
        height: var(--fp-playbtn-size);
    }
    .full-player-play-pause svg {
        width: clamp(24px, 6vw, 28px);
        height: clamp(24px, 6vw, 28px);
    }
    .full-player-secondary-controls { gap: clamp(12px, 3.8vw, 16px); padding: clamp(6px, 1.8vw, 8px) 0; }
    .full-player-secondary-btn { width: clamp(28px, 7.5vw, 32px); height: clamp(28px, 7.5vw, 32px); font-size: clamp(16px, 4.2vw, 18px); }
    .full-player-volume { padding: 0 clamp(16px, 5vw, 24px) clamp(16px, 5vw, 24px); }
    .full-player-volume-slider { height: clamp(4px, 1.2vw, 5px); }

    /* ---- 搜索 ---- */
    .search-modal-input {
        padding: clamp(8px, 2.5vw, 12px);
        font-size: clamp(14px, 3.7vw, 16px);
        height: clamp(40px, 10.5vw, 44px);
    }
    .search-result-item { padding: clamp(6px, 1.8vw, 10px); gap: clamp(6px, 2vw, 8px); }
    .search-result-cover { width: clamp(40px, 10.5vw, 50px); height: clamp(40px, 10.5vw, 50px); }
    .search-result-title { font-size: clamp(12px, 3vw, 14px); }
    .search-result-artist { font-size: clamp(10px, 2.5vw, 12px); }

    /* ---- 面包屑 ---- */
    .local-breadcrumb {
        padding: clamp(6px, 2vw, 8px);
        font-size: clamp(11px, 2.8vw, 12px);
        gap: clamp(3px, 1vw, 4px);
    }
    .breadcrumb-item { font-size: clamp(11px, 2.8vw, 14px); }

    /* ---- Toast ---- */
    .toast {
        padding: clamp(10px, 2.8vw, 16px);
        font-size: clamp(12px, 3vw, 14px);
        border-radius: 8px;
        min-width: clamp(200px, 55vw, 280px);
    }

    /* ---- Loading ---- */
    .loading-overlay { font-size: clamp(12px, 3.5vw, 14px); }
    .loading-spinner { width: clamp(36px, 10vw, 40px); height: clamp(36px, 10vw, 40px); }

    /* ---- 音量弹出框 ---- */
    .volume-popup {
        width: 40px;
        height: 120px;
        right: 12px;
    }
}

/* ============================================
   Phone Landscape Layout
   iPhones in landscape: width 568px-932px, height 320px-430px
   Excludes iPad (min-height 768px in landscape)
   ============================================ */

@media (orientation: landscape) and (max-height: 500px) {

    /* Full-screen player: side-by-side layout */
    .full-player-content {
        display: grid;
        grid-template-columns: 1fr 1fr;
        grid-template-rows: auto auto auto auto;
        align-content: center;
        height: 100vh;
        height: 100dvh;
        padding: 0;
        overflow: hidden;
    }

    /* Left column: artwork spans all rows */
    .full-player-artwork {
        grid-column: 1;
        grid-row: 1 / -1;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 12px;
        padding-left: max(12px, env(safe-area-inset-left));
        height: auto;
    }

    .full-player-artwork-container {
        width: min(calc(100vh - 40px), calc(100dvh - 40px), 45vw);
        height: min(calc(100vh - 40px), calc(100dvh - 40px), 45vw);
    }

    /* Right column: info, progress, controls */
    .full-player-info {
        grid-column: 2;
        text-align: left;
        padding: 8px 16px 4px;
        padding-right: max(16px, env(safe-area-inset-right));
    }

    .full-player-title {
        font-size: clamp(14px, 3.5vw, 18px);
        margin-bottom: 2px;
    }

    .full-player-artist {
        font-size: clamp(11px, 2.5vw, 14px);
        margin-bottom: 4px;
    }

    /* 较高 iPhone 横屏 (Plus/Max: 414-430px) 显示播放列表名 */
    /* 较矮 iPhone 横屏 (SE/mini: 320-380px) 在下方隐藏 */
    .full-player-playlist {
        font-size: 11px;
        opacity: 0.7;
        margin-top: 2px;
    }

    .full-player-progress-section {
        grid-column: 2;
        padding: 4px 16px;
        padding-right: max(16px, env(safe-area-inset-right));
    }

    .full-player-progress-bar {
        height: 4px;
        margin-bottom: 4px;
    }

    .full-player-time {
        font-size: 11px;
    }

    .full-player-controls-grid {
        grid-column: 2;
        justify-content: center;
        padding: 8px 16px;
        padding-right: max(16px, env(safe-area-inset-right));
        gap: 12px;
    }

    .full-player-play-pause {
        width: 48px;
        height: 48px;
    }

    .full-player-control-btn {
        font-size: 16px;
        padding: 8px;
    }

    /* Volume: condense in landscape */
    .full-player-volume {
        grid-column: 2;
        padding: 0 16px 8px;
        padding-right: max(16px, env(safe-area-inset-right));
        max-width: 300px;
        margin: 0;
    }

    /* Header: overlay style in landscape */
    .full-player-header {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        z-index: 10;
        padding: 8px;
        padding-left: max(8px, env(safe-area-inset-left));
        padding-right: max(8px, env(safe-area-inset-right));
    }

    /* KTV controls: compact */
    .full-player-ktv-controls {
        min-width: 80px;
    }

    /* Expanded artwork state: restore to flexbox */
    .full-player.artwork-expanded .full-player-content {
        display: flex;
        flex-direction: column;
    }

    /* Secondary controls: hidden in landscape to save space */
    .full-player-secondary-controls {
        display: none;
    }

    /* Bottom nav in landscape: slimmer */
    .bottom-nav {
        height: clamp(44px, 12vh, 54px);
        padding-left: max(0px, env(safe-area-inset-left));
        padding-right: max(0px, env(safe-area-inset-right));
    }
    .history-modal {
        bottom: clamp(44px, 12vh, 54px);
    }

    /* Content area: reduce padding in landscape */
    .tab-content, #tree {
        padding: 4px 8px;
        padding-left: max(8px, env(safe-area-inset-left));
        padding-right: max(8px, env(safe-area-inset-right));
        padding-bottom: clamp(48px, 14vh, 60px);
    }
}

/* 较矮 iPhone 横屏 (SE/mini 等 <=380px 高度) 隐藏播放列表名 */
@media (orientation: landscape) and (max-height: 380px) {
    .full-player-playlist {
        display: none;
    }
}

/* ============================================
   iPad / Tablet 布局 (侧边栏导航)
   当视口宽度 >= 769px 时生效
   - iPad Air 竖屏 (820px) 及以上
   - iPad mini 横屏 (1024px)
   - iPad Pro 所有方向
   - 自动回退: Split View / Slide Over (< 769px)
     会回退到手机底部导航布局
   ============================================ */

@media (min-width: 769px) {
    /* -- CSS 自定义属性: 侧边栏宽度 + Now Playing 面板宽度 -- */
    :root {
        --sidebar-width: 72px;
        --now-playing-width: 0px;
    }

    /* ---- 底部导航栏 -> 左侧边栏 ---- */
    .bottom-nav {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        right: auto;
        width: var(--sidebar-width);
        height: 100%;
        flex-direction: column;
        justify-content: flex-start;
        align-items: center;
        padding: 24px 0;
        padding-bottom: max(24px, env(safe-area-inset-bottom));
        padding-left: max(0px, env(safe-area-inset-left));
        gap: 8px;
        border-top: none;
        border-right: 1px solid;
    }

    .nav-item {
        flex: 0 0 auto;
        width: 100%;
        padding: 14px 0;
        justify-content: center;
    }

    .nav-icon {
        font-size: 26px;
    }

    .nav-label {
        font-size: 9px;
    }

    /* ---- 主内容区域偏移 ---- */
    .tab-content,
    #tree {
        margin-left: var(--sidebar-width);
        padding-bottom: 32px;
    }

    /* ---- 模态框: 从侧边栏右侧开始, 移除底部偏移 ---- */
    /* 搜索模态框: 原 bottom: 64px, left: 0 */
    .search-modal {
        left: var(--sidebar-width);
        bottom: 0;
        max-height: 100vh;
    }

    /* 历史模态框: 原 bottom: 64px, left: 0 */
    .history-modal {
        left: var(--sidebar-width);
        bottom: 0;
    }

    /* 歌单管理模态框: 原 bottom: 64px, left: 0 */
    .playlists-modal {
        left: var(--sidebar-width);
        bottom: 0;
    }

    /* ---- 全屏覆盖层覆盖整个视口含侧边栏 ---- */
    /* .full-player: iPad 优化在下方独立的 orientation 媒体查询中 */
    /* .settings-panel, #debugModal, .select-playlist-modal, .toast 保持不变 */

    /* ---- 播放列表: 更宽屏幕允许更多空间 ---- */
    .playlist-track-item:not(.current-playing) .track-title {
        max-width: none;
    }

    .track-playlist-name {
        max-width: 200px;
    }

    /* ---- 当前播放曲目: iPad 上更大封面 ---- */
    .playlist-track-item.current-playing .track-cover {
        width: 200px;
        height: 200px;
    }

    .playlist-track-item.current-playing .track-title {
        font-size: 20px;
    }

    /* ---- 全屏播放器: 平板基线优化 ---- */
    /* Orientation-specific overrides in separate media query blocks below */
    .full-player-artwork-container {
        width: min(500px, 65vw);
        height: min(500px, 65vw);
    }

    .full-player-title {
        font-size: 24px;
    }

    .full-player-artist {
        font-size: 16px;
    }

    /* ---- 搜索 ---- */
    .search-modal-body {
        padding-bottom: 32px;
    }

    .search-modal-input {
        font-size: 16px;
        padding: 12px 16px;
    }

    /* ---- 设置面板: 利用更大屏幕 ---- */
    .settings-container {
        max-width: 560px;
    }

    /* ---- 搜索目录网格: 更宽屏幕3列 ---- */
    .search-dir-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    /* ---- 本地文件网格: 更多列 ---- */
    .local-card-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    }

    .local-album-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    }

    .albums-grid {
        grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    }

    /* ---- 拖拽手柄: 恢复正常尺寸 ---- */
    .drag-handle {
        width: 32px;
        height: 48px;
        min-width: 32px;
    }

    .drag-handle svg {
        width: 18px;
        height: 18px;
    }

    /* ---- 歌单管理卡片: 正常尺寸 ---- */
    .playlist-item {
        padding: 14px 16px;
        gap: 14px;
    }

    .playlist-icon {
        width: 48px;
        height: 48px;
        font-size: 22px;
    }

    .playlist-name {
        font-size: 16px;
    }

    .playlist-count {
        font-size: 13px;
    }
}

@media (max-width: 860px) {
    .albums-hero,
    .album-detail-hero {
        grid-template-columns: 1fr;
    }

    .albums-hero-artwork,
    .album-detail-artwork {
        max-width: 360px;
        margin: 0 auto;
    }

    .albums-page-header,
    .album-detail-topbar {
        flex-direction: column;
        align-items: stretch;
    }
}

@media (max-width: 640px) {
    .albums-tab {
        padding-top: calc(16px + var(--safe-area-top));
        padding-right: max(14px, var(--safe-area-right));
        padding-bottom: calc(var(--content-bottom-space) - 16px);
        padding-left: max(14px, var(--safe-area-left));
    }

    .albums-page,
    .album-detail-page {
        gap: 20px;
    }

    .albums-hero,
    .album-detail-hero {
        padding: 18px;
        border-radius: 24px;
    }

    .albums-rail {
        grid-auto-columns: minmax(154px, 180px);
    }

    .albums-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 14px;
    }

    .albums-hero-actions {
        flex-direction: row;
        flex-wrap: nowrap;
    }

    .albums-action-btn {
        width: 100%;
        justify-content: center;
    }
}

/* ============================================
   iPad 全屏播放器 - 横屏分栏布局
   Apple Music 风格: 左侧封面, 右侧控件
   iPad mini 横屏 (1024x768) ~ iPad Pro 12.9" (1366x1024)
   iPhone Pro Max 横屏 932px 被排除
   ============================================ */

@media (min-width: 1024px) and (orientation: landscape) {

    /* 从 flex-column 切换为 2 列 grid */
    .full-player-content {
        display: grid;
        grid-template-columns: 1fr 1fr;
        grid-template-rows: auto auto auto auto;
        align-content: center;
        height: 100vh;
        height: 100dvh;
        padding: 0;
    }

    /* ---- 左列: 封面横跨所有行 ---- */
    .full-player-artwork {
        grid-column: 1;
        grid-row: 1 / -1;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 40px;
        padding-left: max(40px, env(safe-area-inset-left));
        height: auto;
    }

    .full-player-artwork-container {
        width: min(420px, 42vw, calc(100vh - 100px));
        height: min(420px, 42vw, calc(100vh - 100px));
    }

    /* ---- 右列: 信息、进度、控件、音量 ---- */
    .full-player-info {
        grid-column: 2;
        text-align: left;
        padding: 0 40px 8px;
        padding-right: max(40px, env(safe-area-inset-right));
    }

    .full-player-title {
        font-size: 26px;
    }

    .full-player-artist {
        font-size: 16px;
    }

    .full-player-progress-section {
        grid-column: 2;
        padding: 12px 40px;
        padding-right: max(40px, env(safe-area-inset-right));
    }

    .full-player-progress-bar {
        height: 6px;
    }

    .full-player-time {
        font-size: 14px;
    }

    .full-player-controls-grid {
        grid-column: 2;
        justify-content: center;
        padding: 16px 40px;
        padding-right: max(40px, env(safe-area-inset-right));
        gap: 20px;
    }

    .full-player-play-pause {
        width: 80px;
        height: 80px;
    }

    .full-player-volume {
        grid-column: 2;
        padding: 0 40px 24px;
        padding-right: max(40px, env(safe-area-inset-right));
        max-width: 500px;
        margin: 0;
    }

    /* ---- 展开模式: 恢复为 flex-column ---- */
    .full-player.artwork-expanded .full-player-content {
        display: flex;
        flex-direction: column;
    }
}

/* dvh 增强: iPad 横屏 artwork container */
@media (min-width: 1024px) and (orientation: landscape) {
    @supports (height: 1dvh) {
        .full-player-artwork-container {
            width: min(420px, 42vw, calc(100dvh - 100px));
            height: min(420px, 42vw, calc(100dvh - 100px));
        }
    }
}

/* ============================================
   iPad 全屏播放器 - 竖屏增强布局
   更大封面、更多呼吸感留白
   iPad Air 竖屏 (820px) ~ iPad Pro 12.9" 竖屏 (1024px)
   ============================================ */

@media (min-width: 769px) and (orientation: portrait) {

    .full-player-content {
        justify-content: center;
        gap: 8px;
    }

    /* 更大封面: ~70vw */
    .full-player-artwork {
        padding: 24px 20px 36px;
    }

    .full-player-artwork-container {
        width: min(560px, 70vw);
        height: min(560px, 70vw);
    }

    /* 信息区: 更多呼吸感 */
    .full-player-info {
        padding: 20px 32px 12px;
    }

    .full-player-title {
        font-size: 26px;
        margin-bottom: 10px;
    }

    .full-player-artist {
        font-size: 17px;
        margin-bottom: 14px;
    }

    /* 进度条: 更宽内边距 */
    .full-player-progress-section {
        padding: 20px 32px;
    }

    .full-player-progress-bar {
        height: 6px;
        margin-bottom: 12px;
    }

    .full-player-time {
        font-size: 14px;
    }

    /* 控件: 更大间距 */
    .full-player-controls-grid {
        padding: 28px 32px;
        gap: 24px;
    }

    .full-player-play-pause {
        width: 80px;
        height: 80px;
    }

    /* 音量: 更宽 */
    .full-player-volume {
        max-width: 500px;
        padding: 0 32px 32px;
    }
}

/* ============================================
   iPad 全屏播放器 - 触控优化
   更大的触控区域: 进度条、音量、按钮
   min-height: 600px 排除 iPhone 横屏 (最高 ~430px)
   ============================================ */

@media (min-width: 769px) and (min-height: 600px) {

    /* 进度条: 隐形扩大触控区域 */
    .full-player-progress-bar {
        position: relative;
    }

    .full-player-progress-bar::before {
        content: '';
        position: absolute;
        top: -14px;
        bottom: -14px;
        left: 0;
        right: 0;
    }

    /* 进度条滑块: 更大 */
    .full-player-progress-thumb {
        width: 20px;
        height: 20px;
    }

    .full-player-progress-bar.dragging .full-player-progress-thumb {
        transform: translate(-50%, -50%) scale(1.3);
    }

    /* 音量滑块: 更大的滑块和轨道 */
    .full-player-volume-slider input[type="range"] {
        height: 6px;
    }

    .full-player-volume-slider input[type="range"]::-webkit-slider-thumb {
        width: 20px;
        height: 20px;
        margin-top: -7px;
    }

    .full-player-volume-slider input[type="range"]::-moz-range-thumb {
        width: 20px;
        height: 20px;
    }

    .full-player-volume-slider input[type="range"]::-webkit-slider-runnable-track {
        height: 6px;
    }

    .full-player-volume-slider input[type="range"]::-moz-range-track {
        height: 6px;
    }

    /* 控制按钮: 更大触控目标 (Apple HIG >= 44pt) */
    .full-player-control-btn {
        padding: 16px;
        min-width: 48px;
        min-height: 48px;
    }

    /* KTV 按钮: 稍大 */
    .full-player-pitch-btn {
        width: 40px !important;
        height: 40px !important;
    }

    .full-player-offset-btn {
        width: 40px !important;
        height: 40px !important;
    }
}

/* ============================================
   iPad Landscape: Now Playing Side Panel + 双栏布局
   Sidebar(72px) | Content(flexible) | NowPlaying(340px)
   仅在 >=1024px 横屏 + 有歌曲播放(body.npp-visible) 时生效
   ============================================ */

@media (min-width: 1024px) and (orientation: landscape) {

    :root {
        --now-playing-width: 340px;
    }

    /* ---- 主内容区: 基础过渡 (确保移除 npp-visible 时也有动画) ---- */
    .tab-content,
    #tree {
        transition: margin-right 0.3s ease;
    }

    .search-modal,
    .history-modal {
        transition: right 0.3s ease;
    }

    /* ---- 主内容区: 为 Now Playing 面板腾出右侧空间 ---- */
    body.npp-visible .tab-content,
    body.npp-visible #tree {
        margin-right: var(--now-playing-width);
    }

    /* ---- 模态框: 尊重右侧面板 ---- */
    body.npp-visible .search-modal {
        right: var(--now-playing-width);
    }

    body.npp-visible .history-modal {
        right: var(--now-playing-width);
    }

    body.npp-visible .playlists-modal {
        right: var(--now-playing-width);
    }

    /* ---- 本地文件网格: 横屏更多列 ---- */
    .local-card-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    }

    .local-album-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    }

    /* ---- Now Playing Panel ---- */
    .now-playing-panel {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        width: var(--now-playing-width);
        z-index: 50;
        border-left: 1px solid var(--border-color, #333);
        overflow: hidden;
        display: flex !important;
        flex-direction: column;
        padding-right: max(0px, env(safe-area-inset-right));
        will-change: transform;
        transform: translateZ(0);
    }

    .now-playing-panel[hidden] {
        display: none !important;
    }

    .now-playing-panel-inner {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        height: 100%;
        padding: 32px 24px;
        padding-right: max(24px, env(safe-area-inset-right));
        gap: 20px;
        overflow-y: auto;
    }

    /* ---- NPP: 封面 ---- */
    .npp-artwork-section {
        cursor: pointer;
        width: 100%;
        display: flex;
        justify-content: center;
        transition: transform 0.2s ease;
    }

    .npp-artwork-section:hover {
        transform: scale(1.02);
    }

    .npp-artwork-section:active {
        transform: scale(0.98);
    }

    .npp-artwork-container {
        width: min(240px, calc(var(--now-playing-width) - 80px));
        height: min(240px, calc(var(--now-playing-width) - 80px));
        border-radius: 16px;
        overflow: hidden;
        position: relative;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    }

    .npp-artwork-container img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        display: block;
    }

    .npp-artwork-placeholder {
        width: 100%;
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 64px;
        opacity: 0.3;
    }

    /* ---- NPP: 歌曲信息 ---- */
    .npp-info {
        width: 100%;
        text-align: center;
        padding: 0 8px;
    }

    .npp-title {
        font-size: 17px;
        font-weight: 700;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        margin-bottom: 6px;
    }

    .npp-artist {
        font-size: 14px;
        opacity: 0.7;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* ---- NPP: 进度条 (只读) ---- */
    .npp-progress-section {
        width: 100%;
        padding: 0 8px;
    }

    .npp-progress-bar {
        height: 4px;
        border-radius: 2px;
        position: relative;
        margin-bottom: 8px;
        cursor: pointer;
    }

    /* 扩大触控区域 */
    .npp-progress-bar::before {
        content: '';
        position: absolute;
        top: -12px;
        bottom: -12px;
        left: 0;
        right: 0;
    }

    .npp-progress-fill {
        height: 100%;
        border-radius: 2px;
        width: 0%;
        transition: width 0.3s linear;
        pointer-events: none;
    }

    .npp-time {
        display: flex;
        justify-content: space-between;
        font-size: 12px;
        font-weight: 500;
        opacity: 0.6;
    }

    /* ---- NPP: 控制按钮 ---- */
    .npp-controls {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 16px;
    }

    .npp-control-btn {
        background: transparent;
        border: none;
        cursor: pointer;
        padding: 10px;
        border-radius: 50%;
        transition: all 0.2s ease;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .npp-control-btn:hover {
        transform: scale(1.1);
    }

    .npp-control-btn:active {
        transform: scale(0.95);
    }

    .npp-play-pause {
        width: 56px;
        height: 56px;
    }
}

/* iPad Pro 12.9" 横屏: 更宽的 Now Playing 面板 */
@media (min-width: 1200px) and (orientation: landscape) {
    :root {
        --now-playing-width: 380px;
    }
    .npp-artwork-container {
        width: min(280px, calc(var(--now-playing-width) - 80px));
        height: min(280px, calc(var(--now-playing-width) - 80px));
    }
}

/* ---- Now Playing Panel: 竖屏和手机下隐藏 ---- */
@media (min-width: 769px) and (orientation: portrait) {
    .now-playing-panel {
        display: none !important;
    }
}

@media (max-width: 768px) {
    .now-playing-panel {
        display: none !important;
    }

    .full-player-audio-only-notice {
        left: 12px;
        right: 12px;
        bottom: 12px;
        gap: 10px;
        padding: 10px 12px;
        border-radius: 14px;
    }

    .full-player-audio-only-icon {
        width: 24px;
        height: 24px;
        font-size: 14px;
    }

    .full-player-audio-only-title {
        font-size: 12px;
    }

    .full-player-audio-only-body {
        font-size: 11px;
    }
}
