diff --git a/.gitignore b/.gitignore
index dddce45..61cef9b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -18,3 +18,4 @@ apps/api/uploads/
/kb-seed.zip
/REVIEW.md
/PROMPT_CLAUDE_DESIGN.md
+scripts/_*
diff --git a/apps/api/src/app.ts b/apps/api/src/app.ts
index 94aee5e..069ca18 100644
--- a/apps/api/src/app.ts
+++ b/apps/api/src/app.ts
@@ -1,6 +1,9 @@
import express, { type ErrorRequestHandler } from 'express';
import type { HealthResponse } from '@kb/shared';
import { prisma } from './db.js';
+import { env } from './env.js';
+import { HttpError } from './http.js';
+import { contentRouter } from './routes/content.js';
export function createApp() {
const app = express();
@@ -17,12 +20,37 @@ export function createApp() {
res.json(body);
});
+ // Загруженные файлы. Имена картинок не меняются при замене содержимого редко,
+ // поэтому кешируем на сутки, а дальше браузер перепроверяет по ETag.
+ app.use(
+ '/uploads',
+ express.static(env.UPLOADS_DIR, {
+ index: false,
+ dotfiles: 'deny',
+ maxAge: '1d',
+ setHeaders(res, file) {
+ res.setHeader('X-Content-Type-Options', 'nosniff');
+ // Исходники (PDF/DOCX) всегда скачиваются, а не открываются в браузере
+ if (!/\.(webp|png|jpe?g|gif)$/i.test(file)) res.setHeader('Content-Disposition', 'attachment');
+ },
+ }),
+ );
+ app.use('/uploads', (_req, res) => {
+ res.status(404).json({ error: 'Файл не найден' });
+ });
+
+ app.use('/api', contentRouter);
+
app.use('/api', (_req, res) => {
res.status(404).json({ error: 'Не найдено' });
});
// Единая обработка ошибок: клиенту короткое сообщение, подробности в лог.
const onError: ErrorRequestHandler = (err, _req, res, _next) => {
+ if (err instanceof HttpError) {
+ res.status(err.status).json({ error: err.message });
+ return;
+ }
console.error(err);
res.status(500).json({ error: 'Внутренняя ошибка сервера' });
};
diff --git a/apps/api/src/http.ts b/apps/api/src/http.ts
new file mode 100644
index 0000000..8f0b8a5
--- /dev/null
+++ b/apps/api/src/http.ts
@@ -0,0 +1,9 @@
+/** Ошибка с HTTP-кодом: бросаем из обработчика, общий обработчик в app.ts превращает её в ответ. */
+export class HttpError extends Error {
+ constructor(
+ public status: number,
+ message: string,
+ ) {
+ super(message);
+ }
+}
diff --git a/apps/api/src/routes/content.ts b/apps/api/src/routes/content.ts
new file mode 100644
index 0000000..bd18d15
--- /dev/null
+++ b/apps/api/src/routes/content.ts
@@ -0,0 +1,95 @@
+import { Router } from 'express';
+import type { Article, Section, Space } from '@prisma/client';
+import { parseCheatSheet, renderMarkdown } from '@kb/md';
+import type { ArticleDto, ArticleListItem, SectionDto, SpaceDto, TreeResponse, PlaqueColor } from '@kb/shared';
+import { prisma } from '../db.js';
+import { HttpError } from '../http.js';
+
+export const contentRouter = Router();
+
+export const toSpaceDto = (s: Space): SpaceDto => ({ id: s.id, name: s.name, slug: s.slug, icon: s.icon, order: s.order });
+
+export const toSectionDto = (s: Section): SectionDto => ({
+ id: s.id,
+ spaceId: s.spaceId,
+ name: s.name,
+ slug: s.slug,
+ code: s.code,
+ color: s.color as PlaqueColor,
+ icon: s.icon,
+ order: s.order,
+});
+
+type ArticleWithAssets = Article & { assets: { size: number }[] };
+
+export const toListItem = (a: ArticleWithAssets): ArticleListItem => ({
+ id: a.id,
+ slug: a.slug,
+ title: a.title,
+ summary: a.summary,
+ sectionId: a.sectionId,
+ order: a.order,
+ tags: a.tags,
+ equipment: a.equipment,
+ docCode: a.docCode,
+ pinned: a.pinned,
+ status: a.status,
+ visibility: a.visibility,
+ version: a.version,
+ updatedAt: a.updatedAt.toISOString(),
+ imageCount: a.assets.length,
+ bytes: a.assets.reduce((n, x) => n + x.size, 0),
+});
+
+// Всё дерево одним запросом: пространства, разделы и список статей (без текста).
+// Статей сотни, не тысячи, поэтому отдельные запросы на каждый раздел не нужны,
+// а для офлайна один ответ кешировать проще.
+contentRouter.get('/tree', async (_req, res) => {
+ const [spaces, sections, articles] = await Promise.all([
+ prisma.space.findMany({ orderBy: { order: 'asc' } }),
+ prisma.section.findMany({ orderBy: { order: 'asc' } }),
+ prisma.article.findMany({
+ where: { status: 'PUBLISHED' },
+ orderBy: [{ order: 'asc' }, { title: 'asc' }],
+ include: { assets: { select: { size: true } } },
+ }),
+ ]);
+ const body: TreeResponse = {
+ spaces: spaces.map(toSpaceDto),
+ sections: sections.map(toSectionDto),
+ articles: articles.map(toListItem),
+ };
+ res.json(body);
+});
+
+contentRouter.get('/articles/:slug', async (req, res) => {
+ const art = await prisma.article.findUnique({
+ where: { slug: req.params.slug },
+ include: {
+ assets: { select: { size: true } },
+ attachments: { orderBy: { createdAt: 'asc' } },
+ author: { select: { name: true } },
+ },
+ });
+ if (!art || art.status !== 'PUBLISHED') throw new HttpError(404, 'Статья не найдена');
+
+ // Список картинок берём из самого текста (а не из Asset): так порядок совпадает с порядком в статье
+ const { figures, toc } = renderMarkdown(art.bodyMd);
+ const cheat = art.pinned ? parseCheatSheet(art.bodyMd) : null;
+ const body: ArticleDto = {
+ ...toListItem(art),
+ bodyMd: art.bodyMd,
+ bodyHtml: art.bodyHtml,
+ attachments: art.attachments.map((a) => ({
+ id: a.id,
+ filename: a.filename,
+ url: `/uploads/${a.path}`,
+ size: a.size,
+ })),
+ images: figures.flatMap((f) => [f.thumb, f.full]),
+ authorName: art.author?.name ?? null,
+ toc,
+ cheat: cheat?.ok ? cheat : null,
+ };
+ res.json(body);
+});
diff --git a/apps/web/index.html b/apps/web/index.html
index c0ab62e..cb31b72 100644
--- a/apps/web/index.html
+++ b/apps/web/index.html
@@ -1,9 +1,15 @@
-
+
+
+
+
+
Памятки монтажника
+
+
diff --git a/apps/web/package.json b/apps/web/package.json
index 192efa5..fb42010 100644
--- a/apps/web/package.json
+++ b/apps/web/package.json
@@ -14,6 +14,7 @@
"@kb/md": "workspace:^",
"@kb/shared": "workspace:^",
"@tanstack/react-query": "^5.104.1",
+ "qrcode-generator": "^2.0.4",
"react": "^19.3.0",
"react-dom": "^19.3.0",
"react-router-dom": "^7.18.4"
diff --git a/apps/web/public/favicon.svg b/apps/web/public/favicon.svg
new file mode 100644
index 0000000..40d2196
--- /dev/null
+++ b/apps/web/public/favicon.svg
@@ -0,0 +1 @@
+ПМ
diff --git a/apps/web/public/theme-init.js b/apps/web/public/theme-init.js
new file mode 100644
index 0000000..c67ae67
--- /dev/null
+++ b/apps/web/public/theme-init.js
@@ -0,0 +1,9 @@
+// Отдельный файл (а не код в index.html): так политика безопасности CSP может запретить инлайн-скрипты.
+(function () {
+ try {
+ var t = JSON.parse(localStorage.getItem('kb-theme') || '"dark"');
+ if (t === 'light' || t === 'sun' || t === 'dark') document.documentElement.setAttribute('data-theme', t);
+ } catch {
+ /* тема по умолчанию */
+ }
+})();
diff --git a/apps/web/src/App.tsx b/apps/web/src/App.tsx
new file mode 100644
index 0000000..b66a2bb
--- /dev/null
+++ b/apps/web/src/App.tsx
@@ -0,0 +1,45 @@
+import { lazy, Suspense } from 'react';
+import { Route, Routes } from 'react-router-dom';
+import { Screen } from './components/Shell';
+import { BackLink, Notice } from './components/ui';
+import { useTheme } from './lib/theme';
+import { ArticlePage } from './pages/Article';
+import { CheatSheetPage } from './pages/CheatSheet';
+import { FavoritesPage } from './pages/Favorites';
+import { HomePage } from './pages/Home';
+import { SearchPage } from './pages/Search';
+import { SectionPage } from './pages/Section';
+
+// Редко нужные экраны грузятся отдельными файлами, чтобы не замедлять чтение статей
+const PrintPage = lazy(() => import('./pages/Print'));
+
+function NotFound() {
+ return (
+
+
+ Главная
+
+ Проверьте адрес или вернитесь на главную.
+
+ );
+}
+
+export function App() {
+ // Тема применяется один раз здесь: вешает data-theme на
+ useTheme();
+
+ return (
+
+
+ } />
+ } />
+ } />
+ } />
+ } />
+ } />
+ } />
+ } />
+
+
+ );
+}
diff --git a/apps/web/src/components/ArticleBody.tsx b/apps/web/src/components/ArticleBody.tsx
new file mode 100644
index 0000000..17d85f6
--- /dev/null
+++ b/apps/web/src/components/ArticleBody.tsx
@@ -0,0 +1,145 @@
+// Тело статьи. HTML приходит готовым с сервера (или из рендера в редакторе),
+// здесь мы только «оживляем» его: галочки чек-листов, открытие фото, переходы по [[ссылкам]].
+
+import { memo, useEffect, useRef } from 'react';
+import { useNavigate } from 'react-router-dom';
+import { checkKey, getStored, setStored } from '../lib/store';
+
+export interface Figure {
+ src: string;
+ thumb: string;
+ caption: string;
+ file: string;
+}
+
+interface Props {
+ html: string;
+ /** slug и версия: ключ для хранения галочек. Без них (предпросмотр) галочки живут до перезагрузки. */
+ slug?: string;
+ version?: number;
+ onImage?: (index: number, figures: Figure[]) => void;
+ /** Актуальные названия статей для [[ссылок]] (если статью переименовали после сохранения этой). */
+ titles?: (slug: string) => string | undefined;
+}
+
+type Checks = Record;
+
+function paintChecks(root: HTMLElement, state: Checks) {
+ root.querySelectorAll('.kb-check').forEach((box) => {
+ const g = box.dataset.check ?? '0';
+ const rows = box.querySelectorAll('.kb-check-row');
+ let done = 0;
+ rows.forEach((row) => {
+ const on = !!state[`${g}-${row.dataset.i}`];
+ if (on) done++;
+ row.classList.toggle('is-on', on);
+ row.setAttribute('aria-pressed', String(on));
+ });
+ const count = box.querySelector('.kb-check-count');
+ if (count) count.textContent = `${done} из ${rows.length}`;
+ const fill = box.querySelector('.kb-check-fill');
+ if (fill) fill.style.width = `${rows.length ? (done / rows.length) * 100 : 0}%`;
+ });
+}
+
+function collectFigures(root: HTMLElement): Figure[] {
+ return [...root.querySelectorAll('.kb-fig')].map((fig) => {
+ const img = fig.querySelector('img');
+ const thumb = img?.getAttribute('src') ?? '';
+ return {
+ // Полноразмерный файл лежит рядом с превью: fig-1.480.webp → fig-1.webp
+ src: thumb.replace(/\.480\.webp$/, '.webp'),
+ thumb,
+ caption: fig.querySelector('figcaption')?.textContent ?? '',
+ file: img?.dataset.file ?? fig.querySelector('.kb-fig-miss')?.dataset.file ?? '',
+ };
+ });
+}
+
+function ArticleBodyInner({ html, slug, version, onImage, titles }: Props) {
+ const ref = useRef(null);
+ const navigate = useNavigate();
+ const storageKey = slug ? checkKey(slug, version ?? 1) : null;
+ // Для предпросмотра без slug состояние держим в памяти
+ const memory = useRef({});
+
+ useEffect(() => {
+ const root = ref.current;
+ if (!root) return;
+ const load = (): Checks => (storageKey ? getStored(storageKey, {}) : memory.current);
+ const save = (s: Checks) => (storageKey ? setStored(storageKey, s) : (memory.current = s));
+
+ paintChecks(root, load());
+
+ // Подставляем актуальные названия в ссылки-чипы
+ if (titles) {
+ root.querySelectorAll('[data-slug]').forEach((el) => {
+ const t = titles(el.dataset.slug ?? '');
+ const label = el.querySelector('.kb-link-t') ?? (el.classList.contains('kb-ulink') ? el : null);
+ if (t && label && label.textContent !== t) label.textContent = t;
+ });
+ }
+
+ const onClick = (e: MouseEvent) => {
+ const target = e.target as HTMLElement;
+
+ const row = target.closest('.kb-check-row');
+ if (row) {
+ const g = row.closest('.kb-check')?.dataset.check ?? '0';
+ const key = `${g}-${row.dataset.i}`;
+ const state = { ...load() };
+ if (state[key]) delete state[key];
+ else state[key] = true;
+ save(state);
+ paintChecks(root, state);
+ return;
+ }
+
+ const reset = target.closest('.kb-check-reset');
+ if (reset) {
+ const g = reset.closest('.kb-check')?.dataset.check ?? '0';
+ const state = Object.fromEntries(Object.entries(load()).filter(([k]) => !k.startsWith(`${g}-`)));
+ save(state);
+ paintChecks(root, state);
+ return;
+ }
+
+ const fig = target.closest('.kb-fig-btn');
+ if (fig) {
+ onImage?.(Number(fig.dataset.fig ?? 0), collectFigures(root));
+ return;
+ }
+
+ // Внутренние ссылки открываем без перезагрузки страницы
+ const link = target.closest('a.kb-link');
+ if (link && !e.metaKey && !e.ctrlKey && !e.shiftKey && e.button === 0) {
+ e.preventDefault();
+ navigate(link.getAttribute('href') ?? '/');
+ }
+ };
+
+ // Картинка не загрузилась (нет сети и нет в кеше): показываем заглушку с именем файла.
+ // Событие error не всплывает, поэтому ловим его на фазе перехвата.
+ const onError = (e: Event) => {
+ const img = e.target as HTMLElement;
+ if (!(img instanceof HTMLImageElement) || !img.classList.contains('kb-fig-img')) return;
+ const stub = document.createElement('div');
+ stub.className = 'kb-fig-miss';
+ stub.dataset.file = img.dataset.file ?? '';
+ stub.textContent = `фото · ${img.dataset.file ?? ''}`;
+ img.replaceWith(stub);
+ };
+
+ root.addEventListener('click', onClick);
+ root.addEventListener('error', onError, true);
+ return () => {
+ root.removeEventListener('click', onClick);
+ root.removeEventListener('error', onError, true);
+ };
+ }, [html, storageKey, navigate, titles, onImage]);
+
+ // HTML собран нашим рендером и прошёл rehype-sanitize, поэтому вставлять его безопасно
+ return
;
+}
+
+export const ArticleBody = memo(ArticleBodyInner);
diff --git a/apps/web/src/components/Icons.tsx b/apps/web/src/components/Icons.tsx
new file mode 100644
index 0000000..d18a524
--- /dev/null
+++ b/apps/web/src/components/Icons.tsx
@@ -0,0 +1,70 @@
+// Иконки из макета: 24×24, линия 2, скруглённые концы, цвет текста.
+import type { ReactNode } from 'react';
+
+function Svg({ children, size = 24, fill = 'none' }: { children: ReactNode; size?: number; fill?: string }) {
+ return (
+
+ {children}
+
+ );
+}
+
+type P = { size?: number };
+
+export const IconHome = (p: P) => (
+
+
+
+
+);
+export const IconSearch = (p: P) => (
+
+
+
+
+);
+export const IconDoc = (p: P) => (
+
+
+
+
+);
+export const IconStar = ({ size, filled }: P & { filled?: boolean }) => (
+
+
+
+);
+export const IconList = (p: P) => (
+
+
+
+);
+export const IconPrint = (p: P) => (
+
+
+
+
+
+);
+export const IconTheme = (p: P) => (
+
+
+
+
+);
+export const IconUp = (p: P) => (
+
+
+
+);
diff --git a/apps/web/src/components/Lightbox.tsx b/apps/web/src/components/Lightbox.tsx
new file mode 100644
index 0000000..6c7fcb8
--- /dev/null
+++ b/apps/web/src/components/Lightbox.tsx
@@ -0,0 +1,177 @@
+// Полноэкранный просмотр фото: щипок и колесо для зума (1–5×), двойной тап 1× ↔ 2,5×,
+// перетаскивание при увеличении, свайп влево/вправо при 1×. Логика из new_design/Lightbox.dc.html.
+
+import { useCallback, useEffect, useRef, useState } from 'react';
+import type { Figure } from './ArticleBody';
+
+interface View {
+ z: number;
+ x: number;
+ y: number;
+}
+const RESET: View = { z: 1, x: 0, y: 0 };
+const clampZ = (z: number) => Math.max(1, Math.min(5, z));
+const SWIPE_PX = 60;
+
+export function Lightbox({ figures, start, onClose }: { figures: Figure[]; start: number; onClose: () => void }) {
+ const [i, setI] = useState(Math.min(start, Math.max(0, figures.length - 1)));
+ const [view, setView] = useState(RESET);
+ const [drag, setDrag] = useState(false);
+ const [failed, setFailed] = useState>({});
+ // Активные касания: id указателя → координаты
+ const pointers = useRef(new Map());
+ const swipe = useRef<{ x: number; on: boolean }>({ x: 0, on: false });
+ const lastTap = useRef(0);
+ const closeRef = useRef(null);
+
+ const fig = figures[i];
+ const go = useCallback(
+ (d: number) => {
+ if (!figures.length) return;
+ setI((cur) => (cur + d + figures.length) % figures.length);
+ setView(RESET);
+ },
+ [figures.length],
+ );
+ const zoom = (z: number) => setView((v) => (clampZ(z) === 1 ? RESET : { ...v, z: clampZ(z) }));
+
+ useEffect(() => {
+ const onKey = (e: KeyboardEvent) => {
+ if (e.key === 'Escape') onClose();
+ else if (e.key === 'ArrowLeft') go(-1);
+ else if (e.key === 'ArrowRight') go(1);
+ };
+ window.addEventListener('keydown', onKey);
+ // Пока открыт просмотр, страница под ним не прокручивается
+ const prev = document.body.style.overflow;
+ document.body.style.overflow = 'hidden';
+ closeRef.current?.focus();
+ return () => {
+ window.removeEventListener('keydown', onKey);
+ document.body.style.overflow = prev;
+ };
+ }, [go, onClose]);
+
+ const onDown = (e: React.PointerEvent) => {
+ try {
+ e.currentTarget.setPointerCapture(e.pointerId);
+ } catch {
+ // не все браузеры дают захватить указатель: работаем и так
+ }
+ pointers.current.set(e.pointerId, { x: e.clientX, y: e.clientY });
+ if (pointers.current.size === 1) swipe.current = { x: e.clientX, on: view.z === 1 };
+ else swipe.current.on = false;
+ setDrag(true);
+ };
+
+ const onMove = (e: React.PointerEvent) => {
+ const P = pointers.current;
+ if (!P.has(e.pointerId)) return;
+ const ids = [...P.keys()];
+ const prev = ids.map((k) => P.get(k)!);
+ P.set(e.pointerId, { x: e.clientX, y: e.clientY });
+ const cur = ids.map((k) => P.get(k)!);
+
+ if (cur.length === 1) {
+ // Один палец: двигаем увеличенное фото
+ const dx = cur[0]!.x - prev[0]!.x;
+ const dy = cur[0]!.y - prev[0]!.y;
+ setView((v) => (v.z > 1 ? { ...v, x: v.x + dx, y: v.y + dy } : v));
+ } else {
+ // Два пальца: отношение расстояний даёт масштаб, сдвиг середины даёт перемещение
+ const dist = (a: { x: number; y: number }, b: { x: number; y: number }) => Math.hypot(a.x - b.x, a.y - b.y);
+ const ratio = dist(cur[0]!, cur[1]!) / (dist(prev[0]!, prev[1]!) || 1);
+ const mx = (cur[0]!.x + cur[1]!.x - prev[0]!.x - prev[1]!.x) / 2;
+ const my = (cur[0]!.y + cur[1]!.y - prev[0]!.y - prev[1]!.y) / 2;
+ setView((v) => {
+ const z = clampZ(v.z * ratio);
+ return z === 1 ? RESET : { z, x: v.x + mx, y: v.y + my };
+ });
+ }
+ };
+
+ const onUp = (e: React.PointerEvent) => {
+ pointers.current.delete(e.pointerId);
+ if (pointers.current.size > 0) return;
+ setDrag(false);
+ const dx = e.clientX - swipe.current.x;
+ if (swipe.current.on && Math.abs(dx) > SWIPE_PX) {
+ go(dx < 0 ? 1 : -1);
+ return;
+ }
+ // Двойной тап: 1× ↔ 2,5× (dblclick на телефонах ненадёжен, считаем сами)
+ if (Math.abs(dx) < 8) {
+ const now = Date.now();
+ if (now - lastTap.current < 300) {
+ setView((v) => (v.z > 1 ? RESET : { z: 2.5, x: 0, y: 0 }));
+ lastTap.current = 0;
+ } else lastTap.current = now;
+ }
+ };
+
+ const transform = `translate(${view.x}px, ${view.y}px) scale(${view.z})`;
+ const style = { transform, transition: drag ? 'none' : undefined };
+ const missing = !fig?.src || failed[i];
+
+ return (
+
+
+
+
{figures.length ? `${i + 1} / ${figures.length}` : ''}
+
{fig?.caption}
+
+
+ ✕
+
+
+
+
zoom(view.z * (e.deltaY < 0 ? 1.15 : 1 / 1.15))}
+ >
+ {missing ? (
+
+ фото · {fig?.file}
+
+ ) : (
+
setFailed((f) => ({ ...f, [i]: true }))}
+ />
+ )}
+
+
+
+
+ go(-1)} aria-label="Предыдущее">
+ ‹
+
+
+ zoom(view.z / 1.5)} aria-label="Уменьшить">
+ −
+
+ setView(RESET)} aria-label="Сбросить масштаб">
+ {Math.round(view.z * 100)}%
+
+ zoom(view.z * 1.5)} aria-label="Увеличить">
+ +
+
+
+ go(1)} aria-label="Следующее">
+ ›
+
+
+
Щипок или двойной тап: зум · свайп: листать
+
+
+ );
+}
diff --git a/apps/web/src/components/PrintSheet.tsx b/apps/web/src/components/PrintSheet.tsx
new file mode 100644
index 0000000..edebdc3
--- /dev/null
+++ b/apps/web/src/components/PrintSheet.tsx
@@ -0,0 +1,111 @@
+// Окно «Печать и PDF»: формат, что включить, оценка числа листов.
+import { useNavigate } from 'react-router-dom';
+import { plural } from '@kb/shared';
+import { useStored } from '../lib/store';
+import { Sheet } from './ui';
+
+export interface PrintOptions {
+ fmt: 'A4' | 'A5';
+ photos: boolean;
+ checks: boolean;
+ keyOnly: boolean;
+}
+export const PRINT_DEFAULTS: PrintOptions = { fmt: 'A4', photos: true, checks: true, keyOnly: false };
+export const PRINT_KEY = 'kb-print';
+
+export const printUrl = (slug: string, o: PrintOptions, auto = true) =>
+ `/print/${slug}?fmt=${o.fmt}&photos=${o.photos ? 1 : 0}&checks=${o.checks ? 1 : 0}&keyOnly=${o.keyOnly ? 1 : 0}${auto ? '&auto=1' : ''}`;
+
+/** Грубая оценка числа листов: точное число покажет окно печати браузера. */
+function estimateSheets(o: PrintOptions, textLength: number, images: number): number {
+ if (o.keyOnly) return 1;
+ let pages = textLength / 2400 + (o.photos ? Math.ceil(images / 2) * 0.27 : 0);
+ if (o.fmt === 'A5') pages *= 2;
+ return Math.max(1, Math.ceil(pages));
+}
+
+const ROWS: { key: 'photos' | 'checks' | 'keyOnly'; title: string; text: string }[] = [
+ { key: 'photos', title: 'Фото', text: 'С подписями, по 2 в ряд' },
+ { key: 'checks', title: 'Чек-листы', text: 'Пустые квадраты, чтобы отмечать ручкой' },
+ { key: 'keyOnly', title: 'Только памятка', text: '«Главное» и запреты на одном листе' },
+];
+
+export function PrintSheet({
+ slug,
+ title,
+ textLength,
+ images,
+ onClose,
+}: {
+ slug: string;
+ title: string;
+ textLength: number;
+ images: number;
+ onClose: () => void;
+}) {
+ // Последний выбор запоминается на устройстве
+ const [opts, setOpts] = useStored(PRINT_KEY, PRINT_DEFAULTS);
+ const navigate = useNavigate();
+ const n = estimateSheets(opts, textLength, images);
+ const go = () => navigate(printUrl(slug, opts));
+
+ return (
+
+
+
+
Формат
+
+ {(['A4', 'A5'] as const).map((f) => (
+ setOpts({ ...opts, fmt: f })}
+ >
+ {f}
+
+ ))}
+
+
+
+
+
Что включить
+
+ {ROWS.map((r) => (
+ setOpts({ ...opts, [r.key]: !opts[r.key] })}
+ >
+
+ {r.title}
+ {r.text}
+
+
+
+
+
+ ))}
+
+
+
+
+ ≈ {n} {plural(n, ['лист', 'листа', 'листов'])} {opts.fmt} · ч/б-совместимо
+
+
+
+ Печать
+
+
+ Скачать PDF
+
+
+
Чтобы получить файл, в окне печати выберите «Сохранить как PDF».
+
+
+ );
+}
diff --git a/apps/web/src/components/Shell.tsx b/apps/web/src/components/Shell.tsx
new file mode 100644
index 0000000..b4dcfb3
--- /dev/null
+++ b/apps/web/src/components/Shell.tsx
@@ -0,0 +1,135 @@
+// Каркас экрана: на телефоне нижняя панель вкладок, на компьютере левое меню с деревом статей.
+import type { ReactNode } from 'react';
+import { Link, NavLink, useLocation } from 'react-router-dom';
+import { THEME_LABEL, THEME_ORDER, useTheme } from '../lib/theme';
+import { articleHref, useNav } from '../lib/tree';
+import { IconDoc, IconHome, IconSearch, IconStar } from './Icons';
+import { CodeTag } from './ui';
+
+export type Tab = 'home' | 'search' | 'cheat' | 'fav';
+
+const TABS: { id: Tab; to: string; label: string; icon: ReactNode }[] = [
+ { id: 'home', to: '/', label: 'Главная', icon: },
+ { id: 'search', to: '/search', label: 'Поиск', icon: },
+ { id: 'cheat', to: '/cheatsheet', label: 'Шпаргалка', icon: },
+ { id: 'fav', to: '/favorites', label: 'Избранное', icon: },
+];
+
+export function TabBar({ active }: { active: Tab }) {
+ return (
+
+ {TABS.map((t) => (
+
+ {t.icon}
+ {t.label}
+
+ ))}
+
+ );
+}
+
+export function Sidebar({ footer }: { footer?: ReactNode }) {
+ const nav = useNav();
+ const { theme, setTheme } = useTheme();
+ const { pathname } = useLocation();
+
+ return (
+
+
+ Памятки монтажника
+ wiki.suchtech.ru
+
+
+ {nav.space ? (
+
+ {nav.space.icon || nav.space.name[0]}
+
+ Пространство
+ {nav.space.name}
+
+
+ ) : null}
+
+
+
+ Поиск
+
+ {nav.pinned ? (
+
+ Шпаргалка
+
+ ) : null}
+
+ Избранное
+
+ {nav.sections.map((s) => (
+
+
+
+ {s.name}
+
+ {s.articles.map((a) => (
+
+ {nav.short(a)}
+
+ ))}
+
+ ))}
+
+
+
+ {footer}
+
Тема
+
+ {THEME_ORDER.map((t) => (
+ setTheme(t)}
+ >
+ {THEME_LABEL[t]}
+
+ ))}
+
+
+
+ );
+}
+
+/**
+ * Обёртка обычного экрана.
+ * tab: какая вкладка подсвечена внизу; bar: своя нижняя панель вместо вкладок (экран статьи).
+ */
+export function Screen({
+ tab,
+ bar,
+ children,
+ wide,
+}: {
+ tab?: Tab;
+ bar?: ReactNode;
+ children: ReactNode;
+ wide?: boolean;
+}) {
+ return (
+
+
+
+ {children}
+
+ {bar ?? (tab ?
: null)}
+
+ );
+}
diff --git a/apps/web/src/components/ui.tsx b/apps/web/src/components/ui.tsx
new file mode 100644
index 0000000..5ce9148
--- /dev/null
+++ b/apps/web/src/components/ui.tsx
@@ -0,0 +1,104 @@
+// Мелкие общие элементы интерфейса.
+import type { ReactNode } from 'react';
+import { Link } from 'react-router-dom';
+import type { PlaqueColor } from '@kb/shared';
+import { useTheme } from '../lib/theme';
+
+/** Цветная плашка с кодом раздела: «ВВ», «ВОК». size: sm (в сетке), lg (в шапке раздела). */
+export function Plaque({ code, color, size = 'sm' }: { code: string; color: PlaqueColor; size?: 'sm' | 'lg' }) {
+ return {code} ;
+}
+
+/** Код раздела в рамке: в списках избранного, в меню. */
+export function CodeTag({ code, small }: { code: string; small?: boolean }) {
+ return {code} ;
+}
+
+/** Кнопка «Тема» в шапке экрана: переключает по кругу. */
+export function ThemeButton() {
+ const { label, cycle } = useTheme();
+ return (
+
+
+ {label}
+
+ );
+}
+
+/** Ссылка «‹ Назад». */
+export function BackLink({ to, children }: { to: string; children: ReactNode }) {
+ return (
+
+
+ ‹
+
+ {children}
+
+ );
+}
+
+export function Caps({ children, right }: { children: ReactNode; right?: ReactNode }) {
+ return (
+
+
{children}
+ {right ? {right} : null}
+
+ );
+}
+
+/** Состояния «загрузка / ошибка / пусто» в стиле макета (в самом макете их нет). */
+export function Notice({ title, children, tone }: { title: string; children?: ReactNode; tone?: 'error' }) {
+ return (
+
+
{title}
+ {children ?
{children}
: null}
+
+ );
+}
+
+export function Skeleton({ lines = 3 }: { lines?: number }) {
+ return (
+
+ {Array.from({ length: lines }, (_, i) => (
+
+ ))}
+
+ );
+}
+
+/** Выдвижная панель снизу (на телефоне) или окно по центру (на компьютере). */
+export function Sheet({
+ title,
+ subtitle,
+ onClose,
+ children,
+ dialog,
+}: {
+ title: string;
+ subtitle?: string;
+ onClose: () => void;
+ children: ReactNode;
+ /** true: на широком экране показывать окном по центру */
+ dialog?: boolean;
+}) {
+ return (
+
+
+
+
+
+
+
+
+
{title}
+ {subtitle ?
{subtitle}
: null}
+
+
+ ✕
+
+
+ {children}
+
+
+ );
+}
diff --git a/apps/web/src/lib/api.ts b/apps/web/src/lib/api.ts
new file mode 100644
index 0000000..f863893
--- /dev/null
+++ b/apps/web/src/lib/api.ts
@@ -0,0 +1,53 @@
+import { useQuery } from '@tanstack/react-query';
+import type { ArticleDto, TreeResponse } from '@kb/shared';
+
+/** Ошибка ответа API: status нужен, чтобы отличать 401 (надо войти) от 404 и от «нет сети». */
+export class ApiError extends Error {
+ constructor(
+ public status: number,
+ message: string,
+ ) {
+ super(message);
+ }
+}
+
+export async function api(path: string, init?: RequestInit & { json?: unknown }): Promise {
+ const headers = new Headers(init?.headers);
+ let body = init?.body;
+ if (init?.json !== undefined) {
+ headers.set('Content-Type', 'application/json');
+ body = JSON.stringify(init.json);
+ }
+ // X-Requested-With: простой заголовок, который браузер не даст отправить с чужого сайта
+ // без разрешения CORS. Сервер требует его на изменяющих запросах (защита от CSRF).
+ headers.set('X-Requested-With', 'kb');
+
+ let res: Response;
+ try {
+ res = await fetch(`/api${path}`, { ...init, headers, body, credentials: 'same-origin' });
+ } catch {
+ throw new ApiError(0, 'Нет связи с сервером');
+ }
+ if (res.status === 204) return undefined as T;
+ const data = await res.json().catch(() => null);
+ if (!res.ok) {
+ if (res.status === 401) window.dispatchEvent(new Event('kb:unauthorized'));
+ throw new ApiError(res.status, (data as { error?: string } | null)?.error ?? `Ошибка ${res.status}`);
+ }
+ return data as T;
+}
+
+export const treeQuery = { queryKey: ['tree'] as const, queryFn: () => api('/tree') };
+
+export const articleQuery = (slug: string) => ({
+ queryKey: ['article', slug] as const,
+ queryFn: () => api(`/articles/${encodeURIComponent(slug)}`),
+});
+
+export function useTree() {
+ return useQuery(treeQuery);
+}
+
+export function useArticle(slug: string | undefined) {
+ return useQuery({ ...articleQuery(slug ?? ''), enabled: !!slug });
+}
diff --git a/apps/web/src/lib/format.ts b/apps/web/src/lib/format.ts
new file mode 100644
index 0000000..69ec39a
--- /dev/null
+++ b/apps/web/src/lib/format.ts
@@ -0,0 +1,40 @@
+const pad = (n: number) => String(n).padStart(2, '0');
+
+/** 15.09.2026 */
+export function formatDate(iso: string | number | Date): string {
+ const d = new Date(iso);
+ return `${pad(d.getDate())}.${pad(d.getMonth() + 1)}.${d.getFullYear()}`;
+}
+
+/** 15.09.2026, 18:40 */
+export function formatDateTime(iso: string | number | Date): string {
+ const d = new Date(iso);
+ return `${formatDate(d)}, ${pad(d.getHours())}:${pad(d.getMinutes())}`;
+}
+
+/** Для «Недавно открытых»: сегодня → «14:20», вчера → «вчера», раньше → «30.09». */
+export function formatRecent(at: number): string {
+ const d = new Date(at);
+ const today = new Date();
+ today.setHours(0, 0, 0, 0);
+ const day = new Date(d);
+ day.setHours(0, 0, 0, 0);
+ const diff = Math.round((today.getTime() - day.getTime()) / 86_400_000);
+ if (diff <= 0) return `${pad(d.getHours())}:${pad(d.getMinutes())}`;
+ if (diff === 1) return 'вчера';
+ return `${pad(d.getDate())}.${pad(d.getMonth() + 1)}`;
+}
+
+/** 4,1 МБ */
+export function formatBytes(bytes: number): string {
+ if (bytes < 1024) return `${bytes} Б`;
+ const kb = bytes / 1024;
+ if (kb < 1024) return `${Math.round(kb)} КБ`;
+ const mb = kb / 1024;
+ return `${mb < 10 ? mb.toFixed(1).replace('.', ',') : Math.round(mb)} МБ`;
+}
+
+export const fileExt = (name: string) => (name.split('.').pop() ?? '').toUpperCase().slice(0, 4);
+
+/** 01, 02, … */
+export const num2 = (n: number) => pad(n);
diff --git a/apps/web/src/lib/store.ts b/apps/web/src/lib/store.ts
new file mode 100644
index 0000000..cf4b425
--- /dev/null
+++ b/apps/web/src/lib/store.ts
@@ -0,0 +1,95 @@
+// Небольшое хранилище поверх localStorage: избранное, недавние, галочки чек-листов, тема.
+// Всё это живёт на устройстве и работает без сети.
+
+import { useSyncExternalStore } from 'react';
+
+type Listener = () => void;
+const listeners = new Map>();
+// Кеш разобранных значений: useSyncExternalStore требует, чтобы getSnapshot
+// возвращал ТОТ ЖЕ объект, пока данные не менялись.
+const cache = new Map();
+
+function read(key: string, fallback: T): T {
+ if (cache.has(key)) return cache.get(key) as T;
+ let value = fallback;
+ try {
+ const raw = localStorage.getItem(key);
+ if (raw !== null) value = JSON.parse(raw) as T;
+ } catch {
+ // localStorage недоступен (приватный режим) или там мусор: берём значение по умолчанию
+ }
+ cache.set(key, value);
+ return value;
+}
+
+export function getStored(key: string, fallback: T): T {
+ return read(key, fallback);
+}
+
+export function setStored(key: string, value: T) {
+ cache.set(key, value);
+ try {
+ localStorage.setItem(key, JSON.stringify(value));
+ } catch {
+ // место кончилось: значение останется хотя бы в памяти до перезагрузки
+ }
+ listeners.get(key)?.forEach((l) => l());
+}
+
+function subscribe(key: string, l: Listener) {
+ let set = listeners.get(key);
+ if (!set) listeners.set(key, (set = new Set()));
+ set.add(l);
+ return () => set.delete(l);
+}
+
+// Изменения из другой вкладки
+if (typeof window !== 'undefined') {
+ window.addEventListener('storage', (e) => {
+ if (!e.key) return;
+ cache.delete(e.key);
+ listeners.get(e.key)?.forEach((l) => l());
+ });
+}
+
+export function useStored(key: string, fallback: T): [T, (v: T) => void] {
+ const value = useSyncExternalStore(
+ (l) => subscribe(key, l),
+ () => read(key, fallback),
+ );
+ return [value, (v: T) => setStored(key, v)];
+}
+
+// ---------- Избранное ----------
+const FAV = 'kb-fav';
+const NO_FAVS: string[] = [];
+
+export function useFavorites() {
+ const [favs, setFavs] = useStored(FAV, NO_FAVS);
+ return {
+ favs,
+ has: (slug: string) => favs.includes(slug),
+ toggle: (slug: string) => setFavs(favs.includes(slug) ? favs.filter((s) => s !== slug) : [slug, ...favs]),
+ };
+}
+
+// ---------- Недавно открытые ----------
+export interface RecentItem {
+ slug: string;
+ at: number;
+}
+const RECENT = 'kb-recent';
+const NO_RECENT: RecentItem[] = [];
+
+export function useRecent() {
+ return useStored(RECENT, NO_RECENT)[0];
+}
+
+export function pushRecent(slug: string) {
+ const list = getStored(RECENT, NO_RECENT).filter((r) => r.slug !== slug);
+ setStored(RECENT, [{ slug, at: Date.now() }, ...list].slice(0, 12));
+}
+
+// ---------- Чек-листы ----------
+// Ключ = slug + версия статьи: после правки статьи старые галочки не переносятся на новый текст.
+export const checkKey = (slug: string, version: number) => `kb-check:${slug}:v${version}`;
diff --git a/apps/web/src/lib/theme.ts b/apps/web/src/lib/theme.ts
new file mode 100644
index 0000000..b5f48e5
--- /dev/null
+++ b/apps/web/src/lib/theme.ts
@@ -0,0 +1,27 @@
+import { useEffect } from 'react';
+import { useStored } from './store';
+
+export type Theme = 'dark' | 'light' | 'sun';
+// Порядок переключения кнопкой «Тема»: тёмная → светлая → солнце
+export const THEME_ORDER: Theme[] = ['dark', 'light', 'sun'];
+export const THEME_LABEL: Record = { dark: 'Тёмная', light: 'Светлая', sun: 'Солнце' };
+export const THEME_KEY = 'kb-theme';
+
+export function useTheme() {
+ const [stored, setTheme] = useStored(THEME_KEY, 'dark');
+ const theme = THEME_ORDER.includes(stored) ? stored : 'dark';
+
+ useEffect(() => {
+ document.documentElement.dataset.theme = theme;
+ // Цвет системной панели браузера берём из токена фона
+ const bg = getComputedStyle(document.documentElement).getPropertyValue('--bg').trim();
+ document.querySelector('meta[name="theme-color"]')?.setAttribute('content', bg);
+ }, [theme]);
+
+ return {
+ theme,
+ label: THEME_LABEL[theme],
+ setTheme,
+ cycle: () => setTheme(THEME_ORDER[(THEME_ORDER.indexOf(theme) + 1) % THEME_ORDER.length]!),
+ };
+}
diff --git a/apps/web/src/lib/tree.ts b/apps/web/src/lib/tree.ts
new file mode 100644
index 0000000..846ac21
--- /dev/null
+++ b/apps/web/src/lib/tree.ts
@@ -0,0 +1,41 @@
+import { useMemo } from 'react';
+import { type ArticleListItem, type SectionDto, shortTitle } from '@kb/shared';
+import { useTree } from './api';
+
+export interface SectionView extends SectionDto {
+ /** Статьи раздела без закреплённой шпаргалки. */
+ articles: ArticleListItem[];
+}
+
+/** Дерево в удобном для экранов виде: разделы со статьями, поиск статьи и раздела по slug. */
+export function useNav() {
+ const { data, isLoading, error } = useTree();
+ return useMemo(() => {
+ const sections = data?.sections ?? [];
+ const articles = data?.articles ?? [];
+ const bySection = new Map(sections.map((s) => [s.id, s]));
+ const bySlug = new Map(articles.map((a) => [a.slug, a]));
+ const pinned = articles.find((a) => a.pinned) ?? null;
+
+ const views: SectionView[] = sections
+ .map((s) => ({ ...s, articles: articles.filter((a) => a.sectionId === s.id && !a.pinned) }))
+ // Раздел, в котором только закреплённая шпаргалка, в сетке не показываем: у неё своя карточка
+ .filter((s) => s.articles.length > 0);
+
+ return {
+ isLoading,
+ error,
+ space: data?.spaces[0] ?? null,
+ sections: views,
+ articles,
+ pinned,
+ article: (slug: string) => bySlug.get(slug),
+ sectionOf: (a: ArticleListItem | undefined) => (a ? bySection.get(a.sectionId) : undefined),
+ /** Название для меню и списков: без названия раздела в начале. */
+ short: (a: ArticleListItem) => shortTitle(a.title, bySection.get(a.sectionId)?.name),
+ };
+ }, [data, isLoading, error]);
+}
+
+/** Адрес статьи: закреплённая шпаргалка живёт на своём экране. */
+export const articleHref = (a: { slug: string; pinned?: boolean }) => (a.pinned ? '/cheatsheet' : `/a/${a.slug}`);
diff --git a/apps/web/src/main.tsx b/apps/web/src/main.tsx
index 184f832..ebc5baa 100644
--- a/apps/web/src/main.tsx
+++ b/apps/web/src/main.tsx
@@ -1,12 +1,35 @@
import { StrictMode } from 'react';
import { createRoot } from 'react-dom/client';
+import { BrowserRouter } from 'react-router-dom';
+import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
+// Шрифт Onest лежит в сборке (а не на Google Fonts): работает без сети и быстрее грузится
+import '@fontsource-variable/onest/wght.css';
+import './styles/tokens.css';
+import './styles/app.css';
+import './styles/article.css';
+import { App } from './App';
+import { ApiError } from './lib/api';
-function App() {
- return Памятки монтажника ;
-}
+const queryClient = new QueryClient({
+ defaultOptions: {
+ queries: {
+ // Данные считаются свежими минуту: при переходах между экранами повторных запросов нет
+ staleTime: 60_000,
+ // Без сети запрос всё равно выполняем: ответ отдаст service worker из кеша
+ networkMode: 'always',
+ retry: (count, error) => !(error instanceof ApiError && error.status >= 400) && count < 1,
+ refetchOnWindowFocus: false,
+ },
+ mutations: { networkMode: 'always' },
+ },
+});
createRoot(document.getElementById('root')!).render(
-
+
+
+
+
+
,
);
diff --git a/apps/web/src/pages/Article.tsx b/apps/web/src/pages/Article.tsx
new file mode 100644
index 0000000..9d7907d
--- /dev/null
+++ b/apps/web/src/pages/Article.tsx
@@ -0,0 +1,261 @@
+import { useCallback, useEffect, useState } from 'react';
+import { Link, Navigate, useParams } from 'react-router-dom';
+import { ArticleBody, type Figure } from '../components/ArticleBody';
+import { IconList, IconPrint, IconStar, IconTheme, IconUp } from '../components/Icons';
+import { Lightbox } from '../components/Lightbox';
+import { PrintSheet } from '../components/PrintSheet';
+import { Screen } from '../components/Shell';
+import { BackLink, Notice, Sheet, Skeleton } from '../components/ui';
+import { ApiError, useArticle } from '../lib/api';
+import { fileExt, formatBytes, formatDate, num2 } from '../lib/format';
+import { pushRecent, useFavorites } from '../lib/store';
+import { useTheme } from '../lib/theme';
+import { useNav } from '../lib/tree';
+
+/** Прокрутка страницы: показывать ли липкую шапку (после 160 px) и прогресс чтения шагами по 2%. */
+function useReadProgress() {
+ const [state, setState] = useState({ scrolled: false, progress: 0 });
+ useEffect(() => {
+ let frame = 0;
+ const update = () => {
+ frame = 0;
+ const max = document.documentElement.scrollHeight - window.innerHeight;
+ const p = max > 0 ? Math.min(1, window.scrollY / max) : 0;
+ const next = { scrolled: window.scrollY > 160, progress: Math.round(p * 50) / 50 };
+ setState((s) => (s.scrolled === next.scrolled && s.progress === next.progress ? s : next));
+ };
+ const onScroll = () => {
+ if (!frame) frame = requestAnimationFrame(update);
+ };
+ update();
+ window.addEventListener('scroll', onScroll, { passive: true });
+ return () => {
+ window.removeEventListener('scroll', onScroll);
+ cancelAnimationFrame(frame);
+ };
+ }, []);
+ return state;
+}
+
+const scrollToHeading = (id: string) => document.getElementById(id)?.scrollIntoView({ behavior: 'smooth', block: 'start' });
+
+export function ArticlePage() {
+ const { slug = '' } = useParams();
+ // key: при переходе на другую статью состояние (оглавление, просмотр фото) создаётся заново
+ return ;
+}
+
+function ArticleView({ slug }: { slug: string }) {
+ const nav = useNav();
+ const { data: art, isLoading, error } = useArticle(slug);
+ const fav = useFavorites();
+ const theme = useTheme();
+ const { scrolled, progress } = useReadProgress();
+ const [tocOpen, setTocOpen] = useState(false);
+ const [printOpen, setPrintOpen] = useState(false);
+ const [lightbox, setLightbox] = useState<{ figures: Figure[]; start: number } | null>(null);
+
+ const listItem = nav.article(slug);
+ const section = nav.sectionOf(art ?? listItem);
+
+ useEffect(() => {
+ if (art) pushRecent(art.slug);
+ }, [art]);
+
+ // При переходе на другую статью начинаем чтение сверху
+ useEffect(() => {
+ window.scrollTo(0, 0);
+ }, [slug]);
+
+ const onImage = useCallback((start: number, figures: Figure[]) => setLightbox({ figures, start }), []);
+ const titles = useCallback((s: string) => nav.article(s)?.title, [nav]);
+
+ // Закреплённая статья-шпаргалка открывается на своём экране
+ if (art?.pinned && art.cheat) return ;
+
+ const isFav = fav.has(slug);
+ const title = art?.title ?? listItem?.title ?? '';
+ const backTo = section ? `/s/${section.slug}` : '/';
+
+ const bar = (
+
+ fav.toggle(slug)} aria-pressed={isFav}>
+
+ {isFav ? 'В избранном' : 'Избранное'}
+
+ setTocOpen(true)}>
+
+ Оглавление
+
+ setPrintOpen(true)}>
+
+ Печать
+
+
+
+ {theme.label}
+
+ window.scrollTo({ top: 0, behavior: 'smooth' })}>
+
+ Наверх
+
+
+ );
+
+ if (!art) {
+ const notFound = error instanceof ApiError && error.status === 404;
+ return (
+
+
+ {section?.name ?? 'Главная'}
+
+ {title ? {title} : null}
+ {isLoading ? (
+
+ ) : notFound ? (
+ Возможно, её переименовали или сняли с публикации.
+ ) : (
+
+ Нет сети, и эта статья ещё не сохранена на устройстве. Откройте её при связи или скачайте раздел заранее.
+
+ )}
+
+ );
+ }
+
+ const meta = (
+
+ {art.docCode ? (
+ <>
+ Шифр
+ {art.docCode}
+ >
+ ) : null}
+ Версия
+ v{art.version}
+ Обновлено
+ {formatDate(art.updatedAt)}
+
+ );
+
+ const sources = art.attachments.map((f) => (
+
+
+ {fileExt(f.filename)}
+
+
+ Исходник
+ {f.filename}
+
+ {fileExt(f.filename)} · {formatBytes(f.size)}
+
+
+ Скачать
+
+ ));
+
+ const toc = art.toc.map((t, i) => (
+ {
+ setTocOpen(false);
+ scrollToHeading(t.id);
+ }}
+ >
+ {num2(i + 1)}
+ {t.text}
+
+ ));
+
+ return (
+
+ {/* Липкая шапка на телефоне: появляется после 160 px прокрутки */}
+
+
{section?.name}
+
{art.title}
+
+
+
+ {/* Верхняя панель на компьютере */}
+
+
+ {nav.space?.name} / {section ? {section.name} : null} /{' '}
+ {nav.short(art)}
+
+
+
fav.toggle(slug)} aria-pressed={isFav}>
+ {isFav ? '★ В избранном' : '☆ В избранное'}
+
+
setPrintOpen(true)}>
+
+ Печать / PDF
+
+
+
+
+
+
+
+ {section?.name ?? 'Главная'}
+
+
+ {section?.name}
+ {art.title}
+ {art.summary ? {art.summary}
: null}
+ {meta}
+ {art.equipment.length ? (
+
+ {art.equipment.map((e) => (
+
+ {e}
+
+ ))}
+
+ ) : null}
+
+
+
+ {art.tags.length ? (
+
+ {art.tags.map((t) => (
+
+ #{t}
+
+ ))}
+
+ ) : null}
+ {sources}
+
+
+
+ {art.toc.length ? (
+
+ ) : null}
+ {meta}
+ {sources}
+
+
+
+ {tocOpen ? (
+ setTocOpen(false)}>
+ {toc.length ? toc :
В статье нет разделов
}
+
+ ) : null}
+ {printOpen ? (
+ setPrintOpen(false)}
+ />
+ ) : null}
+ {lightbox ? setLightbox(null)} /> : null}
+
+ );
+}
diff --git a/apps/web/src/pages/CheatSheet.tsx b/apps/web/src/pages/CheatSheet.tsx
new file mode 100644
index 0000000..7a0b3c3
--- /dev/null
+++ b/apps/web/src/pages/CheatSheet.tsx
@@ -0,0 +1,152 @@
+import { Link } from 'react-router-dom';
+import type { CheatLine, Seg } from '@kb/shared';
+import { ArticleBody } from '../components/ArticleBody';
+import { IconPrint } from '../components/Icons';
+import { Screen } from '../components/Shell';
+import { Notice, Skeleton, ThemeButton } from '../components/ui';
+import { useArticle } from '../lib/api';
+import { articleHref, useNav } from '../lib/tree';
+
+/** Текст с жирными фрагментами. В запретах жирное красное, в «Всегда» просто жирное. */
+export function Segs({ segs }: { segs: Seg[] }) {
+ return (
+ <>
+ {segs.map((s, i) => (s.bold ? {s.t} : {s.t} ))}
+ >
+ );
+}
+
+function SourceChips({ line, small }: { line: CheatLine; small?: boolean }) {
+ const nav = useNav();
+ if (!line.links.length) return null;
+ return (
+
+ {line.links.map((slug) => {
+ const a = nav.article(slug);
+ return (
+
+ → {a ? nav.short(a) : slug}
+
+ );
+ })}
+
+ );
+}
+
+/** Образец цвета по коду RAL. Сами цвета заданы токенами --ral-XXXX в tokens.css. */
+const ralVar = (code: string) => `var(--ral-${code.replace(/\D/g, '')}, transparent)`;
+
+export function CheatSheetPage() {
+ const nav = useNav();
+ const { data: art, isLoading } = useArticle(nav.pinned?.slug);
+ const cheat = art?.cheat;
+
+ return (
+
+
+
+
Закреплено
+
Шпаргалка
+
+
+
+
+ {!art ? (
+ isLoading || nav.isLoading ? (
+
+ ) : (
+
+ {nav.pinned ? 'Нет сети, и шпаргалка ещё не сохранена на устройстве.' : 'Закреплённой статьи пока нет.'}
+
+ )
+ ) : !cheat ? (
+ // У закреплённой статьи нет структуры шпаргалки: показываем её как обычную статью
+
+ ) : (
+ <>
+ Все цифры и запреты на одном экране. Каждая строка ведёт в статью.
+
+
+ Распечатать на 1 лист / PDF
+
+
+ {cheat.bans.length ? (
+
+
+
+ ЗАПРЕЩЕНО
+ {cheat.bans.length}
+
+ {cheat.bans.map((b, i) => (
+
+
{String(i + 1).padStart(2, '0')}
+
+
+ ))}
+
+ ) : null}
+
+ {cheat.facts.length ? (
+
+
+
Цифры
+ {cheat.facts.length}
+
+
+ {cheat.facts.map((f, i) => (
+
+
+
+
+
+ {f.value}
+
+
+
+ ))}
+
+
+ ) : null}
+
+ {cheat.colors.length ? (
+
+
+
Цвета
+
+
+ {cheat.colors.map((c) => (
+
+ ))}
+
+
+ ) : null}
+
+ {cheat.always.length ? (
+
+ ВСЕГДА
+ {cheat.always.map((a, i) => (
+
+
+
+
+
+
+ ))}
+
+ ) : null}
+ >
+ )}
+
+ );
+}
diff --git a/apps/web/src/pages/Favorites.tsx b/apps/web/src/pages/Favorites.tsx
new file mode 100644
index 0000000..56826f6
--- /dev/null
+++ b/apps/web/src/pages/Favorites.tsx
@@ -0,0 +1,44 @@
+import { Link } from 'react-router-dom';
+import { Screen } from '../components/Shell';
+import { CodeTag, Notice, ThemeButton } from '../components/ui';
+import { useFavorites } from '../lib/store';
+import { articleHref, useNav } from '../lib/tree';
+
+// Экрана «Избранное» в макете нет (есть только вкладка), сделан в стиле списков главной.
+export function FavoritesPage() {
+ const nav = useNav();
+ const { favs } = useFavorites();
+ const items = favs.map((s) => nav.article(s)).filter((a) => !!a);
+
+ return (
+
+
+
+ {items.length ? (
+
+ {items.map((a) => (
+
+
+
+ {nav.short(a!)}
+ {nav.sectionOf(a)?.name}
+
+
+ ›
+
+
+ ))}
+
+ ) : (
+
+ Откройте статью и нажмите «Избранное» внизу экрана: она появится здесь и на главной.
+
+ )}
+
+ );
+}
diff --git a/apps/web/src/pages/Home.tsx b/apps/web/src/pages/Home.tsx
new file mode 100644
index 0000000..087bb86
--- /dev/null
+++ b/apps/web/src/pages/Home.tsx
@@ -0,0 +1,185 @@
+import { useEffect, useRef } from 'react';
+import { Link, useNavigate } from 'react-router-dom';
+import { plural } from '@kb/shared';
+import { Screen } from '../components/Shell';
+import { Caps, CodeTag, Notice, Plaque, Skeleton, ThemeButton } from '../components/ui';
+import { useArticle } from '../lib/api';
+import { formatRecent } from '../lib/format';
+import { useFavorites, useRecent } from '../lib/store';
+import { articleHref, useNav } from '../lib/tree';
+
+// Быстрые запросы под строкой поиска (из макета): самые ходовые артикулы
+const QUICK = ['MG-12', '2273-245', 'RAL 7024', 'порт PoE'];
+
+export function SearchIcon() {
+ return (
+
+
+
+
+ );
+}
+
+export function HomePage() {
+ const nav = useNav();
+ const navigate = useNavigate();
+ const { favs } = useFavorites();
+ const recent = useRecent();
+ const cheat = useArticle(nav.pinned?.slug).data?.cheat;
+ const inputRef = useRef(null);
+
+ // «/» на клавиатуре открывает поиск (подсказка в поле на компьютере)
+ useEffect(() => {
+ const onKey = (e: KeyboardEvent) => {
+ if (e.key === '/' && !(e.target instanceof HTMLInputElement) && !(e.target instanceof HTMLTextAreaElement)) {
+ e.preventDefault();
+ navigate('/search');
+ }
+ };
+ window.addEventListener('keydown', onKey);
+ return () => window.removeEventListener('keydown', onKey);
+ }, [navigate]);
+
+ const favArticles = favs.map((s) => nav.article(s)).filter((a) => !!a);
+ const recentArticles = recent
+ .map((r) => ({ r, a: nav.article(r.slug) }))
+ .filter((x) => !!x.a)
+ .slice(0, 5);
+ const odd = nav.sections.length % 2 === 1;
+
+ return (
+
+
+
+ {/* Поле на главной только открывает экран поиска: печатать удобнее там, где сразу видны результаты */}
+
+
+
+ {
+ if (e.target.value) navigate(`/search?q=${encodeURIComponent(e.target.value)}`);
+ }}
+ />
+
+ /
+
+
+
+ {QUICK.map((q) => (
+
+ {q}
+
+ ))}
+
+
+
+ {nav.error && !nav.articles.length ? (
+
+ Проверьте связь и обновите страницу.
+
+ ) : null}
+ {nav.isLoading ? : null}
+
+
+ {nav.pinned ? (
+
+
+ Закреплено
+ {cheat ? (
+
+ {cheat.bans.length} {plural(cheat.bans.length, ['запрет', 'запрета', 'запретов'])} ·{' '}
+ {cheat.facts.length} {plural(cheat.facts.length, ['цифра', 'цифры', 'цифр'])}
+
+ ) : null}
+
+
Шпаргалка
+
{nav.pinned.summary}
+ {cheat?.facts.length ? (
+
+ {cheat.facts.slice(0, 4).map((f, i) => (
+
+
{f.value}
+
{f.segs.map((s) => s.t).join('')}
+
+ ))}
+
+ ) : null}
+
+ ) : null}
+
+ {recentArticles.length ? (
+
+ Недавно открытые
+
+ {recentArticles.map(({ r, a }) => (
+
+
+ {nav.short(a!)}
+ {nav.sectionOf(a)?.name}
+
+ {formatRecent(r.at)}
+
+ ))}
+
+
+ ) : null}
+
+
+ {nav.sections.length ? (
+
+ Разделы
+
+ {nav.sections.map((s, i) => (
+
+
+
+ {s.name}
+
+ {s.articles.length} {plural(s.articles.length, ['статья', 'статьи', 'статей'])}
+
+
+
+ ))}
+
+
+ ) : null}
+
+ {favArticles.length ? (
+
+ Избранное
+
+ {favArticles.map((a) => (
+
+
+
+ {nav.sectionOf(a)?.name}
+ {nav.short(a!)}
+ {a!.summary}
+
+
+ ›
+
+
+ ))}
+
+
+ ) : null}
+
+ );
+}
diff --git a/apps/web/src/pages/Print.tsx b/apps/web/src/pages/Print.tsx
new file mode 100644
index 0000000..9ddce21
--- /dev/null
+++ b/apps/web/src/pages/Print.tsx
@@ -0,0 +1,218 @@
+// Печатная версия статьи и шпаргалки: /print/:slug?fmt=A4&photos=1&checks=1&keyOnly=0&auto=1
+// Всегда светлая и читается в ч/б. Колонтитулы и «Стр. N из M» рисует браузер по правилам @page.
+
+import { useEffect, useMemo, useRef } from 'react';
+import { Link, useParams, useSearchParams } from 'react-router-dom';
+import qrcode from 'qrcode-generator';
+import type { ArticleDto } from '@kb/shared';
+import { Notice, Skeleton } from '../components/ui';
+import { useArticle } from '../lib/api';
+import { formatDate } from '../lib/format';
+import { articleHref, useNav } from '../lib/tree';
+import { Segs } from './CheatSheet';
+import '../styles/print.css';
+
+/** Строка для CSS content: экранируем кавычки и обратную косую. */
+const cssStr = (s: string) => `"${s.replace(/\\/g, '\\\\').replace(/"/g, '\\"').replace(/\n/g, ' ')}"`;
+
+function Qr({ url, size }: { url: string; size: number }) {
+ const svg = useMemo(() => {
+ const qr = qrcode(0, 'M');
+ qr.addData(url);
+ qr.make();
+ return qr.createSvgTag({ cellSize: 2, margin: 0, scalable: true });
+ }, [url]);
+ return ;
+}
+
+function CheatPrint({ art, today, site }: { art: ArticleDto; today: string; site: string }) {
+ const nav = useNav();
+ const c = art.cheat!;
+ return (
+
+
+ Шпаргалка монтажника
+
+ {nav.space?.name} · {today}
+
+
+
+
+
ЦИФРЫ
+ {c.facts.map((f, i) => (
+
+
+
+
+ {f.value}
+
+ ))}
+ {c.colors.length ? (
+
+ {c.colors.map((col) => (
+
+
+
+ {col.code} {col.label.toLowerCase()}
+
+
+ ))}
+
+ ) : null}
+
+
+ {c.bans.length ? (
+
+ ✕ ЗАПРЕЩЕНО
+ {c.bans.map((b, i) => (
+
+ {String(i + 1).padStart(2, '0')}
+
+
+
+
+ ))}
+
+ ) : null}
+ {c.always.length ? (
+
+ ✓ ВСЕГДА
+ {c.always.map((a, i) => (
+
+
+
+
+
+
+ ))}
+
+ ) : null}
+
+
+
+ Подробности и фото в статьях: {site} · ламинировать и держать в стойке
+
+
+
+ );
+}
+
+export default function PrintPage() {
+ const { slug = '' } = useParams();
+ const [params] = useSearchParams();
+ const nav = useNav();
+ const { data: art, isLoading } = useArticle(slug);
+ const bodyRef = useRef(null);
+ const printed = useRef(false);
+
+ const fmt = params.get('fmt') === 'A5' ? 'A5' : 'A4';
+ const photos = params.get('photos') !== '0';
+ const checks = params.get('checks') !== '0';
+ const keyOnly = params.get('keyOnly') === '1';
+ const auto = params.get('auto') === '1';
+
+ const section = nav.sectionOf(art);
+ const today = formatDate(new Date());
+ const site = location.host;
+ const isCheat = !!art?.cheat;
+ const url = art ? `${location.origin}${articleHref(art)}` : '';
+
+ // В печатной версии [[ссылки]] становятся жирным названием статьи
+ const html = useMemo(
+ () =>
+ (art?.bodyHtml ?? '').replace(
+ /]*>.*?(.*?)<\/span><\/a>/g,
+ '$1 ',
+ ),
+ [art?.bodyHtml],
+ );
+
+ // Автопечать: ждём, пока догрузятся картинки, иначе на листе будут пустые рамки
+ useEffect(() => {
+ if (!art || !auto || printed.current) return;
+ printed.current = true;
+ const imgs = [...(bodyRef.current?.querySelectorAll('img') ?? [])];
+ imgs.forEach((img) => (img.loading = 'eager'));
+ const waits = imgs.map((img) =>
+ img.complete ? Promise.resolve() : new Promise((r) => (img.onload = img.onerror = () => r())),
+ );
+ const timeout = new Promise((r) => setTimeout(r, 4000));
+ void Promise.race([Promise.all(waits), timeout]).then(() => setTimeout(() => window.print(), 150));
+ }, [art, auto]);
+
+ // Колонтитулы: шифр, версия и дата в шапке каждого листа, номер страницы внизу
+ const pageCss = art
+ ? `@page { size: ${fmt}${isCheat ? '' : ' portrait'}; margin: ${isCheat ? '11mm 12mm' : '18mm 14mm 16mm'};
+${
+ isCheat
+ ? ''
+ : `@top-left { content: ${cssStr(`Памятки монтажника · ${nav.space?.name ?? ''} · ${section?.name ?? ''}`)}; font: 700 9pt Onest, sans-serif; border-bottom: 1.5px solid currentColor; padding-bottom: 2mm; }
+@top-right { content: ${cssStr([art.docCode, `v${art.version}`, formatDate(art.updatedAt)].filter(Boolean).join(' · '))}; font: 9pt Onest, sans-serif; border-bottom: 1.5px solid currentColor; padding-bottom: 2mm; }
+@bottom-left { content: ${cssStr(`Напечатано ${today} · ${url.replace(/^https?:\/\//, '')}`)}; font: 9pt Onest, sans-serif; }
+@bottom-right { content: "Стр. " counter(page) " из " counter(pages); font: 700 9pt Onest, sans-serif; }`
+}
+}`
+ : '';
+
+ if (!art) {
+ return (
+
+
+
+ ‹ Назад
+
+
+ {isLoading ?
:
Статья не сохранена на устройстве. }
+
+ );
+ }
+
+ const cls = ['pr-body', photos ? '' : 'pr-no-photos', checks ? '' : 'pr-no-checks', keyOnly ? 'pr-key-only' : '']
+ .filter(Boolean)
+ .join(' ');
+
+ return (
+
+
+
+
+ ‹ Назад
+
+
+ {fmt} · в окне печати можно выбрать «Сохранить как PDF»
+
+ window.print()}>
+ Печать
+
+
+
+
+ {isCheat ? (
+
+ ) : (
+ <>
+ {/* Шапка для предпросмотра на экране; на бумаге её заменяют колонтитулы @page */}
+
+
+ Памятки монтажника · {nav.space?.name} · {section?.name}
+
+ {[art.docCode, `v${art.version}`, formatDate(art.updatedAt)].filter(Boolean).join(' · ')}
+
+
+
{art.title}
+ {art.summary ?
{art.summary}
: null}
+
+
+
+
+
+ Актуальная версия всегда онлайн
+ {url.replace(/^https?:\/\//, '')} · проверьте версию перед монтажом
+
+
+ >
+ )}
+
+
+ );
+}
diff --git a/apps/web/src/pages/Search.tsx b/apps/web/src/pages/Search.tsx
new file mode 100644
index 0000000..b9211c0
--- /dev/null
+++ b/apps/web/src/pages/Search.tsx
@@ -0,0 +1,11 @@
+import { Screen } from '../components/Shell';
+import { Notice } from '../components/ui';
+
+// Поиск появится на этапе 4.
+export function SearchPage() {
+ return (
+
+ Скоро здесь будет поиск по цифрам, артикулам и словам.
+
+ );
+}
diff --git a/apps/web/src/pages/Section.tsx b/apps/web/src/pages/Section.tsx
new file mode 100644
index 0000000..008aed5
--- /dev/null
+++ b/apps/web/src/pages/Section.tsx
@@ -0,0 +1,70 @@
+import { Link, useParams } from 'react-router-dom';
+import { plural } from '@kb/shared';
+import { Screen } from '../components/Shell';
+import { BackLink, Notice, Plaque, Skeleton, ThemeButton } from '../components/ui';
+import { num2 } from '../lib/format';
+import { articleHref, useNav } from '../lib/tree';
+
+export function SectionPage() {
+ const { slug } = useParams();
+ const nav = useNav();
+ const section = nav.sections.find((s) => s.slug === slug);
+
+ if (!section) {
+ return (
+
+
+ Главная
+
+
+ {nav.isLoading ? : Возможно, его переименовали или удалили. }
+
+ );
+ }
+
+ const photos = section.articles.reduce((n, a) => n + a.imageCount, 0);
+
+ return (
+
+
+ Главная
+
+
+
+
+
+
+
{section.name}
+
+ {section.articles.length} {plural(section.articles.length, ['статья', 'статьи', 'статей'])}
+ {photos ? ` · ${photos} фото` : ''}
+
+
+
+
+ {/* Сюда на этапе 5 встаёт строка «Сохранено для офлайна» */}
+
+
+
+ {section.articles.map((a, i) => (
+
+
+ {num2(i + 1)}
+ {nav.short(a)}
+
+ {a.summary ?
{a.summary}
: null}
+ {a.tags.length ? (
+
+ {a.tags.slice(0, 4).map((t) => (
+
+ {t}
+
+ ))}
+
+ ) : null}
+
+ ))}
+
+
+ );
+}
diff --git a/apps/web/src/styles/app.css b/apps/web/src/styles/app.css
new file mode 100644
index 0000000..0ac054e
--- /dev/null
+++ b/apps/web/src/styles/app.css
@@ -0,0 +1,1978 @@
+/* Экраны и общие элементы. Значения из макета new_design/Pamyatki-v3.dc.html. */
+
+/* ---------- Основа ---------- */
+*,
+*::before,
+*::after {
+ box-sizing: border-box;
+}
+
+html {
+ -webkit-text-size-adjust: 100%;
+ text-size-adjust: 100%;
+ scroll-behavior: smooth;
+}
+
+body {
+ margin: 0;
+ background: var(--bg);
+ color: var(--ink);
+ font-family: var(--font);
+ font-size: var(--fs-18);
+ font-weight: var(--wb);
+ line-height: var(--lh-body);
+ -webkit-font-smoothing: antialiased;
+ /* Страница никогда не прокручивается вбок: широкое содержимое переносится внутри блоков */
+ overflow-x: hidden;
+}
+
+button,
+input,
+textarea,
+select {
+ font: inherit;
+ color: inherit;
+}
+
+a {
+ color: inherit;
+}
+
+h1,
+h2,
+h3,
+p,
+dl,
+dd {
+ margin: 0;
+}
+
+img {
+ max-width: 100%;
+}
+
+.icon {
+ flex: none;
+ display: block;
+}
+
+:focus-visible {
+ outline: var(--focus-ring) solid var(--hl);
+ outline-offset: 2px;
+}
+
+@media (prefers-reduced-motion: reduce) {
+ html {
+ scroll-behavior: auto;
+ }
+ * {
+ transition: none !important;
+ animation: none !important;
+ }
+}
+
+/* ---------- Каркас ---------- */
+.shell {
+ min-height: 100dvh;
+}
+
+.sidebar {
+ display: none;
+}
+
+.screen {
+ display: flex;
+ flex-direction: column;
+ gap: var(--sp-10);
+ padding: var(--sp-6) var(--sp-8) calc(var(--h-tabbar) + var(--sp-24) + env(safe-area-inset-bottom));
+ padding-top: calc(var(--sp-6) + env(safe-area-inset-top));
+ min-width: 0;
+}
+
+/* ---------- Нижняя панель ---------- */
+.tabbar {
+ position: fixed;
+ left: 0;
+ right: 0;
+ bottom: 0;
+ z-index: 10;
+ display: grid;
+ grid-template-columns: repeat(4, 1fr);
+ border-top: var(--bw) solid var(--ln);
+ background: var(--sf);
+ padding-bottom: env(safe-area-inset-bottom);
+}
+.tabbar--5 {
+ grid-template-columns: repeat(5, 1fr);
+}
+
+.tab {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+ gap: var(--sp-2);
+ min-height: var(--h-tabbar);
+ min-width: 0;
+ padding: 0 var(--sp-1);
+ border: 0;
+ background: transparent;
+ font-size: var(--fs-13);
+ font-weight: 500;
+ color: var(--ink2);
+ text-decoration: none;
+ cursor: pointer;
+ white-space: nowrap;
+}
+.tab--on {
+ font-weight: 700;
+ color: var(--ink);
+ box-shadow: inset 0 4px 0 var(--hl);
+}
+.tab--btn {
+ font-weight: 600;
+ color: var(--ink);
+}
+
+/* ---------- Шапки ---------- */
+.home-head {
+ display: flex;
+ align-items: center;
+ gap: var(--sp-6);
+}
+.home-head-text {
+ flex: 1;
+ min-width: 0;
+}
+.home-title {
+ font-size: var(--fs-23);
+ font-weight: 700;
+ line-height: var(--lh-tight);
+}
+.home-sub {
+ font-size: var(--fs-13);
+ color: var(--ink2);
+ margin-top: var(--sp-1);
+}
+.over-caps {
+ font-size: var(--fs-12);
+ font-weight: 700;
+ letter-spacing: var(--caps-xwide);
+ text-transform: uppercase;
+ color: var(--ink2);
+}
+.cheat-title {
+ font-size: var(--fs-28);
+ font-weight: 700;
+ line-height: 1.1;
+ letter-spacing: -0.01em;
+}
+
+.theme-btn {
+ flex: none;
+ height: var(--tap);
+ padding: 0 var(--sp-7);
+ border: var(--bw) solid var(--ln);
+ border-radius: var(--r-btn);
+ background: var(--sf);
+ color: var(--ink);
+ font-size: var(--fs-15);
+ font-weight: 600;
+ cursor: pointer;
+ display: flex;
+ align-items: center;
+ gap: var(--sp-4);
+}
+.theme-btn-dot {
+ width: 18px;
+ height: 18px;
+ border-radius: 50%;
+ border: 2px solid var(--ink);
+ background: linear-gradient(90deg, var(--ink) 50%, transparent 50%);
+}
+
+.topline {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: var(--sp-4);
+ margin-left: calc(var(--sp-4) * -1);
+}
+.back {
+ display: flex;
+ align-items: center;
+ gap: var(--sp-2);
+ min-height: var(--tap);
+ padding: 0 var(--sp-4);
+ color: var(--ink);
+ text-decoration: none;
+ font-size: var(--fs-16);
+ font-weight: 600;
+ min-width: 0;
+}
+.back-chev {
+ font-size: var(--fs-24);
+ line-height: 1;
+}
+
+/* ---------- Поиск ---------- */
+.home-search {
+ display: flex;
+ flex-direction: column;
+ gap: var(--sp-6);
+}
+.search-field {
+ display: flex;
+ align-items: center;
+ gap: var(--sp-6);
+ height: var(--h-field);
+ padding: 0 var(--sp-8);
+ border: 2px solid var(--ink);
+ border-radius: var(--r-card);
+ background: var(--sf);
+ cursor: text;
+}
+.search-field:focus-within {
+ box-shadow: 0 0 0 var(--focus-ring) var(--hl);
+}
+.search-field--active {
+ padding-right: var(--sp-3);
+ gap: var(--sp-5);
+}
+.search-ico {
+ position: relative;
+ flex: none;
+ width: 22px;
+ height: 22px;
+}
+.search-ico span:first-child {
+ position: absolute;
+ left: 0;
+ top: 0;
+ width: 14px;
+ height: 14px;
+ border: 2.5px solid var(--ink);
+ border-radius: 50%;
+}
+.search-ico span:last-child {
+ position: absolute;
+ left: 13px;
+ top: 16px;
+ width: 9px;
+ height: 3px;
+ background: var(--ink);
+ transform: rotate(45deg);
+ transform-origin: left center;
+}
+.search-input {
+ flex: 1;
+ min-width: 0;
+ border: 0;
+ outline: 0;
+ background: transparent;
+ font-size: var(--fs-18);
+ color: var(--ink);
+ appearance: none;
+}
+.search-input::placeholder {
+ color: var(--ink2);
+ opacity: 1;
+}
+.search-input::-webkit-search-cancel-button {
+ display: none;
+}
+.search-field--active .search-input {
+ font-size: var(--fs-19);
+ font-weight: 600;
+}
+.search-clear {
+ flex: none;
+ width: var(--tap);
+ height: var(--tap);
+ border: 0;
+ border-radius: var(--r-md);
+ background: var(--sf2);
+ color: var(--ink);
+ font-size: var(--fs-18);
+ cursor: pointer;
+}
+.kbd {
+ display: none;
+}
+
+.chips {
+ display: flex;
+ gap: var(--sp-4);
+ flex-wrap: wrap;
+}
+.chips--tight {
+ gap: var(--sp-3);
+}
+.chips--scroll {
+ flex-wrap: nowrap;
+ overflow-x: auto;
+ margin: 0 calc(var(--sp-8) * -1);
+ padding: var(--sp-2) var(--sp-8);
+ scrollbar-width: none;
+}
+.chips--scroll::-webkit-scrollbar {
+ display: none;
+}
+.chip {
+ display: flex;
+ align-items: center;
+ flex: none;
+ height: var(--h-chip);
+ padding: 0 var(--sp-7);
+ border-radius: var(--r-pill);
+ border: var(--bw) solid var(--ln);
+ background: var(--sf);
+ color: var(--ink);
+ font-size: var(--fs-14);
+ font-weight: 600;
+ text-decoration: none;
+ white-space: nowrap;
+ cursor: pointer;
+}
+.chip--filter {
+ height: var(--tap-sm);
+ padding: 0 var(--sp-8);
+ font-size: var(--fs-15);
+}
+.chip--on {
+ border: 2px solid var(--ink);
+ background: var(--ink);
+ color: var(--bg);
+ font-weight: 700;
+}
+
+.linkchip {
+ display: inline-flex;
+ align-items: center;
+ gap: var(--sp-3);
+ min-height: 34px;
+ padding: 0 var(--sp-6);
+ border: var(--bw) solid var(--ink);
+ border-radius: var(--r-pill);
+ color: var(--ink);
+ font-size: var(--fs-14);
+ font-weight: 600;
+ text-decoration: none;
+}
+.linkchip--sm {
+ min-height: 30px;
+ padding: 0 var(--sp-5);
+ border-color: var(--ln);
+ font-size: var(--fs-13);
+ color: var(--ink2);
+}
+
+/* ---------- Заголовки блоков ---------- */
+.block {
+ display: flex;
+ flex-direction: column;
+ gap: var(--sp-5);
+ min-width: 0;
+}
+.caps-row {
+ display: flex;
+ justify-content: space-between;
+ align-items: baseline;
+ gap: var(--sp-4);
+}
+.caps {
+ font-size: var(--fs-14);
+ font-weight: 600;
+ letter-spacing: var(--caps);
+ text-transform: uppercase;
+ color: var(--ink2);
+}
+.caps-right {
+ font-size: var(--fs-13);
+ color: var(--ink2);
+}
+
+/* ---------- Карточка шпаргалки ---------- */
+.cheat-card {
+ display: flex;
+ flex-direction: column;
+ gap: var(--sp-5);
+ padding: var(--sp-8) var(--sp-9) var(--sp-9);
+ border-radius: var(--r-block);
+ background: var(--brand);
+ color: var(--brand-ink);
+ text-decoration: none;
+ border: 2px solid var(--brand-ink);
+ min-width: 0;
+}
+.cheat-card-caps {
+ display: flex;
+ justify-content: space-between;
+ gap: var(--sp-4);
+ font-size: var(--fs-12);
+ font-weight: 700;
+ letter-spacing: var(--caps-xwide);
+ text-transform: uppercase;
+}
+.cheat-card-title {
+ font-size: var(--fs-30);
+ font-weight: 700;
+ line-height: 1.1;
+}
+.cheat-card-text {
+ font-size: var(--fs-16);
+ line-height: 1.4;
+}
+.cheat-card-facts {
+ display: grid;
+ grid-template-columns: 1fr 1fr;
+ gap: var(--sp-3);
+ margin-top: var(--sp-1);
+}
+.cheat-card-fact {
+ padding: var(--sp-4) var(--sp-5);
+ border-radius: var(--r-sm);
+ background: var(--brand-ink);
+ color: var(--brand);
+ min-width: 0;
+}
+.cheat-card-value {
+ font-size: var(--fs-18);
+ font-weight: 700;
+ line-height: 1.2;
+}
+.cheat-card-label {
+ font-size: var(--fs-13);
+ line-height: 1.3;
+ color: var(--on-strong);
+ display: -webkit-box;
+ -webkit-line-clamp: 2;
+ -webkit-box-orient: vertical;
+ overflow: hidden;
+}
+
+/* ---------- Сетка разделов ---------- */
+.sec-grid {
+ display: grid;
+ grid-template-columns: 1fr 1fr;
+ gap: var(--sp-4);
+}
+.sec-card {
+ display: flex;
+ flex-direction: column;
+ justify-content: space-between;
+ gap: var(--sp-7);
+ min-height: 118px;
+ min-width: 0;
+ padding: var(--sp-7);
+ border: var(--bw) solid var(--ln);
+ border-radius: var(--r-card);
+ background: var(--sf);
+ color: var(--ink);
+ text-decoration: none;
+ box-shadow: var(--sh);
+}
+.sec-card--row {
+ grid-column: 1 / -1;
+ flex-direction: row;
+ align-items: center;
+ justify-content: flex-start;
+ min-height: 72px;
+}
+.sec-card-name {
+ display: block;
+ font-size: var(--fs-17);
+ font-weight: 700;
+ line-height: 1.25;
+}
+.sec-card-n {
+ display: block;
+ font-size: var(--fs-14);
+ color: var(--ink2);
+ margin-top: var(--sp-1);
+}
+
+.plaque {
+ flex: none;
+ align-self: flex-start;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ min-width: 44px;
+ height: 32px;
+ padding: 0 var(--sp-4);
+ border-radius: var(--r-plaque);
+ color: var(--plq-ink-text);
+ font-size: var(--fs-19);
+ font-weight: 700;
+}
+.sec-card--row .plaque,
+.sec-head .plaque {
+ align-self: center;
+}
+.plaque--lg {
+ min-width: 64px;
+ height: 48px;
+ padding: 0 var(--sp-5);
+ font-size: var(--fs-26);
+}
+.plaque--yellow {
+ background: var(--plq-yellow);
+}
+.plaque--orange {
+ background: var(--plq-orange);
+}
+.plaque--blue {
+ background: var(--plq-blue);
+}
+.plaque--green {
+ background: var(--plq-green);
+}
+.plaque--ink {
+ background: var(--ink);
+ color: var(--bg);
+}
+
+.codetag {
+ flex: none;
+ font-size: var(--fs-12);
+ font-weight: 700;
+ line-height: 1.2;
+ padding: var(--sp-2) var(--sp-3);
+ border: 2px solid var(--ink);
+ border-radius: 5px;
+}
+.codetag--sm {
+ font-size: 0.6875rem;
+ padding: 3px 5px;
+ border-radius: var(--r-xs);
+}
+
+/* ---------- Списки ---------- */
+.list {
+ border: var(--bw) solid var(--ln);
+ border-radius: var(--r-card);
+ background: var(--sf);
+ overflow: hidden;
+}
+.list-row {
+ display: flex;
+ align-items: center;
+ gap: var(--sp-6);
+ min-height: var(--h-row);
+ padding: var(--sp-5) var(--sp-7);
+ color: var(--ink);
+ text-decoration: none;
+}
+.list-row + .list-row {
+ border-top: var(--bw) solid var(--ln);
+}
+.list-row-main {
+ flex: 1;
+ min-width: 0;
+}
+.list-row-title {
+ display: block;
+ font-weight: 600;
+ line-height: var(--lh-snug);
+}
+.list-row-sub {
+ display: block;
+ font-size: var(--fs-14);
+ color: var(--ink2);
+}
+.list-row-over,
+.list-row-desc {
+ display: none;
+}
+.list-row-meta {
+ flex: none;
+ font-size: var(--fs-13);
+ color: var(--ink2);
+}
+.list-row-chev {
+ flex: none;
+ font-size: var(--fs-22);
+ color: var(--ink2);
+}
+
+/* ---------- Экран раздела ---------- */
+.sec-head {
+ display: flex;
+ align-items: center;
+ gap: var(--sp-7);
+}
+.sec-title {
+ font-size: var(--fs-28);
+ font-weight: 700;
+ line-height: 1.1;
+}
+.sec-meta {
+ font-size: var(--fs-15);
+ color: var(--ink2);
+ margin-top: var(--sp-1);
+}
+.art-cards {
+ display: flex;
+ flex-direction: column;
+ gap: var(--sp-8);
+}
+.art-card {
+ display: flex;
+ flex-direction: column;
+ gap: var(--sp-4);
+ padding: var(--sp-8);
+ border: var(--bw) solid var(--ln);
+ border-radius: var(--r-card);
+ background: var(--sf);
+ text-decoration: none;
+ color: var(--ink);
+ box-shadow: var(--sh);
+}
+.art-card-head {
+ display: flex;
+ gap: var(--sp-5);
+ align-items: baseline;
+}
+.art-card-n {
+ font-size: var(--fs-14);
+ font-weight: 700;
+ color: var(--ink2);
+}
+.art-card-title {
+ font-size: var(--fs-19);
+ font-weight: 700;
+ line-height: 1.25;
+}
+.art-card-text {
+ font-size: var(--fs-16);
+ line-height: var(--lh-normal);
+ color: var(--ink2);
+}
+
+.tags {
+ display: flex;
+ gap: var(--sp-3);
+ flex-wrap: wrap;
+}
+.tag {
+ display: flex;
+ align-items: center;
+ min-height: 28px;
+ padding: 0 var(--sp-4);
+ border-radius: var(--r-tag);
+ background: var(--sf2);
+ border: var(--bw) solid var(--ln);
+ font-size: var(--fs-13);
+ font-weight: 600;
+}
+.tag--equip {
+ min-height: 32px;
+ padding: 0 var(--sp-5);
+ border-radius: var(--r-sm);
+}
+
+/* Строка «Сохранено для офлайна» */
+.offline-row {
+ display: flex;
+ align-items: center;
+ gap: var(--sp-6);
+ min-height: var(--h-row-sm);
+ padding: var(--sp-4) var(--sp-7);
+ border-radius: var(--r-btn);
+ border: var(--bw) solid var(--ln);
+ background: var(--sf);
+ font-size: var(--fs-15);
+ font-weight: 700;
+}
+.offline-row--done {
+ border-color: transparent;
+ background: var(--grnbg);
+ color: var(--grn);
+}
+.offline-row-text {
+ flex: 1;
+ min-width: 0;
+}
+.offline-row-btn {
+ flex: none;
+ min-height: var(--tap-sm);
+ padding: 0 var(--sp-2);
+ border: 0;
+ background: transparent;
+ color: inherit;
+ font-size: var(--fs-14);
+ font-weight: 600;
+ text-decoration: underline;
+ cursor: pointer;
+}
+.dot {
+ flex: none;
+ width: 10px;
+ height: 10px;
+ border-radius: 50%;
+ background: var(--grnS);
+}
+.dot--sm {
+ width: 8px;
+ height: 8px;
+}
+.pill-offline {
+ flex: none;
+ display: flex;
+ align-items: center;
+ gap: var(--sp-3);
+ height: 32px;
+ padding: 0 var(--sp-5);
+ border-radius: var(--r-pill);
+ background: var(--grnbg);
+ color: var(--grn);
+ font-size: var(--fs-13);
+ font-weight: 700;
+ white-space: nowrap;
+}
+
+/* ---------- Статья ---------- */
+.deskbar,
+.art-aside,
+.art-over {
+ display: none;
+}
+.art-layout {
+ min-width: 0;
+}
+.art {
+ display: flex;
+ flex-direction: column;
+ gap: var(--sp-9);
+ min-width: 0;
+}
+.art-topline {
+ margin-top: calc(var(--sp-4) * -1);
+}
+.art-title {
+ font-size: var(--fs-30);
+ line-height: var(--lh-tight);
+ font-weight: 700;
+ letter-spacing: -0.01em;
+ overflow-wrap: anywhere;
+}
+.art-summary {
+ font-size: var(--fs-17);
+ line-height: 1.5;
+ color: var(--ink2);
+}
+.meta {
+ display: grid;
+ grid-template-columns: auto 1fr;
+ gap: var(--sp-3) var(--sp-7);
+ padding: var(--sp-6) var(--sp-7);
+ border: var(--bw) solid var(--ln);
+ border-radius: var(--r-btn);
+ background: var(--sf);
+ font-size: var(--fs-15);
+ line-height: 1.35;
+}
+.meta dt {
+ color: var(--ink2);
+}
+.meta dd {
+ font-weight: 700;
+ font-size: var(--fs-14);
+}
+.meta-break {
+ word-break: break-all;
+}
+.hashtags {
+ display: flex;
+ gap: var(--sp-3) var(--sp-5);
+ flex-wrap: wrap;
+}
+.hashtag {
+ font-size: var(--fs-14);
+ color: var(--ink2);
+ padding: var(--sp-2) 0;
+ text-decoration: none;
+}
+.art-src-mobile {
+ display: flex;
+ flex-direction: column;
+ gap: var(--sp-4);
+}
+.src-card {
+ display: flex;
+ align-items: center;
+ gap: var(--sp-7);
+ min-height: 76px;
+ padding: var(--sp-6) var(--sp-7);
+ border: var(--bw) solid var(--ln);
+ border-radius: var(--r-card);
+ background: var(--sf);
+ color: var(--ink);
+ text-decoration: none;
+}
+.src-ico {
+ flex: none;
+ width: 42px;
+ height: 52px;
+ border: 2px solid var(--ink);
+ border-radius: var(--r-xs) var(--r-btn) var(--r-xs) var(--r-xs);
+ display: flex;
+ align-items: flex-end;
+ justify-content: center;
+ padding-bottom: var(--sp-3);
+ font-size: 0.6875rem;
+ font-weight: 700;
+}
+.src-main {
+ flex: 1;
+ min-width: 0;
+}
+.src-label {
+ display: block;
+ font-size: var(--fs-12);
+ color: var(--ink2);
+ text-transform: uppercase;
+ letter-spacing: var(--caps);
+ font-weight: 700;
+}
+.src-name {
+ display: block;
+ font-weight: 700;
+ font-size: var(--fs-15);
+ word-break: break-all;
+ line-height: var(--lh-snug);
+}
+.src-meta {
+ display: block;
+ font-size: var(--fs-14);
+ color: var(--ink2);
+}
+.src-btn {
+ flex: none;
+ height: var(--tap);
+ padding: 0 var(--sp-7);
+ border-radius: var(--r-md);
+ background: var(--ink);
+ color: var(--bg);
+ display: flex;
+ align-items: center;
+ font-weight: 700;
+ font-size: var(--fs-15);
+}
+
+.sticky-head {
+ position: fixed;
+ top: 0;
+ left: 0;
+ right: 0;
+ z-index: 5;
+ background: var(--sf);
+ border-bottom: var(--bw) solid var(--ln);
+ padding: calc(var(--sp-4) + env(safe-area-inset-top)) var(--sp-8) var(--sp-5);
+ display: flex;
+ flex-direction: column;
+ gap: 1px;
+ box-shadow: var(--sh);
+ transform: translateY(-110%);
+ transition: transform var(--t-fast);
+}
+.sticky-head.is-on {
+ transform: none;
+}
+.sticky-head-sec {
+ font-size: var(--fs-12);
+ color: var(--ink2);
+}
+.sticky-head-title {
+ font-size: var(--fs-16);
+ font-weight: 700;
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
+}
+.sticky-head-bar {
+ position: absolute;
+ left: 0;
+ bottom: 0;
+ height: 3px;
+ background: var(--hl);
+ transition: width 0.1s linear;
+}
+
+/* ---------- Панель снизу и окно ---------- */
+.sheet-wrap {
+ position: fixed;
+ inset: 0;
+ z-index: 30;
+ display: flex;
+ align-items: flex-end;
+}
+.scrim {
+ position: absolute;
+ inset: 0;
+ border: 0;
+ background: var(--scrim);
+ cursor: pointer;
+}
+.sheet {
+ position: relative;
+ width: 100%;
+ max-height: 86dvh;
+ display: flex;
+ flex-direction: column;
+ background: var(--sf);
+ color: var(--ink);
+ border-radius: var(--r-sheet) var(--r-sheet) 0 0;
+ box-shadow: var(--sheet-shadow);
+ padding-bottom: calc(var(--sp-10) + env(safe-area-inset-bottom));
+ animation: sheet-in var(--t-sheet);
+}
+@keyframes sheet-in {
+ from {
+ transform: translateY(24px);
+ opacity: 0;
+ }
+}
+.sheet-grip {
+ flex: none;
+ display: flex;
+ justify-content: center;
+ padding: var(--sp-5) 0 var(--sp-2);
+}
+.sheet-grip span {
+ width: 44px;
+ height: 5px;
+ border-radius: 3px;
+ background: var(--ln);
+}
+.sheet-head {
+ flex: none;
+ display: flex;
+ align-items: flex-start;
+ justify-content: space-between;
+ gap: var(--sp-4);
+ padding: 0 var(--sp-4) var(--sp-3) var(--sp-9);
+}
+.sheet-titles {
+ flex: 1;
+ min-width: 0;
+ padding-top: var(--sp-4);
+}
+.sheet-title {
+ font-size: var(--fs-19);
+ font-weight: 700;
+}
+.sheet-sub {
+ font-size: var(--fs-15);
+ color: var(--ink2);
+ margin-top: var(--sp-1);
+ line-height: 1.35;
+}
+.sheet-close {
+ flex: none;
+ width: var(--tap);
+ height: var(--tap);
+ border: 0;
+ background: transparent;
+ font-size: var(--fs-20);
+ cursor: pointer;
+ color: var(--ink);
+}
+.sheet-scroll {
+ overflow-y: auto;
+ overscroll-behavior: contain;
+}
+.sheet-body {
+ display: flex;
+ flex-direction: column;
+ gap: var(--sp-8);
+ padding: var(--sp-2) var(--sp-9) 0;
+ overflow-y: auto;
+}
+.sheet-empty {
+ padding: var(--sp-8) var(--sp-9);
+ color: var(--ink2);
+ font-size: var(--fs-16);
+}
+.toc-row {
+ display: flex;
+ align-items: center;
+ gap: var(--sp-7);
+ width: 100%;
+ min-height: var(--h-row-sm);
+ padding: var(--sp-4) var(--sp-9);
+ border: 0;
+ border-top: var(--bw) solid var(--ln);
+ background: transparent;
+ text-align: left;
+ cursor: pointer;
+ color: var(--ink);
+ font-size: var(--fs-17);
+ font-weight: 600;
+ line-height: var(--lh-snug);
+}
+.toc-n {
+ flex: none;
+ font-size: var(--fs-13);
+ color: var(--ink2);
+}
+
+/* ---------- Кнопки ---------- */
+.btn {
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ gap: var(--sp-4);
+ min-height: var(--tap-sm);
+ padding: 0 var(--sp-7);
+ border: var(--bw) solid var(--ln);
+ border-radius: var(--r-md);
+ background: var(--sf);
+ color: var(--ink);
+ font-size: var(--fs-15);
+ font-weight: 600;
+ text-decoration: none;
+ cursor: pointer;
+ white-space: nowrap;
+}
+.btn:disabled {
+ opacity: 0.55;
+ cursor: default;
+}
+.btn--solid {
+ border: 0;
+ background: var(--ink);
+ color: var(--bg);
+ font-weight: 700;
+}
+.btn--outline {
+ border: 2px solid var(--ink);
+ background: transparent;
+ font-weight: 700;
+}
+.btn--brand {
+ border: 0;
+ background: var(--hl);
+ color: var(--brand-ink);
+ font-weight: 700;
+}
+.btn--dashed {
+ border: 2px dashed var(--ln);
+ background: transparent;
+ font-weight: 700;
+}
+.btn--lg {
+ min-height: var(--h-btn);
+ border-radius: var(--r-btn);
+ font-size: var(--fs-16);
+}
+.btn--xl {
+ min-height: var(--h-field);
+ border-radius: var(--r-btn);
+ font-size: var(--fs-18);
+}
+.btn--block {
+ display: flex;
+ width: 100%;
+}
+
+.segmented {
+ display: grid;
+ grid-template-columns: 1fr 1fr;
+ gap: var(--sp-2);
+ padding: var(--sp-2);
+ border: var(--bw) solid var(--ln);
+ border-radius: var(--r-btn);
+ background: var(--sf2);
+}
+.segmented--3 {
+ grid-template-columns: repeat(3, 1fr);
+}
+.seg {
+ min-height: var(--tap-sm);
+ border: 0;
+ border-radius: 9px;
+ background: transparent;
+ color: var(--ink);
+ font-size: var(--fs-15);
+ font-weight: 600;
+ cursor: pointer;
+}
+.seg--on {
+ background: var(--ink);
+ color: var(--bg);
+ font-weight: 700;
+}
+
+/* ---------- Уведомления, пустые состояния, загрузка ---------- */
+.notice {
+ display: flex;
+ flex-direction: column;
+ gap: var(--sp-4);
+ padding: var(--sp-8);
+ border: 2px dashed var(--ln);
+ border-radius: var(--r-card);
+}
+.notice--error {
+ border-style: solid;
+ border-color: var(--redS);
+ background: var(--redbg);
+}
+.notice-title {
+ font-size: var(--fs-18);
+ font-weight: 700;
+}
+.notice-text {
+ font-size: var(--fs-16);
+ color: var(--ink2);
+ line-height: var(--lh-normal);
+}
+.skeleton {
+ display: flex;
+ flex-direction: column;
+ gap: var(--sp-6);
+}
+.skeleton-line {
+ height: var(--h-row-sm);
+ border-radius: var(--r-card);
+ background: var(--sf);
+ border: var(--bw) solid var(--ln);
+ opacity: 0.6;
+}
+
+/* ---------- Шпаргалка ---------- */
+.cheat-intro {
+ margin-top: calc(var(--sp-4) * -1);
+ font-size: var(--fs-16);
+ color: var(--ink2);
+ line-height: var(--lh-normal);
+}
+.cheat-print {
+ margin-top: calc(var(--sp-3) * -1);
+ min-height: var(--h-btn);
+ border-radius: var(--r-btn);
+ font-size: var(--fs-16);
+}
+.cs-box {
+ border: 2px solid var(--ln);
+ border-radius: var(--r-block);
+ overflow: hidden;
+ background: var(--sf);
+}
+.cs-box--red {
+ border-color: var(--redS);
+}
+.cs-box--green {
+ border-color: var(--grnS);
+}
+.cs-box-head {
+ display: flex;
+ align-items: center;
+ gap: var(--sp-5);
+ min-height: var(--tap);
+ padding: 0 var(--sp-7);
+ color: var(--on-strong);
+ font-size: var(--fs-16);
+ font-weight: 700;
+ letter-spacing: var(--caps-wide);
+}
+.cs-box--red .cs-box-head {
+ background: var(--redS);
+}
+.cs-box--green .cs-box-head {
+ background: var(--grnS);
+}
+.cs-box-n {
+ margin-left: auto;
+}
+.cs-minus {
+ flex: none;
+ position: relative;
+ width: 24px;
+ height: 24px;
+ border-radius: 50%;
+ background: var(--on-strong);
+}
+.cs-minus::after {
+ content: '';
+ position: absolute;
+ left: 5.5px;
+ top: 10px;
+ width: 13px;
+ height: 4px;
+ background: var(--redS);
+}
+.cs-ban {
+ display: flex;
+ gap: var(--sp-6);
+ padding: var(--sp-6) var(--sp-7);
+ border-top: var(--bw) solid var(--ln);
+}
+.cs-ban-n {
+ flex: none;
+ font-size: var(--fs-14);
+ font-weight: 700;
+ color: var(--red);
+ padding-top: var(--sp-1);
+}
+.cs-ban-main {
+ display: flex;
+ flex-direction: column;
+ gap: var(--sp-3);
+ min-width: 0;
+}
+.cs-text {
+ line-height: var(--lh-normal);
+}
+.cs-text strong {
+ font-weight: var(--ws);
+}
+.cs-ban .cs-text strong {
+ color: var(--red);
+}
+.cs-h {
+ display: flex;
+ align-items: baseline;
+ justify-content: space-between;
+}
+.cs-h h2 {
+ font-size: var(--fs-22);
+ font-weight: 700;
+}
+.cs-h span {
+ font-size: var(--fs-13);
+ color: var(--ink2);
+}
+.cs-fact {
+ display: flex;
+ flex-direction: column;
+ gap: var(--sp-3);
+ padding: var(--sp-6) var(--sp-7);
+}
+.cs-fact + .cs-fact {
+ border-top: var(--bw) solid var(--ln);
+}
+.cs-fact-row {
+ display: flex;
+ align-items: baseline;
+ justify-content: space-between;
+ gap: var(--sp-6);
+}
+.cs-fact-t {
+ font-size: var(--fs-16);
+ line-height: 1.35;
+ min-width: 0;
+}
+.cs-fact-v {
+ flex: none;
+ font-size: var(--fs-19);
+ font-weight: 700;
+ text-align: right;
+ max-width: 52%;
+}
+.cs-colors {
+ display: grid;
+ grid-template-columns: 1fr 1fr;
+ gap: var(--sp-4);
+}
+.cs-color {
+ display: flex;
+ flex-direction: column;
+ border: var(--bw) solid var(--ln);
+ border-radius: var(--r-card);
+ overflow: hidden;
+ background: var(--sf);
+}
+.cs-swatch {
+ height: 56px;
+}
+.cs-color-text {
+ padding: var(--sp-5) var(--sp-6);
+}
+.cs-color-code {
+ font-size: var(--fs-18);
+ font-weight: 700;
+}
+.cs-color-label {
+ font-size: var(--fs-14);
+ color: var(--ink2);
+}
+.cs-always {
+ display: flex;
+ gap: var(--sp-6);
+ align-items: flex-start;
+ padding: var(--sp-6) var(--sp-7);
+ border-top: var(--bw) solid var(--ln);
+}
+.cs-tick {
+ flex: none;
+ position: relative;
+ width: 22px;
+ height: 22px;
+ margin-top: var(--sp-1);
+ border-radius: var(--r-tag);
+ background: var(--grnS);
+}
+.cs-tick::after {
+ content: '';
+ position: absolute;
+ left: 8px;
+ top: 4px;
+ width: 6px;
+ height: 11px;
+ border: solid var(--on-strong);
+ border-width: 0 2.5px 2.5px 0;
+ transform: rotate(45deg);
+}
+
+/* ---------- Просмотр фото ---------- */
+.lb {
+ position: fixed;
+ inset: 0;
+ z-index: 50;
+ background: var(--lb-bg);
+ color: var(--lb-ink);
+ display: flex;
+ flex-direction: column;
+}
+.lb-top {
+ flex: none;
+ display: flex;
+ align-items: center;
+ gap: var(--sp-5);
+ padding: calc(var(--sp-4) + env(safe-area-inset-top)) var(--sp-4) var(--sp-4) var(--sp-8);
+ min-height: 68px;
+}
+.lb-info {
+ flex: 1;
+ min-width: 0;
+ display: flex;
+ flex-direction: column;
+ gap: var(--sp-1);
+}
+.lb-counter {
+ font-size: var(--fs-13);
+ color: var(--lb-ink2);
+}
+.lb-cap {
+ font-size: var(--fs-16);
+ font-weight: 600;
+ line-height: var(--lh-snug);
+}
+.lb-btn {
+ height: 52px;
+ border-radius: var(--r-btn);
+ border: 1px solid var(--lb-ln);
+ background: var(--lb-sf);
+ color: var(--lb-ink);
+ font-size: var(--fs-22);
+ cursor: pointer;
+}
+.lb-btn--close {
+ flex: none;
+ width: 52px;
+}
+.lb-btn--pct {
+ font-size: var(--fs-15);
+ font-weight: 700;
+}
+.lb-stage {
+ flex: 1;
+ min-height: 0;
+ position: relative;
+ overflow: hidden;
+ touch-action: none;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ cursor: grab;
+ user-select: none;
+}
+.lb-img {
+ max-width: 100%;
+ max-height: 100%;
+ pointer-events: none;
+ transition: transform 0.15s ease-out;
+}
+.lb-miss {
+ width: 86%;
+ aspect-ratio: 4 / 3;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ background: repeating-linear-gradient(135deg, var(--lb-sf) 0 14px, var(--lb-sf2) 14px 28px);
+ font-size: var(--fs-14);
+ color: var(--lb-ink2);
+ transition: transform 0.15s;
+}
+.lb-bottom {
+ flex: none;
+ display: flex;
+ flex-direction: column;
+ gap: var(--sp-4);
+ padding: var(--sp-5) var(--sp-6) calc(var(--sp-11) + env(safe-area-inset-bottom));
+}
+.lb-controls {
+ display: grid;
+ grid-template-columns: 56px 1fr 56px 72px 56px 1fr 56px;
+ gap: var(--sp-3);
+ align-items: center;
+}
+.lb-hint {
+ text-align: center;
+ font-size: var(--fs-13);
+ color: var(--lb-ink3);
+}
+
+/* =====================================================================
+ Компьютер: левое меню, широкая главная, статья с боковой колонкой
+ ===================================================================== */
+@media (min-width: 1024px) {
+ .tabbar {
+ display: none;
+ }
+
+ .sidebar {
+ position: fixed;
+ top: 0;
+ bottom: 0;
+ left: 0;
+ width: var(--w-sidebar);
+ display: flex;
+ flex-direction: column;
+ border-right: var(--bw) solid var(--ln);
+ background: var(--sf);
+ overflow-y: auto;
+ }
+ .sidebar-brand {
+ display: block;
+ padding: var(--sp-10) var(--sp-10) var(--sp-6);
+ text-decoration: none;
+ }
+ .sidebar-brand-title {
+ display: block;
+ font-size: var(--fs-19);
+ font-weight: 700;
+ line-height: var(--lh-snug);
+ }
+ .sidebar-brand-sub {
+ display: block;
+ font-size: var(--fs-13);
+ color: var(--ink2);
+ }
+ .space-pick {
+ margin: 0 var(--sp-6) var(--sp-6);
+ min-height: 52px;
+ display: flex;
+ align-items: center;
+ gap: var(--sp-5);
+ padding: 0 var(--sp-6);
+ border: var(--bw) solid var(--ln);
+ border-radius: var(--r-btn);
+ background: var(--sf2);
+ }
+ .space-pick-icon {
+ flex: none;
+ width: 28px;
+ height: 28px;
+ border-radius: var(--r-tag);
+ background: var(--brand);
+ color: var(--brand-ink);
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ font-weight: 700;
+ font-size: var(--fs-15);
+ }
+ .space-pick-label {
+ display: block;
+ font-size: 0.6875rem;
+ color: var(--ink2);
+ text-transform: uppercase;
+ letter-spacing: var(--caps);
+ font-weight: 700;
+ line-height: 1.3;
+ }
+ .space-pick-name {
+ display: block;
+ font-size: var(--fs-16);
+ font-weight: 700;
+ line-height: 1.3;
+ }
+ .tree {
+ display: flex;
+ flex-direction: column;
+ padding: 0 var(--sp-4) var(--sp-8);
+ }
+ .tree-head {
+ display: flex;
+ align-items: center;
+ gap: var(--sp-5);
+ min-height: var(--tap-sm);
+ padding: var(--sp-3) var(--sp-6) 0;
+ font-size: var(--fs-15);
+ font-weight: 700;
+ line-height: var(--lh-snug);
+ text-decoration: none;
+ }
+ .tree-link {
+ display: flex;
+ align-items: center;
+ min-height: var(--h-chip);
+ padding: var(--sp-2) var(--sp-6) var(--sp-2) 52px;
+ border-radius: var(--r-sm);
+ font-size: var(--fs-15);
+ line-height: var(--lh-snug);
+ color: var(--ink2);
+ text-decoration: none;
+ }
+ .tree-link--top {
+ padding-left: var(--sp-6);
+ font-weight: 600;
+ color: var(--ink);
+ }
+ .tree-link--on,
+ .tree-link.active {
+ font-weight: 700;
+ color: var(--ink);
+ background: var(--sf2);
+ box-shadow: inset 4px 0 0 var(--hl);
+ }
+ .sidebar-foot {
+ margin-top: auto;
+ padding: var(--sp-8);
+ border-top: var(--bw) solid var(--ln);
+ display: flex;
+ flex-direction: column;
+ gap: var(--sp-4);
+ }
+ .sidebar-foot-label {
+ font-size: var(--fs-13);
+ font-weight: 700;
+ color: var(--ink2);
+ }
+ .sidebar-foot .seg {
+ min-height: var(--h-chip);
+ font-size: var(--fs-14);
+ }
+
+ .shell-main {
+ margin-left: var(--w-sidebar);
+ }
+ .screen {
+ gap: var(--sp-12);
+ max-width: calc(var(--w-article) + var(--sp-28) * 2);
+ padding: var(--sp-20) var(--sp-28) var(--sp-32);
+ }
+ .screen--wide {
+ max-width: 1140px;
+ gap: var(--sp-16);
+ }
+
+ /* На компьютере тема переключается в меню слева */
+ .home-head .theme-btn,
+ .topline .theme-btn {
+ display: none;
+ }
+
+ /* Главная */
+ .home-search {
+ max-width: 900px;
+ }
+ .search-field {
+ height: 68px;
+ padding: 0 var(--sp-7) 0 var(--sp-10);
+ border-radius: var(--r-block);
+ gap: var(--sp-7);
+ }
+ .search-input {
+ font-size: var(--fs-20);
+ }
+ .kbd {
+ flex: none;
+ height: 32px;
+ padding: 0 var(--sp-5);
+ display: flex;
+ align-items: center;
+ border: var(--bw) solid var(--ln);
+ border-radius: var(--r-tag);
+ font-size: var(--fs-14);
+ color: var(--ink2);
+ }
+ .home-top {
+ display: grid;
+ grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
+ gap: var(--sp-10);
+ align-items: stretch;
+ }
+ .home-top > :only-child {
+ grid-column: 1 / -1;
+ }
+ .cheat-card {
+ gap: var(--sp-7);
+ padding: var(--sp-12);
+ border-radius: var(--r-lg);
+ }
+ .cheat-card-caps {
+ font-size: var(--fs-13);
+ }
+ .cheat-card-title {
+ font-size: var(--fs-36);
+ line-height: 1;
+ }
+ .cheat-card-text {
+ font-size: var(--fs-17);
+ }
+ .cheat-card-facts {
+ grid-template-columns: repeat(4, 1fr);
+ gap: var(--sp-4);
+ }
+ .cheat-card-fact {
+ padding: var(--sp-6);
+ border-radius: var(--r-md);
+ }
+ .cheat-card-value {
+ font-size: var(--fs-24);
+ }
+ .cheat-card-label {
+ font-size: var(--fs-14);
+ }
+ .home-recent .caps-row {
+ padding: var(--sp-8) var(--sp-9) var(--sp-4);
+ }
+ .home-recent {
+ gap: 0;
+ border: var(--bw) solid var(--ln);
+ border-radius: var(--r-lg);
+ background: var(--sf);
+ overflow: hidden;
+ }
+ .home-recent .list {
+ border: 0;
+ border-radius: 0;
+ }
+ .home-recent .list-row {
+ min-height: var(--h-field);
+ padding: var(--sp-4) var(--sp-9);
+ border-top: var(--bw) solid var(--ln);
+ }
+ .home-recent .list-row-title {
+ font-weight: 700;
+ }
+ .sec-grid {
+ grid-template-columns: repeat(5, minmax(0, 1fr));
+ gap: var(--sp-6);
+ }
+ .sec-card,
+ .sec-card--row {
+ grid-column: auto;
+ flex-direction: column;
+ align-items: stretch;
+ justify-content: space-between;
+ gap: var(--sp-10);
+ min-height: 140px;
+ padding: var(--sp-8);
+ }
+ .sec-card--row .plaque {
+ align-self: flex-start;
+ }
+ .sec-card .plaque {
+ min-width: 48px;
+ height: 34px;
+ font-size: var(--fs-20);
+ }
+ .sec-card-name {
+ font-size: var(--fs-18);
+ }
+ .list--cards {
+ display: grid;
+ grid-template-columns: repeat(3, minmax(0, 1fr));
+ gap: var(--sp-6);
+ border: 0;
+ background: transparent;
+ overflow: visible;
+ }
+ .list--cards .list-row {
+ align-items: flex-start;
+ padding: var(--sp-8);
+ border: var(--bw) solid var(--ln);
+ border-radius: var(--r-card);
+ background: var(--sf);
+ }
+ .list--cards .codetag,
+ .list--cards .list-row-chev {
+ display: none;
+ }
+ .list--cards .list-row-over {
+ display: block;
+ font-size: var(--fs-12);
+ font-weight: 700;
+ color: var(--ink2);
+ text-transform: uppercase;
+ margin-bottom: var(--sp-3);
+ }
+ .list--cards .list-row-title {
+ font-weight: 700;
+ }
+ .list--cards .list-row-desc {
+ display: block;
+ font-size: var(--fs-15);
+ color: var(--ink2);
+ line-height: 1.4;
+ margin-top: var(--sp-3);
+ }
+
+ /* Статья */
+ .screen:has(.art-layout) {
+ max-width: none;
+ padding: 0;
+ gap: 0;
+ }
+ .sticky-head {
+ display: none;
+ }
+ .deskbar {
+ position: sticky;
+ top: 0;
+ z-index: 3;
+ display: flex;
+ align-items: center;
+ gap: var(--sp-5);
+ height: var(--h-row);
+ padding: 0 var(--sp-16);
+ background: var(--bg);
+ border-bottom: var(--bw) solid var(--ln);
+ }
+ .crumbs {
+ flex: 1;
+ min-width: 0;
+ font-size: var(--fs-15);
+ color: var(--ink2);
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ }
+ .crumbs a {
+ text-decoration: none;
+ }
+ .crumbs strong {
+ color: var(--ink);
+ }
+ .art-layout {
+ display: grid;
+ grid-template-columns: minmax(0, var(--w-article)) var(--w-aside);
+ gap: var(--sp-24);
+ padding: var(--sp-16) var(--sp-20) var(--sp-32);
+ justify-content: center;
+ }
+ .art {
+ gap: var(--sp-10);
+ }
+ .art-topline,
+ .art-meta-mobile,
+ .art-src-mobile {
+ display: none;
+ }
+ .art-over {
+ display: block;
+ font-size: var(--fs-13);
+ font-weight: 700;
+ color: var(--ink2);
+ text-transform: uppercase;
+ letter-spacing: var(--caps);
+ }
+ .art-title {
+ margin-top: calc(var(--sp-4) * -1);
+ font-size: var(--fs-40);
+ line-height: 1.12;
+ letter-spacing: -0.015em;
+ }
+ .art-summary {
+ font-size: var(--fs-19);
+ }
+ .art-aside {
+ position: sticky;
+ top: calc(var(--h-row) + var(--sp-16));
+ align-self: start;
+ display: flex;
+ flex-direction: column;
+ gap: var(--sp-7);
+ max-height: calc(100dvh - var(--h-row) - var(--sp-24));
+ overflow-y: auto;
+ }
+ .aside-card {
+ border: var(--bw) solid var(--ln);
+ border-radius: var(--r-card);
+ background: var(--sf);
+ overflow: hidden;
+ }
+ .aside-caps {
+ padding: var(--sp-6) var(--sp-8);
+ font-size: var(--fs-13);
+ font-weight: 700;
+ letter-spacing: var(--caps);
+ text-transform: uppercase;
+ color: var(--ink2);
+ }
+ .aside-toc .toc-row {
+ gap: var(--sp-5);
+ min-height: var(--tap-sm);
+ padding: var(--sp-3) var(--sp-8);
+ font-size: var(--fs-15);
+ }
+ .aside-toc .toc-n {
+ font-size: var(--fs-12);
+ }
+ .aside-meta .meta {
+ border: 0;
+ border-radius: 0;
+ padding: var(--sp-7) var(--sp-8);
+ font-size: var(--fs-14);
+ gap: var(--sp-3) var(--sp-6);
+ }
+ .art-aside .src-card {
+ gap: var(--sp-6);
+ min-height: 0;
+ }
+ .art-aside .src-ico {
+ width: 38px;
+ height: 46px;
+ font-size: 0.625rem;
+ }
+ .art-aside .src-name {
+ font-size: var(--fs-14);
+ }
+ .art-aside .src-meta {
+ font-size: var(--fs-13);
+ }
+ .art-aside .src-btn {
+ display: none;
+ }
+ .kb-h2 {
+ scroll-margin-top: calc(var(--h-row) + var(--sp-8));
+ }
+
+ /* Окно по центру вместо панели снизу */
+ .sheet-wrap {
+ left: var(--w-sidebar);
+ align-items: center;
+ justify-content: center;
+ }
+ .scrim {
+ left: calc(var(--w-sidebar) * -1);
+ background: var(--scrim-strong);
+ }
+ .sheet {
+ width: 520px;
+ max-height: 80dvh;
+ border-radius: var(--r-lg);
+ box-shadow: var(--dialog-shadow);
+ padding-bottom: var(--sp-12);
+ }
+ .sheet-grip {
+ display: none;
+ }
+ .sheet-head {
+ padding: var(--sp-9) var(--sp-8) var(--sp-4) var(--sp-12);
+ }
+ .sheet-title {
+ font-size: var(--fs-22);
+ }
+ .sheet-body {
+ padding: var(--sp-2) var(--sp-12) 0;
+ }
+ .lb {
+ left: 0;
+ }
+}
+
+/* Между телефоном и компьютером (планшет): текст не растягиваем на всю ширину */
+@media (min-width: 720px) and (max-width: 1023.98px) {
+ .screen {
+ max-width: 760px;
+ margin: 0 auto;
+ }
+}
+
+/* ---------- Окно «Печать и PDF» ---------- */
+.tabbar--5 .tab {
+ font-size: var(--fs-12);
+ letter-spacing: -0.01em;
+}
+.seg--lg {
+ min-height: var(--tap);
+ font-size: var(--fs-16);
+}
+.switch-row {
+ display: flex;
+ align-items: center;
+ gap: var(--sp-7);
+ width: 100%;
+ min-height: var(--h-row);
+ padding: var(--sp-5) var(--sp-7);
+ border: 0;
+ background: transparent;
+ text-align: left;
+ color: var(--ink);
+ cursor: pointer;
+}
+.switch-row + .switch-row {
+ border-top: var(--bw) solid var(--ln);
+}
+.switch-row-main {
+ flex: 1;
+ min-width: 0;
+}
+.switch-row-title {
+ display: block;
+ font-size: var(--fs-17);
+ font-weight: 700;
+}
+.switch-row-text {
+ display: block;
+ font-size: var(--fs-14);
+ color: var(--ink2);
+ line-height: 1.35;
+}
+.switch {
+ flex: none;
+ width: 52px;
+ height: 32px;
+ border-radius: 16px;
+ background: var(--sf2);
+ border: var(--bw) solid var(--ln);
+ display: flex;
+ align-items: center;
+ padding: 3px;
+}
+.switch span {
+ width: 24px;
+ height: 24px;
+ border-radius: 50%;
+ background: var(--ink2);
+}
+.switch--on {
+ background: var(--grnS);
+ border-color: var(--grnS);
+ justify-content: flex-end;
+}
+.switch--on span {
+ width: 26px;
+ height: 26px;
+ background: var(--on-strong);
+}
+.print-est {
+ font-size: var(--fs-15);
+ color: var(--ink2);
+}
+.print-hint {
+ font-size: var(--fs-13);
+ color: var(--ink2);
+ margin-top: calc(var(--sp-4) * -1);
+}
+.btn-pair {
+ display: grid;
+ grid-template-columns: 1fr 1fr;
+ gap: var(--sp-4);
+}
diff --git a/apps/web/src/styles/article.css b/apps/web/src/styles/article.css
new file mode 100644
index 0000000..9ac9af6
--- /dev/null
+++ b/apps/web/src/styles/article.css
@@ -0,0 +1,716 @@
+/*
+ * Блоки статьи. Классы kb-* ставит рендер packages/md/src/hast.ts.
+ * Размеры и цвета: из макета new_design/ArticleBodyXL.dc.html.
+ */
+
+.kb-body {
+ display: flex;
+ flex-direction: column;
+ gap: var(--sp-10);
+ font-size: var(--fs-18);
+ line-height: var(--lh-body);
+ font-weight: var(--wb);
+ color: var(--ink);
+ text-wrap: pretty;
+ overflow-wrap: anywhere;
+ min-width: 0;
+}
+
+.kb-body p {
+ margin: 0;
+}
+
+/* Жирный в тексте выделен акцентным цветом: это цифры и ключевые слова */
+.kb-b {
+ font-weight: var(--ws);
+ color: var(--acc);
+}
+
+.kb-h2 {
+ margin: var(--sp-7) 0 calc(var(--sp-2) * -1);
+ padding-top: var(--sp-11);
+ border-top: 2px solid var(--ln);
+ font-size: var(--fs-22);
+ line-height: 1.25;
+ font-weight: 700;
+ /* Чтобы заголовок не прятался под липкой шапкой при переходе из оглавления */
+ scroll-margin-top: 80px;
+}
+
+.kb-h3 {
+ margin: var(--sp-2) 0 calc(var(--sp-4) * -1);
+ font-size: var(--fs-19);
+ line-height: var(--lh-snug);
+ font-weight: 700;
+ color: var(--acc);
+}
+
+.kb-code {
+ padding: 0 var(--sp-2);
+ border-radius: var(--r-xs);
+ background: var(--sf2);
+ font-size: 0.92em;
+}
+
+.kb-pre {
+ margin: 0;
+ padding: var(--sp-6) var(--sp-8);
+ border: var(--bw) solid var(--ln);
+ border-radius: var(--r-card);
+ background: var(--sf);
+ overflow-x: auto;
+ font-size: var(--fs-15);
+}
+
+.kb-quote {
+ margin: 0;
+ padding-left: var(--sp-8);
+ border-left: var(--sp-2) solid var(--ln);
+ color: var(--ink2);
+}
+
+.kb-hr {
+ width: 100%;
+ margin: 0;
+ border: 0;
+ border-top: 2px solid var(--ln);
+}
+
+.kb-a {
+ color: inherit;
+ font-weight: 600;
+ text-decoration: underline;
+}
+
+.kb-ulink {
+ font-weight: 600;
+ text-decoration: underline;
+}
+
+/* ---------- Ссылка-чип на статью: [[slug]] ---------- */
+.kb-link {
+ display: inline-flex;
+ align-items: center;
+ gap: var(--sp-3);
+ min-height: 36px;
+ padding: var(--sp-1) var(--sp-6);
+ margin: 3px 0;
+ border: var(--bw) solid var(--ink);
+ border-radius: var(--r-pill);
+ background: var(--sf);
+ color: var(--ink);
+ font-size: var(--fs-15);
+ font-weight: 600;
+ text-decoration: none;
+ vertical-align: middle;
+ line-height: 1.2;
+}
+
+.kb-link--broken {
+ border-color: var(--redS);
+ color: var(--red);
+}
+
+/* ---------- «Главное» ---------- */
+.kb-key {
+ border: 2px solid var(--ink);
+ border-radius: var(--r-block);
+ overflow: hidden;
+ background: var(--sf);
+}
+
+.kb-hazard {
+ height: 10px;
+ background: repeating-linear-gradient(-45deg, var(--brand) 0 10px, var(--brand-ink) 10px 20px);
+}
+
+.kb-key-head {
+ display: flex;
+ align-items: baseline;
+ justify-content: space-between;
+ padding: var(--sp-6) var(--sp-8) var(--sp-1);
+}
+
+.kb-key-title {
+ font-size: var(--fs-15);
+ font-weight: 700;
+ letter-spacing: var(--caps-wide);
+ text-transform: uppercase;
+}
+
+.kb-key-count {
+ font-size: var(--fs-13);
+ color: var(--ink2);
+}
+
+.kb-key-grid {
+ display: grid;
+ grid-template-columns: 1fr 1fr;
+ grid-auto-flow: dense;
+ gap: var(--sp-4);
+ padding: var(--sp-5);
+}
+
+.kb-key-item {
+ display: flex;
+ flex-direction: column;
+ gap: var(--sp-2);
+ min-width: 0;
+ padding: var(--sp-6) var(--sp-7);
+ border-radius: var(--r-md);
+ background: var(--sf2);
+ border: var(--bw) solid var(--ln);
+}
+
+.kb-key-item--wide {
+ grid-column: 1 / -1;
+}
+
+.kb-key-label {
+ font-size: var(--fs-15);
+ font-weight: 600;
+ color: var(--ink2);
+ line-height: var(--lh-snug);
+}
+
+/* Узкая плитка: значение крупно */
+.kb-key-val {
+ line-height: 1.35;
+}
+.kb-key-val .kb-key-v {
+ font-size: var(--fs-21);
+ font-weight: 700;
+ color: var(--acc);
+ line-height: 1.25;
+}
+.kb-key-val .kb-key-t {
+ font-size: var(--fs-16);
+ color: var(--ink);
+}
+
+/* Широкая плитка: значение в строке текста */
+.kb-key-item--wide .kb-key-val {
+ font-size: var(--fs-17);
+ line-height: var(--lh-normal);
+}
+.kb-key-item--wide .kb-key-v {
+ font-size: var(--fs-19);
+}
+.kb-key-item--wide .kb-key-t {
+ font-size: inherit;
+}
+
+/* ---------- Плашки: ЗАПРЕЩЕНО / ВНИМАНИЕ / СОВЕТ / СПРАВКА ---------- */
+.kb-callout {
+ border: 2px solid var(--ln);
+ border-radius: var(--r-card);
+ overflow: hidden;
+}
+
+.kb-callout-head {
+ display: flex;
+ align-items: center;
+ gap: var(--sp-5);
+ font-weight: 700;
+ letter-spacing: var(--caps-wide);
+}
+
+.kb-callout-body {
+ display: flex;
+ flex-direction: column;
+ gap: var(--sp-4);
+ padding: var(--sp-6) var(--sp-8) var(--sp-7);
+ color: var(--ink);
+}
+
+.kb-callout-icon {
+ flex: none;
+ position: relative;
+}
+
+/* ЗАПРЕЩЕНО: красная шапка, белый круг с минусом */
+.kb-danger {
+ border-color: var(--redS);
+ background: var(--redbg);
+}
+.kb-danger .kb-callout-head {
+ min-height: var(--tap);
+ padding: 0 var(--sp-8);
+ background: var(--redS);
+ color: var(--on-strong);
+ font-size: var(--fs-15);
+}
+.kb-danger .kb-callout-icon {
+ width: 24px;
+ height: 24px;
+ border-radius: 50%;
+ background: var(--on-strong);
+}
+.kb-danger .kb-callout-icon::after {
+ content: '';
+ position: absolute;
+ left: 5.5px;
+ top: 10px;
+ width: 13px;
+ height: 4px;
+ border-radius: 1px;
+ background: var(--redS);
+}
+.kb-danger .kb-b {
+ color: var(--red);
+}
+
+/* ВНИМАНИЕ: жёлтая шапка, треугольник */
+.kb-warning {
+ border-color: var(--ambln);
+ background: var(--ambbg);
+}
+.kb-warning .kb-callout-head {
+ min-height: var(--tap);
+ padding: 0 var(--sp-8);
+ background: var(--brand);
+ color: var(--brand-ink);
+ font-size: var(--fs-15);
+}
+.kb-warning .kb-callout-icon {
+ width: 0;
+ height: 0;
+ border-left: 12px solid transparent;
+ border-right: 12px solid transparent;
+ border-bottom: 20px solid var(--brand-ink);
+}
+.kb-warning .kb-callout-icon::after {
+ content: '';
+ position: absolute;
+ left: -2px;
+ top: 6px;
+ width: 4px;
+ height: 8px;
+ background: var(--brand);
+ border-radius: 1px;
+}
+
+/* СОВЕТ и СПРАВКА: без цветной шапки, заголовок строкой */
+.kb-tip,
+.kb-info {
+ display: flex;
+ flex-direction: column;
+ gap: var(--sp-3);
+ padding: var(--sp-6) var(--sp-8) var(--sp-7);
+}
+.kb-tip .kb-callout-head,
+.kb-info .kb-callout-head {
+ gap: var(--sp-4);
+ font-size: var(--fs-14);
+}
+.kb-tip .kb-callout-body,
+.kb-info .kb-callout-body {
+ padding: 0;
+ gap: var(--sp-3);
+}
+
+.kb-tip {
+ border-color: var(--grnS);
+ background: var(--grnbg);
+}
+.kb-tip .kb-callout-head {
+ color: var(--grn);
+}
+.kb-tip .kb-callout-icon {
+ width: 22px;
+ height: 22px;
+ border-radius: var(--r-tag);
+ background: var(--grnS);
+}
+.kb-tip .kb-callout-icon::after {
+ content: '';
+ position: absolute;
+ left: 8px;
+ top: 4px;
+ width: 6px;
+ height: 11px;
+ border: solid var(--on-strong);
+ border-width: 0 2.5px 2.5px 0;
+ transform: rotate(45deg);
+}
+
+.kb-info {
+ border-color: var(--blu);
+ background: var(--blubg);
+}
+.kb-info .kb-callout-head {
+ color: var(--blu);
+}
+.kb-info .kb-callout-icon {
+ width: 22px;
+ height: 22px;
+ border-radius: 50%;
+ border: 2px solid var(--blu);
+}
+.kb-info .kb-callout-icon::after {
+ content: 'i';
+ position: absolute;
+ inset: 0;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ font-size: var(--fs-13);
+ font-weight: 700;
+ letter-spacing: 0;
+}
+
+/* ---------- Обычный список ---------- */
+.kb-ul {
+ margin: 0;
+ padding: 0;
+ list-style: none;
+ display: flex;
+ flex-direction: column;
+ gap: var(--sp-5);
+}
+.kb-ul > li {
+ display: flex;
+ gap: var(--sp-6);
+}
+.kb-ul > li::before {
+ content: '';
+ flex: none;
+ width: 8px;
+ height: 8px;
+ margin-top: 10px;
+ background: var(--ink);
+}
+.kb-ul > li > span {
+ min-width: 0;
+}
+
+/* ---------- Чек-лист ---------- */
+.kb-check {
+ border: var(--bw) solid var(--ln);
+ border-radius: var(--r-card);
+ background: var(--sf);
+ overflow: hidden;
+ box-shadow: var(--sh);
+}
+
+.kb-check-head {
+ display: flex;
+ align-items: center;
+ gap: var(--sp-5);
+ padding: var(--sp-3) var(--sp-3) var(--sp-3) var(--sp-8);
+}
+
+.kb-check-title {
+ flex: 1;
+ font-size: var(--fs-14);
+ font-weight: 700;
+ letter-spacing: var(--caps-wide);
+ text-transform: uppercase;
+}
+
+.kb-check-count {
+ font-size: var(--fs-18);
+ font-weight: 600;
+}
+
+.kb-check-reset {
+ min-height: var(--tap);
+ padding: 0 var(--sp-6);
+ border: 0;
+ background: transparent;
+ color: var(--ink2);
+ font-size: var(--fs-15);
+ font-weight: 600;
+ text-decoration: underline;
+ cursor: pointer;
+}
+
+.kb-check-bar {
+ height: 4px;
+ background: var(--sf2);
+}
+.kb-check-fill {
+ width: 0;
+ height: 100%;
+ background: var(--grnS);
+ transition: width 0.2s;
+}
+
+.kb-check-row {
+ display: flex;
+ align-items: flex-start;
+ gap: var(--sp-7);
+ width: 100%;
+ min-height: 60px;
+ padding: 15px var(--sp-8);
+ border: 0;
+ border-top: var(--bw) solid var(--ln);
+ background: transparent;
+ text-align: left;
+ cursor: pointer;
+ font-size: var(--fs-18);
+ line-height: 1.5;
+ color: var(--ink);
+}
+
+.kb-box {
+ flex: none;
+ position: relative;
+ width: 30px;
+ height: 30px;
+ border: 2px solid var(--ink);
+ border-radius: var(--r-sm);
+ background: var(--sf);
+}
+
+.kb-check-text {
+ padding-top: var(--sp-1);
+ min-width: 0;
+}
+
+.kb-check-row.is-on .kb-box {
+ border-color: var(--grnS);
+ background: var(--grnS);
+}
+.kb-check-row.is-on .kb-box::after {
+ content: '';
+ position: absolute;
+ left: 9px;
+ top: 3px;
+ width: 8px;
+ height: 15px;
+ border: solid var(--on-strong);
+ border-width: 0 3px 3px 0;
+ transform: rotate(45deg);
+}
+.kb-check-row.is-on .kb-check-text {
+ opacity: 0.5;
+ text-decoration: line-through;
+}
+
+/* ---------- Шаги ---------- */
+.kb-steps {
+ margin: 0;
+ padding: 0;
+ list-style: none;
+ display: flex;
+ flex-direction: column;
+ gap: var(--sp-5);
+}
+
+.kb-step {
+ display: flex;
+ gap: var(--sp-7);
+ padding: var(--sp-8) var(--sp-8) var(--sp-8) var(--sp-7);
+ background: var(--sf);
+ border: var(--bw) solid var(--ln);
+ border-radius: var(--r-card);
+ box-shadow: var(--sh);
+}
+
+.kb-step-n {
+ flex: none;
+ width: 44px;
+ height: 44px;
+ border-radius: var(--r-xs);
+ background: var(--hl);
+ color: var(--brand-ink);
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ font-size: var(--fs-20);
+ font-weight: 700;
+}
+
+.kb-step-main {
+ display: flex;
+ flex-direction: column;
+ gap: var(--sp-2);
+ min-width: 0;
+}
+
+.kb-step-title {
+ font-size: var(--fs-18);
+ font-weight: 700;
+ line-height: var(--lh-snug);
+}
+
+/* ---------- Таблица из двух колонок: «что → значение» ---------- */
+.kb-kv {
+ border: var(--bw) solid var(--ln);
+ border-radius: var(--r-card);
+ background: var(--sf);
+ overflow: hidden;
+}
+
+.kb-kv-head {
+ display: flex;
+ justify-content: space-between;
+ gap: var(--sp-8);
+ padding: var(--sp-5) var(--sp-8);
+ background: var(--sf2);
+ font-size: var(--fs-14);
+ font-weight: 700;
+ color: var(--ink2);
+}
+
+.kb-kv-row {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: var(--sp-8);
+ min-height: var(--h-row-sm);
+ padding: var(--sp-5) var(--sp-8);
+ border-top: var(--bw) solid var(--ln);
+}
+
+.kb-kv-k {
+ flex: 1;
+ min-width: 0;
+ line-height: 1.35;
+}
+
+.kb-kv-v {
+ font-size: var(--fs-19);
+ font-weight: 700;
+ color: var(--acc);
+ text-align: right;
+ /* Короткие значения не переносим, но длинные не должны распирать экран */
+ max-width: 60%;
+}
+
+/* ---------- Таблица из трёх и более колонок: карточки ---------- */
+.kb-cards {
+ display: flex;
+ flex-direction: column;
+ gap: var(--sp-4);
+}
+
+.kb-card {
+ padding: var(--sp-7) var(--sp-8);
+ border: var(--bw) solid var(--ln);
+ border-radius: var(--r-card);
+ background: var(--sf);
+ display: flex;
+ flex-direction: column;
+ gap: var(--sp-4);
+}
+
+.kb-card-title {
+ font-weight: 700;
+ line-height: var(--lh-snug);
+}
+
+.kb-card-row {
+ display: flex;
+ gap: var(--sp-6);
+ align-items: baseline;
+}
+
+.kb-card-label {
+ flex: none;
+ width: 84px;
+ font-size: var(--fs-14);
+ color: var(--ink2);
+ overflow-wrap: break-word;
+}
+
+.kb-card-val {
+ min-width: 0;
+}
+.kb-card-val .kb-b {
+ font-size: var(--fs-18);
+}
+
+/* ---------- Фото ---------- */
+.kb-figs {
+ display: flex;
+ flex-direction: column;
+ gap: var(--sp-7);
+}
+
+.kb-figs-grid {
+ display: grid;
+ grid-template-columns: 1fr 1fr;
+ gap: var(--sp-6);
+}
+
+.kb-fig {
+ margin: 0;
+ display: flex;
+ flex-direction: column;
+ gap: var(--sp-3);
+ min-width: 0;
+}
+.kb-fig--first {
+ gap: var(--sp-4);
+}
+
+.kb-fig-btn {
+ position: relative;
+ display: block;
+ width: 100%;
+ padding: 0;
+ border: var(--bw) solid var(--ln);
+ border-radius: var(--r-md);
+ overflow: hidden;
+ background: var(--sf2);
+ cursor: zoom-in;
+}
+.kb-fig--first .kb-fig-btn {
+ border-radius: var(--r-btn);
+}
+
+.kb-fig-img {
+ display: block;
+ width: 100%;
+ height: auto;
+ aspect-ratio: 1 / 1;
+ object-fit: cover;
+}
+.kb-fig--first .kb-fig-img {
+ aspect-ratio: auto;
+ object-fit: contain;
+}
+
+.kb-fig-zoom {
+ position: absolute;
+ right: var(--sp-5);
+ bottom: var(--sp-5);
+ min-height: 36px;
+ padding: 0 var(--sp-7);
+ display: flex;
+ align-items: center;
+ border-radius: var(--r-pill);
+ background: var(--zoom-pill);
+ color: var(--on-strong);
+ font-size: var(--fs-14);
+ font-weight: 600;
+}
+
+.kb-fig-cap {
+ font-size: var(--fs-14);
+ line-height: 1.35;
+ color: var(--ink2);
+}
+.kb-fig--first .kb-fig-cap {
+ font-size: var(--fs-15);
+ line-height: 1.4;
+}
+
+/* Заглушка, если картинка не загрузилась (нет сети и нет в кеше) */
+.kb-fig-miss {
+ aspect-ratio: 1 / 1;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ padding: var(--sp-4);
+ background: repeating-linear-gradient(135deg, var(--sf2) 0 10px, var(--sf) 10px 20px);
+ font-size: var(--fs-12);
+ color: var(--ink2);
+ text-align: center;
+}
+.kb-fig--first .kb-fig-miss {
+ aspect-ratio: 4 / 3;
+ font-size: var(--fs-13);
+}
diff --git a/apps/web/src/styles/print.css b/apps/web/src/styles/print.css
new file mode 100644
index 0000000..fe1d495
--- /dev/null
+++ b/apps/web/src/styles/print.css
@@ -0,0 +1,592 @@
+/*
+ * Печатная версия (макеты P1–P3). Всегда светлая и читается в ч/б:
+ * блоки различаются рамкой и подписью, цвет только дублирует их.
+ */
+
+.pr-screen {
+ min-height: 100dvh;
+ background: var(--bg);
+ padding: var(--sp-8);
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ gap: var(--sp-8);
+}
+
+.pr-tools {
+ width: 100%;
+ max-width: 794px;
+ display: flex;
+ align-items: center;
+ gap: var(--sp-6);
+}
+.pr-tools-info {
+ flex: 1;
+ min-width: 0;
+ font-size: var(--fs-14);
+ color: var(--ink2);
+}
+
+/* Лист: на экране как страница A4 (794 px = 210 мм при 96 dpi), на телефоне сжимается по ширине */
+.pr-sheet {
+ --ink: var(--pr-ink);
+ --ink2: var(--pr-ink3);
+ --acc: var(--pr-ink);
+ --ws: 700;
+ width: 100%;
+ max-width: 794px;
+ padding: var(--sp-24) var(--sp-28);
+ background: var(--pr-bg);
+ color: var(--pr-ink);
+ display: flex;
+ flex-direction: column;
+ gap: var(--sp-9);
+ font-size: 16px;
+ line-height: 1.5;
+ font-weight: 400;
+ box-shadow: var(--dialog-shadow);
+ overflow-wrap: anywhere;
+}
+.pr-sheet--A5 {
+ max-width: 559px;
+ padding: var(--sp-16);
+}
+.pr-sheet--cheat {
+ padding: 44px 48px;
+ gap: var(--sp-7);
+ font-size: 15px;
+ line-height: 1.4;
+}
+
+.pr-runhead {
+ display: flex;
+ justify-content: space-between;
+ gap: var(--sp-8);
+ padding-bottom: var(--sp-5);
+ border-bottom: 1.5px solid var(--pr-ink);
+ font-size: 13px;
+}
+.pr-title {
+ font-size: 32px;
+ line-height: 1.15;
+ font-weight: 700;
+}
+.pr-summary {
+ margin-top: var(--sp-3);
+ font-size: 17px;
+ color: var(--pr-ink2);
+}
+
+/* ---------- Блоки статьи в печатном виде ---------- */
+.pr-body {
+ display: flex;
+ flex-direction: column;
+ gap: var(--sp-7);
+}
+.pr-body p {
+ margin: 0;
+}
+.pr-body .kb-b,
+.pr-body strong {
+ font-weight: 700;
+ color: var(--pr-ink);
+}
+.pr-body .kb-h2 {
+ margin: var(--sp-3) 0 0;
+ padding-top: var(--sp-5);
+ border-top: 1.5px solid var(--pr-ink);
+ font-size: 21px;
+ font-weight: 700;
+ break-after: avoid;
+}
+.pr-body .kb-h3 {
+ margin: 0;
+ font-size: 17px;
+ font-weight: 700;
+ color: var(--pr-ink);
+ break-after: avoid;
+}
+.pr-body > * {
+ break-inside: avoid;
+}
+.pr-body .kb-ulink {
+ font-weight: 700;
+ text-decoration: none;
+}
+
+/* Главное: сплошная рамка 2 px */
+.pr-body .kb-key {
+ border: 2px solid var(--pr-ink);
+ border-radius: var(--r-sm);
+ background: none;
+}
+.pr-body .kb-hazard {
+ display: none;
+}
+.pr-body .kb-key-head {
+ padding: var(--sp-3) var(--sp-6);
+ border-bottom: 1.5px solid var(--pr-ink);
+ background: repeating-linear-gradient(-45deg, var(--brand) 0 8px, var(--pr-bg) 8px 16px);
+ print-color-adjust: exact;
+ -webkit-print-color-adjust: exact;
+}
+.pr-body .kb-key-title {
+ font-size: 14px;
+ background: var(--pr-bg);
+ padding: 0 var(--sp-3);
+}
+.pr-body .kb-key-count {
+ display: none;
+}
+.pr-body .kb-key-grid {
+ gap: 0;
+ padding: 0;
+}
+.pr-body .kb-key-item {
+ padding: var(--sp-5) var(--sp-6);
+ border: 0;
+ border-bottom: 1px solid var(--pr-ln);
+ border-right: 1px solid var(--pr-ln);
+ border-radius: 0;
+ background: none;
+}
+.pr-body .kb-key-label {
+ font-size: 13px;
+ font-weight: 400;
+ color: var(--pr-ink3);
+}
+.pr-body .kb-key-val .kb-key-v {
+ font-size: 22px;
+ color: var(--pr-ink);
+}
+.pr-body .kb-key-val .kb-key-t {
+ font-size: 15px;
+ color: var(--pr-ink);
+}
+.pr-body .kb-key-item--wide .kb-key-val {
+ font-size: 16px;
+}
+.pr-body .kb-key-item--wide .kb-key-v {
+ font-size: 16px;
+}
+
+/* Плашки */
+.pr-body .kb-callout {
+ border-radius: var(--r-sm);
+ background: none;
+ padding: 0;
+ gap: 0;
+}
+.pr-body .kb-callout-icon {
+ display: none;
+}
+.pr-body .kb-callout-head {
+ min-height: 0;
+ padding: var(--sp-3) var(--sp-6);
+ font-size: 14px;
+ letter-spacing: var(--caps-xwide);
+ color: var(--pr-ink);
+ background: none;
+}
+.pr-body .kb-callout-body {
+ padding: var(--sp-5) var(--sp-6);
+ gap: var(--sp-3);
+}
+/* ЗАПРЕЩЕНО: рамка 3 px и красная шапка (в ч/б останется тёмной) */
+.pr-body .kb-danger {
+ border: 3px solid var(--pr-red);
+}
+.pr-body .kb-danger .kb-callout-head {
+ background: var(--pr-red);
+ color: var(--pr-bg);
+ print-color-adjust: exact;
+ -webkit-print-color-adjust: exact;
+}
+.pr-body .kb-danger .kb-callout-head::before {
+ content: '✕';
+}
+/* ВНИМАНИЕ: пунктирная рамка */
+.pr-body .kb-warning {
+ border: 2px dashed var(--pr-ink);
+}
+.pr-body .kb-warning .kb-callout-head {
+ border-bottom: 1.5px dashed var(--pr-ink);
+}
+.pr-body .kb-warning .kb-callout-head::before {
+ content: '▲';
+}
+.pr-body .kb-tip,
+.pr-body .kb-info {
+ border: 1px solid var(--pr-ink);
+}
+.pr-body .kb-tip .kb-callout-head,
+.pr-body .kb-info .kb-callout-head {
+ padding-bottom: 0;
+}
+
+/* Чек-лист: пустые квадраты под ручку */
+.pr-body .kb-check {
+ border: 0;
+ border-radius: 0;
+ background: none;
+ box-shadow: none;
+ display: flex;
+ flex-direction: column;
+ gap: var(--sp-4);
+ overflow: visible;
+ break-inside: auto;
+}
+.pr-body .kb-check-head,
+.pr-body .kb-check-bar {
+ display: none;
+}
+.pr-body .kb-check-row {
+ min-height: 0;
+ padding: 0;
+ border: 0;
+ gap: var(--sp-6);
+ font-size: inherit;
+ line-height: inherit;
+ color: var(--pr-ink);
+ break-inside: avoid;
+}
+.pr-body .kb-box,
+.pr-square {
+ flex: none;
+ width: 18px;
+ height: 18px;
+ margin-top: 3px;
+ border: 2px solid var(--pr-ink);
+ border-radius: 0;
+ background: none;
+}
+.pr-body .kb-check-row.is-on .kb-box {
+ background: none;
+ border-color: var(--pr-ink);
+}
+.pr-body .kb-check-row.is-on .kb-box::after {
+ display: none;
+}
+.pr-body .kb-check-row.is-on .kb-check-text {
+ opacity: 1;
+ text-decoration: none;
+}
+.pr-body .kb-check-text {
+ padding: 0;
+}
+
+/* Шаги: квадрат для отметки + номер в рамке */
+.pr-body .kb-steps {
+ gap: var(--sp-5);
+ break-inside: auto;
+}
+.pr-body .kb-step {
+ padding: 0;
+ border: 0;
+ background: none;
+ box-shadow: none;
+ gap: var(--sp-5);
+ break-inside: avoid;
+}
+.pr-body .kb-step::before {
+ content: '';
+ flex: none;
+ width: 18px;
+ height: 18px;
+ margin-top: 6px;
+ border: 2px solid var(--pr-ink);
+}
+.pr-body .kb-step-n {
+ width: 30px;
+ height: 30px;
+ border: 2px solid var(--pr-ink);
+ background: none;
+ color: var(--pr-ink);
+ font-size: 16px;
+}
+.pr-body .kb-step-title {
+ font-size: inherit;
+}
+
+/* Таблицы */
+.pr-body .kb-kv,
+.pr-body .kb-card {
+ border: 1px solid var(--pr-ink);
+ border-radius: var(--r-xs);
+ background: none;
+}
+.pr-body .kb-kv-head {
+ background: none;
+ color: var(--pr-ink);
+ border-bottom: 1.5px solid var(--pr-ink);
+ padding: var(--sp-3) var(--sp-6);
+}
+.pr-body .kb-kv-row {
+ min-height: 0;
+ padding: var(--sp-3) var(--sp-6);
+ border-top: 1px solid var(--pr-ln2);
+}
+.pr-body .kb-kv-v {
+ font-size: 16px;
+ color: var(--pr-ink);
+}
+.pr-body .kb-cards {
+ display: grid;
+ grid-template-columns: 1fr 1fr;
+ gap: var(--sp-4);
+ break-inside: auto;
+}
+.pr-body .kb-card {
+ padding: var(--sp-4) var(--sp-5);
+ gap: var(--sp-1);
+ font-size: 14px;
+ break-inside: avoid;
+}
+.pr-body .kb-card-label {
+ font-size: 12px;
+ color: var(--pr-ink3);
+}
+.pr-body .kb-card-val .kb-b {
+ font-size: inherit;
+}
+.pr-body .kb-ul > li::before {
+ background: var(--pr-ink);
+ margin-top: 8px;
+}
+
+/* Фото: по 2 в ряд, высота 220 px */
+.pr-body .kb-figs {
+ display: grid;
+ grid-template-columns: 1fr 1fr;
+ gap: var(--sp-7);
+ break-inside: auto;
+}
+.pr-body .kb-figs-grid {
+ display: contents;
+}
+.pr-body .kb-fig {
+ break-inside: avoid;
+}
+.pr-body .kb-fig-btn {
+ border: 1px solid var(--pr-ink);
+ border-radius: 0;
+ background: none;
+}
+.pr-body .kb-fig-img,
+.pr-body .kb-fig--first .kb-fig-img {
+ width: 100%;
+ height: 220px;
+ aspect-ratio: auto;
+ object-fit: cover;
+}
+.pr-body .kb-fig-zoom {
+ display: none;
+}
+.pr-body .kb-fig-cap,
+.pr-body .kb-fig--first .kb-fig-cap {
+ font-size: 14px;
+ color: var(--pr-ink);
+}
+.pr-body .kb-fig-miss,
+.pr-body .kb-fig--first .kb-fig-miss {
+ height: 220px;
+ aspect-ratio: auto;
+ background: repeating-linear-gradient(135deg, var(--pr-fill) 0 10px, var(--pr-bg) 10px 20px);
+ color: var(--pr-ink3);
+}
+
+/* Что включить */
+.pr-no-photos .kb-figs {
+ display: none;
+}
+.pr-no-checks .kb-check {
+ display: none;
+}
+.pr-key-only > *:not(.kb-key):not(.kb-danger) {
+ display: none;
+}
+
+/* Подвал с QR */
+.pr-foot {
+ display: flex;
+ align-items: center;
+ gap: var(--sp-8);
+ padding-top: var(--sp-6);
+ border-top: 1px solid var(--pr-ink);
+ font-size: 13px;
+ break-inside: avoid;
+}
+.pr-foot-text {
+ display: flex;
+ flex-direction: column;
+ line-height: 1.4;
+}
+.pr-qr {
+ flex: none;
+ display: block;
+ background: var(--pr-bg);
+}
+.pr-qr svg {
+ display: block;
+ width: 100%;
+ height: 100%;
+}
+
+/* ---------- Шпаргалка на один лист ---------- */
+.pr-cheat {
+ display: flex;
+ flex-direction: column;
+ gap: var(--sp-7);
+}
+.pr-cheat-head {
+ display: flex;
+ justify-content: space-between;
+ align-items: flex-end;
+ gap: var(--sp-6);
+ padding-bottom: var(--sp-4);
+ border-bottom: 2px solid var(--pr-ink);
+ font-size: 13px;
+}
+.pr-cheat-title {
+ font-size: 30px;
+ font-weight: 700;
+ line-height: 1;
+}
+.pr-cheat-grid {
+ display: grid;
+ grid-template-columns: 1.1fr 1fr;
+ gap: var(--sp-10);
+}
+.pr-cheat-right {
+ display: flex;
+ flex-direction: column;
+ gap: var(--sp-6);
+}
+.pr-caps {
+ font-size: 14px;
+ font-weight: 700;
+ letter-spacing: var(--caps-wide);
+ padding-bottom: var(--sp-2);
+ border-bottom: 1.5px solid var(--pr-ink);
+}
+.pr-fact {
+ display: grid;
+ grid-template-columns: 1fr auto;
+ gap: var(--sp-5);
+ align-items: baseline;
+ padding: 5px 0;
+ border-bottom: 1px solid var(--pr-ln2);
+}
+.pr-fact strong {
+ font-size: 16px;
+ white-space: nowrap;
+}
+.pr-colors {
+ display: grid;
+ grid-template-columns: 1fr 1fr;
+ gap: var(--sp-4);
+ margin-top: var(--sp-6);
+}
+.pr-color {
+ display: flex;
+ align-items: center;
+ gap: var(--sp-4);
+}
+.pr-swatch {
+ flex: none;
+ width: 28px;
+ height: 20px;
+ border: 1px solid var(--pr-ink);
+ print-color-adjust: exact;
+ -webkit-print-color-adjust: exact;
+}
+.pr-box {
+ border: 2px solid var(--pr-ink);
+}
+.pr-box--red {
+ border: 3px solid var(--pr-red);
+}
+.pr-box-head {
+ padding: 5px var(--sp-5);
+ border-bottom: 1.5px solid var(--pr-ink);
+ font-size: 14px;
+ font-weight: 700;
+ letter-spacing: var(--caps-xwide);
+}
+.pr-box--red .pr-box-head {
+ border: 0;
+ background: var(--pr-red);
+ color: var(--pr-bg);
+ print-color-adjust: exact;
+ -webkit-print-color-adjust: exact;
+}
+.pr-ban {
+ display: grid;
+ grid-template-columns: 24px 1fr;
+ gap: var(--sp-3);
+ padding: 5px var(--sp-5);
+ border-top: 1px solid var(--pr-ln2);
+}
+.pr-always {
+ display: flex;
+ gap: var(--sp-4);
+ padding: 5px var(--sp-5);
+}
+.pr-always .pr-square {
+ width: 16px;
+ height: 16px;
+ margin-top: 2px;
+}
+.pr-cheat-foot {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ gap: var(--sp-6);
+ padding-top: var(--sp-4);
+ border-top: 1px solid var(--pr-ink);
+ font-size: 13px;
+}
+
+@media (max-width: 700px) {
+ .pr-sheet,
+ .pr-sheet--cheat {
+ padding: var(--sp-10) var(--sp-8);
+ }
+ .pr-cheat-grid {
+ grid-template-columns: 1fr;
+ }
+ .pr-tools-info {
+ display: none;
+ }
+ .pr-tools {
+ justify-content: space-between;
+ }
+}
+
+/* ---------- Собственно печать ---------- */
+@media print {
+ html,
+ body {
+ background: var(--pr-bg) !important;
+ }
+ .pr-screen {
+ display: block;
+ padding: 0;
+ background: none;
+ min-height: 0;
+ }
+ .pr-tools,
+ .pr-runhead {
+ display: none;
+ }
+ .pr-sheet,
+ .pr-sheet--A5,
+ .pr-sheet--cheat {
+ max-width: none;
+ padding: 0;
+ box-shadow: none;
+ }
+ .pr-cheat-grid {
+ grid-template-columns: 1.1fr 1fr;
+ }
+}
diff --git a/apps/web/src/styles/tokens.css b/apps/web/src/styles/tokens.css
new file mode 100644
index 0000000..42d28ff
--- /dev/null
+++ b/apps/web/src/styles/tokens.css
@@ -0,0 +1,209 @@
+/*
+ * Дизайн-токены. ВСЕ цвета и размеры сайта заданы здесь, в компонентах только var(--…).
+ * Значения взяты из new_design/README.md («Design Tokens»).
+ * Тема переключается атрибутом data-theme на : dark (по умолчанию), light, sun.
+ */
+
+:root {
+ /* ---------- Цвета, одинаковые во всех темах ---------- */
+ --brand: #f5c400; /* жёлтый маркер бренда: шпаргалка, «Внимание», полосатая лента */
+ --brand-ink: #141414; /* текст и рамки на жёлтом */
+ --on-strong: #ffffff; /* текст на красной/зелёной плашке */
+ --scrim: rgba(0, 0, 0, 0.5);
+ --scrim-strong: rgba(0, 0, 0, 0.55);
+ --zoom-pill: rgba(0, 0, 0, 0.75);
+ --sheet-shadow: 0 -12px 40px rgba(0, 0, 0, 0.3);
+ --dialog-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
+
+ /* Плашки разделов */
+ --plq-yellow: #ffc400;
+ --plq-orange: #ff8a00;
+ --plq-blue: #4c8dff;
+ --plq-green: #2db45a;
+ --plq-ink-text: #111111;
+
+ /* Образцы цветов RAL для шпаргалки */
+ --ral-5017: #005387;
+ --ral-7024: #45494e;
+
+ /* Просмотрщик фото: всегда чёрный */
+ --lb-bg: #000000;
+ --lb-ink: #ffffff;
+ --lb-ink2: #bdbdbd;
+ --lb-ink3: #a8a8a8;
+ --lb-sf: #1a1a1a;
+ --lb-sf2: #262626;
+ --lb-ln: #444444;
+
+ /* Печать: всегда светлая и читается в ч/б */
+ --pr-bg: #ffffff;
+ --pr-ink: #000000;
+ --pr-ink2: #333333;
+ --pr-ink3: #444444;
+ --pr-ln: #999999;
+ --pr-ln2: #bbbbbb;
+ --pr-red: #b3001b;
+ --pr-fill: #f2f2f2;
+
+ /* ---------- Типографика ---------- */
+ --font: 'Onest Variable', 'Onest', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
+ --fs-12: 0.75rem;
+ --fs-13: 0.8125rem;
+ --fs-14: 0.875rem;
+ --fs-15: 0.9375rem;
+ --fs-16: 1rem;
+ --fs-17: 1.0625rem;
+ --fs-18: 1.125rem; /* основной текст */
+ --fs-19: 1.1875rem;
+ --fs-20: 1.25rem;
+ --fs-21: 1.3125rem;
+ --fs-22: 1.375rem; /* H2 */
+ --fs-23: 1.4375rem;
+ --fs-24: 1.5rem;
+ --fs-26: 1.625rem;
+ --fs-28: 1.75rem;
+ --fs-30: 1.875rem; /* H1 на телефоне */
+ --fs-32: 2rem;
+ --fs-36: 2.25rem;
+ --fs-40: 2.5rem; /* H1 на компьютере */
+ --lh-body: 1.6;
+ --lh-tight: 1.15;
+ --lh-snug: 1.3;
+ --lh-normal: 1.45;
+ --caps: 0.08em;
+ --caps-wide: 0.1em;
+ --caps-xwide: 0.12em;
+
+ /* ---------- Отступы (шаг 4) ---------- */
+ --sp-1: 2px;
+ --sp-2: 4px;
+ --sp-3: 6px;
+ --sp-4: 8px;
+ --sp-5: 10px;
+ --sp-6: 12px;
+ --sp-7: 14px;
+ --sp-8: 16px; /* поля экрана */
+ --sp-9: 18px;
+ --sp-10: 20px;
+ --sp-11: 22px;
+ --sp-12: 24px;
+ --sp-16: 32px;
+ --sp-20: 40px;
+ --sp-24: 48px;
+ --sp-28: 56px;
+ --sp-32: 64px;
+
+ /* ---------- Скругления ---------- */
+ --r-plaque: 3px;
+ --r-xs: 4px;
+ --r-tag: 6px;
+ --r-sm: 8px;
+ --r-md: 10px;
+ --r-btn: 12px;
+ --r-card: 14px;
+ --r-block: 16px;
+ --r-lg: 18px;
+ --r-sheet: 22px;
+ --r-pill: 999px;
+
+ /* ---------- Размеры элементов ---------- */
+ --tap: 48px; /* минимальная зона нажатия */
+ --tap-sm: 44px;
+ --h-field: 60px;
+ --h-btn: 56px;
+ --h-row: 64px;
+ --h-row-sm: 56px;
+ --h-chip: 40px;
+ --h-tabbar: 64px;
+ --w-sidebar: 300px;
+ --w-article: 720px;
+ --w-aside: 300px;
+ --focus-ring: 4px;
+
+ --t-fast: 0.15s ease;
+ --t-sheet: 0.24s ease;
+}
+
+/* ---------- Тёмная тема (по умолчанию) ---------- */
+:root,
+[data-theme='dark'] {
+ color-scheme: dark;
+ --bg: #0f1011;
+ --sf: #1a1b1d;
+ --sf2: #242528;
+ --ink: #f2f1ec;
+ --ink2: #c4c2bb;
+ --ln: #393b3f;
+ --acc: #ffcf4a;
+ --red: #ff8a8a;
+ --redS: #c81e32;
+ --redbg: #2e1215;
+ --amb: #ffd266;
+ --ambbg: #2b220c;
+ --ambln: #c99700;
+ --grn: #7ed89c;
+ --grnS: #24854a;
+ --grnbg: #112a1a;
+ --blu: #9ec1f7;
+ --blubg: #13203a;
+ --hl: #f5c400;
+ --wb: 400;
+ --ws: 700;
+ --bw: 1px;
+ --sh: none;
+}
+
+[data-theme='light'] {
+ color-scheme: light;
+ --bg: #eeede8;
+ --sf: #ffffff;
+ --sf2: #f5f4f0;
+ --ink: #141414;
+ --ink2: #45443f;
+ --ln: #d3d1c9;
+ --acc: #8a4b00;
+ --red: #a8001a;
+ --redS: #b3001b;
+ --redbg: #fbeaec;
+ --amb: #6b4500;
+ --ambbg: #fff4d6;
+ --ambln: #e0a800;
+ --grn: #14602f;
+ --grnS: #1b7a3d;
+ --grnbg: #e6f2e9;
+ --blu: #174a8f;
+ --blubg: #e8eef7;
+ --hl: #f5c400;
+ --wb: 400;
+ --ws: 700;
+ --bw: 1px;
+ --sh: 0 1px 2px rgba(20, 20, 20, 0.06), 0 4px 12px -6px rgba(20, 20, 20, 0.12);
+}
+
+/* «Солнце»: максимальный контраст для яркого света, жирнее текст и линии */
+[data-theme='sun'] {
+ color-scheme: light;
+ --bg: #ffffff;
+ --sf: #ffffff;
+ --sf2: #ffffff;
+ --ink: #000000;
+ --ink2: #111111;
+ --ln: #000000;
+ --acc: #6b3a00;
+ --red: #8c0000;
+ --redS: #a00000;
+ --redbg: #ffffff;
+ --amb: #3d2600;
+ --ambbg: #ffffff;
+ --ambln: #000000;
+ --grn: #004d1e;
+ --grnS: #006b2a;
+ --grnbg: #ffffff;
+ --blu: #00337a;
+ --blubg: #ffffff;
+ --hl: #ffd000;
+ --wb: 500;
+ --ws: 800;
+ --bw: 2px;
+ --sh: none;
+}
diff --git a/package.json b/package.json
index cec8c73..7371e67 100644
--- a/package.json
+++ b/package.json
@@ -32,6 +32,7 @@
"eslint": "^10.12.0",
"eslint-plugin-react-hooks": "^7.1.1",
"globals": "^17.13.0",
+ "playwright-core": "^1.63.0",
"prettier": "^3.9.9",
"typescript": "^5.9.0",
"typescript-eslint": "^8.71.0"
diff --git a/packages/md/src/cheatsheet.ts b/packages/md/src/cheatsheet.ts
index 0f344b8..a4acc1a 100644
--- a/packages/md/src/cheatsheet.ts
+++ b/packages/md/src/cheatsheet.ts
@@ -5,37 +5,10 @@
// Ничего не выдумываем: если раздела в статье нет, список будет пустым,
// а если структура совсем другая, экран покажет статью обычным рендером.
+import type { CheatColor, CheatLine, CheatSheet, Seg } from '@kb/shared';
import { type MdNode, parseMarkdown, plainText } from './parse.js';
-export interface Seg {
- t: string;
- bold?: boolean;
-}
-
-export interface CheatLine {
- /** Текст с выделением жирного. */
- segs: Seg[];
- /** Значение (для «Цифр»): «20 см». */
- value?: string;
- /** Статьи-источники: slug из [[...]]. */
- links: string[];
-}
-
-export interface CheatColor {
- /** «RAL 5017» */
- code: string;
- /** «Уголок фотоэлемента» */
- label: string;
-}
-
-export interface CheatSheet {
- bans: CheatLine[];
- facts: CheatLine[];
- colors: CheatColor[];
- always: CheatLine[];
- /** true, если нашёлся хотя бы один из разделов. */
- ok: boolean;
-}
+export type { CheatSheet, CheatLine, CheatColor, Seg };
function segsOf(nodes: MdNode[]): { segs: Seg[]; links: string[] } {
const segs: Seg[] = [];
diff --git a/packages/md/src/frontmatter.ts b/packages/md/src/frontmatter.ts
index 839c6e3..b66483c 100644
--- a/packages/md/src/frontmatter.ts
+++ b/packages/md/src/frontmatter.ts
@@ -48,7 +48,7 @@ function parseList(raw: string): string[] {
export function parseFrontMatter(src: string): { meta: FrontMatter; body: string } {
const meta: FrontMatter = { tags: [], equipment: [], source: [], pinned: false, extra: {} };
// Убираем BOM и приводим переводы строк к \n
- const text = src.replace(/^/, '').replace(/\r\n?/g, '\n');
+ const text = (src.charCodeAt(0) === 0xfeff ? src.slice(1) : src).replace(/\r\n?/g, '\n');
const m = text.match(/^---\n([\s\S]*?)\n---\n?/);
if (!m) return { meta, body: text };
diff --git a/packages/md/src/hast.ts b/packages/md/src/hast.ts
index f296e5c..859aebc 100644
--- a/packages/md/src/hast.ts
+++ b/packages/md/src/hast.ts
@@ -221,11 +221,32 @@ function itemInline(item: MdNode): MdNode[] {
return out;
}
+/**
+ * Делит абзац по переводам строк: в :::блоке каждая строка исходника становится
+ * отдельной строкой на экране (Markdown сам по себе склеил бы их в один абзац).
+ */
+function splitLines(nodes: MdNode[]): MdNode[][] {
+ const lines: MdNode[][] = [[]];
+ for (const n of nodes) {
+ if (n.type === 'break') {
+ lines.push([]);
+ } else if (n.type === 'text' && n.value?.includes('\n')) {
+ n.value.split('\n').forEach((part, i) => {
+ if (i > 0) lines.push([]);
+ if (part) lines.at(-1)!.push({ type: 'text', value: part });
+ });
+ } else {
+ lines.at(-1)!.push(n);
+ }
+ }
+ return lines.filter((l) => l.length);
+}
+
/** Строки внутри :::блока: каждый абзац и каждый пункт списка становится отдельной строкой. */
function directiveLines(node: MdNode): MdNode[][] {
const lines: MdNode[][] = [];
for (const c of node.children ?? []) {
- if (c.type === 'paragraph') lines.push(c.children ?? []);
+ if (c.type === 'paragraph') lines.push(...splitLines(c.children ?? []));
else if (c.type === 'list') for (const li of c.children ?? []) lines.push(itemInline(li));
else lines.push([{ type: 'text', value: plainText(c) }]);
}
diff --git a/packages/shared/src/index.ts b/packages/shared/src/index.ts
index 58e27eb..df5e96d 100644
--- a/packages/shared/src/index.ts
+++ b/packages/shared/src/index.ts
@@ -83,6 +83,10 @@ export interface ArticleDto extends ArticleListItem {
/** Адреса картинок статьи (полные и превью): нужны для офлайн-кеша. */
images: string[];
authorName: string | null;
+ /** Заголовки H2 для оглавления. */
+ toc: TocEntry[];
+ /** Разобранная шпаргалка (только у закреплённой статьи со структурой шпаргалки). */
+ cheat: CheatSheet | null;
}
/** Всё дерево одним запросом: его хватает для главной, меню и офлайна. */
@@ -165,8 +169,10 @@ export function normalizeSearch(s: string): string {
return s
.toLowerCase()
.replace(/ё/g, 'е')
- .replace(/[‐-―−]/g, '-')
- .replace(/[ ]/g, ' ')
+ // \p{Pd}: все виды тире и дефисов, плюс математический минус
+ .replace(/[\p{Pd}−]/gu, '-')
+ // \p{Zs}: все виды пробелов, включая неразрывный и узкий
+ .replace(/\p{Zs}/gu, ' ')
.replace(/\s+/g, ' ')
.trim();
}
@@ -188,3 +194,40 @@ export function shortTitle(title: string, sectionName?: string): string {
}
return t.charAt(0).toUpperCase() + t.slice(1);
}
+
+// ---------- Шпаргалка ----------
+
+export interface Seg {
+ t: string;
+ bold?: boolean;
+}
+
+export interface CheatLine {
+ /** Текст с выделением жирного. */
+ segs: Seg[];
+ /** Значение (для «Цифр»): «20 см». */
+ value?: string;
+ /** Статьи-источники: slug из [[...]]. */
+ links: string[];
+}
+
+export interface CheatColor {
+ /** «RAL 5017» */
+ code: string;
+ /** «Уголок фотоэлемента» */
+ label: string;
+}
+
+export interface CheatSheet {
+ bans: CheatLine[];
+ facts: CheatLine[];
+ colors: CheatColor[];
+ always: CheatLine[];
+ /** true, если нашёлся хотя бы один из разделов. */
+ ok: boolean;
+}
+
+export interface TocEntry {
+ id: string;
+ text: string;
+}
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 622550f..d2e3825 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -20,6 +20,9 @@ importers:
globals:
specifier: ^17.13.0
version: 17.13.0
+ playwright-core:
+ specifier: ^1.63.0
+ version: 1.63.0
prettier:
specifier: ^3.9.9
version: 3.9.9
@@ -117,6 +120,9 @@ importers:
'@tanstack/react-query':
specifier: ^5.104.1
version: 5.104.1(react@19.3.0)
+ qrcode-generator:
+ specifier: ^2.0.4
+ version: 2.0.4
react:
specifier: ^19.3.0
version: 19.3.0
@@ -3121,6 +3127,11 @@ packages:
pkg-types@2.3.3:
resolution: {integrity: sha512-j/lCFdcppV0JxWpCEITdbDltBxPP6cHT+yNJ6Go2OgoSA9518X847X9z0p6LtA4Nc16+eQzCZjRrWanTGvHJ5w==}
+ playwright-core@1.63.0:
+ resolution: {integrity: sha512-rYCsBF/M5HjUch52bbtVONEFjv6Xu8sm8h72dNlR5bzIE1fvC/bxgspzkjSfU+MweEMmPM8KJebG6nnyxo5mCg==}
+ engines: {node: '>=20'}
+ hasBin: true
+
possible-typed-array-names@1.1.0:
resolution: {integrity: sha512-/+5VFTchJDoVj3bhoqi6UeymcD00DAwb1nJwamzPvHEszJ4FpF6SNNbUbOS8yI56qHzdV8eK0qEfOSiodkTdxg==}
engines: {node: '>= 0.4'}
@@ -3192,6 +3203,9 @@ packages:
resolution: {integrity: sha512-+Owyggi9IxT1ePKGafcI87ubSmxol6smwJ+RAHDQlx9+9cPwFWDiKFFCPuWhr9ignlGpZ9vDQLw67N4dcTVFEA==}
engines: {node: '>=20'}
+ qrcode-generator@2.0.4:
+ resolution: {integrity: sha512-mZSiP6RnbHl4xL2Ap5HfkjLnmxfKcPWpWe/c+5XxCuetEenqmNFf1FH/ftXPCtFG5/TDobjsjz6sSNL0Sr8Z9g==}
+
qs@6.16.0:
resolution: {integrity: sha512-h6fhOIaRrID2CbEY2fqs+7t+UXZo+MLAnU5gRIq85uFtdiUPCdsApMlHhXogKVM4HM2DVbIjGNTTYH2OcmP1vA==}
engines: {node: '>=0.6'}
@@ -7021,6 +7035,8 @@ snapshots:
exsolve: 1.1.3
pathe: 2.0.3
+ playwright-core@1.63.0: {}
+
possible-typed-array-names@1.1.0: {}
postcss-load-config@6.0.1(jiti@2.7.0)(postcss@8.5.28)(tsx@4.23.15):
@@ -7069,6 +7085,8 @@ snapshots:
dependencies:
hookified: 2.2.0
+ qrcode-generator@2.0.4: {}
+
qs@6.16.0:
dependencies:
es-define-property: 1.0.1
diff --git a/scripts/check-layout.mjs b/scripts/check-layout.mjs
new file mode 100644
index 0000000..3cf338a
--- /dev/null
+++ b/scripts/check-layout.mjs
@@ -0,0 +1,70 @@
+// Проверка вёрстки: на телефонах страница не должна прокручиваться по горизонтали.
+// Запуск: node scripts/check-layout.mjs [адрес сайта] [папка для скриншотов]
+// Нужен установленный Chrome. Переменные KB_EMAIL / KB_PASSWORD: вход, если сайт закрыт.
+import { chromium } from 'playwright-core';
+import fs from 'node:fs';
+
+const base = process.argv[2] ?? 'http://localhost:8200';
+const shotsDir = process.argv[3];
+const devices = [
+ { name: 'iphone-se', width: 375, height: 667 },
+ { name: 'pixel-7', width: 412, height: 915 },
+ { name: 'desktop', width: 1440, height: 940 },
+];
+
+const browser = await chromium.launch({ channel: 'chrome' });
+let failed = 0;
+
+for (const d of devices) {
+ const ctx = await browser.newContext({
+ viewport: { width: d.width, height: d.height },
+ deviceScaleFactor: d.width < 500 ? 2 : 1,
+ isMobile: d.width < 500,
+ hasTouch: d.width < 500,
+ });
+ const page = await ctx.newPage();
+
+ if (process.env.KB_EMAIL) {
+ const res = await page.request.post(`${base}/api/auth/login`, {
+ headers: { 'X-Requested-With': 'kb' },
+ data: { email: process.env.KB_EMAIL, password: process.env.KB_PASSWORD, remember: false },
+ });
+ if (!res.ok()) throw new Error(`Не удалось войти: ${res.status()}`);
+ }
+
+ const tree = await (await page.request.get(`${base}/api/tree`)).json();
+ const paths = [
+ '/',
+ '/search?q=MG12',
+ '/cheatsheet',
+ '/favorites',
+ ...tree.sections.map((s) => `/s/${s.slug}`),
+ ...tree.articles.filter((a) => !a.pinned).map((a) => `/a/${a.slug}`),
+ ];
+
+ for (const p of paths) {
+ await page.goto(base + p, { waitUntil: 'networkidle' });
+ // Ширина содержимого больше ширины окна = есть горизонтальная прокрутка
+ const over = await page.evaluate(() => {
+ const w = document.documentElement.clientWidth;
+ const wide = [...document.querySelectorAll('body *')]
+ .filter((el) => el.getBoundingClientRect().right > w + 1 && !el.closest('.chips--scroll, .ed-toolbar'))
+ .slice(0, 3)
+ .map((el) => `${el.tagName.toLowerCase()}.${el.className}`);
+ return { scroll: document.documentElement.scrollWidth - w, wide };
+ });
+ const ok = over.scroll <= 0 && over.wide.length === 0;
+ if (!ok) failed++;
+ console.log(`${ok ? 'ok ' : 'FAIL'} ${d.name.padEnd(10)} ${p}${ok ? '' : ` (+${over.scroll}px: ${over.wide.join(', ')})`}`);
+ if (shotsDir) {
+ fs.mkdirSync(shotsDir, { recursive: true });
+ const name = p.replace(/[^a-z0-9]+/gi, '_').replace(/^_|_$/g, '') || 'home';
+ await page.screenshot({ path: `${shotsDir}/${d.name}-${name}.png`, fullPage: false });
+ }
+ }
+ await ctx.close();
+}
+
+await browser.close();
+console.log(failed ? `\nПроблем: ${failed}` : '\nГоризонтальной прокрутки нет');
+process.exit(failed ? 1 : 0);