/* Magic Time: giao diện "quyển sách phép" — đêm xanh đen, giấy da, vàng kim. Màu nhà đổi bằng [data-house]. */
:root {
  --night: #0a0d17; --night2: #121726; --line: #26304a;
  --gold: #d4a84b; --gold-hi: #f2d58b; --gold-lo: #8d6a22;
  --paper: #efe3c6; --paper2: #e5d4a9; --paper3: #f7efd9; --ink: #2a1d12; --ink2: #5a4630; --rule: #b9a273;
  --leather: #2b1712; --acc: #8e1f2f; --acc-ink: #fff;
  --good: #2f6b3c; --good-bg: #dbe9cf; --warn: #7a5200; --warn-bg: #f3e1b0; --bad: #8e1f2f; --bad-bg: #f0cfc8;
  --serif: 'EB Garamond', 'Times New Roman', serif; --display: 'Cormorant Garamond', 'EB Garamond', serif; --cinzel: 'Cinzel', 'Cormorant Garamond', serif; --ui: 'Be Vietnam Pro', system-ui, sans-serif;
  --btn-bg: var(--acc); --btn-fg: var(--acc-ink);
  color-scheme: dark;
}
:root[data-house='green'] { --acc: #1f6b4a; --gold: #c4ced6; --gold-hi: #eef2f5; --gold-lo: #7d8b96; }
:root[data-house='blue'] { --acc: #2b4f8f; --gold: #cf9a52; --gold-hi: #f0cf9c; --gold-lo: #8a5f25; }
:root[data-house='yellow'] { --acc: #7a5c00; --gold: #e6b832; --gold-hi: #fbe39a; --gold-lo: #98700b; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 4.5rem; }
body { margin: 0; background: var(--night); color: #e8e1d0; font-family: var(--serif); font-size: 18px; line-height: 1.55; min-height: 100vh; display: flex; flex-direction: column; }
main { flex: 1; outline: none; }
h1, h2, h3 { font-family: var(--display); line-height: 1.15; text-wrap: balance; margin: 0; }
p { margin: 0 0 .8em; text-wrap: pretty; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
img, svg { max-width: 100%; }
.ic { width: 1.1em; height: 1.1em; flex: none; vertical-align: -.16em; }
.vh { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 0; background: var(--gold); color: #1a1206; padding: .5rem 1rem; z-index: 100; font-family: var(--ui); }
.skip:focus { left: 8px; top: 8px; }
:focus-visible { outline: 3px solid var(--gold-hi); outline-offset: 2px; border-radius: 4px; }
.spread :focus-visible { outline-color: var(--acc); }
[hidden] { display: none !important; }
.muted { color: var(--ink2); }
.fine { font-size: .85rem; color: var(--ink2); font-style: italic; }

/* ---------- thanh đầu trang ---------- */
.top { position: fixed; z-index: 50; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 1rem; padding: .6rem max(1rem, env(safe-area-inset-right)) .6rem max(1rem, env(safe-area-inset-left)); font-family: var(--ui); font-size: .88rem; background: rgba(10, 13, 23, .92); border-bottom: 1px solid var(--line); }
[data-route='home'] .top { background: linear-gradient(#0a0d17ee, #0a0d1700); border-color: transparent; }
.brand { display: flex; align-items: center; gap: .5rem; color: var(--gold); text-decoration: none; font-family: var(--cinzel); font-weight: 700; letter-spacing: .12em; text-transform: uppercase; font-size: .95rem; white-space: nowrap; }
.top nav { display: flex; gap: .25rem; margin-left: auto; }
.top nav a { white-space: nowrap; text-decoration: none; padding: .4rem .7rem; border-radius: 999px; color: #d9d2c0; }
.top nav a:hover, .top nav a[aria-current] { background: #ffffff14; color: #fff; }
.top nav a.sos { background: var(--acc); color: #fff; font-weight: 600; }
.tools { display: flex; align-items: center; gap: .5rem; }
.pts { display: flex; align-items: center; gap: .25rem; color: var(--gold-hi); font-weight: 600; }
.tools select { background: var(--night2); border: 1px solid var(--line); color: #d9d2c0; border-radius: 8px; padding: .35rem .5rem; font: inherit; max-width: 9.5rem; }
.icon-btn { display: grid; place-items: center; min-width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: var(--night2); color: #d9d2c0; cursor: pointer; font-weight: 600; font-size: .78rem; }
.icon-btn:hover { border-color: var(--gold); color: var(--gold-hi); }

/* ---------- nút ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; padding: .6rem 1.1rem; border-radius: 10px; border: 1px solid transparent; background: var(--btn-bg); color: var(--btn-fg); font-family: var(--ui); font-weight: 600; font-size: .92rem; text-decoration: none; cursor: pointer; min-height: 44px; transition: transform .15s, filter .15s; }
.btn:hover { filter: brightness(1.12); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; }
.btn.ghost { background: transparent; color: inherit; border-color: currentColor; }
.btn.big { padding: .8rem 1.5rem; font-size: 1.02rem; }
.btn.danger { color: var(--bad); }
.btn.sos { --btn-bg: #b3322f; }

/* ---------- trang chủ ---------- */
.home { position: relative; min-height: 100svh; overflow: hidden; isolation: isolate; }
/* lớp tối nhẹ phía chữ để nến không đè lên tiêu đề */
.home::after { content: ''; position: absolute; inset: 0; z-index: -1; pointer-events: none; background: linear-gradient(90deg, #0a0d17e0 0%, #0a0d17a0 38%, #0a0d1700 64%); }
#scene { position: absolute; inset: 0; width: 100%; height: 100%; z-index: -1; display: block; }
.home-in { max-width: 1180px; margin: 0 auto; min-height: 100svh; display: grid; grid-template-columns: 1.1fr .9fr; align-items: center; gap: 2rem; padding: 6rem 1.25rem 3rem; }
.home .kick { color: var(--gold); font-family: var(--ui); font-size: .85rem; letter-spacing: .02em; margin-bottom: .8rem; }
.mega { font-size: clamp(3.4rem, 9vw, 7rem); font-weight: 700; color: #f6ecd2; letter-spacing: .01em; text-shadow: 0 2px 40px #d4a84b44; }
.mega em { font-style: italic; color: var(--gold); font-weight: 500; }
.lede { font-size: clamp(1.1rem, 2vw, 1.4rem); color: #d9d2c0; max-width: 34em; margin: 1rem 0 1.6rem; }
.cta { display: flex; flex-wrap: wrap; gap: .7rem; }
.home .btn { --btn-bg: var(--gold); --btn-fg: #1a1206; }
.home .btn.sos { --btn-bg: #b3322f; --btn-fg: #fff; }
.home .btn.ghost { color: #efe3c6; }
.meta { margin-top: 1.4rem; font-family: var(--ui); font-size: .8rem; color: #9aa2b6; }
.book-wrap { display: grid; place-items: center; min-height: 440px; }

/* quyển sách 3D bằng CSS */
.b3d { --bw: 250px; --bh: 350px; --bd: 54px; width: var(--bw); height: var(--bh); perspective: 1700px; position: relative; animation: bfloat 6s ease-in-out infinite; }
@keyframes bfloat { 0%, 100% { translate: 0 0; } 50% { translate: 0 -12px; } }
.b3d-rot { position: absolute; inset: 0; transform-style: preserve-3d; transform: rotateX(var(--rx, -9deg)) rotateY(var(--ry, -26deg)); transition: transform .9s cubic-bezier(.4, 0, .2, 1); }
.b3d.open .b3d-rot { transform: translateX(calc(var(--bw) / 2)) rotateX(-8deg) rotateY(-4deg); }
.face { position: absolute; }
.face.back { inset: 0; transform: translateZ(calc(var(--bd) / -2)); background: var(--leather); border-radius: 4px 8px 8px 4px; }
.face.pages { inset: 5px 6px 5px 4px; transform: translateZ(calc(var(--bd) / 2 - 5px)); background: repeating-linear-gradient(#e9dcc0 0 22px, #cdb98a 22px 23px), var(--paper); border-radius: 2px; }
.face.fore { top: 5px; height: calc(100% - 10px); width: calc(var(--bd) - 8px); left: calc(100% - var(--bd) / 2 - 2px); transform: rotateY(90deg); background: repeating-linear-gradient(90deg, #f4ebd2 0 2px, #cdbb8e 2px 3px); }
.face.top { left: 4px; width: calc(100% - 8px); height: calc(var(--bd) - 8px); top: calc(var(--bd) / -2 + 4px); transform: rotateX(90deg); background: repeating-linear-gradient(0deg, #f4ebd2 0 2px, #cdbb8e 2px 3px); }
.face.bot { left: 4px; width: calc(100% - 8px); height: calc(var(--bd) - 8px); bottom: calc(var(--bd) / -2 + 4px); transform: rotateX(-90deg); background: #cdbb8e; }
.face.spine { top: 0; height: 100%; width: var(--bd); left: calc(var(--bd) / -2); transform: rotateY(-90deg); background: linear-gradient(90deg, #1f0f0b, #3a1d16 50%, #1f0f0b); box-shadow: inset 0 0 0 2px #00000030; }
.face.spine::after { content: ''; position: absolute; inset: 12% 30%; border-top: 2px solid var(--gold); border-bottom: 2px solid var(--gold); opacity: .8; }
.cover { position: absolute; inset: 0; transform-origin: left center; transform-style: preserve-3d; transform: translateZ(calc(var(--bd) / 2)); transition: transform 1.1s cubic-bezier(.45, 0, .2, 1); }
.b3d.open .cover { transform: translateZ(calc(var(--bd) / 2)) rotateY(-172deg); }
.side { position: absolute; inset: 0; backface-visibility: hidden; border-radius: 4px 9px 9px 4px; }
.side.front { background: radial-gradient(120% 90% at 30% 15%, #4a2119, #2b1712 60%, #1b0e0b), var(--leather); box-shadow: inset 0 0 0 2px #00000040, inset 14px 0 18px -10px #000000a0, 0 20px 50px #000000aa; display: grid; place-items: center; }
.side.front::before { content: ''; position: absolute; inset: 14px; border: 1.5px solid var(--gold); border-radius: 3px; opacity: .85; box-shadow: inset 0 0 0 5px #2b1712, inset 0 0 0 6px #d4a84b66; }
.foil { position: relative; text-align: center; color: var(--gold); display: flex; flex-direction: column; align-items: center; gap: .35rem; padding: 0 1.4rem; }
.foil svg { filter: drop-shadow(0 0 8px #d4a84b66); }
.foil strong { font-family: var(--cinzel); font-size: 1.28rem; letter-spacing: .2em; font-weight: 700; margin-top: .5rem; text-shadow: 0 1px 0 #00000080; }
.foil span { font-family: var(--cinzel); font-size: .62rem; letter-spacing: .4em; }
.foil i { width: 54px; height: 1px; background: var(--gold); opacity: .7; margin: .4rem 0; }
.foil em { font-family: var(--display); font-size: 1rem; color: var(--gold-hi); }
.side.inner { transform: rotateY(180deg); background: linear-gradient(90deg, var(--paper), var(--paper2)); display: grid; place-items: center; box-shadow: inset 0 0 0 2px #00000020, inset -14px 0 18px -10px #00000050; border-radius: 9px 4px 4px 9px; }
.endpaper { padding: 1.6rem; color: var(--ink); text-align: center; font-family: var(--display); font-size: 1.25rem; font-style: italic; font-weight: 500; }

/* ---------- bàn đọc + trang sách ---------- */
.desk { max-width: 1240px; margin: 0 auto; padding: 5rem 1rem 2.5rem; }
.steps ol { list-style: none; display: flex; gap: .4rem; margin: 0 auto 1rem; padding: 0; max-width: 1180px; overflow-x: auto; scrollbar-width: none; }
.steps li { flex: 1 0 auto; }
.steps a { display: flex; align-items: center; gap: .5rem; padding: .5rem .85rem; border-radius: 999px; background: var(--night2); border: 1px solid var(--line); color: #bfc4d2; text-decoration: none; font-family: var(--ui); font-size: .82rem; white-space: nowrap; justify-content: center; }
.steps a b { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: #ffffff14; font-size: .75rem; }
.steps a.done b { background: var(--gold); color: #1a1206; }
.steps a[aria-current] { border-color: var(--gold); color: #fff; background: #1b2236; }
.steps a:hover { border-color: var(--gold-lo); }

.spread { color-scheme: light; position: relative; max-width: 1180px; margin: 0 auto; display: grid; grid-template-columns: 1fr 1fr; background: linear-gradient(90deg, var(--paper) 0%, var(--paper3) 47%, #cfbd90 50%, var(--paper3) 53%, var(--paper) 100%); color: var(--ink); border-radius: 10px; border: 12px solid var(--leather); box-shadow: 0 0 0 2px var(--gold-lo), 0 30px 80px #000000aa, inset 0 0 60px #8d6a2233; }
.spread.turn { animation: turn .65s cubic-bezier(.3, .7, .2, 1); transform-origin: left center; }
@keyframes turn { from { opacity: 0; transform: perspective(1800px) rotateY(-14deg) translateX(-14px); } to { opacity: 1; transform: none; } }
.page { padding: 2rem 2.25rem 2.25rem; min-width: 0; }
.page.left { padding-right: 2.6rem; }
.page.right { padding-left: 2.6rem; }
.ph { margin-bottom: 1.2rem; }
.kick { font-family: var(--ui); font-size: .78rem; letter-spacing: .06em; text-transform: uppercase; color: var(--acc); font-weight: 600; margin: 0 0 .35rem; }
.spread h1 { font-size: clamp(1.9rem, 3.2vw, 2.7rem); font-weight: 700; color: var(--ink); }
.spell { font-family: var(--cinzel); font-size: .78rem; letter-spacing: .22em; color: var(--gold-lo); margin: .5rem 0 0; text-transform: uppercase; }
.spread h3 { font-size: 1.35rem; margin: 1.1rem 0 .35rem; color: var(--ink); font-weight: 700; }
.spread ul, .spread ol { padding-left: 1.25rem; margin: 0 0 .9rem; }
.spread li { margin-bottom: .35rem; }
.lesson summary { cursor: pointer; font-family: var(--ui); font-size: .85rem; font-weight: 600; color: var(--acc); padding: .4rem 0; display: none; list-style: none; }
.lesson summary::-webkit-details-marker { display: none; }
.lesson .lbody { font-size: 1.05rem; }
.lead { font-size: 1.15rem; }
code { font-family: ui-monospace, Menlo, monospace; font-size: .85em; background: #00000012; padding: .1em .3em; border-radius: 4px; }
.note { font-style: italic; color: var(--ink2); }
.pager { display: flex; justify-content: space-between; gap: .75rem; max-width: 1180px; margin: 1rem auto 0; }
.pager .btn { --btn-bg: var(--gold); --btn-fg: #1a1206; }
.pager .btn.ghost { color: #d9d2c0; }

/* hướng dẫn từng bước ở trang trái */
.guide { margin-top: 1.4rem; padding: 1rem 1.1rem 1.1rem; background: #fffaf060; border: 1px solid var(--rule); border-left: 5px solid var(--acc); border-radius: 8px; }
.guide h3 { margin: 0 0 .6rem; font-size: 1.3rem; color: var(--acc); }
.guide ol { list-style: none; counter-reset: g; padding: 0 !important; margin: 0 !important; display: grid; gap: .55rem; }
.guide li { counter-increment: g; position: relative; padding-left: 2.1rem; margin: 0; font-size: 1rem; line-height: 1.45; }
.guide li::before { content: counter(g); position: absolute; left: 0; top: .08rem; width: 1.5rem; height: 1.5rem; border-radius: 50%; background: var(--acc); color: #fff; display: grid; place-items: center; font-family: var(--ui); font-size: .75rem; font-weight: 600; }

/* ---------- mục lục ---------- */
.part { font-family: var(--cinzel); font-size: .8rem; letter-spacing: .2em; text-transform: uppercase; color: var(--gold-lo); margin: 0 0 .6rem; font-weight: 600; }
.part:not(:first-child) { margin-top: 1.4rem; }
.toc-list { list-style: none; padding: 0 !important; margin: 0 0 .5rem !important; }
.toc-list li { margin: 0 0 .1rem; }
.toc-list a { display: flex; align-items: baseline; gap: .5rem; text-decoration: none; color: var(--ink); padding: .35rem .4rem; border-radius: 6px; font-family: var(--display); font-size: 1.3rem; font-weight: 700; }
.toc-list a:hover { background: #8d6a2222; }
.toc-list .no { width: 1.4rem; color: var(--acc); }
.toc-list .dots { flex: 1; border-bottom: 2px dotted var(--rule); transform: translateY(-4px); min-width: 1rem; }
.toc-list .st { width: 1.2rem; color: var(--good); }
.toc-list small { display: block; margin: -.15rem 0 .45rem 1.9rem; font-size: .92rem; color: var(--ink2); line-height: 1.3; }
.ring { display: flex; align-items: center; gap: 1rem; margin: 1.2rem 0; }
.ring svg circle { fill: none; stroke-width: 7; }
.ring .bgc { stroke: #b9a27355; } .ring .fgc { stroke: var(--acc); stroke-linecap: round; transition: stroke-dashoffset .8s; }
.ring b { font-size: 1.7rem; display: block; line-height: 1; }
.ring span { font-family: var(--ui); font-size: .8rem; color: var(--ink2); }
.nextdue { background: #00000010; border-left: 4px solid var(--gold-lo); padding: .7rem 1rem; border-radius: 4px; margin: 0 0 1rem; display: grid; gap: .1rem; }
.nextdue.hot { border-color: var(--bad); background: var(--bad-bg); }
.nextdue span { font-family: var(--ui); font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink2); }
.nextdue b { font-family: var(--display); font-size: 1.3rem; }
.nextdue em { font-family: var(--ui); font-style: normal; font-size: .85rem; }

/* ---------- biểu mẫu trên giấy ---------- */
.spread input, .spread select, .spread textarea { font-family: var(--ui); font-size: .92rem; background: #fffaf0b8; border: 1px solid var(--rule); border-radius: 8px; padding: .55rem .65rem; color: var(--ink); width: 100%; min-height: 42px; }
.spread input[type='checkbox'], .spread input[type='radio'] { width: auto; min-height: 0; accent-color: var(--acc); }
.spread input[type='range'] { padding: 0; accent-color: var(--acc); }
.spread textarea { resize: vertical; }
.spread ::placeholder { color: #8b7757; }
.field { margin-bottom: .9rem; display: grid; gap: .3rem; }
.field label, .pcfg label, .ome label { font-family: var(--ui); font-size: .82rem; font-weight: 600; color: var(--ink2); }
.empty { padding: 1.2rem; text-align: center; color: var(--ink2); border: 2px dashed var(--rule); border-radius: 10px; font-style: italic; }
.empty a { color: var(--acc); font-weight: 600; }
.empty.big { padding: 2rem 1.2rem; font-style: normal; }
.owl { font-size: 2.6rem; color: var(--gold-lo); } .owl .ic { width: 1em; height: 1em; }
.tog { font-family: var(--ui); font-size: .78rem; font-weight: 600; padding: .3rem .65rem; border-radius: 999px; border: 1px solid var(--rule); background: transparent; color: var(--ink2); cursor: pointer; min-height: 32px; }
.tog[aria-pressed='true'] { background: var(--acc); border-color: var(--acc); color: #fff; }
.tog:disabled { opacity: .5; cursor: not-allowed; }
.result { background: #00000010; border-radius: 10px; padding: 1rem 1.1rem; margin: 1rem 0; }
.result .big { font-family: var(--ui); font-weight: 600; font-size: 2.2rem; line-height: 1.1; color: var(--acc); }
.result .big small { display: block; font-family: var(--ui); font-size: .78rem; font-weight: 400; color: var(--ink2); margin-top: .3rem; }
.result dl { display: grid; gap: .3rem; margin: .8rem 0 0; font-family: var(--ui); font-size: .88rem; }
.result dl div { display: flex; justify-content: space-between; gap: 1rem; border-top: 1px dotted var(--rule); padding-top: .3rem; }
.result dt { color: var(--ink2); } .result dd { margin: 0; font-weight: 600; }
.warn { color: var(--warn); }
.banner { padding: .8rem 1rem; border-radius: 8px; margin: 0 0 .8rem; font-family: var(--ui); font-size: .88rem; line-height: 1.5; }
.banner.ok { background: var(--good-bg); color: #1f4a29; } .banner.warn { background: var(--warn-bg); color: #5c3d00; } .banner.bad { background: var(--bad-bg); color: #6c1626; }
.banner ul { margin: .4rem 0 .4rem; padding-left: 1.1rem !important; } .banner p { margin: .4rem 0 0; }
.banner a { font-weight: 600; }
.pact { display: flex; flex-wrap: wrap; gap: .6rem; margin: 1rem 0; }

/* Bước 1 */
.qa { display: grid; grid-template-columns: 1fr auto auto; gap: .5rem; margin-bottom: .8rem; }
.qa input[type='datetime-local'] { width: 12.5rem; }
.bulk { margin-bottom: 1rem; } .bulk summary { cursor: pointer; font-family: var(--ui); font-size: .82rem; color: var(--acc); font-weight: 600; margin-bottom: .4rem; } .bulk textarea { margin-bottom: .5rem; }
.sum { font-family: var(--ui); font-size: .85rem; color: var(--ink2); margin-bottom: .5rem; }
.tl { list-style: none; padding: 0 !important; margin: 0 !important; }
.trow { display: grid; grid-template-columns: auto 1fr auto; gap: .35rem .5rem; align-items: center; padding: .6rem 0; border-bottom: 1px solid #b9a27366; }
.trow.is-done .ttl { text-decoration: line-through; opacity: .6; }
.trow .chk { display: grid; place-items: center; }
.trow .chk input { width: 22px; height: 22px; }
.rmeta { grid-column: 2 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .5rem; }
.rmeta input[type='datetime-local'] { width: 12.6rem; }
.hh { display: flex; align-items: center; gap: .25rem; font-family: var(--ui); font-size: .8rem; } .hh input { width: 4.6rem; }
.trow .del { border: 0; background: transparent; color: var(--ink2); cursor: pointer; width: 38px; height: 38px; border-radius: 8px; } .trow .del:hover { background: var(--bad-bg); color: var(--bad); }
.when { margin-left: auto; font-family: var(--ui); font-size: .76rem; color: var(--ink2); } .when:empty { display: none; }
.trow .act { grid-column: 2 / -1; font-family: var(--ui); font-size: .76rem; color: var(--ink2); } .trow .act input { width: 5rem; display: inline-block; min-height: 32px; padding: .2rem .4rem; }
.donebox { margin-top: 1rem; } .donebox summary { cursor: pointer; font-family: var(--ui); font-size: .85rem; color: var(--ink2); }

/* Bước 2 */
.ome { display: grid; grid-template-columns: repeat(3, 1fr) auto; gap: .6rem; align-items: end; margin: .4rem 0 .6rem; }
.ome label { display: grid; gap: .25rem; } .ome label span { font-weight: 400; font-size: .72rem; }
.unit { font-family: var(--ui); font-size: .8rem; color: var(--ink2); padding-bottom: .7rem; }
.calib { font-family: var(--ui); font-size: .82rem; color: var(--ink2); margin: .8rem 0; }

/* Bước 3 */
.mx-cfg { font-family: var(--ui); font-size: .82rem; color: var(--ink2); margin: 0 0 .7rem; } .mx-cfg input { width: 4.6rem; display: inline-block; min-height: 34px; padding: .25rem .4rem; }
.next { display: grid; grid-template-columns: 1fr auto; gap: .1rem .8rem; align-items: center; background: var(--acc); color: #fff; border-radius: 10px; padding: .8rem 1rem; margin-bottom: .9rem; }
.next span { grid-column: 1; font-family: var(--ui); font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; opacity: .85; } .next b { grid-column: 1; font-family: var(--display); font-size: 1.35rem; line-height: 1.15; } .next .btn { grid-column: 2; grid-row: 1 / 3; --btn-bg: var(--gold); --btn-fg: #1a1206; }
.mx { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.q { border: 1px solid var(--rule); border-radius: 10px; padding: .6rem; min-height: 140px; background: #fffaf033; }
.q.over { outline: 3px dashed var(--acc); background: #fffaf080; }
.q h3 { margin: 0 0 .5rem; font-size: 1.05rem; } .q h3 small { display: block; font-family: var(--ui); font-weight: 400; font-size: .7rem; color: var(--ink2); }
.q1 { border-top: 4px solid #b3322f; } .q2 { border-top: 4px solid var(--good); } .q3 { border-top: 4px solid #c58a1b; } .q4 { border-top: 4px solid #8b8473; }
.qe { color: var(--ink2); font-style: italic; font-size: .9rem; margin: 0; }
.mcard { background: var(--paper3); border: 1px solid var(--rule); border-radius: 8px; padding: .5rem .6rem; margin-bottom: .45rem; cursor: grab; display: grid; gap: .25rem; box-shadow: 0 1px 0 #00000018; }
.mcard:active { cursor: grabbing; }
.mt { font-family: var(--display); font-size: 1.12rem; line-height: 1.2; } .md { font-family: var(--ui); font-size: .72rem; color: var(--ink2); } .mc { display: flex; gap: .3rem; flex-wrap: wrap; }
.mc .tog { padding: .15rem .55rem; min-height: 28px; }
.q4 .mt { }

/* Bước 4 */
.pcfg { display: grid; grid-template-columns: repeat(4, 1fr); gap: .6rem; margin-bottom: 1rem; align-items: end; }
.pcfg label { display: grid; gap: .25rem; } .pcfg .chkl { grid-column: 1 / -1; display: flex; align-items: center; gap: .5rem; font-weight: 400; }
.days { list-style: none; padding: 0 !important; margin: 0 !important; display: grid; gap: .6rem; }
.day { border: 1px solid var(--rule); border-radius: 10px; padding: .6rem .8rem; background: #fffaf040; }
.day.today { border-color: var(--acc); box-shadow: 0 0 0 2px #8e1f2f30; }
.dh { display: flex; justify-content: space-between; font-family: var(--ui); font-size: .85rem; } .dh span { color: var(--ink2); }
.bar { height: 6px; background: #b9a27355; border-radius: 3px; margin: .4rem 0 .5rem; overflow: hidden; } .bar i { display: block; height: 100%; background: var(--acc); border-radius: 3px; }
.day ul { list-style: none; margin: 0 !important; padding: 0 !important; } .day li { display: flex; justify-content: space-between; gap: .8rem; margin: 0; padding: .15rem 0; } .day li em { font-style: normal; font-family: var(--ui); font-size: .82rem; color: var(--ink2); white-space: nowrap; }

/* Bước 5 */
.fmodes { display: flex; gap: .5rem; margin-bottom: .9rem; } .fmodes .tog { flex: 1; font-size: .9rem; min-height: 40px; }
.ftask { margin-bottom: .6rem; display: grid; gap: .25rem; } .ftask label { font-family: var(--ui); font-size: .82rem; font-weight: 600; color: var(--ink2); }
.ring2 { position: relative; width: min(280px, 72vw); aspect-ratio: 1; margin: 1rem auto; }
.ring2 svg { width: 100%; height: 100%; } .ring2 circle { fill: none; stroke-width: 7; } .ring2 .bgc { stroke: #b9a27355; } .ring2 .fgc { stroke: var(--acc); stroke-linecap: round; transition: stroke-dashoffset .4s linear; }
.ftime { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
/* chữ số cổ điển của Cormorant trông như chữ cái (1 ~ I): dùng Cinzel cho số lớn */
.ftime b, .ring b, .toc-list .no, .sosl > li::before, .route a::before { font-family: var(--cinzel); font-weight: 600; font-variant-numeric: lining-nums tabular-nums; }
.ftime b { font-size: 3rem; font-variant-numeric: tabular-nums; line-height: 1; } .ftime span { font-family: var(--ui); font-size: .8rem; color: var(--ink2); }
.fbtn { display: flex; justify-content: center; gap: .7rem; flex-wrap: wrap; } .fstat { text-align: center; font-family: var(--ui); font-size: .82rem; color: var(--ink2); margin-top: .8rem; }
.frun .ring2 .fgc { stroke: var(--good); }
.tabs { display: flex; gap: .3rem; margin-bottom: 1rem; flex-wrap: wrap; border-bottom: 1px solid var(--rule); }
.tab { font-family: var(--ui); font-size: .85rem; font-weight: 600; background: transparent; border: 0; border-bottom: 3px solid transparent; padding: .55rem .8rem; cursor: pointer; color: var(--ink2); min-height: 44px; }
.tab[aria-selected='true'] { color: var(--acc); border-color: var(--acc); }
.pat { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: .8rem; }
.orbwrap { position: relative; display: grid; place-items: center; height: 240px; margin: .4rem 0; }
.orb { position: absolute; width: 200px; height: 200px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff1c2, var(--gold) 45%, var(--gold-lo)); box-shadow: 0 0 60px #d4a84b88, inset 0 0 30px #fff7; transform: scale(.62); opacity: .9; }
.orbtxt { position: relative; text-align: center; color: #2a1d12; display: grid; } .orbtxt b { font-family: var(--display); font-size: 1.5rem; } .orbtxt span { font-family: var(--ui); font-size: 1.8rem; font-weight: 600; }
.signs { list-style: none; padding: 0 !important; } .signs label { display: flex; gap: .6rem; align-items: flex-start; cursor: pointer; padding: .3rem 0; }
.mem { list-style: none; padding: 0 !important; display: grid; gap: .5rem; margin-top: 1rem !important; } .mem li { background: #00000010; border-radius: 8px; padding: .6rem .8rem; font-size: .98rem; }

/* SOS, chọn lối, SMART, đàn anh, quiz */
.sosl { list-style: none; counter-reset: s; padding: 0 !important; display: grid; gap: 1rem; } .sosl > li { counter-increment: s; position: relative; padding-left: 3rem; }
.sosl > li::before { content: counter(s); position: absolute; left: 0; top: .1rem; width: 2.2rem; height: 2.2rem; border-radius: 50%; background: var(--acc); color: #fff; display: grid; place-items: center; font-family: var(--display); font-weight: 700; font-size: 1.2rem; }
.sosl h3 { margin-top: 0; } .sosl input[type='text'] { margin-top: .4rem; }
fieldset { border: 0; padding: 0; margin: 0 0 1.1rem; min-width: 0; } legend { font-family: var(--display); font-weight: 700; font-size: 1.2rem; margin-bottom: .4rem; padding: 0; }
.opts { display: flex; flex-wrap: wrap; gap: .45rem; } .opt { cursor: pointer; } .opt input { position: absolute; opacity: 0; }
.opt span { display: block; font-family: var(--ui); font-size: .86rem; padding: .5rem .85rem; border-radius: 999px; border: 1px solid var(--rule); background: #fffaf050; } .opt input:checked + span { background: var(--acc); border-color: var(--acc); color: #fff; } .opt input:focus-visible + span { outline: 3px solid var(--acc); outline-offset: 2px; }
.route { list-style: none; padding: 0 !important; counter-reset: r; display: grid; gap: .6rem; } .route li { counter-increment: r; }
.route a { display: block; position: relative; padding: .8rem 1rem .8rem 3.2rem; border: 1px solid var(--rule); border-radius: 10px; text-decoration: none; background: #fffaf050; } .route a:hover { border-color: var(--acc); background: #fffaf0a0; }
.route a::before { content: counter(r); position: absolute; left: .9rem; top: .7rem; width: 1.8rem; height: 1.8rem; border-radius: 50%; background: var(--acc); color: #fff; display: grid; place-items: center; font-family: var(--display); font-weight: 700; }
.route b { display: block; font-family: var(--display); font-size: 1.25rem; } .route span { font-size: .95rem; color: var(--ink2); }
.sm2 { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.iq li { margin-bottom: .55rem; }
.senior { border: 1px solid var(--rule); border-radius: 10px; padding: 1rem; margin-bottom: .8rem; } .senior header { display: flex; justify-content: space-between; gap: 1rem; font-family: var(--ui); font-size: .82rem; } .senior blockquote { margin: .6rem 0; font-family: var(--display); font-size: 1.25rem; font-style: italic; border-left: 3px solid var(--gold-lo); padding-left: .8rem; }
.team { font-family: var(--display); font-size: 1.15rem; font-weight: 600; } .refs { font-size: .92rem; } .refs a { color: var(--acc); }
.qprog { font-family: var(--ui); font-size: .78rem; color: var(--ink2); margin: 0 0 .4rem; } .qq { margin: 0 0 .9rem !important; font-size: 1.4rem !important; }
.qo { display: grid; gap: .5rem; margin-bottom: .9rem; }
.qopt { text-align: left; font-family: var(--ui); font-size: .92rem; padding: .7rem .9rem; border-radius: 10px; border: 1px solid var(--rule); background: #fffaf050; cursor: pointer; min-height: 44px; }
.qopt:hover:not(:disabled) { border-color: var(--acc); } .qopt.right { background: var(--good-bg); border-color: var(--good); color: #1f4a29; } .qopt.wrong { background: var(--bad-bg); border-color: var(--bad); color: #6c1626; } .qopt:disabled { cursor: default; }

/* ---------- Góc nhạc (YouTube): full = thẻ đầy đủ, mini = ô video 200×200 vẫn phát, closed = ẩn (đã dừng) ----------
   KHÔNG đè nội dung: từ 700px thẻ là CỘT NHỎ ở góc trái trên (nội dung dịch sang phải theo --bgm-w); điện thoại thì là THANH dưới đáy (nội dung có thêm đệm đáy). */
:root { --bgm-w: 0px; --bgm-h: 0px; }
.icon-btn.on { border-color: var(--gold); color: var(--gold-hi); box-shadow: 0 0 12px #d4a84b66; }
.home .btn.music { --btn-bg: transparent; --btn-fg: var(--gold-hi); border-color: var(--gold); }
.bgm { position: fixed; z-index: 70; font-family: var(--ui); }
.bgm.closed { display: none; }
.bgm-card { background: #121726; border: 1px solid var(--gold-lo); border-radius: 14px; padding: 10px; color: #e8e1d0; box-shadow: 0 18px 50px #000000b0; }
.bgm-head { display: flex; justify-content: space-between; align-items: center; margin: 0 2px 8px; font-size: .8rem; letter-spacing: .08em; text-transform: uppercase; color: var(--gold); }
.bgm-hb { display: flex; gap: .3rem; }
.bgm-ib { display: inline-grid; place-items: center; flex: none; width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: #1b2236; color: #d9d2c0; cursor: pointer; padding: 0; }
.bgm-ib:hover { border-color: var(--gold); color: #fff; } .bgm-ib.big { background: var(--gold); border-color: var(--gold); color: #1a1206; width: 40px; height: 40px; }
.bgm.full .mini-only { display: none; }
.bgm.mini .bgm-head, .bgm.mini .bgm-hint, .bgm.mini .bgm-c, .bgm.mini .bgm-yt { display: none; }
.bgm.mini #bgmMute { display: none; } .bgm.mini .bgm-ctl { flex-wrap: nowrap; } .bgm.mini .bgm-ib { width: 34px; height: 34px; } .bgm.mini .bgm-ib.big { width: 38px; height: 38px; }
.bgm-stage { position: relative; width: 100%; height: 200px; border-radius: 10px; overflow: hidden; background: #000; }
.bgm-stage iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; pointer-events: none; }
.bgm-stage.loading::after { content: ''; position: absolute; left: 50%; top: 50%; width: 30px; height: 30px; margin: -15px; border: 3px solid #ffffff44; border-top-color: var(--gold); border-radius: 50%; animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.bgm-sound { margin: 6px 2px 0; font-size: .74rem; color: var(--gold-hi); line-height: 1.35; text-align: center; }
.bgm-hint { margin: 8px 2px 0; font-size: .76rem; color: #b9b3a2; line-height: 1.4; }
.bgm-t { margin: 6px 2px 0; font-weight: 600; font-size: .84rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .bgm-c { margin: 2px 2px 0; font-size: .7rem; color: #9aa2b6; line-height: 1.4; }
.bgm-ctl { display: flex; align-items: center; gap: .35rem; margin-top: 8px; flex-wrap: wrap; }
.bgm-vol { display: flex; align-items: center; flex: 1; min-width: 56px; } .bgm-vol input { width: 100%; accent-color: var(--gold); }
.bgm-yt { font-size: .72rem; color: var(--gold-hi); width: 100%; }
.bgm-msg { margin: .6rem 2px 0; padding: .5rem .7rem; border-radius: 8px; background: #3a1d1a; color: #f6d8d0; font-size: .78rem; } .bgm-msg a { color: var(--gold-hi); }

/* màn từ 700px: thẻ nhỏ ở GÓC TRÁI TRÊN, ngay dưới thanh đầu; nội dung dịch sang phải bằng đúng bề rộng cột (--bgm-w) nên không bị đè */
@media (min-width: 700px) {
  .bgm { top: 70px; left: 10px; }
  .bgm-card { width: 216px; padding: 6px; max-height: calc(100vh - 80px); overflow-y: auto; }
  .bgm.full .bgm-card { width: 300px; padding: 8px; }
  html.bgm-open { --bgm-w: 236px; } html.bgm-full { --bgm-w: 320px; }
  html.bgm-open .desk { margin-left: max(var(--bgm-w), calc((100% - 1240px) / 2)); }
  html.bgm-open .home { padding-left: var(--bgm-w); }
  html.bgm-open .foot { padding-left: calc(1.25rem + var(--bgm-w)); }
}
/* điện thoại: thanh dưới đáy (video bên trái, nút bên phải); nội dung có đệm đáy để cuộn lên trên thanh nhạc */
@media (max-width: 699px) {
  .bgm { left: 0; right: 0; bottom: 0; }
  .bgm-card { width: 100%; border-radius: 14px 14px 0 0; border-bottom: 0; display: grid; grid-template-columns: 204px minmax(0, 1fr); column-gap: 12px; align-content: start; padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); max-height: 60vh; overflow-y: auto; }
  .bgm-head { grid-column: 1 / -1; grid-row: 1; }
  .bgm-stage { grid-column: 1; grid-row: 2 / span 7; width: 204px; }
  .bgm-card > :not(.bgm-head):not(.bgm-stage) { grid-column: 2; margin-top: 0; }
  .bgm-card > .bgm-ctl { margin-top: 8px; }
  html.bgm-open { --bgm-h: 232px; } html.bgm-full { --bgm-h: 330px; }
  html.bgm-open body { padding-bottom: calc(var(--bgm-h) + env(safe-area-inset-bottom)); }
}
@media (max-width: 420px) { .bgm-card { grid-template-columns: 204px minmax(0, 1fr); column-gap: 8px; padding-left: 8px; padding-right: 8px; } .bgm.mini .bgm-ctl { flex-wrap: wrap; } }

/* ---------- chân trang, thông báo ---------- */
.foot { padding: 1.4rem 1.25rem 2rem; font-family: var(--ui); font-size: .72rem; color: #8a92a8; text-align: center; border-top: 1px solid #ffffff0d; }
.foot p { max-width: 62rem; margin: 0 auto; }
.toast { position: fixed; left: 50%; bottom: 1.2rem; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; background: #1b2236; color: var(--gold-hi); border: 1px solid var(--gold-lo); padding: .6rem 1rem; border-radius: 999px; font-family: var(--ui); font-size: .85rem; z-index: 90; transition: .25s; max-width: 92vw; text-align: center; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- màn hình hẹp ---------- */
@media (max-width: 900px) {
  body { font-size: 17px; }
  .home-in { grid-template-columns: 1fr; padding-top: 5.5rem; gap: 1rem; text-align: left; }
  .book-wrap { order: -1; min-height: 340px; } .b3d { --bw: 190px; --bh: 268px; --bd: 42px; }
  .spread { grid-template-columns: 1fr; background: var(--paper); border-width: 8px; }
  .page, .page.left, .page.right { padding: 1.3rem 1.1rem; }
  .page.left { border-bottom: 1px solid var(--rule); }
  .lesson summary { display: block; }
  .tools select { display: none; } .top nav a { padding: .35rem .5rem; } .brand span { display: none; }
  .desk { padding-top: 4.4rem; }
}
@media (max-width: 560px) {
  .top { gap: .5rem; padding-left: .7rem; padding-right: .7rem; } .top nav a { font-size: .8rem; } .pts { display: none; } .tools { gap: .35rem; }
  .qa { grid-template-columns: 1fr auto; } .qa input[type='datetime-local'] { grid-column: 1 / -1; order: 3; width: 100%; }
  .rmeta input[type='datetime-local'] { width: 100%; }
  .mx { grid-template-columns: 1fr; } .pcfg { grid-template-columns: 1fr 1fr; } .sm2 { grid-template-columns: 1fr; } .ome { grid-template-columns: repeat(3, 1fr); } .unit { display: none; }
  .next { grid-template-columns: 1fr; } .next .btn { grid-column: 1; grid-row: auto; margin-top: .5rem; }
  .pager .btn { flex: 1; font-size: .82rem; padding: .5rem .6rem; } .steps a span { display: none; } .steps a { padding: .4rem .6rem; } .steps ol { justify-content: center; }
  .mega { font-size: 3.4rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
@media print {
  body { background: #fff; color: #000; font-size: 12pt; } .top, .foot, .steps, .pager, .toast, .page.left, .pcfg, .pact, .skip { display: none !important; }
  .desk { padding: 0; } .spread { display: block; border: 0; box-shadow: none; background: #fff; color: #000; } .page.right { padding: 0; }
  .day { break-inside: avoid; border-color: #888; } .bar i { background: #444; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
