/* ===== Журнальный стиль =====
   Подключается после style.css и переопределяет его.
   Идея: справочник как хорошее медицинское издание — шрифт с засечками в заголовках,
   линейки вместо карточек с тенями, нумерация, минимум скруглений.
   Палитра «Чернила и кирпич»: холодная бумага, графитовый текст,
   чернильно-синий — ссылки и кнопки, кирпичный — номера, метки и фокус.
   Фон — светлая журнальная бумага #fafaf8 (в main была газетная #f4f3ef):
   почти белый, с едва заметным тёплым оттенком; подложки и линии осветлены так же.
   Все пары текст/фон проверены: ≥4,5:1 для текста, ≥3:1 для рамок полей. */

:root {
  --bg: #fafaf8;
  --surface: #fafaf8;
  --surface-2: #f2f1ed;
  --text: #1c2026;
  --muted: #5a616b;
  --line: #e4e2dc;
  --rule: #1c2026;           /* толстая линейка над разделами */
  --primary: #28497a;
  --primary-strong: #1a3358;
  --primary-soft: #e4e9f1;
  --accent: #a3432d;
  --accent-soft: #f5e5df;
  --accent-text: #8c3625;
  --focus: #a3432d;
  --field-line: #7a808a;
  --on-primary: #ffffff;
  --num: #a3432d;
  --radius: 3px;
  --shadow: none;
  --font: "Golos Text", -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-head: "Source Serif 4", "PT Serif", Georgia, "Times New Roman", serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14171c;
    --surface: #14171c;
    --surface-2: #1c2027;
    --text: #e6e8ec;
    --muted: #a3aab5;
    --line: #2c323b;
    --rule: #d8dce3;
    --primary: #8fb2e3;
    --primary-strong: #b7cdee;
    --primary-soft: #1f2b3e;
    --accent: #e39279;
    --accent-soft: #3a2520;
    --accent-text: #e39279;
    --focus: #e39279;
    --field-line: #66707d;
    --on-primary: #0f1724;
    --num: #e39279;
  }
}
/* Тёмная тема, выбранная вручную переключателем в шапке (те же значения, что выше) */
:root[data-theme="dark"] {
  --bg: #14171c;
  --surface: #14171c;
  --surface-2: #1c2027;
  --text: #e6e8ec;
  --muted: #a3aab5;
  --line: #2c323b;
  --rule: #d8dce3;
  --primary: #8fb2e3;
  --primary-strong: #b7cdee;
  --primary-soft: #1f2b3e;
  --accent: #e39279;
  --accent-soft: #3a2520;
  --accent-text: #e39279;
  --focus: #e39279;
  --field-line: #66707d;
  --on-primary: #0f1724;
  --num: #e39279;
}

/* ---------- Переключатель темы ---------- */
.theme-toggle { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; flex: none;
  background: none; border: 1px solid transparent; border-radius: var(--radius); color: var(--text); cursor: pointer; padding: 0; }
.theme-toggle:hover { color: var(--primary); border-color: var(--line); }
.theme-toggle svg { width: 20px; height: 20px; }
.theme-toggle .ti { display: none; }
.theme-toggle[data-mode="auto"] .ti-auto,
.theme-toggle[data-mode="light"] .ti-light,
.theme-toggle[data-mode="dark"] .ti-dark { display: block; }
@media (max-width: 1040px) {
  .theme-toggle { margin-left: auto; }
  .theme-toggle + .nav-toggle { margin-left: 0; }
}

body { font: 17.5px/1.7 var(--font); font-feature-settings: "kern", "liga"; }
h1, h2, h3, h4 { font-family: var(--font-head); font-weight: 600; letter-spacing: -.012em; font-optical-sizing: auto; }
h1 { font-weight: 700; line-height: 1.12; }
h2 { line-height: 1.2; }
a { text-decoration-thickness: 1px; text-underline-offset: 3px; }

