/* ============================================================
   Stickman Studio — Refined Studio Dark Theme (Anti-Slop Pro)
   ============================================================ */

:root {
  /* Studio Dark Palette (Default) */
  --bg-app: #080a0f;
  --bg-surface: #10131d;
  --bg-raised: #161b29;
  --bg-hover: #1e2436;
  --bg-input: #0b0e16;
  --bg-overlay: rgba(3, 5, 8, 0.85);

  /* Micro Borders */
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.18);
  --border-focus: #6366f1;

  /* High-Contrast Studio Typography */
  --text: #f8fafc;
  --text-secondary: #94a3b8;
  --text-dim: #8ca0b8;
  --text-muted: var(--text-secondary);

  /* Semantic Surface Aliases */
  --surface-2: var(--bg-raised);

  /* Studio Accents: Electric Indigo / Cobalt */
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-strong: #4338ca;
  --primary-soft: rgba(99, 102, 241, 0.14);
  --primary-glow: rgba(99, 102, 241, 0.28);

  --success: #10b981;
  --success-soft: rgba(16, 185, 129, 0.14);
  --warning: #f59e0b;
  --warning-soft: rgba(245, 158, 11, 0.14);
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.14);
  --accent: #8b5cf6;
  --accent-soft: rgba(139, 92, 246, 0.14);

  /* Micro-refraction & shadows */
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  --shadow-lg: 0 16px 36px -4px rgba(0, 0, 0, 0.75), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  --header-h: 64px;
  --tabs-h: 52px;

  /* Font */
  --font: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', 'Consolas', monospace;

  /* Transition */
  --transition: 160ms cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="light"] {
  --bg-app: #f4f5f8;
  --bg-surface: #ffffff;
  --bg-raised: #eaedf3;
  --bg-hover: #e0e5ed;
  --bg-input: #ffffff;
  --bg-overlay: rgba(15, 23, 42, 0.4);

  --border: #e2e5eb;
  --border-strong: #c8ced8;
  --border-focus: #4f46e5;

  --text: #0f172a;
  --text-secondary: #475569;
  --text-dim: #475569;
  --text-muted: var(--text-secondary);

  --surface-2: var(--bg-raised);

  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-strong: #3730a3;
  --primary-soft: rgba(79, 70, 229, 0.1);
  --primary-glow: rgba(79, 70, 229, 0.2);

  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 8px 24px rgba(15, 23, 42, 0.1);
}

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

html {
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font);
  background: var(--bg-app);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  line-height: 1.55;
}

/* Skip link (A11y keyboard navigation) */
.skip-link {
  position: absolute;
  top: -100px;
  left: 16px;
  z-index: 9999;
  padding: 10px 16px;
  background: var(--primary-strong);
  color: #ffffff;
  font-weight: 700;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  text-decoration: none;
  transition: top 160ms ease;
}
.skip-link:focus {
  top: 16px;
  outline: 3px solid #ffffff;
  outline-offset: 2px;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

::selection { background: var(--primary-glow); color: var(--text); }

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.16); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.28); }
[data-theme="light"] ::-webkit-scrollbar-thumb { background: #c9cdd6; }
[data-theme="light"] ::-webkit-scrollbar-thumb:hover { background: #aeb3c0; }

/* Micro Icons */
.ui-icon {
  width: 15px;
  height: 15px;
  stroke-width: 1.85px;
  vertical-align: -2.5px;
  display: inline-block;
  flex-shrink: 0;
}
.ui-icon-title {
  width: 18px;
  height: 18px;
  stroke-width: 2px;
  vertical-align: -3px;
  margin-right: 8px;
  color: var(--primary);
  display: inline-block;
  flex-shrink: 0;
}
.btn .ui-icon {
  margin-right: 5px;
}

/* ── Layout ── */
.app-layout {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 20px 80px;
}

/* Wide layout — desktop & ultrawide */
@media (min-width: 1100px) {
  .app-layout { max-width: 1200px; }
}
@media (min-width: 1440px) {
  .app-layout { max-width: 1360px; }
  .form-row { gap: 20px; }
}

/* ── Header ── */
.app-header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--bg-app);
  margin-bottom: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-logo {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--primary-soft);
  border: 1px solid rgba(59, 130, 246, 0.25);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.brand-sub {
  font-size: 0.8rem;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-badges {
  display: flex;
  gap: 6px;
}

.badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 20px;
  background: var(--bg-raised);
  color: var(--text-dim);
  border: 1px solid var(--border);
  transition: all var(--transition);
  white-space: nowrap;
}

.badge.ready {
  background: var(--success-soft);
  color: var(--success);
  border-color: rgba(34, 197, 94, 0.25);
}

.badge.processing {
  background: var(--warning-soft);
  color: var(--warning);
  border-color: rgba(245, 158, 11, 0.25);
}

/* ── Project Bar ── */
.project-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 14px;
  margin-top: 14px;
}

