/*
 * AVIKON storefront — design system (owner: design module).
 * Mobile-first, no build step. Tokens → reset → layout → header/footer/tab bar → components → overlays → modes.
 * Class reference and component props: docs/modules/design.md
 */

/* ===== 1. Tokens ===================================================== */
:root {
  color-scheme: light;

  /* brand palette (CONTRACT §8) */
  --c-primary: #0B5ED7;
  --c-primary-hover: #0A4FB5;
  --c-accent: #0EA5E9;
  --c-ink: #0F172A;
  --c-muted: #64748B;
  --c-line: #E2E8F0;
  --c-surface: #FFFFFF;
  --c-canvas: #F5F7FB;
  --c-success: #16A34A;
  --c-warning: #D97706;
  --c-danger: #DC2626;

  /* semantic tokens (themes override these) */
  --primary: var(--c-primary);
  --primary-hover: var(--c-primary-hover);
  --primary-soft: #E8F0FD;
  --primary-ink: #0A4FB5;
  --on-primary: #FFFFFF;
  --accent: var(--c-accent);
  --accent-soft: #E0F2FE;
  --accent-ink: #0369A1;
  --ink: var(--c-ink);
  --ink-2: #334155;
  --muted: var(--c-muted);
  --line: var(--c-line);
  --line-strong: #CBD5E1;
  --surface: var(--c-surface);
  --surface-2: #F1F5F9;
  --canvas: var(--c-canvas);
  --img-bg: #FFFFFF;
  --success: var(--c-success);
  --success-soft: #DCFCE7;
  --success-ink: #15803D;
  --warning: var(--c-warning);
  --warning-soft: #FEF3C7;
  --warning-ink: #B45309;
  --danger: var(--c-danger);
  --danger-soft: #FEE2E2;
  --danger-ink: #B91C1C;
  --link: var(--c-primary);
  --focus: rgba(11, 94, 215, .32);
  --overlay: rgba(15, 23, 42, .48);
  --toast-bg: #0F172A;
  --shimmer: rgba(255, 255, 255, .6);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --shadow-md: 0 6px 20px rgba(15, 23, 42, .08);
  --shadow-lg: 0 16px 48px rgba(15, 23, 42, .18);

  /* shape */
  --radius: 12px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --radius-pill: 999px;

  /* type (system fonts only) */
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  /* layout */
  --container: 1280px;
  --gutter: 16px;
  --hdr-top: 52px;
  --tabbar-h: 58px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --ease: cubic-bezier(.2, .8, .2, 1);
  --dur: .22s;

  --z-header: 50;
  --z-suggest: 70;
  --z-tabbar: 60;
  --z-drawer: 80;
  --z-modal: 90;
  --z-toast: 100;
}

@media (min-width: 768px) {
  :root { --gutter: 24px; }
}

@media (min-width: 1280px) {
  :root { --gutter: 32px; }
}

/* dark theme: system preference unless forced light; or forced dark */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --primary: #3B82F6;
    --primary-hover: #60A5FA;
    --primary-soft: rgba(59, 130, 246, .16);
    --primary-ink: #93C5FD;
    --on-primary: #FFFFFF;
    --accent: #38BDF8;
    --accent-soft: rgba(56, 189, 248, .14);
    --accent-ink: #7DD3FC;
    --ink: #E2E8F0;
    --ink-2: #CBD5E1;
    --muted: #94A3B8;
    --line: #243049;
    --line-strong: #33415A;
    --surface: #111A2C;
    --surface-2: #18233A;
    --canvas: #0A111F;
    --img-bg: #FFFFFF;
    --success: #22C55E;
    --success-soft: rgba(34, 197, 94, .14);
    --success-ink: #4ADE80;
    --warning: #F59E0B;
    --warning-soft: rgba(245, 158, 11, .14);
    --warning-ink: #FBBF24;
    --danger: #F87171;
    --danger-soft: rgba(248, 113, 113, .14);
    --danger-ink: #FCA5A5;
    --link: #60A5FA;
    --focus: rgba(96, 165, 250, .42);
    --overlay: rgba(2, 6, 23, .66);
    --toast-bg: #1E293B;
    --shimmer: rgba(255, 255, 255, .07);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-md: 0 6px 20px rgba(0, 0, 0, .35);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, .5);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --primary: #3B82F6;
  --primary-hover: #60A5FA;
  --primary-soft: rgba(59, 130, 246, .16);
  --primary-ink: #93C5FD;
  --on-primary: #FFFFFF;
  --accent: #38BDF8;
  --accent-soft: rgba(56, 189, 248, .14);
  --accent-ink: #7DD3FC;
  --ink: #E2E8F0;
  --ink-2: #CBD5E1;
  --muted: #94A3B8;
  --line: #243049;
  --line-strong: #33415A;
  --surface: #111A2C;
  --surface-2: #18233A;
  --canvas: #0A111F;
  --img-bg: #FFFFFF;
  --success: #22C55E;
  --success-soft: rgba(34, 197, 94, .14);
  --success-ink: #4ADE80;
  --warning: #F59E0B;
  --warning-soft: rgba(245, 158, 11, .14);
  --warning-ink: #FBBF24;
  --danger: #F87171;
  --danger-soft: rgba(248, 113, 113, .14);
  --danger-ink: #FCA5A5;
  --link: #60A5FA;
  --focus: rgba(96, 165, 250, .42);
  --overlay: rgba(2, 6, 23, .66);
  --toast-bg: #1E293B;
  --shimmer: rgba(255, 255, 255, .07);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-md: 0 6px 20px rgba(0, 0, 0, .35);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, .5);
}

