/* Синергетический форум — тема «научный альманах».
   Цвета и шрифты — переменные ниже. Цвет рубрики приходит из config/site.php (rubric_colors)
   через CSS-переменную --rc на элементе (style="--rc: #...").
   Темная тема — ниже, в @media (prefers-color-scheme: dark). */
:root {
  --paper: #f5efe3;
  --sheet: #fffcf6;
  --sheet-2: #efe7d8;
  --ink: #1f1b16;
  --ink-soft: #3d362d;
  --muted: #6f6556;
  --rule: #ddd2bf;
  --rule-strong: #1f1b16;
  --accent: #6b4f2a;          /* бронза: ссылки на служебных местах, фокус */
  --link: #2e4a7d;            /* чернильный синий для ссылок в тексте */
  --link-hover: #8a3b12;
  --mark: #a07a3c;
  --rc: #7a6a55;              /* цвет рубрики по умолчанию */
  --rc-text: var(--rc);
  --rc-soft: color-mix(in srgb, var(--rc) 10%, var(--sheet));
  --shadow: 0 1px 0 rgba(31, 27, 22, .04), 0 10px 30px -18px rgba(31, 27, 22, .25);
  --radius: 4px;
  --serif: Charter, "Bitstream Charter", "Iowan Old Style", "PT Serif", Georgia, Cambria, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --wrap: 1160px;
  --measure: 68ch;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #16140f;
    --sheet: #1d1a14;
    --sheet-2: #26221a;
    --ink: #ece5d7;
    --ink-soft: #cfc6b5;
    --muted: #9d927f;
    --rule: #383124;
    --rule-strong: #ece5d7;
    --accent: #d2ad73;
    --link: #9cb8ea;
    --link-hover: #f0a46f;
    --mark: #c9a062;
    --rc-text: color-mix(in srgb, var(--rc) 55%, #ffffff);
    --rc-soft: color-mix(in srgb, var(--rc) 22%, var(--sheet));
    --shadow: none;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 18px/1.6 var(--serif);
  text-rendering: optimizeLegibility;
  font-kerning: normal;
}
img { max-width: 100%; height: auto; }
a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--link-hover); }
h1, h2, h3, h4 { font-family: var(--serif); font-weight: 700; line-height: 1.18; color: var(--ink); margin: 0 0 .5em; }
h1 { font-size: clamp(1.9rem, 1.3rem + 2.4vw, 3rem); letter-spacing: -.012em; }
h2 { font-size: clamp(1.4rem, 1.15rem + 1vw, 1.8rem); }
h3 { font-size: 1.2rem; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 24px; }
@media (max-width: 600px) { .wrap { padding: 0 16px; } }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 12px; top: 12px; background: var(--sheet); padding: 8px 12px; z-index: 10; }
.eyebrow {
  font-family: var(--sans); font-size: .74rem; font-weight: 600; letter-spacing: .16em; text-transform: uppercase;
  color: var(--rc-text); margin: 0 0 12px;
}

/* ---------- шапка-титул */
.masthead { background: var(--paper); position: relative; }
.mast-row { display: flex; align-items: center; gap: 28px; padding-top: 22px; padding-bottom: 18px; }
.brand { display: flex; align-items: center; gap: 14px; text-decoration: none; color: var(--ink); flex-shrink: 0; }
.brand-mark { width: 56px; height: 56px; display: block; }
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-over {
  font-family: var(--sans); font-size: .7rem; font-weight: 600; letter-spacing: .2em; text-transform: uppercase; color: var(--muted);
}
.brand-name { font-size: 1.85rem; font-weight: 700; letter-spacing: -.01em; margin-top: 4px; }
.brand:hover .brand-name { color: var(--accent); }

.panel { margin-left: auto; display: flex; align-items: center; gap: 22px; }
.top-nav ul { list-style: none; margin: 0; padding: 0; display: flex; gap: 2px; }
.top-nav a {
  display: block; padding: 6px 10px; color: var(--ink-soft); text-decoration: none; white-space: nowrap;
  font-family: var(--sans); font-size: .88rem;
}
.top-nav a:hover, .top-nav a[aria-current] { color: var(--ink); text-decoration: underline; text-decoration-color: var(--mark); }

