/*
  Витрина Marketplace. Одна вёрстка на все бренды.

  Цвета, радиусы и шрифты берутся из переменных, которые подставляет тема
  бренда (apps/brands/themes/). Здесь не должно остаться ни одного цвета
  строкой: захардкоженный #333 сделает тёмную тему нечитаемой.

  Значения ниже — запасные, ровно как в themes/base.py NEUTRAL. Они нужны на
  случай, если инлайновый блок темы не применился; тест проверяет, что все
  токены здесь перечислены.
*/

:root {
  --bg: #f4f5f6;
  --bg-image: none;
  --surface: #ffffff;
  --surface-2: #eef0f2;
  --ink: #16181b;
  --ink-soft: #333a41;
  --muted: #6a7178;
  --line: #dfe2e6;

  --brand: #4c5661;
  --on-brand: #ffffff;
  --accent: #4c5661;
  --accent-solid: #4c5661;
  --accent-tint: #eef0f2;

  --ok: #2f7d53;
  --ok-tint: #e6f2ea;
  --warn: #a84d18;
  --warn-tint: #fbeee4;
  --danger: #a82720;
  --danger-tint: #f9e7e5;

  --sel: #eef0f2;
  --sel-line: #4c5661;
  --sel-width: 2px;
  --sel-glow: 0 0 #0000;
  --sel-ink: #4c5661;
  --sel-text: #16181b;
  --sel-muted: #6a7178;

  --radius: 8px;
  --radius-lg: 10px;
  --radius-pill: 999px;

  --font: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-heading: var(--font);
  --heading-weight: 700;
}

