@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600;700;800;900&display=swap');

/* ═══════════════════════════════════════════════
   Music Player Modal
═══════════════════════════════════════════════ */

.sp-overlay {
    position: fixed;
    inset: 0;
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.45);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
}
.sp-overlay.open {
    opacity: 1;
    pointer-events: all;
}

.sp-window {
    width: min(960px, 96vw);
    height: min(640px, 90vh);
    background: #111;
    border-radius: 14px;
    border: 1px solid rgba(255,255,255,0.07);
    box-shadow:
        0 48px 120px rgba(0,0,0,0.9),
        0 0 0 0.5px rgba(255,255,255,0.03);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.93) translateY(20px);
    opacity: 0;
    transition:
        transform 0.42s cubic-bezier(0.34, 1.2, 0.64, 1),
        opacity 0.28s ease;
    font-family: 'DM Sans', sans-serif;
    -webkit-font-smoothing: antialiased;
}
.sp-overlay.open .sp-window {
    transform: scale(1) translateY(0);
    opacity: 1;
}

/* ── Content area ─────────────────────────── */
.sp-content {
    flex: 1;
    display: flex;
    min-height: 0;
    overflow: hidden;
}

/* ════════════════════════
   SIDEBAR
════════════════════════ */
.sp-sidebar {
    width: 234px;
    min-width: 234px;
    background: #000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-right: 1px solid rgba(255,255,255,0.05);
}

