/* Stilia — дизайн-система «Умный каталог»
   Нейтральные поверхности, цветные метки разделов, ясные карточки,
   алфавитная и рубричная навигация. Без внешних шрифтов и зависимостей. */

:root {
  --bg: #fafaf9;
  --surface: #ffffff;
  --surface-2: #f3f2ef;
  --line: #e3e1dc;
  --line-2: #cfccc4;
  --ink: #1b1b1f;
  --ink-soft: #4b4a52;
  --ink-faint: #6b6a72;
  --focus: #2563eb;
  /* цвета меток разделов (контраст текста на светлой подложке ≥ 4.5:1) */
  --ink-c: #334155;   --ink-t: #e9edf2;
  --amber: #92400e;   --amber-t: #fdf0dc;
  --violet: #6d28d9;  --violet-t: #efe9fd;
  --teal: #0f766e;    --teal-t: #dcf3f0;
  --rose: #be123c;    --rose-t: #fde7ec;
  --green: #047857;   --green-t: #dff4ea;
  --slate: #475569;   --slate-t: #eceff3;
  --blue: #1d4ed8;    --blue-t: #e3eafd;
  --radius: 12px;
  --container: 1180px;
  --measure: 70ch;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 16px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body { margin: 0; background: var(--bg); color: var(--ink); font: 1.03rem/1.62 var(--sans); overflow-x: hidden; }
a { color: var(--ink); text-decoration-color: var(--line-2); text-underline-offset: .18em; }
a:hover { text-decoration-color: currentColor; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; letter-spacing: -.012em; }
h1 { font-size: clamp(1.8rem, 1.3rem + 2vw, 2.7rem); font-weight: 800; }
h2 { font-size: 1.3rem; font-weight: 750; }
h3 { font-size: 1.05rem; font-weight: 700; }
p { margin: 0 0 1em; }

.container { width: 100%; max-width: var(--container); margin-left: auto; margin-right: auto; padding-left: 16px; padding-right: 16px; }
@media (min-width: 720px) { .container { padding-left: 28px; padding-right: 28px; } }
.skip-link { position: absolute; left: 12px; top: -60px; z-index: 100; background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px; font-weight: 700; text-decoration: none; }
.skip-link:focus { top: 12px; color: #fff; }

/* ---------- цветовые классы ---------- */
.r-ink { --c: var(--ink-c); --t: var(--ink-t); }
.r-amber, .c-amber { --c: var(--amber); --t: var(--amber-t); }
.r-violet, .c-violet { --c: var(--violet); --t: var(--violet-t); }
.r-teal, .c-teal { --c: var(--teal); --t: var(--teal-t); }
.r-rose, .c-rose { --c: var(--rose); --t: var(--rose-t); }
.r-green, .c-green { --c: var(--green); --t: var(--green-t); }
.r-slate, .c-slate { --c: var(--slate); --t: var(--slate-t); }
.c-blue { --c: var(--blue); --t: var(--blue-t); }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: .74rem; font-weight: 700; letter-spacing: .02em; padding: 2px 10px; border-radius: 999px; background: var(--t); color: var(--c); text-decoration: none; }
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--c); margin-right: 6px; }

