/* FolioFlip Viewer, DESIGN.md token contract (UX-DR-1/2): each token is
   --fflip-color-*, --fflip-space-*, --fflip-radius-* defined ONLY on the
   plugin containers, never on the site's :root. Renaming a token is a
   breaking change. Two mirror presets over the same names:
   dark (Viewer default) and light ([data-fflip-theme="light"]), with no
   admin choice the initial one follows prefers-color-scheme (UX-DR-3/4).
   Selectors prefixed with the root ID, the site theme CSS never wins
   the cascade inside the plugin surface. */
:where(.fflip-viewer, .fflip-edition-page, .fflip-shelf, .fflip-metabox){
  /* colors, dark preset (default) */
  --fflip-color-surface-viewer:#14161A;
  --fflip-color-surface-chrome:#1D2128;
  --fflip-color-surface-raised:#282E38;
  --fflip-color-ink-primary:#F0F1F4;
  --fflip-color-ink-secondary:#9BA3AE;
  --fflip-color-ink-disabled:#5B626D;
  --fflip-color-accent:#8FB4E8;
  --fflip-color-accent-ink:#10141B;
  --fflip-color-border-hairline:#2E3440;
  --fflip-color-scrim:#0B0D10;
  --fflip-color-scrim-alpha:.65;
  --fflip-color-status-info:#8FB4E8;
  --fflip-color-status-ok:#7FCB8F;
  --fflip-color-status-error:#E88F8F;
  /* space, accessibility floor: tap-target is clamped to ≥44px where
     consumed (UX-DR-7) */
  --fflip-space-1:4px; --fflip-space-2:8px; --fflip-space-3:12px;
  --fflip-space-4:16px; --fflip-space-5:24px; --fflip-space-6:32px;
  --fflip-space-tap-target:44px;
  --fflip-space-bar-height:56px;
  --fflip-space-drawer-width:320px;
  --fflip-space-gutter-mobile:16px;
  --fflip-space-gutter-desktop:32px;
  /* radius */
  --fflip-radius-sm:4px; --fflip-radius-md:8px;
  --fflip-radius-lg:12px; --fflip-radius-full:9999px;
  /* typography */
  --fflip-font-ui:500 14px/1.4 system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;
  --fflip-font-meta:400 12px/1.4 system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;
  /* private derived, focus halo = opposite tint of the preset (UX-DR-26):
     matches ink-primary in both presets */
  --ff-halo:var(--fflip-color-ink-primary);
}

/* Light preset, mirror over the same names, the scrim is NOT
   inverted: the modal veil stays dark in both (UX-DR-3). */
:where(.fflip-viewer[data-fflip-theme="light"],
       .fflip-edition-page[data-fflip-theme="light"],
       .fflip-shelf[data-fflip-theme="light"],
       .fflip-metabox[data-fflip-theme="light"]){
  --fflip-color-surface-viewer:#F5F5F3;
  --fflip-color-surface-chrome:#FBFBFA;
  --fflip-color-surface-raised:#FFFFFF;
  --fflip-color-ink-primary:#1B1E24;
  --fflip-color-ink-secondary:#5C6470;
  --fflip-color-ink-disabled:#A9B0BA;
  --fflip-color-accent:#2B5EA7;
  --fflip-color-accent-ink:#FFFFFF;
  --fflip-color-border-hairline:#E2E4E8;
  --fflip-color-scrim:#171A1F;
  --fflip-color-status-info:#2B5EA7;
  --fflip-color-status-ok:#2E7D46;
  --fflip-color-status-error:#B3261E;
}

/* No admin choice (no attribute) → the initial value follows
   prefers-color-scheme (UX-DR-4). Admin-set preset → it wins. */
@media (prefers-color-scheme:light){
  :where(.fflip-viewer:not([data-fflip-theme]),
         .fflip-edition-page:not([data-fflip-theme]),
         .fflip-shelf:not([data-fflip-theme]),
         .fflip-metabox:not([data-fflip-theme])){
    --fflip-color-surface-viewer:#F5F5F3;
    --fflip-color-surface-chrome:#FBFBFA;
    --fflip-color-surface-raised:#FFFFFF;
    --fflip-color-ink-primary:#1B1E24;
    --fflip-color-ink-secondary:#5C6470;
    --fflip-color-ink-disabled:#A9B0BA;
    --fflip-color-accent:#2B5EA7;
    --fflip-color-accent-ink:#FFFFFF;
    --fflip-color-border-hairline:#E2E4E8;
    --fflip-color-scrim:#171A1F;
    --fflip-color-status-info:#2B5EA7;
    --fflip-color-status-ok:#2E7D46;
    --fflip-color-status-error:#B3261E;
  }
}

/* ---------- Edition Landing ---------- */
#ff-landing[hidden]{display:none}
/* boot splash: covers the gap between the HTML and the viewer mount
   (QA-PO round 3: without it, on slow networks the empty page looked
   like an error). It lives only on the first boot, it goes away when
   the viewer opens. */
#ff-boot{position:fixed;inset:0;z-index:60;display:flex;flex-direction:column;gap:18px;
    align-items:center;justify-content:center;background:#14161A}
#ff-boot[hidden]{display:none}
#ff-boot .ff-boot-spin{width:34px;height:34px;border-radius:50%;
    border:3px solid rgba(255,255,255,.18);border-top-color:#E8E9EB;
    animation:ff-boot-rot .8s linear infinite}
#ff-boot .ff-boot-msg{margin:0;font:500 14px/1.4 system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;
    color:#B9BDC5;letter-spacing:.01em}
@keyframes ff-boot-rot{to{transform:rotate(360deg)}}
@media (prefers-reduced-motion:reduce){#ff-boot .ff-boot-spin{animation:none;opacity:.55}}
#ff-landing{min-height:100vh;background:#F5F5F4;display:flex;align-items:center;
  justify-content:center;padding:32px;box-sizing:border-box}
#ff-landing .ff-card{max-width:520px;text-align:center}
#ff-landing .ff-cover{width:min(340px,78vw);height:auto;border-radius:var(--fflip-radius-sm);
  box-shadow:0 16px 44px rgba(0,0,0,.20)}
#ff-landing .ff-title{font:600 22px/1.3 system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;
  color:#1C1917;margin:26px 0 4px}
#ff-landing .ff-meta{font:400 14px/1.4 system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;
  color:#78716C;margin:0 0 22px}
#ff-landing .ff-read{appearance:none;-webkit-appearance:none;border:0;border-radius:6px;
  background:#1C1917;color:#FAFAF9;
  font:500 15px/1 system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;
  padding:14px 28px;min-height:max(var(--fflip-space-tap-target),44px);cursor:pointer}
#ff-landing .ff-read:hover{background:#292524;color:#FAFAF9}
#ff-landing .ff-read:focus-visible{outline:2px solid #2B5EA7;outline-offset:2px}
#ff-landing .ff-err{font:var(--fflip-font-meta);color:#B3261E;margin:12px 0 0}

/* ---------- Access gate CTA (Epic 17) ---------- */
/* Same light palette as the landing card it lives in; Pro builds the
   block, free only dresses it. */
#ff-landing .ff-gate{margin:24px auto 0;max-width:360px;text-align:center;
  font:400 14px/1.5 system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;color:#44403C}
#ff-landing .ff-gate p{margin:0}
#ff-landing .ff-gate .ff-gate-msg{font-weight:550;color:#1C1917}
#ff-landing .ff-gate .ff-gate-sub{font-size:13px;color:#78716C;margin-top:4px}
#ff-landing .ff-gate form{display:flex;gap:8px;margin-top:16px}
#ff-landing .ff-gate input[type=password]{flex:1;min-width:0;padding:11px 12px;
  border:1px solid #D6D3D1;border-radius:6px;background:#fff;color:#1C1917;
  font:400 14px/1.2 system-ui,-apple-system,"Segoe UI",Roboto,sans-serif}