.project-bar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 220px;
}

.project-bar { flex-wrap: wrap; }
.project-bar-left { flex-wrap: wrap; min-width: 0; }
.project-save-status { font-size: 0.8rem; color: var(--text-secondary); overflow-wrap: anywhere; }
.project-save-status[data-state="error"] { color: var(--danger); }
.project-save-status[data-state="dirty"] { font-weight: 600; }
#references-output .card-header { flex-wrap: wrap; }

.project-bar-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.project-select {
  flex: 1;
  max-width: 320px;
  padding: 7px 32px 7px 11px;
  font-size: 0.85rem;
  font-weight: 600;
}

.project-search-input {
  max-width: 160px;
  padding: 6px 10px;
  font-size: 0.8rem;
  height: 34px;
}

.project-filter-chips {
  display: flex;
  gap: 4px;
  align-items: center;
}

.filter-chip {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 12px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}

.filter-chip:hover {
  color: var(--text);
  border-color: var(--primary);
}

.filter-chip.active {
  background: var(--primary-strong);
  color: #fff;
  border-color: var(--primary-strong);
}

.project-bar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.btn-delete-project:hover {
  color: var(--danger);
  border-color: rgba(220, 38, 38, 0.35);
}

.storyboard-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ── Tabs ── */
.app-tabs {
  display: flex;
  gap: 2px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px;
  margin: 20px 0;
  position: sticky;
  top: var(--header-h);
  z-index: 30;
}

.tab-btn {
  flex: 1;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  white-space: nowrap;
}

.tab-btn:hover { color: var(--text); background: var(--bg-hover); }

.tab-btn.active {
  background: var(--bg-raised);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.08);
}

.tab-num {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--border-strong);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.tab-btn.active .tab-num {
  background: var(--primary-strong);
  color: #fff;
}

/* ── Tab Content ── */
.app-tabs { overflow-x: auto; }

/* ── Focus Visible Global Standards (WCAG 2.2 / UIUXPROMAX) ── */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
button:focus:not(:focus-visible),
a:focus:not(:focus-visible),
input:focus:not(:focus-visible),
select:focus:not(:focus-visible),
textarea:focus:not(:focus-visible) {
  outline: none;
}
.btn:focus-visible,
.tab-btn:focus-visible,
.filter-chip:focus-visible,
.view-switch-btn:focus-visible,
.settings-card button:focus-visible,
.settings-card a:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.toggle-switch-input:focus-visible + .toggle-switch-slider {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.tts-engine-card:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-glow);
}

/* ── Settings Tab Polish ── */
.settings-card {
  max-width: 920px;
  margin: 0 auto 24px auto;
  border: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.settings-card .card-header {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.settings-status-box {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 22px;
  transition: all var(--transition);
}

.settings-status-box .status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-dim);
  flex-shrink: 0;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.04);
}

.settings-status-box.ready {
  background: var(--success-soft);
  border-color: rgba(34, 197, 94, 0.3);
}
.settings-status-box.ready .status-dot {
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.2);
}

.settings-status-box.error {
  background: var(--danger-soft);
  border-color: rgba(239, 68, 68, 0.3);
}
.settings-status-box.error .status-dot {
  background: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
}

.settings-status {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text);
  font-weight: 500;
  line-height: 1.4;
  word-break: break-word;
}

.settings-help {
  margin-top: 6px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.4;
}
.settings-help a {
  color: var(--primary);
  text-underline-offset: 3px;
  font-weight: 600;
}
.settings-help code {
  font-family: var(--mono);
  background: var(--bg-raised);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
  font-size: 0.78rem;
}

