html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: Arial, Helvetica, sans-serif;
    background: #f4f4f4;
  }

  /* ---- Page behind the modal (your own content goes here) ---- */
  #pageContent {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 16px;
  }

  #openFlipbookBtn {
    background: #2d6cdf;
    color: #fff;
    border: none;
    padding: 14px 28px;
    font-size: 16px;
    border-radius: 6px;
    cursor: pointer;
  }

  #openFlipbookBtn:hover { background: #2559b8; }

  /* ---- Modal ---- */
  #flipbookModal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    z-index: 2000;
  }

  #modalInner {
    position: absolute;
     top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 60vw;
  height: 860px;
    /* top: 30px;
    left: 30px;
    right: 30px;
    bottom: 30px; */
    background: #2b2b2b;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  }

  #modalCloseBtn {
    position: absolute;
    top: 10px;
    right: 14px;
    z-index: 100;
    background: transparent;
    color: #eee;
    border: none;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
  }

  #modalCloseBtn:hover { color: #fff; }

  #toolbar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50px;
    background: #1c1c1c;
    color: #eee;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    z-index: 50;
    box-shadow: 0 2px 6px rgba(0,0,0,0.4);
  }

  #toolbar button.navBtn {
    background: #444;
    color: #eee;
    border: none;
    padding: 8px 14px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
  }

  #toolbar button.navBtn:hover:not(:disabled) { background: #666; }
  #toolbar button.navBtn:disabled { opacity: 0.4; cursor: not-allowed; }

  #pageInfo {
    font-size: 14px;
    min-width: 90px;
    text-align: center;
  }

  #stage {
    position: absolute;
    top: 50px;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  #loading {
    color: #ccc;
    font-size: 16px;
    text-align: center;
  }

  .spinner {
    margin: 0 auto 12px auto;
    width: 34px;
    height: 34px;
    border: 4px solid #555;
    border-top-color: #ccc;
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
  }

  @keyframes spin { to { transform: rotate(360deg); } }

  #book { display: none; }

  #book canvas, #book > div {
    box-shadow: 0 10px 40px rgba(0,0,0,0.6);
  }