#ff-landing .ff-gate input[type=password]:focus-visible{outline:2px solid #2B5EA7;
  outline-offset:1px;border-color:#2B5EA7}
#ff-landing .ff-gate button[type=submit]{appearance:none;-webkit-appearance:none;
  border:0;border-radius:6px;background:#1C1917;color:#FAFAF9;cursor:pointer;
  font:500 14px/1 system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;
  padding:0 18px;min-height:44px;white-space:nowrap}
#ff-landing .ff-gate button[type=submit]:hover{background:#292524}
#ff-landing .ff-gate button[type=submit]:focus-visible{outline:2px solid #2B5EA7;outline-offset:2px}
#ff-landing .ff-gate .ff-gate-err{color:#B3261E;font-size:13px;margin-top:10px}
#ff-landing .ff-gate .ff-gate-alt{margin-top:14px;font-size:13px;color:#57534E}
#ff-landing .ff-gate .ff-gate-alt p + p{margin-top:6px}
#ff-landing .ff-gate .ff-gate-alt a{color:#1C1917;font-weight:550}
#ff-landing .ff-gate .ff-gate-alt a:focus-visible{outline:2px solid #2B5EA7;outline-offset:2px}

/* ---------- Indexable Edition text (FR-22, UX-DR-48) ---------- */
/* <details> collapsed by default: the content stays in the DOM for
   search engines and screen readers without being a visual flood
   (QA-PO). */
.ff-text{max-width:720px;margin:0 auto;padding:24px 24px 48px;
  font:400 15px/1.65 system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;color:#1C1917}
.ff-text .ff-text-summary{cursor:pointer;list-style:none;padding:14px 18px;border:1px solid #E7E5E4;
  border-radius:8px;background:#FAFAF9}
.ff-text .ff-text-summary::-webkit-details-marker{display:none}
.ff-text .ff-text-title{display:block;font-weight:600;font-size:15px}
.ff-text .ff-text-note{display:block;font-size:12.5px;color:#78716C;margin-top:2px}
.ff-text[open] .ff-text-summary{border-bottom-left-radius:0;border-bottom-right-radius:0}
.ff-text .ff-text-body{padding:20px 18px 8px;border:1px solid #E7E5E4;border-top:0;
  border-bottom-left-radius:8px;border-bottom-right-radius:8px;background:#FAFAF9}
.ff-text .ff-text-page{margin:0 0 24px}
.ff-text .ff-text-h{font:600 12px/1.4 system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;
  color:#78716C;letter-spacing:.05em;text-transform:uppercase;margin:0 0 6px}
.ff-text .ff-text-p{margin:0;white-space:normal}
/* 21.8 Max custom replacement: same container box as the standard
   block, the inner markup is the editor's own (wp_kses_post). */
.ff-text-custom{max-width:720px;margin:0 auto;padding:24px;
  font:400 15px/1.65 system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;color:#1C1917}
.ff-text-custom a{color:#2B5EA7}

/* ---------- Viewer Overlay ---------- */
.ff-sr{position:absolute;width:1px;height:1px;padding:0;margin:-1px;
  overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0}
#ff-viewer{position:fixed;inset:0;z-index:100000;background:var(--fflip-color-surface-viewer);
  display:flex;color:var(--fflip-color-ink-primary);overscroll-behavior:contain}
/* overscroll-behavior on the fixed overlay (a non-scrollable scroll
   container) traps wheel/touch gestures so the hidden page behind the
   viewer does not scroll (modern-web-guidance: scroll-under-modal) */
#ff-viewer[hidden]{display:none}
/* the hidden attribute loses against any author display (UA
   display:none has minimal specificity), this rule restores its
   semantics for EVERY internal control: capped buttons, vmenu, drawer
   panels, modal, toast (UX-DR-34: nothing inert visible) */
#ff-viewer [hidden]{display:none!important}
#ff-viewer:focus{outline:none}
#ff-viewer .ff-stage{flex:1;position:relative;display:flex;align-items:center;
  justify-content:center;padding:32px;min-width:0;min-height:0}

/* Motor host: fills the stage, the motor mounts inside.
   touch-action keeps the OS pinch-zoom out of the stage so the JS
   pinch owns the gesture (16.3, UX-DR-33) — horizontal/vertical pan
   stays for the swipe scroller and the fit overflow */
#ff-viewer .ff-motor{flex:1;min-width:0;min-height:0;position:relative;
  overflow:hidden;align-self:stretch;touch-action:pan-x pan-y}

/* ---------- SwipeMotor (portrait) ---------- */
#ff-viewer .ff-swipe{position:absolute;inset:0;display:flex;
  overflow-x:auto;overflow-y:hidden;scroll-snap-type:x mandatory;
  scrollbar-width:none;overscroll-behavior:contain;
  -webkit-overflow-scrolling:touch}
#ff-viewer .ff-swipe::-webkit-scrollbar{display:none}
#ff-viewer .ff-slot{flex:0 0 100%;height:100%;scroll-snap-align:center;
  scroll-snap-stop:always;display:flex;align-items:center;justify-content:center}
/* width fit in swipe: the page fills the width and the overflow
   scrolls vertically inside the slot (safe center: the top is not
   lost), page change returns to top (JS) */
#ff-viewer .ff-swipe.ff-fit-w .ff-slot{overflow-y:auto;align-items:safe center;
  scrollbar-width:none}
#ff-viewer .ff-swipe.ff-fit-w .ff-slot::-webkit-scrollbar{display:none}

/* edge-taps, invisible zones, aria-hidden, pan-x lets the swipe
   through */
#ff-viewer .ff-tapzone{position:absolute;top:0;bottom:0;width:56px;z-index:3;
  touch-action:pan-x;cursor:pointer}
#ff-viewer .ff-tz-l{left:0}
#ff-viewer .ff-tz-r{right:0}

/* FlipMotor: single fixed-size canvas (loadFromImages), centered in
   the host, each flip face is drawn every frame (UX-DR-57 with retina
   patch in JS). .ff-hotlayer = transparent layer over the book that
   hosts the hotspots of the 1-2 visible pages, pointer-events only on
   the anchors so the canvas receives the gestures elsewhere. */
#ff-viewer .ff-motor.ff-flip-host{display:flex;align-items:center;justify-content:center}
/* width/height fit in flip (UX-DR-46): the spread may exceed the
   stage, the host scrolls, 'safe center' centers when it fits and does
   not lose the top when it overflows, the flip returns to the start
   (JS settle) */
#ff-viewer .ff-motor.ff-flip-host.ff-fit-scroll{overflow:auto;
  align-items:safe center;justify-content:safe center}
#ff-viewer .ff-flip{position:relative;
  filter:drop-shadow(0 18px 34px rgba(0,0,0,.45))}
#ff-viewer .ff-hotlayer{position:absolute;z-index:2;pointer-events:none}
#ff-viewer .ff-hside{position:absolute;top:0;bottom:0;width:50%}
#ff-viewer .ff-hs-left{left:0}
#ff-viewer .ff-hs-right{left:50%}
#ff-viewer .ff-flip-single .ff-hs-left{display:none}
#ff-viewer .ff-flip-single .ff-hs-right{left:0;width:100%}
#ff-viewer .ff-hotlayer.off .ff-hotspot{pointer-events:none}

/* zoom pan layer (levels {1,1.5,2}, 16.3): covers the zoomed
   book/page, its gesture is a viewport drag, never flip or scroll
   (UX-DR-30). A click without drag hit-tests hotspots in JS → links
   stay alive while zoomed. */
