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

:root {
  --bg: #0f0f0f;
  --surface: #1a1a2e;
  --surface2: #16213e;
  --accent: #e94560;
  --accent2: #0f3460;
  --text: #eee;
  --text-muted: #999;
  --green: #00d26a;
  --red: #e94560;
  --yellow: #ffc107;
  --radius: 12px;
}

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

header {
  background: linear-gradient(135deg, var(--surface) 0%, var(--surface2) 100%);
  padding: 16px 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2px solid var(--accent);
}

header h1 {
  font-size: 24px;
  background: linear-gradient(90deg, var(--accent), #ff6b6b);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

header h1 span { font-weight: 300; opacity: 0.7; font-size: 16px; }

.api-status { display: flex; gap: 8px; align-items: center; }

.api-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  display: inline-block;
}
.api-dot.connected { background: var(--green); box-shadow: 0 0 6px var(--green); }
.api-dot.disconnected { background: var(--red); }

.api-dot-label {
  font-size: 10px;
  color: var(--text-muted);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

/* ===== WIZARD NAV ===== */
#wizardNav {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  padding: 16px 20px;
  gap: 0;
}

.wizard-step {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.3s;
  opacity: 0.5;
}

.wizard-step.active {
  opacity: 1;
  background: rgba(233, 69, 96, 0.15);
}

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

.wizard-num {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--accent2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

.wizard-step.active .wizard-num { background: var(--accent); }
.wizard-step.done .wizard-num { background: var(--green); }

.wizard-label { font-size: 13px; font-weight: 500; }

.wizard-arrow {
  width: 20px;
  height: 2px;
  background: rgba(255,255,255,0.15);
  margin: 0 4px;
}

/* ===== MAIN ===== */
main {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 20px;
}

.wizard-content { display: none; }
.wizard-content.active { display: block; }

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  border: 1px solid rgba(255,255,255,0.06);
}

.card h2 {
  font-size: 20px;
  margin-bottom: 8px;
  color: var(--accent);
}

.subtitle {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 20px;
}

label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 6px;
  margin-top: 14px;
}

input, textarea, select {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

input:focus, textarea:focus, select:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 80px; }

/* ===== BUTTONS ===== */
button.btn {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 12px;
}

.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: #d63851; transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-secondary { background: var(--accent2); color: white; }
.btn-secondary:hover { background: #1a4a8a; }

.btn-small { padding: 8px 16px; font-size: 12px; }
.btn-large { padding: 16px 40px; font-size: 16px; width: 100%; }

/* ===== WIZARD ACTIONS ===== */
.wizard-actions {
  display: flex;
  justify-content: space-between;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid rgba(255,255,255,0.06);
}

/* ===== STEP 1: CHARACTER ===== */
.character-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.character-card {
  display: flex;
  gap: 16px;
  padding: 16px;
  background: var(--bg);
  border-radius: var(--radius);
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
}

.character-card:hover { border-color: var(--accent); }
.character-card.selected { border-color: var(--green); box-shadow: 0 0 12px rgba(0,210,106,0.2); }
.character-card.locked { opacity: 0.5; cursor: default; }
.character-card.locked:hover { border-color: transparent; }

.character-img {
  width: 80px; height: 80px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}

.character-img img {
  width: 100%; height: 100%;
  object-fit: cover;
}

.character-img.placeholder {
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
}

.lock-icon {
  font-size: 24px;
  color: var(--text-muted);
}

.character-name { font-weight: 600; font-size: 15px; }
.character-desc { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.character-tags { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }

.tag {
  padding: 2px 8px;
  background: var(--accent2);
  border-radius: 10px;
  font-size: 10px;
  color: var(--text-muted);
}

/* ===== STEP 2: OUTFIT ===== */
.outfit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  max-height: 500px;
  overflow-y: auto;
  padding: 4px;
}

.outfit-card {
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  border: 3px solid transparent;
  transition: all 0.2s;
  position: relative;
}

.outfit-card:hover { border-color: var(--accent); transform: scale(1.03); }
.outfit-card.selected { border-color: var(--green); box-shadow: 0 0 12px rgba(0,210,106,0.3); }

.outfit-card img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  display: block;
}

.outfit-card .outfit-label {
  font-size: 10px;
  padding: 4px 6px;
  color: var(--text-muted);
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
  background: var(--bg);
}

.selected-outfit-preview {
  margin-top: 16px;
  text-align: center;
}

.selected-outfit-preview h3 {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 8px;
}

.selected-outfit-preview img {
  max-width: 300px;
  max-height: 300px;
  border-radius: 8px;
  border: 2px solid var(--green);
}

/* ===== STEP 3: BRAIN ===== */
.brain-mode-toggle {
  display: flex;
  gap: 0;
  margin-bottom: 16px;
  background: var(--bg);
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.1);
}

.brain-mode {
  flex: 1;
  padding: 10px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.brain-mode.active {
  background: var(--accent);
  color: white;
}

.brain-helper {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}

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

.coming-soon {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.coming-icon {
  display: inline-block;
  padding: 6px 16px;
  background: var(--accent2);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 12px;
}

/* ===== STEP 4: VOICE ===== */
.voice-preview {
  margin-top: 16px;
}

audio { width: 100%; margin-top: 8px; }

.status-text {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 8px;
}

/* ===== STEP 5: VIDEO ===== */
.review-panel {
  background: var(--bg);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 20px;
}

.review-item {
  display: flex;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}

.review-item:last-child { border-bottom: none; }

.review-label {
  color: var(--text-muted);
  font-size: 13px;
  min-width: 100px;
  flex-shrink: 0;
}

.review-value {
  font-size: 13px;
}

.review-script {
  max-height: 60px;
  overflow-y: auto;
  font-size: 12px;
  line-height: 1.4;
}

.video-settings {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.pipeline-progress {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.progress-step {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg);
  border-radius: 8px;
  font-size: 13px;
  border: 1px solid rgba(255,255,255,0.04);
}

.ps-icon {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--accent2);
  flex-shrink: 0;
}

.progress-step.running .ps-icon {
  background: var(--yellow);
  animation: pulse 1s infinite;
}

.progress-step.done .ps-icon { background: var(--green); }
.progress-step.error .ps-icon { background: var(--red); }

#videoResult {
  margin-top: 20px;
}

video {
  width: 100%;
  max-height: 500px;
  border-radius: 8px;
}

/* ===== ANIMATIONS ===== */
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

.loader {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
}

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

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  #wizardNav { flex-wrap: wrap; gap: 4px; padding: 12px; }
  .wizard-arrow { display: none; }
  .wizard-step { padding: 6px 10px; }
  .wizard-label { font-size: 11px; }
  .character-grid { grid-template-columns: 1fr; }
  .outfit-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
  .video-settings { grid-template-columns: 1fr; }
}
