:root {
  --bg: #f6efe0;
  --paper: #fffaf0;
  --page: #fbf4e4;
  --panel: rgba(255, 250, 240, 0.94);
  --line: #e2d5bc;
  --line-soft: rgba(43, 35, 24, 0.08);
  --ink: #2b2318;
  --muted: #7a6a52;
  --accent: #e8672e;
  --accent-hi: #f0823f;
  --mustard: #e5a63a;
  --gold: #c9a35a;
  --gold-hi: #e8cd8f;
  --radius: 8px;
  --display: "Bebas Neue", "Arial Narrow", sans-serif;
  --mono: "Share Tech Mono", ui-monospace, monospace;
  --sans: "Archivo", -apple-system, sans-serif;
  --hand: "Caveat", cursive;

  /* Buch-Geometrie: eine Seite ist hochformatig 3:4 */
  --page-w: clamp(150px, min(38vw, 52vh), 430px);
  --page-h: calc(var(--page-w) * 1.32);

  /* Einband-Farben (Leder) */
  --cover-bordeaux: #6e1f2a;
  --cover-forest: #24483a;
  --cover-navy: #22304e;
  --cover-tobacco: #8a5a33;
  --cover-black: #26231f;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  min-height: 100vh;
  /* feines Papierkorn über allem */
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 0.17 0 0 0 0 0.14 0 0 0 0 0.09 0 0 0 0.05 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
}

.mono { font-family: var(--mono); }

/* ---------- Header ---------- */

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 20px;
  position: sticky;
  top: 0;
  background: rgba(246, 239, 224, 0.92);
  backdrop-filter: blur(6px);
  border-bottom: 2px solid var(--ink);
  z-index: 100;
}

.logo { display: flex; align-items: center; gap: 10px; flex-shrink: 0; color: var(--accent); cursor: pointer; }
.logo h1 {
  font-family: var(--display);
  font-size: 1.35rem;
  font-weight: 400;
  letter-spacing: 3px;
  color: var(--ink);
  white-space: nowrap;
}

.header-right { display: flex; align-items: center; gap: 8px; }

.lang-select {
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 0.7rem;
  padding: 5px 4px;
  color: var(--ink);
  cursor: pointer;
}
.lang-select:focus { outline: none; border-color: var(--accent); }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--accent);
  color: #fff;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  padding: 10px 18px;
  font-family: var(--sans);
  font-size: 0.86rem;
  font-weight: 700;
  letter-spacing: 0.4px;
  cursor: pointer;
  box-shadow: 3px 3px 0 rgba(43, 35, 24, 0.28);
  transition: transform 0.08s ease, box-shadow 0.08s ease, background 0.12s ease;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.btn:hover { background: var(--accent-hi); }
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 rgba(43, 35, 24, 0.28); }
.btn.small { padding: 7px 13px; font-size: 0.78rem; }
.btn.ghost { background: var(--paper); color: var(--ink); }
.btn.ghost:hover { background: #fff; }
.btn.icon-btn { padding: 10px 13px; font-size: 1.05rem; line-height: 1; }

.danger-link {
  background: none;
  border: none;
  color: #c0392b;
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 16px;
  text-decoration: underline;
}

/* ---------- Login ---------- */

#auth-view {
  width: min(440px, calc(100% - 32px));
  margin: 10vh auto 40px;
  background: var(--panel);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: 6px 6px 0 rgba(43, 35, 24, 0.22);
  padding: 30px 26px;
}
.auth-box { display: flex; flex-direction: column; gap: 12px; }
.auth-box h2 {
  font-family: var(--display);
  font-weight: 400;
  letter-spacing: 2px;
  font-size: 1.6rem;
}
.auth-intro { font-size: 0.86rem; line-height: 1.45; color: var(--muted); }
.auth-box input {
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 6px;
  padding: 12px 14px;
  font-family: var(--sans);
  font-size: 1rem;
  color: var(--ink);
  outline: none;
}
.auth-box input:focus { border-color: var(--accent); }
#code-step { display: flex; flex-direction: column; gap: 12px; margin-top: 4px; }
#code-input { font-family: var(--mono); letter-spacing: 6px; text-align: center; }
.link-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.78rem;
  text-decoration: underline;
  cursor: pointer;
}
.link-btn:hover { color: var(--accent); }

.auth-status {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--muted);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.auth-status .link-btn { font-size: 0.7rem; }

/* Admin: fremde Alben zeigen ihren Besitzer */
.owner-badge {
  display: block;
  font-family: var(--mono);
  font-size: 0.62rem;
  color: var(--accent);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Regal ---------- */

#shelf-view {
  width: min(1100px, calc(100% - 32px));
  margin: 4vh auto 60px;
}

