/* Font Google duoc nap qua <link> trong index.html (nhanh hon @import - xem ghi chu o do) */

:root, html[data-theme="dark"] {
  --ink: #12161d;
  --panel: #1b212b;
  --panel-2: #232a36;
  --hairline: #313a48;
  --text: #d9dee6;
  --text-dim: #8b96a5;
  --gold: #c9a24b;
  --gold-soft: #e2c383;
  --paper: #f3ead4;
  --paper-text: #2b2115;
  --paper-text-dim: #6b5c42;
  --danger: #c96b4b;
  --radius: 3px;
  --shadow: 0 20px 60px rgba(0,0,0,.5);
}

html[data-theme="light"] {
  --ink: #f4efe2;
  --panel: #ffffff;
  --panel-2: #f0eadb;
  --hairline: #ddd3ba;
  --text: #2b2115;
  --text-dim: #77694f;
  --gold: #9c7226;
  --gold-soft: #7c5b1e;
  --paper: #fbf7ec;
  --paper-text: #2b2115;
  --paper-text-dim: #6b5c42;
  --danger: #b0492b;
  --radius: 3px;
  --shadow: 0 20px 50px rgba(60,45,20,.18);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100vh;
  background: var(--ink);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  transition: background-color .15s ease, color .15s ease;
  overflow-x: hidden; /* an toan cho cac khoi "tran vien" nhu anh bia profile (rong hon container cha) */
}

#app { min-height: 100vh; display: flex; flex-direction: column; }

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--hairline);
  background: linear-gradient(180deg, #171d26, #14181f);
  position: sticky;
  top: 0;
  z-index: 20;
}
/* Che do sang: thanh top-bar mac dinh dung mau gradient rat toi (gan den), tren nen sang
   gay chenh lech tuong phan manh, nhin lau de moi mat. Doi sang tong mau giay am (paper)
   cung he mau voi theme sang de dju hon, van giu phong cach van hoc/giay cu cua web. */
html[data-theme="light"] .topbar {
  background: linear-gradient(180deg, var(--paper), var(--panel-2));
}
.brand { display: flex; align-items: baseline; gap: 8px; cursor: pointer; user-select: none; }
.brand:hover .brand-name { color: var(--gold-soft); }

.searchbox { flex: 0 0 260px; }
.searchbox input {
  width: 100%; font: inherit; font-size: 14px; padding: 8px 12px;
  border-radius: var(--radius); border: 1px solid var(--hairline);
  background: var(--panel-2); color: var(--text);
}
.searchbox input:focus { outline: none; border-color: var(--gold); }
.brand-mark {
  font-family: 'Literata', serif;
  font-size: 22px;
  color: var(--gold-soft);
  border: 1px solid var(--hairline);
  width: 30px; height: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius);
}
.brand-name { font-family: 'Literata', serif; font-weight: 600; font-size: 18px; letter-spacing: 0.02em; }

.topnav { display: flex; gap: 4px; flex: 1; }
.navbtn {
  background: none; border: none; color: var(--text-dim);
  font: inherit; font-size: 14px; padding: 8px 14px; cursor: pointer;
  border-radius: var(--radius); transition: color .15s, background .15s;
}
.navbtn:hover { color: var(--text); background: var(--panel-2); }
.navbtn.active { color: var(--ink); background: var(--gold-soft); font-weight: 600; }

.authbox { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.authbox .who { color: var(--text-dim); display: flex; align-items: center; gap: 7px; text-decoration: none; }
.authbox .who:hover strong { color: var(--gold-soft); }
.avatar-mini {
  width: 24px; height: 24px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-size: 12px; font-weight: 700; font-family: 'Literata', serif;
  vertical-align: middle; flex-shrink: 0;
}
.btn {
  font: inherit; font-size: 14px; padding: 8px 16px; border-radius: var(--radius);
  border: 1px solid var(--hairline); background: var(--panel-2); color: var(--text);
  cursor: pointer; transition: border-color .15s, background .15s;
}
.btn:hover { border-color: var(--gold); }
.btn.primary { background: var(--gold-soft); color: var(--ink); border-color: var(--gold-soft); font-weight: 600; }
.btn.primary:hover { background: var(--gold); }
.btn.ghost { background: none; }
.btn.danger { color: var(--danger); border-color: var(--danger); background: none; }
.btn:disabled { opacity: .5; cursor: default; }

/* ---------- Main content ---------- */
main { flex: 1; padding: 32px 28px 64px; max-width: 1180px; margin: 0 auto; width: 100%; }

h1, h2, h3 { font-family: 'Literata', serif; margin: 0 0 4px; }
.section-title { font-size: 22px; font-weight: 600; margin-bottom: 20px; color: var(--text); }
.muted { color: var(--text-dim); }
p { line-height: 1.6; }

/* ---------- Library grid: sach xep tren ke ---------- */
.shelf-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 22px 18px;
}
.book {
  cursor: pointer;
  display: flex; flex-direction: column; gap: 8px;
}
.spine {
  aspect-ratio: 2 / 3;
  border-radius: var(--radius) 6px 6px var(--radius);
  display: flex; align-items: flex-end;
  padding: 14px 12px;
  position: relative;
  box-shadow: -4px 0 0 rgba(0,0,0,.25) inset, 0 6px 14px rgba(0,0,0,.35);
  transition: transform .15s ease;
  overflow: hidden;
}
.book:hover .spine { transform: translateY(-4px); }
.spine::before {
  content: '';
  position: absolute; left: 8px; top: 10px; bottom: 10px; width: 1px;
  background: rgba(255,255,255,.18);
}
.spine-title {
  font-family: 'Literata', serif; font-weight: 600; font-size: 14px; line-height: 1.3;
  color: rgba(255,255,255,.94); text-shadow: 0 1px 2px rgba(0,0,0,.4);
}
.book-meta { font-size: 12px; color: var(--text-dim); }
.book-meta .src { color: var(--gold-soft); }

.empty-shelf {
  border: 1px dashed var(--hairline); border-radius: var(--radius);
  padding: 48px 24px; text-align: center; color: var(--text-dim);
}

/* ---------- Forms ---------- */
.card {
  background: var(--panel); border: 1px solid var(--hairline); border-radius: 6px;
  padding: 24px; max-width: 560px;
}
.tabs { display: flex; gap: 4px; margin-bottom: 20px; border-bottom: 1px solid var(--hairline); }
.tab {
  background: none; border: none; color: var(--text-dim); font: inherit; font-size: 14px;
  padding: 10px 4px; margin-right: 20px; cursor: pointer; border-bottom: 2px solid transparent;
}
.tab.active { color: var(--gold-soft); border-color: var(--gold-soft); }

.field { margin-bottom: 16px; display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; color: var(--text-dim); }
.field input[type=text], .field input[type=password], .field input[type=url], .field input[type=email], .field input[type=number], .field textarea {
  font: inherit; font-size: 14px; padding: 10px 12px; border-radius: var(--radius);
  border: 1px solid var(--hairline); background: var(--panel-2); color: var(--text);
}
.field textarea { min-height: 160px; resize: vertical; font-family: 'Literata', serif; }
.field input[type=file] { font-size: 13px; color: var(--text-dim); }
.hint { font-size: 12px; color: var(--text-dim); }
.error-msg { color: var(--danger); font-size: 13px; margin-top: -6px; margin-bottom: 12px; }
.form-actions { display: flex; gap: 10px; align-items: center; }

