/* ============================================================
   TTRUYEN — Trình đọc chương
   ============================================================ */
[data-bg="dark"]  { --read-bg: #0f1117; --read-surface: #1a1d27; --read-text: #d4d8e2; --read-border: rgba(255,255,255,0.06); --read-muted: #5c6270; --ui-bg: rgba(15,17,23,0.96); }
[data-bg="light"] { --read-bg: #f9f7f2; --read-surface: #ffffff; --read-text: #2d3748; --read-border: rgba(0,0,0,0.08); --read-muted: #9ca3af; --ui-bg: rgba(249,247,242,0.96); }
[data-bg="sepia"] { --read-bg: #f4efe4; --read-surface: #faf6ed; --read-text: #4a3728; --read-border: rgba(0,0,0,0.08); --read-muted: #9c8776; --ui-bg: rgba(244,239,228,0.96); }
[data-bg="green"] { --read-bg: #1a2318; --read-surface: #212b1f; --read-text: #c8d4c4; --read-border: rgba(255,255,255,0.06); --read-muted: #607060; --ui-bg: rgba(26,35,24,0.96); }

/* Mặc định nếu chưa set data-bg */
:root { --read-bg: #0f1117; --read-surface: #1a1d27; --read-text: #d4d8e2; --read-border: rgba(255,255,255,0.06); --read-muted: #5c6270; --ui-bg: rgba(15,17,23,0.96); }

[data-font="serif"] .chapter-content { font-family: 'Lora', 'Source Serif 4', Georgia, serif; }
[data-font="sans"]  .chapter-content { font-family: 'Be Vietnam Pro', sans-serif; }

[data-size="15"] .chapter-content { font-size: 15px; }
[data-size="16"] .chapter-content { font-size: 16px; }
[data-size="17"] .chapter-content { font-size: 17px; }
[data-size="18"] .chapter-content { font-size: 18px; }
[data-size="20"] .chapter-content { font-size: 20px; }
[data-size="22"] .chapter-content { font-size: 22px; }
[data-size="24"] .chapter-content { font-size: 24px; }

* { margin: 0; padding: 0; box-sizing: border-box; }
body { background: var(--read-bg); color: var(--read-text); min-height: 100vh; transition: background 0.3s ease, color 0.3s ease; font-family: 'Be Vietnam Pro', sans-serif; padding-bottom: 60px; }
a { color: inherit; text-decoration: none; }
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(245,158,11,0.4); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #f59e0b; }

/* Top bar */
.top-bar { background: var(--ui-bg); backdrop-filter: blur(16px); border-bottom: 1px solid var(--read-border); position: sticky; top: 0; z-index: 1000; padding: 10px 0; transition: transform 0.3s ease; }
.top-bar.hidden { transform: translateY(-100%); }
.logo-sm { font-family: 'Playfair Display', serif; font-size: 1.2rem; font-weight: 700; color: #f59e0b; }
.story-breadcrumb { font-size: 0.78rem; color: var(--read-muted); }
.story-breadcrumb a:hover { color: #f59e0b; }
.story-breadcrumb .sep { margin: 0 6px; }
.top-actions { display: flex; gap: 8px; align-items: center; }
.icon-btn { width: 34px; height: 34px; background: transparent; border: 1px solid var(--read-border); border-radius: 8px; display: flex; align-items: center; justify-content: center; color: var(--read-muted); cursor: pointer; transition: all 0.2s; font-size: 0.85rem; }
.icon-btn:hover { border-color: #f59e0b; color: #f59e0b; }
.icon-btn.active { background: rgba(245,158,11,0.12); border-color: rgba(245,158,11,0.3); color: #f59e0b; }

/* Progress bar */
.read-progress-bar { position: fixed; top: 0; left: 0; height: 3px; background: linear-gradient(90deg, #f59e0b, #f97316); z-index: 9999; transition: width 0.1s linear; border-radius: 0 2px 2px 0; }

/* Chapter nav */
.chapter-nav-bar { background: var(--read-surface); border-bottom: 1px solid var(--read-border); padding: 10px 0; }
.chapter-select-wrap { display: flex; align-items: center; gap: 10px; flex: 1; max-width: 500px; margin: 0 auto; }
.chapter-select { flex: 1; background: var(--read-bg); border: 1px solid var(--read-border); border-radius: 8px; padding: 7px 14px; color: var(--read-text); font-size: 0.82rem; font-family: 'Be Vietnam Pro', sans-serif; outline: none; cursor: pointer; transition: border-color 0.2s; }
.chapter-select:focus { border-color: #f59e0b; }
.nav-chapter-btn { background: transparent; border: 1px solid var(--read-border); border-radius: 8px; padding: 7px 14px; color: var(--read-text); font-size: 0.82rem; font-weight: 600; cursor: pointer; font-family: 'Be Vietnam Pro', sans-serif; transition: all 0.2s; display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.nav-chapter-btn:hover { border-color: #f59e0b; color: #f59e0b; }
.nav-chapter-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.nav-chapter-btn.next { background: #f59e0b; border-color: #f59e0b; color: #000; }
.nav-chapter-btn.next:hover { background: #fbbf24; }

/* Settings panel */
.settings-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 2000; display: none; align-items: flex-start; justify-content: center; padding-top: 70px; }
.settings-overlay.open { display: flex; }
.settings-panel { background: var(--read-surface); border: 1px solid var(--read-border); border-radius: 16px; padding: 24px; width: 100%; max-width: 480px; box-shadow: 0 20px 60px rgba(0,0,0,0.5); animation: slideDown 0.25s ease; }
@keyframes slideDown { from { transform: translateY(-20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.settings-title { font-size: 1rem; font-weight: 700; margin-bottom: 20px; padding-bottom: 12px; border-bottom: 1px solid var(--read-border); display: flex; align-items: center; justify-content: space-between; }
.close-settings { width: 28px; height: 28px; background: transparent; border: 1px solid var(--read-border); border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--read-muted); transition: all 0.2s; }
.close-settings:hover { border-color: #ef4444; color: #ef4444; }
.settings-group { margin-bottom: 20px; }
.settings-label { font-size: 0.8rem; font-weight: 600; color: var(--read-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 10px; display: block; }
.font-options, .bg-options, .line-options, .width-options { display: flex; gap: 8px; }
.font-option { flex: 1; padding: 10px 8px; text-align: center; background: var(--read-bg); border: 2px solid var(--read-border); border-radius: 10px; cursor: pointer; transition: all 0.2s; font-size: 0.85rem; }
.font-option.serif-opt { font-family: 'Lora', serif; }
.font-option.sans-opt { font-family: 'Be Vietnam Pro', sans-serif; }
.font-option.active, .font-option:hover { border-color: #f59e0b; color: #f59e0b; }
.size-control { display: flex; align-items: center; gap: 12px; }
.size-btn { width: 32px; height: 32px; background: var(--read-bg); border: 1px solid var(--read-border); border-radius: 8px; display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--read-text); font-size: 0.9rem; transition: all 0.2s; }
.size-btn:hover { border-color: #f59e0b; color: #f59e0b; }
.size-display { flex: 1; text-align: center; background: var(--read-bg); border: 1px solid var(--read-border); border-radius: 8px; padding: 6px; font-size: 0.85rem; font-weight: 600; }
.bg-option { flex: 1; height: 44px; border-radius: 10px; cursor: pointer; border: 2px solid transparent; transition: all 0.2s; display: flex; align-items: center; justify-content: center; font-size: 0.7rem; font-weight: 700; }
.bg-dark { background: #0f1117; color: #d4d8e2; }
.bg-light { background: #f9f7f2; color: #2d3748; }
.bg-sepia { background: #f4efe4; color: #4a3728; }
.bg-green { background: #1a2318; color: #c8d4c4; }
.bg-option.active { border-color: #f59e0b; }
.bg-option:hover { transform: scale(1.03); }
.line-option, .width-option { flex: 1; padding: 8px 4px; text-align: center; background: var(--read-bg); border: 2px solid var(--read-border); border-radius: 8px; cursor: pointer; font-size: 0.78rem; transition: all 0.2s; }
.line-option.active, .line-option:hover, .width-option.active, .width-option:hover { border-color: #f59e0b; color: #f59e0b; }

/* Chapter drawer */
.drawer-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 2000; display: none; }
.drawer-overlay.open { display: block; }
.chapter-drawer { position: fixed; left: 0; top: 0; bottom: 0; width: 320px; background: var(--read-surface); border-right: 1px solid var(--read-border); z-index: 2001; transform: translateX(-100%); transition: transform 0.3s ease; display: flex; flex-direction: column; }
.chapter-drawer.open { transform: translateX(0); }
.drawer-header { padding: 16px 20px; border-bottom: 1px solid var(--read-border); display: flex; align-items: center; justify-content: space-between; }
.drawer-title { font-size: 0.95rem; font-weight: 700; }
.drawer-close { width: 28px; height: 28px; background: transparent; border: 1px solid var(--read-border); border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--read-muted); }
.drawer-search { padding: 12px 16px; border-bottom: 1px solid var(--read-border); }
.drawer-search input { width: 100%; background: var(--read-bg); border: 1px solid var(--read-border); border-radius: 8px; padding: 7px 12px; color: var(--read-text); font-size: 0.82rem; font-family: 'Be Vietnam Pro', sans-serif; outline: none; }
.drawer-chapters { flex: 1; overflow-y: auto; }
.drawer-chapter-item { padding: 10px 20px; border-bottom: 1px solid var(--read-border); cursor: pointer; transition: all 0.15s; font-size: 0.82rem; display:block; }
.drawer-chapter-item:hover { background: rgba(245,158,11,0.06); color: #f59e0b; }
.drawer-chapter-item.current { background: rgba(245,158,11,0.12); color: #f59e0b; font-weight: 700; border-left: 3px solid #f59e0b; }
.drawer-chapter-title { font-size: 0.72rem; color: var(--read-muted); margin-top: 1px; }

/* Reading area */
.reading-wrap { max-width: var(--read-width, 720px); margin: 0 auto; padding: 40px 24px 80px; }
.reading-wrap.width-narrow { --read-width: 580px; }
.reading-wrap.width-normal { --read-width: 720px; }
.reading-wrap.width-wide { --read-width: 900px; }
.reading-wrap.width-full { --read-width: 100%; }
.chapter-header-area { text-align: center; margin-bottom: 40px; padding-bottom: 32px; border-bottom: 1px solid var(--read-border); }
.chapter-story-title { font-size: 0.8rem; font-weight: 600; color: #f59e0b; text-transform: uppercase; letter-spacing: 2px; margin-bottom: 10px; }
.chapter-number { font-family: 'Playfair Display', serif; font-size: 1.1rem; color: var(--read-muted); margin-bottom: 6px; }
.chapter-title-main { font-family: 'Playfair Display', serif; font-size: 1.9rem; font-weight: 700; line-height: 1.3; margin-bottom: 16px; }
.chapter-meta-row { display: flex; align-items: center; justify-content: center; gap: 20px; font-size: 0.78rem; color: var(--read-muted); flex-wrap: wrap; }
.chapter-meta-row i { margin-right: 4px; }

.chapter-content { font-size: 18px; line-height: var(--read-line, 1.9); color: var(--read-text); transition: all 0.25s; letter-spacing: 0.01em; }
.chapter-content.line-compact { --read-line: 1.6; }
.chapter-content.line-normal { --read-line: 1.9; }
.chapter-content.line-relaxed { --read-line: 2.2; }
.chapter-content p { margin-bottom: 1.4em; text-indent: 2em; }
.chapter-content p:first-of-type { text-indent: 0; }
.chapter-content p:first-of-type::first-letter { font-family: 'Playfair Display', serif; font-size: 3.5em; font-weight: 700; color: #f59e0b; float: left; line-height: 0.75; padding-right: 8px; padding-top: 4px; }
.chapter-divider { text-align: center; margin: 40px 0; display: flex; align-items: center; gap: 16px; }
.chapter-divider::before, .chapter-divider::after { content: ''; flex: 1; height: 1px; background: var(--read-border); }
.divider-icon { color: #f59e0b; font-size: 0.85rem; letter-spacing: 6px; }

.chapter-end { text-align: center; padding: 40px 0 20px; border-top: 1px solid var(--read-border); margin-top: 40px; }
.end-title { font-family: 'Playfair Display', serif; font-size: 1.1rem; color: var(--read-muted); margin-bottom: 6px; }
.end-story { font-size: 0.8rem; color: var(--read-muted); margin-bottom: 24px; }
.end-actions { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }
.btn-end { padding: 11px 24px; border-radius: 50px; font-size: 0.88rem; font-weight: 600; cursor: pointer; font-family: 'Be Vietnam Pro', sans-serif; display: flex; align-items: center; gap: 8px; transition: all 0.2s; border: 1.5px solid; }
.btn-end.primary { background: #f59e0b; border-color: #f59e0b; color: #000; }
.btn-end.primary:hover { background: #fbbf24; }
.btn-end.secondary { background: transparent; border-color: var(--read-border); color: var(--read-text); }
.btn-end.secondary:hover { border-color: #f59e0b; color: #f59e0b; }
.btn-end:disabled { opacity: 0.4; cursor: not-allowed; }

/* Bottom toolbar */
.bottom-toolbar { position: fixed; bottom: 0; left: 0; right: 0; background: var(--ui-bg); backdrop-filter: blur(16px); border-top: 1px solid var(--read-border); padding: 10px 20px; display: flex; align-items: center; justify-content: space-between; z-index: 900; transition: transform 0.3s ease; }
.bottom-toolbar.hidden { transform: translateY(100%); }
.toolbar-left, .toolbar-right { display: flex; gap: 8px; }
.toolbar-center { flex: 1; max-width: 300px; margin: 0 auto; }
.progress-slider-wrap { display: flex; align-items: center; gap: 8px; }
.progress-label { font-size: 0.72rem; color: var(--read-muted); min-width: 28px; text-align: center; }
.progress-slider { flex: 1; -webkit-appearance: none; appearance: none; height: 4px; background: var(--read-border); border-radius: 2px; outline: none; cursor: pointer; }
.progress-slider::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: #f59e0b; cursor: pointer; box-shadow: 0 2px 8px rgba(245,158,11,0.4); }
.progress-slider::-moz-range-thumb { width: 16px; height: 16px; border:none; border-radius: 50%; background: #f59e0b; cursor: pointer; }
.tool-btn { display: flex; align-items: center; gap: 5px; padding: 7px 12px; background: transparent; border: 1px solid var(--read-border); border-radius: 8px; color: var(--read-text); font-size: 0.78rem; font-weight: 500; cursor: pointer; transition: all 0.2s; font-family: 'Be Vietnam Pro', sans-serif; white-space: nowrap; }
.tool-btn:hover { border-color: #f59e0b; color: #f59e0b; }
.tool-btn.active { background: rgba(245,158,11,0.12); border-color: rgba(245,158,11,0.3); color: #f59e0b; }
.tool-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.tool-btn i { font-size: 0.8rem; }

.auto-scroll-indicator { position: fixed; right: 20px; bottom: 70px; background: rgba(245,158,11,0.9); color: #000; border-radius: 50px; padding: 6px 14px; font-size: 0.75rem; font-weight: 700; display: none; align-items: center; gap: 6px; z-index: 901; backdrop-filter: blur(8px); }
.auto-scroll-indicator.active { display: flex; }

/* Donate */
.donate-bar { background: linear-gradient(135deg, rgba(245,158,11,0.08), rgba(249,115,22,0.08)); border: 1px solid rgba(245,158,11,0.2); border-radius: 12px; padding: 16px 20px; display: flex; align-items: center; justify-content: space-between; margin-top: 24px; flex-wrap: wrap; gap: 12px; }
.donate-text h5 { font-size: 0.88rem; font-weight: 700; color: #f59e0b; margin-bottom: 2px; }
.donate-text p { font-size: 0.78rem; color: var(--read-muted); }
.btn-donate { background: linear-gradient(135deg, #f59e0b, #f97316); color: #000; border: none; border-radius: 50px; padding: 8px 20px; font-size: 0.82rem; font-weight: 700; font-family: 'Be Vietnam Pro', sans-serif; cursor: pointer; transition: all 0.2s; }
.btn-donate:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(245,158,11,0.3); }

/* Bình luận (trang đọc) */
.quick-comment { background: var(--read-surface); border: 1px solid var(--read-border); border-radius: 16px; padding: 24px; margin-top: 32px; }
.comments-header { font-size: 0.95rem; font-weight: 700; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; padding: 0; border: none; }
.comments-header i { color: #f59e0b; }
.comment-form-wrap { padding: 0 0 16px !important; border-bottom: 1px solid var(--read-border) !important; }
.comment-input { width: 100%; background: var(--read-bg); border: 1px solid var(--read-border); border-radius: 10px; padding: 12px 16px; color: var(--read-text); font-size: 0.88rem; font-family: 'Be Vietnam Pro', sans-serif; resize: vertical; min-height: 80px; outline: none; transition: border-color 0.2s; }
.comment-input:focus { border-color: #f59e0b; }
.btn-submit-comment { margin-top: 10px; background: #f59e0b; color: #000; border: none; border-radius: 50px; padding: 8px 20px; font-size: 0.82rem; font-weight: 700; font-family: 'Be Vietnam Pro', sans-serif; cursor: pointer; transition: all 0.2s; }
.btn-submit-comment:hover { background: #fbbf24; }
.comment-list { list-style: none; padding: 16px 0 0; margin: 0; }
.comment-list ol.children { list-style: none; padding-left: 40px; }
.comment-item { padding: 14px 0; border-bottom: 1px solid var(--read-border); }
.comment-top { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 6px; }
.comment-user-av { width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 0.75rem; font-weight: 700; color: #fff; flex-shrink: 0; }
.comment-username { font-size: 0.8rem; font-weight: 700; }
.comment-time { font-size: 0.68rem; color: var(--read-muted); }
.comment-text { font-size: 0.85rem; color: var(--read-text); line-height: 1.6; padding-left: 40px; margin-bottom: 6px; }
.comment-actions { display: flex; gap: 16px; padding-left: 40px; }
.comment-action-btn { font-size: 0.72rem; color: var(--read-muted); cursor: pointer; background: none; border: none; font-family: 'Be Vietnam Pro', sans-serif; display:inline-flex; align-items:center; gap:4px; }
.comment-action-btn:hover { color: #f59e0b; }
.comment-form .comment-reply-title { display: none; }
.comment-form .comment-form-comment { margin: 0; }
.comment-form p.form-submit { margin: 0; }
.tt-pagination .nav-links, .comment-list + div .page-numbers { display:flex; gap:6px; justify-content:center; }

@media (max-width: 768px) {
  .reading-wrap { padding: 20px 16px 80px; }
  .chapter-title-main { font-size: 1.5rem; }
  .chapter-content { font-size: 16px !important; }
  .chapter-meta-row { flex-wrap: wrap; gap: 10px; }
  .toolbar-center { max-width: 160px; }
  .chapter-drawer { width: 280px; }
}
