    /* Overlay plein écran */
    .preloader {
        position: fixed;
        inset: 0;
        z-index: 9999;
        display: grid;
        place-items: center;
        background: #fff;
        color: #000;
        text-align: center;
    }

    .preloader--hide {
        display: none;
    }

    /* Spinner (supprimé pour E-ink) */
    .preloader__spinner {
        display: none;
    }

    .preloader__txt {
        margin-top: 12px;
        font: bold 20px system-ui, -apple-system, sans-serif;
    }

    /* Optionnel: éviter le scroll tant que le loader est visible */
    html.preloading,
    body.preloading {
        overflow: hidden;
    }

    :root {
        --b: #000;
    }

    #status {
        position: fixed;
        top: 52px;
        left: 50%;
        transform: translateX(-50%);
        text-align: center;
        background-color: #ffffff;
        border: 3px solid #000000;
        color: #000000;
        padding: 8px 18px;
        border-radius: 4px;
        z-index: 10000;
        font-weight: bold;
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
        font-size: 15px;
    }

    body {
        font: 16px/1.5 system-ui, -apple-system, Segoe UI, Roboto, Arial;
        margin: 0;
        background-color: #fff;
        color: #000;
    }

    .toolbar {
        display: flex;
        flex-wrap: wrap;
        gap: 12px;
        margin: 0 auto 24px;
        max-width: 900px;
    }

    .toolbar button {
        padding: 12px 20px;
        border: 2px solid #000;
        background: #fff;
        cursor: pointer;
        margin: auto;
        font-weight: bold;
        font-size: 16px;
    }

    .wrap,
    #pages {
        width: 100%;
        max-width: 960px;
        margin: 0 auto;
        padding: 8px 12px 8px 54px;
        box-sizing: border-box;
    }

    /* Une page A4/Feuille centrée proprement (max-width 960px pour ne pas déformer le canvas) */
    .page {
        width: 100%;
        max-width: 960px;
        min-height: 260mm;
        margin: 0 auto 20px;
        border: 2px solid #000;
        padding: 12mm 8mm;
        background: #fff;
        box-sizing: border-box;
        scroll-margin-top: 96px;
        content-visibility: auto;
        contain-intrinsic-size: 800px;
    }

    .page h1 {
        font-size: 18px;
        text-align: center;
        margin: 0px;
        font-weight: bold;
    }

    .grid {
        width: 100%;
        border-collapse: collapse;
    }

    .grid th,
    .grid td {
        border: 2px solid var(--b);
        vertical-align: top;
    }

    .grid th {
        background: #fff;
        padding: 8px;
        border-bottom: 3px solid #000;
    }

    .grid td {
        padding: 12px;
    }

    .gauche {
        width: 65%;
    }

    .droite {
        width: 35%;
    }

    .sstitre {
        text-align: center;
        font-weight: 800;
        margin-bottom: 8px;
        text-decoration: underline;
    }

    [contenteditable="true"] {
        outline: 2px solid transparent;
        min-height: 25px;
    }

    [contenteditable="true"]:focus {
        outline: 3px solid #000;
        background: #fff;
    }

    .page-controls {
        display: flex;
        gap: 10px;
        justify-content: flex-end;
        margin: 12px 0 0;
    }

    .page-controls button {
        font-size: 14px;
        padding: 10px 15px;
        border: 2px solid #000;
        background: #fff;
        font-weight: bold;
    }

    @media print {
        @page {
            size: A4;
            margin: 12mm;
        }

        body {
            margin: 0;
            background-color: white;
        }

        .toolbar,
        .page-controls {
            display: none !important;
        }

        .page {
            border: none;
            margin: 0;
            page-break-after: always;
            width: auto;
            min-height: auto;
            padding: 0;
        }

        .noprint {
            display: none !important;
        }

        tr.noprint,
        thead.noprint {
            display: none !important;
            visibility: collapse !important;
        }
    }

    /* MODIFICATION*/

    /* === Styles généraux adaptatifs === */
    body,
    html {
        margin: 0;
        padding: 0;
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }

    .wrap {
        width: 100%;
        max-width: 960px;
        box-sizing: border-box;
    }

    /* Les pages s'adaptent à l'écran tout en gardant des proportions stables */
    .page {
        width: 100%;
        max-width: 960px;
        margin: 0 auto 20px;
        box-sizing: border-box;
    }

    /* Les tableaux */
    table.grid {
        width: 100%;
        border-collapse: collapse;
        table-layout: auto;
        word-wrap: break-word;
    }

    table.grid th,
    table.grid td {
        padding: 8px;
        text-align: left;
        font-size: 15px;
    }

    /* Images responsives */
    img {
        max-width: 100%;
        height: auto;
        display: block;
    }

    /* === Responsive spécifique pour téléphone === */
    @media (max-width: 768px) {
        .toolbar {
            display: flex;
            flex-wrap: wrap;
            gap: 10px;
        }

        .toolbar button {
            flex: 1 1 45%;
            font-size: 16px;
            padding: 12px;
        }

        table.grid th,
        table.grid td {
            font-size: 14px;
        }

        h1.titre {
            font-size: 20px;
            text-align: center;
        }

        .page {
            padding: 12mm 0;
        }
    }

    #app-header {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        background-color: #000;
        color: white;
        font-size: 1.2em;
        font-weight: bold;
        padding: 12px;
        text-align: center;
        z-index: 1000;
    }

    body.has-app-header {
        margin-top: 60px;
    }

    /* canvas*/
    .editable-wrapper {
        position: relative;
        display: inline-block;
        width: 100%;
        touch-action: none !important;
    }

    .editable-canvas {
        position: absolute;
        top: 0;
        left: 0;
        z-index: 10;
        touch-action: none !important;
        pointer-events: auto;
    }

    .clear-btn {
        position: absolute;
        top: 4px;
        right: 4px;
        z-index: 20;
        background: #fff;
        border: 2px solid #000;
        cursor: pointer;
        font-size: 18px;
        opacity: 1;
        padding: 5px;
    }

    .nav-btn {
        background: none;
        border: 2px solid #000;
        font-size: 1.2em;
        cursor: pointer;
        margin: 0 5px;
        padding: 5px 10px;
        background: #fff;
    }

    /* ===============================
   ALIGNEMENT TEXTE + CANVAS
   =============================== */
    .editable-wrapper {
        position: relative;
        width: 100%;
        display: block;
        box-sizing: border-box;
        vertical-align: top;
        touch-action: none !important;
        -webkit-touch-callout: none !important;
        -webkit-user-select: none !important;
        user-select: none !important;
    }

    /* zone texte */
    .editable-zone {
        position: relative;
        z-index: 1;
        width: 100%;
        box-sizing: border-box;
        padding: 8px;
        background: transparent;
        overflow-wrap: break-word;
    }

    .editable-canvas {
        position: absolute;
        top: 0;
        left: 0;
        z-index: 3;
        width: 100%;
        height: 100%;
        pointer-events: auto;
        touch-action: none !important;
        display: block;
        cursor: crosshair;
        -webkit-touch-callout: none !important;
        -webkit-user-select: none !important;
        user-select: none !important;
    }

    .nav-btn,
    .btn-save-custom,
    .btn-undo-custom,
    .tool-btn {
        background: #ffffff;
        border: 2px solid #000000;
        border-radius: 6px;
        color: #000000;
        cursor: pointer;
        font-size: 1.1rem;
        font-weight: bold;
        padding: 4px 8px;
        margin: 0 3px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        user-select: none;
        -webkit-user-select: none;
        touch-action: manipulation;
        transition: background 0.15s ease;
    }
    .nav-btn:hover, .nav-btn:active,
    .btn-save-custom:hover, .btn-save-custom:active,
    .btn-undo-custom:hover, .btn-undo-custom:active,
    .tool-btn:hover, .tool-btn:active {
        background: #e0e0e0;
    }

    #sw-cache-info,
    #pending-info {
        position: fixed;
        bottom: 8px;
        font-size: 12px;
        background: #fff;
        color: #000;
        padding: 5px 10px;
        border: 3px solid #000;
        z-index: 9999;
        font-weight: bold;
    }

    #sw-cache-info {
        left: 8px;
    }

    #pending-info {
        right: 8px;
        pointer-events: none;
    }

    /* === Boutons des en-têtes de chapitre (Même taille 32px que le bandeau haut) === */
    .toolbar button,
    .page-controls button,
    .clear-btn,
    .nav-btn,
    .tool-btn,
    .btn-save-custom,
    .page h1 button {
        width: auto !important;
        max-width: none !important;
        height: 32px !important;
        min-height: 32px !important;
        max-height: 32px !important;
        min-width: 32px !important;
        padding: 0 10px !important;
        font-size: 14px !important;
        font-weight: bold !important;
        border: 2px solid #000000 !important;
        border-radius: 6px !important;
        background: #ffffff !important;
        color: #000000 !important;
        cursor: pointer;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        vertical-align: middle !important;
        margin: 0 3px !important;
        box-sizing: border-box !important;
        user-select: none;
        -webkit-user-select: none;
    }

    .tool-btn.active {
        background: #000000 !important;
        color: #ffffff !important;
    }

    .onyx-btn {
        width: 32px !important;
        height: 32px !important;
        min-width: 32px !important;
        min-height: 32px !important;
        padding: 0 !important;
        font-size: 16px !important;
        font-family: system-ui, -apple-system, sans-serif !important;
        font-weight: bold !important;
        border: 2px solid #000000 !important;
        border-radius: 4px !important;
        margin: 0 !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        cursor: pointer;
        background: #ffffff !important;
        color: #000000 !important;
    }

    /* Bouton actif du bandeau vertical : couleurs inversées */
    .onyx-btn.active {
        background: #000000 !important;
        color: #ffffff !important;
        border-color: #000000 !important;
    }

    /* Pour éviter que le wrapper "étire" le contenu de la cellule */
    td .editable-wrapper {
        display: block;
        width: 100%;
        position: relative;
    }

    /* === Onyx Dock Floating Bar (Bandeau vertical en haut à gauche sous le bandeau des chapitres) === */
    .onyx-floating-dock {
        position: fixed;
        top: 94px;
        left: 4px;
        transform: none;
        z-index: 9990;
        background: #ffffff;
        border: 2px solid #000000;
        border-radius: 6px;
        padding: 4px;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 4px;
        box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.2);
        max-height: calc(100vh - 104px);
        overflow-y: auto;
    }

    .onyx-dock-group {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 4px;
        border-bottom: 2px solid #000;
        padding-bottom: 4px;
        margin-bottom: 2px;
        width: 100%;
    }
    .onyx-dock-group:last-child {
        border-bottom: none;
        padding-bottom: 0;
        margin-bottom: 0;
    }

    .color-swatch {
        width: 28px;
        height: 28px;
        border-radius: 50%;
        border: 2px solid #000;
        cursor: pointer;
        display: inline-block;
        margin: 0 3px;
        vertical-align: middle;
    }
    .color-swatch.active {
        outline: 3px solid #000;
        outline-offset: 2px;
    }

    .thickness-btn {
        font-size: 14px !important;
        padding: 6px 10px !important;
        min-width: 38px !important;
        min-height: 38px !important;
    }

    /* Body top offset for fixed navbar */
    body {
        padding-top: 52px !important;
    }

    /* === Bandeau supérieur des classes (Navigation Onyx / E-Ink / Web) === */
    .class-navbar {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        width: 100%;
        height: 48px;
        z-index: 9999;
        background: #ffffff;
        border-bottom: 2px solid #000000;
        padding: 0 16px;
        display: flex;
        align-items: center;
        gap: 12px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
        white-space: nowrap;
        overflow-x: auto;
        box-sizing: border-box;
    }

    .class-navbar-label {
        font-weight: bold;
        font-size: 15px;
        color: #000000;
        flex-shrink: 0;
        display: flex;
        align-items: center;
        gap: 4px;
    }

    .class-navbar-buttons {
        display: flex;
        align-items: center;
        gap: 6px;
        flex-wrap: nowrap;
    }

    .class-nav-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 4px 14px;
        font-size: 14px;
        font-weight: bold;
        color: #000000;
        background: #ffffff;
        border: 2px solid #000000;
        text-decoration: none;
        cursor: pointer;
        height: 32px;
        user-select: none;
        -webkit-user-select: none;
        border-radius: 6px;
        box-sizing: border-box;
        transition: background 0.15s ease, color 0.15s ease;
    }

    .class-nav-btn:hover {
        background: #e2e8f0;
        color: #000000;
    }

    .class-nav-btn.active {
        background: #000000 !important;
        color: #ffffff !important;
        border-color: #000000 !important;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    }

    .settings-btn {
        margin-left: auto;
        font-size: 16px;
        line-height: 1;
        padding: 0;
        height: 32px;
        width: 32px;
        min-width: 32px;
        flex-shrink: 0;
        box-sizing: border-box;
        border-radius: 6px;
        background: #ffffff;
        border: 2px solid #000000;
        color: #000000;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        transition: background 0.15s ease, color 0.15s ease;
    }

    .readonly-badge {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 4px;
        height: 32px;
        padding: 0 10px;
        border-radius: 6px;
        border: 2px solid #000000;
        background: #000000;
        color: #ffffff;
        font-size: 13px;
        font-weight: bold;
        flex-shrink: 0;
        white-space: nowrap;
        animation: readonly-pulse 1.4s ease-in-out infinite;
        cursor: default;
        user-select: none;
    }

    @keyframes readonly-pulse {
        0%, 100% { opacity: 1; }
        50% { opacity: 0.45; }
    }

    body {
        padding-top: 96px !important;
    }

    /* === Bandeau inférieur des chapitres === */
    .chapter-navbar {
        position: fixed;
        top: 48px;
        left: 0;
        right: 0;
        width: 100%;
        height: 40px;
        z-index: 9998;
        background: #f8fafc;
        border-bottom: 2px solid #000000;
        padding: 0 16px;
        display: flex;
        align-items: center;
        gap: 8px;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
        white-space: nowrap;
        overflow-x: auto;
        box-sizing: border-box;
    }

    .chapter-navbar-label {
        font-weight: bold;
        font-size: 13px;
        color: #000000;
        flex-shrink: 0;
        display: flex;
        align-items: center;
        gap: 4px;
    }

    .chapter-navbar-buttons {
        display: flex;
        align-items: center;
        gap: 6px;
        flex-wrap: nowrap;
    }

    .chapter-nav-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 32px;
        height: 28px;
        padding: 0 10px;
        font-size: 13px;
        font-weight: bold;
        color: #000000;
        background: #ffffff;
        border: 2px solid #000000;
        border-radius: 6px;
        cursor: pointer;
        text-decoration: none;
        user-select: none;
        -webkit-user-select: none;
        transition: background 0.15s ease, color 0.15s ease;
    }

    .chapter-nav-btn:hover {
        background: #e2e8f0;
        color: #000000;
    }

    .chapter-nav-btn.active {
        background: #000000 !important;
        color: #ffffff !important;
        border-color: #000000 !important;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
    }

    @media print {
        body {
            padding-top: 0 !important;
        }
        .onyx-floating-dock,
        .class-navbar,
        .chapter-navbar,
        .noprint,
        .nav-btn,
        .nav-prev,
        .nav-next,
        .btn-save-custom,
        .tool-btn,
        .clear-btn,
        #status,
        #sw-cache-info,
        #pending-info {
            display: none !important;
        }
    }

    .editing-locked {
        user-select: none;
        cursor: wait !important;
        opacity: 0.85;
    }