/*
 * ScannerFree: blanco limpio, gris grafito y un rojo fuerte para lo importante (como el lápiz rojo
 * que marca un papel). De noche, gris carbón con el mismo rojo.
 */
@font-face {
    font-family: "Bricolage";
    src: url("fuentes/bricolage.woff2") format("woff2-variations");
    font-weight: 200 800;
    font-stretch: 75% 100%;
    font-display: swap;
}

:root {
    --fondo: #f4f4f6;
    --superficie: #ffffff;
    --tinta: #1c1c21;
    --grafito: #5e6068;
    --linea: #e2e2e7;
    --rojo: #d7262e;
    --rojo-hondo: #b01b22;
    --sobre-rojo: #ffffff;
    --rojo-suave: #fde9e9;
    --rojo-texto: #c01f27;
    --mesa: #ececf0;
    --renglon: #d3d4da;
    --peligro: #c01f27;
    --sombra: 0 1px 2px rgba(20, 20, 30, .06), 0 8px 24px -12px rgba(20, 20, 30, .18);
    --sombra-hoja: 0 1px 1px rgba(20, 20, 30, .08), 0 6px 18px -6px rgba(20, 20, 30, .25);
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --fondo: #141416;
        --superficie: #1f1f23;
        --tinta: #f1f1f4;
        --grafito: #a5a7b0;
        --linea: #2f3036;
        --rojo: #e5353c;
        --rojo-hondo: #ff5a60;
        --sobre-rojo: #ffffff;
        --rojo-suave: #3a1c1e;
        --rojo-texto: #ff7d82;
        --mesa: #2a2a2f;
        --renglon: #c5c7cf;
        --peligro: #ff7d82;
        --sombra: 0 1px 2px rgba(0, 0, 0, .4);
        --sombra-hoja: 0 1px 1px rgba(0, 0, 0, .3), 0 8px 22px -8px rgba(0, 0, 0, .6);
        color-scheme: dark;
    }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; }
body {
    background: var(--fondo);
    color: var(--tinta);
    font: 17px/1.5 "Bricolage", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-optical-sizing: auto;
    min-height: 100vh;
    -webkit-tap-highlight-color: transparent;
}
body.con-acciones { padding-bottom: calc(140px + env(safe-area-inset-bottom)); }
button, input { font-family: inherit; }
:focus-visible { outline: 3px solid var(--rojo); outline-offset: 2px; border-radius: 6px; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; flex: none; }

h1, h2 { margin: 0 0 .5rem; letter-spacing: -.015em; }
h2 { font-size: 1.2rem; font-weight: 700; line-height: 1.25; }

/* ── Encabezado ── */
.barra {
    display: flex; align-items: center; gap: 6px;
    padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
    background: var(--superficie); border-bottom: 1px solid var(--linea);
    position: sticky; top: 0; z-index: 5;
}
.volver {
    border: 0; background: transparent; color: var(--tinta); width: 40px; height: 40px; margin-left: -10px;
    border-radius: 12px; display: grid; place-items: center; cursor: pointer;
}
.volver svg { width: 26px; height: 26px; stroke-width: 2.2; }
.volver:active { background: var(--mesa); }
.marca { display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: 1.2rem; letter-spacing: -.02em; font-stretch: 85%; color: inherit; text-decoration: none; }
.marca b { color: var(--rojo); font-weight: 800; }
.sello {
    margin-left: auto; display: inline-flex; align-items: center; gap: 5px;
    font-size: .78rem; font-weight: 600; color: var(--grafito); white-space: nowrap;
}
.sello svg { width: 17px; height: 17px; color: var(--rojo); }
@media (max-width: 360px) { .sello { display: none; } }

main { max-width: 760px; margin: 0 auto; padding: 16px; }

