﻿/* ============================================================
   Đọc Truyện – Kawaii Pastel Edition (v2)
   Mobile-first · Dreamy gradient · Floating UI · Cute AF
   ============================================================ */

/* ---------- Theme variables ---------- */
body[data-theme="light"] {
    --bg: #fdf3f8;
    --bg2: #ffffff;
    --card: #ffffff;
    --border: #f6d3e4;
    --text: #2b1b36;
    --text2: #b28ba8;
    --accent: #ea4c9a;
    --accent-soft: #ffe3f1;
    --accent-contrast: #ffffff;
    --ok: #2ab7a0;
    --ok-soft: #dcf7f1;
    --warn: #ffb94e;
    --pink: #ff8fb5;
    --purple: #b06ae0;
    --mint: #9ce6d4;
    --peach: #ffc794;
    --sky: #a8d8fa;
    --shadow: 0 6px 22px rgba(236, 94, 158, .12), 0 2px 8px rgba(236, 94, 158, .07);
    --shadow-sm: 0 3px 10px rgba(236, 94, 158, .10);
    --shadow-big: 0 14px 40px rgba(150, 76, 190, .18);
    --radius: 20px;
    --blob-a: rgba(255, 148, 187, .40);
    --blob-b: rgba(178, 133, 248, .35);
    --reader-glow: radial-gradient(120% 55% at 50% 0%, rgba(236, 94, 158, .10), transparent 60%);
    --topbar-h: 52px;
    --bottomnav-h: 62px;
}
body[data-theme="sepia"] {
    --bg: #fbf1e4;
    --bg2: #fff8ee;
    --card: #fff8ee;
    --border: #f2ddc2;
    --text: #4a3126;
    --text2: #b1947c;
    --accent: #e06a45;
    --accent-soft: #fde7d8;
    --accent-contrast: #ffffff;
    --ok: #2a9d7f;
    --ok-soft: #dff3eb;
    --warn: #f2b13c;
    --pink: #f0a78a;
    --purple: #b58bd6;
    --mint: #a5d8b0;
    --peach: #f6c292;
    --sky: #a9cbe8;
    --shadow: 0 6px 22px rgba(160, 100, 60, .12), 0 2px 8px rgba(160, 100, 60, .07);
    --shadow-sm: 0 3px 10px rgba(160, 100, 60, .10);
    --shadow-big: 0 14px 40px rgba(150, 90, 45, .16);
    --radius: 20px;
    --blob-a: rgba(240, 167, 138, .35);
    --blob-b: rgba(243, 197, 138, .35);
    --reader-glow: radial-gradient(120% 55% at 50% 0%, rgba(224, 106, 69, .10), transparent 60%);
    --topbar-h: 52px;
    --bottomnav-h: 62px;
}
body[data-theme="dark"] {
    --bg: #171124;
    --bg2: #211835;
    --card: #261d3c;
    --border: #3b2b55;
    --text: #f3ecfa;
    --text2: #a48fc2;
    --accent: #ff7ec1;
    --accent-soft: #3c2152;
    --accent-contrast: #171124;
    --ok: #5de8c5;
    --ok-soft: #143028;
    --warn: #ffd98a;
    --pink: #ff7ec1;
    --purple: #b47df0;
    --mint: #6ce0c4;
    --peach: #ffad73;
    --sky: #7fb8e8;
    --shadow: 0 6px 22px rgba(0, 0, 0, .35), 0 2px 8px rgba(0, 0, 0, .25);
    --shadow-sm: 0 3px 10px rgba(0, 0, 0, .30);
    --shadow-big: 0 14px 40px rgba(0, 0, 0, .42);
    --radius: 20px;
    --blob-a: rgba(180, 96, 224, .14);
    --blob-b: rgba(255, 126, 193, .12);
    --reader-glow: radial-gradient(120% 55% at 50% 0%, rgba(255, 126, 193, .07), transparent 60%);
    --topbar-h: 52px;
    --bottomnav-h: 62px;
}
body[data-theme="amoled"] {
    --bg: #000000;
    --bg2: #0c0a12;
    --card: #140f1f;
    --border: #251b38;
    --text: #f3ecfa;
    --text2: #8c77ab;
    --accent: #ff7ec1;
    --accent-soft: #32132c;
    --accent-contrast: #0c0a12;
    --ok: #5de8c5;
    --ok-soft: #0a1f18;
    --warn: #ffd98a;
    --pink: #ff7ec1;
    --purple: #b47df0;
    --mint: #6ce0c4;
    --peach: #ffad73;
    --sky: #7fb8e8;
    --shadow: 0 6px 22px rgba(0, 0, 0, .55), 0 2px 8px rgba(0, 0, 0, .45);
    --shadow-sm: 0 3px 10px rgba(0, 0, 0, .5);
    --shadow-big: 0 14px 40px rgba(0, 0, 0, .6);
    --radius: 20px;
    --blob-a: rgba(120, 40, 130, .22);
    --blob-b: rgba(60, 20, 90, .18);
    --reader-glow: none;
    --topbar-h: 52px;
    --bottomnav-h: 62px;
}

/* ---------- Base ---------- */
* { margin: 0; padding: 0; box-sizing: border-box; touch-action: manipulation; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); }
html { -webkit-text-size-adjust: 100%; }
body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Nunito', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    min-height: 100vh;
    min-height: 100dvh;
    -webkit-font-smoothing: antialiased;
    transition: background .3s ease, color .3s ease;
    overflow-x: hidden;
}

/* Dreamy floating blobs */
body::before, body::after {
    content: '';
    position: fixed;
    border-radius: 50%;
    pointer-events: none;
    z-index: -1;
    filter: blur(7px);
}
body::before {
    width: 340px; height: 340px;
    top: -90px; right: -110px;
    background: radial-gradient(circle, var(--blob-a), transparent 70%);
    animation: blobFloat 18s ease-in-out infinite alternate;
}
body::after {
    width: 380px; height: 380px;
    bottom: -120px; left: -120px;
    background: radial-gradient(circle, var(--blob-b), transparent 70%);
    animation: blobFloat 22s ease-in-out infinite alternate-reverse;
}
@keyframes blobFloat {
    from { transform: translate(0, 0) scale(1); }
    to { transform: translate(24px, -18px) scale(1.08); }
}

