:root {
  --bg-dark: #090b10;
  --bg-card: rgba(18, 22, 31, 0.85);
  --bg-card-hover: rgba(26, 32, 45, 0.95);
  --border: rgba(255, 255, 255, 0.08);
  --border-active: rgba(99, 102, 241, 0.5);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --accent: #6366f1;
  --accent-glow: rgba(99, 102, 241, 0.25);
  --emerald: #10b981;
  --emerald-glow: rgba(16, 185, 129, 0.25);
  --gold: #f59e0b;
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background: radial-gradient(circle at 50% 0%, #171b26 0%, var(--bg-dark) 100%);
  color: var(--text-main);
  font-family: 'Plus Jakarta Sans', 'Prompt', -apple-system, BlinkMacSystemFont, sans-serif;
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10, 13, 20, 0.85);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -0.5px;
}

.brand-icon {
  font-size: 22px;
}

.badge-ai {
  font-size: 11px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  color: #fff;
  padding: 2px 8px;
  border-radius: 999px;
  vertical-align: middle;
}

.nav-links {
  display: flex;
  gap: 6px;
}

.nav-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}

.nav-link:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
}

.nav-link.active {
  color: #fff;
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.3);
}

.credits-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: var(--emerald);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
}

.pill-dot {
  width: 8px;
  height: 8px;
  background: var(--emerald);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--emerald);
}

/* Container */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 20px 80px;
}

/* Hero Section */
.hero-section {
  text-align: center;
  margin-bottom: 28px;
}

.hero-section h1 {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 8px;
}

.gradient-text {
  background: linear-gradient(135deg, #a5b4fc, #6366f1, #c084fc);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  color: var(--text-muted);
  font-size: 15px;
  max-width: 700px;
  margin: 0 auto;
}

/* Product Banner */
.product-banner {
  display: flex;
  align-items: center;
  gap: 20px;
  background: rgba(99, 102, 241, 0.08);
  border: 1px solid rgba(99, 102, 241, 0.25);
  padding: 16px 20px;
  border-radius: var(--radius-md);
  margin-bottom: 24px;
  position: relative;
}

.banner-thumb {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.banner-info {
  flex: 1;
}

.banner-tag {
  font-size: 11px;
  font-weight: 600;
  color: #a5b4fc;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.banner-title {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.banner-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.banner-price {
  font-size: 16px;
  font-weight: 800;
  color: #34d399;
}

.banner-badge {
  font-size: 11px;
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 8px;
  border-radius: 4px;
  color: var(--text-muted);
}

.banner-sku {
  font-size: 11px;
  font-weight: 700;
  color: #67e8f9;
  background: rgba(6, 182, 212, 0.12);
  border: 1px solid rgba(103, 232, 249, 0.28);
  border-radius: 999px;
  padding: 2px 8px;
  overflow-wrap: anywhere;
}

.btn-clear-prod {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
}

.btn-clear-prod:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

/* Mode Tabs */
.mode-tabs-container {
  margin-bottom: 24px;
}

.mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  background: rgba(15, 18, 26, 0.6);
  padding: 6px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

.mode-tab {
  background: none;
  border: 1px solid transparent;
  color: var(--text-muted);
  padding: 14px 18px;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
  transition: all 0.2s;
  font-family: inherit;
}

.mode-tab:hover {
  background: rgba(255, 255, 255, 0.03);
  color: #fff;
}

.mode-tab.active {
  background: var(--bg-card);
  color: #fff;
  border-color: var(--border-active);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3), 0 0 15px var(--accent-glow);
}

.tab-icon {
  font-size: 28px;
}

.tab-title {
  display: block;
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 2px;
}

.tab-desc {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
}

.mode-tab.active .tab-desc {
  color: #cbd5e1;
}

/* Drop Zone Grid (3 Columns) */
.dropzone-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

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

.drop-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
}

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

.drop-header h3 {
  font-size: 14px;
  font-weight: 700;
}

.drop-tag {
  font-size: 11px;
  font-weight: 600;
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  padding: 2px 8px;
  border-radius: 4px;
}

.drop-tag.optional {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
}