.search-form { display: flex; align-items: center; position: relative; }
.search-form input {
  width: 200px; padding: 8px 12px 8px 34px; border: 1px solid var(--rule); border-radius: 999px;
  background: var(--sheet); color: var(--ink); font: .9rem var(--sans);
}
.search-form input:focus { outline: none; border-color: var(--accent); }
.search-form svg { position: absolute; left: 12px; width: 15px; height: 15px; color: var(--muted); pointer-events: none; }
.search-form button { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); border: 0; padding: 0; }

/* строка рубрик: у каждой рубрики свой цвет, как в цветной таблице старого сайта */
.rubrics-nav ul { list-style: none; margin: 0 auto; padding: 0; display: flex; flex-wrap: wrap; }
.rubrics-nav--bar { border-top: 1px solid var(--rule-strong); border-bottom: 1px solid var(--rule); }
.rubrics-nav--bar ul { padding-top: 0; padding-bottom: 0; justify-content: space-between; }
.rubrics-nav--bar a {
  display: flex; align-items: center; gap: 8px; padding: 12px 4px; text-decoration: none; white-space: nowrap;
  color: var(--ink-soft); font-family: var(--sans); font-size: .92rem; font-weight: 500;
  border-bottom: 3px solid transparent; margin-bottom: -1px;
}
.rubrics-nav a::before {
  content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--rc); flex-shrink: 0;
}
.rubrics-nav--bar a:hover { color: var(--ink); border-bottom-color: color-mix(in srgb, var(--rc) 45%, transparent); }
.rubrics-nav--bar a[aria-current] { color: var(--ink); border-bottom-color: var(--rc); }
.rubrics-nav--panel { display: none; }

.spectrum { display: flex; height: 4px; }
.spectrum span { flex: 1; background: var(--rc); }

.nav-toggle { display: none; }

@media (max-width: 1100px) {
  .rubrics-nav--bar ul { justify-content: flex-start; gap: 0 18px; }
}
@media (max-width: 900px) {
  .mast-row { padding-top: 14px; padding-bottom: 14px; gap: 12px; }
  .brand-mark { width: 44px; height: 44px; }
  .brand-name { font-size: 1.45rem; }
  .brand-over { font-size: .62rem; letter-spacing: .14em; }
  .nav-toggle {
    display: block; margin-left: auto; cursor: pointer; padding: 8px 14px; background: var(--sheet);
    border: 1px solid var(--rule); border-radius: 999px; font: .9rem var(--sans); color: var(--ink-soft);
  }
  .panel { display: none; }
  .nav-open .panel {
    display: block; position: absolute; left: 0; right: 0; top: 100%; z-index: 30; margin: 0;
    background: var(--sheet); border-bottom: 1px solid var(--rule); box-shadow: var(--shadow); padding: 16px 16px 22px;
  }
  .masthead { position: relative; }
  .rubrics-nav--bar { display: none; }
  .rubrics-nav--panel { display: block; margin-top: 14px; }
  .rubrics-nav--panel ul { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
  .rubrics-nav--panel a {
    display: flex; align-items: center; gap: 10px; padding: 10px 2px; text-decoration: none; color: var(--ink);
    font-family: var(--sans); border-bottom: 1px solid var(--rule);
  }
  .top-nav ul { flex-direction: column; }
  .top-nav a { padding: 10px 2px; font-size: 1rem; border-bottom: 1px solid var(--rule); }
  .search-form { margin-top: 14px; }
  .search-form input { width: 100%; padding-top: 11px; padding-bottom: 11px; }
}

/* ---------- общая раскладка */
main { padding: 34px 0 72px; min-height: 60vh; }
.crumbs { font-family: var(--sans); font-size: .84rem; color: var(--muted); margin: 0 0 22px; }
.crumbs ol { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px; }
.crumbs li + li::before { content: "/"; margin: 0 6px 0 2px; color: var(--rule); }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--accent); }

