/* Authentication pages: log in, sign up, password reset and status screens. */

/* Authentication pages share the same theme surfaces as the application. */

.auth-page {
    --auth-rule: 1px;

    --auth-bg: var(--bg);
    --auth-surface: var(--surface);
    --auth-elevated: var(--surface-2);
    --auth-control-surface: var(--surface-2);
    --auth-text: var(--text);
    --auth-text-soft: var(--text-soft);
    --auth-text-faint: var(--text-faint);
    --auth-border: var(--border);
    --auth-border-strong: var(--border-strong, var(--border));
    --auth-input-bg: var(--surface-2);
    --auth-input-border: var(--border);
    --auth-link: rgb(var(--accent));
    --auth-danger: var(--danger);
    --auth-success: var(--success);
    --auth-info: var(--info);
    --auth-scroll-thumb: var(--text-faint);
    --auth-scroll-track: var(--surface-2);
}

body.auth-page {
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    background: var(--auth-bg);
    color: var(--auth-text);
}

.auth-page .grid-bg::before,
.auth-page .grid-bg::after {
    animation: none;
}

.auth-page .grid-bg::after {
    opacity: 0.2;
}

.auth-page .grid-bg::before {
    opacity: 0.4;
}

/* Layout */

.auth-main {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-5);
    min-height: 100vh;
    min-height: 100dvh;
    padding: 4rem var(--space-4) var(--space-5);
}

.auth-card {
    width: 100%;
    max-width: 26rem;
    padding: var(--space-6);
    background: var(--auth-surface);
    border: var(--auth-rule) solid var(--auth-border);
    border-radius: var(--radius-lg);
    box-shadow: none;
}

.auth-card-wide {
    max-width: 38rem;
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-5);
    padding-bottom: var(--space-4);
    border-bottom: var(--auth-rule) solid var(--auth-border);
    color: var(--auth-text);
    font-weight: 600;
    text-decoration: none;
}

.auth-brand .app-brand-logo {
    width: 7.25rem;
    max-height: 2rem;
}

.auth-profile-mobile-brand {
    display: none;
}

.auth-title {
    margin: 0 0 var(--space-2);
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.02em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--auth-text);
}

.auth-sub {
    margin: 0 0 var(--space-5);
    font-size: 0.92rem;
    line-height: 1.5;
    color: var(--auth-text-soft);
}

.auth-note {
    max-width: 26rem;
    margin: 0;
    text-align: center;
    font-size: 0.72rem;
    letter-spacing: 0.01em;
    line-height: 1.6;
    color: var(--auth-text-faint);
}

.auth-card-wide + .auth-note {
    max-width: 38rem;
}

/* Theme toggle (same place on every auth page) */

.theme-toggle {
    position: fixed;
    top: max(1rem, env(safe-area-inset-top));
    right: max(1rem, env(safe-area-inset-right));
    z-index: 10;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    padding: 0;
    background: var(--auth-surface);
    border: var(--auth-rule) solid var(--auth-border);
    border-radius: 50%;
    color: var(--auth-text);
    font-size: 1.1rem;
    transition: border-color var(--transition-fast), transform var(--transition-fast);
}

.theme-toggle:hover {
    border-color: var(--auth-link);
}

.theme-toggle:active {
    transform: scale(0.94);
}

.theme-toggle:focus-visible {
    outline: 2px solid var(--auth-link);
    outline-offset: 2px;
}

.theme-toggle .lucide-icon {
    line-height: 1;
}

.auth-page .theme-icon-sun,
.auth-page .theme-icon-moon,
.auth-page .theme-icon-amoled {
    display: none;
}

[data-theme="dark"] .auth-page .theme-icon-moon {
    display: inline-block;
}

[data-theme="light"] .auth-page .theme-icon-sun,
[data-theme="amoled"] .auth-page .theme-icon-amoled {
    display: inline-block;
}

/* Form fields */

.auth-field {
    margin-bottom: var(--space-4);
}

.auth-field label {
    display: block;
    margin-bottom: var(--space-2);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--auth-text-soft);
}

