/* =========================================================
   Lesezeit – Stylesheet
   ========================================================= */

:root {
  --bg: #f7f3ec;
  --bg-elev: #ffffff;
  --bg-sunk: #ece6da;
  --text: #1f1b16;
  --text-2: #6b6359;
  --text-3: #9a9186;
  --line: rgba(60, 45, 25, .12);
  --accent: #b5562b;
  --accent-contrast: #fff;
  --shadow: 0 1px 2px rgba(40, 25, 10, .08), 0 8px 24px rgba(40, 25, 10, .10);
  --cover-shadow: 0 1px 1px rgba(0,0,0,.08), 0 6px 14px rgba(40, 25, 10, .22);
  --scrim: rgba(20, 14, 8, .32);

  --r-bg: #fbf8f2;
  --r-text: #221d17;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --tabbar-h: 56px;

  --ui-font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --title-font: ui-serif, "New York", "Iowan Old Style", Georgia, "Times New Roman", serif;

  /* Leseeinstellungen (werden per JS gesetzt) */
  --read-font: ui-serif, "New York", "Iowan Old Style", Georgia, serif;
  --read-size: 19px;
  --read-lh: 1.55;
  --read-margin: 26px;
  --read-align: justify;
  --read-hyphens: auto;

  color-scheme: light;
}

/* ---------- Themen ---------- */
html[data-theme="sepia"] {
  --bg: #f1e7d3; --bg-elev: #f8f0df; --bg-sunk: #e6d9bf;
  --text: #3b2f22; --text-2: #75644f; --text-3: #9c8b73;
  --line: rgba(80, 55, 20, .16);
  --r-bg: #f4ead6; --r-text: #3b2f22;
}

@media (prefers-color-scheme: dark) {
  html[data-theme="auto"] {
    --bg: #141414; --bg-elev: #1f1f1f; --bg-sunk: #0c0c0c;
    --text: #ece7df; --text-2: #a59d92; --text-3: #6f6961;
    --line: rgba(255, 255, 255, .10);
    --accent: #e0875a;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.4);
    --cover-shadow: 0 1px 1px rgba(0,0,0,.4), 0 6px 14px rgba(0,0,0,.55);
    --scrim: rgba(0, 0, 0, .5);
    --r-bg: #161616; --r-text: #d9d3ca;
    color-scheme: dark;
  }
}
html[data-theme="dark"] {
  --bg: #141414; --bg-elev: #1f1f1f; --bg-sunk: #0c0c0c;
  --text: #ece7df; --text-2: #a59d92; --text-3: #6f6961;
  --line: rgba(255, 255, 255, .10);
  --accent: #e0875a;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.4);
  --cover-shadow: 0 1px 1px rgba(0,0,0,.4), 0 6px 14px rgba(0,0,0,.55);
  --scrim: rgba(0, 0, 0, .5);
  --r-bg: #1a1918; --r-text: #d9d3ca;
  color-scheme: dark;
}
html[data-theme="black"] {
  --bg: #000; --bg-elev: #121212; --bg-sunk: #000;
  --text: #e6e1d9; --text-2: #9a938a; --text-3: #5f5a54;
  --line: rgba(255, 255, 255, .10);
  --accent: #e0875a;
  --shadow: 0 1px 2px rgba(0,0,0,.6), 0 8px 24px rgba(0,0,0,.6);
  --cover-shadow: 0 6px 14px rgba(0,0,0,.7);
  --scrim: rgba(0, 0, 0, .6);
  --r-bg: #000; --r-text: #bdb7ae;
  color-scheme: dark;
}

/* ---------- Basis ---------- */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--ui-font);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
[hidden] { display: none !important; }
img { display: block; }

