
html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at 50% 18%, rgba(255,255,255,.38), transparent 34%),
    radial-gradient(circle at 50% 55%, rgba(155,118,159,.14), transparent 54%),
    linear-gradient(180deg, #e8dfe9 0%, #d7c8da 55%, #c8b6cc 100%);
}

body {
  overflow-x: hidden;
}


:root {
  --ink: #39271e;
  --muted: #735f4d;
  --paper: #ead8b2;
  --paper-light: #f1e3c4;
  --paper-edge: #b9925b;
  --gold: #c99d4e;
  --leather: #4b221a;
  --leather-dark: #24100d;
  --black: #120b08;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: Georgia, "Times New Roman", serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 50% 0%, rgba(112,67,35,.28), transparent 32%),
    linear-gradient(180deg, #24130d, #100a07 62%, #090605);
}

button { font: inherit; }

.diary-stage { min-height: 100vh; }





.intro {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 30px 18px;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 30%, rgba(130, 89, 126, .16), transparent 38%),
    linear-gradient(180deg, #efe9ee, #d9ccd9);
}

.intro-card {
  position: relative;
  width: min(430px, 90vw);
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 18px;
  background: #eee;
  box-shadow:
    0 20px 50px rgba(64, 42, 60, .26),
    0 0 0 1px rgba(255,255,255,.72);
}

.intro-scene,
.opening-video,
.video-endframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  object-position: center;
  border-radius: inherit;
}

.intro-scene {
  z-index: 2;
}

.opening-video {
  z-index: 3;
  opacity: 0;
  pointer-events: none;
  background: #eee;
}

.video-endframe {
  z-index: 4;
  opacity: 0;
  pointer-events: none;
}

.intro.is-playing .opening-video {
  opacity: 1;
}

.intro.is-playing .intro-scene {
  opacity: 0;
}

.intro.is-holding .opening-video {
  opacity: 0;
}

.intro.is-holding .video-endframe {
  opacity: 1;
}

.book-hotspot {
  position: absolute;
  inset: 0;
  z-index: 6;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  cursor: pointer;
  background: transparent;
  clip-path: polygon(
    31% 27%,
    62% 23%,
    67% 32%,
    73% 69%,
    70% 78%,
    42% 84%,
    37% 79%,
    33% 56%
  );
}

.book-hotspot::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0;
  background: rgba(225, 188, 116, .07);
  transition: opacity .18s ease;
}

.book-hotspot:hover::after,
.book-hotspot:focus-visible::after {
  opacity: 1;
}

.book-hotspot:focus-visible {
  outline: none;
}

.intro.is-playing .book-hotspot,
.intro.is-holding .book-hotspot,
.intro.is-finishing .book-hotspot {
  pointer-events: none;
  opacity: 0;
}

.intro.is-finishing .intro-card {
  animation: dissolveIntro .55s ease forwards;
}

