/**
 * Kitobxon Ultra-Realistic 3D Flipbook CSS (Powered by Nodlik/StPageFlip)
 * Skeuomorphic physical book with hardcover casing, layered paper thickness,
 * realistic central spine lighting, silk bookmark ribbon, and soft diagonal page curling.
 */

:root {
  --fb-desk-bg: #070a12;
  --fb-cover-color: #121824;
  --fb-cover-border: rgba(212, 175, 55, 0.35);
  --fb-paper-tone: #faf8f5;
  --fb-spine-depth: rgba(0, 0, 0, 0.45);
  --fb-gold: #f59e0b;
}

/* ── Flipbook Stage & Desk Atmosphere ── */
.fb-stage-wrapper {
  position: relative;
  width: 100%;
  min-height: calc(100vh - 10rem);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 30%, #151c2e 0%, #070a12 85%);
  padding: 1rem 0.5rem 1.25rem;
  border-radius: 1.5rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 2px 10px rgba(255, 255, 255, 0.03), 0 30px 60px -15px rgba(0, 0, 0, 0.9);
  perspective: 2000px;
  user-select: none;
  -webkit-user-select: none;
  overflow: visible;
}

/* ── Hardcover Outer Casing (Qattiq Muqova Hoshiyasi) ── */
.fb-hardcover-casing {
  position: relative;
  padding: 10px 14px 16px 14px;
  background: linear-gradient(145deg, #1b2234 0%, #0f1422 60%, #0a0d17 100%);
  border-radius: 16px;
  border: 2px solid var(--fb-cover-border);
  box-shadow:
    0 35px 80px -20px rgba(0, 0, 0, 0.95),
    0 15px 35px -10px rgba(0, 0, 0, 0.8),
    inset 0 1px 2px rgba(255, 255, 255, 0.2),
    inset 0 -2px 6px rgba(0, 0, 0, 0.8),
    0 0 0 1px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 100%;
  transition: transform 0.25s ease;
}

/* Gold corner accents on the hardcover */
.fb-hardcover-casing::before,
.fb-hardcover-casing::after {
  content: '';
  position: absolute;
  width: 22px;
  height: 22px;
  border: 2px solid rgba(245, 158, 11, 0.45);
  pointer-events: none;
}
.fb-hardcover-casing::before {
  top: 6px;
  left: 6px;
  border-right: none;
  border-bottom: none;
  border-top-left-radius: 10px;
}
.fb-hardcover-casing::after {
  top: 6px;
  right: 6px;
  border-left: none;
  border-bottom: none;
  border-top-right-radius: 10px;
}

/* ── Red Silk Bookmark Ribbon (Atlas Xatcho'p) ── */
.fb-silk-ribbon {
  position: absolute;
  bottom: -32px;
  left: 50%;
  width: 16px;
  height: 64px;
  background: linear-gradient(to right, #991b1b 0%, #dc2626 50%, #b91c1c 100%);
  transform: translateX(-50%);
  z-index: 28;
  box-shadow: 2px 8px 16px rgba(0, 0, 0, 0.65);
  clip-path: polygon(0% 0%, 100% 0%, 100% 84%, 50% 100%, 0% 84%);
  pointer-events: none;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.5));
}

/* ── The Book Spread Container ── */
.fb-book-spread {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0d121d;
  border-radius: 6px;
  max-width: 100%;
  cursor: grab;
  user-select: none !important;
  -webkit-user-select: none !important;
  -webkit-touch-callout: none;
  overflow: hidden;
  box-shadow:
    -3px 2px 0 #ede8df,
    -6px 4px 0 #ded8cc,
    3px 2px 0 #ede8df,
    6px 4px 0 #ded8cc,
    0 12px 28px rgba(0, 0, 0, 0.45);
}

.fb-book-spread:active {
  cursor: grabbing;
}

/* ── Nodlik/StPageFlip Host & Page Styling ── */
.fb-stf-host {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fb-stf-book {
  position: relative;
}

.fb-book-spread .stf__parent {
  position: relative;
  display: block;
  box-sizing: border-box;
  transform: translateZ(0);
  -ms-touch-action: pan-y;
  touch-action: pan-y;
}

.fb-book-spread .stf__wrapper,
.fb-book-spread .sft__wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
}

.fb-book-spread .stf__block {
  position: absolute;
  width: 100%;
  height: 100%;
  left: 0;
  top: 0;
  box-sizing: border-box;
  perspective: 2000px;
}

