/* =========================================================
   Layout primitives — adds wrappers, grids, header, footer,
   cookie banner, tooltip, mobile adaptive rules.
   Include AFTER components.css.
   ========================================================= */

/* ---------- Wrappers ---------- */
.wrap{ max-width: 1200px; margin: 0 auto; padding: 0 24px; }
@media (max-width: 768px){ .wrap{ padding: 0 16px; } }

.site-main{ padding: 32px 0 64px; background: var(--color-bg); }
@media (max-width: 768px){ .site-main{ padding: 20px 0 40px; } }

.divider{ height: 1px; background: var(--color-line); margin: 18px 0 22px; }

/* ---------- Header (lightheader) ---------- */
.lightheader{ background: var(--color-surface); border-bottom: 1px solid var(--color-line); padding-top: 14px; padding-bottom: 22px; }
.lightheader .navrow{ display: flex; align-items: center; justify-content: space-between; gap: 16px; }

.brand-dark{ display: flex; align-items: center; gap: 10px; font-size: 15px; color: var(--color-text); }
.brand-dark b{ font-weight: 600; }
.brand-dark .sep{ color: var(--color-line); }
.brand-dark .muted{ color: var(--color-text-muted); font-size: 13px; }
.mark-forest{
  width: 28px; height: 28px; border-radius: 8px;
  background: var(--color-primary); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; font-family: var(--font-sans);
}

.nav-links{ display: flex; gap: 24px; font-size: 14px; align-items: center; }
.nav-links a{ color: var(--color-text-muted); text-decoration: none; padding: 6px 0; }
.nav-links a[aria-current="page"]{ color: var(--color-text); font-weight: 500; }
.nav-links a:hover{ color: var(--color-text); }

.hd-title{ margin-top: 4px; }
.hd-title h1{
  font-size: 34px; font-weight: 600; letter-spacing: -.022em;
  margin: 0 0 8px; line-height: 1.15; max-width: 820px;
}
.lede-dark{ font-size: 15px; color: var(--color-text-muted); max-width: 680px; line-height: 1.5; margin: 0; }
@media (max-width: 768px){
  .hd-title h1{ font-size: 26px; }
  .lede-dark{ font-size: 14px; }
  .nav-links{ gap: 14px; font-size: 13px; }
  .nav-links a:not(:last-child){ display: none; }  /* keep only CTA on phone */
}

/* ---------- Two-column & NDS grids ---------- */
.two-col{
  display: grid; grid-template-columns: 400px 1fr; gap: 28px;
  max-width: 1200px; margin: 0 auto;
}
.nds-grid{
  display: grid; grid-template-columns: 400px 1fr; gap: 28px;
  max-width: 1000px; margin: 0 auto;
}
.nds-body{ padding: 32px 0 64px; background: var(--color-bg); }

@media (max-width: 768px){
  .two-col, .nds-grid{ grid-template-columns: 1fr; gap: 16px; padding: 0 16px; }

  /* Mobile reorder: hero → форма → сравнение → бары → next-steps → reminder → meta → hub → FAQ → SEO.
     Раскрываем правую <section> через display:contents, чтобы её дети
     стали прямыми детьми .two-col и слушали order: */
  .two-col > section{ display: contents; }

  /* Базовый order для всех «забытых» детей — в самый низ */
  .two-col > section > *      { order: 99; }

  .two-col > aside.card             { order: 2; }   /* форма — сразу под hero */
  .two-col > section > .hero        { order: 1; }
  .two-col > section > .compare     { order: 3; }
  .two-col > section > .bars        { order: 4; }
  .two-col > section > .next-steps  { order: 5; }
  .two-col > section > .reminder    { order: 6; }
  .two-col > section > .meta-note   { order: 7; }
  .two-col > section > .content-hub { order: 8; }
  .two-col > section > .faq-simple  { order: 9; }
  .two-col > section > .seo-content { order: 10; }

  /* После переноса формы наверх — небольшой ритм */
  .two-col > aside.card{ margin-bottom: 4px; }
}

