.clfb {
  --clfb-bg: #eef0f2;
  --clfb-ink: #1e252c;
  --clfb-muted: #6e757c;
  --clfb-accent: #8b1e24;
  --clfb-page-w: min(38vw, 520px);
  --clfb-page-h: calc(var(--clfb-page-w) * 1.3316);
  --clfb-zoom: 1;
  width: 100%;
  min-height: 560px;
  background:
    linear-gradient(18deg, rgba(255,255,255,.48) 0 18%, transparent 18% 100%),
    linear-gradient(-18deg, rgba(255,255,255,.34) 0 16%, transparent 16% 100%),
    var(--clfb-bg);
  border: 1px solid rgba(18,25,33,.08);
  border-radius: 18px;
  overflow: hidden;
  color: var(--clfb-ink);
  box-shadow: 0 18px 55px rgba(25, 31, 38, .11);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.clfb * { box-sizing: border-box; }

.clfb__topbar {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 18px;
  background: rgba(255,255,255,.88);
  border-bottom: 1px solid rgba(18,25,33,.08);
  backdrop-filter: blur(12px);
}

.clfb__title {
  font-size: clamp(16px, 2vw, 24px);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.clfb__actions { display: flex; gap: 8px; flex: 0 0 auto; }

.clfb__icon-btn {
  width: 40px;
  height: 40px;
  border: 1px solid rgba(18,25,33,.10);
  border-radius: 12px;
  background: rgba(255,255,255,.92);
  color: #20262d;
  display: inline-grid;
  place-items: center;
  font: inherit;
  font-size: 21px;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}

.clfb__icon-btn:hover { transform: translateY(-1px); box-shadow: 0 8px 18px rgba(0,0,0,.10); background: #fff; }
.clfb__icon-btn:focus-visible, .clfb__nav:focus-visible { outline: 3px solid rgba(139,30,36,.25); outline-offset: 2px; }

.clfb__stage {
  position: relative;
  min-height: calc(var(--clfb-page-h) + 84px);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 38px 22px 30px;
  overflow: auto hidden;
  touch-action: pan-y;
  perspective: 2400px;
}

.clfb__book-wrap {
  position: relative;
  width: calc(var(--clfb-page-w) * 2);
  height: var(--clfb-page-h);
  flex: 0 0 auto;
  transform: scale(var(--clfb-zoom));
  transform-origin: center center;
  transition: transform .22s ease;
}

.clfb__book {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  filter: drop-shadow(0 18px 22px rgba(20,25,31,.19));
}

.clfb__leaf {
  --turn: 0deg;
  --shade: 0;
  position: absolute;
  top: 0;
  left: 50%;
  width: var(--clfb-page-w);
  height: var(--clfb-page-h);
  transform-origin: left center;
  transform-style: preserve-3d;
  transform: rotateY(var(--turn));
  transition: transform 620ms cubic-bezier(.2,.72,.2,1);
  will-change: transform;
  cursor: grab;
}

.clfb__leaf.is-dragging { transition: none; cursor: grabbing; }

.clfb__face {
  position: absolute;
  inset: 0;
  overflow: hidden;
  backface-visibility: hidden;
  background: #fff;
  border-radius: 0 26px 26px 0;
  box-shadow:
    inset -1px 0 rgba(0,0,0,.08),
    inset 0 0 0 1px rgba(0,0,0,.025);
}

.clfb__face img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}

.clfb__face--front::after,
.clfb__face--back::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: var(--shade);
  transition: opacity 80ms linear;
}

.clfb__face--front::after {
  background: linear-gradient(90deg, rgba(0,0,0,.30), rgba(0,0,0,.02) 20%, rgba(255,255,255,.08) 72%, rgba(0,0,0,.18));
}

.clfb__face--back {
  transform: rotateY(180deg);
  border-radius: 26px 0 0 26px;
  box-shadow:
    inset 1px 0 rgba(0,0,0,.08),
    inset 0 0 0 1px rgba(0,0,0,.025);
}

.clfb__face--back::after {
  background: linear-gradient(270deg, rgba(0,0,0,.27), rgba(0,0,0,.01) 22%, rgba(255,255,255,.06) 70%, rgba(0,0,0,.14));
}

.clfb__leaf::before {
  content: "";
  position: absolute;
  z-index: 5;
  right: -4px;
  top: 12px;
  bottom: 12px;
  width: 7px;
  border-radius: 0 8px 8px 0;
  background: repeating-linear-gradient(to right, rgba(255,255,255,.95) 0 1px, rgba(185,188,190,.58) 1px 2px);
  transform: translateZ(-1px);
  opacity: .88;
  pointer-events: none;
}

.clfb__paper-depth {
  position: absolute;
  top: 8px;
  bottom: 8px;
  width: 11px;
  z-index: 0;
  opacity: .9;
  background: repeating-linear-gradient(to right, #fdfdfc 0 1px, #cfd1d2 1px 2px, #fafafa 2px 3px);
  box-shadow: 0 5px 11px rgba(0,0,0,.10);
  transition: opacity .35s ease, transform .35s ease;
}

.clfb__paper-depth--right { right: -8px; border-radius: 0 13px 13px 0; }
.clfb__paper-depth--left { left: -8px; border-radius: 13px 0 0 13px; opacity: .08; }

.clfb__spine-shadow {
  position: absolute;
  z-index: 80;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 24px;
  transform: translateX(-50%);
  pointer-events: none;
  opacity: .7;
  background: linear-gradient(90deg, transparent, rgba(0,0,0,.12), rgba(255,255,255,.22), rgba(0,0,0,.10), transparent);
  mix-blend-mode: multiply;
}

.clfb__nav {
  position: sticky;
  z-index: 120;
  top: 50%;
  width: 46px;
  height: 46px;
  flex: 0 0 46px;
  border: 0;
  border-radius: 50%;
  background: rgba(255,255,255,.90);
  color: #242a30;
  box-shadow: 0 7px 20px rgba(0,0,0,.14);
  font-size: 33px;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform .18s ease, opacity .18s ease;
}

.clfb__nav:hover { transform: scale(1.06); }
.clfb__nav[disabled] { opacity: .28; cursor: default; transform: none; }

.clfb__footer {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) auto minmax(180px, 1fr);
  align-items: center;
  gap: 16px;
  padding: 14px 18px 17px;
  background: rgba(255,255,255,.78);
  border-top: 1px solid rgba(18,25,33,.07);
}

.clfb__progress { height: 4px; background: rgba(32,38,45,.10); border-radius: 99px; overflow: hidden; }
.clfb__progress span { display: block; width: 0; height: 100%; background: var(--clfb-accent); border-radius: inherit; transition: width .4s ease; }
.clfb__counter { min-width: 88px; text-align: center; font-weight: 650; font-size: 14px; }
.clfb__hint { color: var(--clfb-muted); font-size: 13px; text-align: right; }

.clfb.is-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 999999;
  border-radius: 0;
  min-height: 100vh;
}
.clfb.is-fullscreen .clfb__stage { height: calc(100vh - 128px); }

