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

:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-card: #1a1a26;
  --bg-hover: #22223a;
  --text-primary: #f0f0f5;
  --text-secondary: #8888a0;
  --text-muted: #555570;
  --accent: #6c5ce7;
  --accent-light: #a29bfe;
  --accent-glow: rgba(108, 92, 231, 0.3);
  --green: #00cec9;
  --green-glow: rgba(0, 206, 201, 0.3);
  --red: #ff7675;
  --radius: 16px;
  --radius-sm: 10px;
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
}

.app {
  max-width: 780px;
  margin: 0 auto;
  padding: 0 24px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ========== HEADER ========== */
.header {
  padding: 20px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}

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

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  font-size: 24px;
}

.logo-text {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.logo-badge {
  font-size: 10px;
  font-weight: 600;
  background: var(--accent);
  color: white;
  padding: 2px 8px;
  border-radius: 100px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.header-links {
  display: flex;
  gap: 16px;
}

.header-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: color var(--transition);
}

.header-link:hover {
  color: var(--text-primary);
}

/* ========== MAIN ========== */
.main {
  flex: 1;
  padding: 40px 0;
}

/* ========== HERO ========== */
.hero {
  text-align: center;
  margin-bottom: 48px;
}

.hero-title {
  font-size: 48px;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -1.5px;
  margin-bottom: 16px;
}

.gradient-text {
  background: linear-gradient(135deg, var(--accent), var(--green));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-subtitle {
  font-size: 18px;
  color: var(--text-secondary);
  max-width: 520px;
  margin: 0 auto;
  line-height: 1.6;
  font-weight: 400;
}

/* ========== RECORDER ========== */
.recorder-section {
  margin-bottom: 40px;
}

.recorder-container {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 32px;
  border: 1px solid rgba(255,255,255,0.06);
}

.status-wrapper {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-secondary);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: background var(--transition);
}

.status-dot.active {
  background: var(--red);
  animation: pulse 1s infinite;
}

.status-dot.recording {
  background: var(--red);
  animation: pulse 0.6s infinite;
}

.status-dot.processing {
  background: var(--accent);
  animation: pulse 0.8s infinite;
}

.status-dot.success {
  background: var(--green);
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.3); }
}

.timer {
  font-size: 20px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
  min-width: 48px;
  text-align: right;
}

.timer.active {
  color: var(--red);
}

.timer-low {
  animation: pulse 0.5s ease-in-out infinite alternate;
}

@keyframes pulse {
  from { opacity: 1; transform: scale(1); }
  to { opacity: 0.6; transform: scale(1.1); }
}

/* Waveform */
.waveform-container {
  width: 100%;
  height: 80px;
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  margin-bottom: 24px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.04);
}

.waveform-container canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Record button */
.record-btn-wrapper {
  text-align: center;
  margin-bottom: 24px;
}

.record-btn {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--accent), #5a4bd1);
  cursor: pointer;
  position: relative;
  transition: all var(--transition);
  box-shadow: 0 8px 32px var(--accent-glow);
}

.record-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 12px 40px var(--accent-glow);
}

.record-btn:active {
  transform: scale(0.95);
}

.record-btn.recording {
  background: linear-gradient(135deg, var(--red), #e17055);
  box-shadow: 0 8px 32px rgba(255, 118, 117, 0.3);
  animation: recordPulse 1.5s infinite;
}

@keyframes recordPulse {
  0%, 100% { box-shadow: 0 8px 32px rgba(255, 118, 117, 0.3); }
  50% { box-shadow: 0 8px 48px rgba(255, 118, 117, 0.5); }
}

.record-btn-inner {
  display: flex;
  align-items: center;
  justify-content: center;
}

.mic-icon {
  width: 36px;
  height: 36px;
  color: white;
  transition: all var(--transition);
}

.record-btn.recording .mic-icon {
  transform: scale(0.8);
}

.record-hint {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 12px;
  transition: color var(--transition);
}

.record-hint.active {
  color: var(--accent-light);
}

/* Upload alternative */
.upload-alt {
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.upload-divider {
  font-size: 13px;
  color: var(--text-muted);
}

.upload-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--accent-light);
  cursor: pointer;
  transition: color var(--transition);
  font-weight: 500;
}

.upload-btn:hover {
  color: var(--accent);
}

.upload-icon {
  width: 16px;
  height: 16px;
}

