/* ═══════════════════════════════════════════════════════
   AutoMixSJ88 Python Edition — Next-Gen Design System
   Dark Glassmorphism 2.0 + Mesh Gradient + Micro-anims
   ═══════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');

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

/* ─── Design Tokens ─────────────────────────────────── */
:root {
  /* Backgrounds */
  --bg-deep:       #04040c;
  --bg-primary:    #08081a;
  --bg-secondary:  #0c0c1f;
  --bg-card:       rgba(14, 14, 36, 0.65);
  --bg-card-hover: rgba(22, 22, 55, 0.75);
  --bg-glass:      rgba(255, 255, 255, 0.025);
  --bg-glass-2:    rgba(255, 255, 255, 0.04);
  --bg-input:      rgba(255, 255, 255, 0.045);

  /* Borders */
  --border:        rgba(255, 255, 255, 0.055);
  --border-hover:  rgba(255, 255, 255, 0.10);
  --border-active: rgba(139, 92, 246, 0.45);
  --border-glow:   rgba(99, 102, 241, 0.25);

  /* Typography */
  --text-primary:   #eaeaf2;
  --text-secondary: #8e8ea8;
  --text-muted:     #555570;
  --text-bright:    #ffffff;

  /* Accent Palette */
  --accent-1:  #8b5cf6;
  --accent-2:  #6366f1;
  --accent-3:  #3b82f6;
  --accent-4:  #06b6d4;
  --accent-gradient:   linear-gradient(135deg, #8b5cf6 0%, #6366f1 40%, #3b82f6 100%);
  --accent-gradient-2: linear-gradient(135deg, #a855f7 0%, #6366f1 50%, #06b6d4 100%);
  --accent-glow:       rgba(99, 102, 241, 0.12);

  /* Semantic */
  --success:  #10b981;
  --warning:  #f59e0b;
  --error:    #ef4444;
  --info:     #3b82f6;

  /* Radii */
  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-pill: 100px;

  /* Shadows */
  --shadow-xs:   0 1px 4px rgba(0, 0, 0, 0.25);
  --shadow-sm:   0 2px 10px rgba(0, 0, 0, 0.35);
  --shadow-md:   0 4px 24px rgba(0, 0, 0, 0.45);
  --shadow-lg:   0 8px 44px rgba(0, 0, 0, 0.55);
  --shadow-glow: 0 0 36px rgba(99, 102, 241, 0.10);
  --shadow-card: 0 4px 32px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255,255,255,0.03);

  /* Transitions */
  --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
  --t-fast:   0.15s;
  --t-normal: 0.3s;
  --t-slow:   0.5s;

  /* Layout */
  --sidebar-w: 264px;
  --sidebar-collapsed-w: 72px;
  --header-h: 0px;
}

/* ─── Base ──────────────────────────────────────────── */
html { font-size: 15px; scroll-behavior: smooth; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-deep);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.65;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ─── Mesh Gradient Background ──────────────────────── */
body::before {
  content: '';
  position: fixed; inset: 0;
  z-index: 0;
  background:
    radial-gradient(ellipse at 15% 20%, rgba(139, 92, 246, 0.06) 0%, transparent 55%),
    radial-gradient(ellipse at 85% 75%, rgba(59, 130, 246, 0.05) 0%, transparent 55%),
    radial-gradient(ellipse at 50% 0%,  rgba(168, 85, 247, 0.04) 0%, transparent 60%),
    radial-gradient(ellipse at 50% 100%, rgba(6, 182, 212, 0.03) 0%, transparent 50%);
  animation: meshFloat 40s ease-in-out infinite alternate;
  pointer-events: none;
}
body::after {
  content: '';
  position: fixed; inset: 0;
  z-index: 0;
  background: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.02'/%3E%3C/svg%3E");
  opacity: 0.4;
  pointer-events: none;
}
@keyframes meshFloat {
  0%   { transform: scale(1) translate(0, 0); }
  50%  { transform: scale(1.02) translate(1%, -1%); }
  100% { transform: scale(1) translate(-1%, 1%); }
}

/* ─── Layout ────────────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

/* ─── Sidebar ───────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  top: 0; left: 0;
  z-index: 200;
  backdrop-filter: blur(24px) saturate(1.5);
  transition: width var(--t-normal) var(--ease-smooth), transform var(--t-normal) var(--ease-smooth);
  overflow-y: auto;
  overflow-x: hidden;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.08);
  border-radius: 100px;
}

/* Sidebar Logo */
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}
.sidebar-logo .logo-icon {
  width: 42px; height: 42px;
  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 24px rgba(99, 102, 241, 0.35);
  flex-shrink: 0;
  animation: logoPulse 4s ease-in-out infinite;
}
@keyframes logoPulse {
  0%, 100% { box-shadow: 0 0 24px rgba(99, 102, 241, 0.35); }
  50% { box-shadow: 0 0 36px rgba(139, 92, 246, 0.45); }
}
.sidebar-logo h1 {
  font-size: 1.12rem;
  font-weight: 800;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.01em;
}
.sidebar-logo small {
  font-size: 0.68rem;
  color: var(--text-muted);
  display: block;
  margin-top: 1px;
  letter-spacing: 0.03em;
}

