/*
Theme Name: Simple Webnovel NovelZCQ
Theme URI: https://read.novelzcq.com/
Author: NovelZCQ
Author URI: https://read.novelzcq.com/
Description: A clean, focus-first webnovel reading theme for the Simple Webnovel plugin. Clones the visual design of NovelZCQ: three reader themes (light / sepia / dark), reader font-size and typeface controls persisted in localStorage, a chapter catalog, cover-card grid and dedicated chapter reader.
Version: 1.0.0
Requires at least: 6.0
Tested up to: 6.7
Requires PHP: 7.4
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: simple-webnovel-novelzcq
Tags: blog, news, custom-logo, custom-menu, post-thumbnails, translation-ready
*/

/* ==========================================================================
   1. Design tokens
   ========================================================================== */

:root {
    /* Font sizes */
    --fs-2xs: 11px;
    --fs-xs: 12px;
    --fs-sm: 13px;
    --fs-base: 14px;
    --fs-md: 15px;
    --fs-lg: 16px;
    --fs-xl: 18px;
    --fs-2xl: 21px;
    --fs-3xl: 26px;
    --fs-4xl: 34px;

    /* Spacing (4px base) */
    --sp-1: 4px;
    --sp-2: 8px;
    --sp-3: 12px;
    --sp-4: 16px;
    --sp-5: 20px;
    --sp-6: 24px;
    --sp-8: 32px;
    --sp-10: 40px;

    /* Radius */
    --r-sm: 8px;
    --r-md: 10px;
    --r-lg: 12px;
    --r-pill: 999px;

    /* Shadows */
    --shadow-1: 0 1px 2px rgba(26, 26, 36, .05);
    --shadow-2: 0 6px 20px rgba(26, 26, 36, .08);

    /* Layout */
    --max: 1180px;

    /* Z-indexes */
    --z-header: 40;
    --z-progress: 60;
    --z-skip: 100;

    /* Accent (novelzcq brand; --accent overridden by Customizer via functions.php) */
    --accent: #5b3df5;
    --accent-dark: #4a2fd6;
    --accent-soft: #f0ecff;
    --accent-ink: #3d28b8;

    /* Light theme defaults */
    --text: #1a1a24;
    --text-soft: #5c5c72;
    --bg: #ffffff;
    --surface: #ffffff;
    --bg-soft: #f6f6fa;
    --line: #e6e6f0;
    --line-strong: #d5d5e3;

    /* Reader typography */
    --reader-size: 18px;
    --reader-lead: 1.95;
    --reader-measure: 68ch;
    --reader-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;

    /* Brand + logo heights (overridden by Customizer) */
    --brand-text: var(--accent);
    --logo-height-desktop: 46px;
    --logo-height-mobile: 38px;
}

/* Sepia theme */
:root[data-theme="sepia"] {
    --accent: #8a6d1a;
    --accent-dark: #6b5414;
    --accent-soft: #f3ecd4;
    --accent-ink: #5b470f;
    --text: #2e2a22;
    --text-soft: #6d6552;
    --bg: #faf6ec;
    --surface: #fffdf7;
    --bg-soft: #f3ecdd;
    --line: #e6dfd0;
    --line-strong: #d5ccb8;
    --brand-text: #8a6d1a;
}

/* Dark theme */
:root[data-theme="dark"] {
    --accent: #a99bff;
    --accent-dark: #8f7fff;
    --accent-soft: #2a2347;
    --accent-ink: #c6bbff;
    --text: #e9e9f2;
    --text-soft: #9b9bb0;
    --bg: #14141c;
    --surface: #1c1c26;
    --bg-soft: #1b1b25;
    --line: #2c2c3c;
    --line-strong: #3a3a4c;
    --brand-text: #a99bff;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-2: 0 6px 20px rgba(0, 0, 0, .45);
}

