/* app.css — читалка. Темы: light / sepia / dark. Оттенок уровня: data-level. */

:root {
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, "Charter", Georgia, "Times New Roman", serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --bg: #f7f4ee;
  --bg-elev: #ffffff;
  --fg: #1f1d1a;
  --fg-muted: #6f6a62;
  --line: rgba(0, 0, 0, 0.09);
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.14);
  --accent: #5b5650;
  --accent-soft: rgba(91, 86, 80, 0.12);
  --hl: rgba(255, 196, 0, 0.35);
  --hl-s: rgba(91, 86, 80, 0.10);
  --page-bg: #fbf9f4;
  --sheet-bg: #ffffff;
  --radius: 16px;
}

[data-theme="sepia"] {
  --bg: #efe6d2;
  --bg-elev: #f7f0e0;
  --fg: #3b2f22;
  --fg-muted: #7d6e5a;
  --line: rgba(60, 40, 10, 0.12);
  --page-bg: #f3ead7;
  --sheet-bg: #f9f3e5;
  --hl: rgba(255, 170, 0, 0.35);
}

[data-theme="dark"] {
  --bg: #121212;
  --bg-elev: #1c1c1e;
  --fg: #d9d6d0;
  --fg-muted: #8e8a83;
  --line: rgba(255, 255, 255, 0.10);
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.6);
  --page-bg: #151515;
  --sheet-bg: #1f1f21;
  --hl: rgba(255, 196, 0, 0.30);
  --hl-s: rgba(255, 255, 255, 0.08);
}