/* ---------- Шапка ---------- */
.site-header { background: var(--bg); border-bottom: 1px solid var(--line); box-shadow: 0 3px 0 -2px var(--rule); }
.header-row { min-height: 68px; }
.logo { font-family: var(--font-head); font-size: 1.45rem; font-weight: 700; letter-spacing: -.02em; gap: 8px; }
.logo svg { width: 24px; height: 24px; }
.main-nav { gap: 0 4px; }
.main-nav a { font-size: .92rem; padding: 8px 8px; border-radius: 0; }
.main-nav a:hover, .main-nav a[aria-current] { background: none; color: var(--primary); text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 8px; }
.header-search input { border-radius: var(--radius); background: transparent; }
@media (max-width: 1040px) {
  .main-nav { background: var(--bg); top: 68px; }
  .main-nav a { border-bottom: 1px solid var(--line); }
  .main-nav a:hover, .main-nav a[aria-current] { text-underline-offset: 4px; }
}

/* ---------- Общие элементы ---------- */
.btn { border-radius: var(--radius); font-weight: 500; }
.search-big input, .field input, .field select, .diary-table td input, .seg { border-radius: var(--radius); }
.crumbs { font-size: .84rem; }
.crumbs a { text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }

/* Карточки на остальных страницах: без теней и скруглений, линии вместо рамок */
.card, .steps a, .path, .tool, .toc-inline, .table-wrap { border-radius: var(--radius); box-shadow: none; }
.card { background: transparent; border: 0; border-top: 1px solid var(--line); border-radius: 0; padding: 14px 0 16px; }
a.card:hover { box-shadow: none; border-color: var(--line); }
a.card:hover .card-title { color: var(--primary); text-decoration: underline; }
.card-title { font-family: var(--font-head); font-size: 1.12rem; font-weight: 600; }
.card-drug, .card-tool { border-top: 1px solid var(--line); }
.card-eyebrow { text-transform: none; letter-spacing: 0; font-size: .85rem; font-weight: 500; color: var(--muted); }
.chip { border-radius: var(--radius); background: transparent; }
.block-tint { background: transparent; border-top: 1px solid var(--line); border-radius: 0; padding: 0; }
.tool { background: var(--surface-2); border: 0; border-top: 2px solid var(--rule); }

/* ---------- Главная ---------- */
.ed-mast { padding-top: 44px; padding-bottom: 36px; }
.ed-mast-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 56px; align-items: end; }
.ed-kicker { font-family: var(--font-head); font-style: italic; font-size: 1.1rem; color: var(--muted); margin: 0 0 10px; }
.ed-mast h1 { font-size: clamp(2.1rem, 5.2vw, 3.6rem); max-width: 21ch; margin: 0 0 18px; text-wrap: balance; }
.ed-lead { font-family: var(--font-head); font-size: clamp(1.15rem, 1.8vw, 1.35rem); line-height: 1.5; max-width: 40ch; margin: 0 0 26px; }
.ed-search { display: flex; max-width: 520px; border-bottom: 2px solid var(--rule); }
.ed-search input { flex: 1; min-width: 0; border: 0; background: transparent; padding: 12px 2px; font-size: 1.05rem; }
.ed-search input:focus-visible { outline-offset: 4px; }
.ed-search button { background: none; border: 0; color: var(--primary); font: inherit; font-weight: 600; padding: 12px 4px 12px 16px; cursor: pointer; }
.ed-search button:hover { color: var(--primary-strong); text-decoration: underline; }
.ed-colophon { border-top: 2px solid var(--rule); padding-top: 14px; font-size: .9rem; color: var(--muted); }
.ed-colophon p { margin: 0 0 10px; }
.ed-colophon strong { display: block; font-family: var(--font-head); font-size: 2.6rem; line-height: 1; color: var(--text); font-weight: 600; }

.ed-paths { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.ed-paths li + li { border-left: 1px solid var(--line); }
.ed-paths a { display: block; height: 100%; padding: 26px 24px 28px; text-decoration: none; color: var(--text); }
.ed-paths li:first-child a { padding-left: 0; }
.ed-paths a:hover .ed-paths-title { color: var(--primary); text-decoration: underline; }
.ed-num { display: block; font-family: var(--font-head); font-size: 1.05rem; color: var(--num); font-weight: 600; font-variant-numeric: lining-nums; margin-bottom: 6px; }
.ed-paths-title { display: block; font-family: var(--font-head); font-size: 1.4rem; font-weight: 600; line-height: 1.25; }
.ed-paths-text { display: block; color: var(--muted); font-size: .95rem; margin-top: 6px; }

.ed-sec { margin: 56px 0 0; }
.ed-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px 16px; flex-wrap: wrap; border-top: 2px solid var(--rule); padding-top: 10px; margin-bottom: 6px; }
.ed-head h2 { margin: 0; font-size: clamp(1.5rem, 2.6vw, 1.95rem); }
.ed-head a { font-size: .92rem; text-decoration: none; }
.ed-head a:hover { text-decoration: underline; }
.ed-intro { color: var(--muted); margin: 4px 0 8px; max-width: 62ch; }

