/* =====================================================================
   HỆ THỐNG THIẾT KẾ — một thang thống nhất cho màu, khoảng cách, bo góc, đổ bóng, cỡ chữ.
   Theme đặt trên <html data-theme="light|sepia|dark|oled">; không có data-theme = theo hệ thống.
   Tương phản (WCAG AA ≥ 4.5:1) đã kiểm cho text / muted / accent trên bg, panel, accent-soft ở cả 4 theme
   (ngoại lệ đã tránh: không đặt chữ --muted trên --accent-soft).
   ===================================================================== */
:root {
  color-scheme: light;
  /* Thương hiệu NovelHub (theo logo) */
  --brand-ink: #14123d; --brand-900: #41238a; --brand-700: #5b1fb0; --brand-600: #6d14c4; --brand-500: #8111df;
  --brand-400: #a26af2; --brand-300: #b78bff; --brand-100: #ece0ff; --brand-50: #f6f0ff;
  /* Màu theo theme (sáng). --accent = nền nút/viền nhấn; --accent-text = chữ/link nhấn; --focus = viền focus */
  --bg: #faf8ff; --panel: #ffffff; --text: #14123d; --muted: #5b5878; --line: #e6dffa;
  --accent: var(--brand-600); --accent-ink: #ffffff; --accent-text: var(--brand-600); --accent-soft: var(--brand-100);
  --focus: var(--brand-400);
  --ok: #16a34a; --done: var(--brand-600);
  /* Khoảng cách: 4 / 8 / 12 / 16 / 24 / 32 / 48 / 64 px */
  --s-1: .25rem; --s-2: .5rem; --s-3: .75rem; --s-4: 1rem; --s-5: 1.5rem; --s-6: 2rem; --s-7: 3rem; --s-8: 4rem;
  /* Bo góc: 8 / 12 / 16 (+ thẻ truyện 14, viên thuốc) */
  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 16px; --r-card: 14px; --r-pill: 999px;
  /* Đổ bóng 3 mức (pha màu mực thương hiệu, không dùng đen thuần) */
  --sh-1: 0 1px 2px rgb(20 18 61 / .06), 0 1px 3px rgb(20 18 61 / .06);
  --sh-2: 0 8px 24px -8px rgb(20 18 61 / .18);
  --sh-3: 0 20px 48px -12px rgb(20 18 61 / .3);
  /* Cỡ chữ: 12 / 14 / 16 / 18 / 20 / 24 / 32 / 40 px; tiêu đề đậm vừa, giãn chữ nhẹ */
  --fs-xs: .75rem; --fs-sm: .875rem; --fs-md: 1rem; --fs-lg: 1.125rem; --fs-xl: 1.25rem; --fs-2xl: 1.5rem; --fs-3xl: 2rem; --fs-4xl: 2.5rem;
  --lh-tight: 1.25; --lh-base: 1.6; --fw-head: 650; --ls-head: -.012em;
  /* Bố cục + chuyển động */
  --wrap: 1200px; --gutter: 16px; --hd-h: 64px; --side-w: 20rem; --dur: .2s; --ease: cubic-bezier(.2, .7, .2, 1);
  --rs: clamp(1.125rem, 1.0147rem + .368vw, 1.25rem); /* cỡ chữ đọc mặc định: 18px (≤480px) → ~19px (768px) → 20px (≥1024px) */
  --read-font: var(--serif);
  /* Font CJK theo ngôn ngữ (mặc định giản thể); các ngôn ngữ khác ghi đè bên dưới */
  --cjk-sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "Source Han Sans SC";
  --cjk-serif: "Songti SC", "STSong", "Noto Serif CJK SC", "Source Han Serif SC", "SimSun";
}
:lang(zh-Hant) {
  --cjk-sans: "PingFang TC", "Microsoft JhengHei", "Noto Sans CJK TC", "Source Han Sans TC";
  --cjk-serif: "Songti TC", "Noto Serif CJK TC", "Source Han Serif TC", "PMingLiU", "MingLiU";
}
:lang(ja) {
  --cjk-sans: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", "Noto Sans CJK JP", "Source Han Sans JP";
  --cjk-serif: "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", "Noto Serif CJK JP", "Source Han Serif JP", "MS PMincho";
}
:lang(ko) {
  --cjk-sans: "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans CJK KR", "Noto Sans KR", "Source Han Sans KR";
  --cjk-serif: "AppleMyungjo", "Noto Serif CJK KR", "Noto Serif KR", "Source Han Serif KR", "Batang";
}
/* Khai báo lại trên mọi phần tử có lang để font CJK đúng cả trong đoạn chen ngôn ngữ khác (vd. menu ngôn ngữ) */
:root, [lang] {
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", var(--cjk-sans), sans-serif;
  --serif: Georgia, "Noto Serif", "Times New Roman", var(--cjk-serif), serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", "Noto Sans Mono", var(--cjk-sans), monospace;
}
/* Giấy: giữ nền ấm, nhấn brand-600 (viền focus brand-600 vì brand-400 trên nền giấy < 3:1) */
html[data-theme="sepia"] {
  --bg: #f4ecd8; --panel: #fbf5e4; --text: #3b2f1e; --muted: #6f5f45; --line: #e2d5b5;
  --accent: var(--brand-600); --accent-ink: #ffffff; --accent-text: var(--brand-600); --accent-soft: #e9dbe8; --focus: var(--brand-600);
}
/* Tối: link brand-300, nút chính nền brand-500 chữ trắng */
html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #14102a; --panel: #1d1838; --text: #f1ecff; --muted: #b4acd8; --line: #322b58;
  --accent: var(--brand-500); --accent-ink: #ffffff; --accent-text: var(--brand-300); --accent-soft: #2a2150; --focus: var(--brand-400);
  --ok: #4ade80; --done: var(--brand-300); --sh-1: 0 1px 2px rgb(0 0 0 / .45); --sh-2: 0 6px 18px rgb(0 0 0 / .5);
}
/* Đen OLED: nền #000, nhấn brand-300 */
html[data-theme="oled"] {
  color-scheme: dark;
  --bg: #000000; --panel: #0f0c1f; --text: #ece6ff; --muted: #aaa3cc; --line: #262040;
  --accent: var(--brand-500); --accent-ink: #ffffff; --accent-text: var(--brand-300); --accent-soft: #1a1433; --focus: var(--brand-400);
  --ok: #4ade80; --done: var(--brand-300); --sh-1: none; --sh-2: 0 0 0 1px #262040;
}
@media (prefers-color-scheme: dark) {
  html:not([data-theme]) {
    color-scheme: dark;
    --bg: #14102a; --panel: #1d1838; --text: #f1ecff; --muted: #b4acd8; --line: #322b58;
    --accent: var(--brand-500); --accent-ink: #ffffff; --accent-text: var(--brand-300); --accent-soft: #2a2150; --focus: var(--brand-400);
    --ok: #4ade80; --done: var(--brand-300); --sh-1: 0 1px 2px rgb(0 0 0 / .45); --sh-2: 0 6px 18px rgb(0 0 0 / .5);
  }
}
html[data-font="sans"] { --read-font: var(--sans); }
html[data-font="mono"] { --read-font: var(--mono); }

@media (min-width: 768px) { :root { --gutter: 24px; } }
@media (max-width: 640px) { :root { --fs-3xl: 1.5rem; --fs-4xl: 2rem; } }