.sp-sidebar-hdr {
    padding: 14px 14px 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.sp-brand {
    display: flex;
    align-items: center;
    gap: 7px;
    color: #fff;
}
.sp-brand-name {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.03em;
}

.sp-close-btn {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: rgba(255,255,255,0.07);
    border: none;
    color: rgba(255,255,255,0.5);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.14s, color 0.14s;
}
.sp-close-btn:hover { background: rgba(255,255,255,0.14); color: #fff; }

.sp-nav {
    padding: 2px 8px 10px;
    flex-shrink: 0;
}
.sp-nav-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 10px;
    border-radius: 6px;
    background: none;
    border: none;
    color: rgba(255,255,255,0.48);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-align: left;
    letter-spacing: -0.02em;
    transition: color 0.14s, background 0.14s;
}
.sp-nav-btn svg { opacity: 0.6; transition: opacity 0.14s; flex-shrink: 0; }
.sp-nav-btn:hover, .sp-nav-btn.active { color: #fff; }
.sp-nav-btn:hover svg, .sp-nav-btn.active svg { opacity: 1; }

.sp-library {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0 8px;
}
.sp-lib-hdr {
    padding: 8px 10px 6px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
.sp-lib-hdr-text {
    color: rgba(255,255,255,0.42);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: -0.01em;
}
.sp-lib-add-btn {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: none;
    border: none;
    color: rgba(255,255,255,0.35);
    font-size: 20px;
    line-height: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.14s, background 0.14s;
}
.sp-lib-add-btn:hover { color: #fff; background: rgba(255,255,255,0.08); }

.sp-pl-list {
    flex: 1;
    overflow-y: auto;
    scrollbar-width: none;
    padding-bottom: 8px;
}
.sp-pl-list::-webkit-scrollbar { display: none; }

.sp-pl-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.12s;
}
.sp-pl-item:hover { background: rgba(255,255,255,0.06); }
.sp-pl-item.active { background: rgba(255,255,255,0.1); }

.sp-pl-cover {
    width: 40px;
    height: 40px;
    border-radius: 4px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
}
.sp-pl-info { min-width: 0; }
.sp-pl-name {
    color: rgba(255,255,255,0.9);
    font-size: 14px;
    font-weight: 500;
    letter-spacing: -0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sp-pl-sub {
    color: rgba(255,255,255,0.38);
    font-size: 12px;
    margin-top: 2px;
}

/* ════════════════════════
   MAIN CONTENT
════════════════════════ */
.sp-main {
    flex: 1;
    overflow-y: auto;
    min-width: 0;
    background: #121212;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.1) transparent;
}
.sp-main::-webkit-scrollbar { width: 5px; }
.sp-main::-webkit-scrollbar-track { background: transparent; }
.sp-main::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }

.sp-pl-header {
    padding: 30px 24px 16px;
    display: flex;
    align-items: flex-end;
    gap: 20px;
    background: linear-gradient(to bottom, var(--sp-color, #1a1a2a) 0%, #121212 100%);
}
.sp-pl-big-cover {
    width: 142px;
    height: 142px;
    border-radius: 6px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 54px;
    box-shadow: 0 10px 36px rgba(0,0,0,0.55);
}
.sp-pl-meta { padding-bottom: 2px; }
.sp-pl-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.5);
    margin-bottom: 8px;
}
.sp-pl-big-name {
    font-size: 36px;
    font-weight: 800;
    color: #fff;
    letter-spacing: -0.04em;
    line-height: 1.05;
    margin-bottom: 10px;
}
.sp-pl-desc {
    font-size: 13px;
    color: rgba(255,255,255,0.42);
    letter-spacing: -0.01em;
}
.sp-pl-desc strong { color: rgba(255,255,255,0.75); font-weight: 600; }

.sp-actions-row {
    padding: 14px 24px 8px;
    display: flex;
    align-items: center;
    gap: 14px;
}
.sp-big-play-btn {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: #1ed760;
    border: none;
    color: #000;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.12s, background 0.12s;
    box-shadow: 0 4px 20px rgba(30,215,96,0.4);
}
.sp-big-play-btn:hover { transform: scale(1.06); background: #1fdf64; }

.sp-icon-btn {
    background: none;
    border: none;
    color: rgba(255,255,255,0.35);
    cursor: pointer;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.14s;
}
.sp-icon-btn:hover { color: #fff; }
.sp-icon-btn.active { color: #1ed760; }

/* Track list */
.sp-track-list { padding: 0 16px 28px; }
.sp-track-list-hdr {
    display: grid;
    grid-template-columns: 36px 1fr 1fr 44px;
    gap: 8px;
    padding: 4px 16px 8px;
    border-bottom: 1px solid rgba(255,255,255,0.07);
    margin-bottom: 4px;
    color: rgba(255,255,255,0.3);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.sp-track {
    display: grid;
    grid-template-columns: 36px 1fr 1fr 44px;
    gap: 8px;
    align-items: center;
    padding: 5px 16px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.1s;
}
.sp-track:hover { background: rgba(255,255,255,0.06); }
.sp-track.active { background: rgba(30,215,96,0.07); }

.sp-track-num {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}
.sp-track-num-val {
    color: rgba(255,255,255,0.35);
    font-size: 13.5px;
    font-weight: 400;
    font-variant-numeric: tabular-nums;
}
.sp-track.active .sp-track-num-val { display: none; }
.sp-track:hover .sp-track-num-val { display: none; }
.sp-track:hover .sp-hover-play-ic { display: flex !important; }
.sp-track.active .sp-hover-play-ic { display: none !important; }
.sp-track.active:hover .sp-hover-play-ic { display: flex !important; }
.sp-track.active:hover .sp-playing-bars { display: none !important; }

.sp-hover-play-ic {
    display: none;
    align-items: center;
    justify-content: center;
    color: #fff;
}

/* Animated playing bars */
@keyframes sp-b1 { 0%,100%{transform:scaleY(.35)} 50%{transform:scaleY(1)} }
@keyframes sp-b2 { 0%,100%{transform:scaleY(1)}   50%{transform:scaleY(.3)} }
@keyframes sp-b3 { 0%,100%{transform:scaleY(.5)}  33%{transform:scaleY(1)} 66%{transform:scaleY(.2)} }

.sp-playing-bars {
    display: none;
    align-items: flex-end;
    justify-content: center;
    gap: 2px;
    height: 14px;
}
.sp-track.active .sp-playing-bars { display: flex; }
.sp-playing-bars span {
    display: block;
    width: 3px;
    background: #1ed760;
    border-radius: 1.5px;
    transform-origin: bottom;
}
.sp-playing-bars span:nth-child(1) { height: 8px;  animation: sp-b1 0.8s ease infinite; }
.sp-playing-bars span:nth-child(2) { height: 12px; animation: sp-b2 0.9s ease infinite 0.15s; }
.sp-playing-bars span:nth-child(3) { height: 6px;  animation: sp-b3 0.75s ease infinite 0.05s; }

.sp-track-info {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}
.sp-track-art {
    width: 36px;
    height: 36px;
    border-radius: 3px;
    flex-shrink: 0;
}
.sp-track-text { min-width: 0; }
.sp-track-title {
    color: rgba(255,255,255,0.92);
    font-size: 14px;
    font-weight: 600;
    letter-spacing: -0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sp-track.active .sp-track-title { color: #1ed760; }
.sp-track-artist {
    color: rgba(255,255,255,0.42);
    font-size: 12.5px;
    font-weight: 400;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sp-track-album {
    color: rgba(255,255,255,0.4);
    font-size: 13px;
    font-weight: 400;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sp-track-dur {
    color: rgba(255,255,255,0.35);
    font-size: 12.5px;
    font-weight: 400;
    font-variant-numeric: tabular-nums;
    text-align: right;
}

/* ════════════════════════
   PLAYER BAR
════════════════════════ */
.sp-player {
    height: 90px;
    flex-shrink: 0;
    border-top: 1px solid rgba(255,255,255,0.07);
    background: #0c0c0c;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 0 20px;
    gap: 12px;
}

.sp-player-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}
.sp-np-art {
    width: 48px;
    height: 48px;
    border-radius: 4px;
    flex-shrink: 0;
    background: #333;
    transition: background 0.3s;
}
.sp-np-info { min-width: 0; }
.sp-np-title {
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: -0.02em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sp-np-artist {
    color: rgba(255,255,255,0.45);
    font-size: 12.5px;
    font-weight: 400;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sp-heart-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    color: rgba(255,255,255,0.28);
    display: flex;
    align-items: center;
    flex-shrink: 0;
    transition: color 0.14s, transform 0.14s;
}
.sp-heart-btn:hover { color: rgba(255,255,255,0.8); }
.sp-heart-btn.liked { color: #1ed760; }
.sp-heart-btn.liked:hover { transform: scale(1.15); }

.sp-player-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 7px;
    padding: 14px 0;
}

.sp-ctrl-row {
    display: flex;
    align-items: center;
    gap: 2px;
}
.sp-ctrl-btn {
    background: none;
    border: none;
    color: rgba(255,255,255,0.38);
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.14s, transform 0.1s;
    position: relative;
}
.sp-ctrl-btn:hover { color: #fff; }
.sp-ctrl-btn.active { color: #1ed760; }
.sp-ctrl-btn.active::after {
    content: '';
    position: absolute;
    bottom: 1px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: #1ed760;
}

.sp-play-pause-btn {
    width: 34px;
    height: 34px;
    background: #fff;
    border-radius: 50%;
    color: #000;
    margin: 0 6px;
}
.sp-play-pause-btn:hover { background: #f0f0f0; color: #000; transform: scale(1.06); }

.sp-seek-row {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 330px;
}
.sp-time {
    color: rgba(255,255,255,0.3);
    font-size: 11px;
    font-weight: 400;
    font-variant-numeric: tabular-nums;
    min-width: 30px;
}
.sp-time:last-child { text-align: right; }

.sp-seek-bar {
    flex: 1;
    height: 4px;
    background: rgba(255,255,255,0.14);
    border-radius: 2px;
    cursor: pointer;
    position: relative;
    transition: height 0.12s;
}
.sp-seek-bar:hover { height: 6px; }
.sp-seek-fill {
    height: 100%;
    border-radius: inherit;
    background: rgba(255,255,255,0.8);
    pointer-events: none;
    transition: background 0.12s;
    width: 0%;
}
.sp-seek-bar:hover .sp-seek-fill { background: #1ed760; }

.sp-player-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
}
.sp-vol-bar {
    width: 88px;
    height: 4px;
    background: rgba(255,255,255,0.14);
    border-radius: 2px;
    cursor: pointer;
    transition: height 0.12s;
}
.sp-vol-bar:hover { height: 6px; }
.sp-vol-fill {
    height: 100%;
    border-radius: inherit;
    background: rgba(255,255,255,0.8);
    pointer-events: none;
    transition: background 0.12s;
}
.sp-vol-bar:hover .sp-vol-fill { background: #1ed760; }

/* ════════════════════════════════════════════════
   Pull-handle (mobile only — hidden on desktop)
════════════════════════════════════════════════ */
.sp-handle-bar {
    display: none;
    flex-shrink: 0;
    height: 22px;
    position: relative;
    cursor: grab;
}
.sp-handle-bar::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 36px;
    height: 4px;
    border-radius: 2px;
    background: rgba(255,255,255,0.18);
}

/* ════════════════════════════════════════════════
   Mobile — 768px and below
════════════════════════════════════════════════ */
@media (max-width: 768px) {

    /* Bottom sheet animation */
    .sp-overlay {
        align-items: flex-end;
        background: rgba(0,0,0,0.55);
    }
    .sp-window {
        width: 100%;
        height: 92dvh;
        height: 92vh; /* fallback */
        border-radius: 20px 20px 0 0;
        transform: translateY(100%);
        opacity: 1; /* don't fade, just slide */
    }
    .sp-overlay.open .sp-window {
        transform: translateY(0);
        opacity: 1;
    }

    /* Show pull handle */
    .sp-handle-bar { display: block; }

    /* Hide sidebar entirely */
    .sp-sidebar { display: none; }

    /* Scrolling feel */
    .sp-main {
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }

    /* Smaller playlist header */
    .sp-pl-header {
        padding: 20px 16px 12px;
        gap: 14px;
    }
    .sp-pl-big-cover {
        width: 88px;
        height: 88px;
        font-size: 36px;
    }
    .sp-pl-big-name {
        font-size: 22px;
        margin-bottom: 6px;
    }
    .sp-pl-label { margin-bottom: 4px; }

    /* 3-column track list (drop album) */
    .sp-track-list-hdr,
    .sp-track {
        grid-template-columns: 36px 1fr 44px;
    }
    .sp-track-album { display: none; }
    /* hide the 3rd header span (Album) */
    .sp-track-list-hdr span:nth-child(3) { display: none; }

    /* Bigger touch targets on rows */
    .sp-track { min-height: 50px; }
    .sp-pl-item { padding: 8px 10px; }

    /* ── Player bar — stacked layout ── */
    .sp-player {
        display: flex;
        flex-direction: column;
        height: auto;
        padding: 8px 20px calc(14px + env(safe-area-inset-bottom));
        gap: 0;
        align-items: stretch;
    }

    /* Controls + seek bar first */
    .sp-player-center {
        order: 1;
        padding: 0;
        width: 100%;
        gap: 6px;
    }

    /* Hide shuffle + repeat on mobile */
    #spShuffleBtn, #spRepeatBtn { display: none; }

    /* Seek row full width */
    .sp-seek-row {
        width: 100%;
        max-width: none;
        gap: 6px;
    }

    /* Now-playing info below */
    .sp-player-left {
        order: 2;
        padding-top: 8px;
    }

    /* Hide volume */
    .sp-player-right { display: none; }

    /* Larger play button on mobile */
    .sp-play-pause-btn {
        width: 40px;
        height: 40px;
    }
}

/* ════════════════════════════════════════════════
   Mobile — 430px and below (iPhone SE → 14 Pro Max)
════════════════════════════════════════════════ */
@media (max-width: 430px) {
    .sp-window {
        height: 94dvh;
        height: 94vh;
        border-radius: 16px 16px 0 0;
    }
    .sp-pl-big-cover {
        width: 72px;
        height: 72px;
        font-size: 28px;
    }
    .sp-pl-big-name { font-size: 19px; }
    .sp-pl-desc { font-size: 11.5px; }

    .sp-time {
        font-size: 10px;
        min-width: 24px;
    }
    .sp-track-title { font-size: 13px; }
    .sp-track-artist { font-size: 11.5px; }

    .sp-player {
        padding: 6px 16px calc(12px + env(safe-area-inset-bottom));
    }
    .sp-np-title { font-size: 13px; }
    .sp-np-artist { font-size: 11.5px; }
}
