:root {
  --bg-main: #0b0f17;
  --bg-panel: #131a26;
  --bg-input: #1b2434;
  --border-color: #28344a;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --radius: 10px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
}

body {
  background-color: var(--bg-main);
  color: var(--text-primary);
  line-height: 1.6;
  padding: 20px;
}

.app-container {
  max-width: 1320px;
  margin: 0 auto;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 18px 24px;
  margin-bottom: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo-badge {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.25rem;
  color: #fff;
}

.brand h1 {
  font-size: 1.3rem;
  font-weight: 700;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.engine-status-card {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 12px 16px;
  min-width: 320px;
}

.status-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  margin-bottom: 8px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--warning);
  display: inline-block;
}

.status-dot.ready { background: var(--success); }
.status-dot.error { background: var(--danger); }

.progress-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.progress-bar {
  flex: 1;
  height: 8px;
  background: #0f172a;
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  transition: width 0.2s ease;
}

.progress-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  min-width: 38px;
}

.cache-actions {
  display: flex;
  gap: 8px;
}

.main-grid {
  display: grid;
  grid-template-columns: 440px 1fr;
  gap: 24px;
}

@media (max-width: 980px) {
  .main-grid {
    grid-template-columns: 1fr;
  }
}

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 22px;
}

.panel-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 14px;
  color: #e2e8f0;
}

.tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
  background: var(--bg-input);
  padding: 4px;
  border-radius: 8px;
}

.tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
}

.tab-btn.active {
  background: var(--accent);
  color: #fff;
}

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

.field-label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.hint-text {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.input-control {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.92rem;
}

.input-sm { padding: 6px 10px; width: auto; }

.clone-controls {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

.file-upload-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-input);
  border: 1px dashed var(--accent);
  color: var(--accent);
  padding: 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
}

.audio-mini-box {
  background: var(--bg-input);
  padding: 12px;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.85rem;
}

.divider {
  border: 0;
  border-top: 1px solid var(--border-color);
  margin: 20px 0;
}

.sliders-group {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.slider-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.86rem;
  margin-bottom: 4px;
}

.slider-val {
  color: var(--accent);
  font-weight: 700;
  font-family: monospace;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
}

.slider-scale {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--text-secondary);
}

.advanced-settings {
  margin-top: 16px;
  background: var(--bg-input);
  padding: 10px 14px;
  border-radius: 8px;
}

.advanced-settings summary {
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.advanced-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

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

.script-textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 14px;
  border-radius: 8px;
  font-size: 1rem;
  resize: vertical;
  line-height: 1.7;
}

.editor-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
}

.char-counter {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.action-buttons {
  display: flex;
  gap: 10px;
}

.btn {
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: 0.15s ease;
}

.btn-sm { padding: 5px 10px; font-size: 0.8rem; }
.btn-lg { padding: 11px 22px; font-size: 0.95rem; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-success { background: var(--success); color: #fff; }
.btn-record { background: #dc2626; color: #fff; }
.btn-outline { background: transparent; border: 1px solid var(--border-color); color: var(--text-primary); }
.btn-danger-outline { background: transparent; border: 1px solid var(--danger); color: var(--danger); }
.btn.disabled { opacity: 0.45; pointer-events: none; }

.dialogue-box {
  margin-top: 18px;
  background: var(--bg-input);
  border-radius: 8px;
  padding: 14px;
}

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

.dialogue-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dialogue-list li {
  background: var(--bg-panel);
  padding: 8px 12px;
  border-radius: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
}

.output-card {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 16px;
}

#waveformCanvas {
  width: 100%;
  height: 90px;
  background: #0b0f17;
  border-radius: 6px;
}

.output-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.badge-info {
  margin-top: 10px;
  background: rgba(16, 185, 129, 0.15);
  color: var(--success);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.84rem;
}
