/* Shared Viewer Engine Styles (used identically by Studio & Exported HTML) */
:root {
  /* Band 0–9: Stage Background & Book Stage (isolated inside #bookContainer via isolation: isolate) */
  --z-stage-bg: 0;
  --z-book: 1;
  --z-spine: 2;
  --z-book-guard: 3;

  /* Band 10–29: Viewer Floating Navigation & Footer Bar */
  --z-controls: 20;

  /* Band 30–59: Studio Workspace Layout Chrome */
  --z-studio-panel: 30;
  --z-header: 50;
  --z-studio-tooltip: 55;

  /* Band 60–79: Global Overlays & Feedback */
  --z-toast: 60;
  --z-modal: 70;

  /* Viewer Engine Chrome & Accent Tokens (consistent across Studio preview and Exported HTML) */
  --fb-chrome-bg: rgba(28, 25, 23, 0.90);
  --fb-chrome-bg-soft: rgba(28, 25, 23, 0.80);
  --fb-chrome-drawer-bg: rgba(28, 25, 23, 0.92);
  --fb-chrome-more-panel-bg: rgba(24, 21, 19, 0.98);
  --fb-chrome-pill: rgba(41, 37, 36, 0.92);
  --fb-chrome-pill-hover: rgba(255, 255, 255, 0.12);
  --fb-chrome-border: rgba(230, 225, 214, 0.20);
  --fb-chrome-divider: rgba(231, 229, 228, 0.22);
  --fb-chrome-ink: #fafaf9;
  --fb-chrome-ink-muted: #e7e5e4;
  --fb-accent: #b45309;
  --fb-accent-hover: #92400e;
  --fb-accent-soft: rgba(217, 119, 6, 0.24);
  --fb-accent-border: rgba(245, 158, 11, 0.52);
  --fb-accent-ink: #fde68a;
  --fb-link-bg: rgba(3, 105, 161, 0.08);
  --fb-link-border: rgba(3, 105, 161, 0.26);
  --fb-link-hover-bg: rgba(180, 83, 9, 0.18);
  --fb-thumb-border: rgba(230, 225, 214, 0.28);
  --fb-thumb-active-ring: rgba(180, 83, 9, 0.36);
  --fb-paper-bg: #ffffff;
  --fb-shimmer-a: #f2efe8;
  --fb-shimmer-b: #e6e1d6;
  --fb-whatsapp-bg: #047857;
  --fb-whatsapp-hover: #065f46;
}

.fb-stage-dark {
  background: radial-gradient(circle at center, #1e293b 0%, #090d16 100%);
  color: #f8fafc;
}
.fb-stage-cream {
  background: radial-gradient(circle at center, #fdf8f0 0%, #e7dec8 100%);
  color: #1c1917;
}
.fb-stage-gray {
  background: radial-gradient(circle at center, #e2e8f0 0%, #94a3b8 100%);
  color: #0f172a;
}
.fb-stage-white {
  background: radial-gradient(circle at center, #ffffff 0%, #f1f5f9 100%);
  color: #0f172a;
}
.fb-stage-light-ink {
  color: #f8fafc;
}
.fb-stage-dark-ink {
  color: #1c1917;
}

.fb-stage-wrapper {
  flex: 1 1 0%;
  min-width: 0;
  min-height: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
  container-type: inline-size;
  container-name: fb-stage;
}

.fb-viewport {
  flex: 1 1 0%;
  min-height: 0;
  position: relative;
  direction: ltr;
  overflow: hidden;
  overscroll-behavior: contain;
  touch-action: pan-y pinch-zoom;
  -webkit-overflow-scrolling: touch;
}

.fb-viewport.is-zoomed {
  overflow: auto;
  touch-action: pan-x pan-y pinch-zoom;
}

.fb-viewport.is-pan-mode,
.fb-viewport.is-pan-mode .fb-single-stage,
.fb-viewport.is-pan-mode .fb-cover-dead-guard {
  cursor: grab;
}
.fb-viewport.is-pan-mode .stf__parent,
.fb-viewport.is-pan-mode .fb-single-stage {
  -ms-touch-action: pan-x pan-y pinch-zoom;
  touch-action: pan-x pan-y pinch-zoom;
}
.fb-viewport.is-panning,
.fb-viewport.is-panning * {
  cursor: grabbing !important;
}

.fb-scroll-inner {
  min-width: 100%;
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  box-sizing: border-box;
}

.fb-viewport.is-zoomed .fb-scroll-inner {
  width: max-content;
  min-width: 100%;
  overflow: hidden;
}

@container fb-stage (max-width: 640px) {
  .fb-scroll-inner {
    padding: 6px 8px;
  }
}

.fb-book-container {
  position: relative;
  flex-shrink: 0;
  margin: 0 auto;
  isolation: isolate;
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: transform;
}

.fb-book-host {
  position: relative;
  z-index: var(--z-book);
  margin: 0 auto;
}

/* Override leaf card visuals cleanly without disturbing engine positioning */
.fb-book-host .stf__item {
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.28);
}

.fb-book-host .stf__item.--left {
  box-shadow: -8px 14px 28px -6px rgba(0, 0, 0, 0.34);
}

.fb-book-host .stf__item.--right {
  box-shadow: 8px 14px 28px -6px rgba(0, 0, 0, 0.34);
}

.fb-page-inner {
  width: 100%;
  height: 100%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--fb-paper-bg);
}

@keyframes fbPageShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.fb-page-inner.is-loading::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, var(--fb-shimmer-a) 25%, var(--fb-shimmer-b) 45%, var(--fb-shimmer-a) 65%);
  background-size: 200% 100%;
  animation: fbPageShimmer 1.3s ease-in-out infinite;
  pointer-events: none;
}

