/* ============================================================
   mananke — éditeur photo
   ============================================================ */

:root {
    --anthracite: #1e2124;
    --anthracite-clair: #262a2e;
    --anthracite-panneau: #23272b;
    --anthracite-bord: #34393e;
    --texte: #e6e8ea;
    --texte-doux: #9aa0a6;
    --vert-tendre: #7bc47f;
    --vert-doux: #a5d6a7;
    --vert-fort: #4caf72;
    --rouge-doux: #e5806f;
    --rayon: 6px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--anthracite);
    color: var(--texte);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Repère clavier visible partout, sans polluer la souris. */
:focus-visible {
    outline: 2px solid var(--vert-tendre);
    outline-offset: 2px;
}

/* ============================================================
   En-tête
   ============================================================ */

.barre-haut {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 12px;
    padding: 12px 20px;
    background: var(--anthracite-panneau);
    border-bottom: 1px solid var(--anthracite-bord);
    flex-shrink: 0;
}

.barre-gauche {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.barre-haut h1 {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.logo {
    height: 32px;
    width: auto;
    border-radius: 8px;
}

.btn-upload {
    display: inline-block;
    padding: 8px 16px;
    background: var(--vert-fort);
    color: #fff;
    border-radius: var(--rayon);
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.15s;
}

.btn-upload:hover { background: var(--vert-tendre); }
.btn-upload:focus-within { outline: 2px solid var(--vert-tendre); outline-offset: 2px; }
.btn-upload input { display: none; }

/* --- Barre d'outils de l'en-tête --- */

.barre-outils {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
    margin-right: 12px;
}

.outil {
    min-width: 34px;
    height: 32px;
    padding: 0 9px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--anthracite-clair);
    border: 1px solid var(--anthracite-bord);
    border-radius: var(--rayon);
    color: var(--texte);
    font: inherit;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s, opacity 0.15s;
}

.outil-large { font-size: 12px; font-weight: 600; }

.outil:hover:not(:disabled) {
    border-color: var(--vert-tendre);
    color: var(--vert-doux);
}

.outil:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

/* Pendant la comparaison, le bouton reste allumé : on sait ce qu'on regarde. */
.outil.actif {
    background: var(--vert-fort);
    border-color: var(--vert-fort);
    color: #fff;
}

/* --- Préréglages --- */

.presets {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.presets:empty { display: none; }

.presets-vide {
    font-size: 12px;
    color: var(--texte-doux);
    font-style: italic;
}

.preset {
    display: inline-flex;
    align-items: stretch;
    background: var(--anthracite-clair);
    border: 1px solid var(--anthracite-bord);
    border-radius: var(--rayon);
    overflow: hidden;
    transition: border-color 0.15s;
}

.preset:hover { border-color: var(--vert-tendre); }

.preset-nom {
    padding: 7px 4px 7px 10px;
    max-width: 170px;
    background: none;
    border: none;
    color: var(--texte);
    font: inherit;
    font-size: 12px;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
}

.preset-suppr {
    padding: 0 8px;
    background: none;
    border: none;
    border-left: 1px solid var(--anthracite-bord);
    color: var(--texte-doux);
    font: inherit;
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
}

.preset-suppr:hover {
    background: var(--rouge-doux);
    color: #fff;
}

.preset-nouveau {
    width: 100%;
    margin-top: 10px;
    padding: 9px;
    background: transparent;
    border: 1px dashed var(--anthracite-bord);
    border-radius: var(--rayon);
    color: var(--texte-doux);
    font: inherit;
    font-size: 12px;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}

.preset-nouveau:hover {
    border-color: var(--vert-tendre);
    color: var(--texte);
}

.preset-form {
    display: none;
    gap: 6px;
    margin-top: 10px;
}

.preset-form.ouvert { display: flex; }

.preset-form input {
    flex: 1;
    min-width: 0;
    padding: 8px 10px;
    background: var(--anthracite);
    border: 1px solid var(--anthracite-bord);
    border-radius: var(--rayon);
    color: var(--texte);
    font: inherit;
    font-size: 12px;
}

.preset-form input:focus {
    outline: none;
    border-color: var(--vert-tendre);
}

.preset-ok,
.preset-annuler {
    padding: 0 11px;
    background: var(--anthracite-clair);
    border: 1px solid var(--anthracite-bord);
    border-radius: var(--rayon);
    color: var(--texte);
    font: inherit;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.preset-ok:hover {
    background: var(--vert-fort);
    border-color: var(--vert-fort);
    color: #fff;
}

.preset-annuler:hover { border-color: var(--rouge-doux); }

/* ============================================================
   Corps : aperçu + panneau
   ============================================================ */

.corps {
    flex: 1;
    display: flex;
    overflow: hidden;
    min-height: 0;
}

.zone-apercu {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--anthracite);
    padding: 24px;
    overflow: hidden;
    min-width: 0;
}

.zone-apercu img {
    display: none;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
}

.zone-apercu.fond-sombre { background: var(--anthracite); }
.zone-apercu.fond-neutre { background: #777777; }
.zone-apercu.fond-clair  { background: #e8e8e8; }
.zone-apercu.fond-noir   { background: #000000; }

/* Sur fond clair, l'invite et le voyant doivent rester lisibles. */
.zone-apercu.fond-clair .placeholder,
.zone-apercu.fond-neutre .placeholder { color: #33383c; }

.zone-apercu.fond-clair .occupe-voyant,
.zone-apercu.fond-neutre .occupe-voyant { border-color: rgba(0, 0, 0, 0.25); border-top-color: var(--vert-fort); }

.placeholder {
    color: var(--texte-doux);
    font-size: 14px;
    text-align: center;
    line-height: 1.6;
}

.placeholder-aide {
    display: block;
    margin-top: 4px;
    font-size: 12.5px;
    opacity: 0.7;
}

/* ============================================================
   Voile de glisser-déposer
   ============================================================ */

.depot {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(10, 10, 12, 0.75);
    z-index: 3000;
    /* Le voile ne doit jamais intercepter les événements : sans ça, dragleave
       se déclencherait dès son apparition et il clignoterait sans fin. */
    pointer-events: none;
}

.depot.actif { display: flex; }

.depot-boite {
    padding: 44px 56px;
    border: 2px dashed var(--vert-tendre);
    border-radius: 14px;
    background: rgba(35, 39, 43, 0.9);
    color: var(--texte);
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 0.4px;
    text-align: center;
}

/* Voyant d'attente pendant le calcul d'un aperçu. */
.occupe-voyant {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 18px;
    height: 18px;
    border: 2px solid var(--anthracite-bord);
    border-top-color: var(--vert-tendre);
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}

.zone-apercu.occupe .occupe-voyant {
    opacity: 1;
    animation: tourne 0.8s linear infinite;
}

@keyframes tourne {
    to { transform: rotate(360deg); }
}

/* ============================================================
   Panneau de réglages
   ============================================================ */

.panneau {
    width: 300px;
    background: var(--anthracite-panneau);
    border-left: 1px solid var(--anthracite-bord);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow-y: auto;
}

.panneau-section {
    padding: 16px;
    border-bottom: 1px solid var(--anthracite-bord);
}

.panneau-titre {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--texte-doux);
    margin-bottom: 12px;
}

/* Rappel du filtre en cours : avec dix-sept filtres répartis en quatre
   accordéons, celui qui est actif est souvent replié hors de vue. */
.titre-valeur {
    text-transform: none;
    letter-spacing: 0;
    font-size: 12px;
    color: var(--vert-doux);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- Filtres --- */

.filtres {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.filtre-btn {
    padding: 9px 6px;
    background: var(--anthracite-clair);
    border: 1px solid var(--anthracite-bord);
    border-radius: var(--rayon);
    color: var(--texte);
    font: inherit;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.filtre-btn:hover { border-color: var(--vert-tendre); }

.filtre-btn.actif {
    background: var(--vert-fort);
    border-color: var(--vert-fort);
    color: #fff;
    font-weight: 600;
}

/* --- Curseurs --- */

.reglage { margin-bottom: 16px; }

.reglage-tete {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    margin-bottom: 6px;
}

.reglage-droite {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--vert-doux);
    font-variant-numeric: tabular-nums;
}

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    background: var(--anthracite-bord);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: var(--vert-tendre);
    cursor: pointer;
    border: 2px solid var(--anthracite-panneau);
}

input[type="range"]::-moz-range-thumb {
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: var(--vert-tendre);
    cursor: pointer;
    border: 2px solid var(--anthracite-panneau);
}

/* Réglage désactivé : curseur et valeur grisés. */
.reglage.inactif input[type="range"] { opacity: 0.4; }
.reglage.inactif .reglage-droite { opacity: 0.4; }

/* --- Interrupteur d'activation --- */

.btn-actif {
    width: 30px;
    height: 16px;
    border-radius: 8px;
    border: none;
    background: var(--anthracite-bord);
    position: relative;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.18s;
}

.btn-actif::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--texte-doux);
    transition: transform 0.18s, background 0.18s;
}

.btn-actif[aria-pressed="true"] { background: var(--vert-fort); }

.btn-actif[aria-pressed="true"]::after {
    transform: translateX(14px);
    background: #fff;
}

/* --- Accordéon --- */

.accordeon { border-bottom: 1px solid var(--anthracite-bord); }
.accordeon:first-of-type { border-top: 1px solid var(--anthracite-bord); }

.acc-tete {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 13px 4px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--texte);
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: color 0.15s;
}

.acc-tete:hover { color: var(--vert-doux); }

.acc-fleche {
    color: var(--vert-tendre);
    font-size: 10px;
    transition: transform 0.25s ease;
}

.accordeon.ouvert .acc-fleche { transform: rotate(180deg); }

.acc-corps {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.28s ease;
}

.accordeon.ouvert .acc-corps { max-height: 600px; }
.acc-corps-inner { padding: 4px 4px 14px; }
.acc-corps-inner .reglage:last-child { margin-bottom: 0; }

/* ============================================================
   Boutons d'action
   ============================================================ */

.actions {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.actions button {
    padding: 11px;
    border-radius: var(--rayon);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s, opacity 0.15s;
}

.actions button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-edition {
    background: var(--anthracite-clair);
    color: var(--texte);
    border: 1px solid var(--anthracite-bord);
}

.btn-edition:hover:not(:disabled) {
    border-color: var(--vert-tendre);
    color: var(--vert-doux);
}

/* ============================================================
   Suivi d'export
   ============================================================ */

/* Masquée au repos plutôt que retirée du flux : la fenêtre ne saute pas de
   hauteur au lancement, ce qui déplacerait le bouton sous le curseur. */
.export-progres {
    margin-top: 14px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.18s ease;
}

.export-progres.visible {
    opacity: 1;
    visibility: visible;
}

.export-piste {
    height: 4px;
    background: var(--anthracite);
    border: 1px solid var(--anthracite-bord);
    border-radius: 3px;
    overflow: hidden;
}

.export-barre {
    height: 100%;
    width: 0;
    background: var(--vert-fort);
    /* Calée sur l'intervalle de sondage : plus longue, la barre traînerait
       derrière les chiffres reçus ; plus courte, elle sauterait d'un palier à
       l'autre au lieu de glisser. */
    transition: width 0.28s linear;
}

.export-etape {
    margin-top: 7px;
    font-size: 11.5px;
    color: var(--texte-doux);
    font-variant-numeric: tabular-nums;
    min-height: 15px;
}

/* Les deux boutons d'historique du pinceau, côte à côte sous « Effacer ». */
.pinceau-histo {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 8px;
}

/* La correction automatique est une proposition, pas une action principale :
   elle se distingue des boutons voisins par sa teinte sans leur voler la
   vedette. */
.btn-auto {
    background: var(--anthracite);
    color: var(--vert-doux);
    border: 1px solid var(--vert-fort);
}

.btn-auto:hover:not(:disabled) {
    background: var(--anthracite-clair);
    color: var(--vert-tendre);
}

.btn-export {
    background: var(--vert-fort);
    color: #fff;
    border: 1px solid var(--vert-fort);
}

.btn-export:hover:not(:disabled) {
    background: var(--vert-tendre);
    border-color: var(--vert-tendre);
}

.btn-reset {
    background: transparent;
    color: var(--texte-doux);
    border: 1px solid var(--anthracite-bord);
    font-weight: 400;
}

.btn-reset:hover:not(:disabled) {
    border-color: var(--vert-tendre);
    color: var(--texte);
}

/* ============================================================
   Messages
   ============================================================ */

.message {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translate(-50%, 20px);
    max-width: min(560px, calc(100vw - 32px));
    padding: 12px 18px;
    background: var(--anthracite-clair);
    border: 1px solid var(--rouge-doux);
    border-radius: var(--rayon);
    color: var(--texte);
    font-size: 13px;
    line-height: 1.45;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 2000;
}

.message.visible {
    opacity: 1;
    transform: translate(-50%, 0);
}

/* ============================================================
   Histogramme et écrêtage
   ============================================================ */

.histogramme {
    display: block;
    width: 100%;
    height: 90px;
    background: var(--anthracite);
    border: 1px solid var(--anthracite-bord);
    border-radius: var(--rayon);
}

.ecretage-barre {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 8px;
}

.ecretage-info {
    font-size: 11.5px;
    color: var(--texte-doux);
    font-variant-numeric: tabular-nums;
}

.ecretage-info.alerte { color: var(--rouge-doux); }

.ecretage-btn {
    padding: 5px 10px;
    background: var(--anthracite-clair);
    border: 1px solid var(--anthracite-bord);
    border-radius: var(--rayon);
    color: var(--texte-doux);
    font: inherit;
    font-size: 11.5px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.ecretage-btn:hover { border-color: var(--vert-tendre); color: var(--texte); }

.ecretage-btn.actif {
    background: var(--vert-fort);
    border-color: var(--vert-fort);
    color: #fff;
}

/* Le calque est calé sur l'image par app.js : elle est contenue, pas étirée,
   ses marges dépendent donc de son rapport et de celui de la zone. */
.calque-ecretage {
    position: absolute;
    display: none;
    pointer-events: none;
    image-rendering: pixelated;
    border-radius: 4px;
}

/* L'aperçu est cliquable : loupe par défaut, pipette quand elle est armée. */
.zone-apercu img { cursor: zoom-in; }
.zone-apercu.pipette img { cursor: crosshair; }

/* ============================================================
   Mélangeur TSL
   ============================================================ */

.tsl-onglets {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
    margin-bottom: 12px;
}

.tsl-onglet {
    padding: 6px 4px;
    background: var(--anthracite-clair);
    border: 1px solid var(--anthracite-bord);
    border-radius: var(--rayon);
    color: var(--texte-doux);
    font: inherit;
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.tsl-onglet:hover { border-color: var(--vert-tendre); color: var(--texte); }
.tsl-onglet.actif { background: var(--vert-fort); border-color: var(--vert-fort); color: #fff; }

.tsl-gammes {
    display: flex;
    flex-direction: column;
    gap: 9px;
    margin-bottom: 12px;
}

.tsl-ligne {
    display: grid;
    grid-template-columns: 12px 58px 1fr 30px;
    align-items: center;
    gap: 8px;
}

/* Repère de couleur : on identifie la gamme d'un coup d'œil, sans lire. */
.tsl-pastille {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    flex-shrink: 0;
}

.tsl-nom {
    font-size: 11.5px;
    color: var(--texte-doux);
    cursor: pointer;
    white-space: nowrap;
}

.tsl-valeur {
    font-size: 11px;
    text-align: right;
    color: var(--texte-doux);
    font-variant-numeric: tabular-nums;
}

/* Une gamme réglée se distingue : avec vingt-quatre curseurs répartis sur
   trois onglets, on perd sinon de vue ce qu'on a déjà touché. */
.tsl-ligne.modifie .tsl-nom,
.tsl-ligne.modifie .tsl-valeur { color: var(--vert-doux); }

/* ============================================================
   Courbe tonale
   ============================================================ */

.courbe-onglets {
    display: grid;
    grid-template-columns: 1.6fr 1fr 1fr 1fr;
    gap: 5px;
    margin-bottom: 10px;
}

.courbe-onglet {
    padding: 6px 4px;
    background: var(--anthracite-clair);
    border: 1px solid var(--anthracite-bord);
    border-radius: var(--rayon);
    color: var(--texte-doux);
    font: inherit;
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.courbe-onglet:hover { border-color: var(--vert-tendre); color: var(--texte); }

.courbe-onglet.actif { background: var(--vert-fort); border-color: var(--vert-fort); color: #fff; }
.courbe-onglet.canal-r.actif { background: #e6634a; border-color: #e6634a; }
.courbe-onglet.canal-g.actif { background: #4fc46a; border-color: #4fc46a; }
.courbe-onglet.canal-b.actif { background: #5a8de0; border-color: #5a8de0; }

/* Carré : les deux axes couvrent la même plage, la diagonale doit être à 45°. */
.courbe-toile {
    display: block;
    width: 100%;
    aspect-ratio: 1 / 1;
    background: var(--anthracite);
    border: 1px solid var(--anthracite-bord);
    border-radius: var(--rayon);
    cursor: crosshair;
    touch-action: none;
}

.courbe-aide {
    margin: 8px 0 10px;
    font-size: 11px;
    line-height: 1.5;
    color: var(--texte-doux);
}

/* ============================================================
   Pinceau
   ============================================================ */

.calque-pinceau {
    position: absolute;
    display: none;
    pointer-events: none;
    border-radius: 4px;
}

/* La peinture prime : ni loupe ni pipette tant que le pinceau est actif. */
/* Le pinceau est la seule interaction où le doigt glisse sur l'image. Sans
   touch-action, le navigateur réquisitionne ce glissement pour défiler et
   émet un pointercancel au milieu du trait. La règle est portée par la classe
   « peinture » et non par l'image : hors du pinceau, le défilement au doigt
   sur l'aperçu doit rester possible. */
.zone-apercu.peinture img {
    cursor: cell;
    touch-action: none;
}

.btn-pinceau {
    width: 100%;
    padding: 10px;
    background: var(--anthracite-clair);
    border: 1px solid var(--anthracite-bord);
    border-radius: var(--rayon);
    color: var(--texte);
    font: inherit;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s, opacity 0.15s;
}

.btn-pinceau:hover:not(:disabled) { border-color: var(--vert-tendre); color: var(--vert-doux); }
.btn-pinceau:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-pinceau.actif {
    background: var(--vert-fort);
    border-color: var(--vert-fort);
    color: #fff;
}

.pinceau-corps {
    display: none;
    flex-direction: column;
    gap: 11px;
    margin-top: 14px;
}

.pinceau-corps.ouvert { display: flex; }

/* La case du magnétisme vit dans le panneau, pas dans une fenêtre : elle
   reprend .case et n'ajuste que l'espacement vertical. */
.case-pinceau {
    margin-top: 10px;
}

.pinceau-note {
    margin-top: 6px;
    font-size: 11.5px;
    line-height: 1.45;
    color: var(--texte-doux);
}

.pinceau-separateur {
    margin-top: 4px;
    padding-top: 11px;
    border-top: 1px solid var(--anthracite-bord);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--texte-doux);
}

.pinceau-corps .btn-reset {
    margin-top: 4px;
    padding: 9px;
    font-size: 12px;
}

/* ============================================================
   Plein cadre
   ============================================================ */

body.plein-cadre .barre-haut,
body.plein-cadre .panneau { display: none; }

body.plein-cadre .zone-apercu { padding: 0; }

body.plein-cadre .zone-apercu img {
    border-radius: 0;
    box-shadow: none;
}

.indice-plein-cadre {
    position: absolute;
    bottom: 22px;
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 16px;
    background: rgba(10, 10, 12, 0.8);
    border-radius: 20px;
    color: var(--texte);
    font-size: 12px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.indice-plein-cadre.visible { opacity: 1; }

/* ============================================================
   Loupe 1:1
   ============================================================ */

.modale-loupe { padding: 0; }

.loupe-boite {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    background: rgba(10, 10, 12, 0.96);
}

.loupe-tete {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 12px 20px;
    flex-shrink: 0;
}

.loupe-titre { font-weight: 600; letter-spacing: 0.5px; }

.loupe-aide {
    flex: 1;
    font-size: 12px;
    color: var(--texte-doux);
    text-align: center;
}

.loupe-scene {
    position: relative;
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* Aucun redimensionnement : l'intérêt de la loupe est justement le 1:1. */
#loupeImg {
    max-width: none;
    max-height: none;
    cursor: move;
}

.loupe-attente {
    position: absolute;
    font-size: 13px;
    color: var(--texte-doux);
}

/* ============================================================
   Filigrane
   ============================================================ */

.filigrane-options {
    display: none;
    flex-direction: column;
    gap: 10px;
    margin-top: 12px;
}

.filigrane-options.ouvert { display: flex; }

.champ-texte {
    width: 100%;
    padding: 8px 10px;
    background: var(--anthracite);
    border: 1px solid var(--anthracite-bord);
    border-radius: var(--rayon);
    color: var(--texte);
    font: inherit;
    font-size: 12px;
}

.champ-texte:focus { outline: none; border-color: var(--vert-tendre); }

.glissiere {
    display: grid;
    grid-template-columns: 62px 1fr 46px;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    color: var(--texte-doux);
}

.glissiere span {
    text-align: right;
    font-variant-numeric: tabular-nums;
    color: var(--vert-doux);
}

/* ============================================================
   Fenêtre d'export
   ============================================================ */

.modale {
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 12, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 1500;
}

.modale.ouvert { display: flex; }

/* ============================================================
   Notice d'utilisation
   ============================================================ */

/* Le bouton d'accès, en bas des réglages. Il occupe toute la largeur et porte
   une flèche : on comprend qu'il ouvre autre chose, et non qu'il bascule un
   réglage comme les boutons voisins. */
.btn-notice {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 11px 14px;
    background: var(--anthracite);
    color: var(--texte);
    border: 1px solid var(--anthracite-bord);
    border-radius: var(--rayon);
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.btn-notice:hover {
    background: var(--anthracite-clair);
    border-color: var(--vert-fort);
}

.btn-notice-fleche {
    color: var(--texte-doux);
    font-size: 15px;
}

.btn-notice:hover .btn-notice-fleche { color: var(--vert-tendre); }

/* La notice est du texte long : elle a besoin de plus de largeur que les
   fenêtres de réglage, sans pour autant s'étaler — au-delà d'une soixantaine
   de caractères par ligne, l'œil perd le début de la ligne suivante.

   Sélecteur doublé volontairement. L'élément porte les deux classes, et
   .modale-boite est déclarée plus bas dans ce fichier : à spécificité égale
   c'est elle qui l'emporterait, et la fenêtre resterait à 400 px. */
.modale-boite.modale-boite-large {
    max-width: 640px;
}

.notice-corps {
    max-height: min(64vh, 620px);
    overflow-y: auto;
    padding-right: 12px;
    line-height: 1.62;
    font-size: 13.5px;
    color: var(--texte);
}

.notice-corps:focus { outline: none; }

.notice-corps p { margin: 0 0 13px; }

.notice-corps h2 {
    margin: 26px 0 10px;
    padding-top: 16px;
    border-top: 1px solid var(--anthracite-bord);
    font-size: 15px;
    font-weight: 600;
    color: var(--vert-doux);
}

/* Le premier titre n'a pas à être précédé d'un filet : il n'y a rien avant. */
.notice-corps > h2:first-child {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

.notice-corps h3 {
    margin: 18px 0 8px;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--texte);
}

.notice-corps strong { color: #fff; font-weight: 600; }
.notice-corps em { color: var(--vert-doux); font-style: normal; }

.notice-corps hr {
    margin: 22px 0;
    border: none;
    border-top: 1px solid var(--anthracite-bord);
}

/* Les règles horizontales du texte source séparent de grandes parties, et les
   titres portent déjà leur propre filet : deux traits de suite feraient
   bégayer la page. */
.notice-corps hr + h2 {
    padding-top: 0;
    border-top: none;
    margin-top: 0;
}

.notice-corps table {
    width: 100%;
    margin: 4px 0 16px;
    border-collapse: collapse;
    font-size: 13px;
}

.notice-corps th {
    padding: 7px 10px;
    text-align: left;
    font-weight: 600;
    color: var(--texte-doux);
    border-bottom: 1px solid var(--anthracite-bord);
}

.notice-corps td {
    padding: 7px 10px;
    border-bottom: 1px solid var(--anthracite-bord);
    vertical-align: top;
}

.notice-corps td:first-child { white-space: nowrap; color: var(--vert-doux); }

.notice-corps ul { margin: 0 0 13px 18px; }
.notice-corps li { margin-bottom: 5px; }

.notice-attente { color: var(--texte-doux); }

/* Sur téléphone, la notice prend ce qu'elle peut : c'est du texte à lire, la
   place perdue en marges est de la place en moins pour les mots. */
@media (max-width: 860px) {
    .notice-corps {
        max-height: 68vh;
        padding-right: 6px;
        font-size: 14px;
    }
}

.modale-boite {
    width: 100%;
    max-width: 400px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    padding: 22px;
    background: var(--anthracite-panneau);
    border: 1px solid var(--anthracite-bord);
    border-radius: 10px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

.modale-titre {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 20px;
}

.modale-champ { margin-bottom: 18px; }

.modale-label {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--texte-doux);
    margin-bottom: 8px;
}

/* Qualité sans objet en PNG : on la neutralise sans la retirer, pour éviter
   que la fenêtre ne se réorganise sous le curseur. */
.modale-champ.desactive {
    opacity: 0.35;
    pointer-events: none;
}

.choix {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    gap: 6px;
}

.choix-btn {
    padding: 9px 4px;
    background: var(--anthracite-clair);
    border: 1px solid var(--anthracite-bord);
    border-radius: var(--rayon);
    color: var(--texte);
    font: inherit;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.choix-btn:hover:not(:disabled) { border-color: var(--vert-tendre); }

.choix-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.choix-btn.actif {
    background: var(--vert-fort);
    border-color: var(--vert-fort);
    color: #fff;
    font-weight: 600;
}

.case {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    cursor: pointer;
    user-select: none;
}

.case input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    margin: 0;
    background: var(--anthracite-clair);
    border: 1px solid var(--anthracite-bord);
    border-radius: 4px;
    cursor: pointer;
    position: relative;
    transition: background 0.15s, border-color 0.15s;
}

.case input[type="checkbox"]:checked {
    background: var(--vert-fort);
    border-color: var(--vert-fort);
}

.case input[type="checkbox"]:checked::after {
    content: "";
    position: absolute;
    left: 5px;
    top: 1px;
    width: 5px;
    height: 10px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* Cinq choix tiennent mal sur une ligne : deux rangées de trois. */
.choix-cinq {
    grid-auto-flow: row;
    grid-template-columns: repeat(3, 1fr);
}

.modale-actions-simple { grid-template-columns: 1fr; }

.raccourcis {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 7px 14px;
    align-items: baseline;
    margin: 0;
}

.raccourcis dt {
    padding: 3px 8px;
    background: var(--anthracite-clair);
    border: 1px solid var(--anthracite-bord);
    border-radius: 4px;
    font-size: 11.5px;
    font-weight: 600;
    white-space: nowrap;
    text-align: center;
}

.raccourcis dd {
    margin: 0;
    font-size: 12px;
    line-height: 1.45;
    color: var(--texte-doux);
}

.modale-note {
    margin-top: 8px;
    font-size: 11.5px;
    line-height: 1.45;
    color: var(--texte-doux);
}

.modale-note:empty { display: none; }

/* Disponibilité des modes de filigrane, établie par index.php au chargement. */
.detect {
    list-style: none;
    margin: 10px 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.detect li {
    position: relative;
    padding-left: 20px;
    font-size: 11.5px;
    line-height: 1.55;
    color: var(--texte-doux);
}

.detect li::before {
    position: absolute;
    left: 0;
    top: 0;
    font-weight: 700;
}

.detect li.oui::before { content: "✓"; color: var(--vert-tendre); }
.detect li.non::before { content: "✕"; color: var(--rouge-doux); }

.detect strong {
    color: var(--texte);
    font-weight: 600;
}

.detect code,
.modale-note code {
    padding: 1px 5px;
    background: var(--anthracite);
    border-radius: 3px;
    font-size: 11px;
    color: var(--vert-doux);
}

.modale-resume {
    padding: 11px 12px;
    background: var(--anthracite-clair);
    border-radius: var(--rayon);
    font-size: 12.5px;
    color: var(--vert-doux);
    font-variant-numeric: tabular-nums;
    text-align: center;
}

.modale-alerte {
    display: none;
    margin-top: 10px;
    padding: 10px 12px;
    border-left: 2px solid var(--rouge-doux);
    font-size: 11.5px;
    line-height: 1.5;
    color: var(--texte-doux);
}

.modale-alerte.visible { display: block; }

.modale-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 20px;
}

.modale-actions button {
    padding: 11px;
    border-radius: var(--rayon);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s, opacity 0.15s;
}

.modale-actions button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ============================================================
   Écran d'édition
   ============================================================ */

.edit-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 12, 0.94);
    display: none;
    flex-direction: column;
    z-index: 1000;
}

.edit-overlay.ouvert { display: flex; }

.edit-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 22px;
    flex-shrink: 0;
}

.edit-titre {
    font-weight: 600;
    letter-spacing: 0.5px;
}

.edit-btn-txt {
    background: none;
    border: none;
    color: var(--texte);
    font: inherit;
    font-size: 15px;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: var(--rayon);
    transition: background 0.15s;
}

.edit-btn-txt:hover { background: rgba(255, 255, 255, 0.1); }

.edit-valider {
    color: var(--vert-tendre);
    font-weight: 600;
}

/* Aucune marge intérieure ici : app.js calcule les coordonnées du cadre à
   partir de getBoundingClientRect() de cette boîte, un padding décalerait tout. */
.edit-scene {
    position: relative;
    flex: 1;
    min-height: 0;
    padding: 0;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* La taille est pilotée par app.js. Les contraintes CSS sont neutralisées :
   elles fausseraient le calcul du rectangle englobant. */
#editImg {
    flex: 0 0 auto;
    max-width: none;
    max-height: none;
    transform-origin: center center;
}

/* --- Cadre de recadrage --- */

.crop-box {
    position: absolute;
    border: 1px solid rgba(255, 255, 255, 0.9);
    box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.55);
    cursor: move;
    display: none;
    box-sizing: border-box;
    touch-action: none;
}

.crop-box.actif { display: block; }

/* Repères de composition, tracés en SVG et étirés au cadre.
   non-scaling-stroke garde une épaisseur de trait constante malgré
   l'étirement, qui sinon amincirait les traits dans un sens. */
.crop-guides {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: visible;
}

.crop-guides line,
.crop-guides path {
    fill: none;
    stroke: rgba(255, 255, 255, 0.38);
    stroke-width: 1;
    vector-effect: non-scaling-stroke;
}

.crop-poignee {
    position: absolute;
    width: 16px;
    height: 16px;
    background: #fff;
    border-radius: 2px;
    box-shadow: 0 0 2px rgba(0, 0, 0, 0.6);
    touch-action: none;
}

.ph-tl { top: -8px; left: -8px; cursor: nwse-resize; }
.ph-tr { top: -8px; right: -8px; cursor: nesw-resize; }
.ph-bl { bottom: -8px; left: -8px; cursor: nesw-resize; }
.ph-br { bottom: -8px; right: -8px; cursor: nwse-resize; }

/* --- Barre d'outils d'édition (une seule définition) --- */

.edit-toolbar {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    padding: 16px;
    min-height: 60px;
    flex-shrink: 0;
}

.crop-btn {
    background: var(--anthracite-clair);
    color: var(--texte);
    border: 1px solid var(--anthracite-bord);
    border-radius: var(--rayon);
    padding: 8px 12px;
    font: inherit;
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.crop-btn:hover {
    background: var(--anthracite-bord);
    border-color: var(--vert-tendre);
}

.crop-btn.actif {
    background: var(--vert-fort);
    border-color: var(--vert-fort);
    color: #fff;
}

/* Groupes dépliables horizontaux : ratios, miroir, rotation. */
.crop-groupe {
    display: inline-flex;
    align-items: center;
}

.crop-ratios,
.crop-panneau {
    display: flex;
    align-items: center;
    gap: 6px;
    overflow: hidden;
    max-width: 0;
    opacity: 0;
    margin-left: 0;
    white-space: nowrap;
    transition: max-width 0.3s ease, opacity 0.25s ease, margin-left 0.3s ease;
}

.crop-ratios.ouvert,
.crop-panneau.ouvert {
    max-width: 620px;
    opacity: 1;
    margin-left: 8px;
}

.crop-ratio {
    background: var(--anthracite-clair);
    color: var(--texte-doux);
    border: 1px solid var(--anthracite-bord);
    border-radius: var(--rayon);
    padding: 6px 10px;
    font: inherit;
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.crop-ratio:hover {
    background: var(--anthracite-bord);
    color: var(--texte);
}

.crop-ratio.actif {
    background: var(--vert-fort);
    border-color: var(--vert-fort);
    color: #fff;
}

#rotateSlider { width: 150px; }

.rotate-val {
    min-width: 40px;
    text-align: right;
    font-variant-numeric: tabular-nums;
    color: var(--vert-doux);
    font-size: 13px;
}

/* ============================================================
   Écrans étroits
   ============================================================ */

@media (max-width: 860px) {
    /* C'est le document qui défile, et non plus un cadre figé à la hauteur de
       l'écran. Le passage est nécessaire, pas cosmétique : avec body à 100vh,
       .corps recevait une hauteur fixe et son overflow: hidden coupait le bas
       du panneau — les derniers réglages devenaient inatteignables, puisque
       body n'avait lui-même rien à faire défiler. */
    body {
        height: auto;
        min-height: 100vh;
        overflow: visible;
    }

    .corps {
        flex-direction: column;
        overflow: visible;
    }

    /* Aperçu collant. Les curseurs défilent sous l'image au lieu de la chasser
       de l'écran : régler une saturation sans voir la photo n'a aucun intérêt.
       La barre du haut, elle, s'en va — on y revient d'un pouce.

       Aucun ancêtre ne doit porter overflow autre que visible, sans quoi le
       collant est ignoré : c'est pourquoi body et .corps sont repris juste
       au-dessus. Le fond opaque de .zone-apercu masque le panneau qui passe
       dessous, et le z-index le maintient au-dessus. */
    .zone-apercu {
        position: sticky;
        top: 0;
        z-index: 5;
        height: 45vh;
        flex: none;
        padding: 16px;
    }

    /* En plein cadre le panneau disparaît : l'image reprend tout l'écran.
       Sélecteur plus spécifique que la règle ci-dessus, l'ordre n'y fait rien. */
    body.plein-cadre .zone-apercu { height: 100vh; }

    .panneau {
        width: 100%;
        border-left: none;
        border-top: 1px solid var(--anthracite-bord);
        overflow-y: visible;
    }

    .filtres { grid-template-columns: repeat(3, 1fr); }

    .barre-outils {
        margin-left: 0;
        margin-right: 0;
        order: 3;
        width: 100%;
    }

    .preset-nom { max-width: 60vw; }

    .edit-toolbar {
        justify-content: flex-start;
        overflow-x: auto;
    }

    .crop-ratios.ouvert,
    .crop-panneau.ouvert { max-width: 100%; }
}

/* ============================================================
   Pointeur grossier

   Deux axes distincts, et deux requêtes distinctes : la largeur décide de la
   mise en page, le type de pointeur décide des cibles. Une fenêtre rétrécie
   sur Mac a besoin de la première et surtout pas de la seconde — elle garde un
   pointeur précis et un clavier. Aucun écran à pointeur fin ne lit ce bloc.
   ============================================================ */

@media (pointer: coarse) {
    /* Un carré de 16 px se voit bien et s'attrape mal : au doigt il faut une
       quarantaine de pixels. Le pseudo-élément élargit la seule cible, la
       poignée garde sa taille à l'écran — grossir le carré visible encombrerait
       le cadrage pour rien. */
    .crop-poignee::before {
        content: '';
        position: absolute;
        inset: -14px;
    }
}

/* ============================================================
   Animations réduites
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
/* ============================================================
   Lien vers le compte, dans la barre du haut
   ============================================================ */

.btn-compte {
    text-decoration: none;
    background: transparent;
    border: 1px solid var(--anthracite-bord);
    color: var(--texte-doux);
}

.btn-compte:hover {
    background: var(--anthracite-clair);
    color: var(--texte);
}


/* Un lien qui emprunte l'allure d'un bouton doit s'aligner comme lui : sans
   ces trois lignes, l'ancre reste en ligne et le contenu se tasse à gauche. */
a.btn-notice {
    display: flex;
    align-items: center;
    justify-content: space-between;
    text-decoration: none;
}
