.bwf-flipbook-wrapper *, .bwf-flipbook-wrapper *::before, .bwf-flipbook-wrapper *::after { box-sizing: border-box; }

  :root {
    --gold: #c9a84c;
    --gold-dim: #8a6e2f;
    --paper: #faf7f2;
    --dark: #0e0c09;
  }

  .bwf-flipbook-wrapper {
    background: radial-gradient(ellipse at 50% 40%, #1c1710 0%, #080807 100%);
    font-family: 'Georgia', serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 10px 20px;
    color: #ddd;
    user-select: none;
  }

  header {
    text-align: center;
    margin-bottom: 20px;
  }
  header h1 {
    font-size: clamp(1.1rem, 2.5vw, 1.7rem);
    color: var(--gold);
    letter-spacing: 0.14em;
    font-weight: normal;
  }
  header p {
    font-size: 0.68rem;
    color: #666;
    letter-spacing: 0.32em;
    text-transform: uppercase;
    margin-top: 5px;
  }

  /* ══════════════════════════════
     BOOK
  ══════════════════════════════ */
  .scene {
    perspective: 3000px;
    width: min(96vw, 860px);
  }

  /* Landscape ratio: two portrait halves side by side → 2:1.415 */
  .book-wrap {
    position: relative;
    padding-bottom: 55%;   /* reduced height so controls stay on screen */
  }

  .book {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: stretch;
    border-radius: 3px;
    box-shadow:
      0 50px 100px rgba(0,0,0,0.9),
      0  0   0 1px rgba(255,255,255,0.04),
      inset 0 0 60px rgba(0,0,0,0.2);
  }

  /* ── Spine ── */
  .spine {
    width: 16px;
    flex-shrink: 0;
    background: linear-gradient(to right,
      #060504 0%, #2a2010 30%, #c9a84c 48%, #c9a84c 52%, #2a2010 70%, #060504 100%);
    border-radius: 4px 0 0 4px;
    position: relative;
    z-index: 30;
    box-shadow: 2px 0 12px rgba(0,0,0,0.8), -1px 0 6px rgba(0,0,0,0.5);
  }

  /* ── Left page ── */
  .left-page {
    flex: 1;
    position: relative;
    overflow: hidden;
    border-radius: 4px 0 0 4px;
    border-top: 1px solid #2a2010;
    border-left: 1px solid #2a2010;
    border-bottom: 1px solid #2a2010;
    background: var(--paper);
  }
  /* right-edge shadow on left page */
  .left-page::after {
    content: '';
    position: absolute;
    top: 0; right: 0; bottom: 0;
    width: 32px;
    background: linear-gradient(to left, rgba(0,0,0,0.28), transparent);
    z-index: 5;
    pointer-events: none;
  }

  /* ── Right page ── */
  .right-page {
    flex: 1;
    position: relative;
    overflow: hidden;
    border-radius: 0 4px 4px 0;
    border-top: 1px solid #2a2010;
    border-right: 1px solid #2a2010;
    border-bottom: 1px solid #2a2010;
    background: var(--paper);
  }
  /* left-edge shadow on right page */
  .right-page::before {
    content: '';
    position: absolute;
    top: 0; left: 0; bottom: 0;
    width: 32px;
    background: linear-gradient(to right, rgba(0,0,0,0.28), transparent);
    z-index: 5;
    pointer-events: none;
  }

  .left-page img,
  .right-page img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    display: block;
    background: var(--paper);
  }

  /* Page number */
  .pg-num {
    position: absolute;
    bottom: 8px;
    font-size: 0.65rem;
    color: rgba(0,0,0,0.35);
    letter-spacing: 0.12em;
    z-index: 10;
    pointer-events: none;
  }
  .left-page  .pg-num { right: 36px; }
  .right-page .pg-num { left:  36px; }

  /* ══════════════════════════════
     FLIP OVERLAY  (3-D page curl)
     Sits over the right half while turning forward,
     over the left half while turning backward.
  ══════════════════════════════ */
  .flip-container {
    position: absolute;
    top: 0; bottom: 0;
    width: 50%;          /* covers one page at a time */
    z-index: 20;
    pointer-events: none;
    display: none;
    /* perspective applied from parent .book-wrap via .scene */
  }
  .flip-container.forward { left: 50%; transform-origin: left center; }
  .flip-container.backward { left: 0;  transform-origin: right center; }

  .flip-leaf {
    position: absolute;
    inset: 0;
    transform-style: preserve-3d;
    transform-origin: inherit;
  }

  .flip-face {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    overflow: hidden;
    background: var(--paper);
  }
  .flip-face.back { transform: rotateY(180deg); }
  .flip-face img {
    width: 100%; height: 100%;
    object-fit: contain;
    object-position: center;
  }

  /* Shine highlight that sweeps across during flip */
  .flip-face::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(105deg, transparent 40%, rgba(255,255,255,0.18) 50%, transparent 60%);
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
  }

  /* CSS animations */
  @keyframes pageFlipForward {
    0%   { transform: rotateY(0deg);    }
    100% { transform: rotateY(-180deg); }
  }
  @keyframes pageFlipBackward {
    0%   { transform: rotateY(0deg);   }
    100% { transform: rotateY(180deg); }
  }

  /* ══════════════════════════════
     COVER  (only panel 0 shown alone)
  ══════════════════════════════ */
  .cover-mode .left-page  { display: none; }
  .cover-mode .spine      { border-radius: 4px 0 0 4px; }

  /* ══════════════════════════════
     CONTROLS
  ══════════════════════════════ */
  .controls {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-top: 18px;
  }
  .btn {
    background: transparent;
    border: 1px solid var(--gold);
    color: var(--gold);
    font-size: 0.74rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    padding: 9px 26px;
    cursor: pointer;
    border-radius: 2px;
    transition: background 0.2s, color 0.2s;
    font-family: Georgia, serif;
  }
  .btn:hover:not(:disabled) { background: var(--gold); color: #111; }
  .btn:disabled { opacity: 0.18; cursor: default; }

  .counter {
    font-size: 0.78rem;
    color: #888;
    letter-spacing: 0.15em;
    min-width: 110px;
    text-align: center;
  }

  /* ══════════════════════════════
     THUMBNAILS
  ══════════════════════════════ */
  .thumbs {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 14px 4px 4px;
    width: min(96vw, 1100px);
    scrollbar-width: thin;
    scrollbar-color: var(--gold) #1a1a1a;
    margin-top: 6px;
  }
  .thumbs::-webkit-scrollbar { height: 3px; }
  .thumbs::-webkit-scrollbar-thumb { background: var(--gold); }

  .thumb {
    flex-shrink: 0;
    width: 56px;
    height: 80px;
    border: 1px solid #333;
    border-radius: 2px;
    overflow: hidden;
    cursor: pointer;
    opacity: 0.4;
    transition: opacity 0.18s, border-color 0.18s;
    position: relative;
  }
  .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
  .thumb span {
    position: absolute;
    bottom: 2px; left: 0; right: 0;
    text-align: center;
    font-size: 9px;
    color: rgba(255,255,255,0.7);
    text-shadow: 0 1px 2px rgba(0,0,0,0.8);
  }
  .thumb.active, .thumb:hover { opacity: 1; border-color: var(--gold); }
  .thumb-pair { display: flex; gap: 1px; flex-shrink: 0; }
  .thumb-pair-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
  }
  .thumb-pair-label {
    font-size: 8px;
    color: #555;
    letter-spacing: 0.1em;
  }

  .hint {
    font-size: 0.62rem;
    color: #444;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    margin-top: 10px;
  }