/* ================== VARIABLES & RESET ================== */
:root {
    --bg-color: #f4f7f6;
    --text-color: #111111;
    --header-bg: #ffffff;
    --primary-color: #0056b3;
    --secondary-color: #e67e22;
    --danger-color: #e74c3c;
    --danger-hover: #c0392b;
    --border-color: #cccccc;
    --overlay-color: rgba(0, 0, 0, 0.65);
    --workspace-bg: #e2e6e9;
    --a4-bg: #ffffff;
    --a4-shadow: rgba(0, 0, 0, 0.15);
    --toast-bg: #111111;
    --toast-text: #ffffff;
    --fab-push: 0px;
    --header-height: 72px;
    --footer-height: 60px;
    --fab-size: 65px;
    --fab-gap: 15px;
    --editor-side-padding: 290px;
    --page-gap: 40px;
}

[data-theme="dark"] {
    --bg-color: #121212;
    --text-color: #ffffff;
    --header-bg: #1e1e1e;
    --primary-color: #3a86ff;
    --secondary-color: #f39c12;
    --danger-color: #ff6b6b;
    --danger-hover: #e74c3c;
    --border-color: #333333;
    --workspace-bg: #0a0a0a;
    --a4-bg: #1a1a1a;
    --a4-shadow: rgba(0, 0, 0, 0.8);
    --toast-bg: #3a86ff;
    --toast-text: #ffffff;
}

* {
    box-sizing: border-box;
    font-family: 'Arial', sans-serif;
    margin: 0;
    padding: 0;
    border-radius: 0 !important;
    -webkit-tap-highlight-color: transparent;
}

html {
    margin: 0;
    padding: 0;
    background-color: var(--bg-color);
    font-size: 14px;
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
    /* ❌ PAS de height: 100% ni overscroll-behavior ici */
}

.hidden-view { display: none !important; }

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    /* ✅ overflow-x hidden seulement, on laisse le Y au navigateur */
    overflow-x: hidden;
    /* ❌ PLUS de overscroll-behavior-y: contain — c'était lui qui bloquait la molette */
    padding-top: env(safe-area-inset-top);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

/* ================== FIX MOBILE GLOBAL ================== */
button, .btn-header, .btn-modal, .btn-login, .btn-create-small, .btn-save,
.btn-action, .btn-cancel, .btn-confirm, .context-btn, .nav-btn,
.module-card-mini, .btn-table-edit, .btn-remove-mv, .btn-remove-module {
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
}

.drawer-content,
.modal-content,
.share-users-list-container,
.table-responsive,
.admin-content {
    -webkit-overflow-scrolling: touch;
}

@supports (padding: max(0px)) {
    header, .site-footer, .editor-toolbar {
        padding-left: max(15px, env(safe-area-inset-left));
        padding-right: max(15px, env(safe-area-inset-right));
    }
}

img, canvas, svg { max-width: 100%; }

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[contenteditable="true"]:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.cell-content-area,
.module-textarea,
.module-titling-input {
    touch-action: manipulation;
}

/* ================== VUES GLOBALES ================== */
#home-view {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

header {
    background-color: var(--header-bg);
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--border-color);
    z-index: 3000;
    gap: 20px;
    flex-wrap: wrap;
}

.logo-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    flex-shrink: 0;
}

.logo {
    height: 40px;
    width: auto;
    object-fit: contain;
    margin-bottom: 4px;
}

.subtitle {
    font-size: 0.75rem;
    font-weight: bold;
    color: var(--primary-color);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.sync-status-offline {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: bold;
    font-size: 0.85rem;
    color: #aaaaaa;
    margin-right: 15px;
    user-select: none;
}

.btn-header {
    padding: 10px 15px;
    font-size: 0.9rem;
    font-weight: bold;
    cursor: pointer;
    border: 2px solid var(--text-color);
    background-color: transparent;
    color: var(--text-color);
    transition: background-color 0.2s, color 0.2s, transform 0.1s;
    outline: none;
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-header:hover {
    background-color: var(--text-color);
    color: var(--header-bg);
}

.btn-header:active { transform: scale(0.97); }

.lang-selector-container { position: relative; }

#lang-menu {
    top: calc(100% + 5px);
    right: 0;
    width: 160px;
}

main {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
}

/* ================== TOP ACTIONS / DRIVE ================== */
.top-actions {
    padding: 30px 40px 0;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    background: transparent;
}

.btn-create-small {
    display: flex;
    align-items: center;
    gap: 10px;
    background-color: var(--primary-color);
    color: #fff;
    padding: 14px 26px;
    font-weight: bold;
    font-size: 1.05rem;
    border: none;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.btn-create-small:hover {
    background-color: var(--text-color);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.drive-section {
    padding: 40px;
    background-color: var(--bg-color);
    min-height: 40vh;
}

.drive-section h2 {
    font-size: 1.8rem;
    font-weight: 900;
    letter-spacing: 1px;
    margin-bottom: 25px;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 10px;
}

.reports-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.report-card {
    display: flex;
    flex-direction: column;
    background-color: var(--header-bg);
    border: 2px solid var(--border-color);
    padding: 25px;
    cursor: pointer;
    transition: border-color 0.2s, background-color 0.2s, transform 0.2s, box-shadow 0.2s;
    user-select: none;
    position: relative;
    padding-bottom: 35px;
}

.report-card:hover {
    border-color: var(--text-color);
    background-color: rgba(0, 0, 0, 0.02);
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
}

[data-theme="dark"] .report-card:hover { background-color: rgba(255, 255, 255, 0.05); }

.report-offline { background-color: var(--workspace-bg); border-style: dashed; opacity: 0.85; }
[data-theme="dark"] .report-offline { background-color: #1a1a1a; }

.report-conflict {
    border-color: var(--danger-color) !important;
    box-shadow: 0 0 15px rgba(231, 76, 60, 0.5);
    animation: pulse-red 2.5s infinite;
}

@keyframes pulse-red {
    0% { box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.6); }
    70% { box-shadow: 0 0 0 10px rgba(231, 76, 60, 0); }
    100% { box-shadow: 0 0 0 0 rgba(231, 76, 60, 0); }
}

.report-icon {
    display: inline-block;
    align-self: flex-start;
    background-color: var(--text-color);
    color: var(--bg-color);
    padding: 5px 10px;
    font-weight: 900;
    font-size: 0.9rem;
    margin-bottom: 15px;
    letter-spacing: 1px;
}

.report-name {
    font-size: 1.2rem;
    font-weight: bold;
    margin-bottom: 10px;
    word-break: break-word;
}

.report-date {
    font-size: 0.9rem;
    color: #777777;
    font-weight: bold;
}

.report-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
}

.sync-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999999;
}

/* ================== VUE ÉDITEUR ================== */
#editor-view {
    /* ✅ IMPORTANT : c'est un conteneur flex dans le body qui scrolle */
    display: flex;
    flex-direction: row;
    align-items: stretch;
    width: 100%;
}

.editor-main-area {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-width: 0;
    /* Pas de min-height / overflow → le body gère le scroll */
}

