:root {
  --bg: #ffffff;
  --ink: #141414;
  --muted: #6f6f6f;
  --line: #e9e9e7;
  --soft: #f5f5f3;
  --accent: #141414;
  --accent-ink: #ffffff;
  --radius: 14px;
  --gutter: 16px;
  --max: 1240px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overflow-x: hidden;
}
img { max-width: 100%; height: auto; display: block; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { line-height: 1.25; font-weight: 600; margin: 0; }
.wrap { max-width: var(--max); margin: 0 auto; padding: 0 var(--gutter); }

/* Шапка */
.top { border-bottom: 1px solid var(--line); background: var(--bg); }
.top-row { display: flex; align-items: center; gap: 24px; min-height: 68px; }
.logo { font-size: 20px; font-weight: 700; letter-spacing: -.02em; flex: none; }
.menu { display: flex; gap: 20px; font-size: 15px; flex: none; }
.menu a { color: var(--ink); white-space: nowrap; }
.menu a:hover, .menu a.is-active { color: var(--muted); }
.menu-cat-btn, .submenu { display: none; }
.top-phone { display: inline-flex; align-items: center; min-height: 44px; flex: none; font-size: 15px; font-weight: 600; white-space: nowrap; }
.top-phone:hover, .top-phone:focus-visible { text-decoration: underline; }
.search { position: relative; flex: 1 1 0; min-width: 0; margin: 0; }
.search input {
  width: 100%; height: 40px; padding: 0 14px; font: inherit; font-size: 15px;
  color: var(--ink); background: var(--soft); border: 1px solid transparent;
  border-radius: 999px; outline: none; -webkit-appearance: none; appearance: none;
}
.search input:focus { background: var(--bg); border-color: var(--ink); }
.suggest {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 30;
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(0,0,0,.08); overflow: hidden;
}
.suggest[hidden] { display: none; }
.suggest a { display: flex; align-items: center; gap: 12px; padding: 8px 12px; font-size: 14px; }
.suggest a:hover { background: var(--soft); }
.suggest img { width: 44px; height: 44px; object-fit: contain; border-radius: 8px; background: var(--soft); flex: none; }
.suggest .s-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggest .s-price { color: var(--muted); white-space: nowrap; }
.suggest .s-all { justify-content: center; color: var(--muted); border-top: 1px solid var(--line); padding: 11px; }
.suggest .s-none { padding: 14px; color: var(--muted); font-size: 14px; }
.burger {
  display: none; flex: none; width: 40px; height: 40px; padding: 0; background: none;
  border: 1px solid var(--line); border-radius: 50%; cursor: pointer; color: var(--ink);
}
.burger svg { display: block; margin: auto; }

/* Заголовки страниц */
main { padding: 28px 0 56px; }
.page-title { font-size: 28px; letter-spacing: -.01em; margin: 0 0 20px; }
.page-title small { font-size: 16px; color: var(--muted); font-weight: 400; margin-left: 6px; }

/* Категории */
.pills { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 0 0 28px; }
.pill {
  padding: 8px 16px; font-size: 15px; line-height: 1.3; white-space: nowrap;
  border: 1px solid var(--line); border-radius: 999px; background: var(--bg);
}
.pill:hover { border-color: var(--ink); }
.pill.is-active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* Сетка товаров */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 28px 20px; }
.catalog-consultation {
  grid-column: 1 / -1;
  padding: clamp(16px, 3vw, 32px);
  border: 1px solid var(--line);
  border-radius: 24px;
  background-color: #d9e1e9;
}
.catalog-consultation p { margin: 0; }
.catalog-consultation p + p { margin-top: 12px; }
.catalog-consultation-callout {
  padding: 12px 16px;
  border: 1px solid #bac8d5;
  border-radius: var(--radius);
  background-color: var(--bg);
}
.catalog-consultation a { font-weight: 600; text-decoration: underline; }
.card { display: flex; flex-direction: column; min-width: 0; }
.card-img { display: block; position: relative; aspect-ratio: 1; background: var(--soft); border-radius: var(--radius); overflow: hidden; }
.card-img img { width: 100%; height: 100%; object-fit: contain; transition: transform .25s; }
.card-img:hover img { transform: scale(1.03); }
.badge {
  position: absolute; left: 8px; top: 8px; right: 8px; width: fit-content; max-width: calc(100% - 16px);
  padding: 3px 9px; font-size: 12px; line-height: 1.3; background: var(--bg);
  border-radius: 999px; color: var(--ink);
}
.card-name {
  margin-top: 12px; font-size: 15px; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-foot { margin-top: auto; padding-top: 8px; display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.price { font-weight: 600; white-space: nowrap; }
.to-cart { font-size: 14px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; white-space: nowrap; }
.to-cart:hover { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.empty { color: var(--muted); padding: 32px 0; text-align: center; }

/* Карточка товара */
.crumbs { font-size: 14px; color: var(--muted); margin: 0 0 18px; }
.crumbs a:hover { color: var(--ink); }
.product { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 40px; align-items: start; }
.gallery { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; position: sticky; top: 20px; }
.gallery figure { margin: 0; background: var(--soft); border-radius: var(--radius); overflow: hidden; aspect-ratio: 1; }
.gallery img { width: 100%; height: 100%; object-fit: contain; }
.gallery figure:only-child { grid-column: 1 / -1; }
.info h1 { font-size: 28px; letter-spacing: -.01em; }
.tagline { color: var(--muted); margin: 8px 0 0; }
.buy { display: flex; align-items: center; flex-wrap: wrap; gap: 12px 18px; margin: 20px 0; }
.buy .price { font-size: 26px; flex-basis: 100%; }
.btn {
  display: inline-flex; align-items: center; height: 46px; padding: 0 28px;
  background: var(--accent); color: var(--accent-ink); border-radius: 999px; font-weight: 500;
}
.btn:hover { opacity: .85; }
.gallery-open {
  display: block; position: relative; width: 100%; height: 100%; padding: 0; border: 0;
  border-radius: inherit; background: none; color: var(--ink); cursor: zoom-in;
}
.gallery-open::after {
  content: '⤢'; position: absolute; right: 8px; bottom: 8px; display: grid; place-items: center;
  width: 32px; height: 32px; border: 1px solid var(--line); border-radius: 50%;
  background: var(--bg); font-size: 20px; line-height: 1;
}
.gallery-open:focus-visible { outline: 3px solid var(--ink); outline-offset: -3px; }
.photo-viewer {
  width: min(920px, calc(100% - 24px)); max-height: calc(100% - 24px); padding: 0;
  border: 0; border-radius: var(--radius); background: var(--bg); color: var(--ink);
  box-shadow: 0 12px 48px rgba(0,0,0,.25); overscroll-behavior: contain;
}
.photo-viewer::backdrop { background: rgba(0,0,0,.78); }
html:has(.photo-viewer[open]) { overflow: hidden; }
.photo-viewer-header, .photo-viewer-footer {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
}
.photo-viewer-header { justify-content: space-between; }
.photo-viewer-title { font-size: 16px; }
.photo-viewer-image {
  width: 100%; max-height: calc(100vh - 154px); max-height: calc(100dvh - 154px);
  background: var(--soft); object-fit: contain;
}
.photo-viewer-footer { justify-content: space-between; }
.photo-viewer-footer .btn { margin-left: auto; padding: 0 18px; white-space: nowrap; }
.photo-viewer-navigation { display: flex; align-items: center; gap: 4px; }
.photo-viewer-counter { font-size: 14px; color: var(--muted); white-space: nowrap; }
.photo-viewer-control {
  display: grid; place-items: center; flex: none; width: 44px; height: 44px; padding: 0;
  border: 1px solid var(--line); border-radius: 50%; background: var(--bg); color: var(--ink);
  font-family: inherit; font-size: 26px; line-height: 1; cursor: pointer;
}
.photo-viewer-control:hover { background: var(--soft); }
.link { text-decoration: underline; text-underline-offset: 3px; }
.note { background: var(--soft); border-radius: var(--radius); padding: 12px 14px; font-size: 14px; margin: 0 0 18px; }
.note b { display: block; margin-bottom: 2px; }
details { border-top: 1px solid var(--line); }
details:last-of-type { border-bottom: 1px solid var(--line); }
summary { cursor: pointer; list-style: none; padding: 14px 28px 14px 0; position: relative; font-weight: 500; }
summary::-webkit-details-marker { display: none; }
summary::after { content: "+"; position: absolute; right: 2px; top: 11px; font-size: 22px; font-weight: 300; color: var(--muted); }
details[open] summary::after { content: "−"; }
details .rte { padding-bottom: 16px; }
.docs { list-style: none; margin: 0; padding: 0; }
.docs li { border-bottom: 1px solid var(--line); }
.docs a { display: flex; justify-content: space-between; gap: 16px; padding: 12px 0; align-items: baseline; }
.docs a:hover .doc-name { text-decoration: underline; text-underline-offset: 3px; }
.doc-name { min-width: 0; overflow-wrap: anywhere; }
.doc-meta { color: var(--muted); font-size: 13px; white-space: nowrap; flex: none; }
.section { margin-top: 40px; }
.section-title { font-size: 20px; margin: 0 0 16px; }
.row { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(200px, 1fr); gap: 20px; overflow-x: auto; scroll-snap-type: x proximity; padding-bottom: 8px; }
.row .card { scroll-snap-align: start; }

/* Текст */
.rte { overflow-wrap: anywhere; }
.rte > :first-child { margin-top: 0; }
.rte > :last-child { margin-bottom: 0; }
.rte h2 { font-size: 21px; margin: 1.5em 0 .5em; }
.rte h3 { font-size: 18px; margin: 1.3em 0 .4em; }
.rte h4 { font-size: 16px; margin: 1.2em 0 .4em; }
.rte p { margin: 0 0 .85em; }
.rte ul, .rte ol { padding-left: 22px; margin: 0 0 .85em; }
.rte li { margin: .2em 0; }
.rte a { text-decoration: underline; text-underline-offset: 3px; }
.rte img { border-radius: var(--radius); margin: 8px 0; }
.rte figure { margin: 1em 0; }
.rte figcaption { font-size: 14px; color: var(--muted); }
.rte blockquote { margin: 1em 0; padding: 2px 0 2px 16px; border-left: 2px solid var(--ink); }
.rte hr { border: 0; border-top: 1px solid var(--line); margin: 1.5em 0; }
.table { overflow-x: auto; margin: 0 0 1em; }
.rte table { border-collapse: collapse; width: 100%; font-size: 14px; }
.rte td, .rte th { border: 1px solid var(--line); padding: 6px 9px; text-align: left; vertical-align: top; overflow-wrap: normal; }
.video { position: relative; aspect-ratio: 16 / 9; margin: 0 0 1em; border-radius: var(--radius); overflow: hidden; background: var(--soft); }
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.narrow { max-width: 760px; margin: 0 auto; }

/* Блог */
.blog-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 32px 24px; }
.post-img { display: block; aspect-ratio: 16 / 10; background: var(--soft); border-radius: var(--radius); overflow: hidden; }
.post-img img { width: 100%; height: 100%; object-fit: cover; }
.post-img-empty { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--muted); opacity: .5; font-size: 20px; font-weight: 700; letter-spacing: -.02em; }
.post-date { color: var(--muted); font-size: 14px; margin: 12px 0 2px; }
.post-title { font-size: 18px; line-height: 1.3; }
.post-title a:hover { color: var(--muted); }
.post-text { color: var(--muted); font-size: 15px; margin: 6px 0 0; }
.article h1 { font-size: 30px; letter-spacing: -.01em; margin: 4px 0 20px; }
.article-cover { border-radius: var(--radius); margin: 0 0 24px; width: 100%; }
.hub { list-style: none; margin: 0; padding: 0; }
.hub a { display: block; padding: 14px 0; border-bottom: 1px solid var(--line); }
.hub a:hover { color: var(--muted); }

/* Подвал */
.foot { border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; padding: 28px 0 36px; }
.foot-row { display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.foot nav { display: flex; flex-wrap: wrap; gap: 8px 20px; color: var(--ink); }
.foot p { margin: 0; }
.foot a:hover { text-decoration: underline; }

/* Кнопка «Наверх» */
.to-top {
  position: fixed; right: var(--gutter); bottom: calc(var(--gutter) + env(safe-area-inset-bottom)); z-index: 40;
  width: 46px; height: 46px; padding: 0; display: flex; align-items: center; justify-content: center;
  background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 50%; cursor: pointer;
  opacity: 0; visibility: hidden; transition: opacity .2s, visibility .2s;
}
.to-top.is-visible { opacity: 1; visibility: visible; }
.to-top.is-visible:hover { opacity: .85; }

/* Планшет: меню уходит под кнопку */
@media (max-width: 1080px) {
  .top-row { flex-wrap: wrap; gap: 10px 12px; padding-top: 12px; padding-bottom: 12px; }
  .logo { flex: 1; }
  .burger { display: block; }
  .search { order: 5; flex: 1 1 100%; }
  .menu { display: none; order: 6; flex: 1 1 100%; flex-direction: column; gap: 0; }
  .menu.is-open { display: flex; }
  .menu a { padding: 11px 0; border-top: 1px solid var(--line); }
  .menu-cat > a { display: none; }
  .menu-cat-btn {
    display: flex; justify-content: space-between; align-items: center; width: 100%;
    padding: 11px 0; font: inherit; font-size: 15px; color: var(--ink); text-align: left;
    background: none; border: 0; border-top: 1px solid var(--line); cursor: pointer;
  }
  .menu-cat-btn::after { content: "+"; font-size: 22px; font-weight: 300; line-height: 1; color: var(--muted); }
  .menu-cat-btn[aria-expanded="true"]::after { content: "−"; }
  .submenu:not([hidden]) { display: block; padding-bottom: 8px; }
  .menu .submenu a { display: block; padding: 8px 0 8px 14px; border-top: 0; white-space: normal; }
}

/* Телефон */
@media (max-width: 720px) {
  .top-row { column-gap: 8px; }
  main { padding: 20px 0 40px; }
  .page-title { font-size: 23px; margin-bottom: 14px; }
  .pills { flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto; margin: 0 calc(var(--gutter) * -1) 20px; padding: 0 var(--gutter) 4px; scrollbar-width: none; }
  .pills::-webkit-scrollbar { display: none; }
  .pill { flex: none; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px 12px; }
  .card-name { font-size: 14px; }
  .to-cart { width: 100%; text-align: center; padding: 8px 12px; }
  .card-foot { flex-direction: column; align-items: stretch; }
  .product { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .gallery { position: static; display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: 8px; margin: 0 calc(var(--gutter) * -1); padding: 0 var(--gutter); scrollbar-width: none; }
  .gallery::-webkit-scrollbar { display: none; }
  .gallery figure { flex: 0 0 86%; scroll-snap-align: center; }
  .gallery figure:only-child { flex-basis: 100%; }
  .info h1, .article h1 { font-size: 24px; }
  .buy .btn { flex: 1; justify-content: center; }
  .blog-list { grid-template-columns: minmax(0, 1fr); gap: 26px; }
  .row { grid-auto-columns: 62%; }
  .docs a { flex-direction: column; gap: 2px; }
}
