/* ===== Tokens (theme mặc định "tuoi-sang"; phase 3 ghi đè theo [data-theme]) ===== */
:root {
  --bg: #FBF6EA; --surface: #FFFDF7; --ink: #1E2B22; --muted: #4A5A4E; --accent: #3F7D3A; --on-accent: #FFFFFF;
  --accent-2: #E8B04B; --accent-3: #F3C6C2; --line: #D9CFB8; --frame: #FFFFFF; --shadow: 0 18px 40px -18px rgba(30,43,34,.45);
  --font-display: "Playfair Display", Georgia, "Times New Roman", serif;
  --font-body: "Be Vietnam Pro", "Segoe UI", Arial, sans-serif;
  --font-accent: "Playfair Display", Georgia, serif;
  --display-weight: 800; --radius: 14px; --bg-pattern: none;
  --pad: clamp(16px, 4vw, 56px);
  --book-cover:#2F5F2B; --book-spine:#244A21; --book-paper:#FFFDF7; --book-edge:#EDE5CF; --book-edge-line:#CFC4A6; --book-shadow:0 30px 60px -25px rgba(30,43,34,.55);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--mh, 84px) + 12px); }
body {
  margin: 0; background-color: var(--bg); background-image: var(--bg-pattern); color: var(--ink);
  font-family: var(--font-body); line-height: 1.6; font-size: 1rem; -webkit-text-size-adjust: 100%;
}
body.reader-open { overflow: hidden; }
img { max-width: 100%; height: auto; display: block; user-select: none; -webkit-user-select: none; -webkit-user-drag: none; -webkit-touch-callout: none; }
h1, h2, h3, p, ol, ul, blockquote, figure { margin: 0; padding: 0; }
ol, ul { list-style: none; }
a { color: inherit; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
#decor { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
main, .masthead, .site-foot { position: relative; z-index: 1; }
.shield { position: absolute; inset: 0; z-index: 2; }

.skip { position: absolute; left: 12px; top: -60px; background: var(--accent); color: var(--on-accent); padding: 10px 16px; border-radius: 8px; z-index: 100; text-decoration: none; }
.skip:focus { top: 12px; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5em; text-decoration: none;
  padding: .7em 1.4em; border-radius: 999px; border: 2px solid var(--accent); font-weight: 700; font-size: .95rem;
  letter-spacing: .02em; transition: transform .2s ease, background-color .2s ease, color .2s ease; white-space: nowrap;
}
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-outline { background: transparent; color: var(--accent); }
.btn:hover { transform: translateY(-2px); }
.btn-outline:hover { background: var(--accent); color: var(--on-accent); }

/* ===== Masthead ===== */
.masthead {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: clamp(12px, 2vw, 28px);
  padding: 10px var(--pad); background: var(--surface); border-bottom: 1px solid var(--line);
}
@supports (background: color-mix(in srgb, red, blue)) {
  .masthead { background: color-mix(in srgb, var(--surface) 92%, transparent); }
}
@supports (backdrop-filter: blur(8px)) or (-webkit-backdrop-filter: blur(8px)) {
  .masthead { -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--accent); flex: none; }
.brand-name { display: flex; flex-direction: column; font-family: var(--font-display); font-weight: var(--display-weight); font-size: 1.05rem; line-height: 1.1; color: var(--ink); }
.brand-name small { font-family: var(--font-body); font-weight: 500; font-size: .68rem; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); margin-top: 3px; }
.toc-nav { flex: 1; min-width: 0; }
.toc-nav ul { display: flex; gap: clamp(10px, 1.6vw, 24px); justify-content: center; }
.toc-nav a {
  display: block; padding: 6px 2px; text-decoration: none; font-size: .82rem; font-weight: 500; color: var(--muted);
  border-bottom: 2px solid transparent; transition: color .2s, border-color .2s; white-space: nowrap;
}
.toc-nav a:hover { color: var(--accent); border-bottom-color: var(--accent); }
#theme-switcher { flex: none; }
.masthead .btn { padding: .5em 1.1em; font-size: .85rem; flex: none; }

@media (max-width: 719px) {
  .masthead { flex-wrap: wrap; row-gap: 4px; padding-bottom: 4px; }
  .brand { margin-right: auto; }
  .toc-nav { order: 5; flex: 0 0 100%; overflow-x: auto; white-space: nowrap; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .toc-nav::-webkit-scrollbar { display: none; }
  .toc-nav ul { justify-content: flex-start; width: max-content; }
  .brand-name { font-size: .95rem; }
}
@media (min-width: 720px) and (max-width: 1099px) { .toc-nav a { font-size: .74rem; } }

/* ===== Hero ===== */
.hero {
  display: grid; gap: clamp(28px, 5vw, 72px); align-items: center;
  padding: clamp(32px, 6vw, 88px) var(--pad) clamp(48px, 7vw, 110px); max-width: 1400px; margin: 0 auto;
}
@media (min-width: 900px) { .hero { grid-template-columns: 1.1fr .9fr; } }
.kicker { font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .18em; color: var(--accent); margin-bottom: 1.2rem; }
.hero-title {
  font-family: var(--font-display); font-weight: var(--display-weight); font-size: clamp(2.6rem, 8vw, 6.5rem);
  line-height: .95; letter-spacing: -.02em; text-wrap: balance;
}
.hero-title .w { display: inline-block; }
.hero-title .em { font-style: italic; color: var(--accent); font-family: var(--font-accent); }
.hero-leaf { display: block; width: min(320px, 70%); height: 40px; margin: 1.1rem 0 1.4rem; color: var(--accent); overflow: visible; }
.hero-leaf path { fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.hero-leaf .leaf { fill: var(--accent-2); stroke: var(--accent-2); }
.hero-sub { font-family: var(--font-display); font-style: italic; font-size: clamp(1.05rem, 2vw, 1.35rem); color: var(--muted); }
.hero-quote {
  margin-top: 1.8rem; padding: .2rem 0 .2rem 1.2rem; border-left: 4px solid var(--accent-2); max-width: 36rem;
  font-family: var(--font-accent); font-size: clamp(1rem, 1.6vw, 1.15rem); color: var(--ink); line-height: 1.55;
}
.hero-cta { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 2rem; }

.hero-art { position: relative; justify-self: center; width: min(100%, 440px); padding: 12px 0 28px; }
.frame { position: relative; margin: 0; background: var(--frame); padding: 6px; border-radius: var(--radius); box-shadow: var(--shadow); }
.frame img { border-radius: calc(var(--radius) - 6px); width: 100%; }


/* ===== Sách lật trang ===== */
.book-closed { display: block; margin: 0 auto; width: min(78%, 360px); border: 0; background: none; padding: 0; perspective: 1600px; color: var(--muted); }
.book-closed[hidden], .book-flip[hidden] { display: none; }
.bc-3d { position: relative; display: block; transform: rotateY(-20deg) rotateX(5deg); transform-style: preserve-3d; border-radius: 2px 8px 8px 2px; box-shadow: var(--book-shadow), 14px 10px 24px -14px rgba(0,0,0,.35); }
.bc-cover { width: 100%; height: auto; border-radius: 2px 8px 8px 2px; position: relative; z-index: 1; }
.bc-spine {
  position: absolute; z-index: 1; left: 0; top: 0; bottom: 0; width: 7%; border-radius: 2px 0 0 2px; pointer-events: none;
  background: linear-gradient(90deg, var(--book-spine) 0%, rgba(0,0,0,.28) 22%, rgba(255,255,255,.18) 45%, rgba(0,0,0,.2) 70%, transparent 100%);
}
.bc-edge {
  position: absolute; z-index: 0; top: 6px; right: -10px; bottom: -8px; left: 8px; border-radius: 0 8px 8px 2px;
  background:
    repeating-linear-gradient(90deg, var(--book-edge) 0 2px, var(--book-edge-line) 2px 3px),
    var(--book-edge);
  box-shadow: inset 0 -3px 4px -2px rgba(0,0,0,.25);
}
.bc-edge::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 8px; border-radius: 0 0 8px 2px;
  background: repeating-linear-gradient(0deg, var(--book-edge) 0 2px, var(--book-edge-line) 2px 3px); opacity: .9; }
.bc-hint { display: block; margin-top: 22px; text-align: center; font-size: .85rem; letter-spacing: .06em; color: var(--muted); }
.book-closed:hover .bc-3d, .book-closed:focus-visible .bc-3d { transform: rotateY(-8deg) translateY(-4px); }
@media (prefers-reduced-motion: no-preference) {
  .bc-3d { transition: transform .5s cubic-bezier(.2,.8,.2,1); }
  .book-closed:not(:hover):not(:focus-visible) .bc-3d { animation: bk-breathe 5s ease-in-out 1.6s infinite; }
}
@keyframes bk-breathe { 0%,100% { transform: rotateY(-20deg) rotateX(5deg); } 50% { transform: rotateY(-17deg) rotateX(4deg) translateY(-3px); } }

.hero.is-open { grid-template-columns: 1fr; }
.hero.is-open .hero-art { width: 100%; max-width: 1400px; }
.book-stage { position: relative; margin: 0 auto; }
.hero.is-open .book-stage { width: min(100%, calc((100vh - var(--mh, 84px) - 130px) * 1.4136)); width: min(100%, calc((100svh - var(--mh, 84px) - 130px) * 1.4136)); }
@media (max-width: 760px) {
  .hero.is-open .book-stage { width: min(100%, calc((100vh - var(--mh, 84px) - 130px) * .7068)); width: min(100%, calc((100svh - var(--mh, 84px) - 130px) * .7068)); }
}
.book-flip { min-width: 0 !important; filter: drop-shadow(0 28px 28px rgba(30,43,34,.28)); }
.book-flip.is-hidden { visibility: hidden; }
.bk-page { background: var(--book-paper); overflow: hidden; }
.bk-page img { width: 100%; height: 100%; object-fit: cover; border-radius: 0; }
/* bóng gáy sách nhẹ trên mỗi trang */
.bk-page::after { content: ""; position: absolute; top: 0; bottom: 0; width: 9%; pointer-events: none; z-index: 1; }
.bk-page:nth-child(odd)::after { left: 0; background: linear-gradient(90deg, rgba(0,0,0,.18), transparent); }
.bk-page:nth-child(even)::after { right: 0; background: linear-gradient(270deg, rgba(0,0,0,.14), transparent); }
.book-flip:focus-visible { outline-offset: 6px; }

.book-anim { position: absolute; inset: 0; perspective: 2000px; pointer-events: none; }
.book-anim[hidden] { display: none; }
.ba-under, .ba-cover { position: absolute; }
.ba-under img, .ba-front img, .ba-back img { width: 100%; height: 100%; object-fit: cover; }
.ba-under::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(0,0,0,.2), transparent 14%); }
.ba-cover { transform-origin: left center; transform-style: preserve-3d; box-shadow: 0 10px 30px -10px rgba(0,0,0,.45); }
.ba-front, .ba-back { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; overflow: hidden; }
.ba-back { transform: rotateY(180deg); background: var(--book-paper); }
.ba-front::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(0,0,0,.28), rgba(255,255,255,.12) 6%, transparent 18%); }
@media (prefers-reduced-motion: no-preference) {
  .ba-cover { transition: transform .9s cubic-bezier(.3,.1,.2,1), opacity .25s linear .65s; }
}
.ba-cover.is-open { transform: rotateY(-180deg); }
.ba-cover.is-portrait.is-open { opacity: 0; }

