/* masterpiano.vn – 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; }

:root {
  /* Màu thương hiệu (thư mục Logo masterpiano.vn) */
  --navy: #0F034E;
  /* 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, .92); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.topbar__inner { height: 100%; display: flex; align-items: center; gap: 20px; }
.brand img { height: 30px; width: auto; display: block; }
.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); }
/* chuyển ngôn ngữ VI / EN (cuối thanh trên cùng) */
.crumbs { flex: 1 1 auto; }
.lang-switch { display: inline-flex; flex: none; padding: 3px; border-radius: 999px; background: var(--tint); }
.lang-switch a { padding: .3em .6em; border-radius: 999px; font-weight: 700; font-size: 12px; line-height: 1.2; color: var(--navy-70, inherit); text-decoration: none; }
.lang-switch a:hover { color: var(--navy); }
.lang-switch a[aria-current] { background: var(--navy-grad); color: var(--cream); }

/* Đầ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ữ masterpiano.vn 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: 56%; aspect-ratio: 1400 / 201;
  background: url("../images/wordmark.png") 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 { display: flex; gap: 10px; }
.blk-callout li::before { content: "•"; color: var(--rh); font-weight: 700; }
/* 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: 0 4px 12px -6px rgba(15, 3, 78, .6); }
.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: 0 8px 18px -10px rgba(15, 3, 78, .5); }
.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: drop-shadow(0 0 6px rgba(229, 72, 77, .55)); }
.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: 20px; width: auto; opacity: .9; }
.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.png") 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 { height: 28px; width: 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: 0 1px 4px rgba(15, 3, 78, .18); }
.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: 22px; }
  /* điện thoại: chỉ hiện nút sang ngôn ngữ kia cho gọn */
  .lang-switch { padding: 2px; }
  .lang-switch a { padding: .25em .5em; font-size: 11px; }
  .lang-switch a[aria-current] { display: none; }
  .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: 16px; }
  .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: mỗi phím trắng tối thiểu 32px để ngón tay bấm trúng; vuốt ngang để xem phần còn lại, tự cuộn theo nốt đang phát */
  .kb-scroll { overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: thin; -webkit-overflow-scrolling: touch; }
  .kb { min-width: calc(var(--whites, 15) * 32px); touch-action: pan-x; 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; }
}
