/* Rature : un cahier Seyès, un stylo rouge pour corriger, un stylo bleu pour agir */
:root {
  --desk: #fbf8f0; --paper: #fbf8f0; --rule: #b3baec; --rule-2: #b3baec66; --margin: #e2494f;
  --panel: #fffdf7; --panel-2: #f3efe4;
  --ink: #15151f; --ink-2: #3b3b4d; --muted: #6f6c78;
  --line: #e4dfd2; --line-2: #cfc9b9;
  --accent: #e2494f; --accent-2: #c8323a; --accent-soft: #e2494f1f;
  --pen: #1c2a8f; --pen-2: #101d6e;
  --sel: #2b3fd1; --sel-soft: #2b3fd122;
  --hard: #15151f; /* ombres franches, décalées */
  --shadow: 3px 3px 0 var(--hard);
  --paper-shadow: 5px 5px 0 #15151f26, 0 1px 3px #15151f33;
  --display: 'Young Serif', Georgia, serif;
  --ui: 'Schibsted Grotesk', system-ui, sans-serif;
  --hand: 'Nothing You Could Do', 'Segoe Print', cursive;
}
/* thème sombre, « le cahier la nuit » : automatique (réglage de l'appareil) sauf si « Clair » est choisi, ou forcé par « Sombre » */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme=light]) {
    --desk: #14151c; --paper: #1b1c25; --rule: #3d4577; --rule-2: #3d457740; --margin: #e2494f99;
    --panel: #1d1e27; --panel-2: #272835;
    --ink: #ecebf3; --ink-2: #c4c3d2; --muted: #8d8b9c;
    --line: #2f3040; --line-2: #464759;
    --accent: #ff6b6f; --accent-2: #ff8b8e; --accent-soft: #ff6b6f26;
    --pen: #4a5cf0; --pen-2: #5d6ef7;
    --sel: #8c9bff; --sel-soft: #8c9bff2a;
    --hard: #000;
    --paper-shadow: 5px 5px 0 #0008;
  }
}
:root[data-theme=dark] {
  --desk: #14151c; --paper: #1b1c25; --rule: #3d4577; --rule-2: #3d457740; --margin: #e2494f99;
  --panel: #1d1e27; --panel-2: #272835;
  --ink: #ecebf3; --ink-2: #c4c3d2; --muted: #8d8b9c;
  --line: #2f3040; --line-2: #464759;
  --accent: #ff6b6f; --accent-2: #ff8b8e; --accent-soft: #ff6b6f26;
  --pen: #4a5cf0; --pen-2: #5d6ef7;
  --sel: #8c9bff; --sel-soft: #8c9bff2a;
  --hard: #000;
  --paper-shadow: 5px 5px 0 #0008;
}

* { box-sizing: border-box; }
body { margin: 0; height: 100vh; height: 100dvh; display: grid; grid-template-rows: auto 1fr; grid-template-columns: minmax(0, 1fr); overflow: hidden;
       font: 14px/1.4 var(--ui); color: var(--ink); background: var(--desk); }
button, select, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--sel); outline-offset: 2px; }
svg.i { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
[hidden] { display: none !important; }

/* ---------- En-tête ---------- */
header { display: flex; align-items: center; gap: 18px; height: 62px; padding: 0 18px; background: var(--panel);
         border-bottom: 1.5px solid var(--hard); position: relative; z-index: 6; animation: drop .5s both; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand svg { width: 32px; height: 32px; flex: none; }
.brand b { font: 400 25px/1 var(--display); letter-spacing: -.01em; }
.brand small { font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted);
               border-left: 1px solid var(--line-2); padding-left: 10px; }
.doc { flex: 1; display: flex; justify-content: center; align-items: center; gap: 10px; min-width: 0; }
#fname { max-width: 40ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 6px 14px;
         border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); font-size: 13px; color: var(--ink-2); }
#saved { font-size: 12px; color: var(--muted); opacity: 0; transition: opacity .4s; white-space: nowrap; }
#saved.on { opacity: 1; }
.actions { display: flex; gap: 6px; align-items: center; }
.actions .sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }
.drawer-btn { display: none !important; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 15px;
       border-radius: 11px; border: 1px solid var(--line-2); background: var(--panel); font-weight: 500; cursor: pointer;
       transition: background .15s, border-color .15s, transform .15s, box-shadow .15s, opacity .15s; white-space: nowrap; }
