/* ==========================================================================
   MANUSCRITOS DE LA PENUMBRA — ESTILOS MAESTROS EDITORIALES (V5.1 LUXURY TIER)
   Diseño de Alta Gama: Obsidiana Profunda, Oro Envejecido, Carmesí Gótico
   ========================================================================== */

:root {
  /* Paleta Base: Obsidiana y Sombras */
  --bg-deep: #0a0a0e;
  --bg-main: #0f0f15;
  --bg-surface: #14141d;
  --bg-surface-elevated: #1a1a26;
  --bg-surface-hover: #222232;
  --bg-input: #0b0b10;
  
  /* Bordes y Líneas */
  --border-subtle: #232332;
  --border-medium: #323247;
  --border-accent: #4a2228;
  --border-gold: rgba(197, 160, 89, 0.35);

  /* Acentos de Color */
  --gold: #c5a059;
  --gold-light: #dfbe76;
  --gold-dim: #8c713a;
  --gold-glow: rgba(197, 160, 89, 0.22);

  --crimson: #8f2531;
  --crimson-light: #b93240;
  --crimson-dark: #4d141b;
  --crimson-glow: rgba(143, 37, 49, 0.35);

  --emerald: #1fa472;
  --emerald-dim: rgba(31, 164, 114, 0.18);
  --purple: #8b5cf6;
  --blue: #3b82f6;

  /* Tipografías */
  --text-main: #e8e2d5;       /* Pergamino claro */
  --text-secondary: #aba191;  /* Texto atenuado */
  --text-muted: #756d61;      /* Texto terciario */
  --text-inverse: #0f0f15;

  --font-serif-title: 'Cinzel', Georgia, serif;
  --font-serif-body: 'Crimson Pro', Garamond, serif;
  --font-sans-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  /* Sombras y Luces */
  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.45);
  --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.65);
  --shadow-lg: 0 14px 40px rgba(0, 0, 0, 0.85);
  --shadow-gold: 0 0 25px rgba(197, 160, 89, 0.15);
  --shadow-crimson: 0 0 25px rgba(143, 37, 49, 0.25);

  /* Radios */
  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-full: 9999px;

  /* Dimensiones del Layout */
  --sidebar-width: 275px;
  --topbar-height: 76px;
  --transition-fast: 0.18s ease;
  --transition-normal: 0.28s ease;
}

/* ==========================================================================
   RESET & BASE GLOBALES
   ========================================================================== */

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

html {
  font-size: 15px;
  scroll-behavior: smooth;
  background-color: var(--bg-deep);
  color: var(--text-main);
}

body.app-body {
  font-family: var(--font-sans-ui);
  background: var(--bg-deep);
  background-image: 
    radial-gradient(circle at 15% 10%, rgba(143, 37, 49, 0.08) 0%, transparent 45%),
    radial-gradient(circle at 85% 85%, rgba(197, 160, 89, 0.05) 0%, transparent 50%),
    radial-gradient(circle at 50% 50%, rgba(15, 15, 21, 0.98) 0%, #08080b 100%);
  background-attachment: fixed;
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: rgba(11, 11, 16, 0.8);
}
::-webkit-scrollbar-thumb {
  background: var(--border-medium);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--gold-dim);
}

/* ==========================================================================
   ESTRUCTURA MAESTRA DEL LAYOUT (APP SHELL)
   ========================================================================== */

.app-layout {
  display: flex;
  min-height: 100vh;
  width: 100vw;
  position: relative;
}

/* ==========================================================================
   BARRA LATERAL EDITORIAL (SIDEBAR)
   ========================================================================== */

.app-sidebar {
  width: var(--sidebar-width);
  background: linear-gradient(180deg, #12121a 0%, #0c0c12 100%);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 1000;
  transition: transform var(--transition-normal);
  box-shadow: var(--shadow-lg);
}

/* Marca / Emblema */
.sidebar-brand {
  padding: 1.5rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(0, 0, 0, 0.2);
}

.brand-emblem {
  font-size: 2rem;
  filter: drop-shadow(0 0 10px rgba(197, 160, 89, 0.5));
  animation: flickerCandle 3.5s infinite ease-in-out;
}

@keyframes flickerCandle {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 0 10px rgba(197, 160, 89, 0.5)); }
  50% { transform: scale(1.04); filter: drop-shadow(0 0 14px rgba(197, 160, 89, 0.7)); }
}

