/* ==============================
   HỘI THOẠI — UI styles (4 màn hình SPA)
   Dùng chung biến màu/font từ styles.css
================================ */

:root {
  --ht-primary: #6f79f6;
  --ht-primary-soft: #edf1ff;
  --ht-accent: #ff8a5c;
  --ht-surface: #ffffff;
  --ht-bg: #f3f4f7;
  --ht-text: #121826;
  --ht-muted: #6f7d95;
  --ht-line: #e4e8f0;
  --ht-radius: 16px;
  --ht-shadow: 0 2px 6px rgba(21, 31, 56, 0.10);
}

html, body.hoithoai-body {
  background: var(--ht-bg);
  color: var(--ht-text);
  /* 2026-04-24: font stack đồng nhất với module.css (thêm SF Pro Text) */
  font-family: "Nunito", "SF Pro Text", "Avenir Next", Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  margin: 0;
  -webkit-font-smoothing: antialiased;
}

/* ===== Header (đồng bộ với module/profile page) ===== */
.ht-header {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 14px 12px;
  background: #6f79f6;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.32);
}

/* Back arrow plain text — căn giữa theo chiều dọc của header */
.ht-back-btn {
  position: absolute;
  left: 14px;
  top: env(safe-area-inset-top, 0px);
  bottom: 0;
  display: flex;
  align-items: center;
  margin: 0;
  padding: 0 4px;
  background: transparent;
  border: 0;
  color: #fff;
  /* Button không inherit font-family mặc định → ép inherit để khớp Nunito body */
  font-family: inherit;
  font-size: 22px;
  line-height: 1;
  font-weight: 400;
  cursor: pointer;
  text-decoration: none;
  transition: opacity 0.15s, transform 0.1s;
}
.ht-back-btn:hover { opacity: 0.8; }
.ht-back-btn:active { transform: scale(0.92); }

/* Title mặc định: UPPERCASE 20/600 đồng bộ với module/profile
   (áp dụng cho màn folders / topics / situations — title ngắn). */
.ht-title {
  margin: 0;
  font-size: 20px;
  line-height: 1.15;
  font-weight: 600;
  color: #fff;
  letter-spacing: 0.1px;
  text-align: center;
  text-transform: uppercase;
  padding: 0 64px;  /* chừa chỗ cho back (trái) và lang switcher (phải) để title giữ giữa */
  overflow: visible;
  white-space: nowrap;
  width: 100%;
}

/* Màn chi tiết hội thoại: title là câu tiếng Việt dài (vd "Hỏi có hâm nóng
   không") — dùng font nhỏ + chữ thường + ellipsis để vừa khung. */
.ht-title.is-long {
  font-size: 15px;
  line-height: 1.2;
  font-weight: 700;
  text-transform: none;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ht-header-right {
  position: absolute;
  right: 4px;
  top: calc(4px + env(safe-area-inset-top, 0px));
  display: flex;
  align-items: center;
}

/* Lang switcher trong header tím — trắng chữ, không nền, giống module/profile */
.ht-header .lang-switcher-slot {
  display: flex;
  align-items: center;
}
.ht-header .lang-btn {
  background: transparent;
  color: #fff;
  padding: 4px 6px;
  border-radius: 999px;
}
.ht-header .lang-btn:hover {
  background: rgba(255, 255, 255, 0.18);
}
.ht-header .lang-btn .lang-flag { font-size: 18px; }
.ht-header .lang-btn .lang-code { font-size: 11px; }

/* ===== Breadcrumb ===== */
.ht-breadcrumb {
  padding: 8px 14px;
  font-size: 12px;
  color: var(--ht-muted);
  background: #fff;
  border-bottom: 1px solid var(--ht-line);
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
}
.ht-breadcrumb::-webkit-scrollbar { display: none; }
.ht-breadcrumb a {
  color: var(--ht-primary);
  text-decoration: none;
  cursor: pointer;
}
.ht-breadcrumb a:hover { text-decoration: underline; }
.ht-breadcrumb .sep { margin: 0 6px; color: #c1c8d5; }
.ht-breadcrumb .cur { color: var(--ht-text); font-weight: 700; }

/* ===== Main ===== */
.ht-main {
  padding: 14px 12px 40px;
}

/* ===== Screen 1: Folders ===== */
.ht-screen-intro {
  margin: 0 0 14px;
  padding: 0 2px;
}
.ht-screen-intro h2 {
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.2px;
}
.ht-screen-intro p {
  margin: 0;
  font-size: 13px;
  color: var(--ht-muted);
  line-height: 1.4;
}

.ht-folder-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 4px;
}

.ht-folder-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  padding: 16px 12px 14px;
  background: var(--ht-surface);
  border: 1px solid var(--ht-line);
  border-radius: var(--ht-radius);
  box-shadow: var(--ht-shadow);
  text-align: center;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.15s;
  min-height: 140px;
}
.ht-folder-card:hover { box-shadow: 0 4px 12px rgba(21, 31, 56, 0.15); }
.ht-folder-card:active { transform: scale(0.98); }

