/* =============================================
   DESIGN APPLE — Variables
   ============================================= */
:root {
    /* Couleurs système Apple (clair) */
    --blue:        #007AFF;
    --blue-hover:  #0066d6;
    --green:       #34C759;
    --red:         #FF3B30;
    --orange:      #FF9500;
    --yellow:      #FFD60A;
    --purple:      #AF52DE;

    /* Couches de gris */
    --gray-1: #8e8e93;
    --gray-2: #aeaeb2;
    --gray-3: #c7c7cc;
    --gray-4: #d1d1d6;
    --gray-5: #e5e5ea;
    --gray-6: #f2f2f7;

    /* Etiquettes */
    --label:            #000000;
    --label-2:          rgba(60, 60, 67, 0.60);
    --label-3:          rgba(60, 60, 67, 0.30);
    --separator:        rgba(60, 60, 67, 0.12);
    --separator-strong: rgba(60, 60, 67, 0.22);

    /* Fonds */
    --bg:          #f2f2f7;
    --bg-card:     #ffffff;
    --bg-subtle:   #f2f2f7;
    --bg-input:    rgba(120, 120, 128, 0.12);
    --bg-selected: rgba(0, 122, 255, 0.10);

    /* Ombres */
    --shadow-sm: 0 1px 0 rgba(0,0,0,.04), 0 1px 4px rgba(0,0,0,.06);
    --shadow:    0 2px 8px rgba(0,0,0,.08), 0 0 0 .5px rgba(0,0,0,.05);

    /* Rayon */
    --r-sm:  8px;
    --r:    12px;
    --r-lg: 16px;
    --r-xl: 20px;

    /* Transition */
    --t: 200ms cubic-bezier(.4,0,.2,1);

    /* Blue tint surface */
    --blue-surface: rgba(0, 122, 255, 0.10);
}

/* Mode sombre */
[data-theme="dark"] {
    --blue:      #0A84FF;
    --blue-hover:#2593ff;
    --green:     #30D158;
    --red:       #FF453A;
    --orange:    #FF9F0A;

    --gray-1: #8e8e93;
    --gray-2: #636366;
    --gray-3: #48484a;
    --gray-4: #3a3a3c;
    --gray-5: #2c2c2e;
    --gray-6: #1c1c1e;

    --label:   #ffffff;
    --label-2: rgba(235,235,245,.60);
    --label-3: rgba(235,235,245,.30);
    --separator:        rgba(84,84,88,.65);
    --separator-strong: rgba(84,84,88,.85);

    --bg:       #000000;
    --bg-card:  #1c1c1e;
    --bg-subtle:#2c2c2e;
    --bg-input: rgba(120,120,128,.24);
    --bg-selected: rgba(10, 132, 255, 0.18);

    --shadow-sm: 0 1px 0 rgba(0,0,0,.3);
    --shadow:    0 2px 8px rgba(0,0,0,.5), 0 0 0 .5px rgba(255,255,255,.06);

    --blue-surface: rgba(10, 132, 255, 0.15);
}

/* =============================================
   RESET
   ============================================= */
