/* ══════════════════════════════════════════════════════
   BIẾN CSS — Toàn bộ màu sắc, kích thước dùng biến
   để dễ thay đổi về sau
══════════════════════════════════════════════════════ */

:root {
  /* Màu nhấn chính — san hô ấm */
  --accent:           #ff7a6b;
  --accent-light:     #fff0ee;
  --accent-hover:     #ff5c4a;
  --accent-deep:      #e85d4e;

  /* Nền & bề mặt */
  --bg:               #f0ece8;
  --sidebar-bg:       #f7f4f1;
  --card-bg:          #ffffff;

  /* Chữ */
  --text-main:        #1e1e1e;
  --text-sub:         #4a4a4a;
  --text-muted:       #9e9a96;

  /* Đường viền & bóng đổ */
  --border:           #e0dbd5;
  --shadow-sm:        0 1px 4px rgba(0,0,0,0.07);
  --shadow:           0 4px 16px rgba(0,0,0,0.09);
  --shadow-lg:        0 8px 30px rgba(0,0,0,0.14);

  /* Vàng sao */
  --gold:             #f5c842;
  --gold-light:       #fefae8;
  --gold-deep:        #c9a000;

  /* Màu cho chế độ ôn sao — nền vàng nhẹ */
  --star-bg:          #fdf7e3;
  --star-border:      #f0d98a;

  /* Điểm phát âm */
  --score-great:      #2ecc71;
  --score-ok:         #f39c12;
  --score-poor:       #e74c3c;

  /* Kích thước layout */
  --header-h:         54px;
  --sidebar-w:        288px;
  --radius:           16px;
  --radius-sm:        10px;
  --radius-xs:        6px;
}

/* ══════════════════════════════════════════════════════
   RESET & BASE
══════════════════════════════════════════════════════ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  font-family: 'Noto Sans JP', 'M PLUS Rounded 1c', sans-serif;
  color: var(--text-main);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ══════════════════════════════════════════════════════
   HEADER — Thanh tiêu đề trên cùng
══════════════════════════════════════════════════════ */
.header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  background: var(--card-bg);
  border-bottom: 2px solid var(--accent);
  flex-shrink: 0;
  z-index: 10;
}

/* Logo & tên ứng dụng */
.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--accent);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.header-brand .gate-icon {
  font-size: 20px;
}

/* Gợi ý phím tắt bên phải header */
.header-hint {
  font-size: 11.5px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 14px;
}

/* Style cho các phím */
.kbd {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 2px 7px;
  font-size: 11px;
  color: var(--text-sub);
  font-family: inherit;
}

/* ══════════════════════════════════════════════════════
   LAYOUT — Sidebar + Main nằm ngang
══════════════════════════════════════════════════════ */
.layout {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* ══════════════════════════════════════════════════════
   SIDEBAR — Cột trái chọn bài học
══════════════════════════════════════════════════════ */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
}

/* Tiêu đề sidebar */
.sidebar-header {
  padding: 14px 16px 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  background: var(--sidebar-bg);
}

/* Vùng cuộn danh sách bài học */
.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px;
}

.sidebar-scroll::-webkit-scrollbar { width: 4px; }
.sidebar-scroll::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

/* Vùng nút bên dưới sidebar */
.sidebar-actions {
  padding: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 7px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
}

/* ── Nhóm sách (details/summary) ────────────────────── */
.book-group {
  margin-bottom: 6px;
}

.book-group summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  border-radius: var(--radius-xs);
  font-weight: 600;
  font-size: 12.5px;
  color: var(--text-sub);
  transition: background 0.15s, color 0.15s;
  letter-spacing: 0.01em;
}

.book-group summary:hover {
  background: var(--accent-light);
  color: var(--accent);
}

/* Ẩn mũi tên mặc định của browser */
.book-group summary::-webkit-details-marker { display: none; }

/* Thêm mũi tên custom — xoay khi mở */
.book-group summary::after {
  content: '\f107';
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
  font-size: 10px;
  transition: transform 0.2s;
  color: var(--text-muted);
}

.book-group[open] summary::after {
  transform: rotate(180deg);
}

/* Danh sách unit bên trong mỗi sách */
.units-list {
  padding: 4px 2px 2px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* Chip mỗi unit */
.unit-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: var(--radius-xs);
  font-size: 12.5px;
  color: var(--text-sub);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  user-select: none;
}

.unit-chip:hover {
  background: var(--accent-light);
  color: var(--accent);
}

/* Checkbox trong chip */
.unit-chip input[type="checkbox"] {
  accent-color: var(--accent);
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  cursor: pointer;
}

/* Chip đã được chọn */
.unit-chip.checked {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 600;
}

