/* ═══════════════════════  ТОКЕНЫ  ═══════════════════════ */

:root {
  /* палитра платформы rustat */
  --brand: #0b456e;
  --brand-600: #0d5385;
  --brand-500: #196ba6;
  --brand-300: #57c5f7;

  --bg: #ebeef0;
  --surface: #ffffff;
  --surface-2: #f5f7f8;
  --text: #313233;
  --muted: #6f7173;
  --faint: #8f9294;
  --border: #cdd1d4;
  --border-soft: #e3e6e8;

  --ok: #2a9c36;
  --ok-bg: #eef8ef;
  --warn: #b34700;
  --warn-bg: #fff4ec;
  --stop: #c62828;
  --stop-bg: #fdeded;
  --note-bg: #eef4f9;

  --shadow-1: 0 1px 2px rgba(50, 51, 51, .06), 0 1px 3px rgba(50, 51, 51, .04);
  --shadow-2: 0 4px 16px rgba(50, 51, 51, .08), 0 1px 3px rgba(50, 51, 51, .06);
  --shadow-3: 0 12px 40px rgba(11, 69, 110, .18);

  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;
  --r-xl: 20px;

  /* сильные кривые — стандартные CSS-easing слишком вялые */
  --ease-out: cubic-bezier(.23, 1, .32, 1);
  --ease-in-out: cubic-bezier(.77, 0, .175, 1);

  --header-h: 56px;
  --nav-h: 60px;

  --font: 'Noto Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
    'Helvetica Neue', Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1317;
    --surface: #171d23;
    --surface-2: #1e262e;
    --text: #e7eaec;
    --muted: #9aa2a9;
    --faint: #7c848b;
    --border: #2b343d;
    --border-soft: #232c34;

    --brand: #3d8fc9;
    --brand-600: #57a5db;
    --brand-500: #6bb4e6;

    --ok: #4ec95c;
    --ok-bg: #14251a;
    --warn: #e08544;
    --warn-bg: #2a1d13;
    --stop: #f06060;
    --stop-bg: #2c1618;
    --note-bg: #16222c;

    --shadow-1: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-2: 0 4px 16px rgba(0, 0, 0, .35);
    --shadow-3: 0 12px 40px rgba(0, 0, 0, .5);
  }
}

/* ═══════════════════════  БАЗА  ═══════════════════════ */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 16px);
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
}

body.lock { overflow: hidden; }

button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
a { color: var(--brand-500); text-decoration: none; }
img { max-width: 100%; display: block; }

:focus-visible {
  outline: 2px solid var(--brand-500);
  outline-offset: 2px;
  border-radius: 4px;
}

.sr {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

[hidden] { display: none !important; }

.wrap { max-width: 720px; margin: 0 auto; padding: 0 12px; }

/* ═══════════════════════  ШАПКА  ═══════════════════════ */

.hdr {
  position: sticky; top: 0; z-index: 40;
  height: var(--header-h);
}

/* Блюр живёт на псевдоэлементе: backdrop-filter на самой .hdr сделал бы её
   containing block для position:fixed внутри — нижняя навигация прилипла бы
   к шапке вместо вьюпорта. */
.hdr::before {
  content: ''; position: absolute; inset: 0; z-index: -1;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border-soft);
}

.hdr-in {
  max-width: 720px; margin: 0 auto; padding: 0 12px;
  height: 100%; display: flex; align-items: center; gap: 12px;
}

.logo { height: 22px; width: auto; flex: none; }
@media (prefers-color-scheme: dark) { .logo { filter: brightness(0) invert(1) opacity(.92); } }

.hdr-sep { width: 1px; height: 18px; background: var(--border); flex: none; }
.hdr-title { font-size: 15px; font-weight: 600; letter-spacing: -.01em; }
.hdr-spacer { flex: 1; }

.hdr-btn {
  height: 36px; padding: 0 10px; border-radius: var(--r-sm);
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 600; color: var(--muted);
  transition: transform 160ms var(--ease-out), background-color 160ms ease, color 160ms ease;
}
.hdr-btn:active { transform: scale(.94); }
@media (hover: hover) and (pointer: fine) {
  .hdr-btn:hover { background: var(--surface-2); color: var(--text); }
}
.hdr-btn svg { width: 16px; height: 16px; }

/* ═══════════════════════  ПРОГРЕСС  ═══════════════════════ */

