/* ============================================================
   现代音乐播放器样式
   ============================================================ */

/* ---------- CSS 变量 ---------- */
:root {
    --font: 'Inter', 'Microsoft YaHei', 'PingFang SC', system-ui, -apple-system, sans-serif;

    /* 主题色 */
    --accent: #7c5cfc;
    --accent-glow: rgba(124, 92, 252, .45);
    --accent-light: #a78bfa;

    /* 背景与文字 */
    --bg: #0c0c14;
    --surface: rgba(255, 255, 255, .06);
    --surface-hover: rgba(255, 255, 255, .10);
    --surface-active: rgba(255, 255, 255, .14);
    --border: rgba(255, 255, 255, .08);
    --text: #f0f0f5;
    --text-secondary: rgba(240, 240, 245, .55);
    --text-dim: rgba(240, 240, 245, .3);

    /* 尺寸 */
    --radius: 18px;
    --radius-sm: 10px;
    --radius-xs: 6px;
    --cover-size: 280px;
    --transition: .25s cubic-bezier(.4, 0, .2, 1);
}

/* ---------- 重置与基础 ---------- */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    overflow-x: hidden;
}

body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
}

/* ---------- 动态渐变背景 ---------- */
.bg-gradient {
    position: fixed;
    inset: 0;
    z-index: 0;
    background: radial-gradient(ellipse at 30% 20%, rgba(124, 92, 252, .22) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 70%, rgba(236, 72, 153, .15) 0%, transparent 55%);
    transition: background 1.5s ease;
    pointer-events: none;
}

/* ---------- 应用容器 ---------- */
.app-container {
    position: relative;
    z-index: 1;
    display: flex;
    gap: 24px;
    max-width: 900px;
    width: 100%;
    align-items: flex-start;
    transition: transform var(--transition), box-shadow var(--transition);
}

.app-container.drag-over {
    transform: scale(1.02);
}

