:root {
  color-scheme: light;
  --bg: #f4f6fb;
  --bg-glow-1: rgba(99, 102, 241, 0.14);
  --bg-glow-2: rgba(56, 189, 248, 0.12);
  --surface: #ffffff;
  --surface-2: #f8f9fd;
  --surface-3: #eef1f8;
  --text: #1b2237;
  --muted: #6d7690;
  --border: #e4e8f2;
  --accent: #5b5bd6;
  --accent-2: #7c5fe0;
  --accent-soft: rgba(91, 91, 214, 0.1);
  --danger: #e05260;
  --shadow: 0 18px 45px rgba(30, 41, 90, 0.08);
  --shadow-sm: 0 4px 14px rgba(30, 41, 90, 0.06);
  --stage: linear-gradient(145deg, #e8ebf7 0%, #f3f5fc 48%, #e6eff8 100%);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d1020;
  --bg-glow-1: rgba(99, 102, 241, 0.16);
  --bg-glow-2: rgba(56, 189, 248, 0.08);
  --surface: #171b2e;
  --surface-2: #1d2238;
  --surface-3: #262c45;
  --text: #eef1ff;
  --muted: #99a2bd;
  --border: #2c3350;
  --accent: #8b8bff;
  --accent-2: #a78bfa;
  --accent-soft: rgba(139, 139, 255, 0.14);
  --danger: #ff7b88;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.35);
  --shadow-sm: 0 4px 14px rgba(0, 0, 0, 0.25);
  --stage: linear-gradient(145deg, #14182c 0%, #1a2038 48%, #12192d 100%);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  font-family: "Inter", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  transition: background-color .25s ease, color .25s ease;
}
body::before {
  content: "";
  position: fixed;
  inset: -30% -10% auto -10%;
  height: 70vh;
  background: radial-gradient(circle at 20% 20%, var(--bg-glow-1), transparent 55%), radial-gradient(circle at 80% 10%, var(--bg-glow-2), transparent 50%);
  pointer-events: none;
  z-index: 0;
}
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
svg { width: 20px; height: 20px; display: block; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }
[hidden] { display: none !important; }

.app-shell { position: relative; z-index: 1; max-width: 1440px; margin: 0 auto; padding: 22px clamp(16px, 3vw, 40px) 36px; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: 0 10px 22px rgba(91, 91, 214, .3); }
.brand-mark svg { width: 22px; height: 22px; margin-left: 2px; }
.brand h1 { margin: 0; font-size: 21px; letter-spacing: -.4px; }
.brand p { margin: 3px 0 0; font-size: 12.5px; color: var(--muted); }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 11px; min-height: 40px; padding: 0 15px; background: var(--surface-2); color: var(--text); font-size: 13.5px; font-weight: 600; text-decoration: none; transition: transform .15s ease, background .2s ease, border-color .2s ease, box-shadow .2s ease; white-space: nowrap; }
.qq-music-link:hover { border-color: #31c27c; color: #31c27c; }
.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn svg { width: 18px; height: 18px; }
.btn-soft { border-color: var(--border); background: var(--surface); box-shadow: var(--shadow-sm); }
.btn-soft:hover { border-color: var(--accent); color: var(--accent); }
.btn-primary { color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: 0 8px 18px rgba(91, 91, 214, .24); }
.btn-outline { border-color: var(--border); background: transparent; }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-text { background: transparent; color: var(--muted); box-shadow: none; }
.btn-text:hover { color: var(--accent); }
.btn-icon { width: 40px; min-height: 40px; padding: 0; border-radius: 11px; background: transparent; color: var(--text); }
.btn-icon:hover:not(:disabled) { background: var(--surface-3); }
.btn-icon.subtle { color: var(--muted); }
.btn-icon.subtle:hover:not(:disabled) { color: var(--danger); }
.btn-play { width: 50px; min-height: 50px; padding: 0; border-radius: 50%; color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: 0 8px 20px rgba(91, 91, 214, .3); }
.btn-play svg { width: 22px; height: 22px; }
.btn-play:hover { box-shadow: 0 10px 26px rgba(91, 91, 214, .42); }
.btn.toggle[aria-pressed="true"] { color: var(--accent); background: var(--accent-soft); }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 22px; align-items: start; }
.player-column { min-width: 0; }

.stage { position: relative; width: 100%; aspect-ratio: 16 / 9; min-height: 300px; border-radius: 20px; overflow: hidden; background: var(--stage); border: 1px solid var(--border); box-shadow: var(--shadow); display: grid; place-items: center; }
.stage video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #0a0c14; }
.stage:not(.has-video) video { display: none; }
.stage.is-fullscreen { border-radius: 0; border: none; aspect-ratio: auto; height: 100%; }

.stage-empty { text-align: center; padding: 24px; position: relative; z-index: 2; }
.empty-icon { width: 62px; height: 62px; margin: 0 auto 16px; border-radius: 18px; display: grid; place-items: center; color: var(--accent); background: var(--surface); box-shadow: var(--shadow-sm); }
.empty-icon svg { width: 28px; height: 28px; }
.stage-empty h2 { margin: 0 0 8px; font-size: 19px; }
.stage-empty p { margin: 0 0 20px; color: var(--muted); font-size: 13px; }
.empty-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }

.center-play { position: absolute; z-index: 5; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 70px; height: 70px; border: none; border-radius: 50%; display: grid; place-items: center; color: #fff; background: rgba(91, 91, 214, .88); backdrop-filter: blur(6px); box-shadow: 0 12px 30px rgba(20, 24, 60, .3); opacity: 0; transition: opacity .2s ease, transform .2s ease; }
.center-play svg { width: 28px; height: 28px; margin-left: 3px; }
.stage:hover .center-play, .center-play:focus-visible { opacity: 1; }
.center-play:hover { transform: translate(-50%, -50%) scale(1.06); }

.audio-art { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 18px; background: radial-gradient(circle at 50% 42%, var(--accent-soft), transparent 55%); z-index: 1; }
.audio-disc { width: 132px; height: 132px; border-radius: 50%; display: grid; place-items: center; background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: 0 18px 40px rgba(91, 91, 214, .3); animation: spin 12s linear infinite; animation-play-state: paused; }
.audio-art.is-playing .audio-disc { animation-play-state: running; }
.audio-disc-inner { width: 74px; height: 74px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); color: var(--accent); }
.audio-disc-inner svg { width: 30px; height: 30px; }
.audio-art-label { font-size: 12.5px; color: var(--muted); letter-spacing: 1px; }
.equalizer { display: flex; align-items: flex-end; gap: 5px; height: 26px; }
.equalizer i { width: 5px; height: 30%; border-radius: 4px; background: var(--accent); opacity: .55; }
.audio-art.is-playing .equalizer i { animation: bounce .9s ease-in-out infinite alternate; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes bounce { from { height: 20%; opacity: .45; } to { height: 100%; opacity: 1; } }

.drop-overlay { position: absolute; inset: 12px; z-index: 8; border: 2px dashed var(--accent); border-radius: 16px; background: rgba(91, 91, 214, .14); backdrop-filter: blur(3px); display: grid; place-items: center; }
.drop-card { display: grid; justify-items: center; gap: 10px; color: var(--accent); font-size: 15px; }
.drop-card svg { width: 34px; height: 34px; }

.stage-toast { position: absolute; z-index: 9; left: 50%; bottom: 18px; transform: translateX(-50%); max-width: 86%; padding: 10px 16px; border-radius: 10px; background: rgba(20, 24, 45, .88); color: #fff; font-size: 12.5px; box-shadow: var(--shadow); text-align: center; }

.track-info { padding: 18px 4px 14px; }
.track-title-row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.track-info h2 { margin: 0; font-size: 18px; letter-spacing: -.2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.track-info p { margin: 5px 0 0; color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.type-badge { flex: none; font-size: 11px; font-weight: 700; color: var(--accent); background: var(--accent-soft); padding: 4px 9px; border-radius: 6px; }

.control-panel { padding: 16px 18px 14px; border-radius: 16px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm); }
.seek-row { display: flex; align-items: center; gap: 12px; }
.time { font-variant-numeric: tabular-nums; font-size: 12px; color: var(--muted); min-width: 38px; }
.time:last-child { text-align: right; }
.seek-wrap { flex: 1; min-width: 0; display: flex; }
.range { -webkit-appearance: none; appearance: none; width: 100%; height: 6px; border-radius: 99px; outline: none; cursor: pointer; background: var(--surface-3); }
.range::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 14px; height: 14px; border-radius: 50%; background: var(--accent); border: 2px solid var(--surface); box-shadow: 0 1px 5px rgba(0,0,0,.25); transition: transform .15s ease; }
.range::-webkit-slider-thumb:hover { transform: scale(1.2); }
.range::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); border: 2px solid var(--surface); }
.seek { background: linear-gradient(to right, var(--accent) 0 var(--progress, 0%), rgba(125, 135, 165, .28) var(--progress, 0%) var(--buffered, 0%), var(--surface-3) var(--buffered, 0%) 100%); }
.volume { width: 84px; background: linear-gradient(to right, var(--accent) 0 var(--volume, 80%), var(--surface-3) var(--volume, 80%) 100%); }
.control-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 10px; }
.control-group { display: flex; align-items: center; gap: 4px; }
.control-group.right { gap: 3px; }
.volume-group { display: flex; align-items: center; gap: 4px; margin-left: 6px; }
.speed-picker select { appearance: none; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); border-radius: 9px; padding: 7px 9px; font-size: 12px; font-weight: 700; cursor: pointer; outline: none; }
.speed-picker select:hover { border-color: var(--accent); }
.shortcut-hints { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 14px; color: var(--muted); font-size: 11.5px; }
kbd { font-family: inherit; font-size: 10.5px; padding: 2px 6px; border-radius: 5px; background: var(--surface); border: 1px solid var(--border); box-shadow: 0 1px 0 var(--border); color: var(--text); }

