*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --fs: 18px;
  --serif: "Lora", Georgia, "Times New Roman", serif;
  --bg: #ece3d2; /* тёплая бумага — фон страницы */
  --bg2: #faf5ea; /* кремовая поверхность карточек */
  --bg3: #e2d6bf; /* плейсхолдеры / разделители / полосы */
  --text: #2e2820; /* тёплый «сепия-чёрный» */
  --text2: #6f6450; /* тёплый серо-коричневый */
  --accent: #9a3412; /* кирпично-коричневый — ссылки/CTA */
  --accent-light: #f3e6dc;
  --green: #3f6212; /* приглушённый оливковый — скачать */
  --green-light: #e9efdb;
  --red: #b3261e;
  --red-light: #f6e2df;
  --amber: #8a5a07; /* охра — закладка/полка */
  --amber-light: #f4ead2;
  --border: #d6c6a8; /* тёплая граница */
  --radius: 14px;
  --shadow-card:
    0 1px 2px rgba(74, 56, 30, 0.07), 0 6px 16px rgba(74, 56, 30, 0.05);
  --shadow-modal: 0 -6px 40px rgba(74, 56, 30, 0.2);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

html {
  font-size: var(--fs);
}

body {
  font-family:
    "Inter",
    -apple-system,
    BlinkMacSystemFont,
    system-ui,
    sans-serif;
  background-color: var(--bg);
  background-image:
    radial-gradient(
      circle at 18% 12%,
      rgba(255, 251, 240, 0.55),
      transparent 42%
    ),
    radial-gradient(
      circle at 88% 88%,
      rgba(196, 178, 142, 0.22),
      transparent 48%
    );
  background-attachment: fixed;
  color: var(--text);
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation; /* отключает зум двойным тапом */
}

/* === SVG ICON SYSTEM === */
.icon-svg {
  display: inline-block;
  width: 1em;
  height: 1em;
  vertical-align: -0.125em;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* === HEADER === */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  /* верхний отступ закрывает зону статус-бара (вырез/чёлку) непрозрачным фоном,
     чтобы при прокрутке там не мелькал контент */
  padding: calc(10px + env(safe-area-inset-top, 0px)) 14px 10px;
  box-shadow: 0 1px 4px rgba(28, 28, 40, 0.04);
}

.header-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.logo {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.03em;
}

.stats-badge {
  font-size: 0.72rem;
  color: var(--text2);
  margin-left: auto;
  font-weight: 500;
  white-space: nowrap;
}

.font-controls {
  display: flex;
  gap: 6px;
  margin-left: 6px;
  flex-shrink: 0;
}

/* === АДАПТИВ === */
@media (max-width: 600px) {
  .header {
    padding: calc(8px + env(safe-area-inset-top, 0px)) 10px 8px;
  }
  .header-top {
    gap: 6px;
    margin-bottom: 8px;
  }
  .logo {
    font-size: 1.1rem;
  }
  .stats-badge {
    display: none; /* «N книг» уезжает; место под кнопки */
  }
  .font-controls {
    gap: 4px;
    margin-left: auto;
  }
  .font-btn {
    width: 40px;
    height: 40px;
    font-size: 16px;
    border-radius: 10px;
  }
  .search-row {
    gap: 6px;
    padding: 8px 10px;
  }
  .search-input {
    padding: 11px 14px;
    font-size: 0.95rem;
  }
  #searchBtn {
    padding: 10px 16px;
    min-width: 0;
  }
  .tab {
    font-size: 0.92rem;
    padding: 12px 4px;
    gap: 5px;
  }
  /* иконки на мобиле прячем — подписи и так понятны, освобождаем место */
  .tab .icon-svg {
    display: none;
  }
  /* «Продолжить чтение» — компактнее на мобиле */
  .continue-card {
    gap: 10px;
    padding: 10px 12px;
    min-height: 0;
  }
  .continue-cover {
    width: 46px;
    height: 66px;
  }
  .continue-label {
    font-size: 0.72rem;
  }
  .continue-title {
    font-size: 1rem;
  }
  .continue-progress {
    font-size: 0.8rem;
  }
  .continue-go {
    min-width: 54px;
    padding: 9px 8px;
    font-size: 0.72rem;
  }
  .continue-go svg {
    width: 19px;
    height: 19px;
  }
}
/* Очень узкие экраны (≤360px): ещё компактнее подписи вкладок */
@media (max-width: 360px) {
  .tab {
    font-size: 0.86rem;
  }
}
@media (min-width: 601px) and (max-width: 820px) {
  .stats-badge {
    font-size: 0.68rem;
    max-width: 90px;
    line-height: 1.2;
  }
  .font-btn {
    width: 44px;
    height: 44px;
    font-size: 17px;
  }
}
.font-btn {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-weight: 800;
  font-size: 19px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    transform 0.15s var(--ease),
    background 0.15s;
}
.font-btn:active {
  transform: scale(0.94);
  background: var(--bg3);
}

