:root {
  --bg: #0f1116;
  --bg-soft: #161922;
  --panel: #1b1f29;
  --panel-2: #212631;
  --line: rgba(255, 255, 255, 0.08);
  --text: #e8eaf1;
  --muted: #9aa3b3;
  --accent: #009959;
  --accent-soft: rgba(0, 153, 89, 0.14);
  --gold: #d8b45c;
  --danger: #ff6b6b;
  --radius: 14px;
  --shadow-lg: 0 24px 70px rgba(0, 0, 0, 0.55);
  --shadow-sm: 0 4px 18px rgba(0, 0, 0, 0.35);
  --font-ui: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  --font-serif: Georgia, "Times New Roman", Times, serif;
  --font-script: "Comic Sans MS", "Comic Sans", "Comic Neue", cursive;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow-x: hidden;
  /* Kein Gummiband-/Overscroll-Effekt der Seite (z. B. iOS-Safari) */
  overscroll-behavior: none;
}

body {
  font-family: var(--font-ui);
  color: var(--text);
  background: radial-gradient(1200px 800px at 70% -10%, rgba(0, 153, 89, 0.07), transparent 60%),
              radial-gradient(1000px 700px at 10% 110%, rgba(216, 180, 92, 0.05), transparent 55%),
              var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ============================================================
   Archiv (index.php)
   ============================================================ */

.site-header {
  border-bottom: 1px solid var(--line);
  background: rgba(15, 17, 22, 0.7);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.header-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 22px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-logo {
  width: 46px;
  height: 54px;
  object-fit: contain;
  flex: none;
}

.brand-text { display: flex; flex-direction: column; }

.brand-title {
  font-family: var(--font-serif);
  font-size: 24px;
  letter-spacing: 0.02em;
  color: #fff;
}

.brand-sub {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 2px;
}

.header-tagline {
  font-family: var(--font-script);
  font-weight: 600;
  font-size: 30px;
  letter-spacing: normal;
  color: #009959;
  white-space: nowrap;
  line-height: 1.2;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 18px;
}

.admin-link {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  transition: color 0.15s, border-color 0.15s;
}

.admin-link:hover {
  color: #fff;
  border-color: #009959;
}

.live-indicator[hidden] { display: none !important; }
.live-indicator {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}
.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #009959;
  flex: none;
}
.viewer-toolbar .live-indicator {
  margin-left: 4px;
  background: var(--panel-2);
}
@media (max-width: 820px) {
  .live-indicator { padding: 6px 9px; font-size: 12px; }
}

.archive-main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 40px 24px 60px;
}

.issue-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 28px;
}

.issue-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}
.issue-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-lg);
  border-color: rgba(0, 153, 89, 0.45);
}

.badge-new {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 3;
  background: linear-gradient(135deg, #009959, #009959);
  color: #08250f;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 6px 12px;
  border-radius: 999px;
  box-shadow: 0 4px 14px rgba(0, 153, 89, 0.4);
}

.cover {
  position: relative;
  aspect-ratio: 3 / 4.2;
  background: var(--bg-soft);
  overflow: hidden;
}
.cover canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  opacity: 0;
  transition: opacity 0.4s ease;
}
.cover canvas.loaded { opacity: 1; }

.cover-ph {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cover-ph::before {
  content: "";
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.12);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.card-body { padding: 16px 16px 10px; }

.card-title {
  margin: 0 0 6px;
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 600;
  line-height: 1.25;
  color: #fff;
}

.card-meta {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 12.5px;
  color: var(--muted);
}
.meta-sep { opacity: 0.5; }

.card-progress {
  padding: 0 16px 16px;
}
.card-progress-bar {
  height: 4px;
  border-radius: 999px;
  background: var(--panel-2);
  overflow: hidden;
}
.card-progress-fill {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #009959, var(--accent));
  box-shadow: 0 0 8px rgba(0, 153, 89, 0.45);
  transition: width 0.4s ease;
}
.card-progress-label {
  display: block;
  margin-top: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
}

.empty {
  text-align: center;
  padding: 80px 20px;
  color: var(--muted);
}
.empty h2 { color: #fff; font-family: var(--font-serif); }
.empty code {
  background: var(--panel-2);
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 13px;
}

.site-footer {
  text-align: center;
  padding: 8px 24px 24px;
  color: var(--muted);
  font-size: 12.5px;
  border-top: 1px solid var(--line);
}

/* ============================================================
   Viewer (viewer.php)
   ============================================================ */

.page-viewer { overflow: hidden; }

.viewer-shell {
  display: flex;
  flex-direction: column;
  height: 100dvh;
}

.viewer-toolbar {
  flex: none;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: rgba(15, 17, 22, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  z-index: 30;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 38px;
  padding: 0 12px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 9px;
  color: var(--text);
  cursor: pointer;
  font-size: 13.5px;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}
.tool-btn:hover { background: var(--panel-2); border-color: var(--line); }
.tool-btn:active { transform: scale(0.97); }
.tool-btn svg { width: 18px; height: 18px; flex: none; }

.tool-btn.active {
  background: var(--accent-soft);
  border-color: rgba(0, 153, 89, 0.4);
  color: var(--accent);
}

#btn-view svg { display: none; }
body.view-auto #btn-view .ic-view-auto,
body.view-single #btn-view .ic-view-single,
body.view-double #btn-view .ic-view-double { display: block; }

.viewer-title {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
}
.viewer-title-name {
  font-family: var(--font-serif);
  font-size: 16px;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.viewer-title-sep, .viewer-title-meta { color: var(--muted); font-size: 12.5px; }
.viewer-title-meta { flex: none; }

/* Marke/Claim in der Viewer-Toolbar (mittig) */
.viewer-brand {
  justify-self: center;
  display: flex;
  align-items: center;
  gap: 12px;
  flex: none;
  user-select: none;
}
.brand-logo-sm {
  width: 34px;
  height: 40px;
  object-fit: contain;
  flex: none;
  display: block;
}
.viewer-brand-claim {
  font-family: var(--font-script);
  font-weight: 600;
  font-size: 26px;
  color: #009959;
  white-space: nowrap;
  line-height: 1.1;
}

.toolbar-actions { justify-self: end; display: flex; align-items: center; gap: 4px; flex: none; position: relative; }

/* Überlauf-Menü „⋮": Am Desktop liegen die Buttons direkt in der Leiste,
   auf schmalen Bildschirmen versammeln sie sich im ⋮-Menü (siehe Media-Query). */
#more-menu { display: contents; }
#btn-more { display: none; }
.tool-label.menu-label { display: none; }

.bookmark-wrap, .share-wrap, .print-wrap, .sound-wrap { position: relative; display: inline-flex; }
.bookmark-wrap .bookmark-popover, .share-wrap .share-popover, .print-wrap .print-popover, .sound-wrap .sound-popover {
  left: 50%;
  right: auto;
  transform: translateX(-50%);
  top: calc(100% + 8px);
}
@media (max-width: 820px), (pointer: coarse) {
  .bookmark-wrap .bookmark-popover, .share-wrap .share-popover, .print-wrap .print-popover, .sound-wrap .sound-popover {
    left: auto;
    right: 0;
    transform: none;
  }
}
body.narrow-ui .bookmark-wrap .bookmark-popover, body.narrow-ui .share-wrap .share-popover, body.narrow-ui .print-wrap .print-popover, body.narrow-ui .sound-wrap .sound-popover {
  left: auto;
  right: 0;
  transform: none;
}
/* Teilen-Menü & Druck-Menü & Merken-Menü & Lautstärke */
.share-popover[hidden], .print-popover[hidden], .bookmark-popover[hidden], .sound-popover[hidden] { display: none; }
.share-popover, .print-popover, .bookmark-popover, .sound-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 45;
  min-width: 190px;
  padding: 6px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.share-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}
.share-option:hover { background: var(--accent-soft); color: var(--accent); }
.share-option svg { width: 18px; height: 18px; flex: none; color: var(--muted); }
.share-option:hover svg { color: var(--accent); }
button.share-option {
  background: none;
  border: 0;
  width: 100%;
  text-align: left;
  font-family: inherit;
  cursor: pointer;
}
button.share-option[hidden] { display: none; }
.print-popover { min-width: 224px; }

/* Lautstärke-Popover (Ton-Button): Slider + Prozentanzeige */
.sound-popover { min-width: 216px; }
/* Kopfzeile: Titel + Schieber links, Schließen-Knopf rechts */
.sound-popover .popover-head { justify-content: flex-start; }
.sound-popover .popover-close { margin-left: auto; }
/* Schieberegler "Ton an/aus" – gleiche Optik wie der "Alle"-Schalter in der
   Benutzerverwaltung (auth.php, .perm-all .switch) */
.sound-switch-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}
.sound-switch-row input { position: absolute; opacity: 0; width: 0; height: 0; }
.sound-switch-row .switch {
  width: 32px;
  height: 16px;
  border-radius: 999px;
  background: #33333c;
  border: 1px solid rgba(0, 153, 89, 0.55);
  position: relative;
  transition: background 0.15s ease;
  flex: none;
}
.sound-switch-row .switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ececf1;
  transition: left 0.15s ease;
}
.sound-switch-row input:checked + .switch { background: #009959; }
.sound-switch-row input:checked + .switch::after { left: 18px; }
.sound-switch-row input:focus-visible + .switch {
  outline: 2px solid #009959;
  outline-offset: 2px;
}
.sound-state { font-size: 13px; color: var(--text); }
.sound-vol-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 6px;
}
.sound-vol-row input[type="range"] {
  flex: 1;
  height: 28px;
  margin: 0;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  /* iOS: Die Ziehbewegung gehört dem Regler, nicht dem Browser-Scroll */
  touch-action: none;
  cursor: pointer;
}
.sound-vol-row input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(to right, var(--accent) var(--vol-fill, 40%), #33333c var(--vol-fill, 40%));
}
.sound-vol-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  margin-top: -9px;
  border-radius: 50%;
  background: #ececf1;
  border: 2px solid var(--accent);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}
