:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --border-bottom: #cbd5e1;

  --primary: #58cc02;
  --primary-dark: #46a302;
  --primary-soft: #f0fdf4;

  --accent: #1cb0f6;
  --accent-dark: #0284c7;
  --accent-soft: #e0f2fe;

  --radius-lg: 16px;
  --radius-md: 12px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

input, textarea {
  -webkit-user-select: text;
  user-select: text;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  background-color: var(--bg);
  color: var(--text-main);
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
}

/* =========================================================
   CONTENEDOR RESPONSIVO: MOBILE-FIRST + DESKTOP WIDESCREEN
   ========================================================= */
.app-shell {
  width: 100%;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: var(--surface);
  overflow: hidden;
}

@media (min-width: 900px) {
  body {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
  }
  .app-shell {
    max-width: 1060px;
    height: min(740px, 92dvh);
    border-radius: 24px;
    border: 2px solid var(--border);
    box-shadow: 0 16px 48px rgba(15, 23, 42, 0.07);
  }
}

/* =========================================================
   BARRA SUPERIOR LIMPIA (Botón atrás + barra visual + QR)
   ========================================================= */
.top-header {
  height: 52px;
  padding: 0 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1.5px solid var(--border);
  flex-shrink: 0;
}

@media (min-width: 900px) {
  .top-header {
    height: 64px;
    padding: 0 36px;
    gap: 18px;
  }
}

.nav-back-btn {
  background: transparent;
  border: 1.5px solid var(--border);
  border-bottom-width: 3px;
  border-radius: 10px;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 1rem;
  font-weight: 800;
  flex-shrink: 0;
  transition: background-color 0.15s ease;
}

.nav-back-btn:hover:not(:disabled) {
  background: #f8fafc;
  color: var(--text-main);
}

.nav-back-btn:disabled {
  opacity: 0.25;
  cursor: default;
}

.qr-header-btn {
  background: #f8fafc;
  border: 1.5px solid var(--border);
  border-bottom-width: 3px;
  border-radius: 10px;
  height: 34px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  color: var(--text-main);
  font-size: 0.78rem;
  font-weight: 800;
  flex-shrink: 0;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.qr-header-btn:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-dark);
}

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

@media (min-width: 640px) {
  .qr-btn-label {
    display: inline;
  }
}

.progress-track {
  flex: 1;
  height: 14px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 999px;
  transition: width 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
}

.progress-fill::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 8px;
  right: 8px;
  height: 3.5px;
  background: rgba(255, 255, 255, 0.35);
  border-radius: 999px;
}

/* =========================================================
   ESCENARIO PRINCIPAL (CERO SCROLL, CENTRADO Y PROTAGONISTA)
   ========================================================= */
.main-stage {
  flex: 1;
  padding: 12px 18px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
  animation: fadeIn 0.16s ease-out;
}

.stage-centered {
  width: 100%;
  max-width: 660px;
  margin: 0 auto;
}

@media (min-width: 900px) {
  .main-stage {
    padding: 24px 44px;
  }
}

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

.micro-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  align-self: flex-start;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  padding: 3px 10px;
  border-radius: 999px;
  margin-bottom: 6px;
}

.question-title {
  font-size: 1.16rem;
  font-weight: 800;
  color: var(--text-main);
  margin: 0 0 3px;
  line-height: 1.25;
}

.question-helper {
  font-size: 0.83rem;
  color: var(--text-muted);
  margin: 0 0 10px;
  line-height: 1.3;
}

@media (min-width: 900px) {
  .question-title {
    font-size: 1.42rem;
    margin-bottom: 6px;
  }
  .question-helper {
    font-size: 0.94rem;
    margin-bottom: 18px;
  }
}

/* =========================================================
   PAUSA / CHECKPOINT AL TERMINAR CADA SECCIÓN (MINIMALISTA)
   ========================================================= */
.checkpoint-card {
  max-width: 480px;
  margin: 0 auto;
  background: #f0fdf4;
  border: 2px solid #86efac;
  border-bottom: 4px solid #22c55e;
  border-radius: 20px;
  padding: 24px 22px;
  text-align: center;
}

@media (min-width: 900px) {
  .checkpoint-card {
    padding: 32px 36px;
  }
}

.checkpoint-badge {
  display: inline-block;
  background: #dcfce7;
  color: #166534;
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 4px 12px;
  border-radius: 999px;
  margin-bottom: 10px;
}

.checkpoint-title {
  font-size: 1.35rem;
  font-weight: 900;
  color: #14532d;
  margin: 0 0 6px;
}

.checkpoint-next {
  font-size: 0.96rem;
  font-weight: 700;
  color: #15803d;
  margin: 0 0 14px;
}

.checkpoint-reminder {
  background: #ffffff;
  border: 1.5px solid #bbf7d0;
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 0.88rem;
  line-height: 1.4;
  color: #334155;
}

/* =========================================================
   COMPRENSIÓN LECTORA: TEXTO COMPLETO (3 PÁRRAFOS SIN PISTAS)
   ========================================================= */