.fb-book-host .stf__item.--left .fb-page-inner::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  right: 0;
  width: 24px;
  background: linear-gradient(to left, rgba(0, 0, 0, 0.14), rgba(0, 0, 0, 0));
  pointer-events: none;
}

.fb-book-host .stf__item.--right .fb-page-inner::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 24px;
  background: linear-gradient(to right, rgba(0, 0, 0, 0.14), rgba(0, 0, 0, 0));
  pointer-events: none;
}

.fb-page-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  position: relative;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

/* Center spine highlight when spread is open and resting */
.fb-spine-overlay {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 6px;
  transform: translateX(-50%);
  background: linear-gradient(
    to right,
    rgba(0, 0, 0, 0),
    rgba(0, 0, 0, 0.24),
    rgba(255, 255, 255, 0.18),
    rgba(0, 0, 0, 0)
  );
  z-index: var(--z-spine);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.16s ease;
}

.fb-spine-overlay.is-visible {
  opacity: 1;
}

.fb-spine-overlay.is-flipping {
  opacity: 0 !important;
  transition: none;
}

.fb-stage-wrapper.is-no-spine-shadow .fb-spine-overlay {
  display: none;
}

.fb-stage-wrapper.is-no-spine-shadow .fb-book-host .stf__item .fb-page-inner::after {
  display: none;
}

/* Prevent accidental clicks/hover folds on the empty half outside closed covers */
.fb-cover-dead-guard {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 50%;
  z-index: var(--z-book-guard);
  display: none;
  background: transparent;
  cursor: default;
}

.fb-cover-dead-guard.is-guard-right {
  right: 0;
  display: block;
}

.fb-cover-dead-guard.is-guard-left {
  left: 0;
  display: block;
}

/* Clean Single-Page (Portrait) RTL Stage */
.fb-single-stage {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--fb-paper-bg);
  border-radius: 3px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.34);
  user-select: none;
  -webkit-user-select: none;
  -ms-touch-action: pan-y pinch-zoom;
  touch-action: pan-y pinch-zoom;
  cursor: pointer;
}

.fb-single-slide {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: var(--fb-paper-bg);
  will-change: transform, opacity;
  transition: transform var(--fb-single-slide-ms, 340ms) cubic-bezier(0.22, 1, 0.36, 1), opacity var(--fb-single-slide-ms, 340ms) ease, box-shadow var(--fb-single-slide-ms, 340ms) ease;
}

.fb-single-slide.is-under {
  z-index: var(--z-book);
}

.fb-single-slide.is-top {
  z-index: var(--z-spine);
  box-shadow: -10px 0 28px rgba(0, 0, 0, 0.22);
}

/* External Background Arrows (Right arrow = prev in RTL, Left arrow = next in RTL) */
.fb-nav-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: var(--z-controls);
  width: 44px;
  height: 56px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--fb-chrome-bg-soft);
  color: var(--fb-chrome-ink);
  border: 1px solid var(--fb-chrome-border);
  backdrop-filter: blur(8px);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.28);
  transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease, opacity 0.18s ease;
  cursor: pointer;
  line-height: 1;
}

.fb-nav-arrow svg {
  width: 20px;
  height: 20px;
  pointer-events: none;
}

