:root {
    --primary-color: #ff2d55;
    /* Apple Music Pinkish Red */
    --text-main: #ffffff;
    --text-sec: rgba(255, 255, 255, 0.7);
    --glass-bg: rgba(255, 255, 255, 0.15);
    --glass-border: rgba(255, 255, 255, 0.2);
    --glass-shimmer: rgba(255, 255, 255, 0.4);
    --btn-shadow-light: rgba(255, 255, 255, 0.2);
    --btn-shadow-dark: rgba(0, 0, 0, 0.3);

    --font-stack: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

    --transition-speed: 0.3s;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-stack);
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    /* Safari */
    user-select: none;
    /* Standard syntax */
}

body {
    height: 100vh;
    width: 100vw;
    background: #000;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--text-main);
    position: relative;
}

/* Background & Ambient Effects */
.background-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background: url('assets/bg.png') no-repeat center center/cover;
}

.background-container::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(30px);
    /* Deep blur of standard wallpaper */
}

/* Floating Shapes for 'Alive' feel */
.shape {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.6;
    animation: float 10s infinite alternate ease-in-out;
}

.shape-1 {
    width: 300px;
    height: 300px;
    background: #5c2fa6;
    top: 10%;
    left: 20%;
    animation-delay: 0s;
}

.shape-2 {
    width: 400px;
    height: 400px;
    background: #ff2d55;
    bottom: 10%;
    right: 10%;
    animation-delay: -3s;
}

.shape-3 {
    width: 250px;
    height: 250px;
    background: #2d89ef;
    top: 40%;
    left: 60%;
    animation-delay: -5s;
}

@keyframes float {
    0% {
        transform: translate(0, 0) scale(1);
    }

    100% {
        transform: translate(20px, -30px) scale(1.1);
    }
}

/* App Architecture */
.app-container {
    width: 100%;
    max-width: 400px;
    height: 100dvh;
    /* Dynamic viewport height for mobile */
    max-height: 650px;
    position: relative;
    display: flex;
    flex-direction: column;
}

/* Glass Panels */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    border-radius: 24px;
}

.player-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 15px 20px 20px 20px;
    /* Reduced top/bottom padding */
    position: relative;
    justify-content: space-between;
    /* Ensure evenly spaced */
    z-index: 10;
    overflow: hidden;
    /* Prevent spill */
    margin-top: -50px;
    margin-bottom: 20px;
}

/* Header inside card */
.player-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    z-index: 5;
}

/* Buttons (3D / Texture) */
.glass-btn {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0));
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.18);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    color: white;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.small-btn {
    width: 40px;
    height: 40px;
    font-size: 14px;
}

.wide-btn {
    padding: 12px 20px;
    width: 100%;
    font-size: 16px;
    font-weight: 500;
    gap: 10px;
}

.glass-btn:active {
    transform: scale(0.95);
    box-shadow: inset 0 4px 6px rgba(0, 0, 0, 0.2);
}

/* Album Art */
.album-art-container {
    width: 250px;
    /* Reduced from 280 */
    height: 250px;
    position: relative;
    border-radius: 20px;
    margin-bottom: 15px;
    /* Reduced from 25 */
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    background: #fb388c;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 1;
    /* Allow shrinking */
}

/* Song Info */
.song-info {
    text-align: center;
    margin-bottom: 15px;
    /* Reduced from 30 */
    width: 100%;
}

.song-info h2 {
    font-size: 20px;
    /* Slight reduction */
    font-weight: 700;
    margin-bottom: 5px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.song-info p {
    font-size: 14px;
    color: var(--text-sec);
    margin-bottom: 0;
}

/* Controls */
/* Sliders (Progress & Volume) */
input[type=range] {
    -webkit-appearance: none;
    width: 100%;
    /* Ensure full width */
    background: transparent;
    cursor: pointer;
    flex-grow: 1;
    /* Force grow in flex containers */
}

input[type=range]:focus {
    outline: none;
}

input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.3);
}

input[type=range]::-webkit-slider-thumb {
    height: 16px;
    width: 16px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4);
    -webkit-appearance: none;
    margin-top: -5px;
    /* center thumb */
    transition: transform 0.1s;
}

input[type=range]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.progress-area {
    width: 100%;
    margin-bottom: 20px;
    padding: 0 5px;
    /* prevent cut-off of thumb */
}

.time-bar-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-sec);
    width: 100%;
}

#progress-bar {
    flex: 1;
    width: auto;
    /* Allow reflex */
}

/* Control Buttons (Stereo/3D Play Button) */
.controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 30px;
    margin-bottom: 25px;
}