.search-row {
  display: flex;
  gap: 8px;
  padding: 10px 14px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
}
.search-field {
  position: relative;
  flex: 1;
  min-width: 0; /* даёт полю сжиматься, иначе кнопка «Найти» выносится за край */
  display: flex;
}
.search-field .search-input {
  flex: 1;
  padding-right: 46px;
}
.search-input::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
}
.search-clear {
  position: absolute;
  right: 7px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--bg3);
  color: var(--text2);
  font-size: 22px;
  line-height: 1;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    background 0.15s,
    color 0.15s,
    transform 0.12s var(--ease);
}
.search-clear:active {
  background: var(--accent);
  color: #fff;
  transform: translateY(-50%) scale(0.9);
}
.logo {
  cursor: pointer;
}

.search-input {
  flex: 1;
  min-width: 0; /* поле сжимается ниже интринзик-ширины → кнопка «Найти» не выпирает */
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 1rem;
  font-family: inherit;
  color: var(--text);
  outline: none;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
}
.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(29, 106, 229, 0.12);
}
.search-input::placeholder {
  color: var(--text2);
}

.btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 12px 22px;
  font-size: 1rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  min-height: 48px;
  min-width: 48px;
  transition:
    transform 0.12s var(--ease),
    opacity 0.15s;
}
.btn:active {
  transform: scale(0.97);
}

.btn-outline {
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text);
  font-weight: 600;
  box-shadow: var(--shadow-card);
}
.btn-outline:active {
  transform: scale(0.97);
  background: var(--bg3);
}

/* === TABS === */
.tabs {
  display: flex;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
}
.tab {
  flex: 1;
  min-width: 0; /* равные доли, можно ужиматься на узких экранах */
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap; /* иконка и подпись держатся в одну строку */
  padding: 14px 6px;
  font-size: 1rem;
  font-weight: 700;
  font-family: inherit;
  color: var(--text2);
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  min-height: 52px;
  transition:
    color 0.2s,
    background 0.2s;
}
.tab .icon-svg {
  flex-shrink: 0;
}
.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: var(--accent-light);
}
.tab:active {
  background: var(--bg3);
}
.tab .tab-count {
  display: none; /* счётчики на вкладках убраны по просьбе — место под подписи */
}


/* === SORT BAR === */
.sort-bar {
  display: none;
  gap: 6px;
  padding: 8px 14px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  align-items: center;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.sort-bar::-webkit-scrollbar {
  display: none;
}
.sort-bar.show {
  display: flex;
}
.sort-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text2);
  white-space: nowrap;
  margin-right: 2px;
}
.sort-btn {
  flex-shrink: 0;
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
  font-family: inherit;
  background: var(--bg);
  color: var(--text2);
  border: 1px solid var(--border);
  cursor: pointer;
  min-height: 36px;
  white-space: nowrap;
  transition:
    transform 0.12s var(--ease),
    background 0.15s;
}
.sort-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.sort-btn:active {
  transform: scale(0.95);
}

/* === LANGUAGE FILTER === */
.filters {
  display: flex;
  gap: 6px;
  padding: 10px 14px;
  overflow-x: auto;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  -webkit-overflow-scrolling: touch;
}
.filters::-webkit-scrollbar {
  display: none;
}


/* === ACTIVE FILTERS BAR === */
.active-filters {
  display: none;
  gap: 8px;
  padding: 10px 14px;
  background: var(--accent-light);
  border-bottom: 1px solid var(--accent);
  flex-wrap: wrap;
  align-items: center;
}
.active-filters.show {
  display: flex;
}
.active-filter-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--bg2);
  border: 1px solid var(--accent);
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  min-height: 40px;
  box-shadow: var(--shadow-card);
}
.active-filter-tag .af-link {
  cursor: pointer;
  text-decoration: underline;
  display: inline-flex;
  align-items: center;
  min-height: 36px;
}
.active-filter-tag .af-link:active {
  opacity: 0.7;
}
.active-filter-tag .remove {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--red-light);
  color: var(--red);
  border: none;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s var(--ease);
}
.active-filter-tag .remove:active {
  transform: scale(0.9);
  background: var(--red);
  color: #fff;
}

/* === AUTHOR PAGE === */
.author-header {
  padding: 18px 14px;
  background: var(--bg2);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
}
.author-name {
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}
.author-stats {
  font-size: 0.85rem;
  color: var(--text2);
  margin-bottom: 12px;
  font-weight: 500;
}
.series-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
}
.series-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  min-height: 50px;
  font-size: 0.9rem;
  font-weight: 600;
  transition:
    transform 0.12s var(--ease),
    background 0.15s;
}
.series-item:active {
  transform: scale(0.98);
  background: var(--bg3);
}
.series-item .cnt {
  color: var(--text2);
  font-size: 0.8rem;
  font-weight: 500;
}

