:root {
  --bg-top: #fffaf2;
  --bg-cream: #faf4eb;
  --bg-warm: #f2e6d5;
  --ink-dark: #2c211d;
  --ink-muted: #6d5a52;
  --rose-accent: #c75d65;
  --rose-soft: #f2c4c7;
  --sage: #5b7553;
  --gold: #c99a45;
  --envelope-base: #e7d5bc;
  --envelope-shade: #d8c0a0;
  --envelope-flap: #eddcc4;
  --envelope-inner: #cbb190;
  --envelope-text: #2c211d;
  --envelope-label: #6d5a52;
  --wax-light: #c84044;
  --wax-red: #9c2b2e;
  --wax-dark: #641619;
  --paper: #fffdf8;
  --shadow-soft: 0 22px 60px rgba(56, 36, 25, 0.14);
}

/* Background Theme Variants */
body[data-theme="blush"] {
  --bg-top: #fff7f8;
  --bg-cream: #fceef0;
  --bg-warm: #f5dbe0;
  --rose-accent: #b84a5e;
}

body[data-theme="sage"] {
  --bg-top: #f7faf6;
  --bg-cream: #edf3ea;
  --bg-warm: #dde7d9;
  --rose-accent: #4c6d4a;
}

body[data-theme="midnight"] {
  --bg-top: #1a2130;
  --bg-cream: #131824;
  --bg-warm: #0d1018;
  --ink-dark: #f4ece0;
  --ink-muted: #b7ab9e;
  --rose-accent: #e09f67;
}

/* Envelope Color Variants */
body[data-env="ivory"] {
  --envelope-base: #f5efe4;
  --envelope-shade: #e8dfd0;
  --envelope-flap: #fbf6ee;
  --envelope-inner: #ddd0be;
  --envelope-text: #2c211d;
  --envelope-label: #6d5a52;
}

body[data-env="rose"] {
  --envelope-base: #ebd1d3;
  --envelope-shade: #dcb8bc;
  --envelope-flap: #f3dcde;
  --envelope-inner: #cfa6aa;
  --envelope-text: #3a2024;
  --envelope-label: #6d474d;
}

body[data-env="sage"] {
  --envelope-base: #d5dfd0;
  --envelope-shade: #c1cfb9;
  --envelope-flap: #e1e9dc;
  --envelope-inner: #aebfa5;
  --envelope-text: #233021;
  --envelope-label: #4f614c;
}

body[data-env="navy"] {
  --envelope-base: #2d3648;
  --envelope-shade: #222938;
  --envelope-flap: #364156;
  --envelope-inner: #1b202d;
  --envelope-text: #f7efe2;
  --envelope-label: #c4baa9;
}

/* Wax Seal Color Variants */
body[data-seal="gold"] {
  --wax-light: #e7be6a;
  --wax-red: #c4943a;
  --wax-dark: #855e18;
}

body[data-seal="plum"] {
  --wax-light: #97507d;
  --wax-red: #6d3659;
  --wax-dark: #431c35;
}

body[data-seal="forest"] {
  --wax-light: #558467;
  --wax-red: #375b45;
  --wax-dark: #1d3828;
}

body[data-seal="blush"] {
  --wax-light: #e3919c;
  --wax-red: #c96e7a;
  --wax-dark: #8f424d;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  min-height: 100%;
  background: radial-gradient(circle at 50% 25%, var(--bg-top) 0%, var(--bg-cream) 45%, var(--bg-warm) 100%);
  color: var(--ink-dark);
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  overflow-x: hidden;
  transition: background 0.5s ease, color 0.4s ease;
  -webkit-font-smoothing: antialiased;
}

#petalCanvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 20;
}

.ambient-glow {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 18% 20%, rgba(243, 183, 185, 0.18) 0%, transparent 45%),
    radial-gradient(circle at 82% 78%, rgba(217, 198, 232, 0.18) 0%, transparent 45%);
  pointer-events: none;
  z-index: 0;
}

.paper-grain {
  position: fixed;
  inset: 0;
  opacity: 0.25;
  background-image: radial-gradient(rgba(90, 65, 45, 0.11) 0.75px, transparent 0.75px);
  background-size: 16px 16px;
  pointer-events: none;
  z-index: 1;
}

/* Welcome Page Sunlit Garden Background */
.welcome-floral-backdrop {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  overflow: hidden;
  opacity: 0;
  transform: scale(1.04);
  transition: opacity 1.15s cubic-bezier(0.22, 1, 0.36, 1),
              transform 1.3s cubic-bezier(0.22, 1, 0.36, 1);
}

