:root {
  --ink: #2b2438;
  --ink-soft: #5c5470;
  --paper: #fffaf3;
  --primary: #e2557a;
  --primary-dark: #c93d61;
  --secondary: #f4ece1;
  --border: #e6ddd0;
  --shadow: 0 10px 30px rgba(43, 36, 56, 0.15);
  font-family: 'Quicksand', system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: #faf6ef;
  color: var(--ink);
  line-height: 1.5;
}

a { color: var(--primary-dark); }

.site-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--paper);
}
.brand {
  font-weight: 700;
  font-size: 1.25rem;
  text-decoration: none;
  color: var(--ink);
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}
main.main-wide {
  max-width: 1080px;
}

.site-footer {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--ink-soft);
  font-size: 0.85rem;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.7rem 1.4rem;
  border-radius: 999px;
  border: none;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--secondary); color: var(--ink); }
.btn-secondary:hover { background: var(--border); }
.btn-small { padding: 0.4rem 0.9rem; font-size: 0.85rem; }

/* Landing */
.hero { text-align: center; padding: 2rem 0 3rem; }
.hero h1 { font-size: 2.2rem; margin-bottom: 0.5rem; }
.hero p { color: var(--ink-soft); max-width: 42ch; margin: 0 auto 1.5rem; }
.how-it-works {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1.5rem;
  text-align: center;
}
.how-it-works h2 { font-size: 1rem; color: var(--primary-dark); }
.how-it-works p { color: var(--ink-soft); font-size: 0.9rem; }

/* Forms */
form { display: flex; flex-direction: column; gap: 0.4rem; }
label { font-weight: 700; margin-top: 0.6rem; font-size: 0.9rem; }
input[type="text"], input[type="email"], textarea, select {
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: inherit;
  font-size: 1rem;
  background: #fff;
}
form .btn { margin-top: 1.2rem; align-self: flex-start; }
.form-errors { color: var(--primary-dark); }

.backdrop-thumb {
  display: block;
  max-width: 220px;
  max-height: 140px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--border);
  margin-top: 0.4rem;
}
.checkbox-label {
  font-weight: 500;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.4rem;
}
.checkbox-label input { margin: 0; }

.link-box { margin: 0.75rem 0; }
.link-box input {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: monospace;
  font-size: 0.85rem;
  background: #fff;
}

/* Design picker */
.design-picker { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 0.5rem; }
.design-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  font-weight: 500;
  font-size: 0.8rem;
  cursor: pointer;
}
.design-option input { position: absolute; opacity: 0; }
.design-swatch {
  width: 64px;
  height: 64px;
  border-radius: 12px;
  border: 2px solid transparent;
  box-shadow: var(--shadow);
}
.design-option input:checked + .design-swatch { border-color: var(--primary); }

