/* ============================================================
   Imaning — new design system (v2)
   Dark music-app theme, gradient accents, card grid layout
   ============================================================ */

:root {
  --bg: #0b0b12;
  --surface: #14141f;
  --surface-2: #1c1c2b;
  --surface-3: #24243a;
  --line: rgba(255, 255, 255, 0.08);
  --text: #f2f2f7;
  --muted: #9a9ab0;
  --accent: #8b5cf6;
  --accent-2: #22d3ee;
  --gradient: linear-gradient(135deg, #8b5cf6 0%, #22d3ee 100%);
  --danger: #f43f5e;
  --success: #34d399;
  --warning: #fbbf24;
  --radius: 14px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background:
    radial-gradient(1000px 500px at 80% -10%, rgba(139, 92, 246, 0.18), transparent 60%),
    radial-gradient(800px 400px at 10% 10%, rgba(34, 211, 238, 0.10), transparent 60%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
img { display: block; }

/* ============ NAVBAR ============ */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(14px);
  background: rgba(11, 11, 18, 0.78);
  border-bottom: 1px solid var(--line);
}

.nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.2rem;
  letter-spacing: 0.4px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 18px rgba(139, 92, 246, 0.4);
}

.nav-links {
  display: flex;
  gap: 6px;
  margin-left: 12px;
}

.nav-link {
  padding: 9px 16px;
  border-radius: 10px;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.92rem;
  transition: all 0.18s ease;
}

.nav-link:hover { color: var(--text); background: var(--surface-2); }
.nav-link.active { color: #fff; background: var(--surface-3); }

.nav-search {
  margin-left: auto;
  flex: 0 1 320px;
  position: relative;
}

.nav-search input {
  width: 100%;
  padding: 10px 14px 10px 40px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
  transition: border 0.15s;
}

.nav-search input:focus { border-color: var(--accent); }
.nav-search svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  stroke: var(--muted);
}

.device-badge {
  font-size: 0.72rem;
  color: var(--muted);
  border: 1px solid var(--line);
  padding: 6px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

/* ============ LAYOUT ============ */
.wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 24px 120px;
}

.section { margin-bottom: 44px; }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 18px;
}

.section-head h2 {
  font-size: 1.35rem;
  font-weight: 700;
}

.section-sub { color: var(--muted); font-size: 0.88rem; }

/* ============ HERO ============ */
.hero {
  position: relative;
  border-radius: 20px;
  overflow: hidden;
  padding: 56px 44px;
  background:
    radial-gradient(600px 300px at 85% 20%, rgba(34, 211, 238, 0.35), transparent 70%),
    linear-gradient(135deg, #5b21b6 0%, #1e1b4b 55%, #0f172a 100%);
  box-shadow: var(--shadow);
  margin-bottom: 44px;
}

.hero h1 {
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  font-weight: 800;
  line-height: 1.1;
  margin-bottom: 10px;
}

.hero p { color: #c7d2fe; font-size: 1.02rem; margin-bottom: 22px; }

.hero-stats { display: flex; gap: 34px; margin-top: 20px; }
.hero-stat b { display: block; font-size: 1.6rem; }
.hero-stat span { color: #a5b4fc; font-size: 0.85rem; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: none;
  border-radius: 10px;
  padding: 11px 18px;
  font-weight: 700;
  font-size: 0.92rem;
  color: #fff;
  background: var(--gradient);
  transition: transform 0.12s, filter 0.12s;
}

.btn:hover { filter: brightness(1.1); transform: translateY(-1px); }
.btn-ghost { background: var(--surface-2); border: 1px solid var(--line); }
.btn-sm { padding: 8px 12px; font-size: 0.82rem; }
.btn-danger { background: rgba(244, 63, 94, 0.15); color: var(--danger); border: 1px solid rgba(244, 63, 94, 0.3); }
.btn-success { background: rgba(52, 211, 153, 0.15); color: var(--success); border: 1px solid rgba(52, 211, 153, 0.3); }

/* ============ SONG CARDS GRID ============ */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(185px, 1fr));
  gap: 18px;
}

.song-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}

.song-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.4);
  border-color: rgba(139, 92, 246, 0.45);
}

.cover {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  aspect-ratio: 1;
  background: var(--surface-3);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}

