/* pdftool.css — Editor de PDF (herramienta autocontenida).
   Estética Adobe Acrobat: acento rojo, superficie clara, barras densas.
   El acento vive SOLO en el scope de la herramienta (--pdft-*): no se tocan
   las variables globales de base.css, que son la paleta blueprint de E-scale. */

.pdftool-overlay {
  --pdft-red: #dc2626;
  --pdft-red-dark: #b91c1c;
  --pdft-red-soft: rgba(220, 38, 38, 0.08);
  --pdft-bar: #ffffff;
  --pdft-canvas-bg: #eceff3;
  --pdft-line: rgba(10, 10, 11, 0.12);
  --pdft-ink: #1a1a1c;
  --pdft-muted: #6a6a6e;

  position: fixed;
  inset: 0;
  z-index: 310;
  background: var(--pdft-canvas-bg);
  overflow: hidden;
  font-family: var(--brand-body-font, 'Inter Tight', system-ui, sans-serif);
  color: var(--pdft-ink);
}

.pdftool-overlay .pdft-shell {
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* Header estándar (ToolHeader) — mismo tratamiento que qrtool. */
.pdftool-overlay #pdft-header-host .tool-header { border-bottom: 1px solid var(--pdft-line); }
.pdftool-overlay #pdft-header-host #header-inner.tool-header-inner { justify-content: flex-end; }
.pdftool-overlay #pdft-header-host #btn-app-launcher { color: var(--pdft-ink); }
.pdftool-overlay #pdft-header-host #btn-app-launcher svg { color: inherit; }

/* ── Pestañas de modo (Editar / Unir) ───────────────────────────────────── */
.pdft-modes {
  display: flex;
  gap: 2px;
  padding: 0 14px;
  background: var(--pdft-bar);
  border-bottom: 1px solid var(--pdft-line);
}
.pdft-mode {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 11px 16px;
  border: none;
  background: none;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--pdft-muted);
  border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s;
}
.pdft-mode:hover { color: var(--pdft-ink); }
.pdft-mode.is-active { color: var(--pdft-red); border-bottom-color: var(--pdft-red); }
.pdft-mode i { width: 15px; height: 15px; }

/* ── Barra de herramientas ──────────────────────────────────────────────── */
.pdft-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 7px 12px;
  background: var(--pdft-bar);
  border-bottom: 1px solid var(--pdft-line);
  flex-shrink: 0;
}
.pdft-tb-sep {
  width: 1px;
  height: 22px;
  background: var(--pdft-line);
  margin: 0 6px;
}
.pdft-tb-spacer { flex: 1; }

.pdft-tb-btn {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: none;
  cursor: pointer;
  color: var(--pdft-ink);
  transition: background .15s, border-color .15s, color .15s;
}
.pdft-tb-btn:hover { background: rgba(10, 10, 11, 0.06); }
.pdft-tb-btn i { width: 17px; height: 17px; }
.pdft-tb-btn.is-active {
  background: var(--pdft-red-soft);
  border-color: rgba(220, 38, 38, 0.35);
  color: var(--pdft-red);
}
.pdft-tb-danger:hover { background: var(--pdft-red-soft); color: var(--pdft-red); }
.pdft-tb-open { color: var(--pdft-red); }
/* Deshacer/Rehacer sin nada que hacer: apagados y sin hover. */
.pdft-tb-btn:disabled { opacity: .3; cursor: default; pointer-events: none; }

/* Toggle de proporción bloqueada (imágenes) */
.pdft-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: 1px solid var(--pdft-line);
  border-radius: 6px;
  background: #fff;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--pdft-muted);
  cursor: pointer;
}
.pdft-toggle i { width: 13px; height: 13px; }
.pdft-toggle.is-on {
  background: var(--pdft-red-soft);
  border-color: rgba(220, 38, 38, .4);
  color: var(--pdft-red);
}

.pdft-zoom {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-right: 8px;
}
.pdft-zoom-val {
  min-width: 46px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--pdft-muted);
  font-family: var(--brand-mono-font, 'JetBrains Mono', monospace);
}

