.topbar-profile-trigger,
.topbar-profile-trigger:hover,
.topbar-profile-trigger:focus-visible {
    opacity: 1 !important;
    filter: none !important;
    background: var(--zn-member-bg-app) !important;
}

.topbar-profile-trigger .topbar-profile-image,
.topbar-profile-trigger .topbar-profile-fallback {
    opacity: 1 !important;
    filter: none !important;
    background-color: var(--zn-member-bg-app);
}

.messages-brand-row {
    position: relative;
}

.user-profile-menu.profile-menu-hidden-trigger {
    position: absolute;
    top: calc(100% + 10px);
    right: auto;
    left: 0;
    z-index: 24;
    width: 0;
    height: 0;
    padding: 0;
    border: 0;
    background: transparent;
}

.user-profile-menu .user-profile-menu-panel {
    position: absolute;
    top: 0;
    right: auto;
    left: 0;
    z-index: 1;
    width: min(390px, calc(100vw - 24px));
    max-height: min(700px, calc(100dvh - 24px));
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 16px;
    overflow: auto;
    border: 1px solid var(--zn-member-border);
    border-radius: 16px;
    opacity: 1 !important;
    background: var(--zn-member-bg-app) !important;
    box-shadow: var(--zn-member-shadow);
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}

.user-profile-menu [hidden] {
    display: none !important;
}