*, *::before, *::after {
    margin: 0; padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html { overflow-anchor: none; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text',
                 'Helvetica Neue', Helvetica, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.47;
    color: var(--label);
    background: var(--bg);
    min-height: 100vh;
    min-height: -webkit-fill-available;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    padding: env(safe-area-inset-top,0)
             env(safe-area-inset-right,0)
             env(safe-area-inset-bottom,0)
             env(safe-area-inset-left,0);
    transition: background var(--t), color var(--t);
}

/* =============================================
   LOADING
   ============================================= */
.loading-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.5);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 14px; z-index: 9999;
}
.loading-spinner {
    width: 36px; height: 36px;
    border: 3px solid rgba(255,255,255,.25);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text {
    color: #fff; font-size: 14px; font-weight: 500;
    letter-spacing: .01em;
}

/* =============================================
   THEME TOGGLE
   ============================================= */
.theme-toggle {
    position: fixed; top: 16px; right: 16px;
    width: 38px; height: 38px;
    border-radius: 50%;
    background: var(--bg-card);
    border: none;
    box-shadow: var(--shadow);
    color: var(--label);
    font-size: 17px; line-height: 1;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; z-index: 100;
    transition: transform var(--t), box-shadow var(--t);
}
.theme-toggle:hover { transform: scale(1.08); box-shadow: 0 4px 16px rgba(0,0,0,.15); }

/* Bouton installer PWA */
.install-btn {
    position: fixed; top: 16px; right: 64px;
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 14px;
    background: var(--blue); color: #fff;
    border: none; border-radius: 980px;
    font-family: inherit; font-size: .82em; font-weight: 600;
    cursor: pointer; z-index: 100;
    box-shadow: 0 4px 14px rgba(0,122,255,.4);
    transition: transform var(--t), box-shadow var(--t);
}
.install-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(0,122,255,.5); }
.install-btn:active { transform: scale(.96); }

/* Indicateur hors ligne */
.offline-indicator {
    position: fixed; bottom: 16px; left: 50%;
    transform: translateX(-50%);
    display: inline-flex; align-items: center; gap: 6px;
    padding: 7px 14px;
    background: var(--orange); color: #fff;
    border-radius: 980px;
    font-size: .8em; font-weight: 600;
    box-shadow: 0 4px 14px rgba(255,149,0,.4);
    z-index: 100;
    animation: slideUp .3s ease;
}
@keyframes slideUp {
    from { opacity: 0; transform: translate(-50%, 12px); }
    to   { opacity: 1; transform: translate(-50%, 0); }
}

