/* lib.ssafr.ru — макеты. Токены и компоненты.
   Тема задаётся на <html data-theme="night|sepia|day">, по умолчанию Ночь.
   Имена тем совпадают с темами читалки (reader.css: theme-night / theme-sepia / theme-day). */

:root, [data-theme="night"] {
  --font-display: "Cormorant Garamond", "Iowan Old Style", Palatino, Georgia, serif;
  --font-ui: "Onest", "Segoe UI", system-ui, sans-serif;
  --font-read: "Source Serif 4", "Iowan Old Style", Georgia, serif;

  --page-max: 1440px;
  --page-x: clamp(16px, 3.6vw, 56px);
  --r-pill: 999px;
  --r-md: 14px;
  --r-lg: 20px;
  --cover-r: 3px 8px 8px 3px;

  /* Ночь */
  --bg: #120f0c;
  --surface: #1c1712;
  --surface-2: #261f18;
  --ink: #f3eadc;
  --ink-2: #d5c8b5;
  --muted: #9d8f7d;
  --line: rgba(243, 234, 220, 0.09);
  --line-2: rgba(243, 234, 220, 0.16);
  --accent: #ddb97f;
  --accent-ink: #1a130c;
  --accent-soft: rgba(221, 185, 127, 0.14);
  --ok: #8fba7a;
  --warn: #dda55c;
  --bad: #de7b6b;
  --chip: rgba(243, 234, 220, 0.07);
  --chip-2: rgba(243, 234, 220, 0.12);
  --glass: linear-gradient(160deg, rgba(38, 31, 24, 0.82), rgba(38, 31, 24, 0.55));
  --glass-edge: inset 0 0 0 1px rgba(255, 238, 214, 0.07);
  --header-bg: rgba(18, 15, 12, 0.72);
  --shadow-md: 0 18px 44px rgba(0, 0, 0, 0.42);
  --shadow-lg: 0 30px 70px rgba(0, 0, 0, 0.55);
  --cover-shadow: 1px 0 0 rgba(255, 236, 210, 0.08), 3px 0 0 rgba(0, 0, 0, 0.3), 10px 16px 32px rgba(0, 0, 0, 0.45);
  --backdrop-o: 0.62;
  --glow: rgba(196, 140, 90, 0.2);
  color-scheme: dark;
}

[data-theme="sepia"] {
  --bg: #ebdcbe;
  --surface: #f4e9d1;
  --surface-2: #e3d1ad;
  --ink: #3a2914;
  --ink-2: #57412a;
  --muted: #6e5840;
  --line: rgba(58, 41, 20, 0.13);
  --line-2: rgba(58, 41, 20, 0.22);
  --accent: #8a4f1e;
  --accent-ink: #fbf3e2;
  --accent-soft: rgba(138, 79, 30, 0.12);
  --ok: #4f7a3c;
  --warn: #9a6418;
  --bad: #a4412f;
  --chip: rgba(58, 41, 20, 0.07);
  --chip-2: rgba(58, 41, 20, 0.12);
  --glass: linear-gradient(160deg, rgba(248, 239, 219, 0.84), rgba(248, 239, 219, 0.6));
  --glass-edge: inset 0 0 0 1px rgba(58, 41, 20, 0.1);
  --header-bg: rgba(235, 220, 190, 0.8);
  --shadow-md: 0 14px 34px rgba(70, 45, 15, 0.22);
  --shadow-lg: 0 30px 60px rgba(70, 45, 15, 0.28);
  --cover-shadow: 1px 0 0 rgba(255, 255, 255, 0.25), 3px 0 0 rgba(60, 40, 15, 0.22), 10px 14px 26px rgba(70, 45, 15, 0.3);
  --backdrop-o: 0.34;
  --glow: rgba(176, 110, 50, 0.16);
  color-scheme: light;
}

[data-theme="day"] {
  --bg: #f5f0e7;
  --surface: #fffdf8;
  --surface-2: #ece4d6;
  --ink: #221d16;
  --ink-2: #4a4136;
  --muted: #6b6155;
  --line: rgba(34, 29, 22, 0.1);
  --line-2: rgba(34, 29, 22, 0.18);
  --accent: #9a5a1e;
  --accent-ink: #fffdf8;
  --accent-soft: rgba(154, 90, 30, 0.1);
  --ok: #3f7a4a;
  --warn: #9a6418;
  --bad: #a4412f;
  --chip: rgba(34, 29, 22, 0.06);
  --chip-2: rgba(34, 29, 22, 0.1);
  --glass: linear-gradient(160deg, rgba(255, 253, 248, 0.88), rgba(255, 253, 248, 0.68));
  --glass-edge: inset 0 0 0 1px rgba(34, 29, 22, 0.08);
  --header-bg: rgba(245, 240, 231, 0.82);
  --shadow-md: 0 12px 30px rgba(60, 40, 20, 0.16);
  --shadow-lg: 0 30px 60px rgba(60, 40, 20, 0.2);
  --cover-shadow: 1px 0 0 rgba(255, 255, 255, 0.3), 3px 0 0 rgba(60, 40, 20, 0.18), 10px 14px 24px rgba(60, 40, 20, 0.24);
  --backdrop-o: 0.28;
  --glow: rgba(176, 110, 50, 0.12);
  color-scheme: light;
}

/* ---------- База ---------- */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: radial-gradient(1100px 480px at 85% -8%, var(--glow), transparent 70%), var(--bg);
  background-color: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.3s ease, color 0.3s ease;
}
.has-backdrop { background: var(--bg); }
a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }
button { font: inherit; color: inherit; }
svg.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
svg.i.fill { fill: currentColor; stroke: none; }
svg.i.sm { width: 15px; height: 15px; }
svg.i.lg { width: 22px; height: 22px; }

.page {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 0 var(--page-x) 72px;
}

.kicker {
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
}
.display {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(44px, 5.2vw, 76px);
  line-height: 0.98;
  letter-spacing: -0.01em;
}
.muted { color: var(--muted); }
.tnum { font-variant-numeric: tabular-nums; }

/* ---------- Фон из обложки ---------- */

.backdrop {
  --cg1: var(--g1, #6d5340);
  --cg2: var(--g2, #3d2e24);
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 820px;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}
/* В проде здесь размытая обложка: <img> с filter: blur(40px). В макете — пятна тона обложки (cover_tone). */
.backdrop::before {
  content: "";
  position: absolute;
  right: -10%;
  top: -20%;
  width: 84%;
  height: 130%;
  background:
    radial-gradient(38% 42% at 62% 40%, var(--cg1) 0%, color-mix(in srgb, var(--cg1) 40%, transparent) 45%, transparent 100%),
    radial-gradient(40% 44% at 30% 70%, var(--cg2) 0%, color-mix(in srgb, var(--cg2) 35%, transparent) 50%, transparent 100%),
    radial-gradient(30% 34% at 88% 76%, var(--cg1) 0%, transparent 100%);
  opacity: var(--backdrop-o);
}
.backdrop::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, var(--bg) 0%, color-mix(in srgb, var(--bg) 84%, transparent) 32%, color-mix(in srgb, var(--bg) 30%, transparent) 70%, transparent 100%),
    linear-gradient(180deg, color-mix(in srgb, var(--bg) 55%, transparent) 0%, transparent 20%, transparent 48%, var(--bg) 100%);
}

/* ---------- Шапка ---------- */