.welcome-floral-backdrop.is-visible {
  opacity: 1;
  transform: scale(1);
}

.welcome-bg-image {
  position: absolute;
  inset: 0;
  background: url('assets/welcome-bg.jpg') center 25% / cover no-repeat;
}

.welcome-bg-scrim {
  display: none;
}

.hidden {
  display: none !important;
}

/* Top Navigation Bar */
.top-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 16px 24px;
  pointer-events: none;
}

.top-bar > * {
  pointer-events: auto;
}

.brand-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255, 252, 246, 0.8);
  border: 1px solid rgba(110, 84, 65, 0.16);
  backdrop-filter: blur(10px);
  font-size: 0.84rem;
  font-weight: 600;
  color: #2c211d;
  box-shadow: 0 4px 16px rgba(56, 36, 25, 0.08);
}

.brand-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--rose-accent);
  box-shadow: 0 0 0 3px rgba(199, 93, 101, 0.2);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn,
.pill-btn {
  border: 1px solid rgba(110, 84, 65, 0.18);
  background: rgba(255, 252, 246, 0.84);
  backdrop-filter: blur(10px);
  color: #2c211d;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
  font-family: inherit;
}

.icon-btn {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
}

.icon-btn.is-active {
  background: var(--rose-accent);
  color: #fff;
  border-color: var(--rose-accent);
}

.pill-btn {
  padding: 8px 15px;
  font-size: 0.82rem;
  font-weight: 500;
}

.pill-btn--accent {
  background: #2c211d;
  color: #fffaf3;
  border-color: #2c211d;
}

.icon-btn:hover,
.pill-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(44, 33, 29, 0.14);
}

/* Main Stage Layout */
.stage-container {
  position: relative;
  z-index: 10;
  min-height: 100dvh;
  width: 100%;
  transition: padding-right 0.35s ease;
}

body.studio-open .stage-container {
  padding-right: 420px;
}

.stage {
  position: fixed;
  inset: 0;
  margin: 0 auto;
  width: 100%;
  max-width: 760px;
  padding: 76px 20px 64px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(34px) scale(0.93);
  will-change: opacity, transform;
  transition:
    opacity 0.85s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.95s cubic-bezier(0.22, 1, 0.36, 1),
    visibility 0s linear 0.85s;
}

.stage.stage--active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0) scale(1);
  transition:
    opacity 0.95s cubic-bezier(0.22, 1, 0.36, 1) 0.18s,
    transform 1.05s cubic-bezier(0.22, 1, 0.36, 1) 0.18s,
    visibility 0s linear 0s;
}

.stage-letter {
  justify-content: flex-start;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  touch-action: pan-y;
  padding: 76px 20px 104px;
}

.stage-letter .letter-paper {
  flex-shrink: 0;
  margin: auto 0;
}

.stage.stage--exit {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-24px) scale(0.95);
  transition:
    opacity 0.72s cubic-bezier(0.4, 0, 0.2, 1),
    transform 0.72s cubic-bezier(0.4, 0, 0.2, 1),
    visibility 0s linear 0.72s;
}

/* Smooth choreographed exit for welcome elements */
#welcomeStage .floral-bouquet,
#welcomeStage .welcome-copy {
  transition: opacity 0.65s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.72s cubic-bezier(0.4, 0, 0.2, 1);
}

#welcomeStage.stage--exit .floral-bouquet {
  opacity: 0;
  transform: translateY(-28px) scale(0.9);
}

#welcomeStage.stage--exit .welcome-copy {
  opacity: 0;
  transform: translateY(22px) scale(0.96);
}

/* Center short letters vertically and allow tall letters to scroll */
#letterStage {
  justify-content: flex-start;
}

#letterStage .letter-paper {
  margin: auto 0;
}

/* =========================================================
   STAGE 1: FLORAL WELCOME
   ========================================================= */
.floral-bouquet {
  position: relative;
  width: min(300px, 72vw);
  height: min(335px, 46vh);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
  transition: transform 0.25s ease;
}

.bouquet-aura {
  position: absolute;
  width: 250px;
  height: 250px;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    rgba(245, 193, 71, 0.24) 0%,
    rgba(243, 183, 185, 0.2) 45%,
    transparent 74%
  );
  filter: blur(12px);
  opacity: 0;
  z-index: 0;
}

.stage--active .bouquet-aura {
  animation: auraGlow 1.4s 0.2s ease forwards;
}