.auth-page .form-control,
.auth-page .form-select {
    width: 100%;
    height: 3rem;
    padding: 0 var(--space-4);
    background-color: var(--auth-input-bg);
    background-image: none;
    border: var(--auth-rule) solid var(--auth-input-border);
    border-radius: var(--input-radius);
    color: var(--auth-text);
    font-size: var(--input-font-size);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.auth-page .form-control::placeholder {
    color: var(--auth-text-faint);
    opacity: 1;
}

.auth-page .form-control:focus,
.auth-page .form-select:focus {
    background-color: var(--auth-input-bg);
    border-color: var(--auth-link);
    box-shadow: 0 0 0 3px rgba(var(--accent), 0.22);
    color: var(--auth-text);
}

.auth-page .form-control[aria-invalid="true"],
.auth-page .form-select[aria-invalid="true"] {
    border-color: var(--auth-danger);
}

.auth-page .form-control[aria-invalid="true"]:focus,
.auth-page .form-select[aria-invalid="true"]:focus {
    box-shadow: 0 0 0 3px rgba(251, 113, 133, 0.2);
}

.auth-page .form-select {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 2.75rem;
    background-image:
        linear-gradient(45deg, transparent 50%, var(--auth-text-soft) 50%),
        linear-gradient(135deg, var(--auth-text-soft) 50%, transparent 50%);
    background-position:
        calc(100% - 1.3rem) 50%,
        calc(100% - 0.95rem) 50%;
    background-size: 0.35rem 0.35rem;
    background-repeat: no-repeat;
}

.auth-profile-content .cs-trigger {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
    min-width: 0;
    gap: .65rem;
    padding-right: .9rem;
    background-image: none;
}

.auth-profile-content .cs-trigger-label {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.auth-profile-content .cs-trigger-lucide-chevron::after {
    display: none;
    content: none;
}

.auth-profile-content .cs-trigger-chevron {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    margin-left: auto;
    color: var(--auth-text-soft);
}

.auth-profile-content .cs-trigger-chevron .lucide-icon {
    display: block;
    width: 1rem;
    height: 1rem;
}

.auth-profile-content .cs-option.active::after {
    display: none;
    content: none;
}

.auth-page .form-select option,
.auth-page .form-select optgroup {
    background: var(--auth-surface);
    color: var(--auth-text);
}

.auth-page .form-select:invalid,
.auth-page .form-select option[value=""] {
    color: var(--auth-text-faint);
}

.auth-error {
    display: flex;
    align-items: flex-start;
    gap: 0.4rem;
    margin: var(--space-2) 0 0;
    font-size: 0.8rem;
    line-height: 1.4;
    color: var(--auth-danger);
}

.auth-error[hidden] {
    display: none;
}

.auth-error::before {
    content: "!";
    flex: 0 0 auto;
    display: inline-grid;
    place-items: center;
    width: 1.1em;
    height: 1.1em;
    margin-top: .08em;
    border: 1px solid currentColor;
    border-radius: 50%;
    font-weight: 700;
    font-size: .72em;
}

.auth-link {
    color: var(--auth-link);
    font-weight: 600;
    text-decoration: none;
}

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

.auth-link .lucide-icon {
    margin-right: var(--space-2);
}

.auth-link-btn {
    background: none;
    border: 0;
    padding: 0;
    margin: 0;
    font: inherit;
    font-weight: 600;
    color: var(--auth-link);
    text-decoration: underline;
    cursor: pointer;
}

.auth-link-btn:hover,
.auth-link-btn:focus-visible {
    opacity: .85;
}

.auth-page :focus-visible {
    outline: 2px solid var(--auth-link);
    outline-offset: 2px;
}

/* Buttons */

.auth-submit {
    width: 100%;
    min-height: 3rem;
    border-radius: var(--btn-radius);
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.auth-page .btn-accent:hover:not(:disabled) {
    filter: brightness(1.06);
}

.auth-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.auth-submit.is-loading {
    position: relative;
    color: transparent;
}

.auth-submit.is-loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 1.1rem;
    height: 1.1rem;
    margin: -0.55rem 0 0 -0.55rem;
    border: 2px solid var(--on-accent);
    border-top-color: transparent;
    border-radius: 50%;
    animation: auth-spin 0.7s linear infinite;
}

@keyframes auth-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Slow the button/page spinners rather than removing the loading feedback,
   matching the convention in components/skeleton.css. */
@media (prefers-reduced-motion: reduce) {
    .auth-submit.is-loading::after,
    .auth-page .btn-google.is-loading::after,
    .auth-spin {
        animation-duration: 2s;
    }
}
html[data-motion="reduced"] .auth-submit.is-loading::after,
html[data-motion="reduced"] .auth-page .btn-google.is-loading::after,
html[data-motion="reduced"] .auth-spin {
    animation-duration: 2s;
}

.auth-page .btn-ghost {
    min-height: 3rem;
    border-radius: var(--btn-radius);
    background: transparent;
    border: var(--auth-rule) solid var(--auth-input-border);
    color: var(--auth-text);
    font-weight: 600;
}

.auth-page .btn-ghost:hover {
    background: var(--auth-elevated);
    border-color: var(--auth-border-strong);
}

/* Google sign-in */

.auth-divider {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin: var(--space-5) 0;
    color: var(--auth-text-faint);
    font-family: var(--font-mono);
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.auth-divider::before,
.auth-divider::after {
    content: "";
    flex: 1 1 auto;
    height: 1px;
    background: var(--auth-border);
}

.auth-page .btn-google {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-3);
    min-height: 3rem;
    border-radius: var(--btn-radius);
    background: var(--auth-control-surface);
    border: var(--auth-rule) solid var(--auth-input-border);
    color: var(--auth-text);
    font-weight: 600;
}

.auth-page .btn-google:hover:not(:disabled) {
    background: var(--auth-elevated);
    border-color: var(--auth-border-strong);
}

.auth-page .btn-google .google-g {
    flex: 0 0 auto;
    width: 1.15rem;
    height: 1.15rem;
}

.auth-page .btn-google.is-loading .google-g {
    opacity: 0;
}

.auth-page .btn-google.is-loading {
    position: relative;
    color: transparent;
}

.auth-page .btn-google.is-loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 1.1rem;
    height: 1.1rem;
    margin: -0.55rem 0 0 -0.55rem;
    border: 2px solid var(--auth-text-faint);
    border-top-color: transparent;
    border-radius: 50%;
    animation: auth-spin 0.7s linear infinite;
}

.auth-spin {
    display: inline-block;
    animation: auth-spin 1s linear infinite;
}

/* Student email hint */

.auth-hint {
    margin: var(--space-4) 0 0;
    font-size: 0.8rem;
    line-height: 1.6;
    color: var(--auth-text-faint);
}

.auth-hint-label {
    display: block;
    margin-bottom: var(--space-1);
    font-family: var(--font-mono);
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--auth-text-soft);
}

