/* 翻頁電子書(style/flipbook.js)：雙頁攤開 + 折角翻頁，容器寬度不到640px自動變單頁 */
.flipbook { position: relative; margin: 0 auto; width: 100%; box-sizing: border-box; }
.flipbook-stage-wrap { position: relative; margin: -28px 0 -14px; padding: 28px 0 14px; }
.flipbook-stage-in { position: relative; display: flex; align-items: center; justify-content: center; }
.flipbook-stage-wrap.is-zoomed { overflow: hidden; touch-action: none; cursor: grab; }
.flipbook-viewport { position: relative; flex: 1 1 auto; min-width: 0; display: flex; justify-content: center; }
.flipbook-viewport.is-zoomed { cursor: grab; touch-action: none; }
.flipbook-zoom { width: 100%; transform-origin: center center; }
.flipbook-stage { position: relative; width: 100%; transition: transform .8s cubic-bezier(.4,.1,.2,1); outline: none; user-select: none; -webkit-user-select: none; cursor: pointer; touch-action: pan-y; }
.flipbook-viewport.is-zoomed .flipbook-stage { cursor: grab; transition: none; }
.flipbook-page { position: absolute; top: 0; width: 50%; height: 100%; background: #fff; overflow: hidden; box-shadow: 0 6px 18px rgba(0,0,0,var(--fb-shadow, .18)); }
.flipbook-page img { display: block; width: 100%; height: 100%; object-fit: fill; pointer-events: none; }
.flipbook-page-empty { background: transparent; box-shadow: none; }
.flipbook-page-left::after, .flipbook-page-right::after { content: ""; position: absolute; top: 0; bottom: 0; width: 16%; pointer-events: none; }
.flipbook-page-left::after { right: 0; background: linear-gradient(to left, rgba(0,0,0,calc(var(--fb-spine, 1) * .5)) 0, rgba(0,0,0,calc(var(--fb-spine, 1) * .28)) 3%, rgba(0,0,0,calc(var(--fb-spine, 1) * .12)) 12%, rgba(0,0,0,calc(var(--fb-spine, 1) * .04)) 40%, rgba(0,0,0,0) 100%), linear-gradient(to left, rgba(255,255,255,0) 0, rgba(255,255,255,0) calc(var(--fb-hl-p, 80%) - var(--fb-hl-s, 20%)), rgba(255,255,255,var(--fb-spine-hl, .22)) var(--fb-hl-p, 80%), rgba(255,255,255,0) calc(var(--fb-hl-p, 80%) + var(--fb-hl-s, 20%)), rgba(255,255,255,0) 100%); }
.flipbook-page-right::after { left: 0; background: linear-gradient(to right, rgba(0,0,0,calc(var(--fb-spine, 1) * .5)) 0, rgba(0,0,0,calc(var(--fb-spine, 1) * .28)) 3%, rgba(0,0,0,calc(var(--fb-spine, 1) * .12)) 12%, rgba(0,0,0,calc(var(--fb-spine, 1) * .04)) 40%, rgba(0,0,0,0) 100%), linear-gradient(to right, rgba(255,255,255,0) 0, rgba(255,255,255,0) calc(var(--fb-hl-p, 80%) - var(--fb-hl-s, 20%)), rgba(255,255,255,var(--fb-spine-hl, .22)) var(--fb-hl-p, 80%), rgba(255,255,255,0) calc(var(--fb-hl-p, 80%) + var(--fb-hl-s, 20%)), rgba(255,255,255,0) 100%); }
.flipbook-page-empty::after { display: none; }
.flipbook-fold { position: absolute; inset: 0; overflow: hidden; z-index: 5; pointer-events: none; }
.flipbook-fold-inner { position: absolute; left: 0; right: 0; bottom: 0; }
.flipbook-fold-front, .flipbook-fold-flap { position: absolute; left: 0; top: 0; transform-origin: 0 0; contain: paint; }
.flipbook-fold-flapwrap { position: absolute; inset: 0; filter: drop-shadow(-5px 0 7px rgba(0,0,0,.35)); }
.flipbook-fold-spine { position: absolute; top: 0; pointer-events: none; background: linear-gradient(to right, rgba(0,0,0,calc(var(--fb-spine, 1) * .5)) 0, rgba(0,0,0,calc(var(--fb-spine, 1) * .28)) 3%, rgba(0,0,0,calc(var(--fb-spine, 1) * .12)) 12%, rgba(0,0,0,calc(var(--fb-spine, 1) * .04)) 40%, rgba(0,0,0,0) 100%), linear-gradient(to right, rgba(255,255,255,0) 0, rgba(255,255,255,0) calc(var(--fb-hl-p, 80%) - var(--fb-hl-s, 20%)), rgba(255,255,255,var(--fb-spine-hl, .22)) var(--fb-hl-p, 80%), rgba(255,255,255,0) calc(var(--fb-hl-p, 80%) + var(--fb-hl-s, 20%)), rgba(255,255,255,0) 100%); }
.flipbook-fold-sheet { position: absolute; top: 0; background-size: 100% 100%; background-repeat: no-repeat; }
.flipbook-fold-shadow, .flipbook-fold-light { position: absolute; left: 0; top: 0; width: 110px; transform-origin: 0 0; pointer-events: none; opacity: 0; }
.flipbook-fold-shadow { background: linear-gradient(to right, rgba(0,0,0,0), rgba(0,0,0,.32)); }
.flipbook-fold-light { background: linear-gradient(to right, rgba(0,0,0,.28), rgba(0,0,0,0)); }
.flipbook-arrow { flex: 0 0 auto; width: var(--fb-arrow-size, 56px); height: var(--fb-arrow-size, 56px); margin: 0 14px; border: 0; border-radius: 50%; background: rgba(0,0,0,.45); color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0; transition: opacity .2s, background .2s; position: relative; z-index: 6; }
.flipbook-arrow svg { width: 45%; height: 45%; }
.flipbook-prev { margin: 0 var(--fb-arrow-gap, 14px) 0 8px; }
.flipbook-next { margin: 0 8px 0 var(--fb-arrow-gap, 14px); }
.flipbook-arrow:hover { background: rgba(0,0,0,.65); }
.flipbook-arrow.disabled { opacity: .25; pointer-events: none; }
.flipbook-toolbar { position: relative; z-index: 7; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px 10px; margin-top: 14px; }
.flipbook-counter { font-size: calc(var(--fb-icon-size, 18px) * .78); opacity: .75; min-width: calc(var(--fb-icon-size, 18px) * 3.1); text-align: center; }
.flipbook-jump { box-sizing: border-box; width: var(--fb-jump-w, calc(var(--fb-icon-size, 18px) * 2.9 + 10px)); height: var(--fb-jump-h, auto); padding: 3px 4px; font-size: calc(var(--fb-icon-size, 18px) * .72); text-align: center; border: 1px solid rgba(128,128,128,.5); border-radius: 4px; background: transparent; color: inherit; -moz-appearance: textfield; }
.flipbook-jump::-webkit-outer-spin-button, .flipbook-jump::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.flipbook-btn { border: 0; background: transparent; color: inherit; cursor: pointer; padding: 4px; display: flex; opacity: .75; }
.flipbook-btn:hover { opacity: 1; }
.flipbook-btn.disabled { opacity: .25; pointer-events: none; }
.flipbook-btn svg { width: var(--fb-icon-size, 18px); height: var(--fb-icon-size, 18px); }
.flipbook-tb-prev, .flipbook-tb-next { display: none; }
.flipbook-thumbs { position: absolute; inset: 0; z-index: 20; background: rgba(20,20,20,.92); overflow: auto; padding: 44px 16px 16px; box-sizing: border-box; }
.flipbook-thumbs[hidden] { display: none; }
.flipbook-thumbs-close { position: absolute; top: 6px; right: 12px; border: 0; background: transparent; color: #fff; font-size: 30px; line-height: 1; cursor: pointer; }
.flipbook-thumbs-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 12px; }
.flipbook-thumb { border: 2px solid transparent; background: transparent; color: #fff; padding: 2px; cursor: pointer; text-align: center; font-size: 12px; }
.flipbook-thumb img { display: block; width: 100%; height: auto; background: #fff; }
.flipbook-thumb.active { border-color: #fff; }
.flipbook-btn.active { opacity: 1; color: #e8a400; }
.flipbook-btn.active svg { fill: currentColor; }
.flipbook-toc { position: absolute; inset: 0; z-index: 20; background: rgba(20,20,20,.94); color: #fff; overflow: auto; padding: 44px 12px 16px; box-sizing: border-box; }
.flipbook-toc[hidden] { display: none; }
.flipbook-toc-close { position: absolute; top: 6px; right: 12px; border: 0; background: transparent; color: #fff; font-size: 30px; line-height: 1; cursor: pointer; }
.flipbook-toc-tabs { display: flex; gap: 6px; margin-bottom: 8px; }
.flipbook-toc-tab { border: 0; border-bottom: 2px solid transparent; background: transparent; color: #fff; font-size: 15px; padding: 4px 10px; cursor: pointer; opacity: .7; }
.flipbook-toc-tab.active { border-bottom-color: #fff; opacity: 1; }
.flipbook-toc-row { display: flex; align-items: center; }
.flipbook-toc-item { flex: 1 1 auto; display: flex; justify-content: space-between; gap: 12px; border: 0; border-bottom: 1px solid rgba(255,255,255,.12); background: transparent; color: #fff; font-size: 15px; text-align: left; padding: 10px 12px; cursor: pointer; }
.flipbook-toc-item:hover { background: rgba(255,255,255,.08); }
.flipbook-toc-page { opacity: .6; flex: 0 0 auto; }
.flipbook-toc-remove { border: 0; background: transparent; color: #fff; font-size: 22px; cursor: pointer; padding: 4px 10px; opacity: .6; }
.flipbook-toc-empty { opacity: .6; font-size: 14px; padding: 12px; }
.flipbook.is-fullscreen { max-width: none !important; width: 100%; height: 100%; background: #222; color: #fff; display: flex; flex-direction: column; justify-content: center; padding: 20px; }
.flipbook.is-fullscreen .flipbook-stage-wrap { flex: 1 1 auto; min-height: 0; margin: 0; padding: 0; display: flex; }
.flipbook.is-fullscreen .flipbook-stage-in { flex: 1 1 auto; min-width: 0; }
.flipbook.is-fullscreen .flipbook-viewport, .flipbook.is-fullscreen .flipbook-zoom { height: 100%; }
.flipbook.is-fullscreen .flipbook-zoom { display: flex; justify-content: center; }
.flipbook.is-fullscreen .flipbook-stage { width: auto; max-width: 100%; height: 100%; }
/* 手機：箭頭浮在書頁兩側(不佔寬度，書頁撐滿)，工具列縮小間距 */
@media (max-width: 767px) {
  .flipbook-arrow { --fb-am: var(--fb-arrow-size-m, calc(var(--fb-arrow-size, 56px) * .65)); position: absolute; top: 50%; width: var(--fb-am); height: var(--fb-am); margin: calc(var(--fb-am) * -.5) 0 0; background: rgba(0,0,0,.35); }
  .flipbook-prev { left: var(--fb-arrow-off-m, 4px); }
  .flipbook-next { right: var(--fb-arrow-off-m, 4px); }
  .flipbook-toolbar { flex-wrap: wrap; gap: 2px; }
  .flipbook-btn { padding: 4px; }
  .flipbook-btn svg { width: var(--fb-icon-size-m, calc(var(--fb-icon-size, 18px) * 1.22)); height: var(--fb-icon-size-m, calc(var(--fb-icon-size, 18px) * 1.22)); }
  .flipbook-counter { min-width: 0; font-size: calc(var(--fb-icon-size, 18px) * .72); white-space: nowrap; }
  .flipbook-jump { width: var(--fb-jump-w, calc(var(--fb-icon-size, 18px) * 2.2 + 6px)); padding: 2px; font-size: calc(var(--fb-icon-size, 18px) * .67); }
}
.flipbook.is-pseudo { position: fixed; inset: 0; z-index: 99999; margin: 0; }
.flipbook-link { -webkit-user-drag: none; -webkit-touch-callout: none; position: absolute; display: block; z-index: 3; cursor: pointer; border-radius: 2px; transition: background .15s; }
.flipbook-hl { position: absolute; z-index: 2; pointer-events: none; background: rgba(255,214,0,.4); mix-blend-mode: multiply; border-radius: 2px; box-shadow: 0 0 0 1px rgba(255,170,0,.5); }
.flipbook-link:hover { background: rgba(37,99,235,.14); outline: 1px solid rgba(37,99,235,.45); }
/* 全文搜尋／更多選單(下載 PDF、複製連結、QR Code) */
.flipbook-search-input { display: block; width: calc(100% - 44px); box-sizing: border-box; margin: 0 0 8px; padding: 8px 10px; font-size: 16px; border: 1px solid rgba(255,255,255,.35); border-radius: 6px; background: rgba(255,255,255,.08); color: #fff; }
.flipbook-search-count { font-size: 13px; opacity: .7; margin: 0 0 6px 2px; min-height: 18px; }
.flipbook-search-hit .flipbook-toc-title { white-space: normal; line-height: 1.5; }
.flipbook-search-hit mark { background: #ffe066; color: #000; border-radius: 2px; padding: 0 1px; }
.flipbook-more { position: absolute; right: 6px; bottom: 44px; z-index: 30; min-width: 160px; background: #1f2937; color: #fff; border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.35); padding: 6px; }
.flipbook-more[hidden] { display: none; }
.flipbook-more-item { display: block; width: 100%; box-sizing: border-box; border: 0; background: transparent; color: #fff; font-size: 14px; text-align: left; padding: 9px 12px; border-radius: 6px; cursor: pointer; text-decoration: none; }
.flipbook-more-item:hover { background: rgba(255,255,255,.12); }
.flipbook-qr { text-align: center; padding: 6px 0 2px; }
.flipbook-qr img { width: 150px; height: 150px; background: #fff; border-radius: 6px; }
@media (max-width: 767px) { .flipbook-first, .flipbook-last { display: none; } }


/* 書本厚度：左右兩側紙張疊起來的邊(寬度由 JS 依頁數設定) */
.flipbook-edge { position: absolute; top: 1px; bottom: 1px; width: 0; pointer-events: none; }
.flipbook-edge-l { right: 100%; background: repeating-linear-gradient(to left, #cfcfcf 0 1px, #f6f6f6 1px 2.5px); box-shadow: inset -7px 0 9px rgba(0,0,0,.16), 0 6px 14px rgba(0,0,0,calc(var(--fb-shadow, .18) * .78)); border-radius: 2px 0 0 2px; }
.flipbook-edge-r { left: 100%; background: repeating-linear-gradient(to right, #cfcfcf 0 1px, #f6f6f6 1px 2.5px); box-shadow: inset 7px 0 9px rgba(0,0,0,.16), 0 6px 14px rgba(0,0,0,calc(var(--fb-shadow, .18) * .78)); border-radius: 0 2px 2px 0; }
/* 硬皮封面：整片硬板繞書脊 3D 轉動(正反面各一張圖，邊緣有厚度) */
.flipbook-flat { overflow: visible !important; }
.flipbook-flat-board { position: absolute; top: 0; transform-style: preserve-3d; }
.flipbook-flat-face { position: absolute; inset: 0; background-size: 100% 100%; background-repeat: no-repeat; backface-visibility: hidden; -webkit-backface-visibility: hidden; box-shadow: 0 6px 18px rgba(0,0,0,.25); }
.flipbook-flat-shade { position: absolute; inset: 0; background: #000; opacity: 0; pointer-events: none; }
.flipbook-flat-edge { position: absolute; top: 0; background: linear-gradient(to bottom, #9a9a9a, #6d6d6d); }
/* 空白襯頁：白紙(跟內頁一樣有陰影) */
.flipbook-page-blank { background: #fff; }
