/* ============================================================================
   TRAZOCERO STUDIO PRO — ADAPTADOR DE NOVELA A MANGA CON IA (Por MangaLatam)
   Official Brand Design System: Sumi Obsidian · Imperial Crimson · Platinum Silver · Manga Paper
   ============================================================================ */

:root {
  /* Modo Estudio Oscuro Oficial TrazoCero (Sumi Obsidian Ink + Imperial Crimson + Platinum Silver) */
  --bg-app: #09090b;
  --bg-surface: #111115;
  --bg-card: #17171d;
  --bg-card-hover: #202028;
  --bg-input: #0b0b0e;
  --bg-glass: rgba(15, 15, 19, 0.90);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-highlight: rgba(220, 38, 38, 0.45);

  /* Paleta Oficial TrazoCero Por MangaLatam (Negro Sumi + Carmesí Imperial + Plata Platino + Blanco Papel) */
  --brand-crimson: #dc2626;
  --brand-crimson-hover: #ef4444;
  --brand-crimson-deep: #991b1b;
  --brand-glow: rgba(220, 38, 38, 0.36);
  --accent-silver: #e4e4e7;
  --accent-graphite: #27272a;
  --accent-blue: #d4d4d8;
  --accent-blue-hover: #ffffff;
  --accent-emerald: #f4f4f5;
  --accent-amber: #f59e0b;
  --accent-danger: #ef4444;

  --text-main: #fafafa;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;
  --shadow-card: 0 12px 34px rgba(0, 0, 0, 0.48), 0 1px 0 rgba(255, 255, 255, 0.04) inset;
  --shadow-elevated: 0 24px 60px rgba(0, 0, 0, 0.75);

  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --topbar-height: 60px;
}

/* ============================================================================
   MODO PAPEL MANGA CLARO (PURE MANGA PAPER WHITE & SUMI INK — IGUAL AL BANNER OFICIAL)
   ============================================================================ */
body.theme-light {
  --bg-app: #f3f4f6;
  --bg-surface: #ffffff;
  --bg-card: #f8f8fa;
  --bg-card-hover: #f1f1f4;
  --bg-input: #ffffff;
  --bg-glass: rgba(255, 255, 255, 0.94);
  --border-subtle: rgba(9, 9, 11, 0.10);
  --border-highlight: rgba(200, 30, 43, 0.45);

  --brand-crimson: #c81e2b;
  --brand-crimson-hover: #dc2626;
  --brand-crimson-deep: #991b1b;
  --brand-glow: rgba(200, 30, 43, 0.24);
  --accent-silver: #27272a;
  --accent-blue: #18181b;
  --accent-emerald: #18181b;
  --text-main: #09090b;
  --text-secondary: #3f3f46;
  --text-muted: #71717a;
  --shadow-card: 0 8px 26px rgba(9, 9, 11, 0.06);
  --shadow-elevated: 0 20px 50px rgba(9, 9, 11, 0.14);
}

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

html, body {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-app);
  background-image:
    radial-gradient(ellipse 68% 42% at 15% -8%, rgba(220, 38, 38, 0.14), transparent 65%),
    radial-gradient(ellipse 55% 40% at 88% 108%, rgba(220, 38, 38, 0.08), transparent 65%),
    radial-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 100% 100%, 100% 100%, 18px 18px;
  color: var(--text-main);
  font-family: var(--font-ui);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.2s ease, color 0.2s ease;
}

body.theme-light {
  background-image:
    radial-gradient(ellipse 68% 42% at 15% -8%, rgba(200, 30, 43, 0.08), transparent 65%),
    radial-gradient(rgba(9, 9, 11, 0.05) 1px, transparent 1px);
  background-size: 100% 100%, 16px 16px;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(161, 161, 170, 0.25);
  border-radius: 99px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(220, 38, 38, 0.65);
}

/* ============================================================================
   TOP NAVIGATION BAR (LUXURY TRAZOCERO EDITORIAL HEADER WITH NIB & CRIMSON RIBBON)
   ============================================================================ */
.top-navbar {
  min-height: 54px;
  height: auto;
  background: var(--bg-glass);
  backdrop-filter: blur(22px);
  border-bottom: 1px solid var(--border-subtle);
  box-shadow: 0 1px 0 rgba(220, 38, 38, 0.22), 0 8px 28px rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  padding: 6px 16px;
  gap: 8px;
  z-index: 100;
  flex-shrink: 0;
  width: 100%;
  position: relative;
}

.top-navbar::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, #09090b 0%, #dc2626 35%, #ef4444 50%, #e4e4e7 75%, #09090b 100%);
  pointer-events: none;
}

.brand-area {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex-shrink: 0;
}

