/* =========================================================================
   MINI PLAYER (glassmorphism)
   ========================================================================= */
#mini-player {
    position: fixed;
    bottom: var(--nav-h);
    margin-bottom: 12px;
    left: max(8px, env(safe-area-inset-left));
    right: max(8px, env(safe-area-inset-right));
    background: rgba(22, 22, 30, 0.75);
    backdrop-filter: blur(24px) saturate(1.5);
    -webkit-backdrop-filter: blur(24px) saturate(1.5);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 50px;
    overflow: hidden;
    z-index: 42;
    box-shadow: 0 12px 32px rgba(0,0,0,0.5);
    animation: mini-rise 0.35s var(--ease-spring);
}

@keyframes mini-rise {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

#mini-progress-bar {
    height: 2px;
    background: var(--accent);
    width: 0%;
    transition: width 0.3s linear;
}

#mini-player-content {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    min-height: 56px;
}

#mini-artwork-wrap {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    border-radius: 50%;
    overflow: hidden;
    position: relative;
}

.mini-artwork {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.mini-artwork-placeholder {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #134e4a, #0c3a4a);
    display: flex;
    align-items: center;
    justify-content: center;
}

#mini-song-info {
    flex: 1;
    min-width: 0;
    cursor: pointer;
    padding: 4px 0;
}

#mini-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#mini-artist {
    font-size: 0.7rem;
    color: var(--text-3);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#mini-controls {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
}

.mini-btn {
    width: 38px;
    height: 38px;
    min-height: 38px;
    min-width: 38px;
    padding: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
}

.mini-btn:hover { background: rgba(255,255,255,0.08); }
.mini-btn:active { transform: scale(0.9); }

/* =========================================================================
   FULL-SCREEN PLAYER OVERLAY
   ========================================================================= */
#player-overlay {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: flex;
    flex-direction: column;
    transform: translateY(0);
    visibility: visible;
    transition: transform 0.35s var(--ease-out), visibility 0s;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
    background: var(--bg);
}

#player-overlay.hidden {
    display: flex !important;
    transform: translateY(100%);
    visibility: hidden;
    transition: transform 0.35s var(--ease-out), visibility 0s 0.35s;
    pointer-events: none;
}

/* The overlay stays display:flex so its slide transition works, which also
   means off-screen animations would otherwise keep compositing forever. */
#player-overlay.hidden #player-bg::before,
#player-overlay.hidden #player-bg::after,
#player-overlay.hidden #vinyl-disc,
#player-overlay.hidden .mesh-bg,
#player-overlay.hidden #player-title,
#player-overlay.hidden .eq-icon span,
#player-overlay.playback-paused #player-bg::before,
#player-overlay.playback-paused #player-bg::after,
#player-overlay.playback-paused #vinyl-disc,
#player-overlay.playback-paused .mesh-bg,
#player-overlay.playback-paused #player-title,
#player-overlay.playback-paused .eq-icon span {
    animation-play-state: paused;
}

#player-bg {
    position: absolute;
    inset: 0;
    background: var(--player-grad);
    z-index: -1;
    transition: background 0.6s var(--ease-out);
    overflow: hidden;
}

#player-bg::before,
#player-bg::after {
    content: "";
    position: absolute;
    inset: -40%;
    pointer-events: none;
    filter: blur(80px);
    will-change: transform;
}

#player-bg::before {
    background:
        radial-gradient(42% 42% at 30% 30%, rgba(var(--player-tint), 1), transparent 60%),
        radial-gradient(36% 36% at 75% 65%, rgba(255,255,255,0.22), transparent 65%),
        radial-gradient(30% 30% at 15% 85%, rgba(var(--player-tint), 0.9), transparent 60%);
    animation: player-bg-drift-a 14s var(--ease-in-out) infinite alternate;
}

#player-bg::after {
    background:
        radial-gradient(48% 48% at 70% 20%, rgba(var(--player-tint), 0.95), transparent 60%),
        radial-gradient(34% 34% at 25% 75%, rgba(255,255,255,0.18), transparent 65%),
        radial-gradient(32% 32% at 85% 85%, rgba(var(--player-tint), 0.8), transparent 60%);
    animation: player-bg-drift-b 18s var(--ease-in-out) infinite alternate;
    mix-blend-mode: screen;
}

