:root {
  --bg: #ffffff;
  --bg-soft: #f7f8fa;
  --bg-code: #1c2128;
  --border: #e4e7ec;
  --border-strong: #d0d5dd;
  --text: #1a2027;
  --text-soft: #4a5462;
  --text-muted: #8a93a2;
  --accent: #2563c4;
  --accent-soft: #eaf1fc;
  --sidebar-w: 280px;
  --header-h: 60px;
  --radius: 8px;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--text);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---------- Header ---------- */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-h);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 50;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  font-weight: 600;
  font-size: 16px;
  letter-spacing: -0.01em;
}

.brand .logo {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: linear-gradient(135deg, #2563c4, #4f8be0);
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
}

.brand .tag {
  color: var(--text-muted);
  font-weight: 400;
  font-size: 13px;
  padding-left: 11px;
  margin-left: 4px;
  border-left: 1px solid var(--border-strong);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

/* ---------- Language switch ---------- */
.lang-switch {
  display: inline-flex;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 2px;
}

.lang-switch button {
  border: none;
  background: transparent;
  color: var(--text-soft);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease;
}

.lang-switch button:hover { color: var(--text); }

.lang-switch button.active {
  background: var(--bg);
  color: var(--accent);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.08);
}

/* ---------- Mobile nav toggle ---------- */
.nav-toggle {
  display: none;
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: 7px;
  width: 38px;
  height: 34px;
  cursor: pointer;
  color: var(--text-soft);
  align-items: center;
  justify-content: center;
}
.nav-toggle svg { width: 18px; height: 18px; }

/* ---------- Layout ---------- */
.layout {
  display: flex;
  padding-top: var(--header-h);
  max-width: 1320px;
  margin: 0 auto;
}

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  position: sticky;
  top: var(--header-h);
  align-self: flex-start;
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  padding: 28px 16px 60px 24px;
  border-right: 1px solid var(--border);
}

.sidebar nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-group-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 700;
  color: var(--text-muted);
  margin: 22px 0 8px 10px;
}
.nav-group-title:first-child { margin-top: 0; }

.sidebar nav a {
  display: block;
  padding: 6px 10px;
  border-radius: 6px;
  color: var(--text-soft);
  text-decoration: none;
  font-size: 14px;
  line-height: 1.4;
  transition: background 0.15s ease, color 0.15s ease;
}

.sidebar nav a:hover {
  background: var(--bg-soft);
  color: var(--text);
}

.sidebar nav a.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

/* ---------- Content ---------- */
.content {
  flex: 1;
  min-width: 0;
  padding: 40px 56px 120px;
}

.content-inner { max-width: 760px; }

section.doc-section {
  scroll-margin-top: calc(var(--header-h) + 20px);
  padding-bottom: 26px;
  margin-bottom: 26px;
  border-bottom: 1px solid var(--border);
}
section.doc-section:last-child { border-bottom: none; }

h1 {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 8px;
}
h2 {
  font-size: 23px;
  font-weight: 650;
  letter-spacing: -0.015em;
  margin: 8px 0 14px;
  scroll-margin-top: calc(var(--header-h) + 20px);
}
h3 {
  font-size: 17px;
  font-weight: 650;
  margin: 26px 0 10px;
}

p { margin: 0 0 14px; color: var(--text-soft); }
.content-inner > section > p:first-of-type { color: var(--text); }

a { color: var(--accent); }

strong { color: var(--text); font-weight: 600; }

ul.bullets, ol.steps {
  margin: 0 0 16px;
  padding-left: 22px;
  color: var(--text-soft);
}
ul.bullets li, ol.steps li { margin-bottom: 7px; }
ol.steps { counter-reset: step; }

code.inline {
  font-family: var(--mono);
  font-size: 0.86em;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1.5px 6px;
  color: #b3216b;
  white-space: nowrap;
}

.lead {
  font-size: 17px;
  line-height: 1.6;
  color: var(--text-soft);
}

