/* ==================== 音乐播放器 · 亚克力面板 ==================== */
/* 音符按钮（右下角，收起态的入口） */
#music-toggle {
    position: fixed;
    right: 24px;
    bottom: 88px;
    width: 46px;
    height: 46px;
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.62);
    backdrop-filter: blur(14px) saturate(1.6);
    -webkit-backdrop-filter: blur(14px) saturate(1.6);
    color: var(--accent-deep);
    font-size: 18px;
    cursor: pointer;
    z-index: 1000;
    box-shadow: 0 8px 22px rgba(90, 50, 80, 0.20);
    transition: transform 0.2s ease, background 0.2s ease, color 0.2s ease;
}

#music-toggle:hover {
    transform: scale(1.08);
    color: var(--accent);
}

/* 播放中：粉底白标 + 呼吸光圈 */
#music-toggle.playing {
    background: linear-gradient(135deg, var(--accent-light), var(--accent));
    color: #fff;
    border-color: transparent;
    animation: music-pulse 1.8s ease-in-out infinite;
}

@keyframes music-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0.45); }
    50%      { box-shadow: 0 0 0 12px rgba(var(--accent-rgb), 0); }
}

/* ==================== 面板本体（亚克力） ==================== */
#music-bar {
    position: fixed;
    right: 24px;
    bottom: 144px;
    width: 332px;
    max-width: calc(100vw - 32px);
    padding: 13px 16px 12px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.56);
    backdrop-filter: blur(22px) saturate(1.75);
    -webkit-backdrop-filter: blur(22px) saturate(1.75);
    border: 1px solid rgba(255, 255, 255, 0.66);
    box-shadow: 0 16px 44px rgba(90, 50, 80, 0.20), inset 0 1px 0 rgba(255, 255, 255, 0.75);
    /* 从右下角"长出来"的展开动画 */
    transform-origin: bottom right;
    transform: scale(0.88) translateY(12px);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.3s cubic-bezier(0.34, 1.4, 0.64, 1), opacity 0.24s ease;
    z-index: 999;
}

#music-bar.show {
    transform: none;
    opacity: 1;
    pointer-events: auto;
}

/* 顶部：曲名 + 收起 */
.mb-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px;
}

#music-title {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 13px;
    font-weight: 600;
    color: #5c4a56;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: 0.2px;
}

#music-close {
    flex: 0 0 auto;
    border: none;
    background: transparent;
    color: #a08b96;
    font-size: 13px;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 8px;
    transition: color 0.15s, background 0.15s;
}

#music-close:hover {
    color: var(--accent);
    background: rgba(var(--accent-light-rgb), 0.14);
}

/* 主体：圆形封面 + 右侧信息 */
.mb-body {
    display: flex;
    align-items: center;
    gap: 13px;
}

.mb-cover {
    position: relative;
    flex: 0 0 62px;
    width: 62px;
    height: 62px;
    border-radius: 50%;
    overflow: hidden;
    background: radial-gradient(circle at 35% 30%, var(--accent-pale), var(--accent-pale));
    box-shadow: 0 5px 16px rgba(90, 50, 80, 0.24), inset 0 0 0 1px rgba(255, 255, 255, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
}

.mb-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    /* 唱片旋转：暂停即停（角度保留），播放续转 */
    animation: mbSpin 9s linear infinite;
    animation-play-state: paused;
}

#music-bar.playing .mb-cover img {
    animation-play-state: running;
}

@keyframes mbSpin {
    to { transform: rotate(360deg); }
}

/* 没有封面时的默认图标 */
.mb-cover .mb-fallback {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    color: #e79cc0;
    font-size: 22px;
}

#music-bar:not(.has-cover) .mb-fallback {
    display: flex;
}

.mb-side {
    flex: 1 1 auto;
    min-width: 0;
}

/* 进度条行 */
.mb-progress {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

#music-cur,
#music-dur {
    font-size: 11px;
    color: #a08b96;
    font-variant-numeric: tabular-nums;
    min-width: 30px;
    text-align: center;
    user-select: none;
}

#music-progress {
    -webkit-appearance: none;
    appearance: none;
    flex: 1 1 auto;
    min-width: 60px;
    height: 4px;
    border-radius: 3px;
    /* 已播部分：粉色；未播：半透明 —— --p 由 JS 实时更新 */
    background: linear-gradient(to right,
        var(--accent-light) 0%, var(--accent) var(--p, 0%),
        rgba(120, 90, 110, 0.16) var(--p, 0%), rgba(120, 90, 110, 0.16) 100%);
    outline: none;
    cursor: pointer;
}

