/* Обёртка обложки не должна участвовать в раскладке карточки:
   у самой картинки отрицательные поля во всю её ширину. */
picture { display: contents; }
/* Блог billing.smit34.ru — те же токены, что на главной, но без её тяжёлой вёрстки. */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
  --slate-300: #cbd5e1;
  --slate-400: #94a3b8;
  --slate-800: #1e293b;
  --slate-900: #0f172a;
  --slate-950: #020617;
  --emerald-400: #34d399;
  --emerald-500: #10b981;
  --emerald-600: #059669;
  --teal-400: #2dd4bf;

  --bg-body: #020617;
  --bg-card: rgba(30, 41, 59, 0.5);
  --bg-card-border: rgba(255, 255, 255, 0.08);
  --bg-header: rgba(2, 6, 23, 0.85);
  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --border-light: rgba(255, 255, 255, 0.07);
  --code-bg: #0f172a;
}

[data-theme="light"] {
  /* на светлом фоне мятный акцент нечитаем — берём тёмную зелень */
  --emerald-400: #047857;
  --emerald-500: #065f46;
  --bg-body: #f8fafc;
  --bg-card: rgba(255, 255, 255, 0.75);
  --bg-card-border: rgba(0, 0, 0, 0.08);
  --bg-header: rgba(248, 250, 252, 0.88);
  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --border-light: rgba(0, 0, 0, 0.07);
  --code-bg: #1e293b;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-body);
  color: var(--text-primary);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--emerald-400); text-decoration: none; }
a:hover { color: var(--emerald-500); }
a:focus-visible, button:focus-visible {
  outline: 2px solid var(--emerald-400); outline-offset: 3px; border-radius: 6px;
}

.container { max-width: 1180px; margin: 0 auto; padding: 0 24px; }
.narrow { max-width: 760px; }

/* ---- Заголовок раздела ---- */
.bhead { padding: 64px 0 28px; }
.bhead h1 { font-size: clamp(2rem, 4vw, 3rem); font-weight: 800; line-height: 1.15; letter-spacing: -.02em; }
.bhead p { margin-top: 14px; color: var(--text-secondary); max-width: 720px; }
.bkicker {
  display: inline-block; margin-bottom: 14px; padding: 6px 14px; border-radius: 999px;
  border: 1px solid rgba(16, 185, 129, .3); background: rgba(16, 185, 129, .08);
  color: var(--emerald-400); font-size: .78rem; font-weight: 600;
  letter-spacing: .08em; text-transform: uppercase;
}

/* ---- Карточки постов ---- */
.bgrid {
  display: grid; gap: 22px; padding: 12px 0 72px;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
}
.bcard {
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--bg-card); border: 1px solid var(--bg-card-border);
  border-radius: 16px; padding: 0 24px 24px; color: inherit;
  transition: transform .25s ease, border-color .25s ease, box-shadow .25s ease;
}
.bcard:hover {
  transform: translateY(-3px); border-color: rgba(16, 185, 129, .35);
  box-shadow: 0 18px 40px rgba(0, 0, 0, .25); color: inherit;
}
.bcard-cover {
  display: block; width: calc(100% + 48px); height: auto; margin: 0 -24px 18px;
  aspect-ratio: 16/9; object-fit: cover; background: #060d14;
  /* карточка — флекс-колонка, и без этого картинка ужимается обратно
     в поля; max-width снимаем, иначе общее правило для img режет вынос
     за padding обратно до ширины контента */
  flex-shrink: 0; max-width: none;
}
/* Тег и дата лежат на обложке в левом верхнем углу. Под каждым — своя
   подложка: иллюстрации в тёмной и светлой теме разные, одна и та же
   плашка на обеих читалась бы плохо. */
