/* ═══════════════════════════════════════════
   AutoMixSJ88 — Design System
   Dark Glassmorphism + Gradient Accents
   ═══════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ─── Reset & Base ───────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-primary: #06060f;
  --bg-secondary: #0d0d1a;
  --bg-card: rgba(15, 15, 35, 0.6);
  --bg-card-hover: rgba(20, 20, 50, 0.7);
  --bg-glass: rgba(255, 255, 255, 0.03);
  --bg-input: rgba(255, 255, 255, 0.05);

  --border: rgba(255, 255, 255, 0.06);
  --border-active: rgba(139, 92, 246, 0.4);

  --text-primary: #e8e8ef;
  --text-secondary: #8888a0;
  --text-muted: #555570;

  --accent-1: #8b5cf6;
  --accent-2: #6366f1;
  --accent-3: #3b82f6;
  --accent-gradient: linear-gradient(135deg, #8b5cf6, #6366f1, #3b82f6);
  --accent-glow: rgba(99, 102, 241, 0.15);

  --success: #10b981;
  --warning: #f59e0b;
  --error: #ef4444;
  --info: #3b82f6;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 30px rgba(99, 102, 241, 0.1);

  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: all 0.15s ease;
}

html { font-size: 15px; }
body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  overflow-x: hidden;
}

/* ─── Background Effects ─────────────────── */
body::before {
  content: '';
  position: fixed;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background:
    radial-gradient(circle at 20% 30%, rgba(139, 92, 246, 0.05) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(59, 130, 246, 0.04) 0%, transparent 50%),
    radial-gradient(circle at 50% 50%, rgba(99, 102, 241, 0.02) 0%, transparent 70%);
  z-index: 0;
  animation: bgFloat 30s ease-in-out infinite;
}
@keyframes bgFloat {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  33% { transform: translate(2%, -1%) rotate(1deg); }
  66% { transform: translate(-1%, 2%) rotate(-1deg); }
}

/* ─── Layout ─────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

/* ─── Sidebar ────────────────────────────── */
.sidebar {
  width: 260px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  top: 0;
  left: 0;
  z-index: 100;
  backdrop-filter: blur(20px);
  transition: var(--transition);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}
.sidebar-logo .logo-icon {
  width: 40px;
  height: 40px;
  background: var(--accent-gradient);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  box-shadow: 0 0 20px rgba(99, 102, 241, 0.3);
}
.sidebar-logo h1 {
  font-size: 1.15rem;
  font-weight: 700;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.sidebar-logo small {
  font-size: 0.7rem;
  color: var(--text-muted);
  display: block;
}

/* Nav Items */
.nav-section {
  margin-bottom: 8px;
}
.nav-label {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  padding: 0 8px;
  margin-bottom: 8px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition-fast);
  font-size: 0.9rem;
  font-weight: 500;
  position: relative;
  overflow: hidden;
}
.nav-item:hover {
  background: var(--bg-glass);
  color: var(--text-primary);
}
.nav-item.active {
  background: var(--accent-glow);
  color: var(--accent-1);
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: var(--accent-gradient);
  border-radius: 0 4px 4px 0;
}
.nav-icon { font-size: 1.1rem; width: 24px; text-align: center; }

/* User profile in sidebar */
.sidebar-user {
  margin-top: auto;
  padding: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-user .user-avatar {
  width: 36px;
  height: 36px;
  background: var(--accent-gradient);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.85rem;
}
.sidebar-user .user-info { flex: 1; min-width: 0; }
.sidebar-user .user-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-user .user-email {
  font-size: 0.65rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.btn-logout {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 4px;
  transition: var(--transition-fast);
}
.btn-logout:hover { color: var(--error); }

/* ─── App Header ─────────────────────────── */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px;
  z-index: 200;
  backdrop-filter: blur(20px);
}
.header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}
.header-logo .logo-icon {
  width: 32px;
  height: 32px;
  background: var(--accent-gradient);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}
.header-logo-text {
  font-size: 1rem;
  font-weight: 700;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.header-user {
  display: flex;
  align-items: center;
  gap: 10px;
}
.header-user-name {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* ─── Bottom Navigation ──────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 200;
  padding-bottom: env(safe-area-inset-bottom);
  backdrop-filter: blur(20px);
}
.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  color: var(--text-muted);
  transition: color 0.2s, transform 0.2s;
  padding: 8px 0;
  position: relative;
}
.bottom-nav-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 2px;
  background: var(--success);
  border-radius: 0 0 2px 2px;
  transition: width 0.2s;
}
.bottom-nav-item.active {
  color: var(--success);
}
.bottom-nav-item.active::before {
  width: 32px;
}
.bottom-nav-item.active .bnav-icon {
  transform: scale(1.1);
}
.bnav-icon {
  font-size: 1.4rem;
  transition: transform 0.2s;
}
.bnav-label {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.3px;
}

/* ─── Main Content ───────────────────────── */
.main-content {
  flex: 1;
  padding: 32px;
  padding-bottom: 88px;
  margin-top: 56px;
  min-height: 100vh;
}

