/* Матове скло поверх чорно-білого фото сторінок: графіт і папір */
:root {
  color-scheme: light;
  --ink: #1c1d1f;
  --muted: #55585d;
  --line: rgba(28, 29, 31, .12);
  --accent: #2a2b2e;
  --accent-hover: #000000;
  --accent-ink: #ffffff;
  --accent-soft: rgba(28, 29, 31, .08);
  --danger: #a3271f;
  --ok: #2a2b2e;
  --glass: rgba(246, 246, 244, .66);
  --glass-strong: rgba(248, 248, 246, .9);
  --menu: #f3f3f1;
  --glass-field: rgba(255, 255, 255, .62);
  --glass-edge: rgba(255, 255, 255, .8);
  --glass-blur: blur(20px) saturate(1.2);
  --photo-filter: brightness(.92) contrast(.95);
  --shadow: 0 1px 0 var(--glass-edge) inset, 0 10px 30px rgba(0, 0, 0, .28);
  --shadow-lg: 0 1px 0 var(--glass-edge) inset, 0 18px 50px rgba(0, 0, 0, .4);
  --bar-bg: rgba(20, 21, 23, .72);
  --bar-ink: #f4f4f2;
  --backdrop: rgba(10, 10, 12, .3);
  --radius: 18px;
  --stage: rgba(28, 29, 31, .06);
  --spine: rgba(0, 0, 0, .07);
  --spine-deep: rgba(0, 0, 0, .18);
  --row-hover: rgba(255, 255, 255, .5);
  /* єдиний яскравий колір — лише для акцій, щоб їх було видно здалеку */
  --sale: #b3202a;
  /* Акцент — золоте тиснення, як на палітурках (і золото ікон). Лише там, де людина купує:
     «+» на книзі, кількість, «Оформити», кнопки замовлення, книга в кошику. Решта сайту — графіт і папір */
  --gilt: #b38e45;
  --gilt-foil: linear-gradient(155deg, #dcbd7a, #b08a40 52%, #c9a55e);
  --gilt-ink: #2a2110;
  --gilt-text: #7a5a1a;
  --gilt-shine: inset 0 1px 0 rgba(255, 255, 255, .5), inset 0 -1px 0 rgba(90, 64, 16, .35);
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --ink: #f2f2f0;
    --muted: #a9abaf;
    --line: rgba(255, 255, 255, .1);
    --accent: #efefec;
    --accent-hover: #ffffff;
    --accent-ink: #151618;
    --accent-soft: rgba(255, 255, 255, .1);
    --danger: #f2938a;
    --ok: #efefec;
    --glass: rgba(20, 21, 23, .62);
    --glass-strong: rgba(24, 25, 27, .9);
    --menu: #1e1f22;
    --glass-field: rgba(255, 255, 255, .06);
    --glass-edge: rgba(255, 255, 255, .12);
    --photo-filter: brightness(.42) contrast(1.05);
    --shadow: 0 1px 0 var(--glass-edge) inset, 0 10px 30px rgba(0, 0, 0, .5);
    --shadow-lg: 0 1px 0 var(--glass-edge) inset, 0 18px 50px rgba(0, 0, 0, .65);
    --bar-bg: rgba(8, 8, 10, .72);
    --backdrop: rgba(0, 0, 0, .45);
    --stage: rgba(0, 0, 0, .28);
    --spine: rgba(0, 0, 0, .2);
    --spine-deep: rgba(0, 0, 0, .45);
    --row-hover: rgba(255, 255, 255, .06);
    --sale: #f2827f;
    --gilt: #c9a55e;
    --gilt-text: #dcbf80;
    --gilt-shine: inset 0 1px 0 rgba(255, 255, 255, .45), inset 0 -1px 0 rgba(60, 42, 8, .5);
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
body {
  margin: 0;
  background: #2b2b2b;
  color: var(--ink);
  font: 15px/1.5 Onest, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-bottom: 110px;
}
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
button { font: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Фото за склом: нерухоме, сторінка пливе над ним.
   Лише body > .photo: клас .photo носять і обкладинки (.cover.photo) — інакше вони теж темніють */
body > .photo {
  position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(ellipse 110% 90% at 50% 35%, transparent 45%, rgba(0, 0, 0, .45)),
    url(pages.jpg) center / cover no-repeat;
  filter: var(--photo-filter);
}
@media (max-width: 700px) {
  body > .photo { background-image: radial-gradient(ellipse 110% 90% at 50% 35%, transparent 45%, rgba(0, 0, 0, .45)), url(pages-960.jpg); }
}

/* Скло */
.glass, .list:not(.grid), .toolbar, .count, .state {
  background: var(--glass);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  :root { --glass: var(--glass-strong); }
}

/* Шапка: скляна табличка */
header { padding: 56px 16px 32px; }
.plaque {
  max-width: 620px; margin: 0 auto;
  padding: 30px 36px 28px;
  text-align: center;
  border-radius: 24px;
  box-shadow: var(--shadow-lg);
}
.brand {
  display: block; color: inherit; text-decoration: none;
  font: 600 clamp(30px, 5vw, 46px)/1.08 Literata, Georgia, serif;
  font-optical-sizing: auto;
  letter-spacing: -.015em;
  margin: 0;
  text-wrap: balance;
}
/* назва — посилання на головну: виглядає як заголовок, клік заново відкриває сайт */
.brand a { color: inherit; text-decoration: none; border-radius: 6px; }
@media (max-width: 600px) {
  header { padding: 28px 12px 20px; }
  .plaque { padding: 22px 20px; border-radius: 20px; }
}

/* Пошук: скляна капсула завширшки зі список */
.toolbar {
  position: sticky; top: 10px; z-index: 5;
  width: min(1088px, calc(100% - 32px));
  margin: 0 auto;
  padding: 7px;
  border: 1px solid var(--glass-edge);
  border-radius: 999px;
  box-shadow: var(--shadow);
}
.toolbar .wrap { display: flex; gap: 8px; max-width: none; padding: 0; }
.search { position: relative; flex: 1; min-width: 0; }
.search svg { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.toolbar input, .sort-btn {
  font: inherit; color: inherit;
  background: var(--glass-field);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 11px 16px;
  outline: none;
  transition: border-color .15s, background .15s;
}
.toolbar input { width: 100%; padding-left: 44px; }
.toolbar input::placeholder { color: var(--muted); }
.toolbar input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* Сортування */
.sort { position: relative; flex: none; }
.sort-btn {
  height: 100%;
  display: flex; align-items: center; gap: 8px;
  cursor: pointer; white-space: nowrap;
}
.sort-btn:hover, .sort-btn[aria-expanded="true"] { border-color: color-mix(in srgb, var(--accent) 50%, transparent); }
.sort-btn svg { flex: none; color: var(--muted); }
.sort-btn .chev { transition: transform .2s; }
.sort-btn[aria-expanded="true"] .chev { transform: rotate(180deg); }
.sort-menu, .filter-menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 20;
  min-width: 230px;
  list-style: none; margin: 0; padding: 6px;
  /* всередині скляної смуги розмиття не працює, тому меню суцільне */
  background: var(--menu);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  transform-origin: top right;
  animation: pop .14s ease-out;
}
.sort-menu:focus { outline: none; }

/* Фільтри: категорія (одна, деревом), стан і обкладинка (у кожній групі можна відмітити кілька) */
.filter { position: relative; flex: none; }
.filter-btn .badge {
  min-width: 19px; height: 19px; padding: 0 5px;
  display: grid; place-items: center;
  border-radius: 999px; background: var(--accent); color: var(--accent-ink);
  font-size: 11.5px; font-weight: 600;
}
/* Ліворуч категорії (один рівень дерева), праворуч короткі групи кнопками; кожна частина гортається сама.
   --fm-max — висота до низу вікна, її рахує openFilters */
.filter-menu {
  width: 300px; max-width: calc(100vw - 32px); padding: 0;
  display: grid; grid-template-columns: minmax(0, 1fr);
  overflow: hidden;
}
.filter-menu.two { width: 620px; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); }
.fm-cats, .fm-facets {
  max-height: calc(var(--fm-max, 560px) - 66px);
  overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin;
}
.fm-cats { padding: 8px 6px; }
.fm-facets { padding: 8px 10px 10px; }
.filter-menu.two .fm-facets { border-left: 1px solid var(--line); }
.fm-foot { grid-column: 1 / -1; display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); background: var(--menu); }
.fm-show { flex: 1; }
.fm-reset {
  flex: none; font: inherit; font-weight: 500; color: var(--ink); cursor: pointer;
  background: none; border: 1px solid var(--line); border-radius: 999px; padding: 11px 18px;
  transition: border-color .15s, background .15s;
}
.fm-reset:hover:not(:disabled) { border-color: color-mix(in srgb, var(--accent) 50%, transparent); background: var(--accent-soft); }
.fm-reset:disabled { opacity: .45; cursor: default; }
.filter-menu input[type="radio"] { width: 16px; height: 16px; }
.filter-menu fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.fm-facets fieldset + fieldset { margin-top: 8px; }
.filter-menu legend { padding: 6px 12px 4px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.fm-facets legend { padding: 6px 2px; }
.filter-menu .check { padding: 8px 12px; border-radius: 10px; }
.filter-menu .check:hover { background: var(--accent-soft); }
.filter-menu .check .n { margin-left: auto; padding-left: 16px; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.filter-menu .check .more { width: 8px; flex: none; color: var(--muted); font-size: 17px; line-height: 1; }
.filter-menu .check.head { font-weight: 600; }
.filter-menu .check.sub { padding-left: 24px; }
.filter-menu .empty { opacity: .45; }
.cat-back {
  display: block; width: 100%; text-align: left;
  font: inherit; font-size: 13.5px; color: var(--muted);
  background: none; border: 0; border-radius: 10px;
  padding: 7px 12px; cursor: pointer;
}
.cat-back:hover { background: var(--accent-soft); color: var(--ink); }
/* кнопки-перемикачі: сам перемикач прихований, але лишається для клавіатури */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  position: relative;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px;
  border: 1px solid var(--line); border-radius: 999px;
  font-size: 13.5px; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.chip input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; }
.chip .n { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.chip:hover { border-color: color-mix(in srgb, var(--accent) 50%, transparent); }
.chip:has(input:checked) { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip:has(input:checked) .n { color: inherit; opacity: .75; }
.chip:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }

/* під пошуком: скільки книг знайдено і які фільтри ввімкнені — кожен знімається кліком */
.summary { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 22px 0 24px; }
.picked {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 8px 4px 12px;
  border: 0; border-radius: 999px;
  background: var(--accent); color: var(--accent-ink);
  font-size: 13px; font-weight: 500; cursor: pointer;
}
.picked span { font-size: 16px; line-height: 1; opacity: .7; }
.picked:hover span { opacity: 1; }
@keyframes pop { from { opacity: 0; transform: scale(.96) translateY(-4px); } }
@keyframes sheet { from { opacity: 0; transform: translateY(24px); } }
.sort-menu li {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  white-space: nowrap;
}
.sort-menu li:hover, .sort-menu li.active { background: var(--accent-soft); }
.sort-menu li[aria-selected="true"] { color: var(--accent); font-weight: 600; }
.sort-menu .tick { width: 16px; flex: none; visibility: hidden; }
.sort-menu li[aria-selected="true"] .tick { visibility: visible; }

/* скільки книг знайдено (лише під час пошуку чи фільтрів) — скляна табличка над каталогом */
.count {
  display: inline-block;
  padding: 7px 16px 8px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  font: 600 16px/1.3 Literata, Georgia, serif;
  font-variant-numeric: lining-nums;
}
/* ні лічильника, ні фільтрів — рядок порожній, лишається лише відступ до книг */
.summary:not(:has(.picked, .count:not([hidden]))) { margin: 0 0 22px; }
.shelves:not([hidden]) ~ .summary { margin-top: 40px; }

/* Список книг: одна скляна смуга (вітрина — нижче, без суцільного скла) */
.list { list-style: none; margin: 0; padding: 0; }
.list:not(.grid) {
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.row {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 120px 128px;
  gap: 6px 18px;
  align-items: center;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  transition: background .15s;
}
.row:last-child { border-bottom: 0; }
@media (hover: hover) {
  .row:hover { background: var(--row-hover); }
}
.row.in-cart { background: color-mix(in srgb, var(--gilt) 14%, transparent); box-shadow: inset 3px 0 0 var(--gilt); }

.title { font-weight: 600; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.row .title { font: 600 16.5px/1.35 Literata, Georgia, serif; }
.byline { color: var(--muted); font-size: 13px; margin-top: 3px; }
.byline .author { color: var(--accent); font-weight: 500; }
/* у списку автор і стан уживаної — в одному рядку через крапку; на вітрині стан — позначкою на обкладинці */
.byline .author + .meta::before { content: " · "; }
.meta { color: var(--muted); font-size: 13px; }
.pricebox { text-align: right; }
.price { font: 600 17px/1 Literata, Georgia, serif; white-space: nowrap; font-variant-numeric: lining-nums tabular-nums; }
.ctrl { justify-self: end; }

/* Мініатюра в рядку: маленька книжка на полиці — корінець ліворуч, як у розгорнутій картці */
.cover {
  position: relative;
  width: 48px; height: 67px; /* 5:7 — пропорції звичайної книги */
  border-radius: 2px 4px 4px 2px;
  overflow: hidden;
  background: var(--stage);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .18), 0 6px 14px -4px rgba(0, 0, 0, .3);
}
.cover img { display: block; width: 100%; height: 100%; }
.cover .cover-bg {
  position: absolute; inset: -15%; width: 130%; height: 130%;
  object-fit: cover;
  filter: blur(6px) brightness(.75) saturate(1.15);
}
.cover .cover-img {
  position: relative;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, .4));
}
/* звичайного формату книга заповнює рамку сама, без фону: зрізаються лише кілька відсотків з країв */
/* на фото справжня палітурка — намальований корінець їй не потрібен */
.cover.photo::after { background: none; }
.grid .cover .cover-bg { filter: blur(16px) brightness(.72) saturate(1.15); }
.grid .cover .cover-img { filter: drop-shadow(0 8px 14px rgba(0, 0, 0, .45)); }
.cover::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(90deg, rgba(0, 0, 0, .28), rgba(255, 255, 255, .14) 7%, transparent 14%);
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .08);
}
/* Без фото — тканинна палітурка: переплетення ниток, світло з лівого верхнього кута, затерті краї.
   У списку — перша літера; на вітрині й у картці — назва й автор тисненням і одне з чотирьох оформлень (data-look) */