/* Наверху страницы шапка прозрачная и сливается с фоном из обложки; после прокрутки — стекло. */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: linear-gradient(180deg, color-mix(in srgb, var(--bg) 70%, transparent), transparent);
  transition: background 0.25s ease, box-shadow 0.25s ease;
}
.topbar.scrolled {
  background: var(--header-bg);
  box-shadow: 0 1px 0 var(--line);
  backdrop-filter: blur(18px) saturate(1.2);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
}
.topbar-in {
  max-width: var(--page-max);
  margin: 0 auto;
  height: 72px;
  padding: 0 var(--page-x);
  display: flex;
  align-items: center;
  gap: 36px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 27px;
  letter-spacing: 0.01em;
  color: var(--ink);
  white-space: nowrap;
}
.brand em { font-style: normal; font-weight: 500; color: var(--muted); }
.brand:hover { color: var(--ink); }
.brand-mark { width: 26px; height: 26px; color: var(--accent); }
.mainnav { display: flex; gap: 26px; font-size: 15px; }
.mainnav a { position: relative; color: var(--muted); padding: 6px 0; }
.mainnav a:hover { color: var(--ink); }
.mainnav a[aria-current] { color: var(--ink); }
.mainnav a[aria-current]::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -4px;
  width: 5px;
  height: 5px;
  margin-left: -2.5px;
  border-radius: 50%;
  background: var(--accent);
}
.search-pill {
  margin-left: auto;
  flex: 0 1 440px;
  min-width: 200px;
  height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 0 16px;
  border-radius: var(--r-pill);
  background: var(--chip);
  box-shadow: var(--glass-edge);
  color: var(--muted);
}
.search-pill input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 0;
  outline: none;
  color: var(--ink);
  font: inherit;
  font-size: 14.5px;
}
.search-pill input::placeholder { color: var(--muted); }
.kbd {
  font-size: 12px;
  line-height: 1;
  padding: 5px 8px;
  border-radius: 7px;
  background: var(--chip-2);
  color: var(--muted);
}
.top-actions { display: flex; align-items: center; gap: 10px; position: relative; }
.icon-btn {
  position: relative;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
}
.icon-btn:hover { background: var(--chip); color: var(--ink); }
.icon-btn .dot {
  position: absolute;
  top: 8px;
  right: 9px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 2px var(--bg);
}
.pill-count {
  height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 6px 0 12px;
  border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--warn) 14%, transparent);
  color: var(--warn);
  font-size: 13px;
  font-weight: 500;
}
.pill-count b {
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  display: grid;
  place-items: center;
  border-radius: var(--r-pill);
  background: var(--warn);
  color: var(--accent-ink);
  font-size: 12px;
}
[data-theme="sepia"] .pill-count b,
[data-theme="day"] .pill-count b { color: #fff; }
.avatar {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(160deg, var(--accent), color-mix(in srgb, var(--accent) 55%, var(--bg)));
  color: var(--accent-ink);
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
}

/* Меню аватара */
.menu {
  position: absolute;
  right: 0;
  top: calc(100% + 12px);
  width: 280px;
  padding: 8px;
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--glass-edge), var(--shadow-lg);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  display: none;
  z-index: 50;
}
.menu-wrap.open .menu { display: block; }
.menu-head { padding: 10px 12px 12px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.menu-head b { display: block; font-weight: 600; }
.menu-head span { font-size: 13px; color: var(--muted); }
.menu a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 14.5px;
  color: var(--ink-2);
}
.menu a:hover { background: var(--chip); color: var(--ink); }
.menu a .n { margin-left: auto; font-size: 12px; color: var(--warn); font-weight: 600; }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 4px; }
.menu-label { padding: 8px 12px 6px; font-size: 11.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.menu .seg { margin: 2px 8px 8px; }

/* ---------- Чипы и переключатели ---------- */

.chip {
  height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  border: 0;
  border-radius: var(--r-pill);
  background: var(--chip);
  color: var(--ink-2);
  font-size: 14px;
  white-space: nowrap;
  cursor: pointer;
}
.chip:hover { background: var(--chip-2); color: var(--ink); }
.chip .n { color: var(--muted); font-size: 12.5px; }
.chip.on { background: var(--accent-soft); color: var(--accent); }
.chip.on .n { color: color-mix(in srgb, var(--accent) 70%, var(--muted)); }
.chip .x { opacity: 0.7; margin-right: -4px; }
.chip.outline { background: transparent; box-shadow: inset 0 0 0 1px var(--line-2); }
.swatch { width: 10px; height: 10px; border-radius: 50%; background: var(--g1); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.2); }

.seg {
  display: inline-flex;
  padding: 4px;
  gap: 2px;
  border-radius: var(--r-pill);
  background: var(--chip);
  box-shadow: var(--glass-edge);
}
.seg button, .seg a {
  height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 14px;
  border: 0;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.seg button:hover, .seg a:hover { color: var(--ink); }
.seg .on { background: var(--surface); color: var(--ink); box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18); }
[data-theme="night"] .seg .on { background: var(--chip-2); }
.seg .n { font-size: 12px; color: var(--muted); font-weight: 400; }
.seg.wide { display: flex; }
.seg.wide > * { flex: 1; justify-content: center; }

.tabs { display: flex; gap: 28px; border-bottom: 1px solid var(--line); }
.tabs a {
  position: relative;
  padding: 12px 0 14px;
  color: var(--muted);
  font-size: 15px;
}
.tabs a:hover { color: var(--ink); }
.tabs a.on { color: var(--ink); }
.tabs a.on::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  border-radius: 2px;
  background: var(--accent);
}
.tabs .n { margin-left: 6px; font-size: 12.5px; color: var(--muted); }

.progress {
  height: 4px;
  border-radius: var(--r-pill);
  background: var(--chip-2);
  overflow: hidden;
}
.progress > i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 60%, var(--bg)), var(--accent));
}
.progress.lg { height: 6px; }

.glass {
  background: var(--glass);
  box-shadow: var(--glass-edge);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-radius: var(--r-lg);
}

.crumbs { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 14px; color: var(--muted); padding: 14px 0 0; }
.crumbs a { color: var(--ink-2); }
.crumbs a:hover { color: var(--accent); }
.crumbs .sep { opacity: 0.5; }

/* ---------- Обложки ---------- */

.tone-azure     { --c1: #2f5d78; --c2: #152b3a; --g1: #4f8db3; --g2: #24506b; }
.tone-crimson   { --c1: #7a3232; --c2: #331616; --g1: #b0504a; --g2: #6e2a2a; }
.tone-forest    { --c1: #3a603f; --c2: #182a1b; --g1: #5f9463; --g2: #2c5031; }
.tone-violet    { --c1: #5b447a; --c2: #261a38; --g1: #8a6bb8; --g2: #4a3468; }
.tone-honey     { --c1: #82622a; --c2: #3a2b11; --g1: #c9a24a; --g2: #7a5a20; }
.tone-ink       { --c1: #3f4d68; --c2: #1b2130; --g1: #6a7ea8; --g2: #34405a; }
.tone-rose      { --c1: #7a4052; --c2: #331a22; --g1: #c46b7a; --g2: #6e3a48; }
.tone-parchment { --c1: #74583f; --c2: #372a20; --g1: #b08560; --g2: #6d5340; }

.cover {
  --cv-ink: #f6ecdc;
  --cv-sub: rgba(246, 236, 220, 0.7);
  position: relative;
  aspect-ratio: 2 / 3;
  border-radius: var(--cover-r);
  overflow: hidden;
  container-type: inline-size;
  background: linear-gradient(160deg, var(--c1), var(--c2));
  box-shadow: var(--cover-shadow);
  transform-origin: 50% 100%;
  transition: transform 0.22s ease, box-shadow 0.22s ease;
}
.cover::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.28) 0, rgba(255, 255, 255, 0.14) 2.2%, transparent 5.5%),
    linear-gradient(125deg, rgba(255, 255, 255, 0.18) 0%, transparent 38%, transparent 58%, rgba(0, 0, 0, 0.24) 100%);
  pointer-events: none;
}
.cover-art { position: absolute; inset: 0; }
.cover-text {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: 12cqw 10cqw 10cqw 12cqw;
  color: var(--cv-ink);
}
.cv-series {
  font-family: var(--font-ui);
  font-size: 5.4cqw;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--cv-sub);
}
.cv-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14cqw;
  line-height: 1.02;
  letter-spacing: -0.005em;
  text-wrap: balance;
}
.cv-author {
  margin-top: auto;
  font-family: var(--font-ui);
  font-size: 5.6cqw;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--cv-sub);
}
/* Варианты оформления, чтобы сетка не была однообразной */
.v-top .cv-series { margin-bottom: 5cqw; }
.v-top .cover-art {
  background:
    linear-gradient(var(--cv-sub), var(--cv-sub)) 12cqw 58% / 22cqw 1px no-repeat;
  opacity: 0.8;
}
.v-frame .cover-text { justify-content: center; text-align: center; align-items: center; padding: 16cqw 14cqw; }
.v-frame .cv-author { margin-top: 8cqw; }
.v-frame .cv-series { margin-bottom: 6cqw; }
.v-frame .cover-art::before {
  content: "";
  position: absolute;
  inset: 6cqw 6cqw 6cqw 8cqw;
  border: 1px solid var(--cv-sub);
  opacity: 0.55;
}
.v-sun .cover-art::before {
  content: "";
  position: absolute;
  left: 18cqw;
  right: 18cqw;
  bottom: 22cqw;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 35%, color-mix(in srgb, var(--g1) 90%, white), var(--g1) 45%, transparent 72%);
  opacity: 0.85;
}
.v-sun .cv-author { margin-top: auto; }
.v-band .cover-art::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 46%;
  background: repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.07) 0 2px, transparent 2px 9px);
}
.v-band .cover-text { justify-content: flex-end; }
.v-band .cv-author { margin-top: 5cqw; order: 3; }
.v-band .cv-series { order: 0; margin-bottom: 4cqw; }
.v-light .cv-title { font-style: italic; font-weight: 500; font-size: 15cqw; }
.v-light .cover-art::before {
  content: "";
  position: absolute;
  left: 12cqw;
  right: 10cqw;
  bottom: 30cqw;
  height: 34cqw;
  background:
    radial-gradient(circle at 30% 60%, color-mix(in srgb, var(--g2) 55%, transparent) 0 18cqw, transparent 18.5cqw),
    radial-gradient(circle at 62% 40%, color-mix(in srgb, var(--g1) 55%, transparent) 0 14cqw, transparent 14.5cqw);
}
.cover.sq { aspect-ratio: 1; }