/* ---------- Hilfe ---------- */

#help-view {
  width: min(920px, calc(100% - 32px));
  margin: 4vh auto 60px;
}
#help-view h2 {
  font-family: var(--display);
  font-weight: 400;
  letter-spacing: 2px;
  font-size: 1.6rem;
  text-align: center;
  margin-bottom: 4vh;
}
.help-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}
@media (min-width: 700px) {
  .help-grid { grid-template-columns: repeat(2, 1fr); }
}
.help-card {
  background: var(--panel);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: 6px 6px 0 rgba(43, 35, 24, 0.22);
  padding: 20px 22px;
}
.help-card h4 {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--display);
  font-weight: 400;
  font-size: 1.15rem;
  letter-spacing: 1px;
  margin-bottom: 8px;
}
.help-icon { font-size: 1.2rem; }
.help-card p { font-size: 0.92rem; line-height: 1.55; color: var(--ink); }
.help-card p + p { margin-top: 8px; }

.slogan {
  font-family: var(--hand);
  font-size: clamp(1.5rem, 3.4vw, 2.1rem);
  color: var(--muted);
  text-align: center;
  margin-bottom: 4vh;
  transform: rotate(-1.2deg);
}

.shelf-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
  gap: 34px 26px;
  align-items: end;
}

/* Ein Album im Regal: stehendes Fotobuch mit Leder-Einband */
.shelf-book {
  cursor: pointer;
  text-align: center;
  transition: transform 0.15s ease;
}
.shelf-book:hover { transform: translateY(-6px) rotate(-0.6deg); }

.book-cover-thumb {
  position: relative;
  aspect-ratio: 3 / 4;
  border-radius: 4px 10px 10px 4px;
  border: 2px solid rgba(0, 0, 0, 0.55);
  box-shadow: 6px 6px 0 rgba(43, 35, 24, 0.22);
  padding: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  overflow: hidden;
  /* Leder: Farbe kommt per Klasse, dazu Licht + Korn */
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='3'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.16 0'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)'/%3E%3C/svg%3E"),
    linear-gradient(135deg, rgba(255, 255, 255, 0.16), rgba(0, 0, 0, 0.22) 70%);
}
/* Buchrücken links + Seitenblock rechts angedeutet */
.book-cover-thumb::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 12px;
  background: linear-gradient(90deg, rgba(0,0,0,0.4), rgba(0,0,0,0.08) 60%, rgba(255,255,255,0.12));
}
.book-cover-thumb::after {
  content: "";
  position: absolute;
  right: 3px; top: 6px; bottom: 6px;
  width: 4px;
  border-radius: 2px;
  background: repeating-linear-gradient(180deg, #f2e8d0 0 2px, #d9cbaa 2px 3px);
  opacity: 0.9;
}

.cover-bordeaux { background-color: var(--cover-bordeaux); }
.cover-forest { background-color: var(--cover-forest); }
.cover-navy { background-color: var(--cover-navy); }
.cover-tobacco { background-color: var(--cover-tobacco); }
.cover-black { background-color: var(--cover-black); }

/* Goldprägung */
.emboss {
  font-family: var(--display);
  font-weight: 400;
  letter-spacing: 2.5px;
  background: linear-gradient(175deg, var(--gold-hi) 20%, var(--gold) 55%, #9a7635 90%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.35);
}
.book-cover-thumb .emboss {
  font-size: 1.25rem;
  line-height: 1.15;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.book-cover-thumb .cover-rule {
  width: 56px;
  height: 0;
  border-top: 1.5px solid var(--gold);
  opacity: 0.8;
}

/* aufgeklebtes Foto im Einband-Fenster */
.cover-photo {
  width: 62%;
  aspect-ratio: 1 / 1;
  background: #fff;
  padding: 5px 5px 14px;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.45);
  transform: rotate(-2.2deg);
}
.cover-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  filter: saturate(0.92) contrast(0.98);
}

.shelf-book .book-meta { margin-top: 12px; }
.shelf-book .book-title {
  font-weight: 700;
  font-size: 0.92rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.shelf-book .book-sub {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 3px;
}

/* Neues Album: leerer Einband */
.shelf-book.new .book-cover-thumb {
  background: transparent;
  border: 2px dashed var(--muted);
  box-shadow: none;
  color: var(--muted);
}
.shelf-book.new .book-cover-thumb::before,
.shelf-book.new .book-cover-thumb::after { display: none; }
.shelf-book.new .plus { font-size: 2.6rem; line-height: 1; }
.shelf-book.new .book-cover-thumb span:last-child { font-family: var(--hand); font-size: 1.3rem; }
.shelf-book.new:hover .book-cover-thumb { border-color: var(--accent); color: var(--accent); }

.shelf-empty {
  grid-column: 1 / -1;
  text-align: center;
  font-family: var(--hand);
  font-size: 1.5rem;
  color: var(--muted);
  padding: 20px 0 0;
}

/* ---------- Buch-Ansicht ---------- */

.book-section { padding: 3vh 12px 60px; }

.book-toolbar {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 3.5vh;
}

.book-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(6px, 2vw, 26px);
}

.page-nav {
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 50%;
  width: 44px;
  height: 44px;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--ink);
  cursor: pointer;
  box-shadow: 3px 3px 0 rgba(43, 35, 24, 0.22);
  flex-shrink: 0;
  transition: opacity 0.15s ease, transform 0.08s ease;
}
.page-nav:hover { background: #fff; }
.page-nav:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 rgba(43, 35, 24, 0.22); }
.page-nav:disabled { opacity: 0.25; cursor: default; }

