.catalog-page {
  padding-bottom: 48px;
  min-height: calc(100dvh - 120px);
  display: flex;
  flex-direction: column;
}

.catalog-page > .catalog-layout,
.catalog-page > .product-page,
.catalog-page > .breadcrumb {
  flex: 0 0 auto;
}

.catalog-page--product {
  justify-content: flex-start;
}

.catalog-layout {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  gap: 16px;
  margin-top: 12px;
  flex: 1;
}

.catalog-filters {
  padding: 14px 12px 16px;
  align-self: start;
  position: sticky;
  top: var(--ce-header-offset, 72px);
  max-height: calc(100dvh - var(--ce-header-offset, 72px) - 16px);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable;
}

.catalog-filters.panel-solid {
  padding-top: 14px;
  padding-bottom: 16px;
}

.filters-title {
  font-size: 15px;
  margin: 0 0 8px;
  font-weight: 570;
}

.filters-title.side-gap {
  margin-top: 16px;
}

.filter-groups {
  display: grid;
  gap: 12px;
  margin-top: 10px;
}

.filter-group__toggle {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  margin: 0;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  font: inherit;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ce-muted);
  cursor: pointer;
  text-align: left;
}

.filter-group__toggle:hover,
.filter-group.is-open .filter-group__toggle {
  color: var(--ce-green);
  background: #eef6ef;
}

.filter-group__body {
  display: grid;
  gap: 2px;
  margin-top: 2px;
}

.filter-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 8px;
  text-decoration: none;
  font-size: 13.5px;
  color: var(--ce-ink);
  min-height: 40px;
}

.filter-link--primary {
  font-weight: 620;
}

.filter-link span {
  margin-left: auto;
  color: var(--ce-muted);
  font: 12px/1 var(--ce-mono);
  font-variant-numeric: tabular-nums;
}

.filter-link:hover,
.filter-link.is-active {
  background: #eef6ef;
  color: var(--ce-green);
}

.filter-link--primary.is-active {
  background: color-mix(in srgb, var(--ce-green) 14%, #eef6ef);
}

.filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.catalog-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  align-items: end;
  margin-bottom: 12px;
}

.catalog-heading h1 {
  font-family: var(--ce-display);
  font-size: clamp(26px, 3vw, 36px);
  line-height: 1.18;
  letter-spacing: 0.01em;
  font-weight: 400;
  margin: 0;
}

.catalog-search {
  display: flex;
  gap: 8px;
  flex: 1 1 280px;
  max-width: 420px;
}

.catalog-search input[type="search"] {
  flex: 1;
  min-width: 0;
}

.mobile-filter-bar {
  display: none;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 14px;
}

.active-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.catalog-more {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 20px;
}

.product-grid,
.category-grid {
  display: grid;
  gap: 16px;
}

.product-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: stretch;
  justify-content: start;
}

.product-grid--home {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.catalog-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
  width: 100%;
}

.catalog-stock {
  flex: 0 0 auto;
}

.catalog-active-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 12px;
}

.catalog-empty {
  grid-column: 1 / -1;
  display: grid;
  gap: 12px;
  padding: 8px 0 24px;
}

.catalog-empty__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.category-grid {
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.category-grid--home {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.product-card {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--ce-line);
  border-radius: 12px;
  min-width: 0;
  height: 100%;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.product-card:hover {
  border-color: #a8c0ad;
  box-shadow: 0 8px 20px rgba(20, 38, 31, 0.06);
}

/* Fixed media slot — source aspect ratio cannot stretch the card */
.product-card__media-wrap {
  position: relative;
  flex: 0 0 auto;
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: #eef2ea;
  border-bottom: 1px solid var(--ce-line);
}

.product-card__media {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #eef2ea;
  text-decoration: none;
}

.product-card__media img,
.product-card__media .product-card__placeholder {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  object-fit: contain;
  object-position: center;
  padding: 12px;
  box-sizing: border-box;
}

.product-card__placeholder {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 6px;
  color: var(--ce-green);
  background: #eef2ea;
  text-align: center;
}

.product-card__placeholder em {
  font-style: normal;
  font-size: 12px;
  color: var(--ce-muted);
}

.product-card__body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
  flex: 1 1 auto;
  min-height: 0;
}

.product-card__title {
  font-weight: 600;
  font-size: 15px;
  line-height: 1.35;
  text-decoration: none;
  color: var(--ce-ink);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.7em;
}

.product-card__title:hover {
  color: var(--ce-green);
}

.product-card__params {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 2px;
  align-content: start;
  font: 13px/1.35 var(--ce-font);
  font-variant-numeric: tabular-nums;
  color: var(--ce-muted);
  min-height: 2.6em;
  max-height: 2.8em;
  overflow: hidden;
}

.product-card__params--empty {
  min-height: 0;
  max-height: 0;
}

.product-card__buy {
  display: grid;
  gap: 8px;
  margin-top: auto;
  padding-top: 4px;
}

.product-card__buy .ce-tag,
.ce-tag--compact {
  justify-self: start;
  width: max-content;
  min-height: 24px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 560;
  border-radius: 999px;
}

.product-card__price-stack {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 8px;
}

.product-card__price {
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -0.03em;
  color: var(--ce-ink);
  font-variant-numeric: tabular-nums;
}

.product-card__cart,
.product-card .add-to-cart .ce-btn,
.product-card .add-to-cart__in-cart {
  width: 100%;
  min-height: 44px;
  justify-content: center;
  white-space: nowrap;
  box-shadow: none;
}

.product-card .add-to-cart {
  display: grid;
  gap: 6px;
}

.product-card .add-to-cart__link,
.product-card .add-to-cart__error {
  font-size: 12px;
  text-align: center;
}

.product-card .add-to-cart__error {
  margin: 0;
  color: #a33;
}

@media (max-width: 420px) {
  .product-card__cart-icon {
    display: none;
  }
}

/* Single-result / row template */
.product-card--row {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr) auto;
  align-items: center;
  height: auto;
}

