/* ================================================================
   vibewave-mobile.css  —  Mobile UI overlay
   Breakpoint : max-width 767px
   Accent      : #8b5cf6 (purple)
   ================================================================ */

/* ── Desktop: hide mobile-only elements ── */
.vw-mobile-header,
.vw-mobile-search-bar,
.vw-mobile-drawer-overlay {
    display: none;
}

/* Scroll-lock when drawer is open */
body.vw-drawer-open {
    overflow: hidden;
    touch-action: none;
}

/* ================================================================
   @media (max-width: 767px)
   ================================================================ */
@media (max-width: 767px) {

    /* ── Body ── */
    body.theme-public-classic {
        overflow-x: hidden;
    }

    /* ── App shell ── */
    .app {
        display: flex !important;
        flex-direction: column !important;
        height: auto !important;
        min-height: 100svh;
        overflow: visible !important;
        padding: calc(56px + env(safe-area-inset-top, 0px)) 14px 0 !important;
        gap: 0 !important;
        max-width: 100% !important;
    }

    /* ── Hide desktop columns ── */
    .sidebar,
    .right-panel,
    .sticky-header {
        display: none !important;
    }

    /* ── Main content ── */
    .main-content {
        width: 100% !important;
        flex: 1 1 auto;
        min-width: 0;
        overflow: visible !important;
        overflow-x: hidden !important;
        padding-right: 0 !important;
    }

    /* ── Mobile header: fixed top bar ── */
    .vw-mobile-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 200;
        height: calc(56px + env(safe-area-inset-top, 0px));
        padding: env(safe-area-inset-top, 0px) max(12px, env(safe-area-inset-right, 12px)) 0 max(12px, env(safe-area-inset-left, 12px));
        background: rgba(8, 9, 18, 0.94);
        backdrop-filter: blur(18px);
        -webkit-backdrop-filter: blur(18px);
        border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    }

    /* ── Mobile header: icon buttons ── */
    .vw-mh-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        background: rgba(255, 255, 255, 0.08);
        border: none;
        border-radius: 12px;
        color: #eef2ff;
        font-size: 17px;
        cursor: pointer;
        flex-shrink: 0;
        -webkit-tap-highlight-color: transparent;
        transition: background 0.14s, transform 0.1s;
    }

    .vw-mh-btn:active {
        background: rgba(139, 92, 246, 0.3);
        transform: scale(0.92);
    }

    /* ── Mobile header: logo ── */
    .vw-mh-logo {
        text-decoration: none;
        flex: 1;
        text-align: center;
        padding: 0 8px;
    }

    .vw-mh-logo-text {
        font-size: 15px;
        font-weight: 800;
        color: #eef2ff;
        letter-spacing: 0.05em;
        white-space: nowrap;
    }

    .vw-mh-logo-dot {
        color: #8b5cf6;
    }

    /* ── Search bar: drops below mobile header ── */
    .vw-mobile-search-bar {
        display: none;
        position: fixed;
        top: calc(56px + env(safe-area-inset-top, 0px));
        left: 0;
        right: 0;
        z-index: 199;
        padding: 8px 12px 10px;
        background: rgba(8, 9, 18, 0.97);
        backdrop-filter: blur(18px);
        -webkit-backdrop-filter: blur(18px);
        border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    }

    .vw-mobile-search-bar.is-visible {
        display: block;
        animation: vwSearchIn 0.18s ease;
    }

    @keyframes vwSearchIn {
        from { opacity: 0; transform: translateY(-6px); }
        to   { opacity: 1; transform: translateY(0); }
    }

    .vw-msb-inner {
        display: flex;
        align-items: center;
        gap: 10px;
        background: rgba(255, 255, 255, 0.07);
        border: 1px solid rgba(139, 92, 246, 0.32);
        border-radius: 40px;
        padding: 10px 16px;
    }

    .vw-msb-inner .fa-search {
        color: #8b5cf6;
        font-size: 14px;
        flex-shrink: 0;
    }

    .vw-msb-inner input[type="text"] {
        flex: 1;
        background: transparent;
        border: none;
        outline: none;
        color: #eef2ff;
        font-size: 15px;
        min-width: 0;
        font-family: inherit;
    }

    .vw-msb-inner input[type="text"]::placeholder {
        color: #6b7280;
    }

    .vw-msb-close {
        display: flex;
        align-items: center;
        justify-content: center;
        background: none;
        border: none;
        color: #8b9ec0;
        font-size: 15px;
        cursor: pointer;
        padding: 2px;
        -webkit-tap-highlight-color: transparent;
    }

    /* ── Drawer overlay (backdrop) ── */
    .vw-mobile-drawer-overlay {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 400;
        background: rgba(0, 0, 0, 0.62);
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
        visibility: hidden;
        opacity: 0;
        transition: opacity 0.24s ease, visibility 0.24s ease;
    }

    .vw-mobile-drawer-overlay.is-open {
        visibility: visible;
        opacity: 1;
    }

    /* ── Drawer panel ── */
    .vw-mobile-drawer {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: 280px;
        max-width: 82vw;
        z-index: 401;
        background: rgba(10, 10, 22, 0.97);
        backdrop-filter: blur(22px);
        -webkit-backdrop-filter: blur(22px);
        border-right: 1px solid rgba(255, 255, 255, 0.07);
        box-shadow: 6px 0 30px rgba(0, 0, 0, 0.52);
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.22, 0.88, 0.38, 1.06);
        display: flex;
        flex-direction: column;
        overflow-y: auto;
        padding: calc(env(safe-area-inset-top, 0px) + 20px) 16px calc(env(safe-area-inset-bottom, 0px) + 20px);
        overscroll-behavior: contain;
        scrollbar-width: none;
    }

    .vw-mobile-drawer::-webkit-scrollbar { display: none; }

    .vw-mobile-drawer-overlay.is-open .vw-mobile-drawer {
        transform: translateX(0);
    }

    /* ── Drawer: user header ── */
    .vw-md-head {
        display: flex;
        align-items: center;
        gap: 12px;
        padding-bottom: 18px;
        margin-bottom: 6px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.08);
        flex-shrink: 0;
    }

    .vw-md-avatar {
        width: 48px;
        height: 48px;
        border-radius: 50%;
        background: linear-gradient(135deg, #8b5cf6, #6366f1);
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
        overflow: hidden;
    }

    .vw-md-avatar i { font-size: 22px; color: #fff; }

    .vw-md-avatar img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    .vw-md-user-info {
        flex: 1;
        min-width: 0;
    }

    .vw-md-user-name {
        font-size: 14px;
        font-weight: 600;
        color: #eef2ff;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .vw-md-user-sub {
        font-size: 11px;
        color: #6b7280;
        margin-top: 2px;
    }

    .vw-md-close-btn {
        width: 34px;
        height: 34px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: rgba(255, 255, 255, 0.06);
        border: none;
        border-radius: 10px;
        color: #8b9ec0;
        cursor: pointer;
        font-size: 14px;
        flex-shrink: 0;
        -webkit-tap-highlight-color: transparent;
        transition: background 0.14s;
    }

    .vw-md-close-btn:active {
        background: rgba(139, 92, 246, 0.24);
    }

    /* ── Drawer: section label ── */
    .vw-md-sep-label {
        font-size: 10px;
        font-weight: 700;
        letter-spacing: 0.12em;
        color: rgba(139, 92, 246, 0.65);
        padding: 14px 6px 4px;
        flex-shrink: 0;
    }

    /* ── Drawer: nav list ── */
    .vw-md-nav {
        display: flex;
        flex-direction: column;
        gap: 2px;
    }

    .vw-md-link {
        display: flex;
        align-items: center;
        gap: 14px;
        padding: 11px 12px;
        border-radius: 12px;
        text-decoration: none;
        color: #b8c2dc;
        font-size: 14px;
        font-weight: 500;
        background: transparent;
        border: none;
        cursor: pointer;
        width: 100%;
        text-align: left;
        font-family: inherit;
        -webkit-tap-highlight-color: transparent;
        transition: background 0.14s, color 0.14s;
    }

    .vw-md-link i {
        width: 20px;
        font-size: 15px;
        text-align: center;
        color: #596885;
        flex-shrink: 0;
        transition: color 0.14s;
    }

    .vw-md-link:active,
    .vw-md-link:hover {
        background: rgba(255, 255, 255, 0.06);
        color: #eef2ff;
    }

    .vw-md-link:active i,
    .vw-md-link:hover i {
        color: #8b5cf6;
    }

    .vw-md-link.active {
        background: rgba(139, 92, 246, 0.18);
        color: #c4b5fd;
    }

    .vw-md-link.active i {
        color: #8b5cf6;
    }

    .vw-md-nav form { margin: 0; }

    /* ── Entity hero: stack vertically ── */
    .xtrenew-entity-header,
    .playlist-hero {
        flex-direction: column !important;
        align-items: center !important;
        text-align: center;
        gap: 14px !important;
        padding: 16px 0 !important;
    }

    .xtrenew-entity-cover,
    .playlist-cover-large {
        width: 140px !important;
        height: 140px !important;
        flex-shrink: 0;
    }

    .playlist-info h1,
    .xtrenew-entity-header h1 {
        font-size: clamp(1.2rem, 5vw, 1.5rem) !important;
    }

    .meta-info {
        justify-content: center !important;
        flex-wrap: wrap;
    }

    .action-buttons {
        justify-content: center !important;
    }

    /* ── Grids: 2 columns ── */
    .album-grid,
    .playlist-grid,
    .albums-grid,
    .artist-albums-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 12px !important;
    }

    /* ── Song rows: touch-friendly ── */
    .xtrenew-song-row {
        padding-top: 8px !important;
        padding-bottom: 8px !important;
        min-height: 56px;
    }

}

