/* =====================================================================
 * Modern Zen & Jade — giao diện Á Đông hiện đại, tối giản, ưu tiên điện thoại
 * Tỷ lệ màu 60 · 30 · 10: nền dịu mắt · xanh ngọc bích (Jade) · hổ phách & đỏ son
 * ===================================================================== */

/* ---------- 1. Design tokens ---------- */
:root,
[data-bs-theme="light"] {
  /* 60% — nền */
  --bg: #FAF9F5;              /* trắng ngà giấy tuyên chỉ */
  --surface: #FFFFFF;         /* card, sidebar */
  --surface-2: #F4F2EC;       /* nền phụ: chip, ô nhập, khối liên quan */
  --border: #E5E7EB;
  --text: #1F2937;
  --text-muted: #6B7280;
  --paper: #FFFDF8;           /* ô tập viết */

  /* 30% — Jade Teal */
  --primary: #0D9488;
  --primary-rgb: 13, 148, 136;
  --primary-hover: #0F766E;
  --primary-soft: #E7F5F3;
  --primary-ink: #0F766E;
  --on-primary: #FFFFFF;

  /* 10% — điểm nhấn */
  --amber: #F59E0B;
  --amber-hover: #D97706;
  --amber-soft: #FEF5E1;
  --amber-ink: #B45309;
  --rose: #E11D48;            /* đỏ son trầm */
  --rose-soft: #FDECEF;
  --rose-ink: #BE123C;
  --info-soft: #EEF4FF;
  --info-ink: #1D4ED8;

  /* Thanh điệu */
  --tone-1: #EF4444;
  --tone-2: #10B981;
  --tone-3: #3B82F6;
  --tone-4: #8B5CF6;
  --tone-5: #64748B;

  /* Ô tập viết (Hanzi Writer đọc các biến này khi tạo) */
  --writer-stroke: #1F2937;
  --writer-radical: #E11D48;
  --writer-outline: #E7E2D6;
  --writer-grid: #EBC4BA;
  --writer-frame: #E11D48;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .04), 0 2px 8px rgba(15, 23, 42, .04);
  --shadow: 0 2px 4px rgba(15, 23, 42, .03), 0 10px 30px rgba(15, 23, 42, .07);
  --glass: rgba(255, 255, 255, .86);

  /* Bootstrap dùng chung bảng màu */
  --bs-body-bg: var(--bg);
  --bs-body-color: var(--text);
  --bs-emphasis-color: #0F172A;
  --bs-secondary-color: var(--text-muted);
  --bs-secondary-bg: var(--surface-2);
  --bs-tertiary-bg: var(--surface-2);
  --bs-border-color: var(--border);
  --bs-primary: var(--primary);
  --bs-primary-rgb: var(--primary-rgb);
  --bs-danger: var(--rose);
  --bs-danger-rgb: 225, 29, 72;
  --bs-link-color: var(--primary-ink);
  --bs-link-color-rgb: 15, 118, 110;
  --bs-link-hover-color: var(--primary);
  --bs-link-hover-color-rgb: var(--primary-rgb);
  --bs-focus-ring-color: rgba(var(--primary-rgb), .25);
  color-scheme: light;
}

[data-bs-theme="dark"] {
  --bg: #0F172A;              /* xám than sâu, không dùng đen tuyền */
  --surface: #1E293B;
  --surface-2: #26344A;
  --border: #334155;
  --text: #E2E8F0;
  --text-muted: #94A3B8;
  --paper: #182235;

  --primary: #14B8A6;
  --primary-rgb: 20, 184, 166;
  --primary-hover: #2DD4BF;
  --primary-soft: rgba(20, 184, 166, .14);
  --primary-ink: #5EEAD4;
  --on-primary: #042F2E;

  --amber-hover: #FBBF24;
  --amber-soft: rgba(245, 158, 11, .14);
  --amber-ink: #FCD34D;
  --rose-soft: rgba(225, 29, 72, .16);
  --rose-ink: #FDA4AF;
  --info-soft: rgba(59, 130, 246, .14);
  --info-ink: #93C5FD;

  /* Sáng hơn một nấc để đủ tương phản trên nền tối */
  --tone-1: #F87171;
  --tone-2: #34D399;
  --tone-3: #60A5FA;
  --tone-4: #A78BFA;
  --tone-5: #94A3B8;

  --writer-stroke: #E2E8F0;
  --writer-radical: #FB7185;
  --writer-outline: #334155;
  --writer-grid: rgba(251, 113, 133, .28);
  --writer-frame: rgba(251, 113, 133, .7);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .25);
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --glass: rgba(30, 41, 59, .86);

  --bs-body-bg: var(--bg);
  --bs-body-color: var(--text);
  --bs-emphasis-color: #F8FAFC;
  --bs-secondary-color: var(--text-muted);
  --bs-secondary-bg: var(--surface-2);
  --bs-tertiary-bg: var(--surface-2);
  --bs-border-color: var(--border);
  --bs-primary: var(--primary);
  --bs-primary-rgb: var(--primary-rgb);
  --bs-link-color: var(--primary-ink);
  --bs-link-color-rgb: 94, 234, 212;
  --bs-link-hover-color: var(--primary-hover);
  --bs-focus-ring-color: rgba(var(--primary-rgb), .3);
  color-scheme: dark;
}

:root {
  --font-ui: "Be Vietnam Pro", "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-zh: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
  --font-zh-card: "LXGW WenKai", "Noto Serif SC", "Songti SC", "STKaiti", "KaiTi", serif;
  --radius: 12px;
  --radius-lg: 16px;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --tap: 44px;                 /* vùng chạm tối thiểu */
  --nav-h: 61px;
  --card-h: 460px;
  --bs-body-font-family: var(--font-ui);
  --bs-border-radius: var(--radius);
  --bs-border-radius-lg: var(--radius-lg);
  --bs-border-radius-sm: 10px;
}

/* ---------- 2. Nền tảng & chữ ---------- */
html { -webkit-text-size-adjust: 100%; }
html, body { overflow-x: clip; }   /* chặn cuộn ngang nhưng vẫn giữ position: sticky */
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  line-height: 1.6;
  -webkit-tap-highlight-color: transparent;
  transition: background-color .3s ease, color .3s ease;
}
button { -webkit-tap-highlight-color: transparent; }
.zh { font-family: var(--font-zh); line-height: 1.9; }
.zh-card { font-family: var(--font-zh-card); }
.text-muted-2 { color: var(--text-muted) !important; }
.text-vermilion { color: var(--rose) !important; }
.txt-ok { color: var(--primary-ink); }
.txt-bad { color: var(--rose-ink); }
.txt-learning { color: var(--amber-ink); }
.txt-mastered { color: var(--primary-ink); }
.txt-due { color: var(--rose-ink); font-weight: 600; }

/* Thanh điệu: chỉ tô khi bật (Cài đặt → Tô màu theo thanh điệu) */
.tone-on .t1, .tone-legend .t1 { color: var(--tone-1); }
.tone-on .t2, .tone-legend .t2 { color: var(--tone-2); }
.tone-on .t3, .tone-legend .t3 { color: var(--tone-3); }
.tone-on .t4, .tone-legend .t4 { color: var(--tone-4); }
.tone-on .t5, .tone-legend .t5 { color: var(--tone-5); }
.tone-legend span { font-weight: 600; }

