/* ==========================================================================
   ESTUDIO DE GRADO - SISTEMA DE DISEÑO BASE
   Paleta: Obsidian & Gold (Derecho / Estudio de Alto Rendimiento)
   ========================================================================== */

:root {
  color-scheme: dark;

  /* Tipografías: Serif Jurídica Diploma (Playfair Display) + Lectura Prolongada (Plus Jakarta Sans) */
  --font-serif: 'Playfair Display', Georgia, serif;
  --font-display: 'Playfair Display', 'Cinzel', Georgia, serif;
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Tema Oscuro (Obsidian & Law Gold) por defecto */
  --bg-app: #0c0e14;
  --bg-surface: #141721;
  --bg-surface-elevated: #1a1f2c;
  --bg-surface-hover: #22293a;
  --border-subtle: #262d40;
  --border-focus: #c29b38;

  /* Textos */
  --text-main: #edf2f7;
  --text-muted: #94a3b8;
  --text-subtle: #64748b;
  --text-inverse: #0f172a;

  /* Acentos de Especialidad Jurídica */
  --gold-primary: #d4af37;
  --gold-hover: #e6c35c;
  --gold-glow: rgba(212, 175, 55, 0.18);
  --gold-border: rgba(212, 175, 55, 0.35);

  --civil-color: #38bdf8;
  --civil-bg: rgba(56, 189, 248, 0.12);
  --civil-border: rgba(56, 189, 248, 0.28);

  --procesal-color: #a855f7;
  --procesal-bg: rgba(168, 85, 247, 0.12);
  --procesal-border: rgba(168, 85, 247, 0.28);

  --constitucional-color: #f59e0b;
  --constitucional-bg: rgba(245, 158, 11, 0.12);
  --constitucional-border: rgba(245, 158, 11, 0.28);

  /* Feedback */
  --success: #10b981;
  --success-text: #34d399;
  --success-bg: rgba(16, 185, 129, 0.12);
  --success-border: rgba(16, 185, 129, 0.35);

  --danger: #ef4444;
  --danger-text: #f87171;
  --danger-bg: rgba(239, 68, 68, 0.12);
  --danger-border: rgba(239, 68, 68, 0.35);

  --warning-text: #fbbf24;
  --warning-bg: rgba(251, 191, 36, 0.12);
  --warning-border: rgba(251, 191, 36, 0.35);

  --info: #0ea5e9;
  --info-text: #38bdf8;
  --info-bg: rgba(56, 189, 248, 0.12);
  --info-border: rgba(56, 189, 248, 0.35);

  /* Sombras y Efectos */
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.5);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);

  /* Escala Tipográfica Fluida y Proporcional */
  --font-h1: clamp(1.2rem, 2.2vw, 1.62rem);
  --font-h2: clamp(1.08rem, 1.8vw, 1.32rem);
  --font-h3: clamp(0.98rem, 1.4vw, 1.15rem);
  --font-h4: clamp(0.9rem, 1.1vw, 1.02rem);

  /* Escala Canónica de Interlineado Unificada (PROMPT 029 / v7.36) */
  --lh-title: 1.28;   /* Encabezados principales h1, h2 y título de cédula */
  --lh-heading: 1.35; /* Subtítulos h3, h4, h5, h6 y títulos de tarjetas */
  --lh-body: 1.70;    /* Párrafos, listas y citas doctrinales */
  --lh-table: 1.60;   /* Tablas comparativas y celdas th/td */
  --lh-dense: 1.50;   /* Elementos densos, metadatos, migas de pan y callouts */

  /* Escala Canónica de Espaciado 8pt (PROMPT 030 / v7.37) */
  --space-1: 4px;     /* 0.25rem - Micro espaciado entre iconos y etiquetas */
  --space-2: 8px;     /* 0.5rem  - Espaciado compacto para chips, badges y pills */
  --space-3: 12px;    /* 0.75rem - Relleno interior de controles y botones */
  --space-4: 16px;    /* 1rem    - Espaciado base estándar entre bloques */
  --space-5: 24px;    /* 1.5rem  - Separación entre secciones medianas */
  --space-6: 32px;    /* 2rem    - Márgenes de tarjetas y contenedores */
  --space-7: 48px;    /* 3rem    - Separación estructural mayor */
  --space-8: 64px;    /* 4rem    - Márgenes amplios de cabecera/pie */

  /* Escala Canónica de Z-Index Unificada (header < dropdown < modal < toast) */
  --z-base: 1;
  --z-surface: 10;
  --z-sidebar: 40;
  --z-header: 50;
  --z-dropdown: 100;
  --z-overlay: 200;
  --z-sidebar-mobile: 250;
  --z-modal: 500;
  --z-toast: 1000;
}

/* ==========================================================================
   CÓDIGO MUERTO (Conservado únicamente como referencia histórica WCAG AA de v5.0):
   El Modo Claro ha sido eliminado definitivamente de la plataforma en v7.2.
   Dark Academy (Obsidian & Law Gold) es el único tema activo, permanente e inmutable.
   ========================================================================== */
