.sx-auth-note {
    margin-bottom: 18px;
    color: var(--sx-form-muted);
    font-size: 0.9rem;
    line-height: 1.5;
}

/* Input OTP adapted from shadcn/ui: https://21st.dev/@shadcn/components/input-otp */
html[data-brand="sernax"] :is(.login-card .form-group, .activation-card) input.sx-auth-code {
    --sx-code-cell: clamp(30px, 9vw, 42px);
    box-sizing: content-box;
    width: calc(6 * var(--sx-code-cell)) !important;
    min-width: 0 !important;
    max-width: calc(100% - 2px);
    padding-inline: 0 !important;
    background: repeating-linear-gradient(
        90deg, var(--sx-form-input, var(--sx-canvas)) 0 calc(var(--sx-code-cell) - 1px),
        var(--sx-form-border, var(--sx-border)) calc(var(--sx-code-cell) - 1px) var(--sx-code-cell)
    ) !important;
    font: 700 20px/1.4 ui-monospace, monospace;
    text-indent: calc((var(--sx-code-cell) - 1ch) / 2);
    letter-spacing: calc(var(--sx-code-cell) - 1ch);
}

.sx-auth-code::placeholder { color: var(--sx-form-muted, var(--sx-muted)); opacity: .85; }

.sx-auth-submit .sx-pending-label,
.sx-auth-submit:disabled .sx-action-label { display: none; }

/* Pending label and spinner adapted from https://21st.dev/@ddoemonn/components/loading-button */
.sx-auth-submit:disabled .sx-pending-label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
}

.sx-auth-submit:disabled { cursor: wait; }

.sx-pending-label::before {
    width: 14px;
    height: 14px;
    border: 2px solid currentColor;
    border-inline-end-color: transparent;
    border-radius: 50%;
    content: "";
    animation: sx-auth-spin 750ms linear infinite;
}

@keyframes sx-auth-spin { to { transform: rotate(1turn); } }

html[data-brand="sernax"] body:has(.activation-card)::before,
html[data-brand="sernax"] body:has(.activation-card)::after { display: none; }

html[data-brand="sernax"] .activation-grid {
    padding: 16px;
    border: 1px solid var(--sx-border);
    border-radius: 12px;
    background: var(--sx-canvas);
}

html[data-brand="sernax"] .activation-grid > div { min-width: 0; }

html[data-brand="sernax"] .activation-card button.sx-auth-copy {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    width: auto;
    min-height: 40px;
    margin-top: 8px;
    padding: 0 10px;
    border: 1px solid var(--sx-border) !important;
    border-radius: 7px;
    background: var(--sx-raised) !important;
    color: var(--sx-ink) !important;
    font-size: 0.85rem;
    font-weight: 650;
}

.sx-auth-copy svg { width: 16px; height: 16px; }
html[data-brand="sernax"] .activation-card button.sx-auth-copy:hover { background: var(--sx-border) !important; }
.sx-auth-copy-status { margin: 6px 0 0; color: var(--sx-muted); font-size: 0.82rem; }
.sx-auth-copy-status:empty, html[data-brand="sernax"] .activation-status:empty { display: none; }

.sx-auth-return {
    display: inline-block;
    margin-top: 20px;
    color: var(--sx-accent);
    font-weight: 650;
    text-underline-offset: 4px;
}

@media (max-width: 560px) {
    html[data-brand="sernax"] body:has(.activation-card) { padding: 16px; }
    html[data-brand="sernax"] .activation-card { padding: 20px; }
    html[data-brand="sernax"] .activation-grid { gap: 12px; }
    html[data-brand="sernax"] .activation-qr { width: 148px; height: 148px; }
}

@media (prefers-reduced-motion: reduce) {
    .sx-pending-label::before { animation: none; }
}

.sx-auth-heading-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 8px 12px;
    margin-bottom: 16px;
}

.sx-auth-heading-row .sernax-wordmark { margin: 0 auto 0 0; }

.sx-auth-languages {
    display: inline-flex;
    gap: 2px;
    letter-spacing: normal;
}

.sx-auth-languages a {
    display: grid;
    min-width: 34px;
    min-height: 34px;
    place-items: center;
    border-radius: 6px;
    color: var(--sx-muted);
    text-decoration: none;
    font-size: 0.75rem;
    font-weight: 700;
}

.sx-auth-languages a:is(:hover, [aria-current]) {
    background: var(--sx-raised);
    color: var(--sx-ink);
}

html[data-brand="sernax"] body.sx-login-body {
    --sx-form-surface: #f9f7f3;
    --sx-form-input: #fffdfa;
    --sx-form-ink: #231f1f;
    --sx-form-muted: #675e5e;
    --sx-form-border: #d9d2ca;
    background: #141213;
}

html[data-brand="sernax"] body.sx-login-body::before,
html[data-brand="sernax"] body.sx-login-body::after { display: none !important; }