/* Метки на обложке */
.cv-badge {
  position: absolute;
  z-index: 3;
  top: 8px;
  left: 10px;
  padding: 4px 9px;
  border-radius: var(--r-pill);
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}
.cv-badge.ok { background: var(--ok); color: #10180d; }
.cv-audio {
  position: absolute;
  z-index: 3;
  right: 8px;
  bottom: 8px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(20, 16, 12, 0.72);
  color: #f0d8ae;
  backdrop-filter: blur(8px);
}
.cv-audio svg { width: 15px; height: 15px; }
.cv-ribbon {
  position: absolute;
  z-index: 3;
  top: 0;
  right: 12px;
  width: 18px;
  height: 28px;
  background: var(--accent);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 76%, 0 100%);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}
.cv-ribbon.read { background: var(--ok); }

/* ---------- Карточка книги в сетке и ленте ---------- */

.card { display: flex; flex-direction: column; gap: 12px; min-width: 0; color: var(--ink); }
.card:hover { color: var(--ink); }
.card:hover .cover { transform: translateY(-6px) rotate(-0.6deg); box-shadow: var(--cover-shadow), 0 26px 40px rgba(0, 0, 0, 0.25); }
.card-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; padding: 0 2px; }
.card-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 19px;
  line-height: 1.12;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card:hover .card-title { color: var(--accent); }
.card-meta, .card-sub {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-sub.accent { color: var(--accent); }
.card .progress { margin-top: 8px; }
.card-note { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.card.missing .cover { filter: grayscale(0.6) brightness(0.8); opacity: 0.7; }
.card.missing .card-title { color: var(--ink-2); }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(164px, 1fr));
  gap: 36px 24px;
}

/* ---------- Секции и ленты ---------- */

.section { margin-top: 56px; }
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}
.section-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 32px;
  line-height: 1.1;
  letter-spacing: -0.005em;
}
.section-head .left { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.more { font-size: 14px; color: var(--muted); white-space: nowrap; }
.more:hover { color: var(--accent); }
.section-hint { font-size: 14px; color: var(--muted); margin: -12px 0 18px; }

.rail { position: relative; }
.rail-track {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: var(--card-w, 164px);
  gap: 24px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  padding: 10px 0 12px;
  margin: -10px 0 -12px;
  /* Край ленты растворяется в любом фоне, включая подсветку из обложки */
  -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 150px), transparent);
  mask-image: linear-gradient(90deg, #000 calc(100% - 150px), transparent);
}
.rail-track::-webkit-scrollbar { display: none; }
.rail-track > * { scroll-snap-align: start; }
.rail-next {
  position: absolute;
  z-index: 2;
  right: 0;
  top: calc(var(--card-w, 164px) * 0.75 - 24px);
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--chip-2);
  color: var(--ink);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  cursor: pointer;
}
.rail-next:hover { background: var(--accent); color: var(--accent-ink); }

/* ---------- Главная: герой «Продолжить» ---------- */

.hero {
  position: relative;
  min-height: 470px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 56px;
  padding: 28px 0 24px;
}
.hero-text { display: flex; flex-direction: column; gap: 16px; max-width: 720px; }
.hero-meta { margin: 0; font-size: 16px; color: var(--ink-2); }
.hero-meta a { color: var(--ink); border-bottom: 1px solid var(--line-2); }
.hero-meta a:hover { color: var(--accent); border-color: var(--accent); }
.hero-progress { display: flex; flex-direction: column; gap: 10px; max-width: 460px; margin-top: 6px; }
.hero-progress span { font-size: 14px; color: var(--muted); }
.hero .actions { margin-top: 10px; }
.dots { display: flex; gap: 6px; margin-top: 18px; }
.dots i { width: 16px; height: 4px; border-radius: 4px; background: var(--chip-2); }
.dots i.on { width: 32px; background: var(--accent); }

.pile { position: relative; width: 250px; height: 375px; margin-right: 110px; }
.pile .cover { position: absolute; inset: 0; width: 250px; }
.pile .cover.p1 { z-index: 3; box-shadow: var(--cover-shadow), var(--shadow-lg); }
.pile .cover.p2 { z-index: 2; transform: translate(70px, 12px) rotate(5deg) scale(0.9); filter: brightness(0.7); }
.pile .cover.p3 { z-index: 1; transform: translate(128px, 30px) rotate(10deg) scale(0.8); filter: brightness(0.5); }

/* ---------- Плитки каталога ---------- */

.families { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.family {
  position: relative;
  min-height: 150px;
  padding: 20px 22px;
  border-radius: 18px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: #f6ecdc;
  background:
    radial-gradient(120% 90% at 100% 100%, color-mix(in srgb, var(--g1) 55%, transparent), transparent 60%),
    linear-gradient(160deg, var(--c1), var(--c2));
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.22);
}
.family:hover { color: #fff; filter: brightness(1.08); }
.family b { font-family: var(--font-display); font-weight: 600; font-size: 30px; line-height: 1.05; }
.family span { font-size: 13px; opacity: 0.78; }
.family .count { margin-top: auto; font-size: 13.5px; opacity: 0.92; font-variant-numeric: tabular-nums; }
.family .mini {
  position: absolute;
  right: 18px;
  bottom: -26px;
  display: flex;
}
.family .mini .cover { width: 58px; box-shadow: -4px 6px 14px rgba(0, 0, 0, 0.35); }
.family .mini .cover:nth-child(1) { transform: rotate(-10deg) translate(14px, 8px); }
.family .mini .cover:nth-child(2) { transform: rotate(-2deg); z-index: 1; }
.family .mini .cover:nth-child(3) { transform: rotate(8deg) translate(-14px, 6px); }
.family .mini .cv-title { font-size: 16cqw; }

.eras { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.era {
  padding: 16px 18px;
  border-radius: 16px;
  background: var(--chip);
  box-shadow: var(--glass-edge);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.era:hover { background: var(--chip-2); color: var(--ink); }
.era b { font-family: var(--font-display); font-size: 24px; font-weight: 600; line-height: 1.1; }
.era span { font-size: 13px; color: var(--muted); }
.era .count { margin-top: 10px; font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.era.on { background: linear-gradient(160deg, var(--accent-soft), transparent); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent); }

/* ---------- Подвал ---------- */

.footer {
  margin-top: 72px;
  padding: 28px 0 8px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px 32px;
  font-size: 14px;
  color: var(--muted);
}
.footer .stats { display: flex; flex-wrap: wrap; gap: 8px 22px; }
.footer .stats b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.footer .links { display: flex; flex-wrap: wrap; gap: 8px 20px; }
.footer .links a { color: var(--ink-2); }
.footer .links a:hover { color: var(--accent); }

/* ---------- Карточка книги ---------- */

.book {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
  gap: 56px;
  align-items: start;
  padding-top: 26px;
}
.book-side { display: flex; flex-direction: column; gap: 18px; position: sticky; top: 96px; }
.book-side .cover { width: 100%; box-shadow: var(--cover-shadow), var(--shadow-lg); }
.side-box { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.side-box .label { font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.side-box .row { display: flex; justify-content: space-between; align-items: center; font-size: 13.5px; color: var(--muted); }
.side-box .seg button { padding: 0 9px; font-size: 13.5px; }
.side-links { display: flex; flex-direction: column; gap: 2px; }
.side-links a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; font-size: 14px; color: var(--ink-2); }
.side-links a:hover { background: var(--chip); color: var(--ink); }
.side-links a .muted { margin-left: auto; font-size: 12.5px; }

.book-main { display: flex; flex-direction: column; gap: 0; min-width: 0; }
.book-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; }
.book-main h1 { margin-top: 14px; font-size: clamp(46px, 5vw, 72px); }
.book-author { margin: 14px 0 0; font-size: 19px; }
.book-author a { color: var(--accent); }
.book-author a:hover { text-decoration: underline; text-underline-offset: 4px; }
.rating {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 18px;
  font-size: 14px;
  color: var(--muted);
}
.rating .stars { display: inline-flex; align-items: center; gap: 6px; color: var(--ink); font-weight: 600; font-size: 15px; }
.rating .stars svg { color: var(--accent); }
.book-main .actions { margin-top: 28px; }
.annotation {
  margin: 30px 0 0;
  max-width: 64ch;
  font-family: var(--font-read);
  font-size: 18px;
  line-height: 1.65;
  color: var(--ink-2);
}
.annotation + .more { display: inline-block; margin-top: 8px; }
.facts {
  margin: 32px 0 0;
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr) max-content minmax(0, 1fr);
  gap: 12px 20px;
  max-width: 820px;
  font-size: 14.5px;
}
.facts dt { color: var(--muted); }
.facts dd { margin: 0; color: var(--ink); }
.facts dd a { border-bottom: 1px solid var(--line-2); }
.facts dd a:hover { border-color: var(--accent); }
.facts .chip { height: 28px; font-size: 13px; padding: 0 10px; vertical-align: middle; }

/* Серия корешками */
.series {
  margin-top: 40px;
  padding: 22px 24px 34px;
}
.series-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.series-head h3 { margin: 0; font-family: var(--font-display); font-weight: 600; font-size: 25px; }
.series-head .muted { font-size: 14px; }
.spines { display: flex; align-items: flex-end; gap: 8px; min-height: 236px; padding-bottom: 6px; }
.spine {
  position: relative;
  width: 44px;
  height: 200px;
  border-radius: 3px 3px 2px 2px;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.25), rgba(255, 255, 255, 0.1) 18%, transparent 40%, rgba(0, 0, 0, 0.2)),
    linear-gradient(180deg, var(--c1), var(--c2));
  color: #f6ecdc;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 0 30px;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.28);
  transition: transform 0.18s ease;
}
.spine:hover { transform: translateY(-8px); color: #fff; }
.spine .num { font-family: var(--font-display); font-weight: 700; font-size: 20px; line-height: 1; }
.spine .name {
  margin-top: 10px;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.03em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-height: calc(100% - 34px);
  opacity: 0.88;
}
.spine .mark {
  position: absolute;
  bottom: 7px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--ok);
  color: #10180d;
}
.spine .mark svg { width: 12px; height: 12px; stroke-width: 3; }
.spine.cur { outline: 2px solid var(--accent); outline-offset: 3px; transform: translateY(-10px); }
.spine.cur::after {
  content: "сейчас";
  position: absolute;
  bottom: -30px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}