/* ========== LOADING ========== */
.loading-section {
  text-align: center;
  padding: 40px 0;
}

.spinner-ring {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 3px solid var(--bg-card);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
  margin: 0 auto 20px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  font-size: 16px;
  color: var(--text-secondary);
}

.search-log {
  margin-top: 20px;
  text-align: left;
  max-width: 380px;
  margin-left: auto;
  margin-right: auto;
}

.search-log-item {
  font-size: 13px;
  color: var(--text-muted);
  padding: 6px 0;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ========== RESULTS ========== */
.results-section {
  margin-bottom: 40px;
}

.results-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 20px;
}

.results-title {
  font-size: 22px;
  font-weight: 700;
}

.results-count {
  font-size: 14px;
  color: var(--text-muted);
}

.results-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.result-card {
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 20px 24px;
  border: 1px solid rgba(255,255,255,0.06);
  transition: all var(--transition);
  display: flex;
  align-items: center;
  gap: 20px;
}

.result-card:hover {
  border-color: rgba(255,255,255,0.1);
  background: var(--bg-hover);
  cursor: pointer;
}

.result-card.selected {
  border-color: var(--accent);
  background: rgba(108, 92, 231, 0.1);
}

.result-rank {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-muted);
  min-width: 28px;
}

.result-card:first-child .result-rank {
  color: var(--accent-light);
  font-size: 16px;
}

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

.result-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.result-artist {
  font-size: 14px;
  color: var(--text-secondary);
}

.result-meta {
  display: flex;
  gap: 16px;
  margin-top: 6px;
}

.result-meta-item {
  font-size: 12px;
  color: var(--text-muted);
}

.result-score {
  font-size: 14px;
  font-weight: 600;
  color: var(--green);
  min-width: 40px;
  text-align: right;
}

.confidence-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
  margin-left: 6px;
  vertical-align: middle;
}
.confidence-high { background: #d4edda; color: #155724; }
.confidence-medium { background: #fff3cd; color: #856404; }
.confidence-low { background: #f8d7da; color: #721c24; }

.result-links {
  display: flex;
  gap: 8px;
}

.result-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,0.06);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  transition: all var(--transition);
}

.result-link:hover {
  background: rgba(255,255,255,0.12);
  color: var(--text-primary);
}

.result-link-listen {
  background: var(--accent);
  color: white !important;
  font-size: 12px;
  font-weight: 600;
  padding: 0 14px;
  width: auto;
  border-radius: 100px;
}

.result-link-listen:hover {
  background: #7c6ff0 !important;
  transform: scale(1.05);
}

.results-footer {
  text-align: center;
  margin-top: 24px;
}

/* ========== BUTTONS ========== */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 28px;
  border-radius: 100px;
  border: none;
  background: var(--accent);
  color: white;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}

.btn-primary:hover {
  background: #7c6ff0;
  transform: translateY(-1px);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 24px;
  border-radius: 100px;
  border: 1px solid rgba(255,255,255,0.1);
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}

.btn-secondary:hover {
  border-color: rgba(255,255,255,0.2);
  color: var(--text-primary);
  background: rgba(255,255,255,0.04);
}

.btn-text {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  transition: color var(--transition);
  font-family: inherit;
}

.btn-text:hover {
  color: var(--text-primary);
}

/* ========== ERROR ========== */
.error-section {
  margin-bottom: 40px;
}

.error-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 40px;
  text-align: center;
  border: 1px solid rgba(255, 118, 117, 0.15);
}

.error-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.error-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--red);
}

.error-message {
  font-size: 15px;
  color: var(--text-secondary);
  margin-bottom: 24px;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}

