/* === Webnovel ===
 *
 * Two surfaces, deliberately different:
 *   chrome  — cool neutral, dense, sans. Browsing and navigating.
 *   reader  — warm, wide-spaced, serif. Reading.
 */

:root {
    color-scheme: light;

    --bg: #f6f7f9;
    --bg-card: #ffffff;
    --bg-sunken: #eceff3;
    --bg-reader: #fbfaf7;
    --bg-overlay: rgba(12, 16, 22, 0.72);

    --text: #131820;
    --text-secondary: #4b5563;
    --text-muted: #767f8c;
    --text-reader: #1c1a17;

    --accent: #a8481a;
    --accent-light: #c25b28;
    --accent-contrast: #ffffff;
    --accent-subtle: #fbeee6;

    --border: #dde1e8;
    --border-light: #eaedf2;
    --focus: #1668c7;

    --ok: #2f7d52;
    --ok-subtle: #e7f3ec;
    --info: #2b6390;
    --info-subtle: #e6eef6;
    --warn: #96631a;
    --warn-subtle: #f7efe0;

    --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
    --shadow: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.04);
    --shadow-lg: 0 8px 24px rgba(16, 24, 40, 0.10);

    --max-reader: 40rem;
    --max-content: 78rem;
    --aside-w: 17rem;
    --radius: 6px;
    --radius-lg: 10px;
    --header-h: 3.25rem;

    /* Set by reader.js. Scales the prose only, never the chrome. */
    --reader-scale: 1;

    --font-serif: Georgia, 'Iowan Old Style', 'Times New Roman', serif;
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, system-ui, sans-serif;

    /* Ghost injects --gh-font-* from Design → Brand when a custom font is picked. */
    --font-heading: var(--gh-font-heading, var(--font-serif));
    --font-body: var(--gh-font-body, var(--font-serif));
}

[data-theme="dark"] {
    color-scheme: dark;

    --bg: #0e1116;
    --bg-card: #161a20;
    --bg-sunken: #1c212a;
    --bg-reader: #14171c;
    --bg-overlay: rgba(4, 6, 10, 0.78);

    --text: #e5e9ef;
    --text-secondary: #9fa9b7;
    --text-muted: #6e7784;
    --text-reader: #ddd8ce;

    --accent: #e08a52;
    --accent-light: #f0a36f;
    --accent-contrast: #16100b;
    --accent-subtle: #291d15;

    --border: #262d36;
    --border-light: #1f242c;
    --focus: #6cb0ff;

    --ok: #6fc494;
    --ok-subtle: #16261d;
    --info: #79b3e0;
    --info-subtle: #142230;
    --warn: #d5a760;
    --warn-subtle: #2a2114;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
}