.book-wrap { perspective: 2600px; }

.book {
  position: relative;
  width: calc(var(--page-w) * 2);
  height: var(--page-h);
  transform-style: preserve-3d;
  transition: transform 0.9s cubic-bezier(0.35, 0.1, 0.2, 1);
}
/* zugeklappt: nur die rechte Hälfte existiert sichtbar → optisch zentrieren */
.book.closed { transform: translateX(calc(var(--page-w) / -2)); }

/* Buchrücken/Unterlage: Schatten nur unter der belegten rechten Hälfte;
   im offenen Zustand kommt links der Schatten der umgeblätterten Blätter dazu */
.book::before {
  content: "";
  position: absolute;
  inset: -6px -10px -12px 50%;
  border-radius: 8px;
  background: rgba(43, 35, 24, 0.16);
  filter: blur(9px);
  transform: translateZ(-60px);
}
.book:not(.closed)::after {
  content: "";
  position: absolute;
  inset: -6px 50% -12px -10px;
  border-radius: 8px;
  background: rgba(43, 35, 24, 0.16);
  filter: blur(9px);
  transform: translateZ(-60px);
}

/* Ein Blatt: liegt in der rechten Buchhälfte, klappt um die Mittelachse */
.sheet {
  position: absolute;
  left: 50%;
  top: 0;
  width: 50%;
  height: 100%;
  transform-origin: left center;
  transform-style: preserve-3d;
  transition: transform 0.9s cubic-bezier(0.35, 0.1, 0.2, 1);
  /* KEIN will-change hier: das verflacht auf iOS den preserve-3d-Kontext,
     backface-visibility fällt aus und die Rückseite scheint gespiegelt durch */
}
.sheet.flipped { transform: rotateY(-180deg); }

.face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: hidden;
  border: 1px solid rgba(43, 35, 24, 0.28);
}
/* iOS/WebKit wendet backface-visibility NICHT auf Kinder mit eigenem
   Render-Layer an (absolut positionierte Tools, Ecken, Overlays) — die
   Regel muss explizit auf alles innerhalb der Face */
.face * {
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.face.back { transform: rotateY(180deg); }
/* Gürtel + Hosenträger: im Ruhezustand (nach der Animation, Klasse
   .settled aus app.js) wird die abgewandte Seite hart ausgeblendet —
   dann kann unabhängig von WebKit-Backface-Bugs nichts durchscheinen */
.sheet.settled.flipped .face.front { visibility: hidden; }
.sheet.settled:not(.flipped) .face.back { visibility: hidden; }
/* Chrome hit-testet versteckte Backfaces trotzdem — die abgewandte
   Seite darf deshalb keine Klicks fangen */
.sheet.flipped .face.front { pointer-events: none; }
.sheet:not(.flipped) .face.back { pointer-events: none; }

/* ---------- Seiten-Typen ---------- */

/* Papierseite */
.page-paper {
  width: 100%;
  height: 100%;
  background-color: var(--page);
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 0.2 0 0 0 0 0.16 0 0 0 0 0.1 0 0 0 0.07 0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 7% 8%;
  position: relative;
}
/* Falz-Schatten: rechte Seiten links dunkler, linke Seiten rechts dunkler */
.face.front .page-paper::before,
.face.back .page-paper::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}
.face.front .page-paper::before {
  background: linear-gradient(90deg, rgba(43, 35, 24, 0.16), rgba(43, 35, 24, 0.02) 12%, transparent 20%, rgba(255,255,255,0.06) 96%);
}
.face.back .page-paper::before {
  background: linear-gradient(270deg, rgba(43, 35, 24, 0.16), rgba(43, 35, 24, 0.02) 12%, transparent 20%, rgba(255,255,255,0.06) 96%);
}
.page-paper > * { position: relative; z-index: 2; }