.pdft-download {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border: none;
  border-radius: 8px;
  background: var(--pdft-red);
  color: #fff;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s, transform .1s;
}
.pdft-download:hover { background: var(--pdft-red-dark); }
.pdft-download:active { transform: translateY(1px); }
.pdft-download i { width: 15px; height: 15px; }
.pdft-download.is-hot { box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.18); }
.pdft-download.is-busy { opacity: .6; pointer-events: none; }

/* ── Cuerpo: rail | lienzo | panel ──────────────────────────────────────── */
.pdft-body {
  flex: 1;
  display: flex;
  min-height: 0;
}

.pdft-rail {
  width: 148px;
  flex-shrink: 0;
  background: var(--pdft-bar);
  border-right: 1px solid var(--pdft-line);
  overflow-y: auto;
}
.pdft-rail-head {
  padding: 10px 12px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--pdft-muted);
  font-family: var(--brand-mono-font, 'JetBrains Mono', monospace);
  border-bottom: 1px solid var(--pdft-line);
}
.pdft-thumbs { padding: 10px; display: grid; gap: 10px; }
.pdft-thumb {
  position: relative;
  border: 2px solid transparent;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .12);
}
.pdft-thumb canvas { display: block; width: 100%; height: auto; }
.pdft-thumb.is-active { border-color: var(--pdft-red); }
.pdft-thumb-n {
  position: absolute;
  left: 4px;
  bottom: 4px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(0, 0, 0, .65);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
}
.pdft-thumb-acts {
  position: absolute;
  top: 4px;
  right: 4px;
  display: flex;
  gap: 3px;
  opacity: 0;
  transition: opacity .15s;
}
.pdft-thumb:hover .pdft-thumb-acts { opacity: 1; }
.pdft-thumb-acts button {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 5px;
  background: rgba(255, 255, 255, .95);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
  cursor: pointer;
  color: var(--pdft-ink);
}
.pdft-thumb-acts button:hover { background: var(--pdft-red); color: #fff; }
.pdft-thumb-acts i { width: 12px; height: 12px; }

.pdft-canvas-wrap {
  flex: 1;
  min-width: 0;
  overflow: auto;
  padding: 24px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}
.pdft-canvas-wrap[data-tool="text"],
.pdft-canvas-wrap[data-tool="shape"],
.pdft-canvas-wrap[data-tool="redact"] { cursor: crosshair; }
.pdft-canvas-wrap[data-tool="draw"] { cursor: crosshair; }

.pdft-page {
  position: relative;
  background: #fff;
  box-shadow: 0 4px 20px rgba(0, 0, 0, .16);
  flex-shrink: 0;
}
.pdft-page canvas { display: block; }
/* La capa de elementos NO usa inset:0: mantiene el tamaño del papel sin girar
   (lo fija el render) y se rota por CSS sobre el lienzo, que ya se pinta
   girado. Con 90/270 la capa es más alta que ancha respecto a su contenedor,
   por eso el origen de la transformación es la esquina, no el centro. */
.pdft-layer { position: absolute; left: 0; top: 0; transform-origin: 0 0; }

/* ── Elementos editables ────────────────────────────────────────────────── */
.pdft-item { position: absolute; box-sizing: border-box; }
.pdft-item.is-selected { outline: 1.5px dashed var(--pdft-red); outline-offset: 1px; }
.pdft-item svg { width: 100%; height: 100%; display: block; overflow: visible; }
.pdft-image img { width: 100%; height: 100%; object-fit: fill; display: block; }
.pdft-redact { border-radius: 1px; }

.pdft-text { display: flex; align-items: flex-start; }
.pdft-text-body {
  width: 100%;
  outline: none;
  line-height: inherit;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-break: normal;
  cursor: text;
  min-height: 1em;
  user-select: text;
}
.pdft-text-body:focus-visible { outline: 1px solid var(--pdft-red); }
.pdft-text:has(.is-editing) .pdft-h { display: none; }
.pdft-text-body.is-editing {
  background: rgba(220, 38, 38, .06);
  box-shadow: 0 0 0 1px var(--pdft-red);
}

/* Parche que oculta el texto original ya reescrito. El original vive pintado
   en el canvas, así que sin esto se verían los dos a la vez. No debe capturar
   el ratón: el cuadro editable va justo encima. */
.pdft-cover {
  position: absolute;
  pointer-events: none;
}

/* Texto ORIGINAL del PDF: zona invisible que solo se insinúa al pasar por
   encima, para que se vea que ese texto es editable con doble clic. */
.pdft-src-text {
  position: absolute;
  cursor: text;
  border-radius: 2px;
  transition: background .12s, box-shadow .12s;
}
.pdft-src-text:hover,
.pdft-src-text:focus-visible {
  background: rgba(220, 38, 38, .09);
  box-shadow: 0 0 0 1px rgba(220, 38, 38, .35);
}
.pdft-canvas-wrap:is([data-tool="draw"], [data-tool="shape"], [data-tool="redact"], [data-tool="image"]) .pdft-src-text { pointer-events: none; }

/* Imagen ORIGINAL del PDF: zona invisible que se insinúa al pasar por
   encima, para que se vea que se puede convertir en movible con un clic. */
.pdft-src-image {
  position: absolute;
  cursor: pointer;
  border-radius: 2px;
  transition: background .12s, box-shadow .12s;
}
.pdft-src-image:hover,
.pdft-src-image:focus-visible {
  background: rgba(220, 38, 38, .07);
  box-shadow: 0 0 0 1px rgba(220, 38, 38, .35), inset 0 0 0 1px rgba(255, 255, 255, .5);
}
.pdft-canvas-wrap:is([data-tool="draw"], [data-tool="shape"], [data-tool="redact"], [data-tool="image"]) .pdft-src-image { pointer-events: none; }

.pdft-h {
  position: absolute;
  width: 9px;
  height: 9px;
  background: #fff;
  border: 1.5px solid var(--pdft-red);
  border-radius: 2px;
}
.pdft-h-nw { top: -5px; left: -5px; cursor: nwse-resize; }
.pdft-h-ne { top: -5px; right: -5px; cursor: nesw-resize; }
.pdft-h-sw { bottom: -5px; left: -5px; cursor: nesw-resize; }
.pdft-h-se { bottom: -5px; right: -5px; cursor: nwse-resize; }
/* Con la capa girada 90/270 el tirador "nw" queda visualmente arriba a la
   derecha: el cursor de redimensión se cruza para que apunte adonde arrastra. */
.pdft-layer[data-rot="90"] .pdft-h-nw,
.pdft-layer[data-rot="90"] .pdft-h-se,
.pdft-layer[data-rot="270"] .pdft-h-nw,
.pdft-layer[data-rot="270"] .pdft-h-se { cursor: nesw-resize; }
.pdft-layer[data-rot="90"] .pdft-h-ne,
.pdft-layer[data-rot="90"] .pdft-h-sw,
.pdft-layer[data-rot="270"] .pdft-h-ne,
.pdft-layer[data-rot="270"] .pdft-h-sw { cursor: nwse-resize; }

/* ── Panel derecho ──────────────────────────────────────────────────────── */
.pdft-side {
  width: 250px;
  flex-shrink: 0;
  background: var(--pdft-bar);
  border-left: 1px solid var(--pdft-line);
  overflow-y: auto;
  padding-bottom: 20px;
}
.pdft-side-sec { border-bottom: 1px solid var(--pdft-line); padding: 12px 14px 16px; }
.pdft-side-head {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--pdft-muted);
  font-family: var(--brand-mono-font, 'JetBrains Mono', monospace);
  margin-bottom: 12px;
}
.pdft-f {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 12.5px;
  color: var(--pdft-ink);
}
.pdft-f > span { color: var(--pdft-muted); flex-shrink: 0; }
.pdft-f select,
.pdft-f input[type="number"] {
  width: 110px;
  padding: 5px 8px;
  border: 1px solid var(--pdft-line);
  border-radius: 6px;
  font: inherit;
  font-size: 12.5px;
  background: #fff;
  color: var(--pdft-ink);
  outline: none;
}
.pdft-f select:focus,
.pdft-f input:focus { border-color: var(--pdft-red); }
.pdft-f input[type="color"] {
  width: 42px;
  height: 26px;
  padding: 2px;
  border: 1px solid var(--pdft-line);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
}
.pdft-f input[type="range"] { width: 110px; accent-color: var(--pdft-red); }