.sound-vol-row input[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(to right, var(--accent) var(--vol-fill, 40%), #33333c var(--vol-fill, 40%));
}
.sound-vol-row input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ececf1;
  border: 2px solid var(--accent);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}
.sound-vol-val {
  font-size: 12px;
  color: var(--muted);
  min-width: 38px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.popover-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 2px 6px 8px;
  margin-bottom: 2px;
  border-bottom: 1px solid var(--line);
}
.popover-head-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.popover-close {
  flex: none;
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  border-radius: 7px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.popover-close:hover { color: var(--text); background: var(--panel-2); }
.print-range {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 6px 4px;
  margin-top: 4px;
  border-top: 1px solid var(--line);
}
.print-range input {
  flex: 1;
  min-width: 0;
  height: 32px;
  padding: 0 9px;
  box-sizing: border-box;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font-size: 12px;
  font-family: inherit;
}
.print-range input:focus { outline: none; border-color: var(--accent); }
.print-range input.invalid { border-color: var(--danger); }
.print-range-btn {
  height: 32px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #08120b;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
}
.print-range-btn:hover { filter: brightness(1.08); }
.share-toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(10px);
  z-index: 80;
  padding: 9px 16px;
  background: var(--panel);
  border: 1px solid rgba(0, 153, 89, 0.4);
  border-radius: 999px;
  box-shadow: var(--shadow-lg);
  color: var(--text);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.share-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.zoom-group { display: flex; align-items: center; }
.zoom-group .tool-btn { padding: 0 6px; }
.zoom-val {
  min-width: 62px;
  justify-content: center;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  background: var(--panel-2);
  border-color: var(--line);
  font-weight: 600;
}
.zoom-val.active {
  background: var(--accent-soft);
  border-color: rgba(0, 153, 89, 0.4);
  color: var(--accent);
}
.zoom-val svg { width: 14px; height: 14px; flex: none; }
.zoom-val:not(.active) .zoom-reset-ic { display: none; }
.zoom-val:hover {
  background: var(--accent-soft);
  border-color: rgba(0, 153, 89, 0.4);
  color: var(--accent);
}

.ic-fs-exit { display: none; }
body.is-fullscreen .ic-fs-enter { display: none; }
body.is-fullscreen .ic-fs-exit { display: block; }

/* Umblätter-Sound */
#btn-sound .ic-sound-off { display: none; }
#btn-sound.off .ic-sound-on { display: none; }
#btn-sound.off .ic-sound-off { display: block; }

/* Suchleiste: füllt dynamisch die verfügbare Breite (Container minus
   24px Ränder) und wird nie breiter als der Bildschirm. Die Breite wird
   explizit mit calc gesetzt (kein width:auto/max-content), damit iOS
   Safari die Zeile nicht auf die Inhaltsbreite aufbläht und die Seite
   nicht horizontal übersteht. Das Eingabefeld schrumpft (flex 1, min-
   width 0), die Treffer-Anzeige ("1 / 6") bleibt vollständig sichtbar. */
.search-bar[hidden] { display: none; }
.search-bar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
  box-sizing: border-box;
  width: calc(100% - 24px);
  max-width: 100%;
  overflow: hidden;
  margin-left: 12px;
  margin-right: 12px;
  margin-bottom: 8px;
  padding: 6px 8px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-top: none;
  border-radius: 0 0 10px 10px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.3);
}
/* Auf breiten Bildschirmen die Leiste rechtsbündig und nicht über die ganze Breite spannen */
@media (min-width: 900px) {
  .search-bar { max-width: 520px; margin-left: auto; margin-right: 20px; }
}
.search-ic { width: 16px; height: 16px; flex: none; color: var(--muted); }
.search-input {
  flex: 1 1 auto;
  min-width: 0;
  width: auto;
  height: 34px;
  padding: 0 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  outline: none;
}
.search-input:focus { border-color: var(--accent); }
.search-count {
  flex: none;
  min-width: 0;
  text-align: right;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.search-navgroup { display: flex; gap: 4px; flex: none; }
.search-nav {
  flex: none;
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text);
  cursor: pointer;
}
.search-nav:hover { background: var(--accent-soft); border-color: rgba(0, 153, 89, 0.4); color: var(--accent); }
.search-nav:disabled { opacity: 0.35; cursor: default; }
.search-nav svg { width: 16px; height: 16px; }
.search-clear {
  flex: none;
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
  border-radius: 7px;
}
.search-clear:hover { color: var(--text); background: var(--panel-2); }

/* Treffer-Hervorhebung über dem Buch */
.search-overlay {
  position: fixed;
  inset: 0;
  z-index: 45;
  pointer-events: none;
  overflow: hidden;
}
.search-hl {
  position: absolute;
  background: rgba(0, 153, 89, 0.3);
  outline: 1px solid rgba(0, 153, 89, 0.6);
  border-radius: 2px;
}
.search-hl.current {
  background: rgba(216, 180, 92, 0.55);
  outline-color: rgba(216, 180, 92, 0.9);
}

.viewer-body {
  flex: 1;
  min-height: 0;
  display: flex;
  position: relative;
}

.stage-wrap {
  flex: 1;
  min-width: 0;
  position: relative;
  overflow: auto;
  overflow-anchor: none;
  /* Kein Gummiband-/Overscroll-Effekt (iOS-Safari federt sonst am Rand
     elastisch hoch und springt zurueck); echtes Scrollen/Zoomen bleibt. */
  overscroll-behavior: none;
  background:
    radial-gradient(900px 500px at 50% 0%, rgba(255, 255, 255, 0.035), transparent 65%),
    var(--bg);
}

.stage-wrap {
  display: flex;
}

.stage-box {
  margin: auto;
  flex: none;
  padding: 8px;
}

.book-wrap {
  position: relative;
  width: 800px;
  height: 1100px;
  will-change: width, height;
}

/* StPageFlip-Buch. Per JS wird die Buch-Fläche (.book-wrap) um reservierte
   Stapelstreifen erweitert: in der Doppelansicht (landscape) links und rechts,
   in der Einzelansicht (portrait) rechts – damit der 3D-Seitenstapel außerhalb
   der sichtbaren Seiten liegt. Das Buch selbst behält seine volle Größe. */