.spine.none {
  background: transparent;
  box-shadow: inset 0 0 0 1.5px var(--line-2);
  color: var(--muted);
}
.spine-next { margin-left: auto; align-self: center; display: flex; flex-direction: column; gap: 6px; max-width: 260px; }
.spine-next .muted { font-size: 13px; }
.spine-next a.title { font-family: var(--font-display); font-weight: 600; font-size: 22px; line-height: 1.15; }

.edit-pill {
  height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  border-radius: var(--r-pill);
  background: var(--chip);
  box-shadow: var(--glass-edge);
  font-size: 13.5px;
  color: var(--ink-2);
  white-space: nowrap;
}
.edit-pill:hover { background: var(--chip-2); color: var(--ink); }
.edit-pill .ok { color: var(--ok); }

/* ---------- Каталог ---------- */

.catalog-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin: 26px 0 0; }
.catalog-head h1 { font-size: clamp(40px, 4.2vw, 60px); }
.catalog-head .count { font-size: 15px; color: var(--muted); margin-top: 10px; }
.filterbar {
  position: sticky;
  top: 80px;
  z-index: 20;
  margin-top: 28px;
  padding: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-radius: var(--r-pill);
}
.filterbar .sep { width: 1px; height: 24px; background: var(--line-2); margin: 0 6px; }
.filterbar .right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.fbtn {
  height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px 0 16px;
  border: 0;
  border-radius: var(--r-pill);
  background: var(--chip);
  color: var(--ink-2);
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
}
.fbtn:hover { background: var(--chip-2); color: var(--ink); }
.fbtn .k { color: var(--muted); }
.fbtn.on { background: var(--accent-soft); color: var(--accent); }
.fbtn.on .k { color: color-mix(in srgb, var(--accent) 65%, var(--muted)); }
.fbtn.open { background: var(--accent); color: var(--accent-ink); }
.fbtn.open .k { color: color-mix(in srgb, var(--accent-ink) 65%, transparent); }
.toggle { display: inline-flex; align-items: center; gap: 10px; font-size: 14px; color: var(--ink-2); padding: 0 10px; cursor: pointer; white-space: nowrap; text-decoration: none; }
a.toggle:hover { color: var(--ink); text-decoration: none; }
.toggle i {
  width: 34px;
  height: 20px;
  border-radius: 20px;
  background: var(--chip-2);
  position: relative;
  transition: background 0.2s;
}
.toggle i::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--ink-2);
  transition: transform 0.2s, background 0.2s;
}
.toggle.on i { background: var(--accent); }
.toggle.on i::after { transform: translateX(14px); background: var(--accent-ink); }
.active-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 18px 0 30px; }
.active-row .reset { margin-left: 8px; font-size: 14px; color: var(--muted); }
.fpop { position: relative; }
.popover {
  position: absolute;
  z-index: 30;
  left: 0;
  top: calc(100% + 10px);
  width: 580px;
  padding: 18px;
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--glass-edge), 0 30px 80px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  display: none;
}
.popover.open { display: block; }
.pop-search {
  height: 40px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  border-radius: 12px;
  background: var(--chip);
  color: var(--muted);
  font-size: 14px;
}
.pop-title { margin: 16px 2px 10px; font-size: 11.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.pop-list { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 12px; }
.pop-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 14.5px;
  color: var(--ink-2);
  cursor: pointer;
}
.pop-item:hover { background: var(--chip); color: var(--ink); }
.pop-item { white-space: nowrap; }
.pop-item .n { margin-left: auto; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.pop-item .box {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  box-shadow: inset 0 0 0 1.5px var(--line-2);
  display: grid;
  place-items: center;
}
.pop-item.on { color: var(--ink); }
.pop-item.on .box { background: var(--accent); box-shadow: none; color: var(--accent-ink); }
.pop-item.on .box svg { width: 12px; height: 12px; stroke-width: 3; }
.pop-item.zero { opacity: 0.4; pointer-events: none; }
.pop-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.pop-chips .chip { height: 30px; font-size: 13px; padding: 0 12px; }
.pop-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }

.pager { display: flex; flex-direction: column; align-items: center; gap: 18px; margin-top: 48px; }
.pages { display: flex; gap: 6px; align-items: center; font-size: 14px; }
.pages a, .pages span {
  min-width: 38px;
  height: 38px;
  padding: 0 10px;
  display: grid;
  place-items: center;
  border-radius: var(--r-pill);
  color: var(--ink-2);
}
.pages a:hover { background: var(--chip); }
.pages a.on { background: var(--chip-2); color: var(--ink); font-weight: 600; }
.pages span { color: var(--muted); }

/* ---------- Аудио ---------- */

.listen {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 56px;
  align-items: center;
  padding-top: 26px;
}
.listen .cover { width: 100%; box-shadow: var(--cover-shadow), var(--shadow-lg); }
.listen-text { display: flex; flex-direction: column; gap: 14px; }
.listen-text .book-author { margin: 0; }
.listen-stats { display: flex; gap: 28px; margin-top: 8px; }
.listen-stats div { display: flex; flex-direction: column; gap: 2px; }
.listen-stats b { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.listen-stats span { font-size: 13px; color: var(--muted); }
.tracks { margin-top: 44px; padding: 10px; }
.tracks-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px 14px; }
.tracks-head h2 { margin: 0; font-family: var(--font-display); font-weight: 600; font-size: 28px; }
.track {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 150px 116px 28px;
  align-items: center;
  gap: 14px;
  padding: 11px 14px;
  border-radius: 12px;
  color: var(--ink-2);
  font-size: 15px;
}
.track:hover { background: var(--chip); color: var(--ink); }
.track .n { color: var(--muted); font-variant-numeric: tabular-nums; }
.track .dur { white-space: nowrap; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 14px; }
.track .st { display: grid; place-items: center; color: var(--ok); }
.track .progress { height: 3px; }
.track.done { color: var(--muted); }
.track.cur { background: var(--accent-soft); color: var(--ink); }
.track.cur .n { color: var(--accent); }
.eq { display: inline-flex; align-items: flex-end; gap: 2px; height: 14px; }
.eq i { width: 3px; background: var(--accent); border-radius: 2px; animation: eq 1s ease-in-out infinite; }
.eq i:nth-child(2) { animation-delay: -0.3s; }
.eq i:nth-child(3) { animation-delay: -0.6s; }
@keyframes eq { 0%, 100% { height: 4px; } 50% { height: 14px; } }