/* ---------- Novel detail ---------- */
.breadcrumb { font-size: 13px; color: var(--text-dim); margin-bottom: 14px; }
.breadcrumb a { color: var(--text-dim); text-decoration: none; }
.breadcrumb a:hover { color: var(--gold-soft); }
.novel-detail-layout { display: grid; grid-template-columns: 1fr 280px; gap: 32px; align-items: start; }
.novel-sidebar { display: flex; flex-direction: column; gap: 18px; }
.side-panel { background: var(--panel); border: 1px solid var(--hairline); border-radius: 6px; padding: 18px; }
.side-panel h4 {
  font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-dim); margin: 0 0 12px;
}
.uploader-card { display: flex; align-items: center; gap: 10px; }
.uploader-card .u-main { flex: 1; min-width: 0; }
.uploader-card .u-name { font-weight: 600; font-size: 14px; }
.uploader-card .u-name:hover { color: var(--gold-soft); }
.uploader-card .u-meta { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
@media (max-width: 860px) { .novel-detail-layout { grid-template-columns: 1fr; } }

/* ---------- Bang xep hang (thanh ben trang chi tiet truyen) ---------- */
.leaderboard-tabs { display: flex; gap: 4px; margin-bottom: 10px; }
.leaderboard-tabs button {
  flex: 1; background: var(--panel-2); border: 1px solid var(--hairline); color: var(--text-dim);
  font: inherit; font-size: 12px; padding: 6px 0; border-radius: var(--radius); cursor: pointer;
}
.leaderboard-tabs button.active { background: var(--gold); color: #1a1608; border-color: var(--gold); font-weight: 600; }
.leaderboard-list .rank-num {
  width: 20px; flex-shrink: 0; text-align: center; font-weight: 700; color: var(--text-dim); font-size: 13px;
}
.leaderboard-list li:nth-child(1) .rank-num,
.leaderboard-list li:nth-child(2) .rank-num,
.leaderboard-list li:nth-child(3) .rank-num { color: var(--gold-soft); }

.novel-header { display: flex; gap: 24px; margin-bottom: 12px; flex-wrap: wrap; }
.novel-header .spine { width: 150px; flex-shrink: 0; }
.novel-info { flex: 1; min-width: 240px; }
.novel-info h1 { font-size: 26px; }
.novel-code { font-size: 12px; color: var(--text-dim); font-weight: 400; margin-left: 8px; }
.info-rows { margin: 14px 0; font-size: 14px; display: flex; flex-direction: column; gap: 7px; }
.info-rows .info-row { display: flex; gap: 8px; align-items: center; }
.info-rows .info-label { color: var(--text-dim); flex-shrink: 0; width: 76px; }
.info-row-uploader .info-label { align-self: flex-start; margin-top: 3px; }
.info-uploader { display: inline-flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; }
.info-uploader:hover { color: var(--gold-soft); }
.info-uploader .avatar-mini { width: 26px; height: 26px; font-size: 12px; }
.status-pill { font-size: 12px; padding: 2px 9px; border-radius: 10px; border: 1px solid var(--hairline); }
.status-pill.completed { color: #3fae5c; border-color: #3fae5c; }
.status-pill.ongoing { color: var(--gold-soft); border-color: var(--gold-soft); }
.badge {
  display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 10px;
  border: 1px solid var(--hairline); color: var(--text-dim); margin-top: 6px;
}
.btn.bookmark-btn { display: inline-flex; align-items: center; gap: 6px; }
.chapter-list-head { display: flex; align-items: center; justify-content: space-between; margin: 26px 0 8px; flex-wrap: wrap; gap: 8px; }
.chapter-list-head h3 { margin: 0; }
.chapter-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--hairline); }
.chapter-list li {
  border-bottom: 1px solid var(--hairline); display: flex; align-items: center;
}
.chapter-list button[data-chapter] {
  flex: 1; min-width: 0; text-align: left; background: none; border: none; color: var(--text);
  font: inherit; font-size: 14px; padding: 12px 4px; cursor: pointer; display: flex; justify-content: space-between; gap: 10px;
}
.chapter-list button:hover { color: var(--gold-soft); }
.chapter-list .idx { color: var(--text-dim); margin-right: 10px; width: 34px; display: inline-block; }
.chapter-list .chapter-meta { color: var(--text-dim); font-size: 12px; flex-shrink: 0; display: flex; gap: 10px; }
.add-chapter-form { margin: 14px 0 0; }
.chapter-row-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; padding-right: 4px; }
.chapter-edit-btn, .chapter-del-btn {
  font-size: 12px; cursor: pointer; background: none; border: none; font: inherit; padding: 0; white-space: nowrap;
}
.chapter-edit-btn { color: var(--text-dim); }
.chapter-edit-btn:hover { color: var(--gold-soft); text-decoration: underline; }
.chapter-del-btn { color: var(--danger); }
.chapter-del-btn:hover { text-decoration: underline; }

/* ---------- Reader (trang giay duoi den doc) ---------- */
.reader-wrap { display: flex; justify-content: center; background: var(--ink); }
.reader-page {
  background: var(--paper); color: var(--paper-text);
  max-width: var(--reader-width, 720px); width: 100%; padding: 56px 8vw 90px;
  border-radius: 4px; box-shadow: var(--shadow);
  font-family: 'Literata', serif;
}
.reader-page h2 { font-size: 24px; margin-bottom: 26px; color: var(--paper-text); }
.reader-page .body-text { font-size: 18px; line-height: 1.85; white-space: pre-wrap; }
/* Chan doc gia thuong sao chep noi dung chuong (khong ap dung khi chu truyen/tac gia/admin
   dang xem - ho khong bi gan class nay, xem app.js) */
.reader-page.no-copy .body-text { user-select: none; -webkit-user-select: none; -moz-user-select: none; }
.reader-nav {
  display: flex; justify-content: space-between; align-items: center;
  margin: 40px auto 0; max-width: var(--reader-width, 720px); padding: 0 8px;
}
.reader-nav .btn { background: var(--panel-2); color: var(--text); border-color: var(--hairline); }
.reader-topbar {
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px;
  max-width: var(--reader-width, 720px); margin: 0 auto 18px; padding: 0 8px;
}
.reader-topbar-right { display: flex; align-items: center; gap: 14px; }

/* ---------- Chinh co chu trang doc ---------- */
.font-size-control { display: flex; align-items: center; gap: 2px; }
.font-size-btn {
  width: 28px; height: 28px; border-radius: var(--radius); border: 1px solid var(--hairline);
  background: var(--panel-2); color: var(--text); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; font: inherit;
}
.font-size-btn:hover { border-color: var(--gold); }
.font-size-btn:first-child { font-size: 11px; }
.font-size-btn:last-child { font-size: 16px; }
.font-size-value { min-width: 26px; text-align: center; font-size: 12px; color: var(--text-dim); }

/* ---------- Da doc chuong xong (tu dong danh dau khi luot het chuong) ---------- */
.chapter-list .read-mark {
  color: #3fae5c; font-size: 12px; cursor: pointer; background: none; border: none;
  font: inherit; padding: 0; margin-left: 10px; white-space: nowrap; flex-shrink: 0;
}
.chapter-list .read-mark:hover { color: #3fae5c; text-decoration: underline; }
.reader-read-notice {
  max-width: 720px; margin: 18px auto 0; padding: 0 8px;
  color: #3fae5c; font-size: 13px; display: flex; align-items: center; gap: 6px;
}

.loading { color: var(--text-dim); padding: 40px 0; text-align: center; }

/* ---------- Follow + view count ---------- */
.stat-row { display: flex; gap: 16px; flex-wrap: wrap; margin: 10px 0; font-size: 13px; color: var(--text-dim); }
.stat-row .stat { display: flex; align-items: center; gap: 5px; }
.btn.following { background: var(--panel-2); color: var(--gold-soft); border-color: var(--gold-soft); }

/* ---------- Comments ---------- */
.comments-section { margin-top: 36px; max-width: 720px; }
.comments-section h3 { font-size: 17px; margin-bottom: 14px; }
.comment-form { margin-bottom: 18px; }
.comment-form textarea {
  width: 100%; min-height: 44px; max-height: 140px; font: inherit; font-size: 14px;
  padding: 10px 12px; border-radius: var(--radius); border: 1px solid var(--hairline);
  background: var(--panel-2); color: var(--text); resize: vertical;
}
.comment-list { list-style: none; margin: 0; padding: 0; }
.comment-item {
  border-bottom: 1px solid var(--hairline); padding: 12px 0; font-size: 14px;
}
.comment-item .comment-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 4px; }
.comment-item .comment-author { display: inline-flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.comment-item .comment-user { color: var(--gold-soft); font-weight: 600; }
.comment-item .comment-time { color: var(--text-dim); font-size: 12px; }
.comment-item .comment-body { line-height: 1.5; white-space: pre-wrap; }
.comment-item .del-comment { background: none; border: none; color: var(--text-dim); cursor: pointer; font-size: 12px; }
.comment-item .del-comment:hover { color: var(--danger); }
.comment-empty { color: var(--text-dim); font-size: 13px; padding: 8px 0; }
.comment-item .comment-image { max-width: 220px; max-height: 220px; border-radius: var(--radius); margin-top: 8px; display: block; cursor: zoom-in; }
.comment-form-row { display: flex; gap: 10px; }
.comment-form-tools { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.comment-attach-btn {
  background: none; border: 1px solid var(--hairline); border-radius: var(--radius); color: var(--text-dim);
  font: inherit; font-size: 12px; padding: 5px 10px; cursor: pointer;
}
.comment-attach-btn:hover { border-color: var(--gold); color: var(--text); }
.comment-image-preview { position: relative; display: inline-block; margin-top: 8px; }
.comment-image-preview img { max-height: 90px; border-radius: var(--radius); display: block; }
.pending-image-order { display: block; margin-top: 3px; font-size: 11px; color: var(--text-dim); text-align: center; }
.comment-image-preview button {
  position: absolute; top: -8px; right: -8px; width: 20px; height: 20px; border-radius: 50%;
  border: 1px solid var(--hairline); background: var(--panel); color: var(--text); font-size: 12px;
  cursor: pointer; line-height: 1; display: flex; align-items: center; justify-content: center;
}

/* ---------- Reply long nhau, ghim binh luan, tag @username ---------- */
.comment-item .comment-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.reply-btn, .pin-btn {
  background: none; border: none; color: var(--text-dim); cursor: pointer; font-size: 12px; font: inherit;
  padding: 0;
}
.reply-btn:hover { color: var(--text); text-decoration: underline; }
.pin-btn:hover { color: var(--gold-soft); text-decoration: underline; }
.comment-item.pinned { background: var(--panel-2); border-radius: var(--radius); padding: 12px; margin-bottom: 4px; border-bottom: 1px solid var(--hairline); }
.pinned-badge { color: var(--gold-soft); font-size: 12px; font-weight: 600; margin-bottom: 6px; }
.comment-list.nested { list-style: none; margin: 10px 0 0; padding: 10px 0 0 14px; border-left: 2px solid var(--hairline); }
.comment-list.nested .comment-item { padding: 10px 0; }
.reply-form-slot:not([hidden]) { margin: 10px 0 0 0; padding-left: 2px; }
.reply-form-slot .comment-form { margin-bottom: 0; }
.mention-tag { color: var(--gold-soft); font-weight: 600; text-decoration: none; }
.mention-tag:hover { text-decoration: underline; }
.mention-popover {
  position: fixed; z-index: 1001; width: 240px; max-height: 220px; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--hairline); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 4px; display: none;
}
.mention-popover.open { display: block; }
.mention-opt {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; font: inherit;
  background: none; border: none; color: var(--text); font-size: 13px; padding: 7px 8px;
  cursor: pointer; border-radius: 6px;
}
.mention-opt:hover { background: var(--panel-2); }
.mention-opt span { font-weight: 600; }
.mention-opt em { color: var(--text-dim); font-style: normal; font-size: 12px; margin-left: auto; }

/* ---------- Tac gia/hoa si minh hoa gan tai khoan (novel_contributors) ---------- */
.contributors-row .contributors-list { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.contributor-chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text);
  background: var(--panel-2); border: 1px solid var(--hairline); border-radius: 20px;
  padding: 3px 10px 3px 3px; text-decoration: none;
}
.contributor-chip:hover { border-color: var(--gold-soft); }
.contributor-chip .avatar-mini { width: 20px; height: 20px; font-size: 11px; }
.contributor-chip em { font-style: normal; color: var(--text-dim); font-size: 11px; }