#book {
  position: relative;
  width: 100%;
  height: 100%;
  margin: 0 auto;
  /* pan-y: Vertikales Scrollen der Bühne bleibt erlaubt, horizontale
     Wisch-Gesten werden aber NICHT vom Browser als Scroll übernommen.
     Chromium bricht sonst horizontale Swipes mit touchcancel ab (Firefox
     nicht) – dadurch lief auf Android die falsche Blätterrichtung. */
  touch-action: pan-y;
}
#book .stf__block {
  border-radius: 6px;
  box-shadow: var(--shadow-lg);
  overflow: visible;
}
#book .stf__item {
  background: #fff;
  border-radius: 2px;
  overflow: hidden;
}
#book .stf__item img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
  user-select: none;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
  pointer-events: none;
  background: #fff;
}

/* Canvas-Ueberstand beim Blaettern: Im Canvas-Modus der Library wird das
   ganze Buch inklusive Klapp-Blatt in EIN <canvas> gemalt, das exakt so gross
   wie das Magazin ist – alles, was ueber Ober-/Unterkante hinausreicht,
   verschwindet an der Bitmap-Kante ("Blatt faellt hinter einen Rand").
   body.is-flipping (viewer.js) verlaengert das Canvas daher symmetrisch nach
   oben und unten um --flip-overhang. Das Buch selbst bleibt optisch EXAKT an
   seiner Stelle: Die Library zentriert die Buchflaeche im Canvas, ein um P
   verlaengertes Canvas verschiebt den Buchursprung im Bitmap-Koordinatensystem
   exakt um P – auf dem Bildschirm aendert sich nichts, nur der Zeichenraum
   wächst. Zurueckgestellt wird sofort bei "read" bzw. Zoom (viewer.js). */
#book canvas.stf__canvas.flip-overhang {
  top: calc(-1 * var(--flip-overhang, 90px));
  height: calc(100% + var(--flip-overhang, 90px) * 2);
}

/* Vergrößerter Zustand: Buch reagiert nicht mehr auf Klicks, Ziehen verschiebt den Ausschnitt */
body.is-zoomed #book { pointer-events: none; }
body.is-zoomed .stage-wrap { cursor: grab; touch-action: none; }
body.is-zoomed .stage-wrap.panning { cursor: grabbing; }
/* Während einer Pinch-Geste verhindert touch-action: none den Browser-Zoom */
.stage-wrap.pinching { touch-action: none !important; }

/* Ueberstand aktiv, aber noch kein Fold (Fenster zwischen Auflegen des
   Fingers und Blattstart): Die Buehne muss in diesem Moment NICHT scrollbar
   sein – das nach unten verlaengerte Canvas vergroessert sonst ihren
   scrollbaren Bereich und Android laesst sich das Heft beim Ziehen nativ
   nach oben verschieben ("Gummiband": Rueckstellung clampt scrollTop).
   overflow:hidden unterbindet das; es clippt hier unsichtbar, weil vor dem
   Fold nichts ausserhalb des Buchs gemalt wird. Die spaetere body.is-flipping-
   Regel (gleiche Spezifitaet) gewinnt ab Fold-Beginn und schaltet auf
   overflow:visible um. */
body.overhang-active .stage-wrap {
  overflow: hidden;
}

/* Blättert gerade ein Blatt, ragt es durch die 3D-Perspektive optisch ueber
   Ober-/Unterkante des Magazins hinaus. Damit es dort sichtbar bleibt und
   nicht hinter einem Rand verschwindet, loest body.is-flipping (viewer.js,
   changeState) den Scroll-Clip der Buehne und malt die Buehne ueber die
   Leisten: Toolbar z-index 30, Fussleiste/Lesezeichen-Panel/Fortschritt 25,
   Seitenpfeile 35 – 40 reicht aus, bleibt aber unter Hinweisen/Modals (50+).
   Nur ungezoomt aktiv; im Zoom behaelt die Buehne ihren Clip (siehe viewer.js). */
body.is-flipping .stage-wrap {
  overflow: visible;
  z-index: 40;
}

/* Steuer-Elemente ueber dem Klappblatt halten: Die Buehne malt beim Blaettern
   mit z-index 40 bewusst UEBER die Leisten (Toolbar 30, Fussleiste 25). Im
   Einseitig-Modus reicht das Heft aber fast bis an den Fensterrand – Blatt
   und Schatten fahren dort ueber den Menue-Knopf (z-index 22) und die
   Blaetter-Pfeile (z-index 35), die verschwanden dadurch kurzfristig und
   waren nicht antippbar. Waehrend des Blätterns liegen beide deshalb UEBER
   der Buehne; die Leisten-Hintergruende bleiben weiterhin unter dem Blatt. */
body.is-flipping .panel-open-tab { z-index: 45; }
body.is-flipping .page-arrow { z-index: 45; }

/* Greifzone am linken/rechten Rand der sichtbaren Seite (Einzel- und Doppelseiten-Ansicht): Cursor → Hand */
.book-wrap.grip-zone { cursor: pointer; }

/* Glasscheibe direkt über dem Buch: Im Zoomzustand fängt sie alle Touch-Events ab,
   damit die Blätter-Library das Verschieben nie als Umblättern missversteht.
   Sie liegt im .book-wrap, folgt dadurch exakt jedem Pan/Scroll und jedem Zoom.
   Pan, Pinch und Doppeltipp laufen weiter über .stage-wrap (scroll). */
#pan-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: none;
  touch-action: none;
  cursor: grab;
}
body.is-zoomed #pan-overlay { display: block; }
.stage-wrap.panning #pan-overlay { cursor: grabbing; }

.live-panel-indicator[hidden] { display: none !important; }
.live-panel-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin: 10px 10px 0;
  padding: 7px 12px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  border: 1px solid rgba(0,153,89,0.35);
  border-radius: 999px;
  white-space: nowrap;
}
.live-panel-indicator .live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #009959;
  flex: none;
}

/* Seitenleiste Thumbnails */
.thumbs-panel {
  flex: none;
  width: 232px;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-right: 1px solid var(--line);
  z-index: 25;
}
.thumbs-panel.closed { display: none; }
.thumbs-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 10px 10px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  min-width: 0;
}
.thumbs-header-title { font-size: 12.5px; font-weight: 600; color: var(--muted); }

.panel-tabs {
  flex: 1;
  min-width: 0;
  display: flex;
  gap: 2px;
  padding: 2px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 9px;
}
.panel-tabs[hidden] { display: none; }
.panel-tab {
  flex: 1 1 0;
  min-width: 0;
  height: 26px;
  padding: 0 4px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.panel-tab:hover { color: var(--text); }
.panel-tab.active {
  background: var(--panel-2);
  color: var(--text);
  border-color: rgba(0,153,89,0.45);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

.panel-collapse {
  flex: none;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 7px;
  color: var(--muted);
  cursor: pointer;
}
.panel-collapse:hover { color: var(--text); background: var(--panel-2); }
.panel-collapse svg { width: 16px; height: 16px; }

.panel-open-tab {
  position: absolute;
  left: 0;
  top: 24px;
  z-index: 22;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 10px 6px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: none;
  border-radius: 0 12px 12px 0;
  box-shadow: var(--shadow-lg);
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
}
.viewer-body:has(.thumbs-panel.closed) .panel-open-tab { display: flex; }
.panel-open-tab:hover { color: var(--accent); }
.panel-open-tab svg { width: 18px; height: 18px; }
.panel-open-tab .chev-icon { display: none; }

/* Sobald das PDF unter den Button rutscht, schrumpft er auf ein kompaktes
   Chevron, damit er den Inhalt nicht verdeckt (siehe JS-Überlappungsprüfung). */
.panel-open-tab.compact { width: 28px; padding: 11px 0; gap: 0; }
.panel-open-tab.compact span { display: none; }
.panel-open-tab.compact .grid-icon { display: none; }
.panel-open-tab.compact .chev-icon { display: block; width: 26px; height: 26px; }

.toc-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.toc-list[hidden] { display: none; }
.toc-list::-webkit-scrollbar { width: 8px; }
.toc-list::-webkit-scrollbar-thumb { background: var(--panel-2); border-radius: 8px; }
.toc-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease;
}
.toc-item:hover { background: var(--panel-2); }
.toc-item.active { background: var(--accent-soft); color: var(--accent); }
.toc-item.group {
  cursor: default;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 12px 10px 6px;
}
.toc-item.group:hover { background: transparent; }
.toc-item.sub { padding-left: 26px; font-size: 12.5px; color: var(--muted); }
.toc-label { flex: 1; min-width: 0; overflow-wrap: anywhere; }

.thumbs-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.thumbs-list[hidden] { display: none; }
.thumbs-list::-webkit-scrollbar { width: 8px; }
.thumbs-list::-webkit-scrollbar-thumb { background: var(--panel-2); border-radius: 8px; }

.bookmarks-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.bookmarks-list[hidden] { display: none; }
.bookmarks-list::-webkit-scrollbar { width: 8px; }
.bookmarks-list::-webkit-scrollbar-thumb { background: var(--panel-2); border-radius: 8px; }
.bm-empty {
  padding: 18px 12px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}
.bm-empty-icon {
  display: inline-flex;
  vertical-align: -3px;
  width: 16px;
  height: 16px;
  color: var(--muted);
  margin: 0 1px;
}
.bm-empty-icon svg { width: 16px; height: 16px; }
.bm-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.bm-thumb {
  flex: none;
  width: 52px;
  aspect-ratio: 3 / 4.2;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg-soft);
  padding: 0;
  cursor: pointer;
  position: relative;
}
.bm-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.bm-thumb-ph {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.bm-thumb-ph::before {
  content: "";
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.14);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}
.bm-go {
  flex: 1;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 0;
}
.bm-go:hover { color: var(--gold); }
.bm-del {
  flex: none;
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 7px;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
}
.bm-del:hover { color: var(--danger); background: rgba(255,107,107,0.12); border-color: rgba(255,107,107,0.25); }

