html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #0f1115;
}

.fb-stage {
  height: 100vh;
  width: 100vw;
  display: grid;
  place-items: center;
  padding: 12px;
  box-sizing: border-box;
}

.fb-frame {
  position: relative;
  width: min(1100px, 96vw);
  height: min(96vh, 1100px);
  aspect-ratio: 1 / 1;
}

.fb-container{
  width: min(1100px, 96vw);
  height: min(96vh, 1100px);
  aspect-ratio: 1 / 1;
  overflow: hidden;
}


/* Preview Bild */
#fbPreview {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* Pfeile links rechts als Overlay */
.fb-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 50;
  width: 46px;
  height: 46px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.16);
  background: rgba(0,0,0,.45);
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  user-select: none;
}

.fb-nav:hover { background: rgba(0,0,0,.60); }

.fb-prev { left: 10px; }
.fb-next { right: 10px; }

/* Meldung */
.fb-msg {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 60;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(0,0,0,.55);
  border: 1px solid rgba(255,255,255,.14);
  color: rgba(255,255,255,.92);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  font-size: 13px;
  max-width: min(520px, 90vw);
  white-space: pre-wrap;
}

.fb-shell{
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.fb-top{
  flex: 0 0 auto;
}

.fb-wrap{
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 0;
  box-sizing: border-box;
  overflow: hidden;
}

/* Das ist der wichtige Teil: fixe Größe schon vor dem Flipbook Start */
.fb-container{
  width: min(1100px, 96vw);
  height: min(96vh, 1100px);
  aspect-ratio: 1 / 1;
  overflow: hidden;
}

/* PageFlip (StPageFlip) Wrapper: Weiß entfernen */
#fbContainer,
.fb-container{
  background: transparent !important;
}

/* Die Library erzeugt mehrere Layer, die oft weiß sind */
#fbContainer .stf__parent,
#fbContainer .stf__wrapper,
#fbContainer .stf__block,
#fbContainer .stf__item,
#fbContainer .stf__sheet{
  background: transparent !important;
}

/* Canvas sauber ohne Extra-Abstände */
#fbContainer canvas{
  display: block;
}

/* Desktop: Doppelseite braucht 2 zu 1 */
@media (min-width: 860px){
  .fb-container{
aspect-ratio: 1.92 / 1; /* statt 2 / 1 */
    height: min(96vh, 680px);
    width: min(96vw, 1400px);
  }
}

/* Mobile: Einzelseite bleibt 1 zu 1 */
@media (max-width: 859px){
  .fb-container{
    aspect-ratio: 1 / 1;
    height: min(96vh, 1100px);
    width: min(96vw, 1100px);
  }
}

/* Alles hinter den Seiten dunkel halten */
.fb-container,
#fbContainer,
#fbContainer .stf__parent,
#fbContainer .stf__wrapper,
#fbContainer .stf__block,
#fbContainer .stf__sheet,
#fbContainer .stf__item{
  background: #ffffff !important;
}

html, body{
  background: #ffffff;
}

/* Hintergrundflächen der PageFlip Library dunkel statt weiß */
#fbContainer,
.fb-container,
#fbContainer .stf__parent,
#fbContainer .stf__wrapper,
#fbContainer .stf__block,
#fbContainer .stf__item,
#fbContainer .stf__sheet {
  background: #ffffff !important;
}

/* falls irgendwo noch ein Default Weiß sitzt */
#fbContainer * {
  background-color: transparent;
}

/* Blätter-Pfeile */
.fb-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 56px;
  height: 56px;
  border-radius: 999px;
  cursor: pointer;
  z-index: 50;

  background: rgba(255,255,255,0.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);

  display: flex;
  align-items: center;
  justify-content: center;

  box-shadow: 0 6px 20px rgba(0,0,0,.15);
  transition: opacity .2s ease, transform .2s ease, background .2s ease;
}

/* OPTIMA Gold Linienpfeile */
.fb-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  cursor: pointer;
  z-index: 50;

  display: flex;
  align-items: center;
  justify-content: center;

  background: transparent;
  transition: opacity .25s ease, transform .25s ease;
}

/* Pfeil-Linien */
.fb-nav::before {
  content: '';
  width: 16px;
  height: 16px;
  border-top: 2px solid #C9A24D;   /* Optima Gold */
  border-right: 2px solid #C9A24D;
  display: block;
}

/* Position & Richtung */
.fb-prev { left: 100px; }
.fb-prev::before { transform: rotate(-135deg); }