/* Navigation */
.nav-section { margin-bottom: 6px; }
.nav-label {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.8px;
  color: var(--text-muted);
  padding: 0 10px;
  margin-bottom: 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--t-fast) ease;
  font-size: 0.88rem;
  font-weight: 500;
  position: relative;
  overflow: hidden;
  user-select: none;
}
.nav-item::before {
  content: '';
  position: absolute;
  left: 0; top: 50%;
  transform: translateY(-50%) scaleY(0);
  width: 3px; height: 55%;
  background: var(--accent-gradient);
  border-radius: 0 4px 4px 0;
  transition: transform var(--t-normal) var(--ease-bounce);
}
.nav-item:hover {
  background: var(--bg-glass-2);
  color: var(--text-primary);
}
.nav-item.active {
  background: var(--accent-glow);
  color: var(--accent-1);
}
.nav-item.active::before {
  transform: translateY(-50%) scaleY(1);
}
.nav-icon {
  font-size: 1.08rem;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

/* Sidebar User */
.sidebar-user {
  margin-top: auto;
  padding: 14px 10px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-avatar {
  width: 36px; height: 36px;
  background: var(--accent-gradient);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 0.82rem;
  color: white;
  flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.user-email {
  font-size: 0.64rem;
  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;
  border-radius: var(--radius-sm);
  transition: all var(--t-fast) ease;
}
.btn-logout:hover { color: var(--error); background: rgba(239, 68, 68, 0.08); }

/* Mobile hamburger */
.mobile-toggle {
  display: none;
  position: fixed;
  top: 12px; left: 12px;
  z-index: 300;
  width: 44px; height: 44px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1px solid var(--border);
  backdrop-filter: blur(10px);
  color: var(--text-primary);
  font-size: 1.3rem;
  cursor: pointer;
  align-items: center; justify-content: center;
}
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(3px);
  z-index: 150;
}

/* ─── Main Content ──────────────────────────────────── */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 32px 36px;
  min-height: 100vh;
  max-width: calc(100vw - var(--sidebar-w));
  overflow-x: hidden;
  position: relative;
  z-index: 1;
}

/* ─── Page System ───────────────────────────────────── */
.page { display: none; }
.page.active {
  display: block;
  animation: pageIn 0.35s var(--ease-smooth);
}
@keyframes pageIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── Page Header ───────────────────────────────────── */
.page-header { margin-bottom: 28px; }
.page-header h2 {
  font-size: 1.55rem;
  font-weight: 800;
  margin-bottom: 6px;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--text-primary), var(--accent-1));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.page-header p {
  color: var(--text-secondary);
  font-size: 0.88rem;
  line-height: 1.5;
}

/* ─── Cards ─────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  backdrop-filter: blur(12px) saturate(1.2);
  box-shadow: var(--shadow-card);
  transition: border-color var(--t-normal) ease, box-shadow var(--t-normal) ease;
  overflow: hidden;
  min-width: 0;
  position: relative;
}
.card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(135deg,
    rgba(139, 92, 246, 0.04) 0%,
    transparent 40%,
    transparent 60%,
    rgba(59, 130, 246, 0.03) 100%);
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--t-normal) ease;
}
.card:hover {
  border-color: var(--border-glow);
  box-shadow: var(--shadow-glow), var(--shadow-card);
}
.card:hover::before { opacity: 1; }

.card-title {
  font-size: 0.98rem;
  font-weight: 700;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-primary);
}

/* ─── Buttons ───────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 22px;
  border-radius: var(--radius-md);
  border: none;
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--t-fast) ease;
  position: relative;
  overflow: hidden;
  isolation: isolate;
  user-select: none;
}
/* Ripple */
.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at var(--ripple-x, 50%) var(--ripple-y, 50%), rgba(255,255,255,0.2) 0%, transparent 70%);
  opacity: 0;
  transition: opacity 0.4s ease;
}
.btn:active::after { opacity: 1; transition: opacity 0s; }

