/* ─── 变量 ────────────────────────────────────────── */
:root {
  --accent: #c8a97e;
  --accent-rgb: 200, 169, 126;
  --text: rgba(255, 255, 255, 0.87);
  --text-dim: rgba(255, 255, 255, 0.45);
  --text-faint: rgba(255, 255, 255, 0.25);
  --surface: rgba(255, 255, 255, 0.05);
  --tr: 0.25s ease;
}

/* ─── Reset ──────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  height: 100%;
  overflow: hidden;
  background: #0d0d0d;
  color: var(--text);
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ─── 背景层 ─────────────────────────────────────── */
.bg-layer {
  position: fixed;
  inset: -30px;
  background-size: cover;
  background-position: center;
  filter: blur(60px) brightness(0.28) saturate(1.1);
  transition: opacity 1.4s ease;
  will-change: opacity;
}

#bg-a {
  z-index: 0;
  opacity: 1;
}
#bg-b {
  z-index: 1;
  opacity: 0;
}

/* ─── 应用容器 ───────────────────────────────────── */
#app {
  position: fixed;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
}

/* ─── 顶栏 ───────────────────────────────────────── */
#top-bar {
  flex-shrink: 0;
  padding: 18px 28px 0;
  z-index: 10;
  position: relative;
}

.brand {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
}

#welcome-toast {
  position: absolute;
  right: 28px;
  top: 18px;
  font-size: 12px;
  font-weight: 300;
  color: var(--text-dim);
  letter-spacing: 0.03em;
  opacity: 0;
  transform: translateY(-6px);
  transition:
    opacity 0.6s ease,
    transform 0.6s ease;
  pointer-events: none;
  max-width: 60%;
  text-align: right;
  line-height: 1.5;
}

#welcome-toast.show {
  opacity: 1;
  transform: translateY(0);
}

#welcome-toast .visitor-ip {
  color: var(--accent);
  font-weight: 400;
}

#welcome-toast .visitor-num {
  color: var(--accent);
  font-weight: 500;
}

@media (max-width: 480px) {
  #welcome-toast {
    position: relative;
    right: auto;
    top: auto;
    max-width: 100%;
    text-align: left;
    margin-top: 8px;
    font-size: 11px;
  }
}

/* ─── 主布局 ─────────────────────────────────────── */
#main {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 340px;
  min-height: 0;
  position: relative;
}

/* ─── 播放器区域 ─────────────────────────────────── */
#player-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px 32px 32px;
  position: relative;
  overflow: hidden;
}

/* ─── 唱片封面 ───────────────────────────────────── */
#cover-wrap {
  position: relative;
  width: min(280px, 48vmin);
  height: min(280px, 48vmin);
  flex-shrink: 0;
}

#cover-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
  box-shadow:
    0 0 0 3px rgba(255, 255, 255, 0.06),
    0 20px 60px rgba(0, 0, 0, 0.5);
  transition: opacity 0.4s ease;
}

/* 唱片中心点 */
#cover-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 14%;
  height: 14%;
  border-radius: 50%;
  background: radial-gradient(circle, #2a2a2a 0%, #1a1a1a 100%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  z-index: 2;
  pointer-events: none;
}

/* 旋转：只旋转封面图，中心点保持静止 */
#cover-wrap.spinning #cover-img {
  animation: spin 20s linear infinite;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* 封面切换渐隐渐显 */
#cover-img.fade-out {
  opacity: 0;
}
#cover-img.fade-in {
  opacity: 1;
}

/* ─── 曲目信息 ───────────────────────────────────── */
#track-info {
  margin-top: 28px;
  text-align: center;
  width: 100%;
  max-width: 360px;
  padding: 0 8px;
}

#song-title {
  font-size: clamp(16px, 2.8vw, 22px);
  font-weight: 500;
  color: var(--text);
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#song-title.scroll-text {
  animation: scroll-title 9s linear infinite;
  white-space: nowrap;
  overflow: visible;
  text-overflow: clip;
}

@keyframes scroll-title {
  0%,
  15% {
    transform: translateX(0);
  }
  85%,
  100% {
    transform: translateX(calc(-100% + 280px));
  }
}

#song-artist {
  margin-top: 6px;
  font-size: clamp(12px, 1.8vw, 14px);
  font-weight: 300;
  color: var(--text-dim);
  letter-spacing: 0.04em;
}

