:root { color-scheme: dark; --fb-bg: #20302f; --ink: #f6f1e7; --accent: #e3a93c; }
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 15px/1.45 system-ui, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: radial-gradient(120% 90% at 50% 40%, color-mix(in srgb, var(--fb-bg) 82%, #fff), var(--fb-bg) 62%, color-mix(in srgb, var(--fb-bg) 72%, #000));
  background-color: var(--fb-bg);
  background-size: cover;
  background-position: center;
  overflow: hidden;
  touch-action: none;
}
#fb-root { position: fixed; inset: 0; display: flex; flex-direction: column; overflow: hidden; }

.fb-head { display: flex; align-items: center; gap: 12px; min-height: 42px; padding: 8px 16px 0; flex: none; }
.fb-head:empty { display: none; }
.fb-title { margin: 0; font: 600 15px/1.2 Georgia, "Iowan Old Style", serif; opacity: .9; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.fb-logo { max-height: 34px; max-width: 150px; display: block; }

.fb-zoombox { flex: 1; min-height: 0; display: flex; transform-origin: center center; padding: 12px 16px 8px; }
.is-zoomed .fb-zoombox { cursor: grab; }
.fb-stage { flex: 1; min-width: 0; min-height: 0; position: relative; display: flex; align-items: center; justify-content: center; outline: none; user-select: none; -webkit-user-select: none; }

/* ---------- Page ---------- */
.fb-page { position: relative; width: 100%; height: 100%; background-color: #fff; background-repeat: no-repeat; overflow: hidden; }
.fb-page > canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; opacity: 0; transition: opacity .18s; }
.fb-page.is-ready > canvas { opacity: 1; }
.fb-layers { position: absolute; inset: 0; pointer-events: none; }
.fb-layer { position: absolute; pointer-events: auto; border: 0; padding: 0; background: none; }
.fb-circle { border-radius: 50%; }
.fb-hot.fb-circle { border-radius: 50%; }
/* Two rings, so the outline shows on both dark and light pages. */
.fb-hot.fb-outlined { background: rgba(255, 255, 255, .14); box-shadow: 0 0 0 2px #fff, 0 0 0 4px rgba(0, 0, 0, .55); }
.fb-hot.fb-outlined:hover, .fb-hot.fb-outlined:focus-visible { background: rgba(255, 255, 255, .28); box-shadow: 0 0 0 2px #fff, 0 0 0 4px rgba(0, 0, 0, .75); }
.fb-hl { position: absolute; background: rgba(227, 169, 60, .5); mix-blend-mode: multiply; border-radius: 2px; pointer-events: none; }
.fb-hot { display: block; cursor: pointer; border-radius: 3px; transition: background .15s, box-shadow .15s; }
.fb-hot:hover, .fb-hot:focus-visible { background: rgba(227, 169, 60, .22); box-shadow: 0 0 0 2px rgba(227, 169, 60, .85); outline: none; }
iframe.fb-layer, video.fb-layer, img.fb-layer { background: #000; object-fit: cover; }
img.fb-layer { background: none; }
audio.fb-layer { background: none; }

/* ---------- Book ---------- */
.fb-book { position: relative; perspective: 3800px; transform: translateX(var(--shift, 0)); transition: transform .5s cubic-bezier(.3,.7,.2,1); touch-action: none; cursor: grab; }
.fb-book.is-flipping { cursor: grabbing; }
.fb-slot { position: absolute; top: 0; bottom: 0; width: 50%; }
.fb-slot-left { left: 0; }
.fb-slot-right { left: 50%; }
.fb-book.is-single .fb-slot { width: 100%; left: 0; }
.fb-book.is-single .fb-slot-left { display: none; }
.fb-book.has-shadow .fb-slot:not(.is-empty) { box-shadow: 0 18px 44px rgba(0, 0, 0, .42); }
.fb-slot.is-empty { pointer-events: none; }
/* spine: soft gutter shading on both inside edges */
.fb-slot:not(.is-empty)::after { content: ""; position: absolute; inset: 0; pointer-events: none; }
.fb-book:not(.is-single) .fb-slot-left::after { background: linear-gradient(to left, rgba(0,0,0,.2), rgba(0,0,0,.04) 5%, transparent 12%); }
.fb-book:not(.is-single) .fb-slot-right::after { background: linear-gradient(to right, rgba(0,0,0,.22), rgba(0,0,0,.05) 5%, transparent 12%); }
.fb-book[data-effect="book"]:not(.is-single) { outline: 6px solid #15110c; outline-offset: 0; border-radius: 2px; }

.fb-leaf { position: absolute; top: 0; bottom: 0; width: 50%; transform-style: preserve-3d; z-index: 20; pointer-events: none; }
.fb-leaf-right { left: 50%; }
.fb-leaf-left { left: 0; }
.fb-book.is-single .fb-leaf { left: 0; width: 100%; }
.fb-strip { position: absolute; top: 0; transform-style: preserve-3d; will-change: transform; }
.fb-leaf-right .fb-strip { transform-origin: left center; }
.fb-leaf-left .fb-strip { transform-origin: right center; }
.fb-leaf-left > .fb-strip { right: 0; }
.fb-face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; overflow: hidden; background: #fff; }
.fb-face-back { transform: rotateY(180deg); }
.fb-face canvas { display: block; width: 100%; height: 100%; }
.fb-shade { position: absolute; inset: 0; pointer-events: none; }
.fb-cast { position: absolute; top: 0; bottom: 0; width: 50%; opacity: 0; pointer-events: none; z-index: 10; }
.fb-cast[data-side="left"] { left: 0; background: linear-gradient(to left, rgba(0,0,0,.65), transparent 72%); }
.fb-cast[data-side="right"] { left: 50%; background: linear-gradient(to right, rgba(0,0,0,.65), transparent 72%); }
.fb-book.is-single .fb-cast { left: 0; width: 100%; }

/* Album: thick dark board with each page mounted on it */
.fb-book[data-effect="album"] { outline: 12px solid #2b211a; border-radius: 3px; }
.fb-book[data-effect="album"] .fb-page { box-shadow: inset 0 0 0 10px #f3ece0, inset 0 0 0 11px rgba(0,0,0,.18); }
.fb-book[data-effect="album"] .fb-page > canvas { inset: 11px; width: calc(100% - 22px); height: calc(100% - 22px); }
.fb-book[data-effect="album"] .fb-layers { inset: 11px; }
/* Notebook: spiral rings along the spine */
.fb-book[data-effect="notebook"]:not(.is-single)::before { content: ""; position: absolute; top: 1.5%; bottom: 1.5%; left: calc(50% - 14px); width: 28px; z-index: 30; pointer-events: none;
  background: radial-gradient(ellipse 13px 5px at 50% 50%, transparent 58%, #8a8f94 60%, #d6dadd 76%, #6d7276 92%, transparent 94%) 0 0 / 28px 26px repeat-y; }
.fb-book[data-effect="notebook"].is-single::before { content: ""; position: absolute; top: 1.5%; bottom: 1.5%; left: -6px; width: 22px; z-index: 30; pointer-events: none;
  background: radial-gradient(ellipse 11px 5px at 50% 50%, transparent 58%, #8a8f94 60%, #d6dadd 76%, #6d7276 92%, transparent 94%) 0 0 / 22px 26px repeat-y; }
.fb-book[data-effect="notebook"] .fb-slot::after { background: none !important; }

/* ---------- Carousel effects ---------- */
.fb-track { position: relative; width: var(--w); height: var(--h); perspective: 1800px; transform-style: preserve-3d; touch-action: none; cursor: grab; }
.fb-card { position: absolute; inset: 0; will-change: transform; backface-visibility: hidden; }
.fb-track.has-shadow .fb-card { box-shadow: 0 18px 44px rgba(0, 0, 0, .42); }
.fb-track[data-effect="cards"] .fb-card, .fb-track[data-effect="coverflow"] .fb-card { border-radius: 6px; }
.fb-card:not(.is-centre) .fb-layers { display: none; }

/* ---------- Toolbar ---------- */
.fb-bar { flex: none; align-self: center; display: flex; align-items: center; gap: 2px; margin: 0 8px max(10px, env(safe-area-inset-bottom)); padding: 5px 8px; background: rgba(12, 18, 17, .78); backdrop-filter: blur(10px); border: 1px solid rgba(255, 255, 255, .12); border-radius: 999px; max-width: calc(100vw - 16px); }
.fb-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; flex: none; color: var(--ink); background: none; border: 0; border-radius: 50%; cursor: pointer; text-decoration: none; }
.fb-btn svg { width: 21px; height: 21px; }
.fb-btn:hover { background: rgba(255, 255, 255, .13); }
.fb-btn:focus-visible, .fb-thumb:focus-visible, .fb-result:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.fb-counter { font-variant-numeric: tabular-nums; font-size: 13px; padding: 0 8px; white-space: nowrap; min-width: 64px; text-align: center; }
.fb-scrub { width: clamp(70px, 18vw, 220px); accent-color: var(--accent); touch-action: auto; }
.fb-sep { width: 1px; height: 22px; margin: 0 6px; background: rgba(255, 255, 255, .2); flex: none; }
@media (max-width: 640px) {
  .fb-scrub, .fb-sep { display: none; }
  .fb-bar { padding: 3px 4px; overflow-x: auto; scrollbar-width: none; }
  .fb-btn { width: 36px; height: 36px; }
  .fb-zoombox { padding: 6px 6px 4px; }
}
@media (max-width: 420px) {
  .fb-btn { width: 31px; height: 34px; }
  .fb-btn svg { width: 19px; height: 19px; }
  .fb-counter { min-width: 46px; padding: 0 2px; font-size: 12px; }
}

/* ---------- Panels ---------- */
.fb-panel { position: absolute; top: 10px; bottom: 74px; right: 10px; width: min(340px, calc(100vw - 20px)); z-index: 200; padding: 10px 14px 14px; overflow-y: auto; touch-action: pan-y; background: rgba(15, 22, 21, .94); backdrop-filter: blur(12px); border: 1px solid rgba(255, 255, 255, .12); border-radius: 14px; box-shadow: 0 16px 40px rgba(0,0,0,.4); }
.fb-panel[hidden] { display: none; }
.fb-panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.fb-panel h2 { margin: 0; font: 600 18px Georgia, serif; }
.fb-thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 12px 10px; }
.fb-thumb { background: none; border: 0; color: inherit; font: inherit; font-size: 12px; cursor: pointer; padding: 3px; border-radius: 6px; display: grid; gap: 4px; }
.fb-thumb-face { display: block; width: 100%; background-color: #fff; background-repeat: no-repeat; border-radius: 2px; }
.fb-thumb.is-current { outline: 2px solid var(--accent); }
.fb-panel input[type="search"], .fb-panel textarea { width: 100%; padding: 9px 11px; border-radius: 8px; border: 1px solid rgba(255,255,255,.25); background: rgba(255,255,255,.08); color: inherit; font: inherit; resize: none; }
.fb-search-status { font-size: 13px; opacity: .75; min-height: 1.4em; margin: 8px 0; }
.fb-result { display: block; width: 100%; text-align: left; background: rgba(255,255,255,.06); border: 0; color: inherit; font: inherit; font-size: 13px; padding: 9px 11px; margin-bottom: 6px; border-radius: 8px; cursor: pointer; }
.fb-result:hover { background: rgba(255,255,255,.12); }
.fb-result strong { display: block; margin-bottom: 2px; }
.fb-result mark { background: var(--accent); color: #231a07; border-radius: 2px; }
.fb-share-row { margin-bottom: 12px; display: grid; grid-template-columns: 1fr auto; gap: 6px; align-items: start; }
.fb-share-row label { grid-column: 1 / -1; font-size: 13px; opacity: .8; }
.fb-copy { padding: 8px 12px; border: 0; border-radius: 8px; background: var(--accent); color: #231a07; font: inherit; font-weight: 600; cursor: pointer; }
.fb-share-links { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.fb-share-links a { color: var(--ink); padding: 6px 12px; border: 1px solid rgba(255,255,255,.25); border-radius: 999px; text-decoration: none; font-size: 13px; }
.fb-qr { display: block; background: #fff; border-radius: 8px; padding: 6px; }

.fb-toc-row { display: block; width: 100%; text-align: start; background: none; border: 0; color: inherit; font: inherit; font-size: 14px; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.fb-toc-row:hover, .fb-toc-row:focus-visible { background: rgba(255,255,255,.12); outline: none; }
.fb-brand { position: absolute; left: 12px; bottom: 16px; z-index: 5; font-size: 12px; color: var(--ink); opacity: .65; text-decoration: none; }
.fb-brand:hover { opacity: 1; text-decoration: underline; }
@media (max-width: 900px) { .fb-brand { display: none; } }

.fb-overlay { position: absolute; inset: 0; z-index: 400; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(5, 10, 10, .72); backdrop-filter: blur(6px); }
.fb-lead h2 { margin: 0; font: 600 22px Georgia, serif; }
.fb-lead label { display: grid; gap: 4px; font-size: 13px; }
.fb-lead .fb-consent { display: flex; gap: 8px; align-items: flex-start; line-height: 1.35; }
.fb-lead .fb-consent input { margin-top: 2px; flex: none; }

.fb-print { display: none; }
@media print {
  body { background: #fff !important; overflow: visible; }
  #fb-root { display: none; }
  .fb-print { display: block; }
  .fb-print img { display: block; width: 100%; break-after: page; }
}

/* ---------- States ---------- */
.fb-loader { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 12px; z-index: 300; pointer-events: none; }
.fb-spin { width: 22px; height: 22px; border-radius: 50%; border: 3px solid rgba(255,255,255,.25); border-top-color: var(--accent); animation: fb-spin .9s linear infinite; }
@keyframes fb-spin { to { transform: rotate(360deg); } }
.fb-fatal { margin: auto; text-align: center; padding: 24px; }
.fb-fatal h1 { font: 600 24px Georgia, serif; }
.is-gate #fb-root { align-items: center; justify-content: center; padding: 16px; }
.fb-gate { width: min(360px, 100%); padding: 26px; background: rgba(15, 22, 21, .9); border: 1px solid rgba(255,255,255,.14); border-radius: 16px; display: grid; gap: 12px; touch-action: auto; }
.fb-gate h1 { margin: 0; font: 600 22px Georgia, serif; }
.fb-gate p { margin: 0; opacity: .85; }
.fb-gate input { padding: 11px 12px; border-radius: 9px; border: 1px solid rgba(255,255,255,.3); background: rgba(255,255,255,.08); color: inherit; font: inherit; }
.fb-gate button { padding: 11px; border: 0; border-radius: 9px; background: var(--accent); color: #231a07; font: inherit; font-weight: 700; cursor: pointer; }
.fb-gate-error { color: #ffb4a8; min-height: 1.4em; font-size: 14px; }

@media (prefers-reduced-motion: reduce) {
  .fb-book { transition: none; }
  .fb-page > canvas { transition: none; }
}