@keyframes player-bg-drift-a {
    0%   { transform: translate(-8%, -6%) scale(1) rotate(0deg); }
    50%  { transform: translate(10%, 4%) scale(1.25) rotate(15deg); }
    100% { transform: translate(6%, 12%) scale(1.15) rotate(-10deg); }
}

@keyframes player-bg-drift-b {
    0%   { transform: translate(8%, 6%) scale(1.2) rotate(0deg); }
    50%  { transform: translate(-10%, -8%) scale(1) rotate(-18deg); }
    100% { transform: translate(-4%, 10%) scale(1.3) rotate(12deg); }
}

@media (prefers-reduced-motion: reduce) {
    #player-bg::before,
    #player-bg::after { animation: none; }
}

#player-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 12px 24px 24px;
    overflow: hidden;
}

#player-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0 12px;
}

#player-header .icon-btn {
    color: var(--text);
    background: rgba(255,255,255,0.08);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}
#player-header .icon-btn:hover { background: rgba(255,255,255,0.15); }

#player-source {
    flex: 1;
    text-align: center;
    font-size: 0.78rem;
    font-weight: 600;
    color: rgba(255,255,255,0.7);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

/* Artwork */
#player-artwork-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px 0;
    min-height: 0;
    touch-action: pan-y;
}

#vinyl-stage {
    position: relative;
    width: 85vw;
    max-width: 380px;
    aspect-ratio: 1;
}

#vinyl-disc {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #1f1f1f 0%, #0a0a0a 55%, #050505 100%);
    box-shadow:
        0 24px 60px rgba(0,0,0,0.6),
        inset 0 0 0 2px rgba(255,255,255,0.04),
        inset 0 -4px 20px rgba(0,0,0,0.5);
    cursor: pointer;
    animation: vinyl-spin 8s linear infinite;
    animation-play-state: paused;
    will-change: transform;
}
#vinyl-disc.spinning { animation-play-state: running; }

.vinyl-grooves {
    position: absolute;
    inset: 6%;
    border-radius: 50%;
    pointer-events: none;
    background: repeating-radial-gradient(
        circle at center,
        rgba(255,255,255,0.04) 0 1px,
        transparent 1px 4px
    );
    -webkit-mask-image: radial-gradient(circle, transparent 38%, #000 41%);
    mask-image: radial-gradient(circle, transparent 38%, #000 41%);
}

.vinyl-shine {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    pointer-events: none;
    background: conic-gradient(
        from 0deg,
        rgba(255,255,255,0.08), transparent 30%, transparent 70%, rgba(255,255,255,0.06)
    );
    mix-blend-mode: screen;
}

.vinyl-spindle {
    position: absolute;
    width: 8px;
    height: 8px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: radial-gradient(circle, #d4d4d4, #6a6a6a);
    z-index: 2;
    pointer-events: none;
}

#player-artwork {
    position: absolute;
    width: 38%;
    height: 38%;
    top: 31%;
    left: 31%;
    border-radius: 50%;
    overflow: hidden;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 0 3px rgba(255,255,255,0.08), 0 4px 12px rgba(0,0,0,0.4);
    z-index: 1;
    transition: opacity 0.2s;
    pointer-events: none;
}

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

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

/* Tonearm */
#tonearm {
    position: absolute;
    top: -15%;
    right: -5%;
    width: 65%;
    height: 80%;
    pointer-events: none;
    z-index: 3;
}

.tonearm-base {
    position: absolute;
    top: 4%;
    right: 6%;
    width: 18%;
    aspect-ratio: 1;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, #d4d4d4, #4a4a4a);
    box-shadow: 0 3px 8px rgba(0,0,0,0.5), inset 0 0 0 2px rgba(255,255,255,0.08);
    z-index: 2;
}
.tonearm-base::after {
    content: "";
    position: absolute;
    inset: 30%;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #6a6a6a, #2a2a2a);
}

.tonearm-arm {
    position: absolute;
    top: 11%;
    right: 13%;
    width: 70%;
    height: 6px;
    background: linear-gradient(90deg, #d4d4d4, #8a8a8a 60%, #5a5a5a);
    border-radius: 3px;
    transform-origin: 100% 50%;
    transform: rotate(-45deg);
    transition: transform 600ms cubic-bezier(.25,.8,.4,1);
    box-shadow: 0 2px 4px rgba(0,0,0,0.4);
}

.tonearm-head {
    position: absolute;
    left: -2px;
    top: -14px;
    width: 18px;
    height: 28px;
    background: linear-gradient(180deg, #2a2a2a, #1a1a1a);
    border-radius: 3px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.5);
}
.tonearm-head::after {
    content: "";
    position: absolute;
    bottom: -3px;
    left: 50%;
    transform: translateX(-50%);
    width: 3px;
    height: 6px;
    background: #888;
    border-radius: 0 0 2px 2px;
}

#vinyl-stage.paused .tonearm-arm {
    transform: rotate(-3deg);
}

@media (prefers-reduced-motion: reduce) {
    #vinyl-disc { animation: none; }
    .tonearm-arm { transition: none; }
}

.album-art-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255,255,255,0.4);
}