.cover svg.note { width: 40%; height: 40%; opacity: 0.85; }
.cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

.cover-actions {
  position: absolute;
  inset: auto 0 0 0;
  display: flex;
  gap: 8px;
  padding: 10px;
  transform: translateY(110%);
  transition: transform 0.18s ease;
}

.song-card:hover .cover-actions { transform: translateY(0); }

.icon-btn {
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 999px;
  background: rgba(10, 10, 16, 0.85);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(6px);
}

.icon-btn svg { width: 17px; height: 17px; }
.icon-btn.play { background: var(--gradient); }
.icon-btn:hover { filter: brightness(1.15); }

.song-title {
  font-weight: 700;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.song-artist {
  color: var(--muted);
  font-size: 0.84rem;
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.song-meta {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 0.75rem;
  color: var(--muted);
}

.chip {
  font-size: 0.7rem;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--muted);
  text-transform: capitalize;
}

/* ============ CHIPS (filters) ============ */
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }

.chip-btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 0.85rem;
  font-weight: 600;
}

.chip-btn.active { background: var(--gradient); color: #fff; border-color: transparent; }

/* ============ CHART LIST ============ */
.chart-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  margin-bottom: 8px;
  transition: border-color 0.15s;
}

.chart-row:hover { border-color: rgba(139, 92, 246, 0.4); }
.chart-rank { width: 26px; font-weight: 800; color: var(--muted); text-align: center; }
.chart-row .cover { width: 46px; height: 46px; margin: 0; flex-shrink: 0; }
.chart-info { flex: 1; min-width: 0; }
.chart-info .song-title { font-size: 0.9rem; }
.chart-plays { color: var(--muted); font-size: 0.78rem; margin-right: 10px; }

/* ============ PLAYLIST CARDS ============ */
.playlist-card {
  border-radius: var(--radius);
  padding: 20px;
  color: #fff;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  min-height: 130px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.playlist-card h3 { font-size: 1.05rem; margin-bottom: 4px; }
.playlist-card p { font-size: 0.8rem; opacity: 0.85; margin-bottom: 12px; }

/* ============ DOWNLOADS ============ */
.stats-row { display: flex; gap: 14px; margin-bottom: 24px; flex-wrap: wrap; }

.stat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 22px;
  min-width: 140px;
}

.stat-card b { font-size: 1.5rem; display: block; }
.stat-card span { color: var(--muted); font-size: 0.8rem; }

.download-row {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 10px;
}

.download-row .cover { width: 52px; height: 52px; margin: 0; flex-shrink: 0; }
.download-main { flex: 1; min-width: 0; }

.badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  text-transform: capitalize;
}

.badge.queued { background: rgba(154, 154, 176, 0.15); color: var(--muted); }
.badge.downloading { background: rgba(34, 211, 238, 0.15); color: var(--accent-2); }
.badge.completed { background: rgba(52, 211, 153, 0.15); color: var(--success); }
.badge.failed, .badge.cancelled { background: rgba(244, 63, 94, 0.15); color: var(--danger); }
.badge.paused { background: rgba(251, 191, 36, 0.15); color: var(--warning); }

.progress {
  height: 5px;
  border-radius: 999px;
  background: var(--surface-3);
  margin-top: 8px;
  overflow: hidden;
}

.progress > i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--gradient);
  transition: width 0.4s ease;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

.empty-state svg { width: 46px; height: 46px; stroke: var(--muted); margin-bottom: 12px; }

/* ============ PLAYER MODAL ============ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(6, 6, 12, 0.85);
  backdrop-filter: blur(8px);
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  width: min(700px, 96vw);
  box-shadow: var(--shadow);
}

.modal-head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.modal-head .cover { width: 52px; height: 52px; margin: 0; flex-shrink: 0; }
.modal-title { font-weight: 700; }
.modal-artist { color: var(--muted); font-size: 0.85rem; }
.modal-close { margin-left: auto; }

.player-frame {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
}

.player-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* ============ TOASTS ============ */
.toasts {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 950;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  color: var(--text);
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 0.87rem;
  max-width: 320px;
  box-shadow: var(--shadow);
  animation: slide-in 0.2s ease;
}

.toast.error { border-left-color: var(--danger); }
.toast.success { border-left-color: var(--success); }