.book-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px; margin-top: 14px; }
.book-bar[hidden] { display: none; }
.book-bar button { width: 44px; height: 44px; border-radius: 50%; border: 1.5px solid currentColor; background: transparent; color: var(--ink); font-size: 1.4rem; line-height: 1; display: grid; place-items: center; padding: 0; }
.book-bar button:disabled { opacity: .4; cursor: default; }
.book-bar button:not(:disabled):hover { background: var(--ink); color: var(--bg); }
#bk-count { font-family: var(--font-display); font-weight: 700; color: var(--ink); min-width: 9.5em; text-align: center; }
#bk-section { height: 40px; padding: 0 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; color: var(--ink); font: inherit; font-size: .9rem; max-width: 100%; }
html.book-grab .book-flip { cursor: grab; }
html.book-grabbing .book-flip { cursor: grabbing; }
@media (prefers-reduced-motion: reduce) { .bc-3d, .ba-cover { transition: none; animation: none; } }

/* ===== Mục lục ===== */
.toc { max-width: 1400px; margin: 0 auto; padding: clamp(24px, 5vw, 64px) var(--pad) clamp(40px, 6vw, 80px); border-top: 1px solid var(--line); }
.section-title { font-family: var(--font-display); font-weight: var(--display-weight); font-size: clamp(2rem, 5vw, 3.4rem); line-height: 1; margin-bottom: clamp(20px, 3vw, 40px); }
#toc-list { display: grid; gap: 0 clamp(20px, 4vw, 56px); grid-template-columns: 1fr; }
@media (min-width: 640px) { #toc-list { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1100px) { #toc-list { grid-template-columns: repeat(3, 1fr); } }
#toc-list li { border-top: 1px solid var(--line); }
#toc-list a { display: grid; grid-template-columns: auto 1fr; gap: 0 18px; align-items: start; padding: 22px 0 26px; text-decoration: none; transition: transform .25s ease; }
#toc-list a:hover { transform: translateX(6px); }
.toc-range {
  grid-row: span 2; font-family: var(--font-display); font-weight: var(--display-weight); font-size: clamp(2.5rem, 6vw, 4.5rem); line-height: .9;
  color: transparent; -webkit-text-stroke: 1.5px var(--accent); white-space: nowrap; letter-spacing: -.02em;
}
#toc-list a:hover .toc-range { color: var(--accent); }
.toc-title { font-family: var(--font-display); font-weight: 700; font-size: 1.2rem; line-height: 1.2; align-self: end; }
.toc-desc { grid-column: 2; font-size: .88rem; color: var(--muted); margin-top: 6px; }
@media (min-width: 640px) and (max-width: 1099px) { .toc-range { font-size: clamp(2.2rem, 5vw, 3.2rem); } }

/* ===== Chapter / Gallery ===== */
.chapter { max-width: 1400px; margin: 0 auto; padding: clamp(36px, 6vw, 88px) var(--pad); border-top: 1px solid var(--line); }
.chapter-head { display: grid; gap: 4px 28px; margin-bottom: clamp(24px, 4vw, 48px); align-items: end; }
@media (min-width: 800px) { .chapter-head { grid-template-columns: auto 1fr; } .chapter-desc { grid-column: 2; } }
.chapter-range {
  grid-row: span 2; font-family: var(--font-display); font-weight: var(--display-weight); font-size: clamp(3rem, 9vw, 7rem); line-height: .85;
  color: transparent; -webkit-text-stroke: 1.5px var(--accent); letter-spacing: -.03em;
}
.chapter-title { font-family: var(--font-display); font-weight: var(--display-weight); font-size: clamp(1.6rem, 3.6vw, 2.6rem); line-height: 1.05; }
.chapter-desc { color: var(--muted); max-width: 40rem; }
.chapter-grid { display: grid; gap: clamp(12px, 2vw, 28px); grid-template-columns: repeat(auto-fill, minmax(min(150px, 100%), 1fr)); }
@media (min-width: 900px) { .chapter-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); } }
.card { display: block; width: 100%; border: 0; background: none; padding: 0; text-align: left; transition: transform .3s cubic-bezier(.2,.8,.2,1); }
.card:hover, .card:focus-visible { transform: translateY(-6px) rotate(-.6deg); }
.card .frame { transition: box-shadow .3s ease; }
.card:hover .frame { box-shadow: 0 26px 46px -18px rgba(30,43,34,.55); }
.card figcaption, .card .cap { display: flex; flex-direction: column; gap: 2px; padding: 12px 4px 0; }
.pno { font-size: .68rem; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; color: var(--accent); }
.card strong { font-family: var(--font-display); font-weight: 700; font-size: 1rem; line-height: 1.25; }
.card figcaption span:last-child { font-size: .8rem; color: var(--muted); line-height: 1.4; }