.titulo-vista { font-size: 1.75rem; font-weight: 800; font-stretch: 85%; letter-spacing: -.03em; line-height: 1.1; margin: 4px 0 6px; }
.titulo-seccion { font-size: 1.05rem; font-weight: 800; margin: 28px 0 12px; letter-spacing: -.01em; }
.encabezado-seccion { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.encabezado-seccion .titulo-seccion, .encabezado-seccion .titulo-vista { margin-bottom: 12px; }

/* ── Inicio: la tarjeta de escanear ── */
.escanear-grande {
    width: 100%; border: 0; cursor: pointer; text-align: left; color: var(--sobre-rojo);
    background: var(--rojo); border-radius: 26px; padding: 18px 18px 20px; position: relative; overflow: hidden;
    display: grid; grid-template-columns: 1fr 112px; grid-template-areas: "texto demo" "boton demo"; gap: 4px 10px; align-items: end;
    box-shadow: 0 14px 30px -14px rgba(215, 38, 46, .7);
}
.escanear-grande:active { transform: scale(.99); }
.escanear-texto { grid-area: texto; align-self: start; }
.escanear-texto b { display: block; font-size: 1.6rem; line-height: 1.05; font-weight: 800; font-stretch: 82%; letter-spacing: -.03em; }
.escanear-texto span { display: block; margin-top: 8px; font-size: .92rem; line-height: 1.35; opacity: .92; }
.escanear-boton {
    grid-area: boton; justify-self: start; margin-top: 14px; display: inline-flex; align-items: center; gap: 8px;
    background: #fff; color: #b01b22; font-weight: 800; padding: 10px 16px; border-radius: 999px; font-size: .98rem;
}
.demo { grid-area: demo; width: 132px; height: auto; margin: -10px -14px -16px 0; overflow: visible; stroke: none; }
.demo-papel { fill: #fff; filter: drop-shadow(0 8px 10px rgba(80, 0, 0, .35)); }
.demo-renglon { fill: #d9d9de; }
.demo-renglon.titulo { fill: #1c1c21; }
.demo-firma { fill: none; stroke: #d7262e; stroke-width: 2; }
.demo-barrido { fill: #d7262e; opacity: 0; }
.demo-esquinas path { fill: none; stroke: #fff; stroke-width: 7; stroke-linecap: round; stroke-linejoin: round; }
.demo-hoja { transform-box: view-box; transform-origin: 130px 110px; transform: rotate(-11deg) skewX(7deg) scale(.86); }
.demo-esquinas path { transform-box: view-box; transform-origin: 130px 110px; }

@media (prefers-reduced-motion: no-preference) {
    .demo-hoja { animation: enderezar 1s cubic-bezier(.2, .9, .25, 1.15) .9s forwards; }
    .demo-esquinas .e1 { animation: esquina1 .7s cubic-bezier(.3, 1.4, .5, 1) .3s backwards; }
    .demo-esquinas .e2 { animation: esquina2 .7s cubic-bezier(.3, 1.4, .5, 1) .4s backwards; }
    .demo-esquinas .e3 { animation: esquina3 .7s cubic-bezier(.3, 1.4, .5, 1) .5s backwards; }
    .demo-esquinas .e4 { animation: esquina4 .7s cubic-bezier(.3, 1.4, .5, 1) .6s backwards; }
    .demo-barrido { animation: barrer 1.1s ease-in-out 2s forwards; }
}
@media (prefers-reduced-motion: reduce) { .demo-hoja { transform: none; } }

@keyframes enderezar { to { transform: none; } }
@keyframes esquina1 { from { transform: translate(-26px, -26px); opacity: 0; } }
@keyframes esquina2 { from { transform: translate(26px, -26px); opacity: 0; } }
@keyframes esquina3 { from { transform: translate(26px, 26px); opacity: 0; } }
@keyframes esquina4 { from { transform: translate(-26px, 26px); opacity: 0; } }
@keyframes barrer {
    0% { opacity: .55; transform: translateY(0); }
    85% { opacity: .55; transform: translateY(150px); }
    100% { opacity: 0; transform: translateY(150px); }
}

/* ── Herramientas PDF ── */
.herramientas { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.herramienta {
    display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; cursor: pointer;
    padding: 14px 12px; border-radius: 18px; border: 1px solid var(--linea); background: var(--superficie); color: var(--tinta);
    box-shadow: var(--sombra);
}
.herramienta:active { transform: scale(.97); }
.herramienta .icono { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; margin-bottom: 10px; }
.herramienta .icono svg { width: 26px; height: 26px; }
.herramienta.unir .icono { background: var(--rojo); color: var(--sobre-rojo); }
.herramienta.eliminar .icono { background: var(--tinta); color: var(--superficie); }
.herramienta.fotos .icono { background: var(--rojo-suave); color: var(--rojo-texto); }
.herramienta b { font-size: .98rem; font-weight: 800; line-height: 1.15; letter-spacing: -.01em; }
.herramienta small { color: var(--grafito); font-size: .8rem; line-height: 1.3; }
@media (max-width: 360px) { .herramientas { grid-template-columns: 1fr; } .herramienta { flex-direction: row; align-items: center; gap: 12px; } .herramienta .icono { margin: 0; } }

/* ── Documentos guardados ── */
.documentos { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.documento {
    width: 100%; display: flex; align-items: center; gap: 12px; padding: 10px 12px; cursor: pointer; text-align: left;
    background: var(--superficie); border: 1px solid var(--linea); border-radius: 16px; color: var(--tinta);
}
.documento:active { background: var(--mesa); }
.documento img, .documento .sin-mini {
    width: 44px; height: 56px; object-fit: cover; object-position: top; border-radius: 4px; flex: none;
    background: #fff; box-shadow: 0 0 0 1px var(--linea);
}
.documento .sin-mini { display: grid; place-items: center; color: var(--rojo); }
.documento .datos { flex: 1; min-width: 0; }
.documento b { display: block; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.documento small { color: var(--grafito); font-size: .84rem; }
.documento .etiqueta-pdf { font-size: .7rem; font-weight: 800; color: var(--rojo-texto); background: var(--rojo-suave); padding: 2px 7px; border-radius: 6px; }
.sin-documentos { color: var(--grafito); font-size: .92rem; background: var(--superficie); border: 1px dashed var(--linea); border-radius: 16px; padding: 16px; margin: 0; text-align: center; }

/* ── Cómo funciona (inicio) y pasos (al escanear) ── */
/* ── Cómo funciona ──
 * En escalera: cada paso va abajo del anterior y un escalón más a la derecha. Entre paso y paso, una línea
 * ondulada que baja del centro de un círculo al centro del siguiente. app.js (armarGuia) pone las
 * líneas y le dice a cada paso en qué escalón está (--i) y cuántos son (--n).
 * --escalon: cuánto se corre a la derecha cada paso (más grande = escalera más inclinada).
 * --circulo: tamaño de los círculos.
 */
.guia { --escalon: 12%; --circulo: 52px; list-style: none; margin: 0; padding: 0; }
.guia .paso {
    display: flex; align-items: center; gap: 14px;
    margin-left: calc(var(--i, 0) * var(--escalon));
    width: calc(100% - (var(--n, 1) - 1) * var(--escalon));
}
.guia .paso-icono {
    flex: none; width: var(--circulo); height: var(--circulo); border-radius: 50%; display: grid; place-items: center;
    background: var(--superficie); color: var(--rojo); box-shadow: inset 0 0 0 2px var(--rojo), var(--sombra);
}
.guia .paso-icono svg { width: 24px; height: 24px; }
.guia .final .paso-icono { background: var(--rojo); color: var(--sobre-rojo); box-shadow: 0 0 0 6px var(--rojo-suave); }
.guia b { display: block; font-weight: 800; font-size: 1.02rem; }
.guia b i { font-style: normal; color: var(--rojo-texto); }
.guia small { display: block; color: var(--grafito); font-size: .86rem; line-height: 1.35; }
.guia .onda {
    height: 46px; margin: 3px 0;
    margin-left: calc(var(--i, 0) * var(--escalon) + var(--circulo) / 2);
    width: var(--escalon);
}
.guia .onda svg { width: 100%; height: 100%; display: block; overflow: visible; }
.guia .onda path { fill: none; stroke: var(--rojo); stroke-width: 2.5; stroke-linecap: round; vector-effect: non-scaling-stroke; }

.pasos { list-style: none; margin: 0 0 18px; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); }
.pasos li { display: flex; flex-direction: column; align-items: center; gap: 6px; position: relative; font-size: .8rem; font-weight: 700; color: var(--grafito); }
.pasos li:not(:first-child)::before {
    content: ""; position: absolute; top: 19px; right: 50%; width: 100%; height: 2px; background: var(--linea); z-index: 0;
}
.pasos .paso-icono {
    width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; position: relative; z-index: 1;
    background: var(--superficie); color: var(--grafito); box-shadow: inset 0 0 0 2px var(--linea);
}
.pasos .paso-icono svg { width: 20px; height: 20px; }
.pasos li.hecho, .pasos li.actual { color: var(--tinta); }
.pasos li.hecho::before, .pasos li.actual::before { background: var(--rojo); }
.pasos li.hecho .paso-icono { background: var(--rojo-suave); color: var(--rojo-texto); box-shadow: inset 0 0 0 2px var(--rojo); }
.pasos li.actual .paso-icono { background: var(--rojo); color: var(--sobre-rojo); box-shadow: 0 0 0 5px var(--rojo-suave); }

/* ── Vistas vacías ── */
.vacio { padding: 6px 0 0; }
.vacio h1 { font-size: clamp(1.7rem, 7vw, 2.4rem); line-height: 1.08; font-weight: 800; font-stretch: 84%; letter-spacing: -.03em; margin: 4px 0 10px; }
.vacio p { color: var(--grafito); max-width: 34rem; margin: 0 0 18px; }

/* ── Las hojas / páginas ── */
.filtros-todas { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 10px; margin: 2px 0 18px; color: var(--grafito); font-size: .92rem; }
.hojas {
    list-style: none; padding: 0; margin: 0;
    display: grid; grid-template-columns: repeat(auto-fill, minmax(146px, 1fr)); gap: 22px 14px;
}
.hoja { display: flex; flex-direction: column; position: relative; }
.hoja .mini {
    border: 0; padding: 0; background: var(--mesa); cursor: pointer; border-radius: 14px; color: inherit;
    aspect-ratio: 3 / 4; display: flex; align-items: center; justify-content: center; position: relative; overflow: hidden;
}
div.mini { cursor: default; }
.hoja .mini img { max-width: 86%; max-height: 88%; box-shadow: var(--sombra-hoja); background: #fff; border-radius: 2px; }
.hoja .mini img.giro1 { transform: rotate(90deg) scale(.74); }
.hoja .mini img.giro2 { transform: rotate(180deg); }
.hoja .mini img.giro3 { transform: rotate(270deg) scale(.74); }
.hoja .procesando { color: var(--grafito); font-size: .88rem; font-weight: 600; }
.hoja .procesando::after {
    content: ""; display: block; width: 46px; height: 4px; margin: 10px auto 0; border-radius: 4px;
    background: linear-gradient(90deg, var(--rojo) 0 40%, var(--linea) 40%) 0 0 / 200% 100%;
    animation: cargando 1s linear infinite;
}
@keyframes cargando { to { background-position: -100% 0; } }
@media (prefers-reduced-motion: reduce) { .hoja .procesando::after { animation: none; } }
.hoja .numero {
    position: absolute; top: -8px; left: 10px; z-index: 1; min-width: 28px; height: 26px; padding: 0 8px;
    background: var(--rojo); color: var(--sobre-rojo); font-weight: 800; font-size: .92rem;
    display: inline-flex; align-items: center; justify-content: center; border-radius: 8px;
}
.hoja .aviso {
    position: absolute; left: 8px; right: 8px; bottom: 8px; font-size: .74rem; line-height: 1.25; font-weight: 600;
    background: var(--tinta); color: var(--superficie); border-radius: 8px; padding: 5px 7px;
}
.hoja .pie-hoja { font-size: .76rem; color: var(--grafito); padding: 5px 2px 0; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hoja .barra-hoja { display: flex; justify-content: space-between; padding: 4px 0 0; }
.hoja .barra-hoja button {
    border: 0; background: transparent; color: var(--tinta); width: 36px; height: 36px; border-radius: 10px;
    cursor: pointer; display: grid; place-items: center;
}
.hoja .barra-hoja svg { width: 20px; height: 20px; }
.hoja .barra-hoja button:disabled { opacity: .25; cursor: default; }
.hoja .barra-hoja button:not(:disabled):active { background: var(--rojo-suave); }
.hoja .barra-hoja button:last-child { color: var(--peligro); }

.ayuda { color: var(--grafito); font-size: .9rem; margin: .7rem 0; }
.centro { text-align: center; }
.estado { color: var(--grafito); text-align: center; min-height: 1.5em; font-size: .95rem; margin: 18px 0 0; }
.estado.error { color: var(--peligro); font-weight: 600; }

/* ── Botones ── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 48px; padding: 0 18px; border-radius: 14px; cursor: pointer;
    border: 1px solid var(--linea); background: var(--superficie); color: var(--tinta);
    font-size: 1rem; font-weight: 700; text-decoration: none;
}
.btn svg { width: 20px; height: 20px; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primario { background: var(--rojo); border-color: var(--rojo); color: var(--sobre-rojo); }
.btn.primario:not(:disabled):active { background: var(--rojo-hondo); }
.btn.texto { border-color: transparent; background: transparent; color: var(--rojo-texto); padding: 0 8px; }
.btn.chico { min-height: 40px; padding: 0 14px; font-size: .94rem; border-radius: 12px; }
.fila-botones { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 4px; }
.fila-botones .btn { flex: 1; }

.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 12px; background: var(--mesa); }
.seg button {
    border: 0; background: transparent; color: var(--tinta); font-size: .92rem; font-weight: 600;
    padding: 7px 14px; cursor: pointer; min-height: 36px; border-radius: 9px;
}
.seg button[aria-pressed="true"] { background: var(--superficie); color: var(--rojo-texto); box-shadow: 0 1px 3px rgba(20, 20, 30, .18); }

/* ── Abajo: como la cámara del celular, el disparador grande en el medio ── */
.acciones {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
    display: grid; grid-template-columns: 1fr auto 1fr; align-items: end; gap: 8px;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
    background: var(--superficie); border-top: 1px solid var(--linea);
}
@media (min-width: 760px) {
    .acciones { left: 50%; right: auto; width: 560px; transform: translateX(-50%); border: 1px solid var(--linea); border-bottom: 0; border-radius: 22px 22px 0 0; }
}
.lateral, .disparador {
    border: 0; background: transparent; color: var(--tinta); cursor: pointer;
    display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: .84rem; font-weight: 700; padding: 4px;
}
.lateral svg { width: 46px; height: 46px; padding: 11px; border-radius: 15px; background: var(--mesa); }
.lateral:disabled { opacity: .35; cursor: default; }
.lateral:not(:disabled):active svg { background: var(--rojo-suave); }
.lateral.destacado:not(:disabled) svg { background: var(--tinta); color: var(--superficie); }
.disparador { margin-top: -30px; }
.disparador .aro {
    width: 76px; height: 76px; border-radius: 50%; display: grid; place-items: center;
    background: var(--rojo); color: var(--sobre-rojo);
    box-shadow: 0 0 0 5px var(--superficie), 0 0 0 8px var(--rojo), 0 12px 24px -6px rgba(215, 38, 46, .6);
    transition: transform .12s;
}
.disparador svg { width: 32px; height: 32px; }
.disparador:active .aro { transform: scale(.92); }

.pie { max-width: 34rem; margin: 34px auto 0; color: var(--grafito); font-size: .8rem; text-align: center; }
.pie p { margin: .4rem 0; }

/* ── Resultado ── */
.resultado {
    text-align: center; background: var(--superficie); border: 1px solid var(--linea); border-radius: 24px;
    padding: 24px 20px 16px; margin: 16px 0; box-shadow: var(--sombra);
}
.resultado-sello {
    width: 64px; height: 64px; margin: 0 auto 10px; border-radius: 50%; display: grid; place-items: center;
    background: var(--rojo); color: var(--sobre-rojo); box-shadow: 0 0 0 8px var(--rojo-suave);
}
.resultado-sello svg { width: 34px; height: 34px; stroke-width: 2.4; }
.resultado h2 { font-size: 1.8rem; font-weight: 800; font-stretch: 85%; }
.resultado p { color: var(--grafito); margin: 0 0 6px; }

/* ── Tarjetas y diálogos ── */
.tarjeta { background: var(--superficie); border: 1px solid var(--linea); border-radius: 20px; padding: 20px; margin: 16px 0; }
.dialogo {
    position: fixed; inset: 0; z-index: 20; background: rgba(10, 10, 14, .6);
    display: flex; align-items: flex-end; justify-content: center;
}
.hoja-abajo { width: 100%; max-width: 520px; margin: 0; border-radius: 24px 24px 0 0; padding-bottom: calc(20px + env(safe-area-inset-bottom)); border-bottom: 0; }
@media (min-width: 560px) { .dialogo { align-items: center; } .hoja-abajo { border-radius: 24px; border-bottom: 1px solid var(--linea); } }
.hoja-abajo h2 { font-size: 1.45rem; font-weight: 800; font-stretch: 85%; }
.hoja-abajo label { display: block; font-weight: 700; margin: 14px 0 6px; }
.hoja-abajo input[type="text"] {
    width: 100%; min-height: 50px; padding: 0 14px; border-radius: 12px;
    border: 1px solid var(--linea); background: var(--fondo); color: var(--tinta); font-size: 1rem;
}
.hoja-abajo input[type="text"]:focus { border-color: var(--rojo); outline: none; box-shadow: 0 0 0 3px var(--rojo-suave); }
.hoja-abajo .check { display: flex; gap: 10px; align-items: flex-start; font-weight: 500; }
.hoja-abajo .check input { width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--rojo); flex: none; }
.progreso { height: 10px; background: var(--mesa); border-radius: 99px; overflow: hidden; margin-top: 16px; }
.progreso div { height: 100%; width: 0; background: var(--rojo); border-radius: 99px; transition: width .25s; }

.doc-cabecera { display: flex; gap: 14px; align-items: center; margin-bottom: 14px; }
.doc-cabecera img { width: 60px; height: 78px; object-fit: cover; object-position: top; border-radius: 4px; background: #fff; box-shadow: 0 0 0 1px var(--linea); flex: none; }
.doc-cabecera h2 { margin: 0; font-size: 1.15rem; overflow-wrap: anywhere; }
.doc-cabecera .ayuda { margin: 4px 0 0; }
.doc-acciones { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 8px; }
.doc-acciones button {
    display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 4px; cursor: pointer;
    border: 1px solid var(--linea); border-radius: 16px; background: var(--fondo); color: var(--tinta); font-size: .86rem; font-weight: 700;
}
.doc-acciones button svg { color: var(--rojo); }
.doc-acciones button:active { background: var(--rojo-suave); }
.doc-acciones .peligro { color: var(--peligro); }
#docCerrar { width: 100%; }

/* ── Editor de una hoja y visor (pantalla completa, oscuros para que resalte la foto) ── */
#editor, #visor { background: #111114; align-items: stretch; }
.editor, .visor { display: flex; flex-direction: column; width: 100%; max-width: 760px; height: 100%; color: #f1f1f4; }
.editor-arriba { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: calc(8px + env(safe-area-inset-top)) 10px 6px; }
.editor-arriba h2 { margin: 0; font-size: 1.02rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#editor .btn.texto, #visor .btn.texto { color: #ffb3b6; }
#editor .ayuda { color: #a5a7b0; }
.lienzo {
    flex: 1; min-height: 0; position: relative; display: flex; align-items: center; justify-content: center;
    padding: 22px; touch-action: none; user-select: none; -webkit-user-select: none;
}
.lienzo img { max-width: 100%; max-height: 100%; display: block; pointer-events: none; border-radius: 4px; }
.lienzo svg { position: absolute; overflow: visible; pointer-events: none; }
.lienzo polygon { fill: rgba(229, 53, 60, .16); stroke: #ff4d53; stroke-width: 2.5; stroke-linejoin: round; }
.lienzo circle { fill: rgba(255, 255, 255, .25); stroke: #ff4d53; stroke-width: 3.5; }
.lienzo circle.activa { fill: rgba(229, 53, 60, .55); stroke: #fff; }
.lupa {
    position: absolute; width: 112px; height: 112px; border-radius: 50%;
    border: 3px solid #fff; box-shadow: 0 4px 14px rgba(0, 0, 0, .6); background-repeat: no-repeat; background-color: #000;
    pointer-events: none;
}
.lupa::after {
    content: ""; position: absolute; left: 50%; top: 50%; width: 18px; height: 18px; margin: -9px 0 0 -9px;
    border: 2px solid #ff4d53; border-radius: 50%;
}
.editor-abajo { padding: 4px 12px calc(12px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: center; }
.editor-abajo .fila-botones { width: 100%; }
.editor-abajo .btn { background: #222228; border-color: #33343b; color: #f1f1f4; }
#editor .seg { background: #222228; }
#editor .seg button { color: #d2d3d9; }
#editor .seg button[aria-pressed="true"] { background: var(--rojo); color: #fff; }
.editor-abajo .ayuda { margin: 8px 0 0; min-height: 1.2em; }

.visor-paginas { flex: 1; overflow-y: auto; padding: 12px 12px calc(24px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: center; gap: 12px; }
.visor-paginas img { width: 100%; max-width: 720px; height: auto; background: #fff; border-radius: 3px; box-shadow: 0 6px 20px rgba(0, 0, 0, .5); }
.visor-paginas .ayuda { color: #a5a7b0; }

/* ── Texto de un PDF ── */
.herramientas-texto { display: grid; gap: 10px; }
@media (min-width: 620px) { .herramientas-texto { grid-template-columns: 1fr 1fr; } }
.herramienta-fila {
    display: flex; align-items: center; gap: 14px; text-align: left; cursor: pointer; width: 100%;
    padding: 12px 14px; border-radius: 18px; border: 1px solid var(--linea); background: var(--superficie); color: var(--tinta);
    box-shadow: var(--sombra);
}
.herramienta-fila:active { transform: scale(.985); }
.herramienta-fila .icono { flex: none; width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; background: var(--rojo-suave); color: var(--rojo-texto); }
.herramienta-fila .icono svg { width: 26px; height: 26px; }
.herramienta-fila b { display: block; font-weight: 800; font-size: .98rem; line-height: 1.2; }
.herramienta-fila small { display: block; color: var(--grafito); font-size: .84rem; line-height: 1.3; margin-top: 2px; }

.archivo-texto {
    display: flex; align-items: center; gap: 12px; padding: 12px 14px; margin: 12px 0 4px;
    background: var(--superficie); border: 1px solid var(--linea); border-radius: 16px;
}
.archivo-texto .icono { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--rojo); color: var(--sobre-rojo); flex: none; }
.archivo-texto .datos { min-width: 0; }
.archivo-texto b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.archivo-texto small { color: var(--grafito); font-size: .86rem; }
.estado-texto { color: var(--grafito); font-size: .94rem; min-height: 1.4em; margin: 10px 0; }
.estado-texto.error { color: var(--peligro); font-weight: 600; }
.aviso-ocr { background: var(--rojo-suave); border-radius: 16px; padding: 14px; margin: 8px 0 12px; }
.aviso-ocr p { margin: 0 0 10px; font-size: .94rem; }
.aviso-ocr .btn { width: 100%; }
.texto-salida {
    white-space: pre-wrap; overflow-wrap: anywhere; font: 15px/1.55 "Bricolage", system-ui, sans-serif; margin: 12px 0;
    background: var(--superficie); border: 1px solid var(--linea); border-radius: 16px; padding: 16px; max-height: 60vh; overflow: auto;
    user-select: text; -webkit-user-select: text;
}
.texto-salida:focus-visible { outline-offset: -3px; }
.elegir-pdf { width: 100%; margin-top: 8px; }

/* ── Apoyar el proyecto ── */
.apoyar {
    margin: 30px 0 0; padding: 22px 20px; border-radius: 24px; text-align: center;
    background: var(--rojo-suave); border: 1px solid color-mix(in srgb, var(--rojo) 25%, transparent);
}
.apoyar-icono {
    width: 52px; height: 52px; margin: 0 auto 10px; border-radius: 50%; display: grid; place-items: center;
    background: var(--rojo); color: var(--sobre-rojo);
}
.apoyar-icono svg { width: 26px; height: 26px; fill: currentColor; }
.apoyar h2 { font-size: 1.25rem; font-weight: 800; font-stretch: 88%; margin: 0 0 6px; }
.apoyar p { color: var(--grafito); margin: 0 auto 14px; max-width: 30rem; font-size: .94rem; }
.apoyar .btn { min-width: 160px; }
.apoyar .btn svg { fill: currentColor; }

.apoyar-dlg { text-align: center; }
.apoyar-dlg .qr { width: 196px; height: 196px; margin: 6px auto 12px; padding: 10px; background: #fff; border-radius: 16px; box-shadow: 0 0 0 1px var(--linea); }
.apoyar-dlg .qr svg { width: 100%; height: 100%; display: block; fill: initial; stroke: none; }
.apoyar-dlg .red { display: inline-block; font-size: .8rem; font-weight: 800; color: var(--rojo-texto); background: var(--rojo-suave); padding: 4px 10px; border-radius: 8px; }
.apoyar-dlg .direccion {
    display: block; margin: 10px 0 12px; padding: 12px; border-radius: 12px; background: var(--fondo); border: 1px solid var(--linea);
    font: 600 .95rem/1.4 ui-monospace, "Cascadia Mono", Consolas, monospace; overflow-wrap: anywhere; user-select: all; -webkit-user-select: all;
}
.apoyar-dlg #apoyarCopiar { width: 100%; }
.apoyar-dlg .advertencia { font-size: .84rem; color: var(--grafito); margin: 12px 0 4px; text-align: left; }
.apoyar-dlg #apoyarCerrar { width: 100%; }
.pie a { color: var(--rojo-texto); font-weight: 700; }

/* ── Arrastrar páginas para ordenarlas ── */
.hoja { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
div.mini { cursor: grab; }
.hoja.arrastrando { opacity: .3; }
.hoja.arrastrando .mini { outline: 2px dashed var(--rojo); outline-offset: -2px; }
.hoja.fantasma {
    position: fixed; left: 0; top: 0; z-index: 50; margin: 0; pointer-events: none; cursor: grabbing;
    filter: drop-shadow(0 14px 24px rgba(0, 0, 0, .35));
}
.hoja.fantasma .barra-hoja, .hoja.fantasma .pie-hoja { visibility: hidden; }

/* ── Aviso de la primera vez: «Preparando ScannerFree para que funcione sin internet» ── */
.preparando {
    display: flex; align-items: center; gap: 12px; max-width: 728px; margin: 12px auto 0; padding: 12px 14px;
    width: calc(100% - 32px); background: var(--superficie); border: 1px solid var(--linea); border-radius: 16px; box-shadow: var(--sombra);
}
.preparando-icono { flex: none; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--rojo-suave); color: var(--rojo-texto); }
.preparando.lista .preparando-icono { background: var(--rojo); color: var(--sobre-rojo); }
.preparando-texto { flex: 1; min-width: 0; }
.preparando b { display: block; font-size: .92rem; font-weight: 800; line-height: 1.25; }
.preparando small { display: block; color: var(--grafito); font-size: .82rem; line-height: 1.3; margin-top: 2px; }
.preparando .progreso { display: block; height: 6px; margin-top: 8px; }
.preparando .progreso span { display: block; height: 100%; width: 0; background: var(--rojo); border-radius: 99px; transition: width .3s; }
.preparando.lista .progreso { display: none; }

/* ── Convertir ── */
/* El Word se dibuja acá (tapado por el aviso «Convirtiendo…») para sacarle las páginas */
.conv-lienzo {
    position: absolute; left: 0; top: 0; z-index: 15; background: #fff; color: #000;
    font: 16px/1.15 Calibri, Carlito, Arial, sans-serif; letter-spacing: normal;
}
.conv-lienzo:empty { display: none; }
.conv-lienzo section.docx { margin: 0 0 20px; box-shadow: none; }

/* ── Íconos de convertir: hojitas de colores (azul con W = Word, roja = PDF) ── */
.icono-hojas { background: var(--fondo) !important; box-shadow: inset 0 0 0 1px var(--linea); }
.icono-hojas svg, .sin-mini.hoja-word svg { stroke: none; fill: initial; }
.herramienta-fila .icono-hojas svg, .archivo-texto .icono-hojas svg { width: 40px; height: 40px; }
.sin-mini.hoja-word svg { width: 40px; height: 40px; }
.documento .etiqueta-pdf.word { color: #1f56b8; background: #e3ecfc; }
@media (prefers-color-scheme: dark) { .documento .etiqueta-pdf.word { color: #9cbcf5; background: #1c2a47; } }