/* ✅ Toolbar sticky : elle scrolle avec la page puis se bloque en haut */
.editor-toolbar {
    background-color: var(--header-bg);
    padding: 12px 25px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 2px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 2500;
    flex-wrap: wrap;
    /* petite ombre quand elle est "collée" en haut */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.editor-doc-title-input {
    font-size: 1.1rem;
    font-weight: 900;
    letter-spacing: 0.5px;
    color: var(--text-color);
    background: transparent;
    border: 1px dashed transparent;
    padding: 8px 12px;
    flex: 1 1 200px;
    min-width: 0;
    outline: none;
    transition: border-color 0.2s, background-color 0.2s;
}

.editor-doc-title-input:hover { border-color: var(--border-color); }
.editor-doc-title-input:focus {
    border-color: var(--primary-color) !important;
    border-style: solid;
    background-color: rgba(0, 0, 0, 0.02);
}
[data-theme="dark"] .editor-doc-title-input:focus { background-color: rgba(255, 255, 255, 0.05); }

.editor-toolbar-actions {
    display: flex;
    gap: 8px;
    margin-left: auto;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.btn-save { background-color: var(--primary-color); color: #ffffff; border-color: var(--primary-color); }
.btn-save:hover { background-color: var(--text-color); border-color: var(--text-color); }

/* ================== WORKSPACE / PAGE A4 ================== */
.editor-workspace {
    background-color: var(--workspace-bg);
    padding: 40px 20px 150px 20px;
    text-align: center;
    position: relative;
}

.pages-container {
    display: inline-flex;
    flex-direction: column;
    gap: var(--page-gap);
    text-align: left;
    align-items: center;
    vertical-align: top;
}

.a4-page {
    background-color: var(--a4-bg);
    width: 210mm !important;
    min-height: 297mm !important;
    max-height: 297mm !important;
    flex-shrink: 0;
    box-shadow: 0 10px 30px var(--a4-shadow) !important;
    padding: 24mm 20mm 22mm 20mm !important;
    display: flex;
    flex-direction: column;
    gap: 10px;
    position: relative;
    overflow: visible !important;
    margin: 0 auto;
}
.a4-page.cover-page {
    padding: 15mm 20mm 20mm 20mm !important;
}

.page-running-header {
    position: absolute;
    top: 6mm;
    left: 20mm;
    right: 20mm;
    height: 14mm;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 2mm;
    user-select: none;
    pointer-events: none;
    gap: 10px;
}
.page-running-header img {
    height: 10mm;
    max-height: 36px;
    width: auto;
    object-fit: contain;
}
.page-running-header-title,
.page-running-header-addresses {
    font-size: 0.65rem;
    color: var(--text-color);
    text-align: center;
    line-height: 1.25;
    flex: 1;
}

.page-running-footer {
    position: absolute;
    bottom: 8mm;
    left: 20mm;
    right: 20mm;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-top: 1px solid var(--border-color);
    padding-top: 2mm;
    font-size: 0.82rem;
    font-weight: bold;
    color: var(--text-color);
    user-select: none;
    pointer-events: none;
}

.page-running-footer-mention {
    font-size: 0.82rem;
    font-weight: bold;
    color: var(--text-color);
    white-space: nowrap;
}

.page-running-footer-info {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-color);
    text-align: center;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.page-running-footer-num {
    font-size: 0.82rem;
    font-weight: bold;
    color: var(--text-color);
    white-space: nowrap;
}

.cover-cif-logo {
    height: 48px;
    width: auto;
    object-fit: contain;
    flex-shrink: 0;
}

/* ================== STYLES D'EXPORT PDF ================== */
.pdf-export-mode .pages-container {
    zoom: 1 !important;
    transform: none !important;
}
.pdf-export-mode .a4-page {
    zoom: 1 !important;
    transform: none !important;
    box-shadow: none !important;
    margin: 0 !important;
}
.pdf-export-mode .inserted-module {
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
}
.pdf-export-mode .visual-dropzone {
    border: none !important;
}
.pdf-export-mode .module-titling-input.level-h1,
.pdf-export-mode div.module-titling-input.level-h1 {
    color: #ffffff !important;
    background-color: var(--primary-color) !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
}
.pdf-export-mode .module-titling-input.level-h2,
.pdf-export-mode div.module-titling-input.level-h2 {
    color: var(--primary-color) !important;
}
.pdf-export-mode .module-titling-input.level-h3,
.pdf-export-mode div.module-titling-input.level-h3 {
    text-decoration: underline !important;
}
.pdf-export-mode button,
.pdf-export-mode .module-controls,
.pdf-export-mode .action-cell,
.pdf-export-mode .btn-table-action,
.pdf-export-mode .btn-table-action-danger,
.pdf-export-mode .btn-table-edit,
.pdf-export-mode .btn-remove-mv,
.pdf-export-mode .btn-remove-mv-pair,
.pdf-export-mode .btn-add-mv,
.pdf-export-mode .btn-add-mv-custom,
.pdf-export-mode .btn-add-roulement-subline,
.pdf-export-mode .btn-remove-roulement-subline,
.pdf-export-mode .btn-add-pignon-pt,
.pdf-export-mode .btn-remove-pignon-pt,
.pdf-export-mode .add-btn-row-pignon,
.pdf-export-mode .add-photo-block,
.pdf-export-mode .btn-remove-photo,
.pdf-export-mode .btn-remove-alesage-mv,
.pdf-export-mode .add-btn-row-alesage,
.pdf-export-mode .btn-remove-comment,
.pdf-export-mode .add-mv-wrapper,
.pdf-export-mode .add-btn-row,
.pdf-export-mode .cell-img-btn,
.pdf-export-mode .upload-icon,
.pdf-export-mode .niveau-side-actions,
.pdf-export-mode .niveau-row-actions,
.pdf-export-mode .niveau-side-btn {
    display: none !important;
    visibility: hidden !important;
}

.pdf-export-mode table,
.pdf-export-mode th,
.pdf-export-mode td {
    border-width: 1px !important;
}
.pdf-export-mode .custom-table th,
.pdf-export-mode .custom-table td,
.pdf-export-mode .denture-table th,
.pdf-export-mode .denture-table td {
    border: 1px solid #777 !important;
}

/* ================== WYSIWYG RELEVÉ DES NIVEAUX EN PDF ================== */
.pdf-export-mode .niveau-mid-col .niveau-cell-inner {
    transform: none !important;
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}
.pdf-export-mode .niveau-col-right .niveau-cell-inner {
    flex-direction: row-reverse !important;
}
.pdf-export-mode .niveau-mid-col .niveau-cell-inner .niveau-input.niveau-value {
    width: 44px !important;
    min-width: 44px !important;
    max-width: 44px !important;
    height: 24px !important;
    font-size: 0.85rem !important;
    text-align: center !important;
    box-sizing: border-box !important;
    margin: 0 !important;
}
.pdf-export-mode .niveau-mid-col .niveau-cell-inner .niveau-arrow {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 14px !important;
    height: 38px !important;
    flex-shrink: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
}
.pdf-export-mode .niveau-mid-col .niveau-cell-inner .niveau-arrow canvas {
    display: block !important;
    width: 14px !important;
    height: 38px !important;
    flex-shrink: 0 !important;
}
.pdf-export-mode .niveau-triangle {
    display: none !important;
}

.temp-drag-page {
    opacity: 0.4;
    border: 2px dashed var(--primary-color) !important;
    transform: scale(0.98);
    transition: opacity 0.2s ease, transform 0.2s ease;
}
[data-theme="dark"] .temp-drag-page { opacity: 0.3; }

.page-number {
    position: absolute;
    bottom: 8mm;
    right: 20mm;
    font-size: 0.85rem;
    font-weight: bold;
    color: var(--text-color);
    user-select: none;
    pointer-events: none;
}

/* ================== MODULES ================== */
.inserted-module {
    position: relative;
    width: 100%;
    display: flex;
    flex-direction: column;
    cursor: text;
    page-break-inside: avoid;
    break-inside: avoid;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.module-controls {
    position: absolute;
    left: -260px;
    top: 0;
    width: 240px;
    background: var(--header-bg);
    border: 2px solid var(--border-color);
    padding: 12px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    box-shadow: 2px 2px 0px rgba(0, 0, 0, 0.1);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    z-index: 50;
}
[data-theme="dark"] .module-controls { box-shadow: 2px 2px 0px rgba(0, 0, 0, 0.8); }

.inserted-module.is-focused .module-controls {
    opacity: 1;
    visibility: visible;
}

.drag-handle {
    cursor: grab;
    color: #999999;
    padding-right: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.drag-handle:active { cursor: grabbing; color: var(--primary-color); }

.mobile-move-btns {
    display: none;
    flex-direction: column;
    gap: 4px;
    padding-right: 15px;
}
.mobile-move-btns button {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-color);
    padding: 4px 10px;
    font-size: 0.75rem;
    cursor: pointer;
    min-width: 32px;
}

.module-controls-left {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    min-width: 0;
}

.module-title-label {
    font-weight: 900;
    font-size: 0.9rem;
    color: var(--text-color);
}

.btn-remove-module {
    background: var(--danger-color);
    color: #ffffff;
    border: none;
    padding: 4px 10px;
    cursor: pointer;
    font-weight: bold;
    font-size: 0.9rem;
    transition: background-color 0.2s;
    margin-left: 10px;
    flex-shrink: 0;
}
.btn-remove-module:hover { background-color: var(--danger-hover); }

.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.module-content { width: 100%; flex-grow: 1; }

.inserted-module.is-focused .module-content textarea,
.inserted-module.is-focused .module-content input { background-color: rgba(0, 0, 0, 0.02); }
[data-theme="dark"] .inserted-module.is-focused .module-content textarea,
[data-theme="dark"] .inserted-module.is-focused .module-content input { background-color: rgba(255, 255, 255, 0.05); }

.inserted-module.dragging { opacity: 0.4; transform: scale(0.98); }

/* --- MODULES CONTENU --- */
.cover-company-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border: 1px solid var(--border-color);
    padding: 10px;
    margin-bottom: 10px;
    background-color: transparent;
    gap: 15px;
    flex-wrap: nowrap;
}

.cover-logo-img { height: 45px; width: auto; object-fit: contain; flex-shrink: 0; }

.cover-company-text {
    font-size: 0.7rem;
    line-height: 1.3;
    color: var(--text-color);
    flex: 1;
    min-width: 120px;
}

.cover-main-title {
    border: 1px solid var(--border-color);
    padding: 8px 10px;
    text-align: center;
    margin-bottom: 10px;
}
.cover-main-title strong,
.cover-main-title-input {
    font-size: 1.2rem;
    font-weight: 900;
    color: var(--primary-color);
    text-transform: uppercase;
    letter-spacing: 1px;
    width: 100%;
    text-align: center;
    border: none;
    background: transparent;
    outline: none;
    font-family: inherit;
}

.module-cover-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.module-cover-table td {
    border: 1px solid var(--border-color);
    padding: 8px;
    vertical-align: top;
    word-wrap: break-word;
}

.cover-field { display: flex; flex-direction: column; gap: 4px; }
.cover-field strong { color: var(--primary-color); font-size: 0.85rem; text-transform: uppercase; }
.cover-field input {
    width: 100%;
    border: none;
    border-bottom: 1px dashed transparent;
    background: transparent;
    color: var(--text-color);
    font-family: inherit;
    font-size: 1rem;
    outline: none;
    padding: 4px 0;
    transition: background-color 0.2s, border-color 0.2s;
}
.cover-field input:focus {
    background-color: rgba(0, 0, 0, 0.05);
    border-bottom: 1px solid var(--primary-color);
}
[data-theme="dark"] .cover-field input:focus { background-color: rgba(255, 255, 255, 0.1); }

.cover-header {
    background-color: var(--border-color);
    text-align: center;
    vertical-align: middle !important;
    padding: 10px !important;
}
[data-theme="dark"] .cover-header { background-color: #333333; }
.cover-header strong {
    margin: 0;
    color: var(--text-color);
    font-size: 1rem;
    text-transform: uppercase;
}
.cover-textarea-cell { padding: 0 !important; }
.cover-textarea {
    width: 100%;
    min-height: 100px;
    resize: none;
    border: none;
    background-color: transparent;
    color: var(--text-color);
    font-family: inherit;
    font-size: 1rem;
    line-height: 1.5;
    outline: none;
    padding: 10px;
}
.cover-textarea:focus { background-color: rgba(0, 0, 0, 0.02); }
[data-theme="dark"] .cover-textarea:focus { background-color: rgba(255, 255, 255, 0.05); }
.cover-photo-cell { 
    padding: 0 !important; 
    height: 180px !important; 
    max-height: 180px !important; 
    width: 50% !important; 
    max-width: 50% !important; 
    overflow: hidden !important; 
    vertical-align: middle !important;
}
.cover-photo-cell .visual-dropzone { 
    height: 180px !important; 
    max-height: 180px !important; 
    min-height: 180px !important; 
    width: 100% !important; 
    border: none; 
    background-color: transparent; 
    overflow: hidden !important; 
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}
.cover-photo-cell .uploaded-image { 
    max-width: 100% !important; 
    max-height: 180px !important; 
    width: auto !important; 
    height: auto !important; 
    object-fit: contain !important; 
    display: block !important; 
    margin: auto !important;
}
.cover-photo-cell .visual-dropzone:hover { background-color: rgba(0, 0, 0, 0.05); }
[data-theme="dark"] .cover-photo-cell .visual-dropzone:hover { background-color: rgba(255, 255, 255, 0.08); }

.module-textarea {
    width: 100%;
    min-height: 55px;
    resize: none;
    border: 1px dashed transparent;
    background-color: transparent;
    color: var(--text-color);
    padding: 6px 8px;
    font-size: 1rem;
    font-family: inherit;
    line-height: 1.4;
    outline: none;
    transition: border-color 0.2s, background-color 0.2s;
    overflow: hidden;
}
.inserted-module.is-focused .module-textarea { border-color: var(--border-color); }
.module-textarea:focus {
    border-color: var(--primary-color) !important;
    border-style: solid;
}

.module-titling-container { display: flex; flex-direction: column; gap: 5px; width: 100%; }
.module-titling-select {
    width: 100%;
    padding: 6px 10px;
    font-size: 0.9rem;
    border: 1px solid var(--border-color);
    background-color: var(--bg-color);
    color: var(--text-color);
    outline: none;
    font-weight: bold;
    cursor: pointer;
}
.module-titling-input {
    width: 100%;
    border: 1px dashed transparent;
    background-color: transparent;
    color: var(--text-color);
    padding: 6px 10px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s, background-color 0.2s;
}
.inserted-module.is-focused .module-titling-input { border-color: var(--border-color); }
.module-titling-input:focus { border-color: var(--primary-color) !important; border-style: solid; }
.module-titling-input.level-h1 {
    font-size: 14pt;
    font-weight: bold;
    text-transform: uppercase;
    color: #ffffff !important;
    background-color: var(--primary-color) !important;
    padding: 6px 12px;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}
.module-titling-input.level-h1::placeholder {
    color: rgba(255, 255, 255, 0.75);
}
.module-titling-input.level-h2 {
    font-size: 12pt;
    font-weight: bold;
    text-transform: uppercase;
    color: var(--primary-color);
}
.module-titling-input.level-h3,
.standard-title,
.data-h3-title,
.visual-title {
    font-size: 11pt !important;
    font-weight: bold !important;
    font-style: normal !important;
    text-transform: none !important;
    text-decoration: underline !important;
    color: var(--text-color);
    padding: 6px 10px;
}
.module-titling-input.level-h4 {
    font-size: 11pt !important;
    font-weight: normal;
    font-style: italic;
    text-transform: none;
    text-decoration: none;
    color: var(--text-color);
}

/* Espacement accru entre les fins de paragraphes/modules et les titres */
.inserted-module + .inserted-module.module-type-titling,
.inserted-module + .inserted-module:has(.module-titling-container) {
    margin-top: 16px;
}

/* Titre "Commentaire :" agrandi et uniformisé */
.module-comment-title {
    font-size: 10.5pt;
    font-weight: bold;
    text-decoration: underline;
    color: var(--text-color);
    margin-top: 8px;
    margin-bottom: 6px;
}

.module-visual-container {
    display: flex;
    flex-direction: column !important;
    gap: 15px;
    width: 100%;
    align-items: stretch;
}
.visual-column { flex: 1; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.visual-header {
    background-color: var(--border-color);
    color: var(--text-color);
    font-weight: bold;
    text-align: center;
    padding: 8px;
    text-transform: uppercase;
}
[data-theme="dark"] .visual-header { background-color: #333333; }
.visual-dropzone {
    height: 250px;
    border: 2px dashed var(--border-color);
    background-color: rgba(0, 0, 0, 0.02);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: background-color 0.2s, border-color 0.2s;
}
[data-theme="dark"] .visual-dropzone { background-color: rgba(255, 255, 255, 0.02); }
.visual-dropzone:hover { background-color: rgba(0, 0, 0, 0.05); border-color: var(--primary-color); }
[data-theme="dark"] .visual-dropzone:hover { background-color: rgba(255, 255, 255, 0.08); }
.upload-icon { color: #999999; transition: color 0.2s, transform 0.2s; }
.visual-dropzone:hover .upload-icon { color: var(--primary-color); transform: scale(1.1); }
.uploaded-image { width: 100%; height: 100%; object-fit: contain; background-color: var(--a4-bg); }
.hidden-file-input { display: none; }
.visual-caption {
    width: 100%;
    min-height: 50px;
    resize: none;
    border: 1px dashed transparent;
    background-color: transparent;
    color: var(--text-color);
    padding: 10px;
    font-family: inherit;
    outline: none;
    overflow: hidden;
    transition: border-color 0.2s;
}
.inserted-module.is-focused .visual-caption { border-color: var(--border-color); }
.visual-caption:focus { border-color: var(--primary-color) !important; border-style: solid; }

.module-standard-container { display: flex; flex-direction: column; gap: 15px; width: 100%; }
.standard-title {
    width: 100%;
    border: 1px dashed transparent;
    background-color: transparent;
    color: var(--text-color);
    padding: 5px 10px;
    font-size: 11pt;
    font-weight: bold;
    font-style: normal;
    text-transform: none;
    text-decoration: underline;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}
.inserted-module.is-focused .standard-title { border-color: var(--border-color); }
.standard-title:focus { border-color: var(--primary-color) !important; border-style: solid; }
.standard-body { display: flex; flex-direction: row; gap: 20px; align-items: stretch; width: 100%; }
.standard-photo { flex: 0 0 45%; }
.standard-obs { flex: 1; display: flex; flex-direction: column; }
.standard-textarea {
    flex-grow: 1;
    width: 100%;
    min-height: 250px;
    resize: none;
    border: 1px dashed transparent;
    background-color: transparent;
    color: var(--text-color);
    padding: 10px;
    font-family: inherit;
    line-height: 1.5;
    outline: none;
    transition: border-color 0.2s;
    overflow: hidden;
}
.inserted-module.is-focused .standard-textarea { border-color: var(--border-color); }
.standard-textarea:focus { border-color: var(--primary-color) !important; border-style: solid; }

/* --- TABLEAU PERSONNALISABLE --- */
.custom-table { width: 100%; border-collapse: collapse; margin-top: 6px; table-layout: fixed; }
.custom-table td {
    border: 1px solid var(--border-color);
    position: relative;
    padding: 6px 8px;
    vertical-align: top;
    background: transparent;
    transition: background-color 0.2s;
    word-wrap: break-word;
    overflow-wrap: break-word;
}
.custom-table td .uploaded-image {
    max-width: 100% !important;
    height: auto !important;
    max-height: 220px;
    object-fit: contain;
    display: block;
    margin: 4px auto 0;
}
.custom-table td:hover { background-color: rgba(0, 0, 0, 0.02); }
[data-theme="dark"] .custom-table td:hover { background-color: rgba(255, 255, 255, 0.05); }

.cell-content-area {
    min-height: 28px;
    outline: none;
    line-height: 1.4;
    color: var(--text-color);
    font-size: 0.95rem;
}
.cell-content-area:empty:before { content: "Texte..."; color: #aaa; font-style: italic; }

.cell-img-btn {
    position: absolute;
    bottom: 4px;
    right: 4px;
    background: var(--primary-color);
    color: white;
    border-radius: 4px !important;
    padding: 4px;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}
.cell-img-btn:hover { background: var(--text-color); }
.custom-table td:hover .cell-img-btn,
.custom-table td:focus-within .cell-img-btn { opacity: 1; pointer-events: auto; }

.btn-table-edit {
    background: var(--bg-color);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    padding: 5px 9px;
    font-size: 0.8rem;
    cursor: pointer;
    font-weight: bold;
    border-radius: 4px !important;
    min-height: 32px;
}
.btn-table-edit:hover { background: var(--primary-color); color: white; border-color: var(--primary-color); }

/* --- TABLEAUX DENTURE / ROULEMENT --- */
.denture-table { width: 100%; border-collapse: collapse; margin-bottom: 12px; text-align: center; table-layout: fixed; }
.denture-table th, .denture-table td {
    border: 1px solid var(--border-color);
    padding: 6px;
    vertical-align: middle;
    word-wrap: break-word;
}
.denture-table th {
    background-color: #e2e6e9;
    color: var(--text-color);
    font-weight: bold;
}
[data-theme="dark"] .denture-table th { background-color: #333333; }
.denture-table th.col-obtenu { background-color: #a4c2f4; color: #000; }
[data-theme="dark"] .denture-table th.col-obtenu { background-color: #4a86e8; color: #fff; }

.denture-input {
    width: 100%;
    border: none;
    background: transparent;
    color: var(--text-color);
    text-align: center;
    font-family: inherit;
    font-size: 1rem;
    font-weight: bold;
    outline: none;
    padding: 5px;
}
.denture-input:focus { background-color: rgba(0, 0, 0, 0.05); }
[data-theme="dark"] .denture-input:focus { background-color: rgba(255, 255, 255, 0.1); }
.denture-mini, .roulement-mini, .roulement-maxi { font-weight: bold; }

td.status-green {
    background-color: #d4edda !important;
    transition: background-color 0.3s;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}
td.status-green .denture-input { color: #155724; }
td.status-red {
    background-color: #f8d7da !important;
    transition: background-color 0.3s;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}
td.status-red .denture-input { color: #721c24; }
[data-theme="dark"] td.status-green { background-color: #1e4620 !important; }
[data-theme="dark"] td.status-green .denture-input { color: #a3e4a7; }
[data-theme="dark"] td.status-red { background-color: #4a191c !important; }
[data-theme="dark"] td.status-red .denture-input { color: #ea868f; }

.action-cell { width: 40px; border: none !important; background: transparent !important; }

.add-btn-row td {
    border-left: none !important;
    border-right: none !important;
    border-top: 1px dashed transparent !important;
    border-bottom: 1px dashed transparent !important;
    background: transparent !important;
    padding: 10px 0 !important;
    height: 16px;
    cursor: pointer;
}
.add-btn-row:hover td {
    border-top: 1px solid var(--border-color) !important;
    background: rgba(0, 0, 0, 0.02) !important;
}

.add-mv-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 1;
    transition: opacity 0.2s;
    height: 16px;
    position: relative;
    z-index: 10;
}

.btn-add-mv, .btn-add-roulement {
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 50% !important;
    width: 28px;
    height: 28px;
    cursor: pointer;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: transform 0.1s;
}
.btn-add-mv:hover, .btn-add-roulement:hover { transform: scale(1.15); }
.btn-add-mv-custom {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 8px 20px;
    cursor: pointer;
    font-weight: bold;
    border-radius: 4px !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}
.btn-remove-mv, .btn-remove-mv-pair {
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: 50% !important;
    width: 28px;
    height: 28px;
    cursor: pointer;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: auto;
    transition: transform 0.1s;
}
.btn-remove-mv:hover, .btn-remove-mv-pair:hover { transform: scale(1.15); }

.smiley-na { display: none; font-weight: bold; font-size: 1.1rem; color: #555; }

/* ================== PASTILLE CREATEUR & PARTAGE ================== */
.creator-badge {
    position: absolute;
    bottom: 15px;
    right: 15px;
    width: 32px;
    height: 32px;
    border-radius: 50% !important;
    background-color: var(--primary-color);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    font-weight: 900;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.3);
    z-index: 10;
    cursor: help;
    transition: transform 0.2s;
}
.creator-badge:hover { transform: scale(1.1); }

.share-users-list-container {
    max-height: 300px;
    overflow-y: auto;
    text-align: left;
    margin-bottom: 20px;
    border: 2px solid var(--border-color);
    background-color: var(--workspace-bg);
    border-radius: 8px !important;
    padding: 5px;
}
[data-theme="dark"] .share-users-list-container { background-color: #111; }

.share-user-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    margin-bottom: 5px;
    border-radius: 6px !important;
    background-color: var(--header-bg);
    border: 1px solid var(--border-color);
    transition: border-color 0.2s, box-shadow 0.2s;
    gap: 10px;
    flex-wrap: wrap;
}
.share-user-row:hover { border-color: var(--primary-color); box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05); }
[data-theme="dark"] .share-user-row { background-color: #1e1e1e; }
.share-user-info { display: flex; flex-direction: column; flex: 1; min-width: 150px; }
.share-user-info strong { color: var(--text-color); font-size: 1.05rem; }
.share-user-accred {
    font-size: 0.75rem;
    color: #888;
    text-transform: uppercase;
    margin-top: 3px;
    font-weight: bold;
}
.share-role-select {
    padding: 8px 12px;
    border: 2px solid var(--border-color);
    border-radius: 6px !important;
    background: var(--bg-color);
    color: var(--text-color);
    font-weight: bold;
    outline: none;
    cursor: pointer;
    transition: border-color 0.2s;
    min-height: 40px;
}
.share-role-select:focus { border-color: var(--primary-color); }
.share-role-select[data-role="lecteur"] { border-color: #3498db; color: #3498db; }
.share-role-select[data-role="editeur"] { border-color: #e67e22; color: #e67e22; }
.share-search-input {
    width: 100%;
    padding: 12px 15px;
    margin-bottom: 15px;
    border: 2px solid var(--border-color);
    border-radius: 6px !important;
    background-color: var(--bg-color);
    color: var(--text-color);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}
.share-search-input:focus { border-color: var(--primary-color); }
[data-theme="dark"] .share-search-input { background-color: #1e1e1e; }

/* ================== FABs ================== */
.fab-plus, .fab-draw, .fab-pdf, .fab-mic, .fab-doc {
    position: fixed;
    width: var(--fab-size);
    height: var(--fab-size);
    border-radius: 50% !important;
    color: #ffffff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.4);
    z-index: 1000;
    transition: transform 0.2s, background-color 0.2s;
    transform: translateY(var(--fab-push, 0px));
    -webkit-tap-highlight-color: transparent;
}
.fab-plus:hover, .fab-draw:hover, .fab-pdf:hover, .fab-mic:hover, .fab-doc:hover {
    background-color: var(--text-color);
}
.fab-plus:active, .fab-draw:active, .fab-pdf:active, .fab-mic:active, .fab-doc:active {
    transform: translateY(var(--fab-push, 0px)) scale(0.95);
}

.fab-plus { bottom: 30px; right: 30px; background-color: var(--primary-color); font-size: 2.5rem; font-weight: bold; }
.fab-draw { bottom: 30px; right: calc(30px + var(--fab-size) + var(--fab-gap)); background-color: #27ae60; }
.fab-pdf { bottom: 30px; left: 30px; background-color: var(--secondary-color); font-size: 1.1rem; font-weight: bold; }
.fab-mic { bottom: 30px; left: calc(30px + var(--fab-size) + var(--fab-gap)); background-color: #8e44ad; font-size: 1.8rem; }
.fab-doc { bottom: 30px; left: calc(30px + var(--fab-size) + var(--fab-gap)); background-color: #34495e; }

body.hide-pdf-fab .fab-doc { left: 30px !important; }

/* ================== DRAWER ================== */
/* ✅ Sticky : reste fixé en haut de l'écran pendant tout le défilement de la page */
.drawer {
    align-self: flex-start;
    position: sticky;
    top: 0;
    right: 0;
    width: 0;
    height: 100vh;
    max-height: 100vh;
    background-color: var(--header-bg);
    border-left: 0px solid transparent;
    transition: width 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow: hidden;
}
[data-theme="dark"] .drawer { box-shadow: none; }
.drawer.open {
    width: 350px;
    border-left: 2px solid var(--border-color);
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.1);
}
[data-theme="dark"] .drawer.open { box-shadow: -10px 0 30px rgba(0, 0, 0, 0.8); }

.drawer-header {
    width: 100%;
    padding: 20px 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--border-color);
    background-color: var(--bg-color);
    gap: 15px;
}
.drawer-header h3 { margin: 0; font-size: 1.2rem; font-weight: 900; color: var(--text-color); }

.btn-close-drawer {
    background: none;
    border: 2px solid var(--text-color);
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--text-color);
    cursor: pointer;
    padding: 6px 14px;
    transition: background-color 0.2s, color 0.2s;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.btn-close-drawer:hover { background-color: var(--text-color); color: var(--bg-color); }

.drawer-content {
    width: 100%;
    padding: 20px;
    overflow-y: auto;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding-bottom: 100px;
}
.drawer-content::-webkit-scrollbar { width: 6px; }
.drawer-content::-webkit-scrollbar-track { background: transparent; }
.drawer-content::-webkit-scrollbar-thumb { background-color: var(--text-color); }

.module-card-mini {
    background-color: var(--bg-color);
    border: 2px solid var(--border-color);
    padding: 15px;
    font-size: 1.05rem;
    font-weight: bold;
    cursor: pointer;
    transition: border-color 0.2s, background-color 0.2s, transform 0.1s;
    min-height: 48px;
    display: flex;
    align-items: center;
}
.module-card-mini:hover {
    border-color: var(--primary-color);
    background-color: rgba(0, 0, 0, 0.03);
}
.module-card-mini:active { transform: scale(0.98); }
[data-theme="dark"] .module-card-mini:hover { background-color: rgba(255, 255, 255, 0.05); }

/* ================== CONTEXT MENUS ================== */
.custom-context-menu {
    position: absolute;
    background-color: var(--header-bg);
    border: 2px solid var(--text-color);
    box-shadow: 6px 6px 0px rgba(0, 0, 0, 0.2);
    z-index: 3500;
    display: flex;
    flex-direction: column;
    width: 250px;
    max-width: calc(100vw - 20px);
}
[data-theme="dark"] .custom-context-menu { box-shadow: 6px 6px 0px rgba(0, 0, 0, 0.8); }
.custom-context-menu.hidden { display: none; }

.context-btn {
    background: none;
    border: none;
    padding: 15px 20px;
    text-align: left;
    cursor: pointer;
    font-weight: bold;
    font-size: 1rem;
    color: var(--text-color);
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.2s, color 0.2s;
    min-height: 48px;
}
.context-btn:last-child { border-bottom: none; }
.context-btn:hover { background-color: var(--text-color); color: var(--bg-color); }
.context-btn-danger { color: var(--danger-color); }
.context-btn-danger:hover { background-color: var(--danger-color); color: #ffffff; }

/* ================== MODALS ================== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 4000;
    opacity: 1;
    transition: opacity 0.3s;
    padding: 15px;
    overflow-y: auto;
}
.modal.hidden { opacity: 0; pointer-events: none; }

.modal-content {
    background-color: var(--header-bg);
    border: 4px solid var(--primary-color);
    padding: 30px;
    width: 100%;
    max-width: 550px;
    max-height: calc(100vh - 30px);
    overflow-y: auto;
    text-align: center;
    box-shadow: 10px 10px 0px rgba(0, 0, 0, 0.5);
    margin: auto;
}
#delete-modal .modal-content { border-color: var(--danger-color); }
[data-theme="dark"] .modal-content { box-shadow: 10px 10px 0px rgba(0, 0, 0, 0.9); }
.modal-content h3 {
    color: var(--danger-color);
    font-size: 1.4rem;
    margin-bottom: 20px;
    text-transform: uppercase;
    font-weight: 900;
}
.modal-content p { font-size: 1.05rem; margin-bottom: 30px; line-height: 1.5; }

.modal-input {
    width: 100%;
    padding: 12px;
    margin-bottom: 20px;
    font-size: 1.05rem;
    background: transparent;
    border: 2px solid var(--border-color);
    color: var(--text-color);
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
}
.modal-input:focus { border-color: var(--primary-color); }
[data-theme="dark"] .modal-input { border-color: #555; }

.modal-actions {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

.btn-modal {
    padding: 14px 20px;
    font-size: 0.95rem;
    font-weight: bold;
    cursor: pointer;
    border: 2px solid;
    text-transform: uppercase;
    transition: all 0.2s;
    background: transparent;
    flex: 1;
    min-width: 140px;
    min-height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.btn-cancel { background-color: transparent; color: var(--text-color); border-color: var(--text-color); }
.btn-cancel:hover { background-color: var(--text-color); color: var(--bg-color); }
.btn-confirm-danger { background-color: var(--danger-color); color: #ffffff; border-color: var(--danger-color); }
.btn-confirm-danger:hover { background-color: var(--danger-hover); border-color: var(--danger-hover); }

/* ================== FOOTER ================== */
.site-footer {
    background-color: var(--header-bg);
    border-top: 1px solid var(--border-color);
    padding: 0 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    color: var(--text-color);
    margin-top: auto;
    min-height: var(--footer-height);
    width: 100%;
    gap: 15px;
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: max(30px, env(safe-area-inset-left));
    padding-right: max(30px, env(safe-area-inset-right));
}
.footer-left, .footer-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.footer-brand { font-weight: 900; color: var(--primary-color); letter-spacing: 1px; }
.footer-text { font-weight: bold; color: #777; }
.footer-divider { color: var(--border-color); font-size: 1.2rem; line-height: 1; }
.footer-badge {
    background-color: var(--danger-color);
    color: #fff;
    padding: 2px 6px;
    font-size: 0.7rem;
    font-weight: bold;
    border-radius: 4px !important;
    letter-spacing: 0.5px;
}
.footer-version { color: #888; font-weight: bold; }
.footer-link {
    color: var(--text-color);
    text-decoration: none;
    font-weight: bold;
    transition: color 0.2s;
}
.footer-link:hover { color: var(--primary-color); }

/* ================== TOAST ================== */
.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--toast-bg);
    color: var(--toast-text);
    padding: 15px 30px;
    font-size: 1.05rem;
    font-weight: bold;
    z-index: 5000;
    opacity: 1;
    transition: opacity 0.3s, bottom 0.3s;
    width: max-content;
    max-width: calc(100% - 30px);
    text-align: center;
    border-radius: 30px !important;
    word-break: break-word;
}
.toast.hidden { opacity: 0; bottom: -50px; pointer-events: none; }

/* ================== MODULE DE DESSIN ================== */
.draw-toolbar {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--header-bg);
    padding: 15px 25px;
    border-radius: 8px !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    z-index: 3000;
    display: flex;
    gap: 20px;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--primary-color);
    max-width: calc(100vw - 20px);
    flex-wrap: wrap;
}

.draw-tool-group { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.draw-tool-group label { font-size: 0.8rem; font-weight: bold; margin-bottom: 2px; }
.draw-toolbar input[type="color"] {
    cursor: pointer;
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
}
.draw-toolbar input[type="range"] { cursor: pointer; min-width: 100px; }
.draw-tool-actions { display: flex; flex-direction: row; gap: 10px; flex-wrap: wrap; }

.a4-page.report-grayed-page .inserted-module {
    filter: grayscale(50%) opacity(0.5);
    pointer-events: none;
    user-select: none;
}
.a4-page.report-grayed-page .cover-main-title {
    filter: grayscale(50%) opacity(0.5);
    pointer-events: none;
}
.page-annotation-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1500;
}
.draw-canvas-page {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2000;
    cursor: none;
    touch-action: none;
}

#custom-draw-cursor {
    position: fixed;
    border: 2px solid rgba(0, 0, 0, 0.6);
    background-color: rgba(255, 255, 255, 0.4);
    border-radius: 50% !important;
    pointer-events: none;
    z-index: 9999;
    transform: translate(-50%, -50%);
    display: none;
}
[data-theme="dark"] #custom-draw-cursor {
    border-color: rgba(255, 255, 255, 0.8);
    background-color: rgba(0, 0, 0, 0.4);
}
.draw-toolbar.hidden { display: none !important; }

/* ================== COMMENTAIRES INTERNES EN MARGE ================== */
.inline-comment {
    background-color: #fffbf0;
    border: none;
    border-left: 3px solid #d97706;
    border-radius: 6px !important;
    padding: 8px 12px;
    margin: 8px auto;
    width: 100%;
    max-width: 794px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    display: flex;
    flex-direction: row;
    gap: 12px;
    align-items: flex-start;
    box-sizing: border-box;
    position: relative;
    z-index: 100;
}
[data-theme="dark"] .inline-comment {
    background-color: #2a2418;
    border-left-color: #f59e0b;
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.inline-comment-badge {
    width: 30px;
    height: 30px;
    border-radius: 50% !important;
    background: #d97706;
    color: #ffffff;
    font-weight: bold;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}

.inline-comment-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.inline-comment-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 700;
    font-size: 0.82rem;
    color: #92400e;
}
[data-theme="dark"] .inline-comment-header { color: #fbbf24; }

.btn-remove-comment {
    background: transparent;
    color: #92400e;
    border: none;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 2px 6px;
    border-radius: 4px;
    transition: background-color 0.15s, color 0.15s;
}
.btn-remove-comment:hover {
    background: rgba(217, 119, 6, 0.15);
    color: #b91c1c;
}
[data-theme="dark"] .btn-remove-comment { color: #fbbf24; }

.inline-comment textarea {
    width: 100%;
    min-height: 38px;
    background: transparent;
    border: none !important;
    outline: none !important;
    font-style: italic;
    font-size: 0.9rem;
    line-height: 1.4;
    color: #451a03;
    padding: 0;
    resize: vertical;
    font-family: inherit;
}
[data-theme="dark"] .inline-comment textarea { color: #fef3c7; }

/* ================== AVATAR UTILISATEUR ================== */
.user-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50% !important;
    border: 2px solid var(--text-color);
    background-color: var(--primary-color);
    color: #ffffff;
    font-weight: bold;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    text-transform: uppercase;
    user-select: none;
    transition: transform 0.2s, background-color 0.2s, color 0.2s;
}
.user-avatar:hover {
    transform: scale(1.08);
    background-color: var(--text-color);
    color: var(--header-bg);
}
.user-avatar.hidden { display: none !important; }

/* ================== VUE LOGIN ================== */
.login-view {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    width: 100%;
    background: linear-gradient(135deg, var(--workspace-bg) 0%, #caced1 100%);
    padding: 20px;
}
[data-theme="dark"] .login-view {
    background: linear-gradient(135deg, #121212 0%, #000000 100%);
}

.login-wrapper {
    width: 100%;
    max-width: 420px;
    animation: fadeInSlideUp 0.6s ease-out forwards;
}

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

.login-container {
    background-color: var(--header-bg);
    padding: 40px 35px;
    border-radius: 12px !important;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
    text-align: center;
    border: none;
    border-top: 6px solid var(--primary-color);
}
[data-theme="dark"] .login-container {
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.6);
}

.login-logo { max-width: 160px; margin-bottom: 15px; }

.login-container h2 {
    color: var(--text-color);
    margin-bottom: 5px;
    font-weight: 900;
    font-size: 1.6rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.login-subtitle {
    color: #888;
    font-size: 0.95rem;
    margin-bottom: 30px;
}

.login-container .input-group { margin-bottom: 20px; text-align: left; }

.login-container label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: var(--text-color);
    font-size: 0.9rem;
}

.login-container input, #login-2fa-code {
    width: 100%;
    padding: 14px 15px;
    border: 2px solid var(--border-color);
    background-color: var(--bg-color);
    color: var(--text-color);
    font-size: 1rem;
    outline: none;
    transition: all 0.3s ease;
    border-radius: 8px !important;
    min-height: 50px;
}

.login-container input:focus, #login-2fa-code:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(0, 86, 179, 0.1);
    background-color: var(--header-bg);
}
[data-theme="dark"] .login-container input:focus {
    box-shadow: 0 0 0 4px rgba(58, 134, 255, 0.2);
}

.btn-login {
    width: 100%;
    padding: 15px;
    background-color: var(--primary-color);
    color: #fff;
    border: none;
    font-size: 1.05rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 10px;
    text-transform: uppercase;
    border-radius: 8px !important;
    min-height: 52px;
    letter-spacing: 1px;
    box-shadow: 0 4px 15px rgba(0, 86, 179, 0.2);
}

.btn-login:hover {
    background-color: #004494;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 86, 179, 0.3);
}

.btn-login:active { transform: translateY(0); }

.login-error {
    color: var(--danger-color);
    margin-top: 10px;
    font-weight: bold;
    font-size: 0.9rem;
    min-height: 20px;
}

/* ================== SÉLECTION MODULES ================== */
.inserted-module.is-selected-for-copy {
    outline: 3px solid var(--secondary-color);
    background-color: rgba(230, 126, 34, 0.05) !important;
    transition: outline 0.2s, background-color 0.2s;
}

/* ================== MODULE FICHE REX ================== */
.a4-page.rex-page { background-color: #f6f0fa !important; }

/* ================== LOADER ================== */
.global-loader-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--overlay-color);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.3s ease;
    padding: 20px;
}
.global-loader-overlay.hidden { opacity: 0; pointer-events: none; }
.global-spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--primary-color);
    border-radius: 50% !important;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}
.global-loader-text {
    color: #ffffff;
    font-weight: bold;
    font-size: 1.1rem;
    letter-spacing: 1px;
    text-align: center;
}

.btn-save.is-loading {
    pointer-events: none;
    opacity: 0.8;
    position: relative;
    color: transparent !important;
}
.btn-save.is-loading::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: #ffffff;
    border-radius: 50% !important;
    animation: spin-centered 0.8s linear infinite;
}
@keyframes spin { 100% { transform: rotate(360deg); } }
@keyframes spin-centered { 100% { transform: translate(-50%, -50%) rotate(360deg); } }

body.hide-pdf-fab .fab-mic { left: 30px !important; }
body.hide-pdf-fab .fab-doc { left: calc(30px + var(--fab-size) + var(--fab-gap)) !important; }

/* ================== IMPRESSION ================== */
@page { size: A4; margin: 0mm; }

@media print {
    body { display: none !important; }
    html::before {
        content: "Veuillez utiliser le bouton PDF en bas à gauche de l'écran pour exporter.";
        display: block;
        text-align: center;
        margin-top: 50px;
        font-family: Arial, sans-serif;
        font-weight: bold;
    }
}

/* ================== DRAWER CATEGORIES ================== */
.drawer-category-title {
    font-size: 0.85rem;
    font-weight: 900;
    color: var(--primary-color);
    margin-top: 20px;
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 5px;
}

.drawer-content .drawer-category-title:first-child { margin-top: 0; }

/* --- DICTÉE VOCALE INLINE --- */
.fab-mic { display: none !important; }

.fab-doc { left: calc(30px + var(--fab-size) + var(--fab-gap)) !important; }

.inline-mic-btn {
    position: absolute;
    width: 24px;
    height: 24px;
    border-radius: 50% !important;
    background-color: #8e44ad;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
    cursor: pointer;
    z-index: 100;
    transition: transform 0.15s ease, opacity 0.15s ease;
}
.inline-mic-btn:hover { transform: scale(1.15); background-color: #9b59b6; }
.inline-mic-btn.hidden { opacity: 0; pointer-events: none; transform: scale(0.8); }
.inline-mic-btn svg { width: 12px; height: 12px; }

.a4-page.print-overflow-warning {
    outline: 3px dashed var(--danger-color) !important;
    outline-offset: -3px;
}

/* ================== MODULE RELEVÉ DES NIVEAUX ================== */
.niveau-container {
    border: 1px solid var(--border-color);
    width: 100%;
    background: transparent;
    overflow-x: auto;
}

.niveau-top-row, .niveau-bottom-row {
    display: flex;
    align-items: center;
    position: relative;
    padding: 6px;
    background: rgba(0, 0, 0, 0.01);
}
.niveau-top-row { border-bottom: 1px solid var(--border-color); }
.niveau-bottom-row { border-bottom: 1px solid var(--border-color); }

.niveau-row-list {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-around;
    gap: 4px;
    flex-wrap: nowrap !important;
    min-width: 0;
    overflow: hidden;
}

.niveau-row-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    flex-shrink: 0;
}

.niveau-top-row .niveau-cell,
.niveau-bottom-row .niveau-cell {
    border: none;
    padding: 2px 4px;
    flex: 1 1 0;
    min-width: 0;
    max-width: 100%;
}

.niveau-row-list .niveau-cell * {
    white-space: nowrap;
}

.niveau-row-list .niveau-triangle {
    width: 44px;
    max-width: 100%;
    height: 14px;
    flex-shrink: 1;
}

.niveau-row-list .niveau-input.niveau-value {
    width: 100% !important;
    max-width: 60px;
    min-width: 25px !important;
    padding: 3px 2px;
    font-size: 0.85rem;
}

.niveau-mid-row {
    display: flex;
    min-height: 320px;
    border-bottom: 1px solid var(--border-color);
}

.niveau-mid-col {
    flex: 0 0 95px;
    min-width: 90px;
    width: 95px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    position: relative;
    box-sizing: border-box;
}
.niveau-mid-col:first-child { border-right: 1px solid var(--border-color); }
.niveau-mid-col:last-child { border-left: 1px solid var(--border-color); }

.niveau-side-list {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    align-items: center;
    width: 100%;
    min-height: 0;
    gap: 8px;
    padding: 6px 0;
    box-sizing: border-box;
}

.niveau-mid-col > .niveau-cell,
.niveau-side-list > .niveau-cell {
    flex: 1 1 auto;
    border-bottom: 1px solid var(--border-color);
    min-height: 110px;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2px 0;
    overflow: visible;
    position: relative;
    box-sizing: border-box;
}
.niveau-side-list > .niveau-cell:last-child { border-bottom: none; }

.niveau-mid-col .niveau-cell-inner {
    transform: rotate(-90deg) !important;
    transform-origin: center center !important;
    display: inline-flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
    width: auto !important;
    min-width: max-content !important;
    max-width: none !important;
    white-space: nowrap !important;
    flex-shrink: 0 !important;
}

.niveau-mid-col .niveau-cell-inner .niveau-input.niveau-value {
    width: 44px !important;
    min-width: 44px !important;
    max-width: 44px !important;
    height: 24px !important;
    padding: 2px 4px !important;
    font-size: 0.8rem !important;
    text-align: center !important;
    flex-shrink: 0 !important;
    box-sizing: border-box !important;
    margin: 0 !important;
}

.niveau-mid-col .niveau-cell-inner .niveau-arrow {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
}

.niveau-mid-col .niveau-cell-inner .niveau-triangle {
    width: 38px !important;
    min-width: 38px !important;
    max-width: 38px !important;
    height: 14px !important;
    flex-shrink: 0 !important;
    display: inline-block !important;
}

.niveau-mid-col .niveau-cell-inner .btn-remove-mv {
    width: 18px !important;
    min-width: 18px !important;
    max-width: 18px !important;
    height: 18px !important;
    padding: 0 !important;
    margin: 0 0 0 2px !important;
    font-size: 11px !important;
    line-height: 1 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
    border-radius: 50% !important;
}

.niveau-cell-row-inner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    width: 100%;
    min-width: 0;
}
.niveau-cell-row-inner .btn-remove-mv {
    width: 18px;
    height: 18px;
    font-size: 10px;
    line-height: 1;
    padding: 0;
    margin-left: 2px;
    flex-shrink: 0;
    border-radius: 50% !important;
}

.niveau-side-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 4px;
    background: rgba(0, 0, 0, 0.02);
    width: 100%;
    box-sizing: border-box;
    flex-shrink: 0;
    position: relative;
    z-index: 2;
}
.niveau-side-btn {
    width: 22px;
    height: 22px;
    border-radius: 50% !important;
    border: 1px solid var(--border-color);
    background: var(--header-bg);
    color: var(--text-color);
    font-weight: bold;
    font-size: 0.85rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}
.niveau-side-btn:hover {
    background: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
}

.niveau-center-cell {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 15px;
    min-width: 0;
}

.niveau-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px;
    position: relative;
}

.niveau-label {
    font-size: 0.85rem;
    font-weight: bold;
    color: var(--text-color);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.niveau-input.niveau-value {
    width: 90px;
    text-align: center;
    padding: 5px 8px;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-color);
    font-weight: bold;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s, background-color 0.2s;
}
.niveau-input.niveau-value:focus {
    border-color: var(--primary-color);
    background-color: rgba(0, 0, 0, 0.03);
}
[data-theme="dark"] .niveau-input.niveau-value:focus { background-color: rgba(255, 255, 255, 0.05); }

.niveau-arrow {
    cursor: pointer;
    color: var(--primary-color);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px;
    transition: color 0.2s, transform 0.15s;
    user-select: none;
}
.niveau-arrow:hover { color: var(--secondary-color); transform: scale(1.1); }

.niveau-triangle {
    display: inline-flex;
    width: 68px;
    height: 16px;
    transition: transform 0.2s ease;
    transform-origin: center center;
}
.niveau-triangle svg { width: 100%; height: 100%; display: block; }

.niveau-image-dropzone {
    width: 100%;
    height: 100%;
    min-height: 320px;
    border: 2px dashed var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    overflow: hidden;
    background-color: rgba(0, 0, 0, 0.02);
    transition: background-color 0.2s, border-color 0.2s;
}
.niveau-image-dropzone:hover { background-color: rgba(0, 0, 0, 0.05); border-color: var(--primary-color); }
[data-theme="dark"] .niveau-image-dropzone { background-color: rgba(255, 255, 255, 0.02); }
[data-theme="dark"] .niveau-image-dropzone:hover { background-color: rgba(255, 255, 255, 0.06); }

.niveau-placeholder { font-style: italic; color: #999; font-size: 1rem; text-align: center; padding: 10px; }

.niveau-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background-color: rgba(0, 0, 0, 0.02);
    gap: 15px;
    flex-wrap: wrap;
}
[data-theme="dark"] .niveau-footer { background-color: rgba(255, 255, 255, 0.03); }

.niveau-footer-item { display: flex; align-items: center; gap: 8px; }
.niveau-footer-item label { font-weight: bold; font-size: 0.9rem; color: var(--text-color); }

.niveau-input.niveau-tolerance {
    width: 130px;
    padding: 5px 8px;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-color);
    outline: none;
    font-size: 0.95rem;
}
.niveau-input.niveau-tolerance:focus,
.niveau-input.niveau-unit:focus { border-color: var(--primary-color); }

.niveau-input.niveau-unit {
    padding: 5px 8px;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-color);
    outline: none;
    text-align: center;
    font-weight: bold;
    font-size: 0.95rem;
}

/* ==========================================================================
   RESPONSIVE — TABLETTE (≤ 1200px)
   ========================================================================== */
@media screen and (max-width: 1200px) {
   :root {
        --fab-size: 60px;
        --fab-gap: 12px;
    }
    .module-controls { left: -230px; width: 210px; }
    /* Symétrie appliquée ici aussi */
    .editor-workspace { padding: 30px 20px 150px 20px; }
}

/* ==========================================================================
   RESPONSIVE — TABLETTE PORTRAIT (≤ 992px)
   ========================================================================== */
@media screen and (max-width: 992px) {
    :root {
        --editor-side-padding: 16px;
        --page-gap: 20px;
    }

    .editor-workspace {
        padding: 16px 8px 150px;
    }

    .pages-container {
        zoom: calc((100vw - 32px) / 794px);
        display: inline-flex;
        flex-direction: column;
        align-items: center;
        vertical-align: top;
        gap: 20px;
    }

    .module-controls {
        position: relative;
        left: 0;
        top: 0;
        width: 100%;
        margin-bottom: 0;
        opacity: 0;
        visibility: hidden;
        max-height: 0;
        overflow: hidden;
        box-shadow: none;
        border: 0;
        background: rgba(0, 0, 0, 0.03);
        padding: 0;
        gap: 10px;
        flex-wrap: wrap;
        align-items: center;
        transition: opacity 0.2s, max-height 0.25s, padding 0.2s, margin-bottom 0.2s;
    }
    [data-theme="dark"] .module-controls { background: rgba(255, 255, 255, 0.05); }

    .inserted-module.is-focused .module-controls {
        opacity: 1;
        visibility: visible;
        max-height: 260px;
        padding: 10px;
        margin-bottom: 10px;
        border: 2px solid var(--border-color);
    }

    .drag-handle { display: none; }
    .mobile-move-btns {
        display: flex;
        flex-direction: row;
        padding-right: 0;
        gap: 6px;
    }
    .mobile-move-btns button {
        min-width: 38px;
        min-height: 38px;
        padding: 4px 10px;
        font-size: 0.85rem;
    }
    .module-controls-left {
        flex-direction: row;
        align-items: center;
        flex-wrap: wrap;
        gap: 8px;
        width: auto;
        flex: 1;
    }
    .btn-remove-module {
        margin-left: 0;
        padding: 6px 12px;
        min-width: 38px;
        min-height: 38px;
    }
}

/* ==========================================================================
   RESPONSIVE — MOBILE (≤ 768px)
   ========================================================================== */
@media screen and (max-width: 768px) {
    :root {
        --header-height: auto;
        --fab-size: 56px;
        --fab-gap: 12px;
        --page-gap: 14px;
        --footer-height: auto;
    }

    /* Empêche le zoom auto iOS sur les champs de saisie hors page A4 zoomée */
    .modal-input, .share-search-input {
        font-size: 16px !important;
    }

    /* ---------- HEADER GLOBAL : scroll naturel ---------- */
    header {
        padding: 10px 12px;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        gap: 10px;
        flex-wrap: wrap;
        position: static;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    }
    .logo-container { align-items: flex-start; width: auto; }
    .logo { height: 32px; }
    .subtitle { font-size: 0.7rem; }
    .header-actions {
        justify-content: flex-end;
        width: auto;
        gap: 6px;
        flex-wrap: wrap;
    }
    .btn-header {
        padding: 8px 12px;
        font-size: 0.8rem;
        min-height: 42px;
        border-width: 1.5px;
    }
    .user-avatar { width: 40px; height: 40px; font-size: 1.05rem; }
    .sync-status-offline { margin-right: 0; font-size: 0.75rem; }
    #lang-menu, #avatar-menu { right: 0 !important; left: auto !important; }

    /* ---------- HOME / DRIVE ---------- */
    .top-actions { padding: 14px 12px; flex-direction: column; gap: 10px; }
    .btn-create-small {
        width: 100%;
        justify-content: center;
        padding: 15px 18px;
        font-size: 0.95rem;
        min-height: 54px;
    }
    .btn-create-small svg { width: 20px; height: 20px; }
    .drive-section { padding: 18px 12px; }
    .drive-section h2 { font-size: 1.15rem; text-align: center; margin-bottom: 16px; }
    .reports-grid { grid-template-columns: 1fr; gap: 12px; }
    .report-card { padding: 16px; min-height: 120px; }
    .report-name { font-size: 1rem; }

    /* ---------- ÉDITEUR : TOOLBAR STICKY ---------- */
    /* ✅ La toolbar reste sticky en haut — le header global scrolle,
       puis la toolbar atteint le top et s'y bloque */
    .editor-toolbar {
        padding: 6px 8px;
        gap: 5px;
        flex-direction: column;
        align-items: stretch;
        position: sticky;
        top: 0;
        z-index: 2500;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    }

    /* Titre ultra-compact */
    .editor-doc-title-input {
        flex: 0 0 auto !important;
        width: 100%;
        text-align: center;
        margin: 0;
        font-size: 13px !important;
        font-weight: 700;
        padding: 4px 8px;
        letter-spacing: 0;
        border: 1px solid var(--border-color);
        background-color: rgba(0, 0, 0, 0.02);
        min-height: 28px;
        max-height: 28px;
        height: 28px;
        line-height: 20px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    [data-theme="dark"] .editor-doc-title-input {
        background-color: rgba(255, 255, 255, 0.05);
    }

    /* Boutons de la toolbar : grille auto-fit */
    .editor-toolbar-actions {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(40px, 1fr));
        gap: 4px;
        margin: 0;
    }
    .editor-toolbar-actions .btn-header {
        padding: 0;
        min-width: 0;
        min-height: 40px;
        width: 100%;
        border-width: 1.5px;
    }
    .editor-toolbar-actions .btn-header svg { width: 20px; height: 20px; }

    /* ---------- WORKSPACE : scroll naturel du body ---------- */
    /* ✅ Pas d'overflow ici → c'est le body qui scrolle, la molette fonctionne */
    .editor-workspace {
        padding: 8px 4px 150px;
        text-align: center;
        position: relative;
    }

    .pages-container {
        display: inline-flex;
        flex-direction: column;
        align-items: center;
        vertical-align: top;
        gap: 14px;
        zoom: calc((100vw - 8px) / 794px);
    }

    .a4-page {
        margin: 0 !important;
        box-shadow: 0 4px 12px var(--a4-shadow) !important;
    }

    /* Contrôles des modules : tailles doublées pour compenser le zoom */
    .module-controls {
        padding: 20px 24px;
        gap: 16px;
    }
    .module-title-label { font-size: 1.8rem; }
    .btn-remove-module {
        min-width: 100px;
        min-height: 100px;
        font-size: 2rem;
        padding: 12px 20px;
    }
    .mobile-move-btns button {
        min-width: 80px;
        min-height: 80px;
        font-size: 1.6rem;
        padding: 6px 12px;
    }
    .module-titling-select {
        font-size: 1.8rem;
        padding: 12px;
        min-height: 72px;
    }

    /* ---------- DRAWER : plein écran fixe en mobile ---------- */
    /* ✅ Le drawer reste fixé à l'écran, indépendant du scroll */
    .drawer {
        position: fixed !important;
        top: 0 !important;
        right: 0 !important;
        left: 0 !important;
        height: 100vh !important;
        height: 100dvh !important;
        max-height: 100dvh !important;
        width: 100% !important;
        transform: translateX(100%);
        transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
        border-left: none !important;
        box-shadow: none;
        z-index: 3200;
    }
    .drawer.open { transform: translateX(0); box-shadow: 0 0 40px rgba(0, 0, 0, 0.5); }
    .drawer-header { padding: 14px 16px; position: sticky; top: 0; background: var(--header-bg); z-index: 2; }
    .drawer-header h3 { font-size: 1rem; }
    .btn-close-drawer { min-width: 44px; min-height: 44px; padding: 0 12px; }
    .drawer-content { padding: 14px; padding-bottom: calc(90px + env(safe-area-inset-bottom)); }
    .module-card-mini { font-size: 1rem; padding: 16px 14px; min-height: 52px; }

    /* ---------- FOOTER ---------- */
    .site-footer {
        flex-direction: column;
        gap: 6px;
        padding: 12px 15px calc(12px + env(safe-area-inset-bottom));
        min-height: auto;
        text-align: center;
        font-size: 0.75rem;
    }
    .footer-left, .footer-right { flex-wrap: wrap; justify-content: center; gap: 6px; }
    .footer-badge { font-size: 0.65rem; }

    /* ---------- MODALES ---------- */
    .modal { padding: 0; align-items: stretch; justify-content: stretch; }
    .modal-content {
        padding: 22px 16px calc(22px + env(safe-area-inset-bottom));
        box-shadow: none;
        border-width: 0;
        border-top: 4px solid var(--primary-color);
        max-width: 100%;
        width: 100%;
        max-height: 100vh;
        max-height: 100dvh;
        min-height: 100vh;
        min-height: 100dvh;
        margin: 0;
        display: flex;
        flex-direction: column;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    #delete-modal .modal-content,
    #conflict-modal .modal-content { border-top-color: var(--danger-color); }
    .modal-content h3 { font-size: 1.15rem; margin-bottom: 14px; }
    .modal-content p { font-size: 0.95rem; margin-bottom: 20px; line-height: 1.5; }
    .modal-input { font-size: 16px !important; padding: 14px; min-height: 50px; }
    .modal-actions { margin-top: auto; gap: 10px; flex-direction: column-reverse; }
    .btn-modal {
        width: 100%;
        min-width: 0;
        flex: 1;
        padding: 14px;
        font-size: 0.9rem;
        min-height: 52px;
        text-transform: uppercase;
        font-weight: 800;
    }

    .share-users-list-container { max-height: 45vh; }
    .share-user-row { padding: 12px 14px; gap: 12px; flex-direction: column; align-items: stretch; }
    .share-role-select { width: 100%; min-height: 46px; font-size: 16px !important; }

    /* ---------- LOGIN ---------- */
    .login-view { padding: 15px; align-items: center; }
    .login-wrapper { max-width: 100%; }
    .login-container { padding: 30px 22px; border-radius: 12px !important; }
    .login-logo { max-width: 140px; }
    .login-container h2 { font-size: 1.25rem; }
    .login-subtitle { font-size: 0.9rem; }
    .login-container input { font-size: 16px !important; min-height: 52px; padding: 14px; }
    .btn-login { min-height: 54px; font-size: 1rem; }
    #login-2fa-code { font-size: 1.6rem !important; letter-spacing: 8px !important; padding: 14px !important; min-height: 60px; }

    /* ---------- DRAW TOOLBAR ---------- */
    .draw-toolbar {
        top: 4px; left: 4px; right: 4px;
        transform: none;
        width: auto;
        max-width: none;
        flex-wrap: wrap;
        padding: 10px;
        gap: 8px;
        justify-content: center;
        border-radius: 8px !important;
        max-height: 70vh;
        overflow-y: auto;
    }
    .draw-tool-group { min-width: 0; }
    .draw-tool-group label { font-size: 0.7rem; }
    .draw-toolbar input[type="color"] { width: 38px; height: 38px; }
    .draw-toolbar input[type="range"] { min-width: 90px; }
    .draw-tool-btn { min-width: 42px; min-height: 42px; padding: 8px !important; }
    .draw-tool-actions { width: 100%; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
    .draw-tool-actions .btn-header { padding: 10px 6px; font-size: 0.8rem; min-height: 44px; }

    /* ---------- FABs ---------- */
    .fab-plus, .fab-draw, .fab-pdf, .fab-doc {
        width: var(--fab-size);
        height: var(--fab-size);
        bottom: calc(16px + env(safe-area-inset-bottom));
    }
    .fab-plus { right: 14px; font-size: 2rem; }
    .fab-draw { right: calc(14px + var(--fab-size) + var(--fab-gap)); background-color: #27ae60; }
    .fab-pdf { left: 14px; font-size: 1rem; font-weight: 900; }
    .fab-doc { left: calc(14px + var(--fab-size) + var(--fab-gap)) !important; background-color: #34495e; }
    body.hide-pdf-fab .fab-doc { left: 14px !important; bottom: calc(16px + env(safe-area-inset-bottom)) !important; }

    /* ---------- COMMENTAIRES ---------- */
    .inline-comment { width: calc(100% - 16px); padding: 12px; margin: 12px auto; border-radius: 6px !important; }
    .inline-comment-header { font-size: 0.85rem; }
    .inline-comment textarea { font-size: 16px !important; }

    /* ---------- MODULES SPÉCIFIQUES ---------- */
    .standard-body { flex-direction: row; }
    .standard-photo { flex: 0 0 45%; }
    .module-visual-container { flex-wrap: nowrap; }
    .visual-column { min-width: 0; }
    .visual-dropzone { height: 220px; }

    .cover-company-info { flex-direction: row !important; justify-content: space-between !important; align-items: center !important; gap: 12px; flex-wrap: nowrap !important; }
    .cover-logo-img { height: 38px; align-self: center; }

    .inline-mic-btn { width: 28px; height: 28px; }
    .inline-mic-btn svg { width: 14px; height: 14px; }

    .denture-table, .criticite-table, .custom-table { font-size: 0.85rem; }
    .denture-table th, .denture-table td { padding: 6px; }
    .btn-table-edit { padding: 6px 8px; min-height: 36px; font-size: 0.75rem; }

    .niveau-image-dropzone { min-height: 220px; }
}

/* ==========================================================================
   RESPONSIVE — PETITS MOBILES (≤ 480px)
   ========================================================================== */
@media screen and (max-width: 480px) {
    :root { --fab-size: 52px; --fab-gap: 10px; }

    .logo { height: 30px; }
    .subtitle { display: none; }

    .btn-header { font-size: 0.75rem; padding: 7px 9px; min-height: 40px; }
    .editor-toolbar-actions .btn-header { min-height: 38px; }
    .editor-toolbar-actions .btn-header svg { width: 18px; height: 18px; }

    .editor-doc-title-input {
        font-size: 12px !important;
        min-height: 26px;
        max-height: 26px;
        height: 26px;
        line-height: 18px;
        padding: 3px 6px;
    }

    .editor-workspace { padding: 6px 2px 150px; }
    .pages-container { zoom: calc((100vw - 4px) / 794px); }

    .modal-content { padding: 18px 12px calc(18px + env(safe-area-inset-bottom)); }
    .modal-content h3 { font-size: 1.05rem; }

    .report-card { padding: 14px; }
    .report-icon { font-size: 0.7rem; padding: 3px 7px; }
    .report-name { font-size: 0.95rem; }
    .drive-section h2 { font-size: 1.05rem; }

    .module-card-mini { font-size: 0.95rem; padding: 14px 12px; }

    .fab-plus { font-size: 1.8rem; }
    .fab-pdf { font-size: 0.9rem; }

    .draw-toolbar { padding: 8px 6px; gap: 6px; }
    .draw-tool-group label { font-size: 0.65rem; }
    .draw-toolbar input[type="color"] { width: 32px; height: 32px; }
    .draw-tool-actions .btn-header { padding: 8px 4px; font-size: 0.72rem; min-height: 40px; }

    .denture-table th, .denture-table td { padding: 4px; font-size: 0.75rem; }
}

/* ==========================================================================
   PAYSAGE MOBILE (hauteur ≤ 500px)
   ========================================================================== */
@media screen and (max-height: 500px) and (orientation: landscape) {
    header { padding: 6px 10px; flex-direction: row; }
    .logo { height: 26px; }
    .subtitle { display: none; }
    .editor-toolbar { flex-direction: row; padding: 6px 8px; position: sticky; top: 0; }
    .editor-doc-title-input { max-width: 180px; font-size: 12px !important; min-height: 26px; max-height: 26px; height: 26px; flex: 0 0 auto !important; }
    .editor-toolbar-actions { width: auto; flex: 1; display: flex; flex-wrap: nowrap; }
    .editor-toolbar-actions .btn-header { min-height: 36px; flex: 1; }

    .drawer-content { padding: 10px; padding-bottom: 80px; }
    .modal-content { min-height: auto; max-height: 100vh; padding: 16px; }
    .draw-toolbar { padding: 6px; gap: 6px; max-height: 90vh; }

    .editor-workspace { padding: 6px 2px 100px; }
    .pages-container { zoom: calc((100vw - 60px) / 794px); }
}

/* ==========================================================================
   PREFERS-REDUCED-MOTION
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ==========================================================================
   FEEDBACK TACTILE (hover:none)
   ========================================================================== */
@media (hover: none) and (pointer: coarse) {
    .btn-header:active,
    .btn-modal:active,
    .btn-create-small:active,
    .module-card-mini:active,
    .context-btn:active,
    .report-card:active,
    .nav-btn:active {
        transform: scale(0.96);
        opacity: 0.85;
        transition: transform 0.08s, opacity 0.08s;
    }
}

/* ================== MODULE LIGNAGE ================== */
.lignage-table {
    width: 100%;
    border-collapse: collapse;
    text-align: center;
    margin-bottom: 15px;
    font-size: 0.9rem;
}
.lignage-table th, .lignage-table td {
    border: 1px solid var(--border-color);
    padding: 10px;
    vertical-align: middle;
}
.lignage-table th {
    background-color: rgba(0, 0, 0, 0.05);
    font-weight: bold;
}
[data-theme="dark"] .lignage-table th { background-color: rgba(255, 255, 255, 0.05); }

.lignage-cross {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    grid-template-rows: auto auto auto;
    align-items: center;
    justify-items: center;
    gap: 8px;
}
.lignage-cross .cross-top { grid-column: 2; grid-row: 1; }
.lignage-cross .cross-left { grid-column: 1; grid-row: 2; }
.lignage-cross .cross-img { grid-column: 2; grid-row: 2; }
.lignage-cross .cross-right { grid-column: 3; grid-row: 2; }
.lignage-cross .cross-bot { grid-column: 2; grid-row: 3; }

.lignage-input {
    width: 60px;
    text-align: center;
    border: 1px solid var(--border-color);
    padding: 4px;
    background: transparent;
    color: var(--text-color);
    font-weight: bold;
    outline: none;
    margin-top: 4px;
}
.lignage-input:focus { border-color: var(--primary-color); }
.lignage-res-label { font-weight: bold; margin-right: 5px; }
.lignage-res-val { font-weight: bold; display: inline-block; min-width: 40px; }


.btn-select-module {
    background: var(--bg-color);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    padding: 4px 10px;
    cursor: pointer;
    font-weight: bold;
    font-size: 0.85rem;
}
.inserted-module.is-selected-for-copy .btn-select-module {
    background: var(--secondary-color);
    color: #fff;
    border-color: var(--secondary-color);
}

.btn-remove-roulement-subline {
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: 50% !important;
    width: 22px;
    height: 22px;
    cursor: pointer;
    font-weight: bold;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: auto;
    font-size: 0.9rem;
    line-height: 1;
    transition: transform 0.1s;
}
.btn-remove-roulement-subline:hover { transform: scale(1.15); }

.btn-add-roulement-subline {
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 50% !important;
    width: 22px;
    height: 22px;
    cursor: pointer;
    font-weight: bold;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 6px;
    vertical-align: middle;
    font-size: 0.9rem;
    line-height: 1;
    transition: transform 0.1s;
}
.btn-add-roulement-subline:hover { transform: scale(1.15); }

.crit-comment {
    width: 100%;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 8px;
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--text-color);
    background: var(--card-bg);
    box-sizing: border-box;
}

/* ================== BOUTONS D'ACTION MODERNES ================== */
.btn-table-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    background: linear-gradient(135deg, #1b365d 0%, #2a5298 100%);
    color: #ffffff !important;
    border: none;
    border-radius: 6px !important;
    padding: 6px 14px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(27, 54, 93, 0.2);
    transition: all 0.2s ease;
    user-select: none;
}
.btn-table-action:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(27, 54, 93, 0.3);
    background: linear-gradient(135deg, #24487d 0%, #3567bd 100%);
}
.btn-table-action:active {
    transform: translateY(0);
}

.btn-table-action-danger {
    background: linear-gradient(135deg, #b91c1c 0%, #dc2626 100%);
    box-shadow: 0 2px 4px rgba(185, 28, 28, 0.2);
}
.btn-table-action-danger:hover {
    background: linear-gradient(135deg, #991b1b 0%, #b91c1c 100%);
    box-shadow: 0 4px 8px rgba(185, 28, 28, 0.3);
}

.roulement-table th:nth-child(2),
.roulement-table td:nth-child(2) {
    min-width: 110px !important;
    width: 18% !important;
}

.roulement-cote {
    width: 100% !important;
    min-width: 100px !important;
    text-align: center !important;
    font-size: 0.82rem !important;
    white-space: nowrap !important;
}

/* Auto-wrap & visibility in cells */
.denture-table td,
.roulement-table td,
.custom-table td,
.fonc-table td,
.lub-table td {
    overflow: visible;
}
.denture-input {
    min-width: 0;
    box-sizing: border-box;
}

/* =========================================================
   SCINDER SUR 2 PAGES & PLANCHE PHOTOGRAPHIQUE
   ========================================================= */
.btn-split-module {
    background: rgba(0, 86, 179, 0.08);
    border: 1px solid rgba(0, 86, 179, 0.3);
    color: var(--primary-color);
    border-radius: 4px;
    padding: 3px 9px;
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    margin-left: 10px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s ease;
    vertical-align: middle;
}
.btn-split-module:hover {
    background: var(--primary-color);
    color: #ffffff;
    border-color: var(--primary-color);
}
[data-theme="dark"] .btn-split-module {
    background: rgba(74, 134, 232, 0.15);
    border-color: rgba(74, 134, 232, 0.4);
    color: #93c5fd;
}
[data-theme="dark"] .btn-split-module:hover {
    background: #4a86e8;
    color: #ffffff;
}

.split-notice-banner {
    background: rgba(0, 86, 179, 0.05);
    border: 1px dashed var(--primary-color);
    border-radius: 6px;
    padding: 10px 14px;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}
[data-theme="dark"] .split-notice-banner {
    background: rgba(74, 134, 232, 0.08);
    border-color: #4a86e8;
}

.btn-rejoin-module {
    background: var(--primary-color);
    color: #ffffff;
    border: none;
    border-radius: 4px;
    padding: 5px 12px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: background 0.2s, transform 0.1s;
    white-space: nowrap;
}
.btn-rejoin-module:hover {
    background: #003d80;
    transform: translateY(-1px);
}
[data-theme="dark"] .btn-rejoin-module {
    background: #4a86e8;
}
[data-theme="dark"] .btn-rejoin-module:hover {
    background: #3b78de;
}

.photo-caption-input {
    width: 100%;
    text-align: center;
    margin-top: 5px;
    border: none;
    border-bottom: 1px dashed var(--border-color);
    background: transparent;
    font-size: 0.85rem;
    color: var(--text-color);
    outline: none;
    padding: 2px 4px;
    transition: border-color 0.2s;
}
.photo-caption-input:focus {
    border-bottom: 1px solid var(--primary-color) !important;
}

.dynamic-gallery {
    display: flex;
    gap: 10px !important;
    margin-bottom: 15px !important;
    flex-wrap: wrap;
    width: 100%;
}

/* PDF Export styles */
.pdf-export-mode .btn-split-module,
.pdf-export-mode .btn-rejoin-module {
    display: none !important;
}
.pdf-export-mode .split-notice-banner {
    border: none !important;
    background: transparent !important;
    padding: 4px 0 !important;
    margin-bottom: 6px !important;
    font-style: italic !important;
}
.pdf-export-mode .cell-content-area:empty:before {
    content: none !important;
    display: none !important;
}

/* Uniformisation de la police dans les tableaux de lubrification et fonctionnement */
.lub-table th,
.lub-table td,
.lub-table .denture-input,
.fonc-table th,
.fonc-table td,
.fonc-table .denture-input {
    font-size: 0.88rem !important;
}