.thumb {
  position: relative;
  flex: none;
  display: block;
  width: 100%;
  border: 2px solid transparent;
  border-radius: 8px;
  background: var(--bg-soft);
  padding: 0;
  cursor: pointer;
  overflow: hidden;
  transition: border-color 0.15s ease, opacity 0.15s ease;
}
.thumb:hover { border-color: rgba(255, 255, 255, 0.25); }
.thumb.active { border-color: var(--accent); }

.thumb canvas {
  display: block;
  width: 100%;
  height: auto;
}
.thumb img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 4.2;
  object-fit: contain;
  background: var(--bg-soft);
}
.thumb .thumb-num {
  position: absolute;
  right: 6px;
  bottom: 6px;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  background: rgba(0, 0, 0, 0.55);
  padding: 2px 7px;
  border-radius: 999px;
  backdrop-filter: blur(4px);
}
.thumb.has-match::after {
  content: "";
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 2px rgba(15, 17, 22, 0.7);
}
.thumb.has-bookmark::before {
  content: "";
  position: absolute;
  top: 0;
  left: 10px;
  width: 18px;
  height: 24px;
  background: var(--gold);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 74%, 0 100%);
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  z-index: 2;
}
.thumb.has-bookmark.has-match::after {
  top: 6px;
  right: 6px;
}
#btn-bookmark.active {
  background: rgba(216,180,92,0.18);
  border-color: rgba(216,180,92,0.45);
  color: var(--gold);
}
#btn-bookmark.active svg { fill: var(--gold); stroke: var(--gold); }
.thumb-bm {
  position: absolute;
  top: 6px;
  left: 6px;
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(15,17,22,0.72);
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 7px;
  color: rgba(255,255,255,0.85);
  cursor: pointer;
  backdrop-filter: blur(4px);
  z-index: 3;
}
.thumb-bm:hover { background: rgba(216,180,92,0.22); border-color: rgba(216,180,92,0.4); color: var(--gold); }
.thumb-bm svg { width: 14px; height: 14px; }
.thumb.has-bookmark .thumb-bm { background: rgba(216,180,92,0.92); border-color: var(--gold); color: #1a1400; }
.thumb.has-bookmark .thumb-bm svg { fill: #1a1400; }
.thumb .thumb-ph {
  aspect-ratio: 3 / 4.2;
  display: flex;
  align-items: center;
  justify-content: center;
}
.thumb .thumb-ph::before {
  content: "";
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.14);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}

/* Untere Leiste */
.viewer-bottom {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 10px 14px;
  background: rgba(15, 17, 22, 0.85);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  /* Unter der oberen Toolbar (z-index 30): Das offene ⋮-Menü soll darüber
     schweben und nicht hinter dieser Leiste verschwinden. */
  z-index: 25;
}

.nav-btn {
  width: 44px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}
.nav-btn:hover { background: var(--accent-soft); border-color: rgba(0, 153, 89, 0.4); color: var(--accent); }
.nav-btn:active { transform: scale(0.95); }
.nav-btn svg { width: 20px; height: 20px; }
.nav-btn:disabled { opacity: 0.35; cursor: default; }

.page-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.page-indicator input {
  width: 62px;
  height: 38px;
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  outline: none;
}
.page-indicator input:focus { border-color: var(--accent); }
/* Spinner-Pfeile (Hoch/Runter) im Zahlenfeld ausblenden – der Browser zeigt
   sie sonst am Desktop beim Hover/Fokus an. Tippen/Eingeben bleibt unverändert. */
.page-indicator input::-webkit-outer-spin-button,
.page-indicator input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.page-indicator input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}
#page-total { color: var(--muted); }

/* Handy im Querformat (JS-Klasse .phone-landscape): Untere Leiste deutlich
   schlanker, damit den Seiten mehr vertikale Höhe bleibt und nichts mehr
   über den Rand hinaus scrollt. */
body.phone-landscape .viewer-bottom {
  gap: 10px;
  padding: 3px 10px;
}
body.phone-landscape .nav-btn {
  width: 32px;
  height: 30px;
  border-radius: 8px;
}
body.phone-landscape .nav-btn svg { width: 16px; height: 16px; }
body.phone-landscape .page-indicator {
  gap: 4px;
  font-size: 12px;
}
body.phone-landscape .page-indicator input {
  width: 46px;
  height: 28px;
  font-size: 13px;
  border-radius: 8px;
}

/* Dezente Blätter-Pfeile links/rechts neben dem PDF */
.page-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 35;
  width: 46px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  opacity: 0.22;
  cursor: pointer;
  transition: opacity 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.page-arrow.left { left: 8px; }
.page-arrow.right { right: 8px; }
.viewer-body:has(.thumbs-panel:not(.closed)) .page-arrow.left { left: 224px; }
.page-arrow:hover { opacity: 0.85; color: var(--accent); background: var(--accent-soft); }
.page-arrow:active { transform: translateY(-50%) scale(0.9); }
.page-arrow svg { width: 28px; height: 28px; }

/* Lesefortschritt (unten) */
.read-progress {
  flex: none;
  height: 8px;
  background: var(--panel-2);
  overflow: visible;
  z-index: 25;
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: center;
}
.read-progress::before {
  content: "";
  position: absolute;
  inset: -6px 0;
}
.read-progress-bar {
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg, #009959, var(--accent));
  box-shadow: 0 0 10px rgba(0, 153, 89, 0.55);
  transition: width 0.25s ease;
  pointer-events: none;
  border-radius: 999px;
}
.read-progress-handle {
  position: absolute;
  top: 50%;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #009959;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
  transform: translate(-50%, -50%);
  left: 0%;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease, left 0.25s ease;
}
.read-progress:hover .read-progress-handle,
.read-progress.dragging .read-progress-handle {
  opacity: 1;
}
.read-progress:hover .read-progress-bar,
.read-progress.dragging .read-progress-bar {
  height: 4px;
}
#btn-autoplay .ic-pause { display: none; }
#btn-autoplay.playing .ic-play { display: none; }
#btn-autoplay.playing .ic-pause { display: block; }
#btn-autoplay.playing { background: var(--accent-soft); border-color: rgba(0,153,89,0.4); color: var(--accent); }

/* Lade-Overlay */
.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(11, 13, 18, 0.92);
  backdrop-filter: blur(6px);
  opacity: 1;
  transition: opacity 0.4s ease;
}
.loading-overlay.hidden { opacity: 0; pointer-events: none; }

.loading-card {
  width: min(360px, 86vw);
  text-align: center;
  padding: 36px 28px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}
.loading-spinner {
  width: 46px;
  height: 46px;
  margin: 0 auto 18px;
  border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}
.loading-title { margin: 0 0 6px; font-weight: 600; color: #fff; font-size: 15px; }
.loading-sub { margin: 0 0 16px; color: var(--muted); font-size: 12.5px; }
.loading-bar {
  height: 6px;
  border-radius: 999px;
  background: var(--panel-2);
  overflow: hidden;
}
.loading-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #009959, #009959);
  transition: width 0.2s ease;
}