/* ---------- Anh minh hoa chen trong chuong (luc viet + luc doc) ---------- */
.chapter-content-tools { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.chapter-image-preview-wrap { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.chapter-image-preview { position: relative; display: inline-block; }
.chapter-image-preview img { max-height: 90px; max-width: 140px; object-fit: cover; border-radius: var(--radius); display: block; }
.chapter-image-preview button {
  position: absolute; top: -8px; right: -8px; width: 20px; height: 20px; border-radius: 50%;
  border: 1px solid var(--hairline); background: var(--panel); color: var(--text); font-size: 12px;
  cursor: pointer; line-height: 1; display: flex; align-items: center; justify-content: center;
}
.chapter-img-wrap { display: block; margin: 18px 0; }
.chapter-img { max-width: 100%; max-height: 640px; border-radius: var(--radius); display: block; margin: 0 auto; cursor: zoom-in; }

/* ---------- Anh/gif dinh kem bai viet + binh luan dien dan ---------- */
.forum-post-image { max-width: 100%; max-height: 520px; border-radius: var(--radius); display: block; margin: 0 0 24px; cursor: zoom-in; }
.forum-comment-image { max-width: 220px; max-height: 220px; border-radius: var(--radius); margin-top: 8px; display: block; cursor: zoom-in; }

/* ---------- Lightbox: bam vao anh de xem to + tai ve ---------- */
.lightbox-overlay {
  position: fixed; inset: 0; background: rgba(10, 12, 16, .86); z-index: 1000;
  display: flex; align-items: center; justify-content: center; padding: 32px;
  opacity: 0; pointer-events: none; transition: opacity .15s;
}
.lightbox-overlay.open { opacity: 1; pointer-events: auto; }
.lightbox-inner { display: flex; flex-direction: column; align-items: center; gap: 14px; max-width: min(90vw, 900px); max-height: 90vh; }
.lightbox-inner img { max-width: 100%; max-height: 76vh; border-radius: 6px; box-shadow: var(--shadow); object-fit: contain; }
.lightbox-actions { display: flex; gap: 10px; }
.lightbox-actions .btn { background: var(--panel); }
.lightbox-img, img.lightbox-img { cursor: zoom-in; }

/* ---------- Chon emoji chen vao o nhap ---------- */
.emoji-picker-popover {
  position: fixed; z-index: 1001; width: 260px; max-height: 220px; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--hairline); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 8px; display: none;
}
.emoji-picker-popover.open { display: block; }
.emoji-picker-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; }
.emoji-opt {
  background: none; border: none; font-size: 18px; line-height: 1; padding: 6px 0; cursor: pointer;
  border-radius: var(--radius); transition: background .1s;
}
.emoji-opt:hover { background: var(--panel-2); }
.emoji-trigger-btn { font-size: 15px; }

/* ---------- Thanh tha cam xuc (reaction) ---------- */
.reaction-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-top: 10px; }
.reaction-opt {
  display: inline-flex; align-items: center; gap: 4px; font-size: 13px; line-height: 1;
  background: var(--panel-2); border: 1px solid var(--hairline); border-radius: 12px;
  padding: 4px 9px; cursor: pointer; color: var(--text-dim); transition: border-color .15s, color .15s;
}
.reaction-opt:hover { border-color: var(--gold-soft); }
.reaction-opt.active { border-color: var(--gold); background: var(--panel); color: var(--text); }
.reaction-count { font-size: 11px; color: var(--text-dim); }
.reaction-total { font-size: 12px; color: var(--text-dim); margin-left: 4px; }

/* ---------- Anh bia trang ca nhan (kieu Facebook). Khong co anh -> mau xam o che do
   sang, mau den o che do toi (theo yeu cau), khong dung mau --panel binh thuong. ---------- */