.bouquet-img {
  position: relative;
  z-index: 1;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 20px 30px rgba(58, 37, 24, 0.2));
  opacity: 0;
  transform: translateY(28px) scale(0.84) rotate(-3deg);
  transform-origin: center 75%;
}

.stage--active .bouquet-img {
  animation:
    bouquetReveal 1.25s 0.15s cubic-bezier(0.22, 1, 0.36, 1) forwards,
    bouquetSway 4.6s 1.4s ease-in-out infinite;
}

@keyframes auraGlow {
  to { opacity: 1; }
}

@keyframes bouquetReveal {
  0% {
    opacity: 0;
    transform: translateY(28px) scale(0.84) rotate(-3deg);
  }
  70% {
    opacity: 1;
    transform: translateY(-4px) scale(1.02) rotate(1deg);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1) rotate(0deg);
  }
}

@keyframes bouquetSway {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-6px) rotate(1.2deg); }
}

.welcome-copy {
  text-align: center;
  max-width: 540px;
  padding: 24px 28px;
  border-radius: 22px;
  background: rgba(255, 251, 244, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.75);
  box-shadow: 0 18px 46px rgba(18, 28, 12, 0.24);
}

.eyebrow {
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--rose-accent);
  font-weight: 600;
  margin-bottom: 10px;
  opacity: 0;
}

.welcome-title {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: clamp(2.2rem, 5.5vw, 3.5rem);
  font-weight: 600;
  line-height: 1.08;
  color: var(--ink-dark);
  margin-bottom: 12px;
  opacity: 0;
}

.welcome-subtitle {
  font-size: 1rem;
  line-height: 1.6;
  color: var(--ink-muted);
  margin-bottom: 26px;
  opacity: 0;
}

.stage--active .eyebrow { animation: fadeUpText 0.8s 0.4s ease forwards; }
.stage--active .welcome-title { animation: fadeUpText 0.9s 0.65s ease forwards; }
.stage--active .welcome-subtitle { animation: fadeUpText 0.9s 0.9s ease forwards; }
.stage--active .primary-cta { animation: fadeUpText 0.9s 1.1s ease forwards; }

.primary-cta {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 28px;
  border-radius: 999px;
  border: none;
  background: linear-gradient(135deg, #3c2c26, #241915);
  color: #fffaf3;
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  cursor: pointer;
  box-shadow: 0 14px 32px rgba(44, 33, 29, 0.22);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  opacity: 0;
}

body[data-theme="midnight"] .primary-cta {
  background: linear-gradient(135deg, #e09f67, #b9753c);
  color: #19130e;
}

.primary-cta--compact {
  opacity: 1 !important;
  animation: none !important;
  padding: 10px 18px;
  font-size: 0.85rem;
}

.primary-cta:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 36px rgba(44, 33, 29, 0.28);
}

@keyframes fadeUpText {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

/* =========================================================
   STAGE 2 & 3: 3D ENVELOPE & OPENING ANIMATION
   ========================================================= */
.envelope-scene {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  width: 100%;
}

.stage-hint {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-style: italic;
  font-size: 1.25rem;
  color: var(--ink-muted);
  letter-spacing: 0.02em;
  transition: opacity 0.4s ease;
}

.envelope-wrapper {
  position: relative;
  width: min(440px, 88vw);
  height: min(326px, 65vw);
  perspective: 1400px;
  cursor: pointer;
  outline: none;
  animation: gentleFloat 4.2s ease-in-out infinite;
}

.envelope-wrapper.flipped,
.envelope-wrapper.opened {
  animation: none;
}

.envelope-wrapper.opened {
  cursor: default;
}

@keyframes gentleFloat {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-8px); }
}

.envelope-shadow {
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: -24px;
  height: 28px;
  background: radial-gradient(ellipse at center, rgba(25, 16, 10, 0.28) 0%, transparent 72%);
  filter: blur(6px);
  transition: transform 0.6s ease, opacity 0.6s ease;
}

.envelope-wrapper:hover .envelope-shadow {
  transform: scale(0.95);
  opacity: 0.75;
}

.envelope-card-3d {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.9s cubic-bezier(0.22, 1, 0.36, 1);
}

.envelope-wrapper.flipped .envelope-card-3d {
  transform: rotateY(180deg);
}

.envelope-face {
  position: absolute;
  inset: 0;
  border-radius: 10px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transform-style: preserve-3d;
}

.envelope-face--front {
  transform: rotateY(0deg);
  background: url('assets/envelope-back-paper.jpg') center center / cover no-repeat;
  box-shadow: var(--shadow-soft);
  border: 1px solid rgba(120, 92, 68, 0.16);
  overflow: hidden;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 0.01s linear 0.43s, visibility 0s linear 0s;
}