/* ─── Page Header ────────────────────────── */
.page-header {
  margin-bottom: 32px;
}
.page-header h2 {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 4px;
}
.page-header p {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* ─── Cards ──────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}
.card:hover {
  border-color: var(--border-active);
  box-shadow: var(--shadow-glow);
}
.card-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ─── Buttons ────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  min-height: 40px;
  border-radius: var(--radius-md);
  border: none;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  vertical-align: middle;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}
.btn-primary {
  background: var(--accent-gradient);
  color: #fff;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.35);
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 25px rgba(99, 102, 241, 0.4);
}
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: var(--bg-input);
  color: var(--text-primary);
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-active);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: var(--error);
  border: 1px solid rgba(239, 68, 68, 0.2);
}
.btn-danger:hover { background: rgba(239, 68, 68, 0.25); }

.btn-sm { padding: 6px 14px; font-size: 0.78rem; min-height: 32px; }
.btn-lg { padding: 14px 28px; font-size: 0.95rem; min-height: 48px; }
.btn-block { width: 100%; }
.btn-block { white-space: normal; }

.btn:disabled {
  opacity: 0.65;
  filter: saturate(0.85);
  cursor: not-allowed;
  transform: none !important;
}

/* ─── Inputs ─────────────────────────────── */
.form-group {
  margin-bottom: 16px;
}
.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.85rem;
  transition: var(--transition-fast);
  outline: none;
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--accent-1);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}
.form-textarea { resize: vertical; min-height: 80px; }
.form-select { cursor: pointer; }

/* ─── Voice Template Panel ─────────────────── */
.voice-template-panel {
  position: relative;
  margin: 18px 0 16px;
  padding: 16px;
  border: 1px solid rgba(59, 130, 246, 0.24);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(135deg, rgba(59, 130, 246, 0.12), rgba(16, 185, 129, 0.07)),
    var(--bg-glass);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
  overflow: hidden;
}
.voice-template-panel::before {
  content: '';
  position: absolute;
  inset: -60% auto auto -20%;
  width: 180px;
  height: 180px;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.16);
  filter: blur(28px);
  pointer-events: none;
}
.voice-template-head {
  position: relative;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 14px;
}
.voice-template-kicker {
  color: var(--info);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.voice-template-title {
  color: var(--text-primary);
  font-size: 1rem;
  font-weight: 800;
}
.voice-template-status {
  flex: 0 0 auto;
  max-width: 48%;
  padding: 6px 10px;
  border: 1px solid rgba(16, 185, 129, 0.22);
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.08);
  color: #a7f3d0;
  font-size: 0.72rem;
  line-height: 1.3;
  text-align: right;
}
.voice-template-hidden-select {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.voice-speaker-toggle {
  position: relative;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.voice-speaker-card {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas:
    "icon main"
    "icon sub";
  gap: 1px 10px;
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
  text-align: left;
  cursor: pointer;
  transition: var(--transition-fast);
}
.voice-speaker-card:hover {
  border-color: rgba(59, 130, 246, 0.5);
  background: rgba(59, 130, 246, 0.08);
}
.voice-speaker-card.selected {
  border-color: rgba(16, 185, 129, 0.7);
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.20), rgba(59, 130, 246, 0.12));
  color: var(--text-primary);
}
.voice-speaker-icon {
  grid-area: icon;
  font-size: 1.35rem;
  line-height: 1.2;
}
.voice-speaker-main {
  grid-area: main;
  font-size: 0.9rem;
  font-weight: 800;
}
.voice-speaker-sub {
  grid-area: sub;
  color: var(--text-muted);
  font-size: 0.72rem;
}
.voice-template-grid {
  position: relative;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.voice-template-grid .form-group {
  margin-bottom: 0;
}
.voice-template-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}
.voice-template-badge {
  padding: 5px 9px;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.10);
  border: 1px solid rgba(59, 130, 246, 0.20);
  color: #bfdbfe;
  font-size: 0.72rem;
  font-weight: 700;
}
.voice-template-badge.muted {
  color: var(--text-muted);
  border-color: var(--border);
  background: rgba(255, 255, 255, 0.03);
}
.voice-duration-metric {
  margin-top: 8px;
  padding: 7px 10px;
  border: 1px solid rgba(16, 185, 129, 0.18);
  border-radius: var(--radius-sm);
  background: rgba(16, 185, 129, 0.07);
  color: #a7f3d0;
  font-size: 0.74rem;
  line-height: 1.35;
}

@media (max-width: 768px) {
  .voice-template-head {
    flex-direction: column;
  }
  .voice-template-status {
    max-width: none;
    text-align: left;
  }
  .voice-speaker-toggle,
  .voice-template-grid {
    grid-template-columns: 1fr;
  }
}

/* ─── File Upload Zone ───────────────────── */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}
.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--accent-1);
  background: var(--accent-glow);
}
.upload-zone .upload-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
  opacity: 0.5;
}
.upload-zone .upload-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 4px;
}
.upload-zone .upload-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
}
.upload-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