/* === READING PROGRESS === */
.progress-bar {
  height: 5px;
  background: var(--bg3);
  border-radius: 3px;
  margin: 4px 12px 0;
  overflow: hidden;
}
.progress-bar .fill {
  height: 100%;
  width: 100%;
  border-radius: 3px;
  transform-origin: left;
  /* scaleX вместо width: анимируем только transform (GPU), без layout-thrash */
  transition: transform 0.4s var(--ease);
}
.progress-label {
  font-size: 0.68rem;
  color: var(--text2);
  margin: 2px 12px 6px;
  font-weight: 500;
}
.book-card.read-done {
  border-color: var(--green);
  border-width: 2px;
}

/* === CONTENT === */
.content {
  padding: 10px 12px;
  padding-bottom: calc(24px + var(--safe-bottom));
  max-width: 800px;
  margin: 0 auto;
}

.results-info {
  padding: 10px 4px;
  font-size: 0.85rem;
  color: var(--text2);
  font-weight: 600;
}
.shelf-stats {
  margin-top: 4px;
}
/* Строка «Найдено: N» — наверху раздела, в одном стиле с полкой/закладками */
.results-count {
  font-size: 0.82rem;
  color: var(--text2);
  font-weight: 600;
  margin-bottom: 4px;
  font-variant-numeric: tabular-nums;
}

