/* Teaspot header */
.ts-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--color-header-bg, #FFFFFF);
  padding: var(--header-pad-y) 0;
}

.ts-container {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--container-pad);
}

.ts-header__row {
  display: flex;
  align-items: center;
  gap: var(--header-gap);
}

.ts-header__row--top {
  min-height: var(--ctrl-height);
  align-items: center;
  gap: var(--header-main-gap);
}

.ts-header__row--nav {
  display: flex;
  flex-wrap: nowrap;
  width: 100%;
  margin-top: var(--header-rows-gap);
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  max-height: 64px;
  opacity: 1;
  overflow: hidden;
  transition:
    max-height 0.28s ease,
    opacity 0.2s ease,
    margin-top 0.28s ease;
}

/* Скролл вниз: скрываем только второй ряд; верхний (лого/поиск/кнопки) остаётся */
.ts-header.is-nav-hidden .ts-header__row--nav {
  max-height: 0;
  margin-top: 0;
  opacity: 0;
  pointer-events: none;
}

.ts-nav-bar .ts-nav {
  flex: 1 1 auto;
  min-width: 0;
}

/* City — прижат к правому краю вровень с Войти */
.ts-city-wrap {
  flex: 0 0 auto;
  margin-left: auto;
  margin-right: 0;
}

.ts-city {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  margin-left: 0;
  margin-right: 0;
  color: var(--color-text);
  line-height: 1;
  white-space: nowrap;
}

.ts-city__label {
  font-size: var(--font-muted);
  font-weight: var(--font-muted-weight);
  color: var(--color-text-muted);
}

.ts-city__name {
  display: inline-flex;
  align-items: center;
}

.ts-city__name-inner {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--font-nav);
  font-weight: var(--font-nav-weight);
  text-decoration: none;
}

.ts-city__icon {
  width: 14px;
  height: 14px;
  object-fit: contain;
  flex-shrink: 0;
}

/* Brand / Logo */
.ts-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--color-text);
  flex-shrink: 0;
}

.ts-brand:hover,
.ts-brand:focus {
  text-decoration: none;
  color: var(--color-text);
  outline: none;
  box-shadow: none;
}

.ts-brand__logo {
  display: block;
  width: var(--logo-width);
  height: auto;
  max-height: 40px;
  object-fit: contain;
  object-position: left center;
}

.ts-brand__mark {
  display: block;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
}

.ts-brand__text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.ts-brand__title {
  font-size: var(--font-logo);
  font-weight: var(--font-logo-weight);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.ts-brand__tagline {
  font-size: var(--font-tagline);
  font-weight: var(--font-tagline-weight);
  color: var(--color-text-muted);
}

/* Buttons */
.ts-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: var(--ctrl-height);
  padding: 0 14px;
  border: 0;
  border-radius: var(--radius-btn);
  font-family: inherit;
  font-size: var(--font-btn);
  font-weight: var(--font-btn-weight);
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

/* Убираем чёрную Bootstrap-обводку при клике; клавиатурный фокус оставляем */
.ts-btn:focus,
.ts-btn:active,
a.ts-btn:focus,
a.ts-btn:active {
  outline: none;
  outline-offset: 0;
  box-shadow: none;
}

.ts-btn--catalog {
  background: var(--color-catalog);
  color: var(--color-catalog-text);
  flex-shrink: 0;
}

.ts-btn--catalog:hover,
.ts-btn--catalog:focus {
  color: var(--color-catalog-text);
  text-decoration: none;
  filter: brightness(1.05);
}

.ts-btn--secondary {
  background: var(--color-surface);
  color: var(--color-text);
}

.ts-btn--secondary:hover,
.ts-btn--secondary:focus {
  background: var(--color-surface-hover);
  color: var(--color-text);
  text-decoration: none;
}

.ts-btn__icon {
  width: 18px;
  height: 18px;
  display: block;
  flex-shrink: 0;
  object-fit: contain;
}

.ts-btn__icon--catalog {
  width: 11px;
  height: 11px;
}

.ts-btn--help .ts-btn__icon {
  width: var(--icon-help);
  height: var(--icon-help);
}

.ts-btn--wishlist .ts-btn__icon {
  width: var(--icon-wishlist);
  height: var(--icon-wishlist);
}

.ts-btn--cart .ts-btn__icon {
  width: var(--icon-cart);
  height: var(--icon-cart);
}

.ts-btn--account .ts-btn__icon {
  width: var(--icon-account);
  height: var(--icon-account);
}

.ts-btn__icon-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.ts-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  left: auto;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: var(--radius-badge);
  background: var(--color-badge);
  color: #fff;
  font-size: var(--font-badge);
  font-weight: var(--font-badge-weight);
  line-height: 16px;
  text-align: center;
  pointer-events: none;
  z-index: 1;
}

