/* Mẹ Bông Bom – giao diện. Màu nhấn lấy từ chữ ký màu đất nung trong logo. */
:root {
  --bg: #faf6ee;
  --surface: #fffdf9;
  --surface-2: #f3ecdf;
  --line: #e7dccb;
  --ink: #27211c;
  --muted: #776b60;
  --accent: #c4532b;
  --accent-ink: #a8431f;
  --accent-soft: #f8e6dc;
  --on-accent: #fff;
  --gold: #a9701a;
  --gold-soft: #fbf0d6;
  --ok: #2e7a50;
  --ok-soft: #e2f2e8;
  --warn: #9a6200;
  --warn-soft: #fdf1d3;
  --err: #b3261e;
  --err-soft: #fbe5e3;
  --logo-bg: transparent;
  --shadow: 0 1px 2px rgba(60, 40, 20, 0.06), 0 6px 20px rgba(60, 40, 20, 0.06);
  --radius: 12px;
  --ui: 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --serif: 'Literata', Georgia, 'Times New Roman', serif;
  --reader-fs: 19px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #191613; --surface: #221e1a; --surface-2: #2b2621; --line: #3b342d; --ink: #ebe4d9; --muted: #a59a8e;
    --accent: #e9895f; --accent-ink: #f2a380; --accent-soft: #3a2a22; --on-accent: #1d120c;
    --gold: #e0b060; --gold-soft: #33290f; --ok: #7fcf9f; --ok-soft: #1c3226; --warn: #e6bb5c; --warn-soft: #362b10; --err: #f29088; --err-soft: #3b1e1c;
    --logo-bg: #fbf6ec; --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 20px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --bg: #191613; --surface: #221e1a; --surface-2: #2b2621; --line: #3b342d; --ink: #ebe4d9; --muted: #a59a8e;
  --accent: #e9895f; --accent-ink: #f2a380; --accent-soft: #3a2a22; --on-accent: #1d120c;
  --gold: #e0b060; --gold-soft: #33290f; --ok: #7fcf9f; --ok-soft: #1c3226; --warn: #e6bb5c; --warn-soft: #362b10; --err: #f29088; --err-soft: #3b1e1c;
  --logo-bg: #fbf6ec; --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 20px rgba(0, 0, 0, 0.25);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--ui); font-size: 16px; line-height: 1.6; min-height: 100vh; display: flex; flex-direction: column; }
main { flex: 1; }
img { max-width: 100%; height: auto; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-family: var(--serif); line-height: 1.25; margin: 0 0 0.5em; text-wrap: balance; }
h1 { font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.2rem); }
p { margin: 0 0 1em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: 8px; z-index: 100; }
.skip:focus { left: 8px; }
.wrap { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 20px; }
.narrow { max-width: 780px; }
.pad { padding-top: 28px; padding-bottom: 56px; }
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.nowrap { white-space: nowrap; }
.hp { position: absolute !important; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.ic { flex: none; vertical-align: -3px; }
.empty { color: var(--muted); padding: 18px 0; }

/* Khách chưa đăng nhập: không cho bôi đen nội dung (ô nhập liệu vẫn dùng bình thường) */
.is-guest { -webkit-user-select: none; user-select: none; }
.is-guest input, .is-guest textarea { -webkit-user-select: text; user-select: text; }

/* ---------- Đầu trang ---------- */
.site-header { position: sticky; top: 0; z-index: 50; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.bar { display: flex; align-items: center; gap: 10px; min-height: 74px; }
.logo { display: flex; flex: none; background: var(--logo-bg); border-radius: 10px; padding: 3px 8px 3px 2px; margin-right: 6px; }
.logo img { display: block; height: 58px; width: auto; }
.nav { display: flex; align-items: center; gap: 2px; }
.nav > a, .dd-btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 8px; color: var(--ink); font: inherit; font-weight: 500; font-size: 0.95rem; background: none; border: 0; cursor: pointer; white-space: nowrap; }
.nav > a:hover, .dd-btn:hover { background: var(--surface-2); text-decoration: none; }
.nav-vip { color: var(--gold) !important; }
.dd { position: relative; }
.dd-btn::after { content: ''; width: 6px; height: 6px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg) translateY(-2px); opacity: 0.6; }
.dd-menu { display: none; position: absolute; top: calc(100% + 6px); left: 0; min-width: 220px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 6px; z-index: 60; }
.dd-right .dd-menu { left: auto; right: 0; }
.dd.open .dd-menu { display: block; }
.dd-menu a { display: block; padding: 8px 12px; border-radius: 8px; color: var(--ink); }
.dd-menu a:hover { background: var(--surface-2); text-decoration: none; }
.search { flex: 1; max-width: 300px; margin-left: auto; display: flex; align-items: center; gap: 8px; background: var(--surface-2); border: 1px solid transparent; border-radius: 999px; padding: 0 14px; color: var(--muted); }
.search:focus-within { border-color: var(--accent); background: var(--surface); }
.search input[type='search'] { flex: 1; min-width: 0; width: 0; margin: 0; border: 0; border-radius: 0; background: none; outline: none; color: var(--ink); font: inherit; font-size: 0.92rem; padding: 9px 0; }
.bar > .btn { white-space: nowrap; flex: none; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; min-width: 38px; height: 38px; padding: 0 8px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); }
.burger { display: none; }
.user-name { max-width: 120px; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Nút, nhãn ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 18px; border-radius: 10px; border: 1px solid var(--accent); background: var(--accent); color: var(--on-accent); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; line-height: 1.3; transition: filter 0.15s; }
.btn:hover { filter: brightness(0.94); text-decoration: none; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--surface-2); filter: none; }
.btn-vip { background: var(--gold); border-color: var(--gold); color: #fff; }
:root[data-theme='dark'] .btn-vip { color: #1d1508; }
.btn-danger { background: transparent; border-color: var(--err); color: var(--err); }
.btn-danger:hover { background: var(--err-soft); filter: none; }
.btn-sm { padding: 6px 12px; font-size: 0.875rem; border-radius: 8px; }
.btn-block { width: 100%; }
.btn.is-disabled { opacity: 0.4; pointer-events: none; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.02em; white-space: nowrap; }
.badge-done { background: var(--ok-soft); color: var(--ok); }
.badge-on { background: var(--accent-soft); color: var(--accent-ink); }
.badge-vip { background: var(--gold-soft); color: var(--gold); }

/* ---------- Dải thông báo ---------- */
.ribbon { font-size: 0.92rem; padding: 9px 0; border-bottom: 1px solid var(--line); }
.ribbon-thanks { background: var(--accent-soft); color: var(--accent-ink); font-style: italic; text-align: center; }
.ribbon-warn { background: var(--warn-soft); color: var(--warn); }
.notice { padding: 12px 16px; border-radius: 10px; margin: 0 0 18px; border: 1px solid var(--line); background: var(--surface); }
.notice-ok { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.notice-err { background: var(--err-soft); border-color: transparent; color: var(--err); }
.notice-warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }

/* ---------- Khối, tiêu đề ---------- */
.section { margin-bottom: 44px; }
.sec-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.sec-title { font-size: 1.3rem; margin-bottom: 16px; padding-bottom: 8px; border-bottom: 2px solid var(--line); position: relative; flex: 1; }
.sec-title::after { content: ''; position: absolute; left: 0; bottom: -2px; width: 56px; height: 2px; background: var(--accent); }
.sec-head a { font-size: 0.9rem; white-space: nowrap; }
.page-title { margin-bottom: 22px; }
.crumbs { font-size: 0.875rem; color: var(--muted); margin-bottom: 14px; }
.crumbs span { margin: 0 4px; opacity: 0.6; }
.home-cols { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 40px; }

/* ---------- Thẻ truyện ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 24px 18px; }
.card .cover { position: relative; display: block; aspect-ratio: 2 / 3; border-radius: var(--radius); overflow: hidden; background: var(--surface-2); box-shadow: var(--shadow); }
.card .cover img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.3s; }
.card:hover .cover img { transform: scale(1.04); }
.card .cover .badge { position: absolute; top: 8px; left: 8px; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2); }
.card-title { font-size: 1rem; margin: 10px 0 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-title a { color: var(--ink); }
.card-meta { font-size: 0.8rem; color: var(--muted); margin: 0; }

/* ---------- Mới cập nhật, xếp hạng, đọc tiếp ---------- */
.upd-list, .rank, .plain-list, .ch-list, .cm-list, .adm-list { list-style: none; margin: 0; padding: 0; }
.upd { display: flex; gap: 14px; align-items: center; padding: 12px 0; border-bottom: 1px dashed var(--line); }
.upd-cover img { width: 48px; height: 64px; object-fit: cover; border-radius: 6px; display: block; background: var(--surface-2); }
.upd-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.upd-title { font-family: var(--serif); font-weight: 600; font-size: 1.05rem; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.upd-ch { font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.upd-ch .ic { margin-right: 4px; color: var(--gold); }
.upd-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; font-size: 0.78rem; color: var(--muted); white-space: nowrap; }
.rank li { display: flex; gap: 14px; align-items: center; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.rank-n { font-family: var(--serif); font-size: 1.7rem; font-weight: 700; color: var(--accent); width: 28px; text-align: center; line-height: 1; opacity: 0.9; }
.rank li:nth-child(n + 4) .rank-n { color: var(--muted); opacity: 0.6; }
.rank-body { display: flex; flex-direction: column; min-width: 0; }
.rank-body a { font-family: var(--serif); font-weight: 600; color: var(--ink); }
.rank-body .muted { font-size: 0.8rem; }
.resume { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.resume-item { display: flex; gap: 12px; align-items: center; padding: 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink); }
.resume-item:hover { border-color: var(--accent); text-decoration: none; }
.resume-item img { width: 42px; height: 56px; object-fit: cover; border-radius: 6px; flex: none; }
.resume-item span { display: flex; flex-direction: column; min-width: 0; }
.resume-item strong, .resume-item .muted { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.resume-item .muted { font-size: 0.85rem; }
.plain-list li { padding: 7px 0; border-bottom: 1px dashed var(--line); }
.sform { display: flex; gap: 10px; max-width: 560px; margin-bottom: 10px; }
.sform input[type='search'] { flex: 1; min-width: 0; margin: 0; border-radius: 999px; padding: 11px 18px; }
.sform .btn { flex: none; border-radius: 999px; padding-left: 22px; padding-right: 22px; }
.s-tip { color: var(--muted); font-size: 0.875rem; margin: 0 0 30px; }
.s-group { margin-bottom: 26px; }
.s-group h3 { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; font-size: 1.08rem; margin: 0 0 2px; }
.s-group h3 a { color: var(--ink); }
.s-group h3 small { font-family: var(--ui); font-weight: 400; font-size: 0.8rem; color: var(--muted); }
.s-rest summary { cursor: pointer; color: var(--accent-ink); font-size: 0.9rem; padding: 10px 4px; }
.ch-list a span small { display: block; font-size: 0.8rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }

/* ---------- Trang truyện ---------- */
.story-head { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 32px; margin-bottom: 28px; }
.story-cover { width: 100%; aspect-ratio: 2 / 3; object-fit: cover; border-radius: var(--radius); box-shadow: var(--shadow); background: var(--surface-2); }
.meta { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0 0 18px; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; font-weight: 500; }
.story-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.story-desc { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 24px; margin-bottom: 36px; }
.story-desc.is-collapsed { max-height: 15em; overflow: hidden; position: relative; }
.story-desc.is-collapsed::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 5em; background: linear-gradient(transparent, var(--surface)); pointer-events: none; }
.desc-more { display: block; margin: -24px auto 36px; position: relative; }
.prose { font-family: var(--serif); font-size: 1.05rem; line-height: 1.8; overflow-wrap: break-word; }
.prose h2, .prose h3 { margin-top: 1.4em; }
.prose img { border-radius: 10px; }
.prose > :last-child { margin-bottom: 0; }
.ch-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 32px; }
.ch-list a { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 4px; border-bottom: 1px dashed var(--line); color: var(--ink); }
.ch-list a span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-list a:hover { color: var(--accent-ink); text-decoration: none; }
.ch-list a:visited span { color: var(--muted); }
.ch-list .is-locked .ic { color: var(--gold); }
.pager { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 24px; }
.pg { min-width: 40px; padding: 8px 12px; text-align: center; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); }
.pg.cur { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 700; }
.pg-gap { padding: 8px 2px; color: var(--muted); }

/* ---------- Trang đọc ---------- */
.reader { max-width: 780px; }
.ch-head { text-align: center; margin: 8px 0 20px; }
.ch-head h1 { margin-bottom: 8px; }
.tools { display: inline-flex; gap: 8px; margin-top: 6px; }
.ch-nav { display: flex; justify-content: space-between; gap: 8px; margin: 18px 0; }
.ch-nav .btn { flex: 1; padding-left: 10px; padding-right: 10px; }
.ch-body { font-family: var(--serif); font-size: var(--reader-fs); line-height: 1.9; margin: 28px 0; overflow-wrap: break-word; }
.ch-body p { margin: 0 0 1.15em; }
.ch-body .mid-note { text-align: center; font-style: italic; font-size: 0.9em; color: var(--muted); padding: 10px 14px; border-top: 1px dashed var(--line); border-bottom: 1px dashed var(--line); }
.ch-body .pc { min-height: 1.9em; }
.ch-body .pc canvas { display: block; width: 100%; }
.lockbox { font-family: var(--ui); font-size: 1rem; line-height: 1.6; text-align: center; background: var(--gold-soft); border: 1px solid color-mix(in srgb, var(--gold) 35%, transparent); border-radius: 16px; padding: 30px 24px; margin-top: 24px; }
.lockbox h3 { font-size: 1.25rem; color: var(--gold); margin-bottom: 10px; }
.lock-ic { display: inline-flex; width: 54px; height: 54px; align-items: center; justify-content: center; border-radius: 50%; background: var(--surface); color: var(--gold); margin-bottom: 10px; }
.lock-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin: 18px 0 12px; }
.lock-note { font-size: 0.875rem; color: var(--muted); margin: 6px 0 0; }
.lock-steps { list-style: none; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 18px 0 4px; padding: 0; text-align: left; }
.lock-steps li { display: flex; gap: 10px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; font-weight: 600; font-size: 0.92rem; line-height: 1.35; }
.lock-steps b { flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--gold); color: var(--surface); display: inline-flex; align-items: center; justify-content: center; font-size: 0.85rem; }
.lock-steps small { display: block; font-weight: 400; color: var(--muted); font-size: 0.8rem; }
.vipcard .lock-actions { justify-content: flex-start; margin-bottom: 0; }

