/* ==========================================================================
   TruyệnHub Reader v6 — Ấn Bản "Tờ Giấy Lụa Nổi" & Trình Phát "Đĩa Than Hoa Trà"
   5 Bảng màu giấy 2 lớp · Ngăn kéo Mục lục/Cài đặt · Giọng AI Bắc/Nam
   ========================================================================== */

.reader-page {
  padding-bottom: 0;
  background: var(--r-pagebg);
  color: var(--r-text);
  background-image: none;
  transition: background 0.28s ease, color 0.28s ease;
  --r-pagebg: #f1e9db;
  --r-panel: #fcf8f0;
  --r-surface: #f4ebdc;
  --r-parchment: #f4e5c4;
  --r-parchment-border: #dfcca3;
  --r-parchment-ink: #3c2e1e;
  --r-text: #251f1a;
  --r-muted: #786c60;
  --r-line: #e5dccb;
  --r-hi: #faecc8;
  --r-hibar: #d68a1c;
  --r-font: 'Lora', 'Palatino Linotype', 'Times New Roman', serif;
  --r-size: 20px;
  --r-lh: 1.9;
  --r-gap: 22px;
}

/* 1. Trắng Ngà Sách In (Nền bao ngoài xám ấm giúp tờ giấy trắng nổi khối) */
.reader-page[data-theme='white'] {
  --r-pagebg: #e9e5de;
  --r-panel: #ffffff;
  --r-surface: #f7f3ec;
  --r-parchment: #f5e6c4;
  --r-parchment-border: #e1cfa7;
  --r-parchment-ink: #3b2e1f;
  --r-text: #1b1916;
  --r-muted: #6e655d;
  --r-line: #e6dfd6;
  --r-hi: #fff3c8;
  --r-hibar: #d99b00;
}

/* 2. Giấy Kem Ấm (Mặc định êm mắt cả ngày lẫn tối) */
.reader-page[data-theme='cream'] {
  --r-pagebg: #efe6d5;
  --r-panel: #fcf9f2;
  --r-surface: #f3ece0;
  --r-parchment: #f3e3be;
  --r-parchment-border: #decb9f;
  --r-parchment-ink: #3b2e1f;
  --r-text: #221d18;
  --r-muted: #736759;
  --r-line: #e5dccb;
  --r-hi: #f8e8be;
  --r-hibar: #cc8b1f;
}

/* 3. Sepia Cổ Điển ( Phong vị sách giấy cổ kiểu Toidoc ) */
.reader-page[data-theme='sepia'] {
  --r-pagebg: #ead9b7;
  --r-panel: #f6e9cc;
  --r-surface: #eddab2;
  --r-parchment: #ebd5a7;
  --r-parchment-border: #d4bc89;
  --r-parchment-ink: #3a2b1a;
  --r-text: #382a1b;
  --r-muted: #786549;
  --r-line: #decba2;
  --r-hi: #eed597;
  --r-hibar: #b3741e;
}

/* 4. Lụa Hồng Tiểu Thư (Bản sắc riêng Thư Các TruyệnHub) */
.reader-page[data-theme='pink'] {
  --r-pagebg: #f4e2e7;
  --r-panel: #fff8fa;
  --r-surface: #fbeaf0;
  --r-parchment: #f9dfe7;
  --r-parchment-border: #ecc1cf;
  --r-parchment-ink: #4a2533;
  --r-text: #341f28;
  --r-muted: #8a6976;
  --r-line: #f0d4dd;
  --r-hi: #fde2ea;
  --r-hibar: #e05d79;
}

/* 5. Đêm Nhung Ấm (Chữ kem ấm trên nền than nâu, không mỏi mắt ban đêm) */
.reader-page[data-theme='dark'] {
  --r-pagebg: #151315;
  --r-panel: #221e21;
  --r-surface: #2c272b;
  --r-parchment: #2f292c;
  --r-parchment-border: #433a3e;
  --r-parchment-ink: #dfd5d9;
  --r-text: #dcd3d7;
  --r-muted: #988b91;
  --r-line: #362f33;
  --r-hi: #3a2d24;
  --r-hibar: #f0946d;
}

.reader-page[data-font='book'] { --r-font: 'Literata', 'Palatino Linotype', Georgia, serif; }
.reader-page[data-font='sans'] { --r-font: 'Be Vietnam Pro', system-ui, -apple-system, sans-serif; }

.reader-page .panel { background: var(--r-panel); border-color: var(--r-line); }

/* ---------- Thanh Đọc Ghim Đầu Trang (Sticky Reader Sub-Header) ---------- */
.reader-bar.reader-top {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 42;
  background: color-mix(in srgb, var(--r-panel) 93%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--r-line);
  padding-top: env(safe-area-inset-top);
  transition: transform 0.28s var(--ease), background 0.28s;
}
.reader.chrome-hidden .reader-top { transform: translateY(-105%); }