/*
  Шрифты брендов — свои, из static/fonts (лицензия OFL рядом с файлами):
  политика безопасности не пускает шрифты со сторонних адресов. Inter — текст
  FreeChange и X-Pay, Tektur — заголовки FreeChange, Nunito Sans — Kassa
  (свой шрифт kassa.cc, Museo Sans Cyrl, лицензионный — ставить его к себе
  нельзя). Все вариативные: одним файлом все начертания. Браузер скачивает
  файл, только когда шрифт нужен странице, — витрина Kassa не грузит Inter,
  а FreeChange — Nunito Sans. Три набора: кириллица, латиница и расширенная
  латиница, в которой знак ₽ (U+20BD).
*/
@font-face {
  font-family: "Inter"; font-style: normal; font-weight: 400 800; font-display: swap;
  src: url("../fonts/inter/inter-cyrillic.4e2553027f1d.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Inter"; font-style: normal; font-weight: 400 800; font-display: swap;
  src: url("../fonts/inter/inter-latin-ext.01ba6c2a184b.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308,
    U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113,
    U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Inter"; font-style: normal; font-weight: 400 800; font-display: swap;
  src: url("../fonts/inter/inter-latin.65850a373e25.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304,
    U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Tektur"; font-style: normal; font-weight: 500 700; font-display: swap;
  src: url("../fonts/tektur/tektur-cyrillic.9be290a459a1.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Tektur"; font-style: normal; font-weight: 500 700; font-display: swap;
  src: url("../fonts/tektur/tektur-latin-ext.bfe86e9c3da4.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308,
    U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113,
    U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Tektur"; font-style: normal; font-weight: 500 700; font-display: swap;
  src: url("../fonts/tektur/tektur-latin.79f6f53640ec.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304,
    U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Nunito Sans"; font-style: normal; font-weight: 300 800; font-display: swap;
  src: url("../fonts/nunito-sans/nunito-sans-cyrillic.15709f247b76.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Nunito Sans"; font-style: normal; font-weight: 300 800; font-display: swap;
  src: url("../fonts/nunito-sans/nunito-sans-latin-ext.3a97847bca8b.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308,
    U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113,
    U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Nunito Sans"; font-style: normal; font-weight: 300 800; font-display: swap;
  src: url("../fonts/nunito-sans/nunito-sans-latin.e31445dff877.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304,
    U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

* { box-sizing: border-box; }

/* Без этого iPhone при повороте в горизонталь сам увеличивает шрифт,
   и вёрстка перестраивается рывком. */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;   /* высота без прыжка при появлении адресной строки */
  background-color: var(--bg);
  color: var(--ink);
  /* Длинный адрес, почта или код без пробелов переносится, а не распирает экран. */
  overflow-wrap: break-word;
  font: 16px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}

/* Фон-картинка (градиент FreeChange) — отдельным неподвижным слоем, а не
   background-attachment: fixed. Safari на iPhone fixed не поддерживает:
   градиент растягивался на всю высоту страницы и при прокрутке дёргался. */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1;
  background-image: var(--bg-image); pointer-events: none;
}

h1 {
  font-family: var(--font-heading);
  font-weight: var(--heading-weight);
  font-size: clamp(22px, 4vw, 30px);
  line-height: 1.15;
  margin: 0 0 12px;
}
h2 {
  font-family: var(--font-heading);
  font-weight: var(--heading-weight);
  font-size: 18px;
  margin: 28px 0 12px;
}
p { margin: 0 0 12px; }
a { color: inherit; }

/* Ширина страницы по макету главной (1440 минус поля по 24px). Шапка, лента
   разделов, содержимое и подвал выравниваются по одной колонке. */
main, .top, .cats, .topbar { max-width: 1440px; margin: 0 auto; padding: 0 24px; }

/* --- служебная строка над шапкой --- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  min-height: 36px; font-size: 13px; color: var(--ink-soft);
}
.topbar a { color: var(--ink-soft); text-decoration: none; }
.topbar a:hover { color: var(--ink); }
.topbar-back { display: inline-flex; align-items: center; gap: 6px; }
.topbar-help { display: flex; gap: 20px; flex-wrap: wrap; }

/* --- шапка ---
   Сетка, а не flex-wrap: при переносах элементы прыгали по строкам в зависимости
   от ширины телефона и длины названия бренда. */
.top {
  display: grid; align-items: center; gap: 12px 16px;
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  grid-template-areas: "word catalog search actions";
  padding-top: 4px; padding-bottom: 4px;
}
.wordmark {
  grid-area: word; min-width: 0;
  display: inline-flex; align-items: center; gap: 12px;
  text-decoration: none; white-space: nowrap;
}
/* Длинное название бренда обрезается многоточием, а не выталкивает кнопки. */
.wordmark-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; display: flex; flex-direction: column; line-height: 1.1; }
.wordmark-name { font-family: var(--font-heading); font-weight: var(--heading-weight); font-size: 20px; }
.wordmark-title { font-size: 13px; color: var(--muted); }
/* Временный знак бренда. Когда появится файл логотипа, шаблон подставит
   <img> вместо этого квадрата — правки CSS не потребуется. */
.mark { width: 44px; height: 44px; border-radius: var(--radius-lg); background: var(--accent-solid); flex: none; }
.brand-logo { height: 32px; width: auto; display: block; flex: none; }

/* «Каталог» — <details> со списком разделов. Раскрытый список лежит на
   непрозрачной подложке: поверхность у FreeChange полупрозрачная. */
.catalog-menu { grid-area: catalog; position: relative; }
.catalog-btn {
  display: flex; align-items: center; gap: 10px; height: 56px; padding: 0 24px;
  border-radius: var(--radius-lg); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line);
  font-size: 18px; font-weight: 600; cursor: pointer; list-style: none; user-select: none;
}
.catalog-btn::-webkit-details-marker { display: none; }
.catalog-menu[open] .catalog-btn { box-shadow: inset 0 0 0 var(--sel-width) var(--sel-line); }
.catalog-panel {
  position: absolute; z-index: 20; top: calc(100% + 8px); left: 0; min-width: 280px;
  display: flex; flex-direction: column; gap: 2px; padding: 8px;
  border-radius: var(--radius-lg); background: linear-gradient(var(--surface-2), var(--surface-2)), var(--bg);
  box-shadow: inset 0 0 0 1px var(--line), 0 18px 40px rgb(0 0 0 / 0.28);
}
.catalog-panel a {
  display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px;
  border-radius: var(--radius); text-decoration: none; font-size: 16px;
}
.catalog-panel a.sub { padding-left: 52px; font-size: 14px; color: var(--ink-soft); }
.catalog-panel a:hover { background: var(--sel); }

.search { grid-area: search; min-width: 0; margin: 0; }
.search-field {
  display: flex; align-items: center; gap: 12px; height: 56px; padding: 0 20px;
  border-radius: var(--radius-lg); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line);
  color: var(--muted);
}
.search-field:focus-within { box-shadow: inset 0 0 0 var(--sel-width) var(--sel-line), var(--sel-glow); }
.search-field svg { flex: none; }
.search-field input {
  flex-grow: 1; min-width: 0; border: 0; outline: 0; background: transparent;
  color: var(--ink); font: inherit; font-size: 16px;
}
.search-field input::placeholder { color: var(--muted); opacity: 1; }

.top-actions { grid-area: actions; display: flex; align-items: center; gap: 4px; }
.top-icon {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-width: 64px; height: 56px; padding: 0 6px; border: 0; border-radius: var(--radius);
  background: transparent; color: var(--ink); font: inherit; font-size: 13px; text-decoration: none; cursor: pointer;
}
.top-icon span { color: var(--ink-soft); }
.top-icon:hover { background: var(--surface); }
/* Возврат в обменник в самой шапке — только на телефоне; на широком экране он в служебной строке. */
.top-back { display: none; }
.inline { display: inline; }

/* --- разделы каталога: значок и подпись, без плашек --- */
.cats {
  display: flex; align-items: center; gap: 8px 32px; flex-wrap: wrap;
  padding-top: 12px; padding-bottom: 8px; margin-bottom: 16px;
}
.cats a {
  display: flex; flex: none; align-items: center; gap: 10px; min-height: 44px;
  font-size: 16px; white-space: nowrap; text-decoration: none; color: var(--ink);
}
.cats a:hover { color: var(--accent); }
.cats a[aria-current] { color: var(--sel-ink); box-shadow: inset 0 calc(-1 * var(--sel-width)) 0 var(--sel-line); }
.cat-icon {
  display: flex; flex: none; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: var(--radius); background: var(--ink);
}
.cats .product-logo { box-shadow: none; }

/* --- кнопки --- */
.btn {
  display: inline-block; padding: 9px 16px; border-radius: var(--radius);
  background: var(--brand); color: var(--on-brand); border: 1px solid var(--brand);
  font: inherit; font-weight: 600; font-size: 14px; text-decoration: none; cursor: pointer;
}
.btn.block { display: flex; align-items: center; justify-content: center; width: 100%; text-align: center; }
.btn.ghost { background: transparent; color: var(--muted); border-color: var(--line); }
.btn.ghost:hover { color: var(--ink); border-color: var(--accent); }
.btn:focus-visible, a:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

/* --- каталог --- */
.hero { margin-bottom: 28px; }
.hero p, .lede { color: var(--muted); max-width: 62ch; }

.grid {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(178px, 1fr));
}
.card {
  display: flex; flex-direction: column; gap: 6px;
  padding: 14px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); text-decoration: none;
}
.card:hover { border-color: var(--accent); }
.card .logo { font-size: 22px; }
/* Плитка логотипа несёт свой фирменный фон и не зависит от темы. От темы берётся
   только скругление, а тонкое кольцо отделяет чёрные плитки (Apple, Roblox)
   от тёмной карточки FreeChange. Скругление не больше 22% стороны: у плитки 24px
   радиус темы в 8px превратил бы квадрат в кружок. */
.product-logo {
  display: block; flex: none;
  border-radius: min(var(--radius), 22%); box-shadow: 0 0 0 1px var(--line);
}
/* Логотип рядом с текстом: в заголовке товара, в строке заказа и оформления. */
.product-title { display: flex; align-items: center; gap: 14px; margin: 0 0 12px; }
.product-title h1 { margin: 0; min-width: 0; }
.with-logo { display: inline-flex; align-items: center; gap: 8px; }
.card .name { font-weight: 600; font-size: 14.5px; }
.card .meta { font-size: 12px; color: var(--muted); }
.card .price { font-weight: 700; font-size: 16px; font-variant-numeric: tabular-nums; }
.card .price .from { font-weight: 400; font-size: 12px; color: var(--muted); }
.stock { font-size: 12px; color: var(--ok); }
.stock.out { color: var(--muted); }

/* --- карточка товара --- */
/* Разметка идёт в порядке «заголовок → покупка → подробности», как нужно
   на телефоне. На широком экране покупка встаёт в правую колонку рядом с обоими. */
.product {
  display: grid; column-gap: 24px;
  grid-template-columns: minmax(0, 1fr) 300px;
  grid-template-rows: auto 1fr;
  grid-template-areas: "head buy" "body buy";
}
.product-head { grid-area: head; min-width: 0; }
.product-body { grid-area: body; min-width: 0; }

.facts { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 16px; }
.fact {
  font-size: 12px; padding: 4px 10px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line); color: var(--muted);
}
.prose { color: var(--ink-soft); }
.warn {
  padding: 11px 14px; border-radius: var(--radius);
  background: var(--warn-tint); color: var(--warn); font-size: 14px;
}
.instruction h2 { font-size: 15px; margin-bottom: 6px; }

.buybox {
  grid-area: buy;
  align-self: start; padding: 16px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-lg);
}
/* Номиналы — группа радиокнопок, оформленных строками. Стрелки клавиатуры
   переключают номинал сами: это обычная радиогруппа, скриптов нет. */
.variants-group { margin: 0 0 12px; padding: 0; border: 0; min-width: 0; }
.variants { display: flex; flex-direction: column; gap: 6px; }
.variant-sub { display: block; }
.variants-title { font-size: 13px; font-weight: 600; color: var(--muted); margin: 0 0 8px; padding: 0; }
.variant-option {
  display: block; padding: 11px 12px; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--surface); cursor: pointer;
}
.variant-option.out { cursor: default; opacity: .6; }
.variant-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.variant-name { font-weight: 600; }
.variant-option .price { font-weight: 700; font-variant-numeric: tabular-nums; }
/* Селектор из двух классов намеренно: у кнопки есть .btn.block с display:block,
   и одиночный .variant-cta проигрывал ему по специфичности — кнопки
   показывались у всех номиналов сразу. */
