:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --bg-dark: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --glass-border: rgba(255, 255, 255, 0.1);
    --accent-gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100-vh;
    overflow-x: hidden;
    background-image:
        radial-gradient(circle at 0% 0%, rgba(99, 102, 241, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 100% 100%, rgba(168, 85, 247, 0.15) 0%, transparent 50%);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

/* Header & Search */
header {
    text-align: center;
    margin-bottom: 3rem;
    padding-top: 2rem;
}

h1 {
    font-size: 3rem;
    font-weight: 800;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 1rem;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    max-width: 900px;
    margin: 0 auto;
    background: var(--card-bg);
    padding: 0.5rem;
    border-radius: 1rem;
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(12px);
    transition: all 0.3s ease;
    flex-wrap: wrap;
    justify-content: center;
}

.search-box:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.2);
}

.search-box input {
    flex: 1;
    min-width: 150px;
    height: 42px;
    background: transparent;
    border: none;
    color: white;
    padding: 0 1rem;
    outline: none;
    font-size: 1rem;
}

.search-box button {
    height: 42px;
    background: var(--primary);
    color: white;
    border: none;
    padding: 0 1.5rem;
    border-radius: 0.75rem;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.search-box button:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
}

#sourceSelect {
    height: 42px;
    background: transparent;
    border: none;
    color: white;
    padding: 0 1rem;
    outline: none;
    border-right: 1px solid var(--glass-border);
    cursor: pointer;
    font-size: 0.9rem;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    flex-shrink: 0;
    min-width: 100px;
}

#toplistBtn {
    background: var(--accent-gradient);
    color: white;
}

#playlistToggle {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid var(--glass-border);
}

#toplistBtn:hover,
#playlistToggle:hover {
    transform: translateY(-2px);
}

/* Music Grid */
.music-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 8rem;
}

.music-card {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    border-radius: 1rem;
    padding: 1rem;
    backdrop-filter: blur(12px);
    transition: transform 0.3s ease, background 0.3s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.music-card:hover {
    transform: translateY(-5px);
    background: rgba(30, 41, 59, 0.9);
}

.music-card img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: 0.75rem;
    margin-bottom: 1rem;
}

.music-info h3 {
    font-size: 1.1rem;
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.music-info p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.source-badge {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    background: rgba(0, 0, 0, 0.6);
    padding: 0.25rem 0.6rem;
    border-radius: 0.5rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    font-weight: bold;
}

/* Player Bar */
.player-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(20px);
    border-top: 1px solid var(--glass-border);
    padding: 1rem 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    z-index: 1000;
}

/* Mobile Adjustments */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    h1 {
        font-size: 2rem;
    }

    .search-box {
        flex-direction: column;
        gap: 0.5rem;
        padding: 0.75rem;
    }

    .search-box input {
        width: 100%;
        border-bottom: 1px solid var(--glass-border);
        padding: 0.5rem 0;
    }

    .search-box select,
    .search-box button,
    #toplistBtn,
    #playlistToggle {
        width: 100%;
        margin-left: 0 !important;
        padding: 0.6rem !important;
        border-right: none !important;
    }

    #playlistPanel {
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        top: auto !important;
        width: 100% !important;
        height: 60vh !important;
        border-radius: 1.5rem 1.5rem 0 0 !important;
        transform: translateY(100%);
        transition: transform 0.3s ease-out;
        display: flex !important;
        /* Always flex but hidden by transform */
    }

    #playlistPanel.active {
        transform: translateY(0);
    }

    .player-bar {
        padding: 0.75rem 1rem;
        flex-direction: column;
        gap: 0.75rem;
        height: auto;
        justify-content: flex-start;
    }

    .current-track {
        position: static;
        width: 100%;
        justify-content: flex-start;
        transform: none;
    }

    .player-controls {
        width: 100%;
        max-width: none;
    }

    .player-extra-controls .progress-bar,
    .player-extra-controls #muteBtn {
        display: none;
    }

    .music-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
}

.current-track {
    display: flex;
    align-items: center;
    gap: 1rem;
    width: 300px;
    position: absolute;
    left: 2.5rem;
    top: 50%;
    transform: translateY(-50%);
}

.current-track img {
    width: 48px;
    height: 48px;
    border-radius: 0.5rem;
}

.player-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 600px;
}

.ctrl-btns {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 0.5rem;
}

.play-pause {
    width: 40px;
    height: 40px;
    background: white;
    color: black;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.progress-container {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.progress-bar {
    flex: 1;
    height: 4px;
    background: #334155;
    border-radius: 2px;
    cursor: pointer;
    position: relative;
}

.progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 2px;
    width: 0%;
}

.player-extra-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Loading Animation */
.loader {
    width: 48px;
    height: 48px;
    border: 5px solid #FFF;
    border-bottom-color: transparent;
    border-radius: 50%;
    display: none;
    box-sizing: border-box;
    animation: rotation 1s linear infinite;
    margin: 2rem auto;
}

@keyframes rotation {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Lyrics Styles */
.lyric-line {
    font-size: 1.25rem;
    color: rgba(255, 255, 255, 0.4);
    padding: 0.75rem 0;
    transition: all 0.3s ease;
    cursor: pointer;
}

.lyric-line.active {
    color: white;
    font-size: 1.8rem;
    font-weight: 700;
    text-shadow: 0 0 20px rgba(99, 102, 241, 0.5);
}

#lyricsContent::-webkit-scrollbar {
    width: 0px;
}