/* ==========================================================================
   knigi.ws: читалка (fb2reader). Отдельная страница, knigi2.css не подключается.
   Раскладка как у Яндекс Книг: на компьютере две колонки-страницы, на телефоне одна,
   листание по экранам внутри серверной страницы (CSS columns + translate), либо обычная прокрутка.
   Оглавление:
   1. Токены (темы: белый, сепия, серый, чёрный)
   2. База
   3. Верхняя и нижняя панели, ползунок
   4. Всплывающие панели: настройки и меню «…»
   5. Раскладка: режим страниц и режим прокрутки
   6. Текст книги (FB2)
   7. Подсказка «Вы остановились», кнопки, навигация по страницам
   8. Реклама: экран R2 и полноэкранный блок
   9. Кнопка «Сохранить в цитаты»
   9а. Оглавление
   10. Адаптив, reduced-motion, печать
   ========================================================================== */


/* 1. ТОКЕНЫ
   -------------------------------------------------------------------------- */
/* Резервные шрифты с поправкой метрик (как в knigi2.css): шрифты Google грузятся без блокировки отрисовки, подмена почти без перерасчёта строк. Метрики сняты в Chrome 14.11.2026. */
@font-face { font-family: 'Golos Fallback'; src: local('Arial'), local('ArialMT'), local('Liberation Sans'); font-weight: 100 500; size-adjust: 105.46%; ascent-override: 92.93%; descent-override: 20.86%; line-gap-override: 0%; }
@font-face { font-family: 'Golos Fallback'; src: local('Arial Bold'), local('Arial-BoldMT'), local('Liberation Sans Bold'); font-weight: 600 900; size-adjust: 105.46%; ascent-override: 92.93%; descent-override: 20.86%; line-gap-override: 0%; }
@font-face { font-family: 'Golos Fallback R'; src: local('Roboto'), local('Roboto-Regular'); font-weight: 100 500; size-adjust: 104.12%; ascent-override: 94.12%; descent-override: 21.13%; line-gap-override: 0%; }
@font-face { font-family: 'Golos Fallback R'; src: local('Roboto Bold'), local('Roboto-Bold'); font-weight: 600 900; size-adjust: 104.12%; ascent-override: 94.12%; descent-override: 21.13%; line-gap-override: 0%; }
@font-face { font-family: 'Literata Fallback'; src: local('Georgia'); font-weight: 100 500; size-adjust: 104.68%; ascent-override: 112.73%; descent-override: 29.62%; line-gap-override: 0%; }
@font-face { font-family: 'Literata Fallback'; src: local('Georgia Bold'), local('Georgia-Bold'); font-weight: 600 900; size-adjust: 104.68%; ascent-override: 112.73%; descent-override: 29.62%; line-gap-override: 0%; }
@font-face { font-family: 'Literata Fallback R'; src: local('Noto Serif'), local('NotoSerif-Regular'); size-adjust: 97.25%; ascent-override: 121.34%; descent-override: 31.88%; line-gap-override: 0%; }
@font-face { font-family: 'PT Serif Fallback'; src: local('Georgia'); font-weight: 100 500; size-adjust: 99.32%; ascent-override: 104.72%; descent-override: 29.20%; line-gap-override: 0%; }
@font-face { font-family: 'PT Serif Fallback'; src: local('Georgia Bold'), local('Georgia-Bold'); font-weight: 600 900; size-adjust: 99.32%; ascent-override: 104.72%; descent-override: 29.20%; line-gap-override: 0%; }
@font-face { font-family: 'PT Serif Fallback R'; src: local('Noto Serif'), local('NotoSerif-Regular'); size-adjust: 92.27%; ascent-override: 112.71%; descent-override: 31.43%; line-gap-override: 0%; }

