/* ==========================================================================
LIBRARY.CSS — «Библиотека»: полка сборников-книг, оглавление сборника и
читалка билета (бумажный лист, оглавление разделов, водяной знак).
Выделение текста, перетаскивание картинок и печать в читалке отключены —
материалы библиотеки можно только читать на сайте (см. library.js).
========================================================================== */

.lib-page {
  min-height: 100vh;
  padding: 30px 0 90px;
  background:
    radial-gradient(ellipse 55% 38% at 100% 0%, color-mix(in srgb, #8c54ff 11%, transparent), transparent),
    radial-gradient(ellipse 45% 32% at 0% 25%, color-mix(in srgb, var(--color-primary) 9%, transparent), transparent),
    var(--color-bg-alt);
}

.lib-container {
  max-width: 1180px;
}

.lib-view[hidden] {
  display: none !important;
}

@keyframes libIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
}

.lib-muted {
  color: var(--color-text-muted);
}

/* ---------------- Шапка полки ---------------- */
.lib-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 22px;
  animation: libIn 0.45s cubic-bezier(0.2, 0.8, 0.2, 1) backwards;
}

.lib-eyebrow {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #7c4dff;
}

[data-theme="dark"] .lib-eyebrow {
  color: #a98bff;
}

.lib-title {
  margin: 8px 0 10px;
  font-size: clamp(30px, 4.4vw, 46px);
  font-weight: 900;
  line-height: 1.06;
  letter-spacing: -0.02em;
  color: var(--color-text);
}

.lib-title span {
  background: linear-gradient(90deg, #8c54ff, #4f6bff 55%, #e5484d);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.lib-lead {
  max-width: 620px;
  font-size: 15.5px;
  line-height: 1.6;
  color: var(--color-text-muted);
}

.lib-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.lib-stats[hidden] {
  display: none;
}

.lib-stat {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: var(--color-white);
  font-size: 13px;
  font-weight: 700;
  color: var(--color-text-muted);
}

.lib-stat i {
  font-style: normal;
}

.lib-stat b {
  font-size: 17px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  color: var(--color-text);
}

/* Иллюстрация: книги на полке. */
.lib-hero__art {
  position: relative;
  flex-shrink: 0;
  width: 190px;
  height: 150px;
  animation: libArtFloat 7s ease-in-out infinite;
}

@keyframes libArtFloat {
  50% {
    transform: translateY(-6px);
  }
}

.lib-hero__book {
  position: absolute;
  bottom: 18px;
  width: 34px;
  border-radius: 6px 8px 4px 4px;
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.18), transparent 30%, rgba(255, 255, 255, 0.18) 55%, transparent 70%), var(--c);
  box-shadow: inset 0 -10px 0 rgba(0, 0, 0, 0.12), 0 12px 24px -14px rgba(12, 14, 40, 0.7);
}

.lib-hero__book::before,
.lib-hero__book::after {
  content: "";
  position: absolute;
  left: 6px;
  right: 6px;
  height: 3px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.55);
}

.lib-hero__book::before {
  top: 16px;
}

.lib-hero__book::after {
  top: 22px;
  opacity: 0.6;
}

.lib-hero__book--1 {
  --c: #e5484d;
  left: 20px;
  height: 104px;
}

.lib-hero__book--2 {
  --c: #4f6bff;
  left: 58px;
  width: 40px;
  height: 120px;
}

.lib-hero__book--3 {
  --c: #1fb774;
  left: 102px;
  height: 94px;
}

.lib-hero__book--4 {
  --c: #8c54ff;
  left: 142px;
  height: 110px;
  transform-origin: bottom left;
  transform: rotate(14deg);
}

.lib-hero__shelf {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 6px;
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(180deg, #d9a066, #a8672f);
  box-shadow: 0 10px 20px -10px rgba(120, 60, 10, 0.8);
}

[data-theme="dark"] .lib-hero__shelf {
  background: linear-gradient(180deg, #8a5a30, #5c3a1c);
}

/* ---------------- Доступ ---------------- */
.lib-access {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  padding: 16px 20px;
  border-radius: 22px;
  border: 1px solid var(--color-border);
  background: var(--color-white);
  animation: libIn 0.45s 0.06s cubic-bezier(0.2, 0.8, 0.2, 1) backwards;
}

.lib-access[hidden] {
  display: none;
}

.lib-access--locked {
  border-color: color-mix(in srgb, #8c54ff 35%, var(--color-border));
  background:
    radial-gradient(ellipse 60% 120% at 0% 0%, color-mix(in srgb, #8c54ff 12%, transparent), transparent),
    var(--color-white);
}

.lib-access--open {
  border-color: color-mix(in srgb, #1fb774 35%, var(--color-border));
  background:
    radial-gradient(ellipse 60% 120% at 0% 0%, color-mix(in srgb, #1fb774 10%, transparent), transparent),
    var(--color-white);
}

.lib-access__icon {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 46px;
  height: 46px;
  border-radius: 15px;
  color: #fff;
  background: linear-gradient(145deg, #a47bff, #6a3df0);
  box-shadow: 0 10px 22px -12px rgba(106, 61, 240, 0.9);
}

.lib-access__icon--open {
  background: linear-gradient(145deg, #3fd08f, #12925a);
  box-shadow: 0 10px 22px -12px rgba(18, 146, 90, 0.9);
}

.lib-access__icon svg {
  width: 22px;
  height: 22px;
}

.lib-access__text {
  flex: 1;
  min-width: 0;
}

.lib-access__text b {
  display: block;
  font-size: 15.5px;
  font-weight: 850;
  color: var(--color-text);
}

.lib-access__text p {
  margin-top: 3px;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--color-text-muted);
}

.lib-access__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex-shrink: 0;
}

.lib-access__limit {
  flex-shrink: 0;
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--color-bg-alt);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--color-text-muted);
  white-space: nowrap;
}

/* ---------------- Поиск и фильтр ---------------- */
.lib-toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
  animation: libIn 0.45s 0.1s cubic-bezier(0.2, 0.8, 0.2, 1) backwards;
}

.lib-toolbar[hidden] {
  display: none;
}

.lib-search {
  position: relative;
  display: flex;
  align-items: center;
  flex: 0 1 340px;
  min-width: 0;
}

.lib-search svg {
  position: absolute;
  left: 15px;
  width: 18px;
  height: 18px;
  color: var(--color-text-muted);
  pointer-events: none;
}

.lib-search input {
  width: 100%;
  height: 46px;
  padding: 0 16px 0 42px;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: var(--color-white);
  font: inherit;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--color-text);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.lib-search input:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--color-primary) 60%, var(--color-border));
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--color-primary) 14%, transparent);
}

