:root {
  --bg: #080c14;
  --text: #f1f5f9;
  --primary: #8b5cf6;
  --secondary: #ec4899;
  --glass-bg: rgba(255,255,255,0.03);
  --glass-border: rgba(255,255,255,0.07);
  --font: 'Outfit', sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  overflow-x: hidden;
  position: relative;
  padding: 2rem 1rem 4rem;
}

/* ── Background ── */
.bg-anim {
  position: fixed; inset: 0;
  z-index: 0;
  overflow: hidden;
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.5;
  transition: background 1.2s ease;
  animation: float 18s infinite ease-in-out alternate;
}
.blob-1 { width: 45vw; height: 45vw; background: var(--primary); top: -15%; left: -10%; animation-delay: 0s; }
.blob-2 { width: 40vw; height: 40vw; background: var(--secondary); bottom: -15%; right: -10%; animation-delay: -6s; }
.blob-3 { width: 30vw; height: 30vw; background: #06b6d4; top: 35%; left: 35%; animation-delay: -12s; }

@keyframes float {
  0%   { transform: translate(0, 0) scale(1); }
  100% { transform: translate(8vw, 8vh) scale(1.15); }
}

/* ── Layout ── */
.container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 660px;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* ── Header ── */
.header {
  text-align: center;
  padding: 1rem 0;
  animation: fadeDown 0.9s ease-out;
}
.header h1 {
  font-size: clamp(2.5rem, 6vw, 4rem);
  font-weight: 800;
  letter-spacing: -1.5px;
}
.header h1 .hi { background: linear-gradient(135deg, var(--secondary), var(--primary)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.header p { font-size: 1.05rem; color: #94a3b8; margin-top: 0.4rem; }

/* ── Glass Panel ── */
.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  padding: 1.75rem;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

/* ── Input Section ── */
.input-section {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  animation: fadeUp 0.9s ease-out 0.1s both;
}

.textarea-wrap { position: relative; }
.textarea-wrap textarea {
  width: 100%;
  background: rgba(0,0,0,0.25);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px;
  padding: 1.25rem 1.5rem;
  color: #fff;
  font-family: var(--font);
  font-size: 1.05rem;
  line-height: 1.6;
  resize: vertical;
  min-height: 120px;
  transition: border-color 0.3s, box-shadow 0.3s;
}
.textarea-wrap textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(139,92,246,0.12);
}
.textarea-wrap textarea::placeholder { color: #475569; }

.char-count {
  position: absolute;
  bottom: 0.75rem;
  right: 1rem;
  font-size: 0.75rem;
  color: #334155;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff;
  border: none;
  border-radius: 14px;
  padding: 0.9rem 2rem;
  font-size: 1.1rem;
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  transition: transform 0.2s, box-shadow 0.2s;
  position: relative;
  overflow: hidden;
}
.btn-primary::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.1);
  opacity: 0;
  transition: opacity 0.2s;
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 6px 24px rgba(139,92,246,0.4); }
.btn-primary:hover::after { opacity: 1; }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.hidden { display: none !important; }

.loader {
  width: 22px; height: 22px;
  border: 3px solid rgba(255,255,255,0.25);
  border-radius: 50%;
  border-top-color: #fff;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Results ── */
.results-section {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  animation: fadeUp 0.7s cubic-bezier(.16,1,.3,1) both;
}

/* Mood Row */
.mood-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.mood-label { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 2px; color: #64748b; flex: 0 0 auto; }
.mood-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.45rem 1.25rem;
  border-radius: 999px;
  font-size: 1.1rem;
  font-weight: 700;
  border: 1px solid transparent;
  transition: all 0.5s ease;
}

/* ── Visualizer ── */
.visualizer-section { padding: 1.25rem 1.75rem; }
.viz-label { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 2px; color: #64748b; margin-bottom: 1rem; }

.visualizer {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 60px;
}
.viz-bar {
  flex: 1;
  background: linear-gradient(to top, var(--primary), var(--secondary));
  border-radius: 4px 4px 2px 2px;
  height: 15%;
  transition: height 0.12s ease, background 0.8s ease;
  min-height: 4px;
}

/* ── Player ── */
.player-section { padding: 1.5rem; }
.player-header { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 2px; color: #64748b; margin-bottom: 1rem; }

#yt-player-container {
  width: 100%;
  aspect-ratio: 16/9;
  border-radius: 14px;
  overflow: hidden;
  background: #000;
  position: relative;
}
#yt-player-container iframe {
  width: 100%; height: 100%;
  border: none;
}

/* ── Playlist ── */
.playlist-section { padding: 1.5rem; }
.playlist-header { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 2px; color: #64748b; margin-bottom: 1rem; }

#playlist-grid {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.track-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.9rem 1rem;
  border-radius: 12px;
  background: rgba(0,0,0,0.2);
  border: 1px solid rgba(255,255,255,0.05);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
}
.track-card:hover { background: rgba(255,255,255,0.04); transform: translateX(4px); }
.track-card.active {
  background: rgba(139,92,246,0.1);
  border-color: rgba(139,92,246,0.3);
}
.track-num {
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; color: #64748b; font-weight: 700;
  flex-shrink: 0;
}
.track-meta { flex: 1; min-width: 0; }
.track-name { font-weight: 600; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.track-artist { font-size: 0.8rem; color: #94a3b8; margin-top: 0.15rem; }
.track-play-icon { color: var(--primary); font-size: 0.9rem; flex-shrink: 0; transition: color 0.3s; }
.track-card.active .track-play-icon { animation: pulse-icon 1s infinite; }

@keyframes pulse-icon {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ── Animations ── */
@keyframes fadeDown {
  from { opacity: 0; transform: translateY(-24px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(28px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Accessibility ── */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border-width: 0;
}

/* ── Responsive ── */
@media (max-width: 480px) {
  body { padding: 1rem 0.75rem 3rem; }
  .glass { padding: 1.25rem; border-radius: 18px; }
}
