.nb-wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 0 12px;
}

.amala-flip-embed {
  background: var(--espresso);
  color: #f5ede6;
  margin: 0 0 8px;
  border-radius: var(--radius);
  overflow: hidden;
}

.shelf-card {
  background: rgba(255, 255, 255, 0.78);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 22px 22px 18px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
}

.shelf-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 18px;
}

.page-content .shelf-card h2,
.shelf-card h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.8rem;
  color: var(--espresso);
  font-weight: 700;
}

.year-filter {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-family: var(--font-body);
  color: var(--espresso);
  white-space: nowrap;
}

.year-filter select {
  font-family: var(--font-body);
  font-size: 14px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--espresso);
}

.book[hidden] { display: none !important; }

.shelf-row {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 14px;
  align-items: end;
  min-height: 220px;
  padding: 8px 8px 0;
}

.book {
  position: relative;
  display: block;
  text-decoration: none;
  color: inherit;
  perspective: 700px;
}
.book-cover {
  position: relative;
}

.book-face {
  position: relative;
  height: 210px;
  border-radius: 3px 8px 8px 3px;
  overflow: hidden;
  background: var(--espresso);
  box-shadow:
    4px 8px 18px rgba(0, 0, 0, 0.22),
    inset -8px 0 12px rgba(0, 0, 0, 0.18);
  transform: rotateY(-8deg);
  transform-origin: left center;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.book:hover .book-face {
  transform: rotateY(0deg) translateY(-10px);
  box-shadow: 8px 16px 28px rgba(0, 0, 0, 0.28);
}

.book-face canvas,
.book-face img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.book-fallback {
  height: 100%;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  color: #f6efe6;
  background: linear-gradient(160deg, var(--espresso-soft), var(--espresso));
}
.book-fallback strong {
  font-family: var(--font-display);
  font-size: 16px;
  line-height: 1.3;
}
.book-fallback span {
  font-family: var(--font-body);
  font-size: 11px;
  opacity: 0.8;
}

.book-caption {
  margin-top: 8px;
  font-size: 12px;
  line-height: 1.35;
  font-family: var(--font-body);
  color: var(--espresso);
  text-align: center;
  min-height: 36px;
}

.book-actions {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px;
  background: rgba(47, 34, 28, 0.78);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.25s ease;
  border-radius: 3px 8px 8px 3px;
}
.book:hover .book-actions,
.book:focus-within .book-actions {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(-10px);
}
.book-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 128px;
  padding: 8px 12px;
  border-radius: 999px;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  color: #fff;
  background: var(--gold);
  text-decoration: none;
  line-height: 1.2;
}
.book-action:hover,
.book-action:focus {
  background: var(--gold-bright);
  color: var(--espresso);
}

