/* WORLDLYDEX COGNITIVE CORE™ - DESIGN SYSTEM, PWA & RESPONSIVE UI (v9) */
:root {
  color-scheme: dark;
  --bg-app: #0B0F19;
  --bg-surface: #111827;
  --bg-card: #1E293B;
  --border-muted: #334155;
  --text-primary: #F8FAFC;
  --text-secondary: #94A3B8;
  --accent-blue: #0284C7;
  --accent-cyan: #38BDF8;
  --accent-teal: #10B981;
  --alert-red: #EF4444;
  --alert-orange: #F59E0B;
}

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

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: #0B0F19;
}
::-webkit-scrollbar-thumb {
  background: #334155;
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover {
  background: #38BDF8;
}

body {
  background-color: var(--bg-app);
  color: var(--text-primary);
  font-family: 'Plus Jakarta Sans', sans-serif;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

select,
select option {
  background-color: #0F172A !important;
  color: #F8FAFC !important;
}

select:focus,
input:focus,
textarea:focus {
  border-color: var(--accent-cyan) !important;
  outline: none;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(56, 189, 248, 0.2);
  border-top-color: var(--accent-cyan);
  border-radius: 50%;
  animation: wd-spin 0.8s linear infinite;
  display: inline-block;
}

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

.app-container {
  max-width: 1140px;
  margin: 0 auto;
  padding: 18px;
  padding-bottom: 95px;
}

/* =========================================================================
   HEADER EJECUTIVO COMPACTO (PC & MÓVIL)
   ========================================================================= */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-surface);
  border: 1px solid var(--border-muted);
  padding: 12px 18px;
  border-radius: 14px;
  margin-bottom: 16px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.35);
  gap: 10px;
}

.user-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  min-width: 0;
  flex: 1;
}

