:root {
  --bg: #0f0f0f;
  --surface: rgba(26,26,26,0.78);
  --surface2: rgba(37,37,37,0.7);
  --primary: #6c5ce7;
  --primary-glow: rgba(108,92,231,0.3);
  --text: #e8e8e8;
  --text-muted: #888;
  --accent: #00cec9;
  --error: #ff6b6b;
  --radius: 16px;
  --radius-sm: 10px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  -webkit-font-smoothing: antialiased;
}

#app {
  width: 100%;
  max-width: 480px;
  min-height: 100dvh;
  position: relative;
}

#main-content {
  position: relative;
  z-index: 1;
  padding: 32px 20px 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.view {
  display: none;
  flex-direction: column;
  align-items: center;
  width: 100%;
  animation: fadeIn 0.4s ease;
}

.view.active {
  display: flex;
}

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

/* No CD state */
#cd-no-cd {
  justify-content: center;
  min-height: 60vh;
  gap: 16px;
  text-align: center;
}

#cd-no-cd .no-cd-icon {
  color: var(--text-muted);
  opacity: 0.4;
}

#cd-no-cd h2 {
  font-size: 1.3rem;
  font-weight: 600;
}

#cd-no-cd p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Loading / detection states */
#cd-loading, #cd-ripping {
  justify-content: center;
  min-height: 60vh;
  gap: 24px;
  text-align: center;
  padding-top: 20px;
}

.loading-steps {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
}

.loading-step {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  opacity: 0.4;
  transition: opacity 0.3s, background 0.3s;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.loading-step.active {
  opacity: 1;
  background: var(--surface2);
  border-left: 3px solid var(--primary);
}

.loading-step.done {
  opacity: 0.8;
}

.loading-step.done .step-icon {
  color: var(--accent);
}

.step-icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
}

.step-spinner {
  display: none;
  width: 20px;
  height: 20px;
  border: 2px solid var(--surface2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loading-step.active .step-spinner {
  display: block;
}

.loading-step.active .step-check {
  display: none;
}

.step-check {
  display: none;
}

.loading-step.done .step-check {
  display: block;
}

.loading-step.done .step-spinner {
  display: none;
}

.loading-step.pending .step-check {
  display: none;
}

.loading-step.pending .step-spinner {
  display: none;
}

.step-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.step-title {
  font-size: 0.95rem;
  font-weight: 500;
}

.step-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.progress-container {
  width: 100%;
  max-width: 300px;
}

.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--surface2);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 3px;
  width: 0%;
  transition: width 0.3s ease;
}

.progress-text {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 10px;
}

/* Ready state */
.cover-container {
  width: 280px;
  height: 280px;
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 24px;
  position: relative;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
  background: var(--surface);
}

.cover-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.cover-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  background: var(--surface);
}

.album-info {
  text-align: center;
  margin-bottom: 24px;
  width: 100%;
}

#album-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 4px;
  line-height: 1.2;
}

#album-artist {
  font-size: 1rem;
  color: var(--text-muted);
  margin-bottom: 2px;
}

#album-year {
  font-size: 0.85rem;
  color: var(--text-muted);
  opacity: 0.7;
}

.mode-indicator {
  margin-top: 12px;
  display: flex;
  justify-content: center;
}

.mode-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--surface2);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 12px;
  letter-spacing: 0.02em;
}

.rip-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
}

.rip-btn:hover {
  opacity: 0.85;
}

.rip-btn:active {
  transform: scale(0.97);
}

.tracklist {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.track-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.2s;
  gap: 12px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.track-item:hover, .track-item.active {
  background: var(--surface2);
}

.track-item.active {
  border-left: 3px solid var(--primary);
}

.track-num {
  color: var(--text-muted);
  font-size: 0.85rem;
  width: 28px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.track-title {
  flex: 1;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-duration {
  color: var(--text-muted);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

/* Error state */
#cd-error {
  justify-content: center;
  min-height: 60vh;
  gap: 16px;
  text-align: center;
}

#cd-error .error-icon {
  color: var(--error);
}

#cd-error h2 {
  font-size: 1.3rem;
  font-weight: 600;
}

#cd-error p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

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

/* Player bar */
.player-bar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  border-top: 1px solid var(--surface2);
  padding: 12px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 100;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  transition: transform 0.3s ease;
}

.player-bar.hidden {
  transform: translateX(-50%) translateY(100%);
}

.player-track-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 4px;
}

.player-track-number {
  color: var(--primary);
  font-size: 0.85rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.player-track-title {
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
}

.player-btn {
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s;
  opacity: 0.7;
}

.player-btn:hover {
  opacity: 1;
}

.player-btn-play {
  opacity: 1;
}

.player-progress {
  display: flex;
  align-items: center;
  gap: 8px;
}

.player-time {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  min-width: 32px;
}

.player-progress-bar {
  flex: 1;
  height: 4px;
  background: var(--surface2);
  border-radius: 2px;
  position: relative;
  cursor: pointer;
}

.player-progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
  width: 0%;
  pointer-events: none;
}

.player-progress-range {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  margin: 0;
}

.hidden {
  display: none !important;
}

/* Volume control */
.player-volume {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.player-btn-volume {
  opacity: 0.6;
  padding: 2px;
}

.player-btn-volume:hover {
  opacity: 1;
}

.player-volume-slider {
  width: 60px;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--surface2);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

.player-volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--primary);
  border: none;
  cursor: pointer;
}

.player-volume-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--primary);
  border: none;
  cursor: pointer;
}

@media (max-width: 380px) {
  .player-volume-slider {
    width: 40px;
  }
}

/* Responsive */
@media (min-width: 768px) {
  #main-content {
    padding: 48px 32px 140px;
  }

  .cover-container {
    width: 320px;
    height: 320px;
  }

  .player-bar {
    padding: 16px 24px 20px;
  }
}

@media (max-width: 380px) {
  .cover-container {
    width: 240px;
    height: 240px;
  }

  #album-title {
    font-size: 1.2rem;
  }

  .track-item {
    padding: 10px 12px;
  }
}
