/* =====================================================================
   Каталог книг МСЦ ЕХБ — оформление v2
   Современные возможности (container queries, :has, view transitions,
   scroll-driven animations, @starting-style) подключены как «улучшения»:
   в старых браузерах сайт выглядит проще, но ничего не ломается.
   ===================================================================== */

/* ---------- цвета и размеры ---------- */
:root {
  color-scheme: light dark;
  --bg: #F5F0E6;
  --surface: #FFFDF8;
  --surface-2: #EFE8DB;
  --ink: #1E1A16;
  --ink-2: #3D362F;
  --muted: #5E554B;
  --line: #E3DACB;
  --line-2: #D6CAB6;
  --accent: #B8501F;
  --accent-ink: #FFFFFF;
  --link: #9A4318;
  --link-hover: #6E2E0F;
  --ok-bg: #E4F1E8; --ok-ink: #1F5133;
  --err-bg: #FBE6E2; --err-ink: #8A2419;
  --warn-bg: #FFF1CF; --warn-ink: #6B3A00;
  --shadow: 0 1px 0 rgb(0 0 0 / .06), 0 14px 28px -14px rgb(40 25 10 / .45);
  --shadow-lg: 0 1px 0 rgb(0 0 0 / .08), 0 30px 50px -22px rgb(40 25 10 / .55);
  --radius: 14px;
  --serif: "Literata", "PT Serif", Georgia, "Times New Roman", serif;
  --sans: "Golos Text", "PT Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --wrap: 1320px;
  --pad: clamp(16px, 4vw, 64px);

  /* цвета разделов: --tc — обложка, --tf — текст метки */
  --lib: #2E5E4E;  --lib-f: #2E5E4E;
  --min: #27466F;  --min-f: #27466F;
  --edif: #7A4E12; --edif-f: #7A4E12;
  --false: #8E2A24; --false-f: #8E2A24;
  --neg: #4A433C;  --neg-f: #4A433C;
  --none: #5E554B; --none-f: #5E554B;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16130F; --surface: #211D18; --surface-2: #2A251F;
    --ink: #F1E9DC; --ink-2: #DDD3C4; --muted: #B3A796; --line: #3A332B; --line-2: #4A4238;
    --link: #F0A070; --link-hover: #FFC49C;
    --ok-bg: #173424; --ok-ink: #BFE5CB; --err-bg: #3D1A15; --err-ink: #FFC3B8; --warn-bg: #3A2A0B; --warn-ink: #FFDF9E;
    --shadow: 0 1px 0 rgb(0 0 0 / .4), 0 14px 28px -14px rgb(0 0 0 / .8);
    --shadow-lg: 0 30px 50px -22px rgb(0 0 0 / .9);
    --lib-f: #86C7AE; --min-f: #9DBBE6; --edif-f: #E3B26B; --false-f: #F09A90; --neg-f: #C9BDAE; --none-f: #B3A796;
  }
}
:root[data-theme="dark"] {
  --bg: #16130F; --surface: #211D18; --surface-2: #2A251F;
  --ink: #F1E9DC; --ink-2: #DDD3C4; --muted: #B3A796; --line: #3A332B; --line-2: #4A4238;
  --link: #F0A070; --link-hover: #FFC49C;
  --ok-bg: #173424; --ok-ink: #BFE5CB; --err-bg: #3D1A15; --err-ink: #FFC3B8; --warn-bg: #3A2A0B; --warn-ink: #FFDF9E;
  --shadow: 0 1px 0 rgb(0 0 0 / .4), 0 14px 28px -14px rgb(0 0 0 / .8);
  --shadow-lg: 0 30px 50px -22px rgb(0 0 0 / .9);
  --lib-f: #86C7AE; --min-f: #9DBBE6; --edif-f: #E3B26B; --false-f: #F09A90; --neg-f: #C9BDAE; --none-f: #B3A796;
  color-scheme: dark;
}
:root[data-theme="light"] { color-scheme: light; }

[data-type="lib"]   { --tc: var(--lib);   --tf: var(--lib-f); }
[data-type="min"]   { --tc: var(--min);   --tf: var(--min-f); }
[data-type="edif"]  { --tc: var(--edif);  --tf: var(--edif-f); }
[data-type="false"] { --tc: var(--false); --tf: var(--false-f); }
[data-type="neg"]   { --tc: var(--neg);   --tf: var(--neg-f); }
[data-type="none"]  { --tc: var(--none);  --tf: var(--none-f); }

/* ---------- основа ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 88px; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  background: var(--bg); color: var(--ink);
  font: 400 16px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}
main { flex: 1 0 auto; }
img, svg { display: block; max-width: 100%; }
a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-hover); }
h1, h2, h3 { text-wrap: balance; }
p, li, dd { text-wrap: pretty; }
button, input, select, textarea { font: inherit; color: inherit; }
search { display: block; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.i { flex-shrink: 0; }
.wrap { width: 100%; max-width: var(--wrap); margin-inline: auto; padding-inline: var(--pad); }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 8px; top: -60px; z-index: 100; background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 8px; }
.skip:focus { top: 8px; color: var(--bg); }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 14px; }
.js .nojs-only { display: none; }

/* ---------- кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 44px; padding: 0 20px; border-radius: 12px;
  border: 1.5px solid var(--line-2); background: var(--surface); color: var(--ink);
  font-weight: 600; font-size: 15px; cursor: pointer; text-align: center;
  transition: background .15s, border-color .15s, transform .15s, color .15s;
}
.btn:hover { border-color: var(--ink); color: var(--ink); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: #9E4317; border-color: #9E4317; color: #fff; }
.btn-outline { background: transparent; border-color: var(--ink); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); border-color: transparent; }
.btn-danger { background: #A3291D; border-color: #A3291D; color: #fff; }
.btn-danger:hover { background: #7F1F15; color: #fff; }
.btn-danger-ghost { background: transparent; border-color: transparent; color: var(--err-ink); }
.btn-danger-ghost:hover { background: var(--err-bg); border-color: transparent; color: var(--err-ink); }
.btn-lg { min-height: 54px; padding: 0 26px; font-size: 16px; border-radius: 14px; }
.btn-small { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn-block { width: 100%; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer;
}
.icon-btn:hover { border-color: var(--ink-2); color: var(--ink); }
.linkish { background: none; border: 0; padding: 0; cursor: pointer; color: inherit; display: inline-flex; align-items: center; gap: 6px; }
form.inline { display: inline; margin: 0; }
.kbd { font: 500 12px var(--sans); color: var(--muted); border: 1px solid var(--line-2); border-radius: 6px; padding: 1px 7px; }

/* ---------- шапка ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(12px); backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
@supports not (background: color-mix(in srgb, red 50%, blue)) { .topbar { background: var(--surface); } }
.topbar-in { min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: flex; align-items: center; gap: 12px; color: var(--ink); }
.brand:hover { color: var(--ink); }
.brand-mark { font: 700 26px/1 var(--serif); color: var(--accent); letter-spacing: -.02em; }
.brand-mark.big { font-size: 44px; margin: 0 0 8px; text-align: center; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text b { font-size: 16px; }
.brand-text small { font-size: 13px; color: var(--muted); }
.nav { display: flex; align-items: center; gap: clamp(6px, 2vw, 28px); font-size: 15px; }
.nav > a, .nav .linkish { color: var(--muted); display: inline-flex; align-items: center; gap: 6px; padding: 10px 2px; border-bottom: 2px solid transparent; }
.nav > a:hover, .nav .linkish:hover { color: var(--ink); }
.nav > a[aria-current="page"] { color: var(--ink); font-weight: 600; border-bottom-color: var(--accent); }
.nav-admin { color: var(--link) !important; }
@media (max-width: 720px) {
  .brand-text small { display: none; }
  .topbar:not(.topbar-admin) .nav > a:not(.icon-btn):not(.nav-admin) { display: none; } /* на телефоне — только значки; логотип ведёт в каталог */
  .topbar-admin .nav span { display: none; }
  .topbar-admin .nav { gap: 4px; }
  .topbar-admin .nav > a, .topbar-admin .nav .linkish { padding: 10px; }
}
/* тень у шапки появляется при прокрутке — чистый CSS (scroll-driven animations) */
@supports (animation-timeline: scroll()) {
  @keyframes lift { to { box-shadow: 0 6px 24px -12px rgb(40 25 10 / .35); } }
  .topbar { animation: lift linear both; animation-timeline: scroll(); animation-range: 0 120px; }
}