.product-card--row .product-card__media-wrap {
  aspect-ratio: 1 / 1;
  width: 120px;
  height: 120px;
  flex: none;
  border-bottom: 0;
  border-right: 1px solid var(--ce-line);
}

.product-card--row .product-card__media {
  border: 0;
}

.product-card--row .product-card__body {
  grid-template-rows: auto auto auto;
  grid-template-columns: 1fr;
  padding: 14px 16px;
}

.product-card--row .product-card__title {
  height: auto;
  max-height: 2.6em;
  -webkit-line-clamp: 2;
}

.product-card--row .product-card__params {
  height: auto;
  max-height: none;
}

.product-card--row .product-card__price {
  font-size: 22px;
  justify-self: end;
  grid-column: 1;
}

.category-card--photo {
  position: relative;
  display: block;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  padding: 0;
  min-height: 0;
  text-decoration: none;
  background:
    radial-gradient(circle at 50% 35%, #ffffff 0%, #eef3ea 55%, #dfe8db 100%);
  border: 1px solid var(--ce-line);
  border-radius: var(--ce-radius);
  transition: border-color 0.2s ease, transform 0.25s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.25s ease;
}

.category-card--photo:hover {
  border-color: var(--ce-green);
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(20, 38, 31, 0.1);
}

.category-card__media,
.category-card__fallback {
  position: absolute;
  inset: 0;
}

.category-card__media {
  display: grid;
  place-items: center;
  padding: 18px 18px 42px;
}

.category-card__media img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  filter: drop-shadow(0 10px 18px rgba(20, 38, 31, 0.14));
}

.category-card__fallback {
  background: linear-gradient(145deg, #d7e8db, #8fb59a);
}

.category-card__shade {
  position: absolute;
  inset: auto 0 0;
  height: 46%;
  background: linear-gradient(180deg, rgba(246, 248, 242, 0), rgba(246, 248, 242, 0.98));
  pointer-events: none;
}

.category-card--photo .category-card__text {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
  display: grid;
  gap: 2px;
  padding: 12px 14px;
  min-width: 0;
}

.category-card--photo .category-card__text strong {
  font-size: 15px;
  color: var(--ce-ink);
}

.category-card--photo .category-card__text em {
  font-style: normal;
  color: var(--ce-muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.breadcrumb {
  margin: 8px 0 10px;
}
.breadcrumb a {
  color: var(--ce-green);
}

.product-page {
  display: grid;
  gap: 20px;
  margin-bottom: 40px;
}

.product-page__intro h1 {
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.18;
  letter-spacing: 0.01em;
  font-weight: 400;
  margin: 8px 0 0;
}

.product-page__buy {
  display: grid;
  grid-template-columns: minmax(240px, 0.9fr) minmax(280px, 1.1fr);
  gap: 20px;
  align-items: start;
}

.product-page__gallery {
  position: relative;
  display: block;
  width: 100%;
  overflow: hidden;
  background: #eef2ea;
  padding: 0;
}

.product-gallery {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.product-gallery__main {
  position: relative;
  aspect-ratio: 4 / 3;
  width: 100%;
  border-radius: 12px;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 40%, #fff 0%, #eef3ea 72%);
}

.product-gallery__main img,
.product-gallery--empty .product-card__placeholder {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  padding: 14px;
  box-sizing: border-box;
  margin: 0;
}

.product-gallery__thumbs {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 8px;
}

.product-gallery__thumb {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  padding: 4px;
  border-radius: 10px;
  border: 1px solid var(--ce-line);
  background: #fff;
  overflow: hidden;
  cursor: pointer;
}

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

.product-gallery__thumb.is-active {
  border-color: var(--ce-green);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--ce-green) 28%, transparent);
}

.product-gallery__thumb:hover {
  border-color: #8fb59a;
}

.product-page__info {
  display: grid;
  gap: 12px;
  align-content: start;
}

.product-page__price-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 12px 16px;
}

.product-page__hint {
  font: 14px/1.4 var(--ce-font);
  font-variant-numeric: tabular-nums;
}

.h-small {
  font-size: 18px;
  margin: 8px 0 0;
}

.product-page__details {
  padding: 20px;
  display: grid;
  gap: 12px;
}

.product-desc {
  display: grid;
  gap: 10px;
  max-width: 72ch;
  color: var(--ce-ink);
  font-size: 15px;
  line-height: 1.55;
}

.product-desc p {
  margin: 0;
}

.product-desc__list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.product-desc__list li {
  position: relative;
  padding-left: 14px;
  line-height: 1.45;
}

.product-desc__list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.55em;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--ce-green);
}