/* ─── File List ──────────────────────────── */
.file-list {
  display: grid;
  gap: 8px;
}
.file-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: var(--transition-fast);
}
.file-item:hover { background: var(--bg-card-hover); }
.file-icon {
  font-size: 1.3rem;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-glow);
  border-radius: var(--radius-sm);
}
.history-type-icon {
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1;
  color: #fff;
  font-family: "Segoe UI", Tahoma, sans-serif;
  white-space: nowrap;
  overflow: hidden;
  text-transform: uppercase;
}
.history-type-icon-tts {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
}
.history-type-icon-upload {
  background: linear-gradient(135deg, #0ea5a5 0%, #0f766e 100%);
}
.history-type-icon-mix {
  background: linear-gradient(135deg, #7c3aed 0%, #6366f1 100%);
}
.file-info { flex: 1; min-width: 0; }
.file-name {
  font-size: 0.82rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-meta {
  font-size: 0.7rem;
  color: var(--text-muted);
}
.file-actions {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.file-checkbox {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-1);
  cursor: pointer;
}
.mix-source-item {
  align-items: stretch;
}
.mix-source-item .file-name {
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  display: block;
}
.mix-source-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}
.mix-filter-chip {
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-secondary);
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 6px 12px;
  cursor: pointer;
  transition: var(--transition-fast);
}
.mix-filter-chip:hover {
  color: var(--text-primary);
  border-color: var(--border-active);
}
.mix-filter-chip.active {
  color: #fff;
  border-color: transparent;
  background: var(--accent-gradient);
  box-shadow: 0 4px 18px rgba(99, 102, 241, 0.26);
}
.mix-source-summary {
  margin-top: 8px;
  font-size: 0.75rem;
  color: var(--text-muted);
}
.mix-source-pagination {
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
.mix-page-btn {
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-primary);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
}
.mix-page-btn:hover:not(:disabled) {
  border-color: var(--border-active);
  background: var(--bg-card-hover);
}
.mix-page-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.mix-page-info {
  font-size: 0.72rem;
  color: var(--text-secondary);
}
.mix-cta {
  margin-top: 16px;
  max-width: 680px;
  margin-left: auto;
  margin-right: auto;
  text-align: center;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.08), rgba(15, 15, 35, 0.45));
}
.mix-cta-title {
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--text-secondary);
}
.mix-start-btn {
  font-size: 1rem;
  font-weight: 700;
  min-height: 52px;
}
.mix-start-btn.mix-start-ready {
  box-shadow: 0 10px 28px rgba(99, 102, 241, 0.34);
}
.mix-start-btn.mix-start-ready:hover {
  box-shadow: 0 14px 34px rgba(99, 102, 241, 0.44);
}
.mix-cta-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 8px;
}
.mix-start-btn:disabled {
  opacity: 0.78;
  cursor: not-allowed;
}
.file-thumb-wrap {
  width: 64px;
  min-width: 64px;
  height: 40px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
}
.file-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.file-thumb-fallback {
  width: 100%;
  height: 100%;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  background: var(--accent-glow);
}
.file-usage-row {
  margin-top: 5px;
}

/* ─── Status Badges ──────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 0.7rem;
  font-weight: 600;
}
.badge-queued { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.badge-processing { background: rgba(59, 130, 246, 0.15); color: var(--info); }
.badge-completed { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.badge-failed { background: rgba(239, 68, 68, 0.15); color: var(--error); }
.badge-expired { background: rgba(85, 85, 112, 0.2); color: var(--text-muted); }

/* ─── Progress Bar ───────────────────────── */
.progress-bar {
  height: 6px;
  background: var(--bg-input);
  border-radius: 100px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--accent-gradient);
  border-radius: 100px;
  transition: width 0.5s ease;
}

/* ─── Stats Grid ─────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  backdrop-filter: blur(10px);
}
.stat-value {
  font-size: 1.8rem;
  font-weight: 800;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ─── Job Card ───────────────────────────── */
.job-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 12px;
  transition: var(--transition);
}
.job-card:hover { border-color: var(--border-active); }
.job-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.job-title { font-size: 0.9rem; font-weight: 600; }
.job-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.job-outputs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
  margin-top: 12px;
}
.output-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px;
  background: var(--bg-glass);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
}

