/* Mobile first. Bottom tab bar under 900px, top nav above. Light + dark from the system setting. */
:root {
  --bg: #faf7f2; --card: #ffffff; --ink: #1c1915; --muted: #6b6358; --line: #e7e0d5;
  --accent: #c2651a; --accent-ink: #ffffff; --soft: #fbeee2; --ok: #2f7d4f; --warn: #a1441a;
  --radius: 12px; --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 14px rgba(0,0,0,.05);
  --tab-h: 62px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #14110d; --card: #1e1a15; --ink: #f1ebe2; --muted: #a59b8e; --line: #322b23;
    --accent: #f0913a; --accent-ink: #1a1208; --soft: #2a2017; --ok: #6cc28f; --warn: #f0a07a;
    --shadow: 0 1px 2px rgba(0,0,0,.4); }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom)); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.skip { position: absolute; left: -999px; } .skip:focus { left: 8px; top: 8px; background: var(--card); padding: 6px 10px; z-index: 99; }
.muted { color: var(--muted); } .small { font-size: .85rem; }
h1 { font-size: 1.6rem; line-height: 1.25; margin: .6em 0 .4em; }
h2 { font-size: 1.2rem; margin: 0 0 .6em; }
h3 { font-size: 1rem; margin: 0; }

/* header */
.top { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.top-in { display: flex; align-items: center; gap: 16px; height: 54px; }
.logo { font-weight: 800; font-size: 1.15rem; color: var(--ink); display: flex; align-items: center; gap: 6px; }
.logo:hover { text-decoration: none; }
.logo-mark { color: var(--accent); }
.logo small { font-weight: 600; font-size: .65rem; color: var(--accent); border: 1px solid var(--accent); border-radius: 99px; padding: 0 6px; }
.top-nav { display: none; margin-left: auto; gap: 18px; }
.top-nav a { color: var(--muted); font-weight: 600; font-size: .95rem; }
.top-nav a[aria-current] { color: var(--ink); }

/* bottom tab bar */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tab-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--card); border-top: 1px solid var(--line); }
.tabbar a { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); font-size: .72rem; font-weight: 600; }
.tabbar a:hover { text-decoration: none; }
.tabbar a[aria-current] { color: var(--accent); }
.badge { position: absolute; top: 8px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px;
  background: #d3392f; color: #fff; font: 700 .68rem/18px system-ui; text-align: center; font-style: normal; }
@media (min-width: 900px) {
  body { padding-bottom: 0; }
  .tabbar { display: none; }
  .top-nav { display: flex; }
  h1 { font-size: 2rem; }
}

/* blocks */
.hero { padding: 18px 0 6px; }
.hero h1 { font-size: 1.7rem; }
.hero p { color: var(--muted); max-width: 46em; margin: 0; }
@media (min-width: 900px) { .hero h1 { font-size: 2.4rem; } }
.block { margin: 26px 0; }
.block-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.block-head a { font-weight: 600; font-size: .9rem; }

.ch-list { list-style: none; margin: 0; padding: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.ch-list li { display: grid; grid-template-columns: 1fr auto; gap: 0 12px; padding: 10px 14px; border-top: 1px solid var(--line); }
.ch-list li:first-child { border-top: 0; }
.ch-title { color: var(--ink); font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-link { font-weight: 700; white-space: nowrap; }
.ch-date { grid-column: 1 / -1; color: var(--muted); font-size: .8rem; }

.grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
@media (min-width: 560px) { .grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 900px) { .grid { grid-template-columns: repeat(5, 1fr); } }
.card a { position: relative; display: flex; flex-direction: column; gap: 2px; color: var(--ink); }
.card a:hover { text-decoration: none; }
.card a:hover .card-name { color: var(--accent); }
.cv { display: block; width: 100%; height: auto; aspect-ratio: 1 / 1.42; object-fit: cover; border-radius: 10px; background: var(--line); box-shadow: var(--shadow); }
.cv-none { display: grid; place-items: center; font-size: 2rem; color: var(--muted); }
.rank { position: absolute; top: 6px; left: 6px; background: rgba(0,0,0,.72); color: #fff; font-weight: 800; font-size: .75rem; padding: 1px 7px; border-radius: 99px; }
.card-name { font-weight: 700; line-height: 1.3; margin-top: 6px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-meta, .card-ch { font-size: .78rem; color: var(--muted); }
.tag { align-self: flex-start; font-size: .7rem; font-weight: 700; border-radius: 99px; padding: 0 8px; margin-top: 3px; }
.tag-rv { background: var(--soft); color: var(--accent); }

.rv-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.rv-list a { display: flex; gap: 12px; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; color: var(--ink); }
.rv-list .cv { width: 48px; }
.rv-list span { display: flex; flex-direction: column; }
.rv-list small { color: var(--muted); }
.stars { color: #e0a321; letter-spacing: 1px; }

.promo a { display: grid; grid-template-columns: 110px 1fr; gap: 14px; align-items: center; background: #15110c; color: #efe6d8;
  border-radius: var(--radius); overflow: hidden; }
.promo a:hover { text-decoration: none; }
.promo img { width: 110px; height: 150px; object-fit: cover; }
.promo span { padding: 12px 14px 12px 0; font-size: .92rem; }
.promo small { display: block; color: #f0913a; font-weight: 700; }
.promo b { display: block; font-size: 1.2rem; }

/* title page */
.crumb { font-size: .85rem; color: var(--muted); margin-top: 12px; }
.t-head { display: grid; grid-template-columns: 1fr; gap: 16px; margin-top: 8px; }
.t-cover .cv { width: 150px; margin: 0 auto; }
@media (min-width: 700px) { .t-head { grid-template-columns: 220px 1fr; } .t-cover .cv { width: 220px; } }
.eyebrow { color: var(--accent); font-weight: 700; font-size: .8rem; margin: 0; text-transform: uppercase; letter-spacing: .04em; }
.t-info h1 { margin-top: .2em; }
.lede { font-size: 1.02rem; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 14px 0; }
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 16px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink); font: inherit; font-weight: 700; cursor: pointer; }
.btn:hover { text-decoration: none; border-color: var(--accent); }
.btn-main { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn[aria-pressed="true"] { background: var(--soft); border-color: var(--accent); color: var(--accent); }
.shelf-st { display: inline-flex; gap: 6px; align-items: center; font-size: .9rem; color: var(--muted); }
.shelf-st select { min-height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font: inherit; padding: 0 8px; }
.rate { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; }
.rate-label { flex-basis: 100%; font-size: .9rem; color: var(--muted); }
.rate button { background: none; border: 0; font-size: 1.7rem; line-height: 1; color: var(--line); cursor: pointer; padding: 4px; min-width: 40px; min-height: 44px; }
.rate button.on { color: #e0a321; }
.rate-sum { flex-basis: 100%; }
.sec-nav { position: sticky; top: 54px; z-index: 10; display: flex; gap: 6px; overflow-x: auto; margin: 18px -16px 0; padding: 8px 16px;
  background: var(--bg); border-bottom: 1px solid var(--line); scrollbar-width: none; }
.sec-nav a { flex: none; padding: 6px 12px; border-radius: 99px; background: var(--card); border: 1px solid var(--line); color: var(--ink); font-weight: 600; font-size: .9rem; }
.sec { padding-top: 22px; scroll-margin-top: 110px; }
.fit { background: var(--soft); border-radius: 10px; padding: 10px 14px; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 14px 0 0; }
.facts dt { color: var(--muted); } .facts dd { margin: 0; }
.rv { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 14px; }
.rv header { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px; margin-bottom: 6px; }
.rv-ai { border-left: 4px solid #7a6cf0; }
.rv-owner { border-left: 4px solid var(--accent); }
.rv h4 { margin: 1em 0 .3em; }
.rv-label, .rv-by { font-size: .8rem; color: var(--muted); border-top: 1px dashed var(--line); padding-top: 8px; margin-bottom: 0; }
.chapters { list-style: none; margin: 0; padding: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.chapters li a { display: grid; grid-template-columns: auto 1fr auto auto; gap: 10px; align-items: center; padding: 10px 14px; border-top: 1px solid var(--line); color: var(--ink); min-height: 44px; }
.chapters li:first-child a { border-top: 0; }
.chapters .n { font-weight: 700; white-space: nowrap; }
.chapters .nm { color: var(--muted); font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.chapters .d { color: var(--muted); font-size: .8rem; white-space: nowrap; }
.chapters .go { color: var(--accent); }
.more { margin-top: 10px; } .more summary { cursor: pointer; font-weight: 700; color: var(--accent); min-height: 44px; display: flex; align-items: center; }
.tip { margin-top: 12px; }
.rv-form { display: grid; gap: 10px; margin-top: 14px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.rv-form label { display: grid; gap: 4px; font-weight: 600; }
.rv-form textarea, .rv-form input { font: inherit; border: 1px solid var(--line); border-radius: 8px; padding: 10px; background: var(--bg); color: var(--ink); }
.rv-form .btn { justify-self: start; }
.form-msg { margin: 0; font-weight: 600; }
.form-msg.ok { color: var(--ok); } .form-msg.err { color: var(--warn); }
.reader-rv { border-top: 1px solid var(--line); padding: 10px 0; }
.reader-rv:first-child { border-top: 0; }
.reader-rv p { margin: .2em 0; white-space: pre-line; }
.src { margin-top: 26px; }

/* schedule */
.week { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 700px) { .week { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 1000px) { .week { grid-template-columns: repeat(7, 1fr); } }
.day { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.day.today { border-color: var(--accent); box-shadow: 0 0 0 2px var(--soft); }
.day.today h3::after { content: " · hôm nay"; color: var(--accent); font-weight: 600; }
.day ul { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 8px; }
.day a { display: flex; gap: 10px; align-items: center; color: var(--ink); font-weight: 600; font-size: .9rem; line-height: 1.3; }
.day .cv { width: 40px; flex: none; border-radius: 6px; }
.day small { display: block; color: var(--muted); font-weight: 400; }

/* shelf */
.seg { display: flex; gap: 6px; overflow-x: auto; margin: 10px 0 16px; }
.seg button { flex: none; min-height: 40px; padding: 0 14px; border-radius: 99px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* prose pages */
.prose { max-width: 720px; }
.prose h2 { margin-top: 1.6em; }
.note { background: var(--soft); border-radius: 10px; padding: 12px 14px; }
.disclose, .ai-label { font-size: .85rem; color: var(--muted); border-left: 3px solid var(--accent); padding-left: 10px; }
.todo { display: block; color: var(--warn); font-size: .85rem; }
.orig-cover { width: 100%; max-height: 320px; object-fit: cover; border-radius: var(--radius); margin-top: 14px; }
.orig-list { padding-left: 1.2em; }

.foot { margin-top: 40px; border-top: 1px solid var(--line); padding: 18px 0 24px; font-size: .88rem; color: var(--muted); }
.foot-links { display: flex; flex-wrap: wrap; gap: 8px 16px; }
/* Tin truyện */
.news-list li { grid-template-columns: 1fr; }
.news-list li > span:empty { display: none; }
.news-list .ch-title { font-weight: 600; }
.news h1 { font-size: 1.5rem; line-height: 1.3; }
.src-box { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; }

/* spec 03/12: home cards with teaser, newest chapter, spoiler blocks, official news, reader posts */
.card-teaser { font-size: .82rem; line-height: 1.45; margin-top: 4px; }
.card-cta { font-size: .82rem; font-weight: 700; color: var(--accent); margin-top: 4px; }
.latest-head { margin: 0 0 6px; }
.teaser { font-size: 1.02rem; margin: 0 0 10px; }
.spoil { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 0 14px; margin-bottom: 12px; }
.spoil summary { cursor: pointer; font-weight: 700; color: var(--accent); min-height: 44px; display: flex; align-items: center; }
.spoil[open] { padding-bottom: 12px; }
.notes { margin: 0; padding-left: 1.2em; }
.news-item { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 12px; }
.news-item p:last-child { margin-bottom: 0; }
.rv-form label.check { display: flex; gap: 8px; align-items: center; font-weight: 500; min-height: 44px; }
.rv-form label.check input { width: 20px; height: 20px; }
.reader-rv { border-top: 1px solid var(--line); padding: 10px 0; }
.badge-src { display: inline-block; font-size: .72rem; font-weight: 700; border-radius: 99px; padding: 0 8px; background: var(--soft); color: var(--accent); margin-left: 4px; }
.sub { font-size: 1rem; margin: 14px 0 6px; }
