/* ==========================================================================
   Knigi.ws  |  шаблон knigi2  |  «Корешки на полке»
   Заменяет styles.css (он больше не подключается). engine.css остаётся и
   перекрашивается ниже блоком «ENGINE». Подключать ПОСЛЕ engine.css.

   Оглавление
   1. Токены (тёмная по умолчанию, светлая [data-theme="light"])
   2. База: сброс, типографика, ссылки, фокус, формы, кнопки
   3. Раскладка: контейнер, сетка контент + сайдбар
   4. Шапка, панель жанров, мобильное меню
   5. Жанры (categorymenu.tpl), крошки, пагинация
   6. Сайдбар: топ просмотров, стол заказов, телеграм
   7. Подвал
   8. Рекламные места .ad-slot
   9. Базовые компоненты для страниц: обложка, корешок, ленточка, полка, карточка
  10. Окно входа, комментарии, формы (бывшие стили styles.css)
  11. ENGINE: перекраска engine.css под токены
  12. Устаревшие классы старого шаблона (мост, удалять по мере переверстки)
   ========================================================================== */


/* 1. ТОКЕНЫ
   -------------------------------------------------------------------------- */
/* Резервные шрифты с поправкой метрик: пока Golos/Literata/Sofia грузятся с Google Fonts, текст рисуется системным шрифтом
   той же ширины и высоты строки, и при подмене блоки не сдвигаются (CLS). Метрики сняты в Chrome 14.11.2026.
   Arial / Liberation Sans (Windows, macOS, Linux), Roboto / Noto Serif (Android). */
@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'); 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: 'Sofia Fallback'; src: local('Arial Narrow'), local('ArialNarrow'); size-adjust: 90.28%; ascent-override: 99.69%; descent-override: 33.23%; line-gap-override: 0%; }
@font-face { font-family: 'Sofia Fallback R'; src: local('Roboto Condensed'), local('RobotoCondensed-Regular'); size-adjust: 82.41%; ascent-override: 109.21%; descent-override: 36.40%; line-gap-override: 0%; }

:root {
	color-scheme: dark;
	--bg: #0F1B1E;
	--surface: #152528;
	--surface2: #1B2E32;
	--border: #23383C;
	--line: #33494D;
	--ctl: #6C8388;
	--text: #EAE4D6;
	--muted: #9FB0B0;
	--accent: #EAE4D6;          /* кнопка-наклейка */
	--on-accent: #0F1B1E;
	--accent-text: #FF8163;     /* ссылки, акценты в тексте */
	--ribbon: #F0563A;          /* ленточка-закладка */
	--danger: #FFB4A0;
	--success: #9AD6B0;
	--chip: #1B2E32;
	--accent-soft: rgba(240, 86, 58, .16);
	--ad-bg: #12201F;
	--ad-border: #6C8388;
	--hover: rgba(234, 228, 214, .08);
	--shadow: 0 14px 30px rgba(3, 10, 12, .5);
	--focus: #FF8163;
	--overlay: rgba(3, 10, 12, .62);
	--sel-bg: #EAE4D6;
	--sel-text: #0F1B1E;
	--cloth-text: #F1EADB;      /* текст на обложке/корешке */
	--spine-1: #2F4B7C;
	--spine-2: #7A2E3B;
	--spine-3: #2E5E4A;
	--spine-4: #7E5B1C;
	--spine-5: #3D4650;
	--spine-6: #1F5F66;
	--spine-7: #8C4A2F;
	--spine-8: #27365C;
	--font: 'Golos Text', 'Golos Fallback', 'Golos Fallback R', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
	--font-read: 'Literata', 'Literata Fallback', 'Literata Fallback R', Georgia, 'Times New Roman', serif;
	--font-spine: 'Sofia Sans Condensed', 'Sofia Fallback', 'Sofia Fallback R', 'Golos Text', sans-serif;
	--radius: 8px;
	--radius-lg: 12px;
	--ease: cubic-bezier(.2, .8, .2, 1);
}

:root[data-theme="light"] {
	color-scheme: light;
	--bg: #E6EBEA;
	--surface: #F4F6F4;
	--surface2: #DCE3E2;
	--border: #CBD5D4;
	--line: #B4C1C0;
	--ctl: #667779;
	--text: #0F2327;
	--muted: #47595C;
	--accent: #0F2327;
	--on-accent: #F2EEE2;
	--accent-text: #A82E18;
	--ribbon: #C93A22;
	--danger: #A82E18;
	--success: #1F6A4A;
	--chip: #D8E0DF;
	--accent-soft: rgba(201, 58, 34, .12);
	--ad-bg: #EDF1F0;
	--ad-border: #667779;
	--hover: rgba(15, 35, 39, .07);
	--shadow: 0 14px 30px rgba(15, 35, 39, .18);
	--focus: #0F2327;
	--overlay: rgba(15, 35, 39, .5);
	--sel-bg: #0F2327;
	--sel-text: #F2EEE2;
}


/* 2. БАЗА
   -------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scrollbar-color: var(--line) var(--bg); }

body, h1, h2, h3, h4, h5, h6, p, ul, ol, li, figure, blockquote, dl, dd, form, fieldset, pre {
	margin: 0; padding: 0;
}
ul, ol { list-style: none; }
table { border-collapse: collapse; border-spacing: 0; }
article, aside, figure, footer, header, hgroup, main, nav, section { display: block; }
img { max-width: 100%; height: auto; border: 0; }
button, input, select, textarea { font: inherit; color: inherit; }

body {
	min-width: 320px;
	background: var(--bg);
	color: var(--text);
	font-family: var(--font);
	font-size: 16px;
	font-weight: 400;
	line-height: 1.5;
	font-variant-numeric: tabular-nums;
	-webkit-font-smoothing: antialiased;
}

::selection { background: var(--sel-bg); color: var(--sel-text); }
::placeholder { color: var(--muted); opacity: 1; }

h1, h2, h3, h4, h5, h6 {
	font-weight: 600;           /* жирнее 600 нельзя */
	letter-spacing: -0.03em;
	line-height: 1.15;
}
h1 { font-size: 32px; }
h2 { font-size: 24px; }
h3 { font-size: 20px; }
h4, h5, h6 { font-size: 18px; }
b, strong, .fw700 { font-weight: 600; }

a { color: inherit; text-decoration: none; }
a:hover { color: inherit; }

.k-link, .full-text a, .site-desc a {
	color: var(--accent-text);
	text-decoration: underline;
	text-decoration-thickness: 1px;
	text-underline-offset: 3px;
}
.k-link:hover, .full-text a:hover, .site-desc a:hover { text-decoration-thickness: 2px; }

/* Фокус с клавиатуры: виден всегда */
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
input:focus-visible, textarea:focus-visible, select:focus-visible { outline-offset: 0; }