.btn-primary {
  background: var(--accent-gradient);
  color: white;
  box-shadow: 0 4px 18px rgba(99, 102, 241, 0.30);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 28px rgba(99, 102, 241, 0.40);
  filter: brightness(1.08);
}
.btn-primary:active {
  transform: translateY(0);
  box-shadow: 0 2px 10px rgba(99, 102, 241, 0.25);
}

.btn-secondary {
  background: var(--bg-glass-2);
  color: var(--text-primary);
  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.12);
  color: var(--error);
  border: 1px solid rgba(239, 68, 68, 0.18);
}
.btn-danger:hover { background: rgba(239, 68, 68, 0.22); }

.btn-success {
  background: rgba(16, 185, 129, 0.12);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.18);
}
.btn-success:hover { background: rgba(16, 185, 129, 0.22); }

.btn-sm { padding: 6px 14px; font-size: 0.76rem; border-radius: var(--radius-sm); }
.btn-lg { padding: 14px 30px; font-size: 0.95rem; border-radius: var(--radius-lg); }
.btn-block { width: 100%; }
.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none !important;
  filter: none !important;
}

/* ─── Inputs ────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  letter-spacing: 0.01em;
}
.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.84rem;
  transition: border-color var(--t-fast) ease, box-shadow var(--t-fast) ease;
  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.12), 0 0 16px rgba(139, 92, 246, 0.06);
}
.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--text-muted);
}
.form-textarea {
  resize: vertical;
  min-height: 80px;
  line-height: 1.55;
}
.form-select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238888a0' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}
.form-select option {
  background: var(--bg-secondary);
  color: var(--text-primary);
}
.form-hint {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ─── Upload Zone ───────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 44px 24px;
  text-align: center;
  cursor: pointer;
  transition: all var(--t-normal) var(--ease-smooth);
  position: relative;
}
.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--accent-1);
  background: var(--accent-glow);
}
.upload-zone.drag-over { transform: scale(1.01); }
.upload-zone .upload-icon {
  font-size: 2.8rem;
  margin-bottom: 12px;
  opacity: 0.45;
}
.upload-zone .upload-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 6px;
}
.upload-zone .upload-hint {
  font-size: 0.76rem;
  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: all var(--t-fast) ease;
}
.file-item:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-hover);
}
.file-icon {
  font-size: 1.2rem;
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-glow);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}
.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.68rem;
  color: var(--text-muted);
  margin-top: 1px;
}
.file-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.file-checkbox {
  width: 18px; height: 18px;
  accent-color: var(--accent-1);
  cursor: pointer;
}

/* ─── Badges ────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 12px;
  border-radius: var(--radius-pill);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.badge-queued     { background: rgba(245,158,11,0.12); color: var(--warning); }
.badge-processing { background: rgba(59,130,246,0.12); color: var(--info); animation: badgePulse 2s ease-in-out infinite; }
.badge-completed  { background: rgba(16,185,129,0.12); color: var(--success); }
.badge-failed     { background: rgba(239,68,68,0.12);  color: var(--error); }
.badge-expired    { background: rgba(85,85,112,0.15);   color: var(--text-muted); }
@keyframes badgePulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.65; }
}

/* ─── Progress Bar ──────────────────────────────────── */
.progress-bar {
  height: 6px;
  background: var(--bg-input);
  border-radius: var(--radius-pill);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--accent-gradient);
  border-radius: var(--radius-pill);
  transition: width 0.5s var(--ease-smooth);
  position: relative;
}
.progress-fill::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.25) 50%, transparent 100%);
  animation: progressShimmer 1.5s infinite;
}
@keyframes progressShimmer {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* ─── Auth Pages ────────────────────────────────────── */
.auth-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  position: relative;
  z-index: 1;
  padding: 24px;
}
.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 44px 40px;
  width: 100%;
  max-width: 420px;
  backdrop-filter: blur(24px) saturate(1.3);
  box-shadow: var(--shadow-lg), 0 0 60px rgba(99, 102, 241, 0.06);
  position: relative;
}
.auth-card::before {
  content: '';
  position: absolute;
  top: -1px; left: -1px; right: -1px; bottom: -1px;
  border-radius: inherit;
  background: var(--accent-gradient);
  z-index: -1;
  opacity: 0.08;
  filter: blur(0px);
}
.auth-logo {
  text-align: center;
  margin-bottom: 28px;
}
.auth-logo .logo-icon {
  width: 64px; height: 64px;
  background: var(--accent-gradient);
  border-radius: var(--radius-lg);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.9rem;
  box-shadow: 0 0 48px rgba(99,102,241,0.35);
  animation: authLogoPulse 3s ease-in-out infinite;
}
@keyframes authLogoPulse {
  0%, 100% { box-shadow: 0 0 48px rgba(99,102,241,0.35); transform: scale(1); }
  50% { box-shadow: 0 0 64px rgba(139,92,246,0.45); transform: scale(1.03); }
}
.auth-title {
  text-align: center;
  font-size: 1.4rem;
  font-weight: 800;
  margin-bottom: 4px;
  letter-spacing: -0.02em;
}
.auth-subtitle {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.84rem;
  margin-bottom: 28px;
}
.auth-switch {
  text-align: center;
  margin-top: 22px;
  font-size: 0.82rem;
  color: var(--text-secondary);
}
.auth-switch a {
  color: var(--accent-1);
  cursor: pointer;
  font-weight: 600;
  text-decoration: none;
  transition: color var(--t-fast) ease;
}
.auth-switch a:hover { color: var(--accent-3); text-decoration: underline; }