.brand-info {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-family: var(--font-serif-title);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: #fff;
  line-height: 1.1;
}

.brand-title-accent {
  font-family: var(--font-serif-title);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--gold);
  line-height: 1.2;
}

.brand-caption {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 0.2rem;
}

/* Navegación del Sidebar */
.sidebar-nav {
  flex: 1;
  padding: 1.25rem 0.85rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.nav-group-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--gold-dim);
  font-weight: 700;
  padding: 0 0.75rem 0.4rem;
}

.sidebar-link {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.75rem 0.9rem;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans-ui);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: all var(--transition-fast);
  position: relative;
}

.sidebar-link .nav-icon {
  font-size: 1.15rem;
  opacity: 0.85;
}

.sidebar-link .nav-text {
  flex: 1;
}

.sidebar-link .nav-badge,
.sidebar-link .nav-badge-accent,
.sidebar-link .nav-badge-gold {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.18rem 0.55rem;
  border-radius: var(--radius-full);
}

.sidebar-link .nav-badge {
  background: rgba(255, 255, 255, 0.08);
  color: #cbd5e1;
}

.sidebar-link .nav-badge-accent {
  background: rgba(143, 37, 49, 0.3);
  color: #f87171;
  border: 1px solid rgba(143, 37, 49, 0.6);
}

.sidebar-link .nav-badge-gold {
  background: rgba(197, 160, 89, 0.2);
  color: var(--gold-light);
  border: 1px solid rgba(197, 160, 89, 0.4);
}

.sidebar-link:hover {
  background: var(--bg-surface-elevated);
  color: #fff;
  border-color: var(--border-subtle);
  transform: translateX(3px);
}

.sidebar-link.active {
  background: linear-gradient(90deg, rgba(143, 37, 49, 0.25) 0%, rgba(20, 20, 29, 0.9) 100%);
  color: #fff;
  font-weight: 600;
  border: 1px solid var(--border-accent);
  box-shadow: inset 3px 0 0 var(--crimson-light);
}

.sidebar-link.active .nav-icon {
  opacity: 1;
  filter: drop-shadow(0 0 6px rgba(143, 37, 49, 0.8));
}