.mesh-bg {
    background:
        radial-gradient(40% 50% at 20% 30%, #14b8a6 0%, transparent 50%),
        radial-gradient(45% 55% at 80% 40%, #0ea5e9 0%, transparent 55%),
        radial-gradient(50% 60% at 50% 80%, #0d9488 0%, transparent 55%),
        linear-gradient(135deg, #0a1f1e 0%, #0e1f2a 100%);
    background-size: 200% 200%;
    animation: mesh-drift 16s ease-in-out infinite;
}

@keyframes mesh-drift {
    0%, 100% { background-position: 0% 0%, 100% 0%, 50% 100%, 0 0; }
    50% { background-position: 100% 50%, 0% 50%, 50% 0%, 0 0; }
}

/* Song info + marquee */
#player-song-info {
    text-align: center;
    margin-bottom: 20px;
    padding: 0 8px;
}

.marquee-wrap {
    overflow: hidden;
    white-space: nowrap;
    position: relative;
}

#player-title {
    font-size: clamp(1.05rem, 4.2vw, 1.4rem);
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.02em;
    text-shadow: 0 2px 8px rgba(0,0,0,0.3);
    white-space: nowrap;
    display: inline-block;
}

#player-title.marquee {
    /* Trailing gap so the looped text doesn't end flush; only while scrolling,
       otherwise it shifts short (centered) titles off-center. */
    padding-right: 2em;
    animation: marquee-scroll 14s linear infinite;
}

@keyframes marquee-scroll {
    0%, 10% { transform: translateX(0); }
    90%, 100% { transform: translateX(var(--marquee-distance, -50%)); }
}

#player-artist {
    font-size: clamp(0.82rem, 2.8vw, 0.95rem);
    color: rgba(255,255,255,0.75);
    margin-top: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Waveform */
#player-progress {
    margin: 8px 0 12px;
    padding: 0 4px;
}

.waveform-wrap {
    position: relative;
    height: 56px;
    width: 100%;
    cursor: pointer;
    touch-action: pan-y;
}

#waveform-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

.time-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.72rem;
    color: rgba(255,255,255,0.7);
    margin-top: 4px;
    padding: 0 2px;
    font-variant-numeric: tabular-nums;
}

/* Player controls */
#player-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
}

.ctrl-btn {
    width: 52px;
    height: 52px;
    min-height: 52px;
    border-radius: 50%;
    background: transparent;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.15s, transform 0.1s;
}

.ctrl-btn:hover { background: rgba(255,255,255,0.1); }
.ctrl-btn:active { transform: scale(0.92); }
.ctrl-btn.active { color: var(--accent); }
.ctrl-btn.active svg { filter: drop-shadow(0 0 8px var(--accent-glow)); }

.ctrl-btn.primary {
    width: 72px;
    height: 72px;
    min-height: 72px;
    background: #fff;
    color: #000;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.ctrl-btn.primary:hover { background: rgba(255,255,255,0.9); transform: scale(1.03); }
.ctrl-btn.primary:active { transform: scale(0.95); }

/* Extra controls (±10s + queue) */
#player-extra-controls {
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 0 16px;
    margin-top: 4px;
}

#player-extra-controls .icon-btn {
    color: rgba(255,255,255,0.85);
    background: rgba(255,255,255,0.08);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    width: 44px;
    height: 44px;
    border-radius: 14px;
    transition: background 0.2s ease, color 0.2s ease;
}
#player-extra-controls .icon-btn:hover { background: rgba(255,255,255,0.15); }
#player-extra-controls .icon-btn.active {
    background: rgba(255,255,255,0.22);
    color: #fff;
}

