/* Blätterkatalog – Viewer */
*,
*::before,
*::after { box-sizing: border-box; }

[hidden] { display: none !important; }

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

body.fv {
  --fv-bg: #15161a;
  --fv-accent: #ff5a1f;
  --fv-bar: #1b1c21;
  --fv-bar-line: #2c2e36;
  --fv-ink: #e9eaee;
  --fv-dim: #9a9da8;
  --fv-panel: #202127;
  --fv-field: #2a2c34;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--fv-bg);
  color: var(--fv-ink);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

.fv button, .fv input { font: inherit; color: inherit; }
.fv a { color: inherit; }
.fv :focus-visible { outline: 2px solid var(--fv-accent); outline-offset: 2px; }
.fv-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.fv-muted { color: var(--fv-dim); margin: 0; }
.fv-noscript { position: fixed; inset: 0; margin: 0; padding: 24px; background: var(--fv-bg); text-align: center; z-index: 99; }

/* ---------- Bühne ---------- */

#fv-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(18px, calc(10vh - 30px), 140px) 54px;
  overflow: hidden;
}

#fv-wrap {
  position: relative;
  flex: none;
  opacity: 0;
  transition: opacity .35s ease, transform .45s ease;
}
#fv-stage.fv-ready #fv-wrap { opacity: 1; }

#fv-book { user-select: none; -webkit-user-select: none; }

/* Fehlende Regel der Bibliothek (dort als .sft__wrapper vertippt) */
.stf__wrapper { position: relative; width: 100%; box-sizing: border-box; }

#fv-book .page {
  background: #fff;
  overflow: hidden;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .3);
}
#fv-book .page img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  opacity: 0;
  transition: opacity .25s ease;
  pointer-events: none;
  -webkit-user-drag: none;
}
#fv-book .page.fv-loaded img { opacity: 1; }
.fv-ph {
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, #eceef1 30%, #f7f8fa 50%, #eceef1 70%);
  background-size: 220% 100%;
  animation: fv-shimmer 1.4s linear infinite;
}
.page.fv-loaded .fv-ph { display: none; }
@keyframes fv-shimmer { from { background-position: 120% 0; } to { background-position: -100% 0; } }

/* Seitenzahlen unter dem Buch */
#fv-nums {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  height: 22px;
  padding: 5px 6px 0;
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  line-height: 1.4;
  letter-spacing: .04em;
  font-variant-numeric: tabular-nums;
  color: #8b8e98;
  pointer-events: none;
}
#fv-nums.fv-nums-one { justify-content: center; }

/* Pfeile */
.fv-arrow {
  position: absolute;
  top: 50%;
  z-index: 5;
  width: 40px;
  height: 56px;
  margin-top: -28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 10px;
  background: rgba(20, 21, 25, .55);
  color: #fff;
  cursor: pointer;
  transition: background .15s ease, opacity .15s ease;
}
.fv-arrow-l { left: 7px; }
.fv-arrow-r { right: 7px; }
.fv-arrow:hover { background: rgba(20, 21, 25, .85); }
.fv-arrow:disabled { opacity: 0; pointer-events: none; }

/* Ladeanzeige */
#fv-load { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.fv-spin {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 3px solid rgba(140, 143, 153, .3);
  border-top-color: var(--fv-accent);
  animation: fv-rot .9s linear infinite;
}
@keyframes fv-rot { to { transform: rotate(360deg); } }

#fv-hint {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  z-index: 6;
  max-width: calc(100% - 24px);
  padding: 7px 14px;
  border-radius: 999px;
  background: rgba(20, 21, 25, .82);
  color: #e9eaee;
  font-size: 12.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

#fv-badge {
  position: absolute;
  right: 10px;
  top: 8px;
  z-index: 6;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(20, 21, 25, .5);
  color: #c9cbd3;
  font-size: 11px;
  text-decoration: none;
}
#fv-badge:hover { color: #fff; background: rgba(20, 21, 25, .85); }

/* ---------- Klickflächen ---------- */

.fv-hs {
  position: absolute;
  z-index: 3;
  display: block;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 3px;
  background: transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background .25s ease, box-shadow .25s ease;
}
.fv-hs:hover,
.fv-hs:focus-visible,
.fv-hs-show .fv-hs {
  background: rgba(255, 90, 31, .18);
  background: color-mix(in srgb, var(--fv-accent) 20%, transparent);
  box-shadow: 0 0 0 1px var(--fv-accent);
}
.fv-hs-show .fv-hs-auto {
  background: rgba(255, 90, 31, .1);
  background: color-mix(in srgb, var(--fv-accent) 11%, transparent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--fv-accent) 55%, transparent);
}
.fv-hs-ic {
  position: absolute;
  right: -6px;
  top: -7px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--fv-accent);
  color: #fff;
  font: 700 9px/15px system-ui, sans-serif;
  text-align: center;
  opacity: 0;
  transition: opacity .25s ease;
  pointer-events: none;
}
.fv-hs:hover .fv-hs-ic,
.fv-hs:focus-visible .fv-hs-ic,
.fv-hs-show .fv-hs:not(.fv-hs-auto) .fv-hs-ic { opacity: 1; }