.user-profile-menu .profile-menu-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-profile-menu .mini-profile {
    min-width: 0;
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-profile-menu .mini-profile-avatar {
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    overflow: hidden;
    border-radius: 50%;
    background: var(--zn-member-bg-app);
}

.user-profile-menu .mini-profile-avatar-image,
.user-profile-menu .mini-profile-avatar-fallback {
    width: 100%;
    height: 100%;
    opacity: 1 !important;
    object-fit: cover;
}

.user-profile-menu .mini-profile-avatar-image {
    display: block;
    object-position: center;
    border-radius: inherit;
}

.user-profile-menu .mini-profile-avatar-fallback {
    display: grid;
    place-items: center;
    color: var(--zn-member-accent-text);
    background: var(--zn-member-bg-app);
    font-weight: 700;
}

.user-profile-menu .mini-profile-copy {
    min-width: 0;
    max-width: 100px;
}

.user-profile-menu .mini-profile-copy strong,
.user-profile-menu .mini-profile-copy span {
    display: block;
    overflow-wrap: anywhere;
}

.user-profile-menu .mini-profile-copy strong {
    color: var(--zn-member-text-primary);
    overflow: hidden;
    font-size: 0.9rem;
    line-height: 1.15;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-profile-menu .mini-profile-copy span {
    color: var(--zn-member-text-muted);
    overflow: hidden;
    font-size: 0.72rem;
    line-height: 1.35;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-profile-menu .profile-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.user-profile-menu .profile-form > .form-field {
    gap: 7px;
}

.user-profile-menu .profile-form > .form-field > span {
    color: var(--zn-member-text-secondary);
    font-size: 0.9rem;
}

.user-profile-menu .profile-form > .form-field .form-input {
    min-height: 44px;
    padding: 9px 12px;
    border-radius: 10px;
    font-size: 0.94rem;
}

.user-profile-menu input[type="password"],
.user-profile-menu input[type="text"],
.user-profile-menu select,
.user-profile-menu textarea {
    font-size: 16px;
}

.user-profile-menu .profile-timezone-status {
    margin-top: -6px;
    color: var(--zn-member-text-muted);
    font-size: 0.75rem;
    line-height: 1.35;
}

.user-profile-menu .profile-security-device {
    display: grid;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--zn-member-border);
    border-radius: 14px;
    background: var(--zn-member-bg-surface-faint);
}

.user-profile-menu .profile-security-toggle {
    width: 100%;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 0;
    border: 0;
    color: var(--zn-member-text-primary);
    font: inherit;
    font-weight: 700;
    text-align: left;
    background: transparent;
    cursor: pointer;
}

.user-profile-menu .profile-security-toggle:focus-visible {
    outline: 2px solid var(--zn-member-accent);
    outline-offset: 3px;
    border-radius: 10px;
}

.user-profile-menu .profile-security-chevron {
    flex: 0 0 auto;
    color: var(--zn-member-text-muted);
    font-size: 1.05rem;
    line-height: 1;
    transition: transform 160ms ease;
}

.user-profile-menu .profile-security-toggle[aria-expanded="true"] .profile-security-chevron {
    transform: rotate(90deg);
}

.user-profile-menu .profile-security-content,
.user-profile-menu .profile-security-actions {
    display: grid;
    gap: 10px;
}

.user-profile-menu .profile-security-content {
    padding-top: 2px;
}

.user-profile-menu .profile-security-actions + .profile-security-actions {
    padding-top: 12px;
    border-top: 1px solid var(--zn-member-border);
}

.user-profile-menu .profile-security-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.user-profile-menu .profile-security-heading strong {
    color: var(--zn-member-text-primary);
    font-size: 0.94rem;
}

.user-profile-menu .profile-security-heading span,
.user-profile-menu .profile-passkey-copy span {
    color: var(--zn-member-text-muted);
    font-size: 0.75rem;
    line-height: 1.35;
}

.user-profile-menu .profile-passkey-list {
    display: grid;
    gap: 8px;
}

.user-profile-menu .profile-passkey-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
}

.user-profile-menu .profile-passkey-copy {
    display: grid;
    min-width: 0;
    gap: 3px;
}

.user-profile-menu .profile-passkey-copy strong,
.user-profile-menu .profile-passkey-copy span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-profile-menu .profile-avatar-editor {
    min-width: 0;
    margin: 2px 0 0;
    padding: 12px;
    border: 1px solid var(--zn-member-border);
    border-radius: 14px;
    background: var(--zn-member-bg-surface-faint);
}

.user-profile-menu .profile-avatar-editor legend {
    padding: 0 5px;
    color: var(--zn-member-text-primary);
    font-size: 0.94rem;
    font-weight: 650;
}

.user-profile-menu .profile-avatar-picker-row {
    display: grid;
    grid-template-columns: 64px minmax(0, 1fr);
    align-items: center;
    gap: 12px;
}

.user-profile-menu .profile-avatar-preview {
    width: 64px;
    height: 64px;
    overflow: hidden;
    border: 1px solid var(--zn-member-border-soft);
    border-radius: 50%;
    background: var(--zn-member-bg-app);
}

.user-profile-menu .profile-avatar-preview img,
.user-profile-menu .profile-avatar-preview span {
    width: 100%;
    height: 100%;
}

.user-profile-menu .profile-avatar-preview img {
    display: block;
    object-fit: cover;
    object-position: center;
}

.user-profile-menu .profile-avatar-preview span {
    display: grid;
    place-items: center;
    color: var(--zn-member-accent-text);
    font-size: 1.2rem;
    font-weight: 700;
}

.user-profile-menu .profile-avatar-preview [hidden] {
    display: none;
}

.user-profile-menu .profile-avatar-dropzone {
    min-width: 0;
    min-height: 64px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px dashed var(--zn-member-border);
    border-radius: 12px;
    color: var(--zn-member-text-primary);
    background: var(--zn-member-bg-app);
    cursor: pointer;
    transition: border-color 0.16s ease, background 0.16s ease;
}

.user-profile-menu .profile-avatar-dropzone:hover,
.user-profile-menu .profile-avatar-dropzone:focus-within {
    border-color: color-mix(in srgb, var(--zn-success) 70%, var(--zn-member-border));
    background: color-mix(in srgb, var(--zn-success) 7%, var(--zn-member-bg-app));
}

.user-profile-menu .profile-avatar-upload-icon {
    width: 24px;
    height: 24px;
    flex: 0 0 24px;
    color: var(--zn-success);
}

.user-profile-menu .profile-avatar-dropzone-copy {
    min-width: 0;
    display: grid;
    gap: 3px;
}

.user-profile-menu .profile-avatar-dropzone-copy strong,
.user-profile-menu .profile-avatar-dropzone-copy span {
    overflow-wrap: anywhere;
}

.user-profile-menu .profile-avatar-dropzone-copy strong {
    font-size: 0.88rem;
}

.user-profile-menu .profile-avatar-dropzone-copy span {
    color: var(--zn-member-text-muted);
    font-size: 0.72rem;
    line-height: 1.35;
}

.user-profile-menu .profile-avatar-progress {
    display: grid;
    gap: 7px;
    margin-top: 14px;
}

.user-profile-menu .profile-avatar-progress[hidden] {
    display: none;
}

.user-profile-menu .profile-avatar-progress-copy {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    color: var(--zn-member-text-secondary);
    font-size: 0.8rem;
}

.user-profile-menu .profile-avatar-progress-track {
    height: 8px;
    overflow: hidden;
    border-radius: 999px;
    background: color-mix(in srgb, var(--zn-member-border) 50%, transparent);
}

.user-profile-menu .profile-avatar-progress-track > span {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: var(--zn-success);
    transition: width 0.18s ease;
}

.user-profile-menu .profile-avatar-progress.is-processing .profile-avatar-progress-track > span {
    width: 42%;
    animation: profile-avatar-processing 1.35s ease-in-out infinite alternate;
}

.user-profile-menu .profile-avatar-progress.is-error .profile-avatar-progress-copy {
    color: var(--zn-danger);
}

.user-profile-menu .profile-avatar-progress.is-error .profile-avatar-progress-track > span {
    width: 100% !important;
    background: var(--zn-danger);
}

@keyframes profile-avatar-processing {
    from { transform: translateX(-30%); }
    to { transform: translateX(170%); }
}

@media (prefers-reduced-motion: reduce) {
    .user-profile-menu .profile-avatar-progress.is-processing .profile-avatar-progress-track > span {
        width: 100%;
        animation: none;
        opacity: 0.6;
    }
}

.user-profile-menu .profile-save-button {
    width: 100%;
    min-height: 46px;
    justify-content: center;
    border-radius: 12px;
    font-size: 0.94rem;
}

.user-profile-menu .profile-menu-header > .user-header-actions {
    width: auto;
    flex: 0 0 auto;
    display: flex;
    justify-content: flex-end;
    gap: 6px;
    margin: 0;
    padding: 0;
}

body[class*="user-body-"] .user-profile-menu .profile-menu-header .notification-settings-compact,
body[class*="user-body-"] .user-profile-menu .profile-menu-header .notification-enable-button,
body[class*="user-body-"] .user-profile-menu .profile-menu-header .user-header-logout-button {
    width: auto;
    min-width: 0;
    height: 38px;
    min-height: 38px;
}

body[class*="user-body-"] .user-profile-menu .profile-menu-header .notification-enable-button,
body[class*="user-body-"] .user-profile-menu .profile-menu-header .user-header-logout-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0 8px;
    border-width: 1px !important;
    box-shadow: none !important;
}