/*
[data-theme="light"] {
  color-scheme: light;

  --bg-app: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #f1f5f9;
  --bg-surface-hover: #e2e8f0;
  --border-subtle: #cbd5e1;
  --border-focus: #92400e;

  --text-main: #0f172a;
  --text-secondary: #334155;
  --text-muted: #475569;
  --text-subtle: #64748b;
  --text-inverse: #ffffff;

  --gold-primary: #92400e;
  --gold-hover: #78350f;
  --gold-glow: rgba(146, 64, 14, 0.15);
  --gold-border: rgba(146, 64, 14, 0.35);

  --civil-color: #0369a1;
  --civil-bg: rgba(3, 105, 161, 0.08);
  --civil-border: rgba(3, 105, 161, 0.28);

  --procesal-color: #6b21a8;
  --procesal-bg: rgba(107, 33, 168, 0.08);
  --procesal-border: rgba(107, 33, 168, 0.28);

  --constitucional-color: #b45309;
  --constitucional-bg: rgba(180, 83, 9, 0.08);
  --constitucional-border: rgba(180, 83, 9, 0.28);

  --success: #047857;
  --success-text: #047857;
  --success-bg: rgba(4, 120, 87, 0.09);
  --success-border: rgba(4, 120, 87, 0.28);

  --danger: #b91c1c;
  --danger-text: #b91c1c;
  --danger-bg: rgba(185, 28, 28, 0.09);
  --danger-border: rgba(185, 28, 28, 0.28);

  --warning-text: #92400e;
  --warning-bg: rgba(146, 64, 14, 0.09);
  --warning-border: rgba(146, 64, 14, 0.28);

  --info: #0284c7;
  --info-text: #0284c7;
  --info-bg: rgba(2, 132, 199, 0.09);
  --info-border: rgba(2, 132, 199, 0.28);

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 10px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 20px rgba(0, 0, 0, 0.12);
}
*/

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

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  color: var(--text-main);
  line-height: 1.28;
  font-weight: 700;
  letter-spacing: 0.02em;
}

h1 { font-size: var(--font-h1); }
h2 { font-size: var(--font-h2); }
h3 { font-size: var(--font-h3); }
h4 { font-size: var(--font-h4); }

body {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.6;
  height: 100vh;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* Layout Principal */
.app-layout {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-height: 100dvh;
  width: 100%;
  max-width: 100vw;
  overflow: hidden;
}

/* ==========================================================================
   HEADER SUPERIOR
   ========================================================================== */
.app-header {
  height: 56px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  gap: 12px;
  z-index: var(--z-header);
  box-shadow: var(--shadow-sm);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0 !important;
  white-space: nowrap !important;
}

.brand-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  user-select: none;
  flex-shrink: 0 !important;
  white-space: nowrap !important;
}

.brand-icon-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: var(--radius-sm);
  background: rgba(212, 175, 55, 0.12);
  border: 1px solid rgba(212, 175, 55, 0.28);
  color: var(--gold-primary);
  flex-shrink: 0 !important;
  box-shadow: 0 0 8px rgba(212, 175, 55, 0.15);
  transition: var(--transition-fast);
}

.brand-icon-wrap i,
.brand-icon-wrap svg {
  width: 14px;
  height: 14px;
  stroke-width: 2.2;
}

.brand-text-block {
  display: flex;
  flex-direction: column;
  justify-content: center;
  flex-shrink: 0 !important;
  white-space: nowrap !important;
  line-height: 1.15;
  gap: 1px;
}

.brand-title {
  font-family: var(--font-serif);
  font-size: 0.84rem !important;
  font-weight: 800;
  letter-spacing: 0.07em;
  color: var(--gold-primary);
  line-height: 1.15;
  white-space: nowrap !important;
  word-break: keep-all !important;
  margin: 0;
  padding: 0;
  text-shadow: 0 0 10px rgba(212, 175, 55, 0.22);
}

.brand-subtitle {
  font-family: var(--font-sans);
  font-size: 0.52rem !important;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.03em;
  white-space: nowrap !important;
  word-break: keep-all !important;
  line-height: 1.15;
  margin: 0;
  padding: 0;
}

/* Pestañas de Navegación de la Cabecera (Compactas) */
.header-nav {
  display: flex;
  align-items: center;
  gap: 3px;
  background: var(--bg-surface-elevated);
  padding: 3px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.nav-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
  white-space: nowrap;
}

.nav-tab i {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.nav-tab:hover {
  color: var(--text-main);
  background: var(--bg-surface-hover);
}

.nav-tab.active {
  color: var(--gold-primary);
  background: var(--bg-surface);
  box-shadow: var(--shadow-sm);
}

.badge-count {
  background: var(--gold-primary);
  color: var(--text-inverse);
  font-size: 0.68rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: var(--radius-full);
  min-width: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  text-align: center;
}

/* Barra de Búsqueda y Acciones de Cabecera */
.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-shrink: 0 !important;
}

.search-bar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 5px;
}

.search-mode-selector {
  display: inline-flex;
  align-items: center;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 2px;
  flex-shrink: 0;
}

.search-mode-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  height: 24px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 500;
  border-radius: 3px;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.search-mode-pill i {
  width: 12px;
  height: 12px;
}