/* Respect OS dark mode when no explicit theme chosen (works without JS) */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
        --accent: #a99bff;
        --accent-dark: #8f7fff;
        --accent-soft: #2a2347;
        --accent-ink: #c6bbff;
        --text: #e9e9f2;
        --text-soft: #9b9bb0;
        --bg: #14141c;
        --surface: #1c1c26;
        --bg-soft: #1b1b25;
        --line: #2c2c3c;
        --line-strong: #3a3a4c;
        --brand-text: #a99bff;
        --shadow-1: 0 1px 2px rgba(0, 0, 0, .4);
        --shadow-2: 0 6px 20px rgba(0, 0, 0, .45);
    }
}

/* Reader size */
:root[data-reader-size="s"] { --reader-size: 16px; }
:root[data-reader-size="l"] { --reader-size: 20px; }

/* Reader font */
:root[data-reader-font="serif"] {
    --reader-font: Georgia, "Times New Roman", "Songti SC", "SimSun", serif;
}

/* ==========================================================================
   2. Base / reset
   ========================================================================== */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    font-size: var(--fs-base);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    transition: background-color .25s ease, color .25s ease;

    /* Sticky footer: keep footer pinned to the viewport bottom on short pages */
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    color: var(--accent);
    text-decoration: none;
}
a:hover { color: var(--accent-dark); }

img {
    max-width: 100%;
    height: auto;
    display: block;
}

h1, h2, h3, h4 {
    margin: 0 0 .5em;
    line-height: 1.25;
    color: var(--text);
}

p { margin: 0 0 1em; }

