/* ZStory theme — phong cách tạp chí (editorial). Không font ngoài, không thư viện. */
:root {
    --paper: #fbfaf7;
    --ink: #1b1b1f;
    --ink-2: #4b4b55;
    --muted: #8a8792;
    --rule: #e6e2da;
    --accent: #c2410c;
    --accent-ink: #9a3412;
    --card: #fff;
    --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
    --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --reader-size: 19px;
    --measure: 68ch;
}
html[data-mode="paper"] { --paper: #f4ecd8; --card: #f8f1df; --rule: #e2d6b8; --ink: #3b2f1e; --ink-2: #5b4a33; }
html[data-mode="night"] { --paper: #121214; --card: #1b1b1f; --rule: #2b2b31; --ink: #e9e7e2; --ink-2: #b9b6ae; --muted: #85828c; --accent: #fb923c; --accent-ink: #fdba74; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.6 var(--sans); -webkit-font-smoothing: antialiased; transition: background .2s, color .2s; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
h1, h2, h3 { font-family: var(--serif); font-weight: 700; line-height: 1.15; margin: 0; letter-spacing: -.01em; }
[hidden] { display: none !important; }
.wrap { width: min(1180px, 100% - 40px); margin-inline: auto; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 12px; top: 12px; z-index: 99; background: var(--ink); color: var(--paper); padding: 8px 12px; }

.kicker { display: inline-block; font: 700 11.5px/1 var(--sans); letter-spacing: .12em; text-transform: uppercase; color: var(--accent); }
.byline { font-size: 13px; color: var(--muted); }
.rule-title { font: 800 13px/1 var(--sans); letter-spacing: .14em; text-transform: uppercase; padding-top: 14px; border-top: 3px solid var(--ink); margin-bottom: 18px; }
.cta { display: inline-flex; align-items: center; gap: 8px; padding: 12px 22px; background: var(--accent); color: #fff; border-radius: 999px; font-weight: 600; transition: background .15s, transform .15s; }
.cta:hover { background: var(--accent-ink); transform: translateY(-1px); }
.blank { padding: 60px 0; text-align: center; color: var(--muted); }

/* ---------- Header ---------- */
.masthead { border-bottom: 1px solid var(--rule); background: var(--paper); position: sticky; top: 0; z-index: 30; }
.masthead__row { display: flex; align-items: center; gap: 28px; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; flex: none; color: var(--accent); }
.brand__name { font: 800 22px/1 var(--serif); color: var(--ink); letter-spacing: -.02em; }
.brand__logo { height: 36px; width: auto; }
.topics { display: flex; gap: 22px; overflow-x: auto; scrollbar-width: none; flex: 1; min-width: 0; mask-image: linear-gradient(90deg, #000 92%, transparent); }
.topics::-webkit-scrollbar { display: none; }
.topics a { white-space: nowrap; font-size: 14px; font-weight: 500; color: var(--ink-2); padding: 6px 0; border-bottom: 2px solid transparent; }
.topics a:hover { color: var(--ink); }
.topics a[aria-current] { color: var(--ink); border-color: var(--accent); }
.mode-btn { flex: none; width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--rule); background: transparent; color: var(--ink); cursor: pointer; display: grid; place-items: center; }
.mode-btn:hover { border-color: var(--ink-2); }

/* ---------- Bìa ---------- */
.cover { width: 100%; height: auto; aspect-ratio: 4 / 3; object-fit: cover; background: var(--rule); border-radius: 4px; }
.cover--type {
    display: flex; align-items: flex-end; padding: 8%; color: #fff;
    background: linear-gradient(160deg, hsl(var(--h) 45% 42%), hsl(calc(var(--h) + 40) 50% 22%));
    font: 700 clamp(14px, 2vw, 22px)/1.15 var(--serif); overflow: hidden;
}
.cover--type span { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- Trang chủ ---------- */
.front { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 40px; padding: 36px 0 12px; }
.lead { display: grid; gap: 18px; }
.lead__cover { aspect-ratio: 16 / 10; }
.lead__title { font-size: clamp(28px, 3.2vw, 40px); line-height: 1.15; margin: 10px 0; }
.lead:hover .lead__title { color: var(--accent); }
.lead__dek { font: 19px/1.5 var(--serif); color: var(--ink-2); margin: 0 0 10px; }
.stack { border-left: 1px solid var(--rule); padding-left: 32px; }
.stack__item { display: grid; grid-template-columns: 1fr 96px; gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--rule); align-items: start; }
.stack__item:last-child { border-bottom: 0; }
.stack__item h3 { font-size: 19px; margin: 6px 0; }
.stack__item:hover h3 { color: var(--accent); }
.stack__thumb { aspect-ratio: 1; font-size: 11px !important; }

.band { padding: 36px 0 8px; }
.band__head { display: flex; justify-content: space-between; align-items: baseline; gap: 20px; }
.band__head .rule-title { flex: 1; }
.more { font-weight: 600; color: var(--accent); white-space: nowrap; }
.ranked { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 24px 32px; counter-reset: rank; }
.ranked li { counter-increment: rank; display: flex; gap: 14px; }
.ranked li::before { content: counter(rank); font: 800 34px/1 var(--serif); color: var(--accent); opacity: .85; min-width: 26px; }
.ranked a { display: flex; flex-direction: column; gap: 6px; }
.ranked__title { font: 700 17px/1.3 var(--serif); }
.ranked a:hover .ranked__title { color: var(--accent); }
.shelf { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(170px, 1fr); gap: 22px; overflow-x: auto; padding-bottom: 10px; scroll-snap-type: x mandatory; }
.book { scroll-snap-align: start; display: flex; flex-direction: column; gap: 8px; }
.book__cover { aspect-ratio: 3 / 4; box-shadow: 0 10px 24px -14px rgba(0, 0, 0, .5); transition: transform .2s; }
.book:hover .book__cover { transform: translateY(-4px); }
.book h3 { font-size: 16px; }
.topic-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; padding-bottom: 40px; }
.topic-tile { padding: 22px; border-radius: 6px; background: hsl(var(--h) 40% 94%); color: hsl(var(--h) 45% 22%); display: flex; flex-direction: column; gap: 6px; transition: transform .15s; }
html[data-mode="night"] .topic-tile { background: hsl(var(--h) 25% 18%); color: hsl(var(--h) 50% 85%); }
.topic-tile strong { font: 700 20px var(--serif); }
.topic-tile span { font-size: 13.5px; opacity: .8; }
.topic-tile:hover { transform: translateY(-2px); }

/* ---------- Bộ truyện ---------- */
.series-head { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 44px; padding: 44px 0 28px; align-items: center; }
.series-head__cover { aspect-ratio: 3 / 4; box-shadow: 0 24px 48px -24px rgba(0, 0, 0, .55); }
.series-head h1 { font-size: clamp(32px, 4.5vw, 52px); margin: 12px 0 14px; }
.series-head__dek { font: 19px/1.55 var(--serif); color: var(--ink-2); margin: 0 0 22px; max-width: 60ch; }
.facts { display: flex; flex-wrap: wrap; gap: 28px; margin: 0 0 26px; }
.facts dt { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.facts dd { margin: 4px 0 0; font: 700 20px var(--serif); }
.toc { padding-bottom: 60px; max-width: 820px; }
.toc__list { list-style: none; margin: 0; padding: 0; position: relative; }
.toc__list::before { content: ""; position: absolute; left: 19px; top: 10px; bottom: 10px; width: 2px; background: var(--rule); }
.toc__list a { position: relative; display: flex; align-items: center; gap: 18px; padding: 12px 0; }
.toc__no { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--paper); border: 2px solid var(--rule); font: 700 15px var(--serif); flex: none; transition: border-color .15s, background .15s, color .15s; }
.toc__title { font: 600 18px/1.35 var(--serif); flex: 1; }
.toc__meta { font-size: 13px; color: var(--muted); white-space: nowrap; }
.toc__list a:hover .toc__no { border-color: var(--accent); background: var(--accent); color: #fff; }
.toc__list a:hover .toc__title { color: var(--accent); }

/* ---------- Trang đọc ---------- */
.progress { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 40; }
.progress span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .1s linear; }
.read { width: min(var(--measure), 100% - 40px); margin: 0 auto; padding: 48px 0 24px; }
.read__head { text-align: center; margin-bottom: 32px; }
.read__part { font-size: 13px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin: 14px 0 8px; }
.read__head h1 { font-size: clamp(30px, 4.5vw, 46px); margin: 6px 0 14px; }
.read__cover { aspect-ratio: 16 / 9; margin: 0 0 32px; }
.prose { font: var(--reader-size)/1.75 var(--serif); color: var(--ink); }
.prose p { margin: 0 0 1.1em; }
.prose > p:first-child::first-letter { float: left; font-size: 3.4em; line-height: .9; padding: .06em .1em 0 0; color: var(--accent); font-weight: 700; }
.prose h2, .prose h3 { margin: 1.6em 0 .6em; }
.prose blockquote { margin: 1.4em 0; padding: 0 0 0 1.2em; border-left: 3px solid var(--accent); font-style: italic; color: var(--ink-2); }
.prose a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.prose img { margin: 1.4em auto; border-radius: 4px; height: auto; }
.prose ul, .prose ol { padding-left: 1.3em; margin: 0 0 1.1em; }
.turn { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 44px 0 20px; }
.turn__card { display: flex; flex-direction: column; gap: 6px; padding: 18px 20px; border: 1px solid var(--rule); border-radius: 8px; background: var(--card); transition: border-color .15s; }
.turn__card small { font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.turn__card span { font: 600 16px/1.35 var(--serif); }
.turn__card:hover { border-color: var(--accent); }
.turn__card--next { text-align: right; }
.is-reading .colophon { padding-bottom: 96px; }

.dock {
    position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 35; display: flex; gap: 4px; padding: 6px;
    background: var(--ink); color: var(--paper); border-radius: 999px; box-shadow: 0 16px 40px -12px rgba(0, 0, 0, .5);
}
.dock__btn { min-width: 44px; height: 44px; padding: 0 12px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; border-radius: 999px; border: 0; background: transparent; color: inherit; font: 600 15px var(--sans); cursor: pointer; }
.dock__btn:hover { background: rgba(255, 255, 255, .12); }
.dock__btn--wide { padding: 0 16px; }
.dock__btn--accent { background: var(--accent); color: #fff; }
.dock__btn--accent:hover { background: var(--accent-ink); }
.dock__btn.is-off { opacity: .3; cursor: default; }
.dock__btn.is-off:hover { background: transparent; }

.drawer { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, 0); pointer-events: none; transition: background .2s; }
.drawer.is-open { background: rgba(0, 0, 0, .4); pointer-events: auto; }
.drawer__panel { position: absolute; top: 0; right: 0; bottom: 0; width: min(380px, 90vw); background: var(--paper); display: flex; flex-direction: column; transform: translateX(100%); transition: transform .25s ease; }
.drawer.is-open .drawer__panel { transform: none; }
.drawer__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--rule); font-family: var(--serif); font-size: 18px; }
.drawer__close { border: 0; background: none; font-size: 28px; line-height: 1; cursor: pointer; color: var(--ink); }
.drawer__search { margin: 14px 20px; padding: 10px 14px; border: 1px solid var(--rule); border-radius: 8px; background: var(--card); color: var(--ink); font: inherit; }
.drawer__list { list-style: none; margin: 0; padding: 0 8px 20px; overflow-y: auto; flex: 1; }
.drawer__list a { display: flex; gap: 12px; padding: 10px 12px; border-radius: 6px; font-family: var(--serif); }
.drawer__list a span { color: var(--muted); min-width: 22px; font-weight: 700; }
.drawer__list a:hover { background: var(--card); }
.drawer__list .is-current a { background: var(--accent); color: #fff; }
.drawer__list .is-current a span { color: #fff; }
.drawer__empty { padding: 0 20px; color: var(--muted); }

/* ---------- Danh sách ---------- */
.archive-head { padding: 40px 0 26px; border-bottom: 1px solid var(--rule); margin-bottom: 30px; }
.archive-head h1 { font-size: clamp(34px, 5vw, 56px); margin: 10px 0 6px; }
.mosaic { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 32px 26px; }
.tile { display: flex; flex-direction: column; gap: 12px; }
.tile--big { grid-column: span 2; }
.tile--big .tile__cover { aspect-ratio: 16 / 10; }
.tile h2 { font-size: 18px; margin: 6px 0; }
.tile--big h2 { font-size: 28px; }
.tile p { margin: 0 0 8px; color: var(--ink-2); font: 16px/1.5 var(--serif); }
.tile:hover h2 { color: var(--accent); }
.pages { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px; padding: 44px 0 60px; }
.pages a, .pages span { min-width: 40px; height: 40px; display: grid; place-items: center; padding: 0 12px; border: 1px solid var(--rule); border-radius: 999px; font-weight: 600; font-size: 14px; }
.pages a:hover { border-color: var(--ink); }
.pages [aria-current] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.pages__gap { border: 0 !important; }

.lost { text-align: center; padding: 90px 0; }
.lost__code { font: 800 110px/1 var(--serif); color: var(--accent); margin: 0; }
.lost h1 { font-size: 30px; margin: 10px 0; }
.lost p { color: var(--ink-2); margin: 0 0 26px; }

/* ---------- Footer ---------- */
.colophon { border-top: 1px solid var(--rule); margin-top: 50px; padding: 36px 0 24px; font-size: 14px; color: var(--ink-2); }
.colophon__row { display: flex; justify-content: space-between; gap: 30px; flex-wrap: wrap; }
.colophon__row p { margin: 8px 0 0; }
.colophon nav { display: flex; gap: 18px; flex-wrap: wrap; }
.colophon nav a:hover { color: var(--accent); }
.colophon__legal { margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--rule); font-size: 12.5px; color: var(--muted); }
.colophon__legal p { margin: 4px 0; }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
    .front { grid-template-columns: 1fr; }
    .stack { border-left: 0; padding-left: 0; }
    .ranked { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .mosaic { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .series-head { grid-template-columns: 180px minmax(0, 1fr); gap: 26px; }
}
@media (max-width: 600px) {
    .masthead__row { gap: 14px; }
    .brand__name { font-size: 19px; }
    .ranked { grid-template-columns: 1fr; }
    .mosaic { grid-template-columns: 1fr 1fr; gap: 22px 14px; }
    .tile--big { grid-column: span 2; }
    .series-head { grid-template-columns: 1fr; text-align: center; }
    .series-head__cover { width: 60%; margin: 0 auto; }
    .facts { justify-content: center; }
    .turn { grid-template-columns: 1fr; }
    .toc__meta { display: none; }
    .dock__btn { min-width: 40px; padding: 0 8px; }
}

/* ---------- Trang tĩnh ---------- */
.read--page .read__head { text-align: left; border-bottom: 1px solid var(--rule); padding-bottom: 18px; }
.prose--plain { font: 17px/1.75 var(--sans); }
.prose--plain > p:first-child::first-letter { float: none; font-size: inherit; padding: 0; color: inherit; font-weight: inherit; }
.prose--plain h2 { font-size: 22px; }
.colophon__pages { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-bottom: 10px; }
.colophon__pages a { color: var(--ink-2); font-weight: 500; }
.colophon__pages a:hover { color: var(--accent); }

/* Bản xem trước từ admin */
.preview-bar { position: sticky; top: 0; z-index: 100; padding: 8px 16px; background: #b45309; color: #fff; font: 600 13px/1.4 system-ui, sans-serif; text-align: center; }

/* Ô mã chèn / quảng cáo */
.zs-ad { margin: 24px auto; text-align: center; clear: both; }
.zs-ad:empty { display: none; }
.prose .zs-ad { margin: 1.6em 0; }