/* Ẩn nhanh Pinyin / Nghĩa: làm mờ, chạm vào từng dòng để xem */
.peekable { transition: filter .2s ease, opacity .2s ease; }
.hide-pinyin .peekable[data-peek="pinyin"]:not(.peek),
.hide-meaning .peekable[data-peek="meaning"]:not(.peek) {
  filter: blur(6px);
  opacity: .55;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

/* ---------- 3. Thành phần dùng chung ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: background-color .3s ease, border-color .3s ease;
}
.panel-head {
  display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
  padding: .75rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.panel-body { padding: 1.25rem; }

.callout {
  border-left: 4px solid var(--primary);
  background: var(--primary-soft);
  border-radius: 4px var(--radius) var(--radius) 4px;
  padding: .75rem 1rem;
  margin-bottom: .875rem;
}
.callout-jade { border-left-color: var(--primary); background: var(--primary-soft); }
.callout-amber { border-left-color: var(--amber); background: var(--amber-soft); }
.callout-rose { border-left-color: var(--rose); background: var(--rose-soft); }
.callout-info { border-left-color: var(--tone-3); background: var(--info-soft); }

.icon-btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  width: var(--tap); height: var(--tap);
  border: 0; border-radius: var(--radius);
  background: transparent; color: var(--text-muted);
  font-size: 1.15rem;
  transition: all .2s ease;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn:active { transform: scale(.94); }
.icon-btn-soft { background: var(--surface); border: 1px solid var(--border); }

/* Bootstrap → bảng màu Jade */
.btn { border-radius: var(--radius); font-weight: 600; min-height: var(--tap); transition: all .2s ease; }
.btn-sm { min-height: 36px; }
.btn-primary {
  --bs-btn-bg: var(--primary); --bs-btn-border-color: var(--primary); --bs-btn-color: var(--on-primary);
  --bs-btn-hover-bg: var(--primary-hover); --bs-btn-hover-border-color: var(--primary-hover); --bs-btn-hover-color: var(--on-primary);
  --bs-btn-active-bg: var(--primary-hover); --bs-btn-active-border-color: var(--primary-hover); --bs-btn-active-color: var(--on-primary);
  --bs-btn-disabled-bg: var(--primary); --bs-btn-disabled-border-color: var(--primary);
  --bs-btn-focus-shadow-rgb: var(--primary-rgb);
}
.btn-danger {
  --bs-btn-bg: var(--rose); --bs-btn-border-color: var(--rose); --bs-btn-color: #fff;
  --bs-btn-hover-bg: #BE123C; --bs-btn-hover-border-color: #BE123C; --bs-btn-hover-color: #fff;
  --bs-btn-active-bg: #9F1239; --bs-btn-active-border-color: #9F1239;
}
.btn-outline-danger {
  --bs-btn-color: var(--rose-ink); --bs-btn-border-color: color-mix(in srgb, var(--rose) 45%, transparent);
  --bs-btn-hover-bg: var(--rose-soft); --bs-btn-hover-color: var(--rose-ink); --bs-btn-hover-border-color: var(--rose);
  --bs-btn-active-bg: var(--rose-soft); --bs-btn-active-color: var(--rose-ink); --bs-btn-active-border-color: var(--rose);
}
.btn-soft {
  --bs-btn-bg: var(--surface); --bs-btn-color: var(--text); --bs-btn-border-color: var(--border);
  --bs-btn-hover-bg: var(--surface-2); --bs-btn-hover-color: var(--text); --bs-btn-hover-border-color: var(--border);
  --bs-btn-active-bg: var(--surface-2); --bs-btn-active-color: var(--text); --bs-btn-active-border-color: var(--border);
}
.btn-amber {
  --bs-btn-bg: var(--amber); --bs-btn-border-color: var(--amber); --bs-btn-color: #1F2937;
  --bs-btn-hover-bg: var(--amber-hover); --bs-btn-hover-border-color: var(--amber-hover); --bs-btn-hover-color: #1F2937;
  --bs-btn-active-bg: var(--amber-hover); --bs-btn-active-border-color: var(--amber-hover); --bs-btn-active-color: #1F2937;
  --bs-btn-disabled-bg: var(--surface-2); --bs-btn-disabled-border-color: var(--border); --bs-btn-disabled-color: var(--text-muted);
}
.btn:active { transform: scale(.97); }

.form-control, .form-select {
  background-color: var(--surface);
  border-color: var(--border);
  border-radius: var(--radius);
  min-height: var(--tap);
  transition: all .2s ease;
}
.form-select-sm { min-height: 36px; }
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 .2rem rgba(var(--primary-rgb), .18);
}
.input-group-text { background: var(--surface-2); border-color: var(--border); border-radius: var(--radius); }
.form-check-input:checked { background-color: var(--primary); border-color: var(--primary); }
.form-check-input:focus { border-color: var(--primary); box-shadow: 0 0 0 .2rem rgba(var(--primary-rgb), .18); }
.form-switch .form-check-input { width: 2.6em; height: 1.4em; margin-top: .15em; }
.form-switch { padding-left: 3.2em; }
.form-switch .form-check-input { margin-left: -3.2em; }

.modal-content { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.modal-header, .modal-footer { border-color: var(--border); }
@media (max-width: 575.98px) {
  .modal-fullscreen-sm-down .modal-content { border-radius: 0; }
  .modal-footer { padding-bottom: calc(.75rem + env(safe-area-inset-bottom)); }
}

/* Toast: góc dưới phải trên máy tính, ngay dưới thanh trên cùng trên điện thoại (không đè thanh nút) */
.app-toasts { position: fixed; right: 0; bottom: 0; padding: 1rem; z-index: 1090; }
.toast {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.toast .toast-body { padding: .75rem 1rem; }

/* ---------- 4. Thanh điều hướng trên cùng ---------- */
.app-nav {
  background: var(--glass);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top);
  transition: background-color .3s ease, border-color .3s ease;
}
.app-nav-inner { display: flex; align-items: center; gap: .5rem; min-height: 60px; }
.brand { display: inline-flex; align-items: center; gap: .6rem; font-weight: 700; letter-spacing: -.01em; white-space: nowrap; }
.brand-mark {
  display: inline-grid; place-items: center;
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--rose); color: #fff; font-size: 1.35rem; line-height: 1;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .25);
}
.nav-switch { display: inline-flex; gap: .25rem; margin-left: auto; padding: 3px; background: var(--surface-2); border-radius: 14px; }
.nav-switch-btn {
  display: inline-flex; align-items: center; gap: .4rem; white-space: nowrap;
  min-height: var(--tap); padding: 0 .9rem;
  border: 0; border-radius: var(--radius);
  background: transparent; color: var(--text-muted); font-weight: 600; font-size: .92rem;
  transition: all .2s ease;
}
.nav-switch-btn:hover { color: var(--text); }
.nav-switch-btn.active { background: var(--primary); color: var(--on-primary); box-shadow: 0 2px 8px rgba(var(--primary-rgb), .3); }
.nav-actions { display: flex; gap: .15rem; }
.theme-icon-dark { display: none; }
[data-bs-theme="dark"] .theme-icon-dark { display: inline; }
[data-bs-theme="dark"] .theme-icon-light { display: none; }
#btn-theme i { transition: transform .4s var(--ease); }
#btn-theme:hover i { transform: rotate(-20deg); }

.app-main { max-width: 1120px; padding-top: 1rem; padding-bottom: 2rem; }

/* ---------- 5. Tổng quan tiến độ ---------- */
.progress-dash {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: .75rem 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 1rem 1.25rem;
  transition: background-color .3s ease, border-color .3s ease;
}
.dash-item { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.dash-goal { display: block; }
.dash-num { font-size: 1.4rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.dash-label { font-size: .78rem; color: var(--text-muted); }
.dash-goal-num { font-size: .85rem; color: var(--text-muted); }
.dash-goal-num b { color: var(--text); }
.dash-fire { font-size: 1.7rem; color: var(--border); transition: color .3s; }
.dash-fire.lit { color: var(--amber); animation: flicker 2.4s ease-in-out infinite; }
@keyframes flicker { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.08) rotate(-3deg); } }
.dash-gem { font-size: 1.5rem; color: var(--primary); }
.dash-bar { height: .625rem; border-radius: 999px; margin-top: .35rem; background: var(--surface-2); }
.dash-bar .progress-bar {
  background: linear-gradient(90deg, var(--amber), #FBBF24);
  border-radius: 999px;
  transition: width .7s var(--ease), background .3s ease;
}
.dash-bar .progress-bar.done { background: linear-gradient(90deg, var(--primary), #2DD4BF); }
.dash-review { white-space: nowrap; display: inline-flex; align-items: center; gap: .4rem; }
.dash-due-badge {
  display: inline-block; min-width: 1.6em; padding: .05rem .45rem;
  border-radius: 999px; background: rgba(255, 255, 255, .75); color: #92400E;
  font-size: .78rem; font-weight: 700; line-height: 1.5;
}
.dash-review:disabled { opacity: .55; }
.dash-unlock {
  grid-column: 1 / -1; order: 5;
  font-size: .8rem; color: var(--text-muted);
  border-top: 1px dashed var(--border); padding-top: .55rem;
}
.dash-unlock .bi-lock { color: var(--text-muted); }
.unlock-bar { height: .3rem; border-radius: 999px; margin-top: .35rem; background: var(--surface-2); }
.unlock-bar .progress-bar { background: var(--primary); transition: width .7s var(--ease); }

/* ---------- 6. Thanh công cụ bài học & bộ lọc ---------- */
.lesson-bar { display: flex; align-items: center; gap: .5rem; padding: .875rem 0 .625rem; }
.lesson-tools { display: flex; align-items: center; gap: .4rem; margin-left: auto; }
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-2); border-radius: 14px; }
.seg-btn {
  display: inline-flex; align-items: center; gap: .35rem;
  min-height: var(--tap); padding: 0 .85rem;
  border: 0; border-radius: var(--radius);
  background: transparent; color: var(--text-muted);
  font-weight: 600; font-size: .9rem;
  transition: all .2s ease;
}
.seg-btn.active { background: var(--surface); color: var(--primary-ink); box-shadow: var(--shadow-sm); }
.chip-toggle {
  display: inline-flex; align-items: center; gap: .35rem;
  min-height: var(--tap); padding: 0 .8rem;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); color: var(--primary-ink);
  font-size: .85rem; font-weight: 600;
  transition: all .2s ease;
}
.chip-toggle:hover { border-color: var(--primary); }
.chip-toggle[aria-pressed="false"] { color: var(--text-muted); background: var(--surface-2); }
.chip-toggle[aria-pressed="false"] span { text-decoration: line-through; text-decoration-thickness: 1.5px; }
.chip-toggle:active { transform: scale(.96); }
.filter-dot {
  position: absolute; top: 8px; right: 8px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--amber); box-shadow: 0 0 0 2px var(--surface);
}

.filters-inner { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; padding-bottom: 1rem; }
.filters-inner .form-select { width: auto; }
.deck-stats { margin-left: auto; font-size: .85rem; color: var(--text-muted); }
@media (min-width: 992px) {
  .filters-panel.collapse:not(.show) { display: block; }   /* máy tính: bộ lọc luôn hiện */
  /* Máy tính: công tắc Pinyin/Nghĩa nằm cùng hàng với bộ lọc */
  .lesson-bar { float: right; padding: 1rem 0 0 .75rem; }
  .filters-inner { padding-top: 1rem; }
  .study-grid, #empty-deck { clear: both; }
}