/* Утилиты */
.vh {
	position: absolute; width: 1px; height: 1px; overflow: hidden;
	clip-path: inset(50%); white-space: nowrap;
}
.k-skip {
	position: absolute; left: -9999px; top: 12px; z-index: 100;
	padding: 12px 16px; border-radius: var(--radius);
	background: var(--accent); color: var(--on-accent); font-weight: 500;
}
.k-skip:focus { left: 16px; }
.hidden, #dofullsearch { display: none; }
.clr { clear: both; }
.clearfix::after { content: ""; display: table; clear: both; }
.nowrap { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Кнопки.
   .k-btn          базовая (контурная)
   .k-btn--primary главная «наклейка» (--accent / --on-accent)
   .k-btn--ghost   без рамки
   .k-iconbtn      квадратная 44x44 для иконки */
.k-btn, .btn, .button, .btn2,
input[type="submit"], input[type="button"], input[type="reset"],
button[type="submit"]:not([class*="k-"]), .qq-upload-button {
	display: inline-flex; align-items: center; justify-content: center; gap: 8px;
	min-height: 44px; padding: 0 16px;
	border: 1px solid var(--line); border-radius: var(--radius);
	background: transparent; color: var(--text);
	font: inherit; font-size: 16px; font-weight: 500; line-height: 1.2; text-align: center;
	cursor: pointer;
	transition: transform 140ms var(--ease), background-color 140ms ease, border-color 140ms ease, opacity 140ms ease, color 140ms ease;
}
.k-btn:hover, .btn:hover, .button:hover, .btn2:hover,
input[type="submit"]:hover, input[type="button"]:hover, input[type="reset"]:hover,
button[type="submit"]:not([class*="k-"]):hover, .qq-upload-button:hover {
	background-color: var(--hover); color: var(--text);
}
.k-btn:active, .btn:active, .button:active, input[type="submit"]:active, input[type="button"]:active { transform: translateY(1px); }

.k-btn--primary, .btn:not(.btn2), .button, input[type="submit"],
button[type="submit"]:not([class*="k-"]), .qq-upload-button {
	background: var(--accent); color: var(--on-accent); border-color: var(--accent);
}
.k-btn--primary:hover, .btn:not(.btn2):hover, .button:hover, input[type="submit"]:hover,
button[type="submit"]:not([class*="k-"]):hover, .qq-upload-button:hover {
	background: var(--accent); color: var(--on-accent); opacity: .9;
}
.k-btn--ghost { border-color: transparent; }
.k-btn--block { display: flex; width: 100%; }
.k-btn[disabled], .btn[disabled], .btn.disabled, button[disabled], input[disabled] { cursor: default; opacity: .6; pointer-events: none; }

.k-iconbtn {
	display: inline-flex; align-items: center; justify-content: center; flex: 0 0 44px;
	width: 44px; height: 44px; padding: 0;
	border: 0; border-radius: var(--radius);
	background: transparent; color: var(--text); cursor: pointer;
	transition: transform 140ms var(--ease), background-color 140ms ease, opacity 140ms ease;
}
.k-iconbtn:hover { background: var(--hover); }
.k-iconbtn svg { display: block; }

/* Поля ввода */
input[type="text"], input[type="password"], input[type="email"], input[type="search"],
input[type="url"], input[type="tel"], input[type="number"], input[type="file"],
select, textarea, .k-input {
	width: 100%; min-height: 44px; padding: 0 12px;
	border: 1px solid var(--ctl); border-radius: var(--radius);
	background: var(--bg); color: var(--text);
	font: inherit; font-size: 16px; line-height: 1.4;
	-webkit-appearance: none; appearance: none;
}
input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }
textarea { min-height: 120px; padding: 10px 12px; overflow: auto; vertical-align: top; resize: vertical; }
select {
	width: auto; max-width: 100%; padding-right: 32px;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239FB0B0' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
	background-repeat: no-repeat; background-position: right 10px center;
}
input:focus, textarea:focus, select:focus { border-color: var(--focus); }
input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; accent-color: var(--ribbon); vertical-align: middle; }
input[type="file"] { padding: 8px 12px; height: auto; }
label { cursor: pointer; }
fieldset { border: 1px solid var(--line); padding: 12px; text-align: left; border-radius: var(--radius); }
fieldset legend { padding: 0 6px; color: var(--muted); }

.berrors, .k-alert {
	margin: 0 0 24px; padding: 14px 16px;
	border: 1px solid var(--danger); border-radius: var(--radius);
	background: var(--surface); color: var(--text);
}
.berrors a, .k-alert a { color: var(--accent-text); text-decoration: underline; }
.berrors + .k-crumbs { margin-top: 0; }

@media (prefers-reduced-motion: reduce) {
	*, *::before, *::after { transition-duration: 1ms !important; animation-duration: 1ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}


/* 3. РАСКЛАДКА
   -------------------------------------------------------------------------- */
.k-wrap { min-height: 100vh; display: flex; flex-direction: column; overflow-x: clip; }
.k-container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 32px; }

.k-layout {
	flex: 1 0 auto;
	display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 48px;
	align-items: start;
	padding-top: 24px; padding-bottom: 64px;
}
.k-main { min-width: 0; display: flex; flex-direction: column; gap: 48px; }
.k-aside { display: flex; flex-direction: column; gap: 32px; min-width: 0; }

.k-section { display: flex; flex-direction: column; gap: 20px; }
.k-section__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; }
.k-title { font-size: 30px; line-height: 1.15; font-weight: 600; letter-spacing: -0.03em; }
.k-subtitle { font-size: 18px; font-weight: 600; letter-spacing: -0.02em; }

/* Сетка книг (shortstory в списках). Первая карточка может быть .k-book-feature
   на всю ширину. */
.k-books {
	display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 24px 16px; align-items: start;
}
.k-books > .k-book-feature { grid-column: 1 / -1; }

