:root {
  --bg: #080a0f;
  --surface: #111520;
  --surface-2: #171c2b;
  --border: rgba(255, 255, 255, 0.08);
  --text: #eef2ff;
  --muted: #8b95b0;
  --primary: #7c5cff;
  --primary-hover: #6a46ff;
  --accent: #00d2ff;
  --success: #22c55e;
  --danger: #ef4444;
  --radius: 14px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  background: radial-gradient(circle at top right, #161830 0%, var(--bg) 55%);
  color: var(--text);
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  background: rgba(8, 10, 15, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 18px;
}
.brand-icon {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: grid;
  place-items: center;
  color: #fff;
}
.badge-beta {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(124, 92, 255, 0.18);
  color: #c4b5fd;
  border: 1px solid rgba(124, 92, 255, 0.35);
}

.nav-tabs { display: flex; gap: 6px; }
.nav-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}
.nav-btn.active, .nav-btn:hover {
  color: var(--text);
  background: var(--surface-2);
}

.user-area { display: flex; align-items: center; gap: 12px; }
.credits-pill {
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(0, 210, 255, 0.12);
  border: 1px solid rgba(0, 210, 255, 0.3);
  color: #7dd3fc;
}

.container { max-width: 1360px; margin: 0 auto; padding: 28px 24px 60px; }

/* Buttons */
.btn {
  border: none;
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  transition: 0.15s ease;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: #20273b; }
.btn-accent {
  background: linear-gradient(135deg, rgba(124, 92, 255, 0.22), rgba(0, 210, 255, 0.22));
  border: 1px solid rgba(0, 210, 255, 0.35);
  color: #e0f2fe;
}
.btn-accent:hover { filter: brightness(1.15); }
.btn-danger { background: rgba(239, 68, 68, 0.15); color: #fca5a5; border: 1px solid rgba(239, 68, 68, 0.3); }
.btn-sm { padding: 7px 12px; font-size: 13px; }
.btn-lg { padding: 13px 22px; font-size: 15px; }
.btn-full { width: 100%; }
.link-btn { background: none; border: none; color: var(--accent); cursor: pointer; font-weight: 600; padding: 0; }

/* Hero / Auth Gate */
.auth-gate {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 40px;
  align-items: center;
  padding: 40px 0;
}
.pill {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(124, 92, 255, 0.15);
  border: 1px solid rgba(124, 92, 255, 0.35);
  color: #c4b5fd;
  margin-bottom: 16px;
}
.hero-copy h1 { font-size: 46px; line-height: 1.12; margin: 0 0 18px; }
.gradient-text {
  background: linear-gradient(90deg, #a78bfa, #38bdf8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.hero-copy p { font-size: 17px; line-height: 1.6; color: var(--muted); max-width: 560px; margin-bottom: 28px; }
.hero-actions { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 34px; }
.hero-stats { display: flex; gap: 32px; border-top: 1px solid var(--border); padding-top: 22px; }
.hero-stats strong { display: block; font-size: 15px; }
.hero-stats span { font-size: 13px; color: var(--muted); }

.hero-preview-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.mock-16x9 {
  width: 100%;
  aspect-ratio: 16/9;
  background: #0d121d;
  border-radius: 12px;
  border: 1px solid var(--border);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-around;
}
.mock-face {
  padding: 12px 14px;
  border-radius: 10px;
  background: rgba(255,255,255,0.06);
  font-size: 12px;
  color: var(--muted);
}
.mock-face.speaking {
  border: 2px solid var(--success);
  color: #86efac;
}
.mock-crop-box {
  position: absolute;
  right: 12%;
  top: 6%;
  bottom: 6%;
  width: 32%;
  border: 2px dashed var(--accent);
  border-radius: 8px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 6px;
  font-size: 11px;
  color: var(--accent);
}
.mock-arrow { font-size: 13px; color: var(--muted); font-weight: 600; }
.mock-9x16 {
  width: 140px;
  aspect-ratio: 9/16;
  background: #0d121d;
  border: 3px solid #2a324b;
  border-radius: 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  gap: 8px;
}
.mock-phone-notch { width: 44px; height: 5px; background: #2a324b; border-radius: 99px; position: absolute; top: 8px; }
.mock-phone-speaker { font-weight: 700; font-size: 14px; }
.mock-phone-badge { font-size: 10px; padding: 3px 8px; border-radius: 99px; background: rgba(34, 197, 94, 0.2); color: #86efac; }

/* Studio Grid */
.studio-grid { display: grid; grid-template-columns: 380px 1fr; gap: 22px; align-items: start; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; gap: 12px; }
.card-header h2 { margin: 0; font-size: 17px; }
.muted { color: var(--muted); font-size: 13px; }

.source-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  background: var(--surface-2);
  border-radius: 10px;
  margin-bottom: 14px;
}
.source-tab {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 8px 10px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.source-tab.active {
  background: var(--primary);
  color: #fff;
}
.url-panel {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  background: rgba(124, 92, 255, 0.05);
}
.url-panel input[type="url"] {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 14px;
}

.drop-zone {
  border: 2px dashed rgba(124, 92, 255, 0.4);
  border-radius: 12px;
  padding: 26px 16px;
  text-align: center;
  background: rgba(124, 92, 255, 0.05);
  transition: 0.15s;
}
.drop-zone.dragover { border-color: var(--accent); background: rgba(0, 210, 255, 0.08); }
.drop-icon { font-size: 28px; margin-bottom: 6px; }
.drop-title { margin: 0 0 4px; font-weight: 600; font-size: 14px; }
.drop-sub { margin: 0; font-size: 13px; color: var(--muted); }

.divider {
  display: flex;
  align-items: center;
  text-align: center;
  margin: 16px 0;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.08em;
}
.divider::before, .divider::after { content: ""; flex: 1; border-bottom: 1px solid var(--border); }
.divider span { padding: 0 10px; }

.settings-section { margin-top: 20px; display: flex; flex-direction: column; gap: 14px; }
.settings-section h3 { margin: 0; font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.field span { color: #cbd5e1; }
.field input[type="text"], .field input[type="email"], .field input[type="password"], .field select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 14px;
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.checkbox-field { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #cbd5e1; cursor: pointer; }

/* Preview & Progress */
.preview-actions { display: flex; align-items: center; gap: 12px; }
.safezone-toggle { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); cursor: pointer; }
.preview-empty {
  min-height: 360px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--muted);
  padding: 32px;
}
.empty-badge {
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 12px;
  margin-bottom: 10px;
}

.progress-box { background: var(--surface-2); border-radius: 12px; padding: 16px; margin-bottom: 18px; }
.progress-top { display: flex; justify-content: space-between; font-size: 14px; font-weight: 600; margin-bottom: 10px; }
.progress-bar-bg { height: 8px; background: #0c0f17; border-radius: 999px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: linear-gradient(90deg, var(--primary), var(--accent)); transition: width 0.25s; }
.pipeline-steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 12px; }
.step {
  font-size: 12px;
  text-align: center;
  padding: 6px;
  border-radius: 7px;
  background: rgba(255,255,255,0.03);
  color: var(--muted);
}
.step.active { background: rgba(124, 92, 255, 0.2); color: #ddd6fe; font-weight: 600; }
.step.done { background: rgba(34, 197, 94, 0.16); color: #86efac; }

.video-pair { display: grid; grid-template-columns: 1.35fr 0.65fr; gap: 18px; align-items: start; }
.video-box { display: flex; flex-direction: column; gap: 8px; }
.video-label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; }
.video-box video { width: 100%; border-radius: 10px; background: #000; }

.phone-frame {
  position: relative;
  width: 100%;
  max-width: 280px;
  margin: 0 auto;
  aspect-ratio: 9/16;
  border-radius: 20px;
  overflow: hidden;
  border: 3px solid #2b334a;
  background: #000;
}
.phone-frame video { width: 100%; height: 100%; object-fit: cover; border-radius: 0; }
.safe-zone-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 12px;
  font-size: 10px;
  color: rgba(255,255,255,0.85);
}
.sz-top { background: rgba(239, 68, 68, 0.28); padding: 6px; border-radius: 6px; text-align: center; }
.sz-right { align-self: flex-end; background: rgba(239, 68, 68, 0.28); padding: 10px 6px; border-radius: 6px; writing-mode: vertical-rl; }
.sz-bottom { background: rgba(239, 68, 68, 0.28); padding: 10px 6px; border-radius: 6px; text-align: center; }

.sync-controls { display: flex; gap: 10px; margin-top: 12px; }

.timeline-card { margin-top: 18px; background: var(--surface-2); border-radius: 12px; padding: 14px; }
.timeline-header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.timeline-header h3 { margin: 0; font-size: 14px; }
.timeline-stats { font-size: 12px; color: var(--muted); display: flex; gap: 12px; }
.speaker-timeline-bar {
  height: 28px;
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  background: #0b0e16;
}
.timeline-seg {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: #080a0f;
  overflow: hidden;
  white-space: nowrap;
  border-right: 1px solid rgba(0,0,0,0.25);
}
.speaker-legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 10px; font-size: 12px; color: var(--muted); }
.legend-item { display: flex; align-items: center; gap: 6px; }
.legend-dot { width: 10px; height: 10px; border-radius: 3px; }

/* Library & Plans */
.section-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.section-head h2 { margin: 0; }
.jobs-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.job-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.job-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.job-title { font-weight: 600; font-size: 15px; }
.status-badge { font-size: 11px; padding: 3px 8px; border-radius: 999px; font-weight: 600; }
.status-completed { background: rgba(34, 197, 94, 0.16); color: #86efac; }
.status-processing, .status-queued { background: rgba(0, 210, 255, 0.16); color: #7dd3fc; }
.status-failed { background: rgba(239, 68, 68, 0.16); color: #fca5a5; }
.job-meta { font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 10px; }
.job-actions { display: flex; gap: 8px; margin-top: 4px; }

.plans-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; }
.plan-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.plan-card.current { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.plan-price { font-size: 32px; font-weight: 700; }
.plan-price span { font-size: 14px; color: var(--muted); font-weight: 400; }
.plan-features { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; font-size: 14px; color: #cbd5e1; }

/* Modal & Toast */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: grid;
  place-items: center;
  z-index: 100;
}
.modal-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  position: relative;
}
.modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 22px;
  cursor: pointer;
}
.modal-tabs { display: flex; gap: 8px; margin-bottom: 18px; }
.modal-tabs button {
  flex: 1;
  padding: 9px;
  border: none;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
  font-weight: 600;
  cursor: pointer;
}
.modal-tabs button.active { background: var(--primary); color: #fff; }
.modal-card form { display: flex; flex-direction: column; gap: 12px; }
.error-text { color: #fca5a5; font-size: 13px; margin: 0; }

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 14px;
  z-index: 200;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
}

@media (max-width: 980px) {
  .auth-gate, .studio-grid, .video-pair { grid-template-columns: 1fr; }
}
