html.auth-locked body > *:not(#auth-gate):not(#splash):not(#auth-closing) { display: none !important; }
html.auth-locked body {
    background: #101914;
}

:root {
    --auth-frame-edge-fill: linear-gradient(
        180deg,
        #65684f 0%,
        #595c45 12%,
        #51543d 25%,
        #464833 55%,
        #3e402b 78%,
        #393c26 100%
    );
}

#auth-gate {
    --auth-ink: #edf4ee;
    --auth-muted: #a5b2ae;
    --auth-line: rgba(195, 220, 207, 0.18);
    position: fixed;
    inset: 0;
    z-index: 99000;
    display: grid;
    place-items: safe center;
    overflow-x: hidden;
    overflow-y: auto;
    background:
        radial-gradient(ellipse at center, rgba(103, 105, 78, 0.72), rgba(54, 60, 43, 0.82) 48%, rgba(12, 18, 14, 0.98) 100%),
        var(--auth-frame-edge-fill);
    color: var(--auth-ink);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

#auth-gate[hidden] { display: none; }
#auth-gate *, #auth-gate *::before, #auth-gate *::after { box-sizing: border-box; }

.auth-stage {
    position: absolute;
    top: 50%;
    left: 50%;
    display: grid;
    place-items: center;
    width: 67.0742dvh;
    height: 100dvh;
    flex: 0 0 auto;
    transform: translate(-50%, -50%);
    background: url("../splash/auth-closing-open.png") center / 100% 100% no-repeat;
    box-shadow:
        0 0 0 1px rgba(231, 236, 212, 0.72),
        0 0 0 5px rgba(9, 15, 12, 0.92),
        0 0 0 7px rgba(190, 202, 166, 0.62),
        0 0 0 11px rgba(8, 14, 11, 0.72),
        0 24px 70px rgba(0, 0, 0, 0.72);
}

.auth-stage::after {
    position: absolute;
    inset: 0;
    border: 1px solid rgba(4, 9, 7, 0.72);
    content: "";
    pointer-events: none;
}

#auth-closing {
    position: fixed;
    inset: 0;
    z-index: 100001;
    display: grid;
    place-items: center;
    overflow: hidden;
    background: var(--auth-frame-edge-fill);
}

.auth-closing-stage {
    position: absolute;
    top: 50%;
    left: 50%;
    display: block;
    width: 67.0742vh;
    width: 67.0742dvh;
    height: 100vh;
    height: 100dvh;
    aspect-ratio: 768 / 1145;
    transform: translate(-50%, -50%);
}

.auth-closing-base,
.auth-closing-door {
    position: absolute;
    inset: 0;
    z-index: 0;
    display: block;
    width: 100%;
    height: 100%;
    object-fit: fill;
    pointer-events: none;
}

.auth-closing-door {
    z-index: 1;
    animation: auth-fermeture-porte 1800ms cubic-bezier(0.65, 0, 0.35, 1) both;
    will-change: transform;
}

.auth-closing-stage { overflow: hidden; }

.auth-porte {
    position: absolute;
    inset: 0;
    z-index: 5;
    overflow: hidden;
    pointer-events: none;
}

.auth-porte img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: fill;
    transform: translateY(0);
    transition: transform 1800ms cubic-bezier(0.65, 0, 0.35, 1);
    will-change: transform;
}

.auth-porte.ouverte img { transform: translateY(100%); }

@media (prefers-reduced-motion: reduce) {
    .auth-porte img { transition: none; }
}

@keyframes auth-fermeture-porte {
    from { transform: translateX(-100%); }
    to { transform: translateX(0); }
}

