/* ─── Reader View ────────────────────────────────────────── */
.reader-wrapper {
    position: fixed;
    inset: 0;
    /* Background moved to pseudo-element to allow ambience layering */
    background: transparent;
    color: var(--book-text);
    z-index: 100;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    isolation: isolate;
}

.reader-wrapper::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--book-bg);
    z-index: 0;
    /* Behind Ambience (1) */
}

.reader-progress-bar {
    height: 3px;
    background: var(--book-accent);
    box-shadow: 0 0 12px color-mix(in srgb, var(--book-accent) 50%, transparent);
    transition: width 0.2s ease;
    position: relative;
    z-index: 10;
}

.reader-container {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 5;
    /* Above Ambience */
    padding: 0 2rem 6rem;
    /* Increased bottom padding for the fixed nav */
    background: transparent !important;
    /* Ensure no bg hides ambience */
}

.reader-status-bar {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--book-surface);
    border: 1px solid var(--book-border);
    color: var(--book-text);
    font-family: var(--book-font-heading);
    font-size: 0.8rem;
    padding: 0.3rem 0.8rem;
    border-radius: 99px;
    box-shadow: var(--shadow-sm);
    z-index: 120;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s ease;
    pointer-events: none;
}

.reader-status-bar.visible {
    opacity: 0.9;
    transform: translateY(0);
}

.reader-slider-tooltip {
    position: absolute;
    right: 18px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--book-surface);
    border: 1px solid var(--book-border);
    color: var(--book-text);
    font-size: 0.7rem;
    padding: 0.15rem 0.4rem;
    border-radius: 6px;
    white-space: nowrap;
    opacity: 0.9;
    box-shadow: var(--shadow-sm);
    pointer-events: none;
}

.reader-container.focus-mode .reader-toolbar,
.reader-container.focus-mode .chapter-nav {
    opacity: 0;
    pointer-events: none;
}

.reader-container:not(.show-ui) .reader-toolbar,
.reader-container:not(.show-ui) .chapter-nav {
    opacity: 0;
    transform: translateY(-8px);
    pointer-events: none;
}

.reader-content {
    flex: 1;
    overflow: visible;
    padding: 0 0 2rem;
    scroll-behavior: smooth;
    max-width: var(--book-content-max, var(--book-max-width));
    margin: 0 auto;
    width: 100%;
    background: transparent !important;
    /* Ensure no bg hides ambience */
}

/* Toolbar */
.reader-toolbar {
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 0;
    border-bottom: 1px solid var(--book-border);
    background: rgba(var(--book-bg-rgb), 0.8);
    backdrop-filter: blur(10px);
    z-index: 10;
    position: sticky;
    top: 0;
    transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.reader-toolbar-center {
    font-family: var(--book-font-heading);
    font-size: 0.95rem;
    opacity: 0.85;
    text-align: center;
    flex: 1;
    min-width: 0;
    padding: 0 0.75rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.reader-toolbar-actions {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.reading-time-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 1rem 0 0.5rem;
}

.reading-time-badge,
.remaining-time-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.75rem;
    padding: 0.3rem 0.6rem;
    border-radius: 999px;
    color: var(--book-accent-dark);
    border: 1px solid var(--book-border);
    background: color-mix(in srgb, var(--book-surface) 70%, transparent);
}

.remaining-time-badge {
    opacity: 0.6;
    border-style: dashed;
}

/* Typography */
.reader-article {
    font-family: var(--book-font-body);
    font-size: calc(var(--book-font-size) * var(--font-size-multiplier, 1));
    line-height: var(--book-line-height);
    color: var(--book-text);
    text-align: justify;
    text-justify: inter-word;
    -webkit-text-justify: inter-word;
    hyphens: auto;
    background: transparent !important;
    /* Ensure no bg hides ambience */
    text-shadow: var(--book-text-shadow, none);
}

.reader-article h1,
.reader-article h2,
.reader-article h3,
.reader-article h4,
.reader-article h5,
.reader-article h6 {
    font-family: var(--book-font-heading);
    color: var(--book-accent-dark);
    line-height: 1.25;
    margin: 1.5rem 0 0.75rem;
}

.reader-article h1 {
    font-size: var(--book-h1-size, 2.2rem);
}

.reader-article h2 {
    font-size: var(--book-h2-size, 1.8rem);
}

.reader-article h3 {
    font-size: 1.4rem;
    margin-top: 4rem;
    margin-bottom: 2rem;
}

.reader-article h4 {
    font-size: 1.2rem;
}

.reader-article h5 {
    font-size: 1.05rem;
}

.reader-article h6 {
    font-size: 0.95rem;
    opacity: 0.85;
}

.chapter-main-title {
    font-family: var(--book-font-heading);
    font-size: 3rem;
    text-align: center;
    margin: 3rem 0 4rem;
    font-weight: 600;
}

/* Illustration de chapitre (vignette équilibrée) */
.chapter-figure {
    margin: 1.5rem auto 2.5rem;
    max-width: 480px;
    text-align: center;
}

.chapter-figure img {
    display: block;
    width: 100%;
    max-height: 280px;
    object-fit: contain;
    background: var(--book-surface);
    margin: 0 auto;
    border-radius: 12px;
    border: 1px solid var(--book-border);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    cursor: zoom-in;
    transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}

.chapter-figure img:hover {
    transform: scale(1.02);
    box-shadow: 0 14px 40px rgba(0, 0, 0, 0.45);
}

.chapter-figure + h1.chapter-main-title,
.chapter-byline + .chapter-figure {
    margin-top: 1rem;
}

/* Illustration d'origine de chaque texte (couverture Wattpad) */
.chapter-story-cover {
    margin: 2rem auto 2.5rem;
    max-width: 360px;
    text-align: center;
}

.chapter-story-cover img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 12px;
    border: 1px solid var(--book-border);
    box-shadow: 0 12px 36px rgba(28, 25, 23, 0.18);
    cursor: zoom-in;
    transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}

