:root {
    /* Auto dark/light mode setup */
    --accent: #1db954;
    /* Spotify-like green */
    --accent-hover: #1ed760;
    --card-radius: 12px;
    --transition: 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #000000;
        --surface: #121212;
        --surface-h: #282828;
        --surface-active: #333333;
        --text-pure: #ffffff;
        --text-dim: #b3b3b3;
        --border: rgba(255, 255, 255, 0.1);
        --player-bg: rgba(24, 24, 24, 0.95);
        --player-border: rgba(255, 255, 255, 0.08);
    }
}

@media (prefers-color-scheme: light) {
    :root {
        --bg: #f8f9fa;
        --surface: #ffffff;
        --surface-h: #f1f3f5;
        --surface-active: #e9ecef;
        --text-pure: #212529;
        --text-dim: #6c757d;
        --border: rgba(0, 0, 0, 0.08);
        --player-bg: rgba(255, 255, 255, 0.95);
        --player-border: rgba(0, 0, 0, 0.1);
        --accent: #2563eb;
        --accent-hover: #1d4ed8;
    }
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Plus Jakarta Sans', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg);
    color: var(--text-pure);
    min-height: 100vh;
    padding-bottom: 120px;
}

.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem 5%;
}

header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
    margin-bottom: 3rem;
    margin-top: 2rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo-icon {
    width: 48px;
    height: 48px;
    background: var(--accent);
    color: white;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    box-shadow: 0 8px 20px rgba(var(--accent), 0.3);
}

.brand h1 {
    font-weight: 800;
    font-size: 2.2rem;
    letter-spacing: -0.5px;
}

#search-form {
    width: 100%;
    max-width: 600px;
}

.search-box {
    display: flex;
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 50px;
    padding: 0.5rem 0.5rem 0.5rem 1.5rem;
    transition: var(--transition);
    position: relative;
}

.search-box:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(29, 185, 84, 0.1);
}

.search-box i.fa-magnifying-glass {
    color: var(--text-dim);
    font-size: 1.2rem;
}

.search-box input {
    background: none;
    border: none;
    outline: none;
    color: var(--text-pure);
    font-size: 1.1rem;
    font-weight: 500;
    padding: 0.8rem 1rem;
    flex: 1;
    width: 100%;
}

.search-box input::placeholder {
    color: var(--text-dim);
}

.search-box button {
    background: var(--text-pure);
    color: var(--bg);
    border: none;
    padding: 1rem 2rem;
    border-radius: 40px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
}

.search-box button:hover {
    transform: scale(1.05);
    background: var(--accent);
    color: white;
}

.inline-spinner {
    position: absolute;
    right: 120px;
    width: 20px;
    height: 20px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s infinite linear;
}

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

.hero-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 10vh 0;
    color: var(--text-dim);
}

.hero-state h1 {
    color: var(--text-pure);
    font-size: 2rem;
    margin-bottom: 1rem;
    font-weight: 800;
    line-height: 1.2;
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.2rem;
}

.msg-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 4rem;
    color: var(--text-dim);
    font-size: 1.2rem;
}

/* Track Card */
.track-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--card-radius);
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 1.2rem;
    cursor: pointer;
    transition: var(--transition);
}

.track-card:hover {
    background: var(--surface-h);
}

.track-card.active {
    background: var(--surface-active);
    border-color: var(--accent);
}