.fb-nav-arrow:hover:not(:disabled) {
  background: var(--fb-accent);
  color: var(--fb-chrome-ink);
  border-color: var(--fb-accent-hover);
  transform: translateY(-50%) scale(1.05);
}

.fb-nav-arrow:disabled {
  opacity: 0.22;
  cursor: default;
  pointer-events: none;
}

.fb-stage-wrapper.is-side-arrows-hidden .fb-nav-arrow {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

.fb-nav-left {
  left: 10px;
}

.fb-nav-right {
  right: 10px;
}

@container fb-stage (max-width: 640px) {
  .fb-nav-arrow {
    width: 34px;
    height: 44px;
    border-radius: 10px;
  }
  .fb-nav-arrow svg {
    width: 17px;
    height: 17px;
  }
  .fb-nav-left { left: 6px; }
  .fb-nav-right { right: 6px; }
}

/* Bottom Navigation Bar */
.fb-footer {
  width: 100%;
  padding: 6px max(12px, env(safe-area-inset-right, 0px)) calc(10px + env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  direction: rtl;
  z-index: var(--z-controls);
  flex-shrink: 0;
}

.fb-slider-row {
  width: 100%;
  max-width: 440px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px;
}

.fb-slider-row.is-hidden-slider {
  display: none;
}

.fb-slider-label {
  font-size: 11px;
  font-weight: 600;
  opacity: 0.78;
}

.fb-slider {
  flex: 1;
  accent-color: var(--fb-accent);
  cursor: pointer;
  height: 6px;
}

.fb-toolbar {
  position: relative;
  background: var(--fb-chrome-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--fb-chrome-border);
  border-radius: 14px;
  padding: 5px 8px;
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.28);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 3px;
  max-width: 100%;
  color: var(--fb-chrome-ink);
}

.fb-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--fb-chrome-ink-muted);
  padding: 5px 7px;
  border-radius: 9px;
  cursor: pointer;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.fb-btn svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  pointer-events: none;
}

.fb-btn:hover:not(:disabled) {
  background: var(--fb-chrome-pill-hover);
  color: var(--fb-chrome-ink);
}

.fb-btn:disabled {
  opacity: 0.32;
  cursor: default;
}

.fb-btn.is-active {
  background: var(--fb-accent-soft);
  color: var(--fb-accent-ink);
  border-color: var(--fb-accent-border);
}

.fb-btn:focus-visible,
.fb-nav-arrow:focus-visible,
.fb-thumb-item:focus-visible,
.fb-cta-btn:focus-visible,
.fb-share-close:focus-visible,
.fb-share-copy-btn:focus-visible,
.fb-share-wa-btn:focus-visible,
.fb-designer-credit-corner a:focus-visible,
.fb-brand-subrow a:focus-visible,
.fb-share-credits a:focus-visible {
  outline: 2px solid var(--fb-accent-ink);
  outline-offset: 2px;
}

.fb-divider {
  width: 1px;
  height: 16px;
  background: var(--fb-chrome-divider);
  margin: 0 2px;
}

.fb-badge {
  background: var(--fb-chrome-pill);
  border: 1px solid var(--fb-chrome-border);
  color: var(--fb-accent-ink);
  padding: 4px 8px;
  border-radius: 9px;
  font-size: 12px;
  font-weight: 700;
  min-width: 96px;
  text-align: center;
  white-space: nowrap;
}

.fb-page-full {
  display: inline;
}

.fb-page-short {
  display: none;
}

.fb-zoom-group {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: var(--fb-chrome-pill);
  border: 1px solid var(--fb-chrome-border);
  border-radius: 9px;
  padding: 2px 4px;
}

.fb-zoom-label {
  font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  min-width: 38px;
  text-align: center;
  cursor: pointer;
  color: var(--fb-chrome-ink-muted);
}
.fb-zoom-label:hover {
  color: var(--fb-accent-ink);
}

.fb-toolbar-more-panel {
  display: contents;
}

.fb-btn-more {
  display: none;
}

/* Tier 1 (<=1020px stage, e.g. Studio with sidebar): collapse secondary text labels */
@container fb-stage (max-width: 1020px) {
  .fb-toolbar {
    padding: 4px 7px;
    gap: 2px;
  }
  .fb-btn {
    padding: 5px 6px;
  }
  .fb-badge {
    min-width: 90px;
    font-size: 11.5px;
  }
  .fb-btn-label-desktop {
    display: none;
  }
}

