:root {
  --bg-primary: #09090B;
  --bg-surface: #111114;
  --bg-card: #141418;
  --bg-card-hover: #1A1A20;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(245, 158, 11, 0.5);
  --text-main: #FAFAFA;
  --text-muted: #A1A1AA;
  --text-dim: #71717A;
  --accent: #F59E0B;
  --accent-glow: rgba(245, 158, 11, 0.25);
  --accent-hover: #D97706;
  --emerald: #10B981;
  --danger: #EF4444;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-main);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

/* Ambient glow */
.glow-orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  pointer-events: none;
  z-index: 0;
}
.glow-top {
  top: -100px;
  left: 20%;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(245, 158, 11, 0.12) 0%, transparent 70%);
}
.glow-right {
  top: 30%;
  right: -100px;
  width: 450px;
  height: 450px;
  background: radial-gradient(circle, rgba(245, 158, 11, 0.08) 0%, transparent 70%);
}
.glow-bottom {
  bottom: -100px;
  right: 20%;
  width: 450px;
  height: 450px;
  background: radial-gradient(circle, rgba(245, 158, 11, 0.1) 0%, transparent 70%);
}

/* Navbar */
.studio-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 28px;
  background: rgba(17, 17, 20, 0.85);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-color);
}
.nav-left, .nav-right {
  display: flex;
  align-items: center;
  gap: 16px;
}
.logo-pill {
  display: flex;
  align-items: center;
  gap: 8px;
}
.logo-text {
  font-family: 'Montserrat', sans-serif;
  font-weight: 900;
  font-size: 20px;
  letter-spacing: -0.5px;
  color: #FFFFFF;
}
.accent-dot {
  color: var(--accent);
}
.logo-badge {
  font-size: 10px;
  font-weight: 700;
  background: rgba(245, 158, 11, 0.15);
  color: var(--accent);
  padding: 3px 7px;
  border-radius: 6px;
  border: 1px solid rgba(245, 158, 11, 0.3);
  letter-spacing: 0.5px;
}
.status-tag {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--emerald);
  background: rgba(16, 185, 129, 0.1);
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid rgba(16, 185, 129, 0.2);
}
.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--emerald);
  box-shadow: 0 0 8px var(--emerald);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}
.nav-btn:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.15);
}
.nav-btn-danger:hover {
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.3);
}
.badge-count {
  background: var(--accent);
  color: #000;
  font-size: 11px;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 10px;
}

/* Studio Layout */
.studio-layout {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 28px;
  padding: 24px 28px;
  max-width: 1600px;
  margin: 0 auto;
}
@media (max-width: 1200px) {
  .studio-layout {
    grid-template-columns: 1fr;
  }
}

/* Builder Cards */
.builder-scroll-pane {
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.studio-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
  transition: var(--transition);
}
.studio-card:focus-within {
  border-color: rgba(245, 158, 11, 0.3);
}
.card-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
}
.step-num {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: #000;
  font-family: 'Montserrat', sans-serif;
  font-weight: 900;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.card-title-group h2 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
  margin-bottom: 4px;
}
.card-title-group p {
  font-size: 13px;
  color: var(--text-muted);
}

/* Form inputs */
.form-group {
  margin-bottom: 16px;
}
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #D4D4D8;
  margin-bottom: 8px;
}
.label-split {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.label-hint {
  font-size: 12px;
  color: var(--text-dim);
}
input[type="text"],
input[type="password"],
textarea,
select.form-select {
  width: 100%;
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  transition: var(--transition);
}
input[type="text"]:focus,
input[type="password"]:focus,
textarea:focus,
select.form-select:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px var(--accent-glow);
}
.input-highlight {
  border-color: rgba(245, 158, 11, 0.35) !important;
  color: #FDE68A !important;
  font-weight: 600;
}

.input-action-row {
  display: flex;
  gap: 10px;
}
.btn-ai {
  display: flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #F59E0B 0%, #D97706 100%);
  color: #000;
  font-size: 13px;
  font-weight: 700;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition);
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.3);
}
.btn-ai:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(245, 158, 11, 0.45);
}

.grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.grid-3col {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}
@media (max-width: 768px) {
  .grid-2col, .grid-3col {
    grid-template-columns: 1fr;
  }
}

