/**
 * 音乐盒 · 前台播放器样式
 *
 * 独立的玻璃卡片，不继承主题配色（主题的浅底 / 深底都能压得住）。
 * 全部选择器收在 #mbx-root 下，不会碰到主题样式。
 */

#mbx-root.mbx-player {
    --mbx-accent: #ec4141;
    --mbx-bg: rgba(20, 21, 26, .93);
    --mbx-bg-soft: rgba(255, 255, 255, .07);
    --mbx-ink: #f3f5f8;
    --mbx-muted: #9ba3af;
    --mbx-line: rgba(255, 255, 255, .1);
    --mbx-shadow: 0 22px 50px -18px rgba(0, 0, 0, .55), 0 2px 6px rgba(0, 0, 0, .18);

    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 9990;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    font-size: 13px;
    line-height: 1.5;
    color: var(--mbx-ink);
    -webkit-font-smoothing: antialiased;
    text-align: left;
}

#mbx-root.mbx-player[data-pos="bl"] {
    right: auto;
    left: 22px;
}

#mbx-root.mbx-player *,
#mbx-root.mbx-player *::before,
#mbx-root.mbx-player *::after {
    box-sizing: border-box;
}

/* 浅色主题 */

#mbx-root.mbx-player[data-theme="light"] {
    --mbx-bg: rgba(255, 255, 255, .95);
    --mbx-bg-soft: rgba(15, 23, 42, .05);
    --mbx-ink: #15171c;
    --mbx-muted: #767d89;
    --mbx-line: rgba(15, 23, 42, .1);
    --mbx-shadow: 0 20px 44px -20px rgba(15, 23, 42, .45), 0 2px 6px rgba(15, 23, 42, .08);
}

@media (prefers-color-scheme: light) {
    #mbx-root.mbx-player[data-theme="auto"] {
        --mbx-bg: rgba(255, 255, 255, .95);
        --mbx-bg-soft: rgba(15, 23, 42, .05);
        --mbx-ink: #15171c;
        --mbx-muted: #767d89;
        --mbx-line: rgba(15, 23, 42, .1);
        --mbx-shadow: 0 20px 44px -20px rgba(15, 23, 42, .45), 0 2px 6px rgba(15, 23, 42, .08);
    }
}

/* ---------------- 唱片按钮 ---------------- */

#mbx-root .mbx-disc {
    position: relative;
    display: block;
    width: 56px;
    height: 56px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #14151a;
    cursor: pointer;
    overflow: visible;
    box-shadow: var(--mbx-shadow);
    transition: transform .2s ease, box-shadow .2s ease;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
}

#mbx-root .mbx-disc:hover {
    transform: translateY(-2px);
}

#mbx-root .mbx-disc:active {
    transform: scale(.96);
}

#mbx-root .mbx-disc-art {
    position: absolute;
    inset: 4px;
    border-radius: 50%;
    background-color: #22242b;
    background-size: cover;
    background-position: center;
    background-image: radial-gradient(circle at 50% 42%, #3a3d47 0%, #191a20 72%);
}

#mbx-root .mbx-disc-mask {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: radial-gradient(circle at 50% 50%,
        transparent 0 34%, rgba(0, 0, 0, .28) 36%, transparent 62%);
    pointer-events: none;
}

#mbx-root .mbx-disc-dot {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 7px;
    height: 7px;
    margin: -3.5px 0 0 -3.5px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .85);
    box-shadow: 0 0 0 2px rgba(0, 0, 0, .35);
    pointer-events: none;
}

#mbx-root .mbx-disc-ring {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    color: var(--mbx-accent);
    pointer-events: none;
    transform: rotate(0deg);
}

#mbx-root .mbx-ring-fill {
    transition: stroke-dashoffset .3s linear;
}

#mbx-root.is-playing .mbx-disc-art {
    animation: mbx-spin 18s linear infinite;
}

#mbx-root.is-open .mbx-disc {
    display: none;
}

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

/* ---------------- 迷你控制（缩小态） ---------------- */

/* 唱片收起时常驻的一组小控件：上一曲 / 下一曲 / 音量，不用先点开面板。 */
#mbx-root .mbx-mini {
    position: absolute;
    left: 50%;
    bottom: calc(100% + 8px);
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 7px;
    border-radius: 999px;
    background: var(--mbx-bg);
    border: 1px solid var(--mbx-line);
    box-shadow: var(--mbx-shadow);
    backdrop-filter: blur(18px) saturate(1.4);
    -webkit-backdrop-filter: blur(18px) saturate(1.4);
    z-index: 2;
}

/* 面板展开时唱片没了，迷你控件也一起收起 */
#mbx-root.is-open .mbx-mini {
    display: none;
}

#mbx-root .mbx-mini-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--mbx-ink);
    cursor: pointer;
    transition: background .15s ease, transform .1s ease;
    -webkit-tap-highlight-color: transparent;
}

#mbx-root .mbx-mini-btn:hover {
    background: var(--mbx-bg-soft);
}

#mbx-root .mbx-mini-btn:active {
    transform: scale(.92);
}