@keyframes dissolveIntro {
  from { opacity: 1; transform: scale(1); }
  to { opacity: 0; transform: scale(1.012); }
}
.reader {
  display: none;
  min-height: 100vh;
  padding: 18px 18px 24px;
  background:
    radial-gradient(circle at 50% 18%, rgba(255,255,255,.38), transparent 34%),
    radial-gradient(circle at 50% 55%, rgba(155,118,159,.14), transparent 54%),
    linear-gradient(180deg, #e8dfe9 0%, #d7c8da 55%, #c8b6cc 100%);
  animation: readerIn .58s ease both;
}

.reader.is-visible { display: block; }

@keyframes readerIn {
  from { opacity: 0; transform: translateY(8px) scale(.985); }
  to { opacity: 1; transform: translateY(0); }
}

.reader-bar,
.controls {
  width: min(1180px, 96vw);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.reader-bar {
  color: #f2dfbd;
  margin-bottom: 10px;
}

.reader-button,
.controls button {
  border: 1px solid rgba(213,170,97,.48);
  border-radius: 999px;
  padding: 10px 17px;
  color: #f4dfb9;
  background: rgba(48,26,17,.78);
  cursor: pointer;
  transition: transform .2s ease, background .2s ease;
}

.reader-button:hover,
.controls button:hover:not(:disabled),
.reader-button:focus-visible,
.controls button:focus-visible {
  transform: translateY(-2px);
  background: rgba(84,45,28,.95);
}

.controls button:disabled {
  opacity: .36;
  cursor: default;
}

.spread-counter {
  letter-spacing: .08em;
  font-size: 14px;
}

.book-wrap {
  width: min(980px, 92vw, calc(78vh * 296 / 210));
  margin: 0 auto;
  perspective: 2400px;
}

.book {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: 100%;
  aspect-ratio: 296 / 210;
  min-height: 0;
  transform-style: preserve-3d;
  filter: drop-shadow(0 13px 14px rgba(77,49,78,.20));
}

.cover-underlay {
  position: absolute;
  inset: -20px -24px -22px;
  border-radius: 24px 28px 28px 24px;
  background:
    linear-gradient(90deg, #2b120e, #5a2a20 8%, #32150f 50%, #59291f 92%, #24100d),
    repeating-radial-gradient(circle at 30% 40%, rgba(255,255,255,.025) 0 1px, transparent 1px 5px);
  border: 2px solid #1a0b08;
  box-shadow:
    inset 0 0 0 5px rgba(196,151,76,.15),
    inset 0 0 28px rgba(0,0,0,.48);
}

.static-page,
.turning-sheet {
  position: relative;
  min-width: 0;
  min-height: 0;
  aspect-ratio: 148 / 210;
}

.static-page {
  overflow: hidden;
  background:
    radial-gradient(circle at 20% 18%, rgba(115,83,49,.14) 0 1px, transparent 2px),
    repeating-linear-gradient(93deg, rgba(101,67,36,.035) 0 1px, transparent 1px 13px),
    linear-gradient(90deg, var(--paper), var(--paper-light) 48%, var(--paper));
  box-shadow:
    inset 0 0 38px rgba(102,64,31,.2),
    inset 0 -10px 14px rgba(100,65,34,.11);
}

.left-page {
  border-radius: 18px 4px 4px 18px;
  transform-origin: right center;
  box-shadow:
    inset -22px 0 24px rgba(91,57,30,.14),
    inset 8px 0 14px rgba(255,255,255,.22);
}

.right-page {
  border-radius: 4px 18px 18px 4px;
  transform-origin: left center;
  box-shadow:
    inset 22px 0 24px rgba(91,57,30,.14),
    inset -8px 0 14px rgba(255,255,255,.22);
}

.page-inner {
  position: relative;
  z-index: 1;
  height: 100%;
  padding: clamp(34px, 4.6vw, 68px);
  font-size: clamp(16px, 1.65vw, 21px);
  line-height: 1.7;
}

.page-inner h1,
.page-inner h2 {
  margin-top: 0;
  text-align: center;
  font-weight: 400;
}

.page-inner h1 {
  font-size: clamp(34px, 4.5vw, 58px);
}

.page-inner h2 {
  font-size: clamp(26px, 3.3vw, 42px);
}

.page-inner .date {
  display: block;
  text-align: center;
  color: var(--muted);
  font-style: italic;
  margin-bottom: 26px;
}

.page-inner .flourish {
  text-align: center;
  font-size: 28px;
  margin: 14px 0 22px;
}

.page-number {
  position: absolute;
  bottom: 18px;
  right: 24px;
  color: var(--muted);
  font-size: 14px;
}

.left-page .page-number {
  right: auto;
  left: 24px;
}

.book-gutter {
  position: absolute;
  z-index: 6;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 48px;
  transform: translateX(-50%);
  pointer-events: none;
  background:
    linear-gradient(90deg,
      rgba(58,34,20,0),
      rgba(58,34,20,.24) 24%,
      rgba(255,255,255,.11) 49%,
      rgba(66,38,22,.26) 72%,
      rgba(58,34,20,0));
  filter: blur(.2px);
}

.turning-sheet {
  position: absolute;
  z-index: 10;
  top: 0;
  bottom: 0;
  right: 0;
  width: 50%;
  transform-origin: left center;
  transform-style: preserve-3d;
  pointer-events: none;
  display: none;
}

.turning-sheet.is-active {
  display: block;
}

.turning-sheet.turn-forward {
  animation: flipForward .9s cubic-bezier(.35,.05,.15,1) both;
}

.turning-sheet.turn-backward {
  left: 0;
  right: auto;
  transform-origin: right center;
  animation: flipBackward .9s cubic-bezier(.35,.05,.15,1) both;
}

.sheet-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  overflow: hidden;
  background:
    radial-gradient(circle at 22% 20%, rgba(115,83,49,.14) 0 1px, transparent 2px),
    repeating-linear-gradient(93deg, rgba(101,67,36,.035) 0 1px, transparent 1px 13px),
    linear-gradient(90deg, var(--paper), var(--paper-light) 48%, var(--paper));
  box-shadow: inset 0 0 35px rgba(102,64,31,.2);
}

.sheet-front {
  border-radius: 4px 18px 18px 4px;
  transform: rotateY(0deg);
  box-shadow:
    inset 20px 0 22px rgba(91,57,30,.14),
    -4px 0 9px rgba(52,30,17,.16);
}

.sheet-back {
  border-radius: 18px 4px 4px 18px;
  transform: rotateY(180deg);
  box-shadow:
    inset -20px 0 22px rgba(91,57,30,.14),
    4px 0 9px rgba(52,30,17,.16);
}

@keyframes flipForward {
  0% { transform: rotateY(0deg); }
  42% { filter: brightness(.98); }
  100% { transform: rotateY(-180deg); }
}

@keyframes flipBackward {
  0% { transform: rotateY(0deg); }
  100% { transform: rotateY(180deg); }
}

.toc-list {
  list-style: none;
  margin: 28px 0 0;
  padding: 0;
}

.toc-list li { margin: 10px 0; }

.toc-link {
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: baseline;
  border: 0;
  padding: 6px 0;
  color: var(--ink);
  background: transparent;
  cursor: pointer;
  text-align: left;
  font-size: inherit;
}

.toc-link:hover .toc-title { text-decoration: underline; }

.toc-dots {
  border-bottom: 1px dotted rgba(57,39,30,.5);
  transform: translateY(-4px);
}

.entry-signature {
  margin-top: 34px;
  text-align: right;
  font-size: 1.18em;
  font-style: italic;
}

.controls {
  margin-top: 12px;
}

.keyboard-tip {
  margin: 8px 0 0;
  text-align: center;
  color: rgba(234,216,178,.65);
  font-size: 14px;
}



@media (max-width: 560px) {
    .book {
    gap: 1px;
  }

  .page-inner {
    padding: 20px 11px 38px;
    font-size: 13px;
  }

  .toc-list li { margin: 5px 0; }
  .page-inner p { margin: .65em 0; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}


/* DIN-A5-authentische Buchdarstellung */
.static-page,
.sheet-face {
  border: 1px solid rgba(111, 77, 43, .24);
}

.left-page::after,
.right-page::after,
.sheet-front::after,
.sheet-back::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(255,255,255,.08), transparent 12%, transparent 88%, rgba(90,54,28,.08)),
    radial-gradient(ellipse at center, transparent 64%, rgba(92,55,29,.08) 100%);
  mix-blend-mode: multiply;
}

.left-page {
  transform: rotateY(1.15deg);
}

.right-page {
  transform: rotateY(-1.15deg);
}

.left-page .page-inner,
.right-page .page-inner,
.sheet-face .page-inner {
  max-width: 100%;
  overflow: hidden;
}

@media (min-width: 821px) {
  .page-inner {
    padding: clamp(22px, 3vw, 42px);
    font-size: clamp(14px, 1.25vw, 18px);
    line-height: 1.55;
  }

  .page-inner h1 {
    font-size: clamp(30px, 3.8vw, 50px);
  }

  .page-inner h2 {
    font-size: clamp(24px, 2.9vw, 36px);
  }
}







@media (max-width: 520px) {
  .intro-card {
    width: min(350px, 92vw);
  }
}


  100% {
    width: min(1380px, 132vw);
    transform: translate(-50%, -50%) scale(1);
  }
}