/* ───────────────────────────────────────────────────────────────
   Mobile compact hero (≤768px) — normal state only.
   Цель: показать результат + форму на первом экране.
   alert / deadend / near-vat остаются полноразмерными — там критичен контекст.
   ─────────────────────────────────────────────────────────────── */
@media (max-width: 768px){
  .hero[data-hero-state="normal"] .hero-body{
    padding: 14px 16px 14px;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "badge"
      "mode"
      "figure"
      "delta"
      "jump";
    row-gap: 6px;
  }
  .hero[data-hero-state="normal"] .hero-badge-row{
    grid-area: badge;
    margin: 0; gap: 8px;
  }
  .hero[data-hero-state="normal"] .hero-badge-row .sub,
  .hero[data-hero-state="normal"] .hero-badge-row .tooltip-wrap{ display: none; }
  .hero[data-hero-state="normal"] .hero-badge{ font-size: 10px; padding: 2px 8px; }

  .hero[data-hero-state="normal"] .hero-mode{
    grid-area: mode;
    margin-top: 0; font-size: 13px;
    min-width: 0;
  }
  .hero[data-hero-state="normal"] .hero-mode b{ font-size: 15px; }
  .hero[data-hero-state="normal"] #reco-name-suffix{ display: none; }

  .hero[data-hero-state="normal"] .hero-figure{
    grid-area: figure;
    margin: 2px 0 0; min-width: 0; max-width: 100%;
    align-items: baseline; gap: 6px; flex-wrap: wrap;
  }
  .hero[data-hero-state="normal"] .hero-figure .value{
    font-size: clamp(24px, 8.5vw, 34px);
    letter-spacing: -.02em; line-height: 1;
    overflow-wrap: anywhere;
  }
  .hero[data-hero-state="normal"] .hero-figure .unit{ font-size: 13px; white-space: nowrap; }

  /* Длинная подпись и кнопки — прячем, они избыточны на компактном hero */
  .hero[data-hero-state="normal"] .hero-sub,
  .hero[data-hero-state="normal"] .hero-actions{ display: none; }

  /* Экономия — компактной плашкой во всю ширину */
  .hero[data-hero-state="normal"] .hero-delta{
    grid-area: delta;
    margin-top: 4px; padding: 6px 10px;
    font-size: 12px; line-height: 1.3;
    width: 100%; box-sizing: border-box;
  }
  .hero[data-hero-state="normal"] .hero-delta .tooltip-wrap{ display: none; }

  /* Ссылка-якорь к подробному сравнению */
  .hero[data-hero-state="normal"] .hero-jump-compare{
    grid-area: jump;
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    margin-top: 6px;
    padding: 10px 12px;
    font-size: 13px; font-weight: 500;
    color: var(--color-primary);
    background: var(--color-surface-2);
    border: 1px solid var(--color-line);
    border-radius: 10px;
    text-decoration: none;
    min-height: 40px;
  }
  .hero[data-hero-state="normal"] .hero-jump-compare:active{
    background: var(--color-primary-100);
  }

  /* Карточка формы — чуть плотнее, чтобы больше полей попало в первый экран */
  .two-col > aside.card{ scroll-margin-top: 12px; }
}

/* ---------- Compare section ---------- */
.compare{ margin-top: 32px; }
.compare-head{
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; margin-bottom: 16px;
}
.compare-head h2{
  font-size: 22px; font-weight: 600; margin: 0; letter-spacing: -.015em;
}

.view-toggle{
  display: inline-flex; gap: 4px; padding: 3px;
  background: var(--color-surface); border: 1px solid var(--color-line);
  border-radius: 8px;
}
.view-toggle button{
  border: 0; background: transparent; padding: 6px 14px;
  font: inherit; font-size: 12px; font-weight: 500;
  color: var(--color-text-muted); border-radius: 6px; cursor: pointer;
}
.view-toggle button.active,
.view-toggle button[aria-selected="true"]{
  background: var(--color-surface-2); color: var(--color-text);
}

