:root {
    --cs-font-sans: "Geist", "Avenir Next", sans-serif;
    --auth-accent: #b6532f;
    --auth-accent-hover: #984323;
    --auth-ink: #19231e;
    --auth-muted: #647169;
    --auth-border: #d9e2dc;
    --auth-canvas: #f3f6f4;
    --auth-surface: #ffffff;
    --auth-field: #ffffff;
    --auth-label: #344139;
    --auth-divider: #e8ede9;
    --auth-shadow: 25, 43, 33;
    --auth-action-text: #ffffff;
}

html[data-theme="dark"] {
    --auth-accent: #b6532f;
    --auth-accent-hover: #984323;
    --auth-ink: #eff4f0;
    --auth-muted: #a7b4ab;
    --auth-border: #3a4940;
    --auth-canvas: #151b18;
    --auth-surface: #1d2521;
    --auth-field: #171e1a;
    --auth-label: #d5ded8;
    --auth-divider: #344039;
    --auth-shadow: 0, 0, 0;
    --auth-action-text: #ffffff;
}

.auth-page,
.auth-flow-page {
    color: var(--auth-ink);
    font-family: var(--cs-font-sans);
}

.auth-page {
    min-height: 100vh;
    grid-template-columns: minmax(0, .92fr) minmax(0, 1.08fr);
    background: var(--auth-canvas);
}

.auth-page .auth-showcase {
    display: flex;
    align-items: center;
    padding: 56px;
    color: #f5f7f4;
    background-color: #18211f;
    background-image: linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px);
    background-size: 36px 36px;
}

.auth-page .auth-showcase::before,
.auth-page .auth-showcase::after {
    content: none;
}

.auth-page .showcase-content {
    width: min(100%, 520px);
    margin: auto;
}

.auth-page .brand {
    margin-bottom: 76px;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
}

.auth-page .brand-mark {
    width: 42px;
    height: 42px;
    border: 1px solid rgba(255,255,255,.2);
    border-radius: 10px;
    background: rgba(255,255,255,.08);
}

.auth-page .brand-logo {
    display: block;
    width: 30px;
    height: 30px;
}

.auth-page .showcase-content h1 {
    margin: 0 0 18px;
    font-size: 3.25rem;
    font-weight: 600;
    line-height: 1.08;
    letter-spacing: 0;
}

.auth-page .showcase-content p {
    max-width: 430px;
    color: #c6cfca;
    font-size: 1rem;
    line-height: 1.7;
}

.auth-page .math-card {
    width: fit-content;
    margin-top: 34px;
    padding: 16px 20px;
    border: 1px solid rgba(255,255,255,.15);
    border-radius: 8px;
    background: rgba(255,255,255,.06);
    font-size: 1.05rem;
}

.auth-page .auth-form-side {
    min-width: 0;
    padding: 48px;
    background: #fff;
}

.auth-page .auth-card {
    max-width: 440px;
    margin-inline: auto;
}

.auth-page .auth-card > .subtitle {
    display: none;
}

.auth-page .auth-card h2 {
    color: var(--auth-ink);
    font-size: 1.9rem;
    font-weight: 650;
    letter-spacing: 0;
}

.auth-page .subtitle {
    color: var(--auth-muted);
    font-size: .95rem;
}

.auth-page .field label,
.auth-page .otp-input label {
    color: #34403b;
    font-size: .88rem;
    font-weight: 600;
}

.auth-page .field input,
.auth-page .field select,
.auth-page .field textarea,
.auth-page .otp-input input {
    width: 100%;
    min-height: 48px;
    border: 1px solid var(--auth-border);
    border-radius: 8px;
    background: #fff;
    color: var(--auth-ink);
    font: inherit;
}

.auth-page .field input:focus,
.auth-page .field select:focus,
.auth-page .field textarea:focus,
.auth-page .otp-input input:focus {
    border-color: var(--auth-accent);
    box-shadow: 0 0 0 3px rgba(200,92,43,.12);
}

