/* The Big Booklog. Тёмная тема по умолчанию, светлая «бумага» через data-theme. */

:root,
:root[data-theme="dark"] {
  --bg: #13110f;
  --bg-2: #191613;
  --surface: #201c18;
  --surface-2: #28231e;
  --surface-3: #312b25;
  --line: #3a332c;
  --line-soft: #2c2621;
  --text: #f1e9dd;
  --muted: #a99c8c;
  --faint: #776b5f;
  --accent: #e3a857;
  --accent-ink: #1c1309;
  --accent-soft: rgba(227, 168, 87, 0.14);
  --ok: #7cc4a4;
  --danger: #e0776b;
  --st-want: #8fa8d8;
  --st-reading: #e3a857;
  --st-read: #7cc4a4;
  --st-paused: #b9a3d9;
  --st-dropped: #8d8378;
  --heat-0: #302a24;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  --cover-shadow: 0 1px 0 rgba(255, 255, 255, 0.06) inset, 0 6px 18px rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f5efe4;
  --bg-2: #efe7d9;
  --surface: #fffcf6;
  --surface-2: #f3ebdd;
  --surface-3: #e9dfcd;
  --line: #ddd0bb;
  --line-soft: #e9e0d0;
  --text: #2a2119;
  --muted: #76675a;
  --faint: #a39482;
  --accent: #b76e1f;
  --accent-ink: #fffaf2;
  --accent-soft: rgba(183, 110, 31, 0.12);
  --ok: #3f8f6d;
  --danger: #bf4a3d;
  --st-want: #4f6fae;
  --st-reading: #b76e1f;
  --st-read: #3f8f6d;
  --st-paused: #7d62a8;
  --st-dropped: #8b8178;
  --heat-0: #e6dccb;
  --shadow: 0 10px 30px rgba(60, 40, 20, 0.16);
  --cover-shadow: 0 6px 16px rgba(60, 40, 20, 0.25);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
input, textarea, select { font: inherit; color: inherit; }
svg { fill: currentColor; }
h1, h2, h3, .serif { font-family: Literata, Georgia, serif; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 30px; margin: 0 0 4px; line-height: 1.2; }
h2 { font-size: 20px; margin: 0; }
h3 { font-size: 16px; margin: 0; }
[hidden] { display: none !important; }

/* ------------------------------------------------------------ каркас */

.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 18px;
  padding: calc(env(safe-area-inset-top) + 20px) 14px 20px;
  background: var(--bg-2);
  border-right: 1px solid var(--line-soft);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 6px; }
.brand-text { font-family: Literata, Georgia, serif; font-size: 17px; line-height: 1.1; }
.brand-text b { display: block; font-size: 12px; font-family: Inter, sans-serif; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px; border-radius: 10px;
  color: var(--muted); font-weight: 500;
  transition: background .15s, color .15s;
}
.nav a svg { width: 20px; height: 20px; flex: none; }
.nav a:hover { background: var(--surface); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.add-btn { margin: 4px 0; justify-content: center; }
.side-foot { margin-top: auto; font-size: 13px; color: var(--faint); }
.side-foot .who { color: var(--muted); font-weight: 600; }

/* min-width: 0 обязателен: у элемента сетки минимальная ширина по умолчанию
   равна содержимому, и прокручиваемые вбок блоки (тепловая карта, вкладки
   импорта) растягивали страницу на телефоне до 866px вместо прокрутки. */
.main { padding: calc(env(safe-area-inset-top) + 32px) 40px 80px; max-width: 1280px; width: 100%; min-width: 0; outline: none; }
.loading { color: var(--faint); padding: 40px 0; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-sub { color: var(--muted); margin: 0; }

.section { margin-top: 34px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.section-head a { color: var(--muted); font-size: 14px; }
.section-head a:hover { color: var(--accent); }

/* ------------------------------------------------------------ кнопки и поля */

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); cursor: pointer; font-weight: 500;
  transition: background .15s, border-color .15s, transform .1s;
  white-space: nowrap;
}
.btn svg { width: 18px; height: 18px; }
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn-accent { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 600; }
.btn-accent:hover { background: var(--accent); filter: brightness(1.08); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface); color: var(--text); }
.btn-danger { color: var(--danger); }
.btn-sm { padding: 5px 11px; font-size: 13px; border-radius: 8px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px;
  border: 0; background: transparent; border-radius: 9px; cursor: pointer; color: var(--muted);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg { width: 20px; height: 20px; }

.input, .textarea, .select {
  width: 100%; padding: 9px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg-2);
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.input:focus, .textarea:focus, .select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.textarea { resize: vertical; min-height: 90px; line-height: 1.55; }
.input-num { width: 90px; text-align: center; }
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }

.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--line-soft); }
.seg button {
  border: 0; background: transparent; padding: 7px 12px; border-radius: 9px; cursor: pointer;
  color: var(--muted); font-weight: 500; display: inline-flex; align-items: center; gap: 7px;
}
.seg button:hover { color: var(--text); background: var(--surface); }
.seg button.on { background: var(--surface-3); color: var(--text); }
.seg .count { font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 11px; border-radius: 999px; font-size: 13px;
  border: 1px solid var(--line); background: transparent; cursor: pointer; color: var(--muted);
}
.chip:hover { color: var(--text); border-color: var(--faint); }
.chip.on { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.status-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; letter-spacing: .02em; }
.st-want { --st: var(--st-want); }
.st-reading { --st: var(--st-reading); }
.st-read { --st: var(--st-read); }
.st-paused { --st: var(--st-paused); }
.st-dropped { --st: var(--st-dropped); }
.status-pill .dot, .seg .dot { background: var(--st); }
.status-pill { color: var(--st); }

.card { background: var(--surface); border: 1px solid var(--line-soft); border-radius: 16px; padding: 20px; }
.hint { color: var(--muted); margin: 0; }
.empty { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty h2 { color: var(--text); margin-bottom: 6px; }
.empty .btn { margin-top: 16px; }

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

.cover {
  position: relative; aspect-ratio: var(--ar, 2 / 3); border-radius: 4px 8px 8px 4px; overflow: hidden;
  background: var(--surface-2); box-shadow: var(--cover-shadow);
}
.cover-slot { aspect-ratio: 2 / 3; display: flex; align-items: flex-end; justify-content: center; }
.cover-slot > .cover { width: 100%; }
/* Узкая книга упирается в высоту слота и становится уже, широкая ниже. */
.cover-slot > .cover.narrow { width: auto; height: 100%; }
.cover img { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; object-fit: cover; display: block; }
/* Корешок: тонкая тень слева, как у настоящей книги на полке. */
.cover::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 2;
  background: linear-gradient(90deg, rgba(0,0,0,.28) 0, rgba(255,255,255,.08) 3%, transparent 7%);
}
.cover-fallback {
  position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-between;
  padding: 12% 10% 10% 14%; color: #fbf4e8;
  background: linear-gradient(160deg, hsl(var(--h) 38% 34%), hsl(var(--h) 42% 20%));
}
.cover-fallback .t { font-family: Literata, Georgia, serif; font-weight: 600; font-size: clamp(11px, 1.05em, 17px); line-height: 1.2; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; }
.cover-fallback .a { font-size: .72em; opacity: .75; line-height: 1.25; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.cover-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(0,0,0,.45); z-index: 3; }
.cover-progress i { display: block; height: 100%; background: var(--accent); }

/* ------------------------------------------------------------ 3D-обложки (static/book3d.js)
   Грани живут внутри .cover и видны только в режиме tilt3d. Там же
   overflow:visible и preserve-3d: с overflow:hidden браузер сплющивает 3D. */

.cover.fx { border-radius: 2px 5px 5px 2px; touch-action: pan-y; }
.cover.fx-big { touch-action: none; cursor: grab; }
.cover.fx img { -webkit-user-drag: none; user-select: none; }
/* В 3D углы прямые: скругление лица оставляло просветы на стыках с гранями.
   Фон самой .cover убираем, иначе он висит плоскостью внутри книги. */
