/* ===== Руководство пользователя (/guide) — самодостаточные стили ===== */
:root {
  --g-brand: #3b2a22;
  --g-accent: #7a5a48;
  --g-accent-strong: #5a3f31;
  --g-bg: #f6f5f3;
  --g-surface: #ffffff;
  --g-border: #e7e3df;
  --g-text: #2a2421;
  --g-text-soft: #6b635c;
  --g-text-mute: #968d85;
  --g-code-bg: #f1efec;
  --g-hit: #ffe39c;
  --g-radius: 12px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  color: var(--g-text);
  background: var(--g-bg);
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

/* ── Верхняя панель ── */
.g-topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 16px;
  height: 60px; padding: 0 20px;
  background: rgba(255,255,255,0.9);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--g-border);
}
.g-brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--g-brand); }
.g-lockup { height: 34px; width: auto; display: block; }
.g-brand-sub {
  font-size: 12px; color: var(--g-text-mute); font-weight: 500;
  padding-left: 12px; border-left: 1px solid var(--g-border); white-space: nowrap;
}
@media (max-width: 600px) { .g-brand-sub { display: none; } .g-lockup { height: 28px; } }
.g-brand-logo {
  width: 34px; height: 34px; border-radius: 9px;
  object-fit: cover; background: #e5e5e5; flex-shrink: 0;
}
.g-brand-text {
  font-family: 'Inter Tight', 'Inter', sans-serif;
  font-weight: 700; font-size: 15px; line-height: 1.15;
  display: flex; flex-direction: column;
}
.g-brand-text small { font-weight: 500; font-size: 11px; color: var(--g-text-mute); letter-spacing: 0; }
.g-login-link {
  font-size: 13px; font-weight: 600; text-decoration: none;
  color: var(--g-accent-strong);
  padding: 8px 14px; border-radius: 8px; border: 1px solid var(--g-border);
  transition: background .15s, border-color .15s;
  white-space: nowrap;
}
.g-login-link:hover { background: #faf8f6; border-color: var(--g-accent); }
.g-pdf-link {
  margin-left: auto;
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 13px; font-weight: 600; text-decoration: none;
  color: #fff; background: var(--g-accent-strong);
  padding: 8px 14px; border-radius: 8px; border: 1px solid var(--g-accent-strong);
  transition: background .15s; white-space: nowrap;
}
.g-pdf-link:hover { background: var(--g-brand); border-color: var(--g-brand); }
.g-toc-toggle {
  display: none; align-items: center; gap: 7px;
  margin-left: auto;
  background: none; border: 1px solid var(--g-border); border-radius: 8px;
  padding: 8px 12px; font-size: 13px; font-weight: 600; color: var(--g-text-soft);
  cursor: pointer;
}

/* ── Раскладка ── */
.g-layout {
  max-width: 1200px; margin: 0 auto;
  display: grid; grid-template-columns: 290px minmax(0, 1fr);
  gap: 40px; padding: 0 24px;
}

/* ── Боковое оглавление ── */
.g-sidebar {
  position: sticky; top: 60px; align-self: start;
  height: calc(100vh - 60px);
  display: flex; flex-direction: column;
  padding: 22px 6px 22px 0;
}
.g-search {
  position: relative; display: flex; align-items: center;
  margin-bottom: 12px;
}
.g-search svg { position: absolute; left: 11px; color: var(--g-text-mute); pointer-events: none; }
.g-search input {
  width: 100%; padding: 9px 30px 9px 32px;
  border: 1px solid var(--g-border); border-radius: 9px;
  background: var(--g-surface); font-size: 13.5px; color: var(--g-text);
  font-family: inherit;
}
.g-search input:focus { outline: none; border-color: var(--g-accent); box-shadow: 0 0 0 3px rgba(122,90,72,0.12); }
.g-search-clear {
  position: absolute; right: 6px;
  border: none; background: none; cursor: pointer;
  font-size: 18px; line-height: 1; color: var(--g-text-mute); padding: 4px 6px;
}
.g-search-clear:hover { color: var(--g-text); }
.g-search-empty { font-size: 13px; color: var(--g-text-mute); padding: 4px 8px; }

.g-toc { overflow-y: auto; flex: 1; padding-right: 6px; }
.g-toc::-webkit-scrollbar { width: 8px; }
.g-toc::-webkit-scrollbar-thumb { background: #e0dbd5; border-radius: 8px; }
.g-toc > ul { margin: 0; padding: 0; }
.g-toc ul { list-style: none; margin: 0; padding: 0; }
.g-toc li { margin: 1px 0; }
.g-toc a {
  display: block; text-decoration: none;
  color: var(--g-text-soft); font-size: 13.5px;
  padding: 5px 10px; border-radius: 7px;
  border-left: 2px solid transparent;
  transition: color .12s, background .12s;
}
.g-toc a:hover { color: var(--g-brand); background: #efeae5; }
.g-toc a.is-active {
  color: var(--g-accent-strong); background: #f0e9e3;
  border-left-color: var(--g-accent); font-weight: 600;
}
/* Вложенность h3 */
.g-toc ul ul a { padding-left: 22px; font-size: 12.5px; color: var(--g-text-mute); }
.g-toc ul ul a:hover, .g-toc ul ul a.is-active { color: var(--g-accent-strong); }

/* ── Контент ── */
.g-content { min-width: 0; padding: 28px 0 80px; }
.g-article { max-width: 760px; }
.g-article h1 {
  font-family: 'Inter Tight', sans-serif;
  font-size: 30px; font-weight: 700; line-height: 1.2;
  margin: 0 0 18px; color: var(--g-brand); letter-spacing: -0.02em;
}
.g-article h2 {
  font-family: 'Inter Tight', sans-serif;
  font-size: 22px; font-weight: 700; margin: 44px 0 14px;
  padding-top: 14px; border-top: 1px solid var(--g-border);
  color: var(--g-brand); scroll-margin-top: 76px; letter-spacing: -0.01em;
}
.g-article h3 {
  font-size: 17px; font-weight: 650; margin: 28px 0 10px;
  color: var(--g-accent-strong); scroll-margin-top: 76px;
}
.g-article p { margin: 12px 0; }
.g-article a { color: var(--g-accent-strong); text-decoration: underline; text-underline-offset: 2px; }
.g-article a:hover { color: var(--g-brand); }
.g-article ul, .g-article ol { margin: 12px 0; padding-left: 24px; }
.g-article li { margin: 5px 0; }
.g-article strong, .g-article b { color: var(--g-text); font-weight: 650; }
.g-article hr { border: none; border-top: 1px solid var(--g-border); margin: 32px 0; }

.g-article code {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.86em; background: var(--g-code-bg);
  padding: 2px 6px; border-radius: 5px; color: var(--g-accent-strong);
}
.g-article pre {
  background: var(--g-code-bg); border: 1px solid var(--g-border);
  border-radius: var(--g-radius); padding: 14px 16px; overflow-x: auto;
}
.g-article pre code { background: none; padding: 0; color: var(--g-text); }

.g-article blockquote {
  margin: 16px 0; padding: 10px 16px;
  border-left: 3px solid var(--g-accent);
  background: #f3ede8; border-radius: 0 8px 8px 0;
  color: var(--g-text-soft);
}
.g-article blockquote p { margin: 6px 0; }

.g-article table {
  width: 100%; border-collapse: collapse; margin: 18px 0;
  font-size: 13.5px; display: block; overflow-x: auto;
}
.g-article th, .g-article td {
  border: 1px solid var(--g-border); padding: 8px 11px; text-align: left;
  vertical-align: top;
}
.g-article th { background: #f3efeb; font-weight: 650; color: var(--g-brand); }
.g-article tr:nth-child(even) td { background: #faf9f7; }

/* Якорь-ссылка у заголовков (permalink из python-markdown) */
.g-article .headerlink {
  text-decoration: none; color: var(--g-text-mute);
  margin-left: 8px; opacity: 0; font-weight: 400; font-size: 0.7em;
}
.g-article h2:hover .headerlink, .g-article h3:hover .headerlink { opacity: 1; }

/* Подсветка совпадений поиска */
mark.g-hit { background: var(--g-hit); color: inherit; border-radius: 3px; padding: 0 1px; }

/* ── Callout-блоки (admonition) ── */
.g-article .admonition {
  margin: 18px 0; padding: 12px 16px 12px 18px;
  border-left: 4px solid var(--g-accent);
  background: #f3ede8; border-radius: 0 10px 10px 0;
  font-size: 14px;
}
.g-article .admonition > :first-child { margin-top: 0; }
.g-article .admonition > :last-child { margin-bottom: 0; }
.g-article .admonition-title {
  font-weight: 700; margin: 0 0 6px; color: var(--g-brand);
  font-size: 13.5px; letter-spacing: -0.01em;
}
.g-article .admonition.note { border-left-color: #4b7bec; background: #eef3fd; }
.g-article .admonition.note .admonition-title { color: #2a4fa0; }
.g-article .admonition.tip { border-left-color: #2b9d6b; background: #ebf7f1; }
.g-article .admonition.tip .admonition-title { color: #1c7a51; }
.g-article .admonition.warning { border-left-color: #e0913a; background: #fdf3e7; }
.g-article .admonition.warning .admonition-title { color: #a45f12; }

/* ── Скриншоты (figure) ── */
.g-article figure { margin: 22px 0; }
.g-article figure img {
  display: block; max-width: 100%; height: auto;
  border: 1px solid var(--g-border); border-radius: 10px;
  box-shadow: 0 6px 22px rgba(59,42,34,0.10);
}
.g-article figcaption {
  margin-top: 8px; font-size: 12.5px; color: var(--g-text-mute);
  text-align: center; font-style: italic;
}
.g-article .screens-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin: 22px 0;
}
.g-article .screens-row figure { margin: 0; }
.g-article figure.mobile img { max-width: 280px; margin: 0 auto; }
@media (max-width: 700px) {
  .g-article .screens-row { grid-template-columns: 1fr; }
}

.g-footer {
  max-width: 760px; margin-top: 56px; padding-top: 20px;
  border-top: 1px solid var(--g-border);
  font-size: 13px; color: var(--g-text-mute);
}
.g-footer a { color: var(--g-accent-strong); margin-left: 8px; }

/* ── Кнопка «Наверх» ── */
.g-totop {
  position: fixed; right: 22px; bottom: 22px; z-index: 25;
  width: 42px; height: 42px; border-radius: 50%;
  border: 1px solid var(--g-border); background: var(--g-surface);
  color: var(--g-accent-strong); cursor: pointer;
  display: grid; place-items: center;
  box-shadow: 0 4px 16px rgba(59,42,34,0.14);
}
.g-totop:hover { background: #faf8f6; }

/* ── Адаптив ── */
@media (max-width: 860px) {
  .g-login-link, .g-pdf-link { display: none; }
  .g-toc-toggle { display: inline-flex; }
  .g-layout { grid-template-columns: 1fr; gap: 0; padding: 0 18px; }
  .g-sidebar {
    position: fixed; top: 60px; left: 0; right: 0; bottom: 0; z-index: 28;
    height: auto; background: var(--g-surface);
    padding: 18px; transform: translateX(-100%);
    transition: transform .22s ease; box-shadow: 2px 0 24px rgba(0,0,0,0.12);
    max-width: 340px;
  }
  .g-sidebar.is-open { transform: translateX(0); }
  .g-content { padding: 20px 0 70px; }
  .g-article h1 { font-size: 25px; }
  .g-article h2 { font-size: 20px; }
}