#ff-viewer .ff-panlayer{position:absolute;inset:0;z-index:5;display:none;
  cursor:grab;touch-action:none;background:transparent}
#ff-viewer .ff-panlayer.on{display:block}
#ff-viewer .ff-panlayer:active{cursor:grabbing}
#ff-viewer .ff-page{will-change:transform}

/* Per-page errors (UX-DR-22/23): "Toca para reintentar" chip over
   surface-chrome, never UI over bare dominantColor. In flip the layer
   is a sibling of the hotlayer and shares its geometry/transform, in
   swipe the chip goes inside the page box. */
#ff-viewer .ff-errlayer{position:absolute;z-index:6;pointer-events:none}
#ff-viewer .ff-eside{position:absolute;top:0;bottom:0;width:50%;
  display:flex;align-items:center;justify-content:center}
#ff-viewer .ff-es-left{left:0}
#ff-viewer .ff-es-right{left:50%}
#ff-viewer .ff-flip-single .ff-es-left{display:none}
#ff-viewer .ff-flip-single .ff-es-right{left:0;width:100%}
#ff-viewer .ff-retry{pointer-events:auto;position:absolute;left:50%;top:50%;
  transform:translate(-50%,-50%);z-index:4;
  font:var(--fflip-font-meta);letter-spacing:.02em;color:var(--fflip-color-ink-primary);
  background:var(--fflip-color-surface-chrome);border:1px solid var(--fflip-color-border-hairline);
  border-radius:var(--fflip-radius-md);padding:10px 16px;min-height:max(var(--fflip-space-tap-target),44px);
  display:inline-flex;align-items:center;cursor:pointer;
  box-shadow:0 8px 24px rgba(0,0,0,.35)}
#ff-viewer .ff-eside .ff-retry{position:static;transform:none}
#ff-viewer .ff-retry:hover{background:var(--fflip-color-surface-raised)}
#ff-viewer .ff-retry:focus-visible{outline:2px solid var(--fflip-color-accent);outline-offset:2px;
  box-shadow:0 0 0 4px var(--ff-halo)}

/* Loading shimmer (4.9): subtle sweep over the dominantColor, the
   page "is loading", never a plane that reads as broken.
   Flip: inside the side .ff-eside, swipe: inside the .ff-page. */
#ff-viewer .ff-load{position:absolute;inset:0;pointer-events:none;overflow:hidden;z-index:3}
#ff-viewer .ff-load::before{content:'';position:absolute;top:-20%;bottom:-20%;left:-60%;right:-60%;
  background:linear-gradient(100deg,transparent 42%,rgba(255,255,255,.14) 50%,transparent 58%);
  animation:ff-shimmer 1.6s ease-in-out infinite}
@keyframes ff-shimmer{from{transform:translateX(-45%)}to{transform:translateX(45%)}}

/* Page error box (4.10/4.11): message + bounded retry + diagnostic
   code P{n}-{cause}, over surface-chrome, centered. */
#ff-viewer .ff-errbox{pointer-events:auto;display:flex;flex-direction:column;align-items:center;
  gap:10px;max-width:min(300px,82%);padding:14px 16px;text-align:center;
  font:var(--fflip-font-meta);color:var(--fflip-color-ink-primary);
  background:var(--fflip-color-surface-chrome);border:1px solid var(--fflip-color-border-hairline);
  border-radius:var(--fflip-radius-md);box-shadow:0 8px 24px rgba(0,0,0,.35)}
#ff-viewer .ff-eside .ff-errbox{position:static;transform:none}
#ff-viewer .ff-page .ff-errbox{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);z-index:4}
#ff-viewer .ff-errmsg{margin:0;line-height:1.45}
#ff-viewer .ff-errbox .ff-retry{position:static;transform:none}
#ff-viewer .ff-errcode{font:10px/1.3 ui-monospace,SFMono-Regular,Menlo,monospace;
  color:var(--fflip-color-ink-secondary,#999);letter-spacing:.08em}

/* Page: placeholder = manifest dominantColor + blurred thumb, the
   final image fades on top (blur-up, never a blank page) */
#ff-viewer .ff-page{position:relative;margin:0;overflow:hidden;background:#000;
  filter:drop-shadow(0 18px 34px rgba(0,0,0,.45))}
#ff-viewer .ff-page img{display:block}
#ff-viewer .ff-page .ff-thumb{position:absolute;inset:0;width:100%;height:100%;
  object-fit:cover;filter:blur(10px);transform:scale(1.06);opacity:.85}
#ff-viewer .ff-page .ff-read{position:relative;width:100%;height:100%;object-fit:contain;
  opacity:0;transition:opacity .22s ease}
#ff-viewer .ff-page .ff-read.on{opacity:1}
/* reduced-motion (UX-DR-49): blur-up → short fade, chrome
   transitions → instant (the 3D flip → instant turnTo goes in JS) */
@media (prefers-reduced-motion:reduce){
  #ff-viewer .ff-page .ff-read{transition-duration:.12s}
  #ff-viewer .ff-flip,#ff-viewer .ff-page,#ff-viewer .ff-cluster,
  #ff-viewer .ff-drawer,#ff-viewer .ff-dveil,
  #ff-viewer .ff-hotlayer,#ff-viewer .ff-errlayer,#ff-viewer .ff-panlayer{transition:none!important}
  /* static shimmer: the loading state is communicated without
     motion (4.9) */
  #ff-viewer .ff-load::before{animation:none}
}

/* PDF hotspots (links/goto/video): invisible at rest, the design
   text already suggests them, with subtle affordance on hover and
   focus. */
#ff-viewer .ff-hotspot{position:absolute;z-index:2;cursor:pointer;border-radius:2px;
  pointer-events:auto}
/* hit-area ≥44px even if the manifest visual rect is smaller
   (UX-DR-50): the ::after grows only when width/height falls below the
   floor, the visible hairline stays the real PDF rect */
#ff-viewer .ff-hotspot::after{content:"";position:absolute;
  inset:min(0px,calc((100% - max(var(--fflip-space-tap-target),44px))/2))}
/* permanent faint accent hairline on hover-capable pointers
   (UX-DR-17), inset shadow so layout does not move, on touch
   (hover:none) nothing is painted, the hotspot is completely
   invisible */
@media (hover:hover){
  #ff-viewer .ff-hotspot{box-shadow:inset 0 0 0 1px rgba(143,180,232,.28);
    box-shadow:inset 0 0 0 1px color-mix(in srgb, var(--fflip-color-accent) 30%, transparent)}
}
#ff-viewer .ff-hotspot:hover{background:rgba(143,180,232,.14)}
#ff-viewer .ff-hotspot:focus-visible{outline:2px solid var(--fflip-color-accent);
  outline-offset:1px;box-shadow:0 0 0 4px var(--ff-halo);
  background:rgba(143,180,232,.14)}

/* Invisible selectable text layer (16.2): word spans in % over the
   page box, inside the same wrapper that takes the zoom transform —
   scale and resize come for free, same technique as the hotlayer
   (UX-DR-17). The container ignores the pointer so page gestures keep
   the surface, each word re-enables it: a drag born on text selects,
   anywhere else flips/pans (AD-13). aria-hidden + no tabindex: the
   accessible route stays the landing's <details>; Ctrl+A and visual
   selection still reach the text for copying. */
#ff-viewer .ff-textlayer{position:absolute;inset:0;z-index:1;pointer-events:none;
  container-type:size;white-space:pre;font-size:0;
  user-select:text;-webkit-user-select:text}
/* font-size:0 + transparent selection on the container: the whitespace
   text nodes between spans (the copy separators) form anonymous boxes
   at the layer origin — zero-size and unpaintable */