/* Кнопка «Назад» внутри breadcrumb — аккуратная пилюля с шевроном */
.breadcrumb .back-link {
  font-weight: 600;
  color: var(--accent);
  padding: 5px 12px 5px 9px;
  margin-right: 2px;
  border-radius: 999px;
  background: var(--bg3);
  border: 1px solid var(--border);
  transition:
    background 0.15s,
    transform 0.12s var(--ease);
}
.breadcrumb .back-link:active {
  background: var(--accent-light);
  transform: scale(0.96);
}
.breadcrumb .back-link::before {
  content: "\2039\00a0";
  font-size: 1.15em;
  line-height: 1;
}
/* Лоадер-плашка под breadcrumb пока грузятся книги */
.loading-hint {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--text2);
  margin-top: 4px;
  font-weight: 500;
}
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--bg3);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* === ПРОДОЛЖИТЬ ЧТЕНИЕ === */
.continue-card {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  text-align: left;
  margin: 4px 0 16px;
  padding: 12px 14px;
  background: linear-gradient(135deg, var(--accent-light), var(--bg2));
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  cursor: pointer;
  min-height: 96px;
  font-family: inherit;
  transition:
    transform 0.12s var(--ease),
    box-shadow 0.2s;
}
.continue-card:active {
  transform: scale(0.99);
  box-shadow: none;
}
.continue-cover {
  width: 56px;
  height: 80px;
  flex-shrink: 0;
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg3);
  box-shadow: 0 2px 8px rgba(74, 56, 30, 0.18);
}
.continue-cover .book-cover-ph {
  width: 100%;
  height: 100%;
}
.continue-cover .oc-cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.continue-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.continue-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.continue-label svg {
  width: 16px;
  height: 16px;
}
.continue-title {
  font-family: var(--serif);
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.25;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.continue-progress {
  font-size: 0.85rem;
  color: var(--text2);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.continue-go {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
  color: #fff;
  background: var(--accent);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 0.78rem;
  font-weight: 700;
  min-width: 64px;
}
.continue-go svg {
  width: 22px;
  height: 22px;
}

/* === МОИ ЗАКЛАДКИ === */
.bm-group {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  margin-bottom: 14px;
  overflow: hidden;
}
.bm-book {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--bg3);
}
.bm-book:active {
  background: var(--bg3);
}
.bm-cover {
  width: 40px;
  height: 58px;
  flex-shrink: 0;
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg3);
  box-shadow: var(--shadow-card);
}
.bm-cover .book-cover-ph {
  width: 100%;
  height: 100%;
}
.bm-cover .oc-cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.bm-bookmeta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.bm-booktitle {
  font-family: var(--serif);
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.25;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.bm-bookauthor {
  font-size: 0.85rem;
  color: var(--accent);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bm-items {
  display: flex;
  flex-direction: column;
}
.bm-row {
  padding: 12px 14px;
  border-top: 1px solid var(--bg3);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.bm-row:first-child {
  border-top: none;
}
.bm-snippet {
  font-size: 0.92rem;
  color: var(--text2);
  line-height: 1.45;
  font-style: italic;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.bm-snippet svg {
  width: 16px;
  height: 16px;
  color: var(--amber);
  vertical-align: -2px;
  font-style: normal;
}
.bm-row-actions {
  display: flex;
  gap: 10px;
  align-items: stretch;
}
.bm-continue {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 54px;
  padding: 12px 16px;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition:
    transform 0.12s var(--ease),
    opacity 0.15s;
}
.bm-continue svg {
  width: 20px;
  height: 20px;
}
.bm-continue:active {
  transform: scale(0.98);
  opacity: 0.92;
}
.bm-del {
  flex-shrink: 0;
  width: 54px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.bm-del svg {
  width: 22px;
  height: 22px;
}
.bm-del:active {
  background: var(--red-light);
  color: var(--red);
}

/* === СЕРИЯ ПО ПОРЯДКУ === */
.series-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 10px 12px;
  margin-bottom: 10px;
}
.series-row.done {
  border-color: var(--green);
}
.ser-num {
  flex-shrink: 0;
  min-width: 38px;
  text-align: center;
  font-family: var(--serif);
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.ser-cover {
  width: 46px;
  height: 66px;
  flex-shrink: 0;
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg3);
  box-shadow: var(--shadow-card);
  cursor: pointer;
}
.ser-cover .book-cover-ph {
  width: 100%;
  height: 100%;
}
.ser-cover .book-cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.ser-main {
  flex: 1;
  min-width: 0;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ser-title {
  font-family: var(--serif);
  font-size: 1.02rem;
  font-weight: 700;
  line-height: 1.25;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.ser-st {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text2);
}
.ser-st.done {
  color: var(--green);
}
.ser-st.reading {
  color: var(--amber);
}
.ser-read {
  flex-shrink: 0;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 12px;
  min-width: 64px;
  min-height: 54px;
  border: none;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s var(--ease);
}
.ser-read svg {
  width: 20px;
  height: 20px;
}
.ser-read:active {
  transform: scale(0.97);
}

/* === BOOK GRID === */
.book-list {
  display: block;
}
.book-list.grid-view {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
@media (min-width: 768px) {
  .book-list.grid-view {
    grid-template-columns: 1fr 1fr 1fr;
  }
}
@media (min-width: 1200px) {
  .book-list.grid-view {
    grid-template-columns: 1fr 1fr 1fr 1fr;
  }
}

/* === BOOK CARD (cover-first) === */
.book-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-card);
  transition:
    transform 0.15s var(--ease),
    box-shadow 0.2s;
}
.book-card:active {
  transform: scale(0.98);
  box-shadow: none;
}
.book-card.bookmarked {
  border-color: var(--amber);
}

/* Обложка — большая, во всю ширину карточки */
.book-cover-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 3;
  background: var(--bg3);
  overflow: hidden;
}
.book-cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.book-cover-ph {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text2);
  background: linear-gradient(145deg, var(--bg3) 0%, var(--bg) 100%);
}
.book-cover-ph svg {
  width: 40px;
  height: 40px;
  opacity: 0.3;
}

/* Звезда «на полку» — крупная кнопка поверх обложки */
.cover-star {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: none;
  background: rgba(250, 245, 234, 0.92);
  color: var(--amber);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(74, 56, 30, 0.18);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  transition:
    transform 0.12s var(--ease),
    background 0.15s,
    color 0.15s;
}
.cover-star svg {
  width: 24px;
  height: 24px;
}
.cover-star.on {
  background: var(--amber);
  color: #fff;
}
.cover-star:active {
  transform: scale(0.88);
}

/* Информация под обложкой */
.book-info {
  padding: 12px 14px 10px;
  flex: 1;
  min-width: 0;
  cursor: pointer;
}
.book-title {
  font-size: 1.02rem;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 3px;
  letter-spacing: -0.01em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.book-author {
  font-size: 0.88rem;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.book-meta {
  font-size: 0.8rem;
  color: var(--text2);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* === GENRE CATALOG === */
.genre-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 4px 0;
}
.genre-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 16px;
  cursor: pointer;
  min-height: 76px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  box-shadow: var(--shadow-card);
  transition:
    transform 0.15s var(--ease),
    box-shadow 0.2s;
}
.genre-card:active {
  transform: scale(0.97);
  box-shadow: none;
}
.genre-card .g-icon {
  margin-bottom: 6px;
  color: var(--accent);
}
.genre-card .g-icon svg {
  width: 28px;
  height: 28px;
}
.genre-card .g-name {
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 0;
  font-size: 0.85rem;
  flex-wrap: wrap;
  line-height: 1.3;
  color: var(--text2);
}
.breadcrumb a {
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  border-radius: 8px;
  transition: background 0.15s;
}
.breadcrumb a:active {
  background: var(--accent-light);
}
.breadcrumb .sep {
  color: var(--text2);
  opacity: 0.4;
  display: inline-flex;
  align-items: center;
}
.breadcrumb .current {
  color: var(--text);
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  padding: 2px 2px;
}

/* === CATALOG HEAD + ВСЕ ЖАНРЫ === */
.catalog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.allgenres-btn {
  padding: 10px 16px;
  min-height: 44px;
  font-size: 0.9rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
.allgenres-btn svg {
  width: 18px;
  height: 18px;
}

.allgenres-section {
  margin-bottom: 24px;
}
.allgenres-section h2 {
  font-family: var(--serif);
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 0 0 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.allgenres-section h2 .ag-icon {
  color: var(--accent);
  display: inline-flex;
}
.allgenres-section h2 .ag-icon svg {
  width: 24px;
  height: 24px;
}
.allgenres-section h2 .ag-total {
  margin-left: auto;
  font-family: "Inter", sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text2);
  font-variant-numeric: tabular-nums;
}
.genre-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.genre-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 16px;
  border-radius: 24px;
  background: var(--bg2);
  border: 1px solid var(--border);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  min-height: 48px;
  transition:
    transform 0.12s var(--ease),
    background 0.15s,
    border-color 0.15s;
}
.genre-chip:active {
  transform: scale(0.96);
  background: var(--bg3);
}
.genre-chip .gc-count {
  font-size: 0.78rem;
  color: var(--text2);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

/* === АЛФАВИТНЫЙ УКАЗАТЕЛЬ + ПОДРАЗДЕЛЫ === */
.subg-row,
.alpha-row {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 4px 0;
  margin-bottom: 4px;
  -webkit-overflow-scrolling: touch;
}
.subg-row::-webkit-scrollbar,
.alpha-row::-webkit-scrollbar {
  display: none;
}
.subg {
  flex-shrink: 0;
  padding: 9px 16px;
  min-height: 42px;
  border-radius: 22px;
  border: 1px solid var(--border);
  background: var(--bg2);
  color: var(--text2);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition:
    transform 0.12s var(--ease),
    background 0.15s,
    color 0.15s;
}
.subg.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.subg:active {
  transform: scale(0.96);
}
.alpha {
  flex-shrink: 0;
  min-width: 42px;
  height: 42px;
  padding: 0 8px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg2);
  color: var(--text);
  font-family: inherit;
  font-size: 0.98rem;
  font-weight: 700;
  cursor: pointer;
  transition:
    transform 0.12s var(--ease),
    background 0.15s,
    color 0.15s;
}
.alpha.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.alpha:active {
  transform: scale(0.94);
}

/* === MODAL === */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(28, 28, 40, 0.4);
  z-index: 200;
  align-items: flex-end;
  justify-content: center;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.modal-overlay.open {
  display: flex;
}

.modal {
  background: var(--bg2);
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: 640px;
  max-height: 90dvh;
  overflow-y: auto;
  padding: 16px 18px calc(24px + var(--safe-bottom));
  box-shadow: var(--shadow-modal);
  animation: slideUp 0.3s var(--ease);
}
@keyframes slideUp {
  from {
    transform: translateY(100%);
    opacity: 0.8;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Шапка модалки: ручка + крестик «Закрыть» в правом верхнем углу (виден при прокрутке) */
.modal-bar {
  position: sticky;
  top: 0;
  z-index: 6;
  margin: 0 -18px 6px;
  padding: 10px 18px 6px;
  background: transparent; /* прозрачная: при прокрутке не режет обложку кремовой полосой */
  pointer-events: none;
}
.modal-handle {
  width: 44px;
  height: 4px;
  background: var(--bg3);
  border-radius: 2px;
  margin: 0 auto;
}
.modal-close {
  position: absolute;
  top: 8px;
  right: 12px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg3);
  color: var(--text2);
  border: none;
  pointer-events: auto;
  box-shadow: 0 1px 6px rgba(28, 28, 40, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition:
    transform 0.12s var(--ease),
    background 0.15s,
    color 0.15s;
}
.modal-close svg {
  width: 24px;
  height: 24px;
}
.modal-close:active {
  transform: scale(0.9);
  background: var(--red-light);
  color: var(--red);
}

.modal-header {
  display: flex;
  gap: 16px;
  margin-bottom: 18px;
  align-items: flex-start;
}
.modal-cover {
  width: 150px;
  aspect-ratio: 2 / 3;
  height: auto;
  border-radius: 12px;
  object-fit: cover;
  background: var(--bg3);
  flex-shrink: 0;
  box-shadow: 0 4px 16px rgba(74, 56, 30, 0.18);
}
.modal-title-block {
  flex: 1;
  min-width: 0;
  padding-top: 2px;
}
.modal-title {
  font-family: var(--serif);
  font-size: 1.3rem;
  font-weight: 800;
  line-height: 1.3;
  margin-bottom: 6px;
  letter-spacing: -0.02em;
}
.modal-author {
  font-size: 1.05rem;
  color: var(--accent);
  font-weight: 600;
}
@media (min-width: 768px) {
  .modal-cover {
    width: 180px;
  }
}

.modal-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 10px 0;
  border-bottom: 1px solid var(--bg3);
  font-size: 0.9rem;
  gap: 12px;
}
.modal-row .label {
  color: var(--text2);
  font-weight: 600;
  white-space: nowrap;
}
.modal-row .value {
  text-align: right;
  word-break: break-word;
}

/* Кнопки действий: крупная «Читать», ниже — «Добавить на полку» и «Скачать» */
.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 18px;
}
.modal-actions .btn-row {
  display: flex;
  gap: 10px;
}
.modal-btn {
  flex: 1;
  padding: 14px 12px;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 700;
  font-family: inherit;
  border: none;
  cursor: pointer;
  text-align: center;
  min-height: 54px;
  transition: transform 0.12s var(--ease);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.modal-btn svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}
.modal-btn:active {
  transform: scale(0.97);
}
.modal-btn.read {
  background: var(--accent);
  color: #fff;
}
.modal-btn.read.primary {
  min-height: 64px;
  font-size: 1.18rem;
}
.modal-btn.dl {
  background: var(--green-light);
  color: var(--green);
  border: 1px solid var(--green);
}
.modal-btn.bm {
  background: var(--amber-light);
  color: var(--amber);
  border: 1px solid var(--amber);
}
.modal-btn.bm.active {
  background: var(--amber);
  color: #fff;
  border-color: var(--amber);
}

/* Ссылка «Другие версии этой книги» в карточке */
.other-versions-link {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin-top: 12px;
  padding: 12px 16px;
  min-height: 48px;
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: 12px;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
  transition:
    transform 0.12s var(--ease),
    background 0.15s;
}
.other-versions-link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}
.other-versions-link:active {
  transform: scale(0.98);
  background: var(--bg3);
}

/* Экран выбора версии книги */
.chooser-title {
  font-family: var(--serif);
  font-size: 1.3rem;
  font-weight: 800;
  line-height: 1.3;
  margin-bottom: 6px;
  letter-spacing: -0.02em;
}
.chooser-sub {
  font-size: 0.95rem;
  color: var(--text2);
  line-height: 1.5;
  margin-bottom: 16px;
}
.ver-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ver-row {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  font-family: inherit;
  cursor: pointer;
  min-height: 86px;
  transition:
    transform 0.12s var(--ease),
    background 0.15s,
    border-color 0.15s;
}
.ver-row:active {
  transform: scale(0.98);
  background: var(--bg3);
}
.ver-cover {
  width: 50px;
  height: 72px;
  flex-shrink: 0;
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg3);
  box-shadow: var(--shadow-card);
}
.ver-cover .book-cover-ph {
  width: 100%;
  height: 100%;
}
.ver-cover .oc-cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.ver-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ver-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.ver-badge {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--green);
  background: var(--green-light);
  border-radius: 10px;
  padding: 2px 8px;
}
.ver-meta {
  font-size: 0.82rem;
  color: var(--text2);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.ver-go {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 700;
}
.ver-go svg {
  width: 18px;
  height: 18px;
}

/* Блок «Ещё от автора» — визуальная сетка с обложками, как в каталоге */
/* Аннотация — текст книги, поэтому засечный (The Reading-Serif Rule).
   Без подложки-карточки: модалка сама поверхность, вложенные карточки запрещены. */
.book-annotation {
  margin-top: 24px;
}
.book-annotation h3 {
  font-family: var(--serif);
  font-size: 1.05rem;
  color: var(--text);
  font-weight: 800;
  margin-bottom: 10px;
}
.book-annotation p {
  font-family: var(--serif);
  font-size: 0.98rem;
  line-height: 1.65;
  color: var(--text);
  margin-bottom: 10px;
}
.book-annotation p:last-child {
  margin-bottom: 0;
}

.other-books {
  margin-top: 24px;
}
.other-books h3 {
  font-family: var(--serif);
  font-size: 1.05rem;
  color: var(--text);
  font-weight: 800;
  margin-bottom: 12px;
}
.other-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
@media (min-width: 520px) {
  .other-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}
.other-card {
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.other-card .oc-cover-wrap {
  width: 100%;
  aspect-ratio: 2 / 3;
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg3);
  box-shadow: var(--shadow-card);
  transition: transform 0.12s var(--ease);
}
.other-card:active .oc-cover-wrap {
  transform: scale(0.97);
}
.other-card .oc-cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.other-card .book-cover-ph {
  width: 100%;
  height: 100%;
}
.other-card .oc-title {
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.01em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.other-card .oc-num {
  font-size: 0.72rem;
  color: var(--text2);
  font-weight: 600;
}

/* === PAGINATION === */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  padding: 20px 8px;
}
.pagination .btn {
  padding: 14px 24px;
  font-size: 1rem;
}
.page-info {
  font-size: 0.9rem;
  color: var(--text2);
  font-weight: 600;
}

/* === TOAST === */
.toast {
  position: fixed;
  bottom: calc(24px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: var(--text);
  color: var(--bg2);
  padding: 14px 28px;
  border-radius: 14px;
  font-size: 0.88rem;
  font-weight: 700;
  z-index: 300;
  opacity: 0;
  transition:
    opacity 0.25s,
    transform 0.25s var(--ease);
  pointer-events: none;
  max-width: 90vw;
  text-align: center;
  box-shadow: 0 4px 20px rgba(28, 28, 40, 0.2);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* === ОФЛАЙН-ИНДИКАТОР === */
.offline-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 250;
  background: var(--amber);
  color: #fff;
  padding: calc(10px) 16px calc(10px + var(--safe-bottom));
  font-size: 0.85rem;
  font-weight: 700;
  text-align: center;
  box-shadow: 0 -2px 12px rgba(74, 56, 30, 0.2);
}

/* === ЭКРАН PIN === */
.pin-gate[hidden] {
  display: none;
} /* атрибут hidden должен реально скрывать экран */
.pin-gate {
  position: fixed;
  inset: 0;
  z-index: 400;
  background: var(--bg);
  background-image: radial-gradient(
    circle at 50% 20%,
    rgba(255, 251, 240, 0.6),
    transparent 50%
  );
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.pin-box {
  width: 100%;
  max-width: 340px;
  text-align: center;
}
.pin-logo {
  font-family: var(--serif);
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
}
.pin-sub {
  font-size: 1rem;
  color: var(--text2);
  font-weight: 600;
  margin-top: 6px;
}
.pin-dots {
  font-size: 1.8rem;
  letter-spacing: 6px;
  color: var(--accent);
  min-height: 40px;
  margin-top: 16px;
  font-weight: 800;
}
.pin-error {
  font-size: 0.9rem;
  color: var(--red);
  font-weight: 700;
  min-height: 20px;
  margin-bottom: 10px;
}
.pin-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.pin-key {
  height: 68px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--bg2);
  color: var(--text);
  font-family: inherit;
  font-size: 1.6rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow-card);
  transition:
    transform 0.1s var(--ease),
    background 0.15s;
}
.pin-key:active {
  transform: scale(0.94);
  background: var(--bg3);
}
.pin-key.pin-aux {
  color: var(--text2);
  font-size: 1.4rem;
}
.pin-key.pin-ok {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* === SKELETON LOADER ===
         Карточки — прямые дети #bookList, чтобы наследовать его сетку
         (grid-view) или вертикальный список (list-view). */
.book-list:not(.grid-view) > .skeleton-card {
  margin-bottom: 12px;
}
.skeleton-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.skeleton-cover {
  width: 100%;
  aspect-ratio: 2/3;
  background: linear-gradient(
    110deg,
    var(--bg3) 30%,
    rgba(255, 255, 255, 0.55) 50%,
    var(--bg3) 70%
  );
  background-size: 200% 100%;
  animation: shimmer-slide 1.6s linear infinite;
}
@keyframes shimmer-slide {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}
.skeleton-lines {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
}
.skeleton-line {
  height: 12px;
  border-radius: 6px;
  background: var(--bg3);
  animation: shimmer 1.5s ease-in-out infinite;
}
.skeleton-line:nth-child(1) {
  width: 80%;
}
.skeleton-line:nth-child(2) {
  width: 55%;
}
.skeleton-line:nth-child(3) {
  width: 35%;
  height: 10px;
}
@keyframes shimmer {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--text2);
}
.empty-state .e-icon {
  margin-bottom: 16px;
  color: var(--text2);
  opacity: 0.4;
}
.empty-state .e-icon svg {
  width: 56px;
  height: 56px;
}
.empty-state p {
  font-size: 1rem;
  line-height: 1.7;
  max-width: 280px;
  margin: 0 auto;
}

/* === TABLET === */
@media (min-width: 768px) {
  .content {
    padding: 16px 24px;
  }
  .modal {
    border-radius: 20px;
    margin-bottom: 40px;
  }
  .genre-grid {
    grid-template-columns: 1fr 1fr 1fr;
  }
}

/* ============================================================
   ПОЛИРОВКА: доступность, motion, состояния
   ============================================================ */

/* Убираем легаси-задержку тапа 300мс */
button,
a,
[role="button"],
.sort-btn,
.tab,
.book-card,
.genre-card,
.series-item {
  touch-action: manipulation;
}

/* Видимый фокус для клавиатуры */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 8px;
}
.book-card:focus-visible,
.genre-card:focus-visible {
  outline-offset: -2px;
}

