/* Mobile home declutter (≤768px). Desktop unchanged. */
@media (max-width: 768px) {
  /* —— Phase 1: chrome —— */
  .beta-banner {
    display: none !important;
  }

  .beta-banner-fab {
    display: flex !important;
  }

  .site-header .nav {
    display: none !important;
  }

  .hero-content > h1,
  .hero-content > p {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
  }

  /* —— Phase 2: compact header —— */
  .header-inner {
    flex-direction: row !important;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: 52px;
  }

  /* Лого слева, город и тема — справа (дети шапки через display:contents) */
  body:not(.page-profile) .header-inner .header-logo-region {
    display: contents;
  }

  .logo {
    order: 1;
    justify-content: flex-start;
    flex: 0 0 auto;
    width: auto;
    min-width: max-content;
    max-width: none;
    margin-right: auto;
  }

  .logo img {
    height: 38px !important;
    width: auto !important;
    max-width: 120px;
    object-fit: contain;
  }

  .logo-text {
    font-size: 22px !important;
    letter-spacing: -0.03em;
    line-height: 1;
    font-stretch: normal;
  }

  .header-region {
    order: 2;
    flex: 0 1 auto;
    width: auto;
    max-width: max-content;
    min-width: 0;
    margin: 0;
    padding: 7px 12px;
    border-radius: 999px;
    background: #ffffff;
    border: 1px solid #e6e8ef;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
    color: #1a1a1a;
    gap: 6px;
    overflow: hidden;
  }

  [data-theme="dark"] .header-region {
    background: var(--theme-surface, #111827);
    border-color: rgba(255, 255, 255, 0.14);
    box-shadow: none;
    color: var(--theme-header-text, #e5e7eb);
  }

  .header-region__icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: #2f5eff;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .header-region__label {
    font-size: 14px;
    font-weight: 600;
    min-width: 0;
    max-width: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .actions {
    order: 3;
    width: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    justify-content: flex-end;
    gap: 6px;
    flex-shrink: 0;
  }

  .actions .header-add-ad-btn,
  .actions > a.btn.ghost {
    display: none !important;
  }

  .actions .theme-toggle {
    width: 36px;
    height: 36px;
    margin-right: 0;
    flex-shrink: 0;
  }

  /* Вход есть во вкладке «Профиль». На экранах без таббара кнопку оставляем. */
  body.page-auth .actions > a.btn.ghost,
  body.post-ad-landing-page .actions > a.btn.ghost {
    display: inline-flex !important;
    padding: 8px 12px;
    font-size: 13px;
  }

  /* Профиль уже в нижнем таббаре */
  .user-menu {
    display: none !important;
  }

  body.page-auth .user-menu,
  body.page-ad-create .user-menu,
  body.page-ad-preview .user-menu,
  body.page-chat-mobile-clean .user-menu,
  body.post-ad-landing-page .user-menu,
  body.banner-preview-mode .user-menu {
    display: block !important;
  }

  /* Profile pages keep their own header grid */
  body.page-profile .site-header .header-inner {
    display: grid;
  }

  /* —— Phase 2: single search —— */
  .hero {
    padding: 8px 0 0;
  }

  .modern-searchbar--hero-tight .modern-searchbar__inner {
    flex-direction: row !important;
    align-items: stretch;
    border-radius: 14px;
    overflow: hidden;
  }

  .modern-searchbar--hero-tight .modern-searchbar__control--category,
  .modern-searchbar--hero-tight .modern-searchbar__control--region {
    display: none !important;
  }

  /* Фильтр в строке поиска открывает тот же список, но родитель скрыт — иначе видна только серая подложка. */
  .modern-searchbar--hero-tight .modern-searchbar__control--category:has(.modern-searchbar__dropdown.active) {
    display: block !important;
    position: absolute;
    width: 0;
    height: 0;
    margin: 0;
    padding: 0;
    overflow: visible;
    border: 0;
  }

  .modern-searchbar--hero-tight .modern-searchbar__control--category .modern-searchbar__select {
    display: none !important;
  }

  .dropdown-overlay.active {
    z-index: 1200;
  }

  .modern-searchbar__dropdown.active {
    z-index: 1201;
  }

  .modern-searchbar--hero-tight .modern-searchbar__control--query {
    flex: 1 1 auto;
    min-width: 0;
    border: none;
  }

  .modern-searchbar--hero-tight .modern-searchbar__input {
    padding: 12px 12px 12px 40px;
    font-size: 15px;
  }

  .modern-searchbar--hero-tight .modern-searchbar__icon {
    left: 14px;
    font-size: 14px;
  }

  .modern-searchbar__filter {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 44px;
    flex: 0 0 44px;
    border: none;
    border-left: 1px solid #e6e8ef;
    background: #fff;
    color: #64748b;
    cursor: pointer;
    padding: 0;
  }

  .modern-searchbar__filter:hover,
  .modern-searchbar__filter:focus-visible {
    color: #2f5eff;
    outline: none;
  }

  .modern-searchbar__filter svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .modern-searchbar--hero-tight .modern-searchbar__submit {
    width: 48px;
    flex: 0 0 48px;
    padding: 0 !important;
    border-radius: 0 !important;
    justify-content: center;
    background: #2f5eff;
  }

  .modern-searchbar--hero-tight .modern-searchbar__submit span {
    display: none;
  }

  .modern-searchbar--hero-tight .modern-searchbar__submit i {
    margin: 0;
    font-size: 15px;
  }

  .hero-searchbar-first-row {
    flex-wrap: wrap;
    row-gap: 10px;
  }

  .hero-content p.hero-search-meta {
    display: block !important;
    width: 100%;
    flex: 0 0 100%;
    align-self: flex-start;
    text-align: left !important;
    margin: 0 !important;
    padding: 0;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.3;
    color: #8b95a7;
    font-family: var(--theme-font-family, "Inter", "Segoe UI", sans-serif);
  }

  /* —— Phase 3: hide hero cards, CTA —— */
  .hero-side,
  .hero-searchbar-band__rail,
  .hero-card--auth-inline {
    display: none !important;
  }

  .home-mobile-sell-cta {
    display: flex !important;
    box-sizing: border-box;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: auto;
    margin: 12px max(16px, env(safe-area-inset-left, 0px), env(safe-area-inset-right, 0px)) 8px !important;
    padding: 12px 12px 12px 16px !important;
    border-radius: 16px !important;
    background: #2f5eff !important;
    color: #fff !important;
    text-decoration: none;
    font-family: var(--theme-font-family, "Inter", "Segoe UI", sans-serif);
  }

  .home-mobile-sell-cta__copy {
    display: flex;
    flex-direction: column;
    min-width: 0;
  }

  .home-mobile-sell-cta__title {
    font-size: 16px;
    font-weight: 500;
    line-height: 1.2;
    color: #fff;
  }

  .home-mobile-sell-cta__note {
    margin-top: 4px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.2;
    color: rgba(255, 255, 255, 0.82);
  }

  .home-mobile-sell-cta__btn {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    height: 44px;
    padding: 0 16px;
    border-radius: 14px;
    background: #fff;
    color: #2f5eff !important;
    font-size: 15px;
    font-weight: 500;
    line-height: 1.2;
    white-space: nowrap;
  }

  .section--categories {
    padding: 12px 0 4px !important;
  }

  .section--categories .section-header,
  .section--categories .categories-all-link-row {
    display: none !important;
  }

  .categories-grid.main-categories {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    gap: 12px 8px !important;
  }

  .categories-grid.main-categories .category-tile:not(.category-tile--mobile-pick):not(.category-tile--all) {
    display: none !important;
  }

  .category-tile--mobile-pick {
    order: var(--mobile-order);
  }

  .category-tile--all {
    display: flex !important;
    order: 8;
  }

  .section--categories .category-tile,
  .section--categories .category-card {
    min-height: 0 !important;
    height: auto;
    margin: 0;
    padding: 0 !important;
    background: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    overflow: visible !important;
    align-items: stretch !important;
    flex-direction: column;
    box-shadow: none !important;
    transform: none !important;
  }

  .section--categories .category-tile::after {
    display: none !important;
  }

  .section--categories .category-tile__media {
    position: relative !important;
    inset: auto !important;
    display: block;
    width: 100%;
    aspect-ratio: 1;
    border-radius: 16px;
    background-color: #fff;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
  }

  .section--categories .category-count-badge {
    display: none !important;
  }

  .section--categories .category-tile-content {
    position: static !important;
    width: 100%;
    padding: 6px 0 0 !important;
    text-align: center;
    min-height: 32px;
  }

  .section--categories .category-title {
    display: -webkit-box;
    width: 100%;
    max-width: 100%;
    color: #374151 !important;
    font-size: 11px !important;
    font-weight: 500 !important;
    letter-spacing: -0.02em;
    text-align: center;
    line-height: 1.2;
    white-space: normal;
    overflow: hidden;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }

  .section--categories .category-tile--mobile-pick .category-tile__media {
    background-size: 168% !important;
    background-position: 62% center !important;
  }

  .category-tile--all .category-tile__media {
    display: flex !important;
    align-items: center;
    justify-content: center;
    background: transparent !important;
    background-image: none !important;
    box-shadow: none;
  }

  .category-tile--all .category-tile__media::before {
    content: "";
    position: absolute;
    inset: 9%;
    border-radius: 14px;
    background: #2f5eff;
  }

  .category-tile--all svg {
    position: relative;
    z-index: 1;
    width: 40px;
    height: 40px;
    stroke: #fff;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .section--infinite-home .section-header h2 {
    font-size: 18px;
  }

  .home-after-hero .section-header,
  .home-after-hero .rec-head {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    flex-wrap: nowrap;
    gap: 12px;
  }

  .home-after-hero .section-header h2,
  .home-after-hero .rec-head h2 {
    min-width: 0;
  }

  .home-after-hero .section-header .link,
  .home-after-hero .rec-head .link {
    margin-left: auto;
    flex: 0 0 auto;
    font-family: "Inter", "Segoe UI", sans-serif;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.2;
    color: #2f5eff;
    text-decoration: none;
  }

  /* Soften premium/shops before city feed visually on small screens:
     keep order; CTA sits before categories via markup */

  /* Узкий экран: слово «Авада» и «Выбрать регион» оба остаются целиком */
  @media (max-width: 360px) {
    .logo img {
      height: 30px !important;
    }

    .logo-text {
      font-size: 18px !important;
    }

    .header-inner {
      gap: 6px;
    }

    .header-region {
      padding: 6px 8px;
      gap: 4px;
    }

    .header-region__label {
      font-size: 13px;
    }

    .actions .theme-toggle {
      width: 32px;
      height: 32px;
    }
  }
}

/* Desktop: hide mobile-only chrome */
.beta-banner-fab,
.modern-searchbar__filter,
.hero-search-meta,
.home-mobile-sell-cta {
  display: none;
}

.home-mobile-sell-cta:active {
  opacity: 0.95;
}

/* —— Beta FAB (mobile report entry) —— */
.beta-banner-fab {
  position: fixed;
  right: 14px;
  bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  z-index: 900;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  align-items: center;
  justify-content: center;
  background: #2f5eff;
  color: #fff;
  box-shadow: 0 8px 20px rgba(47, 94, 255, 0.35);
  cursor: pointer;
}

.beta-banner-fab svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

body.page-auth .beta-banner-fab,
body.page-ad-create .beta-banner-fab,
body.page-ad-preview .beta-banner-fab,
body.page-chat-mobile-clean .beta-banner-fab,
body.page-profile-chat-list .beta-banner-fab {
  display: none !important;
}

body.has-mobile-tabbar .beta-banner-fab {
  width: 56px;
  height: 56px;
  bottom: calc(76px + env(safe-area-inset-bottom, 0px));
  right: calc(12px + env(safe-area-inset-right, 0px));
  z-index: 1300;
}

body.has-mobile-tabbar .beta-banner-fab svg {
  width: 24px;
  height: 24px;
}

@media (max-width: 768px) {
  body.has-mobile-tabbar #chat-widget,
  body.has-mobile-tabbar .chat-widget {
    bottom: calc(76px + env(safe-area-inset-bottom, 0px)) !important;
  }
}