/* === Reset & base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--text);
    line-height: 1.55;
    min-height: 100vh;
    display: flex; flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

img, svg { max-width: 100%; height: auto; }
::selection { background: var(--accent); color: var(--accent-contrast); }

a { color: var(--accent); text-decoration: none; transition: color 0.15s; }
a:hover { color: var(--accent-light); }

button, input, select { font: inherit; color: inherit; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 3px; }

.sr-only {
    position: absolute; width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

.skip-link {
    position: absolute; top: -100px; left: 1rem; z-index: 100;
    background: var(--accent); color: var(--accent-contrast);
    padding: 0.5rem 1rem; border-radius: var(--radius);
}
.skip-link:focus { top: 0.5rem; }
main:focus { outline: none; }

/* === Buttons === */
.btn-primary, .btn-ghost, .btn-small {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
    border-radius: var(--radius); cursor: pointer;
    font-weight: 550; white-space: nowrap;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn-primary {
    background: var(--accent); color: var(--accent-contrast);
    padding: 0.5rem 1.1rem; border: 1px solid var(--accent); font-size: 0.875rem;
}
.btn-primary:hover { background: var(--accent-light); border-color: var(--accent-light); color: var(--accent-contrast); }

.btn-ghost {
    background: var(--bg-card); color: var(--text-secondary);
    padding: 0.5rem 1.1rem; border: 1px solid var(--border); font-size: 0.875rem;
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

.btn-small { padding: 0.3rem 0.7rem; font-size: 0.78rem; border: 1px solid var(--border); background: transparent; color: var(--text-secondary); }
.btn-small:hover { border-color: var(--accent); color: var(--accent); }

.icon-btn {
    background: none; border: 1px solid var(--border);
    border-radius: var(--radius); cursor: pointer;
    font-size: 1rem; line-height: 1;
    padding: 0.38rem 0.5rem; color: var(--text-secondary);
    transition: border-color 0.15s, color 0.15s;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }

/* === Chips === */
.chip {
    display: inline-flex; align-items: center; gap: 0.25rem;
    font-size: 0.68rem; font-weight: 650;
    letter-spacing: 0.04em; text-transform: uppercase;
    padding: 0.18rem 0.5rem; border-radius: 3px;
    background: var(--bg-sunken); color: var(--text-secondary);
    white-space: nowrap;
}
.chip-ongoing { background: var(--ok-subtle); color: var(--ok); }
.chip-complete { background: var(--info-subtle); color: var(--info); }
.chip-hiatus { background: var(--warn-subtle); color: var(--warn); }
.chip-series { background: var(--accent-subtle); color: var(--accent); }

.chip-genre {
    text-transform: none; letter-spacing: 0; font-weight: 500;
    font-size: 0.75rem; padding: 0.2rem 0.55rem;
    background: transparent; border: 1px solid var(--border); color: var(--text-secondary);
}
a.chip-genre:hover { border-color: var(--accent); color: var(--accent); }

/* A tag's Ghost accent colour, shown as a swatch rather than as text or
 * background: an author-chosen hex cannot be trusted to clear contrast against
 * both themes, but a dot beside readable text always can. */
.chip-tinted::before {
    content: ''; flex: none;
    width: 0.5em; height: 0.5em; border-radius: 50%;
    background: var(--chip-accent);
    box-shadow: 0 0 0 1px rgb(0 0 0 / 0.12) inset;
}
a.chip-tinted { border-color: color-mix(in srgb, var(--chip-accent) 40%, var(--border)); }
a.chip-tinted:hover {
    border-color: var(--chip-accent);
    background: color-mix(in srgb, var(--chip-accent) 10%, transparent);
    color: var(--text);
}

/* === Header === */
.site-header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 0 1.25rem;
    position: sticky; top: 0; z-index: 50;
}
@supports (backdrop-filter: blur(8px)) or (-webkit-backdrop-filter: blur(8px)) {
    .site-header {
        background: color-mix(in srgb, var(--bg-card) 82%, transparent);
        backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    }
}

.header-inner {
    max-width: var(--max-content); margin: 0 auto;
    display: flex; align-items: center; gap: 1.5rem;
    height: var(--header-h);
}

.site-title {
    font-family: var(--font-heading);
    font-size: 1.2rem; font-weight: 700;
    color: var(--text); letter-spacing: -0.015em; white-space: nowrap;
}
.site-title:hover { color: var(--accent); }

.site-nav ul { display: flex; gap: 0.1rem; list-style: none; }
.site-nav a {
    display: block; font-size: 0.85rem; font-weight: 500;
    color: var(--text-secondary); padding: 0.3rem 0.65rem;
    border-radius: var(--radius); transition: background 0.15s, color 0.15s;
}
.site-nav a:hover { color: var(--text); background: var(--bg-sunken); }
.site-nav a.active, .site-nav a[aria-current="page"] { color: var(--accent); background: var(--accent-subtle); }

.header-controls { margin-left: auto; display: flex; align-items: center; gap: 0.5rem; }

[data-theme="dark"] .icon-sun { display: inline; }
[data-theme="dark"] .icon-moon { display: none; }
.icon-sun { display: none; }
.icon-moon { display: inline; }

.btn-signin, .btn-account {
    font-size: 0.82rem; font-weight: 550; padding: 0.38rem 0.9rem;
    border: 1px solid var(--border); border-radius: var(--radius);
    color: var(--text-secondary); background: transparent;
    transition: border-color 0.15s, color 0.15s;
}
.btn-signin:hover, .btn-account:hover { border-color: var(--accent); color: var(--accent); }

.nav-toggle { display: none; }

.mobile-nav { border-top: 1px solid var(--border-light); padding: 0.4rem 0 0.7rem; }
.mobile-nav ul { list-style: none; display: flex; flex-direction: column; }
.mobile-nav a { display: block; padding: 0.55rem 0.25rem; color: var(--text-secondary); font-size: 0.92rem; }
.mobile-nav a:hover, .mobile-nav a[aria-current="page"] { color: var(--accent); }

/* === Layout shell === */
main { flex: 1; max-width: var(--max-content); margin: 0 auto; padding: 1.75rem 1.25rem 4rem; width: 100%; }

.shell { display: grid; grid-template-columns: minmax(0, 1fr) var(--aside-w); gap: 2.5rem; align-items: start; }
.shell-aside { position: sticky; top: calc(var(--header-h) + 1.25rem); display: grid; gap: 1.5rem; }

.section-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 1rem; margin-bottom: 0.9rem;
}
.section-title {
    font-family: var(--font-heading);
    font-size: 1.15rem; font-weight: 700; letter-spacing: -0.01em;
    color: var(--text);
}
.section-more { font-size: 0.8rem; font-weight: 550; color: var(--text-secondary); white-space: nowrap; }
.section-more:hover { color: var(--accent); }