/* ── Nút sidebar chung ───────────────────────────────── */
.btn-sidebar {
  width: 100%;
  padding: 8px 12px;
  border-radius: var(--radius-xs);
  font-size: 12.5px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: all 0.17s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  letter-spacing: 0.01em;
}

/* Nút chế độ ôn sao */
.btn-star-mode {
  background: transparent;
  border-color: var(--gold);
  color: var(--gold-deep);
}

.btn-star-mode:hover {
  background: var(--gold-light);
}

.btn-star-mode.active {
  background: var(--gold);
  border-color: var(--gold);
  color: #4a3000;
  box-shadow: 0 2px 8px rgba(245,200,66,0.35);
}

/* Nút tải lại */
.btn-reload {
  background: transparent;
  border-color: var(--border);
  color: var(--text-sub);
}

.btn-reload:hover {
  background: var(--bg);
  border-color: #c0bbb5;
}

/* Nút Import */
.btn-import {
  background: var(--text-main);
  border-color: var(--text-main);
  color: #fff;
}

.btn-import:hover {
  background: #333;
  border-color: #333;
}

/* Nút Export */
.btn-export {
  background: transparent;
  border-color: var(--accent);
  color: var(--accent);
}

.btn-export:hover {
  background: var(--accent-light);
}

/* ══════════════════════════════════════════════════════
   MAIN — Vùng chính hiển thị flashcard
══════════════════════════════════════════════════════ */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px 24px;
  overflow: hidden;
  transition: background 0.4s ease;
  position: relative;
}

/* Chế độ ôn sao — đổi màu nền để phân biệt */
.main.star-mode {
  background: var(--star-bg);
}

/* Dải viền vàng nhẹ bên trái main khi ôn sao */
.main.star-mode::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, var(--gold), transparent);
  opacity: 0.7;
}

/* Badge hiển thị khi đang ôn sao */
.star-mode-badge {
  position: absolute;
  top: 14px;
  right: 20px;
  display: none;
  align-items: center;
  gap: 6px;
  background: var(--gold);
  color: #4a3000;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  box-shadow: 0 2px 6px rgba(245,200,66,0.4);
}

.main.star-mode .star-mode-badge {
  display: flex;
}

/* ══════════════════════════════════════════════════════
   EMPTY STATE — Trạng thái chưa chọn bài
══════════════════════════════════════════════════════ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  opacity: 0.5;
  pointer-events: none;
}

.empty-state .empty-icon {
  font-size: 48px;
  line-height: 1;
}

.empty-state p {
  font-size: 14.5px;
  color: var(--text-muted);
  text-align: center;
  max-width: 240px;
  line-height: 1.7;
}

/* ══════════════════════════════════════════════════════
   FLASHCARD — Thẻ học lật 3D
══════════════════════════════════════════════════════ */
.flashcard-wrap {
  perspective: 1200px;
  width: 660px;
  height: 300px;
  cursor: pointer;
}

/* Phần chứa 2 mặt — xoay khi lật */
.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.55s cubic-bezier(0.45, 0.05, 0.55, 0.95);
}

/* Trạng thái đã lật */
.flashcard-wrap.flipped .card-inner {
  transform: rotateY(180deg);
}

/* Mặt chung của thẻ */
.card-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: var(--radius);
  background: var(--card-bg);
  box-shadow: var(--shadow), 0 1px 3px rgba(0,0,0,0.05);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  overflow: hidden;
}

/* Mặt trước — gradient nhẹ ấm */
.card-front {
  background: linear-gradient(160deg, #ffffff 0%, #fff8f6 100%);
}

/* Dải màu nhấn ở đỉnh thẻ trước */
.card-face.card-front::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), #ffb36b);
  border-radius: var(--radius) var(--radius) 0 0;
}

/* Chữ 表/裏 trang trí góc thẻ */
.card-face.card-front::after {
  content: '表';
  position: absolute;
  bottom: 12px;
  right: 16px;
  font-size: 10px;
  color: var(--accent);
  opacity: 0.25;
  font-weight: 700;
  letter-spacing: 0.05em;
}

/* Mặt sau — gradient xanh nhẹ */
.card-back {
  background: linear-gradient(160deg, #ffffff 0%, #f4f7ff 100%);
  transform: rotateY(180deg);
  padding: 28px 44px;
  text-align: center;
  gap: 0;
}

.card-face.card-back::after {
  content: '裏';
  position: absolute;
  bottom: 12px;
  right: 16px;
  font-size: 10px;
  color: #7090d0;
  opacity: 0.25;
  font-weight: 700;
}

/* ── Nội dung thẻ trước ──────────────────────────────── */
.card-kanji {
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 26px;
  color: var(--text-muted);
  font-weight: 400;
  min-height: 34px;
  line-height: 1.2;
  text-align: center;
}

/* Chữ đọc (Hiragana/Katakana) — lớn, màu nhấn */
.card-reading {
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 56px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.1;
  letter-spacing: -0.01em;
  text-align: center;
  padding: 0 12px;
}

/* Hiệu ứng đang phát âm — nhảy nhẹ */
.card-reading.speaking {
  animation: speakPulse 0.4s ease-in-out infinite;
}

@keyframes speakPulse {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.07); }
  100% { transform: scale(1); }
}

