/* ============================================================
   vae / yfc 共享播放器 — 沉浸式深色 + 可切换色板
   明暗主题：[data-theme]; 强调色：[data-accent]（每次打开可随机）
   ============================================================ */

:root {
  --bg: #0e0f12;
  --surface: #16181d;
  --surface-2: #1c1f25;
  --fg: #eae8e4;
  --muted: #8d919a;
  --line: #24272e;
  --shadow: 0 18px 50px rgba(0, 0, 0, .5);
  --serif: "Songti SC", "STSong", "Noto Serif SC", serif;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
          "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
}

[data-theme="light"] {
  --bg: #f5f3ef;
  --surface: #ffffff;
  --surface-2: #f0ede7;
  --fg: #22201d;
  --muted: #86817a;
  --line: #e5e0d8;
  --shadow: 0 18px 50px rgba(40, 36, 30, .14);
}

/* 六套强调色 */
[data-accent="mist"]     { --ac: #8ab4c8; }
[data-accent="gold"]     { --ac: #c9a86a; }
[data-accent="cinnabar"] { --ac: #cf7f6f; }
[data-accent="moss"]     { --ac: #7fae8f; }
[data-accent="wisteria"] { --ac: #a68fd0; }
[data-accent="rose"]     { --ac: #d087a8; }
[data-theme="light"][data-accent="mist"]     { --ac: #4d7d92; }
[data-theme="light"][data-accent="gold"]     { --ac: #9a7b3c; }
[data-theme="light"][data-accent="cinnabar"] { --ac: #b0524a; }
[data-theme="light"][data-accent="moss"]     { --ac: #4e8563; }
[data-theme="light"][data-accent="wisteria"] { --ac: #7a5fb8; }
[data-theme="light"][data-accent="rose"]     { --ac: #b8537e; }

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--fg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background .3s, color .3s;
  overflow: hidden;
}

button { font-family: inherit; }
a { color: inherit; text-decoration: none; }
::selection { background: var(--ac); color: #fff; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border: 1px solid var(--line);
  border-radius: 50%; background: transparent; color: var(--muted);
  cursor: pointer; transition: color .2s, border-color .2s, transform .2s;
}
.icon-btn:hover { color: var(--fg); border-color: var(--ac); }

/* ---------- 布局骨架 ---------- */

.app {
  display: grid; grid-template-columns: 380px 1fr;
  height: 100dvh; max-width: 1240px; margin: 0 auto;
}

/* ---------- 左侧：曲库 ---------- */

.library {
  display: flex; flex-direction: column; min-height: 0;
  border-right: 1px solid var(--line);
  background: var(--surface);
  padding-top: env(safe-area-inset-top);
}

.lib-head {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 22px 22px 14px;
}
.brand {
  font-family: var(--serif); font-size: 30px; font-weight: 700;
  margin: 0; letter-spacing: .06em; line-height: 1;
}
.artist-link { font-size: 13px; color: var(--muted); }
.artist-link:hover { color: var(--ac); }
.artist-link span { font-size: 11px; }

.tabs { display: flex; gap: 6px; padding: 0 16px 12px; flex-wrap: wrap; }
.tab {
  padding: 6px 13px; font-size: 12.5px; color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px;
  background: transparent; cursor: pointer; transition: all .2s;
}
.tab:hover { color: var(--fg); }
.tab.active {
  color: var(--ac); border-color: var(--ac);
  background: color-mix(in srgb, var(--ac) 12%, transparent);
}

.search-wrap {
  display: flex; align-items: center; gap: 8px;
  margin: 0 16px 10px; padding: 8px 12px;
  border: 1px solid var(--line); border-radius: 10px;
  color: var(--muted); background: var(--surface-2);
}
.search-wrap:focus-within { border-color: var(--ac); }
.search-wrap input {
  flex: 1; border: 0; outline: 0; background: transparent;
  color: var(--fg); font-size: 13.5px;
}

.songs {
  flex: 1; overflow-y: auto; margin: 0; padding: 4px 10px 20px;
  list-style: none; scrollbar-width: thin; scrollbar-color: var(--line) transparent;
}
.songs::-webkit-scrollbar { width: 6px; }
.songs::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }

.songs li {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px; border-radius: 9px; cursor: pointer;
  color: var(--muted); transition: background .15s, color .15s;
}
.songs li:hover { background: var(--surface-2); color: var(--fg); }
.songs li.active { color: var(--ac); background: color-mix(in srgb, var(--ac) 10%, transparent); }
.songs .no { font-size: 11.5px; width: 20px; text-align: right; flex: none; opacity: .7; }
.songs .st { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.songs .tt { font-size: 14px; line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.songs li.active .tt { font-weight: 600; }
.songs .ar { font-size: 11.5px; opacity: .75; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.songs .eq { display: none; gap: 2px; align-items: flex-end; height: 12px; flex: none; }
.songs li.active .eq { display: inline-flex; }
.songs .eq i { width: 2.5px; background: var(--ac); animation: eq 1s ease-in-out infinite; border-radius: 1px; }
.songs .eq i:nth-child(2) { animation-delay: .25s; }
.songs .eq i:nth-child(3) { animation-delay: .5s; }
.songs li.paused .eq i { animation-play-state: paused; }
@keyframes eq { 0%, 100% { height: 3px; } 50% { height: 12px; } }

/* ---------- 右侧：播放舞台 ---------- */

.stage {
  position: relative; display: flex; flex-direction: column;
  justify-content: space-between; min-height: 0;
  padding: clamp(24px, 5vh, 56px) clamp(24px, 5vw, 64px);
  background:
    radial-gradient(1200px 500px at 80% -10%, color-mix(in srgb, var(--ac) 9%, transparent), transparent 65%),
    var(--bg);
}

.stage-close { display: none; position: absolute; top: 14px; right: 14px; }

.now { text-align: center; margin-top: auto; }
.now-source {
  margin: 0 0 10px; font-size: 12px; letter-spacing: .3em;
  color: var(--ac); text-transform: uppercase;
}
.now-title {
  font-family: var(--serif); font-weight: 700;
  font-size: clamp(26px, 4.2vw, 46px); line-height: 1.25;
  margin: 0 0 8px; word-break: break-all;
}
.now-artist { margin: 0; color: var(--muted); font-size: 14.5px; letter-spacing: .08em; }

.deck { margin-top: auto; }

.progress {
  position: relative; height: 22px; cursor: pointer;
  display: flex; align-items: center; touch-action: none;
}
.progress::before {
  content: ''; position: absolute; left: 0; right: 0; height: 4px;
  border-radius: 2px; background: var(--line);
}
.p-buffer, .p-fill {
  position: absolute; left: 0; height: 4px; border-radius: 2px; width: 0;
}
.p-buffer { background: color-mix(in srgb, var(--fg) 18%, transparent); }
.p-fill { background: var(--ac); }
.p-knob {
  position: absolute; width: 13px; height: 13px; border-radius: 50%;
  background: var(--ac); transform: translateX(-50%) scale(0);
  transition: transform .15s; box-shadow: 0 0 0 4px color-mix(in srgb, var(--ac) 22%, transparent);
}
.progress:hover .p-knob, .progress.dragging .p-knob { transform: translateX(-50%) scale(1); }

.times {
  display: flex; justify-content: space-between;
  font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums;
}

.controls {
  display: flex; align-items: center; justify-content: center;
  gap: clamp(12px, 2.4vw, 22px); margin-top: 18px;
}

.skip-btn { width: 46px; height: 46px; color: var(--fg); }

.play-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 64px; height: 64px; border: 0; border-radius: 50%;
  background: var(--ac); color: #fff; cursor: pointer;
  box-shadow: 0 10px 30px color-mix(in srgb, var(--ac) 35%, transparent);
  transition: transform .2s;
}
.play-btn:hover { transform: scale(1.05); }
.play-btn .i-pause { display: none; }
.play-btn.playing .i-play { display: none; }
.play-btn.playing .i-pause { display: block; }

.vol { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.vol input[type="range"] {
  width: 90px; accent-color: var(--ac); height: 3px; cursor: pointer;
}

/* ---------- 色板 ---------- */

.palette {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  margin-top: 26px;
}
.pal-label { font-size: 12px; color: var(--muted); letter-spacing: .2em; }
.pal-dots { display: flex; gap: 9px; }
.pal-dot {
  width: 18px; height: 18px; border-radius: 50%; border: 0; cursor: pointer;
  outline: 2px solid transparent; outline-offset: 3px; transition: outline-color .2s, transform .2s;
}
.pal-dot:hover { transform: scale(1.15); }
.pal-dot.active { outline-color: var(--fg); }
.theme-btn { width: 30px; height: 30px; }
[data-theme="dark"] .i-sun { display: none; }
[data-theme="light"] .i-moon { display: none; }

/* ---------- 移动端：迷你条 + 抽屉播放页 ---------- */

.minibar { display: none; }

@media (max-width: 860px) {
  body { overflow: auto; }
  .app { grid-template-columns: 1fr; height: auto; min-height: 100dvh; }
  .library { border-right: 0; min-height: calc(100dvh - 120px); }
  .songs { padding-bottom: 10px; }

  .minibar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--line);
  }
  .mb-info {
    flex: 1; min-width: 0; display: flex; flex-direction: column;
    align-items: flex-start; gap: 1px; border: 0; background: transparent;
    color: var(--fg); cursor: pointer; text-align: left;
  }
  .mb-title { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  .mb-sub { font-size: 11px; color: var(--muted); }
  .mb-play { flex: none; border-color: var(--ac); color: var(--ac); }
.mb-play .i-pause { display: none; }
.mb-play.playing .i-play { display: none; }
.mb-play.playing .i-pause { display: block; }

  /* 播放页变为全屏抽屉 */
  .stage {
    position: fixed; inset: 0; z-index: 50;
    transform: translateY(102%); transition: transform .38s cubic-bezier(.3, .8, .3, 1);
    padding-top: calc(24px + env(safe-area-inset-top));
    padding-bottom: calc(24px + env(safe-area-inset-bottom));
    overflow-y: auto;
  }
  .stage.open { transform: translateY(0); }
  .stage-close { display: inline-flex; }
  .now { margin-top: 12vh; }
  .controls { margin-top: 26px; }
  .play-btn { width: 70px; height: 70px; }
  .vol { display: none; }
  .palette { position: static; margin-top: 34px; }
}

/* ---------- 其他细节 ---------- */

@keyframes fadein { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.now, .deck, .palette { animation: fadein .7s ease backwards; }
.deck { animation-delay: .12s; }
.palette { animation-delay: .24s; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

.no-result { text-align: center; color: var(--muted); font-size: 13px; padding: 30px 0; }