.chapter-story-cover img:hover {
    transform: scale(1.02);
    box-shadow: 0 16px 44px rgba(28, 25, 23, 0.24);
}

/* Le premier titre suit l'illustration : on resserre son espace supérieur. */
.chapter-story-cover + h1.chapter-main-title {
    margin-top: 0;
}

.reader-article p {
    margin-bottom: 1.5rem;
}

/* Théâtre : didascalies bleues et répliques */
.scene-description {
    color: #1f4e9c;
    font-style: italic;
    text-align: left;
    margin: 1.4rem 0 1.8rem;
    padding: 0.15rem 0 0.15rem 1rem;
    border-left: 2px solid rgba(31, 78, 156, 0.35);
}

.scene-description-inline {
    color: #1f4e9c;
    font-style: italic;
}

.chapter-paragraph.dialogue {
    text-align: left;
    text-justify: none;
    hyphens: none;
    padding-left: 0.15rem;
}

[data-theme="light"] .scene-description,
[data-theme="light"] .scene-description-inline {
    color: #1f4e9c;
    border-left-color: rgba(31, 78, 156, 0.3);
}

[data-theme="dark"] .scene-description,
[data-theme="dark"] .scene-description-inline {
    color: #8ab4f8;
    border-left-color: rgba(138, 180, 248, 0.4);
}

/* Dropcap */
.dropcap:first-letter {
    float: left;
    font-family: var(--book-font-heading);
    font-size: var(--book-dropcap-size, 4em);
    line-height: 0.82;
    margin: 0.02em 0.12em 0 0;
    color: var(--book-accent);
}

/* Prefaces / Intros HTML injectées */
.book-intro-generated {
    text-align: center;
    padding: 3rem 2rem;
    background: color-mix(in srgb, var(--book-surface) 40%, transparent);
    border: 1px solid var(--book-border);
    border-radius: 16px;
    margin: 3rem auto;
    max-width: 80%;
    box-shadow: var(--shadow-sm);
}

.book-intro-generated h2 {
    font-family: var(--book-font-heading);
    font-size: 2.5rem !important;
    color: var(--book-accent-dark) !important;
    margin-top: 0 !important;
    margin-bottom: 0.5rem !important;
}

.book-intro-generated hr.ornament {
    border: 0;
    height: 2px;
    background: var(--book-accent);
    width: 60px;
    margin: 1.5rem auto 2rem;
    opacity: 0.6;
}

.book-intro-generated p {
    font-size: 1.1em;
    line-height: 1.8;
    color: var(--book-text);
    margin-bottom: 1.2rem;
}

.book-intro-generated .chapter-continuation {
    font-style: italic;
    opacity: 0.8;
    margin-top: 2rem;
}