.cover.blank {
  display: grid; place-items: center;
  background-color: var(--cloth, #4b4f55);
  background-image:
    linear-gradient(115deg, rgba(255, 255, 255, .09), transparent 45%, rgba(0, 0, 0, .16)),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, .035) 0 1px, transparent 1px 2px),
    repeating-linear-gradient(90deg, rgba(0, 0, 0, .06) 0 1px, transparent 1px 2px);
  color: var(--stamp, #ecebe5);
  font: 600 22px/1 Literata, Georgia, serif;
  container-type: inline-size;
  /* тиснення: літери вдавлені в тканину */
  text-shadow: 0 1px 1px rgba(0, 0, 0, .55), 0 -1px 0 rgba(255, 255, 255, .07);
}
.cover.blank[data-tone="light"] {
  background-image:
    linear-gradient(115deg, rgba(255, 255, 255, .4), transparent 45%, rgba(0, 0, 0, .09)),
    repeating-linear-gradient(0deg, rgba(0, 0, 0, .018) 0 1px, transparent 1px 2px),
    repeating-linear-gradient(90deg, rgba(0, 0, 0, .028) 0 1px, transparent 1px 2px);
  text-shadow: 0 1px 0 rgba(255, 255, 255, .6);
}
/* корінець і затерті краї */
.cover.blank::after {
  background:
    linear-gradient(90deg, rgba(0, 0, 0, .3), rgba(255, 255, 255, .12) 6%, transparent 13%),
    radial-gradient(ellipse 85% 75% at 55% 45%, transparent 58%, rgba(0, 0, 0, .26));
}
.cover-title, .cover-author { display: none; }
/* стан уживаної книги — позначка в куті обкладинки на вітрині */
.cond {
  position: absolute; top: 8px; left: 10px; z-index: 1;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(20, 21, 23, .78); color: #f4f4f2;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  font: 600 11px/1.3 Onest, system-ui, sans-serif;
  text-shadow: none;
}
/* Акція: шовкова закладка-ляссе, що звисає з верхнього краю книги, зі знижкою на ній */
.ribbon {
  position: absolute; top: 0; right: 12%; z-index: 1;
  width: max(34px, 22%);
  padding: 10px 0 max(26px, 17cqi);
  background: linear-gradient(90deg, #8a1520, #b8232e 40%, #c92f3a 55%, #9c1a24);
  color: #fff;
  font: 700 max(11px, 7cqi)/1 Onest, system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.01em;
  text-align: center;
  text-shadow: none;
  /* хвостик з вирізом, як у справжньої стрічки */
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% calc(100% - 8px), 0 100%);
  /* стрічка виходить з-під обрізу книги: зверху її трохи затіняє палітурка */
  box-shadow: inset 0 3px 2px -1px rgba(0, 0, 0, .35);
}
.grid .cover { container-type: inline-size; }
/* закладка займає верх обкладинки — назва на тканинній палітурці опускається під неї */
.grid .cover.blank:has(.ribbon) { padding-top: 48%; }

.price.sale { color: var(--sale); }
.was {
  display: flex; justify-content: flex-end; align-items: baseline; gap: 6px;
  margin-bottom: 4px;
  font-size: 12.5px; color: var(--muted); white-space: nowrap;
}
.was s { text-decoration-thickness: 1px; }
.was .off { color: var(--sale); font-weight: 600; font-variant-numeric: tabular-nums; }
/* на вітрині знижку вже видно на закладці */
.grid .was { justify-content: flex-start; }
.grid .was .off { display: none; }
.buy .was { justify-content: flex-start; font-size: 13.5px; }

.skeleton .cover { box-shadow: none; background: var(--line); }
.skeleton .cover::after { display: none; }

/* Вітрина: кожна книга — окрема скляна картка просто на фото: зверху обкладинка (фото чи тканина) на всю ширину,
   під нею на склі назва й ціна. Між картками видно фото — суцільного скла під каталогом немає.
   Колонок рівно --cols — так само й у полицях добірок, тож книги на головній стоять в одній сітці */
:root { --cols: 5; --gap: 20px; } /* не більше п'яти: інакше обкладинки дрібні, а назви обрізаються */
@media (max-width: 939px) { :root { --cols: 4; } }
@media (max-width: 759px) { :root { --cols: 3; } }
/* телефон: одна книга в ряду — горизонтальна картка (див. «Телефон: одна книга в ряду» нижче) */
@media (max-width: 600px) { :root { --cols: 1; --gap: 10px; } }
.list.grid {
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  gap: 28px var(--gap);
  padding: 0;
}
.grid .row {
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto 1fr auto;
  align-items: start;
  gap: 0 8px;
  padding: 0 14px 14px;
  border-bottom: 0;
  border-radius: 14px;
  overflow: hidden;
  background: var(--glass);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  box-shadow: var(--shadow);
  transition: background-color .15s, box-shadow .15s;
}
@media (hover: hover) {
  .grid .row:hover { background: var(--glass-strong); }
}
/* у кошику — картка в золотій рамці */
.grid .row.in-cart { background: var(--glass); box-shadow: 0 0 0 2px var(--gilt), var(--shadow); }
@media (hover: hover) {
  .grid .row.in-cart:hover { background: var(--glass-strong); }
}
/* наведення у вітрині каталогу: картка трохи піднімається, тінь глибшає — як книга на полиці добірки.
   Лише #list: на полицях своя поведінка (піднімається сама обкладинка, див. .shelf) */
