:root {
  --bg: #0a0a0a;
  --surface: #141414;
  --surface2: #1a1a1a;
  --border: #222;
  --border2: #2a2a2a;
  --text: #f0ede8;
  --muted: #555;
  --muted2: #888;
  --accent: #a855f7;
  --accent-dim: rgba(168, 85, 247, 0.10);
  --accent-border: rgba(168, 85, 247, 0.22);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Mono', monospace;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.04'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 9999;
  opacity: 0.5;
}

/* Header */
header {
  padding: calc(env(safe-area-inset-top, 0px) + 1.5rem) 1.25rem 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.header-left { display: flex; align-items: center; gap: 0.6rem; }
.logo-mark {
  width: 32px; height: 32px;
  background: var(--accent);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.logo-mark {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 1.1rem;
  color: #0a0a0a;
}
header h1 {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
}
header h1 span { color: var(--accent); }

#settings-btn {
  background: none;
  border: 1px solid var(--border2);
  border-radius: 8px;
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--muted2);
  transition: border-color 0.2s, color 0.2s;
  flex-shrink: 0;
}
#settings-btn:active { border-color: var(--accent); color: var(--accent); }
#settings-btn svg { width: 16px; height: 16px; }

/* Main */
main {
  flex: 1;
  padding: 1.25rem 1.25rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-width: 480px;
  width: 100%;
  margin: 0 auto;
}

/* Quick Share badge */
#qs-badge {
  display: none;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: var(--accent-dim);
  border: 1px solid var(--accent-border);
  border-radius: 8px;
  font-size: 0.68rem;
  color: var(--accent);
  letter-spacing: 0.04em;
}
#qs-badge.visible { display: flex; }
.qs-dot {
  width: 6px; height: 6px;
  background: var(--accent);
  border-radius: 50%;
  flex-shrink: 0;
  animation: pulse 2s ease infinite;
}
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.3} }

/* Input */
.input-area { display: flex; flex-direction: column; gap: 0.6rem; }
.input-label {
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.input-row { display: flex; gap: 0.5rem; }
#url-input {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  color: var(--text);
  font-family: 'DM Mono', monospace;
  font-size: 0.78rem;
  outline: none;
  transition: border-color 0.2s;
  min-width: 0;
}
#url-input::placeholder { color: var(--muted); }
#url-input:focus { border-color: var(--accent); }
#go-btn {
  background: var(--accent);
  color: #0a0a0a;
  border: none;
  border-radius: 10px;
  padding: 0.85rem 1.15rem;
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  white-space: nowrap;
  flex-shrink: 0;
}
#go-btn:active { opacity: 0.8; transform: scale(0.97); }
#go-btn:disabled { opacity: 0.35; }

/* Loading */
#loading {
  display: none;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0;
  font-size: 0.75rem;
  color: var(--muted2);
}
.spinner {
  width: 16px; height: 16px;
  border: 2px solid var(--border2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Error */
#error-msg {
  display: none;
  background: rgba(255,80,80,0.08);
  border: 1px solid rgba(255,80,80,0.2);
  border-radius: 10px;
  padding: 0.8rem 1rem;
  font-size: 0.75rem;
  color: #ff8080;
  animation: slideUp 0.25s ease;
}

/* Song card */
#song-card {
  display: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  animation: slideUp 0.28s ease;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.song-meta {
  display: flex;
  gap: 0.85rem;
  padding: 1rem;
  align-items: center;
  border-bottom: 1px solid var(--border);
}
#album-art {
  width: 52px; height: 52px;
  border-radius: 7px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--border);
}
.song-info { min-width: 0; flex: 1; }
.song-title {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.song-artist {
  font-size: 0.72rem;
  color: var(--muted2);
  margin-top: 0.2rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.section-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 1rem 0.4rem;
}
.section-label {
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.show-all-btn {
  background: none;
  border: none;
  font-family: 'DM Mono', monospace;
  font-size: 0.65rem;
  color: var(--muted2);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.show-all-btn:active { color: var(--accent); }

/* Platform rows */
#platforms-list { list-style: none; }
.platform-item {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.8rem 1rem;
  border-top: 1px solid var(--border);
  text-decoration: none;
  color: var(--text);
  transition: background 0.12s;
  animation: fadeIn 0.2s ease both;
}
.platform-item:active { background: rgba(255,255,255,0.04); }
@keyframes fadeIn { from{opacity:0} to{opacity:1} }

.platform-icon {
  width: 34px; height: 34px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: 1rem;
}
.platform-name {
  flex: 1;
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 0.88rem;
}
.copy-btn {
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 6px;
  padding: 0.3rem 0.55rem;
  font-family: 'DM Mono', monospace;
  font-size: 0.6rem;
  color: var(--muted2);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  flex-shrink: 0;
}
.copy-btn.copied { border-color: var(--accent); color: var(--accent); }
.platform-arrow { color: var(--muted); font-size: 0.75rem; flex-shrink: 0; }

/* Copy All */
#copy-all-wrap {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
}
#copy-all-btn {
  width: 100%;
  background: var(--accent-dim);
  border: 1px solid var(--accent-border);
  border-radius: 9px;
  padding: 0.7rem 1rem;
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--accent);
  cursor: pointer;
  transition: background 0.15s;
  letter-spacing: 0.02em;
}
#copy-all-btn:active { background: rgba(168,85,247,0.18); }
#copy-all-btn.copied { color: #7c3aed; border-color: rgba(124,58,237,0.3); }