/* Моноширинные цифры — без «скачков» в счётчиках и колонках */
.stats-badge,
.page-info,
.book-meta,
.results-info,
.modal-row .value,
.tab-count {
  font-variant-numeric: tabular-nums;
}


/* Подсказка о горизонтальной прокрутке рядов-чипов */
.filters,
.sort-bar {
  -webkit-mask-image: linear-gradient(
    to right,
    transparent,
    #000 18px,
    #000 calc(100% - 18px),
    transparent
  );
  mask-image: linear-gradient(
    to right,
    transparent,
    #000 18px,
    #000 calc(100% - 18px),
    transparent
  );
}

/* Плавное закрытие модалки */
.modal-overlay {
  transition: opacity 0.2s var(--ease);
}
.modal-overlay.closing {
  opacity: 0;
}
@keyframes slideDown {
  from {
    transform: translateY(0);
    opacity: 1;
  }
  to {
    transform: translateY(100%);
    opacity: 0.6;
  }
}
.modal.closing {
  animation: slideDown 0.2s var(--ease) forwards;
}

/* Состояние загрузки на кнопках «Скачать» */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.modal-btn.loading {
  color: transparent !important;
  position: relative;
  pointer-events: none;
}
.modal-btn.loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  border: 2px solid var(--green);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
.modal-btn.dl.loading::after {
  border-color: #fff;
  border-top-color: transparent;
}