.bcard { position: relative; }
.bcard-meta {
  position: absolute; top: 14px; left: 14px; z-index: 2;
  display: flex; gap: 8px; align-items: center; font-size: .8rem;
  color: var(--text-muted);
}
.bcard-meta time {
  padding: 3px 9px; border-radius: 999px;
  background: rgba(2, 6, 23, .62); color: #e2e8f0;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.bcard .btag { background: rgba(2, 6, 23, .62); color: #6ee7b7;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
[data-theme="light"] .bcard-meta time {
  background: rgba(255, 255, 255, .82); color: #334155;
}
[data-theme="light"] .bcard .btag {
  background: rgba(255, 255, 255, .82); color: #047857;
}
.btag {
  padding: 3px 10px; border-radius: 999px; font-weight: 600;
  background: rgba(16, 185, 129, .12); color: var(--emerald-400);
}
.bcard h2, .bcard h3 { margin: 12px 0 8px; font-size: 1.22rem; font-weight: 700; line-height: 1.3; }
.bcard p { color: var(--text-secondary); font-size: .96rem; }
.bcard-more { margin-top: auto; padding-top: 16px; color: var(--emerald-400); font-weight: 600; font-size: .92rem; }

/* ---- Статья ---- */
.bpost { padding: 56px 0 80px; }
.bpost-cover {
  display: block; width: 100%; height: auto; aspect-ratio: 16/9; object-fit: cover;
  border-radius: 14px; border: 1px solid var(--border-light);
  margin: 0 0 30px; background: #060d14;
}
.bpost .btag { display: inline-block; margin-bottom: 14px; }
.bpost h1 { font-size: clamp(1.9rem, 3.6vw, 2.7rem); font-weight: 800; line-height: 1.2; letter-spacing: -.02em; }
.bpost .bmeta { margin: 16px 0 34px; color: var(--text-muted); font-size: .9rem; display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.bpost h2 { margin: 38px 0 12px; font-size: 1.5rem; font-weight: 700; line-height: 1.3; }
.bpost h3 { margin: 28px 0 10px; font-size: 1.16rem; font-weight: 700; }
.bpost p { margin-bottom: 16px; color: var(--text-secondary); }
.bpost ul, .bpost ol { margin: 0 0 18px 22px; color: var(--text-secondary); }
.bpost li { margin-bottom: 8px; }
.bpost strong { color: var(--text-primary); }
.bpost blockquote {
  margin: 22px 0; padding: 16px 20px; border-left: 3px solid var(--emerald-500);
  background: rgba(16, 185, 129, .06); border-radius: 0 12px 12px 0; color: var(--text-secondary);
}
.bpost code {
  background: var(--code-bg); color: #7fe0ae; padding: 2px 7px;
  border-radius: 6px; font-size: .9em; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.bpost table { width: 100%; border-collapse: collapse; margin: 18px 0 22px; font-size: .95rem; }
.bpost th, .bpost td { padding: 10px 12px; border-bottom: 1px solid var(--border-light); text-align: left; vertical-align: top; }
.bpost th { color: var(--text-primary); font-weight: 600; }
.bpost td { color: var(--text-secondary); }
.bpost img { max-width: 100%; border-radius: 12px; border: 1px solid var(--border-light); }
/* Обложка карточки — не иллюстрация в тексте: она вынесена за поля карточки
   на всю её ширину, поэтому общее правило для картинок статьи её не касается. */
.bpost .bcard-cover, .brel-grid .bcard-cover {
  max-width: none; border: 0; border-radius: 0;
}

.bback { display: inline-block; margin-bottom: 14px; color: var(--text-muted); font-size: .92rem; }
.bback:hover { color: var(--emerald-400); }

/* ---- Врезка с призывом ---- */
.bcta {
  margin: 44px 0 0; padding: 26px 28px; border-radius: 16px;
  border: 1px solid rgba(16, 185, 129, .25); background: rgba(16, 185, 129, .07);
}
.bcta h3 { margin: 0 0 8px; font-size: 1.15rem; }
.bcta p { margin: 0 0 16px; color: var(--text-secondary); }
.bcta a { font-weight: 600; }

/* ---- Подвал ---- */
.bfoot {
  border-top: 1px solid var(--border-light); padding: 28px 0 44px;
  color: var(--text-muted); font-size: .9rem;
}
.bfoot .container { display: flex; gap: 18px; flex-wrap: wrap; align-items: center; }
.bfoot a { color: var(--text-muted); }
.bfoot a:hover { color: var(--emerald-400); }
.bfoot .sep { margin-left: auto; }

@media (max-width: 640px) {
  .bhead { padding: 40px 0 20px; }
  .bh-nav { gap: 14px; }
  .bh-nav a { font-size: .9rem; }
  .bpost { padding: 34px 0 60px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
  html { scroll-behavior: auto; }
}

/* ---- Хештеги под статьёй ---- */
.bhashes { display: flex; flex-wrap: wrap; gap: 8px; margin: 30px 0 4px; }
.bhash {
  padding: 5px 12px; border-radius: 999px; font-size: .88rem; font-weight: 500;
  border: 1px solid var(--bg-card-border); background: var(--bg-card);
  color: var(--text-secondary);
}
.bhash:hover { border-color: rgba(16,185,129,.4); color: var(--emerald-400); }

/* ---- Читайте также ---- */
.brelated { margin: 56px 0 12px; padding-top: 36px; border-top: 1px solid var(--border-light); }
.brelated h2 { font-size: 1.4rem; font-weight: 700; margin-bottom: 20px; }
.brel-grid {
  display: grid; gap: 20px; padding-bottom: 30px;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

/* ---- Фильтр по тегу в списке ---- */
.bfilter {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin: 4px 0 18px; color: var(--text-muted); font-size: .95rem;
}
.bfilter strong { color: var(--emerald-400); }
.bempty { color: var(--text-muted); padding: 8px 0 60px; }

/* ---- Схемы и код ---- */
.bmermaid {
  margin: 26px 0 30px; padding: 22px 18px; border-radius: 14px;
  border: 1px solid var(--bg-card-border); background: var(--bg-card);
  overflow-x: auto;                 /* широкая схема скроллится внутри блока */
}
.bmermaid pre.mermaid { margin: 0; background: none; text-align: center; }
.bmermaid svg { max-width: 100%; height: auto; }
/* mermaid считает размер шрифта сам — возвращаем читаемый кегль */
.bmermaid .nodeLabel, .bmermaid .edgeLabel, .bmermaid .label { font-size: 15px !important; }
.bmermaid .edgeLabel { background: transparent !important; }
.bcode {
  margin: 20px 0 24px; padding: 16px 18px; border-radius: 12px;
  background: var(--code-bg); border: 1px solid var(--border-light);
  overflow-x: auto; font-size: .9rem; line-height: 1.55;
}
.bcode code { background: none; padding: 0; color: #cbd5e1; }


/* ---- Светлая тема: схемы и код читаются иначе ---- */
[data-theme="light"] .bmermaid { background: #fff; }
[data-theme="light"] .bmermaid .nodeLabel,
[data-theme="light"] .bmermaid .edgeLabel,
[data-theme="light"] .bmermaid .label,
[data-theme="light"] .bmermaid .edgeLabel p,
[data-theme="light"] .bmermaid foreignObject div { color: #0f172a !important; fill: #0f172a !important; }
[data-theme="light"] .bmermaid .edgeLabel rect { fill: #ffffff !important; }
[data-theme="light"] .bcode code { color: #e2e8f0; }
[data-theme="light"] .bcard-cover, [data-theme="light"] .bpost-cover { background: #e2e8f0; }

[data-theme="light"] .btag,
[data-theme="light"] .bkicker { background: rgba(4,120,87,.10); color: #047857; }
[data-theme="light"] .bmermaid { border-color: rgba(0,0,0,.08); }

/* ---- Шапка: копия главной, чтобы блог не выглядел отдельным сайтом ---- */
.header {
      position: fixed;
      top: 0; left: 0; right: 0;
      height: 64px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 0 40px;
      z-index: 100;
      background: rgba(2, 6, 23, 0.8);
      backdrop-filter: blur(16px);
      border-bottom: 1px solid rgba(255,255,255,0.06);
      transition: background .3s;
    }
.theme-toggle {
      width: 38px; height: 38px;
      border-radius: 10px;
      border: 1px solid rgba(255,255,255,0.15);
      background: rgba(255,255,255,0.08);
      color: var(--slate-300);
      font-size: 1.1rem;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      transition: background .2s, transform .2s;
      flex-shrink: 0;
    }
.mobile-toggle {
      display: none;
      width: 38px; height: 38px;
      border-radius: 10px;
      border: 1px solid rgba(255,255,255,0.15);
      background: rgba(255,255,255,0.08);
      color: var(--slate-300);
      font-size: 1.3rem;
      cursor: pointer;
      align-items: center;
      justify-content: center;
      transition: background .2s;
      flex-shrink: 0;
    }
.mobile-menu {
      display: flex;
      position: fixed;
      top: 0; left: 0; right: 0; bottom: 0;
      z-index: 200;
      background: rgba(2, 6, 23, 0.72);
      -webkit-backdrop-filter: blur(26px) saturate(180%);
      backdrop-filter: blur(26px) saturate(180%);
      overflow-y: auto;
      -webkit-overflow-scrolling: touch;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 8px;
      pointer-events: none;
      /* на главной скрытие описано отдельным правилом — здесь оно обязательно,
         иначе полупрозрачный оверлей накрывает страницу и она выглядит пустой */
      opacity: 0;
      visibility: hidden;
      transition: opacity .25s ease, visibility .25s ease;
    }
.header-logo {
      display: flex;
      align-items: center;
      gap: 12px;
    }
.header-logo-icon {
      width: 38px; height: 38px;
      background: linear-gradient(135deg, var(--emerald-500), var(--teal-400));
      border-radius: 10px;
      display: flex;
      align-items: center;
      justify-content: center;
      font-weight: 800;
      font-size: 1.1rem;
      color: #fff;
      box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
    }
.header-logo-text {
      font-size: 1.15rem;
      font-weight: 700;
      letter-spacing: .3px;
    }
.header-logo-text span {
      font-weight: 300;
      opacity: .7;
      margin-left: 4px;
    }
.header-nav {
      display: flex;
      align-items: center;
      gap: 32px;
    }
.header-nav a {
      font-size: .9rem;
      font-weight: 500;
      color: var(--slate-300);
      transition: color .2s;
    }
.header-nav a:hover { color: var(--emerald-400); }
.btn-header {
      display: inline-flex;
      align-items: center;
      gap: 8px;
      padding: 10px 22px;
      background: linear-gradient(135deg, var(--emerald-500), var(--teal-400));
      color: #fff;
      font-weight: 600;
      font-size: .9rem;
      border-radius: 10px;
      border: none;
      cursor: pointer;
      transition: transform .2s, box-shadow .2s;
      box-shadow: 0 4px 20px rgba(16, 185, 129, 0.3);
    }
.btn-header:hover {
      transform: translateY(-2px);
      box-shadow: 0 8px 30px rgba(16, 185, 129, 0.4);
    }
.theme-toggle:hover {
      background: rgba(255,255,255,0.15);
      transform: scale(1.05);
    }
[data-theme="light"] .theme-toggle {
      border-color: rgba(0,0,0,0.12);
      background: rgba(0,0,0,0.05);
      color: var(--slate-600);
    }
[data-theme="light"] .theme-toggle:hover {
      background: rgba(0,0,0,0.1);
    }
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: inline; }
[data-theme="light"] .theme-toggle .icon-sun { display: inline; }
[data-theme="light"] .theme-toggle .icon-moon { display: none; }
[data-theme="light"] .mobile-toggle {
      border-color: rgba(0,0,0,0.12);
      background: rgba(0,0,0,0.05);
      color: var(--slate-600);
    }
[data-theme="light"] .mobile-menu {
      background: rgba(248, 250, 252, 0.78);
    }
.mobile-menu.open { pointer-events: auto; }
.mobile-menu a {
      font-size: 1.3rem;
      font-weight: 600;
      color: var(--slate-200);
      padding: 14px 32px;
      border-radius: 12px;
      transition: background .2s, color .2s;
    }
.mobile-menu a:hover {
      background: rgba(16, 185, 129, 0.1);
      color: var(--emerald-400);
    }
[data-theme="light"] .mobile-menu a { color: var(--text-primary); }
[data-theme="light"] .mobile-menu a:hover { color: var(--emerald-600); }
.mobile-menu .mobile-close {
      position: absolute;
      top: 16px; right: 20px;
      width: 44px; height: 44px;
      border: none;
      background: none;
      color: var(--slate-400);
      font-size: 1.8rem;
      cursor: pointer;
    }
[data-theme="light"] .mobile-menu .mobile-close { color: var(--slate-600); }
[data-theme="light"] .header-logo-text { color: var(--text-primary); }
[data-theme="light"] .header-nav a { color: var(--text-secondary); }
[data-theme="light"] .header-nav a:hover { color: var(--emerald-600); }
.mobile-menu.open {
      opacity: 1;
      visibility: visible;
    }
.mobile-menu a {
      opacity: 0;
      transform: translateY(20px);
      transition: opacity .4s cubic-bezier(.22,1,.36,1), transform .4s cubic-bezier(.22,1,.36,1), background .2s, color .2s;
    }
.mobile-menu.open a:nth-child(2) { opacity: 1; transform: translateY(0); transition-delay: .08s; }
.mobile-menu.open a:nth-child(3) { opacity: 1; transform: translateY(0); transition-delay: .14s; }
.mobile-menu.open a:nth-child(4) { opacity: 1; transform: translateY(0); transition-delay: .20s; }
.mobile-menu.open a:nth-child(5) { opacity: 1; transform: translateY(0); transition-delay: .26s; }
.mobile-menu.open a:nth-child(6) { opacity: 1; transform: translateY(0); transition-delay: .32s; }
.mobile-menu.open a:nth-child(7) { opacity: 1; transform: translateY(0); transition-delay: .38s; }
.mobile-menu.open a:nth-child(8) { opacity: 1; transform: translateY(0); transition-delay: .44s; }
.mobile-menu.open a:nth-child(9) { opacity: 1; transform: translateY(0); transition-delay: .50s; }
.mobile-menu.open a:nth-child(10) { opacity: 1; transform: translateY(0); transition-delay: .56s; }
.mobile-menu .mobile-close {
      opacity: 0;
      transform: rotate(-90deg);
      transition: opacity .3s .1s, transform .3s .1s;
    }
.mobile-menu.open .mobile-close {
      opacity: 1;
      transform: rotate(0);
    }
.header { padding: 0 16px; }
.header-nav { display: none; }
.mobile-toggle { display: flex; }
.header-actions { display: flex; align-items: center; gap: 8px; }
.mobile-menu { height: -webkit-fill-available; }
.header-nav{display:none!important}
.mobile-toggle{display:flex!important}

/* мобильная шапка — тот же медиазапрос, что на главной */
@media (max-width: 768px) {
      section { padding: 60px 20px; }
      .header { padding: 0 16px; }
      .header-nav { display: none; }
      .mobile-toggle { display: flex; }
      .header-actions { display: flex; align-items: center; gap: 8px; }
      .hero h1 { font-size: 2.2rem; }
      .section-title { font-size: 2rem; }
      .features-grid { grid-template-columns: 1fr; }
      .stats-bar .container { grid-template-columns: repeat(2, 1fr); gap: 24px; }
      .stat-item .stat-value { font-size: 2rem; }
      .tech-grid { grid-template-columns: 1fr 1fr; }
      .hero-buttons { flex-direction: column; }
      .hero-buttons .btn-secondary { text-align: center; justify-content: center; }
      .hero-float { display: none; }
      .footer .container { grid-template-columns: 1fr; }
      .footer-bottom { flex-direction: column; gap: 16px; text-align: center; }
    }

/* блог начинается под фиксированной шапкой */
body { padding-top: 64px; }
.bhead { padding-top: 44px; }

/* светлая тема: шапка светлая, как на главной */
[data-theme="light"] .header {
  background: var(--bg-header);
  border-bottom-color: var(--border-light);
}
[data-theme="light"] .header-logo-text { color: var(--text-primary); }

/* hidden у полосы фильтра не работал: display:flex его перебивал */
.bfilter[hidden], .bempty[hidden] { display: none; }

/* Цели касания: минимум 44px. Расширяем зону невидимым слоем, вид не меняем. */
@media (max-width: 768px) {
  .theme-toggle, .mobile-toggle, .header-logo, .bhash, .bback, .bfoot a, .bh-nav a {
    position: relative;
  }
  .theme-toggle::after, .mobile-toggle::after, .header-logo::after, .bhash::after,
  .bback::after, .bfoot a::after, .bh-nav a::after {
    content: ''; position: absolute; top: 50%; left: 50%;
    width: 100%; height: 100%; min-width: 44px; min-height: 44px;
    transform: translate(-50%, -50%);
  }
}

/* Заголовок для навигации по структуре: виден только скринридеру. */
.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---- Таблица сравнения ---- */
.cmp-wrap { overflow-x: auto; margin: 26px 0; }
.cmp { width: 100%; border-collapse: collapse; font-size: .93rem; min-width: 680px; }
.cmp th, .cmp td { padding: 12px 14px; text-align: left; vertical-align: top;
  border-bottom: 1px solid var(--border-light); }
.cmp thead th { font-weight: 700; color: var(--text-primary); white-space: nowrap; }
.cmp td { color: var(--text-secondary); }
.cmp .cmp-us { background: rgba(16,185,129,.07); color: var(--text-primary); font-weight: 600; }
.cmp thead .cmp-us { color: var(--emerald-400); }
[data-theme="light"] .cmp thead .cmp-us { color: var(--emerald-700); }
.cmp tr.cmp-lose .cmp-us { background: rgba(248,113,113,.09); font-weight: 500; }
.cmp-note { font-size: .88rem; color: var(--text-muted); border-left: 3px solid var(--border-light);
  padding-left: 12px; }
@media (max-width: 640px) { .cmp { font-size: .86rem; } .cmp th, .cmp td { padding: 10px; } }


/* ---- Селект категории в списке ---- */
.bhead-top {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
}
.bhead-top .bkicker { margin-bottom: 0; }
.bhead-top + h1 { margin-top: 14px; }

.bsel { position: relative; }
.bsel-btn {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px; border-radius: 12px; cursor: pointer;
  border: 1px solid var(--bg-card-border); background: var(--bg-card);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  color: var(--text-primary); font: inherit; font-size: .92rem; line-height: 1.2;
  transition: border-color .18s ease, background .18s ease;
}
.bsel-btn:hover { border-color: rgba(16, 185, 129, .45); }
.bsel-cap {
  color: var(--text-muted); font-size: .74rem; font-weight: 600;
  letter-spacing: .07em; text-transform: uppercase;
}
.bsel-val { font-weight: 600; }
.bsel.is-set .bsel-val { color: var(--emerald-400); }
.bsel-caret { color: var(--text-muted); transition: transform .18s ease; }
.bsel-btn[aria-expanded="true"] { border-color: rgba(16, 185, 129, .55); }
.bsel-btn[aria-expanded="true"] .bsel-caret { transform: rotate(180deg); }

.bsel-list {
  position: absolute; z-index: 30; right: 0; top: calc(100% + 8px);
  min-width: 244px; max-height: min(70vh, 480px); overflow-y: auto;
  padding: 6px; margin: 0; list-style: none;
  border-radius: 14px; border: 1px solid var(--bg-card-border);
  background: var(--bg-header);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  backdrop-filter: blur(18px) saturate(160%);
  box-shadow: 0 18px 44px rgba(2, 6, 23, .5);
}
.bsel-list[hidden] { display: none; }
.bsel-opt {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 11px; border-radius: 10px; cursor: pointer;
  font-size: .93rem; color: var(--text-secondary);
}
.bsel-opt:hover, .bsel-opt:focus-visible {
  background: rgba(16, 185, 129, .12); color: var(--text-primary); outline: none;
}
.bsel-opt:focus-visible { box-shadow: inset 0 0 0 1.5px var(--emerald-400); }
.bsel-name { flex: 1; }
/* цифра — служебная, поэтому тише текста и с табличными знаками */
.bsel-n { color: var(--text-muted); font-size: .82rem; font-variant-numeric: tabular-nums; }
.bsel-check { opacity: 0; flex: none; color: var(--emerald-400); }
.bsel-opt.is-on { color: var(--text-primary); font-weight: 600; }
.bsel-opt.is-on .bsel-check { opacity: 1; }

[data-theme="light"] .bsel-list { box-shadow: 0 18px 44px rgba(15, 23, 42, .14); }
[data-theme="light"] .bsel-opt:hover,
[data-theme="light"] .bsel-opt:focus-visible { background: rgba(4, 120, 87, .10); }

/* На телефоне ряд не помещается: селект уходит под кичку во всю ширину. */
@media (max-width: 560px) {
  .bhead-top { gap: 12px; }
  .bsel { width: 100%; }
  .bsel-btn { width: 100%; justify-content: space-between; }
  .bsel-list { left: 0; right: 0; min-width: 0; }
  .bsel-opt { padding: 12px 11px; }
}

/* `hidden` у карточки перебивался её собственным display:flex — отфильтрованные
   карточки оставались на экране. Касается и фильтра по хештегу из статьи. */
.bcard[hidden] { display: none; }


/* ---- Футер и селект на телефоне ---- */
.btag[href]:hover { color: var(--emerald-500); }
.bsel-ico { display: none; flex: none; color: var(--text-muted); }
.bfoot-ico { display: none; flex: none; }
.bfoot-copy { color: inherit; }

@media (max-width: 640px) {
  /* Кичка и селект в одну строку: слово «Категория» заменяет иконка,
     длинное название рубрики режется многоточием. */
  .bhead-top { flex-wrap: nowrap; gap: 10px; }
  .bhead-top .bkicker { flex: none; }
  .bsel { width: auto; flex: 1; min-width: 0; }
  .bsel-btn { width: 100%; justify-content: space-between; padding: 9px 12px; }
  .bsel-cap { display: none; }
  .bsel-ico { display: block; }
  .bsel-val { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  /* Футер: ссылки слева, «На главную» и «Канал разработки» — иконками. */
  .bfoot .container { justify-content: flex-start; gap: 14px 18px; }
  .bfoot .sep { margin-left: 0; }
  .bfoot-copy { flex-basis: 100%; }
  .bfoot-ico { display: block; }
  /* Подпись остаётся для скринридера: иконка сама себя не называет. */
  .bfoot-icolink .bfoot-txt {
    position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
  }
}


/* ---- Время чтения, схемы по теме, врезка разработчика ---- */
/* Время чтения — на обложке напротив даты, той же плашкой. */
.bcard-read {
  position: absolute; top: 14px; right: 14px; z-index: 2;
  padding: 3px 9px; border-radius: 999px; font-size: .8rem;
  background: rgba(2, 6, 23, .62); color: #e2e8f0;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  font-variant-numeric: tabular-nums;
}
[data-theme="light"] .bcard-read { background: rgba(255, 255, 255, .82); color: #334155; }

/* Врезка со ссылкой в канал разработки. Класс в статьях был с самого начала,
   а стилей к нему не было — врезка ничем не отличалась от обычного абзаца. */
.bnote-dev {
  margin: 28px 0; padding: 16px 18px; border-radius: 14px;
  border: 1px solid var(--bg-card-border); border-left: 3px solid var(--emerald-500);
  background: var(--bg-card); color: var(--text-secondary); font-size: .95rem;
}
.bnote-dev b { display: block; margin-bottom: 6px; color: var(--text-primary); }

/* Схемы по теме — ссылки на интерактивные схемы системы. */
.bschemes {
  margin: 30px 0 8px; padding: 16px 18px; border-radius: 14px;
  border: 1px solid var(--bg-card-border); background: var(--bg-card);
}
.bschemes > b { display: block; margin-bottom: 12px; color: var(--text-primary); }
.bschemes-links { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.bscheme {
  display: inline-flex; align-items: center; padding: 7px 13px; border-radius: 999px;
  border: 1px solid var(--bg-card-border); color: var(--text-secondary);
  font-size: .9rem; font-weight: 500;
}
.bscheme:hover { border-color: rgba(16, 185, 129, .45); color: var(--emerald-400); }
.bschemes-all { margin-left: auto; font-size: .9rem; font-weight: 600; }
@media (max-width: 560px) {
  .bschemes-all { margin-left: 0; }
}


/* ---- Призыв к действию и кнопки «поделиться» ---- */
.bcta-end { margin: 34px 0 8px; }
.bcta-end p { margin-bottom: 18px; }
.bcta-btns { display: flex; flex-wrap: wrap; gap: 10px; }
.bcta-go, .bcta-ask {
  display: inline-flex; align-items: center; padding: 11px 18px; border-radius: 12px;
  font-size: .95rem; font-weight: 600; line-height: 1.3;
}
.bcta-go { position: relative; background: var(--emerald-500); color: #04140f; }
.bcta-go:hover { background: var(--emerald-400); color: #04140f; }
[data-theme="light"] .bcta-go { color: #fff; }
/* Блик по контуру кнопки — тот же приём, что на карточках схем
   docs.billing.smit34.ru/Workflow/: тонкая бегущая рамка на conic-gradient.
   Здесь запускается не по наведению, а периодически (blog.js), чтобы
   ненавязчиво напоминать о себе тем, кто просто читает статью. */
@property --sheen-angle { syntax: '<angle>'; initial-value: 0deg; inherits: false; }
.bcta-go::before {
  content: ''; position: absolute; inset: 0; z-index: 1;
  border-radius: inherit; padding: 1.5px; pointer-events: none;
  background: conic-gradient(from var(--sheen-angle),
    transparent 0deg 190deg,
    rgba(52, 211, 153, .35) 250deg,
    var(--emerald-400) 300deg,
    #ffffff 322deg,
    var(--emerald-600) 344deg,
    transparent 360deg);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
  opacity: 0; transition: opacity .28s ease;
}
.bcta-go.is-sheening::before { opacity: 1; animation: bcta-sheen-spin 2.8s linear infinite; }
@keyframes bcta-sheen-spin { to { --sheen-angle: 360deg; } }
@media (prefers-reduced-motion: reduce) {
  .bcta-go.is-sheening::before { animation: none; }
}
.bcta-ask {
  border: 1px solid var(--bg-card-border); color: var(--text-secondary);
  font-weight: 500;
}
.bcta-ask:hover { border-color: rgba(16, 185, 129, .45); color: var(--emerald-400); }

.bshare { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin: 26px 0 6px; }
.bshare-cap { color: var(--text-muted); font-size: .9rem; margin-right: 2px; }
.bshare-btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px;
  border-radius: 999px; border: 1px solid var(--bg-card-border);
  background: var(--bg-card); color: var(--text-secondary);
  font: inherit; font-size: .9rem; font-weight: 500; cursor: pointer;
}
.bshare-btn:hover { border-color: rgba(16, 185, 129, .45); color: var(--emerald-400); }

.bshare-toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  z-index: 60; padding: 11px 18px; border-radius: 12px;
  background: var(--bg-header); border: 1px solid var(--bg-card-border);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  color: var(--text-primary); font-size: .92rem;
  box-shadow: 0 14px 36px rgba(2, 6, 23, .4);
  transition: opacity .35s ease, transform .35s ease;
}
.bshare-toast.gone { opacity: 0; transform: translate(-50%, 8px); }

@media (max-width: 560px) {
  .bcta-btns { flex-direction: column; align-items: stretch; }
  .bcta-go, .bcta-ask { justify-content: center; text-align: center; width: 100%; }
  /* На узком экране реплика ассистента идёт первой — она и так выглядит
     как начало диалога, а кнопка записи логичнее как следующий шаг. */
  .bcta-ask { order: -1; }
  .bcta p { font-size: .86rem; }
  .bshare-cap { flex-basis: 100%; }
}


/* ---- Хвост статьи ---- */
.bpost-tail { padding-bottom: 6px; }
/* У части старых постов врезка и концовка стоят в широком контейнере —
   ограничиваем ширину по колонке текста, чтобы строки не тянулись через экран. */
.bnote-dev { max-width: 760px; margin-left: auto; margin-right: auto; }


/* ---- Облако тегов под списком ---- */
.btagcloud {
  margin: 0 0 72px; padding: 22px 24px; border-radius: 16px;
  border: 1px solid var(--bg-card-border); background: var(--bg-card);
}
.btagcloud[hidden] { display: none; }
.btagcloud h2 { font-size: 1.05rem; font-weight: 700; margin-bottom: 14px; }
.btagcloud-list { display: flex; flex-wrap: wrap; gap: 8px; }
.btagchip {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 13px;
  border-radius: 999px; border: 1px solid var(--bg-card-border);
  color: var(--text-secondary); font-size: .9rem; font-weight: 500;
}
.btagchip:hover { border-color: rgba(16, 185, 129, .45); color: var(--emerald-400); }
.btagchip-n { color: var(--text-muted); font-size: .8rem; font-variant-numeric: tabular-nums; }
.btagchip.is-on {
  border-color: rgba(16, 185, 129, .55); background: rgba(16, 185, 129, .12);
  color: var(--emerald-400);
}
.btagchip.is-on .btagchip-n { color: var(--emerald-400); }
/* В выбранной категории тега нет — оставляем на месте, но приглушаем. */
.btagchip.is-empty { opacity: .45; }


/* ---- Меню телефона: как на главной ---- */
/* Без размытия фон обязан быть плотным — иначе текст страницы читается
   сквозь меню. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .mobile-menu { background: rgba(2, 6, 23, .98); }
  [data-theme="light"] .mobile-menu { background: rgba(248, 250, 252, .99); }
}

/* Страница под открытым меню стоит на месте: одного overflow:hidden на
   телефоне мало, позицию возвращает скрипт. */
body.menu-open { position: fixed; left: 0; right: 0; width: 100%; overflow: hidden; }
body.btoc-lock { position: fixed; left: 0; right: 0; width: 100%; overflow: hidden; }

/* Пункты появляются по очереди — так же, как на главной. */
.mobile-menu a {
  opacity: 0; transform: translateY(20px);
  transition: opacity .4s cubic-bezier(.22,1,.36,1),
              transform .4s cubic-bezier(.22,1,.36,1), background .2s, color .2s;
}
.mobile-menu.open a { opacity: 1; transform: translateY(0); }
.mobile-menu.open a:nth-child(2) { transition-delay: .08s; }
.mobile-menu.open a:nth-child(3) { transition-delay: .14s; }
.mobile-menu.open a:nth-child(4) { transition-delay: .20s; }
.mobile-menu.open a:nth-child(5) { transition-delay: .26s; }
.mobile-menu.open a:nth-child(6) { transition-delay: .32s; }
.mobile-menu.open a:nth-child(7) { transition-delay: .38s; }
.mobile-menu.open a:nth-child(8) { transition-delay: .44s; }
.mobile-menu.open a:nth-child(9) { transition-delay: .50s; }
.mobile-menu .mobile-close {
  opacity: 0; transform: rotate(-90deg);
  transition: opacity .3s .1s, transform .3s .1s;
}
.mobile-menu.open .mobile-close { opacity: 1; transform: rotate(0); }


/* ---- Карточки схем ---- */
.bschemes-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 14px; }
.bschemes-head b { color: var(--text-primary); }
.bschemes-head .bschemes-all { margin-left: auto; }
.bschemes-grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
}
.bscard {
  display: block; overflow: hidden; border-radius: 14px; color: inherit;
  border: 1px solid var(--bg-card-border); background: rgba(255, 255, 255, .03);
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
[data-theme="light"] .bscard { background: #fff; }
.bscard:hover {
  transform: translateY(-3px); border-color: rgba(16, 185, 129, .5);
  box-shadow: 0 12px 28px rgba(0, 0, 0, .3); color: inherit;
}
[data-theme="light"] .bscard:hover { box-shadow: 0 12px 28px rgba(15, 23, 42, .12); }
.bscard-media { display: block; background: #0f172a; }
[data-theme="light"] .bscard-media { background: #eef2f5; }
/* height:auto обязателен: у картинок есть атрибуты width/height, браузер
   берёт из них высоту, и aspect-ratio перестаёт работать — обложка вырастала
   до 900 px при ширине карточки 215. */
.bscard img { display: block; width: 100%; height: auto; aspect-ratio: 16/9; object-fit: cover; }
.bscard-media { position: relative; overflow: hidden; }
.bscard .clip {
  position: absolute; inset: 0; display: none;
  width: 100%; height: 100%; object-fit: cover;
  opacity: 0; transition: opacity .3s ease; pointer-events: none;
}
.bscard .clip.ready { opacity: 1; }
/* Пара «обычный/тёмный» подбирается так же, как у картинок: у блога тёмная
   тема по умолчанию. */
.bscard .clip.dark { display: block; }
[data-theme="light"] .bscard .clip.light { display: block; }
[data-theme="light"] .bscard .clip.dark { display: none; }
@media (prefers-reduced-motion: reduce) { .bscard .clip { display: none !important; } }
/* У блога тёмная тема по умолчанию — поэтому светлая обложка показывается
   только при явно выбранной светлой теме. */
.bscard .light { display: none; }
[data-theme="light"] .bscard .light { display: block; }
[data-theme="light"] .bscard .dark { display: none; }
.bscard-body { display: block; padding: 12px 14px 14px; }
.bscard-kind {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: .67rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
  color: var(--text-muted);
}
.bscard-kind svg { color: var(--emerald-400); }
.bscard-name {
  display: block; margin-top: 5px; font-size: .95rem; font-weight: 600; line-height: 1.35;
  color: var(--text-primary);
}
.bscard:hover .bscard-name { color: var(--emerald-400); }
@media (max-width: 700px) {
  /* Лента с прилипанием вместо сетки: на узком экране карточка в половину
     ширины нечитаема, а листать привычнее, чем щуриться. */
  .bschemes-grid {
    display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory;
    scroll-behavior: smooth; padding: 2px 0 10px; -webkit-overflow-scrolling: touch;
    scrollbar-width: thin; scrollbar-color: rgba(16, 185, 129, .5) transparent;
  }
  .bschemes-grid::-webkit-scrollbar { height: 6px; }
  .bschemes-grid::-webkit-scrollbar-track { background: transparent; }
  .bschemes-grid::-webkit-scrollbar-thumb {
    border-radius: 8px; background: rgba(16, 185, 129, .45);
  }
  .bscard { flex: 0 0 78%; scroll-snap-align: start; }
  /* Одна схема — не лента: занимает всю ширину. */
  .bscard:only-child { flex: 0 0 100%; }
  .bschemes-grid:has(> .bscard:only-child) { overflow-x: visible; }
  .bscard-body { padding: 11px 13px 13px; }
  .bscard-name { font-size: .92rem; }
}


/* ---- Снимки экрана и ссылки в статье ---- */
.bfig { margin: 26px 0 28px; }
/* height:auto — чтобы снимок не вытянулся, если у него окажутся атрибуты
   размеров: браузер считает их подсказкой сильнее aspect-ratio. */
.bfig img {
  display: block; width: 100%; height: auto; border-radius: 12px;
  border: 1px solid var(--bg-card-border); background: var(--bg-card);
}
/* видео в статье оформляем как снимок: те же поля, скругление и рамка */
.bfig video {
  display: block; width: 100%; height: auto; border-radius: 12px;
  border: 1px solid var(--bg-card-border); background: #0d1117;
}
.bfig figcaption {
  margin-top: 9px; color: var(--text-muted); font-size: .86rem; line-height: 1.5;
}

.blinks {
  margin: 30px 0 8px; padding: 16px 18px; border-radius: 14px;
  border: 1px solid var(--bg-card-border); background: var(--bg-card);
}
.blinks > b { display: block; margin-bottom: 12px; color: var(--text-primary); }
.blinks-list { display: flex; flex-direction: column; gap: 8px; }
.blink {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px;
  border-radius: 12px; border: 1px solid var(--bg-card-border);
  background: var(--bg-body); color: var(--text-secondary);
  font-size: .92rem; font-weight: 500; line-height: 1.4;
  transition: border-color .15s ease, background .15s ease, color .15s ease;
  /* Появление по очереди: blog.js проставляет каждой ссылке свой --i. */
  opacity: 0; transform: translateY(8px);
  animation: blink-in .4s ease forwards;
  animation-delay: calc(var(--i, 0) * 70ms);
}
@keyframes blink-in { to { opacity: 1; transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) {
  .blink { animation: none; opacity: 1; transform: none; }
}
/* Иконка — контурный SVG своим блоком, а не псевдоэлементом текста: так не
   съезжает при переносе заголовка на вторую строку. Тему (документ, модуль,
   звонок, чат, список) определяет blog.js по тексту и href ссылки. */
.blink-ico {
  flex-shrink: 0; width: 34px; height: 34px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(16, 185, 129, .12); color: var(--emerald-400);
}
.blink-ico svg { width: 17px; height: 17px; }
.blink:hover {
  border-color: rgba(16, 185, 129, .45); color: var(--text-primary);
  background: rgba(16, 185, 129, .06);
}


/* ---- Нижняя строка карточки ---- */
.bcard-foot { display: flex; align-items: center; gap: 12px; margin-top: auto; }
.bcard-date { display: none; }
.bcard-views {
  display: none; align-items: center; gap: 5px; margin-left: auto;
  color: var(--text-muted); font-size: .82rem; font-variant-numeric: tabular-nums;
}
.bcard-views[hidden] { display: none; }

@media (max-width: 640px) {
  /* Дата уходит с обложки вниз карточки: наверху остаётся только рубрика,
     иллюстрация не перекрыта двумя плашками. */
  .bcard-meta time { display: none; }
  .bcard-date { display: inline; color: var(--text-muted); font-size: .82rem; }
  .bcard-more { margin-left: 12px; }
  .bcard-views:not([hidden]) { display: inline-flex; }
}


/* ---- Обложка карточки: рубрика сверху, дата снизу ---- */
/* Обложка получила свою обёртку: вынос за поля карточки теперь на ней,
   а картинка внутри занимает всю ширину. */
.bcard-media {
  position: relative; display: block; overflow: hidden;
  width: calc(100% + 48px); margin: 0 -24px 18px;
}
.bcard-media .bcard-cover { width: 100%; margin: 0; }
.bcard-cdate {
  position: absolute; left: 14px; bottom: 12px; z-index: 2;
  padding: 3px 9px; border-radius: 999px; font-size: .8rem;
  background: rgba(2, 6, 23, .62); color: #e2e8f0;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
[data-theme="light"] .bcard-cdate { background: rgba(255, 255, 255, .82); color: #334155; }
/* Нижняя строка карточки: слева «Читать», справа просмотры. */
.bcard-more { margin-left: 0; }
.bcard-date { display: none !important; }


/* ---- Просмотры в шапке статьи ---- */
.bpost-views {
  display: none; align-items: center; gap: 5px;
  color: var(--text-muted); font-variant-numeric: tabular-nums;
}
.bpost-views:not([hidden]) { display: inline-flex; }
.bpost-views svg { margin-left: 2px; }


/* ---- Вопрос ассистенту репликой в чате ---- */
.bcta-btns { align-items: flex-start; }
.bcta-ask {
  display: flex; flex-direction: column; align-items: flex-end; gap: 6px;
  flex: 1 1 320px; padding: 0; border: 0; background: none; max-width: 100%;
}
.bcta-ask:hover { background: none; }
/* Пузырь как в переписке: скруглён со всех сторон, кроме угла у «хвоста». */
.bask-bubble {
  /* хвостик реплики выступает вправо на 5px — оставляем ему место внутри
     карточки, иначе он упирается в её край и выглядит обрезанным */
  position: relative; display: inline-block; max-width: calc(100% - 8px);
  margin-right: 6px;
  padding: 10px 15px; border-radius: 20px 20px 6px 20px;
  /* заливка как у значка в шапке */
  background: linear-gradient(135deg, var(--emerald-500), var(--teal-400));
  color: #04140f;
  font-size: .95rem; line-height: 1.4; text-align: left;
  box-shadow: 0 6px 18px rgba(16, 185, 129, .18);
  transition: transform .18s ease, box-shadow .18s ease;
}
[data-theme="light"] .bask-bubble { color: #fff; }
.bask-bubble::after {
  /* хвостик реплики: маленький треугольник у нижнего правого угла */
  content: ''; position: absolute; right: -5px; bottom: 0;
  width: 12px; height: 14px;
  background: linear-gradient(135deg, var(--emerald-500), var(--teal-400));
  border-bottom-left-radius: 12px;
  -webkit-mask: radial-gradient(circle at 100% 0, transparent 12px, #000 12.5px);
  mask: radial-gradient(circle at 100% 0, transparent 12px, #000 12.5px);
}
.bcta-ask:hover .bask-bubble {
  transform: translateY(-2px); box-shadow: 0 10px 24px rgba(16, 185, 129, .26);
}
.bask-hint { color: var(--text-muted); font-size: .82rem; font-weight: 500; }
.bcta-ask:hover .bask-hint { color: var(--emerald-400); }


/* Оживление при появлении: сначала «печатает», потом реплика. Заводится один
   раз, когда блок доходит до экрана, и молчит при prefers-reduced-motion. */
.bcta-ask .bask-typing {
  display: none; align-items: center; gap: 4px;
  padding: 11px 14px; border-radius: 20px 20px 6px 20px;
  background: var(--bg-card); border: 1px solid var(--bg-card-border);
}
.bcta-ask .bask-typing i {
  width: 6px; height: 6px; border-radius: 50%; background: var(--text-muted);
  animation: bask-dot 1.1s infinite ease-in-out;
}
.bcta-ask .bask-typing i:nth-child(2) { animation-delay: .18s; }
.bcta-ask .bask-typing i:nth-child(3) { animation-delay: .36s; }
@keyframes bask-dot { 0%, 60%, 100% { opacity: .35; transform: translateY(0); }
                      30% { opacity: 1; transform: translateY(-3px); } }

/* До показа реплика ждёт за кадром — но только если скрипт успел пометить
   блок: без него всё видно сразу, как раньше. */
.bcta-end.is-armed .bask-bubble,
.bcta-end.is-armed .bask-hint { opacity: 0; }
.bcta-end.is-typing .bask-typing { display: inline-flex; }
.bcta-end.is-live .bask-bubble {
  animation: bask-pop .42s cubic-bezier(.22, 1.2, .36, 1) both;
}
.bcta-end.is-live .bask-hint { animation: bask-fade .5s ease .25s both; }
@keyframes bask-pop { from { opacity: 0; transform: translateY(10px) scale(.94); }
                      to { opacity: 1; transform: none; } }
@keyframes bask-fade { from { opacity: 0; } to { opacity: 1; } }

/* Кнопка показа мигает мягким кольцом — два раза и успокаивается. */
/* кольцо перенесено в правило .is-done ниже */
@keyframes bask-ring {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, .45); }
  70% { box-shadow: 0 0 0 14px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

@media (prefers-reduced-motion: reduce) {
  .bcta-end.is-armed .bask-bubble, .bcta-end.is-armed .bask-hint { opacity: 1; }
  .bcta-end .bask-typing { display: none !important; }
  .bcta-end.is-live .bcta-go, .bcta-end.is-live .bask-bubble,
  .bcta-end.is-live .bask-hint { animation: none; }
}

@media (max-width: 560px) {
  .bcta-ask { align-items: flex-end; }
  .bask-bubble { font-size: .92rem; }
}


/* ---- Печать реплики по буквам ---- */
/* Пока текст печатается, ширину держит невидимая копия целиком — иначе пузырь
   растёт рывками и толкает соседние блоки. */
.bask-bubble { position: relative; }
.bask-ghost {
  visibility: hidden; display: block; height: 0; overflow: hidden;
  pointer-events: none;
}
.bask-caret {
  display: inline-block; width: 2px; height: 1.05em; margin-left: 1px;
  vertical-align: -2px; background: currentColor; opacity: .75;
  animation: bask-caret 1s steps(1) infinite;
}
.bcta-end.is-done .bask-caret { display: none; }
@keyframes bask-caret { 0%, 50% { opacity: .75; } 51%, 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .bask-caret { display: none; } }


/* ---- Появление кнопки показа ---- */
/* Кнопка прячется только когда за дело взялся скрипт: без него и при
   выключенных анимациях она видна сразу. */
.bcta-end.is-armed .bcta-go, .bcta-end.is-typing .bcta-go, .bcta-end.is-live .bcta-go {
  opacity: 0; transform: translateY(10px) scale(.97);
}
.bcta-end.is-done .bcta-go {
  animation: bcta-in .5s cubic-bezier(.22, 1.2, .36, 1) both,
             bask-ring 1.8s ease-out .5s 2;
}
@keyframes bcta-in {
  from { opacity: 0; transform: translateY(10px) scale(.97); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .bcta-end .bcta-go { opacity: 1 !important; transform: none !important; animation: none !important; }
}


/* ---- Рубрика в строке с датой ---- */
.bmeta .btag { margin-bottom: 0; }

/* Мобильный: широкая таблица не должна растягивать страницу. Прокручиваем её
   внутри себя — горизонтальная прокрутка всей статьи выглядит как поломка,
   а таблицы сравнения по-другому на 360 px не помещаются. */
@media (max-width: 768px) {
  .bpost table {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .bpost table th, .bpost table td { white-space: normal; }
  .bmermaid { overflow-x: auto; }
  .bpost p, .bpost li, .bpost blockquote, .bpost td { overflow-wrap: break-word; }
  .bpost img, .bpost figure { max-width: 100%; }
}

/* ---- Схемы: миллиметровка, масштаб, полный экран (16.09.2026) ---- */
.bmermaid.bmmd { padding: 0; overflow: hidden; }
.bmmd-bar {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 10px; border-bottom: 1px solid var(--bg-card-border);
}
.bmmd-bar button {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; padding: 0; cursor: pointer;
  border: 1px solid var(--bg-card-border); border-radius: 8px;
  background: transparent; color: var(--text-secondary);
  transition: background .15s, border-color .15s, color .15s;
}
.bmmd-bar button:hover { background: var(--emerald-500); border-color: var(--emerald-500); color: #fff; }
.bmmd-bar button:focus-visible { outline: 2px solid var(--emerald-400); outline-offset: 1px; }
.bmmd-bar .bmmd-full { margin-left: auto; }
.bmmd-pct {
  min-width: 46px; text-align: center; font-size: .82rem;
  font-variant-numeric: tabular-nums; color: var(--text-muted); user-select: none;
}
.bmmd-view {
  padding: 22px 18px; text-align: center; overflow-x: auto;
  /* миллиметровка: мелкая клетка и крупная каждые 5 */
  background-image:
    linear-gradient(rgba(16,185,129,.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(16,185,129,.07) 1px, transparent 1px),
    linear-gradient(rgba(16,185,129,.13) 1px, transparent 1px),
    linear-gradient(90deg, rgba(16,185,129,.13) 1px, transparent 1px);
  background-size: 16px 16px, 16px 16px, 80px 80px, 80px 80px;
  background-position: -1px -1px;
}
[data-theme="light"] .bmmd-view {
  background-image:
    linear-gradient(rgba(4,120,87,.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(4,120,87,.06) 1px, transparent 1px),
    linear-gradient(rgba(4,120,87,.11) 1px, transparent 1px),
    linear-gradient(90deg, rgba(4,120,87,.11) 1px, transparent 1px);
}
.bmmd-view pre.mermaid { display: inline-block; min-width: 100%; }
.bmermaid.is-zoomed .bmmd-view { overflow: auto; max-height: 80vh; cursor: grab; text-align: left; }
.bmermaid.is-zoomed .bmmd-view.is-drag { cursor: grabbing; user-select: none; }
/* полный экран: штатный режим браузера, без него — слой поверх страницы */
.bmermaid.bmmd:fullscreen,
.bmermaid.bmmd.is-fs {
  display: flex; flex-direction: column; margin: 0;
  border: 0; border-radius: 0; background: var(--bg-body);
}
.bmermaid.bmmd.is-fs { position: fixed; inset: 0; z-index: 3000; }
.bmermaid.bmmd:fullscreen .bmmd-view,
.bmermaid.bmmd.is-fs .bmmd-view { flex: 1 1 auto; overflow: auto; max-height: none; }
.bmermaid.bmmd:fullscreen:not(.is-zoomed) .bmmd-view svg,
.bmermaid.bmmd.is-fs:not(.is-zoomed) .bmmd-view svg { max-height: calc(100vh - 110px); width: auto; }
.bmmd-bar svg { flex: 0 0 auto; }
html.bmmd-lock { overflow: hidden; }
@media (pointer: coarse) { .bmmd-bar button { width: 40px; height: 40px; } }
@media (prefers-reduced-motion: reduce) { .bmmd-bar button { transition: none; } }

/* ═══════════ Остров-содержание статьи — мобильная навигация по h2 (≤768px) ═══════════
   Капсула внизу по центру: свёрнута → номер раздела в кольце прогресса + заголовок;
   развёрнута → список всех h2 статьи + полоса прогресса. Тот же приём, что на
   docs.billing.smit34.ru (initDocsIsland), перенесён в токены и тему блога. */
.btoc-island {
  --bi-bg: rgba(15, 23, 42, 0.72);
  --bi-bg-solid: #0b1220;
  --bi-text: var(--text-primary);
  --bi-text-dim: var(--text-secondary);
  --bi-num-muted: var(--text-muted);
  --bi-track: rgba(52, 211, 153, 0.22);
  --bi-shadow: 0 10px 36px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(52, 211, 153, 0.16) inset;
  --bi-accent: var(--emerald-400);
  --bi-accent-soft: rgba(52, 211, 153, 0.12);
  --bi-accent-soft-strong: rgba(52, 211, 153, 0.2);
  --bi-ring-from: var(--emerald-400);
  --bi-ring-to: var(--teal-400);
  --bi-bar: linear-gradient(90deg, var(--emerald-400), var(--teal-400));

  display: none;
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  z-index: 95;
  background: var(--bi-bg);
  color: var(--bi-text);
  border-radius: 26px;
  box-shadow: var(--bi-shadow);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
  overflow: hidden;
  transition: width .38s cubic-bezier(.34,1.3,.64,1),
              height .38s cubic-bezier(.34,1.3,.64,1),
              border-radius .38s ease,
              opacity .3s ease, transform .3s ease;
  width: 252px;
  height: 52px;
  /* Капсула появляется, только когда читатель прокрутил ниже второго
     экрана — на самом верху статьи она бы только мешала: заголовок ещё
     виден, оглавление там ни к чему. */
  opacity: 0; transform: translate(-50%, 16px); pointer-events: none;
}
.btoc-island.is-visible, .btoc-island.open {
  opacity: 1; transform: translate(-50%, 0); pointer-events: auto;
}
@media (prefers-reduced-motion: reduce) {
  .btoc-island { transform: translateX(-50%); }
}
[data-theme="light"] .btoc-island {
  --bi-bg: rgba(255, 255, 255, 0.8);
  --bi-bg-solid: #ffffff;
  --bi-track: rgba(4, 120, 87, 0.16);
  --bi-shadow: 0 10px 36px rgba(15, 23, 42, 0.16), 0 0 0 1px rgba(4, 120, 87, 0.12) inset;
  --bi-accent-soft: rgba(4, 120, 87, 0.1);
  --bi-accent-soft-strong: rgba(4, 120, 87, 0.16);
}
.btoc-island.open {
  width: min(340px, calc(100vw - 24px));
  height: min(60vh, calc(100vh - 110px));
  border-radius: 22px;
}

.btoc-island-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 52px;
  padding: 0 14px 0 8px;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.btoc-island-ring {
  position: relative;
  width: 36px; height: 36px;
  flex-shrink: 0;
  border-radius: 50%;
  background: conic-gradient(from -90deg,
                var(--bi-ring-from) 0%,
                var(--bi-ring-to) calc(var(--bi-progress, 0) * 1%),
                var(--bi-track) calc(var(--bi-progress, 0) * 1%));
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .25s ease;
}
.btoc-island-ring::after {
  content: '';
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: var(--bi-bg-solid);
}
.btoc-island-num {
  position: relative;
  z-index: 1;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: .74rem;
  font-weight: 700;
  color: var(--bi-accent);
}
.btoc-island-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: .82rem;
  font-weight: 600;
  line-height: 1.2;
  color: var(--bi-text);
}
.btoc-island-caret {
  flex-shrink: 0;
  font-size: .7rem;
  color: var(--bi-text-dim);
  opacity: .75;
  transition: transform .3s ease;
}
.btoc-island.open .btoc-island-caret { transform: rotate(180deg); }

.btoc-island-panel {
  display: flex;
  flex-direction: column;
  height: calc(100% - 52px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}
.btoc-island.open .btoc-island-panel {
  opacity: 1;
  pointer-events: auto;
  transition: opacity .25s ease .15s;
}
.btoc-island-progress { height: 3px; flex-shrink: 0; background: var(--bi-track); }
.btoc-island-progress-bar { height: 100%; width: 0; background: var(--bi-bar); transition: width .2s ease; }
.btoc-island-list {
  list-style: none;
  margin: 0;
  padding: 8px;
  overflow-y: auto;
  counter-reset: bi;
  flex: 0 1 auto;
  min-height: 0;
  max-height: 100%;
}
/* Список высотой ровно по своим пунктам (flex-grow: 0) — короткий список
   не растягивается на всю панель и не выталкивает превью за экран; длинный
   упирается в max-height родителя и скроллится сам. Превью снизу панели
   остаётся на месте и никогда не сжимается. */
.btoc-island-panel { flex-direction: column; }
.btoc-island-panel .btoc-next { flex-shrink: 0; }
.btoc-island-list li { margin: 0; counter-increment: bi; }
.btoc-island-list a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  color: var(--bi-text-dim);
  border-radius: 9px;
  text-decoration: none;
  font-size: .85rem;
  line-height: 1.3;
  transition: background .15s, color .15s;
}
.btoc-island-list a::before {
  content: counter(bi, decimal-leading-zero);
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: .68rem;
  font-weight: 700;
  color: var(--bi-num-muted);
  flex-shrink: 0;
  min-width: 20px;
}
.btoc-island-list a:hover { background: var(--bi-accent-soft); color: var(--bi-text); text-decoration: none; }
.btoc-island-list a.active { background: var(--bi-accent-soft-strong); color: var(--bi-accent); font-weight: 600; }
.btoc-island-list a.active::before { color: var(--bi-accent); }
.btoc-island-list::-webkit-scrollbar { width: 4px; }
.btoc-island-list::-webkit-scrollbar-thumb { background: rgba(52,211,153,0.4); border-radius: 8px; }

/* Превью следующей статьи внизу развёрнутой панели: обложка с заголовком
   оверлеем по нижнему краю. Тёмная тема — тёмный градиент и белый текст;
   светлая — светлый градиент и чёрный текст (не наоборот, читаемость ради).
   Появляется плавно, когда список разделов прокручен ближе к низу — не
   занимает место сразу, список остаётся главным содержимым панели. */
.btoc-next {
  display: block; flex-shrink: 0; margin: 4px 8px 8px;
  border-radius: 14px; overflow: hidden; color: inherit; text-decoration: none;
  border: 1px solid var(--bi-accent-soft-strong);
  box-shadow: 0 8px 20px -10px rgba(2, 6, 23, .35);
  opacity: 0; transform: translateY(10px);
  transition: opacity .35s ease, transform .35s ease;
}
[data-theme="light"] .btoc-next { box-shadow: 0 8px 20px -10px rgba(15, 23, 42, .18); }
.btoc-next.is-shown { opacity: 1; transform: translateY(0); }
.btoc-next-media {
  position: relative; display: block; aspect-ratio: 16/9; overflow: hidden;
  background: var(--bi-bg-solid);
}
/* Обложка без mix-blend-mode: exclusion/screen инвертируют яркие или тёмные
   участки картинки в противоположный цвет — светлая обложка на светлой теме
   (или тёмная на тёмной) местами пропадала совсем. Слияние с фоном панели —
   только виньеткой по краям ниже, картинка сама остаётся как есть. */
.btoc-next-media img {
  display: block; width: 100%; height: 100%; object-fit: cover;
  opacity: .78;
}
/* Виньетка: края картинки растворяются в фоне панели, а не просто темнеют —
   обложка выглядит вклеенной в остров, а не наклейкой поверх него. */
.btoc-next-media::before {
  content: ''; position: absolute; inset: 0; z-index: 1;
  background: radial-gradient(120% 100% at 50% 45%, transparent 42%, var(--bi-bg-solid) 100%);
}
.btoc-next-media::after {
  content: ''; position: absolute; inset: 0; z-index: 1;
  background: linear-gradient(to top, rgba(2, 6, 23, .88) 0%, rgba(2, 6, 23, .38) 46%, transparent 74%);
}
[data-theme="light"] .btoc-next-media::after {
  background: linear-gradient(to top, rgba(255, 255, 255, .6) 0%, rgba(255, 255, 255, .26) 46%, transparent 74%);
}
/* «Читайте дальше» + дата/время — оверлеем по верхней линии обложки, на
   собственном затемнении сверху вниз: текст остаётся светлым и читаемым
   поверх любой картинки, независимо от темы страницы. */
.btoc-next-head {
  position: absolute; top: 0; left: 0; right: 0; z-index: 3;
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  padding: 10px 12px;
  background: linear-gradient(to bottom, rgba(2, 6, 23, .78) 0%, rgba(2, 6, 23, .38) 60%, transparent 100%);
}
[data-theme="light"] .btoc-next-head {
  background: linear-gradient(to bottom, rgba(255, 255, 255, .85) 0%, rgba(255, 255, 255, .4) 60%, transparent 100%);
}
.btoc-next-eyebrow {
  display: block;
  font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  color: rgba(255, 255, 255, .78);
}
[data-theme="light"] .btoc-next-eyebrow { color: rgba(15, 23, 42, .68); }
.btoc-next-meta {
  display: flex; align-items: center; gap: 10px; flex-shrink: 0;
  font-size: .74rem; color: rgba(255, 255, 255, .78);
}
[data-theme="light"] .btoc-next-meta { color: rgba(15, 23, 42, .68); }
.btoc-next-meta-item { display: inline-flex; align-items: center; gap: 4px; }
.btoc-next-meta-item svg { width: 12px; height: 12px; flex-shrink: 0; }
.btoc-next-title {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 2;
  margin: 0; padding: 14px 12px;
  font-size: 1.38rem; font-weight: 700; line-height: 1.25;
  color: #f8fafc;
}
[data-theme="light"] .btoc-next-title { color: #0f172a; }
@media (prefers-reduced-motion: reduce) {
  .btoc-next { transition: none; }
}

.btoc-island-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.5);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  z-index: 94;
  opacity: 0;
  transition: opacity .3s ease;
}
.btoc-island-backdrop.show { display: block; opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  .btoc-island, .btoc-island-caret, .btoc-island-panel,
  .btoc-island-progress-bar, .btoc-island-ring { transition: none; }
}

@media (max-width: 768px) {
  .btoc-island { display: block; }
}