.fb-book-spread .stf__item {
  display: none;
  position: absolute;
  transform-style: preserve-3d;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.fb-book-spread .stf__outerShadow,
.fb-book-spread .stf__innerShadow,
.fb-book-spread .stf__hardShadow,
.fb-book-spread .stf__hardInnerShadow {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: none;
}

/* Prevent unmounted page DOM nodes from expanding layout or flashing before StPageFlip initializes */
#fb-stf-book > .fb-stf-page:not(.stf__item) {
  display: none !important;
}

/* Ensure inactive StPageFlip pages set to display: none are strictly hidden */
.stf__item[style*="display: none"],
.fb-stf-page.stf__item[style*="display: none"],
.fb-stf-page[style*="display: none"] {
  display: none !important;
}

/* Guard: loader skeleton inside inactive pages must never be visible outside active spread */
.fb-stf-page:not(.--left):not(.--right):not(.--simple) .fb-stf-page-loader {
  display: none !important;
}

.fb-stf-page {
  background: var(--fb-paper-tone);
  overflow: hidden;
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
  border-radius: 4px;
}

.fb-stf-page-inner {
  position: relative;
  width: 100%;
  height: 100%;
  background: var(--fb-paper-tone);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.fb-stf-page-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
  opacity: 0;
  transition: opacity 0.18s ease;
}

.fb-stf-page-img.is-loaded {
  opacity: 1;
}

/* Spine depth shading on left and right pages */
.fb-stf-spine-lighting {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
}

.fb-stf-page.--left .fb-stf-spine-lighting {
  background: linear-gradient(
    to left,
    rgba(15, 23, 42, 0.24) 0%,
    rgba(15, 23, 42, 0.08) 7%,
    rgba(255, 255, 255, 0.18) 14%,
    transparent 26%
  );
  box-shadow: inset 1px 0 0 rgba(255, 255, 255, 0.7), inset 0 0 0 1px rgba(15, 23, 42, 0.06);
}

.fb-stf-page.--right .fb-stf-spine-lighting {
  background: linear-gradient(
    to right,
    rgba(15, 23, 42, 0.24) 0%,
    rgba(15, 23, 42, 0.08) 7%,
    rgba(255, 255, 255, 0.18) 14%,
    transparent 26%
  );
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.7), inset 0 0 0 1px rgba(15, 23, 42, 0.06);
}

/* Page loading skeleton inside unrendered pages (dark sleek card, zero white glare) */
.fb-stf-page-loader {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  color: #8b9bad;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.75rem;
  background: #0f1422;
  z-index: 1;
  transition: opacity 0.2s ease;
}

.fb-stf-page-loader.is-hidden {
  opacity: 0;
  pointer-events: none;
  display: none !important;
}

.fb-stf-page-loader-spinner {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid rgba(245, 158, 11, 0.25);
  border-top-color: #d97706;
  animation: fbStfSpin 0.8s linear infinite;
}

@keyframes fbStfSpin {
  to {
    transform: rotate(360deg);
  }
}