.envelope-wrapper.flipped .envelope-face--front {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.01s linear 0.43s, visibility 0s linear 0.44s;
}

.envelope-face--back {
  transform: rotateY(180deg);
  box-shadow: var(--shadow-soft);
  background: transparent;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.01s linear 0.43s, visibility 0s linear 0.44s, box-shadow 0.45s ease;
}

.envelope-wrapper.opened .envelope-face--back {
  box-shadow: none;
}

.envelope-wrapper.flipped .envelope-face--back {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 0.01s linear 0.43s, visibility 0s linear 0s;
}

.env-sticker {
  pointer-events: none;
  user-select: none;
  filter: drop-shadow(0 4px 8px rgba(68, 45, 25, 0.18));
}

.env-sticker--wildflowers {
  position: absolute;
  left: 3.5%;
  top: 50%;
  height: 82%;
  width: auto;
  transform: translateY(-50%) rotate(-5deg);
  z-index: 1;
}

.env-sticker--sunflowers {
  position: absolute;
  right: 3.5%;
  bottom: 5%;
  width: 22%;
  height: auto;
  transform: rotate(7deg);
  z-index: 2;
}

.env-sticker--pinky {
  position: absolute;
  right: 4.5%;
  top: 6%;
  width: 23%;
  height: auto;
  transform: rotate(8deg);
  z-index: 2;
}

.plain-address-wrap {
  position: absolute;
  inset: 0;
  padding: 18px 22% 18px 28%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  z-index: 3;
}

.env-sticker--hands {
  width: min(116px, 28vw);
  height: auto;
  transform: rotate(-2deg);
}

.plain-address-text {
  font-family: 'Dancing Script', cursive;
  font-size: clamp(1.36rem, 4.5vw, 1.95rem);
  color: #2c211d;
  line-height: 1.2;
  white-space: nowrap;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.55);
}

.envelope-back {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, var(--envelope-inner) 0%, var(--envelope-shade) 100%);
  border-radius: 10px;
  z-index: 1;
}

.envelope-closed-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  border-radius: 8px;
  z-index: 6;
  opacity: 1;
  transition: opacity 0.55s ease, transform 0.55s ease;
  pointer-events: none;
}

.envelope-wrapper.opened .envelope-closed-img {
  opacity: 0;
  transform: scale(1.015);
}

.envelope-open-layer {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 173.03%;
  object-fit: fill;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.45s ease 0.1s;
}

.envelope-open-back-img {
  z-index: 1;
  filter: drop-shadow(0 18px 40px rgba(42, 28, 18, 0.2));
}

.envelope-open-front-img {
  z-index: 4;
}

.envelope-wrapper.opened .envelope-open-layer {
  opacity: 1;
}

.letter-slip {
  position: absolute;
  left: 8%;
  right: 8%;
  top: 18%;
  height: 76%;
  background: var(--paper);
  border-radius: 6px;
  border: 1px solid rgba(130, 100, 75, 0.18);
  box-shadow: 0 6px 24px rgba(52, 34, 22, 0.14);
  z-index: 2;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  opacity: 0;
  transform: translateY(12%);
  transition: transform 1.15s cubic-bezier(0.22, 1, 0.36, 1) 0.38s,
              opacity 0.3s ease 0.25s;
}

.envelope-wrapper.opened .letter-slip {
  opacity: 1;
  transform: translate(-10%, -62%) rotate(-4deg);
}

.photo-slip {
  position: absolute;
  left: 22%;
  right: 18%;
  top: 15%;
  height: 78%;
  z-index: 3;
  pointer-events: none;
  opacity: 0;
  transform: translate(6%, 14%) rotate(2deg);
  transition: transform 1.2s cubic-bezier(0.22, 1, 0.36, 1) 0.45s,
              opacity 0.32s ease 0.32s;
}

.envelope-wrapper.opened .photo-slip {
  opacity: 1;
  transform: translate(22%, -68%) rotate(8deg);
}

.photo-slip img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 8px 18px rgba(45, 28, 16, 0.24));
}

.slip-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--rose-accent);
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-weight: 600;
  font-size: 1rem;
  border-bottom: 1px solid rgba(199, 93, 101, 0.25);
  padding-bottom: 8px;
}