/* ===== Footer ===== */
.site-foot { text-align: center; padding: clamp(36px, 6vw, 72px) var(--pad); border-top: 1px solid var(--line); background: var(--surface); color: var(--muted); }
.foot-main { font-family: var(--font-display); font-weight: var(--display-weight); font-size: 1.4rem; color: var(--ink); }
.foot-small { font-size: .78rem; margin-top: 1rem; }
.noscript-list { padding: 24px var(--pad); position: relative; z-index: 1; }
.noscript-list ul { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

/* ===== Reader ===== */
#reader {
  position: fixed; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; padding: 0; border: 0;
  background: var(--ink); color: var(--bg); overflow: hidden; z-index: 50;
}
#reader[open] { display: flex; flex-direction: column; }
#reader::backdrop { background: var(--ink); }
.rd-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px clamp(12px, 3vw, 28px); flex: none; }
.rd-meta { display: flex; align-items: baseline; gap: 6px 14px; flex-wrap: wrap; min-width: 0; font-size: .85rem; }
#rd-count { font-family: var(--font-display); font-weight: var(--display-weight); font-size: 1.3rem; color: color-mix(in srgb, var(--accent-2) 30%, var(--bg)); }
#rd-section { opacity: .7; letter-spacing: .08em; text-transform: uppercase; font-size: .7rem; }
#rd-title { font-weight: 500; }
.rd-tools { display: flex; gap: 8px; flex: none; }
.rd-tools button, .rd-prev, .rd-next {
  width: 44px; height: 44px; border-radius: 50%; border: 1.5px solid currentColor; background: transparent; color: var(--bg);
  font-size: 1.5rem; line-height: 1; display: grid; place-items: center; padding: 0; transition: background-color .2s, color .2s;
}
.rd-tools button:hover, .rd-prev:hover, .rd-next:hover { background: var(--bg); color: var(--ink); }
.rd-stage { position: relative; flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; touch-action: none; overflow: hidden; padding: 0 56px; }
.rd-page { position: relative; height: 100%; max-width: 100%; display: flex; align-items: center; justify-content: center; will-change: transform; }
.rd-page img { max-height: 100%; width: auto; max-width: 100%; object-fit: contain; border-radius: 4px; box-shadow: 0 20px 60px rgba(0,0,0,.5); transform-origin: center; touch-action: none; }
.rd-prev, .rd-next { position: absolute; top: 50%; margin-top: -22px; z-index: 5; }
.rd-prev { left: 8px; } .rd-next { right: 8px; }
.rd-strip { flex: none; display: flex; gap: 6px; overflow-x: auto; padding: 10px clamp(12px, 3vw, 28px); scrollbar-width: thin; justify-content: safe center; }
.rd-strip button { flex: none; width: 36px; height: 51px; padding: 0; border: 2px solid transparent; border-radius: 4px; background: var(--muted); overflow: hidden; opacity: .65; position: relative; }
.rd-strip button img { width: 100%; height: 100%; object-fit: cover; border-radius: 0; }
.rd-strip button[aria-current="true"] { border-color: var(--accent-2); opacity: 1; }
@media (max-width: 719px) {
  .rd-stage { padding: 0 8px; }
  .rd-prev, .rd-next { top: auto; bottom: 8px; margin: 0; width: 40px; height: 40px; background: rgba(0,0,0,.35); }
  .rd-strip button { width: 30px; height: 42px; }
}