/* Endpaper page (when PDF has an odd number of pages) */
.fb-stf-endpaper-inner {
  background: radial-gradient(circle at 50% 45%, #f7f2e7 0%, #ebe3d2 100%);
  border: 1px solid rgba(180, 155, 110, 0.25);
}

.fb-stf-endpaper-ornament {
  text-align: center;
  color: rgba(120, 95, 55, 0.55);
  font-family: Georgia, Cambria, "Times New Roman", Times, serif;
  padding: 1.5rem;
  border: 1px double rgba(180, 155, 110, 0.35);
  border-radius: 8px;
}

.fb-stf-endpaper-ornament span {
  display: block;
  font-size: 1.5rem;
  color: rgba(217, 119, 6, 0.55);
  margin-bottom: 0.25rem;
}

.fb-stf-endpaper-ornament p {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin: 0;
}

.fb-stf-endpaper-ornament small {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  opacity: 0.75;
}

/* ── Book Spine (Realistic Center Seam & Curvature) ── */
.fb-book-spine {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 16px;
  transform: translateX(-50%);
  background: linear-gradient(
    to right,
    rgba(0, 0, 0, 0.32) 0%,
    rgba(0, 0, 0, 0.12) 32%,
    rgba(255, 255, 255, 0.14) 50%,
    rgba(0, 0, 0, 0.12) 68%,
    rgba(0, 0, 0, 0.32) 100%
  );
  z-index: 25;
  pointer-events: none;
}

/* Spine stitching hints */
.fb-book-spine::after {
  content: '';
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 50%;
  width: 1px;
  background: repeating-linear-gradient(
    to bottom,
    rgba(245, 158, 11, 0.45) 0px,
    rgba(245, 158, 11, 0.45) 8px,
    transparent 8px,
    transparent 16px
  );
  transform: translateX(-50%);
}

/* ── Big Tactile Navigation Paddles (Desk Arrows) ── */
.fb-nav-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(17, 24, 39, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 35;
  transition: all 0.2s ease;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
}
.fb-nav-arrow:hover {
  background: #f59e0b;
  color: #0f172a;
  border-color: #f59e0b;
  transform: translateY(-50%) scale(1.1);
  box-shadow: 0 0 30px rgba(245, 158, 11, 0.6);
}
.fb-nav-arrow--left {
  left: -20px;
}
.fb-nav-arrow--right {
  right: -20px;
}

/* ── Interactive Bottom Slider & Controls ── */
.fb-controls-shelf {
  width: 100%;
  max-width: 900px;
  margin-top: 1.25rem;
  padding: 0.65rem 1.25rem;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 1rem;
  backdrop-filter: blur(14px);
  display: flex;
  align-items: center;
  gap: 0.85rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
  box-sizing: border-box;
}

html.light .fb-stage-wrapper:not([data-paper-theme="night"]) {
  background: radial-gradient(circle at 50% 30%, #f3efe7 0%, #e4dccb 85%);
  border-color: rgba(24, 22, 19, 0.12);
  box-shadow: inset 0 2px 10px rgba(255, 255, 255, 0.5), 0 20px 45px -15px rgba(24, 22, 19, 0.15);
}

html.light .fb-controls-shelf {
  background: rgba(250, 247, 241, 0.94);
  border: 1px solid rgba(24, 22, 19, 0.12);
  box-shadow: 0 10px 25px rgba(24, 22, 19, 0.08);
}

html.light #fb-page-select,
html.light #fb-page-select option {
  background-color: #faf7f1;
  color: #181613;
}

@media (max-width: 639px) {
  .fb-controls-shelf {
    padding: 0.5rem 0.65rem;
    gap: 0.45rem;
    flex-wrap: wrap;
    justify-content: space-between;
  }
}

.fb-page-slider {
  flex: 1;
  accent-color: #f59e0b;
  height: 6px;
  border-radius: 4px;
  cursor: pointer;
}

/* ── Loading Overlay ── */
.fb-loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(7, 10, 18, 0.94);
  backdrop-filter: blur(10px);
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: opacity 0.4s ease, visibility 0.4s;
}

.fb-loading-overlay.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* ── Mobile Layout (< 900px) ── */
@media (max-width: 899px) {
  .fb-stage-wrapper {
    padding: 0.75rem 0.25rem;
    min-height: 460px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.6);
  }
  .fb-hardcover-casing {
    padding: 6px 8px 12px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.7);
  }
  .fb-book-spread {
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4) !important;
  }
  .fb-book-spine {
    display: none !important;
  }
  .fb-silk-ribbon {
    display: none !important;
  }
  .fb-nav-arrow--left {
    left: 4px;
  }
  .fb-nav-arrow--right {
    right: 4px;
  }
}

