/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    /* Why: iOS Safari/Chrome (WebKit) rescales text on fixed-position elements
       when the URL bar collapses/expands during scroll, lagging behind the
       viewport resize. Pinning to 100% disables that autosizing pass so the
       sticky reading header resizes deterministically with the viewport. */
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

:root {
    --radius-control: 8px; /* buttons, inputs-as-buttons, switches */
    /* Design system ("quiet library", redesign 2026-10-12 — see
       docs/superpowers/specs/2026-10-12-site-redesign-design.md). New
       selectors use these; the legacy names below alias onto them until
       their call sites are migrated. */
    --paper: #F6F1E7;
    --paper-deep: #EFE7D8;
    --surface: #FBF8F1;
    --ink: #2B2622;
    --ink-muted: #6B5F55;
    --rule: #E8DFCF;
    --rule-strong: #D6CAB5;
    --accent: #8A2E2E;
    --accent-hover: #742525;
    --on-accent: #FFFFFF;
    --accent-bright: #B23A3A; /* accent on the dark hero band */
    --font-serif: 'New York', 'Iowan Old Style', Baskerville, 'Hoefler Text', Georgia, 'Times New Roman', serif;
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --level-easy-bg: #E3EBDD;
    --level-easy-fg: #3E5A36;
    --level-moderate-bg: #F3E6CC;
    --level-moderate-fg: #7A5A1E;
    --level-challenging-bg: #F1DEDA;
    --level-challenging-fg: #7A2828;

    /* Legacy tokens, re-pointed at the design system. */
    --primary-color: var(--ink);
    --secondary-color: var(--accent);
    --accent-color: #e74c3c;
    --background-color: var(--paper-deep);
    --card-background: var(--surface);
    --text-color: var(--ink);
    --text-light: var(--ink-muted);
    --text-muted: #8C8178;
    --border-color: var(--rule-strong);
    --border-light: var(--rule);
    --secondary-color-hover: var(--accent-hover);
    --sticky-header-accent: #333333;
    --sticky-header-border: #666666;
    --reading-theme-dark-bg: #1a1a1a;
    --reading-theme-dark-text: #e0e0e0;
    --reading-theme-sepia-bg: #f4ecd8;
    --reading-theme-sepia-text: #5c4f3d;
    --reading-font-serif: -apple-system-ui-serif, ui-serif, 'New York', 'Iowan Old Style', Georgia, serif;
    --skeleton-base: #f0f0f0;
    --skeleton-highlight: #e8e8e8;
    --text-outline: #000;
    --text-dark: #333;
    --text-secondary: #666;
    --cta-gradient-start: #667eea;
    --cta-gradient-end: #764ba2;
    --reading-theme-dark-accent: #5cb3e0;
    --reading-theme-dark-border: #444;
    --sticky-header-muted: #999999;
    --sticky-header-active: #444444;
    --hero-accent: var(--accent);
    --error-bg-light: #fee;
    --section-bg-light: var(--surface);
    --cover-placeholder-bg: var(--rule);
    --admin-modal-bg: #f5f5f5;
    --border-subtle: #ddd;
    --book-author-text: var(--ink-muted);
    --success-gradient-start: #48bb78;
    --success-gradient-end: #38a169;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.15);
}

body {
    font-family: var(--font-sans);
    background-color: var(--paper);
    color: var(--text-color);
    line-height: 1.6;
    /* Why: 100vh on iOS WebKit resolves to the LARGE viewport (toolbar fully
       collapsed), taller than what's actually visible when the toolbar is
       showing. That makes body/html genuinely scrollable by the difference,
       and since nothing prevents native touch-scroll on the reading page,
       iOS can rubber-band into that slack and rest a few px off 0 instead of
       snapping back — shifting content up under the fixed sticky header.
       100svh (small viewport height) is never taller than what's visible. */
    min-height: 100svh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    min-height: 100svh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    background: var(--paper);
    color: var(--ink);
    border-bottom: 1px solid var(--rule);
    width: 100vw;
    position: relative;
    left: 50%;
    right: 50%;
    margin-left: -50vw;
    margin-right: -50vw;
}

/* Hide header when on chapter or medium summary pages.
   Why: the `body:has(...)` form has a known WebKit timing quirk where
   ancestor-selector invalidation can defer to the next style recalc,
   so for one frame after pushState navigation the site nav can paint
   over the chapter text. The deterministic .on-chapter-page class
   (toggled in showOnlySections) sidesteps that race. */
body.on-chapter-page .header {
    display: none;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-link {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--ink);
    text-decoration: none;
    cursor: pointer;
    transition: opacity 0.2s ease;
    flex-shrink: 0; /* Logo never shrinks */
}

.header-link:hover {
    opacity: 0.9;
}

.header-nav-buttons {
    display: flex;
    gap: 20px;
    margin-left: 20px;
    flex: 1;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
    align-items: center;
}

/* Hide scrollbar for Chrome, Safari, Opera */
.header-nav-buttons::-webkit-scrollbar {
    display: none;
}

.header-nav-btn {
    background: transparent;
    color: var(--ink);
    border: none;
    padding: 0;
    font-size: 0.95rem;
    cursor: pointer;
    transition: opacity 0.2s;
    text-decoration: none;
    font-weight: 400;
    white-space: nowrap; /* Prevent wrapping */
    flex-shrink: 0; /* Don't shrink nav items */
}

.header-nav-btn:hover {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 4px;
}

.logo {
    font-family: var(--font-serif);
    font-size: 1.5rem;
    font-style: normal;
    margin: 0;
    font-weight: 600;
}

.logo-icon {
    height: 36px;
    width: auto;
    border-radius: 6px;
}

/* Breadcrumb Navigation - styled to replace back buttons */
.breadcrumb-nav {
    padding: 0;
    margin-top: 16px;
    margin-bottom: 24px;
}

.breadcrumb-list {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.breadcrumb-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* First breadcrumb link gets the back arrow */
.breadcrumb-item:first-child .breadcrumb-link::before {
    content: '← ';
}

.breadcrumb-link {
    color: var(--secondary-color);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    transition: color 0.2s;
}

.breadcrumb-link:hover {
    color: var(--secondary-color-hover);
}

.breadcrumb-separator {
    color: var(--text-light);
    font-size: 0.8rem;
}

.breadcrumb-current {
    color: var(--text-color);
    font-size: 0.95rem;
    font-weight: 400;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 0 0 40px 0;
}

.hidden {
    display: none !important;
}

/* Books Section */
.books-section {
    padding-top: 20px;
}

.books-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

@media (min-width: 480px) {
    .books-grid {
        gap: 10px;
    }

    .container {
        padding: 0 12px;
    }
}

@media (min-width: 650px) {
    .books-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 16px;
    }

    .container {
        padding: 0 20px;
    }
}

@media (min-width: 900px) {
    .books-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 20px;
    }
}

@media (min-width: 1200px) {
    .books-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 20px;
    }
}

.books-grid {
    row-gap: 2rem;
}

/* Book card — the one card used by every book listing (createBookCard in
   app.js). The cover box keeps a 2:3 shape and shows the title in serif
   until the image loads, so loading never shows grey blobs. */
.book-card,
.top-10-book-card {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    min-width: 0;
    color: var(--ink);
    text-decoration: none;
}

.book-card-cover {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 2 / 3;
    margin-bottom: 0.45rem;
    padding: 12%;
    overflow: hidden;
    border: 1px solid var(--rule);
    border-radius: 4px;
    background: var(--paper-deep);
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.book-card-cover-title {
    display: -webkit-box;
    -webkit-line-clamp: 5;
    -webkit-box-orient: vertical;
    overflow: hidden;
    color: var(--ink-muted);
    font-family: var(--font-serif);
    font-size: 1rem;
    line-height: 1.25;
    text-align: center;
}

.book-card-cover picture,
.book-card-cover img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.book-card-cover img {
    object-fit: cover;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.book-card-cover img.loaded {
    opacity: 1;
}

.book-card:hover .book-card-cover,
.top-10-book-card:hover .book-card-cover {
    transform: translateY(-3px);
    box-shadow: 0 8px 18px rgba(43, 38, 34, 0.16);
}

.book-card:focus-visible,
.top-10-book-card:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 4px;
    border-radius: 4px;
}

.book-card-title {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin: 0;
    color: var(--ink);
    font-family: var(--font-serif);
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.3;
    /* Reserve two lines so author and level line up across a row. */
    min-height: 2.6em;
}

.book-card:hover .book-card-title,
.top-10-book-card:hover .book-card-title {
    color: var(--accent);
}

.book-card-author {
    overflow: hidden;
    margin: 0;
    color: var(--ink-muted);
    font-size: 0.85rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.book-card-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem 0.6rem;
    margin: 0.2rem 0 0;
    color: var(--ink-muted);
    font-size: 0.78rem;
}

.level-tag {
    display: inline-block;
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1.5;
}

.level-tag--easy {
    background: var(--level-easy-bg);
    color: var(--level-easy-fg);
}

.level-tag--moderate {
    background: var(--level-moderate-bg);
    color: var(--level-moderate-fg);
}

.level-tag--challenging {
    background: var(--level-challenging-bg);
    color: var(--level-challenging-fg);
}

/* In horizontal shelves (category/discover carousels, "You may also like")
   the card takes a fixed width instead of a grid column. */
.carousel-scroll .book-card,
.carousel-scroll .top-10-book-card,
.related-books-scroll .book-card {
    flex: 0 0 168px;
}

/* "No. 3" badge on the home "Start here" shelf */
.book-card-rank {
    position: absolute;
    top: 0.4rem;
    left: 0.4rem;
    z-index: 1;
    padding: 0.1rem 0.45rem;
    border-radius: 3px;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font-serif);
    font-size: 0.75rem;
}

.book-card-rank .top-10-rank-number {
    font-size: inherit;
}

@media (max-width: 480px) {
    .carousel-scroll .book-card,
    .carousel-scroll .top-10-book-card,
    .related-books-scroll .book-card {
        flex-basis: 136px;
    }

    .book-card-title {
        font-size: 0.92rem;
    }
}

/* Category Detail Section */
.category-detail-section {
    padding-top: 20px;
    animation: fadeIn 0.3s ease;
}

@media (max-width: 768px) {
    .category-detail-section {
        padding-top: 16px;
    }
}

@media (max-width: 480px) {
    .category-detail-section {
        padding-top: 12px;
    }
}

.category-detail-header {
    margin-bottom: 24px;
}

@media (max-width: 768px) {
    .category-detail-header {
        margin-bottom: 16px;
    }
}

@media (max-width: 480px) {
    .category-detail-header {
        margin-bottom: 12px;
    }
}

.category-detail-header h2 {
    font-size: 2rem;
    color: var(--primary-color);
    margin-bottom: 8px;
}

.category-detail-subtitle {
    font-size: 1rem;
    color: var(--text-light);
}

/* All Categories Section */
.all-categories-section {
    padding-top: 20px;
}

.loading {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-light);
    font-size: 1.1rem;
}

/* Skeleton Loading Styles */
@keyframes shimmer-px {
    0% {
        background-position: -1000px 0;
    }
    100% {
        background-position: 1000px 0;
    }
}

.illustration-skeleton {
    width: 100%;
    height: 400px;
    background: linear-gradient(
        90deg,
        var(--skeleton-base) 0px,
        var(--skeleton-highlight) 40px,
        var(--skeleton-base) 80px
    );
    background-size: 1000px 100%;
    animation: shimmer-px 2s infinite linear;
    border-radius: 8px;
    margin: 20px 0;
}

.error {
    background-color: var(--error-bg-light);
    border: 1px solid var(--accent-color);
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
    color: var(--accent-color);
}

/* Summary Section */
.summary-section {
    background: transparent;
    width: 100vw;
    position: relative;
    left: 50%;
    right: 50%;
    margin-left: -50vw;
    margin-right: -50vw;
    padding: 0;
}

.summary-section > * {
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
    padding-left: 20px;
    padding-right: 20px;
}

.summary-section > *:first-child {
    padding-top: 16px;
}

.summary-section > *:last-child {
    padding-bottom: 40px;
}

/* Loading States */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    min-height: 300px;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-left-color: var(--secondary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

.loading-text {
    color: var(--text-light);
    font-size: 0.9rem;
    font-weight: 500;
    opacity: 0.8;
}

.back-button {
    background: transparent;
    color: var(--secondary-color);
    border: none;
    padding: 8px 0;
    font-size: 0.95rem;
    cursor: pointer;
    transition: color 0.2s;
    font-weight: 500;
}

.back-button-container {
    margin-top: 8px;
    margin-bottom: 12px;
}

.back-button {
    background: transparent;
    border: none;
    color: var(--primary-color);
    font-size: 0.9rem;
    cursor: pointer;
    padding: 6px 0;
    transition: opacity 0.2s;
}

.back-button:hover {
    opacity: 0.7;
}

/* Book Detail Header */
/* Book header: framed cover beside title, meta, actions and progress,
   closed off from the page by a hairline. */
.book-detail-header {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    align-items: center;
    gap: 2.75rem;
    margin-bottom: 2.75rem;
    padding: 0.5rem 0 2.75rem;
    border-bottom: 1px solid var(--rule);
}

#book-info-cover {
    display: block;
}

.book-detail-cover {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 2 / 3;
    object-fit: cover;
    border-radius: 6px;
    box-shadow: 0 1px 2px rgba(43, 38, 34, 0.12), 0 14px 32px rgba(43, 38, 34, 0.18);
}

.book-detail-info {
    min-width: 0;
}