.block { margin-bottom: 2.5rem; }

.empty-state {
    text-align: center; color: var(--text-muted);
    padding: 2.5rem 1rem; grid-column: 1 / -1; font-size: 0.9rem;
    border: 1px dashed var(--border); border-radius: var(--radius-lg);
}
/* Misconfiguration, not emptiness — worth reading. */
.setup-hint {
    text-align: left; max-width: 44rem; line-height: 1.65;
    color: var(--text-secondary); border-style: solid;
    border-left: 3px solid var(--warn); background: var(--warn-subtle);
    padding: 1rem 1.25rem;
}
.setup-hint strong { color: var(--text); display: block; margin-bottom: 0.2rem; }
.setup-hint code {
    font-size: 0.85em; padding: 0.1em 0.35em; border-radius: 3px;
    background: var(--bg-card); border: 1px solid var(--border);
}

/* === Home hero === */
.home-hero {
    padding: 0 0 1.75rem; margin-bottom: 1.75rem;
    border-bottom: 1px solid var(--border);
}
.home-hero h1 {
    font-family: var(--font-heading); font-size: 1.75rem;
    font-weight: 700; letter-spacing: -0.02em; line-height: 1.15;
}
.hero-desc { color: var(--text-secondary); margin-top: 0.3rem; font-size: 0.95rem; }

/* === Work grid ===
 * Fixed track width, not 1fr: three novels must not stretch into six columns
 * of dead space, and must not balloon when they are the only three.
 */
.works-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(9.5rem, 11rem));
    justify-content: start;
    gap: 1.5rem 1.25rem;
}

.work-card { display: flex; flex-direction: column; gap: 0.55rem; }

.work-cover {
    position: relative; aspect-ratio: 2/3; overflow: hidden;
    border-radius: var(--radius); background: var(--bg-sunken);
    box-shadow: var(--shadow); border: 1px solid var(--border-light);
    transition: transform 0.2s, box-shadow 0.2s;
}
.work-card:hover .work-cover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.work-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }

.work-cover-placeholder {
    width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(160deg, var(--bg-sunken), var(--accent-subtle));
    color: var(--text-secondary); font-family: var(--font-heading);
    font-size: 0.95rem; text-align: center; padding: 1rem; line-height: 1.3;
}
/* Coverless tiles — genres, mostly — pick up the tag's own colour. Kept low so
 * the title stays legible whatever hex the author chose. */
.work-cover-placeholder[style*="--chip-accent"] {
    background: linear-gradient(160deg,
        color-mix(in srgb, var(--chip-accent) 22%, var(--bg-sunken)),
        color-mix(in srgb, var(--chip-accent) 8%, var(--bg-sunken)));
}

/* Status sits on the cover so the text block below stays one clean stack. */
.work-cover .chip { position: absolute; left: 0.4rem; bottom: 0.4rem; box-shadow: var(--shadow-sm); }