.profile-cover {
  /* Rong hon phan noi dung ben duoi 1/5 (120%), can giua bang margin am 2 ben (10% + 10%) */
  position: relative; width: 120%; margin-left: -10%; height: 220px; border-radius: var(--radius);
  overflow: hidden; margin-bottom: 20px; background: #000000;
}
html[data-theme="light"] .profile-cover.no-photo { background: #d9d9d9; }
html:not([data-theme="light"]) .profile-cover.no-photo { background: #000000; }
.profile-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.profile-cover-actions { position: absolute; right: 12px; bottom: 12px; display: flex; gap: 8px; }
.profile-cover-btn {
  font-size: 12px; padding: 6px 10px; background: rgba(20, 20, 20, .55); color: #fff;
  border-color: rgba(255, 255, 255, .35); backdrop-filter: blur(2px);
}
.profile-cover-btn:hover { background: rgba(20, 20, 20, .75); }
.profile-cover-hint {
  position: absolute; left: 12px; bottom: 12px; font-size: 11px; color: #fff;
  background: rgba(20, 20, 20, .5); padding: 4px 9px; border-radius: 10px; pointer-events: none;
}
.draggable-cover { cursor: grab; }
.draggable-cover.dragging { cursor: grabbing; }
@media (max-width: 640px) {
  /* Man hinh nho khong du cho de "tran vien" - tra ve dung 100% de tranh cuon ngang */
  .profile-cover { height: 140px; width: 100%; margin-left: 0; }
}

/* ---------- Nhan vai tro (reader/author/admin) ---------- */
.role-badge {
  font-size: 11px; font-weight: 600; padding: 2px 9px; border-radius: 10px; vertical-align: middle;
  border: 1px solid var(--hairline); color: var(--text-dim); text-transform: uppercase; letter-spacing: .03em;
}
.role-badge.role-author { color: var(--gold-soft); border-color: var(--gold-soft); }
.role-badge.role-admin { color: var(--danger); border-color: var(--danger); }

/* ---------- Panel "Quan ly quyen xem" tren trang truyen + trang To chuc ---------- */
.access-block { margin-bottom: 18px; }
.access-block:last-child { margin-bottom: 0; }
.access-block h4 { font-size: 13px; margin-bottom: 8px; }
.access-list { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.access-chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 13px; padding: 4px 6px 4px 10px;
  border-radius: 14px; border: 1px solid var(--hairline); background: var(--panel-2); color: var(--text);
}
.access-chip .avatar-mini { width: 18px; height: 18px; font-size: 10px; }
.access-chip.blocked { border-color: var(--danger); color: var(--danger); }
.access-chip button {
  background: none; border: none; color: inherit; cursor: pointer; font-size: 11px; opacity: .7;
  padding: 0; line-height: 1;
}
.access-chip button:hover { opacity: 1; }
.access-add-form { display: flex; gap: 8px; }
.access-add-form input, .access-add-form select {
  flex: 1; padding: 7px 10px; border-radius: var(--radius); border: 1px solid var(--hairline);
  background: var(--panel-2); color: var(--text); font: inherit; font-size: 13px;
}
.access-add-form .btn { font-size: 13px; padding: 7px 12px; flex-shrink: 0; }

.org-card h3 { font-size: 17px; }

/* ---------- Profile ---------- */
.profile-layout { display: grid; grid-template-columns: 240px 1fr; gap: 32px; }
.profile-side { display: flex; flex-direction: column; gap: 16px; }
.avatar-circle {
  width: 96px; height: 96px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-family: 'Literata', serif; font-size: 36px; font-weight: 600; color: #fff;
}
.profile-username {
  font-family: 'Literata', serif; font-size: 20px; font-weight: 600; line-height: 1.3;
  word-break: break-word;
}
.profile-handle { color: var(--text-dim); font-size: 13px; margin-top: 2px; line-height: 1.3; word-break: break-all; }
.profile-stats { display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.profile-stats .row { display: flex; align-items: center; gap: 8px; }
.side-tabs { display: flex; flex-direction: column; gap: 2px; margin-top: 8px; }
.side-tabs button {
  text-align: left; background: none; border: none; color: var(--text-dim); font: inherit; font-size: 14px;
  padding: 8px 10px; border-radius: var(--radius); cursor: pointer;
}
.side-tabs button.active { background: var(--panel-2); color: var(--gold-soft); }
.genre-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; }
.genre-tags-label { font-size: 12px; color: var(--text-dim); margin-right: 2px; }
.genre-tag {
  font-size: 12px; padding: 4px 10px; border-radius: 12px; border: 1px solid var(--hairline);
  color: var(--text-dim); text-decoration: none; cursor: pointer; transition: color .15s, border-color .15s, background .15s;
}
a.genre-tag:hover { color: var(--gold-soft); border-color: var(--gold-soft); background: var(--panel-2); }
a.genre-tag.active { color: var(--gold-soft); border-color: var(--gold-soft); background: var(--panel-2); font-weight: 600; }
.genre-tag-count, .genre-chip-count { opacity: .7; font-size: .92em; }

/* ---------- Bo chon the loai (dang ky / tai khoan / dang truyen): nut dang chip, bam de doi trang thai ---------- */
.genre-picker { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 6px; }
.genre-chip {
  font: inherit; font-size: 12px; padding: 5px 12px; border-radius: 12px;
  border: 1px solid var(--hairline); background: var(--panel-2); color: var(--text-dim);
  cursor: pointer; transition: border-color .12s, background .12s, color .12s;
}
.genre-chip:hover { border-color: var(--gold); color: var(--text); }
.genre-chip.selected, .genre-chip.fav {
  background: var(--gold-soft); color: var(--ink); border-color: var(--gold-soft); font-weight: 600;
}
.genre-chip.dislike { background: none; color: var(--danger); border-color: var(--danger); }
.genre-picker-legend { display: flex; gap: 16px; font-size: 12px; color: var(--text-dim); margin-top: 8px; }
.genre-picker-legend span { display: inline-flex; align-items: center; gap: 5px; }

.profile-main .panel { background: var(--panel); border: 1px solid var(--hairline); border-radius: 6px; padding: 20px; margin-bottom: 20px; }
.profile-main h3 { font-size: 15px; margin-bottom: 10px; color: var(--text-dim); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.novel-row-list { list-style: none; margin: 0; padding: 0; }
.novel-row-list li { display: flex; align-items: center; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--hairline); cursor: pointer; }
.novel-row-list li:hover .row-title { color: var(--gold-soft); }
.row-cover { width: 34px; height: 48px; border-radius: 2px; flex-shrink: 0; }
.row-title { flex: 1; font-size: 14px; }
.row-meta { font-size: 12px; color: var(--text-dim); }
.bio-edit-form textarea { width: 100%; min-height: 90px; }

/* ---------- Forum ---------- */
.forum-list { list-style: none; margin: 0; padding: 0; }
.forum-list li { border-bottom: 1px solid var(--hairline); padding: 16px 4px; cursor: pointer; }
.forum-list .f-title { font-family: 'Literata', serif; font-size: 16px; font-weight: 600; }
.forum-list .f-title:hover { color: var(--gold-soft); }
.forum-list .f-meta { font-size: 12px; color: var(--text-dim); margin-top: 4px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.forum-cat { font-size: 11px; padding: 2px 8px; border-radius: 10px; border: 1px solid var(--hairline); color: var(--gold-soft); margin-right: 8px; }
.forum-post-body { line-height: 1.7; white-space: pre-wrap; margin: 16px 0 28px; font-size: 15px; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid var(--hairline); color: var(--text);
  padding: 10px 18px; border-radius: var(--radius); font-size: 14px; z-index: 50;
}
.toast.error { border-color: var(--danger); color: var(--danger); }

/* ---------- Icon button + dropdown chung (theme, user menu) ---------- */
.icon-btn {
  width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--hairline);
  background: var(--panel-2); color: var(--text); font-size: 16px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { border-color: var(--gold); }

.theme-menu, .user-menu, .notif-menu { position: relative; }
.notif-menu .icon-btn { position: relative; }
.notif-badge {
  position: absolute; top: -4px; right: -4px; min-width: 16px; height: 16px; padding: 0 3px;
  border-radius: 8px; background: var(--danger); color: #fff; font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; line-height: 1;
}
.notif-dropdown { width: 320px; max-height: 420px; overflow-y: auto; padding: 0; }
.notif-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-bottom: 1px solid var(--hairline); }
.notif-head strong { font-size: 13px; }
.notif-list { list-style: none; margin: 0; padding: 4px; }
.notif-item { display: flex; gap: 10px; align-items: flex-start; padding: 9px 8px; border-radius: 5px; cursor: pointer; }
.notif-item:hover { background: var(--panel-2); }
.notif-item.unread { background: rgba(201, 162, 75, .08); }
.notif-item.unread::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--gold-soft); margin-top: 6px; flex-shrink: 0; }
.notif-item .row-cover { width: 32px; height: 44px; }
.notif-text { flex: 1; font-size: 13px; line-height: 1.4; }
.notif-time { color: var(--text-dim); font-size: 11px; }
.notif-empty { color: var(--text-dim); font-size: 13px; padding: 18px 14px; text-align: center; margin: 0; }
.dropdown {
  position: absolute; top: calc(100% + 8px); right: 0; min-width: 150px;
  background: var(--panel); border: 1px solid var(--hairline); border-radius: 8px;
  box-shadow: var(--shadow); padding: 6px; z-index: 40;
  display: none; flex-direction: column; gap: 2px;
}
.dropdown.open { display: flex; }
.dropdown button, .dropdown a {
  background: none; border: none; text-align: left; color: var(--text); font: inherit; font-size: 14px;
  padding: 9px 12px; border-radius: 5px; cursor: pointer; display: flex; align-items: center; gap: 9px;
  text-decoration: none;
}
.dropdown button:hover, .dropdown a:hover { background: var(--panel-2); color: var(--gold-soft); }
.dropdown button.active-theme { color: var(--gold-soft); font-weight: 600; }
.dropdown hr { border: none; border-top: 1px solid var(--hairline); margin: 4px 2px; }

/* ---------- Menu "The loai" o top-bar: liet ke tat ca the loai, mo dang luoi 2 cot ---------- */
.genre-menu { position: relative; }
.genre-dropdown {
  width: 320px; max-height: 70vh; overflow-y: auto;
  display: none; grid-template-columns: 1fr 1fr; gap: 2px;
}
.genre-dropdown.open { display: grid; }
.genre-dropdown a { justify-content: space-between; font-size: 13px; padding: 8px 10px; }
.genre-dropdown a.active { color: var(--gold-soft); font-weight: 600; background: var(--panel-2); }
.genre-dropdown-count { opacity: .65; font-size: .9em; }
@media (max-width: 640px) {
  .genre-dropdown { width: 260px; grid-template-columns: 1fr; }
}

.user-menu-trigger { display: flex; align-items: center; gap: 7px; cursor: pointer; background: none; border: none; color: var(--text-dim); font: inherit; font-size: 14px; padding: 4px; }
.user-menu-trigger:hover strong { color: var(--gold-soft); }
.user-menu .dropdown { right: 0; min-width: 180px; }

/* ---------- Trinh soan tieu su (bo cuc kieu DMOJ) ---------- */
.rte { border: 1px solid var(--hairline); border-radius: var(--radius); background: var(--panel-2); overflow: hidden; }
.rte-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 0 8px; border-bottom: 1px solid var(--hairline); background: var(--panel);
}
.rte-tabs { display: flex; gap: 2px; }
.rte-tab {
  background: none; border: none; border-bottom: 2px solid transparent; color: var(--text-dim);
  font: inherit; font-size: 13px; padding: 10px 14px; cursor: pointer; transition: color .15s, border-color .15s;
}
.rte-tab:hover { color: var(--text); }
.rte-tab.active { color: var(--gold-soft); border-bottom-color: var(--gold-soft); font-weight: 600; }
.rte-toolbar { display: flex; gap: 2px; flex-wrap: wrap; padding: 5px 0; }
.rte-toolbar button {
  min-width: 30px; height: 28px; padding: 0 6px; border-radius: var(--radius);
  border: 1px solid transparent; background: none; color: var(--text-dim);
  cursor: pointer; font-size: 13px; font-weight: 600; line-height: 1;
}
.rte-toolbar button:hover { border-color: var(--hairline); background: var(--panel-2); color: var(--text); }
.rte-toolbar button sup { font-size: 9px; }

.rte .rte-pane { display: flex; background: var(--panel-2); }
/* display:flex/block se de len [hidden] mac dinh cua trinh duyet -> phai khai bao lai */
.rte .rte-pane[hidden] { display: none; }
.rte-gutter {
  flex-shrink: 0; width: 38px; padding: 10px 0; overflow: hidden; text-align: right;
  border-right: 1px solid var(--hairline); background: var(--panel);
  color: var(--text-dim); opacity: .6; user-select: none;
  font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; line-height: 1.6;
}
.rte-gutter div { padding-right: 8px; }
.rte .rte-source {
  flex: 1; min-height: 260px; resize: vertical; border: none; outline: none;
  padding: 10px 12px; background: var(--panel-2); color: var(--text);
  font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; line-height: 1.6;
  white-space: pre; overflow-x: auto;
}
.rte .rte-preview-pane { display: block; min-height: 260px; padding: 14px 16px; }
.rte .rte-preview-pane[hidden] { display: none; }
.rte-help {
  padding: 12px 16px; border-top: 1px solid var(--hairline); background: var(--panel); font-size: 13px;
}
.rte-help p.hint { font-size: 12px; }
.rte-help code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; color: var(--gold-soft); word-break: break-word; }
.bio-render { line-height: 1.6; }
.bio-render a { color: var(--gold-soft); }
.bio-render img { max-width: 100%; border-radius: 4px; }

