.mobile-bar,
.mini-player,
.nav-backdrop {
    display: none;
}

@media (max-width: 768px) {
    :root {
        --bar-h: 52px;
        --player-h: 40px;
        --mini-h: 58px;
    }

    html,
    body {
        height: 100%;
    }

    body {
        display: block;
        height: 100dvh;
        overflow: hidden;
        -webkit-tap-highlight-color: transparent;
    }

    .mobile-bar {
        display: flex;
        align-items: center;
        gap: 10px;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 60;
        box-sizing: border-box;
        height: calc(var(--bar-h) + env(safe-area-inset-top));
        padding: env(safe-area-inset-top) 8px 0 8px;
        background: #000000;
        color: #ffffff;
        border-bottom: 1px solid #282828;
    }

    .menu-btn {
        width: 44px;
        height: 44px;
        font-size: 24px;
        color: #ffffff;
    }

    .mobile-title {
        font-size: 18px;
        font-weight: bold;
    }

    .nav-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 150;
        background: rgba(0, 0, 0, 0.65);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.2s;
    }

    .nav-open .nav-backdrop {
        opacity: 1;
        pointer-events: auto;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 200;
        width: min(84vw, 320px);
        height: auto;
        padding: calc(16px + env(safe-area-inset-top)) 12px calc(var(--player-h) + env(safe-area-inset-bottom) + 24px) 12px;
        overflow-y: auto;
        overscroll-behavior: contain;
        transform: translateX(-100%);
        transition: transform 0.22s ease;
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.6);
    }

    .nav-open .sidebar {
        transform: translateX(0);
    }

    .sidebar button {
        padding: 12px 10px;
        font-size: 15px;
    }

    .sidebar .currently-playing {
        display: none;
    }

    .main {
        position: fixed;
        top: calc(var(--bar-h) + env(safe-area-inset-top));
        left: 0;
        right: 0;
        bottom: 0;
        width: auto;
        box-sizing: border-box;
        padding: 12px 14px calc(var(--player-h) + var(--mini-h) + env(safe-area-inset-bottom) + 20px) 14px;
        overflow-y: auto;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
    }

    .search-box {
        position: sticky;
        top: 0;
        z-index: 5;
        margin: -12px -14px 10px -14px;
        padding: 12px 14px 8px 14px;
        background: #121212;
    }

    .search-box input {
        padding: 11px 12px;
        font-size: 16px;
    }

    .shelf {
        margin-bottom: 20px;
    }

    .shelf-head {
        flex-wrap: wrap;
        gap: 8px;
    }

    .shelf-head .shelf-select {
        max-width: 100%;
        font-size: 16px;
        border-color: #333333;
        padding: 6px 8px;
    }

    .shelf-nav {
        display: none !important;
    }

    #top-tracks,
    #new-tracks,
    #public-playlists,
    #albums,
    #artist-tracks {
        scroll-snap-type: x proximity;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
    }

    #top-tracks li:not(.empty),
    #public-playlists li:not(.empty),
    #albums li:not(.empty),
    #artist-tracks li:not(.empty) {
        width: min(74vw, 270px);
        scroll-snap-align: start;
    }

    #new-tracks {
        grid-auto-columns: min(74vw, 270px);
    }

    #new-tracks li:not(.empty) {
        width: auto;
        scroll-snap-align: start;
    }

    #tracks {
        grid-template-columns: 1fr;
    }

    .tracks li {
        padding: 8px;
    }

    .tracks li .cover {
        width: 68px;
        height: 68px;
        min-width: 68px;
        min-height: 68px;
    }

    .player-container {
        padding: 0 0 env(safe-area-inset-bottom) 0;
        border-top: 1px solid #282828;
    }

    .fp {
        padding: 0 10px;
        gap: 8px;
    }

    .fp-vol {
        display: none;
    }

    .fp-time {
        font-size: 12px;
    }

    
    .fp-wave {
        display: none;
    }

    .mini-player {
        display: flex;
        align-items: center;
        gap: 10px;
        position: fixed;
        left: 0;
        right: 0;
        bottom: calc(var(--player-h) + env(safe-area-inset-bottom));
        z-index: 80;
        box-sizing: border-box;
        height: var(--mini-h);
        padding: 0 12px;
        background: #202020;
        border-top: 1px solid #333333;
        cursor: pointer;
    }

    .mini-player img {
        width: 42px;
        height: 42px;
        min-width: 42px;
        object-fit: cover;
        background: #282828;
    }

    .mini-text {
        display: flex;
        flex-direction: column;
        min-width: 0;
        flex: 1;
    }

    .mini-text b {
        font-size: 14px;
        color: #ffffff;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .mini-text span {
        font-size: 12px;
        color: #b3b3b3;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .track-detail {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: calc(var(--player-h) + env(safe-area-inset-bottom));
        width: 100% !important;
        max-width: 100%;
        height: auto;
        z-index: 90;
        padding: 0 16px 28px 16px;
        overflow-y: auto;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
    }

    .resize-handle {
        display: none;
    }

    .detail-actions {
        position: sticky;
        top: 0;
        z-index: 5;
        padding: calc(10px + env(safe-area-inset-top)) 0 10px 0;
        margin: 0;
        background: #000000;
    }

    .detail-actions .osb-btn {
        flex: 1 1 auto;
    }

    .track-detail .cover-art img {
        max-width: min(280px, 80vw);
    }

    .osb-input,
    .osb-select {
        height: 42px;
        font-size: 16px;
    }

    .osb-btn,
    .sidebar .osb-btn {
        height: 42px;
        font-size: 14px;
    }

    .osb-btn.sm,
    .sidebar .osb-btn.sm {
        height: 32px;
        font-size: 12px;
    }

    .comment-gif {
        max-width: 100%;
    }

    .tenor-embed {
        width: 100%;
    }
}