.prog {
  position: sticky; top: var(--header-h); z-index: 30;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color 200ms ease;
}
.prog.stuck { border-bottom-color: var(--border-soft); }

.prog-in { max-width: 720px; margin: 0 auto; padding: 10px 12px; }

.prog-row {
  display: flex; align-items: baseline; gap: 8px;
  margin-bottom: 8px; font-size: 13px;
}
.prog-lbl { font-weight: 600; letter-spacing: -.01em; }
.prog-cnt { color: var(--muted); font-variant-numeric: tabular-nums; }
.prog-pct {
  margin-left: auto; font-weight: 700; color: var(--brand);
  font-variant-numeric: tabular-nums;
}

.prog-track {
  height: 6px; border-radius: 99px; overflow: hidden;
  background: var(--border-soft);
}
.prog-bar {
  height: 100%; width: 0; border-radius: 99px;
  background: linear-gradient(90deg, var(--brand), var(--brand-500));
  transform-origin: left;
  transition: width 420ms var(--ease-out), background-color 300ms ease;
}
.prog.done .prog-bar { background: linear-gradient(90deg, var(--ok), var(--ok)); }
.prog.done .prog-pct { color: var(--ok); }

/* ═══════════════════════  СЕКЦИИ ЧЕК-ЛИСТА  ═══════════════════════ */

.sec {
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
  margin-bottom: 12px;
  overflow: hidden;
  animation: rise 400ms var(--ease-out) backwards;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
}
.sec:nth-child(1) { animation-delay: 0ms; }
.sec:nth-child(2) { animation-delay: 40ms; }
.sec:nth-child(3) { animation-delay: 80ms; }
.sec:nth-child(4) { animation-delay: 120ms; }
.sec:nth-child(5) { animation-delay: 160ms; }
.sec:nth-child(6) { animation-delay: 200ms; }

.sec-hd {
  width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 14px 14px; text-align: left;
  transition: background-color 160ms ease;
}
@media (hover: hover) and (pointer: fine) {
  .sec-hd:hover { background: var(--surface-2); }
}