.auth-page .auth-submit,
.auth-page .send-btn {
    min-height: 48px;
    border: 1px solid var(--auth-accent);
    border-radius: 8px;
    background: var(--auth-accent);
    color: #fff;
    font: inherit;
    font-weight: 650;
    box-shadow: none;
}

.auth-page .auth-submit:hover:not(:disabled),
.auth-page .send-btn:hover:not(:disabled) {
    border-color: var(--auth-accent-hover);
    background: var(--auth-accent-hover);
    box-shadow: none;
    transform: translateY(-1px);
}

.auth-page .auth-submit:disabled,
.auth-page .send-btn:disabled {
    cursor: not-allowed;
    opacity: .55;
}

.auth-page .auth-link {
    color: var(--auth-muted);
    font-size: .9rem;
}

.auth-page .auth-link a,
.auth-page .auth-link a:hover {
    color: var(--auth-accent-hover);
}

.auth-page .google-btn {
    min-height: 48px;
    border-radius: 8px;
    font: inherit;
}

.auth-page .field-error,
.auth-page .errors {
    color: #b42318;
}

.auth-flow-page {
    min-height: calc(100vh - 68px);
    display: grid;
    place-items: center;
    padding: 48px 20px;
    color: var(--auth-ink);
    background:
        radial-gradient(ellipse at 50% 0, color-mix(in srgb, var(--auth-accent) 9%, transparent), transparent 56%),
        var(--auth-canvas);
}

.auth-flow-page .auth-flow-card {
    width: min(100%, 500px);
    overflow: hidden;
    border: 1px solid var(--auth-border);
    border-radius: 12px;
    background: var(--auth-surface);
    box-shadow: 0 22px 60px rgba(var(--auth-shadow), .12);
}

.auth-flow-page .auth-flow-heading {
    padding: 30px 34px 24px;
    border-bottom: 1px solid var(--auth-divider);
    background: var(--auth-surface);
    text-align: left;
}

.auth-flow-page .auth-flow-mark {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    margin-bottom: 20px;
    border: 1px solid color-mix(in srgb, var(--auth-accent) 28%, transparent);
    border-radius: 10px;
    background: color-mix(in srgb, var(--auth-accent) 11%, var(--auth-surface));
    color: var(--auth-accent);
    font-size: 1.1rem;
}

.auth-flow-page .auth-flow-kicker {
    display: block;
    margin-bottom: 7px;
    color: var(--auth-accent);
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .08em;
}

.auth-flow-page .auth-flow-heading h1 {
    margin: 0 0 8px;
    color: var(--auth-ink);
    font-size: 1.7rem;
    font-weight: 650;
    line-height: 1.2;
}

.auth-flow-page .auth-flow-heading p {
    margin: 0;
    color: var(--auth-muted);
    font-size: .92rem;
}

.auth-flow-page .auth-flow-body {
    padding: 26px 34px 30px;
}

.auth-flow-page .auth-flow-body label {
    display: block;
    margin: 0 0 7px;
    color: var(--auth-label);
    font-size: .88rem;
    font-weight: 600;
}

.auth-flow-page .auth-flow-body .form-control {
    min-height: 48px;
    height: auto;
    margin-bottom: 14px;
    border: 1px solid var(--auth-border);
    border-radius: 8px;
    background: var(--auth-field);
    color: var(--auth-ink);
    font: inherit;
    transition: border-color .16s ease, box-shadow .16s ease, background-color .16s ease;
}

.auth-flow-page .auth-flow-body .form-control::placeholder {
    color: var(--auth-muted);
    opacity: .75;
}

.auth-flow-page .auth-flow-body .form-control:focus {
    border-color: var(--auth-accent);
    box-shadow: 0 0 0 3px rgba(200,92,43,.12);
}

.auth-flow-page .otp-section {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: 10px;
    margin-top: 8px;
}

.auth-flow-page .otp-section .form-control {
    margin-bottom: 0;
}