#ff-viewer .ff-textlayer::selection{background:transparent;color:transparent}
#ff-viewer .ff-tspan{position:absolute;color:transparent;white-space:nowrap;
  line-height:1;pointer-events:auto;cursor:text;transform-origin:0 0}
/* rotated runs (no angle in the JSON): the bbox already is the correct
   strip, the text flows top→bottom */
#ff-viewer .ff-tspan.ff-tvert{writing-mode:vertical-rl}
/* honest highlight: translucent accent, the printed glyph stays
   readable beneath; the text itself never becomes visible */
#ff-viewer .ff-tspan::selection{background:rgba(143,180,232,.5);
  background:color-mix(in srgb,var(--fflip-color-accent) 55%,transparent);
  color:transparent}
/* selection lives only inside the layer: the rest of the stage
   (chrome, canvas, hotspots) keeps selection off; the page field
   input stays editable */
#ff-viewer .ff-stage{user-select:none;-webkit-user-select:none}
#ff-viewer .ff-textlayer,#ff-viewer input{user-select:text;-webkit-user-select:text}

/* Search-hit overlays (21.2): empty geometry divs at span positions,
   inside the same transformed wrapper the text layer uses — zoom and
   resize come free. pointer-events:none always: they never steal a
   page gesture nor a text selection drag. Translucent accent over the
   printed glyph — same honest-highlight treatment as ::selection,
   readable beneath, and since they carry no text they paint even
   where selection is disabled (21.3) without weakening it. */
#ff-viewer .ff-hllayer{position:absolute;inset:0;z-index:1;pointer-events:none}
#ff-viewer .ff-thl{position:absolute;pointer-events:none;
  background:rgba(143,180,232,.45);
  background:color-mix(in srgb,var(--fflip-color-accent) 50%,transparent);
  border-radius:2px}

/* In-book search panel (21.2): the field keeps the skin's raised
   surface, results are full-width rows like the index entries —
   page label on top, snippet under it with the hit in <mark> */
/* :not([hidden]) guard — author display would otherwise defeat the
   hidden attribute the tab pattern toggles */
#ff-viewer .ff-spanel:not([hidden]){display:flex;flex-direction:column}
#ff-viewer .ff-sfield{padding-bottom:10px}
#ff-viewer .ff-sinput{width:100%;box-sizing:border-box;font:var(--fflip-font-ui);
  color:var(--fflip-color-ink-primary);background:var(--fflip-color-surface-raised);
  border:1px solid var(--fflip-color-border-hairline);border-radius:var(--fflip-radius-md);
  padding:9px 12px;min-height:var(--fflip-space-tap-target)}
#ff-viewer .ff-sinput:focus-visible{outline:2px solid var(--fflip-color-accent);outline-offset:1px}
#ff-viewer .ff-sinput::placeholder{color:var(--fflip-color-ink-disabled)}
#ff-viewer .ff-sstatus{font:var(--fflip-font-meta);color:var(--fflip-color-ink-secondary);
  padding:2px 2px 8px}
#ff-viewer .ff-slist{list-style:none;margin:0;padding:0;overflow-y:auto}
#ff-viewer .ff-sr-hit{display:block;width:100%;text-align:left;background:none;border:0;
  cursor:pointer;padding:8px 10px;min-height:var(--fflip-space-tap-target);
  border-radius:var(--fflip-radius-sm)}
#ff-viewer .ff-sr-hit:hover{background:var(--fflip-color-surface-raised)}
#ff-viewer .ff-sr-hit:focus-visible{outline:2px solid var(--fflip-color-accent);outline-offset:1px}
#ff-viewer .ff-sr-page{display:block;font:var(--fflip-font-meta);font-weight:600;
  color:var(--fflip-color-accent);padding-bottom:2px}
#ff-viewer .ff-sr-snip{display:block;font:var(--fflip-font-meta);
  color:var(--fflip-color-ink-primary);line-height:1.45}
#ff-viewer .ff-sr-snip mark{background:none;color:inherit;font-weight:700;
  text-decoration:underline;text-decoration-color:var(--fflip-color-accent);
  text-underline-offset:2px}

/* z-index map inside #ff-viewer (the overlay is 100000 vs. the site;
   .ff-stage is position:relative without z-index → its children
   compete directly in the viewer's stacking context):
     1 textlayer · 2 hotlayer/hotspot · 3 tapzone + .ff-load shimmer
     4 in-page retry/errbox · 5 panlayer · 6 errlayer + ff-ad (20.6:
       the interstitial is a step of the flow below the chrome, never
       a layer over the page being read)
     7 edgegroup arrows + bottom cluster + ff-credit (vmenu lives in
       that context)
     8 dveil — the drawer's dim veil, a capture-layer like vscrim
     9 drawer — modal sheet: above every reader surface (incl. arrows)
    10 vmodal — intentionally top: the video owns the stage
    40 toast — intentionally top: the confirmation reads over anything */

/* Side drawer (UX-DR-16): left overlay subsurface, 320px
   drawer-width over surface-chrome, enters with a slide (RM: no
   slide), visibility:hidden removes it from the a11y tree when
   closed */
#ff-viewer .ff-drawer{position:absolute;left:0;top:0;bottom:0;width:320px;z-index:9;
  display:flex;flex-direction:column;background:var(--fflip-color-surface-chrome);
  background:color-mix(in srgb, var(--fflip-color-surface-chrome) 92%, transparent);
  backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px);
  border-right:1px solid var(--fflip-color-border-hairline);
  transform:translateX(-105%);visibility:hidden;
  transition:transform .25s ease,visibility 0s linear .25s}
#ff-viewer .ff-drawer.on{transform:none;visibility:visible;
  transition:transform .25s ease} /* no visibility transition on open, 
  instant flip: focus to the tab works on the same tick */
/* Drawer veil: the drawer reads as a modal sheet, same capture-layer
   idea as .ff-vscrim — it dims the whole stage and a tap on it closes
   the drawer. While open nothing under it is reachable (arrows, bar,
   hotspots, text layer); pointer-events only in .on so the resting
   transparent layer never blocks the reader. */
#ff-viewer .ff-dveil{position:absolute;inset:0;z-index:8;
  background:var(--fflip-color-scrim);opacity:0;pointer-events:none;
  transition:opacity .25s ease}
#ff-viewer .ff-dveil.on{opacity:var(--fflip-color-scrim-alpha);pointer-events:auto}
#ff-viewer .ff-dhead{display:flex;align-items:center;gap:4px;
  border-bottom:1px solid var(--fflip-color-border-hairline);padding:0 6px 0 0}
#ff-viewer .ff-tabs{display:flex;flex:1}
#ff-viewer .ff-tabs [role=tab]{flex:1;background:none;border:0;cursor:pointer;
  font:var(--fflip-font-ui);color:var(--fflip-color-ink-secondary);
  min-height:max(var(--fflip-space-tap-target),44px);position:relative}
#ff-viewer .ff-tabs [role=tab][aria-selected="true"]{color:var(--fflip-color-ink-primary)}
#ff-viewer .ff-tabs [role=tab][aria-selected="true"]::after{content:"";
  position:absolute;left:24px;right:24px;bottom:0;height:2px;
  background:var(--fflip-color-accent)}
#ff-viewer .ff-dpanel{flex:1;overflow-y:auto;padding:10px 12px 16px;overscroll-behavior:contain}
/* Contenido, hierarchical index from the manifest */
#ff-viewer .ff-index{list-style:none;margin:0;padding:0}
#ff-viewer .ff-ientry{display:block;width:100%;text-align:left;background:none;border:0;
  cursor:pointer;font:var(--fflip-font-meta);color:var(--fflip-color-ink-primary);
  padding:10px 12px;min-height:max(var(--fflip-space-tap-target),44px);
  border-radius:var(--fflip-radius-sm)}