.player {
  position: fixed;
  z-index: 45;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--glass);
  box-shadow: 0 -1px 0 var(--line), 0 -18px 40px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(24px) saturate(1.2);
  -webkit-backdrop-filter: blur(24px) saturate(1.2);
}
.player-seek { height: 4px; background: var(--chip-2); position: relative; }
.player-seek i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent); }
.player-seek b {
  position: absolute;
  top: 50%;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.player-in {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 12px var(--page-x) 14px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 24px;
}
.now { display: flex; align-items: center; gap: 14px; min-width: 0; }
.now .cover { width: 42px; flex: none; border-radius: 3px 5px 5px 3px; }
.now b { display: block; font-weight: 600; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.now span { display: block; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ctrls { display: flex; align-items: center; gap: 10px; }
.ctrl { min-width: 44px; height: 44px; border: 0; border-radius: var(--r-pill); background: transparent; color: var(--ink); font-size: 14px; font-weight: 600; cursor: pointer; font-variant-numeric: tabular-nums; }
.ctrl:hover { background: var(--chip); }
.ctrl.play { width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); box-shadow: 0 8px 24px color-mix(in srgb, var(--accent) 35%, transparent); }
.ctrl.play svg { width: 24px; height: 24px; }
.player-right { display: flex; align-items: center; justify-content: flex-end; gap: 8px; font-size: 13.5px; color: var(--muted); }
.player-right .time { margin-right: 10px; font-variant-numeric: tabular-nums; }
.player-right .chip { height: 34px; }
.has-player .page { padding-bottom: 150px; }

/* ---------- Телефон и Telegram (body.tg-app, @media max-width 700px) ---------- */

.tabbar {
  position: absolute;
  z-index: 4;
  left: 0;
  right: 0;
  bottom: 0;
  height: 86px;
  padding: 8px 6px 26px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: var(--header-bg);
  backdrop-filter: blur(20px) saturate(1.2);
  -webkit-backdrop-filter: blur(20px) saturate(1.2);
  box-shadow: 0 -1px 0 var(--line);
}
.tabbar a { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; padding-top: 4px; font-size: 11px; font-weight: 500; color: var(--muted); }
.tabbar a.on { color: var(--accent); }
.tabbar svg { width: 24px; height: 24px; }
.tabbar .dot { position: absolute; top: 2px; left: calc(50% + 8px); width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px var(--bg); }

/* =========================================================
   ТОЛЬКО ДЛЯ САЙТА — этого нет в макетах
   ========================================================= */

/* ---------- Основа ---------- */

.skip {
  position: absolute; left: 12px; top: -60px; z-index: 100;
  padding: 10px 14px; border-radius: 10px;
  background: var(--accent); color: var(--accent-ink); font-weight: 600;
}
.skip:focus { top: 12px; color: var(--accent-ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; line-height: 1.12; letter-spacing: -0.005em; }
h1 { margin: 0; }
h2 { font-size: 28px; margin: 36px 0 14px; }
h3 { font-size: 21px; margin: 20px 0 8px; }
.lede { margin: 10px 0 0; max-width: 62ch; font-size: 16px; line-height: 1.55; color: var(--ink-2); }
.meta, .small { font-size: 13.5px; color: var(--muted); }
.empty { margin: 0; padding: 18px 0; color: var(--muted); }
.error { color: var(--bad); }
code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 0.92em; padding: 2px 6px; border-radius: 6px; background: var(--chip); }
.code-box { display: block; word-break: break-all; padding: 12px 14px; border-radius: 12px; background: var(--chip); color: var(--accent); font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 13.5px; }
.badge {
  display: inline-flex; align-items: center; height: 22px; padding: 0 8px; margin-right: 6px;
  border-radius: var(--r-pill); background: var(--accent-soft); color: var(--accent);
  font-size: 11.5px; font-weight: 600; white-space: nowrap; vertical-align: middle;
}
.badge.ok { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.badge.warn { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.flash {
  margin: 16px 0 0; padding: 12px 16px; border-radius: var(--r-md);
  background: var(--accent-soft); color: var(--ink); box-shadow: var(--glass-edge); font-size: 14.5px;
}

/* ---------- Кнопки ----------
   .btn              — главная, золотая. На экране одна.
   .btn.ghost        — вторичная, стекло.
   .btn.quiet        — текстовая, без фона.
   .btn.danger       — опасная (удалить, отклонить, отвязать). Можно вместе с ghost.
   .btn.sm           — маленькая.
   <button> без класса — как .btn.ghost.
   Перевод из макетов: btn btn-primary → btn; btn btn-glass → btn ghost;
   btn btn-quiet → btn quiet; btn-sm → sm. */

.btn, button:not([class]) {
  height: 48px; display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  padding: 0 24px; border: 0; border-radius: var(--r-pill);
  background: var(--accent); color: var(--accent-ink);
  font-family: var(--font-ui); font-size: 15px; font-weight: 600; line-height: 1;
  white-space: nowrap; text-decoration: none; cursor: pointer;
  box-shadow: 0 10px 28px color-mix(in srgb, var(--accent) 28%, transparent);
  transition: transform 0.15s ease, background 0.15s ease, filter 0.15s ease;
}
.btn:hover { color: var(--accent-ink); filter: brightness(1.06); text-decoration: none; }
.btn:active, button:not([class]):active { transform: translateY(1px); }
.btn.ghost, button:not([class]) {
  background: var(--chip-2); color: var(--ink); font-weight: 500; box-shadow: none;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.btn.ghost:hover, button:not([class]):hover { background: color-mix(in srgb, var(--ink) 16%, transparent); color: var(--ink); filter: none; }
.btn.quiet { background: transparent; color: var(--ink-2); font-weight: 500; padding: 0 14px; box-shadow: none; }
.btn.quiet:hover { background: var(--chip); color: var(--ink); filter: none; }
.btn.danger { background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad); font-weight: 500; box-shadow: none; }
.btn.danger:hover { background: color-mix(in srgb, var(--bad) 22%, transparent); color: var(--bad); filter: none; }
.btn.sm, button.sm { height: 36px; padding: 0 16px; font-size: 14px; gap: 8px; }
.btn[disabled], button[disabled] { opacity: 0.5; cursor: default; }
.btn .sub { font-weight: 400; opacity: 0.72; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
form.inline { display: inline; }

/* ---------- Поля форм ---------- */

.page input[type=text], .page input[type=search], .page input[type=url], .page input[type=password],
.page input[type=number], .page input[type=email], .page input:not([type]), .page textarea, .page select {
  min-height: 44px; padding: 10px 14px; border: 0; border-radius: 12px;
  background: var(--chip); box-shadow: var(--glass-edge); color: var(--ink);
  font: inherit; font-size: 15px;
}
.page textarea { width: 100%; min-height: 120px; resize: vertical; line-height: 1.55; font-family: var(--font-read); }
.page input::placeholder, .page textarea::placeholder { color: var(--muted); }
.page input[type=file] { max-width: 100%; font-size: 14px; color: var(--ink-2); }
.page input[type=file]::file-selector-button {
  margin-right: 12px; height: 36px; padding: 0 14px; border: 0; border-radius: var(--r-pill);
  background: var(--chip-2); color: var(--ink); font: inherit; cursor: pointer;
}
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; color: var(--muted); }
.field > input, .field > textarea, .field > select { width: 100%; }
.form-grid { display: grid; gap: 12px; max-width: 680px; }
.form-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
label.chip { cursor: pointer; user-select: none; }
label.chip input { margin: 0; accent-color: var(--accent); }
label.chip:has(input:checked) { background: var(--accent-soft); color: var(--accent); }
.display-sm { font-size: clamp(34px, 4vw, 52px); }
.footer .stats a { color: inherit; }
.footer .stats a:hover { color: var(--accent); }

/* ---------- Обложка с настоящей картинкой ---------- */

.cover > img {
  position: absolute; inset: 0; z-index: 1; display: block;
  width: 100%; height: 100%; object-fit: cover; object-position: center top;
}
.cover::after { z-index: 2; }
.cover.has-scan .cover-art, .cover.has-scan .cover-text { visibility: hidden; }

/* ---------- Фон из обложки с картинкой ---------- */

.backdrop > img {
  position: absolute; right: -6%; top: -25%; width: 74%; height: 150%;
  object-fit: cover; filter: blur(48px) saturate(1.15); opacity: var(--backdrop-o);
}
.backdrop:not(.no-img)::before { content: none; }

/* ---------- Шапка: поиск-форма, подсказки, меню на <details> ---------- */

.search-pill { position: relative; }
.search-go {
  display: grid; place-items: center; width: 28px; height: 28px; margin: 0 -4px 0 -6px; padding: 0;
  border: 0; background: transparent; color: inherit; cursor: pointer; box-shadow: none;
}
.search-suggest {
  position: absolute; left: 0; right: 0; top: calc(100% + 8px); z-index: 60;
  max-height: 60vh; overflow: auto; padding: 6px; border-radius: 16px;
  background: var(--surface); box-shadow: var(--glass-edge), var(--shadow-lg);
}
.search-suggest:empty { display: none; }
.search-pill:not(:focus-within) .search-suggest:not(:hover) { display: none; }
.suggest-list { list-style: none; margin: 0; padding: 0; }
.suggest-list a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; color: var(--ink); }
.suggest-list a:hover, .suggest-list a:focus-visible { background: var(--chip); color: var(--ink); }
.suggest-list .meta { padding: 0 12px 8px 12px; margin-top: -6px; font-size: 12.5px; }
.suggest-hint { margin: 0; padding: 8px 12px 4px; font-size: 12.5px; color: var(--accent); }
.suggest-empty { margin: 0; padding: 12px; color: var(--muted); }

details.menu-wrap { position: relative; }
details.menu-wrap > summary, details.fpop > summary, details.seg-more > summary, details.progress-edit > summary { list-style: none; cursor: pointer; }
details.menu-wrap > summary::-webkit-details-marker, details.fpop > summary::-webkit-details-marker,
details.seg-more > summary::-webkit-details-marker, details.progress-edit > summary::-webkit-details-marker { display: none; }
details.menu-wrap[open] > .menu { display: block; }
.menu form { margin: 0; }
.menu .menu-item {
  width: 100%; height: auto; display: flex; align-items: center; justify-content: flex-start; gap: 12px;
  padding: 9px 12px; border: 0; border-radius: 10px; background: transparent; box-shadow: none;
  color: var(--ink-2); font: inherit; font-size: 14.5px; font-weight: 400; text-align: left; cursor: pointer;
}
.menu .menu-item:hover { background: var(--chip); color: var(--ink); }

/* ---------- Статус на полке: пункт «⋯» ---------- */

.status-form { margin: 0; }
.seg-more { position: relative; display: inline-flex; flex: 0 0 auto; }
.seg-more > summary {
  height: 34px; display: inline-flex; align-items: center; padding: 0 10px;
  border-radius: var(--r-pill); color: var(--muted);
}
.seg-more[open] > summary, .seg-more.on > summary { background: var(--chip-2); color: var(--ink); }
.seg-more-menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 30; min-width: 190px;
  display: flex; flex-direction: column; padding: 6px; border-radius: 14px;
  background: var(--surface); box-shadow: var(--glass-edge), var(--shadow-md);
}
.seg-more-menu button { justify-content: flex-start; }
.progress-edit > summary { font-size: 13.5px; color: var(--muted); }
.progress-edit > summary:hover { color: var(--ink); }
.progress-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; margin-top: 10px; }
.progress-form input[type=number] { width: 6.5em; }

/* ---------- Прогресс: новая разметка <i> и старая .progress-bar ---------- */

.progress { display: block; }
.progress > .progress-bar {
  display: block; height: 100%; border-radius: inherit;
  background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 60%, var(--bg)), var(--accent));
}

