/* ansi — дизайн-система (эстетика в духе X: чистый чёрный, hairline-границы, пилюли) */
:root {
  --font-ui: "Onest", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, Consolas, monospace;

  --fs-xs: 13px; --fs-sm: 14px; --fs-base: 15px; --fs-lg: 17px;
  --fs-h3: 20px; --fs-h2: 23px; --fs-h1: clamp(36px, 6.4vw, 60px);

  --r-pill: 9999px; --r-card: 16px; --r-field: 12px; --r-sm: 8px;
  --dur: .15s; --ease: cubic-bezier(.2, 0, 0, 1);

  color-scheme: dark;
  --bg: #000; --surface: #16181c; --surface-2: #202327;
  --text: #e7e9ea; --muted: #71767b; --faint: #536471;
  --border: #2f3336; --border-strong: #3e4144;
  --accent: #1d9bf0; --accent-hover: #1a8cd8; --accent-soft: rgba(29, 155, 240, .12);
  --invert-bg: #eff3f4; --invert-text: #0f1419;
  --hover: rgba(231, 233, 234, .1); --hover-row: rgba(231, 233, 234, .03);
  --success: #00ba7c; --danger: #f4212e;
  --header-bg: rgba(0, 0, 0, .65);
  --muted-2: #8b98a5;                       /* серый на --surface-2, контраст ≥ 4.5 */
  --seg-thumb: #3e4144; --seg-thumb-shadow: none;
  --focus: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg: #fff; --surface: #f7f9f9; --surface-2: #eff3f4;
    --text: #0f1419; --muted: #536471; --faint: #8b98a5;
    --border: #e1e8ed; --border-strong: #cfd9de;
    --accent-soft: rgba(29, 155, 240, .08);
    --invert-bg: #0f1419; --invert-text: #fff;
    --hover: rgba(15, 20, 25, .1); --hover-row: rgba(0, 0, 0, .03);
    --header-bg: rgba(255, 255, 255, .85);
    --muted-2: #536471;
    --seg-thumb: #fff; --seg-thumb-shadow: 0 1px 2px rgba(15, 20, 25, .08), 0 0 0 1px #cfd9de;
  }
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #fff; --surface: #f7f9f9; --surface-2: #eff3f4;
  --text: #0f1419; --muted: #536471; --faint: #8b98a5;
  --border: #e1e8ed; --border-strong: #cfd9de;
  --accent-soft: rgba(29, 155, 240, .08);
  --invert-bg: #0f1419; --invert-text: #fff;
  --hover: rgba(15, 20, 25, .1); --hover-row: rgba(0, 0, 0, .03);
  --header-bg: rgba(255, 255, 255, .85);
  --muted-2: #536471;
  --seg-thumb: #fff; --seg-thumb-shadow: 0 1px 2px rgba(15, 20, 25, .08), 0 0 0 1px #cfd9de;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 400 var(--fs-base)/1.4 var(--font-ui); font-feature-settings: "kern";
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }
::selection { background: var(--accent); color: #fff; }
:focus { outline: none; }
:focus-visible { box-shadow: var(--focus); border-radius: var(--r-sm); }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-mono); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.wrap { width: 100%; max-width: 1040px; margin: 0 auto; padding: 0 20px; }
.col { max-width: 640px; }

/* ---------- шапка ---------- */
.top {
  position: sticky; top: 0; z-index: 10; background: var(--header-bg);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); border-bottom: 1px solid var(--border);
}
.top .wrap { display: flex; align-items: center; justify-content: space-between; height: 56px; }
.mark { display: inline-flex; align-items: baseline; gap: 1px; color: var(--text); font-weight: 800; font-size: 21px; letter-spacing: -0.04em; }
.mark:hover { text-decoration: none; }
.mark i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); display: inline-block; margin-left: 2px; }
.top nav { display: flex; gap: 4px; align-items: center; }
.top nav a { color: var(--text); font-weight: 500; font-size: var(--fs-base); padding: 0 14px; height: 36px; display: inline-flex; align-items: center; border-radius: var(--r-pill); }
.top nav a:hover { background: var(--hover); text-decoration: none; }
.top nav a.outline { box-shadow: inset 0 0 0 1px var(--border-strong); font-weight: 700; }
.top nav .icon { width: 36px; height: 36px; padding: 0; color: var(--muted); }
.top nav .icon:hover { color: var(--text); }
.top nav .icon svg { display: block; }