@media (hover: hover) {
  #list.grid .row { transition: background-color .15s, box-shadow .2s, transform .2s cubic-bezier(.2, .8, .2, 1); }
  #list.grid .row:hover { transform: translateY(-6px); box-shadow: var(--shadow-lg); }
  #list.grid .row.in-cart:hover { box-shadow: 0 0 0 2px var(--gilt), var(--shadow-lg); }
}
@media (prefers-reduced-motion: reduce) {
  #list.grid .row { transition: background-color .15s, box-shadow .2s; }
}
/* обкладинка — верх картки, від краю до краю */
.grid .row .cover {
  grid-column: 1 / -1; grid-row: auto; align-self: auto;
  width: calc(100% + 28px); height: auto; aspect-ratio: 5 / 7;
  margin: 0 -14px 12px;
  border-radius: 0;
  box-shadow: none;
}
.grid .row .info { grid-column: 1 / -1; margin-bottom: 10px; }
.grid .row .title { font-size: 15px; }
.grid .byline { font-size: 12.5px; }
/* вітрина: під назвою лише автор, одним рядком; що не влазить — «…» */
.grid .byline > .author { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grid .pricebox { display: block; text-align: left; align-self: end; }
.grid .ctrl { align-self: end; }
/* картка знає свою ширину: на вузькій (телефон, полиця добірки) ціна й «− 1 +» поруч не вміщаються */
.grid .row { container: card / inline-size; }
.grid .qty button { width: 30px; }
.grid .qty input { width: 24px; }
/* ціна до 7 000 грн — 78px, «− 1 +» — 84px: менше 170px — лічильник під ціну, а не поверх неї */
@container card (max-width: 169px) {
  .grid .row:has(.qty) .pricebox { grid-column: 1 / -1; }
  .grid .row:has(.qty) .ctrl { grid-column: 1 / -1; justify-self: start; margin-top: 8px; }
}

/* Телефон: одна книга в ряду. Обкладинка на всю ширину була б ~500px заввишки — на екрані вміщалася б одна книга,
   тому картка горизонтальна: велика обкладинка ліворуч, праворуч назва й автор, а внизу ціна й кошик.
   Лише вітрина каталогу (#list): полиці добірок на телефоні так само гортаються вбік */
@media (max-width: 600px) {
  #list.grid { row-gap: 14px; }
  #list.grid .row {
    grid-template-columns: 40% minmax(0, 1fr) auto;
    grid-template-rows: auto 1fr auto;
    gap: 0 14px;
    padding: 12px 14px 14px 12px;
  }
  #list.grid .row .cover {
    grid-column: 1; grid-row: 1 / -1; align-self: start;
    width: 100%; margin: 0;
    border-radius: 3px 6px 6px 3px;
    box-shadow: 0 2px 3px rgba(0, 0, 0, .35), 0 14px 22px -10px rgba(0, 0, 0, .6);
  }
  #list.grid .row .info { grid-column: 2 / -1; grid-row: 1; margin: 4px 0 10px; }
  #list.grid .row .title { font-size: 17px; line-height: 1.3; -webkit-line-clamp: 4; }
  /* на телефоні в картці є місце: довгий автор переноситься, а не обрізається */
  #list.grid .byline { margin-top: 6px; }
  #list.grid .byline > .author { white-space: normal; }
  #list.grid .pricebox { grid-column: 2; grid-row: 3; align-self: end; }
  #list.grid .price { font-size: 19px; }
  #list.grid .ctrl { grid-column: 3; grid-row: 3; align-self: end; }
  /* у кошику ціна й «− 1 +» поруч не вміщаються — лічильник під ціну, на всю праву колонку */
  #list.grid .row:has(.qty) .pricebox { grid-column: 2 / -1; grid-row: 2; align-self: end; }
  #list.grid .row:has(.qty) .ctrl { grid-column: 2 / -1; grid-row: 3; justify-self: start; margin-top: 10px; }
}

.grid .cover.blank, .cover.blank.big {
  display: flex; flex-direction: column; justify-content: space-between; align-items: center;
  padding: 20% 13% 12%;
  text-align: center;
}
.grid .cover.blank::before, .cover.blank.big::before {
  content: ""; position: absolute; pointer-events: none;
}
:is(.grid, .big) .cover-letter { display: none; }
/* з позначкою стану назва опускається, щоб не впиратися в неї */
.grid .cover.blank:has(.cond) { padding-top: 32%; }
:is(.grid, .big) .cover-title {
  display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden;
  font: 600 max(13px, 10cqi)/1.2 Literata, Georgia, serif;
  text-wrap: balance; overflow-wrap: anywhere; hyphens: auto; hyphenate-limit-chars: 9 4 4;
}
:is(.grid, .big) .cover-author {
  display: block;
  font: 500 max(10.5px, 6.4cqi)/1.3 Onest, system-ui, sans-serif;
  opacity: .8;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}

/* Оформлення 1 — рамка: подвійна тиснена лінія по периметру */
:is(.grid .cover, .cover.big).blank[data-look="frame"]::before {
  inset: 6% 6% 5% 9%;
  border: 1px solid color-mix(in srgb, currentColor 45%, transparent); border-radius: 2px;
  box-shadow: inset 0 0 0 3px transparent, inset 0 0 0 4px color-mix(in srgb, currentColor 22%, transparent);
}
/* Оформлення 2 — паперова наклейка з назвою, як на старих бібліотечних книгах */
:is(.grid .cover, .cover.big).blank[data-look="label"] .cover-title {
  width: 100%; padding: 11% 8%;
  background: #efece4; color: #2b2c30; text-shadow: none;
  border-radius: 2px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .35), inset 0 0 0 3px #efece4, inset 0 0 0 4px rgba(43, 44, 48, .3);
  font-size: max(12px, 9cqi);
}
:is(.grid .cover, .cover.big).blank[data-look="label"][data-tone="light"] .cover-title { background: #fbfaf6; box-shadow: 0 1px 2px rgba(0, 0, 0, .25), inset 0 0 0 3px #fbfaf6, inset 0 0 0 4px rgba(43, 44, 48, .3); }
/* Оформлення 3 — тиснені смуги згори й знизу */
:is(.grid .cover, .cover.big).blank[data-look="bands"] { padding-bottom: 16%; }
:is(.grid .cover, .cover.big).blank[data-look="bands"]::before {
  inset: 9% 0;
  border-block: 3px double color-mix(in srgb, currentColor 50%, transparent);
}
/* Оформлення 4 — напівпалітурка: корінець темнішою тканиною, текст від лівого краю */
:is(.grid .cover, .cover.big).blank[data-look="quarter"] { align-items: flex-start; text-align: left; padding-left: 31%; padding-right: 10%; }
:is(.grid .cover, .cover.big).blank[data-look="quarter"]::before {
  inset: 0 auto 0 0; width: 22%;
  background: color-mix(in srgb, var(--cloth) 50%, #000);
  border-right: 1px solid color-mix(in srgb, currentColor 30%, transparent);
  box-shadow: 1px 0 3px rgba(0, 0, 0, .3);
}
:is(.grid .cover, .cover.big).blank[data-look="quarter"] .cover-title { text-wrap: pretty; font-size: max(12px, 9cqi); }

/* Велика палітурка: ліва сторінка картки й сторінки книги, коли фото немає */
.cover.big {
  width: min(100%, 290px); height: auto; aspect-ratio: 5 / 7;
  border-radius: 3px 7px 7px 3px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, .2), 0 26px 44px -16px rgba(0, 0, 0, .55);
}

@media (max-width: 600px) {
  .row { grid-template-columns: 48px minmax(0, 1fr) auto; gap: 6px 14px; padding: 12px 16px; }
  .row .cover { grid-row: span 2; align-self: start; }
  .row .info { grid-column: 2 / -1; }
  /* що не влазить у рядок до кнопки кошика, переходить на наступний */
  .pricebox { text-align: left; display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; }
  /* у рядку: ціна, потім стара ціна зі знижкою */
  .pricebox .was { order: 1; margin: 0; }
  .grid .pricebox .was { margin-bottom: 4px; }
  .row .title { font-size: 15.5px; }
  /* iPhone збільшує сторінку при фокусі на полі з текстом, меншим за 16px */
  input, textarea { font-size: 16px !important; }
  /* на телефоні кнопки панелі — лише значки, щоб полю пошуку лишилось місце */
  .sort-btn { padding: 11px 14px; }
  .sort-btn .label, .sort-btn .chev { display: none; }
  /* меню відкриваються на всю ширину панелі, а не від своєї кнопки — інакше вилазять за край екрана */
  .sort, .filter { position: static; }
  .sort-menu, .filter-menu { left: 0; right: 0; min-width: 0; max-width: none; }
  /* фільтри — панель знизу екрана поверх затемненої сторінки: спершу короткі групи, під ними категорії,
     кнопка «Показати…» завжди внизу. Скло панелі пошуку (backdrop-filter) робило б її рамкою для fixed,
     тому, поки панель відкрита, скло вимикаємо і піднімаємо панель пошуку над кошиком */
  .toolbar:has(.filter-menu:not([hidden])) {
    z-index: 40; -webkit-backdrop-filter: none; backdrop-filter: none; background: var(--glass-strong);
  }
  /* затемнення — шар панелі пошуку: дотик по ньому закриває меню і не натискає книгу під ним */
  .toolbar:has(.filter-menu:not([hidden]))::before {
    content: ''; position: fixed; inset: 0; background: var(--backdrop);
  }
  .filter-menu, .filter-menu.two {
    position: fixed; top: auto; bottom: 0; width: auto;
    display: flex; flex-direction: column;
    max-height: 85dvh; overflow-y: auto; overscroll-behavior: contain;
    border-radius: 22px 22px 0 0; border-bottom: 0;
    box-shadow: var(--shadow-lg);
    transform-origin: bottom; animation: sheet .2s ease-out;
  }
  .fm-cats, .fm-facets { max-height: none; overflow: visible; }
  .fm-facets { order: -1; padding: 12px 14px 14px; border-bottom: 1px solid var(--line); }
  .filter-menu.two .fm-facets { border-left: 0; }
  .fm-foot { position: sticky; bottom: 0; margin-top: auto; padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); }
  .list.grid { row-gap: 16px; }
}
/* кругла, на всю висоту панелі, як сусідні кнопки (ті розтягуються своїми обгортками) */
.view-btn { flex: none; width: 46px; height: auto; align-self: stretch; justify-content: center; padding: 0; }