.flip-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  background: var(--espresso);
  font-family: var(--font-body);
}
.flip-bar a, .flip-bar button {
  color: #fff;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 999px;
  padding: 8px 14px;
  text-decoration: none;
  cursor: pointer;
  font-size: 14px;
  font-family: var(--font-body);
}
.flip-bar h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  text-align: center;
  flex: 1;
  color: #fff;
}
.flip-stage {
  position: relative;
  min-height: calc(100vh - 168px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px 12px 8px;
  perspective: 2200px;
}
.spread {
  --page-w: 420px;
  --page-h: 580px;
  position: relative;
  width: calc(var(--page-w) * 2);
  height: var(--page-h);
  transform-style: preserve-3d;
}
.spread.cover-mode { width: var(--page-w); }
.spread.cover-mode .leaf.left { display: none; }
.leaf {
  position: absolute;
  top: 0;
  width: var(--page-w);
  height: var(--page-h);
  background: #fff;
  overflow: hidden;
  cursor: pointer;
  box-shadow: 0 16px 40px rgba(0,0,0,0.35);
}
.leaf.left { left: 0; border-radius: 6px 0 0 6px; }
.leaf.right { right: 0; border-radius: 0 6px 6px 0; }
.leaf canvas, .flip-face canvas {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  background: #fff;
}
.flipper {
  position: absolute;
  top: 0;
  right: 0;
  width: var(--page-w);
  height: var(--page-h);
  transform-origin: left center;
  transform-style: preserve-3d;
  pointer-events: none;
  opacity: 0;
  z-index: 5;
}
.flipper.flipping-forward,
.flipper.flipping-back { opacity: 1; }
.flipper.flipping-forward.turn {
  transition: transform 0.6s ease-in-out;
  transform: rotateY(-180deg);
}
.flipper.flipping-back {
  transform: rotateY(-180deg);
}
.flipper.flipping-back.turn {
  transition: transform 0.6s ease-in-out;
  transform: rotateY(0deg);
}
.flip-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  background: #fff;
  overflow: hidden;
  box-shadow: 0 16px 40px rgba(0,0,0,0.28);
}
.flip-face.back { transform: rotateY(180deg); }
.flip-nav { display: none; }
.flip-toolbar {
  position: sticky;
  bottom: 0;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px;
  padding: 8px 10px 12px;
  background: rgba(47, 34, 28, 0.94);
}
.flip-toolbar button,
.flip-toolbar a {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #fff;
  cursor: pointer;
  text-decoration: none;
}
.flip-toolbar button:hover,
.flip-toolbar a:hover,
.flip-toolbar button.copied {
  background: rgba(212, 176, 106, 0.22);
}
.flip-toolbar svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.tb-gap { width: 10px; }
.page-jump {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: #fff;
  font-size: 13px;
  margin: 0 6px;
  font-family: var(--font-body);
}
.page-jump input {
  width: 52px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.25);
  color: #fff;
  border-radius: 6px;
  padding: 4px 6px;
  text-align: center;
  font-family: var(--font-body);
}
.flip-stage.zoomed {
  overflow: hidden;
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.flip-stage.zoomed.is-panning,
.flip-stage.zoomed.is-panning .leaf {
  cursor: grabbing;
}
.flip-stage.zoomed .leaf {
  cursor: grab;
}
.thumbs {
  position: absolute;
  left: 12px;
  top: 12px;
  bottom: 12px;
  width: min(280px, 70vw);
  background: #241c18;
  border-radius: 12px;
  overflow: auto;
  z-index: 6;
  box-shadow: 0 12px 40px rgba(0,0,0,0.4);
}
.thumbs-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  color: #fff;
  font-size: 13px;
  position: sticky;
  top: 0;
  background: #241c18;
  font-family: var(--font-body);
}
.thumbs-head button {
  background: none;
  border: 0;
  color: #fff;
  font-size: 22px;
  cursor: pointer;
}
.thumbs-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  padding: 0 10px 12px;
}
.thumb {
  background: var(--espresso-soft);
  border: 0;
  border-radius: 6px;
  padding: 6px;
  cursor: pointer;
  color: #ddd;
  font-size: 11px;
  font-family: var(--font-body);
}
.thumb canvas { width: 100%; height: auto; display: block; background: #fff; }
.portrait .spread,
.portrait.cover-mode .spread {
  width: var(--page-w);
}
.portrait .leaf.left { display: none; }
.portrait .leaf.right { right: 0; border-radius: 6px; }

@media (max-width: 1100px) {
  .shelf-row { grid-template-columns: repeat(3, 1fr); gap: 16px; }
  .book-face { height: 200px; }
}
@media (max-width: 720px) {
  .shelf-card { padding: 16px 14px 12px; border-radius: 16px; }
  .page-content .shelf-card h2,
  .shelf-card h2 { font-size: 1.45rem; }
  .shelf-row { grid-template-columns: repeat(2, 1fr); gap: 12px; min-height: 0; padding: 0; }
  .book-face { height: 210px; }
  .book-caption { font-size: 11px; min-height: 32px; }
  .flip-bar { flex-wrap: wrap; padding: 10px 12px; }
  .flip-bar h1 { font-size: 16px; order: 3; flex: 1 1 100%; }
}
@media (max-width: 420px) {
  .shelf-row { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .book-face { height: 170px; }
}
