:root {
  --bg-deep: #0b1020;
  --bg-card: rgba(20, 28, 50, 0.78);
  --bg-card-hover: rgba(31, 43, 74, 0.9);
  --border-subtle: rgba(148, 163, 184, 0.16);
  --border-active: rgba(99, 102, 241, 0.65);
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --accent-1: #6366f1;
  --accent-2: #06b6d4;
  --accent-grad: linear-gradient(135deg, #6366f1 0%, #06b6d4 100%);
  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-pill: 999px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at 12% 8%, rgba(99, 102, 241, 0.22), transparent 40%),
    radial-gradient(circle at 88% 18%, rgba(6, 182, 212, 0.16), transparent 42%),
    var(--bg-deep);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  line-height: 1.45;
}

.app-shell {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: calc(14px + env(safe-area-inset-top)) 16px calc(220px + env(safe-area-inset-bottom));
}

/* Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.brand-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--accent-grad);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 8px 20px rgba(99, 102, 241, 0.35);
}

.brand-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.brand-subtitle {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--text-secondary);
}

.qr-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 13px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-subtle);
  background: rgba(30, 41, 59, 0.72);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.15s ease, border-color 0.2s ease, background 0.2s ease;
}

.qr-btn:hover {
  border-color: var(--border-active);
  background: var(--bg-card-hover);
}

.qr-btn:active {
  transform: scale(0.96);
}

/* Section Headers */
.section-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.section-title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.4px;
}

.category-count,
.track-count {
  font-size: 12px;
  color: var(--text-secondary);
}

/* Category Tabs */
.category-section {
  margin-bottom: 18px;
}

.category-tabs {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 6px;
  margin-bottom: 12px;
  scrollbar-width: none;
}

.category-tabs::-webkit-scrollbar {
  display: none;
}

.category-pill {
  flex-shrink: 0;
  padding: 10px 16px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.category-pill .pill-count {
  font-size: 11px;
  padding: 1px 7px;
  border-radius: var(--radius-pill);
  background: rgba(148, 163, 184, 0.16);
  color: var(--text-secondary);
}

.category-pill.active {
  background: var(--accent-grad);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 6px 18px rgba(99, 102, 241, 0.35);
}

.category-pill.active .pill-count {
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
}

.category-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  backdrop-filter: blur(12px);
}

.category-banner-info {
  min-width: 0;
}

.category-banner-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 3px;
}

.category-banner-desc {
  font-size: 12.5px;
  color: var(--text-secondary);
}

.play-all-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 9px 14px;
  border: none;
  border-radius: var(--radius-pill);
  background: var(--accent-grad);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(99, 102, 241, 0.32);
  transition: transform 0.15s ease, opacity 0.2s ease;
}

.play-all-btn:active {
  transform: scale(0.95);
}

/* Track List */
.track-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.track-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.12s ease;
}

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

.track-item:active {
  transform: scale(0.99);
}

.track-item.active {
  border-color: var(--border-active);
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.22), rgba(6, 182, 212, 0.14));
}

.track-index {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: rgba(148, 163, 184, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.track-item.active .track-index {
  background: rgba(99, 102, 241, 0.28);
  color: #fff;
}

.eq-bars {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 13px;
}

.eq-bars span {
  width: 3px;
  border-radius: 2px;
  background: #fff;
  height: 4px;
  animation: eqPulse 0.9s ease-in-out infinite;
}

.eq-bars span:nth-child(2) {
  animation-delay: 0.2s;
}

.eq-bars span:nth-child(3) {
  animation-delay: 0.4s;
}

.track-item.paused .eq-bars span {
  animation-play-state: paused;
  height: 5px;
}

@keyframes eqPulse {
  0%, 100% { height: 4px; }
  50% { height: 13px; }
}

.track-meta {
  flex: 1;
  min-width: 0;
}

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

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

.track-duration {
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
  flex-shrink: 0;
}

/* Fixed Bottom Player Dock */
.player-dock {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 100%;
  max-width: 560px;
  padding: 14px 18px calc(16px + env(safe-area-inset-bottom));
  background: rgba(11, 16, 32, 0.9);
  border-top: 1px solid var(--border-subtle);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 -12px 32px rgba(0, 0, 0, 0.45);
  z-index: 20;
}

.now-playing {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.disc-wrap {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, #6366f1, #06b6d4, #8b5cf6, #6366f1);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  animation: spinDisc 10s linear infinite;
  animation-play-state: paused;
}

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

.disc-inner {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--bg-deep);
  border: 2px solid rgba(255, 255, 255, 0.8);
}

@keyframes spinDisc {
  to { transform: rotate(360deg); }
}

.now-playing-meta {
  min-width: 0;
  flex: 1;
}

.now-playing-title {
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.now-playing-sub {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.badge {
  font-size: 11px;
  padding: 1px 8px;
  border-radius: var(--radius-pill);
  background: rgba(99, 102, 241, 0.22);
  color: #c7d2fe;
  white-space: nowrap;
}

/* Progress Bar */
.progress-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.time-label {
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
  width: 38px;
  text-align: center;
  flex-shrink: 0;
}

.seek-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 5px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.24);
  outline: none;
  cursor: pointer;
}

.seek-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.45);
}