/* iOS Safari install banner (bottom of screen) */
.ios-safari-banner {
    position: fixed; bottom: 0; left: 0; right: 0;
    z-index: 9998;
    padding: 0 0 env(safe-area-inset-bottom, 0);
    animation: slideUp .4s cubic-bezier(.32,1,.28,1);
}
.ios-safari-banner-content {
    display: flex; align-items: center; gap: 10px;
    background: var(--surface-2);
    border-top: 1px solid var(--separator);
    padding: 12px 16px;
    box-shadow: 0 -4px 20px rgba(0,0,0,.12);
}
.ios-safari-banner-icon {
    width: 40px; height: 40px; flex-shrink: 0;
    background: linear-gradient(135deg, #0A84FF, #0066d6);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    color: #fff;
}
.ios-safari-banner-text {
    flex: 1; display: flex; flex-direction: column; gap: 2px;
    font-size: .84em;
}
.ios-safari-banner-text strong { color: var(--label); }
.ios-safari-banner-text span { color: var(--label-2); }
.ios-safari-banner-text em { font-style: normal; font-weight: 600; }
.ios-safari-banner-close {
    background: var(--surface-3); border: none;
    width: 26px; height: 26px; border-radius: 50%;
    font-size: .8em; color: var(--label-3);
    cursor: pointer; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-family: inherit;
}
.ios-safari-banner-arrow {
    text-align: center;
    font-size: 1.1em; color: var(--blue);
    padding: 2px 0 4px;
    animation: bounce .9s infinite alternate ease-in-out;
}
.ios-copy-link-btn {
    display: flex; align-items: center; gap: 8px; justify-content: center;
    width: 100%; margin-top: 16px;
    padding: 12px;
    background: var(--blue); color: #fff;
    border: none; border-radius: 12px;
    font-size: .92em; font-weight: 600;
    cursor: pointer; font-family: inherit;
}

/* iOS install guide modal */
.ios-install-modal {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex; align-items: flex-end; justify-content: center;
    z-index: 9999;
    padding: 0 0 0 0;
    animation: fadeIn .2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.ios-install-card {
    background: var(--surface-2);
    border-radius: 20px 20px 0 0;
    padding: 28px 24px 40px;
    width: 100%; max-width: 480px;
    position: relative;
    animation: slideUp2 .3s cubic-bezier(.32,1,.28,1);
}
@keyframes slideUp2 {
    from { transform: translateY(60px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}
.ios-install-close {
    position: absolute; top: 16px; right: 16px;
    background: var(--surface-3); border: none;
    width: 30px; height: 30px; border-radius: 50%;
    font-size: .9em; color: var(--label-2);
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    font-family: inherit;
}
.ios-install-icon {
    width: 56px; height: 56px;
    background: linear-gradient(135deg, #0A84FF, #0066d6);
    border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    margin: 0 auto 16px;
    box-shadow: 0 4px 16px rgba(0,122,255,.3);
}
.ios-install-title {
    text-align: center; font-size: 1.2em; font-weight: 700;
    color: var(--label); margin: 0 0 6px;
}
.ios-install-sub {
    text-align: center; font-size: .88em; color: var(--label-2);
    margin: 0 0 22px; line-height: 1.5;
}
.ios-install-steps {
    list-style: none; margin: 0 0 20px; padding: 0;
    display: flex; flex-direction: column; gap: 14px;
}
.ios-install-steps li {
    display: flex; align-items: flex-start; gap: 12px;
    font-size: .9em; color: var(--label); line-height: 1.5;
}
.ios-step-num {
    flex-shrink: 0;
    width: 26px; height: 26px;
    background: var(--blue); color: #fff;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: .8em; font-weight: 700;
}
.ios-install-arrow {
    text-align: center; font-size: 1.4em;
    color: var(--blue); animation: bounce .9s infinite alternate ease-in-out;
}
@keyframes bounce {
    from { transform: translateY(0); }
    to   { transform: translateY(5px); }
}

@media (max-width: 480px) {
    .install-btn {
        top: 10px; right: 56px;
        padding: 7px 11px; font-size: .76em;
    }
    .install-btn span { display: none; }
    .install-btn { padding: 8px; }
    .offline-indicator { bottom: 10px; font-size: .75em; padding: 6px 12px; }
}
.theme-icon-light { display: none; }
.theme-icon-dark  { display: block; }
[data-theme="dark"] .theme-icon-light { display: block; }
[data-theme="dark"] .theme-icon-dark  { display: none; }

/* =============================================
   LAYOUT
   ============================================= */
.container {
    max-width: 860px;
    margin: 0 auto;
    padding: 28px 16px 64px;
}

/* =============================================
   HEADER
   ============================================= */
header { margin-bottom: 24px; }

.brand { display: flex; align-items: center; gap: 12px; }

.brand-mark {
    width: 42px; height: 42px;
    border-radius: 11px;
    background: var(--blue);
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    box-shadow: 0 4px 12px rgba(0,122,255,.35);
    flex-shrink: 0;
}
.brand-mark svg { width: 20px; height: 20px; }

.brand-text h1 {
    font-size: 1.4em;
    font-weight: 700;
    letter-spacing: -.03em;
    color: var(--label);
    line-height: 1.1;
}
.subtitle {
    font-size: .8em;
    color: var(--label-2);
    margin-top: 2px;
    letter-spacing: .01em;
}

/* =============================================
   CARDS
   ============================================= */
main { display: flex; flex-direction: column; gap: 14px; }

.card {
    background: var(--bg-card);
    border-radius: var(--r-xl);
    padding: 20px;
    box-shadow: var(--shadow);
}

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

.section-title { display: flex; align-items: center; gap: 10px; }

.step {
    width: 24px; height: 24px;
    border-radius: 50%;
    background: var(--blue-surface);
    color: var(--blue);
    font-size: .75em; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

.card h2 {
    font-size: 1.05em;
    font-weight: 600;
    color: var(--label);
    letter-spacing: -.02em;
}
.card h2 em {
    color: var(--label-3);
    font-style: normal;
    font-weight: 400;
    font-size: .88em;
    margin-left: 2px;
}

/* =============================================
   BADGES
   ============================================= */
.badge {
    display: inline-flex; align-items: center;
    gap: 5px; padding: 3px 9px;
    border-radius: 20px;
    font-size: .72em; font-weight: 600;
    letter-spacing: .01em;
}
.badge-success { background: rgba(52,199,89,.12); color: var(--green); }
.badge .dot {
    width: 5px; height: 5px;
    border-radius: 50%; background: currentColor;
    animation: blink 2s ease-in-out infinite;
}
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.35} }

/* =============================================
   UPLOAD AREA
   ============================================= */
.upload-area {
    border: 1.5px dashed var(--gray-4);
    border-radius: var(--r-lg);
    padding: 36px 20px;
    text-align: center;
    background: var(--bg-subtle);
    cursor: pointer;
    transition: all var(--t);
}
.upload-area:hover,
.upload-area.dragover {
    border-color: var(--blue);
    background: var(--bg-selected);
}

.drop-zone-content {
    display: flex; flex-direction: column;
    align-items: center; gap: 10px;
}
.drop-icon {
    width: 52px; height: 52px;
    border-radius: 50%;
    background: var(--bg-card);
    display: flex; align-items: center; justify-content: center;
    color: var(--blue);
    box-shadow: var(--shadow-sm);
    margin-bottom: 4px;
}
.drop-icon svg { width: 22px; height: 22px; }
.drop-text {
    font-size: .92em; font-weight: 500; color: var(--label);
}
.drop-text-mobile { display: none; }
.drop-text-desktop { display: block; }
.file-info { color: var(--label-3); font-size: .78em; margin-top: 2px; }

/* =============================================
   BUTTONS
   ============================================= */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 7px;
    padding: 9px 18px;
    font-size: .88em; font-weight: 600;
    font-family: inherit;
    border: none;
    border-radius: 980px; /* pill */
    cursor: pointer;
    transition: all var(--t);
    line-height: 1;
    user-select: none; -webkit-user-select: none;
    white-space: nowrap;
    text-decoration: none;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn svg { flex-shrink: 0; }

.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-hover); }

.btn-success { background: var(--green); color: #fff; }
.btn-success:hover { filter: brightness(.92); }

.btn-secondary {
    background: var(--bg-input);
    color: var(--label);
}
.btn-secondary:hover { filter: brightness(.92); }

.btn-ghost {
    background: var(--bg-input);
    color: var(--label-2);
}
.btn-ghost:hover { color: var(--label); }

.btn-info { background: var(--blue); color: #fff; }
.btn-info:hover { background: var(--blue-hover); }

.btn-sm { padding: 6px 14px; font-size: .8em; }

/* =============================================
   DOC TOOLBAR
   ============================================= */
.doc-toolbar {
    display: flex; justify-content: space-between;
    align-items: center; flex-wrap: wrap; gap: 8px;
    padding: 10px 14px;
    margin-top: 14px;
    background: var(--bg-subtle);
    border-radius: var(--r);
}
.page-info { font-size: .82em; color: var(--label-2); font-weight: 500; }

/* =============================================
   BARRE D'ANNOTATION (surligneur sur document)
   ============================================= */
.annotation-toolbar {
    display: flex; flex-direction: column; gap: 8px;
    padding: 10px 14px;
    margin-top: 8px;
    background: var(--bg-subtle);
    border-radius: var(--r);
    border: 1.5px solid var(--yellow);
    border-left: 4px solid var(--yellow);
}

.annot-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.annot-row-sliders { gap: 14px; }
.annot-colors { display: flex; gap: 5px; align-items: center; }

.annotation-tools { display: flex; gap: 6px; }

.annot-btn {
    display: flex; align-items: center; gap: 6px;
    padding: 6px 13px;
    font-size: .8em; font-weight: 600;
    font-family: inherit;
    background: var(--bg-card);
    border: 1.5px solid var(--separator-strong);
    border-radius: 980px;
    color: var(--label-2);
    cursor: pointer;
    transition: all var(--t);
}
.annot-btn:hover { color: var(--label); }
.annot-btn.active {
    background: var(--yellow);
    border-color: var(--yellow);
    color: #000;
}
.annot-btn.active-erase {
    background: rgba(255,59,48,.12);
    border-color: var(--red);
    color: var(--red);
}

.annotation-controls {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}

.annot-color-swatch {
    width: 26px; height: 26px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer; padding: 0;
    transition: transform var(--t), border-color var(--t);
}
.annot-color-swatch:hover { transform: scale(1.1); }
.annot-color-swatch.active { border-color: var(--label); box-shadow: 0 0 0 2px var(--bg-card), 0 0 0 4px var(--label); }

.annot-size-wrap {
    display: flex; align-items: center; gap: 6px;
}
.annot-size-wrap span { font-size: .75em; color: var(--label-2); font-weight: 500; }
.annot-size-wrap input[type="range"] { width: 80px; }

.annot-clear-btn {
    padding: 5px 11px;
    font-size: .78em; font-weight: 600;
    background: rgba(255,59,48,.1);
    color: var(--red);
    border: none; border-radius: 980px;
    cursor: pointer; font-family: inherit;
    transition: background var(--t);
}
.annot-clear-btn:hover { background: rgba(255,59,48,.2); }

.annot-scroll-hint {
    width: 100%;
    text-align: center;
    font-size: .72em;
    color: var(--label-3);
    margin: 2px 0 0;
    padding: 0;
    display: none;
}
@media (hover: none) and (pointer: coarse) {
    .annot-scroll-hint { display: block; }
}

/* =============================================
   DOCUMENT PREVIEW
   ============================================= */
.document-preview {
    margin-top: 14px;
    text-align: center;
    position: relative;
    overflow-x: hidden;
    overflow-y: visible;
}

.pdf-pages-container {
    display: flex; flex-direction: column;
    gap: 20px; align-items: center;
}

.pdf-page-container {
    position: relative;
    max-width: 100%;
    line-height: 0; /* supprime espace sous canvas */
}

.pdf-page-canvas {
    max-width: 100%; height: auto;
    border-radius: var(--r-sm);
    box-shadow: var(--shadow);
    display: block;
    background: #fff;
}

/* Canvas annotation par-dessus la page PDF */
.annotation-canvas {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    border-radius: var(--r-sm);
    pointer-events: none;
    z-index: 4;
    touch-action: none;
}

/* Quand le mode annotation est actif */
.annotation-mode .annotation-canvas {
    pointer-events: auto;
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Crect x='4' y='10' width='16' height='6' rx='3' fill='%23FFD60A' fill-opacity='.7'/%3E%3C/svg%3E") 12 12, crosshair;
}
.annotation-mode.erase-mode .annotation-canvas {
    cursor: cell;
}

/* Quand annotation active, bloquer le drag signature */
.annotation-mode .signature-overlay,
.annotation-mode .paraphe-overlay {
    pointer-events: none !important;
}

.page-label {
    display: inline-block;
    margin-top: 8px;
    font-size: .73em;
    font-weight: 500;
    color: var(--label-2);
    background: var(--bg-subtle);
    padding: 3px 10px;
    border-radius: 12px;
}

.document-preview img:not(.signature-draggable):not(.paraphe-clone) {
    max-width: 100%;
    border-radius: var(--r);
    box-shadow: var(--shadow);
}

/* =============================================
   SIGNATURE SIZE / PARAPHE SIZE
   ============================================= */
.signature-size-control,
.paraphe-controls {
    margin-top: 12px;
    padding: 12px 14px;
    background: var(--bg-subtle);
    border-radius: var(--r);
}
.signature-size-control label,
.paraphe-controls label {
    display: flex; justify-content: space-between; align-items: center;
    font-weight: 500; font-size: .83em;
    color: var(--label-2); margin-bottom: 9px;
}
.value-pill {
    color: var(--blue); font-weight: 700;
    background: var(--blue-surface);
    padding: 2px 9px; border-radius: 12px;
    font-size: .85em; font-variant-numeric: tabular-nums;
}

/* =============================================
   PAGE SELECTOR
   ============================================= */
.page-selector-panel {
    margin-top: 14px;
    padding: 14px;
    background: var(--bg-subtle);
    border-radius: var(--r);
}
.page-selector-panel h3 { font-size: .9em; font-weight: 600; margin-bottom: 10px; }

.page-selector-options { display: flex; flex-direction: column; gap: 6px; }

.radio-option {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px;
    background: var(--bg-card);
    border: 1px solid var(--separator);
    border-radius: var(--r-sm);
    cursor: pointer; font-size: .88em;
    transition: all var(--t);
}
.radio-option:hover { border-color: var(--blue); }
.radio-option input[type="radio"] { accent-color: var(--blue); }
.radio-option:has(input:checked) {
    border-color: var(--blue);
    background: var(--bg-selected);
    color: var(--blue);
    font-weight: 500;
}

.custom-pages-container {
    display: flex; flex-wrap: wrap; gap: 6px;
    margin-top: 10px; padding-top: 10px;
    border-top: 1px solid var(--separator);
}
.page-checkbox {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 5px 10px;
    background: var(--bg-card);
    border: 1px solid var(--separator);
    border-radius: var(--r-sm);
    cursor: pointer; font-size: .82em;
    transition: all var(--t);
}
.page-checkbox:hover { border-color: var(--blue); }
.page-checkbox input { accent-color: var(--blue); }

/* =============================================
   TOOLS BAR (stylo / surligneur / gomme — signature)
   ============================================= */
.tools-bar {
    display: flex; gap: 4px;
    padding: 4px;
    background: var(--bg-input);
    border-radius: var(--r);
    margin-bottom: 12px;
}
.tool-btn {
    flex: 1;
    display: flex; align-items: center; justify-content: center; gap: 6px;
    padding: 9px 10px;
    background: transparent;
    border: none;
    border-radius: calc(var(--r) - 4px);
    font-size: .8em; font-weight: 500;
    color: var(--label-2);
    cursor: pointer;
    transition: all var(--t);
    font-family: inherit;
}
.tool-btn svg { width: 15px; height: 15px; }
.tool-btn:hover { color: var(--label); }
.tool-btn.active {
    background: var(--bg-card);
    color: var(--blue);
    font-weight: 600;
    box-shadow: var(--shadow-sm);
}

/* =============================================
   SIGNATURE CONTROLS
   ============================================= */
.signature-controls { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }

.controls-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

.control-group {
    display: flex; flex-direction: column; gap: 5px;
    flex: 1; min-width: 120px;
    font-size: .78em; font-weight: 500; color: var(--label-2);
}
.control-group > span {
    display: flex; align-items: center; justify-content: space-between;
}
.control-group em {
    font-style: normal; color: var(--blue); font-weight: 600;
    background: var(--blue-surface);
    padding: 1px 7px; border-radius: 10px; font-size: .95em;
}

/* Color presets */
.color-presets { display: flex; gap: 5px; align-items: center; }

.color-swatch {
    width: 26px; height: 26px; border-radius: 50%;
    border: 2px solid var(--separator); cursor: pointer; padding: 0;
    transition: all var(--t); flex-shrink: 0;
}
.color-swatch:hover { transform: scale(1.12); }
.color-swatch.active { border-color: transparent; box-shadow: 0 0 0 2px var(--bg-card), 0 0 0 4px var(--label); }

.color-picker-custom {
    width: 26px; height: 26px; border-radius: 50%;
    border: 2px dashed var(--gray-3);
    background: transparent; padding: 0;
    overflow: hidden; cursor: pointer; flex-shrink: 0;
}
.color-picker-custom::-webkit-color-swatch-wrapper { padding: 0; }
.color-picker-custom::-webkit-color-swatch { border: none; border-radius: 50%; }
.color-picker-custom::-moz-color-swatch { border: none; border-radius: 50%; }

/* Range inputs */
input[type="range"] {
    -webkit-appearance: none; appearance: none;
    width: 100%; height: 5px; border-radius: 3px;
    background: var(--gray-5); outline: none; cursor: pointer;
    transition: background var(--t);
}
[data-theme="dark"] input[type="range"] { background: var(--gray-4); }
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 18px; height: 18px; border-radius: 50%;
    background: var(--blue); cursor: pointer;
    border: 2px solid var(--bg-card);
    box-shadow: 0 1px 4px rgba(0,0,0,.2);
    transition: transform var(--t);
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.18); }
input[type="range"]::-moz-range-thumb {
    width: 18px; height: 18px; border-radius: 50%;
    background: var(--blue); cursor: pointer;
    border: 2px solid var(--bg-card); box-shadow: 0 1px 4px rgba(0,0,0,.2);
}

.controls-buttons { justify-content: flex-end; }

/* =============================================
   CANVAS SIGNATURE / PARAPHE
   ============================================= */
.canvas-wrap {
    border-radius: var(--r);
    overflow: hidden;
    background: #fff;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--separator);
}
#signature-canvas, #paraphe-canvas {
    display: block; margin: 0 auto;
    background: #fff;
    cursor: crosshair; touch-action: none;
    max-width: 100%; width: 100%;
}

.hint {
    margin-top: 8px;
    font-size: .78em; color: var(--label-3); text-align: center;
}

/* =============================================
   SIGNATURE OVERLAY & DRAG
   ============================================= */
.signature-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; min-height: 100%;
    pointer-events: none;
    z-index: 5;
}
.signature-draggable {
    position: absolute;
    cursor: move;
    border: 1.5px dashed var(--blue);
    border-radius: 6px;
    background: rgba(255,255,255,.9);
    padding: 3px;
    box-shadow: 0 4px 16px rgba(0,122,255,.2);
    transition: box-shadow var(--t);
    pointer-events: auto;
    z-index: 10;
    touch-action: none;
    min-width: 44px; min-height: 44px;
}
.paraphe-draggable {
    border-color: var(--purple);
    box-shadow: 0 4px 16px rgba(175,82,222,.2);
    z-index: 9;
}
.signature-draggable:active {
    cursor: grabbing;
    box-shadow: 0 8px 28px rgba(0,122,255,.4);
}
.signature-hint {
    position: absolute; bottom: -26px; left: 50%;
    transform: translateX(-50%);
    background: var(--blue); color: #fff;
    padding: 3px 9px; border-radius: 12px;
    font-size: .68em; font-weight: 500;
    white-space: nowrap; pointer-events: none;
    opacity: .9;
}