/* Version 10: dieselbe echte Buchansicht bleibt während des gesamten Zooms bestehen */
.reader.is-transitioning {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: block;
  min-height: 100vh;
  padding: 0;
  overflow: hidden;
  background: transparent;
  opacity: 1;
  animation: none;
  pointer-events: none;
}

.reader.is-transitioning .reader-bar,
.reader.is-transitioning .controls,
.reader.is-transitioning .keyboard-tip {
  opacity: 0;
  visibility: hidden;
}

.reader.is-transitioning .book-wrap {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(430px, 90vw);
  margin: 0;
  transform: translate(-50%, -50%);
  transform-origin: center center;
  perspective: 2400px;
}

.reader.is-transitioning .book {
  width: 73.2%;
  margin-left: 14.2%;
  transform:
    translateY(-1.1%)
    rotate(-0.6deg)
    perspective(1200px)
    rotateX(1.4deg);
  filter: drop-shadow(0 8px 9px rgba(0,0,0,.2));
}

.reader.is-transitioning .cover-underlay {
  inset: -7px -9px -8px;
  border-radius: 9px 11px 11px 9px;
}

.reader.is-transitioning .page-inner {
  padding: 10px 12px 14px;
  font-size: 7px;
  line-height: 1.45;
}

.reader.is-transitioning .page-inner h1 {
  font-size: 15px;
  margin-bottom: 4px;
}

.reader.is-transitioning .page-inner h2 {
  font-size: 12px;
  margin-bottom: 5px;
}

.reader.is-transitioning .page-inner .flourish {
  font-size: 10px;
  margin: 2px 0 4px;
}

.reader.is-transitioning .toc-list {
  margin-top: 5px;
}

.reader.is-transitioning .toc-list li {
  margin: 1px 0;
}

.reader.is-transitioning .toc-link {
  padding: 1px 0;
  font-size: 6.4px;
}

.reader.is-transitioning .page-number {
  display: none;
}