/* Tier 2 (<=720px stage): compact page counter (e.g. 2–3/6), tighter zoom pill & spacing BEFORE overflow menu */
@container fb-stage (max-width: 720px) {
  .fb-footer {
    padding: 5px max(8px, env(safe-area-inset-right, 0px)) calc(8px + env(safe-area-inset-bottom, 0px)) max(8px, env(safe-area-inset-left, 0px));
  }
  .fb-toolbar {
    padding: 4px 6px;
    gap: 2px;
  }
  .fb-toolbar .fb-divider {
    display: none;
  }
  .fb-btn {
    padding: 4px 5px;
    gap: 3px;
    font-size: 12px;
  }
  .fb-badge {
    min-width: 46px;
    padding: 3px 7px;
    font-size: 11.5px;
  }
  .fb-page-full {
    display: none;
  }
  .fb-page-short {
    display: inline;
  }
  .fb-zoom-group {
    padding: 1px 2px;
    gap: 0;
  }
  .fb-zoom-group .fb-btn {
    padding: 4px;
  }
  .fb-zoom-label {
    min-width: 30px;
    font-size: 10.5px;
  }
}

/* Tier 3 (<=580px stage): keep all tools on 1 row by tightening zoom group padding */
@container fb-stage (max-width: 580px) {
  .fb-toolbar {
    padding: 3px 5px;
    gap: 1px;
  }
  .fb-btn {
    padding: 4px;
  }
  .fb-zoom-group .fb-btn {
    padding: 3px;
  }
  .fb-zoom-label {
    min-width: 26px;
    font-size: 10px;
  }
}

/* Tier 4: Measured dynamic overflow (.is-overflowing) OR <=480px container fallback */
.fb-toolbar.is-overflowing {
  gap: 2px;
  padding: 4px 6px;
}
.fb-toolbar.is-overflowing .fb-divider {
  display: none;
}
.fb-toolbar.is-overflowing .fb-btn {
  padding: 5px;
}
.fb-toolbar.is-overflowing .fb-badge {
  min-width: 42px;
  padding: 3px 6px;
  font-size: 11px;
}
.fb-toolbar.is-overflowing .fb-page-full {
  display: none;
}
.fb-toolbar.is-overflowing .fb-page-short {
  display: inline;
}
.fb-toolbar.is-overflowing .fb-btn-more {
  display: inline-flex;
}
.fb-toolbar.is-overflowing .fb-toolbar-more-panel {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100cqi - 16px);
  padding: 8px;
  border-radius: 14px;
  background: var(--fb-chrome-more-panel-bg);
  backdrop-filter: blur(14px);
  border: 1px solid var(--fb-chrome-border);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.48);
  z-index: var(--z-controls);
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
  direction: rtl;
}
.fb-toolbar.is-overflowing.is-more-open .fb-toolbar-more-panel {
  display: flex;
}
.fb-toolbar.is-overflowing.is-more-open .fb-toolbar-more-panel .fb-btn {
  padding: 6px 9px;
  background: var(--fb-chrome-pill);
  border-color: var(--fb-chrome-border);
}
.fb-toolbar.is-overflowing.is-more-open .fb-toolbar-more-panel .fb-btn.is-active {
  background: var(--fb-accent-soft);
  border-color: var(--fb-accent-border);
}
.fb-toolbar.is-overflowing.is-more-open .fb-toolbar-more-panel .fb-zoom-group {
  padding: 2px 4px;
  gap: 2px;
}
.fb-toolbar.is-overflowing.is-more-open .fb-toolbar-more-panel .fb-zoom-label {
  min-width: 36px;
  font-size: 11px;
}
.fb-toolbar.is-overflowing.is-more-open .fb-toolbar-more-panel .fb-zoom-group .fb-btn {
  background: transparent;
  border-color: transparent;
  padding: 5px;
}
.fb-toolbar.is-overflowing.is-more-open .fb-toolbar-more-panel .fb-btn-label-desktop {
  display: inline;
}