.auth-inline-code {
    padding: 0.05rem 0.35rem;
    background: var(--auth-elevated);
    border-radius: var(--radius-sm);
    color: var(--auth-text-soft);
    font-family: var(--font-mono);
    font-size: 0.78em;
    word-break: break-all;
}

/* Alerts and footer text */

.auth-alert {
    display: flex;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
    padding: var(--space-3) var(--space-4);
    border: var(--auth-rule) solid;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    line-height: 1.5;
}

.auth-alert.error {
    border-color: var(--auth-danger);
    background: rgba(251, 113, 133, 0.1);
    color: var(--auth-danger);
}

.auth-alert.info {
    border-color: var(--auth-info);
    background: rgba(56, 189, 248, 0.1);
    color: var(--auth-text);
}

.auth-alert[hidden] {
    display: none;
}

.auth-alert .lucide-icon {
    flex: 0 0 auto;
    margin-top: 0.15rem;
    color: var(--auth-info);
}

.auth-foot {
    margin: var(--space-5) 0 0;
    padding-top: var(--space-4);
    border-top: var(--auth-rule) solid var(--auth-border);
    text-align: center;
    font-size: 0.9rem;
    color: var(--auth-text-soft);
}

/* Legal content intro (finish-profile.html) */

.step-sub {
    margin: 0 0 var(--space-5);
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--auth-text-soft);
}

/* Legal text boxes */

.legal-block {
    margin-bottom: var(--space-5);
}

.legal-title {
    margin: 0 0 var(--space-3);
    padding-bottom: var(--space-2);
    border-bottom: var(--auth-rule) solid var(--auth-border);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--auth-text);
}

.legal-box {
    height: 14rem;
    padding: var(--space-4);
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--auth-input-bg);
    border: var(--auth-rule) solid var(--auth-input-border);
    border-radius: var(--radius-sm);
    scrollbar-width: auto;
    scrollbar-color: var(--auth-scroll-thumb) var(--auth-scroll-track);
}

.legal-box:focus-visible {
    outline: 2px solid var(--auth-link);
    outline-offset: -1px;
}

.legal-box::-webkit-scrollbar {
    width: 0.75rem;
}

.legal-box::-webkit-scrollbar-track {
    background: var(--auth-scroll-track);
}

.legal-box::-webkit-scrollbar-thumb {
    background: var(--auth-scroll-thumb);
    border: 2px solid var(--auth-scroll-track);
    border-radius: var(--radius-pill);
}

.legal-text h4 {
    margin: var(--space-4) 0 var(--space-1);
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--auth-text);
}

.legal-text h4:first-child {
    margin-top: 0;
}

.legal-text .lg-h3,
.legal-text .lg-h4 {
    margin: var(--space-4) 0 var(--space-1);
    font-size: .86rem;
    font-weight: 700;
    line-height: 1.45;
    color: var(--auth-text);
}

.legal-text .lg-h3 .lg-num,
.legal-text .lg-h4 .lg-num {
    margin-right: .35rem;
    color: var(--auth-text-faint);
    font-variant-numeric: tabular-nums;
}

.legal-text .lg-nested {
    padding-left: .75rem;
    border-left: 1px solid var(--auth-border);
}