@keyframes slide-in {
  from { transform: translateX(30px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ============ FOOTER / RESPONSIVE ============ */
.footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
  text-align: center;
  padding: 26px;
  font-size: 0.82rem;
}

@media (max-width: 760px) {
  .nav-search { display: none; }
  .nav-inner { flex-wrap: wrap; }
  .hero { padding: 34px 22px; }
  .card-grid { grid-template-columns: repeat(auto-fill, minmax(145px, 1fr)); }
  .device-badge { display: none; }
}

/* ============================================================
   NOW PLAYING bar — Imaning's own player UI
   The audio engine lives off-screen; only this bar is visible.
   ============================================================ */

#audio-engine-host {
  position: fixed;
  left: -9999px;
  top: 0;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.now-playing {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translate(-50%, 140%);
  width: min(560px, calc(100vw - 32px));
  background: rgba(20, 20, 31, 0.94);
  border: 1px solid rgba(139, 92, 246, 0.45);
  border-radius: 16px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(14px);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  z-index: 920;
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.now-playing.visible { transform: translate(-50%, 0); }

.np-cover {
  width: 46px;
  height: 46px;
  border-radius: 10px;
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.np-cover svg.note { width: 55%; height: 55%; opacity: 0.9; }
.np-cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

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

.np-title {
  font-weight: 700;
  font-size: 0.92rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.np-artist {
  color: var(--muted);
  font-size: 0.78rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Equalizer: animates only while playing */
.np-eq {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 22px;
  opacity: 0;
  transition: opacity 0.2s;
}

.np-eq.playing { opacity: 1; }

.np-eq i {
  width: 4px;
  height: 30%;
  border-radius: 2px;
  background: var(--gradient);
}

.np-eq.playing i { animation: eq 0.9s ease-in-out infinite; }
.np-eq.playing i:nth-child(2) { animation-delay: 0.15s; }
.np-eq.playing i:nth-child(3) { animation-delay: 0.3s; }
.np-eq.playing i:nth-child(4) { animation-delay: 0.45s; }

@keyframes eq {
  0%, 100% { height: 30%; }
  50% { height: 100%; }
}

/* ---------------- app promo (install link) ---------------- */
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.btn.ghost {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  border: 1px solid var(--line);
  box-shadow: none;
}
.btn.ghost:hover { background: rgba(255, 255, 255, 0.14); color: var(--text); }

.app-promo {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  margin: 34px 0 8px; padding: 20px;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.14), rgba(34, 211, 238, 0.08));
  border: 1px solid var(--line); border-radius: 18px;
}
.app-promo img { border-radius: 14px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45); }
.app-promo-text { flex: 1; min-width: 200px; }
.app-promo-text b { font-size: 1.02rem; display: block; margin-bottom: 4px; }
.app-promo-text p { color: var(--muted); font-size: 0.86rem; line-height: 1.5; }

.app-banner {
  position: fixed; right: 16px; bottom: 16px; z-index: 60;
  display: flex; align-items: center; gap: 12px;
  max-width: calc(100vw - 32px);
  padding: 12px 14px; padding-right: 34px;
  background: rgba(24, 24, 38, 0.97); backdrop-filter: blur(14px);
  border: 1px solid var(--line); border-radius: 16px;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.55);
  animation: bannerIn 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes bannerIn { from { transform: translateY(18px); opacity: 0; } to { transform: none; opacity: 1; } }
.app-banner img { border-radius: 9px; flex: none; }
.app-banner b { display: block; font-size: 0.85rem; }
.app-banner span { font-size: 0.72rem; color: var(--muted); }
.app-banner .btn { flex: none; padding: 8px 14px; font-size: 0.78rem; }
.app-banner-x {
  position: absolute; top: 4px; right: 6px;
  color: var(--muted); font-size: 1.05rem; line-height: 1;
  padding: 4px; border-radius: 50%;
}
.app-banner-x:hover { color: var(--text); }

@media (max-width: 640px) {
  .app-promo { padding: 16px; gap: 14px; }
  .app-promo .btn { width: 100%; text-align: center; justify-content: center; }
  .app-banner { left: 12px; right: 12px; bottom: 12px; }
  .app-banner span { display: none; }
}