/* ─── Auth Pages ─────────────────────────── */
.auth-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}
.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 40px;
  width: 100%;
  max-width: 400px;
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow-lg);
}
.auth-title {
  text-align: center;
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 4px;
}
.auth-subtitle {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-bottom: 28px;
}
.auth-logo {
  text-align: center;
  margin-bottom: 24px;
}
.auth-logo .logo-icon {
  width: 60px;
  height: 60px;
  background: var(--accent-gradient);
  border-radius: var(--radius-lg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  box-shadow: 0 0 40px rgba(99, 102, 241, 0.3);
}
.auth-switch {
  text-align: center;
  margin-top: 20px;
  font-size: 0.82rem;
  color: var(--text-secondary);
}
.auth-switch a {
  color: var(--accent-1);
  cursor: pointer;
  font-weight: 600;
  text-decoration: none;
}
.auth-switch a:hover { text-decoration: underline; }

/* ─── Toast Notifications ────────────────── */
.toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  font-weight: 500;
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow-md);
  animation: slideIn 0.3s ease;
  max-width: 400px;
}
.toast-success {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: var(--success);
}
.toast-error {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--error);
}
.toast-info {
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.3);
  color: var(--info);
}
@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ─── Loading Spinner ────────────────────── */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent-1);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 40px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ─── Empty State ────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state .empty-icon {
  font-size: 3rem;
  margin-bottom: 12px;
  opacity: 0.4;
}
.empty-state .empty-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

/* ─── Tabs ───────────────────────────────── */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  padding: 4px;
  background: var(--bg-input);
  border-radius: var(--radius-md);
  width: fit-content;
}
.tab {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-secondary);
  transition: var(--transition-fast);
}
.tab:hover { color: var(--text-primary); }
.tab.active {
  background: var(--accent-gradient);
  color: white;
}

/* ─── Grid Layout ────────────────────────── */
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.grid-2 > *,
.grid-3 > * { min-width: 0; }

/* ─── Hidden Pages ───────────────────────── */
.page { display: none; }
.page.active { display: block; animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.range-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 14px;
}
.range-control {
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
}
.range-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  margin-bottom: 8px;
  color: var(--text-secondary);
}
.range-input {
  width: 100%;
  accent-color: var(--accent-1);
}
.form-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: -4px;
  margin-bottom: 14px;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(6px);
}
.modal-card {
  width: min(100%, 920px);
  max-height: 85vh;
  overflow: auto;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-title {
  font-size: 1rem;
  font-weight: 700;
}
.modal-close {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
}
.modal-body {
  padding: 20px;
}
.preview-player {
  width: 100%;
  max-height: 70vh;
  border-radius: var(--radius-lg);
  background: #000;
}

/* Auth hidden */
.app-layout { display: none; }
.app-layout.visible { display: flex; }
.auth-container.hidden { display: none; }

/* ─── Scrollbar ──────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ─── Audio Player ───────────────────────── */
audio {
  width: 100%;
  height: 36px;
  border-radius: var(--radius-sm);
  margin-top: 8px;
}

/* ─── Settings Page ───────────────────────── */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.settings-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.settings-copy {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 16px;
  line-height: 1.5;
}
.settings-inline-help {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.settings-inline-help span {
  font-size: 0.78rem;
  color: var(--text-muted);
}
.settings-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
}
.settings-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.settings-count {
  font-size: 0.78rem;
  color: var(--text-muted);
  background: var(--bg-glass);
  padding: 4px 10px;
  border-radius: 100px;
}
.settings-table-wrap {
  overflow-x: auto;
}
.settings-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.settings-table th {
  text-align: left;
  padding: 10px 12px;
  color: var(--text-muted);
  font-weight: 500;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.settings-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.settings-table tr:last-child td {
  border-bottom: none;
}
.settings-table tr:hover td {
  background: var(--bg-glass);
}
.settings-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 24px 12px;
}
.settings-mono {
  font-family: monospace;
  font-size: 0.8rem;
  color: var(--text-secondary);
}
.settings-chip {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 0.72rem;
  font-weight: 600;
}
.settings-chip-free { background: rgba(99,102,241,0.15); color: var(--accent-1); }
.settings-chip-paid { background: rgba(236,72,153,0.15); color: #ec4899; }
.settings-chip-active { background: rgba(16,185,129,0.15); color: var(--success); }
.settings-chip-inactive { background: rgba(100,100,120,0.15); color: var(--text-muted); }
.settings-name-cell strong { display: block; }
.settings-subtle { font-size: 0.72rem; color: var(--text-muted); }
.settings-actions-cell { text-align: right; }

/* ─── Responsive ─────────────────────────── */
@media (max-width: 768px) {
  .app-header { padding: 0 12px; }
  .header-logo-text { font-size: 0.9rem; }
  .header-user-name { display: none; }
  .main-content { padding: 14px; padding-bottom: 116px; }
  .page-header { margin-bottom: 20px; }
  .page-header h2 { font-size: 1.35rem; }
  .page-header p { font-size: 0.8rem; line-height: 1.45; }
  .card { padding: 14px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .range-grid { grid-template-columns: 1fr; }
  .tabs {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }
  .tab {
    flex: 0 0 auto;
    padding: 8px 12px;
    font-size: 0.76rem;
  }
  .quick-steps-bar {
    justify-content: flex-start;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 10px;
  }
  .step-item { flex: 0 0 auto; }
  .file-item {
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
  }
  .file-item > .file-info {
    flex: 1 1 calc(100% - 90px);
    min-width: 0;
  }
  .file-name {
    white-space: normal;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
  }
  .file-meta { line-height: 1.35; }
  .file-actions {
    flex: 0 0 100%;
    width: 100%;
    justify-content: flex-start;
    margin-top: 8px;
  }
  #page-history .history-item {
    display: grid;
    grid-template-columns: 40px 1fr;
    grid-template-areas:
      "icon info"
      ". status"
      ". actions";
    align-items: start;
    gap: 6px 10px;
  }
  #page-history .history-item .file-icon { grid-area: icon; }
  #page-history .history-item .file-info {
    grid-area: info;
    min-width: 0;
  }
  #page-history .history-status {
    grid-area: status;
    margin: 0;
    justify-self: start;
  }
  #page-history .history-actions {
    grid-area: actions;
    margin: 0;
    width: 100%;
    gap: 6px;
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: 2px;
  }
  #page-history .history-actions .btn {
    flex: 0 0 auto;
    min-height: 30px;
    padding: 6px 9px;
    font-size: 0.72rem;
    white-space: nowrap;
  }
  .bottom-nav { height: 68px; }
  .bottom-nav-item { padding: 6px 0; }
  .bnav-icon { font-size: 1.25rem; }
  .bnav-label { font-size: 0.58rem; letter-spacing: 0; }
  .settings-grid { grid-template-columns: 1fr; }
  .settings-form-row { grid-template-columns: 1fr; }
  .settings-inline-help,
  .settings-actions,
  .settings-header-row { flex-direction: column; align-items: stretch; }
}