.brand-logo-crop {
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  border-radius: 10px;
  padding: 2px 6px;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.brand-logo-crop:hover {
  transform: translateY(-1px);
}

.brand-logo-svg {
  height: 42px;
  width: auto;
  display: block;
  filter: drop-shadow(0 2px 10px rgba(220, 38, 38, 0.25));
  user-select: none;
}

body.theme-light .brand-logo-crop {
  background: linear-gradient(135deg, #09090b 0%, #18181b 100%);
  padding: 3px 10px;
  border: 1px solid rgba(220, 38, 38, 0.45);
  box-shadow: 0 4px 12px rgba(9, 9, 11, 0.18);
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: linear-gradient(135deg, #18181b 0%, #09090b 52%, #dc2626 100%);
  border: 1.5px solid rgba(220, 38, 38, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 13px;
  letter-spacing: -0.5px;
  color: #fff;
  box-shadow: 0 6px 18px var(--brand-glow), 0 0 0 1px rgba(255, 255, 255, 0.08) inset;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}

.brand-text-group {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-name {
  font-size: 16px;
  font-weight: 900;
  letter-spacing: -0.4px;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  line-height: 1.1;
}

.brand-logo-trazo {
  font-style: italic;
  font-weight: 900;
  color: var(--text-main);
  letter-spacing: -0.5px;
}

.brand-logo-cero {
  font-style: italic;
  font-weight: 900;
  color: var(--brand-crimson);
  letter-spacing: -0.5px;
  margin-left: -4px;
  text-shadow: 0 0 18px rgba(220, 38, 38, 0.28);
}

.pro-badge {
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.6px;
  padding: 2px 6px;
  border-radius: 5px;
  background: linear-gradient(135deg, #dc2626, #991b1b);
  border: 1px solid rgba(252, 165, 165, 0.35);
  color: #ffffff;
}

.brand-tag {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 99px;
  background: rgba(220, 38, 38, 0.14);
  color: #fca5a5;
  border: 1px solid rgba(220, 38, 38, 0.35);
  white-space: nowrap;
}

body.theme-light .brand-tag {
  color: #b91c1c;
  background: rgba(200, 30, 43, 0.09);
  border-color: rgba(200, 30, 43, 0.28);
}

.brand-sub {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
  letter-spacing: 0.1px;
}

.brand-sub strong {
  color: var(--text-main);
  font-style: italic;
}

/* Step Switcher Pill */
.step-switcher {
  display: flex;
  align-items: center;
  gap: 3px;
  background: var(--bg-input);
  padding: 3px;
  border-radius: 11px;
  border: 1px solid var(--border-subtle);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25) inset;
  flex-shrink: 1;
  flex-wrap: wrap;
}

.step-tab {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 5px 11px;
  border-radius: 8px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  transition: all 0.18s ease;
}

.step-tab:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

.step-tab.active {
  background: linear-gradient(135deg, #dc2626 0%, #991b1b 100%);
  color: #ffffff;
  font-weight: 800;
  box-shadow: 0 4px 14px var(--brand-glow), 0 1px 0 rgba(255, 255, 255, 0.22) inset;
}

.step-num {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 800;
}

.step-arrow {
  color: var(--text-muted);
  font-size: 12px;
  padding: 0 1px;
  opacity: 0.45;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  min-width: 0;
}

.saas-telemetry-group {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.top-btn-group {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.top-btn-group .btn {
  height: 30px;
  padding: 0 9px;
  font-size: 11px;
}

.memory-status-pill {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(220, 38, 38, 0.12);
  border: 1px solid rgba(220, 38, 38, 0.35);
  color: #fca5a5;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 10.5px;
  font-weight: 700;
  white-space: nowrap;
}

body.theme-light .memory-status-pill {
  color: #991b1b;
  background: rgba(200, 30, 43, 0.10);
  border-color: rgba(200, 30, 43, 0.30);
}

.memory-pill-subtle {
  background: var(--bg-card);
  border-color: var(--border-subtle);
  color: var(--text-secondary);
}

.pulse-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--brand-crimson);
  box-shadow: 0 0 8px var(--brand-crimson);
}

/* ============================================================================
   BUTTONS & INPUTS (LUXURY OBSIDIAN, BRUSHED PLATINUM SILVER & IMPERIAL CRIMSON)
   ============================================================================ */
.btn {
  height: 34px;
  padding: 0 13px;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: #18181f;
  color: #e4e4e7;
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.16s ease;
  text-decoration: none;
}

body.theme-light .btn {
  background: #ffffff;
  border-color: rgba(9, 9, 11, 0.18);
  color: #18181b;
}

.btn:hover:not(:disabled) {
  background: #24242e;
  border-color: rgba(255, 255, 255, 0.32);
  color: #ffffff;
  transform: translateY(-1px);
}

body.theme-light .btn:hover:not(:disabled) {
  background: #f4f4f5;
  border-color: #09090b;
  color: #09090b;
}

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

.btn-ghost {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.13);
  color: #d4d4d8;
}
body.theme-light .btn-ghost {
  background: #f4f4f5;
  border-color: rgba(9, 9, 11, 0.15);
  color: #27272a;
}
.btn-ghost:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.10);
  border-color: rgba(255, 255, 255, 0.28);
  color: #ffffff;
}

/* Botones Secundarios de Acción: Titanio Cepillado / Grafito Metálico (No negro ni rojo saturado) */
.btn-primary,
.btn-emerald {
  background: linear-gradient(180deg, #2a2a35 0%, #1e1e26 100%);
  border: 1px solid rgba(255, 255, 255, 0.20);
  color: #f4f4f5 !important;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35), 0 1px 0 rgba(255, 255, 255, 0.10) inset;
}

body.theme-light .btn-primary,
body.theme-light .btn-emerald {
  background: linear-gradient(180deg, #27272a 0%, #18181b 100%);
  border-color: #18181b;
  color: #ffffff !important;
}

.btn-primary:hover:not(:disabled),
.btn-emerald:hover:not(:disabled) {
  background: linear-gradient(180deg, #383846 0%, #272732 100%);
  border-color: rgba(255, 255, 255, 0.38);
  color: #ffffff !important;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
}

/* Botón Principal de Firma: Rojo Carmesí Imperial Sobrio y Elegante */
.btn-crimson {
  background: linear-gradient(180deg, #dc2626 0%, #991b1b 100%);
  border: 1px solid rgba(248, 113, 113, 0.38);
  color: #ffffff !important;
  font-weight: 800;
  box-shadow: 0 4px 12px rgba(185, 28, 28, 0.28), 0 1px 0 rgba(255, 255, 255, 0.18) inset;
}

body.theme-light .btn-crimson {
  background: linear-gradient(180deg, #dc2626 0%, #991b1b 100%);
  border-color: #991b1b;
  color: #ffffff !important;
}

.btn-crimson:hover:not(:disabled) {
  background: linear-gradient(180deg, #ef4444 0%, #b91c1c 100%);
  border-color: rgba(252, 165, 165, 0.55);
  color: #ffffff !important;
  box-shadow: 0 6px 18px rgba(220, 38, 38, 0.38);
}

/* Botón especial de conexión IA en la barra superior (oscuro con borde carmesí fino) */
.btn-key-connect {
  background: rgba(220, 38, 38, 0.12);
  border: 1px solid rgba(220, 38, 38, 0.48);
  color: #fca5a5 !important;
  font-weight: 700;
}
.btn-key-connect:hover:not(:disabled) {
  background: rgba(220, 38, 38, 0.22);
  border-color: #ef4444;
  color: #ffffff !important;
}

.btn-sm {
  height: 31px;
  padding: 0 11px;
  font-size: 11.5px;
  border-radius: 8px;
}

.btn-xs {
  height: 28px;
  padding: 0 9px;
  font-size: 11px;
  border-radius: 7px;
}

.btn-lg {
  height: 42px;
  padding: 0 22px;
  font-size: 13.5px;
  font-weight: 700;
  border-radius: 11px;
}

.btn-block {
  width: 100%;
}

.input-field, .select-field, .textarea-field {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  border-radius: 9px;
  padding: 8px 11px;
  font-family: var(--font-ui);
  font-size: 12px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.select-field {
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

.input-field:focus, .select-field:focus, .textarea-field:focus {
  outline: none;
  border-color: var(--brand-crimson);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.18);
}

.textarea-field {
  resize: vertical;
  line-height: 1.5;
}

/* Friendly Sentence-Case Field Labels (No Harsh All-Caps Shouting) */
.field-label {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

/* ============================================================================
   MAIN VIEWS CONTAINER
   ============================================================================ */
.views-wrapper {
  flex: 1;
  min-height: 0;
  width: 100%;
  overflow: hidden;
  position: relative;
}

.step-view {
  display: none;
  width: 100%;
  height: 100%;
  overflow-y: auto;
}

.step-view.active {
  display: flex;
  flex-direction: column;
}

/* ============================================================================
   STEP 1: BIBLIA DE LA OBRA (FRESH 3-COLUMN WORKSPACE)
   ============================================================================ */
.bible-container {
  max-width: 1520px;
  width: 100%;
  margin: 0 auto;
  padding: 20px 24px 96px 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.bible-hero-banner {
  background:
    radial-gradient(circle at 0% 0%, rgba(255, 255, 255, 0.03), transparent 55%),
    var(--bg-surface);
  border: 1px solid rgba(255, 255, 255, 0.10);
  box-shadow: var(--shadow-card);
  border-radius: 16px;
  padding: 18px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  position: relative;
  overflow: hidden;
}

.bible-hero-banner::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  bottom: 0;
  background: linear-gradient(180deg, #dc2626 0%, #991b1b 100%);
}

/* ============================================================================
   BYOK 2-CLICK GUIDED ACTIVATION BANNER & STEP CARDS (IDEA 1 — S/ 0.00 SERVER COST)
   ============================================================================ */
.byok-connect-banner {
  background: linear-gradient(135deg, #131318 0%, #17171f 100%);
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-left: 3px solid #dc2626;
  border-radius: 14px;
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.32);
}

body.theme-light .byok-connect-banner {
  background: linear-gradient(135deg, #ffffff 0%, #fafafa 70%, rgba(200, 30, 43, 0.07) 100%);
  border-color: rgba(200, 30, 43, 0.32);
  box-shadow: 0 6px 20px rgba(9, 9, 11, 0.06);
}

.byok-connect-banner.connected {
  border-color: rgba(228, 228, 231, 0.22);
  background: linear-gradient(135deg, rgba(24, 24, 27, 0.92) 0%, rgba(17, 17, 21, 0.95) 100%);
}

body.theme-light .byok-connect-banner.connected {
  background: #ffffff;
  border-color: rgba(9, 9, 11, 0.14);
}

.byok-steps-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

@media (max-width: 680px) {
  .byok-steps-grid {
    grid-template-columns: 1fr;
  }
}

.byok-step-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  position: relative;
}

.byok-step-card.highlight {
  border-color: rgba(220, 38, 38, 0.45);
  background: linear-gradient(160deg, rgba(220, 38, 38, 0.09) 0%, var(--bg-card) 70%);
}

.byok-step-num {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 10.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #fca5a5;
}

body.theme-light .byok-step-num {
  color: #b91c1c;
}

.byok-verify-box {
  border-radius: 10px;
  padding: 10px 13px;
  font-size: 12px;
  font-weight: 600;
  display: none;
  align-items: center;
  gap: 8px;
  line-height: 1.45;
}

.byok-verify-box.ok {
  display: flex;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: #6ee7b7;
}

body.theme-light .byok-verify-box.ok {
  color: #065f46;
  background: rgba(16, 185, 129, 0.10);
}

.byok-verify-box.err {
  display: flex;
  background: rgba(220, 38, 38, 0.14);
  border: 1px solid rgba(220, 38, 38, 0.45);
  color: #fca5a5;
}

body.theme-light .byok-verify-box.err {
  color: #991b1b;
}

.hero-left-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 280px;
  flex: 1;
}

.hero-eyebrow-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 2px;
}

.pro-pill-mini {
  font-size: 10px;
  font-weight: 800;
  padding: 2px 9px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #e4e4e7;
}

body.theme-light .pro-pill-mini {
  color: #18181b;
  background: rgba(9, 9, 11, 0.06);
  border-color: rgba(9, 9, 11, 0.18);
}

.hero-eyebrow-sep {
  color: var(--text-muted);
}

.hero-eyebrow-text {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-secondary);
}

.bible-hero-title {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.3px;
  color: var(--text-main);
}

.bible-hero-desc {
  font-size: 12.5px;
  color: var(--text-secondary);
}

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

.preset-pills-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 6px 10px;
}

.preset-bar-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

.preset-chip {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: #ffffff;
  border-radius: 7px;
  padding: 5px 11px;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  outline: none;
  transition: all 0.15s ease;
}

body.theme-light .preset-chip {
  background: #ffffff;
  border-color: rgba(9, 9, 11, 0.22);
  color: #09090b;
}

.preset-chip:hover:not(.preset-chip-featured):not(.active) {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.45);
  color: #ffffff;
}

body.theme-light .preset-chip:hover:not(.preset-chip-featured):not(.active) {
  background: #f4f4f5;
  border-color: #09090b;
  color: #09090b;
}

.preset-chip.preset-chip-featured,
.preset-chip.active {
  background: linear-gradient(135deg, #e11d48 0%, #dc2626 48%, #991b1b 100%) !important;
  border-color: rgba(252, 165, 165, 0.55) !important;
  color: #ffffff !important;
  font-weight: 800;
  box-shadow: 0 4px 14px rgba(220, 38, 38, 0.42);
}

.saas-economy-panel {
  background: #14141a;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

body.theme-light .saas-economy-panel {
  background: #f8fafc;
  border-color: rgba(9, 9, 11, 0.14);
}

.eco-saving-tag {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #e4e4e7;
}
body.theme-light .eco-saving-tag {
  color: #18181b;
  background: rgba(9, 9, 11, 0.06);
  border-color: rgba(9, 9, 11, 0.18);
}

.eco-toggles-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--border-subtle);
}

.eco-toggle-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  color: var(--text-secondary);
  cursor: pointer;
}

.eco-toggle-item input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--brand-crimson);
  cursor: pointer;
}

.bible-3col-grid {
  display: grid;
  grid-template-columns: 1.15fr 1.05fr 0.95fr;
  gap: 18px;
  align-items: start;
}

.bible-column-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-card);
  border-radius: 16px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 13px;
}

.column-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-subtle);
  gap: 8px;
}

