@media (max-width: 767px) {
  :root {
    --pad: clamp(16px, 6.4vw, 24px);
    --r16: 16px;
    --r20: 20px;
    --r24: 24px;
    --r30: 30px;
  }

  html,
  body {
    overflow-x: hidden;
  }

  .product-page {
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding-inline: 0;
    padding-block-end: 0 !important; /* Убираем padding-bottom, так как футер имеет padding-top 50px */
  }

  .product-page .container,
  .product__nav-bar .container {
    padding-inline: 0;
  }

  /* Header safety on mobile */
  .header__nav,
  .header__button {
    display: none;
  }

  .header__burger {
    display: inline-flex;
  }

  /* Nav bar: catalog + search */
  .product__nav-bar {
    margin-block-start: 0 !important;
    margin-top: 0 !important;
    padding-inline: var(--pad);
    position: relative;
    z-index: 1;
  }

  /* Nav container: 375px width, 70px height, padding 24px left/right (Figma Rectangle 168) */
  .product__nav-container {
    width: 100%;
    max-width: 375px;
    height: 70px;
    padding: 10px 24px;
    border-radius: var(--r20);
    gap: 0;
    background: rgba(255, 255, 255, 0.4);
    display: flex;
    align-items: center;
    justify-content: space-between;
    /* backdrop-filter removed on mobile to fix position:fixed context */
    /* backdrop-filter: blur(15px); */
    /* -webkit-backdrop-filter: blur(15px); */
  }

  .product__catalog-btn {
    inline-size: auto;
    padding: 16px 24px;
    height: 50px;
    border-radius: 30px;
    font-size: 16px;
    font-weight: 300;
    gap: 8px;
    flex-shrink: 0;
  }

  /* Search wrapper: takes available space, container controls its own width */
  .product__search-wrapper {
    flex: 1;
    min-width: 0;
    margin: 0;
    height: 50px;
    max-height: 50px;
    display: flex;
    justify-content: flex-end;
    align-items: center;
  }

  /* ===== COLLAPSED STATE (default) ===== */
  /* Exact 50x50px square icon button pinned to right (Figma) */
  .product__search-container {
    position: relative;
    width: 50px !important;
    height: 50px !important;
    min-height: 50px !important;
    max-height: 50px !important;
    line-height: 50px !important;
    border-radius: 16px;
    padding: 0 !important;
    padding-inline: 0 !important;
    padding-block: 0 !important;
    margin: 0 !important;
    background: #fffaef;
    border: 1px solid #c02927;
    border-width: 1px !important;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition:
      width 250ms cubic-bezier(0.22, 1, 0.36, 1),
      padding 250ms cubic-bezier(0.22, 1, 0.36, 1),
      border-radius 250ms cubic-bezier(0.22, 1, 0.36, 1);
    overflow: hidden;
    cursor: pointer;
    flex-shrink: 0;
    box-sizing: border-box !important;
  }

  /* Hide input visually but keep it focusable in collapsed state */
  .product__search-container:not(:focus-within):not(.is-scrolled)
    .product__search-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    padding: 0;
    font-size: 0;
    border: none;
    outline: none;
    background: transparent;
    cursor: pointer;
    z-index: 2;
    transition: opacity 200ms ease;
  }

  /* Hide clear button in collapsed state */
  .product__search-container:not(:focus-within):not(.is-scrolled)
    .product__search-clear {
    display: none !important;
  }

  /* Center search icon in collapsed state - positioned above input */
  .product__search-container:not(:focus-within):not(.is-scrolled)
    .product__search-btn {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 24px;
    height: 24px;
    margin: 0;
    padding: 0;
    border-radius: 0;
    right: auto;
    background: transparent;
    border: none;
    cursor: pointer;
    color: #c02927;
    pointer-events: none;
    z-index: 1;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  .product__search-container:not(:focus-within):not(.is-scrolled)
    .product__search-btn
    svg {
    width: 24px !important;
    height: 24px !important;
    color: #c02927;
    display: block;
    margin: 0;
    padding: 0;
    flex-shrink: 0;
  }

  /* ===== EXPANDED STATE (on focus) ===== */
  /* Expands to full width when user taps/clicks (focus-within) */
  .product__search-container:focus-within {
    width: 100% !important;
    height: 50px !important;
    min-height: 50px !important;
    max-height: 50px !important;
    line-height: 50px !important;
    border-radius: 16px;
    padding-inline: 12px !important;
    padding-block: 0 !important;
    display: flex;
    align-items: center;
    gap: 8px;
    background: #fffaef;
    flex-shrink: 1 !important;
    box-sizing: border-box !important;
  }

  /* When container is focused, it should expand to fill wrapper */
  .product__search-container:focus-within {
    flex: 1 1 auto !important;
  }

  .product__search-container:focus-within .product__search-input {
    position: relative !important;
    width: 100% !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    font-size: 14px !important;
    padding-inline: 10px 44px !important;
    flex: 1;
    min-width: 0;
    z-index: auto;
    transition: opacity 200ms ease;
  }

  .product__search-container:focus-within .product__search-btn {
    position: absolute;
    right: 0;
    top: 10px;
    width: 50px;
    height: 50px;
    border-radius: 16px;
    transform: none;
    left: auto;
    margin: 0;
    padding: 0;
    pointer-events: auto;
    z-index: 1;
    color: #c02927;
  }

  /* Hide clear button by default in focused state */
  .product__search-container:focus-within .product__search-clear {
    position: absolute;
    right: 58px;
    width: 24px;
    height: 24px;
    padding: 0;
    margin: 0;
    border-radius: 8px;
    z-index: 2;
    color: var(--accent-color);
    display: none;
  }

  /* Show clear button only when input has value in focused state */
  .product__search-container:focus-within
    .product__search-input:not(:placeholder-shown)
    ~ .product__search-clear {
    display: flex;
  }

  /* ===== SCROLL STATE (force expanded) ===== */
  /* When .is-scrolled is present (added by search-sticky.js), force expanded state */
  /* DO NOT override existing glass/fixed behavior - only ensure it's not collapsed */
  /* JS controls positioning via inline styles (left/right), so don't override width/position */
  .product__search-container.is-scrolled {
    width: auto !important; /* Let JS control width via left/right positioning */
    max-width: none !important; /* Remove max-width restriction */
    height: 50px !important;
    border-radius: 24px !important;
    padding-inline: 12px !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    box-sizing: border-box !important; /* Ensure padding is included in width */
    /* Don't override left/right - let JS handle positioning */

    /* Existing glass effect styles preserved */
    background:
      radial-gradient(
        circle at 20% 30%,
        rgba(255, 255, 255, 0.6) 0%,
        transparent 60%
      ),
      radial-gradient(
        circle at 80% 70%,
        rgba(255, 255, 255, 0.5) 0%,
        transparent 60%
      ),
      radial-gradient(
        circle at 50% 50%,
        rgba(255, 255, 255, 0.4) 0%,
        transparent 70%
      ),
      linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.45) 0%,
        rgba(255, 255, 255, 0.3) 50%,
        rgba(255, 255, 255, 0.35) 100%
      );

    backdrop-filter: blur(32px) saturate(220%) !important;
    -webkit-backdrop-filter: blur(32px) saturate(220%) !important;

    border: 1px solid rgba(192, 41, 39, 0.35) !important;

    box-shadow:
      0 8px 30px rgba(0, 0, 0, 0.12),
      inset 0 1px 0 rgba(255, 255, 255, 0.6) !important;
  }

  /* Force input visible and functional when scrolled */
  .product__search-container.is-scrolled .product__search-input {
    position: relative !important;
    width: 100% !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    font-size: 14px !important;
    padding-inline: 10px 44px !important;
    flex: 1;
    min-width: 0;
    z-index: auto !important;
  }

  .product__search-container.is-scrolled .product__search-btn {
    position: absolute !important;
    right: 0 !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    width: 50px !important;
    height: 50px !important;
    border-radius: 16px !important;
    left: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    pointer-events: auto !important;
    color: #c02927 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  /* Clear button positioning when scrolled - HIDDEN by default when input is empty */
  .product__search-container.is-scrolled .product__search-clear {
    position: absolute !important;
    right: 60px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    width: 24px !important;
    height: 24px !important;
    padding: 0 !important;
    margin: 0 !important;
    border-radius: 8px !important;
    z-index: 2 !important;
    color: var(--accent-color) !important;
    align-items: center !important;
    justify-content: center !important;
    display: none !important;
    opacity: 0 !important;
    pointer-events: none !important;
    visibility: hidden !important;
  }

  /* Show clear button ONLY when input has value (not showing placeholder) when scrolled */
  .product__search-container.is-scrolled
    .product__search-input:not(:placeholder-shown)
    ~ .product__search-clear {
    display: flex !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    visibility: visible !important;
  }

  /* Extra rule to ensure it's hidden when placeholder is shown */
  .product__search-container.is-scrolled
    .product__search-input:placeholder-shown
    ~ .product__search-clear {
    display: none !important;
    opacity: 0 !important;
    pointer-events: none !important;
    visibility: hidden !important;
  }

  /* Prevent content from being hidden under fixed search */
  .product-page {
    padding-top: 14px;
  }

  /* Autocomplete must stay above everything */
  .product__search-suggestions {
    z-index: 2100;
  }

  /* Base input styles */
  .product__search-input {
    font-size: 14px;
    padding-inline: 10px 44px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }

  /* Base button styles */
  .product__search-btn {
    width: 50px;
    height: 50px;
    border-radius: var(--r16);
    right: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
  }

  /* Base clear button styles - hidden by default on mobile */
  .product__search-clear {
    position: absolute;
    right: 58px;
    width: 24px;
    height: 24px;
    padding: 0;
    margin: 0;
    border-radius: 8px;
    z-index: 2;
    color: var(--accent-color);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: none !important;
  }

  /* Title + hero */
  .product__title-section {
    padding-block: 16px 12px;
    padding-inline: var(--pad);
  }

  .product__title {
    font-size: 24px;
    line-height: 1;
    font-weight: 300;
    color: #c02927;
  }

  .product__hero {
    padding: 0;
  }

  .product__hero-container {
    padding: 0;
    margin: 0;
  }

  .product__hero-brand-logo {
    position: relative;
    width: 100%;
    height: 200px;
    min-block-size: 200px;
    border-radius: var(--r30);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .product__hero-brand-logo[aria-hidden="true"] {
    display: none;
  }

  .product__hero-brand-logo::before {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.15);
    z-index: 0;
    pointer-events: none;
  }

  .product__hero-brand-logo-img {
    position: relative;
    z-index: 1;
    max-width: 80%;
    max-height: 70%;
    width: auto;
    height: auto;
  }

  .product__hero-carousel {
    width: 100%;
    height: 134px;
    border-radius: var(--r30);
    overflow: hidden;
  }

  .product__hero-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  /* Tabs: stacked */
  .product__tabs-section {
    padding-block: 16px;
    padding-inline: var(--pad);
  }

  .product__tabs-container {
    width: 100%;
  }

  .product__tabs {
    width: 100%;
    padding: 0;
    border-radius: 0;
    background: transparent;
    gap: 16px;
    flex-direction: column;
  }

  .product__tab {
    margin: 0;
    width: 100%;
    height: 50px;
    padding: 0 32px;
    font-size: 24px;
    border-radius: var(--r30);
    text-transform: uppercase;
  }

  .product__tab:not(.product__tab--active) {
    background: #fff;
  }

  .product__tab--active {
    background: var(--accent-color);
    color: #fff;
  }

  .product__tab:hover:not(.product__tab--active) {
    background-color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(192, 41, 39, 0.18);
  }

  /* Switcher section */
  .product__switcher-section {
    padding-inline: var(--pad);
  }

  /* Categories: vertical stack like Figma */
  .product__categories-wrap,
  .product__brands-wrap {
    padding-block: 16px 24px;
  }

  .product__categories-section,
  .product__brands-section {
    padding-block: 0;
  }

  .product__categories-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
  }

  .product__category-card,
  .product__category-card--small,
  .product__category-card--large-wide,
  .product__category-card--large-tall {
    width: 100%;
    height: 83px;
    border-radius: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
  }

  .product__category-card-bg {
    border-radius: 50px;
  }

  .product__category-card-bg-image {
    object-fit: cover;
  }

  .product__category-card-title-img {
    max-width: 100%;
    max-height: 100%;
    width: 100%;
    height: 100%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
  }

  .product__category-card-title-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: 50% 50%;
  }

  .product__category-card[data-category-id="marshmallows"]
    .product__category-card-title-img {
    max-width: 80%;
    max-height: 80%;
  }

  .product__category-card[data-category-id="marmalade"]
    .product__category-card-title-img {
    max-width: 82%;
    max-height: 82%;
  }

  .product__category-card[data-category-id="sponge cake"]
    .product__category-card-title-img {
    max-width: 100%;
    max-height: 87%;
  }

  /* Category image crop controls (mobile only) */
  /* marshmallows: no crop */
  .product__category-card[data-category-id="marshmallows"]
    .product__category-card-title-image {
    /* no crop */
  }

  /* marmalade: no crop */
  .product__category-card[data-category-id="marmalade"]
    .product__category-card-title-image {
    transform: translateY(7px) !important;
    /* no crop */
  }

  /* candy: no crop */
  .product__category-card[data-category-id="candy"]
    .product__category-card-title-image {
    /* no crop */
  }

  /* caramel: no crop */
  .product__category-card[data-category-id="caramel"]
    .product__category-card-title-image {
    width: 95% !important;
    height: 70px !important;
    transform: translateY(2px) !important;
    /* no crop */
  }

  /* sponge cake: no crop */
  .product__category-card[data-category-id="sponge cake"]
    .product__category-card-title-image {
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    transform: translateY(1px) !important;
  }

  .product__category-card[data-category-id="waffles"]
    .product__category-card-title-image {
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    transform: translateY(7px) !important;
  }

  /* jelly: no crop */
  .product__category-card[data-category-id="jelly"]
    .product__category-card-title-image {
    transform: translateY(7px) !important;
  }

  /* chocolate: no crop */
  .product__category-card[data-category-id="chocolate"]
    .product__category-card-title-image {
    /* no crop */
  }

  .product__brands-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  /* Products grid: 2 columns */
  .product__panels {
    padding-inline: var(--pad);
    padding-block: 16px 40px;
  }

  .product__grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    padding-block: 16px;
    width: 100%;
  }

  .product__item {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
    padding: 14px 12px;
    border-radius: var(--r20);
    gap: 12px;
    box-sizing: border-box;
  }

  .product__item-image-wrapper {
    width: 100%;
    min-width: 0;
    height: 120px;
    border-radius: 14px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }

  .product__item-image-wrapper img,
  .product__item img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    border-radius: 14px;
  }

  .product__item-title {
    font-size: 14px;
    line-height: 1.1;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .product__item-button {
    font-size: 14px;
    border-radius: 12px;
    padding: 10px 12px;
  }

  .product__item-button-icon {
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
  }

  .product__item-button-icon svg {
    width: 24px !important;
    height: 24px !important;
    display: block;
    opacity: 1;
  }

  /* Filters */
  .product__breadcrumb-container {
    font-size: 12px;
    flex-wrap: wrap;
  }

  .product__results-header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    margin-block-end: 16px;
  }

  .product__filters-row {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .product-page--brand-selected .product__hero-container {
    min-height: 0px;
  }

  .product-page--brand-selected .product__hero {
    margin-block: 0px;
    padding: 0px;
  }

  .product__category-dropdown-btn,
  .product__popularity-filter {
    width: 100%;
    font-size: 14px;
    padding: 12px 16px;
    border-radius: 16px;
    min-height: 44px;
    justify-content: space-between;
  }

  .product__category-dropdown-menu {
    width: 100%;
    min-width: 0;
    border-radius: 20px;
  }

  .product__category-dropdown-item {
    font-size: 14px;
    padding: 0 16px;
  }

  /* Modal */
  .product-modal__container {
    width: calc(100% - 24px);
    max-width: none;
    max-height: calc(100vh - 24px);
    border-radius: 24px;
  }

  .product-modal__content {
    padding: 16px;
  }

  .product-modal__header {
    grid-template-columns: 1fr;
    gap: 16px;
    margin-bottom: 16px;
    padding-bottom: 16px;
  }

  .product-modal__image-wrapper {
    height: 200px;
  }

  .product-modal__title {
    font-size: 18px;
  }

  .product-modal__section-title {
    font-size: 16px;
  }

  .product-modal__text {
    font-size: 14px;
    line-height: 1.35;
  }

  .product__category-card[data-category-id="marshmallows"]
    .categories__list-item {
    transform: scale(0.2);
  }

  .product__category-card-title-image {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
    transform-origin: center center;
    will-change: transform;
  }

  @media (max-width: 767px) {
    .product__category-card[data-category-id="marshmallows"]
      .product__category-card-title-image {
      transform: scale(-1.2);
    }

    .product__category-card[data-category-id="sponge cake"]
      .product__category-card-title-image {
      transform: scale(1);
    }
  }

  .product__category-card[data-category-id="waffles"]
    .product__category-card-title-img {
    width: 201px !important;
    max-width: 201px !important;
    height: auto !important;
    max-height: none !important;
  }

  .product__category-card[data-category-id="waffles"]
    .product__category-card-title-image {
    width: 201px !important;
    max-width: 201px !important;
    height: auto !important;
    max-height: none !important;
  }

  .product__category-card[data-category-id="sponge cake"]
    .product__category-card-title-image {
    width: 201px !important;
    max-width: 201px !important;
    height: auto !important;
    max-height: auto !important;
  }

  .product__category-card[data-category-id="jelly"]
    .product__category-card-title-img {
    width: 201px !important;
    max-width: 201px !important;
    height: 100% !important;
    max-height: 100% !important;
  }
}
