/* Клиентский каталог — экран и печать/PDF */

:root {
  --ink: #2a2620;
  --ink-muted: #6b6358;
  --cmyk-black: device-cmyk(0% 0% 0% 100%);
  --cmyk-white: device-cmyk(0% 0% 0% 0%);
  --cmyk-muted: device-cmyk(0% 0% 0% 55%);
  --paper: #e8e0d0;
  --paper-warm: #e85222;
  --card-fill: #e85222;
  --card-on-fill: #ffffff;
  --card-on-fill-muted: rgba(255, 255, 255, 0.88);
  --paper-deep: #c8beb0;
  --page-base: #c5b89e;
  --page-bg: #c5b89e;
  --page-gradient: none;
  --accent: #9a7b3c;
  --accent-light: #c9a962;
  --accent-dark: #6d5528;
  --border: #c7431a;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-display: Georgia, "Times New Roman", serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  background-color: var(--page-base);
  min-height: 100%;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background-color: var(--page-base);
  line-height: 1.45;
  margin: 0;
  padding: 0;
  min-height: 100%;
  width: 100%;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

/* Сплошный фон на каждой странице PDF */
.page-bg-layer,
.pdf-chrome-header {
  display: none;
}

.pdf-mode .page-bg-layer {
  display: block;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #c5b89e;
  z-index: 0;
  pointer-events: none;
}

.pdf-mode .pdf-chrome-header {
  display: block;
  position: fixed;
  left: 0;
  right: 0;
  top: 10mm;
  text-align: center;
  font-size: 8pt;
  color: #5c5348;
  z-index: 5;
  background: transparent;
}

body.format-a3.pdf-mode .pdf-chrome-header {
  font-size: 9pt;
}

.pdf-mode,
.pdf-mode html,
.pdf-mode body {
  margin: 0;
  padding: 0;
  background-color: #c5b89e;
}

.pdf-mode .catalog-content,
.pdf-mode .toc-page,
.pdf-mode .catalog-section,
.pdf-mode .catalog-footer {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 6mm 1.5cm 3.2cm;
  background-color: #c5b89e;
  box-sizing: border-box;
}

body.format-a3.pdf-mode .toc-page,
body.format-a3.pdf-mode .catalog-section,
body.format-a3.pdf-mode .catalog-footer {
  padding: 8mm 2cm 3.4cm;
}

.pdf-mode .section-page {
  padding: 0;
  background-color: #c5b89e;
}

/* Заголовок раздела в колонтитуле каждой страницы PDF (WeasyPrint string-set) */
.section-name-marker {
  display: none;
}

.pdf-mode .section-name-marker {
  display: block;
  height: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
  font-size: 0;
  line-height: 0;
  border: 0;
}

body.format-a4.pdf-mode .catalog-content {
  page: content;
  padding: 4mm 1.5cm 8mm;
  background-color: #fff;
}

body.format-a4.pdf-mode .toc-page {
  page: toc;
  background-color: #fff;
}

body.format-a4.pdf-mode .catalog-footer {
  background-color: #fff;
}

body.format-a4.pdf-mode,
body.format-a4.pdf-mode html,
body.format-a4.pdf-mode .page-bg-layer {
  background-color: #fff;
}

body.format-a4.pdf-mode .catalog-grid {
  grid-auto-rows: 82mm;
  align-items: center;
  justify-items: center;
}

body.format-a4.pdf-mode .catalog-item {
  position: relative;
  width: 50mm;
  height: 80.5mm;
  min-height: 0;
  max-height: 80.5mm;
  display: flex;
  flex-direction: column;
  border: 0.35mm solid var(--card-fill);
  border-radius: 3mm;
  overflow: hidden;
  background: var(--paper-warm);
  box-sizing: border-box;
}

body.format-a4.pdf-mode .item-image {
  flex: 0 0 66.7mm;
  width: 100%;
  height: 66.7mm;
  min-height: 66.7mm;
  max-height: 66.7mm;
  position: relative;
  background: #fff;
  overflow: hidden;
}

body.format-a4.pdf-mode .item-image img,
body.format-a4.pdf-mode .item-image .item-no-image {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  object-position: center center;
}

body.format-a4.pdf-mode .item-info {
  flex: 1 1 auto;
  width: 100%;
  min-height: 13.8mm;
  height: auto;
  max-height: none;
  padding: 1.2mm 2mm;
  background: var(--paper-warm);
  box-sizing: border-box;
  border-radius: 0 0 2.65mm 2.65mm;
}

body.format-a4.pdf-mode .item-title {
  font-size: 0.72rem;
  line-height: 1.2;
  max-height: 2.4em;
}

body.format-a4.pdf-mode .item-number {
  font-size: 0.68rem;
  margin: 0 0 0.5mm;
}

body.format-a4.pdf-mode .item-caption {
  font-size: 0.65rem;
  line-height: 1.15;
  margin: 0.4mm 0 0;
}

body.format-a4.pdf-mode .section-name-marker {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

/* PDF: весь текст в CMYK */
.pdf-mode,
.pdf-mode body {
  color: var(--cmyk-black);
}

.pdf-mode .toc-title,
.pdf-mode .toc-list a,
.pdf-mode .catalog-footer,
.pdf-mode .catalog-footer p {
  color: var(--cmyk-black);
}

.pdf-mode .toc-list a::after {
  color: var(--cmyk-black);
}

.pdf-mode .section-header h2 {
  color: var(--cmyk-black);
}

.pdf-mode .section-header {
  display: none;
}

.pdf-mode .cover-page {
  position: relative;
  z-index: 2;
  background: transparent;
}

/* Toolbar */
.catalog-toolbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1.5rem;
  background: var(--paper);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

.toolbar-brand {
  font-weight: 600;
  font-size: 1rem;
  color: var(--accent);
}

.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  font-family: inherit;
}

.btn-primary {
  background: var(--ink);
  color: #fff;
}

.btn-accent {
  background: var(--accent);
  color: #fff;
}

.btn-ghost {
  background: transparent;
  color: var(--ink-muted);
  border-color: var(--border);
}

.format-switch-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.format-switch-label {
  font-size: 0.8rem;
  color: var(--ink-muted);
  white-space: nowrap;
}

.format-switch {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(42, 38, 32, 0.08);
}

.btn-format {
  border-radius: 0;
  border: none;
  background: var(--paper-warm);
  color: var(--ink-muted);
  min-width: 3.2rem;
}

.btn-format.active {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  box-shadow: inset 0 0 0 1px var(--accent-dark);
}

.cover-format {
  display: inline-block;
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent-light);
  border: 1px solid rgba(201, 169, 98, 0.5);
  padding: 0.25rem 0.75rem;
  margin-bottom: 1rem;
}