.work-info { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
.work-info h2, .work-info h3 {
    font-size: 0.9rem; font-weight: 650; line-height: 1.3; color: var(--text);
    letter-spacing: -0.005em;
    display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2;
    -webkit-box-orient: vertical; overflow: hidden;
}
.work-card:hover .work-info h2, .work-card:hover .work-info h3 { color: var(--accent); }
.work-meta { font-size: 0.75rem; color: var(--text-muted); display: flex; gap: 0.35rem; flex-wrap: wrap; }
.work-meta span + span::before { content: '·'; margin-right: 0.35rem; opacity: 0.55; }
.work-desc {
    font-size: 0.78rem; color: var(--text-secondary); line-height: 1.45;
    display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2;
    -webkit-box-orient: vertical; overflow: hidden;
}

/* === Feed: latest chapters === */
.feed { border-top: 1px solid var(--border-light); }
.feed-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center; gap: 0.75rem 1rem;
    padding: 0.6rem 0.5rem;
    border-bottom: 1px solid var(--border-light);
    border-radius: var(--radius);
    transition: background 0.12s;
}
.feed-row:hover { background: var(--bg-card); }
.feed-main { min-width: 0; display: flex; flex-direction: column; gap: 0.1rem; }
.feed-title {
    font-size: 0.9rem; font-weight: 550; color: var(--text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.feed-row:hover .feed-title { color: var(--accent); }
.feed-sub {
    display: flex; align-items: center; gap: 0.45rem; flex-wrap: wrap;
    font-size: 0.75rem; color: var(--text-muted); min-width: 0;
}
.feed-sub a { color: var(--text-secondary); font-weight: 500; }
.feed-sub a:hover { color: var(--accent); }
.feed-sub .sep { opacity: 0.5; }
.feed-aside {
    font-size: 0.75rem; color: var(--text-muted);
    font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap;
}
.feed-aside .sep { margin: 0 0.3rem; opacity: 0.55; }

/* === Sidebar === */
.aside-block {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 0.9rem 1rem 1rem;
}
.aside-title {
    font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.07em; color: var(--text-muted); margin-bottom: 0.7rem;
}
.rank-list { list-style: none; display: flex; flex-direction: column; }
.rank-list li + li { border-top: 1px solid var(--border-light); }
.rank-list a { display: flex; gap: 0.65rem; align-items: center; padding: 0.5rem 0; }
.rank-num {
    font-size: 0.8rem; font-weight: 700; color: var(--text-muted);
    font-variant-numeric: tabular-nums; min-width: 1.1rem;
}
.rank-body { min-width: 0; display: flex; flex-direction: column; }
.rank-title {
    font-size: 0.83rem; font-weight: 550; color: var(--text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rank-list a:hover .rank-title { color: var(--accent); }
.rank-meta { font-size: 0.72rem; color: var(--text-muted); }

.tag-cloud { display: flex; flex-wrap: wrap; gap: 0.35rem; }

/* === Work hero (novel + series pages) === */
.work-hero {
    display: grid;
    grid-template-columns: 11rem minmax(0, 1fr);
    gap: 1.75rem;
    padding-bottom: 1.75rem; margin-bottom: 1.75rem;
    border-bottom: 1px solid var(--border);
}
.hero-cover {
    width: 100%; aspect-ratio: 2/3; object-fit: cover;
    border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-light);
}
.hero-cover-placeholder {
    width: 100%; aspect-ratio: 2/3; border-radius: var(--radius-lg);
    background: linear-gradient(160deg, var(--bg-sunken), var(--accent-subtle));
    display: flex; align-items: center; justify-content: center; text-align: center;
    color: var(--text-secondary); font-family: var(--font-heading); padding: 1rem;
    box-shadow: var(--shadow-lg);
}

.hero-body { display: flex; flex-direction: column; gap: 0.75rem; min-width: 0; }
.hero-chips { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.hero-body h1 {
    font-family: var(--font-heading); font-size: 1.95rem; font-weight: 700;
    line-height: 1.15; letter-spacing: -0.02em;
}
.hero-byline { font-size: 0.9rem; color: var(--text-muted); }
.hero-byline a { font-weight: 600; }

.hero-stats {
    display: flex; gap: 1.75rem; flex-wrap: wrap;
    padding: 0.75rem 0; border-top: 1px solid var(--border-light); border-bottom: 1px solid var(--border-light);
}
.stat { display: flex; flex-direction: column; gap: 0.1rem; }
.stat-value {
    font-size: 1.05rem; font-weight: 700; color: var(--text);
    font-variant-numeric: tabular-nums; line-height: 1.2;
}
.stat-label {
    font-size: 0.68rem; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.06em; color: var(--text-muted);
}

.hero-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; }
.hero-tagline { font-size: 0.95rem; color: var(--text-secondary); line-height: 1.6; }

.work-synopsis {
    font-size: 0.92rem; line-height: 1.7; color: var(--text-secondary);
    margin-bottom: 2rem; max-width: 46rem;
}
.work-synopsis:empty, .page-content:empty { display: none; }
.work-synopsis p { margin-bottom: 0.9em; }
.work-synopsis p:last-child { margin-bottom: 0; }
.work-synopsis ul, .work-synopsis ol { padding-left: 1.4rem; margin-bottom: 0.9em; }

/* === Chapter index === */
.toc-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 1rem; margin-bottom: 0.5rem; flex-wrap: wrap;
}
.toc-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }

/* Novel and series pages are a single centred column — no sidebar competing
 * with the chapter index. */
.novel-page, .series-chapters, .work-hero, .work-synopsis {
    max-width: 58rem; margin-inline: auto;
}

.toc-list { list-style: none; border-top: 1px solid var(--border-light); }
.toc-list--desc { display: flex; flex-direction: column-reverse; border-top: none; border-bottom: 1px solid var(--border-light); }

.toc-item { border-bottom: 1px solid var(--border-light); }
.toc-list--desc .toc-item { border-bottom: none; border-top: 1px solid var(--border-light); }

.toc-item > a {
    display: grid;
    grid-template-columns: 2.5rem minmax(0, 1fr) auto auto;
    align-items: center; gap: 0.85rem;
    padding: 0.5rem 0.5rem;
    border-radius: var(--radius);
    transition: background 0.12s;
}
.toc-item > a:hover { background: var(--bg-card); }

.toc-num {
    font-size: 0.78rem; color: var(--text-muted);
    text-align: right; font-variant-numeric: tabular-nums; font-weight: 600;
}
.toc-info { min-width: 0; display: flex; flex-direction: column; gap: 0.05rem; }
.toc-title {
    font-size: 0.88rem; font-weight: 500; color: var(--text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.toc-item > a:hover .toc-title { color: var(--accent); }
.toc-sub {
    display: flex; gap: 0.5rem; flex-wrap: wrap;
    font-size: 0.72rem; color: var(--text-muted);
}
.toc-series { color: var(--text-secondary); font-weight: 500; }
.toc-meta {
    font-size: 0.73rem; color: var(--text-muted);
    font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right;
}
.toc-read-mark { width: 0.9rem; color: var(--ok); font-size: 0.78rem; text-align: center; }

.toc-item.is-read .toc-title { color: var(--text-muted); font-weight: 400; }
.toc-item.is-read .toc-read-mark::before { content: '✓'; }
.toc-item.is-current > a { background: var(--accent-subtle); }
.toc-item.is-current .toc-title { font-weight: 700; color: var(--accent); }

/* Compact rows lose the sub-line on narrow screens rather than wrapping. */
.toc-list--compact .toc-sub { display: none; }

/* === Authors === */
.authors-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
    gap: 0.6rem;
}
.author-card {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.7rem 0.85rem; background: var(--bg-card);
    border: 1px solid var(--border); border-radius: var(--radius-lg);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.author-card:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.author-avatar {
    width: 42px; height: 42px; border-radius: 50%; object-fit: cover; flex-shrink: 0;
}
.author-avatar-placeholder {
    width: 42px; height: 42px; border-radius: 50%;
    background: var(--accent-subtle); color: var(--accent);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 1.05rem; flex-shrink: 0;
}
.author-card-info { display: flex; flex-direction: column; min-width: 0; }
.author-card-name {
    font-size: 0.87rem; font-weight: 600; color: var(--text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.author-card-meta { font-size: 0.75rem; color: var(--text-muted); }

.author-header {
    display: flex; gap: 1.25rem; align-items: center;
    padding-bottom: 1.5rem; margin-bottom: 1.75rem;
    border-bottom: 1px solid var(--border);
}
.author-avatar-lg { width: 84px; height: 84px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.author-avatar-lg-placeholder {
    width: 84px; height: 84px; border-radius: 50%;
    background: var(--accent-subtle); color: var(--accent);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 2rem; flex-shrink: 0;
}
.author-info h1 { font-family: var(--font-heading); font-size: 1.6rem; letter-spacing: -0.02em; }
.author-bio { margin-top: 0.3rem; color: var(--text-secondary); line-height: 1.6; max-width: 40rem; font-size: 0.92rem; }
.author-stats { margin-top: 0.4rem; font-size: 0.82rem; color: var(--text-muted); }
.author-stats .sep { opacity: 0.5; margin: 0 0.15rem; }

/* === Chapter reader ===
 * Warm surface, wide measure. This is the only part of the site that is not dense.
 */
.chapter-reader {
    max-width: var(--max-reader); margin: 0 auto; padding-bottom: 2rem;
    --text: var(--text-reader);
}
body.post-template { background: var(--bg-reader); }

.chapter-header { padding: 2rem 0 1.5rem; }
.chapter-breadcrumb { margin-bottom: 0.9rem; font-size: 0.82rem; display: flex; gap: 0.5rem; flex-wrap: wrap; }
.chapter-breadcrumb a { color: var(--text-secondary); font-weight: 550; }
.chapter-breadcrumb a:hover { color: var(--accent); }

.chapter-header h1 {
    font-family: var(--font-heading); font-size: 1.85rem;
    font-weight: 700; line-height: 1.2; letter-spacing: -0.02em; color: var(--text-reader);
}
.chapter-header .chapter-meta {
    display: flex; gap: 1rem; flex-wrap: wrap;
    margin-top: 0.5rem; font-size: 0.82rem; color: var(--text-muted);
}
.chapter-header .chapter-meta a { color: var(--text-secondary); font-weight: 550; }
.chapter-header .chapter-meta a:hover { color: var(--accent); }

.reader-toolbar {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.4rem 0; margin: 0 0 1.75rem;
    border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
    position: sticky; top: var(--header-h); z-index: 40;
    background: var(--bg-reader);
}
.font-controls { display: flex; gap: 0.15rem; }
.reader-toolbar button {
    background: transparent; border: 1px solid transparent;
    padding: 0.28rem 0.55rem; border-radius: var(--radius);
    font-size: 0.78rem; cursor: pointer; color: var(--text-secondary);
    transition: border-color 0.15s, background 0.15s;
}
.reader-toolbar button:hover:not(:disabled) { border-color: var(--border); background: var(--bg-card); }
.reader-toolbar button:disabled { opacity: 0.3; cursor: default; }
.toolbar-spacer { flex: 1; }

.reader-progress { display: block; width: 5rem; height: 3px; background: var(--border); border-radius: 2px; overflow: hidden; }
.reader-progress-bar { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.15s linear; }
.reader-progress-pct {
    font-size: 0.72rem; color: var(--text-muted);
    font-variant-numeric: tabular-nums; min-width: 2.4rem; text-align: right;
}

.chapter-content {
    font-family: var(--font-body);
    font-size: calc(1.125rem * var(--reader-scale));
    line-height: 1.85; color: var(--text-reader);
    overflow-wrap: break-word;
}
body.reader-sans .chapter-content { font-family: var(--font-sans); line-height: 1.75; }

.chapter-content p { margin-bottom: 1.35em; }
.chapter-content p + p { text-indent: 1.5em; }
.chapter-content p:first-of-type,
.chapter-content hr + p,
.chapter-content h2 + p, .chapter-content h3 + p, .chapter-content h4 + p,
.chapter-content blockquote + p,
.chapter-content figure + p { text-indent: 0; }

body:not(.no-drop-caps) .chapter-content > p:first-of-type::first-letter {
    float: left; font-size: 3.6em; line-height: 0.78;
    padding: 0.06em 0.12em 0 0; font-weight: 700; color: var(--accent);
}

.chapter-content h2, .chapter-content h3, .chapter-content h4 {
    font-family: var(--font-sans); margin: 2em 0 0.5em;
    font-weight: 650; letter-spacing: -0.01em;
}
.chapter-content h2 { font-size: 1.3rem; }
.chapter-content h3 { font-size: 1.12rem; }
.chapter-content ul, .chapter-content ol { padding-left: 1.4em; margin-bottom: 1.35em; }
.chapter-content li { margin-bottom: 0.35em; }

.chapter-content hr { border: none; text-align: center; margin: 2.25em 0; overflow: visible; }
.chapter-content hr::after {
    content: '◆  ◆  ◆'; color: var(--text-muted);
    font-size: 0.68rem; letter-spacing: 0.3em;
}

.chapter-content blockquote {
    border-left: 3px solid var(--accent); margin: 1.5em 0;
    padding: 0.5em 1.15em; color: var(--text-secondary); font-style: italic;
}
.chapter-content img { border-radius: var(--radius); margin: 1.5em auto; display: block; }
.chapter-content figcaption {
    text-align: center; font-family: var(--font-sans);
    font-size: 0.78rem; color: var(--text-muted); margin-top: 0.5em;
}
.chapter-content pre {
    background: var(--bg-sunken); padding: 1rem; border-radius: var(--radius);
    overflow-x: auto; font-size: 0.85rem; margin-bottom: 1.35em;
}

.kg-width-wide { max-width: min(52rem, 92vw); margin-inline: auto; }
.kg-width-full {
    max-width: 100vw; width: 100vw;
    margin-left: calc(50% - 50vw); margin-right: calc(50% - 50vw);
}
.kg-width-wide img, .kg-width-full img { width: 100%; }
.kg-card { margin: 1.75em 0; }

.author-note, .subscribe-cta {
    margin: 2.25rem 0; padding: 1.1rem 1.35rem;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}
.author-note { border-left: 3px solid var(--accent); }
.author-note h2 {
    font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em;
    margin-bottom: 0.4rem; color: var(--text-muted); font-weight: 700;
}
.author-note p { font-size: 0.92rem; color: var(--text-secondary); font-family: var(--font-body); line-height: 1.65; }

.subscribe-cta { text-align: center; }
.subscribe-cta h2 { font-family: var(--font-heading); font-size: 1.15rem; margin-bottom: 0.3rem; }
.subscribe-cta p { color: var(--text-secondary); font-size: 0.88rem; margin-bottom: 0.9rem; }

/* Chapter navigation — the primary action on a reader page. */
.chapter-nav {
    display: grid; grid-template-columns: 1fr auto 1fr;
    gap: 0.75rem; align-items: stretch;
    margin-top: 2.5rem; padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}
.chapter-nav > div { display: flex; }
.nav-prev { justify-content: flex-start; }
.nav-next { justify-content: flex-end; }
.nav-toc { align-items: center; }

.chapter-nav a {
    display: flex; flex-direction: column; gap: 0.1rem;
    padding: 0.6rem 0.9rem; border: 1px solid var(--border);
    border-radius: var(--radius); background: var(--bg-card);
    min-width: 0; max-width: 100%;
    transition: border-color 0.15s, background 0.15s;
}
.chapter-nav a:hover { border-color: var(--accent); }
.nav-next a { text-align: right; }
.nav-label { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); font-weight: 650; }
.nav-title {
    font-size: 0.85rem; color: var(--text); font-weight: 550;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chapter-nav a:hover .nav-title { color: var(--accent); }
.nav-toc a { justify-content: center; font-size: 0.82rem; white-space: nowrap; }

.kbd-hint { margin-top: 1rem; text-align: center; font-size: 0.73rem; color: var(--text-muted); }
.kbd-hint kbd {
    font-family: var(--font-sans); font-size: 0.7rem;
    border: 1px solid var(--border); border-bottom-width: 2px;
    border-radius: 4px; padding: 0.05em 0.35em; background: var(--bg-card);
}

.chapter-comments { margin-top: 2.5rem; }
.chapter-comments h2 { font-family: var(--font-sans); font-size: 1rem; margin-bottom: 0.9rem; font-weight: 650; }

/* === Resume reading === */
.resume-slot:empty { display: none; }
.resume-btn { flex-direction: column; align-items: flex-start; gap: 0.05rem; line-height: 1.25; padding: 0.45rem 1rem; }
.resume-label { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.06em; opacity: 0.85; font-weight: 650; }
.resume-title { font-size: 0.85rem; font-weight: 600; }

/* === Visibility badge === */
.vis-badge { font-size: 0.72em; margin-left: 0.3em; vertical-align: middle; }
.vis-badge.vis-paid { color: var(--warn); }
.vis-badge.vis-members { color: var(--accent); }
.vis-badge.vis-tiers { color: var(--info); }

/* === Browse === */
.browse-filters { display: flex; gap: 0.5rem; margin-bottom: 0.75rem; flex-wrap: wrap; }
.browse-input {
    flex: 1; min-width: 12rem;
    padding: 0.45rem 0.8rem; font-size: 0.87rem;
    border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--bg-card); color: var(--text);
    transition: border-color 0.15s;
}
.browse-input:hover { border-color: var(--text-muted); }
.browse-select {
    padding: 0.45rem 0.8rem; font-size: 0.87rem;
    border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--bg-card); color: var(--text); cursor: pointer;
}
.browse-count { font-size: 0.78rem; color: var(--text-muted); margin-bottom: 0.4rem; }
.browse-row[hidden] { display: none; }
/* Browse rows carry no chapter number — drop the number column. */
.browse-row > a { grid-template-columns: minmax(0, 1fr) auto auto; }

/* === Static page === */
.static-page { max-width: 44rem; margin: 0 auto; }
.page-header { padding: 1rem 0 1.25rem; }
.page-header h1 { font-family: var(--font-heading); font-size: 1.8rem; letter-spacing: -0.02em; }
.page-lede { margin-top: 0.4rem; color: var(--text-secondary); }
.page-feature-image { width: 100%; border-radius: var(--radius-lg); margin-bottom: 1.75rem; }
.page-content { font-size: 0.98rem; line-height: 1.75; }
.page-content p { margin-bottom: 1em; }
.page-content ul, .page-content ol { padding-left: 1.5rem; margin-bottom: 1em; }
.page-content img { border-radius: var(--radius); }

/* === Error === */
.error-page { max-width: 32rem; margin: 5rem auto; text-align: center; }
.error-code { font-family: var(--font-heading); font-size: 4.5rem; font-weight: 700; line-height: 1; color: var(--border); }
.error-title { font-family: var(--font-heading); font-size: 1.5rem; margin-top: -0.25rem; }
.error-help { margin-top: 0.6rem; color: var(--text-secondary); }
.error-actions { margin-top: 1.75rem; display: flex; gap: 0.6rem; justify-content: center; flex-wrap: wrap; }
.error-details { margin-top: 2.5rem; text-align: left; font-size: 0.83rem; color: var(--text-secondary); }
.error-details ul { padding-left: 1.25rem; }

/* === Footer === */
.site-footer {
    padding: 1.75rem 1.25rem; font-size: 0.8rem; color: var(--text-muted);
    border-top: 1px solid var(--border); margin-top: auto; background: var(--bg-card);
}
.footer-inner { max-width: var(--max-content); margin: 0 auto; display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap; }
.footer-nav ul { list-style: none; display: flex; gap: 1.1rem; flex-wrap: wrap; }
.footer-inner p { margin-left: auto; }
.site-footer a { color: var(--text-secondary); }
.site-footer a:hover { color: var(--accent); }

/* === Preview harness only === */
.preview-stub {
    border: 1px dashed var(--border); border-radius: var(--radius);
    padding: 2rem; text-align: center; color: var(--text-muted); font-size: 0.85rem;
}

/* === Responsive === */
@media (max-width: 1080px) {
    .shell { grid-template-columns: minmax(0, 1fr); }
    .shell-aside { display: none; }
}

@media (max-width: 860px) {
    .site-nav { display: none; }
    .nav-toggle { display: block; }
}

@media (min-width: 861px) { .mobile-nav { display: none; } }

@media (max-width: 640px) {
    main { padding: 1.25rem 0.9rem 3rem; }

    .site-title { font-size: 1.05rem; }
    .home-hero h1 { font-size: 1.45rem; }

    .works-grid { grid-template-columns: repeat(auto-fill, minmax(7.5rem, 1fr)); gap: 1.1rem 0.85rem; }

    .work-hero { grid-template-columns: 7.5rem minmax(0, 1fr); gap: 1rem; }
    .hero-body h1 { font-size: 1.35rem; }
    .hero-stats { gap: 1.1rem; }
    .stat-value { font-size: 0.95rem; }

    .toc-item > a { grid-template-columns: 1.9rem minmax(0, 1fr) auto auto; gap: 0.6rem; }
    .browse-row > a { grid-template-columns: minmax(0, 1fr) auto auto; }
    .toc-meta { display: none; }

    .feed-row { grid-template-columns: minmax(0, 1fr); }
    .feed-aside { text-align: left; }

    .chapter-header { padding: 1.25rem 0 1rem; }
    .chapter-header h1 { font-size: 1.4rem; }
    .chapter-content { font-size: calc(1.05rem * var(--reader-scale)); }
    body:not(.no-drop-caps) .chapter-content > p:first-of-type::first-letter { font-size: 3em; }

    .chapter-nav { grid-template-columns: 1fr; }
    .nav-prev, .nav-next { justify-content: stretch; }
    .chapter-nav a { width: 100%; }
    .nav-next a { text-align: left; }
    .kbd-hint { display: none; }

    .author-header { flex-direction: column; text-align: center; }
    .author-bio { text-align: left; }

    .footer-inner { flex-direction: column; align-items: flex-start; gap: 0.75rem; }
    .footer-inner p { margin-left: 0; }
}

/* === Motion === */
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after {
        animation-duration: 0.01ms !important; animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important; scroll-behavior: auto !important;
    }
    .work-card:hover .work-cover { transform: none; }
}

/* === Print === */
@media print {
    .site-header, .site-footer, .reader-toolbar, .chapter-nav,
    .chapter-comments, .subscribe-cta, .kbd-hint, .skip-link,
    .resume-slot, .toc-order-toggle, .shell-aside { display: none !important; }

    html { font-size: 12pt; }
    body { background: #fff; color: #000; }
    main { max-width: none; padding: 0; }
    .chapter-reader { max-width: none; }
    .chapter-content { font-size: 12pt; line-height: 1.5; }
    .chapter-content a { color: #000; text-decoration: underline; }
    .chapter-content a[href^="http"]::after { content: ' (' attr(href) ')'; font-size: 9pt; }
    .chapter-content p, .chapter-content blockquote { orphans: 3; widows: 3; }
    .chapter-content h2, .chapter-content h3 { break-after: avoid; }
}

/* === Genre archive === */
.genre-hero {
    padding-bottom: 1.25rem; margin-bottom: 1.75rem;
    border-bottom: 1px solid var(--border);
}
.genre-hero h1 {
    font-family: var(--font-heading); font-size: 1.9rem;
    font-weight: 700; letter-spacing: -0.02em; line-height: 1.15;
}
.genre-hero .hero-tagline { margin-top: 0.35rem; }