.slip-lines {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.slip-lines span {
  height: 6px;
  border-radius: 4px;
  background: rgba(110, 84, 65, 0.12);
}

.slip-lines span:nth-child(1) { width: 88%; }
.slip-lines span:nth-child(2) { width: 96%; }
.slip-lines span:nth-child(3) { width: 78%; }
.slip-lines span:nth-child(4) { width: 64%; }

.envelope-front {
  position: absolute;
  inset: 0;
  border-radius: 10px;
  overflow: hidden;
  z-index: 4;
  pointer-events: none;
}

.flap-left {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--envelope-base) 0%, var(--envelope-shade) 100%);
  clip-path: polygon(0 0, 52% 52%, 0 100%);
}

.flap-right {
  position: absolute;
  inset: 0;
  background: linear-gradient(225deg, var(--envelope-base) 0%, var(--envelope-shade) 100%);
  clip-path: polygon(100% 0, 48% 52%, 100% 100%);
}

.flap-bottom {
  position: absolute;
  inset: 0;
  background: linear-gradient(0deg, var(--envelope-shade) 0%, var(--envelope-flap) 75%);
  clip-path: polygon(0 100%, 50% 45%, 100% 100%);
  filter: drop-shadow(0 -3px 6px rgba(60, 40, 20, 0.08));
}

.envelope-details {
  position: absolute;
  inset: 0;
  z-index: 5;
}

.postage-stamp {
  position: absolute;
  top: 16px;
  right: 18px;
  width: 58px;
  height: 68px;
  background: #fffaf0;
  border: 2px dashed #cbb79c;
  padding: 4px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  transform: rotate(3deg);
}

.stamp-inner {
  width: 100%;
  height: 100%;
  border: 1px solid rgba(199, 93, 101, 0.45);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #a93f48;
  text-align: center;
  gap: 2px;
}

.stamp-flower { font-size: 1rem; line-height: 1; }
.stamp-text { font-size: 0.48rem; font-weight: 700; letter-spacing: 0.06em; line-height: 1.15; }

.postmark {
  position: absolute;
  top: 24px;
  right: 68px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 1.5px solid var(--envelope-label);
  opacity: 0.65;
  display: grid;
  place-items: center;
  text-align: center;
  font-size: 0.42rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--envelope-label);
  transform: rotate(-14deg);
}

.address-block {
  position: absolute;
  bottom: 20px;
  left: 24px;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.address-to-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--envelope-label);
}

.address-to {
  font-family: 'Dancing Script', cursive;
  font-size: 1.55rem;
  color: var(--envelope-text);
}

.envelope-flap-top {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 58%;
  transform-origin: top center;
  transform-style: preserve-3d;
  transition: transform 0.85s cubic-bezier(0.35, 0, 0.25, 1) 0.15s, z-index 0s linear 0.45s;
  z-index: 6;
  pointer-events: none;
}

.flap-top-face {
  position: absolute;
  inset: 0;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-top-left-radius: 10px;
  border-top-right-radius: 10px;
}

.flap-top-outer {
  background: linear-gradient(180deg, var(--envelope-flap) 0%, var(--envelope-base) 100%);
  filter: drop-shadow(0 6px 10px rgba(56, 36, 25, 0.14));
}

.flap-top-inner {
  background: linear-gradient(180deg, var(--envelope-inner) 0%, var(--envelope-shade) 100%);
  transform: rotateX(180deg);
}

.envelope-wrapper.opened .envelope-flap-top {
  transform: rotateX(180deg);
  z-index: 1;
}

/* Wax Seal */
.wax-seal--hotspot {
  position: absolute;
  top: 67%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 78px;
  height: 78px;
  border-radius: 50%;
  border: none;
  background: transparent;
  box-shadow: none;
  z-index: 8;
  cursor: pointer;
}

.wax-seal--hotspot::before {
  display: none;
}

.wax-seal--hotspot.broken {
  pointer-events: none;
}

.wax-seal::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 47% 53% 51% 49% / 52% 48% 52% 48%;
  background: inherit;
  z-index: -1;
  opacity: 0.85;
}

.seal-ring {
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 224, 195, 0.48);
}

.seal-emblem {
  color: #fce2ce;
  font-size: 1.5rem;
  font-family: 'Cormorant Garamond', Georgia, serif;
  line-height: 1;
  text-shadow: 0 1px 2px rgba(40, 5, 5, 0.55);
}

.envelope-wrapper:hover .wax-seal {
  transform: translate(-50%, -50%) scale(1.08);
}

.wax-seal.broken {
  transform: translate(-50%, -50%) scale(1.38);
  opacity: 0;
  pointer-events: none;
}