.legal-text .lg-list {
    margin: .5rem 0 .8rem;
    padding-left: 1.25rem;
    color: var(--auth-text-soft);
    font-size: .86rem;
    line-height: 1.55;
}

.legal-text .lg-sub > p,
.legal-text .lg-nested > p {
    margin: 0 0 .75rem;
    color: var(--auth-text-soft);
    font-size: .86rem;
    line-height: 1.6;
}

.legal-text a {
    color: var(--auth-link);
    overflow-wrap: anywhere;
}

.legal-text p {
    margin: 0;
    font-size: 0.88rem;
    line-height: 1.65;
    color: var(--auth-text-soft);
}

/* Consent checkboxes */

.auth-check {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    margin: 0;
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.5;
    cursor: pointer;
}

.auth-check input {
    flex: 0 0 auto;
    width: var(--checkbox-size);
    height: var(--checkbox-size);
    margin-top: 0.2rem;
    top: 0;
    accent-color: rgb(var(--accent));
    cursor: pointer;
}

.auth-check input[type="checkbox"] {
    width: 1.1rem;
    height: 1.1rem;
    margin: .15rem 0 0;
}

.auth-consent-field > .auth-error {
    align-items: center;
}

.auth-consent-field > .auth-error::before {
    display: none;
}

.auth-consent-field > .auth-error > .lucide-icon {
    flex: 0 0 auto;
    align-self: center;
    width: 1rem;
    height: 1rem;
    margin: 0;
}

.auth-consent-field > .auth-error > span {
    min-width: 0;
}

/* Status screens */

.auth-center {
    text-align: center;
}

.status-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3.5rem;
    height: 3.5rem;
    margin-bottom: var(--space-4);
    background: rgba(var(--accent), 0.14);
    border: 2px solid rgb(var(--accent));
    border-radius: var(--radius-sm);
    color: var(--auth-link);
    font-size: 1.5rem;
}

.auth-center[hidden] {
    display: none;
}

.auth-detail {
    margin: 0 0 var(--space-4);
    font-size: 0.88rem;
    line-height: 1.6;
    color: var(--auth-text-soft);
}

.auth-actions {
    display: grid;
    gap: var(--space-3);
    margin-top: var(--space-5);
}

.auth-actions .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--btn-radius);
}

@media (max-width: 575.98px) {
    .auth-profile-mobile-brand {
        display: flex;
        position: fixed;
        top: calc(env(safe-area-inset-top, 0px) + 1.05rem);
        left: max(1.25rem, env(safe-area-inset-left, 0px));
        z-index: 12;
        width: max-content;
        max-width: calc(100vw - 6rem);
        margin: 0;
        padding: 0;
        border: 0;
    }

    .auth-profile-card > .auth-brand {
        display: none;
    }

    .auth-profile-page::before {
        position: fixed;
        inset: 0 0 auto;
        z-index: 9;
        height: calc(env(safe-area-inset-top, 0px) + 3.75rem);
        border-bottom: 1px solid var(--auth-border);
        background: color-mix(in srgb, var(--bg) 88%, var(--surface) 12%);
        content: "";
    }

    .auth-main {
        justify-content: center;
        padding: max(4.5rem, env(safe-area-inset-top) + 3.5rem) var(--space-4) var(--space-5);
    }

    .auth-card {
        padding: var(--space-6) var(--space-5);
    }

    .auth-title {
        font-size: 1.4rem;
    }

    .auth-brand {
        margin-bottom: var(--space-5);
        padding-bottom: var(--space-4);
    }
}

@media (max-width: 399.98px) {
    .auth-title {
        font-size: 1.3rem;
    }
}

@media (min-width: 992px) {
    .auth-main {
        padding-top: var(--space-5);
    }

    .auth-card {
        padding: var(--space-7);
    }
}

/* Refreshed authentication layouts. Keep the existing auth hooks and fields intact. */
body.auth-page {
    background:
        radial-gradient(ellipse at 14% 20%, rgba(var(--accent), .16), transparent 30rem),
        var(--auth-bg);
}

[data-theme="amoled"] body.auth-page {
    background: var(--auth-bg);
}

[data-theme="amoled"] body.auth-page .grid-bg {
    --grid-fade: #000;
    --grid-line: rgba(255, 255, 255, .025);
    --grid-line-major: rgba(var(--accent), .06);
}

.auth-card {
    background: color-mix(in srgb, var(--auth-surface) 94%, rgb(var(--accent)) 6%);
    border-color: var(--auth-border);
    border-radius: var(--radius-md);
    box-shadow: 0 24px 70px rgba(0, 0, 0, .2), 0 1px 0 rgba(255, 255, 255, .035) inset;
}