/* =========================================================================
   LYRICS PANEL (full player)
   - Occupies the artwork slot when `#player-content.showing-lyrics` is set.
   - Header, song info, progress, and controls stay visible unchanged.
   ========================================================================= */
#lyrics-panel {
    display: none;
    flex: 1;
    min-height: 0;
    position: relative;
    padding: 8px 0 12px;
    overflow: hidden;
    touch-action: pan-y;
}

#player-content.showing-lyrics #player-artwork-wrap {
    display: none;
}

#player-content.showing-lyrics #lyrics-panel {
    display: flex;
    flex-direction: column;
}

#lyrics-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 0 8px;
    scroll-behavior: smooth;
    mask-image: linear-gradient(
        to bottom,
        transparent 0%, #000 18%, #000 82%, transparent 100%
    );
    -webkit-mask-image: linear-gradient(
        to bottom,
        transparent 0%, #000 18%, #000 82%, transparent 100%
    );
}

#lyrics-list::-webkit-scrollbar { width: 0; height: 0; }

#lyrics-list .lyrics-spacer {
    height: 40%;
    min-height: 80px;
    flex-shrink: 0;
}

#lyrics-list.plain-only {
    mask-image: none;
    -webkit-mask-image: none;
}

.lyrics-line {
    font-size: 1.35rem;
    font-weight: 600;
    line-height: 1.35;
    text-align: center;
    color: rgba(255,255,255,0.35);
    padding: 10px 14px;
    border-radius: 12px;
    transition: color 0.25s ease, transform 0.25s ease, background 0.2s ease, opacity 0.25s ease;
    cursor: pointer;
    letter-spacing: -0.01em;
    text-shadow: 0 1px 6px rgba(0,0,0,0.25);
    word-break: break-word;
    hyphens: auto;
}

.lyrics-line.past { color: rgba(255,255,255,0.3); }
.lyrics-line.upcoming { color: rgba(255,255,255,0.5); }
.lyrics-line.active {
    color: #fff;
    transform: scale(1.04);
    text-shadow: 0 2px 12px rgba(0,0,0,0.4);
}

.lyrics-line:hover { background: rgba(255,255,255,0.06); }
.lyrics-line:active { background: rgba(255,255,255,0.12); }

.lyrics-line.plain {
    font-size: 1.1rem;
    font-weight: 500;
    color: rgba(255,255,255,0.82);
    cursor: default;
    text-align: center;
    padding: 4px 14px;
    transform: none;
}
.lyrics-line.plain:hover { background: transparent; }

#lyrics-status {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    color: rgba(255,255,255,0.7);
    font-size: 0.98rem;
    text-align: center;
}

.lyrics-empty { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.lyrics-empty-title {
    font-size: 1.15rem;
    font-weight: 600;
    color: rgba(255,255,255,0.95);
}
.lyrics-empty-sub {
    font-size: 0.9rem;
    color: rgba(255,255,255,0.65);
    max-width: 280px;
    line-height: 1.4;
}

.lyrics-retry {
    margin-top: 4px;
    padding: 8px 18px;
    border-radius: 999px;
    background: rgba(255,255,255,0.15);
    color: #fff;
    font-weight: 600;
    border: none;
    cursor: pointer;
}
.lyrics-retry:hover { background: rgba(255,255,255,0.25); }

@media (prefers-reduced-motion: reduce) {
    #lyrics-list { scroll-behavior: auto; }
    .lyrics-line { transition: none; }
}

/* Listen Together */
.together-chip {
    border: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border-radius: 999px;
    background: rgba(244,63,94,0.18);
    color: #fb7185;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    cursor: pointer;
    white-space: nowrap;
    flex: 0 0 auto;
}
.together-chip::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #f43f5e;
    animation: together-pulse 2s infinite;
}
.mini-live-chip {
    flex: 0 0 auto;
    align-self: center;
    padding: 3px 7px;
    border-radius: 999px;
    background: rgba(244,63,94,0.18);
    color: #fb7185;
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.06em;
}
@keyframes together-pulse {
    0% { box-shadow: 0 0 0 0 rgba(244,63,94,0.45); }
    70% { box-shadow: 0 0 0 6px rgba(244,63,94,0); }
    100% { box-shadow: 0 0 0 0 rgba(244,63,94,0); }
}
@media (prefers-reduced-motion: reduce) {
    .together-chip::before { animation: none; }
}