.chars-table .line {
  min-height: 40px;
  align-items: flex-start;
  padding: 10px 0;
}

.chars-table .line code {
  white-space: normal;
  text-align: right;
  max-width: 55%;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.mono {
  font-family: var(--ce-mono);
  font-variant-numeric: tabular-nums;
}

.filter-sheet {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: grid;
  align-items: end;
}

.filter-sheet__backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(16, 41, 31, 0.45);
}

.filter-sheet__panel {
  position: relative;
  z-index: 1;
  max-height: min(85dvh, 720px);
  overflow: auto;
  border-radius: 16px 16px 0 0;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom, 0px));
}

.filter-sheet__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.filter-sheet__actions {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.foot {
  margin-top: auto;
}

@media (max-width: 1100px) {
  .product-grid--home {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 1023px) {
  .catalog-layout {
    grid-template-columns: 1fr;
  }
  .desktop-filters {
    display: none;
  }
  .mobile-filter-bar {
    display: flex;
  }
  .catalog-search {
    max-width: none;
    width: 100%;
  }
  .category-grid--home {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }
}

@media (max-width: 900px) {
  .product-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 767px) {
  .product-page__buy {
    grid-template-columns: 1fr;
  }
  .product-page__gallery {
    aspect-ratio: 4 / 3;
    max-height: none;
  }
}

@media (max-width: 650px) {
  .category-grid--home {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .category-card--photo {
    aspect-ratio: 1 / 1;
  }

  .category-card--photo .category-card__text {
    padding: 10px;
  }

  .category-card--photo .category-card__text strong {
    font-size: 13px;
  }

  .product-grid,
  .product-grid--home {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .product-grid--home .product-card,
  .product-card--home {
    display: grid;
    grid-template-columns: 96px minmax(0, 1fr);
    height: auto;
  }
  .product-grid--home .product-card__media-wrap {
    width: 96px;
    height: 96px;
    aspect-ratio: 1 / 1;
    flex: none;
    border-bottom: 0;
    border-right: 1px solid var(--ce-line);
  }
  .product-grid--home .product-card__body {
    grid-template-rows: auto auto auto auto;
    padding: 12px;
  }
  .product-grid--home .product-card__title {
    height: auto;
    max-height: 2.6em;
    -webkit-line-clamp: 2;
    font-size: 15px;
  }
  .product-grid--home .product-card__params {
    height: auto;
    max-height: none;
    font-size: 13px;
  }
  .product-card--row {
    grid-template-columns: 88px minmax(0, 1fr);
  }
  .product-card--row .product-card__media-wrap {
    width: 88px;
    height: 88px;
  }
  .product-card--row .product-card__price {
    justify-self: start;
  }
}

@media (min-width: 768px) {
  .product-card--row {
    grid-template-columns: 120px minmax(0, 1fr) max-content;
  }
  .product-card--row .product-card__body {
    display: contents;
  }
  .product-card--row .product-card__title,
  .product-card--row .product-card__params,
  .product-card--row .ce-tag {
    grid-column: 2;
  }
  .product-card--row .product-card__title {
    padding: 16px 16px 0;
  }
  .product-card--row .product-card__params {
    padding: 0 16px;
  }
  .product-card--row .ce-tag {
    margin: 0 16px 16px;
    align-self: end;
  }
  .product-card--row .product-card__price {
    grid-column: 3;
    grid-row: 1 / span 3;
    align-self: center;
    padding-right: 20px;
    margin: 0;
  }
}