/* Pie del Sidebar */
.sidebar-footer {
  padding: 1rem 0.85rem;
  border-top: 1px solid var(--border-subtle);
  background: rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.sidebar-status-card {
  background: rgba(11, 11, 16, 0.6);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.8rem;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: #34d399;
  font-weight: 600;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background-color: #34d399;
  border-radius: 50%;
  box-shadow: 0 0 8px #34d399;
  animation: pulseDot 2s infinite ease-in-out;
}

@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

.status-details {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.sidebar-actions {
  display: flex;
  gap: 0.5rem;
}

.btn-sidebar-action {
  flex: 1;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: 0.5rem 0.4rem;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-sidebar-action:hover {
  background: var(--bg-surface-elevated);
  color: #fff;
  border-color: var(--border-medium);
}

/* ==========================================================================
   ÁREA PRINCIPAL DE TRABAJO (MAIN VIEWPORT)
   ========================================================================== */

.app-main-viewport {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
}

/* ==========================================================================
   TOPBAR SUPERIOR (CABECERA Y ACCIONES RÁPIDAS)
   ========================================================================== */

.app-topbar {
  height: var(--topbar-height);
  background: rgba(15, 15, 21, 0.85);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 900;
  padding: 0 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  min-width: 0;
}

/* Botón Hamburger (Móvil / Colapso) */
.sidebar-toggle-btn {
  display: none;
  background: transparent;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xs);
  padding: 0.5rem;
  cursor: pointer;
  flex-direction: column;
  gap: 4px;
}

.toggle-bar {
  width: 18px;
  height: 2px;
  background: var(--gold);
  border-radius: 2px;
}

/* Breadcrumb Contextual Dinámico */
.topbar-breadcrumb {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.breadcrumb-group {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--gold);
  font-weight: 700;
  line-height: 1;
  margin-bottom: 0.2rem;
}

.breadcrumb-title {
  font-family: var(--font-serif-title);
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.breadcrumb-subtitle {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.topbar-security-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(31, 164, 114, 0.12);
  color: #34d399;
  border: 1px solid rgba(31, 164, 114, 0.3);
  padding: 0.35rem 0.8rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* ==========================================================================
   BOTONES Y ELEMENTOS DE ACCIÓN
   ========================================================================== */

.btn {
  font-family: var(--font-sans-ui);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  white-space: nowrap;
  text-decoration: none;
}

.btn-sm {
  padding: 0.42rem 0.85rem;
  font-size: 0.78rem;
}

.btn-primary {
  background: linear-gradient(135deg, var(--crimson-light) 0%, var(--crimson-dark) 100%);
  color: #fff;
  border: 1px solid rgba(239, 68, 68, 0.4);
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #cf283b 0%, var(--crimson) 100%);
  box-shadow: 0 4px 16px rgba(185, 28, 28, 0.5);
  transform: translateY(-1px);
}

.btn-glow {
  box-shadow: 0 0 16px rgba(143, 37, 49, 0.45);
}

.btn-secondary {
  background: var(--bg-surface-elevated);
  color: var(--text-main);
  border: 1px solid var(--border-medium);
}

.btn-secondary:hover {
  background: var(--bg-surface-hover);
  border-color: var(--gold-dim);
  color: #fff;
}

.btn-ai {
  border-color: rgba(197, 160, 89, 0.4);
  color: var(--gold-light);
}

.btn-ai:hover {
  background: rgba(197, 160, 89, 0.15);
  border-color: var(--gold);
}

.btn-copy {
  background: #141c2c;
  color: #93c5fd;
  border: 1px solid rgba(147, 197, 253, 0.3);
  font-size: 0.8rem;
  padding: 0.45rem 0.95rem;
}

.btn-copy:hover {
  background: #1e293b;
  color: #bfdbfe;
  border-color: #93c5fd;
}

/* ==========================================================================
   BANNER DE MÉTRICAS GLOBALES (KPIS)
   ========================================================================== */

.stats-overview-section {
  padding: 1.5rem 2rem 0.5rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 1rem;
}

.stat-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1rem 1.15rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: all var(--transition-fast);
  position: relative;
  overflow: hidden;
}

.stat-box::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: transparent;
  transition: background var(--transition-fast);
}

.stat-box:hover {
  border-color: var(--border-medium);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-box.clickable-stat {
  cursor: pointer;
}

.stat-box.clickable-stat:hover {
  border-color: var(--gold-dim);
}

.stat-box.highlight-gold {
  border-left: 3px solid var(--gold);
}

.stat-icon-wrapper {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  flex-shrink: 0;
}

.gold-tint { background: rgba(197, 160, 89, 0.12); color: var(--gold); }
.crimson-tint { background: rgba(143, 37, 49, 0.16); color: #f87171; }
.emerald-tint { background: rgba(31, 164, 114, 0.14); color: #34d399; }
.purple-tint { background: rgba(139, 92, 246, 0.14); color: #a78bfa; }
.youtube-tint { background: rgba(239, 68, 68, 0.14); color: #ef4444; }
.blue-tint { background: rgba(59, 130, 246, 0.14); color: #60a5fa; }

.stat-data {
  display: flex;
  flex-direction: column;
}

.stat-number {
  font-family: var(--font-serif-title);
  font-size: 1.6rem;
  font-weight: 700;
  color: #fff;
  line-height: 1;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 0.35rem;
  font-weight: 500;
}

/* ==========================================================================
   ÁREA DE CONTENIDO DE PESTAÑAS
   ========================================================================== */

.main-content-area {
  padding: 1.5rem 2rem 3rem;
  flex: 1;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  animation: fadeInTab 0.22s ease-out;
}

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

/* Subheadings Globales */
.subheading {
  font-family: var(--font-serif-title);
  font-size: 1.25rem;
  color: #fff;
  letter-spacing: 0.04em;
  margin-bottom: 0.5rem;
}

/* ==========================================================================
   PESTAÑA 1: BIBLIOTECA DE OBRAS
   ========================================================================== */

.section-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.search-box {
  flex: 1;
  min-width: 290px;
  position: relative;
}

.search-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.95rem;
  opacity: 0.6;
}

.search-box input {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.7rem 1rem 0.7rem 2.5rem;
  color: #fff;
  font-family: var(--font-sans-ui);
  font-size: 0.88rem;
  transition: all var(--transition-fast);
}

.search-box input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 2px var(--gold-glow);
}

.filters-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.styled-select,
.styled-select-lg {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  border-radius: var(--radius-sm);
  padding: 0.7rem 1rem;
  font-family: var(--font-sans-ui);
  font-size: 0.88rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.styled-select:focus,
.styled-select-lg:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 2px var(--gold-glow);
}

.styled-select-lg {
  font-size: 0.95rem;
  font-weight: 500;
  width: 100%;
}

/* Barra de Selección Rápida de Autores */
.authors-quick-container {
  background: rgba(20, 20, 29, 0.6);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  margin-bottom: 1.5rem;
}

.authors-quick-header {
  margin-bottom: 0.5rem;
}

.authors-quick-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 700;
  letter-spacing: 0.08em;
}

.authors-quick-scroll {
  display: flex;
  gap: 0.45rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
}

.author-chip {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 0.78rem;
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-full);
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-fast);
}

.author-chip:hover {
  background: var(--bg-surface-hover);
  color: #fff;
  border-color: var(--gold-dim);
}

.author-chip.active {
  background: var(--crimson-dark);
  color: #fff;
  border-color: var(--crimson-light);
  font-weight: 600;
  box-shadow: 0 0 10px rgba(143, 37, 49, 0.4);
}

/* Rejilla de Obras */
.obras-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: 1.35rem;
}

.obra-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.35rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
  transition: all var(--transition-normal);
  box-shadow: var(--shadow-sm);
}

.obra-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--crimson);
  transition: width var(--transition-fast);
}