/* ---------- Шапка ---------- */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.header-inner { display: flex; align-items: center; gap: 10px 16px; flex-wrap: wrap; min-height: 64px; padding-top: 8px; padding-bottom: 8px; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; margin-right: auto; }
.brand-mark { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; width: 32px; height: 32px; }
.brand-mark i { border-radius: 4px; }
.brand-mark i:nth-child(1) { background: var(--amber); } .brand-mark i:nth-child(2) { background: var(--violet); }
.brand-mark i:nth-child(3) { background: var(--teal); }  .brand-mark i:nth-child(4) { background: var(--rose); }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-weight: 800; font-size: 1.2rem; }
.brand-tag { font-size: .78rem; color: var(--ink-faint); }
.lang-switch { list-style: none; margin: 0; padding: 3px; display: flex; gap: 2px; background: var(--surface-2); border-radius: 999px; }
.lang-switch a, .lang-switch span { display: inline-grid; place-items: center; min-width: 36px; min-height: 32px; padding: 0 6px; border-radius: 999px; font-size: .76rem; font-weight: 700; text-transform: uppercase; text-decoration: none; color: var(--ink-soft); }
.lang-switch [aria-current="true"] { background: var(--ink); color: #fff; }
.nav-toggle { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 8px 14px; font: 700 .92rem var(--sans); color: var(--ink); background: var(--surface); border: 1px solid var(--line-2); border-radius: 999px; cursor: pointer; }
.nav-toggle-bars, .nav-toggle-bars::before, .nav-toggle-bars::after { display: block; width: 16px; height: 2px; background: currentColor; position: relative; content: ""; }
.nav-toggle-bars::before { position: absolute; top: -5px; }
.nav-toggle-bars::after { position: absolute; top: 5px; }
.main-nav { flex-basis: 100%; display: none; padding-bottom: 6px; }
.main-nav.is-open { display: block; }
.no-js .main-nav { display: block; }
.no-js .nav-toggle { display: none; }
.main-nav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.rub { display: inline-flex; align-items: center; gap: 8px; min-height: 38px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); text-decoration: none; font-weight: 600; font-size: .92rem; color: var(--ink); }
.rub::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--c); }
.rub:hover { background: var(--t); border-color: transparent; }
.rub[aria-current="page"] { background: var(--c); color: #fff; border-color: var(--c); }
.rub[aria-current="page"]::before { background: #fff; }
@media (min-width: 1000px) { .nav-toggle { display: none; } .main-nav { display: block; } }

.breadcrumbs { padding-top: 16px; font-size: .86rem; }
.breadcrumbs ol { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px; color: var(--ink-faint); }
.breadcrumbs li + li::before { content: "›"; margin-right: 4px; }
.breadcrumbs a { color: var(--ink-soft); }

/* ---------- Шапка страницы ---------- */
main { display: block; padding-bottom: 32px; }
.page-head { padding: 22px 0 6px; border-bottom: 4px solid var(--c); margin-bottom: 6px; }
.kicker { display: inline-block; font-size: .76rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--c); background: var(--t); padding: 3px 10px; border-radius: 6px; margin-bottom: .8em; }
.lead { font-size: 1.14rem; color: var(--ink-soft); max-width: var(--measure); }
.section { padding-top: 28px; }
.section > h2 { display: flex; align-items: center; gap: 10px; }
.section-intro { color: var(--ink-soft); max-width: var(--measure); }
.prose { max-width: var(--measure); }

/* ---------- Карточки ---------- */
.grid { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 680px) { .grid.g2, .grid.g3 { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 980px) { .grid.g3 { grid-template-columns: repeat(3, 1fr); } }
.card { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.card::before { content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 4px; border-radius: 0 4px 4px 0; background: var(--c, var(--line-2)); }
.card h3 { margin: 0; }
.card p { margin: 0; color: var(--ink-soft); }
.card .stretched { text-decoration: none; }
.card .stretched::after { content: ""; position: absolute; inset: 0; border-radius: var(--radius); }
.card:hover { border-color: var(--line-2); box-shadow: 0 6px 18px rgba(27, 27, 31, .06); }
.card:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
.card .stretched:focus-visible { outline: none; }
.card .ru-only { position: relative; z-index: 1; }
.person::before { background: var(--violet); }

.rubric-index { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
@media (min-width: 760px) { .rubric-index { grid-template-columns: 1fr 1fr; } }
.rubric-index li { background: var(--surface); border: 1px solid var(--line); border-left: 5px solid var(--c); border-radius: 10px; padding: 10px 14px; }
.rubric-index a { font-weight: 700; }
.rubric-index span:not(.ru-only) { display: block; color: var(--ink-soft); font-size: .94rem; }
.ru-only { font-size: .78rem; color: var(--ink-faint); }

.toc ul { list-style: none; margin: 16px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.toc .chip { font-size: .85rem; padding: 5px 12px; }

/* ---------- Хронология, лента ---------- */
.timeline { list-style: none; margin: 16px 0 0; padding: 0; max-width: 860px; }
.timeline > li { display: grid; grid-template-columns: 72px 1fr; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.timeline .year { font-weight: 800; font-size: 1.25rem; color: var(--ink); font-variant-numeric: tabular-nums; }
.timeline h3 { margin: 6px 0 4px; }
.timeline p { margin: 0; color: var(--ink-soft); }
.feed { list-style: none; margin: 16px 0 0; padding: 0; max-width: 900px; }
.feed > li { display: grid; grid-template-columns: 1fr; gap: 4px; padding: 16px 0; border-bottom: 1px solid var(--line); }
@media (min-width: 640px) { .feed > li { grid-template-columns: 110px 1fr; gap: 16px; } }
.feed time { font-weight: 700; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.feed h3 { margin: 6px 0 4px; }
.feed p { margin: 0 0 4px; }
.why { color: var(--ink-soft); font-size: .95rem; }
.to-archive { margin-top: 18px; font-weight: 700; }
.filter { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 16px; }
.filter button { font: 700 .85rem var(--sans); min-height: 36px; padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--surface); cursor: pointer; color: var(--ink); }
.filter button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
[hidden] { display: none !important; }

/* ---------- Подборки ---------- */
.route { list-style: none; margin: 0; padding: 0; counter-reset: r; max-width: 820px; }
.route li { counter-increment: r; position: relative; padding: 12px 0 12px 48px; border-bottom: 1px dashed var(--line-2); }
.route li::before { content: counter(r); position: absolute; left: 0; top: 12px; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; background: var(--t); color: var(--c); }
.route a { font-weight: 700; }
.route p { margin: 2px 0 0; color: var(--ink-soft); }
section.section:has(.route) { --c: var(--teal); --t: var(--teal-t); }

/* ---------- Заметки, FAQ, термины ---------- */
.note { background: var(--surface); border: 1px solid var(--line); border-left: 5px solid var(--c, var(--ink-c)); border-radius: 10px; padding: 14px 18px; margin-top: 22px; max-width: 860px; }
.note-label { font-size: .76rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--c, var(--ink-c)); margin-bottom: 4px; }
.note p:last-child { margin: 0; }
.qa-item { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px 18px; margin-bottom: 10px; max-width: 860px; }
.qa-item p { margin: 0; color: var(--ink-soft); }
.about { color: var(--ink-soft); }
dl.terms { margin: 0; display: grid; gap: 8px; max-width: 860px; }
dl.terms dt { font-weight: 800; }
dl.terms dd { margin: 0 0 8px; color: var(--ink-soft); }
.bullets { margin: 0; padding-left: 1.2em; max-width: var(--measure); }
.bullets li { margin-bottom: 6px; }

/* ---------- Разбор: боковое оглавление ---------- */
.with-toc { display: block; }
.side-toc { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-top: 22px; }
.side-toc h2 { font-size: .78rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-faint); }
.side-toc ol, .side-toc ul { margin: 0; padding-left: 1.1em; }
.side-toc li { margin: 4px 0; }
.topic-nav { list-style: none; padding: 0 !important; }
.topic-nav a { display: flex; align-items: center; text-decoration: none; padding: 4px 0; }
.topic-nav .n { margin-left: auto; font-size: .8rem; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
@media (min-width: 980px) {
  .with-toc { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 36px; align-items: start; }
  .side-toc { position: sticky; top: 16px; }
}
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); max-width: 900px; }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { text-align: left; vertical-align: top; padding: 11px 14px; border-bottom: 1px solid var(--line); }
thead th { background: var(--surface-2); }
tbody tr:last-child > * { border-bottom: 0; }
.unknown { --c: var(--amber); }
.unknown h2::before { content: "?"; display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--amber-t); color: var(--amber); font-size: 1rem; }

/* ---------- Архив: алфавит ---------- */
.counter { margin-top: 14px; font-size: .95rem; color: var(--ink-soft); }
.counter strong { font-size: 1.6rem; color: var(--ink); margin-right: 4px; }
.alpha { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.alpha a { display: inline-grid; place-items: center; min-width: 40px; min-height: 40px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); font-weight: 800; text-decoration: none; }
.alpha a:hover { background: var(--ink); color: #fff; }
.letter { display: grid; grid-template-columns: 44px 1fr; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.letter-mark { font-weight: 800; font-size: 1.4rem; color: var(--line-2); }
.entries { list-style: none; margin: 0; padding: 0; }
.entries li { padding: 6px 0; }
.entries a { font-weight: 700; }
.annot { margin: 2px 0 0; color: var(--ink-soft); font-size: .94rem; }
.meta { font-size: .82rem; color: var(--ink-faint); }

/* ---------- Каталог, источники, исторические адреса ---------- */
.catalog { background: var(--surface); border: 1px solid var(--line-2); border-radius: 16px; padding: 22px 20px; }
@media (min-width: 720px) { .catalog { padding: 28px 32px; } }
.catalog-empty { border: 2px dashed var(--line-2); border-radius: 10px; padding: 12px 14px; color: var(--ink-soft); background: var(--bg); }
.sources { font-size: .94rem; color: var(--ink-soft); }
.actuality { font-size: .86rem; color: var(--ink-faint); border-top: 1px solid var(--line); padding-top: 10px; max-width: var(--measure); }
.provenance { background: var(--surface); border: 1px dashed var(--line-2); border-radius: var(--radius); padding: 16px 18px; margin-top: 18px; max-width: 860px; }
.provenance h2 { font-size: .8rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--slate); }
.meta-row { margin-top: 16px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.status-badge { display: inline-block; font-size: .78rem; font-weight: 800; padding: 3px 10px; border-radius: 6px; background: var(--ink); color: #fff; }

.site-footer { margin-top: 30px; background: var(--surface); border-top: 1px solid var(--line); padding: 28px 0 18px; font-size: .92rem; color: var(--ink-soft); }
.footer-grid { display: grid; gap: 22px; }
@media (min-width: 820px) { .footer-grid { grid-template-columns: 1.4fr 1fr 1fr; } }
.footer-brand { font-weight: 800; color: var(--ink); font-size: 1.1rem; margin-bottom: 4px; }
.site-footer h2 { font-size: .76rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-faint); }
.site-footer ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.footer-bottom { border-top: 1px solid var(--line); margin-top: 18px; padding-top: 12px; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; font-size: .82rem; }

@media print { .site-header, .site-footer, .skip-link, .filter, .side-toc { display: none !important; } body { background: #fff; } }

/* === Статьи-размещения и список публикаций (postbuild.py) === */
.pub-wrap { padding-top: 8px; padding-bottom: 48px; }
.pub { max-width: 780px; background: #ffffff; color: #1b1b1f; border: 1px solid #e3e1dc; border-radius: 14px; padding: clamp(18px, 4vw, 44px); overflow-wrap: break-word; }
.pub-kicker { margin: 0 0 8px; font-size: .78rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #0f766e; }
.pub h1 { font-family: var(--sans); font-size: clamp(1.55rem, 3.4vw, 2.25rem); line-height: 1.2; margin: 0 0 14px; }
.pub-lead { font-size: 1.12rem; line-height: 1.6; margin: 0; }
.pub-meta { margin: 18px 0 22px; padding: 8px 0; border-top: 1px solid #e3e1dc; border-bottom: 1px solid #e3e1dc; font-size: .85rem; color: #4b4a52; }
.pub-toc { margin: 0 0 8px; padding: 12px 18px; border: 1px solid #e3e1dc; border-radius: 14px; }
.pub .pub-toc h2 { font-size: .95rem; margin: 0 0 6px; font-family: inherit; }
.pub-toc ol { margin: 0; padding-left: 1.3em; }
.pub-toc li { margin: 3px 0; }
.pub h2 { font-family: var(--sans); font-size: 1.35rem; line-height: 1.3; margin: 30px 0 10px; scroll-margin-top: 16px; }
.pub p, .pub li { line-height: 1.65; }
.pub ul, .pub ol { padding-left: 1.3em; }
.pub li { margin: 5px 0; }
.pub a { color: #6d28d9; text-decoration-thickness: 1px; text-underline-offset: 2px; overflow-wrap: anywhere; }
.pub-note { margin: 18px 0; padding: 12px 16px; background: #dcf3f0; border-left: 4px solid #0f766e; border-radius: 0 14px 14px 0; }
.pub-note p { margin: 0; }
.pub-sources { margin-top: 28px; font-size: .92rem; }
.pub-foot { margin-top: 30px; padding-top: 12px; border-top: 1px solid #e3e1dc; font-size: .92rem; }
.pub-list { list-style: none; margin: 16px 0 24px; padding: 0; display: grid; gap: 12px; }
.pub-list li { background: #ffffff; border: 1px solid #e3e1dc; border-radius: 14px; padding: 14px 16px; }
.pub-list a { font-family: var(--sans); font-weight: 700; font-size: 1.05rem; color: #6d28d9; overflow-wrap: anywhere; }
.pub-list p { margin: 6px 0 4px; color: #4b4a52; font-size: .95rem; line-height: 1.5; }
.pub-list-meta { font-size: .8rem; color: #4b4a52; }
.pub { margin-top: 14px; }
