:root {
  --bg: #faf9f7;
  --surface: #ffffff;
  --ink: #151413;
  --muted: #6f6b66;
  --line: #e7e3dd;
  --chip: #f1eee9;
  --sale: #c2412d;
  --ok: #2f7d4f;
  --warn: #9a6a12;
  --radius: 12px;
  --gutter: 16px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--sans);
}
a { color: inherit; }
img { display: block; max-width: 100%; }
button, input, select { font: inherit; color: inherit; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 var(--gutter); }
.muted { color: var(--muted); }

/* ---------- Шапка ---------- */
.top {
  position: sticky; top: 0; z-index: 10;
  background: rgba(250, 249, 247, .92);
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.top .wrap { display: flex; align-items: center; gap: 12px; height: 58px; }
.shop { font: 600 21px/1.1 var(--serif); text-decoration: none; letter-spacing: -.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.nav { margin-left: auto; display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.nav a, .nav button {
  text-decoration: none; background: none; border: 0; cursor: pointer;
  padding: 8px 10px; border-radius: 999px; font-size: 14px;
}
.nav a:hover, .nav button:hover { background: var(--chip); }
.nav .label { display: none; }
@media (min-width: 640px) { .nav .label { display: inline; } }

/* ---------- Фильтры ---------- */
.filters { padding: 18px 0 6px; }
.search { display: flex; gap: 8px; }
.search input {
  flex: 1; min-width: 0; height: 44px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
}
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 12px 0 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { position: relative; flex-shrink: 0; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span {
  display: inline-block; padding: 7px 13px; border-radius: 999px; font-size: 14px;
  background: var(--chip); border: 1px solid transparent; cursor: pointer; white-space: nowrap;
}
.chip input:checked + span { background: var(--ink); color: #fff; }
.chip input:focus-visible + span { outline: 2px solid var(--ink); outline-offset: 2px; }
details.more-filters { margin-top: 6px; }
details.more-filters summary {
  cursor: pointer; list-style: none; display: inline-flex; gap: 6px; align-items: center;
  font-size: 14px; color: var(--muted); padding: 6px 0;
}
details.more-filters summary::-webkit-details-marker { display: none; }
.filter-grid { display: grid; gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 8px 0 4px; }
@media (min-width: 720px) { .filter-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.filter-grid .toggle { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.field select, .field input {
  width: 100%; height: 40px; padding: 0 10px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--ink); min-width: 0;
}
.toggle { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink); align-self: end; height: 40px; }
.count { font-size: 13px; color: var(--muted); padding: 10px 0 0; }

/* ---------- Сетка товаров ---------- */
.grid {
  display: grid; gap: 22px 12px; padding: 12px 0 40px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
@media (min-width: 720px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 30px 18px; } }
@media (min-width: 1024px) { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.card { position: relative; }
.card a { text-decoration: none; display: block; }
.ph {
  aspect-ratio: 3 / 4; border-radius: var(--radius); overflow: hidden;
  background: linear-gradient(135deg, #efebe5, #e4dfd7);
}
.ph img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s ease; }
.card:hover .ph img { transform: scale(1.03); }
.card .brand { margin-top: 10px; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.card .title {
  font-size: 14px; line-height: 1.35; margin-top: 2px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.price { margin-top: 6px; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.price b { font-size: 16px; font-weight: 650; }
.price s { color: var(--muted); font-size: 13px; }
.price.sale b { color: var(--sale); }
.badge {
  position: absolute; top: 10px; left: 10px; z-index: 1;
  padding: 3px 8px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--sale); color: #fff;
}
.badge.reserved { background: var(--ink); }
.badge.sold { background: var(--muted); }
.heart {
  position: absolute; top: 8px; right: 8px; z-index: 1;
  width: 36px; height: 36px; border-radius: 50%; border: 0; cursor: pointer;
  background: rgba(255, 255, 255, .88); display: grid; place-items: center;
  font-size: 18px; line-height: 1; color: var(--ink);
}
.heart.on { color: var(--sale); }
.more {
  grid-column: 1 / -1; justify-self: center; margin-top: 8px;
  padding: 12px 26px; border-radius: 999px; border: 1px solid var(--ink);
  background: transparent; cursor: pointer;
}
.more:hover { background: var(--ink); color: #fff; }
.empty { grid-column: 1 / -1; text-align: center; padding: 64px 16px; color: var(--muted); }
.empty h2 { font: 500 22px/1.3 var(--serif); color: var(--ink); margin: 0 0 6px; }

/* ---------- Карточка товара ---------- */
.item { display: grid; gap: 22px; padding: 18px 0 48px; }
@media (min-width: 880px) {
  .item { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 44px; padding-top: 28px; }
  .info { position: sticky; top: 84px; align-self: start; }
}
.gallery {
  display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x mandatory;
  margin: 0 calc(-1 * var(--gutter)); padding: 0 var(--gutter); scrollbar-width: none;
}
.gallery::-webkit-scrollbar { display: none; }
.gallery .ph { flex: 0 0 86%; scroll-snap-align: center; }
@media (min-width: 880px) {
  .gallery { display: grid; grid-template-columns: 1fr 1fr; overflow: visible; margin: 0; padding: 0; }
  .gallery .ph { flex: none; }
  .gallery .ph:first-child { grid-column: 1 / -1; }
}
.gallery-wrap { position: relative; }
.info .brand { font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.info h1 { font: 500 28px/1.2 var(--serif); margin: 6px 0 14px; letter-spacing: -.01em; }
.info .price b { font-size: 26px; }
.info .price s { font-size: 16px; }
.status { display: inline-block; margin-top: 12px; padding: 4px 10px; border-radius: 999px; font-size: 13px; }
.status.reserved { background: var(--ink); color: #fff; }
.status.sold { background: var(--chip); color: var(--muted); }
.sizes { margin: 22px 0 6px; }
.sizes h3 { font-size: 13px; font-weight: 600; margin: 0 0 8px; color: var(--muted); }
.size-list { display: flex; flex-wrap: wrap; gap: 6px; }
.size-list span { min-width: 44px; text-align: center; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); }
.actions { display: flex; gap: 10px; margin-top: 24px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 52px; padding: 0 24px; border-radius: 999px; border: 1px solid var(--ink);
  background: var(--ink); color: #fff; cursor: pointer; text-decoration: none; font-weight: 600;
}
.btn.primary { flex: 1; }
.btn.ghost { background: transparent; color: var(--ink); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn.square { width: 52px; padding: 0; font-size: 20px; }
.btn.square.on { color: var(--sale); }
.htmx-request.btn { opacity: .6; }
.note { margin: 14px 0 0; padding: 12px 14px; border-radius: 10px; font-size: 14px; }
.note.ok { background: #e8f3ec; color: var(--ok); }
.note.warn { background: #f8efdc; color: var(--warn); }
.hint { margin-top: 18px; font-size: 14px; color: var(--muted); }
.hint a { color: var(--ink); }
.desc { margin-top: 22px; white-space: pre-line; }

/* ---------- Страницы-формы ---------- */
.page { max-width: 560px; margin: 0 auto; padding: 32px 0 56px; }
.page h1 { font: 500 28px/1.2 var(--serif); margin: 0 0 8px; }
.page p { margin: 0 0 12px; }
.group { margin-top: 22px; }
.group h3 { font-size: 13px; font-weight: 600; margin: 0 0 8px; color: var(--muted); }
.group .chips { flex-wrap: wrap; overflow: visible; padding: 0; }
.subs { margin-top: 28px; border-top: 1px solid var(--line); }
.sub { display: flex; align-items: center; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.sub div { flex: 1; min-width: 0; }
.sub button { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 6px; }
.login-box { text-align: center; padding: 48px 0; }
.login-box .btn { margin-top: 18px; }
.spinner { margin: 22px auto 0; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--ink); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Подвал ---------- */
.foot { border-top: 1px solid var(--line); padding: 22px 0 32px; font-size: 13px; color: var(--muted); }
.foot a { color: var(--muted); }
.made { display: inline-flex; gap: 6px; align-items: center; }

/* ---------- Оплата ---------- */
.tabs { display: flex; gap: 6px; margin: 18px 0 4px; }
.tabs a { padding: 7px 14px; border-radius: 999px; background: var(--chip); text-decoration: none; font-size: 14px; }
.tabs a.on { background: var(--ink); color: #fff; }
.plans { display: grid; gap: 12px; margin-top: 14px; }
.plan-card { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.plan-card.current { border-color: var(--ink); }
.plan-head { display: flex; align-items: center; gap: 10px; }
.plan-head h2 { font: 500 22px/1.2 var(--serif); margin: 0; }
.tag { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--chip); color: var(--muted); }
.plan-card ul { margin: 10px 0 12px; padding-left: 18px; color: var(--muted); font-size: 14px; }
.option { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; margin-top: 8px; cursor: pointer; background: var(--surface); }
.option:has(input:checked) { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.option input { margin-top: 4px; accent-color: var(--ink); }
.option em { font-style: normal; color: var(--ok); font-size: 13px; margin-left: 4px; }
.steps { padding-left: 20px; }
.steps li { margin-bottom: 14px; }
.details { white-space: pre-wrap; font: 15px/1.5 var(--sans); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin: 8px 0 0; }
.code { font-size: 18px; letter-spacing: .04em; white-space: nowrap; }
.pay .price b { font-size: 24px; }

/* ---------- Поиск по фото ---------- */
.photo-btn { flex-shrink: 0; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%;
  border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-size: 18px; }
#grid.htmx-request { opacity: .5; transition: opacity .2s; }
.similar h2 { font: 500 22px/1.2 var(--serif); margin: 8px 0 0; }