.lib-chips {
  display: flex;
  gap: 8px;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 2px;
}

.lib-chips::-webkit-scrollbar {
  display: none;
}

/* На компьютере листать ленту нечем (нет свайпа) — переносим на вторую
   строку, чтобы все дисциплины были видны. */
@media (min-width: 861px), (hover: hover) and (pointer: fine) {
  .lib-chips {
    flex-wrap: wrap;
    overflow: visible;
  }
}

.lib-chips[hidden] {
  display: none;
}

.lib-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
  height: 40px;
  padding: 0 15px;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: var(--color-white);
  font: inherit;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.lib-chip:hover {
  color: var(--color-text);
}

.lib-chip:active {
  transform: scale(0.96);
}

.lib-chip i {
  font-style: normal;
  font-size: 12px;
  opacity: 0.7;
}

.lib-chip__dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--book, var(--color-primary));
}

.lib-chip.is-active {
  border-color: transparent;
  background: var(--color-text);
  color: var(--color-bg);
}

/* ---------------- Полка ---------------- */
.lib-shelf {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 26px 22px;
}

.lib-shelf[hidden] {
  display: none;
}

.lib-skeleton {
  height: 330px;
  border-radius: 22px;
  background: var(--color-white);
  border: 1px solid var(--color-border);
  animation: libPulse 1.4s ease-in-out infinite;
}

@keyframes libPulse {
  50% {
    opacity: 0.55;
  }
}

.lib-book {
  display: flex;
  flex-direction: column;
  gap: 14px;
  color: inherit;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.lib-book__cover,
.lib-col__cover {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 220px;
  padding: 20px 20px 18px 34px;
  border-radius: 8px 20px 20px 8px;
  overflow: hidden;
  color: #fff;
  background:
    radial-gradient(circle at 85% 12%, rgba(255, 255, 255, 0.28), transparent 45%),
    linear-gradient(155deg, var(--book), var(--book-2));
  box-shadow:
    inset -6px 0 0 rgba(255, 255, 255, 0.85),
    inset -8px 0 0 rgba(0, 0, 0, 0.08),
    inset -11px 0 0 rgba(255, 255, 255, 0.7),
    0 22px 34px -22px color-mix(in srgb, var(--book-2) 85%, #000);
  transition: transform 0.35s cubic-bezier(0.3, 1.4, 0.5, 1), box-shadow 0.35s ease;
}

.lib-book:hover .lib-book__cover,
.lib-book:focus-visible .lib-book__cover {
  transform: translateY(-6px) rotate(-1.2deg);
}

.lib-book:active .lib-book__cover {
  transform: translateY(-2px) scale(0.99);
}

.lib-book__spine {
  position: absolute;
  inset: 0 auto 0 0;
  width: 18px;
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.28), rgba(0, 0, 0, 0.08) 60%, rgba(255, 255, 255, 0.25) 88%, rgba(0, 0, 0, 0.12));
}

.lib-book__kind {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.85;
}

.lib-book__name {
  margin-top: 10px;
  max-width: 88%;
  font-size: 23px;
  font-weight: 900;
  line-height: 1.12;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

.lib-book__author {
  margin-top: 8px;
  font-size: 13px;
  font-weight: 600;
  opacity: 0.85;
}

.lib-book__count {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  margin-top: auto;
  font-size: 13px;
  font-weight: 700;
  opacity: 0.95;
}

.lib-book__count b {
  font-size: 26px;
  font-weight: 900;
  line-height: 1;
}

.lib-book__emblem {
  position: absolute;
  right: 18px;
  bottom: -26px;
  font-size: 150px;
  font-weight: 900;
  line-height: 1;
  opacity: 0.12;
  pointer-events: none;
}

.lib-book__lock {
  position: absolute;
  top: 14px;
  right: 18px;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.26);
  color: #fff;
}

.lib-book__lock svg {
  width: 17px;
  height: 17px;
}

.lib-book__info {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 4px;
}

.lib-book__info h3 {
  font-size: 16px;
  font-weight: 800;
  line-height: 1.3;
  color: var(--color-text);
}

.lib-book__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  font-size: 12.5px;
  font-weight: 650;
  color: var(--color-text-muted);
}

.lib-book__meta span,
.lib-col__chips span,
.lib-paper__meta span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.lib-book__meta svg,
.lib-col__chips svg,
.lib-paper__meta svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.lib-book__progress {
  height: 6px;
  border-radius: 999px;
  background: var(--color-border);
  overflow: hidden;
}

.lib-book__progress span {
  display: block;
  width: var(--p, 0%);
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--book), color-mix(in srgb, var(--book) 60%, #fff));
}

.lib-book__progress-text {
  font-size: 12px;
  font-weight: 650;
  color: var(--color-text-muted);
}

/* ---------------- Поиск: результаты ---------------- */
.lib-results[hidden] {
  display: none;
}

.lib-results__count {
  margin-bottom: 12px;
  font-size: 13px;
  font-weight: 700;
  color: var(--color-text-muted);
}

.lib-results__list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 10px;
  list-style: none;
  padding: 0;
  margin: 0;
}