body[class*="user-body-"] .user-profile-menu .profile-menu-header .notification-enable-button,
body[class*="user-body-"] .user-profile-menu .profile-menu-header .notification-settings[data-state="active"] .notification-enable-button,
body[class*="user-body-"] .user-profile-menu .profile-menu-header .notification-settings.is-notification-active .notification-enable-button {
    border-color: var(--zn-success) !important;
    color: var(--zn-success) !important;
    background: var(--zn-member-bg-app) !important;
    box-shadow: none !important;
}

body[class*="user-body-"] .user-profile-menu .profile-menu-header .notification-enable-button:hover,
body[class*="user-body-"] .user-profile-menu .profile-menu-header .notification-enable-button:focus-visible {
    color: color-mix(in srgb, var(--zn-success) 82%, var(--zn-member-text-primary)) !important;
    background: color-mix(in srgb, var(--zn-success) 8%, var(--zn-member-bg-app)) !important;
}

body[class*="user-body-"] .user-profile-menu .profile-menu-header .user-header-logout-button {
    border-color: var(--zn-danger) !important;
    color: var(--zn-danger) !important;
    background: var(--zn-member-bg-app) !important;
    box-shadow: none !important;
}

body[class*="user-body-"] .user-profile-menu .profile-menu-header .user-header-logout-button:hover,
body[class*="user-body-"] .user-profile-menu .profile-menu-header .user-header-logout-button:focus-visible {
    background: color-mix(in srgb, var(--zn-danger) 8%, var(--zn-member-bg-app)) !important;
}

/* Detached notification settings panel. It is moved under body while open. */
.notification-mobile-panel {
    width: min(500px, calc(100vw - 32px));
    max-height: min(760px, calc(100dvh - 32px));
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 26px;
    border: 1px solid var(--zn-member-border);
    border-radius: 16px;
    background: var(--zn-member-bg-shell);
    color: var(--zn-member-text-primary);
    box-shadow: var(--zn-member-shadow);
    overflow-x: hidden;
}

.notification-mobile-panel > * {
    flex: 0 0 auto;
}

.notification-mobile-panel .notification-settings-header {
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--zn-member-border-soft);
}

.notification-mobile-panel .notification-copy {
    min-width: 0;
    display: grid;
    gap: 4px;
}

.notification-mobile-panel .notification-copy h3 {
    margin: 0;
    color: var(--zn-member-text-primary);
    font-size: 1.45rem;
    line-height: 1.2;
}

.notification-mobile-panel .notification-copy > span {
    color: var(--zn-member-text-secondary);
    font-size: 0.9rem;
}

.notification-mobile-panel .notification-status {
    color: var(--zn-success);
    font-size: 0.82rem;
    font-weight: 650;
}