/* ─── Toast Notifications ───────────────────────────── */
.toast-container {
  position: fixed;
  top: 20px; right: 20px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  font-weight: 500;
  backdrop-filter: blur(14px) saturate(1.3);
  box-shadow: var(--shadow-md);
  animation: toastIn 0.35s var(--ease-smooth);
  max-width: 420px;
  pointer-events: all;
  display: flex;
  align-items: center;
  gap: 10px;
}
.toast-success { background: rgba(16,185,129,0.14); border: 1px solid rgba(16,185,129,0.28); color: var(--success); }
.toast-error   { background: rgba(239,68,68,0.14);  border: 1px solid rgba(239,68,68,0.28);  color: var(--error); }
.toast-info    { background: rgba(59,130,246,0.14);  border: 1px solid rgba(59,130,246,0.28);  color: var(--info); }
.toast-warning { background: rgba(245,158,11,0.14); border: 1px solid rgba(245,158,11,0.28); color: var(--warning); }
.toast-exit { animation: toastOut 0.25s var(--ease-smooth) forwards; }
@keyframes toastIn {
  from { transform: translateX(100%) scale(0.95); opacity: 0; }
  to   { transform: translateX(0) scale(1); opacity: 1; }
}
@keyframes toastOut {
  from { transform: translateX(0) scale(1); opacity: 1; }
  to   { transform: translateX(100%) scale(0.95); opacity: 0; }
}

/* ─── Spinner & Loading ─────────────────────────────── */
.spinner {
  width: 20px; height: 20px;
  border: 2.5px solid var(--border);
  border-top-color: var(--accent-1);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 40px;
  color: var(--text-muted);
  font-size: 0.84rem;
}

/* Skeleton */
.skeleton {
  background: linear-gradient(90deg, var(--bg-glass) 25%, var(--bg-glass-2) 50%, var(--bg-glass) 75%);
  background-size: 200% 100%;
  animation: skeletonShimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}
@keyframes skeletonShimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skeleton-text { height: 14px; margin-bottom: 8px; }
.skeleton-title { height: 20px; width: 60%; margin-bottom: 12px; }

/* ─── Empty State ───────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 56px 24px;
  color: var(--text-muted);
}
.empty-state .empty-icon {
  font-size: 3.2rem;
  margin-bottom: 14px;
  opacity: 0.35;
}
.empty-state .empty-title {
  font-size: 0.98rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.empty-state .empty-desc {
  font-size: 0.8rem;
  max-width: 320px;
  margin: 0 auto;
  line-height: 1.5;
}

/* ─── 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 18px;
  border-radius: var(--radius-sm);
  font-size: 0.79rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all var(--t-fast) ease;
  user-select: none;
}
.tab:hover { color: var(--text-primary); }
.tab.active {
  background: var(--accent-gradient);
  color: white;
  box-shadow: 0 2px 10px rgba(99, 102, 241, 0.25);
}

/* ─── Grid Layouts ──────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }

/* ─── Voice Workspace ───────────────────────────────── */
.voice-workspace {
  display: grid;
  grid-template-columns: minmax(280px, 0.85fr) minmax(320px, 0.95fr) minmax(480px, 1.45fr);
  gap: 18px;
  align-items: start;
}
.voice-panel-output {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 140px);
  max-height: calc(100vh - 120px);
  overflow: hidden;
}
.voice-manual-box {
  margin-bottom: 14px;
  padding: 18px;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.06);
  background:
    linear-gradient(180deg, rgba(139,92,246,0.06), rgba(17,24,39,0.12)),
    rgba(255,255,255,0.015);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.035);
}
.voice-manual-title {
  margin-bottom: 10px;
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.voice-manual-row {
  display: flex;
  gap: 10px;
}

/* Script Results */
.scripts-stack {
  flex: 1;
  overflow-y: auto;
  padding-right: 6px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.scripts-stack::-webkit-scrollbar { width: 4px; }
.scripts-stack::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.08);
  border-radius: 100px;
}
.script-result-card {
  padding: 20px;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(139, 92, 246, 0.15);
  background:
    radial-gradient(circle at top right, rgba(99, 102, 241, 0.08), transparent 32%),
    linear-gradient(180deg, rgba(22, 22, 44, 0.92), rgba(13, 13, 26, 0.90));
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22);
  transition: border-color var(--t-normal) ease;
}
.script-result-card:hover {
  border-color: rgba(139, 92, 246, 0.3);
}