/* ---------- Views ---------- */
.view {
  display: none;
  min-height: 100%;
  padding: calc(var(--safe-top) + 8px) 0 calc(var(--tabbar-h) + var(--safe-bottom) + 24px);
}
.view.active { display: block; animation: fadein .25s ease; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

.large-title { padding: 14px 20px 6px; }
.large-title h1 {
  font-family: var(--title-font);
  font-size: 34px; font-weight: 700; letter-spacing: -.01em;
  margin: 0;
}

.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 18px 20px 10px;
}
.section-head h2 { font-size: 20px; font-weight: 650; margin: 0; letter-spacing: -.01em; }
.text-btn { color: var(--accent); font-size: 15px; }

/* ---------- Weiterlesen ---------- */
.continue { padding: 8px 20px 4px; }
.continue-card {
  display: flex; gap: 16px; align-items: center;
  width: 100%; text-align: left;
  background: var(--bg-elev);
  border-radius: 18px;
  padding: 16px;
  box-shadow: var(--shadow);
}
.continue-card .cover { width: 76px; flex: none; }
.continue-card .meta { min-width: 0; flex: 1; }
.continue-card .eyebrow { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); }
.continue-card .t { font-family: var(--title-font); font-size: 20px; font-weight: 650; margin: 4px 0 2px; line-height: 1.2; }
.continue-card .a { color: var(--text-2); font-size: 14px; }
.continue-card .ch { color: var(--text-3); font-size: 13px; margin-top: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar { height: 4px; border-radius: 2px; background: var(--bg-sunk); overflow: hidden; margin-top: 6px; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 2px; }

/* ---------- Cover ---------- */
.cover {
  position: relative;
  aspect-ratio: 2 / 3;
  border-radius: 4px 7px 7px 4px;
  overflow: hidden;
  box-shadow: var(--cover-shadow);
  background: var(--bg-sunk);
}
.cover img { width: 100%; height: 100%; object-fit: cover; }
.cover::after { /* Buchrücken-Glanz */
  content: ""; position: absolute; inset: 0 auto 0 0; width: 7%;
  background: linear-gradient(90deg, rgba(0,0,0,.18), rgba(255,255,255,.12) 60%, transparent);
  pointer-events: none;
}
.gen-cover {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 14% 12% 12%;
  color: #fff;
  font-family: var(--title-font);
  text-align: center;
}
.gen-cover .gt { font-size: var(--gc-size, 15px); font-weight: 700; line-height: 1.15; overflow-wrap: break-word; hyphens: auto; -webkit-hyphens: auto; }
.gen-cover .gr { width: 30%; height: 1px; background: rgba(255,255,255,.55); margin: 0 auto; }
.gen-cover .ga { font-size: calc(var(--gc-size, 15px) * .72); opacity: .88; font-style: italic; }

/* ---------- Bücherregal ---------- */
.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(94px, 1fr));
  gap: 24px 16px;
  padding: 4px 20px;
}
.book-tile { text-align: left; min-width: 0; display: flex; flex-direction: column; justify-content: flex-start; align-self: start; }
.book-tile > .cover, .book-tile > div { width: 100%; }
.book-tile:active .cover { transform: scale(.97); }
.cover { transition: transform .15s ease; }
.book-tile .t { font-size: 13.5px; font-weight: 600; line-height: 1.25; margin-top: 9px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.book-tile .a { font-size: 12.5px; color: var(--text-2); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.book-tile .p { font-size: 11.5px; color: var(--text-3); margin-top: 3px; }
.book-tile .p.done { color: var(--accent); font-weight: 600; }
.book-tile .badge {
  position: absolute; top: 6px; right: 6px; z-index: 2;
  background: var(--accent); color: #fff; font-size: 10px; font-weight: 700;
  padding: 2px 6px; border-radius: 999px; letter-spacing: .03em;
}

.empty { text-align: center; padding: 40px 30px; color: var(--text-2); }
.empty-illu { font-size: 52px; margin-bottom: 8px; }
.primary-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--accent); color: var(--accent-contrast);
  font-weight: 600; font-size: 16px;
  padding: 13px 22px; border-radius: 14px;
  transition: transform .12s ease, opacity .12s;
}
.primary-btn:active { transform: scale(.97); opacity: .9; }
.primary-btn[disabled] { opacity: .55; }
.secondary-btn {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--bg-sunk); color: var(--text);
  font-weight: 600; font-size: 15px;
  padding: 12px 18px; border-radius: 14px;
}
.danger { color: #c4402f; }

/* ---------- Entdecken ---------- */
.search-wrap { padding: 6px 20px 4px; }
.search {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-sunk); border-radius: 12px;
  padding: 0 12px; height: 40px;
}
.search svg { width: 18px; height: 18px; fill: var(--text-3); flex: none; }
.search input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: transparent;
  font: inherit; font-size: 16px; color: var(--text);
}
.search input::placeholder { color: var(--text-3); }