.notification-mobile-panel[data-state="blocked"] .notification-status {
    color: var(--zn-danger);
}

.notification-mobile-panel .notification-panel-close {
    width: 42px;
    height: 42px;
    border-color: var(--zn-member-border);
    border-radius: 10px;
    background: var(--zn-member-bg-app);
    color: var(--zn-member-text-primary);
}

.notification-mobile-panel .notification-panel-close:hover,
.notification-mobile-panel .notification-panel-close:focus-visible {
    background: var(--zn-member-bg-surface-hover);
    border-color: var(--zn-member-border-strong);
}

.notification-mobile-panel .notification-panel-close-icon {
    width: 20px;
    height: 20px;
}

.notification-mobile-panel .notification-instruction-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.notification-mobile-panel .notification-instruction-icon {
    width: 22px;
    height: 22px;
    flex: 0 0 22px;
    padding: 3px;
    border-radius: 50%;
    background: var(--zn-member-bg-surface-strong);
    color: var(--zn-member-text-secondary);
}

.notification-mobile-panel .notification-instruction {
    font-size: 0.86rem;
}

.notification-mobile-panel .notification-device-health {
    gap: 10px;
}

.notification-mobile-panel .notification-device-details > summary {
    display: none;
}

.notification-mobile-panel .notification-device-chevron {
    width: 18px;
    height: 18px;
    transition: transform 0.16s ease;
}

.notification-mobile-panel .notification-device-details[open] .notification-device-chevron {
    transform: rotate(180deg);
}

.notification-mobile-panel .notification-device-details[open],
.notification-mobile-panel .notification-debug-details[open] {
    height: auto;
    min-height: max-content;
    max-height: none;
}

.notification-mobile-panel .notification-debug-grid {
    gap: 10px;
}

.notification-mobile-panel .notification-debug-grid > div {
    min-height: 78px;
    padding: 13px 14px;
    border-color: var(--zn-member-border);
    border-radius: 10px;
    background: var(--zn-member-bg-app);
}

.notification-mobile-panel .notification-debug-grid dt {
    margin-bottom: 8px;
    font-size: 0.76rem;
}

.notification-mobile-panel .notification-debug-grid dd {
    font-size: 0.9rem;
    font-weight: 600;
}

.notification-mobile-panel .notification-mobile-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.notification-mobile-panel .notification-action-button {
    min-width: 0;
    min-height: 58px;
    justify-content: flex-start;
    gap: 11px;
    padding: 10px 14px;
    border: 1px solid var(--zn-member-border) !important;
    border-radius: 12px !important;
    background: var(--zn-member-bg-app) !important;
    color: var(--zn-member-text-primary) !important;
    font-size: 0.82rem;
    line-height: 1.25;
    text-align: left;
    box-shadow: none !important;
}

.notification-mobile-panel .notification-action-button:hover,
.notification-mobile-panel .notification-action-button:focus-visible {
    border-color: var(--zn-member-accent-border-strong) !important;
    background: var(--zn-member-bg-surface-hover) !important;
}

.notification-mobile-panel .notification-action-button:disabled {
    color: var(--zn-member-text-muted) !important;
    opacity: 0.72;
}

.notification-mobile-panel .notification-action-icon {
    width: 23px;
    height: 23px;
    flex: 0 0 23px;
    color: var(--zn-success);
}

.notification-mobile-panel .notification-action-icon-blue {
    color: var(--zn-member-accent);
}

.notification-mobile-panel .notification-action-icon-danger {
    color: var(--zn-danger);
}

.notification-mobile-panel .notification-debug-details {
    border: 1px solid var(--zn-member-border);
    border-radius: 12px;
    background: var(--zn-member-bg-app);
    overflow: hidden;
}

.notification-mobile-panel .notification-debug-details > summary {
    min-height: 52px;
    justify-content: space-between;
    padding: 0 16px;
    border: 0;
    border-radius: 0;
    color: var(--zn-member-text-primary);
    font-size: 0.9rem;
}

.notification-mobile-panel .notification-debug-details[open] > summary {
    margin-bottom: 0;
    border-bottom: 1px solid var(--zn-member-border-soft);
}

.notification-mobile-panel .notification-debug-details > .notification-debug-grid {
    padding: 10px;
}

.notification-mobile-panel .notification-debug-chevron {
    width: 18px;
    height: 18px;
    transition: transform 0.16s ease;
}

.notification-mobile-panel .notification-debug-details[open] .notification-debug-chevron {
    transform: rotate(180deg);
}

.notification-mobile-panel .notification-toggle-row {
    overflow: hidden;
    gap: 0;
    border: 1px solid var(--zn-member-border);
    border-radius: 12px;
    background: var(--zn-member-bg-app);
}

