:root {
    --panel-duration: 500ms;
    --control-exit-duration: 160ms;
    --control-exit-stagger: 35ms;
    --control-enter-duration: 280ms;
    --control-enter-stagger: 55ms;
    font-family: "Segoe UI", "Microsoft YaHei", "Microsoft Uighur", "Noto Sans Arabic", "Noto Sans", Arial, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #8e9aaf;
    font-family: inherit;
    background: linear-gradient(200deg, #f3e7e9, #e3eeff);
}

button,
input {
    font: inherit;
}

html.i18n-pending .i18n-text {
    visibility: hidden;
    opacity: 0;
}

@keyframes reveal-i18n-text {
    to {
        visibility: visible;
        opacity: 1;
    }
}

html.i18n-pending.i18n-reveal-fallback .i18n-text {
    animation: reveal-i18n-text 1ms ease 1200ms forwards;
}

html[dir="rtl"] .i18n-text,
html[dir="rtl"] input,
html[dir="rtl"] input::placeholder,
html[dir="rtl"] .language-menu {
    direction: rtl;
    text-align: right;
}

.language-control {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 10;
}

.language-toggle {
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
    border: 0;
    background: transparent;
    box-shadow: none;
    cursor: pointer;
}

.language-toggle:hover {
    animation: language-toggle-bounce 300ms ease-out;
}

@keyframes language-toggle-bounce {
    0% {
        transform: translateY(0);
    }
    38% {
        transform: translateY(-4px);
    }
    100% {
        transform: translateY(0);
    }
}

.language-toggle img {
    width: 40px;
    height: 40px;
    object-fit: contain;
    filter: drop-shadow(0 5px 7px rgba(66, 90, 131, 0.35));
}

.language-toggle:focus-visible,
.language-menu button:focus-visible,
.side-switch:focus-visible,
.form-box button:focus-visible,
input:focus-visible {
    outline: 3px solid rgba(93, 207, 241, 0.75);
    outline-offset: 3px;
}

.language-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 150px;
    padding: 6px;
    border: 1px solid rgba(66, 90, 131, 0.14);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 10px 28px rgba(66, 90, 131, 0.2);
    opacity: 0;
    transform: translateY(-8px);
    transform-origin: top right;
    transition: opacity 180ms ease, transform 180ms ease;
}

.language-menu.is-open {
    opacity: 1;
    transform: translateY(0);
}

.language-menu.is-closing {
    opacity: 0;
    transform: translateY(-8px);
    transition-duration: 140ms;
}

.language-menu button {
    display: block;
    width: 100%;
    padding: 8px 10px;
    border: 0;
    border-radius: 7px;
    color: #425a83;
    background: transparent;
    text-align: left;
    cursor: pointer;
}

.language-menu button:hover,
.language-menu button[aria-checked="true"] {
    color: #fff;
    background: #677ea5;
}

html.is-language-changing .i18n-text {
    opacity: 0;
    transition: opacity 160ms ease;
}

html.is-language-changing input::placeholder {
    opacity: 0;
    transition: opacity 160ms ease;
}

html.is-language-entering .i18n-text {
    animation: language-text-enter 240ms ease both;
}

html.is-language-entering input::placeholder {
    animation: language-placeholder-enter 240ms ease both;
}

@keyframes language-text-enter {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes language-placeholder-enter {
    from { opacity: 0; }
    to { opacity: 1; }
}

.container {
    position: relative;
    width: 650px;
    height: min(415px, calc(100dvh - 32px));
    border-radius: 5px;
    background: #fff;
    box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.1);
}

.form-box {
    position: absolute;
    top: 50%;
    left: 5%;
    z-index: 2;
    width: 320px;
    height: min(500px, calc(100dvh - 32px));
    max-height: calc(100dvh - 32px);
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 5px;
    background: #425a83;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    transform: translateY(-50%);
    transition: transform var(--panel-duration) ease-in-out;
}

.form-box.position-login {
    transform: translateY(-50%) translateX(0);
}

.form-box.position-register {
    transform: translateY(-50%) translateX(80%);
}

.form-panel {
    position: absolute;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    transition: opacity 120ms ease;
}

.form-panel-inactive {
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
}

.form-panel-active {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
}

.form-panel form {
    width: 100%;
    height: 100%;
    min-height: 0;
    overflow-y: auto;
    padding: 24px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.login-box form {
    justify-content: center;
}

@media (hover: hover) and (pointer: fine) {
    .register-box form {
        scrollbar-width: thin;
        scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
    }

    .register-box form::-webkit-scrollbar {
        width: 4px;
    }

    .register-box form::-webkit-scrollbar-track {
        background: transparent;
    }

    .register-box form::-webkit-scrollbar-thumb {
        border-radius: 999px;
        background: rgba(255, 255, 255, 0.2);
    }

    .register-box form:hover::-webkit-scrollbar-thumb,
    .register-box form:focus-within::-webkit-scrollbar-thumb {
        background: rgba(255, 255, 255, 0.42);
    }
}

h1 {
    margin-bottom: 25px;
    color: #fff;
    font-size: 24px;
    letter-spacing: 5px;
    text-align: center;
}

.form-field {
    width: 70%;
    position: relative;
}

input {
    width: 100%;
    margin: 5px 0;
    padding: 10px 0;
    border: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.4);
    color: #fff;
    background: transparent;
    font-size: 14px;
    letter-spacing: 2px;
    text-indent: 10px;
}