/* ---------- Фильтры каталога на <details> ---------- */

.tabs button {
  position: relative; height: auto; padding: 12px 0 14px; border: 0; background: none; box-shadow: none;
  color: var(--muted); font: inherit; font-size: 15px; cursor: pointer;
}
.tabs button:hover { color: var(--ink); }
.tabs button.on { color: var(--ink); }
.tabs button.on::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; border-radius: 2px; background: var(--accent);
}
.tabs .n { margin-left: 6px; font-size: 12.5px; color: var(--muted); }
details.fpop[open] > .popover { display: block; }
details.fpop[open] > summary.fbtn { background: var(--accent); color: var(--accent-ink); }
details.fpop[open] > summary.fbtn .k { color: color-mix(in srgb, var(--accent-ink) 65%, transparent); }
a.pop-item { color: var(--ink-2); }
.pop-item .check { width: 18px; height: 18px; display: grid; place-items: center; color: var(--accent); }
.pop-item.on { color: var(--ink); font-weight: 500; }
.page-search { display: none; margin: 18px 0 0; gap: 8px; }
.page-search input[type=search] { flex: 1; height: 48px; font-size: 16px; }

/* ---------- Списки, таблицы, панели ---------- */

.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.list > li { padding: 14px 16px; border-radius: var(--r-md); background: var(--chip); box-shadow: var(--glass-edge); }
.index-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 4px 16px; }
.index-list a { display: flex; justify-content: space-between; gap: 12px; padding: 10px 14px; border-radius: 12px; color: var(--ink-2); }
.index-list a:hover { background: var(--chip); color: var(--ink); }
.index-list .n { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.alpha { display: flex; flex-wrap: wrap; gap: 6px; margin: 18px 0 22px; }
.alpha a {
  min-width: 36px; height: 36px; display: inline-grid; place-items: center; padding: 0 10px;
  border: 0; border-radius: var(--r-pill); background: var(--chip); color: var(--ink-2); font-size: 14px;
}
.alpha a:hover { background: var(--chip-2); color: var(--ink); text-decoration: none; }
.alpha a.on { background: var(--accent-soft); color: var(--accent); }
.panel { padding: 22px 24px; margin-top: 20px; }
.panel > h2:first-child, .panel > h3:first-child { margin-top: 0; }
.table-wrap { overflow-x: auto; margin: 8px 0 24px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; vertical-align: top; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.table th { color: var(--muted); font-weight: 500; font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; }
.table td .small { display: block; }

/* ---------- Правка карточки ---------- */

.edit { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 40px; align-items: start; padding-top: 20px; }
.edit-nav { position: sticky; top: 90px; display: flex; flex-direction: column; gap: 2px; }
.edit-nav a { padding: 8px 12px; border-radius: 10px; color: var(--ink-2); font-size: 14px; }
.edit-nav a:hover { background: var(--chip); color: var(--ink); }
.edit-sec { padding: 22px 24px; margin-bottom: 18px; scroll-margin-top: 90px; }
.edit-sec h2 { margin: 0 0 6px; font-size: 26px; }
.edit-sec .meta { margin: 0 0 14px; }
.edit-sec.danger { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--bad) 40%, transparent); }
.genre-group { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.genre-group .label { min-width: 11rem; font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.cover-drop {
  position: relative; min-height: 220px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 14px; border-radius: 16px; border: 1.5px dashed var(--line-2); background: var(--chip);
  text-align: center; cursor: pointer;
}
.cover-drop.is-over { border-color: var(--accent); background: var(--accent-soft); }
.cover-drop.has-preview { justify-content: flex-start; }
.cover-preview { display: none; width: min(160px, 70%); max-height: 240px; object-fit: contain; border-radius: var(--cover-r); }
.cover-preview:not([hidden]) { display: block; }
.cover-drop-hint { margin: 0; font-size: 13.5px; color: var(--muted); }
.suggest-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

/* ---------- Кабинет и вход ---------- */

.qr-pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin: 12px 0 18px; }
.qr-card { padding: 20px; text-align: center; }
.qr-card h3 { margin-top: 0; }
.qr {
  display: flex;
  justify-content: center;
  align-items: center;
  box-sizing: border-box;
  width: fit-content;
  max-width: 100%;
  padding: 12px;
  margin: 12px auto;
  border-radius: 14px;
  background: #fff;
  line-height: 0;
}
.qr svg { display: block; width: min(200px, 100%); height: auto; aspect-ratio: 1; background: #fff; margin: 0 auto; }
.auth-page { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: min(440px, 100%); padding: 28px 24px 32px; text-align: center; }
.auth-card .qr { margin-left: auto; margin-right: auto; }
.auth-card .brand { justify-content: center; margin-bottom: 12px; }
.auth-card h1 { font-size: 32px; margin: 8px 0 6px; }
.auth-card .lede { margin-left: auto; margin-right: auto; }
.auth-card .actions { justify-content: center; margin-top: 16px; }
.otp-form { display: flex; gap: 8px; justify-content: center; margin-top: 12px; }
.otp-input {
  width: 9em; min-height: 48px; text-align: center; letter-spacing: 0.35em; font-size: 20px;
  border: 0; border-radius: 12px; background: var(--chip); color: var(--ink); box-shadow: var(--glass-edge);
}

/* ---------- Аудио: кнопки-дорожки и ползунок ---------- */

.track-list { list-style: none; margin: 0; padding: 0; }
button.track { width: 100%; border: 0; background: transparent; font: inherit; text-align: left; cursor: pointer; box-shadow: none; height: auto; }
.track .name { min-width: 0; display: flex; align-items: center; gap: 10px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.track .st svg { visibility: hidden; }
.track.done .st svg { visibility: visible; }
.track.cur, .track.on { background: var(--accent-soft); color: var(--ink); }
.track.cur .n, .track.on .n { color: var(--accent); }
.track:not(.cur):not(.done) .progress { visibility: hidden; }
.track .eq { display: none; }
.track.cur.playing .eq { display: inline-flex; }
.player-seek { height: auto; background: none; }
.listen-seek {
  -webkit-appearance: none; appearance: none; display: block; width: 100%; height: 4px; margin: 0;
  background: var(--chip-2); outline: none; cursor: pointer;
}
.listen-seek::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent); border: 0; box-shadow: 0 0 0 4px var(--accent-soft);
}
.listen-seek::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--accent); border: 0; }
.ctrl .icon-play, .ctrl .icon-pause { display: grid; place-items: center; }
.chip.on-timer { background: var(--accent-soft); color: var(--accent); }
.listen-note { font-size: 13.5px; margin: 0; }