/* Mention de transparence sur l'assistance IA, en bas de la dernière de couverture. */
.book-intro-generated p.ai-disclosure,
.book-intro-generated p.provenance-note {
    max-width: 560px;
    margin: 2rem auto 0;
    padding-top: 1rem;
    border-top: 1px solid var(--book-border);
    font-family: var(--font-sans, sans-serif);
    font-size: 0.72rem;
    line-height: 1.6;
    font-style: normal;
    text-align: center;
    color: var(--book-text);
    opacity: 0.62;
}

.chapter-byline {
    font-family: var(--font-sans, sans-serif);
    font-size: 0.78rem;
    font-style: normal;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    text-align: center;
    color: var(--book-accent-dark);
    opacity: 0.75;
    margin-bottom: 1.2rem;
}

/* Poésie : strophes compactes, alignées à gauche, sans justification. */
.chapter-paragraph.poem-stanza {
    text-align: left;
    text-justify: none;
    hyphens: none;
    line-height: 1.9;
}

/* Ligne de titre d'origine conservée telle quelle dans le corps du texte. */
.chapter-paragraph.chapter-original-title {
    text-align: center;
    font-style: italic;
    font-size: 1.08em;
    opacity: 0.82;
    margin: 0 auto 2rem;
}

/* Note de provenance en fin de texte. */
.chapter-source-note {
    margin-top: 3rem;
    padding-top: 1rem;
    border-top: 1px solid var(--book-border);
    text-align: center;
    font-family: var(--font-sans, sans-serif);
    font-size: 0.75rem;
    line-height: 1.6;
    opacity: 0.65;
}

/* Sidebar / TOC */
.sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: -320px;
    width: 320px;
    background: var(--book-surface);
    border-right: 1px solid var(--book-border);
    transition: left 0.3s ease;
    z-index: 200;
    padding: 2rem;
    overflow-y: auto;
}

.sidebar.open {
    left: 0;
}

/* Navigation */
.chapter-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 2rem;
    background: color-mix(in srgb, var(--book-surface) 90%, transparent);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--book-border);
    z-index: 100;
    transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.reader-container:not(.show-ui) .chapter-nav {
    opacity: 0;
    transform: translateY(20px);
    pointer-events: none;
}

.chapter-nav-left,
.chapter-nav-right {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1;
}

.chapter-nav-right {
    justify-content: flex-end;
}

.chapter-nav-center {
    flex: 0 0 auto;
    font-family: var(--book-font-heading);
    font-size: 0.9rem;
    opacity: 0.7;
}

.nav-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: transparent;
    border: 1px solid transparent;
    color: var(--book-text);
    padding: 0.5rem 0.8rem;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all var(--transition-fast);
}

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

.nav-btn:hover:not(:disabled) {
    background: color-mix(in srgb, var(--book-accent) 10%, transparent);
    border-color: var(--book-border);
}

.jump-controls-inline {
    display: flex;
    gap: 0.5rem;
    margin-left: 1.5rem;
    padding-left: 1.5rem;
    border-left: 1px solid var(--book-border);
}

.jump-btn-small {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid var(--book-border);
    background: var(--book-surface);
    color: var(--book-text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.jump-btn-small:hover {
    border-color: var(--book-accent);
    background: var(--book-accent);
    color: white;
}

/* Fin de partie : navigation toujours visible dans le flux */
.chapter-end-nav {
    margin: 3.5rem auto 1rem;
    max-width: 620px;
    padding: 1.75rem 1.25rem 1.25rem;
    border-top: 1px solid var(--book-border);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.8rem;
    text-align: center;
}

.chapter-rights {
    margin: 0.4rem 0 0;
    font-size: 0.72rem;
    letter-spacing: 0.02em;
    color: var(--book-muted, var(--app-muted));
}

.chapter-rights a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.chapter-rights a:hover {
    color: var(--book-accent, var(--app-primary));
}

.chapter-end-label {
    font-family: var(--font-sans, sans-serif);
    font-size: 0.7rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--book-accent-dark);
    opacity: 0.7;
}

.chapter-end-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.65rem;
    max-width: 100%;
    padding: 0.8rem 1.15rem;
    border: 1px solid var(--book-border);
    border-radius: 12px;
    background: color-mix(in srgb, var(--book-surface) 75%, transparent);
    color: var(--book-text);
    font-family: var(--book-font-body);
    font-size: 0.95rem;
    cursor: pointer;
    transition: border-color var(--transition-fast), background var(--transition-fast), transform var(--transition-fast);
}