/* ── Multi-API Key Pool Display ── */
.gemini-keys-pool-container {
  margin-top: 10px;
  margin-bottom: 14px;
}
.gemini-keys-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}
.gemini-key-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  font-family: monospace;
  font-size: 0.78rem;
  color: var(--text);
  transition: all var(--transition);
}
.gemini-key-chip.ready {
  border-color: rgba(34, 197, 94, 0.4);
}
.gemini-key-chip.cooldown {
  border-color: var(--warning);
  background: rgba(245, 158, 11, 0.1);
  color: var(--warning);
}
.gemini-key-chip-status {
  font-size: 0.7rem;
  padding: 1px 5px;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.05);
  font-weight: 600;
}

.settings-error {
  color: var(--danger);
  font-weight: 600;
}

.model-select-wrap {
  display: flex;
  gap: 10px;
  align-items: center;
}
.model-select-wrap .input-select {
  flex: 1;
}

.card-footer-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.settings-help-meta {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin: 0;
}

.whisper-specs-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.spec-chip {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.spec-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  font-weight: 700;
}

.spec-value {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
}

/* ── Subtitle Customization Card & Live Preview ── */
.subtitle-settings-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 18px 20px;
  margin-top: 20px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.subtitle-settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.subtitle-settings-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
}

.subtitle-preview-container {
  margin-top: 14px;
  padding: 20px;
  background: #090d16;
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 100px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.subtitle-preview-badge {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #94a3b8;
  font-weight: 600;
}

.subtitle-preview-bubble {
  background: rgba(0, 0, 0, 0.88);
  border-radius: 999px;
  padding: 8px 22px;
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  transition: all var(--transition);
  max-width: 90%;
}

.subtitle-preview-word {
  font-family: 'Arial Black', Impact, sans-serif;
  font-weight: 900;
  text-transform: uppercase;
  color: #ffffff;
  font-size: 1.1rem;
  line-height: 1.2;
  transition: all var(--transition);
  text-shadow: 2px 2px 0 #000;
}

.subtitle-preview-word.active {
  color: #ffe600;
  transform: scale(1.08);
  text-shadow: 0 0 16px rgba(255, 230, 0, 0.7), 2px 2px 0 #000;
}

/* ── Flow Controls in Storyboard ── */
.flow-action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.flow-controls-cluster {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.flow-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #94a3b8;
  display: inline-block;
  margin-right: 6px;
  transition: all var(--transition);
}

.flow-dot.connected {
  background: #22c55e;
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.7);
}

.flow-dot.disconnected {
  background: #f59e0b;
}

/* ── Studio Feature Toggles Bar ── */
.studio-toggles-bar {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.toggle-group-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
}
.toggles-flex {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.toggle-switch-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
}
.toggle-switch-input {
  display: none;
}
.toggle-switch-slider {
  width: 36px;
  height: 20px;
  background: #cbd5e1;
  border-radius: 999px;
  position: relative;
  transition: background 0.2s ease;
}
.toggle-switch-slider::after {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  background: #fff;
  border-radius: 50%;
  top: 3px;
  left: 3px;
  transition: transform 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}
.toggle-switch-input:checked + .toggle-switch-slider {
  background: var(--primary);
}
.toggle-switch-input:checked + .toggle-switch-slider::after {
  transform: translateX(16px);
}

/* ── Visual Stages (Stage 1 & Stage 2) ── */
.visual-stage-card {
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  margin-bottom: 24px;
}
.stage-tag {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: #fff;
  background: var(--primary);
  padding: 2px 8px;
  border-radius: 4px;
  margin-bottom: 6px;
}
.stage-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Characters Grid in Stage 1 ── */
.stage-characters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
  margin-top: 16px;
}
.stage-char-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.stage-char-preview-box {
  width: 100%;
  height: 240px;
  background: #111827;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
.stage-char-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #0f172a;
}
.stage-char-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: #64748b;
  font-size: 0.8rem;
}
.stage-char-info {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}
.stage-char-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.stage-char-desc {
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.4;
  flex: 1;
}
.stage-char-footer {
  margin-top: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Storyboard View Switcher Bar */
.storyboard-view-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0 20px 0;
  padding: 6px 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: fit-content;
}
.view-switcher-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary);
}
.view-switch-tabs {
  display: flex;
  gap: 6px;
}
.view-switch-btn {
  padding: 6px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.view-switch-btn:hover {
  background: var(--bg-raised);
  color: var(--text);
}
.view-switch-btn.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 1px 3px rgba(37, 99, 235, 0.25);
}
.view-switch-btn.active .badge {
  background: rgba(255, 255, 255, 0.25);
  color: #ffffff;
}

