:root {
  --bg-color: #0b0f19;
  --card-bg: #111827;
  --card-border: #1f2937;
  --text-main: #f9fafb;
  --text-muted: #9ca3af;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --pulse-color: rgba(59, 130, 246, 0.35);
  --radius: 16px;
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  -webkit-font-smoothing: antialiased;
}

.app-container {
  width: 100%;
  max-width: 440px;
}

/* CARDS & PANTALLAS */
.card {
  display: none;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 36px 28px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transform: translateY(8px);
  transition: var(--transition);
}

.card.active {
  display: block;
  opacity: 1;
  transform: translateY(0);
}

/* PANTALLA DE INGRESO */
.header {
  text-align: center;
  margin-bottom: 28px;
}

.logo-mark {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: rgba(59, 130, 246, 0.12);
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}

.subtitle {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
}

label {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

input {
  background: #1f2937;
  border: 1px solid #374151;
  color: var(--text-main);
  padding: 13px 16px;
  border-radius: 10px;
  font-size: 1rem;
  outline: none;
  transition: var(--transition);
}

input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

#session-code {
  font-family: monospace;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

/* BOTONES */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 13px 20px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  transition: var(--transition);
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
  margin-top: 6px;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid #374151;
}

.btn-secondary:hover {
  background: #1f2937;
  color: var(--text-main);
}

.btn-control {
  background: #1f2937;
  color: var(--text-main);
  border: 1px solid #374151;
  flex: 1;
}

.btn-control:hover {
  background: #283548;
}

.btn-control.muted {
  background: rgba(239, 68, 68, 0.15);
  border-color: var(--danger);
  color: #fca5a5;
}

.error-msg {
  font-size: 0.85rem;
  color: var(--danger);
  min-height: 1.2rem;
  text-align: center;
}

/* PANTALLA DE SESIÓN ACTIVA */
.session-card {
  text-align: center;
  padding-top: 24px;
}

.session-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 40px;
}

.room-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #1f2937;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

.room-pill .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
}

.badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 12px;
}

.badge-waiting {
  background: rgba(245, 158, 11, 0.15);
  color: var(--warning);
}

.badge-active {
  background: rgba(16, 185, 129, 0.15);
  color: var(--success);
}

.badge-ended {
  background: rgba(156, 163, 175, 0.15);
  color: var(--text-muted);
}

/* INDICADOR CENTRAL Y PULSO DE AUDIO */
.indicator-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 40px;
}

.visualizer-container {
  position: relative;
  width: 150px;
  height: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 24px;
}

.mic-circle {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  box-shadow: 0 10px 20px rgba(37, 99, 235, 0.35);
  transition: var(--transition);
}

.mic-circle.muted {
  background: linear-gradient(135deg, #dc2626, #991b1b);
  box-shadow: 0 10px 20px rgba(220, 38, 38, 0.35);
}

.pulse-ring {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--pulse-color);
  opacity: 0;
  z-index: 1;
  pointer-events: none;
}

/* Animación de pulso cuando está grabando y no silenciado */
.visualizer-container.recording .pulse-1 {
  animation: pulse-wave 2.2s infinite ease-out 0s;
}

.visualizer-container.recording .pulse-2 {
  animation: pulse-wave 2.2s infinite ease-out 0.7s;
}

.visualizer-container.recording .pulse-3 {
  animation: pulse-wave 2.2s infinite ease-out 1.4s;
}

.visualizer-container.muted .pulse-ring {
  animation: none !important;
  opacity: 0 !important;
}

@keyframes pulse-wave {
  0% {
    transform: scale(0.6);
    opacity: 0.8;
  }
  100% {
    transform: scale(1.6);
    opacity: 0;
  }
}

