/* =========================================================
   全局音乐播放器（悬浮胶囊 + 展开面板）
   颜色全部基于主题 CSS 变量，自动适配明/暗模式
   ========================================================= */

.music-player {
  --mp-bg: color-mix(in srgb, var(--board-bg-color, #fff) 88%, transparent);
  --mp-bg-panel: color-mix(in srgb, var(--board-bg-color, #fff) 97%, transparent);
  --mp-border: color-mix(in srgb, var(--line-color, #eaecef) 80%, transparent);
  --mp-shadow: 0 12px 32px rgba(0, 0, 0, .16), 0 2px 8px rgba(0, 0, 0, .06);
  --mp-accent: var(--link-hover-color, #30a9de);
  --mp-text: var(--text-color, #3c4858);
  --mp-sec-text: var(--sec-text-color, #718096);
  --mp-hover-bg: color-mix(in srgb, var(--button-hover-bg-color, #f2f3f5) 70%, transparent);
  --mp-line: var(--line-color, #eaecef);

  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 1080;
  font-size: 14px;
  line-height: 1.4;
  color: var(--mp-text);
  -webkit-user-select: none;
  user-select: none;
}

/* ---------- 通用按钮 ---------- */
.mp-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--mp-text);
  cursor: pointer;
  transition: background-color .2s ease, color .2s ease, transform .15s ease;
  flex-shrink: 0;
}
.mp-btn svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
  display: block;
}
.mp-btn:hover {
  background: var(--mp-hover-bg);
  color: var(--mp-accent);
}
.mp-btn:active {
  transform: scale(.92);
}
.mp-btn:focus-visible {
  outline: 2px solid var(--mp-accent);
  outline-offset: 1px;
}
.mp-btn.mp-btn-active {
  color: var(--mp-accent);
}

/* ---------- 悬浮胶囊 ---------- */
.mp-capsule {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: min(320px, calc(100vw - 32px));
  padding: 6px;
  border-radius: 999px;
  background: var(--mp-bg);
  border: 1px solid var(--mp-border);
  box-shadow: var(--mp-shadow);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  cursor: grab;
  touch-action: none;
  transition: box-shadow .3s ease;
}
.mp-capsule:hover {
  box-shadow: 0 14px 36px rgba(0, 0, 0, .2), 0 2px 8px rgba(0, 0, 0, .08);
}
.music-player.mp-dragging .mp-capsule {
  cursor: grabbing;
  box-shadow: 0 18px 42px rgba(0, 0, 0, .28);
}
.music-player.mp-dragging .mp-btn,
.music-player.mp-dragging .mp-capsule-info {
  pointer-events: none;
}

.mp-cover,
.mp-pl-cover {
  object-fit: cover;
  border-radius: 50%;
  flex-shrink: 0;
  display: block;
}
.mp-cover {
  width: 42px;
  height: 42px;
  border: 1px solid var(--mp-border);
  background: var(--mp-hover-bg);
}
.mp-capsule-info {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 2px;
}
.mp-song-scroll {
  overflow: hidden;
}
.mp-song-scroll .mp-song-text {
  display: inline-block;
  white-space: nowrap;
  max-width: 100%;
}
.mp-song-scroll.mp-marquee .mp-song-text {
  animation: mp-marquee var(--mp-marq-dur, 8s) linear infinite alternate;
}
.mp-song-scroll.mp-marquee:hover .mp-song-text {
  animation-play-state: paused;
}
@keyframes mp-marquee {
  from { transform: translateX(0); }
  to   { transform: translateX(var(--mp-marq-dist, -30px)); }
}
.mp-song-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--mp-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mp-song-artist {
  font-size: 11px;
  color: var(--mp-sec-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mp-capsule .mp-cover-wrap {
  position: relative;
  flex-shrink: 0;
}
/* 播放时封面旋转（唱片效果） */
.mp-cover-wrap.mp-spin .mp-cover {
  animation: mp-spin 12s linear infinite;
}
@keyframes mp-spin {
  to { transform: rotate(360deg); }
}
.mp-cover-wrap.mp-spin::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--mp-bg-panel);
  border: 1px solid var(--mp-border);
  pointer-events: none;
}

.mp-capsule-play {
  color: #fff;
  background: var(--mp-accent);
}
.mp-capsule-play:hover {
  color: #fff;
  background: var(--mp-accent);
  opacity: .9;
}

/* ---------- 展开面板 ---------- */
.mp-panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  width: 360px;
  max-width: calc(100vw - 32px);
  border-radius: 16px;
  background: var(--mp-bg-panel);
  border: 1px solid var(--mp-border);
  box-shadow: var(--mp-shadow);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity .25s ease, transform .25s ease, visibility .25s;
}
.music-player.mp-open .mp-panel {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.music-player.mp-panel-below .mp-panel {
  bottom: auto;
  top: calc(100% + 8px);
  transform: translateY(-8px);
}
.music-player.mp-panel-below.mp-open .mp-panel {
  transform: translateY(0);
}

.mp-panel-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px 10px;
}
.mp-panel-cover {
  width: 64px;
  height: 64px;
  border-radius: 12px;
  object-fit: cover;
  border: 1px solid var(--mp-border);
  background: var(--mp-hover-bg);
  flex-shrink: 0;
}
.mp-panel-info {
  min-width: 0;
  flex: 1;
}
.mp-panel-title {
  font-size: 15px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mp-panel-artist {
  margin-top: 2px;
  font-size: 12px;
  color: var(--mp-sec-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- 进度条 ---------- */
.mp-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 16px 6px;
}
.mp-progress-time {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--mp-sec-text);
  min-width: 34px;
  text-align: center;
  flex-shrink: 0;
}
.mp-progress-time.mp-time-total {
  text-align: left;
}
.mp-progress-bar {
  position: relative;
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: var(--mp-line);
  cursor: pointer;
  transition: height .15s ease;
}
.mp-progress-bar:hover {
  height: 8px;
}
.mp-progress-fill {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--mp-accent);
  pointer-events: none;
}
.mp-progress-thumb {
  position: absolute;
  top: 50%;
  left: 0;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--mp-accent);
  transform: translate(-50%, -50%);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .25);
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s ease;
}
.mp-progress-bar:hover .mp-progress-thumb {
  opacity: 1;
}

/* ---------- 控制区 ---------- */
.mp-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 4px 16px 10px;
  flex-wrap: wrap;
}
.mp-controls .mp-btn {
  width: 34px;
  height: 34px;
}
.mp-play-big {
  background: var(--mp-accent);
  color: #fff;
  box-shadow: 0 4px 12px color-mix(in srgb, var(--mp-accent) 40%, transparent);
}
.mp-play-big svg {
  width: 26px;
  height: 26px;
}
.mp-play-big:hover {
  color: #fff;
  background: var(--mp-accent);
  opacity: .92;
}
.mp-speed-btn {
  min-width: 44px;
  width: auto;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--mp-sec-text);
  border: 1px solid var(--mp-border);
}
.mp-speed-btn:hover {
  color: var(--mp-accent);
  border-color: var(--mp-accent);
}

/* ---------- 音量 ---------- */
.mp-volume-group {
  display: flex;
  align-items: center;
  gap: 4px;
}
.mp-volume-slider,
.mp-volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
}
.mp-volume-slider {
  width: 64px;
  height: 4px;
  border-radius: 999px;
  background: var(--mp-line);
  outline: none;
  cursor: pointer;
}
.mp-volume-slider::-webkit-slider-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--mp-accent);
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .25);
  cursor: pointer;
}
.mp-volume-slider::-moz-range-thumb {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--mp-accent);
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .25);
  cursor: pointer;
}
.mp-volume-slider::-moz-range-track {
  height: 4px;
  border-radius: 999px;
  background: var(--mp-line);
}