/* ---------- Avatar co anh that ----------
   Truoc day chi co .avatar-edit-wrap moi dinh kieu cho <img>, nen avatar o trang
   Thanh vien (top 3 + bang xep hang) khong duoc co lai -> bi cat goc / hien o trang.
   Cac quy tac duoi day ap dung cho MOI noi dung avatar. */
.avatar-circle.has-img,
.avatar-mini.has-img { padding: 0; overflow: hidden; background: var(--panel-2); }
.avatar-circle img.avatar-img,
.avatar-mini img.avatar-img,
.avatar-edit-wrap img.avatar-img {
  display: block; width: 100%; height: 100%; object-fit: cover; border-radius: 50%;
}

/* ---------- Avatar upload ---------- */
.avatar-edit-wrap { position: relative; width: 96px; }
.avatar-edit-wrap .avatar-circle { overflow: hidden; }
.avatar-edit-overlay {
  position: absolute; inset: 0; border-radius: 50%; background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center; color: #fff; font-size: 12px;
  opacity: 0; cursor: pointer; transition: opacity .15s;
}
.avatar-edit-wrap:hover .avatar-edit-overlay { opacity: 1; }
.avatar-mini img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }

/* ---------- Khoi tieu su tren trang ca nhan (bo cuc kieu DMOJ) ---------- */
.bio-panel { }
.bio-render { line-height: 1.7; word-break: break-word; }
.bio-render > *:first-child { margin-top: 0; }
.bio-render > *:last-child { margin-bottom: 0; }
.bio-render p { margin: 0 0 10px; }
.bio-render ul, .bio-render ol { margin: 0 0 10px; padding-left: 22px; }
.bio-render h1, .bio-render h2, .bio-render h3, .bio-render h4 {
  font-family: 'Literata', serif; margin: 14px 0 8px; line-height: 1.3; color: var(--text);
  text-transform: none; letter-spacing: 0;
}
.bio-render h1 { font-size: 21px; }
.bio-render h2 { font-size: 18px; }
.bio-render h3 { font-size: 16px; }
.bio-render h4 { font-size: 15px; }
.bio-render blockquote {
  margin: 0 0 10px; padding: 6px 14px; border-left: 3px solid var(--gold-soft); color: var(--text-dim);
}
.bio-render code {
  font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px;
  background: var(--panel-2); padding: 1px 5px; border-radius: 4px;
}
.bio-render hr { border: none; border-top: 1px solid var(--hairline); margin: 14px 0; }
.bio-render sup, .bio-render sub { font-size: 75%; }
.bio-render table { width: 100%; border-collapse: collapse; margin: 0 0 12px; font-size: 14px; }
.bio-render th, .bio-render td { border: 1px solid var(--hairline); padding: 6px 10px; text-align: left; }
.bio-render th { background: var(--panel-2); font-weight: 600; }
.bio-render iframe { max-width: 100%; border: none; border-radius: 6px; display: block; margin: 0 0 12px; }
.bio-render pre {
  background: var(--panel-2); border: 1px solid var(--hairline); border-radius: var(--radius);
  padding: 12px; overflow-x: auto; margin: 0 0 10px;
}

/* ---------- Member grid ---------- */
.member-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 16px; }
.member-card {
  background: var(--panel); border: 1px solid var(--hairline); border-radius: 8px;
  padding: 18px 14px; text-align: center; cursor: pointer; transition: border-color .15s;
}
.member-card:hover { border-color: var(--gold); }
.member-card .avatar-circle { width: 56px; height: 56px; font-size: 22px; margin: 0 auto 10px; }
.member-card .m-name { font-family: 'Literata', serif; font-weight: 600; font-size: 14px; }
.member-card .m-meta { font-size: 12px; color: var(--text-dim); margin-top: 4px; }

/* ---------- History (Lich su doc) ---------- */
.history-list { list-style: none; margin: 0; padding: 0; }
.history-list li { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--hairline); cursor: pointer; }
.history-list .row-cover { width: 40px; height: 56px; }
.history-list .h-main { flex: 1; }
.history-list .h-title { font-size: 14px; }
.history-list .h-sub { font-size: 12px; color: var(--text-dim); margin-top: 2px; }

/* ---------- Checkbox (remember me) ---------- */
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-dim); margin: -6px 0 16px; }
.checkbox-row input { accent-color: var(--gold); }
.link-btn { background: none; border: none; color: var(--gold-soft); font: inherit; font-size: 13px; cursor: pointer; padding: 0; text-decoration: underline; }

/* ---------- Cover upload trong form them truyen / chinh sua ---------- */
.cover-picker { display: flex; align-items: center; gap: 14px; }
.cover-preview {
  width: 70px; height: 100px; border-radius: 4px; border: 1px dashed var(--hairline);
  display: flex; align-items: center; justify-content: center; overflow: hidden; flex-shrink: 0; color: var(--text-dim); font-size: 11px; text-align: center;
}
.cover-preview img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- Footer ---------- */
.site-footer {
  margin-top: auto; border-top: 1px solid var(--hairline); padding: 22px 28px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  text-align: center; color: var(--text-dim); font-size: 13px;
}
.footer-credit strong { color: var(--gold-soft); }
.footer-links { display: flex; gap: 14px; }
.footer-link {
  color: var(--text-dim); text-decoration: none; font-size: 13px;
  padding: 5px 12px; border: 1px solid var(--hairline); border-radius: 14px;
  display: inline-flex; align-items: center; gap: 6px;
}
.footer-link:hover { color: var(--gold-soft); border-color: var(--gold); }

/* ---------- Bang xep hang thanh vien ---------- */
.panel { background: var(--panel); border: 1px solid var(--hairline); border-radius: 8px; padding: 22px; }

.top3-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; align-items: end; }
.top3-card {
  background: var(--panel); border: 1px solid var(--hairline); border-radius: 8px; padding: 18px;
  display: flex; flex-direction: column; gap: 10px;
}
.top3-card.top3-first { border-color: var(--gold); box-shadow: 0 6px 24px rgba(0,0,0,.25); transform: translateY(-8px); }
.top3-rank { font-size: 11px; letter-spacing: .06em; color: var(--text-dim); font-weight: 600; }
.top3-rank-first { display: inline-block; background: rgba(60,175,92,.16); color: #3fae5c; padding: 3px 10px; border-radius: 10px; width: fit-content; }
.top3-user { display: flex; align-items: center; gap: 12px; }
.top3-avatar { width: 52px; height: 52px; font-size: 20px; flex-shrink: 0; }
.top3-name { font-family: 'Literata', serif; font-weight: 600; font-size: 15px; }
.top3-handle { font-size: 12px; color: var(--text-dim); }
.top3-score { font-family: 'Literata', serif; font-size: 26px; font-weight: 700; }

.pagination { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.page-btn {
  min-width: 32px; height: 32px; padding: 0 8px; border-radius: 6px; border: 1px solid var(--hairline);
  background: var(--panel-2); color: var(--text); font: inherit; font-size: 13px; cursor: pointer;
}
.page-btn:hover:not(:disabled) { border-color: var(--gold); }
.page-btn.active { background: var(--gold-soft); color: var(--ink); border-color: var(--gold-soft); font-weight: 600; }
.page-btn:disabled { opacity: .4; cursor: default; }
.page-ellipsis { color: var(--text-dim); padding: 0 4px; }

.member-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.member-table th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-dim);
  padding: 8px 10px; border-bottom: 1px solid var(--hairline);
}
.member-table td { padding: 12px 10px; border-bottom: 1px solid var(--hairline); vertical-align: middle; }
.member-table tr:hover td { background: var(--panel-2); cursor: pointer; }
.rating-badge { display: inline-block; width: 10px; height: 10px; border-radius: 50%; }
.member-row-user { display: flex; align-items: center; gap: 10px; }
.member-row-avatar { width: 34px; height: 34px; font-size: 13px; flex-shrink: 0; }
.member-row-name { font-weight: 600; }
.member-row-handle { font-size: 12px; color: var(--text-dim); }

@media (max-width: 700px) {
  .top3-row { grid-template-columns: 1fr; }
  .top3-card.top3-first { transform: none; }
  .member-table { display: block; overflow-x: auto; white-space: nowrap; }
}

@media (max-width: 600px) {
  .topbar { flex-wrap: wrap; gap: 10px; padding: 12px 16px; }
  .searchbox { order: 3; flex-basis: 100%; }
  main { padding: 20px 16px 48px; }
  .reader-page { padding: 36px 6vw 60px; }
  .profile-layout { grid-template-columns: 1fr; }
}