#ff-viewer .ff-ientry:hover{background:var(--fflip-color-surface-raised)}
/* Pages, thumbnail grid, the active one carries a 2px accent ring
   (drawer-thumb-active) + aria-current */
#ff-viewer .ff-dgrid{display:grid;grid-template-columns:repeat(3,1fr);gap:10px}
#ff-viewer .ff-thumb{position:relative;background:var(--fflip-color-surface-raised);
  border:0;cursor:pointer;padding:0;border-radius:var(--fflip-radius-sm);
  overflow:visible;aspect-ratio:7/10}
#ff-viewer .ff-thumb img{width:100%;height:100%;object-fit:cover;display:block;
  border-radius:var(--fflip-radius-sm)}
#ff-viewer .ff-thumb .ff-tnum{position:absolute;left:4px;bottom:4px;
  font:var(--fflip-font-meta);font-size:11px;color:var(--fflip-color-ink-primary);
  background:rgba(23,26,31,.8);border-radius:4px;padding:1px 5px}
#ff-viewer .ff-thumb.on{box-shadow:0 0 0 2px var(--fflip-color-accent)}

/* Video hotspot, ▶ 56px button surface-raised/rounded.full over the
   printed still (Publitas pattern, UX-DR-19). Centered on the link
   zone, the transparent anchor remains the full hit-area. */
#ff-viewer .ff-vplay{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);
  width:56px;height:56px;border-radius:var(--fflip-radius-full);
  background:var(--fflip-color-surface-raised);color:var(--fflip-color-ink-primary);
  display:flex;align-items:center;justify-content:center;
  box-shadow:0 2px 10px rgba(0,0,0,.4)}

/* Video modal (UX-DR-20): the scrim is a capture-layer, it blocks
   all page gestures while the modal is open */
#ff-viewer .ff-vmodal{position:absolute;inset:0;z-index:10}
#ff-viewer .ff-vscrim{position:absolute;inset:0;
  background:var(--fflip-color-scrim);opacity:var(--fflip-color-scrim-alpha)}
#ff-viewer .ff-vdlg{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);
  width:min(90vw,calc(80vh*16/9));background:var(--fflip-color-surface-raised);
  border-radius:var(--fflip-radius-lg);padding:10px;
  border:1px solid var(--fflip-color-border-hairline);
  box-shadow:0 12px 48px rgba(0,0,0,.55)}
#ff-viewer .ff-vhead{display:flex;align-items:center;justify-content:space-between;
  gap:8px;padding:2px 4px 10px}
#ff-viewer .ff-vtitle{margin:0;font:var(--fflip-font-meta);
  color:var(--fflip-color-ink-primary)}
#ff-viewer .ff-vframe{aspect-ratio:16/9;background:#000;
  border-radius:var(--fflip-radius-md);overflow:hidden}
#ff-viewer .ff-vframe iframe{width:100%;height:100%;border:0;display:block}
#ff-viewer .ff-verr{padding:28px 16px;text-align:center;
  color:var(--fflip-color-ink-secondary);font:var(--fflip-font-meta)}
#ff-viewer .ff-verr p{margin:0 0 12px}

/* Page arrows on the edges, one group per side (4.8): start/end +
   previous/next, vertically centered column */
#ff-viewer .ff-edgegroup{position:absolute;top:50%;transform:translateY(-50%);z-index:7;
  display:flex;flex-direction:column;gap:10px}
#ff-viewer .ff-eg-l{left:12px}
#ff-viewer .ff-eg-r{right:12px}
#ff-viewer .ff-edge{width:max(var(--fflip-space-tap-target),44px);height:max(var(--fflip-space-tap-target),44px);border-radius:var(--fflip-radius-md);
  border:0;background:var(--fflip-color-surface-chrome);
  background:color-mix(in srgb, var(--fflip-color-surface-chrome) 78%, transparent);
  color:var(--fflip-color-ink-primary);
  display:flex;align-items:center;justify-content:center;cursor:pointer}
#ff-viewer .ff-edge:hover{background:var(--fflip-color-surface-chrome);
  background:color-mix(in srgb, var(--fflip-color-surface-chrome) 92%, transparent)}
#ff-viewer .ff-edge svg{width:24px;height:24px;stroke:currentColor;stroke-width:2;
  fill:none;stroke-linecap:round;stroke-linejoin:round}
#ff-viewer .ff-edge[disabled]{opacity:.3;pointer-events:none}

/* Persistent exit control (QA-PO ronda 2): fixed outside the bottom
   cluster so mobile auto-hide never strands the reader inside the
   viewer. It uses the same chrome surface and stays below drawer/modal
   layers; the visible word keeps the affordance discoverable. */
#ff-viewer .ff-exit{position:absolute;top:calc(10px + env(safe-area-inset-top,0px));
  left:calc(10px + env(safe-area-inset-left,0px));z-index:7;
  min-height:max(var(--fflip-space-tap-target),44px);padding:0 13px 0 9px;border:0;
  border-radius:var(--fflip-radius-full);border:1px solid var(--fflip-color-border-hairline);
  background:var(--fflip-color-surface-chrome);
  background:color-mix(in srgb, var(--fflip-color-surface-chrome) 84%, transparent);
  backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px);
  color:var(--fflip-color-ink-primary);font:var(--fflip-font-ui);cursor:pointer;
  display:inline-flex;align-items:center;gap:4px;box-shadow:0 2px 12px rgba(0,0,0,.28)}
#ff-viewer .ff-exit:hover{background:var(--fflip-color-surface-raised);
  background:color-mix(in srgb, var(--fflip-color-surface-raised) 92%, transparent)}
#ff-viewer .ff-exit svg{flex:0 0 auto}

/* Floating bottom-right action cluster, surface-chrome ~88% +
   blur(10px), hairline on the edge touching the page (UX-DR-12) */
#ff-viewer .ff-cluster{position:absolute;right:32px;bottom:24px;height:var(--fflip-space-bar-height);
  z-index:7; /* above panlayer(5): with zoom the bar always gets the
     click */
  display:flex;align-items:center;gap:2px;padding:0 10px;
  border-radius:var(--fflip-radius-md);background:var(--fflip-color-surface-chrome);
  background:color-mix(in srgb, var(--fflip-color-surface-chrome) 88%, transparent);
  backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px);
  border:1px solid var(--fflip-color-border-hairline);
  transition:transform .25s ease,opacity .25s ease}
#ff-viewer .ff-chrome-toggle{flex:0 0 auto;display:inline-flex;align-items:center;gap:6px}
#ff-viewer .ff-chrome-toggle svg{transition:transform .2s ease}
#ff-viewer .ff-chrome-toggle .ff-ct-off{display:none}
#ff-viewer.ff-chrome-collapsed .ff-chrome-toggle .ff-ct-on{display:none}
#ff-viewer.ff-chrome-collapsed .ff-chrome-toggle .ff-ct-off{display:inline}
/* QA-PO ronda 2: on desktop the cluster collapses into its chevron.
   The control stays inside the bar so expand remains visible; mobile
   never uses this state and keeps tap-to-hide. */
#ff-viewer.ff-chrome-collapsed .ff-cluster{padding:0 4px}
#ff-viewer.ff-chrome-collapsed .ff-cluster > :not(#ff-chrome-toggle){display:none !important}
#ff-viewer.ff-chrome-collapsed .ff-chrome-toggle svg{transform:rotate(180deg)}
/* Mobile auto-hide (UX-DR-13): the bar retracts ~3s without
   interaction, the class is set by JS only under pointer:coarse
   (desktop never) */