#music-progress::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: #fff;
    border: 3px solid var(--accent);
    box-shadow: 0 2px 7px rgba(var(--accent-rgb), 0.5);
    cursor: grab;
    transition: transform 0.15s ease;
}

#music-progress::-webkit-slider-thumb:hover {
    transform: scale(1.18);
}

#music-progress::-webkit-slider-thumb:active {
    cursor: grabbing;
    transform: scale(1.24);
}

#music-progress::-moz-range-thumb {
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: #fff;
    border: 3px solid var(--accent);
    box-shadow: 0 2px 7px rgba(var(--accent-rgb), 0.5);
    cursor: grab;
}

#music-progress::-moz-range-track {
    height: 4px;
    border-radius: 3px;
    background: rgba(120, 90, 110, 0.16);
}

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

.mb-controls button {
    position: relative;
    border: none;
    background: transparent;
    color: #8a7280;
    font-size: 14px;
    line-height: 1;
    padding: 5px;
    cursor: pointer;
    border-radius: 50%;
    transition: color 0.15s ease, transform 0.15s ease;
}

.mb-controls button:hover {
    color: var(--accent);
    transform: scale(1.14);
}

/* 主播放键 */
#music-play {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, var(--accent-light), var(--accent));
    color: #fff;
    font-size: 14px;
    box-shadow: 0 5px 15px rgba(var(--accent-rgb), 0.38);
}

#music-play:hover {
    color: #fff;
    transform: scale(1.07);
    box-shadow: 0 7px 18px rgba(var(--accent-rgb), 0.48);
}

/* ==================== 夜间模式 ==================== */
html.dark-mode #music-toggle {
    background: rgba(26, 29, 36, 0.62);
    border-color: rgba(255, 255, 255, 0.14);
    color: var(--accent-light);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.45);
}

html.dark-mode #music-toggle.playing {
    background: linear-gradient(135deg, var(--accent-light), var(--accent));
    color: #fff;
}

html.dark-mode #music-bar {
    background: rgba(26, 29, 36, 0.62);
    border-color: rgba(255, 255, 255, 0.14);
    box-shadow: 0 16px 44px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.10);
}

html.dark-mode #music-title {
    color: #e8e2e6;
}

html.dark-mode #music-close,
html.dark-mode #music-cur,
html.dark-mode #music-dur {
    color: #8b8492;
}

html.dark-mode .mb-controls button {
    color: #9a94a4;
}

html.dark-mode .mb-controls button:hover {
    color: var(--accent-light);
}

html.dark-mode #music-progress {
    background: linear-gradient(to right,
        var(--accent-light) 0%, var(--accent) var(--p, 0%),
        rgba(255, 255, 255, 0.16) var(--p, 0%), rgba(255, 255, 255, 0.16) 100%);
}

html.dark-mode #music-progress::-moz-range-track {
    background: rgba(255, 255, 255, 0.16);
}

html.dark-mode .mb-cover {
    background: radial-gradient(circle at 35% 30%, #3a3040, #241f2b);
    box-shadow: 0 5px 16px rgba(0, 0, 0, 0.5), inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

/* ==================== 封面律动（播放时呼吸 + 光圈） ==================== */
/* 呼吸：轻微缩放 + 粉光圈扩散，与右下角音符按钮的脉冲语言一致 */
#music-bar.playing .mb-cover {
    animation: mbBreathe 2.6s ease-in-out infinite;
}

@keyframes mbBreathe {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 5px 16px rgba(90, 50, 80, 0.24),
                    0 0 0 0 rgba(var(--accent-rgb), 0.40),
                    inset 0 0 0 1px rgba(255, 255, 255, 0.5);
    }
    50% {
        transform: scale(1.045);
        box-shadow: 0 8px 22px rgba(90, 50, 80, 0.30),
                    0 0 0 9px rgba(var(--accent-rgb), 0),
                    inset 0 0 0 1px rgba(255, 255, 255, 0.62);
    }
}

/* ==================== 无封面时的"黑胶盘"（纯 CSS 绘制） ==================== */
/* 盘面画在 ::before 上：同心细纹 + 粉色中心标签，播放时旋转 */
#music-bar:not(.has-cover) .mb-cover {
    background: #2a2431;
}