.auth-brand {
    gap: 12px;
    font-size: .95rem;
    letter-spacing: -.01em;
}

.auth-login-main {
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(340px, .85fr);
    grid-template-rows: auto auto;
    align-content: center;
    align-items: center;
    column-gap: clamp(3rem, 8vw, 8rem);
    row-gap: 16px;
    width: min(100%, 78rem);
    margin-inline: auto;
    padding-inline: clamp(1.5rem, 6vw, 6rem);
}

.auth-login-intro {
    grid-column: 1;
    grid-row: 1 / span 2;
    max-width: 35rem;
    padding-block: 1rem;
}

.auth-intro-kicker {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 22px;
    color: var(--auth-text-soft);
    font-family: var(--font-mono);
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .12em;
}

.auth-intro-kicker span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgb(var(--accent));
    box-shadow: 0 0 0 5px rgba(var(--accent), .14);
}

.auth-login-intro h1 {
    margin: 0;
    color: var(--auth-text);
    font-size: clamp(2.6rem, 5vw, 4.4rem);
    font-weight: 800;
    letter-spacing: -.065em;
    line-height: 1.04;
}

.auth-login-intro h1 span {
    color: rgb(var(--accent));
}

.auth-login-intro > p {
    max-width: 29rem;
    margin: 22px 0 30px;
    color: var(--auth-text-soft);
    font-size: 1.03rem;
    line-height: 1.7;
}

.auth-feature-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.auth-feature-list span {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    border: 1px solid var(--auth-border);
    border-radius: 999px;
    background: rgba(255, 255, 255, .025);
    color: var(--auth-text-soft);
    font-size: .78rem;
}

.auth-feature-list .lucide-icon {
    color: rgb(var(--accent));
    font-size: .9rem;
}

.auth-login-card {
    grid-column: 2;
    grid-row: 1;
    width: 100%;
    max-width: 27rem;
    padding: clamp(1.6rem, 3vw, 2.5rem);
}

.auth-login-card .auth-title {
    font-size: 1.8rem;
    letter-spacing: -.04em;
}

.auth-login-card .auth-sub {
    margin-bottom: 24px;
}

.auth-login-card .btn-google {
    min-height: 3.25rem;
    border-radius: var(--btn-radius);
    background: var(--auth-control-surface);
    font-size: .92rem;
}

.auth-consent-note {
    margin: 14px 0 0;
    color: var(--auth-text-faint);
    font-size: .75rem;
    line-height: 1.55;
    text-align: center;
}

.auth-consent-note a {
    color: var(--auth-link);
    font-weight: 600;
    text-decoration: underline;
    text-decoration-color: rgba(var(--accent), .45);
    text-underline-offset: 2px;
}

.auth-consent-note a:hover {
    text-decoration-color: currentColor;
}

.auth-login-card .auth-hint {
    padding: 14px 15px;
    border: 1px solid var(--auth-border);
    border-radius: var(--radius-sm);
    background: var(--auth-control-surface);
    color: var(--auth-text-soft);
}

.status-icon {
    width: 4rem;
    height: 4rem;
    border: 0;
    border-radius: 50%;
    background: rgba(var(--accent), .13);
    color: var(--auth-link);
}

.status-icon-loading {
    background: transparent;
}

.auth-spinner {
    display: block;
    width: 2.8rem;
    height: 2.8rem;
    border: 3px solid rgba(var(--accent), .2);
    border-top-color: rgb(var(--accent));
    border-right-color: rgb(var(--accent));
    border-radius: 50%;
    animation: auth-spin .85s linear infinite;
}

.auth-status-card {
    max-width: 29rem;
}

.auth-callback-main {
    min-height: 100vh;
    min-height: 100dvh;
    justify-content: center;
    padding: calc(env(safe-area-inset-top, 0px) + 5rem) 1.5rem calc(env(safe-area-inset-bottom, 0px) + 3.5rem);
}

.auth-callback-brand {
    position: fixed;
    top: calc(env(safe-area-inset-top, 0px) + 1.25rem);
    left: max(1.5rem, env(safe-area-inset-left, 0px));
    z-index: 10;
    margin: 0;
    padding: 0;
    border: 0;
}

.auth-callback-content {
    width: min(100%, 28rem);
    margin: auto;
}

.auth-callback-content .status-icon-loading {
    position: relative;
    width: 4.25rem;
    height: 4.25rem;
    margin-bottom: 1.5rem;
    background: rgba(var(--accent), .08);
    border: 1px solid rgba(var(--accent), .22);
    box-shadow: 0 0 0 .4rem rgba(var(--accent), .035);
}