/* смена темы: плавный переход цветов (View Transitions, а где их нет — короткая CSS-анимация) */
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .35s; animation-timing-function: ease; }
html.theming, html.theming *, html.theming *::before, html.theming *::after {
  transition: background-color .3s ease, color .3s ease, border-color .3s ease, box-shadow .3s ease, fill .3s ease !important;
}

/* ---------- типографика ---------- */
h1, h2, h3, .lede { text-wrap: balance; }
h1 { font-size: var(--fs-h1); line-height: 1.04; letter-spacing: -0.035em; font-weight: 800; margin: 0; }
h2 { font-size: var(--fs-h2); line-height: 1.2; letter-spacing: -0.015em; font-weight: 700; margin: 0; }
h3 { font-size: var(--fs-lg); line-height: 1.3; font-weight: 700; margin: 0; }
.lede { font-size: var(--fs-lg); line-height: 1.45; color: var(--muted); margin: 16px 0 0; max-width: 32em; }
.label { font: 500 12px/1 var(--font-mono); letter-spacing: .02em; color: var(--muted); }
.muted { color: var(--muted); }

/* ---------- кнопки ---------- */
.btn {
  appearance: none; border: 0; cursor: pointer; font: 700 var(--fs-base)/1 var(--font-ui);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 20px; border-radius: var(--r-pill);
  background: var(--invert-bg); color: var(--invert-text);
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease), background var(--dur);
  white-space: nowrap; text-decoration: none;
}
.btn:hover { opacity: .9; text-decoration: none; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: default; transform: none; }
.btn[aria-busy="true"] { pointer-events: none; cursor: progress; }
.btn[aria-busy="true"] .spin { width: 16px; height: 16px; }
.btn.blue { background: var(--accent); color: #fff; }
.btn.blue:hover { background: var(--accent-hover); opacity: 1; }
.btn.outline { background: transparent; color: var(--text); box-shadow: inset 0 0 0 1px var(--border-strong); }
.btn.outline:hover { background: var(--hover); opacity: 1; }
.btn.text { background: transparent; color: var(--text); padding: 0 14px; }
.btn.text:hover { background: var(--hover); opacity: 1; }
.btn.sm { height: 32px; padding: 0 14px; font-size: var(--fs-sm); }
.btn.lg { height: 52px; padding: 0 28px; font-size: var(--fs-lg); }

/* ---------- поля ---------- */
.field {
  width: 100%; height: 52px; border: 1px solid transparent; border-radius: var(--r-field);
  background: var(--surface-2); color: var(--text); font: 400 var(--fs-lg) var(--font-ui); padding: 0 16px;
  transition: border-color var(--dur), background var(--dur);
}
.field::placeholder { color: var(--muted-2); }
.field:focus { background: var(--bg); border-color: var(--accent); }
.field:focus-visible { box-shadow: none; }

/* ---------- сегменты с бегунком ---------- */
.seg { position: relative; display: inline-flex; padding: 3px; background: var(--surface-2); border-radius: var(--r-pill); isolation: isolate; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg .thumb {
  position: absolute; z-index: -1; top: 3px; bottom: 3px; left: 0; border-radius: var(--r-pill);
  background: var(--seg-thumb); box-shadow: var(--seg-thumb-shadow);
  transition: transform .2s var(--ease), width .2s var(--ease);
}
.seg button {
  appearance: none; border: 0; background: transparent; color: var(--muted-2); cursor: pointer;
  font: 700 var(--fs-sm)/1 var(--font-ui); height: 34px; padding: 0 16px; border-radius: var(--r-pill);
  transition: color var(--dur); white-space: nowrap;
}
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"], .seg button[aria-selected="true"] { color: var(--text); }

/* ---------- табы как в X ---------- */
.tabs { display: flex; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  appearance: none; border: 0; background: transparent; cursor: pointer; color: var(--muted);
  font: 500 var(--fs-base) var(--font-ui); height: 52px; padding: 0 16px; position: relative; white-space: nowrap;
}
.tabs button:hover { background: var(--hover-row); color: var(--text); }
.tabs button[aria-selected="true"] { color: var(--text); font-weight: 700; }
.tabs button[aria-selected="true"]::after {
  content: ""; position: absolute; left: 50%; bottom: 0; transform: translateX(-50%);
  width: min(56px, calc(100% - 24px)); height: 4px; border-radius: var(--r-pill); background: var(--accent);
}

/* ---------- код ---------- */
.code { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); overflow: hidden; }
.code pre { margin: 0; padding: 18px 20px; overflow-x: auto; font: 400 13.5px/1.65 var(--font-mono); color: var(--text); white-space: pre; }
.code .c { color: var(--muted); }
.code .s { color: var(--accent); }
.code .copy { position: absolute; top: 10px; right: 10px; }

/* ---------- раскрывашки ---------- */
.faq { border-top: 1px solid var(--border); }
.faq details { border-bottom: 1px solid var(--border); }
.faq summary {
  list-style: none; cursor: pointer; padding: 18px 44px 18px 12px; margin: 0 -12px; position: relative;
  font-weight: 700; font-size: var(--fs-lg); border-radius: var(--r-sm); transition: background var(--dur);
}
.faq summary:hover { background: var(--hover-row); }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: ""; position: absolute; right: 16px; top: 50%; width: 8px; height: 8px; margin-top: -6px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg);
  transition: transform .28s var(--ease);
}
/* сдвиг и поворот — одним движением (раньше сдвиг через margin «прыгал» без анимации) */
.faq details[open] summary::after { transform: translateY(4px) rotate(-135deg); }
.faq details.closing summary::after { transform: rotate(45deg); }
.faq details p { margin: 0; padding-bottom: 20px; color: var(--muted); max-width: 40em; line-height: 1.55; }