/* Accessibility helpers */
.sr-only {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ==========================================================================
   3. Layout
   ========================================================================== */

.container {
    max-width: var(--max);
    margin: 0 auto;
    padding: 0 var(--sp-4);
}

.site-main {
    min-height: 60vh;
    padding-top: var(--sp-5);
    padding-bottom: var(--sp-10);

    /* Grow to fill remaining height so the footer sits at the bottom */
    flex: 1 0 auto;
}

/* Skip link */
.skip-link {
    position: fixed;
    top: 0;
    left: var(--sp-4);
    z-index: var(--z-skip);
    transform: translateY(-200%);
    background: var(--accent);
    color: #fff;
    padding: var(--sp-2) var(--sp-4);
    border-radius: 0 0 var(--r-sm) var(--r-sm);
    font-size: var(--fs-sm);
    transition: transform .2s ease;
}
.skip-link:focus {
    transform: translateY(0);
    outline: none;
}

/* ==========================================================================
   4. Header
   ========================================================================== */

.site-header {
    position: sticky;
    top: 0;
    z-index: var(--z-header);
    background: color-mix(in srgb, var(--bg) 82%, transparent);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 62px;
    gap: var(--sp-4);
}

.site-brand a {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    color: var(--text);
    font-size: var(--fs-xl);
    font-weight: 700;
    letter-spacing: -.01em;
}
.site-brand a:hover { color: var(--text); }
.site-brand .brand-text {
    background: linear-gradient(120deg, var(--accent), var(--accent-dark));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: var(--brand-text);
}
.site-brand img.custom-logo {
    height: var(--logo-height-desktop);
    width: auto;
}

/* Nav (desktop pill) */
.site-nav {
    display: flex;
    align-items: center;
    gap: var(--sp-1);
}
.site-nav ul,
.site-nav li {
    list-style: none;
    margin: 0;
    padding: 0;
}
.site-nav ul { display: flex; align-items: center; gap: var(--sp-1); }
.site-nav .nav-link,
.site-nav a {
    display: inline-flex;
    align-items: center;
    padding: var(--sp-2) var(--sp-4);
    border-radius: var(--r-pill);
    font-size: var(--fs-sm);
    font-weight: 500;
    color: var(--text-soft);
    transition: background-color .15s ease, color .15s ease;
}
.site-nav a:hover {
    background: var(--bg-soft);
    color: var(--text);
}
.site-nav .nav-link.active,
.site-nav .current-menu-item > a {
    background: var(--accent-soft);
    color: var(--accent-ink);
    font-weight: 600;
}
.site-nav .menu-item-archive > a,
.site-nav .nav-item-archive {
    background: var(--accent);
    color: #fff;
}
.site-nav .menu-item-archive > a:hover {
    background: var(--accent-dark);
    color: #fff;
}

/* Mobile nav toggle (pure CSS via hidden checkbox) */
.nav-toggle-cb {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.nav-toggle {
    display: none;
    cursor: pointer;
    background: none;
    border: 0;
    padding: var(--sp-2);
    min-width: 44px;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 5px;
    color: var(--text);
}
.nav-toggle .bar {
    display: block;
    width: 22px;
    height: 2px;
    border-radius: 2px;
    background: currentColor;
    transition: transform .2s ease, opacity .2s ease;
}

/* ==========================================================================
   5. Buttons
   ========================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    padding: var(--sp-2) var(--sp-5);
    border: 1px solid transparent;
    border-radius: var(--r-pill);
    font-size: var(--fs-base);
    font-weight: 600;
    line-height: 1.4;
    cursor: pointer;
    text-decoration: none;
    transition: background-color .15s ease, border-color .15s ease, color .15s ease;
    white-space: nowrap;
}
.btn-primary {
    background: var(--accent);
    color: #fff;
}
.btn-primary:hover {
    background: var(--accent-dark);
    color: #fff;
}
.btn-outline {
    background: transparent;
    border-color: var(--line-strong);
    color: var(--text);
}
.btn-outline:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-soft);
}
.btn-lg { padding: var(--sp-3) var(--sp-8); font-size: var(--fs-lg); }
.btn-sm { padding: var(--sp-1) var(--sp-3); font-size: var(--fs-xs); }
.btn-next {
    background: var(--accent);
    color: #fff;
}
.btn-next:hover {
    background: var(--accent-dark);
    color: #fff;
}
.btn[disabled],
.btn.is-disabled,
.btn.disabled {
    opacity: .5;
    pointer-events: none;
    cursor: not-allowed;
}

/* ==========================================================================
   6. Novel grid + cover cards
   ========================================================================== */

.novel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
    gap: var(--sp-6);
}

.novel-card {
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    min-width: 0;
}

.novel-cover-link {
    display: block;
    border-radius: var(--r-lg);
    overflow: hidden;
    position: relative;
}

.novel-cover {
    position: relative;
    width: 100%;
    aspect-ratio: 9 / 16;
    background: var(--bg-soft);
    border-radius: var(--r-lg);
    overflow: hidden;
    box-shadow: var(--shadow-1);
    transition: transform .2s ease, box-shadow .2s ease;
}
.novel-card:hover .novel-cover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-2);
}
.novel-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.novel-cover--placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: var(--text-soft);
    font-size: var(--fs-xs);
    text-align: center;
    padding: var(--sp-2);
    letter-spacing: .08em;
}

.badge {
    position: absolute;
    top: var(--sp-2);
    left: var(--sp-2);
    z-index: 1;
    padding: 2px var(--sp-2);
    border-radius: var(--r-pill);
    font-size: var(--fs-2xs);
    font-weight: 600;
    background: var(--accent);
    color: #fff;
    box-shadow: var(--shadow-1);
}
.badge-ongoing { background: var(--accent); color: #fff; }

.novel-info { min-width: 0; }
.novel-title {
    margin: 0;
    font-size: var(--fs-sm);
    font-weight: 600;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.novel-title a { color: var(--text); }
.novel-title a:hover { color: var(--accent); }
.novel-desc {
    margin: var(--sp-1) 0 0;
    font-size: var(--fs-xs);
    color: var(--text-soft);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Cover+title-only grid (reader-recommend) — hide descriptions */
.novel-grid--compact .novel-desc { display: none; }

.empty { color: var(--text-soft); padding: var(--sp-8) 0; }

/* ==========================================================================
   7. Novel detail hero
   ========================================================================== */

.breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--sp-2);
    font-size: var(--fs-sm);
    color: var(--text-soft);
    padding: var(--sp-4) 0;
}
.breadcrumb a { color: var(--text-soft); }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb .breadcrumb-sep { color: var(--line-strong); }
.breadcrumb .breadcrumb-current { color: var(--text); font-weight: 500; }

.novel-hero {
    display: flex;
    gap: var(--sp-6);
    background: var(--bg-soft);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: var(--sp-6);
}
.novel-hero-cover {
    flex-shrink: 0;
    width: 140px;
    aspect-ratio: 9 / 16;
    border-radius: var(--r-lg);
    overflow: hidden;
    box-shadow: var(--shadow-2);
    background: var(--surface);
}
.novel-hero-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.novel-hero-cover .novel-cover--placeholder {
    width: 100%;
    height: 100%;
}
.novel-hero-body {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
}
.novel-hero-kicker {
    font-size: var(--fs-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--accent);
}
.novel-hero-title {
    margin: 0;
    font-size: var(--fs-3xl);
    font-weight: 700;
    line-height: 1.2;
}
.novel-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--sp-3);
    font-size: var(--fs-sm);
    color: var(--text-soft);
}
.novel-meta .badge { position: static; }
.novel-meta .meta-item {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-1);
}
.novel-hero-desc {
    margin: 0;
    font-size: var(--fs-md);
    color: var(--text-soft);
    line-height: 1.8;
}
.novel-hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-3);
    margin-top: var(--sp-2);
}