/* ---------- Thuoc tinh hidden luon thang (nhieu phan tu co display rieng) ---------- */
[hidden] { display: none !important; }

/* ---------- O mat khau co nut hien/an ---------- */
.pw-wrap { position: relative; display: block; width: 100%; }
.pw-wrap input { width: 100%; padding-right: 44px !important; }
.pw-toggle {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; padding: 0; background: none; border: none; border-radius: var(--radius);
  color: var(--text-dim); cursor: pointer;
}
.pw-toggle:hover { color: var(--gold-soft); }
.pw-toggle:focus-visible { outline: 2px solid var(--gold); outline-offset: -2px; }

/* ---------- Trang doc: dong de luu (nhan dup 2 lan) ---------- */
.reader-page .body-text { touch-action: manipulation; }
.reader-hint { font-family: 'Inter', system-ui, sans-serif; font-size: 12px; color: var(--paper-text-dim); margin: -14px 0 22px; }
.chapter-line { border-radius: 2px; }
.chapter-line.has-text { cursor: text; }
.chapter-line.saved {
  --hl: 201, 162, 75;
  background: rgba(var(--hl), .26);
  box-shadow: -5px 0 0 rgb(var(--hl));
}
.chapter-line.saved[data-color="green"] { --hl: 76, 175, 110; }
.chapter-line.saved[data-color="blue"] { --hl: 79, 140, 214; }
.chapter-line.saved[data-color="pink"] { --hl: 214, 100, 150; }
.chapter-line.saved[data-color="purple"] { --hl: 150, 110, 210; }
.chapter-line.saved[data-note]::after { content: ' 📝'; font-size: .7em; opacity: .8; }
.chapter-line.flash { animation: lineFlash 2.2s ease-out; }
@keyframes lineFlash {
  0%, 35% { background: rgba(201, 162, 75, .55); }
  100% { background: rgba(201, 162, 75, 0); }
}
.chapter-line.saved.flash { animation: lineFlashSaved 2.2s ease-out; }
@keyframes lineFlashSaved {
  0%, 35% { background: rgba(var(--hl), .6); }
  100% { background: rgba(var(--hl), .26); }
}

/* ---------- Trang Danh dau (dong da luu) ---------- */
.bookmark-group { margin-bottom: 26px; max-width: 760px; }
.bookmark-novel { font-size: 17px; margin: 0 0 10px; }
.bookmark-novel a { color: var(--gold-soft); text-decoration: none; }
.bookmark-novel a:hover { text-decoration: underline; }
.bookmark-item {
  background: var(--panel); border: 1px solid var(--hairline); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 10px;
}
.bookmark-text {
  margin: 0 0 10px; padding: 2px 0 2px 12px; border-left: 3px solid var(--gold);
  font-family: 'Literata', serif; line-height: 1.7; white-space: pre-wrap; font-size: 15px;
}
.bookmark-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.bookmark-meta a { color: var(--gold-soft); text-decoration: none; font-weight: 600; }
.bookmark-meta a:hover { text-decoration: underline; }
.bookmark-remove { margin-left: auto; font-size: 12px; padding: 4px 10px; }

/* ---------- To chuc ---------- */
.org-page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.org-eyebrow { font-size: 11px; letter-spacing: .14em; color: var(--text-dim); margin-bottom: 4px; }
.org-wide { max-width: none; }
.org-select {
  font: inherit; font-size: 14px; padding: 10px 12px; border-radius: var(--radius);
  border: 1px solid var(--hairline); background: var(--panel-2); color: var(--text);
}
.org-search { margin-bottom: 6px; }
.org-search input {
  width: 100%; font: inherit; font-size: 14px; padding: 10px 14px; border-radius: var(--radius);
  border: 1px solid var(--hairline); background: var(--panel); color: var(--text);
}
.org-search input:focus { outline: none; border-color: var(--gold); }
.org-subtitle { font-size: 16px; margin: 24px 0 12px; }
.org-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.org-mini {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px;
  background: var(--panel); border: 1px solid var(--hairline); border-radius: var(--radius);
  color: var(--text); text-decoration: none; transition: border-color .15s, transform .15s;
}
.org-mini:hover { border-color: var(--gold); transform: translateY(-2px); }
.org-mini-main { min-width: 0; }
.org-mini-name { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.org-mini-sub { font-size: 12px; color: var(--text-dim); margin-top: 3px; }
.org-role {
  font-size: 11px; padding: 2px 9px; border-radius: 10px; border: 1px solid var(--hairline);
  color: var(--text-dim); white-space: nowrap; flex-shrink: 0;
}
.org-role.owner { color: var(--gold-soft); border-color: var(--gold-soft); }
.org-access { font-size: 11px; padding: 2px 9px; border-radius: 10px; border: 1px solid; white-space: nowrap; flex-shrink: 0; }
.org-access.open { color: #3fae5c; border-color: #3fae5c; }
.org-access.closed { color: var(--gold-soft); border-color: var(--gold-soft); }
.org-rows { background: var(--panel); border: 1px solid var(--hairline); border-radius: var(--radius); overflow: hidden; }
.org-row {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--hairline);
  color: var(--text); text-decoration: none;
}
.org-row:last-child { border-bottom: none; }
a.org-row:hover { background: var(--panel-2); }
.org-row-name { flex: 1; min-width: 0; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.org-count { font-size: 12px; color: var(--text-dim); background: var(--panel-2); border-radius: 10px; padding: 1px 10px; min-width: 32px; text-align: center; }

.org-layout { display: grid; grid-template-columns: 1fr 280px; gap: 28px; align-items: start; }
.org-main { min-width: 0; }
.org-hero {
  background: linear-gradient(160deg, var(--panel-2), var(--panel));
  border: 1px solid var(--hairline); border-radius: 6px; padding: 26px;
}
.org-hero-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; flex-wrap: wrap; }
.org-pill {
  display: inline-block; font-size: 11px; letter-spacing: .12em; padding: 3px 11px;
  border-radius: 12px; border: 1px solid var(--hairline); color: var(--gold-soft); background: var(--panel);
}
.org-hero h1 { font-family: 'Literata', serif; font-size: 30px; margin: 12px 0 6px; line-height: 1.2; }
.org-owner { font-size: 13px; color: var(--text-dim); }
.org-owner a { color: var(--gold-soft); text-decoration: none; }
.org-owner a:hover { text-decoration: underline; }
.org-stats { display: flex; gap: 10px; }
.org-stat { min-width: 110px; padding: 10px 14px; border: 1px solid var(--hairline); border-radius: var(--radius); background: var(--panel); }
.org-stat-label { font-size: 10.5px; letter-spacing: .12em; color: var(--text-dim); }
.org-stat-value { font-size: 22px; font-weight: 600; margin-top: 4px; }
.org-stat-value.open { color: #3fae5c; }
.org-stat-value.closed { color: var(--gold-soft); }
.org-info-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 22px; }
.org-info-card {
  border: 1px solid var(--hairline); border-radius: var(--radius); padding: 12px 14px;
  background: var(--panel); font-size: 13px; color: var(--text-dim); line-height: 1.55;
}
.org-info-card strong { display: block; color: var(--text); font-size: 13.5px; margin-bottom: 4px; }
.org-about { margin-top: 16px; }
.org-about-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.org-about-head h3 { margin: 0; font-size: 17px; }
.org-about-icon {
  width: 36px; height: 36px; border-radius: 10px; background: var(--panel-2); color: var(--gold-soft);
  display: flex; align-items: center; justify-content: center; font-family: 'Literata', serif; font-style: italic; font-weight: 700;
  flex-shrink: 0;
}
.org-desc { white-space: pre-wrap; line-height: 1.65; margin: 0; }
.org-side-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 14px; }
.org-side-head h4 { margin: 0; font-size: 18px; text-transform: none; letter-spacing: 0; }
.org-edit-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px;
  border-radius: 8px; background: var(--panel-2); color: var(--text-dim); text-decoration: none; font-size: 16px;
}
.org-edit-btn:hover { color: var(--gold-soft); }
.org-actions { display: flex; flex-direction: column; gap: 10px; }
.org-actions .org-action { width: 100%; text-align: center; display: block; }
.org-note { margin: 0; font-size: 13px; color: var(--text-dim); line-height: 1.5; }
/* Nut dang the <a> trong khu vuc to chuc: bo gach chan, can giua nhu <button> */
.org-actions a.btn, .org-request-card a.btn { display: inline-block; text-decoration: none; }
.org-block { max-width: 760px; margin-bottom: 22px; }
.org-members-list { max-width: 760px; }
.org-member { display: flex; align-items: center; gap: 12px; padding: 11px 16px; border-bottom: 1px solid var(--hairline); }
.org-member:last-child { border-bottom: none; }
.org-member-main { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.org-member-main .avatar-mini { width: 34px; height: 34px; font-size: 14px; }
.org-member-name { font-weight: 600; color: var(--text); text-decoration: none; }
.org-member-name:hover { color: var(--gold-soft); }
.org-remove { font-size: 12px; padding: 4px 10px; }
.org-request { background: var(--panel); border: 1px solid var(--hairline); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px; }
.org-request-reason { margin: 10px 0 12px; padding: 8px 12px; background: var(--panel-2); border-radius: var(--radius); white-space: pre-wrap; font-size: 14px; line-height: 1.55; }
.org-request-card { max-width: 640px; margin: 0 auto; }
.org-request-card h2 { margin: 12px 0 6px; font-size: 24px; }
.org-hr { border: none; border-top: 1px solid var(--hairline); margin: 18px 0; }
.org-danger { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }

@media (max-width: 860px) {
  .org-layout { grid-template-columns: 1fr; }
  .org-info-cards { grid-template-columns: 1fr; }
}

/* ---------- Thanh dieu huong: du cho 6 muc (them "To chuc") ---------- */
.topbar { gap: 18px; }
.navbtn { white-space: nowrap; padding: 8px 12px; }
.searchbox { flex: 0 1 260px; min-width: 150px; }
@media (max-width: 1100px) {
  .navbtn { padding: 8px 9px; font-size: 13.5px; }
  .topbar { padding-left: 16px; padding-right: 16px; }
}
@media (max-width: 1000px) {
  /* man hinh vua/nho: thanh menu xuong hang rieng thay vi tran ngang */
  .topbar { flex-wrap: wrap; }
  .topnav { order: 3; flex: 1 0 100%; flex-wrap: wrap; row-gap: 2px; }
  .searchbox { flex: 1 1 200px; }
}
@media (max-width: 600px) {
  .navbtn { padding: 8px 10px; }
  .searchbox { flex-basis: 100%; order: 4; }
}

/* ================= Danh gia sao, ke doc, tim trong truyen ================= */
.library-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.library-sort { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-dim); }
.book-rating { color: var(--gold-soft); font-weight: 600; }
.stars {
  display: inline-block; font-size: 16px; letter-spacing: 1px; line-height: 1; vertical-align: -1px;
  background: linear-gradient(90deg, var(--gold) var(--pct, 0%), var(--hairline) var(--pct, 0%));
  -webkit-background-clip: text; background-clip: text; color: transparent; -webkit-text-fill-color: transparent;
}
.rating-box { margin: 8px 0 4px; }
.rating-summary { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.rating-mine { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-size: 13px; flex-wrap: wrap; }
.rating-input { display: inline-flex; flex-direction: row-reverse; gap: 2px; }
.rating-star { background: none; border: none; padding: 0 1px; font-size: 22px; line-height: 1; color: var(--hairline); cursor: pointer; transition: transform .1s; }
.rating-star.on { color: var(--gold); }
.rating-input:hover .rating-star { color: var(--hairline); }
.rating-input .rating-star:hover, .rating-input .rating-star:hover ~ .rating-star { color: var(--gold); }
.rating-star:hover { transform: scale(1.15); }
.shelf-select { padding: 8px 10px; }
.shelf-move { margin-top: 8px; width: 100%; font-size: 13px; padding: 6px 8px; }
.novel-search { display: flex; gap: 8px; margin: 0 0 12px; max-width: 460px; }
.novel-search input {
  flex: 1; min-width: 0; font: inherit; font-size: 14px; padding: 8px 12px; border-radius: var(--radius);
  border: 1px solid var(--hairline); background: var(--panel-2); color: var(--text);
}
.novel-search input:focus { outline: none; border-color: var(--gold); }
.search-results-head { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--text-dim); margin: 6px 0 8px; }
.search-results { list-style: none; margin: 0 0 16px; padding: 0; border: 1px solid var(--hairline); border-radius: var(--radius); background: var(--panel); max-height: 420px; overflow-y: auto; }
.search-results li { border-bottom: 1px solid var(--hairline); }
.search-results li:last-child { border-bottom: none; }
.search-results a { display: block; padding: 10px 14px; color: var(--text); text-decoration: none; }
.search-results a:hover { background: var(--panel-2); }
.sr-title { font-weight: 600; font-size: 14px; margin-bottom: 3px; }
.sr-snippet { font-size: 13px; color: var(--text-dim); line-height: 1.55; }
mark { background: rgba(201, 162, 75, .45); color: inherit; border-radius: 2px; padding: 0 1px; }