/* Telegram Mini App: map tokens to Telegram theme params (set by telegram-web-app.js and app.js) */
.tg-app {
  --canvas: var(--tg-theme-secondary-bg-color, #EFEFF4);
  --surface: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, #FFFFFF));
  --ink: var(--tg-theme-text-color, #000000);
  --muted: var(--tg-theme-hint-color, #8E8E93);
  --link: var(--tg-theme-link-color, #2481CC);
  --primary: var(--tg-theme-button-color, #2481CC);
  --primary-hover: var(--tg-theme-button-color, #2481CC);
  --primary-ink: var(--tg-theme-link-color, #2481CC);
  --on-primary: var(--tg-theme-button-text-color, #FFFFFF);
  --accent: var(--tg-theme-accent-text-color, var(--tg-theme-link-color, #2481CC));
  --danger: var(--tg-theme-destructive-text-color, #E53935);
}

@supports (color: color-mix(in srgb, red 50%, blue)) {
  .tg-app {
    --primary-soft: color-mix(in srgb, var(--primary) 12%, transparent);
    --surface-2: color-mix(in srgb, var(--ink) 6%, transparent);
    --line: color-mix(in srgb, var(--ink) 11%, transparent);
    --line-strong: color-mix(in srgb, var(--ink) 20%, transparent);
    --ink-2: color-mix(in srgb, var(--ink) 82%, transparent);
    --focus: color-mix(in srgb, var(--primary) 32%, transparent);
  }
}

/* ===== 2. Reset & base =============================================== */
*,
*::before,
*::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  font-size: 16px;
  scroll-padding-top: 72px;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img, svg, video, canvas, picture { display: block; max-width: 100%; }
img { height: auto; border-style: none; }
h1, h2, h3, h4, h5, h6, p, ul, ol, dl, dd, figure, blockquote, fieldset { margin: 0; }
ul[class], ol[class] { list-style: none; padding: 0; }
fieldset { border: 0; padding: 0; min-width: 0; }
legend { padding: 0; }
table { border-collapse: collapse; border-spacing: 0; }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }

button, input, select, textarea { font: inherit; color: inherit; margin: 0; }
button { cursor: pointer; background: none; border: 0; padding: 0; text-align: inherit; }
button:disabled { cursor: default; }
input[type="search"]::-webkit-search-decoration { -webkit-appearance: none; }

:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
[hidden] { display: none !important; }
::selection { background: var(--primary-soft); }

h1, .h1 { font-size: 24px; line-height: 1.22; font-weight: 800; letter-spacing: -.015em; }
h2, .h2 { font-size: 20px; line-height: 1.3; font-weight: 750; letter-spacing: -.01em; }
h3, .h3 { font-size: 17px; line-height: 1.35; font-weight: 700; }
h4, .h4 { font-size: 15px; line-height: 1.4; font-weight: 700; }

@media (min-width: 768px) {
  h1, .h1 { font-size: 30px; }
  h2, .h2 { font-size: 23px; }
  h3, .h3 { font-size: 18px; }
}

code, kbd, samp { font-family: var(--font-mono); font-size: .9em; }

.icon { display: inline-block; flex: none; vertical-align: middle; }

/* ===== 3. Layout ===================================================== */
.container {
  width: 100%;
  max-width: var(--container);
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--gutter);
  padding-right: var(--gutter);
}

.site-main { flex: 1 0 auto; width: 100%; }
.page { padding-top: 16px; padding-bottom: 40px; }

@media (min-width: 768px) {
  .page { padding-top: 24px; padding-bottom: 56px; }
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px 16px;
  margin-bottom: 16px;
}

.page-title { font-size: 24px; line-height: 1.22; font-weight: 800; letter-spacing: -.015em; }
.page-sub { color: var(--muted); font-size: 14px; }

@media (min-width: 768px) {
  .page-title { font-size: 30px; }
}

.section { margin-top: 28px; }
.section:first-child { margin-top: 0; }

.section__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section__title { font-size: 20px; line-height: 1.3; font-weight: 800; letter-spacing: -.01em; }
.section__link { font-size: 14px; font-weight: 600; white-space: nowrap; }

@media (min-width: 768px) {
  .section { margin-top: 40px; }
  .section__title { font-size: 24px; }
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.card--pad { padding: 16px; }
.card__title { font-size: 17px; font-weight: 700; margin-bottom: 12px; }

@media (min-width: 768px) {
  .card--pad { padding: 20px; }
}

/* sidebar layout (filters, account) */
.layout-aside { display: grid; gap: 16px; }
.layout-aside__side, .layout-aside__main { min-width: 0; }

@media (min-width: 1024px) {
  .layout-aside { grid-template-columns: 264px minmax(0, 1fr); gap: 24px; align-items: start; }
  .layout-aside__side { position: sticky; top: 84px; }
}

.stack { display: flex; flex-direction: column; gap: 12px; }
.stack--sm { gap: 8px; }
.stack--lg { gap: 20px; }

.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.row--between { justify-content: space-between; }
.row--end { justify-content: flex-end; }
.row--nowrap { flex-wrap: nowrap; }

.grid { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }

@media (min-width: 640px) {
  .grid--2, .grid--3, .grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 1024px) {
  .grid { gap: 16px; }
  .grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* ===== 4. Utilities ================================================== */
.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -64px;
  z-index: 200;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: var(--on-primary);
  font-weight: 600;
}

.skip-link:focus { top: 12px; text-decoration: none; }

.muted { color: var(--muted); }
.ink-2 { color: var(--ink-2); }
.small { font-size: 13px; }
.xsmall { font-size: 12px; }
.bold { font-weight: 700; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.nowrap { white-space: nowrap; }
.mono { font-family: var(--font-mono); }
.w-full { width: 100%; }

.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.clamp-2, .clamp-3 {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.clamp-2 { -webkit-line-clamp: 2; }
.clamp-3 { -webkit-line-clamp: 3; }

.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: 4px !important; }
.mt-2 { margin-top: 8px !important; }
.mt-3 { margin-top: 12px !important; }
.mt-4 { margin-top: 16px !important; }
.mt-5 { margin-top: 24px !important; }
.mt-6 { margin-top: 32px !important; }
.mb-0 { margin-bottom: 0 !important; }
.mb-2 { margin-bottom: 8px !important; }
.mb-3 { margin-bottom: 12px !important; }
.mb-4 { margin-bottom: 16px !important; }
.mb-5 { margin-bottom: 24px !important; }

@media (max-width: 767.98px) {
  .hidden-mobile { display: none !important; }
}

@media (min-width: 768px) {
  .hidden-desktop { display: none !important; }
}

/* ===== 5. Header ===================================================== */
.site-header {
  position: -webkit-sticky;
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.hdr {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas:
    "logo gap actions"
    "search search search";
  align-items: center;
  column-gap: 12px;
}

.hdr__logo {
  grid-area: logo;
  display: flex;
  align-items: center;
  height: var(--hdr-top);
  border-radius: var(--radius-xs);
}

.hdr__logo img { height: 28px; width: auto; }
.hdr__logo:hover { text-decoration: none; }

.hdr .hdr__catalog { grid-area: catalog; display: none; } /* beats .btn display */
.hdr__search { grid-area: search; padding-bottom: 10px; min-width: 0; }

.hdr__actions {
  grid-area: actions;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}

.hdr__btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 44px;
  height: 44px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}

.hdr__btn:hover { background: var(--surface-2); text-decoration: none; }

/* label stays readable for screen readers when visually hidden */
.hdr__btn-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.hdr__phone {
  display: none;
  align-items: center;
  gap: 6px;
  height: 44px;
  padding: 0 8px;
  color: var(--ink);
  font-weight: 700;
  font-size: 14px;
  white-space: nowrap;
}

.hdr__phone:hover { color: var(--primary); text-decoration: none; }

@media (max-width: 767.98px) {
  /* on phones the logo row scrolls away, the search row stays */
  .site-header { top: calc(var(--hdr-top) * -1); }
  .hdr__btn--account, .hdr__btn--cart { display: none; }
}

@media (min-width: 768px) {
  .hdr {
    grid-template-columns: auto auto minmax(0, 1fr) auto;
    grid-template-areas: "logo catalog search actions";
    column-gap: 16px;
    min-height: 68px;
  }

  .hdr__logo { height: 68px; }
  .hdr__logo img { height: 30px; }
  .hdr .hdr__catalog { display: inline-flex; }
  .hdr__search { padding-bottom: 0; }
}

@media (min-width: 1024px) {
  .hdr__logo img { height: 32px; }

  .hdr__btn-label {
    position: static;
    width: auto;
    height: auto;
    max-width: 120px;
    clip: auto;
    text-overflow: ellipsis;
  }
}

@media (min-width: 1280px) {
  .hdr__phone { display: inline-flex; }
}

/* cart counter bubble ([data-cart-count]) */
.count {
  position: absolute;
  top: 3px;
  left: 25px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--danger);
  color: #FFFFFF;
  font-size: 11px;
  font-weight: 800;
  line-height: 18px;
  text-align: center;
  box-shadow: 0 0 0 2px var(--surface);
  pointer-events: none;
}

.count.is-bump { animation: avk-bump .35s var(--ease); }

@keyframes avk-bump {
  0% { transform: scale(1); }
  40% { transform: scale(1.35); }
  100% { transform: scale(1); }
}

/* language switch */
.lang {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
}

.lang__link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  height: 32px;
  padding: 0 8px;
  border-radius: var(--radius-pill);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .02em;
}

.lang__link:hover { color: var(--ink); text-decoration: none; }

.lang__link.is-active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

/* ===== 6. Search + suggest =========================================== */
.search { position: relative; display: flex; align-items: center; width: 100%; }

.search__icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.search__input {
  width: 100%;
  height: 44px;
  padding: 0 12px 0 40px;
  border: 1.5px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--ink);
  font-size: 16px;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color .15s, background-color .15s, box-shadow .15s;
}

.search__input::placeholder { color: var(--muted); opacity: 1; }

.search__input:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--focus);
}

.search__btn {
  display: none;
  position: absolute;
  top: 4px;
  right: 4px;
  bottom: 4px;
  padding: 0 16px;
  border-radius: 8px;
  background: var(--primary);
  color: var(--on-primary);
  font-size: 14px;
  font-weight: 700;
}

.search__btn:hover { background: var(--primary-hover); }

@media (min-width: 768px) {
  .search__input { border-color: var(--line); background: var(--surface); }
}

@media (min-width: 1024px) {
  .search__input { padding-right: 112px; }
  .search__btn { display: inline-flex; align-items: center; }
}

.suggest {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: var(--z-suggest);
  max-height: 70vh;
  overflow: auto;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.suggest__group + .suggest__group { margin-top: 4px; padding-top: 4px; border-top: 1px solid var(--line); }

.suggest__label {
  padding: 8px 10px 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.suggest__item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 7px 10px;
  border-radius: 8px;
  color: var(--ink);
  cursor: pointer;
}

.suggest__item:hover, .suggest__item.is-active { background: var(--surface-2); text-decoration: none; }

.suggest__img {
  flex: none;
  width: 40px;
  height: 40px;
  padding: 2px;
  border-radius: 8px;
  background: var(--img-bg);
  border: 1px solid var(--line);
  object-fit: contain;
}

.suggest__ico {
  flex: none;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--primary-soft);
  color: var(--primary);
}

.suggest__text { flex: 1; min-width: 0; }

.suggest__name {
  display: block;
  font-size: 14px;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.suggest__name mark { background: none; color: var(--primary); font-weight: 700; }
.suggest__meta { display: block; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggest__price { flex: none; font-size: 14px; font-weight: 700; white-space: nowrap; }
.suggest__count { flex: none; font-size: 12px; color: var(--muted); }

.suggest__all {
  justify-content: center;
  margin-top: 4px;
  color: var(--primary);
  font-size: 14px;
  font-weight: 700;
}

.suggest__empty { padding: 14px 10px; color: var(--muted); font-size: 14px; }

/* ===== 7. Telegram bar, tab bar, footer ============================== */
.tg-bar { display: none; }

.tg-bar__btn {
  position: relative;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  color: var(--ink);
}

.tg-bar__btn:hover { background: var(--surface-2); text-decoration: none; }
.tg-bar__btn .count { top: 0; left: 22px; }

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: var(--z-tabbar);
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  padding-bottom: var(--safe-b);
  background: var(--surface);
  border-top: 1px solid var(--line);
  box-shadow: 0 -4px 16px rgba(15, 23, 42, .05);
}

.tabbar__item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: var(--tabbar-h);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.1;
}

.tabbar__item:hover { text-decoration: none; color: var(--ink); }
.tabbar__item.is-active { color: var(--primary); }
.tabbar__label { max-width: 100%; padding: 0 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tabbar .count { top: 5px; left: calc(50% + 3px); }

@media (max-width: 767.98px) {
  body { padding-bottom: calc(var(--tabbar-h) + var(--safe-b)); }
}

@media (min-width: 768px) {
  .tabbar { display: none; }
}

.site-footer {
  margin-top: 48px;
  padding-top: 32px;
  background: var(--surface);
  border-top: 1px solid var(--line);
  color: var(--ink-2);
  font-size: 14px;
}

.footer { display: grid; gap: 28px; grid-template-columns: minmax(0, 1fr); }

@media (min-width: 640px) {
  .footer { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 1024px) {
  .footer { grid-template-columns: 1.4fr 1fr 1fr 1.4fr; gap: 32px; }
}

.footer__logo img { height: 30px; width: auto; }
.footer__about { margin-top: 12px; color: var(--muted); line-height: 1.55; }
.footer__contacts { margin-top: 14px; display: flex; flex-direction: column; gap: 6px; }

.footer__phone {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: .01em;
}

.footer__mail { display: inline-flex; align-items: center; gap: 8px; color: var(--ink-2); }

.footer__title {
  margin-bottom: 12px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: .01em;
}

.footer__links { display: flex; flex-direction: column; gap: 2px; }

.footer__links a {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  color: var(--ink-2);
}

.footer__links a:hover { color: var(--primary); }

.footer__info { display: flex; flex-direction: column; gap: 10px; }
.footer__info li { display: flex; gap: 10px; align-items: flex-start; line-height: 1.45; }
.footer__info .icon { color: var(--primary); margin-top: 1px; }

.footer__bottom {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 16px;
  margin-top: 28px;
  padding-top: 16px;
  padding-bottom: 20px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

.footer__bottom a { color: var(--muted); }

.social { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

.social__link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--ink-2);
  transition: background-color .15s, color .15s;
}

.social__link:hover { background: var(--primary); color: var(--on-primary); text-decoration: none; }

/* ===== 8. Buttons ==================================================== */
.btn {
  --btn-h: 44px;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: var(--btn-h);
  padding: 0 18px;
  border: 1.5px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  -webkit-appearance: none;
  appearance: none;
  transition: background-color .15s, border-color .15s, color .15s, box-shadow .15s, transform .1s;
}

.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }

.btn--primary { background: var(--primary); color: var(--on-primary); }
.btn--primary:hover { background: var(--primary-hover); color: var(--on-primary); }

.btn--secondary { background: var(--primary-soft); color: var(--primary-ink); }
.btn--secondary:hover { background: var(--primary); color: var(--on-primary); }

.btn--ghost { background: var(--surface); border-color: var(--line-strong); color: var(--ink); }
.btn--ghost:hover { background: var(--surface-2); color: var(--ink); }

.btn--danger { background: var(--danger); color: #FFFFFF; }
.btn--danger:hover { background: var(--danger-ink); color: #FFFFFF; }

.btn--link { height: auto; padding: 0; background: none; color: var(--link); font-weight: 600; }
.btn--link:hover { text-decoration: underline; }

.btn--sm { --btn-h: 36px; padding: 0 12px; gap: 6px; font-size: 14px; }
.btn--lg { --btn-h: 52px; padding: 0 24px; font-size: 16px; }
.btn--block { display: flex; width: 100%; }
.btn--icon { width: var(--btn-h); padding: 0; }
.btn__idle { display: inline-flex; align-items: center; gap: 6px; }
.btn__done { display: none; }
.btn.is-done .btn__idle { display: none; }
.btn.is-done .btn__done { display: inline-flex; align-items: center; gap: 6px; }
.btn.is-done { background: var(--success); border-color: var(--success); color: #FFFFFF; }

.btn:disabled, .btn.is-disabled { opacity: .5; cursor: default; pointer-events: none; }

.btn.is-loading { pointer-events: none; }
.btn.is-loading > * { visibility: hidden; }

.btn.is-loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: avk-spin .7s linear infinite;
}

@keyframes avk-spin {
  to { transform: rotate(360deg); }
}

.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: avk-spin .7s linear infinite;
  vertical-align: middle;
}

/* ===== 9. Forms ====================================================== */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field__label { color: var(--ink); font-size: 14px; font-weight: 700; }
.field__req { margin-left: 2px; color: var(--danger); }
.field__opt { margin-left: 4px; color: var(--muted); font-weight: 500; }
.field__control { position: relative; display: flex; align-items: stretch; min-width: 0; }
.field__hint { color: var(--muted); font-size: 13px; line-height: 1.4; }
.field__error { color: var(--danger-ink); font-size: 13px; font-weight: 600; line-height: 1.4; }

.input, .select {
  width: 100%;
  min-width: 0;
  min-height: 48px;
  padding: 12px 14px;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.3;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color .15s, box-shadow .15s, background-color .15s;
}

textarea.input { min-height: 104px; resize: vertical; line-height: 1.45; }
.input::placeholder { color: var(--muted); opacity: .85; }
.input:hover, .select:hover { border-color: var(--muted); }

.input:focus, .select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--focus);
}

.input:disabled, .select:disabled, .input[readonly] { background: var(--surface-2); color: var(--muted); }
.select { padding-right: 42px; cursor: pointer; }
.select::-ms-expand { display: none; }

.field__chevron {
  position: absolute;
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.field__affix {
  flex: none;
  display: flex;
  align-items: center;
  padding: 0 12px;
  border: 1.5px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
}

.field__affix--pre { border-right: 0; border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.field__affix--suf { border-left: 0; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.field__affix--pre + .input { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.field__control .input:not(:last-child) { border-top-right-radius: 0; border-bottom-right-radius: 0; }

.field.is-invalid .input,
.field.is-invalid .select,
.field.is-invalid .field__affix { border-color: var(--danger); }
.field.is-invalid .input:focus, .field.is-invalid .select:focus { box-shadow: 0 0 0 3px var(--danger-soft); }

.form-grid { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }

@media (min-width: 640px) {
  .form-grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid .span-2 { grid-column: 1 / -1; }
}

.form-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }

/* checkbox / switch */
.check {
  position: relative;
  display: inline-flex;
  align-items: flex-start;
  gap: 10px;
  min-height: 44px;
  padding: 10px 0;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.4;
  cursor: pointer;
}

.check__input { position: absolute; top: 12px; left: 2px; width: 18px; height: 18px; margin: 0; opacity: 0; }

.check__box {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: 1.5px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  color: transparent;
  transition: background-color .15s, border-color .15s, box-shadow .15s;
}

.check__input:checked + .check__box { border-color: var(--primary); background: var(--primary); color: var(--on-primary); }
.check__input:focus-visible + .check__box { box-shadow: 0 0 0 3px var(--focus); }
.check__input:disabled + .check__box { opacity: .5; }
.check__label { min-width: 0; }
.check__label a { text-decoration: underline; }
.check.is-invalid .check__box { border-color: var(--danger); }

.check--switch .check__box {
  position: relative;
  width: 42px;
  height: 26px;
  border-radius: 13px;
  background: var(--line-strong);
  border-color: transparent;
}

.check--switch .check__box .icon { display: none; }

.check--switch .check__box::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: #FFFFFF;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
  transition: transform .18s var(--ease);
}

.check--switch .check__input:checked + .check__box::after { transform: translateX(16px); }

/* radio option card */
.radio-card {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  transition: border-color .15s, background-color .15s, box-shadow .15s;
}

.radio-card:hover { border-color: var(--line-strong); }
.radio-card__input { position: absolute; top: 16px; left: 18px; width: 18px; height: 18px; margin: 0; opacity: 0; }

.radio-card__dot {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  margin-top: 1px;
  border: 1.5px solid var(--line-strong);
  border-radius: 50%;
  background: var(--surface);
}

.radio-card__dot::after {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--primary);
  transform: scale(0);
  transition: transform .15s var(--ease);
}

.radio-card__input:checked + .radio-card__dot { border-color: var(--primary); }
.radio-card__input:checked + .radio-card__dot::after { transform: scale(1); }
.radio-card__input:focus-visible + .radio-card__dot { box-shadow: 0 0 0 3px var(--focus); }
.radio-card__input:disabled ~ * { opacity: .55; }
.radio-card.is-checked { border-color: var(--primary); background: var(--primary-soft); }
.radio-card:has(.radio-card__input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.radio-card__main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.radio-card__title { font-weight: 700; }
.radio-card__desc { color: var(--muted); font-size: 13px; line-height: 1.4; }
.radio-card__aside { margin-left: auto; padding-left: 8px; font-weight: 700; white-space: nowrap; }
.radio-list { display: grid; gap: 8px; }

/* quantity stepper */
.qty {
  display: inline-flex;
  align-items: stretch;
  height: 44px;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  overflow: hidden;
}

.qty__btn {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  color: var(--ink);
  transition: background-color .15s;
}

.qty__btn:hover { background: var(--surface-2); }
.qty__btn:disabled { opacity: .35; }

.qty__input {
  flex: 1 1 auto;
  width: 48px;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 16px;
  font-weight: 700;
  text-align: center;
  -moz-appearance: textfield;
  appearance: textfield;
}

.qty__input::-webkit-outer-spin-button,
.qty__input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.qty__input:focus { outline: none; background: var(--surface-2); }
.qty--sm { height: 36px; }
.qty--sm .qty__btn { width: 32px; }
.qty--sm .qty__input { width: 38px; }
.qty--lg { height: 52px; }
.qty--lg .qty__btn { width: 48px; }

/* ===== 10. Badges, chips, price, stock, alerts ======================= */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 24px;
  padding: 0 9px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.badge--primary { background: var(--primary-soft); color: var(--primary-ink); }
.badge--success { background: var(--success-soft); color: var(--success-ink); }
.badge--warning { background: var(--warning-soft); color: var(--warning-ink); }
.badge--danger { background: var(--danger-soft); color: var(--danger-ink); }
.badge--info { background: var(--accent-soft); color: var(--accent-ink); }
.badge--sale { background: var(--c-danger); color: #FFFFFF; }
.badge--new { background: var(--c-accent); color: #FFFFFF; }
.badge--outline { background: transparent; box-shadow: inset 0 0 0 1px var(--line-strong); color: var(--ink-2); }
.badge--sm { height: 20px; padding: 0 7px; font-size: 11px; }
.badge--lg { height: 28px; padding: 0 12px; font-size: 13px; }

.badge--dot::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 0;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.chips::-webkit-scrollbar { display: none; }

.chip {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}

.chip:hover { border-color: var(--line-strong); color: var(--ink); text-decoration: none; }
.chip.is-active { border-color: var(--ink); background: var(--ink); color: var(--surface); }

.price {
  --price-fs: 18px;
  display: inline-flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 8px;
  color: var(--ink);
  line-height: 1.2;
}

.price__amount { font-size: var(--price-fs); font-weight: 800; letter-spacing: -.01em; white-space: nowrap; }
.price__old { color: var(--muted); font-size: 13px; text-decoration: line-through; white-space: nowrap; }

.price__off {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--radius-pill);
  background: var(--danger-soft);
  color: var(--danger-ink);
  font-size: 12px;
  font-weight: 800;
}

.price__unit { color: var(--muted); font-size: 13px; white-space: nowrap; }
.price--sm { --price-fs: 15px; }
.price--md { --price-fs: 18px; }
.price--lg { --price-fs: 22px; }
.price--xl { --price-fs: 26px; }
.price--none .price__amount { color: var(--muted); font-size: 14px; font-weight: 700; letter-spacing: 0; white-space: normal; }
.price--personal .price__amount { color: var(--success-ink); }

@media (min-width: 768px) {
  .price--xl { --price-fs: 32px; }
}

.stock {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
}

.stock__dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.stock--in-stock { color: var(--success-ink); }
.stock--incoming { color: var(--warning-ink); }
.stock--on-order { color: var(--muted); }
.stock--sm { font-size: 12px; }
.stock--lg { font-size: 15px; }

.alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
}

.alert__icon { flex: none; margin-top: 1px; }
.alert__main { flex: 1; min-width: 0; }
.alert__title { display: block; font-weight: 800; margin-bottom: 2px; }
.alert--info { background: var(--primary-soft); border-color: transparent; }
.alert--info .alert__icon { color: var(--primary); }
.alert--success { background: var(--success-soft); border-color: transparent; }
.alert--success .alert__icon { color: var(--success-ink); }
.alert--warning { background: var(--warning-soft); border-color: transparent; }
.alert--warning .alert__icon { color: var(--warning-ink); }
.alert--danger { background: var(--danger-soft); border-color: transparent; }
.alert--danger .alert__icon { color: var(--danger-ink); }

/* ===== 11. Product card & grid, category tile ======================= */
.pgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }

@media (min-width: 640px) {
  .pgrid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
}

@media (min-width: 1024px) {
  .pgrid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
  .pgrid--max3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (min-width: 1280px) {
  .pgrid--max5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}

.pcard {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  transition: box-shadow .2s, border-color .2s;
}

@media (hover: hover) {
  .pcard:hover { border-color: transparent; box-shadow: var(--shadow-md); }
  .pcard:hover .pcard__img { transform: scale(1.03); }
}

.pcard__media {
  position: relative;
  display: block;
  padding-top: 100%;
  background: var(--img-bg);
  overflow: hidden;
}

.pcard__img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  padding: 10px;
  object-fit: contain;
  transition: transform .3s var(--ease);
}

.pcard__badges {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.pcard__body { display: flex; flex-direction: column; gap: 5px; flex: 1 1 auto; padding: 10px 10px 0; min-width: 0; }

.pcard__name {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.pcard__name a { color: inherit; }
.pcard__name a:hover { text-decoration: none; }

/* stretched link: the whole card opens the product */
.pcard__name a::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 0;
}

.pcard__meta { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.pcard__buy {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: auto;
  padding: 10px;
}

.pcard__qty { display: none; flex: 1 1 auto; min-width: 0; height: 40px; }
.pcard__qty .qty__btn { width: 34px; }
.pcard__add { --btn-h: 40px; flex: 1 1 auto; padding: 0 10px; font-size: 14px; }

.pcard__license { --btn-h: 40px; flex: 1 1 auto; min-width: 0; padding: 0 10px; font-size: 14px; }
.pcard__license span { overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 479.98px) {
  /* the lock badge on the photo already says it; keep the whole label readable */
  .pcard__license { padding: 0 6px; font-size: 13px; letter-spacing: -.01em; }
  .pcard__license .icon { display: none; }
}

@media (min-width: 480px) {
  .pcard__qty { display: inline-flex; }
  .pcard__add { flex: none; width: 44px; padding: 0; }
  .pcard__add .pcard__add-label { display: none; }
}

.cgrid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }

@media (min-width: 640px) {
  .cgrid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
}

@media (min-width: 1024px) {
  .cgrid { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 16px; }
}

.ctile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 12px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  text-align: center;
  transition: border-color .15s, box-shadow .15s;
}

.ctile:hover { border-color: var(--primary); box-shadow: var(--shadow-sm); text-decoration: none; }

.ctile__img {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border-radius: 14px;
  background: var(--img-bg);
  overflow: hidden;
}

.ctile__img img { width: 100%; height: 100%; padding: 6px; object-fit: contain; }

.ctile__name {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  max-width: 100%;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.3;
  overflow-wrap: break-word;
  -webkit-hyphens: auto;
  hyphens: auto;
}

@media (max-width: 399.98px) {
  .ctile { padding: 10px 4px; }
  .ctile__name { font-size: 12px; letter-spacing: -.01em; }
}

.ctile__count { color: var(--muted); font-size: 12px; }

@media (min-width: 768px) {
  .ctile { padding: 16px 12px; }
  .ctile__img { width: 80px; height: 80px; }
  .ctile__name { font-size: 14px; }
}

/* ===== 12. Gallery, scroll rows, key-value, table, prose ============= */
.gallery { display: grid; gap: 10px; }

.gallery__main {
  position: relative;
  padding-top: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--img-bg);
  overflow: hidden;
}

.gallery__img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  padding: 16px;
  object-fit: contain;
}

.gallery__thumbs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.gallery__thumbs::-webkit-scrollbar { display: none; }

.gallery__thumb {
  flex: none;
  width: 64px;
  height: 64px;
  padding: 4px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--img-bg);
  overflow: hidden;
  scroll-snap-align: start;
  cursor: pointer;
}

.gallery__thumb img { width: 100%; height: 100%; object-fit: contain; }
.gallery__thumb.is-active { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }

.snap {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
}

.snap::-webkit-scrollbar { display: none; }
.snap > * { flex: none; scroll-snap-align: start; }
.snap--cards > * { width: 44%; }

@media (min-width: 640px) {
  .snap--cards > * { width: 30%; }
}

@media (min-width: 1024px) {
  .snap--cards > * { width: 23%; }
}

.kv { display: grid; grid-template-columns: minmax(110px, 42%) minmax(0, 1fr); font-size: 14px; }
.kv dt, .kv__key { padding: 9px 12px 9px 0; border-bottom: 1px dashed var(--line); color: var(--muted); }
.kv dd, .kv__val { margin: 0; padding: 9px 0; border-bottom: 1px dashed var(--line); color: var(--ink); overflow-wrap: anywhere; }

.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.table { width: 100%; font-size: 14px; }
.table th { padding: 10px 14px; background: var(--surface-2); color: var(--muted); font-size: 12px; font-weight: 700; text-align: left; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; }
.table td { padding: 12px 14px; border-top: 1px solid var(--line); vertical-align: top; }
.table .num { text-align: right; white-space: nowrap; }
.table .mono, .table .nowrap { white-space: nowrap; }

.prose { color: var(--ink); font-size: 16px; line-height: 1.65; overflow-wrap: break-word; }
.prose > * + * { margin-top: .9em; }
.prose h2 { margin-top: 1.6em; font-size: 22px; }
.prose h3 { margin-top: 1.4em; font-size: 18px; }
.prose ul, .prose ol { padding-left: 1.4em; }
.prose li + li { margin-top: .3em; }
.prose a { text-decoration: underline; }
.prose img { border-radius: var(--radius); }
.prose table { width: 100%; border: 1px solid var(--line); font-size: 14px; }
.prose th, .prose td { padding: 8px 10px; border: 1px solid var(--line); text-align: left; vertical-align: top; }
.prose blockquote { padding-left: 14px; border-left: 3px solid var(--primary); color: var(--ink-2); }

/* ===== 13. Breadcrumbs, pagination, empty state ===================== */
.crumbs {
  margin: 12px 0;
  color: var(--muted);
  font-size: 13px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.crumbs::-webkit-scrollbar { display: none; }
.crumbs__list { display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.crumbs__item { display: inline-flex; align-items: center; gap: 4px; }
.crumbs__link { display: inline-flex; align-items: center; min-height: 32px; color: var(--muted); }
.crumbs__link:hover { color: var(--ink); }
.crumbs__sep { color: var(--line-strong); }
.crumbs__current { max-width: 70vw; overflow: hidden; text-overflow: ellipsis; color: var(--ink); font-weight: 600; }

.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 24px 0 8px;
}

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

.pager__link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 44px;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font-weight: 700;
}

.pager__link:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }
.pager__link.is-current { border-color: var(--primary); background: var(--primary); color: var(--on-primary); }
.pager__link.is-disabled { opacity: .4; pointer-events: none; }
.pager__gap { padding: 0 2px; color: var(--muted); }
.pager__info { display: none; padding: 0 8px; color: var(--ink-2); font-weight: 700; }

@media (max-width: 639.98px) {
  .pager__num, .pager__gap { display: none; }
  .pager__info { display: inline-flex; }
  .pager__text { display: none; }
}

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 40px 16px;
  text-align: center;
}

.empty__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
}

.empty__title { color: var(--ink); font-size: 18px; font-weight: 800; }
.empty__text { max-width: 440px; color: var(--muted); }
.empty__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 6px; }

