/* TN Digi — light reader: content first, with one floating toolbar. */
.aifv-wrapper {
  --fb-bg: #f5f6f8;
  --fb-surface: #fff;
  --fb-border: #e2e5e9;
  --fb-text: #51565d;
  --fb-muted: #727880;
  --fb-accent: #526d91;
  --fb-speed: 1000ms;
  position: relative;
  display: flex;
  flex-direction: column;
  max-width: 100%;
  min-width: 0;
  isolation: isolate;
  overflow: hidden;
  background: var(--fb-bg);
  border: 1px solid #eceef1;
  border-radius: 3px;
  color: var(--fb-text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-user-select: none;
  user-select: none;
}
.aifv-wrapper *, .aifv-wrapper *::before, .aifv-wrapper *::after { box-sizing: border-box; }
.aifv-wrapper [hidden] { display: none !important; }
/* Keep the document title available to assistive technology. */
.aifv-topbar {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.aifv-progress-wrap { height: 2px; flex: 0 0 2px; overflow: hidden; background: #eceef1; }
.aifv-progress-bar { height: 100%; background: var(--fb-accent); transition: width .25s ease; }
.aifv-stage {
  position: relative;
  width: 100%;
  height: clamp(360px, 80vh, 1000px);
  min-height: 0;
  flex: 1 1 auto;
  perspective: 2800px;
  background: var(--fb-bg);
}
.aifv-viewport {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  overflow: auto;
  padding: 12px 28px 68px;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #cfd4db transparent;
  touch-action: pan-x pan-y;
}
.aifv-book {
  position: relative;
  flex: 0 0 auto;
  width: 100%;
  height: 0;
  margin: auto;
  padding-bottom: 60%;
  background: #fff;
  box-shadow: 0 1px 6px rgba(30, 40, 55, .08);
}
.aifv-book::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 50%;
  z-index: 20;
  width: 1px;
  background: rgba(40, 45, 55, .1);
  pointer-events: none;
}
.aifv-book.aifv-single-page::before { display: none; }
.aifv-page {
  display: none;
  position: absolute;
  top: 0;
  left: 50%;
  width: 50%;
  height: 100%;
  overflow: hidden;
  background: #fff;
  transform-origin: left center;
  transform-style: preserve-3d;
  transition: transform var(--fb-speed) cubic-bezier(.645,.045,.355,1);
}
.aifv-page.active, .aifv-page.flipping { display: block; }
.aifv-page.left-page { left: 0; transform-origin: right center; }
.aifv-page img, .aifv-page canvas {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: contain;
  pointer-events: none;
}
.aifv-overlay-nav { position: absolute; inset: 0; z-index: 30; pointer-events: none; }
.aifv-wrapper .aifv-overlay-btn {
  position: absolute;
  top: 50%;
  display: grid;
  place-items: center;
  width: 42px;
  height: 60px;
  min-height: 0;
  margin: -30px 0 0;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  box-shadow: none;
  color: #686f77;
  cursor: pointer;
  pointer-events: auto;
  opacity: .65;
  transition: opacity .15s, background .15s;
}
.aifv-wrapper .aifv-overlay-prev { left: 2px; }
.aifv-wrapper .aifv-overlay-next { right: 2px; }
.aifv-wrapper .aifv-overlay-btn:hover { opacity: 1; background: rgba(255,255,255,.7); }
.aifv-wrapper .aifv-overlay-btn:disabled { opacity: .16; pointer-events: none; }
.aifv-wrapper .aifv-overlay-btn svg { display: block; width: 20px; height: 32px; }
.aifv-toolbar {
  position: absolute;
  bottom: 16px;
  left: 50%;
  z-index: 40;
  display: flex;
  align-items: center;
  width: max-content;
  max-width: calc(100% - 16px);
  height: 44px;
  padding: 3px;
  border: 1px solid rgba(212,215,221,.85);
  border-radius: 6px;
  background: rgba(255,255,255,.96);
  box-shadow: 0 2px 8px rgba(20,30,45,.14);
  transform: translateX(-50%);
}
.aifv-wrapper .aifv-btn {
  display: grid;
  place-items: center;
  flex: 0 0 36px;
  width: 36px;
  min-width: 0;
  height: 36px;
  min-height: 0;
  padding: 8px;
  margin: 0;
  border: 0;
  border-radius: 3px;
  background: transparent;
  box-shadow: none;
  color: #70757d;
  cursor: pointer;
  line-height: 1;
  text-decoration: none;
  transition: color .15s, background .15s;
}
.aifv-wrapper .aifv-btn svg { display: block; width: 21px; height: 21px; pointer-events: none; }
.aifv-wrapper .aifv-btn:hover, .aifv-wrapper .aifv-btn[aria-expanded=true] { background: #f0f2f5; color: #323943; }
.aifv-wrapper .aifv-btn:disabled { opacity: .3; cursor: default; }
.aifv-wrapper button:focus-visible { outline: 2px solid var(--fb-accent); outline-offset: 2px; }
.aifv-page-counter { display: flex; flex: 0 0 auto; align-items: center; justify-content: center; gap: 2px; min-width: 54px; padding: 0 8px; color: #666d76; font-size: 12px; font-weight: 400; font-variant-numeric: tabular-nums; white-space: nowrap; }
.aifv-sep { color: #9ba1a9; }
.aifv-toolbar-divider { width: 1px; height: 24px; margin: 0 3px; background: #e9ebef; }
.aifv-thumbs {
  position: absolute;
  bottom: 78px;
  left: 50%;
  z-index: 45;
  display: flex;
  align-items: center;
  gap: 10px;
  width: max-content;
  max-width: calc(100% - 32px);
  max-height: 160px;
  overflow-x: auto;
  padding: 12px;
  border: 1px solid var(--fb-border);
  border-radius: 7px;
  background: rgba(255,255,255,.98);
  box-shadow: 0 4px 18px rgba(20,30,45,.12);
  transform: translateX(-50%);
  scrollbar-width: thin;
}
.aifv-wrapper .aifv-thumb {
  position: relative;
  display: block;
  flex: 0 0 56px;
  width: 56px;
  height: 78px;
  min-height: 0;
  margin: 0;
  padding: 3px 3px 16px;
  overflow: hidden;
  border: 1px solid #e0e3e8;
  border-radius: 3px;
  background: #fafbfc;
  box-shadow: none;
  color: var(--fb-muted);
  cursor: pointer;
}
.aifv-thumb img, .aifv-thumb canvas { display: block; width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.aifv-wrapper .aifv-thumb.active { border-color: var(--fb-accent); background: #eef2f7; }
.aifv-thumb::after { content: attr(data-page); position: absolute; bottom: 0; left: 0; right: 0; font-size: 10px; line-height: 16px; text-align: center; }
.aifv-more-panel { position: absolute; bottom: 70px; left: 50%; z-index: 46; width: 220px; max-width: calc(100% - 24px); padding: 5px; border: 1px solid var(--fb-border); border-radius: 6px; background: #fff; box-shadow: 0 4px 18px rgba(20,30,45,.12); transform: translateX(-50%); }
.aifv-wrapper .aifv-more-panel button { display: block; width: 100%; min-height: 38px; padding: 8px 12px; margin: 0; border: 0; border-radius: 3px; background: transparent; box-shadow: none; color: var(--fb-text); text-align: left; font: inherit; font-size: 13px; cursor: pointer; }
.aifv-wrapper .aifv-more-panel button:hover { background: #f2f4f7; }
.aifv-status { position: absolute; bottom: 70px; left: 50%; z-index: 47; max-width: calc(100% - 24px); padding: 6px 10px; border-radius: 4px; background: #fff; box-shadow: 0 2px 8px rgba(20,30,45,.1); color: var(--fb-text); font-size: 12px; transform: translateX(-50%); }
.aifv-status:empty { display: none; }
.aifv-page-placeholder { width: 100%; height: 100%; background: linear-gradient(90deg,#f4f5f7 25%,#eaedf1 50%,#f4f5f7 75%); background-size: 200% 100%; animation: aifv-shimmer 1.4s infinite; }
.aifv-pdf-loading { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; min-height: 360px; padding: 48px 20px; color: var(--fb-muted); }
.aifv-pdf-loading p { margin: 0; font-size: 13px; }
.aifv-spinner { width: 30px; height: 30px; border: 2px solid var(--fb-border); border-top-color: var(--fb-accent); border-radius: 50%; animation: aifv-spin .7s linear infinite; }
@keyframes aifv-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@keyframes aifv-spin { to { transform: rotate(360deg); } }
.aifv-wrapper:fullscreen, .aifv-wrapper.aifv-fullscreen { width: 100% !important; height: 100% !important; border: 0; border-radius: 0; background: var(--fb-bg); }
.aifv-wrapper.aifv-fullscreen { position: fixed; inset: 0; z-index: 999999; width: 100vw !important; height: 100dvh !important; }
.aifv-wrapper:fullscreen .aifv-stage, .aifv-wrapper.aifv-fullscreen .aifv-stage { height: 100%; flex: 1; }
.aifv-error { padding: 12px 16px; border: 1px solid #ead9d9; border-radius: 6px; background: #fff8f8; color: #a13d3d; font-size: 13px; }
@media (max-width: 640px) {
  .aifv-stage { height: clamp(320px,72vh,640px); }
  .aifv-viewport { padding: 12px 12px 64px; }
  .aifv-wrapper .aifv-overlay-btn { width: 32px; height: 48px; margin-top: -24px; }
  .aifv-wrapper .aifv-overlay-btn svg { width: 16px; height: 26px; }
  .aifv-toolbar { bottom: 12px; height: 42px; padding: 2px; }
  .aifv-wrapper .aifv-btn { width: 30px; flex-basis: 30px; height: 36px; padding: 6px; }
  .aifv-wrapper .aifv-btn svg { width: 19px; height: 19px; }
  .aifv-page-counter { min-width: 44px; padding: 0 4px; }
  .aifv-toolbar-divider { margin: 0 2px; }
  .aifv-thumbs { bottom: 66px; }
  .aifv-more-panel, .aifv-status { bottom: 62px; }
}
@media (max-width: 360px) {
  .aifv-wrapper .aifv-btn { width: 27px; flex-basis: 27px; padding: 5px; }
  .aifv-page-counter { min-width: 40px; }
  .aifv-toolbar-divider { margin: 0 1px; }
}
@media (prefers-reduced-motion: reduce) {
  .aifv-wrapper *, .aifv-wrapper *::before, .aifv-wrapper *::after { animation: none !important; transition: none !important; }
}
