* {
  box-sizing: border-box;
}

:root {
  --background: #faf7f2;
  --foreground: #292929;
  --toolbar: #ffffff;
  --border: #dedbd5;
  --muted: #777;
  --font-size: 18px;
}

body[data-theme="dark"] {
  --background: #18191c;
  --foreground: #e8e6e2;
  --toolbar: #25262b;
  --border: #44464b;
  --muted: #aaa;
}

body[data-theme="sepia"] {
  --background: #f2e5c9;
  --foreground: #493b2d;
  --toolbar: #e9d8b6;
  --border: #cbbb9b;
  --muted: #796950;
}

body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-family: Georgia, "Times New Roman", serif;
  font-size: var(--font-size);
  line-height: 1.5;
  transition: background .2s, color .2s;
}

.toolbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--toolbar);
  border-bottom: 1px solid var(--border);
  transition:
  transform .35s ease,
  opacity .35s ease;
}

.toolbar.hidden {
  transform: translateY(-100%);
  opacity: 0;
  pointer-events: none;
}

.toolbar button {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--background);
  color: var(--foreground);
  padding: 8px 12px;
  font-size: 14px;
  cursor: pointer;
}

.toolbar button[aria-pressed="true"] {
  outline: 2px solid var(--foreground);
  outline-offset: 1px;
}

.toolbar button:focus-visible {
  outline: 2px solid #568bd4;
  outline-offset: 2px;
}

.reader {
  max-width: 720px;
  margin: 0 auto;
  padding: 100px 24px 100px;
}

.book-title {
  text-align: center;
  font-family: Arial, sans-serif;
  font-size: 13px;
  letter-spacing: 2px;
  color: var(--muted);
  margin-bottom: 45px;
}

h1 {
  text-align: center;
  font-size: 1.6em;
  font-weight: normal;
  margin-bottom: 50px;
}

.chapter p {
  margin: 0 0 1.3em;
  text-align: justify;
  hyphens: auto;
  overflow-wrap: break-word;
}

@media (max-width: 600px) {
  .toolbar {
    gap: 6px;
    padding: 10px 6px;
  }

  .toolbar button {
    padding: 8px;
  }

  .reader {
    padding: 95px 20px 70px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
  }
}

/* Kapitelüberschriften */
.chapter-heading {
  text-align: center;
  margin: 0 0 3.5em;
}

.chapter-heading h2 {
  font-size: 1.5em;
  font-weight: normal;
  letter-spacing: 0.08em;
  margin: 0;
}

.chapter-subtitle {
  font-size: 1.05em;
  margin-top: 0.3em;
}

/* Perspektivwechsel */
.perspective {
  margin: 2.5em 0 1em;
  font-weight: bold;
  text-align: left;
}

/* Buchtypischer Fließtext */
.chapter p {
  margin: 0;
  padding: 0;
  text-align: justify;
  text-indent: 0;
  hyphens: auto;
  overflow-wrap: break-word;
}

/* Kein Einzug direkt nach Überschriften */
.chapter-heading + .perspective,
.perspective + p {
  text-indent: 0;
}

/* Szenenwechsel */
.scene-break {
  margin: 2em 0;
  text-align: center;
  text-indent: 0;
}

/* Gedanken */
.thought {
  font-style: italic;
}

/* Smartphone-Anpassung */
@media (max-width: 600px) {
  .chapter-heading {
    margin-bottom: 2.5em;
  }
}

/* WhatsApp-Nachrichten */
.chat {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 1.5em 0;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 0.85em;
  line-height: 1.45;
}

.chat-message {
  max-width: 85%;
  min-width: 100px;
  padding: 10px 14px;
  border-radius: 12px;
  overflow-wrap: break-word;
}

.chat-message.chris {
  align-self: flex-end;
  background: var(--chat-chris);
}

.chat-message.lea {
  align-self: flex-start;
  background: var(--chat-lea);
}

.chat-meta {
  display: flex;
  gap: 8px;
  align-items: baseline;
  margin-bottom: 5px;
  font-size: 0.8em;
  opacity: 0.75;
}

.chat-name {
  font-weight: bold;
}

.chat-text {
  white-space: pre-line;
}

.chat .chat-text p {
  margin: 0;
  padding: 0;
  text-align: left;
  text-indent: 0;
  hyphens: none;
}

/* Farben für die drei Lesemodi */
body[data-theme="light"] {
  --chat-chris: #d9fdd3;
  --chat-lea: #e8e8e8;
}

body[data-theme="dark"] {
  --chat-chris: #225c4b;
  --chat-lea: #34363c;
}

body[data-theme="sepia"] {
  --chat-chris: #d8dfbd;
  --chat-lea: #e4d5b8;
}

@media (max-width: 600px) {
  .chat-message {
    max-width: 92%;
    padding: 9px 11px;
  }
}
.chat .chat-text p {
  margin: 0;
  padding: 0;
  line-height: 1.45;
  text-align: left;
  text-indent: 0;
}
.chat-text {
  white-space: normal;
}

/* Tagebucheinträge */
.diary {
  margin: 2.5em 0;
  padding: 1.5em 1.8em;
  background: var(--diary-bg);
  border-left: 3px solid var(--diary-border);
  border-radius: 0 10px 10px 0;
}

.diary-heading {
  text-align: center;
  margin-bottom: 1.5em;
  font-style: normal;
}

.diary-title {
  font-size: 1.1em;
  font-weight: bold;
}

.diary-date {
  font-size: 0.8em;
  color: var(--muted);
  margin-top: 0.3em;
}

.diary-content {
  font-style: italic;
  line-height: 1.5;
}

.chapter .diary-content p {
  margin: 0;
  padding: 0;
  text-align: left;
  text-indent: 0;
}

/* Light Mode */
body[data-theme="light"] {
  --diary-bg: #f0ebe3;
  --diary-border: #b9a58a;
}

/* Dark Mode */
body[data-theme="dark"] {
  --diary-bg: #25262b;
  --diary-border: #9d8a72;
}

/* Sepia Mode */
body[data-theme="sepia"] {
  --diary-bg: #e9d9b9;
  --diary-border: #ac8d60;
}

@media (max-width: 600px) {
  .diary {
    padding: 1.2em;
    margin: 2em 0;
  }
}

/* Abstand zwischen Kapiteln */
.chapter + .chapter {
  margin-top: 5em;
}
.reader-outro {
  margin: 5em auto 3em;
  padding: 2.5em 1em;
  max-width: 650px;
  text-align: center;
  border-top: 1px solid var(--muted);
}

.reader-outro-divider {
  font-size: 1.2em;
  letter-spacing: .5em;
  margin-bottom: 1.5em;
  color: var(--muted);
}

.reader-outro h2 {
  font-size: 1.5em;
  line-height: 1.3;
  margin-bottom: 1em;
}

.reader-outro p {
  text-align: center;
  margin-bottom: 1.5em;
  hyphens: none;
}

.reader-buy-button {
  display: inline-block;
  padding: .9em 1.8em;
  background: #a34e65;
  color: #fff;
  border-radius: 8px;
  font-weight: bold;
  text-decoration: none;
  transition: background .2s ease;
}

.reader-buy-button:hover {
  background: #87384f;
}

.reader-outro .reader-outro-note {
  margin-top: 1.5em;
  font-size: .75em;
  color: var(--muted);
}