:root {
  --catalog-green: #20382f;
  --catalog-green-soft: #2f5145;
  --catalog-paper: #f4efe6;
  --catalog-cream: #fbf7ef;
  --catalog-gold: #b99a61;
  --catalog-ink: #203027;
  --catalog-muted: #766b5c;
  --catalog-shadow: rgba(10, 20, 16, 0.24);
  --catalog-zoom: 1;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  min-height: 100%;
}

body.catalog-page {
  margin: 0;
  background: var(--catalog-paper);
  color: var(--catalog-ink);
  font-family: Arial, sans-serif;
}

.catalog-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background:
    radial-gradient(circle at 20% 0%, rgba(185, 154, 97, 0.16), transparent 32rem),
    linear-gradient(135deg, #f9f4eb 0%, #eee5d6 100%);
}

.catalog-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px clamp(16px, 4vw, 42px);
  background: rgba(251, 247, 239, 0.92);
  border-bottom: 1px solid rgba(32, 56, 47, 0.12);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.catalog-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  color: var(--catalog-green);
  text-decoration: none;
}

.catalog-brand img {
  width: 98px;
  height: 52px;
  object-fit: contain;
  background: rgba(255, 255, 255, 0.68);
  padding: 5px 8px;
}

.catalog-brand strong {
  display: block;
  font-size: 18px;
  line-height: 1.1;
}

.catalog-brand span {
  display: block;
  margin-top: 3px;
  color: var(--catalog-muted);
  font-size: 13px;
}

.catalog-links {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.catalog-link,
.catalog-icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 1px solid rgba(32, 56, 47, 0.2);
  background: rgba(255, 255, 255, 0.58);
  color: var(--catalog-green);
  text-decoration: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  padding: 0 13px;
  cursor: pointer;
}

.catalog-link.is-active {
  background: var(--catalog-green);
  color: #fff;
}

.catalog-stage {
  min-width: 0;
  min-height: 0;
  display: grid;
  align-items: center;
  justify-items: center;
  padding: clamp(16px, 4vw, 36px);
  overflow: auto;
}

.book-zoom {
  width: 100%;
  height: 100%;
  transform: scale(var(--catalog-zoom));
  transform-origin: center center;
  transition: transform 180ms ease;
  will-change: transform;
}

.flipbook {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 24px 40px var(--catalog-shadow));
}

.catalog-loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--catalog-green);
  font-size: 16px;
  font-weight: 700;
  pointer-events: none;
}

.catalog-stage-inner {
  position: relative;
  width: min(96vw, 1380px, calc(141.4vh - 297px));
  aspect-ratio: 1123 / 794;
  height: auto;
  min-height: 360px;
  max-height: 780px;
}

.catalog-toolbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 16px;
  align-items: center;
  padding: 14px clamp(16px, 4vw, 42px) 20px;
  background: rgba(251, 247, 239, 0.94);
  border-top: 1px solid rgba(32, 56, 47, 0.12);
  backdrop-filter: blur(12px);
  position: sticky;
  bottom: 0;
  z-index: 20;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toolbar-group.is-end {
  justify-content: flex-end;
}

.toolbar-group.is-center {
  justify-content: center;
}

.catalog-icon-button {
  width: 42px;
  padding: 0;
}

.catalog-icon-button svg {
  width: 19px;
  height: 19px;
  stroke-width: 2;
}

.catalog-icon-button:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.page-status {
  min-width: 120px;
  text-align: center;
  color: var(--catalog-green);
  font-weight: 800;
  font-size: 14px;
}

.catalog-hint {
  color: var(--catalog-muted);
  font-size: 13px;
  white-space: nowrap;
}

.catalog-shell:fullscreen {
  background: #171f1b;
}

.catalog-shell:fullscreen .catalog-topbar,
.catalog-shell:fullscreen .catalog-toolbar {
  background: rgba(20, 30, 26, 0.86);
  border-color: rgba(255, 255, 255, 0.12);
}

.catalog-shell:fullscreen .catalog-brand,
.catalog-shell:fullscreen .catalog-link,
.catalog-shell:fullscreen .catalog-icon-button,
.catalog-shell:fullscreen .page-status {
  color: #f5ead8;
}

.catalog-shell:fullscreen .catalog-link,
.catalog-shell:fullscreen .catalog-icon-button {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.catalog-shell:fullscreen .catalog-hint,
.catalog-shell:fullscreen .catalog-brand span {
  color: rgba(245, 234, 216, 0.72);
}

[dir="rtl"] .catalog-links {
  justify-content: flex-start;
}

[dir="rtl"] .catalog-brand {
  text-align: right;
}

[dir="rtl"] .page-status {
  direction: rtl;
}

@media (max-width: 900px) {
  .catalog-stage {
    align-items: start;
  }

  .catalog-topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .catalog-links {
    justify-content: flex-start;
  }

  .catalog-toolbar {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .toolbar-group,
  .toolbar-group.is-end,
  .toolbar-group.is-center {
    justify-content: center;
  }

  .catalog-hint {
    display: none;
  }

  .flipbook {
    min-height: 0;
  }

  .catalog-stage-inner {
    width: min(96vw, 760px, 101.8vh);
    aspect-ratio: 1123 / 794;
    height: auto;
    min-height: 260px;
  }
}

@media (max-width: 560px) {
  .catalog-stage {
    padding: 12px 10px 16px;
  }

  .catalog-brand img {
    width: 78px;
    height: 42px;
  }

  .catalog-brand strong {
    font-size: 16px;
  }

  .catalog-link {
    min-height: 34px;
    font-size: 13px;
    padding: 0 10px;
  }

  .catalog-icon-button {
    width: 38px;
    min-height: 38px;
  }

  .page-status {
    min-width: 104px;
  }
}