/* Phones: cover beside title, author and meta; actions and progress run
   full width underneath. */
@media (max-width: 767px) {
    .book-detail-header {
        grid-template-columns: 104px minmax(0, 1fr);
        align-items: start;
        gap: 0.35rem 1.1rem;
        padding-bottom: 2rem;
    }

    .book-detail-info {
        display: contents;
    }

    #book-info-cover {
        grid-row: 1 / span 3;
        grid-column: 1;
    }

    .book-detail-info h2,
    .book-author,
    .book-meta {
        grid-column: 2;
    }

    .book-detail-info h2 {
        font-size: 1.5rem;
    }

    .book-author {
        font-size: 0.95rem;
    }

    .book-meta {
        margin-top: 0.4rem;
        font-size: 0.85rem;
    }

    .book-actions,
    .book-progress,
    .plain-english-coming-soon {
        grid-column: 1 / -1;
    }

    .book-actions {
        margin-top: 1.1rem;
    }
}

/* Author link styling - make it obvious and clickable */
.author-link {
    color: var(--ink);
    text-decoration: underline;
    text-decoration-color: var(--rule-strong);
    text-underline-offset: 3px;
    cursor: pointer;
}

.author-link:hover {
    color: var(--accent);
    text-decoration-color: currentColor;
}

.book-detail-info h2 {
    margin-bottom: 0.5rem;
    color: var(--ink);
    font-family: var(--font-serif);
    font-size: clamp(1.6rem, 3.4vw, 2.6rem);
    line-height: 1.12;
    text-wrap: balance;
    overflow-wrap: break-word;
}

.book-author {
    color: var(--ink-muted);
    font-size: 1.05rem;
}

/* Meta row: level · chapters · time · Plain English */
.book-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem 0.9rem;
    margin-top: 1rem;
    color: var(--ink-muted);
    font-size: 0.92rem;
}

.book-meta:empty {
    display: none;
}

.plain-english-badge {
    padding: 0.1rem 0.55rem;
    border: 1px solid var(--accent);
    border-radius: 999px;
    color: var(--accent);
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.5;
}

.book-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    gap: 0.75rem;
    margin-top: 1.6rem;
}

/* Both actions: one height, one shape */
.book-actions .book-read-btn,
.book-actions .book-sxs-link {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    min-height: 48px;
    margin-top: 0;
    padding: 0 1.3rem;
    border-radius: var(--radius-control);
    font-size: 1rem;
    font-weight: 600;
    line-height: 1;
}

.book-actions .book-sxs-link {
    border: 1px solid var(--rule-strong);
    background: var(--surface);
    color: var(--ink);
    text-decoration: none;
}

.book-actions .book-sxs-link:hover {
    border-color: var(--ink-muted);
    background: var(--paper-deep);
}

.book-actions .book-sxs-link svg {
    color: var(--ink-muted);
}

/* Side by side is a wide-screen reading mode (see view_mode.js). */
@media (max-width: 1023px) {
    .book-actions .book-sxs-link {
        display: none;
    }
}

/* Reading progress under the actions (signed-in readers) */
.book-progress {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1rem;
    color: var(--ink-muted);
    font-size: 0.88rem;
}

.book-progress-track {
    flex: 0 0 140px;
    height: 4px;
    overflow: hidden;
    border-radius: 99px;
    background: var(--rule);
}

.book-progress-track span {
    display: block;
    height: 100%;
    background: var(--accent);
}

.book-progress-where {
    color: var(--ink);
}

@media (max-width: 767px) {
    .book-actions .book-read-btn {
        flex: 1 1 auto;
        justify-content: center;
        white-space: nowrap;
    }

    .book-progress {
        flex-wrap: wrap;
    }
}

.author {
    font-size: 1.1rem;
    color: var(--text-light);
    font-style: italic;
}

/* Book Content Sections */

/* About This Book Section */
.about-section,
.about-author-section {
    max-width: 760px;
    margin-bottom: 48px;
}

.about-single-column {
    margin-bottom: 32px;
}

.about-single-column:last-child {
    margin-bottom: 0;
}

.about-heading-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.about-heading {
    margin: 0 0 12px;
    color: var(--ink);
    font-family: var(--font-serif);
    font-size: 1.5rem;
    font-weight: 600;
}

.about-heading-row .about-heading {
    margin-bottom: 0;
}

.about-text {
    font-size: 0.95rem;
    line-height: 1.7;
    color: var(--text-dark);
    margin: 0;
}

.about-text p {
    margin: 0 0 1em 0;
}

.about-text p:last-child {
    margin-bottom: 0;
}

.about-text strong {
    font-weight: 600;
    color: var(--primary-color);
}

.about-text em {
    font-style: italic;
}

.about-text a {
    color: var(--primary-color);
    text-decoration: none;
    border-bottom: 1px solid var(--primary-color);
}

.about-text a:hover {
    opacity: 0.8;
}

/* Author Info */

/* Reading Guide Section (Standalone) - Matches Summary Tabs */
.reading-guide-section {
    margin-bottom: 48px;
}

.reading-guide-tabs-header {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border-light);
    margin-bottom: 24px;
}

.reading-guide-tab {
    background: transparent;
    border: none;
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
    position: relative;
    bottom: -2px;
}

.reading-guide-tab:hover {
    color: var(--primary-color);
}

.reading-guide-tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    font-weight: 600;
}

.reading-guide-tab-content {
    display: none;
}

.reading-guide-tab-content.active {
    display: block;
}

.guide-image {
    width: 100%;
    height: auto;
    cursor: pointer;
    transition: opacity 0.3s ease-in;
    display: block;
}

.guide-image:hover {
    opacity: 0.9;
}

.author-bio-text {
    font-size: 0.95rem;
    line-height: 1.7;
    color: var(--text-dark);
    margin: 0 0 20px 0;
}

/* Author Books Section */
.author-books-section {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #d0d0d0;
}

/* Responsive design for about section */
@media (max-width: 768px) {
    .about-section {
        padding: 20px;
    }

    .author-books-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 12px;
    }
}

/* Summary Tabs */
.summary-tabs-section {
    margin-bottom: 48px;
}

.summary-tab-content {
    display: none;
}

.summary-tab-content.active {
    display: block;
}

.chapters-section {
    margin-bottom: 48px;
    padding-bottom: 32px;
    border-bottom: none;
}

.chapters-section > h3 {
    margin: 16px 0 20px 0;
    color: var(--ink);
    font-family: var(--font-serif);
    font-size: 1.5rem;
    font-weight: 600;
}

/* "Plain English version coming soon" pill — shown on books that don't
   have a modern English translation yet. Toggled by app.js based on
   whether any chapter has modern_english_text. */
.plain-english-coming-soon {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 12px 0 0 0;
    padding: 6px 14px 6px 12px;
    background-color: var(--paper-deep);
    border: 1px solid var(--rule-strong);
    border-radius: 999px;
    color: var(--text-light);
    font-size: 0.9rem;
    line-height: 1.2;
    /* Single line on desktop; allow wrap on narrow viewports where the
       pill would otherwise overflow the (cover-sharing) info column. */
    white-space: nowrap;
    max-width: 100%;
}

/* On narrow viewports, the book-detail-info column shrinks (cover takes
   ~40% of the row), so the pill needs to wrap and behave like a rounded
   rectangle rather than a single-line stadium. */
@media (max-width: 600px) {
    .plain-english-coming-soon {
        white-space: normal;
        border-radius: 14px;
        padding: 6px 12px;
    }
}

.plain-english-coming-soon.hidden {
    display: none;
}

.plain-english-coming-soon-icon {
    font-size: 1rem;
    line-height: 1;
}

/* Related Books Section */
.related-books-section {
    margin-bottom: 48px;
    padding-top: 16px;
    border-top: 1px solid var(--border-light);
}

.related-books-section > h3 {
    margin: 16px 0 24px 0;
    color: var(--ink);
    font-family: var(--font-serif);
    font-size: 1.5rem;
    font-weight: 600;
}

