.auth-modal-root {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    overscroll-behavior: contain;
    padding: 18px;
}

.auth-modal-root.is-open {
    display: flex;
}

.auth-modal-backdrop {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 24% 18%, rgba(37, 99, 235, 0.28), transparent 28%),
        radial-gradient(circle at 76% 20%, rgba(124, 58, 237, 0.22), transparent 30%),
        rgba(15, 23, 42, 0.46);
    backdrop-filter: blur(14px);
}

.auth-modal-card {
    position: relative;
    width: min(100%, 430px);
    max-height: min(720px, calc(100vh - 28px));
    max-height: min(720px, calc(100dvh - 28px));
    overflow: auto;
    overscroll-behavior: contain;
    border: 1px solid rgba(255, 255, 255, 0.56);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.86);
    box-shadow: 0 26px 80px rgba(15, 23, 42, 0.28);
    backdrop-filter: blur(24px);
    padding: 24px;
    color: #111827;
    animation: authModalIn 0.18s ease-out;
}

@keyframes authModalIn {
    from { opacity: 0; transform: translateY(12px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.auth-modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 8px;
    background: rgba(17, 24, 39, 0.06);
    color: #334155;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}

.auth-modal-close:hover {
    background: rgba(17, 24, 39, 0.11);
}

.auth-modal-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
}

.auth-modal-mark {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #111827;
    color: #fff;
    font-weight: 800;
    font-size: 14px;
}

.auth-modal-title {
    margin: 0;
    font-size: 20px;
    line-height: 1.25;
    font-weight: 800;
    letter-spacing: 0;
}

.auth-modal-subtitle {
    margin: 3px 0 0;
    color: #64748b;
    font-size: 13px;
    line-height: 1.5;
}

.auth-modal-tabs,
.auth-modal-register-modes {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    padding: 4px;
    border-radius: 10px;
    background: rgba(241, 245, 249, 0.82);
    margin-bottom: 16px;
}

.auth-modal-tab,
.auth-modal-mode {
    min-height: 38px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #64748b;
    font-weight: 750;
    font-size: 13px;
    cursor: pointer;
}

.auth-modal-tab.is-active,
.auth-modal-mode.is-active {
    background: rgba(255, 255, 255, 0.92);
    color: #111827;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.08);
}

.auth-modal-form {
    display: none;
}

.auth-modal-form.is-active {
    display: block;
}

.auth-modal-field {
    margin-bottom: 13px;
}

.auth-modal-label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 700;
    color: #334155;
}

.auth-modal-input {
    width: 100%;
    min-height: 44px;
    border-radius: 10px;
    border: 1px solid rgba(148, 163, 184, 0.55);
    background: rgba(255, 255, 255, 0.86);
    color: #0f172a;
    padding: 0 13px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.auth-modal-input:focus {
    border-color: #2563eb;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.auth-modal-code-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 112px;
    gap: 8px;
}

.auth-modal-secondary-btn {
    min-height: 44px;
    border-radius: 10px;
    border: 1px solid rgba(37, 99, 235, 0.22);
    background: rgba(239, 246, 255, 0.88);
    color: #1d4ed8;
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
}

.auth-modal-secondary-btn:disabled,
.auth-modal-primary:disabled {
    opacity: 0.62;
    cursor: not-allowed;
}

.auth-modal-hint {
    margin: 5px 0 0;
    color: #94a3b8;
    font-size: 12px;
    line-height: 1.45;
}

.auth-modal-primary {
    width: 100%;
    min-height: 46px;
    border: 0;
    border-radius: 10px;
    background: linear-gradient(135deg, #111827, #2563eb 52%, #7c3aed);
    color: #fff;
    font-size: 15px;
    font-weight: 850;
    cursor: pointer;
    box-shadow: 0 14px 28px rgba(37, 99, 235, 0.22);
}

.auth-modal-primary:not(:disabled):hover {
    transform: translateY(-1px);
}

.auth-modal-message {
    display: none;
    margin: 0 0 14px;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 13px;
    line-height: 1.45;
}

.auth-modal-message.is-visible {
    display: block;
}

.auth-modal-message.is-error {
    background: rgba(254, 242, 242, 0.92);
    color: #b91c1c;
    border: 1px solid rgba(248, 113, 113, 0.28);
}

.auth-modal-message.is-success {
    background: rgba(240, 253, 244, 0.92);
    color: #15803d;
    border: 1px solid rgba(74, 222, 128, 0.28);
}

.auth-modal-message.is-info {
    background: rgba(239, 246, 255, 0.92);
    color: #1d4ed8;
    border: 1px solid rgba(96, 165, 250, 0.28);
}

.auth-modal-hidden {
    display: none !important;
}

@media (max-width: 520px) {
    .auth-modal-root {
        align-items: flex-end;
        padding: 10px;
    }

    .auth-modal-card {
        width: 100%;
        max-height: calc(100vh - 20px);
        max-height: calc(100dvh - 20px);
        border-radius: 14px;
        padding: 22px 18px;
    }
}
