.modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: grid;
    place-items: center;
    padding: 1rem;
    visibility: hidden;
    pointer-events: none;
}

.modal.is-open {
    visibility: visible;
    pointer-events: auto;
}

.modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(5, 9, 18, 0.62);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    opacity: 0;
    transition: opacity 0.4s ease;
}

.modal.is-open .modal__backdrop {
    opacity: 1;
}

.modal__card {
    position: relative;
    width: 100%;
    max-width: 440px;
    max-height: 92vh;
    max-height: 92dvh;
    overflow-y: auto;
    padding: 2rem 1.6rem 1.6rem;
    border-radius: 26px;
    background: linear-gradient(160deg, rgba(22, 32, 56, 0.97), rgba(8, 14, 28, 0.97));
    border: 1px solid var(--line);
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
    opacity: 0;
    transform: translateY(46px) scale(0.93);
    transition: opacity 0.35s ease, transform 0.55s var(--ease-back);
}

.modal.is-open .modal__card {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.modal__close {
    position: absolute;
    top: 0.8rem;
    right: 0.8rem;
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
    transition: transform 0.35s var(--ease-back), background 0.3s ease;
}

.modal__close:hover {
    background: rgba(255, 90, 78, 0.9);
    transform: rotate(90deg);
}

/* ---------- En-tête ---------- */

.modal__head {
    text-align: center;
    margin-bottom: 1.4rem;
}

.modal__icon {
    display: inline-grid;
    place-items: center;
    width: 60px;
    height: 60px;
    margin-bottom: 0.8rem;
    border-radius: 20px;
    font-size: 1.5rem;
    background: linear-gradient(135deg, var(--brand), #ff9a8f);
    box-shadow: 0 12px 30px rgba(255, 90, 78, 0.4);
}

.modal.is-open .modal__icon {
    animation: iconPop 0.8s var(--ease-back) 0.15s both;
}

.modal__head h2 {
    font-size: 1.45rem;
    font-weight: 600;
}

.modal__head p {
    margin-top: 0.35rem;
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--muted);
}

.modal__head strong {
    color: #ffffff;
}

/* ---------- Apparition en cascade ---------- */

.modal.is-open .form > * {
    animation: riseIn 0.6s var(--ease-out) both;
}

.modal.is-open .form > :nth-child(1) { animation-delay: 0.10s; }
.modal.is-open .form > :nth-child(2) { animation-delay: 0.16s; }
.modal.is-open .form > :nth-child(3) { animation-delay: 0.22s; }
.modal.is-open .form > :nth-child(4) { animation-delay: 0.28s; }
.modal.is-open .form > :nth-child(5) { animation-delay: 0.34s; }
.modal.is-open .form > :nth-child(6) { animation-delay: 0.40s; }
.modal.is-open .form > :nth-child(7) { animation-delay: 0.46s; }
.modal.is-open .form > :nth-child(8) { animation-delay: 0.52s; }
.modal.is-open .form > :nth-child(9) { animation-delay: 0.58s; }

/* ---------- Champs ---------- */

.field {
    margin-bottom: 1rem;
}

.field label {
    display: block;
    margin-bottom: 0.35rem;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--muted);
}

.field__control {
    position: relative;
    display: flex;
    align-items: center;
}

.field__control > i:first-child {
    position: absolute;
    left: 1rem;
    font-size: 0.95rem;
    color: var(--muted);
    pointer-events: none;
    transition: color 0.3s ease;
}

.field__control:focus-within > i:first-child {
    color: var(--brand);
}

.field__control input {
    width: 100%;
    padding: 0.85rem 2.8rem 0.85rem 2.8rem;
    border-radius: 14px;
    border: 1.5px solid var(--line);
    background: rgba(255, 255, 255, 0.06);
    color: #ffffff;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.3s ease, background 0.3s ease, box-shadow 0.3s ease;
}

.field__control input::placeholder {
    color: rgba(203, 213, 225, 0.55);
}

.field__control input:focus {
    border-color: var(--brand);
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 0 0 4px rgba(255, 90, 78, 0.18);
}

.field__control input:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.field.has-error input {
    border-color: #ff6b6b;
    animation: shake 0.45s ease;
}

.field__eye {
    position: absolute;
    right: 0.5rem;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--muted);
    transition: color 0.3s ease, background 0.3s ease;
}

.field__eye:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.1);
}

.field__error {
    display: block;
    margin-top: 0.3rem;
    font-size: 0.78rem;
    color: #ff8a8a;
}

