/* ============================================================
   Pasaporte Undelta — paleta "Comunidad Undelta"
   salvia #8F9D68 · oliva #3F4A29 · navy #2A2F3D
   lima #A4C23A · crema #ECE4D1 · azul #2F5F8A
   ============================================================ */

:root {
    --sage:      #8f9d68;
    --olive:     #3f4a29;
    --navy:      #2a2f3d;
    --navy-2:    #343b4c;
    --lime:      #a4c23a;
    --lime-2:    #b7d24c;
    --cream:     #ece4d1;
    --cream-2:   #ddd2b8;
    --blue:      #2f5f8a;

    --ink:       #262a33;
    --ink-soft:  #5c6470;
    --line:      #e2dcca;

    --accent-grad: linear-gradient(120deg, #6f8a39 0%, #a4c23a 60%, #b7d24c 100%);

    --duration: 1.6s;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
    min-height: 100vh;
    font-family: 'Inter', system-ui, sans-serif;
    background: var(--sage);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 24px;
}

/* formas decorativas de la campaña */
body::before {
    content: "";
    position: fixed;
    top: -170px; left: -150px;
    width: 420px; height: 420px;
    border-radius: 50%;
    background: var(--olive);
    box-shadow: 0 0 0 36px rgba(63, 74, 41, 0.45);
    pointer-events: none;
}
body::after {
    content: "";
    position: fixed;
    right: -160px; bottom: -190px;
    width: 400px; height: 400px;
    border-radius: 50%;
    background: var(--navy);
    opacity: 0.9;
    pointer-events: none;
}

/* botón volver al portal */
.btn-portal {
    position: fixed; top: 18px; left: 18px; z-index: 60;
    border: 1px solid rgba(255, 255, 255, 0.45);
    background: rgba(42, 47, 61, 0.55); color: #fff;
    font-family: 'Inter', sans-serif; font-weight: 600; font-size: 12px;
    text-decoration: none; padding: 8px 14px; border-radius: 20px;
    backdrop-filter: blur(6px);
    transition: background 0.2s, transform 0.15s;
}
.btn-portal:hover { background: rgba(42, 47, 61, 0.8); transform: translateY(-1px); }

/* botón cerrar sesión (visible al estar logueado) */
.btn-logout {
    position: fixed; top: 18px; right: 18px; z-index: 60;
    border: 1px solid rgba(255, 255, 255, 0.45);
    background: rgba(42, 47, 61, 0.55); color: #fff;
    font-family: 'Inter', sans-serif; font-weight: 600; font-size: 12px;
    letter-spacing: 0.5px; padding: 8px 16px; border-radius: 20px; cursor: pointer;
    backdrop-filter: blur(6px);
    transition: background 0.2s, transform 0.15s;
}
.btn-logout:hover { background: rgba(42, 47, 61, 0.8); transform: translateY(-1px); }
.btn-logout[hidden] { display: none; }

/* ---------- ESCENARIO ---------- */
.stage {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 54px;
}

/* ---------- PANEL DE LOGIN (PC) ---------- */
.login-panel {
    width: 320px;
    flex-shrink: 0;
    padding: 34px 30px;
    border-radius: 18px;
    background: var(--cream);
    border: 1px solid var(--cream-2);
    box-shadow: 0 24px 54px rgba(38, 42, 51, 0.3);
    transition: opacity 0.6s ease, transform 0.7s ease,
                margin-right 0.9s cubic-bezier(0.6, 0, 0.2, 1),
                max-width 0.9s cubic-bezier(0.6, 0, 0.2, 1);
    max-width: 320px;
}

.login-head { margin-bottom: 24px; }
.login-logo { width: 138px; height: auto; margin-bottom: 22px; }
.login-head h2 { font-family: 'Poppins', sans-serif; font-size: 23px; font-weight: 700; color: var(--navy); }
.login-head p { font-size: 13px; color: var(--ink-soft); margin-top: 4px; }

.login-form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
    font-size: 11px; font-weight: 600; letter-spacing: 1px;
    text-transform: uppercase; color: var(--ink-soft);
}
.field input {
    width: 100%;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid var(--cream-2);
    background: #fff;
    color: var(--ink);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.field input::placeholder { color: #a7a392; }
.field input:focus {
    border-color: var(--lime);
    box-shadow: 0 0 0 3px rgba(164, 194, 58, 0.28);
}

.btn-login {
    position: relative;
    margin-top: 4px;
    padding: 13px;
    border: none;
    border-radius: 10px;
    background: var(--lime);
    color: var(--navy);
    font-size: 14px; font-weight: 700; letter-spacing: 0.6px;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.25s, background 0.25s;
    box-shadow: 0 8px 20px rgba(164, 194, 58, 0.4);
}
.btn-login:hover { background: var(--lime-2); transform: translateY(-1px); box-shadow: 0 10px 26px rgba(164, 194, 58, 0.5); }
.btn-login:active { transform: translateY(0); }
.btn-login:disabled { cursor: wait; filter: brightness(0.95); }

.btn-loader {
    display: none;
    width: 16px; height: 16px;
    border: 2px solid rgba(42, 47, 61, 0.35);
    border-top-color: var(--navy);
    border-radius: 50%;
    margin: 0 auto;
    animation: spin 0.7s linear infinite;
}
.btn-login.loading .btn-text { display: none; }
.btn-login.loading .btn-loader { display: block; }
@keyframes spin { to { transform: rotate(360deg); } }

.login-msg { min-height: 16px; font-size: 12px; text-align: center; color: #c0492f; }
.login-msg.ok { color: #5c7a1f; }
.login-foot { text-align: center; font-size: 12.5px; color: var(--ink-soft); margin-top: 2px; }
.login-foot a { color: var(--blue); font-weight: 600; text-decoration: none; }
.login-foot a:hover { text-decoration: underline; }

/* al abrir, el panel de PC se retira para centrar el libro */
.stage.opened .login-panel {
    opacity: 0;
    transform: translateX(-40px);
    max-width: 0;
    margin-right: -54px;
    padding-left: 0; padding-right: 0;
    pointer-events: none;
    overflow: hidden;
}

/* el login y el botón "crear cuenta" de la tapa: ocultos en PC */
.cover-login,
.btn-crear { display: none; }

/* ---------- ESCENA 3D ---------- */
.scene {
    perspective: 2600px;
    perspective-origin: 50% 42%;
    flex-shrink: 0;
}

.passport {
    position: relative;
    width: 360px;
    aspect-ratio: 360 / 510;
    transform-style: preserve-3d;
    transition: transform var(--duration) cubic-bezier(0.25, 0.9, 0.3, 1);
}
.passport.open { transform: translateX(180px); }

/* ---------- LIBRO DE HOJAS ---------- */
.book {
    position: absolute;
    inset: 0;
    transform-style: preserve-3d;
}

.leaf {
    position: absolute;
    inset: 0;
    transform-origin: left center;
    transform-style: preserve-3d;
    /* Cada hoja a una micro-profundidad distinta (--leaf-z, seteada por JS) para
       que NUNCA queden co-planares: así iOS/Android no hacen z-fighting (no se
       ven las páginas superpuestas). El translateZ es estático → no se anima. */
    transform: translateZ(var(--leaf-z, 0px));
    transition: transform var(--duration) cubic-bezier(0.25, 0.9, 0.3, 1);
}
.leaf.flipped { transform: translateZ(var(--leaf-z, 0px)) rotateY(-180deg); }

.leaf-face,
.leaf-base {
    position: absolute;
    inset: 0;
    border-radius: 4px 12px 12px 4px;
    overflow: hidden;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}
.leaf-face.back { transform: rotateY(180deg); }
/* la página base, debajo de todo, es la ÚNICA que proyecta la sombra del
   pasaporte abierto (evita que se sumen las sombras de cada hoja). */
.leaf-base {
    z-index: 0;
    /* Bien atrás en profundidad para que no haga z-fighting con las hojas. */
    transform: translateZ(-20px);
    box-shadow:
        inset 0 0 0 1px var(--line),
        0 16px 40px rgba(38, 42, 51, 0.18);
}

/* ---------- PÁGINAS (caras de papel) ---------- */
.page {
    background: linear-gradient(160deg, #ffffff 0%, #f7f4ea 100%);
    /* sin sombra de caída por hoja (se acumulaban y formaban un bloque);
       la sombra del pasaporte la proyecta una sola capa (cubierta / base). */
    box-shadow: inset 0 0 0 1px var(--line);
    padding: 26px 26px 22px;
    display: flex;
    flex-direction: column;
    color: var(--ink);
}

/* franja de marca junto al lomo (izq. en frentes, der. en dorsos) */
.leaf-face.front.page::before,
.leaf-base.page::before {
    content: ""; position: absolute; top: 0; left: 0;
    width: 3px; height: 100%; background: var(--accent-grad); z-index: 3;
}
.leaf-face.back.page::before {
    content: ""; position: absolute; top: 0; right: 0;
    width: 3px; height: 100%; background: var(--accent-grad); z-index: 3;
}

.page-watermark {
    position: absolute;
    top: 52%; left: 52%;
    transform: translate(-50%, -50%) rotate(-16deg);
    font-family: 'Poppins', sans-serif;
    font-size: 58px; font-weight: 700; letter-spacing: 4px;
    color: rgba(63, 74, 41, 0.06);
    pointer-events: none; user-select: none; white-space: nowrap;
}

.page-header {
    display: flex; align-items: center; justify-content: space-between;
    border-bottom: 1px solid var(--line);
    padding-bottom: 12px; margin-bottom: 18px;
    position: relative; z-index: 1;
}
.page-header h2 { font-family: 'Poppins', sans-serif; font-size: 17px; font-weight: 600; color: var(--navy); }
.page-header h2::after {
    content: ""; display: block; width: 42px; height: 3px;
    margin-top: 6px; border-radius: 3px; background: var(--accent-grad);
}
.page-flag {
    font-size: 10px; font-weight: 700; letter-spacing: 1px;
    text-transform: uppercase; color: var(--blue);
}

.photo-row { display: flex; gap: 16px; margin-bottom: 18px; position: relative; z-index: 1; }
.passport-photo {
    width: 104px; height: 104px; flex-shrink: 0;
    align-self: flex-start;       /* no se estira con el alto del bloque de datos */
    border-radius: 50%; padding: 1px;
    background: var(--accent-grad);
    box-shadow: 0 6px 16px rgba(164, 194, 58, 0.35);
}
/* avatar circular: rellena el círculo recortando lo que sobra */
.passport-photo img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 100%;
}
.passport-id { display: flex; flex-direction: column; justify-content: center; gap: 5px; }
.id-label { font-size: 10px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--ink-soft); }
.id-value { font-family: 'Inter', monospace; font-size: 19px; font-weight: 700; letter-spacing: 1px; color: var(--navy); }
.id-role {
    margin-top: 4px; align-self: flex-start;
    font-size: 10.5px; text-transform: uppercase; letter-spacing: 1px;
    background: var(--navy); color: var(--lime-2);
    padding: 4px 11px; border-radius: 20px; font-weight: 600;
}

.data-list { position: relative; z-index: 1; }
.data-item { display: flex; flex-direction: column; padding: 8px 0; border-bottom: 1px solid var(--line); }
.data-item dt { font-size: 10px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--ink-soft); }
.data-item dd { font-size: 15px; font-weight: 500; color: var(--ink); margin-top: 2px; }

/* página "Comunidad" */
.welcome { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: 16px; margin-top: 10px; text-align: center; }
.welcome-mark { width: 56px; height: auto; }
.welcome p { font-size: 14px; line-height: 1.6; color: var(--ink); }
.welcome strong { color: #5c7a1f; }
.welcome-cta {
    position: relative; z-index: 5;   /* por encima de la franja del lomo */
    margin-top: 10px; display: inline-flex; align-items: center; justify-content: center;
    text-decoration: none; cursor: pointer;
    background: var(--accent-grad); color: var(--navy);
    font-family: 'Poppins', sans-serif; font-weight: 700; font-size: 14px;
    padding: 11px 22px; border-radius: 10px;
    box-shadow: 0 8px 20px rgba(164, 194, 58, 0.45);
    transition: transform 0.15s, box-shadow 0.2s, filter 0.2s;
}
.welcome-cta:hover { transform: translateY(-2px); filter: brightness(1.05); box-shadow: 0 11px 26px rgba(164, 194, 58, 0.55); }

/* sello decorativo */
.stamp {
    position: relative; z-index: 1;
    align-self: center; margin-top: 24px;
    font-family: 'Poppins', sans-serif; font-weight: 700; letter-spacing: 3px;
    color: rgba(47, 95, 138, 0.7);
    border: 3px solid rgba(47, 95, 138, 0.5);
    border-radius: 10px; padding: 10px 22px;
    transform: rotate(-12deg);
}

/* detalle del evento */
.visa-desc {
    position: relative; z-index: 1;
    margin-top: 12px; font-size: 13px; line-height: 1.55; color: var(--ink-soft);
    max-width: 62%;            /* deja espacio para la estampa */
}

/* ---------- VISADOS: estampa de asistencia (superpuesta) ---------- */
.visa-stamp {
    position: absolute; z-index: 2;
    right: 18px; bottom: 44px;
    width: 132px; height: 132px; border-radius: 50%;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    color: rgba(47, 95, 138, 0.82);
    border: 3px double rgba(47, 95, 138, 0.68);
    box-shadow: inset 0 0 0 6px rgba(47, 95, 138, 0.07);
    font-family: 'Poppins', sans-serif; text-align: center;
    opacity: 0.9;
    pointer-events: none;
}
.visa-stamp .vs-top  { font-size: 10px; font-weight: 600; letter-spacing: 3px; }
.visa-stamp .vs-main { font-size: 23px; font-weight: 700; letter-spacing: 2px; }
.visa-stamp .vs-date { font-size: 11px; letter-spacing: 1px; }

/* acción de sellar por QR (evento con formulario) */
.visa-accion {
    position: absolute; z-index: 2;
    left: 50%; bottom: 36px; transform: translateX(-50%);
    width: calc(100% - 52px); max-width: 280px;
    display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.visa-escanear {
    width: 100%;
    display: inline-flex; align-items: center; justify-content: center; gap: 9px;
    cursor: pointer; border: none;
    background: var(--accent-grad); color: var(--navy);
    font-family: 'Poppins', sans-serif; font-weight: 700; font-size: 14.5px;
    padding: 13px 16px; border-radius: 12px;
    box-shadow: 0 8px 20px rgba(164, 194, 58, 0.45);
    transition: transform 0.15s, box-shadow 0.2s, filter 0.2s;
}
.visa-escanear:hover { transform: translateY(-2px); filter: brightness(1.05); box-shadow: 0 11px 26px rgba(164, 194, 58, 0.55); }
.visa-escanear:active { transform: translateY(0); }
.visa-escanear .vs-cam { display: inline-flex; }
.visa-link { font-size: 11.5px; color: var(--ink-soft); text-decoration: underline; }
.visa-link:hover { color: var(--navy); }

/* botón para sellar (evento con formulario) */
.visa-sellar {
    position: absolute; z-index: 2;
    left: 50%; bottom: 40px; transform: translateX(-50%);
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    width: calc(100% - 52px); max-width: 260px;
    text-decoration: none; text-align: center;
    background: var(--accent-grad); color: var(--navy);
    font-family: 'Poppins', sans-serif; font-weight: 700; font-size: 15px;
    padding: 12px 16px; border-radius: 12px;
    box-shadow: 0 8px 20px rgba(164, 194, 58, 0.45);
    transition: transform 0.15s, box-shadow 0.2s, filter 0.2s;
}
.visa-sellar:hover { transform: translateX(-50%) translateY(-2px); filter: brightness(1.05); box-shadow: 0 11px 26px rgba(164, 194, 58, 0.55); }
.visa-sellar .vs-ic { font-size: 17px; }
.visa-sellar small { font-weight: 500; font-size: 10.5px; color: rgba(38, 42, 51, 0.7); }

/* visado sin sellar */
.visa-pending {
    position: absolute; z-index: 2;
    right: 18px; bottom: 44px;
    width: 132px; height: 132px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    text-align: center;
    color: rgba(38, 42, 51, 0.32);
    border: 2px dashed rgba(38, 42, 51, 0.25);
    pointer-events: none;
}
.visa-pending span { font-family: 'Poppins', sans-serif; font-weight: 700; font-size: 16px; letter-spacing: 2px; line-height: 1.2; }

/* ---------- interior de la tapa: texto ---------- */
.cover-inside-text {
    position: relative; z-index: 1;
    display: flex; flex-direction: column; align-items: center; gap: 16px;
    text-align: center; padding: 0 8px;
}
.cover-inside-mark { width: 54px; height: auto; opacity: 0.95; }
.cover-inside-text p { font-size: 13px; line-height: 1.6; color: rgba(255, 255, 255, 0.8); }
.cover-inside-text strong { color: var(--lime-2); }
.cover-inside-text .cover-back-note { font-size: 11px; letter-spacing: 0.5px; color: rgba(255, 255, 255, 0.4); }

.base-note { position: relative; z-index: 1; flex: 1; font-size: 13px; color: var(--ink-soft); margin-top: 4px; }
.page-footer { position: relative; z-index: 1; margin-top: auto; }
.mrz {
    display: block; font-family: 'Inter', monospace;
    font-size: 12px; font-weight: 600; letter-spacing: 2px; color: var(--ink-soft);
    background: #f4f1e6; border: 1px solid var(--line); border-radius: 6px;
    padding: 9px 10px; word-break: break-all; line-height: 1.5;
}

.page-num {
    position: absolute; bottom: 14px; right: 16px; z-index: 1;
    font-family: 'Poppins', sans-serif; font-size: 12px; font-weight: 600; color: var(--cream-2);
}

/* ---------- CUBIERTA (frente) ---------- */
.cover-front {
    background: radial-gradient(circle at 50% 42%, #343b4c 0%, var(--navy) 60%, #20242f 100%);
    box-shadow: inset 0 0 80px rgba(0, 0, 0, 0.35), 0 12px 30px rgba(38, 42, 51, 0.2);
    display: flex; flex-direction: column; align-items: center; justify-content: space-between;
    padding: 46px 30px 40px;
    color: #fff; text-align: center;
}
.cover-frame {
    position: absolute; inset: 16px;
    border: 1.5px solid rgba(255, 255, 255, 0.14);
    border-radius: 4px 8px 8px 4px; pointer-events: none;
}
.cover-frame::after {
    content: ""; position: absolute; inset: 5px;
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 3px 6px 6px 3px;
}
.cover-title { position: relative; z-index: 1; display: flex; flex-direction: column; gap: 6px; }
.cover-title .t-main { font-family: 'Poppins', sans-serif; font-size: 28px; font-weight: 700; letter-spacing: 4px; color: #fff; }
.cover-title .t-sub  { font-family: 'Poppins', sans-serif; font-size: 21px; font-weight: 700; letter-spacing: 9px; color: var(--lime); }

.globe { position: relative; z-index: 1; width: 200px; height: 200px; opacity: 0.92; filter: drop-shadow(0 0 18px rgba(164, 194, 58, 0.2)); }
.globe-lines * { stroke: rgba(255, 255, 255, 0.22); stroke-width: 1; fill: none; }
.globe-lines circle { stroke: var(--lime); stroke-width: 1.5; }

.cover-mark { position: relative; z-index: 1; width: 52px; height: auto; filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.45)); }

/* cara interior de la cubierta (dorso) */
.cover-inside {
    background: linear-gradient(160deg, #2f3543, #20242f);
    display: flex; align-items: center; justify-content: center; padding: 30px 26px;
}
.guilloche {
    position: absolute; inset: 18px; border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.07);
    background: repeating-linear-gradient(45deg, rgba(164, 194, 58, 0.06) 0 10px, rgba(47, 95, 138, 0.06) 10px 20px);
}
.cover-back-note { position: relative; font-size: 11px; letter-spacing: 0.5px; color: rgba(255, 255, 255, 0.45); text-align: center; }

/* ---------- PAGINADOR (flechas) ---------- */
.pager {
    position: fixed;
    bottom: 26px; left: 50%;
    transform: translateX(-50%);
    display: flex; gap: 18px;
    z-index: 50;
    opacity: 0; pointer-events: none;
    transition: opacity 0.5s ease 0.6s;
}
.pager.visible { opacity: 1; pointer-events: auto; }
.nav-btn {
    width: 52px; height: 52px;
    border: none; border-radius: 50%;
    background: var(--lime); color: var(--navy);
    font-size: 26px; font-weight: 700; line-height: 1;
    cursor: pointer;
    box-shadow: 0 8px 22px rgba(38, 42, 51, 0.35);
    transition: transform 0.15s, background 0.2s, opacity 0.2s;
}
.nav-btn:hover { background: var(--lime-2); transform: translateY(-2px); }
.nav-btn:active { transform: translateY(0); }
.nav-btn:disabled { opacity: 0.35; cursor: default; transform: none; }

/* botón "Escanear QR" en la barra inferior (entre las flechas) */
.scan-btn {
    display: inline-flex; align-items: center; gap: 8px;
    height: 52px; padding: 0 20px; border: none; border-radius: 26px;
    cursor: pointer;
    background: var(--accent-grad); color: var(--navy);
    font-family: 'Poppins', sans-serif; font-weight: 700; font-size: 14px;
    box-shadow: 0 8px 22px rgba(164, 194, 58, 0.45);
    transition: transform 0.15s, box-shadow 0.2s, filter 0.2s;
}
.scan-btn[hidden] { display: none; }
.scan-btn:hover { transform: translateY(-2px); filter: brightness(1.05); box-shadow: 0 11px 26px rgba(164, 194, 58, 0.55); }
.scan-btn:active { transform: translateY(0); }

/* botón "Crear evento" (flotante, página de bienvenida) */
.crear-btn {
    display: inline-flex; align-items: center; gap: 8px;
    height: 52px; padding: 0 22px; border-radius: 26px; cursor: pointer; text-decoration: none;
    background: var(--navy); color: #fff;
    font-family: 'Poppins', sans-serif; font-weight: 700; font-size: 14px;
    box-shadow: 0 8px 22px rgba(38, 42, 51, 0.4);
    transition: transform 0.15s, background 0.2s;
}
.crear-btn[hidden] { display: none; }
.crear-btn:hover { background: #343b4c; transform: translateY(-2px); }

.welcome-aviso { font-size: 12px; color: var(--blue); font-weight: 600; margin-top: 6px; }

/* ---------- MODAL: lector de QR (cámara) ---------- */
.qr-modal {
    position: fixed; inset: 0; z-index: 100;
    display: none; align-items: center; justify-content: center;
    background: rgba(38, 42, 51, 0.78);
    padding: 20px;
}
.qr-modal.open { display: flex; }
.qr-box {
    position: relative;
    width: min(92vw, 380px);
    background: #fff; border-radius: 18px; padding: 22px 20px 18px;
    text-align: center; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4);
}
.qr-box h3 {
    font-family: 'Poppins', sans-serif; font-size: 17px; color: var(--navy);
    margin-bottom: 14px;
}
.qr-reader {
    width: 100%; border-radius: 12px; overflow: hidden;
    background: #000; min-height: 240px;
}
.qr-reader video { display: block; width: 100% !important; height: auto !important; }
.qr-close {
    position: absolute; top: 8px; right: 12px; z-index: 3;
    width: 38px; height: 38px; border-radius: 50%;
    border: none; background: rgba(255, 255, 255, 0.92); cursor: pointer;
    font-size: 24px; line-height: 1; color: var(--ink-soft);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
    transition: color 0.2s, background 0.2s;
}
.qr-close:hover { color: var(--navy); }
.qr-msg { font-size: 12.5px; color: var(--ink-soft); margin-top: 14px; line-height: 1.5; }

/* ============================================================
   RESPONSIVE — Celular: pasaporte centrado, con margen (se ve el librito)
   ============================================================ */
@media (max-width: 860px) {
    body { overflow: hidden; padding: 20px 16px; }

    /* en celular el login va en la tapa: ocultamos el panel lateral */
    .login-panel { display: none; }

    .stage { width: 100%; gap: 0; }

    .scene {
        width: 100%;
        display: flex;
        justify-content: center;
        perspective: 2200px;
        perspective-origin: 50% 45%;
    }

    /* no ocupa toda la pantalla: deja ver el fondo alrededor.
       el cap en dvh evita que se corte en alto en pantallas bajas. */
    .passport {
        width: min(90vw, 66dvh, 400px);
        height: auto;
        aspect-ratio: 360 / 510;
    }

    /* la tapa se abre dejando la página centrada (sin desplazar el conjunto) */
    .passport.open { transform: translateX(0); }

    .cover-frame { inset: 13px; }

    /* mostramos el login y el botón "crear cuenta" sobre la tapa */
    .cover-login { display: flex; width: 100%; max-width: 280px; gap: 12px; }
    .cover-login .field input {
        background: rgba(0, 0, 0, 0.55);
        border: 1px solid rgba(255, 255, 255, 0.35);
        color: #fff;
        text-align: center;
        letter-spacing: 1px;
        padding: 12px;
    }
    .cover-login .field input::placeholder { color: rgba(255, 255, 255, 0.6); }
    .cover-login .login-msg { color: #ffb0a0; }
    .cover-login .login-msg.ok { color: var(--lime-2); }

    .btn-crear {
        display: block;
        position: absolute; top: 14px; right: 14px; z-index: 2;
        background: transparent;
        border: 1px solid rgba(255, 255, 255, 0.5);
        color: #fff;
        font-size: 10px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase;
        padding: 7px 11px; border-radius: 8px; cursor: pointer;
        transition: background 0.2s, border-color 0.2s;
    }
    .btn-crear:hover { background: rgba(255, 255, 255, 0.12); border-color: #fff; }

    .cover-front { justify-content: space-between; padding: 38px 22px 24px; }
    .globe { width: min(46vw, 180px); height: auto; }
    .cover-mark { width: 50px; }

    .pager { bottom: 18px; }

    /* --- Página de datos compacta en celular ---
       Así entra completa aunque la escuela (u otro dato) ocupe 2 líneas,
       sin que se corte en pantallas más bajas. */
    .page { padding: 20px 22px 18px; }
    .page-header { padding-bottom: 9px; margin-bottom: 12px; }
    .page-header h2 { font-size: 16px; }
    .photo-row { gap: 13px; margin-bottom: 12px; }
    .passport-photo { width: 84px; height: 84px; }
    .id-value { font-size: 17px; }
    .id-role { padding: 3px 9px; }
    .data-item { padding: 6px 0; }
    .data-item dd { font-size: 14px; }
    .page-watermark { font-size: 50px; }
}

@media (max-width: 480px) {
    .cover-front { padding: 32px 20px 22px; }
    .cover-title .t-main { font-size: 24px; letter-spacing: 3px; }
    .cover-title .t-sub  { font-size: 18px; letter-spacing: 6px; }
    .globe { width: 150px; height: 150px; }
    .cover-login .field input { padding: 11px; }
}

/* ============================================================
   Sesión ya iniciada: no mostramos ningún formulario de login
   (el pasaporte se abre solo). Así nunca aparece "Ingresar".
   ============================================================ */
body.sesion-activa .login-panel,
body.sesion-activa .cover-login,
body.sesion-activa .btn-crear {
    display: none !important;
}

/* ============================================================
   OPTIMIZACIÓN DE ANIMACIONES (rendimiento móvil)
   ============================================================ */

/* El flip del pasaporte se anima por GPU vía rotateY/translateX.
   IMPORTANTE: NO usar will-change ni translateZ en estos elementos: en celulares
   (sobre todo iOS Safari y algunos Android) "aplana" el contexto preserve-3d y
   se ven todas las páginas superpuestas a la vez. Sólo reforzamos el 3D con el
   prefijo -webkit- para navegadores viejos. */
.passport,
.leaf {
    -webkit-transform-style: preserve-3d;
}

/* Quita el retardo táctil de ~300 ms en botones/links (respuesta inmediata). */
.btn-login, .btn-logout, .btn-portal, .btn-crear, .btn-crear-form,
.nav-btn, .crear-btn, .scan-btn, .welcome-cta, .visa-escanear, .visa-sellar {
    touch-action: manipulation;
}

/* Respetá la preferencia del sistema "reducir movimiento"
   (accesibilidad + ahorro de batería/CPU en gama baja). */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
    .globe-lines { animation: none !important; }
}

/* ============================================================
   Modal: Pasaporte completo → pre-inscripción a carreras
   ============================================================ */
.preinsc-overlay {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(20, 26, 16, 0.62);
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .28s ease, visibility .28s ease;
}
.preinsc-overlay.open { opacity: 1; visibility: visible; pointer-events: auto; }

.preinsc-modal {
    position: relative;
    width: 100%;
    max-width: 420px;
    background: #ffffff;
    border-radius: 22px;
    padding: 34px 28px 26px;
    text-align: center;
    box-shadow: 0 24px 60px rgba(20, 26, 16, 0.42);
    transform: translateY(24px) scale(0.94);
    opacity: 0;
    transition: transform .34s cubic-bezier(.2,.8,.2,1), opacity .34s ease;
}
.preinsc-overlay.open .preinsc-modal { transform: translateY(0) scale(1); opacity: 1; }

.preinsc-x {
    position: absolute; top: 12px; right: 14px;
    width: 34px; height: 34px; border: 0; background: transparent;
    font-size: 26px; line-height: 1; color: #9aa0a6; cursor: pointer;
    border-radius: 50%; transition: background .15s, color .15s;
}
.preinsc-x:hover { background: #f1f0ea; color: #3f4a29; }

.preinsc-ico { line-height: 0; margin-bottom: 10px; color: #4e5f28; }
.preinsc-ico svg { width: 54px; height: 54px; }
.preinsc-title {
    font-family: 'Poppins', sans-serif;
    font-size: 24px; font-weight: 800; color: #2a2f3d;
    margin-bottom: 12px; line-height: 1.15;
}
.preinsc-text { font-size: 15px; line-height: 1.55; color: #4a4f59; margin-bottom: 12px; }
.preinsc-text strong { color: #3f4a29; }

/* CTA destacado (verde de la marca) */
.preinsc-cta {
    display: block;
    width: 100%;
    margin: 22px 0 12px;
    padding: 15px 18px;
    background: linear-gradient(135deg, #6b8e23, #4e5f28);
    color: #fff;
    font-size: 16px; font-weight: 800; letter-spacing: .2px;
    text-decoration: none;
    border-radius: 14px;
    box-shadow: 0 10px 24px rgba(78, 95, 40, 0.4);
    transition: transform .15s ease, box-shadow .2s ease, filter .2s ease;
}
.preinsc-cta:hover { filter: brightness(1.06); transform: translateY(-2px); box-shadow: 0 14px 30px rgba(78, 95, 40, 0.5); }
.preinsc-cta:active { transform: translateY(0); }

.preinsc-cerrar {
    border: 0; background: transparent; color: #8a8f98;
    font-size: 14px; font-weight: 600; cursor: pointer;
    padding: 8px 14px; border-radius: 10px;
    transition: background .15s, color .15s;
}
.preinsc-cerrar:hover { background: #f1f0ea; color: #3f4a29; }

@media (max-width: 480px) {
    .preinsc-modal { padding: 30px 20px 22px; border-radius: 18px; }
    .preinsc-title { font-size: 21px; }
    .preinsc-text { font-size: 14.5px; }
    .preinsc-cta { font-size: 15px; padding: 14px; }
}
@media (prefers-reduced-motion: reduce) {
    .preinsc-overlay, .preinsc-modal { transition: opacity .001ms !important; }
    .preinsc-modal { transform: none !important; }
}