.variant-option .variant-cta { display: none; margin-top: 10px; }
.variant-option:has(input:checked) .variant-cta { display: flex; }
.variant-option:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
/* Браузер без :has() покажет кнопку у каждого номинала — ровно как было до
   появления выбора. Покупка не ломается ни в одном браузере. */
@supports not selector(:has(*)) { .variant-option .variant-cta { display: flex; } }

/* --- способ оплаты при оформлении ---
   Та же радиогруппа без скриптов, что и у номиналов; выбор подсвечивается
   общим правилом выбора темы выше. */
.pay-methods { margin: 4px 0 4px; padding: 0; border: 0; min-width: 0; width: 100%;
               display: flex; flex-direction: column; gap: 6px; }
.pay-methods legend { font-size: 13px; font-weight: 600; color: var(--muted); margin: 0 0 8px; padding: 0; }
.pay-method {
  display: flex; gap: 10px; align-items: flex-start; padding: 11px 12px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); cursor: pointer;
}
.pay-method input { margin-top: 3px; }
.pay-method-text { display: flex; flex-direction: column; gap: 2px; }
.pay-method-name { font-weight: 600; }
.pay-method:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }

/* --- реквизиты на странице заказа --- */
.pay-details { border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface);
               padding: 16px 18px; margin: 0 0 16px; display: flex; flex-direction: column; gap: 10px; }