.column-title {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text-main);
}

.column-subtitle {
  font-size: 11.5px;
  color: var(--text-secondary);
  margin-top: 2px;
}

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

.entity-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: all 0.16s ease;
}

.entity-card:hover {
  border-color: var(--border-highlight);
}

.entity-card-top {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.entity-avatar-box {
  width: 74px;
  height: 92px;
  border-radius: 9px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  flex-shrink: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.entity-avatar-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.entity-avatar-placeholder {
  font-size: 10px;
  color: var(--text-muted);
  text-align: center;
  padding: 4px;
}

.lock-badge-mini {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(90deg, #dc2626, #991b1b);
  color: #ffffff;
  font-size: 9px;
  font-weight: 800;
  text-align: center;
  padding: 2px 0;
}

.entity-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.entity-name-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.entity-name {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-main);
}

.role-pill {
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 99px;
  background: rgba(220, 38, 38, 0.14);
  border: 1px solid rgba(220, 38, 38, 0.30);
  color: #fca5a5;
  white-space: nowrap;
}
body.theme-light .role-pill {
  color: #b91c1c;
  background: rgba(200, 30, 43, 0.09);
}

.entity-meta-line {
  font-size: 11.5px;
  color: var(--text-secondary);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.entity-meta-line strong {
  color: var(--text-main);
}

.entity-actions-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--border-subtle);
  flex-wrap: wrap;
}

.bible-bottom-cta {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-glass);
  backdrop-filter: blur(18px);
  border-top: 1px solid rgba(220, 38, 38, 0.25);
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.45);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  z-index: 50;
}

