/* =========================================
   OMG Music - Mobile Adaptation V7 (Precision Layout & Logic)
   Target: Max-width 768px
   ========================================= */

@media (max-width: 768px) {

    /* 0. Mobile Reset & Optimization */
    * {
        -webkit-tap-highlight-color: transparent;
    }

    /* 1. Global Reset */
    .app-layout {
        display: flex;
        flex-direction: column;
        height: 100vh;
        height: 100dvh;
        /* Dynamic Viewport Height for Mobile Browsers */
        width: 100vw;
        overflow: hidden;

        /* iPhone Safe Area Support */
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
        background: radial-gradient(circle at top left, #1f2235 0%, #0d0d10 100%);
        /* Enhance depth */
        background-repeat: no-repeat;
        background-attachment: fixed;
        background: radial-gradient(circle at top left, #1f2235 0%, #0d0d10 100%);
        /* Enhance depth */
        background-repeat: no-repeat;
        background-attachment: fixed;
    }

    /* GLOBAL MOBILE POPUP GLASS STYLE */
    .popup {
        /* Deep Blue Tint - More Transparent */
        background: rgba(20, 30, 45, 0.45) !important;
        backdrop-filter: blur(20px) !important;
        -webkit-backdrop-filter: blur(20px) !important;
        border: 1px solid rgba(255, 255, 255, 0.1) !important;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5) !important;
        border-radius: 12px !important;
        color: #fff !important;
    }

    /* Pop Items Text Color */
    .popup .pop-item {
        color: rgba(255, 255, 255, 0.9) !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05) !important;
    }

    .popup .pop-item:active {
        background: rgba(255, 255, 255, 0.1) !important;
    }

    /* Hide PC components */
    .sidebar,
    .top-bar .search-wrapper .search-icon-left,
    .top-bar .hot-tags-row {
        display: none !important;
    }

    /* 3. Top Bar (Compact) */
    .top-bar {
        height: auto;
        display: flex;
        flex-wrap: nowrap;
        /* Force single line */
        gap: 8px;
        /* Reduce gap */
        margin-bottom: 15px;
        align-items: center;
    }

    .top-bar .hot-tags-row::-webkit-scrollbar {
        display: none;
    }

    .hot-tag-item {
        flex-shrink: 0;
        font-size: 0.85rem;
        padding: 4px 12px;
        background: rgba(255, 255, 255, 0.1);
        border-radius: 100px;
        backdrop-filter: blur(5px);
    }

    .right-panel {
        display: none;
        transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    }

    /* 2. Main Area */
    .main-area {
        flex: 1;
        width: 100%;
        /* Increase padding to clear Player Bar (60) + Nav Bar (56) + Safe Area + Spacing */
        padding: 15px 15px calc(140px + env(safe-area-inset-bottom)) 15px;
        background: transparent;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* 3. Top Bar (Compact) */
    .top-bar {
        height: auto;
        display: flex;
        flex-wrap: nowrap;
        /* Force single line */
        gap: 8px;
        /* Reduce gap */
        margin-bottom: 15px;
        align-items: center;
    }

    .search-wrapper {
        width: auto;
        flex: 1;
        /* Take remaining space (shortened naturally by buttons) */
        height: 40px;
        min-width: 0;
        /* Allow shrinking */
    }

    .search-input {
        padding-left: 15px;
        background: rgba(0, 0, 0, 0.2);
    }

    /* 搜索建议下拉框位置修正 - 居中强力修复版 */
    #search-suggestions {
        position: fixed !important;
        /* 增加到 90px + 安全区域，确保完全位于搜索框下方（搜索框底部约为 safe-area + 55px） */
        top: calc(env(safe-area-inset-top) + 90px) !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        /* 强制水平居中 */
        width: 92vw !important;
        /* 宽度设为屏幕宽度的 92% */
        max-width: 450px !important;
        /* 限制最大宽度 */
        right: auto !important;
        /* 清除可能存在的 right 设置 */
        margin: 0 !important;
        /* 重置 margin */

        z-index: 20002 !important;
        /* 极大 z-index 确保最上层 */
        background: rgba(20, 30, 45, 0.95) !important;
        backdrop-filter: blur(25px) !important;
        -webkit-backdrop-filter: blur(25px) !important;
        border-radius: 12px !important;
        border: 1px solid rgba(255, 255, 255, 0.1) !important;
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6) !important;
        max-height: 60vh;
        overflow-y: auto;
    }

    .source-wrapper,
    .search-btn,
    .mobile-nav-btn {
        height: 36px;
        /* Match input height roughly or slightly smaller */
        height: 40px;
        /* Match Input Height 40px */
        border-radius: 8px;
        /* Match input radius */
    }

    .search-btn {
        width: auto;
        padding: 0 15px;
        white-space: nowrap;
    }

    .mobile-nav-btn {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 40px;
        /* Square-ish */
        padding: 0 !important;
        background: rgba(255, 255, 255, 0.1);
        border: 1px solid rgba(255, 255, 255, 0.1);
    }

    .list-actions-col,
    .list-header-row {
        display: none;
    }

    /* Song Item */
    .song-item {
        display: grid !important;
        grid-template-columns: 0px 50px 1fr auto !important;
        /* Reduced image col 60->50 */
        gap: 0;
        padding: 6px 0;
        /* Reduced padding 10->4 */
        border: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
        background: transparent !important;
        height: 54px;
        /* Force height constraint */
        align-content: center;
    }

    /* Adjust Thumb Size for Compactness */
    .song-item .list-thumb {
        width: 40px !important;
        height: 40px !important;
        border-radius: 4px !important;
    }

    /* FIX: Remove sticky hover on mobile. */
    /* FIX: Remove sticky hover on mobile. 
       Note: Use :not(.active) to avoid clearing background of playing song 
    */
    .song-item:not(.active):hover {
        background: transparent !important;
        box-shadow: none !important;
        transform: none !important;
        border: none !important;
        border-bottom: 0.5px solid rgba(255, 255, 255, 0.05) !important;
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        color: inherit !important;
        z-index: 1 !important;
    }

    .song-item:not(.active):hover::before {
        opacity: 0 !important;
    }

    .song-item:not(.active):hover .song-index-num {
        opacity: 1 !important;
        transform: none !important;
    }

    .song-item:not(.active):hover .list-thumb {
        transform: none !important;
        filter: none !important;
    }

    .song-item:not(.active):hover span {
        transform: none !important;
        color: inherit !important;
        text-shadow: none !important;
    }

    /* V13: PORT RICH EFFECTS TO ACTIVE STATE (Touch Feedback) */
    .song-item:active {
        background: var(--item-hover-bg) !important;
        backdrop-filter: blur(10px) !important;
        -webkit-backdrop-filter: blur(10px) !important;
        color: var(--text-primary) !important;
        /* Touch Specific: slightly smaller scale for "press" feel instead of "lift" */
        transform: scale(0.98) !important;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3) !important;
        border: 1px solid var(--c-fx-border) !important;
        z-index: 10 !important;
        transition: none !important;
        /* Instant feedback */
    }

    /* Restore Play Icon on Press? Maybe too distracting, let's keep it simple style */
    .song-item:active::before {
        content: '\f04b';
        font-family: "Font Awesome 6 Free";
        font-weight: 900;
        position: absolute;
        left: 20px;
        top: 50%;
        transform: translate(-50%, -50%) !important;
        opacity: 0.8 !important;
        color: var(--c-hover-text);
        transition: none !important;
    }

    .song-item:active .song-index-num {
        opacity: 0 !important;
    }

    .song-item:active .list-thumb {
        filter: brightness(1.1);
        transform: scale(1.05);
        transition: none;
    }

    .song-item:hover span {
        transform: none !important;
        color: inherit !important;
        text-shadow: none !important;
    }

    .song-item>div:nth-child(2) {
        display: block !important;
        margin-right: 12px;
    }

    .list-thumb {
        width: 48px;
        height: 48px;
        border-radius: 8px;
        opacity: 1 !important;
    }

    .song-item>div:nth-child(3) {
        width: auto;
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: center;
        overflow: hidden;
    }

    .text-link {
        font-size: 1rem;
        margin-bottom: 4px;
        color: #fff;
    }

    .song-item>div:nth-child(4) {
        display: block !important;
        font-size: 0.85rem;
        opacity: 0.6;
        text-align: right;
        max-width: 100px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .song-item>div:nth-child(1),
    .song-item>div:nth-child(5),
    .song-item>div:nth-child(6) {
        display: none;
    }

    /* Grid & Pagination */
    .tile-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 8px;
    }

    .tile-text {
        font-size: 0.7rem;
    }

    .pagination button {
        display: flex !important;
        font-size: 0.8rem;
        padding: 6px 12px;
    }

    /* =========================================
       V8 PLAYER BAR LAYOUT (Simplified & Background Progress)
       Goal: [Background Progress] [Cover] [Info] [Play]
       ========================================= */

    .player-bar {
        position: fixed;
        bottom: calc(60px + env(safe-area-inset-bottom));
        /* Lift above nav bar + safe area + gap */
        left: 10px;
        right: 10px;
        width: auto !important;
        height: 60px;
        background: rgba(20, 20, 20, 0.5);
        /* Frosted Glass */
        backdrop-filter: blur(30px) saturate(180%);
        -webkit-backdrop-filter: blur(30px) saturate(180%);
        border: 1px solid rgba(255, 255, 255, 0.08);
        border-radius: 16px;
        padding: 0 12px !important;
        margin: 0 !important;
        z-index: 999;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
        overflow: hidden !important;
        /* Clip progress bar */

        display: grid !important;
        align-items: center;
        /* Columns: Cover | Info | Play */
        /* Columns: Cover | Info | Play | List */
        grid-template-columns: 48px minmax(0, 1fr) 40px 40px !important;
        grid-template-areas: "cover info play list";
        gap: 8px;
    }

    /* PWA Standalone Fixes */
    @media all and (display-mode: standalone) {
        .app-layout {
            /* Fix status bar overlap if safe-area env fails */
            padding-top: max(20px, env(safe-area-inset-top));
        }

        /* Ensure top bar doesn't touch the dynamic island/notch too closely */
        .top-bar {
            margin-top: 5px;
        }
    }

    /* Flatten Structure */
    .track-info,
    /* .song-info, */
    .controls,
    .player-right {
        display: contents !important;
    }

    /* 1. COVER */
    .track-info img {
        grid-area: cover;
        width: 48px;
        height: 48px;
        border-radius: 8px;
        cursor: pointer;
        z-index: 10;
        position: relative;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    }

    /* 1.1 INFO CONTAINER */
    /* This wrapper is the grid item */
    .song-info {
        grid-area: info;
        display: flex !important;
        flex-direction: column;
        justify-content: center;
        align-items: flex-start;
        height: 100%;
        width: 100%;
        min-width: 0;
        /* CRITICAL: Enables truncation in grid/flex */
        overflow: hidden;
        z-index: 10;
    }

    /* 1.1.1 Title Helper */
    .song-title-with-buttons {
        /* grid-area: info;  <-- No longer needed if parent is the item */
        display: flex !important;
        flex-direction: row;
        align-items: center;
        width: 100%;
        min-width: 0;
        overflow: hidden;
    }

    #bar-title {
        display: block;
        /* Required for span width/overflow */
        font-size: 0.95rem;
        font-weight: 700;
        color: #fff;
        width: 100%;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        margin-bottom: 3px;
        text-align: left;
        line-height: 1.2;
    }

    #bar-artist {
        display: block;
        /* Ensure width works */
        color: rgba(255, 255, 255, 0.6);
        width: 100%;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        text-align: left;
        margin: 0 !important;
        padding: 0 !important;
        line-height: 1.2;
    }

    .track-buttons {
        display: none !important;
    }

    /* 2. PLAY BUTTON */
    #play-btn {
        grid-area: play;
        width: 36px;
        height: 36px;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.1);
        border: 1px solid rgba(255, 255, 255, 0.2);
        display: flex !important;
        justify-content: center;
        align-items: center;
        margin: 0 !important;
        z-index: 20;
    }

    /* Mobile Search Suggestions Fix - Removed to sync with JS injected styles */

    .suggestion-item {
        padding: 12px 15px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
        color: white;
        font-size: 1rem;
    }

    .suggestion-item:last-child {
        border-bottom: none;
    }

    /* Mobile Hot Tags Grid */
    .hot-tags-container {
        display: flex;
        flex-wrap: wrap;
        gap: 10px;
        padding: 10px;
    }

    #play-btn i {
        font-size: 14px;
        margin-left: 2px;
    }

    /* 3. PLAYLIST BUTTON (NEW) */
    #mobile-pl-btn {
        grid-area: list;
        display: flex !important;
        width: 36px;
        height: 36px;
        border-radius: 50%;
        background: transparent;
        border: none;
        justify-content: center;
        align-items: center;
        margin: 0 !important;
        z-index: 20;
        color: #fff;
        opacity: 0.9;
    }

    #mobile-pl-btn i {
        font-size: 18px;
    }



    .play-btn i {
        font-size: 1rem !important;
        margin: 0 !important;
    }

    /* 3. HIDE OTHER CONTROLS (Scoped to Player Bar to allow Full Player buttons) */
    #mode-btn,
    .player-bar button[onclick="playPrev()"],
    .player-bar button[onclick="playNext()"],
    .player-right>button[onclick="togglePopup('pl')"],
    .mobile-dl-btn,
    #qual-btn,
    #rep-btn,
    .player-right button,
    .player-right input {
        display: none !important;
    }

    /* Universal Button Reset */
    .player-bar button {
        background: transparent !important;
        border: none;
        color: #fff;
        font-size: 1.1rem !important;
        width: 30px;
        height: 30px;
        padding: 0;
        display: flex;
        justify-content: center;
        align-items: center;
    }

    /* 移动端播放激活提示 */
    .mobile-audio-hint {
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        background: rgba(0, 0, 0, 0.8);
        color: white;
        padding: 20px;
        border-radius: 10px;
        font-size: 1rem;
        z-index: 10000;
        display: none;
        text-align: center;
        backdrop-filter: blur(10px);
    }

    /* Hide actions row when lyrics view is active */
    .right-panel.view-lyrics .mobile-actions-row {
        display: none !important;
    }

    /* 4. BACKGROUND PROGRESS BAR (Improved) */
    .progress-wrapper {
        position: absolute !important;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        z-index: 0;
        padding: 0;
        opacity: 1;
        pointer-events: none;
        /* Let clicks pass through to bar */
        background: transparent;
    }

    .progress-wrapper::before {
        display: none;
    }

    /* Remove line */

    .prog-bar {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
    }

    .prog-bg {
        width: 100%;
        height: 100%;
        background: transparent;
    }

    .prog-fill {
        height: 100%;
        /* Animated Gradient Shimmer - Force Visible Colors */
        background: linear-gradient(90deg,
                rgba(115, 188, 228, 0.3) 0%,
                rgba(115, 188, 228, 0.8) 50%,
                rgba(115, 188, 228, 0.3) 100%) !important;
        background-size: 200% 100% !important;
        animation: progShimmer 5.0s infinite linear !important;

        width: 0%;
        border-radius: 0;
        transition: width 0.1s linear !important;
        /* Distinct leading edge */
        border-right: 2px solid rgba(255, 255, 255, 0.95) !important;
        box-shadow: 4px 0 15px rgba(115, 188, 228, 0.8) !important;
    }

    @keyframes progShimmer {
        0% {
            background-position: 200% 0;
        }

        100% {
            background-position: -200% 0;
        }
    }

    .prog-fill::after {
        display: none;
    }

    .time-text {
        display: none;
    }

    /* =========================================
       FULLSCREEN PURE MODE
       ========================================= */

    /* Lock Body Scroll when Mobile Player is Open */
    body.show-mobile-player,
    body.noscroll {
        overflow: hidden !important;
        position: fixed !important;
        width: 100% !important;
        height: 100% !important;
    }

    body.show-mobile-player .right-panel {
        display: flex !important;
        position: fixed;
        inset: 0;
        z-index: 5000;
        width: 100vw;
        height: 100vh;
        background: rgba(8, 8, 8, 0.4);
        backdrop-filter: blur(40px);
        padding: 50px 20px;
        flex-direction: column;
        align-items: center;
        animation: slideUp 0.3s;
    }

    /* Hide Controls */
    body.show-mobile-player .player-bar,
    body.show-mobile-player .mobile-nav,
    body.show-mobile-player .progress-wrapper {
        display: none !important;
    }

    /* Vinyl Cover */
    body.show-mobile-player .cover-box {
        width: 75vw;
        max-width: 320px;
        aspect-ratio: 1 / 1 !important;
        height: auto !important;
        margin-top: 40px;
        border-radius: 50%;
        box-shadow: 0 0 40px rgba(0, 0, 0, 0.6);
        animation: spin 20s linear infinite;
        animation-play-state: paused;
    }

    body.show-mobile-player .cover-box.playing {
        animation-play-state: running;
    }

    @keyframes slideUp {
        from {
            transform: translateY(100%);
        }

        to {
            transform: translateY(0);
        }
    }

    /* Lyrics Box (Hidden by Default in Vinyl Mode) */
    body.show-mobile-player .lyrics-box {
        display: none;
        /* KEY FIX */
        margin-top: 50px;
        width: 100%;
        mask-image: linear-gradient(to bottom, transparent, black 15%, black 85%, transparent);
        pointer-events: auto;
        /* Container scrolls */
        touch-action: pan-y;
    }

    /* Show Lyrics when Toggled */
    /* Show Lyrics when Toggled */
    body.show-mobile-player .right-panel.view-lyrics .lyrics-box {
        display: block !important;
        height: 100%;
        margin-top: 0;
        overflow-y: auto;
        /* KEY FIX: Enable CSS Scroll */
        overscroll-behavior: contain;
        /* Prevent chaining */
        -webkit-overflow-scrolling: touch;
        /* Momentum scrolling */
    }

    /* Auto-Hide Scrollbar Logic */
    body.show-mobile-player .lyrics-box::-webkit-scrollbar {
        width: 4px;
        background: transparent;
    }

    body.show-mobile-player .lyrics-box::-webkit-scrollbar-thumb {
        background: transparent;
        border-radius: 4px;
        transition: background-color 0.3s;
    }

    body.show-mobile-player .lyrics-box.scrolling::-webkit-scrollbar-thumb {
        background: rgba(255, 255, 255, 0.3);
    }

    body.show-mobile-player .right-panel.view-lyrics .cover-box {
        display: none !important;
    }

    /* Mobile Nav */
    .mobile-nav {
        display: flex !important;
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        /* Explicit Height incl. Safe Area */
        height: calc(56px + env(safe-area-inset-bottom));
        box-sizing: border-box !important;

        background: rgba(17, 17, 17, 0.8);
        backdrop-filter: blur(20px) saturate(180%);
        -webkit-backdrop-filter: blur(20px) saturate(180%);
        border-top: 1px solid rgba(255, 255, 255, 0.08);
        z-index: 1000;
        justify-content: space-around;
        padding-bottom: env(safe-area-inset-bottom);
    }

    .mobile-nav-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        color: #888;
        font-size: 0.65rem;
    }

    .mobile-nav-item.active {
        color: var(--c-player-main);
    }

    /* V15: MARQUEE OPTIMIZATION (Only scroll when playing) */

    /* Default: No scroll, ellipsis */
    .song-item:not(.active) .marquee-wrap {
        display: block !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        mask-image: none !important;
    }

    .song-item:not(.active) .marquee-content {
        animation: none !important;
        display: inline !important;
        padding-right: 0 !important;
    }

    .song-item:not(.active) .marquee-content span:nth-child(2) {
        display: none !important;
    }

    /* --- Playlist Popup (Bottom Sheet) --- */
    /* Defensive Guard: Ensure this never leaks to PC */
    @media (max-width: 768px) {
        #pop-pl {
            position: fixed !important;
            top: auto !important;
            bottom: 0 !important;
            left: 0 !important;
            right: 0 !important;
            width: 100% !important;
            height: 60vh !important;
            max-height: 60vh !important;
            min-height: 300px !important;
            margin: 0 !important;
            border-radius: 24px 24px 0 0 !important;

            /* Glassmorphism - Playlist */
            background: rgba(20, 30, 45, 0.45) !important;
            backdrop-filter: blur(40px) !important;
            -webkit-backdrop-filter: blur(40px) !important;

            box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.6) !important;
            transform: translateY(110%);
            transition: transform 0.4s cubic-bezier(0.19, 1, 0.22, 1) !important;
            display: flex !important;
            flex-direction: column;
            z-index: 9991 !important;
            /* Above player bar */
            opacity: 1 !important;
            /* Override desktop opacity transition if any */
            padding: 0 !important;
            border: 1px solid rgba(255, 255, 255, 0.08) !important;
            border-bottom: none !important;
        }

        #pop-pl.show {
            transform: translateY(0) !important;
        }
    }

    /* Header inside pop-pl */
    #pop-pl>div:first-child {
        padding: 18px 20px !important;
        text-align: center;
        border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
        font-size: 1.1rem !important;
        color: #fff;
        background: transparent !important;
        /* Allow glass */
        border-radius: 24px 24px 0 0;
    }

    /* Scrollable Area */
    /* Fix Mobile Close Button Overlap */
    .mobile-close-btn {
        position: absolute;
        /* Ensure it is absolute if not already */
        top: calc(20px + env(safe-area-inset-top)) !important;
        /* Move down below status bar */
        left: 20px !important;
        z-index: 2000 !important;
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
        /* background: rgba(0,0,0,0.3); Optional background for visibility */
        border-radius: 50%;
    }

    /* Fix Virtual Scroll Container */
    #cur-pl {
        flex: 1;
        overflow-y: auto !important;
        padding: 0 !important;
        -webkit-overflow-scrolling: touch;
        /* Fix Virtual Scroll Container */
        position: relative;
        width: 100%;
        background: transparent !important;
    }

    /* Item Style */
    #pop-pl .pop-item {
        padding: 0 20px !important;
        /* Fill width with standard padding */
        height: 54px !important;
        /* Match JS const */
        border-bottom: 1px solid rgba(255, 255, 255, 0.03);
        display: flex;
        align-items: center;
        width: 100% !important;
        box-sizing: border-box !important;
        background: transparent;
        position: relative;
    }

    /* Mobile Action Buttons (Love/Download) */
    .mb-action-btn {
        background: transparent;
        border: none;
        color: #fff;
        font-size: 1.4rem;
        padding: 10px;
        margin: 0 10px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.1);
        backdrop-filter: blur(10px);
        z-index: 100;
    }

    /* Active State: Match Home Page Style (Blue/Theme Color) */
    #pop-pl .pop-item.active {
        background: var(--c-active-bg) !important;
        color: #fff !important;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2) !important;
        border-left: none !important;
        /* Remove red border */
    }

    /* Disable sticky hover on mobile, only use active press state */
    @media (hover: hover) {
        #pop-pl .pop-item:hover {
            background: rgba(255, 255, 255, 0.05);
        }
    }

    #pop-pl .pop-item:active {
        background: rgba(255, 255, 255, 0.08) !important;
    }

    /* Text truncate fix */
    #pop-pl .song-line-1 {
        font-size: 1rem !important;
        font-weight: 500 !important;
        color: #eee;
        flex: 1;
        margin-right: 10px;
    }

    #pop-pl .song-line-2 {
        font-size: 0.85rem !important;
        opacity: 0.6;
        max-width: 120px;
        text-align: right;
    }

    /* =========================================
   Marquee / Scrolling Text Animation
   ========================================= */
    .marquee-wrap {
        width: 100%;
        overflow: hidden;
        white-space: nowrap;
        position: relative;
        /* Soft fade on edges */
        mask-image: linear-gradient(to right, transparent 0%, black 5%, black 95%, transparent 100%);
        -webkit-mask-image: linear-gradient(to right, transparent 0%, black 5%, black 95%, transparent 100%);
    }

    .marquee-content {
        display: inline-block;
        white-space: nowrap;
        animation: marquee-scroll 10s linear infinite;
        padding-left: 0;
    }

    @keyframes marquee-scroll {
        0% {
            transform: translateX(0);
        }

        100% {
            transform: translateX(-50%);
        }
    }

    /* Ensure inner text spans are block-like to accept spacing */
    .marquee-content span {
        display: inline-block;
        vertical-align: middle;
    }

    /* =========================================
   Mobile Full Controls (Standard 5-Button Fixed)
   ========================================= */

    /* =========================================
   Mobile Full Controls (Standard 5-Button Fixed V2)
   ========================================= */

    .mobile-controls-v2 {
        width: 100%;
        margin-top: 25px;
        display: flex;
        flex-direction: column;
        gap: 15px;
        align-items: center;
    }

    /* Progress Bar Row V2 */
    .mb-prog-wrapper-v2 {
        display: flex;
        flex-direction: row !important;
        align-items: center;
        gap: 15px;
        padding: 0 20px;
        width: 100%;
        height: 30px;
        margin-bottom: 5px;
    }

    .mb-time-v2 {
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.6);
        width: 45px;
        text-align: center;
        font-variant-numeric: tabular-nums;
        font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    }

    .mb-prog-bar-v2 {
        flex: 1;
        height: 30px;
        display: flex;
        align-items: center;
        position: relative;
    }

    .mb-prog-bg-v2 {
        width: 100%;
        height: 2px;
        background: rgba(255, 255, 255, 0.15);
        border-radius: 2px;
        position: relative;
    }

    .mb-prog-fill-v2 {
        height: 100%;
        background: #fff;
        border-radius: 2px;
        width: 0%;
        position: relative;
        display: flex;
        align-items: center;
    }

    /* Controls Row V2 */
    .mb-controls-row-v2 {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
        padding: 10px 35px;
    }

    .mb-btn-v2 {
        background: transparent;
        border: none;
        color: #fff;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        border-radius: 50%;
        position: relative;
    }

    .mb-btn-v2:active {
        background: rgba(255, 255, 255, 0.1);
    }

    .mb-btn-v2 i {
        font-size: 1.3rem;
        opacity: 0.75;
    }

    .mb-btn-v2.large {
        width: 70px;
        height: 70px;
        border: 1px solid rgba(255, 255, 255, 0.15);
        margin: 0 10px;
    }

    .mb-btn-v2.large i {
        font-size: 2.2rem;
        opacity: 1;
        margin-left: 4px;
    }

    .mb-btn-v2.large i.fa-pause {
        margin-left: 0;
    }

    /* Remove any Minimal styles if they exist by overriding specific IDs */
    #vinyl-single-lrc {
        display: none !important;
    }
}