/* Einband (vorne aussen + Fenster) */
.page-cover {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4%;
  padding: 9%;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='3'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.16 0'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)'/%3E%3C/svg%3E"),
    linear-gradient(135deg, rgba(255, 255, 255, 0.16), rgba(0, 0, 0, 0.25) 75%);
}
.page-cover .cover-frame {
  position: absolute;
  inset: 5.5%;
  border: 1.5px solid var(--gold);
  border-radius: 3px;
  opacity: 0.65;
  pointer-events: none;
}
.page-cover .emboss {
  font-size: clamp(1.1rem, calc(var(--page-w) * 0.085), 2.3rem);
  text-align: center;
  line-height: 1.12;
  max-width: 100%;
}
.page-cover .cover-sub {
  font-family: var(--hand);
  font-size: clamp(0.9rem, calc(var(--page-w) * 0.052), 1.35rem);
  color: var(--gold-hi);
  opacity: 0.95;
}
.page-cover .cover-hint {
  position: absolute;
  bottom: 7%;
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 1.5px;
  color: rgba(255, 255, 255, 0.55);
  text-transform: uppercase;
}

/* Vorsatz-/Titelseite im Buch */
.page-title-inner { text-align: center; }
.page-title-inner .pt-title {
  font-family: var(--hand);
  font-weight: 600;
  font-size: clamp(1.4rem, calc(var(--page-w) * 0.105), 2.6rem);
  line-height: 1.15;
  cursor: pointer;
}
.page-title-inner .pt-sub {
  font-family: var(--hand);
  font-size: clamp(1rem, calc(var(--page-w) * 0.06), 1.5rem);
  color: var(--muted);
  margin-top: 8px;
}
.page-title-inner .pt-date {
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--muted);
  margin-top: 20px;
  letter-spacing: 1px;
}
.page-title-inner .pt-rule {
  width: 44%;
  margin: 14px auto 0;
  border-top: 2px solid var(--ink);
  opacity: 0.25;
}

/* Fotoseite: eingeklebtes Foto mit Ecken + Handschrift */
.photo-mount {
  width: 88%;
  position: relative;
  background: #fff;
  padding: 4.5% 4.5% 5%;
  box-shadow: 0 4px 14px rgba(43, 35, 24, 0.3);
}
.photo-mount img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
  background: #eee;
  /* KEIN filter hier: gefilterte Bilder bekommen eine eigene Compositing-
     Ebene, die auf iOS der 3D-Blätter-Animation hinterherhinkt (Bild
     »klebt«, Blatt dreht). Der warme Retro-Ton kommt als Overlay: */
}
.photo-mount::after {
  content: "";
  position: absolute;
  inset: 4.5% 4.5% 5%;
  pointer-events: none;
  background: linear-gradient(rgba(229, 166, 58, 0.07), rgba(110, 31, 42, 0.05));
  z-index: 2;
}
/* Hoch- und quadratische Formate werden passend eingeklebt statt
   ins Querformat beschnitten (Klasse setzt app.js nach dem Laden) */
