.surface-switcher-item {
    display: contents;
}

.user-sidebar-toggle,
.user-sidebar-submenu,
.user-sidebar-submenu-trigger-control {
    display: none;
}

.user-sidebar-submenu-trigger-control {
    font: inherit;
    cursor: pointer;
}

.surface-switcher-link.surface-switcher-operator,
.surface-switcher-link.surface-switcher-operator.is-active {
    border-color: var(--zn-member-border);
    background: var(--zn-member-bg-surface-hover);
    color: var(--zn-member-text-secondary);
    box-shadow: none;
}

.surface-switcher-link.surface-switcher-operator.is-active {
    border-color: var(--zn-member-accent-border);
    background: var(--zn-member-accent-surface);
    color: var(--zn-member-accent-text);
}

@media (min-width: 761px) {
    body.user-body-messaging .messaging-layout,
    body.user-body-meetings .meeting-layout,
    body.user-body-workspace .workspace-layout {
        transition: none;
    }

    html[data-user-sidebar-motion$="-layout"] body.user-body-messaging .messaging-layout,
    html[data-user-sidebar-motion$="-layout"] body.user-body-meetings .meeting-layout,
    html[data-user-sidebar-motion$="-layout"] body.user-body-workspace .workspace-layout {
        transition: grid-template-columns 320ms cubic-bezier(0.4, 0, 0.2, 1);
    }

    [data-user-sidebar-root] > .conversation-hub {
        position: relative;
    }

    body.user-body-messaging .messages-brand-row,
    body.user-body-meetings .meeting-brand-row,
    body.user-body-workspace .workspace-brand-row {
        grid-template-columns: 46px minmax(0, 1fr) auto 32px !important;
    }

    .user-sidebar-toggle {
        display: inline-grid;
    }

    html[data-user-sidebar-state="collapsed"] body.user-body-messaging .messaging-layout,
    body.user-body-messaging.user-sidebar-collapsed .messaging-layout,
    html[data-user-sidebar-state="collapsed"] body.user-body-meetings .meeting-layout,
    body.user-body-meetings.user-sidebar-collapsed .meeting-layout,
    html[data-user-sidebar-state="collapsed"] body.user-body-workspace .workspace-layout,
    body.user-body-workspace.user-sidebar-collapsed .workspace-layout,
    html[data-user-sidebar-state="collapsed"] body.user-body-workspace:has(.workspace-calendar-shell) .workspace-layout,
    body.user-body-workspace.user-sidebar-collapsed:has(.workspace-calendar-shell) .workspace-layout {
        grid-template-columns: minmax(72px, 72px) minmax(0, 1fr) !important;
        grid-template-rows: minmax(0, 1fr);
        align-content: stretch;
    }

    html[data-user-sidebar-state="collapsed"] body.user-body-messaging [data-user-sidebar-root],
    body.user-body-messaging.user-sidebar-collapsed [data-user-sidebar-root],
    html[data-user-sidebar-state="collapsed"] body.user-body-meetings [data-user-sidebar-root],
    body.user-body-meetings.user-sidebar-collapsed [data-user-sidebar-root],
    html[data-user-sidebar-state="collapsed"] body.user-body-workspace [data-user-sidebar-root],
    body.user-body-workspace.user-sidebar-collapsed [data-user-sidebar-root] {
        position: relative;
        z-index: 20;
        display: block !important;
        grid-column: 1 !important;
        grid-row: 1 !important;
        width: 100% !important;
        min-width: 0 !important;
        max-width: none !important;
        min-height: 0;
        align-self: stretch;
        overflow: visible;
    }

    html[data-user-sidebar-state="collapsed"] body.user-body-messaging .chat-pane,
    body.user-body-messaging.user-sidebar-collapsed .chat-pane,
    html[data-user-sidebar-state="collapsed"] body.user-body-meetings .meeting-cockpit,
    body.user-body-meetings.user-sidebar-collapsed .meeting-cockpit,
    html[data-user-sidebar-state="collapsed"] body.user-body-workspace .workspace-browser,
    body.user-body-workspace.user-sidebar-collapsed .workspace-browser {
        display: flex !important;
        grid-column: 2 !important;
        grid-row: 1 !important;
        width: 100%;
        min-width: 0;
    }

    html[data-user-sidebar-state="collapsed"] body.user-body-messaging .chat-pane,
    body.user-body-messaging.user-sidebar-collapsed .chat-pane {
        display: block !important;
    }

    html[data-user-sidebar-state="collapsed"] body[class*="user-body-"] [data-user-sidebar-root] > .conversation-hub,
    body.user-sidebar-collapsed [data-user-sidebar-root] > .conversation-hub {
        width: 100%;
        height: 100%;
        min-height: min(760px, calc(100vh - 28px));
        padding: 8px;
        overflow: visible;
        border: 1px solid var(--zn-member-border);
        border-radius: 22px;
        background:
            linear-gradient(
                180deg,
                color-mix(in srgb, var(--zn-member-bg-card) 94%, transparent),
                color-mix(in srgb, var(--zn-member-bg-surface) 92%, var(--zn-member-bg-card))
            ),
            var(--zn-member-bg-card);
        box-shadow: var(--zn-member-shadow);
        backdrop-filter: blur(18px);
        transition: width 0.18s ease, padding 0.18s ease, border-radius 0.18s ease;
    }

    html[data-user-sidebar-state="collapsed"] body[class*="user-body-"] [data-user-sidebar-root] .messages-home-header,
    body.user-sidebar-collapsed [data-user-sidebar-root] .messages-home-header {
        width: 100%;
        height: 100%;
        min-height: 0;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 36px;
        padding: 2px 0 12px;
        overflow: visible;
        border: 0;
    }

    html[data-user-sidebar-state="collapsed"] body[class*="user-body-"] [data-user-sidebar-root] .messages-home-header > :not(.messages-brand-row):not(.surface-switcher),
    body.user-sidebar-collapsed [data-user-sidebar-root] .messages-home-header > :not(.messages-brand-row):not(.surface-switcher),
    html[data-user-sidebar-state="collapsed"] body[class*="user-body-"] [data-user-sidebar-root] > .conversation-hub > :not(.messages-home-header),
    body.user-sidebar-collapsed [data-user-sidebar-root] > .conversation-hub > :not(.messages-home-header) {
        display: none !important;
    }

    html[data-user-sidebar-state="collapsed"] body[class*="user-body-"] [data-user-sidebar-root] .messages-brand-row,
    body.user-sidebar-collapsed [data-user-sidebar-root] .messages-brand-row {
        position: static;
        width: 100%;
        min-height: 48px;
        display: flex !important;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 8px;
        padding: 0 !important;
    }

    html[data-user-sidebar-state="collapsed"] body[class*="user-body-"] [data-user-sidebar-root] .messages-brand-row h1,
    html[data-user-sidebar-state="collapsed"] body[class*="user-body-"] [data-user-sidebar-root] .messages-brand-row .znode-user-version,
    body.user-sidebar-collapsed [data-user-sidebar-root] .messages-brand-row h1,
    body.user-sidebar-collapsed [data-user-sidebar-root] .messages-brand-row .znode-user-version {
        display: none !important;
    }

    html[data-user-sidebar-state="collapsed"] body[class*="user-body-"] [data-user-sidebar-root] .topbar-title-mark,
    body.user-sidebar-collapsed [data-user-sidebar-root] .topbar-title-mark {
        width: 46px;
        height: 46px;
        min-width: 46px;
        flex-basis: 46px;
        margin: 0;
        border-radius: 14px;
        transition: transform 0.16s ease;
    }

    html[data-user-sidebar-state="collapsed"] body[class*="user-body-"] [data-user-sidebar-root] .topbar-title-mark:hover,
    html[data-user-sidebar-state="collapsed"] body[class*="user-body-"] [data-user-sidebar-root] .topbar-title-mark:focus-visible,
    body.user-sidebar-collapsed [data-user-sidebar-root] .topbar-title-mark:hover,
    body.user-sidebar-collapsed [data-user-sidebar-root] .topbar-title-mark:focus-visible {
        transform: scale(1.06);
    }

    html[data-user-sidebar-state="collapsed"] body[class*="user-body-"] [data-user-sidebar-root] .surface-switcher-user,
    body.user-sidebar-collapsed [data-user-sidebar-root] .surface-switcher-user {
        width: 100%;
        max-width: none;
        display: flex;
        flex: 0 1 auto;
        flex-direction: column;
        align-items: center;
        justify-content: flex-start;
        gap: 12px;
        overflow: visible;
        padding: 0;
    }

    html[data-user-sidebar-state="collapsed"] body[class*="user-body-"] [data-user-sidebar-root] .surface-switcher-item,
    body.user-sidebar-collapsed [data-user-sidebar-root] .surface-switcher-item {
        position: relative;
        display: block;
        width: 48px;
        height: 48px;
        flex: 0 0 48px;
    }

    html[data-user-sidebar-state="collapsed"] body[class*="user-body-"] [data-user-sidebar-root] .user-sidebar-primary-link,
    body.user-sidebar-collapsed [data-user-sidebar-root] .user-sidebar-primary-link {
        display: none !important;
    }

    html[data-user-sidebar-state="collapsed"] body[class*="user-body-"] [data-user-sidebar-root] .user-sidebar-submenu-trigger-control,
    body.user-sidebar-collapsed [data-user-sidebar-root] .user-sidebar-submenu-trigger-control {
        display: inline-flex;
    }

    html[data-user-sidebar-state="collapsed"] body[class*="user-body-"] [data-user-sidebar-root] .surface-switcher-user .surface-switcher-link,
    body.user-sidebar-collapsed [data-user-sidebar-root] .surface-switcher-user .surface-switcher-link {
        width: 48px !important;
        height: 48px !important;
        min-width: 48px !important;
        min-height: 48px !important;
        max-width: 48px;
        flex: 0 0 48px !important;
        padding: 0 !important;
        border-radius: 15px !important;
        transition:
            transform 0.16s ease,
            background 0.16s ease,
            border-color 0.16s ease,
            color 0.16s ease;
    }

    html[data-user-sidebar-state="collapsed"] body[class*="user-body-"] [data-user-sidebar-root] .surface-switcher-user .surface-switcher-link:hover,
    html[data-user-sidebar-state="collapsed"] body[class*="user-body-"] [data-user-sidebar-root] .surface-switcher-user .surface-switcher-link:focus-visible,
    body.user-sidebar-collapsed [data-user-sidebar-root] .surface-switcher-user .surface-switcher-link:hover,
    body.user-sidebar-collapsed [data-user-sidebar-root] .surface-switcher-user .surface-switcher-link:focus-visible {
        transform: scale(1.08) translateX(2px);
    }

    html[data-user-sidebar-state="collapsed"] body[class*="user-body-"] [data-user-sidebar-root] .surface-switcher-icon,
    body.user-sidebar-collapsed [data-user-sidebar-root] .surface-switcher-icon {
        width: 22px;
        height: 22px;
        flex: 0 0 22px;
    }

    html[data-user-sidebar-state="collapsed"] body[class*="user-body-"] [data-user-sidebar-root] .surface-switcher-label,
    body.user-sidebar-collapsed [data-user-sidebar-root] .surface-switcher-label {
        top: 50%;
        left: calc(100% + 10px);
        transform: translateY(-50%);
    }

    html[data-user-sidebar-state="collapsed"] body[class*="user-body-"] [data-user-sidebar-root] .surface-switcher-link:hover .surface-switcher-label,
    html[data-user-sidebar-state="collapsed"] body[class*="user-body-"] [data-user-sidebar-root] .surface-switcher-link:focus-visible .surface-switcher-label,
    body.user-sidebar-collapsed [data-user-sidebar-root] .surface-switcher-link:hover .surface-switcher-label,
    body.user-sidebar-collapsed [data-user-sidebar-root] .surface-switcher-link:focus-visible .surface-switcher-label {
        top: 50%;
        left: calc(100% + 10px);
        transform: translateY(-50%);
    }

    [data-user-sidebar-submenu-trigger][aria-expanded="true"] .surface-switcher-label {
        opacity: 0 !important;
        pointer-events: none;
    }

    [data-user-sidebar-root][data-user-sidebar-submenu-open] .surface-switcher-user .surface-switcher-link:hover {
        transform: none !important;
    }

    [data-user-sidebar-root][data-user-sidebar-submenu-open] .surface-switcher-user .surface-switcher-label {
        opacity: 0 !important;
        pointer-events: none;
    }

    html[data-user-sidebar-state="collapsed"] body[class*="user-body-"] [data-user-sidebar-root] .user-sidebar-toggle,
    body.user-sidebar-collapsed [data-user-sidebar-root] .user-sidebar-toggle {
        position: static;
        z-index: 3;
        margin: 0;
    }

    html[data-user-sidebar-state="collapsed"] body[class*="user-body-"] [data-user-sidebar-root] .user-sidebar-toggle-chevron,
    body.user-sidebar-collapsed [data-user-sidebar-root] .user-sidebar-toggle-chevron {
        transform: rotate(-45deg);
    }

    .user-sidebar-submenu:not([hidden]) {
        position: absolute;
        top: 0;
        left: calc(100% + 12px);
        z-index: 80;
        width: 168px;
        display: flex;
        flex-direction: column;
        gap: 7px;
        padding: 7px;
        border: 1px solid var(--zn-member-border-strong);
        border-radius: 18px;
        background: var(--zn-member-bg-app);
        box-shadow: var(--zn-member-shadow);
        backdrop-filter: none;
    }

    .user-sidebar-submenu-link {
        position: relative;
        box-sizing: border-box;
        display: grid;
        grid-template-columns: 20px minmax(0, 1fr);
        align-items: center;
        gap: 10px;
        width: 100%;
        height: 44px;
        padding: 0 11px;
        border: 1px solid transparent;
        border-radius: 13px;
        background: transparent;
        color: var(--zn-member-text-secondary);
        font: inherit;
        text-decoration: none;
        text-align: left;
        cursor: pointer;
        transition: transform 0.16s ease, background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
    }

    .user-sidebar-submenu-link:hover,
    .user-sidebar-submenu-link:focus-visible {
        border-color: var(--zn-member-border);
        background: var(--zn-member-bg-surface-hover);
        color: var(--zn-member-text-primary);
        transform: none;
    }

    .user-sidebar-submenu-link:focus-visible {
        outline: 2px solid var(--zn-member-accent-border-strong);
        outline-offset: 2px;
    }

    .user-sidebar-submenu-link.is-active {
        border-color: var(--zn-member-accent-border);
        background: var(--zn-member-accent-surface);
        color: var(--zn-member-accent-text);
    }

    .user-sidebar-submenu-link:disabled,
    .user-sidebar-submenu-link.is-disabled {
        cursor: not-allowed;
        opacity: 0.45;
    }

    .user-sidebar-submenu-link:disabled:hover,
    .user-sidebar-submenu-link.is-disabled:hover {
        border-color: transparent;
        background: transparent;
        color: var(--zn-member-text-secondary);
    }

    .user-sidebar-submenu-icon {
        width: 20px;
        height: 20px;
    }

    .user-sidebar-submenu-label {
        position: static;
        width: auto;
        max-width: none;
        padding: 0;
        overflow: hidden;
        border: 0;
        border-radius: 0;
        background: transparent;
        color: inherit;
        box-shadow: none;
        font-size: 0.78rem;
        font-weight: 700;
        line-height: 1.2;
        opacity: 1;
        transform: none;
        pointer-events: none;
        text-overflow: ellipsis;
        white-space: nowrap;
        transition: none;
    }

    .user-sidebar-submenu-link:hover .user-sidebar-submenu-label,
    .user-sidebar-submenu-link:focus-visible .user-sidebar-submenu-label {
        opacity: 1;
        transform: none;
    }

    .user-sidebar-submenu-link .feed-unread-badge {
        position: absolute;
        top: 50%;
        right: 8px;
        min-width: 18px;
        height: 18px;
        padding: 0 4px;
        font-size: 0.62rem;
        transform: translateY(-50%);
    }
}