.cover.tilt3d { overflow: visible; transform-style: preserve-3d; z-index: 5; box-shadow: none; border-radius: 0; background: transparent; }
.cover.tilt3d > img, .cover.tilt3d > .cover-fallback, .cover.tilt3d::after,
.cover.tilt3d > .cover-progress, .cover.tilt3d > .tile-badge { backface-visibility: hidden; border-radius: 0; }
/* Плитка это ссылка: после крутки мышью на ней оставалась рамка фокуса. */
a.tile:focus, .cover-row a:focus, .reading-card a:focus { outline: none; }
a.tile:focus-visible .cover, .cover-row a:focus-visible .cover { outline: 2px solid var(--accent); outline-offset: 3px; }
/* Плитка под наклоном выходит из виртуализации: paint containment режет грани. */
.tile.fx-live { content-visibility: visible; position: relative; z-index: 5; }
.cover-row a.fx-live { position: relative; z-index: 5; }

.bk-face { position: absolute; visibility: hidden; pointer-events: none; }
.cover.tilt3d .bk-face { visibility: visible; }
.bk-spine {
  /* Грань стоит слева от обложки и повёрнута лицом наружу, иначе название
     на корешке читается зеркально. */
  /* Все грани встык и с нахлестом в 1px: иначе на стыках видны щели
     сглаживания, а утопленный обрез без картонных краёв смотрелся дырой. */
  right: calc(100% - 1px); top: 0; width: calc(var(--depth) + 1px); height: 100%;
  transform-origin: right center; transform: rotateY(-90deg);
  background: linear-gradient(90deg, rgba(0,0,0,.35), rgba(255,255,255,.1) 45%, rgba(0,0,0,.3)), var(--spine);
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.bk-spine span {
  writing-mode: vertical-rl; transform: rotate(180deg);
  font-family: Literata, Georgia, serif; font-weight: 600; color: rgba(255, 248, 235, .88);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-height: 86%; line-height: 1;
}
/* Две строки вдоль корешка: переносы по словам, по центру, без многоточия. */
.bk-spine span.two {
  white-space: normal; text-overflow: clip; text-align: center; line-height: 1.12;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
}
/* mix-blend-mode у блика здесь нельзя: Chromium тогда сплющивает весь 3D
   контекст, и грани превращаются в линии. */
/* Обрез страниц: полоски вдоль толщины, у краёв чуть темнее от твёрдой обложки. */
.bk-pages { background-color: #e9dfc9; }
.bk-right {
  left: calc(100% - 1px); top: 0; width: calc(var(--depth) + 1px); height: 100%;
  transform-origin: left center; transform: rotateY(90deg);
  background-image: linear-gradient(90deg, rgba(0,0,0,.25), transparent 12%, transparent 88%, rgba(0,0,0,.18)),
    repeating-linear-gradient(90deg, #f1e9d6 0 1px, #d8ccb3 1px 2px);
}
.bk-top, .bk-bottom {
  left: 0; width: 100%; height: calc(var(--depth) + 1px);
  background-image: linear-gradient(90deg, rgba(0,0,0,.2), transparent 10%),
    repeating-linear-gradient(0deg, #f1e9d6 0 1px, #d8ccb3 1px 2px);
}
.bk-top { bottom: calc(100% - 1px); transform-origin: center bottom; transform: rotateX(90deg); }
.bk-bottom { top: calc(100% - 1px); transform-origin: center top; transform: rotateX(-90deg); }
.bk-backer-spine {
  right: calc(100% - 3px); top: 1px; width: var(--depth); height: calc(100% - 2px);
  transform-origin: right center; transform: rotateY(-90deg); background: var(--spine);
}
.bk-backer-pages {
  left: calc(100% - 3px); top: 1px; width: var(--depth); height: calc(100% - 2px);
  transform-origin: left center; transform: rotateY(90deg); background: #e2d7bf;
}
.bk-back {
  inset: 0;
  transform: translateZ(calc(-1 * var(--depth))) rotateY(180deg);
  background: linear-gradient(90deg, rgba(255,255,255,.06), transparent 30%), var(--spine);
  backface-visibility: hidden;
}
.bk-glare {
  position: absolute; inset: 0; z-index: 4; pointer-events: none; border-radius: inherit;
  background: radial-gradient(circle at var(--gx, 50%) var(--gy, 40%), rgba(255, 250, 240, .42), rgba(255, 250, 240, 0) 58%);
  opacity: var(--go, 0); transform: translateZ(.5px); backface-visibility: hidden;
}

/* ------------------------------------------------------------ главная */

/* Заголовок «Читаю сейчас» отдельной строкой над левой колонкой: правая
   колонка начинается вровень с первой карточкой книги, а не с заголовком. */
.home-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; grid-template-areas: "head ." "main side"; gap: 0 24px; align-items: start; }
.home-head { grid-area: head; }
.home-main { grid-area: main; min-width: 0; }
.home-grid > .stat-stack { grid-area: side; }

.car { margin-top: 28px; }
.car-head { display: flex; align-items: center; margin-bottom: 12px; user-select: none; }
.car-head h2 { margin: 0; }
.car-all { margin-left: auto; color: var(--muted); font-size: 14px; }
.car-all:hover { color: var(--accent); }
.car-btn { height: 22px; flex: none; padding: 0; display: flex; align-items: center; justify-content: center; background: none; border: 0; color: var(--muted); cursor: pointer; transition: width .24s ease, margin .24s ease, opacity .24s ease, color .15s ease; }
.car-btn svg { width: 16px; height: 16px; display: block; flex: none; }
.car-btn:hover { color: var(--accent); }
.car-btn[hidden] { display: none; }
.car-next { width: 22px; margin-left: 10px; }
.car-next:disabled { opacity: .25; cursor: default; }
/* «Назад» в покое схлопнута: заголовок стоит у края и уезжает вправо
   плавно, ровно на ширину стрелки. */
.car-prev { width: 0; opacity: 0; overflow: hidden; }
.car-prev.shown { width: 22px; margin-right: 6px; opacity: 1; }
.car-row {
  --car-w: 104px;
  display: flex; gap: 12px; overflow-x: auto; scroll-behavior: smooth; scroll-snap-type: x proximity;
  scrollbar-width: none; user-select: none;
  /* Запас под наклон обложки: скролл-контейнер режет и по второй оси. */
  padding-block: 24px; margin-block: -24px;
}
.car-row::-webkit-scrollbar { display: none; }
.car-item { flex: none; width: var(--car-w); scroll-snap-align: start; }
.reading-list { display: flex; flex-direction: column; gap: 14px; }
.reading-card { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 18px; padding: 16px; }
.reading-card .cover-slot { width: 92px; }
.reading-card .rc-title { font-family: Literata, Georgia, serif; font-size: 18px; font-weight: 600; line-height: 1.25; }
.reading-card .rc-title:hover { color: var(--accent); }
.reading-card .rc-title { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.reading-card .rc-author { color: var(--muted); font-size: 14px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rc-desc {
  margin: 8px 0 0; font-size: 13px; line-height: 1.5; color: var(--faint);
  display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden;
}
.rc-desc.clampable { cursor: pointer; transition: color .15s ease; }
.rc-desc.clampable:hover { color: var(--text); }
.rc-desc.expanded { -webkit-line-clamp: unset; overflow: visible; color: var(--muted); }
.rc-body { display: flex; flex-direction: column; min-width: 0; }
.progress-line { display: flex; align-items: center; gap: 12px; margin-top: auto; padding-top: 14px; }
.bar { flex: 1; height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 70%, #fff)); transition: width .4s ease; }
.pct { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 42px; text-align: right; }

.stat-stack { display: flex; flex-direction: column; gap: 14px; }
.goal-card { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; }
.ring { position: relative; width: 148px; height: 148px; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 11; }
.ring .track { stroke: var(--surface-3); }
.ring .val { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset .8s ease; }
.ring .mark { stroke: var(--faint); stroke-width: 13; }
.ring-center { position: absolute; inset: 0; display: grid; place-content: center; }
.ring-center b { font-family: Literata, Georgia, serif; font-size: 34px; line-height: 1; }
.ring-center span { color: var(--muted); font-size: 13px; }
.mini-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.mini { padding: 16px; }
.mini b { display: block; font-family: Literata, Georgia, serif; font-size: 26px; line-height: 1.1; }
.mini span { color: var(--muted); font-size: 13px; }
.mini.hot b { color: var(--accent); }

.heat-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 14px; margin-bottom: 16px; position: relative; }
.heat-head h2 { margin: 0; }
.heat-year { font: inherit; font-size: 14px; font-weight: 600; color: var(--accent); background: var(--accent-soft); border: 0; border-radius: 99px; padding: 4px 12px; cursor: pointer; transition: background .15s ease; }
.heat-year:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 24%, transparent); }
.heat-year:disabled { cursor: default; }
.heat-sum { flex-basis: 100%; font-size: 13px; }
.heat-years { position: absolute; top: calc(100% + 6px); left: 0; z-index: 30; display: grid; grid-template-columns: repeat(4, auto); gap: 4px; padding: 8px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
.heat-years button { font: inherit; font-size: 14px; background: none; border: 0; border-radius: 8px; padding: 6px 12px; color: var(--text); cursor: pointer; }
.heat-years button:hover { background: var(--surface-3); }
.heat-years button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* Карточка шириной с колонку «Читаю сейчас», весь год в один ряд, как
   компактный вид bigbacklog (просьба пользователя 2026-09-27: шесть в ряд
   во всю ширину выходило огромным). На телефоне четыре в ряд, иначе клетки
   в точку. Колонки тянутся, клетка считается от ширины. */
.heat-card { margin-top: 14px; }
.heat-months { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 10px 7px; }
.heat-m-title .full { display: none; }
@media (max-width: 620px) {
  .heat-months { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px 10px; }
  .heat-m-title .full { display: inline; }
  .heat-m-title .short { display: none; }
}
.heat-month { min-width: 0; }
.heat-m-title { font-size: 10px; color: var(--faint); margin-bottom: 5px; text-transform: uppercase; letter-spacing: .05em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.heat-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 1.5px; }
.heat-col { display: flex; flex-direction: column; gap: 1.5px; }
@media (max-width: 620px) { .heat-grid, .heat-col { gap: 2px; } }
.heat-cell { display: block; width: 100%; aspect-ratio: 1; border-radius: 2px; background: var(--heat-0); position: relative; }
.heat-cell.blank { background: transparent; }
/* Будущие дни тише прошедших: рамка у них перетягивала взгляд. */
.heat-cell.fut { background: color-mix(in srgb, var(--heat-0) 45%, transparent); }
.heat-cell.l1 { background: color-mix(in srgb, var(--accent) 30%, var(--heat-0)); }
.heat-cell.l2 { background: color-mix(in srgb, var(--accent) 55%, var(--heat-0)); }
.heat-cell.l3 { background: color-mix(in srgb, var(--accent) 80%, var(--heat-0)); }
.heat-cell.l4 { background: var(--accent); }
.heat-cell.today { box-shadow: 0 0 0 1px var(--text); }
/* Дочитанная книга: точка в клетке, как флажок релиза в bigbacklog. */
.heat-cell.done::after { content: ""; position: absolute; inset: 25%; border-radius: 50%; background: var(--bg); }
.heat-cell[data-d]:hover { box-shadow: 0 0 0 1px var(--accent); cursor: default; }
.heat-legend { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 16px; font-size: 12px; color: var(--faint); margin-top: 14px; }
.heat-legend-scale, .heat-legend-done { display: inline-flex; align-items: center; gap: 4px; }
.heat-legend-done { gap: 6px; }
.heat-legend .heat-cell { width: 11px; flex: none; }
.heat-tip { position: fixed; z-index: 60; pointer-events: none; display: flex; flex-direction: column; gap: 2px; max-width: 260px; padding: 8px 11px; font-size: 13px; line-height: 1.4; color: var(--muted); background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); }
.heat-tip[hidden] { display: none; }
.heat-tip b { color: var(--text); font-weight: 600; }
.heat-tip .ht-books { color: var(--text); }
.heat-tip .ht-done { color: var(--accent); }

.cover-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 16px; }
.cover-row a { display: block; }

.journal-feed { display: flex; flex-direction: column; gap: 10px; }
.jf-item { padding: 14px 16px; border-left: 3px solid var(--line); background: var(--surface); border-radius: 0 12px 12px 0; }
.jf-item.quote { border-left-color: var(--accent); }
.jf-item .jf-text { white-space: pre-wrap; }
.jf-item.quote .jf-text { font-family: Literata, Georgia, serif; font-style: italic; }
.jf-meta { font-size: 13px; color: var(--faint); margin-top: 6px; }
.jf-meta a { color: var(--muted); }
.jf-meta a:hover { color: var(--accent); }

/* ------------------------------------------------------------ регулятор прогресса */

.pc { display: flex; flex-direction: column; gap: 10px; margin-top: auto; padding-top: 12px; }
.pc-top { display: flex; align-items: center; gap: 14px; }
.pc-pct { font-family: Literata, Georgia, serif; font-weight: 600; font-size: 17px; min-width: 46px; text-align: right; font-variant-numeric: tabular-nums; }
.pc-range {
  -webkit-appearance: none; appearance: none; flex: 1; height: 10px; margin: 0; border-radius: 99px; cursor: pointer;
  background: linear-gradient(90deg, var(--accent) var(--p), var(--surface-3) var(--p));
}
.pc-range:focus-visible { outline: 2px solid var(--accent-soft); outline-offset: 4px; }
.pc-range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 22px; height: 22px; border-radius: 50%;
  background: #fff8ec; border: 4px solid var(--accent); box-shadow: 0 2px 6px rgba(0, 0, 0, .35); transition: transform .12s;
}
.pc-range:active::-webkit-slider-thumb { transform: scale(1.15); }
.pc-range::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: #fff8ec; border: 4px solid var(--accent); }
.pc-range::-moz-range-track { background: transparent; }
.pc-bottom { display: flex; align-items: center; gap: 8px 10px; flex-wrap: wrap; font-size: 14px; color: var(--muted); }
.pc-page { font-variant-numeric: tabular-nums; }
.pc-num {
  font: inherit; font-weight: 700; color: var(--text); background: var(--surface-2); border: 1px dashed var(--line);
  border-radius: 6px; padding: 1px 8px; cursor: text; font-variant-numeric: tabular-nums;
}
.pc-num:hover { border-color: var(--accent); }
.pc-input { width: 76px; padding: 3px 6px; text-align: center; display: inline-block; }
.pc-delta { color: var(--accent); font-weight: 600; min-width: 0; }
.pc-steps { display: inline-flex; gap: 4px; margin-left: auto; }
.pc-steps button {
  font: inherit; font-size: 13px; font-weight: 600; color: var(--muted); background: var(--surface-2);
  border: 1px solid var(--line-soft); border-radius: 8px; padding: 4px 9px; cursor: pointer; font-variant-numeric: tabular-nums;
}
.pc-steps button:hover { color: var(--text); border-color: var(--faint); }
.pc-steps button:active { transform: translateY(1px); }
.pc-nopages { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: auto; padding-top: 12px; color: var(--muted); font-size: 14px; }
.progress-card .pc { margin-top: 0; padding-top: 0; }
.pc-total { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line-soft); }