/* ===== Nền tảng ===== */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--hd-h) + var(--s-4)); }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--sans); font-size: var(--fs-md); line-height: var(--lh-base); display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; overflow-x: clip; }
main { flex: 1 0 auto; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: .15em; }
h1, h2, h3 { line-height: var(--lh-tight); font-weight: var(--fw-head); letter-spacing: var(--ls-head); text-wrap: balance; }
img { max-width: 100%; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--r-sm); }
.wrap { width: 100%; max-width: calc(var(--wrap) + 2 * var(--gutter)); margin: 0 auto; padding-left: max(var(--gutter), env(safe-area-inset-left)); padding-right: max(var(--gutter), env(safe-area-inset-right)); }
.site-main { padding-top: var(--s-5); padding-bottom: var(--s-8); }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
html:not(.js) .js-only { display: none !important; }
.skip { position: absolute; left: var(--s-3); top: -3rem; z-index: 60; padding: var(--s-2) var(--s-4); border-radius: var(--r-md); background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.skip:focus { top: var(--s-2); text-decoration: none; }
svg { flex: none; }
.meta { color: var(--muted); font-size: var(--fs-sm); margin: 0; }
.h { font-size: var(--fs-xl); margin: var(--s-5) 0 var(--s-3); }
.empty { color: var(--muted); padding: var(--s-6) 0; }
.muted-s { margin: var(--s-2) 0; color: var(--muted); font-size: var(--fs-sm); }

/* ===== Thành phần ===== */
/* Nút */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: 2.75rem; padding: 0 var(--s-5); border: 1px solid var(--accent); border-radius: var(--r-md);
  background: var(--accent); color: var(--accent-ink); font: inherit; font-weight: 600; font-size: var(--fs-sm); line-height: 1.2; text-align: center; white-space: nowrap; cursor: pointer;
  transition: background-color var(--dur), border-color var(--dur), color var(--dur), box-shadow var(--dur), transform var(--dur);
}
.btn:hover { text-decoration: none; background: color-mix(in srgb, var(--accent) 88%, #000); border-color: color-mix(in srgb, var(--accent) 88%, #000); }
.btn:active { transform: translateY(1px); }
.btn-primary { box-shadow: 0 6px 16px -6px color-mix(in srgb, var(--accent) 70%, transparent); }
.btn.ghost, .btn-ghost { background: var(--panel); border-color: var(--line); color: var(--text); box-shadow: none; }
.btn.ghost:hover, .btn-ghost:hover { background: var(--panel); border-color: var(--accent); color: var(--accent-text); }
.btn-outline { background: transparent; border-color: var(--accent); color: var(--accent-text); box-shadow: none; }
.btn-outline:hover { background: var(--accent-soft); border-color: var(--accent); }
.btn-lg { min-height: 3rem; padding: 0 var(--s-6); font-size: var(--fs-md); border-radius: var(--r-md); }
.btn.danger { background: #b91c1c; border-color: #b91c1c; color: #fff; }
.btn.is-disabled { opacity: .45; pointer-events: none; }
.icon-btn {
  display: inline-grid; place-items: center; min-width: 2.5rem; height: 2.5rem; padding: 0; border: 0; border-radius: var(--r-md);
  background: none; color: var(--text); font: inherit; cursor: pointer; transition: background-color var(--dur), color var(--dur), border-color var(--dur);
}
.icon-btn:hover { background: var(--accent-soft); color: var(--accent-text); }
.icon-btn.bordered { border: 1px solid var(--line); background: var(--panel); }
.icon-btn.round { width: 3rem; min-width: 3rem; height: 3rem; border: 1px solid var(--line); border-radius: 50%; background: var(--panel); }
.icon-btn.round[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); }
.icon-btn.round[aria-pressed="true"] svg { fill: currentColor; }
.icon-btn svg, .big-search svg, .empty-ic, .nv-meta svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn svg { width: 1.25rem; height: 1.25rem; }
.link-btn { padding: var(--s-1) 0; border: 0; background: none; color: var(--accent-text); font: inherit; font-weight: 600; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
/* Ô nhập */
.input {
  width: 100%; min-height: 2.75rem; padding: 0 var(--s-3); border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--panel); color: var(--text); font: inherit; font-size: var(--fs-sm);
}
textarea.input { padding: var(--s-3); }
.input::placeholder { color: var(--muted); opacity: 1; }
.input:focus { outline: 2px solid var(--focus); outline-offset: 0; border-color: transparent; }
/* Chip */
.chips { display: flex; gap: var(--s-2); margin: 0; padding: 0; list-style: none; }
.chips-wrap { flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; min-height: 2.25rem; padding: 0 var(--s-4); border: 1px solid var(--line); border-radius: var(--r-pill);
  background: var(--panel); color: var(--text); font-size: var(--fs-sm); white-space: nowrap; transition: border-color var(--dur), color var(--dur);
}
.chip:hover { text-decoration: none; border-color: var(--accent); color: var(--accent-text); }
.chip[aria-current] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.chip-sm { min-height: 2rem; padding: 0 var(--s-3); font-size: var(--fs-xs); }
/* Trạng thái truyện: chữ + chấm màu trang trí */
.status { display: inline-flex; align-items: center; gap: var(--s-2); white-space: nowrap; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 22%, transparent); }
.status-completed::before { background: var(--done); box-shadow: 0 0 0 3px color-mix(in srgb, var(--done) 22%, transparent); }
/* Huy hiệu nhỏ */
.badges { display: inline-flex; gap: var(--s-1); vertical-align: middle; }
.badge-s { display: inline-grid; place-items: center; height: 18px; padding: 0 6px; border-radius: 6px; font-size: 10px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; line-height: 1; color: #fff; box-shadow: 0 1px 2px rgb(0 0 0 / .2); }
.b-hot { background: #c2410c; }
.b-full { background: #15803d; }
.b-new { background: var(--brand-500); }
/* Bìa: luôn là ảnh (ảnh tải lên hoặc SVG riêng của truyện), tỉ lệ 2:3 */
.cover { position: relative; display: block; aspect-ratio: 2 / 3; overflow: hidden; border-radius: var(--r-sm); background: linear-gradient(150deg, var(--brand-400), var(--brand-900)); box-shadow: var(--sh-1); }
.cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cover-xs { width: 48px; height: 72px; aspect-ratio: auto; flex: none; border-radius: 6px; }
/* Sao nhỏ */
.stars-s { display: inline-flex; align-items: center; gap: 2px; color: #b45309; font-weight: 700; }
html[data-theme="dark"] .stars-s, html[data-theme="oled"] .stars-s { color: #fbbf24; }
@media (prefers-color-scheme: dark) { html:not([data-theme]) .stars-s { color: #fbbf24; } }
/* Thẻ truyện: cả thẻ bấm được (link kéo giãn); lưới cột cố định nên 1 thẻ không giãn to */
.grid, .grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--s-6) var(--s-4); }
@media (max-width: 480px) { .grid, .grid-auto { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: var(--s-5) var(--s-3); } }
.card { position: relative; display: flex; flex-direction: column; min-width: 0; max-width: 220px; }
.card-cover { position: relative; margin-bottom: var(--s-3); border-radius: var(--r-card); transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease); box-shadow: var(--sh-1); }
.card-cover .cover { border-radius: var(--r-card); box-shadow: none; }
.card:hover .card-cover { transform: translateY(-4px); box-shadow: var(--sh-3); }
.card-cover .badges { position: absolute; left: var(--s-2); top: var(--s-2); z-index: 2; }
.card-title { margin: 0 0 var(--s-1); font-size: var(--fs-sm); font-weight: 650; line-height: 1.4; letter-spacing: 0; min-height: 2.8em; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-link { color: var(--text); }
.card-link::after { content: ""; position: absolute; inset: 0; border-radius: var(--r-card); }
.card-link:hover { text-decoration: none; }
.card:hover .card-link { color: var(--accent-text); }
.card-link:focus-visible { outline: none; }
.card-link:focus-visible::after { outline: 2px solid var(--focus); outline-offset: 4px; }
.card-author { margin: 0; min-height: 1.5em; color: var(--muted); font-size: var(--fs-xs); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-meta { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); margin: var(--s-1) 0 0; color: var(--muted); font-size: var(--fs-xs); }
/* Khối, panel */
.sec { margin-bottom: var(--s-7); }
.sec-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-3); flex-wrap: wrap; margin-bottom: var(--s-4); }
.sec-title { margin: 0 0 var(--s-4); font-size: var(--fs-xl); }
.sec-head .sec-title { margin: 0; }
.sec-title.sm { margin-top: var(--s-6); font-size: var(--fs-lg); }
.count { display: inline-grid; place-items: center; min-width: 1.75em; height: 1.5em; margin-left: var(--s-1); padding: 0 .45em; border-radius: var(--r-pill); background: var(--accent-soft); color: var(--text); font-size: .7em; font-weight: 600; vertical-align: middle; }
.more { flex: none; font-size: var(--fs-sm); font-weight: 600; white-space: nowrap; }
.panel { padding: var(--s-5); border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--panel); box-shadow: var(--sh-1); }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-4); }
.panel-title { margin: 0; min-width: 0; font-size: var(--fs-lg); }
.panel-sub { margin-left: var(--s-2); color: var(--muted); font-size: var(--fs-xs); font-weight: 600; letter-spacing: 0; text-transform: uppercase; }
/* Trạng thái rỗng / lỗi */
.empty-state { display: grid; justify-items: center; gap: var(--s-2); padding: var(--s-7) var(--s-4); text-align: center; border: 1px dashed var(--line); border-radius: var(--r-lg); background: var(--panel); }
.empty-ic { width: 3.5rem; height: 3.5rem; color: var(--accent-text); stroke-width: 2.5; }
.empty-title { margin: var(--s-2) 0 0; font-size: var(--fs-lg); color: var(--text); }
.empty-hint { margin: 0; max-width: 34rem; color: var(--muted); }

/* ===== Header: cao 64px, nền kính mờ, bóng nhẹ khi cuộn ===== */
.site-header {
  position: sticky; top: 0; z-index: 30; border-bottom: 1px solid transparent;
  background: var(--bg); background: color-mix(in srgb, var(--bg) 78%, transparent);
  -webkit-backdrop-filter: saturate(1.6) blur(16px); backdrop-filter: saturate(1.6) blur(16px);
  transition: box-shadow var(--dur), border-color var(--dur), background-color var(--dur);
}
.site-header.is-scrolled { border-bottom-color: var(--line); box-shadow: 0 8px 24px -16px rgb(20 18 61 / .35); }
.hd { position: relative; display: flex; align-items: center; gap: var(--s-2); height: var(--hd-h); }
.hd-menu { display: none; }
.brand { display: inline-flex; flex: none; align-items: center; line-height: 0; }
.brand:hover { text-decoration: none; }
.hd-nav { margin-left: var(--s-4); margin-right: auto; min-width: 0; }
.hd-nav > ul { display: flex; align-items: center; gap: var(--s-1); margin: 0; padding: 0; list-style: none; }
.hd-nav summary, .nav-link {
  display: inline-flex; align-items: center; gap: var(--s-1); height: 2.5rem; padding: 0 var(--s-3); border-radius: var(--r-md);
  color: var(--text); font-weight: 600; font-size: var(--fs-sm); white-space: nowrap; cursor: pointer; list-style: none;
}
.hd-nav summary::-webkit-details-marker { display: none; }
.hd-nav summary:hover, .nav-link:hover, .mega[open] summary { background: var(--accent-soft); color: var(--accent-text); text-decoration: none; }
.nav-link[aria-current] { color: var(--accent-text); }
.chev { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; transition: transform var(--dur); }
.mega { position: relative; }
.mega[open] .chev, .lang-pick[open] .chev { transform: rotate(180deg); }
.mega-panel { position: absolute; left: 0; top: calc(100% + var(--s-2)); z-index: 40; width: min(40rem, 90vw); padding: var(--s-3); border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--panel); box-shadow: var(--sh-3); }
.mega-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 2px var(--s-2); margin: 0; padding: 0; list-style: none; }
.mega-grid a { display: block; padding: var(--s-2) var(--s-3); border-radius: var(--r-sm); color: var(--text); font-size: var(--fs-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mega-grid a:hover { background: var(--accent-soft); color: var(--accent-text); text-decoration: none; }
/* Ô tìm + gợi ý */
.hd-search { position: relative; display: flex; align-items: center; margin-left: auto; }
.hd-search input {
  width: 14rem; height: 2.5rem; padding: 0 2.75rem 0 var(--s-4); border: 1px solid var(--line); border-radius: var(--r-pill);
  background: var(--panel); color: var(--text); font: inherit; font-size: var(--fs-sm); transition: width var(--dur) var(--ease), border-color var(--dur);
}
.hd-search input::placeholder { color: var(--muted); opacity: 1; }
.hd-search input:focus { width: 20rem; outline: 2px solid var(--focus); outline-offset: 0; border-color: transparent; }
.hd-search .icon-btn { position: absolute; right: 0; }
.hd-search .icon-btn:hover { background: none; }
.sugg { position: absolute; right: 0; top: calc(100% + var(--s-2)); z-index: 45; width: min(24rem, 92vw); max-height: 70vh; overflow: auto; margin: 0; padding: var(--s-1); list-style: none; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--panel); box-shadow: var(--sh-3); }
.sugg a { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-2); border-radius: var(--r-sm); color: var(--text); }
.sugg a:hover, .sugg [aria-selected="true"] > a { background: var(--accent-soft); text-decoration: none; }
.sg-cover { position: relative; flex: none; display: grid; place-items: center; width: 32px; height: 48px; overflow: hidden; border-radius: 4px; background: linear-gradient(150deg, var(--brand-400), var(--brand-900)); color: #fff; font-family: var(--serif); font-weight: 700; }
.sg-cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.sg-t { display: flex; flex-direction: column; min-width: 0; font-weight: 600; font-size: var(--fs-sm); }
.sg-t small { color: var(--muted); font-weight: 400; font-size: var(--fs-xs); }
.sg-all a { justify-content: center; color: var(--accent-text); font-size: var(--fs-sm); font-weight: 600; }
/* Chọn ngôn ngữ: không bao giờ xuống dòng; màn hẹp chỉ hiện mã ngắn (VI/EN/中/繁…) */
.lang-pick { position: relative; flex: none; }
.lang-sum { display: inline-flex; gap: var(--s-1); padding: 0 var(--s-2); list-style: none; user-select: none; white-space: nowrap; }
.lang-sum::-webkit-details-marker { display: none; }
/* Luôn ghi TÊN ĐẦY ĐỦ ngôn ngữ (không dùng mã); nút co giãn theo tên, không xuống dòng */
.lang-sum { width: auto; }
.lang-name { font-size: var(--fs-sm); font-weight: 600; white-space: nowrap; }
.lang-panel { position: absolute; right: 0; top: calc(100% + var(--s-2)); z-index: 40; width: max-content; min-width: 12rem; max-width: calc(100vw - 2 * var(--gutter)); padding: var(--s-2); border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--panel); box-shadow: var(--sh-3); }
.lang-filter { height: 2.5rem; min-height: 0; margin-bottom: var(--s-1); }
.lang-list { margin: 0; padding: 0; list-style: none; max-height: min(22rem, 60vh); overflow: auto; }
.lang-list a { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); height: 2.5rem; padding: 0 var(--s-3); border-radius: var(--r-sm); color: var(--text); font-family: var(--sans); white-space: nowrap; }
.lang-list a:hover { background: var(--accent-soft); text-decoration: none; }
.lang-list a[aria-current] { background: var(--accent-soft); font-weight: 650; }
.lang-check { width: 16px; height: 16px; flex: none; fill: none; stroke: var(--accent-text); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.ic-sun { display: none; }
html[data-theme="dark"] .ic-sun, html[data-theme="oled"] .ic-sun { display: block; }
html[data-theme="dark"] .ic-moon, html[data-theme="oled"] .ic-moon { display: none; }
@media (prefers-color-scheme: dark) { html:not([data-theme]) .ic-sun { display: block; } html:not([data-theme]) .ic-moon { display: none; } }
/* Menu ngôn ngữ trong thanh trang đọc */
.langmenu { position: relative; }
.langmenu summary { list-style: none; cursor: pointer; padding: var(--s-2) var(--s-3); border: 1px solid var(--line); border-radius: var(--r-md); white-space: nowrap; user-select: none; }
.langmenu summary::-webkit-details-marker { display: none; }
.langmenu ul { position: absolute; right: 0; top: calc(100% + var(--s-2)); z-index: 30; margin: 0; padding: var(--s-1); list-style: none; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-md); min-width: 11rem; box-shadow: var(--sh-3); }
.langmenu li a { font-family: var(--sans); display: block; padding: var(--s-2) var(--s-3); border-radius: var(--r-sm); color: var(--text); white-space: nowrap; }
.langmenu li a:hover, .langmenu li a[aria-current] { background: var(--accent-soft); text-decoration: none; }
.langmenu li a[aria-current] { font-weight: 700; }
/* Menu trượt (mobile) */
.m-drawer { position: fixed; inset: 0 auto 0 0; margin: 0; width: min(20rem, 86vw); height: 100vh; height: 100dvh; max-width: none; max-height: none; padding: 0; border: 0; background: transparent; color: var(--text); }
.m-drawer::backdrop { background: rgb(20 18 61 / .5); }
.m-panel { height: 100%; overflow: auto; padding: var(--s-4) var(--s-4) var(--s-7) max(var(--s-4), env(safe-area-inset-left)); background: var(--panel); box-shadow: var(--sh-3); }
.m-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--s-4); }
.m-links, .m-genres { margin: 0; padding: 0; list-style: none; }
.m-links a { display: block; padding: var(--s-3) var(--s-2); border-radius: var(--r-sm); color: var(--text); font-weight: 600; }
.m-links a:hover, .m-genres a:hover { background: var(--accent-soft); text-decoration: none; }
.m-title { margin: var(--s-5) 0 var(--s-2); color: var(--muted); font-size: var(--fs-xs); font-weight: 600; text-transform: uppercase; letter-spacing: .08em; }
.m-genres { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; }
.m-genres a { display: block; padding: var(--s-2); border-radius: var(--r-sm); color: var(--text); font-size: var(--fs-sm); }
@media (prefers-reduced-motion: no-preference) { .m-drawer[open] .m-panel { animation: rd-slide .22s ease-out; } }
@media (max-width: 1024px) {
  html.js .hd-menu { display: inline-grid; margin-left: calc(-1 * var(--s-2)); }
  html.js .hd-nav { display: none; }
  html:not(.js) .hd { flex-wrap: wrap; height: auto; padding-top: var(--s-2); padding-bottom: var(--s-2); }
  html:not(.js) .hd-nav { order: 6; width: 100%; margin: 0; overflow-x: auto; }
  .hd-search { margin-left: auto; }
}
/* Mobile: ô tìm thu gọn thành kính lúp; mở ra phủ cả hàng header */
@media (max-width: 640px) {
  .hd { gap: var(--s-1); }
  html.js .hd-search input { position: absolute; right: 0; width: 0; padding: 0; border-width: 0; opacity: 0; pointer-events: none; }
  html.js .hd-search .icon-btn { position: static; }
  html.js .search-open .hd-search { position: absolute; inset: 0 0 0 0; z-index: 5; background: var(--bg); padding: 0 var(--gutter); }
  html.js .search-open .hd-search input { position: static; flex: 1; width: auto; height: 2.5rem; padding: 0 2.75rem 0 var(--s-4); border-width: 1px; opacity: 1; pointer-events: auto; }
  html.js .search-open .hd-search .icon-btn { position: absolute; right: var(--gutter); }
  html:not(.js) .hd-search { order: 5; width: 100%; }
  html:not(.js) .hd-search input { width: 100%; }
}