.obra-card:hover {
  border-color: var(--border-medium);
  transform: translateY(-3px);
  box-shadow: var(--shadow-md), var(--shadow-gold);
}

.obra-card:hover::before {
  width: 6px;
  background: var(--gold);
}

.obra-header {
  margin-bottom: 0.6rem;
}

.obra-genero {
  font-size: 0.72rem;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 700;
  letter-spacing: 0.08em;
}

.obra-titulo-espanol {
  font-family: var(--font-serif-title);
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
  margin: 0.2rem 0;
  line-height: 1.25;
}

.obra-titulo-original {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-style: italic;
}

.obra-autor {
  font-size: 0.9rem;
  color: #d1d5db;
  font-weight: 600;
  margin-top: 0.35rem;
}

.obra-sinopsis {
  font-family: var(--font-serif-body);
  font-size: 1rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0.75rem 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.obra-meta {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  margin-bottom: 1.1rem;
}

.badge {
  font-size: 0.72rem;
  padding: 0.22rem 0.55rem;
  border-radius: var(--radius-xs);
  font-weight: 600;
  background: var(--bg-surface-elevated);
  color: #cbd5e1;
  border: 1px solid var(--border-subtle);
}

.badge-accent {
  background: rgba(143, 37, 49, 0.2);
  color: #fca5a5;
  border-color: rgba(143, 37, 49, 0.5);
}

.badge-safe {
  background: rgba(31, 164, 114, 0.15);
  color: #6ee7b7;
  border-color: rgba(31, 164, 114, 0.35);
}

.badge-gold {
  background: rgba(197, 160, 89, 0.15);
  color: var(--gold-light);
  border-color: rgba(197, 160, 89, 0.35);
}

.obra-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--border-subtle);
  padding-top: 0.85rem;
  gap: 0.5rem;
}

/* ==========================================================================
   PESTAÑA 2: TALLER EDITORIAL & DIRECCIÓN AI STUDIO
   ========================================================================== */

.taller-header-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.taller-selector-wrapper {
  flex: 1;
  min-width: 320px;
}

.taller-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 700;
  letter-spacing: 0.06em;
  display: block;
  margin-bottom: 0.4rem;
}