.ts-badge[hidden],
.ts-badge.ts-badge--empty[hidden] {
  display: none !important;
}

/* Search — max 465px, сужается если ряд не влезает в сетку; gap 43px не трогаем */
.ts-search {
  position: relative;
  flex: 1 1 auto;
  width: auto;
  max-width: var(--search-width);
  min-width: 200px;
  margin: 0;
  padding: 0;
  border: 0;
}

.ts-search__input {
  width: 100%;
  height: var(--ctrl-height);
  padding: 0 16px 0 44px;
  border: 0;
  border-radius: var(--radius-search);
  background: var(--color-surface);
  color: var(--color-text);
  font-family: inherit;
  font-size: var(--font-search);
  font-weight: var(--font-search-weight);
  outline: none;
  box-shadow: none;
  -webkit-appearance: none;
  appearance: none;
}

.ts-search__input:focus,
.ts-search__input:focus-visible,
.ts-search__input:active {
  outline: none;
  box-shadow: none;
  border: 0;
}

.ts-search.is-filled .ts-search__input {
  padding-right: 78px;
}

.ts-search__input::placeholder {
  color: var(--color-text-muted);
}

.ts-search__icon {
  position: absolute;
  top: 50%;
  left: 12px;
  right: auto;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  color: #000000;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.ts-search__icon svg {
  display: block;
  stroke: currentColor;
}

/* Крестик + поиск справа — только когда в поле есть текст */
.ts-search__actions {
  position: absolute;
  top: 50%;
  right: 5px;
  transform: translateY(-50%);
  display: none;
  align-items: center;
  gap: 2px;
  z-index: 2;
}

.ts-search.is-filled .ts-search__actions {
  display: inline-flex;
}

.ts-search__clear {
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-btn);
  background: transparent;
  color: var(--color-text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.ts-search__clear:hover {
  color: var(--color-text);
  background: var(--color-surface-hover);
}

.ts-search__go {
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: var(--color-catalog);
  color: var(--color-catalog-text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.ts-search__go:hover {
  filter: brightness(1.08);
}

.ts-search__go svg {
  display: block;
  stroke: currentColor;
}

/* Actions — правый край сетки; слева минимум 43px (gap ряда) */
.ts-actions {
  display: flex;
  align-items: center;
  gap: var(--header-gap);
  flex-shrink: 0;
  margin-left: auto;
}

.ts-brand,
.ts-btn--catalog {
  flex-shrink: 0;
}

/* Nav */
.ts-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 20px;
  min-width: 0;
}

.ts-nav__link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--color-text);
  font-size: var(--font-nav);
  font-weight: var(--font-nav-weight);
  text-decoration: none;
  transition: color 0.15s ease;
}

.ts-nav__link:hover,
.ts-nav__link:focus {
  color: var(--brand-primary);
  text-decoration: none;
}

.ts-nav__icon {
  width: 14px;
  height: 14px;
  object-fit: contain;
}

/* Hide legacy OpenCart top bar in teaspot */
.teaspot-theme #top {
  display: none !important;
}

.ts-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Desktop: бургер/drawer скрыты */
.ts-search-toggle,
.ts-burger {
  display: none;
}

.ts-drawer {
  display: none;
}

/* ========== Adaptive breakpoints ========== */

/* Laptop: secondary без текста, поиск тянется */
@media (max-width: 1280px) {
  .ts-header__row--top {
    gap: 24px;
  }

  .ts-search {
    flex: 1 1 auto;
    width: auto;
    max-width: var(--search-width);
    min-width: 160px;
  }

  .ts-btn--secondary span:not(.ts-badge):not(.ts-btn__icon-wrap):not(.ts-sr-only):not(.ts-btn__label) {
    display: none;
  }

  .ts-btn--secondary .ts-btn__label {
    display: none;
  }

  .ts-btn--secondary {
    padding: 0;
    width: var(--ctrl-height);
    min-width: var(--ctrl-height);
  }
}