.photo-mount.portrait { width: 60%; }
.photo-mount.portrait img { aspect-ratio: 3 / 4; }
.photo-mount.square { width: 72%; }
.photo-mount.square img { aspect-ratio: 1 / 1; }
/* Foto-Ecken */
.pc {
  position: absolute;
  width: 9%;
  aspect-ratio: 1;
  background: linear-gradient(135deg, #e9dcbe, #cdbc95);
  box-shadow: 0 1px 2px rgba(43, 35, 24, 0.35);
  z-index: 3;
}
.pc.tl { top: -2.5%; left: -2.5%; clip-path: polygon(0 0, 100% 0, 0 100%); }
.pc.tr { top: -2.5%; right: -2.5%; clip-path: polygon(0 0, 100% 0, 100% 100%); }
.pc.bl { bottom: -2.5%; left: -2.5%; clip-path: polygon(0 0, 0 100%, 100% 100%); }
.pc.br { bottom: -2.5%; right: -2.5%; clip-path: polygon(100% 0, 100% 100%, 0 100%); }

.photo-caption {
  font-family: var(--hand);
  font-weight: 500;
  font-size: clamp(1rem, calc(var(--page-w) * 0.062), 1.55rem);
  line-height: 1.2;
  text-align: center;
  margin-top: 5.5%;
  min-height: 1.3em;
  max-width: 92%;
  cursor: text;
  color: #3d3226;
}
.photo-caption.empty { color: rgba(122, 106, 82, 0.5); }
.photo-date {
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 1px;
  color: var(--muted);
  margin-top: 6px;
  cursor: text;
}
.caption-input {
  font-family: var(--hand);
  font-weight: 500;
  font-size: clamp(1rem, calc(var(--page-w) * 0.062), 1.55rem);
  text-align: center;
  background: rgba(255, 255, 255, 0.6);
  border: none;
  border-bottom: 2px dashed var(--muted);
  outline: none;
  color: var(--ink);
  width: 92%;
  margin-top: 5.5%;
}
.caption-input.date-input {
  font-family: var(--mono);
  font-size: 0.7rem;
  margin-top: 6px;
  width: 60%;
}

/* Werkzeuge auf der Fotoseite (erscheinen bei Hover) */
.photo-tools {
  position: absolute;
  top: 3.5%;
  right: 4%;
  display: flex;
  gap: 6px;
  opacity: 0;
  transition: opacity 0.15s ease;
  z-index: 4;
}
.face:hover .photo-tools { opacity: 1; }
.photo-tools button {
  background: rgba(255, 250, 240, 0.92);
  border: 1.5px solid var(--ink);
  border-radius: 6px;
  font-size: 0.72rem;
  font-family: var(--mono);
  padding: 4px 7px;
  cursor: pointer;
  color: var(--ink);
}
.photo-tools button:hover { background: #fff; }
.photo-tools .tool-del:hover { color: #c0392b; border-color: #c0392b; }

/* Leere Seite / »Foto einkleben« */
.page-add {
  border: 2.5px dashed rgba(122, 106, 82, 0.55);
  border-radius: 6px;
  width: 78%;
  aspect-ratio: 4 / 3.6;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.page-add:hover { border-color: var(--accent); color: var(--accent); }
.page-add .plus { font-size: 2.4rem; line-height: 1; }
.page-add span:last-child { font-family: var(--hand); font-size: 1.35rem; }

.page-blank-mark {
  font-family: var(--mono);
  font-size: 0.62rem;
  color: rgba(122, 106, 82, 0.4);
  letter-spacing: 2px;
}

.page-indicator {
  text-align: center;
  margin-top: 3vh;
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 1px;
}

.upload-status {
  text-align: center;
  margin-top: 10px;
  font-size: 0.72rem;
  color: var(--accent);
  letter-spacing: 1px;
}

/* ---------- Modal ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(43, 35, 24, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 16px;
}
.modal-panel {
  width: min(420px, 100%);
  background: var(--panel);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: 6px 6px 0 rgba(43, 35, 24, 0.25);
  padding: 26px 24px;
  display: flex;
  flex-direction: column;
}
.modal-panel h2 {
  font-family: var(--display);
  font-weight: 400;
  letter-spacing: 2px;
  font-size: 1.5rem;
  margin-bottom: 14px;
}
.field-label {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
  margin: 12px 0 5px;
}
.modal-panel input[type="text"] {
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 6px;
  padding: 10px 12px;
  font-family: var(--sans);
  font-size: 0.95rem;
  color: var(--ink);
  outline: none;
}
.modal-panel input[type="text"]:focus { border-color: var(--accent); }

.color-swatches { display: flex; gap: 10px; }
.swatch {
  width: 44px;
  height: 56px;
  border-radius: 3px 7px 7px 3px;
  border: 2px solid rgba(0, 0, 0, 0.4);
  cursor: pointer;
  box-shadow: 2px 2px 0 rgba(43, 35, 24, 0.2);
  background-image: linear-gradient(135deg, rgba(255, 255, 255, 0.18), rgba(0, 0, 0, 0.22));
  position: relative;
}
.swatch.selected::after {
  content: "✓";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gold-hi);
  font-size: 1.1rem;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}
.swatch.selected { outline: 3px solid var(--accent); outline-offset: 2px; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}

/* ---------- Teilen-Modal ---------- */

.share-options { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.share-option {
  display: flex;
  flex-direction: column;
  gap: 3px;
  text-align: left;
  background: var(--paper);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 11px 14px;
  cursor: pointer;
  font-family: var(--sans);
  color: var(--ink);
  transition: border-color 0.12s ease, background 0.12s ease;
}
.share-option:hover { border-color: var(--ink); }
.share-option.selected { border-color: var(--accent); background: #fff; box-shadow: 3px 3px 0 rgba(232, 103, 46, 0.25); }
.share-option .so-title { font-weight: 700; font-size: 0.9rem; }
.share-option .so-desc { font-size: 0.76rem; color: var(--muted); line-height: 1.35; }

.share-link-row { display: flex; gap: 8px; }
.share-link-row input {
  flex: 1;
  min-width: 0;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 6px;
  padding: 8px 10px;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--ink);
}
.share-native { margin-top: 8px; width: 100%; }
.share-code-area { text-align: center; margin-top: 6px; }
.share-code-row2 { display: flex; align-items: center; justify-content: center; gap: 8px; }
.share-code-editrow { display: flex; justify-content: center; gap: 8px; margin-top: 8px; }
.share-code-editrow input {
  width: 160px;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 0.95rem;
  letter-spacing: 3px;
  text-align: center;
  text-transform: uppercase;
  color: var(--ink);
  outline: none;
}
.share-code-editrow input:focus { border-color: var(--accent); }

/* Code-Gate für geschützte Alben */
#gate-view {
  width: min(440px, calc(100% - 32px));
  margin: 10vh auto 40px;
  background: var(--panel);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: 6px 6px 0 rgba(43, 35, 24, 0.22);
  padding: 30px 26px;
}
.gate-kicker { font-size: 0.64rem; letter-spacing: 3px; color: var(--accent); }
.gate-title { font-family: var(--hand) !important; font-weight: 600; font-size: 2rem !important; letter-spacing: 0 !important; }
#gate-input { letter-spacing: 5px; text-align: center; text-transform: uppercase; }
.share-code {
  font-size: 1.7rem;
  letter-spacing: 8px;
  padding: 10px 14px 10px 22px;
  background: var(--paper);
  border: 2px dashed var(--ink);
  border-radius: var(--radius);
  display: inline-block;
  margin-top: 4px;
}
.share-code-hint { font-size: 0.74rem; color: var(--muted); margin-top: 6px; }
.share-gallery-hint { font-size: 0.76rem; color: var(--muted); margin-top: 10px; }
.share-gallery-hint a { color: var(--accent); font-weight: 600; }

/* Lese-Ansicht (geteiltes Album): Hinweisbanner oben */
.viewer-banner {
  text-align: center;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 1.5px;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 2vh;
}

/* ---------- QR-Modal ---------- */

.qr-panel { align-items: center; text-align: center; }
.qr-explain { font-size: 0.86rem; color: var(--muted); max-width: 34ch; margin: 0 auto; }
.qr-box {
  width: min(240px, 70vw);
  aspect-ratio: 1;
  background: #fff;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  padding: 12px;
  margin: 16px auto 10px;
  box-shadow: 4px 4px 0 rgba(43, 35, 24, 0.2);
}
.qr-box svg { width: 100%; height: 100%; display: block; }
.qr-url { font-size: 0.68rem; color: var(--muted); word-break: break-all; }
.qr-live { font-size: 0.74rem; color: var(--accent); margin-top: 10px; letter-spacing: 0.5px; }
.qr-note { font-size: 0.74rem; color: var(--muted); margin-top: 6px; }
.qr-panel .modal-actions { justify-content: center; }

/* Party-Modus */
.qr-party {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1.5px dashed var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  width: 100%;
}
.qr-party-note { font-size: 0.74rem; color: var(--muted); max-width: 36ch; }
.qr-party.on .qr-party-note { color: var(--accent); font-weight: 600; }
.qr-party.on #qr-party-toggle { background: var(--paper); color: var(--ink); }
/* Hinweis-Punkt am Party-Button, solange die Party läuft */
#btn-party { position: relative; }
#btn-party.party-on::after {
  content: "";
  position: absolute;
  top: -5px;
  right: -5px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg);
  animation: party-pulse 1.6s ease-in-out infinite;
}
@keyframes party-pulse { 50% { transform: scale(1.35); } }

.up-party {
  font-family: var(--hand);
  font-size: 1.35rem;
  color: var(--accent);
  margin-top: 4px;
}

/* ---------- Admin ---------- */

#admin-view {
  width: min(1100px, calc(100% - 32px));
  margin: 4vh auto 60px;
}
#admin-view h2 {
  font-family: var(--display);
  font-weight: 400;
  letter-spacing: 3px;
  font-size: 1.8rem;
  text-align: center;
}
.admin-totals {
  text-align: center;
  font-size: 0.74rem;
  color: var(--muted);
  letter-spacing: 1px;
  margin: 8px 0 30px;
}
.admin-user { margin-bottom: 44px; }
.admin-user-head {
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
  border-bottom: 2px solid var(--ink);
  padding-bottom: 8px;
  margin-bottom: 20px;
}
.admin-user-head h3 { font-family: var(--mono); font-weight: 400; font-size: 1rem; }
.admin-user-head .admin-user-meta { font-family: var(--mono); font-size: 0.7rem; color: var(--muted); }