.playlist-panel { display: flex; flex-direction: column; min-height: 520px; max-height: calc(100vh - 130px); border-radius: 18px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); overflow: hidden; }
.playlist-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 18px 14px; border-bottom: 1px solid var(--border); }
.playlist-header h2 { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 15px; }
.playlist-header h2 svg { width: 18px; height: 18px; color: var(--accent); }
.playlist-header p { margin: 5px 0 0; font-size: 11.5px; color: var(--muted); }
.playlist { flex: 1; overflow-y: auto; padding: 10px; scrollbar-width: thin; }
.playlist-empty { height: 100%; min-height: 300px; display: grid; place-content: center; justify-items: center; gap: 6px; color: var(--muted); text-align: center; }
.playlist-empty svg { width: 32px; height: 32px; opacity: .5; margin-bottom: 6px; }
.playlist-empty p { margin: 0; font-size: 13.5px; font-weight: 600; color: var(--text); }
.playlist-empty span { font-size: 11.5px; }
.playlist-footer { padding: 12px 18px; border-top: 1px solid var(--border); color: var(--muted); font-size: 10.5px; text-align: center; }

.track-item { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 11px; border: 1px solid transparent; transition: background .15s ease, border-color .15s ease; }
.track-item:hover { background: var(--surface-2); }
.track-item.active { background: var(--accent-soft); border-color: rgba(91, 91, 214, .22); }
.track-index { flex: none; width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-3); color: var(--muted); font-size: 11px; font-weight: 700; }
.track-item.active .track-index { color: #fff; background: var(--accent); }
.track-item-main { flex: 1; min-width: 0; text-align: left; border: none; background: transparent; padding: 0; color: var(--text); }
.track-item-name { display: block; font-size: 12.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.track-item-meta { display: flex; align-items: center; gap: 6px; margin-top: 4px; font-size: 10.5px; color: var(--muted); }
.track-item-meta svg { width: 12px; height: 12px; }
.track-remove { flex: none; width: 28px; height: 28px; display: grid; place-items: center; border: none; border-radius: 8px; background: transparent; color: var(--muted); opacity: 0; transition: opacity .15s ease; }
.track-item:hover .track-remove, .track-remove:focus-visible { opacity: 1; }
.track-remove:hover { color: var(--danger); background: var(--surface-3); }
.track-remove svg { width: 15px; height: 15px; }
.playing-bars { display: inline-flex; align-items: flex-end; gap: 2px; height: 12px; }
.playing-bars i { width: 2px; height: 40%; background: var(--accent); animation: bounce .7s ease-in-out infinite alternate; }
.playing-bars i:nth-child(2) { animation-delay: .2s; }
.playing-bars i:nth-child(3) { animation-delay: .4s; }

.panel-tabs { display: flex; gap: 6px; padding: 10px 10px 0; border-bottom: 1px solid var(--border); }
.panel-tab { flex: 1; min-height: 36px; border: none; border-radius: 9px 9px 0 0; background: transparent; color: var(--muted); font-size: 12.5px; font-weight: 600; }
.panel-tab:hover { color: var(--text); background: var(--surface-2); }
.panel-tab.active { color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 -2px 0 var(--accent); }
.panel-view { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.library-toolbar { padding: 12px; border-bottom: 1px solid var(--border); }
.library-toolbar input, .extract-form input { width: 100%; min-height: 38px; padding: 0 12px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); outline: none; font-size: 12.5px; }
.library-toolbar input:focus, .extract-form input:focus { border-color: var(--accent); }
.library-list, .extract-results { flex: 1; overflow-y: auto; padding: 10px; scrollbar-width: thin; }
.song-card { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 11px; border: 1px solid transparent; }
.song-card:hover { background: var(--surface-2); border-color: var(--border); }
.song-cover { width: 38px; height: 38px; flex: none; border-radius: 10px; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.song-cover svg { width: 18px; height: 18px; }
.song-main { flex: 1; min-width: 0; border: none; background: transparent; color: var(--text); text-align: left; padding: 0; }
.song-name { display: block; font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.song-meta { display: block; margin-top: 4px; font-size: 10.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.song-add { flex: none; width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--accent); display: grid; place-items: center; }
.song-add:hover { background: var(--accent-soft); }
.song-add svg { width: 15px; height: 15px; }
.extract-form { display: grid; gap: 8px; padding: 14px; border-bottom: 1px solid var(--border); }
.extract-form label { font-size: 12px; font-weight: 600; }
.extract-form .btn { width: 100%; }
.extract-form .form-hint { margin: 2px 0 0; }
.extract-status { margin: 10px 12px 0; padding: 9px 11px; border-radius: 9px; font-size: 11.5px; background: var(--accent-soft); color: var(--accent); }
.extract-status.error { background: rgba(224, 82, 96, .12); color: var(--danger); }
.no-result { padding: 26px 12px; text-align: center; color: var(--muted); font-size: 12px; }

.modal-backdrop { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; background: rgba(12, 16, 35, .5); backdrop-filter: blur(4px); }
.modal { width: min(460px, 100%); padding: 22px; border-radius: 18px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.modal-header h2 { margin: 0; font-size: 17px; }
.modal form { display: grid; gap: 8px; }
.modal label { font-size: 12.5px; font-weight: 600; }
.modal label span { color: var(--muted); font-weight: 400; }
.modal input { width: 100%; min-height: 42px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); outline: none; font-size: 13px; }
.modal input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.form-hint { margin: 4px 0 8px; font-size: 11.5px; color: var(--muted); line-height: 1.6; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }

@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .playlist-panel { min-height: 340px; max-height: 420px; }
  .stage { min-height: 240px; }
}
@media (max-width: 620px) {
  .app-shell { padding: 16px 12px 28px; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .topbar-actions { width: 100%; }
  .topbar-actions .btn-soft { flex: 1; }
  .stage { border-radius: 14px; min-height: 200px; }
  .stage-empty h2 { font-size: 16px; }
  .stage-empty p { font-size: 11.5px; }
  .control-panel { padding: 14px 12px; }
  .volume { width: 60px; }
  .control-group.right { gap: 0; }
  .control-group.right .btn-icon { width: 34px; }
  .shortcut-hints { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
