/* ========== Reset & Base ========== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --primary: #ff2d55;
  --primary-light: #ff6b8a;
  --primary-dark: #d4234a;
  --bg: #0a0a1a;
  --bg-card: #161630;
  --bg-card-hover: #1e1e42;
  --text: #ffffff;
  --text-secondary: #8888aa;
  --text-muted: #555570;
  --border: #2a2a50;
  --gradient-1: linear-gradient(135deg, #ff2d55, #6a1b9a);
  --gradient-2: linear-gradient(135deg, #ff6b8a, #9c27b0);
  --disc-size: min(260px, 65vw);
  --mini-height: 64px;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  overscroll-behavior: none;
  touch-action: none;
  position: fixed;
  top: 0;
  left: 0;
}

body {
  position: relative;
}

/* ========== Page Switching ========== */
.page {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.4s ease;
  will-change: transform, opacity;
  overscroll-behavior: none;
}

.page:not(.active) {
  transform: translateX(100%);
  opacity: 0;
  pointer-events: none;
}

.page.active {
  transform: translateX(0);
  opacity: 1;
  pointer-events: auto;
}

.hidden {
  display: none !important;
}

/* ========== Home Page ========== */
.home-header {
  padding: 50px 24px 16px;
  background: var(--gradient-1);
  position: relative;
}

.home-header h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 1px;
}

.home-header .subtitle {
  margin-top: 4px;
  font-size: 14px;
  opacity: 0.8;
}

.search-bar {
  padding: 12px 20px;
  background: rgba(22, 22, 48, 0.8);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.search-bar input {
  width: 100%;
  height: 40px;
  border: none;
  border-radius: 20px;
  background: var(--bg);
  color: var(--text);
  padding: 0 16px;
  font-size: 14px;
  outline: none;
}

.search-bar input::placeholder {
  color: var(--text-muted);
}

.song-list {
  list-style: none;
  padding: 8px 16px;
  padding-bottom: calc(var(--mini-height) + 24px);
}

.song-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.2s;
  margin-bottom: 4px;
}

.song-item:active {
  background: var(--bg-card-hover);
}

.song-item.active {
  background: var(--bg-card);
}

.song-item-index {
  width: 32px;
  font-size: 14px;
  color: var(--text-muted);
  text-align: center;
  flex-shrink: 0;
}

.song-item.active .song-item-index {
  color: var(--primary);
}

.song-item-info {
  flex: 1;
  min-width: 0;
  margin-left: 8px;
}

.song-item-title {
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.song-item.active .song-item-title {
  color: var(--primary);
}

.song-item-artist {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.song-item-playing {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.song-item.active .song-item-playing .equalizer {
  display: flex;
}

.equalizer {
  display: none;
  gap: 2px;
  align-items: flex-end;
  height: 14px;
}

.equalizer span {
  display: block;
  width: 3px;
  background: var(--primary);
  border-radius: 1px;
  animation: equalizer 0.8s ease-in-out infinite alternate;
}

.equalizer span:nth-child(1) { height: 6px; animation-delay: 0s; }
.equalizer span:nth-child(2) { height: 10px; animation-delay: 0.2s; }
.equalizer span:nth-child(3) { height: 4px; animation-delay: 0.4s; }
.equalizer span:nth-child(4) { height: 12px; animation-delay: 0.1s; }

@keyframes equalizer {
  0% { height: 4px; }
  100% { height: 14px; }
}

/* ========== Mini Player ========== */
.mini-player {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--mini-height);
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px 0 16px;
  z-index: 100;
  cursor: pointer;
}

.mini-player-left {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
}

.mini-disc {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, #1a1a2e, #333, #1a1a2e);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  animation: disc-spin 4s linear infinite;
  animation-play-state: paused;
}

.mini-disc.spinning {
  animation-play-state: running;
}

.mini-disc-inner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary);
}

.mini-info {
  margin-left: 12px;
  min-width: 0;
}

.mini-title {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mini-artist {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.mini-player-right {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.btn-play-mini, .btn-next-mini {
  width: 40px;
  height: 40px;
  border: none;
  background: none;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.2s;
}

.btn-play-mini:active, .btn-next-mini:active {
  background: rgba(255, 255, 255, 0.1);
}

.btn-play-mini svg, .btn-next-mini svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

/* ========== Player Page ========== */
.player-bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--gradient-1);
  filter: blur(60px) brightness(0.4);
  transform: scale(1.5);
  z-index: 0;
  transition: background 0.8s ease;
}

.player-container {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 0 24px;
}

.player-header {
  display: flex;
  align-items: center;
  padding-top: 48px;
  padding-bottom: 16px;
}

.btn-back, .btn-playlist {
  width: 44px;
  height: 44px;
  border: none;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.2s;
  flex-shrink: 0;
}

.btn-back:active, .btn-playlist:active {
  background: rgba(255, 255, 255, 0.2);
}

.btn-back svg, .btn-playlist svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.player-header-info {
  flex: 1;
  text-align: center;
  padding: 0 12px;
  min-width: 0;
}

.player-header-title {
  font-size: 13px;
  opacity: 0.7;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-header-artist {
  font-size: 12px;
  opacity: 0.5;
  margin-top: 2px;
}

/* ========== Disc ========== */
.player-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 0;
}

.disc-wrapper {
  position: relative;
  width: var(--disc-size);
  height: var(--disc-size);
}

.disc {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: conic-gradient(
    from 0deg,
    #111 0deg, #222 30deg,
    #111 60deg, #1a1a2e 90deg,
    #111 120deg, #222 150deg,
    #111 180deg, #1a1a2e 210deg,
    #111 240deg, #222 270deg,
    #111 300deg, #1a1a2e 330deg,
    #111 360deg
  );
  position: relative;
  box-shadow:
    0 0 0 8px rgba(0, 0, 0, 0.3),
    0 0 40px rgba(0, 0, 0, 0.5),
    inset 0 0 20px rgba(0, 0, 0, 0.5);
  animation: disc-spin 8s linear infinite;
  animation-play-state: paused;
}

.disc.spinning {
  animation-play-state: running;
}

.disc-cover {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 52%;
  height: 52%;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid rgba(255, 255, 255, 0.1);
}

.disc-cover-inner {
  width: 100%;
  height: 100%;
  background: var(--gradient-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
}

.disc-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.05);
  transform: translate(-50%, -50%);
}