.auth-callback-content .status-icon-loading::before {
    position: absolute;
    inset: -.42rem;
    border: 1px solid transparent;
    border-right-color: rgba(var(--accent), .5);
    border-top-color: rgba(var(--accent), .2);
    border-radius: 50%;
    content: "";
    animation: auth-spin 2.8s linear infinite reverse;
}

.auth-callback-content .status-icon-loading::after {
    position: absolute;
    width: .34rem;
    height: .34rem;
    border-radius: 50%;
    background: rgb(var(--accent));
    content: "";
}

.auth-callback-content .auth-spinner {
    width: 2.4rem;
    height: 2.4rem;
    border-width: 2px;
    border-color: rgba(var(--accent), .18);
    border-top-color: rgb(var(--accent));
    border-right-color: rgb(var(--accent));
}

.auth-callback-main > .auth-note {
    position: absolute;
    right: 1.25rem;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 1rem);
    left: 1.25rem;
    max-width: 28rem;
    margin-inline: auto;
}

.auth-callback-error .auth-callback-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.auth-callback-error .auth-callback-error-icon {
    display: inline-flex;
    margin-bottom: 1.25rem;
}

.auth-callback-error .auth-callback-error-icon .lucide-icon {
    width: 1.65rem;
    height: 1.65rem;
}

.auth-callback-error .auth-callback-content .auth-title,
.auth-callback-error .auth-callback-content .auth-alert {
    width: 100%;
    text-align: center;
}

.auth-callback-error .auth-callback-content [data-callback-actions] {
    position: fixed;
    z-index: 12;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 3.65rem);
    left: 50%;
    width: min(28rem, calc(100vw - 2.5rem));
    margin: 0;
    transform: translateX(-50%);
}

.auth-callback-error .auth-callback-content [data-callback-actions] .btn {
    width: 100%;
    min-height: 3.15rem;
}

.auth-callback-error .auth-callback-main > .auth-note {
    position: fixed;
    z-index: 11;
    right: auto;
    bottom: calc(env(safe-area-inset-bottom, 0px) + .65rem);
    left: 50%;
    width: min(28rem, calc(100vw - 2.5rem));
    margin: 0;
    transform: translateX(-50%);
    text-align: center;
}

/* The callback page gets the same theme control on mobile. */
.auth-mobile-theme-toggle {
    display: none;
}

.auth-title-mobile,
.auth-sub-mobile {
    display: none;
}

.auth-mobile-only {
    display: none;
}

.auth-desktop-only {
    display: inline;
}

.auth-consent-mobile {
    display: none;
}

.auth-mobile-symbol,
.auth-approval-note {
    display: none;
}