/* Fehler-Overlay */
.error-card { color: var(--danger); }
.error-card .error-msg { color: var(--muted); font-size: 13px; }

/* Fortschritts-Banner (Vorschauen werden erzeugt) */
.gen-banner[hidden] { display: none; }
.gen-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--line);
  flex: none;
}
.gen-text {
  flex: 1;
  min-width: 0;
  font-size: 12.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gen-bar {
  flex: none;
  width: min(240px, 30vw);
  height: 6px;
  border-radius: 999px;
  background: var(--panel-2);
  overflow: hidden;
}
.gen-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #009959, #009959);
  transition: width 0.2s ease;
}

/* Hinweis „Fortsetzen bei Seite …" */
.resume-banner[hidden] { display: none; }
.resume-banner {
  position: absolute;
  left: 50%;
  top: 18px;
  transform: translateX(-50%);
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100% - 32px);
  padding: 8px 10px 8px 16px;
  background: var(--panel);
  border: 1px solid rgba(0, 153, 89, 0.4);
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
}
.resume-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.resume-btn {
  flex: none;
  height: 28px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid rgba(0, 153, 89, 0.4);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.resume-btn:hover { background: rgba(0, 153, 89, 0.25); }
.resume-close {
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.resume-close:hover { color: var(--text); background: var(--panel-2); }

/* Token-Dialog */
.modal-backdrop[hidden] { display: none; }
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(7, 9, 13, 0.72);
  backdrop-filter: blur(4px);
}
.modal-card {
  width: min(400px, 90vw);
  padding: 22px 22px 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}
.modal-title {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
}
.modal-desc {
  margin: 0 0 14px;
  font-size: 12.5px;
  color: var(--muted);
}
.modal-input {
  width: 100%;
  box-sizing: border-box;
  height: 38px;
  padding: 0 11px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font-size: 13.5px;
}
.modal-input:focus {
  outline: none;
  border-color: var(--accent);
}
.modal-error {
  margin-top: 8px;
  font-size: 12px;
  color: var(--danger);
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}
.modal-btn {
  height: 34px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.modal-btn:hover { background: var(--panel-2); }
.modal-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #08120b;
  font-weight: 600;
}
.modal-btn.primary:hover { filter: brightness(1.08); }

/* Hilfe-Dialog */
.help-card { width: min(560px, 92vw); }
.help-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.help-head .modal-title { margin-bottom: 0; }
.help-close {
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 6px;
}
.help-close:hover { color: #fff; background: var(--panel-2); }
.help-body { max-height: min(70vh, 560px); overflow-y: auto; padding-right: 6px; }
.help-body h4 {
  margin: 14px 0 6px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
}
.help-body h4:first-child { margin-top: 6px; }
.help-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 6px 2px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 13px;
}
.help-row:last-child { border-bottom: 0; }
.help-act { color: var(--text); }
.help-cap { display: flex; align-items: center; gap: 4px; flex: none; }
.help-cap kbd {
  display: inline-block;
  min-width: 26px;
  text-align: center;
  padding: 3px 7px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 12px;
  color: #fff;
}
.help-cap kbd.shift { min-width: 0; }
.help-text { color: var(--muted); font-size: 12.5px; }

/* Hilfe-Tabs (Tastenkürzel / Bedienungsanleitung) */
.help-tabs {
  display: flex;
  gap: 4px;
  padding: 3px;
  margin: 2px 0 8px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 9px;
}
.help-tab {
  flex: 1 1 0;
  height: 30px;
  padding: 0 10px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.help-tab:hover { color: var(--text); }
.help-tab.active {
  background: var(--panel-2);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

/* Bedienungsanleitung: Eintrag mit Überschrift + Beschreibung */
.help-manual .help-row {
  display: block;
  padding: 7px 2px;
}
.help-manual .help-act {
  display: block;
  font-weight: 600;
  margin-bottom: 2px;
}
.help-manual .help-cap {
  display: block;
  flex: none;
  text-align: left;
}
.help-manual .help-cap .help-text {
  display: inline;
  font-size: 13px;
}
.help-manual .help-intro {
  margin: 4px 2px 10px;
  padding: 0;
  background: none;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text);
}
.help-or {
  color: var(--muted);
  font-size: 11px;
  padding: 0 2px;
}

/* Responsive */
@media (max-width: 820px) {
  .header-tagline { font-size: 24px; }
  .tool-label { display: none; }
  .tool-btn { padding: 0 9px; }
  .viewer-brand-claim { font-size: 20px; }
  .viewer-title-meta, .viewer-title-sep { display: none; }
  /* Offene Seitenleiste schiebt die Bühne beiseite (nicht Overlay), damit die
     PDF-Seite komplett sichtbar bleibt. Die schmalere Bühne wird über den
     ResizeObserver (computeBaseFit/applyLayout) neu skaliert. */
  .thumbs-panel { flex: none; }
  .thumbs-panel.closed { display: none; }
  .panel-open-tab { top: 8px; }

  /* ⋮-Menü: Nur + % - bleiben in der Leiste, der Rest wandert ins Dropdown */
  #more-menu {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 45;
    min-width: 200px;
    padding: 6px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
  }
  #more-menu .tool-btn {
    justify-content: flex-start;
    width: 100%;
    padding: 0 12px;
    gap: 10px;
  }
  /* Einheitliche Icon-Spalte (!wichtig gegen den 30px-Inline-Stil des
     Lesemodus-Icons) und Text sauber daneben linksbuendig */
  #more-menu .tool-btn > svg { width: 18px !important; height: 18px !important; }
  #more-menu .tool-btn .tool-label {
    flex: 1 1 auto;
    text-align: left;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  /* Teilen/Merken/Drucken/Ton: Wrap auf Zeilenbreite strecken, damit
     Hover-/Klickflaeche wie bei den blossen Buttons die ganze Zeile ist */
  #more-menu .share-wrap,
  #more-menu .bookmark-wrap,
  #more-menu .print-wrap,
  #more-menu .sound-wrap { display: flex !important; }
  #more-menu .share-wrap .tool-btn,
  #more-menu .bookmark-wrap .tool-btn,
  #more-menu .print-wrap .tool-btn,
  #more-menu .sound-wrap .tool-btn { flex: 1 1 auto; }
  body.more-open #more-menu { display: flex; }
  #btn-more { display: inline-flex; }
  body.more-open #more-menu .tool-label { display: inline; }
}

/* Tablet hochkant (einseitig, Breite ≥ 820px, Touch): gleiche kompakte UI wie
   beim Mobile-Breakpoint – Seitenmenü eingeklappt, Toolbar-Buttons hinter dem
   ⋮-Menü. Im Querformat (doppelseitig) entfällt die Klasse und Menü/Leiste
   öffnen sich wieder. Die Klasse setzt syncNarrowUi() in viewer.js. */
body.narrow-ui .tool-label { display: none; }
body.narrow-ui .tool-btn { padding: 0 9px; }
/* Offene Seitenleiste schiebt die Bühne beiseite (kein Overlay) → die PDF-Seite
   bleibt komplett sichtbar; der ResizeObserver skaliert sie neu. */
body.narrow-ui .thumbs-panel.closed { display: none; }
body.narrow-ui .panel-open-tab { top: 8px; }
body.narrow-ui #more-menu {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 45;
  min-width: 200px;
  padding: 6px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
}
body.narrow-ui #more-menu .tool-btn {
  justify-content: flex-start;
  width: 100%;
  padding: 0 12px;
  gap: 10px;
}
body.narrow-ui #more-menu .tool-btn > svg { width: 18px !important; height: 18px !important; }
body.narrow-ui #more-menu .tool-btn .tool-label {
  flex: 1 1 auto;
  text-align: left;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
body.narrow-ui #more-menu .share-wrap,
body.narrow-ui #more-menu .bookmark-wrap,
body.narrow-ui #more-menu .print-wrap,
body.narrow-ui #more-menu .sound-wrap { display: flex !important; }
body.narrow-ui #more-menu .share-wrap .tool-btn,
body.narrow-ui #more-menu .bookmark-wrap .tool-btn,
body.narrow-ui #more-menu .print-wrap .tool-btn,
body.narrow-ui #more-menu .sound-wrap .tool-btn { flex: 1 1 auto; }
body.narrow-ui.more-open #more-menu { display: flex; }
body.narrow-ui #btn-more { display: inline-flex; }
body.narrow-ui.more-open #more-menu .tool-label { display: inline; }

