/* Outils PDF — pdf.snap-shoot.fr (feuille de style commune) */
:root {
  --bg: #f6f5f2; --surface: #ffffff; --surface-2: #efede8; --text: #1d1c1a; --muted: #5d5a54;
  --border: #d6d2ca; --accent: #1f5fbf; --accent-text: #ffffff; --accent-soft: #e3ecfa;
  --ok: #1d7a3e; --err: #b3261e; --err-soft: #fbe9e7; --warn-soft: #fdf3dc; --focus: #f0a500;
  --radius: 12px; --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 14px rgba(0,0,0,.06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151515; --surface: #1f1f1f; --surface-2: #2a2a2a; --text: #ecebe8; --muted: #b0ada6;
    --border: #3b3b3b; --accent: #7fb0ff; --accent-text: #0d1b33; --accent-soft: #1d2b44;
    --ok: #6fd08f; --err: #ff8a80; --err-soft: #3a1d1b; --warn-soft: #3a3016; --focus: #ffc94d;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 14px rgba(0,0,0,.3);
  }
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
header.top { padding: 22px 0 8px; }
.back { display: inline-block; margin-bottom: 10px; font-size: .95rem; text-decoration: none; padding: 4px 0; }
.back:hover { text-decoration: underline; }
h1 { font-size: clamp(1.6rem, 4vw, 2.2rem); margin: 0 0 4px; line-height: 1.2; }
h2 { font-size: 1.15rem; margin: 0 0 10px; }
.lead { margin: 0; color: var(--muted); }
.privacy {
  display: inline-flex; gap: 8px; align-items: center; margin: 14px 0 0;
  padding: 8px 12px; border-radius: 12px; background: var(--accent-soft); color: var(--text);
  font-weight: 600; font-size: .95rem;
}
.privacy svg { flex: none; color: var(--accent); }
main { padding: 16px 0 48px; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }

button, .btn {
  font: inherit; cursor: pointer; border-radius: 8px; padding: 9px 14px; min-height: 44px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
button:hover:not(:disabled) { border-color: var(--accent); }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
button.primary:hover:not(:disabled) { filter: brightness(1.08); }
button:disabled { opacity: .5; cursor: not-allowed; }
input[type=text], input[type=number], select {
  font: inherit; font-size: 16px; padding: 8px 10px; min-height: 44px; width: 100%;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text);
}
input[type=color] { width: 64px; height: 44px; padding: 2px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
input[type=range] { width: 100%; accent-color: var(--accent); }
input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--accent); }

