#authModal.modal {
    padding: clamp(14px, 3vh, 32px);
    overflow-y: auto;
    background: rgba(2, 7, 14, 0.76);
    backdrop-filter: blur(22px) saturate(115%);
}

#authModal .modal-content {
    position: relative;
    width: min(500px, 100%);
    max-width: 500px;
    height: auto;
    max-height: min(92dvh, 780px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.11);
    border-radius: 26px;
    background:
        radial-gradient(circle at 15% -5%, rgba(74, 153, 255, 0.12), transparent 31%),
        linear-gradient(155deg, #111c29 0%, #0b141f 56%, #08111b 100%);
    box-shadow: 0 42px 110px rgba(0, 0, 0, 0.58), 0 1px 0 rgba(255, 255, 255, 0.06) inset;
    color: #f5f8fb;
    animation: authModalIn 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}

#authModal .modal-close {
    position: absolute;
    top: 18px;
    right: 18px;
    z-index: 2;
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 0 2px;
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.035);
    box-shadow: none;
    color: #8f9cab;
    font-size: 1.45rem;
    font-weight: 300;
    line-height: 1;
    cursor: pointer;
    transition: color 0.18s ease, border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

#authModal .modal-close:hover {
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.08);
    transform: rotate(3deg);
}

#authModal .modal-header {
    flex: 0 0 auto;
    padding: 31px 68px 20px 32px;
    border: 0;
    background: transparent;
}

#authModal .auth-kicker {
    display: block;
    margin: 0 0 11px;
    color: #70b7ff;
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.18em;
}

#authModal .modal-title {
    margin: 0;
    color: #f7f9fc;
    font-size: clamp(1.55rem, 4vw, 1.9rem);
    line-height: 1.15;
    font-weight: 680;
    letter-spacing: -0.035em;
}

#authModal .auth-subtitle {
    max-width: 350px;
    margin: 9px 0 0;
    color: #8998a9;
    font-size: 0.89rem;
    line-height: 1.45;
}

#authModal .modal-body {
    flex: 1 1 auto;
    min-height: 0;
    padding: 0 32px 32px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.16) transparent;
}

#authModal .auth-tabs {
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px;
    margin: 0 0 23px;
    padding: 4px;
    border: 1px solid rgba(255, 255, 255, 0.075);
    border-radius: 13px;
    background: rgba(0, 0, 0, 0.19);
}

#authModal .auth-tabs[hidden] {
    display: none;
}

#authModal .auth-tab {
    min-height: 41px;
    padding: 0 14px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: #7f8d9c;
    font-size: 0.91rem;
    font-weight: 650;
    text-align: center;
    cursor: pointer;
    transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

#authModal .auth-tab:hover {
    color: #cfd7e0;
}

#authModal .auth-tab.active {
    color: #f6f8fb;
    background: rgba(255, 255, 255, 0.085);
    box-shadow: 0 5px 16px rgba(0, 0, 0, 0.2), 0 1px 0 rgba(255, 255, 255, 0.05) inset;
}

#authModal .auth-form {
    display: none;
}

#authModal .auth-form.active {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
    flex-direction: column;
    gap: 15px;
    animation: authFormIn 0.2s ease;
}

#authModal .form-group {
    margin: 0;
}

#authModal .form-label {
    display: block;
    margin: 0 0 7px;
    color: #aeb9c5;
    font-size: 0.79rem;
    font-weight: 650;
    letter-spacing: 0.015em;
}

#authModal .form-input,
#authModal .form-select {
    width: 100%;
    min-height: 50px;
    padding: 12px 14px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    outline: none;
    background-color: rgba(1, 8, 16, 0.4);
    color: #f4f7fa;
    font-size: 0.96rem;
    font-weight: 450;
    transition: border-color 0.18s ease, background-color 0.18s ease, box-shadow 0.18s ease;
}

#authModal .form-input::placeholder {
    color: #566475;
}

#authModal .form-input:hover,
#authModal .form-select:hover {
    border-color: rgba(255, 255, 255, 0.17);
}

#authModal .form-input:focus,
#authModal .form-select:focus {
    border-color: rgba(91, 171, 255, 0.72);
    background-color: rgba(3, 14, 25, 0.72);
    box-shadow: 0 0 0 4px rgba(45, 139, 234, 0.12);
}

#authModal .auth-code-input {
    text-align: center;
    font-size: 1.22rem;
    font-weight: 700;
    letter-spacing: 0.3em;
    font-variant-numeric: tabular-nums;
}