.reader-top-inner {
  max-width: 1220px;
  margin: 0 auto;
  height: 54px;
  padding: 0 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.reader-top-left, .reader-top-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.reader .icon-btn { color: var(--r-text); width: 36px; height: 36px; }
.reader .icon-btn:hover { background: var(--r-surface); }

.reader-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 34px;
  padding: 0 11px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--r-line);
  background: var(--r-surface);
  color: var(--r-text);
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  transition: border-color 0.2s, transform 0.15s, background 0.2s;
}
.reader-pill-btn:hover { border-color: var(--coral-400); color: var(--coral-600); }
.reader-page[data-theme='dark'] .reader-pill-btn:hover { color: #ff9c88; }

/* Nút Nghe Audio Phát Sáng (Signature Coral × Rose Glow) */
.listen-trigger-wrap { position: relative; display: inline-flex; align-items: center; }
.listen-glow-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 13px;
  border: 0;
  border-radius: var(--radius-pill);
  background: linear-gradient(135deg, #f47e5f 0%, #e65c4f 52%, #d86284 100%);
  color: #fff;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.01em;
  box-shadow: 0 4px 14px rgba(230, 92, 79, 0.38);
  transition: transform 0.2s var(--ease), filter 0.2s, box-shadow 0.2s;
  white-space: nowrap;
}
.listen-glow-btn:hover { transform: translateY(-1px) scale(1.02); filter: brightness(1.06); }
.listen-glow-btn:active { transform: scale(0.96); }
.listen-glow-ring {
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  border: 1.5px solid rgba(244, 126, 95, 0.58);
  animation: listenPulse 2.4s ease-out infinite;
  pointer-events: none;
}
.listen-glow-btn.is-playing {
  background: linear-gradient(135deg, #1aa37a 0%, #128765 55%, #0f6d52 100%);
  box-shadow: 0 4px 14px rgba(22, 155, 115, 0.42);
}
.listen-glow-btn.is-playing .listen-glow-ring { border-color: rgba(52, 211, 153, 0.65); }
@keyframes listenPulse {
  0% { transform: scale(1); opacity: 0.85; }
  75%, 100% { transform: scale(1.13); opacity: 0; }
}
@media (max-width: 430px) {
  .listen-glow-btn { padding: 0 10px; }
  .listen-glow-text { display: none; }
}

.listen-whisper {
  position: absolute;
  top: calc(100% + 9px);
  left: 0;
  z-index: 48;
  padding: 6px 12px;
  border-radius: 11px;
  background: linear-gradient(135deg, #2d1b24, #1e1419);
  color: #fff5f7;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 10px 24px rgba(24, 10, 16, 0.28);
  border: 1px solid rgba(244, 126, 95, 0.45);
  animation: whisperFloat 0.35s var(--ease);
}
.listen-whisper::before {
  content: '';
  position: absolute;
  top: -5px; left: 16px;
  width: 9px; height: 9px;
  background: #2b1a22;
  border-top: 1px solid rgba(244, 126, 95, 0.45);
  border-left: 1px solid rgba(244, 126, 95, 0.45);
  transform: rotate(45deg);
}
@keyframes whisperFloat {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.reader-heading {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  line-height: 1.24;
  padding: 0 4px;
}
.reader-story {
  max-width: 100%;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--r-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.reader-story:hover { color: var(--coral-500); }
.reader-chap {
  max-width: 100%;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--r-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 5 chấm đổi màu giấy nhanh ngay trên Header Desktop */
.header-swatches {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 7px;
  border-radius: var(--radius-pill);
  background: var(--r-surface);
  border: 1px solid var(--r-line);
}
.header-swatches button {
  width: 19px;
  height: 19px;
  border-radius: 50%;
  border: 1.5px solid rgba(0, 0, 0, 0.16);
  padding: 0;
  transition: transform 0.15s, box-shadow 0.15s;
}
.header-swatches button[data-theme='cream'] { background: #f8f1e1; }
.header-swatches button[data-theme='white'] { background: #ffffff; }
.header-swatches button[data-theme='sepia'] { background: #edd5a3; }
.header-swatches button[data-theme='pink'] { background: #fbdbe4; }
.header-swatches button[data-theme='dark'] { background: #1e1a1d; border-color: rgba(255, 255, 255, 0.28); }
.header-swatches button:hover { transform: scale(1.12); }
.header-swatches button.is-active {
  border-color: var(--coral-500);
  box-shadow: 0 0 0 2.5px rgba(230, 98, 74, 0.3);
  transform: scale(1.1);
}

/* Thanh tiến độ đọc mảnh chạy sát mép dưới Header */
.reader-hairline {
  height: 2.5px;
  width: 100%;
  background: color-mix(in srgb, var(--r-line) 65%, transparent);
  overflow: hidden;
}
.reader-hairline span {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--coral-500), #e06387);
  transition: width 0.12s linear;
}

/* ---------- Nút Mũi Tên Tròn Lơ Lửng Hai Mép Trang Giấy (Desktop) ---------- */
.reader-float-arrows { pointer-events: none; }
@media (max-width: 1039px) {
  .reader-float-arrows { display: none !important; }
}
@media (min-width: 1040px) {
  .float-arrow {
    pointer-events: auto;
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    z-index: 32;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: color-mix(in srgb, var(--r-panel) 92%, transparent);
    border: 1px solid var(--r-line);
    color: var(--r-text);
    box-shadow: 0 8px 22px rgba(28, 18, 22, 0.1);
    transition: transform 0.2s var(--ease), border-color 0.2s, color 0.2s, box-shadow 0.2s;
  }
  .float-arrow-prev { left: max(16px, calc(50% - 492px)); }
  .float-arrow-next { right: max(16px, calc(50% - 492px)); }
  .float-arrow:hover:not(.is-disabled) {
    transform: translateY(-50%) scale(1.08);
    border-color: var(--coral-400);
    color: var(--coral-600);
    box-shadow: 0 12px 26px rgba(229, 98, 71, 0.2);
  }
  .float-arrow.is-disabled { opacity: 0.28; pointer-events: none; }
}

/* ---------- Sân Khấu 2 Lớp & Tờ Giấy Nổi Trung Tâm ---------- */
.reader-stage {
  min-height: 100svh;
  padding: calc(56px + env(safe-area-inset-top)) 0 48px;
}
.reader-paper {
  max-width: 856px;
  margin: 0 auto;
  background: var(--r-panel);
  padding: 20px 20px 64px;
  transition: background 0.28s ease, padding-bottom 0.25s ease;
}
.reader.audio-open .reader-paper { padding-bottom: 245px; }
.reader.audio-open.audio-minimized .reader-paper { padding-bottom: 115px; }

@media (min-width: 880px) {
  .reader-stage { padding: 78px 20px 64px; }
  .reader-paper {
    border-radius: 22px;
    border: 1px solid var(--r-line);
    box-shadow: 0 16px 46px rgba(32, 20, 16, 0.06);
    padding: 34px 58px 64px;
  }
  .reader-page[data-theme='dark'] .reader-paper {
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.36);
  }
}

/* ---------- Điều Hướng Chương Kiểu Giấy Cổ (Đầu & Cuối Chương) ---------- */
.parchment-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}
.parchment-nav-top {
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px dashed var(--r-line);
}
.parchment-nav-bottom { margin-top: 18px; }

.parchment-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 40px;
  padding: 0 15px;
  border-radius: 12px;
  background: var(--r-parchment);
  border: 1px solid var(--r-parchment-border);
  color: var(--r-parchment-ink);
  font-size: 13.5px;
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(59, 46, 31, 0.06);
  transition: transform 0.18s var(--ease), filter 0.18s, box-shadow 0.18s;
}
.parchment-btn:hover:not(.is-disabled) {
  transform: translateY(-1px);
  filter: brightness(0.98);
  box-shadow: 0 5px 14px rgba(59, 46, 31, 0.12);
}
.parchment-btn-toc {
  background: var(--r-surface);
  border-color: var(--r-line);
  color: var(--r-text);
  font-weight: 600;
}
.parchment-btn-primary {
  background: var(--grad-primary);
  border-color: transparent;
  color: #fff !important;
  box-shadow: var(--shadow-btn);
}
.parchment-btn.is-disabled {
  opacity: 0.38;
  pointer-events: none;
  box-shadow: none;
}
@media (max-width: 480px) {
  .parchment-nav { gap: 6px; }
  .parchment-btn { height: 37px; padding: 0 11px; font-size: 12.5px; flex: 1; min-width: 0; white-space: nowrap; }
}

/* ---------- Đầu Chương & Hoa Văn Phân Cách ---------- */
.reader-chap-head { text-align: center; margin: 6px 0 30px; }
.reader-overline {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--coral-600);
  margin-bottom: 8px;
}
.reader-page[data-theme='dark'] .reader-overline { color: #ff9e8a; }
.reader-overline:hover { text-decoration: underline; }
.reader-title {
  font-family: var(--font-display);
  font-size: clamp(23px, 3.2vw, 31px);
  font-weight: 700;
  line-height: 1.32;
  margin: 0;
  color: var(--r-text);
}
.reader-byline {
  margin: 7px 0 0;
  font-size: 13px;
  color: var(--r-muted);
}
.reader-byline span { font-weight: 600; color: var(--r-text); }
.reader-fleuron { display: flex; justify-content: center; margin-top: 12px; color: var(--rose-500); }
.reader-fleuron .fleuron { width: 116px; height: 18px; }

.listen-cta-wrap { display: flex; justify-content: center; margin-top: 14px; }
.listen-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 37px;
  padding: 0 17px;
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--coral-500) 10%, var(--r-panel));
  border: 1px solid color-mix(in srgb, var(--coral-500) 35%, var(--r-line));
  color: var(--coral-600);
  font-size: 13.5px;
  font-weight: 600;
  transition: transform 0.2s var(--ease), background 0.2s, box-shadow 0.2s;
}
.reader-page[data-theme='dark'] .listen-pill { color: #ff9c88; }
.listen-pill:hover { transform: translateY(-1px); background: color-mix(in srgb, var(--coral-500) 16%, var(--r-panel)); box-shadow: var(--shadow-sm); }
.listen-pill.is-playing { background: linear-gradient(135deg, #1aa37a, #117f5e); color: #fff !important; border-color: transparent; box-shadow: 0 6px 16px rgba(22, 155, 115, 0.3); }

/* ---------- Văn Bản Đọc & Hiệu Ứng Tô Sáng Câu Đang Nghe ---------- */
.reader-text {
  font-family: var(--r-font);
  font-size: var(--r-size);
  line-height: var(--r-lh);
  text-align: justify;
  hyphens: auto;
  word-break: break-word;
  letter-spacing: 0.008em;
}
.reader-text p {
  margin: 0 0 var(--r-gap);
  padding: 3px 0;
  border-radius: 8px;
  transition: background 0.24s ease, box-shadow 0.24s ease, padding 0.2s ease;
}
.reader-text > p:first-child::first-letter {
  font-family: var(--font-display);
  font-size: 2.35em;
  font-weight: 700;
  line-height: 0.9;
  float: left;
  padding: 4px 10px 0 0;
  color: var(--coral-500);
}
.reader.audio-open .reader-text p { cursor: pointer; }
.reader.audio-open .reader-text p:hover:not(.is-speaking) {
  background: color-mix(in srgb, var(--r-hi) 42%, transparent);
}
.reader-text p.is-speaking {
  background: var(--r-hi);
  padding: 6px 12px 6px 14px;
  margin-left: -14px;
  margin-right: -12px;
  box-shadow: inset 3.5px 0 0 var(--r-hibar);
}

.reader-text.is-locked { position: relative; max-height: 22em; overflow: hidden; }
.reader-text.is-locked::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 12em; background: linear-gradient(180deg, transparent, var(--r-panel)); }

.lock-card { text-align: center; display: flex; flex-direction: column; gap: 10px; align-items: center; margin: 12px 0 32px; padding: 26px 20px; }
.lock-ico { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; background: var(--pink-100); color: var(--rose-600); border: 1px solid var(--pink-200); }
.lock-ico .icon { width: 26px; height: 26px; }

/* Dải phân cách HẾT CHƯƠNG */
.chap-end-rule {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 38px 0 18px;
  color: var(--r-muted);
}
.chap-end-rule span { flex: 1; height: 1px; background: var(--r-line); }
.chap-end-rule em {
  font-style: normal;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

/* ---------- Huy Hiệu Cầu Nối Đọc Truyện ⇄ Vạn Giới 2.5D Cuối Chương ---------- */
.reader-cultivation-reward {
  margin-top: 22px;
  padding: 15px 18px;
  border-radius: 16px;
  background: linear-gradient(135deg, color-mix(in srgb, #f59e0b 10%, var(--r-panel)), color-mix(in srgb, #0ea5e9 7%, var(--r-surface)));
  border: 1px solid color-mix(in srgb, #f59e0b 36%, var(--r-parchment-border));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.rcr-body { flex: 1 1 280px; min-width: 0; }
.rcr-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: #b4690e;
  margin-bottom: 7px;
}
.reader-page[data-theme='dark'] .rcr-eyebrow { color: #fcd34d; }
.rcr-pills { display: flex; gap: 8px; flex-wrap: wrap; }
.rcr-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 12.5px;
  border: 1px solid var(--r-line);
  background: color-mix(in srgb, var(--r-panel) 88%, transparent);
  color: var(--r-text);
}
.rcr-pill small { color: var(--r-muted); font-size: 11.5px; }
.rcr-pill-stone .icon { color: #0ea5e9; }
.rcr-pill-stam .icon { color: #f59e0b; }
.rcr-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rcr-cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 13px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 700;
  text-decoration: none;
  transition: transform 0.15s, box-shadow 0.15s;
}
.rcr-cta:hover { transform: translateY(-1px); }
.rcr-cta-primary {
  background: linear-gradient(135deg, #d97706, #b45309);
  color: #fffbeb;
  box-shadow: 0 4px 12px rgba(180, 83, 9, 0.28);
}
.reader-page[data-theme='dark'] .rcr-cta-primary {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #0f172a;
}
.rcr-cta-ghost {
  border: 1px solid var(--r-line);
  background: var(--r-panel);
  color: var(--r-text);
}
@media (max-width: 620px) {
  .rcr-actions { width: 100%; justify-content: center; }
  .rcr-pills { justify-content: center; }
  .rcr-body { text-align: center; }
}

/* ---------- Hộp Chấm Sao 2 Giây & Lưu Truyện Cuối Chương ---------- */
.reader-engage-card {
  margin-top: 26px;
  padding: 18px 20px;
  border-radius: 18px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--r-parchment) 55%, var(--r-panel)), var(--r-surface));
  border: 1px solid var(--r-parchment-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.engage-left { flex: 1 1 250px; min-width: 0; }
.engage-eyebrow {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #b47818;
  margin-bottom: 4px;
}
.reader-page[data-theme='dark'] .engage-eyebrow { color: #f2c05e; }
.engage-left strong { display: block; font-size: 15.5px; color: var(--r-text); margin-bottom: 3px; }
.engage-left p { margin: 0; font-size: 12.5px; color: var(--r-muted); line-height: 1.48; }
.engage-right { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
@media (max-width: 620px) {
  .engage-right { width: 100%; align-items: center; }
  .engage-left { text-align: center; }
}
.engage-stars { display: flex; gap: 4px; }
.star-btn {
  width: 36px; height: 36px;
  border: 0; border-radius: 50%;
  background: color-mix(in srgb, var(--r-panel) 78%, transparent);
  color: color-mix(in srgb, var(--r-muted) 45%, transparent);
  display: grid; place-items: center;
  transition: transform 0.15s, color 0.15s;
}
.star-btn .icon { width: 21px; height: 21px; fill: currentColor; }
.star-btn:hover, .star-btn.is-lit { color: #f0ad28; transform: scale(1.1); }
.engage-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.engage-bm-btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 33px; padding: 0 13px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--r-line);
  background: var(--r-panel);
  color: var(--r-text);
  font-size: 12.5px; font-weight: 600;
}
.engage-bm-btn.is-saved {
  border-color: var(--coral-400);
  color: var(--coral-600);
  background: color-mix(in srgb, var(--coral-500) 10%, var(--r-panel));
}
.reader-page[data-theme='dark'] .engage-bm-btn.is-saved { color: #ff9c88; }
.engage-info-link { font-size: 12.5px; font-weight: 600; color: var(--coral-600); }
.reader-page[data-theme='dark'] .engage-info-link { color: #ff9c88; }

/* ==========================================================================
   TRÌNH PHÁT AUDIO "ĐĨA THAN HOA TRÀ" (Expanded Vinyl Deck + Mini-Pill)
   ========================================================================== */
.audio-dock {
  position: fixed;
  left: 12px; right: 12px;
  bottom: max(14px, calc(10px + var(--safe-bottom)));
  z-index: 46;
  max-width: 620px;
  margin: 0 auto;
  padding: 13px 16px 12px;
  border-radius: 22px;
  background: linear-gradient(145deg, rgba(37, 22, 30, 0.96) 0%, rgba(20, 14, 19, 0.98) 100%);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid rgba(244, 134, 108, 0.34);
  box-shadow: 0 22px 50px rgba(12, 6, 10, 0.48), 0 0 0 1px rgba(255, 255, 255, 0.05) inset;
  color: #fff6f8;
  transition: max-width 0.25s var(--ease), border-radius 0.25s, padding 0.25s, transform 0.25s;
}
.audio-dock.is-compact {
  max-width: 440px;
  padding: 7px 11px;
  border-radius: 999px;
}

.audio-full { display: flex; flex-direction: column; gap: 9px; }
.audio-dock-top { display: flex; align-items: center; gap: 8px; min-width: 0; }
.audio-status { flex: 1; min-width: 0; display: flex; align-items: center; gap: 11px; }

/* Đĩa than xoay tròn ảnh bìa truyện */
.audio-disc-wrap {
  position: relative;
  width: 46px; height: 46px;
  border-radius: 50%;
  flex: none;
  padding: 2px;
  background: conic-gradient(from 0deg, #f4866c, #f7b3c4, #e55c4d, #f4866c);
  box-shadow: 0 0 14px rgba(242, 123, 92, 0.45);
}
.audio-disc-wrap img {
  width: 100%; height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  animation: tdVinylSpin 9s linear infinite;
  animation-play-state: paused;
}
.audio-dock.is-playing .audio-disc-wrap img { animation-play-state: running; }
.audio-disc-hole {
  position: absolute;
  top: 50%; left: 50%;
  width: 11px; height: 11px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: #1b1217;
  border: 1.5px solid rgba(255, 255, 255, 0.45);
  pointer-events: none;
}
.audio-disc-sm { width: 36px; height: 36px; cursor: pointer; }
.audio-disc-sm .audio-disc-hole { width: 8px; height: 8px; }
@keyframes tdVinylSpin { to { transform: rotate(360deg); } }

.audio-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; line-height: 1.25; }
.audio-title-row { display: flex; align-items: center; gap: 6px; min-width: 0; }
.audio-ai-badge {
  flex: none;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(244, 126, 95, 0.22);
  border: 1px solid rgba(244, 126, 95, 0.45);
  color: #ffb19e;
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.06em;
}
.audio-title-row strong {
  font-size: 13.5px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.audio-meta > span {
  font-size: 11.5px;
  color: rgba(255, 235, 240, 0.65);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.audio-sleep-badge {
  font-size: 11px;
  font-weight: 700;
  color: #ffd38a;
  background: rgba(245, 184, 75, 0.16);
  border: 1px solid rgba(245, 184, 75, 0.35);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  white-space: nowrap;
}
.audio-top-btn {
  width: 30px; height: 30px;
  flex: none;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.72);
  display: grid; place-items: center;
  transition: background 0.15s, color 0.15s;
}
.audio-top-btn:hover { background: rgba(255, 255, 255, 0.16); color: #fff; }

/* Thanh tiến độ thời gian thực mm:ss / mm:ss */
.audio-Timeline { display: flex; align-items: center; gap: 9px; }
.audio-time {
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: rgba(255, 235, 240, 0.68);
  min-width: 38px;
  text-align: center;
}
.audio-Timeline input[type='range'] {
  flex: 1;
  height: 5px;
  border-radius: 999px;
  accent-color: #f47e5f;
  cursor: pointer;
  margin: 0;
}

.audio-controls { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.audio-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 34px;
  padding: 0 11px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.audio-pill:hover { background: rgba(255, 255, 255, 0.15); border-color: rgba(244, 126, 95, 0.6); }
.audio-speed-btn { min-width: 54px; justify-content: center; font-variant-numeric: tabular-nums; }

.audio-transport { display: flex; align-items: center; gap: 6px; }
.audio-step-rate {
  height: 28px; padding: 0 8px;
  border: 0; border-radius: 8px;
  background: transparent;
  color: rgba(255, 235, 240, 0.65);
  font-size: 11.5px; font-weight: 600;
}
.audio-step-rate:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
.audio-skip-btn {
  width: 36px; height: 36px;
  border: 0; border-radius: 50%;
  background: transparent;
  color: rgba(255, 255, 255, 0.85);
  display: grid; place-items: center;
}
.audio-skip-btn:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }

.audio-play-btn {
  width: 48px; height: 48px;
  border-radius: 50%;
  border: 0;
  background: linear-gradient(135deg, #f6886a 0%, #e65d4f 55%, #d96383 100%);
  color: #fff;
  box-shadow: 0 6px 18px rgba(230, 93, 79, 0.5);
  display: grid; place-items: center;
  transition: transform 0.2s var(--ease), filter 0.2s;
}
.audio-play-btn:hover { filter: brightness(1.08); transform: scale(1.04); }
.audio-play-btn:active { transform: scale(0.94); }
.audio-play-btn .icon { width: 21px; height: 21px; fill: currentColor; stroke: none; }
.audio-spinner {
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 2.4px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  animation: audioSpin 0.75s linear infinite;
}
@keyframes audioSpin { to { transform: rotate(360deg); } }

.audio-subbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.audio-vol-group {
  display: flex;
  align-items: center;
  gap: 7px;
  color: rgba(255, 235, 240, 0.65);
}
.audio-vol-group input[type='range'] {
  width: clamp(76px, 23vw, 110px);
  height: 4px;
  accent-color: #f47e5f;
  cursor: pointer;
}
.audio-sub-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 0;
  background: transparent;
  color: rgba(255, 235, 240, 0.68);
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 4px;
  white-space: nowrap;
}
.audio-sub-link:hover { color: #ffb5a3; }

/* Giao diện Mini-Pill Thu Gọn */
.audio-mini-pill {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}
.audio-mini-pill[hidden], .audio-full[hidden] { display: none !important; }
.audio-mini-info {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 0;
  color: #fff;
}
.audio-mini-info strong {
  display: block;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.audio-mini-info small {
  display: block;
  font-size: 11px;
  color: rgba(255, 235, 240, 0.62);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.audio-mini-play {
  width: 36px; height: 36px;
  flex: none;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, #f6886a, #e65d4f);
  color: #fff;
  display: grid; place-items: center;
}
.audio-mini-play .icon { fill: currentColor; stroke: none; }

/* ==========================================================================
   NGĂN KÉO TRƯỢT PHẢI DESKTOP / BOTTOM SHEET MOBILE (Mục lục, Cài đặt, Giọng AI)
   ========================================================================== */
.reader-page .sheet {
  background: var(--r-panel);
  color: var(--r-text);
  max-height: 85svh;
  overflow-y: auto;
}
.drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--r-line);
}
.reader-page .sheet-sub { color: var(--r-muted); }

@media (min-width: 900px) {
  .reader-page .sheet.sheet-drawer {
    left: auto;
    right: 0;
    top: 0;
    bottom: 0;
    width: 396px;
    max-width: 92vw;
    max-height: 100dvh;
    border-radius: 22px 0 0 22px;
    padding: 22px 20px 28px;
    transform: translateX(104%);
    opacity: 1;
    visibility: hidden;
    transition: transform 0.28s var(--ease), visibility 0.28s;
    display: flex;
    flex-direction: column;
  }
  .reader-page .sheet.sheet-drawer.is-open {
    transform: translateX(0);
    visibility: visible;
  }
  .reader-page .sheet.sheet-drawer::before { display: none; }
}

/* ---------- Ngăn Kéo Mục Lục Chương ---------- */
.toc-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 0 10px;
}
.toc-search {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}
.toc-search .icon {
  position: absolute;
  left: 11px;
  color: var(--r-muted);
  pointer-events: none;
}
.toc-search input {
  width: 100%;
  height: 38px;
  padding: 0 12px 0 34px;
  border-radius: 12px;
  border: 1px solid var(--r-line);
  background: var(--r-surface);
  color: var(--r-text);
  font-size: 13px;
}
.toc-search input:focus { outline: none; border-color: var(--coral-400); }
.toc-sort-btn {
  height: 38px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid var(--r-line);
  background: var(--r-surface);
  color: var(--r-text);
  font-size: 12.5px;
  font-weight: 700;
  white-space: nowrap;
}
.toc-drawer-list {
  flex: 1;
  min-height: 200px;
  max-height: 62svh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding-right: 2px;
}
@media (min-width: 900px) {
  .toc-drawer-list { max-height: none; }
}
.toc-loading { padding: 28px 10px; text-align: center; font-size: 13.5px; color: var(--r-muted); }
.toc-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 11px;
  border-radius: 11px;
  color: var(--r-text);
  font-size: 13.5px;
  transition: background 0.15s;
}
.toc-row:hover { background: var(--r-surface); }
.toc-row.is-current {
  background: color-mix(in srgb, var(--coral-500) 12%, var(--r-panel));
  border: 1px solid color-mix(in srgb, var(--coral-500) 35%, var(--r-line));
  font-weight: 700;
  color: var(--coral-600);
}
.reader-page[data-theme='dark'] .toc-row.is-current { color: #ff9c88; }
.toc-row-title { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toc-badge {
  flex: none;
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
}
.toc-badge-cur { background: var(--coral-500); color: #fff; }
.toc-badge-vip { background: var(--gold-100); color: var(--gold-600); border: 1px solid var(--gold-300); }
.toc-badge-ok { background: rgba(24, 155, 110, 0.14); color: #168a62; }

/* ---------- Khối Cài Đặt Trang Sách & Bộ Chọn Giọng AI ---------- */
.setting-block {
  padding: 13px 0;
  border-bottom: 1px solid var(--r-line);
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.setting-row-head { display: flex; align-items: center; justify-content: space-between; }
.setting-label { font-weight: 700; font-size: 13.5px; color: var(--r-text); }
.setting-val { font-size: 13.5px; color: var(--coral-600); font-variant-numeric: tabular-nums; }
.reader-page[data-theme='dark'] .setting-val { color: #ff9c88; }

.theme-cards {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}
.theme-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 8px 4px;
  border-radius: 13px;
  border: 1.5px solid var(--r-line);
  background: var(--r-surface);
  color: var(--r-text);
  transition: all 0.18s;
}
.theme-card small { font-size: 11px; font-weight: 600; white-space: nowrap; }
.theme-card .sw { width: 28px; height: 28px; border-radius: 50%; border: 1.5px solid rgba(0, 0, 0, 0.15); }
.sw-cream { background: #fcf8f0; }
.sw-white { background: #ffffff; }
.sw-sepia { background: #f2dfb7; }
.sw-pink { background: #fce2ea; }
.sw-dark { background: #1e1a1d; border-color: rgba(255, 255, 255, 0.25) !important; }
.theme-card.is-active {
  border-color: var(--coral-500);
  background: color-mix(in srgb, var(--coral-500) 10%, var(--r-panel));
  box-shadow: 0 0 0 2px rgba(230, 98, 74, 0.16);
}

.font-slider-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.step-circle {
  width: 38px; height: 38px;
  flex: none;
  border-radius: 50%;
  border: 1px solid var(--r-line);
  background: var(--r-surface);
  color: var(--r-text);
  font-weight: 700;
  font-size: 13.5px;
}
.step-circle:hover { border-color: var(--coral-400); }
.font-slider-row input[type='range'] {
  flex: 1;
  accent-color: var(--coral-500);
  cursor: pointer;
}

.seg {
  display: flex;
  flex-wrap: nowrap;
  gap: 3px;
  background: var(--r-surface);
  border: 1px solid var(--r-line);
  border-radius: 14px;
  padding: 3px;
}
.seg-full button { flex: 1 1 auto; min-width: 0; }
.seg button {
  height: 32px;
  padding: 0 7px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  font-size: 12px;
  font-weight: 600;
  color: var(--r-muted);
  white-space: nowrap;
}
.seg button.is-active {
  background: var(--r-panel);
  color: var(--coral-600);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}
.reader-page[data-theme='dark'] .seg button.is-active {
  background: #383035;
  color: #ff9c88;
}

/* ---------- Bộ Lọc & Danh Sách Giọng AI ---------- */
.audio-sheet-sec {
  padding: 12px 0;
  border-bottom: 1px solid var(--r-line);
}
.voice-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.seg-compact { flex: 1 1 240px; }
.seg-compact button { flex: 1 1 auto; height: 30px; font-size: 12px; padding: 0 8px; }

.voice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.voice-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  padding: 10px 11px;
  border-radius: 14px;
  border: 1.5px solid var(--r-line);
  background: var(--r-surface);
  text-align: left;
  transition: all 0.18s var(--ease);
}
.voice-card[hidden] { display: none !important; }
.vc-top {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}
.voice-card strong { font-size: 13px; color: var(--r-text); }
.vc-tag {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  background: var(--r-panel);
  color: var(--r-muted);
  border: 1px solid var(--r-line);
}
.voice-card small { font-size: 11px; color: var(--r-muted); line-height: 1.32; }
.voice-card:hover { border-color: var(--coral-300); }
.voice-card.is-active {
  border-color: var(--coral-500);
  background: color-mix(in srgb, var(--coral-500) 11%, var(--r-panel));
  box-shadow: 0 0 0 2px rgba(229, 98, 71, 0.15);
}
.voice-card.is-active .vc-tag {
  border-color: var(--coral-400);
  color: var(--coral-600);
}
.reader-page[data-theme='dark'] .voice-card.is-active .vc-tag { color: #ff9c88; }

/* ---------- v13.0: Linh Ảnh Đạo Tràng 2.5D Ngay Trong Trang Đọc Chương ---------- */
.listen-pill-25d {
  background: linear-gradient(135deg, #0b1324 0%, #162442 100%);
  border-color: rgba(244, 200, 106, 0.45);
  color: #fde68a !important;
  box-shadow: 0 4px 14px rgba(11, 19, 36, 0.22);
}
.listen-pill-25d:hover {
  background: linear-gradient(135deg, #101c34 0%, #1e3158 100%);
  border-color: rgba(244, 200, 106, 0.78);
}
.listen-pill-25d.is-open {
  background: linear-gradient(135deg, #f59e0b 0%, #b45309 100%);
  color: #fff !important;
  border-color: transparent;
}

.reader-la-stage[hidden] {
  display: none !important;
}

.reader-la-stage {
  margin: 0 0 26px;
  border-radius: 18px;
  overflow: hidden;
  background: #070b14;
  border: 1.5px solid rgba(244, 200, 106, 0.38);
  box-shadow: 0 16px 38px rgba(4, 8, 18, 0.34);
  color: #f8fafc;
}

.reader-la-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 14px;
  background: linear-gradient(90deg, rgba(12, 19, 36, 0.96), rgba(8, 12, 24, 0.96));
  border-bottom: 1px solid rgba(244, 200, 106, 0.22);
  font-family: var(--font-sans, system-ui, sans-serif);
}

.reader-la-badges {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

.reader-la-kicker {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: #fde68a;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(245, 158, 11, 0.16);
  border: 1px solid rgba(245, 158, 11, 0.38);
}

.reader-la-scene {
  font-size: 12.5px;
  font-weight: 700;
  color: #e2e8f0;
}

.reader-la-peers {
  font-size: 11.5px;
  color: #94a3b8;
}

.reader-la-close {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.06);
  color: #cbd5e1;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  flex: none;
}
.reader-la-close:hover {
  background: rgba(239, 68, 68, 0.22);
  color: #fff;
  border-color: rgba(239, 68, 68, 0.45);
}

.reader-la-viewport {
  position: relative;
  width: 100%;
  height: clamp(205px, 31vw, 276px);
  background: #060a14;
  transition: height 0.24s ease;
}

.reader-la-stage.is-pond-mode .reader-la-viewport {
  height: clamp(275px, 45vw, 420px);
  background: #0c3b47;
}

.reader-la-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: pointer;
  touch-action: manipulation;
}

.reader-la-caption {
  position: absolute;
  top: 10px;
  left: 14px;
  right: 14px;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(6, 10, 20, 0.68);
  border: 1px solid rgba(244, 200, 106, 0.24);
  color: #fef3c7;
  font-family: var(--font-display, Georgia, serif);
  font-size: 12.5px;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  backdrop-filter: blur(6px);
}

.reader-la-scroll[hidden] {
  display: none !important;
}

.reader-la-scroll {
  position: absolute;
  top: 42px;
  left: 50%;
  transform: translateX(-50%);
  padding: 5px 16px;
  border-radius: 10px;
  background: linear-gradient(90deg, #fef3c7, #fde68a);
  border: 1.5px solid #b45309;
  color: #291507;
  font-size: 12px;
  font-weight: 800;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55);
  pointer-events: none;
  z-index: 4;
}

.reader-la-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(8, 13, 24, 0.96);
  border-top: 1px solid rgba(255, 255, 255, 0.09);
  font-family: var(--font-sans, system-ui, sans-serif);
}

.reader-la-move,
.reader-la-paths {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
}

.reader-la-bar button {
  height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.06);
  color: #e2e8f0;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.reader-la-bar button:hover,
.reader-la-bar button.is-on {
  background: linear-gradient(135deg, #fde68a, #f59e0b);
  color: #1e1204;
  border-color: transparent;
}