button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; -webkit-tap-highlight-color: transparent; }
input, select, textarea { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
a { color: var(--accent); text-decoration: none; }
.hidden { display: none !important; }
.mut { color: var(--text2); font-size: 13px; }

/* ---------- Scrollbar (webkit) ---------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: linear-gradient(180deg, var(--pink), var(--purple)); border-radius: 999px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- Topbar: floating candy pill ---------- */
.topbar {
    position: fixed; top: calc(env(safe-area-inset-top, 0px) + 8px); left: 10px; right: 10px; z-index: 100;
    height: var(--topbar-h);
    background: linear-gradient(135deg, #ff8fb5 0%, #ea4c9a 40%, #b06ae0 100%);
    border-radius: 18px;
    box-shadow: 0 10px 28px rgba(200, 70, 170, .30);
    transition: transform .25s ease, box-shadow .25s ease;
    overflow: visible;
}
.topbar::before {
    content: '';
    position: absolute; inset: 0;
    border-radius: inherit;
    background: radial-gradient(130% 130% at 12% 0%, rgba(255, 255, 255, .35), transparent 46%),
                radial-gradient(120% 120% at 92% 100%, rgba(255, 220, 240, .30), transparent 45%);
    pointer-events: none;
}
.topbar::after {
    content: '';
    position: absolute; top: 6px; left: 12px;
    width: 6px; height: 6px; border-radius: 50%;
    background: #fff;
    box-shadow: 30px -2px 0 rgba(255,255,255,.8), 64px 5px 0 rgba(255,255,255,.55), 96px -4px 0 rgba(255,255,255,.35);
    opacity: .8; pointer-events: none;
}
.topbar-inner {
    max-width: 1080px; height: var(--topbar-h); margin: 0 auto; padding: 0 6px;
    display: flex; align-items: center; gap: 2px;
}
.brand { display: flex; align-items: center; gap: 7px; cursor: pointer; margin-right: auto; min-width: 0; }
.brand-mark {
    font-size: 17px; line-height: 1;
    background: #fff;
    color: #ea4c9a;
    width: 34px; height: 34px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%;
    box-shadow: 0 3px 10px rgba(0, 0, 0, .15);
    flex-shrink: 0;
    transform: rotate(-6deg);
}
.brand-text { font-weight: 900; font-size: 15px; color: #ffffff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-shadow: 0 1px 4px rgba(120, 30, 100, .25); letter-spacing: .2px; }
.topbar-actions { display: flex; align-items: center; gap: 0; flex-shrink: 0; }
.icon-btn {
    width: 40px; height: 40px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    color: rgba(255, 255, 255, .95); font-size: 18px;
    transition: background .15s, transform .15s;
    flex-shrink: 0;
}
.topbar .icon-btn { background: rgba(255, 255, 255, .16); }
.topbar .icon-btn:hover { background: rgba(255, 255, 255, .30); color: #ffffff; }
.icon-btn:active, .bn-item:active { transform: scale(.88); }

/* ---------- Bottom nav: floating glass pill ---------- */
.bottomnav {
    position: fixed; bottom: calc(env(safe-area-inset-bottom, 0px) + 8px); left: 10px; right: 10px; z-index: 100;
    height: var(--bottomnav-h);
    background: color-mix(in srgb, var(--bg2) 88%, transparent);
    -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
    border: 1px solid color-mix(in srgb, var(--purple) 18%, transparent);
    border-radius: 22px;
    display: flex;
    box-shadow: var(--shadow-big);
    transition: transform .25s ease;
    padding: 4px;
}
.bn-item {
    flex: 1; min-width: 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
    font-size: 10px; font-weight: 800; color: var(--text2);
    transition: color .15s;
    position: relative;
    padding: 2px 0;
    border-radius: 16px;
}
.bn-item i { font-size: 20px; transition: transform .2s ease; line-height: 1; }
.bn-item span { line-height: 1.2; }
.bn-item.active { color: #ffffff; background: linear-gradient(135deg, #ff8fb5, #b06ae0); box-shadow: 0 6px 16px rgba(200, 70, 170, .35); }
.bn-item.active i { transform: scale(1.12); animation: bnPop .3s ease; }
@keyframes bnPop { 0% { transform: scale(.7); } 60% { transform: scale(1.2); } 100% { transform: scale(1.12); } }

/* ---------- App shell ---------- */
.app {
    max-width: 1080px; margin: 0 auto;
    padding: calc(var(--topbar-h) + env(safe-area-inset-top, 0px) + 22px) 12px calc(var(--bottomnav-h) + env(safe-area-inset-bottom, 0px) + 22px);
}
.page-root { animation: pageIn .28s cubic-bezier(.22, .9, .3, 1); }
@keyframes pageIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

.page-head {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    margin: 14px 0 16px; flex-wrap: wrap;
}
.page-head h1 {
    font-size: 22px; font-weight: 900; letter-spacing: -.3px;
    background: linear-gradient(120deg, #ea4c9a, #a35be0);
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent; color: transparent;
    display: inline-flex; align-items: center; gap: 8px;
}
.page-head h1::before { content: '✨'; font-size: 18px; }

/* ---------- Buttons: squishy gradient pills ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 10px 18px; border-radius: 999px; font-weight: 800; font-size: 14px;
    transition: transform .12s, filter .15s, background .15s, box-shadow .15s;
    white-space: nowrap;
    min-height: 42px;
}
.btn:active { transform: scale(.94); }
.btn-primary {
    background: linear-gradient(135deg, #ff8fb5, #ea4c9a 45%, #a35be0);
    color: #ffffff;
    box-shadow: 0 6px 18px rgba(200, 70, 170, .35);
}
.btn-primary:active { filter: brightness(1.08); box-shadow: 0 3px 8px rgba(200, 70, 170, .2); }
.btn-outline { border: 1.5px solid var(--border); color: var(--accent); background: var(--bg2); }
.btn-outline:active { background: var(--accent-soft); border-color: var(--accent); }
.btn-sm { padding: 6px 14px; font-size: 12.5px; border-radius: 999px; min-height: 34px; }

/* ---------- Search bars: big candy pill ---------- */
.search-bar {
    display: flex; align-items: center; gap: 8px;
    background: var(--card); border: 1.5px solid color-mix(in srgb, var(--pink) 30%, var(--border));
    border-radius: 18px; padding: 0 8px 0 16px; margin: 6px 0 14px;
    box-shadow: var(--shadow);
    transition: border-color .2s, box-shadow .2s;
    height: 48px;
}
.search-bar:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-soft), var(--shadow-big);
}
.search-bar > i { color: var(--accent); font-size: 17px; flex-shrink: 0; }
.search-bar input { flex: 1; min-width: 0; background: none; border: none; outline: none; font-size: 15px; height: 100%; font-weight: 600; }
.search-bar input::placeholder { color: var(--text2); font-weight: 500; }
.search-bar .clear { color: var(--text2); font-size: 16px; display: inline-flex; padding: 4px; flex-shrink: 0; }
.search-bar .clear:hover { color: var(--accent); }
.btn-search {
    flex-shrink: 0; height: 32px; padding: 0 14px; border-radius: 999px; cursor: pointer;
    border: none; background: var(--accent); color: var(--accent-contrast);
    font-size: 13px; font-weight: 800; display: inline-flex; align-items: center; gap: 5px;
    transition: filter .15s, transform .1s;
}
.btn-search:hover { filter: brightness(1.12); }
.btn-search:active { transform: scale(.96); }

/* ---------- Search result rows (chế độ "tìm theo từ khóa") ---------- */
.search-results { display: flex; flex-direction: column; gap: 10px; }
.search-row {
    display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 14px;
    background: var(--card); border: 1px solid var(--border); box-shadow: var(--shadow);
    text-decoration: none; color: inherit; transition: border-color .2s, transform .1s;
}
.search-row:hover { border-color: var(--accent); transform: translateY(-1px); }
.search-thumb { width: 44px; height: 60px; border-radius: 8px; overflow: hidden; flex-shrink: 0; background: var(--bg); }
.search-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.search-thumb .no-img { width: 44px; height: 60px; display: flex; align-items: center; justify-content: center; color: var(--text2); font-size: 18px; }
.search-body { min-width: 0; flex: 1; }
.search-title { font-weight: 700; font-size: 15px; line-height: 1.35; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-sub { color: var(--text2); font-size: 12.5px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-tag {
    display: inline-block; margin-left: 8px; vertical-align: 1px; flex-shrink: 0;
    font-size: 11px; font-weight: 800; color: var(--accent-contrast); background: var(--accent);
    padding: 2px 8px; border-radius: 999px; white-space: nowrap; align-self: flex-start; margin-top: 2px;
}

/* ---------- Popup chuyển hướng truyện thể loại Hiện Đại ---------- */
.modern-redirect {
    position: fixed; inset: 0; z-index: 250;
    display: flex; align-items: center; justify-content: center; padding: 20px;
    background: rgba(10, 6, 20, .55); backdrop-filter: blur(4px);
    animation: mrFade .18s ease;
}
.mr-card {
    width: min(400px, 100%); background: var(--card);
    border: 1.5px solid color-mix(in srgb, var(--pink) 35%, var(--border));
    border-radius: 22px; padding: 26px 24px; text-align: center; box-shadow: var(--shadow-big);
    animation: mrPop .22s ease;
}
.mr-icon {
    width: 56px; height: 56px; margin: 0 auto 12px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center; font-size: 26px;
    color: var(--accent-contrast); background: var(--accent);
}
.mr-card h3 { margin: 0 0 8px; font-size: 19px; }
.mr-card p { margin: 0 0 18px; color: var(--text2); font-size: 14px; line-height: 1.55; }
.mr-actions { display: flex; gap: 10px; justify-content: center; }
.mr-actions .btn { min-width: 110px; }
@keyframes mrFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes mrPop { from { opacity: 0; transform: translateY(14px) scale(.97); } to { opacity: 1; transform: none; } }

/* ---------- Filters / chips ---------- */
.filters {
    display: flex; gap: 8px; flex-wrap: nowrap; margin: 8px 0;
    overflow-x: auto; scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
    padding: 2px 2px 6px;
    scrollbar-width: none;
}
.filters::-webkit-scrollbar { display: none; }
.chip {
    padding: 8px 16px; border-radius: 999px; font-size: 12.5px; font-weight: 800;
    background: var(--card); border: 1.5px solid var(--border); color: var(--text2);
    transition: all .15s;
    flex-shrink: 0;
    scroll-snap-align: start;
    white-space: nowrap;
    min-height: 38px;
    box-shadow: var(--shadow-sm);
}
.chip.active {
    background: linear-gradient(135deg, #ff8fb5, #a35be0);
    color: #ffffff; border-color: transparent;
    box-shadow: 0 6px 16px rgba(200, 70, 170, .35);
}
.chip:active { transform: scale(.94); }

/* ---------- Cover rail / grid ---------- */
.section-title {
    display: flex; align-items: center; justify-content: space-between;
    margin: 22px 0 12px; font-size: 17px; font-weight: 900;
    letter-spacing: -.2px;
    color: var(--text);
}
.section-title::before {
    content: '💗';
    margin-right: 8px;
    animation: sparkle 2.4s ease-in-out infinite;
}
@keyframes sparkle { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.18) rotate(10deg); } }
.section-title .more {
    font-size: 12.5px; font-weight: 800; color: var(--accent); cursor: pointer; flex-shrink: 0;
    padding: 4px 12px; border-radius: 999px; background: var(--accent-soft);
}
.section-title .more:hover { background: var(--accent); color: #fff; }
.hrail {
    display: flex; gap: 12px; overflow-x: auto; padding: 6px 2px 14px;
    scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.hrail::-webkit-scrollbar { display: none; }

.cover-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 8px; }
.cover-card { scroll-snap-align: start; flex: 0 0 104px; cursor: pointer; width: 104px; }
.cover-grid .cover-card { width: auto; flex: initial; scroll-snap-align: initial; }
.cover-wrap {
    position: relative; border-radius: 18px; overflow: hidden; aspect-ratio: 3/4;
    box-shadow: var(--shadow);
    background: linear-gradient(145deg, #ffffff, var(--accent-soft));
    transition: transform .18s ease, box-shadow .18s ease;
}
.cover-wrap::after {
    content: ''; pointer-events: none; position: absolute; inset: 0;
    background: linear-gradient(120deg, rgba(255, 255, 255, .45) 0%, transparent 42%);
    border-radius: inherit;
}
.cover-grid .cover-card:nth-child(5n+1) .cover-wrap { box-shadow: 0 8px 20px rgba(255, 143, 181, .25); }
.cover-grid .cover-card:nth-child(5n+2) .cover-wrap { box-shadow: 0 8px 20px rgba(176, 106, 224, .25); }
.cover-grid .cover-card:nth-child(5n+3) .cover-wrap { box-shadow: 0 8px 20px rgba(156, 230, 212, .35); }
.cover-grid .cover-card:nth-child(5n+4) .cover-wrap { box-shadow: 0 8px 20px rgba(255, 199, 148, .35); }
.cover-grid .cover-card:nth-child(5n) .cover-wrap { box-shadow: 0 8px 20px rgba(168, 216, 250, .35); }
.cover-card:active .cover-wrap { transform: scale(.95); }
.cover-wrap img { width: 100%; height: 100%; object-fit: cover; }
.no-img { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; font-size: 30px; color: var(--accent); background: linear-gradient(145deg, var(--bg2), var(--accent-soft)); }
.badge-tag {
    position: absolute; top: 6px; left: 6px;
    background: linear-gradient(135deg, #ff8fb5, #a35be0);
    color: #ffffff;
    font-size: 8.5px; font-weight: 900; padding: 3px 8px; border-radius: 999px; letter-spacing: .4px;
    box-shadow: 0 3px 8px rgba(140, 40, 120, .3);
}
.badge-tag.ongoing { background: linear-gradient(135deg, #5de8c5, #2ab7a0); color: #0a2a22; }
.cover-info { padding: 8px 2px 0; }
.cover-info h3 {
    font-size: 12px; font-weight: 800; line-height: 1.35; height: 32px;
    overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.cover-meta { display: flex; align-items: center; gap: 4px; color: var(--text2); font-size: 10px; margin-top: 3px; flex-wrap: wrap; }
.cover-meta .rating { color: var(--warn); font-weight: 900; }

/* ---------- Skeletons ---------- */
.skel-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 8px; }
.skel-card { width: auto; }
.skel {
    background: linear-gradient(100deg, var(--bg2) 40%, var(--border) 50%, var(--bg2) 60%);
    background-size: 200% 100%; animation: skel 1.4s infinite;
    border-radius: 12px; position: relative; overflow: hidden;
}
@keyframes skel { from { background-position: 120% 0; } to { background-position: -80% 0; } }
.skel-img { width: 100%; aspect-ratio: 3/4; border-radius: 18px; }
.skel-line { height: 10px; margin-top: 6px; }
.skel-line.short { width: 60%; }
.bag.skel-row { display: flex; gap: 12px; }
.skel-body { flex: 1; align-self: center; }

/* ---------- Error / empty states ---------- */
.error-state, .empty-state {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 10px; text-align: center; padding: 44px 16px; color: var(--text2);
}
.error-state i, .empty-state i { font-size: 46px; opacity: .55; }
.error-state p, .empty-state p { font-size: 14px; line-height: 1.6; }

/* ---------- Pager ---------- */
.pager { display: flex; justify-content: center; gap: 6px; flex-wrap: wrap; margin: 18px 0 6px; }
.pager button {
    min-width: 38px; height: 38px; padding: 0 10px; border-radius: 12px;
    border: 1.5px solid var(--border); background: var(--bg2); color: var(--text);
    font-size: 13px; font-weight: 800; transition: all .15s;
    box-shadow: var(--shadow-sm);
}
.pager button.active {
    background: linear-gradient(135deg, #ff8fb5, #a35be0);
    border-color: transparent; color: #ffffff;
    box-shadow: 0 6px 16px rgba(200, 70, 170, .35);
}
.pager button:disabled { opacity: .35; }
.pager button.more { border-color: transparent; background: none; box-shadow: none; }

/* ---------- Detail page ---------- */
.detail-hero {
    display: flex; gap: 14px;
    background: var(--card); border-radius: 24px; padding: 14px;
    box-shadow: var(--shadow-big);
    border: 1.5px solid color-mix(in srgb, var(--pink) 20%, var(--border));
    position: relative; overflow: hidden;
}
.detail-hero::before {
    content: '';
    position: absolute; top: -40px; right: -40px; width: 120px; height: 120px;
    background: radial-gradient(circle, var(--blob-a), transparent 70%);
    pointer-events: none;
}
.detail-cover, .detail-hero .no-img {
    flex: 0 0 auto; width: 112px; height: 150px; border-radius: 14px; object-fit: cover; overflow: hidden;
    box-shadow: 0 8px 20px rgba(200, 70, 170, .25);
    position: relative;
}
.detail-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; position: relative; }
.detail-title {
    font-size: 16px; font-weight: 900; line-height: 1.3; letter-spacing: -.2px;
    background: linear-gradient(120deg, var(--accent), var(--purple));
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent; color: transparent;
}
.detail-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.genre-tag {
    font-size: 10.5px; font-weight: 800; padding: 3px 10px; border-radius: 999px;
    background: var(--accent-soft); color: var(--accent);
}
.detail-stats { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 11.5px; color: var(--text2); }
.detail-stats span { display: inline-flex; align-items: center; gap: 3px; }
.detail-stats b { color: var(--text); }
.detail-stats .bi-star-fill { color: var(--warn); }
.detail-actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: auto; }
.detail-actions .btn {
    min-width: 0; padding: 11px 8px; font-size: 12.5px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.detail-actions .btn:last-child { grid-column: 1 / -1; }

.detail-desc {
    background: var(--card); border-radius: 22px; padding: 16px;
    margin-top: 14px; box-shadow: var(--shadow);
    border: 1.5px solid var(--border);
}
.detail-desc h2 {
    font-size: 15px; font-weight: 900; margin-bottom: 8px;
    display: flex; align-items: center; gap: 6px;
}
.detail-desc h2::before { content: '💗'; font-size: 14px; }
.detail-desc p { font-size: 13.5px; color: var(--text); opacity: .92; white-space: pre-line; line-height: 1.7; }
.detail-desc.closed p { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- Chapter panel ---------- */
.chapter-panel {
    background: var(--card); border-radius: 22px; padding: 16px;
    margin-top: 14px; box-shadow: var(--shadow);
    border: 1.5px solid var(--border);
}
.chapter-panel .head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.chapter-panel .head h2 { font-size: 15px; font-weight: 900; display: flex; align-items: center; gap: 6px; }
.chapter-panel .head h2::before { content: '📚'; font-size: 14px; }
.chp-search {
    display: flex; align-items: center; gap: 8px;
    border: 1.5px solid var(--border); border-radius: 12px; padding: 0 12px; margin-bottom: 10px; background: var(--bg);
    transition: border-color .2s, box-shadow .2s;
    height: 42px;
}
.chp-search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.chp-search input { flex: 1; min-width: 0; background: none; border: none; outline: none; font-size: 14px; height: 100%; }
.chp-list { max-height: min(480px, 50vh); overflow-y: auto; }
.chp-item {
    display: flex; align-items: center; gap: 10px; padding: 11px 8px;
    border-bottom: 1px solid var(--border); cursor: pointer; border-radius: 12px;
    transition: background .12s, transform .1s;
}
.chp-item:active { background: var(--accent-soft); transform: scale(.99); }
.chp-item.read { opacity: .55; }
.chp-item.current {
    background: var(--accent-soft);
    box-shadow: inset 0 0 0 1.5px var(--accent);
}
.chp-no {
    font-size: 10.5px; font-weight: 900; color: var(--accent); min-width: 36px; flex-shrink: 0;
    background: var(--accent-soft); text-align: center; padding: 3px 8px; border-radius: 999px;
    white-space: nowrap;
}
.chp-name { flex: 1 1 auto; min-width: 0; font-size: 13px; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; font-weight: 600; padding-right: 4px; }
.chp-read { font-size: 11px; color: var(--ok); font-weight: 800; flex: 0 0 auto; white-space: nowrap; }
.chp-empty { text-align: center; color: var(--text2); padding: 22px 0; font-size: 14px; }
.loadmore {
    display: block; width: 100%; margin-top: 12px; padding: 12px;
    border: 2px dashed color-mix(in srgb, var(--accent) 45%, transparent); border-radius: 14px; color: var(--accent);
    font-weight: 800; font-size: 13px; transition: all .15s;
    background: var(--bg);
}
.loadmore:active { background: var(--accent-soft); border-style: solid; }

/* ---------- Stack / list items (library, history) ---------- */
.stack { display: flex; flex-direction: column; gap: 10px; }
.list-item {
    display: flex; align-items: center; gap: 12px;
    background: var(--card); border-radius: 20px; padding: 10px;
    box-shadow: var(--shadow); cursor: pointer; transition: transform .1s;
    border: 1.5px solid var(--border);
}
.list-item:active { transform: scale(.98); }
.li-cover, .list-item .no-img.li-cover {
    flex: 0 0 auto; width: 46px; height: 62px; border-radius: 10px; object-fit: cover; overflow: hidden;
    box-shadow: 0 4px 12px rgba(200, 70, 170, .2);
}
.list-item .no-img.li-cover { font-size: 16px; }
.li-body { flex: 1; min-width: 0; }
.li-title { font-size: 14px; font-weight: 800; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; }
.li-sub { font-size: 12px; color: var(--text2); margin-top: 1px; }
.li-time { font-size: 10.5px; color: var(--text2); margin-top: 1px; }
.li-actions { display: flex; gap: 2px; flex: 0 0 auto; }
.icon-btn-sm {
    width: 36px; height: 36px; border-radius: 12px; display: inline-flex;
    align-items: center; justify-content: center; color: var(--text2); font-size: 15px;
    transition: all .15s;
    background: var(--bg);
}
.icon-btn-sm:active { background: var(--accent-soft); color: var(--accent); transform: scale(.9); }
.icon-btn-sm.danger { color: #e5484d; }
.icon-btn-sm.danger:active { background: rgba(229, 72, 77, .12); }

/* ---------- Segmented controls ---------- */
.seg {
    display: flex; background: var(--bg2); border: 1.5px solid var(--border);
    border-radius: 16px; padding: 4px; gap: 3px; margin-bottom: 14px; flex-wrap: nowrap;
    overflow-x: auto; scrollbar-width: none;
    box-shadow: var(--shadow-sm);
}
.seg::-webkit-scrollbar { display: none; }
.seg button {
    flex: 1; padding: 9px 4px; border-radius: 12px; font-size: 12px; font-weight: 800; color: var(--text2);
    white-space: nowrap; transition: all .15s;
}
.seg button.active {
    background: linear-gradient(135deg, #ff8fb5, #a35be0);
    color: #ffffff;
    box-shadow: 0 5px 14px rgba(200, 70, 170, .35);
}

/* ---------- Settings ---------- */
.settings-group {
    background: var(--card); border-radius: 22px; padding: 2px 14px;
    margin-bottom: 14px; box-shadow: var(--shadow);
    border: 1.5px solid var(--border);
}
.sg-head {
    font-size: 11px; font-weight: 900; letter-spacing: .6px; text-transform: uppercase; color: var(--accent);
    padding: 14px 0 6px;
}
.settings-row {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 12px 0; border-bottom: 1px solid var(--border); cursor: pointer;
}
.settings-row:last-child { border-bottom: none; }
.sr-label { font-size: 14px; font-weight: 800; }
.sr-sub { font-size: 11.5px; color: var(--text2); margin-top: 2px; }

.seg-mini { display: flex; background: var(--bg); border-radius: 10px; padding: 3px; gap: 2px; flex-shrink: 0; }
.seg-mini button { padding: 6px 9px; border-radius: 8px; font-size: 11px; font-weight: 800; color: var(--text2); }
.seg-mini button.active { background: linear-gradient(135deg, #ff8fb5, #a35be0); color: #ffffff; }

.stepper { display: flex; align-items: center; gap: 2px; background: var(--bg); border-radius: 10px; padding: 3px; flex-shrink: 0; }
.stepper button {
    width: 32px; height: 32px; border-radius: 8px; font-size: 17px; font-weight: 900;
    color: var(--text); transition: background .15s;
}
.stepper button:active { background: var(--accent-soft); color: var(--accent); }
.stepper span { min-width: 42px; text-align: center; font-size: 13px; font-weight: 800; }

.toggle {
    position: relative; display: inline-block; width: 48px; height: 26px;
    border-radius: 999px; background: var(--border); transition: background .25s ease;
    flex-shrink: 0;
}
.toggle::after {
    content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px;
    border-radius: 50%; background: #fff; box-shadow: 0 2px 5px rgba(0, 0, 0, .2);
    transition: transform .25s ease;
}
.toggle.on { background: linear-gradient(135deg, #5de8c5, #2ab7a0); }
.toggle.on::after { transform: translateX(22px); }

/* ---------- Admin ---------- */
.admin-login { display: flex; flex-direction: column; gap: 12px; max-width: 340px; }
.admin-login h2 { font-size: 17px; }
.admin-login input { background: var(--bg2); border: 1px solid var(--border); border-radius: 12px; padding: 11px 13px; font-size: 14px; outline: none; }
.admin-login .secret { font-size: 12px; color: var(--text2); }
.admin-section { display: flex; flex-direction: column; gap: 12px; }
.admin-section h3 { font-size: 16px; }
.admin-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.admin-section .cfg-label { font-size: 12px; color: var(--text2); margin-top: 2px; }
.admin-section .cfg-note { font-size: 13px; color: var(--text2); background: var(--bg2); border: 1px solid var(--border); border-radius: 12px; padding: 8px 10px; }
.admin-section .cfg-note a { color: var(--accent); font-weight: 600; }
.admin-section .cfg-input { background: var(--bg2); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; font-size: 14px; outline: none; color: var(--text); width: 100%; box-sizing: border-box; }
.admin-section textarea.cfg-input { resize: vertical; }
.admin-section input[type="file"].cfg-input { padding: 8px 10px; }
.manual-ch-label { font-size: 12px; color: var(--text2); margin-top: 4px; }
.manual-chapter-row { display: flex; flex-direction: column; gap: 8px; border: 1px dashed var(--border); border-radius: 16px; padding: 10px; background: var(--bg2); }
.manual-ch-row-head { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--text2); }
.manual-ch-row-head .btn { padding: 2px 10px; font-size: 12px; }
.manual-cover-preview { width: min(140px, 40vw); border-radius: 12px; margin-top: 4px; border: 1px solid var(--border); }
.progress-shell { background: var(--card); border-radius: var(--radius); padding: 14px; margin-top: 4px; box-shadow: var(--shadow); }
.progress-track { height: 10px; border-radius: 999px; background: var(--border); overflow: hidden; }
.progress-fill {
    height: 100%; width: 0; border-radius: 999px;
    background: linear-gradient(135deg, #ff8fb5, #a35be0);
    transition: width .3s;
}
.progress-text { font-size: 12px; color: var(--text2); margin-top: 6px; min-height: 16px; }
.check-report {
    background: var(--card); border-radius: var(--radius); padding: 14px;
    margin-top: 12px; box-shadow: var(--shadow); font-size: 13px;
    border: 1px solid var(--border);
}
.check-cols { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 10px; }
.check-col { flex: 1 1 240px; min-width: 0; }
.check-col h4 { font-size: 12.5px; margin-bottom: 6px; }
.check-col ul { list-style: none; }
.check-col li { padding: 4px 0; font-size: 12.5px; border-bottom: 1px dotted var(--border); }
.badge { font-size: 10px; font-weight: 800; padding: 2px 6px; border-radius: 6px; margin-right: 6px; }
.badge.new { background: var(--ok-soft); color: var(--ok); }
.badge.upd { background: var(--accent-soft); color: var(--accent); }

/* ---------- Reader overlay ---------- */
body.reading { overflow: hidden; }
body.reading .topbar { transform: translateY(-140%); }
body.reading .bottomnav { transform: translateY(160%); }

.reader {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 90;
    display: flex; flex-direction: column;
    background: var(--bg);
    touch-action: manipulation;
    overscroll-behavior: contain;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
}
.reader::before {
    content: '';
    position: absolute; inset: 0;
    background: var(--reader-glow);
    pointer-events: none;
}
.reader-top {
    display: flex; align-items: center; gap: 4px; padding: 8px 10px;
    background: linear-gradient(135deg, #ff8fb5, #ea4c9a 45%, #a35be0);
    border-bottom: none; z-index: 2;
    transition: transform .22s ease, opacity .22s ease;
    flex-shrink: 0;
    box-shadow: 0 6px 20px rgba(200, 70, 170, .25);
}
.reader-top .icon-btn { color: rgba(255, 255, 255, .95); width: 38px; height: 38px; font-size: 17px; background: rgba(255, 255, 255, .16); }
.reader-top .icon-btn:hover { background: rgba(255, 255, 255, .30); }
.reader-title {
    flex: 1; min-width: 0; font-weight: 800; font-size: 13px; text-overflow: ellipsis;
    overflow: hidden; white-space: nowrap; text-align: center; color: #fff; padding: 0 4px;
    text-shadow: 0 1px 4px rgba(120, 30, 100, .3);
}
.reader-skeleton { overflow-y: auto; flex: 1; padding: 24px 16px; }
.reader-skeleton .rs-line { margin: 12px auto; height: 13px; }
.reader-content {
    flex: 1; overflow-y: auto; padding: 24px 16px 54px;
    --fs: 17px; --lh: 1.8; --ff: 'Nunito', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-family: var(--ff);
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    overscroll-behavior: contain;
    transition: opacity 180ms ease, transform 180ms ease;
    position: relative;
}
.reader-content::before {
    content: '';
    display: block; max-width: 720px; margin: 0 auto 4px; height: 5px;
    width: 70px; border-radius: 999px;
    background: linear-gradient(90deg, var(--pink), var(--purple));
    opacity: .5;
}
.reader-content.chapter-transition { opacity: 1; transform: translateY(0); }
.reader-chapter-title {
    max-width: 720px; margin: 6px auto 16px; text-align: center;
    font-size: calc(var(--fs) * 1.1); font-weight: 900; line-height: 1.4;
    padding: 0 4px;
    background: linear-gradient(120deg, var(--accent), var(--purple));
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent; color: transparent;
}
.reader-chapter-title small { display: block; font-size: 12px; color: var(--text2); font-weight: 600; margin-top: 5px; -webkit-text-fill-color: var(--text2); color: var(--text2); }
.reader-para { max-width: 720px; margin: 0 auto; text-align: left; padding: 0 2px; }
.reader-para p { margin: 0 0 0.85em; font-size: var(--fs); line-height: var(--lh); color: var(--text); }
.reader-para .tehi-para-img { display: block; max-width: 100%; height: auto; margin: 14px auto; border-radius: 14px; box-shadow: var(--shadow-sm); }

/* Continuous reading */
.continuous-loading { padding: 16px 0; text-align: center; color: var(--text2); font-size: 13px; }
.reader-para-continuous { max-width: 720px; margin: 0 auto; text-align: left; padding: 0 2px; }
.reader-para-continuous p { margin: 0 0 0.85em; font-size: var(--fs); line-height: var(--lh); color: var(--text); }
.reader-para-continuous .tehi-para-img { display: block; max-width: 100%; height: auto; margin: 14px auto; border-radius: 14px; box-shadow: var(--shadow-sm); }

/* Similar stories at end of chapter */
.reader-recs {
    max-width: 720px; margin: 26px auto 8px; padding: 16px;
    background: var(--card); border: 1.5px solid var(--border); border-radius: 22px;
    box-shadow: var(--shadow-big);
    opacity: 0; transform: translateY(10px); transition: opacity .35s ease, transform .35s ease;
}
.reader-recs.in { opacity: 1; transform: translateY(0); }
.reader-recs .section-title { margin-bottom: 12px; }
.reader-recs .hrail { padding-bottom: 2px; }

/* Feelings at end of chapter */
.reader-feelings {
    max-width: 720px; margin: 26px auto 8px; padding: 16px;
    background: var(--card); border: 1.5px solid var(--border); border-radius: 22px;
    box-shadow: var(--shadow-big);
}
.reader-feelings h3 { font-size: 14px; margin: 0 0 12px; display: flex; align-items: center; gap: 6px; font-weight: 900; }
.reader-feelings h3 i { color: var(--accent); }
.feel-form { display: flex; flex-direction: column; gap: 8px; }
.feel-form input, .feel-form textarea {
    width: 100%; box-sizing: border-box; background: var(--bg2);
    border: 1.5px solid var(--border); border-radius: 12px; padding: 10px 12px;
    font-size: 14px; color: var(--text); outline: none; font-family: inherit;
    transition: border-color .2s;
}
.feel-form input { max-width: 220px; height: 44px; }
.feel-form textarea { min-height: 78px; resize: vertical; }
.feel-form textarea:focus, .feel-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.feel-form .btn { align-self: flex-start; }
.feel-notice {
    margin-top: 12px; padding: 10px 12px;
    background: var(--bg2); border: 1px solid var(--border); border-radius: 12px;
    font-size: 12.5px; line-height: 1.5; color: var(--text2);
}
.feel-notice a { color: var(--accent); text-decoration: none; font-weight: 600; }
.feel-notice a:hover { text-decoration: underline; }
.reader-feelings .mut { font-size: 12px; }

.reader-progressbar {
    height: 5px; background: var(--border); flex-shrink: 0;
    position: relative; z-index: 2;
}
.reader-progressbar div {
    height: 100%; width: 0;
    background: linear-gradient(135deg, #ff8fb5, #a35be0);
    transition: width .1s linear;
    border-radius: 0 999px 999px 0;
}

.reader-nav {
    display: flex; gap: 6px; padding: 8px 10px;
    background: color-mix(in srgb, var(--bg2) 88%, transparent);
    border-top: 1px solid var(--border);
    -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px)); z-index: 2;
    transition: transform .22s ease, opacity .22s ease;
    flex-shrink: 0;
}
.reader-nav button {
    flex: 1; display: flex; align-items: center; justify-content: center; gap: 5px;
    padding: 11px 4px; border-radius: 14px; font-weight: 800; font-size: 12.5px;
    background: var(--bg); transition: all .15s;
    box-shadow: var(--shadow-sm);
}
.reader-nav button:active { transform: scale(.95); background: var(--accent-soft); color: var(--accent); }
.reader-nav button:disabled { opacity: .3; box-shadow: none; }
.reader-nav button i { font-size: 16px; }
.reader-nav button .rn-label { font-size: 12px; }
.reader.nav-hidden .reader-top { height: 0; padding: 0; border-bottom: none; overflow: hidden; transform: translateY(-100%); opacity: 0; pointer-events: none; box-shadow: none; }
.reader.nav-hidden .reader-nav { height: 0; padding: 0; border-top: none; overflow: hidden; transform: translateY(100%); opacity: 0; pointer-events: none; }

/* reader menu + toc panels */
.reader-menu, .reader-toc {
    position: absolute; right: 10px; top: 60px; width: min(320px, calc(100vw - 20px));
    max-height: calc(100% - 70px); overflow-y: auto;
    background: color-mix(in srgb, var(--bg2) 92%, transparent);
    -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
    border: 1.5px solid var(--border); border-radius: 20px;
    box-shadow: var(--shadow-big); padding: 14px; z-index: 5;
}
.reader-toc { left: 10px; right: 10px; width: auto; padding: 8px 0; top: auto; bottom: calc(64px + env(safe-area-inset-bottom, 0px)); max-height: calc(100% - 80px); }
.reader.nav-hidden .reader-toc { bottom: 8px; }
.reader-toc h3 { font-size: 13px; padding: 4px 14px 8px; font-weight: 900; color: var(--accent); display: flex; align-items: center; gap: 6px; }
.toc-item {
    display: flex; align-items: center; gap: 10px; padding: 10px 14px;
    font-size: 13px; cursor: pointer; border-bottom: 1px solid var(--border);
    transition: background .12s;
}
.toc-item:active { background: var(--accent-soft); }
.toc-item.read { opacity: .55; }
.toc-item.current { background: var(--accent-soft); font-weight: 800; }
.toc-no {
    font-size: 10.5px; font-weight: 900; color: var(--accent); min-width: 26px;
    background: var(--accent-soft); text-align: center; padding: 2px 7px; border-radius: 999px;
    white-space: nowrap; flex-shrink: 0;
}
.toc-item > span:last-child { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-right: 4px; }
.rg { margin-bottom: 12px; }
.rg:last-child { margin-bottom: 4px; }
.rg label { display: block; font-size: 11.5px; font-weight: 800; color: var(--text2); margin-bottom: 6px; }
.rg .seg-mini, .rg .stepper, .rg select { width: 100%; }
.rg .seg-mini button { flex: 1; }
.rg select {
    width: 100%; padding: 8px 10px; border-radius: 10px; border: 1.5px solid var(--border);
    background: var(--bg2); color: var(--text); outline: none;
}
.rg .toggle-wrap { display: flex; justify-content: flex-end; }

/* ---------- Toast ---------- */
.toast-host {
    position: fixed; left: 0; right: 0; bottom: calc(var(--bottomnav-h) + env(safe-area-inset-bottom, 0px) + 20px);
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    z-index: 300; pointer-events: none; padding: 0 12px;
}
.toast {
    max-width: 90vw;
    background: linear-gradient(135deg, #ff8fb5, #a35be0);
    color: #ffffff;
    padding: 11px 18px; border-radius: 999px; font-size: 13px; font-weight: 800;
    box-shadow: 0 8px 24px rgba(150, 50, 150, .35);
    animation: toastIn .3s cubic-bezier(.22, .9, .3, 1.1);
    display: inline-flex; align-items: center; gap: 6px;
}
.toast::before { content: '💗'; }
.toast.ok { background: linear-gradient(135deg, #5de8c5, #2ab7a0); }
.toast.ok::before { content: '💚'; }
.toast.err { background: linear-gradient(135deg, #ff7d94, #e5484d); }
.toast.err::before { content: '💔'; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px) scale(.92); } to { opacity: 1; transform: none; } }

/* ============================================================
   RESPONSIVE: Tablet+ (640px+)
   ============================================================ */
@media (min-width: 640px) {
    body[data-theme] {
        --topbar-h: 56px;
        --bottomnav-h: 66px;
    }
    .topbar { left: 16px; right: 16px; border-radius: 22px; }
    .topbar-inner { padding: 0 10px; gap: 8px; }
    .brand-text { font-size: 17px; }
    .brand-mark { width: 38px; height: 38px; font-size: 19px; }
    .bottomnav { left: 16px; right: 16px; max-width: 560px; margin: 0 auto; }
    .app { padding-left: 18px; padding-right: 18px; }
    .page-head h1 { font-size: 24px; }
    .page-head h1::before { font-size: 20px; }

    .cover-grid, .skel-grid { grid-template-columns: repeat(4, 1fr); gap: 16px; }
    .cover-card { flex: 0 0 122px; width: 122px; }
    .hrail { gap: 16px; }
    .cover-info h3 { font-size: 12.5px; height: 34px; }
    .cover-meta { font-size: 11px; }

    .detail-hero { padding: 18px; gap: 18px; }
    .detail-cover, .detail-hero .no-img { width: 132px; height: 176px; }
    .detail-title { font-size: 19px; }
    .detail-stats { font-size: 12.5px; }
    .detail-actions { display: flex; flex-wrap: wrap; gap: 8px; grid-template-columns: none; }
    .detail-actions .btn { flex: 1 1 0; padding: 11px 10px; font-size: 13px; grid-column: span 1; overflow: visible; text-overflow: clip; }
    .detail-actions .btn:last-child { grid-column: span 1; }

    .seg button { font-size: 13px; padding: 10px 6px; }

    .search-bar { padding: 0 10px 0 18px; height: 50px; margin: 8px 0 16px; }
    .chp-item { padding: 12px 10px; }

    .filters { flex-wrap: wrap; overflow-x: visible; gap: 8px; }
}

/* ============================================================
   RESPONSIVE: Desktop (1024px+)
   ============================================================ */
@media (min-width: 1024px) {
    .cover-grid, .skel-grid { grid-template-columns: repeat(5, 1fr); }
    .cover-card { flex: 0 0 138px; width: 138px; }
    .detail-cover, .detail-hero .no-img { width: 150px; height: 200px; }
}

/* ============================================================
   RESPONSIVE: Smartphone typography (< 480px)
   ============================================================ */
@media (max-width: 480px) {
    body { font-size: 15px; }
    .page-head h1 { font-size: 21px; }
    .page-head h1::before { font-size: 18px; }
    .section-title { font-size: 17px; }
    .brand-text { font-size: 15px; }
    .search-bar { height: 48px; }
    .search-bar input { font-size: 15px; }
    .search-bar > i { font-size: 17px; }

    .cover-info h3 { font-size: 12px; height: 32px; }
    .cover-meta { font-size: 10.5px; }
    .badge-tag { font-size: 8px; padding: 3px 7px; }

    .chp-item { gap: 8px; padding: 11px 6px; }
    .chp-no { min-width: 34px; font-size: 10.5px; padding: 3px 8px; }
    .chp-name { font-size: 13.5px; }
    .chp-read { font-size: 11.5px; }

    .detail-hero { padding: 12px; gap: 10px; }
    .detail-title { font-size: 16.5px; }
    .genre-tag { font-size: 10.5px; }
    .detail-stats { font-size: 11.5px; gap: 3px 8px; }
    .detail-stats span { gap: 3px; }
    .detail-desc p { font-size: 14px; }
    .detail-desc h2, .chapter-panel .head h2 { font-size: 15px; }

    .list-item { gap: 10px; padding: 10px; }
    .li-title { font-size: 14px; }
    .li-sub { font-size: 12.5px; }
    .li-actions { gap: 4px; }

    .reader-para p, .reader-para-continuous p { margin-bottom: 0.75em; }
    .reader-nav button { padding: 10px 4px; font-size: 13px; }
    .toc-no { min-width: 26px; font-size: 10.5px; }
    .toc-item { padding: 10px 12px; font-size: 13px; }
}

/* ============================================================
   RESPONSIVE: Small phones (< 360px)
   ============================================================ */
@media (max-width: 359px) {
    .brand-text { display: none; }
    .brand-mark { font-size: 16px; width: 30px; height: 30px; }
    .bn-item span { font-size: 9px; }
    .bn-item i { font-size: 18px; }
    .detail-actions .btn { font-size: 13px; padding: 10px 8px; min-width: 0; }
    .reader-nav button .rn-label { display: none; }
}

/* ============================================================
   RESPONSIVE: Very small height phones (landscape)
   ============================================================ */
@media (max-height: 600px) and (orientation: landscape) {
    body[data-theme] {
        --topbar-h: 46px;
        --bottomnav-h: 50px;
    }
    .topbar { top: calc(env(safe-area-inset-top, 0px) + 4px); }
    .bn-item span { display: none; }
    .bn-item { padding: 0; }
    .bn-item i { font-size: 20px; }
}

/* === OVERRIDE: banner che toan bo noi dung doc === */
.ad-unlock{
    position:fixed;top:var(--topbar-h);left:0;right:0;bottom:var(--bottomnav-h);z-index:95;
    display:flex;flex-direction:column;align-items:center;justify-content:center;
    gap:12px;padding:20px;max-width:none;margin:0;border-radius:0;overflow:hidden;
    cursor:pointer;color:#fff;text-decoration:none;
    background:rgba(45,27,54,.7);
    -webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);
}
body.reading .ad-unlock{top:0;bottom:0;}
.ad-unlock::before{content:'';position:absolute;inset:0;background:
    radial-gradient(circle at 50% 18%,rgba(232,67,147,.25),transparent 52%)}
.ad-unlock-title{position:relative;font-size:19px;font-weight:900;display:flex;
    align-items:center;justify-content:center;gap:6px;letter-spacing:.3px}
.ad-unlock-title i{font-size:20px}
.ad-unlock-img{position:relative;width:min(300px,80vw);height:auto;border-radius:14px;
    box-shadow:0 10px 36px rgba(0,0,0,.5);border:3px solid rgba(255,255,255,.2)}
.ad-unlock-banner{position:relative;display:block;line-height:0;border-radius:14px;
    transition:transform .12s, box-shadow .12s}
.ad-unlock-banner:active{transform:scale(.97)}
.ad-unlock-link{position:relative;margin-top:2px;font-size:13.5px;font-weight:800;
    color:#ffd166;text-decoration:underline;text-underline-offset:3px;
    padding:8px 16px;border:1px solid rgba(255,209,102,.45);border-radius:999px;
    transition:background .15s;text-align:center}
.ad-unlock-link:hover{background:rgba(255,209,102,.14)}
.ad-unlock-text{position:relative;max-width:500px;font-size:14px;line-height:1.6;text-align:center;opacity:.96}
.ad-unlock-note{position:relative;max-width:480px;font-size:12px;opacity:.8;font-style:italic;text-align:center}
.ad-unlock:active .ad-unlock-title{transform:scale(.97)}
.ad-unlock-title{transition:transform .12s}
/* === END OVERRIDE === */