/* ================= Bao cao vi pham + hop thoai ================= */
.report-btn {
  background: none; border: none; padding: 0 4px; font: inherit; font-size: 12px; color: var(--text-dim); cursor: pointer;
}
.report-btn:hover { color: var(--danger); text-decoration: underline; }
.btn.report-novel-btn { color: var(--text-dim); }
.btn.report-novel-btn:hover { color: var(--danger); border-color: var(--danger); }
.modal-overlay {
  position: fixed; inset: 0; z-index: 90; background: rgba(10, 12, 16, .6);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal-card { width: 100%; max-width: 440px; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow); }
.report-reasons { display: flex; flex-direction: column; gap: 8px; }
.report-reason { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.notif-icon {
  width: 32px; height: 32px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
  background: var(--panel-2); border-radius: 50%; font-size: 15px;
}

/* ================= Trang quan tri ================= */
.admin-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.admin-filter { margin-bottom: 14px; }
.report-card { background: var(--panel); border: 1px solid var(--hairline); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px; max-width: 820px; }
.report-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; font-size: 14px; }
.report-target { margin-bottom: 8px; font-size: 14px; }
.report-target a { color: var(--gold-soft); text-decoration: none; }
.report-target a:hover { text-decoration: underline; }
.report-preview { margin: 6px 0 0; padding: 4px 0 4px 12px; border-left: 3px solid var(--hairline); color: var(--text-dim); white-space: pre-wrap; font-size: 13px; line-height: 1.55; }
.report-detail { margin-bottom: 8px; font-size: 13px; font-style: italic; color: var(--text-dim); }
.admin-user { flex-wrap: wrap; }
.admin-user .org-row-name a { color: inherit; text-decoration: none; }
.admin-user .org-row-name a:hover { color: var(--gold-soft); }

/* ================= Danh dau: ghi chu + mau ================= */
.bookmark-note { margin: -2px 0 10px; padding: 8px 12px; background: var(--panel-2); border-radius: var(--radius); font-size: 14px; white-space: pre-wrap; line-height: 1.5; }
.color-dots { display: inline-flex; gap: 5px; align-items: center; margin-left: 6px; }
.color-dot { width: 16px; height: 16px; border-radius: 50%; border: 2px solid transparent; padding: 0; cursor: pointer; background: rgb(201, 162, 75); }
.color-dot[data-set-color="green"] { background: rgb(76, 175, 110); }
.color-dot[data-set-color="blue"] { background: rgb(79, 140, 214); }
.color-dot[data-set-color="pink"] { background: rgb(214, 100, 150); }
.color-dot[data-set-color="purple"] { background: rgb(150, 110, 210); }
.color-dot.on { border-color: var(--text); }
.bookmark-small { font-size: 12px; padding: 4px 10px; }
.bookmark-meta .bookmark-small:last-child { margin-left: 0; }
.bookmark-item[data-color="green"] .bookmark-text { border-left-color: rgb(76, 175, 110); }
.bookmark-item[data-color="blue"] .bookmark-text { border-left-color: rgb(79, 140, 214); }
.bookmark-item[data-color="pink"] .bookmark-text { border-left-color: rgb(214, 100, 150); }
.bookmark-item[data-color="purple"] .bookmark-text { border-left-color: rgb(150, 110, 210); }
.bookmark-note-form { margin-top: 10px; }
.bookmark-note-form textarea {
  width: 100%; min-height: 70px; font: inherit; font-size: 14px; padding: 8px 10px; margin-bottom: 8px; border-radius: var(--radius);
  border: 1px solid var(--hairline); background: var(--panel-2); color: var(--text); resize: vertical;
}

