:root {
    color-scheme: light;
    --auth-accent: #1683df;
    --auth-accent-hover: #0d73c8;
    --auth-border: #d7d7d7;
    --auth-muted: #6f6f6f;
    --auth-error: #b00000;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { min-width: 0; background: #f2f5f9; }
body { margin: 0; color: #333; font-family: Arial, Helvetica, sans-serif; }
body.auth-document-open {
    overflow: hidden;
    padding-right: var(--auth-scrollbar-compensation, 0px);
}

.auth-layout {
    width: min(1500px, calc(100% - 40px));
    margin: 40px auto;
    display: grid;
    grid-template-columns: minmax(0, 680px) minmax(0, 680px);
    justify-content: center;
    align-items: stretch;
    gap: 40px;
}
.auth-panel {
    min-width: 0;
    padding: 50px;
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 0 45px rgba(0,0,0,.10), 0 12px 35px rgba(0,0,0,.10);
}
.auth-form-panel { align-self: start; }
@media (min-width: 801px) {
    .auth-forgot-page .auth-form-panel,
    .auth-reset-page .auth-form-panel { align-self: stretch; }
}
.auth-door-panel {
    position: relative;
    min-height: 680px;
    overflow: hidden;
    border: 1px solid rgba(0,0,0,.05);
}
.auth-register-page .auth-door-panel { min-height: 900px; }

.auth-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    width: 100%;
    margin-bottom: 20px;
    font-size: 14px;
}
.auth-register-page .auth-top { margin-bottom: 35px; }
.auth-top a, .auth-link {
    color: var(--auth-muted);
    text-decoration: none;
    transition: color .2s ease;
}
.auth-top a:hover, .auth-link:hover { color: var(--auth-accent); }
.auth-top a:focus-visible, .auth-link:focus-visible,
.auth-document-trigger:focus-visible {
    outline: 3px solid rgba(22,131,223,.22);
    outline-offset: 3px;
    border-radius: 3px;
}

.auth-logo {
    display: block;
    width: min(360px, 100%);
    height: auto;
    margin: 0 auto 25px;
}
.auth-title { margin: 0 0 10px; text-align: center; font-size: 30px; line-height: 1.2; }
.auth-lead {
    margin: 0 auto 30px;
    color: #666;
    text-align: center;
    font-size: 16px;
    line-height: 1.5;
}
.auth-register-page .auth-lead { margin-bottom: 6px; line-height: 1.45; }

.auth-account-types {
    margin: 0 0 22px;
    padding: 0;
    border: 0;
}
.auth-account-types legend {
    margin-bottom: 8px;
    color: #444;
    font-size: 15px;
    font-weight: 600;
}
.auth-account-types__options {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 9px;
}
.auth-account-type {
    position: relative;
    display: flex;
    align-items: center;
    cursor: pointer;
}
.auth-account-type input {
    position: absolute;
    left: 13px;
    z-index: 1;
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: var(--auth-accent);
}
.auth-account-type__tile {
    display: flex;
    width: 100%;
    min-height: 50px;
    align-items: center;
    padding: 10px 12px 10px 39px;
    border: 1px solid var(--auth-border);
    border-radius: 10px;
    background: #fff;
}
.auth-account-type__tile strong {
    display: block;
    color: #333;
    font-size: 14px;
    line-height: 1.3;
}
.auth-account-type input:checked + .auth-account-type__tile {
    border-color: var(--auth-accent);
    background: #f2f8fe;
    box-shadow: 0 0 0 2px rgba(22,131,223,.12);
}
.auth-account-type input:focus-visible + .auth-account-type__tile {
    outline: 3px solid rgba(22,131,223,.22);
    outline-offset: 2px;
}
.auth-account-type__tooltip {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    z-index: 20;
    width: max-content;
    max-width: min(260px, calc(100vw - 32px));
    padding: 7px 9px;
    border-radius: 7px;
    background: #263445;
    color: #fff;
    font-size: 11px;
    font-weight: 400;
    line-height: 1.35;
    text-align: left;
    opacity: 0;
    pointer-events: none;
    transform: translateX(-50%) translateY(3px);
    transition: opacity .15s ease, transform .15s ease;
}
.auth-account-type__tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    border: 5px solid transparent;
    border-top-color: #263445;
    transform: translateX(-50%);
}
.auth-account-type:hover .auth-account-type__tooltip,
.auth-account-type:focus-within .auth-account-type__tooltip {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
.auth-account-types__notice {
    margin: 9px 0 0;
    color: var(--auth-muted);
    font-size: 10px;
    line-height: 1.4;
}

.auth-field { width: 100%; margin-bottom: 22px; }
.auth-field label, .auth-label {
    display: block;
    width: 100%;
    margin: 0 0 7px;
    color: #444;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.4;
}
.auth-register-page .auth-field label,
.auth-register-page .auth-label { margin-bottom: 8px; font-size: 15px; }
.auth-help { margin: -3px 0 10px; color: #8d8d8d; font-size: 12px; line-height: 1.4; }
.auth-input {
    display: block;
    width: 100%;
    height: 52px;
    padding: 12px 15px;
    border: 1px solid var(--auth-border);
    border-radius: 8px;
    outline: none;
    background: #fff;
    color: #333;
    font: inherit;
    font-size: 16px;
    transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}
.auth-register-page .auth-input { height: 48px; padding: 0 16px; border-radius: 10px; }
.auth-input:focus {
    border-color: var(--auth-accent);
    box-shadow: 0 0 0 3px rgba(22,131,223,.12);
}
.auth-register-page .auth-input:focus { box-shadow: 0 0 0 4px rgba(27,115,209,.15); }
.auth-field:has(.auth-error:not([hidden])) .auth-input,
.auth-input[aria-invalid="true"] { border-color: #d40000; background: #fffafa; }
.auth-field:has(.auth-error:not([hidden])) .auth-input:focus,
.auth-input[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px rgba(212,0,0,.12); }
.auth-input:user-invalid { border-color: #d40000; }
.auth-input:user-valid:not([type="password"]):not([type="file"]):not(:placeholder-shown) {
    border-color: #68ad78;
}
.auth-input:disabled, .auth-button:disabled { opacity: .6; cursor: not-allowed; }
.auth-error {
    margin-top: 6px;
    color: var(--auth-error);
    font-size: 13px;
    font-weight: 600;
    line-height: 1.4;
}
.auth-public-name-warning {
    padding: 8px 10px;
    border-radius: 7px;
    background: #3f1515;
    color: #fff;
    box-shadow: 0 5px 14px rgba(0, 0, 0, .18);
}
.auth-status {
    margin: 0 auto 20px;
    padding: 12px 15px;
    border: 1px solid #75bf86;
    border-radius: 8px;
    background: #effaf2;
    color: #236532;
    text-align: center;
    font-weight: 600;
    line-height: 1.4;
}
.auth-status.is-error { border-color: #dc8a8a; background: #fff3f3; color: #9f1d1d; }
.auth-reset-trigger {
    display: block;
    width: max-content;
    margin: 0 auto 14px;
    padding: 2px 0;
    border: 0;
    background: transparent;
    color: var(--auth-muted);
    font: inherit;
    font-size: 13px;
    text-decoration: underline;
    cursor: pointer;
}
.auth-reset-confirm {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    margin: -6px 0 12px;
    color: #555;
    font-size: 13px;
}
.auth-reset-confirm button {
    padding: 4px 10px;
    border: 1px solid #bbb;
    border-radius: 5px;
    background: #f3f3f3;
    cursor: pointer;
}
.auth-password-meter {
    height: 8px;
    margin-top: 10px;
    overflow: hidden;
    border-radius: 10px;
    background: #e5e5e5;
}
.auth-password-meter > span {
    display: block;
    width: 0;
    height: 100%;
    background: #d40000;
    transition: width .25s ease, background .25s ease;
}
.auth-password-feedback {
    min-height: 18px;
    margin-top: 8px;
    color: #666;
    font-size: 13px;
    font-weight: 600;
}
.auth-password-feedback.is-valid { color: #237a39; }
.auth-password-feedback.is-invalid { color: #b00000; }

.auth-button {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 52px;
    padding: 0 20px;
    border: 0;
    border-radius: 8px;
    background: var(--auth-accent);
    color: #fff;
    font: inherit;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background .2s ease, box-shadow .2s ease;
}
.auth-button:hover:not(:disabled) {
    background: var(--auth-accent-hover);
    box-shadow: 0 4px 12px rgba(0,0,0,.15);
}
.auth-button:focus-visible, .auth-avatar-category:focus-visible,
.auth-avatar-option:focus-visible, .auth-search-result:focus-visible {
    outline: 3px solid rgba(22,131,223,.25);
    outline-offset: 2px;
}
.auth-register-page form > .auth-button:last-child {
    border-radius: 12px;
    font-size: 18px;
    font-weight: 700;
}
.auth-button-secondary { border: 1px solid #bdbdbd; background: #e5e5e5; color: #444; }
.auth-button-secondary:hover:not(:disabled) {
    background: #d8d8d8;
    box-shadow: 0 4px 12px rgba(0,0,0,.12);
}
.auth-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    width: 100%;
    margin-top: 28px;
}
.auth-actions > * { width: 100%; }

.auth-check {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 14px 0;
    color: #444;
    font-size: 14px;
    line-height: 1.45;
    cursor: pointer;
}
.auth-check input {
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    margin: 1px 0 0;
    accent-color: var(--auth-accent);
}

.auth-avatar-box {
    margin: 22px 0;
    padding: 18px;
    border: 1px solid var(--auth-border);
    border-radius: 14px;
    background: #fafafa;
}
.auth-avatar-buttons {
    position: relative;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 12px;
}
.auth-avatar-gallery-account-hint {
    position: absolute;
    right: 0;
    bottom: calc(100% + 8px);
    z-index: 25;
    width: max-content;
    max-width: min(280px, calc(100vw - 32px));
    padding: 8px 10px;
    border-radius: 7px;
    background: #263445;
    color: #fff;
    font-size: 12px;
    line-height: 1.35;
    text-align: left;
    box-shadow: 0 4px 14px rgba(0,0,0,.18);
}
.auth-avatar-gallery-account-hint::after {
    content: '';
    position: absolute;
    top: 100%;
    right: 24px;
    border: 5px solid transparent;
    border-top-color: #263445;
}
.auth-avatar-buttons .auth-button { width: 100%; min-height: 46px; }
.auth-avatar-buttons [data-avatar-gallery-open][hidden] { display: none !important; }
.auth-avatar-buttons:has([data-avatar-gallery-open][hidden]) { grid-template-columns: 1fr; }
.auth-visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}
.auth-avatar-preview {
    display: block;
    width: 120px;
    height: 120px;
    margin: 12px auto 0;
    border: 2px solid var(--auth-border);
    border-radius: 50%;
    object-fit: cover;
    background: #fff;
    box-shadow: 0 6px 18px rgba(0,0,0,.12);
}
.auth-avatar-preview.is-entity { border-radius: 12%; }
.auth-avatar-categories {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px;
    width: 100%;
    margin-bottom: 20px;
}
.auth-avatar-category {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    height: 42px;
    padding: 0 6px;
    border: 1px solid #d5d5d5;
    border-radius: 8px;
    background: #f2f2f2;
    color: #333;
    font: inherit;
    font-size: 14px;
    cursor: pointer;
}
.auth-avatar-category[aria-selected="true"] {
    border-color: #2f73c8;
    background: #2f73c8;
    color: #fff;
    font-weight: 700;
}
.auth-avatar-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 14px;
}
.auth-avatar-option {
    min-width: 0;
    padding: 0;
    border: 2px solid transparent;
    border-radius: 12px;
    background: transparent;
    cursor: pointer;
    transition: border-color .2s ease, transform .2s ease, box-shadow .2s ease;
}
.auth-avatar-option:hover { border-color: #2f73c8; transform: scale(1.04); }
.auth-avatar-option[aria-pressed="true"] {
    border-color: var(--auth-accent);
    box-shadow: 0 0 0 3px rgba(22,131,223,.18);
}
.auth-avatar-option img {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 1;
    border-radius: 10px;
    object-fit: cover;
}

.auth-search-results {
    display: grid;
    gap: 6px;
    max-height: 230px;
    margin-top: 8px;
    overflow: auto;
    overscroll-behavior: contain;
}
.auth-search-result {
    padding: 10px 12px;
    border: 1px solid var(--auth-border);
    border-radius: 8px;
    background: #fff;
    color: #333;
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.auth-search-result:hover, .auth-search-result:focus,
.auth-search-result[aria-pressed="true"] {
    border-color: var(--auth-accent);
    background: #edf5ff;
}

.auth-door {
    position: absolute;
    inset: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 50px;
    overflow: hidden;
    background: #fff;
    transition: transform .9s ease;
}
.auth-door::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 10px;
    height: 100%;
    background: linear-gradient(to right, rgba(0,0,0,.22), rgba(0,0,0,.08), transparent);
    pointer-events: none;
}
.auth-door.is-open { transform: translateX(100%); }
.auth-mascot {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 600px;
    object-fit: contain;
    margin: auto;
}
.auth-register-page .auth-door {
    padding: 0;
}
.auth-register-page .auth-mascot {
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    object-fit: contain;
    margin: 0;
}
.auth-login-page .auth-door,
.auth-forgot-page .auth-door,
.auth-reset-page .auth-door {
    padding: 0;
}
.auth-login-page .auth-mascot,
.auth-forgot-page .auth-mascot,
.auth-reset-page .auth-mascot {
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    object-fit: contain;
    margin: 0;
}
.auth-document {
    position: absolute;
    inset: 0;
    z-index: 10;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #fff;
}
.auth-document header {
    padding: 25px;
    border-bottom: 1px solid #ececec;
    font-size: 24px;
    font-weight: 700;
}
.auth-document iframe { width: 100%; flex: 1; border: 0; }
.auth-document footer { padding: 25px; border-top: 1px solid #ececec; }
.auth-document footer button { width: 100%; }
.auth-document-trigger {
    text-decoration: none;
}
.auth-documents-title { margin: 28px 0 14px; font-size: 16px; font-weight: 700; }
.auth-documents { display: grid; gap: 10px; }
.auth-document-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; }
.auth-document-row .auth-button { width: 100%; }
.auth-document-check { min-width: 108px; color: #16863c; font-size: 13px; font-weight: 700; }
.auth-document.is-registration-success > header {
    padding: 105px 25px 18px;
    text-align: center;
}
.auth-document.is-registration-success [data-auth-custom-body] { padding: 0 !important; }
.auth-registration-success { width: 100%; margin: 0; text-align: center; line-height: 1.5; }
.auth-registration-success-mascot {
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;
    max-height: none;
    margin: 0;
    object-fit: contain;
}
.auth-registration-success-copy { padding: 18px 28px 28px; }
.auth-registration-success p { margin: 0 0 12px; }
.auth-success-check { color: #20a63a; font-size: 54px; line-height: 1; font-weight: 900; }
.auth-registration-return { width: min(100%, 360px); margin: 18px auto 0; }
.auth-inline { display: flex; align-items: center; gap: 10px; }
.auth-inline .auth-input { flex: 1; }

@media (max-width: 800px) {
    html, body { min-height: 100%; min-height: 100dvh; }
    .auth-layout {
        width: 100%;
        max-width: 680px;
        margin: 15px auto;
        padding: 0 10px;
        grid-template-columns: 1fr;
        gap: 20px;
    }
    .auth-panel { width: 100%; padding: 30px; }
    .auth-register-page .auth-form-panel,
    .auth-register-page .auth-door-panel { padding: 25px 20px; }
    .auth-register-page .auth-form-panel { padding-bottom: max(42px, calc(24px + env(safe-area-inset-bottom))); }
    .auth-documents-title { scroll-margin-top: max(12px, env(safe-area-inset-top)); }
    .auth-door-panel { min-height: 400px; }
    .auth-register-page .auth-door-panel {
        min-height: calc(400px + var(--auth-mobile-scroll-reserve, 0px));
    }
    .auth-document { max-height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 20px); }
    .auth-register-page .auth-document { max-height: none; }
    .auth-document header { padding-bottom: 12px; }
    .auth-document footer { padding-top: 12px; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
    .auth-top { flex-wrap: wrap; gap: 12px 15px; }
    .auth-top a { font-size: 13px; }
    .auth-actions { grid-template-columns: 1fr; gap: 12px; }
    .auth-avatar-box { margin: 16px 0; padding: 14px; }
    .auth-avatar-buttons { grid-template-columns: 1fr; gap: 9px; }
    .auth-document-row { grid-template-columns: 1fr; gap: 5px; }
    .auth-document-check { min-width: 0; text-align: center; }
    .auth-avatar-categories { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
    .auth-avatar-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
    .auth-document header { padding: 14px 18px 8px; }
    .auth-document footer { padding: 8px 18px max(12px, env(safe-area-inset-bottom)); }
    .auth-document header { font-size: 20px; }
    .auth-document.is-registration-success > header { padding: 28px 18px 16px; }
    .auth-registration-success-copy { padding: 16px 18px 22px; }
    .auth-door { padding: 25px 20px; }
}

@media (max-width: 480px) {
    .auth-layout { margin: 10px auto; padding: 0 8px; }
    .auth-panel, .auth-register-page .auth-form-panel,
    .auth-register-page .auth-door-panel { padding: 24px 16px; border-radius: 14px; }
    .auth-title { font-size: 26px; }
    .auth-logo { max-width: 280px; }
    .auth-button, .auth-input { min-height: 48px; }
    .auth-account-types__options { grid-template-columns: 1fr; }
    .auth-account-type { flex-wrap: wrap; }
    .auth-account-type input { top: 25px; transform: translateY(-50%); }
    .auth-account-type__tooltip {
        position: static;
        width: 100%;
        max-width: none;
        max-height: 0;
        padding: 0 9px;
        overflow: hidden;
        transform: none;
    }
    .auth-account-type__tooltip::after { display: none; }
    .auth-account-type:hover .auth-account-type__tooltip,
    .auth-account-type:focus-within .auth-account-type__tooltip {
        max-height: 80px;
        margin-top: 5px;
        padding: 7px 9px;
        transform: none;
    }
}

@media (max-height: 700px) and (min-width: 801px) {
    .auth-layout { margin-top: 20px; margin-bottom: 20px; }
    .auth-panel { padding-top: 36px; padding-bottom: 36px; }
    .auth-door-panel { min-height: 580px; }
}

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