/* ---------- подвал ---------- */
.foot { margin-top: 96px; border-top: 1px solid var(--border); }
.foot .wrap { padding-top: 24px; padding-bottom: 40px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; color: var(--muted); font-size: var(--fs-xs); }
.foot a { color: var(--muted); }
.foot .grow { flex: 1; }

/* ---------- мелочи ---------- */
.spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; flex-shrink: 0; }
@keyframes spin { to { transform: rotate(360deg); } }
.note-err { color: var(--danger); font-size: var(--fs-base); margin: 12px 4px 0; }
@keyframes shake { 20%, 60% { transform: translateX(-4px); } 40%, 80% { transform: translateX(4px); } }
.shake { animation: shake .3s; }

/* на сенсорных экранах hover «залипает» после касания — отключаем подсветку, оставляем нажатие */
@media (hover: none) {
  .btn:hover { opacity: 1; }
  .btn.text:hover, .btn.outline:hover, .top nav a:hover, .faq summary:hover, .tabs button:hover { background: transparent; }
  .btn.text:active, .btn.outline:active, .top nav a:active, .faq summary:active, .tabs button:active { background: var(--hover); }
}

@media (max-width: 640px) {
  .wrap { padding: 0 16px; }
  .foot a { padding: 8px 0; }
  .tabs { -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent); mask-image: linear-gradient(90deg, #000 85%, transparent); }
  .top nav a.hide-sm { display: none; }
}
/* «меньше анимации»: убираем движения (сдвиги, масштаб, тряску), плавные появления оставляем — они не укачивают */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .shake { animation: none; }
  .btn:active { transform: none; }
  .spin { animation-duration: 1.4s; }
}

/* «Как скачать» и ссылки на страницы платформ */
.howto { margin-top: 88px; }
.howto h2 { margin-bottom: 20px; }
.steps { list-style: none; margin: 0; padding: 0; counter-reset: step; display: grid; gap: 14px; }
.steps li { counter-increment: step; display: grid; grid-template-columns: 32px 1fr; gap: 14px; align-items: baseline;
  font-size: var(--fs-lg); line-height: 1.45; }
.steps li::before { content: counter(step); font: 500 var(--fs-sm)/32px var(--font-mono); color: var(--accent);
  width: 32px; height: 32px; text-align: center; border-radius: var(--r-pill); background: var(--accent-soft); }
.howto .about { margin: 20px 0 0 46px; color: var(--muted); line-height: 1.55; max-width: 40em; }
.plats { margin-top: 28px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.plats span { color: var(--muted); font-size: var(--fs-sm); margin-right: 4px; }
.plats a { height: 32px; padding: 0 14px; display: inline-flex; align-items: center; border: 1px solid var(--border);
  border-radius: var(--r-pill); color: var(--text); font-size: var(--fs-sm); font-weight: 500;
  transition: background var(--dur), border-color var(--dur); }
.plats a:hover { background: var(--hover-row); border-color: var(--border-strong); }
.plats a[aria-current="page"] { border-color: var(--accent); color: var(--accent); }
@media (max-width: 560px) {
  .howto { margin-top: 64px; }
  .steps li { font-size: var(--fs-base); grid-template-columns: 28px 1fr; gap: 12px; }
  .steps li::before { width: 28px; height: 28px; line-height: 28px; }
  .howto .about { margin-left: 0; }
}
