/* ============================================================
   AUTH KIT
   The sign-in shell (Components/Auth/AuthShell) and the pages built on it, from inbox/auth-mockups (centred single
   column, dark only). Every colour, radius and shadow comes from tokens.css: public routes are always dark
   (theme.js sets data-theme="dark", and the shell's .theme-dark pins the dark values on its subtree too).
   Classes: au-*.
   ============================================================ */

.au {
    position: relative;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.5 Inter, "Segoe UI", system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
}

.au *,
.au *::before,
.au *::after {
    box-sizing: border-box;
}

.au a {
    color: var(--brand);
    text-decoration: none;
}

.au a:hover {
    color: var(--brand-hover);
    text-decoration: underline;
}

.au :focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
}

.au-glow {
    position: absolute;
    left: 50%;
    top: 40px;
    width: 900px;
    max-width: 160vw;
    height: 600px;
    transform: translateX(-50%);
    background: radial-gradient(closest-side, var(--brand-soft), transparent);
    pointer-events: none;
}

/* Header: the wordmark only (no theme switch before sign-in). */
.au-header {
    position: relative;
    display: flex;
    align-items: center;
    padding: 20px 32px;
}

.au .au-logo {
    display: inline-flex;
    color: var(--text);
}

.au .au-logo:hover {
    color: var(--text);
    text-decoration: none;
}

.au-logo .wordmark {
    display: block;
    height: 30px;
    width: auto;
}

.au-main {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.au-col {
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 28px;
}

/* Heading block above the card. */
.au-head {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.au-title {
    margin: 0;
    font-size: 32px;
    font-weight: 600;
    letter-spacing: -0.03em;
    line-height: 1.1;
    color: var(--text);
}

.au-sub {
    margin: 0;
    color: var(--text-2);
}

.au-sub strong {
    color: var(--text);
    font-weight: 500;
}

.au .au-back {
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    font-size: 13.5px;
    color: var(--text-2);
    cursor: pointer;
}

.au .au-back:hover {
    color: var(--text);
    text-decoration: none;
}

/* The card that holds a form or a result. */
.au-card {
    display: flex;
    flex-direction: column;
    gap: 18px;
    margin: 0;
    padding: 28px;
    border-radius: 16px;
    background: var(--surface);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-pop);
}

.au-field {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.au-label-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
}

.au-label {
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text);
}

.au .au-label-row a {
    font-size: 13.5px;
}

.au-input {
    width: 100%;
    height: 44px;
    padding: 0 14px;
    border-radius: var(--radius);
    border: 1px solid var(--line-strong);
    background: var(--bg);
    color: var(--text);
    font: inherit;
}

.au-input::placeholder {
    color: var(--text-3);
}

.au-input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-soft);
}

.au-input[aria-invalid="true"] {
    border-color: var(--bad);
}

/* A password field with its show/hide button. */
.au-input-wrap {
    position: relative;
}

.au-input-wrap .au-input {
    padding-right: 44px;
}

.au-reveal {
    position: absolute;
    top: 0;
    right: 0;
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border: 0;
    background: none;
    color: var(--text-3);
    cursor: pointer;
}

.au-reveal:hover {
    color: var(--text);
}

.au-hint {
    margin: 0;
    font-size: 13px;
    color: var(--text-2);
}

/* Buttons. */
.au-btn {
    width: 100%;
    height: 46px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: var(--radius);
    border: 0;
    background: var(--brand);
    color: var(--on-brand);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}

.au .au-btn:hover {
    background: var(--brand-hover);
    color: var(--on-brand);
    text-decoration: none;
}

.au-btn:disabled {
    opacity: 0.6;
    cursor: default;
}

.au .au-btn-quiet {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--line-strong);
}

.au .au-btn-quiet:hover {
    background: var(--surface-2);
    color: var(--text);
}

.au-btn + .au-btn {
    margin-top: 0;
}

.au-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.au-link-btn {
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    color: var(--brand);
    cursor: pointer;
}

.au-link-btn:hover {
    color: var(--brand-hover);
    text-decoration: underline;
}

.au-link-btn:disabled {
    color: var(--text-3);
    cursor: default;
    text-decoration: none;
}

/* Checkbox rows (remember me, trust this browser). */
.au-check {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 14px;
    color: var(--text);
    cursor: pointer;
}