/* ---------- каталог: заголовок и поиск ---------- */
.hero { padding-block: clamp(32px, 7vw, 72px) 28px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.eyebrow { margin: 0; font-size: 13px; letter-spacing: .12em; text-transform: uppercase; color: var(--link); font-weight: 600; }
.hero-title { margin: 0; font: 700 clamp(34px, 5.4vw, 60px)/1.06 var(--serif); letter-spacing: -.015em; max-width: 20ch; }
.hero-lead { margin: 0; font-size: clamp(16px, 1.6vw, 19px); color: var(--muted); max-width: 60ch; }
.search { margin-top: 14px; max-width: 980px; }
.search-form { display: flex; gap: 10px; }
.search-field {
  flex: 1; display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 0 18px;
  background: var(--surface); border: 1.5px solid var(--line-2); border-radius: 16px; color: var(--muted);
  transition: border-color .15s, box-shadow .15s;
}
.search-field:has(input:focus-visible) { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent); }
.search-field input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font-size: 17px; color: var(--ink); }
.search-field input::placeholder { color: color-mix(in srgb, var(--muted) 85%, transparent); }
.search-field.small { min-height: 44px; border-radius: 12px; }
.search-field.small input { font-size: 15px; }
@media (max-width: 600px) { .search-form .btn { display: none; } .kbd { display: none; } .search-field { min-height: 54px; } }

/* ---------- фильтры ---------- */
.filters { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; padding-bottom: 20px; }
.chips {
  display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-block: 4px;
  scroll-snap-type: x proximity; margin-inline: calc(var(--pad) * -1); padding-inline: var(--pad);
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  scroll-snap-align: start; flex-shrink: 0;
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 16px;
  border-radius: 999px; border: 1.5px solid var(--line-2); background: var(--surface);
  color: var(--ink); font-weight: 600; font-size: 15px; white-space: nowrap;
}
.chip:hover { color: var(--ink); border-color: var(--tc, var(--ink)); }
.chip .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--tc, var(--ink)); }
.chip-n { font-weight: 500; opacity: .7; font-variant-numeric: tabular-nums; }
.chip[aria-current="true"] { background: var(--tc, var(--ink)); border-color: var(--tc, var(--ink)); color: #fff; }
.chip[aria-current="true"] .dot { background: #fff; }
:root[data-theme="dark"] .chip:not([data-type])[aria-current="true"] { color: var(--bg); }
.toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px 24px; flex-wrap: wrap;
  padding-top: 16px; border-top: 1px solid var(--line);
}
.letters { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; font: 500 15px var(--serif); max-width: 100%; }
.letters::-webkit-scrollbar { display: none; }
.letters a { min-width: 32px; height: 36px; display: grid; place-items: center; border-radius: 8px; color: var(--ink-2); flex-shrink: 0; }
.letters a:hover { background: var(--surface-2); color: var(--ink); }
.letters a[aria-current="true"] { background: var(--ink); color: var(--bg); }
.toolbar-right { flex-wrap: wrap; display: flex; align-items: center; gap: 16px; font-size: 14px; color: var(--muted); }
.found { margin: 0; }
.found b { color: var(--ink); font-variant-numeric: tabular-nums; }
.select { display: flex; align-items: center; gap: 8px; }
.select select, .field select {
  min-height: 40px; padding: 0 34px 0 12px; border: 1px solid var(--line-2); border-radius: 10px; background: var(--surface);
  appearance: none; background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 17px) 55%, calc(100% - 12px) 55%; background-size: 5px 5px; background-repeat: no-repeat;
}

/* ---------- сетка книг ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(46%, 180px), 1fr)); gap: clamp(28px, 3vw, 40px) clamp(16px, 2vw, 28px); padding-block: 12px 8px; }
.card {
  display: flex; flex-direction: column; gap: 14px; min-width: 0;
  content-visibility: auto; contain-intrinsic-size: auto 440px; /* браузер не рисует книги за пределами экрана */
}
.card[data-over] { display: none; }
.card-cover { display: block; color: inherit; }
.card-body, .toolbar > * { min-width: 0; }
.card-cover .cover { transition: transform .25s cubic-bezier(.2,.8,.2,1), box-shadow .25s; }
.card:hover .card-cover .cover { transform: translateY(-4px) rotate(-.6deg); box-shadow: var(--shadow-lg); }
.card-body { display: flex; flex-direction: column; gap: 5px; }
.card-title { margin: 0; font: 600 17px/1.3 var(--serif); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card-title a { color: var(--ink); }
.card-title a:hover { color: var(--link); }
.card-title a::after { content: ""; position: absolute; inset: 0; } /* вся карточка кликабельна */
.card { position: relative; }
.card-author { margin: 0; font-size: 14px; color: var(--ink-2); }
.card-meta { margin: 0; font-size: 13px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-meta:empty { display: none; }
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--tf); }
.badge .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--tc); }

/* ---------- обложки ---------- */
.cover {
  position: relative; aspect-ratio: 2 / 3; border-radius: 3px 10px 10px 3px; overflow: hidden;
  background: var(--tc, var(--none)); box-shadow: var(--shadow);
  container-type: inline-size; /* размер текста на обложке зависит от её ширины */
}
.cover::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 6%; background: rgb(0 0 0 / .22); z-index: 1; }
.cover::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgb(255 255 255 / .08), transparent 12%, transparent 88%, rgb(0 0 0 / .08)); pointer-events: none; z-index: 1; }
.cover img { width: 100%; height: 100%; object-fit: cover; background: var(--surface-2); }
.gen {
  position: absolute; inset: 7% 7% 7% 13%; border: 1px solid rgb(255 255 255 / .35); border-radius: 3px;
  padding: 11% 9%; display: flex; flex-direction: column; justify-content: space-between; color: #fff;
}
.gen-title {
  font: 600 16px/1.2 var(--serif); font-size: clamp(11px, 9.2cqi, 32px);
  display: -webkit-box; -webkit-line-clamp: 7; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: break-word; hyphens: auto;
}
.gen-foot { display: flex; flex-direction: column; gap: 8px; }
.gen-rule { width: 18%; height: 1px; background: rgb(255 255 255 / .6); }
.gen-author { font-size: 13px; font-size: clamp(10px, 7cqi, 17px); opacity: .92; line-height: 1.25; }
.warn-strip {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 2; display: flex; align-items: center; gap: 6px;
  padding: 7px 10px 7px 12%; background: var(--warn-bg); color: var(--warn-ink); font-size: 12px; font-weight: 600;
}
.cover-mini { width: 56px; flex-shrink: 0; border-radius: 2px 6px 6px 2px; }
.cover-mini .gen { inset: 8% 8% 8% 16%; padding: 8% 6%; border: 0; }
.cover-mini .gen-title { -webkit-line-clamp: 4; font-size: 7px; }
.cover-mini .gen-foot, .cover-mini .warn-strip { display: none; }