/* ==========================================================================
   8. Chapter section / catalog
   ========================================================================== */

.chapter-section {
    margin-top: var(--sp-8);
}
.chapter-section-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-4);
    margin-bottom: var(--sp-4);
}
.chapter-section-title {
    margin: 0;
    font-size: var(--fs-2xl);
    font-weight: 700;
}
.chapter-section-count {
    font-size: var(--fs-sm);
    color: var(--text-soft);
    margin-left: var(--sp-2);
}

.chapter-jump {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
}
.chapter-jump input[type="number"] {
    width: 96px;
    padding: var(--sp-2) var(--sp-3);
    border: 1px solid var(--line-strong);
    border-radius: var(--r-pill);
    background: var(--surface);
    color: var(--text);
    font-size: var(--fs-sm);
}
.chapter-jump input[type="number"]:focus {
    outline: none;
    border-color: var(--accent);
}

/* Order + page-jump toolbar on the catalog header */
.chapter-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: var(--sp-3);
}
.chapter-tools__group {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: var(--sp-3);
}
.chapter-tools__label {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--text-soft);
    white-space: nowrap;
}
.chapter-order {
    padding: var(--sp-2) var(--sp-3);
    border: 1px solid var(--line-strong);
    border-radius: var(--r-pill);
    background: var(--surface);
    color: var(--text);
    font-size: var(--fs-sm);
    font-weight: 600;
    min-height: 36px;
}
.chapter-order:focus {
    outline: none;
    border-color: var(--accent);
}

.chapter-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: var(--sp-3);
    list-style: none;
    margin: 0;
    padding: 0;
}
.chapter-item {
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    background: var(--surface);
    overflow: hidden;
    transition: border-color .15s ease, background-color .15s ease, transform .15s ease;
}
.chapter-item:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
    transform: translateY(-1px);
}
.chapter-item a {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-3);
    color: var(--text);
}
.chapter-item a:hover { color: var(--accent-ink); }
.chapter-num {
    flex-shrink: 0;
    font-size: var(--fs-xs);
    font-weight: 700;
    color: var(--accent);
    background: var(--accent-soft);
    border-radius: var(--r-sm);
    padding: 2px var(--sp-2);
    min-width: 40px;
    text-align: center;
}
.chapter-name {
    flex: 1;
    min-width: 0;
    font-size: var(--fs-sm);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ==========================================================================
   9. Pagination
   ========================================================================== */

.pagination {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--sp-2);
    margin-top: var(--sp-8);
}
.pagination .page-numbers {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    min-height: 40px;
    padding: 0 var(--sp-3);
    border: 1px solid var(--line);
    border-radius: var(--r-pill);
    font-size: var(--fs-sm);
    color: var(--text);
    background: var(--surface);
    transition: border-color .15s ease, background-color .15s ease, color .15s ease;
}
.pagination .page-numbers:hover {
    border-color: var(--accent);
    color: var(--accent);
}
.pagination .page-numbers.current {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    font-weight: 600;
}
.pagination .page-numbers.dots { border-color: transparent; background: transparent; }
.pagination .page-numbers.disabled,
.pagination .prev.disabled,
.pagination .next.disabled {
    opacity: .45;
    pointer-events: none;
}