.reader.is-transitioning.is-zooming {
  animation: continuousBackdrop 2.8s cubic-bezier(.22,.7,.2,1) forwards;
}

.reader.is-transitioning.is-zooming .book-wrap {
  animation: continuousBookZoom 1.45s cubic-bezier(.2,.78,.18,1) forwards;
}

.reader.is-transitioning.is-zooming .book {
  animation: normalizeBook 1.45s cubic-bezier(.2,.78,.18,1) forwards;
}

.reader.is-transitioning.is-zooming .page-inner {
  animation: normalizeContent 1.45s cubic-bezier(.2,.78,.18,1) forwards;
}

@keyframes continuousBackdrop {
  0% {
    background: rgba(232,223,233,0);
  }
  38% {
    background: rgba(232,223,233,0);
  }
  68% {
    background: rgba(216,202,219,.34);
  }
  100% {
    background:
      radial-gradient(circle at 50% 18%, rgba(255,255,255,.38), transparent 34%),
      radial-gradient(circle at 50% 55%, rgba(155,118,159,.14), transparent 54%),
      linear-gradient(180deg, #e8dfe9 0%, #d7c8da 55%, #c8b6cc 100%);
  }
}

@keyframes continuousBookZoom {
  0% {
    width: min(430px, 90vw);
    top: 50%;
  }
  100% {
    width: min(980px, 92vw, calc(78vh * 296 / 210));
    top: 50%;
  }
}

@keyframes normalizeBook {
  0% {
    width: 73.2%;
    margin-left: 14.2%;
    transform:
      translateY(-1.1%)
      rotate(-0.6deg)
      perspective(1200px)
      rotateX(1.4deg);
    filter: drop-shadow(0 8px 9px rgba(0,0,0,.2));
  }
  100% {
    width: 100%;
    margin-left: 0;
    transform: none;
    filter: drop-shadow(0 13px 14px rgba(77,49,78,.20));
  }
}

@keyframes normalizeContent {
  0% {
    padding: 10px 12px 14px;
    font-size: 7px;
    line-height: 1.45;
  }
  100% {
    padding: clamp(22px, 3vw, 42px);
    font-size: clamp(14px, 1.25vw, 18px);
    line-height: 1.55;
  }
}

.reader.transition-complete {
  animation: none;
}

.reader.transition-complete .reader-bar,
.reader.transition-complete .controls,
.reader.transition-complete .keyboard-tip {
  animation: controlsFadeIn .42s ease both;
}

@keyframes controlsFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}


/* Version 11: aktive Buchansicht vollständig im Bildschirm */
.reader:not(.is-transitioning) .page-inner {
  padding: clamp(22px, 3vw, 42px);
  font-size: clamp(14px, 1.25vw, 18px);
  line-height: 1.55;
}

.reader:not(.is-transitioning) .page-inner h1 {
  font-size: clamp(28px, 3.2vw, 44px);
}

.reader:not(.is-transitioning) .page-inner h2 {
  font-size: clamp(23px, 2.5vw, 34px);
}

.reader:not(.is-transitioning) .toc-list {
  margin-top: 18px;
}

.reader:not(.is-transitioning) .toc-list li {
  margin: 6px 0;
}

.reader:not(.is-transitioning) .toc-link {
  padding: 4px 0;
}

@media (max-height: 760px) and (min-width: 821px) {
  .reader {
    padding-top: 10px;
    padding-bottom: 12px;
  }

  .reader-bar {
    margin-bottom: 6px;
  }

  .book-wrap {
    width: min(860px, 90vw, calc(70vh * 296 / 210));
  }

  .controls {
    margin-top: 8px;
  }

  .keyboard-tip {
    display: none;
  }

  .reader:not(.is-transitioning) .page-inner {
    padding: 18px 28px;
    font-size: 13px;
    line-height: 1.45;
  }
}

@media (max-width: 820px) {
  .book-wrap {
    width: min(94vw, calc(68vh * 296 / 210));
  }

  .reader:not(.is-transitioning) .page-inner {
    padding: 18px 14px 34px;
    font-size: 13px;
    line-height: 1.48;
  }

  .reader:not(.is-transitioning) .page-inner h1 {
    font-size: 26px;
  }

  .reader:not(.is-transitioning) .page-inner h2 {
    font-size: 21px;
  }
}


/* Version 12: sanfter lila Übergang statt schwarzem Rand */
.reader-bar,
.controls {
  color: #5f4664;
}

.reader-button,
.controls button {
  color: #5d415f;
  background: rgba(247, 241, 248, .78);
  border-color: rgba(112, 79, 117, .34);
  box-shadow: 0 7px 16px rgba(91, 62, 95, .14);
}

.reader-button:hover,
.controls button:hover:not(:disabled),
.reader-button:focus-visible,
.controls button:focus-visible {
  background: rgba(255, 250, 255, .96);
}