/* ── Nội dung thẻ sau ────────────────────────────────── */
.card-meaning {
  font-size: 25px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 10px;
}

.card-divider {
  width: 36px;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), transparent);
  border-radius: 2px;
  margin: 4px auto 14px;
}

.card-example {
  font-size: 21.5px;
  color: var(--text-sub);
  line-height: 1.8;
  font-family: 'Noto Sans JP', sans-serif;
  font-weight: 300;
  max-width: 480px;
}

/* ── Nút phát âm (loa) — giữa đáy thẻ trước ─────────── */
.speak-btn {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.95);
  box-shadow: var(--shadow-sm), 0 0 0 1px rgba(0,0,0,0.06);
  cursor: pointer;
  font-size: 15px;
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: box-shadow 0.15s, transform 0.15s;
}

.speak-btn:hover {
  box-shadow: var(--shadow);
  transform: translateX(-50%) scale(1.08);
}

.speak-btn:active {
  transform: translateX(-50%) scale(0.95);
}

/* ── Nút mic kiểm tra phát âm — góc phải đáy thẻ ────── */
.mic-btn {
  position: absolute;
  bottom: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.95);
  box-shadow: var(--shadow-sm), 0 0 0 1px rgba(0,0,0,0.06);
  cursor: pointer;
  font-size: 15px;
  color: #4b8cff;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: box-shadow 0.15s, transform 0.15s, background 0.2s, color 0.2s;
}

.mic-btn:hover {
  box-shadow: var(--shadow);
  transform: scale(1.08);
}

.mic-btn:active {
  transform: scale(0.95);
}

/* Trạng thái đang ghi âm — đỏ + vòng nhấp nháy */
.mic-btn.recording {
  background: #e74c3c;
  color: #fff;
  border: none;
  box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.5);
  animation: recordPulse 1s ease infinite;
}

/* Hiệu ứng vòng sóng khi đang ghi âm */
@keyframes recordPulse {
  0%   { box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.5); }
  70%  { box-shadow: 0 0 0 10px rgba(231, 76, 60, 0); }
  100% { box-shadow: 0 0 0 0 rgba(231, 76, 60, 0); }
}

/* ══════════════════════════════════════════════════════
   BẢNG KẾT QUẢ PHÁT ÂM — Popup hiện sau khi ghi âm
   Hiện ngay trên thẻ, không dùng toast
══════════════════════════════════════════════════════ */
.pronun-result {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 14px 20px 18px;
  display: none;
  flex-direction: column;
  gap: 8px;
  backdrop-filter: blur(12px);
  background: rgba(255,255,255,0.92);
  border-top: 1px solid rgba(0,0,0,0.07);
  z-index: 5;
  animation: slideUp 0.25s ease;
}

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

/* Hiển thị kết quả */
.pronun-result.visible {
  display: flex;
}

/* Hàng đầu: điểm số lớn + label */
.pronun-score-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Số điểm phần trăm — lớn, đậm, đổi màu theo mức */
.pronun-score-num {
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
  transition: color 0.3s;
}

.pronun-score-num.great { color: var(--score-great); }
.pronun-score-num.ok    { color: var(--score-ok); }
.pronun-score-num.poor  { color: var(--score-poor); }

/* Nhãn mô tả bên cạnh điểm */
.pronun-score-label {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 20px;
  letter-spacing: 0.04em;
}