/* ---------- 7. Khu học: thẻ + vở viết ---------- */
.study-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.5rem; align-items: start; }
.study-col { min-width: 0; }

/* Flashcard 3D + vuốt */
.flashcard-wrap { position: relative; }
.swipe-layer {
  position: relative;
  perspective: 1200px;
  touch-action: pan-y;                 /* cử chỉ ngang để vuốt, dọc vẫn cuộn */
  transition: transform .28s var(--ease);
  will-change: transform;
}
.swipe-layer.dragging, .swipe-layer.no-anim { transition: none; }
.swipe-layer.enter { animation: card-in .3s var(--ease); }
@keyframes card-in { from { opacity: 0; transform: translateY(10px) scale(.98); } }

.flashcard {
  position: relative;
  height: var(--card-h);
  transform-style: preserve-3d;
  transition: transform .5s cubic-bezier(.4, .2, .2, 1);
  cursor: pointer;
  outline: none;
}
.flashcard.flipped { transform: rotateY(180deg); }
.flashcard:focus-visible .flashcard-face { box-shadow: 0 0 0 3px rgba(var(--primary-rgb), .45); }

.flashcard-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  transition: background-color .3s ease, border-color .2s ease, box-shadow .2s ease;
}
.flashcard-front {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background:
    radial-gradient(120% 80% at 50% 0%, var(--primary-soft) 0%, transparent 60%),
    var(--surface);
}
.flashcard-back { transform: rotateY(180deg); padding: 1.5rem 1.75rem; }
/* Mặt đang úp không nhận chạm/cuộn: tránh cuộn trên mặt trước lại cuộn ngầm nội dung mặt sau */
.flashcard:not(.flipped) .flashcard-back,
.flashcard.flipped .flashcard-front { pointer-events: none; }
.swipe-layer[data-dir="know"] .flashcard-face { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(var(--primary-rgb), .18), var(--shadow); }
.swipe-layer[data-dir="again"] .flashcard-face { border-color: var(--amber); box-shadow: 0 0 0 3px rgba(245, 158, 11, .2), var(--shadow); }

.swipe-stamp {
  position: absolute; top: 1.25rem; z-index: 3;
  padding: .3rem .8rem;
  border: 2px solid; border-radius: 10px;
  background: var(--surface);
  font-weight: 700; font-size: .95rem; letter-spacing: .02em; text-transform: uppercase;
  pointer-events: none;
  opacity: 0;
}
.stamp-know { left: 1.25rem; color: var(--primary-ink); border-color: var(--primary); transform: rotate(-10deg); opacity: clamp(0, var(--swipe, 0), 1); }
.stamp-again { right: 1.25rem; color: var(--amber-ink); border-color: var(--amber); transform: rotate(10deg); opacity: clamp(0, calc(var(--swipe, 0) * -1), 1); }

.card-corner { position: absolute; top: 1rem; display: flex; align-items: center; gap: .5rem; }
.card-corner-start { left: 1rem; }
.hsk-badge {
  display: inline-block; padding: .2rem .6rem;
  border-radius: 999px; background: var(--rose-soft); color: var(--rose-ink);
  font-size: .75rem; font-weight: 700; letter-spacing: .02em;
}
.card-hanzi {
  font-size: clamp(4.5rem, 18vw, 7.5rem);
  line-height: 1.15;
  color: var(--text);
  text-align: center;
  word-break: keep-all;
  padding: 0 1rem;
}
.card-foot { position: absolute; left: 1rem; right: 1rem; bottom: 1rem; text-align: center; }
.card-hint { font-size: .8rem; color: var(--text-muted); }
.swipe-hint { display: none; }
@media (pointer: coarse) { .swipe-hint { display: inline; } }
.review-info { font-size: .78rem; color: var(--text-muted); margin-top: .2rem; }
.review-info:empty { display: none; }

.back-scroll { height: 100%; overflow-y: auto; overscroll-behavior: contain; padding-right: .25rem; scrollbar-width: thin; }
.back-head { display: flex; align-items: flex-start; gap: .875rem; margin-bottom: .5rem; }
.back-head-text { flex: 1; min-width: 0; }
.back-hanzi { font-size: 2.75rem; line-height: 1.25; color: var(--text); }
.back-trad { font-size: 1.25rem; color: var(--text-muted); }
.back-pinyin { font-size: 1.35rem; font-weight: 600; color: var(--primary-ink); line-height: 1.5; letter-spacing: .01em; }
.back-meaning { font-size: 1.15rem; font-weight: 600; margin: .2rem 0 0; line-height: 1.5; }
.back-tags { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: .75rem; }
.back-tags:empty { display: none; }
.tag-chip {
  display: inline-block; padding: .15rem .6rem;
  border-radius: 999px; background: var(--surface-2); color: var(--text-muted);
  font-size: .75rem; font-weight: 500;
}
.back-explain { white-space: pre-line; color: var(--text); font-size: .95rem; line-height: 1.7; }
.back-explain:empty { display: none; }