/* Voice Status */
.voice-status-panel {
  margin-bottom: 14px;
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-glass);
}
.voice-status-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.voice-status-badge {
  padding: 3px 12px;
  border-radius: var(--radius-pill);
  font-size: 0.68rem;
  font-weight: 700;
}
.voice-status-idle  { background: rgba(16,185,129,0.12); color: var(--success); }
.voice-status-busy  { background: rgba(59,130,246,0.12);  color: var(--info); animation: badgePulse 2s ease-in-out infinite; }
.voice-status-error { background: rgba(239,68,68,0.12);   color: var(--error); }
.voice-status-current {
  font-size: 0.78rem;
  color: var(--text-secondary);
}
.voice-status-log {
  font-size: 0.72rem;
  color: var(--text-muted);
  max-height: 80px;
  overflow-y: auto;
  margin-top: 6px;
}

/* TTS Job Panel */
.tts-job-panel {
  margin-bottom: 14px;
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-glass);
}
.tts-job-list { max-height: 200px; overflow-y: auto; }

/* ─── Job Card ──────────────────────────────────────── */
.job-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 12px;
  transition: border-color var(--t-normal) ease;
}
.job-card:hover { border-color: var(--border-glow); }
.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.73rem;
  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.73rem;
}

/* ─── Stats Grid ────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  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);
  transition: border-color var(--t-normal) ease;
}
.stat-card:hover { border-color: var(--border-glow); }
.stat-value {
  font-size: 1.9rem;
  font-weight: 900;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
}
.stat-label {
  font-size: 0.73rem;
  color: var(--text-muted);
  margin-top: 2px;
  font-weight: 500;
}

/* ─── Modal ─────────────────────────────────────────── */
.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(8px);
  animation: fadeIn 0.2s ease;
}
.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 22px;
  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;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: all var(--t-fast) ease;
}
.modal-close:hover { background: var(--bg-glass-2); color: var(--text-primary); }
.modal-body { padding: 22px; }
.preview-player {
  width: 100%;
  max-height: 70vh;
  border-radius: var(--radius-lg);
  background: #000;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ─── Settings ──────────────────────────────────────── */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}
.settings-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.settings-copy {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-bottom: 16px;
  line-height: 1.5;
}
.settings-actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}
.settings-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.settings-count {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 600;
}
.settings-table-wrap { overflow-x: auto; }
.settings-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}
.settings-table th {
  text-align: left;
  padding: 8px 10px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.settings-table td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
}
.settings-table tr:hover td {
  background: var(--bg-glass);
}
.settings-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 24px !important;
}
.settings-inline-help {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* ─── Responsive ────────────────────────────────────── */
@media (max-width: 1200px) {
  .voice-workspace {
    grid-template-columns: minmax(260px, 1fr) minmax(280px, 1fr);
  }
  .voice-workspace > .card:nth-child(3) {
    grid-column: 1 / -1;
  }
}
@media (max-width: 960px) {
  .voice-workspace {
    grid-template-columns: 1fr;
  }
  .voice-panel-output {
    min-height: auto;
    max-height: none;
  }
  .settings-grid { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    width: 280px;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }
  .mobile-toggle { display: flex; }
  .main-content {
    margin-left: 0;
    max-width: 100vw;
    padding: 60px 16px 24px;
  }
  .auth-card { padding: 32px 24px; }
  .settings-form-row { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .tabs { flex-wrap: wrap; width: 100%; }
  .tab { flex: 1 1 45%; text-align: center; }
}
