.cloud-locked body > :not(#cloud-auth-root) {
    visibility: hidden !important;
}

.cloud-locked body {
    overflow: hidden;
}

.cloud-locked {
    overflow: hidden;
    scrollbar-width: none;
}

.cloud-locked::-webkit-scrollbar {
    display: none;
}

#cloud-auth-root {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: grid;
    place-items: center;
    padding: 1rem;
    overflow-y: auto;
    background: var(--bg-primary, #0d1117);
    color: var(--text-primary, #f0f3f6);
}

.cloud-auth-card {
    width: min(100%, 25rem);
    padding: 2rem;
    border: 1px solid var(--border, #30363d);
    border-radius: var(--radius-lg, 1rem);
    background: var(--bg-card, #161b22);
    box-shadow: 0 1.5rem 4rem rgb(0 0 0 / 35%);
}

.cloud-loading-card {
    display: grid;
    justify-items: center;
    gap: 0.5rem;
    width: min(100%, 20rem);
    text-align: center;
}

.cloud-loading-card .cloud-auth-logo {
    margin-bottom: 0.75rem;
}

.cloud-loading-spinner {
    width: 1.75rem;
    height: 1.75rem;
    border: 2px solid var(--border, #30363d);
    border-top-color: var(--accent-light, #b4a0ff);
    border-radius: 50%;
    animation: cloud-loading-spin 0.8s linear infinite;
}

.cloud-loading-message {
    margin: 0.5rem 0 0;
    color: var(--text-secondary, #a1aab4);
    font-size: 0.9rem;
}

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

@media (prefers-reduced-motion: reduce) {
    .cloud-loading-spinner {
        animation: none;
        border-top-color: var(--accent-light, #b4a0ff);
    }
}

.cloud-auth-logo {
    display: block;
    width: 9rem;
    height: auto;
    margin: 0 auto 1.5rem;
}

.cloud-auth-card h1 {
    margin: 0;
    text-align: center;
    font-size: 1.45rem;
}

.cloud-auth-description {
    margin: 0.65rem 0 1.5rem;
    color: var(--text-secondary, #a1aab4);
    line-height: 1.5;
    text-align: center;
}

.cloud-auth-card form {
    display: grid;
    gap: 0.65rem;
}

.cloud-auth-name-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.65rem;
}

.cloud-auth-name-fields > div {
    display: grid;
    gap: 0.65rem;
}

/* Guidance under the sign-in identifier field. Quiet, but must stay legible:
   it is the only place legacy accounts learn they can sign in by email. */
.cloud-auth-hint {
    margin: -0.15rem 0 0.25rem;
    color: var(--text-secondary, #a1aab4);
    font-size: 0.8rem;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.cloud-auth-card input {
    width: 100%;
    min-height: 2.8rem;
    padding: 0.65rem 0.75rem;
    color: inherit;
    border: 1px solid var(--border, #30363d);
    border-radius: var(--radius-sm, 0.4rem);
    background: var(--bg-primary, #0d1117);
}

.cloud-auth-message {
    min-height: 1.5em;
    margin: 0.25rem 0 0;
    color: var(--text-secondary, #a1aab4);
    line-height: 1.45;
}

.cloud-auth-card button {
    min-height: 2.8rem;
    width: 100%;
}

.cloud-account-control {
    display: flex;
    /* flex: 0 0 auto already stops this row shrinking, which is what keeps it
       out of the nav's scroll area. max-height: 100% additionally stops it from
       being pushed past the sidebar's bottom edge on a very short viewport,
       where `overflow: hidden` on <aside> would otherwise clip it away. */
    flex: 0 0 auto;
    max-height: 100%;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin: auto 0.75rem 0;
    padding: 0.6rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 0.75rem;
}

/* The avatar + username is display-only: it identifies the signed-in account
   but is not a link or a button. No hover background, no focus ring, no cursor
   change — anything that signals "clickable" would be a lie here. */
.cloud-account-summary {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    min-width: 0;
}

.cloud-account-icon {
    display: block;
    flex: 0 0 auto;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
}

.cloud-account-username {
    min-width: 0;
    color: var(--text-primary);
    font-size: 0.8rem;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* The account email is shown on the Account settings page, not in a hover
   tooltip here. The tooltip rules that used to live at this point were removed
   along with the .cloud-account-email element. */

.cloud-account-actions {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
}

.cloud-account-actions button {
    display: inline-flex;
    align-items: center;
    min-height: 2rem;
    padding: 0.25rem 0;
    border: 0;
    color: var(--accent-light);
    background: transparent;
    font-size: 0.75rem;
    cursor: pointer;
}

.cloud-account-actions button:disabled {
    cursor: wait;
    opacity: 0.65;
}

.cloud-account-actions .cloud-signout {
    justify-content: center;
    /* Sized to its own label rather than a fixed 5rem. A reserved width here
       came straight out of the username's space and truncated short names to
       "ada_c...", while the label is the same on every screen. */
    min-width: 0;
    min-height: 44px;
    padding: 0.3rem 0.6rem;
    flex: 0 0 auto;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-primary);
    font-weight: 600;
    white-space: nowrap;
}

.cloud-account-actions .cloud-signout:hover:not(:disabled) {
    background: var(--bg-card-hover);
}

.cloud-settings-page {
    display: grid;
    gap: 1rem;
    width: min(100%, 48rem);
    margin: 0 auto;
}

.cloud-settings-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.cloud-settings-title-row {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    min-width: 0;
}

.cloud-settings-title-row > div {
    /* Without this the text column refuses to shrink below its longest word
       (an email) and pushes the row wider than the page at 320px. */
    min-width: 0;
}

.cloud-settings-title-row .cloud-account-icon {
    width: 3rem;
    height: 3rem;
}

.cloud-settings-header h2 {
    font-size: 1.35rem;
    line-height: 1.3;
}

/* The page's own <header> already renders <h1>Account settings</h1>, so this
   repeated <h2> used to put two identical headings on screen. The element stays
   because #cloud-settings-title is the section's aria-labelledby target, but it
   is hidden visually: the account identity below is what is worth reading. */
.cloud-settings-heading {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

/* The account email, shown here now that it no longer lives in a hover
   tooltip on the sidebar avatar. Promoted above the descriptive line and
   given the accent colour so it reads as the account identity. */
/* Scoped as `.cloud-settings-header .cloud-settings-email` on purpose: the
   generic `.cloud-settings-header p` rule below is more specific than a bare
   class and was resetting this to the muted body colour. */
.cloud-settings-header .cloud-settings-email {
    display: block;
    margin-top: 0.3rem;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 600;
    /* A pasted or unusually long address must not push the header wide. */
    overflow-wrap: anywhere;
}

.cloud-settings-header p,
.cloud-settings-account p,
.cloud-settings-delete > p {
    margin-top: 0.35rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
    line-height: 1.5;
}

.cloud-settings-page button:focus-visible,
.cloud-settings-page input:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

.cloud-profile-form,
.cloud-profile-fields,
.cloud-profile-fields > div,
.cloud-settings-delete {
    display: grid;
    gap: 0.65rem;
}

.cloud-settings-username {
    display: grid;
    gap: 0.65rem;
}

.cloud-profile-form,
.cloud-password-section,
.cloud-settings-account,
.cloud-settings-delete {
    padding: 1.25rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
}

.cloud-profile-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.cloud-settings-page label {
    font-size: 0.85rem;
    font-weight: 600;
}

.cloud-settings-page input {
    width: 100%;
    min-height: 2.8rem;
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    color: var(--text-primary);
    font: inherit;
}

.cloud-settings-status,
.cloud-settings-delete-status {
    min-height: 1.5em;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.cloud-settings-save {
    justify-self: start;
}

.cloud-settings-account,
.cloud-password-section,
.cloud-settings-delete {
    display: grid;
    gap: 0.65rem;
    margin-bottom: 0;
}

.cloud-settings-account h3,
.cloud-password-section h3,
.cloud-settings-delete h3 {
    font-size: 1rem;
}

.cloud-password-section > p {
    margin-top: 0.35rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
    line-height: 1.5;
}

.cloud-password-form {
    display: grid;
    gap: 0.65rem;
    margin-top: 0.85rem;
}

.cloud-password-status {
    min-height: 1.5em;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.cloud-password-save {
    justify-self: start;
}

.cloud-settings-switch {
    justify-self: start;
    margin-top: 0.25rem;
}

.cloud-settings-delete h3 {
    color: var(--danger-text);
}

.cloud-settings-delete-button {
    justify-self: start;
    border: 1px solid var(--danger);
    color: var(--danger-text);
    background: transparent;
}

.cloud-settings-delete-button:hover:not(:disabled) {
    background: color-mix(in srgb, var(--danger) 14%, transparent);
}

.cloud-settings-delete-button:disabled {
    cursor: wait;
    opacity: 0.65;
}

.cloud-signout {
    flex: 0 0 auto;
    border: 0;
    padding: 0.25rem;
    color: var(--accent-light);
    background: transparent;
    cursor: pointer;
}

.cloud-sync-error {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 2200;
    max-width: min(32rem, calc(100vw - 2rem));
    padding: 0.8rem 1rem;
    border: 1px solid var(--danger, #f85149);
    border-radius: var(--radius-sm, 0.4rem);
    background: var(--bg-card, #161b22);
    color: var(--text-primary, #f0f3f6);
    box-shadow: 0 0.75rem 2rem rgb(0 0 0 / 30%);
}

@media (max-width: 767px) {
    .cloud-account-control {
        order: 3;
        margin: 0.75rem;
        padding: 0.5rem;
        font-size: 0.68rem;
    }
}

@media (max-width: 480px) {
    .cloud-auth-card {
        padding: 1.25rem;
    }

    @media (max-width: 600px) {
        .cloud-settings-switch {
            width: 100%;
        }
    }

    .cloud-auth-logo {
        margin-bottom: 1rem;
    }

    .cloud-auth-description {
        margin-bottom: 1rem;
    }

    .cloud-profile-form,
    .cloud-password-section,
    .cloud-settings-account,
    .cloud-settings-delete {
        padding: 1rem;
    }

    .cloud-profile-fields {
        grid-template-columns: minmax(0, 1fr);
    }
}