/* ============================================================================
   STEP 2: PLAN DE VIÑETAS IA
   ============================================================================ */
.plan-container {
  max-width: 1420px;
  width: 100%;
  margin: 0 auto;
  padding: 20px 24px 80px 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.plan-page-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: var(--shadow-card);
}

.plan-page-header {
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-subtle);
}

.plan-reason-box {
  background: rgba(220, 38, 38, 0.08);
  border: 1px solid rgba(220, 38, 38, 0.25);
  border-radius: 10px;
  padding: 9px 13px;
  font-size: 12px;
  color: var(--text-secondary);
}

.plan-panels-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}

.plan-panel-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.plan-panel-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.panel-badge {
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 6px;
  background: var(--brand-crimson);
  color: #fff;
}

.camera-badge {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 600;
}

.panel-cast-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.cast-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.14s ease;
}

.cast-chip:hover {
  border-color: var(--border-highlight);
  color: var(--text-main);
}

.cast-chip.active, .cast-chip.selected {
  background: rgba(220, 38, 38, 0.16);
  border-color: var(--brand-crimson);
  color: #fca5a5;
}
body.theme-light .cast-chip.active {
  color: #991b1b;
  background: rgba(200, 30, 43, 0.10);
}

/* ============================================================================
   STEP 3: ESTUDIO DE MANGA (CLEAN, AIRY & ZERO OVERFLOW)
   ============================================================================ */