/* Указатель препаратов */
.ed-index { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); column-gap: 32px; }
.ed-index li { border-bottom: 1px solid var(--line); }
.ed-index a { display: block; padding: 14px 0 15px; text-decoration: none; color: var(--text); }
.ed-index-name { font-family: var(--font-head); font-size: 1.25rem; font-weight: 600; }
.ed-index-sub { margin-left: 8px; color: var(--muted); font-size: .9rem; }
.ed-index-text { display: block; color: var(--muted); font-size: .9rem; line-height: 1.45; margin-top: 2px; }
.ed-index a:hover .ed-index-name { color: var(--primary); text-decoration: underline; }

/* Две колонки: сравнения и ситуации */
.ed-two { display: grid; grid-template-columns: 1fr 1fr; gap: 0 48px; }
.ed-list { list-style: none; margin: 0; padding: 0; }
.ed-list li { border-bottom: 1px solid var(--line); }
.ed-list a { display: block; padding: 11px 0; text-decoration: none; color: var(--text); line-height: 1.4; }
.ed-list a:hover { color: var(--primary); text-decoration: underline; }
.ed-list-text { display: block; color: var(--muted); font-size: .9rem; margin-top: 2px; }
.ed-list a:hover .ed-list-text { text-decoration: none; }
.ed-list.ed-cols > li > a { font-family: var(--font-head); font-size: 1.12rem; font-weight: 600; padding: 14px 0; }
.ed-list.ed-cols .ed-list-text { font-family: var(--font); font-weight: 400; }

/* Курс по шагам */
.ed-steps { list-style: none; counter-reset: s; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 48px; }
.ed-steps li { counter-increment: s; border-bottom: 1px solid var(--line); }
.ed-steps a { display: grid; grid-template-columns: 3.2rem 1fr; padding: 16px 0; text-decoration: none; color: var(--text); }
.ed-steps a::before { content: counter(s, decimal-leading-zero); font-family: var(--font-head); font-size: 1.6rem; line-height: 1.1; color: var(--num); font-weight: 600; grid-row: span 2; }
.ed-steps-title { font-family: var(--font-head); font-size: 1.15rem; font-weight: 600; line-height: 1.3; }
.ed-steps-text { color: var(--muted); font-size: .92rem; line-height: 1.5; margin-top: 4px; }
.ed-steps a:hover .ed-steps-title { color: var(--primary); text-decoration: underline; }

/* Три колонки */
.ed-cols { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 32px; }
.ed-col-title { font-family: var(--font-head); font-size: 1.25rem; font-weight: 600; margin: 14px 0 4px; }
.ed-col-title a { color: var(--text); text-decoration: none; }
.ed-col-title a:hover { color: var(--primary); text-decoration: underline; }

/* Новости */
.ed-news { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 32px; }
.ed-news a { display: block; padding: 14px 0; text-decoration: none; color: var(--text); }
.ed-news time { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 4px; }
.ed-news span { font-family: var(--font-head); font-size: 1.15rem; font-weight: 600; line-height: 1.3; }
.ed-news a:hover span { color: var(--primary); text-decoration: underline; }

.home-text { max-width: 720px; margin-top: 56px; border-top: 2px solid var(--rule); padding-top: 4px; }

/* Текст раздела под карточками — на всю ширину сетки карточек */
.section-text { margin-top: 48px; border-top: 2px solid var(--rule); padding-top: 28px; }
.section-text .article { max-width: none; }

/* Статьи и тексты разделов: по ширине с переносами. Только абзацы и списки —
   заголовки, таблицы, карточка препарата и оглавление остаются без переносов.
   Переносим слова от 6 букв, на строке остаётся не меньше 3 букв («се-маглутид» запрещён). */