/* ================= Trang doc: cong cu moi ================= */
.reader-page[data-reader-font="sans"] { font-family: 'Inter', system-ui, sans-serif; }
.reader-page[data-reader-font="system"] { font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; }
.reader-page[data-reader-theme="white"] { --paper: #ffffff; --paper-text: #1c1c1c; --paper-text-dim: #666666; }
.reader-page[data-reader-theme="sepia"] { --paper: #f1e5c8; --paper-text: #4b3a26; --paper-text-dim: #7a6749; }
.reader-page[data-reader-theme="dark"] { --paper: #1d222b; --paper-text: #cfd5de; --paper-text-dim: #8b96a5; }
.reader-page[data-reader-theme="dark"] mark { background: rgba(201, 162, 75, .5); color: #fff; }
.reader-tool {
  min-width: 34px; height: 30px; padding: 0 8px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
  background: var(--panel-2); color: var(--text); border: 1px solid var(--hairline); border-radius: var(--radius);
}
.reader-tool:hover { border-color: var(--gold); }
.reader-topbar-right { flex-wrap: wrap; justify-content: flex-end; }
.reader-jump {
  max-width: 190px; font: inherit; font-size: 13px; padding: 5px 8px; border-radius: var(--radius);
  border: 1px solid var(--hairline); background: var(--panel-2); color: var(--text);
}
.reader-settings-wrap { position: relative; }
.reader-settings {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 40; width: 300px; padding: 14px;
  background: var(--panel); border: 1px solid var(--hairline); border-radius: 6px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 12px;
}
.rs-row { display: flex; flex-direction: column; gap: 6px; }
.rs-label { font-size: 12px; color: var(--text-dim); }
.rs-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  font: inherit; font-size: 13px; padding: 5px 12px; cursor: pointer; color: var(--text);
  background: var(--panel-2); border: 1px solid var(--hairline); border-radius: 14px;
}
.chip.active { background: var(--gold-soft); color: var(--ink); border-color: var(--gold-soft); font-weight: 600; }
.rs-swatch { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--hairline); cursor: pointer; padding: 0; }
.rs-swatch.active { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold-soft); }
.rs-check { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; color: var(--text-dim); cursor: pointer; }
.rs-reset { align-self: flex-start; font-size: 12px; padding: 5px 12px; }
.reader-progress { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 60; background: transparent; pointer-events: none; }
.reader-progress-fill { height: 100%; width: 0; background: var(--gold); transition: width .1s linear; }
.reader-pct {
  position: fixed; right: 14px; bottom: 14px; z-index: 30; padding: 3px 10px; font-size: 12px; font-weight: 600;
  color: var(--text-dim); background: var(--panel); border: 1px solid var(--hairline); border-radius: 12px; opacity: .85; pointer-events: none;
}
.reader-find {
  position: fixed; right: 16px; top: 72px; z-index: 45; display: flex; align-items: center; gap: 6px; padding: 8px 10px;
  background: var(--panel); border: 1px solid var(--hairline); border-radius: 6px; box-shadow: var(--shadow);
}
.reader-find input {
  width: 190px; font: inherit; font-size: 14px; padding: 6px 10px; border-radius: var(--radius);
  border: 1px solid var(--hairline); background: var(--panel-2); color: var(--text);
}
.reader-find input:focus { outline: none; border-color: var(--gold); }
.reader-find button { background: none; border: 1px solid var(--hairline); border-radius: var(--radius); color: var(--text); width: 28px; height: 28px; cursor: pointer; font-size: 12px; }
.reader-find button:hover { border-color: var(--gold); }
.reader-find-count { min-width: 44px; text-align: center; font-size: 12px; color: var(--text-dim); }
mark.find-hit.current { background: rgb(240, 160, 50); color: #1a1208; outline: 2px solid rgb(240, 160, 50); }
@media (max-width: 600px) {
  .reader-settings { position: fixed; left: 12px; right: 12px; width: auto; top: 150px; max-height: 70vh; overflow-y: auto; }
  .reader-find { left: 12px; right: 12px; }
  .reader-find input { flex: 1; width: auto; min-width: 0; }
  .reader-pct { bottom: 10px; right: 10px; }
}

/* ================= To chuc: xep hang, lien ket moi ================= */
.lb-rank { width: 26px; flex-shrink: 0; text-align: center; font-weight: 700; color: var(--text-dim); font-family: 'Literata', serif; }
.lb-rank.top { color: var(--gold-soft); }
.org-row .avatar-mini { width: 28px; height: 28px; font-size: 12px; }
.invite-link-row { display: flex; gap: 8px; }
.invite-link-row input {
  flex: 1; min-width: 0; font: inherit; font-size: 13px; padding: 8px 10px; border-radius: var(--radius);
  border: 1px solid var(--hairline); background: var(--panel-2); color: var(--text);
}

/* ---------- Chinh nho ---------- */
input[type="range"], input[type="checkbox"], input[type="radio"] { accent-color: var(--gold); }
.report-card a, .bookmark-group a { color: var(--gold-soft); text-decoration: none; }
.report-card a:hover { text-decoration: underline; }
.brand-name { white-space: nowrap; }
.authbox .who strong { white-space: nowrap; max-width: 150px; overflow: hidden; text-overflow: ellipsis; display: inline-block; vertical-align: middle; }
.user-menu-trigger strong { white-space: nowrap; max-width: 150px; overflow: hidden; text-overflow: ellipsis; display: inline-block; vertical-align: middle; }

/* ================= Super Admin: nhan vai tro, khu vuc nguy hiem, xoa tai khoan ================= */
.role-badge.role-super_admin { color: var(--gold); border-color: var(--gold); }

.danger-zone { border-color: var(--danger); }
.danger-label { color: var(--danger); font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 8px; }

.modal-close-x {
  background: none; border: none; color: var(--text-dim); font-size: 20px; line-height: 1; cursor: pointer; padding: 2px 4px;
}
.modal-close-x:hover { color: var(--text); }
.radio-row { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; font-weight: 400; margin-top: 6px; cursor: pointer; }

.profile-actions-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.profile-actions-row .report-btn { padding: 0; }

/* ================= Bao cao chuong + nut ve trang truyen trong reader-nav ================= */
.reader-report-row { display: flex; justify-content: flex-end; max-width: var(--reader-width, 720px); margin: 28px auto 0; padding: 0 8px; }
.reader-home-btn { flex: 0 0 auto; padding: 10px 16px; font-size: 16px; }

/* ================= So sao canh ten nguoi binh luan (da danh gia truyen) ================= */
.comment-rating { color: var(--gold-soft); font-size: 12px; font-weight: 600; margin-left: 6px; }

/* ================= Vote len/xuong cho binh luan (rieng voi cam xuc emoji) ================= */
.vote-bar { display: inline-flex; align-items: center; gap: 6px; margin-top: 10px; margin-right: 10px; }
.vote-btn {
  background: var(--panel-2); border: 1px solid var(--hairline); border-radius: 999px; color: var(--text-dim);
  font-size: 12px; line-height: 1; width: 24px; height: 24px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; transition: border-color .15s, color .15s;
}
.vote-btn:hover { border-color: var(--gold-soft); color: var(--text); }
.vote-btn.vote-up.active { border-color: #3fae5c; color: #3fae5c; background: var(--panel); }
.vote-btn.vote-down.active { border-color: var(--danger); color: var(--danger); background: var(--panel); }
.vote-score { font-size: 13px; font-weight: 600; min-width: 18px; text-align: center; color: var(--text-dim); }
.vote-score.pos { color: #3fae5c; }
.vote-score.neg { color: var(--danger); }
/* Reaction-bar va vote-bar nam canh nhau tren cung 1 hang, tach voi khoi noi dung ben tren */
.comment-body-wrap .vote-bar, .comment-body-wrap .reaction-bar { display: inline-flex; }
.comment-body-wrap { display: block; }

/* ================= Binh luan bi an do vote qua thap (nguong do Admin cau hinh) ================= */
.comment-hidden-banner {
  background: var(--panel-2); border: 1px solid var(--hairline); border-radius: var(--radius);
  padding: 10px 12px; font-size: 13px; color: var(--text-dim); margin: 6px 0;
}
.reveal-hidden-comment-btn {
  background: none; border: none; color: var(--gold-soft); font: inherit; font-size: 13px;
  cursor: pointer; padding: 0; text-decoration: underline;
}

/* ================= Nhieu anh dinh kem 1 lan dang (binh luan, bai viet dien dan) ================= */
.comment-image-preview-wrap { display: flex; flex-wrap: wrap; gap: 10px; }
.comment-image-gallery { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.comment-image-gallery .gallery-img {
  max-width: 160px; max-height: 160px; margin-top: 0; object-fit: cover;
}
.forum-post-image.gallery-img { max-width: 260px; max-height: 260px; margin-bottom: 0; }

/* ================= Sua binh luan/bai viet: nhan "da chinh sua" + xem lich su ================= */
.comment-edited-note { font-size: 12px; color: var(--text-dim); margin-top: 6px; }
.edit-comment-btn { background: none; border: none; color: var(--text-dim); cursor: pointer; font-size: 12px; font: inherit; padding: 0; }
.edit-comment-btn:hover:not(:disabled) { color: var(--gold-soft); text-decoration: underline; }
.edit-comment-btn:disabled { opacity: .45; cursor: not-allowed; }
.edit-form-slot:not([hidden]) { margin: 10px 0 0 0; padding-left: 2px; }
.edit-form-slot .comment-form { margin-bottom: 0; }
.edit-history-item { border-bottom: 1px solid var(--hairline); padding: 12px 0; font-size: 14px; }
.edit-history-item:last-child { border-bottom: none; }
.edit-history-meta { font-size: 12px; color: var(--text-dim); margin-bottom: 4px; }

/* ================= Tab sap xep binh luan: Moi nhat / Noi bat (theo vote) ================= */
.comment-sort-tabs { display: flex; gap: 14px; margin: 4px 0 14px; border-bottom: 1px solid var(--hairline); }
.comment-sort-tab {
  background: none; border: none; border-bottom: 2px solid transparent; color: var(--text-dim);
  font: inherit; font-size: 13px; padding: 6px 2px; cursor: pointer;
}
.comment-sort-tab.active { color: var(--gold-soft); border-color: var(--gold-soft); font-weight: 600; }
.comment-sort-tab:hover:not(.active) { color: var(--text); }

/* ================= Nut "Xin làm Tác giả" tren top-bar (Doc gia) ================= */
.author-request-btn {
  width: auto; height: 34px; border-radius: 17px; padding: 0 14px; font-size: 13px; white-space: nowrap;
}
.author-request-btn:disabled { opacity: .6; cursor: default; }

/* ================= Theo doi 1 bai viet dien dan cu the (khac voi theo doi truyen) ================= */
.following-post-row { cursor: pointer; }
.following-post-row:hover { border-color: var(--gold-soft); }