/* ========== HISTORY ========== */
.history-section {
  margin-bottom: 40px;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.history-title {
  font-size: 22px;
  font-weight: 700;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.history-item {
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  border: 1px solid rgba(255,255,255,0.04);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.history-item-title {
  font-size: 15px;
  font-weight: 600;
}

.history-item-artist {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.history-item-time {
  font-size: 12px;
  color: var(--text-muted);
}

.history-empty {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
  font-size: 15px;
}

/* ========== UTILITY ========== */
.hidden {
  display: none !important;
}

/* ========== FOOTER ========== */
.footer {
  padding: 24px 0;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  border-top: 1px solid rgba(255,255,255,0.04);
}

.footer-legal {
  margin: 12px 0;
  font-size: 11px;
  color: var(--text-muted);
  opacity: 0.7;
}
.footer-legal p {
  margin: 2px 0;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 600px) {
  .app {
    padding: 0 16px;
  }

  .hero-title {
    font-size: 32px;
  }

  .hero-subtitle {
    font-size: 16px;
  }

  .recorder-container {
    padding: 20px;
  }

  .record-btn {
    width: 80px;
    height: 80px;
  }

  .mic-icon {
    width: 28px;
    height: 28px;
  }

  .result-card {
    flex-wrap: wrap;
    gap: 12px;
    padding: 16px;
  }

  .result-links {
    width: 100%;
    justify-content: flex-end;
  }
}

/* ========== FOOTER ========== */
.footer {
  padding: 32px 0 24px;
  text-align: center;
  border-top: 1px solid rgba(255,255,255,0.04);
}

.footer > p {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.footer-author {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.footer-author-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.footer-author-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  background: linear-gradient(135deg, var(--accent), var(--green));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.footer-author-links {
  display: flex;
  gap: 16px;
  margin-top: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.footer-link {
  font-size: 13px;
  color: var(--accent-light);
  text-decoration: none;
  transition: color var(--transition);
  padding: 4px 12px;
  border-radius: 100px;
  background: rgba(108, 92, 231, 0.08);
}

.footer-link:hover {
  color: var(--accent);
  background: rgba(108, 92, 231, 0.15);
}

.footer-link-static {
  color: var(--text-muted);
  background: rgba(255,255,255,0.03);
  cursor: default;
}

/* ========== PLAYER ========== */
.player-section {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid rgba(255,255,255,0.06);
}

.player-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.player-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  flex-shrink: 0;
}

.player-btn:hover {
  transform: scale(1.1);
  background: var(--accent-light);
}

.play-icon {
  width: 14px;
  height: 14px;
  margin-left: 2px;
}

.player-btn.playing .play-icon {
  margin-left: 0;
}

.player-waveform {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 3px;
  height: 32px;
}

.player-wave-bar {
  flex: 1;
  background: var(--accent);
  opacity: 0.4;
  border-radius: 2px;
  height: 40%;
  transition: all 0.2s;
}

.player-wave-bar:nth-child(1) { height: 30%; }
.player-wave-bar:nth-child(2) { height: 55%; }
.player-wave-bar:nth-child(3) { height: 85%; }
.player-wave-bar:nth-child(4) { height: 65%; }
.player-wave-bar:nth-child(5) { height: 40%; }

.player-btn.playing ~ .player-waveform .player-wave-bar {
  opacity: 1;
  animation: waveAnim 0.8s ease-in-out infinite alternate;
}

.player-btn.playing ~ .player-waveform .player-wave-bar:nth-child(1) { animation-delay: 0s; }
.player-btn.playing ~ .player-waveform .player-wave-bar:nth-child(2) { animation-delay: 0.15s; }
.player-btn.playing ~ .player-waveform .player-wave-bar:nth-child(3) { animation-delay: 0.3s; }
.player-btn.playing ~ .player-waveform .player-wave-bar:nth-child(4) { animation-delay: 0.2s; }
.player-btn.playing ~ .player-waveform .player-wave-bar:nth-child(5) { animation-delay: 0.1s; }

@keyframes waveAnim {
  from { height: 20%; }
  to { height: 90%; }
}

/* ========== DEV PANEL ========== */
.dev-panel {
  background: #0d1117;
  border: 1px solid rgba(108, 92, 231, 0.3);
  border-radius: var(--radius-sm);
  margin-bottom: 24px;
  overflow: hidden;
}

.dev-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: rgba(108, 92, 231, 0.1);
  border-bottom: 1px solid rgba(108, 92, 231, 0.15);
}

.dev-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent-light);
}

.dev-body {
  padding: 12px 16px;
}

.dev-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  font-size: 13px;
  gap: 12px;
}

.dev-label {
  color: var(--text-secondary);
  white-space: nowrap;
  flex-shrink: 0;
}

.dev-value {
  color: var(--green);
  text-align: right;
  word-break: break-all;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  max-width: 300px;
}

.dev-body.collapsed {
  display: none;
}

.dev-canvas {
  width: 100%;
  height: 80px;
  background: #0a0a0f;
  border-radius: 6px;
  margin-bottom: 10px;
  border: 1px solid rgba(108, 92, 231, 0.15);
}

.player-time {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  min-width: 36px;
  text-align: right;
}