/* ===== 14. Overlays: modal, drawer, toast ============================ */
.modal, .drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
}

.modal { z-index: var(--z-modal); display: flex; align-items: flex-end; justify-content: center; }
.drawer { z-index: var(--z-drawer); }

.modal__backdrop, .drawer__backdrop {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: var(--overlay);
  opacity: 0;
  transition: opacity var(--dur) ease;
}

.modal.is-open .modal__backdrop,
.drawer.is-open .drawer__backdrop { opacity: 1; }

.modal__dialog {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-height: 92vh;
  max-height: 92dvh;
  padding-bottom: var(--safe-b);
  border-radius: 18px 18px 0 0;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(32px);
  transition: transform var(--dur) var(--ease), opacity var(--dur) ease;
}

.modal.is-open .modal__dialog { opacity: 1; transform: none; }

@media (min-width: 640px) {
  .modal { align-items: center; padding: 24px; }
  .modal__dialog { max-width: 520px; padding-bottom: 0; border-radius: 18px; transform: translateY(10px) scale(.98); }
  .modal__dialog--sm { max-width: 400px; }
  .modal__dialog--lg { max-width: 760px; }
}

.modal__head, .drawer__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal__head { padding: 14px 10px 6px 20px; }
.modal__title, .drawer__title { font-size: 18px; font-weight: 800; line-height: 1.3; }

