/* =====================================================================
   Gästebuch – Leineneinband, Papierseiten, Tinte
   ===================================================================== */

@font-face { font-family: "Cormorant"; src: url(fonts/cormorant-garamond-latin-400-normal.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Cormorant"; src: url(fonts/cormorant-garamond-latin-500-normal.woff2) format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Cormorant"; src: url(fonts/cormorant-garamond-latin-600-normal.woff2) format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Cormorant"; src: url(fonts/cormorant-garamond-latin-400-italic.woff2) format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Cormorant"; src: url(fonts/cormorant-garamond-latin-500-italic.woff2) format("woff2"); font-weight: 500; font-style: italic; font-display: swap; }
@font-face { font-family: "Caveat"; src: url(fonts/caveat-latin-400-normal.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Caveat"; src: url(fonts/caveat-latin-600-normal.woff2) format("woff2"); font-weight: 600; font-display: swap; }

:root {
  --desk: #1c1814;
  --desk-2: #2a231d;
  --linen: #34503f;
  --linen-dark: #22362a;
  --linen-light: #46664f;
  --gold: #d6b871;
  --gold-soft: rgba(214, 184, 113, .55);
  --paper: #f8f2e4;
  --paper-2: #eee3cb;
  --paper-edge: #dccdaa;
  --ink: #2b2520;
  --ink-soft: #6c6153;
  --ink-green: #2f4a3a;
  --rule: rgba(74, 98, 120, .17);
  --red: #993a2a;
  --serif: "Cormorant", "Cormorant Garamond", Garamond, Georgia, serif;
  --hand: "Caveat", "Segoe Print", "Bradley Hand", cursive;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --noise: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  --paper-noise: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.75' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .45 0 0 0 0 .35 0 0 0 0 .2 0 0 0 .14 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  --topbar-h: 52px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--desk); }
body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(ellipse at 50% 35%, rgba(255, 220, 170, .07), transparent 65%),
    var(--noise),
    linear-gradient(180deg, var(--desk-2), var(--desk));
  background-attachment: fixed;
  min-height: 100svh;
}
img { display: block; max-width: 100%; }
button { font: inherit; color: inherit; }
a { color: var(--ink-green); }
[hidden] { display: none !important; }

/* ---------- Texturen ---------- */
.linen {
  background-color: var(--linen);
  background-image:
    linear-gradient(90deg, rgba(0,0,0,.38), rgba(0,0,0,.05) 3%, rgba(0,0,0,.22) 4.2%, transparent 6.5%),
    repeating-linear-gradient(0deg, rgba(255,255,255,.045) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(90deg, rgba(0,0,0,.075) 0 1px, transparent 1px 3px),
    var(--noise),
    radial-gradient(ellipse at 35% 25%, rgba(255,255,255,.10), transparent 60%),
    linear-gradient(140deg, var(--linen-light), var(--linen-dark));
}
.endpaper {
  background-color: #2c4536;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='40'%3E%3Cpath d='M4 32 L16 16 L22 23 L30 10 L44 32' fill='none' stroke='%23d6b871' stroke-opacity='.22' stroke-width='1.2' stroke-linejoin='round'/%3E%3C/svg%3E"),
    var(--noise),
    linear-gradient(160deg, #36533f, #243a2c);
  background-size: 56px 40px, 180px 180px, 100% 100%;
}
.paper {
  background-color: var(--paper);
}
.foil {
  color: var(--gold);
  text-shadow: 0 1px 0 rgba(0,0,0,.5), 0 -1px 0 rgba(255,240,200,.15);
}
.hand { font-family: var(--hand); }
.lined {
  line-height: 1.5em;
  background-image: linear-gradient(to bottom, transparent calc(1.5em - 1px), var(--rule) calc(1.5em - 1px), var(--rule) 1.5em);
  background-size: 100% 1.5em;
  background-attachment: local;
}

/* ---------- Kopfzeile ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  height: var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 clamp(12px, 3vw, 28px);
  background: rgba(18, 15, 12, .88);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(214, 184, 113, .15);
  color: var(--paper);
}
.brand {
  display: flex; align-items: center; gap: 10px;
  color: var(--gold); text-decoration: none;
  font-family: var(--serif); font-size: 1.2rem; font-weight: 500; white-space: nowrap;
  min-width: 0;
}
.brand span { overflow: hidden; text-overflow: ellipsis; }
.brand svg { width: 30px; flex: none; }
.topnav { display: flex; align-items: center; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.topnav::-webkit-scrollbar { display: none; }
.topnav a, .topnav .linklike {
  color: rgba(248, 242, 228, .78); text-decoration: none; white-space: nowrap;
  font-size: .9rem; padding: 7px 10px; border-radius: 999px;
}
.topnav a:hover, .topnav .linklike:hover { color: var(--paper); background: rgba(255,255,255,.07); }
.topnav .nav-cta { background: var(--gold); color: #2a2216; font-weight: 600; }
.topnav .nav-cta:hover { background: #e2c785; color: #2a2216; }
.inline { display: inline; margin: 0; }
.linklike { background: none; border: 0; cursor: pointer; }

.show-sm { display: none; }
@media (max-width: 760px) {
  .brand span, .hide-sm { display: none; }
  .show-sm { display: inline; }
  .topnav a[title="Mein Konto"] { display: none; }
}

/* ---------- Hinweise ---------- */
.flash {
  position: fixed; top: calc(var(--topbar-h) + 12px); left: 50%; z-index: 60;
  transform: translateX(-50%);
  max-width: min(92vw, 520px);
  padding: 10px 18px; border-radius: 10px;
  background: var(--paper); color: var(--ink);
  box-shadow: 0 10px 30px rgba(0,0,0,.35);
  font-size: .95rem;
  animation: flash 5s ease forwards;
}
.flash-error { background: #f6ddd5; color: #6b2015; }
@keyframes flash { 0% { opacity: 0; transform: translate(-50%, -8px); } 6%, 85% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; visibility: hidden; } }

/* =====================================================================
   Das Buch
   ===================================================================== */
.desk {
  min-height: calc(100svh - var(--topbar-h));
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; padding: 18px 12px 22px;
  overflow: hidden;
}
.book {
  --ratio: 1.44;
  --h: min(calc(100svh - var(--topbar-h) - 110px), 780px, calc((100vw - 120px) / var(--ratio)));
  position: relative;
  height: var(--h);
  width: calc(var(--h) * var(--ratio));
  font-size: calc(var(--h) / 34);
  perspective: calc(var(--h) * 3.5);
  transition: transform 1s cubic-bezier(.55, .05, .25, 1);
  user-select: none; -webkit-user-select: none;
}
.book.single {
  --ratio: .72;
  --h: min(calc(100svh - var(--topbar-h) - 100px), calc((100vw - 28px) / var(--ratio)));
  font-size: calc(var(--h) / 30);
}

/* Einbanddeckel, der hinter den Seiten hervorschaut */
.spreads { position: absolute; inset: 0; perspective: calc(var(--h) * 3.5); }
.spreads::before {
  content: ""; position: absolute; inset: -1.6% -1.4% -2.2%; z-index: -1;
  border-radius: 6px;
  background-color: var(--linen-dark);
  background-image: repeating-linear-gradient(0deg, rgba(255,255,255,.04) 0 1px, transparent 1px 3px), repeating-linear-gradient(90deg, rgba(0,0,0,.08) 0 1px, transparent 1px 3px), linear-gradient(140deg, var(--linen), var(--linen-dark));
  box-shadow: 0 24px 60px rgba(0,0,0,.55), 0 4px 10px rgba(0,0,0,.4);
}
.spreads::after { /* Papierkanten unten */
  content: ""; position: absolute; left: .4%; right: .4%; bottom: -.9%; height: 1%; z-index: -1;
  background: repeating-linear-gradient(180deg, #e9dec4 0 1px, #cdbf9f 1px 2px);
  border-radius: 0 0 3px 3px;
}
.book.is-closed .spreads { visibility: hidden; }
.book.is-closed { transform: translateX(-25%); }
.book.single.is-closed { transform: none; }

.spread { position: absolute; inset: 0; display: none; }
.spread.is-current, .spread.stage { display: flex; }

.page {
  position: relative;
  width: 50%; height: 100%;
  overflow: hidden;
  background-color: var(--paper);
  background-image: var(--paper-noise);
}
.page.left {
  border-radius: 4px 0 0 4px;
  background-image:
    linear-gradient(90deg, rgba(120, 95, 50, .10), transparent 6%, transparent 84%, rgba(90, 65, 30, .12) 93%, rgba(60, 40, 15, .32)),
    var(--paper-noise);
}
.page.right {
  border-radius: 0 4px 4px 0;
  background-image:
    linear-gradient(270deg, rgba(120, 95, 50, .10), transparent 6%, transparent 84%, rgba(90, 65, 30, .12) 93%, rgba(60, 40, 15, .30)),
    var(--paper-noise);
}
.page.endpaper { background-image:
    linear-gradient(90deg, transparent 85%, rgba(0,0,0,.35)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='40'%3E%3Cpath d='M4 32 L16 16 L22 23 L30 10 L44 32' fill='none' stroke='%23d6b871' stroke-opacity='.22' stroke-width='1.2' stroke-linejoin='round'/%3E%3C/svg%3E"),
    var(--noise), linear-gradient(160deg, #36533f, #243a2c);
  background-size: 100% 100%, 56px 40px, 180px 180px, 100% 100%;
  background-blend-mode: normal;
}
.single .page { width: 100%; border-radius: 3px 6px 6px 3px; }
.single .spread:not(.show-right) .page.right,
.single .spread.show-right .page.left { display: none; }

.page-inner {
  position: absolute; inset: 7% 10% 9% 9%;
  display: flex; flex-direction: column;
}
.page.right .page-inner { inset: 7% 9% 9% 10%; }
.folio {
  position: absolute; bottom: 3.4%; left: 0; right: 0;
  text-align: center; font-family: var(--serif); font-size: .7em; color: var(--ink-soft); letter-spacing: .08em;
}

/* ---------- Eintrag (linke Seite) ---------- */
.entry-head { margin-bottom: .5em; }
.entry-when {
  margin: 0; font-family: var(--serif); font-style: italic; font-size: .82em;
  color: var(--ink-soft); letter-spacing: .04em;
}
.entry-title {
  margin: .1em 0 0; font-family: var(--serif); font-weight: 600; font-size: 1.55em; line-height: 1.1;
  color: var(--ink);
}
.entry-body {
  flex: 1; min-height: 0;
  overflow-y: auto; overscroll-behavior: contain;
  white-space: pre-line; word-wrap: break-word;
  font-size: 1.22em; color: #2a3140;
  padding-right: .3em;
  scrollbar-width: thin; scrollbar-color: rgba(0,0,0,.18) transparent;
}
.entry-foot { display: flex; align-items: flex-end; justify-content: space-between; gap: 1em; margin-top: .4em; }
.signature {
  order: 2; margin: 0 0 0 auto; font-size: 1.35em; font-weight: 600; color: var(--ink-green);
  transform: rotate(-2deg);
}
.signature::before { content: "– "; }
.entry-tools { order: 1; font-family: var(--sans); font-size: .6em; }
.entry-tools a {
  color: var(--ink-soft); text-decoration: none; border: 1px solid rgba(0,0,0,.15);
  padding: .3em .8em; border-radius: 99px; background: rgba(255,255,255,.4);
}
.entry-tools a:hover { color: var(--ink); border-color: rgba(0,0,0,.35); }

/* ---------- Fotos (rechte Seite) ---------- */
.photos { display: grid; gap: 4%; align-items: center; justify-items: center; }
.photos.n0 { display: flex; align-items: center; justify-content: center; }
.photos.n1 { grid-template-rows: 1fr; }
.photos.n2 { grid-template-rows: 1fr 1fr; }
.photos.n3 { grid-template-columns: 1fr 1fr; grid-template-rows: 1.15fr 1fr; }
.photos.n4 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; gap: 5% 6%; }

.polaroid {
  position: relative; margin: 0;
  padding: 4.5% 4.5% 12%;
  background: #fdfbf5;
  box-shadow: 0 .15em .4em rgba(0,0,0,.18), 0 .6em 1.2em rgba(60,40,15,.16);
  transform: rotate(var(--r, 0deg));
}
.polaroid::before { /* Klebestreifen */
  content: ""; position: absolute; top: -.55em; left: 50%; width: 32%; height: 1.1em;
  transform: translateX(-50%) rotate(calc(var(--r, 0deg) * -1.8));
  background: rgba(236, 226, 196, .72);
  box-shadow: 0 1px 2px rgba(0,0,0,.08);
}
.photo-open { display: block; width: 100%; padding: 0; border: 0; background: #ddd2bb; cursor: zoom-in; }
.polaroid img { width: 100%; height: 100%; object-fit: cover; aspect-ratio: 4 / 3; background: #e6dcc6; }
.photos.n1 .polaroid { width: 92%; }
.photos.n1 .polaroid.tall { width: 74%; }
.photos.n1 .polaroid img { aspect-ratio: auto; max-height: calc(var(--h) * .58); }
.photos.n2 .polaroid { width: 80%; }
.photos.n2 .polaroid:nth-child(1) { justify-self: start; }
.photos.n2 .polaroid:nth-child(2) { justify-self: end; }
.photos.n3 .polaroid:nth-child(1) { grid-column: 1 / 3; width: 78%; }
.photos.n3 .polaroid:nth-child(n+2) { width: 96%; }
.photos.n3 .polaroid:nth-child(n+2) img, .photos.n4 .polaroid img { aspect-ratio: 1; }
.photos.n4 .polaroid { width: 100%; }
.more-photos {
  position: absolute; right: -6%; bottom: -4%;
  width: auto; padding: .25em .7em;
  background: var(--red); color: var(--paper);
  font-family: var(--hand); font-size: 1.05em; font-weight: 600;
  border-radius: 3px; transform: rotate(-6deg);
  box-shadow: 0 .2em .5em rgba(0,0,0,.25); cursor: pointer;
}
.no-photos { width: 72%; color: var(--ink-soft); opacity: .45; }

/* ---------- Titelseiten ---------- */
.title-page { align-items: center; justify-content: center; text-align: center; gap: .3em; }
.title-page h2 { font-family: var(--serif); font-weight: 500; font-size: 2.6em; margin: .1em 0 0; letter-spacing: .02em; }
.title-house { font-family: var(--serif); font-style: italic; font-size: 1.2em; margin: 0; color: var(--ink-soft); }
.rule { width: 30%; height: 1px; background: var(--ink-soft); opacity: .4; margin: .8em 0; }
.welcome { font-size: 1.2em; line-height: 1.35; max-width: 92%; margin: .2em 0 .6em; color: #2a3140; }
p.welcome:not(.hand) { font-family: var(--serif); font-style: italic; }
.title-count { font-family: var(--serif); font-variant: small-caps; letter-spacing: .1em; color: var(--ink-soft); margin: 0 0 .9em; font-size: .9em; }
.emblem { width: 5em; color: var(--ink-green); }
.emblem.ink { opacity: .85; }
.title-page .btn { font-size: .7em; }

.exlibris {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 52%; padding: 7% 6%;
  display: flex; flex-direction: column; align-items: center; gap: .3em;
  background: var(--paper); color: var(--ink-green);
  border: 1px solid rgba(47,74,58,.4); outline: 3px double rgba(47,74,58,.35); outline-offset: -9px;
  box-shadow: 0 .3em 1em rgba(0,0,0,.35);
  text-align: center;
}
.exlibris span { font-family: var(--serif); font-variant: small-caps; letter-spacing: .2em; font-size: .8em; }
.exlibris strong { font-family: var(--serif); font-size: 1.05em; font-weight: 600; line-height: 1.2; }
.exlibris .emblem { width: 4em; }

.blank-page { justify-content: center; }
.blank-note { color: var(--ink-soft); font-size: 1.3em; text-align: center; transform: rotate(-2deg); }

/* ---------- Einband ---------- */
.cover {
  position: absolute; top: 0; left: 50%; width: 50%; height: 100%; z-index: 20;
  transform-origin: left center;
  transform-style: preserve-3d;
  transition: transform 1.15s cubic-bezier(.5, .05, .2, 1), opacity .5s;
}
.single .cover { left: 0; width: 100%; }
.cover-front, .cover-back {
  position: absolute; inset: -1.6% -2.8% -2.2% 0;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  border-radius: 3px 8px 8px 3px;
}
.cover-front {
  cursor: pointer; outline: none;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.05), inset -.3em 0 .6em rgba(0,0,0,.25), 0 24px 60px rgba(0,0,0,.6), 0 4px 10px rgba(0,0,0,.4);
}
.cover-front:focus-visible { box-shadow: 0 0 0 2px rgba(214,184,113,.5), 0 24px 60px rgba(0,0,0,.6); }
.cover-back { transform: rotateY(180deg); border-radius: 8px 3px 3px 8px; inset: -1.6% 0 -2.2% -2.8%; }
.book.is-open .cover { transform: rotateY(-180deg); }
.book.single.is-open .cover { transform: rotateY(-110deg); opacity: 0; }
.book.cover-done .cover { display: none; }
.book.is-opening .spread.is-current .page.left { visibility: hidden; }

.cover-frame {
  position: absolute; inset: 6% 7% 6% 11%;
  border: 1px solid var(--gold-soft);
  outline: 1px solid rgba(214,184,113,.25); outline-offset: 5px;
  pointer-events: none;
}
.cover-title {
  position: absolute; left: 11%; right: 7%; top: 18%;
  display: flex; flex-direction: column; align-items: center; text-align: center;
}
.cover-title .emblem { width: 34%; max-width: 9em; color: var(--gold); filter: drop-shadow(0 1px 0 rgba(0,0,0,.5)); }
.cover-title h1 {
  margin: .25em 0 0; font-family: var(--serif); font-weight: 500;
  font-size: 2.9em; letter-spacing: .06em; line-height: 1;
}
.cover-sub { margin: .5em 0 0; font-family: var(--serif); font-style: italic; font-size: 1.15em; }
.cover-year { margin: 1.4em 0 0; font-family: var(--serif); font-variant: small-caps; letter-spacing: .25em; font-size: .8em; opacity: .85; }
.cover-hint {
  position: absolute; bottom: 9%; left: 11%; right: 7%; text-align: center;
  font-family: var(--serif); font-style: italic; font-size: .8em; color: rgba(248,242,228,.62);
  animation: breathe 2.8s ease-in-out infinite;
}
@keyframes breathe { 50% { opacity: .35; } }

/* ---------- Blätter-Animation ---------- */
.leaf {
  position: absolute; top: 0; width: 50%; height: 100%; z-index: 15;
  transform-style: preserve-3d;
  transition: transform var(--flip-ms, 800ms) cubic-bezier(.42, .03, .3, 1);
  pointer-events: none;
}
.leaf.fwd { left: 50%; transform-origin: left center; }
.leaf.bwd { left: 0; transform-origin: right center; }
.leaf.fwd.go { transform: rotateY(-180deg); }
.leaf.bwd.go { transform: rotateY(180deg); }
.leaf > .page {
  position: absolute; inset: 0; width: 100%; display: block !important;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
}
.leaf > .face-back { transform: rotateY(180deg); }
.leaf > .page::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(90deg, rgba(0,0,0,.0), rgba(0,0,0,.22));
  opacity: 0; animation: leafshade var(--flip-ms, 800ms) ease-in-out;
}
.leaf > .face-back::after { background: linear-gradient(270deg, rgba(0,0,0,0), rgba(0,0,0,.22)); }
@keyframes leafshade { 50% { opacity: 1; } }

.single .leaf { left: 0; width: 100%; transform-origin: left center; }
.single .leaf.fwd.go { transform: rotateY(-100deg); opacity: 0; transition: transform var(--flip-ms) ease-in, opacity var(--flip-ms) ease-in; }
.single .leaf.bwd { transform: rotateY(-100deg); opacity: 0; }
.single .leaf.bwd.go { transform: rotateY(0); opacity: 1; transition: transform var(--flip-ms) ease-out, opacity calc(var(--flip-ms) * .6) ease-out; }

/* ---------- Blätterknöpfe & Leiste ---------- */
.turn {
  position: absolute; top: 50%; z-index: 25;
  width: 46px; height: 46px; margin-top: -23px;
  display: grid; place-items: center;
  border: 1px solid rgba(214,184,113,.35); border-radius: 50%;
  background: rgba(20,17,13,.55); color: var(--gold);
  font-family: var(--serif); font-size: 30px; line-height: 1;
  cursor: pointer; transition: background .2s, opacity .2s;
}
.turn span { margin-top: -4px; }
.turn:hover { background: rgba(20,17,13,.85); }
.turn:disabled { opacity: 0; pointer-events: none; }
.turn-prev { left: -60px; }
.turn-next { right: -60px; }
.book.is-closed .turn { display: none; }
.single .turn { top: auto; bottom: -58px; margin: 0; width: 42px; height: 42px; }
.single .turn-prev { left: 0; }
.single .turn-next { right: 0; }

.book-bar {
  display: flex; align-items: center; gap: 6px;
  padding: 5px; border-radius: 999px;
  background: rgba(20,17,13,.6); border: 1px solid rgba(214,184,113,.18);
  color: var(--paper); font-size: .85rem;
  transition: opacity .4s;
}
.book.is-closed + .book-bar { opacity: 0; pointer-events: none; }
.bar-btn {
  border: 0; background: transparent; color: rgba(248,242,228,.85);
  padding: 6px 12px; border-radius: 999px; cursor: pointer; text-decoration: none; font-size: .85rem;
}
.bar-btn:hover { background: rgba(255,255,255,.08); color: var(--paper); }
.bar-pos { min-width: 8.5em; text-align: center; font-family: var(--serif); font-style: italic; font-size: .98rem; color: var(--gold); }
@media (max-width: 760px) {
  .book-bar { margin-top: 0; max-width: calc(100vw - 110px); }
  .bar-pos { min-width: 0; }
  #lastBtn { display: none; }
}

/* ---------- Inhaltsverzeichnis ---------- */
.toc {
  position: fixed; inset: 0; z-index: 70;
  background: rgba(10,8,6,.55);
  display: flex; justify-content: flex-end;
  animation: fadein .2s ease;
}
.toc-sheet {
  width: min(440px, 100vw); height: 100%;
  background: var(--paper); background-image: var(--paper-noise);
  display: flex; flex-direction: column;
  box-shadow: -10px 0 40px rgba(0,0,0,.4);
  animation: slidein .28s cubic-bezier(.3,.1,.2,1);
}
.toc-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px 6px; }
.toc-head h2 { margin: 0; font-family: var(--serif); font-weight: 500; font-size: 2rem; }
.close { border: 0; background: none; font-size: 2rem; line-height: 1; cursor: pointer; color: var(--ink-soft); padding: 4px 8px; }
.toc-search { padding: 6px 22px 12px; }
.toc-search input { width: 100%; }
.toc-list { list-style: none; margin: 0; padding: 0 10px 30px; overflow-y: auto; }
.toc-list a {
  display: grid; gap: 1px; padding: 10px 12px; border-radius: 8px;
  text-decoration: none; color: var(--ink);
  border-bottom: 1px dotted rgba(0,0,0,.15);
}
.toc-list a:hover, .toc-list a:focus-visible { background: rgba(47,74,58,.08); }
.toc-when { font-family: var(--serif); font-style: italic; color: var(--ink-soft); font-size: .95rem; }
.toc-title { font-family: var(--serif); font-weight: 600; font-size: 1.2rem; }
.toc-author { font-size: .82rem; color: var(--ink-soft); }
.toc-empty { padding: 14px; color: var(--ink-soft); }
@keyframes fadein { from { opacity: 0; } }
@keyframes slidein { from { transform: translateX(40px); opacity: 0; } }

/* ---------- Fotoansicht ---------- */
.lightbox {
  position: fixed; inset: 0; z-index: 80;
  display: grid; place-items: center;
  background: rgba(8,6,4,.94);
  animation: fadein .2s ease;
}
.lightbox img {
  max-width: 94vw; max-height: 86svh;
  border: 8px solid #fdfbf5; border-bottom-width: 26px;
  box-shadow: 0 20px 60px rgba(0,0,0,.6);
  background: #222;
}
.lb-close, .lb-prev, .lb-next {
  position: absolute; border: 0; background: rgba(255,255,255,.08); color: var(--paper);
  width: 48px; height: 48px; border-radius: 50%; font-size: 28px; cursor: pointer; line-height: 1;
}
.lb-close { top: 14px; right: 14px; }
.lb-prev { left: 14px; top: 50%; margin-top: -24px; }
.lb-next { right: 14px; top: 50%; margin-top: -24px; }
.lb-close:hover, .lb-prev:hover, .lb-next:hover { background: rgba(255,255,255,.18); }
.lb-count { position: absolute; bottom: 10px; left: 0; right: 0; text-align: center; color: rgba(248,242,228,.7); font-family: var(--serif); font-style: italic; margin: 0; }

/* =====================================================================
   Login- & Einladungsseite
   ===================================================================== */
.cover-stage {
  min-height: 100svh; display: flex; align-items: center; justify-content: center; padding: 20px 14px;
}
.cover-solo {
  position: relative;
  width: min(460px, 100%);
  min-height: min(680px, calc(100svh - 40px));
  padding: 230px 30px 34px 48px;
  border-radius: 3px 10px 10px 3px;
  box-shadow: 0 30px 70px rgba(0,0,0,.6), 0 4px 10px rgba(0,0,0,.4), inset -.3em 0 .8em rgba(0,0,0,.25);
  display: flex; flex-direction: column; justify-content: flex-end;
  font-size: 16px;
}
.cover-solo .cover-title { top: 9%; }
.cover-solo .cover-title h1 { font-size: 2.6rem; }
.cover-solo .cover-title .emblem { width: 26%; }
.bookplate {
  position: relative; z-index: 2;
  display: flex; flex-direction: column; gap: 12px;
  width: 100%;
  margin-top: 30px;
  padding: 22px 22px 18px;
  background: var(--paper); background-image: var(--paper-noise);
  border-radius: 2px;
  box-shadow: 0 2px 0 rgba(0,0,0,.15), 0 10px 26px rgba(0,0,0,.4);
  outline: 1px solid rgba(47,74,58,.35); outline-offset: -7px;
}
.plate-label { margin: 0; text-align: center; font-family: var(--serif); font-size: 1.45rem; font-weight: 600; color: var(--ink-green); }
.plate-hint { margin: 0; font-size: .85rem; color: var(--ink-soft); text-align: center; line-height: 1.4; }

/* =====================================================================
   Papierseiten (Formulare, Suche, Verwaltung)
   ===================================================================== */
.page-paper main { padding: clamp(14px, 4vw, 40px) 12px 60px; }
.sheet {
  max-width: 780px; margin: 0 auto;
  padding: clamp(22px, 5vw, 52px);
  background: var(--paper); background-image: var(--paper-noise);
  border-radius: 4px;
  box-shadow: 0 1px 0 var(--paper-edge), 0 2px 0 #cbbd9d, 0 3px 0 var(--paper-edge), 0 20px 50px rgba(0,0,0,.5);
}
.sheet-narrow { max-width: 520px; }
.sheet-wide { max-width: 940px; }
.center { text-align: center; }
.sheet h1 { font-family: var(--serif); font-weight: 600; font-size: clamp(1.9rem, 5vw, 2.6rem); line-height: 1.1; margin: .1em 0 .4em; }
.sheet h2 { font-family: var(--serif); font-weight: 600; font-size: 1.5rem; margin: 1.8em 0 .5em; padding-bottom: .2em; border-bottom: 1px solid rgba(0,0,0,.1); }
.eyebrow { margin: 0; font-family: var(--serif); font-variant: small-caps; letter-spacing: .14em; color: var(--ink-soft); font-size: 1.05rem; }
.muted { color: var(--ink-soft); }
.small { font-size: .88rem; }
.note { background: rgba(214,184,113,.2); padding: 10px 14px; border-radius: 6px; }

label { display: flex; flex-direction: column; gap: 6px; font-size: .92rem; font-weight: 600; color: var(--ink); }
label small { font-weight: 400; color: var(--ink-soft); }
input[type=text], input:not([type]), input[type=password], input[type=search], input[type=date], textarea {
  font: inherit; font-weight: 400; color: var(--ink);
  width: 100%; padding: 10px 12px;
  background: rgba(255,255,255,.55);
  border: 1px solid rgba(60,45,25,.25); border-radius: 6px;
  outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus { border-color: var(--ink-green); box-shadow: 0 0 0 3px rgba(47,74,58,.15); }
textarea.hand { font-family: var(--hand); font-size: 1.45rem; color: #2a3140; resize: vertical; padding: 0 12px; min-height: 12em; }
fieldset { border: 0; padding: 0; margin: 0; }
legend { font-size: .92rem; font-weight: 600; padding: 0; margin-bottom: 6px; }
legend small { font-weight: 400; color: var(--ink-soft); }
.form-error { margin: 0 0 12px; padding: 10px 14px; border-radius: 6px; background: #f6ddd5; color: #6b2015; font-size: .95rem; font-weight: 500; }
.bookplate .form-error { margin: 0; }
.stack { display: flex; flex-direction: column; gap: 14px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 20px; border-radius: 999px;
  font: 600 .95rem var(--sans); text-decoration: none; cursor: pointer;
  border: 1px solid transparent; transition: background .15s, transform .1s;
}
.btn:active { transform: translateY(1px); }
.btn-ink { background: var(--ink-green); color: var(--paper); }
.btn-ink:hover { background: #223a2c; }
.btn, .btn-ghost { background-color: transparent; border-color: rgba(47,74,58,.35); color: var(--ink-green); }
.btn.btn-ink { background: var(--ink-green); color: var(--paper); border-color: transparent; }
.btn-ghost:hover { background: rgba(47,74,58,.07); }
.btn-danger { background: transparent; color: var(--red); border-color: rgba(153,58,42,.4); }
.btn-danger:hover { background: rgba(153,58,42,.08); }

/* Eintragsformular */
.entry-form { display: flex; flex-direction: column; gap: 22px; margin-top: 18px; }
.dates { display: flex; flex-wrap: wrap; gap: 12px; }
.dates legend { width: 100%; }
.dates label { flex: 1 1 180px; flex-direction: row; align-items: center; font-weight: 400; }
.dropzone {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  padding: 26px 16px; border: 2px dashed rgba(47,74,58,.35); border-radius: 10px;
  background: rgba(255,255,255,.35); cursor: pointer; text-align: center; transition: background .15s, border-color .15s;
}
.dropzone:hover, .dropzone.over { background: rgba(47,74,58,.07); border-color: var(--ink-green); }
.dropzone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dz-main { font-family: var(--serif); font-size: 1.35rem; color: var(--ink-green); }
.dz-sub { font-weight: 400; font-size: .85rem; color: var(--ink-soft); }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; margin: 10px 0; }
.thumbs:empty { display: none; }
.thumb { position: relative; display: block; aspect-ratio: 1; border-radius: 6px; overflow: hidden; background: #e6dcc6; cursor: pointer; box-shadow: 0 2px 6px rgba(0,0,0,.15); }
.thumb img { width: 100%; height: 100%; object-fit: cover; transition: opacity .15s, filter .15s; }
.thumb input { position: absolute; opacity: 0; }
.thumb-x { position: absolute; inset: auto 0 0; padding: 3px; font-size: .72rem; font-weight: 600; text-align: center; background: rgba(0,0,0,.45); color: #fff; }
.thumb input:checked ~ img { opacity: .3; filter: grayscale(1); }
.thumb input:checked ~ .thumb-x { background: var(--red); }
.thumb input:checked ~ .thumb-x::before { content: "✕ "; }
.thumb button.thumb-x { border: 0; cursor: pointer; width: 100%; }
.progress { position: relative; height: 28px; border-radius: 99px; background: rgba(47,74,58,.12); overflow: hidden; }
.progress-bar { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--ink-green); transition: width .2s; }
.progress span { position: relative; display: block; text-align: center; line-height: 28px; font-size: .85rem; font-weight: 600; color: var(--ink); mix-blend-mode: difference; filter: invert(1); }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.danger-zone { margin-top: 34px; padding-top: 18px; border-top: 1px solid rgba(0,0,0,.1); }

/* Suche */
.search-form { display: flex; gap: 10px; margin: 12px 0 8px; }
.search-form input { font-size: 1.1rem; }
.result-count { color: var(--ink-soft); font-family: var(--serif); font-style: italic; font-size: 1.1rem; }
.results { list-style: none; margin: 0; padding: 0; }
.result a {
  display: grid; gap: 4px; padding: 16px 12px; margin: 0 -12px;
  border-bottom: 1px dotted rgba(0,0,0,.18); text-decoration: none; color: var(--ink); border-radius: 8px;
}
.result a:hover { background: rgba(47,74,58,.06); }
.result-when { font-family: var(--serif); font-style: italic; color: var(--ink-soft); }
.result-title { font-family: var(--serif); font-weight: 600; font-size: 1.35rem; }
.result-snip { font-size: 1.3rem; line-height: 1.25; color: #2a3140; }
.result-snip mark { background: linear-gradient(transparent 45%, rgba(214,184,113,.6) 45%, rgba(214,184,113,.6) 90%, transparent 90%); color: inherit; }
.result-thumbs { display: flex; gap: 6px; align-items: center; margin-top: 4px; }
.result-thumbs img { width: 54px; height: 54px; object-fit: cover; border: 3px solid #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.result-thumbs em { color: var(--ink-soft); font-size: .9rem; }

/* Verwaltung */
.linkbox { margin: 18px 0; padding: 16px 18px; border-radius: 10px; background: rgba(214,184,113,.22); border: 1px solid rgba(214,184,113,.6); }
.linkbox p { margin: 0 0 8px; }
.linkrow { display: flex; gap: 8px; flex-wrap: wrap; }
.linkrow input { flex: 1 1 260px; font-family: ui-monospace, monospace; font-size: .85rem; }
.create-user { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: end; }
.create-user .check { flex-direction: row; align-items: center; font-weight: 400; }
.create-user .btn { justify-self: end; }
@media (max-width: 600px) { .create-user { grid-template-columns: 1fr; } .create-user .btn { justify-self: stretch; } }
.userlist { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.usercard {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 14px 16px; border-radius: 10px; background: rgba(255,255,255,.45); border: 1px solid rgba(0,0,0,.08);
}
.usercard.is-off { opacity: .6; }
.user-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.user-main strong { font-family: var(--serif); font-size: 1.25rem; }
.badge { align-self: flex-start; margin-top: 3px; font-size: .74rem; font-weight: 600; padding: 2px 9px; border-radius: 99px; }
.badge-ok { background: rgba(47,74,58,.13); color: var(--ink-green); }
.badge-pending { background: rgba(214,184,113,.35); color: #6a5013; }
.badge-warn { background: #f6ddd5; color: #6b2015; }
.badge-off { background: rgba(0,0,0,.08); color: var(--ink-soft); }
.user-actions { position: relative; flex: none; }
.user-actions summary { cursor: pointer; list-style: none; font-size: .88rem; font-weight: 600; color: var(--ink-green); padding: 6px 12px; border-radius: 99px; border: 1px solid rgba(47,74,58,.3); }
.user-actions summary::-webkit-details-marker { display: none; }
.user-actions[open] summary { background: rgba(47,74,58,.08); }
.menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 5;
  width: min(300px, 80vw); padding: 8px;
  background: var(--paper); border-radius: 10px; box-shadow: 0 12px 34px rgba(0,0,0,.28);
  display: flex; flex-direction: column; gap: 2px;
}
.menu form { display: flex; flex-direction: column; gap: 2px; margin: 0; }
.menu button { text-align: left; border: 0; background: none; padding: 9px 10px; border-radius: 6px; cursor: pointer; font-size: .9rem; }
.menu button:hover { background: rgba(47,74,58,.08); }
.menu button.danger { color: var(--red); }
.menu .rename { flex-direction: row; gap: 6px; padding: 4px 4px 6px; border-bottom: 1px solid rgba(0,0,0,.08); margin-bottom: 4px; }
.menu .rename input { padding: 6px 8px; font-size: .88rem; }
.menu .rename button { flex: none; background: rgba(47,74,58,.1); }

@media (prefers-reduced-motion: reduce) {
  .leaf, .cover, .book { transition-duration: 1ms !important; }
  .leaf > .page::after, .cover-hint { animation: none; }
}

/* =====================================================================
   Version 2: frei gestaltete Doppelseiten
   ===================================================================== */
@font-face { font-family: "Kalam"; src: url(fonts/kalam-latin-400-normal.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Homemade Apple"; src: url(fonts/homemade-apple-latin-400-normal.woff2) format("woff2"); font-weight: 400; font-display: swap; }

/* Jede Seite zeigt ihre Hälfte der gemeinsamen Ebene (so dürfen Elemente über den Bund laufen) */
.art { position: absolute; inset: 0; overflow: hidden; }
.art > .layer { position: absolute; top: 0; height: 100%; width: 200%; }
.art-l > .layer { left: 0; }
.art-r > .layer { left: -100%; }
.page.left::after, .page.right::after { /* Wölbung am Bund über den Inhalten */
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 5;
}
.spread-free .page.left::after { background: linear-gradient(90deg, transparent 88%, rgba(70, 48, 20, .10) 95%, rgba(50, 32, 10, .26)); }
.spread-free .page.right::after { background: linear-gradient(270deg, transparent 88%, rgba(70, 48, 20, .10) 95%, rgba(50, 32, 10, .24)); }

.layer { container-type: size; overflow: visible; }
.el { position: absolute; transform-origin: 50% 50%; }
.el-text {
  white-space: pre-wrap; overflow-wrap: break-word; line-height: 1.28;
  padding: 0 .1em;
}
.font-caveat { font-family: var(--hand); }
.font-kalam { font-family: "Kalam", var(--hand); line-height: 1.35; }
.font-apple { font-family: "Homemade Apple", var(--hand); line-height: 1.75; }
.font-serif { font-family: var(--serif); font-weight: 500; line-height: 1.15; }

.el-photo { background: #fdfbf5; box-shadow: 0 .12cqh .5cqh rgba(0,0,0,.2), 0 .8cqh 1.8cqh rgba(60,40,15,.16); }
.el-photo.frame-ohne, .el-photo.frame-ecken { background: transparent; }
.el-photo.frame-ecken { box-shadow: 0 .3cqh .9cqh rgba(60,40,15,.22); }
.el-photo.frame-rahmen { box-shadow: 0 .1cqh .4cqh rgba(0,0,0,.18), 0 .6cqh 1.2cqh rgba(60,40,15,.12); }
.ph-clip { position: absolute; overflow: hidden; background: #e6dcc6; }
.ph-clip img { position: absolute; max-width: none; user-select: none; -webkit-user-drag: none; }
.el-photo.is-missing .ph-clip { background: repeating-linear-gradient(45deg, #e6dcc6 0 8px, #ddd2b8 8px 16px); }
.el-photo .corner { position: absolute; width: 11%; aspect-ratio: 1; background: #2b2520; opacity: .9; }
.corner.tl { top: -2%; left: -2%; clip-path: polygon(0 0, 100% 0, 0 100%); }
.corner.tr { top: -2%; right: -2%; clip-path: polygon(0 0, 100% 0, 100% 100%); }
.corner.bl { bottom: -2%; left: -2%; clip-path: polygon(0 0, 100% 100%, 0 100%); }
.corner.br { bottom: -2%; right: -2%; clip-path: polygon(100% 0, 100% 100%, 0 100%); }

.el-sticker svg { width: 100%; height: 100%; overflow: visible; display: block; }
.el-sticker svg * { fill: none; stroke: currentColor; stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.el-sticker svg .f { fill: currentColor; }
.el-sticker svg .lf, .el-sticker svg .lf * { fill: currentColor; fill-opacity: .16; }
.layer .el-sticker svg * { stroke-width: max(1.5px, .35cqh); }

.el-tape {
  opacity: .82; mix-blend-mode: multiply;
  clip-path: polygon(0 6%, 3% 0, 6% 8%, 9% 0, 91% 0, 94% 7%, 97% 0, 100% 5%, 100% 94%, 97% 100%, 94% 92%, 91% 100%, 9% 100%, 6% 93%, 3% 100%, 0 95%);
  box-shadow: inset 0 0 0 100vmax rgba(255,255,255,.08);
}
.tape-honig { background: linear-gradient(180deg, rgba(255,255,255,.25), transparent 40%), #e6c46e; }
.tape-salbei { background: repeating-linear-gradient(45deg, rgba(255,255,255,.25) 0 6px, transparent 6px 14px), #a9c2a0; }
.tape-rose { background: radial-gradient(circle at 30% 50%, rgba(255,255,255,.4) 0 2px, transparent 3px) 0 0 / 14px 14px, #e6b3b0; }
.tape-himmel { background: repeating-linear-gradient(90deg, rgba(255,255,255,.3) 0 3px, transparent 3px 12px), #a9c6de; }
.tape-papier { background: var(--paper-noise), #ece2cb; opacity: .95; }
.tape-karo { background: repeating-linear-gradient(0deg, rgba(160,60,50,.35) 0 4px, transparent 4px 12px), repeating-linear-gradient(90deg, rgba(160,60,50,.35) 0 4px, transparent 4px 12px), #f1e7d6; }

.layer > .ink { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 100000; pointer-events: none; overflow: visible; }
.ink path { fill: none; stroke-linecap: round; stroke-linejoin: round; }

.spread-meta {
  position: absolute; left: 9%; right: 12%; bottom: 3%; z-index: 6;
  display: flex; align-items: center; gap: 1em;
  font-family: var(--serif); font-style: italic; font-size: .66em; color: var(--ink-soft);
}
.spread-meta span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spread-meta a {
  margin-left: auto; flex: none; font-family: var(--sans); font-style: normal; font-size: .9em;
  color: var(--ink-soft); text-decoration: none; border: 1px solid rgba(0,0,0,.15);
  padding: .25em .8em; border-radius: 99px; background: rgba(255,255,255,.5);
}
.spread-meta a:hover { color: var(--ink); border-color: rgba(0,0,0,.35); }
.spread-free .page.left .folio { display: none; }
.spread-free .el-photo { cursor: zoom-in; }

/* ---------- Editor ---------- */
.page-editor .topbar { display: none; }
.page-editor { overflow: hidden; }
.ed { position: fixed; inset: 0; display: flex; flex-direction: column; color: var(--paper); }
.ed-top {
  flex: none; display: flex; align-items: center; gap: 10px;
  padding: 8px clamp(10px, 2vw, 18px);
  background: rgba(18, 15, 12, .92); border-bottom: 1px solid rgba(214, 184, 113, .15);
}
.ed-heading { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.15; }
.ed-heading strong { font-family: var(--serif); font-weight: 500; font-size: 1.3rem; color: var(--gold); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ed-heading span { font-size: .78rem; color: rgba(248,242,228,.6); }
.ed-btn {
  flex: none; border: 1px solid rgba(214,184,113,.35); border-radius: 99px; padding: 8px 16px;
  background: transparent; color: var(--paper); font: 600 .9rem var(--sans); cursor: pointer; text-decoration: none;
}
.ed-btn:hover { background: rgba(255,255,255,.07); }
.ed-btn.primary { background: var(--gold); color: #2a2216; border-color: transparent; }
.ed-btn.primary:hover { background: #e2c785; }
.ed-btn:disabled { opacity: .5; cursor: progress; }

.ed-main { flex: 1; min-height: 0; display: flex; }
.ed-tools {
  flex: none; width: 78px; padding: 10px 8px; display: flex; flex-direction: column; gap: 4px;
  background: rgba(18,15,12,.7); border-right: 1px solid rgba(214,184,113,.12);
  overflow-y: auto;
}
.tool {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 8px 2px; border: 0; border-radius: 10px; background: transparent; cursor: pointer;
  color: rgba(248,242,228,.8); font-size: .72rem;
}
.tool svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linejoin: round; stroke-linecap: round; }
.tool:hover { background: rgba(255,255,255,.07); color: var(--paper); }
.tool.is-active { background: var(--gold); color: #2a2216; }
.tool:disabled { opacity: .3; cursor: default; background: transparent; }
.tool-sep { height: 1px; margin: 6px 4px; background: rgba(214,184,113,.2); }

.ed-wrap { position: relative; flex: 1; min-width: 0; overflow: hidden; }
.ed-stage { position: absolute; touch-action: none; user-select: none; -webkit-user-select: none; }
.ed-stage .page { position: absolute; top: 0; width: 50%; height: 100%; box-shadow: 0 20px 50px rgba(0,0,0,.5); }
.ed-stage .page.left { left: 0; }
.ed-stage .page.right { left: 50%; }
.ed-stage .page.left::after { background: linear-gradient(90deg, transparent 88%, rgba(70,48,20,.10) 95%, rgba(50,32,10,.26)); }
.ed-stage .page.right::after { background: linear-gradient(270deg, transparent 88%, rgba(70,48,20,.10) 95%, rgba(50,32,10,.24)); }
.ed-host { position: absolute; inset: 0; z-index: 2; }
.ed-host > .layer { position: absolute; inset: 0; }
.ed-stage .el { cursor: move; }
.ed-stage[data-mode="draw"], .ed-stage[data-mode="draw"] .el { cursor: crosshair; }
.ed-stage[data-mode="erase"], .ed-stage[data-mode="erase"] .el { cursor: cell; }
.ed-stage .el-text { min-height: 1.2em; min-width: 1em; outline: none; }
.ed-stage .el-text:empty::before { content: "Hier schreiben …"; opacity: .38; }
.ed-stage .el-text.is-editing { cursor: text; background: rgba(255,255,255,.35); box-shadow: 0 0 0 1px rgba(47,74,58,.25); user-select: text; -webkit-user-select: text; }
.ed-stage .el-text:not(.is-editing):hover, .ed-stage .el:not(.is-selected):hover { outline: 1px dashed rgba(47,74,58,.4); outline-offset: 2px; }
.ed-stage[data-mode="draw"] .el:hover, .ed-stage[data-mode="erase"] .el:hover { outline: none; }
.ed-stage .ink { pointer-events: none; }

.sel { position: absolute; z-index: 3; pointer-events: none; outline: 1.5px solid #3f7cd6; outline-offset: 3px; transform-origin: 50% 50%; }
.sel .h {
  position: absolute; width: 16px; height: 16px; margin: -8px 0 0 -8px; pointer-events: auto;
  background: #fff; border: 2px solid #3f7cd6; border-radius: 50%; touch-action: none;
}
.sel .h::after { content: ""; position: absolute; inset: -10px; } /* grössere Trefferfläche für Finger */
.h-nw { left: -3px; top: -3px; cursor: nwse-resize; } .h-ne { left: calc(100% + 3px); top: -3px; cursor: nesw-resize; }
.h-sw { left: -3px; top: calc(100% + 3px); cursor: nesw-resize; } .h-se { left: calc(100% + 3px); top: calc(100% + 3px); cursor: nwse-resize; }
.h-w { left: -3px; top: 50%; cursor: ew-resize; border-radius: 4px; height: 22px; margin-top: -11px; width: 10px; margin-left: -5px; }
.h-e { left: calc(100% + 3px); top: 50%; cursor: ew-resize; border-radius: 4px; height: 22px; margin-top: -11px; width: 10px; margin-left: -5px; }
.h-rot { left: 50%; top: -34px; cursor: grab; background: #3f7cd6; }
.h-rot::before { content: ""; position: absolute; left: 50%; top: 14px; width: 1.5px; height: 18px; background: #3f7cd6; transform: translateX(-50%); }
.sel:not([data-type="text"]):not([data-type="tape"]) .h-w, .sel:not([data-type="text"]):not([data-type="tape"]) .h-e { display: none; }
.sel.is-editing { outline-style: dashed; }
.sel.is-editing .h { display: none; }

.ed-meta-preview { pointer-events: none; z-index: 1; left: 4.5%; width: 41%; }
.ed-hint {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 1; margin: 0;
  pointer-events: none; text-align: center; color: rgba(60,45,25,.45);
  font-family: var(--serif); font-style: italic; font-size: clamp(1rem, 2.2vw, 1.6rem); line-height: 1.4;
}
.ed-stage[data-view="l"] .ed-hint { left: 25%; }
.ed-stage[data-view="r"] .ed-hint { left: 75%; }

.ed-props {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 20;
  max-width: calc(100% - 20px); display: flex; align-items: center; gap: 4px; padding: 5px;
  background: rgba(253, 250, 242, .97); color: var(--ink); border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,.4); overflow-x: auto; scrollbar-width: none;
}
.ed-props::-webkit-scrollbar { display: none; }
.pbtn {
  flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 7px 11px; border: 0; border-radius: 8px;
  background: transparent; font: 600 .84rem var(--sans); color: var(--ink); cursor: pointer; white-space: nowrap;
}
.pbtn:hover { background: rgba(47,74,58,.09); }
.pbtn.is-active { background: var(--ink-green); color: var(--paper); }
.pbtn-danger { color: var(--red); }
.pbtn-done { background: var(--gold); }
.psel { flex: none; font: 600 .84rem var(--sans); padding: 6px 8px; border-radius: 8px; border: 1px solid rgba(0,0,0,.15); background: #fff; color: var(--ink); }
.psep { flex: none; width: 1px; height: 22px; margin: 0 3px; background: rgba(0,0,0,.12); }
.swatches { flex: none; display: flex; gap: 4px; padding: 0 4px; }
.sw { width: 24px; height: 24px; border-radius: 50%; border: 2px solid rgba(0,0,0,.12); cursor: pointer; padding: 0; }
.sw.is-active { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--ink-green); }
.penw { display: inline-block; width: 18px; height: var(--w); max-height: 14px; min-height: 2px; border-radius: 99px; background: currentColor; }

.ed-pager {
  position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); z-index: 20;
  display: flex; gap: 2px; padding: 4px; border-radius: 99px;
  background: rgba(20,17,13,.75); border: 1px solid rgba(214,184,113,.2);
}
.ed-pager button { border: 0; background: transparent; color: rgba(248,242,228,.8); padding: 6px 12px; border-radius: 99px; font-size: .8rem; cursor: pointer; white-space: nowrap; }
.ed-pager button.is-active { background: rgba(214,184,113,.9); color: #2a2216; }

.ed-toast {
  position: fixed; left: 50%; bottom: 64px; transform: translateX(-50%); z-index: 60;
  max-width: min(92vw, 480px); padding: 10px 16px; border-radius: 10px;
  background: var(--paper); color: var(--ink); box-shadow: 0 10px 30px rgba(0,0,0,.4); font-size: .92rem;
}
.ed-toast.is-error { background: #f6ddd5; color: #6b2015; }

.ed-sheet { position: fixed; inset: 0; z-index: 50; background: rgba(10,8,6,.55); display: flex; align-items: center; justify-content: center; padding: 16px; }
.ed-sheet-card {
  width: min(560px, 100%); max-height: calc(100svh - 32px); overflow-y: auto;
  background: var(--paper); background-image: var(--paper-noise); color: var(--ink);
  border-radius: 14px; padding: 16px 20px 22px; box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.ed-sheet-head { display: flex; align-items: center; justify-content: space-between; }
.ed-sheet h2 { margin: 0; font-family: var(--serif); font-weight: 600; font-size: 1.7rem; }
.ed-sheet h3 { margin: 14px 0 8px; font-family: var(--serif); font-variant: small-caps; letter-spacing: .1em; font-weight: 500; color: var(--ink-soft); }
.deco-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.deco-item {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 10px 4px 8px; border: 1px solid rgba(0,0,0,.08); border-radius: 10px; background: rgba(255,255,255,.5);
  cursor: pointer; color: var(--ink-green); font-size: .74rem;
}
.deco-item:hover { background: #fff; border-color: rgba(47,74,58,.4); }
.deco-item svg { width: 46px; height: 46px; }
.deco-item svg * { stroke-width: 4; }
.deco-item span:last-child { color: var(--ink-soft); }
.tape-item .el-tape { position: static; display: block; width: 70px; height: 20px; transform: rotate(-6deg); margin: 12px 0 10px; }

.ed-dialog {
  width: min(520px, calc(100vw - 24px)); border: 0; border-radius: 14px; padding: 22px;
  background: var(--paper); background-image: var(--paper-noise); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.ed-dialog::backdrop { background: rgba(10,8,6,.6); }
.ed-dialog h2 { margin: 0; font-family: var(--serif); font-weight: 600; font-size: 1.6rem; }
.crop-dlg { width: min(880px, calc(100vw - 24px)); }
.crop-area { height: min(60vh, 560px); overflow: hidden; display: flex; align-items: center; justify-content: center; margin: 14px 0; background: #2a241e; border-radius: 8px; }
.crop-img { position: relative; touch-action: none; }
.crop-img img { display: block; width: 100%; height: 100%; user-select: none; -webkit-user-drag: none; }
.crop-box { position: absolute; box-shadow: 0 0 0 100vmax rgba(0,0,0,.55); outline: 2px solid #fff; cursor: move; }
.crop-box::before, .crop-box::after { content: ""; position: absolute; inset: 0; pointer-events: none; }
.crop-box::before { border-left: 1px solid rgba(255,255,255,.4); border-right: 1px solid rgba(255,255,255,.4); left: 33.3%; right: 33.3%; }
.crop-box::after { border-top: 1px solid rgba(255,255,255,.4); border-bottom: 1px solid rgba(255,255,255,.4); top: 33.3%; bottom: 33.3%; }
.ch { position: absolute; width: 18px; height: 18px; background: #fff; border-radius: 50%; margin: -9px; z-index: 1; }
.ch::after { content: ""; position: absolute; inset: -10px; }
.ch-nw { left: 0; top: 0; cursor: nwse-resize; } .ch-ne { left: 100%; top: 0; cursor: nesw-resize; }
.ch-sw { left: 0; top: 100%; cursor: nesw-resize; } .ch-se { left: 100%; top: 100%; cursor: nwse-resize; }
.crop-ratios { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.crop-ratios button { border: 1px solid rgba(47,74,58,.3); background: transparent; border-radius: 99px; padding: 6px 12px; cursor: pointer; font-size: .85rem; }
.crop-ratios button.is-active { background: var(--ink-green); color: var(--paper); border-color: transparent; }

@media (max-width: 760px) {
  .ed-main { flex-direction: column-reverse; }
  .ed-tools { width: auto; flex-direction: row; justify-content: space-around; padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid rgba(214,184,113,.12); overflow-x: auto; }
  .tool { padding: 6px 6px; min-width: 52px; font-size: .66rem; }
  .tool-sep { width: 1px; height: auto; margin: 6px 2px; }
  .ed-heading span { display: none; }
  .ed-heading strong { font-size: 1.1rem; }
  .ed-btn { padding: 7px 12px; font-size: .84rem; }
  #metaBtn { padding: 7px 10px; }
  .ed-toast { bottom: 84px; }
  .ed-pager button { padding: 6px 10px; }
  .ed-props { flex-wrap: wrap; justify-content: center; width: calc(100% - 16px); top: 8px; overflow: visible; }
  .pbtn { padding: 7px 9px; }
}