:root {
	color-scheme: dark;
	/* Серый (по умолчанию) */
	--bg: #2A2C2F;
	--surface: #343639;
	--border: #3F4245;
	--line: #54575B;
	--ctl: #868A8F;
	--text: #DCDAD3;
	--muted: #A9ABAD;
	--accent: #E7E4DB;
	--on-accent: #1E2022;
	--accent-text: #FF9078;
	--ribbon: #F0563A;
	--chip: #3A3D40;
	--ad-bg: #303235;
	--hover: rgba(231, 228, 219, .08);
	--focus: #FF9078;
	--sel-bg: #E7E4DB;
	--sel-text: #1E2022;
	--shadow: 0 14px 30px rgba(0, 0, 0, .45);
	--scrim: rgba(0, 0, 0, .6);

	--font-ui: 'Golos Text', 'Golos Fallback', 'Golos Fallback R', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
	--font-literata: 'Literata', 'Literata Fallback', 'Literata Fallback R', Georgia, 'Times New Roman', serif;
	--font-golos: 'Golos Text', 'Golos Fallback', 'Golos Fallback R', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
	--font-ptserif: 'PT Serif', 'PT Serif Fallback', 'PT Serif Fallback R', Georgia, 'Times New Roman', serif;
	--font-sans: system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
	--radius: 8px;
	--radius-lg: 12px;
	--ease: cubic-bezier(.2, .8, .2, 1);

	--bar-h: 56px;
	--foot-h: 76px;

	--read-font: var(--font-literata);
	--read-size: 18px;
	--read-lead: 1.7;
	--read-width: 680px;

	/* размеры страниц задаёт скрипт, значения ниже только на время до первой раскладки */
	--view-w: calc(100vw - 44px);
	--view-h: calc(100vh - 170px);
	--col-w: calc(100vw - 44px);
	--col-g: 0px;
}
html[data-rt="white"] {
	color-scheme: light;
	--bg: #FFFFFF;
	--surface: #F4F4F2;
	--border: #E2E2DE;
	--line: #C9C9C4;
	--ctl: #767672;
	--text: #1B1B1A;
	--muted: #5A5A56;
	--accent: #1B1B1A;
	--on-accent: #FFFFFF;
	--accent-text: #A82E18;
	--ribbon: #C93A22;
	--chip: #ECECE8;
	--ad-bg: #F7F7F5;
	--hover: rgba(27, 27, 26, .06);
	--focus: #1B1B1A;
	--sel-bg: #1B1B1A;
	--sel-text: #FFFFFF;
	--shadow: 0 14px 30px rgba(27, 27, 26, .16);
	--scrim: rgba(27, 27, 26, .5);
}
html[data-rt="sepia"] {
	color-scheme: light;
	--bg: #F4ECD8;
	--surface: #FAF5E8;
	--border: #E2D7BB;
	--line: #CBBF9E;
	--ctl: #857B63;
	--text: #2E2619;
	--muted: #5F553F;
	--accent: #2E2619;
	--on-accent: #F4ECD8;
	--accent-text: #7A4E00;
	--ribbon: #C93A22;
	--chip: #E8DFC6;
	--ad-bg: #F8F1E0;
	--hover: rgba(46, 38, 25, .07);
	--focus: #2E2619;
	--sel-bg: #2E2619;
	--sel-text: #F4ECD8;
	--shadow: 0 14px 30px rgba(46, 38, 25, .16);
	--scrim: rgba(46, 38, 25, .5);
}
html[data-rt="black"] {
	color-scheme: dark;
	--bg: #000000;
	--surface: #0E0E0F;
	--border: #1F2021;
	--line: #34363A;
	--ctl: #7A7E83;
	--text: #CFCDC6;
	--muted: #9A9C9F;
	--accent: #E2DFD6;
	--on-accent: #000000;
	--accent-text: #FF8163;
	--ribbon: #F0563A;
	--chip: #17181A;
	--ad-bg: #0A0A0B;
	--hover: rgba(226, 223, 214, .09);
	--focus: #FF8163;
	--sel-bg: #E2DFD6;
	--sel-text: #000000;
	--shadow: 0 14px 30px rgba(0, 0, 0, .8);
	--scrim: rgba(0, 0, 0, .75);
}

/* Настройки чтения (ставит скрипт в <head>) */
html[data-font="literata"] { --read-font: var(--font-literata); }
html[data-font="golos"] { --read-font: var(--font-golos); }
html[data-font="ptserif"] { --read-font: var(--font-ptserif); }
html[data-font="sans"] { --read-font: var(--font-sans); }
html[data-lead="tight"] { --read-lead: 1.5; }
html[data-lead="normal"] { --read-lead: 1.7; }
html[data-lead="loose"] { --read-lead: 1.95; }
html[data-width="narrow"] { --read-width: 560px; }
html[data-width="normal"] { --read-width: 680px; }
html[data-width="wide"] { --read-width: 800px; }
@media (min-width: 720px) {
	:root { --read-size: 20px; --foot-h: 64px; }
}


/* 2. БАЗА
   -------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html {
	-webkit-text-size-adjust: 100%; text-size-adjust: 100%;
	scrollbar-color: var(--line) var(--bg);
	scroll-padding-top: calc(var(--bar-h) + 16px);
	background: var(--bg);
}
body {
	margin: 0; min-height: 100vh;
	background: var(--bg); color: var(--text);
	font-family: var(--font-ui); font-size: 16px; line-height: 1.5;
	-webkit-font-smoothing: antialiased; font-variant-numeric: tabular-nums;
}
[hidden] { display: none !important; }
::selection { background: var(--sel-bg); color: var(--sel-text); }
a { color: var(--accent-text); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
button { font: inherit; }
.vh {
	position: absolute; width: 1px; height: 1px; overflow: hidden;
	clip-path: inset(50%); white-space: nowrap;
}
.r-skip {
	position: absolute; left: -9999px; top: 12px; z-index: 60;
	padding: 12px 16px; border-radius: var(--radius);
	background: var(--accent); color: var(--on-accent); font-weight: 500; text-decoration: none;
}
.r-skip:focus { left: 16px; }


/* 3. ВЕРХНЯЯ И НИЖНЯЯ ПАНЕЛИ, ПОЛЗУНОК
   -------------------------------------------------------------------------- */