#auth-gate .auth-card {
    position: relative;
    width: min(62%, 400px, calc(100vw - 32px));
    max-height: min(65dvh, calc(100dvh - 24px));
    margin: 0;
    padding: clamp(12px, 2.2dvh, 21px) clamp(14px, 2.5dvh, 24px);
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-color: rgba(168, 201, 178, 0.52) rgba(5, 12, 12, 0.3);
    scrollbar-width: thin;
    border: 2px solid rgba(121, 145, 128, 0.82);
    border-top-color: #9cad9d;
    border-left-color: #728579;
    border-right-color: #43544a;
    border-bottom-color: #35443b;
    border-radius: 21px;
    background:
        linear-gradient(135deg, rgba(197, 219, 198, 0.62) 0 1px, transparent 1.5px) 9px 9px / 18px 18px no-repeat,
        linear-gradient(225deg, rgba(197, 219, 198, 0.5) 0 1px, transparent 1.5px) calc(100% - 9px) 9px / 18px 18px no-repeat,
        linear-gradient(45deg, rgba(197, 219, 198, 0.45) 0 1px, transparent 1.5px) 9px calc(100% - 9px) / 18px 18px no-repeat,
        linear-gradient(315deg, rgba(197, 219, 198, 0.45) 0 1px, transparent 1.5px) calc(100% - 9px) calc(100% - 9px) / 18px 18px no-repeat,
        linear-gradient(180deg, transparent, rgba(108, 214, 219, 0.3), transparent) 6px center / 1px 58% no-repeat,
        linear-gradient(180deg, transparent, rgba(108, 214, 219, 0.22), transparent) calc(100% - 6px) center / 1px 58% no-repeat,
        radial-gradient(ellipse at 100% 0%, rgba(68, 117, 84, 0.12), transparent 44%),
        linear-gradient(155deg, rgba(23, 31, 28, 0.94), rgba(11, 17, 18, 0.96) 66%);
    box-shadow:
        0 30px 90px rgba(0, 0, 0, 0.58),
        0 0 0 4px rgba(7, 13, 11, 0.86),
        0 0 0 6px rgba(143, 163, 147, 0.32),
        0 0 50px rgba(32, 113, 92, 0.13),
        inset 0 0 0 4px rgba(4, 10, 9, 0.48),
        inset 0 0 0 5px rgba(157, 179, 162, 0.12),
        inset 0 1px rgba(255, 255, 255, 0.07);
    color: var(--auth-ink);
}

#auth-gate .auth-card::before {
    position: absolute;
    top: 7px;
    right: 12px;
    left: 12px;
    height: 2px;
    border-radius: 2px;
    background: linear-gradient(90deg, #17358d 0 33.3%, #f3f1e7 33.3% 66.6%, #c91d31 66.6%);
    box-shadow: 0 0 18px rgba(98, 208, 221, 0.45);
    content: "";
}

#auth-gate .auth-card::after {
    position: absolute;
    top: 23px;
    right: 27px;
    width: 58px;
    height: 58px;
    border: 1px solid rgba(164, 207, 176, 0.1);
    border-radius: 50%;
    background:
        radial-gradient(circle, transparent 0 34%, rgba(147, 205, 164, 0.08) 35% 36%, transparent 37%),
        repeating-conic-gradient(from 0deg, rgba(147, 205, 164, 0.1) 0deg 1deg, transparent 1deg 30deg);
    opacity: 0.58;
    pointer-events: none;
}

#auth-gate .auth-kicker {
    position: relative;
    z-index: 1;
    margin: 0 0 9px;
    color: #a8c9b2;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.2em;
    text-align: center;
}

#auth-gate h1 {
    position: relative;
    margin: 0 0 9px;
    color: #f1f5ef;
    font-size: clamp(1.55rem, 6vw, 1.9rem);
    letter-spacing: 0.11em;
    line-height: 1.2;
    text-align: center;
    text-transform: uppercase;
    text-shadow: 0 0 24px rgba(114, 223, 228, 0.15);
}

#auth-gate p {
    margin: 0 0 14px;
    color: var(--auth-muted);
    font-size: 0.94rem;
    line-height: 1.6;
}

#auth-gate .auth-intro {
    margin: 0 auto 23px;
    text-align: center;
}

#auth-gate .auth-intro strong { color: #dce8df; }

#auth-gate .auth-etat {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    min-height: 38px;
    margin: 20px 0 0;
    border: 1px solid var(--auth-line);
    border-radius: 8px;
    background: rgba(5, 12, 12, 0.34);
    color: #a8d7b4;
    font-size: 0.8rem;
    letter-spacing: 0.04em;
}

#auth-gate .auth-etat[hidden] { display: none; }

#auth-gate .auth-etat::before {
    width: 7px;
    height: 7px;
    flex: 0 0 7px;
    border-radius: 50%;
    background: #70dc9c;
    box-shadow: 0 0 10px rgba(112, 220, 156, 0.8);
    content: "";
}

#auth-gate label {
    display: block;
    margin: 15px 0 7px;
    color: #dce8df;
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.055em;
    text-transform: uppercase;
}

#auth-gate input {
    width: 100%;
    padding: 13px 14px;
    border: 1px solid rgba(195, 220, 207, 0.25);
    border-radius: 9px;
    outline: none;
    background: rgba(5, 12, 13, 0.62);
    color: #f4f7f2;
    font: inherit;
    font-size: 1rem;
    transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