.lib-result,
.lib-ticket {
  display: flex;
  align-items: center;
  gap: 14px;
  height: 100%;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid var(--color-border);
  background: var(--color-white);
  color: inherit;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.25s cubic-bezier(0.3, 1.4, 0.5, 1), border-color 0.2s ease, box-shadow 0.25s ease;
}

.lib-result:hover,
.lib-ticket:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--book, var(--color-primary)) 45%, var(--color-border));
  box-shadow: 0 14px 26px -20px color-mix(in srgb, var(--book, var(--color-primary)) 80%, #000);
}

.lib-result:active,
.lib-ticket:active {
  transform: scale(0.985);
}

.lib-result__num,
.lib-ticket__num {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--book, var(--color-primary)) 13%, transparent);
  color: var(--book, var(--color-primary));
  font-size: 16px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

[data-theme="dark"] .lib-result__num,
[data-theme="dark"] .lib-ticket__num {
  background: color-mix(in srgb, var(--book, var(--color-primary)) 22%, transparent);
  color: color-mix(in srgb, var(--book, var(--color-primary)) 55%, #fff);
}

.lib-result__body,
.lib-ticket__body {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  min-width: 0;
}

.lib-result__body b,
.lib-ticket__body b {
  font-size: 14.5px;
  font-weight: 800;
  line-height: 1.35;
  color: var(--color-text);
}

.lib-result__body small,
.lib-ticket__meta,
.lib-ticket__sections {
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--color-text-muted);
}

.lib-ticket__sections {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 0.85;
}

.lib-ticket__meta em {
  margin-left: 6px;
  padding: 1px 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--book, var(--color-primary)) 14%, transparent);
  color: var(--book, var(--color-primary));
  font-style: normal;
  font-weight: 800;
}

.lib-result__state,
.lib-ticket__state {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: var(--color-text-muted);
}

.lib-result__state svg,
.lib-ticket__state svg {
  width: 17px;
  height: 17px;
}

.lib-ticket.is-read .lib-ticket__state {
  background: color-mix(in srgb, #1fb774 16%, transparent);
  color: #12925a;
}

[data-theme="dark"] .lib-ticket.is-read .lib-ticket__state {
  color: #3fd08f;
}

.lib-ticket.is-read .lib-ticket__num {
  background: color-mix(in srgb, #1fb774 14%, transparent);
  color: #12925a;
}

[data-theme="dark"] .lib-ticket.is-read .lib-ticket__num {
  color: #3fd08f;
}

.lib-ticket.is-last {
  border-color: color-mix(in srgb, var(--book, var(--color-primary)) 55%, var(--color-border));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--book, var(--color-primary)) 12%, transparent);
}

/* ---------------- Пустые состояния ---------------- */
.lib-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  grid-column: 1 / -1;
  padding: 56px 24px;
  border-radius: 26px;
  border: 1px dashed var(--color-border);
  background: var(--color-white);
  text-align: center;
  animation: libIn 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) backwards;
}

.lib-empty--small {
  padding: 30px 20px;
}

.lib-empty--reader {
  border: 0;
  background: transparent;
}

.lib-empty__art {
  display: grid;
  place-items: center;
  width: 92px;
  height: 92px;
  margin-bottom: 8px;
  border-radius: 28px;
  background: linear-gradient(145deg, color-mix(in srgb, #8c54ff 18%, var(--color-white)), color-mix(in srgb, var(--color-primary) 16%, var(--color-white)));
  transform: rotate(-6deg);
}

.lib-empty__art .lp-icon {
  width: 56px;
  height: 56px;
}

.lib-empty b {
  font-size: 18px;
  font-weight: 850;
  color: var(--color-text);
}

.lib-empty p {
  max-width: 440px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--color-text-muted);
}

.lib-empty .btn {
  margin-top: 8px;
}

.lib-empty__hint {
  margin-top: 6px;
  padding: 8px 14px;
  border-radius: 12px;
  background: var(--color-bg-alt);
  font-size: 12.5px !important;
}

.lib-empty__hint--ok {
  background: color-mix(in srgb, #1fb774 12%, transparent);
  color: #12925a !important;
}

[data-theme="dark"] .lib-empty__hint--ok {
  color: #3fd08f !important;
}

.lib-empty__hint code {
  font-weight: 800;
}

/* ---------------- Сборник ---------------- */
.lib-back,
.lib-reader-bar__back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--color-text-muted);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  transition: color 0.2s ease;
}

.lib-back {
  margin-bottom: 18px;
  padding: 8px 14px 8px 10px;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: var(--color-white);
}

.lib-back:hover,
.lib-reader-bar__back:hover {
  color: var(--color-text);
}

.lib-back svg {
  width: 17px;
  height: 17px;
}

.lib-col {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 34px;
  align-items: center;
  margin-bottom: 26px;
  padding: 26px;
  border-radius: 28px;
  border: 1px solid var(--color-border);
  background:
    radial-gradient(ellipse 50% 90% at 0% 0%, color-mix(in srgb, var(--book) 12%, transparent), transparent),
    var(--color-white);
  animation: libIn 0.45s cubic-bezier(0.2, 0.8, 0.2, 1) backwards;
}

.lib-col__cover {
  height: 262px;
  transform: rotate(-3deg);
}

.lib-col__eyebrow {
  color: var(--book);
}

[data-theme="dark"] .lib-col__eyebrow {
  color: color-mix(in srgb, var(--book) 55%, #fff);
}

.lib-col__title {
  margin: 8px 0 8px;
  font-size: clamp(24px, 3.2vw, 34px);
  font-weight: 900;
  line-height: 1.12;
  letter-spacing: -0.015em;
  color: var(--color-text);
}

.lib-col__desc {
  max-width: 640px;
  margin-bottom: 12px;
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--color-text-muted);
}

.lib-col__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}

.lib-col__chips span {
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--color-bg-alt);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--color-text-muted);
}