.sx-login.login-page {
    display: grid;
    grid-template-rows: auto 1fr;
    align-items: stretch;
    justify-content: stretch;
    min-height: 100dvh;
    padding: 0 clamp(16px, 4vw, 52px) clamp(20px, 4vh, 48px);
    background:
        radial-gradient(ellipse at 50% 0%, #302529 0%, transparent 62%),
        linear-gradient(150deg, #1a1719, #141213 74%);
}

.sx-login-masthead {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    min-height: 74px;
    width: min(100%, 1120px);
    margin-inline: auto;
    border-bottom: 1px solid #f8f9fb19;
}

.sx-login-masthead .sernax-wordmark {
    grid-column: 2;
    width: clamp(111px, 18vw, 138px);
}

.sx-login-masthead .sx-auth-languages {
    grid-column: 3;
    justify-self: end;
}

.sx-login-masthead .sx-auth-languages a { min-width: 40px; min-height: 44px; }
.sx-login-masthead .sx-auth-languages a:is(:hover, [aria-current]) { background: #f8f9fb14; }

.sx-login .login-container {
    place-self: center;
    max-width: 440px;
    width: 100%;
    margin-block: clamp(20px, 5vh, 40px);
}

.sx-login .login-container::before,
.sx-login .login-container::after,
.sx-login .login-card::before,
.sx-login .login-btn::before { content: none; }

html[data-brand="sernax"] .sx-login .login-card {
    min-width: 0;
    padding: clamp(22px, 6vw, 46px);
    border: 1px solid #f6f0e7 !important;
    border-radius: 20px;
    background: var(--sx-form-surface) !important;
    color: var(--sx-form-ink);
    color-scheme: light;
    box-shadow: 0 24px 68px #0007 !important;
    backdrop-filter: none !important;
    animation: none;
}

.sernax-login-header { margin-bottom: 28px; }
.sernax-login-header h1 {
    margin: 0;
    color: var(--sx-form-ink);
    font-size: clamp(27px, 5.6vw, 36px);
    line-height: 1.08;
    letter-spacing: -.05em;
    font-weight: 760;
}

.sernax-login-header [data-auth-heading] { display: none; }
[data-auth-mode="login"] [data-auth-heading="login"],
[data-auth-mode="register"] [data-auth-heading="register"],
[data-auth-mode="2fa"] [data-auth-heading="2fa"] { display: inline; }

html[data-brand="sernax"] .sx-login .form-group { margin-bottom: 18px; }
html[data-brand="sernax"] .sx-login .form-group label {
    margin-bottom: 7px;
    color: var(--sx-form-ink);
    font-size: .9rem;
    font-weight: 680;
    letter-spacing: 0;
    text-transform: none;
}

html[data-brand="sernax"] .sx-login .form-group input:not([type="radio"]) {
    min-height: 50px;
    border: 1px solid var(--sx-form-border) !important;
    border-radius: 9px !important;
    background-color: var(--sx-form-input) !important;
    color: var(--sx-form-ink) !important;
    box-shadow: none !important;
    font-size: 16px;
}

html[data-brand="sernax"] .sx-login .form-group input[aria-invalid="true"] {
    border-color: var(--sx-action) !important;
}

.sx-login .form-hint { color: #a81a20 !important; }

html[data-brand="sernax"] .sx-login .login-card :focus-visible {
    outline: 2px solid var(--sx-action) !important;
    outline-offset: 2px;
}

html[data-brand="sernax"] .sx-login .login-card input::placeholder {
    color: var(--sx-form-muted);
    opacity: .84;
}

.sx-login .input-with-button { position: relative; }
.sx-login .input-with-button #password { padding-inline-end: 52px; }

html[data-brand="sernax"] .sx-login .toggle-pass {
    position: absolute;
    inset-inline-end: 5px;
    top: 50%;
    translate: 0 -50%;
    display: grid;
    width: 40px;
    height: 40px;
    place-items: center;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--sx-form-muted);
}

.sx-login .toggle-pass:is(:hover, [aria-pressed="true"]) { color: var(--sx-form-ink); }
.sx-login .toggle-pass svg { width: 20px; height: 20px; }

html[data-brand="sernax"] .sx-login .login-btn {
    min-height: 50px;
    margin-top: 4px;
    border-radius: 9px;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: none;
    transform: none;
}

html[data-brand="sernax"] .sx-login .auth-role-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

html[data-brand="sernax"] .sx-login .auth-role-option span {
    background: var(--sx-form-input);
    border-color: var(--sx-form-border);
    color: var(--sx-form-muted);
}

html[data-brand="sernax"] .sx-login .auth-role-option input:checked + span {
    background: #f8e5e2;
    border-color: #c35b58;
    color: #80171b;
    box-shadow: none;
}

.sx-login .auth-role-option input:focus-visible + span {
    outline: 2px solid var(--sx-action);
    outline-offset: 2px;
}

.sx-login .register-note { color: var(--sx-form-muted); }

.sx-login-return {
    display: inline-block;
    margin-top: 16px;
    color: var(--sx-form-muted);
    font-size: .875rem;
    font-weight: 650;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.sx-login-return:hover { color: var(--sx-form-ink); }

.sx-login-body .custom-modal {
    background: #141213ab;
    backdrop-filter: blur(4px);
}

.sx-login-body .custom-modal-content {
    min-width: 0;
    width: min(calc(100% - 32px), 420px);
    max-height: calc(100dvh - 32px);
    overflow-y: auto;
    border: 1px solid var(--sx-form-border);
    border-radius: 16px;
    background: var(--sx-form-surface);
    box-shadow: 0 24px 58px #0008;
    animation: none;
}

.sx-login-body .custom-modal-icon { display: none; }
.sx-login-body .custom-modal-header { border: 0; padding-bottom: 0; }
.sx-login-body .custom-modal-title { color: var(--sx-form-ink); }
.sx-login-body .custom-modal-body { color: var(--sx-form-muted); padding-block: 10px 18px; }
.sx-login-body .custom-modal-footer { border: 0; padding-top: 0; }
.sx-login-body .custom-modal-confirm { min-height: 42px; text-transform: none; letter-spacing: 0; }
.sx-login-body .register-success-details code { color: var(--sx-form-ink); background: #ede7df; }
.sx-login-body .register-success-link { color: #961d24; }

@media (max-width: 600px) {
    .sx-login-masthead { min-height: 64px; }
    .sernax-login-header { margin-bottom: 23px; }
}

@media (max-height: 610px) {
    .sx-login .login-container { margin-block: 16px; }
}
