.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;
        padding: 0;
        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: none;
    }

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

    body.mobile-profile-mode .app-sidebar.sidebar {
        top: 0;
        right: 0;
        left: 0;
        z-index: 80;
        width: 100%;
        max-width: none;
        height: 100dvh;
        overflow-y: auto;
        border: 0;
    }

    body.mobile-profile-mode .app-sidebar.sidebar.section-menu--open,
    .app-shell .app-sidebar.sidebar.section-menu--open {
        z-index: 1000;
        padding: calc(8px + env(safe-area-inset-top, 0px)) 16px 12px;
    }

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

    .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);
    }
}

.section-topbar,
.section-burger,
.section-menu-cross,
.section-menu__head {
    display: none;
}

@media (max-width: 768px) {
    .section-topbar {
        position: static;
        display: flex;
        align-items: center;
        gap: 8px;
        box-sizing: border-box;
        width: 100%;
        min-height: var(--section-bar-height);
        padding: 0 12px;
        border: 0;
        border-radius: 0;
        background: transparent;
        color: var(--text-1);
    }

    .section-topbar .section-topbar__main {
        display: flex;
        flex: 1 1 auto;
        align-items: center;
        gap: 8px;
        min-width: 0;
    }

    .section-topbar .section-topbar__corner {
        display: flex;
        flex: none;
        align-items: center;
        justify-content: flex-end;
        min-width: var(--section-bar-corner);
        height: var(--section-bar-height);
    }

    .section-topbar .section-topbar__action {
        display: inline-flex;
        flex: none;
        align-items: center;
        justify-content: center;
        width: var(--section-bar-corner);
        height: var(--section-bar-corner);
        margin: 0;
        padding: 0;
        border: 0;
        border-radius: var(--radius-m);
        background: transparent;
        color: var(--text-1);
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }

    .section-topbar .section-topbar__action:disabled {
        color: var(--text-3);
        cursor: default;
    }

    .section-topbar .section-topbar__action:focus:not(:focus-visible) {
        outline: none;
    }

    .section-topbar .section-topbar__action:focus-visible {
        outline: 2px solid var(--focus);
        outline-offset: -2px;
    }

    @media (hover: hover) {
        .section-topbar .section-topbar__action:hover:not(:disabled) {
            background: var(--bg-3);
        }
    }

    .section-topbar .section-topbar__title {
        flex: 1 1 auto;
        min-width: 0;
        overflow: hidden;
        margin: 0;
        color: var(--text-1);
        font-size: var(--fs-16);
        font-weight: var(--fw-bold);
        line-height: var(--lh-tight);
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .section-topbar.section-topbar--row {
        min-height: 0;
        padding: var(--section-bar-gap) var(--section-gutter) 0;
        background: var(--bg-2);
    }

    .section-topbar.section-topbar--row .section-topbar__corner {
        height: auto;
        min-width: 0;
        margin-inline-end: -10px;
    }

    .section-topbar.section-topbar--row .section-topbar__action,
    .section-topbar.section-topbar--row .section-burger {
        height: var(--control-height);
    }

    .section-burger,
    .section-menu-cross {
        display: flex;
        flex-direction: column;
        flex-shrink: 0;
        align-items: flex-end;
        justify-content: space-between;
        box-sizing: border-box;
        width: var(--section-bar-corner);
        height: var(--section-bar-corner);
        margin: auto 0;
        padding: 12px 10px;
        border: 0;
        border-radius: var(--radius-m);
        background: transparent;
        color: var(--text-1);
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }

    .section-burger span,
    .section-menu-cross span {
        display: block;
        height: 2px;
        border-radius: var(--radius-s);
        background: currentColor;
        transition: none;
    }

    .section-burger span:nth-child(1) { width: 70%; }
    .section-burger span:nth-child(2) { width: 100%; }
    .section-burger span:nth-child(3) { width: 45%; }

    .section-burger:focus:not(:focus-visible),
    .section-menu-cross:focus:not(:focus-visible) {
        outline: none;
    }

    .section-burger:focus-visible,
    .section-menu-cross:focus-visible {
        outline: 2px solid var(--focus);
        outline-offset: -2px;
    }

    .section-menu-cross {
        position: fixed;
        z-index: 1001;
        padding: 0;
        align-items: center;
        justify-content: center;
    }

    .section-menu-cross span {
        position: absolute;
        width: 24px;
    }

    .section-menu-cross span:nth-child(1) { transform: rotate(45deg); }
    .section-menu-cross span:nth-child(2) { opacity: 0; }
    .section-menu-cross span:nth-child(3) { transform: rotate(-45deg); }

    .section-menu--open.section-menu--open {
        position: fixed;
        inset: 0;
        z-index: 1000;
        display: block;
        box-sizing: border-box;
        width: 100%;
        max-width: none;
        height: 100dvh;
        max-height: none;
        margin: 0;
        padding: calc(var(--section-bar-height) + env(safe-area-inset-top, 0px)) 16px calc(16px + env(safe-area-inset-bottom, 0px));
        overflow-y: auto;
        overscroll-behavior: contain;
        border: 0;
        border-radius: 0;
        background: var(--surface);
        box-shadow: none;
        visibility: visible;
        opacity: 1;
        pointer-events: auto;
        transform: none;
        transition: none;
        animation: none;
    }

    .section-menu--open .section-menu__head {
        display: flex;
        align-items: center;
        min-height: var(--section-bar-height);
        margin: calc(-1 * var(--section-bar-height) - env(safe-area-inset-top, 0px)) calc(var(--section-bar-corner) + 12px) 0 0;
        padding-top: env(safe-area-inset-top, 0px);
        color: var(--text-1);
        font-size: var(--fs-18);
        font-weight: var(--fw-bold);
    }

    html.section-menu-open,
    html.section-menu-open body {
        overflow: hidden;
    }

    html.section-menu-open .mobile-bottom-nav {
        display: none;
    }

    body:has(.page-sheet:not([hidden]) [data-bottom-nav="hidden"]) {
        --mobile-nav-height: 0px;
    }

    body:has(.page-sheet:not([hidden]) [data-bottom-nav="hidden"]) .mobile-bottom-nav {
        display: none;
    }
}

@media (max-width: 768px) {
    .mobile-bottom-nav {
        --nav-progress: 0;
        --nav-drop: min(var(--nav-scroll-drop-max), calc(max(0px, calc(max(8px, env(safe-area-inset-bottom, 0px)) - 10px)) + 3px));
        transform: translateY(calc(var(--nav-progress) * var(--nav-drop))) scale(calc(1 - var(--nav-scroll-scale) * var(--nav-progress)));
    }

    .mobile-bottom-nav .mobile-nav-item {
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        user-select: none;
        touch-action: manipulation;
    }
}