/* Offenes ⋮-Menü: Bei begrenzter Fensterhöhe nicht über den unteren Rand
   hinausragen, sondern innerhalb des Sichtbereichs scrollbar machen. Gilt
   überall dort, wo das Menü als Dropdown geöffnet wird (Media-Query & narrow-ui). */
body.more-open #more-menu {
  max-height: calc(100dvh - 80px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

@media (max-width: 560px) {
  .site-footer > div {
    flex-direction: column !important;
    align-items: center !important;
    text-align: center !important;
    gap: 14px !important;
    padding-left: 16px !important;
    padding-right: 16px !important;
  }
  .site-footer > div > span:first-child {
    text-align: center !important;
    font-size: 11px !important;
    line-height: 1.5 !important;
  }
  .site-footer > div > span:last-child {
    justify-content: center !important;
    flex-wrap: wrap !important;
  }
  .header-inner { padding: 16px; }
  .brand-title { font-size: 20px; }
  .header-tagline {
    font-size: 20px;
    padding-top: 8px;
    width: 100%;
    border-left: none;
    border-top: 1px solid rgba(0, 153, 89, 0.35);
  }
  .archive-main { padding: 24px 16px 48px; }
  .issue-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 16px; }
  .viewer-toolbar { gap: 6px; padding: 8px 8px; }
  .toolbar-left { gap: 8px; }
  .viewer-brand-claim { display: none; }
  .toolbar-actions .tool-btn { padding: 0 7px; }
  /* Auf kleinen Handys nicht zu viel Platz wegnehmen, damit die PDF-Seite
     neben der offenen Seitenleiste groß genug bleibt. */
  .thumbs-panel { width: min(216px, 56vw); }
  .thumbs-panel { width: min(252px, 68vw); }
  .panel-tabs { gap: 3px; padding: 3px; }
  .panel-tab { font-size: 10.5px; padding: 0 3px; letter-spacing: 0; }
  .live-panel-indicator { font-size: 11.5px; padding: 6px 10px; margin: 8px 8px 0; }
  .page-indicator { font-size: 13px; }
}

/* ---------- Stapel-Vorschau (Hover über den Seitenstapel-Streifen) ---------- */
.stack-tip {
  position: fixed;
  z-index: 200;
  pointer-events: none;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px;
  background: rgba(18, 18, 22, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 12px;
  line-height: 1.2;
  white-space: nowrap;
}
.stack-tip img {
  display: block;
  max-width: 120px;
  max-height: 170px;
  border-radius: 4px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.18);
}
.stack-tip .stack-tip-num {
  padding: 2px 8px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
}
.stack-tip .stack-tip-load {
  width: 110px;
  height: 156px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.55);
  font-size: 11px;
  border-radius: 4px;
  background: repeating-linear-gradient(
    45deg,
    rgba(255, 255, 255, 0.05),
    rgba(255, 255, 255, 0.05) 6px,
    rgba(255, 255, 255, 0.02) 6px,
    rgba(255, 255, 255, 0.02) 12px
  );
}
.stack-tip.clickable {
  pointer-events: none;
}
/* Der Streifen ist nur schmal – beim Hovern kurz das Buch-Menü andeuten,
   dass man hier klicken kann. */
.stack-hint {
  cursor: pointer;
}

/* ---------- iOS-Safari: Fokus-Zoom verhindern ----------
   Safari zoomt beim Fokussieren eines Eingabefelds die ganze Seite hinein,
   solange die Schrift < 16px ist – auf iOS 18 bleibt dieser Zoom haengen
   und ist nur durch manuelles Pinch-Zoomen rueckgaengig zu machen.
   Die 16px-Regel greift NUR auf iOS-Touch-Geraeten (Feature-Query, reines
   iOS-WebKit inkl. iPads); Android, Desktop und macOS-Safari bleiben unveraendert. */
@supports (-webkit-touch-callout: none) {
  @media (hover: none) and (pointer: coarse) {
    .search-input,
    .print-range input,
    .page-indicator input,
    body.phone-landscape .page-indicator input {
      font-size: 16px;
    }

    /* Seitensprung-Feld im Lesemodus: Die Kompakt-Regel im <=430px-Layout
       (#readview .rv-pagejump input) hat hoehere Spezifitaet und stuende
       spaeter im File – deshalb hier mit hoeherer Spezifitaet + wichtig. */
    #readview #rv-page-input {
      font-size: 16px !important;
    }
  }
}

/* ---------- Deaktivierte Tool-Buttons ----------
   z. B. der Vollbild-Button auf iOS/WebKit: Dort gibt es keine Fullscreen-API
   fuer Dokument/Elemente (nur <video>) – der Button ist ohne Funktion und
   wird vom Viewer als deaktiviert markiert. */
.tool-btn:disabled {
  opacity: 0.45;
  cursor: default;
}
.tool-btn:disabled:hover {
  background: transparent;
  border-color: transparent;
  color: var(--text);
}

.consent-backdrop[hidden] { display: none !important; }
.consent-backdrop {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(7, 9, 13, 0.72);
  backdrop-filter: blur(4px);
}
.consent-card {
  width: min(520px, 92vw);
  padding: 22px 22px 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  text-align: left;
}
.consent-title {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  line-height: 1.35;
}
.consent-desc {
  margin: 0 0 16px;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--muted);
}
.consent-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
}
.consent-btn {
  height: 36px;
  padding: 0 18px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
}
.consent-btn:hover { background: var(--panel-2); }
.consent-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #08120b;
}
.consent-btn.primary:hover { filter: brightness(1.08); }

/* ---------- Lesemodus & Vorlesen (Barrierefreiheit) ---------- */

/* Im Lesemodus bleibt nur Toolbar + Textansicht sichtbar; das Blätterheft
   samt Seitenleiste, Pfeilen und unterer Leiste wird ausgeblendet. */
body.read-mode .stage-wrap,
body.read-mode .thumbs-panel,
body.read-mode .panel-open-tab,
body.read-mode .page-arrow,
body.read-mode .viewer-bottom,
body.read-mode .resume-banner {
  display: none !important;
}

/* Toolbar-Funktionen ohne Wirkung im Lesemodus ausblenden
   (Zoom, Ansicht Auto/Ein/Zweiseitig, Suche, Drucken, Umblätter-Sound). */
body.read-mode .zoom-group,
body.read-mode #btn-view,
body.read-mode #btn-search,
body.read-mode .print-wrap,
body.read-mode .sound-wrap {
  display: none !important;
}

.readview {
  flex: 1;
  min-width: 0;
  display: none;
  flex-direction: column;
  position: relative;
  background:
    radial-gradient(900px 500px at 50% 0%, rgba(255, 255, 255, 0.03), transparent 65%),
    var(--bg-soft);
}
body.read-mode .readview { display: flex; }