@media (min-width: 700px) {
  .article .prose p, .article .prose li {
    text-align: justify;
    hyphens: auto; -webkit-hyphens: auto;
    hyphenate-limit-chars: 6 3 3;
    -webkit-hyphenate-limit-before: 3; -webkit-hyphenate-limit-after: 3;
  }
  .article .prose .callout-title { text-align: left; hyphens: manual; }
}
/* Названия препаратов, компаний и исследований не переносятся; «ГПП-1», «СД-2» не разрываются */
.nohy { hyphens: manual; -webkit-hyphens: manual; }
.nobr { white-space: nowrap; }

@media (max-width: 960px) {
  .ed-mast-grid { grid-template-columns: 1fr; gap: 28px; }
  .ed-index { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ed-cols, .ed-news { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .ed-mast { padding-top: 28px; padding-bottom: 24px; }
  .ed-paths { grid-template-columns: 1fr; }
  .ed-paths li + li { border-left: 0; border-top: 1px solid var(--line); }
  .ed-paths a { padding: 18px 0; }
  .ed-index, .ed-two, .ed-steps { grid-template-columns: 1fr; }
  .ed-sec { margin-top: 44px; }
}

/* ---------- Статья ---------- */
.article-head { border-bottom: 1px solid var(--line); margin-bottom: 26px; }
.article h1 { font-size: clamp(1.95rem, 4.2vw, 2.9rem); margin: .25em 0 .45em; text-wrap: balance; }
.article-meta { font-size: .88rem; margin-bottom: 14px; }
.prose > p:first-child { font-family: var(--font-head); font-size: 1.28rem; line-height: 1.55; }
.prose h2 { font-size: clamp(1.5rem, 2.8vw, 1.85rem); margin-top: 2.1em; padding-top: 12px; border-top: 2px solid var(--rule); }
.prose h3 { font-size: 1.22rem; }
.prose strong { font-weight: 600; }

/* Карточка препарата — как паспорт в справочнике */
.drug-card { background: none; border: 0; border-top: 2px solid var(--rule); border-bottom: 1px solid var(--line); border-radius: 0; gap: 0; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.drug-card div { background: none; padding: 12px 18px 12px 0; border-bottom: 1px solid var(--line); }
.drug-card dt { text-transform: none; letter-spacing: 0; font-size: .82rem; }
.drug-card dd { font-family: var(--font-head); font-size: 1.08rem; }

/* Врезки: только линия слева, без заливки */
.callout { background: none; border-radius: 0; border-left-width: 3px; padding: 4px 0 4px 20px; }
.callout-title { font-family: var(--font-head); font-size: 1.1rem; }
.callout-warning { background: var(--danger-soft); padding: 12px 18px 12px 20px; }

/* Таблицы: горизонтальные линейки, без рамки */
.table-wrap { border: 0; border-top: 2px solid var(--rule); border-bottom: 1px solid var(--rule); border-radius: 0; background: none; }
th { background: none; border-bottom: 1px solid var(--rule); font-size: .86rem; font-weight: 600; }
th, td { padding: 10px 14px 10px 0; }

/* Оглавление: номера разделов */
.toc ol { list-style: none; padding-left: 0; counter-reset: t; }
.toc li { counter-increment: t; display: grid; grid-template-columns: 1.9rem 1fr; }
.toc li::before { content: counter(t); font-family: var(--font-head); color: var(--num); font-weight: 600; }
.toc-side { border-left: 0; border-top: 2px solid var(--rule); padding: 10px 0 0; }
.toc-title { text-transform: none; letter-spacing: 0; font-family: var(--font-head); font-size: 1.05rem; color: var(--text); }
.toc-inline { background: none; border: 0; border-top: 2px solid var(--rule); border-bottom: 1px solid var(--line); border-radius: 0; padding: 10px 0; }

.disclaimer { border: 0; border-top: 1px solid var(--line); border-radius: 0; padding: 14px 0 0; }
.related h2 { font-size: 1.35rem; border-top: 2px solid var(--rule); padding-top: 10px; }
.related .cards { grid-template-columns: 1fr; gap: 0; margin-top: 0; }
.related .card { border-top: 0; border-bottom: 1px solid var(--line); }

/* ---------- Подвал ---------- */
.site-footer { background: var(--surface-2); border-top: 2px solid var(--rule); }
.footer-name { font-family: var(--font-head); font-size: 1.35rem; }
.cookie { border-radius: var(--radius); background: var(--bg); }
