/* ═══════════════════════════════════════════════════════════════
   Mikuvi Nihongo — giao diện ưu tiên điện thoại, sáng / tối
   ═══════════════════════════════════════════════════════════════ */

:root {
  --bg: #f4f5f9;
  --surface: #ffffff;
  --surface-2: #eef0f6;
  --text: #1b1e2b;
  --muted: #697089;
  --line: #e3e6ef;
  --track: #e5e8f1;
  --shadow: 0 1px 2px rgba(20, 24, 50, .05), 0 6px 18px rgba(20, 24, 50, .06);
  --shadow-up: 0 -6px 24px rgba(20, 24, 50, .08);

  --brand: #5b5bf0;
  --c-kana: #e4517a;
  --c-vocab: #0c9f86;
  --c-grammar: #8b5cf6;
  --c-kanji: #e07f0b;
  --c-talk: #0a84c6;
  --ok: #17a660;
  --bad: #e5484d;
  --warn: #f08c00;
  --gold: #c8930a;

  --acc: var(--brand);
  --acc-soft: color-mix(in srgb, var(--acc) 13%, transparent);
  --acc-ink: color-mix(in srgb, var(--acc) 82%, #000);

  --radius: 18px;
  --radius-sm: 12px;
  --tabbar-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-jp: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Noto Sans CJK JP", "Yu Gothic UI", "Yu Gothic", Meiryo, sans-serif;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0f1220;
  --surface: #181c2e;
  --surface-2: #222740;
  --text: #edf0f8;
  --muted: #9aa1ba;
  --line: #2a3049;
  --track: #2b3150;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 22px rgba(0, 0, 0, .25);
  --shadow-up: 0 -6px 24px rgba(0, 0, 0, .35);
  --brand: #8486ff;
  --c-kana: #ff7096;
  --c-vocab: #2cc6a8;
  --c-grammar: #a888ff;
  --c-kanji: #ffa53a;
  --c-talk: #45b4f2;
  --ok: #2cc57c;
  --bad: #ff6b6f;
  --warn: #ffaa33;
  --gold: #f0bf3a;
  --acc-ink: color-mix(in srgb, var(--acc) 75%, #fff);
  color-scheme: dark;
}

.acc-brand { --acc: var(--brand); }
.acc-kana { --acc: var(--c-kana); }
.acc-vocab { --acc: var(--c-vocab); }
.acc-grammar { --acc: var(--c-grammar); }
.acc-kanji { --acc: var(--c-kanji); }
.acc-talk { --acc: var(--c-talk); }
/* Biến dẫn xuất phải khai báo lại ở từng vùng màu, nếu không sẽ giữ giá trị tính ở :root */
[class*="acc-"] {
  --acc-soft: color-mix(in srgb, var(--acc) 13%, transparent);
  --acc-ink: color-mix(in srgb, var(--acc) 82%, #000);
}
:root[data-theme="dark"] [class*="acc-"] { --acc-ink: color-mix(in srgb, var(--acc) 72%, #fff); }

/* ───────────── Nền tảng ───────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html.has-overlay body { overflow: hidden; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
[lang="ja"], .jp { font-family: var(--font-jp); }
h1, h2, h3, h4, p { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; text-align: inherit; }
button:disabled { cursor: default; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--acc) 55%, transparent); outline-offset: 2px; }
.ic { flex: none; display: block; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.center { text-align: center; }

/* ───────────── Màn hình chờ ───────────── */
.splash { min-height: 100dvh; display: grid; place-content: center; justify-items: center; gap: 14px; }
.splash-logo, .auth-hero .logo {
  width: 84px; height: 84px; border-radius: 26px; display: grid; place-items: center;
  background: linear-gradient(140deg, #6d6bff, #ef5d8c); color: #fff; font-size: 46px; font-weight: 700;
  box-shadow: 0 12px 30px rgba(110, 90, 255, .35);
}
.splash-name { font-weight: 700; font-size: 20px; letter-spacing: .2px; }
.splash-dots, .loading { display: flex; gap: 6px; justify-content: center; }
.splash-dots i, .loading i { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); animation: blink 1s infinite; }
.splash-dots i:nth-child(2) { animation-delay: .15s; }
.splash-dots i:nth-child(3) { animation-delay: .3s; }
.loading { padding: 80px 0; }
@keyframes blink { 0%, 100% { opacity: .25; transform: scale(.85); } 50% { opacity: 1; transform: scale(1); } }

/* ───────────── Khung + thanh tab ───────────── */
.shell { min-height: 100dvh; }
.view { max-width: 640px; margin: 0 auto; padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + 20px); }
.tabbar {
  position: fixed; inset: auto 0 0 0; z-index: 20;
  display: flex; justify-content: center;
  height: calc(var(--tabbar-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.6) blur(16px); -webkit-backdrop-filter: saturate(1.6) blur(16px);
  border-top: 1px solid var(--line);
}
.tabbar a {
  position: relative; flex: 1; max-width: 160px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); font-size: 12px; font-weight: 600;
}
.tabbar a.on { color: var(--brand); }
.tabbar a.on .ic { transform: translateY(-1px); }
.tabbar .badge {
  position: absolute; top: 7px; left: calc(50% + 6px);
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--bad); color: #fff; font: 700 11px/18px var(--font); font-style: normal; text-align: center;
}

/* ───────────── Trang ───────────── */
.page-in { animation: pageIn .28s ease-out; }
@keyframes pageIn { from { opacity: 0; transform: translateY(8px); } }
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 4px;
  min-height: calc(56px + var(--safe-t)); padding: var(--safe-t) 12px 0;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.topbar h1 { flex: 1; font-size: 20px; font-weight: 750; padding-left: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.page-body { padding: 4px 16px 16px; display: flex; flex-direction: column; gap: 14px; }

.icon-btn {
  width: 44px; height: 44px; flex: none; border-radius: 50%;
  display: grid; place-items: center; color: var(--text);
  transition: background .15s;
}
.icon-btn:active { background: var(--surface-2); }
.icon-btn.lg { width: 54px; height: 54px; }

.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.sec-title { font-size: 17px; font-weight: 750; margin-top: 8px; display: flex; align-items: center; gap: 8px; }
.sec-title small { font-weight: 500; font-size: 13px; color: var(--muted); margin-left: auto; }
.sec-title .ic { color: var(--acc); }

.tag {
  display: inline-flex; align-items: center; gap: 4px; vertical-align: middle;
  padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 650; font-style: normal;
  background: var(--surface-2); color: var(--muted);
}
.tag.new { background: var(--acc-soft); color: var(--acc-ink); }
.tag.gold { background: color-mix(in srgb, var(--gold) 18%, transparent); color: var(--gold); }
.tag.warn { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }

.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 6px 12px; border-radius: 999px;
  background: var(--surface); box-shadow: var(--shadow); font-weight: 700; font-size: 15px;
}
.chip.flame { color: var(--muted); }
.chip.flame.on { color: #f26b1d; }
.chip.xp { color: var(--brand); }

/* Thanh tiến độ & vòng tròn */
.bar { height: 8px; border-radius: 99px; background: var(--track); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: inherit; background: var(--acc); transition: width .45s cubic-bezier(.3, .7, .3, 1); }
.ring { display: block; flex: none; }
.ring circle { transition: stroke-dashoffset .6s cubic-bezier(.3, .7, .3, 1); }
.ring-label { fill: var(--text); font-weight: 800; font-family: var(--font); }

/* ───────────── Nút ───────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 50px; padding: 0 20px; border-radius: 14px;
  font-weight: 700; font-size: 16px; text-align: center;
  transition: transform .08s, filter .15s, background .15s;
  user-select: none; -webkit-user-select: none;
}
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .5; }
.btn-block { width: 100%; }
.btn-sm { min-height: 40px; padding: 0 14px; font-size: 14px; border-radius: 12px; }
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 4px 0 color-mix(in srgb, var(--brand) 70%, #000); }
.btn-acc { background: var(--acc); color: #fff; box-shadow: 0 4px 0 color-mix(in srgb, var(--acc) 70%, #000); }
.btn-ok { background: var(--ok); color: #fff; box-shadow: 0 4px 0 color-mix(in srgb, var(--ok) 70%, #000); }
.btn-bad { background: var(--bad); color: #fff; box-shadow: 0 4px 0 color-mix(in srgb, var(--bad) 70%, #000); }
.btn-gold { background: linear-gradient(135deg, #f7c948, #e59a0f); color: #3b2500; box-shadow: 0 4px 0 #b97a06; }
.btn-soft { background: var(--surface-2); color: var(--text); }
.btn-ghost { color: var(--brand); background: transparent; }
.btn-primary:active:not(:disabled), .btn-acc:active:not(:disabled), .btn-ok:active:not(:disabled), .btn-bad:active:not(:disabled), .btn-gold:active:not(:disabled) { box-shadow: 0 1px 0 rgba(0, 0, 0, .25); transform: translateY(3px); }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.btn-col { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.pill-btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 9px 15px; border-radius: 999px;
  background: var(--acc-soft); color: var(--acc-ink); font-weight: 650; font-size: 14px;
}
.pill-btn:active { filter: brightness(.95); }

/* ───────────── Phân đoạn (tab nhỏ) ───────────── */
.seg { display: flex; gap: 4px; padding: 4px; border-radius: 14px; background: var(--surface-2); }
.seg button {
  flex: 1; min-height: 40px; padding: 6px 8px; border-radius: 11px; text-align: center;
  font-weight: 650; font-size: 15px; color: var(--muted); transition: background .15s, color .15s;
}
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.seg.big button { display: flex; flex-direction: column; align-items: center; gap: 0; min-height: 58px; font-size: 13px; }
.seg.big button span { font-size: 19px; font-weight: 700; color: inherit; }
.seg.big button.on span { color: var(--acc); }
.seg.sm button { min-height: 36px; font-size: 14px; }
.seg.goals button { display: flex; flex-direction: column; align-items: center; min-height: 56px; }
.seg.goals small { font-size: 11px; font-weight: 500; }

/* ───────────── Danh sách ───────────── */
.list { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.row {
  display: flex; align-items: center; gap: 12px; width: 100%;
  min-height: 60px; padding: 10px 14px; border-bottom: 1px solid var(--line);
  transition: background .12s;
}
.row:last-child { border-bottom: 0; }
button.row:active, a.row:active, .row.word:active { background: var(--surface-2); }
.row > .ic { color: var(--acc); }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row-main b { font-weight: 650; overflow-wrap: anywhere; }
.row-main span { color: var(--muted); font-size: 14px; }
.row-main small { color: var(--muted); font-size: 12.5px; }
.row.danger { color: var(--bad); }
.row.danger > .ic { color: var(--bad); }
.row.locked { opacity: .62; }
.row.off { opacity: .55; }
.row:disabled { opacity: .6; }

.lesson-chars {
  min-width: 78px; max-width: 120px; padding: 8px 10px; border-radius: 12px; text-align: center;
  background: var(--acc-soft); color: var(--acc-ink); font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden;
}
.lesson-num {
  width: 38px; height: 38px; flex: none; border-radius: 12px; display: grid; place-items: center;
  background: var(--acc-soft); color: var(--acc-ink); font-weight: 800;
}
.done-mark { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--ok); color: #fff; flex: none; }
.score { font-weight: 800; font-size: 15px; color: var(--muted); flex: none; }
.score.good { color: var(--ok); }

.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--track); display: inline-block; }
.dot.m1 { background: color-mix(in srgb, var(--acc) 45%, var(--track)); }
.dot.m2 { background: var(--ok); }
.legend { display: flex; justify-content: center; gap: 16px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

/* ───────────── Trang chủ ───────────── */
.home-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(18px + var(--safe-t)) 16px 6px;
}
.home-head small { color: var(--muted); font-size: 14px; }
.home-head h1 { font-size: 24px; font-weight: 800; line-height: 1.25; }
.home-chips { display: flex; gap: 8px; flex: none; }
.banner {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 14px;
  background: color-mix(in srgb, var(--brand) 12%, var(--surface)); color: var(--text); font-size: 14px;
}
.banner > .ic:first-child { color: var(--brand); }
.banner span { flex: 1; }

.goal { display: flex; align-items: center; gap: 16px; }
.goal-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.goal-info span { color: var(--muted); font-size: 14px; }
.week { display: flex; gap: 6px; margin-top: 8px; }
.week i { flex: 1; max-width: 34px; height: 8px; border-radius: 4px; background: var(--track); position: relative; font-style: normal; }
.week i.on { background: var(--ok); }
.week i.today { outline: 2px solid color-mix(in srgb, var(--brand) 50%, transparent); outline-offset: 1px; }
.week em { position: absolute; top: 11px; left: 0; right: 0; text-align: center; font-size: 10px; color: var(--muted); font-style: normal; }
.goal .week { margin-bottom: 14px; }

.cta { display: flex; align-items: center; gap: 14px; background: linear-gradient(130deg, var(--brand), color-mix(in srgb, var(--brand) 55%, #ef5d8c)); color: #fff; }
.cta-icon { width: 50px; height: 50px; border-radius: 15px; display: grid; place-items: center; background: rgba(255, 255, 255, .2); flex: none; }
.cta-info { flex: 1; display: flex; flex-direction: column; }
.cta-info span { opacity: .88; font-size: 14px; }

.steps { display: flex; flex-direction: column; gap: 12px; position: relative; }
.step { display: flex; align-items: center; gap: 14px; transition: transform .1s; }
a.step:active { transform: scale(.985); }
.step-glyph {
  width: 58px; height: 58px; border-radius: 17px; flex: none; display: grid; place-items: center;
  font-size: 30px; font-weight: 700; color: #fff;
  background: linear-gradient(140deg, var(--acc), color-mix(in srgb, var(--acc) 60%, #000));
  box-shadow: 0 6px 14px color-mix(in srgb, var(--acc) 35%, transparent);
}
.step-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.step-info small { color: var(--acc); font-weight: 750; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
.step-info b { font-size: 17px; }
.step-info span { color: var(--muted); font-size: 13.5px; }
.step-info .bar { margin-top: 7px; height: 6px; }
.step-info em { font-style: normal; color: var(--muted); font-size: 12px; margin-top: 3px; }
.step-pct { font-weight: 800; color: var(--acc); font-size: 15px; flex: none; }
.step.soon { opacity: .7; }
.step.soon .step-glyph { background: var(--surface-2); color: var(--muted); box-shadow: none; }

/* ───────────── Khối tổng quan ───────────── */
.summary { display: flex; align-items: center; gap: 16px; }
.summary-info { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.summary-info span { color: var(--muted); font-size: 14px; margin-bottom: 8px; }

.levels { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 2px 16px; }
.levels::-webkit-scrollbar { display: none; }
.level {
  flex: none; display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-width: 64px; min-height: 48px; padding: 4px 12px; border-radius: 14px;
  background: var(--surface); box-shadow: var(--shadow); font-weight: 800; color: var(--muted);
}
.level small { font-size: 10px; font-weight: 600; }
.level.on { background: var(--acc); color: #fff; }

/* ───────────── Bảng chữ cái ───────────── */
.kana-grid { display: grid; gap: 8px; }
.kana-grid.cols-5 { grid-template-columns: repeat(5, 1fr); }
.kana-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.kana-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.kana-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.kana-grid.cols-1 { grid-template-columns: 1fr; }
.kana-cell {
  aspect-ratio: 1 / 1.05; border-radius: 14px; background: var(--surface); box-shadow: var(--shadow);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0;
  border: 2px solid transparent; transition: transform .08s;
}
.kana-cell:active { transform: scale(.94); }
.kana-cell span { font-size: clamp(22px, 7vw, 32px); font-weight: 600; line-height: 1.15; }
.kana-grid.cols-3 .kana-cell { aspect-ratio: 1.5 / 1; }
.kana-cell small { font-size: 12px; color: var(--muted); font-weight: 600; }
.kana-cell.m1 { border-color: color-mix(in srgb, var(--acc) 40%, transparent); }
.kana-cell.m2 { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 8%, var(--surface)); }
.kana-cell.blank { background: transparent; box-shadow: none; }

/* ───────────── Chủ đề ───────────── */
.topics { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.topic { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 3px; padding: 14px; text-align: left; transition: transform .1s; }
.topic:active { transform: scale(.97); }
.topic-icon { font-size: 30px; line-height: 1.1; margin-bottom: 6px; }
.topic b { font-size: 15px; line-height: 1.3; }
.topic span { color: var(--muted); font-size: 12.5px; }
.topic .bar { width: 100%; margin-top: 8px; height: 6px; }
.topic.locked { opacity: .7; }
.topic.locked .topic-icon { filter: grayscale(1); }
.topic-lock, .topic-pro { position: absolute; top: 12px; right: 12px; color: var(--muted); font-style: normal; }
.topic-pro { color: var(--gold); }

.actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.action {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 4px;
  border-radius: 16px; background: var(--surface); box-shadow: var(--shadow); color: var(--acc);
  font-size: 12.5px; font-weight: 650; text-align: center; transition: transform .1s;
}
.action span { color: var(--text); }
.action:active { transform: scale(.95); }

.row.word { cursor: pointer; }
.word .row-main b { font-size: 19px; font-weight: 600; }
.word-kanji { font-size: 30px; width: 46px; text-align: center; flex: none; }

/* ───────────── Ngữ pháp ───────────── */
.g-hero { background: linear-gradient(140deg, var(--acc), color-mix(in srgb, var(--acc) 55%, #1d1b4d)); color: #fff; }
.g-hero h2 { font-size: 24px; font-weight: 800; }
.g-hero p { opacity: .9; margin-top: 4px; }
.patterns { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.pattern { background: rgba(255, 255, 255, .16); border-radius: 12px; padding: 10px 14px; font-size: 17px; font-weight: 600; }
.prose p + p { margin-top: 10px; }
.prose p { line-height: 1.65; }
.note { display: flex; gap: 10px; background: color-mix(in srgb, var(--warn) 12%, var(--surface)); box-shadow: none; }
.note > .ic { color: var(--warn); margin-top: 2px; }
.note ul { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; font-size: 15px; }
.examples { display: flex; flex-direction: column; gap: 10px; }
.example { position: relative; display: flex; flex-direction: column; gap: 2px; padding-right: 48px; text-align: left; transition: transform .1s; }
.example:active { transform: scale(.985); }
.ex-jp { font-size: 19px; font-weight: 600; }
.ex-kana { font-size: 13.5px; color: var(--muted); }
.ex-vi { font-size: 15px; margin-top: 4px; }
.example i { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--acc); }
.exercise-cta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; border: 2px solid var(--acc-soft); }
.exercise-cta > div { flex: 1; min-width: 180px; display: flex; flex-direction: column; }
.exercise-cta span { color: var(--muted); font-size: 14px; }
.next-lesson { border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }

/* ───────────── Hội thoại ───────────── */
.talk-icon {
  width: 42px; height: 42px; flex: none; border-radius: 13px; display: grid; place-items: center;
  font-size: 22px; background: var(--acc-soft);
}
.t-hero { background: linear-gradient(140deg, var(--acc), color-mix(in srgb, var(--acc) 55%, #10264d)); color: #fff; }
.t-hero-top { display: flex; align-items: center; gap: 12px; }
.t-emoji { font-size: 36px; line-height: 1; flex: none; }
.t-hero h2 { font-size: 23px; font-weight: 800; line-height: 1.3; }
.t-hero p { opacity: .92; }
.t-scene { margin-top: 10px; font-size: 14.5px; line-height: 1.5; }
.cast { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.cast span { background: rgba(255, 255, 255, .17); border-radius: 999px; padding: 4px 11px; font-size: 13px; }
.cast b { font-weight: 700; }
.talk-tools { display: flex; flex-direction: column; gap: 10px; }
.talk-toggles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.toggle-pill {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 10px;
  border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); color: var(--muted); font-weight: 650; font-size: 14px;
  transition: background .15s, color .15s;
}
.toggle-pill span {
  min-width: 24px; height: 24px; padding: 0 4px; border-radius: 7px; display: grid; place-items: center;
  background: var(--surface-2); font-size: 12.5px; font-weight: 750;
}
.toggle-pill.on { background: var(--acc-soft); color: var(--acc-ink); box-shadow: none; }
.toggle-pill.on span { background: var(--acc); color: #fff; }
.note-voice { background: color-mix(in srgb, var(--warn) 12%, var(--surface)); box-shadow: none; font-size: 14px; }
.chat { display: flex; flex-direction: column; gap: 10px; }
.bubble-row { display: flex; align-items: flex-end; gap: 8px; }
.bubble-row.right { flex-direction: row-reverse; }
.speaker {
  width: 34px; height: 34px; flex: none; border-radius: 50%; display: grid; place-items: center;
  font-size: 15px; font-weight: 700; background: var(--surface-2); color: var(--text);
}
.right .speaker { background: var(--acc); color: #fff; }
.bubble {
  max-width: calc(100% - 42px); display: flex; flex-direction: column; gap: 2px; text-align: left;
  padding: 9px 14px 10px; border-radius: 18px; background: var(--surface); box-shadow: var(--shadow);
  transition: transform .1s, box-shadow .15s;
}
.left .bubble { border-bottom-left-radius: 6px; }
.right .bubble { border-bottom-right-radius: 6px; background: color-mix(in srgb, var(--acc) 11%, var(--surface)); }
.bubble:active { transform: scale(.985); }
.bubble.playing { box-shadow: 0 0 0 2px var(--acc), var(--shadow); }
.b-who { font-size: 12px; font-weight: 700; color: var(--acc-ink); }
.b-jp { font-size: 18px; font-weight: 600; line-height: 1.45; overflow-wrap: anywhere; }
.b-kana { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.b-vi { font-size: 14.5px; margin-top: 4px; padding-top: 5px; border-top: 1px dashed var(--line); }
.chat.no-kana .b-kana, .chat.no-vi .b-vi { display: none; }

/* ───────────── Ôn tập ───────────── */
.review-hero { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; }
.review-hero > div:not(.review-count) { flex: 1; min-width: 180px; display: flex; flex-direction: column; }
.review-hero span { color: var(--muted); font-size: 14px; }
.review-count {
  width: 76px; height: 76px; border-radius: 22px; display: grid; place-items: center; flex: none;
  background: linear-gradient(140deg, var(--brand), color-mix(in srgb, var(--brand) 55%, #ef5d8c)); color: #fff; font-size: 30px; font-weight: 800;
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.mini-card { display: flex; flex-direction: column; gap: 2px; text-align: left; color: var(--brand); transition: transform .1s; }
.mini-card:active { transform: scale(.97); }
.mini-card b { color: var(--text); margin-top: 6px; }
.mini-card span { color: var(--muted); font-size: 13.5px; }
.memory { display: flex; justify-content: space-around; align-items: flex-end; gap: 12px; }
.mem-col { display: flex; flex-direction: column; align-items: center; gap: 4px; flex: 1; }
.mem-bar { width: 44px; height: 110px; border-radius: 12px; background: var(--surface-2); display: flex; align-items: flex-end; overflow: hidden; }
.mem-bar i { width: 100%; border-radius: 12px; transition: height .5s; }
.mem-bar i.m1 { background: color-mix(in srgb, var(--brand) 45%, var(--track)); }
.mem-bar i.m15 { background: var(--brand); }
.mem-bar i.m2 { background: var(--ok); }
.mem-col b { font-size: 18px; }
.mem-col span { font-size: 12.5px; color: var(--muted); }
.kind-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.kind-chips .chip { font-weight: 500; font-size: 13.5px; box-shadow: none; background: var(--surface); }

/* ───────────── Thi ───────────── */
.test-glyph {
  width: 48px; height: 48px; flex: none; border-radius: 14px; display: grid; place-items: center;
  font-size: 24px; font-weight: 700; background: var(--acc-soft); color: var(--acc-ink);
}
.badge-pass { flex: none; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge-pass.ok { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.badge-pass.bad { background: color-mix(in srgb, var(--bad) 13%, transparent); color: var(--bad); }

/* ───────────── Tôi ───────────── */
.me { display: flex; align-items: center; gap: 14px; }
.avatar {
  width: 58px; height: 58px; flex: none; border-radius: 50%; display: grid; place-items: center;
  background: linear-gradient(140deg, #6d6bff, #ef5d8c); color: #fff; font-size: 24px; font-weight: 800;
}
.avatar.sm { width: 40px; height: 40px; font-size: 17px; }
.me-info { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.me-info b { font-size: 18px; }
.me-info > span:not(.tag) { color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.upsell { display: flex; align-items: center; gap: 12px; text-align: left; background: linear-gradient(130deg, #fff4d6, #ffe3a6); color: #4a3200; }
:root[data-theme="dark"] .upsell { background: linear-gradient(130deg, #3a2e10, #4b3809); color: #ffe3a0; }
.upsell > div { flex: 1; display: flex; flex-direction: column; }
.upsell span { font-size: 13.5px; opacity: .85; }
.upsell > .ic:first-child { color: var(--gold); }
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat-grid .stat { display: flex; flex-direction: column; padding: 14px; }
.stat-grid .stat b { font-size: 24px; font-weight: 800; }
.stat-grid .stat span { color: var(--muted); font-size: 13px; }
.setting.col { flex-direction: column; align-items: stretch; gap: 8px; padding-top: 12px; padding-bottom: 12px; }
.setting select {
  width: 100%; min-height: 44px; padding: 0 12px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface-2); font-size: 15px;
}
.warn-row { color: var(--warn); font-size: 14px; background: color-mix(in srgb, var(--warn) 9%, transparent); }
.switch {
  appearance: none; -webkit-appearance: none; flex: none; position: relative; cursor: pointer;
  width: 52px; height: 32px; border-radius: 16px; background: var(--track); transition: background .2s; margin: 0;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 5px rgba(0, 0, 0, .2); transition: transform .2s;
}
.switch:checked { background: var(--ok); }
.switch:checked::after { transform: translateX(20px); }

/* Quản trị */
.search {
  display: flex; align-items: center; gap: 8px; padding: 0 14px; border-radius: 14px;
  background: var(--surface); box-shadow: var(--shadow); color: var(--muted);
}
.search input { flex: 1; min-height: 48px; border: 0; background: transparent; outline: none; color: var(--text); }
.admin-user { display: flex; flex-direction: column; gap: 12px; }
.note-inline { display: flex; gap: 8px; padding: 10px 12px; border-radius: 12px; background: color-mix(in srgb, var(--warn) 12%, transparent); font-size: 14px; }
.note-inline .ic { color: var(--warn); }

/* ───────────── Đăng nhập ───────────── */
.auth { max-width: 440px; margin: 0 auto; padding: calc(36px + var(--safe-t)) 20px calc(30px + var(--safe-b)); display: flex; flex-direction: column; gap: 16px; position: relative; }
.auth-back { position: absolute; top: calc(8px + var(--safe-t)); left: 8px; }
.auth-hero { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; margin-bottom: 6px; }
.auth-hero h1 { font-size: 26px; font-weight: 800; margin-top: 8px; }
.auth-hero p { color: var(--muted); }
.auth-card { display: flex; flex-direction: column; gap: 16px; padding: 18px; }
.auth-card form, .form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field span { font-size: 14px; font-weight: 650; color: var(--muted); }
.field input {
  min-height: 50px; padding: 0 14px; border-radius: 13px; border: 1.5px solid var(--line);
  background: var(--surface-2); font-size: 16px; outline: none; transition: border-color .15s, background .15s;
}
.field input:focus { border-color: var(--brand); background: var(--surface); }
.form-error { color: var(--bad); font-size: 14px; font-weight: 600; }
.auth-note { color: var(--muted); font-size: 13.5px; text-align: center; }
.auth-points { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; font-size: 14.5px; }
.auth-points li { display: flex; gap: 10px; align-items: flex-start; }
.auth-points .ic { color: var(--ok); margin-top: 2px; }

/* ───────────── Trống ───────────── */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 48px 20px; }
.empty.small { padding: 20px; }
.empty-emoji { font-size: 52px; }
.empty h3 { font-size: 19px; }

/* ═════════════ LỚP PHỦ ═════════════ */
.overlay { position: fixed; inset: 0; z-index: 50; }
.screen {
  background: var(--bg); display: flex; flex-direction: column;
  opacity: 0; transform: translateY(26px); transition: opacity .22s, transform .26s cubic-bezier(.2, .8, .3, 1);
}
.screen.open { opacity: 1; transform: none; }
.screen.closing { opacity: 0; transform: translateY(26px); }

.backdrop { position: absolute; inset: 0; background: rgba(8, 10, 22, .45); opacity: 0; transition: opacity .22s; }
.open > .backdrop { opacity: 1; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; margin: 0 auto; max-width: 640px;
  max-height: 88dvh; display: flex; flex-direction: column;
  background: var(--surface); border-radius: 24px 24px 0 0; box-shadow: var(--shadow-up);
  transform: translateY(100%); transition: transform .3s cubic-bezier(.2, .8, .3, 1);
  padding-bottom: var(--safe-b);
}
.open > .sheet { transform: none; }
.sheet-tall .sheet { max-height: 94dvh; }
.sheet-grip { width: 100%; height: 22px; flex: none; position: relative; cursor: grab; }
.sheet-grip::after { content: ""; position: absolute; top: 9px; left: 50%; width: 40px; height: 5px; margin-left: -20px; border-radius: 3px; background: var(--line); }
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 0 8px 6px 20px; }
.sheet-head h3 { flex: 1; font-size: 18px; font-weight: 750; }
.sheet-body { overflow-y: auto; padding: 6px 20px 20px; overscroll-behavior: contain; }

.modal-wrap { display: grid; place-items: center; padding: 20px; }
.modal {
  position: relative; width: 100%; max-width: 380px; background: var(--surface); border-radius: 22px; padding: 22px;
  box-shadow: var(--shadow); transform: scale(.94); opacity: 0; transition: transform .2s, opacity .2s;
}
.open > .modal { transform: none; opacity: 1; }
.modal h3 { font-size: 19px; font-weight: 750; }
.modal p { color: var(--muted); margin-top: 8px; }
.modal-actions { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 10px; margin-top: 20px; }

/* Thông báo nổi */
.toasts { position: fixed; z-index: 90; left: 0; right: 0; top: calc(12px + var(--safe-t)); display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
.toast {
  max-width: 480px; padding: 12px 18px; border-radius: 14px; background: #1f2333; color: #fff;
  font-size: 14.5px; font-weight: 600; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); animation: toastIn .25s ease-out;
}
.toast.ok { background: var(--ok); }
.toast.bad { background: var(--bad); }
.toast.out { opacity: 0; transform: translateY(-8px); transition: .25s; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px); } }
.confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 95; }

/* ═════════════ BÀI LUYỆN / THẺ HỌC ═════════════ */
.quiz { height: 100%; display: flex; flex-direction: column; max-width: 640px; width: 100%; margin: 0 auto; }
.quiz-top { display: flex; align-items: center; gap: 10px; padding: calc(8px + var(--safe-t)) 12px 8px; flex: none; }
.quiz-bar { flex: 1; height: 14px; }
.quiz-count { min-width: 46px; display: flex; align-items: center; justify-content: flex-end; gap: 4px; font-weight: 750; font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.quiz-count.warn { color: var(--bad); }
.quiz-body { flex: 1; overflow-y: auto; padding: 8px 18px 20px; overscroll-behavior: contain; }
.quiz-foot { flex: none; padding: 12px 18px calc(14px + var(--safe-b)); display: flex; flex-direction: column; gap: 10px; }
.quiz-foot:empty { padding: 0 0 var(--safe-b); }

.fade-in { animation: fadeIn .25s ease-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } }

.q { display: flex; flex-direction: column; gap: 18px; min-height: 100%; }
.q-ask { font-size: 18px; font-weight: 750; }
.q-ask .tag { margin-left: 6px; background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.q-prompt {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  min-height: 150px; padding: 18px 44px; border-radius: 22px; background: var(--surface); box-shadow: var(--shadow);
}
.q-text { font-weight: 650; line-height: 1.25; overflow-wrap: anywhere; }
.q-prompt.xl .q-text { font-size: clamp(64px, 24vw, 104px); font-weight: 500; }
.q-prompt.lg .q-text { font-size: clamp(30px, 10vw, 44px); }
.q-prompt.md .q-text { font-size: clamp(20px, 6vw, 25px); line-height: 1.45; }
.q-sub { color: var(--muted); font-size: 16px; margin-top: 6px; }
.q-note { color: var(--acc-ink); font-size: 15px; margin-top: 10px; font-weight: 600; }
.q-prompt .say { position: absolute; top: 6px; right: 6px; color: var(--acc); }
.q-listen {
  width: 112px; height: 112px; border-radius: 50%; display: grid; place-items: center;
  background: var(--acc); color: #fff; box-shadow: 0 6px 0 color-mix(in srgb, var(--acc) 70%, #000);
  transition: transform .08s;
}
.q-listen:active { transform: translateY(4px); box-shadow: 0 2px 0 color-mix(in srgb, var(--acc) 70%, #000); }
.q-hint { color: var(--muted); font-size: 13.5px; margin-top: 12px; }

.opts { display: grid; gap: 10px; }
.opts.cols-2 { grid-template-columns: 1fr 1fr; }
.opt {
  min-height: 58px; padding: 12px 16px; border-radius: 16px; background: var(--surface);
  border: 2px solid var(--line); border-bottom-width: 4px;
  display: flex; flex-direction: column; justify-content: center; text-align: left;
  font-size: 17px; font-weight: 600; transition: transform .08s, border-color .15s, background .15s;
}
.opt:active { transform: translateY(2px); border-bottom-width: 2px; }
.opt.big { align-items: center; text-align: center; min-height: 76px; }
.opt.big .opt-text { font-size: 30px; font-weight: 600; }
.opt-sub { color: var(--muted); font-size: 13px; font-weight: 500; }
.opt.right { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 13%, var(--surface)); color: var(--ok); }
.opt.wrong { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, var(--surface)); color: var(--bad); animation: shake .35s; }
.opt.picked { border-color: var(--acc); background: var(--acc-soft); }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

.q-input {
  width: 100%; min-height: 60px; padding: 0 18px; border-radius: 16px; text-align: center;
  border: 2px solid var(--line); background: var(--surface); font-size: 22px; font-weight: 650; outline: none;
}
.q-input:focus { border-color: var(--acc); }
.q-input.right { border-color: var(--ok); color: var(--ok); }
.q-input.wrong { border-color: var(--bad); color: var(--bad); }
.q-input.picked { border-color: var(--acc); }

.order { display: flex; flex-direction: column; gap: 18px; }
.order-line {
  min-height: 70px; padding: 10px; border-radius: 16px; display: flex; flex-wrap: wrap; gap: 8px; align-content: flex-start;
  border: 2px dashed var(--line); background: color-mix(in srgb, var(--surface) 60%, transparent);
}
.order-line.right { border: 2px solid var(--ok); }
.order-line.wrong { border: 2px solid var(--bad); }
.order-line.picked { border: 2px solid var(--acc); }
.order-bank { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.chip-token {
  padding: 10px 14px; border-radius: 12px; background: var(--surface); border: 2px solid var(--line); border-bottom-width: 4px;
  font-size: 19px; font-weight: 600; transition: transform .08s;
}
.chip-token:active { transform: translateY(2px); }

.fb { animation: fbIn .22s ease-out; border-radius: 22px 22px 0 0; }
.fb.ok { background: color-mix(in srgb, var(--ok) 14%, var(--surface)); }
.fb.bad { background: color-mix(in srgb, var(--bad) 12%, var(--surface)); }
@keyframes fbIn { from { transform: translateY(30%); opacity: 0; } }
.fb-head { display: flex; align-items: center; gap: 8px; font-size: 19px; }
.fb.ok .fb-head { color: var(--ok); }
.fb.bad .fb-head { color: var(--bad); }
.fb-ans { display: flex; flex-direction: column; font-size: 17px; font-weight: 600; }
.fb-ans small { color: var(--muted); font-size: 13px; font-weight: 600; }
.fb-exp { color: var(--muted); font-size: 14.5px; }
.fb-quote { display: flex; flex-direction: column; gap: 2px; padding: 8px 12px; border-radius: 12px; background: var(--surface); font-size: 16px; }
.fb-quote small { color: var(--muted); font-size: 13.5px; }

/* Kết quả */
.result { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding-top: 12px; }
.result h2 { font-size: 26px; font-weight: 800; }
.result-emoji { font-size: 64px; }
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; width: 100%; margin: 8px 0; }
.stat-row .stat { background: var(--surface); box-shadow: var(--shadow); border-radius: 16px; padding: 12px 6px; display: flex; flex-direction: column; }
.stat-row .stat b { font-size: 20px; font-weight: 800; }
.stat-row .stat span { color: var(--muted); font-size: 12.5px; }
.result .sec-title { align-self: flex-start; }
.wrong-list { list-style: none; margin: 0; padding: 0; width: 100%; display: flex; flex-direction: column; gap: 8px; text-align: left; }
.wrong-list li { background: var(--surface); border-left: 4px solid var(--bad); border-radius: 12px; padding: 10px 14px; display: flex; flex-direction: column; }
.wrong-list small { color: var(--muted); }

/* Chi tiết thẻ */
.cd { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; }
.cd-main { font-size: clamp(80px, 30vw, 120px); line-height: 1.1; font-weight: 500; color: var(--text); }
.cd-main.word { font-size: clamp(36px, 12vw, 52px); font-weight: 650; }
.cd-kana { font-size: 20px; color: var(--acc-ink); }
.cd-romaji { color: var(--muted); font-size: 16px; letter-spacing: .3px; }
.cd-romaji.big { font-size: 28px; font-weight: 750; color: var(--acc); }
.cd-hv { font-size: 22px; font-weight: 800; color: var(--acc); letter-spacing: 1px; }
.cd-vi { font-size: 21px; font-weight: 650; margin-top: 4px; }
.cd-ex {
  position: relative; display: flex; align-items: center; gap: 10px; margin-top: 14px; padding: 12px 44px 12px 16px;
  border-radius: 16px; background: var(--surface-2); text-align: left; max-width: 100%;
}
.cd-ex span { font-size: 20px; font-weight: 600; }
.cd-ex em, .cd-word em { font-style: normal; color: var(--muted); font-size: 14.5px; }
.cd-ex i, .cd-word i { font-style: normal; color: var(--acc-ink); font-size: 14px; }
.cd-ex .ic, .cd-word .ic { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--acc); }
.cd-ex.col { flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; }
.cd-read { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; margin: 12px 0 0; }
.cd-read div { background: var(--surface-2); border-radius: 14px; padding: 10px; }
.cd-read dt { font-size: 12px; color: var(--muted); font-weight: 650; }
.cd-read dd { margin: 2px 0 0; font-size: 17px; font-weight: 600; }
.cd-words { display: flex; flex-direction: column; gap: 8px; width: 100%; margin-top: 10px; }
.cd-word {
  position: relative; display: grid; grid-template-columns: auto 1fr; align-items: baseline; column-gap: 10px; text-align: left;
  padding: 10px 44px 10px 14px; border-radius: 14px; background: var(--surface-2);
}
.cd-word span { font-size: 20px; font-weight: 650; grid-row: span 2; }
.say-row { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.card-sheet { display: flex; flex-direction: column; gap: 6px; }
.card-sheet .sec-title.center { justify-content: center; }

.intro { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-height: 100%; padding: 6px 0 12px; }
.pad-fold { width: 100%; margin-top: 12px; }
.pad-fold summary { cursor: pointer; text-align: center; color: var(--acc); font-weight: 650; padding: 8px; list-style: none; }
.pad-fold summary::-webkit-details-marker { display: none; }
.pad { position: relative; width: min(100%, 280px); aspect-ratio: 1; margin: 8px auto 0; border-radius: 20px; background: var(--surface); box-shadow: var(--shadow); overflow: hidden; --text: var(--text); }
.pad::before, .pad::after { content: ""; position: absolute; background: var(--line); }
.pad::before { left: 50%; top: 0; bottom: 0; width: 1px; }
.pad::after { top: 50%; left: 0; right: 0; height: 1px; }
.pad-guide { position: absolute; inset: 0; display: grid; place-items: center; font-size: 200px; line-height: 1; color: var(--text); opacity: .1; pointer-events: none; }
.pad canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; z-index: 1; }
.pad-clear { position: absolute; right: 6px; bottom: 6px; z-index: 2; color: var(--muted); }

/* Thẻ lật */
.flip { perspective: 1200px; min-height: 100%; display: flex; cursor: pointer; outline: none; }
.flip-inner { position: relative; flex: 1; min-height: 380px; transition: transform .5s cubic-bezier(.3, .7, .3, 1); transform-style: preserve-3d; }
.flip.flipped .flip-inner { transform: rotateY(180deg); }
.flip-face {
  position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  border-radius: 26px; background: var(--surface); box-shadow: var(--shadow);
  display: flex; flex-direction: column; justify-content: center; padding: 22px; overflow-y: auto;
}
.flip-face.back { transform: rotateY(180deg); justify-content: flex-start; }
.flip-face.front { border-bottom: 5px solid var(--acc-soft); }
.flip-hint { display: flex; align-items: center; justify-content: center; gap: 6px; color: var(--muted); font-size: 14px; margin-top: 22px; }

/* Trình phát nghe */
.player { display: flex; align-items: center; justify-content: center; gap: 26px; }
.play-btn {
  width: 76px; height: 76px; border-radius: 50%; display: grid; place-items: center;
  background: var(--acc); color: #fff; box-shadow: 0 5px 0 color-mix(in srgb, var(--acc) 70%, #000);
}
.play-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 color-mix(in srgb, var(--acc) 70%, #000); }

/* Premium */
.upgrade { display: flex; flex-direction: column; gap: 16px; }
.upgrade-hero { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.upgrade-hero h2 { font-size: 24px; font-weight: 800; }
.upgrade-hero p { color: var(--muted); }
.crown { width: 68px; height: 68px; border-radius: 22px; display: grid; place-items: center; background: linear-gradient(135deg, #f7c948, #e59a0f); color: #3b2500; }
.perks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.perks li { display: flex; gap: 12px; align-items: center; font-size: 15px; }
.perks .ic { color: var(--gold); }
.plans { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.plan {
  position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 2px;
  padding: 18px 4px 12px; border-radius: 16px; border: 2px solid var(--line); background: var(--surface);
}
.plan b { font-size: 15px; }
.plan span { font-size: 14px; color: var(--muted); font-weight: 650; }
.plan em {
  position: absolute; top: -10px; left: 50%; transform: translateX(-50%); white-space: nowrap;
  font-style: normal; font-size: 10.5px; font-weight: 750; padding: 2px 8px; border-radius: 999px; background: var(--gold); color: #fff;
}
.plan.on { border-color: var(--gold); background: color-mix(in srgb, var(--gold) 9%, var(--surface)); }
.plan.on span { color: var(--gold); }

/* ───────────── Màn hình rộng ───────────── */
@media (min-width: 720px) {
  .topics { grid-template-columns: repeat(3, 1fr); }
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
  .screen { padding: 0 12px; }
}
@media (max-width: 360px) {
  .actions { gap: 6px; }
  .action { font-size: 11.5px; padding: 12px 2px; }
  .plans { grid-template-columns: 1fr; }
  .plan em { position: static; transform: none; margin-bottom: 2px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
