/* LyricLens — editorial music palette */

:root {
  --bg: #0a0a12;
  --bg2: #12121e;
  --bg3: #1a1a2e;
  --surface: #1e1e32;
  --surface2: #252540;
  --border: #2e2e50;
  --accent: #7c5cfc;
  --accent2: #a855f7;
  --accent3: #06b6d4;
  --text: #e8e8f0;
  --text2: #a0a0c0;
  --text3: #606080;
  --error: #f87171;
  --success: #34d399;
  --warn: #fbbf24;
  --gradient: linear-gradient(135deg, #7c5cfc 0%, #a855f7 50%, #06b6d4 100%);
  --vinyl: linear-gradient(135deg, #1a0533 0%, #0a0a12 40%, #001a2e 100%);
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(124, 92, 252, 0.15);
  --shadow-lg: 0 8px 48px rgba(124, 92, 252, 0.25);
}

[data-theme="light"] {
  --bg: #f8f7ff;
  --bg2: #f0effe;
  --bg3: #e8e5fd;
  --surface: #fff;
  --surface2: #f3f0ff;
  --border: #d4cfff;
  --text: #1a1830;
  --text2: #4a4870;
  --text3: #8a88a0;
  --shadow: 0 4px 24px rgba(124, 92, 252, 0.1);
  --shadow-lg: 0 8px 48px rgba(124, 92, 252, 0.15);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  transition: background 0.3s, color 0.3s;
}

/* ── Typography ── */
h1, h2, h3 { line-height: 1.2; }

/* ── Layout ── */
.app-shell {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100vh;
}

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* ── Header ── */
header {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 1rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.wordmark {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
}

.wordmark-icon {
  width: 36px;
  height: 36px;
  background: var(--gradient);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.wordmark-icon svg { width: 20px; height: 20px; fill: white; }

.wordmark-text {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.icon-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text2);
  cursor: pointer;
  padding: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.875rem;
  transition: all 0.2s;
}
.icon-btn:hover { background: var(--surface); color: var(--text); border-color: var(--accent); }
.icon-btn svg { width: 16px; height: 16px; }

/* ── Main ── */
main { padding: 2rem 0 4rem; }

/* ── Hero search ── */
.hero {
  text-align: center;
  padding: 3rem 0 2.5rem;
}

.hero-title {
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 0.75rem;
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-sub {
  color: var(--text2);
  font-size: 1.05rem;
  margin-bottom: 2rem;
}

/* ── Search form ── */
.search-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.25rem;
  box-shadow: var(--shadow);
  max-width: 680px;
  margin: 0 auto 1.5rem;
}

.search-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

@media (max-width: 540px) {
  .search-row { grid-template-columns: 1fr; }
}

.field-wrap {
  position: relative;
}

.field-wrap input {
  width: 100%;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.95rem;
  padding: 0.7rem 1rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.field-wrap input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124,92,252,0.15); }
.field-wrap input::placeholder { color: var(--text3); }

.field-wrap .field-label {
  position: absolute;
  top: -0.55rem;
  left: 0.75rem;
  background: var(--surface);
  color: var(--text3);
  font-size: 0.72rem;
  padding: 0 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.btn-primary {
  background: var(--gradient);
  border: none;
  border-radius: var(--radius-sm);
  color: white;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.75rem 1.75rem;
  width: 100%;
  transition: opacity 0.2s, transform 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}
.btn-primary:hover { opacity: 0.9; }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.6rem 1.25rem;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.btn-secondary:hover { background: var(--surface2); border-color: var(--accent); color: var(--accent); }

.btn-icon {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text2);
  cursor: pointer;
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  transition: all 0.2s;
}
.btn-icon:hover { border-color: var(--accent); color: var(--accent); background: var(--surface2); }
.btn-icon svg { width: 14px; height: 14px; }

/* ── Autocomplete ── */
.autocomplete-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  overflow: hidden;
  max-height: 220px;
  overflow-y: auto;
}

.autocomplete-item {
  padding: 0.6rem 1rem;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.15s;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text2);
}
.autocomplete-item:hover, .autocomplete-item.active { background: var(--surface2); color: var(--text); }
.autocomplete-item .autocomplete-title { color: var(--text); font-weight: 500; }
.autocomplete-item .autocomplete-artist { font-size: 0.8rem; color: var(--text3); }