/* ================================================================
   MINI BAR + SWIPE-UP SHEET  (max-width: 767px)
   ================================================================ */

/* ── YouTube portal: JS sets inline !important styles (see page-hooks.js)  ──
   This CSS is only a lightweight fallback for non-play pages. The JS fix
   covers play-page calibration timers that re-fire at 0/80/240/700 ms. ── */
@media (max-width: 767px) {
    body:not(.xt-route-play) #xt-player-portal.xt-player-portal {
        bottom: calc(70px + env(safe-area-inset-bottom, 0px)) !important;
        right: 10px !important;
        left: auto !important;
        top: auto !important;
        width: 160px !important;
        height: 90px !important;
        min-width: 0 !important;
        min-height: 0 !important;
        max-width: none !important;
        border-radius: 12px !important;
    }
    /* Keep visible even before xt-play-anchor-ready on mobile */
    body.xt-route-play:not(.xt-play-anchor-ready) #xt-player-portal.xt-player-portal.is-active {
        opacity: 1 !important;
        visibility: visible !important;
        pointer-events: auto !important;
    }
}

/* ── Reduce body padding-bottom for 64px mini bar ── */
@media (max-width: 767px) {
    body.theme-public-classic {
        padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px)) !important;
    }
}

/* ── Mini bar: compact single-row player ── */
@media (max-width: 767px) {
    body:not(.vw-player-sheet-open) .xt-gp-main {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        min-height: 0 !important;
        height: 64px !important;
        padding: 0 10px 0 10px !important;
        padding-bottom: env(safe-area-inset-bottom, 0px) !important;
        gap: 0 !important;
        position: relative;
    }

    /* Progress line at top of mini bar */
    body:not(.vw-player-sheet-open) .xt-gp-timeline {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        height: 3px;
        gap: 0;
        padding: 0;
        pointer-events: none;
    }
    body:not(.vw-player-sheet-open) .xt-gp-time { display: none; }
    body:not(.vw-player-sheet-open) .xt-gp-progress {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 3px;
        margin: 0;
        padding: 0;
        border-radius: 0;
        pointer-events: auto;
        accent-color: #8b5cf6;
        opacity: 0.7;
    }
    body:not(.vw-player-sheet-open) .xt-gp-progress::-webkit-slider-thumb {
        -webkit-appearance: none;
        width: 12px;
        height: 12px;
        border-radius: 50%;
        background: #8b5cf6;
        opacity: 0;
    }
    body:not(.vw-player-sheet-open) .xt-gp-progress:active::-webkit-slider-thumb {
        opacity: 1;
    }

    /* Left: cover + title — tap area to open sheet */
    body:not(.vw-player-sheet-open) .xt-gp-left {
        flex: 1 1 auto !important;
        min-width: 0;
        overflow: hidden;
        gap: 10px !important;
        cursor: pointer;
    }
    body:not(.vw-player-sheet-open) .xt-gp-cover-link {
        width: 44px !important;
        height: 44px !important;
        flex-shrink: 0 !important;
        pointer-events: none; /* tap handled by .xt-gp-left */
    }
    body:not(.vw-player-sheet-open) .xt-gp-cover,
    body:not(.vw-player-sheet-open) .xt-gp-cover-placeholder {
        width: 44px !important;
        height: 44px !important;
        border-radius: 10px !important;
    }
    body:not(.vw-player-sheet-open) .xt-gp-media {
        flex: 1;
        min-width: 0;
    }
    body:not(.vw-player-sheet-open) .xt-gp-title-row { margin-bottom: 0 !important; }
    body:not(.vw-player-sheet-open) .xt-gp-title {
        font-size: 13px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    body:not(.vw-player-sheet-open) .xt-gp-meta-line {
        font-size: 11px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    body:not(.vw-player-sheet-open) .xt-gp-inline-actions { display: none !important; }
    body:not(.vw-player-sheet-open) .xt-gp-playlist-popover { display: none !important; }

    /* Center: prev / play / next only */
    body:not(.vw-player-sheet-open) .xt-gp-center {
        flex: 0 0 auto !important;
    }
    body:not(.vw-player-sheet-open) .xt-gp-controls {
        display: flex !important;
        align-items: center;
        gap: 0;
    }
    body:not(.vw-player-sheet-open) .xt-gp-icon-btn[data-xt-player-shuffle],
    body:not(.vw-player-sheet-open) .xt-gp-icon-btn[data-xt-player-repeat] { display: none !important; }
    body:not(.vw-player-sheet-open) .xt-gp-resume-btn:not([hidden]) {
        padding: 6px 10px !important;
        font-size: 11px !important;
    }

    /* Right: hide everything */
    body:not(.vw-player-sheet-open) .xt-gp-right { display: none !important; }
    body:not(.vw-player-sheet-open) .xt-gp-mobile-drawer-btn { display: none !important; }

    /* Touch-friendly control buttons */
    body:not(.vw-player-sheet-open) .xt-gp-icon-btn {
        width: 40px !important;
        height: 40px !important;
        font-size: 17px !important;
    }
    body:not(.vw-player-sheet-open) .xt-gp-play-btn {
        width: 46px !important;
        height: 46px !important;
        font-size: 19px !important;
    }
}

/* ── Close/drag handle button ── */
.vw-sheet-close-btn {
    display: none;
    width: 100%;
    padding: calc(env(safe-area-inset-top, 0px) + 10px) 0 6px;
    background: none;
    border: none;
    cursor: pointer;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}
.vw-sheet-close-btn::after {
    content: '';
    display: block;
    width: 48px;
    height: 5px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.22);
    margin: 0 auto;
}

/* ── Swipe-up sheet: full-screen expanded player ── */
@media (max-width: 767px) {
    body.vw-player-sheet-open {
        overflow: hidden;
        touch-action: none;
    }

    body.vw-player-sheet-open #xt-global-player-shell:not([hidden]) {
        top: 0 !important;
    }

    body.vw-player-sheet-open .xt-gp-surface {
        height: 100dvh;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        display: flex;
        flex-direction: column;
        border-radius: 0;
        scrollbar-width: none;
    }
    body.vw-player-sheet-open .xt-gp-surface::-webkit-scrollbar { display: none; }

    body.vw-player-sheet-open .vw-sheet-close-btn {
        display: block;
    }

    /* Sheet: main container — column layout */
    body.vw-player-sheet-open .xt-gp-main {
        display: flex !important;
        flex-direction: column !important;
        height: auto !important;
        min-height: 0 !important;
        padding: 16px 24px calc(env(safe-area-inset-bottom, 0px) + 24px) !important;
        align-items: center !important;
        gap: 0 !important;
        flex: 0 0 auto;
    }

    /* Sheet: large cover */
    body.vw-player-sheet-open .xt-gp-left {
        flex-direction: column !important;
        align-items: center !important;
        text-align: center;
        width: 100%;
        cursor: default;
        gap: 0 !important;
    }
    body.vw-player-sheet-open .xt-gp-cover-link {
        width: 220px !important;
        height: 220px !important;
        margin-bottom: 20px;
        pointer-events: auto !important;
        flex-shrink: 0 !important;
    }
    body.vw-player-sheet-open .xt-gp-cover,
    body.vw-player-sheet-open .xt-gp-cover-placeholder {
        width: 220px !important;
        height: 220px !important;
        border-radius: 20px !important;
        box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255,255,255,0.06);
    }
    body.vw-player-sheet-open .xt-gp-title {
        font-size: 18px !important;
        white-space: normal !important;
        text-align: center;
        line-height: 1.3;
    }
    body.vw-player-sheet-open .xt-gp-meta-line {
        font-size: 13px !important;
        text-align: center;
        justify-content: center;
        white-space: normal !important;
        margin-top: 4px;
    }
    body.vw-player-sheet-open .xt-gp-title-row { margin-bottom: 2px !important; }

    /* Inline actions: show in sheet */
    body.vw-player-sheet-open .xt-gp-inline-actions {
        display: flex !important;
        justify-content: center;
        gap: 12px;
        margin-top: 14px;
        width: 100%;
    }
    body.vw-player-sheet-open .xt-gp-inline-btn {
        width: 42px !important;
        height: 42px !important;
        display: flex !important;
        align-items: center;
        justify-content: center;
        background: rgba(255, 255, 255, 0.08) !important;
        border-radius: 50% !important;
        font-size: 16px !important;
    }

    /* Sheet: center controls */
    body.vw-player-sheet-open .xt-gp-center {
        display: flex !important;
        flex-direction: column;
        width: 100%;
        align-items: stretch;
        gap: 12px;
        margin-top: 22px;
        flex: 0 0 auto;
    }

    /* Timeline: full, above controls */
    body.vw-player-sheet-open .xt-gp-timeline {
        display: flex !important;
        order: -1;
        align-items: center;
        gap: 8px;
        width: 100%;
        position: static !important;
        height: auto !important;
        pointer-events: auto !important;
    }
    body.vw-player-sheet-open .xt-gp-time {
        display: inline !important;
        font-size: 12px;
        color: rgba(255, 255, 255, 0.55);
        min-width: 32px;
        text-align: center;
    }
    body.vw-player-sheet-open .xt-gp-progress {
        position: static !important;
        inset: auto !important;
        flex: 1;
        height: 4px;
        opacity: 1 !important;
        accent-color: #8b5cf6;
    }
    body.vw-player-sheet-open .xt-gp-progress::-webkit-slider-thumb {
        opacity: 1 !important;
        width: 16px;
        height: 16px;
    }

    /* Show shuffle + repeat in sheet */
    body.vw-player-sheet-open .xt-gp-icon-btn[data-xt-player-shuffle],
    body.vw-player-sheet-open .xt-gp-icon-btn[data-xt-player-repeat] {
        display: inline-flex !important;
    }
    body.vw-player-sheet-open .xt-gp-controls {
        justify-content: center !important;
        gap: 6px;
    }
    body.vw-player-sheet-open .xt-gp-icon-btn {
        width: 50px !important;
        height: 50px !important;
        font-size: 18px !important;
    }
    body.vw-player-sheet-open .xt-gp-play-btn {
        width: 62px !important;
        height: 62px !important;
        font-size: 22px !important;
    }

    /* Sheet: right section (queue button) */
    body.vw-player-sheet-open .xt-gp-right {
        display: flex !important;
        justify-content: center;
        align-items: center;
        width: 100%;
        margin-top: 16px;
        flex: 0 0 auto;
        gap: 10px;
    }
    body.vw-player-sheet-open .xt-gp-count-chip { display: inline-flex !important; }
    body.vw-player-sheet-open .xt-gp-chip-btn--queue { display: inline-flex !important; }
    body.vw-player-sheet-open .xt-gp-mobile-drawer-btn { display: none !important; }
    body.vw-player-sheet-open .xt-gp-volume-wrap { display: none !important; }

    /* Queue panel: still works as bottom sheet inside the full sheet */
    body.vw-player-sheet-open .xt-gp-queue-panel {
        flex: 1 1 auto;
    }
}