/* ---------- Fotoautomat (Webcam am Desktop) ---------- */

.cam-panel { width: min(680px, 100%); align-items: center; text-align: center; }
.cam-frame {
  position: relative;
  width: 100%;
  margin-top: 12px;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  overflow: hidden;
  background: #1a1712;
  box-shadow: 4px 4px 0 rgba(43, 35, 24, 0.2);
}
#cam-video {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  transform: scaleX(-1); /* Spiegel-Vorschau — das Foto selbst bleibt ungespiegelt */
}
#cam-flash {
  position: absolute;
  inset: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none;
}
#cam-flash.zap { animation: cam-zap 0.35s ease-out; }
@keyframes cam-zap { 0% { opacity: 0.95; } 100% { opacity: 0; } }
.cam-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 22px;
  margin-top: 18px;
  width: 100%;
  position: relative;
}
#cam-shutter {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 3px solid var(--ink);
  background: radial-gradient(circle at 35% 30%, var(--accent-hi), var(--accent) 65%);
  cursor: pointer;
  box-shadow: 4px 4px 0 rgba(43, 35, 24, 0.25);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
#cam-shutter:active { transform: translate(2px, 2px) scale(0.96); box-shadow: 1px 1px 0 rgba(43, 35, 24, 0.25); }
.cam-count { font-size: 0.72rem; color: var(--muted); position: absolute; right: 0; }