/* =============================================
   ACTIONS
   ============================================= */
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.actions .btn { flex: 1; min-width: 130px; padding: 13px 20px; font-size: .9em; }

/* =============================================
   EMAIL FORM
   ============================================= */
.email-form {
    margin-top: 14px; padding: 16px;
    background: var(--bg-subtle); border-radius: var(--r);
    display: flex; flex-direction: column; gap: 9px;
}
.email-form h3 { font-size: .95em; font-weight: 600; margin-bottom: 2px; }

.email-form input,
.email-form textarea {
    width: 100%;
    padding: 10px 13px;
    border: 1px solid var(--separator-strong);
    border-radius: var(--r-sm);
    background: var(--bg-card);
    color: var(--label);
    font-family: inherit; font-size: .9em;
    transition: border-color var(--t), box-shadow var(--t);
    resize: vertical;
}
.email-form input:focus, .email-form textarea:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px var(--blue-surface);
}
.email-form input::placeholder, .email-form textarea::placeholder { color: var(--label-3); }

.form-actions { display: flex; gap: 7px; margin-top: 2px; }
.form-actions .btn { flex: 1; }

.status-message {
    padding: 9px 13px; border-radius: var(--r-sm);
    font-size: .85em; font-weight: 500; display: none;
}
.status-message.success { display: block; background: rgba(52,199,89,.12); color: var(--green); }
.status-message.error   { display: block; background: rgba(255,59,48,.1);  color: var(--red);   }

