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

:root {
  --primary: #7c3aed;
  --primary-light: #a78bfa;
  --accent: #06b6d4;
  --bg: #0a0a0f;
  --surface: #12121a;
  --surface2: #1c1c28;
  --border: rgba(255,255,255,0.08);
  --text: #f1f0f7;
  --text-muted: #8b8a9e;
  --suno: #7c3aed;
  --udio: #0ea5e9;
  --radius: 16px;
  --shadow: 0 8px 32px rgba(0,0,0,0.4);
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

.bg-orbs { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.18;
}
.orb-1 { width: 600px; height: 600px; background: var(--primary); top: -200px; left: -200px; }
.orb-2 { width: 400px; height: 400px; background: var(--accent); bottom: -100px; right: -100px; }
.orb-3 { width: 300px; height: 300px; background: #ec4899; top: 50%; left: 60%; }

header {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 40px;
  background: rgba(10,10,15,0.8);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}

.logo { display: flex; align-items: center; gap: 10px; }
.logo-icon { font-size: 24px; }
.logo-text { font-size: 22px; font-weight: 800; letter-spacing: -0.5px; }
.accent { color: var(--primary-light); }

.nav-links { display: flex; gap: 28px; }
.nav-links a {
  color: var(--text-muted); text-decoration: none;
  font-size: 14px; font-weight: 500;
  transition: color 0.2s;
}
.nav-links a:hover { color: var(--text); }

main { position: relative; z-index: 1; max-width: 860px; margin: 0 auto; padding: 60px 24px 80px; }

.hero { text-align: center; margin-bottom: 60px; }
.hero h1 { font-size: clamp(2rem, 5vw, 3.2rem); font-weight: 800; line-height: 1.15; margin-bottom: 16px; letter-spacing: -1px; }
.gradient-text {
  background: linear-gradient(135deg, var(--primary-light) 0%, var(--accent) 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.subtitle { color: var(--text-muted); font-size: 17px; margin-bottom: 36px; max-width: 520px; margin-left: auto; margin-right: auto; }

.search-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 24px;
  box-shadow: var(--shadow);
}

.input-row { display: flex; gap: 12px; }

#urlInput {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 18px;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}
#urlInput:focus { border-color: var(--primary-light); }
#urlInput::placeholder { color: var(--text-muted); }

#fetchBtn {
  background: linear-gradient(135deg, var(--primary) 0%, #5b21b6 100%);
  color: white;
  border: none;
  border-radius: 12px;
  padding: 14px 28px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
  display: flex; align-items: center; gap: 8px;
  white-space: nowrap;
}
#fetchBtn:hover { opacity: 0.9; }
#fetchBtn:active { transform: scale(0.98); }
#fetchBtn:disabled { opacity: 0.5; cursor: not-allowed; }

.platform-badges { margin-top: 14px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.badge {
  font-size: 12px; font-weight: 600; padding: 4px 12px;
  border-radius: 99px;
}
.badge-suno { background: rgba(124,58,237,0.2); color: var(--primary-light); border: 1px solid rgba(124,58,237,0.3); }
.badge-udio { background: rgba(14,165,233,0.15); color: #38bdf8; border: 1px solid rgba(14,165,233,0.3); }
.badge-hint { color: var(--text-muted); font-size: 12px; margin-left: auto; }

.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.hidden { display: none !important; }

.result { margin-bottom: 50px; animation: slideUp 0.4s ease; }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

.song-card {
  display: flex; gap: 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 28px;
  box-shadow: var(--shadow);
}

.song-cover-wrap { position: relative; flex-shrink: 0; }
#songCover {
  width: 180px; height: 180px;
  border-radius: 14px;
  object-fit: cover;
  background: var(--surface2);
  display: block;
}
.platform-badge {
  position: absolute; top: 10px; left: 10px;
  font-size: 11px; font-weight: 700; padding: 3px 10px;
  border-radius: 99px; text-transform: uppercase; letter-spacing: 0.5px;
}
.platform-suno { background: rgba(124,58,237,0.85); color: white; }
.platform-udio { background: rgba(14,165,233,0.85); color: white; }

.song-info { flex: 1; min-width: 0; }
.song-meta { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.meta-platform { font-size: 13px; color: var(--text-muted); font-weight: 500; }
.meta-duration { font-size: 13px; color: var(--text-muted); }

#songTitle { font-size: 22px; font-weight: 700; margin-bottom: 6px; line-height: 1.3; }
#songArtist { color: var(--text-muted); font-size: 15px; margin-bottom: 14px; }

.tag-list { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 24px; }
.tag {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12px; padding: 3px 10px; border-radius: 99px;
}

.download-buttons { display: flex; gap: 12px; flex-wrap: wrap; }
.btn-download {
  display: flex; align-items: center; gap: 8px;
  border: none; border-radius: 12px;
  padding: 12px 22px;
  font-size: 14px; font-weight: 600; font-family: inherit;
  cursor: pointer; transition: opacity 0.2s, transform 0.1s;
}
.btn-download:hover { opacity: 0.88; }
.btn-download:active { transform: scale(0.97); }
.btn-mp3 { background: linear-gradient(135deg, var(--primary), #5b21b6); color: white; }
.btn-img { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }

.error-section { margin-bottom: 40px; animation: slideUp 0.3s ease; }
.error-card {
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.3);
  border-radius: 14px;
  padding: 18px 22px;
  display: flex; align-items: center; gap: 14px;
}
.error-icon { font-size: 22px; }
#errorMsg { color: #fca5a5; font-size: 15px; }

.how-section { margin-bottom: 60px; }
.how-section h2, .history-section h2 { font-size: 22px; font-weight: 700; margin-bottom: 28px; }

.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; }
.step {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
}
.step-num {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--primary), #5b21b6);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 18px; margin-bottom: 14px;
}
.step h3 { font-size: 16px; font-weight: 600; margin-bottom: 8px; }
.step p { color: var(--text-muted); font-size: 14px; line-height: 1.6; }

.history-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.btn-clear {
  background: transparent; border: 1px solid var(--border);
  color: var(--text-muted); border-radius: 8px;
  padding: 6px 14px; font-size: 13px; font-family: inherit;
  cursor: pointer; transition: border-color 0.2s, color 0.2s;
}
.btn-clear:hover { border-color: #ef4444; color: #ef4444; }

.history-list { display: flex; flex-direction: column; gap: 12px; }
.empty-history {
  text-align: center; padding: 48px 0;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: 16px;
}
.empty-history span { font-size: 32px; display: block; margin-bottom: 10px; }
.empty-history p { font-size: 15px; }

.history-item {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 14px 18px;
  cursor: pointer; transition: border-color 0.2s;
}
.history-item:hover { border-color: var(--primary-light); }
.history-thumb {
  width: 50px; height: 50px;
  border-radius: 8px; object-fit: cover;
  background: var(--surface2); flex-shrink: 0;
}
.history-info { flex: 1; min-width: 0; }
.history-title { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-artist { font-size: 13px; color: var(--text-muted); }
.history-platform {
  font-size: 11px; font-weight: 700; padding: 2px 8px;
  border-radius: 99px; text-transform: uppercase;
}
.history-del {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; font-size: 18px; padding: 4px;
  transition: color 0.2s;
}
.history-del:hover { color: #ef4444; }

footer {
  position: relative; z-index: 1;
  text-align: center;
  padding: 24px;
  color: var(--text-muted);
  font-size: 13px;
  border-top: 1px solid var(--border);
}

@media (max-width: 640px) {
  header { padding: 14px 20px; }
  .nav-links { gap: 16px; }
  main { padding: 40px 16px 60px; }
  .song-card { flex-direction: column; }
  #songCover { width: 100%; height: 220px; }
  .input-row { flex-direction: column; }
  #fetchBtn { width: 100%; justify-content: center; }
  .badge-hint { display: none; }
}
