/* Черемша — site styles. System fonts only: no third-party requests. */

/* Light theme: white page, black text, green only for accents. */
:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f5f5f5;
  --border: #e5e5e5;
  --text: #0a0a0a;
  --muted: #555555;
  --accent: #1f5134;
  --accent-hover: #163d27;
  --accent-soft: #eef5f0;
  --accent-text: #ffffff;
  --link: #1f6b3f;
  --focus: #2f8a52;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --topbar-h: 56px;
  --radius: 8px;
  color-scheme: light;
}

/* Dark theme: follows the system unless the visitor picked a theme (html[data-theme]). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0c0c;
    --surface: #111312;
    --surface-2: #1a1d1b;
    --border: #2a2e2c;
    --text: #ededed;
    --muted: #a3a3a3;
    --accent: #6cc28a;
    --accent-hover: #86d19f;
    --accent-soft: #15241b;
    --accent-text: #0b130e;
    --link: #7fd09b;
    --focus: #7fd09b;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b0c0c;
  --surface: #111312;
  --surface-2: #1a1d1b;
  --border: #2a2e2c;
  --text: #ededed;
  --muted: #a3a3a3;
  --accent: #6cc28a;
  --accent-hover: #86d19f;
  --accent-soft: #15241b;
  --accent-text: #0b130e;
  --link: #7fd09b;
  --focus: #7fd09b;
  color-scheme: dark;
}

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

html { scroll-behavior: smooth; scroll-padding-top: calc(var(--topbar-h) + 16px); }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--link); text-underline-offset: 2px; }
code { font-family: var(--mono); font-size: 0.9em; }
:not(pre) > code:not(.codebox code) {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0.05em 0.35em;
}
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

.skip {
  position: absolute; left: -999px; top: 8px;
  background: var(--surface); padding: 8px 12px; z-index: 100;
}
.skip:focus { left: 8px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: 500 14px/1.3 var(--font);
  text-decoration: none;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--surface-2); }
.btn--accent { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn--accent:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn--small { padding: 6px 12px; font-size: 13px; }

.icon-btn {
  flex: none;
  display: inline-grid; place-items: center;
  width: 32px; height: 32px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}
.icon-btn:hover { color: var(--text); background: var(--surface-2); }
.icon-btn svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn.is-done { color: var(--accent); border-color: var(--accent); }

.chip {
  display: inline-block;
  padding: 1px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  font: 500 12px/1.6 var(--mono);
  color: var(--muted);
  vertical-align: middle;
}
.chip--muted { font-family: var(--font); font-weight: 500; }
.chip--accent { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

/* Theme switch: shows the sun in dark mode, the moon in light mode */
.theme-btn { width: 32px; height: 32px; }
.theme-btn .i-sun { display: none; }
:root[data-theme="dark"] .theme-btn .i-sun { display: block; }
:root[data-theme="dark"] .theme-btn .i-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .theme-btn .i-sun { display: block; }
  :root:not([data-theme]) .theme-btn .i-moon { display: none; }
}

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  height: var(--topbar-h);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar__inner {
  height: 100%;
  max-width: 1320px; margin: 0 auto;
  padding: 0 20px;
  display: flex; align-items: center; gap: 20px;
}
.brand {
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--text); text-decoration: none;
  font-weight: 700; font-size: 17px; letter-spacing: -0.01em;
}
.topnav { display: flex; gap: 20px; margin-left: auto; }
.topnav a { color: var(--muted); text-decoration: none; font-size: 14px; }
.topnav a:hover { color: var(--text); }
.menu-btn {
  display: none;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: 8px; padding: 5px 10px; font: 500 13px var(--font); cursor: pointer;
}

/* ---------- Layout ---------- */
.layout {
  max-width: 1320px; margin: 0 auto;
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr) 210px;
}