.related-books-scroll {
    display: flex;
    gap: 0.75rem;
    overflow-x: auto;
    overflow-y: visible;
    scroll-behavior: smooth;
    padding: 1rem 1rem;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.related-books-scroll::-webkit-scrollbar {
    display: none;
}

@media (max-width: 768px) {
    .related-books-scroll {
        padding: 0.75rem 0.75rem;
    }
}

@media (max-width: 480px) {
    .related-books-scroll {
        padding: 0.5rem 0.5rem;
    }
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.section-header h3 {
    font-size: 1.5rem;
    color: var(--primary-color);
    font-weight: 600;
    margin: 0;
}

.section-header h4 {
    font-size: 1.2rem;
    color: var(--primary-color);
    font-weight: 600;
    margin: 0;
}

.tts-button-inline {
    background: transparent;
    color: var(--secondary-color);
    border: 1px solid var(--secondary-color);
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.tts-button-inline:hover {
    background: var(--secondary-color);
    color: white;
}

/* Summary Text */
.summary-text {
    /* font-size is set via JavaScript reading settings - default removed to allow inline styles to work */
    font-family: var(--font-serif);
    line-height: 1.75;
    color: var(--text-color);
}

.summary-text.preview {
    color: var(--text-color);
}

/* Concise Preview Container */
.concise-preview-container {
    position: relative;
    max-height: 300px;
    overflow: hidden;
    margin-bottom: 16px;
    transition: max-height 0.4s ease;
}

.concise-preview-container.expanded {
    max-height: none;
}

.concise-preview-text {
    position: relative;
}

.concise-preview-fade {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 120px;
    background: linear-gradient(to bottom, rgba(246,241,231,0), var(--paper));
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.concise-preview-fade.hidden {
    opacity: 0;
}

/* Medium Preview Container */
.medium-preview-container {
    position: relative;
    max-height: 300px;
    overflow: hidden;
    margin-bottom: 16px;
}

.medium-preview-text {
    position: relative;
}

.preview-fade {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 120px;
    background: linear-gradient(to bottom, rgba(246,241,231,0), var(--paper));
    pointer-events: none;
}

/* Chapters List */
.chapters-list {
    display: flex;
    flex-direction: column;
    border-top: 1px solid var(--rule);
}

/* Table-of-contents row: number · title · time · read check */
.chapter-box {
    display: grid;
    grid-template-columns: 2.25rem minmax(0, 1fr) auto 1.25rem;
    align-items: baseline;
    gap: 0 1rem;
    padding: 0.9rem 0.5rem;
    border-bottom: 1px solid var(--rule);
    color: var(--ink);
    text-decoration: none;
    transition: background 0.15s ease;
}

.chapter-box:hover {
    background: var(--paper-deep);
}

.chapter-box:hover .chapter-box-title {
    color: var(--accent);
}

.chapter-box:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

.chapter-box-num {
    color: var(--ink-muted);
    font-family: var(--font-serif);
    font-size: 1rem;
    text-align: right;
}

.chapter-box-title {
    margin: 0;
    color: var(--ink);
    font-family: var(--font-serif);
    font-size: 1.05rem;
    font-weight: 600;
}

.chapter-box-time {
    color: var(--ink-muted);
    font-size: 0.85rem;
    white-space: nowrap;
}

.chapter-box-check {
    visibility: hidden;
    color: var(--level-easy-fg);
    font-weight: 700;
}

.chapter-box.completed .chapter-box-check {
    visibility: visible;
}

@media (max-width: 480px) {
    .chapter-box {
        grid-template-columns: 1.6rem minmax(0, 1fr) auto;
        padding: 0.8rem 0.25rem;
    }

    .chapter-box-check {
        display: none;
    }

    .chapter-box.completed .chapter-box-num {
        color: var(--level-easy-fg);
    }
}

/* Section Headers (for two-level structure) */
.section-header {
    margin-top: 24px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--border-color);
}

.section-header:first-child {
    margin-top: 0;
}

.section-header h4 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--ink);
    font-family: var(--font-serif);
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Indented chapters (for two-level structure) */
.chapter-box.indented {
    margin-left: 20px;
}

/* Medium Detail Section */
.medium-detail-section {
    background: var(--card-background);
    width: 100vw;
    position: relative;
    left: 50%;
    right: 50%;
    margin-left: -50vw;
    margin-right: -50vw;
    padding: 0;
}

.medium-detail-section > * {
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
    padding-left: 20px;
    padding-right: 20px;
}

.medium-detail-section > *:first-child {
    padding-top: 16px;
}

.medium-detail-section > *:last-child {
    padding-bottom: 40px;
}

.medium-detail-header {
    margin-bottom: 32px;
}

.medium-detail-header h2 {
    font-size: 1.8rem;
    color: var(--primary-color);
    margin-bottom: 8px;
    line-height: 1.2;
}

.medium-detail-subtitle {
    font-size: 1rem;
    color: var(--text-light);
}

.medium-detail-content {
    margin-top: 24px;
}

/* Chapter Detail Section */
.chapter-detail-section {
    background: var(--card-background);
    width: 100vw;
    position: relative;
    left: 50%;
    right: 50%;
    margin-left: -50vw;
    margin-right: -50vw;
    padding: 51px 0 0 0; /* Top padding matches sticky header height exactly (51px) */
}

.chapter-detail-section > * {
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
    padding-left: 20px;
    padding-right: 20px;
}

.chapter-detail-section > *:first-child {
    padding-top: 0; /* No extra padding needed with pagination */
}

.chapter-detail-section > *:last-child {
    padding-bottom: 40px;
}

.chapter-detail-content {
    /* Content is already contained within chapter-detail-section which has edge-to-edge white background */
}

/* Chapter Illustration */
.chapter-illustration-container {
    margin: 16px 0;
    text-align: center;
}

.chapter-illustration {
    max-width: 100%;
    max-height: 600px;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Responsive illustration sizing */
@media (max-width: 768px) {
    .chapter-illustration {
        max-height: none;
        width: 100%;
    }

    .chapter-illustration-container {
        margin: 32px -20px;
        width: calc(100% + 40px);
    }
}

.chapter-summary-content {
    margin-top: 16px;
    padding-top: 0;
}

.chapter-fulltext-section {
    margin-top: 16px;
}

.chapter-fulltext {
    /* font-size is set via JavaScript reading settings - default removed to allow inline styles to work */
    line-height: 1.75;
    color: var(--text-color);
    margin-top: 0;
}

/* Markdown formatting in summaries */
.summary-text h1,
.summary-text h2,
.summary-text h3,
.summary-text h4,
.chapter-summary h1,
.chapter-summary h2,
.chapter-summary h3,
.chapter-summary h4,
.summary-content h1,
.summary-content h2,
.summary-content h3,
.summary-content h4 {
    color: var(--primary-color);
    margin-top: 1.5em;
    margin-bottom: 0.5em;
    font-weight: 600;
}

.summary-text h1,
.chapter-summary h1,
.summary-content h1 {
    font-size: 1.8rem;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0.3em;
}

.summary-text h2,
.chapter-summary h2,
.summary-content h2 {
    font-size: 1.5rem;
}

.summary-text h3,
.chapter-summary h3,
.summary-content h3 {
    font-size: 1.3rem;
}

.summary-text h4,
.chapter-summary h4,
.summary-content h4 {
    font-size: 1.15rem;
}

.summary-text p,
.chapter-summary p,
.summary-content p,
.chapter-fulltext p {
    margin-bottom: 1em;
}

.summary-text ul,
.summary-text ol,
.chapter-summary ul,
.chapter-summary ol,
.summary-content ul,
.summary-content ol {
    margin: 1em 0;
    padding-left: 2em;
}

.summary-text li,
.chapter-summary li,
.summary-content li {
    margin-bottom: 0.5em;
}

.summary-text strong,
.chapter-summary strong,
.summary-content strong {
    font-weight: 600;
    color: var(--primary-color);
}

.summary-text em,
.chapter-summary em,
.summary-content em {
    font-style: italic;
}

.summary-text blockquote,
.chapter-summary blockquote,
.summary-content blockquote {
    border-left: 4px solid var(--secondary-color);
    margin: 1.5em 0;
    padding: 0.5em 1em;
    background: var(--background-color);
    font-style: italic;
}

.summary-text code,
.chapter-summary code,
.summary-content code {
    background: var(--background-color);
    padding: 0.2em 0.4em;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

.summary-text pre,
.chapter-summary pre,
.summary-content pre {
    background: var(--background-color);
    padding: 1em;
    border-radius: 5px;
    overflow-x: auto;
    margin: 1em 0;
}

.summary-text pre code,
.chapter-summary pre code,
.summary-content pre code {
    background: none;
    padding: 0;
}

.summary-text hr,
.chapter-summary hr,
.summary-content hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 2em 0;
}

/* Comprehensive View */

.chapter-toggle.expanded {
    transform: rotate(180deg);
}

.chapter-content.expanded {
    max-height: none;
    overflow: visible;
}

.chapter-summary {
    /* font-size is set via JavaScript reading settings - default removed to allow inline styles to work */
    line-height: 1.8;
    color: var(--text-color);
    padding-top: 16px;
}

/* Footer */
.footer {
    text-align: center;
    padding: 32px 0;
    margin-top: 40px;
    margin-bottom: 100px; /* Space for persistent player */
    border-top: 1px solid var(--rule);
    color: var(--ink-muted);
}

.footer-tagline {
    font-family: var(--font-serif);
    color: var(--ink);
}

.footer-links {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px 20px;
    margin-top: 12px;
}

.footer-links a {
    color: var(--ink-muted);
    text-decoration: none;
}

.footer-links a:hover {
    color: var(--accent);
    text-decoration: underline;
}

.footer .small {
    font-size: 0.85rem;
    margin-top: 12px;
}

/* Wrong-account notice (auth.js's checkAuthStatus 403 handling) — shown
   only when signed in with a Google account not on SUMMRA_ALLOWED_EMAILS.
   Amber/warning-toned, distinct from a plain signed-out visitor who never
   sees this at all. */
.wrong-account-banner {
    text-align: center;
    padding: 10px 24px;
    font-size: 0.85rem;
    background: var(--error-bg-light);
    color: var(--text-color);
    border-bottom: 1px solid var(--border-color);
}

/* Deliberately quiet — a way back in, not an invitation. No icon, no
   "with Google", small and faint. Matches OpenReader's sidebar treatment. */
.footer-signin {
    display: inline-block;
    margin-top: 12px;
    font-size: 0.75rem;
    color: var(--text-light);
    text-decoration: none;
    opacity: 0.6;
}

.footer-signin:hover {
    text-decoration: underline;
    opacity: 1;
}

/* Persistent Audio Player */

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

/* Full-Length View */

/* Summary Section */
.summary-section {
    margin-bottom: 16px;
    padding: 0px 16px 0px 16px;
}

/* Add padding and margin when expanded */
.summary-section:has(.summary-content:not(.collapsed)) .summary-section-header {
    margin-bottom: 12px;
}

.summary-content {
    font-size: 1.1rem;
    line-height: 1.8;
    color: var(--text-color);
    max-height: none;
    overflow: visible;
    transition: max-height 0.3s ease, padding 0.3s ease;
}

.summary-content.collapsed {
    max-height: 0;
    overflow: hidden;
    padding: 0;
}

/* Full Text Section */

/* Responsive Design */
@media (max-width: 768px) {
    .header-content {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .header-nav-buttons {
        flex-shrink: 0;
        white-space: nowrap;
    }

    .logo {
        font-size: 1.3rem;
    }

    .logo-icon {
        height: 30px;
    }

    .option-cards {
        grid-template-columns: 1fr;
    }

    .summary-content {
        padding: 20px;
    }

    .book-info h2 {
        font-size: 1.5rem;
    }

    /* Edge-to-edge white background is already applied via main section styles */
    .summary-section > *,
    .medium-detail-section > *,
    .chapter-detail-section > * {
        padding-left: 16px;
        padding-right: 16px;
    }

    /* Reduce margins between sections */
    .concise-summary-section,
    .medium-preview-section,
    .chapters-section {
        margin-bottom: 32px;
        padding-bottom: 24px;
    }

    /* Persistent player mobile layout */
    

    

    

    
}

/* ===== Hero Banners (Apple-style) ===== */

/* Fallback for browsers that don't support WebP */

/* Discover Hero */

/* Learn Hero */

/* Learn Features Grid - 3 Column Layout */

/* Responsive - Stack on mobile */

/* Read Hero */

/* Top 10 Carousel in Discover Section */

/* When viewport is smaller than carousel + buttons, switch to left-aligned mode */

/* Skeleton loading card for carousel */

/* Shimmer animation */
@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

/* Fade in animation when real books load */

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mobile responsive */

@media (max-width: 480px) {

    .hero-banner-ctas {
        margin-top: 1.5rem;
    }
}

.hero-banner-ctas {
    display: flex;
    gap: 1rem;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 2rem;
}

.hero-cta-primary {
    background: var(--accent);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 980px;
    font-size: 1.0625rem;
    font-weight: 400;
    text-decoration: none;
    transition: background 0.2s ease;
    display: inline-block;
}

.hero-cta-primary:hover {
    background: var(--accent-hover);
}

.hero-cta-secondary {
    background: transparent;
    color: var(--hero-accent);
    padding: 0.75rem 1.5rem;
    border-radius: 980px;
    font-size: 1.0625rem;
    font-weight: 400;
    text-decoration: none;
    transition: background 0.2s ease;
    display: inline-block;
    border: 2px solid var(--hero-accent);
}

.hero-cta-secondary:hover {
    background: var(--paper-deep);
}

/* Hero Search Bar */
.hero-search-container {
    margin-top: 2rem;
    display: flex;
    justify-content: center;
}

.hero-search-wrapper {
    position: relative;
    width: 100%;
    max-width: 600px;
}

.hero-search-input {
    width: 100%;
    padding: 0.85rem 1.25rem;
    font: inherit;
    font-size: 1.05rem;
    border: 1px solid var(--rule-strong);
    border-radius: 999px;
    background: var(--surface);
    color: var(--ink);
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.hero-search-input:focus {
    border-color: var(--ink-muted);
    box-shadow: 0 0 0 3px rgba(138, 46, 46, 0.12);
}

.hero-search-input::placeholder {
    color: var(--ink-muted);
}

.hero-search-results {
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 0;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: 10px;
    box-shadow: 0 10px 28px rgba(43, 38, 34, 0.16);
    max-height: 340px;
    overflow-y: auto;
    z-index: 1000;
}

.hero-search-results.hidden {
    display: none;
}

.hero-search-result-item {
    padding: 0.7rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid var(--rule);
    transition: background 0.2s ease;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.hero-search-result-item:last-child {
    border-bottom: none;
}

.hero-search-result-item:hover {
    background: var(--paper-deep);
}

.hero-search-result-cover {
    width: 40px;
    height: 60px;
    object-fit: cover;
    border-radius: 4px;
    flex-shrink: 0;
}

.hero-search-result-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    min-width: 0;
    text-align: left;
}

.hero-search-result-title {
    font-family: var(--font-serif);
    font-size: 1rem;
    font-weight: 600;
    color: var(--ink);
    margin: 0;
}

.hero-search-result-author {
    font-size: 0.875rem;
    color: var(--text-light);
    margin: 0;
}

.hero-search-result-author::before {
    content: "by ";
    font-style: italic;
}

.hero-search-no-results {
    padding: 2rem;
    text-align: center;
    color: var(--text-light);
    font-size: 1rem;
}

@media (max-width: 768px) {
    .hero-search-input {
        font-size: 1rem;
        padding: 0.875rem 1.25rem;
    }

    .hero-search-wrapper {
        max-width: 90%;
    }

    .hero-search-results {
        max-height: 155px; /* Show exactly 3 results on mobile without showing partial 4th item */
    }

    .hero-search-result-item {
        padding: 0.75rem 1rem;
    }

    .hero-search-result-cover {
        width: 32px;
        height: 48px;
    }

    .hero-search-result-title {
        font-size: 0.9rem;
    }

    .hero-search-result-author {
        font-size: 0.8rem;
    }
}

/* ===== Category Carousels ===== */
.categories-section {
    margin-bottom: 1rem;
    margin-top: 2.5rem;  /* More space after blue header */
}

.categories-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;  /* Less gap between carousels */
}

.category-carousel {
    margin-bottom: 0;
}

.category-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    padding: 0;
}

.category-title {
    font-family: var(--font-serif);
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--primary-color);
    margin: 0;
}

.view-all-link {
    color: var(--secondary-color);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    transition: color 0.2s;
}

.view-all-link:hover {
    color: var(--secondary-color-hover);
    text-decoration: underline;
}

.carousel-container {
    position: relative;
    width: 100%;
}

.carousel-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: white;
    border: 1px solid var(--border-subtle);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: all 0.2s;
}

.carousel-nav-btn:hover {
    background: #f7f7f7;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.carousel-nav-btn.left {
    left: -20px;
}

.carousel-nav-btn.right {
    right: -20px;
}

.carousel-nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.carousel-scroll {
    display: flex;
    gap: 0.75rem;  /* Less gap between books */
    overflow-x: auto;  /* Allow horizontal scrolling */
    overflow-y: visible;  /* Allow vertical overflow for scaled cards */
    scroll-behavior: smooth;
    padding: 1rem 1rem;  /* Add padding to prevent clipping on all sides */
    scrollbar-width: none;  /* Firefox - hide scrollbar */
    -ms-overflow-style: none;  /* IE/Edge - hide scrollbar */
}

.carousel-scroll::-webkit-scrollbar {
    display: none;  /* Chrome/Safari - hide scrollbar */
}

/* Responsive carousel styling */
@media (max-width: 768px) {
    /* Hero Banners Responsive */

    .hero-banner-ctas {
        gap: 0.75rem;
        margin-top: 1.5rem;
    }

    .hero-cta-primary,
    .hero-cta-secondary {
        padding: 0.625rem 1.25rem;
        font-size: 1rem;
    }

    .category-title {
        font-size: 1.25rem;
    }

    .section-title {
        font-size: 1.5rem;
    }

    .carousel-scroll {
        padding: 0.75rem 0.75rem;  /* Reduce padding on tablet: 12px */
    }

    .categories-container {
        gap: 0.75rem;  /* Reduce gap between carousels */
    }

    .categories-section {
        margin-top: 1.25rem;  /* Reduce space after blue header */
    }

    .category-header {
        margin-bottom: 0.5rem;  /* Reduce gap between header and carousel */
    }
}

@media (max-width: 480px) {
    .category-title {
        font-size: 1.1rem;
    }

    .section-title {
        font-size: 1.3rem;
    }

    .carousel-scroll {
        padding: 0.25rem 0.5rem 0.5rem 0.5rem;  /* Reduce top padding on mobile: 4px top, 8px bottom/sides */
    }

    .categories-container {
        gap: 0.25rem;  /* 4px gap between carousels */
    }

    .categories-section {
        margin-top: 0.5rem;  /* 8px space after blue header */
    }

    .category-header {
        margin-bottom: 0;  /* 0px gap between header and carousel */
    }
}

/* ===== Reading Experience Enhancements ===== */

/* Reading Settings Toggle Button */
.back-button-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.reading-settings-toggle {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-color);
    border-radius: 8px;
    padding: 8px 16px;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s;
}