@media (max-width: 575.98px) {
    .auth-callback-error .auth-callback-main {
        padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 7.25rem);
    }

    body.auth-page {
        min-height: 100vh;
        min-height: 100svh;
        min-height: 100dvh;
    }

    .auth-main {
        min-height: 100vh;
        min-height: 100svh;
        min-height: 100dvh;
        padding: calc(env(safe-area-inset-top, 0px) + 5.25rem) max(1.25rem, env(safe-area-inset-left, 0px)) calc(env(safe-area-inset-bottom, 0px) + 1.25rem);
        gap: 1rem;
    }

    .auth-brand {
        position: fixed;
        top: calc(env(safe-area-inset-top, 0px) + 1.05rem);
        left: max(1.25rem, env(safe-area-inset-left, 0px));
        z-index: 11;
        width: max-content;
        max-width: calc(100vw - 6rem);
        margin: 0;
        padding: 0;
        border: 0;
    }

    .auth-brand .app-brand-logo {
        display: block;
        width: 6.75rem;
        max-width: 100%;
        max-height: 1.65rem;
        object-fit: contain;
        object-position: left center;
    }

    .auth-page .theme-toggle {
        top: calc(env(safe-area-inset-top, 0px) + .7rem);
        right: max(1.1rem, env(safe-area-inset-right, 0px));
        width: 2.5rem;
        height: 2.5rem;
    }

    .auth-mobile-theme-toggle {
        display: inline-flex;
    }

    .auth-login-main {
        display: flex;
        width: 100%;
        max-width: none;
        margin: 0;
        gap: 0;
        padding-inline: max(1.25rem, env(safe-area-inset-left, 0px));
        align-items: stretch;
        justify-content: flex-start;
    }

    .auth-login-intro {
        display: none;
    }

    .auth-login-main > .auth-login-card {
        display: contents;
    }

    .auth-login-card,
    .auth-card {
        width: 100%;
        max-width: 30rem;
        margin: auto;
        padding: 0;
        background: transparent;
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }

    .auth-login-card > .auth-mobile-symbol { order: 0; }
    .auth-login-card > .auth-title { order: 1; width: 100%; max-width: 30rem; }
    .auth-login-card > .auth-sub { order: 2; width: 100%; }
    .auth-login-card > .auth-alert { order: 3; width: 100%; }
    .auth-login-card > .auth-hint { order: 4; width: 100%; }
    .auth-login-card > [data-google-signin] { order: 5; }
    .auth-login-card > .auth-approval-note { order: 6; width: 100%; }
    .auth-login-card > .auth-consent-mobile { order: 7; width: 100%; }

    .auth-title-desktop,
    .auth-sub-desktop {
        display: none;
    }

    .auth-title-mobile,
    .auth-sub-mobile {
        display: inline;
    }

    .auth-mobile-only {
        display: inline;
    }

    .auth-consent-desktop {
        display: none;
    }

    .auth-consent-mobile {
        display: block;
    }

    .auth-desktop-only {
        display: none;
    }

    .auth-login-card .auth-title {
        margin: 0 0 .65rem;
        font-size: clamp(1.55rem, 6vw, 1.8rem);
        line-height: 1.2;
        text-align: center;
        white-space: normal;
        overflow: visible;
    }

    .auth-mobile-symbol {
        display: grid;
        width: 2.75rem;
        height: 2.75rem;
        margin: auto auto 1.1rem;
        place-items: center;
        border-radius: 50%;
        background: rgba(var(--accent), .12);
        color: rgb(var(--accent));
        font-size: 1.2rem;
    }

    .auth-login-card .auth-sub {
        max-width: 22rem;
        margin: 0 auto 1.35rem;
        font-size: .92rem;
        text-align: center;
    }

    .auth-login-card .btn-google {
        min-height: 3.35rem;
        width: 100%;
        margin-top: .7rem;
        border-radius: var(--radius-pill);
        font-size: .96rem;
        background: var(--auth-elevated);
        border-color: var(--auth-border-strong);
        color: var(--auth-text);
    }

    .auth-login-card .btn-google:hover:not(:disabled) {
        background: var(--auth-surface);
        border-color: var(--auth-border-strong);
    }

    .auth-login-card .auth-hint {
        margin: auto 0 0;
        padding: 0;
        border: 0;
        border-radius: 0;
        background: transparent;
        font-size: .78rem;
        line-height: 1.55;
        text-align: center;
    }

    .auth-hint-label {
        margin-bottom: .3rem;
        font-size: .68rem;
    }

    .auth-inline-code {
        display: inline-block;
        padding: .28rem .42rem;
        background: var(--auth-elevated);
        border-radius: var(--radius-sm);
        font-size: .8rem;
        line-height: 1.5;
        overflow-wrap: anywhere;
        word-break: normal;
    }

    .auth-approval-note {
        display: block;
        margin: .65rem auto 0;
        color: var(--auth-text-soft);
        font-size: .76rem;
        line-height: 1.5;
        text-align: center;
    }

    .auth-consent-note {
        max-width: 22rem;
        margin: .85rem auto 0;
        font-size: .75rem;
        line-height: 1.5;
        text-align: center;
    }

    .auth-alert {
        margin-top: 0;
    }

    .auth-profile-main {
        display: flex;
        align-items: stretch;
        justify-content: flex-start;
        padding-top: calc(env(safe-area-inset-top, 0px) + 5rem);
    }

    .auth-profile-page .theme-toggle {
        z-index: 11;
        border-color: var(--auth-border);
        background: var(--auth-elevated);
    }

    .auth-profile-page .auth-profile-card {
        max-width: 38rem;
        margin: 0 auto;
        padding: 0;
        border: 0;
        border-radius: 0;
        background: transparent;
        box-shadow: none;
    }

    .auth-profile-card .auth-title {
        font-size: 1.55rem;
        white-space: normal;
        overflow: visible;
    }

    .auth-profile-card .auth-sub {
        margin-bottom: 1.1rem;
        font-size: .88rem;
    }

    .auth-profile-content[hidden] {
        display: none;
    }

    .auth-profile-main:not(.is-profile-ready) .auth-profile-content {
        display: none;
    }

    .auth-profile-content .auth-field {
        margin-bottom: 1rem;
    }

    .auth-profile-content .auth-field > label:not(.auth-check) {
        margin-bottom: .4rem;
        font-family: var(--font-sans);
        font-size: .84rem;
        font-weight: 600;
        letter-spacing: 0;
        text-transform: none;
        color: var(--auth-text);
    }

    .auth-profile-content .form-control,
    .auth-profile-content .form-select {
        height: 3.15rem;
    }

    .auth-profile-content .legal-box {
        height: 14rem;
        padding: .8rem;
    }

    .auth-profile-content .legal-block {
        margin-bottom: 1.1rem;
    }

    .auth-profile-content .legal-text p {
        font-size: .82rem;
        line-height: 1.55;
    }

    .auth-profile-content .legal-text .lg-h3,
    .auth-profile-content .legal-text .lg-h4,
    .auth-profile-content .legal-text .lg-list,
    .auth-profile-content .legal-text .lg-sub > p,
    .auth-profile-content .legal-text .lg-nested > p {
        font-size: .82rem;
    }

    .auth-profile-content .auth-check {
        align-items: center;
        gap: .65rem;
        line-height: 1.5;
    }

    .auth-profile-content .auth-check input[type="checkbox"] {
        flex: 0 0 1.1rem;
        margin-top: 0;
    }

    .auth-profile-content .auth-submit {
        position: sticky;
        bottom: calc(env(safe-area-inset-bottom, 0px) + .5rem);
        z-index: 2;
        min-height: 3.25rem;
        box-shadow: 0 4px 16px rgba(0, 0, 0, .14);
    }

    .auth-main > .auth-card:not(.auth-login-card):not(.auth-profile-card) {
        margin-block: auto;
    }

    .auth-main > .auth-card:not(.auth-login-card):not(.auth-profile-card) .auth-center {
        max-width: 26rem;
        margin-inline: auto;
    }

    .auth-note {
        max-width: 28rem;
        margin: 0 auto;
        padding-bottom: .25rem;
    }
}

