/* Say Piano – e-book bài học */
@font-face { font-family: "Quicksand"; src: url("../fonts/Quicksand-Regular.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Quicksand"; src: url("../fonts/Quicksand-Medium.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Quicksand"; src: url("../fonts/Quicksand-SemiBold.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Quicksand"; src: url("../fonts/Quicksand-Bold.woff2") format("woff2"); font-weight: 700; font-display: swap; }
/* Không để một chữ đứng lẻ ở dòng cuối (chủ dự án 2026-10-19), áp cho mọi trang: đoạn văn "pretty" (tránh chữ mồ côi), chữ ngắn
   "balance" (nút, ô trả lời, thẻ, tiêu đề – các dòng dài gần bằng nhau). Trình duyệt cũ: assets/js/chu-khong-le.js nối hai từ cuối. */
body { text-wrap: pretty; }
h1, h2, h3, h4, h5, h6, button, label, summary, li, th, figcaption, [role="radio"], [role="button"],
.gm-card, .gm-card__chu, .gm-btn, .gm-dien__ten, .gm-ask__q, .tc-lc li { text-wrap: balance; }

:root {
  /* Màu thương hiệu (bảng màu cũ của sách điện tử) */
  --navy: #0F004E;
  /* gradient thương hiệu: xanh than → tím than */
  /* gradient thương hiệu nhiều mảng: các vệt tím / lam / tím than loang trên nền xanh than (không chia đôi) */
  --navy-grad:
    radial-gradient(70% 90% at 15% 15%, rgba(98, 66, 214, .75) 0%, transparent 60%),
    radial-gradient(60% 80% at 85% 85%, rgba(58, 34, 150, .9) 0%, transparent 65%),
    radial-gradient(50% 70% at 80% 10%, rgba(42, 82, 190, .55) 0%, transparent 60%),
    #0F034E;
  --navy-grad-h:
    radial-gradient(28% 160% at 6% 0%, rgba(98, 66, 214, .7) 0%, transparent 70%),
    radial-gradient(24% 140% at 30% 100%, rgba(42, 82, 190, .5) 0%, transparent 70%),
    radial-gradient(26% 170% at 55% 0%, rgba(124, 74, 220, .45) 0%, transparent 70%),
    radial-gradient(24% 150% at 78% 100%, rgba(58, 34, 150, .85) 0%, transparent 70%),
    radial-gradient(22% 160% at 98% 10%, rgba(98, 66, 214, .6) 0%, transparent 70%),
    #0F034E;
  --navy-grad-v: linear-gradient(180deg, #43289C 0%, #0F034E 100%);
  --cream: #FFFFFB;
  /* Tông phụ dựng từ màu thương hiệu */
  --navy-90: #241A5E;
  --navy-70: #4A4275;
  --navy-50: #7E78A0;
  --tint: #ECEAF6;
  --tint-2: #F5F4FA;
  --line: rgba(15, 3, 78, .12);
  /* Màu tay */
  --rh: #6A5AE0;
  --rh-soft: #DEDAFB;
  --lh: #12A39A;
  --lh-soft: #CDEFEC;
  --radius: 18px;
  --shadow: 0 16px 40px -24px rgba(15, 3, 78, .45);
  --topbar: 64px;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-padding-top: calc(var(--topbar) + 16px); }
body {
  margin: 0; background: var(--cream); color: var(--navy);
  font: 500 17px/1.65 "Quicksand", system-ui, sans-serif; -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; color: inherit; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0; }
p { margin: 0 0 .8em; }
.wrap { width: min(100% - 32px, 920px); margin-inline: auto; }

/* Thanh trên */
.topbar { position: sticky; top: 0; z-index: 30; height: var(--topbar); background: rgba(255, 255, 251, .98); border-bottom: 1px solid var(--line); }
.topbar__inner { height: 100%; display: flex; align-items: center; gap: 20px; }
/* logo chữ Say Piano ≥ 160 px ngang (cỡ nhỏ nhất của bộ nhận diện); chỗ hẹp (≤ 900 px) → biểu tượng O vương miện */
.brand img { width: 160px; height: auto; display: block; }
@media (max-width: 900px) { .brand img { content: url("../images/mark.svg"); width: auto; height: 40px; } }
.crumbs { display: flex; gap: 8px; font-size: 14px; font-weight: 600; color: var(--navy-50); min-width: 0; white-space: nowrap; overflow: hidden; }
.crumbs > * + *::before { content: "/"; margin-right: 8px; opacity: .6; }
.crumbs a { color: inherit; text-decoration: none; }
.crumbs a[href]:hover { color: var(--navy); }
.crumbs span:empty, .crumbs a:empty { display: none; }
.view-toggle { margin-left: auto; display: inline-flex; padding: 3px; border-radius: 999px; background: var(--tint); flex: none; }
.view-toggle button { border: 0; background: none; padding: .35em 1em; border-radius: 999px; font-weight: 700; font-size: 14px; cursor: pointer; }
.view-toggle button[aria-pressed="true"] { background: var(--navy-grad); color: var(--cream); }
.crumbs { flex: 1 1 auto; }
/* chế độ app (trong app Say Piano): nút quay về app thay cho logo và mục "Giáo trình" */
.app-back { flex: none; display: inline-flex; align-items: center; gap: .35em; padding: .35em .9em .35em .7em; border-radius: 999px; background: var(--navy-grad); color: var(--cream); font-weight: 700; font-size: 14px; text-decoration: none; }
.app-back span { font-size: 1.3em; line-height: 1; }
html.is-app .brand, html.is-app .crumbs > a:first-child { display: none; }
html.is-app .crumbs > a:first-child + *::before { content: none; }

/* Đầu bài */
.lesson-head, .title-card { position: relative; margin: 32px 0 8px; padding: 32px 36px; background: var(--tint); border-radius: 24px; overflow: hidden; isolation: isolate; }
.lesson-head::after, .title-card::after {
  /* logo chữ Say Piano chìm – luôn nằm trọn trong khung, co giãn theo bề rộng khung */
  content: ""; position: absolute; z-index: -1; pointer-events: none;
  right: 4%; bottom: 7%; width: 42%; aspect-ratio: 1780.17 / 577.46;
  background: url("../images/logo.svg") center / contain no-repeat; opacity: .06;
}
.lh__meta { display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 700; text-transform: uppercase; color: var(--navy-70); }
.lh__badge { background: var(--navy-grad); color: var(--cream); padding: .25em .8em; border-radius: 999px; text-transform: none; }
.lh__title { font-size: clamp(28px, 4.2vw, 40px); margin: 14px 0 10px; max-width: 80%; }
.lh__goal { color: var(--navy-70); max-width: 620px; margin: 0; }
.lh__num { position: absolute; right: 28px; top: 8px; font-size: clamp(64px, 11vw, 120px); font-weight: 700; color: var(--navy); opacity: .08; line-height: 1.1; }

/* Block */
.lesson { padding-bottom: 48px; }
.slide--title { display: none; }
.blk-heading { display: flex; align-items: center; gap: 12px; font-size: 24px; margin: 48px 0 16px; }
.blk-heading::before { content: ""; width: 5px; height: 26px; border-radius: 3px; background: var(--navy-grad-v); }
.blk-text p { max-width: 760px; }
.blk-text strong { font-weight: 700; }
.em { background: none; color: var(--rh); font-weight: 700; }
.blk-callout { margin: 20px 0; padding: 20px 24px; border-radius: var(--radius); background: var(--tint-2); border: 1px solid var(--line); }
.blk-callout--technique { background: var(--tint); border-color: transparent; }
.blk-callout--remember { border-left: 5px solid var(--navy); }
.blk-callout h4 { font-size: 17px; margin-bottom: 8px; }
.blk-callout ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.blk-callout li { position: relative; padding-left: 20px; } /* không dùng flex: chữ đậm trong dòng sẽ bị tách thành cột */
.blk-callout li::before { content: "•"; color: var(--rh); font-weight: 700; position: absolute; left: 2px; top: 0; }
/* Bảng */
.blk-table { margin: 20px 0; }
.blk-table__scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.blk-table table { width: 100%; border-collapse: collapse; font-size: 15px; }
.blk-table th { text-align: left; background: var(--tint); font-weight: 700; padding: 10px 14px; }
.blk-table td { padding: 9px 14px; border-top: 1px solid var(--line); vertical-align: top; }
.blk-table figcaption, .blk-keyboard figcaption { text-align: center; color: var(--navy-50); font-size: 14px; margin-top: 10px; }
body.is-presenting .blk-table table { font-size: 20px; }

/* Bàn phím minh hoạ */
.blk-keyboard { margin: 20px 0; }
.blk-keyboard__kb { background: var(--navy-grad-h); padding: 6px 6px 0; border-radius: 14px; }
.blk-keyboard .kb { height: 110px; }
body.is-presenting .blk-keyboard .kb { height: 160px; }
.kb__white.is-mark-rh { background: var(--rh-soft); }
.kb__white.is-mark-lh { background: var(--lh-soft); }
.kb__white.is-mark-mark { background: #FDE2E6; }
.kb__black.is-mark-rh { background: var(--rh); }
.kb__black.is-mark-lh { background: var(--lh); }
.kb__black.is-mark-mark { background: #E5484D; }
.kb__label--mark { color: var(--navy) !important; font-size: 13px !important; font-weight: 700; display: block !important; }
.kb__black .kb__label--mark { color: #fff !important; bottom: 6px; }

/* ---------- Minh hoạ cách tính hợp âm ba (triad-builder) ---------- */
@font-face { font-family: "Bravura"; src: url("../../vendor/alphatab/font/Bravura.woff2") format("woff2"); font-display: block; }
.tb { margin: 24px 0; padding: 20px; border-radius: 22px; background: #fff; border: 1px solid var(--line); box-shadow: var(--shadow); }
.tb__head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.tb__seg { display: inline-flex; padding: 3px; border-radius: 999px; background: var(--tint); }
.tb__seg button { border: 0; background: none; padding: .45em 1.2em; border-radius: 999px; font-weight: 700; cursor: pointer; color: var(--navy); }
.tb__seg button[aria-pressed="true"] { background: var(--navy-grad); color: var(--cream); box-shadow: none; }
.tb__root { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 700; color: var(--navy-70); }
.tb__root select { font: inherit; font-weight: 700; color: var(--navy); border: 1px solid var(--line); border-radius: 999px; padding: .35em .9em; background: #fff; }
.tb__play { margin-left: auto; display: inline-flex; gap: 8px; flex-wrap: wrap; }
.tb__play button { display: inline-flex; align-items: center; gap: 6px; border: 0; border-radius: 999px; padding: .5em 1.1em; font-weight: 700; font-size: 14px; cursor: pointer; color: var(--cream); background: var(--navy-grad); }
.tb__play button svg { width: 14px; height: 14px; }
.tb__play button:hover { filter: brightness(1.15); }

.tb__formula { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 18px 0 6px; font-size: 16px; }
.tb__pill { display: inline-flex; align-items: center; gap: 8px; padding: .45em 1em; border-radius: 14px; font-weight: 700; transition: transform .2s, box-shadow .2s; }
.tb__pill b { font-weight: 700; opacity: .8; }
.tb__pill i { font-style: normal; font-size: 18px; }
.tb__pill--a { background: #ECE9FF; color: #4B3BC8; }
.tb__pill--b { background: #FFF3D1; color: #A86E00; }
.tb__pill.is-on { transform: translateY(-2px) scale(1.04); box-shadow: none; }
.tb__plus, .tb__eq { font-size: 22px; font-weight: 700; color: var(--navy-50); }
.tb__result { font-size: 16px; color: var(--navy-70); }
.tb__result b { color: var(--navy); font-size: 18px; }

.tb__svg { display: block; width: 100%; height: auto; overflow: visible; }
.tb__line { stroke: #2B2357; stroke-width: 1.3; }
.tb__bar { stroke: #2B2357; stroke-width: 1.6; }
.tb__barfill { fill: #2B2357; }
.tb__glyph { font-family: "Bravura"; font-size: 64px; fill: var(--navy); }
.tb__clef { font-size: 64px; }
.tb__acc { font-size: 64px; opacity: 0; transition: opacity .35s; }
.tb__acc.is-shown { opacity: 1; fill: #E5484D; }
.tb__note { transition: transform .45s cubic-bezier(.3, 1.4, .5, 1); }
.tb__note .tb__nh { fill: #8A84AD; transition: fill .2s; }
.tb__note.is-chord .tb__nh { fill: var(--navy); }
.tb__note--chord .tb__nh { fill: #6A5AE0 !important; }
.tb__note.is-on .tb__nh { fill: #E5484D !important; }
.tb__note.is-on { filter: none; }
.tb__ledger { stroke: #2B2357; stroke-width: 1.3; }
.tb__deg circle { fill: #fff; stroke: #C9C4E4; stroke-width: 1.5; }
.tb__deg text { font: 700 15px "Quicksand"; text-anchor: middle; fill: var(--navy-70); }
.tb__deg.is-chord circle { fill: #E5484D; stroke: none; }
.tb__deg.is-chord text { fill: #fff; }
.tb__chordname { font: 700 22px "Quicksand"; text-anchor: middle; fill: #6A5AE0; }

.tb__arc path { fill: none; stroke-width: 3.5; stroke-linecap: round; transition: stroke-width .2s; }
.tb__arc.is-whole path { stroke: #12A39A; }
.tb__arc.is-half path { stroke: #E5484D; stroke-dasharray: 2 0; }
.tb__arc circle { fill: #fff; stroke-width: 2; }
.tb__arc.is-whole circle { stroke: #12A39A; }
.tb__arc.is-half circle { stroke: #E5484D; }
.tb__arc text { font: 700 14px "Quicksand"; text-anchor: middle; }
.tb__arc.is-whole text { fill: #0B7F78; }
.tb__arc.is-half text { fill: #C2185B; }
.tb__arc.is-on path { stroke-width: 6; }
.tb__marker.is-whole path { fill: #12A39A; }
.tb__marker.is-half path { fill: #E5484D; }

.tb__span path { fill: none; stroke-width: 2.5; stroke-linejoin: round; }
.tb__span text { font: 700 14px "Quicksand"; text-anchor: middle; }
.tb__span--a path { stroke: #6A5AE0; }
.tb__span--a text { fill: #4B3BC8; }
.tb__span--b path { stroke: #F2A900; }
.tb__span--b text { fill: #A86E00; }

.tb__legend { display: flex; flex-wrap: wrap; gap: 8px 20px; justify-content: center; font-size: 13px; color: var(--navy-70); margin: 4px 0 14px; }
.tb__legend span { display: inline-flex; align-items: center; gap: 6px; }
.tb__dot { width: 18px; height: 6px; border-radius: 4px; display: inline-block; }
.tb__dot--whole { background: #12A39A; }
.tb__dot--half { background: #E5484D; }
.tb__dot--chord { width: 12px; height: 12px; border-radius: 50%; background: #E5484D; }

.tb__kb { border-radius: 16px; padding: 10px 10px 6px; background: var(--tint-2); }
.tb__kbsvg { display: block; width: 100%; height: auto; }
.tb__key { cursor: pointer; }
.tb__key rect { transition: fill .12s, transform .08s; }
.tb__key.is-white rect { fill: #fff; stroke: #1B1240; stroke-width: 1.5; }
.tb__key.is-black rect { fill: #1B1240; }
.tb__key.is-white.is-scale rect { fill: #F1EFFA; }
.tb__key.is-white.is-chord rect { fill: #DEDAFB; }
.tb__key.is-black.is-chord rect { fill: #6A5AE0; }
.tb__key.is-on rect { fill: #FFD9DB !important; transform: translateY(2px); }
.tb__key.is-black.is-on rect { fill: #E5484D !important; }
.tb__keydeg circle { fill: #8A84AD; }
.tb__key.is-chord .tb__keydeg circle { fill: #E5484D; }
.tb__keydeg text { font: 700 13px "Quicksand"; text-anchor: middle; fill: #fff; pointer-events: none; }
.tb__keydeg { pointer-events: none; }
.tb__kb { padding: 12px 14px 8px; }
.tb__count circle { stroke-width: 2.5; fill: #fff; }
.tb__count text { font: 700 13px "Quicksand"; text-anchor: middle; pointer-events: none; }
.tb__count { pointer-events: none; }
.tb__count.tb__span--a circle { stroke: #6A5AE0; }
.tb__count.tb__span--a text { fill: #4B3BC8; }
.tb__count.tb__span--b circle { stroke: #E0A100; }
.tb__count.tb__span--b text { fill: #A86E00; }
.tb__key.is-black .tb__count circle { fill: #1B1240; }
.tb__key.is-black .tb__count.tb__span--a text { fill: #C9C2FF; }
.tb__key.is-black .tb__count.tb__span--b text { fill: #FFD66B; }
.tb__brace path { fill: none; stroke-width: 2.5; stroke-linecap: round; }
.tb__brace rect { stroke: none; }
.tb__brace text { font: 700 14px "Quicksand"; text-anchor: middle; }
.tb__brace.tb__span--a path { stroke: #6A5AE0; }
.tb__brace.tb__span--a rect { fill: #ECE9FF; }
.tb__brace.tb__span--a text { fill: #4B3BC8; }
.tb__brace.tb__span--b path { stroke: #E0A100; }
.tb__brace.tb__span--b rect { fill: #FFF3D1; }
.tb__brace.tb__span--b text { fill: #A86E00; }

/* so sánh trưởng / thứ */
.tb__compare { margin-top: 16px; display: grid; gap: 8px; }
.tb__cmp { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; padding: 10px 14px; border-radius: 14px; border: 1px solid var(--line); background: #fff; opacity: .6; transition: opacity .2s, border-color .2s, box-shadow .2s; }
.tb__cmp.is-current { opacity: 1; border-color: transparent; box-shadow: 0 0 0 2px #6A5AE0 inset; }
.tb__cmp b { min-width: 64px; font-size: 16px; color: var(--navy); }
.tb__cmp .tb__pill { padding: .3em .8em; font-size: 14px; border-radius: 10px; }
.tb__cmp em { margin-left: auto; font-style: normal; font-size: 13px; color: var(--navy-50); }
.tb__tip { margin: 4px 2px 0; font-size: 14px; color: var(--navy-70); text-align: center; }
.tb__tip b { color: var(--navy); }
@media (max-width: 640px) {
  .tb { padding: 14px; }
  .tb__play { margin-left: 0; }
  .tb__formula { font-size: 14px; }
}
@media (prefers-reduced-motion: reduce) { .tb__note, .tb__acc { transition: none; } }

.blk-unknown { padding: 16px; border: 1px dashed var(--line); border-radius: 12px; color: var(--navy-50); }

/* Khối bản nhạc */
.blk-score { margin: 20px 0 28px; }
.sb__head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.sb__label { font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--rh); }
.sb__title { font-size: 19px; }
.sb__credit { font-size: 14px; color: var(--navy-50); font-weight: 600; }
.sb__instruction { color: var(--navy-70); font-size: 15px; margin: 4px 0 12px; }
.sb__card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.sb--compact .sb__card { box-shadow: none; }
.sb__caption { text-align: center; color: var(--navy-50); font-size: 14px; margin: 10px 0 0; }

.sb__bar { background: var(--navy-grad-h); color: var(--cream); padding: 10px 12px; }
.sb__row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.sb__row--tools { margin-top: 10px; padding-top: 10px; border-top: 1px solid rgba(255, 255, 251, .14); gap: 8px; }
/* thanh thu gọn */
.sb__top { display: flex; align-items: center; gap: 12px; }
.sb__logo { height: 28px; width: auto; }   /* biểu tượng O vương miện – thanh bản nhạc chật, logo chữ cần ≥ 160 px */
.sb__top .sb__time { margin-left: auto; min-width: 0; opacity: .8; }
.sb__more-btn {
  margin-left: auto; display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px;
  border: 0; border-radius: 999px; background: rgba(255, 255, 251, .12); color: var(--cream); font-size: 13px; font-weight: 700; cursor: pointer;
}
.sb__top .sb__time + .sb__more-btn { margin-left: 4px; }
.sb__more-btn:hover { background: rgba(255, 255, 251, .2); }
.sb__more-btn svg { width: 16px; height: 16px; transition: transform .2s; }
.sb__bar.is-open .sb__more-btn svg { transform: rotate(180deg); }
/* phần thả xuống: trượt mở mượt */
.sb__more { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .25s ease; }
.sb__bar.is-open .sb__more { grid-template-rows: 1fr; }
.sb__more-inner { min-height: 0; overflow: hidden; }
.sb__more-inner > .sb__row:first-child { margin-top: 10px; padding-top: 10px; border-top: 1px solid rgba(255, 255, 251, .14); }
@media (prefers-reduced-motion: reduce) { .sb__more, .sb__more-btn svg { transition: none; } }
.sb__btn {
  height: 36px; min-width: 36px; padding: 0 10px; border: 0; border-radius: 10px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-size: 13px; font-weight: 700;
  background: rgba(255, 255, 251, .1); color: var(--cream);
}
.sb__btn:hover { background: rgba(255, 255, 251, .2); }
.sb__btn:disabled { opacity: .4; cursor: progress; }
.sb__btn svg { width: 17px; height: 17px; flex: none; }
.sb__btn[aria-pressed="true"] { background: var(--cream); color: var(--navy); }
.sb__btn--play { width: 44px; height: 44px; border-radius: 50%; padding: 0; background: var(--cream); color: var(--navy); }
.sb__btn--play svg { width: 20px; height: 20px; }
.sb__time { font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; min-width: 80px; }
.sb__progress { flex: 1 1 160px; height: 6px; border-radius: 6px; background: rgba(255, 255, 251, .2); position: relative; cursor: pointer; }
.sb__progress::after { content: ""; position: absolute; inset: -10px 0; }
.sb__progress i { position: absolute; inset: 0 auto 0 0; width: 0; border-radius: 6px; background: var(--cream); }
.sb__vol { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; }
.sb__vol svg { width: 18px; height: 18px; flex: none; }
.sb__vol input { width: 90px; accent-color: var(--cream); }
.sb__vol output { min-width: 38px; font-variant-numeric: tabular-nums; }
.sb__zoom { display: inline-flex; align-items: center; gap: 2px; background: rgba(255, 255, 251, .1); border-radius: 12px; padding: 2px; }
.sb__zoom .sb__btn { background: none; height: 32px; min-width: 32px; padding: 0 6px; }
.sb__zoom .sb__btn:hover { background: rgba(255, 255, 251, .15); }
.sb__zoom output { min-width: 42px; text-align: center; font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }
.sb__speed { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; }
.sb__speed input { width: 90px; accent-color: var(--cream); }
.sb__speed output { min-width: 56px; font-variant-numeric: tabular-nums; }

.seg { display: inline-flex; background: rgba(255, 255, 251, .1); border-radius: 12px; padding: 3px; }
.seg button { border: 0; background: none; color: var(--cream); font-size: 13px; font-weight: 700; padding: 0 12px; height: 30px; border-radius: 9px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.seg button[aria-pressed="true"] { background: var(--cream); color: var(--navy); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot--rh { background: var(--rh); }
.dot--lh { background: var(--lh); }

.sw { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; cursor: pointer; }
.sw input { position: absolute; opacity: 0; }
.sw i { width: 34px; height: 20px; border-radius: 20px; background: rgba(255, 255, 251, .25); position: relative; transition: background .15s; }
.sw i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: var(--cream); transition: transform .15s; }
.sw input:checked + i { background: var(--rh); }
.sw input:checked + i::after { transform: translateX(14px); }
.sw input:focus-visible + i { outline: 2px solid var(--cream); outline-offset: 2px; }

.sb__score { position: relative; min-height: 120px; padding: 12px 4px 4px; }
.sb__loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--navy-50); font-weight: 600; font-size: 14px; padding: 12px; text-align: center; }
.sb__loading.is-error { color: #C2185B; }
.sb__score .at-surface { margin: 0 auto; }
.at-cursor-bar { background: rgba(106, 90, 224, .08); }
.at-cursor-beat { background: var(--navy); width: 3px; border-radius: 2px; }
.at-selection div { background: rgba(106, 90, 224, .18); }
.at-highlight * { fill: var(--navy) !important; stroke: var(--navy) !important; }

/* Bàn phím ảo */
.sb__kb { border-top: 1px solid var(--line); background: var(--navy-grad-h); padding: 6px 6px 0; }
.kb { position: relative; display: flex; height: 92px; user-select: none; -webkit-user-select: none; touch-action: none; }
/* Phím: có gờ dưới như phím thật; khi nhấn (tay bấm hoặc trình phát chơi) phím lún xuống */
.kb__white {
  flex: 1 1 0; position: relative; margin-left: -1px; cursor: pointer;
  background: linear-gradient(#fff 0 88%, #F3F1FA); border: 1px solid var(--navy); border-radius: 0 0 6px 6px;
  box-shadow: inset 0 -5px 0 #E3E0EF;
  transition: transform .07s ease-out, box-shadow .07s ease-out, background .07s;
}
.kb__black {
  position: absolute; top: 0; height: 60%; z-index: 2; cursor: pointer; border-radius: 0 0 5px 5px;
  background: linear-gradient(#2A1F57, #120A35 85%); box-shadow: inset 0 -5px 0 rgba(255, 255, 255, .14), 0 3px 3px rgba(15, 3, 78, .35);
  transition: transform .07s ease-out, box-shadow .07s ease-out, height .07s ease-out, background .07s;
}
/* trạng thái nhấn: mất gờ dưới, bóng ở đầu phím, phím lún 2px */
.kb__white.is-pressed, .kb__white.is-rh, .kb__white.is-lh {
  transform: translateY(2px);
  box-shadow: inset 0 6px 8px -4px rgba(15, 3, 78, .35), inset 0 -1px 0 #E3E0EF;
}
.kb__white.is-pressed { background: linear-gradient(#ECEAF6, #E1DEF0); }
.kb__white.is-rh { background: linear-gradient(var(--rh-soft), #CBC5F7); box-shadow: inset 0 6px 8px -4px rgba(15, 3, 78, .35), inset 0 -4px 0 var(--rh); }
.kb__white.is-lh { background: linear-gradient(var(--lh-soft), #B6E6E2); box-shadow: inset 0 6px 8px -4px rgba(15, 3, 78, .35), inset 0 -4px 0 var(--lh); }
.kb__black.is-pressed, .kb__black.is-rh, .kb__black.is-lh {
  transform: translateY(1px); height: 58.5%;
  box-shadow: inset 0 -2px 0 rgba(255, 255, 255, .12), 0 1px 1px rgba(15, 3, 78, .3);
}
.kb__black.is-pressed { background: linear-gradient(#3A2E6E, #22174F); }
.kb__black.is-rh { background: linear-gradient(#8273EA, var(--rh)); }
.kb__black.is-lh { background: linear-gradient(#2BB8AE, var(--lh)); }
@media (prefers-reduced-motion: reduce) { .kb__white, .kb__black { transition: none; } }
.kb__white:first-child { margin-left: 0; }
.kb__label { position: absolute; left: 0; right: 0; bottom: 4px; text-align: center; font-size: 10px; font-weight: 700; color: var(--navy-50); pointer-events: none; white-space: nowrap; }
.kb__label--mid { color: var(--navy); }
.kb__label--mid::after { content: ""; display: block; width: 5px; height: 5px; margin: 2px auto 0; border-radius: 50%; background: var(--navy); }

/* Logo chìm nền trang */
.watermark {
  position: fixed; z-index: -1; pointer-events: none; right: -12vmin; bottom: -14vmin; width: 62vmin; height: 62vmin;
  background: url("../images/mark.svg") center / contain no-repeat; opacity: .035;
}
body { position: relative; isolation: isolate; }


/* ---------- Trình chiếu: khung 3 phần đều nhau (đầu slide – nội dung – điều khiển) ---------- */
.present-bar, .present-head { display: none; }
body.is-presenting { overflow: hidden; }
body.is-presenting .topbar, body.is-presenting .lesson-head, body.is-presenting .foot { display: none; }
body.is-presenting main.wrap { width: 100%; max-width: none; }
body.is-presenting .lesson { padding: 0; }
body.is-presenting .slide { display: none; }
body.is-presenting .watermark { opacity: .05; right: -8vmin; bottom: 0; }

body.is-presenting .present-head {
  display: flex; align-items: center; gap: 20px; position: fixed; top: 0; left: 0; right: 0; height: 64px; z-index: 40;
  padding: 0 max(24px, calc((100vw - 1180px) / 2)); background: var(--cream); border-bottom: 1px solid var(--line);
}
.present-head img { width: 160px; height: auto; }
.present-head span { margin-left: auto; font-size: 14px; font-weight: 700; color: var(--navy-50); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

body.is-presenting .slide.is-current {
  display: flex; flex-direction: column; position: fixed; inset: 64px 0 64px; overflow: auto;
  padding: 32px max(24px, calc((100vw - 1180px) / 2)); font-size: 22px;
}
/* nội dung căn giữa theo chiều dọc; dài quá thì cuộn mà không bị cắt đầu */
body.is-presenting .slide__inner { margin-block: auto; width: 100%; }
body.is-presenting .slide[data-kind="text"] .slide__inner { max-width: 1000px; margin-inline: auto; }
body.is-presenting .slide .blk-heading { margin: 0 0 24px; font-size: 38px; }
body.is-presenting .slide .blk-heading::before { height: 36px; width: 6px; }
body.is-presenting .slide .blk-text p { max-width: none; line-height: 1.7; }
body.is-presenting .slide .blk-callout { margin: 0; padding: 28px 32px; }
body.is-presenting .slide .blk-callout h4 { font-size: 26px; margin-bottom: 14px; }
body.is-presenting .slide .blk-callout ul { gap: 12px; }
body.is-presenting .slide .blk-score, body.is-presenting .slide body.is-presenting .slide .sb__title { font-size: 26px; }
body.is-presenting .slide .sb__instruction { font-size: 18px; }
body.is-presenting .slide .kb { height: 120px; }
/* slide bản nhạc: tên mục đã hiện ở thanh điều khiển → nhường chỗ cho bản nhạc */
body.is-presenting .slide[data-kind="score"] .blk-heading { display: none; }
body.is-presenting .slide body.is-presenting .slide 
body.is-presenting .slide--title .slide__inner { max-width: 1000px; margin-inline: auto; }
body.is-presenting .title-card { margin: 0; padding: 72px 64px; }
body.is-presenting .title-card .lh__title { font-size: 54px; max-width: 85%; }
body.is-presenting .title-card .lh__goal { font-size: 22px; max-width: 720px; }
body.is-presenting .title-card::after { width: 60%; right: 4%; bottom: 7%; opacity: .07; }

body.is-presenting .present-bar {
  display: flex; align-items: center; gap: 14px; position: fixed; left: 0; right: 0; bottom: 0; height: 64px;
  padding: 0 max(24px, calc((100vw - 1180px) / 2)); background: var(--navy-grad-h); color: var(--cream); z-index: 40; font-weight: 700;
}
.present-bar button { border: 0; background: rgba(255, 255, 251, .12); color: var(--cream); width: 44px; height: 40px; border-radius: 12px; font-size: 26px; line-height: 1; cursor: pointer; }
.present-bar button:disabled { opacity: .3; cursor: default; }
.present-bar__section { flex: 1; text-align: center; font-size: 15px; opacity: .85; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.present-bar .present-bar__exit { width: auto; padding: 0 16px; font-size: 14px; }
.present-bar #present-count { font-variant-numeric: tabular-nums; font-size: 14px; }

/* ---------- Ghi chú: lớp vẽ toàn màn hình + nút bút nổi ---------- */
.ann-overlay { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 45; pointer-events: none; }
body.is-drawing .ann-overlay { pointer-events: auto; touch-action: none; cursor: crosshair; }
body.is-drawing .ann-overlay[data-tool="eraser"] { cursor: cell; }
body.is-presenting .present-head, body.is-presenting .present-bar { z-index: 50; }

.pen { position: fixed; right: 24px; bottom: 88px; z-index: 70; width: 56px; height: 56px; }
.pen__panel { position: absolute; bottom: calc(100% + 12px); left: 0; }
/* đang ở chế độ viết, bảng đã ẩn: nút mang màu bút + vòng nhịp nhẹ */
.pen__fab.is-writing { background: var(--c); color: #fff; animation: pen-pulse 1.8s ease-in-out infinite; }
@keyframes pen-pulse { 50% { box-shadow: 0 10px 28px -8px rgba(15, 3, 78, .6), 0 0 0 3px var(--cream), 0 0 0 10px color-mix(in srgb, var(--c) 35%, transparent); } }
@media (prefers-reduced-motion: reduce) { .pen__fab.is-writing { animation: none; } }
.pen--left .pen__panel { left: auto; right: 0; }
.pen--below .pen__panel { bottom: auto; top: calc(100% + 12px); }
.pen__fab {
  width: 56px; height: 56px; border-radius: 50%; border: 0; cursor: grab; touch-action: none;
  background: var(--navy-grad); color: var(--cream); display: grid; place-items: center;
  box-shadow: 0 10px 28px -8px rgba(15, 3, 78, .6), 0 0 0 3px var(--cream), 0 0 0 6px var(--c, transparent);
}
.pen__fab:active { cursor: grabbing; }
.pen__fab svg { width: 24px; height: 24px; }
.pen__fab.is-active { background: var(--cream); color: var(--navy); box-shadow: 0 10px 28px -8px rgba(15, 3, 78, .6), 0 0 0 3px var(--navy), 0 0 0 6px var(--c); }
.pen__panel { background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 12px; box-shadow: var(--shadow); width: 256px; }
.pen__tools { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.pen__tools button { border: 0; background: var(--tint-2); border-radius: 12px; padding: 8px 4px; display: grid; justify-items: center; gap: 2px; font-size: 12px; font-weight: 700; cursor: pointer; color: var(--navy); }
.pen__tools button svg { width: 20px; height: 20px; }
.pen__tools button[aria-pressed="true"] { background: var(--navy-grad); color: var(--cream); }
.pen__row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; }
.pen__sizes { display: inline-flex; gap: 4px; background: var(--tint-2); border-radius: 12px; padding: 3px; }
.pen__sizes button { width: 34px; height: 30px; border: 0; background: none; border-radius: 9px; cursor: pointer; display: grid; place-items: center; }
.pen__sizes button i { width: var(--d); height: var(--d); border-radius: 50%; background: var(--navy); }
.pen__sizes button[aria-pressed="true"] { background: #fff; box-shadow: none; }
.pen__undo { white-space: nowrap; border: 0; background: var(--tint-2); border-radius: 12px; height: 36px; padding: 0 10px; display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: var(--navy); cursor: pointer; }
.pen__undo svg { width: 16px; height: 16px; }
.pen__colors { display: flex; justify-content: space-between; margin: 12px 4px; }
.pen__colors button { width: 30px; height: 30px; border-radius: 50%; border: 0; background: var(--c); cursor: pointer; box-shadow: 0 0 0 2px #fff, 0 0 0 3px var(--line); }
.pen__colors button[aria-pressed="true"] { box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--c); }
.pen__clear { width: 100%; border: 1px solid var(--line); background: none; border-radius: 12px; padding: 8px; display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 13px; font-weight: 700; cursor: pointer; color: #C2185B; }
.pen__clear svg { width: 16px; height: 16px; }
.pen__who { margin: 8px 2px 0; font-size: 12px; color: var(--navy-50); line-height: 1.4; }
.pen__toast { position: absolute; right: 68px; top: 12px; white-space: nowrap; background: var(--navy-grad); color: var(--cream); font-size: 13px; font-weight: 700; padding: .5em .9em; border-radius: 10px; }
body.is-presenting .pen { bottom: 84px; }

/* Mục lục bậc */
body.is-level .view-toggle, body.is-level .pen, body.is-level .ann-overlay { display: none; }
.stage { margin-top: 40px; }
.stage__title { display: flex; align-items: center; gap: 12px; font-size: 22px; margin-bottom: 16px; }
.stage__title span { width: 34px; height: 34px; border-radius: 50%; background: var(--navy-grad); color: var(--cream); display: grid; place-items: center; font-size: 16px; flex: none; }
.stage__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.lcard { position: relative; display: flex; flex-direction: column; gap: 8px; min-height: 128px; padding: 18px; border-radius: 18px; background: #fff; border: 1px solid var(--line); color: var(--navy); text-decoration: none; transition: transform .15s, box-shadow .15s, border-color .15s; }
a.lcard:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--navy); }
.lcard__num { font-size: 32px; font-weight: 700; line-height: 1; color: var(--navy); opacity: .2; }
.lcard__title { font-weight: 700; line-height: 1.35; }
.lcard.is-soon { background: var(--tint-2); color: var(--navy-50); }
.lcard__soon { margin-top: auto; font-size: 12px; font-weight: 700; color: var(--navy-50); }
.level-notes { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 40px; }
.level-notes .blk-callout { margin: 0; }

/* Danh sách bậc */
.levels { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; margin-top: 32px; }
.lvcard { display: grid; align-content: start; gap: 8px; padding: 24px; border-radius: 20px; background: #fff; border: 1px solid var(--line); color: var(--navy); text-decoration: none; transition: transform .15s, box-shadow .15s, border-color .15s; }
.lvcard:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--navy); }
.lvcard__num { justify-self: start; font-size: 13px; font-weight: 700; padding: .25em .8em; border-radius: 999px; background: var(--navy-grad); color: var(--cream); }
.lvcard b { font-size: 22px; line-height: 1.3; }
.lvcard span:last-child { color: var(--navy-50); font-size: 15px; }

/* Chuyển bài */
.lnav { width: min(100% - 32px, 920px); margin: 8px auto 24px; display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: stretch; }
.lnav__item { display: grid; gap: 4px; padding: 14px 18px; border-radius: 16px; border: 1px solid var(--line); background: #fff; color: var(--navy); text-decoration: none; }
a.lnav__item:hover { border-color: var(--navy); }
.lnav__item small { font-size: 12px; font-weight: 700; color: var(--navy-50); }
.lnav__item b { font-size: 15px; line-height: 1.35; }
.lnav__item--next { text-align: right; }
.lnav__item.is-soon { background: var(--tint-2); color: var(--navy-50); }
.lnav__all { align-self: center; font-size: 13px; font-weight: 700; color: var(--navy); text-decoration: none; padding: .5em 1em; border-radius: 999px; background: var(--tint); white-space: nowrap; }
body.is-presenting .lnav { display: none; }

.foot { padding: 24px 0 40px; font-size: 13px; color: var(--navy-50); text-align: center; }


@media (max-width: 640px) {
  body { font-size: 16px; }
  .crumbs { display: none; }
  .lesson-head { padding: 24px 20px; }
  .lh__title { max-width: none; }
  .sb__time { min-width: 0; }
  .sb__btn--tool span { display: none; }
  .sb__speed input { width: 70px; }
  .kb { height: 72px; }
  .kb__label { font-size: 9px; }
  .kb__label:not(.kb__label--c) { display: none; }
  body.is-presenting .slide.is-current { padding: 20px 12px; font-size: 17px; }
  body.is-presenting .slide .blk-heading { font-size: 26px; }
  .level-notes { grid-template-columns: 1fr; }
  .lnav { grid-template-columns: 1fr 1fr; }
  .lnav__all { grid-column: 1 / -1; grid-row: 2; justify-self: center; }
  body.is-presenting .title-card { padding: 36px 24px; }
  body.is-presenting .title-card .lh__title { font-size: 32px; }
  .topbar__inner { gap: 8px; }
  .brand { margin-right: auto; }
  .brand img { height: 34px; }
  .view-toggle button { padding: .35em .7em; font-size: 12px; }
  .sb__zoom output { min-width: 34px; }
  .sb__vol input { width: 64px; }
  .sb__vol output { display: none; }
  .sb__logo { height: 24px; }
  .sb__more-btn span { display: none; }
}
/* phím hai tay cùng dùng (vd. Đô giữa cho hai ngón cái) */
.kb__white.is-mark-both { background: linear-gradient(90deg, var(--lh-soft) 50%, var(--rh-soft) 50%); }

/* ---------- điện thoại ---------- */
.kb-scroll { position: relative; }
@media (max-width: 640px) {
  /* bàn phím: luôn trọn phạm vi trong bề ngang (chủ dự án 2026-10-19: không bắt vuốt ngang để xem phím) – phím co theo bề ngang */
  .kb { height: 110px; }
  .kb__label:not(.kb__label--c) { display: block; }
  /* trình chiếu không dùng trên điện thoại: nhường chỗ cho thanh trên cùng */
  .view-toggle { display: none; }
}

/* ---------- tiết học thử ---------- */
.trial__title { margin: 28px 0 14px; }
.lvcard--trial { background: var(--navy-grad); color: var(--cream); border-color: transparent; }
.lvcard--trial span { color: rgba(255, 255, 251, .85); }
.lvcard--trial .lvcard__num { background: var(--cream); color: var(--navy); }
.is-kids .lvcard--trial, .lvcard--trial:nth-child(1) { box-shadow: var(--shadow); }

/* khối "Dành cho giáo viên": kịch bản dạy, học viên không thấy */
.blk-callout--teacher { background: #FFF8E6; border: 2px dashed #E8A70C; border-left-width: 2px; position: relative; padding-top: 30px; }
.blk-callout__tag { position: absolute; top: -12px; left: 18px; background: #E8A70C; color: #fff; font-size: 13px; font-weight: 700; padding: 2px 12px; border-radius: 999px; }
.blk-callout--teacher li::before { content: "▸"; color: #E8A70C; }
body.is-student .blk-callout--teacher { display: none; }

/* lộ trình buổi học */
.blk-agenda { margin: 24px 0; padding: 22px 24px; border-radius: var(--radius); background: #fff; border: 1px solid var(--line); box-shadow: var(--shadow); }
.blk-agenda__title { font-size: 20px; margin-bottom: 14px; }
.blk-agenda__steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; counter-reset: s; }
.blk-agenda__steps li { position: relative; display: grid; justify-items: center; text-align: center; gap: 4px; padding: 14px 10px 12px; border-radius: 16px; background: var(--tint-2); }
.blk-agenda__icon { font-size: 30px; line-height: 1; }
.blk-agenda__steps b { font-size: 15px; line-height: 1.3; text-wrap: balance; }
.blk-agenda__steps small { font-size: 13px; font-weight: 700; color: var(--rh); }
.blk-agenda__steps span:not(.blk-agenda__icon) { font-size: 13px; color: var(--navy-70); line-height: 1.4; }
.blk-agenda__steps li:last-child { background: var(--navy-grad); color: var(--cream); }
.blk-agenda__steps li:last-child small, .blk-agenda__steps li:last-child span:not(.blk-agenda__icon) { color: rgba(255, 255, 251, .85); }
.is-kids .blk-agenda { border-radius: 28px; border: 4px solid #fff; }
.is-kids .blk-agenda__steps li:last-child { background: linear-gradient(135deg, #FF8FB1, #FFB86B); }
@media (max-width: 640px) { .blk-agenda__steps { grid-template-columns: 1fr 1fr; } }
.lvcard.lvcard--trial > span:last-child { color: rgba(255, 255, 251, .88); }
.lvcard.lvcard--trial b { color: var(--cream); }

/* ---------- Đàn thử: máy nghe và chấm ---------- */
.sb__listen {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px; margin-left: auto; border: 0; border-radius: 999px; cursor: pointer;
  background: #fff; color: var(--navy); font-weight: 700; font-size: 14px; box-shadow: 0 4px 14px -6px rgba(0, 0, 0, .4);
}
.sb__listen + .sb__more-btn { margin-left: 8px; }
.sb__listen[aria-pressed="true"] { background: #FF4B6E; color: #fff; animation: lsn-pulse 1.4s ease-in-out infinite; }
@keyframes lsn-pulse { 50% { box-shadow: 0 0 0 6px rgba(255, 75, 110, .25); } }
.lsn { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: #FFF5F7; border-bottom: 1px solid #FFD3DD; font-weight: 600; flex-wrap: wrap; }
.lsn.is-wrong { background: #FFF1E6; }
.lsn.is-error { background: #FFF8E6; }
.lsn.is-done { background: #E9FBF0; }
.lsn__mic { position: relative; font-size: 20px; width: 30px; display: inline-flex; align-items: flex-end; gap: 3px; }
.lsn__mic i { display: block; width: 5px; height: 20px; border-radius: 3px; background: #36C26B; transform-origin: bottom; transform: scaleY(0); transition: transform .06s; }
.lsn__msg { flex: 1; min-width: 180px; font-size: 16px; }
.lsn__msg span { font-weight: 500; }
.lsn__stars { font-size: 20px; margin-right: 6px; }
.lsn__btn { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 14px; font-weight: 700; font-size: 14px; cursor: pointer; }
.lsn__sens { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-soft, #5b5578); }
.lsn__sens select { width: auto; max-width: 170px; border: 1px solid var(--line); border-radius: 999px; padding: 5px 10px; font: inherit; font-weight: 700; background: #fff; }
.lsn__btn--stop { background: var(--navy); color: var(--cream); border-color: transparent; }
.lsn-layer { position: absolute; inset: 0; pointer-events: none; z-index: 4; }
/* chấm điểm: đầu nốt đúng chuyển xanh; nốt bấm nhầm hiện đầu nốt đỏ đúng cao độ */
.lsn-head { position: absolute; border-radius: 50%; transform: rotate(-20deg) scale(1.12); }
.lsn-head.is-ok { background: #1FA45B; box-shadow: 0 0 0 1px #1FA45B; }
.lsn-head.is-bad { background: #E5484D; box-shadow: 0 0 0 1px #E5484D; opacity: .95; }
.lsn-acc { position: absolute; color: #E5484D; font-weight: 700; line-height: 1; }
@keyframes lsn-ring { 50% { transform: scale(1.25); } }
@keyframes lsn-shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
@media (max-width: 640px) { .sb__listen span:last-child { display: none; } .sb__listen { padding: 0 10px; } }

/* ---------- tác phẩm bổ trợ ---------- */
.lvcard--lib { display: grid; margin: 0 0 16px; background: linear-gradient(135deg, #FFF6D6, #FFE6F0); border-color: #FFD3E4; }
.lib-filters { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; margin-top: 18px; font-weight: 600; font-size: 15px; }
.lib-filters select { font: inherit; padding: 6px 10px; border-radius: 12px; border: 1px solid var(--line); background: #fff; }
.lib-search { flex: 1 1 240px; display: flex; align-items: center; gap: 8px; background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; }
.lib-search input { border: 0; outline: 0; font: inherit; flex: 1; min-width: 0; background: transparent; }
.lib-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.lib-tag { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 4px 12px; font-weight: 600; font-size: 14px; cursor: pointer; }
.lib-tag[aria-pressed="true"] { background: var(--navy); color: var(--cream); border-color: transparent; }
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; margin: 24px 0; }
.lib-card { display: grid; gap: 4px; align-content: start; padding: 18px 20px; border-radius: var(--radius); background: #fff; border: 1px solid var(--line); text-decoration: none; color: var(--navy); box-shadow: var(--shadow); transition: transform .15s; }
.lib-card:hover { transform: translateY(-3px); }
.lib-card b { font-size: 20px; line-height: 1.25; text-wrap: balance; }
.lib-card small { color: var(--navy-50); font-size: 14px; }
.lib-card__by { color: var(--navy-70); font-size: 14px; }
.lib-card__tags { display: flex; gap: 6px; flex-wrap: wrap; }
.lib-card__tags i { font-style: normal; font-size: 12px; font-weight: 700; color: var(--rh); background: var(--tint); padding: 1px 8px; border-radius: 999px; }
.lib-card__vers { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.lib-card__vers em { font-style: normal; font-size: 13px; font-weight: 700; padding: 3px 10px; border-radius: 999px; background: #E9FBF0; color: #1E8E4A; }
.lib-card__vers em.is-locked { background: var(--tint-2); color: var(--navy-50); }
.lib-card.is-locked { opacity: .75; }
.lib-empty { margin: 30px 0; color: var(--navy-70); }
.lib-orig { margin: -6px 0 6px; color: var(--navy-50); font-style: italic; }
.lib-vers { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.lib-ver { display: grid; gap: 2px; padding: 10px 16px; border-radius: 16px; background: #fff; border: 2px solid var(--line); text-decoration: none; color: var(--navy); min-width: 170px; }
.lib-ver b { font-size: 16px; }
.lib-ver small { font-size: 13px; color: var(--navy-50); font-weight: 600; }
.lib-ver.is-current { border-color: var(--rh); box-shadow: 0 8px 20px -12px var(--rh); }
.lib-ver.is-locked { background: var(--tint-2); color: var(--navy-50); cursor: not-allowed; }
.lib-rights { font-size: 13px; color: var(--navy-50); margin-top: 14px; }
.lib-style { display: inline-flex; gap: 4px; margin-top: 14px; padding: 4px; border-radius: 999px; background: rgba(255, 255, 255, .7); border: 1px solid var(--line); }
.lib-style button { border: 0; background: none; border-radius: 999px; padding: 6px 14px; font-weight: 700; font-size: 14px; cursor: pointer; color: var(--navy-70); }
.lib-style button[aria-pressed="true"] { background: var(--navy); color: var(--cream); }
.is-kids .lib-style button[aria-pressed="true"] { background: linear-gradient(135deg, #FF6FA8, #FF9A2E); }

/* vạch chạy & ô nhịp đang phát: ẩn khi chưa phát (đỡ vướng mắt lúc đọc bài) */
.sb:not(.has-started) .at-cursor-bar, .sb:not(.has-started) .at-cursor-beat { opacity: 0; }
.lsn__mic { width: auto; min-width: 30px; }
.lsn__mic b { font-size: 14px; color: #1E8E4A; min-width: 32px; }

/* màn ăn mừng phá kỷ lục */
.lsn-record { position: fixed; inset: 0; z-index: 215; display: grid; place-items: center; background: rgba(15, 3, 78, .55); animation: lsn-in .3s ease; }
.lsn-record.is-out { opacity: 0; transition: opacity .4s; }
.lsn-record__card { display: grid; justify-items: center; gap: 2px; padding: 28px 48px 24px; border-radius: 32px; background: linear-gradient(160deg, #FFF6D6, #fff 55%, #FFE6F0);
  border: 5px solid #FFC93C; box-shadow: 0 30px 80px -20px rgba(255, 154, 46, .9); animation: lsn-pop .7s cubic-bezier(.2, 1.6, .4, 1); }
.lsn-record__trophy { font-size: 64px; line-height: 1; animation: lsn-bounce .9s ease-in-out infinite; }
.lsn-record__card b { font-size: 28px; color: #E8A70C; }
.lsn-record__card strong { font-size: 84px; line-height: 1; color: var(--navy); }
.lsn-record__card small { font-size: 18px; font-weight: 700; color: var(--navy-70); }
@keyframes lsn-in { from { opacity: 0; } }
@keyframes lsn-pop { 0% { transform: scale(.3) rotate(-8deg); } 100% { transform: none; } }
@keyframes lsn-bounce { 50% { transform: translateY(-10px) rotate(6deg); } }

/* ---------- minh hoạ cách tính thang âm ---------- */
.scb { margin: 24px 0; padding: 20px 22px; border-radius: var(--radius); background: #fff; border: 1px solid var(--line); box-shadow: var(--shadow); }
.scb__head { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; }
.scb__seg { display: inline-flex; gap: 4px; padding: 4px; border-radius: 999px; background: var(--tint); }
.scb__seg button { border: 0; background: none; border-radius: 999px; padding: 6px 14px; font-weight: 700; font-size: 14px; cursor: pointer; color: var(--navy-70); }
.scb__seg button[aria-pressed="true"] { background: var(--navy); color: var(--cream); }
.scb__root { font-weight: 600; font-size: 14px; display: inline-flex; gap: 8px; align-items: center; }
.scb__root select { font: inherit; padding: 5px 10px; border-radius: 10px; border: 1px solid var(--line); }
.scb__actions { display: flex; gap: 8px; margin-left: auto; }
.scb__btn { border: 0; border-radius: 999px; padding: 7px 16px; font-weight: 700; font-size: 14px; cursor: pointer; background: var(--navy-grad); color: var(--cream); }
.scb__btn--ghost { background: var(--tint); color: var(--navy); }
.scb__btn--ghost[aria-pressed="true"] { background: #FFE6F0; color: #B03A6A; }
.scb__formula { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin: 14px 0 4px; font-size: 15px; }
.scb__steps { display: inline-flex; gap: 4px; }
.scb__steps i { font-style: normal; font-weight: 700; min-width: 30px; text-align: center; padding: 2px 8px; border-radius: 8px; background: var(--lh-soft); color: #0E7C75; }
.scb__steps i.is-half { background: #FFE1E1; color: #D9303B; }
.scb__steps i.is-aug { background: #FFF1D6; color: #B87500; }
.scb__names { color: var(--navy-70); font-weight: 600; }
.scb__svg { width: 100%; height: auto; display: block; }
.scb__line, .scb__ledger { stroke: var(--navy); stroke-width: 1.6; }
.scb__glyph { font-family: Bravura; fill: var(--navy); }
.scb__clef { font-size: 64px; }
.scb__nh { font-size: 64px; }
.scb__acc { font-size: 58px; fill: #D9303B; }
.scb__note { transition: transform .35s; }
.scb__note.is-on .scb__nh { fill: var(--rh); }
.scb__deg { font: 700 40px Quicksand, sans-serif; fill: var(--navy); text-anchor: middle; }
.scb__gaptxt { font: 700 22px Quicksand, sans-serif; text-anchor: middle; fill: #0E7C75; }
.scb__gapunit { font: 600 15px Quicksand, sans-serif; text-anchor: middle; fill: var(--navy-50); }
.scb__gap.is-half .scb__gaptxt { fill: #D9303B; }
.scb__gap.is-aug .scb__gaptxt { fill: #B87500; }
.scb__gap.is-on .scb__gaptxt { font-size: 26px; }
.scb__brace, .scb__slur { fill: none; stroke: #D9303B; stroke-width: 2.4; stroke-linecap: round; }
.scb__slurtxt { font: 700 17px Quicksand, sans-serif; fill: #D9303B; text-anchor: middle; }
.scb__hit { fill: transparent; stroke: #FF9A2E; stroke-width: 2; stroke-dasharray: 5 4; cursor: pointer; }
.scb.is-quiz .scb__acc { fill: #FF9A2E; }
.scb__quizbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin: 6px 0 10px; padding: 10px 14px; border-radius: 14px; background: #FFF6D6; font-weight: 600; }
.scb__quizbar.is-right { background: #E9FBF0; color: #1E8E4A; }
.scb__quizbar.is-wrong { background: #FFF0F0; color: #D9303B; }
.scb__kb { margin-top: 10px; }
.scb__kbsvg { width: 100%; height: auto; display: block; }
.scb__key.is-white rect { fill: #fff; stroke: var(--navy); stroke-width: 2; }
.scb__key.is-black rect { fill: var(--navy); }
.scb__key.is-white.is-scale rect { fill: var(--rh-soft); }
.scb__key.is-black.is-scale rect { fill: var(--rh); }
.scb__key.is-on rect { fill: #FFC93C !important; }
.scb__keydeg circle { fill: var(--navy); }
.scb__key.is-black .scb__keydeg circle { fill: #fff; }
.scb__keydeg text { font: 700 17px Quicksand, sans-serif; fill: #fff; text-anchor: middle; }
.scb__key.is-black .scb__keydeg text { fill: var(--navy); }
.scb figcaption { margin-top: 10px; color: var(--navy-70); font-size: 15px; }
.is-kids .scb { border-radius: 28px; border: 4px solid #fff; }
@media (max-width: 640px) { .scb { padding: 14px 10px; } .scb__actions { margin-left: 0; } }
@media (max-width: 640px) {
  .scb__staff { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -8px; padding: 0 8px; }
  .scb__staff .scb__svg { width: 620px; max-width: none; }
}

/* ---------- bảo vệ nội dung (protect.js) ---------- */
html.is-protected body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
html.is-protected input, html.is-protected textarea, html.is-protected [contenteditable="true"] { -webkit-user-select: text; user-select: text; }
html.is-protected img, html.is-protected svg { -webkit-user-drag: none; }
.guard-veil { position: fixed; inset: 0; z-index: 2147483000; display: none; place-items: center; background: #FAF8FF; }
.guard-veil > div { display: grid; gap: 6px; text-align: center; color: var(--navy, #1D1550); }
.guard-veil b { font-size: 26px; }
html.is-shielded .guard-veil { display: grid; }
.guard-mark { position: fixed; inset: 0; z-index: 2147482000; pointer-events: none; background-repeat: repeat; }
.guard-print { display: none; }
@media print {
  html.is-protected, html.is-protected body { background: #fff !important; }
  html.is-protected body::before, html.is-protected body::after { display: none !important; }
  html.is-protected body > * { display: none !important; }
  html.is-protected body > .guard-print { display: block !important; padding: 40mm 20mm; font: 700 18px/1.5 sans-serif; text-align: center; color: #1D1550; }
}

/* ---------- bản nhạc toàn màn hình: thanh công cụ dính trên, bàn phím dính dưới, bản nhạc cuộn ở giữa ---------- */
.sb__btn--fs { color: #fff; background: rgba(255, 255, 255, .12); border-radius: 999px; width: 38px; height: 38px; display: inline-grid; place-items: center; flex: none; }
.sb__btn--fs svg { width: 20px; height: 20px; }
.sb__card.is-fs, .sb__card:fullscreen { position: fixed; inset: 0; z-index: 2147481000; width: 100vw; height: 100vh; height: 100dvh; max-width: none; margin: 0; border: 0; border-radius: 0; overflow: hidden; background: #fff; display: flex; flex-direction: column; }
.sb__card.is-fs > * { flex: none; }
.sb__card.is-fs .sb__bar { border-radius: 0; }
.sb__card.is-fs .sb__score { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
html.sb-fs-lock, html.sb-fs-lock body { overflow: hidden; }

/* ---------- chấm điểm kiểu karaoke: thanh tiến độ + điểm tạm; màn kết quả điểm số quay, tung hoa ---------- */
.lsn__prog { flex: 1 1 120px; min-width: 80px; height: 8px; border-radius: 999px; background: #EDE9FA; overflow: hidden; }
.lsn__prog i { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, #6C5CE7, #FF5FA2); transition: width .4s ease; }
.lsn__live { font-size: 18px; color: #6C5CE7; min-width: 70px; text-align: right; font-variant-numeric: tabular-nums; }
.sb__card { position: relative; }
.lsn-final { position: absolute; inset: 0; z-index: 30; display: grid; place-items: center; overflow: hidden; border-radius: inherit; min-height: 360px; background: rgba(15, 3, 78, .78); animation: lsn-in .3s ease; }
.lsn-final.is-out { opacity: 0; transition: opacity .35s; }
.lsn-final__card { display: grid; justify-items: center; gap: 6px; padding: 30px 44px 26px; border-radius: 32px; min-width: min(360px, 88vw);
  background: linear-gradient(160deg, #FFF6D6, #fff 55%, #FFE6F0); box-shadow: 0 30px 80px -20px rgba(15, 3, 78, .6); text-align: center; }
.lsn-final__kick { margin: 0; font-weight: 700; color: #6C5CE7; font-size: 18px; }
.lsn-final__num { display: flex; gap: 8px; margin: 6px 0 0; }
.lsn-final__num span { display: grid; place-items: center; width: 74px; height: 104px; border-radius: 18px; font-size: 76px; font-weight: 800; line-height: 1;
  color: #fff; background: linear-gradient(180deg, #2B1F7A, #1D1550); box-shadow: inset 0 -6px 0 rgba(0, 0, 0, .25); font-variant-numeric: tabular-nums; }
.lsn-final__num span:empty { display: none; }
.lsn-final__num span.is-set { background: linear-gradient(180deg, #FF7AB6, #FF5F7A); animation: lsn-pop .35s ease; }
.lsn-final__unit { font-size: 16px; color: #4A4060; margin-top: -2px; }
.lsn-final__msg { margin: 6px 0 0; font-size: 20px; font-weight: 700; color: #1D1550; min-height: 1.4em; }
.lsn-final__act { display: flex; gap: 10px; margin-top: 10px; }
.lsn-final.is-done .lsn-final__card { animation: lsn-pop .45s ease; }
@keyframes lsn-pop { 0% { transform: scale(.85); } 60% { transform: scale(1.08); } 100% { transform: scale(1); } }
@media (max-width: 520px) { .lsn-final__num span { width: 58px; height: 84px; font-size: 60px; } .lsn-final__card { padding: 24px 22px; } }
/* hoa / pháo hoa (kids.js burst) bay phía TRÊN màn kết quả chấm điểm */
.kd-fx { z-index: 2147482600 !important; pointer-events: none; }
/* bước chọn tay + đoạn ô nhịp trước khi chấm */
.lsn--setup { flex-wrap: wrap; gap: 10px; }
.lsn__field { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: #4A4060; }
.lsn__field select, .lsn__field input { font: inherit; font-weight: 700; padding: 5px 8px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.lsn__field input { width: 64px; }
.lsn__btn--go { background: linear-gradient(90deg, #6C5CE7, #FF5FA2); color: #fff; border-color: transparent; }
/* đoạn luyện tập + link giao bài */
.lsn__custom { display: none; gap: 10px; flex-wrap: wrap; }
.lsn__custom.is-open { display: inline-flex; }
.lsn__pass { font-size: 13px; color: #4A4060; }
body:not(.is-teacher) .lsn__btn--link { display: none; }
.lsn-final__pass { margin: 2px 0 0; font-weight: 700; color: #1FA45B; }

.lsn-petal { position: absolute; left: 50%; top: 45%; font-style: normal; pointer-events: none; z-index: 2; animation: lsn-petal 2.2s cubic-bezier(.2, .7, .3, 1) forwards; }
@keyframes lsn-petal { 0% { transform: translate(-50%, -50%) scale(.3); opacity: 0; } 12% { opacity: 1; }
  100% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy) + 120px)) rotate(var(--r)) scale(1); opacity: 0; } }
/* đoạn đang chọn để chấm: tô sáng các ô nhịp trên bản nhạc */
.lsn-hl { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
.lsn-hl i { position: absolute; background: rgba(255, 196, 61, .2); border-top: 2px solid rgba(255, 170, 0, .55); border-bottom: 2px solid rgba(255, 170, 0, .55); }
.lsn-hl i.is-first { border-left: 3px solid #FFAA00; border-radius: 8px 0 0 8px; }
.lsn-hl i.is-last { border-right: 3px solid #FFAA00; border-radius: 0 8px 8px 0; }
.lsn-hl i.is-first.is-last { border-radius: 8px; }