/* Accueil : grille des outils */
.tool-grid { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.tool-card {
  display: flex; gap: 14px; align-items: flex-start; height: 100%; padding: 16px; text-decoration: none; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.tool-card:hover { border-color: var(--accent); }
.tool-card svg { flex: none; color: var(--accent); }
.tool-card strong { display: block; font-size: 1.05rem; margin-bottom: 2px; }
.tool-card span { color: var(--muted); font-size: .92rem; }
.note { margin-top: 28px; color: var(--muted); font-size: .92rem; }
.note h2 { color: var(--text); }
.note ul { margin: 0; padding-left: 20px; }

/* Zone de dépôt */
.drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  width: 100%; min-height: 220px; padding: 32px 16px; text-align: center;
  border: 2px dashed var(--border); border-radius: var(--radius); background: var(--surface);
  color: var(--text); box-shadow: var(--shadow);
}
.drop.small { min-height: 0; padding: 14px 16px; flex-direction: row; box-shadow: none; }
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop strong { font-size: 1.15rem; }
.drop.small strong { font-size: 1rem; }
.drop span { color: var(--muted); }
.drop svg { color: var(--accent); flex: none; }

/* Messages */
.status {
  margin: 16px 0; padding: 10px 14px; border-radius: 8px; border-left: 4px solid var(--accent);
  background: var(--surface); box-shadow: var(--shadow);
}
.status:empty { display: none; }
.status.error { border-left-color: var(--err); background: var(--err-soft); }
.status.ok { border-left-color: var(--ok); }
progress { display: block; width: 100%; height: 8px; margin: 0 0 16px; accent-color: var(--accent); }
.warning { margin: 0 0 14px; padding: 10px 14px; border-radius: 8px; background: var(--warn-soft); font-size: .95rem; }

/* Panneau d'options */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.panel + .panel, .panel + .list, .list + .panel { margin-top: 16px; }
.fileinfo { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; }
.fileinfo p { margin: 0; overflow-wrap: anywhere; }
.fileinfo .name { font-weight: 700; }
.tools { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); margin-top: 16px; }
.tools fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
.tools legend, .lbl { font-weight: 600; margin-bottom: 6px; display: block; padding: 0; }
.check { display: flex; gap: 10px; align-items: center; min-height: 44px; cursor: pointer; }
.inline { display: flex; gap: 12px; align-items: center; }
.inline output { min-width: 3.5em; font-variant-numeric: tabular-nums; }
.row { display: flex; flex-wrap: wrap; gap: 8px; }
.row > button { flex: 1 1 auto; }
.row > input { flex: 1 1 140px; width: auto; }
.row > input + button { flex: 0 0 auto; }
.row + .row { margin-top: 8px; }
.hint { margin: 6px 0 0; font-size: .88rem; color: var(--muted); }
.actions { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.actions .row button { flex: 1 1 200px; }
.result { margin-top: 12px; font-weight: 600; }

/* Grille des pages (découper, organiser) */
.pages { list-style: none; margin: 20px 0 0; padding: 0; display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
@media (max-width: 420px) { .pages { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } }
.card {
  display: flex; flex-direction: column; gap: 8px; padding: 10px; border-radius: var(--radius);
  background: var(--surface); border: 2px solid var(--border); box-shadow: var(--shadow);
}
.card.selected { border-color: var(--accent); background: var(--accent-soft); }
.card.deleted .pic { opacity: .25; }
.card.deleted { border-style: dashed; }
.card.drag-over, .fileitem.drag-over { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.card.dragging, .fileitem.dragging { opacity: .5; }
.card[draggable=true], .fileitem[draggable=true] { cursor: grab; }
.thumb { position: relative; display: block; cursor: pointer; border-radius: 6px; }
.thumb:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.pic {
  position: relative; display: flex; align-items: center; justify-content: center; width: 100%; aspect-ratio: 1 / 1.414;
  background: var(--surface-2); border-radius: 6px; overflow: hidden; color: var(--muted); font-size: .85rem; text-align: center;
}
.pic.square { aspect-ratio: 1 / 1; }
.pic img { display: block; width: 100%; height: 100%; object-fit: contain; }
.pic img.page { background: #fff; }
.pic.square img { width: auto; height: auto; max-width: 100%; max-height: 100%; }
.thumb input { position: absolute; top: 6px; left: 6px; width: 24px; height: 24px; margin: 0; cursor: pointer; }
.num {
  position: absolute; top: 6px; right: 6px; min-width: 28px; padding: 2px 8px; border-radius: 999px;
  background: rgba(0,0,0,.72); color: #fff; font-size: .85rem; font-weight: 700; text-align: center;
}
.del-label { position: absolute; left: 0; right: 0; bottom: 8px; text-align: center; font-weight: 700; color: var(--err); }
.fname { display: flex; align-items: center; gap: 4px; }
.fname input { min-width: 0; padding: 6px 8px; font-size: 16px; }
.fname span { color: var(--muted); font-size: .9rem; }
.card > button { width: 100%; padding: 6px 10px; }
.icons { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.icons button { min-height: 40px; padding: 4px 0; font-size: 1.05rem; line-height: 1; }
.icons button.danger:hover:not(:disabled) { border-color: var(--err); color: var(--err); }

/* Liste de fichiers (fusionner, images) */
.list { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 10px; }
.fileitem {
  display: grid; grid-template-columns: 56px 1fr auto; gap: 12px; align-items: center; padding: 10px;
  background: var(--surface); border: 2px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.fileitem .mini { width: 56px; height: 72px; border-radius: 4px; background: var(--surface-2); overflow: hidden; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: .7rem; }
.fileitem .mini img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.fileitem .meta { min-width: 0; }
.fileitem .meta strong { display: block; overflow-wrap: anywhere; }
.fileitem .meta span { color: var(--muted); font-size: .9rem; }
.fileitem .icons { grid-template-columns: repeat(3, 44px); }
.fileitem .pos { font-weight: 700; color: var(--muted); margin-right: 4px; }
@media (max-width: 480px) {
  .fileitem { grid-template-columns: 48px 1fr; }
  .fileitem .mini { width: 48px; height: 62px; }
  .fileitem .icons { grid-column: 1 / -1; grid-template-columns: repeat(3, 1fr); }
}

footer { padding: 24px 0 40px; color: var(--muted); font-size: .88rem; }
@media (max-width: 560px) {
  header.top { padding-top: 16px; }
  .panel { padding: 12px; }
  .drop.small { flex-direction: column; gap: 4px; }
}
@media (prefers-reduced-motion: no-preference) {
  .card, .drop, button, .tool-card, .fileitem { transition: border-color .15s, background-color .15s; }
  .pic img { transition: transform .2s; }
}