/* Cover */
.cover-page {
  page: cover;
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2.5rem 2rem;
  page-break-after: always;
  overflow: hidden;
}

.pdf-mode .cover-page {
  min-height: 0;
  height: 297mm;
}

.cover-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 50% 20%, rgba(201, 169, 98, 0.18) 0%, transparent 60%),
    radial-gradient(ellipse 60% 50% at 80% 80%, rgba(154, 123, 60, 0.12) 0%, transparent 50%),
    linear-gradient(165deg, #12151a 0%, #1e2229 35%, #252018 70%, #14171c 100%);
}

.cover-frame {
  position: relative;
  z-index: 1;
  width: min(92%, 560px);
  padding: 3rem 2.5rem;
  border: 1px solid rgba(201, 169, 98, 0.45);
  background: rgba(10, 12, 16, 0.55);
  box-shadow:
    0 0 0 1px rgba(201, 169, 98, 0.15) inset,
    0 24px 64px rgba(0, 0, 0, 0.45);
}

.cover-corner {
  position: absolute;
  width: 28px;
  height: 28px;
  border-color: var(--accent-light);
  border-style: solid;
}

.cover-corner-tl { top: 12px; left: 12px; border-width: 2px 0 0 2px; }
.cover-corner-tr { top: 12px; right: 12px; border-width: 2px 2px 0 0; }
.cover-corner-bl { bottom: 12px; left: 12px; border-width: 0 0 2px 2px; }
.cover-corner-br { bottom: 12px; right: 12px; border-width: 0 2px 2px 0; }