.ht-folder-card .icon {
  font-size: 34px;
  line-height: 1;
  margin-bottom: 2px;
  text-align: center;
}

/* 2026-04-26: Cover image trên trang folders (giống pattern list-intro-image
   của module Vocab/Grammar/Listening). Aspect ratio 1280:280 ≈ 4.57:1
   để khớp với hero hoithoai (1400×~306). */
.ht-folder-cover {
  margin: 8px 14px 12px;
  border-radius: 12px;
  overflow: hidden;
  aspect-ratio: 1280 / 280;
  background: #e7ebf6;
  box-shadow: var(--ht-shadow);
}
.ht-folder-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 20%;
  display: block;
}
/* 2026-04-26: SVG icon thay thế emoji — kích thước hơi lớn hơn để cân
   visual weight với emoji (emoji có padding nội bộ, SVG không có). */
.ht-folder-card .icon-img {
  width: 44px;
  height: 44px;
  object-fit: contain;
  display: block;
  margin: 0 auto 2px;
}
@media (max-width: 480px) {
  .ht-folder-card .icon-img { width: 38px; height: 38px; }
}
.ht-folder-card .name {
  font-size: 16px;
  font-weight: 800;
  color: var(--ht-text);
  text-align: center;
}
.ht-folder-card .desc {
  font-size: 11.5px;
  color: var(--ht-muted);
  line-height: 1.35;
  text-align: center;
  flex: 1;
}
.ht-folder-card .count {
  font-size: 11px;
  color: var(--ht-primary);
  font-weight: 700;
  text-align: center;
  margin-top: 2px;
}

/* ===== Screen 2: Topics ===== */
.ht-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ht-topic-card, .ht-situation-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--ht-surface);
  border: 1px solid var(--ht-line);
  border-radius: 14px;
  box-shadow: var(--ht-shadow);
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  transition: transform 0.12s, box-shadow 0.15s;
}
.ht-topic-card:hover, .ht-situation-card:hover { box-shadow: 0 4px 10px rgba(21, 31, 56, 0.13); }
.ht-topic-card:active, .ht-situation-card:active { transform: scale(0.99); }

.ht-topic-card .icon {
  /* Đồng bộ kích thước với .icon ở trang chữ Hán (styles.css:243) */
  font-size: 33px;
  line-height: 1;
  width: 48px;
  text-align: center;
  flex-shrink: 0;
}
.ht-topic-card .body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  gap: 2px;
}
.ht-topic-card .name-vi {
  display: block;
  font-size: 15px;
  font-weight: 700;
  color: var(--ht-text);
}
.ht-topic-card .name-ja {
  display: block;
  font-size: 11.5px;
  color: var(--ht-muted);
}
.ht-topic-card .desc {
  display: block;
  font-size: 12px;
  color: #1f2d4e;
  line-height: 1.35;
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.ht-topic-card .meta {
  display: block;
  font-size: 11px;
  color: #4a55d4;
  font-weight: 700;
  margin-top: 4px;
}

.ht-topic-card .arrow, .ht-situation-card .arrow {
  color: #c1c8d5;
  font-size: 18px;
  flex-shrink: 0;
}

/* ===== Filter bar (pills Tất cả / Dễ / Vừa / Khó) ===== */
.ht-filter-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px; /* tránh cắt shadow */
}
.ht-filter-bar::-webkit-scrollbar { display: none; }