/* ---------- FAQ grouped ---------- */
.faq-grouped{ margin-top: 40px; }
.section-lead{
  display: grid; grid-template-columns: 80px 1fr; gap: 20px;
  padding-bottom: 20px; margin-bottom: 24px;
  border-bottom: 1px solid var(--color-line);
}
.section-lead .sec-no{
  font-family: var(--font-mono); font-size: 40px; font-weight: 600;
  color: var(--color-primary); letter-spacing: -.03em; line-height: 1;
}
.section-lead .sec-eyebrow{
  font-size: 11px; text-transform: uppercase; letter-spacing: .12em;
  color: var(--color-accent); font-weight: 600; margin-bottom: 6px;
}
.section-lead .sec-h{
  font-size: 24px; font-weight: 600; letter-spacing: -.015em; margin: 0;
}
@media (max-width: 768px){
  .section-lead{ grid-template-columns: 48px 1fr; gap: 14px; }
  .section-lead .sec-no{ font-size: 28px; }
  .section-lead .sec-h{ font-size: 19px; }
}

/* ---------- Field: subfield row (compact) ---------- */
.field.compact{ display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.subfield > .input{ margin-top: 0; }
.subfield .field-row{ margin-bottom: 6px; }

/* ---------- Select-поля (ПСН: регион + ОКВЭД) ---------- */
.field .input--select{ padding: 0; overflow: hidden; min-width: 0; }
.field .input--select select{
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;                /* позволяет селекту сжиматься внутри grid-ячейки */
  border: 0; outline: 0;
  background: transparent;
  padding: 0 36px 0 14px;
  height: 100%;
  font: 500 14px/1.2 var(--font-sans);
  color: var(--color-text);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  text-overflow: ellipsis;     /* обрезаем слишком длинные названия ОКВЭД */
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2366786e' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}
.field .input--select:focus-within{
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(15,92,74,.12);
}

/* ПСН-поле: слабо выделенная вторичная группа полей */
.field.psn-field{
  display: block;
  box-sizing: border-box;
  width: 100%;
  background: var(--color-surface-2);
  border: 1px dashed var(--color-line);
  border-radius: 12px;
  padding: 10px 12px 14px;
  margin: 14px 0;
}
.psn-field__title{
  font-size: 11px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--color-text-muted);
  margin: 0 0 10px;
  font-weight: 600;
}
/* По умолчанию: селекты в одну колонку — так ничего не обрезается в боковой карточке.
   Разворачиваем в 2 колонки только когда места реально хватает (>= 880px вьюпорта). */
.psn-field__row{
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  min-width: 0;
}
.psn-field__row .subfield{ min-width: 0; }   /* разрешить селекту ужиматься */
.psn-field__row .input--select{ width: 100%; }
@media (min-width: 880px){
  .psn-field__row{ grid-template-columns: 1fr 1fr; gap: 12px; }
}

/* ---------- Tooltip (ⓘ) ---------- */
.tooltip-wrap{ position: relative; display: inline-flex; align-items: center; gap: 6px; }
.tooltip-trigger{
  width: 14px; height: 14px; border-radius: 50%;
  border: 1px solid var(--color-line);
  background: var(--color-surface-2);
  color: var(--color-text-muted);
  font: 600 10px/1 var(--font-sans);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: help;
  transition: border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.tooltip-trigger:hover,
.tooltip-trigger:focus-visible{
  border-color: var(--color-primary);
  color: var(--color-primary);
  outline: 0;
}
.tooltip-body{
  position: absolute; left: 50%; bottom: calc(100% + 8px);
  transform: translateX(-50%);
  min-width: 200px; max-width: 280px;
  padding: 10px 12px;
  background: var(--color-text); color: #eaf2ee;
  border-radius: 8px; font-size: 12px; line-height: 1.4;
  box-shadow: 0 8px 24px -10px rgba(12,42,34,.45);
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
  z-index: 20;
}
.tooltip-body::after{
  content: ''; position: absolute; left: 50%; top: 100%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--color-text);
}
.tooltip-wrap:hover .tooltip-body,
.tooltip-trigger:focus-visible + .tooltip-body{
  opacity: 1; visibility: visible;
  transform: translateX(-50%) translateY(-2px);
}

/* Hero — более лёгкая иконка подсказки (светлый фон hero) */
.hero .tooltip-trigger{
  width: 15px; height: 15px;
  border-color: rgba(255,255,255,.3);
  background: rgba(255,255,255,.12);
  color: rgba(255,255,255,.85);
}
.hero .tooltip-trigger:hover,
.hero .tooltip-trigger:focus-visible{
  border-color: rgba(255,255,255,.6);
  color: #fff;
}

/* Заголовки колонок в таблице режимов — центрируем ⓘ правее текста */
.col-head{
  display: inline-flex; align-items: center; gap: 6px;
  justify-content: flex-end;
}
.mode-row.header .col-head{ width: 100%; }

/* Бренд-ссылка (VibeTools → /) — убираем подчёркивание и наследуем цвет */
.brand-link{
  color: inherit; text-decoration: none;
  display: inline-flex; align-items: center; gap: 6px;
  transition: opacity var(--dur-fast) var(--ease);
  cursor: pointer;
}
.brand-link:hover,
.brand-link:focus-visible{ opacity: .78; outline: 0; }
.darkheader .brand-link{ color: inherit; }

/* ---------- NDS result ---------- */
.nds-result{
  position: relative;
  background: linear-gradient(180deg, #fff 0%, #f7faf8 100%);
  border: 1px solid var(--color-line); border-radius: 18px;
  box-shadow: var(--sh-hero); padding: 24px 28px 26px;
  overflow: hidden;
}
.nds-result::before{
  content: ''; position: absolute; left: 0; top: 0; bottom: 0;
  width: 4px; background: linear-gradient(180deg, var(--color-accent), var(--color-primary));
}
.nds-result .tag{
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--color-accent-050); color: var(--color-accent-600);
  padding: 3px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 600; letter-spacing: .02em;
}
.nds-result .fig{
  display: flex; align-items: baseline; gap: 10px;
  margin: 12px 0 8px;
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
}
.nds-result .fig .v{
  font-size: 58px; line-height: 1; letter-spacing: -.03em;
  color: var(--color-text); font-weight: 600;
}
.nds-result .fig .u{
  font-size: 20px; color: var(--color-text-muted); font-weight: 500;
}
.nds-result .note{
  color: var(--color-text-2); font-size: 14px; line-height: 1.5;
  margin: 0 0 16px;
}
.breakdown{ margin: 0 0 18px; padding: 0; display: flex; flex-direction: column; gap: 2px; border-top: 1px dashed var(--color-line); padding-top: 14px; }
.brow{ display: flex; justify-content: space-between; align-items: baseline; padding: 8px 0; font-size: 14px; }
.brow dt{ color: var(--color-text-muted); }
.brow dd{ margin: 0; font-family: var(--font-mono); font-variant-numeric: tabular-nums; color: var(--color-text-2); }
.brow.accent{ color: var(--color-accent); }
.brow.accent dt{ color: var(--color-accent); font-weight: 500; }
.brow.accent dd{ color: var(--color-accent-600); font-weight: 600; }
.brow.total{ border-top: 1px solid var(--color-line); margin-top: 6px; padding-top: 12px; }
.brow.total dt{ color: var(--color-text); font-weight: 600; }
.brow.total dd{ color: var(--color-text); font-weight: 600; font-size: 15px; }

@media (max-width: 768px){
  .nds-result .fig .v{ font-size: 44px; }
}

/* ---------- Hero states — empty / alert / deadend ---------- */
/* All base styles are in components.css; layout.css adds content pieces */
.hero-empty-icon{
  width: 56px; height: 56px; border-radius: 14px;
  background: var(--color-surface-2);
  border: 1.5px dashed var(--color-line);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--color-text-muted); margin-bottom: 16px;
}
.hero-placeholder{
  font-family: var(--font-mono); font-size: 48px;
  color: var(--color-text-faint); letter-spacing: .1em;
  margin: 8px 0 16px;
}
.hero-chips{ display: flex; flex-wrap: wrap; gap: 8px; }
.hero-chips .chip{
  padding: 7px 12px; border-radius: 999px;
  background: var(--color-surface); border: 1px solid var(--color-line);
  color: var(--color-text-2); font-size: 12px; font-weight: 500;
  cursor: pointer;
}
.hero-chips .chip:hover{ border-color: var(--color-primary); color: var(--color-primary); }