.layout-aside { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 44px; align-items: start; }
@media (max-width: 1000px) { .layout-aside { grid-template-columns: minmax(0, 1fr); gap: 20px; } .layout-aside > aside { order: 2; } }

.page-head { margin-bottom: 30px; padding-bottom: 22px; border-bottom: 1px solid var(--rule); position: relative; }
.rubric-page .page-head::after { content: ""; position: absolute; left: 0; bottom: -1px; width: 120px; height: 3px; background: var(--rc); }
.page-head h1 .meta { font-size: .5em; font-weight: 400; }
.page-head .lead { color: var(--ink-soft); font-size: 1.05rem; max-width: var(--measure); }
.kicker {
  display: inline-flex; align-items: center; gap: 8px; font: 600 .76rem var(--sans); letter-spacing: .14em; text-transform: uppercase;
  color: var(--rc-text); text-decoration: none; margin-bottom: 14px;
}
.kicker::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--rc); }
.kicker:hover { color: var(--ink); }
.meta { color: var(--muted); font-family: var(--sans); font-size: .88rem; }

.section-title {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  font: 600 .78rem var(--sans); letter-spacing: .16em; text-transform: uppercase;
  color: var(--ink); margin: 0 0 18px; padding-bottom: 10px; border-bottom: 1px solid var(--rule-strong);
}
.section-title a { color: inherit; text-decoration: none; }
.section-title .more { font-size: .8rem; letter-spacing: .02em; text-transform: none; font-weight: 500; color: var(--muted); }
.section-title .more:hover { color: var(--accent); }

.btn {
  display: inline-block; padding: 11px 20px; border-radius: 999px; border: 1px solid var(--ink); background: var(--ink); color: var(--paper);
  font: 600 .92rem var(--sans); cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--accent); border-color: var(--accent); color: var(--paper); }
.btn-ghost { background: transparent; color: var(--ink); }
.btn-ghost:hover { background: var(--ink); border-color: var(--ink); color: var(--paper); }

/* ---------- главная */
.hero {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 40px; align-items: end;
  padding: 8px 0 38px; margin-bottom: 40px; border-bottom: 1px solid var(--rule);
}
.hero .eyebrow { color: var(--accent); }
.hero h2 { font-size: clamp(2rem, 1.3rem + 2.6vw, 3rem); line-height: 1.08; letter-spacing: -.02em; max-width: 20ch; margin-bottom: 18px; }
.hero-lead { font-size: 1.12rem; color: var(--ink-soft); max-width: 60ch; margin: 0 0 22px; }
.hero-links { display: flex; flex-wrap: wrap; gap: 10px; margin: 0; }
.hero-facts { margin: 0; display: grid; gap: 18px; min-width: 200px; border-left: 1px solid var(--rule); padding-left: 28px; }
.hero-facts dt { font: 600 .7rem var(--sans); letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.hero-facts dd { margin: 2px 0 0; font-size: 1.5rem; font-weight: 700; }
@media (max-width: 820px) {
  .hero { grid-template-columns: minmax(0, 1fr); gap: 26px; }
  .hero-facts { grid-template-columns: repeat(3, auto); justify-content: start; gap: 22px; border-left: 0; padding-left: 0; border-top: 1px solid var(--rule); padding-top: 18px; }
  .hero-facts dd { font-size: 1.2rem; }
}

/* научная редакция: новые статьи (config editorial) */
.editorial { margin-bottom: 52px; }
.editorial .section-title { margin-bottom: 8px; }
.editorial-note { margin: 0 0 18px; color: var(--muted); font: .92rem var(--sans); }
/* у статей редакции длинные заголовки и анонсы, поэтому не больше двух колонок */
.editorial-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 18px; }
.editorial-card {
  display: flex; flex-direction: column; background: var(--sheet); border: 1px solid var(--rule); border-top: 3px solid var(--rc);
  border-radius: var(--radius); padding: 16px 20px 14px; box-shadow: var(--shadow);
}
.editorial-card .kicker { margin-bottom: 8px; font-size: .7rem; }
.editorial-card h3 { font-size: 1.22rem; line-height: 1.25; margin: 0 0 8px; }
.editorial-card h3 a { color: var(--ink); text-decoration: none; }
.editorial-card h3 a:hover { color: var(--link-hover); }
.editorial-card p { margin: 0 0 12px; color: var(--ink-soft); font-size: .97rem; line-height: 1.5; flex: 1; }
.editorial-card .meta { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .8rem; }
.ed-badge {
  display: inline-block; margin: 0 0 4px 10px; padding: 1px 8px; border: 1px solid var(--rule); border-radius: 999px;
  font: 600 .66rem var(--sans); letter-spacing: .1em; text-transform: uppercase; color: var(--accent); vertical-align: 1px;
}
.article-row .ed-badge:first-child { margin-left: 0; }