/* Tablet: лого+кнопки / каталог+поиск */
@media (max-width: 992px) {
  .ts-container {
    padding-left: 20px;
    padding-right: 20px;
  }

  .ts-header__row--top {
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-areas:
      "brand actions"
      "catalog search";
    gap: 12px;
    align-items: center;
  }

  .ts-brand { grid-area: brand; }
  .ts-actions {
    grid-area: actions;
    margin-left: auto;
    justify-self: end;
  }
  .ts-btn--catalog { grid-area: catalog; }
  .ts-search {
    grid-area: search;
    flex: none;
    width: 100%;
    min-width: 0;
    max-width: none;
  }

  .ts-nav-bar {
    flex-wrap: wrap;
    gap: 12px 20px;
  }

  .ts-nav {
    gap: 8px 16px;
  }
}

/* Mobile: бургер + поиск-иконка; меню/город только в drawer */
@media (max-width: 768px) {
  .ts-header {
    padding: 12px 0;
  }

  .ts-container {
    padding-left: 16px;
    padding-right: 16px;
  }

  .ts-brand__logo {
    width: var(--logo-width-mobile);
    max-height: var(--logo-max-height-mobile);
  }

  .ts-header__row--top {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "brand actions"
      "catalog catalog";
    gap: 10px;
  }

  .ts-header.is-search-open .ts-header__row--top {
    grid-template-areas:
      "brand actions"
      "search search"
      "catalog catalog";
  }

  .ts-actions {
    gap: 8px;
  }

  .ts-btn--catalog {
    width: 100%;
    padding: 0 12px;
    overflow: hidden;
    max-height: var(--ctrl-height);
    opacity: 1;
    transition:
      max-height 0.28s ease,
      opacity 0.2s ease,
      margin-top 0.28s ease,
      padding 0.28s ease,
      height 0.28s ease;
  }

  /*
   * Скролл вниз: схлопываем только высоту «Каталог».
   * Сетку (grid-areas / gap) НЕ меняем — иначе кнопка уходит в auto-placement.
   */
  .ts-header.is-nav-hidden .ts-btn--catalog {
    max-height: 0;
    min-height: 0;
    height: 0;
    opacity: 0;
    padding-top: 0;
    padding-bottom: 0;
    margin-top: -10px;
    border: 0;
    overflow: hidden;
    pointer-events: none;
    visibility: hidden;
    transition:
      max-height 0.28s ease,
      opacity 0.2s ease,
      margin-top 0.28s ease,
      padding 0.28s ease,
      height 0.28s ease,
      visibility 0s linear 0.28s;
  }

  .ts-search-toggle {
    display: inline-flex;
  }

  .ts-search {
    display: none;
    grid-area: search;
    width: 100%;
    max-width: none;
  }

  .ts-header.is-search-open .ts-search {
    display: block;
  }

  .ts-burger {
    display: inline-flex;
  }

  .ts-burger .ts-burger__icon {
    width: 22px;
    height: 22px;
  }

  /* Прячем десктопный ряд меню/города */
  .ts-nav-bar {
    display: none !important;
  }

  /* Drawer */
  .ts-drawer {
    display: block;
  }

  .ts-drawer[hidden] {
    display: none !important;
  }

  .ts-header.is-drawer-open .ts-drawer {
    display: block;
  }

  .ts-drawer__panel {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    width: min(360px, 88vw);
    height: 100%;
    background: var(--color-header-bg, #FFFFFF);
    box-shadow: -8px 0 24px rgba(0, 0, 0, 0.12);
    transform: translateX(100%);
    transition: transform 0.2s ease;
    overflow-y: auto;
    padding: 16px;
  }

  .ts-header.is-drawer-open .ts-drawer__panel {
    transform: translateX(0);
  }

  .ts-drawer__backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 1090;
    background: rgba(0, 0, 0, 0.35);
  }

  .ts-drawer__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
  }

  .ts-drawer__catalog-wrap {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 8px;
  }

  .ts-drawer__catalog-btn {
    width: 100%;
    justify-content: center;
    flex-shrink: 0;
  }

  .ts-drawer__catalog[hidden] {
    display: none !important;
  }

  .ts-drawer__catalog {
    display: block;
    margin: 0 0 4px;
  }

  .ts-drawer__catalog-view {
    display: block;
  }

  .ts-drawer__panel.is-catalog-open [data-ts-drawer-nav] {
    display: none;
  }

  .ts-drawer__catalog .ts-megamenu__mlist {
    gap: 6px;
  }

  .ts-drawer__catalog .ts-megamenu__mlink {
    padding: 11px 12px;
    font-size: 15px;
  }

  .ts-drawer__catalog .ts-megamenu__back {
    margin-bottom: 8px;
  }

  .ts-drawer__catalog .ts-megamenu__mobile-head {
    margin-bottom: 10px;
  }

  .ts-brand--drawer {
    flex: 0 1 auto;
    min-width: 0;
  }

  .ts-brand--drawer .ts-brand__logo {
    width: var(--logo-width);
    max-width: 100%;
    height: auto;
  }

  .ts-nav--drawer {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
  }

  .ts-nav--drawer .ts-nav__link {
    font-size: 16px;
    padding: 12px 0;
    border-bottom: 1px solid var(--color-border);
  }

  .ts-city--drawer {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin-left: 0;
    margin-top: 16px;
    gap: 12px;
  }

  .ts-city--drawer .ts-city__label {
    flex: 0 0 auto;
    margin-right: auto;
  }

  .ts-city--drawer .ts-city__name {
    flex: 0 0 auto;
    margin-left: auto;
  }

  .ts-city--drawer .ts-city__name-inner {
    text-decoration: none;
  }

  /* На мобиле: помощь / избранное / войти — только в drawer */
  .ts-actions .ts-btn--help,
  .ts-actions .ts-btn--wishlist,
  .ts-actions .ts-btn--account {
    display: none;
  }

  .ts-drawer__actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: auto;
    padding-top: 24px;
    flex-shrink: 0;
    position: sticky;
    bottom: 0;
    background: var(--color-header-bg, #FFFFFF);
    padding-bottom: 4px;
  }

  .ts-drawer__actions-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .ts-drawer__actions .ts-btn--secondary {
    width: 100%;
    min-width: 0;
    padding: 0 12px;
    justify-content: center;
  }

  .ts-drawer__actions .ts-btn__label {
    display: inline !important;
  }

  .ts-drawer__login {
    width: 100%;
  }

  body.ts-drawer-lock {
    overflow: hidden;
  }
}