/* ── Lyrics result card ── */
.result-area { margin-top: 2rem; }

.result-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.song-info h2 {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.25rem;
}

.song-info .artist-name {
  color: var(--accent2);
  font-size: 1rem;
  font-weight: 500;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.6rem;
}

.badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-source {
  background: rgba(124,92,252,0.15);
  color: var(--accent);
  border: 1px solid rgba(124,92,252,0.3);
}
.badge-ai { background: rgba(6,182,212,0.15); color: var(--accent3); border: 1px solid rgba(6,182,212,0.3); }
.badge-mood { background: rgba(52,211,153,0.15); color: var(--success); border: 1px solid rgba(52,211,153,0.3); }
.badge-lang { background: rgba(251,191,36,0.15); color: var(--warn); border: 1px solid rgba(251,191,36,0.3); }

.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

/* ── Tabs ── */
.tab-bar {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.25rem;
  gap: 0;
}

.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text3);
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.6rem 1.1rem;
  transition: all 0.2s;
  margin-bottom: -1px;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Lyrics view ── */
.lyrics-view {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  box-shadow: var(--shadow);
}

.lyrics-plain {
  font-family: 'Georgia', 'Times New Roman', serif;
  font-size: 1.05rem;
  line-height: 1.9;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

/* Synced lyrics */
.lrc-line {
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: 'Georgia', serif;
  font-size: 1rem;
  line-height: 1.8;
  color: var(--text2);
}
.lrc-line:hover { background: var(--surface2); color: var(--text); }
.lrc-line.lrc-active {
  background: rgba(124,92,252,0.12);
  color: var(--text);
  font-weight: 600;
  font-size: 1.1rem;
}

/* ── Meaning view ── */
.meaning-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.meaning-section {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}
.meaning-section:last-child { border-bottom: none; }

.meaning-section h3 {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 0.6rem;
}

.meaning-section p, .meaning-section ul, .meaning-section ol {
  color: var(--text2);
  font-size: 0.95rem;
  line-height: 1.7;
}

.meaning-section ul, .meaning-section ol { padding-left: 1.25rem; }
.meaning-section li { margin-bottom: 0.3rem; }

.verse-item {
  background: var(--bg2);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 0.75rem 1rem;
  margin-bottom: 0.75rem;
}
.verse-item .verse-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.3rem;
}
.verse-item p { color: var(--text2); font-size: 0.9rem; }

/* Similar songs */
.similar-list {
  display: grid;
  gap: 0.5rem;
}

.similar-item {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: all 0.2s;
}
.similar-item:hover { border-color: var(--accent); background: var(--surface2); }
.similar-item .sim-title { font-weight: 500; font-size: 0.9rem; }
.similar-item .sim-artist { color: var(--text3); font-size: 0.8rem; }

/* Web meaning results */
.web-results { display: grid; gap: 0.75rem; }

.web-result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem 1.25rem;
  transition: border-color 0.2s;
}
.web-result-card:hover { border-color: var(--accent); }
.web-result-card h4 { font-size: 0.95rem; font-weight: 600; margin-bottom: 0.4rem; color: var(--text); }
.web-result-card p { font-size: 0.875rem; color: var(--text2); line-height: 1.5; }
.web-result-card .web-source { font-size: 0.75rem; color: var(--accent); margin-top: 0.4rem; }

/* ── Recent / Favorites ── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.section-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
}

.mini-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}
.mini-card:hover { border-color: var(--accent); box-shadow: var(--shadow); transform: translateY(-1px); }
.mini-card .mc-title { font-weight: 600; font-size: 0.875rem; margin-bottom: 0.2rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-card .mc-artist { font-size: 0.78rem; color: var(--text3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-card .mc-del {
  position: absolute;
  top: 0.5rem; right: 0.5rem;
  background: none; border: none;
  color: var(--text3); cursor: pointer;
  font-size: 0.8rem; padding: 0.2rem;
  opacity: 0;
  transition: opacity 0.15s;
}
.mini-card:hover .mc-del { opacity: 1; }
.mini-card .mc-del:hover { color: var(--error); }

.fav-btn { position: relative; }
.fav-btn.is-fav svg { fill: #f87171; stroke: #f87171; }

/* ── Translation panel ── */
.translation-panel {
  margin-top: 1.25rem;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1.25rem;
}
.translation-panel h4 { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent3); margin-bottom: 0.75rem; }
.translation-panel .translated-text { font-family: 'Georgia', serif; font-size: 0.95rem; line-height: 1.8; color: var(--text2); white-space: pre-wrap; }

