:root {
  --yb-player-h: 96px;
  --yb-lyrics-h: min(48vh, 360px);
}

body.has-global-player {
  padding-bottom: calc(var(--yb-player-h) + 20px) !important;
}

body.has-global-player.lyrics-open {
  padding-bottom: calc(var(--yb-player-h) + var(--yb-lyrics-h) + 12px) !important;
}

#yuebox-global-player {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9990;
  height: var(--yb-player-h);
  display: grid;
  grid-template-columns: minmax(140px, 1.1fr) auto minmax(200px, 1.4fr) minmax(160px, 0.95fr);
  grid-template-areas: "now controls progress extras";
  align-items: center;
  gap: 0.55rem 0.75rem;
  padding: 0 1rem;
  background: rgba(24, 24, 24, 0.97);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(16px);
  color: #f5f5f5;
  font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
}

#yuebox-global-player .now { grid-area: now; }
#yuebox-global-player .controls { grid-area: controls; }
#yuebox-global-player .progress { grid-area: progress; }
#yuebox-global-player .extras { grid-area: extras; }

#yuebox-global-player .now {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
  cursor: pointer;
}

#yuebox-global-player .now-art {
  width: 46px;
  height: 46px;
  border-radius: 10px;
  flex-shrink: 0;
  background: linear-gradient(145deg, rgba(225, 29, 72, 0.5), #1a1a1a);
}

#yuebox-global-player .now-meta { min-width: 0; }

#yuebox-global-player .now-title {
  font-weight: 600;
  font-size: 0.94rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#yuebox-global-player .now-sub {
  margin-top: 0.1rem;
  color: #a7a7a7;
  font-size: 0.76rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#yuebox-global-player .controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
}

#yuebox-global-player .ctrl {
  width: 2.2rem;
  height: 2.2rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

#yuebox-global-player .ctrl:hover {
  background: rgba(255, 255, 255, 0.08);
}

#yuebox-global-player .ctrl-main {
  width: 2.55rem;
  height: 2.55rem;
  background: #fff;
  color: #111;
}

#yuebox-global-player .ctrl-main .icon-play,
#yuebox-global-player .ctrl-main .icon-pause {
  display: block;
  pointer-events: none;
}

#yuebox-global-player .ctrl-main .icon-pause { display: none; }
#yuebox-global-player .ctrl-main.is-playing .icon-play { display: none; }
#yuebox-global-player .ctrl-main.is-playing .icon-pause { display: block; }

#yuebox-global-player .progress {
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.45rem;
  align-items: center;
  color: #a7a7a7;
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
}

#yuebox-global-player .progress input[type="range"],
#yuebox-global-player .vol input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    #e11d48 0 var(--seek-pct, 0%),
    #3a3a3a var(--seek-pct, 0%) 100%
  );
  outline: none;
  cursor: pointer;
}

#yuebox-global-player .progress input[type="range"]::-webkit-slider-thumb,
#yuebox-global-player .vol input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #e11d48;
  border: 0;
}

#yuebox-global-player .extras {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
}

#yuebox-global-player .vol {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  width: min(100%, 110px);
  color: #a7a7a7;
  flex: 1 1 auto;
  max-width: 140px;
}

#yuebox-global-player .tool-btn {
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: transparent;
  color: #f5f5f5;
  border-radius: 999px;
  padding: 0.3rem 0.65rem;
  font-size: 0.74rem;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

#yuebox-global-player .tool-btn:hover,
#yuebox-global-player .tool-btn.is-active {
  border-color: rgba(225, 29, 72, 0.55);
  color: #fda4af;
}

#yuebox-global-audio {
  display: none !important;
}

#yuebox-player-toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--yb-player-h) + 18px);
  transform: translateX(-50%);
  z-index: 10000;
  max-width: min(92vw, 420px);
  padding: 0.65rem 0.95rem;
  border-radius: 12px;
  background: rgba(28, 28, 28, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #f5f5f5;
  font-size: 0.84rem;
  line-height: 1.45;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

#yuebox-player-toast[hidden] {
  display: none !important;
}