.pdft-seg { display: inline-flex; gap: 2px; }
.pdft-seg button {
  display: grid;
  place-items: center;
  width: 30px;
  height: 26px;
  border: 1px solid var(--pdft-line);
  background: #fff;
  cursor: pointer;
  color: var(--pdft-ink);
}
.pdft-seg button:first-child { border-radius: 6px 0 0 6px; }
.pdft-seg button:last-child { border-radius: 0 6px 6px 0; }
.pdft-seg button.is-active {
  background: var(--pdft-red-soft);
  border-color: rgba(220, 38, 38, .4);
  color: var(--pdft-red);
}
.pdft-seg i { width: 13px; height: 13px; }

.pdft-side-act {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  margin-bottom: 5px;
  border: 1px solid var(--pdft-line);
  border-radius: 7px;
  background: #fff;
  font: inherit;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--pdft-ink);
  cursor: pointer;
  text-align: left;
  transition: border-color .15s, background .15s;
}
.pdft-side-act:hover { border-color: var(--pdft-red); background: var(--pdft-red-soft); }
.pdft-side-act i { width: 14px; height: 14px; color: var(--pdft-red); }

/* Firma manuscrita o escrita, colocada con los controles de imagen del PDF. */
.pdft-signature-dialog {
  width: min(600px, calc(100vw - 48px));
  max-height: calc(100dvh - 48px);
  overflow: auto;
  box-sizing: border-box;
  padding: 24px;
  border: 1px solid var(--pdft-line);
  border-radius: 12px;
  background: var(--pdft-bar);
  color: var(--pdft-ink);
  font: inherit;
  box-shadow: 0 16px 60px rgba(0, 0, 0, .2);
}
.pdft-signature-dialog::backdrop { background: rgba(0, 0, 0, .4); }
.pdft-signature-dialog h2 { margin: 0 0 8px; font-size: 22px; }
.pdft-signature-dialog p { margin: 0 0 18px; color: var(--pdft-muted); font-size: 13px; line-height: 1.5; }
.pdft-signature-modes, .pdft-signature-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.pdft-signature-actions { margin-top: 16px; }
.pdft-signature-actions > span { flex: 1; }
.pdft-signature-dialog button {
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid var(--pdft-line);
  border-radius: 7px;
  background: var(--pdft-bar);
  color: var(--pdft-ink);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.pdft-signature-dialog button:hover:not(:disabled),
.pdft-signature-dialog button[aria-pressed="true"] { border-color: var(--pdft-red); background: var(--pdft-red-soft); }
.pdft-signature-dialog button:active:not(:disabled) { background: var(--pdft-red-soft); }
.pdft-signature-dialog button:focus-visible,
.pdft-signature-dialog input:focus-visible { outline: 2px solid var(--pdft-red); outline-offset: 2px; }
.pdft-signature-dialog [data-insert] { color: #fff; background: var(--pdft-red); border-color: var(--pdft-red); }
.pdft-signature-dialog [data-insert]:hover:not(:disabled) { background: var(--pdft-red-dark); }
.pdft-signature-dialog button:disabled { opacity: .45; cursor: default; }
.pdft-signature-dialog canvas {
  display: block;
  box-sizing: border-box;
  width: 100%;
  height: auto;
  margin-top: 16px;
  border: 1px dashed var(--pdft-muted);
  border-radius: 7px;
  background: #fff;
  cursor: crosshair;
  touch-action: none;
}
.pdft-signature-dialog canvas.is-typed { cursor: default; }
.pdft-signature-name { display: grid; gap: 6px; margin-top: 16px; font-size: 13px; }
.pdft-signature-name[hidden] { display: none; }
.pdft-signature-name input { min-width: 0; padding: 9px 10px; border: 1px solid var(--pdft-line); border-radius: 7px; font: inherit; }

.pdft-side-del {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  padding: 8px 10px;
  margin-top: 4px;
  border: 1px solid rgba(220, 38, 38, .35);
  border-radius: 7px;
  background: var(--pdft-red-soft);
  color: var(--pdft-red);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}
.pdft-side-del:hover { background: var(--pdft-red); color: #fff; }
.pdft-side-del i { width: 14px; height: 14px; }

/* Aviso dentro del panel: el texto reescrito no borra el original del PDF. */
.pdft-side-warn {
  display: flex;
  gap: 7px;
  align-items: flex-start;
  margin: 0 0 12px;
  padding: 9px 10px;
  border: 1px solid rgba(245, 158, 11, .38);
  border-radius: 7px;
  background: rgba(245, 158, 11, .1);
  font-size: 11.5px;
  line-height: 1.45;
  color: #92400e;
}
.pdft-side-warn i { width: 14px; height: 14px; flex-shrink: 0; margin-top: 1px; }

.pdft-side-note {
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--pdft-muted);
  margin: 8px 0 0;
}

/* ── Estado vacío / dropzone ────────────────────────────────────────────── */
.pdft-empty {
  max-width: 460px;
  margin: 8vh auto 0;
  text-align: center;
  padding: 40px 32px;
  border: 2px dashed var(--pdft-line);
  border-radius: 16px;
  background: #fff;
  transition: border-color .15s, background .15s;
}
.pdft-empty.is-over { border-color: var(--pdft-red); background: var(--pdft-red-soft); }
.pdft-empty-icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  border-radius: 14px;
  background: var(--pdft-red-soft);
  color: var(--pdft-red);
}
.pdft-empty-icon i { width: 26px; height: 26px; }
.pdft-empty h2 {
  font-family: var(--brand-display-font, 'Fraunces', serif);
  font-size: 21px;
  font-weight: 600;
  margin: 0 0 8px;
}
.pdft-empty p { font-size: 13.5px; line-height: 1.6; color: var(--pdft-muted); margin: 0 0 20px; }
.pdft-empty-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 22px;
  border: none;
  border-radius: 9px;
  background: var(--pdft-red);
  color: #fff;
  font: inherit;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
}
.pdft-empty-btn:hover { background: var(--pdft-red-dark); }
.pdft-empty-btn i { width: 15px; height: 15px; }