.sec-num {
  flex: none; width: 26px; height: 26px; border-radius: 8px;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 700;
  background: var(--surface-2); color: var(--muted);
  transition: background-color 260ms var(--ease-out), color 260ms var(--ease-out);
}
.sec.done .sec-num { background: var(--ok); color: #fff; }
.sec-num svg { width: 14px; height: 14px; }

.sec-txt { flex: 1; min-width: 0; }
.sec-ttl { font-size: 16px; font-weight: 700; letter-spacing: -.015em; }
.sec-sub { font-size: 12px; color: var(--muted); margin-top: 1px; }

.sec-cnt {
  flex: none; font-size: 12px; font-weight: 600; color: var(--muted);
  font-variant-numeric: tabular-nums;
  transition: color 260ms ease;
}
.sec.done .sec-cnt { color: var(--ok); }

.sec-chev {
  flex: none; width: 18px; height: 18px; color: var(--faint);
  transition: transform 260ms var(--ease-out);
}
.sec.open .sec-chev { transform: rotate(180deg); }

/* плавная высота без замера JS */
.sec-body {
  display: grid; grid-template-rows: 0fr;
  transition: grid-template-rows 300ms var(--ease-out);
}
.sec.open .sec-body { grid-template-rows: 1fr; }
.sec-body > div { overflow: hidden; }

/* ═══════════════════════  ПУНКТ ЧЕК-ЛИСТА  ═══════════════════════ */

.it { border-top: 1px solid var(--border-soft); }

.it-row {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 14px;
  min-height: 52px;
}

.box {
  position: relative;
  flex: none; width: 24px; height: 24px; margin-top: 1px;
  border-radius: 7px; border: 2px solid var(--border);
  background: var(--surface);
  display: grid; place-items: center;
  transition: transform 160ms var(--ease-out), background-color 200ms var(--ease-out),
    border-color 200ms var(--ease-out);
}
/* палец толще чекбокса: расширяем зону нажатия до 44px, не трогая вид */
.box::after { content: ''; position: absolute; inset: -10px; }
.box:active { transform: scale(.88); }
@media (hover: hover) and (pointer: fine) {
  .box:hover { border-color: var(--brand-500); }
}
.box svg { width: 14px; height: 14px; color: #fff; }
.box path {
  stroke-dasharray: 22; stroke-dashoffset: 22;
  transition: stroke-dashoffset 220ms var(--ease-out) 40ms;
}
.it.on .box { background: var(--brand); border-color: var(--brand); }
.it.on .box path { stroke-dashoffset: 0; }
.it.on.blocker .box, .it.on.danger .box { background: var(--ok); border-color: var(--ok); }

.it-txt {
  flex: 1; min-width: 0; text-align: left;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: opacity 240ms ease;
}
.it.on .it-txt { opacity: .5; }

.it-t {
  font-size: 15px; font-weight: 500; line-height: 1.4;
  transition: color 240ms ease;
}
.it.on .it-t { text-decoration: line-through; text-decoration-color: var(--faint); }

.it-h {
  font-size: 12.5px; color: var(--muted); margin-top: 2px; line-height: 1.35;
}

.it-tag {
  display: inline-block; margin-left: 6px; padding: 1px 6px;
  border-radius: 5px; font-size: 10px; font-weight: 700;
  letter-spacing: .04em; text-transform: uppercase;
  vertical-align: 1.5px;
}
.blocker .it-tag { background: var(--note-bg); color: var(--brand); }
.danger .it-tag { background: var(--stop-bg); color: var(--stop); }

.it-more {
  position: relative;
  flex: none; align-self: flex-start;
  width: 32px; height: 32px; margin: -4px -6px 0 0;
  border-radius: 8px; display: grid; place-items: center;
  color: var(--faint);
  transition: transform 220ms var(--ease-out), background-color 160ms ease, color 160ms ease;
}
.it-more::after { content: ''; position: absolute; inset: -6px; }
.it-more svg { width: 16px; height: 16px; }
.it-more:active { transform: scale(.9); }
@media (hover: hover) and (pointer: fine) {
  .it-more:hover { background: var(--surface-2); color: var(--text); }
}
.it.exp .it-more { transform: rotate(180deg); color: var(--brand-500); }
.it.exp .it-more:active { transform: rotate(180deg) scale(.9); }

.it-body {
  display: grid; grid-template-rows: 0fr;
  transition: grid-template-rows 300ms var(--ease-out);
}
.it.exp .it-body { grid-template-rows: 1fr; }
.it-body > div { overflow: hidden; }
.it-body .blocks { padding: 2px 14px 14px 50px; }

/* ═══════════════════════  БЛОКИ КОНТЕНТА  ═══════════════════════ */

.blocks > * { margin: 0 0 10px; }
.blocks > *:last-child { margin-bottom: 0; }

.blocks p { font-size: 14px; line-height: 1.55; color: var(--text); }
.blocks b { font-weight: 700; }

.b-h {
  font-size: 13px; font-weight: 700; letter-spacing: .02em;
  text-transform: uppercase; color: var(--muted);
  margin-top: 18px;
}
.blocks > .b-h:first-child { margin-top: 0; }

.b-list, .b-steps { padding-left: 0; margin-left: 0; list-style: none; }
.b-list li, .b-steps li {
  position: relative; font-size: 14px; line-height: 1.5;
  padding-left: 24px; margin-bottom: 7px;
}
.b-list li:last-child, .b-steps li:last-child { margin-bottom: 0; }

.b-list li::before {
  content: ''; position: absolute; left: 7px; top: 8px;
  width: 5px; height: 5px; border-radius: 50%; background: var(--brand-300);
}
.b-steps { counter-reset: s; }
.b-steps li { counter-increment: s; padding-left: 26px; }
.b-steps li::before {
  content: counter(s); position: absolute; left: 0; top: 1px;
  width: 18px; height: 18px; border-radius: 5px;
  background: var(--note-bg); color: var(--brand);
  font-size: 10.5px; font-weight: 700;
  display: grid; place-items: center;
}

.b-kv {
  border: 1px solid var(--border-soft); border-radius: var(--r);
  overflow: hidden;
}
.b-kv div {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr);
  gap: 10px; padding: 9px 11px; font-size: 13.5px;
  border-bottom: 1px solid var(--border-soft);
}
.b-kv div:last-child { border-bottom: 0; }
.b-kv div:nth-child(odd) { background: var(--surface-2); }
.b-kv dt { color: var(--muted); }
.b-kv dd { margin: 0; font-weight: 600; }

.b-cal { border-left: 3px solid; border-radius: var(--r-sm); padding: 10px 12px; }
.b-cal p { font-size: 13.5px; line-height: 1.5; margin: 0; }
.b-cal.note { border-color: var(--brand-500); background: var(--note-bg); }
.b-cal.warn { border-color: var(--warn); background: var(--warn-bg); }
.b-cal.warn p { color: var(--warn); }
.b-cal.stop { border-color: var(--stop); background: var(--stop-bg); }
.b-cal.stop p { color: var(--stop); font-weight: 600; }

.b-fig { margin: 0; }
.b-fig img {
  width: 100%; border-radius: var(--r); background: var(--surface-2);
  border: 1px solid var(--border-soft); cursor: zoom-in;
  transition: transform 200ms var(--ease-out);
}
.b-fig img:active { transform: scale(.99); }
.b-fig figcaption {
  font-size: 12px; color: var(--muted); margin-top: 5px; text-align: center;
}

.b-grid {
  display: grid; gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
}

.b-link {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 13.5px; font-weight: 600; color: var(--brand-500);
  padding: 7px 0;
  transition: gap 200ms var(--ease-out);
}
.b-link svg { width: 14px; height: 14px; }
@media (hover: hover) and (pointer: fine) { .b-link:hover { gap: 8px; } }

/* табы схем */
.b-tabs { border: 1px solid var(--border-soft); border-radius: var(--r); overflow: hidden; }
.b-tabs-hd {
  display: flex; gap: 2px; padding: 4px;
  background: var(--surface-2); border-bottom: 1px solid var(--border-soft);
}
.b-tab {
  flex: 1; padding: 7px 4px; border-radius: 7px;
  font-size: 12.5px; font-weight: 600; color: var(--muted);
  transition: color 200ms ease, background-color 200ms ease, transform 160ms var(--ease-out);
}
.b-tab:active { transform: scale(.96); }
.b-tab[aria-selected='true'] {
  background: var(--surface); color: var(--brand); box-shadow: var(--shadow-1);
}
.b-tabs-bd { padding: 12px; }
.b-tabs-bd .blocks { animation: fadeIn 240ms var(--ease-out); }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } }

/* ═══════════════════════  СБРОС / ФИНАЛ  ═══════════════════════ */

.done-card {
  display: flex; align-items: center; gap: 12px;
  background: var(--ok-bg); border: 1px solid color-mix(in srgb, var(--ok) 30%, transparent);
  border-radius: var(--r-lg); padding: 14px; margin-bottom: 12px;
  animation: rise 400ms var(--ease-out);
}
.done-card svg { width: 22px; height: 22px; color: var(--ok); flex: none; }
.done-card p { margin: 0; font-size: 14px; font-weight: 600; color: var(--ok); }

.reset-row { display: flex; justify-content: center; padding: 4px 0 20px; }
.reset {
  padding: 9px 16px; border-radius: 99px;
  font-size: 13px; font-weight: 600; color: var(--muted);
  border: 1px solid var(--border);
  transition: transform 160ms var(--ease-out), color 160ms ease, border-color 160ms ease;
}
.reset:active { transform: scale(.96); }
@media (hover: hover) and (pointer: fine) {
  .reset:hover { color: var(--stop); border-color: var(--stop); }
}

/* ═══════════════════════  ИНСТРУКЦИИ  ═══════════════════════ */

.doc-hd { padding: 20px 0 14px; }
.doc-ttl { font-size: 24px; font-weight: 700; letter-spacing: -.02em; margin: 0; }
.doc-sub { font-size: 13.5px; color: var(--muted); margin: 4px 0 0; }