@media (max-width: 1023px) {
	.k-container { padding: 0 16px; }
	.k-layout { grid-template-columns: minmax(0, 1fr); gap: 48px; padding-top: 16px; padding-bottom: 48px; }
	.k-main { gap: 40px; }
	.k-title { font-size: 24px; }
}
@media (max-width: 719px) {
	.k-books { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}


/* 4. ШАПКА, ПАНЕЛЬ ЖАНРОВ, МЕНЮ
   -------------------------------------------------------------------------- */
.k-header { position: relative; z-index: 12; background: var(--surface); border-bottom: 1px solid var(--border); }
.k-header__in { display: flex; align-items: center; gap: 4px; height: 64px; }

.k-logo { display: flex; align-items: center; gap: 10px; margin-right: 16px; color: var(--text); flex: 0 0 auto; }
.k-logo svg { display: block; flex: 0 0 auto; }
.k-logo__ribbon { fill: var(--ribbon); }
.k-logo__spine { fill: currentColor; }
.k-logo__name { font-size: 19px; font-weight: 600; letter-spacing: -0.03em; line-height: 1; }

.k-nav { display: flex; align-items: center; }
.k-nav__item {
	display: inline-flex; align-items: center; gap: 6px;
	height: 44px; padding: 0 12px; border: 0; border-radius: var(--radius);
	background: transparent; color: var(--text); font: inherit; cursor: pointer;
	transition: background-color 140ms ease, color 140ms ease;
}
.k-nav__item:hover { background: var(--hover); }
.k-nav__item svg { transition: transform 140ms var(--ease); }
.k-nav__item[aria-expanded="true"] svg { transform: rotate(180deg); }

.k-search { margin: 0 8px 0 auto; flex: 0 1 340px; min-width: 0; }
.k-search__box {
	display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 0 0 12px;
	border: 1px solid var(--ctl); border-radius: var(--radius);
	background: var(--bg); color: var(--muted); cursor: text;
}
.k-search__box:focus-within { border-color: var(--focus); }
.k-search__box input {
	flex: 1; min-width: 0; height: 40px; min-height: 0; padding: 0; border: 0; border-radius: 0;
	background: transparent; color: var(--text); outline: 0;
}
.k-search__go {
	flex: 0 0 44px; width: 44px; height: 42px; padding: 0; border: 0; border-radius: var(--radius);
	background: transparent; color: var(--muted); cursor: pointer;
	display: flex; align-items: center; justify-content: center;
}
.k-search__go:hover { color: var(--text); }

.k-header__actions { display: flex; align-items: center; gap: 4px; }
.k-login { height: 44px; padding: 0 14px; border: 1px solid var(--line); border-radius: var(--radius); background: transparent; color: var(--text); font-weight: 500; cursor: pointer; transition: background-color 140ms ease; }
.k-login:hover { background: var(--hover); }

/* Переключатель темы: солнце в тёмной, луна в светлой */
.k-theme-toggle .k-ico-moon { display: none; }
:root[data-theme="light"] .k-theme-toggle .k-ico-sun { display: none; }
:root[data-theme="light"] .k-theme-toggle .k-ico-moon { display: block; }

.btn-menu { display: none; }

/* Панель жанров (она же мобильное меню; класс .to-mob сохранён) */
.k-panel {
	display: none; position: absolute; left: 0; right: 0; top: 100%;
	background: var(--surface); border-bottom: 1px solid var(--border); box-shadow: var(--shadow);
}
.k-panel.is-open { display: block; }
.k-panel__in { padding-top: 20px; padding-bottom: 28px; }
.k-panel__all { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; margin-top: 12px; color: var(--accent-text); font-weight: 500; }
.k-panel__all:hover { text-decoration: underline; text-underline-offset: 3px; }
.k-only-mobile { display: none; }

@media (max-width: 1023px) {
	.k-header__in { flex-wrap: wrap; height: auto; padding-top: 6px; padding-bottom: 8px; gap: 2px; }
	.btn-menu { display: inline-flex; margin-left: -8px; }
	.k-logo { flex: 1 1 auto; margin-right: 0; min-height: 44px; }
	.k-nav, .k-only-desktop { display: none; }
	.k-search { order: 10; flex: 1 1 100%; margin: 4px 0 0; }
	.k-header__actions { margin-left: auto; }
	.k-login { padding: 0 12px; }
	.k-panel { position: static; box-shadow: none; border-bottom: 0; border-top: 1px solid var(--border); margin: 0 -16px; width: calc(100% + 32px); }
	.k-panel__in { padding-top: 8px; padding-bottom: 16px; }
	.k-only-mobile { display: block; }
	.k-mobnav { display: flex; flex-direction: column; margin-bottom: 8px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
	.k-mobnav a { display: flex; align-items: center; min-height: 48px; padding: 0 12px; border-radius: var(--radius); }
	.k-mobnav a:hover { background: var(--hover); }
	.k-panel__label { display: block; padding: 8px 12px 4px; font-size: 14px; color: var(--muted); }
}
@media (max-width: 400px) {
	.k-logo__name { font-size: 18px; }
}

/* Кнопка «наверх» (создаётся в libs.js) */
#gotop {
	position: fixed; right: 16px; bottom: 16px; z-index: 40; display: none;
	width: 44px; height: 44px; line-height: 44px; text-align: center; cursor: pointer;
	border: 1px solid var(--line); border-radius: var(--radius);
	background: var(--surface2); color: var(--text); box-shadow: var(--shadow);
}
@media (max-width: 1023px) { #gotop { display: none !important; } }


/* 5. ЖАНРЫ, КРОШКИ, ПАГИНАЦИЯ
   -------------------------------------------------------------------------- */
/* categorymenu.tpl: .k-genres > .k-genre(.k-genre__link + вложенные .k-genre) */
.k-genres { columns: 4; column-gap: 32px; }
.k-genre { break-inside: avoid; padding-bottom: 4px; }
.k-genre__link {
	display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 4px 8px;
	border-radius: var(--radius); color: var(--text); font-weight: 500;
	transition: background-color 140ms ease;
}
.k-genre__link:hover { background: var(--hover); color: var(--text); }
.k-mark { flex: 0 0 6px; width: 6px; height: 20px; border-radius: 1px; background: var(--cover, var(--spine-1)); }
.k-genre .k-genre { break-inside: auto; padding: 0 0 0 24px; }
.k-genre .k-genre .k-genre__link { min-height: 36px; padding: 0 8px; font-size: 15px; font-weight: 400; color: var(--muted); }
.k-genre .k-genre .k-genre__link:hover { text-decoration: underline; text-underline-offset: 3px; background: transparent; color: var(--text); }
.k-genre .k-genre .k-mark { display: none; }
.k-genres > .k-genre:nth-child(8n+1) { --cover: var(--spine-1); }
.k-genres > .k-genre:nth-child(8n+2) { --cover: var(--spine-2); }
.k-genres > .k-genre:nth-child(8n+3) { --cover: var(--spine-3); }
.k-genres > .k-genre:nth-child(8n+4) { --cover: var(--spine-4); }
.k-genres > .k-genre:nth-child(8n+5) { --cover: var(--spine-5); }
.k-genres > .k-genre:nth-child(8n+6) { --cover: var(--spine-6); }
.k-genres > .k-genre:nth-child(8n+7) { --cover: var(--spine-7); }
.k-genres > .k-genre:nth-child(8n+8) { --cover: var(--spine-8); }
@media (max-width: 1023px) {
	.k-genres { columns: 2; column-gap: 16px; }
}
@media (max-width: 560px) {
	.k-genres { columns: 1; }
	.k-genre__link { min-height: 48px; }
}

/* Чип (метка жанра на главной, фильтры) */
.k-chip {
	display: inline-flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 14px 0 12px;
	border-radius: var(--radius); background: var(--chip); color: var(--text); font-size: 15px;
	transition: background-color 140ms ease;
}
.k-chip:hover { background: var(--surface2); }

/* Хлебные крошки (speedbar.tpl). Разделитель задаётся в настройках DLE. */
.k-crumbs { font-size: 14px; color: var(--muted); display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; }
.k-crumbs a { display: inline-block; padding: 6px 0; color: var(--muted); text-underline-offset: 3px; }
.k-crumbs a:hover { color: var(--text); text-decoration: underline; }
.k-crumbs [aria-current="page"], .k-crumbs > span:last-child { color: var(--text); }

/* Пагинация (navigation.tpl) */
.k-pagination { padding: 8px 0; }
.k-pagination__row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.k-pag__pages { display: flex; flex-wrap: wrap; gap: 2px; font-size: 15px; }
.k-pag__pages a, .k-pag__pages > span, .k-pag__prev a, .k-pag__next a, .k-pag__prev > span, .k-pag__next > span {
	display: inline-flex; align-items: center; justify-content: center;
	min-width: 44px; height: 44px; padding: 0 12px; border-radius: var(--radius);
	color: var(--text); font-weight: 500; transition: background-color 140ms ease;
}
.k-pag__pages a:hover, .k-pag__prev a:hover, .k-pag__next a:hover { background: var(--hover); }
.k-pag__pages > span { background: var(--chip); }
.k-pag__pages > span.nav_ext { background: transparent; color: var(--muted); min-width: 24px; padding: 0 4px; }
.k-pag__prev > span, .k-pag__next > span { color: var(--muted); opacity: .5; }
.k-pag__prev a, .k-pag__next a, .k-pag__prev > span, .k-pag__next > span { border: 1px solid var(--line); background: transparent; }
@media (max-width: 719px) {
	.k-pagination__row { justify-content: center; }
	.k-pag__pages { order: 3; width: 100%; justify-content: center; }
}


/* 6. САЙДБАР
   -------------------------------------------------------------------------- */
.k-side { display: flex; flex-direction: column; gap: 12px; }
.k-side__title { font-size: 18px; font-weight: 600; letter-spacing: -0.02em; }

.k-quick { display: flex; gap: 8px; }
.k-quick .k-btn { flex: 1; padding: 0 12px; }

.k-top { counter-reset: top; }
.k-top__item { border-bottom: 1px solid var(--border); counter-increment: top; }
.k-top__link { display: flex; align-items: center; gap: 12px; padding: 10px 0; color: var(--text); }
.k-top__link::before { content: counter(top); flex: 0 0 14px; color: var(--muted); font-size: 15px; }
.k-top__cover { flex: 0 0 34px; width: 34px; height: 51px; aspect-ratio: auto; border-radius: 3px; }
.k-top__txt { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.k-top__title { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.k-top__author { font-size: 14px; color: var(--muted); }
.k-top__link:hover .k-top__title { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }

.k-order { padding: 20px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); gap: 10px; }
.k-order p { color: var(--muted); }
.k-order .k-btn { align-self: flex-start; margin-top: 4px; }

.k-tg { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius-lg); color: var(--text); transition: background-color 140ms ease; }
.k-tg:hover { background: var(--hover); }
.k-tg__ico { flex: 0 0 40px; width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; border-radius: var(--radius); background: var(--chip); color: var(--accent-text); }
.k-tg__txt { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.k-tg__txt strong { font-weight: 500; }
.k-tg__txt span { font-size: 14px; color: var(--muted); }

/* SEO-блок на главной (main-seo.tpl) */
.site-desc { margin-top: 0; padding-top: 32px; border-top: 1px solid var(--border); line-height: 1.65; color: var(--muted); }
.site-desc h1, .site-desc h2 { margin-bottom: 10px; font-size: 18px; font-weight: 500; letter-spacing: -0.02em; color: var(--text); }
.site-desc p { max-width: 68ch; }
.site-desc p + p { margin-top: 8px; }


/* 7. ПОДВАЛ
   -------------------------------------------------------------------------- */
.k-footer { border-top: 1px solid var(--border); font-size: 14px; }
.k-footer__in { display: flex; flex-wrap: wrap; gap: 24px 48px; padding-top: 32px; padding-bottom: 40px; }
.k-footer__brand { flex: 2 1 260px; display: flex; flex-direction: column; gap: 6px; }
.k-footer__name { font-size: 18px; font-weight: 600; letter-spacing: -0.03em; }
.k-footer__text { color: var(--muted); max-width: 44ch; }
.k-footer__nav { flex: 1 1 180px; display: flex; flex-direction: column; }
.k-footer__nav a { display: flex; align-items: center; min-height: 32px; color: var(--muted); }
.k-footer__nav a:hover { color: var(--text); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.k-footer__copy { color: var(--muted); margin-top: 8px; }
.k-footer__copy a { color: var(--accent-text); text-decoration: underline; text-underline-offset: 3px; }
.k-footer__counter { margin-top: 8px; }
.k-footer__counter img { display: block; }


/* 8. РЕКЛАМНЫЕ МЕСТА
   Внутрь .ad-slot__body вставляется код блока. Высота зарезервирована
   (нет сдвига вёрстки). .ad-slot--demo рисует заглушку пунктиром.
   -------------------------------------------------------------------------- */
.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;
}
.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--rail { --ad-h: 600px; position: sticky; top: 24px; }
.ad-slot--feed { --ad-h: 260px; }
.ad-slot--wide { --ad-h: 200px; }
.ad-slot--inline { --ad-h: 280px; }
.ad-slot--demo { border-style: dashed; border-color: var(--ad-border); }
.ad-slot--demo .ad-slot__body { text-align: center; color: var(--muted); font-size: 14px; }
/* Плавающий блок внизу (Floor Ad / Anchor) только на телефоне */
.ad-slot--floor {
	position: sticky; bottom: 0; z-index: 30; display: none; flex-direction: row; align-items: center;
	border-radius: 0; border-width: 1px 0 0; padding: 6px 8px 8px 12px; background: var(--surface2);
}
.ad-slot--floor .ad-slot__body { --ad-h: 56px; flex: 1; }
@media (max-width: 719px) { .ad-slot--floor { display: flex; } }
@media (max-width: 1023px) { .ad-slot--rail { position: static; --ad-h: 250px; } }


/* 9. БАЗОВЫЕ КОМПОНЕНТЫ ДЛЯ СТРАНИЦ
   --------------------------------------------------------------------------
   Цвет ткани задаётся переменной --cover на самом элементе или на предке:
     style="--cover: var(--spine-3)"  либо класс .k-c1 ... .k-c8
   -------------------------------------------------------------------------- */
.k-c1 { --cover: var(--spine-1); } .k-c2 { --cover: var(--spine-2); }
.k-c3 { --cover: var(--spine-3); } .k-c4 { --cover: var(--spine-4); }
.k-c5 { --cover: var(--spine-5); } .k-c6 { --cover: var(--spine-6); }
.k-c7 { --cover: var(--spine-7); } .k-c8 { --cover: var(--spine-8); }

/* Обложка 2:3. Внутри <img> (data-src/src) или текст-заглушка в .k-cover__t.
   Пока картинка грузится, виден цвет ткани. */
.k-cover {
	position: relative; display: block; aspect-ratio: 2 / 3; overflow: hidden;
	border-radius: 6px; background: var(--cover, var(--spine-5)); color: var(--cloth-text);
	transition: transform 160ms var(--ease);
}
.k-cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.k-cover__t {
	position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: flex-end;
	padding: 10px; font-size: 14px; line-height: 1.15; font-weight: 500;
}
.k-cover--shadow { box-shadow: var(--shadow); }
a:hover > .k-cover, a:hover .k-cover { transform: translateY(-2px); }

/* Карточка книги в списке: <a class="k-card"> .k-cover + .k-card__title + .k-card__author */
.k-card { display: flex; flex-direction: column; gap: 6px; color: var(--text); min-width: 0; }
.k-card__title { margin-top: 2px; font-size: 15px; line-height: 1.3; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.k-card__author { font-size: 14px; color: var(--muted); }
.k-card:hover .k-card__title { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }

/* Крупная карточка (первая в ленте) */
.k-book-feature { display: flex; gap: 24px; padding: 24px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
.k-book-feature__cover { flex: 0 0 132px; align-self: flex-start; }
.k-book-feature__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
@media (max-width: 719px) {
	.k-book-feature { gap: 14px; padding: 16px; }
	.k-book-feature__cover { flex-basis: 88px; }
}

/* Панель-поверхность */
.k-surface { padding: 24px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
@media (max-width: 719px) { .k-surface { padding: 16px; } }

/* Полка корешков (серия, «Мои списки») */
.k-shelf {
	display: flex; align-items: flex-end; gap: 4px; margin: 0; padding: 0 12px 0;
	min-height: 262px; border-bottom: 4px solid var(--line); overflow-x: auto; overflow-y: hidden;
	padding-top: 12px;
}
.k-shelf > li { flex: 1 1 0; max-width: 76px; min-width: 44px; display: flex; }
.k-spine {
	position: relative; flex: 1; height: var(--spine-h, 200px);
	display: flex; flex-direction: column; align-items: center; justify-content: space-between;
	padding: 14px 0 10px; border-radius: 3px 3px 0 0;
	background: var(--cover, var(--spine-1)); color: var(--cloth-text);
	transition: transform 160ms var(--ease);
}
a.k-spine:hover { transform: translateY(-6px); color: var(--cloth-text); }
.k-spine__title {
	writing-mode: vertical-rl; transform: rotate(180deg); overflow: hidden; text-overflow: ellipsis;
	font-family: var(--font-spine); font-size: 17px; font-weight: 500; letter-spacing: .02em; white-space: nowrap;
}
.k-spine__n { font-size: 22px; font-weight: 600; line-height: 1; }
/* текущая книга выше остальных */
.k-spine--current, .k-spine[aria-current="true"], .k-spine[aria-current="page"] { --spine-h: 240px; }
/* ленточка у прочитанных: <span class="k-ribbon"> внутри .k-spine */
.k-ribbon {
	position: absolute; left: 58%; bottom: -22px; width: 8px; height: 22px; background: var(--ribbon);
	clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 72%, 0 100%);
}
.k-ribbon--static { position: relative; left: auto; bottom: auto; display: inline-block; }
@media (prefers-reduced-motion: reduce) { a.k-spine:hover, a:hover .k-cover { transform: none; } }

/* Рейтинг / метки / прогресс */
.k-tag { display: inline-flex; align-items: center; min-height: 32px; padding: 0 10px; border-radius: var(--radius); background: var(--chip); font-size: 14px; }
.k-progress { display: block; height: 3px; background: var(--chip); }
.k-progress > span { display: block; height: 100%; background: var(--ribbon); }
.k-muted { color: var(--muted); }
.k-read { font-family: var(--font-read); line-height: 1.6; }


/* 10. ВХОД, КОММЕНТАРИИ, ФОРМЫ (бывшее в styles.css)
   -------------------------------------------------------------------------- */
.login-overlay { position: fixed; z-index: 998; inset: 0; display: none; background: var(--overlay); }
.login-box {
	position: fixed; z-index: 999; left: 50%; top: 50%; transform: translate(-50%, -50%);
	display: none; width: 400px; max-width: calc(100% - 32px); max-height: calc(100vh - 32px); overflow-y: auto;
	padding: 32px; border: 1px solid var(--line); border-radius: var(--radius-lg);
	background: var(--surface); color: var(--text); box-shadow: var(--shadow);
}
body.zfix { overflow: hidden; }
.login-close {
	position: absolute; top: 4px; right: 4px; width: 44px; height: 44px; padding: 0;
	border: 0; border-radius: var(--radius); background: transparent; color: var(--muted); cursor: pointer; font-size: 20px;
}
.login-close:hover { background: var(--hover); color: var(--text); }
.login-title { margin-bottom: 16px; font-size: 22px; font-weight: 600; letter-spacing: -0.03em; text-align: center; }
.login-avatar { width: 64px; height: 64px; margin: 0 auto 16px; border-radius: 50%; overflow: hidden; background: var(--chip); }
.login-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.login-input { margin-bottom: 12px; }
.login-btn button { width: 100%; margin: 8px 0 12px; }
.login-btm { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.login-btm a { display: inline-flex; align-items: center; min-height: 44px; color: var(--accent-text); font-size: 14px; text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.login-btm a::after, .login-soc-title::after { content: attr(data-text); }
.login-menu { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--border); border-left: 1px solid var(--border); }
.login-menu li { border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.login-menu a { display: flex; align-items: center; justify-content: center; min-height: 48px; padding: 6px; font-size: 14px; text-align: center; }
.login-menu a:hover { background: var(--hover); }
.login-menu li .fa { display: none; }
.login-admin { margin: -8px 0 20px; text-align: center; }
.login-admin a { color: var(--accent-text); text-decoration: underline; }
.login-soc-title { margin: 24px 0 12px; text-align: center; color: var(--muted); font-size: 14px; }
.login-soc-btns { display: flex; justify-content: center; gap: 8px; }
.login-soc-btns a { display: inline-block; }
.login-soc-btns img { display: block; width: 36px; height: 36px; border-radius: 50%; }

.add-comm-btn { cursor: pointer; }
.add-comms { display: none; margin-bottom: 20px; padding: 20px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
.ac-inputs { display: flex; gap: 12px; margin-bottom: 12px; }
.ac-inputs input { flex: 1; }
.ac-textarea textarea { min-height: 120px; margin-bottom: 12px; }
.ac-protect, .ac-textarea .bb-editor + br { display: none; }
.comments_subscribe { display: block; }
.comments_subscribe input { margin-right: 10px; }
.mass_comments_action { margin: 20px 0 0; padding: 10px; background: var(--chip); text-align: right; border-radius: var(--radius); }
.last-comm-link { margin-bottom: 10px; text-decoration: underline; text-underline-offset: 3px; }

.comm-item { display: flex; gap: 16px; margin-bottom: 20px; font-size: 15px; }
.comm-left { position: relative; flex: 0 0 40px; width: 40px; }
.comm-right { flex: 1; min-width: 0; position: relative; }
.comm-img { position: relative; width: 40px; height: 40px; border-radius: 50%; overflow: hidden; background: var(--chip); }
.comm-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.comm-letter {
	position: absolute; left: 0; top: 0; width: 40px; height: 40px; line-height: 40px; text-align: center; border-radius: 50%;
	background: var(--spine-5); color: var(--cloth-text); font-size: 18px; font-weight: 500; text-transform: uppercase;
}
.comm-one { display: flex; flex-wrap: wrap; gap: 2px 12px; color: var(--muted); font-size: 14px; }
.comm-one > span.comm-author, .comm-one > span.comm-author a { color: var(--text); font-weight: 500; }
.comm-two { margin: 4px 0; color: var(--text); }
.comm-three { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; font-size: 14px; }
.comm-three-left, .comm-three-left a, .comm-three-right a { color: var(--muted); }
.comm-three-right li { display: inline-block; margin-left: 12px; }
.comm-three a:hover, .reply:hover { text-decoration: underline; }
.reply { cursor: pointer; display: inline-flex; align-items: center; min-height: 32px; color: var(--muted); }
.comm-rate3 { display: inline-flex; align-items: center; gap: 6px; margin-right: 12px; color: var(--muted); white-space: nowrap; }
.comm-rate3 a { color: var(--muted); }
.comm-rate3 a:hover { color: var(--text); }
.comm-rate3 > span > span.ratingtypeplus, .comm-rate3 > span > span.ratingplus { color: var(--success); }
.comm-rate3 > span > span.ratingminus { color: var(--danger); }
.comments-tree-list .comments-tree-list { padding-left: 24px; }

/* Формы DLE (регистрация, добавление, профиль) */
.form-wrap h1, .mtitle, .sub-title h1 { margin-bottom: 24px; font-size: 28px; font-weight: 600; letter-spacing: -0.03em; }
.form-item > label { color: var(--muted); }
.imp > label::after { content: "*"; margin: 0 0 0 6px; color: var(--ribbon); }
.form-secur input { max-width: 300px; }
.form-submit button:last-child { margin-left: 10px; }
.search-page, .search { margin-bottom: 20px; }


/* 11. ENGINE: перекраска engine.css под токены
   -------------------------------------------------------------------------- */
#loading-layer { background-color: var(--line); height: 4px !important; }
#loading-layer::before { background-color: var(--ribbon); }

.vote-title { background: var(--chip); border-radius: var(--radius); }
.vote label::before { background-color: var(--ctl); }
.vote input:checked + label::before { background-color: var(--ribbon); box-shadow: inset 0 0 0 4px var(--ribbon); }
.vote label:hover { color: var(--accent-text); }
button.vres, button.vall { background: var(--chip) !important; color: var(--muted) !important; }
button.vres:hover, button.vall:hover { background: var(--line) !important; color: var(--text) !important; }
.vote-buts2 .fa { color: var(--text); }

#pollbox { border-bottom-color: var(--border); }
.tableform td, .tableform th { border-top-color: var(--border); }
.checkbox { color: var(--muted); }
.form-textarea > label { background: var(--surface2); color: var(--text); }
.findrelated { background: var(--surface2); border-color: var(--line); color: var(--text); }
.xfieldsnote, fieldset legend { color: var(--muted); }
.file-box, .uploadedfile { border-color: var(--line); background: var(--surface); box-shadow: none; }
.qq-upload-drop-area { background: var(--surface2); color: var(--text); }
.qq-upload-drop-area-active { background: var(--chip); }
.progress { background: var(--chip); box-shadow: none; }
.progress .progress-bar, .progress-blue { background: var(--ribbon); background-image: none; border-color: var(--ribbon); }

.user-popup, .us-prof { background: var(--surface); color: var(--text); }
.us-prof { border: 1px solid var(--border); box-shadow: none; }
.usp-left, .usp-activ { background: var(--surface2); color: var(--text); }
.usp-activ > div + div { border-left-color: var(--border); }
.usp-av { border-color: var(--line); }
.up-img { border-color: var(--surface); box-shadow: none; }
.usp-name { background: var(--surface2); border-bottom-color: var(--border); }
.usp-meta li:nth-child(2n+1) { background: var(--chip); }
.usp-group span { color: var(--accent-text) !important; }
.offline, .online { background: var(--ctl); color: var(--bg); }
.online { background: var(--success); }
.usp-btn a { display: flex; }

#searchtable fieldset { border-color: var(--line); }
.sres-wrap { background: var(--surface); border-color: var(--border); }
.sres-wrap:nth-child(2n) { background: var(--bg); }
.sres-wrap:hover { border-color: var(--ctl); box-shadow: none; }
.sres-text { color: var(--text); }
.sres-text h2 { color: var(--text); }
.sres-date { background: var(--surface2); color: var(--text); }

.pm-menu a { background: var(--chip); color: var(--text); }
.pm-menu a:hover { background: var(--accent); color: var(--on-accent); }
.pm_progress_bar { background: var(--chip); }
.pm_progress_bar span { background: var(--ribbon); }
.pm, .userstop { border-color: var(--line); }
.pm tr td, .userstop tr td { border-color: var(--line); }
.pm tr:nth-child(1) { background: var(--surface2); color: var(--text); }
.pm tr:nth-child(2n+2), .userstop tr:nth-child(2n+2) { background: var(--surface); }

.scriptcode, .title_spoiler, .text_spoiler, .hide, .inhide { background: var(--surface); border-color: var(--border); color: var(--text); }
.scriptcode { color: var(--success); }
.quote { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); }
.quote::after { color: var(--line); }
.hide a { color: var(--accent-text); }

.calendar { color: var(--text); }
.calendar td.day, .calendar td.day-active-v, .calendar th.workday { border-color: var(--border); background: var(--surface); }
.calendar td.weekday, .calendar td.day-active, .calendar th.weekday { border-color: var(--border); background: var(--surface2); }
.day-active a, .day-active-v a, .archives { color: var(--accent-text); }
.calendar td.day-current { background: var(--ribbon); }
#dle_news_archive_link .archives { color: var(--text); }

.quick-edit-textarea, .quick-edit-text { background: var(--bg); color: var(--text); border: 1px solid var(--ctl); box-shadow: none; }

#dropmenudiv { background: var(--surface); color: var(--text); border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: var(--radius); }
#dropmenudiv a { color: var(--text); }
#dropmenudiv a:hover { background: var(--hover); }

.highslide-wrapper, .highslide-outline, .highslide-html, .highslide-caption { background: var(--surface); color: var(--text); }
.highslide-image { border-color: var(--surface); }

.cloud-tags span a { border: 1px solid var(--line); border-radius: var(--radius); }
.cloud-tags span a:hover { background: var(--accent); color: var(--on-accent); box-shadow: none; }

#searchsuggestions { background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); font-size: 14px; }
#searchsuggestions a, #searchsuggestions span.notfound { border-bottom-color: var(--border); }
#searchsuggestions a { color: var(--text); }
#searchsuggestions a:hover { background: var(--hover); color: var(--text); }
#searchsuggestions span.seperator a { background: var(--surface2); color: var(--accent-text); }

.ui-widget-overlay { background: var(--overlay); opacity: 1; }
.ui-dialog, .ui-widget-content { background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.ui-dialog .ui-dialog-titlebar, .ui-widget-header { background: var(--surface2); color: var(--text); border: 0; border-bottom: 1px solid var(--border); border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.ui-dialog-title { font-weight: 600; letter-spacing: -0.02em; }
.ui-dialog .ui-dialog-buttonpane { background: var(--surface2); border-top: 1px solid var(--border); }
.ui-dialog .ui-dialog-buttonpane button { height: auto; min-height: 44px; line-height: 1.2; }
.ui-icon-closethick::before { color: var(--text); }
.ui-state-error { background: var(--surface) !important; border: 1px solid var(--danger); color: var(--danger); }
.ui-menu { background: var(--surface); border-color: var(--line); color: var(--text); }
.ui-menu .ui-menu-item a.ui-state-hover, .ui-menu .ui-menu-item a.ui-state-active { background: var(--hover); border-color: var(--line); color: var(--text); }

.voteprogress, .pollprogress { background: var(--chip); background-image: none; box-shadow: none; }
.voteprogress span, .pollprogress span { background: var(--ctl); background-image: none; text-shadow: none; }
.voteprogress .vote2, span.poll1 { background: var(--ribbon); background-image: none; }
.voteprogress .vote3, span.poll2 { background: var(--success); background-image: none; }
.voteprogress .vote4, span.poll3 { background: var(--spine-6); background-image: none; }
.voteprogress .vote5, span.poll4 { background: var(--spine-4); background-image: none; }

#dlefastreplycomments { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.commentsreplyname { background: var(--bg); color: var(--text); border-color: var(--ctl); }
.dle-captcha img { transition: opacity 140ms ease; }

/* Стол заказов (orderdesc.css жёстко светлый, подправляем контраст) */
.orderdesc-area { color: var(--text); }
.orderdesc-h { font: 600 22px/1.2 var(--font); letter-spacing: -0.03em; color: var(--text); }
.orderdesc-add-area { background: var(--surface); }
.orderdesc-add-area-row-input { background: var(--bg); color: var(--text); border-color: var(--ctl); }
.orderdesc-table td, .orderdesc-table th { color: var(--text); border-color: var(--border); }
.orderdesc-table tr:hover { background: var(--hover); }


/* 12. УСТАРЕВШИЕ КЛАССЫ СТАРОГО ШАБЛОНА (мост на время переверстки)
   Нужны, пока fullstory/shortstory/comments/userinfo и др. ещё на старой
   разметке. Когда страница переверстана на k-*, соответствующий блок удалить.
   -------------------------------------------------------------------------- */
.fx-row { display: flex; flex-wrap: wrap; justify-content: space-between; }
.fx-col { display: flex; flex-direction: column; }
.fx-center { justify-content: center; }
.fx-middle { align-items: center; }
.fx-start { justify-content: flex-start; }
.fx-first { order: -1; }
.fx-last { order: 10; }
.fx-1 { flex: 1 1 0; max-width: 100%; min-width: 50px; }
.fx-between { justify-content: space-between; }
.icon-left .fa, .icon-left .far, .icon-left .fas { margin-right: 8px; }
.icon-right .fa, .icon-right .far, .icon-right .fas { margin-left: 8px; }
.anim { transition: color 140ms ease, opacity 140ms ease; }

.img-box, .img-wide, .img-square, .img-resp, .img-resp-vert, .img-resp-sq, .img-fit { overflow: hidden; position: relative; }
.img-resp { padding-top: 60%; }
.img-resp-vert { padding-top: 150%; }
.img-resp-sq { padding-top: 100%; }
.img-box img, .img-square img, .img-resp img, .img-resp-vert img, .img-resp-sq img { width: 100%; min-height: 100%; display: block; }
.img-resp img, .img-resp-vert img, .img-resp-sq img { position: absolute; left: 0; top: 0; }
.img-wide img { width: 100%; display: block; }
.img-fit img { width: 100%; height: 100%; object-fit: cover; }

.sect, .sect-header { margin-bottom: 24px; }
.sect-title { font-size: 30px; font-weight: 600; letter-spacing: -0.03em; line-height: 1.15; }
.sect-title-small { font-size: 20px; }
.sect-items { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 24px 16px; align-items: start; }
.single-item { width: auto; padding: 0; margin: 0; min-width: 0; }
.single-item-link { display: block; }
.single-item-img { margin-bottom: 8px; border-radius: 6px; background: var(--spine-5); }
.single-item-title { font-size: 15px; font-weight: 500; line-height: 1.3; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.single-item-subtitle { margin-top: 4px; font-size: 14px; color: var(--muted); }
.single-item-subtitle a:not(:hover) { color: var(--muted); }
.single-item-link:hover .single-item-title { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.mb-remove { margin-bottom: 0; }
#dle-content > *:not(.single-item) { max-width: 100%; }
.sect-items > .single-item ~ #dle-ajax-comments { grid-column: 1 / -1; }
.speedbar { font-size: 14px; color: var(--muted); margin-bottom: 16px; }
.speedbar a { color: var(--muted); }
.speedbar a:hover { color: var(--text); text-decoration: underline; }
.speedbar .far { display: none; }

.fheader { margin-bottom: 16px; }
.fheader h1 { font-size: 30px; }
.fleft { width: 200px; margin-right: 30px; }
.fimg { margin-bottom: 16px; border-radius: 6px; }
.fctrl { width: 200px; margin-left: 30px; }
.finfo { margin-top: 10px; line-height: 1.6; }
.finfo li { padding: 5px; }
.finfo li > span:first-child { color: var(--muted); margin-right: 5px; }
.finfo li:nth-child(2n+1) { background: var(--surface); border-radius: var(--radius); }
.finfo a { color: var(--accent-text); text-decoration: underline; }
.fdl, .fhelp, .fadd { margin-top: 16px; position: relative; }
.fdl-title { font-weight: 600; font-size: 17px; margin-bottom: 12px; width: 100%; }
.fdl-item + .fdl-item { margin-top: 10px; }
.fdl-btn { display: inline-flex; align-items: center; min-height: 32px; padding: 0 10px; border-radius: var(--radius); background: var(--accent); color: var(--on-accent); font-size: 13px; }
.fcompl a { display: inline-block; margin-top: 16px; color: var(--danger); text-decoration: underline; }
.fhelp a { color: var(--accent-text); text-decoration: underline; }
.btn-add { padding: 0 10px; }
.dropdown-add { position: absolute; left: 0; top: 100%; z-index: 99; display: none; padding: 12px 20px; line-height: 2; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.dropdown-add span:hover { cursor: pointer; text-decoration: underline; }
.frate-title { margin-bottom: 12px; }
.frate-box { margin-bottom: 10px; padding: 4px 14px 6px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.frate [class*=myicon] { display: inline-block; width: 30px; height: 30px; line-height: 30px; margin-right: 10px; border-radius: 50%; text-align: center; vertical-align: top; background: var(--success); color: var(--bg); font-size: 18px; }
.frate [class*=myicon-thumb_down] { background: var(--danger); }
.fr-count { position: relative; width: 60px; height: 60px; border-radius: 50%; background: var(--chip); box-shadow: inset 0 0 0 5px var(--line); }
.fr-count > div { position: absolute; left: 0; top: 0; z-index: 1; width: 100%; height: 100%; padding-top: 10px; text-align: center; font-size: 18px; font-weight: 600; }
.fr-count > div div { margin-top: 0; font-size: 11px; font-weight: 400; color: var(--muted); }
.rate-plus, .rate-minus { cursor: pointer; display: flex; align-items: center; min-height: 44px; font-size: 16px; }
.rate-plus:hover [class*=myicon], .rate-minus:hover [class*=myicon] { opacity: .6; }
.rel-item { width: 48%; margin-bottom: 16px; }
.rel-img { width: 80px; height: 120px; margin-right: 16px; border-radius: 6px; }
.rel-title { font-size: 17px; }
.rel-text { color: var(--muted); margin-top: 6px; }
.pravo { font-size: 18px; color: var(--danger); }
.svert { overflow: hidden; padding: 3px 0; }
.svert-link { color: var(--accent-text); text-decoration: underline; }

.full-text { line-height: 1.65; font-size: 16px; }
.full-text img:not(.emoji) { max-width: 100%; margin: 10px 0; }
.full-text h2, .full-text h3, .full-text h4, .full-text h5 { margin: 16px 0 8px; font-size: 22px; font-weight: 600; letter-spacing: -0.03em; }
.full-text p { margin-bottom: 10px; }
.full-text ul li { list-style: disc; margin-left: 40px; }
.full-text ol li { list-style: decimal; margin-left: 40px; }
.video-box embed, .video-box object, .video-box video, .video-box iframe, .video-box frame { max-width: 100% !important; display: block; width: 100%; height: 400px; }
.full-taglist { margin-top: 20px; }
.full-taglist a { color: var(--accent-text); }
.full-taglist span:not(.fa):not(:last-child)::after { content: ","; }

.genres-page { color: var(--text); }
.genres-hero { margin-bottom: 24px; }
.genres-hero__label { display: none; }
.genres-hero h1 { font-size: 30px; }
.genres-catalog__text:empty { display: none; }
.full-text .genres-list, .full-text .genres-list__sub { margin: 0; padding: 0; }
.full-text .genres-list__item { list-style: none; margin: 0; }
.genres-list > .genres-list__item { margin-bottom: 28px; }
.genres-list__link { display: inline-flex; align-items: baseline; min-height: 32px; color: var(--accent-text) !important; font-size: 17px; line-height: 1.35; text-decoration: none !important; }
.genres-list > .genres-list__item > .genres-list__link { margin-bottom: 8px; color: var(--text) !important; font-size: 22px; font-weight: 600; letter-spacing: -0.02em; }
.genres-list__link:hover { text-decoration: underline !important; }
.genres-list__sub { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 28px; row-gap: 4px; }
.genres-list__sub .genres-list__sub .genres-list__link { font-size: 15px; color: var(--muted) !important; }

.attach, .file-box { color: var(--text); }
.telegram-channel a { display: block; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); }

@media (max-width: 1023px) {
	.fleft { margin: 0 auto 16px; }
	.fright { min-width: 100%; }
	.fctrl { width: 100%; margin: 16px 0 0; }
}
@media (max-width: 719px) {
	.sect-items { grid-template-columns: repeat(2, minmax(0, 1fr)); }
	.sect-title, .fheader h1 { font-size: 24px; }
	.rel-item { width: 100%; }
	.ac-inputs { flex-direction: column; }
	.video-box embed, .video-box object, .video-box video, .video-box iframe, .video-box frame { height: 250px; }
	.ui-dialog { width: 100% !important; }
	.mass_comments_action { display: none; }
	.login-box { padding: 24px 16px; }
	.k-title { font-size: 24px; }
}

/* Knigi Quotes: дописать в конец templates/knigi2/style/knigi2.css (общий файл: цитаты есть и на странице книги, и в профиле). */
.kb-quotes__count { color: var(--muted); font-size: 15px; }
.kb-quotes { display: flex; flex-direction: column; gap: 12px; margin: 0; padding: 0; list-style: none; }
.kb-quote { padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius); }
.kb-quote__text {
	position: relative; margin: 0; padding: 0 0 0 26px;
	font-family: var(--font-read); font-size: 17px; line-height: 1.55; overflow-wrap: anywhere;
}
.kb-quote__text::before {
	content: "\201C"; position: absolute; left: 0; top: -2px;
	color: var(--ribbon); font-size: 34px; line-height: 1;
}
.kb-quote__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; margin-top: 10px; color: var(--muted); font-size: 14px; }
.kb-quote__meta a { color: var(--accent-text); }
.kb-quote__del {
	min-height: 44px; margin-left: auto; padding: 0 12px;
	border: 1px solid var(--line); border-radius: var(--radius); background: transparent; color: var(--muted); font: inherit; cursor: pointer;
}
.kb-quote__del:hover { color: var(--danger); border-color: var(--danger); }
.kb-quote__del:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }
.kb-quotes__more { margin-top: 12px; }
.kb-quotes__hint { margin: 12px 0 0; color: var(--muted); font-size: 15px; }

/* Knigi Series Subscribe: дописать в templates/knigi2/style/knigi2.css (кнопки .kb-follow и .k-series__follow уже оформлены в k-book.css / k-home.css). */
[data-follow-news][aria-busy="true"] { opacity: .6; cursor: progress; }

.ks-subs__list { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; list-style: none; }
.ks-sub { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.ks-sub a { color: var(--accent-text); overflow-wrap: anywhere; }
.ks-subs__hint { margin: 12px 0 0; color: var(--muted); font-size: 15px; }

.ks-toast {
	position: fixed; left: 50%; bottom: 24px; z-index: 1000; transform: translateX(-50%);
	max-width: calc(100% - 32px); padding: 12px 16px; border-radius: var(--radius);
	background: var(--accent); color: var(--on-accent); font-size: 15px;
}

/* Рекламные места: пустой баннер (нет кода) не занимает места; A4 «Лента» не показываем на телефоне вместе с Floor Ad */
.ad-slot:has(> .ad-slot__body:empty) { display: none; }
@media (max-width: 719px) { .kb-ad--a4 { display: none; } }

/* ==========================================================================
   Статические страницы и справочные статьи (static.tpl; блоки .kh-* пишутся в тексте страницы)
   ========================================================================== */
.k-static { max-width: 760px; }
.k-static__title { margin: 8px 0 20px; }
.kh { font-size: 17px; line-height: 1.65; }
.kh p { margin: 0 0 14px; }
.kh h2 { margin: 44px 0 14px; font-size: 26px; line-height: 1.2; font-weight: 600; letter-spacing: -0.03em; scroll-margin-top: 80px; }
.kh h3 { margin: 28px 0 10px; font-size: 20px; line-height: 1.3; font-weight: 600; letter-spacing: -0.02em; scroll-margin-top: 80px; }
.kh ul, .kh ol { margin: 0 0 16px; padding: 0; }
.kh ul li, .kh ol li { margin: 0 0 6px 24px; }
.kh ul li { list-style: disc; }
.kh ol li { list-style: decimal; }
.kh li::marker { color: var(--muted); }
.kh b, .kh strong { font-weight: 600; }
.kh kbd, .kh .kh-ui { display: inline-block; padding: 0 7px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); font: inherit; font-size: .92em; line-height: 1.5; white-space: nowrap; }
.kh code { padding: 1px 5px; border-radius: 4px; background: var(--chip); font-size: .9em; }
.kh-lead { font-size: 19px; line-height: 1.6; color: var(--text); }
.kh-muted { color: var(--muted); }

/* Оглавление-чипы */
.kh-toc { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 28px; padding: 0; }
.kh-toc li { list-style: none !important; margin: 0 !important; }
.kh-toc a { display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text); text-decoration: none; font-size: 15px; }
.kh-toc a:hover { background: var(--hover); }

/* Коротко: карточки по устройствам */
.kh-quick { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 0 0 24px; }
.kh-quick__item { padding: 16px 18px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
.kh-quick__dev { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; font-weight: 600; }
.kh-quick__dev svg { flex: 0 0 auto; color: var(--muted); }
.kh-quick__fmt { display: inline-block; margin: 0 6px 6px 0; padding: 1px 8px; border-radius: 6px; background: var(--chip); font-size: 13px; font-weight: 600; letter-spacing: .02em; }
.kh-quick__item p { margin: 0; font-size: 15px; line-height: 1.5; color: var(--muted); }
.kh-quick__item a { color: var(--accent-text); }

/* Шаги */
.kh-steps { counter-reset: kh-step; margin: 0 0 20px; padding: 0; }
.kh-steps > li { position: relative; list-style: none !important; margin: 0 0 18px !important; padding-left: 48px; }
.kh-steps > li::before { counter-increment: kh-step; content: counter(kh-step); position: absolute; left: 0; top: -1px; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: var(--on-accent); font-size: 15px; font-weight: 600; }

/* Иллюстрации */
.kh-fig { margin: 8px 0 24px; text-align: center; }
.kh-fig img { display: block; width: 100%; max-width: 360px; max-height: 620px; object-fit: contain; height: auto; margin: 0 auto !important; }
.kh-fig--wide img { max-width: 720px; }
.kh-fig figcaption { margin-top: 8px; font-size: 14px; line-height: 1.45; color: var(--muted); }
.kh-figs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin: 8px 0 24px; }
.kh-figs .kh-fig { margin: 0; }

/* Подсказки */
.kh-note { margin: 0 0 20px; padding: 14px 18px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); font-size: 16px; line-height: 1.55; }
.kh-note > :last-child { margin-bottom: 0; }
.kh-note__t { display: block; margin-bottom: 4px; font-weight: 600; }
.kh-note--tip { box-shadow: inset 4px 0 0 var(--success); }
.kh-note--warn { box-shadow: inset 4px 0 0 var(--ribbon); }

/* Таблица */
.kh-table { overflow-x: auto; margin: 0 0 24px; border: 1px solid var(--border); border-radius: var(--radius-lg); }
.kh-table table { width: 100%; border-collapse: collapse; font-size: 15px; line-height: 1.45; }
.kh-table th, .kh-table td { padding: 10px 14px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.kh-table th { background: var(--surface2); font-weight: 600; white-space: nowrap; }
.kh-table tr:last-child td { border-bottom: 0; }
.kh-table td:first-child { font-weight: 600; white-space: nowrap; }

/* Вопросы и ответы */
.kh-faq { margin: 0 0 24px; border-top: 1px solid var(--border); }
.kh-faq details { border-bottom: 1px solid var(--border); }
.kh-faq summary { position: relative; display: block; padding: 16px 40px 16px 0; font-weight: 600; cursor: pointer; list-style: none; }
.kh-faq summary::-webkit-details-marker { display: none; }
.kh-faq summary::after { content: ""; position: absolute; right: 8px; top: 50%; width: 9px; height: 9px; margin-top: -7px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform .2s var(--ease); }
.kh-faq details[open] summary::after { transform: rotate(-135deg); margin-top: -2px; }
.kh-faq details > div { padding: 0 0 16px; }
.kh-faq details > div > :last-child { margin-bottom: 0; }

/* Карточки программ */
.kh-apps { display: grid; gap: 14px; margin: 0 0 24px; }
.kh-app { padding: 18px 20px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
.kh-app__head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 12px; margin-bottom: 8px; }
.kh-app__name { margin: 0 !important; font-size: 19px !important; }
.kh-app__badge { padding: 1px 8px; border-radius: 6px; background: var(--accent-soft); color: var(--accent-text); font-size: 13px; font-weight: 600; }
.kh-app__meta { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; padding: 0; }
.kh-app__meta li { list-style: none !important; margin: 0 !important; padding: 1px 8px; border-radius: 6px; background: var(--chip); font-size: 13px; }
.kh-app p { font-size: 16px; line-height: 1.55; }
.kh-app__links { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 0; }
.kh-app__links a { display: inline-flex; align-items: center; min-height: 36px; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--radius); color: var(--text); text-decoration: none; font-size: 14px; }
.kh-app__links a:hover { background: var(--hover); }

/* Ссылки-продолжения */
.kh-next { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 28px 0 8px; }
.kh-next a { display: block; padding: 16px 18px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); color: var(--text); text-decoration: none; }
.kh-next a:hover { background: var(--hover); }
.kh-next b { display: block; margin-bottom: 2px; }
.kh-next span { color: var(--muted); font-size: 15px; }

@media (max-width: 719px) {
	.kh { font-size: 16px; }
	.kh-lead { font-size: 17px; }
	.kh h2 { margin-top: 36px; font-size: 22px; }
	.kh-quick, .kh-figs, .kh-next { grid-template-columns: minmax(0, 1fr); }
	.kh-steps > li { padding-left: 42px; }
	.kh-table td:first-child { white-space: normal; }
}
.kh-steps--from3 { counter-reset: kh-step 2; }

/* Knigi Reco: если подобрать нечего, блок «Рекомендуем» не показываем */
.k-reco:not(:has(li)) { display: none; }