input::placeholder {
    color: #fff;
}

input:focus {
    outline: none;
    border-bottom-color: #5dcff180;
}

input:focus::placeholder {
    opacity: 0;
}

input.is-invalid {
    border-bottom-color: #ffb4b4;
}

input.is-shaking {
    animation: invalid-field-shake 280ms ease-out;
}

.field-error-message {
    min-height: 14px;
    display: block;
    margin: -3px 0 1px;
    color: #ffd1d1;
    font-size: 11px;
    line-height: 14px;
    letter-spacing: 0;
    text-align: left;
}

.field-help,
.password-policy {
    display: block;
    min-height: 14px;
    color: rgba(255, 255, 255, 0.72);
    font-size: 10px;
    line-height: 14px;
    letter-spacing: 0;
    text-align: left;
}

.password-meter {
    width: 100%;
    display: flex;
    gap: 4px;
    margin: 2px 0 2px;
}

.password-meter-segment {
    flex: 1;
    height: 4px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.22);
    transition: background 160ms ease;
}

.password-meter[hidden],
.password-policy[hidden] {
    display: none;
}

.password-meter-segment.is-weak { background: #ef6a6a; }
.password-meter-segment.is-medium { background: #f2c45e; }
.password-meter-segment.is-strong { background: #5bd38c; }

.auth-status {
    width: 70%;
    min-height: 18px;
    margin-top: 10px;
    color: #d7f9e5;
    font-size: 11px;
    line-height: 16px;
    letter-spacing: 0;
    text-align: left;
}

.auth-status.is-error {
    color: #ffd1d1;
}

.resend-entry {
    width: 70%;
    margin-top: 8px;
}

.resend-entry input {
    margin-top: 0;
}

.resend-button {
    width: 100%;
    margin-top: 6px;
    padding: 8px;
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: 6px;
    color: #fff;
    background: transparent;
    font-size: 11px;
    cursor: pointer;
}

.resend-button:hover {
    background: rgba(255, 255, 255, 0.15);
}

.resend-button:disabled,
.form-box form > button:disabled {
    cursor: wait;
    opacity: 0.55;
}

[dir="rtl"] .field-error-message {
    text-align: right;
}

@keyframes invalid-field-shake {
    0%, 100% { transform: translateX(0); }
    30% { transform: translateX(-5px); }
    65% { transform: translateX(5px); }
}

.form-box form > button {
    width: 70%;
    margin-top: 24px;
    padding: 13px;
    border: 0;
    border-radius: 8px;
    color: #8e9aaf;
    background: #f6f6f6;
    letter-spacing: 2px;
    cursor: pointer;
}

.form-box form > button.is-flashing {
    animation: registration-button-flash 360ms ease-out;
}

@keyframes registration-button-flash {
    0%, 100% { transform: scale(1); }
    45% { transform: scale(1.04); box-shadow: 0 0 0 4px rgba(93, 207, 241, 0.35); }
}

.form-box form > button:hover {
    color: #f6f6f6;
    background: #2c3950;
}

.con-box {
    position: absolute;
    top: 50%;
    width: 50%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transform: translateY(-50%);
}

.con-box.left {
    left: -2%;
}

.con-box.right {
    right: -2%;
}

.con-box h2 {
    margin-bottom: 4px;
    color: #8e9aaf;
    font-size: 25px;
    font-weight: bold;
    letter-spacing: 3px;
    text-align: center;
}

.con-box p {
    color: #8e9aaf;
    font-size: 12px;
    letter-spacing: 2px;
    text-align: center;
}

.con-box img {
    width: 200px;
    height: 200px;
    margin: 10px 0;
    object-fit: contain;
    opacity: 0.9;
}

.side-switch {
    margin-top: 3%;
    padding: 6px 10px;
    border: 1px solid #8e9aaf;
    border-radius: 5px;
    color: #8e9aaf;
    background: #fff;
    letter-spacing: 1px;
    cursor: pointer;
}

.side-switch:hover {
    color: #fff;
    background: #677ea5;
}

.side-switch.is-bouncing {
    animation: language-toggle-bounce 300ms ease-out;
}

.is-exiting > form > h1,
.is-exiting > form > .form-field,
.is-exiting > form > button,
.is-entering > form > h1,
.is-entering > form > .form-field,
.is-entering > form > button {
    animation-fill-mode: both;
    animation-timing-function: ease-out;
}

.verification-code-field[hidden] {
    display: none;
}

.is-entering[data-enter-direction="left"] > form > h1,
.is-entering[data-enter-direction="left"] > form > .form-field,
.is-entering[data-enter-direction="left"] > form > button {
    animation-name: control-enter-from-left;
}

.is-entering[data-enter-direction="right"] > form > h1,
.is-entering[data-enter-direction="right"] > form > .form-field,
.is-entering[data-enter-direction="right"] > form > button {
    animation-name: control-enter-from-right;
}

.is-exiting[data-exit-direction="left"] > form > h1,
.is-exiting[data-exit-direction="left"] > form > .form-field,
.is-exiting[data-exit-direction="left"] > form > button {
    animation-name: control-exit-to-left;
}

.is-exiting[data-exit-direction="right"] > form > h1,
.is-exiting[data-exit-direction="right"] > form > .form-field,
.is-exiting[data-exit-direction="right"] > form > button {
    animation-name: control-exit-to-right;
}

.is-exiting > form > h1,
.is-exiting > form > .form-field,
.is-exiting > form > button {
    animation-name: control-exit;
    animation-duration: var(--control-exit-duration);
}

.is-entering > form > h1,
.is-entering > form > .form-field,
.is-entering > form > button {
    animation-name: control-enter;
    animation-duration: var(--control-enter-duration);
}

.is-exiting > form > :nth-child(1) { animation-delay: 0ms; }
.is-exiting > form > :nth-child(2) { animation-delay: var(--control-exit-stagger); }
.is-exiting > form > :nth-child(3) { animation-delay: calc(var(--control-exit-stagger) * 2); }
.is-exiting > form > :nth-child(4) { animation-delay: calc(var(--control-exit-stagger) * 3); }
.is-exiting > form > :nth-child(5) { animation-delay: calc(var(--control-exit-stagger) * 4); }
.is-exiting > form > :nth-child(6) { animation-delay: calc(var(--control-exit-stagger) * 5); }
.is-entering > form > :nth-child(1) { animation-delay: 0ms; }
.is-entering > form > :nth-child(2) { animation-delay: var(--control-enter-stagger); }
.is-entering > form > :nth-child(3) { animation-delay: calc(var(--control-enter-stagger) * 2); }
.is-entering > form > :nth-child(4) { animation-delay: calc(var(--control-enter-stagger) * 3); }
.is-entering > form > :nth-child(5) { animation-delay: calc(var(--control-enter-stagger) * 4); }
.is-entering > form > :nth-child(6) { animation-delay: calc(var(--control-enter-stagger) * 5); }

@keyframes control-exit {
    to {
        opacity: 0;
        transform: translate(12px, 8px);
    }
}

@keyframes control-enter {
    from {
        opacity: 0;
        transform: translate(-14px, -10px);
    }
    to {
        opacity: 1;
        transform: translate(0, 0);
    }
}

@keyframes control-enter-from-left {
    from { opacity: 0; transform: translateX(-18px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes control-enter-from-right {
    from { opacity: 0; transform: translateX(18px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes control-exit-to-left {
    to { opacity: 0; transform: translateX(-12px); }
}

@keyframes control-exit-to-right {
    to { opacity: 0; transform: translateX(12px); }
}

@media (prefers-reduced-motion: reduce) {
    .form-box,
    .form-panel,
    .is-exiting > form > h1,
    .is-exiting > form > .form-field,
    .is-exiting > form > button,
    .is-entering > form > h1,
    .is-entering > form > .form-field,
    .is-entering > form > button {
        animation: none !important;
        transition: none !important;
    }

    .language-menu,
    .language-toggle,
    .language-toggle:hover,
    .side-switch.is-bouncing,
    .side-switch:hover,
    input.is-shaking,
    html.is-language-changing .i18n-text,
    html.is-language-changing input::placeholder,
    html.is-language-entering .i18n-text,
    html.is-language-entering input::placeholder {
        animation: none !important;
        transition: none !important;
    }
}

@media (max-width: 720px) {
    body {
        align-items: flex-start;
        padding: 64px 14px 24px;
        overflow-x: hidden;
    }

    .container {
        width: min(100%, 520px);
        height: min(620px, calc(100dvh - 88px));
        max-height: calc(100dvh - 88px);
        margin: 0 auto;
    }

    .form-box {
        top: 24px;
        left: 8%;
        width: 84%;
        top: 24px;
        height: min(430px, calc(100dvh - 112px));
        max-height: calc(100dvh - 112px);
        min-height: 0;
        padding: 26px 0;
        transform: none !important;
    }

    .form-box.position-register,
    .form-box.position-login {
        transform: none;
    }

    .con-box {
        top: auto;
        bottom: 24px;
        width: 100%;
        transform: none;
    }

    .con-box.left,
    .con-box.right {
        left: 0;
        right: 0;
    }

    .form-box.position-login ~ .con-box.right,
    .form-box.position-register ~ .con-box.left {
        display: none;
    }

    .con-box img,
    .con-box h2,
    .con-box p:first-of-type {
        display: none;
    }

    .con-box p:last-of-type {
        margin-top: 0;
    }

    .con-box .side-switch {
        margin-top: 8px;
    }
}