.track-thumb {
    width: 56px;
    height: 56px;
    border-radius: 8px;
    background: var(--surface-h);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

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

.track-thumb .placeholder-icon {
    font-size: 1.5rem;
    color: var(--text-dim);
}

.track-card.active .track-thumb {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.track-card.active .track-thumb img {
    opacity: 0.8;
}

.track-card.active .track-info .title {
    color: var(--accent);
}

.track-info {
    flex: 1;
    overflow: hidden;
}

.track-info .title {
    color: var(--text-pure);
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 0.2rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.track-info .artist {
    color: var(--text-dim);
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Footer Section */
footer {
    text-align: center;
    margin-top: 4rem;
    padding: 2rem 0;
    color: var(--text-dim);
    font-weight: 500;
}

footer a {
    color: var(--text-pure);
    text-decoration: none;
    font-weight: 700;
    border-bottom: 2px solid var(--accent);
    padding-bottom: 2px;
    transition: color 0.2s;
}

footer a:hover {
    color: var(--accent);
}

/* Audio Player */
.player {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: var(--player-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--player-border);
    padding: 1rem 0;
    z-index: 100;
    transition: transform 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.player-hidden {
    transform: translateY(110%);
}

.player-inner {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 2%;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.now-playing {
    display: flex;
    align-items: center;
    gap: 1rem;
    width: 30%;
    min-width: 250px;
}

.player .cover-art {
    width: 56px;
    height: 56px;
    border-radius: 8px;
    background: var(--surface);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

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

.player .track-info h3 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-pure);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    max-width: 250px;
}

.player .track-info p {
    font-size: 0.8rem;
    color: var(--text-dim);
    margin-top: 0.2rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.player-controls {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 600px;
}

.controls-main {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 0.5rem;
}

.ctrl-btn {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 1.3rem;
    cursor: pointer;
    transition: var(--transition);
}

.ctrl-btn:hover {
    color: var(--text-pure);
}

.play-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--text-pure);
    color: var(--surface);
    /* Super high contrast inversion */
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.play-btn:hover {
    transform: scale(1.08);
}

.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--text-pure);
    border-radius: 50%;
    color: var(--surface);
}

.spin-anim {
    animation: spin 1s linear infinite;
}

.progress-container {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    width: 100%;
    font-size: 0.75rem;
    font-variant-numeric: tabular-nums;
    color: var(--text-dim);
}

.progress-bar {
    flex: 1;
    height: 4px;
    background: var(--surface-h);
    border-radius: 2px;
    cursor: pointer;
    position: relative;
    display: flex;
    align-items: center;
}

.progress-bar:hover .progress {
    background: var(--accent);
}

.progress-bar:hover .progress::after {
    opacity: 1;
}

.progress {
    height: 100%;
    background: var(--text-pure);
    border-radius: 2px;
    width: 0%;
    position: relative;
}

.progress::after {
    content: '';
    position: absolute;
    right: -6px;
    top: 50%;
    transform: translateY(-50%);
    width: 12px;
    height: 12px;
    background: var(--text-pure);
    border-radius: 50%;
    opacity: 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: opacity 0.2s;
}

.player-actions {
    width: 30%;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 1rem;
}

.mute-btn {
    font-size: 1rem;
}

.vol-slider {
    width: 90px;
    accent-color: var(--text-pure);
    cursor: pointer;
    height: 4px;
}

.vol-slider:hover {
    accent-color: var(--accent);
}

.divider {
    width: 1px;
    height: 24px;
    background: var(--border);
    margin: 0 0.5rem;
}

.action-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-dim);
    background: transparent;
    font-size: 1.4rem;
    text-decoration: none;
    transition: var(--transition);
}

.action-btn:hover {
    background: var(--surface-active);
    color: var(--text-pure);
    transform: translateY(-2px);
}

.download-text {
    display: none;
}

.hidden {
    display: none !important;
}

@media (max-width: 900px) {
    .now-playing {
        width: auto;
        max-width: 30%;
    }

    .player-actions {
        width: auto;
    }
}

@media (max-width: 600px) {
    .player-inner {
        flex-direction: column;
        gap: 1rem;
    }

    .now-playing {
        width: 100%;
        max-width: 100%;
        justify-content: flex-start;
    }

    .player .track-info h3 {
        max-width: 100%;
    }

    .player-controls {
        width: 100%;
        max-width: 100%;
    }

    .player-actions {
        display: flex;
        width: 100%;
        justify-content: center;
        position: static;
        margin-top: 0.2rem;
    }

    /* Hide only the volume slider elements on mobile */
    .mute-btn,
    .vol-slider,
    .divider {
        display: none;
    }

    .search-box button {
        padding: 1rem;
    }

    .action-btn.download-btn {
        width: 100%;
        max-width: 300px;
        height: 48px;
        border-radius: 24px;
        background-color: var(--accent);
        color: white;
        gap: 0.5rem;
        font-size: 1.1rem;
        font-weight: 700;
        margin-bottom: 0.5rem;
    }

    .action-btn.download-btn:hover {
        background-color: var(--accent-hover);
        transform: scale(1.02);
    }

    .download-text {
        display: inline;
    }

    .inline-spinner {
        right: 70px;
    }
}