/* Родословная — общий стиль. Цвета и шрифты взяты из книги. */

@font-face { font-family: "Plex"; font-weight: 400; font-style: normal; font-display: swap;
  src: url(fonts/IBMPlexSerif-Regular-Cyrillic.woff2) format("woff2"); unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Plex"; font-weight: 400; font-style: normal; font-display: swap;
  src: url(fonts/IBMPlexSerif-Regular-Latin1.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2122; }
@font-face { font-family: "Plex"; font-weight: 400; font-style: italic; font-display: swap;
  src: url(fonts/IBMPlexSerif-Italic-Cyrillic.woff2) format("woff2"); unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Plex"; font-weight: 400; font-style: italic; font-display: swap;
  src: url(fonts/IBMPlexSerif-Italic-Latin1.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2122; }
@font-face { font-family: "Plex"; font-weight: 600; font-style: normal; font-display: swap;
  src: url(fonts/IBMPlexSerif-SemiBold-Cyrillic.woff2) format("woff2"); unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Plex"; font-weight: 600; font-style: normal; font-display: swap;
  src: url(fonts/IBMPlexSerif-SemiBold-Latin1.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2122; }
@font-face { font-family: "Cond"; font-weight: 600; font-display: swap;
  src: url(fonts/RobotoCondensed-600-cyr.woff2) format("woff2"); unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Cond"; font-weight: 600; font-display: swap;
  src: url(fonts/RobotoCondensed-600-lat.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2122; }

:root {
  color-scheme: light;
  --paper: #f2f1e3;
  --paper-2: #e9e6d3;
  --paper-3: #dfdac4;
  --ink: #1d1b19;
  --ink-2: #4b4640;
  --thread: #9e2a2b;
  --thread-2: #7f1f20;
  --line: rgba(29, 27, 25, .14);
  --shadow: 0 1px 2px rgba(29, 27, 25, .06), 0 6px 20px -8px rgba(29, 27, 25, .18);
  --serif: "Plex", "PT Serif", Georgia, "Times New Roman", serif;
  --cond: "Cond", "Roboto Condensed", "Arial Narrow", sans-serif;
  --r: 10px;
  --gutter: 16px;
  --tap: 56px;
}

/* На телефонах берём системный размер текста: если у человека в настройках крупный шрифт, сайт его подхватит. */
@media (pointer: coarse) {
  @supports (font: -apple-system-body) { html { font: -apple-system-body; } }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; } /* иначе display у класса перебивает атрибут hidden */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: var(--serif); font-size: 1.125rem; line-height: 1.6;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
img { max-width: 100%; display: block; }
a { color: inherit; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--thread); outline-offset: 3px; border-radius: 4px; }

.kicker { font-family: var(--cond); font-weight: 600; color: var(--thread); letter-spacing: .02em; font-size: 1rem; }
.caps { font-family: var(--cond); font-weight: 600; text-transform: uppercase; letter-spacing: .015em; line-height: 1.1; }
.muted { color: var(--ink-2); }
.wrap { width: 100%; max-width: 760px; margin: 0 auto; padding: 0 var(--gutter); }
.icon { width: 1.3em; height: 1.3em; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* кнопки */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  min-height: var(--tap); padding: .5em 1.2em; border-radius: var(--r);
  border: 1.5px solid var(--ink); background: transparent; text-decoration: none;
  font-family: var(--cond); font-weight: 600; font-size: 1.125rem; letter-spacing: .01em;
  cursor: pointer; transition: background-color .15s ease, color .15s ease, transform .1s ease;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
  max-width: 100%; overflow-wrap: anywhere; text-align: center; /* крупный шрифт: текст кнопки переносится */
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--ink); color: var(--paper); }
.btn-primary:hover { background: #33302c; }
.btn-ghost:hover { background: var(--paper-2); }
.btn-red { border-color: var(--thread); background: var(--thread); color: #fff; }
.btn-red:hover { background: var(--thread-2); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .35; pointer-events: none; }
.btn-block { width: 100%; }

.toast {
  position: fixed; left: 50%; bottom: calc(160px + env(safe-area-inset-bottom)); transform: translate(-50%, 12px);
  background: var(--ink); color: var(--paper); padding: .7em 1.1em; border-radius: var(--r);
  font-family: var(--cond); font-weight: 600; opacity: 0; pointer-events: none; transition: .2s ease; z-index: 50;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- главная ---------- */

body.home { line-height: 1.55; }
.skip {
  position: fixed; top: 8px; left: 8px; z-index: 80; padding: 12px 14px; border-radius: 8px;
  background: var(--ink); color: var(--paper); text-decoration: none; transform: translateY(-200%);
}
.skip:focus { transform: none; }
.shell { max-width: 1200px; margin: 0 auto; padding: 0 20px; }
.masthead {
  min-height: 52px; display: flex; align-items: center; border-bottom: 1px solid var(--line);
  font-family: var(--cond); font-weight: 600; font-size: 1rem; letter-spacing: .06em; text-transform: uppercase;
}
.cover-layer { position: absolute; inset: 0; width: 100%; height: 100%; }
.film img, .opening-cover img { position: absolute; max-width: none; }

/* первый экран: заголовок и обложка рядом, список родов сразу под ними — всё обычным потоком,
   чтобы крупный шрифт в настройках телефона ничего не налезал друг на друга */
.top { display: grid; grid-template-columns: minmax(0, 1fr); padding: 22px 0 8px; }
/* абзац и картинка рядом; при крупном шрифте, когда абзацу не остаётся 9 его «em» (было бы по слову в строке),
   картинка уходит под абзац */
.intro {
  --film-w: clamp(110px, 36vw, 170px);
  display: flex; flex-wrap: wrap; column-gap: 16px; align-items: flex-start;
}
.intro h1 {
  flex: 1 0 100%; margin: 0; font-family: var(--serif); font-weight: 400;
  font-size: min(2.375rem, 11.5vw); line-height: 1.12; letter-spacing: -.03em; overflow-wrap: anywhere;
}
.intro h1 span, .intro h1 em { display: block; }
.intro h1 em { color: var(--thread); }
.lead { flex: 1 1 9em; min-width: 0; margin: 14px 0 0; color: var(--ink-2); font-size: 1.0625rem; line-height: 1.5; overflow-wrap: anywhere; }
.film { flex: none; position: relative; width: var(--film-w); aspect-ratio: 1242 / 1758; margin: 16px auto 0; }

.families { padding-top: 20px; }
.families h2 {
  margin: 0; padding-bottom: 12px; border-bottom: 1.5px solid var(--ink);
  font-family: var(--cond); font-weight: 600; font-size: 1.5rem; line-height: 1.2;
}
.family {
  display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 18px; align-items: center;
  padding: 16px 6px 16px 0; border-bottom: 1px solid var(--line); text-decoration: none;
  -webkit-tap-highlight-color: transparent; transition: background-color .15s ease;
}
.family:hover { background: var(--paper-2); }
.family:active { background: var(--paper-3); }
.family .mark { width: 72px; height: 88px; object-fit: contain; }
.family .info { min-width: 0; }
/* фамилия — одной строкой и при крупном шрифте: не крупнее, чем помещается самая длинная («Шайхутдиновы» ≈ 6,6 em)
   в колонку рядом с тамгой (окно минус поля 40, тамга 72, промежуток 18, отступ 6 px) */
.family h3 { margin: 0 0 4px; font-family: var(--cond); font-weight: 600; font-size: min(1.75rem, calc((100vw - 136px) / 6.6));
  line-height: 1.15; overflow-wrap: anywhere; }
.family .who, .family .where { display: block; font-size: 1.0625rem; line-height: 1.45; }
.family .where { color: var(--ink-2); }
.family .go { display: inline-flex; align-items: center; gap: 8px; margin-top: 6px; color: var(--thread);
  font-family: var(--cond); font-weight: 600; font-size: 1.0625rem; }

.resume {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 20px;
  padding: 14px 16px; border-radius: var(--r); background: var(--thread); color: #fffdf4; text-decoration: none;
}
.resume:hover { background: var(--thread-2); }
.resume strong { display: block; font-family: var(--cond); font-weight: 600; font-size: 1.3rem; line-height: 1.2; }
#resume-detail { display: block; font-size: 1rem; margin-top: 2px; }
.resume > span { min-width: 0; overflow-wrap: anywhere; }
.resume .icon { width: 28px; height: 28px; }

.archive { display: grid; gap: 20px; margin-top: 28px; padding: 32px 0; border-top: 1.5px solid var(--ink); }
.archive h2 { margin: 0; font-family: var(--serif); font-weight: 400; font-size: 2rem; line-height: 1.2; letter-spacing: -.02em; }
.archive p { margin: 14px 0 0; color: var(--ink-2); font-size: 1.0625rem; max-width: 36ch; }
.download-list { border-top: 1px solid var(--line); }
.download {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 76px;
  padding: 14px 6px 14px 0; border-bottom: 1px solid var(--line); text-decoration: none;
  font-family: var(--cond); font-weight: 600; font-size: 1.25rem; line-height: 1.3;
}
.download:hover { background: var(--paper-2); }
.download small { display: block; margin-top: 2px; font-family: var(--serif); font-weight: 400; font-size: 1rem; color: var(--ink-2); }
.download .icon { color: var(--thread); width: 1.4em; height: 1.4em; }
.download-all { color: var(--thread); }
.doc-note { display: grid; gap: 8px; padding: 24px 0; border-top: 1px solid var(--line); }
.doc-note h2 { margin: 0; font-family: var(--cond); font-weight: 600; font-size: 1.25rem; }
.doc-note p { margin: 0; color: var(--ink-2); font-size: 1.0625rem; line-height: 1.6; }
.home-foot { display: grid; gap: 4px; padding: 22px 0 calc(28px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line);
  color: var(--ink-2); font-size: .95rem; }

@media (min-width: 900px) {
  .shell { padding: 0 48px; }
  .masthead { min-height: 76px; font-size: 1.125rem; }
  .top { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 72px; padding: 48px 0 24px; align-items: start; }
  .intro { --film-w: 280px; }
  .intro h1 { font-size: clamp(3rem, 5vw, 4.25rem); }
  .lead { flex-basis: 100%; }
  .film { margin: 32px auto 0; }
  .families { padding-top: 0; }
  .archive, .doc-note { grid-template-columns: 1fr 1fr; column-gap: 72px; }
  .home-foot { display: flex; justify-content: space-between; }
}

/* вступление: обложка книги на весь экран, затем уезжает в своё место (.film); управляет home.js */
.opening { display: none; }
[data-intro="on"] .opening { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; }
.opening-bg { position: absolute; inset: 0; background: var(--paper); }
.opening-cover {
  position: relative; width: min(94vw, calc(86vh * .7065)); aspect-ratio: 1242 / 1758;
  container-type: inline-size; will-change: transform;
}
@supports (height: 1svh) { .opening-cover { width: min(94vw, calc(86svh * .7065)); } }
.o-label {
  position: absolute; transform: translateY(-50%); white-space: nowrap; color: var(--ink);
  font-family: var(--cond); font-weight: 600; text-transform: uppercase; letter-spacing: .02em; line-height: 1.1;
  font-size: 15px; font-size: clamp(11px, 4.4cqw, 26px); /* «титры» — размер от кадра, не от настроек шрифта */
}
.o-label small { display: block; margin-top: 2px; font-family: var(--serif); font-weight: 400; font-size: .8em;
  text-transform: none; letter-spacing: 0; color: var(--ink-2); }
.o-label.left { text-align: right; }
/* до старта анимаций — пустая бумага, без мигания готовой картинкой */
[data-intro="on"] .o-thread { clip-path: inset(0 0 100% 0); }
[data-intro="on"] .o-tamga, [data-intro="on"] .o-label { opacity: 0; }
[data-intro="on"] .film { visibility: hidden; }

section.block { padding: 36px 0 8px; }
section.block > h2 { font-size: 1.6rem; margin: 0 0 16px; }

.note { font-size: 1rem; color: var(--ink-2); border-left: 3px solid var(--thread); padding: 4px 0 4px 14px; margin: 20px 0; }
.downloads { display: grid; gap: 10px; }
.dl {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; min-height: var(--tap); padding: 10px 14px;
  border: 1px solid var(--line); border-radius: var(--r); text-decoration: none; background: transparent;
}
.dl:hover { background: var(--paper-2); }
.dl b { font-family: var(--cond); font-weight: 600; font-size: 1.1rem; min-width: 0; overflow-wrap: anywhere; }
.dl span { margin-left: auto; color: var(--ink-2); font-size: .95rem; white-space: nowrap; }
footer.site { padding: 36px var(--gutter) calc(40px + env(safe-area-inset-bottom)); text-align: center; color: var(--ink-2); font-size: .95rem; }

/* ---------- страница ветки ---------- */

.topbar {
  position: sticky; top: 0; z-index: 20; background: rgba(242, 241, 227, .94);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.topbar .wrap { display: flex; align-items: center; gap: 8px; min-height: 60px; }
.back { display: inline-flex; align-items: center; gap: .35em; min-height: 48px; padding: 0 10px 0 4px; margin-left: -4px;
  text-decoration: none; font-family: var(--cond); font-weight: 600; font-size: 1.1rem; border-radius: 8px; }
.back:hover { background: var(--paper-2); }

.branch-hero { text-align: center; padding: 28px 0 4px; }
/* фамилия всегда в одну строку: размер от ширины экрана и длины слова (--chars задаёт branch.js) */
.branch-hero h1 { font-size: min(4rem, calc((min(100vw, 760px) - 2 * var(--gutter)) / (var(--chars, 10) * .66))); white-space: nowrap; margin: 4px 0 14px; }
.hero-tamga { display: block; height: clamp(150px, 46vw, 260px); width: auto; max-width: 100%; margin: 0 auto 16px; object-fit: contain; }
.hero-meta { margin: 0; font-size: 1.125rem; line-height: 1.45; }
.hero-meta span { display: block; margin-top: 2px; color: var(--ink-2); font-size: 1rem; }

/* «Тамга рода» */
/* при крупном шрифте пара встаёт друг под другом */
.tamga-pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 9.5rem), 1fr)); gap: 12px; margin: 0 0 20px; }
.tamga-pair figure { margin: 0; min-width: 0; }
.tp-img { aspect-ratio: 1; display: grid; place-items: center; overflow: hidden; border-radius: var(--r);
  background: var(--paper-3); border: 1px solid var(--line); }
.tp-img img { width: 100%; height: 100%; object-fit: contain; }
.tp-img.paper { background: var(--paper-2); padding: 12px; }
.tamga-pair figcaption { margin-top: 8px; font-size: 1rem; line-height: 1.35; color: var(--ink-2); overflow-wrap: anywhere; }
.tamga-pair figcaption b { display: block; color: var(--ink); font-family: var(--cond); font-weight: 600; font-size: 1.125rem; }
.tamga-quote { margin: 0 0 18px; padding: 4px 0 4px 16px; border-left: 3px solid var(--thread); font-style: italic; font-size: 1.125rem; line-height: 1.5; }
.tamga-quote cite { display: block; margin-top: 8px; font-style: normal; font-size: .95rem; line-height: 1.4; color: var(--ink-2); }
.tamga-story p { margin: 0 0 14px; }
.tamga-story .btn { margin-top: 6px; }
.branch-actions { display: grid; gap: 12px; margin: 24px 0 8px; }
@media (min-width: 640px) { .branch-actions { grid-template-columns: 1fr 1fr; } }

.sections { list-style: none; padding: 0; margin: 0; counter-reset: s; border-top: 1px solid var(--line); }
.sections li { border-bottom: 1px solid var(--line); }
.sections a {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 14px; align-items: baseline;
  padding: 14px 4px; min-height: var(--tap); text-decoration: none; line-height: 1.4;
}
.sections a > span:first-child { overflow-wrap: anywhere; }
.sections a:hover { background: var(--paper-2); }
.sections .pg { font-family: var(--cond); font-weight: 600; color: var(--thread); white-space: nowrap; font-size: 1rem; text-align: right; }
.sections .here { font-weight: 600; }
.sections .here .pg::after { content: "вы здесь"; display: block; color: var(--ink-2); } /* отдельной строкой — иначе при крупном шрифте не помещается */

/* ---------- читалка ---------- */

/* запас под фиксированной нижней панелью — по её настоящей высоте (--nav-pad ставит reader.js), чтобы при крупном
   шрифте последние строки выходили из-под панели; элемент с фокусом клавиатуры браузер выводит между липкой
   шапкой (--bar-pad) и нижней панелью — учитывать нужно обе, иначе одна из них его закроет */
body.reader { padding-bottom: var(--nav-pad, calc(150px + env(safe-area-inset-bottom))); }
html { scroll-padding: var(--bar-pad, 0px) 0 var(--nav-pad, 0px); }
/* шапка: «≡ К разделам  Род Шавалиевых  стр. 8» одной строкой; длинное название рода сокращается многоточием,
   номер страницы — никогда */
.r-title { min-width: 0; flex: 1; display: flex; flex-wrap: wrap; align-items: baseline; column-gap: .45em; }
/* не хватает места («Род Шайхутдиновых» на узком телефоне) — номер уходит под род, шапка той же высоты */
.r-title b { min-width: 0; max-width: 100%; font-family: var(--cond); font-weight: 600; font-size: 1.05rem; line-height: 1.15;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#rt-count { flex: none; white-space: nowrap; font-size: .95rem; line-height: 1.2; color: var(--ink-2); }

.r-tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 12px 0; }
/* при крупном шрифте на узком экране кнопки группы переносятся на следующую строку внутри рамки;
   разделители — тенью: у крайних кнопок строки она уходит за рамку и обрезается */
.seg { display: inline-flex; flex-wrap: wrap; max-width: 100%; border: 1.5px solid var(--ink); border-radius: var(--r); overflow: hidden; }
.seg button {
  min-height: 48px; padding: 0 14px; border: 0; background: transparent; cursor: pointer;
  font-family: var(--cond); font-weight: 600; font-size: 1.05rem; display: inline-flex; align-items: center; gap: .4em;
}
.seg button + button { box-shadow: -1.5px -1.5px 0 var(--ink); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.seg button[disabled] { opacity: .35; }
.tool { min-height: 48px; padding: 0 14px; font-size: 1.05rem; }
/* лупа и размер шрифта — у правого края ряда; лупа без подписи (подпись — aria-label) */
.r-tools .sizes, .r-tools .zoom-btn { margin-left: auto; }
.zoom-btn { min-width: 48px; padding: 0 10px; }
.zoom-btn .icon { width: 1.6em; height: 1.6em; }
/* одна страница, уменьшенная под высоту окна (reader.js fitPage), — по центру */
#content > .sheet { margin-inline: auto; }

.sheet { position: relative; background: #fff; box-shadow: var(--shadow); border-radius: 4px; overflow: hidden; aspect-ratio: .7071; }
.sheet img { width: 100%; height: 100%; object-fit: contain; cursor: zoom-in; transition: opacity .2s ease; }
.sheet.loading img { opacity: 0; }
.sheet.loading::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, .55) 50%, transparent 70%) var(--paper-2);
  background-size: 200% 100%; animation: shimmer 1.2s linear infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }
.sheet-error { position: absolute; inset: 0; display: grid; place-content: center; gap: 14px; text-align: center; padding: 24px; background: var(--paper-2); }
.hidden-note {
  position: absolute; left: 12px; right: 12px; top: 50%; transform: translateY(-50%);
  background: rgba(29, 27, 25, .92); color: var(--paper); padding: 16px 18px; border-radius: var(--r);
  font-size: 1rem; line-height: 1.45; text-align: center;
}
.hidden-note b { display: block; font-family: var(--cond); font-weight: 600; font-size: 1.15rem; margin-bottom: 4px; }

.text-page { --fs: 1.2rem; font-size: var(--fs); line-height: 1.65; padding: 8px 0 24px; overflow-wrap: break-word; hyphens: manual; }
.text-page[data-size="1"] { --fs: 1.45rem; }
.text-page[data-size="2"] { --fs: 1.8rem; line-height: 1.55; }
.text-page p { margin: 0 0 .8em; }
/* строки внутри блока (поля карточки, строки записи) — переносом, как в книге */
.text-page p, .text-page h2, .text-page h3, .tbl-card dd, .tbl-grid td { white-space: pre-line; }
.text-page .fn { font-size: .82em; line-height: 1.45; color: var(--ink-2); margin: 0 0 .4em; }
.text-page .fn-first { border-top: 1px solid var(--line); padding-top: .8em; margin-top: 1.4em; }
/* таблицы */
.tbl-wrap { overflow-x: auto; margin: .4em 0 1.1em; }
.tbl-grid { border-collapse: collapse; width: 100%; font-size: .9em; line-height: 1.35; }
.tbl-grid th, .tbl-grid td { border: 1px solid var(--line); padding: .35em .5em; text-align: left; vertical-align: top; }
.tbl-grid th { font-family: var(--cond); font-weight: 600; background: var(--paper-2); }
.tbl-cards { margin: .4em 0 1.1em; }
.tbl-group, .tbl-title { font-weight: 600; margin: 1em 0 .5em; white-space: pre-line; }
.tbl-grid .tbl-group-row th { background: none; font-family: inherit; }
.tbl-card { margin: 0 0 .7em; padding: .6em .8em; border: 1px solid var(--line); border-radius: 8px; background: rgba(255, 255, 255, .45); }
.tbl-card > div + div { margin-top: .35em; }
.tbl-card dt { font-family: var(--cond); font-weight: 600; font-size: .78em; color: var(--ink-2); line-height: 1.25; }
.tbl-card dd { margin: 0; line-height: 1.4; }
.text-page h2 { font-family: var(--cond); font-weight: 600; text-transform: uppercase; font-size: 1.5em; line-height: 1.15; margin: .4em 0 .6em; color: var(--thread); }
.text-page h3 { font-family: var(--serif); font-weight: 600; font-size: 1.1em; line-height: 1.3; margin: 1.2em 0 .5em; }
.text-page .cap { font-weight: 600; font-size: .82em; line-height: 1.4; color: var(--ink-2); margin: 1.2em 0 .4em; }
.text-page .tr { font-style: italic; border-left: 3px solid var(--thread); padding-left: .8em; }
.text-page .pb { font-weight: 600; }
.text-page figure { margin: .6em 0 1.1em; }
.text-page figure button { display: block; width: 100%; padding: 0; border: 1px solid var(--line); background: #fff; cursor: zoom-in; border-radius: 4px; overflow: hidden; }
.text-page figcaption { font-size: .75em; color: var(--ink-2); margin-top: .3em; display: flex; align-items: center; gap: .3em; }
.page-end { display: flex; align-items: center; gap: 10px; color: var(--ink-2); font-size: .95rem; margin: 8px 0 0; }
.page-end::before, .page-end::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.navbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: rgba(242, 241, 227, .97); border-top: 1px solid var(--line);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  padding: 8px var(--gutter) calc(10px + env(safe-area-inset-bottom));
}
.navbar .inner { max-width: 760px; margin: 0 auto; }
/* номер страницы в нижней панели — только в низком виде (шапка там уезжает вместе с текстом), иначе он в шапке */
.pageinfo { display: none; text-align: center; line-height: 1.25; }
.pageinfo b { font-family: var(--cond); font-weight: 600; font-size: 1.15rem; }
.navbtns { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }  /* поровну, от подписей не зависит */
.navbtns .btn { min-height: 60px; font-size: 1.15rem; padding: .4em .6em; }
/* крупный шрифт на маленьком экране (.compact ставит reader.js): у «Предыдущая/Следующая» и «К разделам» —
   только значки (подписи остаются для экранного диктора), строка «… в роде …» скрыта */
body.compact .back .lbl, body.compact .navbtns .lbl { display: none; }
.navbar.icons-only .navbtns .lbl { display: none; }  /* подпись не помещается одной строкой (reader.js navLabels) */
body.compact .back { padding: 0 8px; }
/* низкое окно (.low ставит reader.js, когда обычные панели оставляют меньше трёх строк текста): шапка уезжает
   вместе с текстом, нижняя панель — одна строка «← Страница N из M →», кнопки не ниже 48 px.
   Невидимые копии панелей (.probe) — всегда в обычном виде: по ним reader.js и решает */
.navbar.probe { visibility: hidden; pointer-events: none; }
body.low .topbar:not(.probe) { position: static; }
body.low .navbar:not(.probe) { padding-top: 6px; padding-bottom: calc(6px + env(safe-area-inset-bottom)); }
body.low .navbar:not(.probe) .inner { display: grid; grid-template-columns: minmax(48px, 1fr) minmax(0, auto) minmax(48px, 1fr); align-items: center; gap: 10px; }
body.low .navbar:not(.probe) .navbtns { display: contents; }
body.low .navbar:not(.probe) #prev { grid-area: 1 / 1; }
body.low .navbar:not(.probe) .pageinfo { display: block; grid-area: 1 / 2; margin: 0; min-width: 0; }  /* в узком окне счётчик переносится, стрелки остаются в окне */
body.low .navbar:not(.probe) #next { grid-area: 1 / 3; }
body.low .navbar:not(.probe) .navbtns .btn { min-height: 48px; padding: .2em .6em; }

/* разворот на широком экране: две страницы целиком по высоте окна, панель режимов — в шапке, листание стрелками
   по бокам; нижней панели нет (номера страниц — в шапке и на самих страницах книги) */
body.spread { padding-bottom: 0; }
body.spread .navbar { display: none; }
body.spread main.wrap, .spread-bar .wrap { max-width: none; }
/* шапка разворота (.spread-bar): название не сжимается в ноль — если кнопкам рядом не хватает места (крупный
   шрифт), они уходят на вторую строку, а высоту листов reader.js считает от настоящей высоты шапки.
   Поместится ли разворот, reader.js узнаёт по невидимой копии шапки (.probe), не трогая живые кнопки. */
.spread-bar .wrap { gap: 2px 12px; flex-wrap: wrap; }
.spread-bar .r-title { flex: 1 1 15em; }
.spread-bar .r-tools { justify-content: flex-end; gap: 8px; padding: 6px 0; margin-left: auto; min-width: 0; }
.spread-bar .seg button, .spread-bar .tool { min-height: 44px; }
.topbar.probe { position: absolute; top: 0; left: 0; right: 0; visibility: hidden; pointer-events: none; }
.spread-view { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 8px 0; }
.spread-pages { display: flex; box-shadow: var(--shadow); }
.spread-pages .sheet { height: var(--sheet-h, 80vh); width: auto; flex: none; border-radius: 0; box-shadow: none; }
.spread-pages .sheet + .sheet { box-shadow: inset 10px 0 12px -10px rgba(0, 0, 0, .28); } /* корешок */
.spread-pages .sheet.blank { visibility: hidden; }
.spread-arrow {
  width: 56px; height: 56px; flex: none; display: grid; place-items: center; border-radius: 50%;
  border: 1.5px solid var(--ink); background: var(--paper); color: var(--ink); cursor: pointer;
}
.spread-arrow .icon { width: 28px; height: 28px; } /* в px: кнопка 56 px при любом шрифте, на это рассчитан ARROWS_W */
.spread-arrow:hover:not(:disabled) { background: var(--ink); color: var(--paper); }
.spread-arrow:disabled { opacity: .25; cursor: default; }

/* просмотр с увеличением */
.zoom { position: fixed; inset: 0; z-index: 60; background: #151412; display: none; touch-action: none; overscroll-behavior: contain; }
.zoom.open { display: block; }
.zoom-stage { position: absolute; inset: 0; overflow: hidden; }
.zoom-stage img { position: absolute; left: 0; top: 0; transform-origin: 0 0; max-width: none; user-select: none; -webkit-user-drag: none; will-change: transform; }
.zoom-bar {
  position: absolute; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
  padding: 10px 10px calc(10px + env(safe-area-inset-bottom)); background: rgba(21, 20, 18, .88);
}
.zoom-bar .btn { color: var(--paper); border-color: rgba(242, 241, 227, .6); min-height: 58px; font-size: 1rem; flex-direction: column; gap: 2px; padding: 4px; }
.zoom-bar .btn .icon { width: 1.5em; height: 1.5em; }
.zoom-hint { position: absolute; top: calc(12px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  color: var(--paper); background: rgba(21, 20, 18, .8); padding: 8px 14px; border-radius: 999px; font-size: .95rem; white-space: nowrap; transition: opacity .4s; }

/* первая подсказка: страница слегка «качается», намекая, что её можно листать */
@keyframes nudge { 0%, 100% { transform: none; } 30% { transform: translateX(-18px); } 60% { transform: translateX(6px); } }
.nudge { animation: nudge 1.1s ease .6s 1; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Крупный шрифт в настройках телефона (до 200%) на узком экране: длинные слова вроде «Мухаммедсадыкович»
   переносим внутри слова — это лучше, чем горизонтальная прокрутка. */
.tamga-quote, .tamga-story p, .hero-meta, .archive h2, .archive p, .download span, .doc-note p, .lead,
.family .who, .family .where, .text-page { overflow-wrap: anywhere; }