#ff-viewer.ff-chrome-hidden .ff-cluster{transform:translateY(110%);opacity:0;pointer-events:none}
#ff-viewer .ff-cluster .ff-pind{font:var(--fflip-font-meta);letter-spacing:.02em;
  color:var(--fflip-color-ink-secondary);padding:0 10px;white-space:nowrap}
/* Direct jump field (4.8) as expandable indicator (16.4, dFlip
   display→input→gotoPage): the {n} presents as plain text — no box,
   transparent, hugging its digits (field-sizing, size=2 fallback) —
   and grows into an editable field on :focus over surface-raised.
   The collapse IS the blur: no JS state, no duplicate control. The
   hit area stays ≥44px even in text disguise (UX-DR-7). */
#ff-viewer .ff-pind #ff-pnum{width:auto;min-inline-size:2ch;max-inline-size:9ch;
  field-sizing:content;min-height:var(--fflip-space-tap-target);
  padding:0 6px;margin:0;border:0;border-radius:var(--fflip-radius-sm);
  background:transparent;color:var(--fflip-color-ink-primary);
  font:inherit;letter-spacing:inherit;text-align:center;outline:none;
  cursor:text;transition:background .15s ease}
@media (hover:hover){
  /* fine-pointer affordance only — touch has no hover, and a sticky
     :hover would leave the collapsed field looking armed after a tap */
  #ff-viewer .ff-pind #ff-pnum:hover:not(:focus){
    background:var(--fflip-color-surface-raised)}
}
#ff-viewer .ff-pind #ff-pnum:focus{min-inline-size:3.4em;padding:4px 12px;
  font-size:16px; /* ≥16px: iOS does not auto-zoom the page on focus */
  background:var(--fflip-color-surface-raised);
  box-shadow:inset 0 0 0 1px var(--fflip-color-border-hairline)}
@media (prefers-reduced-motion:reduce){
  #ff-viewer .ff-pind #ff-pnum{transition:none}
}
#ff-viewer .ff-cluster .ff-sep{width:1px;height:26px;background:var(--fflip-color-border-hairline);margin:0 6px}
/* min-height (not height): text survives 200% zoom without
   truncation (UX-DR-53) */
#ff-viewer .ff-btn{min-height:max(var(--fflip-space-tap-target),44px);min-width:max(var(--fflip-space-tap-target),44px);padding:0 14px;border:0;
  border-radius:var(--fflip-radius-md);
  background:transparent;color:var(--fflip-color-ink-primary);font:var(--fflip-font-ui);
  cursor:pointer;display:inline-flex;align-items:center;justify-content:center}
#ff-viewer .ff-btn:hover{background:var(--fflip-color-surface-raised)}
#ff-viewer .ff-btn[disabled]{color:var(--fflip-color-ink-disabled);pointer-events:none}
#ff-viewer .ff-cnav{display:none;padding:0 10px} /* on desktop the edge
     arrows rule */

/* "Powered by FolioFlip" chrome credit (14.5, lic.§6): free-plan credit
   pinned bottom-right of the chrome, inside the stage's dead padding
   under the floating bar — it never sits on a page (fixed bottom-right
   badge, the dFlip equivalent). pointer-events:none on the span: only
   the link itself is clickable, book gestures and hotspots stay intact. */
#ff-viewer .ff-credit{position:absolute;left:32px;bottom:6px;z-index:7;
  pointer-events:none;font:var(--fflip-font-meta);font-size:11px;
  letter-spacing:.02em;line-height:1.4}
#ff-viewer .ff-credit a{pointer-events:auto;color:var(--fflip-color-ink-secondary);
  opacity:.55;text-decoration:none}
#ff-viewer .ff-credit a:hover{opacity:1;color:var(--fflip-color-ink-primary);
  text-decoration:underline}
#ff-viewer .ff-credit a:focus-visible{opacity:1}

/* Client branding (20.1, lic.§9): the publisher's own mark in the same
   chrome zone the credit uses — bottom-left inside the stage's dead
   padding, never on a page. Pro builds the content; free only dresses it.
   pointer-events:none on the whole span (no link, nothing to tap): book
   gestures and hotspots stay intact underneath. Inherits the chrome
   typography — the brand reads as part of the reader, not as a sticker. */
#ff-viewer .ff-brand{position:absolute;left:32px;bottom:6px;z-index:7;
  pointer-events:none;display:flex;align-items:center;gap:6px;
  font:var(--fflip-font-meta);font-size:13px;letter-spacing:.02em;line-height:1.4;
  color:var(--fflip-color-ink-secondary)}
#ff-viewer .ff-brand img{display:block;max-height:26px;width:auto;max-width:180px;
  object-fit:contain;opacity:.9}
#ff-viewer .ff-brand .ff-brand-txt{opacity:.75;white-space:nowrap;
  overflow:hidden;text-overflow:ellipsis;max-width:200px}

/* View modes menu (cap_modos, UX-DR-46): popover over the bar, same
   skin as the cluster, the active item carries an accent mark */
#ff-viewer .ff-vmenu{position:absolute;right:10px;bottom:calc(100% + 8px);
  display:flex;flex-direction:column;min-width:190px;padding:6px;z-index:30;
  border-radius:var(--fflip-radius-md);background:var(--fflip-color-surface-chrome);
  background:color-mix(in srgb, var(--fflip-color-surface-chrome) 92%, transparent);
  backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px);
  border:1px solid var(--fflip-color-border-hairline);
  box-shadow:0 12px 32px rgba(0,0,0,.45)}
#ff-viewer .ff-vmenu button{display:flex;align-items:center;gap:10px;width:100%;
  min-height:40px;padding:8px 12px;border:0;border-radius:var(--fflip-radius-sm);
  background:transparent;color:var(--fflip-color-ink-primary);
  font:var(--fflip-font-meta);letter-spacing:.02em;text-align:left;cursor:pointer}
#ff-viewer .ff-vmenu button:hover{background:var(--fflip-color-surface-raised)}
#ff-viewer .ff-vmenu button::before{content:"";width:18px;flex:0 0 18px;text-align:center;
  color:var(--fflip-color-accent);font-weight:700}
#ff-viewer .ff-vmenu button[aria-checked="true"]::before{content:"✓"}

/* Error message inside the stage */
#ff-viewer .ff-fail{font:var(--fflip-font-ui);color:var(--fflip-color-ink-secondary);text-align:center;
  display:flex;flex-direction:column;align-items:center;gap:10px;max-width:min(340px,84%)}
#ff-viewer .ff-fail button{margin-top:4px}
#ff-viewer .ff-fail .ff-errmsg{color:var(--fflip-color-ink-primary)}

/* Confirmation toast (UX-DR-24/55): centered pill over the bar, 
   the spoken copy goes through #ff-live, this is the visual
   confirmation */
#ff-viewer .ff-toast{position:absolute;left:50%;bottom:calc(var(--fflip-space-bar-height) + 40px);
  transform:translateX(-50%) translateY(8px);padding:10px 18px;border-radius:var(--fflip-radius-md);
  background:var(--fflip-color-surface-raised);color:var(--fflip-color-ink-primary);
  font:var(--fflip-font-ui);box-shadow:0 4px 18px rgba(0,0,0,.35);
  border:1px solid var(--fflip-color-border-hairline);
  opacity:0;pointer-events:none;transition:opacity .2s ease,transform .2s ease;z-index:40}
#ff-viewer .ff-toast.on{opacity:1;transform:translateX(-50%) translateY(0)}

/* Visible focus (UX-DR-26): dual mechanism, 2px accent outline +
   2px offset PLUS a second ring of the preset's opposite tint →
   ≥3:1 contrast on any surface, including light photography */