/* ==========================================================================
   10. Reader (chapter)
   ========================================================================== */

.read-progress {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    z-index: var(--z-progress);
    background: transparent;
    pointer-events: none;
}
.read-progress span {
    display: block;
    height: 100%;
    width: 100%;
    background: var(--accent);
    transform-origin: left center;
    transform: scaleX(0);
}

.to-top {
    position: fixed;
    right: var(--sp-6);
    bottom: var(--sp-6);
    z-index: var(--z-header);
    width: 46px;
    height: 46px;
    border-radius: 50%;
    border: 1px solid var(--line-strong);
    background: var(--surface);
    color: var(--text-soft);
    box-shadow: var(--shadow-2);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition: opacity .2s ease, visibility .2s ease, transform .2s ease;
    cursor: pointer;
    font-size: var(--fs-lg);
}
.to-top.is-visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
.to-top:hover { color: var(--accent); }

.chapter-header {
    text-align: center;
    padding: var(--sp-10) 0 var(--sp-6);
}
.chapter-book {
    display: inline-block;
    font-size: var(--fs-sm);
    color: var(--accent);
    margin-bottom: var(--sp-2);
}
.chapter-title {
    margin: 0 0 var(--sp-2);
    font-size: var(--fs-2xl);
    font-weight: 700;
}
.chapter-progress {
    font-size: var(--fs-sm);
    color: var(--text-soft);
}

.reader-container {
    max-width: 800px;
}

/* Reader settings (collapsible — attached to the chapter header, not sticky) */
.reader-settings {
    margin: 0 0 var(--sp-6);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    background: var(--surface);
    box-shadow: var(--shadow-1);
}
.reader-settings summary {
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-3) var(--sp-4);
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--text-soft);
    user-select: none;
}
.reader-settings summary::-webkit-details-marker { display: none; }
.reader-settings summary::before {
    content: '⚙';
    font-size: var(--fs-md);
    line-height: 1;
}
.reader-settings summary::after {
    content: '▾';
    margin-left: auto;
    transition: transform .18s ease;
}
.reader-settings[open] summary::after { transform: rotate(180deg); }
.reader-settings summary:hover { color: var(--text); }
.reader-settings__inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--sp-2);
    padding: 0 var(--sp-4) var(--sp-4);
    border-top: 1px solid var(--line);
    padding-top: var(--sp-3);
}
.reader-settings__inner .rt-group {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-1);
    background: var(--bg-soft);
    border-radius: var(--r-pill);
    padding: 3px;
}
.reader-settings__inner .rt-group__label {
    padding-left: var(--sp-2);
    font-size: var(--fs-xs);
    color: var(--text-soft);
    font-weight: 700;
}
.rt-sep {
    width: 1px;
    height: 20px;
    background: var(--line-strong);
    margin: 0 var(--sp-1);
}
.rt-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    min-height: 36px;
    padding: var(--sp-1) var(--sp-3);
    border: 0;
    border-radius: var(--r-pill);
    background: transparent;
    color: var(--text-soft);
    font-size: var(--fs-xs);
    font-weight: 600;
    cursor: pointer;
    transition: background-color .15s ease, color .15s ease;
}
.rt-btn:hover { background: var(--surface); color: var(--text); }
.rt-btn.is-active {
    background: var(--accent);
    color: #fff;
}

/* Chapter content */
.chapter-content {
    font-size: var(--reader-size);
    line-height: var(--reader-lead);
    max-width: var(--reader-measure);
    font-family: var(--reader-font);
    margin: 0 auto;
    color: var(--text);
}
.chapter-content p {
    margin: 0 0 1.2em;
}
.chapter-content img {
    border-radius: var(--r-md);
    margin: var(--sp-6) auto;
}