.reading-settings-toggle:hover {
    background: var(--background-color);
    border-color: var(--secondary-color);
}

/* Reading Progress Bar - Kindle Style */
.reading-progress-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 24px;
    background: transparent;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    z-index: 999;
    pointer-events: none;
}

.reading-progress-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 3px;
    background: rgba(0, 0, 0, 0.3);
    transition: width 0.2s ease;
    width: 0%;
}

.reading-progress-text {
    font-size: 0.9rem;
    color: rgba(0, 0, 0, 0.5);
    font-weight: 400;
    text-align: center;
    margin-top: 5px;
}

/* Progress bar colors for different themes */
.chapter-detail-section[data-theme="dark"] .reading-progress-fill {
    background: rgba(255, 255, 255, 0.3);
}

.chapter-detail-section[data-theme="dark"] .reading-progress-text {
    color: rgba(255, 255, 255, 0.5);
}

.chapter-detail-section[data-theme="sepia"] .reading-progress-fill {
    background: rgba(92, 79, 61, 0.3);
}

.chapter-detail-section[data-theme="sepia"] .reading-progress-text {
    color: rgba(92, 79, 61, 0.5);
}

/* Next Chapter Button */

/* Reading Settings Panel */
.reading-settings-panel {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    width: 360px;
    max-width: 90vw;
    background: var(--surface);
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);
    z-index: 1001;
    overflow-y: auto;
    transform: translateX(100%);
    transition: transform 0.3s ease;
}

.reading-settings-panel:not(.hidden) {
    transform: translateX(0);
}

.reading-settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    background: var(--background-color);
}

.reading-settings-header h3 {
    font-size: 1.3rem;
    color: var(--primary-color);
    margin: 0;
}

.reading-settings-close {
    background: transparent;
    border: none;
    color: var(--text-light);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 4px 8px;
    transition: color 0.2s;
}

.reading-settings-close:hover {
    color: var(--primary-color);
}

.reading-settings-section {
    padding: 24px 20px;
    border-bottom: 1px solid var(--border-color);
}

.reading-settings-section:last-child {
    border-bottom: none;
}

.reading-settings-section h4 {
    font-size: 1rem;
    color: var(--primary-color);
    margin: 0 0 16px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

/* Font Selection */
.font-choices {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 8px;
}

.font-choice {
    background: var(--surface);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
    font-size: 2rem;
    cursor: pointer;
    transition: all 0.2s;
}

.font-choice:hover {
    border-color: var(--secondary-color);
    background: rgba(138, 46, 46, 0.05);
}

.font-choice.active {
    border-color: var(--secondary-color);
    background: rgba(138, 46, 46, 0.08);
}

.font-choice[data-font="georgia"] {
    font-family: var(--reading-font-serif);
}

.font-choice[data-font="system"] {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

.font-choice[data-font="opensans"] {
    font-family: 'Open Sans', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

.font-labels {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    text-align: center;
}

.font-labels span {
    font-size: 0.85rem;
    color: var(--text-light);
}

/* Text Size Control */
.size-control {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.size-btn {
    background: var(--surface);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 44px;
}

.size-btn:hover {
    border-color: var(--secondary-color);
    background: rgba(138, 46, 46, 0.05);
}

.size-slider-container {
    flex: 1;
}

.size-slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--border-color);
    outline: none;
    -webkit-appearance: none;
}

.size-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--secondary-color);
    cursor: pointer;
}

.size-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--secondary-color);
    cursor: pointer;
    border: none;
}

.size-value {
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-light);
    font-weight: 600;
}

/* Theme Selection */
.theme-choices {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.theme-choice {
    background: var(--surface);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.theme-choice:hover {
    border-color: var(--secondary-color);
    background: rgba(138, 46, 46, 0.05);
}

.theme-choice.active {
    border-color: var(--secondary-color);
    background: rgba(138, 46, 46, 0.08);
}

.theme-preview {
    width: 100%;
    height: 60px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.theme-preview-light {
    background: white;
}

.theme-preview-dark {
    background: var(--reading-theme-dark-bg);
}

.theme-preview-sepia {
    background: var(--reading-theme-sepia-bg);
}

.theme-choice span {
    font-size: 0.85rem;
    color: var(--text-light);
    font-weight: 600;
}

/* Chapter Reading Themes */
.chapter-detail-section[data-theme="light"] {
    background: white;
    color: #2c3e50;
}

/* When chapter section is active with light theme, set body background */
body:has(.chapter-detail-section[data-theme="light"]:not(.hidden)) {
    background: white;
}

.chapter-detail-section[data-theme="dark"] {
    background: var(--reading-theme-dark-bg);
    color: var(--reading-theme-dark-text);
}

/* When chapter section is active with dark theme, set body background */
body:has(.chapter-detail-section[data-theme="dark"]:not(.hidden)) {
    background: var(--reading-theme-dark-bg);
}

.chapter-detail-section[data-theme="dark"] .chapter-fulltext p,
.chapter-detail-section[data-theme="dark"] .chapter-summary-text,
.chapter-detail-section[data-theme="dark"] h2,
.chapter-detail-section[data-theme="dark"] h4 {
    color: var(--reading-theme-dark-text);
}

.chapter-detail-section[data-theme="dark"] .chapter-summary-box {
    background: #2a2a2a;
    border-left-color: #ffc107;
}

.chapter-detail-section[data-theme="dark"] .back-button {
    color: var(--reading-theme-dark-accent);
}

.chapter-detail-section[data-theme="dark"] .next-chapter-btn {
    color: var(--reading-theme-dark-text);
    border-color: var(--reading-theme-dark-border);
}

.chapter-detail-section[data-theme="dark"] .next-chapter-btn:hover {
    border-color: var(--reading-theme-dark-accent);
    color: var(--reading-theme-dark-accent);
    background: rgba(92, 179, 224, 0.1);
}

.chapter-detail-section[data-theme="sepia"] {
    background: var(--reading-theme-sepia-bg);
    color: var(--reading-theme-sepia-text);
}

/* When chapter section is active with sepia theme, set body background */
body:has(.chapter-detail-section[data-theme="sepia"]:not(.hidden)) {
    background: var(--reading-theme-sepia-bg);
}

.chapter-detail-section[data-theme="sepia"] .chapter-fulltext p,
.chapter-detail-section[data-theme="sepia"] .chapter-summary-text,
.chapter-detail-section[data-theme="sepia"] h2,
.chapter-detail-section[data-theme="sepia"] h4 {
    color: var(--reading-theme-sepia-text);
}

.chapter-detail-section[data-theme="sepia"] .chapter-summary-box {
    background: #e8dcc4;
    border-left-color: #d4a574;
}

.chapter-detail-section[data-theme="sepia"] .next-chapter-btn {
    color: var(--reading-theme-sepia-text);
    border-color: #d4c5a9;
}

.chapter-detail-section[data-theme="sepia"] .next-chapter-btn:hover {
    border-color: #a88f5a;
    color: #4a3f2f;
    background: rgba(168, 143, 90, 0.1);
}

/* Medium Detail Reading Themes */
.medium-detail-section[data-theme="light"] {
    background: white;
    color: #2c3e50;
}

/* When medium section is active with light theme, set body background */
body:has(.medium-detail-section[data-theme="light"]:not(.hidden)) {
    background: white;
}

.medium-detail-section[data-theme="dark"] {
    background: var(--reading-theme-dark-bg);
    color: var(--reading-theme-dark-text);
}

/* When medium section is active with dark theme, set body background */
body:has(.medium-detail-section[data-theme="dark"]:not(.hidden)) {
    background: var(--reading-theme-dark-bg);
}

.medium-detail-section[data-theme="dark"] .summary-text,
.medium-detail-section[data-theme="dark"] h2,
.medium-detail-section[data-theme="dark"] h3,
.medium-detail-section[data-theme="dark"] h4 {
    color: var(--reading-theme-dark-text);
}

.medium-detail-section[data-theme="dark"] .back-button {
    color: var(--reading-theme-dark-accent);
}

.medium-detail-section[data-theme="sepia"] {
    background: var(--reading-theme-sepia-bg);
    color: var(--reading-theme-sepia-text);
}

/* When medium section is active with sepia theme, set body background */
body:has(.medium-detail-section[data-theme="sepia"]:not(.hidden)) {
    background: var(--reading-theme-sepia-bg);
}

.medium-detail-section[data-theme="sepia"] .summary-text,
.medium-detail-section[data-theme="sepia"] h2,
.medium-detail-section[data-theme="sepia"] h3,
.medium-detail-section[data-theme="sepia"] h4 {
    color: var(--reading-theme-sepia-text);
}

/* Sticky Reading Header */
.sticky-reading-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: #000000 !important;
    border-bottom: 1px solid var(--sticky-header-accent);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
    transition: transform 0.3s ease;
    pointer-events: none;
    height: 51px; /* Fixed height: 34px content + 8px top padding + 8px bottom padding + 1px border = 51px */
    box-sizing: border-box; /* Include border in height */
}

.sticky-reading-header:not(.hidden) {
    pointer-events: auto;
}

.sticky-reading-header.hidden {
    transform: translateY(-100%);
    visibility: hidden;
}

.sticky-header-content {
    max-width: 100%;
    margin: 0;
    padding: 8px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    height: 34px; /* Fixed height: prevents layout shift during chapter transitions */
    box-sizing: content-box; /* Padding is added to height, total = 34px + 8px + 8px = 50px */
}

/* Three-column layout for sticky header */
.sticky-header-left {
    flex: 1 1 0;
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    overflow: hidden;
}

.sticky-header-center {
    flex: 0 0 auto;
    display: flex;
    justify-content: center;
    align-items: center;
}

.sticky-header-right {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Sticky header buttons */
.sticky-back-btn {
    background: var(--sticky-header-accent);
    border: 1px solid var(--sticky-header-border);
    color: var(--card-background) !important;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.sticky-back-btn:hover {
    background: var(--sticky-header-active);
    border-color: var(--sticky-header-muted);
}

.sticky-chapter-title {
    color: var(--card-background);
    font-size: 0.9rem;
    font-weight: 400;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    flex: 1 1 0;
}

/* Unified view toggle (Summary/Original/Modern/Side×Side) */
.unified-view-toggle {
    display: flex;
    gap: 0;
    background: #1a1a1a;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--sticky-header-border);
}

.unified-view-btn {
    background: transparent;
    border: none;
    color: var(--sticky-header-muted);
    padding: 6px 14px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    border-right: 1px solid var(--sticky-header-border);
}

.unified-view-btn:last-child {
    border-right: none;
}

.unified-view-btn:hover {
    background: var(--sticky-header-accent);
}

.unified-view-btn.active {
    background: var(--sticky-header-active);
    color: var(--card-background);
}

/* TTS and settings buttons */
.sticky-tts-btn,
.sticky-settings-btn {
    background: transparent;
    border: 1px solid var(--sticky-header-border);
    color: var(--card-background) !important;
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
}

.sticky-tts-btn:hover,
.sticky-settings-btn:hover {
    background: var(--sticky-header-accent);
    border-color: var(--sticky-header-muted);
}

/* Font Family Application - includes summary text, modern English, and side-by-side */
.chapter-detail-section[data-font="georgia"] .chapter-fulltext,
.chapter-detail-section[data-font="georgia"] .chapter-modern-english,
.chapter-detail-section[data-font="georgia"] .side-by-side-cell,
.chapter-detail-section[data-font="georgia"] .chapter-summary-text,
.chapter-detail-section[data-font="georgia"] .summary-text,
.medium-detail-section[data-font="georgia"] .summary-text {
    font-family: var(--reading-font-serif);
    font-optical-sizing: auto;
}

.chapter-detail-section[data-font="system"] .chapter-fulltext,
.chapter-detail-section[data-font="system"] .chapter-modern-english,
.chapter-detail-section[data-font="system"] .side-by-side-cell,
.chapter-detail-section[data-font="system"] .chapter-summary-text,
.chapter-detail-section[data-font="system"] .summary-text,
.medium-detail-section[data-font="system"] .summary-text {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

.chapter-detail-section[data-font="opensans"] .chapter-fulltext,
.chapter-detail-section[data-font="opensans"] .chapter-modern-english,
.chapter-detail-section[data-font="opensans"] .side-by-side-cell,
.chapter-detail-section[data-font="opensans"] .chapter-summary-text,
.chapter-detail-section[data-font="opensans"] .summary-text,
.medium-detail-section[data-font="opensans"] .summary-text {
    font-family: 'Open Sans', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* Font family for pagination containers */
.pagination-page-container[data-font="georgia"],
.pagination-page-container[data-font="georgia"] .side-by-side-cell,
.pagination-page-container[data-font="georgia"] p {
    font-family: var(--reading-font-serif);
    font-optical-sizing: auto;
}

.pagination-page-container[data-font="system"],
.pagination-page-container[data-font="system"] .side-by-side-cell,
.pagination-page-container[data-font="system"] p {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

.pagination-page-container[data-font="opensans"],
.pagination-page-container[data-font="opensans"] .side-by-side-cell,
.pagination-page-container[data-font="opensans"] p {
    font-family: 'Open Sans', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

@media (max-width: 768px) {
    .reading-settings-panel {
        width: 100%;
        max-width: 100%;
    }

    .reading-progress-bar {
        height: 32px;
    }

    .next-chapter-container {
        margin-bottom: 60px;
    }
}

/* ===================================
   Image Lightbox Overlay
   =================================== */

/* Lightbox overlay - full screen dark background */
.lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.95);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.lightbox-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

/* Close button - top right corner */
.lightbox-close {
    position: absolute;
    top: 24px;
    right: 24px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    font-size: 2rem;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 10001;
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
    transform: scale(1.1);
}

/* Lightbox image - centered and scaled */
.lightbox-image {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    cursor: default;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

/* Make illustration clickable (pointer cursor) */
.chapter-illustration {
    cursor: pointer;
    transition: opacity 0.3s ease-in;
}

.chapter-illustration:hover {
    opacity: 0.9 !important; /* Override when loaded */
}

.chapter-illustration-container {
    position: relative;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .lightbox-close {
        top: 16px;
        right: 16px;
        width: 44px;
        height: 44px;
        font-size: 1.5rem;
    }

    .lightbox-image {
        max-width: 95vw;
        max-height: 95vh;
    }
}

/* ===== Author Page Styles ===== */

#author-detail-section {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

.author-header {
    text-align: center;
    margin-bottom: 3rem;
    padding-bottom: 2rem;
    border-bottom: 2px solid var(--border-color);
}

.author-header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    color: var(--text-color);
}

.author-country {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

.author-bio-section,
.author-books-section,
.author-other-books-section {
    margin-bottom: 3rem;
}

.author-bio-section h2,
.author-books-section h2,
.author-other-books-section h2 {
    font-size: 1.75rem;
    margin-bottom: 1rem;
    color: var(--text-color);
}

.author-books-section h2 .count {
    color: var(--text-secondary);
    font-size: 1.25rem;
    font-weight: normal;
}

.author-long-bio {
    line-height: 1.8;
    color: var(--text-color);
}

.author-long-bio p {
    margin-bottom: 1rem;
}

/* Books carousel on author page */
.books-carousel {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 2rem;
    margin-top: 1.5rem;
}

/* Other books grid (non-platform books) */
.other-books-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 2rem;
    margin-top: 1.5rem;
}

.other-books-column ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.other-books-column li {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-color);
    position: relative;
    padding-left: 1.5rem;
}

.other-books-column li:before {
    content: "📚";
    position: absolute;
    left: 0;
    top: 0.75rem;
}

.other-books-column li:last-child {
    border-bottom: none;
}

/* Author link styling */
.author-link {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.2s ease;
}

.author-link:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .author-header h1 {
        font-size: 2rem;
    }

    .other-books-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .books-carousel {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 1rem;
    }
}

/* ===========================
   Discover Page
   =========================== */

#discover-section {
    padding-top: 20px;
    animation: fadeIn 0.3s ease;
}

.discover-header {
    max-width: 640px;
    margin-bottom: 1.5rem;
}

.discover-header h2 {
    margin-bottom: 0.4rem;
    color: var(--ink);
    font-family: var(--font-serif);
    font-size: clamp(1.75rem, 4vw, 2.4rem);
    line-height: 1.15;
}

.discover-header p {
    color: var(--ink-muted);
    font-size: 1.02rem;
}

.discover-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 2rem;
    padding: 1rem 0;
    border-top: 1px solid var(--rule);
    border-bottom: 1px solid var(--rule);
}

.discover-filter,
.discover-sort {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
}

.discover-filter-label {
    margin-right: 0.25rem;
    color: var(--ink-muted);
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.filter-chip {
    padding: 0.35rem 0.85rem;
    border: 1px solid var(--rule-strong);
    border-radius: 999px;
    background: transparent;
    color: var(--ink);
    font: inherit;
    font-size: 0.88rem;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.filter-chip:hover {
    border-color: var(--ink-muted);
}

.filter-chip[aria-pressed="true"] {
    border-color: var(--ink);
    background: var(--ink);
    color: var(--paper);
}

.filter-chip:focus-visible,
.discover-sort select:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.discover-sort {
    margin-left: auto;
}

.discover-sort select {
    padding: 0.35rem 0.6rem;
    border: 1px solid var(--rule-strong);
    border-radius: 6px;
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-size: 0.88rem;
}

.discover-count {
    margin: 1rem 0 1.25rem;
    color: var(--ink-muted);
    font-size: 0.9rem;
}

.discover-empty {
    padding: 3rem 0;
    color: var(--ink-muted);
    text-align: center;
}

.discover-empty button {
    margin-left: 0.5rem;
    padding: 0.4rem 0.9rem;
}

/* Filtering: the grid carries the active filters; non-matching cards hide.
   Works on the server-rendered page before any JS runs. */
.discover-grid[data-filter-level="easy"] > .book-card:not([data-level="easy"]),
.discover-grid[data-filter-level="moderate"] > .book-card:not([data-level="moderate"]),
.discover-grid[data-filter-level="challenging"] > .book-card:not([data-level="challenging"]),
.discover-grid[data-filter-length="short"] > .book-card:not([data-length="short"]),
.discover-grid[data-filter-length="medium"] > .book-card:not([data-length="medium"]),
.discover-grid[data-filter-length="long"] > .book-card:not([data-length="long"]) {
    display: none;
}

@media (max-width: 600px) {
    .discover-controls {
        flex-direction: column;
        align-items: flex-start;
    }

    .discover-filter .discover-filter-label {
        flex-basis: 100%;
    }

    .discover-sort {
        margin-left: 0;
    }
}

@media (max-width: 768px) {
    #discover-section {
        padding-top: 16px;
    }
}

@media (max-width: 480px) {
    #discover-section {
        padding-top: 12px;
    }
}

/* ===========================
   Modern English Side-by-Side View
   =========================== */

/* View Mode Toggle */

.view-mode-btn.active {
    background: var(--primary-color);
    color: white;
}

/* Header Controls Flexbox */

/* Modern English Text (single view) */
.chapter-modern-english {
    /* font-size is set via JavaScript reading settings - default removed to allow inline styles to work */
    line-height: 1.75;
    color: var(--text-color);
    margin-top: 16px;
}

.chapter-modern-english p {
    margin-bottom: 1em;
}

/* Side-by-Side Container */
.chapter-side-by-side {
    display: flex;
    flex-direction: column;
    gap: 0;
    max-width: 1400px;
    margin: 0 auto;
}

/* Side-by-Side Headers */
.side-by-side-headers {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #e8e8e8;
}

.side-by-side-header {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-light);
    text-align: left;
}

.side-by-side-header:first-child {
    padding-right: 1rem;
}

.side-by-side-header:last-child {
    padding-left: 1rem;
}

.side-by-side-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    align-items: start;
    margin-bottom: 0;
}

.side-by-side-cell {
    min-width: 0; /* Prevent overflow */
    /* font-size is set via JavaScript reading settings - default removed to allow inline styles to work */
    line-height: 1.75;
    color: var(--text-color);
}

.side-by-side-cell p {
    margin-bottom: 1.5em;
}

/* Add visual separation with subtle background for original text */
.side-by-side-cell.original {
    padding-right: 1rem;
    border-right: 1px solid var(--border-light);
}

.side-by-side-cell.modern {
    padding-left: 1rem;
}

/* Mobile Responsiveness */
@media (max-width: 1024px) {
    .side-by-side-headers {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    .side-by-side-header:first-child {
        padding-right: 0;
        padding-bottom: 0.5rem;
    }

    .side-by-side-header:last-child {
        padding-left: 0;
        padding-top: 0.5rem;
    }

    .side-by-side-row {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .side-by-side-cell.original {
        border-right: none;
        border-bottom: 2px solid var(--border-light);
        padding-right: 0;
        padding-bottom: 1rem;
    }

    .side-by-side-cell.modern {
        padding-left: 0;
        padding-top: 1rem;
    }
}

@media (max-width: 768px) {
    .view-mode-toggle {
        flex-wrap: wrap;
        gap: 0.25rem;
    }

    .view-mode-btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.85rem;
    }

    .header-controls {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .side-by-side-cell p {
        font-size: 1rem;
    }
}

/* ===========================
   Admin Features (Development Only)
   =========================== */

/* Admin Edit Button */

/* Update chapter header to flex layout */

/* Admin Modal */
.admin-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.admin-modal.hidden {
    opacity: 0;
    pointer-events: none;
}

.admin-modal-content {
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    width: 90%;
    max-width: 900px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.admin-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-light);
    background: var(--admin-modal-bg);
}

.admin-modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--primary-color);
}