.drop-box {
  flex: 1;
  min-height: 190px;
  border: 2px dashed rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: all 0.2s;
  background: rgba(10, 13, 20, 0.4);
}

.drop-box:hover, .drop-box.dragover {
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.05);
}

.upload-icon {
  font-size: 32px;
  display: block;
  margin-bottom: 8px;
}

.drop-placeholder p {
  font-size: 13px;
  margin-bottom: 4px;
}

.drop-placeholder small {
  color: var(--text-muted);
  font-size: 11px;
  display: block;
  max-width: 240px;
  margin: 0 auto;
}

.auto-hint {
  display: inline-block;
  margin-top: 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--emerald);
  background: rgba(16, 185, 129, 0.12);
  padding: 2px 8px;
  border-radius: 4px;
}

.drop-preview {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
}

.drop-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.btn-remove-img {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-remove-img:hover {
  background: #ef4444;
}

/* Model Presets */
.model-presets {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  align-items: center;
}

.preset-label {
  font-size: 11px;
  color: var(--text-muted);
  width: 100%;
  margin-bottom: 2px;
}

.btn-preset {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--border);
  color: #e2e8f0;
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}

.btn-preset:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* Section Card */
.section-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-bottom: 24px;
}

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

.section-header h3 {
  font-size: 16px;
  font-weight: 700;
}

.section-sub {
  color: var(--text-muted);
  font-size: 12px;
}

.badge-tag {
  font-size: 12px;
  font-weight: 600;
  color: var(--emerald);
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 4px 12px;
  border-radius: 999px;
}

/* Styles Grid */
.styles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.style-card {
  background: rgba(15, 19, 28, 0.6);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  outline: none;
}

.style-prompt-editors { display: grid; gap: 18px; margin: 18px 0; }
.style-prompt-panel { border: 1px solid var(--border, #303441); border-radius: 12px; padding: 18px; min-width: 0; background: rgba(255,255,255,.025); }
.style-prompt-panel[hidden] { display: none; }
.style-prompt-panel h4 { margin: 0 0 16px; display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; }
.style-prompt-panel h4 small { color: #65dbb1; font-weight: 400; }
.style-prompt-panel textarea { box-sizing: border-box; width: 100%; resize: vertical; }
#aiTargetStyle { max-width: 100%; background: #171b24; color: #fff; padding: 8px; border: 1px solid #343948; border-radius: 8px; }

.style-card:hover {
  border-color: var(--border-active);
  background: var(--bg-card-hover);
}

.style-card.active {
  border-color: var(--emerald);
  background: rgba(16, 185, 129, 0.08);
}

.style-card:focus-visible {
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.25);
  border-color: var(--emerald);
}

.style-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.style-emoji {
  font-size: 20px;
}

.check-mark {
  display: none;
  font-size: 12px;
  font-weight: 800;
  color: var(--emerald);
}

.style-card.active .check-mark {
  display: inline-block;
}

.style-card h4 {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 4px;
}

.style-card p {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
}

.style-selection-summary {
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: var(--radius-sm);
  background: rgba(16, 185, 129, 0.06);
}

.style-selection-summary.warning {
  border-color: rgba(245, 158, 11, 0.55);
  background: rgba(245, 158, 11, 0.08);
}

.style-selection-summary.error {
  border-color: rgba(239, 68, 68, 0.55);
  background: rgba(239, 68, 68, 0.08);
}

.style-summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--text-secondary);
  font-size: 12px;
}

.style-summary-row strong {
  color: var(--text-primary);
  font-size: 13px;
}

.selected-style-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}

.selected-style-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 9px;
  border-radius: 999px;
  color: var(--emerald);
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.28);
  font-size: 11px;
  font-weight: 700;
}

#styleSelectionHint {
  margin-top: 9px;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.5;
}