/* ─── 进度条 ─────────────────────────────────────── */
#progress-wrap {
  width: 100%;
  max-width: 360px;
  margin-top: 28px;
  cursor: pointer;
}

#progress-bar {
  height: 3px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  position: relative;
  transition: height var(--tr);
}

#progress-wrap:hover #progress-bar {
  height: 5px;
}

#progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.1s linear;
  pointer-events: none;
}

#progress-thumb {
  position: absolute;
  top: 50%;
  left: 0%;
  transform: translate(-50%, -50%) scale(0);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fff;
  transition:
    transform var(--tr),
    left 0.1s linear;
  pointer-events: none;
}

#progress-wrap:hover #progress-thumb {
  transform: translate(-50%, -50%) scale(1);
}

#time-display {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.03em;
}

/* ─── 控制按钮 ───────────────────────────────────── */
#controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 22px;
}

.ctrl-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  opacity: 0.75;
  transition: opacity var(--tr);
  flex-shrink: 0;
}

.ctrl-btn svg {
  width: 18px;
  height: 18px;
  pointer-events: none;
}

.ctrl-btn:hover {
  opacity: 1;
}

.ctrl-btn:active {
  opacity: 0.5;
}

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

/* 播放按钮 */
.play-btn {
  width: 48px !important;
  height: 48px !important;
  background: rgba(255, 255, 255, 0.08) !important;
  opacity: 1 !important;
}

.play-btn svg {
  width: 20px !important;
  height: 20px !important;
}

.play-btn:hover {
  background: rgba(255, 255, 255, 0.12) !important;
}

/* ─── 音量弹窗 ───────────────────────────────────── */
#volume-popup {
  position: absolute;
  bottom: 120px;
  right: 40px;
  width: 36px;
  padding: 14px 0 10px;
  background: rgba(18, 18, 18, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  z-index: 20;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  animation: vol-in 0.18s ease both;
}

#volume-popup.open {
  display: flex;
}

@keyframes vol-in {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

#volume-track {
  height: 90px;
  width: 3px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  position: relative;
  cursor: pointer;
}

#volume-fill {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 80%;
  background: var(--accent);
  border-radius: 3px;
  transition: height 0.1s;
}

#volume-thumb {
  position: absolute;
  left: 50%;
  transform: translate(-50%, 50%);
  bottom: 80%;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #fff;
  transition: bottom 0.1s;
  cursor: grab;
}

#volume-pct {
  font-size: 10px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

/* ─── 歌单区域 ───────────────────────────────────── */
#playlist-section {
  display: flex;
  flex-direction: column;
  border-left: 1px solid rgba(255, 255, 255, 0.05);
  background: rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  min-height: 0;
  overflow: hidden;
}

#playlist-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 20px 20px 14px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  flex-shrink: 0;
  cursor: pointer;
  user-select: none;
}

#song-count {
  margin-left: auto;
  font-weight: 400;
}

#playlist-toggle-icon {
  font-size: 14px;
  color: var(--text-faint);
  transition: transform var(--tr);
  display: none; /* 桌面隐藏，手机显示 */
}

#playlist-list {
  flex: 1;
  overflow-y: auto;
  list-style: none;
  padding: 0 0 20px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

#playlist-list::-webkit-scrollbar {
  width: 3px;
}
#playlist-list::-webkit-scrollbar-track {
  background: transparent;
}
#playlist-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}

#playlist-list li {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 0 20px;
  height: 56px;
  cursor: pointer;
  border-left: 2px solid transparent;
  transition:
    background var(--tr),
    border-color var(--tr);
}

#playlist-list li:hover {
  background: rgba(255, 255, 255, 0.04);
}

#playlist-list li.active {
  border-left-color: var(--accent);
}

