/* ==========================================================================
   talk.css - Giao diện Luyện nói & Trò chuyện nhập vai tiếng Trung
   Đạt chuẩn: Responsive >= 360px, Sáng/Tối, CSS variables từ style.css
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Wrapper & Khung trang
   -------------------------------------------------------------------------- */
.talk-page-wrap {
  max-width: 960px;
  margin: 0 auto;
  padding: 1rem 0.75rem 2.5rem;
  width: 100%;
  box-sizing: border-box;
  font-family: var(--font-base, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);
  color: var(--text, var(--text-main, #1f1a17));
  overflow-x: hidden;
  min-width: 0;
}

/* Nav Pill Switcher */
.talk-nav-header {
  display: flex;
  justify-content: center;
  margin-bottom: 1.25rem;
  width: 100%;
}

.talk-tabs-pill {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: center;
  background: var(--bg-secondary, rgba(0, 0, 0, 0.04));
  border: 1px solid var(--border, var(--border-color, #e5e7eb));
  padding: 4px;
  border-radius: 9999px;
  gap: 4px;
  max-width: 100%;
  box-sizing: border-box;
}

.talk-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 9999px;
  border: none;
  background: transparent;
  color: var(--muted, var(--text-sub, #6b7280));
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.talk-tab-btn:hover {
  color: var(--text, var(--text-main, #111827));
}

.talk-tab-btn.active {
  background: var(--card, var(--bg-card, #ffffff));
  color: var(--accent, #b3261e);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* --------------------------------------------------------------------------
   2. Mode 1: Nói từng từ (Word Drill)
   -------------------------------------------------------------------------- */
.talk-words-container {
  max-width: 640px;
  width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
  min-width: 0;
}

.talk-words-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  padding: 0.75rem 1rem;
  background: var(--card, var(--bg-card, #ffffff));
  border: 1px solid var(--border, var(--border-color, #e5e7eb));
  border-radius: 12px;
  box-sizing: border-box;
  min-width: 0;
  width: 100%;
}

.talk-scope-selector {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  min-width: 0;
  flex: 1 1 200px;
}

.talk-scope-selector label {
  font-weight: 500;
  color: var(--muted, var(--text-sub, #4b5563));
  white-space: nowrap;
}

.talk-scope-selector select {
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.talk-progress-badge {
  font-size: 0.85rem;
  background: var(--accent-light, rgba(179, 38, 30, 0.08));
  color: var(--accent, #b3261e);
  padding: 0.25rem 0.65rem;
  border-radius: 9999px;
  font-weight: 600;
  white-space: nowrap;
}

/* Word Card */
.talk-word-card {
  background: var(--card, var(--bg-card, #ffffff));
  border: 1px solid var(--border, var(--border-color, #e5e7eb));
  border-radius: 16px;
  padding: 1.75rem 1.25rem;
  text-align: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
}

.talk-hanzi-display {
  font-size: 3.5rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--text, var(--text-main, #111827));
  margin-bottom: 0.25rem;
  line-height: 1.2;
}

.talk-pinyin-display {
  font-size: 1.5rem;
  color: var(--accent, #b3261e);
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.talk-meaning-display {
  font-size: 1.05rem;
  color: var(--muted, var(--text-sub, #4b5563));
  margin-bottom: 1.25rem;
}

.talk-audio-actions {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.talk-syllables-row {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 1.75rem;
  flex-wrap: wrap;
}

.talk-syl-chip {
  padding: 0.35rem 0.85rem;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  transition: all 0.2s;
}

.syllable-pending {
  background: var(--bg-secondary, rgba(0, 0, 0, 0.05));
  color: var(--muted, var(--text-sub, #6b7280));
  border: 1px solid var(--border, var(--border-color, #e5e7eb));
}

.syllable-correct {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #86efac;
}

.syllable-wrong {
  background: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fca5a5;
}

/* Mic Interactive Button */
.talk-mic-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 1.5rem 0;
}

.talk-big-mic-btn {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: none;
  background: var(--accent, #b3261e);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(179, 38, 30, 0.35);
  transition: all 0.25s ease;
  position: relative;
}

.talk-big-mic-btn:hover {
  transform: scale(1.05);
}

.talk-big-mic-btn.listening {
  background: #dc2626;
  animation: talk-pulse-ring 1.5s infinite;
}

@keyframes talk-pulse-ring {
  0% {
    box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.6);
  }
  70% {
    box-shadow: 0 0 0 16px rgba(220, 38, 38, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(220, 38, 38, 0);
  }
}

.talk-mic-hint {
  font-size: 0.875rem;
  color: var(--muted, var(--text-sub, #6b7280));
  margin-top: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.talk-wave-anim {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #dc2626;
  animation: talk-dot-pulse 0.8s infinite alternate;
}

@keyframes talk-dot-pulse {
  from { opacity: 0.3; transform: scale(0.8); }
  to { opacity: 1; transform: scale(1.3); }
}

.talk-interim-text {
  min-height: 1.5rem;
  font-size: 0.95rem;
  font-style: italic;
  color: var(--accent, #b3261e);
  margin-top: 0.35rem;
}

/* Feedback panel */
.talk-feedback-panel {
  border-radius: 12px;
  padding: 1rem;
  margin: 1.25rem 0;
  text-align: left;
}

.talk-feedback-panel.pass {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #166534;
}

.talk-feedback-panel.fail {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
}

.talk-feedback-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.talk-score-tag {
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  font-weight: 700;
  font-size: 0.85rem;
}

.score-green {
  background: #22c55e;
  color: #ffffff;
}

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

.talk-heard-text {
  font-size: 0.85rem;
  color: var(--muted, var(--text-sub, #4b5563));
  margin-left: auto;
}

.talk-advice-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.9rem;
}

.talk-advice-item {
  line-height: 1.4;
}

/* Card Footer */
.talk-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border, var(--border-color, #e5e7eb));
  flex-wrap: wrap;
  gap: 0.75rem;
}

.talk-footer-actions {
  display: flex;
  gap: 0.5rem;
}

/* --------------------------------------------------------------------------
   3. Mode 2: Trò chuyện nhập vai (Roleplay)
   -------------------------------------------------------------------------- */
.talk-lobby-container {
  max-width: 900px;
  margin: 0 auto;
}

.talk-lobby-intro {
  text-align: center;
  margin-bottom: 1.75rem;
}

.talk-lobby-intro h2 {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.talk-lobby-intro p {
  color: var(--muted, var(--text-sub, #6b7280));
  max-width: 600px;
  margin: 0 auto;
  font-size: 0.95rem;
}

.talk-scenarios-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}

.talk-scenario-card {
  background: var(--card, var(--bg-card, #ffffff));
  border: 1px solid var(--border, var(--border-color, #e5e7eb));
  border-radius: 14px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
  transition: transform 0.2s, box-shadow 0.2s;
}

.talk-scenario-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.06);
}

.talk-sc-top {
  display: flex;
  gap: 0.85rem;
  align-items: flex-start;
  margin-bottom: 0.75rem;
}

.talk-sc-avatar-wrap {
  flex-shrink: 0;
}

.talk-avatar-circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  color: #fff;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.talk-sc-meta {
  flex: 1;
}

.talk-badge-topic {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent, #b3261e);
  background: var(--accent-light, rgba(179, 38, 30, 0.08));
  padding: 2px 6px;
  border-radius: 4px;
  margin-bottom: 4px;
}

.talk-sc-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0 0 4px 0;
  color: var(--text, var(--text-main, #111827));
}

.talk-sc-npc-name {
  font-size: 0.8rem;
  color: var(--muted, var(--text-sub, #6b7280));
}

.talk-sc-desc {
  font-size: 0.875rem;
  color: var(--muted, var(--text-sub, #4b5563));
  line-height: 1.4;
  margin-bottom: 1.25rem;
  flex-grow: 1;
}

.talk-sc-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--border, var(--border-color, #f3f4f6));
  padding-top: 0.75rem;
  gap: 0.5rem;
}

.talk-sc-history {
  font-size: 0.8rem;
  color: var(--muted, var(--text-sub, #6b7280));
}

/* Chat Wrapper */
.talk-chat-wrapper {
  max-width: 680px;
  margin: 0 auto;
  background: var(--card, var(--bg-card, #ffffff));
  border: 1px solid var(--border, var(--border-color, #e5e7eb));
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  height: 640px;
  max-height: 80vh;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.05);
  overflow: hidden;
}

.talk-chat-header {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border, var(--border-color, #e5e7eb));
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card, #ffffff);
}

.talk-chat-header-info {
  text-align: center;
  flex: 1;
}

.talk-chat-header-info h4 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.talk-chat-npc-subtitle {
  font-size: 0.75rem;
  color: var(--muted, var(--text-sub, #6b7280));
}

/* Chat Stream Messages */
.talk-chat-stream {
  flex: 1;
  padding: 1.25rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background: var(--bg-app, var(--bg, #fdfbf7));
}

.talk-chat-bubble-wrap {
  display: flex;
  flex-direction: column;
  max-width: 82%;
}

.npc-wrap {
  align-self: flex-start;
}

.user-wrap {
  align-self: flex-end;
  align-items: flex-end;
}

.talk-chat-bubble {
  padding: 0.85rem 1.1rem;
  border-radius: 16px;
  position: relative;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.bubble-npc {
  background: var(--card, var(--bg-card, #ffffff));
  border: 1px solid var(--border, var(--border-color, #e5e7eb));
  color: var(--text, var(--text-main, #111827));
  border-bottom-left-radius: 4px;
}

.bubble-user {
  background: var(--accent, #b3261e);
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

.talk-bubble-text {
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1.4;
}

.talk-bubble-py {
  font-size: 0.85rem;
  margin-top: 0.25rem;
  opacity: 0.9;
}

.talk-bubble-vi {
  font-size: 0.85rem;
  margin-top: 0.25rem;
  opacity: 0.8;
  font-style: italic;
}

.talk-bubble-audio-btn {
  margin-top: 0.5rem;
  background: var(--bg-secondary, rgba(0, 0, 0, 0.05));
  border: none;
  border-radius: 9999px;
  padding: 3px 8px;
  font-size: 0.75rem;
  color: var(--muted, var(--text-sub, #4b5563));
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.talk-bubble-audio-btn:hover {
  background: rgba(0, 0, 0, 0.1);
}

.talk-msg-time {
  font-size: 0.7rem;
  color: var(--muted, var(--text-sub, #9ca3af));
  margin-top: 3px;
  padding: 0 4px;
}

.talk-user-eval {
  margin-top: 0.4rem;
  padding-top: 0.4rem;
  border-top: 1px solid rgba(255, 255, 255, 0.25);
  font-size: 0.75rem;
}

.talk-eval-pill {
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
}

.pill-green {
  background: #22c55e;
  color: #ffffff;
}

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

.talk-msg-advice {
  margin-top: 4px;
  font-size: 0.75rem;
  opacity: 0.95;
  line-height: 1.3;
}

/* Hint Box inside Chat */
.talk-msg-hint-box {
  align-self: center;
  max-width: 90%;
  background: #fffbeb;
  border: 1px dashed #f59e0b;
  border-radius: 12px;
  padding: 0.85rem;
  font-size: 0.875rem;
  color: #92400e;
}

.talk-hint-title {
  font-weight: 700;
  margin-bottom: 4px;
}

.talk-hint-goal {
  margin-bottom: 8px;
}

.talk-hint-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.talk-hint-ans-item {
  background: #ffffff;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid #fde68a;
  cursor: pointer;
  display: flex;
  flex-direction: column;
}

.talk-hint-ans-item:hover {
  border-color: #f59e0b;
}

.talk-hint-zh {
  font-weight: 700;
  color: #111827;
}

.talk-hint-py {
  font-size: 0.75rem;
  color: var(--accent, #b3261e);
}

.talk-hint-vi {
  font-size: 0.75rem;
  color: #6b7280;
}

/* Bottom Bar Chat Controls */
.talk-chat-bottom-bar {
  padding: 0.75rem 1rem;
  background: var(--card, var(--bg-card, #ffffff));
  border-top: 1px solid var(--border, var(--border-color, #e5e7eb));
}

.talk-goal-prompt {
  font-size: 0.85rem;
  background: var(--accent-light, rgba(179, 38, 30, 0.06));
  color: var(--text, var(--text-main, #1f1a17));
  padding: 6px 12px;
  border-radius: 8px;
  margin-bottom: 0.65rem;
  display: flex;
  align-items: center;
  gap: 6px;
}

.talk-chat-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.talk-chat-status {
  font-size: 0.8rem;
  color: var(--muted, var(--text-sub, #6b7280));
  display: flex;
  align-items: center;
  gap: 4px;
}

/* --------------------------------------------------------------------------
   4. Summary Card (Modal / End Screen)
   -------------------------------------------------------------------------- */
.talk-summary-card {
  max-width: 600px;
  margin: 1.5rem auto;
  background: var(--card, var(--bg-card, #ffffff));
  border: 1px solid var(--border, var(--border-color, #e5e7eb));
  border-radius: 16px;
  padding: 2rem 1.5rem;
  text-align: center;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

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

.talk-reward-banner {
  background: #fef3c7;
  border: 1px solid #fde68a;
  color: #92400e;
  padding: 0.65rem;
  border-radius: 8px;
  font-size: 0.9rem;
  margin: 1rem 0;
}

.talk-summary-stats-row {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin: 1.5rem 0;
  flex-wrap: wrap;
}

.talk-stat-box {
  background: var(--bg-secondary, rgba(0, 0, 0, 0.03));
  border: 1px solid var(--border, var(--border-color, #e5e7eb));
  border-radius: 12px;
  padding: 0.85rem 1.5rem;
  min-width: 100px;
}

.talk-stat-val {
  display: block;
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--accent, #b3261e);
}

.talk-stat-label {
  font-size: 0.8rem;
  color: var(--muted, var(--text-sub, #6b7280));
}

.talk-top-errors-box {
  text-align: left;
  margin: 1.25rem 0;
  background: var(--bg-secondary, rgba(0, 0, 0, 0.02));
  border-radius: 10px;
  padding: 1rem;
  border: 1px solid var(--border, var(--border-color, #e5e7eb));
}

.talk-top-errors-box h3 {
  font-size: 0.95rem;
  margin: 0 0 0.5rem 0;
}

.talk-error-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.talk-error-item {
  font-size: 0.85rem;
  line-height: 1.4;
}

.talk-err-badge {
  font-weight: 700;
  color: var(--accent, #b3261e);
  margin-right: 6px;
}

.talk-perfect-box {
  padding: 1rem;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #065f46;
  border-radius: 8px;
  font-weight: 600;
  margin: 1rem 0;
}

.talk-summary-actions {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}

/* --------------------------------------------------------------------------
   5. Dark mode adjustments
   -------------------------------------------------------------------------- */
[data-theme="dark"] .talk-tabs-pill,
body.dark .talk-tabs-pill {
  background: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .talk-tab-btn.active,
body.dark .talk-tab-btn.active {
  background: var(--bg-card, #262626);
  color: #f87171;
}

[data-theme="dark"] .syllable-pending,
body.dark .syllable-pending {
  background: rgba(255, 255, 255, 0.08);
  color: #9ca3af;
}

[data-theme="dark"] .talk-feedback-panel.pass,
body.dark .talk-feedback-panel.pass {
  background: rgba(34, 197, 94, 0.15);
  border-color: rgba(34, 197, 94, 0.3);
  color: #86efac;
}

[data-theme="dark"] .talk-feedback-panel.fail,
body.dark .talk-feedback-panel.fail {
  background: rgba(245, 158, 11, 0.15);
  border-color: rgba(245, 158, 11, 0.3);
  color: #fde68a;
}

[data-theme="dark"] .talk-msg-hint-box,
body.dark .talk-msg-hint-box {
  background: rgba(245, 158, 11, 0.12);
  color: #fde68a;
}

[data-theme="dark"] .talk-hint-ans-item,
body.dark .talk-hint-ans-item {
  background: rgba(0, 0, 0, 0.3);
  border-color: rgba(245, 158, 11, 0.3);
}

[data-theme="dark"] .talk-hint-zh,
body.dark .talk-hint-zh {
  color: #f3f4f6;
}

[data-theme="dark"] .talk-reward-banner,
body.dark .talk-reward-banner {
  background: rgba(245, 158, 11, 0.15);
  color: #fde68a;
}

/* --------------------------------------------------------------------------
   6. Mobile responsiveness (360px+)
   -------------------------------------------------------------------------- */
@media (max-width: 480px) {
  .talk-page-wrap {
    padding: 0.75rem 0.5rem 2rem;
  }

  .talk-tabs-pill {
    width: 100%;
    border-radius: 16px;
    justify-content: center;
  }

  .talk-tab-btn {
    padding: 0.35rem 0.55rem;
    font-size: 0.785rem;
    gap: 0.25rem;
    flex: 1 1 auto;
    justify-content: center;
  }

  .talk-tab-btn svg {
    width: 15px;
    height: 15px;
  }

  .talk-words-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }

  .talk-scope-selector {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
    width: 100%;
  }

  .talk-scope-selector select {
    width: 100%;
  }

  .talk-progress-badge {
    align-self: flex-start;
  }

  .talk-hanzi-display {
    font-size: 2.75rem;
  }

  .talk-pinyin-display {
    font-size: 1.25rem;
  }

  .talk-word-card {
    padding: 1.25rem 0.75rem;
  }

  .talk-audio-actions {
    gap: 0.4rem;
  }

  .talk-audio-actions .btn {
    font-size: 0.775rem;
    padding: 0.35rem 0.5rem;
  }

  .talk-card-footer {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }

  .talk-footer-actions {
    flex-direction: column;
    width: 100%;
    gap: 0.5rem;
  }

  .talk-card-footer button,
  .talk-footer-actions button,
  .talk-footer-actions a {
    width: 100%;
    justify-content: center;
  }

  .talk-chat-wrapper {
    height: 520px;
    border-radius: 12px;
  }

  .talk-chat-bubble-wrap {
    max-width: 90%;
  }

  .talk-big-mic-btn {
    width: 60px;
    height: 60px;
  }

  .talk-scenarios-grid {
    grid-template-columns: 1fr;
  }

  .talk-roleab-grid {
    grid-template-columns: 1fr;
  }

  .roleab-listen-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .roleab-listen-controls {
    flex-direction: column;
    width: 100%;
  }

  .roleab-listen-controls button {
    width: 100%;
  }

  .roleab-role-banner {
    flex-direction: column;
    align-items: stretch;
  }

  .roleab-support-toggles {
    width: 100%;
    justify-content: center;
  }

  .roleab-support-btn {
    font-size: 0.75rem;
    padding: 4px 8px;
    flex: 1;
    text-align: center;
  }

  .roleab-bubble {
    max-width: 92%;
  }

  .roleab-prompt-zh {
    font-size: 1.35rem;
  }

  .roleab-step-text {
    font-size: 0.72rem;
  }
}

/* --------------------------------------------------------------------------
   8. Mode 3: Đóng vai A-B (Roleplay A-B)
   -------------------------------------------------------------------------- */
.talk-roleab-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
  margin-top: 1.25rem;
}

.talk-roleab-card {
  background: var(--card, var(--bg-card, #ffffff));
  border: 1px solid var(--border, var(--border-color, #e5e7eb));
  border-radius: 14px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.85rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  min-width: 0;
  box-sizing: border-box;
}

.talk-roleab-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
}

.roleab-card-head {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.roleab-card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.roleab-topic-badge {
  background: var(--bg-secondary, rgba(0, 0, 0, 0.05));
  color: var(--muted, #6b7280);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 6px;
}

.roleab-badge-completed {
  background: rgba(16, 185, 129, 0.12);
  color: #059669;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 9999px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.roleab-card-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text, var(--text-main, #111827));
}

.roleab-card-scene {
  margin: 0;
  font-size: 0.875rem;
  color: var(--muted, var(--text-sub, #6b7280));
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.roleab-roles-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  background: var(--bg-secondary, rgba(0, 0, 0, 0.02));
  padding: 0.5rem 0.75rem;
  border-radius: 10px;
}

.roleab-role-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  font-weight: 600;
}

.roleab-role-chip.role-a {
  color: #2563eb;
}

.roleab-role-chip.role-b {
  color: #059669;
}

.roleab-swap-arrow {
  color: var(--muted, #9ca3af);
  font-weight: bold;
}

.roleab-scores-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.825rem;
  padding: 0.4rem 0.6rem;
  background: var(--bg-secondary, rgba(0, 0, 0, 0.03));
  border-radius: 8px;
}

.roleab-score-box {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.score-num.text-green {
  color: #10b981;
}

.roleab-start-btn {
  width: 100%;
  justify-content: center;
}

/* Progress bar */
.roleab-progress-wrap {
  margin-bottom: 1.25rem;
  width: 100%;
}

.roleab-progress-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
  max-width: 540px;
  margin: 0 auto;
  padding: 0 0.5rem;
}

.roleab-progress-bar::before {
  content: "";
  position: absolute;
  top: 16px;
  left: 30px;
  right: 30px;
  height: 2px;
  background: var(--border, #e5e7eb);
  z-index: 1;
}

.roleab-step-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  position: relative;
  z-index: 2;
  flex: 1;
  text-align: center;
}

.roleab-step-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--card, #ffffff);
  border: 2px solid var(--border, #d1d5db);
  color: var(--muted, #9ca3af);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  transition: all 0.2s ease;
}

.roleab-step-item.active .roleab-step-circle {
  background: var(--accent, #b3261e);
  border-color: var(--accent, #b3261e);
  color: #ffffff;
  box-shadow: 0 0 0 4px rgba(179, 38, 30, 0.2);
}

.roleab-step-item.done .roleab-step-circle {
  background: #10b981;
  border-color: #10b981;
  color: #ffffff;
}

.roleab-step-text {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted, #6b7280);
}

.roleab-step-item.active .roleab-step-text {
  color: var(--text, #111827);
  font-weight: 700;
}

/* Session wrapper */
.roleab-session-wrap {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
  box-sizing: border-box;
}

.roleab-session-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.roleab-header-info h2 {
  margin: 0;
  font-size: 1.25rem;
  color: var(--text, #111827);
}

.roleab-scene-tag {
  font-size: 0.875rem;
  color: var(--muted, #6b7280);
}

/* Listen Toolbar */
.roleab-listen-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.75rem 1rem;
  background: var(--card, #ffffff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 12px;
}

.roleab-listen-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* 2-Side Chat Stream */
.roleab-chat-stream {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 520px;
  overflow-y: auto;
  padding: 0.75rem;
  background: var(--bg-secondary, rgba(0, 0, 0, 0.02));
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 14px;
  box-sizing: border-box;
}

.roleab-listen-item {
  display: flex;
  width: 100%;
}

.roleab-listen-item.side-left {
  justify-content: flex-start;
}

.roleab-listen-item.side-right {
  justify-content: flex-end;
}

.roleab-bubble {
  max-width: 82%;
  border-radius: 14px;
  padding: 0.85rem 1rem;
  box-sizing: border-box;
  transition: all 0.2s ease;
  position: relative;
}

.bubble-a {
  background: var(--card, #ffffff);
  border: 1px solid var(--border, #e5e7eb);
  border-top-left-radius: 3px;
}

.bubble-b {
  background: rgba(59, 130, 246, 0.06);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-top-right-radius: 3px;
}

.roleab-listen-item.is-user-role .roleab-bubble {
  border: 2px solid var(--accent, #b3261e);
  box-shadow: 0 2px 8px rgba(179, 38, 30, 0.12);
}

.roleab-listen-item.sentence-active .roleab-bubble {
  border-color: #3b82f6 !important;
  background: rgba(59, 130, 246, 0.12) !important;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

.roleab-bubble-meta {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.775rem;
  color: var(--muted, #6b7280);
  margin-bottom: 0.35rem;
}

.roleab-pill-you {
  background: var(--accent, #b3261e);
  color: #fff;
  font-size: 0.7rem;
  padding: 1px 6px;
  border-radius: 9999px;
  font-weight: 700;
}

.roleab-bubble-zh {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text, #111827);
  margin-bottom: 0.2rem;
  line-height: 1.4;
}

.roleab-bubble-py {
  font-size: 0.9rem;
  color: #2563eb;
  margin-bottom: 0.25rem;
}

.roleab-bubble-vi {
  font-size: 0.85rem;
  color: var(--muted, #6b7280);
}

.roleab-btn-speak-one {
  background: transparent;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 0.75rem;
  cursor: pointer;
  margin-top: 0.4rem;
  color: var(--muted, #4b5563);
}

.roleab-btn-speak-one:hover {
  background: var(--bg-secondary, rgba(0,0,0,0.05));
  color: var(--text, #111827);
}

/* Role Banner & Support Level Toggles */
.roleab-role-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.75rem 1rem;
  background: var(--card, #ffffff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 12px;
}

.roleab-cur-role-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
}

.roleab-support-toggles {
  display: inline-flex;
  background: var(--bg-secondary, rgba(0, 0, 0, 0.05));
  padding: 3px;
  border-radius: 9999px;
  gap: 3px;
}

.roleab-support-btn {
  border: none;
  background: transparent;
  padding: 5px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 9999px;
  cursor: pointer;
  color: var(--muted, #6b7280);
  transition: all 0.15s ease;
}

.roleab-support-btn.active {
  background: var(--card, #ffffff);
  color: var(--accent, #b3261e);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Current Card */
.roleab-current-card {
  background: var(--card, #ffffff);
  border: 2px solid var(--border, #e5e7eb);
  border-radius: 14px;
  padding: 1.25rem 1rem;
  box-sizing: border-box;
}

.my-turn-card {
  border-color: var(--accent, #b3261e);
  box-shadow: 0 4px 16px rgba(179, 38, 30, 0.1);
}

.partner-turn-card {
  border-color: #3b82f6;
  background: rgba(59, 130, 246, 0.02);
}

.roleab-card-status-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
}

.roleab-step-counter {
  background: var(--bg-secondary, rgba(0,0,0,0.06));
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
}

.roleab-turn-title {
  font-weight: 600;
  color: var(--accent, #b3261e);
}

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

.roleab-prompt-zh {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text, #111827);
  margin-bottom: 0.35rem;
}

.roleab-prompt-py {
  font-size: 1.1rem;
  color: #2563eb;
  margin-bottom: 0.35rem;
}

.roleab-prompt-vi {
  font-size: 0.95rem;
  color: var(--muted, #6b7280);
}

.roleab-masked {
  letter-spacing: 5px;
  opacity: 0.4;
  user-select: none;
}

.roleab-memory-hint {
  margin-top: 0.4rem;
  font-size: 0.8rem;
  color: #eab308;
  font-style: italic;
}

/* Evaluation Panel in RoleAB */
.roleab-eval-panel {
  margin-top: 0.85rem;
  padding: 0.75rem;
  border-radius: 10px;
}

.roleab-eval-panel.eval-pass {
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.roleab-eval-panel.eval-retry {
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.25);
}

.roleab-eval-score-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.roleab-chars-eval {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin: 0.75rem 0;
}

.roleab-char-chip {
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 1.25rem;
  font-weight: 700;
}

.roleab-char-chip.char-ok {
  background: rgba(16, 185, 129, 0.15);
  color: #059669;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.roleab-char-chip.char-wrong {
  background: rgba(239, 68, 68, 0.15);
  color: #dc2626;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.roleab-retry-notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.6rem;
  font-size: 0.85rem;
  color: #b45309;
}

.roleab-retry-actions {
  display: flex;
  gap: 0.4rem;
}

.roleab-mic-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1rem;
}

.roleab-partner-speaking-indicator {
  text-align: center;
  padding: 1rem 0;
  color: #2563eb;
  font-weight: 600;
}

/* Summary Chart & Stats */
.roleab-chart-card {
  background: var(--bg-secondary, rgba(0, 0, 0, 0.02));
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 12px;
  padding: 1rem;
  margin: 1rem 0;
}

.roleab-chart-card h3 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  text-align: center;
}

.roleab-chart-wrap {
  max-width: 320px;
  margin: 0 auto;
}

.roleab-chart-avg {
  text-align: center;
  font-size: 0.95rem;
  margin-top: 0.5rem;
}

.roleab-history-compare-box {
  background: var(--card, #ffffff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  text-align: center;
}

.roleab-weak-sentences-box {
  background: rgba(239, 68, 68, 0.04);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.roleab-weak-sentences-box h3 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
  color: #dc2626;
}

.roleab-weak-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.roleab-weak-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.875rem;
  padding: 0.35rem 0.6rem;
  background: var(--card, #ffffff);
  border-radius: 6px;
}

.roleab-weak-tag {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted, #6b7280);
}

.roleab-weak-zh {
  font-weight: 600;
  flex: 1;
}

.roleab-weak-score {
  font-weight: 700;
  color: #dc2626;
}

/* Dark Theme Overrides for RoleAB */
[data-theme="dark"] .talk-roleab-card,
[data-theme="dark"] .roleab-listen-toolbar,
[data-theme="dark"] .roleab-role-banner,
[data-theme="dark"] .roleab-current-card,
[data-theme="dark"] .bubble-a,
[data-theme="dark"] .roleab-weak-item,
[data-theme="dark"] .roleab-history-compare-box {
  background: #1e1e1e;
  border-color: #333333;
}

[data-theme="dark"] .bubble-b {
  background: #1a2736;
  border-color: #2b4563;
}

[data-theme="dark"] .roleab-step-circle {
  background: #2a2a2a;
  border-color: #444444;
  color: #aaaaaa;
}

[data-theme="dark"] .roleab-support-btn.active {
  background: #2d2d2d;
  color: #ef4444;
}

[data-theme="dark"] .roleab-roles-preview,
[data-theme="dark"] .roleab-scores-row,
[data-theme="dark"] .roleab-chat-stream,
[data-theme="dark"] .roleab-chart-card {
  background: #181818;
  border-color: #333333;
}