.pay-details h2 { margin: 0; font-size: 16px; }
.pay-details .pay-address { font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
                            font-size: 15px; overflow-wrap: anywhere; }
.pay-details form { margin: 0; }

/* --- вход покупателя --- */
.auth { max-width: 440px; }
.auth .code-input { font-size: 24px; letter-spacing: .3em; font-variant-numeric: tabular-nums; }

/* --- выбор бренда --- */
.choose { max-width: 460px; }
.choices { display: flex; flex-direction: column; gap: 10px; margin: 20px 0 12px; }
.choice {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 16px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); text-decoration: none; font-weight: 600;
}
.choice:hover { border-color: var(--accent); }
.choice .host { margin-left: auto; font-weight: 400; font-size: 12px; color: var(--muted); }

/* --- прочее --- */
.muted { color: var(--muted); }
.small { font-size: 13px; }
/* Подвал во всю ширину на своей подложке; колонки — по ширине страницы. */
.foot {
  margin-top: 56px; padding: 40px 0 48px;
  background: var(--surface-2); box-shadow: inset 0 1px 0 var(--line);
}
.foot-cols, .foot-bottom { max-width: 1440px; margin: 0 auto; padding: 0 24px; }
.foot-cols { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 32px; }
.foot-col { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.foot-title { margin: 0; font-family: var(--font); font-size: 16px; font-weight: 700; }
.foot-col a, .foot-col span { font-size: 14px; color: var(--ink); text-decoration: none; }
.foot-col a:hover { color: var(--accent); }
.foot-bottom {
  display: flex; flex-direction: column; gap: 4px; margin-top: 28px; padding-top: 24px;
  box-shadow: inset 0 1px 0 var(--line); font-size: 14px; color: var(--ink-soft);
}

/* Нижняя навигация телефона: на широком экране её нет. */
.tabbar { display: none; }

/* --- оформление заказа и личный кабинет --- */
.checkout { max-width: 560px; }
.rows {
  display: flex; flex-direction: column;
  border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden;
  background: var(--surface); margin: 16px 0;
}
.row { display: flex; align-items: center; gap: 12px; padding: 12px 15px; font-size: 14px; }
.row + .row { border-top: 1px solid var(--line); }
.row .k { color: var(--muted); }
.row .k { flex: none; }
/* min-width: 0 обязателен: без него длинное значение (ссылка на оплату) не
   сжимается внутри flex-строки и выезжает за край карточки. */
.row .v { margin-left: auto; min-width: 0; text-align: right; overflow-wrap: anywhere; font-weight: 600; font-variant-numeric: tabular-nums; }
.row.total .v { font-size: 18px; }
.order-row { text-decoration: none; }
.order-row:hover { background: var(--accent-tint); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
/* Номер заказа не рвётся по дефисам на три строки. */
.order-id { white-space: nowrap; }

.timer {
  font-size: 13px; color: var(--warn); background: var(--warn-tint);
  padding: 9px 13px; border-radius: var(--radius);
}
.checkout-form { display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
.confirm { display: flex; gap: 9px; align-items: flex-start; font-size: 14px; max-width: 52ch; }

.order-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.badge {
  font-size: 12px; padding: 4px 10px; border-radius: var(--radius-pill);
  background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.badge.status-completed, .badge.status-delivered { background: var(--ok-tint); color: var(--ok); }
.badge.status-awaiting_payment { background: var(--warn-tint); color: var(--warn); }
.badge.status-failed, .badge.status-cancelled { background: var(--danger-tint); color: var(--danger); }

.codebox {
  border: 1px dashed var(--line); border-radius: var(--radius-lg);
  padding: 20px; text-align: center; background: var(--surface); margin: 16px 0;
}
.codebox .masked { font-size: 20px; letter-spacing: .14em; color: var(--muted); margin-bottom: 12px; }
.codebox .code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  /* Коды бывают на 20+ символов: шрифт сжимается под ширину телефона, а в
     крайнем случае код переносится. Копирование при этом берёт его целиком. */
  font-size: clamp(16px, 5.6vw, 22px); font-weight: 700; letter-spacing: .08em; margin-bottom: 10px;
  overflow-wrap: anywhere; user-select: all;
}
.codebox.revealed { border-style: solid; border-color: var(--accent); }

/* --- заявка на оплату сервиса --- */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; width: 100%; }
.field label { font-size: 12.5px; color: var(--muted); }
.input {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 9px 12px;
  /* 16px — не дизайн, а требование iPhone: на поле мельче Safari при нажатии
     сам увеличивает страницу, и она остаётся сдвинутой. */
  font: inherit; font-size: 16px; background: var(--surface); color: var(--ink); width: 100%;
}
.amount-row { display: flex; gap: 8px; }
.amount-row .input:last-child { width: 90px; flex: none; }
.note-safe {
  margin-top: 16px; padding: 12px 14px; border-radius: var(--radius);
  background: var(--accent-tint); font-size: 13.5px;
}

/* --- выбор ---
   Одно состояние на все места, где человек что-то выбирает: номинал товара и
   текущий раздел в навигации. Налёт `sel` ложится ПОВЕРХ поверхности вторым
   слоем фона, поэтому может быть прозрачным — у Kassa заливки нет вовсе.
   Толщина рамки добирается внутренней тенью: вёрстка при выборе не прыгает. */
.variant-option:has(input:checked),
.pay-method:has(input:checked) {
  background-color: var(--surface);
  background-image: linear-gradient(var(--sel), var(--sel));
  border-color: var(--sel-line);
  box-shadow: inset 0 0 0 calc(var(--sel-width) - 1px) var(--sel-line), var(--sel-glow);
  color: var(--sel-text);
}
.variant-option:has(input:checked) .muted { color: var(--sel-muted); }

/* Скрыто глазом, но доступно экранному диктору и клавиатуре. */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* --- главная ---------------------------------------------------------
   Раскладка — макет «вариант 2» (по образцу ggsel): лента популярного,
   быстрая покупка, хиты продаж, оплата сервисов, текст о витрине. */
.home { display: flex; flex-direction: column; gap: 48px; }
.section-title { margin: 0; font-size: 32px; line-height: 1.15; }

/* Популярное: высокие плитки, лента листается вбок. Логотип растянут на всю
   плитку с обрезкой — у каждого свой фирменный фон, тема тут ни при чём. */
.popular { position: relative; margin-top: 4px; }
.popular-track {
  display: flex; gap: 16px; overflow-x: auto; overscroll-behavior-x: contain;
  scroll-snap-type: x proximity; scrollbar-width: none;
}
.popular-track::-webkit-scrollbar { display: none; }
.promo-card {
  position: relative; flex: none; display: block; width: 180px; height: 225px; overflow: hidden;
  border-radius: calc(var(--radius-lg) * 1.6); background: var(--surface-2);
  scroll-snap-align: start; text-decoration: none;
}
.promo-card img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  transform: scale(1.12); transition: transform .2s ease;
}
.promo-card:hover img { transform: scale(1.18); }
/* Затемнение и белая подпись не зависят от темы: они лежат на логотипе бренда. */
.promo-shade {
  position: absolute; left: 0; right: 0; bottom: 0; height: 60%;
  background: linear-gradient(to top, rgb(0 0 0 / 0.55), rgb(0 0 0 / 0));
}
.promo-title {
  position: absolute; left: 16px; right: 14px; bottom: 16px;
  font-family: var(--font-heading); font-weight: 700; font-size: 20px; line-height: 1.2; color: rgb(255 255 255);
}
.promo-service { background: var(--accent-solid); color: var(--on-brand); }
.promo-service svg { position: absolute; left: 16px; top: 16px; }
.promo-service .promo-title { color: var(--on-brand); }
.popular-next {
  position: absolute; right: 8px; top: calc(50% - 26px);
  display: flex; align-items: center; justify-content: center; width: 52px; height: 52px;
  border: 0; border-radius: var(--radius-pill); color: var(--ink); cursor: pointer;
  background: linear-gradient(var(--surface), var(--surface)), var(--bg);
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.2), inset 0 0 0 1px var(--line);
}