.chapter-end-btn:hover {
    border-color: var(--book-accent);
    background: color-mix(in srgb, var(--book-accent) 10%, var(--book-surface));
    transform: translateY(-1px);
}

.chapter-end-btn strong {
    font-family: var(--book-font-heading);
    font-size: 1.05rem;
    font-weight: 600;
}

.chapter-end-next-label {
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    opacity: 0.65;
    white-space: nowrap;
}

/* Pastille de secours quand la barre est masquée */
.reader-chapter-pill {
    position: fixed;
    bottom: 1.1rem;
    left: 1.5rem;
    right: auto;
    transform: none;
    display: inline-flex;
    align-items: center;
    padding: 0.25rem;
    border-radius: 999px;
    background: color-mix(in srgb, var(--book-surface) 92%, transparent);
    border: 1px solid var(--book-border);
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(10px);
    z-index: 150;
    opacity: 0.92;
}

.reader-chapter-pill button {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    border: 0;
    background: transparent;
    color: var(--book-text);
    cursor: pointer;
    font-family: var(--font-sans, sans-serif);
    font-size: 0.78rem;
    padding: 0.35rem 0.55rem;
    border-radius: 999px;
}

.reader-chapter-pill button:hover {
    background: color-mix(in srgb, var(--book-accent) 12%, transparent);
}

.reader-chapter-pill .pill-next {
    border-left: 1px solid var(--book-border);
    border-radius: 0 999px 999px 0;
}

.reader-chapter-pill .pill-next:disabled {
    opacity: 0.3;
    cursor: default;
}

.reader-chapter-pill .pill-count {
    font-variant-numeric: tabular-nums;
}

.reader-chapter-pill .pill-next-label {
    font-size: 0.72rem;
    opacity: 0.8;
}

@media (max-width: 900px) {
    .reader-chapter-pill {
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        bottom: 0.8rem;
    }
}

@media (max-width: 600px) {
    .reader-chapter-pill .pill-next-label {
        display: none;
    }

    .chapter-end-nav {
        margin-top: 2.5rem;
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }

    .chapter-end-btn {
        flex-wrap: wrap;
        row-gap: 0.35rem;
    }
}

/* Section Headings */
.section-heading {
    font-family: var(--book-font-heading);
    font-size: 1.8rem;
    margin: 2.5rem 0 1.5rem;
    color: var(--book-accent-dark);
}

.reader-slider {
    position: fixed;
    right: 12px;
    top: 120px;
    bottom: 120px;
    width: 6px;
    background: color-mix(in srgb, var(--book-border) 40%, transparent);
    border-radius: 999px;
    cursor: pointer;
    z-index: 110;
}

.reader-slider-handle {
    position: absolute;
    left: -4px;
    width: 14px;
    background: var(--book-accent);
    border-radius: 999px;
    box-shadow: 0 4px 12px color-mix(in srgb, var(--book-accent) 40%, transparent);
}

.reader-slider-progress {
    position: absolute;
    right: 24px;
    transform: translateY(-50%);
    background: var(--book-surface);
    border: 1px solid var(--book-border);
    color: var(--book-text);
    font-size: 0.75rem;
    padding: 0.2rem 0.45rem;
    border-radius: 10px;
    box-shadow: var(--shadow-sm);
    pointer-events: none;
}

.chapter-cover {
    max-width: var(--book-content-max, var(--book-max-width));
    margin: 1rem auto 1.5rem;
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid var(--book-border);
    box-shadow: var(--shadow-md);
}

.chapter-cover img {
    width: 100%;
    height: auto;
    display: block;
    cursor: zoom-in;
    transition: transform var(--transition-normal);
}

.chapter-cover:hover img {
    transform: scale(1.012);
}



.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-fast);
    z-index: 150;
}

.sidebar-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.sidebar-body {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toc-section-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: color-mix(in srgb, var(--book-text) 60%, transparent);
    margin: 0.5rem 0;
}

.toc-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.7rem;
    border-radius: 10px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: border-color var(--transition-fast), background var(--transition-fast);
}

.toc-item:hover {
    border-color: var(--book-border);
    background: color-mix(in srgb, var(--book-surface) 70%, transparent);
}

.toc-item.active {
    border-color: var(--book-accent);
    background: color-mix(in srgb, var(--book-accent) 12%, transparent);
}

.toc-num {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 1px solid var(--book-border);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    flex-shrink: 0;
}