/* =========================================
   Mobile Full Controls V3 (Redesign - Fixed)
   Layout: Progress (Top) -> Metadata (Mid) -> 5 Buttons (Bot)
   ========================================= */
@media (max-width: 768px) {
    .mobile-controls-v3 {
        width: 100%;
        margin-top: auto;
        /* Push to bottom */
        padding: 0 25px 60px 25px;
        /* Lift from bottom edge */
        display: flex;
        flex-direction: column;
        gap: 15px;
        /* Spacing between rows */
    }

    /* Row 1: Progress Bar */
    .mb-prog-bar-v3 {
        width: 100%;
        height: 30px;
        /* Touch target */
        display: flex;
        align-items: center;
        cursor: pointer;
        position: relative;
    }

    .mb-prog-bg-v3 {
        width: 100%;
        height: 3px;
        background: rgba(255, 255, 255, 0.2);
        border-radius: 2px;
        position: relative;
    }

    .mb-prog-fill-v3 {
        height: 100%;
        background: #fff;
        border-radius: 2px;
        width: 0%;
        position: relative;
    }

    .mb-prog-dot-v3 {
        position: absolute;
        width: 12px;
        height: 12px;
        background: #fff;
        border-radius: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
        /* Center strictly */
        right: -6px;
        /* Initial offset? cancel strictly with JS */
        /* JS sets left property. We need to ensure it aligns. */
        /* If JS sets left: 50%, translate -50% centers it. Perfect. */
        opacity: 1;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
        pointer-events: none;
    }

    /* Row 2: Metadata (Time - Qual - Time) */
    .mb-metadata-row {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
        padding: 0 5px;
        margin-bottom: 5px;
        /* Tweak spacing */
    }

    .mb-time-v3 {
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.6);
        font-family: monospace;
        width: 45px;
        text-align: center;
    }

    .mb-quality-tag-v3 {
        font-size: 0.75rem;
        color: rgba(255, 255, 255, 0.9);
        border: 1px solid rgba(255, 255, 255, 0.3);
        padding: 3px 12px;
        border-radius: 4px;
        cursor: pointer;
        backdrop-filter: blur(4px);
    }

    /* Row 3: Buttons (5 Buttons) */
    .mb-controls-row-v3 {
        display: flex;
        justify-content: space-between;
        /* Evenly spaced */
        align-items: center;
        width: 100%;
        padding: 0 10px;
        margin-top: 10px;
    }

    .mb-btn-v3 {
        background: transparent;
        border: none;
        color: #fff;
        display: flex;
        justify-content: center;
        align-items: center;
        width: 40px;
        height: 40px;
        padding: 0;
    }

    .mb-btn-v3 i {
        font-size: 1.4rem;
        opacity: 0.8;
    }

    .mb-btn-v3.large {
        width: 64px;
        height: 64px;
        border-radius: 50%;
    }

    .mb-btn-v3.large i {
        font-size: 2.8rem;
        opacity: 1;
    }

    /* FIX: Playlist Popup Z-Index (Bring to Front) */
    body.show-mobile-player #pop-pl {
        z-index: 20000 !important;
        position: fixed;
        bottom: 0px !important;
        left: 0;
        width: 100% !important;
        max-height: 70vh;
        border-radius: 20px 20px 0 0;
        background: #1e1e1e;
        display: block;
        /* Ensure it overrides any flex/none issues if toggled */
    }

    /* Ensure mask is also high z-index */
    /* Ensure mask is also high z-index and covers screen */
    .pop-mask {
        z-index: 19999 !important;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        display: none;
        backdrop-filter: blur(2px);
    }

    /* =========================================
   V3 Control Button Refactors (Extracted from HTML)
   ========================================= */
    .mb-btn-prev,
    .mb-btn-next {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        width: 50px !important;
        height: 50px !important;
        background: transparent !important;
        border: none !important;
        z-index: 99999 !important;
        padding: 0 !important;
        cursor: pointer;
    }

    .mb-btn-svg {
        filter: drop-shadow(0 0 4px rgba(0, 0, 0, 0.5));
    }

    .mb-btn-play-primary {
        background: #1db954 !important;
        /* Spotify Green */
        border-radius: 50% !important;
        width: 72px !important;
        height: 72px !important;
        border: none !important;
        box-shadow: 0 8px 16px rgba(29, 185, 84, 0.3) !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    .mb-btn-play-primary i {
        font-size: 28px !important;
        color: white !important;
        margin-left: 4px;
        /* Optical center */
    }

    /* Ensure Playlist Button is clickable */
    #active-playlist-btn {
        position: relative;
        z-index: 99999 !important;
    }

    /* =========================================
   MOBILE ACTIONS ROW (Like & Download)
   Added V16
   ========================================= */
    .mobile-actions-row {
        display: flex;
        justify-content: center;
        align-items: center;
        gap: 50px;
        /* Generous spacing */
        margin-top: 10px;
        margin-bottom: 5px;
        width: 100%;
        z-index: 20;
    }

    .mb-action-btn {
        background: transparent;
        border: none;
        color: rgba(255, 255, 255, 0.6);
        font-size: 1.4rem;
        width: 44px;
        height: 44px;
        border-radius: 50%;
        display: flex;
        justify-content: center;
        align-items: center;
        transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
        -webkit-tap-highlight-color: transparent;
    }

    .mb-action-btn:active {
        background: rgba(255, 255, 255, 0.1);
        color: #fff;
        transform: scale(0.92);
    }

    /* Specific button Tweaks */
    #mb-like-btn.fas.fa-heart {
        color: #e74c3c !important;
        /* Loved Red */
        animation: heartPop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    }

    @keyframes heartPop {
        0% {
            transform: scale(1);
        }

        50% {
            transform: scale(1.3);
        }

        100% {
            transform: scale(1);
        }
    }
}


/* =========================================
   Mobile Lyrics Overrides (Added V17)
   Fix for long lines and readability
   ========================================= */
@media (max-width: 768px) {
    body.show-mobile-player .lrc {
        font-size: 1.3rem !important;
        /* Larger text for mobile */
        white-space: pre-wrap !important;
        /* Force wrap */
        word-wrap: break-word !important;
        line-height: 1.6 !important;
        padding: 12px 20px !important;
        /* More padding */
        width: 100%;
        box-sizing: border-box;
    }

    body.show-mobile-player .lrc.active {
        font-size: 1.8rem !important;
        /* Even larger for active line */
        font-weight: 800;
        transform: scale(1.02);
        /* Subtle scale */
        margin: 15px 0;
        /* More vertical space */
        color: #fff;
        text-shadow: 0 0 20px rgba(255, 255, 255, 0.4);
    }
}