.taller-actions-wrapper {
  display: flex;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.text-metrics-bar {
  display: flex;
  gap: 0.85rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.metric-pill {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.6rem 1rem;
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-secondary);
}

.metric-pill strong {
  color: #fff;
  font-size: 0.92rem;
}

/* Tarjetas de Dirección Narrativa */
.narrative-direction-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}

.narrative-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.narrative-card-header {
  background: var(--bg-surface-elevated);
  padding: 0.85rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-subtle);
}

.narrative-card-header h4 {
  font-family: var(--font-serif-title);
  font-size: 0.95rem;
  color: #fff;
  letter-spacing: 0.04em;
}

.narrative-card-body {
  padding: 1.25rem;
  font-size: 0.88rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  line-height: 1.45;
}

.narrative-card-body p strong {
  color: var(--gold);
}

.rule-inviolable-box {
  background: rgba(143, 37, 49, 0.2);
  border: 1px solid rgba(143, 37, 49, 0.5);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  color: #fca5a5;
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

.rule-inviolable-box strong {
  color: #f87171;
  display: block;
  margin-bottom: 0.2rem;
}

/* Selector de Bloques */
.blocks-selector-bar {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1.25rem;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.blocks-selector-bar label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gold);
}

.blocks-info {
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* Editor Dual */
.dual-editor-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.editor-pane {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.pane-header {
  padding: 0.85rem 1.25rem;
  background: var(--bg-surface-elevated);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.pane-title {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.pane-header h3 {
  font-family: var(--font-serif-title);
  font-size: 0.95rem;
  color: #fff;
  letter-spacing: 0.03em;
}

.editor-pane textarea {
  width: 100%;
  height: 480px;
  background: var(--bg-input);
  border: none;
  padding: 1.25rem;
  color: var(--text-main);
  font-family: var(--font-serif-body);
  font-size: 1.05rem;
  line-height: 1.65;
  resize: vertical;
}

.editor-pane textarea:focus {
  outline: none;
  background: #0d0d14;
}

.pane-footer {
  padding: 0.75rem 1.25rem;
  background: var(--bg-surface-elevated);
  border-top: 1px solid var(--border-subtle);
  font-size: 0.78rem;
  color: var(--text-muted);
}

.pane-footer a {
  color: var(--gold);
  text-decoration: none;
}

.pane-footer a:hover {
  text-decoration: underline;
}

/* AI Studio Panel */
.ai-studio-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-md);
  padding: 1.35rem;
  box-shadow: var(--shadow-crimson);
}

.ai-studio-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.ai-studio-header h3 {
  font-family: var(--font-serif-title);
  font-size: 1.15rem;
  color: #fff;
  letter-spacing: 0.03em;
}

.ai-studio-header p {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.ai-studio-panel textarea {
  width: 100%;
  background: #09090d;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 1.1rem;
  color: #e2e8f0;
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 0.88rem;
  line-height: 1.5;
  resize: vertical;
}

/* ==========================================================================
   PESTAÑA 3: PIPELINE DE YOUTUBE (12 ETAPAS KANBAN)
   ========================================================================== */

.pipeline-header-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
}

.pipeline-header-card h2 {
  font-family: var(--font-serif-title);
  font-size: 1.35rem;
  color: #fff;
}

.pipeline-header-card p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.kanban-wrapper {
  overflow-x: auto;
  padding-bottom: 1.5rem;
}

.kanban-board {
  display: flex;
  gap: 1rem;
  min-width: 2400px; /* Asegura espacio fluido para las 12 etapas */
}

.kanban-column {
  flex: 0 0 250px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  max-height: 75vh;
}

.kanban-column-header {
  padding: 0.85rem 1rem;
  background: var(--bg-surface-elevated);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.kanban-col-title,
.kanban-column-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.kanban-count,
.kanban-column-count {
  font-size: 0.72rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.1);
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
  color: var(--gold-light);
}

.kanban-cards-list,
.kanban-cards-container {
  padding: 0.85rem;
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.kanban-card,
.kanban-item {
  background: var(--bg-deep);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.85rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.kanban-card:hover,
.kanban-item:hover {
  border-color: var(--gold-dim);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.kanban-card-title,
.kanban-item-title {
  font-family: var(--font-serif-title);
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 0.25rem;
  line-height: 1.25;
}

.kanban-card-author,
.kanban-item-author {
  font-size: 0.78rem;
  color: var(--gold);
  margin-bottom: 0.35rem;
}

.kanban-item-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.5rem;
  border-top: 1px solid var(--border-subtle);
  padding-top: 0.5rem;
}

/* ==========================================================================
   PESTAÑA 4: ARCHIVO DE MANUSCRITOS LOCALES (51)
   ========================================================================== */

.manuscritos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.25rem;
}

.manuscrito-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: all var(--transition-normal);
}

.manuscrito-card:hover {
  border-color: var(--border-medium);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.manuscrito-header {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  margin-bottom: 0.85rem;
}

.manuscrito-icon {
  font-size: 1.75rem;
  opacity: 0.9;
}

.manuscrito-name {
  font-family: monospace;
  font-size: 0.9rem;
  font-weight: 600;
  color: #fff;
  word-break: break-all;
}

.manuscrito-author {
  font-size: 0.8rem;
  color: var(--gold);
  margin-top: 0.2rem;
}

.manuscrito-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
}

.manuscrito-actions {
  display: flex;
  gap: 0.5rem;
}

/* ==========================================================================
   PESTAÑA 5: AUTORES & FUENTES LEGALES
   ========================================================================== */

.autores-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.autores-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 1.25rem;
}

.autor-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.35rem;
  cursor: pointer;
  transition: all var(--transition-normal);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.autor-card:hover {
  border-color: var(--gold-dim);
  transform: translateY(-3px);
  box-shadow: var(--shadow-md), var(--shadow-gold);
}

.autor-card-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.85rem;
}

