.mobile-bottom-nav {
    display: none;
}

:where(.mobile-bottom-nav, .page-profile) .mobile-profile-avatar {
    --avatar-size: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    overflow: hidden;
    border-radius: 50%;
    background: var(--bg-3);
    color: var(--text-1);
    font-size: var(--fs-14);
    font-weight: var(--fw-bold);
}

:where(.mobile-bottom-nav, .page-profile) .mobile-profile-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.profile-language:where(.page-profile, .page-profile *) {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 20px;
}

.profile-language__label:where(.page-profile, .page-profile *) {
    font-size: var(--fs-16);
    white-space: nowrap;
}

.mobile-profile-card:where(.page-profile, .page-profile *) {
    padding: 28px 16px;
    text-align: center;
}

.mobile-profile-card > .mobile-profile-avatar:where(.page-profile, .page-profile *) {
    --avatar-size: 88px;
    width: 88px;
    height: 88px;
    font-size: var(--fs-32);
}

.mobile-profile-card h2:where(.page-profile, .page-profile *) {
    margin: 16px 0 6px;
    font-size: var(--fs-24);
}

.mobile-profile-card p:where(.page-profile, .page-profile *) {
    margin: 0;
    color: var(--text-3);
    font-size: var(--fs-14);
}

.mobile-profile-links:where(.page-profile, .page-profile *) {
    max-width: 520px;
    margin: 8px auto;
    overflow: hidden;
    border: 1px solid var(--border-1);
    border-radius: var(--radius-l);
    background: var(--surface);
}

.mobile-profile-links > :is(a, .nav-item):where(.page-profile, .page-profile *) {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    margin: 0;
    padding: 20px;
    border: 0;
    border-radius: 0;
    background: var(--surface);
    color: var(--text-1);
    font: inherit;
    font-size: var(--fs-14);
    text-align: left;
    text-decoration: none;
}

.mobile-profile-links .profile-link__icon:where(.page-profile, .page-profile *) {
    flex: none;
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
    color: var(--text-2);
}

.mobile-profile-links .profile-link__label:where(.page-profile, .page-profile *) {
    flex: 1;
    min-width: 0;
    color: var(--text-1);
    font-weight: inherit;
}

.mobile-profile-links:not(.profile-language) > * + *:where(.page-profile, .page-profile *) {
    border-top: 1px solid var(--border-1);
}

.mobile-profile-links span:where(.page-profile, .page-profile *) {
    color: var(--text-3);
}

.mobile-profile-links > *:hover:where(.page-profile, .page-profile *) {
    background: var(--bg-3);
}

.profile-sign-out > .nav-item:where(.page-profile, .page-profile *),
.profile-sign-out .profile-link__icon:where(.page-profile, .page-profile *),
.profile-sign-out .profile-link__label:where(.page-profile, .page-profile *) {
    color: var(--danger);
}

.profile-sign-out > .nav-item:disabled:where(.page-profile, .page-profile *) {
    opacity: .6;
    cursor: progress;
}

@media (max-width: 768px) {
    :root {
        --mobile-nav-height: calc(60px + env(safe-area-inset-bottom, 0px));
    }

    .mobile-bottom-nav {
        position: fixed;
        inset: auto 12px max(0px, calc(max(8px, env(safe-area-inset-bottom, 0px)) - 10px));
        z-index: 35;
        display: grid;
        grid-auto-columns: minmax(0, 1fr);
        grid-auto-flow: column;
        box-sizing: border-box;
        height: 54px;
        padding: 0 2px;
        border: 0;
        border-radius: var(--radius-full);
    }

    .mobile-bottom-nav .mobile-nav-item {
        position: relative;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 0;
        min-width: 0;
        margin: 0;
        padding: 0;
        border: 0;
        border-radius: var(--radius-m);
        background: none;
        color: var(--text-1);
        font: var(--fw-medium) var(--fs-12)/var(--lh-tight) var(--font-sans);
        text-decoration: none;
        opacity: 1;
        cursor: pointer;
    }

    .mobile-bottom-nav .mobile-nav-item svg {
        flex-shrink: 0;
        width: 26px;
        height: 26px;
        stroke-width: 1.7;
    }

    .mobile-bottom-nav .mobile-nav-item.active {
        color: var(--text-1);
    }

    .mobile-bottom-nav .mobile-nav-item.active svg {
        fill: currentColor;
    }

    .mobile-bottom-nav [data-section="chats"].active svg g {
        fill: var(--bg-1);
    }

    .mobile-bottom-nav .mobile-nav-item.active .mobile-profile-avatar {
        outline: 2px solid var(--text-1);
        outline-offset: 2px;
    }

    /* Число раздела (app-host.js onBadge → data-badge), как у свёрнутой боковой панели. */
    .mobile-bottom-nav .mobile-nav-item.has-badge::after {
        content: attr(data-badge);
        position: absolute;
        top: 2px;
        left: calc(50% + 4px);
        min-width: 14px;
        height: 16px;
        padding: 0 3px;
        border: 2px solid var(--bg-2);
        border-radius: var(--radius-full);
        background: var(--accent);
        color: var(--text-inverse);
        font-size: var(--fs-12);
        font-weight: var(--fw-bold);
        line-height: 16px;
        text-align: center;
        box-sizing: content-box;
    }

    .mobile-bottom-nav .mobile-nav-item:focus-visible {
        outline: 2px solid var(--focus);
        outline-offset: -2px;
    }

    .mobile-bottom-nav .mobile-profile-avatar {
        --avatar-size: 28px;
        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-1);
        border-radius: 50%;
        background: var(--presence-offline);
        pointer-events: none;
    }

    body:has(.connection-status.online) .mobile-bottom-nav .mobile-connection-dot {
        background: var(--presence-online);
    }

    body:has(.mobile-bottom-nav) .mobile-shell-bar:where(.app-shell, .app-shell *),
    :is(.main > .topbar, .main > .home-container > .topbar):where(.app-shell, .app-shell *) {
        display: none;
    }

    body.mobile-profile-mode .mobile-shell-bar:where(.app-shell, .app-shell *) {
        position: fixed;
        top: env(safe-area-inset-top, 0px);
        right: 12px;
        left: auto;
        z-index: 81;
        display: flex;
        width: 44px;
        height: 48px;
        min-height: 48px;
        border: 0;
        background: transparent;
        pointer-events: none;
    }

    body.mobile-profile-mode .mobile-shell-bar .app-burger:where(.app-shell, .app-shell *) {
        display: flex;
        pointer-events: auto;
        transform: scaleX(-1);
    }

    .mobile-profile-mode .mobile-shell-bar strong:where(.app-shell, .app-shell *) {
        display: none;
    }

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

    body.mobile-profile-mode .app-sidebar .app-sidebar__head {
        display: none;
    }

    .mobile-profile-card:where(.page-profile, .page-profile *) {
        padding: 24px 16px 28px;
    }

    body.chat-open:has(.page-chat:not([hidden])),
    body.support-open:has(.page-support:not([hidden])) {
        --mobile-nav-height: 0px;
    }

    body.chat-open:has(.page-chat:not([hidden])) .mobile-bottom-nav,
    body.support-open:has(.page-support:not([hidden])) .mobile-bottom-nav,
    html[data-keyboard-open] .mobile-bottom-nav {
        display: none;
    }

    .app-shell :is(.inbox, .support-list, .page-contacts, .page-profile) {
        padding-bottom: var(--mobile-nav-height);
        scroll-padding-bottom: var(--mobile-nav-height);
    }
}
