:root {
    color-scheme: dark;
    --auth-bg: #070b16;
    --auth-panel: #0b1120;
    --auth-card: rgba(16, 24, 42, .96);
    --auth-input: #0c1527;
    --auth-border: #25324b;
    --auth-border-strong: #3b4b6b;
    --auth-text: #f5f7ff;
    --auth-muted: #9aa7be;
    --auth-purple: #8d59ff;
    --auth-blue: #4b82ff;
    --auth-orange: #ff9f1c;
    --auth-green: #35cf78;
    --auth-danger: #ff6b7e;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
    margin: 0;
    min-width: 320px;
    background: var(--auth-bg);
    color: var(--auth-text);
    font-size: 16px;
    overflow-x: hidden;
}
button, input { font: inherit; }
.auth-page [hidden], .auth-dialog [hidden] { display: none !important; }

.auth-page {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(480px, 1.04fr) minmax(520px, .96fr);
    background:
        radial-gradient(circle at 72% 12%, rgba(76, 121, 255, .11), transparent 32%),
        var(--auth-bg);
}

.auth-left {
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding: clamp(28px, 4vw, 58px) clamp(36px, 5vw, 78px) 28px;
    overflow: hidden;
    background:
        radial-gradient(circle at 8% 44%, rgba(141, 89, 255, .13), transparent 30%),
        linear-gradient(145deg, #09101f 0%, #080d19 48%, #0a1020 100%);
    border-right: 1px solid rgba(61, 75, 106, .42);
}
.auth-left::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: .18;
    background-image: linear-gradient(rgba(255,255,255,.03) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.03) 1px, transparent 1px);
    background-size: 34px 34px;
    mask-image: linear-gradient(to bottom, transparent, #000 24%, transparent 92%);
}