#mbx-root .mbx-mini-btn svg {
    width: 17px;
    height: 17px;
}

#mbx-root .mbx-mini-vol {
    width: 72px;
    height: 4px;
    margin: 0 4px;
    appearance: none;
    -webkit-appearance: none;
    background: var(--mbx-bg-soft);
    border-radius: 999px;
    outline: none;
    cursor: pointer;
}

#mbx-root .mbx-mini-vol::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: var(--mbx-accent);
    border: 2px solid #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .35);
    cursor: pointer;
}

#mbx-root .mbx-mini-vol::-moz-range-thumb {
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: var(--mbx-accent);
    border: 2px solid #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .35);
    cursor: pointer;
}

/* ---------------- 面板 ---------------- */

#mbx-root .mbx-panel {
    width: 340px;
    max-width: calc(100vw - 28px);
    max-height: min(560px, calc(100vh - 40px));
    display: flex;
    flex-direction: column;
    gap: 11px;
    padding: 14px 14px 12px;
    border-radius: 20px;
    background: var(--mbx-bg);
    border: 1px solid var(--mbx-line);
    box-shadow: var(--mbx-shadow);
    backdrop-filter: blur(18px) saturate(1.4);
    -webkit-backdrop-filter: blur(18px) saturate(1.4);
    animation: mbx-pop .22s cubic-bezier(.2, .9, .3, 1.1);
}

#mbx-root .mbx-panel[hidden] {
    display: none;
}

@keyframes mbx-pop {
    from {
        opacity: 0;
        transform: translateY(10px) scale(.97);
    }
}

/* 头部 */

#mbx-root .mbx-head {
    display: flex;
    align-items: center;
    gap: 11px;
    min-width: 0;
}

#mbx-root .mbx-cover {
    flex: 0 0 auto;
    width: 50px;
    height: 50px;
    border-radius: 13px;
    background-color: var(--mbx-bg-soft);
    background-size: cover;
    background-position: center;
    display: grid;
    place-items: center;
    overflow: hidden;
    box-shadow: 0 6px 16px -8px rgba(0, 0, 0, .5);
}

#mbx-root .mbx-cover.has-art .mbx-cover-ph {
    display: none;
}

#mbx-root .mbx-cover-ph {
    width: 22px;
    height: 22px;
    color: var(--mbx-muted);
}

#mbx-root .mbx-cover-ph svg {
    width: 100%;
    height: 100%;
    fill: none;
}

#mbx-root .mbx-meta {
    flex: 1 1 auto;
    min-width: 0;
}

#mbx-root .mbx-title {
    font-size: 14px;
    font-weight: 600;
    letter-spacing: .01em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#mbx-root .mbx-artist {
    margin-top: 2px;
    font-size: 12px;
    color: var(--mbx-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#mbx-root .mbx-icon {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--mbx-ink);
    cursor: pointer;
    opacity: .74;
    transition: opacity .16s, background .16s;
    -webkit-tap-highlight-color: transparent;
}

#mbx-root .mbx-icon:hover {
    opacity: 1;
    background: var(--mbx-bg-soft);
}

#mbx-root .mbx-icon svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

#mbx-root .mbx-close svg {
    fill: none;
}

/* 提示条 */

#mbx-root .mbx-note {
    padding: 7px 10px;
    border-radius: 9px;
    font-size: 11.5px;
    line-height: 1.6;
    background: rgba(255, 178, 60, .14);
    color: #ffc978;
    border: 1px solid rgba(255, 178, 60, .22);
}

#mbx-root[data-theme="light"] .mbx-note {
    color: #9a5b00;
    background: #fff6e5;
    border-color: #ffe2b0;
}

#mbx-root .mbx-note.is-error {
    background: rgba(255, 90, 90, .14);
    color: #ff9d9d;
    border-color: rgba(255, 90, 90, .24);
}

#mbx-root .mbx-note.is-busy {
    background: var(--mbx-bg-soft);
    color: var(--mbx-muted);
    border-color: transparent;
}

#mbx-root .mbx-note[hidden] {
    display: none;
}

/* 进度 */

#mbx-root .mbx-progress {
    display: flex;
    align-items: center;
    gap: 9px;
}

#mbx-root .mbx-time {
    flex: 0 0 auto;
    font-size: 11px;
    font-variant-numeric: tabular-nums;
    color: var(--mbx-muted);
    min-width: 34px;
}

#mbx-root .mbx-now {
    text-align: right;
}

#mbx-root .mbx-bar {
    position: relative;
    flex: 1 1 auto;
    height: 14px;
    cursor: pointer;
    touch-action: none;
    outline: none;
}

#mbx-root .mbx-bar::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 5px;
    height: 4px;
    border-radius: 99px;
    background: var(--mbx-bg-soft);
}

#mbx-root .mbx-bar-fill {
    position: absolute;
    left: 0;
    top: 5px;
    height: 4px;
    width: 0;
    border-radius: 99px;
    background: var(--mbx-accent);
    pointer-events: none;
}