/* ── Modo Unir PDF ──────────────────────────────────────────────────────── */
.pdft-merge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 18px;
  width: 100%;
  align-content: start;
}
.pdft-mcard {
  position: relative;
  background: #fff;
  border: 1px solid var(--pdft-line);
  border-radius: 10px;
  padding: 12px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .07);
}
.pdft-mcard-canvas {
  height: 190px;
  display: grid;
  place-items: center;
  overflow: hidden;
  margin-bottom: 10px;
}
.pdft-mcard-canvas canvas {
  max-width: 100%;
  max-height: 100%;
  box-shadow: 0 1px 6px rgba(0, 0, 0, .14);
}
.pdft-mcard-name {
  font-size: 12.5px;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pdft-mcard-meta {
  font-size: 11px;
  color: var(--pdft-muted);
  text-align: center;
  margin-top: 3px;
  font-family: var(--brand-mono-font, 'JetBrains Mono', monospace);
}
.pdft-mcard-x {
  position: absolute;
  top: 6px;
  right: 6px;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, .9);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .2);
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s;
  color: var(--pdft-ink);
}
.pdft-mcard:hover .pdft-mcard-x { opacity: 1; }
.pdft-mcard-x:hover { background: var(--pdft-red); color: #fff; }
.pdft-mcard-x i { width: 13px; height: 13px; }

.pdft-mcard-add {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 250px;
  border: 2px dashed var(--pdft-line);
  background: transparent;
  cursor: pointer;
  color: var(--pdft-muted);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  box-shadow: none;
}
.pdft-mcard-add:hover { border-color: var(--pdft-red); color: var(--pdft-red); }
.pdft-mcard-add i { width: 24px; height: 24px; }

/* Lista ordenable */
.pdft-order { display: grid; gap: 4px; margin-bottom: 14px; }
.pdft-order-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border: 1px solid var(--pdft-line);
  border-radius: 7px;
  background: #fff;
  cursor: grab;
  font-size: 12px;
}
.pdft-order-row.is-dragging { opacity: .45; }
.pdft-order-row.is-target { border-color: var(--pdft-red); background: var(--pdft-red-soft); }
.pdft-order-n {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  border-radius: 5px;
  background: var(--pdft-red);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}