.add {
  border: 0; cursor: pointer;
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--gilt-foil); color: var(--gilt-ink);
  box-shadow: var(--gilt-shine), 0 3px 8px -2px rgba(0, 0, 0, .35);
  font-size: 22px; line-height: 1;
  transition: filter .15s;
  flex: none;
}
.add:hover, .btn:hover:not(:disabled) { filter: brightness(1.08) saturate(1.1); }

.qty { display: inline-flex; align-items: center; background: var(--gilt-foil); box-shadow: var(--gilt-shine); border-radius: 999px; color: var(--gilt-ink); flex: none; }
.qty button {
  width: 34px; height: 40px; border: 0; background: none; color: inherit;
  font-size: 18px; cursor: pointer;
}
.qty button:disabled { opacity: .35; cursor: default; }
.qty input {
  width: 26px; border: 0; background: none; color: inherit; text-align: center; padding: 0;
  font: inherit; font-weight: 600; -moz-appearance: textfield; outline: none;
}
.qty input::-webkit-outer-spin-button, .qty input::-webkit-inner-spin-button { -webkit-appearance: none; }

/* Скелетон */
.skeleton .line { background: var(--line); }
.skeleton .line { height: 12px; border-radius: 6px; margin: 4px 0; }
.skeleton { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .5; } }