.home-cols { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 48px; align-items: start; margin-bottom: 56px; }
@media (max-width: 1000px) { .home-cols { grid-template-columns: minmax(0, 1fr); } }

.section-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 18px; }
.section-card {
  background: var(--sheet); border: 1px solid var(--rule); border-top: 4px solid var(--rc); border-radius: var(--radius);
  padding: 18px 20px 16px; display: flex; flex-direction: column; box-shadow: var(--shadow);
}
.section-card header { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.section-card h3 { margin: 0; font-size: 1.3rem; }
.section-card h3 a { color: var(--ink); text-decoration: none; }
.section-card h3 a:hover { color: var(--rc-text); }
.section-card .count { font: 600 .8rem var(--sans); color: var(--rc-text); background: var(--rc-soft); padding: 2px 8px; border-radius: 999px; }
.section-card ul { list-style: none; margin: 0 0 12px; padding: 0; flex: 1; }
.section-card li { padding: 8px 0; border-bottom: 1px dotted var(--rule); font-size: .95rem; line-height: 1.35; }
.section-card li:last-child { border-bottom: 0; }
.section-card li a { color: var(--ink-soft); text-decoration: none; }
.section-card li a:hover { color: var(--link-hover); }
.section-card .more { font: 500 .85rem var(--sans); color: var(--rc-text); text-decoration: none; }
.section-card .more:hover { text-decoration: underline; }

.news-col { position: sticky; top: 16px; }
.news-list { list-style: none; margin: 0; padding: 0; counter-reset: n; }
.news-list li { padding: 12px 0 12px 0; border-bottom: 1px solid var(--rule); }
.news-list li:last-child { border-bottom: 0; }
.news-list time { display: block; font: .78rem var(--sans); color: var(--muted); margin-bottom: 3px; }
.news-list a { color: var(--ink); text-decoration: none; font-weight: 700; line-height: 1.3; }
.news-list a:hover { color: var(--link-hover); }
@media (max-width: 1000px) { .news-col { position: static; } }

.about-box {
  display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 44px;
  background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius); padding: 36px 40px; box-shadow: var(--shadow);
}
.about-box .about-text { max-width: none; }
.about-box h2 { font-size: 1.6rem; }
.about-box .about-text > p:first-of-type::first-letter {
  float: left; font-size: 3.4em; line-height: .86; padding: 6px 10px 0 0; color: var(--accent); font-weight: 700;
}
.about-side { border-left: 1px solid var(--rule); padding-left: 32px; }
.about-side h3 { font: 600 .78rem var(--sans); letter-spacing: .16em; text-transform: uppercase; margin-bottom: 10px; }
.about-side .note { color: var(--muted); font-size: .92rem; margin: 0 0 10px; }
.members { list-style: none; margin: 0 0 12px; padding: 0; }
.members li { padding: 9px 0; border-bottom: 1px dotted var(--rule); font-size: .93rem; color: var(--ink-soft); line-height: 1.4; }
.members b { display: block; color: var(--ink); font-size: 1.02rem; }
@media (max-width: 860px) {
  .about-box { grid-template-columns: 1fr; padding: 24px 20px; gap: 24px; }
  .about-side { border-left: 0; padding-left: 0; border-top: 1px solid var(--rule); padding-top: 20px; }
}