#authModal .form-select {
    appearance: none;
    padding-right: 42px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238f9dad' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 15px center;
}

#authModal .auth-forgot-link,
#authModal .btn-link {
    align-self: flex-end;
    width: auto;
    min-height: auto;
    margin: -3px 0 0;
    padding: 2px 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    color: #75b9ff;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: color 0.18s ease;
}

#authModal .auth-forgot-link:hover,
#authModal .btn-link:hover {
    color: #b7dcff;
    transform: none;
}

#authModal .auth-recovery-copy {
    display: grid;
    gap: 7px;
    margin: 0 0 4px;
    padding: 15px 16px;
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 13px;
    background: rgba(255, 255, 255, 0.035);
}

#authModal .auth-recovery-copy strong {
    color: #edf3f8;
    font-size: 0.91rem;
    font-weight: 650;
}

#authModal .auth-recovery-copy span {
    color: #8593a2;
    font-size: 0.82rem;
    line-height: 1.48;
}

#authModal .auth-inline-status {
    min-height: 0;
    color: #93a2b2;
    font-size: 0.82rem;
    line-height: 1.45;
}

#authModal .auth-inline-status:not(:empty) {
    min-height: 42px;
    padding: 11px 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.035);
}

#authModal .auth-inline-status[data-kind="success"] {
    color: #9fe0be;
    border-color: rgba(70, 200, 135, 0.18);
    background: rgba(34, 143, 91, 0.09);
}

#authModal .auth-inline-status[data-kind="error"] {
    color: #ffb2b2;
    border-color: rgba(255, 101, 101, 0.2);
    background: rgba(191, 51, 51, 0.1);
}

#authModal .form-actions {
    display: flex;
    gap: 10px;
    margin: auto 0 0;
    padding-top: 8px;
}

#authModal .btn {
    flex: 1 1 0;
    min-height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 16px;
    border: 1px solid transparent;
    border-radius: 12px;
    font-size: 0.91rem;
    font-weight: 680;
    cursor: pointer;
    transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

#authModal .btn:hover {
    transform: translateY(-1px);
}

#authModal .btn:focus-visible,
#authModal .auth-tab:focus-visible,
#authModal .modal-close:focus-visible,
#authModal .auth-forgot-link:focus-visible {
    outline: 2px solid #67b3ff;
    outline-offset: 3px;
}

#authModal .btn:disabled {
    cursor: wait;
    opacity: 0.58;
    transform: none;
}

#authModal .btn-primary {
    color: #06101a;
    background: linear-gradient(180deg, #f7fbff 0%, #dbeeff 100%);
    border-color: rgba(255, 255, 255, 0.88);
    box-shadow: 0 9px 24px rgba(30, 113, 197, 0.18);
}

#authModal .btn-primary:hover {
    color: #02070c;
    background: #ffffff;
    box-shadow: 0 13px 28px rgba(30, 113, 197, 0.24);
}

#authModal .btn-secondary {
    color: #a8b4c1;
    background: rgba(255, 255, 255, 0.035);
    border-color: rgba(255, 255, 255, 0.09);
    box-shadow: none;
}

#authModal .btn-secondary:hover {
    color: #edf2f7;
    background: rgba(255, 255, 255, 0.07);
    border-color: rgba(255, 255, 255, 0.16);
}

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

@keyframes authFormIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 680px) {
    #authModal.modal { padding: 10px; }

    #authModal .modal-content {
        width: min(440px, 100%);
        max-height: calc(100dvh - 20px);
        border-radius: 20px;
    }

    #authModal .modal-header { padding: 25px 58px 17px 21px; }
    #authModal .modal-close { top: 14px; right: 14px; width: 34px; height: 34px; }
    #authModal .modal-title { font-size: 1.45rem; }
    #authModal .auth-subtitle { margin-top: 7px; font-size: 0.82rem; }
    #authModal .modal-body { padding: 0 20px 22px; }
    #authModal .auth-tabs { margin-bottom: 18px; }
    #authModal .auth-form.active { gap: 12px; }
    #authModal .form-input,
    #authModal .form-select { min-height: 46px; }
    #authModal .form-actions { gap: 8px; }
    #authModal .btn { min-height: 45px; padding-inline: 11px; font-size: 0.86rem; }
}

@media (max-width: 390px) {
    #authModal .form-actions { flex-direction: column-reverse; }
}

@media (prefers-reduced-motion: reduce) {
    #authModal .modal-content,
    #authModal .auth-form.active { animation: none; }
}
