* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px;
    background: #f8f8f8;
    color: #1a1a1a;
    overflow: hidden;
}

.app {
    display: flex;
    height: 100vh;
}

.sidebar {
    width: 280px;
    background: #fff;
    border-right: 1px solid #e0e0e0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}
/* Icon-only presentation for the left tools group */
.tools-icons { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tools-icons .btn-tool {
    justify-content: center;
    gap: 0;
    width: 44px;
    height: 44px;
    padding: 0;
    aspect-ratio: 1/1;
    border-radius: 4px;
}
.tools-icons .btn-tool span { /* hide text labels */
    display: none !important;
}
.tools-icons .btn-tool .tool-icon {
    margin-right: 0;
    width: 22px;
    height: 22px;
}
.tools-icons .btn-tool { border: 1px solid #d9d9d9; background:#fff; }
.tools-icons .btn-tool:hover { background:#f2f2f2; border-color:#cfcfcf; }
.tools-icons .btn-tool.active { outline: 2px solid #bdbdbd; background:#fff; color: inherit; }
.theme-dark .tools-icons .btn-tool { background:#2b2b2b; border-color:#555; }
.theme-dark .tools-icons .btn-tool:hover { background:#333; border-color:#666; }
.theme-dark .tools-icons .btn-tool.active { outline: 2px solid #777; background:#2b2b2b; color: #ddd; }
/* Invert tool icons in dark theme (black strokes become white, white fill becomes dark) */
.theme-dark .btn-tool .tool-icon { filter: invert(1); }
.btn-tool:hover .tool-icon {
    opacity: 0.9;
}

.sidebar::-webkit-scrollbar,
.rightbar::-webkit-scrollbar,
#historyPanel::-webkit-scrollbar,
.canvas-scroll-area::-webkit-scrollbar,
#designScroll::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}

.sidebar::-webkit-scrollbar-track,
.rightbar::-webkit-scrollbar-track,
#historyPanel::-webkit-scrollbar-track,
.canvas-scroll-area::-webkit-scrollbar-track,
#designScroll::-webkit-scrollbar-track {
    background: #f8f8f8;
}

.sidebar::-webkit-scrollbar-thumb,
.rightbar::-webkit-scrollbar-thumb,
#historyPanel::-webkit-scrollbar-thumb,
.canvas-scroll-area::-webkit-scrollbar-thumb,
#designScroll::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 2px;
}

.logo {
    padding: 17px 20px;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 2px;
    border-bottom: 1px solid #e0e0e0;
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 10;
    height: 56px;
    display: flex;
    align-items: center;
}

.section {
    padding: 16px;
    border-bottom: 1px solid #e0e0e0;
}

.section-title {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 12px;
    opacity: 0.6;
}

.btn-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

/* 🎯 Groupe de boutons collés sans espace entre eux */
.btn-group-tight {
    display: inline-flex;
    gap: 0;
}

.btn-tool .tool-icon {
    width: 16px;
    height: 16px;
    display: inline-block;
    vertical-align: middle;
    margin-right: 4px;
    image-rendering: -webkit-optimize-contrast;
}
.btn-group-tight .btn {
    border-radius: 0;
}

.btn-group-tight .btn:first-child {
    border-radius: 0;
}

.btn-group-tight .btn:last-child {
    border-radius: 0;
}

/* 🎯 Tous les boutons de la toolbar sont carrés (pas d'arrondi) */
.toolbar .btn {
    border-radius: 0 !important;
}

/* 🎯 HARMONISATION: Hauteur standard pour tous les boutons et inputs */
.btn {
    height: 32px;
    padding: 0 12px;
    background: transparent;
    color: #1a1a1a;
    border: 1px solid #1a1a1a;
    cursor: pointer;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10px;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

.btn:hover {
    background: rgba(0, 0, 0, 0.05);
    border-color: #000;
}

.btn.active {
    background: #1a1a1a;
    color: #fff;
    border-color: #1a1a1a;
}

/* Style spécifique pour les boutons d'outils (icônes uniquement): fond blanc, fin liseré gris clair */
.btn-tool { background: #fff; color: #111; border: 1px solid #d9d9d9; }
.btn-tool:hover { background: #f2f2f2; border-color:#cfcfcf; }
.btn-tool.active { outline: 2px solid #bdbdbd; background: #fff; color: #111; }

.btn-secondary {
    background: transparent;
    color: #555;
    border: 1px solid #ccc;
}

.btn-secondary:hover {
    background: rgba(0, 0, 0, 0.03);
    border-color: #999;
    color: #333;
}

.btn-secondary.active {
    background: #1a1a1a;
    color: #fff;
    border-color: #1a1a1a;
}

.btn-danger {
    background: #dc3545;
    color: #fff;
    font-weight: 600;
}
.btn-danger:hover {
    background: #c82333;
}

.btn-dark {
    background: transparent;
    color: #000;
    border: 1px solid #000;
}
.btn-dark:hover {
    background: rgba(0, 0, 0, 0.05);
}

/* Theme: Dark overrides */
.theme-dark body { background: #121212; color: #eaeaea; }
.theme-dark .sidebar, .theme-dark .rightbar, .theme-dark .toolbar, .theme-dark .logo { background: #1e1e1e; border-color: #333; }
.theme-dark .section { border-color: #333; }
.theme-dark .canvas-scroll-area { background: #181818; }
.theme-dark .btn { background: transparent; color: #e0e0e0; border-color: #666; }
.theme-dark .btn:hover { background: rgba(255, 255, 255, 0.08); border-color: #888; }
.theme-dark .btn.active { background: #fff; color: #000; border-color: #fff; }
.theme-dark .btn-tool { background: #3a3a3a; color: #ccc; }
.theme-dark .btn-tool:hover { background: #444; }
.theme-dark .btn-tool.active { background: #fff; color: #000; }
.theme-dark .btn-secondary { background: transparent; color: #aaa; border-color: #555; }
.theme-dark .btn-secondary:hover { background: rgba(255, 255, 255, 0.05); border-color: #777; color: #ccc; }
.theme-dark .btn-secondary.active { background: #fff; color: #000; border-color: #fff; }
.theme-dark .btn-danger { background: #d32f2f; color: #fff; }
.theme-dark .btn-danger:hover { background: #b71c1c; }
.theme-dark .input-group input, .theme-dark .input-group select { background: #1a1a1a; color: #eaeaea; border-color: #333; }
.theme-dark .modal { background: #1e1e1e; }
.theme-dark .modal-header { border-bottom-color: #333; }
.theme-dark .modal-option { background: #222; }
.theme-dark .modal-option:hover { background: #2a2a2a; }
.theme-dark .modal-title { color: #eaeaea; }
.theme-dark .modal-section-title { color: #cfcfcf; opacity: 0.9; }
.theme-dark .modal-option label { color: #e0e0e0; }
.theme-dark .modal-option-desc { color: #aaaaaa; }
.theme-dark .format-btn { background: #2a2a2a; color: #eee; border-color: #333; }
.theme-dark .format-btn:hover { background: #333; }
.theme-dark .layers-panel { background: #1a1a1a; }
.theme-dark .layer-item { background: #222; color: #ddd; }
.theme-dark .layer-item:hover { background: #2b2b2b; }
.theme-dark .layer-item.active { background: #2d2d2d; color: #fff; }
.theme-dark #historyPanel { background: #1a1a1a; border-color: #333; }
.theme-dark .history-item { background: #1f1f1f; color: #d8d8d8; border-bottom-color: #2a2a2a; }
.theme-dark .history-item:hover { background: #272727; }
.theme-dark .history-item.current { background: #2d2d2d; color: #fff; }
.theme-dark .imposition-page { background: #222; border-color: #444; color: #eaeaea; }
.theme-dark .chemin-single-page-container { background: #222; border-color: #555; }
.theme-dark .chemin-page-thumb:hover .chemin-single-page-container { border-color: #888; box-shadow: 0 2px 8px rgba(0,0,0,0.5); }
.theme-dark .chemin-page-label { background: rgba(255, 255, 255, 0.9); color: #1a1a1a; }
.theme-dark .chemin-page-thumb.drag-over { outline-color: #888; }
.theme-dark .faq-question { border-bottom-color: #333; color: #e0e0e0 !important; }
.theme-dark .faq-answer { color: #d0d0d0 !important; }
.theme-dark .faq-answer div { color: #d0d0d0 !important; }
.theme-dark .faq-answer span { color: #999 !important; }
.theme-dark .faq-answer b { color: #fff !important; }
.theme-dark #faqModal .modal { background: #1e1e1e !important; }

/* Correction mode sombre pour la colonne de droite */
.theme-dark .section-title { color: #cfcfcf; opacity: 0.9; }
.theme-dark .unit-btn { background: #2a2a2a; color: #ddd; border-color: #333; }
.theme-dark .unit-btn:hover { background: #333; }
.theme-dark .unit-btn.active { background: #1a1a1a; color: #fff; border-color: #1a1a1a; }
.theme-dark .transform-input label { color: #aaa; opacity: 0.8; }

/* Trappe (Bibliothèque) Styles */
.trappe-tab {
    transition: all 0.2s;
}
.trappe-tab:hover {
    background: rgba(0,0,0,0.04);
}
.trappe-tab.active {
    background: #fff;
    border-left: 3px solid #1a1a1a !important;
    font-weight: 700;
}
#trappePanel #trappeContent { background: #fff !important; }
#trappePanel .trappe-tab { color: inherit; }
#trappePanel .trappe-tab:hover { background: rgba(0,0,0,0.04); }
#trappePanel .trappe-tab.active { background: #fff; border-left-color: #1a1a1a !important; }
#trappeTabs { background: #fff !important; border-right: 1px solid #ddd !important; border-left: none !important; }
.assets-scroll-btn { position: absolute; top: 50%; transform: translateY(-50%); z-index: 10020; background: rgba(0,0,0,0.16); color: #111; border: 1px solid rgba(0,0,0,0.15); width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; cursor: pointer; border-radius: 12px; box-shadow: 0 1px 3px rgba(0,0,0,0.12); backdrop-filter: saturate(110%) blur(1px); font-size: 16px; line-height: 1; }
.assets-scroll-btn:hover { background: rgba(0,0,0,0.22); }
#assetsScrollLeft { left: 72px; }
#assetsScrollRight { right: 8px; }
.trappe-item { height: calc(100% - 16px); display: inline-flex; flex-direction: column; align-items: center; justify-content: center; box-sizing: border-box; }
.trappe-content { display: flex; align-items: center; height: 100%; }
#designScroll { display: flex; align-items: center; height: 100%; padding-left: 8px !important; padding-right: 32px !important; position: relative; }
#trappeContent {
    opacity: 0;
    transform: translateY(-6px);
    transition: opacity 160ms ease, transform 160ms ease;
    will-change: opacity, transform;
    position: relative;
}
#trappePanel[data-open="true"] #trappeContent {
    opacity: 1;
    transform: translateY(0);
}
#trappeContent::before, #trappeContent::after {
    content: "";
    position: absolute;
    top: 0; bottom: 0;
    width: 48px;
    pointer-events: none;
    z-index: 10010;
}
#trappeContent::before { left: 72px;  background: linear-gradient(to right, #fff 0%, rgba(255,255,255,0) 100%); width: 60px; }
#trappeContent::after { right: 0; background: linear-gradient(to left, #fff 0%, rgba(255,255,255,0) 100%); }

.trappe-item {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 10px;
    cursor: grab;
    transition: all 0.2s;
    user-select: none;
    display: inline-block;
    vertical-align: top;
    width: 160px;
    margin-right: 12px;
}
.trappe-item:hover {
    border-color: #1a1a1a;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transform: translateY(-2px);
}
.trappe-item:active {
    cursor: grabbing;
}

.cursor-grab-hd {
    cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 32 32'><path fill='none' stroke='%23000' stroke-width='2' d='M8 19v-5a2 2 0 1 1 4 0v3M12 17v-6a2 2 0 1 1 4 0v6M16 17v-5a2 2 0 1 1 4 0v5M20 17v-4a2 2 0 1 1 4 0v8c0 3-2 5-5 5h-5c-3 0-5-2-5-5v-2'/></svg>") 8 8, grab !important;
}
.cursor-grabbing-hd {
    cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 32 32'><path fill='none' stroke='%23000' stroke-width='2' d='M9 14a2 2 0 1 1 4 0v2M13 14a2 2 0 1 1 4 0v2M17 14a2 2 0 1 1 4 0v2M21 14a2 2 0 1 1 4 0v6c0 3-2 5-5 5h-6c-3 0-5-2-5-5v-4'/></svg>") 8 8, grabbing !important;
}

.trappe-item-preview {
    background: #f9f9f9;
    border: 1px solid #e5e5e5;
    border-radius: 4px;
    padding: 6px;
    margin-bottom: 10px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    width: 100%;
}
.trappe-item-preview.trappe-item-preview-img { height: 100%; }
.trappe-item-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
}
.trappe-item-label { display: block; font-size: 10px; color: #666; margin-top: 17px; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; width: 100%; text-align: center; }
.trappe-item:hover .trappe-item-label { color: #333; }
.theme-dark #trappePanel {
    background: rgba(30,30,30,0.98) !important;
    border-bottom-color: #333 !important;
}
.theme-dark .trappe-tab { color: #ddd; }
.theme-dark .trappe-tab:hover { background: rgba(255,255,255,0.05); }
.theme-dark .trappe-tab.active {
    background: #222 !important;
    border-left-color: #fff !important;
    color: #fff;
}
.theme-dark .trappe-item { background: #222; border-color: #333; }
.theme-dark .trappe-item:hover { border-color: #666; }
.theme-dark .trappe-item-preview { background: #1a1a1a; border-color: #333; }
.theme-dark .trappe-item-label { color: #aaa; }
.theme-dark #trappeContent { background: #1e1e1e !important; border-bottom-color: #333 !important; }
.theme-dark #trappeContent::before { background: linear-gradient(to right, #1e1e1e 0%, rgba(30,30,30,0) 100%); }
.theme-dark #trappeContent::after { background: linear-gradient(to left, #1e1e1e 0%, rgba(30,30,30,0) 100%); }
.theme-dark .transform-input input { background: #1a1a1a; color: #eaeaea; border-color: #333; }
.theme-dark .nudge-btn { background: #2a2a2a; color: #ddd; border-color: #333; }
.theme-dark .nudge-btn:hover { background: #333; }
.theme-dark #cmykDisplay { background: #1a1a1a; color: #ddd; }
.theme-dark .rightbar input[type="color"] { border-color: #333; }
.theme-dark .rightbar input[type="number"] { background: #1a1a1a; color: #eaeaea; border-color: #333; }
.theme-dark .rightbar select { background: #1a1a1a; color: #eaeaea; border-color: #333; }
.theme-dark .rightbar label { color: #aaa; }
.theme-dark .rightbar div[style*="opacity: 0.6"] { color: #aaa; opacity: 0.8; }
.theme-dark .rightbar div[id$="Info"] { color: #aaa; }
.theme-dark .sidebar::-webkit-scrollbar-track,
.theme-dark .rightbar::-webkit-scrollbar-track,
.theme-dark #historyPanel::-webkit-scrollbar-track,
.theme-dark #designScroll::-webkit-scrollbar-track { background: #1a1a1a; }
.theme-dark .sidebar::-webkit-scrollbar-thumb,
.theme-dark .rightbar::-webkit-scrollbar-thumb,
.theme-dark #historyPanel::-webkit-scrollbar-thumb,
.theme-dark #designScroll::-webkit-scrollbar-thumb { background: #555; border-radius: 4px; }
.theme-dark .sidebar::-webkit-scrollbar-thumb:hover,
.theme-dark .rightbar::-webkit-scrollbar-thumb:hover,
.theme-dark #historyPanel::-webkit-scrollbar-thumb:hover { background: #666; }
.theme-dark .canvas-scroll-area::-webkit-scrollbar-track { background: #0a0a0a; }
.theme-dark .canvas-scroll-area::-webkit-scrollbar-thumb { background: #444; border-radius: 6px; }
.theme-dark .canvas-scroll-area::-webkit-scrollbar-thumb:hover { background: #555; }
.icon-btn {
    background: transparent;
    border: none;
    color: #888;
    cursor: pointer;
    padding: 6px;
    line-height: 1;
    border-radius: 4px;
}
.icon-btn:hover { color: #555; background: #f2f2f2; }
.input-group { margin-bottom: 10px; }
.input-group label {
    display: block;
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
    opacity: 0.6;
}
.input-group input,
.input-group select {
    width: 100%;
    height: 28px;
    padding: 0 6px;
    border: 1px solid #e0e0e0;
    background: #fff;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10px;
    box-sizing: border-box;
}
.input-group input[type="color"] {
    height: 28px;
    padding: 2px;
    border-radius: 4px;
    cursor: pointer;
}
.input-row { display: flex; gap: 6px; }
.input-row .input-group { flex: 1; min-width: 0; }
.canvas-container { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.toolbar { background: #fff; border-bottom: 1px solid #e0e0e0; padding: 12px 20px; display: flex; justify-content: space-between; align-items: center; }
.toolbar-left,
.toolbar-right { display: flex; gap: 8px; align-items: center; }
.canvas-wrapper { flex: 1; overflow: hidden; position: relative; background: #e8e8e8; display: flex; }
.cmyk-preview-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 9998; display: none; background: rgba(0, 40, 60, 0.08); mix-blend-mode: multiply; }
.cmyk-preview-overlay.active { display: block; }
.cmyk-preview-label { position: fixed; top: 80px; right: 296px; background: #000000; color: #fff; padding: 8px 16px; font-family: 'IBM Plex Mono', monospace; font-size: 11px; font-weight: 700; letter-spacing: 1px; z-index: 9999; display: none; box-shadow: 0 4px 12px rgba(0,0,0,0.3); border-left: 4px solid #333333; }
.cmyk-preview-label.active { display: block; }
.canvas-scroll-area { 
    flex: 1; 
    overflow: auto; 
    display: flex; 
    align-items: flex-start; 
    justify-content: center; 
    padding: 40px; 
    position: relative;
}
.typo-styles-widget { position: absolute; left: 16px; bottom: 144px; z-index: 30; background: rgba(255,255,255,0.96); color: #111; border: 1px solid rgba(0,0,0,0.12); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,0.15); min-width: 160px; max-width: 200px; overflow: hidden; user-select: none; backdrop-filter: saturate(1.2) blur(2px); display: flex; flex-direction: column; }
.theme-dark .typo-styles-widget { background: rgba(24,24,24,0.96); color: #e6e6e6; border-color: rgba(255,255,255,0.1); }
.typo-styles-header { display: flex; align-items: center; gap: 6px; padding: 6px 8px; font-weight: 700; font-size: 11px; letter-spacing: 0.8px; text-transform: uppercase; cursor: move; }
.typo-styles-header .dot { width: 5px; height: 5px; border-radius: 50%; background: #111; }
.theme-dark .typo-styles-header .dot { background: #e6e6e6; }
.typo-styles-list { display: none; padding: 4px; max-height: 260px; overflow: auto; }
.typo-styles-widget.expanded .typo-styles-list { display: block; }
.typo-style-item { padding: 6px 8px; border-radius: 6px; cursor: pointer; transition: background 0.15s ease; font-size: 10px; display: flex; align-items: center; justify-content: space-between; }
.typo-style-item:hover { background: rgba(0,0,0,0.06); }
.theme-dark .typo-style-item:hover { background: rgba(255,255,255,0.08); }
.typo-style-item small { opacity: 0.6; font-size: 9px; margin-left: 4px; }
.typo-style-add { display: block; width: 100%; text-align: center; background: transparent; border: none; color: inherit; padding: 6px 8px; font-size: 10px; border-top: 1px dashed rgba(0,0,0,0.1); cursor: pointer; }
.theme-dark .typo-style-add { border-top-color: rgba(255,255,255,0.15); }
.typo-style-add:hover { background: rgba(0,0,0,0.06); }
.theme-dark .typo-style-add:hover { background: rgba(255,255,255,0.08); }
.swatches-widget { position: absolute; left: 16px; bottom: 80px; z-index: 29; background: rgba(255,255,255,0.96); color: #111; border: 1px solid rgba(0,0,0,0.12); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,0.15); min-width: 160px; max-width: 200px; overflow: hidden; user-select: none; backdrop-filter: saturate(1.2) blur(2px); display: flex; flex-direction: column; }
/* ==================== FILTERS WIDGET ==================== */
.filters-widget { position: absolute; left: 16px; bottom: 16px; z-index: 31; background: rgba(255,255,255,0.96); color: #111; border: 1px solid rgba(0,0,0,0.12); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,0.15); min-width: 160px; max-width: 200px; overflow: hidden; user-select: none; backdrop-filter: saturate(1.2) blur(2px); display: flex; flex-direction: column; }
.theme-dark .filters-widget { background: rgba(24,24,24,0.96); color: #e6e6e6; border-color: rgba(255,255,255,0.1); }
.filters-header { display: flex; align-items: center; gap: 6px; padding: 6px 8px; cursor: move; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px; }
.filters-header .dot { width: 5px; height: 5px; border-radius: 50%; background: #111; }
.theme-dark .filters-header .dot { background: #e6e6e6; }
.filters-toggle-arrow { font-size: 10px; transition: transform 0.2s; }
.filters-widget .filters-list { display: none; }
.filters-widget.expanded .filters-list { display: block; }
.filters-widget.expanded .filters-toggle-arrow { transform: rotate(180deg); }
.filters-list { padding: 4px; max-height: 260px; overflow-y: auto; overflow-x: hidden; }
.filter-item { display: flex; align-items: center; gap: 8px; padding: 6px 8px; background: transparent; border: none; width: 100%; cursor: pointer; transition: background 0.15s; text-align: left; border-radius: 6px; }
.filter-item:hover { background: rgba(0,0,0,0.06); }
.theme-dark .filter-item:hover { background: rgba(255,255,255,0.08); }
.filter-item.active { background: rgba(0,0,0,0.1); }
.theme-dark .filter-item.active { background: rgba(255,255,255,0.15); }
.filter-preview { width: 32px; height: 32px; border-radius: 6px; border: 1px solid rgba(0,0,0,0.1); flex-shrink: 0; }
.theme-dark .filter-preview { border-color: rgba(255,255,255,0.15); }
.filter-name { font-size: 10px; font-weight: 500; color: inherit; }

/* PAGE & LAYOUT CONTAINERS */
.pages-container { 
    display: flex; 
    flex-direction: column; 
    gap: 40px; 
    align-items: center; 
    transform-origin: top center; 
    transition: transform 0.2s ease;
    margin: 0 auto;
}
.page-wrapper { 
    position: relative; 
    transition: all 0.2s ease;
    display: flex;
    justify-content: center;
    padding-bottom: 16px;
}
.page-wrapper.active-page .canvas-inner { box-shadow: 0 0 0 3px #00aaff, 0 4px 20px rgba(0,0,0,0.1); }
.spread-wrapper { 
    display: flex; 
    gap: 0px; 
    margin-bottom: 40px; 
    position: relative;
    justify-content: center;
}
.spread-wrapper.active-page .canvas-inner { box-shadow: 0 0 0 3px #00aaff, 0 4px 20px rgba(0,0,0,0.1); }
.spread-center-line { position: absolute; background: rgba(0,0,0,0.15); pointer-events: none; z-index: 10; }
.spread-center-line:before { content: ''; position: absolute; top: -5px; left: -2px; width: 5px; height: 5px; background: rgba(0,0,0,0.2); border-radius: 50%; }
.spread-center-line:after { content: ''; position: absolute; bottom: -5px; left: -2px; width: 5px; height: 5px; background: rgba(0,0,0,0.2); border-radius: 50%; }
.canvas-inner { background: #ffffff; box-shadow: 0 4px 20px rgba(0,0,0,0.1); position: relative; margin-bottom: 10px; z-index: 2; }
/* 🎯 Forcer les canvas Fabric.js à avoir un fond blanc pur */
.canvas-inner canvas { background: #ffffff !important; }
.canvas-inner .canvas-container { background: #ffffff !important; }
.canvas-inner canvas.lower-canvas { background: #ffffff !important; }
.canvas-inner canvas.upper-canvas { background: transparent !important; }
.ruler-horizontal { position: absolute; top: -20px; left: 0; height: 20px; background: #f0f0f0; border-bottom: 1px solid #ccc; cursor: crosshair; z-index: 100; }
.ruler-vertical { position: absolute; left: -20px; top: 0; width: 20px; background: #f0f0f0; border-right: 1px solid #ccc; cursor: crosshair; z-index: 100; }
.guide-line { position: absolute; background: #ff00ff; pointer-events: auto; z-index: 99; }
.guide-line.horizontal { height: 1px; width: 100%; left: 0; cursor: ns-resize; }
.guide-line.vertical { width: 1px; height: 100%; top: 0; cursor: ew-resize; }
.guide-label { position: absolute; background: #000; color: #fff; padding: 2px 6px; font-size: 10.8px; font-family: 'IBM Plex Mono', monospace; border-radius: 2px; white-space: nowrap; pointer-events: none; z-index: 100; }
.ruler-tick { position: absolute; background: #666; }
.ruler-tick.major { background: #333; }
.ruler-label { position: absolute; font-size: 9.6px; color: #666; font-family: 'IBM Plex Mono', monospace; }
.page-number { 
    text-align: left; 
    font-size: 10px; 
    opacity: 0.5; 
    margin-top: 4px; 
    margin-left: 0;
    font-family: 'IBM Plex Mono', monospace; 
}
.preset-formats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.format-btn { padding: 8px 8px; background: #f8f8f8; border: 1px solid #e0e0e0; cursor: pointer; text-align: center; font-size: 10px; transition: all 0.2s; }
.format-btn:hover { background: #f0f0f0; }
.format-btn.active { background: #1a1a1a; color: #fff; border-color: #1a1a1a; }
.layers-panel { max-height: 240px; overflow-y: auto; }
.layer-item { padding: 6px 8px; background: #f8f8f8; margin-bottom: 3px; cursor: pointer; font-size: 10px; display: flex; justify-content: space-between; align-items: center; }
.layer-item:hover { background: #f0f0f0; }
.layer-item.active { background: #1a1a1a; color: #fff; }
.overflow-indicator { width: 8px; height: 8px; background: #ff0000; border-radius: 2px; }
.link-indicator { font-size: 9px; opacity: 0.7; }
.rightbar { width: 280px; background: #fff; border-left: 1px solid #e0e0e0; overflow-y: auto; }
.rightbar .section { padding: 12px 14px; border-bottom: 1px solid #e0e0e0; }
.rightbar .section-title { margin-bottom: 10px; }
.rightbar .btn { height: 28px; padding: 0 10px; font-size: 9px; }
.rightbar .btn-group { gap: 6px; margin-bottom: 10px; }
.rightbar .btn-group .btn { flex: 1; min-width: 0; }
.unit-toggle { display: flex; gap: 3px; margin-bottom: 10px; }
.unit-btn { flex: 1; padding: 5px; background: #f0f0f0; border: 1px solid #e0e0e0; cursor: pointer; font-size: 9px; text-align: center; }
.unit-btn.active { background: #1a1a1a; color: #fff; }
.transform-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 10px; }
.transform-input label { font-size: 8px; text-transform: uppercase; opacity: 0.6; margin-bottom: 3px; display: block; }
.transform-input input { width: 100%; height: 28px; padding: 0 5px; font-size: 10px; border: 1px solid #e0e0e0; box-sizing: border-box; }
.nudge-controls { display: flex; gap: 3px; margin-top: 6px; flex-wrap: nowrap; }
.nudge-btn { padding: 3px 5px; background: #f0f0f0; border: 1px solid #e0e0e0; cursor: pointer; font-size: 9px; text-align: center; flex: 1; min-width: 0; }
.nudge-btn:hover { background: #e0e0e0; }
#historyPanel { max-height: 120px; overflow-y: auto; background: #fafafa; border: 1px solid #e0e0e0; }
.history-item { padding: 4px 8px; border-bottom: 1px solid #e8e8e8; cursor: pointer; font-size: 8px; display: flex; justify-content: space-between; align-items: center; transition: all 0.15s; gap: 8px; }
.history-item:hover { background: #f0f0f0; }
.history-item.current { background: #1a1a1a; color: #fff; font-weight: 500; }
.history-item-action { font-weight: 500; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-item-time { opacity: 0.5; font-size: 7px; flex-shrink: 0; }
.modal-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.6); z-index: 10000; align-items: center; justify-content: center; }
.modal-overlay.active { display: flex; }
.modal { background: #fff; border-radius: 0; max-width: 600px; width: 90%; max-height: 80vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3); animation: modalSlideIn 0.3s ease; }
@keyframes modalSlideIn { from { transform: translateY(-20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-header { padding: 24px; border-bottom: 1px solid #e0e0e0; position: relative; }
.modal-title { font-size: 14px; font-weight: 500; letter-spacing: 2px; text-transform: uppercase; }
.modal-body { padding: 24px; }
.modal-close { background: transparent; border: none; font-size: 22px; line-height: 1; cursor: pointer; margin-left: auto; }
.modal-section { margin-bottom: 24px; }
.modal-section:last-child { margin-bottom: 0; }
.modal-section-title { font-size: 10px; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 12px; opacity: 0.6; }
.modal-options { display: flex; flex-direction: column; gap: 12px; }
.modal-option { display: flex; align-items: center; gap: 12px; padding: 12px; background: #f8f8f8; cursor: pointer; transition: all 0.2s; }
.modal-option:hover { background: #f0f0f0; }
.modal-option input[type="checkbox"], .modal-option input[type="radio"] { width: 18px; height: 18px; cursor: pointer; accent-color: #000000; }
.modal-option label { flex: 1; cursor: pointer; font-size: 11px; color: #000; font-weight: normal; }
.modal-option-desc { font-size: 9px; color: #666; margin-top: 4px; }
.modal-footer { padding: 20px 24px; border-top: 1px solid #e0e0e0; display: flex; gap: 12px; justify-content: flex-end; }
.modal-btn { height: 40px; padding: 0 24px; border: none; cursor: pointer; font-family: 'IBM Plex Mono', monospace; font-size: 11px; letter-spacing: 0.5px; transition: all 0.2s; display: inline-flex; align-items: center; justify-content: center; box-sizing: border-box; }
.modal-btn-primary { background: #1a1a1a; color: #fff; }
.modal-btn-primary:hover { background: #333; }
.modal-btn-secondary { background: #f0f0f0; color: #1a1a1a; }
.modal-btn-secondary:hover { background: #e0e0e0; }
.imposition-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 12px; }
.imposition-page { aspect-ratio: 1/1.414; background: #fff; border: 2px solid #e0e0e0; display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 600; transition: all 0.2s; }
.imposition-page:hover { border-color: #1a1a1a; }
.color-swatch { aspect-ratio: 1; cursor: pointer; border-radius: 2px; transition: all 0.2s; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.color-swatch:hover { transform: scale(1.15); box-shadow: 0 2px 6px rgba(0,0,0,0.2); z-index: 10; }
.color-swatch.active { border: 2px solid #1a1a1a !important; box-shadow: 0 0 0 2px #fff, 0 0 0 4px #1a1a1a; }
@media print { .upper-canvas, .guide-line, .guide-label, .ruler-horizontal, .ruler-vertical { display: none !important; } }
.chemin-page-thumb { background: transparent; border: none; border-radius: 0; padding: 0; cursor: move; transition: all 0.2s; position: relative; display: flex; gap: 2px; }
.chemin-page-thumb.single-page { aspect-ratio: 1/1.414; }
.chemin-page-thumb.spread-page { aspect-ratio: 2/1.414; }
.chemin-page-thumb:hover { transform: translateY(-2px); }
.chemin-page-thumb.dragging { opacity: 0.5; transform: rotate(2deg); }
.chemin-page-thumb.drag-over { outline: 3px solid #1a1a1a; outline-offset: 2px; }
.chemin-single-page-container { flex: 1; position: relative; background: #fff; border: 2px solid #d0d0d0; border-radius: 2px; overflow: hidden; display: flex; align-items: center; justify-content: center; transition: all 0.2s; }
.chemin-page-thumb:hover .chemin-single-page-container { border-color: #1a1a1a; box-shadow: 0 2px 8px rgba(0,0,0,0.12); }
.chemin-single-page-container img { width: 100%; height: 100%; object-fit: contain; display: block; }
.chemin-page-label { position: absolute; top: 4px; left: 4px; background: rgba(26,26,26,0.85); color: #fff; padding: 3px 7px; border-radius: 2px; font-size: 10px; font-weight: 700; letter-spacing: 0.3px; z-index: 10; pointer-events: none; backdrop-filter: blur(4px); }
.chemin-single-page-container.right-page .chemin-page-label { left: auto; right: 4px; }
.chemin-drop-end { background: #fff; border: 2px dashed #e0e0e0; border-radius: 4px; padding: 12px; display: flex; align-items: center; justify-content: center; color: #7a7a7a; font-size: 11px; font-family: 'IBM Plex Mono', monospace; min-height: 64px; transition: all 0.2s; }
.chemin-drop-end.active { border-color: #1a1a1a; background: #f5f5f5; color: #1a1a1a; }
.chemin-insert-indicator { position: absolute; width: 4px; height: 100%; background: #1a1a1a; z-index: 1000; pointer-events: none; opacity: 0; transition: opacity 0.15s; box-shadow: 0 0 8px rgba(26,26,26,0.5); }
.chemin-insert-indicator.active { opacity: 1; }
.chemin-insert-indicator.left { left: -8px; }
.chemin-insert-indicator.right { right: -8px; }
.chemin-page-number { text-align: center; font-size: 14px; font-weight: 700; color: #fff; padding: 6px 8px; background: #1a1a1a; border-radius: 3px; letter-spacing: 0.5px; }
.chemin-page-actions { display: flex; gap: 4px; justify-content: center; }
.chemin-page-btn { padding: 4px 8px; font-size: 9px; background: #fff; border: 1px solid #e0e0e0; cursor: pointer; border-radius: 2px; transition: all 0.2s; }
.chemin-page-btn:hover { background: #1a1a1a; color: #fff; border-color: #1a1a1a; }
#cropCanvas { cursor: crosshair; border-radius: 4px; box-shadow: 0 2px 8px rgba(0,0,0,0.1); transition: box-shadow 0.2s ease; }
#cropCanvas:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.15); }
#cropModal input[type="number"] { border: 1px solid #ddd; border-radius: 3px; font-family: 'IBM Plex Mono', monospace; text-align: center; }
#cropModal input[type="number"]:focus { border-color: #ff6b00; box-shadow: 0 0 0 2px rgba(255,107,0,0.1); }
.image-crop-btn { position: absolute; width: 12px; height: 12px; background: #2196F3; border: 2px solid #fff; border-radius: 50%; cursor: pointer; z-index: 1000; box-shadow: 0 2px 4px rgba(0,0,0,0.3); opacity: 0; transition: all 0.2s ease; }
.image-crop-btn:hover { background: #1976D2; transform: scale(1.2); box-shadow: 0 3px 6px rgba(0,0,0,0.4); }
.mask-context-menu { position: absolute; background: #fff; border: 1px solid #ddd; border-radius: 8px; padding: 6px; z-index: 10001; box-shadow: 0 4px 16px rgba(0,0,0,0.15); min-width: 150px; max-width: 150px; display: none; font-family: -apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif; }
.mask-context-menu.active { display: block; }
.mask-menu-item { padding: 8px 10px; cursor: pointer; border-radius: 6px; font-size: 12px; color: #333; display: flex; align-items: center; gap: 8px; transition: all 0.15s ease; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mask-menu-item:hover { background: rgba(0,0,0,0.06); }
.mask-menu-item.disabled { opacity: 0.5; cursor: not-allowed; }
.mask-menu-item.disabled:hover { background: transparent; }
.mask-menu-divider { height: 1px; background: rgba(0,0,0,0.1); margin: 4px 0; }
.mask-menu-icon { width: 14px; text-align: center; font-size: 12px; flex-shrink: 0; }
.mask-position-submenu { padding: 6px; background: #f8f8f8; border-radius: 6px; margin-top: 4px; }
.mask-position-grid { display: grid; grid-template-columns: repeat(3, 26px); grid-template-rows: repeat(3, 26px); gap: 6px; }
.mask-position-panel { position: fixed; background: #fff; border: 1px solid #ddd; border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.15); padding: 12px 14px; z-index: 10000; display: none; flex-direction: column; gap: 8px; min-width: 180px; }
.mask-position-panel.active { display: flex; }
.mask-position-btn { width: 30px; height: 30px; background: #fff; border: 1px solid #ddd; border-radius: 6px; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 15px; transition: all 0.12s ease; user-select: none; }
.mask-position-btn:hover { background: rgba(0,0,0,0.06); border-color: #999; transform: scale(1.04); }
.mask-position-btn.active { background: #FF5722; color: #fff; border-color: #FF5722; }
.shape-mask-btn:hover { background: #E64A19; transform: scale(1.1); box-shadow: 0 3px 10px rgba(0,0,0,0.4); }
.login-screen { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: #fff; display: flex; align-items: center; justify-content: center; z-index: 99999; }
.login-screen.hidden { display: none; }
.login-content { text-align: center; }
.login-logo { font-family: 'IBM Plex Mono', monospace; font-size: 18px; font-weight: 500; letter-spacing: 2px; margin-bottom: 10px; color: #1a1a1a; }
html[lang="ja"] .login-logo, html[lang="ja"] .logo span { font-family: 'Noto Sans JP','Hiragino Kaku Gothic ProN','Yu Gothic',Meiryo,'MS PGothic',sans-serif !important; letter-spacing: 1px; }
.login-form { margin-top: 20px; }
.login-input { width: 280px; height: 40px; padding: 0 16px; font-size: 11px; font-family: 'IBM Plex Mono', monospace; background: #fff; border: 1px solid #e0e0e0; color: #1a1a1a; text-align: center; letter-spacing: 1px; transition: all 0.2s; box-sizing: border-box; }
.login-input:focus { outline: none; border-color: #1a1a1a; }
.login-input::placeholder { color: #999; letter-spacing: 1px; }
.login-btn { margin-top: 12px; height: 40px; padding: 0 40px; font-size: 10px; font-family: 'IBM Plex Mono', monospace; letter-spacing: 1px; background: #1a1a1a; border: none; color: #fff; cursor: pointer; transition: all 0.2s; text-transform: uppercase; display: inline-flex; align-items: center; justify-content: center; box-sizing: border-box; }
.login-btn:hover { background: #333; }
.login-error { color: #ff0000; margin-top: 12px; font-size: 10px; opacity: 0; transition: opacity 0.3s; }
.login-error.show { opacity: 1; }

/* ==================== SWATCHES WIDGET (color pastilles) ==================== */
/* Container already defined as .swatches-widget; extend with internals */
.theme-dark .swatches-widget { background: rgba(24,24,24,0.96); color: #e6e6e6; border-color: rgba(255,255,255,0.1); }

.swatches-header { display: flex; align-items: center; gap: 6px; padding: 6px 8px; cursor: move; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px; }
.swatches-header .dot { width: 5px; height: 5px; border-radius: 50%; background: #111; }
.theme-dark .swatches-header .dot { background: #e6e6e6; }
.swatches-toggle-arrow { font-size: 10px; transition: transform 0.2s; opacity: 0.6; }

.swatches-list { display: none; padding: 4px; max-height: 260px; overflow: auto; }
.swatches-widget.expanded .swatches-list { display: block; }
.swatches-widget.expanded .swatches-toggle-arrow { transform: rotate(180deg); }

.swatch-item { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; cursor: pointer; transition: background 0.15s ease, transform 0.12s ease; border: 1px solid transparent; }
.swatch-item:hover { background: rgba(0,0,0,0.06); transform: scale(1.02); }
.theme-dark .swatch-item:hover { background: rgba(255,255,255,0.08); }

/* Pastille preview */
.swatch-preview { width: 22px; height: 22px; border-radius: 50%; border: 1px solid rgba(0,0,0,0.1); box-shadow: inset 0 0 0 1px rgba(255,255,255,0.35); flex-shrink: 0; }
.theme-dark .swatch-preview { border-color: rgba(255,255,255,0.15); box-shadow: inset 0 0 0 1px rgba(0,0,0,0.35); }

.swatch-info { display: flex; flex-direction: column; min-width: 0; }
.swatch-name { font-size: 12px; line-height: 1.2; font-weight: 600; color: #0f172a; }
.theme-dark .swatch-name { color: #e5e7eb; }
.swatch-value { font-size: 11px; line-height: 1.2; color: #64748b; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.theme-dark .swatch-value { color: #94a3b8; }

.swatch-add { display: block; width: 100%; text-align: center; background: transparent; border: none; color: inherit; padding: 6px 8px; font-size: 10px; border-top: 1px dashed rgba(0,0,0,0.1); cursor: pointer; }
.theme-dark .swatch-add { border-top-color: rgba(255,255,255,0.15); }
.swatch-add:hover { background: rgba(0,0,0,0.06); }
.theme-dark .swatch-add:hover { background: rgba(255,255,255,0.08); }

/* ==================== SWATCH CREATOR MODAL ==================== */
#swatchCreatorModal { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 20000; align-items: center; justify-content: center; }
#swatchCreatorModal .modal-body { background: #ffffff; border-radius: 12px; width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow: auto; padding: 16px; border: 1px solid #e5e7eb; }
.theme-dark #swatchCreatorModal .modal-body { background: #0f1114; border-color: #2a2d31; }

.swatch-type-btn { display: inline-flex; align-items: center; justify-content: center; padding: 8px 10px; border-radius: 8px; border: 2px solid #ddd; background: #fff; cursor: pointer; margin-right: 6px; font-size: 13px; font-weight: 600; }
.swatch-type-btn.active { border-color: #000; }
.theme-dark .swatch-type-btn { background: #111214; border-color: #2a2d31; color: #e5e7eb; }
.theme-dark .swatch-type-btn.active { border-color: #e5e7eb; }

#swatchPreview { width: 100%; height: 80px; border: 1px solid #e5e7eb; border-radius: 8px; background: #000; }
.theme-dark #swatchPreview { border-color: #2a2d31; }

#swatchCMYKPreview { display: none; margin-top: 8px; padding: 8px 12px; background: #f5f5f5; border-radius: 6px; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; font-size: 11px; color: #666; }
.theme-dark #swatchCMYKPreview { background: #15171a; color: #e5e7eb; }

#cancelSwatchBtn { padding: 10px 20px; border: 1px solid #ddd; background: #fff; border-radius: 6px; cursor: pointer; font-size: 14px; font-weight: 500; }
#createSwatchBtn { padding: 10px 20px; border: none; background: #000; color: #fff; border-radius: 6px; cursor: pointer; font-size: 14px; font-weight: 600; }

/* ==================== PATHFINDER WIDGET ==================== */
.pathfinder-widget { position: absolute; left: 16px; bottom: 208px; z-index: 28; background: rgba(255,255,255,0.96); color: #111; border: 1px solid rgba(0,0,0,0.12); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,0.15); min-width: 160px; max-width: 200px; overflow: hidden; user-select: none; backdrop-filter: saturate(1.2) blur(2px); display: flex; flex-direction: column; }
.theme-dark .pathfinder-widget { background: rgba(24,24,24,0.96); color: #e6e6e6; border-color: rgba(255,255,255,0.1); }

.pathfinder-header { display: flex; align-items: center; gap: 6px; padding: 6px 8px; cursor: move; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px; }
.pathfinder-header .dot { width: 5px; height: 5px; border-radius: 50%; background: #111; }
.theme-dark .pathfinder-header .dot { background: #e6e6e6; }
.pathfinder-toggle-arrow { font-size: 10px; transition: transform 0.2s; opacity: 0.6; }

.pathfinder-list { display: none; padding: 4px; }
.pathfinder-widget.expanded .pathfinder-list { display: flex; flex-direction: column; gap: 4px; }
.pathfinder-widget.expanded .pathfinder-toggle-arrow { transform: rotate(180deg); }

.pathfinder-item { display: flex; align-items: center; gap: 8px; padding: 8px; background: transparent; border: none; width: 100%; cursor: pointer; transition: background 0.15s; text-align: left; border-radius: 6px; color: inherit; font-size: 12px; }
.pathfinder-item:hover { background: rgba(0,0,0,0.06); }
.theme-dark .pathfinder-item:hover { background: rgba(255,255,255,0.08); }
.pathfinder-item:active { background: rgba(0,0,0,0.12); }
.theme-dark .pathfinder-item:active { background: rgba(255,255,255,0.15); }

.pathfinder-icon { width: 28px; height: 28px; border-radius: 6px; border: 1px solid rgba(0,0,0,0.1); display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; background: #f8f9fa; }
.theme-dark .pathfinder-icon { border-color: rgba(255,255,255,0.15); background: #1a1b1e; }

.pathfinder-name { font-size: 11px; font-weight: 500; color: inherit; }