.studio-workspace {
  display: flex;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

/* Left Strip: Pages */
.studio-pages-sidebar {
  width: clamp(175px, 14vw, 205px);
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  padding: 12px;
  gap: 8px;
  flex-shrink: 0;
}

.pages-vertical-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-right: 2px;
}

.page-thumb-card {
  background: var(--bg-card);
  border: 2px solid var(--border-subtle);
  border-radius: 12px;
  padding: 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: all 0.16s ease;
}

.page-thumb-card:hover {
  border-color: var(--border-highlight);
}

.page-thumb-card.active {
  border-color: var(--brand-crimson);
  background: rgba(220, 38, 38, 0.12);
  box-shadow: 0 4px 14px rgba(220, 38, 38, 0.18);
}

.page-thumb-preview {
  width: 100%;
  height: 168px;
  background: #ffffff;
  border-radius: 7px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.page-thumb-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.page-thumb-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-main);
}

/* Center Manga Canvas Area */
.studio-center-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-app);
  background-image: radial-gradient(rgba(161, 161, 170, 0.14) 1px, transparent 1px);
  background-size: 20px 20px;
  position: relative;
  overflow: hidden;
  min-width: 0;
}

.stage-top-hud {
  min-height: 44px;
  height: auto;
  width: 100%;
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  padding: 5px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  flex-wrap: wrap;
  flex-shrink: 0;
  z-index: 20;
}

.hud-left-group, .hud-center-group, .hud-right-group {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.hud-right-group .btn {
  height: 26px;
  padding: 0 8px;
  font-size: 11px;
}

.hud-sheet-title {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 105px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  padding: 3px 8px;
  border-radius: 7px;
}

.hud-zoom-pill, .hud-history-pill {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 2px 5px;
}

.hud-icon-btn {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-main);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.14s;
}
.hud-icon-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.12);
}
.hud-icon-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.hud-fit-btn {
  height: 22px;
  padding: 0 7px;
  border-radius: 6px;
  border: none;
  background: rgba(220, 38, 38, 0.16);
  color: var(--text-main);
  font-size: 10.5px;
  font-weight: 700;
  cursor: pointer;
}
.hud-fit-btn:hover {
  background: rgba(220, 38, 38, 0.28);
}

.hud-zoom-readout {
  font-family: var(--font-mono);
  font-size: 10.5px;
  min-width: 36px;
  text-align: center;
  color: var(--text-main);
  font-weight: 600;
}

/* Never float over the manga page! Hidden so the sheet is 100 % unobstructed */
.canvas-floating-bar {
  display: none !important;
}

/* Scrollable Canvas Viewport */
.canvas-viewport {
  flex: 1;
  width: 100%;
  overflow: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 22px 16px;
}

.canvas-scroll-sizer {
  position: relative;
  margin: auto;
  flex-shrink: 0;
}

.canvas-stage-wrapper {
  background: #ffffff;
  border-radius: 4px;
  box-shadow: var(--shadow-elevated), 0 0 0 1px rgba(255, 255, 255, 0.18);
  transform-origin: top left;
}

/* Right Director Inspector Sidebar — Clean, Cohesive & Responsive */
.studio-director-sidebar {
  width: clamp(305px, 24vw, 352px);
  background: var(--bg-surface);
  border-left: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px;
  gap: 10px;
  flex-shrink: 0;
}

.inspector-top-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-subtle);
}

.inspector-tabs-bar {
  display: grid;
  grid-template-columns: 1.1fr 1.1fr 1.1fr 0.8fr;
  gap: 4px;
  background: var(--bg-input);
  padding: 4px;
  border-radius: 11px;
  border: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 15;
}

.inspector-tab-btn {
  height: 30px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-ui);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.inspector-tab-btn:hover {
  color: var(--text-main);
}