.r-btn {
	display: inline-flex; align-items: center; justify-content: center; gap: 6px;
	min-width: 44px; min-height: 44px; padding: 0 10px;
	border: 0; border-radius: var(--radius); background: transparent; color: var(--text);
	font: inherit; text-decoration: none; cursor: pointer; flex: 0 0 auto;
	transition: transform 140ms var(--ease), background-color 140ms ease, border-color 140ms ease, opacity 140ms ease;
}
.r-btn:hover { background: var(--hover); text-decoration: none; }
.r-btn:active { transform: translateY(1px); }
.r-btn[aria-expanded="true"], .r-btn[aria-pressed="true"] { background: var(--chip); }
.r-btn[aria-pressed="true"] { color: var(--accent-text); }
.r-btn[disabled] { cursor: default; opacity: .45; }
.r-btn--line { border: 1px solid var(--line); }
.r-btn--accent { background: var(--accent); color: var(--on-accent); font-weight: 500; }
.r-btn--accent:hover { background: var(--accent); opacity: .9; }
.r-aa { font-size: 17px; letter-spacing: -.02em; line-height: 1; }
.r-aa b { font-size: 22px; font-weight: 600; }

.r-bar, .r-foot {
	position: fixed; left: 0; right: 0; z-index: 20; background: var(--bg);
	transition: transform 200ms var(--ease), visibility 0s linear 0s;
}
.r-bar { top: 0; height: var(--bar-h); border-bottom: 1px solid var(--border); }
.r-foot { bottom: 0; height: var(--foot-h); border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom); }
html[data-bars="off"] .r-bar { transform: translateY(-100%); visibility: hidden; transition: transform 200ms var(--ease), visibility 0s linear 200ms; }
html[data-bars="off"] .r-foot { transform: translateY(100%); visibility: hidden; transition: transform 200ms var(--ease), visibility 0s linear 200ms; }
html:not([data-mode]) .r-foot { display: none; }

.r-bar__row {
	height: 100%; max-width: 1400px; margin: 0 auto; padding: 0 4px;
	display: flex; align-items: center; gap: 2px;
}
.r-bar__title {
	flex: 1; min-width: 0; padding: 0 6px; text-align: center; line-height: 1.25;
}
.r-bar__name {
	display: block; font-size: 16px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.r-bar__act { display: flex; align-items: center; }
.r-back { justify-self: start; }

.r-foot__in {
	height: 100%; max-width: 900px; margin: 0 auto; padding: 4px 16px 0;
	display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "l r" "s s";
	align-items: center; column-gap: 12px;
}
.r-foot__l, .r-foot__r {
	font-size: 13px; line-height: 1.3; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.r-foot__l { grid-area: l; }
.r-foot__r { grid-area: r; text-align: right; }
.r-slider { grid-area: s; position: relative; min-width: 0; }
.r-tip {
	position: absolute; bottom: 100%; left: 0; z-index: 2; margin-bottom: 2px;
	padding: 6px 10px; border-radius: var(--radius); background: var(--accent); color: var(--on-accent);
	font-size: 14px; white-space: nowrap; pointer-events: none; transform: translateX(-50%);
}
.r-range {
	-webkit-appearance: none; appearance: none; display: block; width: 100%; height: 44px; margin: 0;
	background: transparent; cursor: pointer; touch-action: pan-x;
}
.r-range:focus { outline: none; }
.r-range::-webkit-slider-runnable-track {
	height: 4px; border-radius: 2px;
	background: linear-gradient(to right, var(--ribbon) var(--fill, 0%), var(--line) var(--fill, 0%));
}
.r-range::-webkit-slider-thumb {
	-webkit-appearance: none; appearance: none; width: 22px; height: 22px; margin-top: -9px; border-radius: 50%;
	background: var(--accent); border: 2px solid var(--bg); box-shadow: 0 0 0 1px var(--ctl);
}
.r-range::-moz-range-track { height: 4px; border-radius: 2px; background: var(--line); }
.r-range::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--ribbon); }
.r-range::-moz-range-thumb {
	width: 18px; height: 18px; border-radius: 50%; background: var(--accent); border: 2px solid var(--bg); box-shadow: 0 0 0 1px var(--ctl);
}
.r-range:focus-visible::-webkit-slider-thumb { outline: 2px solid var(--focus); outline-offset: 2px; }
.r-range:focus-visible::-moz-range-thumb { outline: 2px solid var(--focus); outline-offset: 2px; }
.r-range:disabled { opacity: .4; cursor: default; }