.notification-mobile-panel .notification-toggle {
    min-width: 0;
    min-height: 54px;
    gap: 10px;
    padding: 10px 14px;
    color: var(--zn-member-text-primary);
    font-size: 0.8rem;
}

.notification-mobile-panel .notification-toggle + .notification-toggle {
    border-left: 1px solid var(--zn-member-border-soft);
}

.notification-mobile-panel .notification-toggle input {
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    accent-color: var(--zn-member-accent);
}

@media (max-width: 760px) {
    .notification-mobile-panel {
        top: calc(env(safe-area-inset-top) + 12px);
        right: 12px;
        bottom: calc(env(safe-area-inset-bottom) + 12px);
        left: 12px;
        width: auto;
        max-height: none;
        gap: 14px;
        padding: 16px;
        border-radius: 14px;
        transform: none;
    }

    .notification-mobile-panel .notification-settings-header {
        position: sticky;
        top: -16px;
        z-index: 2;
        margin: -16px -16px 0;
        padding: 16px 16px 12px;
        background: var(--zn-member-bg-shell);
    }

    .notification-mobile-panel .notification-copy h3 {
        font-size: 1.2rem;
    }

    .notification-mobile-panel .notification-copy > span {
        font-size: 0.78rem;
    }

    .notification-mobile-panel .notification-device-details {
        overflow: hidden;
        border: 1px solid var(--zn-member-border);
        border-radius: 12px;
        background: var(--zn-member-bg-app);
    }

    .notification-mobile-panel .notification-device-details > summary {
        min-height: 50px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        padding: 0 14px;
        color: var(--zn-member-text-primary);
        font-size: 0.9rem;
        font-weight: 700;
        cursor: pointer;
        list-style: none;
    }

    .notification-mobile-panel .notification-device-details > summary::-webkit-details-marker {
        display: none;
    }

    .notification-mobile-panel .notification-device-details[open] > summary {
        border-bottom: 1px solid var(--zn-member-border-soft);
    }

    .notification-mobile-panel .notification-device-health {
        padding: 10px;
    }

    .notification-mobile-panel .notification-mobile-actions {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .notification-mobile-panel .notification-action-button {
        min-height: 54px !important;
        gap: 8px;
        padding: 8px 10px !important;
        font-size: 0.74rem;
    }

    .notification-mobile-panel .notification-action-icon {
        width: 20px;
        height: 20px;
        flex-basis: 20px;
    }
}

@media (max-width: 340px) {
    .notification-mobile-panel .notification-mobile-actions,
    .notification-mobile-panel .notification-debug-grid,
    .notification-mobile-panel .notification-toggle-row {
        grid-template-columns: minmax(0, 1fr);
    }

    .notification-mobile-panel .notification-toggle + .notification-toggle {
        border-top: 1px solid var(--zn-member-border-soft);
        border-left: 0;
    }
}

.user-profile-menu .profile-action-label {
    display: inline;
    font-size: 0.72rem;
    font-weight: 650;
    white-space: nowrap;
}

html[data-user-sidebar-state="collapsed"] [data-user-sidebar-root] .user-profile-menu,
body.user-sidebar-collapsed [data-user-sidebar-root] .user-profile-menu {
    top: 0;
    left: calc(100% + 10px);
}

@media (max-width: 760px) {
    .user-profile-menu.profile-menu-hidden-trigger {
        top: calc(100% + 8px);
        left: 0;
    }

    .user-profile-menu .user-profile-menu-panel {
        gap: 12px;
        padding: 14px;
    }

    .user-profile-menu .mini-profile-avatar {
        width: 44px;
        height: 44px;
        flex-basis: 44px;
    }

    .user-profile-menu .mini-profile-copy strong {
        font-size: 1.05rem;
    }

    .user-profile-menu .mini-profile-copy span {
        font-size: 0.8rem;
    }

    .user-profile-menu .profile-action-label {
        display: none;
    }

    body[class*="user-body-"] .user-profile-menu .profile-menu-header .notification-enable-button,
    body[class*="user-body-"] .user-profile-menu .profile-menu-header .user-header-logout-button {
        width: 42px;
        padding: 0;
    }

    .user-profile-menu .profile-avatar-picker-row {
        grid-template-columns: 56px minmax(0, 1fr);
        gap: 12px;
    }

    .user-profile-menu .profile-avatar-preview {
        width: 56px;
        height: 56px;
    }

    .user-profile-menu .profile-avatar-dropzone {
        min-height: 56px;
        padding: 9px;
    }
}