@media (max-width: 900px) {
  .clfb { --clfb-page-w: min(41vw, 430px); }
  .clfb__stage { gap: 8px; padding-inline: 8px; }
  .clfb__nav { width: 40px; height: 40px; flex-basis: 40px; font-size: 29px; }
  .clfb__footer { grid-template-columns: 1fr auto; }
  .clfb__hint { display: none; }
}

@media (max-width: 600px) {
  .clfb { --clfb-page-w: 41vw; border-radius: 12px; }
  .clfb__topbar { min-height: 56px; padding: 8px 10px; }
  .clfb__title { font-size: 15px; max-width: 54vw; }
  .clfb__icon-btn { width: 36px; height: 36px; border-radius: 10px; font-size: 18px; }
  .clfb__stage { min-height: calc(var(--clfb-page-h) + 58px); padding-top: 26px; padding-bottom: 22px; }
  .clfb__face { border-radius: 0 16px 16px 0; }
  .clfb__face--back { border-radius: 16px 0 0 16px; }
  .clfb__nav { position: absolute; bottom: 10px; top: auto; }
  .clfb__nav--prev { left: 14px; }
  .clfb__nav--next { right: 14px; }
  .clfb__footer { padding: 12px 14px; }
}

@media (prefers-reduced-motion: reduce) {
  .clfb__leaf, .clfb__book-wrap, .clfb__progress span, .clfb__icon-btn, .clfb__nav { transition-duration: 1ms !important; }
}