.keyboard-tip {
  color: rgba(83, 61, 87, .68);
}

.spread-counter {
  color: #5f4664;
  text-shadow: none;
}


/* Version 13: Übergang von der Haupt-Homepage in die Tagebuchseite */
.intro,
.reader {
  inset: 0;
  margin: 0;
  border: 0;
}

.reader {
  box-sizing: border-box;
  background:
    radial-gradient(circle at 50% 18%, rgba(255,255,255,.38), transparent 34%),
    radial-gradient(circle at 50% 55%, rgba(155,118,159,.14), transparent 54%),
    linear-gradient(180deg, #e8dfe9 0%, #d7c8da 55%, #c8b6cc 100%);
}

/* Die obere Bedienleiste liegt frei über der Fläche und bildet keinen Balken mehr. */
.reader-bar {
  position: relative;
  z-index: 8;
  width: min(980px, 92vw);
  margin: 0 auto 8px;
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}

/* Gleiche Außenkante während Zoom und aktiver Ansicht */
.book {
  border-radius: 8px 10px 10px 8px;
}

.cover-underlay {
  inset: -4px -5px -5px;
  border-width: 1px;
  border-radius: 8px 10px 10px 8px;
  box-shadow:
    0 10px 18px rgba(77,49,78,.18),
    inset 0 0 0 1px rgba(255,255,255,.06);
}

/* Schmaler, videonaher Buchrücken */
.gutter {
  width: 11px;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(58,34,20,.14),
    rgba(255,255,255,.10),
    rgba(66,38,22,.15),
    transparent
  );
}

/* Seitenkante feiner halten */
.page {
  box-shadow: inset 0 0 13px rgba(102,64,31,.12);
}

.page-left {
  box-shadow:
    inset -7px 0 10px rgba(91,57,30,.09),
    inset 0 0 11px rgba(102,64,31,.08);
}

.page-right {
  box-shadow:
    inset 7px 0 10px rgba(91,57,30,.09),
    inset 0 0 11px rgba(102,64,31,.08);
}

/* Exakt dieselbe Einbandstärke im Übergang */
.reader.is-transitioning .cover-underlay {
  inset: -4px -5px -5px;
  border-radius: 8px 10px 10px 8px;
}

.reader.is-transitioning .gutter {
  width: 11px;
}

/* Der Endzustand bleibt geometrisch identisch zum letzten Zoom-Frame. */
.reader:not(.is-transitioning) .book {
  width: 100%;
  margin-left: 0;
  transform: none;
}

.reader:not(.is-transitioning) .cover-underlay {
  inset: -4px -5px -5px;
}

/* Für die spätere Einbindung auf Lilas Hauptseite:
   Intro bleibt transparent zur Hauptseite, erst beim Zoom wird die
   Tagebuch-Farbwelt vollständig übernommen. */
.intro:not(.is-finishing) {
  background: transparent;
}

.reader.is-transitioning {
  background: transparent;
}

.reader.is-transitioning.is-zooming {
  animation: continuousBackdrop 2.8s cubic-bezier(.22,.7,.2,1) forwards;
}


/* Version 14: aktive Ansicht ohne zweiten Zoom */
.reader.is-visible:not(.is-transitioning) {
  animation: none !important;
}

.reader.transition-complete .book-wrap {
  animation: microSettle .16s ease-out both;
}

@keyframes microSettle {
  from {
    transform: translateY(.5px);
  }
  to {
    transform: translateY(0);
  }
}


/* Version 17: stabile Buchüberlagerung + unabhängiger langsamer Hintergrund */
html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  background: transparent !important;
}

/* Die Tagebuchfläche selbst bleibt durchsichtig.
   Der lila Zielhintergrund liegt ausschließlich auf der separaten ::before-Ebene. */
.reader,
.reader.is-visible,
.reader.is-transitioning,
.reader.is-visible:not(.is-transitioning) {
  background: transparent !important;
  animation: none !important;
}

.reader {
  isolation: isolate;
}

.reader::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0;
  background:
    radial-gradient(circle at 50% 18%, rgba(255,255,255,.38), transparent 34%),
    radial-gradient(circle at 50% 55%, rgba(155,118,159,.14), transparent 54%),
    linear-gradient(180deg, #e8dfe9 0%, #d7c8da 55%, #c8b6cc 100%);
}

.reader.background-fading::before {
  animation: v18LilacFade 4.8s cubic-bezier(.22,.62,.24,1) forwards;
}

.reader.background-ready::before {
  opacity: 1;
}

@keyframes v17LilacFade {
  0%   { opacity: 0; }
  25%  { opacity: .03; }
  45%  { opacity: .12; }
  65%  { opacity: .30; }
  82%  { opacity: .58; }
  100% { opacity: 1; }
}