.state { text-align: center; color: var(--muted); padding: 40px 16px; border-radius: var(--radius); margin-top: 12px; }
.state.error { color: var(--danger); }
/* Перемикач сторінок каталогу: скляні капсули під полицею; поточна — залита, як вибраний фільтр */
.pager {
  display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px;
  margin-top: 18px;
}
.pager a, .pager span {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  min-width: 42px; height: 42px; padding: 0 12px;
  border-radius: 999px;
  font-weight: 500; font-variant-numeric: tabular-nums;
  color: var(--ink); text-decoration: none;
}
.pager a, .pager .step, .pager [aria-current] {
  border: 1px solid var(--glass-edge);
  background: var(--glass);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  box-shadow: 0 1px 0 var(--glass-edge) inset, 0 4px 14px rgba(0, 0, 0, .2);
}
.pager a:hover { background: var(--glass-strong); }
.pager [aria-current] { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.pager .step { padding: 0 14px; }
.pager .step[aria-disabled] { opacity: .45; }
/* «…» стоїть просто на фото — тінь, як у підвалі */
.pager .gap { min-width: 20px; padding: 0; color: rgba(255, 255, 255, .9); text-shadow: 0 0 6px #000; }
@media (max-width: 600px) {
  .pager { gap: 4px; }
  .pager a, .pager span { min-width: 38px; height: 40px; padding: 0 8px; }
  .pager .step .label { display: none; }
  .pager .step { padding: 0 10px; }
}

/* ---------- Добірки ----------
   На головній — вітрина: одна добірка (новинки, популярне), на яку крамниця хоче звернути увагу.
   Єдиний темний елемент на світлій сторінці — димчасте скло в тонкій золотій рамці. Згори по центру назва добірки,
   «Усі N книг» і стрілки — у правому куті, поверх смуги з назвою (висоти не додають); під назвою обкладинки
   стоять просто на склі (не картками, як у каталозі), по центру, а коли не вміщаються — гортаються вбік.
   Опису на вітрині немає — лише назва.
   Вибрана добірка — заголовок з описом над її книгами */
.shelves { display: grid; gap: 28px; margin-top: 22px; }
/* у темній темі сторінка й так темна — вітрина ще темніша, вирізняє її золота рамка */
@media (prefers-color-scheme: dark) { .shelves .shelf.glass { background: rgba(4, 4, 6, .8); } }
.shelf.glass {
  /* усередині вітрини — світлі кольори на темному склі в обох темах */
  --ink: #f4f2ec; --muted: #b3b0a8;
  --line: rgba(255, 255, 255, .14); --glass-field: rgba(255, 255, 255, .07);
  --accent: #efefec; --accent-soft: rgba(255, 255, 255, .1);
  --gilt-text: #dcbf80;
  --side: 200px; /* місце з боків назви під «Усі N книг» праворуч (і стільки ж ліворуч — щоб назва стояла по центру) */
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-width: 0;
  padding: 26px 0 24px;
  border: 1px solid color-mix(in srgb, var(--gilt) 45%, transparent);
  border-radius: 22px;
  overflow: hidden; /* ряд книг обрізається заокругленим краєм вітрини */
  background: rgba(22, 22, 24, .78);
  color: var(--ink);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .1), 0 22px 50px rgba(0, 0, 0, .45);
}
/* заголовок: назва по центру; «Усі N книг» і стрілки — у правому куті, на рівні назви */
.shelf-head { display: contents; }
.shelf-head:has(.shelf-nav:not([hidden])) { --side: 300px; }
.shelf-title {
  margin: 0 var(--side);
  text-align: center;
  font: 600 clamp(26px, 3vw, 34px)/1.15 Literata, Georgia, serif; letter-spacing: -.015em;
  text-wrap: balance;
}
.shelf-title a { color: inherit; text-decoration: none; }
.shelf-title a:hover { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 5px; }
/* назва — 34px × 1.15 ≈ 39px заввишки, кнопки — 40px: верх кнопок на рівні верху назви */
.shelf-all, .shelf-nav { position: absolute; top: 26px; right: 30px; }
/* стрілки праворуч, «Усі N книг» — ліворуч від них */
.shelf-head:has(.shelf-nav:not([hidden])) .shelf-all { right: 126px; }
.shelf-all {
  display: inline-flex; align-items: center; gap: 4px;
  height: 40px; padding: 0 12px 0 16px;
  border: 1px solid color-mix(in srgb, var(--gilt) 60%, transparent); border-radius: 999px;
  color: var(--gilt-text);
  font-size: 14px; font-weight: 600; text-decoration: none; white-space: nowrap;
  transition: background-color .15s, color .15s;
}
.shelf-all:hover { background: var(--gilt-foil); color: var(--gilt-ink); border-color: transparent; }
.shelf-nav { display: flex; gap: 6px; }
.shelf-nav button {
  display: grid; place-items: center;
  width: 40px; height: 40px; padding: 0;
  border: 1px solid var(--line); border-radius: 50%;
  background: var(--glass-field); color: var(--ink);
  cursor: pointer; transition: background-color .15s;
}
.shelf-nav button:hover:not(:disabled) { background: var(--accent-soft); }
.shelf-nav button:disabled { opacity: .35; cursor: default; }
/* на телефоні вітрину гортають пальцем */
@media (hover: none) {
  .shelf-nav { display: none; }
  .shelf-head:has(.shelf-nav) { --side: 200px; }
  .shelf-head:has(.shelf-nav) .shelf-all { right: 30px; }
}

/* ряд книг: на всю ширину вітрини; мало книг — стоять по центру, багато — наступна визирає з-за краю */
.shelf-row {
  display: flex; gap: 26px;
  /* ряд гортається вбік, тож обрізає все, що виходить за нього, і згори теж: 14px зверху — місце для книги,
     піднятої при наведенні (6px), разом із золотою рамкою книги в кошику (ще 6px); відступ від заголовка — як і був, 22px */
  list-style: none; margin: 8px 0 0; padding: 14px 30px 4px;
  overflow-x: auto; overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory; scroll-padding: 0 30px;
  scrollbar-width: none;
}
.shelf-row::-webkit-scrollbar { display: none; }
/* по центру через автовідступи, а не justify-content: так ряд, що не вміщається, не обрізається зліва */
.shelf-row > :first-child { margin-left: auto; }
.shelf-row > :last-child { margin-right: auto; }
/* чотири книги й край п'ятої — трохи більші, ніж у каталозі */
.shelf-row > li { flex: 0 0 clamp(170px, calc((100% - 60px - 4 * 26px) / 4.4), 250px); scroll-snap-align: start; }
/* книга у вітрині — обкладинка просто на склі, під нею назва й ціна; без скляної картки */
/* .shelf .row.in-cart:hover — окремо: інакше перемагає сильніше .grid .row.in-cart:hover зі світлим фоном картки */
.shelf .row, .shelf .row:hover, .shelf .row.in-cart, .shelf .row.in-cart:hover {
  padding: 0; border-radius: 0; overflow: visible;
  background: none; -webkit-backdrop-filter: none; backdrop-filter: none; box-shadow: none;
}
.shelf .row .cover {
  width: 100%; margin: 0 0 14px;
  border-radius: 3px 6px 6px 3px;
  box-shadow: 0 2px 3px rgba(0, 0, 0, .45), 0 24px 34px -14px rgba(0, 0, 0, .85);
}
.shelf .row.in-cart .cover { outline: 2px solid var(--gilt); outline-offset: 4px; }
/* наведення: книгу ніби беруть з полиці — трохи піднімається, тінь глибшає (і для книг у кошику) */
@media (hover: hover) {
  .shelf .row .cover { transition: transform .2s cubic-bezier(.2, .8, .2, 1), box-shadow .2s; }
  .shelf .row:hover .cover {
    transform: translateY(-6px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, .4), 0 34px 44px -16px rgba(0, 0, 0, .9);
  }
}
@media (prefers-reduced-motion: reduce) {
  .shelf .row .cover { transition: none; }
}
.shelf .row .title { font-size: 15.5px; }
/* добірка більша за вітрину — в кінці ряду порожнє місце з посиланням на всю добірку */
.shelf-more a {
  display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 4px;
  aspect-ratio: 5 / 7;
  border: 1.5px dashed color-mix(in srgb, var(--gilt) 50%, transparent);
  border-radius: 3px 6px 6px 3px;
  color: var(--ink); text-decoration: none; text-align: center;
  transition: background-color .15s;
}
.shelf-more a:hover { background: var(--accent-soft); }
.shelf-more b { font: 600 24px/1.2 Literata, Georgia, serif; color: var(--gilt-text); }
.shelf-more span { color: var(--muted); font-size: 13.5px; }
.shelf-more svg { margin-top: 6px; color: var(--gilt-text); }

@media (max-width: 759px) {
  .shelf.glass { padding: 20px 0 22px; border-radius: 18px; }
  /* поруч із назвою по центру кнопці місця немає — назва сама веде на добірку, зі стрілкою */
  .shelf-title, .shelf-head:has(.shelf-nav:not([hidden])) .shelf-title { margin: 0 20px; font-size: 26px; }
  .shelf-title a::after { content: "\a0›"; color: var(--gilt-text); }
  .shelf-all, .shelf-nav { display: none; }
  /* 14px зверху — місце для золотої рамки книги в кошику, як і на ПК; відступ від заголовка лишається 18px */
  .shelf-row { margin-top: 4px; padding: 14px 20px 4px; scroll-padding: 0 20px; gap: 16px; }
  /* дві книги й край третьої — видно, що вітрину можна гортати */
  .shelf-row > li { flex-basis: 42%; }
}
.coll-intro { margin-top: 18px; }
.coll-head {
  margin-top: 12px; padding: 28px 34px 26px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.coll-kicker { margin: 0 0 6px; color: var(--muted); font-size: 12.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.coll-head :is(h1, h2) { font: 600 clamp(26px, 3.4vw, 36px)/1.15 Literata, Georgia, serif; letter-spacing: -.01em; margin: 0; text-wrap: balance; }
.coll-desc { margin: 12px 0 0; max-width: 68ch; font: 400 16px/1.65 Literata, Georgia, serif; text-wrap: pretty; }
.coll-desc + .coll-desc { margin-top: .6em; }

/* Категорія: без суцільного скла — лише табличка під розмір назви (шлях угору й назва)
   і підкатегорії одним рядком скляних кнопок, як «‹ Усі книги», що гортається вбік */
/* один ряд: табличка, підкатегорії, стрілки */
.cat-head { display: flex; align-items: center; gap: 14px; }
.cat-label {
  flex: none; max-width: min(46%, 520px); padding: 9px 20px 11px;
  border-radius: 16px; box-shadow: var(--shadow);
}
.cat-path { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 6px; font-size: 13px; color: var(--muted); }
.cat-path a { color: inherit; text-decoration: none; font-weight: 500; border-radius: 4px; }
.cat-path a:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.cat-path .sep { opacity: .6; }
.cat-label :is(h1, h2) {
  margin: 1px 0 0;
  font: 600 clamp(22px, 2.6vw, 28px)/1.15 Literata, Georgia, serif; letter-spacing: -.015em;
  text-wrap: balance;
}
.cat-nav { display: flex; gap: 6px; flex: none; }
.cat-nav button {
  display: grid; place-items: center;
  width: 38px; height: 38px; padding: 0;
  border: 1px solid var(--glass-edge); border-radius: 50%;
  box-shadow: 0 1px 0 var(--glass-edge) inset, 0 4px 14px rgba(0, 0, 0, .2);
  color: var(--ink); cursor: pointer;
}
.cat-nav button:hover { background: var(--glass-strong); }
/* на початку чи в кінці рядка зайва стрілка зникає, але місце лишається — друга не стрибає */
.cat-nav button:disabled { visibility: hidden; }
/* знизу місце для тіні кнопок: рядок гортається вбік і обрізає все, що за ним */
.cat-strip {
  --fade-l: 0px; --fade-r: 0px;
  flex: 1; min-width: 0;
  display: flex; gap: 8px;
  list-style: none; margin: 0; padding: 8px 0 12px;
  overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 var(--fade-l), #000 calc(100% - var(--fade-r)), transparent);
  mask-image: linear-gradient(90deg, transparent, #000 var(--fade-l), #000 calc(100% - var(--fade-r)), transparent);
}
.cat-strip::-webkit-scrollbar { display: none; }
.cat-strip[data-left] { --fade-l: 40px; }
.cat-strip[data-right] { --fade-r: 40px; }
.cat-strip li { flex: none; }
.cat-strip a {
  display: inline-flex; align-items: baseline; gap: 7px;
  padding: 7px 14px 8px;
  border: 1px solid var(--glass-edge); border-radius: 999px;
  box-shadow: 0 1px 0 var(--glass-edge) inset, 0 4px 14px rgba(0, 0, 0, .2);
  color: var(--ink); text-decoration: none; white-space: nowrap;
  font-size: 14px; font-weight: 500;
}
/* кнопки малі, і крізь звичайне скло фото проступає надто різко — скло тут щільніше */
.cat-strip a.glass { background: var(--glass-strong); }
.cat-strip a.glass:hover { background: var(--menu); }
.cat-strip a:focus-visible { outline-offset: -2px; }
@media (hover: none) { .cat-nav { display: none; } }
/* вузько — підкатегорії під табличкою, рядок від краю до краю екрана */
@media (max-width: 760px) {
  .cat-head { flex-wrap: wrap; row-gap: 4px; }
  .cat-label { max-width: 100%; padding: 8px 16px 10px; }
  .cat-strip { flex-basis: 100%; margin: 0 -16px; padding: 6px 16px 10px; scroll-padding: 0 16px; }
  .cat-nav { display: none; }
}
@media (max-width: 600px) {
  .coll-head { padding: 22px 20px 20px; }
}

.btn {
  font-weight: 600; cursor: pointer;
  border: 0; border-radius: 999px;
  padding: 12px 22px;
  background: var(--gilt-foil); color: var(--gilt-ink);
  box-shadow: var(--gilt-shine);
  transition: filter .15s;
}
.btn:disabled { opacity: .55; cursor: default; }

/* Кошик: димчасте скло */
.cartbar {
  position: fixed; left: 50%; bottom: 20px; z-index: 10;
  width: min(560px, calc(100% - 32px));
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 10px 10px 20px;
  background: var(--bar-bg); color: var(--bar-ink);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 999px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .12) inset, 0 18px 50px rgba(0, 0, 0, .4);
  transform: translate(-50%, 160%);
  transition: transform .25s cubic-bezier(.2, .8, .2, 1);
}
.cartbar.show { transform: translate(-50%, 0); }
.cartbar .info { display: flex; align-items: center; gap: 12px; min-width: 0; }
.cartbar .pill { background: rgba(255, 255, 255, .16); color: var(--bar-ink); border-radius: 999px; min-width: 28px; height: 28px; display: grid; place-items: center; font-weight: 600; font-size: 13px; padding: 0 8px; }
.cartbar b { font: 600 17px Literata, Georgia, serif; white-space: nowrap; }
.cartbar .btn { white-space: nowrap; }

/* Зв'язок з продавцем: золота кругла кнопка в правому нижньому куті, над нею — меню */
.chat { position: fixed; right: 20px; bottom: 20px; z-index: 11; transition: bottom .25s cubic-bezier(.2, .8, .2, 1); }
.chat-btn {
  display: grid; place-items: center;
  width: 56px; height: 56px; padding: 0;
  border: 0; border-radius: 50%; cursor: pointer;
  background: var(--gilt-foil); color: var(--gilt-ink);
  box-shadow: var(--gilt-shine), 0 10px 28px rgba(0, 0, 0, .4);
  transition: filter .15s;
}
.chat-btn:hover { filter: brightness(1.08) saturate(1.1); }
.chat-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.chat-menu {
  position: absolute; right: 0; bottom: calc(100% + 10px);
  width: max-content; max-width: calc(100vw - 40px);
  padding: 6px;
  background: var(--menu); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: var(--shadow-lg);
  transform-origin: bottom right;
  animation: pop .14s ease-out;
}
.chat-title { display: grid; gap: 2px; margin: 6px 10px 6px; font-size: 13px; font-weight: 600; color: var(--ink); }
/* робочі години — ті самі, що на сторінці «Контакти» і в боті (SUPPORT_HOURS) */
.chat-title small { font-size: 12.5px; font-weight: 400; color: var(--muted); }
.chat-menu a {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 11px;
  color: var(--ink); text-decoration: none;
}
.chat-menu a:hover, .chat-menu a:focus-visible { background: var(--accent-soft); outline: none; }
.chat-menu a svg { flex: none; color: var(--accent); }
.chat-menu span { display: grid; gap: 1px; }
.chat-menu b { font-size: 14px; font-weight: 600; }
.chat-menu small { font-size: 12.5px; color: var(--muted); }
/* на вузькому екрані смуга кошика на всю ширину — кнопка піднімається над нею */
@media (max-width: 760px) {
  body:has(.cartbar.show) .chat { bottom: 100px; }
}
@media (max-width: 600px) {
  /* на телефоні менша: картки каталогу на всю ширину, і кнопка не повинна закривати назви й ціни */
  .chat { right: 12px; bottom: 12px; }
  .chat-btn { width: 44px; height: 44px; box-shadow: var(--gilt-shine), 0 6px 16px rgba(0, 0, 0, .35); }
  .chat-btn svg { width: 20px; height: 20px; }
}
@media print { .chat { display: none; } }

/* ---------- Вікна: скляні аркуші над затемненим фото ----------
   На ПК — по центру; на телефоні — аркуш, що виїжджає знизу на всю ширину */
dialog {
  width: min(560px, calc(100% - 32px));
  max-height: calc(100dvh - 48px);
  border: 1px solid var(--glass-edge); border-radius: 26px; padding: 0;
  background: var(--glass-strong); color: var(--ink);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  box-shadow: var(--shadow-lg);
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--muted) 45%, transparent) transparent;
  overscroll-behavior: contain;
}
dialog[open] { animation: rise .22s cubic-bezier(.2, .8, .2, 1); }
/* поки відкрите вікно, сторінка під ним не гортається (інакше на телефоні вона їде під пальцем) */
html:has(dialog[open]) { overflow: hidden; }
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(.985); } }
@keyframes sheet { from { transform: translateY(100%); } }
dialog::backdrop { background: var(--backdrop); -webkit-backdrop-filter: blur(8px) grayscale(.3); backdrop-filter: blur(8px) grayscale(.3); }