#ff-viewer :focus-visible{outline:2px solid var(--fflip-color-accent);outline-offset:2px;
  box-shadow:0 0 0 4px var(--ff-halo)}

@media (max-width:720px){
  #ff-viewer .ff-chrome-toggle{display:none}
  /* mobile 16px gutters, the bottom margin clears the docked bar
     (UX-DR-27) */
  #ff-viewer .ff-stage{padding:16px 16px 72px}
  /* the mobile bar replaces the edge arrows (mobile mock, 56px
     bar) */
  #ff-viewer .ff-edgegroup{display:none}
  /* the drawer is a desktop subsurface (UX-DR-16), on mobile there is
     no room for 320px of side panel */
  #ff-viewer #ff-dbtn{display:none}
  #ff-viewer .ff-drawer{display:none}
  #ff-viewer .ff-cluster{left:0;right:0;bottom:0;height:var(--fflip-space-bar-height);
    border-radius:0;border:0;border-top:1px solid var(--fflip-color-border-hairline);
    background:var(--fflip-color-surface-chrome);
    background:color-mix(in srgb, var(--fflip-color-surface-chrome) 90%, transparent);padding:0 8px}
  #ff-viewer .ff-cluster .ff-pind{flex:1;text-align:center}
  #ff-viewer .ff-cnav{display:inline-flex}
  /* the docked bar owns the bottom edge: the credit rides the dead gap
     between its top edge and the stage's 72px bottom padding — still
     chrome, still never on a page */
  #ff-viewer .ff-credit{left:8px;right:auto;bottom:calc(var(--fflip-space-bar-height) + 4px)}
  /* the client brand shares the credit's zone (20.1): same ride over the
     docked bar, same dead gap, never on a page */
  #ff-viewer .ff-brand{left:8px;right:auto;bottom:calc(var(--fflip-space-bar-height) + 4px)}
}

/* QA-PO FIX D: landscape phones (coarse pointer, short height) — the
   >720px width path left them with the desktop floating cluster: it
   covered the page and never felt like mobile chrome. Same docked bar
   as portrait mobile but slimmer (48px) since landscape height is the
   scarce axis; stage padding shrinks to match. */
@media (pointer:coarse) and (min-width:721px) and (max-height:520px){
  #ff-viewer .ff-chrome-toggle{display:none}
  #ff-viewer .ff-stage{padding:12px 12px 58px}
  #ff-viewer .ff-edgegroup{display:none}
  #ff-viewer #ff-dbtn{display:none}
  #ff-viewer .ff-drawer{display:none}
  #ff-viewer .ff-cluster{left:0;right:0;bottom:0;height:48px;
    border-radius:0;border:0;border-top:1px solid var(--fflip-color-border-hairline);
    background:var(--fflip-color-surface-chrome);
    background:color-mix(in srgb, var(--fflip-color-surface-chrome) 90%, transparent);padding:0 6px}
  #ff-viewer .ff-cluster .ff-pind{flex:1;text-align:center}
  #ff-viewer .ff-cluster .ff-btn{min-height:40px;min-width:40px;padding:0 10px}
  #ff-viewer .ff-cnav{display:inline-flex}
  #ff-viewer .ff-credit,#ff-viewer .ff-brand{left:8px;right:auto;bottom:calc(48px + 4px)}
  #ff-viewer .ff-toast{bottom:calc(48px + 20px)}
}

/* 20.6 ad interstitial: the surface IS a step of the reading flow,
   never a layer over the page being read — full-stage at z 6, below
   the chrome (7): navigation and close stay visible and operable.
   Always announced as advertising: visible tag + complementary role. */
#ff-viewer .ff-ad{position:absolute;inset:0;z-index:6;display:flex;flex-direction:column;
  align-items:center;justify-content:center;gap:18px;padding:28px;
  background:var(--fflip-color-surface-viewer);color:var(--fflip-color-ink-primary)}
#ff-viewer .ff-ad[hidden]{display:none}
#ff-viewer .ff-ad-tag{font:var(--fflip-font-meta);letter-spacing:.14em;text-transform:uppercase;
  color:var(--fflip-color-ink-secondary);border:1px solid var(--fflip-color-border-hairline);
  border-radius:var(--fflip-radius-sm);padding:.3em .8em}
#ff-viewer .ff-ad-body{max-width:min(92%,760px);max-height:64vh;overflow:auto}
/* QA-PO FIX 8: the close control must read as a control over ANY
   creative — opaque chip, visible border, separation shadow and a 20px
   glyph inside the 44px target. Transparent-over-image was invisible
   on busy or dark ads. Same treatment for ad/form/wall closes. */
#ff-viewer .ff-ad-close{position:absolute;top:16px;right:16px;z-index:2;width:max(var(--fflip-space-tap-target),44px);
  height:max(var(--fflip-space-tap-target),44px);display:inline-flex;align-items:center;justify-content:center;
  padding:0;border-radius:var(--fflip-radius-full);border:1px solid var(--fflip-color-border-strong,var(--fflip-color-ink-secondary));
  background:var(--fflip-color-surface-raised);color:var(--fflip-color-ink-primary);cursor:pointer;
  box-shadow:0 1px 6px rgba(0,0,0,.45)}
#ff-viewer .ff-ad-close svg{width:20px;height:20px;flex:0 0 auto}
#ff-viewer .ff-ad-close:hover{background:var(--fflip-color-surface-viewer)}
#ff-viewer .ff-ad-close:focus-visible{outline:2px solid var(--fflip-color-accent);outline-offset:2px}

/* 21.10 form steps: same surface discipline as the interstitial — a
   step of the reading flow at z 6, never a layer over the page, close
   always visible. The card is the reading width, the fields are the
   accessible floor: visible labels, ≥1rem inputs, ≥48px tap targets. */
#ff-viewer .ff-visually-hidden{position:absolute;width:1px;height:1px;padding:0;margin:-1px;
  overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0}
#ff-viewer .ff-form{position:absolute;inset:0;z-index:6;display:flex;
  align-items:center;justify-content:center;padding:28px;
  background:var(--fflip-color-surface-viewer);color:var(--fflip-color-ink-primary)}
#ff-viewer .ff-form[hidden]{display:none}
#ff-viewer .ff-form-card{position:relative;width:min(92%,520px);max-height:calc(100% - 8px);overflow:auto;
  padding:26px 26px 22px;border:1px solid var(--fflip-color-border-hairline);
  border-radius:var(--fflip-radius-md,8px);background:var(--fflip-color-surface-raised)}
#ff-viewer .ff-form-close{position:absolute;top:10px;right:10px;z-index:2;width:max(var(--fflip-space-tap-target),44px);
  height:max(var(--fflip-space-tap-target),44px);display:inline-flex;align-items:center;justify-content:center;
  padding:0;border-radius:var(--fflip-radius-full);border:1px solid var(--fflip-color-border-strong,var(--fflip-color-ink-secondary));
  background:var(--fflip-color-surface-raised);color:var(--fflip-color-ink-primary);cursor:pointer;
  box-shadow:0 1px 6px rgba(0,0,0,.45)}
#ff-viewer .ff-form-close svg{width:20px;height:20px;flex:0 0 auto}
#ff-viewer .ff-form-close:hover{background:var(--fflip-color-surface-viewer)}
#ff-viewer .ff-form-close:focus-visible{outline:2px solid var(--fflip-color-accent);outline-offset:2px}
#ff-viewer .ff-form-title{margin:0 44px 4px 0;font:var(--fflip-font-title,600 1.25rem/1.3 inherit)}
#ff-viewer .ff-form-intro{margin:.2em 0 1em;color:var(--fflip-color-ink-secondary);font-size:.95rem}
#ff-viewer .ff-form-row{margin:0 0 14px;border:0;padding:0}
#ff-viewer .ff-form-row>label,#ff-viewer .ff-form-row>legend{display:block;font-size:.95rem;
  font-weight:600;margin:0 0 5px;padding:0}