/* ---------- Мелочи карточки книги ---------- */

.side-link {
  width: 100%; height: auto; display: flex; align-items: center; justify-content: flex-start; gap: 10px;
  padding: 8px 10px; border: 0; border-radius: 10px; background: transparent; box-shadow: none;
  color: var(--ink-2); font: inherit; font-size: 14px; font-weight: 400; cursor: pointer;
}
.side-link:hover { background: var(--chip); color: var(--ink); }
.rating .has-audio { display: inline-flex; align-items: center; gap: 6px; }
.facts .links a + a { margin-left: 14px; }
.series-head h3 a { color: inherit; }
.series-head h3 a:hover { color: var(--accent); }
.offer-prev { margin: 16px 0 0; padding: 16px 18px; }
.offer-prev ul { margin: 6px 0 12px; padding-left: 1.2em; color: var(--ink-2); }
.side-box.tight { padding: 8px; }

/* ---------- Полка, добавление книги ---------- */

.shelf-tabs { margin-top: 18px; }
.shelf-grid { margin-top: 28px; }
.add-seed { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 18px; align-items: start; }
.add-seed h2 { margin: 0 0 4px; font-size: 24px; }

/* ---------- Telegram ---------- */

body.tg-app .mainnav, body.tg-app .brand em, body.tg-app .pill-count { display: none; }
body.tg-app .tabbar.fixed {
  display: grid; position: fixed; z-index: 44;
  height: calc(62px + env(safe-area-inset-bottom)); padding: 6px 4px env(safe-area-inset-bottom);
}
body.tg-app .page { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
body.tg-app.has-player .page { padding-bottom: calc(190px + env(safe-area-inset-bottom)); }
body.tg-app .player { bottom: calc(62px + env(safe-area-inset-bottom)); }

/* ---------- Меньше движения ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* ---------- Адаптивность ----------
   Одна вёрстка на все ширины:
   ≤1100 — узкий ноутбук и планшет в альбомной ориентации,
   ≤900  — планшет,
   ≤760  — телефон в браузере и в Telegram: вкладки внизу, одна колонка. */

.tabbar.fixed { display: none; }

@media (max-width: 1100px) {
  .topbar-in { gap: 24px; }
  .mainnav { gap: 18px; }
  .hero { gap: 32px; }
  .pile { width: 210px; height: 315px; margin-right: 80px; }
  .pile .cover { width: 210px; }
  .families { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .eras { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .book { grid-template-columns: 260px minmax(0, 1fr); gap: 40px; }
  .side-box { padding: 14px; }
  .side-box .seg button { padding: 0 7px; font-size: 13px; }
  .facts { grid-template-columns: max-content minmax(0, 1fr); }
  .spines { flex-wrap: wrap; }
  .spine-next { flex-basis: 100%; max-width: none; margin: 40px 0 0; }
  .filterbar { flex-wrap: wrap; border-radius: 24px; }
  .filterbar .right { margin-left: 0; }
  .listen { grid-template-columns: 240px minmax(0, 1fr); gap: 40px; }
  .track { grid-template-columns: 40px minmax(0, 1fr) 100px 116px 24px; }
}

@media (max-width: 900px) {
  .search-pill { flex: 0 0 44px; width: 44px; min-width: 0; padding: 0; justify-content: center; }
  .search-pill input, .search-pill .kbd { display: none; }
  .pill-count { font-size: 0; gap: 0; padding: 0 5px; }
  .pill-count b { font-size: 12px; }
  .brand em { display: none; }
  .player-right .time { display: none; }
  /* Выбор жанра раскрывается на всю ширину строки фильтров, а не от кнопки */
  .fpop { position: static; }
  .popover { left: 10px; right: 10px; width: auto; }
  .series-head { flex-direction: column; gap: 2px; }
  /* Корешки без подписей: восемь томов помещаются в узкую колонку */
  .spine { width: 34px; max-height: 170px; padding: 7px 0 22px; }
  .spine:nth-child(odd) { max-height: 156px; }
  .spine:nth-child(3n) { max-height: 164px; }
  .spine .num { font-size: 16px; }
  .spine .name { display: none; }
  .spine .mark { width: 15px; height: 15px; bottom: 5px; }
  .spine .mark svg { width: 10px; height: 10px; }
  .spine.cur::after { bottom: -22px; font-size: 9px; }
  .spines { gap: 6px; min-height: 0; }
}

@media (max-width: 760px) {
  body { font-size: 14px; }

  /* Шапка: логотип, поиск, колокольчик, аватар. Разделы — во вкладках внизу, модерация — во вкладке «Я» */
  .topbar-in { height: 56px; gap: 8px; }
  .mainnav, .pill-count { display: none; }
  .brand { font-size: 24px; gap: 8px; }
  .brand-mark { width: 22px; height: 22px; }
  .search-pill { flex: 1 1 auto; width: auto; height: 40px; padding: 0 12px; justify-content: flex-start; margin-left: 6px; }
  .search-pill input { display: block; font-size: 14px; }
  .top-actions { gap: 2px; }
  .avatar { width: 34px; height: 34px; }
  .tabbar.fixed {
    display: grid;
    position: fixed;
    z-index: 44;
    height: calc(62px + env(safe-area-inset-bottom));
    padding: 6px 4px env(safe-area-inset-bottom);
  }
  .page { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
  .crumbs { font-size: 13px; padding-top: 10px; }

  .display { font-size: 36px; }
  .section { margin-top: 36px; }
  .section-head { flex-wrap: wrap; gap: 10px 16px; margin-bottom: 14px; }
  .section-head h2 { font-size: 26px; }
  .section-head .left { gap: 12px; }
  .section-hint { margin: -4px 0 14px; font-size: 13px; }
  .seg { max-width: 100%; overflow-x: auto; scrollbar-width: none; }

  /* Ленты листаются пальцем, стрелки не нужны */
  .rail-track {
    grid-auto-columns: 124px;
    gap: 14px;
    -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 48px), transparent);
    mask-image: linear-gradient(90deg, #000 calc(100% - 48px), transparent);
  }
  .rail-next { display: none; }
  .card { gap: 9px; }
  .card-title { font-size: 16px; }
  .card-meta, .card-sub, .card-note { font-size: 12px; }
  .cv-badge { font-size: 10px; padding: 3px 7px; top: 6px; left: 6px; }
  .cv-audio { width: 24px; height: 24px; right: 6px; bottom: 6px; }
  .cv-audio svg { width: 12px; height: 12px; }

  /* Фон из обложки: пятно по центру, уходит в фон вниз */
  .backdrop { height: 520px !important; }
  .backdrop::before { right: -40%; width: 180%; top: -10%; height: 110%; }
  .backdrop::after {
    background: linear-gradient(180deg, color-mix(in srgb, var(--bg) 35%, transparent) 0%, transparent 30%, color-mix(in srgb, var(--bg) 55%, transparent) 65%, var(--bg) 100%);
  }

  /* Главная: герой — компактная карточка, как в Telegram */
  .hero {
    grid-template-columns: 96px minmax(0, 1fr);
    align-items: start;
    gap: 16px;
    min-height: 0;
    margin-top: 8px;
    padding: 14px;
    border-radius: 22px;
    background: linear-gradient(135deg, color-mix(in srgb, var(--g1, var(--accent)) 30%, var(--surface)), var(--surface) 75%);
    box-shadow: var(--glass-edge), var(--shadow-md);
  }
  .pile { order: -1; width: 96px; height: 144px; margin: 0; }
  .pile .cover { width: 96px; }
  .pile .cover.p1 { box-shadow: var(--cover-shadow); }
  .pile .cover.p2, .pile .cover.p3 { display: none; }
  .hero-text { gap: 6px; }
  .hero .kicker { font-size: 10.5px; letter-spacing: 0.14em; }
  .hero .display { font-size: 23px; line-height: 1.05; }
  .hero-meta { font-size: 12.5px; color: var(--muted); }
  .hero-meta a { color: var(--muted); border-bottom: 0; }
  .hero-progress { gap: 6px; margin-top: 4px; }
  .hero-progress span { font-size: 12px; }
  .hero .actions { margin-top: 6px; }
  .hero .btn { height: 40px; padding: 0 16px; font-size: 14px; }
  .hero .btn { width: 100%; }
  .hero .btn.ghost, .dots { display: none; }
  .hero-text > .muted { display: none !important; }

  .families { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .family { min-height: 112px; padding: 14px; border-radius: 16px; }
  .family b { font-size: 21px; }
  .family span { font-size: 12px; }
  .family .mini { display: none; }
  .eras { display: flex; gap: 10px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; }
  .era { flex: 0 0 150px; }
  .footer { flex-direction: column; align-items: flex-start; margin-top: 48px; font-size: 13px; }

  /* Карточка книги: одна колонка в порядке чтения —
     обложка, название, автор, рейтинг, кнопки, статус, описание, факты, серия, файлы */
  .book { display: flex; flex-direction: column; align-items: stretch; gap: 0; padding-top: 12px; }
  .book-side, .book-main { display: contents; }
  .book-side > .cover { order: 1; width: 190px; align-self: center; margin: 4px 0 22px; }
  .book-top { order: 2; align-items: center; }
  .book-main h1 { order: 3; font-size: 34px; margin-top: 10px; }
  .book-author { order: 4; font-size: 17px; margin-top: 8px; }
  .rating { order: 5; margin-top: 10px; gap: 4px 12px; font-size: 13px; }
  .book-main .actions { order: 6; margin-top: 20px; }
  .book-main .actions .btn { flex: 1 1 100%; }
  .book-side > .side-box:nth-child(2) { order: 7; margin-top: 16px; }
  .annotation { order: 8; margin-top: 22px; font-size: 16.5px; }
  .facts { order: 9; margin-top: 22px; gap: 10px 16px; font-size: 14px; }
  .series { order: 10; margin-top: 28px; padding: 16px 16px 30px; }
  .book-side > .side-box:nth-child(3) { order: 11; margin-top: 16px; }
  .edit-pill { flex: none; width: 36px; height: 36px; padding: 0; justify-content: center; font-size: 0; }
  .series-head { flex-direction: column; gap: 2px; margin-bottom: 14px; }
  .series-head h3 { font-size: 22px; }
  .spines { flex-wrap: wrap; gap: 6px; min-height: 0; }
  .spine { width: 34px; max-height: 150px; padding: 7px 0 22px; }
  .spine:nth-child(odd) { max-height: 138px; }
  .spine:nth-child(3n) { max-height: 146px; }
  .spine .num { font-size: 16px; }
  .spine .name { display: none; }
  .spine .mark { width: 15px; height: 15px; bottom: 5px; }
  .spine .mark svg { width: 10px; height: 10px; }
  .spine.cur::after { bottom: -22px; font-size: 9px; }
  .spine-next { flex-basis: 100%; max-width: none; margin: 34px 0 0; }
  .spine-next a.title { font-size: 20px; }

  /* Каталог: фильтры — лента чипов под шапкой, выбор значений — нижняя шторка */
  .tabs { gap: 22px; overflow-x: auto; scrollbar-width: none; white-space: nowrap; }
  .tabs a { font-size: 14px; }
  .catalog-head { margin-top: 16px; }
  .catalog-head h1 { font-size: 32px; }
  .catalog-head .count { font-size: 13.5px; }
  .filterbar {
    top: 56px;
    margin: 18px -16px 0;
    padding: 8px 16px;
    border-radius: 0;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    background: color-mix(in srgb, var(--bg) 94%, transparent);
    box-shadow: 0 1px 0 var(--line);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
  .filterbar .sep { display: none; }
  .filterbar .right { margin-left: 0; }
  .fbtn { height: 36px; padding: 0 12px; font-size: 13.5px; }
  .toggle { padding: 0 4px; font-size: 13.5px; }
  .popover {
    position: fixed;
    left: 0;
    right: 0;
    top: auto;
    bottom: calc(62px + env(safe-area-inset-bottom));
    width: auto;
    max-height: min(70vh, 560px);
    overflow-y: auto;
    padding: 16px 16px 18px;
    border-radius: 22px 22px 0 0;
    box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.5), 0 -20px 60px rgba(0, 0, 0, 0.45);
  }
  .popover::before { content: ""; display: block; width: 40px; height: 4px; margin: -6px auto 12px; border-radius: 2px; background: var(--line-2); }
  .pop-list { grid-template-columns: 1fr; }
  .pop-foot { flex-direction: column; align-items: stretch; gap: 10px; }
  .pop-foot .btn { width: 100%; }
  .active-row { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 14px 0 22px; }
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px 12px; }
  .grid .card-title { font-size: 15px; }
  .grid .card-sub { display: none; }
  .pager { margin-top: 32px; }
  .pages a, .pages span { min-width: 34px; height: 34px; }

  /* Аудио: обложка сверху, кнопки во всю ширину, мини-плеер над вкладками */
  .listen { grid-template-columns: 1fr; gap: 20px; padding-top: 12px; }
  .listen > .cover { width: 180px; justify-self: center; }
  .listen-text { gap: 10px; }
  .listen-text .kicker { font-size: 11px; }
  .listen-stats { gap: 18px; }
  .listen-stats b { font-size: 18px; }
  .listen-text .actions .btn { flex: 1 1 100%; }
  .listen-text .actions .btn.quiet { display: none; }
  .tracks { margin: 28px -16px 0; padding: 6px 8px; border-radius: 0; }
  .tracks-head { padding: 10px 8px; }
  .tracks-head h2 { font-size: 24px; }
  .track { grid-template-columns: 28px minmax(0, 1fr) auto; gap: 10px; padding: 11px 8px; font-size: 14px; }
  .track > :nth-child(3), .track > :last-child { display: none; }
  .track .dur { font-size: 12.5px; }
  .player { bottom: calc(62px + env(safe-area-inset-bottom)); }
  .player-in { grid-template-columns: minmax(0, 1fr) auto; gap: 10px; padding: 8px 12px; }
  .player-right { display: none; }
  .ctrls { gap: 2px; }
  .ctrls .ctrl:first-child, .ctrls .ctrl:last-child { display: none; }
  .ctrl { min-width: 40px; height: 40px; font-size: 13px; }
  .ctrl.play { width: 46px; height: 46px; }
  .now { gap: 10px; }
  .now .cover { width: 36px; }
  .now b { font-size: 13.5px; }
  .now span { font-size: 12px; }
  .has-player .page { padding-bottom: calc(190px + env(safe-area-inset-bottom)); }
}

/* ---------- Только для сайта: адаптивность ---------- */

@media (max-width: 900px) and (min-width: 761px) {
  .page-search { display: flex; }
}
@media (max-width: 900px) {
  .edit { grid-template-columns: 1fr; gap: 16px; }
  .edit-nav { position: static; flex-direction: row; overflow-x: auto; scrollbar-width: none; gap: 6px; }
  .edit-nav a { white-space: nowrap; background: var(--chip); border-radius: var(--r-pill); }
}
@media (max-width: 760px) {
  .backdrop > img { right: -30%; width: 160%; top: -10%; height: 110%; }
  .alpha { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-left: -16px; margin-right: -16px; padding: 0 16px; }
  .panel, .edit-sec { padding: 18px 16px; }
  .btn { height: 46px; }
  /* Полка и другие сетки с классом .as-rows — строками */
  .grid.as-rows { grid-template-columns: 1fr; gap: 0; }
  .grid.as-rows .card { flex-direction: row; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); }
  .grid.as-rows .card .cover { width: 54px; flex: none; }
  .grid.as-rows .card-title { font-family: var(--font-ui); font-size: 15px; font-weight: 600; }
  .grid.as-rows .card:hover .cover { transform: none; }
  .grid.as-rows .card-body { flex: 1; }
}

/* ---------- Сверка аудио (из legacy) ---------- */
.audio-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(34, 28, 23, 0.82);
  color: var(--accent, #d4b483);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
  pointer-events: none;
}

.audio-bands {
  display: flex;
  flex-direction: column;
  gap: 28px;
  margin: 20px 0;
}

.audio-band-label {
  margin: 0 0 8px;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.audio-band-end .audio-band-label {
  color: var(--ink);
}

.audio-band-end .audio-compare section {
  border-style: dashed;
}

.audio-compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin: 0;
  align-items: stretch;
}

.audio-compare section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: min(72vh, 44rem);
}

.audio-compare .audio-text {
  flex: 1 1 auto;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  min-height: 10rem;
  padding-right: 6px;
}

.audio-compare .audio-text .annotation {
  white-space: pre-wrap;
  max-width: none;
}

.audio-compare mark.hit {
  background: rgba(143, 186, 122, 0.32);
  color: inherit;
  padding: 0 0.08em;
  border-radius: 2px;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.audio-compare audio,
#chapter-player,
#clip-player {
  width: 100%;
  margin: 8px 0 12px;
}

.audio-compare h3 {
  font-size: 1rem;
  margin: 12px 0 8px;
}

.audio-shared {
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--warn) 50%, transparent);
  background: var(--surface);
  border-radius: var(--r-md);
  padding: 12px 14px;
  margin: 8px 0 18px;
}

.audio-shared > .lede {
  margin: 0 0 10px;
  max-width: none;
}

.audio-shared .list { margin: 0; }

.audio-shared .list li { margin-bottom: 6px; }

.audio-shared .list li:last-child { margin-bottom: 0; }

@media (max-width: 700px) {
  .audio-compare { grid-template-columns: 1fr; }
}