.au-check input {
    flex: none;
    width: 18px;
    height: 18px;
    margin: 2px 0 0;
    accent-color: var(--brand);
}

.au-check small {
    display: block;
    font-size: 13px;
    color: var(--text-2);
}

/* Messages: a note (session ended), an error, a success. */
.au-msg {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 12px 14px;
    border-radius: var(--radius);
    color: var(--text);
    font-size: 14px;
}

.au-msg svg {
    flex: none;
    margin-top: 1px;
}

.au-msg span {
    flex: 1;
}

.au-note {
    background: var(--warn-soft);
}

.au-note svg {
    stroke: var(--warn);
}

.au-error {
    background: var(--bad-soft);
}

.au-error svg {
    stroke: var(--bad);
}

.au-success {
    background: var(--ok-soft);
}

.au-success svg {
    stroke: var(--ok);
}

.au-msg-close {
    flex: none;
    padding: 0;
    border: 0;
    background: none;
    color: var(--text-2);
    cursor: pointer;
}

/* A result in the card: icon, title, text (verify email, a sent link). */
.au-result {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    text-align: center;
}

.au-result-icon {
    width: 52px;
    height: 52px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    background: var(--brand-soft);
    color: var(--brand);
}

.au-result-icon.is-ok {
    background: var(--ok-soft);
    color: var(--ok);
}

.au-result-icon.is-bad {
    background: var(--bad-soft);
    color: var(--bad);
}

.au-result h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
}

.au-result p {
    margin: 0;
    color: var(--text-2);
}

/* The six code boxes. */
.au-otp {
    border: 0;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.au-otp legend {
    padding: 0;
    margin-bottom: 10px;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text);
}

.au-otp-boxes {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 8px;
}

.au-otp-boxes input {
    width: 100%;
    height: 54px;
    padding: 0;
    text-align: center;
    border-radius: var(--radius);
    border: 1px solid var(--line-strong);
    background: var(--bg);
    color: var(--text);
    font: inherit;
    font-size: 22px;
    font-weight: 600;
}

.au-otp-boxes input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-soft);
}

/* Links under the card. */
.au-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px 22px;
    font-size: 14px;
}

.au-foot-text {
    margin: 0;
    text-align: center;
    color: var(--text-2);
}

/* Password rules (reset password). */
.au-rules {
    display: grid;
    gap: 4px;
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: 13px;
    color: var(--text-2);
}

.au-rules li {
    display: flex;
    align-items: center;
    gap: 8px;
}

.au-rules li::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--line-strong);
}

.au-rules li.is-met {
    color: var(--ok);
}

.au-rules li.is-met::before {
    background: var(--ok);
}

/* Footer: Privacy, Terms and the language. */
.au-footer {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    gap: 12px 20px;
    align-items: center;
    justify-content: center;
    padding: 24px 32px;
    font-size: 13.5px;
    color: var(--text-2);
}

.au .au-footer a {
    color: var(--text-2);
}

.au .au-footer a:hover {
    color: var(--text);
}

.au-sep {
    width: 1px;
    height: 14px;
    background: var(--line-strong);
}