/* Кнопка «закрити»: кругла скляна, однакова в обох вікнах */
.x {
  flex: none; display: grid; place-items: center;
  width: 40px; height: 40px; padding: 0;
  border: 1px solid var(--line); border-radius: 50%;
  background: var(--glass-field); color: var(--ink);
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.x:hover { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }

.dlg { padding: 0; }
.dlg-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.dlg h2 { font: 600 26px/1.2 Literata, Georgia, serif; letter-spacing: -.01em; margin: 0; }

/* ---------- Замовлення: ліворуч три кроки, праворуч підсумок, що лишається на місці ---------- */
dialog.order { width: min(1000px, calc(100% - 32px)); }
#orderBody:not([hidden]) {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  grid-template-areas: "head head" "form sum";
  column-gap: 8px;
}
.order .dlg-head { grid-area: head; padding: 26px 26px 10px 36px; }
.order-form { grid-area: form; padding: 10px 28px 36px 36px; }
.order-sum {
  grid-area: sum; align-self: start;
  position: sticky; top: 16px;
  margin: 8px 24px 28px 0;
  border: 1px solid var(--line); border-radius: 20px;
  background: var(--stage);
  overflow: hidden;
}
.order-lines { padding: 18px 18px 6px; }
.sum-title { margin: 0 0 4px; color: var(--muted); font-size: 13px; font-weight: 500; }
.order-pay { padding: 14px 18px 18px; border-top: 1px solid var(--line); }
.order-pay .btn { width: 100%; padding: 14px 22px; font-size: 15.5px; }

.lines { list-style: none; margin: 0; padding: 0; max-height: 46dvh; overflow-x: hidden; overflow-y: auto; scrollbar-width: thin; }
.lines li {
  display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 12px; align-items: start;
  padding: 12px 0; border-top: 1px solid var(--line);
}
.lines li:first-child { border-top: 0; }
.lines .cover { width: 34px; height: 48px; }
.lines .cover.blank { font-size: 15px; }
.lines .title { -webkit-line-clamp: 2; font: 600 14px/1.3 Literata, Georgia, serif; }
.lines .meta { font-size: 12.5px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* передзамовлення: позначка під назвою, щоб було видно ще до надсилання */
.lines .pre {
  margin-top: 3px; padding-left: 9px;
  border-left: 2px solid var(--accent);
  color: var(--ink); font-size: 12px; font-weight: 600; line-height: 1.35;
}
/* кількість — менший лічильник, ніж у каталозі */
.lines .qty { margin-top: 8px; box-shadow: none; }
.lines .qty button { width: 28px; height: 28px; font-size: 16px; }
.lines .qty input { width: 30px; font-size: 13.5px; }
/* сума, під нею «прибрати» */
.line-end { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.lines .sum { font: 600 14.5px/1.3 Literata, Georgia, serif; white-space: nowrap; font-variant-numeric: lining-nums tabular-nums; }
.lines .remove {
  display: grid; place-items: center; width: 26px; height: 26px; padding: 0;
  background: none; border: 0; border-radius: 50%; color: var(--muted); cursor: pointer;
}
.lines .remove:hover { color: var(--danger); background: var(--accent-soft); }
.total { display: flex; justify-content: space-between; align-items: baseline; margin: 0 0 14px; }
.total span { color: var(--muted); font-weight: 500; }
.total b { font: 600 26px/1 Literata, Georgia, serif; font-variant-numeric: lining-nums tabular-nums; }

/* Кроки форми — справжня послідовність, тому з номерами */
.step + .step { margin-top: 30px; padding-top: 26px; border-top: 1px solid var(--line); }
.step-title {
  display: flex; align-items: center; gap: 12px;
  font: 600 19px/1.3 Literata, Georgia, serif; margin: 0 0 16px;
}
.step-title .n {
  flex: none; display: grid; place-items: center;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink);
  font: 600 13.5px/1 Onest, system-ui, sans-serif;
}
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
.form .full { grid-column: 1 / -1; }
label { display: grid; gap: 6px; font-size: 13px; font-weight: 500; color: var(--muted); }
label input:not([type=radio]):not([type=checkbox]), label textarea {
  font: inherit; font-size: 15px; font-weight: 400; color: var(--ink);
  background: var(--glass-field);
  border: 1px solid var(--line); border-radius: 14px;
  padding: 12px 14px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
label input::placeholder, label textarea::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }
label input:not([type=radio]):not([type=checkbox]):focus, label textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
label input:disabled { opacity: .6; cursor: not-allowed; }
label .hint { font-weight: 400; color: var(--muted); }
label input[aria-invalid="true"]:not([type=radio]):not([type=checkbox]) { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 7%, var(--glass-field)); }
.err {
  min-height: 0; font-size: 12.5px; font-weight: 500; color: var(--danger);
  display: flex; align-items: center; gap: 5px;
}
.err:empty { display: none; }
.err::before { content: "!"; flex: none; width: 15px; height: 15px; border-radius: 50%; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; }
.counter { justify-self: end; font-size: 12px; font-weight: 400; margin-top: -2px; }
.help-link { justify-self: start; font-size: 12.5px; font-weight: 500; color: var(--accent); text-decoration: none; }
.help-link:hover { text-decoration: underline; }
textarea { resize: vertical; min-height: 76px; }
.choices + .form, .note + .form { margin-top: 14px; }
.choices + .note { margin-top: 10px; }

/* Вибір доставки й оплати: плитки з колом-позначкою */
.choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.choice { display: block; cursor: pointer; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice span {
  position: relative;
  display: grid; gap: 2px; height: 100%;
  padding: 11px 36px 11px 14px;
  border: 1px solid var(--line); border-radius: 14px;
  background: var(--glass-field);
  transition: border-color .15s, background .15s;
}
.choice span::after {
  content: ""; position: absolute; top: 12px; right: 12px;
  width: 16px; height: 16px; border-radius: 50%;
  border: 1.5px solid color-mix(in srgb, var(--muted) 60%, transparent);
  box-sizing: border-box;
}
/* Нова пошта: як отримати — сегментований перемикач під плитками перевізників */
.carriers ~ .form { margin-top: 14px; }
/* чотири перевізники — одним рядом, а не 3 + 1; на вузькому — 2 × 2 */
.choices.carriers { grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); }
.seg {
  display: flex; gap: 3px; margin-top: 10px; padding: 3px;
  border: 1px solid var(--line); border-radius: 13px; background: var(--glass-field);
}
.seg[hidden] { display: none; }
.seg label { flex: 1; min-width: 0; cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 6px; border-radius: 10px;
  font-size: 13.5px; font-weight: 500; color: var(--muted); white-space: nowrap;
  transition: background .15s, color .15s, box-shadow .15s;
}
.seg span .ico { flex: none; width: 18px; height: 18px; }
.seg label:hover span { color: var(--ink); }
.seg input:checked + span { background: var(--menu); color: var(--ink); font-weight: 600; box-shadow: 0 1px 3px rgba(0, 0, 0, .12), inset 0 0 0 1px var(--accent); }
.seg input:checked + span .ico { color: var(--accent); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }
/* на телефоні в перемикачі лише слова: з іконками «Відділення» впирається в краї */
@media (max-width: 420px) { .seg span .ico { display: none; } }
/* місце під логотип перевізника (файл у img/carriers/) замість іконки */
.choice .logo { display: block; height: 22px; width: auto; max-width: 100%; margin-bottom: 6px; object-fit: contain; object-position: left; }
/* у Meest логотип — напис, а не знак: трохи більший, щоб читався; висота плитки та сама */
.choice .logo-meest { height: 30px; margin: -4px 0 2px -2px; }