@media (max-width: 359.98px) {
    .auth-login-card .auth-title {
        font-size: 1.5rem;
    }

    .auth-login-card .auth-hint,
    .auth-consent-note {
        font-size: .72rem;
    }
}

@media (max-width: 575.98px) {
    .auth-status-main {
        align-items: stretch;
        justify-content: flex-start;
        padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 6.25rem);
    }

    .auth-status-main > .auth-status-card {
        display: flex;
        flex: 1 0 auto;
        flex-direction: column;
        justify-content: center;
        width: 100%;
        max-width: 30rem;
        margin: 0 auto;
        padding: 0;
        border: 0;
        border-radius: 0;
        background: transparent;
        box-shadow: none;
    }

    .auth-status-card > .auth-center:not([hidden]) {
        margin-block: auto;
    }

    .auth-status-card .auth-actions a[href="login.html"] {
        position: fixed;
        z-index: 13;
        left: 50%;
        bottom: calc(env(safe-area-inset-bottom, 0px) + 2.8rem);
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: min(30rem, calc(100vw - 2.5rem));
        min-height: 3.15rem;
        margin: 0;
        transform: translateX(-50%);
    }

    .auth-status-main > .auth-note {
        position: fixed;
        z-index: 12;
        right: max(1.25rem, env(safe-area-inset-right, 0px));
        bottom: calc(env(safe-area-inset-bottom, 0px) + .55rem);
        left: max(1.25rem, env(safe-area-inset-left, 0px));
        width: auto;
        max-width: 30rem;
        margin: 0 auto;
        padding: 0;
        text-align: center;
        font-size: .72rem;
        line-height: 1.35;
    }
}

@media (prefers-reduced-motion: reduce) {
    .auth-spinner,
    .auth-page .status-icon .auth-spin,
    .auth-callback-content .status-icon-loading::before {
        animation: none;
    }
}

html[data-motion="reduced"] .auth-spinner,
html[data-motion="reduced"] .auth-page .status-icon .auth-spin,
html[data-motion="reduced"] .auth-callback-content .status-icon-loading::before {
    animation: none;
}

.auth-status-card .auth-center .auth-title {
    white-space: normal;
}

.auth-profile-main {
    justify-content: flex-start;
    padding-top: max(4.5rem, env(safe-area-inset-top) + 3rem);
}

.auth-profile-card {
    max-width: 44rem;
}

.auth-profile-card > .auth-title {
    font-size: 1.9rem;
}

.auth-profile-content > .auth-title {
    font-size: 1.9rem;
}

.auth-required {
    color: var(--auth-danger);
}

@media (min-width: 576px) and (max-width: 900px) {
    .auth-login-main {
        display: flex;
        width: 100%;
        gap: 0;
        padding-inline: var(--space-4);
    }

    .auth-login-intro {
        display: none;
    }

}

@media (prefers-reduced-motion: reduce) {
    .auth-spinner { animation-duration: 2s; }
}

@media (max-width: 575.98px) {
    .auth-profile-main {
        padding-top: calc(env(safe-area-inset-top, 0px) + 5rem);
    }

    .auth-profile-card {
        max-width: 38rem;
    }

    .auth-profile-main:not(.is-profile-ready) {
        justify-content: center;
    }

    .auth-profile-main:not(.is-profile-ready) .auth-profile-card {
        margin-block: auto;
    }

    .auth-profile-card .auth-profile-content > .auth-title {
        font-size: 1.55rem;
    }
}
