/* Flipbook-Betrachter: Grundlayout + Vorlagen (magazin, classic, float, spread, neat) */
html, body { margin: 0; height: 100%; overflow: hidden; }
#flipbook { position: fixed; inset: 0; }
.fb {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  font: 14px/1.3 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: radial-gradient(ellipse at 50% 35%, var(--fb-bg1), var(--fb-bg2));
  color: var(--fb-bar-fg); user-select: none; -webkit-user-select: none; overflow: hidden;
}
.fb button { font: inherit; }
.fb svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Kopfzeile */
.fb-head { display: flex; align-items: center; gap: 16px; padding: 12px 20px; min-height: 22px; position: relative; z-index: 3; }
.fb-logo { display: block; height: 34px; max-width: 40%; object-fit: contain; object-position: left center; }
.fb-counter { display: none; }
.fb-title { flex: 1; font-size: 16px; font-weight: 600; color: var(--fb-title-fg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: .01em; }

/* Suche */
.fb-search { position: relative; display: flex; align-items: center; gap: 4px; flex: none; }
.fb-search input { width: 190px; height: 28px; padding: 0 8px; border: 1px solid rgba(0,0,0,.25); border-radius: 3px; background: #fff; color: #222; font: inherit; font-size: 13px; }
.fb-search input:focus { outline: 2px solid var(--fb-accent); outline-offset: -1px; }
.fb-search .fb-btn { width: 34px; height: 30px; color: var(--fb-title-fg); }
.tpl-magazin .fb-search .fb-btn, .tpl-spread .fb-search .fb-btn { color: var(--fb-bar-fg); }
.fb-results { position: absolute; right: 0; top: calc(100% + 6px); width: 340px; max-width: 86vw; max-height: 60vh; overflow-y: auto; padding: 4px; border-radius: 6px; background: #fff; color: #222; box-shadow: 0 10px 30px rgba(0,0,0,.3); z-index: 20; }
.fb-results[hidden] { display: none; }
.fb-hit { display: block; width: 100%; padding: 8px 10px; border: 0; border-radius: 4px; background: none; color: inherit; text-align: left; font-size: 13px; line-height: 1.35; cursor: pointer; }
.fb-hit:hover { background: #f1f3f5; }
.fb-hit b { display: block; margin-bottom: 2px; font-size: 12px; color: var(--fb-accent); }
.fb-hit mark { background: #ffe27a; color: inherit; padding: 0 1px; }
.fb-nohit { padding: 10px; color: #666; font-size: 13px; }

/* Bühne + Buch */
.fb-stage { flex: 1; position: relative; display: flex; align-items: center; justify-content: center; min-height: 0; }
.fb-viewport { display: flex; align-items: center; justify-content: center; transition: transform .35s ease; touch-action: none; cursor: pointer; }
.fb-zoomed .fb-viewport { cursor: grab; transition: none; }
.fb-zoomed .fb-viewport:active { cursor: grabbing; }
.fb-book { position: relative; transition: transform var(--fb-speed) cubic-bezier(.42,.08,.36,1); opacity: 0; }
.fb-ready .fb-book { opacity: 1; transition: transform var(--fb-speed) cubic-bezier(.42,.08,.36,1), opacity .4s; }
.fb-half { position: absolute; top: 0; width: 50%; height: 100%; background: #fff; overflow: hidden; box-shadow: 0 12px 34px rgba(0,0,0,.32), 0 2px 6px rgba(0,0,0,.18); }
.fb-l { left: 0; }
.fb-r { left: 50%; }
.fb-half img { display: block; width: 100%; height: 100%; object-fit: fill; pointer-events: none; }
.fb-half.fb-blank { background: transparent; box-shadow: none; }
.fb-half.fb-blank img { display: none; }
.fb-half.fb-blank::before, .fb-alone .fb-half::before { display: none; }
/* Falz in der Buchmitte */
.fb-half::before { content: ""; position: absolute; top: 0; bottom: 0; width: 9%; z-index: 1; pointer-events: none; }
.fb-l::before { right: 0; background: linear-gradient(to right, rgba(0,0,0,0), rgba(0,0,0,.16)); }
.fb-r::before { left: 0; background: linear-gradient(to left, rgba(0,0,0,0), rgba(0,0,0,.16)); }
.fb-single .fb-half::before { display: none; }
.fb-single .fb-l { display: none; }
.fb-single .fb-r { left: 0; width: 100%; }

/* Hintergrundbild */
.fb.fb-bgimg { background-color: var(--fb-bg2); background-position: center; }
.fb.fb-bg-cover { background-size: cover; background-repeat: no-repeat; }
.fb.fb-bg-repeat { background-size: auto; background-repeat: repeat; }
.fb.fb-bg-center { background-size: contain; background-repeat: no-repeat; }

/* Blatt in Bewegung (gewölbte Ecke) */
.fb-curl-front { display: none; position: absolute; top: 0; height: 100%; z-index: 4; background: #fff; overflow: hidden; pointer-events: none; }
.fb-curl-wrap { display: none; position: absolute; left: 0; top: 0; width: 0; height: 0; z-index: 5; pointer-events: none; filter: drop-shadow(0 0 7px rgba(0,0,0,.28)); }
.fb-curl-back { position: absolute; left: 0; top: 0; transform-origin: 0 0; background: #fff; overflow: hidden; }
.fb-curl-front img, .fb-curl-back img { display: block; width: 100%; height: 100%; pointer-events: none; }
.fb-curl-front.fb-blank, .fb-curl-back.fb-blank { background: #f3f3f1; }
.fb-curl-front.fb-blank img, .fb-curl-back.fb-blank img { visibility: hidden; }
.fb-shade { position: absolute; left: 0; top: 0; width: 0; height: 0; opacity: 0; transform-origin: 0 0; pointer-events: none; z-index: 3; }
.fb-flap { background: linear-gradient(to bottom, rgba(0,0,0,.24), rgba(0,0,0,.06) 30%, rgba(255,255,255,.22) 62%, rgba(0,0,0,.06)); }
.fb-fold { background: linear-gradient(to bottom, rgba(0,0,0,.2), rgba(0,0,0,.05) 45%, rgba(0,0,0,0)); }
.fb-cast { background: linear-gradient(to bottom, rgba(0,0,0,.5), rgba(0,0,0,.14) 35%, rgba(0,0,0,0)); }

/* Seitenpfeile */
.fb-nav { position: absolute; top: 50%; transform: translateY(-50%); z-index: 4; width: 46px; height: 64px; border: 0; border-radius: 6px; display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--fb-title-fg); background: rgba(0,0,0,.12); opacity: .75; transition: opacity .2s, background .2s; }
.fb-nav:hover { opacity: 1; background: rgba(0,0,0,.25); }
.fb .fb-nav:disabled { opacity: 0; pointer-events: none; }
.fb-nav svg { width: 28px; height: 28px; }
.fb-nav-prev { left: 10px; }
.fb-nav-next { right: 10px; }
.fb-zoomed .fb-nav { display: none; }

/* Werkzeugleiste */
.fb-bar { display: flex; align-items: center; justify-content: center; gap: 18px; padding: 6px 14px; background: var(--fb-bar); color: var(--fb-bar-fg); position: relative; z-index: 6; flex-wrap: wrap; }
.fb-group { display: flex; align-items: center; gap: 2px; }
.fb-btn { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border: 0; border-radius: 6px; background: transparent; color: inherit; cursor: pointer; text-decoration: none; transition: background .15s, color .15s; }
.fb-btn:hover { background: rgba(127,127,127,.2); }
.fb-btn:disabled { opacity: .35; cursor: default; background: transparent; }
.fb-btn.fb-active { color: var(--fb-accent); }
.fb-btn.fb-off { opacity: .55; }
.fb-pagebox { display: inline-flex; align-items: center; gap: 6px; margin: 0 6px; font-variant-numeric: tabular-nums; }
.fb-pageinput { width: auto; min-width: 2.5em; text-align: center; font: inherit; color: inherit; background: rgba(127,127,127,.18); border: 1px solid rgba(127,127,127,.35); border-radius: 4px; padding: 4px 6px; }
.fb-pageinput:focus { outline: 2px solid var(--fb-accent); outline-offset: 0; }
.fb-pagetotal { opacity: .75; white-space: nowrap; }

/* Seitenübersicht */
.fb-thumbs { position: absolute; top: 0; bottom: 0; left: 0; width: 248px; max-width: 80%; z-index: 8; display: flex; flex-direction: column; background: var(--fb-bar); color: var(--fb-bar-fg); box-shadow: 4px 0 24px rgba(0,0,0,.3); transform: translateX(-105%); transition: transform .3s ease; }
.fb-thumbs-open .fb-thumbs { transform: none; }
.fb-thumbs-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 8px 8px 16px; font-weight: 600; border-bottom: 1px solid rgba(127,127,127,.25); }
.fb-thumbs-grid { flex: 1; overflow-y: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 14px 10px; padding: 14px; align-content: start; }
.fb-thumb { border: 0; padding: 0; background: none; color: inherit; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12px; }
.fb-thumb span { opacity: .75; }
.fb-thumb.fb-current span { opacity: 1; }
.fb-thumb img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; background: #fff; border: 2px solid transparent; border-radius: 2px; box-shadow: 0 2px 6px rgba(0,0,0,.25); }
.fb-thumb:hover img { border-color: rgba(127,127,127,.6); }
.fb-thumb.fb-current { color: var(--fb-accent); }
.fb-thumb.fb-current img { border-color: var(--fb-accent); }

/* Ladeanzeige */
.fb-loader { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none; transition: opacity .3s; z-index: 9; }
.fb-loader i { width: 34px; height: 34px; border-radius: 50%; border: 3px solid rgba(255,255,255,.25); border-top-color: var(--fb-accent); animation: fb-spin .8s linear infinite; }
.fb-ready .fb-loader { opacity: 0; }
@keyframes fb-spin { to { transform: rotate(360deg); } }

/* ---------- Vorlage: Classic ---------- */
.tpl-classic .fb-bar { box-shadow: 0 -2px 12px rgba(0,0,0,.25); }
.tpl-classic .fb-group-tools { border-left: 1px solid rgba(127,127,127,.3); padding-left: 14px; }

/* ---------- Vorlage: Float ---------- */
.tpl-float .fb-head { justify-content: center; text-align: center; }
.tpl-float .fb-bar { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); border-radius: 999px; padding: 6px 18px; box-shadow: 0 8px 28px rgba(0,0,0,.22); flex-wrap: nowrap; }
.tpl-float .fb-stage { margin-bottom: 72px; }
.tpl-float .fb-btn { border-radius: 50%; }
.tpl-float .fb-nav { border-radius: 50%; width: 52px; height: 52px; background: var(--fb-bar); color: var(--fb-bar-fg); box-shadow: 0 4px 16px rgba(0,0,0,.18); opacity: .92; }
.tpl-float .fb-thumbs { top: 12px; bottom: 12px; left: 12px; border-radius: 14px; }

/* ---------- Vorlage: Spread ---------- */
.tpl-spread .fb-head { background: var(--fb-bar); padding: 4px 8px 4px 20px; box-shadow: 0 2px 12px rgba(0,0,0,.2); }
.tpl-spread .fb-title { color: var(--fb-bar-fg); }
.tpl-spread .fb-bar { background: transparent; padding: 0; gap: 10px; }
.tpl-spread .fb-group-nav .fb-btn:first-child, .tpl-spread .fb-group-nav .fb-btn:last-child { display: none; }
.tpl-spread .fb-nav { background: transparent; color: var(--fb-title-fg); }
.tpl-spread .fb-nav:hover { background: rgba(0,0,0,.08); }
.tpl-spread .fb-thumbs { top: 50px; }

/* ---------- Vorlage: Neat ---------- */
.tpl-neat .fb-head { position: absolute; top: 0; left: 0; right: 0; justify-content: space-between; }
.tpl-neat .fb-title { font-weight: 500; opacity: .85; }
.tpl-neat .fb-stage { margin-top: 46px; }
.tpl-neat .fb-bar { background: transparent; color: var(--fb-title-fg); padding: 10px 14px 14px; }
.tpl-neat .fb-group-nav .fb-btn { display: none; }
.tpl-neat .fb-pageinput { background: transparent; border-color: transparent; min-width: 0; width: 3.2em; padding: 2px 0; text-align: right; }
.tpl-neat .fb-pagebox { gap: 4px; }
.tpl-neat .fb-head .fb-group-tools { color: var(--fb-title-fg); }
.tpl-neat .fb-nav { width: 56px; height: 120px; background: transparent; color: var(--fb-title-fg); }
.tpl-neat .fb-nav svg { width: 40px; height: 40px; stroke-width: 1.4; }
.tpl-neat .fb-nav:hover { background: rgba(255,255,255,.06); }

/* Klein (Handy) */
@media (max-width: 640px) {
  .fb-head { padding: 8px 12px; }
  .fb-search input { width: 110px; }
  .fb-title { font-size: 14px; }
  .fb-bar { gap: 6px; padding: 4px 6px; }
  .fb-btn { width: 34px; height: 34px; }
  .fb-group-nav .fb-btn:first-child, .fb-group-nav .fb-btn:last-child { display: none; }
  .fb-nav { display: none; }
  .tpl-float .fb-bar { bottom: 10px; padding: 4px 10px; }
  .tpl-float .fb-stage { margin-bottom: 60px; }
  .tpl-spread .fb-head { padding: 4px 6px 4px 12px; }
  .tpl-spread .fb-title { display: none; }
}

/* ---------- Vorlage: Magazin (Kopfleiste mit Logo, eckige Schaltflächen) ---------- */
.tpl-magazin .fb-head { margin: 4px 4px 0; padding: 5px 12px; min-height: 36px; border-radius: 4px; background: linear-gradient(rgba(255,255,255,.55), rgba(0,0,0,.07)), var(--fb-bar); box-shadow: 0 1px 4px rgba(0,0,0,.35); }
.tpl-magazin .fb-title { color: var(--fb-bar-fg); font-weight: 600; }
.tpl-magazin .fb-counter { display: block; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); padding: 4px 8px; background: #fff; color: #222; font-size: 13px; border-radius: 2px; font-variant-numeric: tabular-nums; box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); }
.tpl-magazin .fb-bar { justify-content: space-between; margin: 0 4px 4px; padding: 5px 6px; border-radius: 4px; background: linear-gradient(rgba(255,255,255,.55), rgba(0,0,0,.07)), var(--fb-bar); box-shadow: 0 -1px 4px rgba(0,0,0,.3); }
.tpl-magazin .fb-group { gap: 4px; }
.tpl-magazin .fb-btn { width: 46px; height: 34px; border: 1px solid rgba(0,0,0,.35); border-radius: 4px; color: var(--fb-bar-fg); background: linear-gradient(rgba(255,255,255,.9), rgba(255,255,255,.35)); box-shadow: inset 0 1px 0 rgba(255,255,255,.8); }
.tpl-magazin .fb-btn:hover { background: linear-gradient(#fff, rgba(255,255,255,.6)); }
.tpl-magazin .fb-btn:disabled { opacity: .45; }
.tpl-magazin .fb-btn.fb-active { color: var(--fb-accent); }
.tpl-magazin .fb-pagebox { display: none; }
.tpl-magazin .fb-nav { width: 42px; height: 96px; border-radius: 6px; background: rgba(105,107,112,.78); color: #fff; opacity: 1; }
.tpl-magazin .fb-nav:hover { background: rgba(80,82,88,.9); }
.tpl-magazin .fb-half:not(.fb-blank) { box-shadow: 0 0 0 5px #f7f7f7, 0 0 0 6px rgba(0,0,0,.18), 0 6px 18px rgba(0,0,0,.28); }
.tpl-magazin .fb-thumbs { top: 50px; bottom: 54px; }
@media (max-width: 640px) {
  .tpl-magazin .fb-logo { height: 26px; }
  .tpl-magazin .fb-title { display: none; }
  .tpl-magazin .fb-btn { width: 36px; height: 32px; }
  .tpl-magazin .fb-group-nav .fb-btn:first-child, .tpl-magazin .fb-group-nav .fb-btn:last-child { display: none; }
}