/* Miniature de l'illustration d'origine dans le sommaire */
.toc-thumb {
    width: 36px;
    height: 50px;
    object-fit: cover;
    border-radius: 5px;
    border: 1px solid var(--book-border);
    flex-shrink: 0;
    transition: transform var(--transition-fast);
}

.toc-thumb.zoomable {
    cursor: zoom-in;
}

.toc-thumb.zoomable:hover {
    transform: scale(1.12);
}

/* ─── Chapter Content Enhancements ──────────────────────────── */

/* Pull quote / citation mise en valeur */
.chapter-pullquote {
    border-left: 3px solid var(--book-accent);
    padding: 1rem 1.5rem;
    margin: 2rem 0;
    background: color-mix(in srgb, var(--book-accent) 6%, transparent);
    border-radius: 0 12px 12px 0;
    font-style: italic;
    color: var(--book-accent-dark);
    line-height: 1.8;
}

/* Séparateur de section ornemental */
.chapter-divider {
    border: none;
    height: 1px;
    background: linear-gradient(
        to right,
        transparent,
        var(--book-border) 30%,
        var(--book-accent) 50%,
        var(--book-border) 70%,
        transparent
    );
    margin: 3rem auto;
    max-width: 60%;
    opacity: 0.6;
}

/* Titre de section interne (sous-chapitre) */
.chapter-section-title {
    font-family: var(--book-font-heading);
    font-size: 1.5rem;
    color: var(--book-accent);
    text-align: center;
    margin: 2rem 0 1.5rem;
    letter-spacing: 0.03em;
    opacity: 0.9;
}

/* Table de statistiques */
.chapter-stats-table {
    width: 100%;
    border-collapse: collapse;
    margin: 2rem 0;
    font-family: var(--book-font-body);
    font-size: 0.92rem;
}

.chapter-stats-table thead tr {
    background: color-mix(in srgb, var(--book-accent) 15%, transparent);
    color: var(--book-accent-dark);
}

.chapter-stats-table th {
    padding: 0.7rem 1rem;
    text-align: left;
    font-family: var(--book-font-heading);
    font-size: 0.85rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    border-bottom: 2px solid var(--book-accent);
}

.chapter-stats-table td {
    padding: 0.65rem 1rem;
    border-bottom: 1px solid var(--book-border);
    vertical-align: middle;
    line-height: 1.5;
}

.chapter-stats-table tbody tr:nth-child(even) {
    background: color-mix(in srgb, var(--book-surface) 50%, transparent);
}

.chapter-stats-table tbody tr:hover {
    background: color-mix(in srgb, var(--book-accent) 8%, transparent);
}

.chapter-stats-table td:nth-child(2) {
    font-weight: 600;
    color: var(--book-accent-dark);
}

.chapter-stats-table td:nth-child(3) {
    font-style: italic;
    opacity: 0.75;
    font-size: 0.85rem;
}

/* Variante pour les listes de descripteurs : la seconde colonne n'est pas une valeur */
.chapter-stats-table.descripteurs td:nth-child(2) {
    font-weight: 400;
    color: inherit;
    text-align: left;
}

.chapter-stats-table.descripteurs td:first-child {
    text-align: left;
}

/* Tableaux larges : defilement horizontal sur petit ecran */
.chapter-table-scroll {
    margin: 2rem 0;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
}

.chapter-table-scroll > .chapter-stats-table {
    margin: 0;
}

@media (max-width: 700px) {
    .chapter-table-scroll[data-cols="3"] > .chapter-stats-table {
        min-width: 540px;
    }

    .chapter-table-scroll[data-cols="4"] > .chapter-stats-table {
        min-width: 660px;
    }
}

/* Bloc de telechargement PDF (livre Sciences et technologie) */
.chapter-download {
    margin: 2.5rem auto;
    max-width: 620px;
    padding: 1.4rem 1.6rem;
    background: color-mix(in srgb, var(--book-surface) 55%, transparent);
    border: 1px solid var(--book-border);
    border-radius: 12px;
    text-align: center;
}

.chapter-download-link {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.7rem 1.4rem;
    background: var(--book-accent-dark);
    color: var(--book-bg);
    border-radius: 8px;
    font-family: var(--font-sans, sans-serif);
    font-size: 0.92rem;
    text-decoration: none;
}

.chapter-download-link:hover {
    opacity: 0.88;
}