/* Audio & Preview Buttons */
.select-preview-row {
  display: flex;
  gap: 8px;
}
.btn-icon-play {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: var(--transition);
}
.btn-icon-play:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent);
}

/* Range Slider */
.range-slider {
  width: 100%;
  accent-color: var(--accent);
  height: 6px;
  background: var(--bg-card);
  border-radius: 4px;
  cursor: pointer;
}

/* Toggle Box */
.toggle-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.toggle-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.toggle-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-main);
}
.toggle-desc {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
}

/* Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #27272A;
  transition: .3s;
  border-radius: 20px;
}
.slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
}
input:checked + .slider {
  background-color: var(--accent);
}
input:checked + .slider:before {
  transform: translateX(16px);
  background-color: #000;
}

/* Preset Cards */
.preset-cards-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
@media (max-width: 900px) {
  .preset-cards-grid { grid-template-columns: 1fr; }
}
.preset-card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  cursor: pointer;
  transition: var(--transition);
}
.preset-card:hover {
  border-color: rgba(255, 255, 255, 0.2);
  background: var(--bg-card-hover);
}
.preset-card.active {
  border-color: var(--accent);
  background: rgba(245, 158, 11, 0.05);
  box-shadow: 0 0 16px rgba(245, 158, 11, 0.15);
}
.preset-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background: var(--accent);
  color: #000;
  font-size: 9px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
}
.preset-title {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 8px;
}
.preset-preview-text {
  font-family: 'Montserrat', sans-serif;
  font-weight: 900;
  font-size: 14px;
  padding: 10px 0;
  text-align: center;
  letter-spacing: 0.5px;
}
.gold-style { color: #FFF; text-shadow: 0 2px 8px #000; }
.gold-word { color: var(--accent); }
.netflix-style { color: #FFF; text-shadow: 0 1px 4px #000; }
.capsule-box {
  background: rgba(0, 0, 0, 0.85);
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.preset-desc {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 6px;
  line-height: 1.3;
}

/* Render CTA */
.render-cta-box {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.batch-selector-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.batch-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}
.batch-pills {
  display: flex;
  gap: 8px;
}
.batch-pill {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}
.batch-pill:hover {
  background: var(--bg-card-hover);
  color: var(--text-main);
}
.batch-pill.active {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
  font-weight: 700;
}
.btn-render-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  background: linear-gradient(135deg, #F59E0B 0%, #D97706 100%);
  color: #000;
  font-family: 'Montserrat', sans-serif;
  font-size: 16px;
  font-weight: 900;
  padding: 16px;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 6px 24px rgba(245, 158, 11, 0.35);
}
.btn-render-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 32px rgba(245, 158, 11, 0.5);
}

/* Phone Mockup */
.preview-sticky-pane {
  position: sticky;
  top: 80px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.phone-container {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.phone-mockup {
  position: relative;
  width: 270px;
  height: 540px;
  background: #000;
  border-radius: 44px;
  border: 6px solid #27272A;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6), 0 0 24px rgba(245, 158, 11, 0.1);
  overflow: hidden;
}
.dynamic-island {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: 80px;
  height: 20px;
  background: #000;
  border-radius: 12px;
  z-index: 20;
}
.phone-screen {
  position: relative;
  width: 100%;
  height: 100%;
  background: #111;
  overflow: hidden;
}
#demoBgVideo {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.phone-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0.3) 0%, transparent 40%, rgba(0,0,0,0.7) 100%);
  pointer-events: none;
}
.live-subtitle-box {
  position: absolute;
  bottom: 80px;
  left: 16px;
  right: 16px;
  text-align: center;
  z-index: 10;
  font-family: 'Montserrat', sans-serif;
  font-weight: 900;
  font-size: 15px;
  line-height: 1.3;
  transition: var(--transition);
}
.live-subtitle-box.reels-gold .sub-text {
  color: #FFF;
  text-shadow: 0 2px 6px #000, 0 0 12px #000;
}
.live-subtitle-box.reels-gold .accent-word {
  color: var(--accent);
}
.live-subtitle-box.netflix-white .sub-text {
  color: #FFF;
  text-shadow: 0 1px 4px #000;
}
.live-subtitle-box.contrast-capsule .sub-text {
  background: rgba(0, 0, 0, 0.85);
  padding: 6px 12px;
  border-radius: 8px;
  color: #FFF;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

.mockup-reels-actions {
  position: absolute;
  bottom: 60px;
  right: 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 10;
}
.mock-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 9px;
  font-weight: 700;
  color: #FFF;
  text-shadow: 0 1px 3px #000;
}
.mockup-sound-badge {
  position: absolute;
  bottom: 12px;
  left: 12px;
  right: 12px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 9px;
  color: #D4D4D8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  z-index: 10;
}
.preview-caption {
  font-size: 11px;
  color: var(--text-dim);
  text-align: center;
  margin-top: 8px;
}

/* Active Task Progress Card */
.active-task-card {
  background: var(--bg-surface);
  border: 1px solid rgba(245, 158, 11, 0.4);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.5);
}
.task-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.task-title {
  font-size: 13px;
  font-weight: 700;
  flex-grow: 1;
}
.task-pct {
  font-family: 'Montserrat', sans-serif;
  font-weight: 900;
  color: var(--accent);
  font-size: 14px;
}
.progress-bar-wrapper {
  width: 100%;
  height: 8px;
  background: var(--bg-card);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 8px;
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #F59E0B, #10B981);
  transition: width 0.3s ease;
}
.task-message {
  font-size: 12px;
  color: var(--text-muted);
}

.completed-video-box {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.result-player {
  width: 100%;
  border-radius: var(--radius-sm);
  background: #000;
  max-height: 220px;
}
.result-actions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.btn-action {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  border: none;
  transition: var(--transition);
}
.btn-download {
  background: #27272A;
  color: #FFF;
}
.btn-download:hover { background: #3F3F46; }
.btn-export {
  background: var(--accent);
  color: #000;
}
.btn-export:hover { background: var(--accent-hover); }
.export-status-label {
  font-size: 11px;
  text-align: center;
  color: var(--emerald);
  margin-top: 4px;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-dialog {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  padding: 24px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.7);
}
.modal-lg { max-width: 900px; }
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.modal-header h3 { font-size: 18px; font-weight: 700; }
.modal-close {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
}
.modal-close:hover { color: #FFF; }
.settings-notice {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
  margin-bottom: 16px;
  background: var(--bg-card);
  padding: 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}
.status-pill {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  margin-bottom: 12px;
  background: rgba(16, 185, 129, 0.1);
  color: var(--emerald);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

/* Gallery Grid */
.gallery-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  max-height: 60vh;
  overflow-y: auto;
  padding-right: 4px;
}
.gallery-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.gallery-thumb {
  width: 100%;
  aspect-ratio: 9/16;
  max-height: 200px;
  object-fit: cover;
  background: #000;
}
.gallery-info {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.gallery-title {
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gallery-meta {
  font-size: 11px;
  color: var(--text-dim);
}
.gallery-btn-row {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}
.btn-sm {
  padding: 4px 8px;
  font-size: 11px;
}

/* Login Page Styles */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}
.login-card {
  position: relative;
  z-index: 1;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 40px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), 0 0 40px rgba(245, 158, 11, 0.08);
}
.brand-header {
  text-align: center;
  margin-bottom: 32px;
}
.brand-header .logo-pill {
  justify-content: center;
  margin-bottom: 12px;
}
.brand-tagline {
  font-size: 13px;
  color: var(--text-muted);
}
.btn-primary {
  background: linear-gradient(135deg, #F59E0B 0%, #D97706 100%);
  color: #000;
  font-family: 'Montserrat', sans-serif;
  font-weight: 800;
  font-size: 14px;
  padding: 12px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: var(--transition);
}
.btn-primary:hover {
  box-shadow: 0 6px 20px rgba(245, 158, 11, 0.4);
}
.btn-block { width: 100%; }
.error-banner {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #FCA5A5;
  font-size: 12px;
  padding: 10px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  text-align: center;
}
.login-footer {
  text-align: center;
  margin-top: 24px;
  font-size: 11px;
  color: var(--text-dim);
}

/* Spinner */
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(0, 0, 0, 0.3);
  border-radius: 50%;
  border-top-color: #000;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
