/* Dictation Lab – giao diện theo bản thiết kế trên Claude Design */
:root {
  --ink: #13203B; --ink-2: #3D4A66; --muted: #4A5672; --mask: #636E87;
  --bg: #F3F4F3; --card: #FFFFFF; --line: #E6E9E8; --line-2: #D3D9D7; --track: #E8EBEA;
  --pri: #047857; --pri-d: #065F46; --pri-l: #D1FAE5;
  --yellow: #FFC83D; --yellow-l: #FFF3CC; --yellow-ink: #6B4E00; --yellow-b: #F2D27A; --yellow-bg: #FFF8E0; --yellow-ink2: #5C4300;
  --green: #12805C; --green-d: #0B5E43; --green-l: #E3F5EE; --green-ink: #0D6648;
  --red: #C2352F; --red-l: #FDECEB; --red-ink: #A12A25; --red-b: #F3C4C1;
  --fire: #B4401A; --fire-l: #FFF1EB; --fire-ink: #8F3315;
  --orange: #B45309; --orange-l: #FEF3E2;
  --navy: #0B3B30;
  --r: 24px; --r-sm: 16px;
  --shadow: 0 12px 32px rgba(15, 23, 42, .07);
  --shadow-lg: 0 20px 50px rgba(15, 23, 42, .08);
  --shadow-sm: 0 2px 10px rgba(15, 23, 42, .06);
  --hl: inset 0 1px 0 rgba(255, 255, 255, .9);
  --glow: 0 10px 24px rgba(4, 120, 87, .28);
  --grad-pri: linear-gradient(135deg, #0E9F74, #0F766E);
  --grad-text: linear-gradient(90deg, #0E7490, #059669);
  --hdr-h: 84px;
  /* Chữ: Lora cho tiêu đề & con số lớn · Be Vietnam Pro cho mọi chữ giao diện · JetBrains Mono cho ô chữ & phím */
  --font-display: 'Lora', 'Noto Serif Thai', 'Noto Serif SC', 'Songti SC', 'SimSun', Georgia, serif;
  --font-ui: 'Be Vietnam Pro', 'Noto Sans Thai', 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --serif: var(--font-display);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 500 16px/1.55 var(--font-ui); color: var(--ink); background: var(--bg); }
a { color: var(--pri); text-decoration: none; }
a:hover { color: var(--pri-d); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .5; cursor: default; }
:focus-visible { outline: 3px solid var(--pri); outline-offset: 2px; }
h1, h2, h3 { margin: 0; font-family: var(--serif); font-weight: 700; letter-spacing: -.3px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 24px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.hidden { display: none !important; }
svg.i { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

/* ───── Nút ───── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: 16px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font-weight: 700; font-size: 15px; white-space: nowrap; text-decoration: none; box-shadow: var(--shadow-sm); transition: transform .15s, box-shadow .15s, background .15s; }
a.btn:hover { color: var(--ink); }
.btn:hover:not(:disabled) { border-color: var(--line-2); transform: translateY(-1px); }
.btn.lg { min-height: 56px; padding: 0 28px; border-radius: 18px; font-size: 16px; }
.btn.primary { background: var(--pri); border-color: var(--pri); color: #fff; box-shadow: var(--glow); }
.btn.primary:hover:not(:disabled) { background: var(--pri-d); border-color: var(--pri-d); }
.btn.green { background: var(--green); border-color: var(--green); color: #fff; box-shadow: 0 10px 24px rgba(18, 128, 92, .25); }
.btn.dark { background: var(--ink); border-color: var(--ink); color: #fff; box-shadow: 0 10px 24px rgba(19, 32, 59, .22); }
.btn.yellow { background: var(--yellow-bg); border-color: var(--yellow-b); color: var(--yellow-ink2); box-shadow: none; }
.btn.ghost { border-color: transparent; background: transparent; box-shadow: none; }
.btn.danger { color: var(--red-ink); }
a.btn.primary:hover, a.btn.green:hover, a.btn.dark:hover { color: #fff; }
.btn.icon { padding: 0; width: 44px; }
.btn.round { border-radius: 50%; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 13px; font-weight: 700; background: var(--track); color: var(--ink-2); white-space: nowrap; }
.chip.blue { background: var(--pri-l); color: var(--pri-d); }
.chip.green { background: var(--green-l); color: var(--green-ink); }
.chip.yellow { background: var(--yellow-l); color: var(--yellow-ink); }
.chip.red { background: var(--red-l); color: var(--red-ink); }
.chip.fire { background: var(--fire-l); color: var(--fire-ink); }
.chip.pro { background: var(--ink); color: var(--yellow); }
.lv-A1, .lv-A2 { background: var(--green-l); color: var(--green-ink); }
.lv-B1 { background: var(--pri-l); color: var(--pri-d); }
.lv-B2 { background: var(--yellow-l); color: var(--yellow-ink); }
.lv-C1, .lv-C2 { background: #FFE8E0; color: var(--fire-ink); }

/* ───── Form ───── */
.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 600; color: var(--ink-2); }
.input, .select, .textarea { width: 100%; min-height: 50px; padding: 0 16px; border-radius: 16px; border: 1px solid var(--line-2); background: var(--card); font-size: 16px; font-weight: 700; color: var(--ink); box-shadow: inset 0 2px 4px rgba(15, 23, 42, .04); }
.textarea { padding: 12px 14px; resize: vertical; line-height: 1.5; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--pri); box-shadow: 0 0 0 4px var(--pri-l); }
.check { display: inline-flex; align-items: center; gap: 10px; font-weight: 600; font-size: 15px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--pri); }
.search { display: flex; align-items: center; gap: 10px; min-height: 50px; padding: 0 16px; border-radius: 16px; border: 1px solid var(--line-2); background: var(--card); color: var(--muted); box-shadow: inset 0 2px 4px rgba(15, 23, 42, .04); }
.search input { flex: 1; border: 0; outline: 0; background: transparent; font-size: 16px; font-weight: 700; color: var(--ink); min-width: 0; }
.search:focus-within { border-color: var(--pri); }
.seg { display: inline-grid; grid-auto-flow: column; gap: 4px; padding: 4px; border-radius: 16px; background: var(--track); }
.seg button { min-height: 40px; padding: 0 14px; border: 0; border-radius: 12px; background: transparent; font-weight: 600; font-size: 14px; color: var(--ink-2); }
.seg button[aria-selected="true"], .seg button[aria-pressed="true"] { background: var(--card); color: var(--ink); font-weight: 700; box-shadow: var(--shadow-sm); }

/* ───── Khung chung ───── */
.card { background: var(--card); border: 1px solid rgba(255, 255, 255, .9); border-radius: var(--r); padding: 22px; box-shadow: var(--shadow), var(--hl); }
.progress { height: 8px; border-radius: 8px; background: var(--track); overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: 8px; background: var(--grad-pri); transition: width .3s; }
.progress.green > i { background: var(--green); }
.page { padding: 40px 24px 80px; display: flex; flex-direction: column; gap: 24px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 38px; letter-spacing: -.6px; }
.page-head p { margin: 6px 0 0; font-size: 17px; color: var(--muted); }
.empty { text-align: center; padding: 48px 20px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 12px; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 4px solid var(--track); border-top-color: var(--pri); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { display: flex; justify-content: center; padding: 60px; }
.msg { padding: 13px 16px; border-radius: 14px; font-size: 15px; font-weight: 600; display: flex; gap: 10px; align-items: flex-start; }
.msg:empty { display: none; }
.msg.ok { background: var(--green-l); color: var(--green-ink); }
.msg.bad { background: var(--red-l); color: var(--red-ink); }
.msg.info { background: var(--yellow-l); color: var(--yellow-ink); }
.msg.blue { background: var(--pri-l); color: var(--pri-d); }
kbd { font: 600 12px var(--font-mono); padding: 2px 7px; border: 1px solid var(--line-2); border-bottom-width: 3px; border-radius: 6px; background: var(--bg); color: var(--ink); }

/* ───── Chọn ngôn ngữ ───── */
.lang-pick { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 12px; border-radius: 16px; border: 1px solid var(--line); font-size: 14px; font-weight: 600; color: var(--ink); background: var(--card); }
.lang-pick select { border: 0; background: transparent; font-weight: 600; color: var(--ink); cursor: pointer; max-width: 120px; }
.lang-pick select:focus { outline: none; }
.lang-pick:focus-within { border-color: var(--pri); }

/* ───── Header: thanh viên thuốc nổi ───── */
.hdr { position: sticky; top: 0; z-index: 30; padding: 16px 16px 0; pointer-events: none; }
.hdr .wrap { pointer-events: auto; position: relative; max-width: 1140px; display: flex; align-items: center; gap: 16px; min-height: 64px; padding: 8px 12px 8px 16px; background: var(--card); border-radius: 24px; box-shadow: var(--shadow-lg), var(--hl); }
.logo { display: flex; align-items: center; gap: 10px; color: var(--ink); font: 700 21px/1 var(--serif); letter-spacing: -.2px; white-space: nowrap; }
.logo:hover { color: var(--ink); }
.logo-mark { width: 40px; height: 40px; border-radius: 13px; background: linear-gradient(135deg, #10B981, #0E7490); color: #fff; display: flex; align-items: center; justify-content: center; box-shadow: 0 6px 14px rgba(4, 120, 87, .28); flex: none; }
.nav { flex: 1; min-width: 0; display: flex; justify-content: center; gap: 2px; flex-wrap: nowrap; }
.nav a { white-space: nowrap; padding: 10px 14px; border-radius: 14px; color: var(--muted); font-weight: 700; font-size: 15px; }
.nav a:hover { color: var(--ink); }
.nav a[aria-current="page"] { background: var(--pri-l); color: var(--pri-d); font-weight: 600; }
.nav .nav-lang, .nav .nav-start { display: none; }
.nav-toggle { display: none; width: 44px; height: 44px; padding: 0; border-radius: 14px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); align-items: center; justify-content: center; box-shadow: var(--shadow-sm); }
.hdr-right { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--grad-pri); color: #fff; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; border: 0; font-size: 17px; box-shadow: var(--glow); }
.menu { position: relative; }
.menu-list { position: absolute; right: 0; top: calc(100% + 12px); background: var(--card); border: 0; border-radius: 20px; box-shadow: 0 20px 50px rgba(15, 23, 42, .16); padding: 8px; min-width: 210px; display: flex; flex-direction: column; z-index: 40; }
.menu-list a, .menu-list button { text-align: left; min-height: 44px; padding: 11px 12px; border-radius: 12px; border: 0; background: none; color: var(--ink); font-weight: 600; font-size: 15px; }
.menu-list a:hover, .menu-list button:hover { background: var(--bg); }
/* Thanh điều hướng thu vào nút ☰ khi màn hình không đủ rộng */
@media (max-width: 1199px) { .hdr-right .chip.hide-sm { display: none; } .hdr-right .lang-pick select { max-width: 92px; } }
@media (max-width: 1100px) {
  .hdr { padding: 12px 12px 0; }
  .hdr .wrap { gap: 8px; padding: 8px 8px 8px 12px; }
  .logo { font-size: 19px; }
  .nav-toggle { display: inline-flex; }
  .hdr-right .lang-pick, .hdr-right .chip.hide-sm, .hdr-right .btn.hide-sm, .hdr-right .btn.primary { display: none; }
  .nav { display: none; position: absolute; left: 0; right: 0; top: calc(100% + 10px); flex-direction: column; justify-content: flex-start; flex-wrap: nowrap; gap: 2px; padding: 10px; background: var(--card); border-radius: 24px; box-shadow: 0 20px 50px rgba(15, 23, 42, .16); }
  .nav.open { display: flex; }
  .nav a { min-height: 44px; display: flex; align-items: center; font-size: 16px; }
  .nav .nav-lang { display: flex; padding-top: 6px; }
  .nav .nav-lang .lang-pick { display: inline-flex; }
  .nav .nav-start { display: inline-flex; margin: 6px 4px 2px; }
  .nav .nav-pro { color: var(--yellow-ink2); }
}
@media (max-width: 400px) { .logo-word { display: none; } }
@media (forced-colors: active) { .hero h1 .grad { -webkit-text-fill-color: currentColor; background: none; } }

/* ───── Trang chủ ───── */
.hero { display: flex; gap: 56px; align-items: center; flex-wrap: wrap; padding: 72px 24px 64px; }
.hero-text { flex: 1 1 440px; min-width: 0; display: flex; flex-direction: column; gap: 24px; align-items: flex-start; }
.hero h1 { font-size: clamp(40px, 6vw, 64px); line-height: 1.08; letter-spacing: -1px; }
.hero h1 .grad { display: inline-block; padding-bottom: .08em; color: #0E7490; background: var(--grad-text); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.hero p { margin: 0; font-size: 19px; line-height: 1.65; color: var(--muted); max-width: 520px; }
.pill { display: inline-flex; align-items: center; gap: 8px; padding: 8px 16px; border-radius: 999px; background: var(--pri-l); color: var(--pri-d); font-size: 14px; font-weight: 600; box-shadow: var(--hl); }
.pill svg.i { width: 16px; height: 16px; }
.hero-btns { display: flex; gap: 14px; flex-wrap: wrap; }
.stats { display: flex; gap: 36px; flex-wrap: wrap; padding-top: 4px; }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat b { font: 700 28px/1.1 var(--serif); color: var(--ink); }
.stat span { font-size: 14px; color: var(--muted); font-weight: 700; }
.hero-art { flex: 1 1 400px; min-width: 0; display: flex; justify-content: center; padding: 28px 20px; }
.phone { position: relative; width: min(100%, 380px); }
.phone-card { background: var(--card); border-radius: 36px; box-shadow: 0 30px 70px rgba(15, 23, 42, .12), var(--hl); padding: 26px 22px 22px; display: flex; flex-direction: column; gap: 18px; }
.phone-top { display: flex; align-items: center; gap: 16px; }
.ring { position: relative; width: 84px; height: 84px; flex: none; }
.ring svg { width: 84px; height: 84px; transform: rotate(-90deg); }
.ring-n { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font: 700 17px var(--serif); color: var(--pri-d); }
.phone .answer { font-size: 19px; min-height: 0; padding: 14px; background: var(--bg); }
.phone-play { width: 100%; min-height: 56px; border: 0; border-radius: 20px; background: var(--grad-pri); color: #fff; box-shadow: var(--glow); font-weight: 700; font-size: 17px; display: flex; align-items: center; justify-content: center; gap: 10px; }
.float { position: absolute; display: flex; align-items: center; gap: 10px; padding: 10px 16px 10px 10px; border-radius: 999px; background: var(--card); box-shadow: 0 14px 34px rgba(15, 23, 42, .14), var(--hl); font-weight: 600; font-size: 14px; color: var(--ink); white-space: nowrap; }
.float .fi { width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--pri); color: #fff; }
.float .fi svg.i { width: 16px; height: 16px; stroke-width: 3; }
.float.f1 { top: -18px; right: -14px; }
.float.f2 { bottom: 44px; left: -22px; }
.float.f2 .fi { background: var(--yellow-l); color: var(--yellow-ink); }
@media (max-width: 760px) {
  .hero { padding-top: 28px; gap: 24px; }
  .hero h1 { font-size: 40px; }
  .hero p { font-size: 17px; }
  .hero-art { flex-basis: 100%; padding: 22px 14px; }
  .hero-btns .btn { flex: 1 1 100%; }
  .stats { gap: 16px; flex-wrap: nowrap; justify-content: space-between; width: 100%; }
  .stat b { font-size: 24px; }
  .stat span { font-size: 13px; }
  .float.f1 { right: -4px; } .float.f2 { left: -4px; }
}
.band { background: var(--card); box-shadow: 0 0 40px rgba(15, 23, 42, .04); }
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 20px; }
.step { padding: 28px; border-radius: 24px; background: var(--bg); display: flex; flex-direction: column; gap: 12px; }
.step-n { width: 48px; height: 48px; border-radius: 14px; font-size: 22px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.feature { padding: 24px; border-radius: 24px; background: var(--card); box-shadow: var(--shadow), var(--hl); display: flex; gap: 16px; }
.feature .ic { flex: none; width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; }
.cta { border-radius: 32px; background: linear-gradient(135deg, #D1FAE5, #CCFBF1 60%, #ECFDF5); box-shadow: var(--shadow-lg), var(--hl); padding: 44px; display: flex; gap: 24px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.footer { background: transparent; border-top: 1px solid var(--line); padding: 28px 0; color: var(--muted); font-size: 15px; }

/* ───── Thẻ bài học ───── */
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 18px; }
.lcard { color: var(--ink); background: var(--card); border: 0; border-radius: 24px; overflow: hidden; box-shadow: var(--shadow), var(--hl); display: flex; flex-direction: column; transition: transform .15s, box-shadow .15s; }
.lcard:hover { color: var(--ink); transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.thumb { position: relative; aspect-ratio: 16 / 9; background: var(--navy); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.thumb .dur { position: absolute; right: 10px; bottom: 10px; padding: 3px 8px; border-radius: 6px; background: rgba(0, 0, 0, .65); color: #fff; font-size: 12px; font-weight: 600; }
.thumb .done { position: absolute; left: 10px; top: 10px; }
.lcard .body { padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.lcard .title { font-size: 17px; font-weight: 700; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lcard .meta { font-size: 14px; color: var(--muted); }
.lcard .progress { border-radius: 0; height: 6px; }

/* ───── Luyện nghe ───── */
.learn-hdr { background: var(--card); box-shadow: var(--shadow-sm); }
.learn-hdr .wrap { max-width: 1320px; display: flex; align-items: center; gap: 16px; padding-top: 12px; padding-bottom: 12px; flex-wrap: wrap; }
.learn { max-width: 1480px; margin: 0 auto; padding: 24px; display: grid; grid-template-columns: 300px minmax(0, 1fr) 250px; gap: 20px; align-items: start; }
.cap-col { position: sticky; top: var(--hdr-h); }
.cap-col .seglist { max-height: calc(100vh - 220px); }
.center { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.side-col { display: flex; flex-direction: column; gap: 16px; position: sticky; top: var(--hdr-h); }
.side-col .keys { flex-direction: column; gap: 10px; border-top: 0; font-size: 14px; }
.player { position: relative; aspect-ratio: 16 / 9; border-radius: 24px; box-shadow: var(--shadow-lg); background: var(--navy); overflow: hidden; }
.player iframe, .player > div:first-child { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.cover { position: absolute; inset: 0; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 10px; color: #D1FAE5; background: var(--navy); font-weight: 600; }
.hide-video .cover { display: flex; }
.controls { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.play-btn { width: 52px; height: 52px; border-radius: 50%; border: 0; background: var(--pri); color: #fff; display: flex; align-items: center; justify-content: center; box-shadow: var(--glow); }
.seglist { list-style: none; margin: 0; padding: 0; max-height: 420px; overflow: auto; display: flex; flex-direction: column; gap: 2px; }
.seglist li button { width: 100%; display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; border: 0; background: transparent; text-align: left; font-weight: 700; font-size: 15px; color: var(--ink); }
.seglist li button:hover { background: var(--bg); }
.seglist li.cur button { background: var(--pri-l); }
.seglist .n { width: 28px; font-size: 14px; font-weight: 600; color: var(--muted); flex: none; }
.seglist .t { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seglist .t.m { display: flex; flex-wrap: nowrap; overflow: hidden; gap: 5px 6px; align-items: flex-end; min-height: 1.3em; }
.uls { display: contents; }
.uls i { display: inline-block; height: 9px; border-bottom: 3px solid var(--mask); border-radius: 2px; max-width: 100%; }
.seglist .dot { width: 24px; height: 24px; border-radius: 50%; background: var(--line); flex: none; display: flex; align-items: center; justify-content: center; color: #fff; }
.seglist .done .dot { background: var(--green); }
.seglist .revealed .dot { background: var(--yellow); color: var(--ink); }
.seglist .cur .dot { box-shadow: 0 0 0 3px var(--pri); }
.dict { min-width: 0; background: var(--card); border-radius: 28px; padding: 24px; display: flex; flex-direction: column; gap: 16px; box-shadow: var(--shadow-lg), var(--hl); }
.answer { padding: 18px 20px; border-radius: 18px; background: var(--bg); font-size: 25px; font-weight: 600; line-height: 1.6; display: flex; flex-wrap: wrap; gap: 4px 0; min-height: 110px; align-content: flex-start; }
.answer .w { margin-right: 11px; border-radius: 6px; }
.answer .w.glue { margin-right: 0; }
.w.ok { color: var(--green); }
.w.bad { color: var(--red); text-decoration: line-through; }
.w.word { cursor: pointer; padding: 0 2px; margin-left: -2px; }
.w.word:hover { background: var(--yellow-l); }
.dict textarea { font-size: 20px; min-height: 96px; }
.diff { display: flex; gap: 6px 8px; flex-wrap: wrap; align-items: center; font-size: 16px; font-weight: 600; }
.actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.actions .btn { min-height: 52px; border-radius: 14px; }
.keys { display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 13px; color: var(--muted); padding-top: 10px; border-top: 1px solid var(--line); }
@media (min-width: 761px) and (max-width: 1150px) {
  .learn { grid-template-columns: 260px minmax(0, 1fr); }
  .side-col { grid-column: 1 / -1; flex-direction: row; position: static; }
  .side-col > .card { flex: 1; }
}
@media (max-width: 760px) {
  .learn { padding: 14px; gap: 14px; grid-template-columns: minmax(0, 1fr); }
  .center { order: 1; } .cap-col { order: 2; position: static; } .side-col { order: 3; position: static; }
  .cap-col .seglist { max-height: 320px; }
  .dict { padding: 16px; border-radius: 20px; }
  .answer { font-size: 20px; min-height: 80px; padding: 14px; }
  .dict textarea { font-size: 18px; }
  .actions { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .actions .btn { font-size: 13px; padding: 0 6px; white-space: normal; line-height: 1.15; gap: 4px; }
  .keys { display: none; }
}

/* ───── Bảng tra từ ───── */
.pop { position: fixed; z-index: 60; width: min(400px, calc(100vw - 24px)); background: var(--card); border-radius: 24px; box-shadow: 0 20px 50px rgba(15, 23, 42, .2); border: 0; padding: 18px; display: flex; flex-direction: column; gap: 12px; max-height: min(560px, calc(100vh - 24px)); overflow: auto; }
.pop .word { font-size: 28px; font-weight: 700; letter-spacing: -.3px; }
.pop .ipa { font: 500 16px var(--font-ui); color: var(--muted); }
.pop .vi { padding: 12px 14px; border-radius: 14px; background: var(--green-l); }
.pop .vi b { font-size: 19px; }
.pop .def { display: flex; gap: 10px; font-size: 15px; color: var(--ink-2); line-height: 1.5; }
.pos { flex: none; height: 24px; padding: 0 8px; border-radius: 6px; background: var(--pri-l); color: var(--pri-d); font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; }
@media (max-width: 600px) { .pop { left: 12px !important; right: 12px; top: auto !important; bottom: 12px; width: auto; } }

/* ───── Modal ───── */
.overlay { position: fixed; inset: 0; z-index: 70; background: rgba(19, 32, 59, .45); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { width: min(460px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--card); border-radius: 32px; box-shadow: var(--shadow-lg); padding: 32px; display: flex; flex-direction: column; gap: 16px; position: relative; }
.modal .x { position: absolute; right: 14px; top: 14px; }
.or { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; font-weight: 600; }
.or::before, .or::after { content: ''; flex: 1; height: 1px; background: var(--line); }

/* ───── Bảng xếp hạng ───── */
.podium { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; align-items: end; }
.pod { background: var(--card); box-shadow: var(--shadow), var(--hl); border-radius: 24px; padding: 20px 12px; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; min-width: 0; }
.pod.first { background: var(--yellow-l); border: 2px solid var(--yellow); padding-top: 28px; }
.pod .av { width: 64px; height: 64px; border-radius: 50%; font-size: 24px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.pod b { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-list { list-style: none; margin: 0; padding: 0; }
.rank-list li { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-radius: 14px; }
.rank-list li.me { background: var(--pri-l); }
.rank-list .rk { width: 32px; text-align: center; font-weight: 700; color: var(--muted); }
.rank-list .av { width: 42px; height: 42px; border-radius: 50%; background: var(--track); font-weight: 700; display: flex; align-items: center; justify-content: center; flex: none; }
.rank-list .me .av { background: var(--pri); color: #fff; }

/* ───── Thống kê ───── */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.kpi { border-radius: 22px; padding: 18px 20px; display: flex; flex-direction: column; gap: 2px; }
.kpi span { font-size: 14px; font-weight: 600; }
.kpi b { font-size: 32px; font-weight: 700; color: var(--ink); }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 200px; }
.bars > div { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px; height: 100%; font-size: 11px; font-weight: 600; color: var(--muted); min-width: 0; }
.bars i { display: block; width: 100%; border-radius: 8px 8px 3px 3px; background: #A7F3D0; min-height: 4px; }
.bars .today i { background: var(--pri); }

/* ───── Từ vựng ───── */
.vocab-layout { display: flex; gap: 22px; flex-wrap: wrap; align-items: flex-start; }
.vocab-side { flex: 1 1 240px; max-width: 290px; min-width: 0; padding: 14px; display: flex; flex-direction: column; gap: 4px; }
.vocab-side .grp { min-height: 44px; padding: 0 12px; border-radius: 12px; border: 0; background: transparent; font-weight: 600; font-size: 15px; color: var(--ink); display: flex; align-items: center; gap: 10px; text-align: left; }
.vocab-side .grp[aria-pressed="true"] { background: var(--pri-l); color: var(--pri-d); }
.vocab-side .grp .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.vocab-main { flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.vitem { background: var(--card); box-shadow: var(--shadow-sm), var(--hl); border-radius: 20px; padding: 16px 18px; display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.vitem .l { flex: 1 1 320px; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.vitem .r { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.vitem .w { font-size: 21px; font-weight: 700; }
.vitem .note { font-size: 17px; font-weight: 600; color: var(--green-ink); }
.vitem .sent { font-size: 14px; color: var(--ink-2); line-height: 1.5; }
mark { background: var(--yellow-l); color: var(--ink); border-radius: 4px; padding: 0 3px; font-weight: 700; }
.grp-title { margin: 10px 0 0; font-size: 14px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
.lock { display: inline-flex; align-items: center; gap: 6px; }

/* ───── Flashcard & quiz ───── */
.focus-hdr { background: var(--card); box-shadow: var(--shadow-sm); }
.focus-hdr .wrap { max-width: 860px; display: flex; align-items: center; gap: 16px; min-height: 68px; }
.focus { max-width: 760px; margin: 0 auto; padding: 36px 24px 64px; display: flex; flex-direction: column; gap: 22px; }
.flash { background: var(--card); border-radius: 28px; box-shadow: var(--shadow-lg), var(--hl); padding: 36px 28px; display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; min-height: 360px; justify-content: center; cursor: pointer; }
.flash .big { font-size: clamp(34px, 7vw, 52px); font-weight: 700; letter-spacing: -.8px; line-height: 1.15; }
.flash hr { width: 100%; border: 0; height: 1px; background: var(--line); margin: 6px 0; }
.grades { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.grades button { min-height: 72px; border-radius: 16px; font-weight: 700; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border: 2px solid transparent; }
.grades b { font-size: 17px; }
.grades span { font-size: 12px; font-weight: 600; }
.g0 { background: var(--red-l); border-color: var(--red-b) !important; color: var(--red-ink); }
.g1 { background: var(--yellow-bg); border-color: var(--yellow-b) !important; color: var(--yellow-ink2); }
.g2 { background: var(--green); color: #fff; box-shadow: 0 8px 20px rgba(18, 128, 92, .25); }
.g3 { background: var(--pri-l); border-color: #A7F3D0 !important; color: var(--pri-d); }
.options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.options button { min-height: 64px; padding: 10px 18px; border-radius: 18px; border: 1px solid var(--line); box-shadow: var(--shadow-sm); background: var(--card); font-weight: 700; font-size: 18px; text-align: left; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.options button.right { border-color: var(--green); background: var(--green-l); color: var(--green-ink); }
.options button.wrong { border-color: var(--red); background: var(--red-l); color: var(--red-ink); }
@media (max-width: 560px) { .options { grid-template-columns: 1fr; } .grades { gap: 6px; } .grades b { font-size: 15px; } }

/* ───── Nâng cấp ───── */
.plans { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.plan { padding: 20px; border-radius: 22px; border: 2px solid transparent; box-shadow: var(--shadow), var(--hl); background: var(--card); text-align: left; display: flex; flex-direction: column; gap: 4px; position: relative; }
.plan[aria-checked="true"] { border: 2px solid var(--pri); background: var(--pri-l); }
.plan b { font-size: 26px; font-weight: 700; }
.plan .tag { position: absolute; top: -12px; right: 12px; }
.qr { width: 200px; height: 200px; border-radius: 16px; border: 1px solid var(--line); background: #fff; object-fit: contain; flex: none; }
table.t { width: 100%; border-collapse: collapse; font-size: 15px; }
table.t th, table.t td { padding: 12px 8px; text-align: left; border-top: 1px solid var(--line); }
table.t th { font-size: 13px; color: var(--muted); border-top: 0; }

/* ───── Toast ───── */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 14px; font-weight: 600; opacity: 0; pointer-events: none; transition: .25s; z-index: 90; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* nút từ trong câu đáp án */
.answer button.w { border: 0; background: none; font: inherit; color: inherit; padding: 0 2px; margin-left: -2px; cursor: pointer; line-height: inherit; }
.answer button.w:hover, .answer button.w:focus-visible { background: var(--yellow-l); }
.vitem button.w { color: var(--ink); }
@media (max-width: 600px) {
  .wrap, .page, .hero { padding-left: 16px; padding-right: 16px; }
  .page-head h1 { font-size: 30px; }
  .cta { padding: 28px; }
  .modal { padding: 24px; }
}
/* Trang học 3 cột: video vừa màn hình để ô gõ luôn nằm trong tầm nhìn */
.center .player { width: min(100%, calc(46vh * 16 / 9)); margin: 0 auto; }
.center .controls { padding: 10px 14px; }
.cap-col .seglist .t:not(.m) { white-space: normal; overflow: visible; line-height: 1.45; word-break: break-word; }
.cap-col .seglist li button { align-items: flex-start; }
@media (max-width: 760px) { .center .player { width: 100%; } }

/* Ô gõ trực tiếp trong câu */
.typebox { position: relative; border: 1px solid var(--line-2); border-radius: 18px; background: var(--bg); cursor: text; }
.typebox:focus-within { border-color: var(--pri); box-shadow: 0 0 0 4px var(--pri-l); background: #fff; }
.typebox .mirror, .typebox textarea { font-family: inherit; font-size: 25px; font-weight: 600; line-height: 1.6; letter-spacing: 0; padding: 16px 20px; margin: 0; border: 0; white-space: pre-wrap; overflow-wrap: break-word; word-break: normal; font-variant-ligatures: none; }
.typebox .mirror { min-height: 110px; color: var(--ink); }
.typebox textarea { position: absolute; inset: 0; width: 100%; height: 100%; background: transparent; color: transparent; caret-color: var(--ink); resize: none; outline: none; overflow: hidden; box-shadow: none; }
.typebox textarea::selection { background: rgba(4, 120, 87, .25); color: transparent; }
.mirror .ok { color: var(--green); }
.mirror .bad { color: var(--red); text-decoration: underline wavy rgba(194, 53, 47, .5); text-underline-offset: 5px; }
.mirror .near { color: var(--orange); text-decoration: underline dotted var(--orange) 3px; text-underline-offset: 6px; }
.mirror .gap { position: relative; }
.mirror .gap::before { content: '▢' attr(data-x); position: absolute; left: -.55em; top: 50%; transform: translateY(-50%); font-size: .55em; color: var(--orange); font-weight: 700; white-space: nowrap; line-height: 1; }
.mirror .gap.end::before { left: .2em; }
.typebox.done { cursor: default; }
.typebox.done textarea { pointer-events: none; caret-color: transparent; }
.typebox.done .mirror { display: flex; flex-wrap: wrap; gap: 4px 0; align-content: flex-start; white-space: normal; background: none; border-radius: 0; }
@media (max-width: 760px) { .typebox .mirror, .typebox textarea { font-size: 20px; padding: 12px 14px; } .typebox .mirror { min-height: 80px; } }
.typebox.done .mirror button.w { color: var(--green); }

/* Trang sửa phụ đề */
.btn.sm { min-height: 36px; padding: 0 10px; font-size: 13px; border-radius: 10px; }
.btn.icon.sm { width: 36px; padding: 0; }
.input.sm { min-height: 36px; width: 92px; padding: 0 8px; font-size: 14px; }
.btn.pulse { box-shadow: 0 0 0 4px var(--yellow-l), var(--glow); }
.edit-grid { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 20px; align-items: start; }
.edit-side { position: sticky; top: var(--hdr-h); display: flex; flex-direction: column; gap: 14px; }
.erows { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.erow { padding: 12px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.erow-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.erow-top label { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; color: var(--muted); }
.erow .n { width: 34px; font-weight: 700; color: var(--muted); }
.erow textarea { font-size: 17px; min-height: 0; }
@media (max-width: 900px) { .edit-grid { grid-template-columns: minmax(0, 1fr); } .edit-side { position: static; } }

/* ───── Luyện tập: nút Chậm, bố cục nút, thẻ tổng kết, cảm ứng ───── */
.actions { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.actions #b-prev, .actions #b-next { grid-column: span 2; }
.actions #b-check { grid-column: 1 / -1; order: 10; }
.actions #b-prev { order: 8; } .actions #b-next { order: 9; }
.sum-card { margin-top: 14px; padding: 18px; border-radius: 16px; background: var(--pri-l); color: var(--pri-d); }
.sum-card h2 { font-size: 20px; margin: 0 0 10px; }
.sum-card dl { margin: 0; display: grid; gap: 6px; }
.sum-row { display: flex; justify-content: space-between; gap: 12px; font-weight: 600; font-size: 16px; border-bottom: 1px dashed rgba(6, 95, 70, .25); padding-bottom: 4px; }
.sum-row dt, .sum-row dd { margin: 0; }
.sum-btns { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.sum-btns .btn { min-height: 48px; }
@media (hover: none) and (pointer: coarse) { .side-col .keys { display: none; } }
@media (max-width: 760px) {
  .actions { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .actions #b-prev, .actions #b-next { grid-column: auto; }
  .learn .btn, .learn .play-btn, .learn .seg button, .learn .select { min-height: 44px; }
  .learn .play-btn { min-width: 44px; }
  .learn .seg button { min-width: 44px; }
  .learn .check { min-height: 44px; }
  .learn .check input { width: 24px; height: 24px; }
  .seglist li button { min-height: 44px; }
  .learn .seg { max-width: 100%; overflow-x: auto; }
}

/* Hàng "ô từ": mỗi từ một ô bo góc, gạch chân theo số ký tự (chỉ dùng shape) */
.slots { display: flex; flex-wrap: wrap; gap: 8px 6px; }
.slot { display: inline-flex; align-items: flex-end; box-sizing: border-box; max-width: 100%; min-width: 1.6em; min-height: 34px; padding: 3px 8px 5px; border: 2px solid var(--line-2); border-radius: 10px; background: #fff; color: var(--ink); font: 600 18px/1.25 var(--font-mono); overflow-wrap: anywhere; }
.slot.glue { margin-right: -3px; }
.slot .u { display: inline-block; width: .46em; margin: 0 .08em; height: 0; border-bottom: 3px solid var(--mask); }
.slot .tx { font-variant-ligatures: none; }
.slot .plus { margin-left: 4px; color: var(--red); font-size: .8em; align-self: center; }
.slot.cur { border-color: var(--orange); box-shadow: 0 0 0 3px var(--orange-l); }
.slot.ok { border-color: var(--green); color: var(--green); }
.slot.bad { border-color: var(--red); color: var(--red); }
.slot.near { border-style: dotted; border-color: var(--orange); color: var(--orange); }
.slot.gap { border-style: dashed; border-color: var(--orange); }
.slot.over { border-color: var(--red); box-shadow: 0 0 0 3px rgba(194, 53, 47, .15); }
.slot.cur.ok, .slot.cur.bad, .slot.cur.near { border-color: var(--orange); }
.w.slot { display: inline-flex; vertical-align: middle; min-height: 28px; margin: 0 4px; padding: 2px 6px 4px; font-size: 15px; }
@media (max-width: 760px) { .slot { font-size: 16px; min-height: 32px; padding: 3px 6px 4px; } }

/* Tạo phụ đề bằng AI */
.ai-cta { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; padding: 14px 16px; border-radius: 14px; border: 2px dashed var(--line-2); background: var(--bg); }
.ai-cta b { display: inline-flex; gap: 6px; align-items: center; }
.ai-cta.pulse { border-color: var(--pri); background: var(--pri-l); }
.ai-job { display: flex; flex-direction: column; gap: 14px; }
.ai-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.ai-steps li { display: flex; align-items: center; gap: 12px; padding: 6px 0; font-weight: 700; color: var(--muted); }
.ai-steps .dot { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--line-2); display: inline-flex; align-items: center; justify-content: center; flex: none; color: #fff; }
.ai-steps li.ok { color: var(--ink-2); }
.ai-steps li.ok .dot { background: var(--green); border-color: var(--green); }
.ai-steps li.now { color: var(--ink); font-weight: 700; }
.ai-steps li.now .dot { border-color: var(--pri); border-top-color: transparent; animation: spin .9s linear infinite; }
.ai-steps li.fail { color: var(--red-ink); }
.ai-steps li.fail .dot { background: var(--red); border-color: var(--red); }
@media (prefers-reduced-motion: reduce) { .ai-steps li.now .dot { animation: none; border-top-color: var(--pri); } }

/* Gõ trực tiếp trên các thanh từ (ô nhập thật được ẩn, chỉ nhận phím) */
.slotbox { position: relative; border: 1px solid var(--line-2); border-radius: 18px; background: var(--bg); padding: 18px; min-height: 104px; cursor: text; }
.slotbox:focus-within { border-color: var(--pri); box-shadow: 0 0 0 4px var(--pri-l); background: var(--card); }
.slotbox .slots { gap: 12px 8px; }
.slotbox .slot { font-size: 22px; min-height: 48px; padding: 5px 10px 8px; cursor: text; }
.slotbox .ghost-input { position: absolute; left: 18px; top: 18px; width: 1px; height: 1px; min-height: 0; opacity: 0; border: 0; padding: 0; margin: 0; resize: none; overflow: hidden; font-size: 16px; caret-color: transparent; }
.slotbox::after { content: attr(data-hint); display: block; margin-top: 12px; font-size: 14px; color: var(--muted); visibility: hidden; } /* luôn giữ chỗ để bố cục không nhảy khi bấm nút */
.slotbox:not(.has-text):not(:focus-within)::after { visibility: visible; }
.slotbox.done::after { display: none; }
.slot .caret { display: inline-block; width: 2px; height: 1.05em; margin: 0 1px; align-self: center; background: var(--ink); animation: caret-blink 1s steps(1) infinite; }
@keyframes caret-blink { 50% { opacity: 0; } }
.slotbox.done { padding: 0; border-color: transparent; background: none; cursor: default; }
.slotbox.done .mirror button.w { color: var(--green); }
@media (max-width: 760px) { .slotbox { padding: 12px; min-height: 84px; } .slotbox .slot { font-size: 18px; min-height: 40px; padding: 4px 8px 6px; } }
@media (prefers-reduced-motion: reduce) { .slot .caret { animation: none; } }

/* Hàng nút: ◀ Nghe lại ▶ cạnh nhau, rồi Chậm · Gợi ý · Xem đáp án · Kiểm tra */
.actions { grid-template-columns: 56px minmax(0, 1fr) 56px minmax(0, 1fr); grid-template-areas: "prev replay next slow" "hint hint reveal reveal" "check check check check"; }
.actions > .btn { order: 0; }
.actions #b-prev { grid-area: prev; } .actions #b-replay { grid-area: replay; } .actions #b-next { grid-area: next; } .actions #b-slow { grid-area: slow; }
.actions #b-hint { grid-area: hint; } .actions #b-reveal { grid-area: reveal; } .actions #b-check { grid-area: check; }
.actions .icon-nav { padding: 0; }
.actions .flip { display: inline-flex; transform: scaleX(-1); }
/* Bảng phím tắt */
.side-col .keys .hk { display: flex; justify-content: space-between; gap: 10px; align-items: center; width: 100%; }
.side-col .keys .kc { display: inline-flex; gap: 3px; align-items: center; flex: none; color: var(--ink-2); }
.seg.sm button { min-height: 30px; padding: 0 10px; font-size: 12px; }
@media (max-width: 760px) { .actions { grid-template-columns: 48px minmax(0, 1fr) 48px minmax(0, 1fr); } }