@container fb-stage (max-width: 480px) {
  .fb-toolbar {
    gap: 2px;
    padding: 4px 6px;
  }
  .fb-btn {
    padding: 5px;
  }
  .fb-badge {
    min-width: 42px;
    padding: 3px 6px;
    font-size: 11px;
  }
  .fb-btn-more {
    display: inline-flex;
  }
  .fb-toolbar-more-panel {
    display: none;
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    width: max-content;
    max-width: calc(100cqi - 16px);
    padding: 8px;
    border-radius: 14px;
    background: var(--fb-chrome-more-panel-bg);
    backdrop-filter: blur(14px);
    border: 1px solid var(--fb-chrome-border);
    box-shadow: 0 14px 32px rgba(0, 0, 0, 0.48);
    z-index: var(--z-controls);
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 6px;
    direction: rtl;
  }
  .fb-toolbar.is-more-open .fb-toolbar-more-panel {
    display: flex;
  }
  .fb-toolbar.is-more-open .fb-toolbar-more-panel .fb-btn {
    padding: 6px 9px;
    background: var(--fb-chrome-pill);
    border-color: var(--fb-chrome-border);
  }
  .fb-toolbar.is-more-open .fb-toolbar-more-panel .fb-btn.is-active {
    background: var(--fb-accent-soft);
    border-color: var(--fb-accent-border);
  }
  .fb-toolbar.is-more-open .fb-toolbar-more-panel .fb-zoom-group {
    padding: 2px 4px;
    gap: 2px;
  }
  .fb-toolbar.is-more-open .fb-toolbar-more-panel .fb-zoom-label {
    min-width: 36px;
    font-size: 11px;
  }
  .fb-toolbar.is-more-open .fb-toolbar-more-panel .fb-zoom-group .fb-btn {
    background: transparent;
    border-color: transparent;
    padding: 5px;
  }
  .fb-toolbar.is-more-open .fb-toolbar-more-panel .fb-btn-label-desktop {
    display: inline;
  }
}

.fb-stage-wrapper .hidden {
  display: none;
}

.fb-stage-wrapper a.fb-btn {
  text-decoration: none;
}

/* Pseudo-fullscreen fallback for iOS Safari / in-app browsers */
.fb-stage-wrapper.is-pseudo-fullscreen {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100dvh;
  max-height: 100dvh;
  z-index: var(--z-modal);
}

/* Interactive PDF Hyperlink Overlay */
.fb-page-links {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: var(--z-spine);
}

.fb-page-link {
  position: absolute;
  pointer-events: auto;
  display: block;
  background: var(--fb-link-bg);
  border: 1px solid var(--fb-link-border);
  border-radius: 3px;
  cursor: pointer;
  padding: 0;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.fb-page-link:hover,
.fb-page-link:focus-visible {
  background: var(--fb-link-hover-bg);
  border-color: var(--fb-accent);
  outline: none;
}

/* Thumbnails Drawer Strip */
.fb-thumb-drawer {
  width: 100%;
  padding: 8px 14px;
  background: var(--fb-chrome-drawer-bg);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--fb-chrome-border);
  z-index: var(--z-controls);
  flex-shrink: 0;
  direction: rtl;
}

.fb-thumb-grid {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 4px 2px;
  scrollbar-width: thin;
}

.fb-thumb-item {
  position: relative;
  flex-shrink: 0;
  width: 56px;
  height: 76px;
  padding: 2px;
  border-radius: 8px;
  border: 2px solid var(--fb-thumb-border);
  background: var(--fb-paper-bg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.fb-thumb-item:hover {
  border-color: var(--fb-accent);
  transform: translateY(-2px);
}

.fb-thumb-item.is-active {
  border-color: var(--fb-accent);
  box-shadow: 0 0 0 2px var(--fb-thumb-active-ring);
}

.fb-thumb-item img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  pointer-events: none;
}

.fb-thumb-num {
  position: absolute;
  bottom: 2px;
  left: 2px;
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--fb-chrome-bg);
  color: var(--fb-chrome-ink);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.2;
}

/* Stage Background Media Layer (supports image opacity & overlay without dimming stage controls) */
.fb-stage-bg-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: var(--z-stage-bg, 0);
  background-position: center center;
  background-repeat: no-repeat;
}

/* Stage 3B: Unified Single Viewer Header Bar (Logo + Title + Hint + Client CTA Actions) */
.fb-brand-bar {
  width: 100%;
  padding: max(7px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) 7px max(16px, env(safe-area-inset-left, 0px));
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 14px;
  background: var(--fb-chrome-bg);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--fb-chrome-border);
  z-index: var(--z-controls, 20);
  flex-shrink: 0;
  direction: rtl;
  position: relative;
}

.fb-brand-start {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1 1 auto;
}

.fb-brand-end {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-right: auto;
  min-width: 0;
}

