@media (max-width: 800px) {
  /* Keep both calls to action comfortably tappable without filling the row. */
  body .am-home-feed-panel > h2 { align-items: center; flex-wrap: wrap; gap: 8px; }
  body .am-home-feed-add {
    display: inline-flex !important;
    width: auto !important;
    max-width: 100% !important;
    min-height: 44px;
    padding: 8px 14px;
    font-size: 14px;
    flex: 0 1 auto;
  }

  /* Give the selected settlement the first, full row of the header. */
  #ama-app .ama-geo-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start !important;
    padding-left: min(138px, 36vw) !important;
    padding-right: 12px;
    gap: 3px 8px;
  }
  #ama-app .ama-geo-header > .ama-geo {
    order: -1;
    flex: 1 1 100%;
    min-width: 0;
    max-width: 100%;
  }
  #ama-app .ama-geo-header > .ama-geo > summary {
    width: fit-content;
    max-width: 100%;
    height: auto;
    min-height: 44px;
  }
  #ama-app .ama-geo-header > .ama-geo > summary span {
    min-width: 0;
    max-width: none;
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
    overflow-wrap: anywhere;
    text-align: left;
  }
  #ama-app .ama-geo-header > .am-home-account-group {
    order: 1;
    flex: 1 1 100%;
    max-width: 100%;
    margin-left: 0;
  }
  /* The bottom cabinet tab is the mobile entry point. */
  #ama-app .ama-geo-header .am-home-account-group a[href$="/edinyy-kabinet/"],
  #ama-app .ama-geo-header > a[href$="/edinyy-kabinet/"] {
    display: none !important;
  }

  /* Better Messages 2.x uses a fixed full-screen panel; keep its composer
     above the Android gesture bar and the site's mobile navigation. */
  body.bp-messages-mobile .bp-messages-wrap-main,
  body.bp-messages-mobile .bp-messages-wrap,
  body:has(.ama-bottom-nav) .bp-messages-wrap-main.bm-initialized {
    bottom: calc(64px + env(safe-area-inset-bottom, 0px)) !important;
  }
  body:has(.ama-bottom-nav) .bp-messages-wrap-main.bm-initialized .bp-messages-wrap {
    min-height: 0 !important;
  }

  html.ama-mobile-ready .ama-bottom-nav,
  html:not(.ama-mobile-ready) .ama-bottom-nav {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  }
  .ama-bottom-nav > a.ama-ai-bottom {
    display: flex !important;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-width: 0;
    padding: 6px 2px 4px;
    color: inherit;
    text-align: center;
    text-decoration: none;
  }
  .ama-bottom-nav > a.ama-ai-bottom svg { width: 22px; height: 22px; }
  .ama-bottom-nav > a.ama-ai-bottom span { font-size: 11px; line-height: 1.1; }
}

/* Mobile header: messages and logout remain in their dedicated navigation. */
@media(max-width:800px){
 html.ama-mobile-ready .ama-geo-header .am-home-account-group>.ama-top-messages,
 html.ama-mobile-ready .ama-geo-header>.ama-header-logout{display:none!important}
}