.app-container.drag-over::after {
    content: "松开以上传音乐";
    position: absolute;
    inset: -10px;
    border: 2px dashed var(--accent);
    border-radius: calc(var(--radius) + 10px);
    background: rgba(124, 92, 252, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: var(--accent);
    z-index: 100;
    pointer-events: none;
    backdrop-filter: blur(4px);
}

/* ---------- 播放器卡片 ---------- */
.player-card {
    flex: 1;
    min-width: 340px;
    background: var(--surface);
    backdrop-filter: blur(40px) saturate(1.4);
    -webkit-backdrop-filter: blur(40px) saturate(1.4);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px 28px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    box-shadow: 0 8px 48px rgba(0, 0, 0, .35),
        inset 0 1px 0 rgba(255, 255, 255, .05);
    animation: cardIn .6s ease forwards;
}

@keyframes cardIn {
    from {
        opacity: 0;
        transform: translateY(24px) scale(.97);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ---------- 封面区域 ---------- */
.cover-section {
    width: 100%;
    display: flex;
    justify-content: center;
}

.cover-wrapper {
    position: relative;
    width: var(--cover-size);
    height: var(--cover-size);
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: linear-gradient(135deg, rgba(124, 92, 252, .15), rgba(236, 72, 153, .10));
    box-shadow: 0 12px 40px rgba(0, 0, 0, .4);
    transition: box-shadow var(--transition);
}

.cover-wrapper:hover {
    box-shadow: 0 16px 56px rgba(124, 92, 252, .3);
}

.cover-art {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity .5s ease;
}

.cover-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-dim);
}

.visualizer-canvas {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 60%;
    pointer-events: none;
    opacity: .7;
}

.hidden {
    display: none !important;
}

/* ---------- 曲目信息 ---------- */
.track-info {
    text-align: center;
    width: 100%;
    padding: 0 8px;
}

.track-title {
    font-size: 1.15rem;
    font-weight: 600;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.track-artist {
    font-size: .85rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* ---------- 进度条 ---------- */
.progress-section {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
}

.time {
    font-size: .72rem;
    font-weight: 500;
    color: var(--text-secondary);
    min-width: 36px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.progress-bar-container {
    flex: 1;
    position: relative;
    height: 20px;
    display: flex;
    align-items: center;
    cursor: pointer;
}

.progress-bar-bg {
    width: 100%;
    height: 4px;
    border-radius: 2px;
    background: rgba(255, 255, 255, .1);
    overflow: hidden;
    transition: height var(--transition);
}

.progress-bar-container:hover .progress-bar-bg {
    height: 6px;
}

.progress-bar-fill {
    height: 100%;
    width: 0%;
    border-radius: 2px;
    background: linear-gradient(90deg, var(--accent), var(--accent-light));
    transition: width .08s linear;
}

.progress-slider {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}

/* ---------- 控制按钮 ---------- */
.controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.ctrl-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all var(--transition);
}

.ctrl-btn.secondary {
    width: 42px;
    height: 42px;
}

.ctrl-btn.secondary:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.ctrl-btn.secondary.active {
    color: var(--accent);
}

.ctrl-btn.primary {
    width: 58px;
    height: 58px;
    background: var(--accent);
    color: #fff;
    box-shadow: 0 4px 20px var(--accent-glow);
    transition: all var(--transition);
}

.ctrl-btn.primary:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px var(--accent-glow);
}

.ctrl-btn.primary:active {
    transform: scale(.96);
}

.ctrl-btn.tiny {
    width: 32px;
    height: 32px;
}

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

/* ---------- 歌词显示区域 ---------- */
.lyrics-section {
    width: 100%;
    padding: 0;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.lyrics-mask {
    width: 100%;
    height: 160px;
    overflow: hidden;
    position: relative;
    /* 上下渐变遮罩，模拟消失效果 */
    -webkit-mask-image: linear-gradient(to bottom, transparent, black 25%, black 75%, transparent);
    mask-image: linear-gradient(to bottom, transparent, black 25%, black 75%, transparent);
}

.save-lrc-btn {
    background: var(--surface-active);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text-secondary);
    padding: 6px 14px;
    font-size: 0.72rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    transition: all var(--transition);
    backdrop-filter: blur(8px);
}

.save-lrc-btn:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    box-shadow: 0 0 12px var(--accent-glow);
}

.save-lrc-btn svg {
    opacity: 0.8;
}

.lyrics-display {
    width: 100%;
    padding: 60px 0;
    /* 给上下留出空间，让第一行和最后一行能居中 */
    pointer-events: none;
    transition: transform 0.6s cubic-bezier(0.23, 1, 0.32, 1);
    will-change: transform;
}

.lyric-line {
    padding: 3px 0;
    transition: all .35s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.8;
}

.lyric-line.active {
    color: var(--accent-light);
    font-weight: 700;
    font-size: 1.05rem;
    text-shadow: 0 0 16px var(--accent-glow);
}

.lyric-line.dim-1 {
    color: var(--text-secondary);
    font-size: .88rem;
}

.lyric-line.dim-2 {
    color: var(--text-dim);
    font-size: .80rem;
}

.lyrics-placeholder {
    color: var(--text-dim);
    font-size: .85rem;
}

.file-hint {
    display: block;
    margin-top: 6px;
    font-size: .72rem;
    color: var(--text-dim);
    text-align: center;
}

/* ---------- 音量 ---------- */
.volume-section {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 0 4px;
}

.volume-slider {
    -webkit-appearance: none;
    appearance: none;
    flex: 1;
    height: 4px;
    border-radius: 2px;
    background: linear-gradient(to right, var(--accent) 0%, var(--accent) var(--vol-pct, 80%), rgba(255, 255, 255, .1) var(--vol-pct, 80%));
    outline: none;
    cursor: pointer;
    transition: height var(--transition);
}

.volume-slider:hover {
    height: 6px;
}

.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 0 6px rgba(0, 0, 0, .3);
    cursor: pointer;
    transition: transform var(--transition);
}

