/* ── Reset & base ────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --font: 'Inter', system-ui, sans-serif;
  --radius: 18px;
  --radius-sm: 10px;
  --glass: rgba(255,255,255,0.10);
  --glass-border: rgba(255,255,255,0.18);
  --shadow: 0 8px 32px rgba(0,0,0,0.25);
  --transition: 0.8s cubic-bezier(0.4,0,0.2,1);

  /* Mood palettes */
  --c1: #667eea; --c2: #764ba2;           /* neutral */
  --accent: #a78bfa;
  --text: #fff;
}

/* Mood themes – sets --c1, --c2, --accent */
body.mood-happy     { --c1:#f7971e; --c2:#ffd200; --accent:#ffe066; }
body.mood-party     { --c1:#f953c6; --c2:#b91d73; --accent:#ff6ef7; }
body.mood-chill     { --c1:#0099f7; --c2:#00c9a7; --accent:#7ff9e2; }
body.mood-romantic  { --c1:#fc5c7d; --c2:#9b59b6; --accent:#f8a5c2; }
body.mood-melancholic{--c1:#2c3e50; --c2:#4a5568; --accent:#90cdf4; }
body.mood-tense     { --c1:#c0392b; --c2:#8b0000; --accent:#fc4040; }
body.mood-energetic { --c1:#11998e; --c2:#38ef7d; --accent:#00f5a0; }
body.mood-focused   { --c1:#1a1a2e; --c2:#16213e; --accent:#60a5fa; }
body.mood-neutral   { --c1:#667eea; --c2:#764ba2; --accent:#a78bfa; }

html { font-family: var(--font); scroll-behavior: smooth; }

body {
  min-height: 100vh;
  color: var(--text);
  background: #0a0a0a;
  overflow-x: hidden;
}

/* ── Canvas (particles) ──────────────────────────────────────────────────── */
#canvas {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 0;
}

/* ── Utility ─────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
html[data-auth="1"] #app { display: block !important; }
a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Auth screen ─────────────────────────────────────────────────────────── */
#auth-screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  z-index: 10;
  padding: 1rem;
}

.auth-card {
  background: var(--glass);
  backdrop-filter: blur(24px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 3rem 2.5rem;
  max-width: 420px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow);
  animation: fadeUp .6s ease both;
}

.auth-logo {
  display: flex; justify-content: center; margin-bottom: 1.5rem;
  color: #1DB954;
  filter: drop-shadow(0 0 12px #1DB954aa);
}

.auth-card h1 {
  font-size: 2rem; font-weight: 800; margin-bottom: .75rem;
}

.auth-card p {
  font-size: .95rem; opacity: .8; line-height: 1.6; margin-bottom: 2rem;
}

.btn-spotify {
  display: inline-flex; align-items: center; gap: .5rem;
  background: #1DB954;
  color: #000;
  font-weight: 700; font-size: 1rem;
  padding: .85rem 2rem;
  border-radius: 50px;
  transition: transform .2s, box-shadow .2s;
  box-shadow: 0 4px 20px #1DB95460;
}

.btn-spotify:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px #1DB95480;
  text-decoration: none;
}

.auth-note {
  font-size: .75rem; opacity: .5; margin-top: 1rem; margin-bottom: 0;
}

/* ── Main app layout ─────────────────────────────────────────────────────── */
#app {
  position: relative; z-index: 1;
  max-width: 800px; margin: 0 auto;
  padding: 0 1.25rem 3rem;
}

/* ── Header ──────────────────────────────────────────────────────────────── */
header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.5rem 0;
  position: sticky; top: 0; z-index: 5;
}

.header-logo {
  display: flex; align-items: center; gap: .5rem;
  font-weight: 700; font-size: 1.05rem;
  color: #1DB954;
  filter: drop-shadow(0 0 6px #1DB95466);
}

.live-badge {
  display: flex; align-items: center; gap: .4rem;
  background: var(--glass);
  backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: 50px;
  padding: .35rem .9rem;
  font-size: .78rem; font-weight: 600;
}

.live-dot {
  width: 7px; height: 7px;
  background: #1DB954;
  border-radius: 50%;
  animation: pulseDot 1.5s infinite;
}

/* ── Now playing ─────────────────────────────────────────────────────────── */
.now-playing-section { margin-bottom: 2.5rem; }

.now-playing-card, .not-playing-card {
  background: var(--glass);
  backdrop-filter: blur(24px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: fadeUp .5s ease both;
}

.np-header {
  display: flex; align-items: center; gap: .5rem;
  padding: .85rem 1.25rem;
  font-size: .78rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  background: rgba(0,0,0,.15);
  opacity: .9;
}

/* Equalizer bars animation */
.np-equalizer {
  display: flex; align-items: flex-end; gap: 2px; height: 14px;
}
.np-equalizer span {
  width: 3px; border-radius: 2px;
  background: #1DB954;
  animation: equalize 1s ease-in-out infinite alternate;
}
.np-equalizer span:nth-child(1) { height: 8px;  animation-delay: 0s; }
.np-equalizer span:nth-child(2) { height: 14px; animation-delay: .2s; }
.np-equalizer span:nth-child(3) { height: 6px;  animation-delay: .4s; }
.np-equalizer span:nth-child(4) { height: 12px; animation-delay: .1s; }

.np-body {
  display: flex; gap: 1.25rem; padding: 1.25rem; align-items: flex-start;
}

.album-art {
  width: 100px; height: 100px; min-width: 100px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  box-shadow: 0 4px 20px rgba(0,0,0,.35);
  transition: transform .3s;
}
.album-art:hover { transform: scale(1.04); }

.np-info { flex: 1; min-width: 0; }

.track-name {
  display: block;
  font-size: 1.15rem; font-weight: 700; line-height: 1.3;
  margin-bottom: .25rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.track-name:hover { text-decoration: underline; }

.track-artist { font-size: .9rem; opacity: .85; font-weight: 500; margin-bottom: .15rem; }
.track-album  { font-size: .78rem; opacity: .55; margin-bottom: .75rem; }

.progress-wrap { margin-top: .25rem; }

.progress-bar {
  height: 4px; border-radius: 50px;
  background: rgba(255,255,255,.2);
  overflow: hidden; margin-bottom: .4rem;
}

.progress-fill {
  height: 100%; border-radius: 50px;
  background: linear-gradient(90deg, var(--accent), #1DB954);
  transition: width .5s linear;
}

.progress-times {
  display: flex; justify-content: space-between;
  font-size: .7rem; opacity: .5;
}

.not-playing-card {
  text-align: center; padding: 3rem 1.5rem;
}
.np-icon { font-size: 3rem; margin-bottom: .75rem; }
.not-playing-card p { font-size: 1rem; opacity: .8; margin-bottom: .3rem; }
.not-playing-card small { opacity: .5; font-size: .82rem; }

/* ── Mood Canvas Card (Spotify-style) ────────────────────────────────────── */
.mood-canvas-section { margin-bottom: 2.5rem; }

.mood-canvas-card {
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  background: #121212;
  animation: fadeUp .5s ease both;
}

.mc-gradient {
  height: 164px;
  background: linear-gradient(160deg, var(--c1) 0%, var(--c2) 52%, #121212 100%);
  transition: background var(--transition);
  display: flex;
  align-items: flex-end;
  padding: 0 1.5rem 0;
}

.mc-emoji-wrap {
  width: 86px; height: 86px;
  background: rgba(0,0,0,.32);
  border: 3px solid rgba(255,255,255,.18);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 28px rgba(0,0,0,.55);
  transform: translateY(43px);
  transition: border-color var(--transition);
  flex-shrink: 0;
}

.mc-emoji {
  font-size: 2.8rem; line-height: 1;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,.4));
  animation: floatIcon 4s ease-in-out infinite;
}

.mc-body {
  padding: 3.5rem 1.5rem 1.75rem;
  display: flex; flex-direction: column;
  gap: .45rem;
}

.mc-type {
  font-size: .62rem; font-weight: 700;
  letter-spacing: .16em; text-transform: uppercase;
  opacity: .42;
}

.mc-name {
  font-size: 2.15rem; font-weight: 900; line-height: 1.1;
  color: #fff;
}

.mc-desc {
  font-size: .88rem; opacity: .62; line-height: 1.55;
  margin-bottom: .35rem;
}

.mc-moods {
  display: flex; flex-wrap: wrap; gap: .45rem;
  margin-top: .6rem;
}

.mc-chip {
  display: flex; align-items: center; gap: .38rem;
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 50px;
  padding: .32rem .78rem;
  font-size: .75rem; font-weight: 500;
  opacity: .42;
  transition: background .3s, border-color .3s, opacity .3s, transform .2s, box-shadow .3s;
  user-select: none;
  cursor: default;
}

.mc-chip.active {
  background: rgba(255,255,255,.14);
  border-color: var(--accent);
  color: #fff;
  opacity: 1;
  font-weight: 700;
  transform: scale(1.07);
  box-shadow: 0 0 14px var(--accent);
}

.mc-source {
  display: flex; align-items: center; gap: .45rem;
  font-size: .7rem; opacity: .38;
  margin-top: .6rem;
}

.mc-dot {
  width: 6px; height: 6px; flex-shrink: 0;
  background: #1DB954; border-radius: 50%;
}

/* ── Recent tracks ───────────────────────────────────────────────────────── */
.recent-section { margin-bottom: 2.5rem; }

.section-title {
  display: flex; align-items: center; gap: .5rem;
  font-size: 1.1rem; font-weight: 700; margin-bottom: 1rem;
  opacity: .9;
}

.recent-list { display: flex; flex-direction: column; gap: .5rem; }

.track-row {
  display: flex; align-items: center; gap: 1rem;
  background: var(--glass);
  backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: .65rem .9rem;
  transition: transform .15s, background .15s;
  animation: fadeUp .4s ease both;
  cursor: pointer;
}
.track-row:hover {
  transform: translateX(4px);
  background: rgba(255,255,255,.16);
  text-decoration: none;
}

.track-row-num {
  font-size: .72rem; font-weight: 700; opacity: .4;
  width: 18px; text-align: center; flex-shrink: 0;
}

.track-row-art {
  width: 44px; height: 44px; min-width: 44px;
  border-radius: 6px; object-fit: cover;
  background: rgba(255,255,255,.1);
}

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

.track-row-name {
  font-size: .9rem; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.track-row-artist {
  font-size: .75rem; opacity: .6; margin-top: .1rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.track-row-time {
  font-size: .7rem; opacity: .45; flex-shrink: 0; margin-left: .5rem;
}

/* Skeleton loading */
.skeleton-list { display: flex; flex-direction: column; gap: .5rem; }

.skeleton-item {
  height: 60px; border-radius: var(--radius-sm);
  background: linear-gradient(90deg, rgba(255,255,255,.05) 25%, rgba(255,255,255,.12) 50%, rgba(255,255,255,.05) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

/* ── History card (last played track when nothing is live) ───────────────── */
.history-card {
  display: flex; gap: 1rem; padding: 1.25rem; align-items: center;
}

.history-art {
  width: 80px; height: 80px; min-width: 80px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  box-shadow: 0 4px 16px rgba(0,0,0,.3);
}

.history-art-placeholder {
  width: 80px; height: 80px; min-width: 80px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,.1);
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem;
}

.history-info { flex: 1; min-width: 0; }

.history-badge {
  font-size: .7rem; font-weight: 600; opacity: .6;
  margin-bottom: .4rem; letter-spacing: .05em;
}

.history-name {
  display: block; font-size: 1rem; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-bottom: .2rem;
}
.history-name:hover { text-decoration: underline; }

.history-artist { font-size: .85rem; opacity: .75; }
.history-album  { font-size: .75rem; opacity: .5; margin-top: .1rem; }

/* ── Footer ──────────────────────────────────────────────────────────────── */
footer {
  text-align: center; font-size: .75rem; opacity: .4;
  padding-top: 1rem;
}
footer a { opacity: .8; }

/* ── Keyframes ───────────────────────────────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes floatIcon {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-10px); }
}

@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: .4; transform: scale(.7); }
}

@keyframes equalize {
  from { transform: scaleY(.4); }
  to   { transform: scaleY(1); }
}

@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 500px) {
  .np-body { flex-direction: column; }
  .album-art { width: 100%; height: 200px; min-width: unset; }
  .history-card { flex-direction: column; text-align: center; }
  .mc-gradient { height: 130px; }
  .mc-emoji-wrap { width: 72px; height: 72px; transform: translateY(36px); }
  .mc-emoji { font-size: 2.2rem; }
  .mc-name { font-size: 1.7rem; }
  .mc-body { padding: 3rem 1.1rem 1.5rem; }
}
