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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #0a0b10;
  color: #e1e4ea;
  height: 100vh;
  overflow: hidden;
}

.app {
  display: flex;
  height: 100vh;
}

/* ── Sidebar ────────────────────────────────────────────────────── */
.sidebar {
  width: 200px;
  background: #0f1117;
  border-right: 1px solid #1e2130;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.logo {
  padding: 24px 20px;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  line-height: 1.3;
  border-bottom: 1px solid #1e2130;
}

.nav-items {
  flex: 1;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: none;
  background: none;
  color: #8b8fa3;
  font-size: 13px;
  cursor: pointer;
  border-radius: 6px;
  text-align: left;
  font-family: inherit;
  transition: all 0.15s;
}

.nav-item:hover {
  background: #161822;
  color: #c1c4d0;
}

.nav-item.active {
  background: #1a1d2e;
  color: #fff;
}

.nav-item.completed .step-num {
  background: #22c55e;
  color: #fff;
}

.step-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #1e2130;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
}

.nav-item.active .step-num {
  background: #6366f1;
  color: #fff;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid #1e2130;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: #555;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ef4444;
  flex-shrink: 0;
}

.status-dot.connected {
  background: #22c55e;
  box-shadow: 0 0 6px #22c55e66;
}

/* ── Main ───────────────────────────────────────────────────────── */
.main {
  flex: 1;
  overflow-y: auto;
  padding: 32px 40px;
  position: relative;
}

.step-panel {
  max-width: 800px;
}

.step-panel h2 {
  font-size: 22px;
  font-weight: 600;
  color: #fff;
  margin-bottom: 8px;
}

.step-desc {
  color: #8b8fa3;
  margin-bottom: 20px;
  line-height: 1.5;
}

.hidden {
  display: none !important;
}

/* ── Forms ───────────────────────────────────────────────────────── */
textarea {
  width: 100%;
  background: #0f1117;
  border: 1px solid #1e2130;
  border-radius: 8px;
  padding: 14px;
  color: #e1e4ea;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.6;
  resize: vertical;
  outline: none;
}

textarea:focus {
  border-color: #6366f1;
}

textarea[readonly] {
  cursor: default;
  background: #0d0e14;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
  overflow: visible;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  overflow: visible;
}

.form-group label {
  font-size: 12px;
  color: #8b8fa3;
  font-weight: 500;
}

select, input[type="file"] {
  background: #0f1117;
  border: 1px solid #1e2130;
  border-radius: 6px;
  padding: 8px 10px;
  color: #e1e4ea;
  font-size: 13px;
  outline: none;
  font-family: inherit;
}

select:focus {
  border-color: #6366f1;
}

input[type="file"] {
  padding: 6px;
  font-size: 12px;
}

input[type="file"]::file-selector-button {
  background: #1e2130;
  border: 1px solid #2a2d3e;
  border-radius: 4px;
  color: #e1e4ea;
  padding: 4px 10px;
  margin-right: 8px;
  cursor: pointer;
  font-size: 12px;
}

/* ── Searchable select ───────────────────────────────────────────── */
.searchable-select {
  position: relative;
}

.search-input {
  width: 100%;
  background: #0f1117;
  border: 1px solid #1e2130;
  border-radius: 6px;
  padding: 8px 10px;
  color: #e1e4ea;
  font-size: 13px;
  outline: none;
  font-family: inherit;
}

.search-input:focus {
  border-color: #6366f1;
}

.dropdown-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  max-height: 240px;
  overflow-y: auto;
  background: #161822;
  border: 1px solid #2a2d3e;
  border-radius: 6px;
  margin-top: 4px;
  z-index: 50;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