/* ── Settings panel ── */
.settings-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 500;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}
.settings-overlay.open { opacity: 1; pointer-events: all; }

.settings-panel {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: 680px;
  padding: 1.5rem;
  max-height: 85vh;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.32,0.72,0,1);
}
.settings-overlay.open .settings-panel { transform: translateY(0); }

.settings-panel h2 { font-size: 1.1rem; font-weight: 700; margin-bottom: 1.25rem; }

.settings-group { margin-bottom: 1.25rem; }
.settings-group label { display: block; font-size: 0.82rem; color: var(--text2); margin-bottom: 0.4rem; }
.settings-group select,
.settings-group input[type="text"],
.settings-group input[type="password"] {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.9rem;
  padding: 0.6rem 0.9rem;
  outline: none;
  transition: border-color 0.2s;
}
.settings-group select:focus,
.settings-group input:focus { border-color: var(--accent); }

.settings-group .hint { font-size: 0.75rem; color: var(--text3); margin-top: 0.3rem; }

/* ── Skeletons ── */
.skeleton {
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface2) 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 6px;
}
@keyframes shimmer { 0%{ background-position: 200% 0 } 100%{ background-position: -200% 0 } }

.skel-line { height: 1em; margin-bottom: 0.6rem; }
.skel-line.short { width: 40%; }
.skel-line.medium { width: 70%; }
.skel-line.full { width: 100%; }

/* ── Toast ── */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.875rem;
  padding: 0.6rem 1.25rem;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.3s ease, fadeOut 0.4s 2.8s forwards;
  pointer-events: none;
}
.toast.error { border-color: var(--error); color: var(--error); }
.toast.success { border-color: var(--success); color: var(--success); }
@keyframes slideUp { from{ transform:translateY(20px); opacity:0 } to{ transform:translateY(0); opacity:1 } }
@keyframes fadeOut { to{ opacity:0; transform:translateY(-10px) } }

/* ── Keyboard hints ── */
.kbd {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.7rem;
  padding: 0.1rem 0.35rem;
  color: var(--text3);
  font-family: monospace;
}

/* ── Footer ── */
footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem 0;
  text-align: center;
  color: var(--text3);
  font-size: 0.8rem;
}
footer a { color: var(--accent); text-decoration: none; }
footer a:hover { text-decoration: underline; }

/* ── Waveform accent ── */
.waveform-accent {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 20px;
}
.waveform-accent span {
  display: block;
  width: 3px;
  border-radius: 2px;
  background: var(--accent);
  animation: wave 1s ease-in-out infinite;
}
.waveform-accent span:nth-child(2) { animation-delay: 0.1s; }
.waveform-accent span:nth-child(3) { animation-delay: 0.2s; }
.waveform-accent span:nth-child(4) { animation-delay: 0.3s; }
.waveform-accent span:nth-child(5) { animation-delay: 0.15s; }
@keyframes wave {
  0%, 100% { height: 6px; }
  50% { height: 18px; }
}

/* ── Spinner ── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg) } }

/* ── Share banner ── */
.share-banner {
  display: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 1rem;
  font-size: 0.8rem;
  color: var(--text2);
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.share-banner.visible { display: flex; }

/* ── Utility ── */
.hidden { display: none !important; }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.text-muted { color: var(--text3); font-size: 0.875rem; }

.divider {
  height: 1px;
  background: var(--border);
  margin: 1.5rem 0;
}

/* ── Responsive ── */
@media (max-width: 600px) {
  .hero { padding: 2rem 0 1.5rem; }
  .hero-title { font-size: 1.8rem; }
  .result-header { flex-direction: column; }
  .result-actions { width: 100%; }
  .tab-btn { padding: 0.5rem 0.7rem; font-size: 0.8rem; }
}