.cover-inner {
  text-align: center;
  color: #fff;
}

.cover-ornament {
  font-size: 1.25rem;
  color: var(--accent-light);
  margin-bottom: 1rem;
  letter-spacing: 0.5em;
}

.cover-label {
  font-size: 0.7rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: rgba(201, 169, 98, 0.85);
  margin-bottom: 1.25rem;
}

.cover-title {
  font-family: var(--font-display);
  font-size: 3rem;
  font-weight: 400;
  letter-spacing: 0.06em;
  color: var(--accent-light);
  line-height: 1.1;
}

.cover-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin: 1.25rem 0 1rem;
}

.cover-divider::before,
.cover-divider::after {
  content: "";
  flex: 1;
  max-width: 80px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent-light), transparent);
}

.cover-divider span {
  width: 6px;
  height: 6px;
  background: var(--accent-light);
  transform: rotate(45deg);
}

.cover-subtitle {
  font-size: 1.35rem;
  font-weight: 300;
  letter-spacing: 0.04em;
  margin-bottom: 0.6rem;
}

.cover-desc {
  font-size: 0.95rem;
  color: rgba(255, 255, 255, 0.65);
  margin-bottom: 2rem;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}

.cover-filter {
  font-size: 1rem;
  color: var(--accent-light);
  margin-bottom: 1.5rem;
}

.cover-stats {
  display: inline-flex;
  align-items: center;
  gap: 2rem;
  padding: 1rem 2rem;
  margin-bottom: 2rem;
  border: 1px solid rgba(201, 169, 98, 0.3);
  background: rgba(0, 0, 0, 0.2);
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-sep {
  width: 1px;
  height: 40px;
  background: rgba(201, 169, 98, 0.35);
}

.stat-value {
  font-size: 2.2rem;
  font-weight: 300;
  color: var(--accent-light);
  line-height: 1;
  font-family: var(--font-display);
}

.stat-label {
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.5);
  margin-top: 0.35rem;
}

.cover-date,
.cover-updated {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.5);
}

.cover-updated {
  margin-top: 0.3rem;
}

.cover-site {
  margin-top: 1rem;
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  color: var(--accent-light);
}

/* Table of contents */
.toc-page {
  page: toc;
  background-color: #c5b89e;
  padding: 2.2cm 1.5cm 2.8cm;
  max-width: none;
  margin: 0;
  page-break-after: always;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

body.format-a3 .toc-page {
  padding: 2.2cm 2cm 3cm;
}

.toc-title {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 400;
  margin-bottom: 1.5rem;
  padding-bottom: 0.6rem;
  border-bottom: 2px solid var(--accent);
  color: var(--ink);
}

.toc-list {
  list-style: none;
  columns: 2;
  column-gap: 2.5rem;
}

.toc-list li {
  break-inside: avoid;
  page-break-inside: avoid;
  margin-bottom: 0.45rem;
}

.toc-list a {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--ink);
  padding: 0.25rem 0;
  font-size: 0.92rem;
  border-bottom: 1px dotted var(--border);
}

.toc-name {
  flex: 0 1 auto;
  font-weight: 500;
}

.toc-list a::before {
  content: "";
  flex: 1 1 auto;
  border-bottom: 1px dotted var(--border);
  margin: 0 0.25rem;
  min-width: 12px;
  transform: translateY(-0.2em);
}

.toc-page-num {
  flex: 0 0 auto;
  font-weight: 600;
  color: var(--accent-dark);
  min-width: 1.5rem;
  text-align: right;
}

/* PDF: номера страниц через WeasyPrint */
.pdf-mode .toc-list a::before {
  display: none;
}

