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

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', 'Arial', sans-serif;
  font-weight: 200;
  background: #fff;
  color: #1a1a1a;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}

body {
  padding: 20px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

/* ── Card ─────────────────────────────────────────────── */

.card {
  width: 100%;
  max-width: 1200px;
  height: calc(100vh - 40px);
  background: #f5f5f5;
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

/* ── Top bar ──────────────────────────────────────────── */

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 32px 0;
}

.top-bar .title {
  font-size: 1.35rem;
  font-weight: 300;
  color: #1a1a1a;
  letter-spacing: -0.01em;
}

/* ── Content ──────────────────────────────────────────── */

.content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 20px 32px 24px;
  overflow-y: auto;
}

/* ── State visibility ─────────────────────────────────── */

.app-state { display: none; width: 100%; }
.app-state.active { display: flex; flex-direction: column; align-items: center; }

/* ── Drop zone ────────────────────────────────────────── */

#stateDropZone.active {
  flex: 1;
  justify-content: center;
}

.drop-zone {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  width: 100%;
  max-width: 480px;
  padding: 64px 24px;
  border: 1.5px dashed #ccc;
  border-radius: 16px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}

.drop-zone:hover {
  border-color: #999;
  background: #eee;
}

.drop-zone-text {
  font-size: 0.82rem;
  font-weight: 300;
  color: #888;
  line-height: 1.8;
}

.drop-zone-sub {
  font-size: 0.68rem;
  color: #bbb;
}

.drop-zone input[type="file"] { display: none; }

/* ── Full-page drop overlay ───────────────────────────── */

.drop-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,.45);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 300;
  line-height: 1.6;
  backdrop-filter: blur(4px);
  z-index: 100;
  pointer-events: auto;
}

.drop-overlay.visible { display: flex; }

/* ── Loading / processing states ──────────────────────── */

.state-text {
  font-size: 0.85rem;
  font-weight: 300;
  color: #555;
  margin-bottom: 20px;
  text-align: center;
}

.progress-bar {
  width: 100%;
  max-width: 360px;
  height: 4px;
  background: #ddd;
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 10px;
}

.progress-bar .fill {
  height: 100%;
  width: 0%;
  background: #1a1a1a;
  border-radius: 2px;
  transition: width .2s ease;
}

.progress-pct {
  font-size: 0.72rem;
  color: #999;
  font-variant-numeric: tabular-nums;
}

#stateLoading.active,
#stateProcessing.active {
  flex: 1;
  justify-content: center;
}

/* ── Error state ──────────────────────────────────────── */

#stateError.active {
  flex: 1;
  justify-content: center;
}

.error-text {
  font-size: 0.82rem;
  font-weight: 300;
  color: #d32f2f;
  margin-bottom: 20px;
  max-width: 400px;
  text-align: center;
  word-break: break-word;
}

/* ── Results ──────────────────────────────────────────── */

.song-info {
  display: flex;
  gap: 10px;
  width: 100%;
  max-width: 560px;
  margin-bottom: 20px;
}

.song-info input {
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 300;
  padding: 8px 12px;
  border: 1.5px solid #ddd;
  border-radius: 8px;
  background: #fff;
  color: #1a1a1a;
  outline: none;
  transition: border-color .15s;
}

.song-info input:focus { border-color: #1a1a1a; }

.song-info .title-input { flex: 1; }
.song-info .bpm-input   { width: 72px; text-align: center; }

/* ── Stems panel ──────────────────────────────────────── */

.stems-panel {
  width: 100%;
  max-width: 560px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 20px;
}

.stem-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: #eee;
  border-radius: 10px;
}

.stem-label {
  width: 52px;
  font-size: 0.68rem;
  font-weight: 400;
  color: #555;
  flex-shrink: 0;
}

.stem-waveform {
  flex: 1;
  height: 40px;
  border-radius: 4px;
  background: #e4e4e2;
  overflow: hidden;
}

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

.stem-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* ── Solo / mute buttons ──────────────────────────────── */

.stem-btn {
  width: 24px;
  height: 24px;
  border: 1px solid #ccc;
  border-radius: 6px;
  background: transparent;
  font-family: inherit;
  font-size: 0.58rem;
  font-weight: 600;
  color: #999;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .12s, color .12s, border-color .12s;
  padding: 0;
}

.stem-btn:hover { border-color: #888; color: #555; }

.solo-btn.on { background: #f0c040; border-color: #d4a520; color: #5a4200; }
.mute-btn.on { background: #d32f2f; border-color: #b71c1c; color: #fff; }

/* ── Volume slider ────────────────────────────────────── */

.volume-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 60px;
  height: 3px;
  background: #ccc;
  border-radius: 2px;
  outline: none;
}

.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #1a1a1a;
  cursor: pointer;
}

.volume-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #1a1a1a;
  border: none;
  cursor: pointer;
}

/* ── Playback controls ────────────────────────────────── */

.playback-controls {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

/* ── Export section ────────────────────────────────────── */

.export-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 560px;
}

/* ── Buttons ──────────────────────────────────────────── */

.btn {
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 400;
  padding: 9px 24px;
  border: 1.5px solid #1a1a1a;
  border-radius: 8px;
  background: #f0f0ee;
  color: #1a1a1a;
  cursor: pointer;
  transition: background .15s, color .15s;
}

.btn:hover:not(:disabled) { background: #1a1a1a; color: #f0f0ee; }
.btn:disabled { border-color: #ccc; color: #ccc; cursor: default; }

.btn-primary {
  background: #1a1a1a;
  color: #fff;
  border-color: #1a1a1a;
  width: 100%;
  padding: 11px 24px;
}

.btn-primary:hover:not(:disabled) { background: #333; border-color: #333; }

.btn.playing { background: #1a1a1a; color: #fff; }

.btn-ghost {
  background: none;
  border: none;
  color: #999;
  font-family: inherit;
  font-size: 0.72rem;
  cursor: pointer;
  padding: 4px 8px;
}

.btn-ghost:hover { color: #555; }

.btn-secondary {
  background: transparent;
  width: 100%;
  font-size: 0.75rem;
}

/* ── Footer ───────────────────────────────────────────── */

.footer {
  padding: 16px 32px;
  text-align: center;
  font-size: 0.6rem;
  color: #bbb;
  font-weight: 300;
}

.footer a { color: #bbb; text-decoration: none; }
.footer a:hover { text-decoration: underline; }
