:root {
  --bg: #f6f6f7;
  --surface: #ffffff;
  --surface-soft: #f2f3f5;
  --text: #0f1115;
  --muted: #6f747e;
  --line: #e8e9ee;
  --line-strong: #d7d9e0;
  --accent: #16171c;
  --accent-hover: #2b2d35;
  --link: #2f6bff;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(15, 17, 21, 0.04);
  --shadow-md: 0 12px 32px rgba(15, 17, 21, 0.08);
  --shadow-lg: 0 30px 80px rgba(15, 17, 21, 0.28);
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

img {
  display: block;
  max-width: 100%;
}

.wrap {
  width: min(1200px, 100% - 48px);
  margin-inline: auto;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- шапка ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(12px);
}

.header-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  padding-block: 14px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  color: inherit;
  text-decoration: none;
}

.brand:hover .brand-name {
  opacity: 0.65;
}

.brand:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 6px;
  border-radius: 12px;
}

.brand-text {
  display: block;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.brand-name {
  margin: 0;
  font-size: 17px;
  font-weight: 650;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.brand-sub {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12.5px;
}

.header-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.brand-count {
  margin: 0;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
}

.header-link {
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  background: var(--surface);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.header-link:hover {
  border-color: var(--line-strong);
  background: var(--surface-soft);
}

/* ---------- поиск и сортировка ---------- */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-block: 26px 10px;
}

.search {
  position: relative;
  flex: 1 1 340px;
}

.search-icon {
  position: absolute;
  top: 50%;
  left: 15px;
  width: 17px;
  height: 17px;
  transform: translateY(-50%);
  color: var(--muted);
}

.search input {
  width: 100%;
  padding: 12px 16px 12px 43px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: inherit;
  font: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.search input::placeholder {
  color: #9aa0aa;
}

.search input:focus-visible,
.sort select:focus-visible {
  outline: none;
  border-color: var(--line-strong);
  box-shadow: 0 0 0 3px rgba(47, 107, 255, 0.12);
}

.sort {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 12.5px;
  color: var(--muted);
}

.sort-label {
  color: var(--muted);
}

.sort select {
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.result-line {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 12.5px;
}

/* ---------- сетка карточек ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(228px, 1fr));
  gap: 20px;
  padding-bottom: 12px;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.card:hover {
  transform: translateY(-2px);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-md);
}

.card:focus-within {
  outline: 2px solid var(--link);
  outline-offset: 2px;
}

/* обложки всегда квадратные — сетка выглядит ровно */
.card-media {
  position: relative;
  aspect-ratio: 1 / 1;
  background: var(--surface-soft);
}

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

.card-photos {
  position: absolute;
  right: 10px;
  bottom: 10px;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(15, 17, 21, 0.62);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  backdrop-filter: blur(4px);
}

.card-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 6px;
  padding: 14px 16px 16px;
}

.card-price {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.card-title {
  margin: 0;
  font-size: 13.5px;
  font-weight: 550;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-open {
  all: unset;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.card-open::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
}

.card-snippet {
  margin: 0;
  color: var(--muted);
  font-size: 12.5px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-meta {
  margin: auto 0 0;
  padding-top: 10px;
  color: #9aa0aa;
  font-size: 11.5px;
}

.empty {
  padding: 60px 0 80px;
  color: var(--muted);
  text-align: center;
}

/* ---------- подвал ---------- */

.site-footer {
  margin-top: 40px;
  padding-block: 26px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12.5px;
}

.site-footer p {
  margin: 0;
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  align-items: center;
  justify-content: space-between;
}

.footer-muted {
  color: #9aa0aa;
}

/* ---------- попап товара ---------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
}

.modal[hidden] {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 17, 21, 0.55);
  backdrop-filter: blur(3px);
}

.modal-card {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
  width: min(1120px, 100%);
  max-height: min(92vh, 900px);
  overflow: auto;
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 2;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.94);
  color: var(--text);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.modal-close:hover {
  background: var(--surface-soft);
}

.gallery {
  position: sticky;
  top: 0;
  align-self: start;
  padding: 16px;
  background: var(--surface-soft);
}

.gallery-main {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 14px;
  background: #e9eaee;
}

.gallery-main img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.gallery-zoom {
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: zoom-in;
}

.gallery-zoom:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: -2px;
}

.gallery-count {
  position: absolute;
  bottom: 10px;
  left: 10px;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(15, 17, 21, 0.62);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  backdrop-filter: blur(4px);
}

.gallery-count:empty {
  display: none;
}

.gallery-nav {
  position: absolute;
  top: 50%;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transform: translateY(-50%);
}

.gallery-nav.prev {
  left: 10px;
}

.gallery-nav.next {
  right: 10px;
}

.gallery-nav[hidden] {
  display: none;
}

.gallery-thumbs {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.gallery-thumbs button {
  flex: 0 0 64px;
  width: 64px;
  height: 50px;
  padding: 0;
  overflow: hidden;
  border: 2px solid transparent;
  border-radius: 10px;
  background: #dfe2e8;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.15s ease, border-color 0.15s ease;
}

.gallery-thumbs button:hover {
  opacity: 1;
}

.gallery-thumbs button[aria-current="true"] {
  border-color: var(--text);
  opacity: 1;
}

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

.gallery-thumbs:empty {
  display: none;
}

.modal-body {
  padding: 28px 28px 30px;
}

.modal-title {
  margin: 0 34px 12px 0;
  font-size: 20px;
  font-weight: 650;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.modal-price {
  margin: 0 0 12px;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.modal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin: 0 0 18px;
  padding: 0 0 18px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12.5px;
  list-style: none;
}

.modal-meta li:empty {
  display: none;
}

.modal-desc {
  margin-bottom: 6px;
  color: #2a2d34;
  white-space: pre-line;
  font-size: 14px;
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.modal-desc.is-expanded {
  display: block;
  -webkit-line-clamp: unset;
  overflow: visible;
}

.desc-toggle {
  display: block;
  margin: 0 0 4px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--link);
  font: inherit;
  font-size: 13px;
  font-weight: 550;
  cursor: pointer;
}

.desc-toggle:hover {
  text-decoration: underline;
}

.desc-toggle[hidden] {
  display: none;
}

.modal-video {
  margin-top: 18px;
  overflow: hidden;
  border-radius: 14px;
  background: #0b0c0f;
}

.modal-video[hidden] {
  display: none;
}

.modal-video iframe {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 0;
}

.modal-link {
  display: block;
  width: fit-content;
  margin: 22px auto 0;
  padding: 12px 24px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  transition: background 0.15s ease;
}

.modal-link:hover {
  background: var(--accent-hover);
}

/* ---------- полноэкранный просмотр фото ---------- */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 40px 64px;
}

.lightbox[hidden] {
  display: none;
}

.lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 9, 12, 0.95);
}

.lightbox-image {
  position: relative;
  max-width: 100%;
  max-height: calc(100vh - 100px);
  object-fit: contain;
  border-radius: 10px;
}

.lightbox-close,
.lightbox-nav {
  position: absolute;
  z-index: 1;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  cursor: pointer;
  transition: background 0.15s ease;
}

.lightbox-close:hover,
.lightbox-nav:hover {
  background: rgba(255, 255, 255, 0.24);
}

.lightbox-close {
  top: 18px;
  right: 20px;
  width: 40px;
  height: 40px;
  font-size: 22px;
  line-height: 1;
}

.lightbox-nav {
  top: 50%;
  width: 44px;
  height: 44px;
  font-size: 24px;
  line-height: 1;
  transform: translateY(-50%);
}

.lightbox-nav.prev {
  left: 16px;
}

.lightbox-nav.next {
  right: 16px;
}

.lightbox-nav[hidden] {
  display: none;
}

.lightbox-counter {
  position: absolute;
  bottom: 18px;
  left: 50%;
  margin: 0;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 12px;
  transform: translateX(-50%);
}

@media (max-width: 860px) {
  .modal {
    padding: 10px;
  }

  .modal-card {
    grid-template-columns: minmax(0, 1fr);
    max-height: 94vh;
  }

  .gallery {
    position: static;
  }

  .gallery-main {
    aspect-ratio: 1 / 1;
  }

  .modal-body {
    padding: 20px;
  }
}

@media (max-width: 720px) {
  .wrap {
    width: min(1200px, 100% - 28px);
  }

  .sort-label {
    display: none;
  }

  .header-inner {
    padding-block: 12px;
  }

  .grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
  }

  .card-body {
    padding: 10px 12px 12px;
  }

  .lightbox {
    padding: 16px;
  }

  .lightbox-nav {
    top: auto;
    bottom: 16px;
    transform: none;
  }
}