/* ---------- пусто / ещё ---------- */
.empty { text-align: center; padding: 64px 16px; color: var(--muted); display: grid; justify-items: center; gap: 8px; }
.empty h2 { margin: 8px 0 0; font: 600 24px var(--serif); color: var(--ink); }
.empty p { margin: 0 0 12px; }
.more { display: flex; justify-content: center; padding-top: 48px; }

/* ---------- страница книги ---------- */
.crumbs { display: flex; align-items: center; gap: 10px; padding-block: 24px 0; font-size: 14px; color: var(--muted); }
.crumbs a { display: inline-flex; align-items: center; gap: 6px; }
.book {
  display: grid; grid-template-columns: minmax(200px, 360px) minmax(0, 1fr); gap: clamp(28px, 6vw, 80px);
  align-items: start; padding-block: 28px 16px;
}
.book-cover { position: sticky; top: 96px; }
.book-cover .cover { box-shadow: var(--shadow-lg); view-transition-name: cover; }
.book-info { display: flex; flex-direction: column; gap: 22px; max-width: 760px; }
.book-info > .badge { font-size: 13px; }
.book-title { margin: -8px 0 0; font: 700 clamp(30px, 4vw, 50px)/1.1 var(--serif); letter-spacing: -.01em; }
.book-author { margin: -8px 0 0; font-size: 20px; font-weight: 500; }
.caution { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 12px; background: var(--warn-bg); color: var(--warn-ink); }
.facts { margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); border-block: 1px solid var(--line); }
.facts > div { padding: 16px 0 16px 20px; border-left: 1px solid var(--line); display: grid; gap: 2px; }
.facts > div:first-child { padding-left: 0; border-left: 0; }
.facts dt { font-size: 13px; color: var(--muted); }
.facts dd { margin: 0; font-size: 17px; font-weight: 600; }
.facts:empty { display: none; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.about h2, .related h2 { margin: 0 0 12px; font: 600 clamp(20px, 2vw, 26px) var(--serif); }
.prose { font: 400 18px/1.7 var(--serif); color: var(--ink-2); }
.prose p { margin: 0 0 1em; }
.prose[data-clamped] { max-height: 13.6em; overflow: hidden; -webkit-mask-image: linear-gradient(#000 70%, transparent); mask-image: linear-gradient(#000 70%, transparent); }
.more-text { margin-top: 6px; padding: 8px 0; border: 0; background: none; color: var(--link); font-weight: 600; cursor: pointer; }
.related { padding-block: 48px 8px; }
.shelf {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 16px;
  overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 12px; scrollbar-width: thin;
}
.mini {
  scroll-snap-align: start; display: flex; gap: 14px; align-items: center; padding: 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink);
  transition: border-color .15s, transform .15s;
}
.mini:hover { color: var(--ink); border-color: var(--line-2); transform: translateY(-2px); }
.mini-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.mini-text b { font: 600 15px/1.3 var(--serif); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.mini-text small { font-size: 13px; color: var(--muted); }
.notfound, .text-page { padding-block: 64px; max-width: 760px; }
.notfound h1, .text-page h1 { font: 700 clamp(28px, 4vw, 42px)/1.15 var(--serif); margin: 0 0 16px; }
.notfound p { color: var(--muted); margin: 0 0 24px; }
@media (max-width: 760px) {
  .book { grid-template-columns: 1fr; }
  .book-cover { position: static; width: min(62vw, 280px); margin-inline: auto; }
  .actions .btn { flex: 1 1 100%; }
}

/* ---------- переходы между страницами (View Transitions API) ---------- */
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .22s; }
::view-transition-group(cover) { animation-duration: .38s; animation-timing-function: cubic-bezier(.2,.8,.2,1); }

/* ---------- подвал ---------- */
.footer { margin-top: 80px; background: #1E1A16; color: #D9D0C2; }
.footer-in { display: flex; justify-content: space-between; align-items: center; gap: 16px 32px; flex-wrap: wrap; padding-block: 32px; font-size: 14px; }
.footer-brand { margin: 0; display: flex; align-items: center; gap: 10px; }
.footer .brand-mark { color: #E27A45; font-size: 22px; }
.footer-nav { display: flex; gap: 8px 24px; flex-wrap: wrap; }
.footer-nav a { color: #F1E9DC; }
.footer-nav a:hover { color: #fff; text-decoration: underline; }

/* ---------- сообщения ---------- */
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 14px 16px; border-radius: 12px; margin-bottom: 16px; font-size: 15px; }
.notice a { color: inherit; text-decoration: underline; font-weight: 600; }
.notice-ok { background: var(--ok-bg); color: var(--ok-ink); }
.notice-error { background: var(--err-bg); color: var(--err-ink); }
@starting-style { .notice { opacity: 0; transform: translateY(-6px); } }
.notice { transition: opacity .3s, transform .3s; }

/* ---------- формы ---------- */
.form { display: grid; gap: 18px; }
.field { display: grid; gap: 6px; font-size: 14px; font-weight: 600; color: var(--ink-2); }
.field i { color: var(--accent); font-style: normal; }
.field input:not([type="checkbox"]):not([type="file"]), .field textarea, .field select {
  width: 100%; min-height: 46px; padding: 10px 14px; border: 1.5px solid var(--line-2); border-radius: 12px;
  background: var(--surface); font-size: 16px; font-weight: 400; color: var(--ink);
}
.field textarea { min-height: 120px; line-height: 1.55; resize: vertical; field-sizing: content; max-height: 60vh; }
.field input:focus, .field textarea:focus, .field select:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 20%, transparent); }
.field [aria-invalid="true"] { border-color: var(--err-ink) !important; }
.field input[type="file"] { font-size: 14px; font-weight: 400; }
.field-error { margin: 0; color: var(--err-ink); font-weight: 500; font-size: 14px; }
.hint { font-weight: 400; color: var(--muted); font-size: 13px; }
.check { display: flex; align-items: center; gap: 10px; font-size: 15px; cursor: pointer; min-height: 32px; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.checks { display: grid; gap: 6px; }
.row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.row-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 640px) { .row, .row-3 { grid-template-columns: 1fr; } }

/* ---------- вход ---------- */
.auth { display: grid; place-items: center; padding-block: 8vh; }
.auth-card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 32px; box-shadow: var(--shadow); }
.auth-card h1 { margin: 0; text-align: center; font: 700 26px var(--serif); }
.auth-card > .muted { text-align: center; margin: 4px 0 24px; }
.auth-card .form { margin-bottom: 16px; }

/* ---------- панель редактора ---------- */
.admin { padding-block: 32px; }
.admin.narrow { max-width: 640px; }
.admin-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.admin-head h1 { margin: 0; font: 700 clamp(26px, 3vw, 36px) var(--serif); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: clamp(16px, 2.4vw, 24px); margin-bottom: 20px; }
.panel h2 { margin: 0 0 14px; font: 600 18px var(--sans); display: flex; align-items: center; gap: 8px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 20px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 16px 18px; display: grid; }
.kpi b { font: 700 30px/1.1 var(--serif); font-variant-numeric: tabular-nums; }
.kpi span { font-size: 14px; color: var(--muted); }
.panels { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; }
.panels .panel { margin: 0; }
.panels + .panel { margin-top: 20px; }
.bars { width: 100%; height: 120px; fill: var(--accent); margin-bottom: 10px; }
.bars rect:hover { fill: var(--link-hover); }
.top { margin: 0; padding-left: 22px; display: grid; gap: 6px; font-size: 15px; }
.top li { padding-left: 4px; }
.top li span { float: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.tools { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 4px; }
.tools a { display: flex; align-items: center; gap: 10px; padding: 8px 0; }
.list-head { display: flex; align-items: center; gap: 12px 20px; flex-wrap: wrap; margin-bottom: 12px; }
.list-head h2 { margin: 0; }
.list-head .search-field { flex: 1 1 260px; max-width: 420px; }
.table-wrap { overflow-x: auto; margin-inline: -8px; }
.table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table th { text-align: left; font-size: 13px; font-weight: 600; color: var(--muted); padding: 8px; border-bottom: 1px solid var(--line); position: sticky; top: 68px; background: var(--surface); }
.table td { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:hover td { background: var(--surface-2); }
.table a b { color: var(--ink); font-weight: 600; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.flags { white-space: nowrap; }
.flag { display: inline-grid; place-items: center; width: 22px; height: 22px; margin-right: 3px; border-radius: 6px; font-size: 11px; font-weight: 700; background: var(--err-bg); color: var(--err-ink); }
.flag.on { background: var(--ok-bg); color: var(--ok-ink); }
.row-actions { white-space: nowrap; text-align: right; }
.row-actions .icon-btn { width: 36px; height: 36px; }
.problems { margin: 0; padding-left: 20px; font-size: 14px; display: grid; gap: 4px; }
.help p { font-size: 15px; color: var(--ink-2); }
.help summary { cursor: pointer; font-weight: 600; }

.editor { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.editor-main { display: grid; gap: 18px; margin: 0; }
.editor-side { display: grid; gap: 20px; position: sticky; top: 88px; }
.editor-side .panel { margin: 0; }
.editor-actions { display: grid; gap: 8px; }
@media (max-width: 900px) { .editor { grid-template-columns: 1fr; } .editor-side { position: static; } }
.drop { display: grid; grid-template-columns: 96px 1fr; gap: 14px; align-items: stretch; }
.drop-preview .cover-mini { width: 96px; }
.drop-preview img { width: 96px; aspect-ratio: 2/3; object-fit: cover; border-radius: 3px 8px 8px 3px; box-shadow: var(--shadow); }
.drop-zone {
  position: relative; display: grid; place-content: center; justify-items: center; gap: 4px; text-align: center; padding: 14px;
  border: 2px dashed var(--line-2); border-radius: 14px; color: var(--muted); font-size: 14px; cursor: pointer; transition: border-color .15s, background .15s;
}
.drop-zone b { color: var(--link); }
.drop-zone small { font-size: 12px; }
.drop-zone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop-zone:hover, .drop.is-over .drop-zone { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, transparent); }
.drop-zone:has(input:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; }
.file-now { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; font-weight: 600; }

/* ---------- диалог (нативный <dialog>) ---------- */
.dialog { width: min(460px, calc(100% - 32px)); border: 0; border-radius: 20px; padding: 28px; background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg); }
.dialog h2 { margin: 0 0 8px; font: 700 22px var(--serif); }
.dialog p { color: var(--ink-2); margin: 0 0 22px; }
.dialog::backdrop { background: rgb(20 14 8 / .55); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; }
.dialog[open] { animation: pop .18s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }

/* ---------- уважение к настройкам пользователя ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  @view-transition { navigation: none; }
}
@media print {
  .topbar, .footer, .filters, .search, .actions, .more, .related { display: none !important; }
  body { background: #fff; color: #000; }
  .card { break-inside: avoid; }
}

/* ---------- archive.org: встроенная читалка ---------- */
.reader { padding-block: 40px 8px; scroll-margin-top: 80px; }
.reader-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.reader-head h2 { margin: 0; font: 600 clamp(22px, 2.4vw, 28px) var(--serif); }
.reader-tools { display: flex; gap: 6px; flex-wrap: wrap; }
.reader-frame {
  position: relative; height: min(86vh, 900px); min-height: 480px; border-radius: 18px; overflow: hidden;
  background: #1E1A16; border: 1px solid var(--line); box-shadow: var(--shadow);
}
.reader-frame:fullscreen { height: 100%; border-radius: 0; border: 0; }
.reader-iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #1E1A16; }
.reader-loading { position: absolute; inset: 0; display: grid; place-items: center; color: #D9D0C2; font-size: 15px; }
.reader-poster {
  position: absolute; inset: 0; display: grid; grid-template-columns: auto minmax(0, 32rem); align-items: center; justify-content: center;
  gap: clamp(20px, 5vw, 56px); padding: 32px; color: #F1E9DC;
  background: radial-gradient(120% 90% at 30% 20%, #3A2F24 0%, #1E1A16 60%);
}
.reader-poster:hover { color: #fff; }
.reader-poster .cover-poster { width: clamp(140px, 22vw, 240px); box-shadow: 0 30px 60px -20px rgb(0 0 0 / .8); transition: transform .3s cubic-bezier(.2,.8,.2,1); }
.reader-poster:hover .cover-poster { transform: translateY(-6px) rotate(-1deg); }
.reader-cta { display: grid; gap: 12px; justify-items: start; }
.reader-cta small { color: #C9BDAE; font-size: 14px; line-height: 1.5; }
@media (max-width: 640px) {
  .reader-frame { height: 78vh; min-height: 420px; border-radius: 14px; margin-inline: calc(var(--pad) * -1 + 8px); }
  .reader-poster { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .reader-cta { justify-items: center; }
}
.online-tag { margin: 2px 0 0; display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--link); }
.chip-toggle { border-style: dashed; }
.chip-toggle[aria-current="true"] { background: var(--accent); border-color: var(--accent); border-style: solid; color: #fff; }
.ia-field { gap: 6px; }
.ia-row { display: flex; gap: 8px; }
.ia-row input { flex: 1; min-width: 0; }
.ia-row .btn { flex-shrink: 0; min-height: 46px; }
.ia-box { padding: 12px 14px; border-radius: 12px; background: var(--surface-2); margin-bottom: 12px; display: grid; gap: 8px; font-size: 14px; }
.ia-box p { margin: 0; }
.drop-preview img[src^="https://archive.org"] { background: var(--surface-2); }

/* =====================================================================
   Для телефона: полка, «продолжить чтение», установка, Телеграм, QR
   ===================================================================== */

/* кнопки в шапке */
.shelf-btn { position: relative; }
.shelf-btn[aria-current="page"] { border-color: var(--accent); color: var(--accent); }
.shelf-count {
  position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center;
}
.install-btn { border-color: var(--accent); color: var(--accent); }
@media (max-width: 720px) { .topbar .nav { gap: 6px; } }

/* сердечко на карточке */
.heart {
  position: absolute; top: 8px; right: 8px; z-index: 3; width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer; border: 0;
  background: rgb(255 253 248 / .92); color: var(--ink-2); box-shadow: 0 2px 8px rgb(0 0 0 / .2);
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); transition: transform .15s, color .15s;
}
.heart:hover { transform: scale(1.08); }
.heart[aria-pressed="true"], .heart-btn[aria-pressed="true"] { color: #C0392B; }
.heart[aria-pressed="true"] svg, .heart-btn[aria-pressed="true"] svg { fill: currentColor; }
@media (hover: hover) { .card .heart[aria-pressed="false"] { opacity: 0; } .card:hover .heart, .heart:focus-visible { opacity: 1; } }
.pop { animation: pop-heart .35s cubic-bezier(.2,.8,.2,1.4); }
@keyframes pop-heart { 40% { transform: scale(1.3); } }

/* «Продолжить чтение» */
.continue {
  display: flex; align-items: center; gap: 10px; margin-top: 18px; max-width: 560px; padding: 10px 10px 10px 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow);
}
.continue-link { flex: 1; display: flex; align-items: center; gap: 14px; min-width: 0; color: var(--ink); }
.continue-link:hover { color: var(--ink); }
.continue-link .cover-mini { width: 44px; }
.continue-text { display: grid; min-width: 0; }
.continue-text small { font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--link); }
.continue-text b { font: 600 16px/1.3 var(--serif); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.continue-x { width: 36px; height: 36px; font-size: 20px; line-height: 1; flex-shrink: 0; }

/* страница «Моя полка» */
.shelf-page { padding-block: 32px 8px; }
.shelf-head h1 { margin: 0; font: 700 clamp(30px, 4vw, 44px)/1.1 var(--serif); }
.shelf-head p { margin: 8px 0 0; max-width: 60ch; }
.shelf-page .grid { margin-top: 24px; }
.phone-tools { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; margin-top: 40px; }
.tool-card { margin: 0; display: grid; gap: 10px; justify-items: start; }
.tool-card h2 { margin: 0; }
.tool-card p { margin: 0; }
.steps { margin: 0 0 20px; padding-left: 22px; display: grid; gap: 8px; color: var(--ink-2); }

/* внутри Телеграма: своя шапка у Телеграма, наша — компактнее; установка не нужна */
.in-tg .topbar { position: static; }
.in-tg .brand-text small, .in-tg .install-btn, .in-tg [data-install-card], .in-tg .theme-btn,
.in-tg .topbar .nav > a:not([aria-current]):not(.nav-admin):not(.icon-btn) { display: none !important; }
.in-tg .hero { padding-top: 20px; }
.in-tg .footer { margin-top: 40px; }

/* ---------- наклейки с QR-кодами ---------- */
.qr-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.qr-layout .panel { margin: 0; }
@media (max-width: 900px) { .qr-layout { grid-template-columns: 1fr; } }
.qr-pick .list-head select { min-height: 44px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: 12px; background: var(--surface); }
.qr-bulk { display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap; margin-bottom: 8px; }
.qr-list { list-style: none; margin: 0; padding: 0; max-height: 52vh; overflow-y: auto; border-top: 1px solid var(--line); }
.qr-list li { border-bottom: 1px solid var(--line); }
.qr-list .check { padding: 8px 4px; align-items: flex-start; }
.qr-list .check input { margin-top: 3px; flex-shrink: 0; }
.qr-list b { font-weight: 600; }
.qr-opts h2 { margin-bottom: 8px; }
.qr-opts .check { align-items: flex-start; }
.qr-sheets { display: grid; gap: 24px; margin-top: 24px; justify-items: center; }
.qr-sheet {
  width: 210mm; min-height: 297mm; background: #fff; color: #000; box-shadow: var(--shadow-lg);
  display: grid; align-content: start; box-sizing: border-box;
}
.qr-sheet.s24 { grid-template-columns: repeat(3, 70mm); grid-auto-rows: 37mm; padding: 0; }
.qr-sheet.s8 { grid-template-columns: repeat(2, 105mm); grid-auto-rows: 74mm; }
.sticker { display: flex; align-items: center; gap: 3mm; padding: 2.5mm 3mm; overflow: hidden; outline: 1px dashed #ddd; font-family: var(--sans); }
.sticker-qr { flex-shrink: 0; width: 30mm; height: 30mm; }
.sticker-qr svg { width: 100%; height: 100%; }
.sticker-text { display: grid; gap: 1mm; min-width: 0; }
.sticker-text b { font: 600 10pt/1.15 var(--serif); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.sticker-text span { font-size: 8pt; color: #333; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sticker-text small { font-size: 6.5pt; color: #666; line-height: 1.2; }
.s8 .sticker { gap: 6mm; padding: 6mm; }
.s8 .sticker-qr { width: 52mm; height: 52mm; }
.s8 .sticker-text b { font-size: 14pt; -webkit-line-clamp: 4; }
.s8 .sticker-text span { font-size: 11pt; white-space: normal; }
.s8 .sticker-text small { font-size: 8pt; }

@media print {
  @page { size: A4; margin: 0; }
  .page-qr .topbar, .page-qr .footer, .page-qr .no-print, .page-qr .notice { display: none !important; }
  .page-qr .admin { padding: 0; max-width: none; }
  .page-qr .qr-sheets { margin: 0; gap: 0; display: block; }
  .qr-sheet { box-shadow: none; min-height: 0; height: 297mm; break-after: page; }
  .qr-sheet:last-child { break-after: auto; }
  .sticker { outline: 0; }
}

/* плашка «Установить приложение» внизу экрана телефона */
.install-banner {
  position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom, 0px)); z-index: 30;
  display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 14px; max-width: 560px; margin-inline: auto;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line-2); border-radius: 18px; box-shadow: var(--shadow-lg);
  animation: rise .35s cubic-bezier(.2,.8,.2,1);
}
.install-banner { gap: 10px; }
.install-banner img { width: 40px; height: 44px; border-radius: 11px; flex-shrink: 0; }
.install-banner-text { flex: 1; min-width: 0; display: grid; line-height: 1.3; }
.install-banner-text b { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.install-banner-text small { font-size: 13px; color: var(--muted); }
.install-banner .btn { min-height: 42px; padding: 0 16px; flex-shrink: 0; }
.install-banner .icon-btn { width: 36px; height: 36px; border: 0; background: transparent; font-size: 22px; flex-shrink: 0; }
@keyframes rise { from { transform: translateY(120%); opacity: 0; } }
.in-tg .install-banner { display: none !important; }

/* =====================================================================
   Оболочка приложения на телефоне: нижняя панель вкладок и меню «Ещё»
   (как в архиве газет). Показывается на узких экранах и в установленном приложении.
   ===================================================================== */
.tabbar { display: none; }
@media (max-width: 720px), (display-mode: standalone) {
  .tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
    display: grid; grid-template-columns: repeat(4, 1fr);
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px));
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    -webkit-backdrop-filter: saturate(1.4) blur(14px); backdrop-filter: saturate(1.4) blur(14px);
    border-top: 1px solid var(--line);
  }
  @supports not (background: color-mix(in srgb, red 50%, blue)) { .tabbar { background: var(--surface); } }
  .tabbar > a, .tabbar > button {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    min-height: 52px; border: 0; background: none; border-radius: 12px; cursor: pointer;
    color: var(--muted); font: 600 11px/1.1 var(--sans); -webkit-tap-highlight-color: transparent;
  }
  .tabbar > a:hover { color: var(--ink); }
  .tabbar > [aria-current="page"] { color: var(--accent); }
  .tabbar > [aria-current="page"] svg { stroke-width: 2.4; }
  .tabbar > a:active, .tabbar > button:active { background: var(--surface-2); }
  .tab-ico { position: relative; display: block; }
  .tab-ico .shelf-count { top: -6px; right: -10px; }
  body { padding-bottom: calc(68px + env(safe-area-inset-bottom, 0px)); }
  .page-admin, .page-edit, .page-import, .page-password, .page-qr { padding-bottom: 0; }
  /* то, что переехало в нижнюю панель и меню, из шапки убираем */
  .topbar:not(.topbar-admin) .shelf-btn, .topbar:not(.topbar-admin) .theme-btn { display: none; }
  .footer-nav { display: none; }
  .footer { margin-top: 48px; }
  .footer-in { padding-block: 20px; }
  .install-banner { bottom: calc(76px + env(safe-area-inset-bottom, 0px)); }
  .editor-side { position: static; }
}
/* в установленном приложении — отступ под «чёлку» и без лишнего */
@media (display-mode: standalone) {
  .topbar { padding-top: env(safe-area-inset-top, 0px); }
  .install-btn, .install-banner, [data-install] { display: none !important; }
}

/* нижнее меню «Ещё» */
.sheet {
  width: 100%; max-width: 560px; margin: auto auto 0; padding: 10px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  border: 0; border-radius: 22px 22px 0 0; background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg);
}
.sheet::backdrop { background: rgb(20 14 8 / .45); }
.sheet[open] { animation: sheet-up .25s cubic-bezier(.2,.8,.2,1); }
@keyframes sheet-up { from { transform: translateY(100%); } }
.sheet-grip { width: 40px; height: 5px; border-radius: 3px; background: var(--line-2); margin: 0 auto 10px; }
.sheet-list { list-style: none; margin: 0 0 8px; padding: 0; }
.sheet-row {
  width: 100%; display: flex; align-items: center; gap: 14px; min-height: 52px; padding: 0 8px;
  border: 0; background: none; border-radius: 12px; color: var(--ink); font-size: 16px; text-align: left; cursor: pointer;
}
.sheet-row:hover, .sheet-row:active { background: var(--surface-2); color: var(--ink); }
.sheet-row svg { color: var(--link); }
.sheet-list li + li { border-top: 1px solid var(--line); }
@media print { .tabbar, .sheet { display: none !important; } }

/* =====================================================================
   Поиск: подсказки и результаты по тексту книг
   ===================================================================== */
.search-hint { margin: 10px 0 0; font-size: 15px; color: var(--muted); }
.hint-fix { color: var(--link); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; font-size: 15px; }
.fulltext { margin-top: 48px; padding-top: 28px; border-top: 1px solid var(--line); }
.fulltext h2 { margin: 0 0 4px; font: 600 clamp(20px, 2.2vw, 26px) var(--serif); display: flex; align-items: center; gap: 10px; }
.ft-list { list-style: none; margin: 18px 0 0; padding: 0; display: grid; gap: 14px; }
.ft-item { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.ft-item > p { margin: 0; }
.ft-item > p:first-child a { font: 600 17px var(--serif); color: var(--ink); }
.ft-item small { color: var(--muted); }
.ft-snip { margin: 8px 0 12px !important; font: 400 16px/1.6 var(--serif); color: var(--ink-2); }
.ft-snip mark { background: color-mix(in srgb, var(--accent) 22%, transparent); color: inherit; border-radius: 3px; padding: 0 2px; }
.ft-acts { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- скачать для чтения без интернета ---------- */
.offline { padding: 14px 16px; border: 1px dashed var(--line-2); border-radius: 14px; display: grid; gap: 10px; }
.offline-title { margin: 0; display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 15px; }
.offline-links { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.offline-links .btn small { font-weight: 400; color: var(--muted); }
.offline-help { font-size: 14px; font-weight: 600; margin-left: 4px; }

/* ---------- страница «Читать в читалке» ---------- */
.readers .lead { font-size: 18px; color: var(--ink-2); }
.readers h2 { font: 600 22px var(--serif); margin: 32px 0 10px; }
.opds-box { margin: 24px 0 8px; }
.opds-box p { margin: 0 0 8px; }
.copy-row { display: flex; gap: 8px; }
.copy-row input { flex: 1; min-width: 0; min-height: 46px; padding: 0 12px; border: 1.5px solid var(--line-2); border-radius: 12px; background: var(--bg); color: var(--ink); }

/* ---------- панель: «искали, но не нашли» ---------- */
.missed { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.missed li { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.missed li b { flex: 1; font-weight: 500; }
.missed li span { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 13px; }
.missed .icon-btn { width: 32px; height: 32px; border: 0; background: none; }

/* =====================================================================
   Удобство для слабовидящих
   ===================================================================== */
.a11y-btn { font: 700 15px var(--serif); }
@media (max-width: 720px) { .topbar:not(.topbar-admin) .a11y-btn { display: none; } }
@media (min-width: 721px) { .sheet { margin: auto; border-radius: 22px; } }

/* крупный текст: масштабируем всю страницу целиком, вёрстка не ломается */
html[data-text="l"] body { zoom: 1.15; }
html[data-text="xl"] body { zoom: 1.32; }
@supports not (zoom: 1) {
  html[data-text="l"] { font-size: 115%; }
  html[data-text="xl"] { font-size: 132%; }
}
html[data-text] .card-meta, html[data-text] .card-author { -webkit-line-clamp: 4; }

/* повышенная контрастность */
html[data-contrast="high"] {
  --muted: #2E2822; --ink-2: #14110E; --line: #9C8F7D; --line-2: #6F6353; --link: #7A3000; --link-hover: #4A1B00;
  --lib-f: #1D4336; --min-f: #172F4F; --edif-f: #573500; --false-f: #6E1510; --neg-f: #2E2822;
}
@media (prefers-color-scheme: dark) {
  html[data-contrast="high"]:not([data-theme="light"]) {
    --bg: #000; --surface: #121010; --ink: #FFF; --ink-2: #F4EEE6; --muted: #E2D8CA; --line: #7A6E60; --line-2: #A89A88; --link: #FFB27F; --link-hover: #FFD2B3;
    --lib-f: #A6E3CB; --min-f: #BFD6FF; --edif-f: #FFD08A; --false-f: #FFB4AA; --neg-f: #E2D8CA;
  }
}
html[data-theme="dark"][data-contrast="high"] {
  --bg: #000; --surface: #121010; --ink: #FFF; --ink-2: #F4EEE6; --muted: #E2D8CA; --line: #7A6E60; --line-2: #A89A88; --link: #FFB27F; --link-hover: #FFD2B3;
  --lib-f: #A6E3CB; --min-f: #BFD6FF; --edif-f: #FFD08A; --false-f: #FFB4AA; --neg-f: #E2D8CA;
}
html[data-contrast="high"] a:not(.btn):not(.chip):not(.brand):not(.card-cover):not(.mini):not(.sheet-row):not(.icon-btn):not([data-tab]) { text-decoration: underline; text-underline-offset: 3px; }
html[data-contrast="high"] :focus-visible { outline-width: 4px; outline-color: var(--ink); }
html[data-contrast="high"] .gen-title, html[data-contrast="high"] .gen-author { text-shadow: 0 1px 2px rgb(0 0 0 / .6); }

/* переключатели в меню */
.sheet-a11y { padding: 10px 8px 12px; display: grid; gap: 8px; }
.sheet-label { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.seg { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; padding: 4px; background: var(--surface-2); border-radius: 12px; }
.seg button { min-width: 0; padding: 0 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-height: 44px; border: 0; border-radius: 9px; background: transparent; color: var(--ink); font-weight: 600; font-size: 14px; cursor: pointer; }
.seg button[aria-checked="true"] { background: var(--surface); box-shadow: 0 1px 4px rgb(0 0 0 / .15); color: var(--accent); }
.seg-l { font-size: 15px; }
.seg-xl { font-size: 16px; }
.switch { margin-left: auto; width: 44px; height: 26px; border-radius: 13px; background: var(--line-2); position: relative; flex-shrink: 0; transition: background .2s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgb(0 0 0 / .3); }
[aria-checked="true"] > .switch { background: var(--accent); }
[aria-checked="true"] > .switch::after { transform: translateX(18px); }

/* ---------- церковная библиотека /libs ---------- */
.book-subtitle { margin: -12px 0 0; font: italic 400 18px/1.4 var(--serif); color: var(--muted); }
.libs-note { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 14px; background: var(--ok-bg); color: var(--ok-ink); }
.libs-note a { color: inherit; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.libs-note .muted { color: inherit; opacity: .85; }
.libs-sample { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 8px 0 0; font-size: 15px; }
.libs-sample dt { color: var(--muted); }
.libs-sample dd { margin: 0; }
.warn-text { color: var(--warn-ink); background: var(--warn-bg); display: inline-block; padding: 4px 8px; border-radius: 8px; margin-top: 4px; }
.libs-plan { max-height: 70vh; overflow: auto; }
.plan-badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; background: var(--surface-2); }
.plan-new .plan-badge { background: var(--ok-bg); color: var(--ok-ink); }
.plan-merge .plan-badge { background: #E3ECF8; color: #1F3F6B; }
.plan-skip td { opacity: .6; }

/* =====================================================================
   Аудиокниги
   ===================================================================== */
.online-tag { gap: 12px; flex-wrap: wrap; }
.online-tag span { display: inline-flex; align-items: center; gap: 5px; }
.listen { padding-block: 40px 8px; scroll-margin-top: 80px; }
.listen-head { display: flex; align-items: baseline; justify-content: space-between; gap: 6px 16px; flex-wrap: wrap; margin-bottom: 14px; }
.listen-head h2 { margin: 0; font: 600 clamp(22px, 2.4vw, 28px) var(--serif); display: flex; align-items: center; gap: 10px; }
.listen-head p { margin: 0; font-size: 15px; }
.player {
  display: grid; gap: 14px; padding: clamp(16px, 3vw, 24px); border-radius: 20px; margin-bottom: 16px;
  background: linear-gradient(160deg, #2A2119, #1E1A16); color: #F1E9DC; box-shadow: var(--shadow-lg);
}
.player-now { display: flex; align-items: center; gap: 14px; min-width: 0; }
.player-now .cover-mini { width: 56px; }
.player-text { display: grid; min-width: 0; }
.player-text small { color: #C9BDAE; font-size: 13px; }
.player-text b { font: 600 clamp(17px, 2vw, 20px)/1.25 var(--serif); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.player-text .muted { color: #E2A77F; }
.player-bar { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; }
.p-time { font-size: 13px; font-variant-numeric: tabular-nums; color: #C9BDAE; min-width: 40px; }
.p-time:last-child { text-align: right; }
.player-bar input[type="range"] { width: 100%; accent-color: #E27A45; height: 28px; cursor: pointer; }
.player-ctrl { display: flex; align-items: center; justify-content: center; gap: clamp(6px, 3vw, 22px); }
.p-btn {
  position: relative; width: 52px; height: 52px; border-radius: 50%; border: 0; background: rgb(255 255 255 / .08);
  color: #F1E9DC; display: grid; place-items: center; cursor: pointer;
}
.p-btn:hover { background: rgb(255 255 255 / .16); }
.p-btn small { position: absolute; font-size: 9px; font-weight: 700; top: 50%; left: 50%; transform: translate(-50%, -45%); }
.p-play {
  width: 72px; height: 72px; border-radius: 50%; border: 0; background: #E27A45; color: #1E1A16;
  display: grid; place-items: center; cursor: pointer; box-shadow: 0 10px 24px -8px rgb(226 122 69 / .7); transition: transform .15s;
}
.p-play:hover { transform: scale(1.05); }
.p-play.small { width: 44px; height: 44px; box-shadow: none; }
.player-extra { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.chip-btn {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 14px; border-radius: 999px;
  border: 1px solid rgb(255 255 255 / .2); background: transparent; color: #F1E9DC; font-size: 14px; font-weight: 600; cursor: pointer;
}
.chip-btn:hover { color: #fff; border-color: rgb(255 255 255 / .5); }
.chip-btn.on { background: #E27A45; border-color: #E27A45; color: #1E1A16; }
.player :focus-visible { outline-color: #F1E9DC; }

.chapters { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; background: var(--surface); }
.chapters li + li { border-top: 1px solid var(--line); }
.chapter { display: grid; grid-template-columns: 36px 1fr auto; align-items: center; gap: 10px; padding: 12px 16px; color: var(--ink); min-height: 52px; }
.chapter:hover { background: var(--surface-2); color: var(--ink); }
.ch-n { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 700; background: var(--surface-2); color: var(--muted); }
.ch-t { min-width: 0; }
.ch-d { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.chapter.is-done .ch-n { background: var(--ok-bg); color: var(--ok-ink); }
.chapter.is-done .ch-n::after { content: "✓"; }
.chapter.is-done .ch-n { font-size: 0; }
.chapter.is-done .ch-n::after { font-size: 14px; }
.chapter.is-current { background: color-mix(in srgb, var(--accent) 10%, var(--surface)); font-weight: 600; }
.chapter.is-current .ch-n { background: var(--accent); color: #fff; font-size: 13px; }
.chapter.is-current .ch-n::after { content: none; }
.is-playing .chapter.is-current .ch-n { animation: pulse-n 1.6s ease-in-out infinite; }
@keyframes pulse-n { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 25%, transparent); } }

.miniplayer {
  position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 26; max-width: 560px; margin-inline: auto;
  display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 12px; padding: 8px 14px 12px 8px;
  background: #1E1A16; color: #F1E9DC; border-radius: 16px; box-shadow: var(--shadow-lg); overflow: hidden;
}
.miniplayer .mini-text { display: grid; min-width: 0; color: #F1E9DC; }
.miniplayer .mini-text:hover { color: #fff; }
.miniplayer .mini-text b { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.miniplayer .mini-text span { font-size: 12px; color: #C9BDAE; font-variant-numeric: tabular-nums; }
.mini-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: rgb(255 255 255 / .12); }
.mini-progress span { display: block; height: 100%; width: 0; background: #E27A45; }
@media (max-width: 720px), (display-mode: standalone) {
  .miniplayer { bottom: calc(76px + env(safe-area-inset-bottom, 0px)); }
}

/* редактор */
.audio-edit { border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px 16px; display: grid; gap: 14px; margin: 0; }
.audio-edit legend { padding: 0 6px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.audio-list { list-style: none; margin: 0; padding: 0; max-height: 320px; overflow-y: auto; border-top: 1px solid var(--line); }
.audio-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; border-bottom: 1px solid var(--line); padding: 4px 2px; }
.audio-list small { color: var(--muted); font-variant-numeric: tabular-nums; }
.formats { margin: 20px 0; }
.formats h2 { margin-top: 0 !important; }
.formats p { font-size: 16px; }
.offline-note { margin: 0; }
.pick { margin: 24px 0 8px; }
.pick h2 { margin-top: 0 !important; }
.pick-list { margin: 0; display: grid; gap: 4px 0; }
.pick-list dt { display: flex; align-items: center; gap: 8px; font-weight: 700; margin-top: 12px; }
.pick-list dt svg { color: var(--link); }
.pick-list dd { margin: 2px 0 0 28px; color: var(--ink-2); }
.steps.big li { font-size: 17px; margin-bottom: 6px; }
.steps small { font-size: 14px; }

/* =====================================================================
   Реакции и отзывы
   ===================================================================== */
.reactions { display: flex; flex-wrap: wrap; gap: 8px; }
.react {
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px; border-radius: 999px;
  border: 1.5px solid var(--line-2); background: var(--surface); color: var(--ink-2); font-size: 14px; font-weight: 600; cursor: pointer;
  transition: border-color .15s, background .15s, color .15s;
}
.react:hover { border-color: var(--accent); color: var(--ink); }
.react b { font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 600; }
.react b:empty { display: none; }
.react[aria-pressed="true"] { background: color-mix(in srgb, var(--accent) 12%, var(--surface)); border-color: var(--accent); color: var(--link); }
.react[aria-pressed="true"] b { color: var(--link); }
.react[aria-pressed="true"]::before { content: "✓"; font-weight: 700; }

.reviews { padding-block: 48px 8px; scroll-margin-top: 80px; }
.reviews-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.reviews-head h2 { margin: 0; font: 600 clamp(22px, 2.4vw, 28px) var(--serif); display: flex; align-items: center; gap: 10px; }
.review-form { display: grid; gap: 14px; max-width: 760px; }
.review-form .consent { align-items: flex-start; font-size: 14px; line-height: 1.45; }
.review-form .consent input { margin-top: 2px; flex-shrink: 0; }
.review-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.hp { position: absolute !important; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.my-pending .notice { margin-bottom: 10px; }
.my-pending .linkish { text-decoration: underline; font-weight: 600; color: inherit; }
.review-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; max-width: 860px; }
.review { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.review header { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.review header time { margin-left: auto; font-size: 13px; color: var(--muted); }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--link); font: 700 15px var(--serif); flex-shrink: 0; }
.review-text { font: 400 17px/1.65 var(--serif); color: var(--ink-2); }
.reply { margin-top: 12px; padding: 10px 14px; border-left: 3px solid var(--accent); background: var(--surface-2); border-radius: 0 10px 10px 0; font-size: 15px; }
.reply b { display: inline-flex; align-items: center; gap: 6px; color: var(--link); margin-bottom: 4px; }
.own-del { margin-top: 10px; color: var(--muted); text-decoration: underline; }

/* панель модерации */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.tabs a { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1.5px solid var(--line-2); color: var(--ink); font-weight: 600; font-size: 14px; }
.tabs a[aria-current="page"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.mod { display: grid; gap: 10px; }
.mod-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; align-items: flex-start; }
.mod-text { font: 400 16px/1.6 var(--serif); white-space: normal; }
.mod-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; }
.reply-box { flex-basis: 100%; order: 3; }
.reply-box[open] { display: grid; gap: 10px; padding: 12px; border: 1px dashed var(--line-2); border-radius: 12px; }
.reply-box summary { list-style: none; display: inline-flex; width: max-content; }
.reply-box summary::-webkit-details-marker { display: none; }
.nav-badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--accent); color: #fff; font-size: 12px; line-height: 20px; text-align: center; }
.kpi { color: var(--ink); }
a.kpi:hover { border-color: var(--accent); color: var(--ink); }
.kpi-alert { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--surface)); }
.kpi-alert b { color: var(--link); }

/* =====================================================================
   Полоса проектов МСЦ ЕХБ (вверху каждой страницы)
   ===================================================================== */
.projects { background: #1E1A16; color: #D9D0C2; font-size: 13px; }
.projects-in {
  display: flex; align-items: center; gap: 2px; min-height: 36px; overflow-x: auto; scrollbar-width: none;
  -webkit-mask-image: linear-gradient(90deg, #000 92%, transparent); mask-image: linear-gradient(90deg, #000 92%, transparent);
}
.projects-in::-webkit-scrollbar { display: none; }
.projects a {
  flex-shrink: 0; display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 10px;
  color: #D9D0C2; white-space: nowrap; border-radius: 0; position: relative;
}
.projects a:hover { color: #fff; background: rgb(255 255 255 / .06); }
.projects .proj-home { color: #F1E9DC; font-weight: 700; padding-left: 0; }
.projects a[aria-current="page"] { color: #fff; font-weight: 700; }
.projects a[aria-current="page"]::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: 0; height: 2px; background: #E27A45; border-radius: 2px; }
.projects a + a::before { content: ""; position: absolute; left: -1px; top: 50%; height: 12px; margin-top: -6px; width: 1px; background: rgb(255 255 255 / .15); }
.projects a[aria-current="page"] + a::before, .projects a + a[aria-current="page"]::before { opacity: 0; }
@media (max-width: 720px) { .projects a { padding: 0 9px; font-size: 13px; } }
.in-tg .projects { display: none; }
@media print { .projects { display: none; } }

/* меню «Ещё»: проекты */
.sheet-proj-title { margin: 14px 8px 6px; }
.sheet-projects { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin-bottom: 10px; }
.sheet-projects a { display: grid; gap: 1px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); color: var(--ink); line-height: 1.25; }
.sheet-projects a:hover { color: var(--ink); background: color-mix(in srgb, var(--accent) 10%, var(--surface-2)); }
.sheet-projects a[aria-current="page"] { outline: 2px solid var(--accent); }
.sheet-projects b { font-size: 15px; }
.sheet-projects small { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet { max-height: 92vh; overflow-y: auto; }

/* =====================================================================
   Подсказки к разделам
   ===================================================================== */
button.badge { border: 0; background: none; padding: 0; font: inherit; font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--tf); cursor: help; }
.has-tip { position: relative; z-index: 2; align-self: flex-start; } /* выше ссылки-«накладки» карточки */
.tip-q {
  display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; margin-left: 2px;
  font-size: 10px; font-weight: 800; letter-spacing: 0; background: color-mix(in srgb, currentColor 14%, transparent); color: inherit;
}
.has-tip:hover .tip-q, .has-tip:focus-visible .tip-q { background: currentColor; color: var(--surface); }
.type-tip {
  position: fixed; z-index: 60; padding: 12px 14px; border-radius: 14px; display: grid; gap: 4px;
  background: #1E1A16; color: #F1E9DC; box-shadow: 0 18px 40px -12px rgb(0 0 0 / .5); font-size: 14px; line-height: 1.5;
  border-top: 3px solid var(--tc, #E27A45); pointer-events: auto;
}
.type-tip b { font-size: 13px; letter-spacing: .04em; text-transform: uppercase; color: #fff; }
.type-tip.warn b::before { content: "⚠ "; color: #FFD08A; }
@starting-style { .type-tip:not([hidden]) { opacity: 0; transform: translateY(-4px); } }
.type-tip { transition: opacity .15s, transform .15s; }

.legend-btn {
  justify-self: start; display: inline-flex; align-items: center; gap: 8px; border: 0; background: none; padding: 4px 0;
  color: var(--link); font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px;
}
.legend-btn .tip-q { width: 20px; height: 20px; font-size: 12px; text-decoration: none; }
.legend { width: min(620px, calc(100% - 24px)); max-height: 88vh; overflow-y: auto; }
.legend dl { margin: 0 0 16px; display: grid; gap: 4px; }
.legend dt { margin-top: 12px; display: flex; align-items: center; gap: 6px; }
.legend dd { margin: 0; color: var(--ink-2); font-size: 15px; line-height: 1.55; }

/* блок «Рядом в разделе»: заголовки книг — тёмные и чёткие */
.mini .mini-text b { color: var(--ink); }
.mini:hover .mini-text b { color: var(--link); }

/* файлы книги в редакторе */
.file-list { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 6px; }
.file-list li { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 6px 0; border-bottom: 1px solid var(--line); }
.file-list .file-now { margin: 0; display: inline-flex; align-items: center; gap: 6px; }
.file-list .check { min-height: 0; margin-left: auto; }