/* Cleversite: плавающая кнопка скрыта — чат только через «Помощь» в шапке.
   Окно чата скрыто, пока нет body.ts-chat-open (блок авто-открытия Cleversite). */
#cleversite_button,
.cleversite-button,
.cs-widget-button,
.clever-site-button,
.clever-standard-button,
.clever-widget__button,
.clever-standard-button-template,
#cleversite_widget_app,
#cleversite_widget_app *,
.clever-widget,
.clever-widget * {
  pointer-events: none !important;
}

#cleversite_button,
.cleversite-button,
.cs-widget-button,
.clever-site-button,
.clever-standard-button,
.clever-widget__button,
.clever-standard-button-template {
  opacity: 0 !important;
  visibility: hidden !important;
  width: 0 !important;
  height: 0 !important;
  overflow: hidden !important;
  pointer-events: none !important;
}

/* Скрываем окно чата, пока пользователь не нажал «Помощь» */
body:not(.ts-chat-open) #cleversite_widget_app .clever-screen,
body:not(.ts-chat-open) .clever-widget .clever-screen,
body:not(.ts-chat-open) #cleversite_popups_app,
body:not(.ts-chat-open) .clever-invite,
body:not(.ts-chat-open) .clever-proactive,
body:not(.ts-chat-open) [class*="clever-invite"],
body:not(.ts-chat-open) [class*="clever-proactive"] {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
  transform: translateY(120%) !important;
}

/* Корзина/checkout: виджет не нужен вообще */
.ts-checkout-page #cleversite_widget_app,
.ts-checkout-page #cleversite_popups_app,
.ts-checkout-page .clever-widget,
.ts-checkout-page .clever-standard-button,
.ts-checkout-page .clever-widget__button {
  display: none !important;
}

body.ts-chat-open #cleversite_widget_app,
body.ts-chat-open #cleversite_widget_app *,
body.ts-chat-open .clever-widget,
body.ts-chat-open .clever-widget * {
  pointer-events: auto !important;
}