.search-mode-pill:hover {
  color: var(--text-main);
  background: var(--bg-surface-hover);
}

/* Modo Semántico Activo (Azul info) */
.search-mode-pill[data-mode="semantic"].active {
  background: rgba(2, 132, 199, 0.15);
  color: var(--info-text, #0284c7);
  border-color: rgba(2, 132, 199, 0.35);
  font-weight: 600;
}

/* Modo Q&A Activo (Dorado) */
.search-mode-pill[data-mode="qa"].active {
  background: var(--gold-glow, rgba(212, 175, 55, 0.15));
  color: var(--gold-primary, #d4af37);
  border-color: rgba(212, 175, 55, 0.35);
  font-weight: 600;
}

.search-input-wrapper {
  position: relative;
  width: 110px;
  transition: width var(--transition-fast);
}

.search-bar:focus-within .search-input-wrapper {
  width: 170px;
}

.search-input-wrapper input {
  width: 100%;
  height: 28px;
  padding: 4px 6px 4px 24px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 0.74rem;
  transition: var(--transition-fast);
}

.search-input-wrapper .search-icon {
  position: absolute;
  left: 7px;
  top: 50%;
  transform: translateY(-50%);
  width: 13px;
  height: 13px;
  color: var(--text-subtle);
  pointer-events: none;
  transition: color var(--transition-fast);
}

/* Foco e Identidad Visual por Modo */
.search-bar[data-mode="semantic"] input:focus,
.search-bar.mode-semantic input:focus {
  outline: none;
  border-color: var(--info-text, #0284c7);
  box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.25);
}

.search-bar[data-mode="semantic"] .search-icon,
.search-bar.mode-semantic .search-icon {
  color: var(--info-text, #0284c7);
}

.search-bar[data-mode="semantic"] .search-dropdown,
.search-bar.mode-semantic .search-dropdown {
  border-top: 2px solid var(--info-text, #0284c7);
}

.search-bar[data-mode="qa"] input:focus,
.search-bar.mode-qa input:focus {
  outline: none;
  border-color: var(--gold-primary, #d4af37);
  box-shadow: 0 0 0 2px var(--gold-glow, rgba(212, 175, 55, 0.25));
}

.search-bar[data-mode="qa"] .search-icon,
.search-bar.mode-qa .search-icon {
  color: var(--gold-primary, #d4af37);
}

.search-bar[data-mode="qa"] .search-dropdown,
.search-bar.mode-qa .search-dropdown {
  border-top: 2px solid var(--gold-primary, #d4af37);
}

.search-clear-btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  line-height: 1;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast), background var(--transition-fast);
  z-index: 2;
}

.search-clear-btn:hover {
  color: var(--text-main);
  background: var(--bg-surface-hover);
}

.search-clear-btn.hidden {
  display: none !important;
}

.shortcut-key {
  display: inline-block;
  font-size: 0.62rem;
  padding: 1px 4px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 3px;
  color: var(--text-muted);
  pointer-events: none;
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
}

.search-input-wrapper:focus-within .shortcut-key {
  display: none !important;
}

.live-sync-indicator .live-text {
  display: none !important;
}

.search-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 480px;
  max-width: calc(100vw - 24px);
  max-height: 480px;
  overflow-y: auto;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: var(--z-dropdown);
  padding: 10px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-subtle) transparent;
}

.search-dropdown.hidden {
  display: none;
}

.global-mode-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.global-mode-section.hidden {
  display: none !important;
}

/* --- Filtros del Vault en Dropdown (Semántico) --- */
.vault-search-filters {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-subtle);
}

.vault-filter-pills {
  display: flex;
  gap: 4px;
}

.vault-filter-pill {
  flex: 1;
  padding: 4px 6px;
  font-size: 0.7rem;
  font-weight: 600;
  text-align: center;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.vault-filter-pill:hover {
  color: var(--text-main);
  border-color: var(--border-medium);
  background: var(--bg-surface-hover);
}

.vault-filter-pill.active {
  color: var(--info-text, #0284c7);
  background: rgba(2, 132, 199, 0.15);
  border-color: var(--info-text, #0284c7);
}

.vault-filter-chapter-wrapper {
  width: 100%;
}

.vault-filter-chapter {
  width: 100%;
  padding: 5px 8px;
  font-size: 0.72rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition-fast);
}

.vault-filter-chapter:focus {
  border-color: var(--info-text, #0284c7);
}

/* --- Historial de Búsquedas en Dropdown (Semántico) --- */
.vault-search-history {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 8px 10px;
  margin-bottom: 6px;
}

.vault-search-history.hidden {
  display: none !important;
}

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

.vault-history-title {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

.vault-history-icon {
  width: 12px;
  height: 12px;
  color: var(--info-text, #0284c7);
}

.vault-history-clear-btn {
  background: transparent;
  border: none;
  font-size: 0.68rem;
  color: var(--info-text, #0284c7);
  cursor: pointer;
  padding: 0 4px;
  border-radius: var(--radius-sm);
  transition: opacity var(--transition-fast);
}

.vault-history-clear-btn:hover {
  opacity: 0.8;
  text-decoration: underline;
}

.vault-history-items {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.vault-history-chip {
  font-size: 0.7rem;
  padding: 3px 8px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.vault-history-chip:hover {
  color: var(--info-text, #0284c7);
  border-color: var(--info-text, #0284c7);
  background: rgba(2, 132, 199, 0.08);
}

/* --- Sub-modos Q&A en Dropdown --- */
.qa-mode-pills-wrapper {
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-subtle);
}

.qa-mode-pills {
  display: flex;
  gap: 4px;
}

.qa-mode-pill {
  flex: 1;
  padding: 4px 6px;
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  cursor: pointer;
  text-align: center;
  transition: all var(--transition-fast);
}

.qa-mode-pill:hover {
  color: var(--text-main);
  border-color: var(--border-medium);
}

.qa-mode-pill.active {
  background: var(--gold-primary, #d4af37);
  color: #121212;
  font-weight: 600;
  border-color: var(--gold-primary, #d4af37);
}

/* --- Respuesta Q&A y Tarjetas de Cita --- */
.qa-answer {
  max-height: 380px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-subtle) transparent;
}

.qa-answer.hidden {
  display: none !important;
}

.qa-answer-container {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 9px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.qa-answer-header {
  display: flex;
  align-items: center;
  gap: 5px;
}

.qa-answer-tag {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--gold-primary, #d4af37);
  letter-spacing: 0.4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.qa-answer-tag i {
  width: 12px;
  height: 12px;
}

.qa-answer-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.qa-citation-card {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px;
  transition: border-color var(--transition-fast);
}

.qa-citation-card:hover {
  border-color: var(--gold-primary, #d4af37);
}

.qa-block-perspective-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  margin-bottom: 5px;
}

.qa-citation-header {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 4px;
}

.qa-citation-meta {
  display: flex;
  align-items: baseline;
  gap: 5px;
}

.qa-citation-code {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--gold-primary, #d4af37);
  background: rgba(217, 119, 6, 0.12);
  padding: 1px 4px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

.qa-citation-title {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.25;
}

.qa-citation-source {
  font-size: 0.66rem;
  color: var(--text-muted);
}

.qa-citation-snippet {
  font-size: 0.72rem;
  line-height: 1.4;
  color: var(--text-secondary);
  border-left: 2px solid var(--gold-primary, #d4af37);
  padding-left: 7px;
  margin: 5px 0;
  word-break: break-word;
}

.qa-quote-glyph {
  color: var(--gold-primary, #d4af37);
  font-weight: 700;
}

.qa-citation-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 4px;
}

.qa-action-jump-btn {
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--gold-primary, #d4af37);
  font-size: 0.68rem;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all var(--transition-fast);
}

.qa-action-jump-btn:hover {
  background: rgba(217, 119, 6, 0.12);
  border-color: var(--gold-primary, #d4af37);
}

.qa-action-jump-btn i {
  width: 11px;
  height: 11px;
}

.qa-answer-footer {
  border-top: 1px solid var(--border-subtle);
  padding-top: 6px;
  margin-top: 2px;
}

.qa-answer-disclaimer {
  font-size: 0.64rem;
  color: var(--text-muted);
  line-height: 1.3;
  display: flex;
  align-items: flex-start;
  gap: 4px;
}

.qa-answer-disclaimer i {
  width: 11px;
  height: 11px;
  flex-shrink: 0;
  margin-top: 1px;
}

.qa-uncovered-box {
  padding: 10px;
  background: rgba(239, 68, 68, 0.05);
  border: 1px dashed rgba(239, 68, 68, 0.35);
  border-radius: var(--radius-md);
  text-align: left;
}

.qa-uncovered-title {
  font-size: 0.77rem;
  font-weight: 700;
  color: #f87171;
  margin-bottom: 4px;
}

.qa-uncovered-desc {
  font-size: 0.71rem;
  color: var(--text-secondary);
  line-height: 1.35;
  margin-bottom: 6px;
}

.qa-uncovered-suggestion {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.7rem;
  margin-bottom: 4px;
  flex-wrap: wrap;
}

.qa-suggestion-label {
  color: var(--text-muted);
}

.qa-suggestion-pill {
  background: rgba(217, 119, 6, 0.15);
  color: var(--gold-primary, #d4af37);
  padding: 1px 6px;
  border-radius: var(--radius-full);
  font-weight: 600;
  font-size: 0.68rem;
}

.qa-uncovered-hint {
  font-size: 0.66rem;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 4px;
}

/* --- Panel de Huecos (Uncovered Queries) en Dropdown --- */
.qa-gaps-panel {
  padding: 8px 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  margin-top: 6px;
}

.qa-gaps-panel.hidden {
  display: none !important;
}

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

.qa-gaps-title {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

.qa-gaps-icon {
  width: 12px;
  height: 12px;
  color: var(--gold-primary, #d4af37);
}

.qa-gaps-clear-btn {
  background: none;
  border: none;
  font-size: 0.68rem;
  color: var(--gold-primary, #d4af37);
  cursor: pointer;
  padding: 0 4px;
}

.qa-gaps-clear-btn:hover {
  text-decoration: underline;
  opacity: 0.85;
}

.qa-gaps-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-height: 120px;
  overflow-y: auto;
}

.qa-gap-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.68rem;
  padding: 2px 7px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.qa-gap-chip:hover {
  color: var(--gold-primary, #d4af37);
  border-color: var(--gold-primary, #d4af37);
  background: rgba(217, 119, 6, 0.08);
}

.qa-gap-badge {
  font-size: 0.61rem;
  color: var(--gold-primary, #d4af37);
  opacity: 0.8;
}

.qa-gap-count {
  font-size: 0.61rem;
  font-weight: 700;
  color: var(--gold-primary, #d4af37);
}

/* --- Resultados y Badges Semánticos en Dropdown --- */
.vault-search-results {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.vault-search-results.hidden {
  display: none !important;
}

.search-dropdown-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px 6px 6px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 6px;
}

.search-mode-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.search-mode-badge.mode-semantic {
  background: rgba(2, 132, 199, 0.15);
  color: var(--info-text, #0284c7);
  border: 1px solid rgba(2, 132, 199, 0.3);
}

.search-mode-badge.mode-qa {
  background: var(--gold-glow, rgba(212, 175, 55, 0.15));
  color: var(--gold-primary, #d4af37);
  border: 1px solid rgba(212, 175, 55, 0.3);
}

.search-mode-badge i {
  width: 11px;
  height: 11px;
}

.search-result-item {
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: var(--transition-fast);
  border: 1px solid transparent;
  background: var(--bg-surface);
  content-visibility: auto;
  contain-intrinsic-size: 0 80px;
}

.search-skeleton-preview {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mastery-pulse {
  transform: scale(0.96);
  transition: transform 120ms ease;
}

.vault-highlight-pulse {
  animation: highlightGlow 0.4s ease-out;
}

@keyframes highlightGlow {
  0% { transform: scale(1); }
  50% { transform: scale(1.04); }
  100% { transform: scale(1); }
}


.search-result-item:hover,
.search-result-item:focus {
  background: var(--bg-surface-hover);
  border-color: var(--border-subtle);
  outline: none;
}

.search-result-header-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.search-result-title {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-main);
}

.vault-result-code {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--info-text, #0284c7);
  background: rgba(2, 132, 199, 0.12);
  padding: 1px 5px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

.search-result-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.search-result-snippet {
  font-size: 0.74rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin-top: 4px;
}

.search-result-snippet mark,
.search-result-snippet .vault-highlight,
.vault-highlight {
  background: rgba(2, 132, 199, 0.22);
  color: var(--text-main);
  padding: 0 2px;
  border-radius: 2px;
}

.search-qa-wrapper {
  padding: 4px 2px;
}

.search-empty-state {
  padding: 14px;
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: center;
}

/* Indicador de Sincronización en Tiempo Real */
.live-sync-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  padding: 5px 10px;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  user-select: none;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: var(--radius-full);
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
  animation: pulseLive 2s infinite ease-in-out;
}

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

.live-sync-indicator.syncing .live-dot {
  background: var(--gold-primary);
  box-shadow: 0 0 8px var(--gold-primary);
}

/* ==========================================================================
   BOTONES E ÍCONOS
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: var(--transition-fast);
  white-space: nowrap;
}

.btn i {
  width: 16px;
  height: 16px;
}

.btn-primary {
  background: var(--gold-primary);
  color: #0f172a;
  border-color: var(--gold-primary);
  box-shadow: 0 2px 8px var(--gold-glow);
}

.btn-primary:hover {
  background: var(--gold-hover);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-surface-elevated);
  color: var(--text-main);
  border-color: var(--border-subtle);
}

.btn-secondary:hover {
  background: var(--bg-surface-hover);
  border-color: var(--border-focus);
}

.btn-outline {
  background: transparent;
  color: var(--text-main);
  border-color: var(--border-subtle);
}

.btn-outline:hover {
  background: var(--bg-surface-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: transparent;
}

.btn-ghost:hover {
  background: var(--bg-surface-hover);
  color: var(--text-main);
}

.btn-danger-outline {
  background: transparent;
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.4);
}

.btn-danger-outline:hover {
  background: var(--danger-bg);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.78rem;
}

.icon-btn {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition-fast);
}

.icon-btn:hover {
  background: var(--bg-surface-hover);
  color: var(--text-main);
  border-color: var(--border-subtle);
}

/* Toggle tema eliminado en v7.2 (Dark Academy es el único tema activo e inmutable) */

/* ==========================================================================
   CUERPO PRINCIPAL
   ========================================================================== */
.app-body {
  display: flex;
  flex: 1;
  min-height: 0;
  height: auto;
  overflow: hidden;
  position: relative;
}

.main-content {
  flex: 1;
  height: 100%;
  overflow-y: auto;
  background: var(--bg-app);
  position: relative;
}

.view-section {
  display: none;
  height: 100%;
}

.view-section.active {
  display: flex;
  flex-direction: column;
  animation: viewFadeIn 180ms ease-out;
}

@keyframes viewFadeIn {
  from {
    opacity: 0.45;
  }
  to {
    opacity: 1;
  }
}


/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: var(--z-toast);
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  min-width: 280px;
  max-width: 420px;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.85rem;
  color: var(--text-main);
  animation: slideInRight 0.25s ease-out;
}

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

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

.toast-error {
  border-color: var(--danger);
  border-left: 4px solid var(--danger);
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Utilidades generales */
.hidden {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* ==========================================================================
   RESPONSIVO MÓVIL Y TABLET (SAFARI iOS / IPHONE / ANDROID)
   ========================================================================== */

/* Backdrops globales para modales y paneles laterales en móvil */
.sidebar-backdrop, .aside-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: var(--z-overlay, 200);
  transition: opacity 0.2s ease;
}

.sidebar-backdrop.hidden, .aside-backdrop.hidden {
  display: none !important;
  opacity: 0;
  pointer-events: none;
}

/* ==========================================================================
   RESPONSIVO: NOTEBOOKS Y PANTALLAS DE RESOLUCIÓN COMPACTA (769px a 1366px)
   ========================================================================== */
@media (min-width: 769px) and (max-width: 1366px) {
  .app-header {
    height: 54px;
    padding: 0 12px;
    gap: 8px;
  }

  .header-brand {
    gap: 6px;
    flex-shrink: 0 !important;
  }

  .brand-badge {
    gap: 6px;
    flex-shrink: 0 !important;
  }

  .brand-icon-wrap {
    width: 22px;
    height: 22px;
  }

  .brand-icon-wrap i,
  .brand-icon-wrap svg {
    width: 13px;
    height: 13px;
  }

  .brand-title {
    font-size: 0.72rem !important;
    letter-spacing: 0.04em;
    white-space: nowrap !important;
  }

  .brand-subtitle {
    font-size: 0.50rem !important;
    letter-spacing: 0.02em;
    white-space: nowrap !important;
  }

  .nav-tab {
    padding: 5px 9px;
    font-size: 0.76rem;
    gap: 5px;
  }

  .nav-tab i {
    width: 14px;
    height: 14px;
  }

  .header-actions {
    gap: 5px;
    flex-shrink: 0 !important;
  }

  .search-bar {
    width: auto;
  }

  .search-input-wrapper {
    width: 95px;
  }

  .search-bar:focus-within .search-input-wrapper {
    width: 145px;
  }

  .search-input-wrapper input {
    height: 28px;
    padding: 4px 6px 4px 22px;
    font-size: 0.73rem;
  }

  .search-icon {
    left: 6px;
    width: 12px;
    height: 12px;
  }

  .shortcut-key {
    display: none !important;
  }

  .live-sync-indicator .live-text {
    display: none !important;
  }
}

/* Pantallas intermedias / notebooks pequeños (hasta 1120px) */
@media (min-width: 769px) and (max-width: 1120px) {
  .shortcut-key {
    display: none;
  }

  .search-bar {
    width: auto;
  }

  .search-input-wrapper {
    width: 85px;
  }

  .search-bar:focus-within .search-input-wrapper {
    width: 135px;
  }
}

/* Tablets en horizontal / ventanas estrechas (hasta 880px) */
@media (min-width: 769px) and (max-width: 880px) {
  .nav-tab-label {
    display: none;
  }

  .nav-tab {
    padding: 6px 8px;
  }

  .search-bar {
    width: auto;
  }

  .search-mode-label {
    display: none;
  }

  .search-input-wrapper {
    width: 75px;
  }
}

/* ==========================================================================
   RESPONSIVO MÓVIL Y TABLET (HASTA 768px)
   ========================================================================== */
@media (max-width: 768px) {
  .app-header {
    height: auto;
    min-height: 52px;
    padding: 8px 12px;
    padding-top: max(8px, env(safe-area-inset-top));
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  }

  .header-brand {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 0 0 auto;
    min-width: 0;
  }

  .header-brand .icon-btn {
    min-width: 44px;
    min-height: 44px;
  }

  /* Logotipo móvil solo-ícono: ocultar textos de marca para prevenir superposición */
  .brand-title,
  .brand-subtitle,
  .brand-text-block {
    display: none !important;
  }

  .brand-badge {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0;
  }

  .brand-icon-wrap {
    width: 30px;
    height: 30px;
  }

  .brand-icon-wrap i,
  .brand-icon-wrap svg {
    width: 16px;
    height: 16px;
  }

  .header-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    margin-left: auto;
    flex: 1 1 auto;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
  }

  .header-actions > *:not(.search-bar) {
    order: 1;
  }

  .header-actions .icon-btn {
    min-width: 44px;
    min-height: 44px;
  }

  /* Chip de usuario en móvil: ocultar texto y mostrar únicamente avatar y logout */
  .user-profile-name {
    display: none !important;
  }

  .user-profile-pill {
    padding: 2px 4px 2px 6px;
    gap: 4px;
    min-height: 44px;
    align-items: center;
  }

  .user-avatar-placeholder,
  .user-avatar-img {
    width: 26px;
    height: 26px;
  }

  .btn-user-logout {
    min-width: 44px; /* WCAG touch target v7.65 (supera min-width: 36px) */
    min-height: 44px;
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .search-bar {
    display: flex;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    order: 4;
    margin-top: 4px;
    box-sizing: border-box;
    position: relative;
  }

  .search-mode-selector {
    display: flex;
    gap: 3px;
  }

  .search-mode-pill {
    min-width: 44px;
    min-height: 44px;
    padding: 0 10px;
    display: inline-flex;
    justify-content: center;
    align-items: center;
  }

  .search-mode-label {
    display: none !important; /* Cero texto nuevo en móvil (solo iconos) */
  }

  .search-input-wrapper {
    flex: 1;
    min-width: 0;
    width: auto !important;
  }

  .search-bar:focus-within .search-input-wrapper {
    width: auto !important;
  }

  .search-input-wrapper input {
    width: 100%;
    min-width: 0;
    height: 44px;
    min-height: 44px;
    font-size: 0.82rem;
    padding: 8px 44px 8px 28px;
    box-sizing: border-box;
  }

  .search-icon {
    left: 8px;
    width: 14px;
    height: 14px;
  }

  .search-clear-btn {
    right: 2px;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .shortcut-key {
    display: none !important;
  }

  .search-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    width: 100%;
    max-width: 100%;
    max-height: calc(100vh - 180px);
    z-index: var(--z-dropdown);
    box-sizing: border-box;
    overflow-x: hidden;
  }

  .vault-filter-pill,
  .qa-mode-pill {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
  }

  .vault-filter-chapter {
    min-height: 44px;
    font-size: 0.8rem;
  }

  .vault-history-chip,
  .qa-gap-chip {
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
  }

  .qa-action-jump-btn {
    min-height: 38px;
    padding: 6px 12px;
    font-size: 0.74rem;
  }

  .live-sync-indicator {
    display: none; /* Ahorro de espacio en pantallas pequeñas */
  }

  .header-nav {
    order: 3;
    width: 100%;
    display: flex;
    gap: 3px;
    padding: 3px;
    background: var(--bg-surface-elevated);
    border-radius: var(--radius-sm);
    margin-top: 2px;
  }

  .nav-tab {
    flex: 1;
    min-height: 44px;
    padding: 6px 4px;
    font-size: 0.74rem;
    justify-content: center;
    gap: 4px;
    text-align: center;
  }

  .nav-tab i {
    width: 14px;
    height: 14px;
  }

  .nav-tab span {
    white-space: nowrap;
  }

  .badge-count {
    font-size: 0.6rem;
    padding: 0 4px;
    min-width: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
  }

  .app-body {
    flex: 1;
    min-height: 0;
    height: auto;
    max-height: none;
    overflow: hidden;
  }

  .main-content {
    overflow-x: hidden;
  }

  .toast-container {
    left: 12px;
    right: 12px;
    bottom: calc(16px + env(safe-area-inset-bottom));
  }

  .toast {
    min-width: 0;
    width: 100%;
    max-width: 100%;
    font-size: 0.8rem;
    padding: 10px 14px;
  }
}

/* Teléfonos muy compactos (< 480px) */
@media (max-width: 480px) {
  .app-header {
    padding: 6px 8px;
    padding-top: max(6px, env(safe-area-inset-top));
    gap: 6px;
  }



  .nav-tab {
    font-size: 0.7rem;
    padding: 5px 2px;
  }

  .nav-tab i {
    width: 13px;
    height: 13px;
  }
}

/* ==========================================================================
   ESTILOS DE PERFIL DE USUARIO Y AUTENTICACIÓN GOOGLE (AuthService)
   ========================================================================== */
.auth-user-container {
  display: flex;
  align-items: center;
}

.user-profile-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  padding: 3px 8px 3px 4px;
  font-size: 0.8rem;
  color: var(--text-main);
  transition: border-color 0.2s, background-color 0.2s;
}

.user-profile-pill:hover {
  border-color: var(--gold-primary);
}

.user-avatar-img {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--gold-primary);
}

.user-avatar-placeholder {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(212, 160, 23, 0.15);
  color: var(--gold-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
}

.user-profile-name {
  font-weight: 500;
  max-width: 130px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-user-logout {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 50%;
  transition: color 0.15s, background-color 0.15s;
}

.btn-user-logout:hover {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.1);
}

.google-btn-wrapper {
  display: flex;
  align-items: center;
}

.auth-login-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: var(--radius-full);
  border: 1px solid var(--gold-primary);
  color: var(--gold-primary);
  background: transparent;
  cursor: pointer;
  transition: all 0.2s ease;
}

.auth-login-btn:hover {
  background: var(--gold-primary);
  color: #0c0e14;
}

/* Utilidad Universal Ocultar */
.hidden {
  display: none !important;
}

/* ==========================================================================
   DESARROLLADOR DE PREGUNTAS DEL AGENTE — VERIFICACIÓN DE CÉDULA (v7.11)
   ========================================================================== */

#section-quiz-developer {
  margin-top: 48px;
  margin-bottom: 32px;
  padding: 28px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}

.quiz-dev-header {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-subtle);
}

@media (min-width: 768px) {
  .quiz-dev-header {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

.quiz-dev-title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.quiz-dev-main-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 0;
  letter-spacing: -0.01em;
}

#quiz-nature-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.quiz-admin-lab-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(217, 119, 6, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.35);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.quiz-progress-box {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 180px;
}

.quiz-progress-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

.quiz-progress-bar {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-full);
  overflow: hidden;
}

#quiz-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #10b981);
  border-radius: var(--radius-full);
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  width: 0%;
}

#quiz-completed-banner {
  margin-bottom: 24px;
  padding: 16px 20px;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  gap: 14px;
  color: #34d399;
  animation: fadeInQuizBanner 0.3s ease;
}

@keyframes fadeInQuizBanner {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.quiz-questions-grid {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.quiz-question-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.quiz-question-card:hover {
  border-color: rgba(255, 255, 255, 0.12);
}

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

.quiz-q-num {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

.quiz-q-nature-tag {
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
}

.quiz-q-statement {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.5;
  margin-bottom: 16px;
  white-space: pre-line;
}

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

.quiz-option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 0.88rem;
  line-height: 1.45;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s ease;
  width: 100%;
}

.quiz-option:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.2);
  color: var(--text-main);
}

.quiz-option:focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

.quiz-option.selected {
  border-color: #3b82f6;
  background: rgba(59, 130, 246, 0.12);
  color: var(--text-main);
}

.quiz-option.correct {
  border-color: #10b981 !important;
  background: rgba(16, 185, 129, 0.15) !important;
  color: #34d399 !important;
}

.quiz-option.incorrect {
  border-color: #ef4444 !important;
  background: rgba(239, 68, 68, 0.12) !important;
  color: #f87171 !important;
}

.quiz-opt-letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.08);
  font-size: 0.78rem;
  font-weight: 700;
  flex-shrink: 0;
  color: var(--text-main);
}

.quiz-option.correct .quiz-opt-letter {
  background: #10b981;
  color: #0c0e14;
}

.quiz-option.incorrect .quiz-opt-letter {
  background: #ef4444;
  color: #ffffff;
}

.quiz-answer-feedback {
  margin-top: 14px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 0.84rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.quiz-answer-feedback.success {
  background: rgba(16, 185, 129, 0.1);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.quiz-answer-feedback.warning {
  background: rgba(239, 68, 68, 0.1);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.25);
}

.quiz-solution {
  margin-top: 14px;
  padding: 14px 16px;
  background: rgba(0, 0, 0, 0.2);
  border-left: 3px solid #3b82f6;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.quiz-solution-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #60a5fa;
  margin-bottom: 6px;
  letter-spacing: 0.04em;
}

.quiz-pauta-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #f59e0b;
  margin-top: 10px;
  margin-bottom: 4px;
  letter-spacing: 0.04em;
}

.quiz-cites-wrap {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.quiz-cite-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 600;
  background: rgba(59, 130, 246, 0.12);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.2);
}

/* ==========================================================================
   FEEDBACK VISUAL UNIFICADO, SKELETONS Y ACCESIBILIDAD WCAG AA (v7.37 / PROMPT 030)
   ========================================================================== */

/* Universal Focus Visible (WCAG 2.1 AA) */
:focus-visible {
  outline: 2px solid var(--gold-primary, #d4af37);
  outline-offset: 2px;
}

:focus:not(:focus-visible) {
  outline: none;
}

/* Reducción de movimiento para usuarios sensibles (WCAG 2.3.3) */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Skeleton Loading Shimmer Unificado */
.ui-skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-surface-elevated, #1a1f2c) 25%,
    var(--bg-surface-hover, #22293a) 37%,
    var(--bg-surface-elevated, #1a1f2c) 63%
  );
  background-size: 400% 100%;
  animation: uiSkeletonShimmer 1.4s ease infinite;
  border-radius: var(--radius-sm, 6px);
  pointer-events: none;
  user-select: none;
}

@keyframes uiSkeletonShimmer {
  0% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0 50%;
  }
}

/* Estados Vacíos Unificados (Empty States) */
.ui-state-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-6, 32px) var(--space-4, 16px);
  color: var(--text-muted);
  gap: var(--space-3, 12px);
}

.ui-state-empty svg,
.ui-state-empty i {
  width: 40px;
  height: 40px;
  color: var(--text-subtle);
  opacity: 0.6;
}

.ui-state-empty-title {
  font-family: var(--font-display, var(--font-serif));
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 0;
}

.ui-state-empty-desc {
  font-size: 0.85rem;
  line-height: var(--lh-dense, 1.5);
  color: var(--text-muted);
  max-width: 380px;
  margin: 0;
}

/* Estados de Error Unificados (Error States) */
.ui-state-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-6, 32px) var(--space-4, 16px);
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  border-radius: var(--radius-md);
  color: var(--danger-text);
  gap: var(--space-3, 12px);
}

.ui-state-error svg,
.ui-state-error i {
  width: 36px;
  height: 36px;
  color: var(--danger);
}
