:root {
  color-scheme: dark;
  --bg: #1a1a1a;
  --panel: rgba(34, 34, 42, 0.72);
  --panel-strong: rgba(42, 42, 54, 0.92);
  --text: #f6f3ff;
  --muted: #a8a2b8;
  --line: rgba(255, 255, 255, 0.12);
  --accent-a: #667eea;
  --accent-b: #764ba2;
  --accent-c: #78dcca;
  --danger: #ff6b8b;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.32);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --player-height: 118px;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 16% 12%, rgba(102, 126, 234, 0.28), transparent 28rem),
    radial-gradient(circle at 86% 6%, rgba(120, 220, 202, 0.16), transparent 24rem),
    linear-gradient(140deg, #171717 0%, #1f1d28 52%, #15151b 100%);
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

.app-shell {
  min-height: 100vh;
  padding-bottom: calc(var(--player-height) + 24px);
}

.app-shell[data-theme="light"] {
  color-scheme: light;
  --bg: #f2f0f7;
  --panel: rgba(255, 255, 255, 0.72);
  --panel-strong: rgba(255, 255, 255, 0.92);
  --text: #17151f;
  --muted: #6f697c;
  --line: rgba(25, 20, 35, 0.12);
  --shadow: 0 24px 70px rgba(75, 62, 110, 0.18);
  background:
    radial-gradient(circle at 12% 18%, rgba(102, 126, 234, 0.18), transparent 28rem),
    radial-gradient(circle at 84% 10%, rgba(120, 220, 202, 0.16), transparent 24rem),
    #f2f0f7;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(190px, 260px) minmax(220px, 560px) auto;
  gap: 20px;
  align-items: center;
  padding: 18px clamp(16px, 4vw, 42px);
  border-bottom: 1px solid var(--line);
  background: rgba(20, 20, 24, 0.74);
  backdrop-filter: blur(22px);
}

[data-theme="light"] .topbar {
  background: rgba(245, 243, 250, 0.74);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent-a), var(--accent-b));
  box-shadow: 0 14px 36px rgba(102, 126, 234, 0.28);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
}

.brand strong,
.brand small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.search-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  transition: border-color 240ms var(--ease), background 240ms var(--ease), transform 240ms var(--ease);
}

.search-wrap:focus-within {
  border-color: rgba(102, 126, 234, 0.72);
  background: rgba(255, 255, 255, 0.12);
  transform: translateY(-1px);
}

.search-wrap svg {
  width: 19px;
  height: 19px;
  flex: 0 0 auto;
  fill: none;
  stroke: var(--muted);
  stroke-linecap: round;
  stroke-width: 2;
}

.search-wrap input {
  width: 100%;
  height: 46px;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
}

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

.top-actions,
.lyrics-tools,
.controls,
.volume-box,
.progress-row {
  display: flex;
  align-items: center;
}

.top-actions {
  justify-content: flex-end;
  gap: 10px;
}

.icon-button,
.mini-button,
.play-button {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
  transition: transform 220ms var(--ease), border-color 220ms var(--ease), background 220ms var(--ease);
}

.icon-button:hover,
.mini-button:hover,
.play-button:hover {
  border-color: rgba(102, 126, 234, 0.62);
  background: rgba(255, 255, 255, 0.14);
  transform: translateY(-1px);
}

.icon-button {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 50%;
  font-weight: 800;
}

.mini-button {
  height: 32px;
  min-width: 38px;
  border-radius: 999px;
  font-size: 12px;
}

.play-button {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-a), var(--accent-b));
  box-shadow: 0 16px 34px rgba(102, 126, 234, 0.32);
  color: white;
  font-weight: 900;
}

.main-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 390px);
  gap: 22px;
  padding: 26px clamp(16px, 4vw, 42px);
}

.library-panel,
.lyrics-panel,
.player-bar {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px);
}

.library-panel {
  min-width: 0;
  padding: clamp(18px, 3vw, 30px);
  border-radius: 28px;
}

.section-heading,
.lyrics-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-c);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(30px, 4vw, 54px);
  line-height: 1.04;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 23px;
}

.count-pill,
.genre-chip {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.07);
  white-space: nowrap;
}

.count-pill {
  padding: 10px 14px;
  font-size: 13px;
}

.status-line {
  min-height: 20px;
  margin: 18px 0 22px;
  color: var(--muted);
  font-size: 14px;
}