/* =========================================================
   STAGE 4: MAIN LETTER PAPER & VARIANTS
   ========================================================= */
.letter-paper {
  position: relative;
  width: min(650px, 94vw);
  background: linear-gradient(180deg, rgba(255, 253, 248, 0.98) 0%, rgba(253, 248, 238, 0.98) 100%);
  color: #2c211d;
  border: 1px solid rgba(145, 118, 92, 0.22);
  border-radius: 8px;
  padding: clamp(30px, 6vw, 54px) clamp(24px, 6vw, 56px);
  box-shadow:
    0 24px 70px rgba(45, 28, 18, 0.14),
    0 2px 6px rgba(45, 28, 18, 0.06),
    inset 0 0 40px rgba(226, 208, 181, 0.25);
  overflow: hidden;
  transform: translateY(28px) scale(0.95);
  opacity: 0;
  transition: transform 1s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.9s ease;
}

.stage--active .letter-paper {
  transform: translateY(0) scale(1);
  opacity: 1;
}

.letter-paper[data-paper="lined"]::before {
  content: '';
  position: absolute;
  inset: 104px 48px 72px;
  background-image: repeating-linear-gradient(
    to bottom,
    transparent,
    transparent 33px,
    rgba(165, 140, 118, 0.12) 34px
  );
  pointer-events: none;
}