.auth-flow-page .send-btn,
.auth-flow-page .register-btn {
    min-height: 48px;
    border: 1px solid var(--auth-accent);
    border-radius: 8px;
    background: var(--auth-accent);
    color: var(--auth-action-text);
    font: inherit;
    font-weight: 650;
    transition: transform .16s ease, box-shadow .16s ease, background-color .16s ease;
}

.auth-flow-page .send-btn:hover:not(:disabled),
.auth-flow-page .register-btn:hover:not(:disabled) {
    background: var(--auth-accent-hover);
    border-color: var(--auth-accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 5px 14px color-mix(in srgb, var(--auth-accent) 24%, transparent);
}

.auth-flow-page .send-btn:focus-visible,
.auth-flow-page .register-btn:focus-visible,
.auth-flow-page .auth-back-link:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--auth-accent) 45%, transparent);
    outline-offset: 3px;
}

.auth-flow-page .register-btn {
    width: 100%;
    margin-top: 18px;
}

.auth-flow-page .register-btn:disabled {
    cursor: not-allowed;
    opacity: .55;
}

.auth-flow-page .field-error {
    min-height: 0;
    margin: -7px 0 12px;
    color: #b42318;
    font-size: .84rem;
}

.auth-flow-page #message {
    margin-top: 14px;
    color: var(--auth-muted);
    font-size: .88rem;
    text-align: left;
}

.auth-flow-page .auth-back-link {
    display: inline-block;
    margin-top: 18px;
    color: var(--auth-accent);
    font-size: .9rem;
    text-decoration: none;
}

.auth-flow-page .auth-back-link:hover {
    text-decoration: underline;
}

.auth-page :is(a, button, input, select, textarea):focus-visible,
.auth-flow-page :is(a, button, input, select, textarea):focus-visible {
    outline: 3px solid color-mix(in srgb, var(--auth-accent) 48%, transparent);
    outline-offset: 3px;
}

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

@media (max-width: 900px) {
    .auth-page {
        grid-template-columns: 1fr;
    }

    .auth-page .auth-showcase {
        min-height: 250px;
        padding: 32px 28px;
    }

    .auth-page .brand {
        margin-bottom: 28px;
    }

    .auth-page .showcase-content h1 {
        font-size: 2.5rem;
    }

    .auth-page .math-card {
        display: none;
    }

    .auth-page .auth-form-side {
        padding: 38px 24px;
    }
}

@media (max-width: 576px) {
    .auth-page .auth-showcase {
        min-height: 220px;
        padding: 24px 22px;
    }

    .auth-page .auth-form-side {
        padding: 30px 20px;
    }

    .auth-flow-page {
        min-height: auto;
        padding: 24px 14px;
    }

    .auth-flow-page .auth-flow-heading,
    .auth-flow-page .auth-flow-body {
        padding-right: 20px;
        padding-left: 20px;
    }

    .auth-flow-page .auth-flow-heading {
        padding-top: 24px;
    }

    .auth-flow-page .otp-section {
        grid-template-columns: 1fr;
    }

    .auth-flow-page .send-btn {
        width: 100%;
    }
}

.auth-page .auth-showcase {
    position: relative;
    isolation: isolate;
    min-height: 100vh;
    overflow: hidden;
    align-items: flex-start;
    padding: 48px;
    background: #0d0905;
}

.auth-page .showcase-content {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: none;
    height: 100%;
    min-height: calc(100vh - 96px);
    margin: 0;
}

.auth-page .brand {
    position: relative;
    z-index: 3;
    gap: 14px;
    margin: 0;
    color: #fff;
    font-size: 1.5rem;
    font-weight: 650;
}

.auth-page .brand-mark {
    width: 56px;
    height: 56px;
    flex: 0 0 auto;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: url("../images/logo.svg") center / contain no-repeat;
    color: transparent;
    font-size: 0;
}

.auth-page .brand-mark svg {
    display: none;
}