.admin-modal-close {
    background: transparent;
    border: none;
    font-size: 2rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.admin-modal-close:hover {
    color: var(--text-dark);
}

.admin-modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.admin-form-group {
    margin-bottom: 20px;
}

.admin-form-group:last-child {
    margin-bottom: 0;
}

.admin-form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--primary-color);
    font-size: 0.95rem;
}

.admin-textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border-light);
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: 'Courier New', monospace;
    line-height: 1.6;
    resize: vertical;
    transition: border-color 0.2s;
}

.admin-textarea:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(138, 46, 46, 0.08);
}

.admin-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 20px 24px;
    border-top: 1px solid var(--border-light);
    background: var(--admin-modal-bg);
}

.admin-btn-primary,
.admin-btn-secondary {
    padding: 10px 24px;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.admin-btn-primary {
    background: #4caf50;
    color: white;
}

.admin-btn-primary:hover {
    background: #45a049;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(76, 175, 80, 0.3);
}

.admin-btn-secondary {
    background: #e0e0e0;
    color: var(--text-dark);
}

.admin-btn-secondary:hover {
    background: #d5d5d5;
}

@media (max-width: 768px) {
    .admin-modal-content {
        width: 95%;
        max-height: 95vh;
    }

    .admin-modal-header,
    .admin-modal-body,
    .admin-modal-footer {
        padding: 16px;
    }

    .admin-textarea {
        font-size: 0.9rem;
    }
}

/* ===== Blog Styles ===== */

.blog-index-section,
.blog-post-section {
    padding: 20px 0;
}

.blog-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 30px;
    margin-top: 30px;
}

.blog-card {
    background: var(--card-bg);
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.blog-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
}

.blog-card-image {
    width: 100%;
    height: 200px;
    overflow: hidden;
}

.blog-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.blog-card:hover .blog-card-image img {
    transform: scale(1.05);
}

.blog-card-content {
    padding: 30px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.blog-card-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--text-primary);
    line-height: 1.3;
}

.blog-card-date {
    font-size: 0.9rem;
    color: var(--text-light);
    margin-bottom: 15px;
}

.blog-card-excerpt {
    font-size: 1rem;
    line-height: 1.6;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.blog-card-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    font-size: 1rem;
    transition: color 0.2s ease;
}

.blog-card-link:hover {
    color: var(--primary-dark);
}

.blog-post {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

.blog-post-header-image {
    width: 100%;
    max-height: 400px;
    overflow: hidden;
    border-radius: 12px;
    margin-bottom: 30px;
}

.blog-post-header-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.blog-post-header {
    margin-bottom: 40px;
}

.blog-back-link {
    display: inline-block;
    color: var(--primary-color);
    text-decoration: none;
    margin-bottom: 20px;
    font-size: 1rem;
    transition: color 0.2s ease;
}

.blog-back-link:hover {
    color: var(--primary-dark);
}

.blog-post-title {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 15px;
    line-height: 1.2;
    color: var(--text-primary);
}

.blog-post-meta {
    display: flex;
    gap: 20px;
    font-size: 0.95rem;
    color: var(--text-light);
}

.blog-post-author {
    font-weight: 500;
}

.blog-post-content {
    font-size: 1.1rem;
    line-height: 1.8;
    color: var(--text-secondary);
}

.blog-post-content h1,
.blog-post-content h2,
.blog-post-content h3,
.blog-post-content h4 {
    margin-top: 40px;
    margin-bottom: 20px;
    color: var(--text-primary);
}

.blog-post-content h2 {
    font-size: 2rem;
    font-weight: 600;
}

.blog-post-content h3 {
    font-size: 1.6rem;
    font-weight: 600;
}

.blog-post-content p {
    margin-bottom: 20px;
}

.blog-post-content ul,
.blog-post-content ol {
    margin-left: 30px;
    margin-bottom: 20px;
}

.blog-post-content li {
    margin-bottom: 10px;
}

.blog-post-content a {
    color: var(--primary-color);
    text-decoration: underline;
}

.blog-post-content a:hover {
    color: var(--primary-dark);
}

.blog-post-content strong {
    font-weight: 600;
}

.blog-post-content code {
    background: rgba(0, 0, 0, 0.05);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.95em;
}

.blog-post-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 30px 0;
}

.blog-post-content th,
.blog-post-content td {
    border: 1px solid var(--border-color);
    padding: 12px;
    text-align: left;
}

.blog-post-content th {
    background: rgba(0, 0, 0, 0.05);
    font-weight: 600;
}

.blog-empty,
.blog-error {
    text-align: center;
    padding: 60px 20px;
}

.blog-empty h2,
.blog-error h2 {
    font-size: 2rem;
    margin-bottom: 15px;
    color: var(--text-primary);
}

.blog-empty p,
.blog-error p {
    font-size: 1.1rem;
    color: var(--text-secondary);
}

@media (max-width: 768px) {
    .blog-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .blog-card {
        padding: 20px;
    }

    .blog-post-title {
        font-size: 1.8rem;
    }

    .blog-post-content {
        font-size: 1rem;
    }

    .blog-post-content h2 {
        font-size: 1.6rem;
    }

    .blog-post-content h3 {
        font-size: 1.3rem;
    }
}

