html:has(.th-auth-dialog[open]) {
    overflow: hidden;
}

.th-auth-dialog {
    position: fixed;
    inset: 0;
    width: min(480px, calc(100vw - 32px));
    max-width: none;
    max-height: min(calc(100dvh - 24px), 760px);
    margin: auto;
    overflow: auto;
    border: 0;
    border-radius: 16px;
    padding: 0;
    background: var(--th-card);
    color: var(--th-foreground);
    box-shadow: 0 14px 42px color-mix(in oklab, var(--th-foreground) 16%, transparent);
}

.th-auth-dialog::backdrop {
    background: color-mix(in oklab, var(--th-foreground) 36%, transparent);
    backdrop-filter: blur(2px);
}

.th-auth-dialog[data-auth-kind="login"]:not(.th-auth-switching) {
    overflow: hidden;
}

.th-auth-dialog-close {
    position: sticky;
    z-index: 2;
    top: 8px;
    display: grid;
    width: 40px;
    height: 40px;
    margin: 8px 8px -48px auto;
    place-items: center;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--th-muted-foreground);
    cursor: pointer;
}

.th-auth-dialog-close:hover {
    background: var(--th-muted);
    color: var(--th-foreground);
}

.th-auth-dialog-close:focus-visible,
.th-auth-dialog-content button:focus-visible,
.th-auth-dialog-content a:focus-visible {
    outline: 2px solid var(--th-primary);
    outline-offset: 2px;
}

.th-auth-dialog-close .admin-icon {
    width: 20px;
    height: 20px;
}

.th-auth-dialog-status {
    width: auto;
    margin: 58px 24px 0;
}

.th-auth-dialog-status[hidden] {
    display: none;
}

.th-auth-dialog-content .auth-page {
    box-sizing: border-box;
    display: block;
    width: 100%;
    min-width: 0;
    min-height: 0;
    margin: 0;
    padding: 20px !important;
}

.th-auth-dialog-content {
    min-width: 0;
    max-width: 100%;
}

.th-auth-dialog-content.th-auth-transitioning {
    position: relative;
    overflow: hidden;
    transition: height .18s cubic-bezier(.22, 1, .36, 1);
}

.th-auth-dialog-content.th-auth-transitioning > .auth-page {
    position: absolute;
    inset: 0 auto auto 0;
    width: 100%;
    opacity: 0;
    pointer-events: none;
    transform: translateY(6px);
    transition: opacity .16s ease, transform .16s ease;
}

.th-auth-dialog-content.th-auth-transitioning > .auth-page.th-auth-view-active {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.th-auth-dialog-content > .auth-page.th-auth-view-staging {
    position: absolute;
    inset: 0 auto auto 0;
    width: 100%;
    visibility: hidden;
    pointer-events: none;
}

.th-auth-dialog-content.th-auth-transitioning > .auth-page.th-auth-view-leaving {
    pointer-events: none;
}

.th-auth-dialog-content .auth-card {
    box-sizing: border-box !important;
    width: 100% !important;
    max-width: none !important;
    border: 0 !important;
    border-radius: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
}

.auth-compact-page .auth-login-header {
    display: grid;
    justify-items: center;
    text-align: center;
}

.th-auth-dialog-content .auth-compact-page .auth-login-mark,
.th-auth-dialog-content .auth-compact-page .auth-login-header .eyebrow {
    display: none;
}

.auth-compact-page .auth-login-mark {
    display: grid;
    width: 42px;
    height: 42px;
    margin: 0 0 10px;
    place-items: center;
    overflow: hidden;
    border-radius: 50%;
    background: var(--th-muted);
}

.auth-compact-page .auth-login-mark img {
    display: block;
    width: 36px;
    height: 36px;
    object-fit: contain;
}

.auth-compact-page .auth-login-header .eyebrow {
    margin: 0 0 3px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.4;
}

.auth-compact-page .auth-login-header h1 {
    margin: 0;
    padding: 0 30px;
    font-size: 27px;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -.035em;
}

.auth-compact-page .auth-login-header .auth-card-copy {
    max-width: 340px;
    margin: 6px 0 14px;
    color: var(--th-muted-foreground);
    font-size: 13px;
    line-height: 1.45;
}

.auth-reset-page .auth-login-header {
    margin-bottom: 16px;
}

.auth-reset-page .auth-login-header h1 {
    padding-inline: 8px;
}

.auth-compact-page .auth-card > .auth-alert,
.auth-compact-page .auth-card > .auth-success {
    width: 100%;
    margin: 0 0 12px;
    padding: 9px 11px;
    font-size: 13px;
    line-height: 1.4;
}

.auth-compact-page .auth-login-form {
    display: grid;
    gap: 8px;
}

.auth-compact-page .auth-compact-field {
    position: relative;
    min-width: 0;
    margin: 0;
}

.auth-compact-page .auth-form label.auth-input-shell {
    position: relative;
    display: block;
    width: 100%;
    min-height: 56px;
    margin: 0;
    overflow: hidden;
    border: 1px solid var(--th-input) !important;
    border-radius: 10px !important;
    background: var(--th-card) !important;
    color: var(--th-foreground) !important;
    cursor: text;
}

.auth-compact-page .auth-input-shell:focus-within {
    border-color: var(--th-primary) !important;
    box-shadow: 0 0 0 1px var(--th-primary);
}

.auth-compact-page .auth-input-shell > .admin-icon {
    top: 50%;
    left: 14px;
    width: 18px;
    height: 18px;
    color: var(--th-muted-foreground);
}

.auth-compact-page .auth-floating-label {
    position: absolute;
    z-index: 1;
    top: 6px;
    left: 44px;
    color: var(--th-muted-foreground);
    font-size: 11px;
    font-weight: 500;
    line-height: 1.2;
    pointer-events: none;
}

.auth-compact-page .auth-form .auth-input-shell input[type="email"],
.auth-compact-page .auth-form .auth-input-shell input[type="password"],
.auth-compact-page .auth-form .auth-input-shell input[type="text"] {
    box-sizing: border-box;
    width: 100%;
    min-height: 54px;
    margin: 0;
    border: 0 !important;
    border-radius: 0 !important;
    padding: 21px 44px 7px 44px;
    background: transparent !important;
    color: var(--th-foreground) !important;
    font: inherit;
    font-size: 14px;
    font-weight: 400;
    outline-offset: -3px;
}

.auth-compact-page .auth-form .auth-input-shell input:focus-visible {
    outline: 0 !important;
    outline-offset: 0 !important;
}

.auth-compact-page .auth-password-toggle {
    position: absolute;
    top: 50%;
    right: 7px;
    display: grid;
    width: 40px;
    height: 40px;
    place-items: center;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--th-muted-foreground);
    cursor: pointer;
    transform: translateY(-50%);
}

