.mobile-bottom-nav {
    display: none;
}
:where(.mobile-bottom-nav, #profile-section) .mobile-profile-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--brand-soft);
    color: var(--brand-strong);
    font-size: 13px;
    font-weight: 600;
    overflow: hidden;
}
:where(.mobile-bottom-nav, #profile-section) .mobile-profile-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}
.profile-language:where(#profile-section, #profile-section *) {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 20px;
}
.profile-language__label:where(#profile-section, #profile-section *) {
    font-size: 15px;
    white-space: nowrap;
}
.mobile-profile-card:where(#profile-section, #profile-section *) {
    text-align: center;
    padding: 28px 16px;
}
.mobile-profile-card > .mobile-profile-avatar:where(#profile-section, #profile-section *) {
    width: 88px;
    height: 88px;
    font-size: 32px;
}
.mobile-profile-card h2:where(#profile-section, #profile-section *) {
    margin: 16px 0 6px;
    font-size: 22px;
}
.mobile-profile-card p:where(#profile-section, #profile-section *) {
    color: var(--text-3);
    margin: 0;
    font-size: 14px;
}
.mobile-profile-links:where(#profile-section, #profile-section *) {
    max-width: 520px;
    margin: 8px auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
}
.mobile-profile-links > a:where(#profile-section, #profile-section *), .mobile-profile-links > .nav-item:where(#profile-section, #profile-section *) {
    box-sizing: border-box;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    padding: 20px;
    margin: 0;
    border: 0;
    border-radius: 0;
    background: var(--surface);
    color: var(--text);
    text-decoration: none;
    font: inherit;
    font-size: 14px;
    text-align: left;
}
.mobile-profile-links:not(.profile-language) > * + *:where(#profile-section, #profile-section *) {
    border-top: 1px solid var(--border);
}
.mobile-profile-links span:where(#profile-section, #profile-section *) {
    color: var(--text-3);
}
.mobile-profile-links > *:hover:where(#profile-section, #profile-section *) {
    background: var(--surface-2);
}
.app-sidebar .primary-nav-item:disabled {
    opacity: 1;
    cursor: default;
    color: var(--text-3);
}
@media (max-width: 768px) {
    :root {
        --mobile-nav-height: calc(70px + env(safe-area-inset-bottom, 0px));
    }
    .workspace.app-shell {
        height: 100dvh;
    }
    .mobile-bottom-nav {
        position: fixed;
        inset: auto 12px max(8px, env(safe-area-inset-bottom, 0px));
        z-index: 35;
        display: grid;
        grid-auto-flow: column;
        grid-auto-columns: minmax(0, 1fr);
        box-sizing: border-box;
        height: 54px;
        padding: 0 2px;
        border-radius: 28px;
        border: 0;
    }
    .mobile-bottom-nav .mobile-nav-item {
        position: relative;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: 0;
        min-width: 0;
        margin: 0;
        padding: 0;
        border: 0;
        border-radius: 8px;
        background: none;
        color: var(--text);
        text-decoration: none;
        font: 500 10px/1.2 system-ui;
        cursor: pointer;
        opacity: 1;
    }
    .mobile-bottom-nav .mobile-nav-item svg {
        width: 26px;
        height: 26px;
        flex-shrink: 0;
        stroke-width: 1.7;
    }
    .mobile-bottom-nav .mobile-nav-item.active {
        color: var(--text);
    }
    .mobile-bottom-nav .mobile-nav-item.active svg {
        fill: currentColor;
    }
    .mobile-bottom-nav [data-section="chats"].active svg g {
        fill: var(--bg);
    }
    .mobile-bottom-nav .mobile-nav-item.active .mobile-profile-avatar {
        outline: 2px solid var(--text);
        outline-offset: 2px;
    }
    .mobile-bottom-nav .mobile-nav-item:focus-visible {
        outline: 2px solid var(--focus);
        outline-offset: -2px;
    }
    .mobile-bottom-nav .mobile-nav-future {
        cursor: default;
    }
    .mobile-bottom-nav .mobile-profile-avatar {
        position: relative;
        width: 28px;
        height: 28px;
        overflow: visible;
    }
    .mobile-bottom-nav .mobile-connection-dot {
        position: absolute;
        right: -2px;
        bottom: -2px;
        width: 11px;
        height: 11px;
        border: 2px solid var(--bg);
        border-radius: 50%;
        background: var(--presence-offline);
        pointer-events: none;
    }
    body:has(#connection.online) .mobile-bottom-nav .mobile-connection-dot {
        background: var(--presence-online);
    }
    /* The bottom bar replaces the top bar; guests on standalone pages have no bottom bar and keep the burger. */
    body:has(.mobile-bottom-nav) .mobile-shell-bar:where(.app-shell, .app-shell *), .main > .topbar:where(.app-shell, .app-shell *), .main > .home-container > .topbar:where(.app-shell, .app-shell *) {
        display: none;
    }
    /* Profile keeps only the burger, floating over the profile card instead of taking a strip. */
    body.mobile-profile-mode .mobile-shell-bar:where(.app-shell, .app-shell *) {
        display: flex;
        position: fixed;
        top: env(safe-area-inset-top, 0px);
        left: auto;
        right: 12px;
        width: 44px;
        height: 48px;
        min-height: 48px;
        z-index: 81;
        border: 0;
        background: transparent;
        pointer-events: none;
    }
    body.mobile-profile-mode .mobile-shell-bar .app-burger:where(.app-shell, .app-shell *) {
        transform: scaleX(-1);
        pointer-events: auto;
    }
    .mobile-profile-mode .mobile-shell-bar .app-burger:where(.app-shell, .app-shell *) {
        display: flex;
    }
    .mobile-profile-mode .mobile-shell-bar strong:where(.app-shell, .app-shell *) {
        display: none;
    }
    .app-sidebar.sidebar {
        top: 0;
        bottom: 0;
        right: auto;
        width: min(310px, 85vw);
        height: 100dvh;
        max-height: 100dvh;
        padding: 24px 16px;
        transform: translateX(-105%);
        border-right: 1px solid var(--border);
        border-bottom: 0;
        box-shadow: 8px 0 32px var(--shadow-color);
        z-index: 60;
    }
    .app-shell--mobile-open .app-sidebar.sidebar {
        transform: translateX(0);
    }
    .app-shell--mobile-open:where(.app-shell, .app-shell *)::before {
        content: "";
        position: fixed;
        inset: 0;
        background: var(--overlay);
        z-index: 55;
    }
    .mobile-profile-card:where(#profile-section, #profile-section *) {
        padding: 24px 16px 28px;
    }
}
@media (prefers-reduced-motion: reduce) {
    .app-sidebar.sidebar {
        transition: none;
    }
}

@media (max-width: 768px) {
    body.chat-open:has(#chat-section:not([hidden])),
    body.support-open:has(#support-section:not([hidden])) {
        --mobile-nav-height: 0px;
    }
    body.chat-open:has(#chat-section:not([hidden])) .mobile-bottom-nav,
    body.support-open:has(#support-section:not([hidden])) .mobile-bottom-nav {
        display: none;
    }
}

@media (max-width: 768px) {
    #inbox:where(.app-shell, .app-shell *), #contacts-section:where(.app-shell, .app-shell *), #profile-section:where(.app-shell, .app-shell *), #support-list:where(.app-shell, .app-shell *) {
        padding-bottom: var(--mobile-nav-height);
        scroll-padding-bottom: var(--mobile-nav-height);
    }
}

@media (max-width: 768px) {
    body.mobile-profile-mode .app-sidebar.sidebar {
        left: 0;
        right: 0;
        top: calc(48px + env(safe-area-inset-top, 0px));
        width: 100%;
        max-width: none;
        height: calc(100dvh - 48px - env(safe-area-inset-top, 0px));
        border: 0;
        overflow-y: auto;
        z-index: 80;
    }
    body.mobile-profile-mode .app-sidebar .app-sidebar__head { display: none; }
}