.autor-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--crimson-dark) 0%, #1c1822 100%);
  border: 1px solid var(--border-gold);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif-title);
  font-size: 1.2rem;
  color: var(--gold);
  font-weight: 700;
}

.autor-nombre {
  font-family: var(--font-serif-title);
  font-size: 1.15rem;
  color: #fff;
  font-weight: 700;
}

.autor-dates {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.autor-bio-preview {
  font-family: var(--font-serif-body);
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 0.85rem;
}

/* Legal Banner */
.legal-intro-banner {
  background: rgba(20, 20, 29, 0.7);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.5rem;
  margin: 2rem 0;
}

.legal-intro-banner h3 {
  font-family: var(--font-serif-title);
  font-size: 1.1rem;
  color: #fff;
  margin-bottom: 0.4rem;
}

.legal-intro-banner p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Fuentes Grid */
.fuentes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 1.25rem;
  margin-top: 1rem;
}

.fuente-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  transition: all var(--transition-fast);
}

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

.fuente-name {
  font-family: var(--font-serif-title);
  font-size: 1.05rem;
  color: #fff;
  margin-bottom: 0.35rem;
}

.fuente-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.45;
  margin-bottom: 0.85rem;
}

/* Sub-vista B: Perfil Individual Autor */
.autor-perfil-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-md);
  padding: 2rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-gold);
}

.autor-obras-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
}

.autor-obras-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.25rem;
}

/* ==========================================================================
   MODALES Y DIÁLOGOS DE CONTROL
   ========================================================================== */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(6, 6, 9, 0.82);
  backdrop-filter: blur(12px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast);
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: scale(0.96);
  transition: transform var(--transition-fast);
}

.modal-overlay.active .modal-card {
  transform: scale(1);
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-surface-elevated);
}

.modal-header h2 {
  font-family: var(--font-serif-title);
  font-size: 1.25rem;
  color: #fff;
}

.close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.6rem;
  cursor: pointer;
  line-height: 1;
  transition: color var(--transition-fast);
}

.close-btn:hover {
  color: #fff;
}

.modal-body {
  padding: 1.5rem;
}

.form-group {
  margin-bottom: 1.15rem;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--gold);
  margin-bottom: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.9rem;
  color: #fff;
  font-family: var(--font-sans-ui);
  font-size: 0.88rem;
  transition: all var(--transition-fast);
}

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

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

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.5rem;
  border-top: 1px solid var(--border-subtle);
  padding-top: 1.25rem;
}

/* ==========================================================================
   PANTALLA DE ACCESO CON PIN DE SEGURIDAD (LOCK SCREEN)
   ========================================================================== */