/* Модалка чата Cleversite: 20px от правого и нижнего края (десктоп) */
body.ts-chat-open #cleversite_widget_app .clever-screen,
body.ts-chat-open .clever-widget .clever-screen {
  right: var(--chat-offset) !important;
  bottom: var(--chat-offset) !important;
  left: auto !important;
  top: auto !important;
}

/* Мобилка: чат на весь экран, без съезда вбок и обрезки */
@media (max-width: 768px) {
  body.ts-chat-open {
    overflow: hidden !important;
    overscroll-behavior: none;
  }

  body.ts-chat-open #cleversite_widget_app,
  body.ts-chat-open .clever-widget {
    position: fixed !important;
    inset: 0 !important;
    width: 100% !important;
    max-width: 100vw !important;
    height: 100% !important;
    max-height: 100dvh !important;
    z-index: 100000 !important;
    transform: none !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  body.ts-chat-open #cleversite_widget_app .clever-screen,
  body.ts-chat-open .clever-widget .clever-screen {
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    top: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    max-width: 100vw !important;
    height: 100% !important;
    max-height: 100dvh !important;
    margin: 0 !important;
    transform: none !important;
    border-radius: 0 !important;
    box-sizing: border-box !important;
  }
}

/* ========== Catalog megamenu (Ozon-like, width = Каталог…поиск) ========== */
.ts-megamenu {
  position: absolute;
  z-index: 120;
  box-sizing: border-box;
}

.ts-megamenu[hidden],
.ts-megamenu-backdrop[hidden] {
  display: none !important;
}

.ts-megamenu-backdrop {
  position: fixed;
  inset: 0;
  z-index: 110;
  background: rgba(26, 26, 26, 0.18);
}

.ts-megamenu__box {
  display: flex;
  min-height: 320px;
  max-height: min(70vh, 560px);
  background: #ffffff;
  border-radius: var(--radius-btn, 10px);
  box-shadow: 0 12px 40px rgba(26, 26, 26, 0.14);
  overflow: hidden;
}

.ts-megamenu__nav {
  flex: 0 0 42%;
  max-width: var(--megamenu-nav-max, 300px);
  overflow-y: auto;
  background: var(--color-surface, #F2F2F2);
  padding: 8px 0;
}

.ts-megamenu__nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  color: var(--color-text, #1A1A1A);
  font-size: 15px;
  font-weight: 500;
  text-decoration: none;
  outline: none;
  box-shadow: none;
}

.ts-megamenu__nav-icon {
  flex: 0 0 var(--megamenu-icon-size, 40px);
  width: var(--megamenu-icon-size, 40px);
  height: var(--megamenu-icon-size, 40px);
  border-radius: var(--megamenu-icon-radius, 10px);
  background: var(--color-surface-hover, #E5E3E3);
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.ts-megamenu__nav-icon img {
  display: block;
  width: var(--megamenu-icon-img, 88%);
  height: auto;
  max-height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  vertical-align: bottom;
  object-fit: contain;
  object-position: bottom center;
  transform-origin: bottom center;
  align-self: flex-end;
  pointer-events: none;
}

/* Отдельная загруженная иконка меню — на весь квадрат 40×40 */
.ts-megamenu__nav-icon.is-custom,
.ts-megamenu__mlink-icon.is-custom {
  align-items: center;
}

.ts-megamenu__nav-icon.is-custom img,
.ts-megamenu__mlink-icon.is-custom img {
  width: 100%;
  height: 100%;
  max-height: none;
  object-fit: cover;
  object-position: center;
  align-self: center;
}

.ts-megamenu__nav-text {
  flex: 1 1 auto;
  min-width: 0;
  line-height: 1.25;
}

.ts-megamenu__nav-item:hover,
.ts-megamenu__nav-item:focus,
.ts-megamenu__nav-item:active {
  outline: none;
  box-shadow: none;
  text-decoration: none;
  color: var(--color-text, #1A1A1A);
  background: rgba(63, 78, 62, 0.08);
}

.ts-megamenu__nav-item.is-active {
  background: #ffffff;
  color: var(--brand-primary, #3F4E3E);
  font-weight: 600;
}

.ts-megamenu__nav-chevron {
  flex: 0 0 auto;
  margin-left: auto;
  color: rgba(26, 26, 26, 0.35);
  font-size: 16px;
  line-height: 1;
}

.ts-megamenu__panels {
  flex: 1 1 auto;
  min-width: 0;
  overflow-y: auto;
  padding: 16px 20px 20px;
  background: #ffffff;
}

.ts-megamenu__panel {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.ts-megamenu__panel[hidden] {
  display: none !important;
}

.ts-megamenu__all {
  display: inline-flex;
  margin-bottom: 14px;
  color: var(--brand-primary, #3F4E3E);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  outline: none;
}

.ts-megamenu__all:hover,
.ts-megamenu__all:focus,
.ts-megamenu__all:active {
  outline: none;
  text-decoration: none;
  opacity: 0.75;
}

.ts-megamenu__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}

.ts-megamenu__link {
  display: block;
  padding: 4px 0;
  color: var(--color-text, #1A1A1A);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  outline: none;
}

.ts-megamenu__link:hover,
.ts-megamenu__link:focus,
.ts-megamenu__link:active {
  outline: none;
  color: var(--brand-primary, #3F4E3E);
  text-decoration: none;
}

.ts-megamenu__sub {
  list-style: none;
  margin: 0 0 8px;
  padding: 0 0 0 0;
}

.ts-megamenu__sublink {
  display: block;
  padding: 2px 0;
  color: rgba(26, 26, 26, 0.65);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  outline: none;
}

.ts-megamenu__sublink:hover,
.ts-megamenu__sublink:focus,
.ts-megamenu__sublink:active {
  outline: none;
  color: var(--brand-primary, #3F4E3E);
  text-decoration: none;
}

.ts-megamenu__empty {
  margin: 0;
  color: rgba(26, 26, 26, 0.45);
  font-size: 14px;
}

/* Хиты категории, если нет подкатегорий — один ряд + «Все товары» */
.ts-megamenu__hits {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
  height: 100%;
}

.ts-megamenu__products {
  display: flex;
  flex-direction: column;
  gap: var(--megamenu-product-gap, 10px);
  align-content: start;
  flex: 1 1 auto;
  min-height: 0;
}

.ts-megamenu__product {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
  min-width: 0;
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--megamenu-product-radius, 12px);
  background: var(--color-surface, #F2F2F2);
  text-decoration: none;
  color: var(--color-text, #1A1A1A);
  outline: none;
  box-shadow: none;
}

.ts-megamenu__product:hover,
.ts-megamenu__product:focus,
.ts-megamenu__product:active,
.ts-megamenu__product:focus-visible {
  outline: none;
  box-shadow: none;
  background: var(--color-surface-hover, #E5E3E3);
  text-decoration: none;
  color: var(--color-text, #1A1A1A);
}

.ts-megamenu__product-media {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 var(--megamenu-product-thumb, 56px);
  width: var(--megamenu-product-thumb, 56px);
  height: var(--megamenu-product-thumb, 56px);
  border-radius: 10px;
  overflow: hidden;
  background: #ffffff;
}

.ts-megamenu__product-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.ts-megamenu__product-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.ts-megamenu__product-name {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.25;
}

.ts-megamenu__product-price {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--brand-primary, #3F4E3E);
}

.ts-megamenu__product-price-old {
  margin-left: 6px;
  font-size: 12px;
  font-weight: 500;
  color: rgba(26, 26, 26, 0.45);
  text-decoration: line-through;
}

.ts-megamenu__all-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: auto;
  height: var(--ctrl-height, 40px);
  padding: 0 16px;
  border-radius: var(--radius-btn, 10px);
  background: var(--brand-primary, #3F4E3E);
  color: #ffffff;
  font-family: var(--font-family);
  font-size: var(--font-btn, 16px);
  font-weight: var(--font-btn-weight, 500);
  text-decoration: none;
  outline: none;
  box-shadow: none;
}

.ts-megamenu__all-btn:hover,
.ts-megamenu__all-btn:focus,
.ts-megamenu__all-btn:active,
.ts-megamenu__all-btn:focus-visible {
  outline: none;
  box-shadow: none;
  text-decoration: none;
  color: #ffffff;
  background: #354233;
}

button.ts-btn--catalog {
  appearance: none;
  -webkit-appearance: none;
}

/* Мобильный drill-down: пункты меню вместо товаров */
.ts-megamenu__mobile[hidden],
.ts-megamenu__desktop[hidden] {
  display: none !important;
}

.ts-megamenu__back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 0 0 10px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--brand-primary, #3F4E3E);
  font-family: var(--font-family);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  box-shadow: none;
}

.ts-megamenu__back:hover,
.ts-megamenu__back:focus,
.ts-megamenu__back:active,
.ts-megamenu__back:focus-visible {
  outline: none;
  box-shadow: none;
  opacity: 0.75;
}

.ts-megamenu__back-chevron {
  font-size: 18px;
  line-height: 1;
}

.ts-megamenu__mobile-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 12px;
}

.ts-megamenu__mobile-title {
  margin: 0;
  flex: 1 1 auto;
  min-width: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--color-text, #1A1A1A);
  line-height: 1.25;
}

.ts-megamenu__mobile-head .ts-megamenu__all {
  flex: 0 0 auto;
  margin: 0;
  white-space: nowrap;
}

.ts-megamenu__mlist {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ts-megamenu__mlink {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 14px;
  border: 0;
  border-radius: var(--megamenu-product-radius, 12px);
  background: var(--color-surface, #F2F2F2);
  color: var(--color-text, #1A1A1A);
  font-family: var(--font-family);
  font-size: 15px;
  font-weight: 600;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  outline: none;
  box-shadow: none;
  appearance: none;
  -webkit-appearance: none;
}

.ts-megamenu__mlink:hover,
.ts-megamenu__mlink:focus,
.ts-megamenu__mlink:active,
.ts-megamenu__mlink:focus-visible {
  outline: none;
  box-shadow: none;
  text-decoration: none;
  color: var(--color-text, #1A1A1A);
  background: var(--color-surface-hover, #E5E3E3);
}

.ts-megamenu__mlink-icon {
  flex: 0 0 var(--megamenu-icon-size, 40px);
  width: var(--megamenu-icon-size, 40px);
  height: var(--megamenu-icon-size, 40px);
  border-radius: var(--megamenu-icon-radius, 10px);
  background: var(--color-surface-hover, #E5E3E3);
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.ts-megamenu__mlink-icon img {
  display: block;
  width: var(--megamenu-icon-img, 88%);
  height: auto;
  max-height: 100%;
  object-fit: contain;
  object-position: bottom center;
  pointer-events: none;
}

.ts-megamenu__mlink-text {
  flex: 1 1 auto;
  min-width: 0;
  line-height: 1.25;
}

.ts-megamenu__mlink-chevron {
  flex: 0 0 auto;
  color: rgba(26, 26, 26, 0.35);
  font-size: 16px;
  line-height: 1;
}

@media (max-width: 768px) {
  /* Шапка «Каталог» — megamenu с drill-down; в бургере — только ссылка */
  .ts-megamenu__box {
    flex-direction: column;
    max-height: min(75vh, 520px);
    min-height: 0;
  }

  /* L1 не слайдером — вертикальный список в .ts-megamenu__mobile */
  .ts-megamenu__nav {
    display: none !important;
  }

  .ts-megamenu__desktop {
    display: none !important;
  }

  .ts-megamenu__mobile {
    display: block;
  }

  .ts-megamenu__panels {
    padding: 12px 14px 16px;
    overflow-x: hidden;
  }

  html.ts-megamenu-open,
  html.ts-megamenu-open body {
    overflow: hidden;
  }

  /* Меню каталога — fixed к экрану (не absolute внутри sticky) */
  .ts-megamenu {
    position: fixed;
    z-index: 120;
  }

  /* Меню открыто — «Каталог» всегда на месте (в т.ч. после скролла mid-page) */
  .ts-header.is-megamenu-open .ts-btn--catalog {
    max-height: var(--ctrl-height) !important;
    min-height: var(--ctrl-height) !important;
    height: var(--ctrl-height) !important;
    opacity: 1 !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    margin-top: 0 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    overflow: hidden;
    transition: none !important;
  }
}

/*
 * Блокировка скролла — только мобилка.
 * На ПК overflow:hidden ломает sticky-шапку (меню mid-page → шапка уезжает вверх).
 */
@media (max-width: 768px) {
  html.ts-megamenu-open,
  html.ts-megamenu-open body {
    overflow: hidden !important;
    overscroll-behavior: none;
    touch-action: none;
  }

  body.ts-megamenu-scroll-lock {
    overflow: hidden;
    overscroll-behavior: none;
    touch-action: none;
  }
}
