:root {
  --wall: #e8e8e4;
  --ink: #1e1f1c;
  --muted: #6c6e68;
  --slot: #d6d7d1;
  --focus: #2f5d8a;
  --edge: clamp(6px, 2.2vw, 28px);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--wall); color: var(--ink); scrollbar-gutter: stable; }
html.lb-open { overflow: hidden; }
body { margin: 0; font: 16px/1.5 var(--sans); }

/* Kopf */
.masthead { padding: clamp(2.5rem, 8vw, 6.5rem) var(--edge) clamp(1.5rem, 4vw, 3rem); }
.masthead h1 { margin: 0; font: 400 clamp(2.5rem, 8vw, 6rem)/.95 var(--serif); letter-spacing: -.015em; }
.masthead p { margin: 1rem 0 0; max-width: 40em; color: var(--muted); }
.note { margin: 0 var(--edge); color: var(--muted); }

/* Raster */
.grid { position: relative; margin: 0 var(--edge) var(--edge); }
.tile { position: absolute; display: block; overflow: hidden; background: var(--slot); cursor: zoom-in; }
.tile img { display: block; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .4s ease; }
.tile.loaded img { opacity: 1; }
.tile:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; z-index: 1; }

/* Zeitmarke */
.when {
  position: fixed; left: var(--edge); bottom: calc(clamp(.75rem, 3vw, 1.5rem) + env(safe-area-inset-bottom));
  z-index: 5; padding: .3em .75em .4em; border-radius: 2px;
  background: rgba(232, 232, 228, .92); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  font: italic 400 clamp(1.1rem, 2.4vw, 1.6rem)/1.1 var(--serif);
  opacity: 0; transform: translateY(6px); transition: opacity .25s, transform .25s; pointer-events: none;
}
.when.show { opacity: 1; transform: none; }
html.lb-open .when { display: none; }

/* Großansicht */
.lb { position: fixed; inset: 0; z-index: 20; background: #000; color: #f2f2ef; outline: none; -webkit-user-select: none; user-select: none; }
.lb[hidden] { display: none; }

.lb-stage {
  position: absolute; inset: 0; margin: 0; display: flex; align-items: center; justify-content: center;
  padding: clamp(8px, 4vh, 48px) clamp(8px, 6vw, 96px) calc(76px + env(safe-area-inset-bottom));
  touch-action: pinch-zoom;
}
.lb-img { display: block; width: 100%; height: 100%; object-fit: contain; }

.lb-btn {
  appearance: none; border: 0; margin: 0; padding: 0; width: 48px; height: 48px; border-radius: 50%;
  display: grid; place-items: center; color: inherit; background: rgba(255, 255, 255, .08);
  cursor: pointer; transition: background .2s;
}
.lb-btn:hover { background: rgba(255, 255, 255, .18); }
.lb-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.lb-btn[hidden] { display: none; }
.lb svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.lb .i-play path { fill: currentColor; stroke: none; }
.lb .i-pause, .lb.playing .i-play { display: none; }
.lb.playing .i-pause { display: block; }

.lb-close { position: absolute; top: max(12px, env(safe-area-inset-top)); right: 12px; }
.lb-prev, .lb-next { position: absolute; top: 50%; margin-top: -24px; }
.lb-prev { left: 12px; }
.lb-next { right: 12px; }

.lb-bar {
  position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: center; justify-content: center;
  gap: 18px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
}
.lb-meta { margin: 0; min-width: 11em; text-align: center; line-height: 1.25; }
.lb-date { display: block; font: italic 1.15rem/1.2 var(--serif); }
.lb-count { display: block; font-size: .8rem; color: #9a9b96; font-variant-numeric: tabular-nums; }

.lb-ui { transition: opacity .3s; }
.lb.idle { cursor: none; }
.lb.idle .lb-ui:not(:focus-within) { opacity: 0; pointer-events: none; }

.lb-progress { position: absolute; top: 0; left: 0; right: 0; height: 2px; z-index: 2; background: rgba(255, 255, 255, .12); opacity: 0; transition: opacity .3s; }
.lb.playing .lb-progress { opacity: 1; }
.lb-progress span { display: block; height: 100%; background: #f2f2ef; transform: scaleX(0); transform-origin: 0 50%; }
@keyframes lb-progress { to { transform: scaleX(1); } }

.lb-spinner {
  position: absolute; left: 50%; top: 50%; width: 28px; height: 28px; margin: -14px 0 0 -14px;
  border: 2px solid rgba(255, 255, 255, .2); border-top-color: #fff; border-radius: 50%; opacity: 0; pointer-events: none;
}
.lb.loading .lb-spinner { animation: lb-spin .8s linear infinite, lb-appear 0s .4s forwards; }
@keyframes lb-spin { to { transform: rotate(360deg); } }
@keyframes lb-appear { to { opacity: 1; } }

@media (max-width: 600px) {
  .lb-prev, .lb-next { width: 40px; height: 40px; margin-top: -20px; background: rgba(0, 0, 0, .35); }
}

@media (prefers-reduced-motion: reduce) {
  .tile img, .when, .lb-ui, .lb-progress { transition: none; }
  .lb.loading .lb-spinner { animation: lb-appear 0s .4s forwards; }
}