.chapter-end {
    text-align: center;
    color: var(--text-soft);
    font-size: var(--fs-sm);
    margin-top: var(--sp-10);
    padding-top: var(--sp-6);
    border-top: 1px solid var(--line);
}

.reader-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-3);
    margin-top: var(--sp-8);
}

/* Reader recommend */
.reader-recommend {
    margin-top: var(--sp-10);
    padding-top: var(--sp-8);
    border-top: 1px solid var(--line);
}
.reader-recommend-head {
    display: flex;
    align-items: baseline;
    gap: var(--sp-3);
    margin-bottom: var(--sp-5);
}
.reader-recommend-title {
    margin: 0;
    font-size: var(--fs-xl);
    font-weight: 700;
}
.reader-recommend .novel-grid {
    grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
}

/* ==========================================================================
   11. Footer
   ========================================================================== */

.site-footer {
    border-top: 1px solid var(--line);
    background: var(--bg-soft);
    color: var(--text-soft);
    font-size: var(--fs-sm);
}
.footer-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-4);
    padding-top: var(--sp-6);
    padding-bottom: var(--sp-6);
}
.footer-brand {
    font-weight: 700;
    color: var(--text);
    font-size: var(--fs-md);
}
.footer-nav ul {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-4);
    list-style: none;
    margin: 0;
    padding: 0;
}
.footer-nav a {
    color: var(--text-soft);
}
.footer-nav a:hover { color: var(--accent); }
.footer-copy { color: var(--text-soft); }
.footer-copy a { color: var(--text); }
.footer-copy a:hover { color: var(--accent); }

/* ==========================================================================
   12. Responsive
   ========================================================================== */

@media (max-width: 700px) {
    .header-inner { height: auto; min-height: 62px; }

    /* Mobile nav toggle shows */
    .nav-toggle { display: inline-flex; }
    .site-brand img.custom-logo { height: var(--logo-height-mobile); }

    .site-nav {
        display: none;
        position: absolute;
        top: 62px;
        left: 0;
        right: 0;
        background: var(--surface);
        border-bottom: 1px solid var(--line);
        box-shadow: var(--shadow-2);
        padding: var(--sp-3) var(--sp-4) var(--sp-5);
        flex-direction: column;
        align-items: stretch;
    }
    .site-nav ul {
        flex-direction: column;
        align-items: stretch;
        gap: var(--sp-1);
    }
    .site-nav .nav-link,
    .site-nav a {
        border-radius: var(--r-md);
        padding: var(--sp-3);
    }

    /* Open/close by checkbox: checked sibling shows nav */
    .nav-toggle-cb:checked ~ .nav-toggle .bar:nth-child(1) { transform: translateY(7px) rotate(45deg); }
    .nav-toggle-cb:checked ~ .nav-toggle .bar:nth-child(2) { opacity: 0; }
    .nav-toggle-cb:checked ~ .nav-toggle .bar:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
    .nav-toggle-cb:checked ~ .site-nav {
        display: flex;
    }

    .novel-hero {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    .novel-hero-cover { width: 180px; }
    .novel-hero-actions { justify-content: center; }
    .chapter-section-head { flex-direction: column; align-items: flex-start; }

    /* Reader settings wrap on small screens */
    .reader-settings__inner { gap: var(--sp-2); }
    .reader-settings__inner .rt-group { flex-wrap: wrap; }
    .rt-btn,
    .btn,
    .pagination .page-numbers {
        min-height: 44px;
    }
    .rt-btn { min-width: 44px; }

    /* Hide the size/font textual labels, keep icons via data-icon */
    .rt-btn .rt-label { display: none; }
    .rt-btn[data-icon]::before { content: attr(data-icon); }

    .to-top { right: var(--sp-4); bottom: var(--sp-4); }
}

/* ==========================================================================
   13. Reduced motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
        scroll-behavior: auto !important;
    }
    html { scroll-behavior: auto; }
}