/* Оттенок уровня — акцент поверх темы */
[data-level="orig"] { --accent: #5b5650; --accent-soft: rgba(91, 86, 80, 0.14); }
[data-level="b2"]   { --accent: #4b5aa8; --accent-soft: rgba(75, 90, 168, 0.14); }
[data-level="b1"]   { --accent: #2f7f8a; --accent-soft: rgba(47, 127, 138, 0.14); }
[data-level="a2"]   { --accent: #b8742a; --accent-soft: rgba(184, 116, 42, 0.16); }
[data-level="a1"]   { --accent: #6f9a3a; --accent-soft: rgba(111, 154, 58, 0.16); }
[data-theme="dark"][data-level="orig"] { --accent: #a8a29a; }
[data-theme="dark"][data-level="b1"]   { --accent: #5fb8c4; }
[data-theme="dark"][data-level="a2"]   { --accent: #e0a05a; }

* { box-sizing: border-box; }
/* overscroll-behavior нужен и на html: «потяни вниз — обнови» в Chrome живёт
   на области просмотра, и значение с body до неё доходит не всегда. Тут же
   отключается и резиновый отскок в Safari. */
html, body { margin: 0; padding: 0; height: 100%; overscroll-behavior: none; }
body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--fg);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
.app { min-height: 100%; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
img { display: block; }

/* ---------------------------------------------------------------- Полка */
.lib { max-width: 980px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 20px) 20px 40px; }
.lib-title { font-size: 28px; font-weight: 700; letter-spacing: -0.01em; margin: 6px 0 18px; }
.lib-sub { color: var(--fg-muted); font-size: 14px; margin: -12px 0 20px; }
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 22px 18px; }
.card { display: block; }
.card-cover {
  aspect-ratio: 2 / 3; border-radius: 10px; overflow: hidden; background: var(--bg-elev);
  box-shadow: 0 6px 18px rgba(0,0,0,0.16), 0 1px 2px rgba(0,0,0,0.12);
  transition: transform .18s ease;
}
.card:active .card-cover { transform: scale(0.98); }
.card-cover img { width: 100%; height: 100%; object-fit: cover; }
.card-cover.placeholder { display: flex; align-items: flex-end; padding: 12px; font-family: var(--font-serif); font-size: 15px; color: var(--fg-muted); }
.card-title { font-weight: 600; font-size: 15px; margin: 10px 0 2px; line-height: 1.25; }
.card-author { color: var(--fg-muted); font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip {
  font-size: 11.5px; font-weight: 600; letter-spacing: 0.02em; padding: 3px 8px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
}
.chip[data-level="orig"] { --accent: #5b5650; --accent-soft: rgba(91, 86, 80, 0.14); }
.chip[data-level="b1"] { --accent: #2f7f8a; --accent-soft: rgba(47, 127, 138, 0.14); }
.chip[data-level="a2"] { --accent: #b8742a; --accent-soft: rgba(184, 116, 42, 0.16); }
.card-progress { margin-top: 6px; font-size: 12px; color: var(--fg-muted); }

/* ---------------------------------------------------------------- Книга */
.book { max-width: 720px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 8px) 20px 60px; }
.topnav { display: flex; align-items: center; gap: 8px; height: 44px; margin-bottom: 8px; }
.btn-icon {
  width: 40px; height: 40px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center;
  color: var(--fg); font-size: 20px;
}
.btn-icon:active { background: var(--accent-soft); }
.book-head { display: flex; gap: 18px; align-items: flex-start; }
.book-cover { width: 120px; flex: 0 0 120px; border-radius: 10px; overflow: hidden; box-shadow: 0 6px 18px rgba(0,0,0,0.18); }
.book-cover img { width: 100%; height: auto; }
.book-title { font-family: var(--font-serif); font-size: 24px; font-weight: 700; line-height: 1.15; margin: 4px 0 4px; }
.book-author { color: var(--fg-muted); font-size: 15px; }
.book-blurb { font-size: 15px; line-height: 1.5; margin: 14px 0 22px; color: var(--fg); }
/* Книга взята не целиком — сказано в скобках рядом с названием, и только */
.partial { display: block; color: var(--fg-muted); font-weight: 400; }
.book-title .partial { font-size: 0.58em; letter-spacing: 0.01em; margin-top: 3px; font-family: var(--font-ui); }
.card-title .partial { font-size: 12px; margin-top: 1px; }

.levels { display: grid; gap: 10px; margin-bottom: 18px; }
.level-opt {
  display: flex; align-items: center; gap: 14px; text-align: left; padding: 12px 14px; border-radius: 14px;
  background: var(--bg-elev); border: 2px solid transparent; box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}
.level-opt[aria-checked="true"] { border-color: var(--accent); background: var(--accent-soft); }
.level-opt[data-level="orig"] { --accent: #5b5650; --accent-soft: rgba(91, 86, 80, 0.10); }
.level-opt[data-level="b1"] { --accent: #2f7f8a; --accent-soft: rgba(47, 127, 138, 0.10); }
.level-opt[data-level="a2"] { --accent: #b8742a; --accent-soft: rgba(184, 116, 42, 0.12); }
.level-badge {
  width: 46px; height: 46px; border-radius: 12px; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; background: var(--accent); color: #fff; flex: 0 0 46px;
}
/* «Оригинал» словом в квадрат не влезает — пиктограмма книги */
.level-badge .ico { width: 24px; height: 24px; fill: currentColor; }
.level-opt-name { font-weight: 600; font-size: 15px; }
.level-opt-hint { font-size: 13px; color: var(--fg-muted); margin-top: 2px; line-height: 1.3; }

.btn-primary {
  display: block; width: 100%; padding: 15px; border-radius: 14px; text-align: center;
  background: var(--accent); color: #fff; font-weight: 600; font-size: 16px;
}
.btn-primary:active { filter: brightness(0.92); }
.btn-primary .sub { display: block; font-weight: 400; font-size: 12.5px; opacity: 0.85; margin-top: 2px; }
.btn-secondary { display: block; width: 100%; padding: 13px; border-radius: 14px; text-align: center; background: var(--accent-soft); color: var(--accent); font-weight: 600; margin-top: 10px; }

.toc { margin-top: 28px; }
.toc-h { font-size: 13px; font-weight: 600; color: var(--fg-muted); text-transform: uppercase; letter-spacing: 0.06em; margin: 0 0 8px; }
.toc-part { font-family: var(--font-serif); font-weight: 700; font-size: 15px; margin: 18px 0 6px; color: var(--fg); }
.toc-item {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 11px 6px;
  border-bottom: 1px solid var(--line);
}
.toc-item:active { background: var(--accent-soft); }
.toc-num { font-family: var(--font-serif); font-size: 16px; min-width: 44px; }
.toc-words { color: var(--fg-muted); font-size: 12px; margin-left: auto; white-space: nowrap; }
.toc-item .chips { margin: 0; }
.toc-item .chip { font-size: 10.5px; padding: 2px 6px; }
.toc-item.current { background: var(--accent-soft); border-radius: 10px; }

/* ---------------------------------------------------------------- Читалка */
/* touch-action: none живёт на сцене, а не на .reader: touch-action
   наследуется вниз, и запрет на предке отменял pan-y в шторке (текст не
   скроллился). Жесты листания слушает именно .rd-stage. */
/* overflow: clip, а не hidden — см. .rd-stage ниже. Две строки подряд: на
   Safari младше 16 вторая не понимается и остаётся прежнее hidden. */
.reader {
  position: fixed; inset: 0; background: var(--page-bg); color: var(--fg);
  overflow: hidden; overflow: clip;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
/* overflow: clip, а не hidden. `hidden` — это не «обрезать», а «обрезать и
   стать прокручиваемым контейнером»; WebKit засчитывает выступ содержимого
   ВВЕРХ в прокручиваемую область и сдвигает начало координат — текст опускался
   на 2px и стоял так, пока подсвечено слово в первой строке (Илья, iPhone,
   2026-09-05; Blink выступ вверх игнорирует, потому на десктопе не
   воспроизводилось). `clip` обрезает так же, но контейнер не прокручиваемый —
   сдвигать нечего. Две строки подряд: Safari младше 16 понимает только первую.
   padding — небольшой запас под краску, чтобы подсветка не упиралась в срез;
   он вычитается в paginator.layout(), поэтому top/bottom уменьшены на него. */
.rd-stage {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 44px + 10px);   /* высота постоянной панели + воздух */
  bottom: calc(env(safe-area-inset-bottom) + 26px);
  left: max(env(safe-area-inset-left), 22px);
  right: max(env(safe-area-inset-right), 22px);
  padding: 4px 0;
  overflow: hidden; overflow: clip; touch-action: none;
}
@media (min-width: 700px) {
  .rd-stage { left: max(env(safe-area-inset-left), 48px); right: max(env(safe-area-inset-right), 48px); top: 72px; bottom: 40px; }
}
@media (min-width: 1100px) {
  .rd-stage { left: calc((100vw - 1000px) / 2); right: calc((100vw - 1000px) / 2); }
}
.rd-content {
  font-family: var(--font-serif);
  font-size: var(--fs, 19px);
  line-height: 1.5;
  height: 100%;
  column-fill: auto;
  overflow: visible;
  transform: translate3d(0, 0, 0);
  will-change: transform;
  hyphens: auto; -webkit-hyphens: auto;
  text-align: justify;
  orphans: 2; widows: 2;
}
.rd-content.font-sans { font-family: var(--font-sans); line-height: 1.55; }
.rd-content.animate { transition: transform .28s cubic-bezier(.2,.7,.2,1); }
.rd-content p { margin: 0; text-indent: 1.4em; }
.rd-content h1 + p, .rd-content h2 + p, .rd-content h3 + p, .rd-content hr + p, .rd-content p:first-child { text-indent: 0; }
.rd-content p.quote { text-indent: 0; margin: 0.55em 1.2em 0.55em 1.6em; font-style: italic; }
.rd-content p.quote + p.quote { margin-top: 0; }
.rd-content p.quote em { font-style: normal; }
.rd-content h1, .rd-content h2, .rd-content h3 {
  font-weight: 400; text-align: center; letter-spacing: 0.06em; text-transform: uppercase;
  font-size: 1.05em; margin: 1.6em 0 2em; break-after: avoid; -webkit-column-break-after: avoid;
}
.rd-content h1 { font-size: 1.15em; }
.rd-content hr { border: 0; height: 1.8em; margin: 0; break-inside: avoid; }
.rd-content hr::after { content: ""; display: block; width: 3em; height: 1px; background: var(--fg-muted); opacity: 0.4; margin: 0.9em auto 0; }
.rd-content .w { cursor: pointer; border-radius: 3px; }
/* Подсветка не рисует наружу: box-shadow со спредом выступал за верхний край
   сцены на словах первой строки, и WebKit опускал из-за этого весь текст.
   Одного `overflow: clip` выше хватило бы, но причину лучше убрать саму —
   тогда и на Safari младше 16 всё в порядке. Разница на глаз — доли пикселя
   по вертикали, фон и скругление остались. */
.rd-content .w.hl { background: var(--hl); border-radius: 4px; }
.rd-content .s.hl-s { background: var(--hl-s); border-radius: 3px; }
.rd-content p.hl-p { background: var(--hl-s); border-radius: 4px; }
.rd-end { text-align: center; padding-top: 2.5em; text-indent: 0; break-before: avoid; }
.rd-end .rd-end-title { font-size: 0.85em; letter-spacing: 0.1em; text-transform: uppercase; color: var(--fg-muted); margin-bottom: 1.2em; }
.rd-end button {
  font-family: var(--font-ui); font-size: 15px; font-weight: 600; padding: 12px 20px; border-radius: 12px;
  background: var(--accent); color: #fff; margin: 6px; display: inline-block; text-indent: 0;
}
.rd-end button.ghost { background: var(--accent-soft); color: var(--accent); }

.rd-foot {
  position: absolute; left: 0; right: 0; bottom: calc(env(safe-area-inset-bottom) + 6px);
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font-ui); pointer-events: none;
}
/* Номер страницы — кнопка: за ней оглавление, поиск и переход по страницам */
.rd-page {
  pointer-events: auto; font-size: 11.5px; color: var(--fg-muted); letter-spacing: 0.02em;
  padding: 5px 12px; border-radius: 999px; background: var(--accent-soft);
  min-width: 62px; text-align: center;
}
.rd-page:active { background: var(--accent); color: #fff; }
.rd-back-jump {
  pointer-events: auto; font-size: 11.5px; padding: 5px 11px; border-radius: 999px;
  background: var(--accent); color: #fff; font-weight: 600; white-space: nowrap;
}
/* Скрытая сцена: в ней меряются страницы всех глав для сквозной нумерации */
/* opacity, а не visibility: скрытый текст всё равно должен честно вёрстаться,
   иначе getClientRects() вернёт пустоту и замер соврёт */
.rd-probe { position: absolute; left: -200vw; top: 0; width: 1px; height: 1px; overflow: hidden; opacity: 0; pointer-events: none; z-index: -1; }
/* Смена главы на месте — короткое затухание, чтобы подмена не выглядела рывком */
.rd-content.swap { opacity: 0; }
.rd-content { transition: opacity .14s ease; }
.rd-content p.flash { animation: flash 1.4s ease-out; }
@keyframes flash { from { background: var(--hl); } to { background: transparent; } }
.rd-progress { position: absolute; left: 0; bottom: 0; height: 2px; background: var(--accent); opacity: 0.55; width: 0; transition: width .2s; }

/* Верхняя панель — видна всегда: читатель не должен угадывать, где кнопки */
.rd-top {
  position: absolute; left: 0; right: 0; top: 0; padding: env(safe-area-inset-top) 6px 0;
  height: calc(env(safe-area-inset-top) + 44px); display: flex; align-items: center; gap: 2px;
  background: var(--page-bg); font-family: var(--font-ui); z-index: 4;
}
.rd-top .btn-icon { width: 36px; height: 36px; border-radius: 10px; }
.rd-top-title { flex: 1; min-width: 0; text-align: center; font-size: 13px; padding: 0 2px; }
.rd-top-title .t1 { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rd-top-title .t2 { font-size: 11px; color: var(--fg-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Значок уровня — кнопка «сменить уровень»: стрелка ▾ говорит, что он нажимается */
.pill {
  font-family: var(--font-ui); font-weight: 700; font-size: 12.5px; padding: 6px 9px 6px 11px; border-radius: 999px;
  background: var(--accent); color: #fff; letter-spacing: 0.03em; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 3px;
}
.pill .caret { font-size: 10px; opacity: 0.8; font-weight: 400; }
.pill .ico { width: 15px; height: 15px; fill: currentColor; display: block; }
.pill:active { filter: brightness(0.9); }

/* Пузырёк над словом */
.bubble {
  position: absolute; z-index: 5; max-width: min(320px, 86vw);
  background: var(--fg); color: var(--bg); font-family: var(--font-ui);
  padding: 8px 12px; border-radius: 12px; box-shadow: var(--shadow);
  font-size: 14.5px; line-height: 1.3; cursor: pointer; opacity: 0; transform: translateY(4px) scale(0.98);
  transition: opacity .12s ease, transform .12s ease; pointer-events: none;
}
.bubble.show { opacity: 1; transform: none; pointer-events: auto; }
.bubble .b-line { display: block; }
.bubble .b-word { font-weight: 600; opacity: 0.75; font-size: 12.5px; margin-right: 6px; }
.bubble .b-ru { font-weight: 500; }
.bubble .b-more { opacity: 0.6; margin-left: 8px; font-size: 12px; }
/* Вторая строка — значение слова вообще: контекстный перевод не должен
   подменять словарное значение (hand = «стрелка») */
.bubble .b-gen { display: block; margin-top: 3px; font-size: 12.5px; line-height: 1.25; opacity: 0.62; }
.bubble .b-gen .b-lab { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em; margin-right: 5px; opacity: 0.75; }
.bubble::after {
  content: ""; position: absolute; left: var(--arrow-x, 50%); bottom: -6px; width: 12px; height: 12px;
  background: var(--fg); transform: translateX(-50%) rotate(45deg); border-radius: 2px;
}
.bubble.below::after { bottom: auto; top: -6px; }
.bubble.muted { background: var(--bg-elev); color: var(--fg-muted); border: 1px solid var(--line); }
.bubble.muted::after { background: var(--bg-elev); border-left: 1px solid var(--line); border-top: 1px solid var(--line); }
.bubble.below.muted::after { border: 0; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }

/* Затемнение и шторка */
.scrim { position: absolute; inset: 0; background: rgba(0,0,0,0.18); opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 8; }
.scrim.show { opacity: 1; pointer-events: auto; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 9; font-family: var(--font-ui);
  background: var(--sheet-bg); color: var(--fg); border-radius: 18px 18px 0 0; box-shadow: var(--shadow);
  max-height: 88%; display: flex; flex-direction: column;
  transform: translateY(105%); transition: transform .26s cubic-bezier(.2,.7,.2,1);
  padding-bottom: env(safe-area-inset-bottom);
}
.sheet.show { transform: translateY(0); }
@media (min-width: 700px) { .sheet { left: 50%; right: auto; width: 560px; transform: translate(-50%, 105%); } .sheet.show { transform: translate(-50%, 0); } }
.sheet-handle { width: 36px; height: 4px; border-radius: 2px; background: var(--line); margin: 8px auto 4px; flex: 0 0 auto; }
/* За эти части шторку тянут пальцем — жест наш, браузеру его отдавать нельзя,
   иначе вместо шторки поедет страница (и сработает «потяни — обнови»).
   На саму .sheet ставить нельзя: touch-action запрещает и потомкам, а
   .sheet-body должен скроллиться. */
.sheet-handle, .sheet-head, .sheet-gloss, .sheet-title, .nav-page, .seg, .set-row,
.bubble, .scrim, .rd-top, .rd-foot { touch-action: none; }
.nav-slider { touch-action: none; }        /* ползунок тянут, а не скроллят */
/* Колонка внутри шторки: только .sheet-body тянется и скроллится,
   шапка и вкладки стоят на месте. Без этого длинный абзац обрезался. */
.sheet-inner { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.sheet.dragging { transition: none; }
.sheet-head { padding: 6px 18px 4px; flex: 0 0 auto; display: flex; align-items: baseline; gap: 10px; }
.sheet-head .h-word { font-family: var(--font-serif); font-size: 22px; font-weight: 600; }
.sheet-head .h-ru { font-size: 15px; color: var(--fg); }
.sheet-head .h-meta { font-size: 12px; color: var(--fg-muted); margin-left: auto; white-space: nowrap; }
/* «здесь» и «вообще»: подписи серым, без рамок */
.sheet-gloss { padding: 0 18px 8px; flex: 0 0 auto; }
.sheet-gloss .g-row { display: flex; gap: 8px; align-items: baseline; line-height: 1.35; margin-top: 2px; }
.sheet-gloss .g-lab { flex: 0 0 84px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--fg-muted); }
.sheet-gloss .g-val { font-size: 15px; }
.sheet-gloss .g-row + .g-row .g-val { font-size: 14px; color: var(--fg-muted); }
.sheet-body {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch; padding: 0 18px 18px; touch-action: pan-y;
  user-select: text; -webkit-user-select: text;
}
.seg[hidden] { display: none; }
.seg { display: flex; background: var(--accent-soft); border-radius: 10px; padding: 3px; margin: 4px 0 12px; flex: 0 0 auto; }
.seg button { flex: 1; padding: 7px; border-radius: 8px; font-size: 13.5px; font-weight: 600; color: var(--fg-muted); }
.seg button[aria-selected="true"] { background: var(--sheet-bg); color: var(--fg); box-shadow: 0 1px 3px rgba(0,0,0,0.12); }
.tr-en { font-family: var(--font-serif); font-size: 15px; line-height: 1.45; color: var(--fg-muted); margin: 0 0 8px; }
.tr-en .hl { background: var(--hl); border-radius: 3px; }
.tr-ru { font-size: 16px; line-height: 1.5; margin: 0 0 14px; }
.tr-none { font-size: 14px; color: var(--fg-muted); font-style: italic; margin: 0 0 14px; }
.lvl-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 4px 0 10px; }
.lvl-row .lab { font-size: 12.5px; color: var(--fg-muted); }
.lvl-btn {
  font-size: 12.5px; font-weight: 700; padding: 6px 11px; border-radius: 999px; background: var(--accent-soft); color: var(--accent);
}
.lvl-btn[data-level="orig"] { --accent: #5b5650; --accent-soft: rgba(91, 86, 80, 0.14); }
.lvl-btn[data-level="b1"] { --accent: #2f7f8a; --accent-soft: rgba(47, 127, 138, 0.14); }
.lvl-btn[data-level="a2"] { --accent: #b8742a; --accent-soft: rgba(184, 116, 42, 0.16); }
.lvl-btn[aria-pressed="true"] { background: var(--accent); color: #fff; }
.alt-text { font-family: var(--font-serif); font-size: 16px; line-height: 1.5; padding: 10px 12px; border-radius: 12px; background: var(--accent-soft); margin: 0 0 12px; }
.alt-text .dim { opacity: 0.55; }
.alt-text .match { opacity: 1; background: var(--hl); border-radius: 3px; }
.alt-text .alt-p + .alt-p { margin-top: 0.5em; }
.sheet .note { font-size: 13px; color: var(--fg-muted); line-height: 1.4; }

/* Шторка навигации: страница, оглавление, поиск */
.nav-page { padding: 0 18px 6px; flex: 0 0 auto; }
.nav-page-lab { display: flex; justify-content: space-between; align-items: baseline; font-size: 12.5px; color: var(--fg-muted); margin-bottom: 2px; }
.nav-page-lab .nv-now { color: var(--fg); font-weight: 600; }
.nav-slider { width: 100%; margin: 2px 0 4px; accent-color: var(--accent); height: 26px; }
.nav-body { padding-top: 2px; }
.nav-note { margin: 14px 0 0; }
.toc-list { padding-bottom: 4px; }
.toc-row {
  display: flex; align-items: baseline; gap: 10px; width: 100%; text-align: left;
  padding: 11px 4px; border-bottom: 1px solid var(--line); font-size: 15px;
}
.toc-row:last-child { border-bottom: 0; }
.toc-row.current { background: var(--accent-soft); border-radius: 10px; font-weight: 600; }
.toc-row[disabled] { opacity: 0.45; }
.toc-row .toc-name { font-family: var(--font-serif); }
.toc-row .toc-note { font-size: 11.5px; color: var(--fg-muted); }
.toc-row .toc-w { margin-left: auto; font-size: 12px; color: var(--fg-muted); white-space: nowrap; }
.find-q {
  width: 100%; font: inherit; font-size: 16px; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg-elev); color: var(--fg); -webkit-appearance: none;
}
.find-q:focus { outline: none; border-color: var(--accent); }
.find .note { margin: 6px 0 4px; }
.find-row {
  display: block; width: 100%; text-align: left; padding: 9px 4px;
  border-bottom: 1px solid var(--line);
}
.find-row:last-child { border-bottom: 0; }
.find-row .find-ch { display: block; font-size: 11.5px; color: var(--fg-muted); margin-bottom: 2px; }
.find-row .find-txt { display: block; font-size: 14.5px; line-height: 1.4; }
.find-row .find-txt[lang="en"] { font-family: var(--font-serif); }
.find-row mark { background: var(--hl); color: inherit; border-radius: 3px; padding: 0 1px; }

/* Шторка уровней и настроек */
.sheet-title { font-weight: 700; font-size: 16px; padding: 4px 18px 10px; flex: 0 0 auto; }
.opt-list { padding: 0 12px 10px; overflow-y: auto; min-height: 0; touch-action: pan-y; }
.opt-list .level-opt { margin-bottom: 8px; }
.set-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 18px; border-bottom: 1px solid var(--line); }
.set-row:last-child { border-bottom: 0; }
.set-lab { font-size: 15px; }
.set-ctl { display: flex; gap: 6px; }
.set-btn { padding: 8px 14px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); font-weight: 600; font-size: 14px; }
.set-btn[aria-pressed="true"] { background: var(--accent); color: #fff; }
.set-btn.big { font-size: 18px; min-width: 48px; }
.theme-dot { width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--line); }
.theme-dot[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }

/* Тост */
.toast {
  position: absolute; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 44px); transform: translateX(-50%) translateY(10px);
  background: var(--fg); color: var(--bg); font-family: var(--font-ui); font-size: 13.5px; padding: 9px 14px; border-radius: 10px;
  opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; z-index: 20; white-space: nowrap; max-width: 90vw; overflow: hidden; text-overflow: ellipsis;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--fg-muted); font-family: var(--font-ui); font-size: 14px; }