/* 4. ВСПЛЫВАЮЩИЕ ПАНЕЛИ: НАСТРОЙКИ И МЕНЮ «…»
   -------------------------------------------------------------------------- */
.r-pop {
	position: fixed; z-index: 30; left: 8px; right: 8px; bottom: 8px;
	max-height: 76vh; max-height: 76dvh; overflow-y: auto; overscroll-behavior: contain;
	background: var(--surface); color: var(--text);
	border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow);
}
.r-pop__in { padding: 8px 16px 16px; display: flex; flex-direction: column; }
.r-sec { display: flex; flex-direction: column; gap: 8px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.r-sec__label { font-size: 14px; color: var(--muted); }
.r-sec--reset { border-bottom: 0; padding-bottom: 0; align-items: flex-start; }
.r-reset { color: var(--text); }

.r-step { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; }
.r-step__b { width: 100%; min-height: 48px; }
.r-step__val { min-width: 48px; text-align: center; font-size: 18px; font-weight: 500; }
.r-step__a { font-family: var(--font-literata); font-weight: 500; line-height: 1; }
.r-step__a--s { font-size: 16px; }
.r-step__a--l { font-size: 26px; }

.r-seg {
	display: grid; gap: 2px; padding: 2px; border-radius: var(--radius); background: var(--chip);
}
.r-seg--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.r-seg--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.r-seg__b {
	min-height: 44px; padding: 0 8px; border: 0; border-radius: 6px;
	background: transparent; color: var(--muted); font-size: 15px; cursor: pointer;
	transition: background-color 140ms ease, color 140ms ease;
}
.r-seg__b:hover { color: var(--text); }
.r-seg__b[aria-pressed="true"] { background: var(--bg); color: var(--text); box-shadow: inset 0 0 0 1px var(--ctl); }

.r-themes { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.r-theme {
	display: flex; flex-direction: column; align-items: center; gap: 4px; min-height: 44px; padding: 0;
	border: 0; background: transparent; color: var(--text); font-size: 13px; cursor: pointer;
}
.r-theme__sw {
	display: flex; align-items: center; justify-content: center; width: 100%; height: 48px;
	border-radius: var(--radius); border: 1px solid var(--line); font-family: var(--font-literata); font-size: 20px;
}
.r-theme[aria-pressed="true"] .r-theme__sw { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent-text); }
.r-theme--white .r-theme__sw { background: #FFFFFF; color: #1B1B1A; }
.r-theme--sepia .r-theme__sw { background: #F4ECD8; color: #2E2619; }
.r-theme--gray .r-theme__sw { background: #2A2C2F; color: #DCDAD3; }
.r-theme--black .r-theme__sw { background: #000000; color: #CFCDC6; }

.r-fonts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.r-fonts .r-seg__b { border: 1px solid var(--line); font-size: 16px; }
.r-fonts .r-seg__b[aria-pressed="true"] { border-color: var(--ctl); }
.r-f-literata { font-family: var(--font-literata); }
.r-f-golos { font-family: var(--font-golos); }
.r-f-ptserif { font-family: var(--font-ptserif); }
.r-f-sans { font-family: var(--font-sans); }

.r-switches { display: flex; flex-direction: column; border-bottom: 1px solid var(--border); padding: 4px 0; }
.r-switch {
	display: flex; align-items: center; justify-content: space-between; gap: 16px; width: 100%; min-height: 48px; padding: 0;
	border: 0; background: transparent; color: var(--text); font-size: 16px; text-align: left; cursor: pointer;
}
.r-switch__t {
	position: relative; flex: 0 0 auto; width: 46px; height: 28px; border-radius: 14px; background: var(--line);
	transition: background-color 140ms ease;
}
.r-switch__t::after {
	content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
	background: var(--bg); transition: transform 140ms var(--ease);
}
.r-switch[aria-checked="true"] .r-switch__t { background: var(--accent-text); }
.r-switch[aria-checked="true"] .r-switch__t::after { transform: translateX(18px); background: var(--surface); }

.r-list { list-style: none; margin: 0; padding: 6px; }
.r-item {
	display: flex; align-items: center; min-height: 48px; padding: 0 14px; border-radius: var(--radius);
	color: var(--text); text-decoration: none; font-size: 16px;
}
.r-item:hover { background: var(--hover); text-decoration: none; }


/* 5. РАСКЛАДКА: РЕЖИМ СТРАНИЦ И РЕЖИМ ПРОКРУТКИ
   -------------------------------------------------------------------------- */
.r-main { position: relative; }
.r-view { position: relative; }
.r-pager { position: relative; }

/* Режим прокрутки (и без JS): обычный поток, панели закреплены сверху и снизу */
html:not([data-mode="paged"]) .r-main {
	max-width: calc(var(--read-width) + 40px); margin: 0 auto;
	padding: calc(var(--bar-h) + 24px) 20px calc(var(--foot-h) + 48px);
}
html:not([data-mode="paged"]) .r-turn { display: none; }

/* Режим страниц: окно между панелями, внутри колонки */
html[data-mode="paged"] body { overflow: hidden; height: 100vh; height: 100dvh; min-height: 0; }
html[data-mode="paged"] .r-main {
	position: fixed; top: var(--bar-h); bottom: var(--foot-h); left: 0; right: 0; z-index: 1;
	display: flex; align-items: center; justify-content: center; overflow: hidden;
}
html[data-mode="paged"] .r-view {
	flex: 0 0 auto; width: var(--view-w); height: var(--view-h); overflow: hidden;
	touch-action: pan-y pinch-zoom;
}
html[data-mode="paged"] .r-pager {
	width: var(--view-w); height: 100%; will-change: transform;
	transition: transform 240ms var(--ease);
}
html[data-mode="paged"] .r-pager.r-noanim { transition: none; }
html[data-mode="paged"] .fb2-book {
	width: var(--view-w); height: var(--view-h);
	column-width: var(--col-w); column-gap: var(--col-g); column-fill: auto;
}
html[data-mode="paged"] .fb2-book img { max-height: var(--view-h); object-fit: contain; break-inside: avoid; }
html[data-mode="paged"] .fb2-book h1, html[data-mode="paged"] .fb2-book h2, html[data-mode="paged"] .fb2-book h3,
html[data-mode="paged"] .fb2-book h4, html[data-mode="paged"] .fb2-book .title { break-after: avoid; }
html[data-mode="paged"]:not(.r-ready) .r-view { visibility: hidden; }
html[data-mode="paged"] .r-crumbs {
	position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}
html[data-mode="paged"] .r-nav { display: none; }
html[data-mode="paged"] .r-resume {
	position: absolute; z-index: 5; top: 8px; left: 50%; transform: translateX(-50%);
	width: min(560px, calc(100% - 24px)); margin: 0; box-shadow: var(--shadow);
}

/* Кнопки «страница назад/вперёд» по краям (только мышь, ширина от 720px) */
.r-turn {
	position: absolute; top: 50%; z-index: 3; display: none; align-items: center; justify-content: center;
	width: 48px; height: 64px; margin-top: -32px; padding: 0;
	border: 0; border-radius: var(--radius); background: transparent; color: var(--ctl); cursor: pointer;
	transition: background-color 140ms ease, color 140ms ease, opacity 140ms ease;
}
.r-turn:hover { background: var(--hover); color: var(--text); }
.r-turn[disabled] { opacity: .25; cursor: default; background: transparent; }
.r-turn--prev { left: 12px; }
.r-turn--next { right: 12px; }
@media (min-width: 720px) and (hover: hover) {
	html[data-mode="paged"] .r-turn { display: flex; }
}

.r-crumbs { margin: 0 0 20px; font-size: 14px; line-height: 2; color: var(--muted); }
.r-crumbs a { color: var(--muted); }
.r-crumbs a:hover { color: var(--text); }


/* 6. ТЕКСТ КНИГИ (FB2)
   -------------------------------------------------------------------------- */
.fb2-book {
	margin: 0; font-family: var(--read-font); font-size: var(--read-size); line-height: var(--read-lead);
	color: var(--text); overflow-wrap: break-word; hyphens: auto; -webkit-hyphens: auto;
}
html[data-hyph="off"] .fb2-book { hyphens: manual; -webkit-hyphens: manual; }
html[data-bold="on"] .fb2-book { font-weight: 600; }
html[data-bold="on"] .fb2-book strong, html[data-bold="on"] .fb2-book b { font-weight: 700; }
html[data-align="justify"] .fb2-book p:not(.text-author) { text-align: justify; text-justify: inter-word; }
.fb2-book p { margin: 0 0 1.1em; orphans: 2; widows: 2; }
.fb2-book div { max-width: 100%; }
.fb2-book img { max-width: 100%; height: auto; }
.fb2-book a { color: var(--accent-text); }
.fb2-book strong, .fb2-book b { font-weight: 600; }
.fb2-book sup { color: var(--accent-text); vertical-align: super; font-size: .7em; line-height: 0; }
.fb2-book sub { font-size: .7em; line-height: 0; }
.fb2-book h1, .fb2-book h2, .fb2-book h3, .fb2-book h4, .fb2-book h5, .fb2-book h6,
.fb2-book .title {
	margin: 1.6em 0 .8em; font-family: var(--font-ui); font-weight: 600;
	font-size: 1.4em; line-height: 1.2; letter-spacing: -0.03em; text-align: left; hyphens: manual;
}
.fb2-book .title p { margin: 0; font-size: inherit; text-align: left; }
.fb2-book > :first-child { margin-top: 0; }
.fb2-book h3, .fb2-book h4, .fb2-book .subtitle { font-size: 1.15em; }
.fb2-book .subtitle { font-family: var(--font-ui); font-weight: 500; margin: 1.4em 0 .8em; }
.fb2-book .quote, .fb2-book blockquote, .fb2-book .cite, .fb2-book .epigraph {
	margin: 0 0 1.1em; padding: 4px 0 4px 16px; border-left: 2px solid var(--ribbon); font-style: italic;
}
.fb2-book .quote p, .fb2-book blockquote p, .fb2-book .cite p, .fb2-book .epigraph p { margin-bottom: .6em; }
.fb2-book .poem, .fb2-book .stanza { margin: 0 0 1.1em; padding-left: 1.5em; }
.fb2-book .text-author { text-align: right; font-style: italic; color: var(--muted); }
.fb2-book .book-notes {
	margin-top: 10px; font-size: .8em; line-height: 1.5; font-style: italic; color: var(--muted);
}
.fb2-book .book-notes span { color: var(--accent-text); }
.fb2-book table { max-width: 100%; border-collapse: collapse; }
.fb2-book td, .fb2-book th { padding: 4px 8px; border: 1px solid var(--line); }
.r-removed { color: var(--muted); font-family: var(--font-ui); }
.r-litres { margin: 2em 0 0; text-align: center; font-family: var(--font-ui); break-inside: avoid; }
.r-litres__text { margin: 0 0 16px; font-size: 1.25em; font-weight: 600; letter-spacing: -0.03em; }
.r-litres__buy { padding: 0 24px; min-height: 52px; }


/* 7. ПОДСКАЗКА «ВЫ ОСТАНОВИЛИСЬ», КНОПКИ, НАВИГАЦИЯ ПО СТРАНИЦАМ
   -------------------------------------------------------------------------- */
.r-resume {
	display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 0 0 24px;
	padding: 10px 10px 10px 16px; border: 1px solid var(--line); border-radius: var(--radius);
	background: var(--surface);
}
.r-resume__text { flex: 1 1 200px; margin: 0; }

.r-nav { margin-top: 48px; display: flex; flex-direction: column; gap: 16px; }
.r-nav__btns { display: flex; flex-wrap: wrap; gap: 8px; }
.r-nav__btns:empty { display: none; }
.r-nav__btn {
	display: flex; align-items: center; gap: 8px; min-height: 52px; padding: 0 16px;
	border: 1px solid var(--line); border-radius: var(--radius); color: var(--text); text-decoration: none;
	transition: transform 140ms var(--ease), background-color 140ms ease, opacity 140ms ease;
}
.r-nav__btn:hover { background: var(--hover); text-decoration: none; }
.r-nav__btn:active { transform: translateY(1px); }
.r-nav__btn--prev { flex: 1 1 140px; }
.r-nav__btn--next {
	flex: 2 1 200px; justify-content: space-between;
	background: var(--accent); color: var(--on-accent); border-color: var(--accent); font-weight: 500;
}
.r-nav__btn--next:hover { background: var(--accent); opacity: .9; }
.pages { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; }
.pages a, .pages span {
	display: inline-flex; align-items: center; justify-content: center;
	min-width: 44px; min-height: 44px; padding: 0 10px; border-radius: var(--radius);
	font-size: 15px; text-align: center; text-decoration: none;
}
.pages a { color: var(--text); }
.pages a:hover { background: var(--hover); text-decoration: none; }
.pages span { background: var(--chip); color: var(--text); box-shadow: inset 0 0 0 1px var(--ctl); }
.pages .nav_ext { background: transparent; box-shadow: none; color: var(--muted); min-width: 24px; padding: 0 4px; }
.r-nav__hint { margin: 0; font-size: 14px; color: var(--muted); text-align: center; }


/* 8. РЕКЛАМА: ЭКРАН R2 И ПОЛНОЭКРАННЫЙ БЛОК
   Баннеров между абзацами и сбоку нет. Нигде нет липкого баннера поверх текста.
   R2: в режиме страниц отдельный экран после текста (позицию и размер ставит скрипт), в режиме прокрутки блок перед кнопками.
   -------------------------------------------------------------------------- */
.ad-slot {
	display: flex; flex-direction: column; gap: 6px;
	padding: 8px 12px 12px; border: 1px solid var(--border); border-radius: var(--radius-lg);
	background: var(--ad-bg); contain: layout;
	font-family: var(--font-ui); font-size: 16px; line-height: 1.5;
}
.ad-slot__label { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; color: var(--muted); }
.ad-slot__body { display: flex; align-items: center; justify-content: center; min-height: var(--ad-h, 250px); overflow: hidden; }
.ad-slot--end { --ad-h: 250px; width: 100%; max-width: 720px; }
html:not([data-mode="paged"]) .r-end:not([hidden]) { margin: 48px 0 100px; }
html[data-mode="paged"] .r-end {
	position: absolute; top: 0; display: flex; align-items: center; justify-content: center;
}

.r-full {
	position: fixed; inset: 0; z-index: 80; display: flex; align-items: center; justify-content: center;
	padding: 12px; background: var(--scrim);
}
.r-full__card {
	display: flex; flex-direction: column; width: min(760px, 100%); max-height: 100%;
	border-radius: 16px; background: var(--surface); color: var(--text); box-shadow: var(--shadow); overflow: hidden;
}
.r-full__top { display: flex; align-items: center; justify-content: space-between; padding: 4px 4px 4px 16px; }
.r-full__label { font-size: 13px; color: var(--muted); }
.r-full__close {
	display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; padding: 0 10px;
	border: 0; border-radius: var(--radius); background: transparent; color: var(--text); font-size: 17px; cursor: pointer;
	font-variant-numeric: tabular-nums;
}
.r-full__close:not(:disabled):hover { background: var(--hover); }
.r-full__close:disabled { color: var(--muted); cursor: default; }
.r-full__close svg { display: block; }
.r-full__body { display: flex; align-items: center; justify-content: center; min-height: 250px; padding: 0 12px 12px; overflow: auto; }


/* 9. КНОПКА «СОХРАНИТЬ В ЦИТАТЫ»
   Показывается скриптом только при FLAGS.quotes = true.
   -------------------------------------------------------------------------- */
.r-quote { position: fixed; z-index: 40; left: 0; top: 0; }
.r-quote__btn {
	display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px;
	border: 0; border-radius: var(--radius); background: var(--accent); color: var(--on-accent);
	font: inherit; font-weight: 500; cursor: pointer; box-shadow: var(--shadow); white-space: nowrap;
}
.r-quote__btn:hover { opacity: .9; }


/* 9а. ОГЛАВЛЕНИЕ
   Данные даёт плагин Knigi Reader TOC, окно строит скрипт. На телефоне нижний лист, от 720px окно по центру.
   -------------------------------------------------------------------------- */
.r-toc {
	position: fixed; inset: 0; z-index: 70; display: flex; align-items: flex-end; justify-content: center;
	background: var(--scrim);
}
html.r-toc-open body { overflow: hidden; }
.r-toc__card {
	display: flex; flex-direction: column; width: 100%; max-height: 88vh; max-height: 88dvh;
	background: var(--surface); color: var(--text); border: 1px solid var(--border); border-bottom: 0;
	border-radius: 16px 16px 0 0; box-shadow: var(--shadow);
	padding-bottom: env(safe-area-inset-bottom);
	animation: r-toc-up 220ms var(--ease);
}
.r-toc__grip { display: block; width: 36px; height: 4px; margin: 8px auto 0; border-radius: 2px; background: var(--line); }
.r-toc__head {
	display: flex; align-items: flex-start; gap: 14px; padding: 12px 8px 14px 16px; border-bottom: 1px solid var(--border);
}
.r-toc__cover { flex: 0 0 auto; width: 56px; height: 84px; border-radius: 4px; overflow: hidden; background: var(--chip); }
.r-toc__cover img { display: block; width: 100%; height: 100%; object-fit: cover; }
.r-toc__meta { flex: 1 1 auto; min-width: 0; padding-top: 2px; }
.r-toc__name {
	margin: 0; font-size: 17px; font-weight: 600; line-height: 1.3; letter-spacing: -0.01em;
	display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.r-toc__by { margin: 4px 0 0; font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.r-toc__h { margin: 10px 0 0; font-size: 13px; font-weight: 500; color: var(--muted); }
.r-toc__x { margin-left: auto; color: var(--muted); }
.r-toc__x:hover { color: var(--text); }
.r-toc__list {
	position: relative; flex: 1 1 auto; min-height: 0; margin: 0; padding: 6px 0 10px; list-style: none;
	overflow-y: auto; overscroll-behavior: contain;
}
.r-toc__li { margin: 0; }
.r-toc__i {
	display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 10px 16px 10px 16px;
	color: var(--text); text-decoration: none; font-size: 16px; line-height: 1.35;
}
.r-toc__li--l2 .r-toc__i { padding-left: 36px; }
.r-toc__li--l3 .r-toc__i { padding-left: 56px; }
.r-toc__li--l4 .r-toc__i { padding-left: 76px; }
.r-toc__list--parts .r-toc__li--l1 .r-toc__i { font-weight: 600; }
a.r-toc__i:hover { background: var(--hover); text-decoration: none; }
a.r-toc__i:focus-visible { outline-offset: -2px; }
.r-toc__t { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.r-toc__pc { flex: 0 0 auto; font-size: 14px; font-variant-numeric: tabular-nums; }
.r-toc__i[aria-current] { color: var(--accent-text); font-weight: 600; }
.r-toc__i--locked { color: var(--muted); opacity: .7; cursor: default; }
.r-toc__lock { flex: 0 0 auto; }
.r-toc__note {
	margin: 8px 16px 4px; padding: 10px 0 0; border-top: 1px solid var(--border);
	font-size: 13px; color: var(--muted);
}
@keyframes r-toc-up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes r-toc-in { from { transform: translateY(8px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }


/* 10. АДАПТИВ, REDUCED-MOTION, ПЕЧАТЬ
   -------------------------------------------------------------------------- */
@media (min-width: 720px) {
	.r-bar__row { display: grid; grid-template-columns: 1fr minmax(0, 640px) 1fr; padding: 0 16px; gap: 8px; }
	.r-bar__act { justify-self: end; }
	.r-foot__in { grid-template-columns: minmax(120px, 24%) minmax(0, 1fr) minmax(48px, auto); grid-template-areas: "l s r"; padding: 0 24px; column-gap: 16px; }
	.r-foot__r { text-align: right; }
	html:not([data-mode="paged"]) .r-main { padding-top: calc(var(--bar-h) + 40px); }
	html[data-mode="paged"] .r-foot__in { max-width: calc(var(--view-w) + 48px); }
	.r-pop { left: auto; right: 16px; bottom: auto; top: calc(var(--bar-h) + 8px); width: 380px; max-height: calc(100vh - var(--bar-h) - 24px); max-height: calc(100dvh - var(--bar-h) - 24px); }
	.r-pop--more { width: 300px; }
	.r-toc { align-items: center; padding: 24px; }
	.r-toc__card {
		width: min(560px, 100%); max-height: min(80vh, 760px); max-height: min(80dvh, 760px);
		border: 1px solid var(--border); border-radius: 16px; padding-bottom: 0; animation-name: r-toc-in;
	}
	.r-toc__grip { display: none; }
	.r-toc__head { padding: 20px 12px 16px 24px; }
	.r-toc__i { padding-left: 24px; padding-right: 24px; }
	.r-toc__li--l2 .r-toc__i { padding-left: 44px; }
	.r-toc__li--l3 .r-toc__i { padding-left: 64px; }
	.r-toc__li--l4 .r-toc__i { padding-left: 84px; }
	.r-toc__note { margin-left: 24px; margin-right: 24px; }
}
@media (prefers-reduced-motion: reduce) {
	.r-btn, .r-seg__b, .r-nav__btn, .r-turn { transition: background-color 140ms ease, border-color 140ms ease, opacity 140ms ease; }
	.r-btn:active, .r-nav__btn:active { transform: none; }
	html[data-mode="paged"] .r-pager { transition: none; }
	.r-bar, .r-foot { transition: none !important; }
	.r-switch__t, .r-switch__t::after { transition: none; }
	.r-toc__card { animation: none; }
}
@media print {
	.r-bar, .r-foot, .r-pop, .r-nav, .ad-slot, .r-end, .r-quote, .r-resume, .r-turn, .r-full, .r-toc { display: none !important; }
	html[data-mode] body { overflow: visible; height: auto; background: #fff; color: #000; }
	html[data-mode] .r-main { position: static; display: block; overflow: visible; max-width: none; padding: 0; }
	html[data-mode] .r-view { width: auto; height: auto; overflow: visible; }
	html[data-mode] .r-pager { width: auto; height: auto; transform: none !important; }
	html[data-mode] .fb2-book { width: auto; height: auto; column-width: auto; color: #000; }
	html[data-mode] .r-crumbs { position: static; width: auto; height: auto; clip-path: none; }
}

/* Название книги в шапке на первой странице — H1 (SEO), выглядит как прежний span */
h1.r-bar__name { margin: 0; font-size: 16px; font-weight: 500; line-height: inherit; letter-spacing: inherit; }