/* Card designs */
.design-confetti {
  background:
    radial-gradient(circle at 15% 20%, #ffd166 0 6px, transparent 7px),
    radial-gradient(circle at 70% 15%, #ef476f 0 5px, transparent 6px),
    radial-gradient(circle at 40% 60%, #06d6a0 0 5px, transparent 6px),
    radial-gradient(circle at 85% 70%, #118ab2 0 6px, transparent 7px),
    radial-gradient(circle at 25% 85%, #ffd166 0 4px, transparent 5px),
    linear-gradient(135deg, #fff3d6, #ffe1ec);
}
.design-balloons {
  background:
    radial-gradient(circle at 20% 30%, #a78bfa 0 26px, transparent 27px),
    radial-gradient(circle at 55% 15%, #60a5fa 0 22px, transparent 23px),
    radial-gradient(circle at 80% 45%, #f472b6 0 24px, transparent 25px),
    radial-gradient(circle at 35% 70%, #34d399 0 20px, transparent 21px),
    linear-gradient(160deg, #eef2ff, #ede9fe);
}
.design-elegant {
  background:
    repeating-linear-gradient(45deg, rgba(212,175,55,0.12) 0 2px, transparent 2px 22px),
    linear-gradient(160deg, #1f2440, #2b2f57);
  color: #fdf6e3;
}
.design-elegant .hero-title { color: #f1d888; }

/* Split variants for the two inside half-panels: the same recipe, sized to
   200% width so it reads as one continuous pattern across the fold, with
   background-position picking out each half's portion of that shared image. */
.design-confetti-left, .design-confetti-right {
  background-size: 200% 100%;
  background-image:
    radial-gradient(circle at 15% 20%, #ffd166 0 6px, transparent 7px),
    radial-gradient(circle at 70% 15%, #ef476f 0 5px, transparent 6px),
    radial-gradient(circle at 40% 60%, #06d6a0 0 5px, transparent 6px),
    radial-gradient(circle at 85% 70%, #118ab2 0 6px, transparent 7px),
    radial-gradient(circle at 25% 85%, #ffd166 0 4px, transparent 5px),
    linear-gradient(135deg, #fff3d6, #ffe1ec);
}
.design-confetti-left { background-position: left top; }
.design-confetti-right { background-position: right top; }

.design-balloons-left, .design-balloons-right {
  background-size: 200% 100%;
  background-image:
    radial-gradient(circle at 20% 30%, #a78bfa 0 26px, transparent 27px),
    radial-gradient(circle at 55% 15%, #60a5fa 0 22px, transparent 23px),
    radial-gradient(circle at 80% 45%, #f472b6 0 24px, transparent 25px),
    radial-gradient(circle at 35% 70%, #34d399 0 20px, transparent 21px),
    linear-gradient(160deg, #eef2ff, #ede9fe);
}
.design-balloons-left { background-position: left top; }
.design-balloons-right { background-position: right top; }

.design-elegant-left, .design-elegant-right {
  background-size: 200% 100%;
  background-image:
    repeating-linear-gradient(45deg, rgba(212,175,55,0.12) 0 2px, transparent 2px 22px),
    linear-gradient(160deg, #1f2440, #2b2f57);
  color: #fdf6e3;
}
.design-elegant-left { background-position: left top; }
.design-elegant-right { background-position: right top; }

/* Card 3D stage — one folded sheet, not a slideshow. There are exactly two
   physical half-panels sharing a hinge at the center (like a real folded
   card): the RIGHT panel's two faces (via backface-visibility) are FRONT and
   the right half of the INSIDE; the LEFT panel's two faces are BACK and the
   left half of the INSIDE. Opening the card rotates only the right panel
   around the shared hinge from 0deg (flat/open, its natural resting angle)
   to -180deg (folded back over the left panel, showing FRONT) — the interior
   is simply what you see at 0deg, not a separate object that fades in.
   Seeing the back is a distinct gesture: the whole closed stack (both panels,
   wherever the right panel's fold currently is) spins 180deg around its own
   center — a coin-flip of the closed card, independent of the fold. */
.card-3d-stage {
  perspective: 2400px;
  margin: 1.5rem auto 0.5rem;
}
.hinge-scene {
  position: relative;
  width: min(96vw, 1000px);
  aspect-ratio: 10 / 7;
  margin: 0 auto;
  transform-style: preserve-3d;
  transition: transform 0.5s ease;
}
.hinge-scene[data-state="front"],
.hinge-scene[data-state="back"] {
  /* Centers the 5:7 closed card within the wider 10:7 stage box. */
  transform: translateX(-25%);
}

.flip-wrapper {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform 0.6s ease;
}
.hinge-scene[data-state="back"] .flip-wrapper {
  transform: rotateY(180deg);
}

.left-panel {
  position: absolute;
  left: 0;
  top: 0;
  width: 50%;
  height: 100%;
  transform-style: preserve-3d;
}

.right-lift {
  position: absolute;
  left: 50%;
  top: 0;
  width: 50%;
  height: 100%;
  /* This forward nudge only matters while closed, to keep the folded-over
     cover nearer the camera than the left panel underneath it. Left active
     while open, it out-ranks the left panel at the same nominal depth and
     causes z-fighting right at the seam — so it's zeroed out below once open. */
  transform: translateZ(2px);
  transform-style: preserve-3d;
  transition: opacity 0.25s ease, transform 0.6s ease;
}
.hinge-scene[data-state="open"] .right-lift {
  transform: translateZ(0);
}
.hinge-scene[data-state="back"] .right-lift {
  /* Safety net: once flipped to the back, force the right panel out of the
     way rather than depend on nested-rotation depth-sorting alone. */
  opacity: 0;
  pointer-events: none;
}

.right-panel {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transform-origin: left center;
  transform: rotateY(-180deg);
  transition: transform 0.6s ease;
}
.hinge-scene[data-state="open"] .right-panel {
  transform: rotateY(0deg);
}

.face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.5rem;
  text-align: center;
}
/* Left-inside/right-inside together form one continuous open spread, so only
   their outer corners round; front/back are always shown alone, so they get
   the full standalone-card rounding. */
.face-left-inside { border-radius: 20px 0 0 20px; }
.face-right-inside { border-radius: 0 20px 20px 0; }
.face-front { border-radius: 20px; transform: rotateY(180deg); }
.face-back { border-radius: 20px; background: var(--secondary); transform: rotateY(180deg); }

.hero-title { font-size: 1.8rem; margin: 0; }
.back-logo { max-width: 55%; }

.card-controls {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 1rem;
}
.card-controls .ctrl-front,
.card-controls .ctrl-open,
.card-controls .ctrl-back {
  display: none;
}
.hinge-scene[data-state="front"] ~ .card-controls .btn.ctrl-front { display: inline-block; }
.hinge-scene[data-state="open"] ~ .card-controls .btn.ctrl-open { display: inline-block; }
.hinge-scene[data-state="open"] ~ .card-controls .locked-note.ctrl-open { display: block; }
.hinge-scene[data-state="back"] ~ .card-controls .btn.ctrl-back { display: inline-block; }
.locked-note { color: var(--ink-soft); font-size: 0.9rem; }

/* Signature blocks */
.signature-block {
  position: absolute;
  transform: translate(-50%, -50%);
  background: rgba(255,255,255,0.9);
  border-radius: 10px;
  padding: 0.5rem 0.7rem;
  box-shadow: 0 4px 10px rgba(0,0,0,0.12);
  max-width: 150px;
  text-align: center;
  font-size: 0.85rem;
}
.signature-block.dragging { cursor: grab; touch-action: none; user-select: none; }
.signature-name { font-size: 1.3rem; line-height: 1.1; }
.signature-message { font-size: 0.75rem; color: var(--ink-soft); margin-top: 0.2rem; }
.signature-gif { max-width: 100%; border-radius: 6px; margin-top: 0.3rem; }

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(43,36,56,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 50;
}
.modal[hidden] { display: none; }
.modal-content {
  background: #fff;
  border-radius: 16px;
  padding: 1.5rem;
  max-width: 480px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}
.modal-close {
  position: absolute;
  top: 0.75rem;
  right: 0.9rem;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--ink-soft);
}
.sign-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 10 / 7;
  border-radius: 12px;
  overflow: hidden;
  margin: 0.5rem 0;
}
.drag-hint { font-size: 0.8rem; color: var(--ink-soft); margin: 0 0 0.5rem; }

.honeypot { position: absolute; left: -9999px; }

/* Toast */
.toast {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  background: #eafaf1;
  color: #1b7a4b;
  text-align: center;
}
.toast-error { background: #fdecec; color: var(--primary-dark); }

/* Admin */
.admin-page section { margin-top: 2rem; }
.admin-sig-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.9rem 1rem;
  margin-bottom: 0.75rem;
  background: #fff;
}
.admin-sig-actions { display: flex; gap: 0.5rem; margin-top: 0.6rem; }
.lock-form { margin-top: 1rem; }