.dropdown-item {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.dropdown-item:hover, .dropdown-item.highlighted {
  background: #1e2130;
}

.dropdown-item.selected {
  color: #6366f1;
}

.dropdown-item .voice-category {
  font-size: 11px;
  color: #555;
}

.dropdown-empty {
  padding: 12px;
  text-align: center;
  color: #555;
  font-size: 12px;
}

input[type="range"] {
  -webkit-appearance: none;
  height: 4px;
  background: #1e2130;
  border-radius: 2px;
  outline: none;
  flex: 1;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #6366f1;
  cursor: pointer;
}

.range-val {
  font-size: 12px;
  color: #8b8fa3;
  min-width: 30px;
  text-align: right;
}

.form-group:has(input[type="range"]) {
  flex-direction: row;
  align-items: center;
  gap: 10px;
}

.form-group:has(input[type="range"]) label {
  min-width: 70px;
}

/* ── Buttons ────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 20px;
  border: 1px solid #2a2d3e;
  border-radius: 6px;
  background: #1e2130;
  color: #e1e4ea;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}

.btn:hover {
  background: #252838;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  background: #6366f1;
  border-color: #6366f1;
  color: #fff;
}

.btn-primary:hover {
  background: #5558e6;
}

.btn-secondary {
  background: #1e2130;
  border-color: #6366f1;
  color: #c4c7f5;
}

.btn-secondary:hover {
  background: #252838;
}

.step-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
}

.char-count {
  font-size: 12px;
  color: #555;
}

.quota-info {
  font-size: 12px;
  color: #8b8fa3;
}

/* ── Result boxes ───────────────────────────────────────────────── */
.result-box {
  margin-top: 20px;
  padding: 16px;
  background: #0f1117;
  border: 1px solid #1e2130;
  border-radius: 8px;
}

.result-box h3 {
  font-size: 14px;
  margin-bottom: 12px;
  color: #c1c4d0;
}

.info-box {
  padding: 10px 14px;
  background: #0f1117;
  border: 1px solid #1e2130;
  border-radius: 6px;
  font-size: 13px;
  color: #8b8fa3;
  margin-bottom: 12px;
}

/* ── Script segments ────────────────────────────────────────────── */
.script-segment {
  margin-bottom: 12px;
}

.script-segment-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
  font-size: 12px;
  font-weight: 600;
  color: #8b8fa3;
}

.script-segment textarea {
  font-size: 12px;
  line-height: 1.5;
}

/* ── Audio player ───────────────────────────────────────────────── */
audio {
  width: 100%;
  margin-bottom: 8px;
}

/* ── Segments list ──────────────────────────────────────────────── */
.segments-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.segment-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: #161822;
  border: 1px solid #1e2130;
  border-radius: 6px;
}

.segment-item .seg-num {
  font-weight: 600;
  color: #6366f1;
  min-width: 24px;
}

.segment-item .seg-name {
  flex: 1;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.segment-item .seg-duration {
  font-size: 12px;
  color: #8b8fa3;
}

.segment-item audio {
  width: 200px;
  height: 30px;
  margin: 0;
}

/* ── Task list (HeyGen step) ────────────────────────────────────── */
.task-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 12px;
}

.task-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: #161822;
  border: 1px solid #1e2130;
  border-radius: 6px;
}

.task-item .task-name {
  flex: 1;
  font-size: 13px;
}

.task-item .task-progress {
  font-size: 12px;
  color: #555;
  min-width: 40px;
  text-align: right;
}

.task-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
}

.task-badge.pending { background: #1e2130; color: #8b8fa3; }
.task-badge.processing { background: #3b2f1e; color: #fbbf24; animation: pulse 1.5s infinite; }
.task-badge.completed { background: #14532d; color: #22c55e; }
.task-badge.failed { background: #451a1a; color: #ef4444; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* ── Video ──────────────────────────────────────────────────────── */
video {
  border-radius: 8px;
  background: #000;
  margin-bottom: 8px;
}

/* ── Loading overlay ────────────────────────────────────────────── */
.loading-overlay {
  position: absolute;
  inset: 0;
  background: #0a0b10dd;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 100;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid #1e2130;
  border-top-color: #6366f1;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

#loading-text {
  font-size: 14px;
  color: #8b8fa3;
}

/* ── Scrollbar ──────────────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #1e2130;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #2a2d3e;
}

/* ── Cut Log ────────────────────────────────────────────────────── */
.cut-log-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cut-log-entry {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: #12131a;
  border-radius: 6px;
  border-left: 3px solid #444;
  font-size: 13px;
}

.cut-log-entry.elevenlabs_join {
  border-left-color: #8b5cf6;
}

.cut-log-entry.audio_split {
  border-left-color: #06b6d4;
}

.cut-log-time {
  font-family: 'SF Mono', monospace;
  font-weight: 600;
  color: #fff;
  min-width: 52px;
}

.cut-log-type {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  background: #1e2130;
  color: #8b8fa3;
  white-space: nowrap;
}

.cut-log-entry.elevenlabs_join .cut-log-type {
  background: rgba(139, 92, 246, 0.15);
  color: #a78bfa;
}

.cut-log-entry.audio_split .cut-log-type {
  background: rgba(6, 182, 212, 0.15);
  color: #22d3ee;
}

.cut-log-desc {
  color: #8b8fa3;
  flex: 1;
}