.modal__x, .drawer__x {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin-left: auto;
  border-radius: 50%;
  color: var(--muted);
}

.modal__x:hover, .drawer__x:hover { background: var(--surface-2); color: var(--ink); }
.modal__body { padding: 8px 20px 20px; overflow: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }

.modal__foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px 16px;
  border-top: 1px solid var(--line);
}

.drawer__panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 440px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  transform: translateX(100%);
  transition: transform .26s var(--ease);
}

.drawer--left .drawer__panel { right: auto; left: 0; transform: translateX(-100%); }
.drawer--wide .drawer__panel { max-width: 560px; }
.drawer.is-open .drawer__panel { transform: none; }
.drawer__head { min-height: 60px; padding: 8px 8px 8px 20px; border-bottom: 1px solid var(--line); }
.drawer__body { flex: 1 1 auto; padding: 16px 20px; overflow: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }

.drawer__foot {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 20px calc(14px + var(--safe-b));
  border-top: 1px solid var(--line);
  background: var(--surface);
}

html.is-locked, html.is-locked body { overflow: hidden; }
html.is-locked body { padding-right: var(--sbw, 0px); }

.toasts {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 12px);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

@media (min-width: 768px) {
  .toasts { left: auto; right: 24px; bottom: 24px; width: 400px; align-items: flex-end; }
}