.status-label {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.status-sub {
  font-size: 0.85rem;
  color: var(--text-muted);
  max-width: 280px;
  line-height: 1.4;
}

/* CONTROLES */
.session-controls {
  display: flex;
  gap: 12px;
}

.hidden {
  display: none !important;
}

/* ==============================================================================
   PANEL DE AUTOCORRECCIÓN GUIADA
   ============================================================================== */

.guided-modal {
  position: fixed;
  inset: 0;
  background: rgba(11, 15, 25, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
  opacity: 1;
  transition: opacity 0.25s ease;
}

.guided-modal.hidden {
  display: none !important;
  opacity: 0;
}

.guided-card {
  background: #111827;
  border: 1px solid #1f2937;
  border-radius: var(--radius);
  width: 100%;
  max-width: 440px;
  padding: 24px 22px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(59, 130, 246, 0.2);
  animation: guidedCardEnter 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes guidedCardEnter {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.guided-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.guided-badge-group {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.guided-pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #3b82f6;
  box-shadow: 0 0 8px #3b82f6;
  animation: pulseDot 1.5s infinite;
}

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

.guided-badge {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 3px 9px;
  border-radius: 6px;
  background: rgba(59, 130, 246, 0.2);
  color: #60a5fa;
}

.guided-badge.cat-grammar { background: rgba(59, 130, 246, 0.2); color: #60a5fa; }
.guided-badge.cat-vocabulary { background: rgba(168, 85, 247, 0.2); color: #c084fc; }
.guided-badge.cat-pronunciation { background: rgba(16, 185, 129, 0.2); color: #34d399; }
.guided-badge.cat-upgrade_c1 { background: rgba(245, 158, 11, 0.2); color: #fbbf24; }
.guided-badge.cat-fluency { background: rgba(236, 72, 153, 0.2); color: #f472b6; }

.guided-tag {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

.guided-top-right {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.modal-close-btn {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #94a3b8;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
  transition: all 0.2s ease;
  padding: 0;
}

.modal-close-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.3);
  transform: scale(1.06);
}

.guided-content {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.guided-section {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.guided-section-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.guided-context-text {
  font-size: 0.88rem;
  font-style: italic;
  color: #94a3b8;
  background: rgba(15, 23, 42, 0.6);
  padding: 8px 12px;
  border-radius: 8px;
  border-left: 3px solid #64748b;
  line-height: 1.4;
}

.guided-student-quote {
  font-size: 1.05rem;
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.1);
  border-left: 3px solid var(--danger);
  padding: 10px 14px;
  border-radius: 8px;
  line-height: 1.5;
  font-weight: 500;
}

.guided-student-quote .highlight-error {
  background: rgba(239, 68, 68, 0.3);
  color: #ffffff;
  padding: 1px 4px;
  border-radius: 3px;
  text-decoration: underline wavy var(--danger);
  font-weight: 600;
}

.guided-prompt-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.3);
  padding: 10px 14px;
  border-radius: 8px;
  color: #93c5fd;
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.35;
}

.guided-prompt-banner svg {
  flex-shrink: 0;
  color: #3b82f6;
}

/* Solución Revelada */
.guided-solution-container {
  animation: solutionReveal 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.guided-solution-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.35);
  border-left: 4px solid var(--success);
  padding: 12px 14px;
  border-radius: 8px;
}

.guided-solution-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #34d399;
}

.guided-solution-text {
  font-size: 1.05rem;
  color: #86efac;
  font-weight: 600;
  line-height: 1.45;
}

.guided-solution-text .highlight-fix {
  background: rgba(46, 160, 67, 0.35);
  color: #ffffff;
  padding: 1px 4px;
  border-radius: 3px;
  font-weight: 700;
}

.guided-explanation-text {
  font-size: 0.82rem;
  color: #cbd5e1;
  line-height: 1.4;
  margin-top: 4px;
  padding-top: 6px;
  border-top: 1px dashed rgba(255, 255, 255, 0.1);
}

/* ==============================================================================
   FASE 2: MICRO-EJERCICIOS INTERACTIVOS CON IA (STUDENT-WEB)
   ============================================================================== */

.exercise-modal-card {
  border-color: rgba(168, 85, 247, 0.4);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(168, 85, 247, 0.25);
}

.guided-pulse-dot.exercise-dot {
  background: #a855f7;
  box-shadow: 0 0 8px #a855f7;
}

.exercise-instruction-banner {
  color: #94a3b8;
  font-size: 0.88rem;
  font-weight: 500;
  line-height: 1.4;
}

.exercise-sentence-box {
  background: rgba(15, 23, 42, 0.7);
  border-left: 3px solid #a855f7;
  padding: 14px 16px;
  border-radius: 8px;
  font-size: 1.08rem;
  line-height: 1.6;
  color: #f8fafc;
}

.exercise-sentence-box .prompt-blank {
  background: rgba(168, 85, 247, 0.25);
  border-bottom: 2px dashed #c084fc;
  padding: 2px 10px;
  border-radius: 4px;
  font-weight: 700;
  color: #f3e8ff;
  display: inline-block;
}

.exercise-options-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
}

.exercise-option-btn {
  background: #1f2937;
  border: 1px solid #374151;
  color: #f3f4f6;
  border-radius: 10px;
  padding: 13px 18px;
  font-size: 1.02rem;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  outline: none;
}

.exercise-option-btn:hover:not(:disabled) {
  background: #374151;
  border-color: #a855f7;
  transform: translateY(-1px);
}

.exercise-option-btn:disabled {
  cursor: default;
}

.exercise-option-btn.option-correct {
  background: rgba(16, 185, 129, 0.22) !important;
  border-color: #10b981 !important;
  color: #34d399 !important;
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.35);
}

.exercise-option-btn.option-wrong {
  background: rgba(239, 68, 68, 0.2) !important;
  border-color: #ef4444 !important;
  color: #f87171 !important;
  text-decoration: line-through;
}

.exercise-feedback-container {
  animation: solutionReveal 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  margin-top: 6px;
}

.exercise-feedback-box {
  background: rgba(17, 24, 39, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 12px 14px;
  border-radius: 8px;
}

.exercise-feedback-title {
  display: block;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.exercise-feedback-title.correct {
  color: #34d399;
}

.exercise-feedback-title.incorrect {
  color: #f87171;
}

.exercise-feedback-text {
  font-size: 0.88rem;
  color: #cbd5e1;
  line-height: 1.4;
  margin: 0;
}

/* FORMATO 2: SPOT THE ERROR */
.exercise-spot-segments {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.spot-segment-btn {
  background: #1f2937;
  border: 1px solid #374151;
  color: #f3f4f6;
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 0.98rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  outline: none;
}

.spot-segment-btn:hover:not(:disabled) {
  background: #374151;
  border-color: #a855f7;
  transform: translateY(-1px);
}

.spot-segment-btn:disabled {
  cursor: default;
}

.spot-segment-btn.option-wrong {
  background: rgba(239, 68, 68, 0.22) !important;
  border-color: #ef4444 !important;
  color: #f87171 !important;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.3);
  text-decoration: underline wavy #ef4444;
}

.spot-segment-btn.option-correct {
  background: rgba(16, 185, 129, 0.22) !important;
  border-color: #10b981 !important;
  color: #34d399 !important;
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.35);
}

/* FORMATO 3: KEY WORD TRANSFORMATION */
.exercise-transform-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.transform-base-box,
.transform-template-box {
  background: rgba(15, 23, 42, 0.7);
  border-left: 3px solid #64748b;
  padding: 10px 14px;
  border-radius: 6px;
}

.transform-template-box {
  border-left-color: #a855f7;
}

.transform-box-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.exercise-transform-base {
  font-size: 0.95rem;
  font-style: italic;
  color: #cbd5e1;
  margin: 0;
  line-height: 1.4;
}

.exercise-transform-template {
  font-size: 1.02rem;
  color: #f8fafc;
  margin: 0;
  line-height: 1.5;
}

.transform-keyword-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.transform-keyword-chip {
  background: rgba(168, 85, 247, 0.25);
  border: 1px solid rgba(168, 85, 247, 0.5);
  color: #c084fc;
  font-size: 0.92rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  padding: 4px 12px;
  border-radius: 6px;
}

.exercise-input-group {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.exercise-text-input {
  flex: 1;
  background: #1f2937;
  border: 1px solid #374151;
  color: #ffffff;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s ease;
}

.exercise-text-input:focus {
  border-color: #a855f7;
  box-shadow: 0 0 0 2px rgba(168, 85, 247, 0.2);
}

.btn-submit-exercise {
  padding: 10px 16px;
  font-size: 0.88rem;
  font-weight: 700;
  white-space: nowrap;
}

.exercise-feedback-solution {
  font-size: 0.9rem;
  color: #86efac;
  background: rgba(35, 134, 54, 0.15);
  border-left: 3px solid #10b981;
  padding: 8px 12px;
  border-radius: 4px;
  margin: 6px 0;
  font-weight: 600;
}

/* Polaridad del ejercicio en Student Web */
.exercise-polarity-tag {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 9999px;
  letter-spacing: 0.02em;
}

.exercise-polarity-tag.polarity-target {
  background: rgba(16, 185, 129, 0.18);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.exercise-polarity-tag.polarity-contrast {
  background: rgba(245, 158, 11, 0.18);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.4);
}

/* FORMATO 4: ERROR CORRECTION INPUT */
.correction-sentence-box {
  border-left-color: #f59e0b;
}

.exercise-faulty-sentence {
  font-size: 1rem;
  color: #f8fafc;
  line-height: 1.45;
  margin: 4px 0 0;
  font-style: italic;
}

/* FORMATO 5: SENTENCE UNSCRAMBLE */
.exercise-unscramble-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.unscramble-result-box {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(168, 85, 247, 0.35);
  border-radius: 8px;
  padding: 12px 14px;
  min-height: 52px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.unscramble-result-text {
  font-size: 1rem;
  color: #f8fafc;
  line-height: 1.45;
  margin: 0;
  min-height: 24px;
}

.unscramble-bank {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 4px 0;
}

.unscramble-chip {
  background: #1f2937;
  border: 1px solid #374151;
  color: #f3f4f6;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.unscramble-chip:hover:not(:disabled) {
  background: #374151;
  border-color: #a855f7;
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.unscramble-chip.chip-used {
  opacity: 0.35;
  pointer-events: none;
  background: #111827;
  border-color: #1f2937;
  text-decoration: line-through;
}

.unscramble-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

.btn-clear-unscramble {
  padding: 8px 14px;
  font-size: 0.84rem;
}

/* FORMATO 6: OPEN CLOZE */
.cloze-input-group {
  max-width: 480px;
}

.exercise-cloze-input {
  max-width: 260px;
  font-weight: 600;
  letter-spacing: 0.03em;
}