.field__error:empty {
    display: none;
}

.check {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 1rem;
    font-size: 0.85rem;
    color: var(--muted);
    cursor: pointer;
}

.check input {
    width: 16px;
    height: 16px;
    accent-color: var(--brand);
}

/* ---------- Alertes ---------- */

.form__alert {
    margin-bottom: 1rem;
    padding: 0.7rem 0.9rem;
    border-radius: 12px;
    font-size: 0.85rem;
    line-height: 1.4;
}

.form__alert.is-error {
    background: rgba(255, 107, 107, 0.15);
    border: 1px solid rgba(255, 107, 107, 0.5);
    color: #ffb3b3;
}

.form__alert.is-success {
    background: rgba(74, 222, 128, 0.14);
    border: 1px solid rgba(74, 222, 128, 0.5);
    color: #b6f5cd;
}

/* ---------- Lien de bascule ---------- */

.form__switch {
    margin-top: 1rem;
    text-align: center;
    font-size: 0.88rem;
    color: var(--muted);
}

.form__switch button {
    border: 0;
    background: none;
    color: var(--brand-2);
    font-size: inherit;
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.form__switch button:disabled {
    opacity: 0.55;
    text-decoration: none;
    cursor: not-allowed;
}

/* ---------- Avatar ---------- */

.avatar-picker {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.45rem;
    margin-bottom: 1.2rem;
}

.avatar-picker small {
    font-size: 0.78rem;
    color: var(--muted);
}

.avatar-picker__label {
    position: relative;
    display: block;
    width: 94px;
    height: 94px;
    border-radius: 50%;
    cursor: pointer;
}

.avatar-picker__preview {
    width: 100%;
    height: 100%;
    display: grid;
    place-items: center;
    border-radius: 50%;
    overflow: hidden;
    font-size: 1.8rem;
    color: var(--muted);
    background: rgba(255, 255, 255, 0.08);
    border: 2px dashed rgba(255, 255, 255, 0.35);
    transition: transform 0.4s var(--ease-back), border-color 0.3s ease;
}

.avatar-picker__label:hover .avatar-picker__preview {
    transform: scale(1.06);
    border-color: var(--brand);
}

.avatar-picker__preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-picker__preview b {
    font-size: 2.2rem;
    color: #ffffff;
}

.avatar-picker__badge {
    position: absolute;
    right: -2px;
    bottom: -2px;
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    border: 3px solid #0d1526;
    background: var(--brand);
    font-size: 0.75rem;
    transition: transform 0.35s var(--ease-back);
}

.avatar-picker__label:hover .avatar-picker__badge {
    transform: scale(1.15) rotate(12deg);
}

.avatar-picker input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    border-radius: 50%;
    cursor: pointer;
}

/* ---------- OTP ---------- */

.otp {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin: 0.4rem 0 0.4rem;
}

.otp.is-shake {
    animation: shake 0.45s ease;
}

.otp__box {
    width: 46px;
    height: 56px;
    text-align: center;
    border-radius: 14px;
    border: 1.5px solid var(--line);
    background: rgba(255, 255, 255, 0.06);
    color: #ffffff;
    font-size: 1.5rem;
    font-weight: 600;
    outline: none;
    transition: border-color 0.3s ease, transform 0.3s var(--ease-back), box-shadow 0.3s ease;
}

.otp__box:focus {
    border-color: var(--brand);
    transform: translateY(-3px) scale(1.06);
    box-shadow: 0 0 0 4px rgba(255, 90, 78, 0.18);
}

.otp__box:not(:placeholder-shown),
.otp__box[value]:not([value='']) {
    border-color: rgba(255, 255, 255, 0.45);
}

.otp__error {
    text-align: center;
    margin-bottom: 0.9rem;
}

/* ---------- Keyframes ---------- */

@keyframes iconPop {
    0%   { transform: scale(0.4) rotate(-20deg); opacity: 0; }
    100% { transform: scale(1) rotate(0); opacity: 1; }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%      { transform: translateX(-7px); }
    40%      { transform: translateX(7px); }
    60%      { transform: translateX(-4px); }
    80%      { transform: translateX(4px); }
}

/* ---------- Petits écrans ---------- */

@media (max-width: 400px) {
    .modal__card {
        padding: 1.8rem 1.1rem 1.3rem;
        border-radius: 22px;
    }

    .otp {
        gap: 0.35rem;
    }

    .otp__box {
        width: 40px;
        height: 50px;
        font-size: 1.3rem;
    }
}