.note {
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin: 0 0 18px;
  font-size: 14px;
  color: var(--text-soft);
}
.note.warn {
  border-left-color: #d9920a;
  background: #fdf6e8;
}
.note strong { display: block; margin-bottom: 2px; }

/* ---------- Tables ---------- */
.field-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 18px;
  font-size: 14px;
}
.field-table th, .field-table td {
  text-align: left;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.field-table th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  font-weight: 700;
  background: var(--bg-soft);
}
.field-table td:first-child {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--accent);
  white-space: nowrap;
}
.field-table td.t { color: var(--text-muted); font-family: var(--mono); font-size: 12.5px; }

/* ---------- Code blocks ---------- */
.code-block {
  position: relative;
  margin: 0 0 18px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid #2b3138;
  background: var(--bg-code);
}

.code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 12px 7px 14px;
  background: #161a20;
  border-bottom: 1px solid #2b3138;
}
.code-lang {
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #7d8896;
}
.copy-btn {
  border: 1px solid #2b3138;
  background: #20262e;
  color: #9aa4b2;
  font-family: var(--sans);
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.copy-btn:hover { background: #2b333d; color: #d6dce4; }
.copy-btn.copied { color: #6fd08c; border-color: #2e5a3a; }

pre {
  margin: 0;
  padding: 16px 18px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.6;
  color: #d6dce4;
  tab-size: 2;
}
pre code { font-family: inherit; white-space: pre; }

/* Code tabs (lang variants inside one block) */
.code-tabs { margin: 0 0 18px; }
.tab-row {
  display: flex;
  gap: 4px;
  background: #161a20;
  border: 1px solid #2b3138;
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 6px 6px 0;
}
.tab-row button {
  border: none;
  background: transparent;
  color: #7d8896;
  font-family: var(--mono);
  font-size: 12.5px;
  padding: 7px 14px;
  border-radius: 6px 6px 0 0;
  cursor: pointer;
}
.tab-row button.active { background: var(--bg-code); color: #d6dce4; }
.code-tabs .code-block { border-radius: 0 0 var(--radius) var(--radius); margin: 0; }
.code-tabs .tab-pane { display: none; }
.code-tabs .tab-pane.active { display: block; }

/* ---------- Syntax highlight tokens ---------- */
.tok-key   { color: #79b8ff; }
.tok-str   { color: #9ecb7e; }
.tok-num   { color: #f0a35e; }
.tok-bool  { color: #d98fe0; }
.tok-null  { color: #d98fe0; }
.tok-punc  { color: #8895a3; }
.tok-kw    { color: #d98fe0; }
.tok-fn    { color: #79b8ff; }
.tok-com   { color: #6a7480; font-style: italic; }
.tok-prop  { color: #9cdcfe; }

/* ---------- Language visibility ---------- */
[data-lang-en], [data-lang-ru] { display: none; }
body.lang-en [data-lang-en] { display: revert; }
body.lang-ru [data-lang-ru] { display: revert; }
/* block-level elements that should be block when shown */
body.lang-en section[data-lang-en],
body.lang-ru section[data-lang-ru] { display: block; }

.footer {
  margin-top: 50px;
  padding-top: 22px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-muted);
}

/* ---------- Responsive ---------- */
.backdrop { display: none; }

@media (max-width: 960px) {
  .content { padding: 32px 28px 100px; }
  .nav-toggle { display: inline-flex; }
  .brand .tag { display: none; }

  .sidebar {
    position: fixed;
    top: var(--header-h);
    left: 0;
    bottom: 0;
    height: auto;
    width: 290px;
    background: var(--bg);
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 40;
    box-shadow: 2px 0 16px rgba(16, 24, 40, 0.12);
  }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open .backdrop {
    display: block;
    position: fixed;
    inset: var(--header-h) 0 0 0;
    background: rgba(16, 24, 40, 0.35);
    z-index: 35;
  }
}

@media (max-width: 560px) {
  .content { padding: 24px 18px 90px; }
  h1 { font-size: 25px; }
  h2 { font-size: 20px; }
  .site-header { padding: 0 14px; }
}