/* ===== Breadcrumb ===== */
.crumbs { margin: 0 0 var(--s-5); }
.crumbs ol { display: flex; flex-wrap: wrap; gap: var(--s-1); margin: 0; padding: 0; list-style: none; font-size: var(--fs-sm); color: var(--muted); }
.crumbs li { min-width: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crumbs li + li::before { content: "›"; margin-right: var(--s-1); color: var(--muted); }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--accent-text); }
.crumbs [aria-current] { color: var(--text); }

/* ===== Bố cục 2 cột: nội dung + cột phụ (dính khi cuộn trên desktop) ===== */
.cols { display: grid; gap: var(--s-7); }
.col-main { min-width: 0; }
.side { display: grid; gap: var(--s-5); align-content: start; min-width: 0; }
@media (min-width: 1024px) {
  .cols { grid-template-columns: minmax(0, 1fr) var(--side-w); gap: var(--s-7); }
  .side { position: sticky; top: calc(var(--hd-h) + var(--s-5)); align-self: start; }
}

/* ===== Hero (carousel) trang chủ: ~320px, nền gradient tím + họa tiết, bìa nghiêng ===== */
.hero { position: relative; margin: 0 0 var(--s-7); border-radius: var(--r-lg); overflow: hidden; background: var(--brand-ink); box-shadow: var(--sh-2); }
.hero-track { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; overscroll-behavior-x: contain; }
.hero-track::-webkit-scrollbar { display: none; }
.slide {
  position: relative; flex: 0 0 100%; scroll-snap-align: start; display: grid; grid-template-columns: 11rem minmax(0, 1fr); gap: var(--s-7); align-items: center;
  height: 320px; padding: var(--s-6) var(--s-8) var(--s-6) var(--s-7); color: #fff; overflow: hidden;
  background:
    radial-gradient(circle at 1px 1px, rgb(255 255 255 / .09) 1px, transparent 1.5px) 0 0 / 22px 22px,
    radial-gradient(120% 140% at 85% 0%, var(--brand-500) 0%, transparent 55%),
    linear-gradient(135deg, var(--brand-700) 0%, var(--brand-900) 55%, var(--brand-ink) 100%);
}
.slide::after { content: ""; position: absolute; right: -6rem; bottom: -8rem; width: 22rem; height: 22rem; border-radius: 50%; border: 1px solid rgb(255 255 255 / .12); box-shadow: 0 0 0 2.5rem rgb(255 255 255 / .03), 0 0 0 5rem rgb(255 255 255 / .02); pointer-events: none; }
.slide-cover { position: relative; z-index: 1; }
.slide-cover .cover { width: 100%; border-radius: var(--r-md); transform: rotate(-4deg); box-shadow: 0 24px 40px -12px rgb(0 0 0 / .6), 0 0 0 1px rgb(255 255 255 / .12); }
.slide-body { position: relative; z-index: 1; min-width: 0; max-width: 40rem; }
.slide-kicker { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); margin: 0 0 var(--s-3); font-size: var(--fs-xs); font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: rgb(255 255 255 / .8); }
.slide-title { margin: 0 0 var(--s-2); font-family: var(--serif); font-size: var(--fs-3xl); line-height: 1.2; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.slide-title a { color: #fff; }
.slide-meta { margin: 0 0 var(--s-3); color: rgb(255 255 255 / .8); font-size: var(--fs-sm); }
.slide-blurb { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; margin: 0 0 var(--s-5); color: rgb(255 255 255 / .9); font-size: var(--fs-sm); line-height: 1.65; }
.slide .btn-primary { background: #fff; border-color: #fff; color: var(--brand-ink); box-shadow: 0 8px 20px -8px rgb(0 0 0 / .6); }
.slide .btn-primary:hover { background: var(--brand-50); border-color: var(--brand-50); }
.hero-ctrl { position: absolute; right: var(--s-4); bottom: var(--s-4); z-index: 2; display: flex; align-items: center; gap: var(--s-1); padding: var(--s-1); border-radius: var(--r-pill); background: rgb(20 18 61 / .45); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.hero-btn { min-width: 2.5rem; height: 2.5rem; border-radius: var(--r-pill); color: #fff; }
.hero-btn:hover { background: rgb(255 255 255 / .15); color: #fff; }
.hero-btn svg { fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.hero-btn .ic-play { display: none; fill: currentColor; stroke: none; }
.hero.is-paused .ic-play { display: block; }
.hero.is-paused .ic-pause { display: none; }
.hero-dots { display: flex; gap: 2px; }
.hero-dots button { width: 1.5rem; height: 2.5rem; padding: 0; border: 0; background: none; cursor: pointer; }
.hero-dots button::before { content: ""; display: block; width: 8px; height: 8px; margin: auto; border-radius: 50%; background: rgb(255 255 255 / .45); transition: width var(--dur), background-color var(--dur); }
.hero-dots button[aria-current]::before { width: 18px; border-radius: var(--r-pill); background: #fff; }
@media (max-width: 900px) { .slide { grid-template-columns: 8.5rem minmax(0, 1fr); gap: var(--s-5); padding: var(--s-5) var(--s-6); } }
@media (max-width: 640px) {
  .hero { margin-left: calc(-1 * var(--gutter)); margin-right: calc(-1 * var(--gutter)); border-radius: 0; }
  .slide { grid-template-columns: 6.5rem minmax(0, 1fr); gap: var(--s-4); height: auto; min-height: 15rem; padding: var(--s-5) var(--s-4) 4.25rem; align-items: start; }
  .slide-cover .cover { transform: rotate(-3deg); }
  .slide-title { font-size: var(--fs-xl); }
  .slide-blurb { -webkit-line-clamp: 3; margin-bottom: var(--s-4); }
  .hero-ctrl { left: 50%; right: auto; transform: translateX(-50%); }
}

/* ===== Trang chủ: tiếp tục đọc / theo dõi ===== */
.continue, .follow { display: none; }
html.has-recent .continue, html.has-follow .follow { display: block; }
.cont-row { display: flex; gap: var(--s-3); height: 6rem; margin: 0; padding: 0 0 var(--s-1); list-style: none; overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: thin; }
/* Mobile: dải cuộn ngang tràn sát mép màn hình (cố ý) */
@media (max-width: 640px) { .cont-row { margin: 0 calc(-1 * var(--gutter)); padding: 0 var(--gutter) var(--s-1); } }
.cont-row li { flex: 0 0 min(18rem, 80vw); scroll-snap-align: start; }
.cont-card { display: flex; gap: var(--s-3); height: 100%; padding: var(--s-2); border: 1px solid var(--line); border-radius: var(--r-md); background: var(--panel); color: var(--text); box-shadow: var(--sh-1); transition: border-color var(--dur), box-shadow var(--dur); }
.cont-card:hover { text-decoration: none; border-color: var(--accent); box-shadow: var(--sh-2); }
.cont-card .cover-xs { width: 52px; height: auto; aspect-ratio: 2 / 3; }
.cont-body { display: flex; flex-direction: column; justify-content: center; gap: 2px; min-width: 0; flex: 1; }
.cont-title { font-weight: 650; font-size: var(--fs-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cont-meta { color: var(--muted); font-size: var(--fs-xs); }
.cont-bar { position: relative; height: 4px; margin-top: var(--s-1); border-radius: var(--r-pill); background: var(--line); overflow: hidden; }
.cont-bar::after { content: ""; position: absolute; inset: 0; background: var(--accent); transform: scaleX(var(--p, 0)); transform-origin: 0 50%; }

/* ===== Mới cập nhật: grid cột cố định + cột tên co giãn; < 900px thành thẻ xếp dọc ===== */
.upd-head, .upd { display: grid; grid-template-columns: 48px minmax(240px, 1fr) 8.5rem 12rem 6.5rem; gap: var(--s-4); align-items: center; }
.upd-head { margin: 0 calc(-1 * var(--s-3)); padding: 0 var(--s-3) var(--s-3); border-bottom: 1px solid var(--line); color: var(--muted); font-size: var(--fs-xs); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.upd-head span:first-child { grid-column: 1 / span 2; }
.upd-head span:last-child { text-align: right; }
.upd-list { margin: 0 calc(-1 * var(--s-3)); padding: 0; list-style: none; }
.upd { padding: var(--s-3); border-radius: var(--r-md); }
.upd + .upd { border-top: 1px solid var(--line); }
.upd:hover { background: var(--accent-soft); }
.upd-main { min-width: 0; }
.upd-tline { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.4; }
.upd-tline .badges { margin-right: var(--s-1); vertical-align: 1px; }
.upd-title { color: var(--text); font-weight: 650; font-size: var(--fs-sm); }
.upd-author { display: block; margin-top: 2px; color: var(--muted); font-size: var(--fs-xs); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.upd-genre { color: var(--muted); font-size: var(--fs-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.upd-ch { display: flex; flex-direction: column; min-width: 0; color: var(--accent-text); font-size: var(--fs-sm); font-weight: 600; white-space: nowrap; }
.upd-ct { color: var(--muted); font-weight: 400; font-size: var(--fs-xs); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.upd-time { color: var(--muted); font-size: var(--fs-xs); text-align: right; white-space: nowrap; }
.upd-box { container-type: inline-size; }
/* Dạng thẻ khi CHÍNH KHỐI hẹp (vd. cột chính cạnh cột phụ ở 1024px), không chỉ theo độ rộng màn hình */
@container (max-width: 780px) {
  .upd-head { display: none; }
  .upd-list { display: grid; gap: var(--s-3); margin: 0; }
  .upd { grid-template-columns: 48px minmax(0, 1fr); grid-template-areas: "c m" "c h"; gap: var(--s-1) var(--s-3); align-items: start; padding: var(--s-3); border: 1px solid var(--line); border-radius: var(--r-md); background: var(--panel); }
  .upd + .upd { border-top: 1px solid var(--line); }
  .upd .cover-xs { grid-area: c; }
  .upd-main { grid-area: m; }
  .upd-genre { display: none; }
  .upd-ch { grid-area: h; flex-direction: row; align-items: baseline; gap: var(--s-2); }
  .upd-ct { flex: 1; min-width: 0; }
  .upd-time { position: absolute; right: var(--s-3); top: var(--s-3); }
  .upd { position: relative; }
  .upd-main { padding-right: 5.5rem; }
}
/* Dự phòng cho trình duyệt chưa hỗ trợ container query */
@supports not (container-type: inline-size) {
  @media (max-width: 1240px) {
  .upd-head { display: none; }
  .upd-list { display: grid; gap: var(--s-3); margin: 0; }
  .upd { grid-template-columns: 48px minmax(0, 1fr); grid-template-areas: "c m" "c h"; gap: var(--s-1) var(--s-3); align-items: start; padding: var(--s-3); border: 1px solid var(--line); border-radius: var(--r-md); background: var(--panel); }
  .upd + .upd { border-top: 1px solid var(--line); }
  .upd .cover-xs { grid-area: c; }
  .upd-main { grid-area: m; }
  .upd-genre { display: none; }
  .upd-ch { grid-area: h; flex-direction: row; align-items: baseline; gap: var(--s-2); }
  .upd-ct { flex: 1; min-width: 0; }
  .upd-time { position: absolute; right: var(--s-3); top: var(--s-3); }
  .upd { position: relative; }
  .upd-main { padding-right: 5.5rem; }
  }
}

/* ===== Bảng xếp hạng (cột phụ + trang xếp hạng) ===== */
.tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 2px; margin-bottom: var(--s-3); padding: 3px; border-radius: var(--r-md); background: var(--bg); }
.tabs [role="tab"] { min-height: 2.25rem; border: 0; border-radius: var(--r-sm); background: none; color: var(--muted); font: inherit; font-size: var(--fs-xs); font-weight: 600; white-space: nowrap; cursor: pointer; }
.tabs [role="tab"][aria-selected="true"] { background: var(--panel); color: var(--text); box-shadow: var(--sh-1); }
html.js .rank-panel:not(.is-active) { display: none; }
html.js .rank-nojs { display: none; }
.rank-nojs { margin: var(--s-3) 0 var(--s-2); font-size: var(--fs-sm); color: var(--muted); }
.rank-list, .mini-list { margin: 0; padding: 0; list-style: none; }
.rank-list li { display: grid; grid-template-columns: 24px 36px minmax(0, 1fr); gap: var(--s-3); align-items: center; padding: var(--s-2) 0; }
.mini-list li { display: grid; grid-template-columns: 36px minmax(0, 1fr); gap: var(--s-3); align-items: center; padding: var(--s-2) 0; }
.rank-list li + li, .mini-list li + li { border-top: 1px solid var(--line); }
.rank-list .cover-xs, .mini-list .cover-xs { width: 36px; height: 54px; }
.rank-no { display: grid; place-items: center; height: 24px; border-radius: 6px; color: var(--muted); font-size: var(--fs-xs); font-weight: 800; font-variant-numeric: tabular-nums; }
.rank-no.r1, .rank-no.r2, .rank-no.r3 { color: #fff; }
.rank-no.r1 { background: var(--brand-600); } .rank-no.r2 { background: var(--brand-500); } .rank-no.r3 { background: var(--brand-400); color: var(--brand-ink); }
.rank-body { display: flex; flex-direction: column; min-width: 0; }
.rank-title { color: var(--text); font-weight: 600; font-size: var(--fs-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-meta { color: var(--muted); font-size: var(--fs-xs); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.genre-cloud { display: flex; flex-wrap: wrap; gap: var(--s-2); margin: var(--s-3) 0 0; padding: 0; list-style: none; }
.genre-cloud a { display: inline-flex; align-items: center; height: 2rem; padding: 0 var(--s-3); border: 1px solid var(--line); border-radius: var(--r-pill); color: var(--text); font-size: var(--fs-xs); white-space: nowrap; }
.genre-cloud a:hover { border-color: var(--accent); color: var(--accent-text); text-decoration: none; }
.genre-cloud a[aria-current] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.rank-big { margin: 0; padding: 0; list-style: none; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--panel); overflow: hidden; box-shadow: var(--sh-1); }
.rb { display: grid; grid-template-columns: 2rem 48px minmax(0, 1fr) auto; gap: var(--s-4); align-items: center; padding: var(--s-3) var(--s-4); }
.rb + .rb { border-top: 1px solid var(--line); }
.rb .rank-no { height: 2rem; font-size: var(--fs-sm); }
.rb-body { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.rb-top { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.rb-title { color: var(--text); font-weight: 650; margin-right: var(--s-1); }
.rb-meta { color: var(--muted); font-size: var(--fs-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rb-meta a { color: var(--muted); }
.rb-views { color: var(--text); font-weight: 600; font-size: var(--fs-sm); white-space: nowrap; font-variant-numeric: tabular-nums; }
@media (max-width: 560px) { .rb { grid-template-columns: 1.75rem 48px minmax(0, 1fr); gap: var(--s-3); } .rb-views { grid-column: 3; font-weight: 400; color: var(--muted); } }

/* ===== Danh sách (thể loại, hot, full, xếp hạng, tìm kiếm) ===== */
.page-head { margin: 0 0 var(--s-5); }
.page-title { margin: 0; font-size: var(--fs-3xl); overflow-wrap: anywhere; }
.page-sub { margin: var(--s-1) 0 0; color: var(--muted); font-size: var(--fs-sm); }
.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--s-3); margin: 0 0 var(--s-6); padding: var(--s-4); border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--panel); }
.fl { display: grid; gap: var(--s-1); flex: 1 1 9rem; min-width: 0; color: var(--muted); font-size: var(--fs-xs); font-weight: 600; }
.fl select { height: 2.5rem; padding: 0 var(--s-3); border: 1px solid var(--line); border-radius: var(--r-md); background: var(--bg); color: var(--text); font: inherit; font-size: var(--fs-sm); max-width: 100%; }
html.js .filters.auto .fl-apply { display: none; }
.big-search { position: relative; display: flex; gap: var(--s-2); max-width: 40rem; margin-bottom: var(--s-6); }
.big-search svg { position: absolute; left: var(--s-3); top: 50%; width: 20px; height: 20px; margin-top: -10px; color: var(--muted); pointer-events: none; }
.big-search .input { height: 3rem; padding-left: 2.75rem; border-radius: var(--r-md); }
.big-search .btn { height: 3rem; }
.pager { display: flex; align-items: center; justify-content: center; gap: var(--s-2); flex-wrap: wrap; margin-top: var(--s-7); }
.pager-nums { display: flex; gap: var(--s-1); margin: 0; padding: 0; list-style: none; }
.pnum { display: inline-grid; place-items: center; min-width: 2.5rem; height: 2.5rem; padding: 0 var(--s-2); border-radius: var(--r-md); color: var(--text); font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
a.pnum:hover { background: var(--accent-soft); text-decoration: none; }
.pnum[aria-current] { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.pager .gap { display: grid; place-items: center; min-width: 1.5rem; color: var(--muted); }
@media (max-width: 480px) { .pager .btn { flex: 1; padding: 0 var(--s-3); } .pager-nums { order: -1; width: 100%; justify-content: center; } }
.genre-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr)); grid-auto-rows: 1fr; gap: var(--s-3); margin: 0; padding: 0; list-style: none; }
.genre-grid a { height: 100%; align-items: center; }
.genre-grid a { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-3); padding: var(--s-4); border: 1px solid var(--line); border-radius: var(--r-md); background: var(--panel); color: var(--text); box-shadow: var(--sh-1); transition: border-color var(--dur), transform var(--dur); }
.genre-grid a:hover { border-color: var(--accent); text-decoration: none; transform: translateY(-2px); }
.gg-name { font-weight: 650; }
.gg-count { color: var(--muted); font-size: var(--fs-xs); white-space: nowrap; }
.prose-page { max-width: 44rem; }
.prose-page p { margin: 0 0 var(--s-4); font-size: var(--fs-lg); line-height: 1.75; }
.prose-page .page-title { margin-bottom: var(--s-5); }

/* ===== Trang truyện ===== */
.nv-hero { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: var(--s-7); align-items: start; margin: 0 0 var(--s-7); }
.nv-cover .cover { width: 100%; border-radius: var(--r-md); box-shadow: var(--sh-3); }
.nv-info { min-width: 0; }
.nv-info > .badges { margin-bottom: var(--s-2); }
.nv-title { margin: 0 0 var(--s-2); font-family: var(--serif); font-size: var(--fs-4xl); line-height: 1.15; overflow-wrap: anywhere; }
.nv-author { margin: 0 0 var(--s-4); color: var(--muted); }
.nv-author a { color: var(--text); font-weight: 600; }
/* Một hàng thông tin: biểu tượng nhỏ + giá trị */
.nv-meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-5); margin: 0 0 var(--s-4); padding: 0; list-style: none; color: var(--muted); font-size: var(--fs-sm); }
.nv-meta li { display: inline-flex; align-items: center; gap: var(--s-2); white-space: nowrap; }
.nv-meta svg { width: 16px; height: 16px; color: var(--muted); }
.nv-meta a { color: var(--text); font-weight: 600; }
.nv-meta .status { color: var(--text); font-weight: 600; }
.nv-rate { white-space: normal; }
.tags { display: flex; flex-wrap: wrap; gap: var(--s-1) var(--s-3); margin: 0 0 var(--s-4); padding: 0; list-style: none; color: var(--muted); font-size: var(--fs-sm); }
/* Đánh giá sao gọn trong hàng thông tin */
.rating { margin: 0; }
.rating fieldset { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 0 var(--s-2); margin: 0; padding: 0; border: 0; min-width: 0; }
.stars { display: inline-flex; }
.stars button { width: 1.75rem; height: 1.75rem; padding: 0; border: 0; border-radius: 6px; background: none; color: var(--line); font-size: 1.15rem; line-height: 1; cursor: pointer; transition: color var(--dur), transform var(--dur); }
html[data-theme="dark"] .stars button, html[data-theme="oled"] .stars button { color: #3d365f; }
@media (prefers-color-scheme: dark) { html:not([data-theme]) .stars button { color: #3d365f; } }
.stars button.on, html .stars button.on { color: #f59e0b; }
.stars button[aria-pressed="true"] { transform: scale(1.15); }
html .stars:hover button { color: var(--line); }
.stars:has(button:nth-child(1):hover) button:nth-child(-n+1),
.stars:has(button:nth-child(2):hover) button:nth-child(-n+2),
.stars:has(button:nth-child(3):hover) button:nth-child(-n+3),
.stars:has(button:nth-child(4):hover) button:nth-child(-n+4),
.stars:has(button:nth-child(5):hover) button:nth-child(-n+5) { color: #f59e0b; }
.rating-sum { color: var(--muted); font-size: var(--fs-xs); }
.rating.is-busy .stars { opacity: .6; pointer-events: none; }
/* Một hàng nút */
.nv-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); margin: var(--s-5) 0 var(--s-5); }
.nv-cont { display: none; }
html.has-progress .nv-cont { display: inline-flex; }
/* Đã đọc dở: "Đọc tiếp" thay chỗ "Đọc từ đầu" (chương 1 vẫn có trong danh sách chương) -> giữ một hàng nút */
html.has-progress .nv-start { display: none; }
.nv-toast { color: var(--muted); font-size: var(--fs-sm); overflow-wrap: anywhere; }
.nv-toast:empty { display: none; }
.nv-langs { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-3); }
.nv-langs-label { color: var(--muted); font-size: var(--fs-sm); }
/* Tab: gạch chân động */
.nv-tabs { display: flex; gap: var(--s-6); margin: 0 0 var(--s-6); padding: 0; border-bottom: 1px solid var(--line); background: none; border-radius: 0; overflow-x: auto; scrollbar-width: none; }
.nv-tabs [role="tab"] { position: relative; flex: none; display: inline-flex; align-items: center; gap: var(--s-2); height: 3rem; padding: 0; border: 0; border-radius: 0; background: none; color: var(--muted); font: inherit; font-size: var(--fs-md); font-weight: 600; box-shadow: none; cursor: pointer; }
.nv-tabs [role="tab"]::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; border-radius: 3px 3px 0 0; background: var(--accent); transform: scaleX(0); transition: transform .25s var(--ease); }
.nv-tabs [role="tab"]:hover { color: var(--text); }
.nv-tabs [role="tab"][aria-selected="true"] { color: var(--text); background: none; box-shadow: none; }
.nv-tabs [role="tab"][aria-selected="true"]::after { transform: scaleX(1); }
.nv-tabs .count { font-size: .7em; }
html.js .tab-panel:not(.is-active) { display: none; }
html.js .tab-nojs { display: none; }
.tab-panel { margin-bottom: var(--s-7); }
.desc-body { max-width: 46rem; font-family: var(--serif); font-size: var(--fs-lg); line-height: 1.75; }
.desc-body p { margin: 0 0 var(--s-3); }
html.js .desc-body.is-clamped:not(.is-open) { max-height: calc(1.75em * 5); overflow: hidden; -webkit-mask-image: linear-gradient(#000 60%, transparent); mask-image: linear-gradient(#000 60%, transparent); }
.ch-tools { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); margin-bottom: var(--s-4); }
.ch-jump { display: flex; gap: var(--s-2); flex: 0 1 16rem; min-width: 0; }
.ch-jump .input { min-width: 0; height: 2.5rem; min-height: 0; }
.ch-jump .btn { min-height: 2.5rem; }
.ch-ranges { display: flex; flex-wrap: wrap; gap: var(--s-1); flex: 1 1 16rem; min-width: 0; }
.ch-ranges .chip { font-variant-numeric: tabular-nums; }
#toc-rev[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); }
.toc { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; background: var(--panel); }
.toc li + li { border-top: 1px solid var(--line); }
.toc a { display: grid; grid-template-columns: 7.5rem minmax(0, 1fr) auto 20px; gap: var(--s-4); align-items: baseline; padding: var(--s-3) var(--s-4); color: var(--text); font-size: var(--fs-sm); }
.toc a:hover { background: var(--accent-soft); text-decoration: none; }
.toc .num { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.toc .ct { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toc time { font-size: var(--fs-xs); white-space: nowrap; }
.toc .mark { position: relative; width: 20px; height: 16px; align-self: center; overflow: hidden; color: transparent; font-size: 0; }
.toc .mark::before { position: absolute; inset: 0; display: grid; place-items: center; font-size: 14px; }
.toc .is-read .mark::before { content: "✓"; color: var(--muted); }
.toc .is-read .ct { color: var(--muted); }
.toc .is-current a { background: var(--accent-soft); }
.toc .is-current .mark::before { content: ""; inset: 4px 6px; border-radius: 50%; background: var(--accent); }
.toc .is-current .ct { font-weight: 650; }
.nv-related { margin-top: var(--s-7); }
@media (max-width: 760px) {
  .nv-hero { grid-template-columns: 120px minmax(0, 1fr); gap: var(--s-5); }
  .nv-title { font-size: var(--fs-2xl); }
  .nv-meta { gap: var(--s-2) var(--s-4); }
  .nv-actions { grid-column: 1 / -1; }
  .toc a { grid-template-columns: minmax(0, 1fr) 20px; row-gap: 0; }
  .toc .num { grid-column: 1; font-size: var(--fs-xs); }
  .toc .ct { grid-column: 1; white-space: normal; }
  .toc time { display: none; }
  .toc .mark { grid-column: 2; grid-row: 1 / span 2; }
}
@media (max-width: 480px) {
  .nv-hero { grid-template-columns: 1fr; }
  .nv-cover { width: 140px; }
  .nv-actions .btn-lg { flex: 1 1 100%; }
  .nv-tabs { gap: var(--s-4); }
  .nv-tabs [role="tab"] { font-size: var(--fs-sm); }
}

/* ===== Lỗi / 404 ===== */
.error-page { max-width: 40rem; margin: var(--s-6) auto; text-align: center; }
.error-code { margin: 0 0 calc(-1 * var(--s-6)); font-family: var(--serif); font-size: clamp(4rem, 18vw, 7rem); font-weight: 700; line-height: 1; color: var(--accent-soft); }
.error-page .empty-state { position: relative; }
.error-page .big-search { margin: var(--s-5) auto var(--s-3); }
.error-actions { display: flex; justify-content: center; gap: var(--s-3); flex-wrap: wrap; }
.nf { text-align: center; padding: var(--s-8) 0; }

/* ===== Footer: 4 cột + dòng bản quyền ===== */
.site-footer { margin-top: auto; border-top: 1px solid var(--line); background: var(--panel); color: var(--muted); font-size: var(--fs-sm); }
.ft-grid { display: grid; grid-template-columns: 1.4fr 1.6fr 1fr 1fr; gap: var(--s-7); padding-top: var(--s-7); padding-bottom: var(--s-6); }
@media (max-width: 900px) { .ft-grid { grid-template-columns: 1fr 1fr; gap: var(--s-6); } .ft-about { grid-column: 1 / -1; } }
@media (max-width: 480px) { .ft-grid { grid-template-columns: 1fr; } }
.ft-about p { margin: var(--s-3) 0 0; max-width: 22rem; line-height: 1.6; }
.ft-h { margin: 0 0 var(--s-3); color: var(--text); font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.ft-list { display: grid; gap: var(--s-2); margin: 0; padding: 0; list-style: none; }
.ft-cols { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: var(--s-4); }
.ft-all { grid-column: 1 / -1; }
.ft-list a { color: var(--muted); }
.ft-list a:hover, .ft-list a[aria-current] { color: var(--accent-text); }
.ft-all a { color: var(--accent-text); font-weight: 600; }
.ft-bottom { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-2) var(--s-5); padding-top: var(--s-4); padding-bottom: max(var(--s-5), env(safe-area-inset-bottom)); border-top: 1px solid var(--line); font-size: var(--fs-xs); }
.ft-copy { margin: 0; }
.is-reader .site-footer { text-align: start; }

/* ===== Chuyển động ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; animation-duration: 0s !important; scroll-behavior: auto !important; }
  .card:hover .card-cover { transform: none; }
}

/* ---- Thông báo, ô nhập có nhãn, honeypot ---- */
.notice { margin: 0 0 var(--s-3); padding: var(--s-2) var(--s-3); border-radius: var(--r-md); font-size: var(--fs-sm); }
.notice-ok { background: color-mix(in srgb, #16a34a 14%, var(--panel)); color: var(--text); }
.notice-err { background: color-mix(in srgb, #dc2626 14%, var(--panel)); color: var(--text); }
.is-ok { color: var(--text); } .is-err { color: #b91c1c; }
html[data-theme="dark"] .is-err, html[data-theme="oled"] .is-err { color: #fca5a5; }
@media (prefers-color-scheme: dark) { html:not([data-theme]) .is-err { color: #fca5a5; } }
.field { display: grid; gap: var(--s-1); margin-bottom: var(--s-3); color: var(--muted); font-size: var(--fs-sm); font-weight: 600; }
.field textarea { resize: vertical; min-height: 6rem; font-weight: 400; line-height: 1.6; }
.field input { font-weight: 400; }
.hp { position: absolute !important; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ---- Bình luận ---- */
.cmts { font-family: var(--sans); font-size: 1rem; }
.cmt-form { position: relative; margin: 0 0 var(--s-5); padding: var(--s-4); border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--panel); }
.cmt-fields { max-width: 20rem; }
.cmt-actions { display: flex; align-items: center; justify-content: flex-end; gap: var(--s-3); }
.cmt-len { color: var(--muted); font-size: var(--fs-xs); font-variant-numeric: tabular-nums; }
.cmt-msg, .rp-msg { margin: var(--s-2) 0 0; font-size: var(--fs-sm); }
.cmt-msg:empty, .rp-msg:empty { display: none; }
.cmt-replying { margin: 0 0 var(--s-3); color: var(--muted); font-size: var(--fs-sm); }
.cmt-empty { color: var(--muted); }
.cmt-list, .cmt-replies { margin: 0; padding: 0; list-style: none; }
.cmt { display: grid; grid-template-columns: 2.5rem minmax(0, 1fr); gap: var(--s-3); padding: var(--s-4) 0; border-top: 1px solid var(--line); }
.cmt-list > .cmt:first-child { border-top: 0; }
.cmt-replies { margin-top: var(--s-2); }
.cmt-replies .cmt { grid-template-columns: 2rem minmax(0, 1fr); padding: var(--s-3) 0 0; border-top: 0; }
.cmt-replies .cmt-av { width: 2rem; height: 2rem; font-size: .85rem; }
.cmt-av { display: grid; place-items: center; width: 2.5rem; height: 2.5rem; border-radius: 50%; background: hsl(var(--h, 240) 45% 42%); color: #fff; font-weight: 700; }
.cmt-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 var(--s-2); margin: 0 0 var(--s-1); font-size: var(--fs-sm); }
.cmt-name { color: var(--text); }
.cmt-ch { color: var(--muted); font-size: var(--fs-xs); }
.cmt-head time { color: var(--muted); font-size: var(--fs-xs); }
.cmt-body { margin: 0; white-space: pre-line; overflow-wrap: anywhere; line-height: 1.6; }
.cmt-reply-btn { font-size: var(--fs-sm); }
.cmt-main .cmt-form { margin-top: var(--s-3); }
.cmt-pager { display: flex; align-items: center; justify-content: center; gap: var(--s-3); margin-top: var(--s-4); }

/* ===== Admin (giữ class cũ, dùng token chung) ===== */
.admin-nav { display: flex; gap: var(--s-4); align-items: center; flex-wrap: wrap; }
.admin-nav form { margin-left: auto; }
.tbl { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.tbl th, .tbl td { padding: .6rem .8rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl th { color: var(--muted); font-weight: 600; font-size: .85rem; }
.badge { display: inline-block; padding: .05rem .45rem; border-radius: var(--r-sm); background: var(--bg); border: 1px solid var(--line); font-size: .78rem; margin: 0 .15rem .15rem 0; }
.flash { padding: .7rem 1rem; border-radius: var(--r-md); margin: 0 0 1rem; }
.flash.ok { background: #dcfce7; color: #14532d; }
.flash.error { background: #fee2e2; color: #7f1d1d; }
form.stack label { display: block; margin: .8rem 0 .25rem; font-weight: 600; font-size: .9rem; }
form.stack input[type=text], form.stack input[type=number], form.stack input[type=password], form.stack select, form.stack textarea {
  width: 100%; padding: .5rem .7rem; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--bg); color: var(--text); font: inherit; }
form.stack textarea { min-height: 14rem; line-height: 1.6; resize: vertical; }
form.stack textarea.short { min-height: 6rem; }
form.stack input[type=color] { width: 3.5rem; height: 2.2rem; padding: 0; border: 1px solid var(--line); border-radius: var(--r-md); background: none; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 560px) { .row2 { grid-template-columns: 1fr; } }
details.lang-block { border: 1px solid var(--line); border-radius: var(--r-md); padding: .4rem .9rem .8rem; margin: .7rem 0; background: var(--panel); }
details.lang-block > summary { cursor: pointer; font-weight: 700; padding: .4rem 0; }
.card-box { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 1rem 1.2rem; margin-bottom: 1rem; }
.narrow { max-width: 26rem; margin: 3rem auto; }


/* ===== Admin: tổng quan, bìa ===== */
.adm-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr)); gap: var(--s-4); }
.adm-h { margin: 0 0 var(--s-3); font-size: var(--fs-lg); }
.adm-sub { margin: var(--s-3) 0 var(--s-1); font-size: var(--fs-sm); color: var(--muted); }
.adm-top { margin: 0; padding-left: 1.4rem; }
.adm-bars td:last-child { display: flex; align-items: center; gap: var(--s-2); font-variant-numeric: tabular-nums; }
.adm-bars .bar { display: inline-block; height: .6rem; width: calc(var(--w) * 10rem); min-width: 2px; border-radius: var(--r-pill); background: var(--accent); }
.adm-bars .is-today td { font-weight: 700; }
.tbl-wrap { overflow-x: auto; margin-top: var(--s-3); }
.adm-novels td.num { white-space: nowrap; font-variant-numeric: tabular-nums; }
.adm-thumb { display: block; width: 48px; height: 64px; object-fit: cover; border-radius: var(--r-sm); background: var(--line); }
.pill-toggle { min-height: 2rem; padding: 0 var(--s-3); border: 1px solid var(--line); border-radius: var(--r-pill); background: var(--panel); color: var(--muted); font: inherit; font-size: var(--fs-xs); cursor: pointer; }
.pill-toggle.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
.cover-edit { display: grid; grid-template-columns: 150px 1fr; gap: var(--s-4); align-items: start; }
.adm-cover { width: 150px; height: 200px; object-fit: cover; border-radius: var(--r-md); box-shadow: var(--sh-1); }
form.stack label.check { display: flex; align-items: center; gap: var(--s-2); font-weight: 400; }
@media (max-width: 560px) { .cover-edit { grid-template-columns: 1fr; } }


/* Admin: bình luận, báo lỗi */
.count-dot { display: inline-block; padding: 0 .45rem; border-radius: var(--r-pill); background: #b91c1c; color: #fff; font-size: var(--fs-xs); font-weight: 700; }
.adm-tabs { display: flex; flex-wrap: wrap; gap: var(--s-2); margin: var(--s-3) 0; }
.adm-tabs a { padding: var(--s-1) var(--s-3); border: 1px solid var(--line); border-radius: var(--r-pill); color: var(--text); }
.adm-tabs a[aria-current] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.adm-bulk-bar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); margin: var(--s-3) 0; }
.adm-bulk-bar .check { display: inline-flex; gap: var(--s-1); align-items: center; margin-right: var(--s-3); }
.adm-body { max-width: 32rem; white-space: pre-line; overflow-wrap: anywhere; }
.tbl tr.st-pending { background: color-mix(in srgb, #f59e0b 12%, transparent); }
.tbl tr.st-hidden { opacity: .6; }


/* =====================================================================
   THƯƠNG HIỆU: logo sáng/tối theo theme (html[data-theme] hoặc hệ thống)
   ===================================================================== */
.logo-h { display: block; width: auto; height: 38px; }
picture.logo-light { display: block; }   /* bản tối: ẩn mặc định, hiện theo theme ở các quy tắc .logo-dark bên dưới */
picture { line-height: 0; }
.logo-v { display: block; width: 144px; height: auto; }
.logo-dark { display: none; }
html[data-theme="dark"] .logo-light, html[data-theme="oled"] .logo-light { display: none; }
html[data-theme="dark"] .logo-dark, html[data-theme="oled"] .logo-dark { display: block; }
@media (prefers-color-scheme: dark) {
  html:not([data-theme]) .logo-light { display: none; }
  html:not([data-theme]) .logo-dark { display: block; }
}
@media (max-width: 640px) { .logo-h { height: 32px; } }
@media (max-width: 400px) { .logo-h { height: 28px; } }
.m-head .logo-h { height: 32px; }
.ft-about .brand { display: inline-block; }
.admin-brand { display: inline-flex; align-items: center; gap: var(--s-2); font-weight: 700; color: var(--text); }
.admin-brand .logo-h { height: 32px; }
.admin-login-logo { display: flex; justify-content: center; margin: 0 0 var(--s-4); }
.admin-login-logo .logo-v { width: 10rem; }

.badge-demo { background: #b45309; border-color: #b45309; color: #fff; font-weight: 800; letter-spacing: .05em; }

/* Ngôn ngữ: tên đầy đủ trong danh sách (header + trang đọc), ngôn ngữ đang chọn có dấu ✓ */
.langmenu li a { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); white-space: nowrap; }
.langmenu ul { width: max-content; min-width: 11rem; }
.rd-lang-name { font-family: var(--sans); font-size: var(--fs-sm); font-weight: 600; }
.rd-lang-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; }   /* thiếu chỗ: rút gọn bằng "…" (vẫn là tên, không đổi thành mã) */
/* Màn hẹp: logo thu gọn thành biểu tượng (picture), header vẫn đủ chỗ cho tên ngôn ngữ đầy đủ */
@media (max-width: 480px) {
  .logo-h { height: 32px; }
  .hd .lang-sum { padding: 0 var(--s-1); }
  .hd .lang-sum .chev { display: none; }
}

/* =====================================================================
   TRANG ĐỌC CHƯƠNG — thoáng, dễ đọc lâu. Desktop: "tờ giấy" trên nền hơi khác màu; mobile: tràn mép.
   ===================================================================== */
.is-reader { --bar-h: 56px; --dock-h: 60px; --rd-page: #f3effb; --rd-paper: #ffffff; background: var(--rd-page); }
html[data-theme="sepia"] .is-reader { --rd-page: #e8dcc3; --rd-paper: #f4ecd8; }
html[data-theme="dark"] .is-reader { --rd-page: #14102a; --rd-paper: #1d1838; }
html[data-theme="oled"] .is-reader { --rd-page: #000000; --rd-paper: #0a0a0a; }
@media (prefers-color-scheme: dark) { html:not([data-theme]) .is-reader { --rd-page: #14102a; --rd-paper: #1d1838; } }
html:has(body.is-reader) { scroll-padding-top: calc(var(--bar-h) + 1rem); }
.rd-main { min-height: 70vh; padding-bottom: calc(var(--dock-h) + 2.5rem); }

/* ---- Thanh trên: gọn, kính mờ, tự ẩn khi cuộn xuống; tiến độ là vạch mảnh ở đáy ---- */
.rd-bar {
  position: sticky; top: 0; z-index: 20; min-height: var(--bar-h);   /* min-height: chữ phóng to (rem) vẫn nằm trong thanh */
  display: flex; align-items: center; gap: var(--s-1);
  padding: 0 max(var(--s-2), env(safe-area-inset-right)) 0 max(var(--s-2), env(safe-area-inset-left));
  background: var(--rd-page); background: color-mix(in srgb, var(--rd-page) 82%, transparent);
  -webkit-backdrop-filter: saturate(1.5) blur(14px); backdrop-filter: saturate(1.5) blur(14px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  font-family: var(--sans); transition: transform .28s var(--ease), opacity .28s;
}
html.rd-ui-hidden .rd-bar, html[data-focus="1"]:not(.rd-peek) .rd-bar { transform: translateY(-100%); opacity: 0; }
.rd-bar:has(:focus-visible) { transform: none !important; opacity: 1 !important; }
.rd-progress { position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; pointer-events: none; }
.rd-progress span { display: block; height: 100%; background: var(--accent); transform: scaleX(0); transform-origin: 0 50%; }
html:not(.js) .rd-progress { display: none; }
.rd-icon {
  position: relative; flex: none; width: 44px; height: 44px; display: grid; place-items: center;
  border: 0; border-radius: 12px; background: none; color: var(--text); cursor: pointer; font: inherit;
  transition: background-color var(--dur), color var(--dur);
}
.rd-icon:hover { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent-text); text-decoration: none; }
.rd-icon svg, .rd-lang summary svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.rd-aa { font-family: var(--serif); font-size: 18px; font-weight: 650; letter-spacing: -.02em; } /* px như các biểu tượng: luôn vừa nút 44px */
.rd-where { flex: 1 1 auto; min-width: 5.5rem; display: flex; flex-direction: column; line-height: 1.25; padding: .35rem var(--s-1); }
.rd-novel { color: var(--text); font-weight: 650; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rd-chnum { color: var(--muted); font-size: .78rem; white-space: nowrap; }
.rd-lang { flex: 0 1 auto; min-width: 44px; }
.rd-lang summary { min-width: 44px; max-width: 100%; height: 44px; padding: 0 var(--s-2); border: 0; display: inline-flex; align-items: center; gap: var(--s-1); white-space: nowrap; border-radius: 12px; color: var(--text); }
.rd-lang summary:hover { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.rd-lang ul { top: calc(100% + 4px); }

/* ---- Cột đọc + "tờ giấy" ---- */
.rd-stage { padding: 0; }
.rd {
  --measure: 44rem; --pad: 1.25rem;                        /* ~700px; mobile lề 20px */
  width: min(100%, calc(var(--measure) + 2 * var(--pad)));
  margin: 0 auto; padding: 2rem var(--pad) 2.5rem; background: var(--rd-paper);
}
html[data-width="narrow"] .rd { --measure: 36rem; }
html[data-width="wide"] .rd { --measure: 52rem; }
@media (max-width: 899px) { .is-reader { background: var(--rd-paper); } .rd-bar { background: var(--rd-paper); background: color-mix(in srgb, var(--rd-paper) 85%, transparent); } }
@media (min-width: 900px) {
  .rd-stage { padding: 2.5rem var(--gutter) 0; }
  .rd { --pad: clamp(2.5rem, 5vw, 4.5rem); padding-top: 3.5rem; padding-bottom: 3rem; border-radius: 16px;
        box-shadow: 0 1px 2px rgb(20 18 61 / .04), 0 12px 40px -18px rgb(20 18 61 / .18); }
  html[data-theme="dark"] .rd, html[data-theme="oled"] .rd { box-shadow: 0 0 0 1px rgb(255 255 255 / .05); }
}
@media (min-width: 900px) and (prefers-color-scheme: dark) { html:not([data-theme]) .rd { box-shadow: 0 0 0 1px rgb(255 255 255 / .05); } }

/* ---- Đầu chương ---- */
.rd-head { text-align: center; margin: 0 0 2.75rem; }
.rd-kicker { margin: 0 0 .75rem; color: var(--accent-text); font-family: var(--sans); font-size: .8rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }
.rd-head h1 { margin: 0 0 .9rem; font-family: var(--serif); font-weight: 650; font-size: clamp(1.75rem, 4vw, 2.5rem); line-height: 1.22; letter-spacing: -.01em; text-wrap: balance; overflow-wrap: anywhere; }
.rd-meta { margin: 0; color: var(--muted); font-family: var(--sans); font-size: .82rem; font-variant-numeric: tabular-nums; }
.rd-head::after { content: ""; display: block; width: 48px; height: 2px; margin: 2rem auto 0; border-radius: 2px; background: var(--accent); opacity: .35; }

/* ---- Văn bản ---- */
.prose {
  font-family: var(--read-font); font-size: var(--rs); line-height: var(--lh, 1.9); color: var(--text);
  text-align: start; overflow-wrap: break-word; font-kerning: normal; text-rendering: optimizeLegibility;
}
.prose p { margin: 0 0 1.1em; }
html[data-align="justify"] .prose { text-align: justify; hyphens: auto; -webkit-hyphens: auto; }
html[data-align="left"] .prose { text-align: start; hyphens: manual; }
html[data-indent="1"] .prose p { text-indent: var(--indent, 1.6em); }
html[data-indent="0"] .prose p { text-indent: 0; }
/* CJK: giãn dòng 2.0, ngắt dòng kinsoku, căn đều + thụt 2 chữ mặc định (người đọc đổi được) */
:lang(zh) .prose, :lang(ja) .prose { --indent: 2em; line-height: var(--lh, 2); text-align: justify; line-break: strict; word-break: normal; overflow-wrap: anywhere; hanging-punctuation: allow-end; letter-spacing: .02em; }
:lang(zh) .prose p, :lang(ja) .prose p { text-indent: 2em; }
:lang(ko) .prose { --indent: 1em; line-height: var(--lh, 2); word-break: keep-all; line-break: strict; overflow-wrap: anywhere; }

/* ---- Cuối chương: hai nút ngang hàng + liên kết mục lục ---- */
.rd-end { margin: 3.5rem 0 0; padding-top: 2rem; border-top: 1px solid var(--line); font-family: var(--sans); text-align: center; }
.rd-end-h { margin: 0 0 .25rem; color: var(--muted); font-size: .78rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }
.rd-latest { margin: .25rem 0 0; color: var(--muted); font-size: .9rem; }
.rd-pager { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; margin-top: 1.25rem; }
.rd-btn {
  display: flex; flex-direction: column; justify-content: center; gap: 2px; min-width: 0; min-height: 4rem;
  padding: .75rem 1rem; border: 1px solid var(--line); border-radius: 14px; background: transparent; color: var(--text);
  text-align: left; line-height: 1.3; transition: border-color var(--dur), background-color var(--dur), transform var(--dur);
}
.rd-btn:hover { text-decoration: none; border-color: var(--accent); }
.rd-btn.primary { align-items: flex-end; text-align: right; background: var(--accent); border-color: var(--accent); color: var(--accent-ink); box-shadow: 0 10px 24px -12px color-mix(in srgb, var(--accent) 80%, transparent); }
.rd-btn.primary:hover { background: color-mix(in srgb, var(--accent) 88%, #000); }
.rd-btn.is-off { opacity: .4; pointer-events: none; }
.rd-btn-label { font-weight: 650; font-size: 1rem; white-space: nowrap; }
.rd-btn-sub { max-width: 100%; font-size: .8rem; opacity: .82; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rd-toc-link { margin: 1rem 0 0; }
.rd-toc-link a { color: var(--accent-text); font-size: .92rem; font-weight: 600; }

/* ---- Có thể bạn thích (3–4 thẻ nhỏ) ---- */
.rd-more { margin: 3rem 0 0; font-family: var(--sans); }
.rd-sec-h { margin: 0 0 1rem; font-size: 1rem; font-weight: 700; }
.rd-rel { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; margin: 0; padding: 0; list-style: none; }
.rd-rel-item { position: relative; display: flex; flex-direction: column; gap: .35rem; min-width: 0; }
.rd-rel-item .cover { border-radius: 10px; transition: transform var(--dur) var(--ease), box-shadow var(--dur); }
.rd-rel-item:hover .cover { transform: translateY(-3px); box-shadow: var(--sh-2); }
.rd-rel-title { color: var(--text); font-size: .85rem; font-weight: 650; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.rd-rel-title::after { content: ""; position: absolute; inset: 0; }
.rd-rel-title:hover { text-decoration: none; color: var(--accent-text); }
.rd-rel-meta { color: var(--muted); font-size: .75rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 560px) {
  .rd-rel { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .75rem; }   /* 3 thẻ một hàng, không lẻ thẻ */
  .rd-rel-item:nth-child(n+4) { display: none; }
  .rd-btn { padding: .7rem .8rem; }
  .rd-btn-label { font-size: .95rem; }
}

/* ---- Báo lỗi: liên kết chữ nhỏ ---- */
.rd-report { margin: 2.5rem 0 0; font-family: var(--sans); text-align: center; }
.rd-report summary { display: inline-block; padding: .35rem .5rem; border-radius: 8px; color: var(--muted); font-size: .82rem; cursor: pointer; list-style: none; text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--muted) 50%, transparent); text-underline-offset: 3px; }
.rd-report summary::-webkit-details-marker { display: none; }
.rd-report summary:hover { color: var(--accent-text); }
.rd-report[open] summary { margin-bottom: .75rem; }
.rd-report .rp-form, .rd-report .notice { text-align: left; }
.rp-form { padding: 1rem 1.1rem; border: 1px solid var(--line); border-radius: 14px; background: color-mix(in srgb, var(--rd-page) 50%, var(--rd-paper)); }
.rp-reasons { display: grid; gap: .15rem; margin: 0 0 .75rem; padding: 0; border: 0; }
.rp-reasons legend { margin-bottom: .4rem; color: var(--muted); font-size: .85rem; font-weight: 600; }
.rp-reasons label { display: flex; align-items: center; gap: .5rem; min-height: 2.25rem; font-size: .92rem; }

/* ---- Bình luận: thu gọn mặc định, thẳng cột đọc ---- */
.rd-cmts { margin: 2rem 0 0; border-top: 1px solid var(--line); font-family: var(--sans); }
.rd-cmts > summary { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 3.5rem; padding: .75rem 0; cursor: pointer; list-style: none; }
.rd-cmts > summary::-webkit-details-marker { display: none; }
.rd-cmts-h { font-size: 1.05rem; font-weight: 700; color: var(--text); }
.rd-cmts > summary .chev { width: 20px; height: 20px; color: var(--muted); transition: transform var(--dur); }
.rd-cmts[open] > summary .chev { transform: rotate(180deg); }
.rd-cmts > summary:hover .rd-cmts-h { color: var(--accent-text); }
.rd-cmts .cmts > .sec-title { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.rd-cmts .cmt-form { padding: 1rem; background: color-mix(in srgb, var(--rd-page) 50%, var(--rd-paper)); }
.rd-cmts .cmt-fields { max-width: none; }

/* ---- Thanh công cụ nổi (5 nút 44px, kính mờ, tooltip desktop) ---- */
.rd-dock {
  position: fixed; left: 50%; bottom: max(.75rem, env(safe-area-inset-bottom)); z-index: 25; transform: translateX(-50%);
  display: flex; align-items: center; gap: 4px; padding: 6px; border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--line) 80%, transparent);
  background: var(--rd-paper); background: color-mix(in srgb, var(--rd-paper) 78%, transparent);
  -webkit-backdrop-filter: saturate(1.6) blur(16px); backdrop-filter: saturate(1.6) blur(16px);
  box-shadow: 0 10px 30px -10px rgb(20 18 61 / .35); font-family: var(--sans);
  transition: transform .28s var(--ease), opacity .28s;
}
.rd-dock .rd-icon { border-radius: 999px; }
.rd-dock .rd-aa-btn { background: var(--accent); color: var(--accent-ink); }
.rd-dock .rd-aa-btn:hover { background: color-mix(in srgb, var(--accent) 88%, #000); color: var(--accent-ink); }
.rd-dock .is-off { opacity: .3; pointer-events: none; }
.rd-badge { position: absolute; top: 4px; right: 2px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: 10px; font-weight: 800; line-height: 18px; text-align: center; }
html.rd-ui-hidden .rd-dock, html[data-focus="1"]:not(.rd-peek) .rd-dock { transform: translate(-50%, calc(100% + 1.5rem)); opacity: 0; }
.rd-dock:has(:focus-visible) { transform: translateX(-50%) !important; opacity: 1 !important; }
@media (hover: hover) and (pointer: fine) {
  .rd-icon[data-tip]::after {
    content: attr(data-tip); position: absolute; left: 50%; bottom: calc(100% + 10px); transform: translate(-50%, 4px);
    padding: 5px 9px; border-radius: 8px; background: var(--text); color: var(--bg); font-size: 12px; font-weight: 600; white-space: nowrap;
    opacity: 0; pointer-events: none; transition: opacity .15s, transform .15s;
  }
  .rd-bar .rd-icon[data-tip]::after { bottom: auto; top: calc(100% + 8px); transform: translate(-50%, -4px); }
  .rd-icon[data-tip]:hover::after, .rd-icon[data-tip]:focus-visible::after { opacity: 1; transform: translate(-50%, 0); }
}

/* ---- Lên đầu + toast ---- */
.rd-top {
  position: fixed; right: max(1rem, env(safe-area-inset-right)); bottom: calc(max(.75rem, env(safe-area-inset-bottom)) + var(--dock-h) + .75rem); z-index: 15;
  width: 44px; height: 44px; display: grid; place-items: center; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: var(--rd-paper); color: var(--text); box-shadow: var(--sh-2);
  opacity: 0; visibility: hidden; transform: translateY(.5rem); transition: opacity .2s, transform .2s, visibility 0s .2s;
}
.rd-top svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
html.rd-far:not(.rd-ui-hidden):not([data-focus="1"]) .rd-top, html.rd-far[data-focus="1"].rd-peek .rd-top { opacity: 1; visibility: visible; transform: none; transition: opacity .2s, transform .2s; }
.rd-toast {
  position: fixed; left: 50%; bottom: calc(max(.75rem, env(safe-area-inset-bottom)) + var(--dock-h) + .75rem); z-index: 40; width: max-content; max-width: min(28rem, calc(100vw - 2rem));
  padding: .7rem 1rem; border-radius: 12px; background: var(--text); color: var(--bg); font-family: var(--sans); font-size: .9rem; line-height: 1.45;
  transform: translate(-50%, .5rem); opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s;
}
.rd-toast.show { opacity: 1; transform: translate(-50%, 0); }
.rd-toast:empty { display: none; }

/* ---- Bảng Aa (popover desktop / bottom sheet mobile) + mục lục (drawer) ---- */
.rd-sheet, .rd-drawer { padding: 0; border: 0; background: transparent; color: var(--text); max-width: none; max-height: none; overflow: visible; }
.rd-sheet::backdrop { background: rgb(20 18 61 / .08); }
.rd-drawer::backdrop { background: rgb(20 18 61 / .45); }
.rd-panel { background: var(--panel); color: var(--text); border: 1px solid var(--line); box-shadow: var(--sh-3); font-family: var(--sans); font-size: 1rem; line-height: 1.45; overflow: auto; overscroll-behavior: contain; }
.rd-panel-head { display: flex; align-items: center; gap: 4px; margin: -6px -8px .75rem 0; }
.rd-panel-head h2 { flex: 1; margin: 0; font-size: 1.05rem; font-weight: 700; }
.rd-sheet { position: fixed; inset: auto auto calc(max(.75rem, env(safe-area-inset-bottom)) + var(--dock-h) + .75rem) 50%; transform: translateX(-50%); margin: 0; width: min(24rem, calc(100vw - 1.5rem)); }
.rd-sheet .rd-panel { border-radius: 20px; padding: 1.1rem 1.2rem 1.2rem; max-height: calc(100vh - var(--dock-h) - 3rem); max-height: calc(100dvh - var(--dock-h) - 3rem); }
.rd-drawer { position: fixed; inset: 0 auto 0 0; margin: 0; width: min(26rem, 92vw); height: 100vh; height: 100dvh; }
.rd-drawer .rd-panel { height: 100%; display: flex; flex-direction: column; overflow: hidden; border-radius: 0 20px 20px 0; border-left: 0; padding: 1rem 1rem 0 max(1rem, env(safe-area-inset-left)); }
@media (max-width: 640px) {
  .rd-sheet { inset: auto 0 0 0; transform: none; width: 100%; }
  .rd-sheet .rd-panel { border-radius: 22px 22px 0 0; border-bottom: 0; max-height: 85vh; max-height: 85dvh; padding-bottom: max(1.2rem, env(safe-area-inset-bottom)); }
  .rd-sheet .rd-panel::before { content: ""; display: block; width: 40px; height: 4px; margin: -4px auto 12px; border-radius: 4px; background: var(--line); }
  .rd-drawer { width: 100%; }
  .rd-drawer .rd-panel { border-radius: 0; border: 0; }
}
@media (prefers-reduced-motion: no-preference) {
  .rd-sheet[open] .rd-panel { animation: rd-pop .18s ease-out; }
  .rd-drawer[open] .rd-panel { animation: rd-slide .22s ease-out; }
  @media (max-width: 640px) { .rd-sheet[open] .rd-panel { animation: rd-up .22s ease-out; } }
  html.rd-theme-anim, html.rd-theme-anim * { transition: background-color .35s ease, color .35s ease, border-color .35s ease !important; }
}
@media (prefers-reduced-motion: reduce) { .rd-bar, .rd-dock, .rd-top, .rd-toast { transition: none; } }
@keyframes rd-pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes rd-up { from { transform: translateY(100%); } }
@keyframes rd-slide { from { transform: translateX(-100%); } }
/* Xem trước trực tiếp: dùng đúng biến đọc (phông, cỡ, giãn dòng, căn lề) */
.rd-preview { margin: 0 0 1rem; padding: .85rem 1rem; border: 1px solid var(--line); border-radius: 14px; background: var(--rd-paper); color: var(--text);
  font-family: var(--read-font); font-size: min(var(--rs), 1.5rem); line-height: var(--lh, 1.9); max-height: 7.5em; overflow: hidden; }
html[data-align="justify"] .rd-preview { text-align: justify; }
.rd-field { border: 0; margin: 0 0 1rem; padding: 0; min-width: 0; }
.rd-field legend, .rd-label { display: flex; justify-content: space-between; width: 100%; padding: 0; margin-bottom: .45rem; color: var(--muted); font-size: .8rem; font-weight: 700; letter-spacing: .02em; }
.rd-label output { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.rd-seg { display: flex; gap: 4px; padding: 4px; border-radius: 12px; background: var(--bg); }
.rd-seg label { position: relative; flex: 1 1 0; min-width: 0; }
.rd-seg input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.rd-seg span { display: grid; place-items: center; min-height: 40px; padding: 0 .4rem; border-radius: 9px; color: var(--muted); font-size: .88rem; font-weight: 600; text-align: center; line-height: 1.2; transition: background-color var(--dur), color var(--dur); }
.rd-seg input:checked + span { background: var(--panel); color: var(--text); box-shadow: var(--sh-1); }
.rd-seg input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }
.f-serif { font-family: var(--serif); } .f-sans { font-family: var(--sans); } .f-mono { font-family: var(--mono); }
/* Theme: ô tròn màu */
.rd-dots { display: flex; justify-content: space-between; gap: 6px; }
.rd-dot { position: relative; flex: 1 1 0; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; cursor: pointer; }
.rd-dot input { position: absolute; opacity: 0; width: 44px; height: 44px; margin: 0; cursor: pointer; }
.rd-dot .dot { width: 40px; height: 40px; border-radius: 50%; border: 1px solid rgb(20 18 61 / .18); box-shadow: inset 0 0 0 3px var(--panel); transition: box-shadow var(--dur); }
.rd-dot input:checked + .dot { box-shadow: inset 0 0 0 3px var(--panel), 0 0 0 2px var(--accent); }
.rd-dot input:focus-visible + .dot { outline: 2px solid var(--focus); outline-offset: 3px; }
.dot-label { color: var(--muted); font-size: .72rem; font-weight: 600; text-align: center; line-height: 1.2; }
.rd-dot input:checked ~ .dot-label { color: var(--text); }
.dot-light .dot { background: #ffffff; }
.dot-sepia .dot { background: #f4ecd8; }
.dot-dark .dot { background: #1d1838; }
.dot-oled .dot { background: #000000; }
.dot-system .dot { background: linear-gradient(135deg, #ffffff 50%, #1d1838 50%); }
.rd-range { display: flex; align-items: center; gap: .5rem; }
.rd-range input[type=range] { flex: 1; min-width: 0; height: 44px; accent-color: var(--accent); }
.rd-step { flex: none; width: 44px; height: 40px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--text); font-family: var(--serif); font-weight: 700; cursor: pointer; }
.rd-step .a-sm { font-size: .8rem; } .rd-step .a-lg { font-size: 1.2rem; }
.rd-step:hover { border-color: var(--accent); }
.rd-switches { display: grid; gap: 0; }
.rd-switch { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 44px; cursor: pointer; }
.rd-switch span { order: -1; font-size: .92rem; }
.rd-switch input { appearance: none; -webkit-appearance: none; flex: none; position: relative; width: 44px; height: 26px; margin: 0; border-radius: 999px; background: var(--line); border: 1px solid var(--muted); cursor: pointer; transition: background-color .2s; }
.rd-switch input::before { content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: var(--panel); box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .2s; }
.rd-switch input:checked { background: var(--accent); border-color: var(--accent); }
.rd-switch input:checked::before { transform: translateX(18px); }
.rd-reset { width: 100%; min-height: 44px; margin-top: .25rem; border: 1px solid var(--line); border-radius: 12px; background: none; color: var(--text); font: inherit; font-weight: 600; cursor: pointer; }
.rd-reset:hover { border-color: var(--accent); color: var(--accent-text); }
/* Mục lục */
.rd-filter { width: 100%; padding: .65rem .85rem; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); color: var(--text); font: inherit; }
.rd-toc-status { margin: .5rem .1rem 0; min-height: 1.3em; color: var(--muted); font-size: .85rem; }
.rd-toc-status:empty { margin: 0; min-height: 0; }
.rd-toc-list { list-style: none; flex: 1; margin: .5rem -.5rem 0; padding: 0 0 max(1rem, env(safe-area-inset-bottom)); overflow: auto; overscroll-behavior: contain; }
.rd-toc-list a { display: flex; align-items: baseline; gap: .75rem; padding: .6rem .7rem; border-radius: 10px; color: var(--text); }
.rd-toc-list a:hover { background: var(--bg); text-decoration: none; }
.rd-toc-list .n { flex: none; min-width: 5.5rem; color: var(--muted); font-size: .84rem; font-variant-numeric: tabular-nums; }
.rd-toc-list .t { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rd-toc-list a[aria-current] { background: var(--accent-soft); font-weight: 650; }
.rd-toc-list .tag { flex: none; color: var(--accent-text); font-size: .74rem; font-weight: 600; }

/* ---- Chân trang tối giản ở trang đọc ---- */
.rd-foot { border-top: 1px solid var(--line); background: transparent; }
.rd-foot-in { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: .5rem 1.25rem; padding-top: 1.25rem; padding-bottom: calc(1.25rem + var(--dock-h) + env(safe-area-inset-bottom)); font-size: .82rem; color: var(--muted); }
.rd-foot .logo-h { height: 24px; }
.rd-foot-links { display: flex; gap: 1rem; }
.rd-foot-links a { color: var(--muted); }
.rd-foot-links a:hover { color: var(--accent-text); }

/* ---- In: chỉ nội dung chương ---- */
@media print {
  html { --bg: #fff !important; --panel: #fff !important; --text: #000 !important; --muted: #444 !important; color-scheme: light !important; }
  .site-header, .site-footer, .rd-bar, .rd-end, .rd-more, .rd-report, .rd-cmts, .rd-dock, .rd-top, .rd-toast, dialog, .rd-meta, .rd-head::after { display: none !important; }
  body, .is-reader { background: #fff !important; color: #000; }
  .rd-stage { padding: 0; }
  .rd { width: auto; padding: 0; box-shadow: none !important; background: #fff; }
  .prose { font-size: 12pt; line-height: 1.6; }
  .prose p { orphans: 3; widows: 3; }
  .rd-head h1 { break-after: avoid; }
  a { color: inherit; }
}