/* ---------- список статей */
.article-list { list-style: none; margin: 0; padding: 0; }
.article-row { padding: 22px 0; border-bottom: 1px solid var(--rule); display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 24px; }
.article-row:first-child { padding-top: 4px; }
.article-row time { font: .84rem var(--sans); color: var(--muted); padding-top: 5px; }
.article-row h2 { font-size: 1.3rem; margin: 0 0 6px; }
.article-row h2 a { color: var(--ink); text-decoration: none; }
.article-row h2 a:hover { color: var(--link-hover); }
.article-row p { margin: 0; color: var(--ink-soft); font-size: 1rem; }
.article-row .cat {
  display: inline-flex; align-items: center; gap: 6px; font: 600 .74rem var(--sans); letter-spacing: .12em; text-transform: uppercase;
  color: var(--rc-text); text-decoration: none; margin-bottom: 4px;
}
.article-row .cat::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--rc); }
.article-row.has-img { grid-template-columns: 120px minmax(0, 1fr) 170px; }
.article-row .thumb { grid-column: 3; grid-row: 1; display: block; aspect-ratio: 3 / 2; overflow: hidden; border-radius: var(--radius); background: var(--sheet-2); }
.article-row .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
@media (max-width: 640px) {
  .article-row, .article-row.has-img { grid-template-columns: 1fr; gap: 4px; }
  .article-row .thumb { grid-column: auto; grid-row: auto; margin: 6px 0; }
}

.subcats { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 26px; padding: 0; list-style: none; }
.subcats a {
  display: block; padding: 6px 14px; border: 1px solid var(--rule); border-radius: 999px; background: var(--sheet);
  text-decoration: none; color: var(--ink-soft); font: .9rem var(--sans);
}
.subcats a:hover { border-color: var(--accent); color: var(--accent); }
.subcats .n { color: var(--muted); font-size: .8rem; margin-left: 4px; }

/* каталог (на этом сайте не используется, оставлен для совместимости движка) */
.catalog { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 18px; list-style: none; margin: 0; padding: 0; }
.catalog li { background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 10px; text-align: center; }
.catalog .pic img { max-height: 140px; width: auto; }
.catalog a.title { color: var(--ink); font-weight: 600; text-decoration: none; }
.catalog .extra { color: var(--accent); font-weight: 700; margin-top: auto; }
.catalog .note { margin: 0; font-size: .88rem; color: var(--muted); text-align: left; }

/* статья с правой колонкой */
.layout-article { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 64px; align-items: start; }
.side-block { margin-bottom: 34px; }
.side-block ul { list-style: none; margin: 0; padding: 0; }
.side-block li { padding: 9px 0; border-bottom: 1px dotted var(--rule); font-size: .95rem; line-height: 1.38; }
.side-block li:last-child { border-bottom: 0; }
.side-block a { color: var(--ink-soft); text-decoration: none; }
.side-block a:hover { color: var(--link-hover); }
.side-block .n { color: var(--muted); font: .78rem var(--sans); float: right; margin-left: 8px; }
.rubric-index li { display: flex; align-items: center; gap: 10px; font-family: var(--sans); font-size: .92rem; }
.rubric-index li::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--rc); flex-shrink: 0; }
.rubric-index .n { margin-left: auto; }
.layout-article > aside { position: sticky; top: 16px; }
@media (max-width: 1000px) { .layout-article { grid-template-columns: minmax(0, 1fr); gap: 0; } .layout-article > aside { position: static; margin-top: 56px; } }

/* дерево раздела */
.tree { background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius); padding: 16px 0; font: .93rem var(--sans); position: sticky; top: 16px; }
.tree .tree-title { font-weight: 700; padding: 0 18px 8px; display: block; color: var(--ink); text-decoration: none; }
.tree ul { list-style: none; margin: 0; padding: 0; }
.tree ul ul { padding-left: 14px; }
.tree a { display: block; padding: 6px 18px; color: var(--ink-soft); text-decoration: none; border-left: 3px solid transparent; }
.tree a:hover { color: var(--link-hover); }
.tree a.active { color: var(--ink); font-weight: 600; }
.tree a.current { border-left-color: var(--rc); background: var(--rc-soft); }