.fb-header-title {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.25;
  color: var(--fb-chrome-ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.fb-header-hint {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--fb-accent-ink);
  white-space: nowrap;
  line-height: 1.2;
}

.fb-brand-subrow {
  flex: 1 0 100%;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding-top: 3px;
  border-top: 1px solid var(--fb-chrome-divider);
  font-size: 0.7rem;
  color: var(--fb-chrome-ink-muted);
  opacity: 0.85;
}

.fb-brand-subrow a,
.fb-designer-credit-corner a,
.fb-share-credits a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.fb-designer-credit-corner {
  position: absolute;
  bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  left: max(12px, env(safe-area-inset-left, 0px));
  z-index: var(--z-controls);
  padding: 3px 9px;
  border-radius: 9999px;
  background: var(--fb-chrome-bg-soft);
  border: 1px solid var(--fb-chrome-border);
  color: var(--fb-chrome-ink-muted);
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1.3;
  max-width: min(220px, calc(100cqi - 24px));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0.78;
  transition: opacity 0.15s ease;
  direction: rtl;
}

.fb-designer-credit-corner:hover {
  opacity: 1;
}

.fb-stage-wrapper.is-tiiny-hosted .fb-designer-credit-corner {
  bottom: 66px;
}

.fb-credit-inline {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}

.fb-credit-link {
  color: inherit;
  text-decoration: none;
}

.fb-credit-link:hover span {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.fb-credit-logo {
  max-height: 16px;
  max-width: 72px;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
  border-radius: 3px;
  flex-shrink: 0;
}

.fb-brand-logo-slot {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  min-width: 0;
}

.fb-brand-logo-slot.is-badge-light {
  background: rgba(255, 255, 255, 0.95);
  padding: 3px 8px;
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.fb-brand-logo-slot.is-badge-dark {
  background: rgba(15, 23, 42, 0.65);
  padding: 3px 8px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.16);
}

.fb-brand-logo-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.fb-brand-logo-img {
  max-height: 36px;
  max-width: 150px;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
  border-radius: 5px;
}

.fb-cta-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.fb-cta-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  border-radius: 9px;
  border: 1px solid var(--fb-chrome-border);
  background: var(--fb-chrome-pill);
  color: var(--fb-chrome-ink);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}

.fb-cta-btn:hover {
  background: var(--fb-chrome-pill-hover);
  border-color: var(--fb-accent-border);
}

.fb-cta-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.fb-cta-btn svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.fb-cta-custom-icon {
  width: 14px;
  height: 14px;
  object-fit: contain;
  border-radius: 3px;
  flex-shrink: 0;
  display: block;
}

.fb-cta-btn.is-icon-only {
  width: 32px;
  height: 32px;
  padding: 0;
  justify-content: center;
  border-radius: 9999px;
}

.fb-cta-btn.is-icon-only svg,
.fb-cta-btn.is-icon-only .fb-cta-custom-icon {
  width: 16px;
  height: 16px;
}

.fb-cta-btn.fb-cta-whatsapp {
  background: var(--fb-whatsapp-bg);
  border-color: var(--fb-whatsapp-bg);
  color: var(--fb-chrome-ink);
}

.fb-cta-btn.fb-cta-whatsapp:hover {
  background: var(--fb-whatsapp-hover);
  border-color: var(--fb-whatsapp-hover);
}

@container fb-stage (max-width: 767px) {
  .fb-header-hint {
    font-size: 0.69rem;
    white-space: normal;
  }
}

@container fb-stage (max-width: 640px) {
  .fb-brand-bar {
    padding: max(5px, env(safe-area-inset-top, 0px)) max(10px, env(safe-area-inset-right, 0px)) 5px max(10px, env(safe-area-inset-left, 0px));
    gap: 6px 8px;
  }
  .fb-header-title {
    font-size: 0.84rem;
  }
  .fb-brand-logo-img {
    max-height: 28px;
    max-width: 112px;
  }
  .fb-cta-btn {
    padding: 4px 8px;
    font-size: 11px;
  }
  .fb-cta-btn.is-icon-only {
    width: 28px;
    height: 28px;
    padding: 0;
  }
  .fb-cta-btn.is-icon-only svg,
  .fb-cta-btn.is-icon-only .fb-cta-custom-icon {
    width: 14px;
    height: 14px;
  }
  .fb-designer-credit-corner {
    font-size: 9.5px;
    padding: 2px 7px;
    bottom: calc(6px + env(safe-area-inset-bottom, 0px));
    left: max(6px, env(safe-area-inset-left, 0px));
  }
  .fb-stage-wrapper.is-tiiny-hosted .fb-designer-credit-corner {
    bottom: 62px;
  }
}

/* Stage 3D: Auto bottom clearance when hosted on *.tiiny.site (avoids overlap with 55px Tiiny bar) */
.fb-stage-wrapper.is-tiiny-hosted {
  padding-bottom: 58px;
  box-sizing: border-box;
}

/* Stage 3D: Share Booklet + Offline QR Popover */
.fb-share-popover {
  position: absolute;
  bottom: 84px;
  left: 50%;
  transform: translateX(-50%);
  width: min(312px, calc(100cqi - 24px));
  max-height: calc(100% - 110px);
  overflow-y: auto;
  padding: 12px 14px;
  border-radius: 16px;
  background: var(--fb-chrome-bg);
  backdrop-filter: blur(14px);
  border: 1px solid var(--fb-chrome-border);
  box-shadow: 0 20px 44px rgba(0, 0, 0, 0.42);
  color: var(--fb-chrome-ink);
  direction: rtl;
  z-index: var(--z-modal);
  display: flex;
  flex-direction: column;
  gap: 10px;
  user-select: text;
  -webkit-user-select: text;
}

.fb-stage-wrapper.is-tiiny-hosted .fb-share-popover {
  bottom: 142px;
}

.fb-share-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.fb-share-title {
  font-size: 0.86rem;
  font-weight: 800;
  color: var(--fb-chrome-ink);
}

.fb-share-close {
  background: transparent;
  border: 1px solid transparent;
  color: var(--fb-chrome-ink-muted);
  width: 26px;
  height: 26px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}

.fb-share-close:hover {
  background: var(--fb-chrome-pill-hover);
  color: var(--fb-chrome-ink);
}

.fb-share-close svg {
  width: 15px;
  height: 15px;
}

.fb-share-notice {
  margin: 0;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--fb-accent-soft);
  border: 1px solid var(--fb-accent-border);
  color: var(--fb-accent-ink);
  font-size: 11.5px;
  line-height: 1.45;
  font-weight: 600;
}