.pdf-mode .toc-page-num {
  display: none;
}

.pdf-mode .toc-list a {
  display: block;
}

.pdf-mode .toc-list a::after {
  content: leader(dotted) target-counter(attr(href), page);
  float: right;
  margin-left: 0.5rem;
  color: var(--accent-dark);
  font-weight: 600;
}

/* Content */
.catalog-content {
  background: transparent;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 0 3rem;
}

.pdf-mode .catalog-content {
  max-width: none;
  margin: 0;
  padding: 0;
}

.catalog-section {
  page: content;
  margin: 0;
  page-break-before: always;
  background-color: #c5b89e;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.section-page {
  padding: 2rem 1.5rem 2.8rem;
  box-sizing: border-box;
}

.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
  padding-bottom: 0.6rem;
  border-bottom: 2px solid var(--accent);
}

.section-header h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 400;
  color: var(--ink);
  width: 100%;
}

.catalog-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 3mm;
  align-items: start;
  justify-items: stretch;
}

.catalog-item {
  border: 1px solid var(--border);
  border-radius: 3.5mm;
  overflow: hidden;
  background: var(--paper-warm);
  break-inside: avoid;
  page-break-inside: avoid;
  width: 100%;
  min-width: 0;
  margin: 0;
  box-sizing: border-box;
}

.pdf-mode .catalog-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 3mm;
  align-items: start;
  justify-items: stretch;
  grid-auto-rows: 99mm;
}

.pdf-mode .catalog-item {
  height: 99mm;
  min-height: 99mm;
  max-height: 99mm;
}

.pdf-mode .catalog-item {
  display: block;
  align-self: stretch;
  box-shadow: none;
  overflow: hidden;
}

.pdf-mode .item-image {
  display: block;
  position: relative;
  width: 100%;
  height: 77mm;
  padding-bottom: 0;
  flex: none;
  background: var(--paper-warm);
  overflow: hidden;
  aspect-ratio: auto;
}

.pdf-mode .item-image img,
.pdf-mode .item-image .item-no-image {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  object-fit: fill;
  object-position: center center;
  display: block;
  background: transparent;
}

.pdf-mode .item-info {
  display: block;
  height: 22mm;
  min-height: 22mm;
  max-height: 22mm;
  padding: 2.5mm 3mm 2.5mm;
  overflow: hidden;
  box-sizing: border-box;
  background: var(--paper-warm);
}

.pdf-mode .item-number {
  margin: 0 0 0.8mm;
  line-height: 1.2;
  color: var(--cmyk-white);
}

.pdf-mode .item-title {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.25;
  max-height: 2.5em;
  overflow: hidden;
  color: var(--cmyk-white);
}

.pdf-mode .item-category {
  margin: 0.8mm 0 0;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--cmyk-white);
}

.pdf-mode .item-caption {
  margin: 0.8mm 0 0;
  line-height: 1.25;
  white-space: pre-line;
  color: var(--cmyk-white);
}

body.format-a3.pdf-mode .catalog-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 3.5mm;
  grid-auto-rows: 110mm;
}

body.format-a3.pdf-mode .catalog-item {
  height: 110mm;
  min-height: 110mm;
  max-height: 110mm;
}

body.format-a3.pdf-mode .item-image {
  height: 86mm;
}

body.format-a3.pdf-mode .item-info {
  height: 24mm;
  min-height: 24mm;
  max-height: 24mm;
  padding: 3mm 3.5mm 2.5mm;
}

body.format-a3.pdf-mode .item-title {
  font-size: 0.88rem;
  max-height: 2.6em;
}

.screen-mode .catalog-item {
  box-shadow: 0 2px 8px rgba(42, 38, 32, 0.06);
  display: flex;
  flex-direction: column;
}

.screen-mode .catalog-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

body.format-a3.screen-mode .catalog-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.item-image {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  background: var(--paper-warm);
  overflow: hidden;
  flex: 0 0 auto;
}

.item-image img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  object-position: center center;
  display: block;
}