/* ------------------------------------------------------------ опыт */

.xp-badge { position: relative; display: inline-grid; place-items: center; width: var(--sz); height: calc(var(--sz) * 52 / 48); flex: none; }
.xp-badge svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.xp-badge .rib { fill: color-mix(in srgb, var(--rc) 70%, #000); }
.xp-badge .ring { fill: color-mix(in srgb, var(--rc) 85%, #000); stroke: color-mix(in srgb, var(--rc) 60%, #fff); stroke-width: 1.5; }
.xp-badge .core { fill: color-mix(in srgb, var(--rc) 35%, #15110d); stroke: color-mix(in srgb, var(--rc) 50%, #000); stroke-width: 1; }
.xp-badge b { position: relative; top: calc(var(--sz) * -0.07); font-family: Literata, Georgia, serif; font-weight: 700; color: #fff8ec;
  font-size: calc(var(--sz) * 0.36); line-height: 1; text-shadow: 0 1px 2px rgba(0,0,0,.6); font-variant-numeric: lining-nums; }
.xp-bar { position: relative; height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.xp-bar i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 99px; }
.xp-main { z-index: 1; background: linear-gradient(90deg, color-mix(in srgb, var(--rc) 75%, #000), var(--rc)); }
/* Прирост золотом (палитра bigbacklog): без светлого конца, иначе торчит
   только кремовый хвост. */
.xp-gain { width: 0; background: linear-gradient(90deg, #e0a13a, #ffd36b); box-shadow: 0 0 10px rgba(255, 211, 107, .45); transition: opacity .6s ease; }
.xp-gain.spent { opacity: 0; }
.xp-bar.land { animation: xp-land .6s ease-out; }
@keyframes xp-land { 0% { box-shadow: 0 0 14px 2px color-mix(in srgb, var(--rc) 65%, transparent); } 100% { box-shadow: 0 0 0 0 transparent; } }
.xp-plus { margin-left: 6px; color: #ffd36b; font-weight: 700; font-variant-numeric: tabular-nums; }
.xp-side-wrap { display: flex; flex-direction: column; gap: 8px; }

.side-foot { display: flex; flex-direction: column; gap: 8px; padding: 0 6px; }
.xp-side { display: flex; align-items: center; gap: 10px; }
.xp-side-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.xp-side-text .rank { font-size: 12px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.xp-side:hover .who { color: var(--text); }
.xp-side-num { font-size: 11px; color: var(--faint); font-variant-numeric: tabular-nums; }

.xp-card { display: flex; flex-direction: column; gap: 12px; }
.xp-card-top { display: flex; align-items: center; gap: 14px; }
.xp-card-text { min-width: 0; }
.xp-rank { font-family: Literata, Georgia, serif; font-size: 19px; font-weight: 600; line-height: 1.2; color: var(--rc); }
.xp-card .xp-bar { height: 9px; }
.xp-card-foot { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; color: var(--muted); flex-wrap: wrap; font-variant-numeric: tabular-nums; }
.xp-sources { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin-top: 6px; padding-top: 14px; border-top: 1px solid var(--line-soft); }
.xp-sources b { display: block; font-family: Literata, Georgia, serif; font-size: 20px; }
.xp-sources span { font-size: 12px; color: var(--muted); }
.xp-layout { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.ranks { display: flex; flex-direction: column; gap: 2px; }
.rank-row { display: grid; grid-template-columns: 34px 12px 1fr; gap: 10px; align-items: center; padding: 5px 8px; border-radius: 8px; color: var(--faint); font-size: 14px; }
.rank-row .rank-lvl { font-variant-numeric: tabular-nums; text-align: right; font-size: 12px; }
.rank-row .rank-dot { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--rc); opacity: .5; }
.rank-row.got { color: var(--muted); }
.rank-row.got .rank-dot { background: var(--rc); opacity: 1; }
.rank-row.cur { background: color-mix(in srgb, var(--rc) 14%, transparent); color: var(--text); font-weight: 600; }
.xp-rules { margin-top: 16px; }
.xp-rules summary { cursor: pointer; font-weight: 600; }
.xp-rules ul { margin: 12px 0 0; padding-left: 20px; color: var(--muted); line-height: 1.6; }
.levelup .xp-badge { margin: 0 auto; }

/* ------------------------------------------------------------ полка */

.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 14px; }
.toolbar .grow { flex: 1; min-width: 180px; max-width: 320px; }
.toolbar .select { width: auto; }
.shelves-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 22px; }
.shelves-row .chip .n { color: var(--faint); font-size: 12px; }

.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 26px 20px; }
.tile { display: flex; flex-direction: column; gap: 8px; content-visibility: auto; contain-intrinsic-size: auto 290px; }
.tile-title { font-weight: 600; font-size: 14px; line-height: 1.3; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.tile-author { color: var(--muted); font-size: 13px; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-meta { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 2px 6px; min-height: 18px; }
.tile-badge { position: absolute; top: 6px; right: 6px; z-index: 3; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 6px; background: rgba(20,16,12,.8); color: #f1e9dd; backdrop-filter: blur(4px); }

.book-list { display: flex; flex-direction: column; }
.row { display: grid; grid-template-columns: 44px minmax(0, 2.2fr) minmax(0, 1.4fr) 120px 150px 90px; align-items: center; gap: 16px; padding: 8px 10px; border-radius: 10px; content-visibility: auto; contain-intrinsic-size: auto 66px; }
.row:hover { background: var(--surface); }
.row .cover { width: 44px; border-radius: 2px 4px 4px 2px; }
.row .r-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .r-sub { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .bar { height: 6px; }

.stars { display: inline-flex; gap: 1px; color: var(--accent); vertical-align: middle; }
.stars svg { width: 14px; height: 14px; }
.stars .off { color: var(--surface-3); }

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

.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); margin-bottom: 18px; font-size: 14px; cursor: pointer; background: none; border: 0; padding: 0; }
.back-link:hover { color: var(--accent); }
.back-link svg { width: 18px; height: 18px; }
.book-top { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 40px; align-items: start; }
.book-cover-col { position: sticky; top: 24px; display: flex; flex-direction: column; gap: 12px; }
.book-cover-col .cover { font-size: 20px; }
.book-title { font-size: 34px; line-height: 1.15; margin: 0; }
.book-title[contenteditable="true"] { outline: 2px solid var(--accent-soft); border-radius: 6px; }
.book-orig { color: var(--faint); font-size: 14px; margin-top: 4px; }
.book-author { font-size: 18px; color: var(--muted); margin-top: 8px; }
.book-facts { display: flex; flex-wrap: wrap; gap: 6px 18px; color: var(--muted); font-size: 14px; margin-top: 12px; }
.book-facts b { color: var(--text); font-weight: 600; }
.block { margin-top: 26px; }
.block-label { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); margin-bottom: 10px; }
.progress-card { padding: 18px 20px; }
.progress-card .progress-line { padding-top: 0; }
.progress-card .pct { font-size: 20px; font-family: Literata, Georgia, serif; min-width: 56px; }
.range { width: 100%; accent-color: var(--accent); margin: 14px 0 6px; }
.progress-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; }
.dates { display: flex; flex-wrap: wrap; gap: 14px; }
.dates .input { width: 170px; }

.rate { display: inline-flex; align-items: center; gap: 2px; }
.rate .star { position: relative; width: 30px; height: 30px; color: var(--surface-3); }
.rate .star svg { width: 30px; height: 30px; display: block; }
.rate .star .half { position: absolute; top: 0; left: 0; width: 50%; height: 100%; overflow: hidden; color: var(--accent); }
.rate .star.full { color: var(--accent); }
.rate .star button { position: absolute; top: 0; bottom: 0; width: 50%; border: 0; background: transparent; cursor: pointer; padding: 0; }
.rate .star button.l { left: 0; }
.rate .star button.r { right: 0; }
.rate-val { margin-left: 10px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 28px; }

.description { color: var(--muted); line-height: 1.65; white-space: pre-line; max-height: 10.5em; overflow: hidden; position: relative; }
.description.open { max-height: none; }
.more-btn { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 4px 0; font-size: 14px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line-soft); margin-bottom: 16px; }
.tabs button { background: none; border: 0; padding: 10px 14px; cursor: pointer; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); }
.tabs button .count { color: var(--faint); font-size: 12px; margin-left: 4px; }

.j-form { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.j-form-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.j-item { position: relative; padding: 14px 44px 14px 16px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line-soft); margin-bottom: 10px; }
.j-item.quote { border-left: 3px solid var(--accent); }
.j-item.quote .j-text { font-family: Literata, Georgia, serif; font-style: italic; font-size: 16px; }
.j-text { white-space: pre-wrap; line-height: 1.6; }
.j-meta { color: var(--faint); font-size: 13px; margin-top: 6px; }
.j-item .icon-btn { position: absolute; top: 8px; right: 8px; width: 28px; height: 28px; }
.j-item .icon-btn svg { width: 16px; height: 16px; }

.s-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.s-table td, .s-table th { padding: 9px 8px; border-bottom: 1px solid var(--line-soft); text-align: left; }
.s-table th { color: var(--faint); font-weight: 500; font-size: 13px; }
.s-table td.num { font-variant-numeric: tabular-nums; }

.danger-zone { margin-top: 40px; padding-top: 20px; border-top: 1px solid var(--line-soft); display: flex; gap: 10px; flex-wrap: wrap; }

/* ------------------------------------------------------------ статистика */

.big-nums { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.big-num b { display: block; font-family: Literata, Georgia, serif; font-size: 38px; line-height: 1.05; }
.big-num span { color: var(--muted); font-size: 14px; }
.big-num small { display: block; color: var(--faint); font-size: 13px; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chart { display: grid; grid-template-columns: repeat(12, 1fr); gap: 10px; align-items: end; height: 200px; padding-top: 20px; }
.chart .col { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 6px; }
.chart .colbar { width: 100%; max-width: 44px; background: var(--accent); border-radius: 6px 6px 2px 2px; min-height: 2px; position: relative; transition: height .5s ease; }
.chart .colbar.zero { background: var(--surface-3); }
.chart .colval { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; min-height: 16px; }
.chart .collab { font-size: 12px; color: var(--faint); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.hbars { display: flex; flex-direction: column; gap: 10px; }
.hbar { display: grid; grid-template-columns: minmax(0, 1fr) 2fr 28px; gap: 12px; align-items: center; font-size: 14px; }
.hbar .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .track { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.hbar .track i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.hbar .n { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.year-list { display: flex; flex-direction: column; }
.year-list a { display: grid; grid-template-columns: 90px minmax(0, 1fr) auto; gap: 12px; padding: 8px 4px; border-bottom: 1px solid var(--line-soft); font-size: 14px; }
.year-list a:hover { color: var(--accent); }
.year-list .d { color: var(--faint); font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------ достижения */

.ach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.ach { display: grid; grid-template-columns: 52px 1fr; gap: 14px; align-items: center; padding: 16px; }
.ach-icon { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; background: var(--surface-3); color: var(--faint); }
.ach-icon svg { width: 28px; height: 28px; }
.ach.done .ach-icon { background: var(--accent-soft); color: var(--accent); box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 40%, transparent) inset; }
.ach-name { font-weight: 600; }
.ach-desc { color: var(--muted); font-size: 13px; line-height: 1.35; }
.ach .bar { height: 5px; margin-top: 8px; }
.ach-prog { font-size: 12px; color: var(--faint); margin-top: 4px; font-variant-numeric: tabular-nums; }
.ach:not(.done) { opacity: .85; }

/* ------------------------------------------------------------ настройки */

.settings { display: flex; flex-direction: column; gap: 16px; max-width: 720px; }
.settings .card h2 { margin-bottom: 6px; }
.settings .card .hint { margin-bottom: 14px; }
.row-inline { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.file-drop { display: block; border: 1.5px dashed var(--line); border-radius: 12px; padding: 22px; text-align: center; color: var(--muted); cursor: pointer; transition: border-color .15s, background .15s; }
.file-drop:hover, .file-drop.drag { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.steps { margin: 0 0 14px; padding-left: 20px; color: var(--muted); }
.steps a, .imp-pane a { color: var(--accent); }
/* Прокрутка вбок нужна только на узком экране. Вкладки заходят на общую
   линию на 1px (margin-bottom: -1px у .tabs button), из-за этого браузер
   рисовал ещё и вертикальный скролл. Здесь линия под вкладками своя. */
#imp-tabs { margin: 4px 0 14px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
#imp-tabs::-webkit-scrollbar { display: none; }
#imp-tabs button { white-space: nowrap; margin-bottom: 0; }
.imp-pane { margin-bottom: 14px; }
.imp-pane .steps { margin-bottom: 8px; }
.imp-note { font-size: 13px; margin: 0 0 4px; }
.imp-cols { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.imp-cols span { font-size: 12px; padding: 3px 9px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--line-soft); color: var(--text); }
.imp-pane #imp-sample { margin-top: 10px; }
#bookmark-step { margin-top: 16px; }
.bm-list { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.bm-row { display: grid; grid-template-columns: minmax(0, 1fr) 90px 60px auto; gap: 10px; align-items: center; }
.bm-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-src { color: var(--accent); font-size: 12px; }
.steps li { margin: 3px 0; }

/* ------------------------------------------------------------ модалки */

.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: start center; padding: calc(env(safe-area-inset-top) + 8vh) 16px calc(env(safe-area-inset-bottom) + 16px); }
.modal-backdrop { position: absolute; inset: 0; background: rgba(8, 6, 4, .62); backdrop-filter: blur(3px); }
.modal-card { position: relative; width: 100%; max-width: 680px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); display: flex; flex-direction: column; max-height: 84vh; overflow: hidden; }
.search-head { display: flex; align-items: center; gap: 10px; padding: 12px 12px 12px 18px; border-bottom: 1px solid var(--line-soft); }
.search-head > svg { width: 22px; height: 22px; color: var(--faint); flex: none; }
.search-head input::-webkit-search-cancel-button { display: none; }
.search-head input { flex: 1; border: 0; background: transparent; outline: none; font-size: 18px; padding: 6px 0; min-width: 0; }
.search-body { overflow-y: auto; padding: 10px; min-height: 120px; }
.search-body .hint { padding: 18px 10px; }
.search-foot { border-top: 1px solid var(--line-soft); padding: 8px 10px; display: flex; justify-content: center; flex-wrap: wrap; gap: 4px; }
.search-foot .btn svg { width: 17px; height: 17px; fill: currentColor; }
.modal.drop .search-card { outline: 2px dashed var(--accent); outline-offset: 4px; }

/* Очередь загрузки файлов книг */
.up-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 4px 4px 10px; }
.up-list { display: flex; flex-direction: column; gap: 4px; }
.up-row { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border-radius: 10px; background: var(--bg-2); }
.up-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--surface-3); margin-top: 5px; flex: none; }
.up-row.busy .up-dot { background: var(--accent); animation: up-pulse 1s ease-in-out infinite; }
.up-row.ok .up-dot { background: var(--ok); }
.up-row.dup .up-dot { background: var(--faint); }
.up-row.err .up-dot { background: var(--danger); }
.up-row.err .up-state { color: var(--danger); }
@keyframes up-pulse { 50% { transform: scale(.6); } }
.up-body { min-width: 0; }
.up-name { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-row .up-state { font-size: 12px; margin: 2px 0 0; }
.up-state a { color: var(--accent); }

/* Файл книги в карточке */
.file-box { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px 6px; }
.file-box .hint { font-size: 12px; }
.file-box .btn svg, #read-btn svg { width: 17px; height: 17px; fill: currentColor; }

/* Книга с файлом: уголок-закладка на обложке. Без opacity и filter: внутри
   .cover.tilt3d они сплющивают 3D (правило из CLAUDE.md). */
.cover[data-read] { cursor: pointer; }

/* Читалка поверх сайта */
html.reading, html.reading body { overflow: hidden; }
.reader-ov { position: fixed; inset: 0; z-index: 200; perspective: 1600px; }
.rov-page { position: absolute; inset: 0; background: #fbf8f2; opacity: 0; }
.rov-frame { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; opacity: 0; transition: opacity .35s ease; background: transparent; }
.rov-frame.shown { opacity: 1; }
.rov-book { position: fixed; z-index: 2; transform-origin: 50% 50%; transform-style: preserve-3d; will-change: transform; }
.rov-leaf { position: absolute; inset: 0 0 0 2px; background: linear-gradient(90deg, #e9e1d0, #fbf8f2 12%, #fbf8f2); border-radius: 1px 3px 3px 1px; box-shadow: 0 10px 40px rgba(0,0,0,.35); }
.rov-cover { position: absolute; inset: 0; transform-origin: 0 50%; transform-style: preserve-3d; }
.rov-cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: 1px 3px 3px 1px; backface-visibility: hidden; box-shadow: 0 10px 40px rgba(0,0,0,.35); }
.rov-cover-back { position: absolute; inset: 0; background: #efe7d6; transform: rotateY(180deg); backface-visibility: hidden; border-radius: 3px 1px 1px 3px; }
.result { display: grid; grid-template-columns: 54px minmax(0, 1fr); gap: 14px; padding: 10px; border-radius: 12px; }
.result:hover { background: var(--surface-2); }
.result .cover { width: 54px; font-size: 9px; }
.result-title { font-weight: 600; line-height: 1.3; }
.result-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.result-actions { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; align-items: center; }
.skeleton { height: 88px; border-radius: 12px; margin: 6px 0; background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.manual-form { padding: 16px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.manual-form .full { grid-column: 1 / -1; }

.picker-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 10px 20px; border-bottom: 1px solid var(--line-soft); }
.picker-search { display: flex; gap: 8px; padding: 12px 20px 0; }
.picker-search .input { flex: 1; min-width: 0; }
.picker-body { overflow-y: auto; padding: 16px 20px; min-height: 200px; }
.picker-body > .hint { margin-bottom: 12px; }
.picker-group + .picker-group { margin-top: 18px; }
.picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 12px; }
.picker-item { padding: 0; border: 2px solid transparent; border-radius: 6px; background: var(--surface-2); cursor: pointer; aspect-ratio: 2 / 3; overflow: hidden; transition: border-color .15s, transform .15s; }
.picker-item:hover { border-color: var(--accent); transform: translateY(-2px); }
.picker-item img { width: 100%; height: 100%; object-fit: contain; display: block; }
.picker-item.busy { border-color: var(--accent); opacity: .6; }
.picker-skel { aspect-ratio: 2 / 3; border-radius: 6px; background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; }
.picker-foot { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 12px 20px; border-top: 1px solid var(--line-soft); }
.picker-link { display: flex; gap: 8px; flex: 1; min-width: 220px; }
.picker-link .input { flex: 1; min-width: 0; padding: 6px 10px; }
.picker-empty p { margin: 0 0 10px; line-height: 1.55; }
.toasts { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 80; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: var(--surface-3); color: var(--text); border: 1px solid var(--line); padding: 10px 18px; border-radius: 12px; box-shadow: var(--shadow); font-size: 14px; animation: toast-in .25s ease; pointer-events: auto; }
.toast.err { border-color: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.celebrate { text-align: center; padding: 28px 24px; }
.celebrate h2 { font-size: 24px; margin: 10px 0 6px; }
.celebrate .cover { width: 120px; margin: 0 auto; }

.pw-form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: 10px; align-items: center; }
@media (max-width: 760px) { .pw-form { grid-template-columns: 1fr; } .pw-form .btn { justify-content: center; } }

/* ------------------------------------------------------------ аватарки */

.ava { width: var(--sz); height: var(--sz); border-radius: 50%; object-fit: cover; display: block; flex: none; background: var(--surface-3); }
.ava-letter {
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: calc(var(--sz) * .42); line-height: 1;
  background: linear-gradient(145deg, hsl(var(--h) 45% 42%), hsl(var(--h) 50% 28%));
}
.side-ava { position: relative; flex: none; }
.side-ava .xp-badge { position: absolute; right: -5px; bottom: -4px; }
.check { display: flex; align-items: flex-start; gap: 10px; margin-top: 16px; cursor: pointer; font-size: 14px; }
.check input { margin-top: 3px; accent-color: var(--accent); width: 16px; height: 16px; flex: none; }
.set-profile { display: flex; align-items: center; gap: 18px; margin-top: 10px; flex-wrap: wrap; }
.set-ava { position: relative; padding: 0; border: 0; background: none; cursor: pointer; border-radius: 50%; }
.set-ava > span { position: absolute; right: -2px; bottom: -2px; width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; }
.set-ava > span svg { width: 15px; height: 15px; fill: currentColor; }
.set-profile-btns { display: flex; flex-wrap: wrap; gap: 8px; }

/* ------------------------------------------------------------ лента */

.feed-layout { max-width: 760px; }
.composer { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 18px; }
.cmp-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.cmp-text { width: 100%; resize: none; min-height: 42px; max-height: 320px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line-soft); background: var(--bg-2); color: var(--text); font: inherit; line-height: 1.5; }
.cmp-text:focus { outline: none; border-color: var(--accent); }
.cmp-foot { display: flex; align-items: center; gap: 10px; }
.cmp-send { margin-left: auto; }
.cmp-book-wrap { position: relative; min-width: 0; }
.cmp-book-btn { max-width: 320px; }
.cmp-book-btn svg { width: 16px; height: 16px; fill: currentColor; flex: none; }
.cmp-book-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmp-book-btn.chosen { color: var(--accent); background: var(--accent-soft); }
.cmp-pick { position: absolute; left: 0; top: calc(100% + 6px); z-index: 30; width: 320px; max-width: 80vw; padding: 8px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
.cmp-pick .input { width: 100%; margin-bottom: 6px; }
.cmp-pick-list { max-height: 280px; overflow-y: auto; display: flex; flex-direction: column; }
.cmp-pick-list button { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; text-align: left; padding: 7px 9px; border: 0; background: none; color: var(--text); border-radius: 8px; cursor: pointer; font: inherit; }
.cmp-pick-list button:hover { background: var(--surface-3); }
.cmp-pick-list b { font-weight: 600; font-size: 14px; }
.cmp-pick-list span { font-size: 12px; color: var(--muted); }
.feed-tabs { margin-bottom: 14px; }
.feed-list { display: flex; flex-direction: column; gap: 12px; }
.feed-hint { margin-bottom: 12px; border-style: dashed; }
.feed-hint p { margin: 6px 0 12px; color: var(--muted); font-size: 14px; }
.more-btn { display: flex; margin: 16px auto 0; }

.post { padding: 16px 18px; }
.post-head { display: flex; align-items: center; gap: 12px; }
.post-who { min-width: 0; flex: 1; }
.post-name { font-weight: 600; }
.post-name:hover { color: var(--accent); }
.post-kind { display: inline-block; margin-left: 8px; padding: 1px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface-2); vertical-align: 1px; }
.post-kind.k-finished { color: var(--accent); background: var(--accent-soft); }
.post-kind.k-started { color: var(--st-reading); }
.dlg { padding: 20px; display: flex; flex-direction: column; gap: 12px; overflow-y: auto; }
.dlg h2 { margin: 0; }
.dlg .hint { margin: 0; }
.dialog-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.crop-stage { margin: 4px 0 0; }
.post-rank { font-size: 12px; margin-top: 1px; }
.post-del { opacity: .55; }
.post-del:hover { opacity: 1; color: var(--danger); }
.post-text { margin-top: 12px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 8; -webkit-box-orient: vertical; overflow: hidden; }
.post-text.review { font-family: Literata, Georgia, serif; font-size: 15px; -webkit-line-clamp: 5; }
.post-text.clampable { cursor: pointer; }
.post-text.clampable:hover { color: var(--text); }
.post-text.expanded { -webkit-line-clamp: unset; overflow: visible; }
.post-book { display: flex; gap: 14px; margin-top: 12px; padding: 12px; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--line-soft); }
.post-book.finished { border-color: color-mix(in srgb, var(--accent) 35%, var(--line-soft)); background: linear-gradient(100deg, var(--accent-soft), transparent 70%), var(--bg-2); }
.pb-cover { width: 58px; flex: none; }
.pb-body { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.pb-title { font-family: Literata, Georgia, serif; font-weight: 600; font-size: 16px; line-height: 1.3; }
.pb-title a:hover { color: var(--accent); }
.pb-author { color: var(--muted); font-size: 13px; }
.pb-rate { margin-top: 4px; }
.pb-foot { margin-top: auto; padding-top: 8px; }
.pb-have { font-size: 12px; color: var(--faint); }
a.pb-have:hover { color: var(--accent); }
.post-foot { display: flex; align-items: center; gap: 6px; margin-top: 12px; }
.post-act { display: inline-flex; align-items: center; gap: 5px; padding: 5px 8px; border: 0; background: none; border-radius: 8px; color: var(--muted); cursor: pointer; font: inherit; font-size: 13px; }
.post-act svg { width: 17px; height: 17px; fill: currentColor; }
.post-act:hover { background: var(--surface-2); color: var(--text); }
.post-act.like.on { color: #e0776b; }
.post-time { margin-left: auto; font-size: 12px; color: var(--faint); }
.post-comments { margin-top: 10px; padding-top: 12px; border-top: 1px solid var(--line-soft); display: flex; flex-direction: column; gap: 12px; }
.post-comments[hidden] { display: none; }
.cm { display: flex; gap: 10px; }
.cm-body { min-width: 0; font-size: 14px; }
.cm-name { font-weight: 600; }
.cm-time { font-size: 12px; color: var(--faint); margin-left: 6px; }
.cm-del { border: 0; background: none; color: var(--faint); font-size: 12px; cursor: pointer; margin-left: 6px; padding: 0; }
.cm-del:hover { color: var(--danger); }
.cm-text { margin-top: 2px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.cm-form { display: flex; gap: 10px; align-items: center; }
.cm-form .input { flex: 1; min-width: 0; }

.readers { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.reader { display: flex; gap: 14px; align-items: flex-start; }
.reader-body { flex: 1; min-width: 0; }
.reader-name { font-weight: 600; font-size: 16px; }
.reader-name:hover { color: var(--accent); }
.reader-stats { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 8px; font-size: 13px; color: var(--muted); }
.reader-stats b { color: var(--text); }
.reader-now { display: flex; align-items: flex-end; gap: 6px; margin-top: 10px; }
.reader-now .hint { font-size: 12px; margin-right: 2px; align-self: center; }
.rn-cover { width: 30px; }
.follow-btn { flex: none; }

/* ------------------------------------------------------------ профиль */

.pf-hero {
  position: relative; display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap;
  min-height: 220px; padding: 24px; overflow: hidden;
  background: radial-gradient(700px 240px at 15% 0%, var(--accent-soft), transparent 70%), var(--surface);
}
.pf-hero.has-bg { background: linear-gradient(180deg, rgba(0,0,0,.05) 0%, rgba(0,0,0,.55) 100%), var(--pf-bg) center / cover no-repeat, var(--surface); }
.pf-bg-btn { position: absolute; right: 14px; top: 14px; display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 99px; border: 0; cursor: pointer; font: inherit; font-size: 13px; color: #fff; background: rgba(0,0,0,.45); }
.pf-bg-btn svg { width: 15px; height: 15px; fill: currentColor; }
.pf-bg-btn:hover { background: rgba(0,0,0,.65); }
.pf-id { display: flex; align-items: flex-end; gap: 20px; min-width: 0; }
.pf-ava { position: relative; border-radius: 50%; box-shadow: 0 0 0 4px var(--surface), var(--shadow); flex: none; }
.pf-ava.mine { cursor: pointer; }
.pf-ava-edit { position: absolute; right: 2px; bottom: 2px; width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; box-shadow: 0 0 0 3px var(--surface); }
.pf-ava-edit svg { width: 17px; height: 17px; fill: currentColor; }
.pf-name-block { min-width: 0; padding-bottom: 4px; }
.pf-name { font-size: 32px; margin: 0; overflow-wrap: anywhere; }
.pf-hero.has-bg .pf-name, .pf-hero.has-bg .pf-sub { color: #fff; text-shadow: 0 1px 6px rgba(0,0,0,.6); }
.pf-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.pf-actions { margin-top: 12px; display: flex; gap: 8px; }
.pf-xp { display: flex; align-items: center; gap: 14px; min-width: 260px; padding: 12px 16px; border-radius: 14px; background: color-mix(in srgb, var(--surface) 85%, transparent); border: 1px solid var(--line-soft); }
.pf-xp-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.pf-rank { font-family: Literata, Georgia, serif; font-weight: 600; font-size: 17px; }
.pf-xp-num { font-size: 12px; color: var(--muted); }
.pf-grid { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 16px; margin-top: 16px; align-items: stretch; }
.pf-panel { padding: 18px 20px; }
.pf-title { font-size: 12px; font-family: Inter, sans-serif; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); margin: 0 0 14px; }
.pf-title-row { display: flex; align-items: baseline; justify-content: space-between; }
.pf-info { display: grid; grid-template-columns: 1fr auto; gap: 11px 12px; margin: 0; font-size: 14px; }
.pf-info dt { color: var(--muted); }
.pf-info dd { margin: 0; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.pf-link { border: 0; background: none; padding: 0; font: inherit; font-weight: 600; color: var(--text); cursor: pointer; }
.pf-link:hover { color: var(--accent); }
.pf-ach { display: grid; grid-template-columns: repeat(auto-fill, 44px); gap: 8px; }
.pf-ach-i { position: relative; width: 44px; height: 44px; border-radius: 10px; display: grid; place-items: center; background: var(--bg-2); border: 1px solid var(--line-soft); color: var(--faint); outline: none; }
.pf-ach-i svg { width: 20px; height: 20px; fill: currentColor; }
.pf-ach-i.done { color: var(--accent); background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.pf-ach-tip { position: absolute; left: 50%; bottom: calc(100% + 8px); transform: translateX(-50%); z-index: 20; width: 210px; padding: 8px 10px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); box-shadow: var(--shadow); font-size: 12px; line-height: 1.4; color: var(--muted); display: none; pointer-events: none; }
.pf-ach-tip b { display: block; color: var(--text); font-size: 13px; margin-bottom: 2px; }
.pf-ach-tip i { display: block; font-style: normal; color: var(--accent); margin-top: 4px; }
.pf-ach-i:hover .pf-ach-tip, .pf-ach-i:focus .pf-ach-tip { display: block; }
/* Карусели профиля в карточке: заголовок в стиле панелей профиля. */
.pf-car { margin-top: 16px; }
.pf-car .car-head h2 { font-size: 12px; font-family: Inter, sans-serif; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.pf-shelf { display: flex; flex-direction: column; gap: 6px; }
.pf-shelf-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; background: var(--bg-2); border: 1px solid var(--line-soft); font-size: 14px; }
.pf-shelf-n { color: var(--muted); }
.pf-open { margin-left: auto; font-size: 12px; color: var(--accent); }
a.pf-shelf-row:hover { border-color: var(--line); }
.pf-activity .feed-list { max-width: 760px; }
.follows-list { display: flex; flex-direction: column; gap: 4px; max-height: 60vh; overflow-y: auto; margin: 12px 0; }
.follows-list a { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; }
.follows-list a:hover { background: var(--surface-2); }
.follows-list .hint { margin-left: auto; font-size: 12px; }

/* Кадрирование аватарки и фона */
.crop-stage { position: relative; width: 100%; overflow: hidden; border-radius: 12px; background: #000; margin: 12px 0; cursor: grab; touch-action: none; user-select: none; }
.crop-stage:active { cursor: grabbing; }
.crop-stage img { position: absolute; left: 0; top: 0; transform-origin: 0 0; max-width: none; pointer-events: none; }
/* Круглая маска поверх квадрата: видно, что попадет в кружок. */
.crop-stage.round::after { content: ""; position: absolute; inset: 0; border-radius: 50%; box-shadow: 0 0 0 999px rgba(0,0,0,.55); pointer-events: none; }
.crop-zoom { width: 100%; accent-color: var(--accent); }

/* ------------------------------------------------------------ админка */

.adm-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.adm-note { margin: 0 0 12px; font-size: 13px; }
.adm-chart { grid-template-columns: repeat(var(--n, 30), minmax(0, 1fr)); gap: 3px; }
.adm-chart .colval { font-size: 11px; display: flex; flex-direction: column; align-items: center; line-height: 1.2; }
.adm-new { font-style: normal; color: #ffd36b; font-weight: 700; }
.hbar .n small { color: var(--faint); font-weight: 400; }

.adm-people { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 16px; align-items: start; }
.adm-list { padding: 6px; display: flex; flex-direction: column; gap: 2px; max-height: 70vh; overflow-y: auto; }
.adm-user { display: flex; flex-direction: column; gap: 2px; text-align: left; background: none; border: 0; border-radius: 10px; padding: 10px 12px; cursor: pointer; color: var(--text); font: inherit; }
.adm-user:hover { background: var(--surface-2); }
.adm-user.on { background: var(--accent-soft); }
.adm-name { font-weight: 600; display: flex; align-items: center; gap: 6px; }
.adm-sub { font-size: 12px; color: var(--muted); }
.adm-online { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 25%, transparent); flex: none; }
.adm-feed { min-height: 200px; }
.adm-day { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--faint); margin: 16px 0 6px; }
.adm-day:first-of-type { margin-top: 0; }
.adm-ev { display: grid; grid-template-columns: 48px minmax(0, 1fr); gap: 10px; padding: 5px 0; border-bottom: 1px solid var(--line-soft); font-size: 14px; }
.adm-ev:last-of-type { border-bottom: 0; }
.adm-time { color: var(--faint); font-variant-numeric: tabular-nums; }
.adm-more { margin-top: 12px; }

.xp-user { width: auto; min-width: 200px; }
.xp-adm-top { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.xp-adm-top .xp-rank { font-family: Literata, Georgia, serif; font-size: 20px; font-weight: 600; }
.xp-adm-src .hbar { grid-template-columns: minmax(0, 1fr) auto; }
.xp-adm-note { margin: 12px 0 0; font-size: 13px; }
.xp-adm-actions { display: flex; flex-direction: column; gap: 10px; }
.xp-adm-actions h2 { margin: 0; }
.xp-adm-actions .hint { margin: 0; font-size: 13px; }
.xp-adm-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.xp-adm-row .input-num { width: 100px; }
.xp-days { display: flex; flex-direction: column; }
.xp-day { display: grid; grid-template-columns: 150px 80px minmax(0, 1fr) 90px auto; gap: 12px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line-soft); font-size: 14px; }
.xp-day:last-child { border-bottom: 0; }
.xp-day.old { color: var(--faint); }
.xp-day-b { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.xp-day-c { font-size: 12px; color: var(--muted); }
.xp-day.old .xp-day-c { color: var(--faint); }
@media (max-width: 760px) { .xp-day { grid-template-columns: 1fr auto; } .xp-day-b, .xp-day-c { display: none; } }
.inv-form { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto auto; gap: 10px; align-items: center; margin: 10px 0; }
.inv-code { display: flex; align-items: center; gap: 4px; color: var(--muted); }
.inv-code .input { flex: 1; min-width: 0; }
.inv-max { display: flex; align-items: center; gap: 6px; }
.inv-list { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
.inv-row { display: flex; flex-direction: column; gap: 10px; }
.inv-row.off { opacity: .6; }
.inv-top { display: flex; align-items: center; gap: 8px; }
.inv-count { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; }
.inv-track { display: block; height: 4px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.inv-track b { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.inv-link { display: flex; align-items: center; gap: 10px; min-width: 0; }
.inv-link code { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: var(--surface-2); border: 1px solid var(--line-soft); border-radius: 8px; padding: 6px 10px; font-size: 13px; }
.inv-stats { display: flex; gap: 16px; color: var(--muted); font-size: 13px; }
.inv-stats b { color: var(--text); }
.inv-guests { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; }
.inv-actions { display: flex; flex-wrap: wrap; gap: 6px; }

/* ------------------------------------------------------------ телефон */

@media (max-width: 1000px) {
  .home-grid { grid-template-columns: minmax(0, 1fr); grid-template-areas: "head" "main" "side"; }
  .home-grid > .stat-stack { margin-top: 24px; }
  .stat-stack { display: grid; grid-template-columns: 1fr 1fr; }
  .big-nums { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .row { grid-template-columns: 44px minmax(0, 1fr) 110px 80px; }
  .row .r-col-author, .row .r-col-date { display: none; }
}

@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .side {
    position: fixed; top: auto; bottom: 0; left: 0; right: 0; height: auto; z-index: 40;
    flex-direction: row; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); gap: 4px;
    border-right: 0; border-top: 1px solid var(--line-soft);
  }
  .brand, .side-foot { display: none; }
  .nav { flex-direction: row; flex: 1; justify-content: space-around; }
  .nav a { flex-direction: column; gap: 2px; padding: 6px 4px; font-size: 11px; flex: 1; }
  .add-btn { position: fixed; right: 16px; bottom: calc(76px + env(safe-area-inset-bottom)); width: 54px; height: 54px; border-radius: 50%; padding: 0; box-shadow: var(--shadow); margin: 0; }
  .add-btn span { display: none; }
  .add-btn svg { width: 26px; height: 26px; }
  /* С домашнего экрана сайт заходит под статус-бар: отступ под него. */
  .main { padding: calc(env(safe-area-inset-top) + 20px) calc(env(safe-area-inset-right) + 16px) 140px calc(env(safe-area-inset-left) + 16px); }
  h1 { font-size: 26px; }
  .stat-stack { grid-template-columns: 1fr; }
  .reading-card { grid-template-columns: 72px 1fr; gap: 14px; }
  .reading-card .cover-slot { width: 72px; }
  .book-top { grid-template-columns: 1fr; gap: 20px; }
  /* Обложка слева, кнопки столбиком справа от нее: в ряд они вылезали
     за экран и растягивали страницу вбок. */
  .book-cover-col { position: static; display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 8px 16px; align-content: end; align-items: end; }
  .book-cover-col .cover { width: 130px; grid-row: 1 / span 4; align-self: end; }
  .book-cover-col .file-box { justify-content: flex-start; }
  .book-title { font-size: 26px; }
  .book-grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 20px 14px; }
  .two-col { grid-template-columns: 1fr; }
  .big-num b { font-size: 30px; }
  .xp-layout { grid-template-columns: 1fr; }
  .xp-sources { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .chart { gap: 4px; height: 160px; }
  .modal { padding: 0; place-items: stretch; }
  .modal-card { max-height: 100vh; height: 100%; border-radius: 0; max-width: none; }
  .manual-form { grid-template-columns: 1fr; }
  .row { grid-template-columns: 40px minmax(0, 1fr) 70px; }
  .row .r-col-rating { display: none; }
  .adm-people { grid-template-columns: 1fr; }
  .pf-grid { grid-template-columns: 1fr; }
  .pf-hero { min-height: 0; padding: 18px; }
  .pf-id { flex-direction: column; align-items: flex-start; gap: 12px; }
  .pf-name { font-size: 26px; }
  .pf-xp { min-width: 0; width: 100%; }
  .readers { grid-template-columns: 1fr; }
  .composer > .ava { display: none; }
  /* На телефоне «Достижения» живут в профиле и в карточке XP на главной:
     седьмой пункт меню не влезает. */
  .nav a[data-nav="achievements"] { display: none; }
  .adm-list { max-height: 260px; }
  .inv-form { grid-template-columns: 1fr; }
  .inv-form .btn { justify-content: center; }
  /* Шесть пунктов у владельца: подписи мельче и режутся многоточием, а не
     вылезают за край экрана. */
  .nav a { padding: 6px 1px; font-size: 10px; min-width: 0; }
  .nav a span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

.ko-rows { display: flex; flex-direction: column; gap: 6px; margin: 4px 0 10px; }
.ko-row { display: grid; grid-template-columns: 80px minmax(0, 1fr); gap: 10px; align-items: baseline; font-size: 14px; }
.ko-row code { font-size: 13px; overflow-wrap: anywhere; user-select: all; }
.ko-key { font-size: 16px !important; letter-spacing: .08em; color: var(--accent); }
.ko-books { margin-top: 14px; display: flex; flex-direction: column; gap: 4px; }
.ko-book { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; }
.ko-book a, .ko-book span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Без сети: плашка сверху, сайт показывает последнюю копию (static/sw.js). */
.offline-bar { position: fixed; z-index: 90; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 20px); transform: translateX(-50%); white-space: nowrap;
  max-width: calc(100vw - 32px); padding: 7px 14px; border-radius: 999px; background: var(--surface-2, #2a2622); color: var(--text, #eee);
  border: 1px solid var(--line, #3a3530); font-size: 13px; line-height: 1.3; text-align: center; box-shadow: 0 6px 20px rgba(0,0,0,.3); pointer-events: none; }
.offline-bar[hidden] { display: none; }
@media (max-width: 760px) { .offline-bar { bottom: calc(env(safe-area-inset-bottom, 0px) + 76px); } }