html[data-user-sidebar-motion$="-layout"] body.user-body-messaging .chat-pane,
html[data-user-sidebar-motion$="-layout"] body.user-body-meetings .meeting-cockpit,
html[data-user-sidebar-motion$="-layout"] body.user-body-workspace .workspace-browser {
    animation: user-sidebar-main-settle 320ms cubic-bezier(0.4, 0, 0.2, 1) both;
}

html[data-user-sidebar-motion$="-layout"] [data-user-sidebar-root] > .conversation-hub > :not(.messages-home-header) {
    opacity: 0 !important;
    pointer-events: none !important;
}

html[data-user-sidebar-motion$="-reveal"] [data-user-sidebar-root] > .conversation-hub > :not(.messages-home-header) {
    animation: user-sidebar-content-reveal 140ms ease-out both;
}

@keyframes user-sidebar-main-settle {
    from {
        opacity: 0.76;
        translate: 14px 0;
    }

    to {
        opacity: 1;
        translate: 0 0;
    }
}

@keyframes user-sidebar-content-reveal {
    from {
        opacity: 0;
        translate: -4px 0;
    }

    to {
        opacity: 1;
        translate: 0 0;
    }
}

@media (max-width: 760px) {
    .user-sidebar-toggle,
    .user-sidebar-submenu,
    .user-sidebar-submenu-trigger-control {
        display: none !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    body.user-body-messaging .messaging-layout,
    body.user-body-meetings .meeting-layout,
    body.user-body-workspace .workspace-layout,
    html[data-user-sidebar-motion] body.user-body-messaging .chat-pane,
    html[data-user-sidebar-motion] body.user-body-meetings .meeting-cockpit,
    html[data-user-sidebar-motion] body.user-body-workspace .workspace-browser,
    html[data-user-sidebar-motion] [data-user-sidebar-root] > .conversation-hub > :not(.messages-home-header) {
        animation: none !important;
        transition: none !important;
    }

    .user-sidebar-toggle,
    .user-sidebar-toggle-chevron,
    .user-sidebar-submenu-link,
    .user-sidebar-submenu-label,
    [data-user-sidebar-root] .surface-switcher-link,
    [data-user-sidebar-root] .topbar-title-mark,
    [data-user-sidebar-root] > .conversation-hub {
        transition: none !important;
    }
}