/* ---------- Vorschaubilder ---------- */

.fv-thumbs {
  flex: none;
  background: var(--fv-bar);
  border-top: 1px solid var(--fv-bar-line);
}
.fv-thumbs-list {
  position: relative;
  display: flex;
  gap: 8px;
  padding: 10px 12px 8px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  scrollbar-color: #4a4d58 transparent;
}
.fv-thumb {
  flex: none;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  text-align: center;
  color: var(--fv-dim);
}
.fv-thumb img {
  display: block;
  width: 100%;
  height: 92px;
  object-fit: cover;
  background: #2c2e36;
  border-radius: 3px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .08);
}
.fv-thumb span { display: block; padding-top: 3px; font-size: 11px; font-variant-numeric: tabular-nums; }
.fv-thumb:hover img { box-shadow: 0 0 0 1px rgba(255, 255, 255, .4); }
.fv-thumb.is-active img { box-shadow: 0 0 0 2px var(--fv-accent); }
.fv-thumb.is-active { color: var(--fv-ink); }

/* ---------- Werkzeugleiste ---------- */

.fv-bar {
  flex: none;
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  height: calc(64px + env(safe-area-inset-bottom, 0px));
  padding: 0 12px env(safe-area-inset-bottom, 0px);
  background: var(--fv-bar);
  border-top: 1px solid var(--fv-bar-line);
}
.fv-bar-nav, .fv-bar-tools { display: flex; align-items: center; gap: 2px; flex: none; }
.fv-bar-tools { margin-left: auto; }
.fv-bar-title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1 1 auto;
  padding: 0 6px;
}
.fv-logo { flex: none; display: inline-flex; align-items: center; }
.fv-logo img { display: block; max-height: 34px; max-width: 130px; width: auto; height: auto; }
.fv-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--fv-dim); font-size: 13.5px; }

.fv-btn {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--fv-ink);
  cursor: pointer;
  text-decoration: none;
  transition: background .15s ease, color .15s ease;
}
.fv-btn:hover { background: rgba(255, 255, 255, .09); }
.fv-btn:active { background: rgba(255, 255, 255, .15); }
.fv-btn:disabled { opacity: .32; cursor: default; background: transparent; }
.fv-btn.is-on { color: var(--fv-accent); background: rgba(255, 255, 255, .07); }
.fv-btn-accent { background: var(--fv-accent); color: #fff; }
.fv-btn-accent:hover { background: var(--fv-accent); filter: brightness(1.1); }

.fv-pagebox { display: inline-flex; align-items: center; gap: 6px; padding: 0 4px; color: var(--fv-dim); font-variant-numeric: tabular-nums; }
#fv-page {
  width: 66px;
  height: 34px;
  padding: 0 6px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--fv-field);
  color: var(--fv-ink);
  text-align: center;
  font-variant-numeric: tabular-nums;
}
#fv-page:hover { border-color: #444752; }
.fv-total { white-space: nowrap; font-size: 13px; }

/* ---------- Bereiche (Suche, Frage) ---------- */

.fv-panel {
  position: fixed;
  z-index: 30;
  top: 0;
  right: 0;
  bottom: calc(64px + env(safe-area-inset-bottom, 0px));
  width: min(360px, 100%);
  display: flex;
  flex-direction: column;
  background: var(--fv-panel);
  border-left: 1px solid var(--fv-bar-line);
  box-shadow: -12px 0 32px rgba(0, 0, 0, .35);
}
.fv-panel-head {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 8px 8px 16px;
  border-bottom: 1px solid var(--fv-bar-line);
  font-size: 15px;
}
.fv-panel-form { flex: none; display: flex; gap: 8px; padding: 12px; }
.fv-panel-form input {
  flex: 1 1 auto;
  min-width: 0;
  height: 40px;
  padding: 0 12px;
  border: 1px solid #3a3c46;
  border-radius: 9px;
  background: var(--fv-field);
  color: var(--fv-ink);
  font-size: 16px; /* verhindert das Hineinzoomen auf iOS */
}
.fv-panel-form input::placeholder { color: #7d808b; }
.fv-panel-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 4px 12px 14px; overscroll-behavior: contain; }