/* Alle echten Inhalte bleiben während des gesamten Fades über dem Hintergrund. */
.reader > * {
  position: relative;
  z-index: 2;
}

/* Nach dem Zoom bleibt das Buch exakt auf dessen Endkoordinaten.
   Es wird nicht neu in den normalen Dokumentfluss gesetzt. */
.reader.is-visible:not(.is-transitioning) {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: block;
  width: 100%;
  min-height: 100vh;
  padding: 0 !important;
  overflow: hidden;
}

.reader.is-visible:not(.is-transitioning) .book-wrap {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(980px, 92vw, calc(78vh * 296 / 210));
  margin: 0 !important;
  transform: translate(-50%, -50%);
  perspective: 2400px;
}

.reader.is-visible:not(.is-transitioning) .book {
  width: 100%;
  margin-left: 0;
  transform: none;
  opacity: 1;
  visibility: visible;
}

/* Die Leisten schweben über der Seite und drücken das Buch nicht nach unten. */
.reader-bar {
  position: fixed !important;
  top: 12px;
  left: 50%;
  z-index: 80 !important;
  width: min(980px, 92vw);
  margin: 0 !important;
  padding: 0;
  transform: translateX(-50%);
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
}

.controls {
  position: fixed !important;
  left: 50%;
  bottom: 14px;
  z-index: 80 !important;
  width: auto;
  margin: 0 !important;
  transform: translateX(-50%);
}

.keyboard-tip {
  display: none !important;
}

/* Während des Zooms bleiben Buch und Seiten garantiert sichtbar. */
.reader.is-transitioning .book-wrap,
.reader.is-transitioning .book,
.reader.is-transitioning .static-page,
.reader.is-transitioning .page-inner {
  opacity: 1 !important;
  visibility: visible !important;
}

/* Der Buch-Zoom bleibt exakt so schnell wie in der funktionierenden Version 14. */
.reader.is-transitioning.is-zooming .book-wrap {
  animation-duration: 1.45s !important;
}

.reader.is-transitioning.is-zooming .book,
.reader.is-transitioning.is-zooming .page-inner {
  animation-duration: 1.45s !important;
}


/* Version 18: echter transparenter Ausgangszustand */
.intro,
.reader,
.reader.is-visible,
.reader.is-transitioning,
.reader.is-visible:not(.is-transitioning) {
  background-color: transparent !important;
}

/* Der lila Hintergrund startet mit dem Buch-Zoom und bleibt zunächst sehr dezent. */
.reader.background-fading::before {
  animation: v18LilacFade 4.8s cubic-bezier(.22,.62,.24,1) forwards;
}

@keyframes v18LilacFade {
  0%   { opacity: 0; }
  18%  { opacity: .025; }
  34%  { opacity: .08; }
  50%  { opacity: .18; }
  66%  { opacity: .34; }
  80%  { opacity: .56; }
  92%  { opacity: .80; }
  100% { opacity: 1; }
}


/* Version 19: sichtbarer Fade über echte Ebene */
.reader::before {
  content: none !important;
  display: none !important;
}

/* Der bisher fest eingebaute lila Intro-Hintergrund hatte die Animation verdeckt. */
.intro,
.intro:not(.is-finishing),
.intro.is-playing,
.intro.is-holding {
  background: transparent !important;
}

/* Auch die äußere Seite bleibt bis zum Übergang wirklich transparent. */
html,
body,
.diary-stage {
  background: transparent !important;
}