/* while a modal/drawer is open, keep toasts off its footer */
html.is-locked .toasts { top: calc(12px + env(safe-area-inset-top, 0px)); bottom: auto; }

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 440px;
  min-height: 48px;
  padding: 8px 6px 8px 14px;
  border-radius: 12px;
  background: var(--toast-bg);
  color: #F8FAFC;
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  line-height: 1.4;
  pointer-events: none; /* never block the page; only the buttons are clickable */
  opacity: 0;
  transform: translateY(14px);
  transition: transform .22s var(--ease), opacity .22s ease;
}

.toast.is-in { opacity: 1; transform: none; }

.toast::before {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--toast-c, #60A5FA);
}

.toast--success { --toast-c: #4ADE80; }
.toast--error { --toast-c: #F87171; }
.toast--warning { --toast-c: #FBBF24; }
.toast__text { flex: 1 1 auto; min-width: 0; padding: 4px 0; }

.toast__action {
  flex: none;
  pointer-events: auto;
  padding: 8px 10px;
  border-radius: 8px;
  color: #93C5FD;
  font-weight: 800;
  white-space: nowrap;
}

.toast__action:hover { background: rgba(255, 255, 255, .08); color: #BFDBFE; text-decoration: none; }

.toast__x {
  flex: none;
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  color: rgba(248, 250, 252, .6);
}

.toast__x:hover { background: rgba(255, 255, 255, .08); color: #F8FAFC; }

/* cart drawer content */
.cart-list { display: flex; flex-direction: column; }

.citem {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  transition: opacity .15s;
}

.citem:first-child { padding-top: 0; }
.citem.is-busy { opacity: .55; pointer-events: none; }

.citem__img {
  display: block;
  width: 64px;
  height: 64px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--img-bg);
  overflow: hidden;
}

.citem__img img { width: 100%; height: 100%; padding: 4px; object-fit: contain; }
.citem__main { min-width: 0; }

.citem__name {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.35;
}

.citem__name:hover { color: var(--primary); text-decoration: none; }
.citem__meta { margin-top: 2px; color: var(--muted); font-size: 12px; }
.citem__na { display: inline-block; margin-top: 4px; color: var(--danger-ink); font-size: 12px; font-weight: 700; }
.citem__row { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.citem__sum { margin-left: auto; font-size: 15px; font-weight: 800; white-space: nowrap; }

.citem__remove {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  color: var(--muted);
}

.citem__remove:hover { background: var(--danger-soft); color: var(--danger-ink); }
.cart-sum { display: flex; flex-direction: column; gap: 6px; margin-bottom: 4px; }
.cart-sum__row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.cart-sum__total { font-size: 22px; font-weight: 800; letter-spacing: -.01em; }
.cart-note { color: var(--muted); font-size: 13px; line-height: 1.4; }

/* ===== 15. Skeleton loaders ========================================== */
.sk {
  position: relative;
  display: block;
  overflow: hidden;
  border-radius: 8px;
  background: var(--surface-2);
}

.sk::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: linear-gradient(90deg, transparent, var(--shimmer), transparent);
  transform: translateX(-100%);
  animation: avk-shimmer 1.3s ease-in-out infinite;
}

@keyframes avk-shimmer {
  100% { transform: translateX(100%); }
}

.sk--text { height: 12px; margin: 6px 0; }
.sk--title { height: 18px; width: 60%; margin: 6px 0; }
.sk--img { padding-top: 100%; border-radius: 0; }
.sk--btn { height: 40px; border-radius: var(--radius-sm); }
.sk--circle { width: 44px; height: 44px; border-radius: 50%; }
.sk-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.sk-card__body { padding: 10px; }
.sk-row { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.sk-row .sk--img { padding-top: 0; height: 64px; border-radius: var(--radius-sm); }

/* ===== 16. Account layout ============================================ */
.account { display: grid; gap: 16px; padding-top: 16px; padding-bottom: 40px; }

@media (min-width: 1024px) {
  .account { grid-template-columns: 272px minmax(0, 1fr); gap: 24px; align-items: start; padding-top: 24px; }
}

.account__aside {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

@media (min-width: 1024px) {
  .account__aside { position: sticky; top: 84px; padding: 16px; }
}

.account__user {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 4px 12px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.account__avatar {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 16px;
  font-weight: 800;
}

.account__who { min-width: 0; }
.account__name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 800; }
.account__phone { display: block; color: var(--muted); font-size: 13px; }

.account__nav {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.account__nav::-webkit-scrollbar { display: none; }

.account__link {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  color: var(--ink-2);
  font-weight: 600;
  white-space: nowrap;
}

.account__link:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.account__link.is-active { background: var(--primary-soft); color: var(--primary-ink); }
.account__logout { color: var(--danger-ink); }
.account__logout:hover { background: var(--danger-soft); color: var(--danger-ink); }
.account__main { min-width: 0; }
.account__title { margin-bottom: 16px; }

@media (max-width: 1023.98px) {
  /* horizontal strip: fade the right edge so it reads as scrollable */
  .account__nav {
    padding-right: 40px;
    -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent);
    mask-image: linear-gradient(90deg, #000 85%, transparent);
  }
}

@media (min-width: 1024px) {
  .account__nav { flex-direction: column; overflow: visible; }
  .account__link { flex: initial; }
}

/* ===== 17. Error pages =============================================== */
.error-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  max-width: 580px;
  margin: 0 auto;
  padding: 40px 0 56px;
  text-align: center;
}

.error-page__code {
  font-size: 76px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -.04em;
  color: var(--primary);
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.error-page__title { font-size: 24px; font-weight: 800; line-height: 1.25; }
.error-page__text { max-width: 480px; color: var(--muted); font-size: 16px; }
.error-page__search { width: 100%; max-width: 440px; margin-top: 8px; }
.error-page__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 8px; }

/* ===== 18. Telegram Mini App mode ==================================== */
.tg-app .site-header,
.tg-app .site-footer,
.tg-app .tabbar { display: none !important; }

.tg-app body, body.tg-app { padding-bottom: 0; }

.tg-app .tg-bar {
  position: -webkit-sticky;
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--tg-theme-bg-color, var(--surface));
  border-bottom: 1px solid var(--line);
}

.tg-app .tg-bar .search { flex: 1 1 auto; min-width: 0; }
.tg-app .tg-bar .search__input { height: 40px; border-color: transparent; background: var(--surface-2); padding-right: 12px; }
.tg-app .tg-bar .search__btn { display: none; }
.tg-app .toasts { bottom: calc(12px + var(--safe-b)); }
.tg-app .site-main { padding-bottom: 12px; }

/* ===== 19. Motion & print ============================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

@media print {
  .site-header, .site-footer, .tabbar, .tg-bar, .toasts, .drawer, .modal, .pcard__buy, .skip-link, .no-print { display: none !important; }
  body { padding: 0 !important; background: #FFFFFF; color: #000000; }
  .pcard, .card { break-inside: avoid; box-shadow: none !important; }
  a { color: inherit; }
}

/* ===== 20. Wide desktop: the page fills the screen (Doston 13.11: "komputerda 2ta cheti bo'm-bo'sh") ===== */
@media (min-width: 1440px) {
  :root { --container: 2560px; --gutter: 40px; }
  .hdr__search { width: 100%; max-width: 920px; }
}

@media (min-width: 1280px) {
  /* product grids: as many columns as fit (≈230px cards), whatever the max-N modifier says */
  .pgrid, .pgrid--max3, .pgrid--max4, .pgrid--max5 { grid-template-columns: repeat(auto-fill, minmax(228px, 1fr)); }
  .cgrid { grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); }
}