.fb-next { right: 100px; }
.fb-next::before { transform: rotate(45deg); }

/* Hover: minimal stärker */
.fb-nav:hover::before {
  border-color: #E3C36A; /* helleres Gold */
}

/* Desktop: nur bei Hover sichtbar */
@media (hover: hover) {
  .fb-nav {
    opacity: 0;
  }
  .fb-wrap:hover .fb-nav {
    opacity: 1;
  }
}

/* Touch: immer sichtbar */
@media (hover: none) {
  .fb-nav {
    opacity: 1;
  }
}

/* Mobile: Pfeile komplett ausblenden */
@media (max-width: 859px) {
  .fb-nav {
    display: none !important;
  }
}

@media (max-width: 859px){
  .fb-container{
    aspect-ratio: auto;
    width: 96vw;
    height: 76vh; /* nach Geschmack 70-80vh */
  }
  .fb-nav{ display:none !important; }
}

/* Mobile: Wrapper für Slide + Schatten */
.fb-mob-wrap{
  width: 100%;
  height: 100%;
  overflow: hidden;
  position: relative;
}

/* Die Seite */
.fb-mob-img{
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  position: absolute;
  inset: 0;
  transform: translateX(0);
  opacity: 1;
}

/* Animation Klassen */
.fb-mob-img.is-enter-right { transform: translateX(14%); opacity: 0; }
.fb-mob-img.is-enter-left  { transform: translateX(-14%); opacity: 0; }
.fb-mob-img.is-leave-left  { transform: translateX(-14%); opacity: 0; }
.fb-mob-img.is-leave-right { transform: translateX(14%); opacity: 0; }

/* Dauer: wie bei dir langsamer */
.fb-mob-img,
.fb-mob-img.is-enter-right,
.fb-mob-img.is-enter-left,
.fb-mob-img.is-leave-left,
.fb-mob-img.is-leave-right{
  transition: transform 300ms ease, opacity 300ms ease;
}

/* Mini Page Curl (Eselsohr) */
.fb-mob-curl{
  position: absolute;
  top: 50%;
  width: 22px;
  height: 22px;
  transform: translateY(-50%) rotate(45deg);
  pointer-events: none;
  opacity: 0;
  transition: opacity 300ms ease, transform 300ms ease;
  background: radial-gradient(circle at 30% 30%,
    rgba(255,255,255,.85) 0%,
    rgba(255,255,255,.45) 38%,
    rgba(0,0,0,.18) 100%);
  border-radius: 4px;
  filter: blur(.1px);
}

/* Curl rechts beim "weiter" */
.fb-mob-curl.is-next{
  right: 10px;
}

/* Curl links beim "zurück" */
.fb-mob-curl.is-prev{
  left: 10px;
}

.fb-mob-curl.is-on{
  opacity: .9;
  transform: translateY(-50%) rotate(45deg) scale(1.06);
}

/* iPhone Landscape: PageFlip Wrapper hart zentrieren */
@media (max-width: 859px) and (orientation: landscape) {

  /* iOS: besser als 100vh (Adressleiste) */
  .fb-shell { height: 100dvh; }
  .fb-wrap  { height: 100dvh; }

  /* Container als Bezug */
  #fbContainer,
  .fb-container {
    position: relative;
    height: 100dvh;
  }

  /* Parent muss Bezug für absolute Zentrierung sein */
  #fbContainer .stf__parent {
    position: relative !important;
    height: 100% !important;
  }

  /* DAS ist der entscheidende Fix */
  #fbContainer .stf__wrapper {
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    right: auto !important;
    bottom: auto !important;
    transform: translate(-50%, -50%) !important;
    margin: 0 !important;
  }
}

/* iPhone Landscape: stabile Höhe + zentriert, ohne PageFlip zu "kaputt-override'n" */
@media (max-width: 859px) and (orientation: landscape) {

  html, body {
    height: 100dvh;
  }

  .fb-shell {
    height: 100dvh;
  }

  /* falls du .fb-wrap als Grid nutzt: perfekt, sonst bitte so setzen */
  .fb-wrap{
    height: 100%;
    display: grid;
    place-items: center;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    box-sizing: border-box;
  }

  /* Container bekommt eine echte Höhe (keine 100% Kette ins Leere) */
  #fbContainer,
  .fb-container{
    width: 96vw;
    height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    overflow: hidden;
  }

  /* Nur Parent zentriert, Wrapper nicht anfassen */
  #fbContainer .stf__parent{
    width: 100% !important;
    height: 100% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    overflow: hidden !important;
  }
}