/* Быстрая покупка */
.quick {
  display: flex; flex-direction: column; gap: 16px; padding: 20px 24px 24px;
  border-radius: calc(var(--radius-lg) * 1.6); box-shadow: inset 0 0 0 3px var(--line);
}
.quick-title { margin: 0; font-family: var(--font); font-size: 16px; font-weight: 400; color: var(--muted); }
.quick-tabs {
  display: flex; gap: 32px; overflow-x: auto; scrollbar-width: none;
  box-shadow: inset 0 -1px 0 var(--line);
}
.quick-tabs::-webkit-scrollbar { display: none; }
.quick-tab {
  display: flex; flex: none; align-items: center; gap: 8px; padding: 0 0 10px;
  font-family: var(--font-heading); font-weight: var(--heading-weight); font-size: 24px;
  color: var(--muted); text-decoration: none;
}
.quick-tab .product-logo { opacity: .55; box-shadow: none; }
.quick-tab .cat-icon { width: 26px; height: 26px; }
.quick-tab[aria-selected="true"] { color: var(--ink); box-shadow: inset 0 calc(-1 * var(--sel-width)) 0 var(--sel-line); }
.quick-tab[aria-selected="true"] .product-logo { opacity: 1; }
.quick-panel { display: grid; grid-template-columns: minmax(0, 1fr) 260px 360px; gap: 12px; align-items: start; }
.quick-panel[hidden] { display: none; }
.quick-options { margin: 0; padding: 0; border: 0; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.quick-label { font-size: 13px; color: var(--muted); padding: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  position: relative; display: inline-flex; align-items: center; height: 40px; padding: 0 16px;
  border-radius: var(--radius-pill); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line);
  font-size: 16px; cursor: pointer; font-variant-numeric: tabular-nums;
}
.chip input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.chip:has(input:checked) {
  background-image: linear-gradient(var(--sel), var(--sel));
  box-shadow: inset 0 0 0 var(--sel-width) var(--sel-line), var(--sel-glow);
  color: var(--sel-text); font-weight: 600;
}
.chip:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.chip.out { background: var(--surface-2); box-shadow: none; color: var(--muted); text-decoration: line-through; cursor: not-allowed; }
/* Браузер без :has() покажет обычные радиокнопки — выбор всё равно работает. */
@supports not selector(:has(*)) { .chip input { position: static; opacity: 1; width: auto; height: auto; margin-right: 8px; } }
.quick-side { display: flex; flex-direction: column; gap: 10px; }
.quick-fact {
  display: flex; flex-direction: column; justify-content: center; gap: 2px; min-height: 56px;
  padding: 6px 16px; border-radius: var(--radius-lg); background: var(--surface-2);
}
.quick-how { font-size: 13px; color: var(--muted); }
.quick-buy { display: flex; flex-direction: column; gap: 10px; }
.quick-cta {
  display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 56px; padding: 0 20px;
  border-radius: var(--radius-lg); background: var(--brand); color: var(--on-brand);
  font-size: 20px; font-weight: 600; text-decoration: none; white-space: nowrap; font-variant-numeric: tabular-nums;
}
.quick-cta:hover { filter: brightness(1.06); }
.quick-cta.out { background: var(--surface-2); color: var(--muted); }
.quick-note { font-size: 13px; color: var(--muted); }