body.has-global-player.lyrics-open #yuebox-player-toast {
  bottom: calc(var(--yb-player-h) + var(--yb-lyrics-h) + 14px);
}

/* 歌词抽屉 */
#yuebox-lyrics-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: var(--yb-player-h);
  z-index: 9985;
  height: var(--yb-lyrics-h);
  display: flex;
  flex-direction: column;
  background: rgba(18, 18, 18, 0.98);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(16px);
  color: #f5f5f5;
  font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
}

#yuebox-lyrics-sheet[hidden] {
  display: none !important;
}

#yuebox-lyrics-sheet .ly-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

#yuebox-lyrics-sheet .ly-head-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

#yuebox-lyrics-sheet .ly-head-text strong {
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#yuebox-lyrics-sheet .ly-head-text span {
  color: #a7a7a7;
  font-size: 0.78rem;
}

#yuebox-lyrics-sheet .ly-close {
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: transparent;
  color: #f5f5f5;
  border-radius: 999px;
  padding: 0.3rem 0.75rem;
  cursor: pointer;
  flex-shrink: 0;
}

#yuebox-lyrics-sheet .ly-body {
  flex: 1;
  overflow: auto;
  padding: 1rem 1.1rem 1.4rem;
  scroll-behavior: smooth;
}

#yuebox-lyrics-sheet .ly-placeholder {
  margin: 2.5rem 0 0;
  text-align: center;
  color: #7d7d7d;
}

#yuebox-lyrics-sheet .ly-line {
  margin: 0;
  padding: 0.45rem 0;
  text-align: center;
  color: #7a7a7a;
  font-size: 0.98rem;
  line-height: 1.55;
  transition: color 0.2s ease, transform 0.2s ease;
}

#yuebox-lyrics-sheet .ly-line.is-active {
  color: #fff;
  font-weight: 700;
  font-size: 1.12rem;
  transform: scale(1.02);
}

/* 平板 / 手机：三行，保留音量与歌词 */
@media (max-width: 920px) {
  :root {
    --yb-player-h: 128px;
    --yb-lyrics-h: min(42vh, 320px);
  }

  body.has-global-player {
    padding-bottom: calc(var(--yb-player-h) + env(safe-area-inset-bottom, 0px) + 10px) !important;
  }

  body.has-global-player.lyrics-open {
    padding-bottom: calc(var(--yb-player-h) + var(--yb-lyrics-h) + env(safe-area-inset-bottom, 0px) + 8px) !important;
  }

  #yuebox-global-player {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "now controls"
      "progress progress"
      "extras extras";
    height: auto;
    min-height: var(--yb-player-h);
    padding: 0.5rem 0.75rem calc(0.5rem + env(safe-area-inset-bottom, 0px));
    gap: 0.35rem 0.45rem;
  }

  #yuebox-global-player .extras {
    justify-content: space-between;
  }

  #yuebox-global-player .vol {
    max-width: none;
    flex: 1 1 auto;
    width: auto;
    min-width: 90px;
  }

  #yuebox-global-player .popout {
    display: none;
  }

  #yuebox-global-player .now-art {
    width: 40px;
    height: 40px;
  }

  #yuebox-lyrics-sheet {
    bottom: calc(var(--yb-player-h) + env(safe-area-inset-bottom, 0px) - 8px);
  }
}

@media (max-width: 560px) {
  :root {
    --yb-player-h: 132px;
  }

  #yuebox-global-player .tool-btn {
    padding: 0.28rem 0.58rem;
    font-size: 0.72rem;
  }

  #yuebox-global-player .ctrl {
    width: 2.05rem;
    height: 2.05rem;
  }

  #yuebox-global-player .ctrl-main {
    width: 2.4rem;
    height: 2.4rem;
  }
}