/* iOS Install Banner */
.ios-install-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, var(--cta-gradient-start) 0%, var(--cta-gradient-end) 100%);
    color: white;
    padding: 16px 20px;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

.ios-banner-content {
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: 1200px;
    margin: 0 auto;
}

.ios-banner-icon {
    font-size: 32px;
    flex-shrink: 0;
}

.ios-banner-text {
    flex: 1;
    min-width: 0;
}

.ios-banner-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 4px;
}

.ios-banner-subtitle {
    font-size: 13px;
    opacity: 0.95;
    display: flex;
    align-items: center;
    gap: 4px;
}

.ios-share-icon {
    width: 16px;
    height: 16px;
    display: inline-block;
    vertical-align: middle;
}

.ios-banner-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 20px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.ios-banner-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.ios-banner-close:active {
    background: rgba(255, 255, 255, 0.4);
}

@media (max-width: 768px) {
    .ios-install-banner {
        padding: 12px 16px;
    }

    .ios-banner-icon {
        font-size: 28px;
    }

    .ios-banner-title {
        font-size: 14px;
    }

    .ios-banner-subtitle {
        font-size: 12px;
    }
}

/* ============================================
   PAGINATION SYSTEM FOR CHAPTER READING
   ============================================ */

/* Pagination wrapper - contains all pagination elements */
.pagination-wrapper {
    position: relative;
    width: 100%;
    min-height: 400px;
    overflow: hidden;
    overscroll-behavior: contain;
}

/* Page container - holds the current page content */
.pagination-page-container {
    position: relative;
    width: 100%;
    height: 100%;
    max-height: 100%;
    overflow: hidden;
    overscroll-behavior: contain;
    /* font-size is set via JavaScript reading settings - default removed to allow inline styles to work */
    line-height: 1.75;
    color: var(--text-color);
}

/* Prevent body/html scrolling when pagination is active */
html.pagination-active,
body.pagination-active {
    overflow: hidden;
}

/* Temporary measuring div (hidden) */

/* Navigation zones - invisible tap/click areas */
/* Navigation zones removed - text selection enabled, only visible buttons remain */

/* Navigation buttons - visible on hover/always on mobile */
.pagination-nav-button {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
    border: none;
    background-color: rgba(0, 0, 0, 0.1);
    color: var(--text-color);
    font-size: 32px;
    font-weight: 300;
    border-radius: 50%;
    cursor: pointer;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    opacity: 0;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

/* Show buttons when wrapper has buttons-visible class (touch/click/hover activated) */
.pagination-wrapper.buttons-visible .pagination-nav-button {
    opacity: 0.7;
}

/* Keep button focus state for accessibility */
.pagination-nav-button:focus {
    opacity: 0.7;
}

.pagination-nav-button:hover {
    opacity: 1 !important;
    background-color: rgba(0, 0, 0, 0.2);
    transform: translateY(-50%) scale(1.1);
}

.pagination-nav-button:active {
    transform: translateY(-50%) scale(0.95);
}

/* Previous button */
.pagination-nav-prev {
    left: 12px;
}

/* Next button */
.pagination-nav-next {
    right: 12px;
}

/* Dark theme button styles */
[data-theme="dark"] .pagination-nav-button {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--text-color);
}

[data-theme="dark"] .pagination-nav-button:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

/* Sepia theme button styles */
[data-theme="sepia"] .pagination-nav-button {
    background-color: rgba(95, 75, 50, 0.15);
    color: var(--text-color);
}

[data-theme="sepia"] .pagination-nav-button:hover {
    background-color: rgba(95, 75, 50, 0.25);
}

/* Wide screens: Position buttons OUTSIDE text container */
@media (min-width: 600px) {
    .pagination-wrapper {
        overflow: visible; /* Allow buttons to extend outside */
        max-width: calc(100% - 140px); /* Reserve 70px on each side for buttons (60px offset + 10px margin) */
        margin: 0 auto; /* Center the text container */
    }

    .pagination-nav-prev {
        left: -60px; /* Outside left edge */
    }

    .pagination-nav-next {
        right: -60px; /* Outside right edge */
    }
}

/* Wider screens: Allow more width for text container */
@media (min-width: 900px) {
    .pagination-wrapper {
        max-width: 800px; /* Comfortable reading width */
    }
}

/* Mobile: Smaller button size */
@media (max-width: 768px) {
    .pagination-nav-button {
        width: 40px;
        height: 40px;
        font-size: 28px;
    }

    .pagination-nav-prev {
        left: 8px;
    }

    .pagination-nav-next {
        right: 8px;
    }
}

/* Touch device adjustments - remove always-visible behavior */
@media (hover: none) and (pointer: coarse) {
    .pagination-nav-button {
        /* Removed opacity: 0.6 - buttons now hidden by default */
    }
}

/* Ensure pagination content inherits theme styles */
.pagination-page-container p {
    margin-bottom: 1em;
}

/* Allow seamless text continuation across pages */
.pagination-page-container p.paragraph-continuation {
    margin-top: 0;
    padding-top: 0;
}

.pagination-page-container h1,
.pagination-page-container h2,
.pagination-page-container h3,
.pagination-page-container h4,
.pagination-page-container h5,
.pagination-page-container h6 {
    color: var(--primary-color);
    margin-top: 1.5em;
    margin-bottom: 0.5em;
    font-weight: 600;
}

.pagination-page-container ul,
.pagination-page-container ol {
    margin: 1em 0;
    padding-left: 2em;
}

.pagination-page-container li {
    margin-bottom: 0.5em;
}

.pagination-page-container strong {
    font-weight: 600;
    color: var(--primary-color);
}

.pagination-page-container em {
    font-style: italic;
}

.pagination-page-container code {
    font-family: 'Courier New', monospace;
    background-color: rgba(0, 0, 0, 0.05);
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.9em;
}

[data-theme="dark"] .pagination-page-container {
    color: var(--reading-theme-dark-text);
}

[data-theme="dark"] .pagination-page-container p,
[data-theme="dark"] .pagination-page-container .side-by-side-cell {
    color: var(--reading-theme-dark-text);
}

[data-theme="dark"] .pagination-page-container h1,
[data-theme="dark"] .pagination-page-container h2,
[data-theme="dark"] .pagination-page-container h3,
[data-theme="dark"] .pagination-page-container h4,
[data-theme="dark"] .pagination-page-container h5,
[data-theme="dark"] .pagination-page-container h6 {
    color: var(--reading-theme-dark-text);
}

[data-theme="dark"] .pagination-page-container code {
    background-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .pagination-page-container .side-by-side-cell.original {
    border-right-color: var(--reading-theme-dark-border) !important;
}

[data-theme="sepia"] .pagination-page-container code {
    background-color: rgba(95, 75, 50, 0.1);
}

.pagination-page-container blockquote {
    border-left: 4px solid var(--primary-color);
    padding-left: 1em;
    margin: 1em 0;
    font-style: italic;
    color: var(--text-secondary);
}

/* Accessibility: Focus styles for keyboard navigation */
.pagination-nav-button:focus-visible {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
}

/* Hide scrollbar for pagination container */
.pagination-page-container::-webkit-scrollbar {
    display: none;
}

.pagination-page-container {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* Ensure smooth page transitions */
.pagination-page-container * {
    transition: none;
}

/* Preserve side-by-side grid layout inside pagination */
/* Use !important to override mobile breakpoint since side-by-side is only available on wide screens */
.pagination-page-container .side-by-side-headers {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 2rem !important;
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #e8e8e8;
}

.pagination-page-container .side-by-side-row {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 2rem !important;
    align-items: start;
    margin-bottom: 0;
}

.pagination-page-container .side-by-side-cell {
    min-width: 0;
    line-height: 1.75;
}

.pagination-page-container .side-by-side-cell.original {
    padding-right: 1rem !important;
    border-right: 1px solid var(--border-light) !important;
    border-bottom: none !important;
    padding-bottom: 0 !important;
}

.pagination-page-container .side-by-side-cell.modern {
    padding-left: 1rem !important;
    padding-top: 0 !important;
}

/* Continuous Reader and Library */
.library-section,
.continuous-reader-section {
    width: 100vw;
    position: relative;
    left: 50%;
    margin-left: -50vw;
    background: var(--card-background);
    min-height: calc(100vh - 51px);
}

.library-section {
    box-sizing: border-box;
    min-height: calc(100vh - 76px);
    padding: 3.25rem max(1.25rem, calc((100vw - 1120px) / 2)) 4rem;
    background: var(--paper);
}

.library-header,
.library-shelf { margin: 0 auto 2.75rem; max-width: 1120px; }
.library-eyebrow { margin: 0 0 .55rem; color: var(--primary-color); font-size: .76rem; font-weight: 750; letter-spacing: .1em; }
.library-header h1 { margin-bottom: .5rem; font-family: var(--font-serif); font-size: clamp(2rem, 4vw, 2.85rem); }
.library-intro { color: var(--text-light); font-size: 1.08rem; }
.library-shelf h2 { margin-bottom: 1rem; font-family: var(--font-serif); font-size: 1.45rem; }
.library-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1rem; }
.library-card { display: grid; grid-template-columns: 108px minmax(0, 1fr); gap: 1.1rem; min-height: 180px; max-width: 520px; padding: 1rem; border: 1px solid var(--border-light); border-radius: 12px; background: var(--card-background); box-shadow: 0 2px 8px rgba(25, 40, 52, .05); cursor: pointer; transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease; }
.library-card:hover { border-color: color-mix(in srgb, var(--primary-color) 35%, var(--border-light)); box-shadow: 0 8px 22px rgba(25, 40, 52, .1); transform: translateY(-1px); }
.library-card-cover-frame { display: flex; align-items: flex-start; min-width: 0; }
.library-card .book-card-cover { width: 108px; height: auto; margin: 0; padding: 10%; }
.library-card .book-card-cover-title { font-size: .85rem; }
.library-card-body { min-width: 0; display: flex; flex-direction: column; align-items: flex-start; }
.library-card-meta { display: flex; width: 100%; justify-content: space-between; gap: .75rem; color: var(--text-light); font-size: .76rem; font-weight: 650; letter-spacing: .03em; text-transform: uppercase; }
.library-card h3 { margin: .35rem 0 .2rem; color: var(--ink); font-family: var(--font-serif); font-size: 1.25rem; line-height: 1.22; }
.library-card-author, .library-card-location, .library-card-mode { margin: 0; color: var(--text-light); font-size: .9rem; }
.library-card-location { overflow: hidden; max-width: 100%; margin-top: .5rem; text-overflow: ellipsis; white-space: nowrap; }
.library-card-progress { width: 100%; height: 5px; margin: .75rem 0 .85rem; overflow: hidden; border-radius: 99px; background: var(--rule); }
.library-card-progress span { display: block; height: 100%; min-width: 4px; border-radius: inherit; background: var(--accent); }
.library-card-actions { display: flex; align-items: center; flex-wrap: wrap; gap: .75rem; }
.library-card-actions button { cursor: pointer; }
.library-read-action { display: inline-flex; align-items: center; gap: .45rem; border: 0; border-radius: var(--radius-control); background: var(--accent); color: var(--on-accent); padding: .54rem .72rem; font: inherit; font-size: .87rem; font-weight: 650; }
.library-read-action:hover { background: var(--accent-hover); }
.library-mark-unfinished { border: 0; background: transparent; color: var(--primary-color); padding: .35rem 0; font: inherit; font-size: .82rem; font-weight: 650; }
.library-card-mode { margin-top: auto; padding-top: .55rem; font-size: .78rem; text-transform: capitalize; }
.library-empty { max-width: 520px; margin: 4rem auto; padding: 2rem; border: 1px dashed var(--border-light); border-radius: 12px; background: rgba(255,255,255,.72); text-align: center; }

@media (max-width: 599px) {
    .library-section { padding-top: 2.25rem; }
    .library-card { grid-template-columns: 82px minmax(0, 1fr); gap: .85rem; min-height: 150px; padding: .85rem; }
    .library-card .book-card-cover { width: 82px; }
    .library-card h3 { font-size: 1.1rem; }
    .library-card-mode { display: none; }
}

.book-read-btn { display: inline-flex; align-items: center; gap: .55rem; margin-top: 1rem; padding: .65rem 1rem; border: 0; border-radius: var(--radius-control); background: var(--accent); color: var(--on-accent); font: inherit; font-weight: 650; cursor: pointer; }
.book-read-btn:hover { background: var(--accent-hover); }
.book-read-btn-arrow { font-size: 1.15em; line-height: 1; }

/* Focused reader chrome: a quiet paper toolbar in the light theme (matching
   the site header); dark and sepia themes give it their own colours below. */
.continuous-reader-section { --reader-chrome-height: 59px; min-height: 100vh; padding-top: var(--reader-chrome-height); }
.continuous-reader-chrome { position: fixed; z-index: 1000; top: 0; left: 0; right: 0; height: var(--reader-chrome-height); min-height: var(--reader-chrome-height); display: flex; align-items: center; gap: 1rem; padding: 10px 18px; box-sizing: border-box; border-bottom: 1px solid var(--rule); background: var(--paper); color: var(--ink); }
.reader-toolbar-left { min-width: 0; flex: 1 1 0; display: flex; align-items: center; gap: 12px; }
.reader-back-btn { flex: 0 0 auto; border: 1px solid var(--rule-strong); border-radius: 7px; background: transparent; color: inherit; padding: 7px 13px; font-size: 1rem; line-height: 1; cursor: pointer; }
.reader-back-btn:hover, .reader-back-btn:focus-visible { background: var(--paper-deep); }
.reader-title-wrap { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.reader-chapter-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: inherit; font-family: var(--font-serif); font-size: 1rem; font-weight: 600; }
.reader-book-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-muted); font-size: .76rem; }
.reader-toolbar-right { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; }
.reader-toolbar-btn { border: 1px solid var(--rule-strong); border-radius: 7px; background: transparent; color: inherit; font: inherit; cursor: pointer; }
.reader-toolbar-btn:hover, .reader-toolbar-btn:focus-visible { background: var(--paper-deep); }
.reader-icon-btn { display: grid; place-items: center; width: 38px; height: 38px; padding: 0; }
.reader-icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.reader-mode-choices { display: grid; gap: .55rem; }
.reader-mode-choices button { border: 1px solid var(--border-color); border-radius: 7px; background: var(--card-background); color: var(--text-color); padding: .7rem .8rem; font: inherit; text-align: left; cursor: pointer; }
.reader-mode-choices button:hover:not(:disabled), .reader-mode-choices button:focus-visible:not(:disabled) { border-color: var(--primary-color); background: var(--hover-background); }
.reader-mode-choices button.active { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--card-background)); color: var(--accent); font-weight: 650; }
.reader-mode-choices button:disabled { cursor: not-allowed; opacity: .45; }
.reader-mode-help { margin-top: .75rem; color: var(--text-light); font-size: .82rem; line-height: 1.4; }
.reader-panel { position: fixed; z-index: 1002; top: 0; right: 0; bottom: 0; width: min(390px, 100vw); overflow: auto; padding: 1.25rem; box-sizing: border-box; border-left: 1px solid var(--rule); background: var(--surface); box-shadow: -12px 0 36px rgba(43,38,34,.16); }
.reader-panel-header { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding-bottom: 1rem; border-bottom: 1px solid var(--border-light); }
.reader-panel-header h2 { margin: 0; font-family: var(--font-serif); font-size: 1.3rem; }
.reader-panel-close { border: 0; background: transparent; color: var(--text-color); font-size: 1.25rem; cursor: pointer; }
#reader-toc-list { display: grid; gap: .2rem; padding: 1rem 0; }
#reader-toc-list button { text-align: left; border: 0; border-radius: 6px; background: transparent; color: var(--text-color); padding: .75rem; font: inherit; cursor: pointer; }
#reader-toc-list button:hover, #reader-toc-list button:focus-visible { background: var(--hover-background); }
.reader-status { max-width: 760px; margin: 1rem auto; padding: 1rem; color: var(--text-light); text-align: center; }
.continuous-reader-content { max-width: 900px; margin: 0 auto; padding: 1rem 1.25rem 0; line-height: 1.75; color: var(--text-color); }
.continuous-reader-content > p { margin: 0 0 1.25em; }
.reader-chapter-heading { margin: 1rem 0 1.25rem; font-family: var(--font-serif); font-size: 1.6rem; }
.continuous-reader-content .reader-section-heading { margin: 1.2em 0 .45em; font-family: var(--font-serif); font-size: 1.1em; font-weight: 700; line-height: 1.35; }
.continuous-reader-content > p.reader-list-item,
.continuous-reader-content .side-by-side-cell > p.reader-list-item { margin-bottom: .25em; padding-left: 1.5em; text-indent: -1.5em; }
.reader-gap { color: var(--text-light); font-style: italic; }
.continuous-reader-footer { position: fixed; z-index: 30; bottom: 0; left: 0; right: 0; display: flex; align-items: center; justify-content: center; gap: .75rem; box-sizing: border-box; padding: .42rem 1rem; border-top: 1px solid var(--rule); background: var(--card-background); color: var(--ink-muted); font-size: .82rem; text-align: center; }
.reader-progress-track { width: min(240px, 40vw); height: 3px; overflow: hidden; border-radius: 99px; background: var(--rule); }
.reader-progress-track span { display: block; height: 100%; background: var(--accent); transition: width .3s ease; }
/* Chapter illustration under its heading; fixed height so pagination can
   measure the page before the image loads. */