#auth-gate input:focus {
    border-color: #75cdd0;
    background: rgba(5, 12, 13, 0.88);
    box-shadow: 0 0 0 3px rgba(80, 194, 199, 0.14), 0 0 20px rgba(80, 194, 199, 0.08);
}

#auth-gate .auth-password-field { position: relative; }
#auth-gate .auth-password-field input { padding-right: 92px; }

#auth-gate .auth-password-toggle {
    position: absolute;
    top: 50%;
    right: 8px;
    transform: translateY(-50%);
    padding: 6px 8px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: #c3d6c9;
    font: inherit;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
}

#auth-gate .auth-password-toggle:hover { background: rgba(183, 219, 194, 0.1); color: #fff; }
#auth-gate .auth-password-toggle:focus-visible { outline: 2px solid #75cdd0; }

#auth-gate .auth-message {
    min-height: 1.4em;
    margin: 12px 0 0;
    color: #ff9a91;
    font-size: 0.86rem;
    font-weight: 600;
}

#auth-gate .auth-message:empty { display: none; }

#auth-gate button[type="submit"] {
    width: 100%;
    margin-top: 15px;
    padding: 14px 16px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 9px;
    background: linear-gradient(110deg, #922228, #bd3033 55%, #a3222a);
    box-shadow: 0 10px 24px rgba(120, 25, 30, 0.28), inset 0 1px rgba(255, 255, 255, 0.12);
    color: #fff;
    font: inherit;
    font-size: 0.95rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    cursor: pointer;
    transition: filter 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

#auth-gate button[type="submit"]:hover:not(:disabled) {
    transform: translateY(-1px);
    filter: brightness(1.12);
    box-shadow: 0 12px 28px rgba(120, 25, 30, 0.36), 0 0 18px rgba(177, 52, 53, 0.17);
}

#auth-gate button[type="submit"]:focus-visible {
    outline: 2px solid #83d8d8;
    outline-offset: 3px;
}

#auth-gate button[type="submit"]:disabled { opacity: 0.65; cursor: wait; }

#auth-gate .auth-pied {
    margin: 20px 0 0;
    padding-top: 16px;
    border-top: 1px solid var(--auth-line);
    color: #a5b2ae;
    font-size: 0.82rem;
}

#auth-gate .auth-pied a {
    color: #f08e86;
    font-weight: 700;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}

#auth-gate .auth-pied a:hover { color: #ffc0ad; }

#auth-logout {
    position: fixed;
    right: 10px;
    bottom: 10px;
    z-index: 900;
    padding: 7px 12px;
    border: 1px solid rgba(11, 34, 64, 0.25);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
    color: #0b2240;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
}

#auth-logout:hover { border-color: #a82025; background: #fff; color: #a82025; }

.modal-toolbar .auth-toolbar-logout {
    margin-left: auto;
    padding: 8px 12px;
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 7px;
    background: rgba(168, 32, 37, 0.55);
    color: #fff;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.modal-toolbar .auth-toolbar-logout:hover { background: #a82025; }

@media (max-width: 768px) {
    .modal-toolbar .auth-toolbar-logout {
        order: 1;
        padding: 7px 8px;
        font-size: 0.78rem;
    }

    .modal-toolbar > .module-nav-controls {
        order: 2;
        flex: 1 0 100%;
    }
}

@media (max-width: 480px) {
    #auth-gate .auth-card { padding: 17px 16px 15px; }
    #auth-gate .auth-card::after { top: 15px; right: 16px; }
    #auth-gate input,
    #auth-gate button[type="submit"] { min-height: 48px; }
}

@media (max-width: 700px) {
    #auth-gate .auth-card {
        padding: clamp(12px, 2dvh, 17px) clamp(12px, 3vw, 16px);
        border: 1px solid rgba(195, 220, 207, 0.16);
        border-radius: 14px;
        background: linear-gradient(180deg, rgba(10, 16, 17, 0.84), rgba(10, 16, 17, 0.76));
        box-shadow: inset 0 0 0 1px rgba(4, 10, 9, 0.42), inset 0 1px rgba(255, 255, 255, 0.06);
    }
    #auth-gate .auth-card::after { display: none; }
}

@media (min-width: 701px) {
    #auth-closing {
        background-image:
            radial-gradient(ellipse at center, rgba(81, 84, 61, 0.38), transparent 78%),
            var(--auth-frame-edge-fill);
    }
    .auth-closing-stage {
        width: 67.0742dvh;
        height: 100dvh;
    }
}

@media (prefers-reduced-motion: reduce) {
    .auth-closing-door {
        animation: none;
    }
}