/* ── Paper Tone Themes ── */
.fb-stage-wrapper[data-paper-theme="sepia"] {
  --fb-paper-tone: #f4ebd0;
  background: radial-gradient(circle at 50% 30%, #1f1b14 0%, #0d0c09 85%);
}
.fb-stage-wrapper[data-paper-theme="sepia"] .fb-book-spread {
  box-shadow:
    -3px 2px 0 #ded2b3,
    -6px 4px 0 #ccbe9a,
    3px 2px 0 #ded2b3,
    6px 4px 0 #ccbe9a,
    0 14px 30px rgba(0, 0, 0, 0.55) !important;
}
.fb-stage-wrapper[data-paper-theme="sepia"] .fb-stf-page {
  background: #f4ebd0 !important;
}
/* Ko'z himoyasi: butun sahifaga filtr bermaymiz (soya va chetlar zarg'aldoq bo'lib ketadi).
   Rasm iliq qog'oz ustida "multiply" qilinadi: oq fon → qog'oz rangi, qora matn qora qoladi. */
.fb-stage-wrapper[data-paper-theme="sepia"] .fb-stf-page-inner {
  background: #f4ebd0 !important;
  filter: none !important;
  isolation: isolate;
}
.fb-stage-wrapper[data-paper-theme="sepia"] .fb-stf-page-img {
  mix-blend-mode: multiply;
  filter: sepia(0.2) brightness(0.98);
}
.fb-stage-wrapper[data-paper-theme="sepia"] .fb-stf-page.--left .fb-stf-spine-lighting {
  background: linear-gradient(to left, rgba(92, 64, 28, 0.22) 0%, rgba(92, 64, 28, 0.07) 7%, transparent 22%);
  box-shadow: inset 0 0 0 1px rgba(92, 64, 28, 0.06);
}
.fb-stage-wrapper[data-paper-theme="sepia"] .fb-stf-page.--right .fb-stf-spine-lighting {
  background: linear-gradient(to right, rgba(92, 64, 28, 0.22) 0%, rgba(92, 64, 28, 0.07) 7%, transparent 22%);
  box-shadow: inset 0 0 0 1px rgba(92, 64, 28, 0.06);
}
.fb-stage-wrapper[data-paper-theme="sepia"] .fb-stf-endpaper-inner {
  background: radial-gradient(circle at 50% 45%, #f4ebd0 0%, #e5d7b5 100%) !important;
  border-color: rgba(180, 150, 95, 0.4) !important;
}
.fb-stage-wrapper[data-paper-theme="sepia"] .fb-stf-endpaper-ornament {
  color: rgba(120, 85, 40, 0.75) !important;
  border-color: rgba(180, 150, 95, 0.45) !important;
}

.fb-stage-wrapper[data-paper-theme="night"] {
  --fb-paper-tone: #0f1420;
  background: radial-gradient(circle at 50% 30%, #0c101a 0%, #04060a 85%);
}
.fb-stage-wrapper[data-paper-theme="night"] .fb-book-spread {
  background: #090d15 !important;
  box-shadow:
    -3px 2px 0 #1e2638,
    -6px 4px 0 #131926,
    3px 2px 0 #1e2638,
    6px 4px 0 #131926,
    0 18px 40px rgba(0, 0, 0, 0.9) !important;
}
.fb-stage-wrapper[data-paper-theme="night"] .fb-stf-page {
  background: #0f1420 !important;
}
.fb-stage-wrapper[data-paper-theme="night"] .fb-stf-page-inner {
  background: #ffffff !important; /* Inverts to clean dark charcoal #121212 without white margins */
  filter: invert(0.90) hue-rotate(180deg) contrast(0.96) brightness(0.94) !important;
}
.fb-stage-wrapper[data-paper-theme="night"] .fb-stf-endpaper-inner {
  background: radial-gradient(circle at 50% 45%, #151d2d 0%, #0b0f19 100%) !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  filter: none !important;
}
.fb-stage-wrapper[data-paper-theme="night"] .fb-stf-endpaper-ornament {
  color: rgba(226, 232, 240, 0.5) !important;
  border-color: rgba(255, 255, 255, 0.12) !important;
}
.fb-stage-wrapper[data-paper-theme="night"] .fb-stf-endpaper-ornament span {
  color: rgba(245, 158, 11, 0.7) !important;
}
.fb-stage-wrapper[data-paper-theme="night"] .fb-stf-spine-lighting {
  background: linear-gradient(to right, rgba(0, 0, 0, 0.55) 0%, transparent 22%) !important;
  box-shadow: none !important;
}
.fb-stage-wrapper[data-paper-theme="night"] .fb-book-spine {
  background: linear-gradient(
    to right,
    rgba(0, 0, 0, 0.65) 0%,
    rgba(255, 255, 255, 0.05) 50%,
    rgba(0, 0, 0, 0.65) 100%
  ) !important;
}

.fb-stage-wrapper[data-paper-theme="ivory"],
.fb-stage-wrapper[data-paper-theme="white"] {
  --fb-paper-tone: #faf8f5;
}
.fb-stage-wrapper[data-paper-theme="ivory"] .fb-stf-page-inner,
.fb-stage-wrapper[data-paper-theme="white"] .fb-stf-page-inner {
  filter: none;
}

/* ── Active Paper Theme Button Highlight ── */
[data-paper-theme-btn].is-active {
  background-color: rgba(245, 158, 11, 0.22) !important;
  color: #fcd34d !important;
  border-color: rgba(245, 158, 11, 0.5) !important;
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.2) !important;
  font-weight: 700 !important;
}

/* ── Fullscreen Stage Support ── */
#fb-standalone-container:fullscreen {
  background: #070a12;
  padding: 0.75rem 1rem 1rem;
  overflow-y: auto;
  width: 100vw;
  height: 100vh;
  box-sizing: border-box;
}
#fb-standalone-container:fullscreen .fb-stage-wrapper {
  min-height: calc(100vh - 7.5rem);
  border-radius: 1rem;
}




/* ── Matn rejimi (jonli shrift sozlamalari) ── */
#fb-page-select,
#fb-page-select option {
  background-color: #0f172a;
  color: #f1f5f9;
}