.lib-col__chips .lib-col__chip--ok {
  background: color-mix(in srgb, #1fb774 14%, transparent);
  color: #12925a;
}

.lib-col__chips .lib-col__chip--warn {
  background: color-mix(in srgb, #f59e0b 16%, transparent);
  color: #b26b00;
}

[data-theme="dark"] .lib-col__chips .lib-col__chip--ok {
  color: #3fd08f;
}

[data-theme="dark"] .lib-col__chips .lib-col__chip--warn {
  color: #ffc15c;
}

.lib-col__progress {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 460px;
  margin-top: 18px;
}

.lib-col__progress .lib-book__progress {
  flex: 1;
}

.lib-col__progress small {
  flex-shrink: 0;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--color-text-muted);
}

.lib-col__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.lib-col__actions .btn {
  gap: 8px;
  height: 46px;
  padding: 0 22px;
  font-size: 14.5px;
  font-weight: 800;
}

.lib-col__actions .btn svg {
  width: 17px;
  height: 17px;
}

.lib-col-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.lib-parts {
  display: flex;
  gap: 6px;
  padding: 4px;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: var(--color-white);
  overflow-x: auto;
  scrollbar-width: none;
}

.lib-parts::-webkit-scrollbar {
  display: none;
}

.lib-part {
  flex-shrink: 0;
  height: 36px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  font: inherit;
  font-size: 13.5px;
  font-weight: 750;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.lib-part i {
  font-style: normal;
  opacity: 0.65;
}

.lib-part.is-active {
  background: var(--color-text);
  color: var(--color-bg);
}

.lib-search--sm {
  flex: 0 1 300px;
}

.lib-search--sm input {
  height: 44px;
}

.lib-part-title {
  margin: 22px 4px 12px;
  font-size: 13px;
  font-weight: 850;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.lib-part-title:first-child {
  margin-top: 4px;
}

.lib-tickets {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 10px;
  list-style: none;
  padding: 0;
  margin: 0;
}

/* ---------------- Читалка ---------------- */
.lib-reader-bar {
  position: sticky;
  top: 86px;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  padding: 8px 10px 8px 8px;
  border-radius: 20px;
  border: 1px solid var(--color-border);
  background: color-mix(in srgb, var(--color-white) 97%, transparent);
  box-shadow: 0 10px 30px -24px rgba(12, 14, 40, 0.6);
  animation: libIn 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) backwards;
}

.lib-reader-bar__back {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: var(--color-bg-alt);
}

.lib-reader-bar__back svg {
  width: 20px;
  height: 20px;
}

.lib-reader-bar__title {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.lib-reader-bar__title span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11.5px;
  font-weight: 750;
  letter-spacing: 0.02em;
  color: var(--color-text-muted);
}

.lib-reader-bar__title b {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14.5px;
  font-weight: 850;
  color: var(--color-text);
}

.lib-reader-bar__tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.lib-font {
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: 14px;
  background: var(--color-bg-alt);
}

.lib-tool {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 38px;
  height: 38px;
  padding: 0 10px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  font: inherit;
  font-size: 15px;
  font-weight: 850;
  color: var(--color-text);
  cursor: pointer;
  transition: background 0.2s ease, opacity 0.2s ease, transform 0.2s ease;
}

.lib-tool:hover:not(:disabled) {
  background: var(--color-white);
}

.lib-tool:active:not(:disabled) {
  transform: scale(0.92);
}

.lib-tool:disabled {
  opacity: 0.35;
  cursor: default;
}

.lib-tool small {
  font-size: 12px;
}

.lib-tool svg {
  width: 18px;
  height: 18px;
}

.lib-tool--toc {
  display: none;
  background: var(--color-bg-alt);
  font-size: 13.5px;
}

.lib-tool--toc[hidden] {
  display: none !important;
}

.lib-reader-bar__progress {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: -1px;
  height: 3px;
  border-radius: 3px;
  overflow: hidden;
  pointer-events: none;
}

.lib-reader-bar__progress i {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--book, var(--color-primary)), #8c54ff);
  transform: scaleX(0);
  transform-origin: left center;
}

.lib-reader {
  display: grid;
  grid-template-columns: minmax(0, 820px);
  justify-content: center;
  gap: 28px;
  align-items: start;
}

.lib-reader.has-toc {
  grid-template-columns: 250px minmax(0, 820px);
}

.lib-toc {
  position: sticky;
  top: 164px;
  max-height: calc(100vh - 184px);
  overflow-y: auto;
  padding: 16px 12px 16px 14px;
  border-radius: 22px;
  border: 1px solid var(--color-border);
  background: var(--color-white);
  scrollbar-width: thin;
}

.lib-reader:not(.has-toc) .lib-toc {
  display: none;
}

.lib-toc__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 4px 10px;
}

.lib-toc__head b {
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.lib-toc__close {
  display: none;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 12px;
  background: var(--color-bg-alt);
  color: var(--color-text);
  cursor: pointer;
}

.lib-toc__close svg {
  width: 18px;
  height: 18px;
}

.lib-toc__list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.lib-toc__list a {
  display: flex;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 12px;
  font-size: 13.5px;
  font-weight: 650;
  line-height: 1.4;
  color: var(--color-text-muted);
  text-decoration: none;
  transition: background 0.2s ease, color 0.2s ease;
}

.lib-toc__list a span {
  flex-shrink: 0;
  min-width: 30px;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
  color: color-mix(in srgb, var(--book, var(--color-primary)) 80%, var(--color-text-muted));
}

.lib-toc__list a:hover {
  background: var(--color-bg-alt);
  color: var(--color-text);
}

.lib-toc__list a.is-active {
  background: color-mix(in srgb, var(--book, var(--color-primary)) 12%, transparent);
  color: var(--color-text);
}

.lib-toc-backdrop {
  display: none;
}

/* Лист билета */
.lib-paper {
  --lib-fs: 16.5px;
  position: relative;
  min-width: 0;
  padding: 44px 56px 34px;
  border-radius: 26px;
  border: 1px solid var(--color-border);
  background: var(--color-white);
  box-shadow: 0 30px 60px -48px rgba(12, 14, 40, 0.55);
  overflow: hidden;
  font-size: var(--lib-fs);
  line-height: 1.72;
  color: var(--color-text);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.lib-paper::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 5px;
  background: linear-gradient(90deg, var(--book, var(--color-primary)), #8c54ff);
}

.lib-watermark {
  position: absolute;
  inset: 0;
  z-index: 3;
  background-repeat: repeat;
  background-size: 420px 240px;
  pointer-events: none;
}

.lib-paper__body.is-entering {
  animation: libIn 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) backwards;
}

.lib-paper__loading {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.lib-line {
  height: 14px;
  border-radius: 8px;
  background: var(--color-bg-alt);
  animation: libPulse 1.3s ease-in-out infinite;
}

.lib-line--kicker {
  width: 32%;
  height: 12px;
}

.lib-line--title {
  width: 70%;
  height: 30px;
  margin-bottom: 14px;
}

.lib-line--short {
  width: 58%;
  margin-bottom: 10px;
}

.lib-paper__head {
  margin-bottom: 26px;
  padding-bottom: 22px;
  border-bottom: 1px dashed var(--color-border);
}

.lib-paper__kicker {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
}

.lib-paper__dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--book, var(--color-primary));
}