.lock-screen-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: radial-gradient(circle at center, #161622 0%, #09090d 80%, #040406 100%);
  z-index: 999999;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(16px);
}

.lock-screen-card {
  background: #14141d;
  border: 1px solid #3d352e;
  box-shadow: 0 16px 60px rgba(0, 0, 0, 0.9), 0 0 40px rgba(197, 160, 89, 0.2);
  border-radius: var(--radius-lg);
  padding: 2.75rem 2.25rem;
  max-width: 440px;
  width: 90%;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.lock-icon {
  font-size: 3.2rem;
  margin-bottom: 0.6rem;
  filter: drop-shadow(0 0 16px rgba(197, 160, 89, 0.65));
}

.lock-title {
  font-family: var(--font-serif-title);
  font-size: 1.5rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
}

.lock-subtitle {
  font-size: 0.85rem;
  color: var(--gold);
  margin-bottom: 1.75rem;
}

.lock-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  display: block;
  margin-bottom: 0.6rem;
}

.pin-input-container {
  margin: 1.25rem 0;
}

.pin-input-container input {
  font-size: 2.2rem;
  text-align: center;
  letter-spacing: 0.45em;
  padding: 0.65rem;
  background: #09090d;
  border: 2px solid var(--border-medium);
  color: var(--gold-light);
  border-radius: var(--radius-sm);
  width: 100%;
  font-family: 'Consolas', monospace;
  font-weight: 700;
}

.pin-input-container input:focus {
  border-color: var(--gold);
  outline: none;
  box-shadow: 0 0 20px rgba(197, 160, 89, 0.4);
}

.pin-error-msg {
  color: #f87171;
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

.btn-lock-submit {
  width: 100%;
  padding: 0.85rem;
  font-size: 0.95rem;
}

.lock-footer {
  margin-top: 1.75rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ==========================================================================
   SISTEMA DE NOTIFICACIONES TOAST
   ========================================================================== */

.toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  pointer-events: none;
}

.toast-message {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1.25rem;
  color: #fff;
  font-size: 0.85rem;
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  animation: toastSlideIn 0.25s ease-out;
}

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

.toast-message.toast-success {
  border-left: 4px solid var(--emerald);
}

.toast-message.toast-error {
  border-left: 4px solid var(--crimson-light);
}

.toast-message.toast-info {
  border-left: 4px solid var(--gold);
}

/* ==========================================================================
   LISTAS DE VERSIONES Y RESPALDOS (MODALES)
   ========================================================================== */

.versiones-history-list,
.respaldos-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  max-height: 320px;
  overflow-y: auto;
  margin-top: 0.5rem;
}

.version-item,
.respaldo-item {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1.15rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all var(--transition-fast);
}

.version-item:hover,
.respaldo-item:hover {
  border-color: var(--gold-dim);
  background: var(--bg-surface-hover);
  transform: translateX(2px);
}

.version-info,
.respaldo-info {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.version-badge {
  font-family: var(--font-serif-title);
  font-size: 0.95rem;
  color: var(--gold-light);
  font-weight: 700;
}

.version-meta,
.respaldo-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.respaldo-name {
  font-family: monospace;
  font-size: 0.88rem;
  font-weight: 600;
  color: #fff;
}

/* ==========================================================================
   ADAPTABILIDAD RESPONSIVA (TABLETS Y MÓVILES)
   ========================================================================== */

@media (max-width: 1024px) {
  .app-sidebar {
    transform: translateX(-100%);
  }

  body.sidebar-open .app-sidebar {
    transform: translateX(0);
  }

  .app-main-viewport {
    margin-left: 0;
  }

  .sidebar-toggle-btn {
    display: flex;
  }

  .dual-editor-container {
    grid-template-columns: 1fr;
  }

  .editor-pane textarea {
    height: 360px;
  }
}

@media (max-width: 768px) {
  .app-topbar {
    padding: 0 1rem;
  }

  .breadcrumb-subtitle {
    display: none;
  }

  .topbar-security-pill {
    display: none;
  }

  .stats-overview-section,
  .main-content-area {
    padding: 1rem;
  }

  .obras-grid,
  .manuscritos-grid,
  .autores-cards-grid {
    grid-template-columns: 1fr;
  }
}