/* Хиты продаж */
.hits { display: flex; flex-direction: column; gap: 24px; }
.hit-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 20px; }
.hit { display: flex; flex-direction: column; gap: 6px; min-width: 0; text-decoration: none; }
.hit[hidden] { display: none; }
.hit-media {
  position: relative; display: block; aspect-ratio: 1 / 1; overflow: hidden;
  border-radius: var(--radius-lg); background: var(--surface-2);
}
.hit-media img { display: block; width: 100%; height: 100%; transition: transform .2s ease; }
.hit:hover .hit-media img { transform: scale(1.04); }
.hit-emoji { display: grid; place-items: center; height: 100%; font-size: 48px; }
.hit-badge {
  position: absolute; left: 10px; top: 10px; padding: 4px 10px; border-radius: var(--radius-pill);
  background: var(--surface-2); color: var(--ink); font-size: 12px; font-weight: 700;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.hit-kind {
  margin-top: 6px; font-size: 12px; color: var(--ink-soft);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hit-price {
  font-family: var(--font-heading); font-weight: var(--heading-weight); font-size: 24px; line-height: 1.15;
  white-space: nowrap; font-variant-numeric: tabular-nums;
}
.hit-price .from { font-family: var(--font); font-size: 14px; font-weight: 500; color: var(--muted); }
.hit-name {
  font-size: 14px; line-height: 1.4; min-height: 2.8em;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.hit-meta { font-size: 13px; color: var(--muted); }
.hit-cta {
  display: flex; align-items: center; justify-content: center; height: 36px; margin-top: auto;
  border-radius: var(--radius); background: var(--brand); color: var(--on-brand); font-size: 14px; font-weight: 700;
}
.hit-cta.out { background: var(--surface-2); color: var(--muted); }
.more-btn {
  height: 56px; border: 0; border-radius: var(--radius-lg); background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line); color: var(--ink); font: inherit; font-size: 18px; font-weight: 600; cursor: pointer;
}
.more-btn:hover { box-shadow: inset 0 0 0 1px var(--accent); }

/* Оплата сервисов */
.service-promo {
  display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 2fr) 320px; gap: 40px; align-items: center;
  padding: 32px; border-radius: calc(var(--radius-lg) * 1.6); background: var(--accent-tint);
}
.service-intro { display: flex; flex-direction: column; gap: 10px; }
.service-intro h2 { margin: 0; font-size: 28px; line-height: 1.2; }
.service-intro p { margin: 0; font-size: 15px; color: var(--ink-soft); }
.eyebrow { font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); }
.service-steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; }
.service-steps li { display: flex; gap: 12px; align-items: flex-start; }
.service-steps li > span:last-child { display: flex; flex-direction: column; gap: 2px; padding-top: 1px; font-size: 14px; color: var(--ink-soft); }
.service-steps b { font-size: 15px; color: var(--ink); }
.step-num {
  display: flex; flex: none; align-items: center; justify-content: center; width: 36px; height: 36px;
  border-radius: var(--radius-pill); background: var(--ink); color: var(--bg); font-weight: 800; font-size: 15px;
}
.service-cta { display: flex; flex-direction: column; gap: 12px; }
.service-safe { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; line-height: 1.45; color: var(--ink-soft); }
.service-safe svg { flex: none; color: var(--accent); }