.seek-slider::-moz-range-thumb {
  width: 15px;
  height: 15px;
  border: none;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.45);
}

/* Controls */
.controls-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.transport-group {
  display: flex;
  align-items: center;
  gap: 16px;
}

.icon-btn {
  border: none;
  background: transparent;
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 8px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: background 0.15s ease, transform 0.12s ease, color 0.15s ease;
}

.icon-btn:hover {
  background: rgba(148, 163, 184, 0.12);
}

.icon-btn:active {
  transform: scale(0.92);
}

.mode-btn {
  padding: 7px 11px;
  border: 1px solid var(--border-subtle);
  background: rgba(30, 41, 59, 0.55);
  font-size: 12px;
  color: #c7d2fe;
}

.mode-text {
  white-space: nowrap;
}

.play-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  background: var(--accent-grad);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(99, 102, 241, 0.45);
  transition: transform 0.14s ease;
}

.play-btn:active {
  transform: scale(0.93);
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  top: 20px;
  transform: translate(-50%, -18px);
  background: rgba(15, 23, 42, 0.94);
  color: #f8fafc;
  border: 1px solid var(--border-active);
  padding: 10px 16px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
  z-index: 50;
  max-width: calc(100vw - 32px);
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* QR Import Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 18, 0.76);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
  z-index: 40;
}

@media (min-width: 600px) {
  .modal-backdrop {
    align-items: center;
  }
}

.modal-card {
  width: 100%;
  max-width: 460px;
  background: #121a30;
  border: 1px solid var(--border-subtle);
  border-radius: 22px;
  padding: 20px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.modal-title {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
}

.modal-desc {
  margin: 0 0 16px;
  font-size: 13px;
  color: var(--text-secondary);
}

.upload-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 22px 16px;
  border-radius: var(--radius-lg);
  border: 1.5px dashed var(--border-active);
  background: rgba(99, 102, 241, 0.08);
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.upload-zone:hover {
  background: rgba(99, 102, 241, 0.16);
}

.upload-title {
  font-size: 14.5px;
  font-weight: 600;
}

.upload-sub {
  font-size: 12px;
  color: var(--text-secondary);
}

.modal-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0;
  font-size: 12px;
  color: var(--text-secondary);
}

.modal-divider::before,
.modal-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border-subtle);
}

.url-form {
  display: flex;
  gap: 8px;
}

.url-input {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
  background: rgba(11, 16, 32, 0.85);
  color: var(--text-primary);
  font-size: 13.5px;
  outline: none;
}

.url-input:focus {
  border-color: var(--accent-1);
}

.qr-status {
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(99, 102, 241, 0.14);
  border: 1px solid rgba(99, 102, 241, 0.3);
  font-size: 13px;
  color: #e0e7ff;
}

.qr-status.error {
  background: rgba(239, 68, 68, 0.14);
  border-color: rgba(239, 68, 68, 0.35);
  color: #fecaca;
}

.is-hidden,
[hidden] {
  display: none !important;
}

.empty-state {
  text-align: center;
  padding: 36px 16px;
  color: var(--text-secondary);
  font-size: 14px;
}