.auth-compact-page .auth-password-toggle:hover {
    background: var(--th-muted);
    color: var(--th-foreground);
}

.auth-compact-page .auth-password-toggle:focus-visible,
.auth-compact-page .auth-submit-button:focus-visible {
    outline: 2px solid var(--th-primary);
    outline-offset: 2px;
}

.auth-compact-page .auth-password-toggle .admin-icon {
    width: 19px;
    height: 19px;
}

.auth-compact-page .auth-password-toggle[aria-pressed="false"]::after {
    position: absolute;
    width: 21px;
    height: 1.5px;
    border-radius: 2px;
    background: currentColor;
    content: "";
    transform: rotate(-42deg);
}

.auth-compact-page .auth-options-row {
    display: flex;
    min-width: 0;
    min-height: 34px;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.auth-compact-page .auth-options-row .auth-checkbox {
    min-height: 38px;
    margin: 0;
    gap: 8px;
    color: var(--th-muted-foreground);
    font-size: 13px;
    font-weight: 400;
}

.auth-compact-page .auth-checkbox {
    min-height: 38px;
    margin: 0;
    gap: 8px;
    color: var(--th-muted-foreground);
    font-size: 13px;
    font-weight: 400;
}

.auth-compact-page .auth-checkbox-control {
    width: 18px;
    height: 18px;
    flex-basis: 18px;
    border-radius: 5px;
}

.auth-compact-page .auth-checkbox-control .admin-icon {
    width: 13px;
    height: 13px;
}

.auth-compact-page .auth-options-row .auth-links {
    margin: 0;
    font-size: 13px;
    text-align: right;
}

.auth-compact-page .auth-options-row .auth-links a,
.auth-compact-page .auth-consent a,
.auth-compact-page .auth-switch a {
    color: var(--th-primary);
    font-weight: 600;
    text-underline-offset: 3px;
}

.auth-compact-page .auth-options-row .auth-links a {
    text-decoration: none;
}

.auth-compact-page .auth-options-row .auth-links a:hover,
.auth-compact-page .auth-options-row .auth-links a:focus-visible {
    text-decoration: underline;
}

.auth-compact-page .auth-submit-button {
    display: inline-flex;
    width: 100%;
    min-height: 48px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 0;
    border-radius: 10px !important;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: filter .15s ease, transform .15s ease;
}

.auth-compact-page .auth-submit-button:hover:not(:disabled) {
    filter: brightness(.96);
}

.auth-compact-page .auth-submit-button:active:not(:disabled) {
    transform: translateY(1px);
}

.auth-compact-page .auth-submit-button:disabled {
    cursor: wait;
    opacity: .75;
}

.auth-compact-page .auth-submit-icon {
    width: 18px;
    height: 18px;
}

.auth-compact-page .auth-submit-spinner:not([hidden]) {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid color-mix(in oklab, var(--th-primary-foreground) 40%, transparent);
    border-top-color: var(--th-primary-foreground);
    border-radius: 50%;
    animation: th-auth-spin .7s linear infinite;
}

.auth-compact-page .auth-submit-button[aria-busy="true"] .auth-submit-icon {
    display: none;
}

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

.auth-compact-page .auth-consent {
    margin: 9px 0 0;
    color: var(--th-muted-foreground);
    font-size: 11px;
    line-height: 1.5;
    text-align: center;
}

.auth-compact-page .auth-consent a {
    text-decoration: none;
}

.auth-compact-page .auth-consent a:hover,
.auth-compact-page .auth-consent a:focus-visible,
.auth-compact-page .auth-switch a:hover,
.auth-compact-page .auth-switch a:focus-visible {
    text-decoration: underline;
}

.auth-compact-page .auth-divider {
    gap: 12px;
    margin: 10px 0;
    color: var(--th-muted-foreground);
    font-size: 12px;
}

.auth-compact-page .auth-google-button {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
    gap: 9px;
    border-radius: 10px !important;
    background: var(--th-card) !important;
    color: var(--th-foreground) !important;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
}

.auth-compact-page .auth-google-mark {
    flex: 0 0 20px;
}

.th-auth-dialog-content .auth-switch {
    margin: 12px -32px 0;
    border-top: 1px solid var(--th-border);
    padding: 12px 32px;
    background: color-mix(in oklab, var(--th-primary) 3%, var(--th-card));
    color: var(--th-muted-foreground);
    font-size: 13px;
    line-height: 1.4;
    text-align: center;
}

.th-auth-dialog-content .field-error {
    margin: -5px 0 0;
    color: var(--th-destructive);
    font-size: 12px;
    line-height: 1.4;
}

.th-auth-popup-result {
    display: grid;
    min-height: 100vh;
    place-items: center;
    margin: 0;
    padding: 24px;
    background: var(--th-background);
    color: var(--th-foreground);
    font-family: var(--th-font, system-ui, sans-serif);
    text-align: center;
}

.th-auth-popup-result main {
    width: min(100%, 420px);
    border: 1px solid var(--th-border);
    border-radius: var(--th-radius-panel);
    padding: 24px;
    background: var(--th-card);
}

.th-auth-popup-result h1 {
    margin: 0 0 8px;
    font-size: 20px;
}

.th-auth-popup-result p {
    margin: 0;
    color: var(--th-muted-foreground);
}

@media (max-width: 480px) {
    .th-auth-dialog {
        width: calc(100vw - 32px);
        max-height: min(calc(100dvh - 24px), 760px);
        border-radius: 16px;
    }

    .auth-compact-page .auth-login-header h1 {
        padding-inline: 24px;
        font-size: 25px;
    }

    .auth-reset-page .auth-login-header h1 {
        padding-inline: 8px;
    }

    .th-auth-dialog-content .auth-switch {
        margin-inline: -20px;
        padding-inline: 20px;
    }
}

@media (max-height: 640px) {
    .th-auth-dialog-content .auth-compact-page {
        padding-top: 12px !important;
    }

    .auth-compact-page .auth-login-mark {
        width: 36px;
        height: 36px;
        margin-bottom: 6px;
    }

    .auth-compact-page .auth-login-mark img {
        width: 30px;
        height: 30px;
    }

    .auth-compact-page .auth-login-header h1 {
        font-size: 24px;
    }

    .auth-compact-page .auth-login-header .auth-card-copy {
        margin-bottom: 10px;
    }

    .auth-compact-page .auth-form label.auth-input-shell {
        min-height: 52px;
    }

    .auth-compact-page .auth-form .auth-input-shell input[type="email"],
    .auth-compact-page .auth-form .auth-input-shell input[type="password"],
    .auth-compact-page .auth-form .auth-input-shell input[type="text"] {
        min-height: 50px;
    }

    .auth-compact-page .auth-options-row {
        min-height: 30px;
    }

    .auth-compact-page .auth-submit-button {
        min-height: 44px;
    }

    .auth-compact-page .auth-consent {
        margin-top: 7px;
    }

    .auth-compact-page .auth-divider {
        margin: 7px 0;
    }

    .auth-compact-page .auth-google-button {
        min-height: 40px;
    }

    .th-auth-dialog-content .auth-switch {
        margin-top: 8px;
        padding-block: 10px;
    }
}

@media (max-width: 360px) {
    .auth-compact-page .auth-options-row {
        align-items: flex-start;
    }

    .auth-compact-page .auth-options-row .auth-checkbox,
    .auth-compact-page .auth-options-row .auth-links {
        font-size: 12px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .auth-compact-page .auth-submit-spinner {
        animation: none;
    }

    .auth-compact-page .auth-submit-button,
    .th-auth-dialog-content.th-auth-transitioning,
    .th-auth-dialog-content.th-auth-transitioning > .auth-page {
        transition: none;
    }
}