.fb-share-qr-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.fb-share-qr-box {
  width: 148px;
  height: 148px;
  padding: 6px;
  border-radius: 12px;
  background: #ffffff;
  border: 1px solid var(--fb-chrome-border);
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

.fb-share-qr-box svg {
  width: 100%;
  height: 100%;
  display: block;
}

.fb-share-qr-box.is-preview {
  opacity: 0.55;
}

.fb-share-qr-caption {
  font-size: 11px;
  color: var(--fb-chrome-ink-muted);
  text-align: center;
}

.fb-share-url-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.fb-share-url-input {
  flex: 1;
  min-width: 0;
  padding: 6px 8px;
  border-radius: 9px;
  border: 1px solid var(--fb-chrome-border);
  background: var(--fb-chrome-pill);
  color: var(--fb-chrome-ink);
  font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.fb-share-copy-btn {
  padding: 6px 10px;
  border-radius: 9px;
  border: 1px solid var(--fb-accent-border);
  background: var(--fb-accent-soft);
  color: var(--fb-accent-ink);
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.fb-share-copy-btn:hover:not(:disabled) {
  background: var(--fb-accent);
  color: var(--fb-chrome-ink);
}

.fb-share-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.fb-share-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--fb-chrome-border);
  background: var(--fb-chrome-pill);
  color: var(--fb-chrome-ink);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  box-sizing: border-box;
  transition: background-color 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

.fb-share-action-btn:hover:not(.is-disabled):not(:disabled) {
  background: var(--fb-chrome-pill-hover);
  border-color: var(--fb-accent-border);
}

.fb-share-action-btn.is-disabled,
.fb-share-action-btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
  pointer-events: none;
}

.fb-share-action-btn svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.fb-share-wa-btn {
  background: var(--fb-whatsapp-bg);
  border-color: var(--fb-whatsapp-bg);
}

.fb-share-wa-btn:hover:not(.is-disabled) {
  background: var(--fb-whatsapp-hover);
  border-color: var(--fb-whatsapp-hover);
}

.fb-share-credits {
  padding-top: 8px;
  border-top: 1px solid var(--fb-chrome-divider);
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 11px;
  line-height: 1.4;
  color: var(--fb-chrome-ink-muted);
}

.fb-share-credits-heading {
  font-size: 10.5px;
  font-weight: 800;
  color: var(--fb-chrome-ink);
}

.fb-share-credit-row,
.fb-share-credits-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
}

.fb-share-credit-row .fb-credit-logo,
.fb-share-credits-item .fb-credit-logo {
  max-height: 20px;
  max-width: 88px;
}