.auth-page .brand img {
    display: block;
    width: 56px;
    height: 56px;
    object-fit: contain;
}

.auth-math-scene {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}

.auth-page .showcase-content > h1,
.auth-page .showcase-content > p,
.auth-page .showcase-content > .math-card {
    display: none;
}

.auth-equations {
    position: absolute;
    inset: 0;
}

.auth-equation {
    position: absolute;
    display: block;
    color: rgba(255, 151, 58, .52);
    white-space: nowrap;
    opacity: var(--equation-opacity, .6);
    filter: blur(var(--equation-blur, 0px));
    animation: auth-equation-drift 11s ease-in-out infinite alternate;
}

.auth-equation .katex {
    color: inherit;
    font-size: calc(1.5rem * var(--equation-scale, 1));
}

.auth-equation .katex-display {
    margin: 0;
}

@keyframes auth-equation-drift {
    from { transform: translate3d(0, 0, 0); }
    to { transform: translate3d(10px, -12px, 0); }
}

@media (max-width: 900px) {
    .auth-page .auth-showcase {
        min-height: 230px;
        padding: 26px 24px;
    }

    .auth-page .showcase-content {
        min-height: 178px;
    }

    .auth-page .brand {
        font-size: 1.2rem;
    }

    .auth-page .brand img {
        width: 44px;
        height: 44px;
    }

    .auth-equation .katex {
        font-size: 1.65rem;
    }

    .auth-equation .katex { font-size: calc(1rem * var(--equation-scale, 1)); }
}

@media (prefers-reduced-motion: reduce) {
    .auth-equation {
        animation: none;
    }
}