.lib-paper__num {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  margin-top: 16px;
  padding: 5px 12px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--book, var(--color-primary)) 12%, transparent);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--book, var(--color-primary));
}

[data-theme="dark"] .lib-paper__num {
  color: color-mix(in srgb, var(--book, var(--color-primary)) 55%, #fff);
}

.lib-paper__num small {
  font-size: 11px;
  font-weight: 700;
  opacity: 0.7;
  text-transform: none;
  letter-spacing: 0;
}

.lib-paper__title {
  margin: 12px 0 14px;
  font-size: clamp(24px, 1.7em, 34px);
  font-weight: 900;
  line-height: 1.16;
  letter-spacing: -0.015em;
  text-wrap: balance;
}

.lib-paper__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--color-text-muted);
}

.lib-paper__protected {
  color: #12925a;
}

[data-theme="dark"] .lib-paper__protected {
  color: #3fd08f;
}

.lib-paper__notice {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  padding: 11px 14px;
  border-radius: 14px;
  background: color-mix(in srgb, #f59e0b 12%, transparent);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.5;
  color: #9a5b00;
}

[data-theme="dark"] .lib-paper__notice {
  color: #ffc15c;
}

.lib-paper__notice svg {
  flex-shrink: 0;
  width: 17px;
  height: 17px;
  margin-top: 1px;
}

/* ---- Типографика билета ---- */
.lib-content {
  overflow-wrap: break-word;
}

.lib-content p {
  margin: 0 0 0.75em;
  color: inherit;
}

.lib-content td,
.lib-content th,
.lib-content li,
.lib-footnotes p {
  color: inherit;
}

.lib-content h1,
.lib-content h2,
.lib-content h3,
.lib-content h4,
.lib-content h5 {
  scroll-margin-top: 180px;
  color: var(--color-text);
  text-wrap: balance;
}

.lib-content h2 {
  position: relative;
  margin: 1.9em 0 0.75em;
  padding-left: 16px;
  font-size: 1.3em;
  font-weight: 900;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.lib-content h2::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.12em;
  bottom: 0.12em;
  width: 5px;
  border-radius: 3px;
  background: var(--book, var(--color-primary));
}

.lib-content > h2:first-child {
  margin-top: 0.4em;
}

.lib-content h3 {
  margin: 1.5em 0 0.55em;
  font-size: 1.1em;
  font-weight: 850;
  line-height: 1.3;
}

.lib-content h4,
.lib-content h5 {
  margin: 1.3em 0 0.5em;
  font-size: 1em;
  font-weight: 850;
  line-height: 1.35;
  color: color-mix(in srgb, var(--color-text) 80%, var(--book, var(--color-primary)));
}

.lib-content .b,
.lib-content b,
.lib-content strong {
  font-weight: 800;
}

.lib-content .i,
.lib-content em {
  font-style: italic;
}

.lib-content .u {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.lib-content .c-red {
  color: #d22f45;
}

.lib-content .c-green {
  color: #0f8a55;
}

.lib-content .c-blue {
  color: #2f55e0;
}

.lib-content .c-link {
  color: var(--color-primary);
  text-decoration-color: color-mix(in srgb, var(--color-primary) 45%, transparent);
}

[data-theme="dark"] .lib-content .c-red {
  color: #ff7086;
}

[data-theme="dark"] .lib-content .c-green {
  color: #44d494;
}

[data-theme="dark"] .lib-content .c-blue,
[data-theme="dark"] .lib-content .c-link {
  color: #8fa6ff;
}

.lib-content .yl,
.lib-content mark {
  background: color-mix(in srgb, #ffd60a 32%, transparent);
  color: inherit;
}

/* Цветные выделения из конспектов: зелёный, голубой, красный, сиреневый, синий. */
.lib-content mark.hl-g { background: color-mix(in srgb, #2fb344 22%, transparent); }
.lib-content mark.hl-b { background: color-mix(in srgb, #12b5e5 22%, transparent); }
.lib-content mark.hl-r { background: color-mix(in srgb, #ff4d4f 22%, transparent); }
.lib-content mark.hl-v { background: color-mix(in srgb, #8c54ff 20%, transparent); }
.lib-content mark.hl-s { background: color-mix(in srgb, #3d5afe 14%, transparent); }

.lib-content a {
  color: var(--color-primary);
}

.lib-content .li {
  margin: 0.28em 0;
  text-indent: -1.4em;
}

.lib-content .in-li {
  margin-left: calc(min(var(--in, 0), 90) * 0.85pt + 1.4em);
}

.lib-content .in-p {
  margin-left: min(calc(var(--in, 0) * 0.8pt), 18%);
}

.lib-content ul,
.lib-content ol {
  margin: 0.4em 0 0.9em;
  padding-left: 1.5em;
}

.lib-content li {
  margin: 0.25em 0;
}

.lib-content sup,
.lib-content .fn-ref {
  font-size: 0.7em;
  font-weight: 800;
  line-height: 0;
  color: var(--color-primary);
}

.lib-content .fn {
  font-size: 0.86em;
  font-weight: 550;
  font-style: normal;
  color: var(--color-text-muted);
}

.lib-content .fn::before {
  content: " [";
}

.lib-content .fn::after {
  content: "]";
}

.lib-content hr {
  margin: 1.6em 0;
  border: 0;
  border-top: 1px dashed var(--color-border);
}

.lib-content pre {
  margin: 1.2em 0;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid var(--color-border);
  background: color-mix(in srgb, var(--color-text) 5%, transparent);
  overflow-x: auto;
  text-indent: 0;
  white-space: pre;
  tab-size: 2;
}

.lib-content pre code,
.lib-content code {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 0.88em;
  color: var(--color-text);
}

.lib-content code:not(pre code) {
  padding: 0.1em 0.4em;
  border-radius: 6px;
  background: color-mix(in srgb, var(--color-text) 8%, transparent);
}

/* Врезки: нормы и практика / лектор и доктрина / внимание. */
.lib-content .callout,
.lib-content blockquote {
  --accent: #3d5afe;
  margin: 1.2em 0;
  padding: 14px 18px 12px;
  border-radius: 16px;
  border: 1px solid color-mix(in srgb, var(--accent) 26%, transparent);
  background: color-mix(in srgb, var(--accent) 7%, transparent);
  text-indent: 0;
}

.lib-content .callout.note,
.lib-content blockquote {
  --accent: #8c54ff;
}

.lib-content .callout.warn {
  --accent: #f08c00;
}

.lib-content .callout > :last-child,
.lib-content blockquote > :last-child {
  margin-bottom: 0;
}

.lib-content .callout__label {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 6px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.1em;
  line-height: 1.4;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--accent) 85%, var(--color-text));
}

.lib-content .callout__label::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}

[data-theme="dark"] .lib-content .callout__label {
  color: color-mix(in srgb, var(--accent) 55%, #fff);
}

.lib-content .bt {
  margin-bottom: 0.35em;
}

/* Таблицы */
.lib-table {
  margin: 1.2em 0;
  overflow-x: auto;
  border-radius: 14px;
  border: 1px solid var(--color-border);
  -webkit-overflow-scrolling: touch;
}

.lib-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9em;
  line-height: 1.5;
}

.lib-table th,
.lib-table td {
  padding: 9px 11px;
  border: 1px solid var(--color-border);
  vertical-align: top;
  text-align: left;
  text-indent: 0;
}

.lib-table tr:first-child th,
.lib-table tr:first-child td {
  border-top: 0;
}

.lib-table tr > :first-child {
  border-left: 0;
}

.lib-table tr > :last-child {
  border-right: 0;
}

.lib-table tr:last-child > * {
  border-bottom: 0;
}

.lib-table th {
  background: var(--color-bg-alt);
  font-weight: 850;
}

.lib-table td.g {
  background: color-mix(in srgb, #1fb774 8%, transparent);
}

.lib-table td.yl {
  background: color-mix(in srgb, #ffd60a 16%, transparent);
}

.lib-table p {
  margin: 0 0 0.35em;
}

.lib-table p:last-child {
  margin-bottom: 0;
}

/* Схемы */
.lib-figure {
  position: relative;
  width: fit-content;
  max-width: 100%;
  margin: 1.3em auto;
  padding: 8px;
  border-radius: 16px;
  border: 1px solid var(--color-border);
  background: #fff;
  cursor: zoom-in;
  text-indent: 0;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.lib-figure:hover {
  box-shadow: 0 18px 34px -26px rgba(12, 14, 40, 0.7);
}

.lib-figure:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--color-primary) 50%, transparent);
  outline-offset: 3px;
}

.lib-figure img {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 10px;
  pointer-events: none;
  -webkit-user-drag: none;
  user-select: none;
}

.lib-figure__zoom {
  position: absolute;
  right: 14px;
  bottom: 14px;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: rgba(15, 17, 30, 0.62);
  color: #fff;
  opacity: 0;
  transform: scale(0.9);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.lib-figure__zoom svg {
  width: 18px;
  height: 18px;
}

.lib-figure:hover .lib-figure__zoom,
.lib-figure:focus-visible .lib-figure__zoom {
  opacity: 1;
  transform: none;
}

@media (hover: none) {
  .lib-figure__zoom {
    opacity: 0.9;
    transform: none;
  }
}

/* Сноски */
.lib-footnotes {
  margin-top: 32px;
  padding-top: 18px;
  border-top: 1px dashed var(--color-border);
  font-size: 0.86em;
  line-height: 1.6;
  color: var(--color-text-muted);
}

.lib-footnotes h3 {
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.lib-footnotes ol {
  margin: 0;
  padding-left: 1.6em;
}

.lib-footnotes li {
  margin: 0.3em 0;
}

/* Низ листа */
.lib-paper__foot {
  margin-top: 36px;
  padding-top: 22px;
  border-top: 1px dashed var(--color-border);
}

.lib-paper__done {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 20px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--color-text-muted);
}

.lib-paper__done-icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px dashed var(--color-border);
  color: transparent;
  transition: background 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

.lib-paper__done-icon svg {
  width: 16px;
  height: 16px;
}

.lib-paper__done.is-done {
  color: #12925a;
}

[data-theme="dark"] .lib-paper__done.is-done {
  color: #3fd08f;
}

.lib-paper__done.is-done .lib-paper__done-icon {
  border-color: transparent;
  background: #1fb774;
  color: #fff;
  animation: libPop 0.45s cubic-bezier(0.3, 1.6, 0.5, 1);
}

@keyframes libPop {
  from {
    transform: scale(0.5);
  }
}

.lib-pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.lib-pager__link {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid var(--color-border);
  background: var(--color-bg-alt);
  color: inherit;
  text-decoration: none;
  line-height: 1.35;
  transition: transform 0.25s cubic-bezier(0.3, 1.4, 0.5, 1), border-color 0.2s ease;
}

.lib-pager__link:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--book, var(--color-primary)) 45%, var(--color-border));
}

.lib-pager__link small {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.lib-pager__link small svg {
  width: 14px;
  height: 14px;
}

.lib-pager__link b {
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  font-size: 14px;
  font-weight: 800;
  color: var(--color-text);
}

.lib-pager__link--next {
  align-items: flex-end;
  text-align: right;
}

.lib-paper__index {
  margin-top: 14px;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--color-text-muted);
}

/* ---------------- Окно «нужен тариф» ---------------- */
.lib-modal {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: grid;
  place-items: center;
  padding: 20px;
}

.lib-modal[hidden] {
  display: none;
}

.lib-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 12, 24, 0.55);
  opacity: 0;
  transition: opacity 0.22s ease;
}

.lib-modal__card {
  position: relative;
  width: min(420px, 100%);
  padding: 30px 26px 24px;
  border-radius: 28px;
  border: 1px solid var(--color-border);
  background: var(--color-white);
  box-shadow: 0 40px 80px -30px rgba(10, 12, 30, 0.6);
  opacity: 0;
  transform: translateY(16px) scale(0.97);
  transition: opacity 0.22s ease, transform 0.3s cubic-bezier(0.3, 1.3, 0.5, 1);
}

.lib-modal.is-open .lib-modal__backdrop {
  opacity: 1;
}

.lib-modal.is-open .lib-modal__card {
  opacity: 1;
  transform: none;
}

.lib-modal__close {
  position: absolute;
  top: 14px;
  right: 14px;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 12px;
  background: var(--color-bg-alt);
  color: var(--color-text);
  cursor: pointer;
}

.lib-modal__close svg {
  width: 18px;
  height: 18px;
}

.lib-lock {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.lib-lock__icon {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin-bottom: 14px;
  border-radius: 22px;
  color: #fff;
  background: linear-gradient(145deg, var(--book, #a47bff), var(--book-2, #6a3df0));
  box-shadow: 0 16px 30px -16px color-mix(in srgb, var(--book-2, #6a3df0) 90%, #000);
  transform: rotate(-6deg);
}

.lib-lock__icon svg {
  width: 28px;
  height: 28px;
}

.lib-lock h2 {
  font-size: 21px;
  font-weight: 900;
  line-height: 1.2;
  color: var(--color-text);
}

.lib-lock__item {
  margin-top: 8px;
  padding: 6px 12px;
  border-radius: 10px;
  background: var(--color-bg-alt);
  font-size: 13px;
  font-weight: 700;
  color: var(--color-text);
}

.lib-lock__text {
  margin-top: 10px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--color-text-muted);
}

.lib-lock__list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  margin: 16px 0 18px;
  padding: 14px 16px;
  border-radius: 16px;
  background: var(--color-bg-alt);
  list-style: none;
  text-align: left;
}

.lib-lock__list li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--color-text);
}

.lib-lock__list svg {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  color: #1fb774;
}

.lib-lock__actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.lib-lock__actions .btn {
  height: 46px;
  font-weight: 800;
}

body.lib-modal-open {
  overflow: hidden;
}

/* ---------------- Схема на весь экран ---------------- */
.lib-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1200;
  background: rgba(8, 10, 20, 0.9);
  opacity: 0;
  transition: opacity 0.2s ease;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.lib-lightbox[hidden] {
  display: none;
}

.lib-lightbox.is-open {
  opacity: 1;
}

.lib-lightbox__stage {
  position: absolute;
  inset: 64px 16px 24px;
  cursor: zoom-out;
}

.lib-lightbox__img {
  width: 100%;
  height: 100%;
  border-radius: 14px;
  background-color: #fff;
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  transform: scale(0.96);
  transition: transform 0.25s cubic-bezier(0.3, 1.3, 0.5, 1);
}

.lib-lightbox.is-open .lib-lightbox__img {
  transform: none;
}

.lib-lightbox__close {
  position: absolute;
  top: 14px;
  right: 16px;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  cursor: pointer;
}

.lib-lightbox__close svg {
  width: 20px;
  height: 20px;
}

/* ---------------- Тост ---------------- */
.lib-toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  z-index: 1300;
  max-width: calc(100vw - 32px);
  padding: 12px 18px;
  border-radius: 16px;
  background: #151827;
  color: #fff;
  font-size: 13.5px;
  font-weight: 700;
  line-height: 1.4;
  text-align: center;
  box-shadow: 0 18px 40px -18px rgba(0, 0, 0, 0.6);
  opacity: 0;
  transform: translate(-50%, 10px);
  transition: opacity 0.22s ease, transform 0.3s cubic-bezier(0.3, 1.3, 0.5, 1);
  pointer-events: none;
}

[data-theme="dark"] .lib-toast {
  background: #f1f3fb;
  color: #151827;
}

.lib-toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------------- Адаптив ---------------- */
@media (max-width: 1080px) {
  .lib-reader.has-toc {
    grid-template-columns: minmax(0, 820px);
  }

  .lib-tool--toc {
    display: inline-flex;
  }

  .lib-toc {
    position: fixed;
    inset: auto 0 0;
    z-index: 1001;
    max-height: min(70vh, 560px);
    padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
    border-radius: 26px 26px 0 0;
    border-bottom: 0;
    box-shadow: 0 -24px 60px -30px rgba(10, 12, 30, 0.6);
    transform: translateY(105%);
    transition: transform 0.32s cubic-bezier(0.3, 1.1, 0.5, 1);
  }

  .lib-reader:not(.has-toc) .lib-toc {
    display: block;
    visibility: hidden;
  }

  .lib-toc.is-open {
    transform: none;
  }

  .lib-toc__close {
    display: grid;
  }

  .lib-toc-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: block;
    background: rgba(10, 12, 24, 0.45);
    animation: libFade 0.2s ease;
  }

  .lib-toc-backdrop[hidden] {
    display: none;
  }

  body.lib-toc-open {
    overflow: hidden;
  }
}

@keyframes libFade {
  from {
    opacity: 0;
  }
}

@media (max-width: 860px) {
  .lib-hero__art {
    display: none;
  }

  .lib-access {
    flex-wrap: wrap;
  }

  .lib-access__text {
    flex-basis: calc(100% - 62px);
  }

  .lib-access__actions {
    width: 100%;
  }

  .lib-access__limit {
    margin-left: 62px;
  }

  .lib-access__actions .btn {
    flex: 1;
  }

  .lib-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .lib-search {
    flex-basis: auto;
  }

  .lib-col {
    grid-template-columns: 130px 1fr;
    gap: 22px;
    padding: 20px;
  }

  .lib-col__cover {
    height: 176px;
    padding: 14px 12px 12px 24px;
  }

  .lib-col__cover .lib-book__name {
    font-size: 17px;
  }

  .lib-col__cover .lib-book__emblem {
    font-size: 100px;
  }

  .lib-col-tools {
    flex-direction: column;
    align-items: stretch;
  }

  .lib-col-tools > span:empty {
    display: none;
  }

  .lib-search--sm {
    flex-basis: auto;
  }

  .lib-results__list,
  .lib-tickets {
    grid-template-columns: minmax(0, 1fr);
  }

  .lib-paper {
    padding: 34px 30px 28px;
  }
}

@media (max-width: 560px) {
  .lib-page {
    padding-top: 20px;
  }

  .lib-shelf {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px 14px;
  }

  .lib-book__cover {
    height: 190px;
    padding: 14px 12px 12px 26px;
    border-radius: 6px 16px 16px 6px;
  }

  .lib-book__spine {
    width: 14px;
  }

  .lib-book__name {
    font-size: 17px;
    max-width: 100%;
  }

  .lib-book__author {
    font-size: 12px;
  }

  .lib-book__count b {
    font-size: 21px;
  }

  .lib-book__emblem {
    font-size: 110px;
    right: 8px;
  }

  .lib-book__lock {
    top: 10px;
    right: 10px;
    width: 28px;
    height: 28px;
    border-radius: 10px;
  }

  .lib-book__lock svg {
    width: 14px;
    height: 14px;
  }

  .lib-book__info h3 {
    font-size: 14px;
  }

  .lib-access {
    padding: 14px 16px;
  }

  .lib-access__icon {
    width: 40px;
    height: 40px;
    border-radius: 13px;
  }

  .lib-col {
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
    padding: 18px;
    text-align: left;
  }

  .lib-col__cover {
    display: none;
  }

  .lib-col__actions .btn {
    flex: 1;
  }

  .lib-col__progress {
    max-width: none;
  }

  .lib-ticket {
    gap: 12px;
    padding: 12px 12px 12px 12px;
  }

  .lib-ticket__num,
  .lib-result__num {
    width: 40px;
    height: 40px;
    border-radius: 13px;
    font-size: 15px;
  }

  .lib-reader-bar {
    top: 84px;
    gap: 8px;
    padding: 6px;
    border-radius: 18px;
  }

  .lib-reader-bar__back {
    width: 38px;
    height: 38px;
    border-radius: 12px;
  }

  .lib-reader-bar__title span {
    display: none;
  }

  .lib-reader-bar__title b {
    font-size: 13.5px;
  }

  .lib-tool {
    min-width: 34px;
    height: 34px;
    padding: 0 8px;
  }

  .lib-tool--toc span {
    display: none;
  }

  .lib-paper {
    --lib-fs: 16px;
    margin: 0 -8px;
    padding: 28px 18px 24px;
    border-radius: 22px;
  }

  .lib-content h2 {
    padding-left: 13px;
  }

  .lib-content .in-li {
    margin-left: calc(min(var(--in, 0), 60) * 0.42pt + 1.3em);
  }

  .lib-content .li {
    text-indent: -1.3em;
  }

  .lib-content .in-p {
    margin-left: min(calc(var(--in, 0) * 0.4pt), 10%);
  }

  .lib-content .callout,
  .lib-content blockquote {
    margin-left: -4px;
    margin-right: -4px;
    padding: 12px 14px 10px;
  }

  .lib-table table {
    min-width: 520px;
  }

  .lib-pager {
    grid-template-columns: minmax(0, 1fr);
  }

  .lib-pager__link--next {
    align-items: flex-start;
    text-align: left;
  }

  .lib-modal {
    align-items: end;
    padding: 0;
  }

  .lib-modal__card {
    width: 100%;
    padding: 28px 20px calc(20px + env(safe-area-inset-bottom));
    border-radius: 28px 28px 0 0;
    transform: translateY(40px);
  }

  .lib-lightbox__stage {
    inset: 64px 8px 16px;
  }
}

@media (max-width: 760px) {
  body.has-tabbar .lib-toast {
    bottom: calc(92px + env(safe-area-inset-bottom));
  }
}

@media (prefers-reduced-motion: reduce) {
  .lib-hero,
  .lib-hero__art,
  .lib-access,
  .lib-toolbar,
  .lib-col,
  .lib-empty,
  .lib-reader-bar,
  .lib-skeleton,
  .lib-line,
  .lib-paper__body.is-entering,
  .lib-paper__done.is-done .lib-paper__done-icon {
    animation: none !important;
  }

  .lib-book__cover,
  .lib-ticket,
  .lib-result,
  .lib-toc,
  .lib-modal__card,
  .lib-lightbox__img {
    transition: none !important;
  }
}

/* Печать библиотеки отключена: вместо билета — пояснение. */
@media print {
  body > * {
    display: none !important;
  }

  body::before {
    content: "Материалы библиотеки LexPrep доступны только для чтения на сайте lexprep.ru.";
    display: block;
    padding: 48px;
    font: 600 16px/1.5 Arial, sans-serif;
    color: #000;
  }
}