.inspector-tab-btn.active {
  background: linear-gradient(135deg, #dc2626 0%, #991b1b 100%);
  color: #ffffff;
  font-weight: 700;
  box-shadow: 0 3px 10px var(--brand-glow);
}

.inspector-tab-pane {
  display: none;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.inspector-tab-pane.active,
.studio-director-sidebar.show-all-panes .inspector-tab-pane {
  display: flex;
}

/* Unified Clean Cards */
.director-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 13px;
  padding: 11px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  box-sizing: border-box;
}

.studio-director-sidebar .btn-block {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  white-space: normal;
  height: auto;
  min-height: 30px;
  padding: 6px 8px;
  line-height: 1.22;
  text-align: center;
  box-sizing: border-box;
}

.director-card-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 6px;
}
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}
.grid-4-compact {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 5px;
}
.grid-5-compact {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px;
}

.grid-2 > .btn,
.grid-3 > .btn,
.grid-4-compact > .btn,
.grid-5-compact > .btn {
  min-width: 0;
  width: 100%;
  padding: 0 7px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.grid-4-compact > .btn,
.grid-5-compact > .btn {
  font-size: 10.5px;
  padding: 0 4px;
}

/* ============================================================================
   MODALS, OVERLAY & TOASTS
   ============================================================================ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(9, 9, 11, 0.78);
  backdrop-filter: blur(10px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 250;
}
.modal-backdrop.open {
  display: flex;
}

#modalCharacter, #modalLocation {
  z-index: 295;
}

.balloons-quick-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-height: 118px;
  overflow-y: auto;
}

.balloon-quick-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 11.5px;
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.14s ease;
}

.balloon-quick-item:hover {
  border-color: var(--border-highlight);
}

.balloon-quick-item.active {
  border-color: var(--brand-crimson);
  background: rgba(220, 38, 38, 0.14);
  font-weight: 700;
}

.novel-breakdown-section {
  background: var(--bg-surface);
  border: 1px solid rgba(220, 38, 38, 0.35);
  border-radius: 16px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: var(--shadow-card);
}

.novel-breakdown-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-subtle);
  flex-wrap: wrap;
}

.novel-sheets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 14px;
}

.novel-sheet-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.page-thumb-del-btn {
  background: rgba(220, 38, 38, 0.14);
  border: 1px solid rgba(220, 38, 38, 0.35);
  color: #fca5a5;
  border-radius: 6px;
  padding: 2px 6px;
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
}
.page-thumb-del-btn:hover {
  background: #dc2626;
  color: #fff;
}

.modal-box {
  background: var(--bg-surface);
  border: 1px solid rgba(220, 38, 38, 0.38);
  border-radius: 18px;
  width: 560px;
  max-width: 94vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-elevated);
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  background: linear-gradient(135deg, rgba(220, 38, 38, 0.12), rgba(24, 24, 27, 0.6));
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

/* AI Production Fullscreen Overlay */
.ai-production-overlay {
  position: fixed;
  inset: 0;
  background: rgba(9, 9, 11, 0.84);
  backdrop-filter: blur(12px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 300;
}
.ai-production-overlay.open {
  display: flex;
}

.production-card {
  width: 500px;
  max-width: 92vw;
  background: var(--bg-surface);
  border: 1.5px solid var(--brand-crimson);
  border-radius: 18px;
  padding: 26px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: var(--shadow-elevated);
}

.progress-track {
  width: 100%;
  height: 9px;
  background: var(--bg-input);
  border-radius: 99px;
  overflow: hidden;
  border: 1px solid var(--border-subtle);
}

.progress-fill {
  height: 100%;
  width: 25%;
  background: linear-gradient(90deg, #991b1b 0%, #dc2626 55%, #ffffff 100%);
  border-radius: 99px;
  transition: width 0.3s ease;
}

.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 400;
}

.toast-msg {
  background: var(--bg-surface);
  border: 1px solid var(--border-highlight);
  border-left: 4px solid var(--brand-crimson);
  color: var(--text-main);
  padding: 11px 16px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  box-shadow: var(--shadow-elevated);
  max-width: 360px;
}

.credit-wallet-pill {
  background: rgba(220, 38, 38, 0.14);
  border-color: rgba(220, 38, 38, 0.40);
  color: #fca5a5;
  cursor: pointer;
  transition: all 0.16s ease;
}
body.theme-light .credit-wallet-pill {
  color: #b91c1c;
}
.credit-wallet-pill:hover {
  background: rgba(220, 38, 38, 0.24);
}

.webtoon-live-container {
  width: min(800px, 96%);
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-bottom: 40px;
}

.webtoon-live-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  background: var(--bg-glass);
  border: 1px solid var(--border-highlight);
  border-radius: 14px;
  padding: 12px 16px;
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(14px);
}

.webtoon-strip-list {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  background: #09090b;
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-elevated);
}

.webtoon-strip-list img {
  width: 100%;
  max-width: 800px;
  display: block;
}

/* ============================================================================
   1. EDICIÓN DIRECTA A DOBLE CLIC (BARRA SUPERIOR ACOPLADA — JAMÁS TAPA EL MANGA)
   ============================================================================ */
