:root {
  --purple: #8b5cf6;
  --pink: #ec4899;
  --cyan: #06b6d4;
  --text: #1e1b4b;
  --text-dim: #64748b;
  --card: rgba(255, 255, 255, 0.7);
  --shadow-sm: 0 2px 8px rgba(139, 92, 246, 0.08);
  --shadow-md: 0 8px 24px rgba(139, 92, 246, 0.12);
  --shadow-lg: 0 12px 40px rgba(139, 92, 246, 0.18);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: linear-gradient(135deg, #f5f3ff 0%, #fdf4ff 25%, #fef3c7 60%, #e0f2fe 100%);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

.bg-blobs {
  position: fixed; inset: 0; background-size: cover; background-position: center;
  filter: blur(120px) saturate(1.5); opacity: 0.25; z-index: -1;
  transition: background-image 0.6s ease; pointer-events: none;
}

/* VIEWS */
.view { display: none; min-height: 100vh; padding: 24px; padding-bottom: 140px; max-width: 900px; margin: 0 auto; }
.view.active { display: block; animation: fadeIn 0.3s ease; }

.view-player {
  position: fixed; inset: 0; padding: 20px 24px 40px; overflow-y: auto;
  background: linear-gradient(160deg, #faf5ff 0%, #fdf2f8 40%, #ecfeff 100%);
  z-index: 100; max-width: none;
}
.view-player.active { display: flex; flex-direction: column; align-items: center; }

.view-lyrics {
  position: fixed; inset: 0; padding: 20px 24px 40px; overflow-y: auto;
  background: linear-gradient(160deg, #faf5ff 0%, #fdf2f8 40%, #ecfeff 100%);
  z-index: 110; max-width: none; display: none; flex-direction: column;
}
.view-lyrics.active { display: flex; }

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

/* HEADER & BROWSE */
header { padding: 8px 0 16px; }
header h1 {
  font-size: 34px; font-weight: 800;
  background: linear-gradient(135deg, var(--purple), var(--pink), var(--cyan));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  letter-spacing: -1px;
}
header p { color: var(--text-dim); font-size: 11px; letter-spacing: 3px; font-weight: 700; margin-top: 2px; }

.fav-header-btn {
  padding: 8px 16px; border: 1px solid rgba(236, 72, 153, 0.2); border-radius: 100px;
  background: rgba(255, 255, 255, 0.7); color: #ec4899; font-weight: 600;
  cursor: pointer; backdrop-filter: blur(10px); transition: all 0.2s;
}
.fav-header-btn:hover { background: white; box-shadow: 0 4px 12px rgba(236, 72, 153, 0.15); }

.moods { display: flex; gap: 10px; overflow-x: auto; padding: 8px 0 16px; scrollbar-width: none; }
.moods::-webkit-scrollbar { display: none; }
.moods button {
  padding: 10px 18px; border: 1px solid rgba(139, 92, 246, 0.15); border-radius: 100px;
  background: var(--card); color: var(--text); font-size: 14px; font-weight: 500;
  white-space: nowrap; cursor: pointer; backdrop-filter: blur(20px); box-shadow: var(--shadow-sm); transition: all 0.2s;
}
.moods button:hover { background: white; transform: translateY(-2px); box-shadow: var(--shadow-md); }

.search-box { display: flex; gap: 10px; margin-bottom: 24px; }
.search-box input {
  flex: 1; padding: 16px 20px; border: 1px solid rgba(139, 92, 246, 0.15); border-radius: 16px;
  background: var(--card); color: var(--text); font-size: 15px; outline: none;
  backdrop-filter: blur(20px); box-shadow: var(--shadow-sm); transition: all 0.2s;
}
.search-box input::placeholder { color: var(--text-dim); }
.search-box input:focus { border-color: var(--purple); box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.12); background: white; }
.search-box button {
  padding: 16px 28px; border: none; border-radius: 16px;
  background: linear-gradient(135deg, var(--purple), var(--pink)); color: white;
  font-weight: 600; font-size: 15px; cursor: pointer; box-shadow: 0 4px 16px rgba(139, 92, 246, 0.3); transition: all 0.2s;
}
.search-box button:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(139, 92, 246, 0.4); }

#songs { display: flex; flex-direction: column; gap: 12px; }
.song {
  display: flex; align-items: center; gap: 14px; padding: 12px; border-radius: 18px;
  background: var(--card); backdrop-filter: blur(20px); border: 1px solid rgba(139, 92, 246, 0.08);
  cursor: pointer; transition: all 0.2s; box-shadow: var(--shadow-sm);
}
.song:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); background: white; }
.song img { width: 64px; height: 64px; border-radius: 12px; object-fit: cover; flex-shrink: 0; background: #f3f0ff; }
.song .meta { flex: 1; min-width: 0; }
.song .meta h3 { font-size: 15px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 3px; }
.song .meta p { font-size: 13px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.song .add-btn {
  width: 44px; height: 44px; border: none; border-radius: 50%;
  background: linear-gradient(135deg, var(--purple), var(--pink)); color: white;
  font-size: 22px; font-weight: 700; cursor: pointer; flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.35); transition: all 0.2s;
  display: flex; align-items: center; justify-content: center;
}
.song .add-btn:hover { transform: scale(1.1); }

.empty { text-align: center; padding: 60px 20px; color: var(--text-dim); font-size: 15px; }
.empty-emoji { font-size: 48px; display: block; margin-bottom: 12px; }

/* PLAYER VIEW */
.back-btn {
  width: 44px; height: 44px; border: none; border-radius: 50%; background: var(--card);
  color: var(--text); font-size: 20px; cursor: pointer; box-shadow: var(--shadow-sm);
  backdrop-filter: blur(20px); margin-bottom: 12px; align-self: flex-start; transition: all 0.2s;
}
.back-btn:hover { background: white; transform: translateX(-4px); }

.cover-wrap {
  width: min(70vw, 300px); height: min(70vw, 300px); aspect-ratio: 1 / 1;
  flex-shrink: 0; margin: 0 auto 20px; border-radius: 50% !important;
  padding: 8px; background: linear-gradient(135deg, var(--purple), var(--pink));
  box-shadow: var(--shadow-lg); position: relative;
}
.cover-wrap img {
  width: 100%; height: 100%; border-radius: 50%; object-fit: cover;
  animation: spin 15s linear infinite; animation-play-state: paused;
}
.cover-wrap.playing img { animation-play-state: running; }
@keyframes spin { 100% { transform: rotate(360deg); } }

#visualizer { width: 100%; max-width: 500px; height: 70px; margin: -10px 0 15px; pointer-events: none; }

.meta-lg { text-align: center; margin-bottom: 20px; width: 100%; }
.meta-lg h1 { font-size: 24px; font-weight: 700; margin-bottom: 6px; color: var(--text); }
.meta-lg p { color: var(--text-dim); font-size: 15px; }

.fav-btn { background: none; border: none; font-size: 28px; cursor: pointer; transition: transform 0.2s, filter 0.2s; filter: grayscale(1); }
.fav-btn.active { filter: grayscale(0); animation: pop 0.3s ease; }
.fav-btn:hover { transform: scale(1.15); }
@keyframes pop { 0% { transform: scale(1); } 50% { transform: scale(1.3); } 100% { transform: scale(1); } }

.progress-row-lg { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; width: 100%; max-width: 500px; }
.progress-row-lg span { font-size: 12px; color: var(--text-dim); font-variant-numeric: tabular-nums; min-width: 36px; text-align: center; }
.progress-lg { flex: 1; height: 6px; background: rgba(139, 92, 246, 0.15); border-radius: 10px; cursor: pointer; overflow: hidden; position: relative; }
#progressBarLg { height: 100%; width: 0%; background: linear-gradient(90deg, var(--purple), var(--pink)); border-radius: 10px; pointer-events: none; }

.controls-lg { display: flex; align-items: center; justify-content: center; gap: 16px; margin: 24px 0; }
.ctrl-icon {
  width: 44px; height: 44px; border: none; border-radius: 50%; background: rgba(255, 255, 255, 0.7);
  color: var(--text); font-size: 18px; cursor: pointer; box-shadow: var(--shadow-sm); transition: all 0.2s; backdrop-filter: blur(20px);
}
.ctrl-icon:hover { background: white; transform: scale(1.08); }
.ctrl-icon.active { background: var(--purple); color: white; }
.play-btn-lg {
  width: 72px; height: 72px; border: none; border-radius: 50%; background: linear-gradient(135deg, var(--purple), var(--pink));
  color: white; font-size: 26px; cursor: pointer; box-shadow: 0 8px 24px rgba(139, 92, 246, 0.4);
  transition: all 0.2s; display: flex; align-items: center; justify-content: center;
}
.play-btn-lg:hover { transform: scale(1.06); box-shadow: 0 12px 32px rgba(139, 92, 246, 0.5); }

.volume-row { display: flex; align-items: center; gap: 12px; width: 100%; max-width: 300px; margin: 0 auto 32px; }
.vol-icon { background: none; border: none; font-size: 20px; cursor: pointer; }
.volume-row input[type="range"] { flex: 1; accent-color: var(--purple); cursor: pointer; }

/* UP NEXT */
.upnext { width: 100%; max-width: 500px; }
.upnext h2 { font-size: 18px; font-weight: 700; margin-bottom: 14px; color: var(--text); }
.upnext-item { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 14px; cursor: pointer; transition: background 0.2s; position: relative; }
.upnext-item:hover { background: rgba(255, 255, 255, 0.6); }
.upnext-item.active { background: rgba(139, 92, 246, 0.12); }
.upnext-item img { width: 48px; height: 48px; border-radius: 10px; object-fit: cover; flex-shrink: 0; background: #f3f0ff; }
.upnext-item h4 { font-size: 14px; font-weight: 600; margin-bottom: 2px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.upnext-item p { font-size: 12px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.upnext-remove { background: rgba(236, 72, 153, 0.1); border: none; color: #ec4899; width: 32px; height: 32px; border-radius: 50%; font-size: 16px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.2s; flex-shrink: 0; }
.upnext-remove:hover { background: #ec4899; color: white; }
.upnext-empty { text-align: center; color: var(--text-dim); font-size: 13px; padding: 20px; }

/* LYRICS VIEW */
.lyrics-header { display: flex; align-items: center; gap: 16px; margin-bottom: 30px; background: rgba(255, 255, 255, 0.5); padding: 12px; border-radius: 16px; backdrop-filter: blur(10px); }
.lyrics-header img { width: 64px; height: 64px; border-radius: 12px; object-fit: cover; background: #f3f0ff; }
.lyrics-header-info h2 { font-size: 18px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.lyrics-header-info p { font-size: 14px; color: var(--text-dim); }
.lyrics-content { font-size: 24px; line-height: 1.6; font-weight: 700; color: var(--text); text-align: center; white-space: pre-wrap; padding-bottom: 100px; }
.lyrics-loading { text-align: center; color: var(--text-dim); font-size: 16px; font-weight: 500; margin-top: 40px; animation: pulse 1.5s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

/* MINI BAR */
.mini-bar {
  position: fixed; bottom: 16px; left: 16px; right: 16px; max-width: 500px; margin: 0 auto;
  background: rgba(255, 255, 255, 0.9); backdrop-filter: blur(24px); border-radius: 20px;
  padding: 10px; display: flex; align-items: center; gap: 12px; box-shadow: var(--shadow-lg);
  border: 1px solid rgba(139, 92, 246, 0.1); z-index: 90; transition: transform 0.3s ease, opacity 0.3s ease; cursor: pointer;
}
.mini-bar.hidden { transform: translateY(150%); opacity: 0; pointer-events: none; }
.mini-bar img { width: 48px; height: 48px; border-radius: 12px; object-fit: cover; flex-shrink: 0; background: #f3f0ff; }
.mini-info { flex: 1; min-width: 0; }
.mini-info h4 { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 2px; }
.mini-info p { font-size: 12px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-btn { width: 40px; height: 40px; border: none; border-radius: 50%; background: linear-gradient(135deg, var(--purple), var(--pink)); color: white; font-size: 16px; cursor: pointer; flex-shrink: 0; transition: transform 0.15s; display: flex; align-items: center; justify-content: center; }
.mini-btn:active { transform: scale(0.9); }
.fav-mini { background: transparent !important; color: var(--text) !important; font-size: 20px !important; width: auto !important; padding: 0 8px; filter: grayscale(1); }
.fav-mini.active { filter: grayscale(0); }

/* TOAST */
.toast { position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%) translateY(20px); background: rgba(30, 27, 75, 0.95); color: white; padding: 12px 20px; border-radius: 30px; font-size: 14px; font-weight: 500; opacity: 0; pointer-events: none; transition: all 0.3s; z-index: 200; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2); max-width: 90vw; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

button:focus-visible, input:focus-visible { outline: 2px solid var(--purple); outline-offset: 2px; }

@media (max-width: 640px) {
  .view { padding: 20px; padding-bottom: 140px; }
  header h1 { font-size: 28px; }
  .search-box { flex-direction: column; }
  .search-box button { width: 100%; }
  .meta-lg h1 { font-size: 20px; }
  .ctrl-icon { width: 40px; height: 40px; font-size: 16px; }
  .play-btn-lg { width: 64px; height: 64px; font-size: 22px; }
  .controls-lg { gap: 12px; }
}