.ht-filter-pill {
  appearance: none;
  flex: 1 1 auto;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 12px;
  /* 2026-04-24: đổi pill full-round → rounded rect, bỏ viền, luôn có nền */
  border: 0;
  border-radius: 10px;
  background: #e7eaf2;
  color: var(--ht-text);
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, transform 0.1s;
}
.ht-filter-pill:hover { background: #d9dde8; }
.ht-filter-pill:active { transform: scale(0.97); }

.ht-filter-pill .count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  /* 2026-04-24: bỏ background + viền, chỉ giữ chữ số màu xanh đen */
  background: transparent;
  color: #1f2940;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.3;
}

/* Active state theo cấp độ — Khó từ đỏ → amber đậm cho dịu mắt */
.ht-filter-pill.is-active {
  background: var(--ht-primary);
  color: #fff;
}
.ht-filter-pill.is-active .count { color: #fff; }

.ht-filter-pill.is-easy.is-active { background: #16a34a; }
.ht-filter-pill.is-medium.is-active { background: #eab308; color: #1f2940; }
.ht-filter-pill.is-medium.is-active .count { color: #1f2940; }
.ht-filter-pill.is-hard.is-active { background: #d97706; }

/* ===== Screen 3: Situations ===== */
.ht-situation-card .body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  gap: 2px;
}
.ht-situation-card .title-vi {
  display: block;
  font-size: 14.5px;
  font-weight: 700;
  color: var(--ht-text);
}
.ht-situation-card .title-ja {
  display: block;
  font-size: 11.5px;
  color: var(--ht-muted);
}
.ht-situation-card .tag-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.ht-badge {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1.4;
}
.ht-badge.is-easy { background: #e4f7e7; color: #2a7f3a; }
.ht-badge.is-medium { background: #fef3c7; color: #ca8a04; }
.ht-badge.is-hard { background: #fed7aa; color: #92400e; }

.ht-status-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  background: #eef1f7;
  color: #6f7d95;
}
.ht-status-chip.is-learned {
  background: #e6f0ff;
  color: #2360b3;
}
/* 2026-04-26: vòng tròn 🔒 thay mũi tên › cho situation khoá.
   Mimic .group-progress.is-locked-progress của module.css để đồng bộ trải
   nghiệm với phần Ngữ pháp/Chữ hán. */
.ht-lock-circle {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #e5e7ef;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.ht-lock-circle > span {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #fff;
  display: grid;
  place-items: center;
  font-size: 16px;
  color: #8892aa;
}

/* Card khoá: mờ nhẹ tiêu đề để hint, click được để show dialog */
.ht-situation-card.is-locked {
  position: relative;
}
.ht-situation-card.is-locked .title-vi,
.ht-situation-card.is-locked .title-ja {
  color: #6f7d95;
}
.ht-situation-card.is-locked:hover {
  box-shadow: var(--ht-shadow);
}

/* ===== Screen 4: Dialogue detail ===== */
.ht-dialogue-wrap {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Hero block ĐỒNG NHẤT 112px cho mọi topic:
   - Topic chưa có ảnh → gradient tím nhạt placeholder
   - Topic có ảnh (class .has-image) → background-image cover + overlay đậm hơn
   Luôn hiện badge + status góc trái dưới. */
.ht-situation-hero {
  position: relative;
  min-height: 112px;
  padding: 0;
  border-radius: var(--ht-radius);
  border: 0;
  background: linear-gradient(135deg, #eef2ff 0%, #d8defc 100%);
  background-size: cover;
  /* 2026-04-26: position center 20% — ưu tiên hiện phần trên ảnh để
     tránh cắt đầu nhân vật khi ảnh dạng portrait/3:1 */
  background-position: center 20%;
  background-repeat: no-repeat;
  overflow: hidden;
}
.ht-situation-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 55%, rgba(0, 0, 0, 0.35));
  pointer-events: none;
}
.ht-situation-hero .hero-row {
  position: absolute;
  left: 12px;
  bottom: 10px;
  margin: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 8px;
}
/* Khi có ảnh — đổi fallback bg khi ảnh chưa load xong */
.ht-situation-hero.has-image {
  background-color: #d9dde8;
}

/* 2026-04-24: Layout card flat giống module listening (không còn bubble
   lệch trái/phải, không avatar tròn, icon SVG loa/mic xếp dọc bên phải). */
.ht-bubble-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ht-card {
  background: #ffffff;
  border: 1px solid #e7ebf5;
  border-radius: 12px;
  padding: 8px 12px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 30px;
  column-gap: 6px;
  align-items: stretch;
}
.ht-card.soft { background: #f7f9ff; }

.ht-card .card-main { min-width: 0; }

.ht-card .line-mark {
  background: transparent;
  color: #394b73;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 4px;
}

.ht-card .ja-ruby {
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.85;
  color: var(--ht-text);
}
.ht-card .ja-ruby ruby rt {
  font-size: 10px;
  color: var(--ht-muted);
  font-weight: 400;
}

.ht-card .vi-line {
  margin: 0;
  font-size: 13px;
  color: #4a5270;
  line-height: 1.4;
}

.ht-card .card-side-actions {
  align-self: stretch;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 9px;
  padding: 2px 0;
}

.ht-card .side-icon-btn {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: #1f57be;
  padding: 0;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 0.1s;
}
.ht-card .side-icon-btn:active { transform: scale(0.92); }
.ht-card .side-icon-btn.is-flash { color: #2f58db; animation: htIconFlash 0.45s ease-out; }
@keyframes htIconFlash {
  0% { transform: scale(1); }
  40% { transform: scale(1.25); }
  100% { transform: scale(1); }
}

.ht-card .side-icon-btn .icon-speaker,
.ht-card .side-icon-btn .icon-mic {
  width: 21px;
  height: 21px;
  display: block;
}
.ht-card .side-icon-btn .icon-speaker path:first-child,
.ht-card .side-icon-btn .icon-mic path:first-child {
  fill: currentColor;
}

/* ===== Card active highlight khi phản xạ nhanh đang chạy ===== */
.ht-card.is-qr-active { box-shadow: 0 0 0 2px var(--ht-primary) inset; }
.ht-card.is-qr-playing { box-shadow: 0 0 0 2px #16a34a inset; }
.ht-card.is-line-recording { box-shadow: 0 0 0 2px #ef4444 inset; }

/* Nút mic đang ghi — pulse đỏ */
.ht-card .side-icon-btn.is-recording {
  color: #ef4444;
  animation: htMicPulse 0.9s ease-in-out infinite;
}
@keyframes htMicPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.15); opacity: 0.7; }
}

/* Score chip inline dưới vi-line khi user đã ghi âm câu đó */
.ht-card .ht-rec-result {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed #dfe3ee;
  font-size: 12px;
  line-height: 1.4;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.ht-card .ht-rec-result .chip {
  display: inline-block;
  align-self: flex-start;
  padding: 2px 8px;
  border-radius: 999px;
  background: #e7eaf2;
  color: #1f2940;
  font-weight: 700;
}
.ht-card .ht-rec-result.is-good .chip { background: #dcfce7; color: #166534; }
.ht-card .ht-rec-result.is-ok .chip { background: #fef9c3; color: #854d0e; }
.ht-card .ht-rec-result.is-warn .chip { background: #fed7aa; color: #92400e; }
.ht-card .ht-rec-result.is-bad .chip { background: #fee2e2; color: #991b1b; }
.ht-card .ht-rec-result .heard { color: var(--ht-muted); font-size: 11.5px; }

/* 2026-04-26: Footer 3 nút — Trước (rộng) · Phát lại (vuông nhỏ) · Sau (rộng) */
.ht-dialogue-nav {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-top: 14px;
  padding-bottom: 8px;
  align-items: stretch;
}
.ht-nav-btn {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 2px;
  padding: 8px 12px;
  background: #ffffff;
  border: 1px solid var(--ht-line);
  border-radius: var(--ht-radius);
  box-shadow: var(--ht-shadow);
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.15s, background 0.15s, color 0.15s;
  font: inherit;
  color: #1f2937;
  min-width: 0;
}
.ht-nav-btn .nav-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.ht-nav-btn.is-prev .nav-row { justify-content: flex-start; }
.ht-nav-btn.is-next .nav-row { justify-content: flex-end; }
.ht-nav-btn .nav-sub {
  font-size: 12px;
  font-weight: 600;
  color: var(--ht-muted, #6f7d95);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  text-align: inherit;
}
.ht-nav-btn.is-prev { text-align: left; }
.ht-nav-btn.is-next { text-align: right; }
.ht-nav-btn:hover:not(:disabled) {
  background: #f5f8ff;
  box-shadow: 0 4px 10px rgba(21, 31, 56, 0.13);
}
.ht-nav-btn:active:not(:disabled) { transform: scale(0.97); }
.ht-nav-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  background: #f3f4f6;
}
.ht-nav-btn .nav-arrow {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary, #4e79f8);
  line-height: 1;
}
.ht-nav-btn:disabled .nav-arrow { color: #c1c8d5; }
.ht-nav-btn .nav-label-short {
  font-size: 14px;
  font-weight: 700;
}
/* Phát lại — pill ngang vừa đủ chữ "Phát lại" */
.ht-nav-btn.is-replay {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 14px;
  background: var(--primary, #4e79f8);
  border-color: var(--primary, #4e79f8);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(79, 110, 247, 0.28);
}
.ht-nav-btn.is-replay .nav-replay-label {
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ht-nav-btn.is-replay:hover:not(:disabled) {
  background: #3a66e0;
  border-color: #3a66e0;
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(79, 110, 247, 0.35);
}
.ht-nav-btn.is-replay .nav-replay-icon {
  font-size: 16px;
  line-height: 1;
}
.ht-nav-btn.is-replay.is-playing {
  background: #ef4444;
  border-color: #ef4444;
  animation: htReplayPulse 1.4s ease-in-out infinite;
}
.ht-nav-btn.is-replay.is-playing .nav-replay-icon {
  font-size: 14px;
  visibility: visible;
  font-family: inherit;
}
@keyframes htReplayPulse {
  0%, 100% { box-shadow: 0 2px 8px rgba(239, 68, 68, 0.35); }
  50%      { box-shadow: 0 4px 16px rgba(239, 68, 68, 0.55); }
}

/* Highlight bubble đang phát trong auto-play */
.ht-card.is-auto-playing {
  outline: 2px solid var(--primary, #4e79f8);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(79, 110, 247, 0.12);
  transition: outline-color 0.2s, box-shadow 0.2s;
}

/* ===== Phản xạ nhanh block ===== */
.ht-quickreact {
  position: relative;
  margin-top: 6px;
  padding: 16px 14px 18px;
  background: #fff;
  border: 1px solid var(--ht-line);
  border-radius: var(--ht-radius);
  box-shadow: var(--ht-shadow);
  overflow: hidden;
}

/* Global fireworks overlay — floating fullscreen khi không có layer cụ thể */
.ht-global-fireworks {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 999;
}
.ht-quickreact .qr-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.ht-quickreact .qr-head .qr-icon {
  font-size: 22px;
  line-height: 1;
}
.ht-quickreact .qr-head h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
}
.ht-quickreact .qr-sub {
  margin: 0 0 12px;
  font-size: 12px;
  color: var(--ht-muted);
  line-height: 1.4;
}

.ht-quickreact .qr-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}
.ht-quickreact .qr-btn {
  appearance: none;
  border: 1px solid var(--ht-line);
  background: #fff;
  color: var(--ht-text);
  padding: 10px 8px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.12s, transform 0.1s, border-color 0.12s;
}
.ht-quickreact .qr-btn:hover { background: var(--ht-primary-soft); border-color: #c5cffe; }
.ht-quickreact .qr-btn:active { transform: scale(0.98); }
.ht-quickreact .qr-btn.is-primary {
  background: var(--ht-primary);
  color: #fff;
  border-color: var(--ht-primary);
}
.ht-quickreact .qr-btn.is-primary:hover { filter: brightness(1.06); }
.ht-quickreact .qr-btn.is-record {
  background: #ff5a4a;
  color: #fff;
  border-color: #ff5a4a;
}
.ht-quickreact .qr-btn.is-record:hover { filter: brightness(1.06); }
.ht-quickreact .qr-btn[disabled] { opacity: 0.5; cursor: not-allowed; }

.ht-quickreact .qr-status {
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.45;
  margin-bottom: 12px;
  background: #eef1f7;
  color: #4a5270;
  text-align: center;
}
.ht-quickreact .qr-status.is-recording {
  background: #ffecec;
  color: #b42424;
  font-weight: 700;
}
.ht-quickreact .qr-status .dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #ff5a4a;
  margin-right: 6px;
  vertical-align: middle;
  animation: ht-pulse 1s infinite;
}

@keyframes ht-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.ht-quickreact .qr-score {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 12px;
  background: var(--ht-primary-soft);
  border: 1px solid #d8defc;
  border-radius: 12px;
}
.ht-quickreact .qr-score.full-width { grid-template-columns: 1fr; }
.ht-quickreact .qr-score .row {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ht-quickreact .qr-score .label {
  font-size: 11px;
  color: var(--ht-muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.ht-quickreact .qr-score .value {
  font-size: 15px;
  font-weight: 800;
  color: var(--ht-text);
}
.ht-quickreact .qr-score .value.is-big {
  font-size: 22px;
  color: var(--ht-primary);
}
.ht-quickreact .qr-score .comment {
  grid-column: 1 / -1;
  font-size: 12.5px;
  color: #4a5270;
  line-height: 1.4;
  padding-top: 8px;
  border-top: 1px dashed #c5cffe;
  margin-top: 2px;
}

/* Role picker pill (chọn A / B trước khi bắt đầu) */
.ht-quickreact .qr-role-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0 12px;
  font-size: 13px;
  color: var(--ht-text);
}
.ht-quickreact .qr-role-label { font-weight: 700; }
.ht-quickreact .qr-role-pill {
  appearance: none;
  min-width: 44px;
  height: 32px;
  border: 0;
  border-radius: 10px;
  background: #e7eaf2;
  color: var(--ht-text);
  font-family: inherit;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  transition: background 0.12s, transform 0.1s;
}
.ht-quickreact .qr-role-pill:hover { background: #d9dde8; }
.ht-quickreact .qr-role-pill:active { transform: scale(0.96); }
.ht-quickreact .qr-role-pill.is-active {
  background: var(--ht-primary);
  color: #fff;
}

/* Per-line report */
.ht-quickreact .qr-per-line {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ht-quickreact .qr-line-row {
  padding: 8px 10px;
  background: #f7f9ff;
  border: 1px solid var(--ht-line);
  border-radius: 10px;
  font-size: 12.5px;
  line-height: 1.45;
}
.ht-quickreact .qr-line-head {
  font-weight: 700;
  color: var(--ht-primary);
  margin-bottom: 4px;
}
.ht-quickreact .qr-line-expected { color: var(--ht-text); }
.ht-quickreact .qr-line-heard { color: var(--ht-muted); margin-top: 2px; }
.ht-quickreact .qr-line-heard em { color: #b42424; font-style: italic; }

/* ===== Practice modal (click mic bubble mở ra) ===== */
body.ht-practice-open { overflow: hidden; }

.ht-practice-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(15, 20, 40, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
.ht-practice-modal.is-open { display: flex; }

.ht-practice-dialog {
  position: relative;
  width: 100%;
  max-width: 380px;
  background: #fff;
  border-radius: 18px;
  padding: 28px 22px 22px;
  box-shadow: 0 20px 60px rgba(15, 20, 40, 0.25);
  text-align: center;
  overflow: hidden;
}

/* Timer bar — 8s đầy dần khi record */
.ht-practice-timer {
  margin: 4px 0 12px;
  height: 6px;
  background: #eef1f7;
  border-radius: 999px;
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.2s;
}
.ht-practice-timer.is-active { opacity: 1; }
.ht-practice-timer-bar {
  display: block;
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #6f79f6, #7f59ec);
  border-radius: 999px;
  transform: scaleX(0);
  transform-origin: left center;
}

/* Fireworks layer */
.ht-practice-fireworks {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  overflow: hidden;
}
.ht-firework-particle {
  position: absolute;
  left: 50%;
  top: 56%;
  width: 6px;
  height: 12px;
  border-radius: 999px;
  background: hsl(var(--hue) 92% 58%);
  opacity: 0;
}
.ht-practice-fireworks.is-burst .ht-firework-particle {
  animation: htFireworkBurst 900ms ease-out forwards;
  animation-delay: var(--delay, 0s);
}
@keyframes htFireworkBurst {
  0% { opacity: 0; transform: translate(-50%, -40%) scale(0.3); }
  20% { opacity: 1; }
  100% { opacity: 0; transform: translate(calc(-50% + var(--x)), calc(-40% + var(--y))) scale(0.95); }
}

.ht-practice-close {
  position: absolute;
  top: 10px;
  right: 12px;
  background: transparent;
  border: 0;
  font-size: 18px;
  color: #9aa3b8;
  cursor: pointer;
  padding: 4px 8px;
}

.ht-practice-icon-wrap {
  width: 72px;
  height: 72px;
  margin: 0 auto 12px;
  border-radius: 50%;
  background: var(--ht-primary-soft);
  color: var(--ht-primary);
  display: grid;
  place-items: center;
  transition: background 0.2s, color 0.2s;
}
.ht-practice-icon-wrap svg { width: 36px; height: 36px; }
.ht-practice-icon-wrap svg path:first-child { fill: currentColor; }

.ht-practice-icon-wrap.is-recording {
  background: #fee2e2;
  color: #ef4444;
  animation: htMicPulse 0.9s ease-in-out infinite;
}
.ht-practice-icon-wrap.is-processing {
  background: #fef3c7;
  color: #ca8a04;
  animation: htIconSpin 1s linear infinite;
}
@keyframes htIconSpin {
  to { transform: rotate(360deg); }
}

.ht-practice-status {
  margin: 0 0 12px;
  font-size: 14px;
  color: var(--ht-text);
  font-weight: 600;
}

.ht-practice-expected {
  margin: 0 0 12px;
  padding: 10px 12px;
  background: var(--ht-primary-soft);
  border: 1px solid #d8defc;
  border-radius: 10px;
  text-align: left;
}
.ht-practice-expected-ja {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.85;
  color: var(--ht-text);
}
.ht-practice-expected-ja ruby rt {
  font-size: 10px;
  color: var(--ht-muted);
  font-weight: 400;
}
.ht-practice-expected-vi {
  margin-top: 4px;
  font-size: 12.5px;
  color: var(--ht-muted);
}

.ht-practice-transcript-box {
  min-height: 20px;
  margin-bottom: 10px;
  padding: 8px 10px;
  background: #f7f9ff;
  border: 1px dashed #dfe3ee;
  border-radius: 10px;
  font-size: 13px;
  color: var(--ht-text);
  min-height: 30px;
}
.ht-practice-transcript-text:empty::before {
  content: attr(data-empty);
  color: #9aa3b8;
  font-style: italic;
}

.ht-practice-badge {
  margin: 8px 0 4px;
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 800;
  background: #e7eaf2;
  color: #1f2940;
}
.ht-practice-badge:empty { display: none; }
.ht-practice-badge.is-good { background: #dcfce7; color: #166534; }
.ht-practice-badge.is-ok { background: #fef9c3; color: #854d0e; }
.ht-practice-badge.is-warn { background: #fed7aa; color: #92400e; }
.ht-practice-badge.is-bad { background: #fee2e2; color: #991b1b; }

.ht-practice-hint {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--ht-muted);
  min-height: 16px;
}

.ht-practice-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 14px;
}
.ht-practice-btn {
  appearance: none;
  padding: 10px;
  border: 1px solid var(--ht-line);
  background: #fff;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  display: none;
  transition: background 0.12s, transform 0.1s;
}
.ht-practice-btn.is-visible { display: block; }
.ht-practice-btn:hover { background: var(--ht-primary-soft); }
.ht-practice-btn:active { transform: scale(0.97); }
.ht-practice-btn.is-disabled { opacity: 0.5; pointer-events: none; }

/* ===== Empty / loading ===== */
.ht-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--ht-muted);
  font-size: 14px;
}
.ht-loading {
  text-align: center;
  padding: 40px 20px;
  color: var(--ht-muted);
  font-size: 13px;
}

/* ===== Responsive: màn rất nhỏ ===== */
@media (max-width: 360px) {
  .ht-folder-grid { gap: 10px; }
  .ht-folder-card { padding: 12px 10px 10px; min-height: 120px; }
  .ht-folder-card .icon { font-size: 28px; }
  .ht-folder-card .name { font-size: 15px; }
  .ht-card .ja-ruby { font-size: 15px; }
}