.style-job-status-list {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.style-job-status-row {
  display: grid;
  grid-template-columns: minmax(160px, 1.4fr) minmax(130px, 1fr) minmax(120px, 0.8fr);
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(15, 19, 28, 0.55);
  font-size: 11px;
}

.style-job-status-row strong {
  color: var(--text-primary);
}

.style-job-status-row .job-state {
  color: var(--cyan, #22d3ee);
  font-weight: 700;
}

.style-job-status-row[data-terminal="completed"] .job-state {
  color: var(--emerald);
}

.style-job-status-row[data-terminal="failed"] .job-state {
  color: var(--danger, #ef4444);
}

.video-style-label {
  display: inline-flex;
  margin-bottom: 7px;
  padding: 4px 8px;
  border-radius: 999px;
  color: var(--emerald);
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.25);
  font-size: 10px;
  font-weight: 700;
}

@media (max-width: 720px) {
  .style-summary-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .style-job-status-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}

/* AI Assist Buttons */
.ai-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  min-width: 0;
}

@media (max-width: 900px) {
  .topbar-inner { flex-wrap: wrap; min-width: 0; padding: 10px 16px; }
  .brand { flex-shrink: 0; }
  .topbar .nav-links { order: 3; width: 100%; min-width: 0; overflow-x: auto; }
  .topbar .nav-link { flex-shrink: 0; white-space: nowrap; }
  .topbar .topbar-right { width: 100%; min-width: 0; flex-wrap: wrap; }
}

.btn-ai-assist {
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.4);
  color: #c7d2fe;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
  font-family: inherit;
}

.btn-ai-assist:hover {
  background: var(--accent);
  color: #fff;
  transform: translateY(-1px);
}

.btn-ai-assist.gold {
  background: rgba(245, 158, 11, 0.15);
  border-color: rgba(245, 158, 11, 0.4);
  color: #fde68a;
}

.btn-ai-assist.gold:hover {
  background: var(--gold);
  color: #000;
}

/* Forms */
.prompt-form-group {
  margin-bottom: 14px;
}

.prompt-form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: #e2e8f0;
}

.prompt-form-group textarea, .prompt-form-group input {
  width: 100%;
  background: rgba(10, 13, 20, 0.6);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: #fff;
  padding: 12px 14px;
  font-family: inherit;
  font-size: 13px;
  transition: all 0.2s;
}

.prompt-form-group textarea:focus, .prompt-form-group input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 10px var(--accent-glow);
}

/* Advanced Accordion */
.advanced-details {
  margin-top: 14px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.advanced-details summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.advanced-details summary:hover {
  color: #fff;
}

.advanced-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 12px;
}

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

.adv-field label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.adv-field select {
  width: 100%;
  background: rgba(10, 13, 20, 0.6);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: #fff;
  padding: 8px 10px;
  font-size: 12px;
  font-family: inherit;
}

/* The BIG OK Button */
.action-section {
  text-align: center;
  margin: 32px 0;
}

.btn-big-generate {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  border: none;
  color: #fff;
  padding: 20px 48px;
  border-radius: 999px;
  font-size: 20px;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 10px 30px rgba(16, 185, 129, 0.4), 0 0 40px var(--emerald-glow);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: inherit;
}

.btn-big-generate:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 15px 40px rgba(16, 185, 129, 0.5), 0 0 60px var(--emerald-glow);
}

.btn-big-generate:active {
  transform: translateY(0) scale(0.98);
}

.btn-icon {
  font-size: 28px;
}

.btn-labels {
  display: flex;
  flex-direction: column;
  text-align: left;
}

.btn-main-label {
  font-size: 20px;
  letter-spacing: -0.5px;
}

.btn-sub-label {
  font-size: 12px;
  font-weight: 500;
  color: #d1fae5;
  letter-spacing: 0.2px;
}