/* Prompt Box inside Character & Scene Cards */
.stage-char-prompt-box,
.stage-char-ref-box,
.stage-scene-prompt-box {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.stage-char-prompt-box:hover,
.stage-char-ref-box:hover,
.stage-scene-prompt-box:hover {
  border-color: var(--primary);
}
.stage-char-prompt-header,
.stage-scene-prompt-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.prompt-box-tag {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--primary);
  background: var(--primary-soft);
  padding: 2px 7px;
  border-radius: 4px;
}
.prompt-box-tag.ref-tag {
  color: #7c3aed;
  background: rgba(124, 58, 237, 0.12);
}
.stage-char-prompt-text,
.stage-scene-prompt-text {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.73rem;
  line-height: 1.45;
  color: var(--text);
  max-height: 90px;
  overflow-y: auto;
  word-break: break-word;
  white-space: pre-wrap;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(0, 0, 0, 0.05);
  transition: background 0.15s ease;
}
.stage-char-prompt-text:hover,
.stage-scene-prompt-text:hover {
  background: #ffffff;
}
.btn-xs {
  padding: 2px 8px;
  font-size: 0.7rem;
  font-weight: 600;
  border-radius: 4px;
  cursor: pointer;
  line-height: 1.4;
}
.btn-copied {
  background: var(--success) !important;
  color: #ffffff !important;
  border-color: var(--success) !important;
}

/* Scene Card Meta & Character Tags */
.stage-scene-num-badge {
  font-weight: 700;
  color: var(--text);
  font-size: 0.82rem;
}
.stage-scene-time-badge {
  color: var(--text-dim);
  font-size: 0.72rem;
}
.stage-scene-meta {
  font-size: 0.72rem;
  color: var(--primary);
  font-weight: 600;
  display: flex;
  gap: 8px;
}
.stage-scene-character {
  font-size: 0.75rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}
.stage-char-name-tag {
  color: var(--text);
  font-weight: 600;
  background: var(--bg-hover);
  padding: 1px 6px;
  border-radius: 4px;
}
.scene-label-tag {
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-soft);
  padding: 2px 6px;
  border-radius: 4px;
  width: fit-content;
}
.stage-scene-narration {
  font-size: 0.8rem;
  color: var(--text);
  line-height: 1.45;
  background: var(--bg-raised);
  padding: 8px 10px;
  border-radius: 6px;
  border-left: 3px solid var(--primary);
  display: flex;
  flex-direction: column;
  gap: 3px;
}

/* ── Scenes Grid in Stage 2 ── */
.stage-scenes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin-top: 16px;
}
.stage-scene-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
}
.stage-scene-card:hover {
  transform: translateY(-2px);
  border-color: rgba(99, 102, 241, 0.4);
  box-shadow: 0 12px 28px -6px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(99, 102, 241, 0.2);
}
.stage-scene-preview-box {
  width: 100%;
  height: 200px;
  background: #090c13;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid var(--border);
}
.stage-scene-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #0f172a;
}
.stage-scene-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: #64748b;
  font-size: 0.78rem;
}
.stage-scene-info {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}
.stage-scene-badge-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--text-dim);
  font-weight: 700;
}
.stage-scene-narration {
  font-size: 0.78rem;
  color: var(--text);
  line-height: 1.35;
  margin-top: 4px;
  flex: 1;
}
.stage-scene-footer {
  margin-top: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.voice-downloads { margin-top: 16px; }
.prompt-count { margin-top: 18px; color: var(--text-secondary); font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.combined-prompts { min-height: 360px; white-space: pre-wrap; overflow-wrap: anywhere; }
#prompts-output .card-header { flex-wrap: wrap; }
.prompt-list-empty { color: var(--text-secondary); padding: 16px 0; }
#whisper-progress-text, #whisper-percent-text { font-variant-numeric: tabular-nums; }

.tab-content#tab-settings.active { animation: none; }

.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeIn 0.2s ease; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Cards ── */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}

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

.card-title {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.card-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ── Forms ── */
.form-group { margin-bottom: 16px; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1.35fr 1fr;
  gap: 16px;
}

.form-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}

.input-text, .input-select, .textarea-script {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.input-text:focus, .input-select:focus, .textarea-script:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.input-text::placeholder, .textarea-script::placeholder { color: var(--text-dim); }

.input-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 12 12' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3 4.5L6 7.5L9 4.5' stroke='%236b7280' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}

.input-select option { background: var(--bg-surface); color: var(--text); }

.textarea-script {
  resize: vertical;
  min-height: 160px;
  font-size: 0.92rem;
  line-height: 1.7;
  font-family: inherit;
}

/* Speed control */
.speed-control {
  display: flex;
  align-items: center;
  gap: 12px;
}

.input-range {
  flex: 1;
  appearance: none;
  height: 5px;
  background: var(--border-strong);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}

.input-range::-webkit-slider-thumb {
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid #fff;
  cursor: pointer;
}

.speed-val {
  font-family: var(--mono);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--primary);
  min-width: 42px;
  text-align: right;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 80ms ease, background 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
  text-decoration: none;
  white-space: nowrap;
}