.letter-paper[data-paper="vintage"] {
  background: linear-gradient(180deg, #f6ead4 0%, #ede0c6 100%);
  border-color: #cfb792;
  box-shadow:
    0 24px 70px rgba(45, 28, 18, 0.2),
    inset 0 0 65px rgba(178, 140, 92, 0.25);
}

.letter-paper[data-paper="dark"] {
  background: linear-gradient(180deg, #212531 0%, #171a23 100%);
  color: #f4ece0;
  border-color: rgba(224, 159, 103, 0.28);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
}

.letter-paper[data-paper="dark"] .letter-date,
.letter-paper[data-paper="dark"] .closing-line,
.letter-paper[data-paper="dark"] .text-action-btn {
  color: #b7ab9e;
}

.letter-paper[data-paper="dark"] .letter-salutation,
.letter-paper[data-paper="dark"] .letter-paragraphs {
  color: #f1e8dc;
}

/* Font Modes on Paper */
.letter-paper[data-font="script"] .letter-salutation,
.letter-paper[data-font="script"] .letter-paragraphs {
  font-family: 'Dancing Script', cursive;
  font-size: clamp(1.32rem, 2.7vw, 1.55rem);
  line-height: 1.55;
}

.letter-paper[data-font="sans"] .letter-salutation,
.letter-paper[data-font="sans"] .letter-paragraphs {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: clamp(0.98rem, 2vw, 1.08rem);
  line-height: 1.75;
}

.pressed-flower {
  position: absolute;
  top: 12px;
  right: 14px;
  width: clamp(68px, 14vw, 96px);
  transform: rotate(7deg);
  opacity: 0.96;
  pointer-events: none;
  z-index: 3;
}

.pressed-flower-img {
  width: 100%;
  height: auto;
  display: block;
  filter: drop-shadow(0 6px 12px rgba(56, 36, 25, 0.18));
}

.letter-head {
  position: relative;
  z-index: 2;
  margin-bottom: 24px;
}

.letter-date {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: #6d5a52;
  margin-bottom: 12px;
}

.letter-divider {
  width: 64px;
  height: 2px;
  background: linear-gradient(90deg, var(--rose-accent), transparent);
}

.letter-body-wrap {
  position: relative;
  z-index: 2;
}

.letter-body-wrap::after {
  content: '';
  display: table;
  clear: both;
}

.letter-salutation {
  font-family: 'Caveat', 'Dancing Script', cursive;
  font-size: clamp(1.62rem, 3.5vw, 2.02rem);
  font-weight: 700;
  color: #2b1a15;
  line-height: 1.25;
  margin-bottom: 14px;
}

.letter-paragraphs {
  display: block;
  font-family: 'Caveat', cursive;
  font-size: clamp(1.34rem, 2.7vw, 1.56rem);
  font-weight: 500;
  line-height: 1.52;
  letter-spacing: 0.01em;
  color: #2f201b;
}

.letter-paragraphs em {
  font-style: italic;
  font-weight: 600;
  color: #5b2730;
  background: linear-gradient(180deg, transparent 62%, rgba(236, 174, 180, 0.28) 62%);
  padding: 0 2px;
}

.letter-paragraphs p + p {
  margin-top: 16px;
}

.letter-paragraphs p {
  opacity: 0;
  transform: translateY(10px);
  animation: inkReveal 0.85s ease forwards;
}

@keyframes inkReveal {
  to { opacity: 1; transform: translateY(0); }
}

/* Scrapbook Keepsake Photo (top-right beside greeting & opening paragraphs) */
.keepsake-scrapbook {
  position: relative;
  float: right;
  width: clamp(134px, 44%, 222px);
  margin: 22px -4px 12px 14px;
  text-align: center;
  opacity: 0;
  transform: translateY(14px) rotate(2deg);
  animation: keepsakeReveal 0.9s 0.75s ease forwards;
}

.keepsake-scrapbook .keepsake-photo-img {
  width: 100%;
  height: auto;
  display: block;
  filter: drop-shadow(0 10px 22px rgba(50, 32, 18, 0.24));
}

.keepsake-scrapbook .favorite-person-sticker {
  position: absolute;
  top: -66px;
  left: 6%;
  width: 66%;
  height: auto;
  display: block;
  transform: rotate(-4deg);
  pointer-events: none;
  filter: drop-shadow(0 4px 10px rgba(50, 32, 18, 0.2));
  z-index: 4;
}

@keyframes keepsakeReveal {
  to {
    opacity: 1;
    transform: translateY(0) rotate(2deg);
  }
}

/* Polaroid Keepsake Card */
.polaroid-card {
  margin: 22px auto 6px;
  width: min(240px, 100%);
  background: #ffffff;
  padding: 10px 10px 18px;
  border-radius: 4px;
  box-shadow: 0 10px 26px rgba(45, 28, 18, 0.16);
  transform: rotate(-1.8deg);
  text-align: center;
}

.polaroid-card img {
  width: 100%;
  height: 175px;
  object-fit: cover;
  border-radius: 2px;
  display: block;
}

.polaroid-card figcaption {
  margin-top: 10px;
  font-family: 'Dancing Script', cursive;
  font-size: 1.15rem;
  color: #3a2b24;
}

.letter-love-highlight {
  clear: both;
  margin-top: 24px;
  font-family: 'Caveat', 'Dancing Script', cursive;
  font-size: clamp(1.46rem, 4.2vw, 2.38rem);
  font-weight: 700;
  color: #c11f36;
  line-height: 1.25;
  opacity: 0;
  transform: translateY(10px);
  animation: inkReveal 0.85s 1.15s ease forwards;
}

.letter-signoff {
  clear: both;
  margin-top: 18px;
  opacity: 0;
  animation: inkReveal 0.85s 1.32s ease forwards;
}

.closing-line {
  font-family: 'Caveat', cursive;
  font-style: italic;
  font-size: 1.35rem;
  color: #6d5a52;
  margin-bottom: 4px;
}

.signature {
  font-family: 'Caveat', 'Dancing Script', cursive;
  font-size: clamp(1.75rem, 3.8vw, 2.15rem);
  font-weight: 700;
  color: #362520;
  line-height: 1.25;
}

.letter-footer {
  position: relative;
  z-index: 2;
  margin-top: 32px;
  padding-top: 18px;
  border-top: 1px dashed rgba(145, 118, 92, 0.3);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
}

.text-action-btn {
  background: transparent;
  border: none;
  color: #6d5a52;
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 500;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 6px;
  transition: color 0.2s ease, background 0.2s ease;
}

.text-action-btn:hover {
  color: var(--ink-dark);
  background: rgba(145, 118, 92, 0.12);
}

/* =========================================================
   CUSTOMIZE STUDIO SIDE DRAWER
   ========================================================= */
.studio-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(410px, 100vw);
  background: #fffcf7;
  color: #2c211d;
  border-left: 1px solid rgba(130, 100, 75, 0.2);
  box-shadow: -12px 0 44px rgba(25, 16, 10, 0.18);
  z-index: 50;
  display: flex;
  flex-direction: column;
  animation: slideInDrawer 0.28s ease forwards;
}

@keyframes slideInDrawer {
  from { transform: translateX(30px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.studio-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 12px;
  border-bottom: 1px solid rgba(130, 100, 75, 0.14);
}

.studio-kicker {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--rose-accent);
  font-weight: 700;
}

.studio-header h2 {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.55rem;
  font-weight: 600;
}

.close-btn {
  border: none;
  background: transparent;
  font-size: 1.75rem;
  line-height: 1;
  color: #6d5a52;
  cursor: pointer;
}

.studio-stage-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 10px 16px;
  background: #f6efe4;
  border-bottom: 1px solid rgba(130, 100, 75, 0.12);
}

.stage-jump-btn {
  border: 1px solid rgba(130, 100, 75, 0.2);
  background: #fff;
  color: #4f3e36;
  border-radius: 8px;
  padding: 7px 6px;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.stage-jump-btn.active {
  background: #2c211d;
  color: #fffaf3;
  border-color: #2c211d;
}

.studio-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(130, 100, 75, 0.14);
}

.studio-tab {
  border: 1px solid rgba(130, 100, 75, 0.22);
  background: #faf4eb;
  color: #4f3e36;
  border-radius: 999px;
  padding: 6px 11px;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.studio-tab.active {
  background: var(--rose-accent);
  color: #fff;
  border-color: var(--rose-accent);
}

.studio-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px 24px;
}

.tab-panel {
  display: none;
  flex-direction: column;
  gap: 14px;
}

.tab-panel.active {
  display: flex;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #5f4c44;
}

.field input[type="text"],
.field textarea,
.field select {
  width: 100%;
  border: 1px solid rgba(130, 100, 75, 0.28);
  border-radius: 10px;
  padding: 9px 12px;
  font-family: inherit;
  font-size: 0.88rem;
  color: #2c211d;
  background: #fff;
  outline: none;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--rose-accent);
  box-shadow: 0 0 0 3px rgba(199, 93, 101, 0.14);
}