.li-num {
  font-size: 12px;
  color: var(--text-faint);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

li.active .li-num {
  color: var(--accent);
}

.li-num .playing-icon {
  display: none;
}
li.active .li-num .num-text {
  display: none;
}
li.active .li-num .playing-icon {
  display: block;
}

@keyframes playing-bounce {
  0%,
  100% {
    transform: scaleY(0.4);
  }
  50% {
    transform: scaleY(1);
  }
}

.li-info {
  overflow: hidden;
}

.li-title {
  font-size: 13px;
  font-weight: 400;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

li.active .li-title {
  color: var(--accent);
  font-weight: 500;
}

.li-artist {
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.li-dur {
  font-size: 11px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ─── 限额 Banner ────────────────────────────────── */
#quota-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  padding: 10px 20px;
  text-align: center;
  font-size: 13px;
  font-weight: 400;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: none;
  animation: banner-in 0.3s ease both;
}

/* ─── Autoplay 提示 ─────────────────────────────── */
#autoplay-hint {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  font-size: 13px;
  font-weight: 300;
  color: var(--text-dim);
  letter-spacing: 0.06em;
  padding: 10px 24px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  opacity: 0;
  transition:
    opacity 0.5s ease,
    transform 0.5s ease;
  z-index: 50;
  cursor: pointer;
  white-space: nowrap;
}

#autoplay-hint.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@keyframes hint-pulse {
  0%,
  100% {
    opacity: 0.7;
  }
  50% {
    opacity: 1;
  }
}

#autoplay-hint.show {
  animation: hint-pulse 2.5s ease-in-out infinite;
}

#quota-banner.warning {
  display: block;
  background: rgba(200, 140, 20, 0.12);
  border-top: 1px solid rgba(200, 140, 20, 0.25);
  color: #c8960a;
}

#quota-banner.halt {
  display: block;
  background: rgba(180, 50, 50, 0.15);
  border-top: 1px solid rgba(180, 50, 50, 0.3);
  color: #c05050;
}

@keyframes banner-in {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* ─── Screensaver ────────────────────────────────── */
#player-section,
#playlist-section {
  transition: opacity 0.8s ease;
}

body.idle #controls,
body.idle #progress-wrap,
body.idle #track-info,
body.idle #playlist-section {
  opacity: 0;
  pointer-events: none;
}

#controls,
#progress-wrap,
#track-info,
#playlist-section {
  transition: opacity 0.8s ease;
}

/* ─── 响应式：平板竖屏 ───────────────────────────── */
@media (max-width: 768px) {
  #main {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
    overflow: hidden;
  }

  #player-section {
    padding: 20px 20px 16px;
  }

  #cover-wrap {
    width: min(220px, 52vmin);
    height: min(220px, 52vmin);
  }

  #playlist-section {
    border-left: none;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    max-height: 42vh;
    flex-shrink: 0;
  }
}

/* ─── 响应式：手机 ───────────────────────────────── */
@media (max-width: 480px) {
  #top-bar {
    padding: 14px 20px 0;
  }

  #main {
    grid-template-rows: 1fr;
    grid-template-columns: 1fr;
    overflow: visible;
  }

  #player-section {
    padding: 16px 16px 12px;
    justify-content: flex-start;
    padding-top: 12px;
    overflow: visible;
  }

  #cover-wrap {
    width: min(190px, 54vw);
    height: min(190px, 54vw);
    margin-top: 8px;
  }

  #track-info {
    margin-top: 20px;
  }

  #song-title {
    font-size: 16px;
  }

  #song-artist {
    font-size: 12px;
  }

  #progress-wrap {
    margin-top: 20px;
  }

  #controls {
    gap: 10px;
    margin-top: 18px;
  }

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

  .play-btn {
    width: 44px !important;
    height: 44px !important;
  }
  .play-btn svg {
    width: 18px !important;
    height: 18px !important;
  }

  /* 手机歌单：底部抽屉 */
  #playlist-section {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 78vh;
    border-radius: 16px 16px 0 0;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    border-left: none;
    transform: translateY(calc(100% - 130px));
    transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 10;
    background: rgba(10, 10, 10, 0.92);
  }

  #playlist-section.expanded {
    transform: translateY(0);
  }

  #playlist-toggle-icon {
    display: block;
  }

  #playlist-header {
    position: relative;
    padding-top: 22px;
  }

  #playlist-header::before {
    content: "";
    position: absolute;
    top: 9px;
    left: 50%;
    transform: translateX(-50%);
    width: 32px;
    height: 3px;
    background: rgba(255, 255, 255, 0.18);
    border-radius: 2px;
  }

  #volume-popup {
    right: 16px;
    bottom: 150px;
  }

  #playlist-list {
    max-height: calc(78vh - 130px);
  }

  body.idle #playlist-section {
    opacity: 0.06;
    pointer-events: none;
  }
}
