/* Документация API (/docs): те же токены, что у сайта (styles.css), статическая страница без React */
:root {
  --bg: #F5F5F0; --surface: #ffffff; --surface-2: #ecece6; --border: #e3e3dd; --border-strong: #cfcfc8;
  --text: #0B0B0C; --text-2: #5f5f5a; --text-3: #9a9a94;
  --accent: #D7FF00; --accent-text: #0B0B0C; --accent-ink: #5a6b00; --accent-tint: #f1ffb3;
  --code-bg: #0f0f10; --code-text: #e8e8e2; --code-bar: #18181a;
  --t-s: #c3e88d; --t-k: #D7FF00; --t-n: #f78c6c; --t-b: #89ddff; --t-c: #6a6a66; --t-kw: #c792ea; --t-f: #82aaff; --t-v: #ffcb6b;
  --get: #1f9d55; --post: #3b6fe0; --delete: #e5484d;
  --r: 14px; --r-ctl: 10px; --font: 'Geologica', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: light;
}
:root[data-theme='dark'] {
  --bg: #0b0e15; --surface: #121725; --surface-2: #1a2132; --border: #1f2738; --border-strong: #30394f;
  --text: #eef1f7; --text-2: #a3abbb; --text-3: #6f798b;
  --accent-ink: #D7FF00; --accent-tint: rgba(215, 255, 0, 0.1);
  --code-bg: #0f1320; --code-bar: #151b2a;
  --get: #5fe08a; --post: #7aa2ff; --delete: #ff7a7f;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 84px; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.65 var(--font); -webkit-font-smoothing: antialiased; }
/* Фон «блокчейн-сеть» (docs/bg.js) — как в приложении; контент поверх него */
.bc-layer { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.bc-layer canvas { position: absolute; left: 0; top: 0; }
.top, .layout, main.doc, .doc-foot { position: relative; z-index: 1; }
/* Текст лежит на полупрозрачной карточке с блюром (как карточки приложения), иначе линии сети мешают читать */
.layout .doc, main.doc.page, .toc > details { background: color-mix(in srgb, var(--bg) 84%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border: 1px solid var(--border); border-radius: 20px; }
.layout .doc { padding: 36px 40px 64px; margin: 28px 0 40px; }
.toc > details { padding: 18px 16px; margin-top: 28px; }
main.doc.page { margin: 28px auto 48px; padding: 36px 40px 48px; }
@media (max-width: 920px) { .layout .doc { padding: 24px 18px 40px; margin: 16px 0 24px; } main.doc.page { padding: 24px 18px 36px; margin: 12px auto 24px; } }
a { color: inherit; }
::selection { background: var(--accent); color: #0B0B0C; }

/* ---------- Шапка — та же, что в приложении (styles.css .header): логотип с бейджем, пилюли разделов,
   справа пилюля языка, круглая кнопка темы и жёлтая кнопка-действие ---------- */
.top {
  position: sticky; top: 0; z-index: 10; height: 72px; padding: 0 20px;
  display: flex; align-items: center; gap: 12px;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-weight: 700; font-size: 18px; letter-spacing: -0.01em; margin-inline-end: 8px; }
.brand svg { width: 30px; height: 30px; border-radius: 9px; }
.brand svg.wordmark { width: auto; height: 24px; margin-top: 2px; border-radius: 0; }
.logo-bg { fill: #0B0B0C; }
.logo-a { fill: #D7FF00; }
.logo-b { fill: #A8C800; }
.logo-c { fill: #C4E800; }
.tag { align-self: flex-start; margin-top: 1px; margin-inline-start: -6px; font-size: 8px; font-weight: 800; letter-spacing: 0.06em; color: var(--accent-ink); border: 1px solid var(--accent-ink); border-radius: 4px; padding: 0 3px; line-height: 1.4; }
.top-links { display: flex; align-items: center; gap: 2px; }
.top-links a { text-decoration: none; color: var(--text-2); font-size: 15px; font-weight: 500; padding: 8px 12px; border-radius: var(--r-ctl); transition: color .15s, background .15s; }
.top-links a:hover { color: var(--text); background: var(--surface-2); }
/* Активный раздел — нейтральная плашка с рамкой, как .nav-pill в приложении; жёлтый остаётся только у кнопки-действия */
.top-links a.active { color: var(--text); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--border-strong); }
.top-right { margin-inline-start: auto; display: flex; align-items: center; gap: 8px; }
.pill { display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px 0 8px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-ctl); color: var(--text); font-size: 14px; font-weight: 600; text-decoration: none; transition: border-color .15s, background .15s; }
.pill:hover { border-color: var(--border-strong); background: var(--surface-2); }
.pill .ico { width: 22px; height: 22px; display: grid; place-items: center; color: var(--text-2); }
.pill .ico svg { width: 18px; height: 18px; }
.pill .chev { width: 10px; height: 6px; color: var(--text-2); }
.btn-app { display: inline-flex; align-items: center; height: 40px; padding: 0 16px; border-radius: var(--r-ctl); background: var(--accent); color: var(--accent-text); font-size: 15px; font-weight: 600; text-decoration: none; border: 1px solid var(--accent); transition: background .15s; }
.btn-app:hover { background: #c9ef00; border-color: #c9ef00; }
:root[data-theme='dark'] .btn-app:hover { background: #e6ff4d; border-color: #e6ff4d; }
.theme { width: 40px; height: 40px; border-radius: var(--r-ctl); border: 1px solid var(--border); background: var(--surface); color: var(--text-2); display: grid; place-items: center; cursor: pointer; padding: 0; transition: border-color .15s, color .15s; }
.theme:hover { border-color: var(--border-strong); color: var(--text); }
.theme svg { width: 18px; height: 18px; }
:root[data-theme='dark'] .moon, :root:not([data-theme='dark']) .sun { display: none; }
/* Меню языков — как LanguageMenu в приложении: пилюля с глобусом, список на родных названиях */
.lang { position: relative; }
.lang-code { white-space: nowrap; }
.pill.open { border-color: var(--border-strong); }
.pill.open .chev { transform: rotate(180deg); }
.pop {
  position: absolute; top: calc(100% + 8px); inset-inline-end: 0; z-index: 60; min-width: 360px; padding: 8px;
  background: var(--bg); border: 1px solid var(--border-strong); border-radius: var(--r); box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}
.pop[hidden] { display: none; }
.pop-title { font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-3); padding: 6px 10px 8px; }
.lang-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; }
.lang-grid .item { display: flex; align-items: center; gap: 10px; width: 100%; background: none; border: 0; padding: 9px 12px; border-radius: var(--r-ctl); color: var(--text); font: inherit; font-size: 14px; font-weight: 600; text-align: start; cursor: pointer; }
.lang-grid .item:hover { background: var(--surface-2); }
.lang-grid .item.on { background: var(--accent-tint); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 55%, transparent); color: var(--accent-ink); }
.lang-grid .item .check { width: 16px; height: 16px; margin-inline-start: auto; color: var(--accent-ink); flex-shrink: 0; }
/* Плашка «переведено автоматически» и состояние перевода */
.tr-note { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; margin: 0 0 18px; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface); color: var(--text-2); font-size: 13.5px; }
.tr-note a { color: var(--accent-ink); text-decoration: none; border-bottom: 1px dashed var(--accent-ink); }
body.translating .doc, body.translating .toc { opacity: 0.55; transition: opacity 0.2s; }
/* Узкий экран: разделы не прячем, а переносим второй строкой под шапку (раньше на телефоне меню не было вовсе) */
@media (max-width: 860px) {
  .top { flex-wrap: wrap; height: auto; padding-top: 12px; padding-bottom: 8px; row-gap: 8px; }
  .top-links { order: 3; width: 100%; overflow-x: auto; scrollbar-width: none; gap: 4px; }
  .top-links::-webkit-scrollbar { display: none; }
  .top-links a { white-space: nowrap; font-size: 14px; padding: 6px 12px; border: 1px solid var(--border); border-radius: var(--r-ctl); }
  .top-links a.active { border-color: var(--border-strong); }
}
@media (max-width: 520px) {
  .brand svg.wordmark, .tag, .pill .lang-code { display: none; } .pill { padding-inline-end: 8px; } .btn-app { padding: 0 12px; font-size: 14px; }
  .pop { position: fixed; left: 12px; right: 12px; top: 80px; min-width: 0; } .lang-grid { grid-template-columns: 1fr; }
}

/* ---------- Каркас ---------- */
.layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 48px; max-width: 1180px; margin: 0 auto; padding: 0 24px; }
.toc { position: sticky; top: 64px; align-self: start; max-height: calc(100vh - 64px); overflow-y: auto; padding: 32px 0 40px; }
.toc summary { display: none; }
.toc ul { list-style: none; margin: 0; padding: 0; }
.toc > details > ul > li { margin-bottom: 14px; }
.toc > details > ul > li > a { font-weight: 600; font-size: 14px; color: var(--text); }
.toc li ul { margin-top: 6px; padding-left: 10px; border-left: 1px solid var(--border); }
.toc li ul a { font-size: 13px; color: var(--text-2); }
.toc a { display: block; text-decoration: none; padding: 3px 8px; border-radius: 8px; line-height: 1.4; }
.toc a:hover { color: var(--text); background: var(--surface-2); }
/* Текущий раздел оглавления — нейтральная плашка, без жёлтой заливки */
.toc a.on { color: var(--text) !important; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--border-strong); }
/* Под оглавлением — файлы для моделей и инструментов (раньше были пунктами в шапке) */
.toc-files { margin-top: 12px; padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; background: color-mix(in srgb, var(--bg) 84%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border: 1px solid var(--border); border-radius: 20px; }
.toc-files-title { font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-3); padding: 0 8px 6px; }
.toc-files a { font-size: 13px; color: var(--text-2); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.toc .m { font-size: 9px; padding: 1px 4px; margin-right: 4px; vertical-align: 1px; }
.toc a.on .m { background: rgba(0,0,0,0.15); color: inherit; }
.toc code.path { font-size: 12px; background: none; padding: 0; color: inherit; }

/* ---------- Текст ---------- */
.doc { min-width: 0; max-width: 800px; padding: 40px 0 80px; }
.doc h1 { font-size: 48px; line-height: 1.05; letter-spacing: -0.035em; margin: 8px 0 20px; font-weight: 700; }
.doc h1 + p { font-size: 19px; color: var(--text-2); line-height: 1.6; }
.doc h2 { font-size: 30px; letter-spacing: -0.02em; line-height: 1.2; margin: 64px 0 16px; padding-top: 32px; border-top: 1px solid var(--border); font-weight: 650; }
.doc h3 { font-size: 20px; letter-spacing: -0.01em; margin: 40px 0 12px; font-weight: 650; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.doc h2, .doc h3 { position: relative; }
.anchor { position: absolute; left: -24px; color: var(--text-3); text-decoration: none; opacity: 0; font-weight: 400; transition: opacity .15s; }
.doc h2 .anchor { top: 32px; }
.doc h2:hover .anchor, .doc h3:hover .anchor { opacity: 1; }
.doc p, .doc li { color: var(--text-2); }
.doc strong { color: var(--text); font-weight: 600; }
.doc a { color: var(--text); text-decoration: underline; text-decoration-color: var(--accent-ink); text-decoration-thickness: 2px; text-underline-offset: 3px; }
.doc a:hover { color: var(--accent-ink); }
.doc ul, .doc ol { padding-left: 22px; }
.doc li { margin: 6px 0; }
.doc li::marker { color: var(--text-3); }
/* Инлайн-код переносится: длинный вызов вроде swap(owner, …) иначе растягивал страницу на телефоне */
.doc :not(pre) > code { font-family: var(--mono); font-size: 0.86em; background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 1px 6px; color: var(--text); white-space: normal; overflow-wrap: anywhere; }
.doc h3 code.path { font-size: 19px; background: none; border: 0; padding: 0; }

/* Метки методов */
.m { font: 700 11px/1 var(--mono); letter-spacing: 0.04em; border-radius: 6px; padding: 5px 7px; color: #fff; }
.m-get { background: var(--get); }
.m-post { background: var(--post); }
.m-delete { background: var(--delete); }
:root[data-theme='dark'] .m { color: #0B0B0C; }

/* Выноска */
.callout { margin: 24px 0; padding: 16px 20px; border-radius: var(--r); background: var(--accent-tint); border: 1px solid color-mix(in srgb, var(--accent-ink) 35%, transparent); }
.callout p { margin: 0; color: var(--text); }
.callout p + p { margin-top: 8px; }

/* Таблицы */
.table { overflow-x: auto; margin: 20px 0; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface); }
.doc table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.doc th { text-align: left; font-weight: 600; color: var(--text); background: var(--surface-2); padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.doc td { padding: 10px 14px; border-top: 1px solid var(--border); color: var(--text-2); vertical-align: top; }
.doc tbody tr:first-child td { border-top: 0; }
.doc td:first-child { color: var(--text); white-space: nowrap; }
.doc td code { white-space: nowrap; }

/* Код */
.code { margin: 20px 0; border-radius: var(--r); overflow: hidden; background: var(--code-bg); border: 1px solid #1f2738; }
.code-bar { display: flex; justify-content: space-between; align-items: center; padding: 6px 8px 6px 16px; background: var(--code-bar); border-bottom: 1px solid #1f2738; }
.code-bar span { font: 500 12px var(--mono); color: #8e97a8; text-transform: lowercase; }
.copy { font: 600 12px var(--font); color: #cfd5e1; background: #232c40; border: 1px solid #30394f; border-radius: 8px; padding: 4px 10px; cursor: pointer; }
.copy:hover { color: #0B0B0C; background: var(--accent); border-color: var(--accent); }
.copy.done { color: #0B0B0C; background: var(--accent); }
.code pre { margin: 0; padding: 16px 18px; overflow-x: auto; }
/* Блоки без языка и любой другой pre: тоже скроллятся внутри себя, а не растягивают страницу */
.doc pre { max-width: 100%; overflow-x: auto; }
.doc pre > code { white-space: pre; }
.code code { font: 13.5px/1.65 var(--mono); color: var(--code-text); white-space: pre; tab-size: 2; }
.t-s { color: var(--t-s); } .t-k { color: var(--t-k); } .t-n { color: var(--t-n); } .t-b { color: var(--t-b); }
.t-c { color: var(--t-c); font-style: italic; } .t-kw { color: var(--t-kw); } .t-f { color: var(--t-f); } .t-v { color: var(--t-v); }

.doc-foot { margin-top: 72px; padding-top: 24px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 13px; color: var(--text-3); }
.doc-foot span { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.doc-foot span.foot-meta { display: block; }
.doc-foot a { color: var(--text-2); text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 3px; }
.doc-foot a:hover { color: var(--text); }

/* ---------- Узкие экраны ---------- */
@media (max-width: 920px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 0; padding: 0 16px; }
  .toc { position: static; max-height: none; padding: 16px 0 0; }
  .toc summary { display: flex; justify-content: space-between; align-items: center; cursor: pointer; font-weight: 600; font-size: 15px; padding: 12px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-ctl); list-style: none; }
  .toc summary::-webkit-details-marker { display: none; }
  .toc summary::after { content: '+'; color: var(--text-3); font-size: 20px; font-weight: 400; }
  .toc details[open] summary::after { content: '–'; }
  .toc details > ul { padding: 12px 8px 4px; }
  .doc { padding-top: 24px; }
  .doc h1 { font-size: 36px; }
  .doc h2 { font-size: 25px; margin-top: 48px; }
  .anchor { display: none; }
  .top { padding-inline: 16px; }
}
@media (max-width: 420px) {
  .doc h1 { font-size: 32px; }
  .doc h1 + p { font-size: 17px; }
  .code code { font-size: 12.5px; }
  .doc :not(pre) > code { white-space: normal; word-break: break-word; }
}