.btn:active:not(:disabled) {
  transform: translateY(1px) scale(0.985);
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}
.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.btn-secondary {
  background: var(--bg-raised);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}

.btn-outline {
  background: var(--bg-surface);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-outline:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--border-strong);
  color: var(--text);
  text-decoration: none;
}

.btn-lg { padding: 13px 28px; font-size: 0.92rem; }
.btn-sm { padding: 6px 12px; font-size: 0.75rem; }

.btn-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ── Tag chips ── */
.tags-cheatsheet {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.cheatsheet-label {
  font-size: 0.7rem;
  color: var(--text-dim);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.tag-chip {
  padding: 3px 10px;
  font-size: 0.7rem;
  font-family: var(--mono);
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid rgba(168, 85, 247, 0.2);
  border-radius: 6px;
  cursor: pointer;
  transition: all var(--transition);
}

.tag-chip:hover { background: rgba(168, 85, 247, 0.2); }

/* ── Word count badge ── */
.word-count-badge {
  font-size: 0.7rem;
  font-family: var(--mono);
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-raised);
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
  white-space: nowrap;
}

/* ── Words cloud ── */
.words-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-height: 240px;
  overflow-y: auto;
  padding: 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  line-height: 1.8;
}

.word-chip {
  display: inline-block;
  padding: 2px 7px;
  font-size: 0.72rem;
  font-family: var(--mono);
  background: var(--bg-raised);
  color: var(--text-secondary);
  border-radius: 4px;
  border: 1px solid var(--border);
}

.word-chip.hot {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: rgba(59, 130, 246, 0.25);
  font-weight: 600;
}

/* ── Beats grid ── */
.beats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.beat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color var(--transition), transform var(--transition);
}

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

.beat-img {
  width: 100%;
  aspect-ratio: 9 / 16;
  object-fit: cover;
  display: block;
  background: var(--bg-raised);
  cursor: pointer;
}

.beat-img-placeholder {
  width: 100%;
  aspect-ratio: 9 / 16;
  background: var(--bg-raised);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 6px;
  color: var(--text-dim);
  font-size: 0.75rem;
  cursor: pointer;
}

.beat-body { padding: 10px 12px; }

.beat-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.beat-text {
  font-size: 0.78rem;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.5;
}

.beat-upload { margin-top: 8px; }

.file-upload-label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--bg-raised);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: all var(--transition);
}

.file-upload-label:hover { background: var(--bg-hover); color: var(--text); }

.file-upload-label input[type="file"] { display: none; }

.file-upload-label.has-file {
  background: var(--success-soft);
  color: var(--success);
  border-color: rgba(34, 197, 94, 0.25);
}

/* ── Render progress ── */
.render-box {
  margin-top: 20px;
  padding: 20px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

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

#render-status-text { font-size: 0.85rem; font-weight: 500; }

#render-percent-text {
  font-family: var(--mono);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--primary);
}

.progress-bar-bg {
  height: 8px;
  background: var(--bg-input);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.progress-bar-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--primary), #60a5fa);
  border-radius: 4px;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.4s ease;
}