.album-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(154px, 1fr));
  gap: 18px;
}

.album-card {
  position: relative;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.075);
  cursor: pointer;
  animation: cardIn 420ms var(--ease) both;
  animation-delay: calc(var(--stagger) * 24ms);
  transition: transform 260ms var(--ease), background 260ms var(--ease), border-color 260ms var(--ease);
}

.album-card:hover,
.album-card.is-active {
  border-color: rgba(102, 126, 234, 0.58);
  background: rgba(255, 255, 255, 0.12);
  transform: translateY(-5px) scale(1.018);
}

.cover-wrap {
  position: relative;
  overflow: hidden;
  aspect-ratio: 1;
  border-radius: 17px;
  background: rgba(255, 255, 255, 0.08);
}

.cover-wrap img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  transition: transform 300ms var(--ease), filter 300ms var(--ease);
}

.album-card:hover .cover-wrap img {
  transform: scale(1.06);
  filter: saturate(1.1) contrast(1.05);
}

.card-play {
  position: absolute;
  right: 10px;
  bottom: 10px;
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: white;
  background: linear-gradient(135deg, var(--accent-a), var(--accent-b));
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.24);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 240ms var(--ease), transform 240ms var(--ease);
}

.album-card:hover .card-play,
.album-card.is-active .card-play {
  opacity: 1;
  transform: translateY(0);
}

.card-body {
  display: flex;
  min-width: 0;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 2px 2px;
}

.card-body h3 {
  margin-bottom: 5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 16px;
  line-height: 1.2;
}

.card-body p {
  margin-bottom: 0;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.genre-chip {
  align-self: flex-start;
  max-width: 92px;
  overflow: hidden;
  padding: 5px 8px;
  text-overflow: ellipsis;
  font-size: 11px;
}

.favorite-dot {
  position: absolute;
  top: 17px;
  left: 17px;
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.34);
  color: rgba(255, 255, 255, 0.58);
}

.favorite-dot.on {
  color: #ff7ca0;
}

.empty-state {
  grid-column: 1 / -1;
  margin: 30px 0;
  color: var(--muted);
  text-align: center;
}

.lyrics-panel {
  position: sticky;
  top: 102px;
  height: calc(100vh - 142px - var(--player-height));
  min-height: 460px;
  overflow: hidden;
  padding: 22px;
  border-radius: 28px;
}

.lyrics-tools {
  gap: 8px;
}

.lyrics-stage {
  position: relative;
  height: calc(100% - 62px);
  overflow: hidden;
  margin-top: 18px;
  border-top: 1px solid var(--line);
  mask-image: linear-gradient(transparent, black 16%, black 82%, transparent);
}

.lyrics-track {
  padding: calc(50% - 36px) 0;
  transition: transform 280ms var(--ease);
  will-change: transform;
}

.lyric-line {
  display: block;
  width: 100%;
  margin: 0;
  padding: 12px 6px;
  border: 0;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: var(--lyrics-font-size, 18px);
  line-height: 1.5;
  text-align: center;
  transition: color 220ms var(--ease), transform 220ms var(--ease), opacity 220ms var(--ease);
}

.lyric-line:hover {
  color: var(--text);
}

.lyric-line.active {
  color: var(--text);
  opacity: 1;
  transform: scale(1.06);
  text-shadow: 0 0 24px rgba(102, 126, 234, 0.45);
}

.lyric-empty {
  margin: 52px 0;
  color: var(--muted);
  text-align: center;
}

.player-bar {
  position: fixed;
  right: clamp(12px, 3vw, 28px);
  bottom: 16px;
  left: clamp(12px, 3vw, 28px);
  z-index: 30;
  display: grid;
  grid-template-columns: minmax(210px, 300px) minmax(260px, 1fr) minmax(190px, 260px);
  gap: 20px;
  align-items: center;
  min-height: var(--player-height);
  padding: 16px 18px;
  border-radius: 26px;
  background: var(--panel-strong);
}

.now-playing {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 13px;
}

.now-playing img {
  width: 72px;
  height: 72px;
  flex: 0 0 auto;
  border-radius: 18px;
  object-fit: cover;
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.28);
}

.now-playing strong,
.now-playing span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.now-playing strong {
  margin-bottom: 7px;
  font-size: 17px;
}

