:root {
    --bg: #0f1117;
    --surface: #181b25;
    --surface-2: #1f2330;
    --border: #2a2f3f;
    --text: #eef0f6;
    --muted: #9aa3b5;
    --accent: #7c5cff;
    --accent-2: #38bdf8;
    --ok: #34d399;
    --danger: #f87171;
    --radius: 14px;
    --viewer-bar-h: 49px;
    --expo-out: cubic-bezier(0.16, 1, 0.3, 1);
    color-scheme: dark;
}

/* Modo claro: elegido manualmente… */
:root[data-theme="light"] {
    --bg: #f7f8fa;
    --surface: #ffffff;
    --surface-2: #eef0f6;
    --border: #e3e6ec;
    --text: #171a23;
    --muted: #5b6375;
    --accent: #6d4fe0;
    --accent-2: #0284c7;
    --ok: #059669;
    --danger: #dc2626;
    color-scheme: light;
}

/* …o heredado del sistema (si el usuario no ha forzado oscuro) */
@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) {
        --bg: #f7f8fa;
        --surface: #ffffff;
        --surface-2: #eef0f6;
        --border: #e3e6ec;
        --text: #171a23;
        --muted: #5b6375;
        --accent: #6d4fe0;
        --accent-2: #0284c7;
        --ok: #059669;
        --danger: #dc2626;
        color-scheme: light;
    }
}

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

body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    line-height: 1.55;
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

.nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 22px;
    border-bottom: 1px solid var(--border);
}

.brand {
    font-weight: 800;
    font-size: 1.15rem;
    letter-spacing: -0.02em;
    color: var(--text) !important;
    text-decoration: none !important;
}
.brand span { color: var(--accent); }

.nav-links { display: flex; gap: 18px; font-size: 0.95rem; }
.nav-links a { color: var(--text); }
.nav-links a:hover { color: var(--accent); text-decoration: none; }

main { flex: 1; width: 100%; max-width: 920px; margin: 0 auto; padding: 34px 20px 60px; }
main.full { max-width: none; padding: 0; }

.footer {
    text-align: center;
    color: var(--muted);
    font-size: 0.85rem;
    padding: 18px;
    border-top: 1px solid var(--border);
}

h1 { font-size: 2rem; letter-spacing: -0.02em; margin-bottom: 8px; }
.lead { color: var(--muted); margin-bottom: 28px; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
}

.grid { display: grid; gap: 16px; }
@media (min-width: 700px) {
    .grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
    .grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
}

/* Checkbox con etiqueta al lado (opciones de publicación) */
.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 0.92rem; cursor: pointer; margin: 0; }
.check input { width: auto; }

.icon {
    width: 1.2em;
    height: 1.2em;
    vertical-align: -0.22em;
    flex-shrink: 0;
}

/* Botones de solo icono (ojito, tema) */
.icon-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--muted);
    padding: 5px 8px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    line-height: 1;
}
.icon-btn:hover { color: var(--text); border-color: var(--accent); }

/* Campo de contraseña con ojito para mostrar/ocultar */
.password-field { position: relative; }
.password-field input { padding-right: 46px; }
.password-eye {
    position: absolute;
    top: 50%;
    right: 6px;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    padding: 6px;
    display: inline-flex;
    align-items: center;
}
.password-eye:hover { color: var(--text); }

.theme-toggle.floating {
    position: fixed;
    right: 14px;
    bottom: 56px;
    z-index: 60;
    background: var(--surface);
}

/* El botón de tema muestra sol en oscuro y luna en claro */
.theme-toggle .i-moon { display: none; }
:root[data-theme="light"] .theme-toggle .i-sun { display: none; }
:root[data-theme="light"] .theme-toggle .i-moon { display: inline-block; }
@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) .theme-toggle .i-sun { display: none; }
    :root:not([data-theme="dark"]) .theme-toggle .i-moon { display: inline-block; }
}