/* Stepper */
.progress-section {
  background: var(--bg-card);
  border: 1px solid var(--border-active);
  border-radius: var(--radius-md);
  padding: 24px;
  margin-bottom: 32px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.progress-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.progress-copy {
  flex: 1;
  min-width: 0;
}

.retry-status-card {
  min-width: 150px;
  padding: 9px 12px;
  border: 1px solid rgba(99, 102, 241, 0.45);
  border-radius: var(--radius-sm);
  background: rgba(99, 102, 241, 0.12);
  text-align: right;
}

.retry-status-card[data-state="waiting"] {
  border-color: rgba(245, 158, 11, 0.6);
  background: rgba(245, 158, 11, 0.12);
}

.retry-status-card[data-state="succeeded"] {
  border-color: rgba(16, 185, 129, 0.6);
  background: rgba(16, 185, 129, 0.12);
}

.retry-status-card[data-state="exhausted"],
.retry-status-card[data-state="stopped"] {
  border-color: rgba(248, 113, 113, 0.65);
  background: rgba(248, 113, 113, 0.12);
}

.retry-status-label {
  display: block;
  color: var(--text-muted);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.12em;
}

#retryStatusText {
  display: block;
  margin-top: 2px;
  font-size: 13px;
}

.field-help {
  display: block;
  margin-top: 6px;
  color: var(--text-muted);
  font-size: 10px;
  line-height: 1.45;
}