.au-lang {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.au-lang select {
    height: 34px;
    padding: 0 10px;
    border-radius: 8px;
    border: 1px solid var(--line-strong);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 13.5px;
}

.au-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Phones. */
@media (max-width: 480px) {
    .au-header {
        padding: 16px 20px;
    }

    .au-main {
        align-items: flex-start;
        padding: 8px 16px 16px;
    }

    .au-col {
        gap: 22px;
    }

    .au-title {
        font-size: 28px;
    }

    .au-card {
        padding: 20px;
    }

    .au-otp-boxes {
        gap: 6px;
    }

    .au-otp-boxes input {
        height: 50px;
        font-size: 20px;
    }

    .au-footer {
        padding: 20px 16px;
    }
}

/* A card leaving (forgot and reset password, after a success), and a working spinner. */
.au-card {
    transition: opacity 0.3s ease;
}

.au-card.is-leaving {
    opacity: 0;
}

.au-spin {
    animation: au-spin 0.9s linear infinite;
}

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

@media (prefers-reduced-motion: reduce) {
    .au-card,
    .au-spin {
        transition: none;
        animation: none;
    }
}

/* A result card's heading is the page's h1, sized for the card. */
.au-result .au-title {
    font-size: 24px;
}

/* synapse.css colours every input:valid and input:focus with !important (old pages); inside the shell the tokens win. */
.au .au-input,
.au .au-otp-boxes input {
    border-color: var(--line-strong) !important;
}

.au .au-input:focus,
.au .au-otp-boxes input:focus {
    border-color: var(--brand) !important;
    box-shadow: 0 0 0 3px var(--brand-soft) !important;
}

.au .au-input[aria-invalid="true"] {
    border-color: var(--bad) !important;
}

/* A long address in the back link wraps from the left. */
.au .au-back {
    max-width: 100%;
    text-align: left;
    overflow-wrap: anywhere;
}

/* Every page before sign-in is dark (theme.js marks them html.is-public), whatever a later page stylesheet sets on
   html and body for its own page (check-in.css paints them light). */
html.is-public,
html.is-public body {
    background: var(--bg);
}

/* app.css sets overflow-x: hidden on html and body, which makes the body the scroll container: the document then
   never scrolls (a phone's address bar stays, a full-page screenshot is one screen). clip keeps nothing sideways
   without that. */
html.is-public,
html.is-public body {
    overflow-x: clip;
}

/* Header's right-hand side (sign-up: "Have an account? Sign in"). */
.au-header {
    justify-content: space-between;
    gap: 16px;
}

.au-header-end {
    font-size: 14px;
    color: var(--text-2);
    text-align: right;
}

/* The wider column (sign-up's two cards side by side). */
.au-col-wide {
    max-width: 560px;
}

.au-form {
    display: flex;
    flex-direction: column;
    gap: 28px;
    transition: opacity 0.3s ease;
}

.au-form.is-leaving {
    opacity: 0;
}

/* Step bars over the heading (sign-up). */
.au-head-steps {
    gap: 14px;
}

.au-bars {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
}

.au-bars span {
    height: 4px;
    border-radius: 4px;
    background: var(--line);
}

.au-bars span.is-done {
    background: var(--brand);
}

.au-step-label {
    font-size: 13.5px;
    color: var(--text-2);
}

/* Two fields on one row (first and last name). */
.au-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

/* Two choice cards (set up my company, join my team). */
.au-choices {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin: 0;
    padding: 0;
    border: 0;
    min-width: 0;
}

.au-choice {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 22px;
    border-radius: 16px;
    background: var(--surface);
    border: 1.5px solid var(--line);
    cursor: pointer;
}

.au-choice:hover {
    border-color: var(--line-strong);
}

.au-choice.is-selected {
    background: var(--brand-faint);
    border-color: var(--brand);
}

.au-choice:focus-within {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
}

.au-choice-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.au-choice-icon {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border-radius: 11px;
    background: var(--surface-2);
    color: var(--text-2);
}

.au-choice.is-selected .au-choice-icon {
    background: var(--brand-soft);
    color: var(--brand);
}

.au-choice input {
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: var(--brand);
}

.au-choice input:focus-visible {
    outline: none;
}

.au-choice-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
}

.au-choice-text {
    font-size: 14px;
    color: var(--text-2);
}

/* Back on the left, the step's action on the right. */
.au-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.au-nav .au-btn {
    width: auto;
    padding: 0 28px;
}

.au-nav .au-btn-quiet {
    padding: 0 18px;
}

/* The workspace address with its edit button, and the availability line. */
.au-url {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding: 4px 4px 4px 14px;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: var(--surface-2);
}

.au-url-text {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    font-size: 14px;
    overflow-wrap: anywhere;
}

.au-url-text strong {
    font-weight: 600;
    color: var(--text);
}

.au-url-muted {
    color: var(--text-3);
}

.au .au-url-input {
    width: 12ch;
    min-width: 0;
    height: 30px;
    padding: 0 6px;
    border-radius: 6px;
    border: 1px solid var(--brand) !important;
    background: var(--bg);
    color: var(--text);
    font: inherit;
}

.au-url-edit {
    flex: none;
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 8px;
    background: none;
    color: var(--text-2);
    cursor: pointer;
}

.au-url-edit:hover {
    background: var(--surface);
    color: var(--text);
}