#share-btn {
  display: none;
  width: 100%;
  background: var(--accent);
  border: none;
  border-radius: 9px;
  padding: 0.85rem 1rem;
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 0.88rem;
  color: #0a0a0a;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  letter-spacing: 0.02em;
  margin-bottom: 0.5rem;
}
#share-btn:active { opacity: 0.85; transform: scale(0.98); }
#share-btn.pulse {
  animation: sharePulse 1.4s ease infinite;
}
@keyframes sharePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(168,85,247,0.5); }
  50%       { box-shadow: 0 0 0 10px rgba(168,85,247,0); }
}

/* Install */
#install-prompt {
  display: none;
  padding: 0.9rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  text-align: center;
}
#install-prompt p { font-size: 0.72rem; color: var(--muted2); margin-bottom: 0.65rem; line-height: 1.5; }
#install-btn {
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 7px;
  padding: 0.55rem 1.1rem;
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 0.78rem;
  cursor: pointer;
}

footer {
  padding: 1.25rem;
  text-align: center;
  font-size: 0.6rem;
  color: #2a2a2a;
  letter-spacing: 0.05em;
}

/* ════ Settings Drawer ════ */
#settings-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
  backdrop-filter: blur(2px);
}
#settings-overlay.open { opacity: 1; pointer-events: all; }

#settings-drawer {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 101;
  background: #111;
  border-top: 1px solid var(--border2);
  border-radius: 20px 20px 0 0;
  padding-bottom: env(safe-area-inset-bottom, 1rem);
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.32,0.72,0,1);
  max-height: 88dvh;
  display: flex;
  flex-direction: column;
}
#settings-drawer.open { transform: translateY(0); }

.drawer-handle {
  width: 36px; height: 4px;
  background: var(--border2);
  border-radius: 2px;
  margin: 0.85rem auto 0;
  flex-shrink: 0;
}
.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem 0.75rem;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
}
.drawer-title {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 1.05rem;
}
#close-settings {
  background: none; border: none;
  color: var(--muted2);
  font-size: 1.2rem;
  cursor: pointer;
  line-height: 1;
  padding: 0.25rem;
}
.drawer-body {
  overflow-y: auto;
  flex: 1;
  padding: 1.1rem 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.settings-section { display: flex; flex-direction: column; gap: 0.55rem; }
.settings-section-title {
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Toggle row */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  gap: 0.75rem;
}
.toggle-info { flex: 1; min-width: 0; }
.toggle-label { font-family: 'Syne', sans-serif; font-weight: 700; font-size: 0.88rem; }
.toggle-desc { font-size: 0.68rem; color: var(--muted2); margin-top: 0.2rem; line-height: 1.4; }

.toggle { position: relative; width: 44px; height: 26px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-track {
  position: absolute; inset: 0;
  background: var(--border2);
  border-radius: 13px;
  cursor: pointer;
  transition: background 0.2s;
}
.toggle-track::after {
  content: '';
  position: absolute;
  left: 3px; top: 3px;
  width: 20px; height: 20px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}
.toggle input:checked + .toggle-track { background: var(--accent); }
.toggle input:checked + .toggle-track::after { transform: translateX(18px); }

/* Source picker */
#source-picker { display: flex; flex-direction: column; gap: 0.4rem; margin-top: 0.25rem; }

.source-item {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.7rem 0.9rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  user-select: none;
}
.source-item.selected {
  border-color: var(--accent-border);
  background: var(--accent-dim);
}
.source-radio {
  width: 20px; height: 20px;
  border: 1.5px solid var(--border2);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: border-color 0.15s;
}
.source-item.selected .source-radio { border-color: var(--accent); }
.source-radio::after {
  content: '';
  width: 10px; height: 10px;
  background: var(--accent);
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.1s;
}
.source-item.selected .source-radio::after { opacity: 1; }

/* Platform checklist */
#platform-checklist { display: flex; flex-direction: column; gap: 0.4rem; margin-top: 0.25rem; }

.platform-check-item {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.7rem 0.9rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  user-select: none;
}
.platform-check-item.checked {
  border-color: var(--accent-border);
  background: var(--accent-dim);
}
.check-icon {
  width: 30px; height: 30px;
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.9rem;
  flex-shrink: 0;
}
.check-name {
  flex: 1;
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 0.85rem;
}
.checkmark {
  width: 20px; height: 20px;
  border: 1.5px solid var(--border2);
  border-radius: 5px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
}
.platform-check-item.checked .checkmark { background: var(--accent); border-color: var(--accent); }
.checkmark svg { width: 11px; height: 11px; opacity: 0; transition: opacity 0.1s; }
.platform-check-item.checked .checkmark svg { opacity: 1; }

.hint-text { font-size: 0.68rem; color: var(--muted); line-height: 1.5; }