.reading-layout {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.reading-passage-panel {
  background: #f8fafc;
  border: 2px solid #cbd5e1;
  border-left: 5px solid var(--accent-dark);
  border-radius: var(--radius-md);
  padding: 10px 13px;
}

.reading-passage-header {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #475569;
  margin-bottom: 5px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.reading-paragraphs p {
  margin: 0 0 6px;
  font-size: 0.83rem;
  line-height: 1.36;
  color: #1e293b;
}

.reading-paragraphs p:last-child {
  margin-bottom: 0;
}

.reading-question-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

@media (min-width: 900px) {
  .reading-layout {
    display: grid;
    grid-template-columns: 1.15fr 1fr;
    gap: 32px;
    align-items: center;
    height: 100%;
  }

  .reading-passage-panel {
    padding: 22px 24px;
    border-radius: var(--radius-lg);
  }

  .reading-passage-header {
    font-size: 0.8rem;
    margin-bottom: 12px;
  }

  .reading-paragraphs p {
    font-size: 1rem;
    line-height: 1.62;
    margin-bottom: 14px;
  }
}

/* =========================================================
   BOTONES TÁCTILES Y GRILLAS
   ========================================================= */
.choice-grid {
  display: grid;
  gap: 8px;
}

.choice-grid.cols-3 {
  grid-template-columns: repeat(3, 1fr);
}

.choice-grid.cols-2 {
  grid-template-columns: repeat(2, 1fr);
}

@media (min-width: 900px) {
  .choice-grid {
    gap: 12px;
  }
  .choice-grid.desktop-cols-3 {
    grid-template-columns: repeat(3, 1fr);
  }
}

.tactile-btn {
  appearance: none;
  background: var(--surface);
  border: 2px solid var(--border);
  border-bottom: 4px solid var(--border-bottom);
  border-radius: var(--radius-md);
  padding: 10px 13px;
  font-size: 0.94rem;
  font-weight: 700;
  color: var(--text-main);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  transition: transform 0.06s ease, background-color 0.12s ease, border-color 0.12s ease;
}

@media (min-width: 900px) {
  .tactile-btn {
    padding: 14px 18px;
    font-size: 1.04rem;
  }
}

.tactile-btn.center {
  justify-content: center;
  text-align: center;
  padding: 10px 8px;
}

.tactile-btn:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.tactile-btn:active {
  transform: translateY(2px);
  border-bottom-width: 2px;
}

.tactile-btn.selected {
  background: var(--accent-soft);
  border-color: var(--accent);
  border-bottom-color: var(--accent-dark);
  color: #0369a1;
}

.key-badge {
  width: 25px;
  height: 25px;
  border-radius: 7px;
  border: 1.5px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--text-muted);
  flex-shrink: 0;
  background: #fff;
}

.tactile-btn.selected .key-badge {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

/* =========================================================
   CAMPOS DE ENTRADA Y COMPONENTES DE EJERCICIO
   ========================================================= */
.compact-group {
  margin-bottom: 10px;
}

@media (min-width: 900px) {
  .compact-group {
    margin-bottom: 16px;
  }
}

.compact-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 5px;
}

.text-input, .text-area {
  width: 100%;
  font-family: inherit;
  font-size: 0.98rem;
  padding: 11px 14px;
  border: 2px solid var(--border);
  border-bottom-width: 4px;
  border-radius: var(--radius-md);
  background: #f8fafc;
  color: var(--text-main);
  outline: none;
  resize: none;
}

@media (min-width: 900px) {
  .text-input, .text-area {
    font-size: 1.08rem;
    padding: 14px 18px;
  }
}

.text-input:focus, .text-area:focus {
  background: #fff;
  border-color: var(--accent);
}

/* Oración para Vocabulario */
.sentence-card {
  background: #f8fafc;
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 16px;
  font-size: 1.25rem;
  font-weight: 800;
  text-align: center;
  margin-bottom: 14px;
}

@media (min-width: 900px) {
  .sentence-card {
    padding: 28px 24px;
    font-size: 1.55rem;
    margin-bottom: 22px;
  }
}

.blank-slot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 96px;
  padding: 2px 14px;
  margin: 0 4px;
  border-bottom: 3px dashed #94a3b8;
  color: var(--accent-dark);
  border-radius: 6px;
  background: #fff;
}

.blank-slot.filled {
  border-bottom: 3px solid var(--accent-dark);
  background: var(--accent-soft);
}

/* Tarjeta de Traducción */
.translate-prompt-card {
  background: #f8fafc;
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
}

@media (min-width: 900px) {
  .translate-prompt-card {
    padding: 22px 24px;
    margin-bottom: 18px;
  }
}

.translate-icon { font-size: 1.7rem; }
.translate-sentence { font-size: 1.2rem; font-weight: 800; }

@media (min-width: 900px) {
  .translate-sentence { font-size: 1.45rem; }
}

