:root {
  --body: #1c1b1a;
  --case-top: #2a2826;
  --case-bottom: #1c1b1a;
  --case-edge: #3a3632;
  --label: #8d857c;
  --amber: #f5a623;
  --red-hi: #ff7a6b;
  --red: #d63a2f;
  --paper: #f4f1ea;
  --undeveloped: linear-gradient(#352e2b, #54463e);
  --text: #f4efe6;
  --muted: #a39b91;
  --hand: 'Segoe Script', 'Bradley Hand', 'Brush Script MT', cursive;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--body);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button { font: inherit; cursor: pointer; }
button:focus-visible { outline: 3px solid var(--amber); outline-offset: 3px; }
[hidden] { display: none !important; }

/* ---------- Text-Screens ---------- */
.screen {
  min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; padding: 32px 24px calc(32px + env(safe-area-inset-bottom)); text-align: center;
}
.screen h1 { font: 400 30px/1.2 var(--hand); margin: 0; }
.screen p { margin: 0; max-width: 32ch; }
.muted { color: var(--muted); }
.pill {
  background: var(--paper); color: #2a2826; border: 0; border-radius: 999px; padding: 12px 20px; font-weight: 600;
}
.ghost { background: none; border: 1px solid #4a4540; color: var(--text); border-radius: 999px; padding: 10px 18px; }
.screen .stack-big { position: relative; width: 120px; height: 120px; margin-bottom: 8px; }
.stack-big .stack-pol { width: 110px; height: 120px; }

/* ---------- Kamera ---------- */
.cam {
  height: 100dvh; display: flex; flex-direction: column;
  background: linear-gradient(var(--case-top), var(--case-bottom));
  padding: calc(14px + env(safe-area-inset-top)) 16px calc(18px + env(safe-area-inset-bottom));
  user-select: none; -webkit-user-select: none;
}
.cam-top { display: flex; align-items: center; justify-content: space-between; height: 44px; }
.brand { font: 700 11px system-ui; letter-spacing: 3px; color: var(--label); }
.counter {
  font: 700 26px/1 'Courier New', ui-monospace, monospace; color: var(--amber);
  background: #0e0e0e; border: 2px solid #4a4540; border-radius: 7px; padding: 4px 10px;
  box-shadow: inset 0 2px 5px #000; min-width: 54px; text-align: center;
}
.finder {
  position: relative; flex: 1; margin: 10px 0 18px; border-radius: 14px; overflow: hidden;
  border: 3px solid var(--case-edge); box-shadow: inset 0 0 0 2px #000; background: #000;
}
.finder video { width: 100%; height: 100%; object-fit: cover; display: block; }
.finder video.mirror { transform: scaleX(-1); }
.finder-black { position: absolute; inset: 0; background: #000; opacity: 0; transition: opacity .08s; pointer-events: none; }
.finder-black.on { opacity: 1; }
.finder-msg {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; padding: 24px; text-align: center; color: var(--text); background: #111;
}
.finder-msg button { background: var(--paper); color: #222; border: 0; border-radius: 999px; padding: 10px 18px; font-weight: 600; }

.cam-bottom { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; height: 96px; }
.stack { position: relative; width: 62px; height: 66px; }
.stack-pol {
  position: absolute; inset: 0; background: var(--paper); border-radius: 2px; padding: 5px 5px 14px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, .6); transform: rotate(var(--rot, 0deg));
}
.stack-pol::after { content: ""; display: block; width: 100%; height: 100%; background: var(--undeveloped); }
.stack-pol.landed { animation: land .25s ease-out; }
@keyframes land { from { transform: rotate(var(--rot)) scale(1.25); opacity: .4; } }

.shutter {
  width: 78px; height: 78px; border-radius: 50%; border: 5px solid var(--case-edge);
  background: radial-gradient(circle at 40% 35%, var(--red-hi), var(--red));
  box-shadow: 0 0 0 2px #000, 0 4px 10px rgba(0, 0, 0, .5); transition: transform .08s;
}
.shutter:active, .shutter:disabled { transform: scale(.93); }
.side { display: flex; justify-content: flex-end; gap: 10px; }
.side button {
  width: 46px; height: 46px; border-radius: 50%; border: 0; background: var(--case-edge); color: #ddd; font-size: 21px;
}
.side .flash[aria-pressed="true"] { background: var(--amber); color: #222; }

.fly {
  position: fixed; z-index: 10; border-radius: 10px; background-size: cover; background-position: center;
  filter: brightness(.22) blur(3px); transform-origin: 0 0; pointer-events: none;
  transition: transform .6s cubic-bezier(.5, 0, .3, 1), border-radius .6s;
}
.screen-flash { position: fixed; inset: 0; background: #fff; opacity: 0; pointer-events: none; z-index: 20; transition: opacity .1s; }
.screen-flash.on { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  .fly, .stack-pol.landed { transition: none; animation: none; }
}

/* ---------- Hinweis-Karte (Push) ---------- */
.sheet {
  position: fixed; inset: auto 0 0 0; z-index: 30; padding: 0 12px calc(12px + env(safe-area-inset-bottom));
  animation: up .3s ease-out;
}
.sheet-card {
  background: var(--paper); color: #2a2826; border-radius: 18px; padding: 20px; display: flex; flex-direction: column;
  gap: 12px; box-shadow: 0 -6px 30px rgba(0, 0, 0, .5); max-width: 460px; margin: 0 auto; text-align: center;
}
.sheet-card h2 { font: 400 24px/1.2 var(--hand); margin: 0; }
.sheet-card p { margin: 0; }
.sheet-card .pill { background: #2a2826; color: var(--paper); }
.sheet-card .ghost { color: #6b625a; border-color: #d8d1c5; }
@keyframes up { from { transform: translateY(100%); } }

/* ---------- Fotobuch ---------- */
.book { min-height: 100dvh; overflow: hidden; }
.board { position: relative; isolation: isolate; max-width: 1100px; margin: 0 auto; padding: 0 8px; } /* Polaroid-z-index bleibt unter der Großansicht */
.cover {
  position: absolute; top: 0; left: 0; right: 0; height: 160px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 4px; color: var(--cover-ink, #5a4636); font-family: Georgia, serif;
  padding-top: env(safe-area-inset-top);
}
.cover small { font-size: 12px; letter-spacing: 3px; text-transform: uppercase; }
.cover b { font-size: 30px; font-weight: 400; }
.marker { position: absolute; left: 14px; font: 400 24px/1 var(--hand); }
.bpol {
  position: absolute; padding: 6% 6% 22%; background: #fff; border: 0; border-radius: 2px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .28); transform: rotate(var(--rot)); transition: transform .15s;
}
.bpol:hover, .bpol:focus-visible { transform: rotate(0) scale(1.04); z-index: 9999 !important; }
.bpol { display: block; }
.bpol img { display: block; width: 100%; height: auto; aspect-ratio: 1; object-fit: cover; background: #e9e4da; }
.empty { position: absolute; top: 200px; left: 0; right: 0; text-align: center; color: #5a4636; }

.lightbox {
  position: fixed; inset: 0; z-index: 50; background: rgba(12, 11, 10, .96);
  display: flex; align-items: center; justify-content: center; touch-action: pan-y;
}
.lightbox img { max-width: 100%; max-height: calc(100dvh - 120px); object-fit: contain; user-select: none; -webkit-user-drag: none; }
.lightbox button { position: absolute; background: rgba(255, 255, 255, .12); color: #fff; border: 0; border-radius: 50%; width: 48px; height: 48px; font-size: 26px; }
.lb-close { top: calc(12px + env(safe-area-inset-top)); right: 12px; font-size: 20px !important; }
.lb-prev { left: 10px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 10px; top: 50%; transform: translateY(-50%); }
.lb-bar {
  position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-between; align-items: center;
  padding: 14px 18px calc(14px + env(safe-area-inset-bottom)); color: #ddd; font-size: 14px;
}
.lb-dl { color: #222; background: var(--paper); border-radius: 999px; padding: 9px 16px; text-decoration: none; font-weight: 600; }
@media (hover: none) { .lb-prev, .lb-next { display: none; } }