.alert-strip{
  display: flex; gap: 10px; align-items: center;
  padding: 12px 28px;
  background: linear-gradient(90deg, #fff6e8, #fff);
  color: #7a3f04;
  border-bottom: 1px solid #f2d9ac;
  font-size: 13px; font-weight: 500;
}
.alert-strip[hidden]{ display: none; }
.alert-strategies{ display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.alert-strategies[hidden]{ display: none; }
.alert-strategy{
  padding: 12px 14px;
  background: var(--color-surface-2);
  border: 1px solid var(--color-line);
  border-radius: 10px;
}
.alert-strategy .n{ font-family: var(--font-mono); font-size: 11px; color: var(--color-accent); font-weight: 600; }
.alert-strategy b{ display: block; font-size: 13px; font-weight: 600; margin: 4px 0 2px; color: var(--color-text); }
.alert-strategy span{ font-size: 12px; color: var(--color-text-muted); }

.deadend-options{ display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.deadend-options[hidden]{ display: none; }
.deadend-options .opt{
  padding: 12px 14px;
  background: var(--color-surface-2);
  border: 1px solid var(--color-line);
  border-left: 3px solid var(--color-text-muted);
  border-radius: 8px;
  font-size: 13px; color: var(--color-text-2);
}
.deadend-options .opt b{ color: var(--color-text); font-weight: 600; display: block; margin-bottom: 2px; }

/* ---------- Mobile sticky-peek (summary dock) ---------- */
.sticky-peek{
  display: none; /* desktop: hidden */
}
@media (max-width: 768px){
  .sticky-peek{
    /* высота bnav (icon 22 + label 12 + gap 3 + padding 6+6 + safe-area) */
    --bnav-h: calc(58px + env(safe-area-inset-bottom));
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    display: flex; gap: 12px; align-items: center;
    padding: 10px 14px calc(14px + env(safe-area-inset-bottom));
    background: rgba(255,255,255,.96);
    backdrop-filter: saturate(1.2) blur(8px);
    -webkit-backdrop-filter: saturate(1.2) blur(8px);
    border-top: 1px solid var(--color-line);
    box-shadow: 0 -8px 24px -14px rgba(12,42,34,.15);
    transition: bottom .28s cubic-bezier(.32, .72, .24, 1);
  }
  /* Когда bnav видим — поднимаем peek поверх него */
  body:has(.bnav[data-state="visible"]) .sticky-peek{
    bottom: var(--bnav-h);
    padding-bottom: 14px;
  }
  .sticky-peek .sp-label{
    flex: 1; min-width: 0;
  }
  .sticky-peek .sp-label .eb{
    font-size: 10px; text-transform: uppercase; letter-spacing: .08em;
    color: var(--color-text-muted); font-weight: 600; display: block;
  }
  .sticky-peek .sp-label b{
    display: block; font-size: 14px; color: var(--color-text); font-weight: 600;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .sticky-peek .sp-value{
    font-family: var(--font-mono); font-size: 17px; font-weight: 600;
    color: var(--color-text); margin-right: 6px;
  }
  .sticky-peek .btn{ flex-shrink: 0; height: 44px; }
  /* Give page bottom padding so peek + bnav don't cover content */
  body{ padding-bottom: calc(72px + 58px + env(safe-area-inset-bottom)); }
}

/* ---------- Footer ---------- */
.footer{
  background: var(--color-primary-700);
  color: #c1d5cc;
  padding: 40px 0 22px;
  margin-top: 48px;
}
.footer .wrap{ max-width: 1200px; }
.footer-grid{
  display: grid; grid-template-columns: 2fr 1fr 1fr;
  gap: 40px;
}
.footer-brand .brand-dark{ color: #fff; }
.footer-brand .brand-dark b a{
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid rgba(255,255,255,.25);
  transition: border-color .15s;
}
.footer-brand .brand-dark b a:hover{ border-bottom-color: var(--color-accent); }
.footer-brand .mark-forest{ background: var(--color-accent); }
.footer-brand p{
  font-size: 13px; color: #9fc4b6; line-height: 1.55;
  margin: 12px 0 0; max-width: 360px;
}
.footer h5{
  font-size: 11px; text-transform: uppercase; letter-spacing: .12em;
  color: #7fc08a; font-weight: 600; margin: 0 0 14px;
}
.footer ul{ list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.footer ul a{ color: #c1d5cc; text-decoration: none; font-size: 13px; }
.footer ul a:hover{ color: #fff; }

.footer-social{ display: flex; gap: 8px; }
.footer-social a{
  width: 34px; height: 34px; border-radius: 8px;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.12);
  color: #c1d5cc;
  display: inline-flex; align-items: center; justify-content: center;
  text-decoration: none; font-weight: 600; font-size: 12px;
}
.footer-social a:hover{ background: var(--color-accent); border-color: var(--color-accent); color: #fff; }

.footer-bottom{
  margin-top: 28px; padding-top: 18px;
  border-top: 1px solid rgba(255,255,255,.08);
  display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap;
  font-size: 12px; color: #7a9a8e;
}
.footer-bottom a{ color: #9fc4b6; text-decoration: none; margin-right: 14px; }
.footer-bottom a:last-child{ margin-right: 0; }
.footer-meta{
  display: inline-flex; align-items: center; gap: 8px;
  color: #9fc4b6;
  font-variant-numeric: tabular-nums;
}
.footer-meta::before{
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 0 3px rgba(74, 222, 128, .18);
}

/* ---------- Scroll-top button ---------- */
.scroll-top{
  position: fixed; right: 20px; bottom: 20px;
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  border: 0;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(15, 92, 74, .3), 0 2px 4px rgba(15, 92, 74, .2);
  opacity: 0; visibility: hidden; transform: translateY(8px);
  transition: opacity .2s, transform .2s, visibility 0s linear .2s, background .15s;
  z-index: 50;
}
.scroll-top.is-visible{
  opacity: 1; visibility: visible; transform: translateY(0);
  transition: opacity .2s, transform .2s, visibility 0s, background .15s;
}
.scroll-top:hover{ background: var(--color-accent, #116B5A); }
.scroll-top:focus-visible{ outline: 2px solid var(--color-accent); outline-offset: 3px; }
@media (max-width: 640px){
  .scroll-top{ right: 14px; bottom: 14px; width: 40px; height: 40px; }
}

@media (max-width: 768px){
  .footer-grid{ grid-template-columns: 1fr; gap: 28px; }
}

/* ---------- Cookie banner (152-ФЗ) ---------- */
.cookie-banner{
  position: fixed; right: 20px; bottom: 20px; z-index: 90;
  max-width: 360px;
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: 12px;
  box-shadow: 0 12px 32px -16px rgba(12,42,34,.25);
  padding: 14px 16px;
  font-size: 12px; color: var(--color-text-2); line-height: 1.5;
}
.cookie-banner b{ color: var(--color-text); font-weight: 600; display: block; margin-bottom: 2px; font-size: 13px; }
.cookie-banner a{ color: var(--color-primary); text-decoration: underline; text-decoration-color: var(--color-primary-100); text-underline-offset: 2px; }
.cookie-banner .actions{ display: flex; gap: 8px; margin-top: 10px; }
.cookie-banner .btn{ height: 36px; font-size: 13px; flex: 1; justify-content: center; }

@media (max-width: 768px){
  .cookie-banner{
    right: 12px; left: 12px;
    /* над peek (~84) + bnav (~58) + safe-area */
    bottom: calc(84px + 58px + env(safe-area-inset-bottom));
    max-width: none;
  }
}

/* Respect when peek is present — lift cookie above it */
body:has(.sticky-peek) .cookie-banner{ bottom: calc(84px + env(safe-area-inset-bottom)); }
/* ─── Bottom Nav (mobile only, brand-tinted) ──────────────────────────────────
   Цвет берётся из --bnav-color (fallback --color-primary, затем --primary).
   Каждый инструмент окрашивает меню в свой brand-токен.
   ──────────────────────────────────────────────────────────────────────────── */

.bnav { display: none; }

@media (max-width: 767px) {
  .bnav {
    --bnav-color: var(--color-primary, var(--primary, #1F5FFF));
    --bnav-ink: #0f172a;
    --bnav-bg: color-mix(in srgb, var(--bnav-color) 6%, #ffffff 94%);
    --bnav-border: color-mix(in srgb, var(--bnav-color) 22%, transparent);
    --bnav-shadow: color-mix(in srgb, var(--bnav-color) 28%, transparent);
    --bnav-muted: color-mix(in srgb, var(--bnav-ink) 62%, transparent);
    --bnav-active-bg: color-mix(in srgb, var(--bnav-color) 12%, transparent);

    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 90;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    background: var(--bnav-bg);
    -webkit-backdrop-filter: saturate(180%) blur(16px);
            backdrop-filter: saturate(180%) blur(16px);
    border-top: 1px solid var(--bnav-border);
    box-shadow: 0 -8px 24px -12px var(--bnav-shadow);
    transform: translateY(110%);
    transition: transform .28s cubic-bezier(.32, .72, .24, 1);
    will-change: transform;
  }

  /* Тонкая цветная линия-акцент сверху */
  .bnav::before {
    content: "";
    position: absolute;
    top: 0;
    left: 12%;
    right: 12%;
    height: 2px;
    border-radius: 2px;
    background: linear-gradient(90deg,
      transparent,
      var(--bnav-color) 30%,
      var(--bnav-color) 70%,
      transparent);
    opacity: .55;
  }

  .bnav[data-state="visible"] { transform: translateY(0); }

  @media (prefers-color-scheme: dark) {
    .bnav {
      --bnav-ink: #e6edf3;
      --bnav-bg: color-mix(in srgb, var(--bnav-color) 10%, #11151c 90%);
      --bnav-border: color-mix(in srgb, var(--bnav-color) 32%, transparent);
      --bnav-shadow: rgba(0, 0, 0, .45);
      --bnav-muted: color-mix(in srgb, var(--bnav-ink) 60%, transparent);
      --bnav-active-bg: color-mix(in srgb, var(--bnav-color) 22%, transparent);
    }
  }

  /* Fallback без backdrop-filter: плотный тонированный фон */
  @supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
    .bnav {
      background: color-mix(in srgb, var(--bnav-color) 8%, #ffffff 92%);
    }
    @media (prefers-color-scheme: dark) {
      .bnav {
        background: color-mix(in srgb, var(--bnav-color) 14%, #11151c 86%);
      }
    }
  }

  .bnav__link {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 6px 2px;
    min-height: 52px;
    border-radius: 12px;
    text-decoration: none;
    color: var(--bnav-muted);
    transition: color .15s ease, background-color .2s ease, transform .15s ease;
  }

  .bnav__link:hover { color: var(--bnav-ink); }
  .bnav__link:active { transform: scale(.96); }
  .bnav__link:focus-visible {
    outline: 2px solid var(--bnav-color);
    outline-offset: -2px;
  }

  .bnav__link[aria-current="page"] {
    color: var(--bnav-color);
    background: var(--bnav-active-bg);
    font-weight: 600;
  }
  .bnav__link[aria-current="page"] .bnav__icon {
    transform: translateY(-1px);
  }

  .bnav__icon {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    transition: transform .2s ease;
  }

  .bnav__label {
    font-size: 11px;
    line-height: 1.1;
    font-weight: 500;
    letter-spacing: -0.01em;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  @media (max-width: 380px) {
    .bnav__label { font-size: 10px; }
    .bnav__link { gap: 2px; padding: 6px 1px; }
  }

  /* Защита от перекрытия контента нижним меню */
  body { padding-bottom: calc(60px + env(safe-area-inset-bottom)); }

  /* Кнопка «Наверх» поднимается над меню */
  .scroll-to-top {
    bottom: calc(72px + env(safe-area-inset-bottom)) !important;
  }

  @media (prefers-reduced-motion: reduce) {
    .bnav { transition: none; }
    .bnav__link, .bnav__icon { transition: none; }
  }
}