/* Escala Likert (1 a 5) */
.likert-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.likert-scale {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

@media (min-width: 900px) {
  .likert-scale { gap: 14px; }
}

.likert-btn {
  appearance: none;
  background: #fff;
  border: 2px solid var(--border);
  border-bottom: 4px solid var(--border-bottom);
  border-radius: var(--radius-md);
  padding: 14px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

@media (min-width: 900px) {
  .likert-btn { padding: 22px 8px; gap: 8px; }
}

.likert-btn .emo { font-size: 1.3rem; }
.likert-btn .num { font-size: 1.2rem; font-weight: 800; color: var(--text-main); }

.likert-btn.selected {
  background: var(--accent-soft);
  border-color: var(--accent);
  border-bottom-color: var(--accent-dark);
}

/* Píldoras para opinión abierta */
.idea-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.idea-chip {
  background: #fffbeb;
  border: 1.5px solid #fcd34d;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.76rem;
  font-weight: 700;
  color: #92400e;
  cursor: pointer;
}

.dynamic-coach {
  margin-top: 8px;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 0.82rem;
  font-weight: 700;
  background: #f1f5f9;
  color: #334155;
  display: flex;
  align-items: center;
  gap: 7px;
}

.dynamic-coach.encouraging { background: #eff6ff; color: #1e40af; }
.dynamic-coach.deep { background: #f0fdf4; color: #166534; }

/* =========================================================
   PIE DE PÁGINA LIMPIO (Solo botón de acción)
   ========================================================= */
.bottom-bar {
  height: 66px;
  padding: 0 18px;
  border-top: 1.5px solid var(--border);
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.bottom-bar-inner {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.primary-btn {
  width: 100%;
  appearance: none;
  background: var(--primary);
  border: none;
  border-bottom: 4px solid var(--primary-dark);
  color: #fff;
  font-size: 0.98rem;
  font-weight: 800;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  padding: 13px 20px;
  border-radius: var(--radius-md);
  cursor: pointer;
}

.primary-btn:disabled {
  background: #e2e8f0;
  border-bottom-color: #cbd5e1;
  color: #94a3b8;
  cursor: not-allowed;
}

@media (min-width: 900px) {
  .bottom-bar {
    height: 82px;
    padding: 0 44px;
  }
  .primary-btn {
    width: auto;
    min-width: 220px;
    padding: 14px 32px;
    font-size: 1rem;
  }
}

/* =========================================================
   MODAL AMIGABLE DE BIENVENIDA Y MODAL DE CÓDIGO QR
   ========================================================= */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(15, 23, 42, 0.72);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-backdrop.hidden {
  display: none;
}

.modal-card {
  width: 100%;
  max-width: 450px;
  background: #ffffff;
  border-radius: 22px;
  padding: 24px 22px 22px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
  animation: popModal 0.2s ease-out;
}

@keyframes popModal {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.modal-pill {
  display: inline-block;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #065f46;
  font-size: 0.73rem;
  font-weight: 900;
  letter-spacing: 0.7px;
  padding: 4px 12px;
  border-radius: 999px;
  margin-bottom: 10px;
}

.modal-headline {
  font-size: 1.4rem;
  font-weight: 900;
  margin: 0 0 14px;
  color: var(--text-main);
}

.modal-sub {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin: 0 0 14px;
}

.modal-highlights {
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
  margin-bottom: 18px;
}

.modal-point {
  background: #f8fafc;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 12px 15px;
}

.modal-point strong {
  display: block;
  font-size: 0.95rem;
  color: var(--text-main);
  margin-bottom: 2px;
}

.modal-point span {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.modal-btn {
  width: 100%;
  border: none;
  border-radius: 12px;
  padding: 14px 18px;
  font-size: 0.96rem;
  font-weight: 800;
  background: var(--primary);
  border-bottom: 4px solid var(--primary-dark);
  color: #fff;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.modal-btn:disabled {
  background: #f1f5f9;
  border: 1.5px solid #cbd5e1;
  border-bottom: 3px solid #cbd5e1;
  color: #64748b;
  cursor: default;
}

/* Modal de QR Red Local */
.qr-code-container {
  background: #f8fafc;
  border: 2px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.qr-url-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.qr-url-pill {
  background: #e0f2fe;
  color: #0369a1;
  font-weight: 800;
  font-size: 0.95rem;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1.5px solid #bae6fd;
  cursor: pointer;
}

.qr-url-pill.active {
  background: #0284c7;
  color: #ffffff;
  border-color: #0369a1;
}

/* Modal Nativo de Advertencia y Reinicio por Cambio de Pestaña */
.tab-alert-card {
  max-width: 410px;
}

.modal-pill.pill-warning {
  background: #fef3c7;
  border-color: #fcd34d;
  color: #92400e;
}

.modal-pill.pill-danger {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #991b1b;
}

.modal-btn.btn-warning {
  background: #f59e0b;
  border-bottom-color: #d97706;
}

.modal-btn.btn-danger {
  background: #ef4444;
  border-bottom-color: #dc2626;
}