.user-avatar-box {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  background: linear-gradient(135deg, #0284C7 0%, #0F172A 100%);
  border: 1px solid #38BDF8;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #38BDF8;
  font-size: 0.9rem;
  box-shadow: 0 4px 12px rgba(2,132,199,0.25);
}

.user-meta-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.user-badge {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.target-badge {
  font-size: 0.76rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.quick-lexicon-btn {
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid var(--accent-cyan);
  color: var(--accent-cyan);
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 5px;
}
.quick-lexicon-btn:hover {
  background: rgba(56, 189, 248, 0.22);
}

.cefr-indicator {
  background: #0B0F19;
  border: 1px solid var(--border-muted);
  padding: 6px 10px;
  border-radius: 8px;
  display: flex;
  gap: 6px;
  align-items: center;
  cursor: pointer;
}
.cefr-level { color: var(--accent-teal); font-weight: 700; font-size: 0.82rem; }
.ielts-equiv { color: var(--text-secondary); font-size: 0.72rem; font-family: 'JetBrains Mono', monospace; }

.logout-btn {
  background: rgba(239, 68, 68, 0.14);
  color: #FCA5A5;
  border: 1px solid rgba(239, 68, 68, 0.5);
  padding: 6px 11px;
  border-radius: 8px;
  font-size: 0.75rem;
  cursor: pointer;
  font-weight: 600;
}

/* =========================================================================
   NAVEGACIÓN DE 3 PILARES CENTRALES (DESKTOP & BOTTOM BAR MÓVIL)
   ========================================================================= */
.main-nav {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  background: var(--bg-surface);
  padding: 6px;
  border-radius: 12px;
  border: 1px solid var(--border-muted);
  margin-bottom: 20px;
}

.nav-tab {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 11px 12px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.nav-tab:hover:not(.active) {
  color: var(--text-primary);
  background: rgba(30, 41, 59, 0.55);
}

.nav-tab.active {
  background: var(--accent-blue);
  color: #FFFFFF;
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.4);
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* =========================================================================
   PILAR 1: RUTA DE MAESTRÍA & DIVULGACIÓN PROGRESIVA
   ========================================================================= */
.lock-banner {
  background: linear-gradient(135deg, #1E293B 0%, #0F172A 100%);
  border: 1px solid var(--border-muted);
  border-radius: 14px;
  padding: 18px 20px;
  margin-bottom: 16px;
  box-shadow: 0 8px 25px rgba(0,0,0,0.3);
}

.mission-bar {
  background: rgba(245, 158, 11, 0.07);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-left: 4px solid var(--alert-orange);
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.mission-tag {
  color: #FBBF24;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: block;
  margin-bottom: 3px;
}

.mission-text h4 {
  margin: 0;
  color: #F8FAFC;
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.45;
}

.mission-steps-counter {
  background: #0B0F19;
  border: 1px solid var(--border-muted);
  color: var(--accent-cyan);
  padding: 6px 12px;
  border-radius: 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
}

.lesson-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-muted);
  border-radius: 16px;
  padding: 22px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.45);
}

.lesson-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  flex-wrap: wrap;
  gap: 8px;
}

.section-label { color: var(--accent-cyan); font-size: 0.76rem; font-weight: 700; letter-spacing: 0.05em; }
.badge-source { background: #0B0F19; color: var(--text-secondary); padding: 4px 10px; border-radius: 6px; font-size: 0.7rem; font-family: 'JetBrains Mono', monospace; border: 1px solid var(--border-muted); }

.lesson-main-heading {
  margin: 0 0 14px 0;
  font-size: 1.35rem;
  line-height: 1.35;
  color: #F8FAFC;
}

.cat-tabs-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  border-bottom: 1px solid #334155;
  padding-bottom: 12px;
  overflow-x: auto;
}

.cat-tab-btn {
  background: #1E293B;
  color: #94A3B8;
  border: 1px solid #334155;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.cat-tab-btn.active {
  background: var(--accent-blue);
  color: #FFFFFF;
  border-color: var(--accent-cyan);
}

.theory-box {
  background: #0B0F19;
  border: 1px solid var(--border-muted);
  border-radius: 12px;
  padding: 18px;
  line-height: 1.68;
  font-size: 0.94rem;
  color: #E2E8F0;
  word-break: break-word;
}

/* Botón de Divulgación Progresiva (Progressive Disclosure) */
.progressive-disclosure-btn {
  width: 100%;
  background: rgba(56, 189, 248, 0.08);
  border: 1px dashed #38BDF8;
  color: #38BDF8;
  padding: 11px 16px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.2s;
}
.progressive-disclosure-btn:hover {
  background: rgba(56, 189, 248, 0.16);
}

/* Flujo de Tokens Sintácticos */
.syntax-flow-box {
  background: #0B0F19;
  border: 1px solid #334155;
  border-radius: 12px;
  padding: 14px 16px;
  margin: 16px 0;
}

.syntax-flow-title {
  color: #38BDF8;
  font-size: 0.74rem;
  font-weight: 700;
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.syntax-flow-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.syntax-token-card {
  background: #1E293B;
  padding: 10px 12px;
  border-radius: 8px;
}
.token-subj { border-left: 3px solid #38BDF8; }
.token-verb { border-left: 3px solid #10B981; }
.token-obj  { border-left: 3px solid #F59E0B; }

.token-label {
  display: block;
  color: #94A3B8;
  font-size: 0.7rem;
  text-transform: uppercase;
  margin-bottom: 3px;
}

.syntax-token-card code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.86rem;
  color: #F8FAFC;
  word-break: break-word;
}

/* Tablas Oscuras Blindadas */
table, .theory-box table, .manual-content-body table {
  width: 100% !important;
  border-collapse: collapse !important;
  margin: 14px 0 !important;
  background-color: #0F172A !important;
  border: 1px solid #334155 !important;
  border-radius: 8px !important;
  overflow: hidden !important;
}
th, .theory-box th, .manual-content-body th {
  background-color: #1E293B !important;
  color: #38BDF8 !important;
  font-weight: 700 !important;
  text-align: left !important;
  padding: 10px 12px !important;
  border: 1px solid #334155 !important;
  font-size: 0.78rem !important;
  text-transform: uppercase !important;
}
td, .theory-box td, .manual-content-body td {
  background-color: #0F172A !important;
  color: #F8FAFC !important;
  padding: 10px 12px !important;
  border: 1px solid #334155 !important;
  font-size: 0.88rem !important;
  line-height: 1.45 !important;
}

/* Taller Interactivo & Drills */
.interactive-workshop {
  background: #0B0F19;
  border: 1px solid var(--border-muted);
  border-radius: 12px;
  padding: 18px;
  margin-top: 16px;
}

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

.step-indicator {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-teal);
  border: 1px solid rgba(16, 185, 129, 0.35);
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
}

.drill-opt-btn {
  text-align: left;
  background: #1E293B;
  border: 1px solid #334155;
  color: #F8FAFC;
  padding: 13px 15px;
  border-radius: 10px;
  font-size: 0.92rem;
  cursor: pointer;
  transition: all 0.2s ease;
  line-height: 1.45;
}
.drill-opt-btn:hover:not(:disabled) {
  border-color: var(--accent-cyan) !important;
  background: #0F172A !important;
  transform: translateY(-1px);
}
.drill-opt-btn:disabled {
  opacity: 0.75;
  cursor: default;
}

.workshop-input-row { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.workshop-input-row input { flex: 1; min-width: 200px; background: #1E293B; border: 1px solid var(--border-muted); color: white; padding: 12px; border-radius: 8px; font-size: 0.95rem; }

.primary-btn { background: var(--accent-blue); color: white; border: none; padding: 11px 18px; border-radius: 8px; font-weight: 600; cursor: pointer; transition: background 0.2s; }
.primary-btn:hover:not(:disabled) { background: #0369A1; }
.secondary-btn { background: #1E293B; color: #38BDF8; border: 1px solid #38BDF8; padding: 9px 16px; border-radius: 8px; font-weight: 600; cursor: pointer; transition: all 0.2s; }
.barrier-btn { background: var(--accent-teal); color: #0B0F19; border: none; padding: 11px 20px; border-radius: 8px; font-weight: 700; cursor: pointer; }

.lesson-footer-nav {
  margin-top: 18px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.feedback-card {
  background: #0F172A;
  border: 1px solid var(--border-muted);
  border-radius: 8px;
  padding: 14px;
  margin-top: 12px;
  font-size: 0.9rem;
  line-height: 1.5;
}

/* Acordeón de Grammar Core & SOPs integrado en Pilar 1 */
.grammar-core-accordion {
  margin-top: 22px;
  background: var(--bg-surface);
  border: 1px solid var(--border-muted);
  border-radius: 14px;
  overflow: hidden;
}

.grammar-core-toggle-btn {
  width: 100%;
  background: linear-gradient(135deg, #1E293B 0%, #0F172A 100%);
  border: none;
  padding: 16px 20px;
  text-align: left;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.accordion-chevron {
  background: rgba(56, 189, 248, 0.12);
  color: #38BDF8;
  border: 1px solid rgba(56, 189, 248, 0.35);
  padding: 5px 12px;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}

.grammar-core-body {
  padding: 20px;
  border-top: 1px solid var(--border-muted);
}

.query-chip {
  background: #1E293B;
  border: 1px solid #334155;
  color: #94A3B8;
  font-size: 0.75rem;
  padding: 5px 10px;
  border-radius: 12px;
  cursor: pointer;
}
.query-chip:hover {
  color: #38BDF8;
  border-color: #38BDF8;
}

.res-filter-btn {
  background: #1E293B;
  color: #94A3B8;
  border: 1px solid #334155;
  padding: 5px 11px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.78rem;
  cursor: pointer;
}
.res-filter-btn.active {
  background: #38BDF8;
  color: #0F172A;
  border-color: #38BDF8;
}

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

/* =========================================================================
   PILAR 2: EXECUTIVE AI HUB (MENTOR VOZ + SIMULADOR STAR)
   ========================================================================= */
.mode-segmented-control {
  display: flex;
  background: #0F172A;
  border: 1px solid #334155;
  border-radius: 12px;
  padding: 5px;
  margin-bottom: 16px;
  gap: 6px;
  overflow-x: auto;
}

.mode-pill-btn {
  flex: 1;
  min-width: 140px;
  padding: 10px 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #94A3B8;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.mode-pill-btn.active {
  background: var(--accent-blue);
  color: #FFFFFF;
}

.gemini-ai-workspace,
.star-panel {
  height: 74vh;
  min-height: 540px;
  max-height: 780px;
  background: radial-gradient(circle at top right, #131C31 0%, #0B0F19 100%);
  border: 1px solid #1E293B;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
}

.ai-chat-header {
  padding: 12px 18px;
  background: #1E293B;
  border-bottom: 1px solid #334155;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.pronunciation-mini-bar {
  padding: 8px 16px;
  background: #111827;
  border-bottom: 1px solid #1E293B;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.pronunciation-mini-bar input {
  flex: 1;
  min-width: 180px;
  padding: 6px 10px;
  background: #0B0F19;
  border: 1px solid #334155;
  color: #E2E8F0;
  border-radius: 6px;
  font-size: 0.82rem;
}

.pronunciation-mini-bar button {
  background: #0284C7;
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.star-presets-bar {
  padding: 10px 18px;
  background: #111827;
  border-bottom: 1px solid #1E293B;
}

.preset-chip-btn {
  background: #1E293B;
  border: 1px solid #334155;
  color: #38BDF8;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
}
.preset-chip-btn:hover {
  background: rgba(56, 189, 248, 0.15);
  border-color: #38BDF8;
}

.ai-chat-stream {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: #0B0F19;
  scroll-behavior: smooth;
}

.mentor-welcome-card {
  background: #1E293B;
  border: 1px solid #334155;
  padding: 14px 18px;
  border-radius: 14px;
  max-width: 88%;
  align-self: flex-start;
  color: #E2E8F0;
  line-height: 1.55;
  font-size: 0.92rem;
}

.mentor-pro-bubble {
  background: linear-gradient(180deg, #162033 0%, #111827 100%);
  border: 1px solid #26354D;
  border-left: 3px solid #38BDF8;
  padding: 16px 18px;
  border-radius: 14px;
  border-top-left-radius: 4px;
  max-width: 88%;
  align-self: flex-start;
  color: #F1F5F9;
  line-height: 1.65;
  font-size: 0.94rem;
  word-break: break-word;
}

.user-pro-bubble {
  background: linear-gradient(135deg, #0284C7 0%, #0369A1 100%);
  border: 1px solid rgba(56, 189, 248, 0.35);
  padding: 10px 15px;
  border-radius: 14px;
  border-bottom-right-radius: 4px;
  max-width: 80%;
  align-self: flex-end;
  color: #FFFFFF;
  font-size: 0.93rem;
  line-height: 1.45;
  word-break: break-word;
  white-space: normal;
  margin-bottom: 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.user-pro-bubble strong,
.user-pro-label {
  margin: 0 !important;
  padding: 0 !important;
  display: block;
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  line-height: 1.2;
}

.user-pro-text {
  white-space: pre-wrap;
  margin: 0;
  padding: 0;
  line-height: 1.45;
  color: #FFFFFF;
}

.ai-chat-input-zone {
  padding: 12px 16px;
  background: #111827;
  border-top: 1px solid #1E293B;
}

.chat-input-pill {
  display: flex;
  align-items: center;
  background: #1E293B;
  border: 1px solid #475569;
  border-radius: 12px;
  padding: 6px 12px;
  gap: 8px;
}

.chat-input-pill input,
.chat-input-pill textarea {
  flex: 1;
  min-width: 140px;
  background: transparent;
  border: none;
  outline: none;
  color: #F8FAFC;
  font-size: 0.94rem;
  padding: 6px 0;
  resize: none;
  font-family: inherit;
}

.ai-action-icon-btn {
  background: #334155;
  border: none;
  color: #F8FAFC;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
}

.ai-action-primary-btn {
  background: #0284C7;
  border: none;
  color: white;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
}

/* =========================================================================
   PILAR 3: MI BÓVEDA (KNOWLEDGE VAULT) & INSPECTOR FLOTANTE
   ========================================================================= */
.vault-hero-banner {
  background: linear-gradient(135deg, #1E293B 0%, #0F172A 100%);
  border: 1px solid #334155;
  border-radius: 14px;
  padding: 18px 20px;
  margin-bottom: 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.ielts-badge {
  background: rgba(16, 185, 129, 0.2);
  color: var(--accent-teal);
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 0.74rem;
  font-weight: 700;
}

.save-word-btn {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid var(--accent-teal);
  color: var(--accent-teal);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.audio-btn {
  background: #1E293B;
  border: 1px solid var(--border-muted);
  color: var(--accent-cyan);
  padding: 6px 11px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.88rem;
}

.saved-vocab-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 14px;
}

.vocab-card-item {
  background: var(--bg-surface);
  border: 1px solid var(--border-muted);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
}

.vocab-card-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  border-top: 1px solid var(--border-muted);
  padding-top: 8px;
}

.vocab-del-btn {
  background: none;
  border: none;
  color: #EF4444;
  font-size: 0.78rem;
  cursor: pointer;
  font-weight: 600;
}

.flashcard-interactive-box {
  background: #1E293B;
  border: 1px solid #38BDF8;
  border-radius: 14px;
  min-height: 230px;
  padding: 24px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  box-shadow: 0 10px 25px rgba(0,0,0,0.4);
  user-select: none;
}

/* Drawer Flotante (Ctrl+K y Móvil) */
.quick-lexicon-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: 380px;
  max-width: 100%;
  height: 100%;
  background: var(--bg-surface);
  border-left: 1px solid var(--border-muted);
  z-index: 999999;
  padding: 20px;
  box-shadow: -10px 0 30px rgba(0,0,0,0.7);
  overflow-y: auto;
}
.drawer-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 16px; }
.drawer-search { display: flex; gap: 8px; margin-bottom: 15px; }
.drawer-search input { flex: 1; background: #0B0F19; border: 1px solid var(--border-muted); color: white; padding: 11px; border-radius: 8px; }
.drawer-search button { background: var(--accent-blue); color: white; border: none; padding: 0 16px; border-radius: 8px; font-weight: 600; cursor: pointer; }
.close-drawer-btn { background: #1E293B; border: 1px solid #334155; color: var(--text-primary); width: 32px; height: 32px; border-radius: 8px; font-size: 1rem; cursor: pointer; }
.quick-result-card { background: #0B0F19; border: 1px solid var(--border-muted); border-radius: 10px; padding: 14px; }
.quick-word-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.quick-def { color: #CBD5E1; font-size: 0.9rem; line-height: 1.5; margin: 8px 0; }
.quick-us-uk { display: flex; justify-content: space-between; font-size: 0.8rem; color: var(--text-secondary); padding-top: 8px; border-top: 1px solid #1E293B; }

/* Examen de Ascenso */
.exam-card { background: var(--bg-surface); border: 1px solid var(--border-muted); border-radius: 16px; padding: 22px; }
.exam-progress-bar-wrap { width: 100%; height: 8px; background: #0B0F19; border-radius: 999px; overflow: hidden; margin-bottom: 12px; }
.exam-progress-bar { height: 100%; background: linear-gradient(90deg, var(--accent-blue), var(--accent-teal)); transition: width 0.3s ease; }
.exam-stats { display: flex; justify-content: space-between; align-items: center; font-size: 0.85rem; color: var(--text-secondary); font-weight: 600; margin-bottom: 16px; }
.score-badge { background: rgba(16, 185, 129, 0.15); color: var(--accent-teal); padding: 4px 10px; border-radius: 8px; font-family: 'JetBrains Mono', monospace; }
.exam-category-label { color: var(--accent-cyan); font-size: 0.75rem; font-weight: 700; text-transform: uppercase; margin: 0 0 6px 0; }
.exam-question-title { color: var(--text-primary); font-size: 1.15rem; line-height: 1.45; margin: 0 0 18px 0; }
.exam-options-list { display: flex; flex-direction: column; gap: 10px; }
.exam-option-btn { background: #1E293B; border: 1px solid #334155; color: var(--text-primary); padding: 13px 16px; border-radius: 10px; font-size: 0.92rem; text-align: left; cursor: pointer; }
.exam-option-btn.correct { background: rgba(16, 185, 129, 0.18) !important; border-color: #10B981 !important; color: #6EE7B7 !important; font-weight: 700; }
.exam-option-btn.incorrect { background: rgba(239, 68, 68, 0.18) !important; border-color: #EF4444 !important; color: #FCA5A5 !important; }
.exam-feedback-box { margin-top: 18px; background: #0B0F19; border-left: 4px solid var(--accent-cyan); border-radius: 10px; padding: 16px; }
.remedial-box { background: rgba(56, 189, 248, 0.08); padding: 10px 12px; border-radius: 8px; margin: 10px 0 14px 0; font-size: 0.86rem; color: #CBD5E1; }

/* =========================================================================
   EXPERIENCIA MOBILE-FIRST (ANDROID, IPHONE & TABLET)
   ========================================================================= */
@media (max-width: 768px) {
  .app-container {
    padding: 10px;
    padding-bottom: 92px;
  }

  .app-header {
    padding: 10px 12px;
    margin-bottom: 12px;
    border-radius: 12px;
  }

  .lexicon-btn-label {
    display: none;
  }

  .quick-lexicon-btn {
    padding: 7px 10px;
    font-size: 0.9rem;
  }

  .ielts-equiv {
    display: none;
  }

  /* Barra Inferior Fija Tipo App Nativa con 3 Pilares Amplios */
  .main-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    z-index: 99990;
    background: rgba(11, 15, 25, 0.96);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--border-muted);
    border-radius: 0;
    padding: 8px 10px;
    margin: 0;
    box-shadow: 0 -8px 25px rgba(0,0,0,0.85);
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }

  .nav-tab {
    flex-direction: column;
    gap: 3px;
    padding: 7px 4px;
    font-size: 0.74rem;
    border-radius: 10px;
  }

  .nav-icon {
    font-size: 1.05rem;
  }

  .lock-banner,
  .lesson-card,
  .exam-card {
    padding: 15px;
    border-radius: 12px;
  }

  .lesson-main-heading {
    font-size: 1.15rem;
  }

  .theory-box {
    padding: 14px;
    font-size: 0.9rem;
  }

  .syntax-flow-grid {
    grid-template-columns: 1fr;
  }

  .gemini-ai-workspace,
  .star-panel {
    height: calc(100vh - 210px);
    min-height: 460px;
  }

  .ai-chat-stream {
    padding: 14px;
    gap: 12px;
  }

  .mentor-pro-bubble,
  .mentor-welcome-card {
    max-width: 96%;
    padding: 13px 15px;
    font-size: 0.9rem;
  }

  .user-pro-bubble {
    max-width: 88%;
    padding: 10px 14px;
    font-size: 0.9rem;
  }

  .quick-lexicon-drawer {
    width: 100%;
  }
}

/* =========================================================================
   OPTIMIZACIÓN DE VIEWPORT DINÁMICO (dvh) Y TEXTAREA ADAPTABLE
   ========================================================================= */
.gemini-ai-workspace,
.star-panel {
  height: calc(100dvh - 175px) !important;
  min-height: 540px;
  max-height: 850px;
}

.chat-input-pill {
  align-items: flex-end !important;
}

.chat-input-pill textarea {
  line-height: 1.45;
  max-height: 125px;
  overflow-y: auto;
  padding: 8px 0;
}

@media (max-width: 768px) {
  .main-nav {
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px)) !important;
  }
  .gemini-ai-workspace,
  .star-panel {
    height: calc(100dvh - 195px) !important;
    min-height: 440px;
  }
}

/* =========================================================================
   LIBRETA EJECUTIVA AUTÓNOMA MAGICNOTES™ (EXECUTIVE CHEAT SHEETS)
   ========================================================================= */
.magic-notebook-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  background: #0F172A;
  border: 1px solid #334155;
  padding: 10px 14px;
  border-radius: 12px;
  margin-bottom: 16px;
}

.mn-filter-pill {
  background: #1E293B;
  border: 1px solid #334155;
  color: #94A3B8;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}
.mn-filter-pill.active {
  background: var(--accent-blue);
  color: #FFFFFF;
  border-color: var(--accent-cyan);
}

.mn-recall-toggle-btn {
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid var(--accent-teal);
  color: var(--accent-teal);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}
.mn-recall-toggle-btn.active {
  background: var(--accent-teal);
  color: #0B0F19;
}

.magic-cheat-card {
  background: #0F172A;
  border: 1px solid #334155;
  border-left: 4px solid var(--accent-cyan);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}

.magic-cheat-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  flex-wrap: wrap;
}

.magic-cheat-badge {
  background: rgba(56, 189, 248, 0.12);
  color: #38BDF8;
  border: 1px solid rgba(56, 189, 248, 0.35);
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.magic-golden-rule-box {
  background: #111827;
  border: 1px solid #1E293B;
  padding: 10px 14px;
  border-radius: 8px;
  color: #F1F5F9;
  font-size: 0.88rem;
  line-height: 1.5;
}

.magic-formula-pill {
  background: #0B0F19;
  border: 1px solid #334155;
  padding: 9px 12px;
  border-radius: 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.84rem;
  color: #6EE7B7;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.magic-contrast-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 8px;
}

.magic-contrast-wrong {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.35);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.84rem;
  color: #FCA5A5;
}

.magic-contrast-right {
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.35);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.84rem;
  color: #6EE7B7;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.magic-self-check-box {
  background: rgba(2, 132, 199, 0.08);
  border: 1px dashed rgba(56, 189, 248, 0.4);
  padding: 10px 14px;
  border-radius: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.magic-note-accordion {
  background: #0B0F19;
  border: 1px solid #1E293B;
  border-radius: 8px;
  padding: 8px 12px;
}

.magic-note-accordion summary {
  color: #38BDF8;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  outline: none;
}

.recall-target.recall-masked {
  filter: blur(6px);
  cursor: pointer;
  user-select: none;
  transition: filter 0.2s ease;
}
.recall-target.recall-masked:hover {
  filter: blur(3px);
}


/* =========================================================================
   CHAT TEÓRICO MULTI-TURNO GRAMMAR CORE™ (INTEGRADO EN PILAR 1)
   ========================================================================= */
.grammar-chat-console {
  background: radial-gradient(circle at top right, #131C31 0%, #0B0F19 100%);
  border: 1px solid #334155;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  margin-bottom: 22px;
}

.grammar-chat-stream {
  height: 460px;
  min-height: 360px;
  max-height: 620px;
  padding: 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: #0B0F19;
  scroll-behavior: smooth;
}

@media (max-width: 768px) {
  .grammar-chat-stream {
    height: 400px;
    min-height: 300px;
  }
}


/* =========================================================================
   MICRO-INTERACCIONES EJECUTIVAS, GAMIFICACIÓN & ONBOARDING PROACTIVO
   ========================================================================= */
@keyframes wd-mastery-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.65);
    border-color: #10B981;
  }
  50% {
    box-shadow: 0 0 28px 6px rgba(16, 185, 129, 0.28);
    border-color: #34D399;
  }
  100% {
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
    border-color: #10B981;
  }
}

.mastery-celebration-glow {
  animation: wd-mastery-pulse 1.2s ease-out forwards !important;
  border-color: #10B981 !important;
}

.srs-mastered-flash {
  animation: wd-mastery-pulse 0.75s ease-out !important;
  border-color: #10B981 !important;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.18) 0%, #1E293B 100%) !important;
}

.proactive-action-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed rgba(56, 189, 248, 0.25);
}

.proactive-chip-btn {
  background: rgba(2, 132, 199, 0.14);
  border: 1px solid rgba(56, 189, 248, 0.4);
  color: #38BDF8;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.proactive-chip-btn:hover {
  background: #0284C7;
  color: #FFFFFF;
  border-color: #38BDF8;
  transform: translateY(-1px);
}

.mentor-module-advance-cta {
  margin-top: 12px;
  padding: 10px 14px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.4);
  border-radius: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.mentor-module-advance-btn {
  background: #10B981;
  color: #0B0F19;
  border: none;
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}

.mentor-module-advance-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35);
}


/* =========================================================================
   COMPATIBILIDAD AVANZADA PARA TABLETS Y SMARTPHONES (iOS & ANDROID - v9)
   ========================================================================= */
@media (min-width: 769px) and (max-width: 1024px) {
  .app-container {
    max-width: 96%;
    padding: 14px;
    padding-bottom: 40px;
  }

  .app-header {
    flex-wrap: wrap;
    padding: 12px 14px;
  }

  .gemini-ai-workspace,
  .star-panel {
    height: calc(100dvh - 190px) !important;
    min-height: 500px;
  }
}

@media (max-width: 768px) {
  /* Evita el auto-zoom brusco de Safari en iOS al tocar inputs, selects o textareas */
  input,
  select,
  textarea,
  .chat-input-pill textarea,
  .pronunciation-mini-bar input,
  .workshop-input-row input,
  #curriculumTopicSelect {
    font-size: 16px !important;
  }

  /* Scroll horizontal táctil fluido en tablas gramaticales anchas */
  .theory-box table,
  .manual-content-body table {
    display: block !important;
    width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  .magic-cheat-top,
  .vault-hero-banner,
  .mentor-module-advance-cta {
    flex-direction: column;
    align-items: stretch !important;
  }

  .mentor-module-advance-btn {
    width: 100%;
    text-align: center;
    padding: 10px 14px;
  }
}