.progress-bar-fill.done { background: linear-gradient(90deg, var(--success), #4ade80); }
.progress-bar-fill.error { background: linear-gradient(90deg, var(--danger), #f87171); }

/* ── Video result ── */
.video-result-box .player-container {
  display: flex;
  justify-content: center;
  padding: 10px 0;
}

/* ── Spinner ── */
.spinner {
  width: 15px;
  height: 15px;
  border: 2px solid rgba(255,255,255,0.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: inline-block;
}

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

/* ── Hidden utility ── */
.hidden { display: none !important; }

/* ── Toast Notifications ── */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text);
  pointer-events: auto;
  animation: toastIn 0.25s ease;
  max-width: 360px;
}

.toast.removing { animation: toastOut 0.2s ease forwards; }

.toast-icon {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  flex-shrink: 0;
  font-weight: 700;
}

.toast.success .toast-icon { background: var(--success); color: #fff; }
.toast.error   .toast-icon { background: var(--danger); color: #fff; }
.toast.info    .toast-icon { background: var(--primary-strong); color: #fff; }

.toast.success { border-color: rgba(34, 197, 94, 0.3); }
.toast.error   { border-color: rgba(239, 68, 68, 0.3); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(30px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(30px); }
}

/* ── Voice Preview ── */
.voice-select-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.voice-select-row .input-select { flex: 1; }
.voice-select-row .btn { white-space: nowrap; flex-shrink: 0; }

/* ── Consistency Audit ── */
.consistency-checks-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 4px;
}

.consistency-check-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
}

.consistency-check-icon {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 1px;
}

.consistency-check-icon.pass {
  background: var(--success);
  color: #fff;
}

.consistency-check-icon.fixed {
  background: var(--primary);
  color: #fff;
}

.consistency-check-icon.warn {
  background: var(--warning);
  color: #fff;
}

.consistency-check-content {
  flex: 1;
  min-width: 0;
}

.consistency-check-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}

.consistency-check-desc {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 3px;
  line-height: 1.4;
}

@media (max-width: 768px) {
  .consistency-checks-grid { grid-template-columns: 1fr; }
}

/* ── Script Tools (Hook, Multi-part, English) ── */
.script-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.script-action-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.hook-analysis-box {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 16px;
}

.hook-score-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.hook-sub-scores {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 600;
}

.hook-feedback-text {
  font-size: 0.88rem;
  color: var(--text);
  line-height: 1.5;
  margin-bottom: 10px;
}

.hook-improved-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  flex-wrap: wrap;
}

.hook-improved-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--primary-strong);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.hook-improved-text {
  flex: 1;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  min-width: 200px;
}

.multi-part-box {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 16px;
}

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

.multi-part-header h3 {
  font-size: 1rem;
  font-weight: 700;
}

.multi-part-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.multi-part-item {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}

.multi-part-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.multi-part-item-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--primary-strong);
}

.multi-part-item-summary {
  font-size: 0.84rem;
  color: var(--text);
  line-height: 1.5;
  margin-bottom: 4px;
}

.multi-part-item-cliff {
  font-size: 0.78rem;
  color: var(--text-secondary);
  font-style: italic;
}

/* ── BGM Pacing Map ── */
.bgm-pacing-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.bgm-pacing-item {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}

.bgm-pacing-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.bgm-pacing-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--primary-strong);
}

.bgm-pacing-badge {
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
  color: var(--text-secondary);
}

.bgm-pacing-mood {
  font-size: 0.82rem;
  color: var(--text);
  line-height: 1.4;
  margin-bottom: 4px;
}

.bgm-pacing-inst {
  font-size: 0.76rem;
  color: var(--text-secondary);
}

/* ── Thumbnail Concepts ── */
.thumbnails-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-top: 10px;
}

.thumbnail-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
}

.thumbnail-overlay-preview {
  background: #111827;
  color: #fbbf24;
  font-weight: 900;
  font-size: 1rem;
  text-align: center;
  padding: 14px 10px;
  border-radius: 6px;
  letter-spacing: 0.04em;
  text-shadow: 0 2px 8px rgba(0,0,0,0.8);
}

.thumbnail-concept-name {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}