/* пагинация */
.pager { display: flex; flex-wrap: wrap; gap: 6px; margin: 36px 0 0; padding: 0; list-style: none; font-family: var(--sans); }
.pager a, .pager span {
  display: block; min-width: 40px; padding: 7px 12px; text-align: center; border: 1px solid var(--rule);
  border-radius: 999px; text-decoration: none; color: var(--ink-soft); background: var(--sheet); font-size: .9rem;
}
.pager a:hover { border-color: var(--accent); color: var(--accent); }
.pager .cur { background: var(--ink); color: var(--paper); border-color: var(--ink); font-weight: 700; }
.pager .gap { border: 0; background: none; min-width: 0; padding: 7px 4px; }

/* ---------- статья */
.article { max-width: 760px; }
.article-head { margin-bottom: 32px; padding-bottom: 22px; border-bottom: 1px solid var(--rule); }
.article-head h1 { margin-bottom: 14px; font-size: clamp(1.8rem, 1.25rem + 2.2vw, 2.7rem); }
.article-head .meta { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.article-head .meta .author { color: var(--ink-soft); font-weight: 600; }
/* вводка: анонс статьи под заголовком */
.article-head .lead { margin-top: 18px; max-width: var(--measure); font-size: 1.2rem; line-height: 1.55; color: var(--ink-soft); }
.article-head .lead p { margin: 0; }
.article-head .lead p + p { margin-top: .6em; }
@media (max-width: 600px) { .article-head .lead { font-size: 1.08rem; } }

/* оглавление длинной статьи (собирается в theme/article.php по <h2>) */
.toc {
  max-width: var(--measure); margin: 0 0 34px; padding: 16px 22px 14px; background: var(--sheet);
  border: 1px solid var(--rule); border-left: 3px solid var(--rc); border-radius: var(--radius); font-family: var(--sans);
}
.toc .toc-title { font: 600 .74rem var(--sans); letter-spacing: .16em; text-transform: uppercase; color: var(--muted); margin: 0 0 8px; }
.toc ol { margin: 0; padding: 0; list-style: none; counter-reset: toc; }
.toc li { counter-increment: toc; display: flex; gap: 10px; padding: 5px 0; font-size: .95rem; line-height: 1.35; }
.toc li::before { content: counter(toc); min-width: 1.2em; color: var(--rc-text); font-weight: 600; font-variant-numeric: tabular-nums; }
.toc li.toc-sources::before { content: "—"; color: var(--muted); }
.toc a { color: var(--ink-soft); text-decoration: none; }
.toc a:hover { color: var(--link-hover); text-decoration: underline; }
.toc li.toc-sources a { color: var(--muted); }

.prose { font-size: 1.12rem; line-height: 1.7; color: var(--ink); max-width: var(--measure); overflow-wrap: break-word; hyphens: auto; }
.prose > * + * { margin-top: 1.05em; }
.prose p { margin: 0; }
.prose p + p { margin-top: .95em; }
.prose h2, .prose h3, .prose h4 { margin: 1.7em 0 .5em; }
.prose h1 { font-size: 1.6rem; margin: 1.4em 0 .5em; }
.prose ul, .prose ol { padding-left: 1.4em; margin-bottom: 0; }
.prose li + li { margin-top: .35em; }
.prose li::marker { color: var(--muted); }
.prose img { border-radius: 2px; }
.prose img[style*="float: left"], .prose img[style*="float:left"] { margin: .3em 1.4em 1em 0 !important; }
.prose img[style*="float: right"], .prose img[style*="float:right"] { margin: .3em 0 1em 1.4em !important; }
.prose blockquote { margin: 1.5em 0; padding: 2px 0 2px 22px; border-left: 3px solid var(--rc); color: var(--ink-soft); font-style: italic; }
.prose hr { border: 0; text-align: center; margin: 2.2em 0; }
.prose hr::after { content: "⁂"; color: var(--muted); letter-spacing: .4em; }
.prose pre { background: var(--sheet-2); padding: 14px; border-radius: var(--radius); overflow-x: auto; font-size: .9rem; white-space: pre-wrap; }
.prose .table-wrap { overflow-x: auto; margin: 1.4em 0; -webkit-overflow-scrolling: touch; }
.prose table { border-collapse: collapse; font-size: .95rem; min-width: 60%; }
.prose td, .prose th { border: 1px solid var(--rule); padding: 7px 10px; vertical-align: top; text-align: left; }
.prose th { background: var(--sheet-2); }
.prose iframe { max-width: 100%; border: 0; }
.prose figure { margin: 0 0 1.6em; }
.prose figure img { display: block; width: 100%; height: auto; }
.prose figcaption { margin-top: 8px; font: .82rem var(--sans); color: var(--muted); }
.prose sup { line-height: 0; }
.prose sup a { text-decoration: none; }
.prose .sources, .prose p.sources { margin-top: 2em; padding-top: 14px; border-top: 1px solid var(--rule); font-size: .9rem; color: var(--muted); }
/* переходы по якорям: разделы из оглавления, ссылки [N] на источники */
.prose h2[id], .prose a[name], .prose .sources[id] { scroll-margin-top: 24px; }
.prose .sources a[name]:target::before { content: "▸ "; color: var(--link-hover); font-weight: 700; }
.prose::after { content: ""; display: block; clear: both; }
.prose [align="center"], .prose .center { text-align: center; }
@media (max-width: 600px) {
  .prose { font-size: 1.04rem; line-height: 1.65; }
  .prose img[style*="float"] { float: none !important; display: block; margin: 1em auto !important; }
  .prose td, .prose th { padding: 6px 8px; }
}

.related { margin-top: 60px; }
.related ul { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.related li { background: var(--sheet); border: 1px solid var(--rule); border-top: 3px solid var(--rc); border-radius: var(--radius); padding: 14px 16px; }
.related li a { color: var(--ink); text-decoration: none; font-weight: 700; line-height: 1.3; }
.related li a:hover { color: var(--link-hover); }
.related li time { display: block; font: .78rem var(--sans); color: var(--muted); margin-top: 8px; }

/* ---------- поиск, ошибки */
.search-big { display: flex; gap: 10px; margin: 0 0 26px; max-width: 640px; }
.search-big input {
  flex: 1; min-width: 0; padding: 11px 16px; font: 1rem var(--sans); border: 1px solid var(--rule); border-radius: 999px;
  background: var(--sheet); color: var(--ink);
}
.error-page { text-align: center; padding: 40px 0; max-width: 640px; margin: 0 auto; }
.error-page .code { font-size: 5.5rem; font-weight: 700; color: var(--accent); line-height: 1; margin-bottom: 8px; }
.error-page .search-big { margin: 26px auto; }
.empty { color: var(--muted); padding: 20px 0; }

/* ---------- подвал */
.site-footer { border-top: 1px solid var(--rule-strong); padding: 40px 0 48px; font: .9rem var(--sans); color: var(--muted); background: var(--sheet); }
.footer-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1fr); gap: 32px; }
.footer-brand img { display: block; margin-bottom: 10px; }
.footer-brand p { margin: 0 0 6px; color: var(--ink-soft); }
.footer-brand .footer-sub { color: var(--muted); }
.site-footer h2 { font: 600 .72rem var(--sans); letter-spacing: .16em; text-transform: uppercase; color: var(--muted); margin: 0 0 10px; }
.site-footer ul { list-style: none; margin: 0; padding: 0; columns: 2; column-gap: 20px; }
.site-footer li { padding: 3px 0; break-inside: avoid; }
.site-footer a { color: var(--ink-soft); text-decoration: none; }
.site-footer a:hover { color: var(--accent); text-decoration: underline; }
@media (max-width: 760px) { .footer-grid { grid-template-columns: 1fr; gap: 24px; } }

@media print {
  .masthead, .site-footer, .related, .tree, .crumbs, .layout-article > aside, .toc { display: none; }
  body { background: #fff; color: #000; }
}