.disc-ring-1 { width: 60%; height: 60%; }
.disc-ring-2 { width: 72%; height: 72%; }
.disc-ring-3 { width: 84%; height: 84%; }

.disc-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.5);
}

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

/* ========== Song Info ========== */
.player-info {
  text-align: center;
  padding: 0 16px;
}

.song-title {
  font-size: 20px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.song-artist {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ========== Progress ========== */
.progress-section {
  padding: 24px 0 8px;
}

.progress-bar {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 2px;
  cursor: pointer;
  position: relative;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
  width: 0%;
  position: relative;
  transition: width 0.1s linear;
}

.progress-thumb {
  position: absolute;
  top: 50%;
  left: 0%;
  transform: translate(-50%, -50%);
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 8px rgba(255, 45, 85, 0.5);
  transition: left 0.1s linear;
}

.time-info {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-secondary);
}

/* ========== Controls ========== */
.controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 16px 0 48px;
}

.ctrl-btn {
  width: 48px;
  height: 48px;
  border: none;
  background: none;
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s;
}

.ctrl-btn:active {
  background: rgba(255, 255, 255, 0.1);
  transform: scale(0.9);
}

.ctrl-btn.active {
  color: var(--primary);
}

.ctrl-btn svg {
  width: 26px;
  height: 26px;
  fill: currentColor;
}

.ctrl-btn-play {
  width: 64px;
  height: 64px;
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 20px rgba(255, 45, 85, 0.4);
}

.ctrl-btn-play svg {
  width: 30px;
  height: 30px;
}

.ctrl-btn-play:active {
  background: var(--primary-dark);
  transform: scale(0.92);
}

.icon-play-main {
  margin-left: 3px;
}

.icon-mode, .icon-shuffle, .icon-prev, .icon-next, .icon-back, .icon-list {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-mode, .icon-shuffle {
  width: 22px;
  height: 22px;
}

/* ========== Playlist Panel ========== */
.playlist-panel {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 50;
}

.playlist-panel.hidden {
  display: none;
}

.playlist-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
}

.playlist-content {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  max-height: 60%;
  background: var(--bg-card);
  border-radius: 16px 16px 0 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: slide-up 0.3s ease;
}

@keyframes slide-up {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.playlist-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.playlist-header h3 {
  font-size: 16px;
  font-weight: 600;
}

.playlist-header button {
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.playlist-list {
  list-style: none;
  overflow-y: auto;
  padding: 8px 0;
}

.playlist-item {
  display: flex;
  align-items: center;
  padding: 12px 20px;
  cursor: pointer;
  transition: background 0.2s;
}

.playlist-item:active {
  background: var(--bg-card-hover);
}

.playlist-item.active {
  color: var(--primary);
}

.playlist-item-title {
  flex: 1;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.playlist-item.active .playlist-item-title {
  color: var(--primary);
}

.playlist-item-index {
  width: 28px;
  font-size: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.playlist-item.active .playlist-item-index {
  color: var(--primary);
}

/* ========== Scrollbar ========== */
::-webkit-scrollbar {
  width: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
}

/* ========== Safe Area ========== */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .mini-player {
    padding-bottom: env(safe-area-inset-bottom);
  }
  .controls {
    padding-bottom: calc(48px + env(safe-area-inset-bottom));
  }
}

/* ========== Empty State ========== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state p {
  font-size: 16px;
}

/* ========== Disc Cover Colors ========== */
.disc-cover-inner.color-0 { background: linear-gradient(135deg, #ff2d55, #6a1b9a); }
.disc-cover-inner.color-1 { background: linear-gradient(135deg, #ff6b35, #f7c948); }
.disc-cover-inner.color-2 { background: linear-gradient(135deg, #00b894, #006266); }
.disc-cover-inner.color-3 { background: linear-gradient(135deg, #0984e3, #6c5ce7); }
.disc-cover-inner.color-4 { background: linear-gradient(135deg, #fd79a8, #6c5ce7); }
.disc-cover-inner.color-5 { background: linear-gradient(135deg, #e17055, #d63031); }
.disc-cover-inner.color-6 { background: linear-gradient(135deg, #00cec9, #0984e3); }
.disc-cover-inner.color-7 { background: linear-gradient(135deg, #a29bfe, #6c5ce7); }
.disc-cover-inner.color-8 { background: linear-gradient(135deg, #fdcb6e, #e17055); }
.disc-cover-inner.color-9 { background: linear-gradient(135deg, #55efc4, #00b894); }
.disc-cover-inner.color-10 { background: linear-gradient(135deg, #fab1a0, #e17055); }