.toc {
  display: flex; gap: 6px; overflow-x: auto; padding: 0 12px 12px;
  margin: 0 -12px; scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.toc::-webkit-scrollbar { display: none; }
.toc a {
  flex: none; padding: 7px 12px; border-radius: 99px;
  font-size: 13px; font-weight: 600; color: var(--muted);
  background: var(--surface); border: 1px solid var(--border-soft);
  white-space: nowrap;
  transition: transform 160ms var(--ease-out), color 160ms ease, border-color 160ms ease;
}
.toc a:active { transform: scale(.95); }
.toc a.on { color: var(--brand); border-color: var(--brand); background: var(--note-bg); }

.dsec {
  background: var(--surface); border-radius: var(--r-lg);
  box-shadow: var(--shadow-1); margin-bottom: 12px; overflow: hidden;
  animation: rise 400ms var(--ease-out) backwards;
}
.dsec-hd {
  width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 15px 14px; text-align: left;
  transition: background-color 160ms ease;
}
@media (hover: hover) and (pointer: fine) {
  .dsec-hd:hover { background: var(--surface-2); }
}
.dsec-ttl { flex: 1; font-size: 16px; font-weight: 700; letter-spacing: -.015em; }
.dsec-chev {
  flex: none; width: 18px; height: 18px; color: var(--faint);
  transition: transform 260ms var(--ease-out);
}
.dsec.open .dsec-chev { transform: rotate(180deg); }
.dsec-body {
  display: grid; grid-template-rows: 0fr;
  transition: grid-template-rows 300ms var(--ease-out);
}
.dsec.open .dsec-body { grid-template-rows: 1fr; }
.dsec-body > div { overflow: hidden; }
.dsec-body .blocks { padding: 2px 14px 16px; border-top: 1px solid var(--border-soft); padding-top: 14px; }

/* ═══════════════════════  НИЖНЯЯ НАВИГАЦИЯ  ═══════════════════════ */

.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex;
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-top: 1px solid var(--border-soft);
}
.nav a {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 3px;
  font-size: 10.5px; font-weight: 600; color: var(--muted);
  transition: color 200ms ease, transform 160ms var(--ease-out);
}
.nav a:active { transform: scale(.93); }
.nav a.on { color: var(--brand); }
.nav svg { width: 21px; height: 21px; }

/* ═══════════════════════  ЛАЙТБОКС  ═══════════════════════ */

.lb {
  position: fixed; inset: 0; z-index: 90;
  display: grid; place-items: center; padding: 16px;
  background: rgba(10, 14, 18, .92);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  opacity: 0; pointer-events: none;
  transition: opacity 220ms var(--ease-out);
}
.lb.on { opacity: 1; pointer-events: auto; }
.lb img {
  max-width: 100%; max-height: 82vh; border-radius: var(--r);
  transform: scale(.96); transition: transform 260ms var(--ease-out);
  object-fit: contain;
}
.lb.on img { transform: scale(1); }
.lb figcaption {
  color: #cdd1d4; font-size: 13px; text-align: center;
  margin-top: 12px; max-width: 480px;
}
.lb-x {
  position: absolute; top: calc(12px + env(safe-area-inset-top)); right: 12px;
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(255, 255, 255, .12); color: #fff;
  transition: transform 160ms var(--ease-out), background-color 160ms ease;
}
.lb-x:active { transform: scale(.9); }
.lb-x svg { width: 18px; height: 18px; }

/* ═══════════════════════  ПЛАНШЕТ / ДЕСКТОП  ═══════════════════════ */

@media (min-width: 768px) {
  body { padding-bottom: 32px; }
  .nav {
    position: static; height: auto; padding: 0; border: 0; background: none;
    backdrop-filter: none; -webkit-backdrop-filter: none;
    gap: 4px; margin-left: auto;
  }
  .nav a {
    flex: none; flex-direction: row; gap: 6px;
    padding: 7px 12px; border-radius: 99px; font-size: 13px;
    transition: color 200ms ease, background-color 200ms ease, transform 160ms var(--ease-out);
  }
  .nav a.on { background: var(--note-bg); }
  @media (hover: hover) and (pointer: fine) {
    .nav a:hover { color: var(--text); background: var(--surface-2); }
    .nav a.on:hover { color: var(--brand); background: var(--note-bg); }
  }
  .nav svg { width: 17px; height: 17px; }
  .hdr-title { display: none; }
  .hdr-sep { display: none; }

  .wrap { padding: 0 16px; }
  .it-body .blocks { padding-right: 20px; }
  .doc-ttl { font-size: 30px; }
  .b-grid { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
}

/* ═══════════════════════  СНИЖЕННАЯ АНИМАЦИЯ  ═══════════════════════ */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-delay: 0ms !important;
    transition-duration: .01ms !important;
  }
  /* понимание состояния оставляем — убираем только движение */
  .sec-body, .it-body, .dsec-body { transition: none; }
  .prog-bar { transition: width 120ms linear; }
  .lb, .lb img { transition: opacity 120ms linear; }
}