/* Просторнее на больших экранах (планшет-ландшафт / десктоп) */
@media (min-width: 1024px) {
  .content {
    max-width: 1100px;
  }
  .book-list.grid-view {
    grid-template-columns: repeat(4, 1fr);
  }
  .genre-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* Бумажная типографика: serif для заголовков и названий книг */
.logo,
.book-title,
.modal-title,
.author-name,
.genre-card .g-name,
.other-books h3,
.breadcrumb .current,
.empty-state p {
  font-family: var(--serif);
}
.logo {
  letter-spacing: -0.01em;
}
.book-title {
  letter-spacing: 0;
}

/* === НАСТРОЙКИ === */
.settings-sheet {
  max-width: 520px;
}
.settings-title {
  font-family: var(--serif);
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 18px;
}
.settings-group {
  margin-bottom: 22px;
}
.settings-label {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text2);
  margin-bottom: 10px;
}
.settings-hint {
  margin: -2px 0 12px;
  color: var(--text2);
  font-size: 0.86rem;
  line-height: 1.45;
}
.lang-options {
  display: grid;
  gap: 8px;
}
.lang-opt {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 18px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 1.08rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 58px;
  text-align: left;
  transition:
    border-color 0.15s,
    background 0.15s,
    color 0.15s,
    transform 0.12s var(--ease);
}
.lang-opt:active {
  transform: scale(0.99);
  background: var(--bg3);
}
.lang-opt.active {
  border-color: var(--accent);
  background: var(--accent-light);
  color: var(--accent);
}
.lang-opt .lang-check {
  width: 22px;
  height: 22px;
  opacity: 0;
  flex-shrink: 0;
}
.lang-opt.active .lang-check {
  opacity: 1;
}
.settings-font {
  display: flex;
  align-items: center;
  gap: 16px;
}
.settings-font .btn {
  flex: 0 0 auto;
}
.font-size-val {
  font-size: 1.1rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  min-width: 80px;
  text-align: center;
  color: var(--text);
}

/* Уважение к prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ===== CSP-safe utility classes (Set C.1 / C4): бывшие inline style= ===== */
.u-hidden { display: none; }
.u-userlabel { font-weight: 700; font-size: 1.05em; }
.u-icon11 { width: 1.1em; height: 1.1em; }
.u-icon15 { width: 1.5em; height: 1.5em; }
.u-w100 { width: 100%; }
.u-w100-mt4 { width: 100%; margin-top: 4px; }
.u-link-accent { color: var(--accent); cursor: pointer; text-decoration: underline; }
.u-link { cursor: pointer; text-decoration: underline; }
.u-sublabel { font-size: 0.88rem; font-weight: 700; margin-bottom: 6px; color: var(--text2); }
.u-mt14-w100 { margin-top: 14px; width: 100%; }
.u-pad204 { padding: 20px 4px; }
.u-sz28 { width: 28px; height: 28px; }
.u-sz56 { width: 56px; height: 56px; }
.u-row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