.item-info {
  flex: 0 0 auto;
  min-height: 4.2rem;
  padding: 0.6rem 0.75rem 0.75rem;
  background: var(--paper-warm);
  box-sizing: border-box;
}

.item-number {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--card-on-fill-muted);
}

.item-title {
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--card-on-fill);
}

.item-category {
  font-size: 0.72rem;
  color: var(--card-on-fill-muted);
}

.item-caption {
  font-size: 0.72rem;
  color: var(--card-on-fill-muted);
  line-height: 1.35;
  margin: 0;
  white-space: pre-line;
}

.catalog-footer {
  background-color: #c5b89e;
  border-top: 1px solid var(--border);
  text-align: center;
  padding: 1.5rem;
  font-size: 0.8rem;
  color: var(--ink-muted);
}

.screen-mode html,
.screen-mode body {
  background-color: #c5b89e !important;
}

.screen-mode .toc-page,
.screen-mode .catalog-section,
.screen-mode .catalog-footer {
  background-color: #c5b89e;
  width: 100%;
  max-width: none;
  margin: 0;
  box-shadow: none;
}

.screen-mode .catalog-content {
  max-width: none;
  width: 100%;
  padding: 0;
}

/* Страницы PDF: margin 0, без колонтитулов в полях (они давали белую рамку) */
@page cover {
  size: A4 portrait;
  margin: 0;
  background-color: #14171c;
}

@page toc {
  size: A4 portrait;
  margin: 8mm 0 14mm 0;
  background-color: #fff;
  @bottom-center {
    content: "стр. " counter(page);
    text-align: center;
    font-size: 8pt;
    color: device-cmyk(0% 0% 0% 100%);
    padding-bottom: 3mm;
  }
}

@page content {
  size: A4 portrait;
  margin: 8mm 0 14mm 0;
  background-color: #fff;
  @bottom-center {
    content: "стр. " counter(page);
    text-align: center;
    font-size: 8pt;
    color: device-cmyk(0% 0% 0% 100%);
    padding-bottom: 3mm;
  }
}

@media print {
  html,
  body {
    background-color: #c5b89e !important;
  }

  body.format-a4.pdf-mode,
  body.format-a4.pdf-mode html {
    background-color: #fff !important;
  }

  .page-bg-layer {
    display: block;
    position: fixed;
    inset: 0;
    background-color: #c5b89e !important;
    z-index: 0;
    pointer-events: none;
  }

  body.format-a4.pdf-mode .page-bg-layer {
    background-color: #fff !important;
  }

  .pdf-chrome-header {
    display: none !important;
  }

  .catalog-content,
  .toc-page,
  .catalog-section,
  .catalog-footer,
  .section-page {
    position: relative;
    z-index: 1;
    background-color: #c5b89e !important;
  }

  body.format-a4.pdf-mode .catalog-content,
  body.format-a4.pdf-mode .toc-page,
  body.format-a4.pdf-mode .catalog-footer {
    background-color: #fff !important;
  }

  body.format-a4.pdf-mode .catalog-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 3mm;
    align-items: center;
    justify-items: center;
    grid-auto-rows: 82mm;
  }

  body.format-a4.pdf-mode .catalog-item {
    box-shadow: none;
    display: flex;
    flex-direction: column;
    position: relative;
    width: 50mm;
    height: 80.5mm;
    min-height: 0;
    max-height: 80.5mm;
    overflow: hidden;
    border: 0.35mm solid var(--card-fill);
    border-radius: 3mm;
    background: var(--paper-warm);
    box-sizing: border-box;
  }

  body.format-a4.pdf-mode .item-image {
    display: block;
    position: relative;
    width: 100%;
    height: 66.7mm;
    min-height: 66.7mm;
    max-height: 66.7mm;
    flex: 0 0 66.7mm;
    background: #fff;
    overflow: hidden;
  }

  body.format-a4.pdf-mode .item-image img,
  body.format-a4.pdf-mode .item-image .item-no-image {
    object-fit: fill;
    object-position: center center;
  }

  body.format-a4.pdf-mode .item-info {
    flex: 1 1 auto;
    min-height: 13.8mm;
    height: auto;
    max-height: none;
    overflow: hidden;
    background: var(--paper-warm);
    border-radius: 0 0 2.65mm 2.65mm;
  }

  body.format-a4.pdf-mode .item-title {
    max-height: 2.4em;
    overflow: hidden;
  }

  .catalog-item {
    box-shadow: none;
    display: block;
    width: 100%;
    min-width: 0;
    height: 99mm;
    min-height: 99mm;
    max-height: 99mm;
    overflow: hidden;
  }

  .catalog-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 3mm;
    justify-items: stretch;
    grid-auto-rows: 99mm;
  }

  .item-image {
    display: block;
    position: relative;
    width: 100%;
    height: 77mm;
    background: var(--paper-warm);
    overflow: hidden;
  }

  .item-image img,
  .item-image .item-no-image {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    object-fit: fill;
    object-position: center center;
  }

  .item-info {
    height: 22mm;
    min-height: 22mm;
    max-height: 22mm;
    overflow: hidden;
    background: var(--paper-warm);
  }

  .item-title {
    max-height: 2.5em;
    overflow: hidden;
  }

  .no-print, .catalog-toolbar { display: none !important; }
  .cover-page, .toc-page, .catalog-section { box-shadow: none; margin: 0; max-width: none; }
  .catalog-content { max-width: none; padding: 0; }
  .section-page { padding: 2cm 1.5cm 3.2cm; }

  .toc-list a::before { display: none; }
  .toc-page-num { display: none; }
  .toc-list a {
    display: block;
    border-bottom: none;
  }
  .toc-list a::after {
    content: leader(dotted) target-counter(attr(href), page);
    float: right;
    font-weight: 600;
    color: var(--accent-dark);
  }
}