.pdft-order-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pdft-order-grip { width: 13px; height: 13px; color: var(--pdft-muted); flex-shrink: 0; }

.pdft-merge-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px;
  margin-bottom: 8px;
  border: none;
  border-radius: 9px;
  background: var(--pdft-red);
  color: #fff;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.pdft-merge-cta:hover { background: var(--pdft-red-dark); }
.pdft-merge-cta.is-busy { opacity: .6; pointer-events: none; }
.pdft-merge-cta i { width: 15px; height: 15px; }

/* Preview del resultado */
.pdft-merge-result { width: 100%; }
.pdft-merge-result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.pdft-merge-result-head h3 {
  font-family: var(--brand-display-font, 'Fraunces', serif);
  font-size: 18px;
  font-weight: 600;
  margin: 0;
}
.pdft-merge-result-head p { font-size: 12.5px; color: var(--pdft-muted); margin: 2px 0 0; }
.pdft-ghost {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border: 1px solid var(--pdft-line);
  border-radius: 8px;
  background: #fff;
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  color: var(--pdft-ink);
}
.pdft-ghost:hover { border-color: var(--pdft-red); color: var(--pdft-red); }
.pdft-ghost i { width: 14px; height: 14px; }

.pdft-merge-pages {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 16px;
}
.pdft-mpage { position: relative; text-align: center; }
.pdft-mpage canvas {
  max-width: 100%;
  height: auto;
  background: #fff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .14);
}
.pdft-mpage span {
  display: block;
  margin-top: 5px;
  font-size: 11px;
  color: var(--pdft-muted);
  font-family: var(--brand-mono-font, 'JetBrains Mono', monospace);
}