/* ─── Quick Steps Bar ───────────────────────── */
.quick-steps-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 20px;
}
.step-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  background: var(--bg-glass);
  border: 1px solid var(--border);
  transition: var(--transition);
  opacity: 0.5;
}
.step-item.active {
  background: var(--accent-glow);
  border-color: var(--accent-1);
  opacity: 1;
}
.step-item.active .step-icon {
  transform: scale(1.1);
}
.step-icon {
  font-size: 1rem;
}
.step-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
}
.step-item.active .step-label {
  color: var(--text-primary);
}
.step-arrow {
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* ─── Persona Chips ─────────────────────────── */
.persona-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 100px;
  background: var(--bg-glass);
  border: 1px solid var(--border);
  font-size: 0.8rem;
  cursor: pointer;
  transition: var(--transition-fast);
  user-select: none;
}
.persona-chip:hover {
  border-color: var(--accent-1);
  background: var(--accent-glow);
}
.persona-chip.selected {
  background: var(--accent-gradient);
  color: white;
  border-color: transparent;
}

.persona-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 8px;
}
.persona-row-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.persona-name-input {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 500;
  outline: none;
  width: 100%;
  min-width: 0;
}
.persona-voice-label {
  font-size: 0.72rem;
  color: var(--text-muted);
}
.persona-voice-select {
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 0.75rem;
  cursor: pointer;
  min-width: 140px;
  max-width: 180px;
}