.fbt-panel {
  position: fixed;
  inset: 0;
  margin: 0 !important; /* space-y-* konteyner ichida margin-top tushmasin */
  z-index: 1000010;
  display: none;
  flex-direction: column;
  --fbt-bg: #0f1420;
  --fbt-fg: #e7e4dc;
  --fbt-bar: #151b2b;
  --fbt-card: #131929;
  --fbt-menu-bg: #1a2236;
  --fbt-menu-hover: rgba(245, 158, 11, 0.18);
  --fbt-border: rgba(255, 255, 255, 0.12);
  --fbt-muted: #94a3b8;
  --fbt-accent: #f59e0b;
  background: var(--fbt-bg);
  color: var(--fbt-fg);
}
.fbt-panel.is-open { display: flex; }
.fbt-panel[data-theme="light"] {
  --fbt-bg: #f6f2ea;
  --fbt-fg: #1c1916;
  --fbt-bar: #ece6d9;
  --fbt-card: #fbf9f5;
  --fbt-menu-bg: #ffffff;
  --fbt-menu-hover: rgba(217, 119, 6, 0.14);
  --fbt-border: rgba(28, 25, 22, 0.15);
  --fbt-muted: #6b6358;
  --fbt-accent: #d97706;
}
.fbt-panel[data-theme="sepia"] {
  --fbt-bg: #f1e4c8;
  --fbt-fg: #3d2c19;
  --fbt-bar: #e6d4ae;
  --fbt-card: #f7ecd5;
  --fbt-menu-bg: #faefd9;
  --fbt-menu-hover: rgba(180, 83, 9, 0.15);
  --fbt-border: rgba(74, 55, 34, 0.22);
  --fbt-muted: #7a6446;
  --fbt-accent: #b45309;
}

