/* Тема — из Telegram.WebApp.themeParams: JS телеграма выставляет --tg-theme-* на :root. */
:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --bg2: var(--tg-theme-secondary-bg-color, #f2f3f5);
  --text: var(--tg-theme-text-color, #111111);
  --hint: var(--tg-theme-hint-color, #6b7280);
  --link: var(--tg-theme-link-color, #2563eb);
  --accent: var(--tg-theme-button-color, #2563eb);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  color-scheme: light dark;
}
:root[data-theme="dark"] {
  --bg: var(--tg-theme-bg-color, #17212b);
  --bg2: var(--tg-theme-secondary-bg-color, #232e3c);
  --text: var(--tg-theme-text-color, #f5f5f5);
  --hint: var(--tg-theme-hint-color, #8fa1b3);
  --link: var(--tg-theme-link-color, #6ab3f3);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
.page { max-width: 40rem; margin: 0 auto; padding: 1rem 1rem 2rem; }
.page.center { min-height: 80vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; }
h1 { font-size: 1.4rem; margin: .5rem 0; }
h2 { font-size: 1.05rem; margin: 0 0 .5rem; }
.muted, .meta { color: var(--hint); }
.meta { font-size: .85rem; }
.hint { color: var(--hint); font-size: .9rem; margin: .5rem 0 0; }
.lead { font-size: 1.1rem; }
.card { background: var(--bg2); border-radius: .9rem; padding: .9rem 1rem; margin: 1rem 0; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: .5rem 0; border-top: 1px solid rgba(128,128,128,.2); }
.list li:first-child { border-top: 0; }
.item-title { font-weight: 600; }
.nav { display: flex; flex-direction: column; gap: .4rem; }
.nav-item { display: flex; justify-content: space-between; align-items: center;
  padding: .6rem .8rem; border-radius: .7rem; background: var(--bg);
  color: var(--text); text-decoration: none; }
.badge { font-size: .75rem; color: var(--accent-text); background: var(--accent);
  border-radius: .5rem; padding: .1rem .5rem; }
.link { color: var(--link); text-decoration: none; }
.foot { text-align: center; color: var(--hint); font-size: .8rem; padding: 1rem; }
/* --- библиотека --- */
input[type=text], input[type=search], select { width: 100%; padding: .5rem .7rem; border: 1px solid rgba(128,128,128,.35);
  border-radius: .6rem; font-size: 1rem; background: var(--bg); color: var(--text); }
button { padding: .5rem .9rem; border: 0; border-radius: .6rem; background: var(--accent); color: var(--accent-text);
  font-size: .95rem; cursor: pointer; }
button.small { padding: .25rem .6rem; font-size: .8rem; }
button.danger { background: #c0392b; color: #fff; }
.filters { display: flex; flex-direction: column; gap: .4rem; margin: .5rem 0 1rem; }
.stack { display: flex; flex-direction: column; gap: .5rem; }
.stack label { display: flex; flex-direction: column; gap: .2rem; font-size: .9rem; color: var(--hint); }
.check { display: flex; gap: .5rem; align-items: center; color: var(--text) !important; flex-direction: row !important; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.inline { display: inline; margin: 0; }
.actions { display: flex; gap: .6rem; flex-wrap: wrap; }
.notice { background: var(--bg2); border-radius: .6rem; padding: .5rem .8rem; }
.notice.error { color: #c0392b; }
.notice.warn { color: #b7791f; }
.badge-parsed { background: #2e8b57; } .badge-failed { background: #c0392b; } .badge-queued, .badge-parsing { background: #b7791f; }
.nav-item.big { font-size: 1.1rem; font-weight: 600; }
.chapters li { padding-left: calc(var(--depth, 0) * .8rem); }
.chapters li.excluded .item-title { color: var(--hint); text-decoration: line-through; }
.chapter-row { display: flex; justify-content: space-between; gap: .5rem; align-items: center; }
.chapter-row .item-title { color: var(--link); text-decoration: none; }
.pager { display: flex; justify-content: space-between; margin: .8rem 0; }
.chapter-text { line-height: 1.6; }
.chapter-text p { margin: 0 0 .8rem; white-space: pre-line; }
.segment.chunk { border-left: 3px solid var(--accent); padding-left: .7rem; margin: 1rem 0; }
.chunk-label { font-size: .75rem; color: var(--hint); margin-bottom: .4rem; }
.chapter-text p.note { background: var(--bg2); border-radius: .5rem; padding: .4rem .6rem; font-size: .9rem; }
.note-mark { font-size: .7rem; text-transform: uppercase; color: var(--hint); }
.cards .item-title { color: var(--link); text-decoration: none; font-weight: 600; }