/* ===== Chuyển động (chỉ khi người dùng không tắt) ===== */
@media (prefers-reduced-motion: no-preference) {
  .hero-title .w { animation: rise .8s cubic-bezier(.2,.8,.2,1) both; animation-delay: calc(var(--i) * 120ms + 80ms); }
  .hero-leaf .stem { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 1.4s ease-out .7s forwards; }
  .hero-leaf .leaf { opacity: 0; animation: fade .5s ease 1.9s forwards; }
  .kicker, .hero-sub, .hero-quote, .hero-cta { animation: fade .9s ease both; animation-delay: .9s; }
  .hero-art { animation: rise .9s cubic-bezier(.2,.8,.2,1) .3s both; }
  .js .reveal { opacity: 0; transform: translateY(28px); transition: opacity .7s ease, transform .7s cubic-bezier(.2,.8,.2,1); }
  .js .reveal.is-in { opacity: 1; transform: none; }
  html { scroll-behavior: smooth; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } .btn, .card, #toc-list a { transition: none; } }
@keyframes rise { from { opacity: 0; transform: translateY(.5em); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes draw { to { stroke-dashoffset: 0; } }

/* ===== Phase 3: switcher, watermark, guard, in ấn ===== */
#theme-switcher { display: flex; align-items: center; gap: 10px; }
.ts-group { display: flex; gap: 2px; }
.ts-dot { width: 40px; height: 40px; padding: 0; border: 0; background: none; border-radius: 50%; display: grid; place-items: center; }
.ts-chip { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--line); box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s ease, box-shadow .2s ease; }
.ts-dot:hover .ts-chip { transform: scale(1.12); }
.ts-dot[aria-checked="true"] .ts-chip { border-color: var(--ink); box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--accent); }
.ts-name { font-size: .78rem; font-weight: 600; color: var(--muted); white-space: nowrap; }
@media (max-width: 719px) { .ts-name { display: none; } .ts-dot { width: 40px; height: 40px; } #theme-switcher { margin-left: auto; } .brand { margin-right: 0; } }
@media (min-width: 720px) and (max-width: 1099px) { .ts-name { display: none; } }

#wm { position: fixed; inset: 0; z-index: 60; pointer-events: none; background-image: var(--wm-dark); background-size: 340px 220px; }
[data-theme="bang-phan"] #wm { background-image: var(--wm-light); }
.rd-stage::after { content: ""; position: absolute; inset: 0; z-index: 4; pointer-events: none; background-image: var(--wm-light); background-size: 340px 220px; }

#guard { position: fixed; inset: 0; z-index: 2147483000; background: color-mix(in srgb, var(--bg) 96%, transparent); background: var(--bg); display: grid; place-items: center; text-align: center; padding: 24px; color: var(--ink); }
#guard[hidden] { display: none; }
.guard-box { max-width: 28rem; display: grid; gap: 16px; justify-items: center; color: var(--accent); }
.guard-box p { font-family: var(--font-display); font-size: 1.4rem; line-height: 1.3; color: var(--ink); }
html.guarded main, html.guarded .masthead, html.guarded .site-foot, html.guarded #reader { filter: blur(18px); }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); z-index: 2147482000; max-width: calc(100vw - 32px); padding: 12px 20px; border-radius: 999px; background: var(--ink); color: var(--bg); font-size: .9rem; box-shadow: 0 10px 30px rgba(0,0,0,.35); opacity: 0; pointer-events: none; transition: opacity .25s ease, transform .25s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

#print-note { display: none; }
@media print {
  body > *:not(#print-note) { display: none !important; }
  #print-note { display: block !important; padding: 40px; font: 18px/1.5 Georgia, serif; color: #000; }
}
@media (min-width: 720px) and (max-width: 1599px) { .ts-name { display: none; } }
.toc-nav { overflow-x: auto; scrollbar-width: none; }
.toc-nav::-webkit-scrollbar { display: none; }
.toc-nav ul { width: max-content; margin: 0 auto; }

/* Nút âm thanh */
#bk-sound[aria-pressed="false"] .snd-on, #bk-sound[aria-pressed="true"] .snd-off { display: none; }
.book-bar #bk-sound[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }

/* Con trỏ tuỳ biến (chỉ khi html.cur-on) */
#cursor{position:fixed;left:0;top:0;width:0;height:0;z-index:2147482500;pointer-events:none}
#cursor[hidden]{display:none}
.cur-icon{position:absolute;left:0;top:0;width:32px;height:32px;will-change:transform;transition:opacity .15s}
.cur-icon svg{display:block;transform-origin:2px 2px;transition:transform .15s}
#cursor.is-link .cur-icon svg{transform:scale(1.18)}
#cursor.is-native .cur-icon,#cursor.is-out .cur-icon{opacity:0}
.cur-p{position:absolute;left:-3px;top:-3px;width:6px;height:6px;border-radius:50%;background:var(--accent);opacity:0;will-change:transform,opacity}
html.cur-on,html.cur-on *{cursor:none!important}
html.cur-on input,html.cur-on select,html.cur-on textarea,html.cur-on [contenteditable]{cursor:auto!important}
html.cur-on.book-grab .book-flip,html.cur-on.book-grab .book-flip *{cursor:grab!important}
html.cur-on.book-grabbing,html.cur-on.book-grabbing *{cursor:grabbing!important}
@media (prefers-reduced-motion: reduce){#cursor{display:none!important}}

/* Trang đang lật (đường cong + bóng) có thể vượt mép màn hình -> cắt phần thừa, không sinh thanh cuộn ngang.
   clip (không phải hidden) để không tạo vùng cuộn, giữ sticky header. */
html, body { overflow-x: clip; }