/* іконка способу доставки чи оплати — над назвою; вибраний спосіб — іконка кольором акценту */
.choice .ico { display: block; width: 22px; height: 22px; margin-bottom: 6px; color: var(--muted); transition: color .15s; }
.choice input:checked + span .ico { color: var(--accent); }
.choice b { color: var(--ink); font-size: 14px; font-weight: 600; }
.choice small { color: var(--muted); font-size: 12.5px; font-weight: 400; }
.choice:hover span { border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.choice input:checked + span { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.choice input:checked + span::after { border: 5px solid var(--accent); }
.choice input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.note { margin: 0; padding: 11px 14px; border-radius: 14px; background: var(--accent-soft); color: var(--ink); font-size: 13.5px; }
.note:empty { display: none; }
/* попередження про передзамовлення — між «Разом» і кнопкою надсилання */
.pre-note {
  display: flex; gap: 10px; align-items: flex-start;
  margin: 0 0 14px; font-size: 13px; line-height: 1.45;
  background: color-mix(in srgb, var(--gilt) 22%, transparent);
  border: 1px solid color-mix(in srgb, var(--gilt) 70%, transparent);
  box-shadow: inset 3px 0 0 var(--gilt);
}
.pre-note[hidden] { display: none; }
/* хрестик «сховати» — у правому верхньому куті; тексту лишаємо місце, щоб не налазив */
.pre-note { position: relative; padding-right: 38px; }
.pre-close {
  position: absolute; top: 6px; right: 6px;
  display: grid; place-items: center; width: 28px; height: 28px; padding: 0;
  border: 0; border-radius: 50%; background: none; color: var(--muted); cursor: pointer;
}
.pre-close:hover { background: color-mix(in srgb, var(--gilt) 25%, transparent); color: var(--ink); }
.pre-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.pre-note svg { flex: none; margin-top: 1px; color: var(--gilt); }
.pre-note b { display: block; margin-bottom: 2px; font-weight: 700; }
.check { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 400; font-size: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; }

/* Підказки (населений пункт, відділення) */
.combo { position: relative; display: grid; }
.combo-list {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 30;
  max-height: 260px; overflow-y: auto;
  list-style: none; margin: 0; padding: 4px;
  background: var(--menu);
  border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow-lg);
}
.combo-list li { padding: 9px 11px; border-radius: 9px; cursor: pointer; color: var(--ink); font-weight: 400; font-size: 14px; line-height: 1.35; }
.combo-list li.active { background: var(--accent-soft); }
.combo-list li.combo-empty { color: var(--muted); cursor: default; background: none; }

.trap { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.msg { white-space: pre-line; font-size: 13.5px; }
.msg:empty { display: none; }
.msg.error { color: var(--danger); margin: 0 0 12px; }
.done { text-align: center; padding: 48px 28px 36px; }
.done .check { width: 68px; height: 68px; margin: 0 auto 18px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; }
.done h2 { margin-bottom: 8px; }
.done p { color: var(--muted); margin: 0 auto 24px; max-width: 380px; text-wrap: pretty; }
dialog.order:has(#orderDone:not([hidden])) { width: min(480px, calc(100% - 32px)); }

/* З карткою книги весь рядок відкриває її (посилання на назві розтягнуте на рядок);
   кнопка кошика лежить зверху і лишається окремою */
.row:has(a.title) { position: relative; cursor: pointer; }
a.title { color: inherit; text-decoration: none; }
a.title::after { content: ""; position: absolute; inset: 0; }
.row .ctrl { position: relative; z-index: 1; }
a.title:focus-visible { outline: none; }
.row:has(a.title:focus-visible) { outline: 2px solid var(--accent); outline-offset: -2px; }

/* ---------- Картка книги: розгорнута книга ----------
   Ліва сторінка — сама книга (фото чи тканинна палітурка) і покупка, права — текст, що гортається.
   Між ними корінець. Висота стала, щоб вікно не стрибало від книги до книги */
dialog.book {
  width: min(1040px, calc(100% - 32px));
  height: min(740px, calc(100dvh - 48px));
  overflow: hidden;
}
.spread {
  position: relative; height: 100%;
  display: grid;
  grid-template-columns: minmax(300px, 5fr) minmax(0, 7fr);
  grid-template-rows: minmax(0, 1fr) auto;
  grid-template-areas: "photos text" "buy text";
}
/* корінець: тінь, що западає в обидва боки від згину */
.spread::after {
  content: ""; position: absolute; top: 0; bottom: 0; left: calc(5 / 12 * 100%); width: 60px;
  transform: translateX(-50%); pointer-events: none;
  background: linear-gradient(90deg, transparent, var(--spine) 44%, var(--spine-deep) 50%, var(--spine) 56%, transparent);
}
.leaf-photos { grid-area: photos; display: flex; flex-direction: column; min-height: 0; background: var(--stage); }
.stage { position: relative; flex: 1; min-height: 0; display: grid; grid-template: minmax(0, 1fr) / minmax(0, 1fr); place-items: center; padding: 48px 56px 20px; touch-action: pan-y; }
.stage img {
  display: block; max-width: 100%; max-height: 100%; object-fit: contain;
  border-radius: 3px;
  filter: drop-shadow(0 18px 30px rgba(0, 0, 0, .32));
}
.stage .cover.big { width: min(250px, 100%); }
.stage .nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  display: grid; place-items: center;
  width: 40px; height: 40px; padding: 0; border: 1px solid var(--glass-edge); border-radius: 50%;
  background: var(--glass-strong); color: var(--ink);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  cursor: pointer;
  box-shadow: var(--shadow);
}
.stage .prev { left: 12px; }
.stage .next { right: 12px; }
.thumbs { display: flex; gap: 8px; justify-content: center; padding: 4px 20px 16px; overflow-x: auto; scrollbar-width: none; }
.thumbs button {
  flex: none; width: 42px; height: 58px; padding: 0;
  border: 0; border-radius: 4px; overflow: hidden; cursor: pointer;
  background: var(--line); opacity: .5;
  transition: opacity .15s;
}
.thumbs button:hover, .thumbs button[aria-current="true"] { opacity: 1; }
.thumbs button[aria-current="true"] { box-shadow: 0 0 0 2px var(--accent); }
.thumbs img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Покупка під книгою: ціна ліворуч, кнопка праворуч, на скляній смузі */
.buy {
  grid-area: buy;
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  margin: 0 22px 22px 18px; padding: 14px 14px 14px 20px;
  border: 1px solid var(--glass-edge); border-radius: 20px;
  background: var(--glass-strong);
  box-shadow: 0 1px 0 var(--glass-edge) inset, 0 8px 24px rgba(0, 0, 0, .12);
}
.buy .price { font-size: 26px; }
.buy .was { justify-content: flex-start; font-size: 13.5px; }
.ctrl.wide { display: flex; align-items: center; gap: 10px; }
.ctrl.wide .add.btn { width: auto; height: auto; border: 0; border-radius: 999px; padding: 13px 22px; font-size: 15px; font-weight: 600; }
.ctrl.wide .in { color: var(--muted); font-size: 13px; font-weight: 500; }
.ctrl.wide .qty button { width: 40px; height: 46px; }

.leaf-text { grid-area: text; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.leaf-head { padding: 40px 84px 0 48px; }
.crumbs { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; margin: 0 0 12px; font-size: 13px; color: var(--muted); }
.crumbs a { color: inherit; text-decoration: none; font-weight: 500; }
.crumbs a:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.crumbs .sep { opacity: .6; }
.crumbs[hidden] + h2 { margin-top: 4px; }
.book h2, .page-text h1 {
  font: 600 clamp(25px, 2.7vw, 34px)/1.16 Literata, Georgia, serif; letter-spacing: -.012em;
  margin: 0 0 10px; text-wrap: balance;
}
.book-by { margin: 0; color: var(--ink); font-size: 16px; font-weight: 500; }
/* характеристики: сітка «назва над значенням», розділена тонкими лініями, як вихідні дані книги */
.facts {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); column-gap: 24px;
  margin: 26px 48px 0; font-size: 14.5px;
  border-top: 1px solid var(--line);
}
.facts > div { padding: 11px 0 12px; border-bottom: 1px solid var(--line); min-width: 0; }
.facts dt { color: var(--muted); font-size: 12.5px; margin-bottom: 2px; }
.facts dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; font-variant-numeric: lining-nums; }
.facts:empty { display: none; }
.desc { padding: 26px 48px 40px; font: 400 16.5px/1.72 Literata, Georgia, serif; max-width: 68ch; hyphens: auto; }
.desc p { margin: 0 0 .9em; text-wrap: pretty; }
.desc p:last-child { margin-bottom: 0; }
.desc:empty { display: none; }
/* «Є питання про цю книгу?» — під описом; без опису стоїть одразу під характеристиками */
.ask { margin: 26px 48px 40px; padding: 16px 18px; border-radius: 14px; background: var(--accent-soft); max-width: 60ch; }
.desc:not(:empty) + .ask { margin-top: 0; }
.ask p { margin: 0 0 12px; font-size: 14px; line-height: 1.5; color: var(--muted); }
.ask p b { display: block; color: var(--ink); font-size: 15px; margin-bottom: 2px; }
.ask-links { display: flex; flex-wrap: wrap; gap: 8px; }
.ask-links a {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px 8px 12px; border-radius: 999px;
  background: var(--menu); border: 1px solid var(--line);
  color: var(--ink); text-decoration: none; font-size: 14px; font-weight: 600;
  transition: border-color .15s;
}
.ask-links a:hover { border-color: color-mix(in srgb, var(--accent) 50%, transparent); }
.ask-links a svg { flex: none; width: 18px; height: 18px; color: var(--accent); }
/* у кнопці — лише назва; адреса й нік видно в меню чату */
.ask-links small { display: none; }
dialog.book > .x { position: absolute; top: 18px; right: 18px; z-index: 3; background: var(--glass-strong); }

@media (max-width: 860px) {
  .spread { grid-template-columns: minmax(260px, 5fr) minmax(0, 7fr); }
  .leaf-head { padding: 34px 72px 0 32px; }
  .facts { margin: 22px 32px 0; }
  .desc { padding: 22px 32px 32px; }
  .ask { margin: 22px 32px 32px; }
  .stage { padding: 44px 40px 16px; }
  .buy { margin: 0 16px 16px 12px; }
}

/* ---------- Телефон: обидва вікна — аркуші знизу ---------- */
@media (max-width: 720px) {
  dialog, dialog.order, dialog.book {
    width: 100%; max-width: 100%;
    margin: auto 0 0;
    max-height: calc(100dvh - 10px);
    border-radius: 24px 24px 0 0; border-bottom: 0;
  }
  dialog[open] { animation: sheet .28s cubic-bezier(.2, .8, .2, 1); }
  dialog.order:has(#orderDone:not([hidden])) { width: 100%; }

  /* замовлення: книги згори, далі кроки, сума з кнопкою прилипає до низу */
  #orderBody:not([hidden]) { display: flex; flex-direction: column; }
  .order .dlg-head { order: 0; padding: 18px 14px 8px 20px; }
  .dlg h2 { font-size: 22px; }
  .order-sum { display: contents; }
  .order-lines { order: 1; margin: 4px 16px 0; padding: 12px 14px 4px; border: 1px solid var(--line); border-radius: 18px; background: var(--stage); }
  .lines { max-height: none; }
  .order-form { order: 2; padding: 22px 20px 24px; }
  .order-pay {
    order: 3; position: sticky; bottom: 0; z-index: 4;
    display: flex; flex-wrap: wrap; align-items: center; gap: 0 14px;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: var(--glass-strong);
    -webkit-backdrop-filter: blur(14px) saturate(1.2); backdrop-filter: blur(14px) saturate(1.2);
  }
  .order-pay .total { flex-direction: column; align-items: flex-start; gap: 3px; margin: 0; }
  .order-pay .total span { font-size: 12px; }
  .order-pay .total b { font-size: 22px; }
  .order-pay .msg.error { order: -1; flex-basis: 100%; margin: 0 0 10px; }
  .order-pay .btn { flex: 1; width: auto; }
  .form { grid-template-columns: 1fr; }
  .choices { grid-template-columns: 1fr 1fr; }
  .step + .step { margin-top: 24px; padding-top: 22px; }
  .done { padding: 40px 20px calc(28px + env(safe-area-inset-bottom)); }

  /* картка книги: одна колонка, що гортається; ціна з кнопкою — смугою знизу */
  dialog.book { height: auto; }
  .spread { display: block; height: auto; max-height: calc(100dvh - 10px); overflow-y: auto; overscroll-behavior: contain; }
  .spread::after { display: none; }
  .stage { height: min(50dvh, 420px); padding: 40px 52px 12px; }
  .has-cloth .stage { height: auto; padding: 36px 20px 8px; }
  .stage .cover.big { width: 150px; }
  .leaf-text { overflow: visible; }
  .leaf-head { padding: 22px 20px 0; }
  .book h2 { font-size: 25px; }
  .facts { margin: 20px 20px 0; grid-template-columns: 1fr 1fr; column-gap: 16px; }
  .desc { padding: 20px 20px 28px; font-size: 16px; }
  .ask { margin: 20px 20px 28px; }
  .buy {
    position: sticky; bottom: 0; z-index: 2;
    margin: 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    border: 0; border-top: 1px solid var(--line); border-radius: 0;
    -webkit-backdrop-filter: blur(14px) saturate(1.2); backdrop-filter: blur(14px) saturate(1.2);
    box-shadow: none;
    flex-wrap: nowrap;
  }
  .buy .price { font-size: 22px; }
  dialog.book > .x { top: 12px; right: 12px; }
}

/* Окремі сторінки (книга /book/15/, «Доставка й оплата», «Контакти»…): лише свій вміст —
   пошук і каталог живуть на головній, туди веде «Усі книги» і назва магазину в шапці.
   Каталог сторінка все одно завантажує: з нього свіжа ціна, наявність і кошик */
body[data-page] .toolbar,
body[data-page] main > .summary,
body[data-page] main > .list,
body[data-page] main > .state,
body[data-page] main > .pager,
body[data-page] main > .shelves,
body[data-page] main > .coll-intro { display: none; }
body[data-page] main { max-width: 980px; }
/* текстова сторінка вужча за книгу, але так само по центру, як шапка й підвал; «Усі книги» — над лівим краєм аркуша */
body[data-page]:not([data-book]) main { max-width: 752px; }

/* Текстова сторінка: скляний аркуш, текст тим самим книжковим шрифтом, що й опис книги.
   Ширина аркуша і є шириною рядка (~70 знаків) — без порожньої смуги праворуч */
.text-page {
  margin-top: 14px; padding: 38px 44px 34px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font: 400 16px/1.7 Literata, Georgia, serif;
}
.text-page h1 { font: 600 clamp(26px, 3.4vw, 36px)/1.15 Literata, Georgia, serif; letter-spacing: -.01em; margin: 0 0 14px; text-wrap: balance; }
.text-page h2 { font: 600 20px/1.3 Literata, Georgia, serif; margin: 28px 0 8px; }
.text-page h3 { font: 600 16.5px/1.35 Literata, Georgia, serif; margin: 20px 0 6px; }
.text-page p, .text-page ul, .text-page ol { margin: 0 0 .8em; text-wrap: pretty; }
.text-page > :last-child { margin-bottom: 0; }
.text-page ul, .text-page ol { padding-left: 1.3em; }
.text-page li + li { margin-top: .35em; }
.text-page a { color: var(--ink); text-underline-offset: 3px; }
.text-page b { font-weight: 600; }
/* ще не заповнене власником — видно одразу (збирач теж попереджає) */
.todo {
  padding: 1px 6px; border-radius: 4px;
  background: var(--accent-soft); color: var(--muted);
  outline: 1px dashed color-mix(in srgb, var(--muted) 60%, transparent);
  font: 500 14px/1.5 Onest, system-ui, sans-serif;
}
@media (max-width: 600px) {
  .text-page { padding: 26px 20px 24px; font-size: 15.5px; }
}
.back {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px 6px 10px;
  border: 1px solid var(--glass-edge); border-radius: 999px;
  box-shadow: 0 1px 0 var(--glass-edge) inset, 0 4px 14px rgba(0, 0, 0, .2);
  color: var(--ink); text-decoration: none; font-size: 14px; font-weight: 500;
}
.back:hover { background: var(--glass-strong); }
.back svg { color: var(--muted); }
/* Сторінка книги (/book/15/): та сама розгорнута книга, що й у картці, але на всю висоту тексту */
.book-page {
  position: relative;
  display: grid; grid-template-columns: minmax(280px, 5fr) minmax(0, 7fr);
  margin-top: 14px;
  border-radius: 26px;
  box-shadow: var(--shadow);
  /* clip, а не hidden: інакше ліва сторінка не прилипне */
  overflow: clip;
}
.book-page::after {
  content: ""; position: absolute; top: 0; bottom: 0; left: calc(5 / 12 * 100%); width: 60px;
  transform: translateX(-50%); pointer-events: none;
  background: linear-gradient(90deg, transparent, var(--spine) 44%, var(--spine-deep) 50%, var(--spine) 56%, transparent);
}
.page-side { background: var(--stage); }
/* книга з ціною тримається на виду, поки читаєте довгий опис */
.page-hold { position: sticky; top: 0; }
.page-photo { display: grid; place-items: center; padding: 48px 48px 24px; }
.page-photo img {
  display: block; max-width: 100%; max-height: 520px; object-fit: contain;
  border-radius: 3px;
  filter: drop-shadow(0 18px 30px rgba(0, 0, 0, .32));
}
.page-photo .cover.big { width: min(250px, 100%); }
.page-buy {
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  margin: 0 22px 22px 18px; padding: 14px 14px 14px 20px;
  border: 1px solid var(--glass-edge); border-radius: 20px;
  background: var(--glass-strong);
  box-shadow: 0 1px 0 var(--glass-edge) inset, 0 8px 24px rgba(0, 0, 0, .12);
}
.page-buy .price { font-size: 26px; }
.page-buy .was { justify-content: flex-start; font-size: 13.5px; }
.page-text { padding: 40px 48px 44px; min-width: 0; }
.page-text .facts { margin: 26px 0 0; }
.page-text .desc { padding: 26px 0 0; }
.page-text .ask { margin: 26px 0 0; }
.sold { color: var(--muted); font-weight: 500; }
@media (max-width: 720px) {
  .book-page { grid-template-columns: minmax(0, 1fr); }
  .book-page::after { display: none; }
  .page-hold { position: static; }
  .page-photo { padding: 32px 40px 18px; }
  .page-photo img { max-height: 54dvh; }
  .page-photo:has(.big) { padding: 32px 20px 16px; }
  .page-photo .cover.big { width: 150px; }
  .page-buy { margin: 0 12px 12px; }
  .page-text { padding: 24px 20px 26px; }
  .page-text .facts { grid-template-columns: 1fr 1fr; column-gap: 16px; }
}

/* Підвал прямо на фото; тінь тримає текст читабельним на білих сторінках.
   Посилання для покупців — помітніші, підпис автора — ледь видний */
footer.wrap {
  text-align: center; margin-top: 28px;
  color: rgba(255, 255, 255, .92);
  text-shadow: 0 0 6px #000, 0 0 12px rgba(0, 0, 0, .8);
}
.footer-nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 22px; font-size: 14px; font-weight: 500; }
.footer-nav a { color: inherit; text-decoration: none; padding: 4px 0; }
.footer-nav a:hover { text-decoration: underline; text-underline-offset: 4px; }
.footer-nav a[aria-current] { text-decoration: underline; text-underline-offset: 4px; }
.credit { margin: 10px 0 0; font-size: 12px; color: rgba(255, 255, 255, .7); }

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