.fbt-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.65rem;
  padding: 0.65rem 1rem;
  background: var(--fbt-bar);
  border-bottom: 1px solid var(--fbt-border);
  position: relative;
  z-index: 20;
}
.fbt-group {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.15rem;
  border: 1px solid var(--fbt-border);
  border-radius: 0.75rem;
  background: rgba(0, 0, 0, 0.06);
}
.fbt-btn, .fbt-select {
  background: transparent;
  color: var(--fbt-fg);
  border: 0;
  padding: 0.32rem 0.65rem;
  border-radius: 0.55rem;
  font: 700 0.8rem 'DM Mono', monospace;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.fbt-select,
.fbt-select option {
  background-color: var(--fbt-menu-bg);
  color: var(--fbt-fg);
}
.fbt-btn:hover:not(:disabled) { background: var(--fbt-menu-hover); }
.fbt-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.fbt-btn.is-active { background: #f59e0b; color: #1a1205; }
.fbt-label { font: 700 0.8rem 'DM Mono', monospace; color: var(--fbt-accent); min-width: 3rem; text-align: center; user-select: none; }
.fbt-range { width: 6.5rem; accent-color: #f59e0b; cursor: pointer; touch-action: manipulation; }
.fbt-spacer { flex: 1; }
.fbt-close { background: #f59e0b !important; color: #1a1205 !important; font-weight: 800; }
.fbt-close:hover { background: #fbbf24 !important; }

/* Custom High-Contrast Dropdowns (.fbt-dd) */
.fbt-dd {
  position: relative;
  display: inline-flex;
}
.fbt-dd-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.38rem 0.75rem;
  border-radius: 0.65rem;
  border: 1px solid var(--fbt-border);
  background: var(--fbt-menu-bg);
  color: var(--fbt-fg);
  font: 600 0.8rem 'DM Sans', system-ui, sans-serif;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
  transition: border-color 0.15s ease, background 0.15s ease;
}
.fbt-dd-trigger--compact {
  padding: 0.22rem 0.5rem;
  border: 0;
  background: transparent;
  box-shadow: none;
}
.fbt-dd-trigger:hover,
.fbt-dd.is-open .fbt-dd-trigger {
  border-color: #f59e0b;
}
.fbt-dd-prefix { opacity: 0.8; font-size: 0.85rem; }
.fbt-dd-caret { opacity: 0.75; font-size: 0.75rem; transition: transform 0.15s ease; }
.fbt-dd.is-open .fbt-dd-caret { transform: rotate(180deg); color: #f59e0b; }

.fbt-dd-menu {
  position: absolute;
  top: calc(100% + 0.4rem);
  left: 0;
  min-width: 13.5rem;
  background: var(--fbt-menu-bg);
  color: var(--fbt-fg);
  border: 1px solid var(--fbt-border);
  border-radius: 0.85rem;
  padding: 0.35rem;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(245, 158, 11, 0.15);
  display: none;
  flex-direction: column;
  gap: 0.15rem;
  z-index: 100;
}
.fbt-dd-menu--pages {
  min-width: 10rem;
  max-height: 18rem;
  overflow-y: auto;
}
.fbt-dd.is-open .fbt-dd-menu {
  display: flex;
}
.fbt-dd-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
  text-align: left;
  padding: 0.5rem 0.7rem;
  border: 0;
  border-radius: 0.55rem;
  background: transparent;
  color: var(--fbt-fg);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}
.fbt-dd-item:hover {
  background: var(--fbt-menu-hover);
}
.fbt-dd-item.is-selected {
  background: rgba(245, 158, 11, 0.22);
  color: var(--fbt-accent);
  font-weight: 700;
}
.fbt-dd-check {
  opacity: 0;
  color: var(--fbt-accent);
  font-weight: 900;
}
.fbt-dd-item.is-selected .fbt-dd-check {
  opacity: 1;
}

/* Scrollable Full-Book Reader Stage */
.fbt-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem 1rem 5rem;
  scroll-behavior: smooth;
}
.fbt-body {
  max-width: 52rem;
  margin: 0 auto;
  transition: font-size 0.12s ease, line-height 0.12s ease;
}
.fbt-page {
  background: var(--fbt-card);
  border: 1px solid var(--fbt-border);
  border-radius: 1.1rem;
  padding: 1.75rem 2rem;
  margin-bottom: 1.75rem;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.12);
}
@media (max-width: 640px) {
  .fbt-page { padding: 1.15rem 1.1rem; }
}
.fbt-page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 0.75rem;
  margin-bottom: 1.25rem;
  border-bottom: 1px dashed var(--fbt-border);
  font: 700 0.75rem 'DM Mono', monospace;
  color: var(--fbt-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.fbt-page-badge {
  color: var(--fbt-accent);
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.3);
  padding: 0.18rem 0.6rem;
  border-radius: 999px;
}
.fbt-notice {
  max-width: 32rem;
  margin: 3rem auto;
  padding: 2rem 1.5rem;
  text-align: center;
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 0.95rem;
  line-height: 1.6;
  background: var(--fbt-card);
  border: 1px solid var(--fbt-border);
  border-radius: 1rem;
}
.fbt-notice-icon { font-size: 2.5rem; margin-bottom: 0.5rem; }
.fbt-notice h3 { font-size: 1.1rem; font-weight: 700; margin: 0 0 0.5rem; }
.fbt-notice p { color: var(--fbt-muted); margin: 0 0 1.25rem; }
/* Matn rejimi sahifa matni — yozuvlarning o'zini to'g'ridan-to'g'ri kattalashtirish (ekran stabil qoladi) */
.fbt-page-content {
  font-size: var(--fbt-font-size, 19px) !important;
  line-height: var(--fbt-line-height, 1.8) !important;
  font-family: var(--fbt-font-family, 'Merriweather', Georgia, serif) !important;
  word-break: break-word;
  overflow-wrap: break-word;
}
.fbt-page-content p {
  font-size: var(--fbt-font-size, 19px) !important;
  line-height: var(--fbt-line-height, 1.7) !important;
  font-family: inherit !important;
  margin: 0 0 0.55em !important;
  text-align: left;
  hyphens: auto;
}
.fbt-page-content p.fbt-item {
  margin: 0 0 0.28em !important;
  padding-left: 0.9em;
  text-indent: -0.9em;
}
.fbt-page-content .fbt-h {
  font-weight: 800;
  margin: 1.1em 0 0.55em;
  font-size: calc(var(--fbt-font-size, 19px) * 1.22) !important;
  line-height: 1.35 !important;
  color: var(--fbt-accent);
}
.fbt-page-content .fbt-h:first-child { margin-top: 0; }
.fbt-page-content .fbt-kv {
  display: grid;
  grid-template-columns: minmax(7.5em, 12.5em) 1fr;
  gap: 0.5em 1.25em;
  padding: 0.42em 0;
  border-bottom: 1px solid var(--fbt-border);
  align-items: baseline;
  font-size: var(--fbt-font-size, 19px) !important;
  line-height: var(--fbt-line-height, 1.8) !important;
}
@media (max-width: 560px) {
  .fbt-page-content .fbt-kv { grid-template-columns: 1fr; gap: 0.15em; }
}
.fbt-page-content .fbt-k {
  font-weight: 700;
  color: var(--fbt-fg);
}
.fbt-page-content .fbt-v {
  color: var(--fbt-fg);
  opacity: 0.92;
}
.fbt-page-head {
  /* Sahifa boshi va badge o'lchami o'zgarmaydi, ekran stabil qoladi */
  font-size: 0.75rem !important;
  line-height: 1.2 !important;
}
.fbt-page-badge {
  font-size: 0.72rem !important;
}
.fbt-body p {
  margin: 0 0 0.95em;
  text-align: left;
  hyphens: auto;
}
.fbt-body .fbt-h {
  font-weight: 800;
  margin: 1.1em 0 0.55em;
  font-size: 1.22em;
  line-height: 1.35;
  color: var(--fbt-accent);
}
.fbt-body .fbt-h:first-child { margin-top: 0; }
.fbt-body .fbt-kv {
  display: grid;
  grid-template-columns: minmax(7.5em, 12.5em) 1fr;
  gap: 0.5em 1.25em;
  padding: 0.42em 0;
  border-bottom: 1px solid var(--fbt-border);
  align-items: baseline;
}
@media (max-width: 560px) {
  .fbt-body .fbt-kv { grid-template-columns: 1fr; gap: 0.15em; }
}
.fbt-body .fbt-k {
  font-weight: 700;
  color: var(--fbt-fg);
}
.fbt-body .fbt-v {
  color: var(--fbt-fg);
  opacity: 0.92;
}
.fbt-muted { color: var(--fbt-muted); text-align: center; padding: 2rem 1rem; }
.fbt-foot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 0.65rem 1rem;
  background: var(--fbt-bar);
  border-top: 1px solid var(--fbt-border);
  position: relative;
  z-index: 20;
}

/* ══════════════════════════════════════════════════════════════════════
   MOBILE FULLSCREEN IMMERSIVE READER (Image 2 style)
   ══════════════════════════════════════════════════════════════════════ */
body.fb-mobile-fullscreen-active,
html.fb-mobile-fullscreen-active {
  overflow: hidden !important;
  position: fixed !important;
  inset: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  height: 100dvh !important;
  margin: 0 !important;
  padding: 0 !important;
  background: var(--fb-desk-bg, #070a12) !important;
}

body.fb-mobile-fullscreen-active header,
body.fb-mobile-fullscreen-active footer,
body.fb-mobile-fullscreen-active nav#mobile-bottom-nav,
body.fb-mobile-fullscreen-active .ks-bottom-nav,
body.fb-mobile-fullscreen-active #fb-standalone-container > div:first-child,
body.fb-mobile-fullscreen-active .fb-controls-shelf,
body.fb-mobile-fullscreen-active .fb-nav-arrow,
body.fb-mobile-fullscreen-active #fb-standalone-container > div:not(#fb-root):not(#reading-tracker-root):not(#fbt-panel):not(#fb-quote-modal) {
  display: none !important;
}

body.fb-mobile-fullscreen-active #reading-tracker-root,
body.fb-mobile-fullscreen-active .reading-tracker-root {
  display: block !important;
  position: relative !important;
  z-index: 9999999 !important;
}

body.fb-mobile-fullscreen-active .reading-tracker-modal,
.reading-tracker-modal {
  z-index: 9999999 !important;
}

body.fb-mobile-fullscreen-active .reading-tracker-floating-widget {
  display: flex !important;
  position: fixed !important;
  z-index: 999998 !important;
  bottom: 5rem !important;
  right: 1rem !important;
  pointer-events: auto !important;
}

/* Mobile Fullscreen Mutolaa Timer Badge */
.fb-mfs-mutolaa-pill {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 999996;
  background: rgba(13, 19, 31, 0.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(245, 158, 11, 0.4);
  border-radius: 9999px;
  padding: 0.35rem 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  pointer-events: auto;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  transition: opacity 0.28s ease, transform 0.28s ease;
  user-select: none;
}
.fb-mfs-overlay.is-hidden-controls .fb-mfs-mutolaa-pill {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px);
}
.fb-mfs-mutolaa-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #10B981;
  box-shadow: 0 0 8px #10B981;
  animation: fbPulseDot 1.5s infinite;
}
@keyframes fbPulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}