.chapter-download-meta {
    margin-top: 0.7rem;
    font-family: var(--font-sans, sans-serif);
    font-size: 0.75rem;
    opacity: 0.65;
}

.chapter-download-note {
    margin-top: 0.5rem;
    font-size: 0.8rem;
    opacity: 0.75;
}

/* Sommaire d'origine d'une partie */
.chapter-original-toc {
    margin: 1.5rem 0 2.5rem;
    padding: 1.2rem 1.6rem;
    border-left: 3px solid var(--book-accent);
    background: color-mix(in srgb, var(--book-surface) 45%, transparent);
}

.chapter-original-toc h3 {
    margin-top: 0;
    font-size: 1.05rem;
    letter-spacing: 0.02em;
}

.chapter-original-toc ol {
    margin: 0;
    padding-left: 1.2rem;
    font-family: var(--font-sans, sans-serif);
    font-size: 0.85rem;
    line-height: 1.7;
}

.chapter-original-toc li {
    margin-bottom: 0.15rem;
}

.chapter-original-toc .toc-page {
    opacity: 0.55;
}

/* Contexte et resume de 2026 */
.chapter-context {
    text-align: center;
    font-family: var(--font-sans, sans-serif);
    font-size: 0.75rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--book-accent-dark);
    opacity: 0.7;
    margin-bottom: 2rem;
}

.chapter-summary {
    margin-bottom: 1.4rem;
}

/* Listes dans les chapitres (carnets et parties techniques) */
.chapter-content ul,
.chapter-content ol {
    margin: 0 0 1.4rem;
    padding-left: 1.35rem;
    font-family: var(--book-font-body);
    font-size: 1em;
    line-height: var(--book-line-height);
}

.chapter-content li {
    margin-bottom: 0.55rem;
}

.chapter-content li > ul,
.chapter-content li > ol {
    margin-top: 0.55rem;
}

/* Sommaire d'origine : listes sans puces, labels conserves */
.chapter-original-toc ul {
    list-style: none;
    margin: 0;
    padding-left: 0;
    font-family: var(--font-sans, sans-serif);
    font-size: 0.85rem;
    line-height: 1.7;
}

.chapter-original-toc ul ul {
    padding-left: 1.2rem;
    margin-top: 0.15rem;
}

.chapter-original-toc ul ul li {
    opacity: 0.9;
}

/* ─── Lecture audio d'une nouvelle ─────────────────────────── */
.chapter-audio {
    margin: 1.25rem 0 2.5rem;
    padding: 1rem 1.15rem 1.1rem;
    border: 1px solid var(--book-border);
    border-radius: 12px;
    background: var(--book-surface);
}

.chapter-audio h2 {
    margin: 0 0 0.5rem;
    font-family: var(--book-font-heading);
    font-size: 1.35rem;
    color: var(--book-accent-dark);
}

.chapter-audio p {
    margin: 0 0 0.6rem;
    font-size: 0.95em;
    line-height: 1.55;
    text-align: left;
    text-justify: none;
    hyphens: none;
}

.chapter-audio audio {
    display: block;
    width: 100%;
    margin: 0.4rem 0 0.7rem;
}

.chapter-audio .chapter-audio-link {
    margin: 0;
    font-size: 0.9em;
}

.chapter-audio .chapter-audio-link a {
    color: var(--book-accent-dark);
}

/* ─── Bande dessinée : planches de cases ─────────────────────
   Chapitres BD exportés avec .bd-page. Le papier, les cases, les
   récitatifs et les bulles sont rendus en HTML ; les images gardent
   leur ratio natif et ne sont jamais recadrées. */

.bd-page {
    --bd-paper: #f4ecdf;
    --bd-paper-edge: #c9b99f;
    --bd-ink: #1c1a17;
    --bd-bubble: #fffdf6;
    --bd-caption: #fbf3e2;
    --bd-red: #8b2500;
    margin: 0 auto 2.5rem;
}

.bd-page .bd-sheet {
    background-color: var(--bd-paper);
    background-image:
        radial-gradient(circle at 20% 10%, rgba(255, 255, 255, 0.45), transparent 55%),
        radial-gradient(circle at 80% 90%, rgba(120, 90, 50, 0.08), transparent 60%);
    border: 1px solid var(--bd-paper-edge);
    padding: 14px;
    box-shadow:
        0 2px 0 rgba(255, 255, 255, 0.35) inset,
        0 18px 44px rgba(0, 0, 0, 0.45);
}

.bd-page .bd-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    align-items: start;
}

