/* Flipbook reader */
.fb { position: relative; display: flex; flex-direction: column; border: 1px solid var(--rule); background: #fff; outline: none; }
.fb-stage { position: relative; height: clamp(440px, calc(100vh - 230px), 1000px); background: #f2f2f2; overflow: hidden; display: flex; align-items: center; justify-content: center; }
body.embed .fb { border: 0; height: 100vh; }
body.embed .fb-stage { height: auto; flex: 1; }
.fb.is-full, .fb.fake-full { border: 0; background: #2b2b2b; }
.fb.is-full .fb-stage, .fb.fake-full .fb-stage { height: auto; flex: 1; background: #2b2b2b; }
.fb.fake-full { position: fixed; inset: 0; z-index: 9999; height: 100%; }
.fb:fullscreen { width: 100vw; height: 100vh; }
.fb:-webkit-full-screen { width: 100vw; height: 100vh; }
body.fb-lock { overflow: hidden; }

.fb-book { position: relative; margin: 0 auto; opacity: 0; transition: opacity .3s; }
.fb.ready .fb-book { opacity: 1; }
.fb.zoomed .fb-book { visibility: hidden; position: absolute; }
.fb-page { background: #fff; overflow: hidden; }
.fb-page img { display: block; width: 100%; height: 100%; object-fit: fill; user-select: none; -webkit-user-drag: none; opacity: 0; transition: opacity .25s; }
.fb-page.loaded img { opacity: 1; }
.fb-links { position: absolute; inset: 0; }
.fb-link { position: absolute; display: block; z-index: 2; border-radius: 2px; cursor: pointer; }
.fb-link:hover { background: rgba(13, 81, 162, .14); outline: 1px solid rgba(13, 81, 162, .5); }
.fb-link:focus-visible { outline: 3px solid var(--band); background: rgba(13, 81, 162, .14); }

.fb-loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.fb.ready .fb-loading { display: none; }
.fb-loading span { width: 42px; height: 42px; border: 4px solid #cfcfcf; border-top-color: var(--primary); border-radius: 50%; animation: fb-spin .8s linear infinite; }
@keyframes fb-spin { to { transform: rotate(360deg); } }

.fb-nav { position: absolute; top: 50%; margin-top: -26px; width: 52px; height: 52px; border-radius: 50%; background: #fff; border: 1px solid #ddd; display: flex; align-items: center; justify-content: center; cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,.14); z-index: 20; }
.fb-nav svg { width: 24px; height: 24px; fill: none; stroke: var(--text); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.fb-nav:hover { background: var(--pale); }
.fb-nav:disabled { opacity: 0; pointer-events: none; }
.fb-prev { left: 14px; }
.fb-next { right: 14px; }
@media (max-width: 640px) { .fb-nav { width: 44px; height: 44px; margin-top: -22px; opacity: .85; } .fb-prev { left: 6px; } .fb-next { right: 6px; } }

/* Zoomed view: scroll or drag to move around the page */
.fb-zoomview { position: absolute; inset: 0; overflow: auto; cursor: grab; z-index: 10; -webkit-overflow-scrolling: touch; }
.fb-zoomview.dragging { cursor: grabbing; }
.fb-zoominner { display: flex; width: max-content; min-width: 100%; min-height: 100%; align-items: center; justify-content: center; padding: 30px; box-sizing: border-box; }
.fb-zpage { position: relative; background: #fff; box-shadow: 0 8px 30px rgba(0,0,0,.25); flex: none; }
.fb-zpage img { display: block; width: 100%; height: 100%; user-select: none; }

/* Toolbar, like Issuu: page number, zoom slider, then search, share, download and full screen */
.fb-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 8px 14px; flex-wrap: wrap; padding: 6px 10px; border-top: 1px solid var(--rule); background: #fff; }
.fb.is-full .fb-toolbar, .fb.fake-full .fb-toolbar { background: #1e1e1e; border-color: #1e1e1e; }
.fb-group { display: flex; align-items: center; gap: 2px; }
.fb-btn { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; background: none; border: 0; border-radius: 4px; color: var(--text); cursor: pointer; text-decoration: none; }
.fb-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.fb-btn:hover, .fb-btn[aria-expanded="true"] { background: var(--grey-panel); color: var(--primary); }
.fb.is-full .fb-btn, .fb.fake-full .fb-btn { color: #f0f0f0; }
.fb.is-full .fb-btn:hover, .fb.fake-full .fb-btn:hover { background: #333; color: #fff; }
.fb-pageform { display: flex; align-items: center; gap: 6px; margin-left: 6px; font-size: 14px; }
.fb-pagein { width: 64px; height: 36px; text-align: center; border: 1px solid #bebebe; font-weight: 700; font-size: 14px; color: var(--text); }
.fb-pagecount { color: #555; white-space: nowrap; }
.fb.is-full .fb-pagecount, .fb.fake-full .fb-pagecount, .fb.is-full .fb-zoompct, .fb.fake-full .fb-zoompct { color: #f0f0f0; }
.fb-zoompct { width: 46px; font-size: 13px; font-weight: 700; color: var(--text); }
.fb-zoomrange { -webkit-appearance: none; appearance: none; width: 180px; height: 24px; background: transparent; cursor: pointer; --fill: 0%; }
.fb-zoomrange::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: linear-gradient(to right, var(--primary) var(--fill), #cfcfcf var(--fill)); }
.fb-zoomrange::-moz-range-track { height: 4px; border-radius: 2px; background: #cfcfcf; }
.fb-zoomrange::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--primary); }
.fb-zoomrange::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; margin-top: -7px; border-radius: 50%; background: var(--primary); border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.35); }
.fb-zoomrange::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--primary); border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.35); }
@media (max-width: 700px) {
  .fb-toolbar { justify-content: center; }
  .fb-zoomrange { width: 110px; }
  .fb-zoom { order: 3; width: 100%; justify-content: center; }
  .fb-stage { height: clamp(380px, calc(100vh - 220px), 760px); }
}

/* Side panel */
.fb-panel { position: absolute; top: 0; left: 0; bottom: 0; width: min(360px, 100%); background: #fff; z-index: 30; box-shadow: 4px 0 20px rgba(0,0,0,.18); overflow: auto; padding: 0 0 20px; }
.fb-panel-head { position: sticky; top: 0; background: #fff; display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--rule); z-index: 1; }
.fb-panel h2 { font-size: 18px; color: var(--text); }
.fb-panel h3 { font-size: 15px; color: var(--text); margin: 22px 16px 8px; }
.fb-close { width: 44px; height: 44px; margin: -8px -10px -8px 0; border: 0; background: none; font-size: 28px; line-height: 1; cursor: pointer; color: var(--text); }
.fb-note { padding: 12px 16px; margin: 0; font-size: 14px; color: #555; }
.fb-thumbs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; padding: 16px; }
.fb-thumb { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 6px; background: none; border: 2px solid transparent; cursor: pointer; font-size: 13px; color: var(--text); }
.fb-thumb img { width: 100%; aspect-ratio: 210 / 297; object-fit: contain; background: #f2f2f2; box-shadow: 0 1px 5px rgba(0,0,0,.18); }
.fb-thumb:hover { border-color: #cfcfcf; }
.fb-thumb.on { border-color: var(--primary); font-weight: 700; }
.fb-contents, .fb-contents ul, .fb-hits { list-style: none; margin: 0; padding: 0; }
.fb-contents button, .fb-hits button { display: flex; width: 100%; gap: 12px; justify-content: space-between; text-align: left; padding: 11px 16px; background: none; border: 0; border-bottom: 1px solid var(--rule); cursor: pointer; font-size: 14px; color: var(--text); }
.fb-contents button:hover, .fb-hits button:hover { background: var(--grey-panel); color: var(--primary); }
.fb-hits button { flex-direction: column; gap: 3px; }
.fb-pg { font-weight: 700; color: var(--primary); white-space: nowrap; }
.fb-hits mark { background: #fff1a8; color: inherit; }
.fb-searchform { display: flex; padding: 14px 16px 6px; }
.fb-searchform input { flex: 1; min-width: 0; height: 46px; border: 2px solid var(--primary); border-right: 0; padding: 0 10px; }
.fb-panel .copy-row, .fb-panel .share-links { margin: 10px 16px; }
.fb-check { display: flex; gap: 10px; align-items: center; margin: 16px 16px 4px; font-size: 14px; cursor: pointer; }
.fb-check input { width: 18px; height: 18px; accent-color: var(--primary); }
.fb-panel textarea { display: block; width: calc(100% - 32px); margin: 0 16px 10px; font-family: monospace; font-size: 12px; padding: 8px; border: 1px solid #bebebe; resize: vertical; }
.fb-panel .btn-plain { margin-left: 16px; }