body.fb-mobile-fullscreen-active main {
  padding: 0 !important;
  margin: 0 !important;
  max-width: 100vw !important;
  width: 100vw !important;
  height: 100vh !important;
  height: 100dvh !important;
  min-height: 100vh !important;
}

body.fb-mobile-fullscreen-active #fb-standalone-container {
  padding: 0 !important;
  margin: 0 !important;
  max-width: 100vw !important;
  width: 100vw !important;
  height: 100vh !important;
  height: 100dvh !important;
  gap: 0 !important;
}

body.fb-mobile-fullscreen-active #fb-root,
body.fb-mobile-fullscreen-active .fb-stage-wrapper {
  position: fixed !important;
  inset: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  height: 100dvh !important;
  z-index: 999990 !important;
  padding: 0 !important;
  margin: 0 !important;
  border-radius: 0 !important;
  border: none !important;
  box-shadow: none !important;
  background: var(--fb-desk-bg, #070a12) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

body.fb-mobile-fullscreen-active .fb-hardcover-casing {
  padding: 0 !important;
  margin: 0 !important;
  border: none !important;
  box-shadow: none !important;
  background: transparent !important;
  border-radius: 0 !important;
  width: 100% !important;
  height: 100% !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

body.fb-mobile-fullscreen-active .fb-hardcover-casing::before,
body.fb-mobile-fullscreen-active .fb-hardcover-casing::after,
body.fb-mobile-fullscreen-active .fb-silk-ribbon,
body.fb-mobile-fullscreen-active .fb-book-spine {
  display: none !important;
}

body.fb-mobile-fullscreen-active .fb-book-spread {
  box-shadow: none !important;
  border-radius: 0 !important;
  background: transparent !important;
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  max-height: 100% !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

body.fb-mobile-fullscreen-active .fb-stf-page {
  border-radius: 0 !important;
  box-shadow: none !important;
}

body.fb-mobile-fullscreen-active .fb-stf-page-inner {
  border-radius: 0 !important;
}

body.fb-mobile-fullscreen-active .fb-stf-page-img {
  object-fit: contain !important;
}

/* ── Mobile Fullscreen Overlay Controls (Image 2 style) ── */
.fb-mfs-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 999995;
  transition: opacity 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

.fb-mfs-overlay.is-hidden-controls {
  opacity: 0;
}
.fb-mfs-overlay.is-hidden-controls * {
  pointer-events: none !important;
}

/* Floating top-left back button (<) */
.fb-mfs-back-btn {
  position: absolute;
  top: max(16px, env(safe-area-inset-top, 16px));
  left: 16px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.76);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  transition: all 0.2s ease;
}
.fb-mfs-back-btn:active {
  transform: scale(0.92);
  background: rgba(15, 23, 42, 0.95);
}

/* Floating page pill (e.g. "2 / 826 sahifa") */
.fb-mfs-page-pill {
  position: absolute;
  bottom: calc(max(70px, env(safe-area-inset-bottom, 70px)));
  left: 50%;
  transform: translateX(-50%);
  background: rgba(20, 26, 38, 0.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #f1f5f9;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11px;
  font-weight: 700;
  padding: 6px 18px;
  border-radius: 9999px;
  pointer-events: auto;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
  white-space: nowrap;
  letter-spacing: 0.02em;
  transition: all 0.2s ease;
}
.fb-mfs-page-pill:active {
  transform: translateX(-50%) scale(0.95);
  background: rgba(20, 26, 38, 0.98);
}

/* Floating page quick slider (pops up when pill is clicked) */
.fb-mfs-slider-wrap {
  position: absolute;
  bottom: calc(max(110px, env(safe-area-inset-bottom, 110px)));
  left: 50%;
  transform: translateX(-50%);
  width: min(320px, calc(100vw - 40px));
  background: rgba(15, 23, 42, 0.94);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 16px;
  padding: 10px 16px;
  pointer-events: auto;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.65);
  z-index: 1000000;
}

/* Floating bottom bar (Image 2 style) */
.fb-mfs-bottom-bar {
  position: absolute;
  bottom: max(14px, env(safe-area-inset-bottom, 14px));
  left: 50%;
  transform: translateX(-50%);
  width: min(360px, calc(100vw - 28px));
  height: 48px;
  border-radius: 24px;
  background: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 0 8px;
  pointer-events: auto;
}

.fb-mfs-bar-btn {
  background: transparent;
  border: none;
  color: #cbd5e1;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.18s ease;
  padding: 0;
}
.fb-mfs-bar-btn:hover {
  color: #f8fafc;
  background: rgba(255, 255, 255, 0.1);
}
.fb-mfs-bar-btn:active {
  transform: scale(0.9);
  color: #f59e0b;
}