.inline-balloon-popover {
  position: relative;
  top: auto;
  left: auto;
  transform: none;
  z-index: 25;
  width: 100%;
  background: var(--bg-surface);
  border-bottom: 1.5px solid var(--brand-crimson);
  border-radius: 0;
  padding: 8px 16px;
  display: none;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

.inline-balloon-popover.open {
  display: flex;
}

.inline-popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.inline-popover-title {
  font-size: 12px;
  font-weight: 800;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ============================================================================
   2. BOTÓN MODO CREACIÓN RÁPIDA EN 1 CLIC (EXPRESS MANGA CTA — TRAZOCERO SIGNATURE)
   ============================================================================ */
.btn-express-magic {
  background: linear-gradient(180deg, #dc2626 0%, #991b1b 100%);
  border: 1px solid rgba(248, 113, 113, 0.42);
  color: #ffffff !important;
  font-weight: 800;
  box-shadow: 0 4px 14px rgba(185, 28, 28, 0.30), 0 1px 0 rgba(255, 255, 255, 0.18) inset;
}

.btn-express-magic:hover {
  background: linear-gradient(180deg, #ef4444 0%, #b91c1c 100%);
  border-color: rgba(252, 165, 165, 0.6);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(220, 38, 38, 0.42);
}

/* ============================================================================
   3. SELECTOR VISUAL DE EXPRESIONES FACIALES EN 1 CLIC
   ============================================================================ */
.emotion-chips-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
}

.emotion-chip-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 29px;
  padding: 0 6px;
  border-radius: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.14s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.emotion-chip-btn:hover {
  border-color: var(--brand-crimson);
  background: var(--bg-card-hover);
}

.emotion-chip-btn.active {
  background: rgba(220, 38, 38, 0.18);
  border-color: var(--brand-crimson);
  color: #fca5a5;
  font-weight: 700;
}
body.theme-light .emotion-chip-btn.active {
  color: #b91c1c;
}

/* ============================================================================
   4. SELECTOR GRÁFICO DE PLANTILLAS DE VIÑETAS (MINIATURAS SVG)
   ============================================================================ */
.layout-visual-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  margin-bottom: 6px;
}

.layout-visual-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 7px 5px;
  border-radius: 10px;
  background: var(--bg-input);
  border: 1.5px solid var(--border-subtle);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.layout-visual-card:hover {
  border-color: var(--border-highlight);
  color: var(--text-main);
  background: var(--bg-card-hover);
}

.layout-visual-card.active {
  border-color: var(--brand-crimson);
  background: rgba(220, 38, 38, 0.14);
  color: var(--text-main);
  box-shadow: 0 2px 10px rgba(220, 38, 38, 0.22);
}

.layout-visual-card svg {
  width: 34px;
  height: 46px;
  display: block;
}

.layout-visual-label {
  font-size: 10px;
  font-weight: 700;
  text-align: center;
  line-height: 1.15;
}

/* ============================================================================
   5. MODO LECTURA Y PRESENTACIÓN A PANTALLA COMPLETA (MANGA READER OVERLAY)
   ============================================================================ */
.manga-reader-overlay {
  position: fixed;
  inset: 0;
  z-index: 350;
  background: rgba(9, 9, 11, 0.96);
  backdrop-filter: blur(16px);
  display: none;
  flex-direction: column;
}

.manga-reader-overlay.open {
  display: flex;
}

.manga-reader-topbar {
  min-height: 54px;
  height: auto;
  padding: 8px 18px;
  background: rgba(17, 17, 21, 0.94);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  flex-shrink: 0;
}

.manga-reader-stage {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 24px 16px 48px;
  gap: 20px;
}

.reader-page-frame {
  max-height: calc(100vh - 130px);
  width: auto;
  max-width: min(720px, 94vw);
  border-radius: 6px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: #ffffff;
  object-fit: contain;
}

.reader-vertical-list {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  width: min(720px, 95vw);
}

.reader-vertical-list img {
  width: 100%;
  height: auto;
  border-radius: 6px;
  background: #ffffff;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.65);
}

.reader-nav-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(23, 23, 29, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.14);
  padding: 8px 16px;
  border-radius: 99px;
}

/* ============================================================================
   RESPONSIVE BREAKPOINTS (100 % FLUID ACROSS ALL SCREENS)
   ============================================================================ */
@media (max-width: 1880px) {
  .brand-sub {
    display: none;
  }
}

@media (max-width: 1760px) {
  .memory-pill-subtle {
    display: none;
  }
  .brand-name .brand-tag {
    display: none;
  }
}

@media (max-width: 1580px) {
  #apiEconomyPill {
    display: none;
  }
  .step-tab {
    padding: 4px 8px;
    font-size: 11px;
  }
  .top-btn-group .btn {
    padding: 0 8px;
    font-size: 10.5px;
    height: 28px;
  }
}

@media (max-width: 1360px) {
  .studio-pages-sidebar {
    width: 168px;
    padding: 10px;
  }
  .studio-director-sidebar {
    width: 295px;
    padding: 10px;
  }
}

@media (max-width: 1180px) {
  .bible-3col-grid {
    grid-template-columns: 1fr 1fr;
  }
  .saas-telemetry-group {
    display: none;
  }
}

@media (max-width: 960px) {
  .bible-3col-grid {
    grid-template-columns: 1fr;
  }
}