.reader-illustration { display: flex; justify-content: center; height: min(52vh, 480px); margin: 0 0 1.5rem; }
.reader-illustration picture { display: contents; }
.reader-illustration img { max-width: 100%; height: 100%; object-fit: contain; border-radius: 4px; cursor: zoom-in; }
.chapter-side-by-side .reader-illustration { grid-column: 1 / -1; }
/* Side by side: a hairline between aligned original / plain-English rows */
.continuous-reader-section .side-by-side-row { padding: .9rem 0; border-bottom: 1px solid var(--rule); }
.continuous-reader-section[data-theme="dark"] { background: var(--reading-theme-dark-bg); color: var(--reading-theme-dark-text); }
.continuous-reader-section[data-theme="dark"] .continuous-reader-chrome,
.continuous-reader-section[data-theme="dark"] .continuous-reader-footer,
.continuous-reader-section[data-theme="dark"] .reader-panel { background: var(--reading-theme-dark-bg); }
.continuous-reader-section[data-theme="dark"] .continuous-reader-chrome { border-bottom-color: var(--reading-theme-dark-border); color: var(--reading-theme-dark-text); }
.continuous-reader-section[data-theme="dark"] .reader-book-title { color: var(--sticky-header-muted); }
.continuous-reader-section[data-theme="dark"] .reader-toolbar-btn,
.continuous-reader-section[data-theme="dark"] .reader-back-btn { border-color: var(--reading-theme-dark-border); }
.continuous-reader-section[data-theme="dark"] .reader-toolbar-btn:hover,
.continuous-reader-section[data-theme="dark"] .reader-back-btn:hover { background: var(--sticky-header-accent); }
.continuous-reader-section[data-theme="dark"] .side-by-side-row,
.continuous-reader-section[data-theme="dark"] .continuous-reader-footer { border-color: var(--reading-theme-dark-border); }
.continuous-reader-section[data-theme="dark"] .reader-progress-track { background: var(--reading-theme-dark-border); }
.continuous-reader-section[data-theme="sepia"] { background: var(--reading-theme-sepia-bg); color: var(--reading-theme-sepia-text); }
.continuous-reader-section[data-theme="sepia"] .continuous-reader-content,
.continuous-reader-section[data-theme="sepia"] .pagination-page-container,
.continuous-reader-section[data-theme="sepia"] .pagination-page-container p,
.continuous-reader-section[data-theme="sepia"] .pagination-page-container .side-by-side-cell,
.continuous-reader-section[data-theme="sepia"] .pagination-page-container h1,
.continuous-reader-section[data-theme="sepia"] .pagination-page-container h2,
.continuous-reader-section[data-theme="sepia"] .pagination-page-container h3,
.continuous-reader-section[data-theme="sepia"] .pagination-page-container h4,
.continuous-reader-section[data-theme="sepia"] .pagination-page-container h5,
.continuous-reader-section[data-theme="sepia"] .pagination-page-container h6 { color: var(--reading-theme-sepia-text); }
.continuous-reader-section[data-theme="sepia"] .continuous-reader-chrome,
.continuous-reader-section[data-theme="sepia"] .continuous-reader-footer,
.continuous-reader-section[data-theme="sepia"] .reader-panel { background: var(--reading-theme-sepia-bg); }
.continuous-reader-section[data-theme="sepia"] .continuous-reader-chrome { color: var(--reading-theme-sepia-text); }
body:has(.continuous-reader-section[data-theme="sepia"]:not(.hidden)) { background: var(--reading-theme-sepia-bg); }
.continuous-reader-section[data-font="georgia"] .continuous-reader-content { font-family: var(--reading-font-serif); font-optical-sizing: auto; }
.continuous-reader-section[data-font="system"] .continuous-reader-content { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
.continuous-reader-section[data-font="opensans"] .continuous-reader-content { font-family: "Open Sans", Arial, sans-serif; }

@media (max-width: 759px) {
    .continuous-reader-section { --reader-chrome-height: calc(59px + env(safe-area-inset-top)); }
    .continuous-reader-chrome { height: var(--reader-chrome-height); min-height: var(--reader-chrome-height); gap: 8px; padding: max(8px, env(safe-area-inset-top)) 10px 8px; }
    .reader-toolbar-left { min-width: 0; }
    .reader-title-wrap { max-width: calc(100vw - 128px); }
    .reader-book-title { display: none; }
    .continuous-reader-content { padding: .75rem 1rem 0; }
}

/* ===== User Account Modal ===== */

/* User account button */

/* Modal container */

/* Modal overlay */

/* Modal content */

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Close button */

/* Modal title */

/* Form styles */
.user-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--primary-color);
}

.form-group input {
    padding: 0.75rem;
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.2s ease;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(138, 46, 46, 0.08);
}

.form-group small {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Error message */
.form-error {
    background: var(--error-bg-light);
    border: 1px solid #fcc;
    color: #c33;
    padding: 0.75rem;
    border-radius: 6px;
    font-size: 0.9rem;
}

.form-error.hidden {
    display: none;
}

/* Buttons */
.btn-primary {
    background: var(--accent);
    color: var(--on-accent);
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius-control);
    font: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    background: var(--surface);
    color: var(--ink);
    padding: 0.7rem 1.2rem;
    border: 1px solid var(--rule-strong);
    border-radius: var(--radius-control);
    font: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.2s ease;
}

.btn-secondary:hover {
    border-color: var(--ink-muted);
    background: var(--paper-deep);
}

/* Modal footer */

.link-btn {
    background: none;
    border: none;
    color: var(--primary-color);
    cursor: pointer;
    font-weight: 500;
    padding: 0;
    text-decoration: underline;
}

.link-btn:hover {
    color: var(--secondary-color-hover);
}

/* View switching */

/* Account view */

/* Account stats */

/* Mobile responsiveness */

/* ===== Completed Chapter Styling ===== */

/* Completed chapter header styling in chapter view */
.chapter-header.completed {
    opacity: 0.8;
}

.chapter-header.completed h1,
.chapter-header.completed h2 {
    color: var(--text-muted);
}

/* Progress indicator badge */

/* Reading progress summary */

/* Mobile adjustments */
@media (max-width: 768px) {
    .chapter-box.completed::before {
        font-size: 1.25rem;
        right: 0.75rem;
    }

    .chapter-progress-badge {
        font-size: 0.75rem;
        padding: 0.2rem 0.6rem;
    }

    .reading-progress-summary {
        flex-direction: column;
        align-items: flex-start;
    }

    .progress-summary-icon {
        font-size: 1.5rem;
    }
}

/* ===== Resume Reading Button ===== */

/* Mobile adjustments */

/* ===========================
   Home (redesign 2026-10-12)
   =========================== */

.home-hero {
    display: grid;
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
    align-items: center;
    gap: 3.5rem;
    /* Full-bleed dark band; content stays on the header's 1160px column. */
    margin: 0 calc(50% - 50vw);
    padding: 4.5rem max(20px, calc(50vw - 580px)) 4rem;
    background: var(--ink);
    color: var(--paper);
}

.home-hero .hero-banner-title {
    margin-bottom: 1.1rem;
    color: var(--paper);
    font-family: var(--font-serif);
    font-size: clamp(2.3rem, 5vw, 3.5rem);
    font-weight: 600;
    line-height: 1.06;
    letter-spacing: -0.01em;
}

.home-hero .hero-banner-subtitle {
    max-width: 30rem;
    color: var(--rule-strong);
    font-family: var(--font-serif);
    font-size: 1.2rem;
    font-style: italic;
    line-height: 1.55;
}

.home-hero .hero-banner-ctas {
    justify-content: flex-start;
    margin-top: 2rem;
}

.home-hero .hero-cta-primary {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.8rem 1.4rem;
    border-radius: var(--radius-control);
    background: var(--paper);
    color: var(--ink);
    font-size: 1rem;
    font-weight: 600;
}

.home-hero .hero-cta-primary:hover {
    background: var(--surface);
}

/* The text thread */
.hero-thread-messages {
    display: grid;
}

.hero-sentence {
    display: flex;
    flex-direction: column;
    justify-content: flex-end; /* like a chat: newest message sits at the bottom */
    grid-area: 1 / 1;
    margin: 0;
}

.hero-sentence[hidden] {
    display: flex;
    visibility: hidden;
}

.hero-sentence-source {
    margin: 0 0 0.45rem 0.25rem;
    color: var(--rule-strong);
    font-size: 0.8rem;
    font-weight: 600;
}