@media (max-width: 768px) {
  .persona-row {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .persona-voice-select {
    width: 100%;
    min-width: 0;
    max-width: none;
  }
}

/* ─── Editable Persona Chips ───────────────── */
.persona-chip-edit {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 4px;
  padding-left: 12px;
  transition: var(--transition-fast);
}
.persona-chip-edit:hover {
  border-color: var(--accent-1);
}
.persona-edit-input {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 0.8rem;
  width: 120px;
  outline: none;
}
.persona-edit-input:focus {
  border-bottom: 1px solid var(--accent-1);
}
.persona-edit-remove {
  cursor: pointer;
  padding: 4px;
  color: var(--text-muted);
  font-size: 0.9rem;
  transition: var(--transition-fast);
}
.persona-edit-remove:hover {
  color: var(--error);
}


.upload-status-text {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.upload-current-task {
  margin-top: 8px;
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  width: 100%;
  border-radius: 10px;
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-secondary);
  font-size: 0.84rem;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.upload-current-task[data-active='1'] {
  color: var(--text-primary);
  border-color: rgba(99, 102, 241, 0.45);
  background: rgba(99, 102, 241, 0.16);
}

.upload-selection-summary {
  margin-top: 10px;
  border: 1px solid rgba(99, 102, 241, 0.35);
  border-radius: 12px;
  padding: 12px;
  background: rgba(99, 102, 241, 0.08);
}

.upload-selection-title {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--text-primary);
}

.upload-selection-meta {
  margin-top: 4px;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.upload-selection-files {
  margin-top: 8px;
  display: grid;
  gap: 4px;
}

.upload-selection-file {
  font-size: 0.76rem;
  color: var(--text-secondary);
  line-height: 1.35;
  word-break: break-word;
}

.upload-selection-actions {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.upload-selection-actions .btn {
  min-width: 120px;
}


/* Mobile readability enhancements */
@media (max-width: 768px) {
  .btn {
    min-height: 44px;
    padding: 12px 16px;
    font-size: 0.9rem;
  }

  .btn-sm {
    min-height: 40px;
    padding: 8px 12px;
    font-size: 0.8rem;
  }

  .btn-lg {
    min-height: 52px;
    padding: 14px 20px;
    font-size: 0.98rem;
  }

  .card {
    padding: 14px;
    border-radius: 14px;
  }

  .card-title {
    font-size: 1.05rem;
  }

  .form-label {
    font-size: 0.85rem;
  }

  .form-input,
  .form-select,
  .form-textarea {
    min-height: 44px;
    font-size: 0.95rem;
    padding: 10px 12px;
  }

  .form-textarea {
    min-height: 120px;
  }

  .page-header {
    margin-bottom: 18px;
  }

  .page-header h2 {
    font-size: 1.32rem;
    line-height: 1.3;
  }

  .page-header p {
    font-size: 0.88rem;
    line-height: 1.4;
  }

  .tab {
    min-height: 40px;
  }

  .quick-steps-bar {
    padding: 10px;
  }

  .step-item {
    padding: 8px 10px;
    gap: 8px;
  }

  .step-label {
    font-size: 0.8rem;
  }

  .upload-zone {
    padding: 26px 14px;
  }

  .upload-zone .upload-icon {
    font-size: 2.3rem;
    margin-bottom: 10px;
  }

  .upload-zone .upload-title,
  .upload-zone .upload-hint,
  .upload-status-text {
    font-size: 0.88rem;
  }

  .upload-selection-summary {
    padding: 10px;
  }

  .upload-selection-title {
    font-size: 0.84rem;
  }

  .upload-selection-meta,
  .upload-selection-file {
    font-size: 0.78rem;
  }

  .upload-selection-actions {
    gap: 6px;
  }

  .upload-selection-actions .btn {
    flex: 1 1 calc(50% - 3px);
    min-width: 0;
  }

  .upload-zone .upload-current-task {
    font-size: 0.8rem;
    padding: 10px;
    margin-top: 8px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.22);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .upload-zone .upload-current-task[data-active='1'] {
    color: var(--text-primary);
    border-color: rgba(99, 102, 241, 0.4);
    background: rgba(99, 102, 241, 0.16);
  }

  .file-item {
    padding: 12px;
    gap: 10px;
  }

  .file-icon {
    width: 40px;
    height: 40px;
    font-size: 1.1rem;
  }

  .file-name {
    font-size: 0.82rem;
  }

  .file-meta {
    font-size: 0.72rem;
  }

  .file-actions .btn,
  .history-actions .btn {
    min-height: 38px;
  }

  .main-content {
    padding: 12px;
    padding-bottom: 120px;
  }

  .bottom-nav {
    height: 64px;
    padding-top: 4px;
  }

  .bottom-nav-item {
    padding: 4px 0;
    gap: 4px;
  }

  .bnav-icon {
    font-size: 1.22rem;
  }

  .bnav-label {
    font-size: 0.62rem;
    letter-spacing: 0;
  }

  .toast-container {
    top: 8px;
    right: 8px;
    left: 8px;
    width: calc(100vw - 16px);
  }

  .toast {
    width: 100%;
    max-width: none;
    font-size: 0.88rem;
  }

  .upload-progress-wrap {
    margin-top: 10px;
    gap: 6px;
  }
}

@media (max-width: 420px) {
  .app-header {
    padding: 0 10px;
    height: 54px;
  }

  .header-logo-text {
    font-size: 0.9rem;
  }

  .header-logo .logo-icon {
    width: 28px;
    height: 28px;
    font-size: 0.9rem;
  }

  .btn,
  .btn-sm,
  .btn-lg,
  .btn-block {
    width: 100%;
  }

  .mix-start-btn,
  .btn-qa,
  .btn-q {
    min-height: 40px;
  }

  .mix-cta {
    padding: 12px;
  }

  .main-content {
    padding: 10px;
    padding-bottom: 122px;
  }

  .card {
    padding: 12px;
  }

  .page-header h2 {
    font-size: 1.22rem;
  }

  .upload-zone .upload-title,
  .upload-zone .upload-hint,
  .upload-status-text,
  .upload-zone .upload-current-task {
    font-size: 0.86rem;
  }

  .upload-selection-actions .btn {
    flex: 1 1 100%;
  }

  .upload-current-task {
    font-size: 0.84rem;
  }

  .grid-2,
  .grid-3 {
    gap: 10px;
  }

  .form-input,
  .form-select,
  .form-textarea {
    font-size: 0.9rem;
    padding: 10px;
  }

  .file-name {
    font-size: 0.84rem;
  }

  .file-meta {
    font-size: 0.72rem;
  }

  .tab {
    padding: 8px 10px;
    font-size: 0.78rem;
  }

  .mix-page-btn {
    padding: 8px 12px;
    font-size: 0.75rem;
  }

  .mix-cta-hint {
    font-size: 0.74rem;
  }
}

@media (max-width: 360px) {
  .upload-zone {
    padding: 22px 10px;
  }

  .upload-zone .upload-title {
    font-size: 0.92rem;
  }

  .upload-zone .upload-hint,
  .upload-status-text,
  .upload-current-task {
    font-size: 0.8rem;
  }

  .upload-current-task {
    line-height: 1.35;
  }

  .bottom-nav-item {
    padding: 2px 0;
    gap: 2px;
  }

  .btn-qa,
  .btn-q {
    border-radius: 8px;
  }
}





/* ─── AutoMixSJ88 Product Router / Auto Split / Rich TTS History ───────── */
.workflow-card {
  margin-bottom: 18px;
  padding: 18px;
  border: 1px solid rgba(139, 92, 246, 0.25);
  border-radius: var(--radius-xl);
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.72), rgba(17, 24, 39, 0.68));
  box-shadow: var(--shadow-md);
}
.workflow-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 14px;
}
.workflow-title { font-weight: 800; font-size: 1.15rem; color: var(--text-primary); }
.workflow-subtitle { color: var(--text-secondary); font-size: 0.86rem; }
.workflow-pill {
  border: 1px solid rgba(16, 185, 129, 0.35);
  background: rgba(16, 185, 129, 0.12);
  color: #6ee7b7;
  border-radius: 999px;
  padding: 7px 12px;
  font-weight: 700;
  font-size: 0.78rem;
  white-space: nowrap;
}
.template-card-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.template-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  text-align: left;
  color: var(--text-primary);
  background: rgba(255,255,255,0.035);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 10px;
  cursor: pointer;
  transition: var(--transition-fast);
}
.template-card:hover, .template-card.active {
  border-color: rgba(139, 92, 246, 0.72);
  background: rgba(139, 92, 246, 0.12);
  transform: translateY(-1px);
}
.template-visual {
  min-height: 104px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 12px;
  overflow: hidden;
  position: relative;
  border: 1px solid rgba(255,255,255,0.08);
}
.template-visual::before {
  content: '';
  position: absolute;
  inset: 10px auto auto 12px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(255,255,255,0.22);
  box-shadow: 56px 14px 0 rgba(255,255,255,0.08), 126px -6px 0 rgba(255,255,255,0.07);
}
.template-visual span, .template-visual b {
  position: relative;
  z-index: 1;
  background: rgba(0,0,0,0.38);
  color: #fff;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 0.72rem;
}
.template-visual b { border-radius: 8px; font-size: 0.82rem; }
.template-ugc { background: linear-gradient(135deg, #7c3aed, #2563eb); }
.template-factory { background: linear-gradient(135deg, #334155, #0f766e); }
.template-school { background: linear-gradient(135deg, #7f1d1d, #f59e0b); }
.template-home { background: linear-gradient(135deg, #0f766e, #6366f1); }
.template-body strong { display: block; font-size: 0.92rem; }
.template-body small { display: block; color: var(--text-secondary); line-height: 1.35; margin-top: 2px; }
.router-summary {
  margin-top: 8px;
  color: var(--text-secondary);
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  font-size: 0.82rem;
}
.router-summary strong { color: var(--text-primary); }
.advanced-check-grid { display: grid; gap: 9px; }
.advanced-check { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 0.86rem; }
.script-cta-actions { display: grid; grid-template-columns: 0.9fr 1.1fr; gap: 8px; }
.script-progress-line {
  margin-top: 8px;
  color: var(--text-secondary);
  font-size: 0.82rem;
}
.emotion-badges { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.emotion-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border: 1px solid rgba(59,130,246,0.25);
  border-radius: 999px;
  background: rgba(59,130,246,0.10);
  color: #bfdbfe;
  font-size: 0.72rem;
  font-weight: 700;
}
.split-preview-list { display: grid; gap: 10px; }
.split-preview-card {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: rgba(255,255,255,0.03);
}
.split-preview-head { display: flex; justify-content: space-between; gap: 10px; color: var(--text-secondary); font-size: 0.78rem; margin-bottom: 6px; }
.history-toolbar {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) 170px 170px;
  gap: 10px;
  margin: -8px 0 16px;
}
.tts-history-card, .voice-rich-card {
  align-items: stretch;
  gap: 14px;
  background: linear-gradient(135deg, rgba(15,15,35,0.92), rgba(24,24,52,0.82));
  border-color: rgba(139, 92, 246, 0.16);
}
.tts-history-main { flex: 1; min-width: 0; }
.tts-script-preview {
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.45;
  max-height: 3.05em;
  overflow: hidden;
}
.tts-meta-line { color: var(--text-secondary); font-size: 0.8rem; margin-top: 5px; }
.tts-player { width: 100%; margin-top: 10px; }
.tts-action-wrap { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; align-content: flex-start; max-width: 310px; }
.tts-badges { display:flex; flex-wrap:wrap; gap:6px; margin-top:8px; }
.tts-badge {
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.04);
  border-radius: 999px;
  color: var(--text-secondary);
  padding: 3px 8px;
  font-size: 0.72rem;
}
@media (max-width: 980px) {
  .template-card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .history-toolbar { grid-template-columns: 1fr; }
  .script-cta-actions { grid-template-columns: 1fr; }
  .tts-history-card, .voice-rich-card { flex-direction: column; }
  .tts-action-wrap { justify-content: flex-start; max-width: none; }
}
@media (max-width: 520px) {
  .template-card-grid { grid-template-columns: 1fr; }
  .workflow-head { flex-direction: column; }
}

/* ─── Pre Generate Review Gate ────────────────────────────────────────── */
.script-cta-actions {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.preflight-review { display: grid; gap: 14px; color: var(--text-primary); }
.preflight-hero {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 16px;
  align-items: stretch;
}
.preflight-hero .template-visual { min-height: 132px; }
.preflight-hero-info {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: rgba(255,255,255,0.03);
  padding: 16px;
}
.preflight-kicker { color: var(--accent-1); font-weight: 800; font-size: 0.78rem; margin-bottom: 4px; }
.preflight-hero-info h3 { margin: 0 0 6px; font-size: 1.25rem; }
.preflight-hero-info p { margin: 0; color: var(--text-secondary); line-height: 1.5; }
.preflight-meta-line { margin-top: 10px; color: var(--text-muted); font-size: 0.82rem; }
.preflight-check {
  display: flex;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 14px;
  background: rgba(255,255,255,0.035);
}
.preflight-check.ok { border-color: rgba(16,185,129,0.26); background: rgba(16,185,129,0.08); }
.preflight-check.warn { border-color: rgba(245,158,11,0.32); background: rgba(245,158,11,0.09); }
.preflight-check-icon { font-size: 1.25rem; }
.preflight-check strong { display:block; margin-bottom:2px; }
.preflight-check div div { color: var(--text-secondary); font-size: 0.84rem; line-height: 1.45; }
.preflight-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.preflight-stat {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  background: rgba(255,255,255,0.03);
  min-width: 0;
}
.preflight-stat span { display:block; color: var(--text-muted); font-size: 0.74rem; margin-bottom: 4px; }
.preflight-stat strong { display:block; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size: 0.9rem; }
.preflight-section { display: grid; gap: 10px; }
.preflight-section-head { display:flex; justify-content:space-between; gap:10px; color: var(--text-secondary); font-size: 0.82rem; }
.preflight-section-head strong { color: var(--text-primary); }
.preflight-split-offer {
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:10px;
  border:1px solid rgba(59,130,246,0.25);
  border-radius:var(--radius-md);
  background:rgba(59,130,246,0.08);
  padding:10px 12px;
}
.preflight-split-offer strong { display:block; }
.preflight-split-offer span { display:block; color:var(--text-secondary); font-size:0.8rem; }
.preflight-script-list { display:grid; gap:12px; max-height: min(48vh, 520px); overflow:auto; padding-right:4px; }
.preflight-script-card {
  border:1px solid var(--border);
  border-radius:var(--radius-lg);
  background:rgba(255,255,255,0.03);
  padding:12px;
}
.preflight-script-head { display:flex; justify-content:space-between; gap:10px; margin-bottom:8px; }
.preflight-script-head strong { display:block; }
.preflight-script-head small,
.preflight-script-head span { color: var(--text-muted); font-size:0.76rem; }
.preflight-label { display:block; color: var(--text-muted); font-size:0.75rem; margin:8px 0 4px; }
.preflight-script-input { min-height: 112px; }
.preflight-spoken-box {
  margin-top:8px;
  border:1px dashed rgba(255,255,255,0.12);
  border-radius:var(--radius-md);
  padding:8px 10px;
  background:rgba(0,0,0,0.13);
}
.preflight-spoken-box span { color: var(--accent-1); font-weight:700; font-size:0.75rem; }
.preflight-spoken-box p { margin:4px 0 0; color:var(--text-secondary); font-size:0.84rem; line-height:1.45; }
.preflight-empty-tags { color:var(--text-muted); font-size:0.76rem; margin:8px 0; }
.preflight-footer { display:flex; justify-content:flex-end; flex-wrap:wrap; gap:8px; padding-top:4px; }
.preflight-two-col { display:grid; grid-template-columns:1fr 1fr; gap:14px; }
.preflight-mini-list { display:grid; gap:8px; max-height:340px; overflow:auto; }
.preflight-mini-list > div {
  border:1px solid var(--border);
  border-radius:var(--radius-md);
  background:rgba(255,255,255,0.03);
  padding:10px;
}
.preflight-mini-list strong { display:block; font-size:0.86rem; line-height:1.35; }
.preflight-mini-list span { display:block; margin-top:3px; color:var(--text-muted); font-size:0.76rem; }
@media (max-width: 980px) {
  .script-cta-actions { grid-template-columns: 1fr; }
  .preflight-hero { grid-template-columns:1fr; }
  .preflight-stats { grid-template-columns:1fr 1fr; }
  .preflight-two-col { grid-template-columns:1fr; }
}
@media (max-width: 520px) {
  .preflight-stats { grid-template-columns:1fr; }
  .preflight-footer { justify-content:stretch; }
  .preflight-footer .btn { width:100%; }
}