/* ============================================================================
   TUTORIAL INTERACTIVO, DICCIONARIO DE BOTONES E INSPECTOR INTELIGENTE
   ============================================================================ */
.tutorial-hero-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding: 14px 16px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(220, 38, 38, 0.22), rgba(24, 24, 27, 0.85));
  border: 1px solid rgba(220, 38, 38, 0.45);
}

.guide-sections-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 12px;
}

.guide-steps-cards {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.guide-btn-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.guide-btn-item {
  background: rgba(15, 15, 19, 0.65);
  border: 1px solid var(--border-subtle);
  border-radius: 9px;
  padding: 9px 11px;
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.guide-btn-item:hover {
  border-color: rgba(220, 38, 38, 0.55);
}

.guide-btn-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 5px;
}

.guide-btn-head .btn {
  margin-left: auto;
}

.guide-btn-chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.guide-btn-chip.chip-ai {
  background: linear-gradient(135deg, rgba(220, 38, 38, 0.35), rgba(39, 39, 42, 0.65));
  border-color: rgba(239, 68, 68, 0.55);
}

.guide-cost-tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 10.5px;
  font-weight: 800;
  white-space: nowrap;
}

.guide-cost-tag.cost-free {
  background: rgba(228, 228, 231, 0.14);
  color: #f4f4f5;
  border: 1px solid rgba(228, 228, 231, 0.32);
}

.guide-cost-tag.cost-ai {
  background: rgba(220, 38, 38, 0.20);
  color: #fca5a5;
  border: 1px solid rgba(220, 38, 38, 0.45);
}

.guide-btn-item p {
  margin: 0;
  font-size: 11.8px;
  color: var(--text-secondary);
  line-height: 1.48;
}

/* Recorrido Guiado en Vivo (Spotlight Tour) */
.tour-overlay {
  position: fixed;
  inset: 0;
  z-index: 9800;
  pointer-events: none;
}

.tour-spotlight-box {
  position: fixed;
  border-radius: 12px;
  border: 3px solid #ef4444;
  box-shadow: 0 0 0 9999px rgba(9, 9, 11, 0.76), 0 0 28px rgba(220, 38, 38, 0.85);
  transition: all 0.28s cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: none;
}

.tour-dialog-card {
  position: fixed;
  width: min(390px, 92vw);
  background: rgba(17, 17, 21, 0.98);
  border: 1.5px solid rgba(220, 38, 38, 0.65);
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.88);
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: top 0.28s ease, left 0.28s ease;
  z-index: 9810;
}

.tour-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tour-step-badge {
  font-size: 10.5px;
  font-weight: 900;
  letter-spacing: 0.6px;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(220, 38, 38, 0.28);
  color: #fecaca;
}

.tour-close-btn {
  margin-left: auto;
  background: transparent;
  border: none;
  color: #a1a1aa;
  font-size: 14px;
  cursor: pointer;
  padding: 2px 6px;
}

.tour-close-btn:hover {
  color: #ffffff;
}

.tour-card-title {
  font-size: 15px;
  font-weight: 800;
  color: #ffffff;
}

.tour-card-desc {
  font-size: 12.5px;
  color: #d4d4d8;
  line-height: 1.55;
}

.tour-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.tour-dots {
  display: flex;
  align-items: center;
  gap: 5px;
}

.tour-dot {
  width: 7px;
  height: 7px;
  border-radius: 99px;
  background: rgba(161, 161, 170, 0.35);
  transition: all 0.2s ease;
}

.tour-dot.active {
  width: 18px;
  background: #dc2626;
}

/* Inspector Inteligente Flotante de Botones (Hover Card) */
.smart-btn-tooltip {
  position: fixed;
  z-index: 9900;
  width: min(310px, 88vw);
  background: rgba(15, 15, 19, 0.98);
  border: 1px solid rgba(220, 38, 38, 0.55);
  border-radius: 11px;
  padding: 10px 12px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.82);
  pointer-events: none;
  backdrop-filter: blur(10px);
}

.smart-tooltip-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 5px;
}

.smart-tooltip-top strong {
  font-size: 12px;
  color: #ffffff;
  font-weight: 800;
}

.smart-tooltip-desc {
  font-size: 11.5px;
  color: #d4d4d8;
  line-height: 1.45;
}

.smart-tooltip-tip {
  margin-top: 6px;
  padding-top: 5px;
  border-top: 1px dashed rgba(161, 161, 170, 0.22);
  font-size: 10.8px;
  color: #fca5a5;
  font-weight: 600;
}

/* Efecto de iluminación cuando el autor pulsa "📍 Señalar" */
@keyframes locatePulseRing {
  0% {
    box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.95), 0 0 24px rgba(220, 38, 38, 0.9);
    transform: scale(1.04);
  }
  50% {
    box-shadow: 0 0 0 12px rgba(220, 38, 38, 0), 0 0 32px rgba(239, 68, 68, 0.95);
    transform: scale(1.08);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(220, 38, 38, 0), 0 0 0 rgba(220, 38, 38, 0);
    transform: scale(1);
  }
}

.locate-pulse-highlight {
  position: relative;
  z-index: 500 !important;
  outline: 3px solid #ef4444 !important;
  outline-offset: 3px !important;
  animation: locatePulseRing 1.1s ease-in-out 3;
}