.thumbnail-trigger-text {
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* ── Responsive ── */
@media (max-width: 640px) {
  html { font-size: 14px; }

  .app-layout { padding: 0 12px 60px; }

  .app-header {
    flex-direction: column;
    height: auto;
    padding: 12px 0;
    gap: 10px;
    align-items: stretch;
  }

  .header-right { justify-content: space-between; }
  .status-badges { flex-wrap: wrap; }

  .project-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .project-bar-left {
    min-width: 0;
    width: 100%;
  }
  .project-select {
    max-width: 100%;
  }
  .project-bar-right {
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 6px;
  }

  .app-tabs {
    top: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .tab-btn {
    font-size: 0.8rem;
    padding: 12px 10px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .tab-btn .tab-num { width: 20px; height: 20px; font-size: 0.75rem; }

  /* Touch targets minimum 44px on mobile (UIUXPROMAX / Apple HIG / WCAG 2.5.5) */
  .btn-sm {
    min-height: 44px;
    padding: 10px 14px;
    font-size: 0.82rem;
  }
  .filter-chip {
    min-height: 38px;
    padding: 8px 12px;
    font-size: 0.78rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .view-switch-btn {
    min-height: 44px;
  }

  .card { padding: 18px 16px; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; gap: 10px; }
  .bgm-pacing-grid, .thumbnails-grid { grid-template-columns: 1fr; }
  .beats-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }

  .btn-lg { width: 100%; }

  .toast-container {
    left: 12px;
    right: 12px;
    bottom: 12px;
  }

  .toast { max-width: 100%; }
}

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

/* ── Fact Check Box & Checks ── */
.fact-alerts-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 12px 0;
}
.fact-alert-item {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 0.85rem;
  color: #fca5a5;
  line-height: 1.4;
}
.fact-checks-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}
.fact-check-item {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.85rem;
}
.fact-check-item.verified {
  border-left: 3px solid #22c55e;
}
.fact-check-item.myth_or_inaccurate {
  border-left: 3px solid #ef4444;
}
.fact-check-claim {
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
.fact-check-expl {
  color: var(--text-muted);
  font-size: 0.8rem;
  line-height: 1.35;
}
.fact-check-correction {
  margin-top: 6px;
  padding: 4px 8px;
  background: rgba(34, 197, 94, 0.1);
  border-radius: 4px;
  color: #86efac;
  font-size: 0.78rem;
}

/* ── Character Bible List ── */
.bible-character-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
  margin-top: 14px;
}
.bible-char-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.bible-char-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.bible-char-name {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
}
.bible-char-era {
  font-size: 0.75rem;
  background: var(--bg-hover);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--text-muted);
}
.btn-delete-bible-char {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.8rem;
  line-height: 1;
  transition: all var(--transition, 0.15s ease);
}
.btn-delete-bible-char:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}
.bible-char-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
  flex: 1;
}
.bible-char-props {
  font-size: 0.75rem;
  color: var(--primary);
  font-weight: 500;
}
.bible-char-appearances {
  font-size: 0.72rem;
  color: var(--text-dim);
}

/* ── Comic Overlays Grid & Prompt Cards ── */
.comic-overlays-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
  margin-top: 14px;
}
.comic-overlay-thumb {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.comic-overlay-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.comic-overlay-badge {
  font-size: 0.75rem;
  font-weight: 700;
  color: #facc15;
  background: rgba(250, 204, 21, 0.12);
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid rgba(250, 204, 21, 0.3);
}
.comic-overlay-body {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.comic-overlay-svg-wrap {
  width: 76px;
  height: 76px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: repeating-conic-gradient(#222 0% 25%, #181818 0% 50%) 50% / 12px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.comic-overlay-svg-wrap svg {
  max-width: 90%;
  max-height: 90%;
}
.comic-overlay-prompt-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.comic-overlay-prompt-text {
  font-size: 0.77rem;
  color: var(--text-secondary);
  line-height: 1.4;
  background: var(--bg-raised);
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  max-height: 90px;
  overflow-y: auto;
  font-family: inherit;
  word-break: break-word;
}
.comic-overlay-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

/* ── TTS Engine Switcher Cards ── */
.tts-engine-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
  margin-top: 8px;
}
.tts-engine-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  user-select: none;
}
.tts-engine-card:hover {
  border-color: var(--primary);
  background: var(--bg-raised);
}
.tts-engine-card.active {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: 0 0 0 2px var(--primary-glow);
}
.tts-engine-card input[type="radio"] {
  margin-top: 3px;
  cursor: pointer;
}
.tts-engine-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.tts-engine-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
}
.tts-engine-desc {
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.35;
}

/* ── Pustaka Library Toolbar ── */
.library-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 18px;
  gap: 12px;
  flex-wrap: wrap;
}
.library-toolbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  flex: 1;
}
.library-toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.library-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-secondary);
  white-space: nowrap;
}
.select-lib {
  padding: 6px 10px;
  font-size: 0.85rem;
  min-width: 200px;
}

