/* One centred surface for sign-in and first-account setup. */
#authModal.passwordless-auth-active {
    inset: 0;
    width: 100%;
    height: calc(100dvh / var(--ui-zoom, 1));
    padding: 24px 16px;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
}
#authModal .passwordless-modal {
    box-sizing: border-box;
    flex-shrink: 0;
    width: min(100%, 420px);
    max-width: 420px;
    max-height: none;
    margin: auto;
    padding: 28px;
    overflow: visible;
    border: 0;
    border-radius: 18px;
    background: transparent;
    box-shadow: none;
    font-family: var(--font-reading, sans-serif);
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto minmax(64px, auto) 44px minmax(62px, auto) minmax(88px, auto);
    isolation: isolate;
}
/* The panel ends after the account choices; provider attribution has its own
   row outside it. The generated grid item also grows with expanded sign-in. */
#authModal .passwordless-modal::before {
    content: '';
    position: static;
    grid-area: 1 / 1 / 5 / 3;
    inset: auto;
    height: auto;
    margin: -28px;
    border: 1px solid var(--border-color);
    border-radius: 18px;
    background: var(--bg-card, #11151c);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    z-index: -1;
}
.passwordless-modal .auth-welcome-copy {
    grid-area: 1 / 1 / 2 / 3;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 9px;
    margin-bottom: 26px;
}
.passwordless-modal .auth-welcome-mark {
    display: grid;
    width: 32px;
    height: 32px;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    border-radius: 8px;
}
.passwordless-modal .auth-welcome-mark img { width: 32px; height: 32px; border-radius: 8px; }
.passwordless-modal .auth-welcome-copy h3 {
    font-size: 22px;
    margin: 0;
    letter-spacing: -0.025em;
}
/* The page explains itself; no subtitle, and About lives in Settings. */
.passwordless-modal .auth-welcome-copy p { display: none !important; }
#authModal.passwordless-auth-active .auth-about-link { display: none !important; }
.passwordless-modal .auth-body { display: contents; }
#passwordlessSignIn { display: contents !important; }
#authModal[data-auth-loading] #passwordlessSignIn { visibility: hidden; }
#passwordlessAttributionSpace { grid-area: 5 / 1 / 6 / 3; min-height: 88px; pointer-events: none; }
.passwordless-auth-feedback, .passwordless-profile-form { grid-area: 2 / 1 / 4 / 3; }
.passwordless-auth-feedback { display: grid; align-content: center; gap: 10px; min-height: 108px; }
.passwordless-auth-feedback p { margin: 0; font-size: 13px; line-height: 1.5; color: var(--text-secondary); }
.passwordless-auth-feedback .auth-submit-btn { min-height: 44px; }
#passwordlessLoadingStatus[hidden] { display: none; }
.passwordless-options-toggle:disabled { cursor: wait; }
#passwordlessSignIn .cl-rootBox,
#passwordlessSignIn .cl-cardBox,
#passwordlessSignIn .cl-card { width: 100%; max-width: 100%; min-width: 0; }
#passwordlessSignIn .cl-footer { background: transparent; }
/* Let the provider card, disclosure and guest alternative share one layout.
   Provider attribution remains visible, after the visitor's choices. */
#passwordlessSignIn.cl-rootBox,
#passwordlessSignIn .cl-cardBox { display: contents !important; }
#passwordlessSignIn .cl-card {
    grid-area: 2 / 1 / 3 / 3;
    padding: 16px 16px 0;
    border-radius: 14px 14px 0 0;
    background: var(--bg-tertiary, #1a1f2b);
}
#passwordlessSignIn .cl-footer {
    grid-area: 5 / 1 / 6 / 3;
    margin-top: 44px;
    padding: 0;
    border-radius: 0;
}
#passwordlessSignIn .cl-footerItem { border: 0; background: transparent; padding: 0; }
#passwordlessSignIn .cl-socialButtonsBlockButton,
#passwordlessSignIn .cl-formButtonPrimary,
#passwordlessSignIn .cl-formFieldInput { border-radius: 12px; font-family: inherit; }
#passwordlessSignIn .cl-socialButtonsBlockButton__microsoft,
#passwordlessSignIn .cl-formFieldInput {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    box-shadow: none;
}
#passwordlessSignIn .cl-formFieldLabel,
#passwordlessSignIn .cl-footerActionText { color: var(--text-secondary); }
/* Google is the default. Other providers and email are a disclosure away;
   keep Clerk's real controls and verification flow intact. */
