:root {
  color-scheme: dark;
  --muc: #0B0D12;
  --kinh: rgba(16, 18, 26, .7);
  --o: rgba(255, 255, 255, .06);
  --vien: rgba(241, 238, 232, .12);
  --chu: #F1EEE8;
  --mo: #A7AAB6;
  /* #7E8293 cũ đo 3,86:1 trên góc thẻ kính sáng nhất vì aura (dưới 4,5:1 WCAG AA cho chữ thường) —
     soát cuối P4, mục D. #969AAB đo tối thiểu 5,26:1 trên cùng điểm. */
  --nhat: #969AAB;
  --than: #FF6B4A;
  --phach: #FFB547;
  --hong: #E0457B;
  --ngoc: #2EC4B6;
  --nguy: #FF8A7A;
  --tieu-de: "Bricolage Grotesque", "Be Vietnam Pro", system-ui, sans-serif;
  --than-chu: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", sans-serif;
  --tab: 64px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--muc); color: var(--chu); font: 16px/1.55 var(--than-chu); -webkit-tap-highlight-color: transparent; }
#nen {
  position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; display: block;
  background:
    radial-gradient(55% 45% at 18% 28%, rgba(255, 107, 74, .38), transparent 70%),
    radial-gradient(45% 40% at 78% 22%, rgba(224, 69, 123, .28), transparent 70%),
    radial-gradient(55% 50% at 62% 88%, rgba(46, 196, 182, .24), transparent 70%),
    var(--muc);
}
.khung {
  position: relative; z-index: 1; max-width: 720px; margin: 0 auto; display: grid; gap: 16px;
  padding-inline: 16px;
  padding-block: calc(12px + env(safe-area-inset-top, 0px)) calc(var(--tab) + 24px + env(safe-area-inset-bottom, 0px));
}
.dau { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.ten-app { display: inline-flex; align-items: center; min-height: 44px; font: 700 26px/1 var(--tieu-de); color: var(--chu); text-decoration: none; letter-spacing: -.02em; }
.dau-phai { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.pill { display: inline-flex; align-items: center; gap: 8px; min-height: 32px; padding: 4px 12px; border-radius: 999px; background: var(--kinh); border: 1px solid var(--vien); font-size: 13px; color: var(--mo); }
.pill i { width: 8px; height: 8px; border-radius: 50%; background: var(--nhat); }
.pill[data-muc="tot"] i { background: var(--ngoc); }
.pill[data-muc="cho"] i { background: var(--phach); }
.pill[data-muc="loi"] i { background: var(--nguy); }
.nut-tron { display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--vien); color: var(--chu); text-decoration: none; background: var(--kinh); font-size: 14px; }
.bang-bao { margin: 0; padding: 10px 14px; border-radius: 12px; background: rgba(255, 181, 71, .14); color: var(--phach); font-size: 14px; }
#man { display: grid; gap: 16px; outline: none; }
.the {
  position: relative; isolation: isolate; display: grid; gap: 14px; padding: 20px;
  background: var(--kinh); border: 1px solid var(--vien); border-radius: 16px;
  backdrop-filter: blur(18px) saturate(140%); -webkit-backdrop-filter: blur(18px) saturate(140%);
}
.the::before, .the::after { content: ""; position: absolute; border-radius: inherit; pointer-events: none; opacity: var(--glow, 0); transition: opacity .35s; }
.the::before { inset: 0; z-index: -1; background: radial-gradient(460px circle at var(--mx, 50%) var(--my, 50%), rgba(255, 160, 90, .12), transparent 45%); }
.the::after {
  inset: -1px; padding: 1px;
  background: radial-gradient(280px circle at var(--mx, 50%) var(--my, 50%), rgba(255, 181, 71, .8), transparent 60%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
}
h1, h2, h3 { margin: 0; font-family: var(--tieu-de); text-wrap: balance; }
h2 { font-size: 22px; line-height: 1.2; }
h3 { font-size: 17px; line-height: 1.3; }
p, ul { margin: 0; }
ul.phu { padding-left: 20px; display: grid; gap: 4px; }
.phu { color: var(--mo); font-size: 14px; }
.nhan-the { display: inline-block; padding: 2px 10px; border-radius: 999px; font: 600 12px var(--than-chu); letter-spacing: .04em; background: rgba(255, 181, 71, .16); color: var(--phach); vertical-align: middle; }
.so-lon { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 20px; }
.so-lon b { display: block; font: 700 28px/1.1 var(--tieu-de); font-variant-numeric: tabular-nums; }
.so-lon span { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--mo); }
.hang-nut { display: flex; flex-wrap: wrap; gap: 8px; }
.nut { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; min-width: 44px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--vien); background: var(--o); color: var(--chu); font: 500 15px var(--than-chu); text-decoration: none; cursor: pointer; text-align: center; }
.nut:hover { border-color: rgba(241, 238, 232, .3); }
.nut:disabled { opacity: .6; cursor: default; }
.nut-chinh { background: linear-gradient(100deg, var(--phach), var(--than)); color: #1C0F08; border: 0; font-weight: 600; }
.nut-lon { min-height: 64px; font-size: 18px; width: 100%; }
.nut-nguy { color: var(--nguy); border-color: rgba(255, 138, 122, .45); }
.nut[aria-pressed="true"] { background: var(--chu); color: var(--muc); }
:focus-visible { outline: 2px solid var(--phach); outline-offset: 2px; }
form { display: grid; gap: 12px; }
.o-nhap { display: grid; gap: 6px; font-size: 14px; color: var(--mo); }
input, select { width: 100%; min-height: 44px; font: inherit; color: var(--chu); background: var(--o); border: 1px solid var(--vien); border-radius: 10px; padding: 8px 12px; }
input[type="checkbox"], input[type="radio"] { width: 22px; height: 22px; min-height: 0; padding: 0; accent-color: var(--than); flex: none; }
.chon { display: flex; align-items: center; gap: 10px; min-height: 44px; color: var(--chu); cursor: pointer; }
.luoi-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
fieldset { border: 0; margin: 0; padding: 0; display: grid; gap: 4px; min-width: 0; }
legend { padding: 0; margin-bottom: 4px; color: var(--chu); }
.danh-sach { list-style: none; margin: 0; padding: 0; display: grid; }
.dong { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; padding-block: 10px; border-bottom: 1px solid var(--vien); overflow-wrap: anywhere; }
.dong:last-child { border-bottom: 0; }
.dong small { display: block; color: var(--nhat); font-size: 13px; }
.canh-bao { display: grid; gap: 8px; padding: 12px 14px; border-radius: 12px; background: rgba(255, 138, 122, .12); color: var(--chu); border: 1px solid rgba(255, 138, 122, .35); }
.loi { color: var(--nguy); font-size: 14px; }
.ma-lon { font: 700 28px/1.2 var(--tieu-de); letter-spacing: .08em; font-variant-numeric: tabular-nums; user-select: all; overflow-wrap: anywhere; }
.bieu-do { width: 100%; height: auto; max-width: 100%; }
.bieu-do .duong { fill: none; stroke: var(--phach); stroke-width: 2.5; }
.bieu-do .cham { fill: var(--mo); }
.bieu-do .truc { stroke: var(--vien); }
.bieu-do .nhan { fill: var(--mo); font-size: 11px; }
.an { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.thanh-tab {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: grid; grid-template-columns: repeat(4, 1fr);
  padding-bottom: env(safe-area-inset-bottom, 0px); background: rgba(11, 13, 18, .92); border-top: 1px solid var(--vien);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.thanh-tab a { display: flex; align-items: center; justify-content: center; min-height: var(--tab); color: var(--mo); text-decoration: none; font-size: 14px; }
.thanh-tab a[aria-current="page"] { color: var(--chu); font-weight: 600; box-shadow: inset 0 3px 0 var(--than); }
body[data-trang="tap"] .thanh-tab, body[data-trang="chao"] .thanh-tab { display: none; }
/* Màn Tập phủ kín viewport (.man-tap, z-index 10) nhưng nền chỉ 82% đục, nên header .dau (vẫn còn
   trong DOM, z-index 1) hiện mờ xuyên qua, chữ "Nhịp Tập" đè lên "Vòng X/Y · Bước Z/W" ở màn hẹp —
   soát cuối P4, mục Step 6. Header cũng không bấm được lúc này (bị overlay che), ẩn hẳn cho khỏi đè. */
body[data-trang="tap"] .dau { display: none; }
@media (min-width: 900px) {
  .thanh-tab { top: 0; right: auto; width: 200px; grid-template-columns: 1fr; align-content: start; padding-top: 88px; border-top: 0; border-right: 1px solid var(--vien); }
  .thanh-tab a { justify-content: flex-start; padding-inline: 24px; min-height: 52px; }
  .thanh-tab a[aria-current="page"] { box-shadow: inset 3px 0 0 var(--than); }
  .khung { margin-left: max(216px, calc((100vw - 720px) / 2)); padding-bottom: 32px; }
  body[data-trang="tap"] .khung, body[data-trang="chao"] .khung { margin-left: auto; }
}
/* Màn Tập. Canvas nằm tuyệt đối trong .tap-hinh (P3 Review Focus 3). */
.man-tap {
  position: fixed; inset: 0; z-index: 10; display: grid; grid-template-rows: auto minmax(38vh, 1fr) auto; gap: 8px;
  background: rgba(11, 13, 18, .82); overflow-y: auto;
  padding: calc(8px + env(safe-area-inset-top, 0px)) 16px calc(12px + env(safe-area-inset-bottom, 0px));
}
.tap-dau { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
/* CLAUDE.md mục 3: nút chính màn Tập (Xong hiệp đã có nut-lon; Tạm dừng) cao từ 64px — review cuối P4 I2. */
#tap-dung { min-height: 64px; }
.tap-hinh { position: relative; min-height: 38vh; }
.tap-hinh canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.tap-hinh .hinh-2d { position: absolute; inset: 0; }
.goc-nhin { position: absolute; right: 0; bottom: 0; display: flex; gap: 6px; }
/* Nút "?": danh sách "Dừng tập ngay khi" cũng ở màn Tập, không chỉ Trước khi tập (review cuối P4 I2).
   <details> thuần, không JS. Bảng hiện đè (absolute) ngay dưới nút, nền đục var(--muc), neo theo
   .tap-hoi (không theo cả .tap-dau) và co hẹp ở 390px nên không che đầu người minh hoạ hay đồng hồ. */
.tap-hoi { position: relative; }
.tap-hoi > summary { list-style: none; }
.tap-hoi > summary::-webkit-details-marker { display: none; }
.tap-hoi[open] > summary { background: var(--chu); color: var(--muc); }
.tap-hoi > p {
  position: absolute; z-index: 6; top: 100%; right: 0; margin: 6px 0 0;
  width: min(230px, 62vw); padding: 10px 12px; border-radius: 12px; font-size: 13px; text-align: left;
  background: var(--muc); border: 1px solid var(--vien); color: var(--chu);
}
.tap-than { display: grid; gap: 10px; max-width: 560px; width: 100%; margin: 0 auto; align-content: start; }
.dong-ho { font: 700 56px/1 var(--tieu-de); font-variant-numeric: tabular-nums; text-align: center; }
.dem { display: flex; align-items: center; justify-content: center; gap: 16px; }
.dem output { font: 700 40px/1 var(--tieu-de); min-width: 64px; text-align: center; font-variant-numeric: tabular-nums; }
.hinh-2d { display: grid; place-items: center; align-content: center; gap: 8px; text-align: center; overflow-y: auto; }
.hinh-2d svg { width: min(220px, 60vw); height: auto; }
.hinh-2d line { stroke: var(--chu); stroke-width: 6; stroke-linecap: round; }
.hinh-2d line.san { stroke: var(--nhat); stroke-width: 2; }
.hinh-2d circle { fill: var(--chu); }
@media (min-width: 900px) {
  .man-tap { grid-template-columns: minmax(0, 1fr) 420px; grid-template-rows: auto minmax(0, 1fr); }
  .tap-dau { grid-column: 1 / -1; }
  .tap-hinh { min-height: 0; }
  .tap-than { align-self: center; }
}
html[data-motion="off"] *, html[data-motion="off"] *::before, html[data-motion="off"] *::after { animation: none !important; transition: none !important; }