.rv-head {
  position: sticky;
  top: 0;
  z-index: 5;
  padding: 0;
  background: rgba(22, 25, 34, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.rv-head-inner {
  max-width: 1180px;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px clamp(12px, 2vw, 22px);
  /* Ab 720 px alles in EINER Zeile; darunter rutscht die Vorlesen-Gruppe
     in eine zweite Zeile (siehe Media-Query unten) */
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
}
@media (max-width: 719px) {
  /* Schmale Screens (Handy / Einzelseite): Vorlesen-Gruppe rutscht als
     eigene zweite Zeile unter den Rest – keine Scrollerei nötig */
  .rv-head-inner {
    flex-wrap: wrap;
    overflow-x: visible;
    overflow-y: visible;
    row-gap: 4px;
  }
  .rv-sep { display: none; }
  .rv-pagejump { margin-left: auto; }
  #readview .rv-ttsbar { order: 10; flex-basis: 100%; }
}
@media (max-width: 430px) {
  .rv-head-inner { gap: 4px; padding: 8px 8px; }
  .rv-title { display: none; }
  .rv-fontctrl { gap: 2px; margin-left: 0; }
  .rv-actions { gap: 4px; }
  /* Gesamtanzahl weichen, damit x/y + Pfeile + X sicher in Zeile 1 passen */
  #rv-page-total { display: none; }
  /* Vorlesen-Zeile: Textlabels der Auswahlfelder sparen Platz */
  .rv-opt-label { display: none; }
}
.rv-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.rv-pagejump {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.rv-pagejump input {
  width: 46px;
  height: 30px;
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  outline: none;
}
.rv-pagejump input:focus { border-color: var(--accent); }
/* Spinner-Pfeile ausblenden (wie im Blätterheft) */
.rv-pagejump input::-webkit-outer-spin-button,
.rv-pagejump input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.rv-pagejump input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}
.rv-page-status {
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Ansicht-Umschalter: Heft-Modus <-> fortlaufendes Scrollen */
.rv-view-btn .ic-pages { display: none; }
.rv-view-btn[aria-pressed="true"] {
  background: var(--panel-2);
  color: var(--gold);
}
.rv-view-btn[aria-pressed="true"] .ic-scroll { display: none; }
.rv-view-btn[aria-pressed="true"] .ic-pages { display: block; }
.rv-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.rv-scroll {
  flex: 1;
  min-height: 0;
  position: relative;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: clamp(16px, 4vw, 44px) clamp(14px, 4vw, 40px) 30vh;
  outline: none;
}
.rv-hint {
  text-align: center;
  color: var(--muted);
  padding: 3rem 1rem;
}
.rv-page {
  max-width: 72ch;
  margin: 0 auto 2rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: clamp(16px, 3vw, 30px) clamp(18px, 4vw, 40px);
}
.rv-page-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.55rem;
  margin-bottom: 1rem;
}
.rv-page-num {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--gold);
}
.rv-jump {
  margin-left: auto;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: 999px;
  padding: 4px 12px;
  cursor: pointer;
  white-space: nowrap;
}
.rv-jump:hover {
  color: var(--text);
  background: var(--panel-2);
}
.rv-text p {
  margin: 0 0 0.95em;
  line-height: 1.65;
  font-size: var(--rv-font-size, 1.05rem);
  overflow-wrap: break-word;
}
.rv-fontctrl {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 6px;
}
.rv-font-btn {
  min-width: 36px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.rv-font-btn:disabled { opacity: 0.35; cursor: default; }
.rv-head .nav-btn[disabled], .rv-head .tool-btn[disabled] { opacity: 0.35; cursor: default; }
.rv-text p:last-child { margin-bottom: 0; }
.rv-empty,
.rv-loading {
  color: var(--muted);
  font-style: italic;
}

/* Vorlesen-Gruppe: sitzt mit in der Kopfzeile – eine Zeile statt zwei */
.rv-ttsbar {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
}
.rv-ttsbar[hidden] { display: none; }
.rv-ttsbar-inner {
  display: flex;
  align-items: center;
  gap: 6px;
}
.rv-ttsbar .nav-btn[disabled] {
  opacity: 0.4;
  cursor: default;
}
.rv-sep {
  width: 2px;
  height: 24px;
  border-radius: 1px;
  background: var(--muted);
  margin: 0 3px;
}
#btn-rv-speak .ic-pause { display: none; }
#btn-rv-speak.tts-playing .ic-play { display: none; }
#btn-rv-speak.tts-playing .ic-pause { display: block; }
#btn-rv-speak.tts-playing {
  background: var(--accent-soft);
  border-color: rgba(0, 153, 89, 0.4);
  color: var(--accent);
}
.rv-opt {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
}
.rv-opt select {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 4px 6px;
  font-size: 12.5px;
  max-width: 140px;
}

/* Einheitliche Groesse fuer alle Bedienelemente der Kopfzeile
   (Desktop 34 px hoch, Icons 20 px – Handy siehe Media-Query unten) */
#readview .nav-btn,
#readview .tool-btn {
  height: 34px;
  min-width: 38px;
  width: auto;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
#readview .rv-font-btn { min-width: 44px; padding: 0 8px; }
#readview .nav-btn svg,
#readview .tool-btn svg { width: 20px; height: 20px; }
#readview #rv-close { font-size: 20px; line-height: 1; }
#readview .rv-pagejump input { height: 34px; }
#readview .rv-opt select { height: 34px; padding: 0 8px; }
@media (max-width: 430px) {
  #readview .nav-btn,
  #readview .tool-btn { height: 30px; min-width: 28px; }
  #readview .rv-font-btn { min-width: 30px; padding: 0 4px; font-size: 11px; }
  #readview .nav-btn svg,
  #readview .tool-btn svg { width: 16px; height: 16px; }
  #readview .rv-pagejump input { width: 34px; height: 30px; font-size: 12px; }
  #readview .rv-pagejump { gap: 4px; }
  #readview .rv-opt select { height: 30px; font-size: 12px; }
}

/* Seiten-Ansicht – Doppelseite mit je eigener Scrollbar, aber seitenweises Blättern */
.rv-sheets {
  flex: 1;
  min-height: 0;
  display: none;
  padding: clamp(10px, 2vw, 22px) clamp(10px, 2.5vw, 28px);
  overflow: hidden;
  outline: none;
}
.rv-sheets[hidden] { display: none !important; }
body.read-mode .rv-mode-pages .rv-sheets { display: block; }
body.read-mode .rv-mode-pages .rv-scroll { display: none !important; }
.rv-sheet {
  height: 100%;
  max-height: 100%;
  max-width: 1180px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(12px, 2vw, 26px);
  align-items: stretch;
}
.rv-mode-pages .rv-page {
  max-width: none;
  margin: 0;
  height: 100%;
  max-height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.rv-sheet .rv-page:only-child {
  max-width: 72ch;
  margin: 0 auto;
  width: 100%;
}
@media (max-width: 899.98px) {
  .rv-sheet { grid-template-columns: 1fr; max-width: 72ch; }
  .rv-sheet .rv-page + .rv-page { display: none; }
}
/* Aktuell vorgelesener Satz (Karaoke) und Hover-Hinweis auf Klickbarkeit */
.rv-sent { border-radius: 3px; }
.rv-sent:hover { background: rgba(255, 255, 255, 0.05); }
.rv-sent.speaking {
  background: var(--accent-soft);
  box-shadow: 0 0 0 2px var(--accent-soft);
  transition: background 0.2s ease;
}

/* ---------- Kommentare/Blog ---------- */
.comment-wrap { position: relative; display: inline-flex; align-items: center; }
.comment-count-badge {
  position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; padding: 0 5px;
  background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px;
  text-align: center; border-radius: 999px; pointer-events: none;
}
.blog-card { --blog-line: #3d4760; width: min(680px, calc(100vw - 32px)); height: min(88dvh, 720px); display: flex; flex-direction: column; }
.blog-card .modal-title { font-size: 17px; }
.blog-head { display: flex; align-items: center; gap: 12px; }
.blog-body { display: flex; flex-direction: column; gap: 16px; flex: 1 1 auto; min-height: 0; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; padding: 4px 2px; }
.blog-form { display: flex; flex-direction: column; gap: 12px; background: var(--panel-2); border: 1px solid var(--blog-line); border-radius: 12px; padding: 14px 16px; flex: 0 0 auto; box-shadow: 0 2px 12px rgba(0,0,0,0.25); }
.blog-form[hidden] { display: none; }
.blog-fields { display: flex; flex-direction: column; gap: 12px; }
.blog-fields[hidden] { display: none; }
.blog-form-row { display: flex; flex-direction: column; gap: 6px; }
.blog-label { font-size: 13px; font-weight: 700; color: #9a9aa4; }
.blog-label small { font-weight: 400; font-size: 12px; opacity: 0.8; }
.blog-form-row input[type="text"],
.blog-form-row textarea,
.blog-form-row select {
  background: var(--bg); border: 1px solid var(--blog-line); border-radius: 8px; color: var(--text);
  font-family: inherit; font-size: 14px; padding: 10px 12px;
}
/* Textfeld passt sich dynamisch an: waechst beim Tippen bis zur Obergrenze
   (field-sizing: content, moderne Browser) und wird darueber intern scrollbar.
   Aeltere Browser: feste 88px-Hoehe mit eigenem Scrollbalken. */
.blog-form-row textarea {
  height: 88px; min-height: 70px; max-height: 34vh; overflow-y: auto;
  resize: vertical; field-sizing: content;
}
.blog-form-row input[type="text"]:hover,
.blog-form-row textarea:hover,
.blog-form-row select:hover { border-color: #4b5874; }
.blog-form-row input[type="text"]:focus,
.blog-form-row textarea:focus,
.blog-form-row select:focus { outline: none; border-color: var(--accent); }
/* iOS vermeidet den Autozoom in Felder mit Schriftgroesse < 16px nur bei >= 16px.
   Ueberall aber 16px zu setzen wuerde Desktop groesser wirken lassen, daher
   nur auf schmalen Viewports (Handy) die Grenze ueberschreiben. */
@media (max-width: 820px) {
  .blog-form-row input[type="text"],
  .blog-form-row textarea,
  .blog-form-row select {
    font-size: 16px;
  }
  /* Auf dem Handy kompakter: Textfeld startet kleiner und scrollt eher intern */
  .blog-form-row textarea { height: 78px; min-height: 64px; max-height: 28vh; }
  /* Schmale Viewports: Aktionsknoepfe nur noch als Icons */
  .blog-submit-label, .blog-cancel-label { display: none; }
  .blog-submit, .blog-cancel { padding: 6px 8px; }
  .blog-ico { width: 16px; height: 16px; }
}
.blog-form-row input:-webkit-autofill,
.blog-form-row input:-webkit-autofill:hover,
.blog-form-row input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px var(--bg) inset;
  -webkit-text-fill-color: var(--text);
  transition: background-color 9999s ease-out 0s;
}
.blog-stars { display: inline-flex; gap: 6px; }
.blog-stars .star {
  background: none; border: 0; padding: 0; font-size: 26px; line-height: 1; cursor: pointer;
  color: #3a4150; transition: color 0.15s ease;
}
.blog-stars .star:hover, .blog-stars .star.on { color: #f5b301; }
.blog-actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.blog-submit {
  display: inline-flex; align-items: center; gap: 7px; flex: 0 0 auto;
  background: var(--accent); color: #fff; border: 0; border-radius: 8px;
  font-family: inherit; font-size: 12.5px; font-weight: 600; padding: 5px 12px; cursor: pointer;
}
.blog-submit:hover { filter: brightness(1.1); }
.blog-submit:disabled { opacity: 0.6; cursor: default; }
.blog-cancel {
  display: inline-flex; align-items: center; gap: 7px; flex: 0 0 auto;
  background: var(--panel-2); color: var(--text); border: 1px solid var(--blog-line); border-radius: 8px;
  font-family: inherit; font-size: 12.5px; font-weight: 600; padding: 5px 12px; cursor: pointer;
}
.blog-cancel:hover { border-color: var(--accent); }
.blog-cancel[hidden] { display: none; }
.blog-ico { width: 13px; height: 13px; flex: 0 0 auto; }
.blog-submit .blog-ico-send { display: none; }
.blog-submit[data-open="true"] .blog-ico-pencil { display: none; }
.blog-submit[data-open="true"] .blog-ico-send { display: block; }
.blog-head-right { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.blog-note { font-size: 12px; color: #8a8a94; line-height: 1.5; margin: 0; }
.blog-error { background: rgba(255, 90, 90, 0.12); border: 1px solid rgba(255, 90, 90, 0.4); color: #ff9a9a;
              border-radius: 8px; padding: 10px 12px; font-size: 13px; }
.blog-list { display: flex; flex-direction: column; gap: 12px; flex: 0 0 auto; min-height: 0; max-height: none; overflow: visible; border-top: 1px solid var(--blog-line); padding-top: 14px; }
.blog-empty { color: #8a8a94; font-size: 13px; text-align: center; padding: 16px 0; }
.blog-entry { position: relative; background: var(--panel); border: 1px solid var(--blog-line); border-radius: 12px; padding: 12px 14px; box-shadow: 0 2px 10px rgba(0,0,0,0.20); }
.blog-entry-meta { display: flex; align-items: center; gap: 10px; padding-right: 30px; }
.blog-entry-edit {
  position: absolute; top: 8px; right: 12px; background: none; border: 0; color: #8a8a94;
  padding: 2px; line-height: 1; cursor: pointer;
}
.blog-entry-edit:hover { color: var(--accent); }
.blog-entry-name { font-weight: 700; font-size: 14px; color: var(--text); }
.blog-entry-date { font-size: 12px; color: #8a8a94; margin-left: auto; }
.blog-entry-issue { font-size: 12px; color: var(--accent); font-weight: 600; margin-top: 2px; }
.blog-entry-stars { font-size: 15px; letter-spacing: 1px; margin-top: 6px; }
.blog-entry-stars .on { color: #f5b301; }
.blog-entry-stars .off { color: #3a4150; }
.blog-entry-text { margin: 8px 0 0; font-size: 14px; line-height: 1.55; color: var(--text); white-space: pre-wrap; }
.blog-entry-likes {
  margin-top: 10px; display: inline-flex; align-items: center; gap: 6px;
  background: none; border: 1px solid var(--blog-line); border-radius: 999px;
  color: #8a8a94; font-size: 13px; font-family: inherit; line-height: 1;
  padding: 6px 12px; cursor: pointer; transition: border-color 0.15s ease, color 0.15s ease;
}
.blog-entry-likes:hover { border-color: var(--accent); color: var(--text); }
.blog-entry-likes.liked { border-color: rgba(0, 153, 89, 0.5); color: var(--accent); background: rgba(0, 153, 89, 0.07); }
.blog-entry-likes .blog-like-icon { font-size: 15px; }
.blog-reply {
  margin: 10px 0 0; padding: 10px 0 0 16px; border-top: 1px solid var(--blog-line);
}
.blog-reply-head { display: flex; align-items: center; gap: 8px; }
.blog-reply-name { font-weight: 700; font-size: 14px; color: var(--text); }
.blog-reply-label {
  font-size: 11px; color: var(--accent); border: 1px solid rgba(0, 153, 89, 0.45);
  border-radius: 999px; padding: 1px 8px; font-weight: 600;
}
.blog-reply-date { font-size: 12px; color: #8a8a94; margin-left: auto; }
.blog-reply-text { margin: 8px 0 0; font-size: 14px; line-height: 1.55; color: #aab1bd; white-space: pre-wrap; }
.blog-pager { display: flex; align-items: center; justify-content: center; gap: 14px; }
.blog-pager[hidden] { display: none; }
.blog-page-btn {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--blog-line); border-radius: 8px;
  font-family: inherit; font-size: 16px; line-height: 1; width: 34px; height: 34px; cursor: pointer;
}
.blog-page-btn:hover { border-color: var(--accent); }
.blog-page-btn:disabled { opacity: 0.4; cursor: default; }
.blog-page-info { font-size: 12px; color: #8a8a94; }
.blog-footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; flex: 0 0 auto; border-top: 1px solid var(--blog-line); padding-top: 12px; }
/* Sehr geringe Fensterhoehe (z. B. Handy quer): Karte waechst statt 88dvh
   zu fixieren. Der Dialoginhalt scrollt ohnehin als Einheit oben im Dialog,
   die Fussleiste liegt fest darunter und wird nie ueberlagert. */
@media (max-height: 480px) {
  .blog-card { height: auto; max-height: calc(100dvh - 16px); }
}
.blog-sizebar { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.blog-sizebar select {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--blog-line); border-radius: 8px;
  font-family: inherit; font-size: 13px; padding: 6px 10px; cursor: pointer;
}
.blog-smiley-wrap { position: relative; }
.blog-smiley-toggle {
  background: var(--panel-2); color: #8a8a94; border: 1px solid var(--blog-line); border-radius: 8px;
  padding: 4px 8px; font-size: 12px; line-height: 1.2; cursor: pointer; margin-top: 0;
}
.blog-smiley-toggle:hover { border-color: var(--accent); }
.blog-smiley-palette {
  position: absolute; bottom: calc(100% + 8px); left: 0; z-index: 5;
  background: var(--panel-2); border: 1px solid var(--blog-line); border-radius: 10px; padding: 8px;
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; width: max-content; max-width: 260px;
}
.blog-smiley-palette[hidden] { display: none; }
.blog-smiley-palette .smiley {
  background: none; border: 0; font-size: 18px; line-height: 1; padding: 2px; border-radius: 6px; cursor: pointer;
}
.blog-smiley-palette .smiley:hover { background: var(--blog-line); }