/* ── Modal Progress Overlay (%) ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(9, 9, 11, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: modalFadeIn 0.2s ease-out;
}
.modal-overlay.hidden {
  display: none !important;
}
@keyframes modalFadeIn {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: scale(1); }
}
.modal-progress-card {
  background: #18181b;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 16px;
  padding: 32px 36px;
  max-width: 460px;
  width: 100%;
  text-align: center;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.9);
}
.modal-progress-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: #f4f4f5;
  margin: 0 0 8px 0;
}
.modal-progress-percent {
  font-size: 2.5rem;
  font-weight: 800;
  font-family: monospace;
  color: #38bdf8;
  margin: 10px 0 16px 0;
  letter-spacing: -1px;
}
.modal-progress-track {
  height: 10px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 16px;
}
.modal-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #38bdf8, #818cf8, #a855f7);
  background-size: 200% 100%;
  animation: shimmerProgress 2s linear infinite;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 6px;
}
@keyframes shimmerProgress {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.modal-progress-message {
  font-size: 0.88rem;
  color: #a1a1aa;
  margin: 0;
  line-height: 1.45;
}

/* ── Split-Pane Script Workspace ── */
.script-workspace-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}
@media (min-width: 1024px) {
  .script-workspace-grid {
    grid-template-columns: 5fr 7fr;
    align-items: start;
  }
}

/* Duration estimate badge */
.word-count-badge.ready {
  background: var(--success-soft);
  color: var(--success);
  border-color: rgba(16, 185, 129, 0.3);
}
.word-count-badge.warning {
  background: var(--warning-soft);
  color: var(--warning);
  border-color: rgba(245, 158, 11, 0.3);
}

/* ── Interactive Karaoke Word Cloud ── */
.word-chip {
  cursor: pointer;
  transition: all 120ms ease;
  user-select: none;
}
.word-chip:hover {
  border-color: var(--primary);
  color: var(--text);
  transform: translateY(-1px);
}
.word-chip.word-active {
  background: var(--primary) !important;
  color: #ffffff !important;
  border-color: var(--primary-hover) !important;
  box-shadow: 0 0 10px var(--primary-glow);
  transform: scale(1.06);
}

/* ── Filmstrip Pacing Bar ── */
.filmstrip-pacing-wrap {
  margin: 14px 0 18px 0;
  padding: 12px 14px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.filmstrip-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 0.75rem;
}

.filmstrip-title {
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.filmstrip-meta {
  font-family: var(--mono);
  color: var(--primary);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.filmstrip-track {
  display: flex;
  height: 28px;
  background: var(--bg-input);
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
  gap: 2px;
}

.filmstrip-block {
  height: 100%;
  background: var(--primary-soft);
  border-right: 1px solid rgba(0, 0, 0, 0.4);
  cursor: pointer;
  transition: all 120ms ease;
  position: relative;
  min-width: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 0.65rem;
  color: var(--text-secondary);
  user-select: none;
}

.filmstrip-block:hover {
  background: var(--primary);
  color: #ffffff;
  transform: scaleY(1.15);
  z-index: 2;
  box-shadow: 0 0 10px var(--primary-glow);
}

.filmstrip-block.has-image {
  background: rgba(16, 185, 129, 0.25);
  color: var(--success);
}

.filmstrip-block.has-image:hover {
  background: var(--success);
  color: #ffffff;
}

/* Drag and Drop Zone */
.stage-scene-preview-box.drag-over {
  border: 2px dashed var(--primary) !important;
  background: var(--primary-soft) !important;
}

/* 🧬 Project DNA & Production Summary */
.project-dna-section {
  position: relative;
  border-radius: var(--radius-sm);
}

.production-summary-card {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  transition: all 0.2s ease;
}

.production-summary-card:hover {
  border-color: var(--primary);
}

.audio-audit-box {
  transition: all 0.2s ease;
  border-left: 3px solid var(--primary);
}

/* ── Prefers-reduced-motion (A11y & Motion Guardrails) ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .spinner, .spinner-lg {
    animation: none !important;
    border-style: dotted !important;
  }
  .modal-overlay {
    animation: none !important;
  }
  .filmstrip-block:hover, .word-chip:hover, .btn:active:not(:disabled) {
    transform: none !important;
  }
}