#mbx-root .mbx-bar-dot {
    position: absolute;
    top: 7px;
    left: 0;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .4);
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: opacity .16s;
    pointer-events: none;
}

#mbx-root .mbx-bar:hover .mbx-bar-dot,
#mbx-root .mbx-bar:focus-visible .mbx-bar-dot {
    opacity: 1;
}

/* 控制按钮 */

#mbx-root .mbx-controls {
    display: flex;
    align-items: center;
    gap: 2px;
}

#mbx-root .mbx-play {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    margin: 0 4px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--mbx-accent);
    color: #fff;
    cursor: pointer;
    box-shadow: 0 8px 20px -10px var(--mbx-accent);
    transition: transform .16s, filter .16s;
    -webkit-tap-highlight-color: transparent;
}

#mbx-root .mbx-play:hover {
    filter: brightness(1.08);
}

#mbx-root .mbx-play:active {
    transform: scale(.94);
}

#mbx-root .mbx-play svg {
    width: 19px;
    height: 19px;
    fill: currentColor;
}

#mbx-root .mbx-spacer {
    flex: 1 1 auto;
}

#mbx-root .mbx-vol {
    flex: 0 0 auto;
    width: 62px;
    height: 4px;
    margin: 0 2px 0 0;
    padding: 0;
    border: 0;
    border-radius: 99px;
    background: var(--mbx-bg-soft);
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
    outline: none;
}

#mbx-root .mbx-vol::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--mbx-ink);
    border: 0;
    cursor: pointer;
}

#mbx-root .mbx-vol::-moz-range-thumb {
    width: 10px;
    height: 10px;
    border: 0;
    border-radius: 50%;
    background: var(--mbx-ink);
    cursor: pointer;
}

/* 歌单选择 */

#mbx-root .mbx-listbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-top: 2px;
    border-top: 1px solid var(--mbx-line);
}

#mbx-root .mbx-select {
    flex: 1 1 auto;
    min-width: 0;
    padding: 5px 6px;
    border: 1px solid var(--mbx-line);
    border-radius: 8px;
    background: transparent;
    color: var(--mbx-ink);
    font: inherit;
    font-size: 12px;
    cursor: pointer;
}

#mbx-root .mbx-select option {
    background: #1a1b21;
    color: #f3f5f8;
}

#mbx-root[data-theme="light"] .mbx-select option {
    background: #fff;
    color: #15171c;
}

#mbx-root .mbx-count {
    flex: 0 0 auto;
    font-size: 11px;
    color: var(--mbx-muted);
    font-variant-numeric: tabular-nums;
}

/* 曲目列表 */

#mbx-root .mbx-tracks {
    flex: 1 1 auto;
    min-height: 0;
    max-height: 232px;
    margin: 0;
    padding: 2px;
    list-style: none;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
}

#mbx-root .mbx-tracks::-webkit-scrollbar {
    width: 5px;
}

#mbx-root .mbx-tracks::-webkit-scrollbar-thumb {
    background: rgba(140, 148, 160, .35);
    border-radius: 99px;
}

#mbx-root .mbx-track {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 9px;
    cursor: pointer;
    transition: background .14s;
}

#mbx-root .mbx-track:hover {
    background: var(--mbx-bg-soft);
}

#mbx-root .mbx-track.is-on {
    background: rgba(236, 65, 65, .15);
}

#mbx-root .mbx-track.is-on .mbx-track-main b {
    color: var(--mbx-accent);
}

#mbx-root .mbx-track-no {
    flex: 0 0 auto;
    width: 16px;
    font-size: 10.5px;
    text-align: center;
    color: var(--mbx-muted);
    font-variant-numeric: tabular-nums;
}

#mbx-root .mbx-track.is-on .mbx-track-no {
    color: var(--mbx-accent);
}

#mbx-root .mbx-track-main {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

#mbx-root .mbx-track-main b {
    font-size: 12.5px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#mbx-root .mbx-track-main em {
    font-size: 11px;
    font-style: normal;
    color: var(--mbx-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#mbx-root .mbx-track-time {
    flex: 0 0 auto;
    font-size: 10.5px;
    color: var(--mbx-muted);
    font-variant-numeric: tabular-nums;
}

#mbx-root .mbx-empty {
    padding: 22px 8px;
    text-align: center;
    font-size: 12px;
    color: var(--mbx-muted);
    cursor: default;
}

/* ---------------- 移动端 ---------------- */

@media (max-width: 640px) {
    #mbx-root.mbx-player {
        right: 14px;
        bottom: 14px;
    }

    #mbx-root.mbx-player[data-pos="bl"] {
        left: 14px;
    }

    #mbx-root .mbx-panel {
        width: calc(100vw - 28px);
        max-width: 380px;
        max-height: min(70vh, 520px);
        border-radius: 18px;
    }

    #mbx-root .mbx-tracks {
        max-height: 180px;
    }

    #mbx-root .mbx-vol {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    #mbx-root.is-playing .mbx-disc-art {
        animation: none;
    }

    #mbx-root .mbx-panel {
        animation: none;
    }
}
