:root {
    --green: #1DB954;
    --green-light: #1ed760;
    --black: #191414;
    --text-base: #FFFFFF;
    --text-subdued: #B3B3B3;
    --bg-base: #121212;
    --bg-highlight: #181818;
    --bg-press: #282828;
    --card-bg: #181818;
    --scrollbar-bg: rgba(255, 255, 255, 0.1);
    --layout-sidebar-width: 240px;
    --layout-player-height: 90px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 12px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--scrollbar-bg);
    border: 3px solid transparent;
    background-clip: padding-box;
    border-radius: 6px;
}

::-webkit-scrollbar-thumb:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

body {
    font-family: 'Circular Std', 'Figtree', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: #000;
    color: var(--text-base);
    height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

.mobile-only {
    display: none !important;
}

/* --- Layout --- */
.app-container {
    display: grid;
    grid-template-columns: var(--layout-sidebar-width) 1fr;
    grid-template-rows: 1fr var(--layout-player-height);
    height: 100vh;
    grid-template-areas: 
        "sidebar main"
        "player player";
}

/* --- Sidebar --- */
.sidebar {
    grid-area: sidebar;
    background-color: #000000;
    padding: 24px 8px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    font-weight: 700;
    font-size: 14px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 22px;
    padding: 0 16px;
    margin-bottom: 8px;
    color: var(--text-base);
}

.logo i {
    color: var(--green);
    font-size: 28px;
}

.nav-links {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-links a {
    text-decoration: none;
    color: var(--text-subdued);
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 16px;
    border-radius: 4px;
    transition: color 0.2s ease, background-color 0.2s;
}

.nav-links a:hover, .nav-links a.active {
    color: var(--text-base);
}

.nav-links a i {
    font-size: 20px;
}

.sidebar-divider {
    height: 1px;
    background-color: #282828;
    margin: 4px 16px;
}

.sidebar-playlist-list {
    overflow-y: auto;
    flex: 1;
    color: var(--text-subdued);
    font-weight: 400;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 8px 16px;
}

.sidebar-playlist-list p { 
    cursor: pointer; 
    transition: color 0.2s; 
    white-space: nowrap; 
    overflow: hidden; 
    text-overflow: ellipsis; 
}

.sidebar-playlist-list p:hover { 
    color: var(--text-base); 
}


/* --- Main View --- */
.main-view {
    grid-area: main;
    background-color: var(--bg-base);
    overflow-y: auto;
    position: relative;
    border-radius: 8px;
    margin: 8px 8px 0 0;
    background: linear-gradient(180deg, #222 0%, var(--bg-base) 100%);
    scroll-behavior: smooth;
    transition: background 0.5s ease;
}

/* Top Bar */
.top-bar {
    position: sticky;
    top: 0;
    height: 64px;
    background-color: rgba(18, 18, 18, 0);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    z-index: 100;
    transition: background-color 0.3s ease;
}

.top-bar.scrolled {
    background-color: #070707;
}

.nav-buttons {
    display: flex;
    gap: 16px;
}

.nav-btn {
    background-color: rgba(0,0,0,0.7);
    border: none;
    color: var(--text-base);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.nav-btn:hover {
    background-color: rgba(0,0,0,0.9);
}

.user-profile {
    background-color: rgba(0,0,0,0.7);
    padding: 2px;
    border-radius: 50%; /* Circle for just the image */
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    width: 32px;
    height: 32px;
}

.user-profile:hover {
    background-color: var(--bg-press);
    transform: scale(1.05);
}

.user-profile-img {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
}

.search-container {
    display: flex;
    align-items: center;
    background-color: #ffffff;
    border-radius: 500px;
    padding: 8px 16px;
    width: 100%;
    max-width: 360px;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.search-container input {
    border: none;
    outline: none;
    margin-left: 10px;
    width: 100%;
    font-family: inherit;
    font-size: 14px;
    color: #000;
}

.search-container i { color: #555; }

.clear-btn {
    background: none;
    border: none;
    color: #555;
    cursor: pointer;
    display: none;
    padding: 2px;
}
.clear-btn.show { display: block; }

/* Content Area */
.content-scroll {
    padding: 24px 32px;
}

/* Hero Section */
.playlist-header-hero {
    display: flex;
    align-items: flex-end;
    gap: 24px;
    margin-bottom: 24px;
    padding-bottom: 24px;
}

.playlist-cover {
    width: 232px;
    height: 232px;
    box-shadow: 0 8px 48px rgba(0,0,0,0.6);
    flex-shrink: 0;
}

.playlist-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.playlist-details {
    display: flex;
    flex-direction: column;
}

.playlist-type {
    text-transform: uppercase;
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 8px;
}

.playlist-title-hero {
    font-size: 72px;
    font-weight: 900;
    letter-spacing: -3px;
    line-height: 1.1;
    margin-bottom: 12px;
}

.playlist-description {
    color: var(--text-subdued);
    font-size: 14px;
    margin-bottom: 8px;
}

.playlist-meta {
    font-size: 14px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Action Bar */
.action-bar {
    display: flex;
    align-items: center;
    gap: 32px;
    margin-bottom: 32px;
}

.play-btn-large {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background-color: var(--green);
    border: none;
    color: #000;
    font-size: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.3, 0, 0, 1);
    box-shadow: 0 8px 16px rgba(0,0,0,0.3);
}

.play-btn-large:hover {
    transform: scale(1.05);
    background-color: var(--green-light);
}

.play-btn-large:active {
    transform: scale(0.98);
}

.action-btn {
    background: transparent;
    border: none;
    color: var(--text-subdued);
    font-size: 32px;
    cursor: pointer;
    transition: all 0.2s;
}

.action-btn:hover { color: var(--text-base); }


/* Playlist Table */
.playlist-table-container {
    color: var(--text-subdued);
    font-size: 14px;
}

.table-header {
    display: grid;
    grid-template-columns: 48px 4fr 2fr 120px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding: 0 16px 8px 16px;
    margin-bottom: 16px;
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 1px;
}

.playlist-item {
    display: grid;
    grid-template-columns: 48px 4fr 2fr 120px;
    padding: 8px 16px;
    border-radius: 4px;
    align-items: center;
    transition: background-color 0.2s;
    user-select: none;
}

.playlist-item:hover {
    background-color: rgba(255,255,255,0.1);
}

.playlist-item.active {
    background-color: rgba(255,255,255,0.05);
}

.playlist-item.active .title-text {
    color: var(--green);
}

.col-index {
    display: flex;
    align-items: center;
    justify-content: center;
    font-variant-numeric: tabular-nums;
    width: 32px;
}

.index-play-icon {
    display: none;
    font-size: 12px;
    color: var(--text-base);
}

.playlist-item:hover .index-num { display: none; }
.playlist-item:hover .index-play-icon { display: block; }

.playlist-item.active .index-num { display: none; }
.playlist-item.active .index-play-icon { display: block; color: var(--green); }

.col-title {
    display: flex;
    align-items: center;
    gap: 12px;
    overflow: hidden;
}

.col-title img {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 4px;
}

.text-wrapper {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.title-text {
    color: var(--text-base);
    font-size: 16px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.artist-text {
    font-size: 13px;
    color: var(--text-subdued);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.col-album, .col-add {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.col-add {
    display: flex;
    justify-content: center;
    align-items: center;
}

.main-footer {
    margin-top: 64px;
    padding-bottom: 32px;
    text-align: center;
    font-size: 14px;
}

.main-footer a { 
    color: var(--text-subdued); 
    text-decoration: none; 
    transition: all 0.3s ease;
    padding: 8px 16px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.05);
}

.main-footer a:hover { 
    color: var(--text-base);
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

/* --- Now Playing Bar --- */
.now-playing-bar {
    grid-area: player;
    background-color: #000;
    border-top: 1px solid #282828;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 200;
}

.now-playing-left {
    display: flex;
    align-items: center;
    width: 30%;
    min-width: 180px;
}

.now-playing-cover {
    width: 56px;
    height: 56px;
    margin-right: 14px;
    flex-shrink: 0;
    position: relative;
}

.now-playing-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 4px;
}

.now-playing-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: hidden;
    margin-right: 12px;
}

.track-link {
    color: var(--text-base);
    font-size: 14px;
    text-decoration: none;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.track-link:hover { text-decoration: underline; }

.artist-link {
    color: var(--text-subdued);
    font-size: 11px;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis;
}

.artist-link:hover { text-decoration: underline; color: var(--text-base); }

.like-btn {
    background: none;
    border: none;
    color: var(--text-subdued);
    cursor: pointer;
    padding: 8px;
    transition: all 0.2s;
}

.like-btn:hover { color: var(--text-base); transform: scale(1.1); }
.like-btn.active { color: var(--green); }

/* Center Controls */
.now-playing-center {
    width: 40%;
    max-width: 722px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.player-controls {
    display: flex;
    align-items: center;
    gap: 24px;
}

.control-btn {
    background: none;
    border: none;
    color: var(--text-subdued);
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative; /* Added for dot indicator */
}

.control-btn:hover { color: var(--text-base); }
.control-btn.active { 
    color: var(--green); 
}

.control-btn.active::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    background-color: var(--green);
    border-radius: 50%;
}

.control-btn.play-circle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: var(--text-base);
    color: #000;
    font-size: 14px;
}
.control-btn.play-circle:hover { transform: scale(1.08); }
.control-btn.play-circle:active { transform: scale(0.95); }

.playback-bar {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: var(--text-subdued);
}

.progress-container {
    flex: 1;
    height: 4px;
    background-color: #4d4d4d;
    border-radius: 2px;
    position: relative;
    cursor: pointer;
}

.progress-bar {
    width: 0%;
    height: 100%;
    background-color: var(--text-base);
    border-radius: 2px;
    position: relative;
    transition: background-color 0.2s;
}

.progress-container:hover .progress-bar {
    background-color: var(--green);
}

/* Right Controls */
.now-playing-right {
    width: 30%;
    min-width: 180px;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 12px;
}

.volume-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100px;
}

#volume-slider {
    -webkit-appearance: none;
    height: 4px;
    background: #4d4d4d;
    border-radius: 2px;
    width: 100%;
    cursor: pointer;
}

#volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--text-base);
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.5);
    visibility: hidden;
}

.volume-bar:hover #volume-slider::-webkit-slider-thumb {
    visibility: visible;
}


/* --- Mobile Styles --- */
.mobile-player-modal { display: none; }

@media (max-width: 768px) {
    .app-container {
        display: block;
    }

    .sidebar { display: none; }

    .mobile-only {
        display: block !important;
    }

    .main-view {
        margin: 0;
        border-radius: 0;
        height: 100vh;
        padding-bottom: 80px;
    }

    .top-bar {
        padding: 0 16px;
    }

    .search-container {
        width: calc(100% - 100px);
        padding: 6px 12px;
    }

    .content-scroll { padding: 16px; }

    .playlist-header-hero {
        flex-direction: column;
        align-items: center;
        text-align: center;
        padding-top: 20px;
        gap: 16px;
    }

    .playlist-cover {
        width: 180px;
        height: 180px;
    }

    .playlist-title-hero {
        font-size: 28px;
        letter-spacing: -0.5px;
    }

    .table-header { display: none; }

    .playlist-item {
        grid-template-columns: 1fr auto;
        padding: 12px 8px;
        border-radius: 8px;
    }

    .col-index, .col-album { display: none; }
    
    .col-add {
        display: flex;
        align-items: center;
    }

    /* Mobile Player Bar */
    .now-playing-bar {
        position: fixed;
        bottom: 12px;
        left: 8px;
        right: 8px;
        height: 56px;
        background-color: #282828;
        border: none;
        border-radius: 8px;
        width: calc(100% - 16px);
        padding: 0 12px;
        box-shadow: 0 8px 24px rgba(0,0,0,0.5);
        overflow: hidden;
    }

    .mobile-mini-progress {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 2px;
        background: rgba(255, 255, 255, 0.1);
        display: block;
    }

    .mini-progress-fill {
        height: 100%;
        width: 0%;
        background: var(--text-base);
        transition: width 0.1s linear;
    }

    .now-playing-center, .now-playing-right { display: none; }

    .now-playing-left {
        width: 100%;
        justify-content: space-between;
    }

    .now-playing-info {
        flex: 1;
        margin-right: 12px;
    }

    .now-playing-cover {
        width: 40px;
        height: 40px;
        margin-right: 12px;
    }

    .expand-btn {
        position: absolute;
        top: 0; left: 0; width: 100%; height: 100%;
        background: transparent;
        border: none;
        z-index: 10;
        cursor: pointer;
        display: block;
    }

    /* Mobile Player Modal */
    .mobile-player-modal {
        display: flex;
        flex-direction: column;
        position: fixed;
        top: 100%;
        left: 0;
        width: 100%;
        height: 100%;
        background: linear-gradient(180deg, #333 0%, #121212 100%);
        z-index: 1000;
        transition: transform 0.4s cubic-bezier(0.3, 0, 0, 1);
        padding: 24px;
        overflow-y: auto;
    }

    .mobile-player-modal.active {
        transform: translateY(-100%);
    }

    .mobile-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 32px;
    }

    .mobile-header button {
        background: none;
        border: none;
        color: var(--text-base);
        font-size: 20px;
        padding: 8px;
    }

    .mobile-art-container {
        width: 100%;
        max-width: 320px;
        margin: 0 auto 40px auto;
        aspect-ratio: 1/1;
        box-shadow: 0 12px 48px rgba(0,0,0,0.6);
    }

    .mobile-art-container img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        border-radius: 8px;
    }

    .mobile-track-info {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 24px;
        padding: 0 4px;
    }

    .mobile-track-info h2 { font-size: 24px; font-weight: 700; margin-bottom: 4px; }
    .mobile-track-info p { color: var(--text-subdued); font-size: 16px; }

    .mobile-progress-container {
        width: 100%;
        height: 4px;
        background: rgba(255,255,255,0.1);
        border-radius: 2px;
        margin-bottom: 12px;
        position: relative;
    }

    .mobile-progress-bar {
        width: 0%;
        height: 100%;
        background: var(--text-base);
        border-radius: 2px;
    }

    .mobile-time-display {
        display: flex;
        justify-content: space-between;
        font-size: 12px;
        color: var(--text-subdued);
        margin-bottom: 32px;
        padding: 0 4px;
    }

    .mobile-controls {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0 4px;
    }

    .mobile-controls button {
        background: none;
        border: none;
        color: var(--text-base);
        font-size: 24px;
        padding: 12px;
    }

    .mobile-controls button.play-circle-large {
        width: 72px;
        height: 72px;
        border-radius: 50%;
        background-color: var(--green) !important;
        color: #000 !important;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 28px !important;
        box-shadow: 0 4px 12px rgba(0,0,0,0.3);
        transition: transform 0.1s;
        padding: 0;
    }

    .mobile-controls button.play-circle-large:active {
        transform: scale(0.92);
    }

    .mobile-mini-controls {
        display: flex;
        align-items: center;
        margin-right: 8px;
        z-index: 20;
        position: relative;
    }

    .mini-play-btn {
        background: none;
        border: none;
        color: var(--text-base);
        font-size: 22px;
        width: 44px;
        height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* --- 999 Mode (Easter Egg) --- */
body.mode-999 {
    --green: #bb00ff;
    --green-light: #d46aff;
    background: linear-gradient(180deg, #1a0029 0%, #000 100%) !important;
}

/* --- Glitch Explosion --- */
body.glitch-active {
    filter: url(#glitch); /* If using SVG filter, but we'll use CSS instead */
    animation: chromaticAberration 0.1s infinite;
}

body.glitch-active .user-profile-img {
    animation: rapidSpin 0.2s infinite linear;
}

body.glitch-active .app-container {
    filter: contrast(150%) brightness(120%) hue-rotate(90deg);
}

@keyframes rapidSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes shake {
    0% { transform: translate(0,0); }
    25% { transform: translate(5px, -5px); }
    50% { transform: translate(-5px, 5px); }
    75% { transform: translate(5px, 5px); }
    100% { transform: translate(-5px, -5px); }
}

@keyframes chromaticAberration {
    0% { text-shadow: 2px 0 0 red, -2px 0 0 blue; }
    50% { text-shadow: -2px 0 0 red, 2px 0 0 blue; }
    100% { text-shadow: 2px 0 0 red, -2px 0 0 blue; }
}

body.mode-999 .play-btn-large, 
body.mode-999 .play-circle, 
body.mode-999 .play-circle-large {
    box-shadow: 0 0 20px rgba(187, 0, 255, 0.6);
}

body.mode-999 .playlist-title-hero {
    text-shadow: 0 0 15px rgba(187, 0, 255, 0.8);
    color: #fff;
}

body.mode-999 .logo i {
    color: var(--green);
    text-shadow: 0 0 10px var(--green);
}

.easter-egg-999 {
    position: fixed;
    bottom: 100px;
    right: 30px;
    font-size: 80px;
    font-weight: 900;
    color: rgba(187, 0, 255, 0.2);
    pointer-events: none;
    z-index: 1000;
    font-family: 'Figtree', sans-serif;
    letter-spacing: -5px;
    animation: float999 4s ease-in-out infinite;
    display: none;
}

body.mode-999 .easter-egg-999 {
    display: block;
}

@keyframes float999 {
    0%, 100% { transform: translateY(0) rotate(-5deg); opacity: 0.2; }
    50% { transform: translateY(-20px) rotate(5deg); opacity: 0.5; text-shadow: 0 0 30px #bb00ff; }
}

/* Loading Overlay (Optimized to be non-blocking) */
.loading-overlay {
    position: absolute; /* Changed from fixed */
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    border-radius: inherit;
}
.loading-overlay.show { opacity: 1; }

.loading-spinner {
    width: 32px; height: 32px;
    border: 3px solid rgba(255,255,255,0.1);
    border-top-color: var(--green);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}
