@font-face { font-family: "Geist"; src: url(fonts/Geist-Variable-latin.woff2) format("woff2"); font-weight: 100 900; font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Geist"; src: url(fonts/Geist-Variable-latin-ext.woff2) format("woff2"); font-weight: 100 900; font-display: swap; unicode-range: U+0100-024F, U+1E00-1EFF, U+20A0-20AB, U+20AD-20CF, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "IBM Plex Mono"; src: url(fonts/IBMPlexMono-400-latin.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url(fonts/IBMPlexMono-500-latin.woff2) format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Instrument Serif"; src: url(fonts/InstrumentSerif-Italic-latin.woff2) format("woff2"); font-style: italic; font-display: swap; }

:root {
  --navy: #0B1823;
  --papier: #FCFCFB;
  --brass: #AE8F56;
  --brass-text: #806737;
  --slate: #505B66;
  --linie: #D2D9DF;
  --kuehl: #E9EBEC;
  --bg-light: radial-gradient(120% 95% at 50% 38%, #F5F6F6 0%, #E7EAEC 55%, #D3D8DC 100%);
  --bg-dark: radial-gradient(120% 95% at 50% 38%, #1C2A36 0%, #0F1D29 55%, #060E15 100%);
  --bg: var(--bg-light);
  --bg-base: #E7EAEC;
  --fg: var(--navy);
  --muted: var(--slate);
  --accent-text: var(--brass-text);
  --surface: rgba(252, 252, 251, .86);
  --surface-strong: rgba(252, 252, 251, .9);
  --line: var(--linie);
  --hover: var(--kuehl);
  --pressed-bg: var(--navy);
  --pressed-fg: var(--papier);
  --shadow: rgba(11, 24, 35, .28);
  color-scheme: light;
  --sans: "Geist", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
}
:root[data-theme="dark"] {
  --bg: var(--bg-dark);
  --bg-base: #0F1D29;
  --fg: #F1F2F1;
  --muted: #9AA6B1;
  --accent-text: #C9AD77;
  --surface: rgba(19, 33, 45, .82);
  --surface-strong: rgba(19, 33, 45, .92);
  --line: rgba(252, 252, 251, .13);
  --hover: rgba(252, 252, 251, .1);
  --pressed-bg: var(--papier);
  --pressed-fg: var(--navy);
  --shadow: rgba(0, 0, 0, .55);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
html { background: var(--bg-base); transition: background-color .6s ease; }
body {
  background: transparent;
  color: var(--fg);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* Hintergrund als zwei Ebenen, damit der Verlauf beim Moduswechsel weich überblendet */
body::before, body::after { content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none; transition: opacity .6s ease; }
body::before { background: var(--bg-light); }
body::after { background: var(--bg-dark); opacity: 0; }
:root[data-theme="dark"] body::after { opacity: 1; }

/* Während des Umschaltens Farben der Bedienelemente mitblenden */
@media (prefers-reduced-motion: no-preference) {
  .theme-anim *:not(#btnTheme svg), .theme-anim *::before, .theme-anim *::after {
    transition: background-color .6s ease, color .6s ease, border-color .6s ease, box-shadow .6s ease, opacity .6s ease !important;
  }
}

#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
#scene.grab { cursor: grab; }
#scene.grabbing { cursor: grabbing; }

/* Kopf */
.brand {
  position: fixed; top: max(20px, env(safe-area-inset-top)); left: 24px;
  display: flex; flex-direction: column; gap: 6px; pointer-events: none;
}
.brand-mark {
  font-family: var(--mono); font-weight: 500; font-size: 12px; letter-spacing: .32em; text-transform: uppercase; color: var(--muted);
}
.brand-mark::after { content: ""; display: block; width: 44px; height: 1px; background: var(--brass); margin-top: 8px; }
.brand-title { font-size: 19px; font-weight: 600; letter-spacing: -.01em; }
.brand-title em { font-family: "Instrument Serif", Georgia, serif; font-weight: 400; font-size: 1.18em; color: var(--accent-text); }

/* Hinweis */
.hint {
  position: fixed; left: 50%; bottom: calc(88px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  margin: 0; font-family: var(--mono); font-size: 12px; letter-spacing: .04em; color: var(--muted);
  white-space: nowrap; pointer-events: none; transition: opacity .6s;
}
.hint.gone { opacity: 0; }

/* Steuerleiste */
.bar {
  position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  display: flex; align-items: center; gap: 4px; padding: 6px;
  background: var(--surface); backdrop-filter: blur(14px) saturate(1.2); -webkit-backdrop-filter: blur(14px) saturate(1.2);
  border: 1px solid var(--line); border-radius: 999px;
  box-shadow: 0 10px 30px -12px var(--shadow);
  z-index: 5;
}
.bar button {
  display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 14px;
  border: 0; border-radius: 999px; background: transparent; color: var(--fg);
  font: 500 14px var(--sans); cursor: pointer; transition: background .15s, color .15s;
}
.bar button.icon { width: 40px; padding: 0; justify-content: center; }
.bar button:hover { background: var(--hover); }
.bar button:focus-visible { outline: 2px solid var(--brass); outline-offset: 1px; }
.bar button[aria-pressed="true"] { background: var(--pressed-bg); color: var(--pressed-fg); }
.bar button:disabled { opacity: .3; cursor: default; background: transparent; }
.bar svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
#btnTheme { position: relative; }
#btnTheme svg { position: absolute; left: 10px; top: 10px; transition: opacity .5s ease, transform .5s ease; }
.theme-dark-icon { opacity: 0; transform: rotate(-60deg) scale(.6); }
:root[data-theme="dark"] .theme-dark-icon { opacity: 1; transform: none; }
:root[data-theme="dark"] .theme-light-icon { opacity: 0; transform: rotate(60deg) scale(.6); }
.page-label { white-space: nowrap; min-width: 116px; text-align: center; font: 500 13px var(--mono); letter-spacing: .02em; font-variant-numeric: tabular-nums; }
.sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }

.bar-dark { --fg: var(--papier); --hover: rgba(252, 252, 251, .12); background: rgba(11, 24, 35, .82); border-color: rgba(252, 252, 251, .14); color: var(--papier); }
.bar-dark button { color: var(--papier); }
.bar-dark button:hover { background: rgba(252, 252, 251, .12); }
.bar-dark .sep { background: rgba(252, 252, 251, .18); }

/* Seitenübersicht */
.thumbs {
  position: fixed; left: 16px; right: 16px; bottom: calc(84px + env(safe-area-inset-bottom));
  max-width: 1120px; margin: 0 auto; z-index: 4;
  display: flex; gap: 14px; padding: 14px 16px 12px; overflow-x: auto; overscroll-behavior: contain;
  background: var(--surface-strong); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 14px 36px -16px var(--shadow);
  scrollbar-width: thin;
}
.thumbs[hidden] { display: none; }
.thumb {
  flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: 6px;
  border: 0; padding: 0; background: none; cursor: pointer; color: var(--muted);
  font: 400 11px var(--mono);
}
.thumb-imgs { display: flex; height: 92px; box-shadow: 0 2px 8px -2px rgba(11, 24, 35, .35); outline: 2px solid transparent; outline-offset: 3px; border-radius: 1px; transition: outline-color .15s, transform .15s; }
.thumb-imgs img { height: 100%; width: auto; display: block; aspect-ratio: 1654 / 2339; background: var(--papier); }
.thumb:hover .thumb-imgs { transform: translateY(-2px); }
.thumb.active { color: var(--fg); font-weight: 500; }
.thumb.active .thumb-imgs { outline-color: var(--brass); }
.thumb:focus-visible { outline: none; }
.thumb:focus-visible .thumb-imgs { outline-color: var(--fg); }

/* Lupe */
.lupe { position: fixed; inset: 0; z-index: 20; background: rgba(11, 24, 35, .94); }
.lupe[hidden] { display: none; }
.lupe-stage { position: absolute; inset: 0; overflow: hidden; touch-action: none; cursor: grab; }
.lupe-stage.grabbing { cursor: grabbing; }
.lupe-content { position: absolute; left: 0; top: 0; display: flex; transform-origin: 0 0; will-change: transform; box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .6); }
.lupe-content img { display: block; width: 1654px; height: 2339px; background: var(--papier); user-select: none; -webkit-user-drag: none; }
.lupe .page-label { color: var(--papier); }

/* Lader */
.loader {
  position: fixed; inset: 0; z-index: 30; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  background: var(--bg-base) var(--bg); transition: opacity .7s;
}
.loader .brand-mark::after { margin: 8px auto 0; }
.loader.done { opacity: 0; pointer-events: none; }
.loader-track { width: 180px; height: 2px; background: var(--line); overflow: hidden; }
.loader-fill { height: 100%; width: 100%; background: var(--fg); transform: scaleX(0); transform-origin: left; transition: transform .2s; }
.loader-text { font: 400 12px var(--mono); color: var(--muted); letter-spacing: .04em; }

.nogl { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); max-width: 340px; text-align: center; font-size: 15px; line-height: 1.5; }

@media (max-width: 640px) {
  .brand { left: 16px; }
  .brand-title { font-size: 16px; }
  .bar button span { display: none; }
  .bar button:not(.icon) { width: 40px; padding: 0; justify-content: center; }
  .page-label { min-width: 64px; font-size: 12px; }
  .lbl-pre { display: none; }
  .bar { gap: 2px; padding: 4px; max-width: calc(100vw - 24px); }
  .sep { margin: 0 2px; }
  .hint { font-size: 11px; white-space: normal; text-align: center; width: calc(100% - 32px); }
  .thumb-imgs { height: 74px; }
}

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