/* О витрине */
.about { padding: 24px; border-radius: var(--radius-lg); box-shadow: inset 0 0 0 1px var(--line); }
.about h2 { margin: 0 0 12px; font-family: var(--font); font-size: 16px; font-weight: 700; }
.about p { margin: 0; color: var(--ink-soft); max-width: 110ch; }

@media (max-width: 1180px) {
  .hit-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .quick-panel { grid-template-columns: minmax(0, 1fr) 240px; }
  .quick-buy { grid-column: 1 / -1; }
  .service-promo { grid-template-columns: minmax(0, 1fr); gap: 24px; }
}

/* --- документы, FAQ, контакты --- */
.legal { max-width: 820px; display: flex; flex-direction: column; gap: 14px; }
.legal h1 { margin: 0; }
.legal h2 { margin: 18px 0 0; }
.legal-meta { margin: 0; font-size: 14px; color: var(--muted); }
.legal-body h2 { font-size: 20px; margin: 22px 0 8px; }
.legal-body h3 { font-size: 17px; margin: 18px 0 6px; }
.legal-body ul, .legal-body ol { margin: 0 0 12px; padding-left: 22px; }
.legal-body li + li { margin-top: 4px; }
.legal-preview {
  margin: 0; padding: 11px 14px; border-radius: var(--radius);
  background: var(--warn-tint); color: var(--warn); font-size: 14px;
}
.legal-table { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); }
.legal-table table { width: 100%; border-collapse: collapse; font-size: 14px; }
.legal-table th, .legal-table td { padding: 10px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
.legal-table tr:last-child td { border-bottom: 0; }
.legal-table th { font-size: 12px; color: var(--muted); font-weight: 600; }
.faq-group { display: flex; flex-direction: column; gap: 8px; }
.faq-item { border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); }
.faq-item summary { cursor: pointer; padding: 14px 16px; font-weight: 600; min-height: 44px; }
.faq-item .prose { padding: 0 16px 12px; }
.legal-list { margin: 0; display: grid; gap: 0; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); overflow: hidden; }
.legal-list > div { display: grid; grid-template-columns: minmax(0, 220px) minmax(0, 1fr); gap: 12px; padding: 12px 16px; }
.legal-list > div + div { border-top: 1px solid var(--line); }
.legal-list dt { color: var(--muted); font-size: 14px; }
.legal-list dd { margin: 0; overflow-wrap: anywhere; }