/* En modo Unir y Separar no hay rail ni zoom de página: no se edita una
   página, se organizan documentos. */
.pdft-shell[data-mode="merge"] .pdft-rail,
.pdft-shell[data-mode="merge"] .pdft-zoom,
.pdft-shell[data-mode="merge"] .pdft-tool,
.pdft-shell[data-mode="merge"] #pdft-undo,
.pdft-shell[data-mode="merge"] #pdft-redo,
.pdft-shell[data-mode="merge"] #pdft-delete,
.pdft-shell[data-mode="merge"] #pdft-rot-l,
.pdft-shell[data-mode="merge"] #pdft-rot-r,
.pdft-shell[data-mode="merge"] .pdft-tb-sep,
.pdft-shell[data-mode="split"] .pdft-rail,
.pdft-shell[data-mode="split"] .pdft-zoom,
.pdft-shell[data-mode="split"] .pdft-tool,
.pdft-shell[data-mode="split"] #pdft-undo,
.pdft-shell[data-mode="split"] #pdft-redo,
.pdft-shell[data-mode="split"] #pdft-delete,
.pdft-shell[data-mode="split"] #pdft-rot-l,
.pdft-shell[data-mode="split"] #pdft-rot-r,
.pdft-shell[data-mode="split"] .pdft-tb-sep { display: none; }

/* Unir y Separar pintan rejillas, no una pagina centrada: el wrap deja de ser
   flex para que el host tenga ancho DEFINIDO. Sin el, `auto-fill` no sabe
   cuanto espacio hay y colapsa a una sola columna. */
.pdft-shell[data-mode="merge"] .pdft-canvas-wrap,
.pdft-shell[data-mode="split"] .pdft-canvas-wrap { display: block; }

/* ── Separar PDF ────────────────────────────────────────────────────────── */
.pdft-split { width: 100%; }
.pdft-split-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}
.pdft-split-head h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  overflow-wrap: anywhere;
}
.pdft-split-head p { font-size: 12.5px; color: var(--pdft-muted); margin: 2px 0 0; }