@media (max-height: 650px) {
    #auth-gate .auth-card { padding: 10px 12px 8px; }
    #auth-gate .auth-kicker { margin-bottom: 5px; }
    #auth-gate h1 { margin-bottom: 5px; font-size: clamp(1.35rem, 6vw, 1.65rem); }
    #auth-gate p { margin-bottom: 6px; font-size: 0.86rem; line-height: 1.35; }
    #auth-gate .auth-intro { margin-bottom: 8px; }
    #auth-gate .auth-etat { min-height: 30px; margin-top: 8px; }
    #auth-gate label { margin: 7px 0 3px; }
    #auth-gate input { padding: 8px 10px; }
    #auth-gate .auth-message { min-height: 1em; margin-top: 5px; }
    #auth-gate button[type="submit"] { margin-top: 8px; padding: 9px 12px; }
    #auth-gate .auth-pied { margin-top: 9px; padding-top: 8px; }
}

@media (min-width: 701px) {
    #auth-gate .auth-card {
        width: min(62%, 400px, calc(100vw - 32px));
        padding: clamp(14px, 2.2dvh, 21px) clamp(16px, 2.5dvh, 24px);
        border: 1px solid rgba(195, 220, 207, 0.2);
        border-radius: 15px;
        background:
            radial-gradient(ellipse at 50% 0%, rgba(56, 95, 70, 0.14), transparent 58%),
            linear-gradient(155deg, rgba(8, 15, 16, 0.78), rgba(8, 15, 16, 0.9));
        box-shadow:
            0 12px 38px rgba(0, 0, 0, 0.32),
            inset 0 0 0 1px rgba(4, 10, 9, 0.35),
            inset 0 1px rgba(255, 255, 255, 0.06);
        font-size: 0.94rem;
    }

    #auth-gate .auth-card::after { display: none; }

    #auth-gate .auth-kicker {
        margin-bottom: 8px;
        font-size: 0.7rem;
    }

    #auth-gate h1 {
        margin-bottom: 8px;
        font-size: clamp(1.55rem, 3dvh, 1.9rem);
    }

    #auth-gate p { font-size: 0.88rem; }
    #auth-gate .auth-intro { margin-bottom: 12px; }
    #auth-gate label { margin: 9px 0 5px; font-size: 0.8rem; }

    #auth-gate input {
        padding: 10px 12px;
        border-color: rgba(195, 220, 207, 0.24);
        background: rgba(5, 12, 13, 0.68);
        color: #f4f7f2;
    }

    #auth-gate input:focus {
        border-color: #75cdd0;
        background: rgba(5, 12, 13, 0.9);
        box-shadow: 0 0 0 3px rgba(80, 194, 199, 0.14), 0 0 20px rgba(80, 194, 199, 0.08);
    }

    #auth-gate input:-webkit-autofill,
    #auth-gate input:-webkit-autofill:hover,
    #auth-gate input:-webkit-autofill:focus {
        -webkit-box-shadow: 0 0 0 1000px #101a18 inset;
        -webkit-text-fill-color: #f4f7f2;
        caret-color: #f4f7f2;
    }

    #auth-gate input:autofill {
        box-shadow: 0 0 0 1000px #101a18 inset;
        color: #f4f7f2;
        caret-color: #f4f7f2;
    }

    #auth-gate .auth-password-toggle { color: #c3d6c9; }
    #auth-gate .auth-password-toggle:hover { background: rgba(183, 219, 194, 0.1); color: #fff; }

    #auth-gate button[type="submit"] {
        margin-top: 12px;
        padding: 12px 14px;
        font-size: 0.9rem;
    }

    #auth-gate .auth-pied { margin-top: 12px; padding-top: 10px; }
}

@media (max-height: 600px) and (orientation: landscape) {
    #auth-gate .auth-card {
        position: fixed;
        top: 50%;
        left: 50%;
        width: min(440px, calc(100vw - 48px));
        max-height: calc(100dvh - max(16px, env(safe-area-inset-top)) - max(16px, env(safe-area-inset-bottom)));
        padding: 10px 16px;
        border: 1px solid rgba(195, 220, 207, 0.3);
        border-radius: 14px;
        background: rgba(8, 15, 16, 0.96);
        box-shadow: 0 12px 38px rgba(0, 0, 0, 0.58), inset 0 0 0 1px rgba(157, 179, 162, 0.12);
        transform: translate(-50%, -50%);
    }

    #auth-gate .auth-card::after { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    #auth-gate *,
    #auth-gate *::before,
    #auth-gate *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}