/* ---------- 播放列表 ---------- */
.mp-playlist {
  border-top: 1px solid var(--mp-line);
  max-height: 280px;
  display: flex;
  flex-direction: column;
  background: var(--mp-bg-panel);
}
.mp-playlist-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
}
.mp-playlist-count {
  color: var(--mp-sec-text);
  font-weight: 400;
  font-size: 12px;
  margin-left: 4px;
}
.mp-playlist-clear {
  font-size: 12px;
  font-weight: 400;
  color: var(--mp-sec-text);
  border-radius: 999px;
  padding: 2px 10px;
  height: auto;
  width: auto;
}
.mp-playlist-clear:hover {
  color: #e05555;
  background: color-mix(in srgb, #e05555 12%, transparent);
}
.mp-playlist-list {
  list-style: none;
  margin: 0;
  padding: 0 8px 10px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.mp-pl-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border-radius: 10px;
  cursor: pointer;
  transition: background-color .18s ease;
}
.mp-pl-item:hover {
  background: var(--mp-hover-bg);
}
.mp-pl-item.mp-active {
  background: color-mix(in srgb, var(--mp-accent) 12%, transparent);
}
.mp-pl-cover {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: var(--mp-hover-bg);
}
.mp-pl-indicator {
  width: 22px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--mp-accent);
}
.mp-tri-state {
  font-size: 12px;
  min-width: 22px;
  text-align: center;
}
.mp-pl-meta {
  min-width: 0;
  flex: 1;
}
.mp-pl-name {
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mp-pl-item.mp-active .mp-pl-name {
  color: var(--mp-accent);
  font-weight: 500;
}
.mp-pl-artist {
  font-size: 11px;
  color: var(--mp-sec-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mp-pl-del {
  width: 26px;
  height: 26px;
  opacity: 0;
  transition: opacity .15s ease;
}
.mp-pl-del svg {
  width: 15px;
  height: 15px;
}
.mp-pl-item:hover .mp-pl-del {
  opacity: 1;
}
.mp-pl-empty {
  padding: 18px 12px;
  text-align: center;
  color: var(--mp-sec-text);
  font-size: 12px;
}

/* 当前播放的均衡器指示动画 */
.mp-eq {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 14px;
}
.mp-eq.mp-paused span {
  animation-play-state: paused;
  height: 4px;
}
.mp-eq span {
  width: 3px;
  border-radius: 2px;
  background: var(--mp-accent);
  animation: mp-eq-bounce 1s ease-in-out infinite;
}
.mp-eq span:nth-child(1) { height: 60%; animation-delay: 0s; }
.mp-eq span:nth-child(2) { height: 100%; animation-delay: .2s; }
.mp-eq span:nth-child(3) { height: 40%; animation-delay: .4s; }
@keyframes mp-eq-bounce {
  0%, 100% { transform: scaleY(.5); }
  50% { transform: scaleY(1); }
}

/* 播放列表滚动条（贴合主题配色） */
.mp-playlist-list::-webkit-scrollbar {
  width: 6px;
}
.mp-playlist-list::-webkit-scrollbar-thumb {
  background: var(--scrollbar-color, #c4c6c9);
  border-radius: 999px;
}
.mp-playlist-list::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-hover-color, #a6a6a6);
}

/* ---------- 音频元素 ---------- */
.mp-audio {
  display: none;
}

/* ---------- 移动端适配 ---------- */
@media (max-width: 575px) {
  .music-player {
    right: 12px;
    bottom: 12px;
  }
  .mp-capsule {
    max-width: calc(100vw - 24px);
  }
  .mp-panel {
    width: calc(100vw - 24px);
    max-width: calc(100vw - 24px);
  }
  .mp-capsule .mp-song-artist {
    display: none;
  }
}