.sidebar {
  position: sticky; top: var(--topbar-h);
  align-self: start;
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  padding: 24px 16px 40px 20px;
  border-right: 1px solid var(--border);
}
.sidebar__group {
  margin: 18px 0 6px;
  font: 500 12px/1.4 var(--mono);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.sidebar__group:first-child { margin-top: 0; }
.sidebar a, .toc a {
  display: block;
  padding: 5px 10px;
  border-radius: 7px;
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  line-height: 1.4;
}
.sidebar a:hover, .toc a:hover { color: var(--text); background: var(--surface-2); }
.sidebar a.is-active { color: var(--text); background: var(--surface-2); font-weight: 600; }

.toc {
  position: sticky; top: var(--topbar-h);
  align-self: start;
  padding: 28px 20px 40px 12px;
}
.toc__title { margin: 0 0 8px 10px; font-size: 13px; font-weight: 600; }
.toc a { font-size: 13px; padding: 3px 10px; border-left: 2px solid transparent; border-radius: 0; }
.toc a.is-active { color: var(--text); border-left-color: var(--accent); background: none; }

/* ---------- Article ---------- */
.article {
  min-width: 0;
  max-width: 780px;
  width: 100%;
  margin: 0 auto;
  padding: 40px 32px 0;
}
.article section { padding-bottom: 40px; }
.article section + section { border-top: 1px solid var(--border); padding-top: 36px; }

.meta { margin: 0 0 14px; color: var(--muted); font: 13px/1.5 var(--mono); }
.meta .chip { margin-right: 6px; }

h1 {
  display: flex; align-items: center; gap: 14px;
  margin: 0 0 8px;
  font-size: clamp(32px, 5vw, 44px);
  line-height: 1.1;
  letter-spacing: -0.025em;
}
h1 img { border-radius: 9px; flex: none; }
.subtitle { margin: 0 0 22px; font-size: 19px; color: var(--muted); max-width: 40em; }

h2 { margin: 0 0 12px; font-size: 26px; line-height: 1.25; letter-spacing: -0.015em; }
h3 { margin: 0 0 4px; font-size: 17px; line-height: 1.3; }
.article p { margin: 0 0 14px; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 28px; }

/* Install box */
.install {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px 6px;
  margin-bottom: 28px;
}
.install__label { margin: 0 0 8px !important; font: 500 13px/1.4 var(--mono); color: var(--muted); }
.install__note { font-size: 13px; color: var(--muted); margin: 8px 0 18px !important; }

.codebox {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 8px 8px 14px;
}
.codebox code {
  flex: 1; min-width: 0;
  font-size: 14px;
  overflow-wrap: anywhere;
  padding: 4px 0;
}
.prompt { font-family: var(--mono); color: var(--muted); user-select: none; }

/* Stats */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  margin: 0;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.stats div { background: var(--surface); padding: 14px 16px; }
.stats dt { font-size: 13px; color: var(--muted); }
.stats dd { margin: 2px 0 0; font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }

/* Steps */
.steps { margin: 0; padding-left: 1.3em; }
.steps li { margin-bottom: 10px; padding-left: 4px; }
.steps li::marker { color: var(--accent); font-weight: 700; }

/* Tabs */
.tabs {
  display: flex; gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-top: 18px;
  overflow-x: auto;
}
.tab {
  padding: 9px 14px;
  border: 0; border-bottom: 2px solid transparent;
  background: none;
  color: var(--muted);
  font: 500 14px var(--font);
  cursor: pointer;
  white-space: nowrap;
  margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.panel { padding: 18px 0 0; }
.panel .codebox { margin-bottom: 14px; }
.panel__intro { color: var(--muted); }
.howto { margin: 0 0 12px; padding-left: 1.3em; }
.howto li { margin-bottom: 8px; padding-left: 4px; }
.note {
  font-size: 14px;
  color: var(--muted);
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  padding: 10px 14px;
  border-radius: 0 8px 8px 0;
}

/* Cards */
.bases { display: grid; gap: 14px; margin-top: 18px; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.card h3 { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.card__meta { font: 13px/1.5 var(--mono); color: var(--muted); margin-bottom: 12px !important; }
.card__note { font-size: 14px; color: var(--muted); margin: 12px 0 0 !important; }
.kv { list-style: none; margin: 0 0 14px; padding: 0; }
.kv:last-of-type { margin-bottom: 0; }
.kv--cols { columns: 2; column-gap: 28px; }
.card__sub { margin: 4px 0 2px !important; font: 500 12px/1.4 var(--mono); color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.kv .soon { color: var(--muted); font-weight: 500; }
.kv li {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  break-inside: avoid;
}
.kv b { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }

/* Examples: question → what the AI finds → source */
.examples { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.examples li {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 15px;
}
.ex__q { margin: 0 0 8px !important; font-weight: 600; }
.ex__a { margin: 0 0 8px !important; color: var(--muted); }
.ex__src { margin: 0 !important; font-size: 13px; }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); margin-bottom: 14px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; vertical-align: top; padding: 10px 14px; border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: 0; }
th { font-weight: 600; background: var(--surface-2); }
td:first-child { white-space: nowrap; }

/* FAQ */
.faq details {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  margin-bottom: 8px;
}
.faq summary {
  cursor: pointer;
  padding: 12px 16px;
  font-weight: 600;
  list-style: none;
  display: flex; justify-content: space-between; gap: 12px;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; color: var(--muted); font-weight: 400; }
.faq details[open] summary::after { content: "−"; }
.faq details p { padding: 0 16px 4px; color: var(--muted); }

.plain { padding-left: 1.2em; margin: 0; }
.plain li { margin-bottom: 8px; }

.footer { padding: 24px 0 40px; border-top: 1px solid var(--border); color: var(--muted); font-size: 13px; }
.footer p { margin: 0 0 6px !important; }
.footer a { color: var(--muted); }
.footer a:hover { color: var(--text); }

/* Legal pages (policy, terms) */
.doc { max-width: 760px; margin: 0 auto; padding: 40px 20px 0; }
.doc h1 { font-size: 32px; }
.doc h2 { font-size: 20px; margin-top: 28px; }
.doc p, .doc li { margin: 0 0 10px; }
.placeholder { background: #fff3bf; color: #5c4400; padding: 0 4px; border-radius: 3px; }
:root[data-theme="dark"] .placeholder { background: #4a3b00; color: #ffe28a; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .placeholder { background: #4a3b00; color: #ffe28a; }
}

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 24px;
  transform: translate(-50%, 20px);
  background: var(--text); color: var(--bg);
  padding: 8px 16px; border-radius: 8px;
  font-size: 14px;
  opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 50;
}
.toast.is-shown { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .layout { grid-template-columns: 220px minmax(0, 1fr); }
  .toc { display: none; }
}

@media (max-width: 860px) {
  .layout { display: block; }
  .menu-btn { display: inline-block; }
  .topnav { display: none; }
  .topbar__inner { gap: 12px; padding: 0 16px; }
  .topbar .btn { margin-left: auto; }
  .sidebar {
    display: none;
    position: fixed; inset: var(--topbar-h) 0 0 0;
    height: auto;
    z-index: 15;
    background: var(--bg);
    border-right: 0;
    padding: 16px;
  }
  .sidebar.is-open { display: block; }
  .article { padding: 28px 16px 0; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .kv { columns: 1; }
}

@media (max-width: 560px) {
  /* Stack table rows: name on top, description below */
  .table-wrap thead { display: none; }
  .table-wrap tr { display: block; padding: 10px 0; border-bottom: 1px solid var(--border); }
  .table-wrap tr:last-child { border-bottom: 0; }
  .table-wrap td { display: block; border: 0; padding: 2px 14px; }
  .table-wrap td:first-child { padding-bottom: 6px; }
}

@media (max-width: 420px) {
  .brand span { display: none; }
  .subtitle { font-size: 17px; }
}