.hero-sentence-source a {
    color: inherit;
    font-weight: 400;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.hero-bubble {
    max-width: 85%;
    margin: 0;
    padding: 0.85rem 1.1rem;
    border-radius: 18px;
}

.hero-bubble--original {
    align-self: flex-start;
    border-bottom-left-radius: 5px;
    background: var(--paper-deep);
    color: var(--ink-muted);
    font-family: var(--font-serif);
    font-size: 1.05rem;
    font-style: italic;
    line-height: 1.5;
}

.hero-bubble--plain {
    align-self: flex-end;
    margin-top: 1rem;
    border-bottom-right-radius: 5px;
    background: var(--accent-bright);
    color: #fff;
}

.hero-bubble--plain .hero-sentence-label {
    display: block;
    margin-bottom: 0.25rem;
    color: rgba(255, 255, 255, 0.78);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.04em;
}

.hero-sentence-plain {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 500;
    line-height: 1.45;
}

/* The reply pops in, like a message arriving — only when the reader asks
   for another example (app.js marks that example .is-new), not on load. */
.hero-sentence.is-new .hero-bubble--plain {
    animation: hero-reply-in 0.35s ease-out 0.2s both;
}

@keyframes hero-reply-in {
    from { opacity: 0; transform: translateY(8px) scale(0.97); }
}

@media (prefers-reduced-motion: reduce) {
    .hero-sentence.is-new .hero-bubble--plain {
        animation: none;
    }
}

.hero-sentence-next {
    display: block;
    margin: 1rem 0 0 auto;
    padding: 0;
    border: 0;
    background: none;
    color: var(--rule-strong);
    font: inherit;
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
}

.hero-sentence-next:hover {
    color: var(--paper);
    text-decoration: underline;
    text-underline-offset: 4px;
}

/* Sections below the hero */
.home-section {
    padding: 2.5rem 0;
    border-top: 1px solid var(--rule);
}

/* The dark band already separates the first section from the hero. */
.hero-main + .home-section,
.hero-main + .home-section.hidden + .home-section {
    border-top: 0;
}

.home-section-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.home-section-head h2 {
    color: var(--ink);
    font-family: var(--font-serif);
    font-size: 1.75rem;
    font-weight: 600;
}

.home-section-sub {
    margin-top: 0.25rem;
    color: var(--ink-muted);
}

.home-section-link {
    color: var(--accent);
    font-size: 0.95rem;
    text-decoration: none;
    white-space: nowrap;
}

.home-section-link:hover {
    text-decoration: underline;
}

.top-10-carousel {
    position: relative;
}

.top-10-carousel .carousel-scroll {
    display: flex;
    gap: 1.25rem;
    padding: 0.5rem 0 1rem;
    overflow-x: auto;
    scroll-behavior: smooth;
    scrollbar-width: none;
}

.top-10-carousel .carousel-scroll::-webkit-scrollbar {
    display: none;
}

.skeleton-book-card {
    flex: 0 0 168px;
    aspect-ratio: 2 / 3;
    border-radius: 4px;
    background: var(--paper-deep);
}

/* Choose by level */
.level-cards {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
}

.level-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1.4rem;
    border: 1px solid var(--rule);
    border-radius: 10px;
    background: var(--surface);
    color: var(--ink);
    text-decoration: none;
    transition: border-color 0.15s ease, transform 0.15s ease;
}

.level-card:hover {
    border-color: var(--ink-muted);
    transform: translateY(-2px);
}

.level-card .level-tag {
    font-size: 0.85rem;
}

.level-card-desc {
    color: var(--ink);
    font-family: var(--font-serif);
    font-size: 1.08rem;
    line-height: 1.45;
}

.level-card-count {
    margin-top: auto;
    color: var(--accent);
    font-size: 0.9rem;
}

/* How it works */
.how-grid {
    display: grid;
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
    align-items: start;
    gap: 2.5rem;
    margin-bottom: 1.5rem;
}

.how-steps {
    display: grid;
    gap: 1.1rem;
    margin: 0;
    padding-left: 1.4rem;
    color: var(--ink-muted);
    line-height: 1.55;
}

.how-steps strong {
    color: var(--ink);
}

.how-sxs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    border: 1px solid var(--rule);
    border-radius: 10px;
    background: var(--surface);
}

.how-sxs-col {
    padding: 1.25rem;
    font-family: var(--font-serif);
    line-height: 1.55;
}

.how-sxs-col + .how-sxs-col {
    border-left: 1px solid var(--rule);
}

.how-sxs-col:first-child p {
    color: var(--ink-muted);
}

/* Header search: an inline field on wide screens; below 900px a magnifier
   opens it as a full-width bar under the header. */
.header-search {
    position: relative;
    display: flex;
    align-items: center;
    margin-left: auto;
}

.header-search-toggle {
    display: none;
    place-items: center;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--ink);
    cursor: pointer;
}

.header-search-toggle:hover,
.header-search.open .header-search-toggle {
    background: var(--paper-deep);
}

.header-search-panel {
    position: relative;
    width: 240px;
}

.header-search-panel::before {
    content: "";
    position: absolute;
    left: 0.8rem;
    top: 50%;
    width: 15px;
    height: 15px;
    transform: translateY(-50%);
    background: var(--ink-muted);
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.5-3.5'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.5-3.5'/%3E%3C/svg%3E") center / contain no-repeat;
    pointer-events: none;
}

.header-search-input {
    height: 36px;
    padding: 0 0.9rem 0 2.1rem;
    font-size: 0.9rem;
    border-color: var(--rule-strong);
    background: var(--surface);
}

.header-search-input:focus {
    border-color: var(--ink-muted);
    box-shadow: none;
}

.header-search-input::-webkit-search-cancel-button {
    -webkit-appearance: none;
}

.header-search .hero-search-results {
    left: auto;
    right: 0;
    width: min(380px, calc(100vw - 2rem));
}

@media (max-width: 899px) {
    /* The bar anchors to .header (position: relative), not the icon. */
    .header-search {
        position: static;
    }

    .header-search-toggle {
        display: grid;
    }

    .header-search-panel {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        z-index: 1001;
        display: none;
        width: auto;
        padding: 0.6rem 16px 0.75rem;
        background: var(--paper);
        border-bottom: 1px solid var(--rule);
    }

    .header-search.open .header-search-panel {
        display: block;
    }

    .header-search-panel::before {
        left: calc(16px + 0.8rem);
        top: calc(0.6rem + 20px);
    }

    .header-search-input {
        height: 40px;
        font-size: 1rem;
    }

    .header-search .hero-search-results {
        left: 16px;
        right: 16px;
        width: auto;
        top: calc(100% - 0.25rem);
    }
}

@media (max-width: 860px) {
    .home-hero {
        grid-template-columns: 1fr;
        gap: 2.25rem;
        padding-top: 2.75rem;
        padding-bottom: 2.5rem;
    }

    .hero-bubble {
        max-width: 92%;
        padding: 0.7rem 0.95rem;
    }

    .hero-bubble--original {
        font-size: 0.95rem;
        line-height: 1.45;
    }

    .hero-bubble--plain {
        margin-top: 0.75rem;
    }

    .hero-sentence-plain {
        font-size: 1.02rem;
    }

    .level-cards,
    .how-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .how-sxs {
        grid-template-columns: 1fr;
    }

    .how-sxs-col + .how-sxs-col {
        border-top: 1px solid var(--rule);
        border-left: 0;
    }

    .home-section-head h2 {
        font-size: 1.45rem;
    }
}

/* Phone header: the icon alone links home, leaving room for the nav links. */
@media (max-width: 600px) {
    .header .logo {
        display: none;
    }

    .header-nav-buttons {
        gap: 14px;
        margin-left: 4px;
    }

    .header-nav-btn {
        font-size: 0.9rem;
    }

    /* Also linked from the footer */
    #categories-nav-btn {
        display: none;
    }
}

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

/* Account: a circular initial in the header */
.header-account {
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid var(--rule-strong);
    border-radius: 50%;
    background: var(--surface);
    color: var(--accent);
    cursor: pointer;
}

.header-account:hover {
    border-color: var(--accent);
    background: var(--paper-deep);
}

.account-avatar {
    display: grid;
    place-items: center;
    font-family: var(--font-serif);
    font-size: 1rem;
    font-weight: 600;
    line-height: 1;
}

/* Account modal */
.user-modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: grid;
    place-items: center;
    padding: 16px;
}

.user-modal.hidden {
    display: none;
}

.user-modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(43, 38, 34, 0.45);
}

.user-modal-content {
    position: relative;
    width: min(420px, 100%);
    padding: 1.75rem;
    border: 1px solid var(--rule);
    border-radius: 12px;
    background: var(--surface);
    color: var(--ink);
    box-shadow: 0 18px 48px rgba(43, 38, 34, 0.2);
}

.user-modal-close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--ink-muted);
    font-size: 1rem;
    cursor: pointer;
}

.user-modal-close:hover {
    background: var(--paper-deep);
    color: var(--ink);
}

.user-modal-title {
    margin: 0 0 1.1rem;
    font-family: var(--font-serif);
    font-size: 1.5rem;
    font-weight: 600;
}

.user-modal-subtitle,
.account-stats-description {
    margin: 0;
    color: var(--ink-muted);
    font-size: 0.9rem;
    line-height: 1.5;
}

.account-info {
    border-top: 1px solid var(--rule);
}

.account-item {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.65rem 0;
    border-bottom: 1px solid var(--rule);
    font-size: 0.92rem;
}

.account-label {
    color: var(--ink-muted);
}

.account-value {
    min-width: 0;
    overflow-wrap: anywhere;
    text-align: right;
}

.account-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin: 1.25rem 0 0.75rem;
}

.account-stat {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding: 0.85rem 1rem;
    border-radius: 10px;
    background: var(--paper);
}

.stat-value {
    font-family: var(--font-serif);
    font-size: 1.6rem;
    font-weight: 600;
    line-height: 1.1;
}

.stat-label {
    color: var(--ink-muted);
    font-size: 0.85rem;
}

.account-library-link {
    margin-top: 1.25rem;
}

/* Book page summary: heading, Short/Full switch, Listen */
.book-summary-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1rem;
    margin-bottom: 1.1rem;
}

.book-summary-title {
    margin: 0 auto 0 0;
    font-family: var(--font-serif);
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--ink);
}

.summary-switch {
    display: inline-flex;
    padding: 3px;
    border: 1px solid var(--rule);
    border-radius: var(--radius-control);
    background: var(--paper-deep);
}

.summary-tab {
    display: inline-flex;
    align-items: baseline;
    min-height: 34px;
    padding: 0.4rem 0.9rem;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--ink-muted);
    font: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
}

.summary-tab:hover {
    color: var(--ink);
}

.summary-tab.active {
    background: var(--surface);
    color: var(--ink);
    box-shadow: 0 1px 2px rgba(43, 38, 34, 0.12);
}

.summary-tab-time {
    margin-left: 0.15rem;
    color: var(--ink-muted);
    font-weight: 400;
}

#concise-summary-text,
.book-summary .summary-text {
    font-size: 1.08rem;
    color: var(--ink);
}

.summary-more {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.35rem 0;
    border: 0;
    background: none;
    color: var(--accent);
    font: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
}

.summary-more:hover {
    color: var(--accent-hover);
    text-decoration: underline;
    text-underline-offset: 4px;
}

.summary-more svg {
    transition: transform 0.2s ease;
}

.summary-more[aria-expanded="true"] svg {
    transform: rotate(180deg);
}

/* Listen: one outline button with a state (Listen / Preparing / Pause / Resume) */
.listen-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    min-height: 36px;
    padding: 0 0.9rem;
    border: 1px solid var(--rule-strong);
    border-radius: var(--radius-control);
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
}

.listen-btn:hover {
    border-color: var(--ink-muted);
    background: var(--paper-deep);
}

.listen-btn svg {
    color: var(--accent);
}

.listen-btn.is-playing {
    border-color: var(--accent);
    color: var(--accent);
}

.listen-btn:disabled {
    cursor: progress;
    opacity: 0.75;
}

.listen-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid var(--rule-strong);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: listen-spin 0.8s linear infinite;
}

@keyframes listen-spin {
    to { transform: rotate(360deg); }
}

/* Persistent audio player: a flat bar on the paper surface */
.persistent-audio-player {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1500;
    border-top: 1px solid var(--rule);
    background: var(--surface);
    color: var(--ink);
    box-shadow: 0 -6px 20px rgba(43, 38, 34, 0.08);
}

.persistent-audio-player.hidden {
    display: none;
}

.player-content {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0.65rem 20px;
}

.player-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
    flex: 0 1 34%;
}

.now-playing-icon {
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    border-radius: var(--radius-control);
    background: var(--paper-deep);
    color: var(--accent);
}

.player-text {
    min-width: 0;
}

.player-title {
    overflow: hidden;
    font-family: var(--font-serif);
    font-size: 0.98rem;
    font-weight: 600;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.player-subtitle {
    overflow: hidden;
    color: var(--ink-muted);
    font-size: 0.8rem;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.player-controls {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex: 1;
    min-width: 0;
}

.player-btn {
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid var(--rule-strong);
    border-radius: 50%;
    background: var(--surface);
    color: var(--ink);
    cursor: pointer;
}

.player-btn:hover {
    background: var(--paper-deep);
}

.player-btn-main {
    width: 40px;
    height: 40px;
    border-color: var(--accent);
    background: var(--accent);
    color: var(--on-accent);
}

.player-btn-main:hover {
    background: var(--accent-hover);
}

.player-progress {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
    min-width: 0;
}

.progress-bar {
    flex: 1;
    height: 4px;
    overflow: hidden;
    border-radius: 99px;
    background: var(--rule);
    cursor: pointer;
}

.progress-fill {
    width: 0;
    height: 100%;
    background: var(--accent);
}

.player-time {
    flex: 0 0 auto;
    color: var(--ink-muted);
    font-size: 0.8rem;
    font-variant-numeric: tabular-nums;
}

@media (max-width: 640px) {
    .player-content {
        flex-wrap: wrap;
        gap: 0.5rem 0.75rem;
        padding: 0.6rem 16px;
    }

    .player-info {
        flex: 1 1 100%;
    }

    .now-playing-icon {
        display: none;
    }

    .book-summary-title {
        flex: 1 1 100%;
    }

    .book-summary-head {
        column-gap: 0.5rem;
    }

    .summary-switch {
        flex: 1 1 auto;
        min-width: 0;
    }

    .summary-tab {
        flex: 1;
        justify-content: center;
        padding: 0.4rem 0.5rem;
        white-space: nowrap;
    }

    .listen-btn {
        padding: 0 0.7rem;
    }
}