.card h3 { margin-bottom: 6px; font-size: 1.05rem; display: flex; align-items: center; gap: 9px; }
.card h3 .icon { color: var(--accent); width: 1.35em; height: 1.35em; }
h1 .icon { color: var(--accent); width: 1.1em; height: 1.1em; }
.tabs button { display: inline-flex; align-items: center; gap: 7px; }
.card p { color: var(--muted); font-size: 0.92rem; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--accent);
    color: #fff !important;
    border: none;
    border-radius: 10px;
    padding: 11px 20px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none !important;
    transition: filter .15s;
}
.btn:hover { filter: brightness(1.12); }
/* El texto sigue al tema: .btn fuerza #fff, que en claro era invisible */
.btn.secondary { background: var(--surface-2); border: 1px solid var(--border); color: var(--text) !important; }
.btn.big { padding: 15px 28px; font-size: 1.1rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

input[type="text"], input[type="url"], input[type="email"],
input[type="password"], input[type="search"], input[type="date"],
select, textarea, input[type="file"] {
    width: 100%;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    padding: 12px 14px;
    font-size: 1rem;
    font-family: inherit;
}
textarea { min-height: 180px; font-family: ui-monospace, monospace; font-size: 0.88rem; }
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

label { display: block; font-size: 0.9rem; color: var(--muted); margin: 16px 0 6px; }

.error { color: var(--danger); font-size: 0.9rem; margin-top: 8px; }
.notice { color: var(--ok); font-size: 0.95rem; }

/* ── Entrada de código grande ─────────────────────────── */
.code-input {
    text-align: center;
    font-size: 2rem !important;
    letter-spacing: 0.45em;
    text-transform: uppercase;
    font-family: ui-monospace, "Cascadia Mono", monospace;
    padding: 16px !important;
}

/* ── Pantalla receptora (TV) ──────────────────────────── */
.tv {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 26px;
    padding: 30px;
    text-align: center;
}

.tv .room-code {
    font-family: ui-monospace, "Cascadia Mono", monospace;
    font-size: clamp(3.5rem, 12vw, 9rem);
    font-weight: 800;
    letter-spacing: 0.18em;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    line-height: 1.1;
}

.tv .qr-box { background: #fff; padding: 14px; border-radius: 16px; display: inline-block; }
.tv .qr-box svg { display: block; width: clamp(140px, 22vw, 240px); height: auto; }

.tv .hint { color: var(--muted); font-size: clamp(1rem, 2.4vw, 1.5rem); }
.tv .hint strong { color: var(--text); }

.tv .waiting { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 1.05rem; }

.pulse {
    width: 12px; height: 12px; border-radius: 50%;
    background: var(--ok);
    animation: pulse 1.6s infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: .35; transform: scale(.75); }
}

/* Contenido proyectado a pantalla completa */
.stage {
    position: fixed;
    inset: 0;
    background: var(--bg);
    display: none;
    flex-direction: column;
}
.stage.active { display: flex; }
.stage iframe { flex: 1; border: 0; width: 100%; background: #fff; }
.stage .stage-text {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6vw;
    font-size: clamp(1.6rem, 4.5vw, 3.4rem);
    text-align: center;
    white-space: pre-wrap;
    word-break: break-word;
}
.stage-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 14px;
    background: var(--surface);
    border-top: 1px solid var(--border);
    font-size: 0.9rem;
    color: var(--muted);
}
.stage-bar .code-chip {
    font-family: ui-monospace, monospace;
    color: var(--accent-2);
    font-weight: 700;
}

/* ── Resultado de publicación ─────────────────────────── */
.share-link {
    display: flex;
    gap: 10px;
    align-items: center;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 14px;
    font-family: ui-monospace, monospace;
    font-size: 1.02rem;
    overflow-wrap: anywhere;
}

.qr-inline { background: #fff; padding: 10px; border-radius: 12px; display: inline-block; }
.qr-inline svg { display: block; width: 180px; height: 180px; }

/* ── Tabs ─────────────────────────────────────────────── */
.tabs { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.tabs button {
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--muted);
    border-radius: 10px;
    padding: 9px 18px;
    font-size: 0.95rem;
    cursor: pointer;
    font-weight: 600;
}
.tabs button.active { background: var(--accent); border-color: var(--accent); color: #fff; }
/* En celular las pestañas se reparten el ancho en vez de salirse */
@media (max-width: 520px) {
    .tabs button { flex: 1 1 auto; justify-content: center; padding: 9px 10px; font-size: 0.86rem; }
    .tabs button .icon { width: 1em; height: 1em; }
}
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ── Visores ──────────────────────────────────────────── */
.viewer-bar {
    /* Fija y de alto conocido: el contenido de abajo se cuelga de --viewer-bar-h,
       así no hay que adivinar cuánto mide la barra ni se le encima nada. */
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 10;
    height: var(--viewer-bar-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    font-size: 0.92rem;
}
.viewer-bar .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-bar .actions { display: flex; gap: 14px; flex-shrink: 0; }
.viewer-body { position: fixed; inset: var(--viewer-bar-h) 0 0 0; }
.viewer-body iframe { width: 100%; height: 100%; border: 0; background: #fff; }
.viewer-body.center { display: flex; align-items: center; justify-content: center; overflow: auto; padding: 20px; }
.viewer-body img { max-width: 100%; max-height: 100%; border-radius: 8px; }

/* ── eBook (PDF) ──────────────────────────────────────── */
.ebook {
    position: fixed; inset: var(--viewer-bar-h) 0 0 0;
    display: flex; flex-direction: column;
    background: #23262f;
}
.ebook-stage {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    overflow: hidden;
    padding: 14px;
}
/* "Ajustar al ancho": una página al ancho, alineada arriba y con scroll vertical */
.ebook-stage.fit-width {
    align-items: flex-start;
    overflow-y: auto;
    overflow-x: hidden;
}
/* Al ancho la página debe poder ser más alta que el contenedor (por eso no la limitamos) */
.ebook-stage.fit-width canvas { max-height: none; }
.ebook-stage canvas {
    max-width: 100%;
    max-height: 100%;
    box-shadow: 0 12px 40px rgba(0,0,0,.55);
    border-radius: 4px;
    background: #fff;
}
.ebook-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 18px;
    padding: 10px;
    background: var(--surface);
    border-top: 1px solid var(--border);
}
.ebook-controls button {
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 8px;
    padding: 8px 16px;
    font-size: 1rem;
    cursor: pointer;
}
.ebook-controls button:hover { background: var(--accent); border-color: var(--accent); }
.ebook-controls .page-info { color: var(--muted); font-size: 0.95rem; min-width: 90px; text-align: center; }

.center-page { text-align: center; padding: 60px 20px; }
.meta { color: var(--muted); font-size: 0.88rem; }

/* ── Rayar encima del contenido (lápiz / resaltador) ───────── */
/* Va con `canvas.` a propósito: dentro del ebook existe `.ebook-stage canvas`,
   que da fondo blanco y sombra a las páginas del PDF. Sin esta especificidad
   la capa hereda ese blanco y tapa por completo lo que hay debajo. */
canvas.pl-annotate-canvas {
    position: absolute;
    inset: 0;
    z-index: 5;
    background: transparent;
    box-shadow: none;
    border-radius: 0;
    max-width: none;
    max-height: none;
    /* Apagado: los clics pasan al contenido de abajo como si no existiera */
    pointer-events: none;
    /* touch-action none = arrastrar dibuja en vez de hacer scroll */
    touch-action: none;
}
canvas.pl-annotate-canvas.on { pointer-events: auto; cursor: crosshair; }

.pl-annotate-bar {
    position: fixed;
    left: 14px;
    top: 50%;
    transform: translateY(-50%) scale(0.9);
    z-index: 60;
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 10px 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    box-shadow: 0 8px 30px rgb(0 0 0 / 0.35);
    opacity: 0;
    transition: opacity 0.15s ease, transform 0.15s ease;
}
.pl-annotate-bar.on { display: flex; opacity: 1; transform: translateY(-50%) scale(1); }

.pl-annotate-colors { display: flex; flex-direction: column; gap: 8px; }
.pl-annotate-color {
    width: 26px; height: 26px;
    padding: 0;
    border: 2px solid transparent;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 0 1px var(--border);
}
.pl-annotate-color.on { border-color: var(--text); transform: scale(1.12); }

.pl-annotate-sep { width: 22px; height: 1px; background: var(--border); }

.pl-annotate-tool {
    width: 30px; height: 30px;
    display: flex; align-items: center; justify-content: center;
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--border);
    border-radius: 50%;
    font-size: 0.95rem;
    line-height: 1;
    cursor: pointer;
}
.pl-annotate-tool:hover { color: var(--text); border-color: var(--accent); }
.pl-annotate-tool.on { color: #fff; background: var(--accent); border-color: var(--accent); }

/* En pantallas angostas la barra se va abajo y se acuesta */
@media (max-width: 640px) {
    .pl-annotate-bar {
        left: 50%; top: auto; bottom: 16px;
        transform: translateX(-50%) scale(0.9);
        flex-direction: row;
        padding: 8px 12px;
    }
    .pl-annotate-bar.on { transform: translateX(-50%) scale(1); }
    .pl-annotate-colors { flex-direction: row; }
    .pl-annotate-sep { width: 1px; height: 22px; }
}

/* Envoltorio que se ajusta al contenido para que el lápiz caiga justo encima */
.draw-wrap {
    position: relative;
    display: flex;
    max-width: 100%;
    max-height: 100%;
    min-height: 0;
}
.draw-wrap img { display: block; object-fit: contain; }

/* El botón "Rayar" encendido en la barra del visor */
.viewer-bar .actions a.on,
.stage-bar a.on { color: var(--accent); font-weight: 600; }
.viewer-bar .actions a .icon,
.stage-bar a .icon { width: 1em; height: 1em; vertical-align: -2px; }

/* Páginas de error (404 / 410) */
.error-code {
    font-family: ui-monospace, "Cascadia Mono", monospace;
    font-size: clamp(2.6rem, 9vw, 4.6rem);
    font-weight: 800;
    letter-spacing: 0.04em;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    line-height: 1.05;
    margin-bottom: 6px;
}
.center-page h1 { margin-bottom: 10px; }
.center-page .lead { max-width: 560px; margin-left: auto; margin-right: auto; }

/* ── Cambio de tema: círculo difuminado ────────────────────
   Basado en el efecto "circle-blur" de theme-toggle.rdsx.dev, adaptado a
   nuestro `data-theme` (el original usa una clase .dark).

   Cómo funciona: la View Transition API saca una foto del antes y del
   después. Dejamos la foto vieja quieta al fondo y revelamos la nueva a
   través de una máscara: un círculo SVG desenfocado que crece hasta cubrir
   la pantalla. El desenfoque va dentro del SVG, así que el borde del
   círculo sale suave en vez de recortado.

   Envuelto en `no-preference` a propósito: un barrido a pantalla completa
   es justo lo que molesta a quien pide menos movimiento. Ahí el tema
   cambia igual, pero de golpe. */
@media (prefers-reduced-motion: no-preference) {
    ::view-transition-group(root) {
        animation-timing-function: var(--expo-out);
    }

    ::view-transition-new(root) {
        mask: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 40 40"><defs><filter id="blur"><feGaussianBlur stdDeviation="2"/></filter></defs><circle cx="20" cy="20" r="18" fill="white" filter="url(%23blur)"/></svg>') center / 0 no-repeat;
        animation: pl-theme-wipe 1s;
        animation-fill-mode: both;
    }

    /* La foto vieja se queda fija detrás mientras la nueva la va tapando */
    ::view-transition-old(root) {
        animation: none;
        animation-fill-mode: both;
        z-index: -1;
    }

    @keyframes pl-theme-wipe {
        to { mask-size: 200vmax; }
    }
}

/* ── Botón Cerrar y aviso del modo dibujo ─────────────────── */
.pl-annotate-close {
    padding: 6px 14px;
    border-radius: 999px;
    border: none;
    background: var(--danger);
    color: #fff;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}
.pl-annotate-close:hover { filter: brightness(1.1); }

.pl-annotate-hint {
    position: fixed;
    top: 58px; left: 50%;
    transform: translateX(-50%) translateY(-8px);
    z-index: 70;
    background: rgba(20, 22, 30, 0.96);
    color: #fff;
    padding: 11px 16px;
    border-radius: 10px;
    font-size: 0.9rem;
    max-width: 90vw;
    text-align: center;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
}
.pl-annotate-hint.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Barra del visor: responsive en celular ───────────────── */
@media (max-width: 640px) {
    .viewer-bar { padding: 8px 10px; gap: 8px; }
    .viewer-bar .brand { display: none; }
    .viewer-bar .title { font-size: 0.82rem; max-width: 32vw; }
    .viewer-bar .actions {
        gap: 15px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        font-size: 0.85rem;
        scrollbar-width: none;
    }
    .viewer-bar .actions::-webkit-scrollbar { display: none; }
    .viewer-bar .actions a { white-space: nowrap; }
}

/* ── Spinner mientras carga el PDF ────────────────────────── */
.ebook-loading {
    position: absolute; inset: 0;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 14px; color: var(--muted);
    background: #23262f; z-index: 6;
}
.ebook-loading.hidden { display: none; }
.ebook-spinner {
    width: 46px; height: 46px;
    border: 4px solid rgba(255, 255, 255, 0.14);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: pl-spin 0.8s linear infinite;
}
@keyframes pl-spin { to { transform: rotate(360deg); } }

/* Páginas legales (términos, privacidad) */
.legal h3 { margin: 22px 0 6px; font-size: 1.05rem; color: var(--text); }
.legal h3:first-child { margin-top: 0; }
.legal p, .legal li { color: var(--text); font-size: 0.95rem; }
.legal ul { margin: 6px 0 6px 22px; }
.legal li { margin: 3px 0; }

/* Footer con enlaces */
.footer-links { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; margin-top: 6px; }
.footer-links a { color: var(--muted); font-size: 0.82rem; }
.footer-links a:hover { color: var(--accent); }

/* Banner "verifica tu correo" y aviso global */
.verify-banner, .flash-status {
    max-width: 920px;
    margin: 12px auto 0;
    padding: 10px 16px;
    border-radius: 10px;
    font-size: 0.9rem;
    display: flex; align-items: center; justify-content: center; gap: 12px;
    flex-wrap: wrap;
}
.verify-banner {
    background: color-mix(in srgb, var(--accent) 14%, transparent);
    border: 1px solid var(--accent);
    color: var(--text);
}
.verify-banner form { display: inline; }
.verify-banner button {
    background: var(--accent); color: #fff; border: none;
    border-radius: 8px; padding: 5px 12px; font-size: 0.82rem; cursor: pointer;
}
.flash-status {
    background: color-mix(in srgb, var(--ok) 16%, transparent);
    border: 1px solid var(--ok);
    color: var(--text);
}

/* Espacio para anuncios (Google AdSense u otros) */
.ad-slot {
    max-width: 920px;
    margin: 22px auto;
    min-height: 90px;
    display: flex; align-items: center; justify-content: center;
    color: var(--muted); font-size: 0.8rem;
    text-align: center;
}

/* Spinner dentro de un botón (al enviar formularios) */
.btn-spinner {
    display: inline-block;
    width: 14px; height: 14px;
    border: 2px solid rgba(255,255,255,0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: pl-spin 0.7s linear infinite;
    vertical-align: -2px;
}

/* Alerta de error visible (login, registro…) */
.alert-error {
    display: flex;
    align-items: flex-start;
    gap: 11px;
    background: color-mix(in srgb, var(--danger) 14%, transparent);
    border: 1px solid var(--danger);
    border-radius: 10px;
    padding: 13px 15px;
    margin-top: 16px;
    color: var(--text);
    font-size: 0.93rem;
}
.alert-error .alert-icon {
    flex-shrink: 0;
    width: 20px; height: 20px;
    border-radius: 50%;
    background: var(--danger);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 700;
    line-height: 1;
}
.alert-error strong { display: block; }
.alert-error .alert-help { color: var(--muted); font-size: 0.85rem; margin-top: 5px; }

/* ── Menú hamburguesa (solo en celular) ───────────────────── */
.nav-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 42px; height: 38px;
    padding: 0 9px;
    background: none;
    border: 1px solid var(--border);
    border-radius: 9px;
    cursor: pointer;
}
.nav-toggle span {
    display: block;
    height: 2px;
    background: var(--text);
    border-radius: 2px;
    transition: transform .22s ease, opacity .22s ease;
}
/* Al abrir, las barras forman una X */
.nav-toggle.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle.open span:nth-child(2) { opacity: 0; }
.nav-toggle.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

@media (max-width: 820px) {
    .nav { flex-wrap: wrap; }
    .nav-toggle { display: flex; }
    .nav-links {
        display: none;
        width: 100%;
        flex-direction: column;
        align-items: stretch !important;
        gap: 0;
        margin-top: 12px;
        padding-top: 8px;
        border-top: 1px solid var(--border);
    }
    .nav-links.open { display: flex; }
    .nav-links > a,
    .nav-links > form,
    .nav-links > button { width: 100%; }
    .nav-links > a {
        padding: 12px 4px;
        border-bottom: 1px solid var(--border);
    }
    .nav-links > a.btn { border-bottom: none; margin-top: 10px; justify-content: center; }
    .nav-links > form { margin-top: 10px; }
    .nav-links > form button { width: 100%; }
    .nav-links .theme-toggle { margin-top: 12px; align-self: flex-start; }
}

/* ═══════════════════════════════════════════════════════════
   REDISEÑO estilo herramientas (iLovePDF) — PRUEBA LOCAL
   ═══════════════════════════════════════════════════════════ */

/* Tipografía propia para títulos y controles */
@font-face { font-family: 'Outfit'; src: url('/fonts/outfit-400.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Outfit'; src: url('/fonts/outfit-600.woff2') format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Outfit'; src: url('/fonts/outfit-800.woff2') format('woff2'); font-weight: 800; font-display: swap; }

h1, h2, h3, .brand, .btn, .nav-links, .tool-card .tool-title, .hero-title {
    font-family: 'Outfit', system-ui, sans-serif;
}
h1, .hero-title { letter-spacing: -0.03em; }

/* ── Rejilla de herramientas ──────────────────────────────── */
.hero-title { font-size: clamp(2rem, 5vw, 3.1rem); font-weight: 800; line-height: 1.1; text-align: center; margin-bottom: 12px; }
.hero-sub { text-align: center; color: var(--muted); font-size: 1.05rem; max-width: 620px; margin: 0 auto 38px; }

.tool-grid { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 620px) { .tool-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 940px) { .tool-grid { grid-template-columns: repeat(3, 1fr); } }

.tool-card {
    display: block;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 26px 22px;
    text-decoration: none !important;
    color: inherit;
    transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.tool-card:hover {
    transform: translateY(-4px);
    border-color: var(--tool);
    box-shadow: 0 12px 30px rgb(0 0 0 / 0.10);
}
.tool-ico {
    width: 52px; height: 52px;
    border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    background: color-mix(in srgb, var(--tool) 14%, transparent);
    color: var(--tool);
    margin-bottom: 16px;
}
.tool-ico .icon { width: 26px; height: 26px; }
.tool-card .tool-title { font-size: 1.12rem; font-weight: 600; margin-bottom: 6px; }
.tool-card p { color: var(--muted); font-size: 0.9rem; margin: 0; }

/* ── Pasos 1-2-3 ──────────────────────────────────────────── */
.steps { display: grid; gap: 20px; grid-template-columns: 1fr; margin-top: 14px; }
@media (min-width: 720px) { .steps { grid-template-columns: repeat(3, 1fr); } }
.step { display: flex; gap: 13px; align-items: flex-start; }
.step-num {
    flex-shrink: 0;
    width: 30px; height: 30px; border-radius: 50%;
    background: var(--accent); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.9rem;
    font-family: 'Outfit', system-ui, sans-serif;
}
.step-txt strong { display: block; margin-bottom: 2px; }
.step-txt span { color: var(--muted); font-size: 0.88rem; }

/* ── Zona de arrastre para el PDF ─────────────────────────── */
.dropzone {
    border: 2px dashed var(--border);
    border-radius: 16px;
    background: var(--surface-2);
    padding: 38px 22px;
    text-align: center;
    cursor: pointer;
    transition: border-color .15s ease, background .15s ease;
}
.dropzone:hover { border-color: var(--accent); }
.dropzone.dragging { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.dropzone .dz-ico { color: var(--accent); width: 44px; height: 44px; margin-bottom: 10px; }
.dropzone .dz-main { font-weight: 600; font-size: 1.05rem; font-family: 'Outfit', system-ui, sans-serif; }
.dropzone .dz-sub { color: var(--muted); font-size: 0.86rem; margin-top: 5px; }
.dropzone.has-file { border-style: solid; border-color: var(--ok); background: color-mix(in srgb, var(--ok) 8%, transparent); }
.dropzone.has-file .dz-ico { color: var(--ok); }

/* ── Pantalla receptora: sitio que no se deja mostrar ────── */
.stage-blocked {
    flex: 1;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 14px; padding: 40px 24px; text-align: center;
    color: var(--muted);
}
.stage-blocked .icon { color: var(--accent); }
.stage-blocked h2 { font-size: clamp(1.3rem, 3vw, 1.9rem); color: var(--text); margin: 0; }
.stage-blocked p { max-width: 560px; margin: 0; font-size: 1rem; }
.stage-blocked .blocked-url {
    font-family: ui-monospace, monospace; font-size: 0.85rem;
    color: var(--muted); word-break: break-all; max-width: 90%;
}
.stage-hint {
    position: absolute; left: 50%; bottom: 70px;
    transform: translateX(-50%);
    background: rgba(20, 22, 30, 0.94); color: #fff;
    padding: 11px 18px; border-radius: 10px;
    font-size: 0.9rem; z-index: 5;
    box-shadow: 0 8px 26px rgba(0,0,0,.4);
    max-width: 90vw; text-align: center;
}
.stage-hint a { color: #7dd3fc; font-weight: 600; margin-left: 6px; }

/* ── Crédito de autoría con dino pixel-art que trota ───────────────── */
.dev-credit { margin-top: 26px; text-align: center; font-size: 0.85rem; color: var(--muted); }
.dev-credit a { color: inherit; text-decoration: none; }
.dev-credit a:hover { color: var(--accent); }

.dino-run {
    display: inline-block;   /* si algún reset pone svg{display:block}, no salta de línea */
    width: 1.5em;
    height: 1.5em;
    vertical-align: -0.35em; /* lo asienta sobre la línea de texto */
    color: var(--accent);    /* el SVG usa fill=currentColor */
}
/* Solo se mueven las patas: alterna la parte baja de cada pierna → trote */
@keyframes dinoStepA { 0%, 50% { opacity: 1; } 50.01%, 100% { opacity: 0; } }
@keyframes dinoStepB { 0%, 50% { opacity: 0; } 50.01%, 100% { opacity: 1; } }
.dino-run__leg--a { animation: dinoStepA 0.26s steps(1) infinite; }
.dino-run__leg--b { animation: dinoStepB 0.26s steps(1) infinite; }

@media (prefers-reduced-motion: reduce) {
    .dino-run__leg--a, .dino-run__leg--b { animation: none; opacity: 1; }
}

/* ── Ventana de confirmación propia (reemplaza al confirm() del navegador) ── */
.pl-modal {
    position: fixed; inset: 0; z-index: 1000;
    display: none; align-items: center; justify-content: center; padding: 20px;
    background: rgba(0, 0, 0, .55);
}
.pl-modal.open { display: flex; }
.pl-modal-box {
    background: var(--surface); color: var(--text);
    border: 1px solid var(--border); border-radius: 16px;
    padding: 24px; width: 100%; max-width: 420px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, .35);
}
@media (prefers-reduced-motion: no-preference) {
    .pl-modal.open .pl-modal-box { animation: plModalIn .16s ease-out; }
    @keyframes plModalIn { from { transform: translateY(8px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }
}
.pl-modal-title { margin: 0 0 8px; font-size: 1.15rem; }
.pl-modal-msg { margin: 0 0 22px; color: var(--muted); line-height: 1.5; }
.pl-modal-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.pl-modal .btn.danger { background: var(--danger); color: #fff !important; border-color: var(--danger); }

/* ── Protección con contraseña (toggle con candado) ─────────────────── */
.protect-box {
    border: 1px solid var(--border); border-radius: 12px;
    padding: 14px 16px; background: var(--surface-2);
    transition: border-color .15s;
}
.protect-box.on { border-color: var(--accent); }
.protect-head {
    display: flex; align-items: center; gap: 13px;
    cursor: pointer; margin: 0;
}
/* El checkbox real queda oculto pero funcional; el candado es el indicador visual */
.protect-head input[type="checkbox"] { position: absolute; opacity: 0; width: 0; height: 0; }
.protect-ico {
    flex-shrink: 0; width: 42px; height: 42px; border-radius: 10px;
    display: grid; place-items: center;
    background: var(--surface); color: var(--muted);
    border: 1px solid var(--border); transition: all .15s;
}
.protect-box.on .protect-ico { background: var(--accent); color: #fff; border-color: var(--accent); }
.protect-ico .i-closed { display: none; }
.protect-box.on .protect-ico .i-open { display: none; }
.protect-box.on .protect-ico .i-closed { display: block; }
.protect-text { display: flex; flex-direction: column; gap: 2px; }
.protect-text strong { font-size: .98rem; }
.protect-field { margin-top: 12px; }

/* Insignia de candado en la pantalla de contraseña */
.lock-badge {
    width: 68px; height: 68px; border-radius: 50%;
    display: grid; place-items: center; margin: 0 auto 18px;
    background: var(--surface-2); color: var(--accent);
    border: 1px solid var(--border);
}

/* Insignia "con contraseña" en Mis enlaces */
.pub-lock { color: var(--accent); font-weight: 600; white-space: nowrap; }

/* Error de contraseña bien notorio: alerta roja + sacudida del formulario */
.pw-alert {
    display: flex; align-items: center; gap: 8px;
    margin-top: 12px; padding: 10px 12px; border-radius: 10px;
    background: rgba(220, 38, 38, .10);
    border: 1px solid var(--danger);
    color: var(--danger); font-weight: 600; font-size: .95rem;
}
.card.shake .password-field input { border-color: var(--danger); }
@media (prefers-reduced-motion: no-preference) {
    .card.shake { animation: plShake .4s ease; }
    @keyframes plShake {
        0%, 100% { transform: none; }
        20% { transform: translateX(-9px); }
        40% { transform: translateX(9px); }
        60% { transform: translateX(-5px); }
        80% { transform: translateX(5px); }
    }
}

/* Cuenta regresiva del panel de bloqueo (pantalla receptora) */
.blocked-count { color: var(--muted); font-size: 1rem; margin: 4px 0 0; }
.blocked-count strong { color: var(--accent); font-size: 1.15em; }