#ff-viewer .ff-form-row input[type=text],#ff-viewer .ff-form-row input[type=email],
#ff-viewer .ff-form-row textarea{display:block;width:100%;box-sizing:border-box;
  font-size:1rem;line-height:1.4;padding:.6em .7em;min-height:44px;
  border:1px solid var(--fflip-color-border-hairline);border-radius:var(--fflip-radius-sm);
  background:var(--fflip-color-surface-viewer);color:var(--fflip-color-ink-primary)}
#ff-viewer .ff-form-row textarea{resize:vertical;min-height:4.5em}
#ff-viewer .ff-form-row input:focus-visible,#ff-viewer .ff-form-row textarea:focus-visible{
  outline:2px solid var(--fflip-color-accent);outline-offset:1px}
#ff-viewer .ff-form-opt{display:flex;align-items:center;gap:.5em;min-height:44px;
  font-size:1rem;font-weight:400;cursor:pointer}
#ff-viewer .ff-form-opt input{width:1.15em;height:1.15em;margin:0}
/* the honeypot is invisible without display:none (bots probe for it):
   clipped, zero-sized, out of the tab order and hidden from AT */
#ff-viewer .ff-form-hp{position:absolute;width:1px;height:1px;overflow:hidden;
  clip:rect(0 0 0 0);white-space:nowrap;opacity:0;pointer-events:none}
#ff-viewer .ff-form-status{min-height:1.2em;font-size:.9rem;color:var(--fflip-color-ink-secondary);margin:2px 0 8px}
#ff-viewer .ff-form-send,#ff-viewer .ff-form-donate{display:inline-flex;align-items:center;justify-content:center;
  min-height:max(var(--fflip-space-tap-target),44px);padding:.5em 1.6em;box-sizing:border-box;
  font-size:1rem;font-weight:600;border:0;border-radius:var(--fflip-radius-sm);cursor:pointer;
  background:var(--fflip-color-accent);color:var(--fflip-color-on-accent,#fff);text-decoration:none}
#ff-viewer .ff-form-send:disabled{opacity:.55;cursor:default}
#ff-viewer .ff-form-send:focus-visible,#ff-viewer .ff-form-donate:focus-visible{
  outline:2px solid var(--fflip-color-accent);outline-offset:2px}
#ff-viewer .ff-form-thanks{margin:1em 0;font-size:1.05rem}

/* Access-wall step at the end of a gated sample (Epic 17): same flow
   discipline as ads/forms — a step at z 6, never a layer coexisting
   with the page. The card reuses the landing gate block server-side,
   dressed here for the dark reader chrome. */
#ff-viewer .ff-wall{position:absolute;inset:0;z-index:6;display:flex;
  align-items:center;justify-content:center;padding:28px;
  background:var(--fflip-color-surface-viewer);color:var(--fflip-color-ink-primary)}
#ff-viewer .ff-wall[hidden]{display:none}
#ff-viewer .ff-wall-card{position:relative;width:min(92%,440px);max-height:calc(100% - 8px);overflow:auto;
  padding:28px 26px 24px;border:1px solid var(--fflip-color-border-hairline);
  border-radius:var(--fflip-radius-md,8px);background:var(--fflip-color-surface-raised);
  text-align:center;font-size:.95rem;line-height:1.45}
#ff-viewer .ff-wall-close{position:absolute;top:10px;right:10px;z-index:2;width:max(var(--fflip-space-tap-target),44px);
  height:max(var(--fflip-space-tap-target),44px);display:inline-flex;align-items:center;justify-content:center;
  padding:0;border-radius:var(--fflip-radius-full);border:1px solid var(--fflip-color-border-strong,var(--fflip-color-ink-secondary));
  background:var(--fflip-color-surface-raised);color:var(--fflip-color-ink-primary);cursor:pointer;
  box-shadow:0 1px 6px rgba(0,0,0,.45)}
#ff-viewer .ff-wall-close svg{width:20px;height:20px;flex:0 0 auto}
#ff-viewer .ff-wall-close:hover{background:var(--fflip-color-surface-viewer)}
#ff-viewer .ff-wall-body p{margin:.35em 0}
#ff-viewer .ff-wall-body .ff-gate-msg{font-weight:650;font-size:1.05rem}
#ff-viewer .ff-wall-body .ff-gate-sub,#ff-viewer .ff-wall-body .ff-gate-alt{color:var(--fflip-color-ink-secondary);font-size:.9rem}
#ff-viewer .ff-wall-body form{display:flex;gap:8px;margin-top:16px}
#ff-viewer .ff-wall-body input[type=password]{flex:1;min-width:0;min-height:44px;padding:.6em .7em;
  border:1px solid var(--fflip-color-border-hairline);border-radius:var(--fflip-radius-sm);
  background:var(--fflip-color-surface-viewer);color:var(--fflip-color-ink-primary);font-size:1rem}
#ff-viewer .ff-wall-body button[type=submit]{min-height:44px;padding:.5em 1.2em;border:0;
  border-radius:var(--fflip-radius-sm);background:var(--fflip-color-accent);
  color:var(--fflip-color-on-accent,#fff);font-weight:600;cursor:pointer}
#ff-viewer .ff-wall-body .ff-gate-err{color:#ffb4ab;font-size:.9rem;margin-top:.7em}
#ff-viewer .ff-wall-body a{color:var(--fflip-color-ink-primary);font-weight:600}

/* 20.5 3D cover: static treatment — thickness on the cut edge as hard
   stacked shadows, a wider support shadow and the spine shade as a
   translucent gradient. NEVER a transform on the book itself: hotspot
   hit-testing stays exact. No animation anywhere — reduced-motion is
   satisfied by construction and the class simply leaves on the first
   page turn. Flip: .ff-hs-right of the hotlayer matches the lone cover
   pixel to pixel, pointer-events:none by construction. Swipe: the
   first slot's .ff-page IS the cover. */
/* QA-PO FIX 6: reader pace control — quiet select in the chrome,
   same height as the buttons, no box of its own until focus */
#ff-viewer .ff-kspeed{align-self:center;height:32px;margin:0 2px;padding:0 2px;
  border:1px solid transparent;border-radius:var(--fflip-radius-sm);background:transparent;
  color:var(--fflip-color-ink-secondary);font-size:.8rem;cursor:pointer;max-width:4.6em}
#ff-viewer .ff-kspeed:hover,#ff-viewer .ff-kspeed:focus-visible{
  border-color:var(--fflip-color-border-hairline);color:var(--fflip-color-ink-primary);
  outline:none;background:var(--fflip-color-surface-raised)}
#ff-viewer .ff-kspeed option{color:#222;background:#fff}

#ff-viewer .ff-motor.ff-c3d .ff-hs-right{
  background:linear-gradient(to right,rgba(0,0,0,.22),rgba(0,0,0,0) 9%);
  box-shadow:1px 1px 0 rgba(20,16,12,.5),2px 2px 0 rgba(20,16,12,.32),3px 3px 0 rgba(20,16,12,.16),
    12px 16px 38px rgba(0,0,0,.42)}
#ff-viewer .ff-motor.ff-c3d .ff-swipe .ff-slot:first-child .ff-page{
  box-shadow:1px 1px 0 rgba(20,16,12,.5),2px 2px 0 rgba(20,16,12,.32),3px 3px 0 rgba(20,16,12,.16),
    12px 16px 38px rgba(0,0,0,.42),
    inset 12px 0 22px -12px rgba(0,0,0,.35)}