.volume-slider::-webkit-slider-thumb:hover {
    transform: scale(1.25);
}

/* ---------- 文件导入 ---------- */
.file-section {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.file-btns {
    display: flex;
    gap: 10px;
    width: 100%;
    justify-content: center;
}

.file-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    background: var(--surface);
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: .82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    flex: 1;
    justify-content: center;
}

.file-btn:hover {
    background: var(--surface-hover);
    color: var(--text);
    border-color: var(--accent);
    box-shadow: 0 0 16px var(--accent-glow);
}

/* ---------- 播放列表面板 ---------- */
.playlist-panel {
    width: 280px;
    flex-shrink: 0;
    background: var(--surface);
    backdrop-filter: blur(40px) saturate(1.4);
    -webkit-backdrop-filter: blur(40px) saturate(1.4);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 0;
    max-height: 520px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 48px rgba(0, 0, 0, .3);
    animation: cardIn .6s .15s ease both;
}

.playlist-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px 14px;
    border-bottom: 1px solid var(--border);
}

.playlist-header h2 {
    font-size: .95rem;
    font-weight: 600;
}

.playlist-count {
    font-size: .75rem;
    color: var(--text-secondary);
}

.playlist-list {
    list-style: none;
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.playlist-list::-webkit-scrollbar {
    width: 4px;
}

.playlist-list::-webkit-scrollbar-track {
    background: transparent;
}

.playlist-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, .12);
    border-radius: 2px;
}

.playlist-empty {
    padding: 32px 20px;
    text-align: center;
    color: var(--text-dim);
    font-size: .82rem;
}

.playlist-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    cursor: pointer;
    transition: background var(--transition);
    border-radius: 0;
}

.playlist-item:hover {
    background: var(--surface-hover);
}

.playlist-item.active {
    background: var(--surface-active);
}

.playlist-item .pl-index {
    font-size: .72rem;
    color: var(--text-dim);
    min-width: 20px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.playlist-item.active .pl-index {
    color: var(--accent);
}

.playlist-item .pl-name {
    flex: 1;
    font-size: .82rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.playlist-item.active .pl-name {
    color: var(--accent-light);
    font-weight: 500;
}

.playlist-item .pl-artist {
    width: 84px;
    flex-shrink: 0;
    text-align: right;
    font-size: .72rem;
    color: var(--text-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 需重新授权的曲目样式 */
.playlist-item.needs-auth {
    opacity: .55;
}

.playlist-item.needs-auth:hover {
    opacity: 1;
}

.playlist-item.needs-auth .pl-name::after {
    content: "（需重新授权）";
    font-size: .68rem;
    color: #f59e0b;
    margin-left: 4px;
}

/* 正在播放时的均衡器动画 */
.playlist-item.active .pl-index .eq-bars {
    display: inline-flex;
    gap: 2px;
    align-items: flex-end;
    height: 12px;
}

.eq-bar {
    width: 3px;
    background: var(--accent);
    border-radius: 1px;
    animation: eqBounce .8s ease infinite alternate;
}

.eq-bar:nth-child(2) {
    animation-delay: .15s;
}

.eq-bar:nth-child(3) {
    animation-delay: .3s;
}

@keyframes eqBounce {
    0% {
        height: 3px;
    }

    100% {
        height: 12px;
    }
}

/* ---------- 响应式 ---------- */
@media (max-width: 720px) {
    .app-container {
        flex-direction: column;
        align-items: stretch;
    }

    .player-card {
        min-width: 0;
    }

    .playlist-panel {
        width: 100%;
        max-height: 300px;
    }

    :root {
        --cover-size: 220px;
    }
}

@media (max-width: 400px) {
    .player-card {
        padding: 20px 16px 18px;
    }

    :root {
        --cover-size: 180px;
    }

    .controls {
        gap: 8px;
    }

    .ctrl-btn.primary {
        width: 50px;
        height: 50px;
    }
}