.btn:hover { background: var(--panel-2); transform: translateY(-1px); }
.btn:active { transform: none; }
.btn:disabled { opacity: .4; pointer-events: none; }
.btn.icon { width: 38px; padding: 0; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--panel-2); }
.btn.primary { background: var(--pen); border-color: var(--hard); color: #fff; font-weight: 700; box-shadow: 3px 3px 0 var(--hard); }
.btn.primary:hover { background: var(--pen-2); transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--hard); }
.btn.primary:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--hard); }
.btn .spin { display: none; width: 16px; height: 16px; border: 2px solid #fff6; border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
.btn.busy { pointer-events: none; opacity: .9; }
.btn.busy .spin { display: block; }
.btn.busy svg { display: none; }

/* ---------- Mise en page ---------- */
main { display: grid; grid-template-columns: 164px 1fr 268px; min-height: 0; }
.side { display: flex; flex-direction: column; gap: 14px; padding: 22px 18px; overflow: auto; background: var(--panel); }
.side.right { border-left: 1px solid var(--line); animation: slide .5s .1s both; }
.side.left { border-right: 1px solid var(--line); padding: 18px 10px; gap: 10px; overflow: hidden; animation: slideL .5s .1s both; }
body:not(.loaded) .side.left > * { visibility: hidden; }
.side h2 { font: 400 21px/1.1 var(--display); margin: 0; }
.side h2 + p { margin: 4px 0 0; font-size: 13px; color: var(--muted); }
.side-head { display: flex; align-items: baseline; justify-content: space-between; padding: 0 6px; }
.side-head h2 { font-size: 19px; }
.count { font-size: 12px; color: var(--muted); }
.side-actions { display: flex; flex-direction: column; gap: 6px; }

/* ---------- Miniatures ---------- */
#thumbs { flex: 1; min-height: 0; overflow: auto; display: flex; flex-direction: column; gap: 2px; padding: 2px; }
.pthumb { position: relative; padding: 8px 10px; border-radius: 12px; cursor: pointer; transition: background .15s; }
.pthumb:hover { background: var(--panel-2); }
.pthumb.cur { background: var(--panel-2); }
.pthumb canvas { display: block; width: 100%; background: #fff; border-radius: 2px; box-shadow: 0 1px 2px #0002, 0 4px 12px -4px #3a2f1a44; }
.pthumb .pn { display: block; text-align: center; font-size: 12px; color: var(--muted); margin-top: 6px; }
.pthumb.cur .pn { color: var(--accent); font-weight: 600; }
.pthumb.before { box-shadow: inset 0 3px 0 var(--accent); }
.pthumb.after { box-shadow: inset 0 -3px 0 var(--accent); }
.pact { position: absolute; top: 12px; right: 12px; display: grid; grid-template-columns: repeat(3, 26px); gap: 3px; opacity: 0; transition: opacity .15s; }
.pthumb:hover .pact { opacity: 1; }
.pact button { width: 26px; height: 26px; border: 0; border-radius: 8px; background: var(--panel); box-shadow: var(--shadow);
               display: grid; place-items: center; cursor: pointer; color: var(--ink-2); }
.pact button:hover { color: var(--panel); background: var(--ink); }
.pact button.danger:hover { background: var(--accent); color: #fff; }
.pact svg { width: 14px; height: 14px; }
.side .add { height: 40px; border: 1.5px dashed var(--line-2); background: transparent; font-size: 13px; padding: 0 10px; }
.side .add:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

/* ---------- Bureau et pages ---------- */
/* le bureau est une page de cahier : grands carreaux et marge rouge, la barre d'outils se tient dans la marge */
#desk { --mx: 166px; position: relative; overflow: hidden; background-color: var(--desk);
        background-image: linear-gradient(90deg, transparent calc(var(--mx) - 1px), var(--margin) calc(var(--mx) - 1px), var(--margin) calc(var(--mx) + 1px), transparent calc(var(--mx) + 1px)),
                          linear-gradient(var(--rule) 1px, transparent 1px), linear-gradient(var(--rule-2) 1px, transparent 1px), linear-gradient(90deg, var(--rule-2) 1px, transparent 1px);
        background-size: 100% 100%, 100% 32px, 100% 8px, 32px 100%; background-position: 0 0, 0 11px, 0 3px, 6px 0; }
body.loaded #desk { background-size: 100% 100%, 100% 32px, 0 0, 32px 100%; } /* derrière les pages : seulement les lignes principales, plus calme */
#pages { --z: 1; position: absolute; inset: 0; overflow: auto; padding: 86px 40px 120px 196px; }
.page { position: relative; margin: 0 auto 64px; width: calc(var(--w) * var(--z) * 1px); height: calc(var(--h) * var(--z) * 1px);
        background: #fff; border-radius: 2px; box-shadow: var(--paper-shadow); animation: rise .6s cubic-bezier(.2,.7,.2,1) both; }
.page::before { content: ''; position: absolute; inset: 0; border: 1.5px solid var(--hard); border-radius: 2px; pointer-events: none; z-index: 1; opacity: .85; }
.page::after { content: attr(data-n); position: absolute; top: calc(100% + 16px); left: 0; right: 0; text-align: center;
               font-size: 12px; letter-spacing: .14em; color: var(--muted); pointer-events: none; }
.layer { position: absolute; left: 0; top: 0; width: calc(var(--w) * 1px); height: calc(var(--h) * 1px);
         transform: scale(var(--z)); transform-origin: 0 0; }
.layer canvas.pdf { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 2px; }
.layer > svg.shape { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
svg.shape > * { pointer-events: all; }
svg.shape > .mark { pointer-events: bounding-box; cursor: move; }
svg.shape > .ink { pointer-events: visibleStroke; }
svg.shape:has(> .hl) { mix-blend-mode: multiply; }
svg.shape > .sel { filter: drop-shadow(0 0 2px var(--sel)); }
body[data-tool=text] .layer, body[data-tool=edit] .layer { cursor: text; }
body[data-tool=stamp] .layer, body[data-tool=draw] .layer, body[data-tool=highlight] .layer, body[data-tool=note] .layer, body[data-tool=arrow] .layer,
body[data-tool=rect] .layer, body[data-tool=ellipse] .layer, body[data-tool=line] .layer, body[data-tool=redact] .layer, body[data-tool=field] .layer, body[data-tool=crop] .layer,
body[data-tool=link] .layer { cursor: crosshair; }
body[data-tool=draw] .layer, body[data-tool=highlight] .layer, body[data-tool=arrow] .layer, body[data-tool=redact] .layer, body[data-tool=link] .layer,
body[data-tool=rect] .layer, body[data-tool=ellipse] .layer, body[data-tool=line] .layer, body[data-tool=field] .layer, body[data-tool=crop] .layer { touch-action: none; } /* au doigt : on dessine au lieu de faire défiler */
#pages { touch-action: pan-x pan-y; } /* le zoom à deux doigts est celui de Rature, pas celui du navigateur */
/* écrans tactiles : cibles plus grandes */
@media (pointer: coarse) {
  #tools button { width: 46px; height: 44px; }
  .menu button { padding-top: 11px; padding-bottom: 11px; }
  .box .grip { width: calc(14px / var(--z)); height: calc(30px / var(--z)); opacity: 1; }
  .prop button, .stepper button { min-width: 36px; min-height: 36px; }
}
body[data-tool=move] svg.shape > * { cursor: move; }

/* éléments posés sur la page (tailles de cadre compensées pour rester fines à tous les zooms) */
.box { position: absolute; padding: 4px; border-radius: 4px; cursor: move;
       outline: calc(1px / var(--z)) dashed color-mix(in srgb, var(--sel) 55%, transparent); transition: box-shadow .15s; }
.box:hover, .box.sel { outline-style: solid; outline-color: var(--sel); box-shadow: 0 0 0 calc(3px / var(--z)) var(--sel-soft); }
.box.note { padding: 8px; background: #fff3a8; border-radius: 2px; outline-color: #d9bf3f;
            box-shadow: 0 2px 5px #0002, 0 10px 18px -10px #0005; }
.box.note.sel, .box.note:hover { box-shadow: 0 0 0 calc(3px / var(--z)) var(--sel-soft), 0 10px 18px -10px #0005; }
.box .rich { outline: none; cursor: text; }
.box textarea, .box .rich { position: relative; display: block; border: 0; padding: 0; margin: 0; background: transparent; outline: none; resize: none;
                overflow: hidden; cursor: text; white-space: pre;
                font-kerning: none; font-variant-ligatures: none; } /* comme dans le PDF enregistré : largeurs identiques */
.box .cover { position: absolute; pointer-events: none; }
.box .grip { position: absolute; top: 50%; right: calc(-4px / var(--z)); width: calc(7px / var(--z)); height: calc(20px / var(--z));
             transform: translateY(-50%); border-radius: 99px; background: var(--sel); opacity: 0; cursor: ew-resize; transition: opacity .15s; }
.box:hover .grip, .box.sel .grip { opacity: 1; }
.img { position: absolute; resize: horizontal; overflow: hidden; min-width: 12px; cursor: move; border-radius: 2px;
       outline: calc(1px / var(--z)) dashed color-mix(in srgb, var(--sel) 55%, transparent); }
.img:hover, .img.sel { outline-style: solid; outline-color: var(--sel); box-shadow: 0 0 0 calc(3px / var(--z)) var(--sel-soft); }
.img img { display: block; width: 100%; height: 100%; pointer-events: none; }
.tl { position: absolute; display: none; border-radius: 1px; }
body[data-tool=edit] .tl { display: block; }
body[data-tool=edit] .tl:hover { background: var(--accent-soft); outline: calc(1.5px / var(--z)) solid var(--accent); }
.page .ocr { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); display: none; z-index: 2;
             background: var(--ink); color: var(--panel); border-color: transparent; box-shadow: var(--shadow); }
body[data-tool=edit] .page.scan:not(.ocrdone) .ocr { display: inline-flex; }
.hit { position: absolute; background: #ffd84d88; mix-blend-mode: multiply; pointer-events: none; border-radius: 2px; }
.hit.cur { background: #ff8a3d99; outline: calc(1.5px / var(--z)) solid var(--accent); }
.guide { position: absolute; background: var(--accent); pointer-events: none; z-index: 5; }
.guide.v { top: 0; bottom: 0; width: calc(1px / var(--z)); }
.guide.h { left: 0; right: 0; height: calc(1px / var(--z)); }
.marquee { position: absolute; border: calc(1px / var(--z)) dashed var(--sel); background: var(--sel-soft); pointer-events: none; }
.deco { position: absolute; inset: 0; pointer-events: none; overflow: hidden; font-family: 'Plume arial', Arial, sans-serif; }
.deco span { position: absolute; white-space: pre; line-height: 1; color: #444; }
.deco .wm { left: 50%; top: 50%; font-weight: 700; transform: translate(-50%, -50%) rotate(-45deg); }

/* champs de formulaire du PDF */
.field { position: absolute; margin: 0; padding: 0 2px; border: 0; border-bottom: 1px solid #2f62e066; border-radius: 1px;
         background: #2f62e014; color: #000; font-family: Helvetica, Arial, sans-serif; outline: none; }
.field:hover { background: #2f62e024; }
.field:focus { background: #2f62e02e; box-shadow: 0 0 0 1px #2f62e0; }
textarea.field { resize: none; padding: 1px 2px; line-height: 1.15; }
input.field[type=checkbox], input.field[type=radio] { border: 0; background: none; box-shadow: none; accent-color: #2f62e0; cursor: pointer; }
.field:disabled { background: transparent; border-color: transparent; }

/* ---------- Barre d'outils (rail) ---------- */
.float { background: var(--panel); border: 1.5px solid var(--hard); box-shadow: var(--shadow); z-index: 4;
         transition: opacity .3s, transform .3s; }
/* barre d'outils : chaque outil écrit en toutes lettres, l'outil choisi passe au rouge */
#tools { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column;
         gap: 1px; padding: 6px; border-radius: 16px; width: 138px; }
#tools hr { border: 0; height: 1px; background: var(--line); margin: 4px 6px; flex: none; }
#tools button { position: relative; width: 42px; height: 40px; border: 0; border-radius: 10px; background: transparent; flex: none;
                color: var(--ink-2); display: grid; place-items: center; cursor: pointer; transition: background .15s, color .15s; }
#tools > button, #tools .tgroup > button { width: 100%; height: 38px; display: flex; justify-content: flex-start; gap: 10px; padding: 0 10px; font-size: 14px; font-weight: 500; text-align: left; }
#tools button:hover { background: var(--panel-2); color: var(--ink); }
#tools button.on { background: var(--accent); color: #fff; font-weight: 700; }
#tools button::after { content: attr(data-tip); position: absolute; left: calc(100% + 14px); top: 50%;
                       transform: translate(-4px, -50%); white-space: nowrap; padding: 6px 10px; border-radius: 8px;
                       background: var(--ink); color: var(--panel); font-size: 12px; font-weight: 500;
                       opacity: 0; pointer-events: none; transition: opacity .15s, transform .15s; z-index: 2; }
#tools button:hover::after { opacity: 1; transform: translate(0, -50%); transition-delay: .5s; } /* le nom est déjà écrit : l'infobulle (raccourci) vient après un temps */
.tgroup { position: relative; }
.tgroup > button::after { display: none; }
.tgroup > button > i { position: absolute; right: 8px; top: 50%; margin-top: -4px; border: 4px solid transparent; border-left-color: currentColor; opacity: .6; }
.flyout { position: absolute; left: calc(100% + 12px); top: 50%; transform: translateY(-50%); display: none; gap: 2px; padding: 5px;
          background: var(--panel); border: 1.5px solid var(--hard); border-radius: 14px; box-shadow: var(--shadow); }
.flyout::before { content: ''; position: absolute; right: 100%; top: 0; bottom: 0; width: 14px; }
.tgroup:hover .flyout, .tgroup:focus-within .flyout { display: flex; }
.flyout button::after { left: 50% !important; top: calc(100% + 8px) !important; transform: translate(-50%, -4px) !important; }
.flyout button:hover::after { transform: translate(-50%, 0) !important; }

/* ---------- Options contextuelles ---------- */
#props { position: absolute; top: 18px; left: 50%; transform: translateX(-50%); display: flex; align-items: center;
         gap: 14px; padding: 7px 12px 7px 14px; border-radius: 15px; white-space: nowrap; max-width: calc(100% - 140px); overflow-x: auto; scrollbar-width: none; }
.prop { display: flex; align-items: center; gap: 8px; }
.prop:not([hidden]) ~ .prop:not([hidden]) { border-left: 1px solid var(--line); padding-left: 14px; }
.prop > span { font-size: 12px; color: var(--muted); }
.prop.info { font-size: 12.5px; color: var(--ink-2); }
.sw { position: relative; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--panel); padding: 0; flex: none;
      background: var(--c); box-shadow: 0 0 0 1px var(--line-2); cursor: pointer; transition: transform .15s, box-shadow .15s; }
.sw:hover { transform: scale(1.14); }
.sw.on { box-shadow: 0 0 0 2px var(--ink); }
.sw.custom { background: conic-gradient(#e74c3c, #f1c40f, #2ecc71, #3498db, #9b59b6, #e74c3c); overflow: hidden; }
.sw.custom input { position: absolute; inset: -6px; opacity: 0; cursor: pointer; }
.stepper { display: flex; align-items: center; border: 1px solid var(--line-2); border-radius: 10px; overflow: hidden; }
.stepper button { width: 27px; height: 29px; border: 0; background: transparent; color: var(--ink-2); font-size: 16px; cursor: pointer; }
.stepper button:hover { background: var(--panel-2); color: var(--ink); }
.stepper input { width: 40px; height: 29px; border: 0; border-inline: 1px solid var(--line); background: transparent;
                 text-align: center; font-weight: 500; font-size: 13px; -moz-appearance: textfield; }
.stepper input::-webkit-inner-spin-button { -webkit-appearance: none; }
.sel-font { height: 31px; padding: 0 8px; border: 1px solid var(--line-2); border-radius: 10px; background: var(--panel); font-size: 13px; cursor: pointer; }
.tog, .kinds button { min-width: 31px; height: 31px; padding: 0 8px; border: 1px solid var(--line-2); border-radius: 10px;
                      background: transparent; cursor: pointer; font-size: 14px; transition: background .15s, color .15s; }
.kinds button.txt-k { font-size: 12.5px; }
.tog:hover, .kinds button:hover { background: var(--panel-2); }
.tog.on, .kinds button.on { background: var(--ink); color: var(--panel); border-color: var(--ink); }
.kinds { display: flex; gap: 4px; }
.kinds i { width: 1px; background: var(--line); margin: 3px 4px; }
#allpages { height: 31px; padding: 0 11px; font-size: 13px; border-radius: 10px; }

/* ---------- Aide, zoom, recherche ---------- */
#hint { position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%); padding: 8px 16px; border-radius: 999px;
        font-size: 13px; color: var(--ink-2); white-space: nowrap; max-width: calc(100% - 300px); overflow: hidden; text-overflow: ellipsis;
        background: var(--panel); }
#hint em { display: inline-grid; place-items: center; width: 20px; height: 20px; margin: 0 7px 0 0; border-radius: 50%; vertical-align: 1px;
           background: var(--accent); color: #fff; font: 700 11.5px/1 var(--ui); font-style: normal; }
#hint b { color: var(--ink); margin-right: 14px; }
#hint i { display: inline-block; width: 1px; height: 12px; background: var(--line-2); margin: 0 10px; vertical-align: -1px; }
kbd { font: 600 11px var(--ui); padding: 1px 6px; border-radius: 5px; background: var(--panel-2); border: 1px solid var(--line-2);
      border-bottom-width: 2px; color: var(--ink); }
#zoom { position: absolute; right: 18px; bottom: 18px; display: flex; align-items: center; padding: 4px; border-radius: 13px; }
#zoom button { height: 32px; min-width: 32px; border: 0; border-radius: 9px; background: transparent; cursor: pointer;
               display: grid; place-items: center; color: var(--ink-2); font-size: 13px; font-weight: 500; }
#zoom button:hover { background: var(--panel-2); color: var(--ink); }
#zoom svg { width: 16px; height: 16px; }
#zoomval { min-width: 58px !important; }
#find { position: absolute; top: 72px; right: 18px; z-index: 5; width: min(360px, calc(100% - 36px)); padding: 6px; border-radius: 14px;
        display: flex; flex-direction: column; gap: 6px; }
.frow { display: flex; align-items: center; gap: 4px; }
.frow input { flex: 1; min-width: 0; height: 34px; padding: 0 10px; border: 1px solid var(--line-2); border-radius: 9px; background: var(--panel-2); outline: none; }
.frow input:focus { border-color: var(--sel); }
.frow > button { height: 34px; min-width: 32px; border: 0; border-radius: 9px; background: transparent; cursor: pointer; color: var(--ink-2); display: grid; place-items: center; }
.frow > button:hover { background: var(--panel-2); color: var(--ink); }
.frow > button.on { background: var(--ink); color: var(--panel); }
.frow .btn { height: 34px; padding: 0 11px; font-size: 13px; }
.frow svg { width: 17px; height: 17px; }
#fcount { font-size: 12px; color: var(--muted); min-width: 44px; text-align: center; }
body:not(.loaded) .float { opacity: 0; pointer-events: none; }
body:not(.loaded) #tools { transform: translate(-12px, -50%); }

/* ---------- Accueil ---------- */
#empty { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; z-index: 3; overflow: auto; transition: opacity .3s, visibility .3s; }
body.loaded #empty { opacity: 0; visibility: hidden; }
/* à gauche ce que fait Rature, à droite une seule grande zone où déposer le fichier */
#empty { padding-left: calc(var(--mx) + 24px); }
body:not(.loaded) main { grid-template-columns: minmax(0, 1fr); } /* accueil : toute la largeur pour le dépôt, les panneaux viennent avec le document */
body:not(.loaded) .side { display: none !important; }
.welcome { width: min(1080px, 100%); display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 20px 72px; align-items: center; }
.pitch { display: flex; flex-direction: column; gap: 22px; animation: rise .7s both; }
.eyebrow { margin: 0; font-size: 18px; color: var(--ink-2); }
.eyebrow s { position: relative; text-decoration: none; }
.eyebrow s svg { position: absolute; left: -4%; top: 34%; width: 108%; height: 14px; overflow: visible; }
.eyebrow s path { fill: none; stroke: var(--accent); stroke-width: 12; stroke-linecap: round; stroke-dasharray: 520; animation: strike .7s .6s cubic-bezier(.65,0,.35,1) both; }
.pitch h1 { margin: -8px 0 0; font: 400 clamp(38px, 4.6vw, 62px)/1.08 var(--display); letter-spacing: -.02em; }
.pitch > p { margin: 0; font-size: 18px; line-height: 1.55; color: var(--ink-2); }
.pitch ul { display: flex; flex-direction: column; gap: 9px; margin: 0; padding: 0; list-style: none; font-size: 15.5px; }
.pitch li { display: flex; align-items: center; gap: 12px; }
.pitch li::before { content: ''; width: 18px; height: 18px; flex: none;
                    background: var(--accent); mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 12.5 5 5L20 6.5'/%3E%3C/svg%3E") center / contain no-repeat; }
.alt { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; color: var(--muted); font-size: 13.5px; }
.alt .btn { color: var(--ink); }
.dropwrap { position: relative; animation: rise .7s .15s both; }
.drop { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; min-height: min(520px, 62vh);
        padding: 40px 32px; text-align: center; border: 3px dashed var(--hard); border-radius: 22px; background: var(--panel); cursor: pointer;
        box-shadow: 8px 8px 0 color-mix(in srgb, var(--hard) 14%, transparent); animation: zone 4.2s 1.6s ease-in-out infinite;
        transition: transform .2s; }
.drop:hover, .drop:focus-visible, #desk.over .drop { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 7%, var(--panel)); animation: none; }
.drop:focus-visible { outline: 3px solid var(--pen); outline-offset: 4px; }
#desk.over .drop { transform: scale(1.015); }
.drop .down { width: 72px; height: 82px; animation: nudge 1.6s ease-in-out infinite; }
.drop strong { font: 400 clamp(26px, 2.6vw, 34px)/1.15 var(--display); }
.drop .or { margin-top: -12px; color: var(--muted); font-size: 15px; }
.drop .cta { display: inline-flex; align-items: center; gap: 11px; padding: 17px 30px; border: 1.5px solid var(--hard); border-radius: 14px;
             background: var(--pen); color: #fff; font-weight: 700; font-size: 18px; box-shadow: 4px 4px 0 var(--hard); transition: transform .15s, box-shadow .15s, background .15s; }
.drop:hover .cta { background: var(--pen-2); transform: translate(-1px, -1px); box-shadow: 5px 5px 0 var(--hard); }
.drop:active .cta { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--hard); }
.drop small { max-width: 320px; color: var(--muted); font-size: 13.5px; line-height: 1.5; }
.drop .fly { position: absolute; left: 50%; top: 10%; width: 92px; height: 114px; margin-left: -46px; pointer-events: none; opacity: 0; animation: fly 4.2s 1.6s cubic-bezier(.45,0,.2,1) infinite; }
.drop:hover .fly, #desk.over .fly { display: none; }
.here { position: absolute; left: -150px; bottom: -34px; width: 190px; pointer-events: none; }
.here svg { display: block; width: 150px; height: 96px; overflow: visible; }
.here path { fill: none; stroke: var(--accent); stroke-width: 3; stroke-linecap: round; stroke-dasharray: 300; animation: strike-a .9s 2.2s cubic-bezier(.6,0,.2,1) both; }
.here span { position: absolute; left: -44px; bottom: -6px; font: 30px/1 var(--hand); color: var(--accent); transform: rotate(-4deg); white-space: nowrap; animation: rise .5s 2.6s both; }
@keyframes strike { from { stroke-dashoffset: 520; } to { stroke-dashoffset: 0; } }
@keyframes strike-a { from { stroke-dashoffset: 300; } to { stroke-dashoffset: 0; } }
@keyframes nudge { 50% { transform: translateY(5px); } }
@keyframes zone { 0%, 40%, 100% { border-color: var(--hard); } 52%, 80% { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 7%, var(--panel)); } }
@keyframes fly { 0%, 12% { opacity: 0; transform: translate(150px, -130px) rotate(14deg); } 22% { opacity: 1; } 52% { transform: translate(0, 0) rotate(-3deg); }
                 60%, 78% { opacity: 1; transform: translate(0, 6px) rotate(-3deg) scale(.96); } 88%, 100% { opacity: 0; transform: translate(0, 30px) rotate(-3deg) scale(.8); } }
.resume { grid-column: 1 / -1; order: -1; display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 16px; border-radius: 16px; background: var(--panel);
          border: 1.5px solid var(--hard); box-shadow: var(--shadow); animation: rise .6s .25s both; }
@media (max-width: 1180px) { #empty { padding-left: 24px; } }
@media (max-width: 900px) {
  .welcome { grid-template-columns: minmax(0, 1fr); max-width: 560px; gap: 26px; }
  .dropwrap { order: -1; } .resume { order: -2; }
  .pitch { gap: 16px; } .pitch ul { display: none; }
  .drop { min-height: 0; padding: 30px 20px; } .here { display: none; }
}
.resume > svg { color: var(--accent); }
.resume div { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.resume small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Signatures ---------- */
#signew { height: 46px; border: 1.5px dashed var(--line-2); background: transparent; }
#signew:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
#sigphotobtn { height: 36px; font-size: 13px; }
#siglist { display: flex; flex-direction: column; gap: 10px; }
.thumb { position: relative; padding: 10px; border-radius: 13px; background: #fff; border: 1px solid var(--line); cursor: grab;
         transition: transform .18s, box-shadow .18s; animation: rise .35s both; }
.thumb:hover { transform: translateY(-2px) rotate(-.6deg); box-shadow: var(--shadow); }
.thumb img { display: block; width: 100%; height: 62px; object-fit: contain; pointer-events: none; }
.thumb .del { position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; display: grid; place-items: center; border: 0;
              border-radius: 9px; background: #f2eee6; color: #7a7466; opacity: 0; cursor: pointer; transition: opacity .15s, background .15s; }
.thumb .del svg { width: 15px; height: 15px; }
.thumb:hover .del, .thumb .del:focus-visible { opacity: 1; }
.thumb .del:hover { background: var(--accent); color: #fff; }
#sigempty { text-align: center; padding: 18px 8px; color: var(--muted); font-size: 13px; }
#sigempty svg { width: 64px; height: 32px; color: var(--line-2); display: block; margin: 0 auto 6px; stroke-width: 1.5; }
.side .tip { margin-top: auto; font-size: 12px; color: var(--muted); padding: 12px; border-radius: 12px; background: var(--panel-2); }

/* ---------- Fenêtres ---------- */
dialog { border: 0; padding: 0; width: min(560px, calc(100vw - 32px)); max-height: calc(100dvh - 24px); border-radius: 22px; background: var(--panel);
         color: var(--ink); border: 2px solid var(--hard); box-shadow: 7px 7px 0 var(--hard); }
dialog.wide { width: min(920px, calc(100vw - 24px)); }
dialog[open] { animation: pop .28s cubic-bezier(.2,.8,.2,1.15); }
dialog::backdrop { background: #1d23318f; backdrop-filter: blur(3px); }
.dlg-head { padding: 24px 26px 4px; }
.dlg-head h3 { font: 400 24px/1.1 var(--display); margin: 0 0 4px; }
.dlg-head p { margin: 0; color: var(--muted); font-size: 13px; white-space: pre-line; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 18px 26px 24px; flex-wrap: wrap; }
.dlg-foot .grow { margin-right: auto; }
#palette { position: fixed; inset: 0; z-index: 60; background: #0006; display: flex; justify-content: center; align-items: flex-start; padding: 12vh 16px 0; }
#palette[hidden] { display: none; }
.pal { width: min(560px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; }
.pal input { width: 100%; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: var(--ink); font: inherit; font-size: 16px; padding: 14px 16px; outline: none; }
#pallist { max-height: 50vh; overflow: auto; padding: 6px; }
#pallist button { display: flex; width: 100%; align-items: center; gap: 10px; border: 0; background: none; color: var(--ink); font: inherit; text-align: left; padding: 9px 10px; border-radius: 10px; cursor: pointer; }
#pallist button small { color: var(--muted); margin-left: auto; font-size: 12px; }
#pallist button.on, #pallist button:hover { background: var(--accent-soft); }
#pallist .none { color: var(--muted); padding: 12px; }
.menu button.undone span { opacity: .45; text-decoration: line-through; }
.tabbar { display: flex; gap: 4px; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.tab { display: flex; align-items: center; gap: 4px; max-width: 190px; padding: 4px 6px 4px 10px; border-radius: 9px; font-size: 13px; cursor: pointer;
       color: var(--muted); border: 1px solid transparent; white-space: nowrap; flex: none; }
.tab span { overflow: hidden; text-overflow: ellipsis; }
.tab.on { color: var(--ink); background: var(--panel); border-color: var(--line); }
.tab button { border: 0; background: none; color: inherit; cursor: pointer; font-size: 11px; opacity: .6; padding: 2px 4px; border-radius: 5px; }
.tab button:hover { opacity: 1; background: var(--line); }
.tab.add { padding: 4px 10px; font-size: 16px; background: none; }
.profgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; padding: 6px 26px; max-height: 60vh; overflow: auto; }
.profgrid label { display: grid; gap: 3px; font-size: 12.5px; color: var(--muted); }
.profgrid label.full { grid-column: 1 / -1; }
.checklist { padding: 4px 26px; max-height: 58vh; overflow: auto; display: grid; gap: 6px; }
.checklist .row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.checklist .row .grow { flex: 1; min-width: 0; }
.checklist .row small { display: block; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.checklist .row input.txt { width: 100%; }
.checklist .empty { color: var(--muted); padding: 10px 0; }
@media (max-width: 560px) { .profgrid { grid-template-columns: 1fr; } }
svg.shape .link { fill: color-mix(in srgb, #1d6fe0 12%, transparent); stroke: #1d6fe0; stroke-dasharray: 4 3; }
.warnline { margin: 10px 26px 0; padding: 9px 12px; border-radius: 10px; background: color-mix(in srgb, #e0a800 16%, transparent); font-size: 13px; }
.prevpages { max-height: min(66vh, 720px); overflow: auto; padding: 4px 26px 8px; display: grid; gap: 16px; }
.prevpage h4 { margin: 0 0 6px; font-size: 13px; color: var(--muted); font-weight: 600; }
.prevpair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.prevpair figure { margin: 0; }
.prevpair figcaption { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.prevpair canvas { width: 100%; border-radius: 6px; box-shadow: 0 1px 3px #0003; background: #fff; }
.dlg-msg { min-height: 20px; padding: 8px 26px 0; color: var(--accent); font-size: 13px; }
.padwrap { position: relative; margin: 16px 26px 8px; border-radius: 15px; background: #fff; border: 1px solid var(--line); overflow: hidden; }
.padwrap::before { content: '×'; position: absolute; left: 18px; bottom: 50px; font: 22px var(--display); color: #c9bfa9; pointer-events: none; }
.padwrap::after { content: ''; position: absolute; left: 40px; right: 28px; bottom: 56px; border-bottom: 1.5px dashed #ddd4c2; pointer-events: none; }
#sigpad { display: block; width: 100%; height: 210px; touch-action: none; cursor: crosshair; position: relative; z-index: 1; }
.dlg-ink { display: flex; align-items: center; gap: 8px; padding: 0 26px; font-size: 12px; color: var(--muted); }
.fld { display: block; margin: 16px 26px 0; font-size: 12px; font-weight: 500; color: var(--muted); }
.txt { display: block; width: 100%; height: 42px; margin-top: 6px; padding: 0 13px; border: 1px solid var(--line-2); border-radius: 11px;
       background: var(--panel-2); font-size: 15px; outline: none; }
.txt:focus { border-color: var(--sel); box-shadow: 0 0 0 3px var(--sel-soft); }
.choice { display: flex; align-items: center; gap: 10px; margin-top: 8px; font-size: 14px; color: var(--ink); }
.choice input[type=radio], .chk input { accent-color: var(--accent); width: 17px; height: 17px; margin: 0; }
.choice .txt { flex: 1; height: 36px; margin: 0; }
.chk { display: flex; align-items: center; gap: 10px; margin: 16px 26px 0; font-size: 14px; cursor: pointer; }
.chk small { color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chips button { height: 28px; padding: 0 11px; border: 1px solid var(--line-2); border-radius: 999px; background: transparent; cursor: pointer; font-size: 12.5px; color: var(--ink); }
.chips button:hover { background: var(--panel-2); }
.row { display: flex; align-items: center; gap: 10px; margin-top: 8px; color: var(--ink); font-size: 13px; font-weight: 400; flex-wrap: wrap; }
.row select { height: 36px; padding: 0 8px; border: 1px solid var(--line-2); border-radius: 10px; background: var(--panel-2); }
.row input[type=range] { accent-color: var(--accent); width: 130px; }
.hintline { margin: 10px 26px 0; font-size: 12px; color: var(--muted); }
#askbody { padding: 0 26px; }
#askbody:empty { display: none; }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 7px 14px; margin: 14px 0 0; font-size: 13.5px; align-items: center; }
.keys dt { text-align: right; white-space: nowrap; }
.keys dd { margin: 0; color: var(--ink-2); }
.scanstage { position: relative; margin: 14px 26px 0; height: min(56dvh, 540px); background: #111; border-radius: 14px; overflow: hidden;
             display: grid; place-items: center; touch-action: none; }
#scanimg { display: block; max-width: 100%; max-height: 100%; }
#scansvg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.hdl { position: absolute; width: 28px; height: 28px; margin: -14px 0 0 -14px; border-radius: 50%; background: #fff;
       border: 3px solid var(--accent); box-shadow: 0 2px 8px #0009; cursor: grab; touch-action: none; }
.scanbar { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 14px 26px 0; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 11px; overflow: hidden; }
.seg button { height: 34px; padding: 0 14px; border: 0; background: transparent; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line-2); }
.seg button.on { background: var(--ink); color: var(--panel); }

/* ---------- Notifications ---------- */
#toasts { position: fixed; bottom: 76px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column;
          align-items: center; gap: 8px; z-index: 50; pointer-events: none; width: max-content; max-width: calc(100vw - 24px); }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 14px; padding: 10px 12px 10px 16px; border-radius: 13px;
         background: var(--ink); color: var(--panel); font-size: 14px; box-shadow: 0 14px 34px -12px #000a;
         animation: toast .32s cubic-bezier(.2,.8,.2,1.2); transition: opacity .3s, transform .3s; }
.toast.error { background: var(--accent); color: #fff; }
.toast button { border: 0; padding: 5px 11px; border-radius: 8px; background: #ffffff2e; font-weight: 600; font-size: 13px; cursor: pointer; }
.toast.out { opacity: 0; transform: translateY(8px); }

@keyframes rise { from { opacity: 0; transform: translateY(16px); } }
@keyframes drop { from { opacity: 0; transform: translateY(-8px); } }
@keyframes slide { from { opacity: 0; transform: translateX(12px); } }
@keyframes slideL { from { opacity: 0; transform: translateX(-12px); } }
@keyframes pop { from { opacity: 0; transform: scale(.94) translateY(10px); } }
@keyframes toast { from { opacity: 0; transform: translateY(14px) scale(.96); } }
@keyframes spin { to { transform: rotate(360deg); } }
/* écrans plus petits : les panneaux deviennent des tiroirs ouverts depuis l'en-tête */
@media (max-width: 1180px) {
  main { grid-template-columns: 1fr 268px; }
  .side.left { display: none; }
  #btnPages { display: inline-flex !important; }
  body.show-left .side.left { display: flex; position: fixed; left: 0; top: 62px; bottom: 0; width: 190px; z-index: 20; box-shadow: var(--shadow); }
}
@media (max-width: 860px) {
  main { grid-template-columns: 1fr; }
  .side.right, .brand small, #hint, #saved { display: none; }
  #btnSigs { display: inline-flex !important; }
  body.show-right .side.right { display: flex; position: fixed; right: 0; top: 62px; bottom: 0; width: min(290px, 86vw); z-index: 20; box-shadow: var(--shadow); }
  #pages { padding: 80px 16px 70px 72px; }
  #props { left: 72px; right: 12px; transform: none; max-width: none; }
  #tools { left: 10px; }
}
@media (max-width: 640px) {
  header { gap: 8px; padding: 0 10px; }
  .brand b, #fname, .lbl, .actions .sep, #help { display: none; }
  .btn { padding: 0 11px; }
  #tools button { width: 38px; height: 35px; }
  #zoom { right: 10px; bottom: 10px; }
  .drop { padding: 30px 18px 24px; }
  .drop h1 { font-size: 28px; }
}
@media (prefers-reduced-motion: reduce) { *, ::before, ::after { animation: none !important; transition: none !important; } }

/* ---------- Réglages des éléments ---------- */
.box.seal { padding: 4px; border: 2px solid; border-radius: 2px; background: transparent; }
.box.seal.frame-round { border-radius: 10px; }
.box.seal.frame-double { border-style: double; border-width: 4px; padding: 2px; }
.box.seal textarea { font-weight: 700; letter-spacing: .02em; }
.box, .img, .fieldbox { transform-origin: 50% 50%; }
.locked { cursor: default !important; }
.box.locked, .img.locked, .fieldbox.locked { outline-style: dotted !important; }
.box.locked .grip { display: none; }
.fieldbox { position: absolute; border: calc(1px / var(--z)) dashed #2f62e0; background: #2f62e012; border-radius: 2px; cursor: move; overflow: hidden; }
.fieldbox.sel, .fieldbox:hover { background: #2f62e022; box-shadow: 0 0 0 calc(3px / var(--z)) var(--sel-soft); }
.fieldbox span { position: absolute; left: 3px; top: 1px; font: 600 8px/1.2 var(--ui); color: #2f62e0; white-space: nowrap; pointer-events: none; }
.marquee.crop { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 9999px #0003; }
.mini { height: 31px; width: 130px; padding: 0 9px; border: 1px solid var(--line-2); border-radius: 10px; background: var(--panel); font-size: 13px; }
.mini.wide { width: 200px; }
#opacity { accent-color: var(--accent); width: 90px; }
.btn.danger { color: var(--accent); }
.btn.danger:hover { background: var(--accent); color: #fff; border-color: transparent; }
.muted { color: var(--muted); font-size: 13px; font-weight: 400; }

/* ---------- Menus ---------- */
.menu { position: fixed; z-index: 60; min-width: 220px; max-width: 290px; padding: 6px; border-radius: 14px; background: var(--panel);
        border: 1px solid var(--line); box-shadow: 0 18px 44px -14px #0008; animation: pop .16s ease-out; }
.menu button { display: flex; align-items: center; justify-content: space-between; gap: 16px; width: 100%; padding: 8px 10px; border: 0;
               border-radius: 9px; background: transparent; text-align: left; font-size: 13.5px; cursor: pointer; }
.menu button:hover:not(:disabled) { background: var(--panel-2); }
.menu button:disabled { opacity: .4; cursor: default; }
.menu button.on::before { content: '✓'; margin-right: -8px; color: var(--accent); font-weight: 700; }
.menu button.danger { color: var(--accent); }
.menu kbd { font-size: 10.5px; opacity: .8; }
.menu hr { border: 0; height: 1px; background: var(--line); margin: 5px 4px; }
.mhead { padding: 8px 10px 3px; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }

/* ---------- Vue en grille ---------- */
#grid { position: absolute; inset: 0; z-index: 8; display: flex; flex-direction: column; background: var(--desk); animation: rise .25s ease-out; }
.gridbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 14px 20px; background: var(--panel); border-bottom: 1px solid var(--line); }
.gridbar b { font-weight: 600; min-width: 150px; }
.gridacts { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; }
.gridacts .btn { height: 34px; padding: 0 12px; font-size: 13px; }
.gridacts .btn.icon { width: 34px; padding: 0; }
.gridtip { margin: 10px 20px 0; font-size: 12.5px; color: var(--muted); }
#gridcards { flex: 1; overflow: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 18px; padding: 18px 20px 40px; align-content: start; }
.gcard { position: relative; padding: 10px 10px 8px; border-radius: 14px; cursor: pointer; transition: background .15s, box-shadow .15s; }
.gcard:hover { background: var(--panel-2); }
.gcard.on { background: var(--sel-soft); box-shadow: 0 0 0 2px var(--sel); }
.gcard canvas { display: block; width: 100%; background: #fff; border-radius: 2px; box-shadow: 0 1px 2px #0002, 0 6px 16px -6px #3a2f1a55; }
.gcard span { display: block; margin-top: 7px; text-align: center; font-size: 12.5px; color: var(--muted); }
.gcard.before { box-shadow: inset 4px 0 0 var(--accent); }
.gcard.after { box-shadow: inset -4px 0 0 var(--accent); }

/* ---------- Tampons ---------- */
.side-sec { margin-top: 8px; padding-top: 14px; border-top: 1px solid var(--line); }
.side-sec h2 { font: 400 19px/1.1 var(--display); margin: 0; }
.side-sec p { margin: 4px 0 0; font-size: 12.5px; color: var(--muted); }
#stampnew { height: 40px; border: 1.5px dashed var(--line-2); background: transparent; font-size: 13px; }
#stampnew:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
#stamplist { display: flex; flex-direction: column; gap: 8px; }
.stampcard { display: grid; place-items: center; min-height: 58px; }
.stampcard img { height: 48px; }
.seal-prev { display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 3px 9px; border: 2px solid;
             font: 700 13px/1.3 'Plume arial', Arial, sans-serif; letter-spacing: .02em; transform: rotate(-4deg); }
.seal-prev.frame-round { border-radius: 9px; }
.seal-prev.frame-double { border-style: double; border-width: 4px; }
.stamppreview { display: grid; place-items: center; min-height: 80px; margin: 14px 26px 0; border-radius: 14px; background: #fff; border: 1px solid var(--line); }
.stamppreview .seal-prev { font-size: 18px; padding: 5px 14px; }

/* ---------- Fenêtres des outils ---------- */
.txt.small { width: 70px; flex: none; }
.area { display: block; width: 100%; height: 46dvh; margin-top: 6px; padding: 12px; border: 1px solid var(--line-2); border-radius: 12px; background: var(--panel-2);
        font: 13px/1.5 ui-monospace, Consolas, monospace; color: var(--ink); resize: vertical; outline: none; }
.area.short { height: 130px; font-family: var(--ui); font-size: 14px; }
#cmpout { margin: 14px 26px 0; max-height: 55dvh; overflow: auto; }
.cmpsum { margin: 0 0 10px; font-weight: 600; }
.cmpsum .muted { display: block; font-weight: 400; margin-top: 3px; }
.cmprow { border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px; background: var(--panel); }
.cmprow summary { padding: 10px 14px; cursor: pointer; display: flex; gap: 10px; align-items: baseline; }
.cmprow summary span { color: var(--accent); font-size: 13px; }
.cmprow.same summary span { color: var(--muted); }
.cmpbody { display: flex; gap: 14px; padding: 0 14px 14px; flex-wrap: wrap; align-items: flex-start; }
.cmpbody canvas { width: 260px; border-radius: 6px; box-shadow: 0 1px 3px #0003; }
.diff { flex: 1; min-width: 240px; margin: 0; padding: 10px; border-radius: 10px; background: var(--panel-2); font: 12px/1.5 ui-monospace, Consolas, monospace; white-space: pre-wrap; max-height: 320px; overflow: auto; }
.diff .del { color: #c62828; }
.diff .ins { color: #2e7d32; }

/* ---------- Visite guidée ---------- */
#tour { position: fixed; inset: 0; z-index: 70; }
.tour-hole { position: fixed; border-radius: 14px; box-shadow: 0 0 0 9999px #0d1018b0; transition: all .3s cubic-bezier(.2,.8,.2,1); pointer-events: none; }
.tour-tip { position: fixed; padding: 18px 18px 14px; border-radius: 16px; background: var(--panel); box-shadow: 0 20px 50px -16px #000a; transition: left .3s, top .3s; }
.tour-tip p { margin: 0 0 14px; font-size: 14.5px; line-height: 1.5; }
.tour-foot { display: flex; align-items: center; gap: 8px; }
.tour-foot span { margin-right: auto; font-size: 12px; color: var(--muted); }
@media (max-width: 640px) { #themebtn, #settingsbtn ~ #help { display: none; } .gridtip { display: none; } }
/* en-tête plus étroit : ces boutons restent accessibles depuis « Plus d'outils » et « Réglages » */
@media (max-width: 1180px) { #findbtn, #decobtn, #themebtn, #help, .brand small { display: none; } }

/* ---------- Rature : barre d'outils sur petits écrans, écrans tactiles, signatures montrées ---------- */
@media (pointer: coarse) { #tools > button, #tools .tgroup > button { height: 42px; } }
@media (max-width: 860px) {
  #desk { --mx: 70px; }
  #tools { width: auto; }
  #tools > button, #tools .tgroup > button { width: 42px; padding: 0; justify-content: center; }
  #tools > button > span, #tools .tgroup > button > span { display: none; }
  #tools button:hover::after { transition-delay: 0s; }
}
@media (max-width: 640px) { #tools > button, #tools .tgroup > button { width: 38px; } }
.side.right.flash { animation: flash 1.2s ease-out; }
@keyframes flash { 0%, 60% { box-shadow: inset 0 0 0 3px var(--accent); } }
@media (max-width: 640px) {
  #histbtn { display: none; } .brand svg { width: 26px; height: 26px; }
  header { gap: 4px; } .actions { gap: 3px; } header .btn { height: 36px; padding: 0 9px; } header .btn.icon { width: 34px; padding: 0; }
}
@media (max-width: 1180px) { body:not(.loaded) #desk { --mx: 10px; } }
.guides { margin: 0; font-size: 13.5px; color: var(--muted); }
.guides a { color: var(--ink-2); }
html[lang=en] .guides { display: none; } /* guides en français seulement pour l'instant */
.en-wait header, .en-wait #empty { visibility: hidden; } /* visiteur anglophone : rien n'apparaît avant la traduction (voir index.html) */