.word-image {
  flex: 0 0 auto;
  width: 96px; height: 96px;
  border-radius: var(--radius-lg);
  background: var(--amber-soft);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.word-image.is-emoji { font-size: 3.6rem; line-height: 1; font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", sans-serif; }
.word-image img { width: 100%; height: 100%; object-fit: cover; }

.section-title {
  display: inline-flex; align-items: center; gap: .35rem;
  color: var(--primary-ink);
  font-size: .78rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  margin-bottom: .4rem;
}
.section-box {
  border-radius: var(--radius);
  padding: .75rem .875rem .5rem;
  margin-bottom: .875rem;
  background: var(--surface-2);
}
/* Các dòng dùng chung 1 lưới để cột chữ Hán / pinyin tự co theo từ dài nhất */
.related-grid {
  display: grid;
  grid-template-columns: max-content max-content auto 1fr;
  column-gap: .5rem;
  align-items: baseline;
}
.related-row { display: contents; cursor: pointer; }
.related-row > span { padding: .3rem 0; text-align: left; transition: color .2s ease; }
.related-row:hover > .rel-zh, .related-row:active > .rel-zh { color: var(--primary); }
.related-row .rel-zh { font-size: 1.25rem; font-weight: 500; color: var(--text); white-space: nowrap; line-height: 1.6; }
.related-row .rel-py { color: var(--text-muted); font-size: .85rem; white-space: nowrap; }
.related-row .rel-colon { color: var(--text-muted); }
.related-row .rel-vi { font-weight: 500; font-size: .9rem; }

.example {
  position: relative;
  border-left: 4px solid var(--amber);
  background: var(--amber-soft);
  padding: .625rem 3.25rem .625rem 1rem;
  border-radius: 4px var(--radius) var(--radius) 4px;
  margin-bottom: .625rem;
}
.example .ex-zh { font-size: 1.3rem; line-height: 1.9; color: var(--text); }
.example .ex-py { font-size: .9rem; line-height: 1.6; color: var(--text-muted); }
.example .ex-vi { font-size: .9rem; line-height: 1.6; color: var(--text); opacity: .85; }
.ex-badge {
  display: inline-block; margin-bottom: .15rem; padding: .05rem .5rem;
  border-radius: 999px; font-size: .68rem; font-weight: 700; letter-spacing: .02em;
}
.ex-basic { background: var(--primary-soft); color: var(--primary-ink); }
.ex-simple { background: var(--info-soft); color: var(--info-ink); }
.ex-compound { background: var(--rose-soft); color: var(--rose-ink); }
.btn-speak-ex {
  position: absolute; top: .35rem; right: .35rem;
  width: var(--tap); height: var(--tap);
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: var(--radius);
  background: transparent; color: var(--rose-ink); font-size: 1.15rem;
  transition: all .2s ease;
}
.btn-speak-ex:hover { background: var(--rose-soft); }
.btn-speak-ex:active { transform: scale(.92); }

/* Thanh điều khiển (máy tính: nằm dưới thẻ; điện thoại: ghim đáy màn hình) */
.action-bar { margin-top: 1rem; }
.bar-row { display: grid; grid-template-columns: var(--tap) 1fr 1fr var(--tap); gap: .5rem; }
.bar-row-write { grid-template-columns: 1fr 1fr 1fr var(--tap); }
.ctl-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-width: var(--tap); min-height: 48px; padding: 0 .75rem;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
  font-weight: 600; font-size: .92rem; white-space: nowrap;
  transition: all .2s ease;
}
.ctl-btn i { font-size: 1.15rem; }
.ctl-btn:hover { background: var(--surface-2); }
.ctl-btn:active { transform: scale(.96); }
.ctl-primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.ctl-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.ctl-accent { background: var(--rose-soft); border-color: transparent; color: var(--rose-ink); }
.ctl-accent:hover { background: var(--rose-soft); border-color: color-mix(in srgb, var(--rose) 40%, transparent); }
.ctl-btn[aria-pressed="false"] { color: var(--text-muted); }

.rate-label { text-align: center; font-size: .85rem; color: var(--text-muted); margin: .875rem 0 .5rem; }
.rate-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.btn-rate {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0;
  min-height: 60px; padding: .4rem .25rem;
  border-radius: var(--radius); border: 1.5px solid;
  font-weight: 600; line-height: 1.25;
  transition: all .2s ease;
}
.btn-rate i { font-size: 1.15rem; }
.btn-rate small { font-weight: 400; font-size: .68rem; opacity: .85; }
.btn-rate:hover { transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.btn-rate:active { transform: scale(.96); }
.rate-again { color: var(--rose-ink); border-color: color-mix(in srgb, var(--rose) 30%, transparent); background: var(--rose-soft); }
.rate-again:hover { border-color: var(--rose); }
.rate-good { color: var(--amber-ink); border-color: color-mix(in srgb, var(--amber) 40%, transparent); background: var(--amber-soft); }
.rate-good:hover { border-color: var(--amber); }
.rate-master { color: var(--primary-ink); border-color: color-mix(in srgb, var(--primary) 35%, transparent); background: var(--primary-soft); }
.rate-master:hover { border-color: var(--primary); }

/* Vở tập viết */
.char-tabs { display: flex; gap: .25rem; list-style: none; margin: 0; padding: 0; flex-wrap: wrap; }
.char-tabs:empty { display: none; }
.char-tab {
  width: var(--tap); height: var(--tap);
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--text);
  font-family: var(--font-zh-card); font-size: 1.35rem; line-height: 1;
  transition: all .2s ease;
}
.char-tab:hover { border-color: var(--primary); }
.char-tab.active { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }

.writer-box {
  width: 300px; height: 300px;
  background: var(--paper);
  border-radius: var(--radius);
  /* Khóa cuộn trang / pull-to-refresh / chọn chữ khi đang viết nét */
  touch-action: none;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  transition: background-color .3s ease;
}
.writer-box svg { display: block; }
.writer-box.shake { animation: shake .3s; }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
html.is-writing, html.is-writing body { overscroll-behavior: none; }   /* tắt pull-to-refresh khi ngón tay đang viết */

.writer-status { margin-top: .75rem; min-height: 1.6rem; font-size: .92rem; color: var(--text-muted); }
.writer-status.st-ok { color: var(--primary-ink); }
.writer-status.st-bad { color: var(--rose-ink); }
.writer-status.st-hint { color: var(--tone-3); }
.writer-status.st-warn { color: var(--amber-ink); }
.writing-stats { font-size: .85rem; color: var(--text-muted); margin-top: .5rem; }
.writing-stats .zh { font-size: 1.3rem; color: var(--text); }
.writer-legend { font-size: .8rem; color: var(--text-muted); margin-top: .25rem; }
.legend-dot { display: inline-block; width: .7rem; height: .7rem; border-radius: 50%; vertical-align: middle; }
.legend-radical { background: var(--writer-radical); }
.legend-stroke { background: var(--writer-stroke); }

/* ---------- 8. Trạng thái học ---------- */
.dot { display: inline-block; width: .55rem; height: .55rem; border-radius: 50%; vertical-align: middle; }
.dot-new { background: var(--text-muted); opacity: .6; }
.dot-learning { background: var(--amber); }
.dot-mastered { background: var(--primary); }
.status-chip { display: inline-flex; align-items: center; gap: .35rem; font-size: .75rem; font-weight: 600; white-space: nowrap; }
.status-chip .dot { width: .5rem; height: .5rem; }
.status-new { color: var(--text-muted); }
.status-learning { color: var(--amber-ink); }
.status-mastered { color: var(--primary-ink); }

/* ---------- 9. Tab Từ vựng ---------- */
.lvl-row { display: grid; grid-template-columns: 10rem 1fr 6rem; align-items: center; gap: .75rem; padding: .4rem 0; }
.lvl-row.locked { opacity: .5; }
.lvl-name { font-size: .88rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lvl-row.locked .lvl-name { font-weight: 500; }
.lvl-bar { height: .55rem; border-radius: 999px; background: var(--surface-2); }
.lvl-bar .progress-bar { transition: width .6s var(--ease); }
.bar-mastered { background: var(--primary); }
.bar-learning { background: var(--amber); }
.lvl-num { font-size: .8rem; color: var(--text-muted); text-align: right; font-variant-numeric: tabular-nums; }
.legend { white-space: nowrap; font-size: .8rem; color: var(--text-muted); }

.list-tools { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.list-tools .form-select { width: auto; }
.search-box { position: relative; flex: 1 1 260px; }
.search-box i { position: absolute; left: .9rem; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }
.search-box .form-control { padding-left: 2.5rem; }

.table-panel { overflow: hidden; }
.vocab-table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--text);
  --bs-table-hover-bg: var(--primary-soft);
  --bs-table-border-color: var(--border);
}
.vocab-table thead th {
  font-size: .75rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: var(--text-muted); background: var(--surface-2); border-bottom-width: 1px;
  padding: .75rem 1rem;
}
.vocab-table td { padding: .7rem 1rem; transition: background-color .2s ease; }
.vocab-table tbody tr:last-child td { border-bottom: 0; }
.vocab-table tbody tr:hover td { background: var(--primary-soft); }
.vocab-table .zh { font-size: 1.4rem; line-height: 1.5; white-space: nowrap; }
.vocab-table .py-cell { font-weight: 500; color: var(--primary-ink); }
.vocab-table tr.row-learning td:first-child { box-shadow: inset 3px 0 0 var(--amber); }
.vocab-table tr.row-mastered td:first-child { box-shadow: inset 3px 0 0 var(--primary); }
.btn-study {
  width: var(--tap); height: var(--tap);
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: var(--radius);
  background: var(--primary-soft); color: var(--primary-ink); font-size: 1.2rem;
  transition: all .2s ease;
}
.btn-study:hover { background: var(--primary); color: var(--on-primary); }
.btn-study:active { transform: scale(.92); }

.list-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-top: 1rem; }
.pagination {
  --bs-pagination-color: var(--text);
  --bs-pagination-bg: var(--surface);
  --bs-pagination-border-color: var(--border);
  --bs-pagination-hover-color: var(--primary-ink);
  --bs-pagination-hover-bg: var(--primary-soft);
  --bs-pagination-hover-border-color: var(--border);
  --bs-pagination-focus-color: var(--primary-ink);
  --bs-pagination-focus-bg: var(--primary-soft);
  --bs-pagination-focus-box-shadow: 0 0 0 .2rem rgba(var(--primary-rgb), .18);
  --bs-pagination-active-bg: var(--primary);
  --bs-pagination-active-border-color: var(--primary);
  --bs-pagination-active-color: var(--on-primary);
  --bs-pagination-disabled-bg: var(--surface);
  --bs-pagination-disabled-color: var(--text-muted);
  --bs-pagination-disabled-border-color: var(--border);
  --bs-pagination-border-radius: var(--radius);
  gap: .25rem;
}
.pagination .page-link {
  min-width: var(--tap); height: var(--tap);
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius) !important; margin-left: 0 !important;
  transition: all .2s ease;
}

/* ---------- 9b. Màn hình chào & tài khoản ---------- */
.welcome {
  position: fixed; inset: 0; z-index: 1040;
  display: none; align-items: center; justify-content: center;
  overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain;
  padding: calc(env(safe-area-inset-top) + 1.5rem) 1rem calc(env(safe-area-inset-bottom) + 1.5rem);
  background:
    radial-gradient(60% 45% at 88% 0%, rgba(var(--primary-rgb), .13), transparent 70%),
    radial-gradient(45% 35% at 0% 100%, rgba(245, 158, 11, .10), transparent 70%),
    var(--bg);
}
html.show-welcome .welcome { display: flex; }
html.show-welcome body { overflow: hidden; }
html.show-welcome .app-nav,
html.show-welcome .app-main,
html.show-welcome .app-toasts { display: none !important; }

.welcome-art {
  position: fixed; right: -4%; bottom: -10%;   /* fixed: không làm trang chào có thanh cuộn thừa */
  font-size: min(78vw, 34rem); line-height: 1;
  color: var(--primary); opacity: .06;
  transform: rotate(-8deg);
  pointer-events: none; user-select: none;
}
.welcome-card {
  position: relative;
  width: 100%; max-width: 28rem; margin: auto;
  padding: 2.25rem 2rem 1.75rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  text-align: center;
  animation: welcome-in .6s var(--ease) both;
}
@keyframes welcome-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.welcome-mark { width: 60px; height: 60px; border-radius: 18px; font-size: 2.1rem; margin-bottom: 1.25rem; }
.welcome-eyebrow { margin: 0 0 .5rem; color: var(--primary-ink); font-size: .875rem; font-weight: 600; text-wrap: balance; }
.welcome-title {
  margin: 0 0 .75rem;
  font-size: clamp(1.55rem, 5.6vw, 1.95rem); font-weight: 700; line-height: 1.3; letter-spacing: -.02em;
  color: var(--bs-emphasis-color); text-wrap: balance;
}
.welcome-lead { margin: 0 auto 1.75rem; max-width: 23rem; color: var(--text-muted); line-height: 1.65; text-wrap: pretty; }