@media (max-width: 900px) {
  .catalog-grid { grid-template-columns: repeat(2, 1fr); }
  .toc-list { columns: 1; }
}

@media (max-width: 520px) {
  .catalog-grid { grid-template-columns: 1fr; }
  .cover-title { font-size: 2.2rem; }
  .cover-frame { padding: 2rem 1.5rem; }
}

/* ——— Формат A3 ——— */
body.format-a3.screen-mode .catalog-content {
  max-width: none;
}

body.format-a3.pdf-mode .cover-page {
  height: 420mm;
}

body.format-a3 .catalog-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 3.5mm;
}

body.format-a3 .toc-list {
  columns: 3;
  column-gap: 2rem;
}

body.format-a3 .cover-title {
  font-size: 3.4rem;
}

body.format-a3 .cover-frame {
  width: min(88%, 640px);
}

body.format-a3 .item-title {
  font-size: 0.92rem;
}

body.format-a3 .section-header h2 {
  font-size: 1.75rem;
}

body.format-a3 .cover-page { page: cover-a3; }
body.format-a3 .toc-page { page: toc-a3; }
body.format-a3 .catalog-section { page: content-a3; }

@page cover-a3 {
  size: A3 portrait;
  margin: 0;
  background-color: #14171c;
}

@page toc-a3 {
  size: A3 portrait;
  margin: 8mm 0 16mm 0;
  background-color: #c5b89e;
  @bottom-center {
    content: "стр. " counter(page);
    text-align: center;
    font-size: 8pt;
    color: device-cmyk(0% 0% 0% 100%);
    padding-bottom: 3mm;
  }
}

@page content-a3 {
  size: A3 portrait;
  margin: 8mm 0 16mm 0;
  background-color: #c5b89e;
  @bottom-center {
    content: "стр. " counter(page);
    text-align: center;
    font-size: 8pt;
    color: device-cmyk(0% 0% 0% 100%);
    padding-bottom: 3mm;
  }
}

@media (max-width: 1100px) {
  body.format-a3 .catalog-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  body.format-a3 .toc-list {
    columns: 2;
  }
}