.passwordless-options-collapsed #passwordlessSignIn .cl-socialButtonsBlockButton__microsoft,
.passwordless-options-collapsed #passwordlessSignIn .cl-dividerRow,
.passwordless-options-collapsed #passwordlessSignIn .cl-form,
#passwordlessSignIn .cl-footerAction {
    display: none;
}
#passwordlessSignIn .cl-socialButtonsBlockButton__google {
    background: #a5b4fc;
    color: #111827;
    font-weight: 600;
}
#passwordlessSignIn .cl-socialButtonsBlockButton__google:hover { background: #c7d2fe; }
#passwordlessSignIn .cl-formButtonPrimary {
    background: #a5b4fc;
    color: #111827;
    box-shadow: none;
}
#passwordlessSignIn .cl-formButtonPrimary:hover { background: #c7d2fe; }
.passwordless-options-toggle {
    grid-area: 3 / 1 / 4 / 3;
    align-self: center;
    border: 0;
    background: var(--bg-tertiary, #1a1f2b);
    padding: 11px 16px;
    min-height: 44px;
    color: var(--text-secondary, #cbd5e1);
    font: inherit;
    font-size: 12px;
    cursor: pointer;
    width: 100%;
    border-radius: 0 0 14px 14px;
}
.passwordless-options-toggle:hover { color: var(--text-primary, #f8fafc); background: var(--bg-tertiary); }
.passwordless-options-toggle:focus-visible,
.passwordless-account-switch a:focus-visible,
.passwordless-modal .guest-btn:focus-visible { outline: 2px solid #a5b4fc; outline-offset: 3px; }
.passwordless-account-switch {
    grid-area: 4 / 1 / 5 / 2;
    align-self: center;
    margin: 18px 8px 0 0;
    padding: 10px 0;
    text-align: left;
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1.6;
}
.passwordless-account-switch a { color: #a5b4fc; font-weight: 600; text-decoration: none; border-radius: 3px; }
.passwordless-account-switch a:hover { text-decoration: underline; }
.passwordless-modal #guestModeRow {
    grid-area: 4 / 2 / 5 / 3;
    justify-content: flex-end;
    align-self: center;
    margin-top: 18px;
    padding-top: 0;
}
.passwordless-modal .guest-btn {
    flex: 0 1 auto;
    width: auto;
    min-height: 44px;
    padding: 8px 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    justify-content: center;
    font-family: inherit;
    border-radius: 12px;
}
.passwordless-modal .guest-btn:hover { background: var(--bg-tertiary); transform: none; }
.passwordless-modal .guest-btn .auth-btn-title { font-size: 12px; font-weight: 500; color: var(--text-secondary, #cbd5e1); }
.passwordless-modal .guest-btn .auth-choice-icon,
.passwordless-modal .guest-btn .auth-choice-arrow,
.passwordless-modal .guest-btn .auth-btn-desc { display: none; }
/* Blocks the page until dismissed; sits above the auth modal (30001). */
.passwordless-dialog-overlay {
    position: fixed;
    inset: 0;
    z-index: 30010;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.72);
}
.passwordless-dialog {
    box-sizing: border-box;
    width: min(100%, 380px);
    padding: 24px 22px 22px;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    background: var(--bg-card, #1a222c);
    color: var(--text-primary, #f8fafc);
    font-family: var(--font-reading, sans-serif);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
    text-align: left;
}
.passwordless-dialog h3 { margin: 0 0 10px; font-size: 18px; }
.passwordless-dialog p { margin: 0 0 20px; color: var(--text-secondary, #cbd5e1); font-size: 14px; line-height: 1.55; }
.passwordless-dialog .auth-submit-btn {
    width: 100%; min-height: 48px; border: 0; border-radius: 12px;
    background: #a5b4fc; color: #111827; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
}
.passwordless-dialog .auth-submit-btn:focus-visible { outline: 2px solid #a5b4fc; outline-offset: 3px; }
.passwordless-profile-form { display: grid; gap: 14px; width: 100%; }
.passwordless-profile-form h4 { margin: 0; font-size: 20px; text-align: center; }
.passwordless-profile-form p { margin: 0; color: var(--text-secondary); font-size: 13px; line-height: 1.5; }
.passwordless-profile-form label { font-size: 13px; font-weight: 600; }
.passwordless-profile-form .initials-input { width: 100%; box-sizing: border-box; }
.passwordless-profile-form [role="alert"] { color: #fca5a5; }
.passwordless-profile-form [role="alert"]:empty { display: none; }
.passwordless-profile-form .auth-submit-btn { width: 100%; min-height: 44px; }
.passwordless-loading-container {
    display: flex;
    grid-area: 2 / 1 / 3 / 3;
    box-sizing: border-box;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px 16px 0;
    min-height: 64px;
    width: 100%;
    border-radius: 14px 14px 0 0;
    background: var(--bg-tertiary);
}
.passwordless-spinner {
    width: 18px;
    height: 18px;
    flex: none;
    box-sizing: border-box;
    border: 3px solid rgba(165, 180, 252, 0.2);
    border-top-color: #a5b4fc;
    border-radius: 50%;
    animation: passwordlessSpin 0.75s linear infinite;
}
.passwordless-loading-text {
    font-size: 13px;
    color: var(--text-secondary, #94a3b8);
    font-weight: 500;
}
@keyframes passwordlessSpin {
    to { transform: rotate(360deg); }
}
@media (max-width: 480px) {
    #authModal.passwordless-auth-active { padding: 16px 12px; }
    #authModal .passwordless-modal { padding: 24px 20px; max-height: none; }
    #authModal .passwordless-modal::before { margin: -24px -20px; }
}

/* A logout transition covers open account/settings surfaces until reload. */
body.auth-logging-out #appLoadingScreen { z-index: 40000; }