/* Nút Google theo hướng dẫn thương hiệu (nền trắng / tối, logo G 4 màu) */
.btn-google {
  display: flex; align-items: center; justify-content: center; gap: .75rem;
  width: 100%; min-height: 52px; padding: 0 1.25rem;
  background: #FFFFFF; color: #1F1F1F;
  border: 1px solid #747775; border-radius: var(--radius);
  font-size: 1rem; font-weight: 600;
  transition: all .2s ease;
}
.btn-google:hover { background: #F7F8F8; box-shadow: 0 1px 3px rgba(60, 64, 67, .3), 0 4px 8px rgba(60, 64, 67, .12); }
.btn-google:active { transform: scale(.985); }
.btn-google:focus-visible { outline: 3px solid rgba(var(--primary-rgb), .45); outline-offset: 2px; }
.btn-google:disabled { cursor: progress; opacity: .75; }
.btn-google .g-logo { width: 20px; height: 20px; flex: none; }
[data-bs-theme="dark"] .btn-google { background: #131314; color: #E3E3E3; border-color: #8E918F; }
[data-bs-theme="dark"] .btn-google:hover { background: #1B1C1E; box-shadow: 0 2px 10px rgba(0, 0, 0, .4); }

.welcome-alert { margin: .875rem 0 0; text-align: left; font-size: .875rem; line-height: 1.55; }
.welcome-alert .btn { min-height: 36px; margin-top: .5rem; }
.welcome-free {
  display: flex; gap: .65rem; align-items: flex-start;
  margin: 1.25rem 0 0; padding: .75rem .9rem;
  background: var(--primary-soft); border-radius: var(--radius);
  text-align: left; font-size: .9rem; line-height: 1.6;
}
.welcome-free i { color: var(--primary); font-size: 1.1rem; line-height: 1.4; }
.welcome-free b { color: var(--primary-ink); }
.welcome-fine { margin: 1rem auto 0; max-width: 22rem; color: var(--text-muted); font-size: .78rem; line-height: 1.55; }

/* Tài khoản trên thanh điều hướng */
.account-btn { padding: 0; }
.avatar {
  display: inline-grid; place-items: center; flex: none;
  width: 32px; height: 32px; border-radius: 50%; overflow: hidden;
  background: var(--primary-soft); color: var(--primary-ink);
  font-size: .95rem; font-weight: 700; line-height: 1;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-lg { width: 44px; height: 44px; font-size: 1.15rem; }
.sync-dot {
  position: absolute; right: 5px; bottom: 6px;
  width: 11px; height: 11px; border-radius: 50%;
  border: 2px solid var(--surface); background: var(--text-muted);
  display: none;
}
.account[data-mode="user"] .sync-dot { display: block; }
.account[data-status="synced"] .sync-dot { background: var(--primary); }
.account[data-status="pending"] .sync-dot,
.account[data-status="syncing"] .sync-dot,
.account[data-status="loading"] .sync-dot { background: var(--amber); }
.account[data-status="syncing"] .sync-dot { animation: sync-pulse 1s ease-in-out infinite; }
.account[data-status="offline"] .sync-dot,
.account[data-status="error"] .sync-dot { background: var(--rose); }
@keyframes sync-pulse { 50% { opacity: .35; } }

.account-menu {
  --bs-dropdown-bg: var(--surface);
  --bs-dropdown-border-color: var(--border);
  --bs-dropdown-border-radius: var(--radius-lg);
  --bs-dropdown-link-color: var(--text);
  --bs-dropdown-link-hover-bg: var(--surface-2);
  --bs-dropdown-link-hover-color: var(--text);
  --bs-dropdown-link-active-bg: var(--primary-soft);
  --bs-dropdown-link-active-color: var(--primary-ink);
  width: min(19rem, calc(100vw - 1.5rem));
  padding: .5rem; box-shadow: var(--shadow);
}
.account-head { display: flex; align-items: center; gap: .75rem; padding: .5rem .5rem .75rem; min-width: 0; }
.account-head > div { min-width: 0; }
.account-name { font-weight: 700; line-height: 1.3; }
.account-email { font-size: .82rem; color: var(--text-muted); overflow-wrap: anywhere; }
.account-status {
  display: flex; align-items: center; gap: .5rem;
  margin: 0 .25rem .5rem; padding: .5rem .65rem;
  background: var(--surface-2); border-radius: var(--radius);
  font-size: .85rem; color: var(--text-muted);
}
.account-status .bi { font-size: 1rem; }
.account-status.ok .bi { color: var(--primary); }
.account-status.warn .bi { color: var(--amber); }
.account-status.bad .bi { color: var(--rose); }
.account-menu .dropdown-item { display: flex; align-items: center; gap: .6rem; min-height: var(--tap); border-radius: var(--radius); font-weight: 500; }
.account-menu .dropdown-item .bi { color: var(--text-muted); }

/* ---------- 10. Máy tính bảng & điện thoại (< 992px): 1 cột, thanh nút ghim đáy ---------- */
@media (max-width: 991.98px) {
  :root {
    --bar-card-h: 144px;   /* chiều cao thanh nút dưới thẻ (2 hàng) */
    --bar-write-h: 72px;
    --lesson-h: 66px;
    /* Thẻ vừa khít 1 màn hình: 100dvh trừ thanh trên, thanh công cụ và thanh nút đáy */
    --card-h: clamp(320px, calc(100vh - var(--nav-h) - var(--lesson-h) - var(--bar-card-h) - 1.5rem - env(safe-area-inset-bottom)), 680px);
    --card-h: clamp(320px, calc(100dvh - var(--nav-h) - var(--lesson-h) - var(--bar-card-h) - 1.5rem - env(safe-area-inset-bottom)), 680px);
  }
  .app-main { max-width: 760px; padding-left: 1rem; padding-right: 1rem; padding-bottom: .75rem; }

  /* Thanh công cụ bài học dính dưới thanh trên cùng */
  .lesson-bar {
    position: sticky; top: var(--nav-h); z-index: 1010;
    margin: 0 -1rem; padding: .5rem 1rem;
    background: var(--bg);
    transition: background-color .3s ease;
  }
  .filters-inner { display: grid; grid-template-columns: 1fr 1fr; padding-top: .25rem; }
  .filters-inner .form-select { width: 100%; }
  .deck-stats { grid-column: 1 / -1; margin-left: 0; }

  .study-grid { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .study-grid[data-mode="card"] .study-col-write,
  .study-grid[data-mode="write"] .study-col-card { display: none; }
  .study-col-card { padding-bottom: calc(var(--bar-card-h) + env(safe-area-inset-bottom)); }
  .study-col-write { padding-bottom: calc(var(--bar-write-h) + env(safe-area-inset-bottom) + .5rem); }

  /* Thanh nút vùng ngón cái */
  .action-bar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030;
    margin: 0;
    padding: .625rem max(1rem, env(safe-area-inset-right)) calc(.625rem + env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
    background: var(--glass);
    -webkit-backdrop-filter: saturate(1.4) blur(14px);
    backdrop-filter: saturate(1.4) blur(14px);
    border-top: 1px solid var(--border);
    box-shadow: 0 -6px 24px rgba(15, 23, 42, .06);
  }
  .action-bar > * { max-width: 728px; margin-left: auto; margin-right: auto; }
  .rate-label { display: none; }
  .rate-grid { margin-top: .5rem; }
  .btn-rate { min-height: 56px; }
  .ctl-btn { min-height: var(--tap); }

  .write-panel { border-radius: var(--radius-lg); }
  .write-panel .panel-body { padding: 1rem; }

  .app-toasts { top: calc(var(--nav-h) + env(safe-area-inset-top) + .5rem); bottom: auto; left: 0; right: 0; display: flex; justify-content: center; padding: 0 1rem; }
  .toast { width: 100%; max-width: 420px; }
}

/* ---------- 11. Điện thoại (< 576px) ---------- */
@media (max-width: 575.98px) {
  .welcome { align-items: flex-start; }
  .welcome-card { background: transparent; border: 0; box-shadow: none; padding: 1.5rem .5rem 1rem; }
  .welcome-art { right: -18%; bottom: -4%; }

  .brand-text { display: none; }
  .nav-switch { margin-left: .25rem; }
  .nav-switch-btn { padding: 0 .75rem; }
  .app-main { padding-top: .75rem; }

  /* Tổng quan: 2 hàng (chuỗi · đã thuộc · ôn tập / mục tiêu) */
  .progress-dash { grid-template-columns: 1fr 1fr auto; padding: .75rem .875rem; gap: .5rem .75rem; }
  .dash-item { gap: .45rem; }
  .dash-goal { grid-column: 1 / -1; order: 4; }
  .dash-num { font-size: 1.2rem; }
  .dash-label { font-size: .72rem; white-space: nowrap; }
  .dash-fire, .dash-gem { font-size: 1.3rem; }
  .dash-review { padding: 0 .75rem; }
  .dash-review-text { display: none; }

  /* Thanh công cụ: bỏ icon, giữ chữ để vừa 1 hàng */
  .lesson-bar { gap: .375rem; }
  .lesson-tools { gap: .375rem; }
  .seg-btn i, .chip-toggle i { display: none; }
  .seg-btn { padding: 0 .75rem; }
  .chip-toggle { padding: 0 .75rem; }

  .flashcard-back { padding: 1.1rem 1.1rem; }
  .back-hanzi { font-size: 2.4rem; }
  .word-image { width: 76px; height: 76px; border-radius: var(--radius); }
  .word-image.is-emoji { font-size: 2.8rem; }
  .back-pinyin { font-size: 1.2rem; }
  .back-meaning { font-size: 1.08rem; }
  .back-explain { font-size: .9rem; }
  .example { padding: .5rem 3rem .5rem .875rem; }
  .example .ex-zh { font-size: 1.25rem; }
  .example .ex-py, .example .ex-vi { font-size: .85rem; }

  .lvl-row { grid-template-columns: 8.25rem 1fr 4.4rem; gap: .5rem; }
  .lvl-name { font-size: .82rem; }
  .panel-head .legend { display: none; }
  .list-tools .form-select { flex: 1 1 40%; min-width: 0; }

  /* Bảng từ vựng → danh sách thẻ gọn */
  .vocab-table thead { display: none; }
  .vocab-table tbody tr {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas: "zh py act" "zh vi act" "zh st act";
    column-gap: .875rem; row-gap: .1rem;
    align-items: center;
    padding: .75rem 1rem;
    border-bottom: 1px solid var(--border);
  }
  .vocab-table tbody tr:last-child { border-bottom: 0; }
  .vocab-table td { padding: 0; border: 0; background: transparent !important; box-shadow: none !important; }
  .vocab-table td:nth-child(1) { grid-area: zh; }
  .vocab-table td:nth-child(2) { grid-area: py; font-size: .88rem; }
  .vocab-table td:nth-child(3) { grid-area: vi; font-size: .9rem; }
  .vocab-table td:nth-child(5) { grid-area: st; }
  .vocab-table td:nth-child(7) { grid-area: act; }
  .vocab-table td[colspan] { grid-column: 1 / -1; grid-area: auto; padding: .5rem 0; }
  .vocab-table tr.row-learning { box-shadow: inset 3px 0 0 var(--amber); }
  .vocab-table tr.row-mastered { box-shadow: inset 3px 0 0 var(--primary); }
  .vocab-table .zh { font-size: 1.6rem; }
  .list-foot { justify-content: center; }
}

@media (max-width: 359.98px) {
  .chip-toggle span { display: none; }
  .ctl-btn span { display: none; }
}

/* Điện thoại: tiến độ thành popup dưới thanh trên cùng (mở bằng nút #btn-dash) để thẻ học vừa 1 màn hình */
.nav-due-badge {
  position: absolute; top: 3px; right: 1px;
  min-width: 1.15rem; height: 1.15rem; padding: 0 .25rem;
  border-radius: 999px; background: var(--amber); color: #fff;
  font-size: .66rem; font-weight: 700; line-height: 1.15rem; text-align: center;
  box-shadow: 0 0 0 2px var(--bg);
}
#btn-dash[aria-expanded="true"] { background: var(--primary-soft); color: var(--primary); }
.dash-backdrop { display: none; }
@media (max-width: 575.98px) {
  .progress-dash {
    position: fixed; z-index: 1035;
    top: calc(var(--nav-h) + env(safe-area-inset-top) + .5rem);
    left: max(.75rem, env(safe-area-inset-left)); right: max(.75rem, env(safe-area-inset-right));
    box-shadow: var(--shadow);
    opacity: 0; visibility: hidden; transform: translateY(-8px);
    transition: opacity .18s ease, transform .18s var(--ease), visibility 0s linear .18s;
  }
  .progress-dash.is-open {
    opacity: 1; visibility: visible; transform: none;
    transition: opacity .18s ease, transform .18s var(--ease);
  }
  .dash-backdrop.is-open {
    display: block; position: fixed; inset: 0; z-index: 1034;
    background: rgba(15, 23, 42, .28);
  }
  .dash-review-text { display: inline; }
}

/* Điện thoại hẹp: thanh trên có thêm nút tài khoản → bỏ biểu tượng ở nút Học / Từ vựng */
@media (max-width: 399.98px) {
  .nav-switch-btn i { display: none; }
}

/* ---------- 11c. Tài liệu học tập (#resources-modal), Mời tác giả ly trà (#donate-modal), chúc mừng (#cele-modal) ---------- */
/* Thông tin chuyển khoản còn là mẫu → ẩn mọi lối vào trên trang thật (js/support.js gắn .support-on) */
html:not(.support-on) .support-entry { display: none !important; }

.nav-support {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; align-self: center;
  min-height: 36px; padding: 0 .85rem; margin-right: .35rem;
  border: 1px solid rgba(var(--primary-rgb), .28); border-radius: 999px;
  background: var(--primary-soft); color: var(--primary-ink);
  font-size: .85rem; font-weight: 600; white-space: nowrap;
  transition: all .2s ease;
}
.nav-support:hover { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.nav-support:active { transform: scale(.96); }
.nav-support i { font-size: 1rem; }

/* Lối vào theo ngữ cảnh — chỉ ở tab Từ vựng, không đặt trong màn đang học thẻ / tập viết */
.res-promo {
  display: flex; align-items: center; gap: .85rem; width: 100%;
  padding: .85rem 1.25rem; border: 0; border-top: 1px solid var(--border);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  background: linear-gradient(90deg, var(--primary-soft), transparent 75%);
  color: var(--text); text-align: left;
  transition: background-color .2s ease;
}
.res-promo:hover { background-color: var(--surface-2); }
.res-promo-icon {
  flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px;
  background: var(--surface); color: var(--primary-ink); font-size: 1.15rem; box-shadow: var(--shadow-sm);
}
.res-promo-text { display: flex; flex-direction: column; gap: .1rem; min-width: 0; flex: 1; }
.res-promo-text b { font-size: .92rem; color: var(--bs-emphasis-color); }
.res-promo-text span { font-size: .8rem; line-height: 1.4; color: var(--text-muted); }
.res-promo-cta { flex: none; font-size: .85rem; font-weight: 600; color: var(--primary-ink); white-space: nowrap; }
.res-promo:hover .res-promo-cta i { transform: translateX(3px); }
.res-promo-cta i { display: inline-block; transition: transform .2s ease; }

.res-hint {
  display: flex; align-items: center; gap: .6rem; width: 100%; margin-top: 1rem;
  padding: .8rem 1rem; border: 1px dashed rgba(var(--primary-rgb), .45); border-radius: var(--radius);
  background: transparent; color: var(--primary-ink); font-size: .9rem; font-weight: 600; text-align: left;
  transition: background-color .2s ease, border-color .2s ease;
}
.res-hint:hover { background: var(--primary-soft); border-style: solid; }
.res-hint .bi-file-earmark-pdf { font-size: 1.1rem; }
.res-hint span { flex: 1; }
.res-hint-arrow { transition: transform .2s ease; }
.res-hint:hover .res-hint-arrow { transform: translateX(3px); }

.app-footer { display: flex; justify-content: center; margin-top: 1.5rem; padding-top: .75rem; border-top: 1px solid var(--border); }
.footer-donate {
  display: inline-flex; align-items: center; gap: .35rem; min-height: 36px; padding: 0 .75rem;
  border: 0; border-radius: 999px; background: transparent; color: var(--text-muted); font-size: .82rem;
  transition: color .2s ease, background-color .2s ease;
}
.footer-donate:hover { color: var(--amber-ink); background: var(--amber-soft); }
.app-legal { display: flex; flex-wrap: wrap; justify-content: center; gap: .15rem .5rem; margin-top: .5rem; padding-bottom: .5rem; font-size: .78rem; color: var(--text-muted); }
.app-legal-start { justify-content: flex-start; margin-top: 1rem; padding-bottom: 0; }
.app-legal a, .welcome-fine a, .sp-legal a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.app-legal a:hover, .welcome-fine a:hover, .sp-legal a:hover { color: var(--primary-ink); }
.sp-legal { margin: .75rem 0 0; color: var(--text-muted); font-size: .78rem; line-height: 1.55; }
.sp-seller:not(:empty) { display: block; margin-top: .2rem; }

#donate-modal .sp-tiers { padding-top: .35rem; }

/* Chúc mừng khi xong một mục tiêu (#cele-modal) */
.cele-modal .modal-dialog { max-width: 400px; }
.cele-modal .modal-content { border-radius: 24px; overflow: hidden; border: 0; }
.cele-modal .modal-body {
  position: relative; padding: 1.25rem 1.5rem 1.4rem; text-align: center;
  background:
    radial-gradient(90% 45% at 50% 0%, rgba(var(--primary-rgb), .16), transparent 70%),
    radial-gradient(60% 35% at 100% 100%, var(--amber-soft), transparent 70%),
    var(--surface);
}
.cele-close { position: absolute; top: .9rem; right: .9rem; z-index: 1; }

.cele-mascot { width: 128px; height: 120px; margin: .25rem auto 0; }
.cele-mascot svg { width: 100%; height: 100%; overflow: visible; }
.cele-shadow { fill: rgba(15, 23, 42, .1); animation: cele-shadow 1.5s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.cele-body { fill: #FFF8EC; stroke: #EADBC2; stroke-width: 2; }
.cele-pleat, .cele-arm { fill: none; stroke: #EADBC2; stroke-width: 2.5; stroke-linecap: round; }
.cele-arm { stroke: #E9D3AE; stroke-width: 6; }
.cele-dot { fill: #F43F5E; }
.cele-eye { fill: none; stroke: #3F3A36; stroke-width: 3; stroke-linecap: round; }
.cele-blush { fill: #FB7185; opacity: .45; }
.cele-mouth { fill: #E11D48; }
.cele-bun { transform-box: view-box; transform-origin: 60px 100px; animation: cele-hop 1.5s var(--ease) infinite; }
.cele-arm-l { transform-box: view-box; transform-origin: 24px 70px; animation: cele-wave-l .5s ease-in-out infinite alternate; }
.cele-arm-r { transform-box: view-box; transform-origin: 96px 70px; animation: cele-wave-r .5s ease-in-out infinite alternate; }
.cele-spark { fill: var(--amber); transform-box: fill-box; transform-origin: center; animation: cele-twinkle 1.6s ease-in-out infinite; }
.cele-spark.s2 { fill: var(--primary); animation-delay: .4s; }
.cele-spark.s3 { fill: #FB7185; animation-delay: .8s; }
.cele-spark.s4 { fill: var(--primary); animation-delay: 1.2s; }
@keyframes cele-hop {
  0%, 100% { transform: translateY(0) scale(1, 1); }
  18% { transform: translateY(0) scale(1.08, .9); }
  42% { transform: translateY(-14px) scale(.95, 1.06); }
  66% { transform: translateY(0) scale(1.06, .93); }
  80% { transform: translateY(0) scale(.98, 1.02); }
}
@keyframes cele-shadow { 0%, 18%, 66%, 100% { transform: scale(1); opacity: 1; } 42% { transform: scale(.7); opacity: .5; } }
@keyframes cele-wave-l { from { transform: rotate(8deg); } to { transform: rotate(-14deg); } }
@keyframes cele-wave-r { from { transform: rotate(-8deg); } to { transform: rotate(14deg); } }
@keyframes cele-twinkle { 0%, 100% { opacity: .25; scale: .6; } 50% { opacity: 1; scale: 1.15; } }

.cele-badge {
  display: inline-block; margin-top: .35rem; padding: .2rem .7rem; border-radius: 999px;
  background: var(--primary-soft); color: var(--primary-ink); font-size: .78rem; font-weight: 700;
}
.cele-title {
  margin: .55rem 0 .2rem; font-size: 1.45rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.25;
  color: var(--bs-emphasis-color);
  animation: cele-pop .55s var(--ease) .1s both;
}
@keyframes cele-pop { from { opacity: 0; transform: translateY(8px) scale(.92); } to { opacity: 1; transform: none; } }
.cele-cheer {
  display: inline-flex; flex-direction: column; align-items: center; gap: 0;
  margin: 0 auto .35rem; padding: .25rem .9rem; border: 0; border-radius: 14px; background: transparent;
  transition: background-color .2s ease;
}
.cele-cheer:hover { background: var(--surface-2); }
.cele-zh { font-family: var(--font-zh-card); font-size: 1.7rem; font-weight: 700; line-height: 1.35; color: var(--rose); }
[data-bs-theme="dark"] .cele-zh { color: #FB7185; }
.cele-py { font-size: .8rem; color: var(--text-muted); }
.cele-py i { margin-left: .15rem; color: var(--primary); }
.cele-sub { margin: 0 auto 1rem; max-width: 22rem; font-size: .92rem; line-height: 1.5; color: var(--text-muted); }
.cele-sub b { color: var(--text); }

.cele-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; margin-bottom: .9rem; }
.cele-stat {
  display: flex; flex-direction: column; align-items: center; gap: .05rem;
  padding: .65rem .35rem .6rem; border-radius: 16px; background: var(--surface-2);
  animation: cele-pop .5s var(--ease) both;
}
.cele-stat:nth-child(1) { animation-delay: .2s; }
.cele-stat:nth-child(2) { animation-delay: .3s; }
.cele-stat:nth-child(3) { animation-delay: .4s; }
.cele-stat-icon { font-size: 1.15rem; line-height: 1.2; }
.cele-stat b { font-size: 1.35rem; line-height: 1.2; font-variant-numeric: tabular-nums; color: var(--bs-emphasis-color); }
.cele-stat span:last-child { font-size: .72rem; color: var(--text-muted); }
.cele-extra { display: flex; flex-wrap: wrap; justify-content: center; gap: .4rem; margin-bottom: .9rem; }
.cele-extra:empty { display: none; }
.cele-pill { padding: .2rem .65rem; border-radius: 999px; background: var(--amber-soft); color: var(--amber-ink); font-size: .78rem; font-weight: 600; }
.cele-next { min-height: 48px; border-radius: 14px; font-size: 1rem; }

.cele-donate {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem .75rem;
  margin-top: .85rem; padding: .55rem .6rem .55rem .9rem;
  border-radius: 14px; background: var(--amber-soft);
  font-size: .84rem; line-height: 1.4; text-align: left; color: var(--text);
}
.cele-donate-btn {
  flex: none; min-height: 36px; padding: 0 .85rem; border: 0; border-radius: 999px;
  background: var(--amber); color: #fff; font-size: .84rem; font-weight: 700; white-space: nowrap;
  box-shadow: 0 3px 10px rgba(245, 158, 11, .3);
  transition: transform .15s ease, background-color .2s ease;
}
.cele-donate-btn:hover { background: var(--amber-hover); transform: translateY(-1px); }
.cele-donate-btn:active { transform: scale(.96); }

/* Pháo giấy rơi khắp màn hình (tạo bằng JS, tự xóa sau vài giây) */
.confetti-layer { position: fixed; inset: 0; z-index: 1070; overflow: hidden; pointer-events: none; }
.confetti-piece {
  position: absolute; top: -20px; width: 8px; height: 12px; border-radius: 2px; opacity: 0;
  animation: confetti-fall 3s cubic-bezier(.25, .6, .45, 1) forwards;
}
.confetti-piece.is-round { width: 9px; height: 9px; border-radius: 50%; }
.confetti-piece.is-strip { width: 5px; height: 16px; }
@keyframes confetti-fall {
  0% { opacity: 1; transform: translate3d(0, 0, 0) rotate(0); }
  85% { opacity: 1; }
  100% { opacity: 0; transform: translate3d(var(--drift, 0), 105vh, 0) rotate(var(--spin, 540deg)); }
}

/* Khung chung của 2 modal Tài liệu học tập / Mời tác giả ly trà */
.support-modal .modal-content { border-radius: 20px; }
.support-modal .modal-header { align-items: flex-start; padding: 1.1rem 1.25rem .9rem; }
.support-modal .modal-title { display: flex; align-items: center; gap: .5rem; font-weight: 700; color: var(--bs-emphasis-color); }
.support-modal .modal-title i { color: var(--primary); }
.sp-sub { margin-top: .15rem; font-size: .82rem; color: var(--text-muted); }
.support-modal .modal-body { padding: 1rem 1.25rem 1.25rem; }
.sp-demo { font-size: .85rem; }
.sp-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 1.25rem; align-items: start; }
.sp-lead { margin-bottom: .75rem; color: var(--text-muted); font-size: .9rem; }

.sp-products { display: grid; gap: .6rem; }
.sp-product {
  position: relative; display: flex; gap: .8rem; margin: 0;
  padding: .85rem 2.75rem .85rem .85rem;
  border: 1.5px solid var(--border); border-radius: 14px; background: var(--surface);
  cursor: pointer; transition: border-color .2s ease, background-color .2s ease, box-shadow .2s ease;
}
.sp-product:hover { border-color: rgba(var(--primary-rgb), .45); }
.sp-product.active { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 0 0 3px rgba(var(--primary-rgb), .12); }
.sp-product input { position: absolute; opacity: 0; pointer-events: none; }
.sp-product:has(input:focus-visible) { outline: 2px solid var(--primary); outline-offset: 2px; }
.sp-product-icon {
  flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px;
  background: var(--surface-2); color: var(--primary-ink); font-size: 1.15rem;
}
.sp-product.active .sp-product-icon { background: var(--surface); }
.sp-product-body { display: flex; flex-direction: column; gap: .25rem; min-width: 0; flex: 1; }
.sp-product-top { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.sp-product-name { font-weight: 700; line-height: 1.3; color: var(--bs-emphasis-color); }
.sp-badge {
  padding: .1rem .5rem; border-radius: 999px; background: var(--amber-soft); color: var(--amber-ink);
  font-size: .7rem; font-weight: 700; white-space: nowrap;
}
.sp-badge-jade { background: var(--primary); color: var(--on-primary); }
.sp-product-desc { font-size: .83rem; line-height: 1.45; color: var(--text-muted); }
.sp-product-foot { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-top: .15rem; }
.sp-format { padding: .05rem .45rem; border: 1px solid var(--border); border-radius: 6px; font-size: .72rem; font-weight: 600; color: var(--text-muted); }
.sp-price { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--primary-ink); white-space: nowrap; }
.sp-price s { margin-left: .25rem; font-size: .82rem; font-weight: 500; color: var(--text-muted); }
.sp-check {
  position: absolute; top: .85rem; right: .85rem;
  display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  border: 1.5px solid var(--border); color: transparent; font-size: .8rem;
  transition: all .2s ease;
}
.sp-product.active .sp-check { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }

.sp-letter { margin-bottom: 1.1rem; padding: .9rem 1rem; border-radius: 14px; background: var(--surface-2); font-size: .9rem; line-height: 1.55; }
.sp-letter p { margin-bottom: .5rem; }
.sp-tiers { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .5rem; }
.sp-tier {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .15rem;
  min-height: 78px; padding: .65rem .35rem;
  border: 1.5px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--text);
  transition: all .2s ease;
}
.sp-tier:hover { border-color: rgba(var(--primary-rgb), .45); }
.sp-tier.active { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 0 0 3px rgba(var(--primary-rgb), .12); }
.sp-tier-amt { font-size: 1.05rem; font-weight: 700; color: var(--bs-emphasis-color); white-space: nowrap; }
.sp-tier.active .sp-tier-amt { color: var(--primary-ink); }
.sp-tier-label { font-size: .72rem; line-height: 1.3; text-align: center; color: var(--text-muted); }
.sp-tier-badge {
  position: absolute; top: -.6rem; left: 50%; transform: translateX(-50%);
  padding: .05rem .5rem; border-radius: 999px; background: var(--amber); color: #fff;
  font-size: .65rem; font-weight: 700; white-space: nowrap;
}
.sp-custom { margin-top: 1rem; }
.sp-custom .form-control { font-weight: 600; font-variant-numeric: tabular-nums; }
.sp-error { margin-top: .35rem; font-size: .83rem; color: var(--rose-ink); }

/* Khu vực VietQR (chung 2 tab) */
.sp-pay { position: sticky; top: 0; padding: 1rem; border-radius: 16px; background: var(--surface-2); }   /* máy tính: QR luôn trong tầm mắt khi cuộn danh sách gói */
.sp-pay-head { display: flex; flex-direction: column; align-items: center; margin-bottom: .75rem; text-align: center; }
.sp-pay-for { font-size: .8rem; line-height: 1.35; color: var(--text-muted); }
.sp-pay-amount { font-size: 1.6rem; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; color: var(--primary-ink); }
.sp-qr {
  position: relative; width: 100%; max-width: 240px; aspect-ratio: 540 / 640; margin: 0 auto;
  border-radius: 14px; background: #fff; overflow: hidden; box-shadow: var(--shadow-sm);
}
.sp-qr img { display: block; width: 100%; height: 100%; object-fit: contain; }
/* Thông tin chuyển khoản còn là mẫu: dải "MẪU" chéo qua mã QR */
.sp-qr-sample {
  position: absolute; left: -20%; right: -20%; top: 38%;
  padding: .3rem 0; transform: rotate(-20deg); pointer-events: none;
  background: rgba(225, 29, 72, .85); color: #fff;
  font-size: 1rem; font-weight: 800; letter-spacing: .3em; text-align: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .15);
}
.sp-qr.is-empty .sp-qr-sample, .sp-qr.is-loading .sp-qr-sample { display: none; }
.sp-qr-state {
  position: absolute; inset: 0; display: none; flex-direction: column; align-items: center; justify-content: center; gap: .5rem;
  padding: 1rem; background: #fff; color: #6B7280; font-size: .83rem; text-align: center;
}
.sp-qr-state i { font-size: 1.6rem; color: #9CA3AF; }
.sp-qr-loading .spinner-border { width: 1.5rem; height: 1.5rem; color: #0D9488; }
.sp-qr.is-loading .sp-qr-loading, .sp-qr.is-error .sp-qr-error, .sp-qr.is-empty .sp-qr-empty { display: flex; }
.sp-qr-actions { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-top: .85rem; }
.sp-qr-actions .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  padding: .4rem .5rem; font-size: .8rem; line-height: 1.25; white-space: normal;
}
.sp-qr-actions .btn.is-done, .sp-copy-mini.is-done {
  border-color: var(--primary) !important; background: var(--primary-soft) !important; color: var(--primary-ink) !important;
}
.sp-hint { margin-top: .5rem; font-size: .75rem; line-height: 1.4; text-align: center; color: var(--text-muted); }
.sp-info { display: grid; gap: .3rem; margin: .85rem 0 0; padding-top: .75rem; border-top: 1px dashed var(--border); font-size: .83rem; }
.sp-info > div { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.sp-info dt { font-weight: 500; color: var(--text-muted); white-space: nowrap; }
.sp-info dd { display: flex; align-items: center; gap: .2rem; min-width: 0; margin: 0; font-weight: 600; text-align: right; color: var(--text); overflow-wrap: anywhere; }
.sp-mono { font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.sp-copy-mini {
  flex: none; display: inline-grid; place-items: center; width: 28px; height: 28px;
  border: 1px solid transparent; border-radius: 8px; background: none; color: var(--text-muted);
}
.sp-copy-mini:hover { background: var(--surface); color: var(--primary-ink); }
.sp-deliver { margin-top: .9rem; padding-top: .85rem; border-top: 1px dashed var(--border); }
.sp-deliver-note { margin-bottom: .6rem; font-size: .82rem; line-height: 1.45; color: var(--text-muted); }
.sp-note-warn { color: var(--rose-ink); font-weight: 600; }
.sp-link-btn {
  display: block; width: 100%; margin-top: .45rem; padding: .25rem; border: 0; background: none;
  font-size: .8rem; color: var(--text-muted); text-decoration: underline; text-underline-offset: 2px;
}
.sp-link-btn:hover { color: var(--rose-ink); }

/* Đơn mua (js/support.js): khung đăng nhập / trạng thái đơn thay cho mã QR */
.sp-pay.is-gated > :not(.sp-gate) { display: none !important; }
.sp-pay:not(.is-gated) > .sp-gate { display: none; }
.sp-gate { display: flex; flex-direction: column; align-items: center; gap: .5rem; padding: 1.25rem .25rem; text-align: center; }
.sp-gate p { margin: 0; }
.sp-gate .btn { margin-top: .35rem; }
.sp-gate-icon { font-size: 2rem; line-height: 1; color: var(--text-muted); }
.sp-gate-icon.is-ok { color: var(--primary); }
.sp-gate-text { font-size: .83rem; line-height: 1.5; color: var(--text-muted); }
.sp-gate-error { margin: .5rem 0 0; font-size: .8rem; color: var(--rose-ink); }
.sp-spam-tip {
  display: flex; gap: .45rem; align-items: flex-start; width: 100%; padding: .55rem .7rem; border-radius: 10px;
  background: var(--amber-soft); color: var(--text); font-size: .8rem; line-height: 1.45; text-align: left;
}
.sp-spam-tip .bi { color: var(--amber-ink); margin-top: .1rem; }
.sp-gate .spinner-border { color: var(--primary); }
.sp-chip {
  align-self: flex-start; display: inline-flex; align-items: center; gap: .3rem;
  padding: .1rem .5rem; border-radius: 999px; font-size: .74rem; font-weight: 600;
}
.sp-chip-amber { background: var(--amber-soft); color: var(--amber-ink); }
.sp-chip-jade { background: var(--primary-soft); color: var(--primary-ink); }
.sp-chip-rose { background: var(--rose-soft); color: var(--rose-ink); }
.sp-remind:empty { display: none; }
.sp-remind-item { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1rem; font-size: .85rem; line-height: 1.5; }
.sp-remind-item > div:first-child { flex: 1 1 260px; }
.sp-remind-actions { display: flex; gap: .4rem; }
/* Có đơn chờ thanh toán quá 10 phút → chấm cam ở các lối vào "Tài liệu học tập" và nút tài khoản (điện thoại) */
html.sp-order-due .nav-support, html.sp-order-due .account-menu [data-support-open="resources"] { position: relative; }
html.sp-order-due .nav-support::after,
html.sp-order-due .account-menu [data-support-open="resources"]::after {
  content: ""; position: absolute; top: 2px; right: 2px; width: 9px; height: 9px;
  border-radius: 50%; background: var(--amber); box-shadow: 0 0 0 2px var(--bg);
}
html.sp-order-due .account-menu [data-support-open="resources"]::after { top: 50%; right: 1rem; margin-top: -4.5px; }
@media (max-width: 575.98px) {
  html.sp-order-due .account-btn { position: relative; }
  html.sp-order-due .account-btn::before {
    content: ""; position: absolute; top: 3px; left: 3px; z-index: 1; width: 9px; height: 9px;
    border-radius: 50%; background: var(--amber); box-shadow: 0 0 0 2px var(--bg);
  }
}

@media (max-width: 767.98px) {
  .nav-support span { display: none; }
  .nav-support { width: 36px; padding: 0; margin-right: .15rem; }
  .sp-layout { grid-template-columns: minmax(0, 1fr); gap: 1rem; }
  .sp-pay { position: static; }
}
@media (max-width: 575.98px) {
  .nav-support { display: none; }     /* điện thoại: mở từ menu tài khoản */
  .support-modal .modal-header { padding: 1rem 1rem .8rem; }
  .support-modal .modal-body { padding: .875rem 1rem 1rem; }
  .sp-tiers { grid-template-columns: 1fr 1fr; gap: .85rem .5rem; padding-top: .35rem; }
  .res-promo { flex-wrap: wrap; align-items: flex-start; gap: .25rem .75rem; padding: .85rem 1rem; }
  .res-promo-text { flex-basis: calc(100% - 3.25rem); }
  .res-promo-cta { margin-left: calc(40px + .75rem); }
  .sp-product { padding: .75rem 2.5rem .75rem .75rem; gap: .65rem; }
  .sp-product-icon { width: 36px; height: 36px; font-size: 1.05rem; }
  .sp-qr { max-width: 220px; }
  .cele-modal .modal-body { padding: 1.1rem 1.1rem 1.2rem; }
  .cele-title { font-size: 1.3rem; }
  .cele-donate { flex-direction: column; text-align: center; padding: .7rem; }
}

/* ---------- 12. Giảm chuyển động ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