.chips { display: flex; gap: 8px; padding: 12px 20px 2px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  padding: 7px 14px; border-radius: 999px;
  background: var(--bg-sunk); color: var(--text-2);
  font-size: 14px; font-weight: 550; white-space: nowrap;
}
.chip.active { background: var(--text); color: var(--bg); }

.shelf { margin-top: 10px; }
.shelf .section-head { padding-bottom: 6px; }
.shelf .section-head p { margin: 2px 0 0; font-size: 13px; color: var(--text-2); }
.shelf-row {
  display: grid; grid-auto-flow: column; grid-auto-columns: 112px;
  gap: 16px; overflow-x: auto; padding: 8px 20px 14px;
  scroll-snap-type: x proximity; scroll-padding: 0 20px;
  scrollbar-width: none;
}
.shelf-row::-webkit-scrollbar { display: none; }
.shelf-row .book-tile { scroll-snap-align: start; }

.result-list { padding: 4px 20px; }
.result {
  display: flex; gap: 14px; align-items: center; width: 100%; text-align: left;
  padding: 10px 0; border-bottom: 1px solid var(--line);
}
.result .cover { width: 52px; flex: none; }
.result .meta { min-width: 0; flex: 1; }
.result .t { font-weight: 600; font-size: 15.5px; line-height: 1.25; }
.result .a { color: var(--text-2); font-size: 13.5px; margin-top: 2px; }
.result .s { color: var(--text-3); font-size: 12px; margin-top: 4px; }
.result-info { color: var(--text-2); font-size: 14px; padding: 14px 20px; }
.spinner {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2.5px solid var(--line); border-top-color: var(--accent);
  animation: spin .8s linear infinite; display: inline-block; vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }
.center-pad { padding: 30px; text-align: center; color: var(--text-2); }
.more-btn { display: block; margin: 14px auto; }

