.auth-modal-backdrop[hidden],
.auth-modal-step[hidden],
.auth-modal-error[hidden] {
    display: none !important;
}

.auth-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(20, 18, 12, 0.36);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    animation: auth-modal-fade 200ms ease-out;
}

.auth-modal-card {
    position: relative;
    width: 100%;
    max-width: 420px;
    max-height: calc(100dvh - 40px);
    overflow-y: auto;
    padding: 40px 40px 32px;
    border-radius: 22px;
    background: #fff;
    color: #0a0a0a;
    box-shadow: 0 30px 60px -28px rgba(12, 12, 12, 0.25),
                0 6px 16px -8px rgba(12, 12, 12, 0.1);
    animation: auth-modal-rise 280ms cubic-bezier(.2, .7, .2, 1);
}

.auth-modal-card h2 {
    margin: 0 0 8px;
    color: #0a0a0a;
    font-size: 30px;
    font-weight: 500;
    line-height: 1.15;
    letter-spacing: -0.04em;
}

.auth-modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    display: flex;
    width: 32px;
    height: 32px;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #8a8a86;
    cursor: pointer;
    transition: color 140ms cubic-bezier(.2, .7, .2, 1),
                background 140ms cubic-bezier(.2, .7, .2, 1);
}

.auth-modal-close:hover {
    background: #f6f5f3;
    color: #0a0a0a;
}

.auth-modal-subtitle {
    margin: 0 0 24px;
    color: #8a8a86;
    font-size: 14.5px;
}

.auth-modal-subtitle strong {
    color: #0a0a0a;
    font-weight: 500;
    overflow-wrap: anywhere;
}

.auth-modal-label {
    display: block;
    margin-bottom: 7px;
    color: #5f5f5b;
    font-size: 13px;
    font-weight: 500;
}

.auth-modal-input {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid #ececea;
    border-radius: 10px;
    outline: none;
    background: #fff;
    color: #0a0a0a;
    font: inherit;
    font-size: 14.5px;
    transition: border-color 140ms cubic-bezier(.2, .7, .2, 1),
                box-shadow 140ms cubic-bezier(.2, .7, .2, 1);
}

.auth-modal-input:focus {
    border-color: #0a0a0a;
    box-shadow: 0 0 0 3px rgba(10, 10, 10, 0.06);
}

.auth-modal-input::placeholder {
    color: #a09f9a;
}

.auth-modal-submit {
    display: inline-flex;
    width: 100%;
    height: 40px;
    align-items: center;
    justify-content: center;
    margin-top: 16px;
    padding: 0 18px;
    border: 1px solid transparent;
    border-radius: 999px;
    background: #0a0a0a;
    color: #fff;
    font: inherit;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: transform 140ms cubic-bezier(.2, .7, .2, 1),
                background 140ms cubic-bezier(.2, .7, .2, 1),
                opacity 140ms ease;
}

.auth-modal-submit:hover {
    background: #2a2a2a;
}

.auth-modal-submit:active {
    transform: scale(.97);
}

.auth-modal-submit:disabled,
.auth-modal-footer button:disabled {
    opacity: .6;
    cursor: default;
}

.auth-modal-note {
    margin: 16px 0 0;
    color: #8a8a86;
    font-size: 12px;
    line-height: 1.5;
    text-align: center;
}

.auth-modal-notice {
    margin: -8px 0 16px;
    padding: 10px 12px;
    border-radius: 10px;
    background: #fff7ed;
    color: #9a3412;
    font-size: 13px;
}

.auth-modal-error {
    margin-top: 8px;
    color: #d83a1f;
    font-size: 13px;
}

.auth-modal-error-center {
    margin-top: 4px;
    text-align: center;
}

.auth-modal-status {
    min-height: 20px;
    color: #8a8a86;
    font-size: 13px;
    text-align: center;
}

.auth-modal-back {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin: 0 0 16px;
    padding: 0;
    border: 0;
    background: none;
    color: #8a8a86;
    font: inherit;
    font-size: 13px;
    cursor: pointer;
}

.auth-modal-back:hover {
    color: #0a0a0a;
}

.auth-code-row {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin: 6px 0 20px;
}

.auth-code-cell {
    width: 48px;
    height: 56px;
    padding: 0;
    border: 1.5px solid #ececea;
    border-radius: 12px;
    outline: none;
    background: #f6f5f3;
    color: #0a0a0a;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 22px;
    font-weight: 500;
    text-align: center;
    transition: border-color 140ms cubic-bezier(.2, .7, .2, 1),
                background 140ms cubic-bezier(.2, .7, .2, 1);
}

.auth-code-cell:focus {
    border-color: #0a0a0a;
    background: #fff;
}

.auth-code-cell.is-filled {
    border-color: #d6d5d1;
    background: #fff;
}

.auth-code-cell.is-error {
    border-color: #d83a1f;
    animation: auth-modal-shake 360ms ease;
}

.auth-modal-footer {
    margin-top: 4px;
    color: #8a8a86;
    font-size: 13px;
    text-align: center;
}

.auth-modal-footer button {
    padding: 0;
    border: 0;
    background: none;
    color: #0a0a0a;
    font: inherit;
    font-weight: 500;
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
}

body.auth-modal-open {
    overflow: hidden;
}

@keyframes auth-modal-fade {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes auth-modal-rise {
    from { opacity: 0; transform: translateY(20px) scale(.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes auth-modal-shake {
    10%, 90% { transform: translateX(-2px); }
    20%, 80% { transform: translateX(3px); }
    30%, 50%, 70% { transform: translateX(-5px); }
    40%, 60% { transform: translateX(5px); }
}

@media (max-width: 640px) {
    .auth-modal-backdrop { padding: 12px; }
    .auth-modal-card { padding: 32px 20px 24px; }
    .auth-code-row { gap: 6px; }
    .auth-code-cell {
        width: clamp(36px, 11vw, 44px);
        height: 52px;
        font-size: 20px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .auth-modal-backdrop,
    .auth-modal-card,
    .auth-code-cell.is-error {
        animation: none;
    }
}