.diary-fade-bg {
  position: fixed !important;
  inset: 0;
  z-index: 0 !important;
  pointer-events: none;
  opacity: 0;
  visibility: visible;
  background:
    radial-gradient(circle at 50% 18%, rgba(255,255,255,.38), transparent 34%),
    radial-gradient(circle at 50% 55%, rgba(155,118,159,.14), transparent 54%),
    linear-gradient(180deg, #e8dfe9 0%, #d7c8da 55%, #c8b6cc 100%);
  will-change: opacity;
}

.reader.background-fading .diary-fade-bg {
  animation: v19LilacFade 4.8s linear forwards;
}

.reader.background-ready .diary-fade-bg {
  opacity: 1;
}

@keyframes v19LilacFade {
  0%   { opacity: 0; }
  12%  { opacity: .04; }
  25%  { opacity: .10; }
  40%  { opacity: .20; }
  55%  { opacity: .34; }
  70%  { opacity: .52; }
  84%  { opacity: .72; }
  94%  { opacity: .88; }
  100% { opacity: 1; }
}

/* Alle Buchinhalte liegen sicher oberhalb der neuen Hintergrundebene. */
.reader > :not(.diary-fade-bg) {
  position: relative;
  z-index: 2;
}


/* Version 20: reduzierte Bedienelemente direkt an den aktiven Seiten */
.spread-counter,
.controls,
.keyboard-tip {
  display: none !important;
}

/* Menü und Schließen schweben über dem Buch, ohne dessen Lage zu beeinflussen. */
.reader-bar {
  position: fixed !important;
  top: max(14px, calc(50% - min(39vh, 276px) - 56px));
  left: 50% !important;
  width: min(980px, 92vw, calc(78vh * 296 / 210)) !important;
  height: 44px;
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  transform: translateX(-50%) !important;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity .38s ease, visibility .38s ease;
}

.reader.ui-visible .reader-bar {
  opacity: 1;
  visibility: visible;
}

.reader-icon-button {
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid rgba(108, 73, 116, .24);
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: rgba(75, 46, 82, .72);
  background: rgba(249, 244, 250, .38);
  box-shadow: 0 5px 14px rgba(61, 39, 66, .10);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  cursor: pointer;
  pointer-events: auto;
  transition: opacity .22s ease, background .22s ease, transform .18s ease;
}

.reader-icon-button span {
  display: block;
  font: 400 25px/1 Arial, sans-serif;
  transform: translateY(-1px);
}

.reader-icon-button.toc-icon span {
  font-size: 22px;
  letter-spacing: -2px;
  transform: translate(-1px, -1px);
}

.reader-icon-button:hover,
.reader-icon-button:focus-visible {
  color: rgba(63, 34, 71, .96);
  background: rgba(255, 251, 255, .72);
  transform: scale(1.06);
  outline: none;
}

.reader-icon-button:active {
  transform: scale(.94);
}

/* Pfeile liegen direkt auf den äußeren Seitenrändern. */
.page-arrow {
  position: absolute;
  top: 50%;
  z-index: 35;
  width: clamp(34px, 4vw, 48px);
  height: clamp(56px, 8vw, 78px);
  padding: 0;
  border: 0;
  display: grid;
  place-items: center;
  color: rgba(79, 47, 83, .48);
  background: rgba(126, 88, 132, .10);
  box-shadow: inset 0 0 0 1px rgba(96, 64, 101, .08);
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-50%);
  transition: opacity .38s ease, visibility .38s ease, background .22s ease, color .22s ease, transform .16s ease;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.reader.ui-visible .page-arrow {
  opacity: 1;
  visibility: visible;
}

.page-arrow-prev {
  left: 0;
  border-radius: 0 999px 999px 0;
}

.page-arrow-next {
  right: 0;
  border-radius: 999px 0 0 999px;
}

.page-arrow span {
  font: 300 clamp(34px, 4vw, 48px)/1 Georgia, serif;
  transform: translateY(-2px);
}

.page-arrow:hover:not(:disabled),
.page-arrow:focus-visible:not(:disabled) {
  color: rgba(72, 38, 79, .88);
  background: rgba(132, 91, 140, .24);
  outline: none;
}

.page-arrow:active:not(:disabled) {
  transform: translateY(-50%) scale(.94);
}

.page-arrow:disabled {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none;
}

/* Während Video und Zoom bleiben alle Bedienfelder vollständig verborgen. */
.reader.is-transitioning .reader-bar,
.reader.is-transitioning .page-arrow {
  opacity: 0 !important;
  visibility: hidden !important;
}

@media (hover: hover) and (pointer: fine) {
  .page-arrow {
    opacity: .62;
  }

  .reader.ui-visible .page-arrow:hover {
    opacity: 1;
  }
}

@media (max-width: 700px) {
  .reader-bar {
    top: 10px;
    width: calc(100vw - 24px) !important;
  }

  .reader-icon-button {
    width: 36px;
    height: 36px;
  }

  .page-arrow {
    width: 34px;
    height: 58px;
  }
}


/* Version 23: automatische Fortsetzungsseiten für lange TXT-Einträge */
.pagination-measurer-shell {
  position: fixed;
  left: -200vw;
  top: 0;
  z-index: -9999;
  width: min(980px, 92vw, calc(78vh * 296 / 210));
  height: auto;
  visibility: hidden;
  pointer-events: none;
}

.pagination-measurer-shell .static-page {
  width: 50%;
  aspect-ratio: 148 / 210;
}

.pagination-measurer-shell .page-inner {
  height: 100%;
  overflow: hidden;
}

.continuation-heading {
  margin: 0 0 1.1em;
  text-align: center;
  color: var(--muted);
  font-size: .9em;
  font-style: italic;
}

.continuation-heading span {
  white-space: nowrap;
}

/* Version 24: Eingangsvideo ohne eingebrannte Seitenbalken */
.intro-card {
  /* Das beschnittene Video hat jetzt das echte Motivformat 40:27. */
  aspect-ratio: 40 / 27;
  background: transparent !important;
}

.intro-scene,
.opening-video,
.video-endframe {
  object-fit: cover;
  object-position: center center;
  background: transparent !important;
}

/* Winziger Sicherheitsbeschnitt gegen einzelne dunkle Randpixel. */
.opening-video {
  width: 102%;
  height: 102%;
  inset: -1%;
}


/* Mobile Lesemodus: Hochformat zeigt eine große Einzelseite, Querformat die Doppelseite. */
@media (max-width: 820px), (orientation: landscape) and (max-height: 600px) and (pointer: coarse) {
  .reader { padding: 8px 4px 12px !important; }
  .reader-bar { width: calc(100vw - 16px) !important; margin-bottom: 4px !important; }
  .book-wrap { width: min(97vw, calc(88svh * 148 / 210)) !important; }
  .single-page-mode .book { aspect-ratio: 148 / 210 !important; }
  .single-page-mode .left-page,
  .single-page-mode .book-gutter,
  .single-page-mode .turning-sheet { display: none !important; }
  .single-page-mode .right-page {
    display: block !important;
    width: 100% !important;
    left: 0 !important;
    border-radius: 8px !important;
  }
  .single-page-mode .cover-underlay { inset: -4px !important; }
  .reader:not(.is-transitioning) .page-inner {
    padding: 24px 22px 42px !important;
    font-size: clamp(15px, 4.15vw, 18px) !important;
    line-height: 1.58 !important;
  }
  .reader:not(.is-transitioning) .page-inner h1 { font-size: clamp(28px, 8vw, 38px) !important; }
  .reader:not(.is-transitioning) .page-inner h2 { font-size: clamp(23px, 6.4vw, 31px) !important; }
}

@media (max-width: 920px) and (orientation: landscape) {
  .reader { padding: 4px 8px 8px !important; }
  .reader-bar { margin-bottom: 2px !important; }
  .book-wrap { width: min(96vw, calc(86svh * 296 / 210)) !important; }
  .reader:not(.is-transitioning) .page-inner {
    padding: 16px 20px 28px !important;
    font-size: clamp(12px, 1.55vw, 16px) !important;
    line-height: 1.5 !important;
  }
}


/* Version 25: mobile Tagebuchseite nutzt die gesamte Buchfläche. */
@media (max-width: 820px), (orientation: landscape) and (max-height: 600px) and (pointer: coarse) {
  .reader.is-visible:not(.is-transitioning) .book-wrap {
    width: min(94vw, calc(88svh * 148 / 210));
    max-width: 94vw;
  }

  .reader.single-page-mode .book {
    display: grid;
    grid-template-columns: 1fr;
    aspect-ratio: 148 / 210;
  }

  .reader.single-page-mode .left-page,
  .reader.single-page-mode .book-gutter,
  .reader.single-page-mode .turning-sheet {
    display: none !important;
  }

  .reader.single-page-mode .right-page {
    grid-column: 1;
    width: 100%;
    height: 100%;
    aspect-ratio: 148 / 210;
    border-radius: 14px;
    transform: none;
    box-shadow:
      inset 0 0 30px rgba(102,64,31,.16),
      inset 0 -9px 13px rgba(100,65,34,.10);
  }

  .reader.single-page-mode .page-inner {
    padding: clamp(24px, 6vw, 34px) clamp(18px, 5vw, 28px) 42px;
    font-size: clamp(13px, 3.7vw, 16px);
    line-height: 1.52;
  }

  .reader.single-page-mode .page-inner h1 {
    font-size: clamp(28px, 8vw, 40px);
  }

  .reader.single-page-mode .page-inner h2 {
    font-size: clamp(22px, 6.5vw, 32px);
  }

  .pagination-measurer-shell.single-page-mode {
    width: min(94vw, calc(88svh * 148 / 210));
  }

  .pagination-measurer-shell.single-page-mode .static-page {
    width: 100%;
    aspect-ratio: 148 / 210;
  }
}

/* Querformat reagiert nach dem Drehen automatisch und nutzt die verfügbare Höhe. */
@media (orientation: landscape) and (max-height: 560px) {
  .reader.is-visible:not(.is-transitioning) .book-wrap,
  .pagination-measurer-shell {
    width: min(96vw, calc(88svh * 296 / 210));
  }

  .reader:not(.is-transitioning) .page-inner,
  .pagination-measurer-shell .page-inner {
    padding: 16px 22px 28px;
    font-size: clamp(11px, 1.8vw, 14px);
    line-height: 1.42;
  }

  .reader:not(.is-transitioning) .page-inner h1 {
    font-size: clamp(24px, 4vw, 34px);
  }

  .reader:not(.is-transitioning) .page-inner h2 {
    font-size: clamp(19px, 3vw, 27px);
  }
}