.pronun-score-label.great { background: #d4f7e5; color: #1a7a45; }
.pronun-score-label.ok    { background: #fef3db; color: #9a6200; }
.pronun-score-label.poor  { background: #fde4e1; color: #8c1a12; }

/* Thanh tiến trình điểm số */
.pronun-bar-track {
  height: 6px;
  background: var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.pronun-bar-fill {
  height: 100%;
  border-radius: 10px;
  transition: width 0.5s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.3s;
  width: 0%;
}

.pronun-bar-fill.great { background: linear-gradient(90deg, #2ecc71, #00b894); }
.pronun-bar-fill.ok    { background: linear-gradient(90deg, #f39c12, #f1c40f); }
.pronun-bar-fill.poor  { background: linear-gradient(90deg, #e74c3c, #e17055); }

/* Dòng chữ "Bạn nói: ..." */
.pronun-spoken-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.pronun-spoken-text {
  font-weight: 600;
  color: var(--text-sub);
  font-family: 'Noto Sans JP', sans-serif;
}

/* Nút đóng kết quả */
.pronun-close {
  position: absolute;
  top: 10px;
  right: 12px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-muted);
  padding: 2px;
  line-height: 1;
  transition: color 0.15s;
}

.pronun-close:hover { color: var(--text-main); }

/* ── Overlay "Đang ghi âm..." trên thẻ ──────────────── */
.recording-overlay {
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  background: rgba(231, 76, 60, 0.06);
  display: none;
  align-items: stretch;
  justify-content: center;
  z-index: 4;
  pointer-events: none;
  padding: 40px;
}

.recording-overlay.visible {
  display: flex;
}

/* Vòng sóng âm thanh khi ghi âm */
.recording-wave {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 10px;
  width: 100%;
  height: 100%;
}

.recording-wave span {
  width: 14px;
  border-radius: 8px;
  background: #e74c3c;
  animation: waveBar 0.7s ease-in-out infinite;
}

.recording-wave span:nth-child(1) { height: 40%; }
.recording-wave span:nth-child(2) { height: 65%; }
.recording-wave span:nth-child(3) { height: 90%; }
.recording-wave span:nth-child(4) { height: 65%; }
.recording-wave span:nth-child(5) { height: 40%; }

@keyframes waveBar {
  0%, 100% { transform: scaleY(0.4); opacity: 0.6; }
  50%       { transform: scaleY(1);   opacity: 1; }
}

.recording-label {
  font-size: 12.5px;
  font-weight: 600;
  color: #e74c3c;
  letter-spacing: 0.05em;
}

/* ══════════════════════════════════════════════════════
   DECK META — Thanh tiến trình + số thẻ
══════════════════════════════════════════════════════ */
.deck-meta {
  margin-top: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  width: 660px;
}

.deck-info-text {
  font-size: 12.5px;
  color: var(--text-muted);
  min-width: 72px;
  font-variant-numeric: tabular-nums;
}

.progress-track {
  flex: 1;
  height: 4px;
  background: var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #ffb36b);
  border-radius: 10px;
  transition: width 0.4s ease;
  width: 0%;
}

/* ══════════════════════════════════════════════════════
   CONTROLS — Nút điều hướng bên dưới thẻ
══════════════════════════════════════════════════════ */
.controls {
  margin-top: 18px;
  width: 400px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Nút Trước / Tiếp */
.ctrl-btn {
  background: var(--card-bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 20px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  color: var(--text-sub);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 7px;
  transition: all 0.17s ease;
  box-shadow: var(--shadow-sm);
}

.ctrl-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.ctrl-btn:active {
  transform: translateY(0);
}

/* Nút sao tròn giữa */
.star-btn {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--card-bg);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 20px;
  color: var(--text-muted);
  transition: all 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: var(--shadow-sm);
}

.star-btn:hover {
  border-color: var(--gold);
  color: var(--gold);
  transform: scale(1.12);
}

/* Trạng thái đã gắn sao */
.star-btn.starred {
  background: var(--gold-light);
  border-color: var(--gold);
  color: var(--gold);
  box-shadow: 0 2px 10px rgba(245,200,66,0.35);
}

.star-btn.starred i {
  animation: starPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes starPop {
  0%   { transform: scale(0.5) rotate(-15deg); }
  100% { transform: scale(1) rotate(0deg); }
}

/* ══════════════════════════════════════════════════════
   FLIP HINT — Gợi ý cách lật thẻ
══════════════════════════════════════════════════════ */
.flip-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 10px;
  opacity: 0.65;
  letter-spacing: 0.01em;
}

/* ══════════════════════════════════════════════════════
   SCROLLBAR — Dọn dẹp scrollbar toàn trang
══════════════════════════════════════════════════════ */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

/* ══════════════════════════════════════════════════════
   HIỆU ỨNG VÀO — Animation khi thẻ xuất hiện
══════════════════════════════════════════════════════ */
.card-enter {
  animation: cardIn 0.28s ease;
}

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

/* ══════════════════════════════════════════════════════
   TOAST — Thông báo nổi ở đáy màn hình
══════════════════════════════════════════════════════ */
.toast-wrap {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  pointer-events: none;
}

.toast-msg {
  background: rgba(20,20,20,0.9);
  color: #fff;
  padding: 10px 18px;
  border-radius: 24px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  white-space: nowrap;
  backdrop-filter: blur(8px);
  animation: toastIn 0.28s ease, toastOut 0.3s ease 2.2s forwards;
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}

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

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

/* ══════════════════════════════════════════════════════
   RESPONSIVE — Điều chỉnh cho màn hình nhỏ hơn
══════════════════════════════════════════════════════ */
@media (max-width: 960px) {
  .flashcard-wrap {
    width: min(660px, calc(100vw - var(--sidebar-w) - 48px));
  }
  .deck-meta {
    width: min(660px, calc(100vw - var(--sidebar-w) - 48px));
  }
}