.fv-result {
  display: block;
  width: 100%;
  margin: 0 0 6px;
  padding: 9px 11px;
  border: 0;
  border-radius: 9px;
  background: rgba(255, 255, 255, .045);
  text-align: left;
  cursor: pointer;
}
.fv-result:hover { background: rgba(255, 255, 255, .1); }
.fv-result-p { display: block; font-size: 12px; font-weight: 650; color: var(--fv-accent); margin-bottom: 2px; }
.fv-result-s { display: block; font-size: 13px; color: #c5c7cf; overflow-wrap: anywhere; }
.fv-result mark { background: color-mix(in srgb, var(--fv-accent) 38%, transparent); color: #fff; border-radius: 2px; padding: 0 1px; }

.fv-ask-log { display: flex; flex-direction: column; gap: 8px; padding-top: 12px; }
.fv-ask-form { border-top: 1px solid var(--fv-bar-line); }
.fv-msg { max-width: 92%; padding: 9px 12px; border-radius: 12px; font-size: 14px; overflow-wrap: anywhere; }
.fv-msg-q { align-self: flex-end; background: var(--fv-accent); color: #fff; border-bottom-right-radius: 4px; }
.fv-msg-a { align-self: flex-start; background: rgba(255, 255, 255, .07); border-bottom-left-radius: 4px; }
.fv-msg-err { color: #ffb4a3; }
.fv-cite {
  display: inline-block;
  margin: 0 1px;
  padding: 0 7px;
  border: 0;
  border-radius: 999px;
  background: color-mix(in srgb, var(--fv-accent) 30%, transparent);
  color: #fff;
  font-size: 12px;
  line-height: 20px;
  cursor: pointer;
  white-space: nowrap;
}
.fv-cite:hover { background: var(--fv-accent); }
.fv-dots { display: inline-flex; gap: 4px; padding: 4px 0; }
.fv-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--fv-dim); animation: fv-dot 1s ease-in-out infinite; }
.fv-dots i:nth-child(2) { animation-delay: .15s; }
.fv-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes fv-dot { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }

/* ---------- Zoom ---------- */

.fv-zoom {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  background: rgba(12, 13, 16, .97);
}
.fv-zoom-view {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.fv-zoom-view.is-drag { cursor: grabbing; }
.fv-zoom-inner {
  position: absolute;
  left: 0;
  top: 0;
  display: flex;
  transform-origin: 0 0;
  will-change: transform;
  background: #fff;
}
.fv-zoom-cell { height: 100%; background-size: 100% 100%; background-repeat: no-repeat; }
.fv-zoom-cell img { display: block; width: 100%; height: 100%; pointer-events: none; -webkit-user-drag: none; }
.fv-zoom-bar {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: calc(56px + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--fv-bar);
  border-top: 1px solid var(--fv-bar-line);
}
.fv-z-pct { min-width: 58px; text-align: center; color: var(--fv-dim); font-variant-numeric: tabular-nums; }
#fv-z-close { margin-left: 12px; }

/* ---------- Toast ---------- */

.fv-toast {
  position: fixed;
  left: 50%;
  bottom: calc(80px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 70;
  max-width: calc(100% - 32px);
  padding: 9px 16px;
  border-radius: 999px;
  background: #f1f2f5;
  color: #17181c;
  font-size: 13.5px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .4);
}

/* ---------- Schmale Fenster ---------- */

@media (max-width: 900px) {
  .fv-title { display: none; }
}

@media (max-width: 640px) {
  #fv-stage { padding: 10px 8px; }
  .fv-arrow { display: none; }
  .fv-bar { gap: 4px; padding-left: 6px; padding-right: 6px; }
  .fv-bar-title { display: none; }
  #fv-first, #fv-last { display: none; }
  .fv-btn { width: 36px; height: 36px; }
  #fv-page { width: 54px; }
  .fv-bar-tools { flex: 0 1 auto; min-width: 0; overflow-x: auto; scrollbar-width: none; }
  .fv-bar-tools::-webkit-scrollbar { display: none; }
  .fv-panel { width: 100%; border-left: 0; }
  #fv-badge { top: 4px; right: 4px; font-size: 10px; }
  #fv-hint { bottom: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  #fv-wrap, #fv-book .page img, .fv-hs, .fv-hs-ic, .fv-btn, .fv-arrow { transition: none; }
  .fv-ph { animation: none; }
  .fv-spin { animation-duration: 3s; }
  .fv-dots i { animation: none; opacity: .7; }
}