.auth-brand, .auth-mobile-brand {
    position: relative;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    gap: 12px;
    width: max-content;
    color: var(--auth-text);
    text-decoration: none;
}
.auth-brand__mark {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 13px;
    font-size: 23px;
    font-weight: 800;
    background: linear-gradient(145deg, #ffad2d 0%, #8e50ed 76%);
    box-shadow: 0 12px 30px rgba(126, 77, 225, .28);
}
.auth-brand strong { display: block; font-size: 20px; line-height: 1.1; }
.auth-brand small { display: block; margin-top: 4px; color: var(--auth-muted); font-size: 12px; font-weight: 500; }
.auth-mobile-brand { display: none; }

.auth-presentation {
    position: relative;
    z-index: 1;
    width: min(100%, 610px);
    margin: clamp(48px, 8vh, 96px) 0 18px;
}
.auth-eyebrow, .auth-card__eyebrow, .auth-dialog__header > div > span {
    display: inline-block;
    color: #aa79ff;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .12em;
}
.auth-headline {
    margin: 15px 0 14px;
    color: var(--auth-text);
    font-size: clamp(38px, 4vw, 62px);
    line-height: 1.08;
    letter-spacing: -.045em;
}
.auth-headline span { color: #a96eff; }
.auth-headline em { color: var(--auth-orange); font-style: normal; }
.auth-subtitle {
    max-width: 560px;
    margin: 0;
    color: #a9b4c8;
    font-size: 16px;
    line-height: 1.7;
}

.auth-features {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px 28px;
    margin-top: 36px;
}
.auth-feature { display: flex; align-items: flex-start; gap: 13px; min-width: 0; }
.auth-feature .icon-badge { width: 40px; height: 40px; flex: 0 0 40px; border-radius: 12px; }
.auth-feature h2 { margin: 1px 0 4px; font-size: 14px; line-height: 1.35; }
.auth-feature p { margin: 0; color: var(--auth-muted); font-size: 12px; line-height: 1.45; }

.auth-illustration {
    position: absolute;
    z-index: 1;
    right: clamp(18px, 4vw, 64px);
    bottom: 42px;
    width: min(48vw, 520px);
    opacity: .96;
    pointer-events: none;
}
.auth-illustration svg { display: block; width: 100%; height: auto; }
.auth-footer { position: relative; z-index: 2; margin: auto 0 0; color: #6f7d96; font-size: 12px; }

.auth-right {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 0;
    padding: 38px clamp(28px, 5vw, 78px);
}
.auth-card {
    width: min(100%, 500px);
    padding: clamp(30px, 4vw, 46px);
    border: 1px solid rgba(55, 70, 101, .78);
    border-radius: 22px;
    background: linear-gradient(160deg, rgba(20, 30, 51, .97), rgba(12, 19, 34, .98));
    box-shadow: 0 28px 70px rgba(0, 0, 0, .35), inset 0 1px 0 rgba(255,255,255,.03);
}
.auth-card__intro { text-align: center; }
.auth-card__intro h2 { margin: 9px 0 8px; font-size: 30px; letter-spacing: -.025em; }
.auth-card__intro p { margin: 0 0 26px; color: var(--auth-muted); font-size: 14px; line-height: 1.55; }

.auth-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 7px;
    padding: 5px;
    margin-bottom: 24px;
    border: 1px solid #25324a;
    border-radius: 13px;
    background: #0b1425;
}
.auth-tab {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    border: 0;
    border-radius: 9px;
    color: var(--auth-muted);
    background: transparent;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: color .2s ease, background .2s ease, box-shadow .2s ease;
}
.auth-tab .icon { width: 18px; height: 18px; }
.auth-tab:hover { color: var(--auth-text); }
.auth-tab.is-active { color: #fff; background: linear-gradient(135deg, #486ef9, #8c4ff0); box-shadow: 0 8px 20px rgba(101, 76, 241, .25); }

.form-group { margin-bottom: 17px; }
.form-group > label { display: block; margin: 0 0 8px; color: #dbe2f2; font-size: 14px; font-weight: 700; }
.form-input {
    display: flex;
    align-items: center;
    gap: 11px;
    min-height: 48px;
    padding: 0 14px;
    border: 1px solid var(--auth-border);
    border-radius: 10px;
    background: var(--auth-input);
    transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}
.form-input:focus-within { border-color: #6d66ee; box-shadow: 0 0 0 3px rgba(109, 102, 238, .16); background: #0e192d; }
.form-input.is-invalid { border-color: var(--auth-danger); box-shadow: 0 0 0 3px rgba(255, 107, 126, .12); }
.form-input > .icon { width: 18px; height: 18px; flex: 0 0 18px; color: #74829b; }
.form-input input { flex: 1; min-width: 0; border: 0; outline: 0; color: var(--auth-text); background: transparent; font-size: 14px; }
.form-input input::placeholder { color: #66748d; }
.form-input input:-webkit-autofill, .form-input input:-webkit-autofill:hover, .form-input input:-webkit-autofill:focus { -webkit-text-fill-color: var(--auth-text); -webkit-box-shadow: 0 0 0 1000px var(--auth-input) inset; transition: background-color 9999s ease-in-out 0s; }
.form-input__toggle, .dialog-close, .auth-link { border: 0; padding: 0; color: #8997ae; background: transparent; cursor: pointer; }
.form-input__toggle { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; }
.form-input__toggle:hover { color: #fff; background: rgba(255,255,255,.05); }

.field-error { min-height: 17px; margin: 5px 0 0; color: #ff8494; font-size: 12px; line-height: 1.35; }
.field-hint { display: block; margin: 6px 0 0; color: #7f8da5; font-size: 12px; line-height: 1.45; }
.auth-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 2px 0 20px; }
.checkbox { display: inline-flex; align-items: flex-start; gap: 9px; color: #aeb9ca; font-size: 13px; line-height: 1.45; cursor: pointer; }
.checkbox input { position: absolute; opacity: 0; pointer-events: none; }
.checkbox__box { position: relative; flex: 0 0 18px; width: 18px; height: 18px; margin-top: 1px; border: 1px solid #41506d; border-radius: 5px; background: #0b1425; }
.checkbox input:focus-visible + .checkbox__box { outline: 3px solid rgba(108, 98, 244, .38); outline-offset: 2px; }
.checkbox input:checked + .checkbox__box { border-color: #725cf3; background: linear-gradient(135deg, #5078ff, #9755ee); }
.checkbox input:checked + .checkbox__box::after { content: ""; position: absolute; left: 5px; top: 2px; width: 5px; height: 9px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.auth-link { color: #ab7aff; font-size: 13px; font-weight: 700; text-decoration: none; }
.auth-link:hover { color: #c59fff; text-decoration: underline; }

.auth-submit { position: relative; min-height: 48px; justify-content: center; width: 100%; font-size: 14px; font-weight: 800; }
.auth-submit.is-loading, button.is-loading { pointer-events: none; opacity: .78; }
.button-spinner { display: none; width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.35); border-top-color: #fff; border-radius: 50%; animation: auth-spin .75s linear infinite; }
.is-loading .button-spinner { display: inline-block; }
@keyframes auth-spin { to { transform: rotate(360deg); } }

.auth-divider { display: flex; align-items: center; gap: 12px; margin: 24px 0 17px; color: #6d7a92; font-size: 12px; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: #243149; }
.social-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.social-btn { justify-content: center; min-height: 45px; gap: 9px; color: #dce2ee; border-color: #2c3a55; background: rgba(12, 21, 39, .72); font-size: 13px; }
.social-btn:hover { border-color: #526383; background: #111d32; }
.social-btn svg { width: 18px; height: 18px; }
.auth-signup { margin: 23px 0 0; text-align: center; color: #9ba8bd; font-size: 13px; }
.auth-security-note { display: flex; align-items: center; justify-content: center; gap: 7px; margin: 20px 0 0; color: #6f7d95; font-size: 12px; }
.auth-security-note .icon { width: 14px; height: 14px; color: var(--auth-green); }
.auth-back-link { display: block; margin-top: 18px; text-align: center; color: #ae7dff; font-size: 13px; text-decoration: none; }

.auth-feedback { margin: 0 0 18px; padding: 11px 13px; border: 1px solid rgba(255, 107, 126, .38); border-radius: 9px; color: #ffc1c9; background: rgba(255, 85, 108, .09); font-size: 13px; line-height: 1.45; }
.auth-feedback.is-info { color: #c8d8ff; border-color: rgba(76, 130, 255, .38); background: rgba(76, 130, 255, .09); }
.auth-feedback.is-success { color: #b7f3cf; border-color: rgba(53, 207, 120, .35); background: rgba(53, 207, 120, .09); }
.auth-feedback[hidden], .auth-toast[hidden] { display: none !important; }

.auth-dialog {
    width: min(680px, calc(100vw - 32px));
    max-height: calc(100vh - 32px);
    margin: auto;
    padding: 0;
    border: 1px solid #32415e;
    border-radius: 18px;
    color: var(--auth-text);
    background: #0e1729;
    box-shadow: 0 30px 90px rgba(0,0,0,.62);
    overflow: hidden;
}
.auth-dialog::backdrop { background: rgba(2, 6, 14, .78); backdrop-filter: blur(7px); }
.auth-dialog__panel { max-height: calc(100vh - 32px); display: flex; flex-direction: column; margin: 0; }
.auth-dialog__header { display: flex; justify-content: space-between; gap: 20px; padding: 24px 26px 19px; border-bottom: 1px solid #273550; }
.auth-dialog__header h2 { margin: 6px 0 5px; font-size: 22px; }
.auth-dialog__header p { margin: 0; color: var(--auth-muted); font-size: 13px; }
.dialog-close { display: grid; place-items: center; flex: 0 0 36px; width: 36px; height: 36px; border: 1px solid #354461; border-radius: 9px; }
.dialog-close:hover { color: #fff; background: #18243a; }
.auth-dialog__body { padding: 23px 26px; overflow-y: auto; }
.auth-dialog__footer { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 26px; border-top: 1px solid #273550; background: #0b1424; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.auth-toast { position: fixed; z-index: 100; right: 24px; bottom: 24px; max-width: min(390px, calc(100vw - 32px)); padding: 13px 16px; border: 1px solid #3a4a68; border-radius: 11px; color: #eaf0ff; background: #131e33; box-shadow: 0 18px 48px rgba(0,0,0,.42); font-size: 13px; }

button:focus-visible, a:focus-visible, input:focus-visible { outline: 3px solid rgba(123, 97, 255, .5); outline-offset: 3px; }

@media (max-width: 1120px) {
    .auth-page { grid-template-columns: minmax(390px, .84fr) minmax(500px, 1.16fr); }
    .auth-left { padding-left: 42px; padding-right: 42px; }
    .auth-features { grid-template-columns: 1fr; gap: 13px; }
    .auth-feature:nth-child(n+4) { display: none; }
    .auth-illustration { width: 380px; right: 8px; opacity: .68; }
}

@media (max-width: 880px) {
    .auth-page { display: block; min-height: 100vh; }
    .auth-left { display: none; }
    .auth-right { min-height: 100vh; padding: 28px 20px; }
    .auth-mobile-brand { display: inline-flex; align-self: flex-start; margin: 0 auto 24px 0; }
    .auth-mobile-brand .auth-brand__mark { width: 39px; height: 39px; font-size: 20px; }
    .auth-card { max-width: 540px; }
}

@media (max-width: 560px) {
    .auth-right { justify-content: flex-start; padding: 20px 14px 30px; }
    .auth-card { padding: 27px 20px; border-radius: 17px; }
    .auth-card__intro h2 { font-size: 25px; }
    .social-grid, .form-grid { grid-template-columns: 1fr; }
    .auth-row { align-items: flex-start; }
    .auth-dialog { width: calc(100vw - 20px); max-height: calc(100vh - 20px); }
    .auth-dialog__panel { max-height: calc(100vh - 20px); }
    .auth-dialog__header, .auth-dialog__body { padding-left: 19px; padding-right: 19px; }
    .auth-dialog__footer { padding: 14px 19px; flex-wrap: wrap; }
}

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