.au-status {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    min-height: 20px;
    margin: 0;
    font-size: 13px;
    color: var(--text-2);
}

.au-status .is-ok {
    color: var(--ok);
}

.au-status .is-bad {
    color: var(--bad);
}

.au-input-code {
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

/* The Terms and Privacy line before an account is made. */
.au-consent {
    margin: 0;
    font-size: 13px;
    color: var(--text-2);
}

/* A read-only field (the invited address). */
.au .au-input[readonly] {
    background: var(--surface);
    border-color: var(--line) !important;
    color: var(--text-2);
}

/* The workspace's initials (accept invite). */
.au-avatar {
    width: 52px;
    height: 52px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    background: var(--surface-2);
    border: 1px solid var(--line-strong);
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
}

@media (max-width: 480px) {
    .au-header-text {
        display: none;
    }

    .au-choices {
        grid-template-columns: minmax(0, 1fr);
    }

    .au-choice {
        padding: 18px;
    }

    .au-row {
        grid-template-columns: minmax(0, 1fr);
    }

    /* On a phone a form stands on the page itself, without the card around it (accept invite). */
    .au-card.is-flat {
        padding: 0;
        background: none;
        border: 0;
        box-shadow: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .au-form {
        transition: none;
    }
}

/* App components shown inside the shell (TwoFactorSetup on enrolment, DataExportsPanel on account recovery) read the
   older variables (synapse.css): here they take the shell's tokens, so they are dark like the page around them. */
.au .au-embed {
    --background: var(--bg);
    --foreground: var(--text);
    --card: var(--surface);
    --card-foreground: var(--text);
    --popover: var(--surface-2);
    --popover-foreground: var(--text);
    --primary: var(--brand);
    --primary-foreground: var(--on-brand);
    --secondary: var(--surface-2);
    --secondary-foreground: var(--text);
    --muted: var(--surface-2);
    --muted-foreground: var(--text-2);
    --accent: var(--brand);
    --accent-foreground: var(--on-brand);
    --border: var(--line);
    --glass: var(--surface);
    --glass-border: var(--line);
    color: var(--text);
}

/* A choice card shows the focus ring for the keyboard only (a click already shows the selected border). */
.au-choice:focus-within {
    outline: none;
}

.au-choice:has(input:focus-visible) {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
}

/* Their hard-coded light colours, inside the shell only. */
.au .au-embed .form-input,
.au .au-embed .custom-select-trigger {
    background: var(--bg);
    border: 1px solid var(--line-strong) !important;
    color: var(--text);
}

.au .au-embed .form-input:focus,
.au .au-embed .custom-select-wrapper.open .custom-select-trigger {
    background: var(--bg);
    border-color: var(--brand) !important;
    box-shadow: 0 0 0 3px var(--brand-soft) !important;
}

.au .au-embed .custom-select-trigger:hover {
    background: var(--bg);
    border-color: var(--text-3) !important;
}

.au .au-embed .custom-select-dropdown {
    background: var(--surface-2);
    border: 1px solid var(--line-strong);
    box-shadow: var(--shadow-pop);
}

.au .au-embed .custom-select-option:hover,
.au .au-embed .custom-select-option.selected {
    background: var(--brand-faint);
}

.au .au-embed .form-label {
    color: var(--text-2);
}

.au .au-embed .btn-primary {
    background: var(--brand) !important;
    color: var(--on-brand) !important;
    border: 0;
}

.au .au-embed .btn-primary:hover {
    background: var(--brand-hover) !important;
}

.au .au-embed .pf-card {
    background: var(--surface);
    border-color: var(--line);
    box-shadow: var(--shadow-pop);
    border-radius: 16px;
    margin-bottom: 0;
}

.au .au-embed .pf-card-header {
    border-bottom-color: var(--line);
}

.au .au-embed .pf-card-title,
.au .au-embed .pf-danger-row-title {
    color: var(--text);
}

.au .au-embed .pf-danger-row-desc {
    color: var(--text-2);
}

/* A link drawn as a button ("Go to sign in"): .au a would colour its text the same as its background. */
.au a.au-btn {
    color: var(--on-brand);
    text-decoration: none;
}

.au a.au-btn-quiet {
    color: var(--text);
}