/* ---------- Khung chuyển khoản VIP ---------- */
.pay { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 18px 24px; align-items: start; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 20px; margin: 18px 0 12px; font-family: var(--ui); font-size: 0.95rem; line-height: 1.55; }
.pay p { margin: 0; text-indent: 0; text-align: left; }
.pay-qr { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.pay-qr img { display: block; width: 220px; height: 220px; border-radius: 10px; background: #fff; border: 1px solid var(--line); image-rendering: pixelated; }
.pay .pay-how { margin: 0 0 10px; color: var(--muted); font-size: 0.9rem; }
.pay-how strong { color: var(--ink); }
.pay-rows { margin: 0; }
.pay-rows > div { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.pay-rows > div:last-child { border-bottom: 0; }
.pay-rows dt { flex: 0 0 108px; color: var(--muted); font-size: 0.875rem; }
.pay-rows dd { margin: 0; flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 10px; font-weight: 600; }
.pay-rows code { font-size: 1rem; font-weight: 700; -webkit-user-select: all; user-select: all; }
#pay-code { color: var(--accent-ink); letter-spacing: 0.04em; }
.pay-alt { grid-column: 1 / -1; border-top: 1px solid var(--line); padding-top: 12px; }
.pay-alt summary { cursor: pointer; font-weight: 600; font-size: 0.95rem; color: var(--accent-ink); padding: 4px 0; }
.pay-alt[open] summary { margin-bottom: 6px; }
.pay-alt .pay-rows dt { flex-basis: 132px; }
.pay-alt .pay-rows code { overflow-wrap: anywhere; }
.pay .pay-alt-note { margin: 10px 0 0; color: var(--muted); font-size: 0.9rem; }
.pay-alt-act { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.pay-alt-act form { margin: 0; }
.pay-foot { grid-column: 1 / -1; border-top: 1px solid var(--line); padding-top: 14px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.pay-foot form { margin: 0; }
.pay-wait { margin: 0; flex: 1 1 300px; font-size: 0.9rem; color: var(--muted); display: flex; gap: 10px; align-items: baseline; }
.pay-wait.is-done { color: var(--ok); font-weight: 600; }
.pay-dot { flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--gold); animation: pay-pulse 1.4s ease-in-out infinite; }
.pay-wait.is-done .pay-dot { display: none; }
.pay-sent { margin: 0; flex: 1 1 100%; font-size: 0.9rem; color: var(--ok); background: var(--ok-soft); border-radius: 8px; padding: 8px 12px; }
@keyframes pay-pulse { 0%, 100% { opacity: 0.3; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .pay-dot { animation: none; } }
@media (max-width: 640px) {
  .pay { grid-template-columns: minmax(0, 1fr); padding: 16px; }
  .pay-rows > div { flex-direction: column; align-items: stretch; gap: 2px; }
  .pay-rows dt { flex: none; font-size: 0.8rem; }
  .pay-alt .pay-rows dt { flex: none; }
  .lock-steps { grid-template-columns: 1fr; }
  .lockbox { padding: 24px 14px; }
}
.btn-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.btn-row input[type='text'] { margin: 0; width: 180px; padding: 6px 10px; }
.btn-row .tag { margin-left: 0; }
.panel-hot { border-color: var(--gold); }
.panel h3 { font-size: 1rem; margin: 20px 0 10px; }

.donate { font-family: var(--ui); font-size: 0.95rem; line-height: 1.6; background: var(--accent-soft); color: var(--ink); border-radius: var(--radius); padding: 18px 22px; margin: 28px 0 8px; -webkit-user-select: text; user-select: text; }
.donate p { margin: 0 0 10px; }
.donate > :last-child, .donate p:last-child { margin-bottom: 0; }
.donate a { font-weight: 600; text-decoration: underline; }
.donate .donate-flex { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.donate .donate-info { min-width: 0; overflow-wrap: anywhere; }
.donate img { display: block; width: 132px; height: auto; border-radius: 10px; background: #fff; flex: none; }

/* ---------- Bình luận ---------- */
.comments { margin-top: 48px; }
.cm-form { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 22px; }
.cm { padding: 14px 0; border-bottom: 1px dashed var(--line); }
.cm-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cm-head time { color: var(--muted); font-size: 0.8rem; margin-left: auto; }
.cm-body { margin: 6px 0 0; white-space: pre-line; overflow-wrap: anywhere; }
.cm-at { font-size: 0.8rem; margin: 2px 0 0; }

/* ---------- Biểu mẫu ---------- */
label { display: block; font-weight: 500; font-size: 0.92rem; margin-bottom: 14px; }
label small { display: block; font-weight: 400; color: var(--muted); margin-top: 4px; }
input[type='text'], input[type='email'], input[type='password'], input[type='search'], input[type='number'], input[type='datetime-local'], input[type='time'], input[type='file'], select, textarea {
  display: block; width: 100%; margin-top: 6px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); font: inherit; font-weight: 400;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
input:disabled { background: var(--surface-2); color: var(--muted); }
textarea { resize: vertical; line-height: 1.6; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 16px; }
.row-wide-first { grid-template-columns: 3fr 1fr; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; }
.check input { margin-top: 5px; }
.auth-card { max-width: 430px; margin: 24px auto; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 28px; box-shadow: var(--shadow); }
.auth-card h1 { font-size: 1.6rem; text-align: center; margin-bottom: 20px; }
.auth-links { text-align: center; font-size: 0.92rem; margin: 16px 0 0; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 20px; }
.panel h2 { font-size: 1.15rem; }
.panel > :last-child { margin-bottom: 0; }
.vipcard { background: var(--gold-soft); border: 1px solid color-mix(in srgb, var(--gold) 35%, transparent); border-radius: var(--radius); padding: 16px 20px; margin-bottom: 22px; }
.vipcard p:last-child { margin-bottom: 0; }
.transfer { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
code { font-family: ui-monospace, Consolas, monospace; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 2px 8px; font-size: 0.95em; }
.wrap-code { display: inline-block; word-break: break-all; margin-top: 6px; -webkit-user-select: all; user-select: all; }
details summary { cursor: pointer; color: var(--accent-ink); margin-bottom: 8px; }

/* ---------- Chân trang ---------- */
.site-footer { border-top: 1px solid var(--line); background: var(--surface); font-size: 0.9rem; color: var(--muted); padding: 26px 0; }
.foot { display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.foot nav { display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: flex-start; }

/* ---------- Quản trị ---------- */
.admin { background: var(--bg); }
.adm-top { position: sticky; top: 0; z-index: 40; display: flex; align-items: center; gap: 18px; padding: 0 20px; background: #2a231d; color: #f4ece0; overflow-x: auto; }
.adm-top a { color: #e8ddcd; white-space: nowrap; }
.adm-brand { font-weight: 700; padding: 14px 0; }
.adm-top nav { display: flex; gap: 2px; flex: 1; }
.adm-top nav a { padding: 14px 12px; border-bottom: 3px solid transparent; font-size: 0.94rem; }
.adm-top nav a:hover { background: rgba(255, 255, 255, 0.07); text-decoration: none; }
.adm-top nav a.cur { border-bottom-color: #e9895f; color: #fff; font-weight: 600; }
.adm-main { width: 100%; max-width: 1180px; margin: 0 auto; padding: 26px 20px 60px; }
.adm-main > h1 { font-size: 1.6rem; margin-bottom: 18px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 22px; }
.stats > div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; color: var(--muted); font-size: 0.875rem; }
.stats b { display: block; font-family: var(--serif); font-size: 1.7rem; color: var(--ink); line-height: 1.2; }
.stats a { color: inherit; display: block; }
.stats > div:hover { border-color: var(--accent); }
.cols2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 14px; }
.inline-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; margin-bottom: 12px; }
.inline-form label { margin-bottom: 0; flex: 1; min-width: 150px; }
.inline-form select, .inline-form input { margin-top: 6px; }
.toolbar .inline-form { margin-bottom: 0; flex: 1; min-width: 260px; }
.toolbar .inline-form input, .toolbar .inline-form select { margin-top: 0; flex: 1; width: auto; }
.row-form { margin: 0; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; }
.tabs a { padding: 6px 12px; border-radius: 999px; color: var(--ink); font-size: 0.9rem; border: 1px solid var(--line); background: var(--surface); }
.tabs a.cur { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); margin-bottom: 16px; }
.table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.table th, .table td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { background: var(--surface-2); font-weight: 600; white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table .thumb, .thumb { border-radius: 6px; object-fit: cover; display: block; background: var(--surface-2); }
.tag { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 0.78rem; font-weight: 600; white-space: nowrap; margin-left: 4px; }
td > .tag:first-child, p > .tag:first-child { margin-left: 0; }
.tag-ok { background: var(--ok-soft); color: var(--ok); }
.tag-warn { background: var(--warn-soft); color: var(--warn); }
.tag-off { background: var(--surface-2); color: var(--muted); }
.form.wide { max-width: 900px; }
.form-actions { display: flex; gap: 10px; margin: 6px 0 20px; }
.editor { font-family: var(--serif); font-size: 1.02rem; line-height: 1.7; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 0.9rem; }
.adm-list > li { display: flex; gap: 16px; justify-content: space-between; align-items: flex-start; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px; }
.adm-actions { display: flex; gap: 8px; flex: none; }
.adm-actions form { margin: 0; }
.nav-n { display: inline-block; min-width: 18px; margin-left: 5px; padding: 0 5px; border-radius: 999px; background: #e9895f; color: #1d120c; font-size: 0.72rem; font-weight: 700; line-height: 18px; text-align: center; }
.tabs a small { color: inherit; opacity: 0.65; font-size: 0.8em; margin-left: 2px; }
.filters select { flex: 0 1 180px; }
.crumb-links { display: flex; flex-wrap: wrap; gap: 4px 0; }
.half { max-width: 440px; }
.form-actions { flex-wrap: wrap; }
/* Ô chọn truyện có tìm kiếm */
.pick { position: relative; flex: 1; min-width: 240px; }
label .pick { margin-top: 6px; }
.pick-input { margin-top: 0 !important; }
.pick-native { position: absolute !important; left: 0; bottom: 0; width: 100% !important; height: 1px !important; padding: 0 !important; margin: 0 !important; border: 0 !important; opacity: 0; pointer-events: none; }
.pick-list { position: absolute; z-index: 30; top: calc(100% + 4px); left: 0; right: 0; max-height: 340px; overflow-y: auto; margin: 0; padding: 4px; list-style: none; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); font-weight: 400; font-size: 0.94rem; }
.pick-list li { padding: 8px 10px; border-radius: 7px; cursor: pointer; }
.pick-list li.is-cur { font-weight: 600; color: var(--accent-ink); }
.pick-list li.is-active, .pick-list li[role='option']:hover { background: var(--accent-soft); }
.pick-list .pick-note { color: var(--muted); font-size: 0.85rem; cursor: default; }
.pick-list .pick-note:hover { background: none; }
.toolbar .inline-form .pick-input { width: 100%; }
/* Thanh lối tắt quản trị trên trang đọc */
.adm-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; padding: 8px 14px; margin: 0 0 16px; border: 1px dashed var(--accent); border-radius: 10px; background: var(--accent-soft); font-size: 0.88rem; }
.adm-bar span { font-weight: 600; color: var(--muted); }

/* ---------- Màn hình nhỏ ---------- */
@media (max-width: 900px) {
  .burger { display: inline-flex; }
  .bar { position: relative; }
  .nav { display: none; position: absolute; top: 100%; left: 0; right: 0; flex-direction: column; align-items: stretch; background: var(--surface); border-bottom: 1px solid var(--line); padding: 10px 16px 16px; box-shadow: var(--shadow); }
  .nav-open .nav { display: flex; }
  .nav .dd-menu { position: static; display: block; box-shadow: none; border: 0; padding: 0 0 0 14px; }
  .nav .dd-btn::after { display: none; }
  .search { max-width: none; }
  .home-cols { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .cols2 { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .wrap { padding: 0 16px; }
  .bar { gap: 8px; min-height: 60px; }
  .logo { flex: 0 1 auto; min-width: 0; margin-right: auto; }
  .logo img { height: auto; max-height: 44px; max-width: 100%; }
  .search { display: none; position: absolute; top: calc(100% + 10px); left: 16px; right: 16px; max-width: none; margin: 0; z-index: 61; }
  .nav-open .search { display: flex; }
  .nav-open .nav { padding-top: 66px; }
  .bar > .btn { padding: 7px 12px; font-size: 0.875rem; white-space: nowrap; flex: none; }
  .bar > .icon-btn, .bar > .dd { flex: none; }
  .user-name { display: none; }
  .story-head { grid-template-columns: 1fr; gap: 18px; }
  .story-cover { max-width: 190px; margin: 0 auto; }
  .ch-list { grid-template-columns: 1fr; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 20px 14px; }
  .row2, .row3, .row-wide-first { grid-template-columns: 1fr; }
  .hide-sm { display: none; }
  .upd-side .badge { display: none; }
  .auth-card { padding: 22px 18px; }
  .adm-list > li { flex-direction: column; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}
@media print {
  .ch-body, .prose { display: none; }
}