html:has(.auth-page),
body:has(.auth-page) {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.auth-page {
    height: 100dvh;
    min-height: 0;
    max-height: 100dvh;
    overflow: hidden;
    grid-template-rows: minmax(0, 1fr);
}

.auth-page .auth-showcase {
    height: 100dvh;
}

.auth-page .auth-form-side {
    height: 100dvh;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    align-items: safe center;
    -webkit-overflow-scrolling: touch;
    scrollbar-gutter: stable;
}

@media (max-width: 900px) {
    html:has(.auth-page),
    body:has(.auth-page) {
        height: auto;
        min-height: 100%;
        overflow-x: hidden;
        overflow-y: auto;
    }

    .auth-page {
        display: grid;
        height: auto;
        min-height: 100dvh;
        max-height: none;
        overflow: visible;
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: 230px auto;
    }

    .auth-page .auth-showcase {
        height: 230px;
        min-height: 0;
    }

    .auth-page .showcase-content {
        min-height: 178px;
    }

    .auth-page .auth-form-side {
        height: auto;
        min-height: 0;
        max-height: none;
        overflow: visible;
        align-items: start;
    }
}

@media (max-width: 576px) {
    .auth-page {
        grid-template-rows: 190px auto;
    }

    .auth-page .auth-form-side {
        scrollbar-gutter: auto;
    }

    .auth-page .auth-card {
        max-width: 320px;
        margin-inline: auto;
    }

    .auth-page .auth-showcase {
        height: 190px;
    }
}

@media (max-width: 900px) and (max-height: 620px) {
    .auth-page {
        grid-template-rows: 145px minmax(0, 1fr);
    }

    .auth-page .auth-showcase {
        height: 145px;
        padding-block: 16px;
    }

    .auth-page .brand img {
        width: 36px;
        height: 36px;
    }
}

@media (max-width: 576px) {
    .auth-page {
        grid-template-rows: 208px auto;
        align-content: start;
    }

    .auth-page .auth-showcase {
        height: 208px;
        padding: 18px 22px;
        background-color: #18211f;
        background-image:
            linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px),
            linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px),
            linear-gradient(135deg, #18211f, #202c27);
        background-size: 28px 28px, 28px 28px, auto;
    }

    .auth-page .showcase-content {
        display: flex;
        min-height: 0;
        height: 100%;
        align-items: center;
        justify-content: center;
    }

    .auth-page .brand {
        gap: 10px;
        margin: 0;
        font-size: 1.05rem;
    }

    .auth-page .brand-mark {
        width: 40px;
        height: 40px;
    }

    .auth-page .brand img,
    .auth-page .brand-logo {
        width: 36px;
        height: 36px;
    }

    .auth-page .auth-form-side {
        position: relative;
        z-index: 2;
        margin-top: -54px;
        padding: 0 18px 34px;
        background: transparent;
    }

    .auth-page .auth-card {
        width: 100%;
        max-width: 430px;
        margin: 0 auto;
        padding: 24px 20px;
        border: 1px solid var(--auth-border);
        border-radius: 12px;
        background: rgba(255,255,255,.86);
        box-shadow: 0 18px 44px rgba(var(--auth-shadow), .14);
        -webkit-backdrop-filter: blur(16px);
        backdrop-filter: blur(16px);
    }

    .auth-page .auth-card-brand {
        display: none;
    }

    .auth-page .auth-card h2 {
        margin-bottom: 8px;
        font-size: 1.55rem;
        line-height: 1.25;
    }

    .auth-page .auth-card > .subtitle {
        display: block;
        margin-bottom: 20px;
        font-size: .9rem;
        line-height: 1.55;
    }

    .auth-page .auth-card .field {
        margin-bottom: 14px;
    }

    .auth-page .auth-card .field input,
    .auth-page .auth-card .field select,
    .auth-page .auth-card .field textarea,
    .auth-page .auth-card .reset-field input,
    .auth-page .auth-card .reset-code-field input {
        min-height: 48px;
        border-radius: 8px;
        font-size: 16px;
    }

    .auth-page .auth-card .auth-submit,
    .auth-page .auth-card .google-btn,
    .auth-page .auth-card .reset-submit,
    .auth-page .auth-card .reset-send-btn {
        min-height: 48px;
        border-radius: 8px;
    }

    .auth-page .auth-card .auth-link {
        margin-top: 14px;
        font-size: .86rem;
    }

    .auth-page .auth-card .auth-divider {
        margin: 17px 0 12px;
    }

    .auth-page .auth-card .reset-otp-section {
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 8px;
    }

    .auth-page .auth-card .reset-send-btn {
        padding: 0 12px;
        font-size: .84rem;
    }

    .auth-page .auth-equation {
        animation: none;
    }

    .auth-page .auth-equation .katex {
        font-size: calc(.9rem * var(--equation-scale, 1));
    }
}

@media (max-width: 360px) {
    .auth-page .auth-form-side {
        padding-right: 12px;
        padding-left: 12px;
    }

    .auth-page .auth-card {
        padding: 20px 16px;
    }

    .auth-page .auth-card .reset-otp-section {
        grid-template-columns: minmax(0, 1fr);
    }

    .auth-page .auth-card .reset-send-btn {
        width: 100%;
    }
}

@media (max-width: 576px) and (max-height: 620px) {
    .auth-page {
        grid-template-rows: 180px auto;
    }

    .auth-page .auth-showcase {
        height: 180px;
    }

    .auth-page .auth-form-side {
        margin-top: -46px;
    }
}

.auth-page:has(.google-form) .auth-card {
    display: flex;
    flex-direction: column;
}

.auth-page:has(.google-form) .auth-card > .auth-card-brand { order: 0; }
.auth-page:has(.google-form) .auth-card > h2 { order: 1; }
.auth-page:has(.google-form) .auth-card > .subtitle { order: 2; }
.auth-page:has(.google-form) .auth-card > .google-form { order: 3; }
.auth-page:has(.google-form) .auth-card > .auth-divider { order: 4; }
.auth-page:has(.google-form) .auth-card > form:not(.google-form) { order: 5; }
.auth-page:has(.google-form) .auth-card > .auth-link { order: 6; }