/* ---------- Шапка ---------- */
header {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 40;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.header__top {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 68px;
}

.page-title {
  margin-bottom: 20px;
}

.logo {
  font-family: Archivo, sans-serif;
  font-weight: 800;
  font-size: 25px;
  letter-spacing: -.04em;
  white-space: nowrap;
}

.logo span {
  color: var(--accent);
}

.btn-catalog {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: var(--ink);
  color: var(--bg);
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 16px;
}

.btn-catalog svg {
  width: 16px;
  height: 16px;
}

.search {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-soft);
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 0 14px;
  height: 46px;
  min-width: 120px;
}

.search:focus-within {
  border-color: var(--ink);
}

.search input {
  flex: 1;
  border: 0;
  background: none;
  outline: none;
  font: inherit;
  color: var(--ink);
  min-width: 0;
  font-size: 16px;
}

.icons {
  display: flex;
  align-items: center;
  gap: 6px;
}

.icon-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 10px;
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--ink-2);
  position: relative;
}

.icon-btn:hover {
  background: var(--bg-soft);
  color: var(--ink);
}

.icon-btn svg {
  width: 22px;
  height: 22px;
}

/* Кнопка поиска нужна только в мобильной шапке */
.search-toggle {
  display: none;
}

.badge {
  position: absolute;
  top: 2px;
  right: 4px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  display: grid;
  place-items: center;
}

/* ---------- Блок категорий ---------- */
.categories {
  position: sticky;
  top: calc(68px + env(safe-area-inset-top, 0px)); /* Прилипает ровно под шапкой (высота шапки 68px) */
  z-index: 30;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  margin-bottom: 20px;
}

.categories .navline {
  display: flex;
  align-items: center;
  gap: 24px;
  height: 48px;
  overflow-x: auto;
  scrollbar-width: none;
}

.categories .navline::-webkit-scrollbar {
  display: none;
}

.categories .category-link {
  display: inline-flex;
  align-items: center;
  height: 100%;
  padding: 0 2px;
  font-size: 16px;
  font-weight: 500;
  color: var(--ink-2);
  white-space: nowrap;
  text-decoration: none;
  box-sizing: border-box;
  border-bottom: 2px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.categories .category-link:hover {
  color: var(--ink);
}

.categories .category-link.active {
  opacity: 1;
  color: var(--ink);
  font-weight: 600;
  /* border-bottom-color: var(--ink); */
}

/* ---------- Выезжающий каталог ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  opacity: 0;
  visibility: hidden;
  transition: opacity .2s;
  z-index: 50;
}

.overlay.open {
  opacity: 1;
  visibility: visible;
}

.drawer {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  width: min(420px, 88vw);
  background: var(--bg);
  z-index: 60;
  transform: translateX(-100%);
  transition: transform .25s ease;
  overflow-y: auto;
  padding: calc(env(safe-area-inset-top, 0px) + 18px) 20px 40px;
}

.drawer.open {
  transform: none;
}

.drawer__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.drawer__head h2 {
  font-size: 23px;
}

.brandlist {
  list-style: none;
  margin: 0;
  padding: 0;
}

.brandlist > li {
  border-bottom: 1px solid var(--line);
}

.brandlist summary {
  padding: 12px 0;
  font-weight: 600;
  font-size: 17px;
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brandlist summary::-webkit-details-marker {
  display: none;
}

.brandlist summary::after {
  content: "+";
  color: var(--ink-2);
  font-weight: 400;
}

.brandlist details[open] summary::after {
  content: "–";
}

.brandlist .sub {
  padding: 0 0 12px;
  display: grid;
  gap: 8px;
}

.brandlist .sub a {
  color: var(--ink-2);
  font-size: 16px;
}

.brandlist .sub a:hover {
  color: var(--ink);
}

.brandlist > li > a {
  display: block;
  padding: 12px 0;
  font-weight: 600;
  font-size: 17px;
}

/* ---------- Мобильная адаптивность ---------- */
@media (max-width: 640px) {
  /* Каталог слева, логотип по центру, поиск/профиль/корзина справа.
     Боковые колонки 1fr одинаковой ширины — логотип стоит ровно посередине */
  .header__top {
    position: relative;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    height: 60px;
    gap: 8px;
  }

  .btn-catalog {
    grid-column: 1;
    grid-row: 1;
    justify-self: start;
    padding: 10px 14px;
  }

  .logo {
    grid-column: 2;
    grid-row: 1;
    font-size: 22px;
  }

  .icons {
    grid-column: 3;
    grid-row: 1;
    justify-self: end;
    gap: 0;
  }

  .icon-btn {
    padding: 6px;
  }

  .badge {
    top: 0;
    right: 0;
  }

  .search-toggle {
    display: flex;
  }

  .search-toggle[aria-expanded="true"] {
    background: var(--bg-soft);
    color: var(--ink);
  }

  .btn-catalog span,
  .icon-btn span {
    display: none;
  }

  /* Строка поиска выпадает под шапкой поверх полосы категорий */
  .search {
    display: none;
    position: absolute;
    top: 100%;
    left: -16px;
    right: -16px;
    height: auto;
    padding: 8px 16px;
    background: var(--bg);
    border: 0;
    border-bottom: 1px solid var(--line);
    border-radius: 0;
    z-index: 35;
  }

  .search.open {
    display: flex;
  }

  .search:focus-within {
    border-color: var(--line);
  }

  .search svg {
    display: none;
  }

  .search input {
    height: 44px;
    padding: 0 14px;
    background: var(--bg-soft);
    border: 1px solid transparent;
    border-radius: var(--radius);
  }

  .search input:focus {
    border-color: var(--ink);
  }

  .categories {
    top: calc(60px + env(safe-area-inset-top, 0px)); /* Корректировка высоты прилипания под мобильный хедер */
  }

  .categories .navline {
    height: 44px;
    gap: 18px;
  }

  .categories .category-link {
    font-size: 15px;
  }
}