.fb-share-credit-title {
  font-weight: 700;
  color: var(--fb-chrome-ink);
}

.fb-share-credits-platform {
  font-size: 10px;
  opacity: 0.78;
}

/* Stage 4D: Container-Measured Low-Height & Narrow Stage Density (zero global viewport-height queries) */
.fb-stage-wrapper.is-compact-height .fb-footer {
  padding: 4px max(10px, env(safe-area-inset-right, 0px)) calc(6px + env(safe-area-inset-bottom, 0px)) max(10px, env(safe-area-inset-left, 0px));
  gap: 4px;
}
.fb-stage-wrapper.is-compact-height .fb-slider-row {
  gap: 8px;
}
.fb-stage-wrapper.is-compact-height .fb-slider-label {
  font-size: 10px;
}
.fb-stage-wrapper.is-compact-height .fb-slider {
  height: 4px;
}
.fb-stage-wrapper.is-compact-height .fb-share-popover {
  bottom: 68px;
  max-height: calc(100% - 86px);
  padding: 10px 12px;
  gap: 7px;
}
.fb-stage-wrapper.is-compact-height.is-tiiny-hosted .fb-share-popover {
  bottom: 124px;
  max-height: calc(100% - 140px);
}
.fb-stage-wrapper.is-compact-height .fb-share-qr-box {
  width: 96px;
  height: 96px;
  padding: 5px;
  border-radius: 10px;
}
.fb-stage-wrapper.is-compact-height .fb-share-notice {
  padding: 6px 8px;
  font-size: 11px;
}
.fb-stage-wrapper.is-compact-height .fb-share-action-btn {
  padding: 6px 10px;
  font-size: 12px;
}

.fb-stage-wrapper.is-ultra-compact-height .fb-footer {
  padding: 3px max(8px, env(safe-area-inset-right, 0px)) calc(5px + env(safe-area-inset-bottom, 0px)) max(8px, env(safe-area-inset-left, 0px));
  gap: 3px;
}
.fb-stage-wrapper.is-ultra-compact-height .fb-slider-row {
  max-width: 340px;
  min-height: 20px;
}
.fb-stage-wrapper.is-ultra-compact-height .fb-slider-label {
  display: none;
}
.fb-stage-wrapper.is-ultra-compact-height .fb-share-popover {
  bottom: 56px;
  max-height: calc(100% - 70px);
  padding: 8px 10px;
  gap: 6px;
}
.fb-stage-wrapper.is-ultra-compact-height.is-tiiny-hosted .fb-share-popover {
  bottom: 114px;
  max-height: calc(100% - 126px);
}
.fb-stage-wrapper.is-ultra-compact-height .fb-share-qr-box {
  width: 82px;
  height: 82px;
  padding: 4px;
}
.fb-stage-wrapper.is-ultra-compact-height .fb-share-qr-caption {
  font-size: 10px;
}

.fb-stage-wrapper.is-narrow-stage .fb-brand-bar {
  box-sizing: border-box;
  max-width: 100%;
  padding: max(4px, env(safe-area-inset-top, 0px)) max(8px, env(safe-area-inset-right, 0px)) 4px max(8px, env(safe-area-inset-left, 0px));
  gap: 5px 6px;
}
.fb-stage-wrapper.is-narrow-stage .fb-brand-start {
  flex: 1 1 100%;
  min-width: 0;
  gap: 6px;
}
.fb-stage-wrapper.is-narrow-stage .fb-header-title {
  font-size: 0.78rem;
}
.fb-stage-wrapper.is-narrow-stage .fb-brand-end {
  flex: 1 1 100%;
  width: 100%;
  max-width: 100%;
  justify-content: space-between;
  margin-right: 0;
  gap: 5px 8px;
}
.fb-stage-wrapper.is-narrow-stage .fb-header-hint {
  flex: 1 1 130px;
  min-width: 0;
  font-size: 0.66rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fb-stage-wrapper.is-narrow-stage .fb-brand-logo-img {
  max-height: 24px;
  max-width: 88px;
}
.fb-stage-wrapper.is-narrow-stage .fb-cta-group {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
  gap: 4px;
}
.fb-stage-wrapper.is-narrow-stage .fb-slider-row {
  max-width: calc(100% - 8px);
  gap: 6px;
  padding: 0 4px;
}
.fb-stage-wrapper.is-narrow-stage .fb-share-popover {
  width: min(300px, calc(100% - 16px));
}