@media (max-width: 640px) {
  .progress-header {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .retry-status-card {
    width: 100%;
    text-align: left;
  }
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(99, 102, 241, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s infinite linear;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.stepper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  position: relative;
}

.step-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
  z-index: 2;
}

.step-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.step-item.active .step-circle {
  background: var(--accent);
  box-shadow: 0 0 15px var(--accent);
}

.step-item.done .step-circle {
  background: var(--emerald);
  color: #fff;
}

.step-line {
  flex: 1;
  height: 2px;
  background: rgba(255, 255, 255, 0.1);
  margin: 0 8px;
  margin-bottom: 24px;
}

.step-line.done {
  background: var(--emerald);
}

/* Log Box */
.log-box {
  background: #05070c;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  max-height: 160px;
  overflow-y: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
}

.log-entry {
  margin-bottom: 4px;
  line-height: 1.5;
}

.log-entry.info { color: #94a3b8; }
.log-entry.progress { color: #818cf8; }
.log-entry.success { color: #34d399; }
.log-entry.warn { color: #fbbf24; }
.log-entry.error { color: #f87171; }

/* 4-Video Result Gallery */
.results-section {
  margin-bottom: 32px;
}

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

.video-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

@media (max-width: 1000px) {
  .video-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

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

.video-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: all 0.2s;
}

.video-card:hover {
  border-color: var(--border-active);
  transform: translateY(-2px);
}

.video-wrap {
  position: relative;
  aspect-ratio: 9 / 16;
  background: #000;
}

.video-wrap video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.video-card-body {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.video-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  font-size: 13px;
}

.video-filename {
  display: block;
  color: #a5f3fc;
  background: rgba(6, 182, 212, 0.08);
  border: 1px solid rgba(103, 232, 249, 0.18);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 10px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.btn-download-vid {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border);
  color: #fff;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  display: block;
}

.btn-download-vid:hover {
  background: var(--emerald);
  border-color: var(--emerald);
}

/* History */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(15, 19, 28, 0.5);
  border: 1px solid var(--border);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
}

.history-thumb {
  width: 48px;
  height: 48px;
  border-radius: 6px;
  object-fit: cover;
  background: #000;
}

.history-details {
  flex: 1;
}

.history-title {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 2px;
}

.history-sub {
  font-size: 11px;
  color: var(--text-muted);
}

.history-scope {
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 12px;
}

.identity-pill {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border: 1px solid rgba(34, 211, 238, 0.45);
  border-radius: 999px;
  padding: 7px 13px;
  background: rgba(8, 145, 178, 0.12);
  color: #a5f3fc;
  font: 600 12px inherit;
  cursor: pointer;
}

.identity-pill[data-mode="user"] {
  border-color: rgba(74, 222, 128, 0.5);
  background: rgba(34, 197, 94, 0.12);
  color: #bbf7d0;
}

.fs-auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(2, 6, 23, 0.8);
  backdrop-filter: blur(10px);
}

.fs-auth-overlay[hidden] {
  display: none;
}

.fs-auth-card {
  position: relative;
  width: min(100%, 480px);
  padding: 28px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 18px;
  background: #111827;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
}

.fs-auth-card h2 {
  margin: 0 0 8px;
}

.fs-auth-card p,
.fs-auth-card small {
  color: var(--text-muted);
}

.fs-auth-card label {
  display: block;
  margin: 16px 0 6px;
  color: #dbeafe;
  font-size: 12px;
  font-weight: 700;
}

.fs-auth-card input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 11px 12px;
  background: #0b1220;
  color: var(--text);
  font: inherit;
}

.fs-auth-card input:focus {
  border-color: #22d3ee;
  outline: 2px solid rgba(34, 211, 238, 0.15);
}

.fs-auth-close {
  position: absolute;
  top: 12px;
  right: 14px;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-size: 25px;
  cursor: pointer;
}

.fs-auth-error {
  min-height: 22px;
  margin-top: 10px;
  color: #fda4af;
  font-size: 12px;
}

.fs-auth-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin: 6px 0 12px;
}

.history-status {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  border-radius: 8px;
  background: rgba(148, 163, 184, 0.12);
  font-size: 22px;
}

/* Faceless guard UI: keep the existing layout, with explicit version/error state. */
.capability-status { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.capability-status > p { flex: 1 1 320px; }
.generation-notice { margin: 10px 0; padding: 12px 14px; border: 1px solid rgba(56, 189, 248, .28); border-radius: 10px; color: #bae6fd; background: rgba(14, 116, 144, .10); font-size: 13px; line-height: 1.7; overflow-wrap: anywhere; }
.generation-notice[hidden], .compiled-preview[hidden] { display: none; }
.generation-notice[data-severity="warning"], .generation-notice[data-status="unavailable"] { color: #fde68a; border-color: rgba(251, 191, 36, .4); background: rgba(180, 83, 9, .12); }
.generation-notice[data-severity="error"], .draft-feedback[data-severity="error"] { color: #fda4af; border-color: rgba(251, 113, 133, .45); }
.draft-mode-label { color: #6ee7b7; font-weight: 600; font-size: 13px; }
.draft-feedback, .compiled-count { color: var(--text-muted); font-size: 12px; line-height: 1.7; overflow-wrap: anywhere; }
.draft-warnings { color: #fde68a; font-size: 12px; line-height: 1.7; padding-left: 20px; overflow-wrap: anywhere; }
.draft-warnings[hidden] { display: none; }
.style-prompt-input[aria-invalid="true"] { border-color: #fb7185; }
.compiled-preview { margin-top: 12px; border: 1px solid var(--border); border-radius: 9px; padding: 12px; }
.compiled-preview summary, .history-generation-details summary { cursor: pointer; color: #7dd3fc; font-size: 13px; line-height: 1.7; }
.compiled-prompt, .history-generation-details pre { white-space: pre-wrap; overflow-wrap: anywhere; font-family: inherit; font-size: 12px; line-height: 1.7; max-height: 360px; overflow-y: auto; }
.history-generation-details { margin-top: 8px; }
.history-generation-details p { font-size: 12px; line-height: 1.7; overflow-wrap: anywhere; }
.history-generation-details strong { font-size: 12px; }
.history-details, .style-prompt-panel { min-width: 0; }
.mode-tab:focus-visible, .compiled-preview summary:focus-visible, .history-generation-details summary:focus-visible { outline: 2px solid #38bdf8; outline-offset: 3px; }
.mode-tab:disabled, .drop-box[aria-disabled="true"], .style-card[aria-disabled="true"] { cursor: wait; opacity: .65; }
@media (max-width: 600px) {
  /* Two auto-minimum grid tracks pushed the Faceless tab past a 320px viewport. */
  .mode-tabs { grid-template-columns: minmax(0, 1fr); }
  .mode-tab, .mode-tab .tab-texts { min-width: 0; }
  .mode-tab .tab-texts { overflow-wrap: anywhere; }
  .mode-tab .tab-icon { flex-shrink: 0; }
  .capability-status { align-items: stretch; }
  .capability-status > button { width: 100%; }
  .compiled-preview { padding: 9px; }
  .history-item { flex-wrap: wrap; }
  .history-details { flex: 1 1 180px; }
}

@media (max-width: 900px) {
  .identity-pill {
    max-width: 150px;
  }
}