.control-btn {
    width: 50px;
    height: 50px;
    font-size: 20px;
    background: transparent;
    border: none;
    color: #fff;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;

    background: linear-gradient(145deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
    box-shadow:
        5px 5px 10px rgba(0, 0, 0, 0.2),
        -5px -5px 10px rgba(255, 255, 255, 0.05),
        inset 1px 1px 1px rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.main-play {
    width: 70px;
    /* Reduced */
    height: 70px;
    font-size: 28px;
    background: linear-gradient(135deg, var(--primary-color), #ff5c8a);
    box-shadow: 0 10px 25px rgba(255, 45, 85, 0.4);
    border: none;
}

/* Volume controls fixed width */
.volume-controls {
    width: 100%;
    /* Allow full width of parent container */
    padding: 0 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 25px;
    /* More space */
    opacity: 0.9;
}

.volume-controls input {
    flex: 1;
}

.extra-controls {
    width: 100%;
    display: flex;
    gap: 15px;
    justify-content: space-between;
    margin-top: 0;
    margin-bottom: 5px;
    /* Ensure space at bottom */
}

/* Re-enable visuals */
.album-art.spinning {
    animation: spin 8s linear infinite;
}

.icon-only {
    width: 50px;
}

/* Playlist Panel */
.playlist-panel {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 70%;
    z-index: 20;
    transform: translateY(110%);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    flex-direction: column;
    padding: 20px;
    background: rgb(255 255 255 / 10%);
    ;
    /* Darker for readability */
}

.playlist-panel.active {
    transform: translateY(0);
}

.playlist-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.playlist-list {
    list-style: none;
    overflow-y: auto;
    flex: 1;
}

.playlist-item {
    padding: 10px;
    border-radius: 10px;
    margin-bottom: 8px;
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.2s;
    user-select: none;
}

.playlist-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.playlist-item.active {
    background: rgba(255, 45, 85, 0.2);
    border: 1px solid rgba(255, 45, 85, 0.5);
    color: #fff;
}

.playlist-item.dragging {
    opacity: 0.5;
    background: rgba(255, 255, 255, 0.2);
}

.playlist-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    overflow: hidden;
}

.song-detail {
    overflow: hidden;
}

.chk-select {
    width: 18px;
    height: 18px;
    accent-color: var(--primary-color);
    cursor: pointer;
}

.drag-handle {
    color: rgba(255, 255, 255, 0.3);
    cursor: grab;
    padding: 0 5px;
}

.drag-handle:active {
    cursor: grabbing;
}

.remove-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    margin-left: 10px;
}

.remove-btn:hover {
    color: #ff2d55;
}

.close-btn {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

/* Toast */
.toast {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    padding: 10px 20px;
    border-radius: 30px;
    font-size: 14px;
    z-index: 100;
    transition: opacity 0.3s;
}

.toast.hidden {
    opacity: 0;
    pointer-events: none;
}

/* Animations */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.spinning {
    animation: spin 8s linear infinite;
}

/* Additions for new controls */

.controls-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-bottom: 20px;
    padding: 0 10px;
}

.ab-loop-controls {
    display: flex;
    gap: 8px;
}

.very-small-btn {
    padding: 5px 10px;
    height: 30px;
    font-size: 12px;
    min-width: 30px;
}

.ab-active {
    background: rgba(255, 45, 85, 0.4);
    border-color: #ff2d55;
    color: #fff;
    box-shadow: 0 0 10px rgba(255, 45, 85, 0.5);
}

.hidden {
    display: none !important;
}

/* Update visualizer z-index or opacity if needed for Kaleidoscope */
#visualizer {
    opacity: 0.6;
    mix-blend-mode: screen;
    /* Makes colors pop on dark bg */
}

/* Light Mode Override */
body.light-theme {
    background: #e0e5ec;
}

body.light-theme .glass-panel {
    background: rgba(255, 255, 255, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.15);
}

body.light-theme .background-container::after {
    background: rgba(255, 255, 255, 0.3);
}

body.light-theme .shape {
    opacity: 0.8;
}

body.light-theme .song-info h2 {
    color: #333;
    text-shadow: none;
}

body.light-theme .song-info p {
    color: #666;
}

body.light-theme .time-bar-wrapper {
    color: #555;
}

body.light-theme .glass-btn {
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.8);
    color: #333;
}

body.light-theme .glass-btn:hover {
    background: rgba(255, 255, 255, 0.8);
}

body.light-theme input[type=range]::-webkit-slider-runnable-track {
    background: rgba(0, 0, 0, 0.1);
}

body.light-theme input[type=range]::-webkit-slider-thumb {
    background: #ff2d55;
}

body.light-theme .playlist-item {
    background: rgba(0, 0, 0, 0.05);
    color: #333;
}

body.light-theme .playlist-item:hover {
    background: rgba(0, 0, 0, 0.08);
}

body.light-theme .playlist-panel {
    background: rgb(255 255 255 / 10%);
}

body.light-theme .playlist-header,
body.light-theme .close-btn {
    color: #333;
    border-bottom-color: rgba(0, 0, 0, 0.1);
}

body.light-theme .remove-btn,
body.light-theme .drag-handle {
    color: rgba(0, 0, 0, 0.4);
}