.pdft-split-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(126px, 1fr));
  gap: 14px;
}
/* Cada página lleva el color de SU parte: con el grid partido en varias filas
   el agrupamiento no se puede leer por posición, solo por color y número. */
.pdft-spage {
  position: relative;
  padding: 6px;
  border: 2px solid var(--parte, var(--pdft-red));
  border-radius: 8px;
  background: #fff;
  text-align: center;
}
.pdft-spage.is-off { opacity: .4; filter: grayscale(1); }
.pdft-spage-canvas {
  display: grid;
  place-items: center;
  min-height: 90px;
  overflow: hidden;
}
.pdft-spage-canvas canvas { max-width: 100%; height: auto; display: block; }
.pdft-spage-part {
  position: absolute;
  top: -9px;
  left: 8px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--parte, var(--pdft-red));
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  font-family: var(--brand-mono-font, 'JetBrains Mono', monospace);
}
.pdft-spage-n {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  color: var(--pdft-muted);
  font-family: var(--brand-mono-font, 'JetBrains Mono', monospace);
}
/* La tijera cuelga del borde derecho: "cortar DESPUÉS de esta página". */
.pdft-cut {
  position: absolute;
  top: 50%;
  right: -13px;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 1px solid var(--pdft-line);
  border-radius: 999px;
  background: #fff;
  color: var(--pdft-muted);
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s, background .15s, color .15s;
  z-index: 2;
}
.pdft-spage:hover .pdft-cut,
.pdft-cut:focus-visible,
.pdft-cut.is-on { opacity: 1; }
.pdft-cut:hover { border-color: var(--pdft-red); color: var(--pdft-red); }
.pdft-cut.is-on { background: var(--pdft-red); border-color: var(--pdft-red); color: #fff; }
.pdft-cut i { width: 13px; height: 13px; }

.pdft-split-every {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 8px 0;
  font-size: 12.5px;
  color: var(--pdft-muted);
}
.pdft-split-every input {
  width: 52px;
  padding: 5px 7px;
  border: 1px solid var(--pdft-line);
  border-radius: 6px;
  font: inherit;
  font-size: 12.5px;
  color: var(--pdft-ink);
}
.pdft-split-every .pdft-ghost { padding: 5px 10px; font-size: 12px; }

.pdft-parts { display: grid; gap: 5px; margin-bottom: 12px; }
.pdft-part {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 8px;
  border: 1px solid var(--pdft-line);
  border-left: 3px solid var(--parte, var(--pdft-red));
  border-radius: 6px;
  background: #fff;
}
.pdft-part.is-off { opacity: .5; }
.pdft-part-main {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  cursor: pointer;
}
.pdft-part-main input { flex-shrink: 0; accent-color: var(--pdft-red); }
.pdft-part-main span { min-width: 0; }
.pdft-part-main b {
  display: block;
  font-size: 12px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pdft-part-main em {
  display: block;
  font-style: normal;
  font-size: 11px;
  color: var(--pdft-muted);
}
.pdft-part-dl {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  border: 1px solid var(--pdft-line);
  border-radius: 6px;
  background: #fff;
  color: var(--pdft-muted);
  cursor: pointer;
}
.pdft-part-dl:hover { border-color: var(--pdft-red); color: var(--pdft-red); }
.pdft-part-dl i { width: 13px; height: 13px; }

.pdft-merge-cta[disabled] { opacity: .45; pointer-events: none; }

/* ── Toast ──────────────────────────────────────────────────────────────── */
.pdft-toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  z-index: 340;
  padding: 11px 20px;
  border-radius: 10px;
  background: var(--pdft-ink);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .22);
  max-width: 80vw;
}
.pdft-toast.is-ok { background: #15803d; }
.pdft-toast.is-err { background: var(--pdft-red-dark); }
.pdft-toast[hidden] { display: none; }

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .pdftool-overlay .pdft-rail { width: 110px; }
  .pdftool-overlay .pdft-side { width: 210px; }
}
@media (max-width: 820px) {
  .pdftool-overlay .pdft-rail { display: none; }
  .pdftool-overlay .pdft-side { width: 190px; }
  .pdftool-overlay .pdft-canvas-wrap { padding: 14px; }
}