/* ---------- Tab-Leiste ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: space-around;
  padding: 6px 0 calc(var(--safe-bottom) + 4px);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-top: .5px solid var(--line);
}
.tab {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  width: 110px; padding: 2px 0; color: var(--text-3); font-size: 10.5px; font-weight: 550;
}
.tab svg { width: 26px; height: 26px; fill: currentColor; }
.tab.active { color: var(--accent); }

/* ---------- Sheets ---------- */
.scrim {
  position: fixed; inset: 0; z-index: 40; background: var(--scrim);
  animation: fadein .2s ease;
}
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  max-height: 88vh; overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: var(--bg-elev);
  border-radius: 22px 22px 0 0;
  padding: 8px 20px calc(var(--safe-bottom) + 22px);
  box-shadow: 0 -10px 40px rgba(0,0,0,.18);
  animation: sheetup .32s cubic-bezier(.2,.9,.25,1);
  max-width: 640px; margin: 0 auto;
}
.sheet.tall { height: 82vh; display: flex; flex-direction: column; }
@keyframes sheetup { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet.closing { animation: sheetdown .22s ease forwards; }
@keyframes sheetdown { to { transform: translateY(100%); } }
.grabber { width: 38px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 14px; }
.sheet-title { margin: 0 0 14px; font-size: 18px; font-weight: 650; text-align: center; }

/* Buchdetails */
.detail-head { display: flex; gap: 18px; align-items: flex-end; margin-bottom: 18px; }
.detail-head .cover { width: 116px; flex: none; }
.detail-head .t { font-family: var(--title-font); font-size: 23px; font-weight: 700; line-height: 1.18; margin: 0 0 6px; }
.detail-head .a { color: var(--text-2); font-size: 15px; }
.detail-head .s { color: var(--text-3); font-size: 13px; margin-top: 8px; }
.detail-actions { display: flex; flex-direction: column; gap: 10px; }
.detail-actions .primary-btn { width: 100%; }
.detail-note { color: var(--text-3); font-size: 12.5px; margin-top: 14px; line-height: 1.45; }
.detail-subjects { color: var(--text-2); font-size: 13.5px; line-height: 1.5; margin: 0 0 16px; }

/* Einstellungen */
.set-row { display: flex; align-items: center; gap: 10px; }
.seg-btn {
  flex: 1; height: 46px; border-radius: 12px; background: var(--bg-sunk);
  display: flex; align-items: center; justify-content: center; font-family: var(--title-font);
}
.seg-btn:active { opacity: .7; }
.font-size-val { width: 54px; text-align: center; font-variant-numeric: tabular-nums; color: var(--text-2); font-size: 15px; }
.set-label { font-size: 12.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); font-weight: 600; margin: 20px 0 8px; }
.themes { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.themes button { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); }
.sw { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); display: block; }
.sw-auto { background: linear-gradient(135deg, #fbf8f2 50%, #1a1918 50%); }
.sw-light { background: #fbf8f2; }
.sw-sepia { background: #f4ead6; }
.sw-dark { background: #1a1918; }
.sw-black { background: #000; }
.themes button.active .sw { outline: 2.5px solid var(--accent); outline-offset: 2px; }
.themes button.active { color: var(--text); font-weight: 600; }

.font-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.font-list button {
  padding: 11px 12px; border-radius: 12px; background: var(--bg-sunk);
  text-align: left; font-size: 17px; border: 2px solid transparent;
}
.font-list button small { display: block; font-family: var(--ui-font); font-size: 11.5px; color: var(--text-3); margin-top: 1px; }
.font-list button.active { border-color: var(--accent); }

.segmented { display: flex; background: var(--bg-sunk); border-radius: 11px; padding: 3px; }
.segmented button { flex: 1; padding: 8px 4px; border-radius: 9px; font-size: 14px; font-weight: 550; color: var(--text-2); }
.segmented button.active { background: var(--bg-elev); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.12); }

.toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 14px 0 0; font-size: 16px; }
.toggle-row input { position: absolute; opacity: 0; pointer-events: none; }
.switch { width: 50px; height: 30px; border-radius: 15px; background: var(--bg-sunk); position: relative; transition: background .2s; flex: none; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0,0,0,.2); transition: transform .2s; }
.toggle-row input:checked + .switch { background: #34c759; }
.toggle-row input:checked + .switch::after { transform: translateX(20px); }

/* Inhalt / Lesezeichen */
.toc-tabs { margin-bottom: 10px; flex: none; }
.toc-list { overflow-y: auto; flex: 1; -webkit-overflow-scrolling: touch; margin: 0 -20px; padding: 0 20px; }
.toc-item {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  width: 100%; text-align: left; padding: 13px 0; border-bottom: 1px solid var(--line);
  font-size: 15.5px;
}
.toc-item .n { color: var(--text-3); font-size: 13px; font-variant-numeric: tabular-nums; flex: none; }
.toc-item.current { color: var(--accent); font-weight: 600; }
.bm-item { display: flex; gap: 10px; align-items: flex-start; border-bottom: 1px solid var(--line); }
.bm-item > button:first-child { flex: 1; text-align: left; padding: 12px 0; min-width: 0; }
.bm-item .bm-ch { font-size: 12.5px; color: var(--accent); font-weight: 600; }
.bm-item .bm-snip { font-family: var(--title-font); font-size: 15px; margin-top: 3px; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.bm-item .bm-date { font-size: 12px; color: var(--text-3); margin-top: 3px; }
.bm-del { padding: 14px 4px; color: var(--text-3); font-size: 20px; line-height: 1; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--safe-bottom) + 84px); z-index: 100;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: rgba(30, 26, 22, .92); color: #fff; font-size: 14.5px; font-weight: 500;
  padding: 10px 16px; border-radius: 12px; max-width: 86vw; text-align: center;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* =========================================================
   Leseansicht
   ========================================================= */
.reader {
  position: fixed; inset: 0; z-index: 30;
  background: var(--r-bg); color: var(--r-text);
  overflow: hidden;
}
.chrome {
  position: absolute; left: 0; right: 0; z-index: 5;
  background: color-mix(in srgb, var(--r-bg) 88%, transparent);
  -webkit-backdrop-filter: saturate(160%) blur(18px);
  backdrop-filter: saturate(160%) blur(18px);
  transition: transform .25s ease, opacity .25s ease;
}
.reader.chrome-hidden .chrome { opacity: 0; pointer-events: none; }
.reader.chrome-hidden .reader-top { transform: translateY(-100%); }
.reader.chrome-hidden .reader-bottom { transform: translateY(100%); }

.reader-top {
  top: 0; display: flex; align-items: center; gap: 2px;
  padding: calc(var(--safe-top) + 4px) 8px 6px;
  border-bottom: .5px solid var(--line);
}
.reader-title { flex: 1; min-width: 0; text-align: center; padding: 0 4px; }
.reader-title #r-title { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reader-title #r-chapter { font-size: 12px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { width: 42px; height: 42px; border-radius: 21px; display: flex; align-items: center; justify-content: center; flex: none; }
.icon-btn:active { background: var(--line); }
.icon-btn svg { width: 24px; height: 24px; fill: currentColor; }
.icon-btn .aa { font-family: var(--title-font); font-size: 19px; font-weight: 600; }
#r-bookmark .bm-fill { display: none; fill: var(--accent); }
#r-bookmark.on .bm-fill { display: block; }
#r-bookmark.on .bm-outline { display: none; }

.reader-bottom {
  bottom: 0; padding: 12px 22px calc(var(--safe-bottom) + 10px);
  border-top: .5px solid var(--line);
}
.r-bottom-row { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--text-2); margin-top: 6px; font-variant-numeric: tabular-nums; }
#r-slider { width: 100%; accent-color: var(--accent); margin: 0; }

.reader-status {
  position: absolute; left: 0; right: 0; bottom: calc(var(--safe-bottom) + 8px);
  text-align: center; font-size: 11.5px; color: var(--text-3);
  font-variant-numeric: tabular-nums; pointer-events: none;
  transition: opacity .2s;
}
.reader:not(.chrome-hidden) .reader-status { opacity: 0; }

/* Viewport */
.r-viewport {
  position: absolute; left: 0; right: 0;
  top: calc(var(--safe-top) + 34px);
  bottom: calc(var(--safe-bottom) + 34px);
  overflow: hidden;
  touch-action: pan-y;
}
.reader.mode-scroll .r-viewport {
  top: 0; bottom: 0;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: calc(var(--safe-top) + 30px) var(--read-margin) calc(var(--safe-bottom) + 40px);
}

.r-content {
  font-family: var(--read-font);
  font-size: var(--read-size);
  line-height: var(--read-lh);
  text-align: var(--read-align);
  hyphens: var(--read-hyphens);
  -webkit-hyphens: var(--read-hyphens);
  overflow-wrap: break-word;
  font-kerning: normal;
  font-variant-ligatures: common-ligatures;
  text-rendering: optimizeLegibility;
}
.reader.mode-paged .r-content {
  position: absolute; top: 0; left: var(--read-margin);
  height: 100%;
  column-fill: auto;
  will-change: transform;
}
.reader.mode-paged .r-content.anim { transition: transform .32s cubic-bezier(.25,.8,.3,1); }
.reader.mode-scroll .r-content { max-width: 40em; margin: 0 auto; }

/* Typografie des Buchtextes */
.r-content p { margin: 0; text-indent: 1.4em; orphans: 2; widows: 2; }
.r-content h1 + p, .r-content h2 + p, .r-content h3 + p, .r-content h4 + p,
.r-content hr + p, .r-content .no-indent, .r-content blockquote p,
.r-content header + p, .r-content p.first { text-indent: 0; }
.r-content h1, .r-content h2, .r-content h3, .r-content h4, .r-content h5, .r-content h6 {
  font-weight: 600; line-height: 1.25; text-align: center; hyphens: manual;
  break-after: avoid; margin: 1.6em 0 1em; text-indent: 0;
}
.r-content h1 { font-size: 1.55em; }
.r-content h2 { font-size: 1.35em; }
.r-content h3 { font-size: 1.15em; }
.r-content h4, .r-content h5, .r-content h6 { font-size: 1em; }
.r-content > :first-child { margin-top: .4em; }
.r-content .chapter-start { margin-top: 2.2em; }
.r-content blockquote { margin: 1em 0 1em 1.2em; font-size: .95em; }
.r-content .poem, .r-content .stanza, .r-content [epub\:type~="z3998:poem"] { text-align: left; margin: 1em 0 1em 1em; }
.r-content .poem p, .r-content .stanza p, .r-content .verse p { text-indent: -1em; padding-left: 1em; }
.r-content img { max-width: 100%; height: auto; max-height: 80vh; margin: 1em auto; break-inside: avoid; }
html[data-theme="dark"] .r-content img[src$=".svg"],
html[data-theme="black"] .r-content img[src$=".svg"] { filter: invert(.88); }
@media (prefers-color-scheme: dark) {
  html[data-theme="auto"] .r-content img[src$=".svg"] { filter: invert(.88); }
}
.r-content figure { margin: 1em 0; text-align: center; break-inside: avoid; }
.r-content figcaption, .r-content .caption { font-size: .85em; color: var(--text-2); }
.r-content hr { border: 0; text-align: center; margin: 1.4em 0; height: 1em; }
.r-content hr::after { content: "⁂"; color: var(--text-3); }
.r-content table { border-collapse: collapse; margin: 1em auto; font-size: .9em; max-width: 100%; }
.r-content td, .r-content th { padding: .2em .5em; vertical-align: top; text-align: left; }
.r-content a { color: inherit; text-decoration-color: color-mix(in srgb, var(--r-text) 30%, transparent); }
.r-content a.fn, .r-content sup a { color: var(--accent); text-decoration: none; }
.r-content .center, .r-content [align="center"] { text-align: center; text-indent: 0; }
.r-content .right, .r-content [align="right"] { text-align: right; }
.r-content small, .r-content .smcap, .r-content .small-caps { font-variant: small-caps; }
.r-content abbr { text-decoration: none; }
.r-content pre { white-space: pre-wrap; font-family: inherit; }
.r-content .pagenum, .r-content .ws-pagenum, .r-content .pageno { display: none; }

.chapter-end {
  text-align: center; padding: 2em 0 1em; text-indent: 0;
  break-inside: avoid;
}
.chapter-end button {
  font-family: var(--ui-font); font-size: 15px; font-weight: 600;
  color: var(--accent); padding: 12px 20px; border-radius: 12px; background: var(--line);
}

/* Lade-Overlay */
.loading-overlay {
  position: fixed; inset: 0; z-index: 60;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: var(--bg); color: var(--text-2); font-size: 15px; text-align: center; padding: 30px;
}
.loading-overlay .lt { font-family: var(--title-font); font-size: 20px; color: var(--text); font-weight: 650; }

@media (min-width: 700px) {
  .book-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
}