#music-bar:not(.has-cover) .mb-cover::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background:
        /* 中心标签（粉色圆片） */
        radial-gradient(circle at 50% 50%,
            var(--accent-pale) 0 13%,
            var(--accent-light) 13% 14.5%,
            transparent 14.5%),
        /* 黑胶同心细纹 */
        repeating-radial-gradient(circle at 50% 50%,
            rgba(255, 255, 255, 0.045) 0 1px,
            rgba(0, 0, 0, 0) 1px 3.2px),
        /* 盘体：中心稍亮，边缘压暗（有体积感） */
        radial-gradient(circle at 50% 50%,
            #443a4d 0 26%,
            #332b3c 55%,
            #231d29 88%,
            #1b1620 100%);
    animation: mbSpin 9s linear infinite;
    animation-play-state: paused;
}

#music-bar.playing:not(.has-cover) .mb-cover::before {
    animation-play-state: running;
}

/* 固定高光（不随盘面旋转，像玻璃罩反光） */
#music-bar:not(.has-cover) .mb-cover::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: linear-gradient(135deg,
        rgba(255, 255, 255, 0.30) 0%,
        rgba(255, 255, 255, 0.10) 26%,
        rgba(255, 255, 255, 0) 46%);
    pointer-events: none;
    z-index: 2;
}

/* 无封面时中心的小音符：白色，压在粉色标签上 */
#music-bar:not(.has-cover) .mb-fallback {
    z-index: 3;
    font-size: 15px;
    color: rgba(255, 255, 255, 0.92);
    text-shadow: 0 1px 3px rgba(180, 60, 120, 0.45);
}

/* 夜间模式：盘体略亮一点，标签用更亮的粉 */
html.dark-mode #music-bar:not(.has-cover) .mb-cover::before {
    background:
        radial-gradient(circle at 50% 50%,
            var(--accent-pale) 0 13%,
            var(--accent-light) 13% 14.5%,
            transparent 14.5%),
        repeating-radial-gradient(circle at 50% 50%,
            rgba(255, 255, 255, 0.06) 0 1px,
            rgba(0, 0, 0, 0) 1px 3.2px),
        radial-gradient(circle at 50% 50%,
            #4e4359 0 26%,
            #3a3145 55%,
            #282130 88%,
            #1f1a26 100%);
}

/* ==================== 歌曲列表（可折叠） ==================== */
#music-list-toggle {
    flex: 0 0 auto;
    border: none;
    background: transparent;
    color: #a08b96;
    font-size: 12px;
    line-height: 1;
    padding: 4px 6px;
    border-radius: 8px;
    cursor: pointer;
    transition: color 0.15s ease, background 0.15s ease;
}

#music-list-toggle:hover,
#music-list-toggle.open {
    color: var(--accent);
    background: rgba(var(--accent-light-rgb), 0.16);
}

.mb-list {
    max-height: 0;
    overflow: hidden auto;
    opacity: 0;
    margin-top: 0;
    transition: max-height 0.34s cubic-bezier(0.34, 1.2, 0.64, 1), opacity 0.24s ease, margin-top 0.3s ease;
    scrollbar-width: thin;
    scrollbar-color: rgba(var(--accent-light-rgb), 0.5) transparent;
    overscroll-behavior: contain;
}

.mb-list.open {
    max-height: 172px;
    opacity: 1;
    margin-top: 10px;
}

.mb-list::-webkit-scrollbar {
    width: 5px;
}

.mb-list::-webkit-scrollbar-thumb {
    background: rgba(var(--accent-light-rgb), 0.5);
    border-radius: 3px;
}

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

.mb-item {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    border: none;
    background: transparent;
    text-align: left;
    padding: 7px 9px;
    border-radius: 9px;
    font-size: 12.5px;
    line-height: 1.35;
    color: #6f5c66;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.mb-item + .mb-item {
    margin-top: 1px;
}