.now-playing span {
  color: var(--muted);
  font-size: 13px;
}

.transport {
  min-width: 0;
}

.controls {
  justify-content: center;
  gap: 12px;
  margin-bottom: 12px;
}

.progress-row {
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.progress-row span {
  width: 42px;
  flex: 0 0 auto;
  text-align: center;
}

input[type="range"] {
  --range-value: 0%;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  outline: 0;
  appearance: none;
  background: linear-gradient(90deg, var(--accent-a), var(--accent-b) var(--range-value), rgba(255, 255, 255, 0.16) var(--range-value));
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  width: 16px;
  height: 16px;
  border: 2px solid white;
  border-radius: 50%;
  appearance: none;
  background: var(--accent-a);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.22);
}

input[type="range"]::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border: 2px solid white;
  border-radius: 50%;
  background: var(--accent-a);
}

.volume-box {
  justify-content: flex-end;
  gap: 11px;
  min-width: 0;
}

.volume-box input {
  max-width: 116px;
}

.volume-icon {
  color: var(--muted);
  font-size: 12px;
}

.icon-button.active {
  color: #ff7ca0;
}

.visualizer {
  display: flex;
  align-items: end;
  width: 42px;
  height: 28px;
  gap: 3px;
}

.visualizer i {
  width: 4px;
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(var(--accent-c), var(--accent-a));
  opacity: 0.42;
  transform-origin: bottom;
}

.visualizer.playing i {
  animation: pulse 860ms ease-in-out infinite alternate;
  opacity: 0.9;
}

.visualizer i:nth-child(2) { animation-delay: 120ms; }
.visualizer i:nth-child(3) { animation-delay: 240ms; }
.visualizer i:nth-child(4) { animation-delay: 80ms; }
.visualizer i:nth-child(5) { animation-delay: 190ms; }
.visualizer i:nth-child(6) { animation-delay: 310ms; }

.only-mobile {
  display: none;
}

@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  from { transform: scaleY(0.45); }
  to { transform: scaleY(2.2); }
}

@media (min-width: 1420px) {
  .album-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

@media (max-width: 1180px) {
  .main-layout {
    grid-template-columns: 1fr;
  }

  .lyrics-panel {
    position: fixed;
    top: 84px;
    right: 16px;
    bottom: calc(var(--player-height) + 26px);
    z-index: 25;
    width: min(440px, calc(100vw - 32px));
    height: auto;
    min-height: 0;
    transform: translateX(calc(100% + 28px));
    transition: transform 260ms var(--ease);
  }

  .lyrics-panel.open {
    transform: translateX(0);
  }

  .only-mobile {
    display: grid;
  }
}

@media (max-width: 860px) {
  :root {
    --player-height: 178px;
  }

  .topbar {
    grid-template-columns: 1fr auto;
  }

  .search-wrap {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .player-bar {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .volume-box {
    justify-content: center;
  }

  .now-playing {
    justify-content: center;
  }
}

@media (max-width: 620px) {
  :root {
    --player-height: 212px;
  }

  .app-shell {
    padding-bottom: calc(var(--player-height) + 16px);
  }

  .topbar {
    padding: 14px;
    gap: 12px;
  }

  .brand small {
    display: none;
  }

  .main-layout {
    padding: 14px;
  }

  .library-panel {
    padding: 16px;
    border-radius: 22px;
  }

  .section-heading {
    align-items: flex-start;
  }

  h1 {
    font-size: 32px;
  }

  .album-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .album-card {
    padding: 9px;
    border-radius: 18px;
  }

  .cover-wrap {
    border-radius: 14px;
  }

  .card-body {
    display: block;
  }

  .genre-chip {
    display: inline-block;
    margin-top: 9px;
    max-width: 100%;
  }

  .player-bar {
    right: 10px;
    bottom: 10px;
    left: 10px;
    padding: 13px;
    border-radius: 22px;
  }

  .now-playing {
    justify-content: flex-start;
  }

  .now-playing img {
    width: 58px;
    height: 58px;
    border-radius: 15px;
  }

  .volume-box {
    gap: 8px;
  }

  .visualizer {
    display: none;
  }

  .lyrics-panel {
    top: 74px;
    right: 10px;
    bottom: calc(var(--player-height) + 22px);
    width: calc(100vw - 20px);
    padding: 18px;
    border-radius: 22px;
  }
}