/* --- телефон --- */
@media (max-width: 760px) {
  main, .top, .cats, .foot-cols, .foot-bottom { padding-left: 16px; padding-right: 16px; }
  .topbar { display: none; }
  .top {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "word back" "search search";
    padding-top: 12px;
  }
  /* Каталог, заказы и вход переезжают в нижнюю навигацию. Два класса — с запасом
     по специфичности: у формы выхода есть .inline, который задаёт display раньше. */
  .top .catalog-menu, .top .top-actions { display: none; }
  .top .top-back {
    grid-area: back; display: inline-flex; align-items: center; gap: 6px;
    min-height: 44px; font-size: 14px; color: var(--ink-soft); text-decoration: none;
  }
  .foot { padding-bottom: 120px; }
  .foot-cols { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  .tabbar {
    position: fixed; z-index: 30; left: 12px; right: 12px;
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    display: flex; gap: 2px; padding: 6px; border-radius: var(--radius-pill);
    background: linear-gradient(var(--surface), var(--surface)), var(--bg);
    box-shadow: 0 10px 30px rgb(0 0 0 / 0.22), inset 0 0 0 1px var(--line);
  }
  .tabbar > a, .tabbar > form { flex: 1 1 0; min-width: 0; }
  .tabbar > form { display: flex; }
  .tabbar a, .tabbar button {
    display: flex; flex: 1; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    min-height: 52px; padding: 4px 2px; border: 0; border-radius: var(--radius-pill);
    background: transparent; color: var(--ink-soft); font: inherit; font-size: 11px; text-decoration: none;
  }
  .tabbar [aria-current] { background: var(--sel); color: var(--sel-ink); }

  /* Разделы — одна строка, которая листается вбок. Перенос на две-три строки
     съедал экран и менялся от телефона к телефону. */
  .cats {
    gap: 20px; margin-bottom: 8px;
    flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-x: contain;
    scrollbar-width: none; scroll-snap-type: x proximity; scroll-padding-inline: 20px;
    /* Сверху запас под свечение выбранного раздела — иначе прокрутка его срежет. */
    padding-top: 4px;
  }
  .cats::-webkit-scrollbar { display: none; }
  /* Затухание у правого края — намёк, что строка листается: иначе последний
     видимый раздел мог кончиться ровно у края, и остальные казались пропавшими. */
  .cats {
    -webkit-mask-image: linear-gradient(to right, black calc(100% - 32px), transparent);
            mask-image: linear-gradient(to right, black calc(100% - 32px), transparent);
  }
  .cats a { scroll-snap-align: start; }
  /* Правый отступ у прокручиваемой строки: padding справа браузеры в прокрутке теряют. */
  .cats::after { content: ""; flex: 0 0 1px; }

  .product { grid-template-columns: minmax(0, 1fr); grid-template-areas: "head" "buy" "body"; row-gap: 20px; }

  .home { gap: 36px; }
  .section-title { font-size: 26px; }
  .promo-card { width: 150px; height: 190px; }
  /* Стрелка ленты — для мыши; на узком экране ленту листают пальцем. */
  .popular .popular-next { display: none; }
  .popular-track { scroll-padding-inline: 16px; }
  .quick { padding: 16px; }
  .quick-tabs { gap: 22px; }
  .quick-tab { font-size: 20px; }
  .quick-panel { grid-template-columns: minmax(0, 1fr); }
  .hit-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
  .hit-price { font-size: 20px; }
  .service-promo { padding: 20px; }
  .service-steps { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .legal-list > div { grid-template-columns: minmax(0, 1fr); gap: 2px; }

  /* Заказ в две строки: название и сумма, под ними номер и статус.
     В одну строку при 320px сумма обрезалась. */
  .order-row {
    display: grid; grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "name sum" "id status" "date date"; gap: 4px 12px; align-items: center;
  }
  .order-row .order-name { grid-area: name; font-weight: 600; }
  .order-row .order-sum { grid-area: sum; margin-left: 0; }
  .order-row .order-id { grid-area: id; }
  .order-row .order-date { grid-area: date; }
  .order-row .order-status { grid-area: status; justify-self: end; }
}

/* --- палец вместо мыши: цели не меньше 44px (рекомендация Apple) ---
   Высота набирается ТОЛЬКО отступами, display здесь не трогаем. Правило стоит
   в конце файла, и любое display в нём перебивало скрытие элементов выше:
   кнопки «Купить» появлялись у всех номиналов, возврат в обменник — в шапке. */
@media (pointer: coarse) {
  .btn { padding-top: 11px; padding-bottom: 11px; }
  .confirm input { width: 22px; height: 22px; flex: none; margin: 0; }
}

/* --- самые узкие телефоны (320–359px) ---
   Подпись «· Сервисы» убирается целиком: иначе название бренда резалось
   многоточием на полуслове. Остаётся имя бренда — или один логотип. */
@media (max-width: 359px) {
  .wordmark-title { display: none; }
}

/* Сообщения на карточке товара (catalog/_messages.html) — во всех раскладках. */
.page-messages { display: flex; flex-direction: column; gap: 8px; margin: 0 0 16px; }
.page-messages p { margin: 0; }
