/* ==========================================================================
   AI Speech Recognition & Pronunciation Shadowing Trainer Styles
   ========================================================================== */

.speech-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(5px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: speechFadeIn 0.2s ease;
}

@keyframes speechFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.speech-modal-card {
  background: #ffffff;
  border-radius: 24px;
  width: min(780px, 100%);
  max-height: 94vh;
  overflow-y: auto;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.28);
  position: relative;
  display: flex;
  flex-direction: column;
}

.speech-modal-header {
  padding: 20px 28px;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.speech-modal-header h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
  color: #0f172a;
  display: flex;
  align-items: center;
  gap: 8px;
}

.speech-level-selector {
  display: flex;
  gap: 12px;
  padding: 16px 28px 0;
  align-items: center;
  flex-wrap: wrap;
}

.speech-lvl-btn {
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  color: #475569;
  padding: 8px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.speech-lvl-btn:hover {
  background: #f1f5f9;
}

.speech-lvl-btn.active {
  background: #6657d9;
  color: #ffffff;
  border-color: #6657d9;
  box-shadow: 0 4px 12px rgba(102, 87, 217, 0.25);
}

.speech-lesson-select {
  border: 1.5px solid #cbd5e1;
  background: #ffffff;
  border-radius: 10px;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 600;
  color: #334155;
  outline: none;
  cursor: pointer;
  max-width: 280px;
  transition: border-color 0.2s;
}

.speech-lesson-select:focus {
  border-color: #6657d9;
  box-shadow: 0 0 0 3px rgba(102, 87, 217, 0.15);
}

.speech-random-btn {
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  color: #475569;
  padding: 6px 12px;
  border-radius: 9px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.speech-random-btn:hover {
  background: #ede9fe;
  color: #6657d9;
  border-color: #c4b5fd;
}

.speech-modal-body {
  padding: 20px 28px 28px;
}

/* Target Sentence Display */
.speech-target-box {
  background: #faf5ff;
  border: 2px solid #ede9fe;
  border-radius: 20px;
  padding: 28px 24px 24px;
  text-align: center;
  margin-bottom: 22px;
  position: relative;
}

.speech-lesson-tag {
  position: absolute;
  top: 12px;
  left: 14px;
  background: #ede9fe;
  color: #6657d9;
  font-size: 11px;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 6px;
  letter-spacing: 0.05em;
}

.speech-target-hanzi {
  font-family: STKaiti, KaiTi, 'KaiTi SC', serif;
  font-size: 38px;
  color: #1e1b4b;
  margin-bottom: 8px;
  line-height: 1.35;
}

.speech-target-pinyin {
  font-size: 18px;
  font-weight: 700;
  color: #6657d9;
  margin-bottom: 6px;
}

.speech-target-vi {
  font-size: 15px;
  color: #64748b;
  line-height: 1.4;
}

/* Action Controls (Audio, Mic, Playback & Comparison) */
.speech-actions {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.speech-btn-prev,
.speech-btn-listen,
.speech-btn-user,
.speech-btn-compare,
.speech-btn-next {
  background: #f1f5f9;
  color: #334155;
  border: 1px solid #cbd5e1;
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
  user-select: none;
}

.speech-btn-prev:hover,
.speech-btn-listen:hover {
  background: #e2e8f0;
}

.speech-btn-user:hover:not(:disabled),
.speech-btn-compare:hover:not(:disabled) {
  background: #e2e8f0;
}

.speech-btn-user:disabled,
.speech-btn-compare:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.speech-btn-user.is-playing-user {
  background: #dcfce7 !important;
  color: #15803d !important;
  border-color: #86efac !important;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.2);
}

.speech-btn-listen.is-playing-sample {
  background: #e0e7ff !important;
  color: #3730a3 !important;
  border-color: #a5b4fc !important;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.speech-btn-compare.is-comparing {
  background: #fef3c7 !important;
  color: #92400e !important;
  border-color: #fcd34d !important;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.2);
}

.speech-btn-next {
  background: #6657d9;
  color: #ffffff;
  border: 0;
}

.speech-btn-next:hover {
  background: #5849c8;
}

.speech-btn-mic {
  background: #dc2626;
  color: #ffffff;
  border: 0;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  font-size: 26px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 20px rgba(220, 38, 38, 0.35);
  transition: all 0.2s ease;
  position: relative;
  flex-shrink: 0;
}

.speech-btn-mic:hover {
  transform: scale(1.06);
}

.speech-btn-mic.recording {
  animation: speechPulse 1.2s infinite ease-in-out;
  background: #ef4444;
}

@keyframes speechPulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
  }
  50% {
    box-shadow: 0 0 0 16px rgba(239, 68, 68, 0);
  }
}

.speech-status-text {
  text-align: center;
  font-size: 13.5px;
  color: #475569;
  margin-bottom: 16px;
  min-height: 22px;
}

/* Evaluation Card */
.speech-eval-card {
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 18px 20px;
  background: #ffffff;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.03);
}

.speech-eval-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.speech-score-badge {
  font-size: 16px;
  font-weight: 900;
  padding: 5px 14px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.speech-score-high { background: #dcfce7; color: #15803d; }
.speech-score-mid { background: #fef9c3; color: #854d0e; }
.speech-score-low { background: #fee2e2; color: #b91c1c; }

.speech-transcript-box {
  background: #f8fafc;
  border-radius: 12px;
  padding: 12px 16px;
  margin: 10px 0;
  font-size: 16px;
  line-height: 1.6;
}

.speech-char-match {
  color: #16a34a;
  font-weight: 800;
  border-bottom: 2px solid #86efac;
}

.speech-char-miss {
  color: #dc2626;
  font-weight: 800;
  background: #fee2e2;
  border-radius: 4px;
  padding: 0 2px;
}

.speech-feedback-text {
  font-size: 13.5px;
  font-weight: 600;
  color: #334155;
  margin-top: 8px;
}

@media (max-width: 680px) {
  .speech-actions {
    gap: 8px;
  }
  .speech-btn-prev,
  .speech-btn-listen,
  .speech-btn-user,
  .speech-btn-compare,
  .speech-btn-next {
    padding: 8px 12px;
    font-size: 12px;
  }
  .speech-btn-mic {
    width: 54px;
    height: 54px;
    font-size: 22px;
  }
  .speech-target-hanzi {
    font-size: 28px;
  }
  .speech-target-box {
    padding: 24px 16px 18px;
  }
}
