/* ==========================================================================
   speak.css - Luyện phát âm tiếng Trung (Pronunciation Practice Stylesheet)
   Kế thừa hệ thống biến giao diện từ style.css & themes.css (Sáng/Tối, 360px+)
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Wrapper & Khung Chứa Chính
   -------------------------------------------------------------------------- */
.speak-app-wrapper {
  max-width: 860px;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
  width: 100%;
  box-sizing: border-box;
  overflow-x: hidden;
  font-family: var(--font-base, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);
  color: var(--text, var(--text-main, #1f1a17));
}

/* Header */
.speak-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border, var(--border-color, #e6ddce));
  padding-bottom: 1rem;
}

.speak-header-title {
  flex: 1;
  min-width: 260px;
}

.speak-main-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text, var(--text-main, #1f1a17));
  margin: 0 0 0.25rem 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.speak-sub-title {
  font-size: 0.875rem;
  color: var(--muted, var(--text-sub, #4b5563));
  margin: 0;
}

.badge-accent {
  background: var(--accent-light, rgba(179, 38, 30, 0.08));
  color: var(--accent, #b3261e);
  font-weight: 600;
  font-size: 0.8rem;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-full, 9999px);
  border: 1px solid var(--accent, #b3261e);
}

/* --------------------------------------------------------------------------
   2. Sub-tabs Navigation
   -------------------------------------------------------------------------- */
.speak-nav-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  border-bottom: 2px solid var(--border, var(--border-color, #e6ddce));
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
  max-width: 100%;
  scrollbar-width: thin;
}

.speak-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.15rem;
  font-size: 0.925rem;
  font-weight: 600;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  color: var(--muted, var(--text-sub, #4b5563));
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  border-radius: 6px 6px 0 0;
  flex-shrink: 0;
}

.speak-tab-btn:hover {
  color: var(--text, var(--text-main, #1f1a17));
  background: var(--surface-2, rgba(0, 0, 0, 0.03));
}

.speak-tab-btn.active {
  color: var(--accent, #b3261e);
  border-bottom-color: var(--accent, #b3261e);
  background: var(--accent-light, rgba(179, 38, 30, 0.06));
}

.speak-tab-btn .tab-icon {
  font-size: 1.1rem;
}

/* --------------------------------------------------------------------------
   3. Common Cards & UI Elements
   -------------------------------------------------------------------------- */
.speak-pitch-card,
.speak-practice-card,
.shadow-card,
.confusing-header-card,
.confusing-quiz-card,
.shadow-summary-card {
  background: var(--surface, var(--bg-card, #ffffff));
  border: 1px solid var(--border, var(--border-color, #e6ddce));
  border-radius: var(--radius-md, 12px);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-sm, 0 1px 3px rgba(0, 0, 0, 0.05));
  box-sizing: border-box;
}

.card-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.card-header-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1rem;
  color: var(--text, var(--text-main, #1f1a17));
}

.btn-primary {
  background: var(--accent, #b3261e);
  color: #ffffff;
  border: none;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-sm, 8px);
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.1);
  box-shadow: var(--shadow-sm, 0 2px 4px rgba(0, 0, 0, 0.1));
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--surface-2, #f4efe3);
  color: var(--text, var(--text-main, #1f1a17));
  border: 1px solid var(--border, var(--border-color, #e6ddce));
  font-weight: 500;
  font-size: 0.9rem;
  padding: 0.65rem 1.15rem;
  border-radius: var(--radius-sm, 8px);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-secondary:hover {
  background: var(--border, var(--border-color, #e6ddce));
}

.pill-group {
  display: inline-flex;
  gap: 0.25rem;
  background: var(--surface-2, #f4efe3);
  padding: 3px;
  border-radius: var(--radius-full, 9999px);
  border: 1px solid var(--border, var(--border-color, #e6ddce));
}

.pill-btn {
  background: transparent;
  border: none;
  padding: 0.35rem 0.85rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted, var(--text-sub, #4b5563));
  border-radius: var(--radius-full, 9999px);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.pill-btn.active {
  background: var(--accent, #b3261e);
  color: #ffffff;
  box-shadow: var(--shadow-sm);
}

.score-badge {
  font-size: 0.85rem;
  background: var(--surface-2, #f4efe3);
  border: 1px solid var(--border, var(--border-color, #e6ddce));
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-sm, 8px);
  font-weight: 600;
  color: var(--text, var(--text-main, #1f1a17));
}

/* --------------------------------------------------------------------------
   4. Tab 1: Cao Độ 5 Mức (SVG) & Luyện Thanh
   -------------------------------------------------------------------------- */
.pitch-svg-wrapper {
  width: 100%;
  max-width: 520px;
  margin: 0.5rem auto 1.25rem;
  background: var(--surface-2, #fdfbf7);
  border: 1px solid var(--border, var(--border-color, #e6ddce));
  border-radius: var(--radius-md, 12px);
  padding: 0.75rem 0.5rem 0.25rem;
  box-sizing: border-box;
}

.pitch-svg-canvas {
  width: 100%;
  height: auto;
  display: block;
}

.pitch-axis-text {
  font-size: 11px;
  fill: var(--muted, #64748b);
  font-weight: bold;
}

.pitch-grid-line {
  stroke: var(--border, #cbd5e1);
  stroke-width: 1;
}

.pitch-axis-line {
  stroke: var(--border-focus, var(--muted, #94a3b8));
  stroke-width: 1.5;
}

.pitch-curve {
  fill: none;
  stroke-width: 3.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: all 0.3s;
}

.pitch-curve.tone-1 { stroke: var(--tone-1, #3b82f6); }
.pitch-curve.tone-2 { stroke: var(--tone-2, #10b981); }
.pitch-curve.tone-3 { stroke: var(--tone-3, #f59e0b); }
.pitch-curve.tone-4 { stroke: var(--tone-4, #ef4444); }

.pitch-curve-label {
  font-size: 11px;
  font-weight: 700;
  text-anchor: middle;
}

.tone-path-group.dimmed {
  opacity: 0.25;
}

.tone-path-group.active .pitch-curve {
  stroke-width: 5.5;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

/* Grid mẹo thanh điệu */
.pitch-tips-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.pitch-tip-item {
  background: var(--surface-2, #f4efe3);
  border: 1px solid var(--border, var(--border-color, #e6ddce));
  border-left: 4px solid var(--tip-tone-color, var(--accent));
  border-radius: var(--radius-sm, 8px);
  padding: 0.75rem;
  font-size: 0.8rem;
  line-height: 1.4;
  transition: transform 0.2s, box-shadow 0.2s;
}

.pitch-tip-item.highlight {
  background: var(--accent-light, rgba(179, 38, 30, 0.08));
  border-color: var(--tip-tone-color);
  box-shadow: 0 0 0 2px var(--tip-tone-color);
  transform: translateY(-2px);
}

.tip-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.25rem;
}

.tip-badge {
  font-weight: 700;
  color: var(--tip-tone-color);
  white-space: nowrap;
}

.tip-hanzi {
  white-space: nowrap;
}

.tip-pitch {
  font-size: 0.75rem;
  color: var(--muted, #64748b);
}

.tip-desc {
  font-size: 0.85rem;
  color: var(--text, var(--text-main, #1f1a17));
  margin-bottom: 0.25rem;
}

.tip-body {
  color: var(--muted, var(--text-sub, #4b5563));
}

/* Luyện Thanh Controls */
.level-switcher-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px dashed var(--border, #e6ddce);
}

.switcher-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text, var(--text-main, #1f1a17));
}

.tone-quiz-box {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.quiz-prompt-center {
  text-align: center;
  padding: 0.5rem 0;
}

.quiz-sub-hint {
  display: block;
  font-size: 0.95rem;
  color: var(--muted, var(--text-sub, #4b5563));
  margin-bottom: 0.85rem;
}

.btn-play-audio-large {
  background: var(--surface-2, #f4efe3);
  color: var(--accent, #b3261e);
  border: 2px solid var(--accent, #b3261e);
  border-radius: var(--radius-full, 9999px);
  padding: 0.85rem 2rem;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-sm);
}

.btn-play-audio-large:hover {
  background: var(--accent, #b3261e);
  color: #ffffff;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.audio-wave-anim {
  font-size: 1.2rem;
  animation: pulse-icon 1.5s infinite ease-in-out;
}

@keyframes pulse-icon {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

/* 4 Nút chọn Thanh 1-4 */
.tone-buttons-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
}

@media (max-width: 580px) {
  .tone-buttons-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.tone-choice-btn {
  background: var(--surface, #ffffff);
  border: 2px solid var(--border, #e6ddce);
  border-radius: var(--radius-md, 12px);
  padding: 1rem 0.5rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
}

.tone-choice-btn:hover:not(:disabled) {
  border-color: var(--accent, #b3261e);
  background: var(--accent-light, rgba(179, 38, 30, 0.05));
  transform: translateY(-2px);
}

.tone-choice-num {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text, var(--text-main, #1f1a17));
}

.tone-choice-symbol {
  font-size: 1.5rem;
  font-weight: bold;
  color: var(--accent, #b3261e);
  line-height: 1;
}

.tone-choice-name {
  font-size: 0.75rem;
  color: var(--muted, #64748b);
}

.tone-choice-btn.correct {
  background: #ecfdf5 !important;
  border-color: #10b981 !important;
  color: #065f46 !important;
  box-shadow: 0 0 0 2px #10b981;
}

.tone-choice-btn.wrong {
  background: #fef2f2 !important;
  border-color: #ef4444 !important;
  color: #991b1b !important;
}

.tone-choice-btn.disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Cặp thanh Level 2 Picker */
.tone-pair-picker {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  flex-wrap: wrap;
  padding: 1rem;
  background: var(--surface-2, #f4efe3);
  border-radius: var(--radius-md, 12px);
}

.picker-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.picker-col-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted, var(--text-sub, #4b5563));
}

.pill-tone-row {
  display: flex;
  gap: 0.35rem;
}

.pill-tone-btn {
  background: var(--surface, #ffffff);
  border: 1px solid var(--border, #e6ddce);
  border-radius: var(--radius-sm, 8px);
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text, var(--text-main, #1f1a17));
  transition: all 0.15s ease;
}

.pill-tone-btn:hover:not(:disabled) {
  border-color: var(--accent, #b3261e);
}

.pill-tone-btn.selected {
  background: var(--accent, #b3261e);
  color: #ffffff;
  border-color: var(--accent, #b3261e);
  box-shadow: var(--shadow-sm);
}

.picker-divider {
  font-size: 1.5rem;
  font-weight: bold;
  color: var(--muted, #64748b);
}

.pair-submit-row {
  text-align: center;
  margin-top: 0.5rem;
}

/* Phản hồi đúng/sai */
.quiz-feedback-card {
  border-radius: var(--radius-md, 12px);
  padding: 1rem 1.25rem;
  animation: fadeIn 0.3s ease;
}

.quiz-feedback-card.correct {
  background: #ecfdf5;
  border: 1px solid #10b981;
  color: #065f46;
}

.quiz-feedback-card.wrong {
  background: #fef2f2;
  border: 1px solid #ef4444;
  color: #991b1b;
}

.feedback-msg {
  font-size: 1.05rem;
  margin-bottom: 0.35rem;
}

.feedback-detail {
  font-size: 0.9rem;
  margin-bottom: 0.85rem;
}

.target-hanzi {
  font-family: var(--font-hanzi, "Noto Sans SC", sans-serif);
  font-size: 1.25rem;
}

.target-pinyin {
  color: var(--accent, #b3261e);
  font-size: 1.1rem;
}

.feedback-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* --------------------------------------------------------------------------
   5. Tab 2: Đọc Theo (Shadowing & Voice Recognition)
   -------------------------------------------------------------------------- */
.shadow-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.progress-col {
  flex: 1;
  min-width: 180px;
}

.progress-label {
  font-size: 0.85rem;
  color: var(--muted, var(--text-sub, #4b5563));
  margin-bottom: 0.35rem;
  display: block;
}

.progress-track {
  width: 100%;
  height: 8px;
  background: var(--surface-2, #f4efe3);
  border-radius: var(--radius-full, 9999px);
  overflow: hidden;
  border: 1px solid var(--border, #e6ddce);
}

.progress-fill {
  height: 100%;
  background: var(--accent, #b3261e);
  border-radius: var(--radius-full, 9999px);
  transition: width 0.3s ease;
}

.speed-controls-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.speed-label {
  font-size: 0.85rem;
  color: var(--muted, #64748b);
}

/* Prompt Card */
.shadow-card {
  text-align: center;
  padding: 2rem 1.5rem;
}

.shadow-prompt-wrapper {
  margin-bottom: 1.5rem;
}

.shadow-pinyin {
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--accent, #b3261e);
  margin-bottom: 0.5rem;
  letter-spacing: 0.5px;
}

.shadow-hanzi {
  font-family: var(--font-hanzi, "Noto Sans SC", sans-serif);
  font-size: 2.75rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--text, var(--text-main, #1f1a17));
  margin-bottom: 0.5rem;
  word-break: break-word;
}

.shadow-vi {
  font-size: 1rem;
  color: var(--muted, var(--text-sub, #4b5563));
  font-style: italic;
}

.char-ok {
  color: #10b981;
  font-weight: bold;
}

.char-fail {
  color: #ef4444;
  font-weight: bold;
  background: rgba(239, 68, 68, 0.12);
  border-radius: 4px;
  padding: 0 4px;
}

.char-punct {
  color: var(--muted, #94a3b8);
}

.shadow-audio-bar {
  margin-bottom: 1.75rem;
}

.btn-listen-sample {
  background: var(--surface-2, #f4efe3);
  color: var(--text, var(--text-main, #1f1a17));
  border: 1px solid var(--border, #e6ddce);
  border-radius: var(--radius-full, 9999px);
  padding: 0.65rem 1.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s;
}

.btn-listen-sample:hover {
  background: var(--border, #e6ddce);
  transform: translateY(-1px);
}

/* Micro Record Controls */
.shadow-mic-area {
  margin-bottom: 1.5rem;
}

.recognition-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.btn-mic-record {
  background: var(--accent, #b3261e);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-full, 9999px);
  padding: 1rem 2.25rem;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  box-shadow: 0 4px 14px rgba(179, 38, 30, 0.3);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-mic-record:hover {
  filter: brightness(1.1);
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(179, 38, 30, 0.4);
}

.btn-mic-record.recording {
  background: #dc2626 !important;
  animation: pulse-ring 1.5s infinite;
}

@keyframes pulse-ring {
  0% {
    transform: scale(0.98);
    box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.7);
  }
  70% {
    transform: scale(1.04);
    box-shadow: 0 0 0 16px rgba(220, 38, 38, 0);
  }
  100% {
    transform: scale(0.98);
    box-shadow: 0 0 0 0 rgba(220, 38, 38, 0);
  }
}

.mic-status-msg {
  font-size: 0.85rem;
  color: var(--muted, var(--text-sub, #4b5563));
}

/* MediaRecorder Fallback Box */
.media-recorder-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: var(--surface-2, #f4efe3);
  border-radius: var(--radius-md, 12px);
}

.rec-controls-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: center;
}

.btn-rec {
  background: #dc2626;
  color: #fff;
  border: none;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-full, 9999px);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-rec.recording {
  animation: pulse-ring 1.5s infinite;
}

.btn-play-rec,
.btn-play-sample-again {
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e6ddce);
  padding: 0.65rem 1.15rem;
  border-radius: var(--radius-full, 9999px);
  font-weight: 600;
  cursor: pointer;
  color: var(--text, var(--text-main, #1f1a17));
}

.self-eval-box {
  margin-top: 0.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.eval-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text, var(--text-main, #1f1a17));
}

.eval-buttons {
  display: flex;
  gap: 0.75rem;
}

.btn-eval {
  padding: 0.6rem 1.25rem;
  border-radius: var(--radius-sm, 8px);
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}

.btn-eval.pass {
  background: #10b981;
  color: #fff;
}

.btn-eval.retry {
  background: #f59e0b;
  color: #fff;
}

/* Feedback sau nhận diện */
.recognition-feedback-box {
  border-radius: var(--radius-md, 12px);
  padding: 1rem;
  margin-bottom: 1.5rem;
  text-align: left;
}

.recognition-feedback-box.pass {
  background: #ecfdf5;
  border: 1px solid #10b981;
}

.recognition-feedback-box.retry {
  background: #fffbeb;
  border: 1px solid #f59e0b;
}

.feedback-score-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.score-pill {
  font-size: 0.95rem;
  font-weight: 700;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-full, 9999px);
}

.score-pill.pass {
  background: #10b981;
  color: #ffffff;
}

.score-pill.retry {
  background: #f59e0b;
  color: #ffffff;
}

.status-badge-text {
  font-weight: 700;
  font-size: 0.95rem;
}

.heard-text-row {
  font-size: 0.9rem;
  color: #4b5563;
  margin-top: 0.25rem;
}

.heard-text-row .label {
  font-weight: 600;
}

.heard-content {
  font-family: var(--font-hanzi, "Noto Sans SC", sans-serif);
  font-weight: 600;
  color: var(--text-main, #0f172a);
}

.shadow-actions-bottom {
  display: flex;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.shadow-footer-hint {
  font-size: 0.8rem;
  text-align: center;
  color: var(--muted, #64748b);
  margin-top: 0.5rem;
}

/* Shadow Summary Card */
.shadow-summary-card {
  text-align: center;
  padding: 2.5rem 1.5rem;
}

.summary-icon {
  font-size: 3rem;
  margin-bottom: 0.5rem;
}

.summary-title {
  font-size: 1.6rem;
  font-weight: 700;
  margin: 0 0 0.5rem 0;
  color: var(--text, var(--text-main, #1f1a17));
}

.summary-sub {
  font-size: 0.95rem;
  color: var(--muted, var(--text-sub, #4b5563));
  margin-bottom: 1.5rem;
}

.summary-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  max-width: 420px;
  margin: 0 auto 2rem;
}

.stat-box {
  background: var(--surface-2, #f4efe3);
  border: 1px solid var(--border, #e6ddce);
  border-radius: var(--radius-md, 12px);
  padding: 1.25rem;
}

.stat-value {
  display: block;
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--accent, #b3261e);
}

.stat-name {
  font-size: 0.8rem;
  color: var(--muted, #64748b);
}

.summary-history-list {
  text-align: left;
  max-width: 580px;
  margin: 0 auto 2rem;
}

.summary-history-list h4 {
  margin: 0 0 0.75rem 0;
  font-size: 0.95rem;
  color: var(--text, var(--text-main, #1f1a17));
}

.history-item-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm, 8px);
  background: var(--surface-2, #f4efe3);
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
}

.history-item-row.pass {
  border-left: 4px solid #10b981;
}

.history-item-row.fail {
  border-left: 4px solid #ef4444;
}

.history-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.item-hanzi {
  font-family: var(--font-hanzi, "Noto Sans SC", sans-serif);
}

.item-badge.pass {
  color: #10b981;
  font-weight: 700;
}

.item-badge.fail {
  color: #ef4444;
  font-weight: 700;
}

/* --------------------------------------------------------------------------
   6. Tab 3: Âm Dễ Nhầm (Confusing Sounds)
   -------------------------------------------------------------------------- */
.filter-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.filter-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text, var(--text-main, #1f1a17));
}

.confusing-select {
  flex: 1;
  min-width: 220px;
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-sm, 8px);
  border: 1px solid var(--border, #e6ddce);
  background: var(--surface, #fff);
  color: var(--text, var(--text-main, #1f1a17));
  font-size: 0.9rem;
  font-weight: 600;
}

.confusing-tip-box {
  background: var(--surface-2, #f4efe3);
  border-radius: var(--radius-sm, 8px);
  padding: 0.85rem 1rem;
  border-left: 3px solid var(--accent, #b3261e);
}

.tip-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent, #b3261e);
  margin-bottom: 0.35rem;
}

.tip-content {
  font-size: 0.825rem;
  color: var(--text, var(--text-main, #1f1a17));
  line-height: 1.5;
}

.quiz-top-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  font-size: 0.85rem;
  color: var(--muted, #64748b);
}

.quiz-audio-center {
  text-align: center;
  margin-bottom: 1.5rem;
}

.sub-instruction {
  display: block;
  font-size: 0.9rem;
  color: var(--muted, var(--text-sub, #4b5563));
  margin-bottom: 0.75rem;
}

.confusing-options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.confusing-opt-btn {
  background: var(--surface, #ffffff);
  border: 2px solid var(--border, #e6ddce);
  border-radius: var(--radius-md, 12px);
  padding: 1.25rem 0.75rem;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s ease;
}

.confusing-opt-btn:hover:not(:disabled) {
  border-color: var(--accent, #b3261e);
  background: var(--accent-light, rgba(179, 38, 30, 0.05));
  transform: translateY(-2px);
}

.opt-pinyin {
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--text, var(--text-main, #1f1a17));
}

.confusing-opt-btn.correct {
  background: #ecfdf5 !important;
  border-color: #10b981 !important;
  box-shadow: 0 0 0 2px #10b981;
}

.confusing-opt-btn.wrong {
  background: #fef2f2 !important;
  border-color: #ef4444 !important;
}

.confusing-opt-btn.disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Nghe đối chiếu từng âm cạnh nhau */
.side-by-side-audio-compare {
  margin: 0.85rem 0 1rem;
  padding: 0.75rem;
  background: var(--surface, #ffffff);
  border-radius: var(--radius-sm, 8px);
  border: 1px dashed var(--border, #e6ddce);
}

.compare-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted, #64748b);
  display: block;
  margin-bottom: 0.5rem;
}

.compare-buttons-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.btn-compare-audio {
  background: var(--surface-2, #f4efe3);
  border: 1px solid var(--border, #e6ddce);
  border-radius: var(--radius-full, 9999px);
  padding: 0.4rem 0.85rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text, var(--text-main, #1f1a17));
  transition: all 0.15s;
}

.btn-compare-audio:hover {
  background: var(--accent, #b3261e);
  color: #fff;
  border-color: var(--accent, #b3261e);
}

/* --------------------------------------------------------------------------
   7. Dark Theme Adjustments (html[data-theme="dark"])
   -------------------------------------------------------------------------- */
[data-theme="dark"] .speak-pitch-card,
[data-theme="dark"] .speak-practice-card,
[data-theme="dark"] .shadow-card,
[data-theme="dark"] .confusing-header-card,
[data-theme="dark"] .confusing-quiz-card,
[data-theme="dark"] .shadow-summary-card,
[data-theme="dark"] .side-by-side-audio-compare {
  background: var(--surface, #221b17);
  border-color: var(--border, #382c26);
}

[data-theme="dark"] .pitch-svg-wrapper,
[data-theme="dark"] .pitch-tip-item,
[data-theme="dark"] .tone-pair-picker,
[data-theme="dark"] .media-recorder-box,
[data-theme="dark"] .confusing-tip-box,
[data-theme="dark"] .history-item-row,
[data-theme="dark"] .stat-box {
  background: var(--surface-2, #2c221e);
  border-color: var(--border, #382c26);
}

[data-theme="dark"] .pitch-grid-line {
  stroke: #382c26;
}

[data-theme="dark"] .pitch-axis-text {
  fill: #a1a1aa;
}

[data-theme="dark"] .pitch-axis-line {
  stroke: #71717a;
}

[data-theme="dark"] .tone-choice-btn,
[data-theme="dark"] .confusing-opt-btn,
[data-theme="dark"] .pill-tone-btn,
[data-theme="dark"] .confusing-select {
  background: var(--surface, #221b17);
  border-color: var(--border, #382c26);
  color: var(--text, #faf6ee);
}

[data-theme="dark"] .btn-secondary,
[data-theme="dark"] .btn-listen-sample,
[data-theme="dark"] .btn-play-audio-large,
[data-theme="dark"] .btn-compare-audio {
  background: var(--surface-2, #2c221e);
  border-color: var(--border, #382c26);
}

[data-theme="dark"] .quiz-feedback-card.correct,
[data-theme="dark"] .recognition-feedback-box.pass {
  background: rgba(16, 185, 129, 0.15);
  border-color: #10b981;
  color: #34d399;
}

[data-theme="dark"] .quiz-feedback-card.wrong,
[data-theme="dark"] .recognition-feedback-box.retry {
  background: rgba(239, 68, 68, 0.15);
  border-color: #ef4444;
  color: #f87171;
}

[data-theme="dark"] .heard-text-row {
  color: #a1a1aa;
}

[data-theme="dark"] .heard-content {
  color: #f8fafc;
}

/* --------------------------------------------------------------------------
   8. Responsive Layout (Down to 360px without horizontal scroll)
   -------------------------------------------------------------------------- */
@media (max-width: 560px) {
  .speak-nav-tabs {
    gap: 0.35rem;
    padding-bottom: 6px;
    overflow-x: auto !important;
    scrollbar-width: thin;
    max-width: 100%;
  }

  .speak-tab-btn {
    padding: 0.5rem 0.75rem;
    font-size: 0.82rem;
    flex-shrink: 0;
  }

  .pitch-tips-grid {
    grid-template-columns: 1fr !important;
    gap: 0.65rem;
  }
}

@media (max-width: 480px) {
  .speak-app-wrapper {
    padding: 1rem 0.5rem 2.5rem;
  }

  .speak-main-title {
    font-size: 1.25rem;
  }

  .shadow-hanzi {
    font-size: 2.15rem;
  }

  .shadow-pinyin {
    font-size: 1.15rem;
  }

  .btn-play-audio-large {
    padding: 0.75rem 1.25rem;
    font-size: 0.95rem;
  }

  .btn-mic-record {
    padding: 0.85rem 1.5rem;
    font-size: 1rem;
  }

  .pitch-tips-grid {
    grid-template-columns: 1fr;
  }

  .tone-pair-picker {
    flex-direction: column;
    gap: 0.75rem;
  }

  .picker-divider {
    display: none;
  }
}

/* --------------------------------------------------------------------------
   8. English Pronunciation Specific Styles (Chủ đề Tiếng Anh)
   -------------------------------------------------------------------------- */
.speak-english-theme .speak-main-title {
  color: var(--accent, #14213d);
}

.speak-english-theme .badge-accent {
  background: var(--accent-light, rgba(20, 33, 61, 0.08));
  color: var(--accent, #14213d);
  border-color: var(--accent-2, #b08d57);
}

/* Tab 1: Quy tắc nhấn âm & Thẻ câu hỏi */
.stress-rules-card {
  background: var(--surface-2, #f4efe6);
  border: 1px solid var(--border, #dfd7c7);
  border-radius: var(--radius-md, 12px);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.stress-rules-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--accent, #14213d);
  margin-bottom: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.stress-rules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0.75rem;
}

.stress-rule-card {
  background: var(--surface, #ffffff);
  border: 1px solid var(--border, #dfd7c7);
  border-radius: var(--radius-sm, 8px);
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.stress-rule-badge {
  align-self: flex-start;
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--accent-light, rgba(20, 33, 61, 0.08));
  color: var(--accent, #14213d);
  border: 1px solid var(--accent-2, #b08d57);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
}

.stress-rule-desc {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text, #1f2937);
  line-height: 1.4;
}

.stress-rule-eg {
  font-size: 0.82rem;
  color: var(--muted, #4b5563);
  font-style: italic;
}

.stress-card {
  text-align: center;
  padding: 1.75rem 1.25rem;
}

.stress-display-target {
  margin: 1.25rem 0 1.5rem;
}

.stress-target-word {
  font-size: 2.25rem;
  font-weight: 800;
  color: var(--accent, #14213d);
  letter-spacing: 0.03em;
  margin-bottom: 0.35rem;
}

.stress-target-ipa {
  font-size: 1.2rem;
  color: var(--accent-2, #b08d57);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  margin-bottom: 0.35rem;
}

.stress-target-meaning {
  font-size: 0.95rem;
  color: var(--muted, #4b5563);
}

.stress-syllable-buttons-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
  margin: 1.5rem 0;
}

.stress-syllable-btn {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  min-width: 90px;
  padding: 0.85rem 1.25rem;
  background: var(--surface, #ffffff);
  border: 2px solid var(--border, #dfd7c7);
  border-radius: var(--radius-md, 12px);
  cursor: pointer;
  transition: all 0.2s ease;
}

.stress-syllable-btn:hover:not(:disabled) {
  border-color: var(--accent, #14213d);
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
}

.stress-syllable-btn .syl-idx {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted, #4b5563);
}

.stress-syllable-btn .syl-txt {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--accent, #14213d);
}

.stress-syllable-btn.correct {
  background: #ecfdf5 !important;
  border-color: #10b981 !important;
  box-shadow: 0 0 0 2px #10b981;
}

.stress-syllable-btn.wrong {
  background: #fef2f2 !important;
  border-color: #ef4444 !important;
}

.stress-syllable-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* Shadowing English: Toggles & Dictation */
.shadow-toggle-group {
  display: inline-flex;
  gap: 0.35rem;
  background: var(--surface-2, #f4efe6);
  padding: 3px;
  border-radius: var(--radius-full, 9999px);
  border: 1px solid var(--border, #dfd7c7);
}

.shadow-toggle-btn {
  background: transparent;
  border: none;
  padding: 0.4rem 0.95rem;
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--muted, #4b5563);
  border-radius: var(--radius-full, 9999px);
  cursor: pointer;
  transition: all 0.15s ease;
}

.shadow-toggle-btn.active {
  background: var(--accent, #14213d);
  color: #ffffff;
  box-shadow: var(--shadow-sm, 0 1px 3px rgba(0,0,0,0.1));
}

.dictation-box {
  margin-top: 1.25rem;
  background: var(--surface-2, #f4efe6);
  border: 1px solid var(--border, #dfd7c7);
  border-radius: var(--radius-md, 12px);
  padding: 1rem;
  text-align: left;
}

.dictation-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text, #1f2937);
  margin-bottom: 0.6rem;
}

.dictation-input-row {
  display: flex;
  gap: 0.5rem;
}

.dictation-input {
  flex: 1;
  padding: 0.65rem 0.95rem;
  border-radius: var(--radius-sm, 8px);
  border: 1px solid var(--border, #dfd7c7);
  background: var(--surface, #ffffff);
  color: var(--text, #1f2937);
  font-size: 0.95rem;
}

.dictation-input:focus {
  outline: none;
  border-color: var(--accent, #14213d);
  box-shadow: 0 0 0 2px rgba(20, 33, 61, 0.15);
}

.dictation-check-btn {
  padding: 0.65rem 1.15rem;
  font-weight: 600;
  font-size: 0.9rem;
  border-radius: var(--radius-sm, 8px);
  background: var(--accent, #14213d);
  color: #ffffff;
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
}

.dictation-check-btn:hover {
  filter: brightness(1.15);
}

/* Tab 3: Confusing Sounds (Minimal pairs & Ending sounds) */
.confusing-category-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.confusing-cat-btn {
  background: var(--surface-2, #f4efe6);
  border: 1px solid var(--border, #dfd7c7);
  border-radius: var(--radius-full, 9999px);
  padding: 0.45rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted, #4b5563);
  cursor: pointer;
  transition: all 0.15s ease;
}

.confusing-cat-btn.active {
  background: var(--accent, #14213d);
  color: #ffffff;
  border-color: var(--accent, #14213d);
}

.confusing-options-grid.two-cols {
  grid-template-columns: repeat(2, minmax(130px, 1fr));
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
}

.confusing-options-grid.three-cols {
  grid-template-columns: repeat(3, minmax(110px, 1fr));
  max-width: 540px;
  margin-left: auto;
  margin-right: auto;
}

.confusing-opt-btn .opt-word {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text, #1f2937);
  display: block;
}

.confusing-opt-btn .opt-ipa {
  font-size: 0.95rem;
  color: var(--accent-2, #b08d57);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  margin-top: 0.25rem;
  display: block;
}

@media (max-width: 480px) {
  .confusing-options-grid.two-cols,
  .confusing-options-grid.three-cols {
    grid-template-columns: 1fr;
  }
}

