/* ============================================================
   LIBRE RESALE — интернет-магазин. Чистый премиальный e-commerce
   в духе TSUM Collect: белый фон, sans-serif, минимализм.
   ============================================================ */

:root {
    --bg:      #ffffff;
    --ink:     #17130f;
    --muted:   #8a847c;
    --muted-2: #b6afa6;
    --line:    #eceae6;
    --soft:    #f7f6f3;
    --soft-2:  #f0eee9;
    --accent:  #a8874f;
    --sale:    #c0392b;
    --maxw:    1440px;
    --pad:     clamp(16px, 4vw, 56px);
    --ease:    cubic-bezier(.22,.61,.36,1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: var(--ink); background: var(--bg); line-height: 1.5;
    font-size: 15px; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button { font-family: inherit; cursor: pointer; }

/* ===== Плавные переходы между страницами ===== */
main { animation: pageIn .4s ease both; }
@keyframes pageIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
body.is-leaving { opacity: 0; transition: opacity .18s ease; }
@media (prefers-reduced-motion: reduce) {
    main { animation: none; }
    body.is-leaving { transition: none; opacity: 1; }
}
.wrap { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: var(--pad); }

/* ============================ ШАПКА ============================ */
.topbar { background: var(--ink); color: #d8d2c8; font-size: 12.5px; }
.topbar .wrap { display: flex; align-items: center; justify-content: space-between; height: 38px; }
.topbar a { color: #cfc9bf; transition: color .2s; }
.topbar a:hover { color: #fff; }
.topbar .t-left { display: flex; gap: 26px; }
.topbar .t-right { display: flex; gap: 8px; align-items: center; letter-spacing: .04em; color: var(--muted-2); }
.topbar .t-right b { color: var(--accent); font-weight: 600; }

/* контейнер не должен быть containing block — иначе sticky-шапка отлипает через ~160px скролла */
#app-header { display: contents; }
.header { position: sticky; top: -1px; z-index: 90; background: rgba(255,255,255,.96); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.header .wrap { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 30px; height: 76px; }
.logo { font-weight: 800; font-size: 22px; letter-spacing: .18em; white-space: nowrap; }
.logo .dot { color: var(--accent); }

.search { position: relative; max-width: 560px; width: 100%; justify-self: center; }
.search input {
    width: 100%; height: 44px; border: 1px solid var(--line); background: var(--soft);
    border-radius: 100px; padding: 0 20px 0 46px; font-size: 14px; color: var(--ink);
    outline: none; transition: border-color .2s, background .2s;
}
.search input:focus { border-color: var(--accent); background: #fff; }
.search .ic { position: absolute; left: 18px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 16px; pointer-events: none; }
.search-close { display: none; }

/* Панель живых подсказок поиска */
.search-panel { position: absolute; top: calc(100% + 10px); left: 0; right: 0; background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 18px 50px rgba(0,0,0,.14); padding: 6px; z-index: 95; display: none; max-height: 70vh; overflow-y: auto; }
.search-panel.show { display: block; }
.sug { display: flex; align-items: center; gap: 14px; padding: 8px 10px; border-radius: 10px; transition: background .15s; }
.sug:hover { background: var(--soft); }
.sug-ph { width: 46px; height: 58px; border-radius: 6px; background: var(--soft-2); overflow: hidden; flex: none; display: grid; place-items: center; color: var(--muted-2); }
.sug-ph img { width: 100%; height: 100%; object-fit: cover; }
.sug-txt { flex: 1; min-width: 0; }
.sug-brand { font-size: 13px; font-weight: 700; }
.sug-name { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sug-price { font-size: 14px; font-weight: 700; white-space: nowrap; }
.sug-all { display: block; padding: 12px 10px; font-size: 13px; font-weight: 600; color: var(--accent); border-top: 1px solid var(--line); margin-top: 4px; }
.sug-empty { padding: 22px 12px; text-align: center; color: var(--muted); font-size: 14px; }

.h-actions { display: flex; align-items: center; gap: 8px; }
.only-mobile { display: none; }
.acct-btn.authed { border-color: var(--ink); position: relative; }
.acct-btn.authed::after { content: ''; position: absolute; top: 2px; right: 2px; width: 9px; height: 9px; border-radius: 50%; background: #2e9e5b; border: 2px solid #fff; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 100px; overflow: hidden; background: var(--soft); }
.seg button { border: none; background: transparent; padding: 9px 16px; font-size: 13px; font-weight: 600; color: var(--muted); transition: background .2s, color .2s; }
.seg button.on { background: var(--ink); color: #fff; }
.icon-btn { width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 50%; background: #fff; display: grid; place-items: center; font-size: 17px; color: var(--ink); transition: background .2s, border-color .2s; }
.icon-btn:hover { background: var(--soft); border-color: var(--muted-2); }
.burger { display: none; background: none; border: none; font-size: 22px; }

/* Навигация категорий */
.catnav { border-bottom: 1px solid var(--line); background: #fff; }
.catnav .wrap { display: flex; align-items: center; gap: 30px; height: 48px; overflow-x: auto; scrollbar-width: none; }
.catnav .wrap::-webkit-scrollbar { display: none; }
.catnav a { font-size: 13px; letter-spacing: .05em; text-transform: uppercase; color: var(--ink); font-weight: 500; white-space: nowrap; position: relative; padding: 4px 0; transition: color .2s; }
.catnav a:hover { color: var(--accent); }
.catnav a.sale { color: var(--sale); }

/* ============================ КНОПКИ ============================ */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px; height: 52px; padding: 0 30px; border-radius: 100px; font-size: 15px; font-weight: 600; border: 1px solid transparent; transition: transform .25s var(--ease), background .25s, color .25s; }
.btn-dark { background: var(--ink); color: #fff; }
.btn-dark:hover { transform: translateY(-2px); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--ink); }
.btn-ghost:hover { background: var(--ink); color: #fff; }
.btn-block { width: 100%; }

/* ============================ HERO ============================ */
.hero { position: relative; height: clamp(420px, 56vw, 640px); border-radius: 0; overflow: hidden; background: var(--soft-2); }
.hero img { width: 100%; height: 100%; object-fit: cover; }
/* Баннер со своим текстом — показываем целиком, без обрезки по бокам */
.hero-banner { height: auto; background: var(--ink); }
.hero-banner img { width: 100%; height: auto; object-fit: contain; display: block; }
.hero-cap { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center; padding: var(--pad); background: linear-gradient(90deg, rgba(0,0,0,.42), rgba(0,0,0,.05) 55%, transparent); color: #fff; }
.hero-cap .eyebrow { color: #f0e6d2; }
.hero-cap h1 { font-size: clamp(30px, 4.6vw, 60px); font-weight: 700; line-height: 1.05; letter-spacing: -.01em; margin: 14px 0 18px; max-width: 640px; }
.hero-cap p { font-size: 17px; max-width: 440px; margin-bottom: 26px; color: #f3efe8; }

.eyebrow { font-size: 12px; letter-spacing: .26em; text-transform: uppercase; color: var(--accent); font-weight: 600; }

/* ============================ СЕКЦИИ ============================ */
/* только вертикальный отступ — иначе перебивает боковой padding у .section.wrap */
.section { padding-block: clamp(48px, 7vw, 88px); }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 30px; gap: 20px; }
.section-head h2 { font-size: clamp(22px, 2.8vw, 34px); font-weight: 700; letter-spacing: -.01em; }
.section-head .link { font-size: 14px; font-weight: 600; color: var(--muted); white-space: nowrap; transition: color .2s; }
.section-head .link:hover { color: var(--accent); }

/* ============================ СЕТКА ТОВАРОВ ============================ */
.grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: clamp(14px, 1.6vw, 26px) clamp(12px, 1.4vw, 22px); }
.grid.g5 { grid-template-columns: repeat(5, 1fr); }

.pcard { display: block; position: relative; }
.pcard .ph { position: relative; aspect-ratio: 3/4; background: var(--soft); overflow: hidden; border-radius: 6px; }
.pcard .ph img { width: 100%; height: 100%; object-fit: cover; transition: transform .7s var(--ease); }
.pcard:hover .ph img { transform: scale(1.045); }
.pcard .ph .noimg { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted-2); font-size: 30px; }
/* Универсальные плитки категорий: иконка на мягком фоне вместо фото товара */
.cat-card .cat-ph { display: grid; place-items: center; background: linear-gradient(135deg, #f4f2ee 0%, #eceae4 100%); }
.cat-card .cat-ph svg { width: 42%; height: 42%; color: #6b6257; transition: transform .5s var(--ease), color .3s; }
.cat-card:hover .cat-ph svg { transform: scale(1.08); color: var(--ink); }
/* Фото категории поверх иконки; если файла нет — img.onerror удаляет её и видна иконка */
.cat-card .cat-ph .cat-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: transform .7s var(--ease); }
.cat-card:hover .cat-ph .cat-img { transform: scale(1.05); }
/* Адаптивная сетка категорий: на телефоне 2 в ряд, на десктопе — все в строку.
   ID перебивает .grid/.grid.g5 и медиазапросы, поэтому картинки не разъезжаются. */
#catGrid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.cat-card .p-brand { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pcard .badge { position: absolute; top: 10px; left: 10px; background: var(--sale); color: #fff; font-size: 12px; font-weight: 700; padding: 4px 8px; border-radius: 4px; letter-spacing: .02em; }
.pcard .fav { position: absolute; top: 8px; right: 8px; width: 34px; height: 34px; border-radius: 50%; background: rgba(255,255,255,.9); display: grid; place-items: center; font-size: 15px; opacity: 0; transform: translateY(-4px); transition: opacity .25s, transform .25s; }
.pcard:hover .fav { opacity: 1; transform: none; }
.pcard .fav:hover { background: #fff; }
/* Сохранённый товар — сердечко всегда видно и подсвечено */
.pcard .fav.on { opacity: 1; transform: none; color: var(--sale); }
.pcard .p-brand { font-size: 13px; font-weight: 700; margin: 12px 0 3px; letter-spacing: .01em; }
.pcard .p-name { font-size: 13px; color: var(--muted); line-height: 1.35; height: 2.7em; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pcard .p-price { display: flex; align-items: baseline; gap: 8px; margin-top: 8px; }
.pcard .p-price .now { font-size: 15px; font-weight: 700; }
.pcard .p-price .old { font-size: 13px; color: var(--muted-2); text-decoration: line-through; }
.pcard .p-cond { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* Скелетоны */
.skeleton .ph::after { content: ''; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255,255,255,.6), transparent); transform: translateX(-100%); animation: shimmer 1.4s infinite; }
@keyframes shimmer { 100% { transform: translateX(100%); } }
.skeleton .l { height: 12px; background: var(--soft-2); border-radius: 5px; margin-top: 12px; }
.skeleton .l.s { width: 45%; }

.grid-empty { grid-column: 1/-1; text-align: center; color: var(--muted); padding: 60px 0; }

/* ============================ ПРЕИМУЩЕСТВА ============================ */
.usps { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--soft); }
.usps .wrap { display: grid; grid-template-columns: repeat(4, 1fr); }
.usp { padding: 34px 26px; border-right: 1px solid var(--line); }
.usp:last-child { border-right: none; }
.usp .ic { font-size: 24px; margin-bottom: 12px; }
.usp h3 { font-size: 16px; font-weight: 700; margin-bottom: 6px; }
.usp p { font-size: 13.5px; color: var(--muted); }

/* ============================ БРЕНДЫ ============================ */
.brand-rail { display: flex; flex-wrap: wrap; gap: 12px; }
.brand-rail a { padding: 12px 22px; border: 1px solid var(--line); border-radius: 100px; font-size: 14px; font-weight: 500; transition: border-color .2s, background .2s; }
.brand-rail a:hover { border-color: var(--ink); background: var(--ink); color: #fff; }

/* ============================ КАТАЛОГ ============================ */
.catalog-layout { display: grid; grid-template-columns: 260px 1fr; gap: 40px; align-items: start; padding-top: 32px; }
.filters { position: sticky; top: 140px; }
.filter-group { border-bottom: 1px solid var(--line); padding: 18px 0; }
.filter-group:first-child { padding-top: 0; }
.filter-group h4 { font-size: 13px; letter-spacing: .08em; text-transform: uppercase; margin-bottom: 14px; font-weight: 700; }
.filter-list { display: flex; flex-direction: column; gap: 9px; max-height: 260px; overflow-y: auto; }
.filter-list button, .filter-list a { text-align: left; background: none; border: none; font-size: 14px; color: var(--muted); padding: 2px 0; transition: color .2s; }
.filter-list button:hover, .filter-list a:hover { color: var(--ink); }
.filter-list .on { color: var(--ink); font-weight: 600; }

/* Chip-фильтры (бренд, цвет, размер, материал) — мультивыбор как в приложении */
.chips-filter { display: flex; flex-wrap: wrap; gap: 8px; max-height: 210px; overflow-y: auto; }
.chips-filter button { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line); background: #fff; border-radius: 100px; padding: 7px 14px; font-size: 13px; color: var(--ink); transition: border-color .15s, background .15s, color .15s; }
.chips-filter button:hover { border-color: var(--ink); }
.chips-filter button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.chips-filter .sw { width: 13px; height: 13px; border-radius: 50%; border: 1px solid rgba(0,0,0,.18); flex: none; }

/* Шапка и кнопка «Показать» — видны только в мобильном drawer */
.filters-head { display: none; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.filters-head span { font-size: 18px; font-weight: 700; }
.filters-close { background: none; border: none; font-size: 22px; color: var(--muted); line-height: 1; padding: 4px; }
.filters-done { display: none; width: 100%; height: 50px; margin-top: 18px; border: none; border-radius: 12px; background: var(--ink); color: #fff; font-size: 15px; font-weight: 700; }
.price-row { display: flex; gap: 10px; align-items: center; }
.price-row input { width: 100%; height: 40px; border: 1px solid var(--line); border-radius: 8px; padding: 0 12px; font-size: 14px; outline: none; }
.price-row input:focus { border-color: var(--accent); }
.filter-apply { margin-top: 12px; height: 42px; border-radius: 8px; background: var(--ink); color: #fff; border: none; font-size: 13px; font-weight: 600; width: 100%; }
.filter-reset { margin-top: 8px; background: none; border: none; color: var(--muted); font-size: 13px; text-decoration: underline; }

.toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; gap: 16px; flex-wrap: wrap; }
.toolbar h1 { font-size: clamp(22px, 3vw, 32px); font-weight: 700; }
.toolbar .count { color: var(--muted); font-size: 14px; margin-left: 12px; font-weight: 400; white-space: nowrap; }
.sortsel { height: 42px; border: 1px solid var(--line); border-radius: 8px; padding: 0 34px 0 14px; font-size: 14px; color: var(--ink); outline: none; appearance: none; -webkit-appearance: none; -moz-appearance: none; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5l3.5 3.5 3.5-3.5' fill='none' stroke='%238a847c' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 13px center; cursor: pointer; }
.filter-toggle { display: none; }
.load-more { text-align: center; margin-top: 44px; }

.breadcrumb { display: flex; gap: 8px; font-size: 13px; color: var(--muted); margin: 22px 0 6px; flex-wrap: wrap; }
.breadcrumb a:hover { color: var(--ink); }
.breadcrumb span { color: var(--muted-2); }

/* Активные фильтры-чипсы */
.active-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.active-chips .c { display: inline-flex; align-items: center; gap: 6px; background: var(--soft-2); border-radius: 100px; padding: 6px 12px; font-size: 13px; }
.active-chips .c b { font-weight: 600; }
.active-chips .c button { background: none; border: none; color: var(--muted); font-size: 14px; line-height: 1; }

/* ============================ КАРТОЧКА ТОВАРА ============================ */
.product { display: grid; grid-template-columns: 1.15fr .85fr; gap: 50px; padding-top: 20px; align-items: start; }
.gallery { display: grid; grid-template-columns: 76px 1fr; gap: 14px; position: sticky; top: 140px; }
.thumbs { display: flex; flex-direction: column; gap: 10px; }
.thumbs button { width: 76px; aspect-ratio: 3/4; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: var(--soft); padding: 0; }
.thumbs button.on { border-color: var(--ink); }
.thumbs img { width: 100%; height: 100%; object-fit: cover; }
.gallery-main { aspect-ratio: 3/4; background: var(--soft); border-radius: 10px; overflow: hidden; }
.gallery-main img { width: 100%; height: 100%; object-fit: cover; }

.pd-brand { font-size: 15px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.pd-name { font-size: clamp(22px, 3vw, 30px); font-weight: 500; margin: 8px 0 18px; line-height: 1.2; }
.pd-price { display: flex; align-items: baseline; gap: 14px; margin-bottom: 8px; }
.pd-price .now { font-size: 28px; font-weight: 700; }
.pd-price .old { font-size: 18px; color: var(--muted-2); text-decoration: line-through; }
.pd-price .disc { background: var(--sale); color: #fff; font-size: 13px; font-weight: 700; padding: 3px 8px; border-radius: 5px; }
.pd-cond { color: var(--muted); font-size: 14px; margin-bottom: 24px; }
.pd-cta { display: flex; flex-direction: column; gap: 10px; margin-bottom: 26px; }
.pd-note { display: flex; gap: 12px; align-items: center; font-size: 13px; color: var(--muted); padding: 13px 0; border-top: 1px solid var(--line); line-height: 1.45; }
.pd-note .ic { flex: none; width: 20px; text-align: center; font-size: 15px; line-height: 1; color: var(--accent); }
.pd-specs { margin-top: 24px; border-top: 1px solid var(--line); padding-top: 22px; }
.pd-specs h3 { font-size: 15px; font-weight: 700; margin-bottom: 14px; }
.pd-specs dl { display: grid; grid-template-columns: 130px 1fr; gap: 10px 16px; font-size: 14px; }
.pd-specs dt { color: var(--muted); }
.pd-desc { margin-top: 24px; font-size: 14.5px; color: #3d3833; line-height: 1.7; white-space: pre-line; }

/* ============================ ПОДВАЛ ============================ */
footer { background: var(--ink); color: #cfc9bf; padding: 64px 0 32px; margin-top: 40px; }
.foot-grid { display: grid; grid-template-columns: 1.6fr 1fr 1fr 1fr; gap: 40px; }
footer .logo { color: #fff; margin-bottom: 14px; display: inline-block; }
footer .about { font-size: 13.5px; line-height: 1.7; color: #b6afa6; max-width: 320px; }
.foot-req { font-size: 12px; color: #86807880; color: #857f76; line-height: 1.8; margin-top: 16px; }
.foot-col h4 { color: #fff; font-size: 13px; letter-spacing: .08em; text-transform: uppercase; margin-bottom: 16px; }
.foot-col a { display: block; font-size: 13.5px; margin-bottom: 11px; color: #cfc9bf; transition: color .2s; }
.foot-col a:hover { color: var(--accent); }
.store-badges { display: flex; gap: 10px; margin-top: 6px; flex-wrap: wrap; }
.store-badge { display: inline-flex; align-items: center; gap: 8px; background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.16); padding: 10px 14px; border-radius: 10px; font-size: 13px; }
.store-badge small { display: block; font-size: 10px; color: #928c82; }
.foot-bottom { border-top: 1px solid rgba(255,255,255,.1); margin-top: 44px; padding-top: 22px; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px; font-size: 12.5px; color: #857f76; }

/* ============================ ЮРИДИЧЕСКИЕ ============================ */
.legal { padding: 46px 0 70px; }
.legal .inner { max-width: 820px; }
.legal .back { font-size: 14px; color: var(--accent); font-weight: 600; margin-bottom: 22px; display: inline-block; }
.legal h1 { font-size: clamp(28px, 4vw, 42px); font-weight: 700; margin-bottom: 8px; }
.legal .updated { color: var(--muted); font-size: 14px; margin-bottom: 34px; }
.legal h2 { font-size: 20px; font-weight: 700; margin: 34px 0 12px; }
.legal p { color: #3d3833; margin-bottom: 14px; white-space: pre-line; }
.legal .card-box { background: var(--soft); border: 1px solid var(--line); border-radius: 12px; padding: 24px 26px; margin-bottom: 28px; }

/* ============================ АДАПТИВ ============================ */
@media (max-width: 1080px) {
    .grid, .grid.g5 { grid-template-columns: repeat(3, 1fr); }
    .product { grid-template-columns: 1fr; gap: 30px; }
    .gallery { position: static; }
    .catalog-layout { grid-template-columns: 1fr; }
    .filters { position: fixed; inset: 0 0 0 auto; width: min(90vw, 360px); background: #fff; z-index: 120; padding: 22px; overflow-y: auto; transform: translateX(100%); transition: transform .3s var(--ease); box-shadow: -10px 0 40px rgba(0,0,0,.15); }
    .filters.open { transform: none; }
    /* В мобильном drawer крупнее пункты и выше контраст — чтобы легко читать и попадать пальцем */
    .filters .filter-list button, .filters .filter-list a { font-size: 15px; padding: 9px 0; color: var(--ink); }
    .filters .filter-list .on { font-weight: 700; }
    .filters-head { display: flex; }
    .filters-done { display: block; }
    .filter-toggle { display: inline-flex; align-items: center; gap: 8px; height: 42px; padding: 0 18px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-size: 14px; font-weight: 600; }
    .filters-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.28); z-index: 110; }
    .filters-backdrop.show { display: block; }
}
@media (max-width: 900px) {
    .header .wrap { grid-template-columns: auto 1fr auto; height: 64px; gap: 10px; }
    .search { display: none; }
    .header.search-open .search { display: flex; align-items: center; gap: 12px; position: absolute; left: 0; right: 0; top: 100%; padding: 12px var(--pad); background: #fff; border-bottom: 1px solid var(--line); max-width: none; justify-self: stretch; }
    .header.search-open .search input { flex: 1; }
    .header.search-open .search .ic { left: calc(var(--pad) + 18px); }
    .header.search-open .search-close { display: inline-block; background: none; border: none; color: var(--muted); font-size: 14px; white-space: nowrap; }
    .header.search-open .search-panel { left: var(--pad); right: var(--pad); }
    .seg { display: none; }
    .only-mobile { display: grid; }
    .usps .wrap { grid-template-columns: repeat(2, 1fr); }
    .usp:nth-child(2) { border-right: none; }
    .foot-grid { grid-template-columns: 1fr 1fr; }
    .burger { display: block; }
    .topbar .t-right { display: none; }
    .logo { font-size: 18px; letter-spacing: .12em; }
}
@media (max-width: 620px) {
    /* На узких экранах поднимаем нижнюю границу бокового отступа,
       чтобы карточки товара не липли к краям (шапка тоже использует --pad). */
    :root { --pad: clamp(20px, 4vw, 56px); }
    .grid, .grid.g5 { grid-template-columns: repeat(2, 1fr); gap: 14px 12px; }
    .usps .wrap { grid-template-columns: 1fr; }
    .usp { border-right: none; border-bottom: 1px solid var(--line); }
    .foot-grid { grid-template-columns: 1fr; gap: 26px; }
    .pd-specs dl { grid-template-columns: 110px 1fr; }
}

/* ============================ МОДАЛКА ВХОДА ============================ */
.modal-backdrop { display: none; position: fixed; inset: 0; background: rgba(15,12,9,.5); backdrop-filter: blur(2px); z-index: 200; }
.modal-backdrop.show { display: block; }
.modal { display: none; position: fixed; z-index: 210; top: 50%; left: 50%; transform: translate(-50%, -48%); width: min(92vw, 400px); background: #fff; border-radius: 18px; padding: 34px 30px 28px; box-shadow: 0 30px 80px rgba(0,0,0,.3); }
.modal.show { display: block; animation: modalIn .25s var(--ease); }
@keyframes modalIn { from { opacity: 0; transform: translate(-50%, -44%); } to { opacity: 1; transform: translate(-50%, -50%); } }
.modal-close { position: absolute; top: 16px; right: 16px; background: none; border: none; font-size: 20px; color: var(--muted); line-height: 1; }
.auth-title { font-size: 22px; font-weight: 700; margin-bottom: 8px; }
.auth-sub { font-size: 14px; color: var(--muted); margin-bottom: 20px; line-height: 1.5; }
.auth-sub b { color: var(--ink); }
.auth-input { width: 100%; height: 52px; border: 1px solid var(--line); border-radius: 12px; padding: 0 16px; font-size: 16px; outline: none; transition: border-color .2s; background: var(--soft); }
.auth-input:focus { border-color: var(--accent); background: #fff; }
.code-cells { display: flex; gap: 10px; justify-content: center; margin: 4px 0 2px; }
.code-cell { width: 56px; height: 60px; border: 1px solid var(--line); border-radius: 12px; background: var(--soft); text-align: center; font-size: 26px; font-weight: 700; color: var(--ink); outline: none; transition: border-color .2s, background .2s; }
.code-cell:focus { border-color: var(--accent); background: #fff; }
.auth-err { color: var(--sale); font-size: 13px; min-height: 18px; margin: 8px 2px; }
.modal .btn { margin-top: 4px; }
.auth-back { display: block; width: 100%; text-align: center; background: none; border: none; color: var(--muted); font-size: 14px; margin-top: 14px; }
.auth-note { font-size: 12px; color: var(--muted-2); line-height: 1.6; margin-top: 16px; text-align: center; }
.auth-note a { color: var(--muted); text-decoration: underline; }

/* Мобильное меню */
.mmenu { position: fixed; inset: 0 auto 0 0; width: min(86vw, 330px); background: #fff; z-index: 130; transform: translateX(-100%); transition: transform .3s var(--ease); padding: 22px; overflow-y: auto; box-shadow: 10px 0 40px rgba(0,0,0,.15); }
.mmenu #mAuth { color: var(--accent); font-weight: 700; }
.mmenu.open { transform: none; }
.mmenu .m-close { background: none; border: none; font-size: 24px; margin-bottom: 20px; }
.mmenu a { display: block; padding: 13px 0; font-size: 16px; border-bottom: 1px solid var(--line); }
.mbackdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 125; }
.mbackdrop.show { display: block; }

/* ---------- Кнопка корзины в шапке ---------- */
.cart-btn { position: relative; text-decoration: none; }
.cart-count { position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; line-height: 1; }
.cart-count[hidden] { display: none; }

/* ---------- Переключатель способа доставки в оформлении заказа ---------- */
.dm-seg { display: flex; gap: 6px; background: var(--soft); border: 1px solid var(--line); border-radius: 12px; padding: 4px; margin: 4px 0 8px; }
.dm-seg button { flex: 1; height: 40px; border: none; background: transparent; border-radius: 9px; font-size: 14px; font-weight: 600; color: var(--muted); transition: background .2s, color .2s; }
.dm-seg button.on { background: var(--ink); color: #fff; }

/* ---------- Кнопка «В корзину» на карточке товара ---------- */
.btn.added { border-color: var(--accent); color: var(--accent); }

/* ---------- Кнопка избранного в шапке ---------- */
.fav-btn { position: relative; text-decoration: none; }

/* ---------- Страница «Избранное» ---------- */
.fav-card { position: relative; display: flex; flex-direction: column; }
.fav-card .p-brand { display: block; text-decoration: none; color: inherit; }
.fav-card .p-name { text-decoration: none; color: var(--muted); }
.fav-remove { position: absolute; top: 8px; right: 8px; width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--line); background: rgba(255,255,255,.92); color: var(--muted); font-size: 14px; line-height: 1; display: grid; place-items: center; cursor: pointer; z-index: 2; transition: background .2s, color .2s, border-color .2s; }
.fav-remove:hover { background: #fff; color: var(--ink); border-color: var(--muted-2); }
.fav-add { margin-top: 12px; height: 42px; font-size: 14px; }

/* ---------- Страница корзины ---------- */
.cart-layout { display: grid; grid-template-columns: 1fr 340px; gap: 30px; align-items: start; margin: 20px 0 60px; }
.cart-list { display: flex; flex-direction: column; gap: 14px; }
.cart-item { display: grid; grid-template-columns: 22px 84px 1fr auto; gap: 16px; align-items: center; border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.cart-check { display: grid; place-items: center; }
.cart-check input, #cartSelAll { width: 18px; height: 18px; accent-color: var(--ink); cursor: pointer; }
.cart-selall { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); margin: 0 2px 12px; cursor: pointer; user-select: none; }
.btn:disabled { opacity: .45; pointer-events: none; }
.cart-ph { width: 84px; height: 108px; border-radius: 8px; overflow: hidden; background: var(--soft); display: grid; place-items: center; }
.cart-ph img { width: 100%; height: 100%; object-fit: cover; }
.cart-ph .noimg { color: var(--muted-2); font-size: 26px; }
.cart-info { display: flex; flex-direction: column; gap: 4px; }
.cart-brand { font-size: 14px; font-weight: 700; color: var(--ink); }
.cart-name { font-size: 13px; color: var(--muted); }
.cart-price { font-size: 16px; font-weight: 700; margin-top: 4px; }
.cart-remove { width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 50%; background: #fff; color: var(--muted); font-size: 14px; align-self: start; transition: border-color .2s, color .2s; }
.cart-remove:hover { border-color: var(--ink); color: var(--ink); }
.cart-summary { border: 1px solid var(--line); border-radius: 16px; padding: 24px; background: var(--soft); position: sticky; top: 90px; }
.cart-summary h3 { font-size: 18px; font-weight: 700; margin-bottom: 18px; }
.cart-sum-row { display: flex; justify-content: space-between; font-size: 14px; padding: 8px 0; }
.cart-sum-row.muted { color: var(--muted); }
.cart-sum-total { display: flex; justify-content: space-between; align-items: baseline; font-size: 18px; font-weight: 700; padding: 14px 0 18px; margin-top: 6px; border-top: 1px solid var(--line); }
.cart-note { font-size: 12px; color: var(--muted-2); line-height: 1.6; margin-top: 14px; text-align: center; }

/* ---------- Страница «Мои заказы» ---------- */
.orders-list { display: flex; flex-direction: column; gap: 14px; margin: 20px 0 24px; max-width: 640px; }
.order-card { border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; }
.order-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.order-id { font-size: 15px; font-weight: 700; }
.order-date { font-size: 13px; color: var(--muted); margin-top: 2px; }
.order-status { font-size: 12px; font-weight: 700; padding: 5px 12px; border-radius: 100px; background: var(--soft-2); color: var(--muted); white-space: nowrap; }
.order-status.ok { background: #eaf5ec; color: #2e9e52; }
.order-status.err { background: #fbeceb; color: var(--sale); }
.order-foot { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.order-sum { font-size: 17px; font-weight: 700; }
.order-track { font-size: 13px; color: var(--ink); }
.order-track.muted { color: var(--muted-2); }

/* ---------- Профиль: ссылки ---------- */
.profile-links { display: flex; flex-direction: column; gap: 2px; margin: 6px 0 14px; }
.profile-links a { display: flex; align-items: center; justify-content: space-between; padding: 13px 4px; font-size: 15px; color: var(--ink); border-bottom: 1px solid var(--line); }
.profile-links a:hover { color: var(--accent); }
.profile-links a::after { content: "›"; color: var(--muted-2); font-size: 18px; }

/* ---------- Страница результата оплаты ---------- */
.pay-result { max-width: 520px; margin: 80px auto; text-align: center; padding: 0 20px; }
.pay-icon { width: 76px; height: 76px; border-radius: 50%; background: var(--soft); display: grid; place-items: center; font-size: 34px; color: var(--muted); margin: 0 auto 24px; }
.pay-icon.ok { background: #eaf5ec; color: #2e9e52; }
.pay-icon.err { background: #fbeceb; color: var(--sale); }
.pay-result h1 { font-size: 26px; font-weight: 700; margin-bottom: 12px; }
.pay-result p { font-size: 15px; color: var(--muted); line-height: 1.6; }
.pay-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 28px; }

@media (max-width: 820px) {
    .cart-layout { grid-template-columns: 1fr; }
    .cart-summary { position: static; }
}