.mb-item .no {
    flex: 0 0 18px;
    font-size: 10.5px;
    color: #bda8b3;
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.mb-item .nm {
    flex: 1 1 auto;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mb-item .mb-cur-ico {
    display: none;
    flex: 0 0 auto;
    font-size: 10px;
    color: var(--accent);
}

.mb-item:hover {
    background: rgba(var(--accent-light-rgb), 0.13);
    color: var(--accent-deep);
}

.mb-item.current {
    background: linear-gradient(135deg, rgba(var(--accent-light-rgb), 0.24), rgba(var(--accent-rgb), 0.14));
    color: var(--accent-deep);
    font-weight: 600;
}

.mb-item.current .no {
    color: var(--accent-deep);
}

.mb-item.current .mb-cur-ico {
    display: inline-block;
}

html.dark-mode .mb-item {
    color: #b9b2c4;
}

html.dark-mode .mb-item .no {
    color: #6f6879;
}

html.dark-mode .mb-item:hover {
    background: rgba(var(--accent-light-rgb), 0.16);
    color: var(--accent-light);
}

html.dark-mode .mb-item.current {
    background: linear-gradient(135deg, rgba(var(--accent-light-rgb), 0.26), rgba(var(--accent-rgb), 0.16));
    color: var(--accent-light);
}

html.dark-mode .mb-item.current .no {
    color: var(--accent-light);
}

/* ==================== 循环模式三态（图标 + 角标 + 配色） ==================== */
/* 列表循环：默认灰（fa-repeat）；单曲循环：粉色 + "1" 角标；随机播放：粉色（fa-shuffle） */
#music-loop.mode-one,
#music-loop.mode-shuffle {
    color: var(--accent);
}

#music-loop.mode-one:hover,
#music-loop.mode-shuffle:hover {
    color: var(--accent-deep);
}

/* 单曲循环的 "1" 角标 */
#music-loop.mode-one::after {
    content: '1';
    position: absolute;
    right: 0;
    bottom: 1px;
    min-width: 10px;
    padding: 1px 2px;
    border-radius: 5px;
    background: var(--accent);
    color: #fff;
    font-size: 8px;
    font-weight: 700;
    line-height: 1.15;
    text-align: center;
    box-shadow: 0 1px 4px rgba(var(--accent-rgb), 0.45);
    pointer-events: none;
}

/* ==================== 切歌方向回弹（上一首向左、下一首向右） ==================== */
#music-prev.dir-bump-l i {
    animation: dirBumpL 0.36s cubic-bezier(0.34, 1.4, 0.64, 1);
}

#music-next.dir-bump-r i {
    animation: dirBumpR 0.36s cubic-bezier(0.34, 1.4, 0.64, 1);
}

@keyframes dirBumpL {
    0%   { transform: translateX(0) scale(1); opacity: 0.45; }
    45%  { transform: translateX(-5px) scale(0.9); }
    100% { transform: translateX(0) scale(1); opacity: 1; }
}

@keyframes dirBumpR {
    0%   { transform: translateX(0) scale(1); opacity: 0.45; }
    45%  { transform: translateX(5px) scale(0.9); }
    100% { transform: translateX(0) scale(1); opacity: 1; }
}

/* 所有控制按钮：按下去有实感 */
.mb-controls button:active {
    transform: scale(0.86);
}

/* 通用小回弹（循环键 / 播放键共用） */
#music-loop.icon-bump i,
#music-play.icon-bump i {
    animation: iconBump 0.34s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes iconBump {
    0%   { transform: scale(0.72) rotate(-14deg); opacity: 0.4; }
    60%  { transform: scale(1.12) rotate(4deg); }
    100% { transform: scale(1) rotate(0); opacity: 1; }
}

/* 夜间模式：角标与图标保持粉亮 */
html.dark-mode #music-loop.mode-one,
html.dark-mode #music-loop.mode-shuffle {
    color: var(--accent-light);
}

html.dark-mode #music-loop.mode-one::after {
    background: var(--accent-light);
    color: #241a22;
}

/* ==================== 缓冲状态提示 ==================== */
/* 播放中数据跟不上时（waiting/stalled），转盘暂停 + 标题后缀提示 */
#music-bar.buffering .mb-cover {
    animation-play-state: paused;
}

#music-bar.buffering:not(.has-cover) .mb-cover::before {
    animation-play-state: paused;
}

#music-bar.buffering #music-title::after {
    content: ' · 缓冲中…';
    font-size: 11px;
    font-weight: 400;
    opacity: 0.7;
}

#music-bar.buffering .mb-progress {
    opacity: 0.55;
}

#music-bar.buffering #music-cover {
    animation-play-state: paused;
}