/* ---------- Handy-Upload-Seite ---------- */

.up-main {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
}
.up-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: 6px 6px 0 rgba(43, 35, 24, 0.22);
  padding: 30px 24px;
  text-align: center;
}
.up-kicker { font-size: 0.66rem; letter-spacing: 3px; color: var(--accent); }
.up-title {
  font-family: var(--hand);
  font-weight: 600;
  font-size: 2.1rem;
  line-height: 1.1;
  margin-top: 8px;
}
.up-sub { font-family: var(--hand); font-size: 1.2rem; color: var(--muted); margin-top: 2px; }
.up-count { font-size: 0.72rem; color: var(--muted); margin: 10px 0 20px; letter-spacing: 1px; }
#up-actions { display: flex; flex-direction: column; gap: 12px; }
.btn.up-big { padding: 16px 20px; font-size: 1rem; width: 100%; }
.up-status { font-family: var(--mono); font-size: 0.78rem; color: var(--accent); margin-top: 16px; }
.up-done {
  font-family: var(--hand);
  font-size: 1.6rem;
  color: var(--teal, #2a9d8f);
  margin-top: 14px;
}
.up-error {
  font-size: 0.88rem;
  color: #c0392b;
  margin-top: 12px;
  line-height: 1.4;
}
.up-hint { font-size: 0.68rem; color: var(--muted); letter-spacing: 0.5px; }

/* ---------- Lightbox ---------- */

#lightbox {
  position: fixed;
  inset: 0;
  background: rgba(20, 16, 11, 0.93);
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lb-figure {
  max-width: min(92vw, 1400px);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin: 0;
}
#lb-img {
  max-width: 100%;
  max-height: calc(90vh - 70px);
  object-fit: contain;
  background: #fff;
  padding: clamp(6px, 1vw, 12px);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
}
#lb-caption {
  font-family: var(--hand);
  font-size: clamp(1.1rem, 2.4vw, 1.5rem);
  color: var(--paper);
  text-align: center;
  min-height: 1.2em;
}
#lb-close {
  position: absolute;
  top: 14px;
  right: 18px;
  background: none;
  border: none;
  color: var(--paper);
  font-size: 2.2rem;
  line-height: 1;
  cursor: pointer;
  z-index: 2;
}
.lb-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(246, 239, 224, 0.12);
  border: 1.5px solid rgba(246, 239, 224, 0.5);
  border-radius: 50%;
  width: 46px;
  height: 46px;
  color: var(--paper);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  z-index: 2;
}
.lb-nav:hover { background: rgba(246, 239, 224, 0.25); }
.lb-nav:disabled { opacity: 0.25; cursor: default; }
#lb-prev { left: 14px; }
#lb-next { right: 14px; }
#lb-count {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(246, 239, 224, 0.7);
  font-size: 0.72rem;
  letter-spacing: 2px;
}
.photo-mount { cursor: zoom-in; }

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

#toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--paper);
  padding: 10px 18px;
  border-radius: 6px;
  font-size: 0.74rem;
  letter-spacing: 0.5px;
  z-index: 300;
  box-shadow: 4px 4px 0 rgba(43, 35, 24, 0.25);
}

/* ---------- Mobile ---------- */

@media (max-width: 640px) {
  /* Logo nur als Icon — der Platz gehört den Aktionen */
  .logo h1 { display: none; }
  .logo svg { width: 26px; height: 26px; }
  header { padding: 10px 12px; gap: 6px; }
  .header-right { gap: 5px; }
  .btn { padding: 9px 13px; font-size: 0.78rem; }

  /* Header kompakt: E-Mail ausblenden (Abmelden bleibt), «+ Neues Album» → «+»,
     «‹ Regal» → «‹» */
  .auth-status > span:first-child { display: none; }
  #btn-new-album { font-size: 0; padding: 7px 12px; }
  #btn-new-album::after { content: "+"; font-size: 1.15rem; line-height: 1; }
  #btn-back-shelf { font-size: 0; padding: 7px 12px; }
  #btn-back-shelf::after { content: "‹"; font-size: 1.15rem; line-height: 1; }
  #btn-help, #btn-admin { padding: 7px 9px; font-size: 0.72rem; }

  /* ---- Buch-Ansicht als App-Screen: alles sitzt in genau einer
     Bildschirmhöhe, kein Scrollen. Ganzes Buch (Doppelseite) so breit
     wie möglich, vertikal zentriert; Pfeile + Seitenanzeige unten als
     Daumen-Leiste. ---- */
  :root { --page-w: min(46.5vw, 34svh); }

  .book-section {
    position: relative;
    height: calc(100svh - 59px); /* Header (sticky) abgezogen */
    padding: 0 0 calc(64px + env(safe-area-inset-bottom));
    margin: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  .viewer-banner { margin: 10px 0 0; }
  .book-toolbar { gap: 6px; margin: 10px 0 0; flex-shrink: 0; }
  /* Toolbar: nur Icons, Beschriftungen weg */
  .book-toolbar .btn-txt { display: none; }
  .book-toolbar .btn { padding: 10px 12px; font-size: 0.95rem; gap: 0; min-height: 40px; }

  /* Bühne füllt den Rest, Buch schwebt mittig */
  .book-stage { flex: 1; min-height: 0; gap: 0; }

  /* Pfeile unten links/rechts, gross genug für den Daumen */
  .page-nav {
    position: absolute;
    top: auto;
    bottom: calc(10px + env(safe-area-inset-bottom));
    z-index: 50;
    width: 48px;
    height: 48px;
    font-size: 1.4rem;
  }
  .page-nav.prev { left: 16px; }
  .page-nav.next { right: 16px; }

  /* Seitenanzeige mittig zwischen den Pfeilen */
  .page-indicator {
    position: absolute;
    left: 72px;
    right: 72px;
    bottom: calc(24px + env(safe-area-inset-bottom));
    margin: 0;
    font-size: 0.66rem;
  }
  .upload-status {
    position: absolute;
    left: 0;
    right: 0;
    bottom: calc(62px + env(safe-area-inset-bottom));
    margin: 0;
  }

  .lb-nav { width: 40px; height: 40px; }
  .shelf-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 26px 18px; }
}

/* ---------- Hub: Album-Code-Eingabe ---------- */

.hub-code {
  margin-top: 6vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.hub-code-label {
  font-family: var(--hand);
  font-size: 1.35rem;
  color: var(--muted);
  transform: rotate(-1deg);
}
.hub-code-row { display: flex; gap: 8px; }
#hub-code-input {
  width: 190px;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 1.05rem;
  letter-spacing: 4px;
  text-align: center;
  text-transform: uppercase;
  color: var(--ink);
  outline: none;
}
#hub-code-input:focus { border-color: var(--accent); }
.hub-code-err { font-size: 0.7rem; color: #c0392b; letter-spacing: 0.5px; }

/* Touch-Geräte: Hover existiert nicht — Foto-Werkzeuge immer zeigen */
@media (hover: none) {
  .face:hover .photo-tools, .photo-tools { opacity: 1; }
  .photo-tools button { padding: 6px 9px; font-size: 0.8rem; }
}