/* =============================================
   FOOTER
   ============================================= */
footer {
    margin-top: 28px; text-align: center;
    color: var(--label-3); font-size: .75em; padding: 14px 0;
}

/* =============================================
   PREVENT SCROLL DURING DRAWING (iOS fix)
   ============================================= */
/* =============================================
   RESPONSIVE — TABLETTES
   ============================================= */
@media (max-width: 768px) {
    .container { padding: 16px 12px 50px; }
    .card { padding: 16px; border-radius: var(--r-lg); }
    .actions { flex-direction: column; }
    .actions .btn { width: 100%; }
    .form-actions { flex-direction: column; }
    .form-actions .btn { width: 100%; }
    .tool-btn span { display: none; }
    .tool-btn { padding: 11px; }
    .tool-btn svg { width: 18px; height: 18px; }
    .annot-size-wrap input[type="range"] { width: 60px; }
}

/* =============================================
   RESPONSIVE — TELEPHONES
   ============================================= */
@media (max-width: 480px) {
    .container { padding: 12px 10px 40px; }
    .card { padding: 14px; border-radius: var(--r); }

    .brand-mark { width: 36px; height: 36px; }
    .brand-mark svg { width: 17px; height: 17px; }
    .brand-text h1 { font-size: 1.2em; }
    .subtitle { font-size: .78em; }
    header { margin-bottom: 16px; }

    .drop-text-mobile  { display: block; }
    .drop-text-desktop { display: none; }

    .btn { min-height: 44px; }
    .btn-sm { min-height: 36px; padding: 7px 13px; }

    .color-swatch, .color-picker-custom { width: 30px; height: 30px; }

    input[type="range"]::-webkit-slider-thumb { width: 22px; height: 22px; }
    input[type="range"]::-moz-range-thumb { width: 22px; height: 22px; }

    .email-form input, .email-form textarea { font-size: 16px; }

    .theme-toggle { top: 10px; right: 10px; width: 34px; height: 34px; font-size: 15px; }

    .controls-row { flex-direction: column; align-items: stretch; }
    .control-group { min-width: 0; }
    .controls-buttons { flex-direction: row !important; }
    .controls-buttons .btn { flex: 1; }

    #signature-canvas { min-height: 220px; }
    #paraphe-canvas   { min-height: 160px; }

    .pdf-pages-container { gap: 14px; }
    .pdf-page-canvas { border-radius: 6px; }

    .tool-btn {
        padding: 9px 6px;
        flex-direction: column; gap: 3px;
    }
    .tool-btn span { display: block; font-size: .65em; }
    .tool-btn svg { width: 16px; height: 16px; }

    .annot-row { flex-wrap: wrap; }
    .annot-size-wrap input[type="range"] { width: 110px; }
}

/* =============================================
   CONTRÔLE PLACEMENT MULTIPLE
   ============================================= */
.sig-placement-control {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 14px;
    flex-wrap: wrap;
}

.sig-multi-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.87rem;
    font-weight: 500;
    color: var(--label);
    user-select: none;
}

.sig-multi-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--blue);
    flex-shrink: 0;
}

.sig-placement-hint {
    font-size: 0.75rem;
    color: var(--label-2);
}

/* =============================================
   PAYSAGE
   ============================================= */
@media (max-height: 500px) and (orientation: landscape) {
    #signature-canvas { min-height: 130px; }
    #paraphe-canvas   { min-height: 90px; }
    header { margin-bottom: 10px; }
}