.field input[type="range"] {
  accent-color: var(--rose-accent);
  cursor: pointer;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.upload-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.upload-pill,
.mini-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 12px;
  border-radius: 8px;
  border: 1px solid rgba(130, 100, 75, 0.28);
  background: #faf4eb;
  color: #2c211d;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.upload-pill:hover,
.mini-btn:hover {
  background: #f0e4d4;
}

.choice-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.radio-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(130, 100, 75, 0.24);
  background: #fff;
  cursor: pointer;
}

.radio-card strong {
  display: block;
  font-size: 0.84rem;
  color: #2c211d;
}

.radio-card small {
  display: block;
  font-size: 0.74rem;
  font-weight: 400;
  color: #6d5a52;
}

.swatch-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.theme-chip {
  border: 1px solid rgba(130, 100, 75, 0.26);
  background: #fff;
  color: #3a2b24;
  border-radius: 9px;
  padding: 8px 10px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.theme-chip.active {
  border-color: var(--rose-accent);
  background: rgba(199, 93, 101, 0.12);
  color: var(--rose-accent);
}

.color-dots {
  display: flex;
  gap: 10px;
  padding: 4px 0;
}

.color-dot {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid rgba(44, 33, 29, 0.2);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.color-dot.active {
  transform: scale(1.14);
  box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--rose-accent);
}

.emblem-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.emblem-row input {
  width: 90px;
  text-align: center;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.84rem;
  font-weight: 500;
  color: #3a2b24;
  cursor: pointer;
}

.checkbox-row input {
  width: 16px;
  height: 16px;
  accent-color: var(--rose-accent);
}

.studio-footer {
  padding: 14px 20px;
  border-top: 1px solid rgba(130, 100, 75, 0.14);
  background: #faf4eb;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

/* Toast Notification */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #2c211d;
  color: #fffaf3;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.85rem;
  opacity: 0;
  pointer-events: none;
  z-index: 60;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Mobile Tweaks */
@media (max-width: 900px) {
  body.studio-open .stage-container {
    padding-right: 20px;
  }
}

@media (max-width: 540px) {
  .top-bar {
    padding: 12px 14px;
  }

  .stage {
    padding: 68px 16px 70px;
  }

  .stage-letter {
    padding: 68px 16px 104px;
  }

  .keepsake-scrapbook {
    width: clamp(128px, 45%, 172px);
    margin: 18px -2px 10px 12px;
  }

  .keepsake-scrapbook .favorite-person-sticker {
    top: -50px;
    left: 2%;
    width: 70%;
  }

  .floral-bouquet {
    width: min(225px, 56vw);
    height: min(215px, 31dvh);
    margin-bottom: 12px;
  }

  .welcome-copy {
    padding: 18px 20px;
    max-width: 350px;
    border-radius: 18px;
  }

  .welcome-title {
    font-size: clamp(1.7rem, 6.6vw, 2.3rem);
    margin-bottom: 8px;
  }

  .welcome-subtitle {
    font-size: 0.92rem;
    margin-bottom: 18px;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .letter-paper[data-paper="lined"]::before {
    inset: 96px 24px 66px;
  }
}