.bd-page .bd-panel {
    position: relative;
    container-type: inline-size;
    min-width: 0;
    background-color: #0f0e0d;
    border: 2px solid var(--bd-ink);
}

.bd-page .bd-panel--large,
.bd-page .bd-panel--banner {
    grid-column: span 2;
}

.bd-page .bd-frame {
    position: relative;
    width: 100%;
    overflow: visible;
}

.bd-page .bd-panel--large .bd-frame {
    aspect-ratio: 1344 / 576;
}

.bd-page .bd-panel--banner .bd-frame {
    aspect-ratio: 1536 / 512;
}

.bd-page .bd-panel--portrait .bd-frame {
    aspect-ratio: 768 / 1024;
}

.bd-page .bd-frame img {
    display: block;
    width: 100%;
    height: 100%;
    margin: 0;
    object-fit: contain;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    cursor: zoom-in;
}

.bd-page .bd-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.bd-page .bd-caption {
    position: absolute;
    width: var(--caption-w, 52%);
    max-width: 94%;
    margin: 0;
    padding: 0.42em 0.6em;
    background: var(--bd-caption);
    color: var(--bd-ink);
    border: 1.5px solid var(--bd-ink);
    box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.35);
    font-family: var(--book-font-body);
    font-size: clamp(0.7rem, 2.9cqw, 0.98rem);
    font-style: italic;
    line-height: 1.34;
    text-align: left;
    text-shadow: none;
    hyphens: auto;
    text-wrap: pretty;
}

.bd-page .bd-pos-tl { top: 3%; left: 3%; }
.bd-page .bd-pos-tr { top: 3%; right: 3%; }
.bd-page .bd-pos-bl { bottom: 3%; left: 3%; }
.bd-page .bd-pos-br { bottom: 3%; right: 3%; }

.bd-page .bd-bubble {
    position: absolute;
    left: var(--bx, 50%);
    top: var(--by, 20%);
    width: var(--bw, 40%);
    max-width: 94%;
    margin: 0;
    transform: translate(-50%, -50%);
    padding: 0.5em 0.68em;
    background: var(--bd-bubble);
    color: var(--bd-ink);
    border: 1.5px solid var(--bd-ink);
    border-radius: 14px;
    box-shadow: 2px 3px 0 rgba(0, 0, 0, 0.3);
    font-family: var(--book-font-body);
    font-size: clamp(0.7rem, 2.9cqw, 0.98rem);
    line-height: 1.32;
    text-align: left;
    text-shadow: none;
    hyphens: auto;
    text-wrap: pretty;
}

.bd-page .bd-speaker {
    display: block;
    margin-bottom: 0.15em;
    color: var(--bd-red);
    font-size: 0.72em;
    font-weight: 700;
    letter-spacing: 0.07em;
    line-height: 1.2;
    text-transform: uppercase;
}

.bd-page .bd-text {
    display: block;
}

.bd-page .bd-bubble::after {
    content: "";
    position: absolute;
    width: 12px;
    height: 12px;
    background: var(--bd-bubble);
    transform: rotate(45deg);
}

.bd-page .bd-tail-bl::after {
    bottom: -8px;
    left: 18px;
    border-bottom: 1.5px solid var(--bd-ink);
    border-left: 1.5px solid var(--bd-ink);
}

.bd-page .bd-tail-br::after {
    bottom: -8px;
    right: 18px;
    border-bottom: 1.5px solid var(--bd-ink);
    border-right: 1.5px solid var(--bd-ink);
}

.bd-page .bd-tail-tl::after {
    top: -8px;
    left: 18px;
    border-top: 1.5px solid var(--bd-ink);
    border-left: 1.5px solid var(--bd-ink);
}

.bd-page .bd-tail-tr::after {
    top: -8px;
    right: 18px;
    border-top: 1.5px solid var(--bd-ink);
    border-right: 1.5px solid var(--bd-ink);
}

@media (max-width: 560px) {
    .bd-page .bd-sheet {
        padding: 8px;
    }

    .bd-page .bd-grid {
        grid-template-columns: minmax(0, 1fr);
        gap: 8px;
    }

    .bd-page .bd-panel--large,
    .bd-page .bd-panel--banner {
        grid-column: auto;
    }

    .bd-page .bd-caption,
    .bd-page .bd-bubble {
        font-size: clamp(0.74rem, 3.4cqw, 0.95rem);
    }
}
