/* ==========================================================================
   STILE FOTOREALISTICO "PROVA" + IMPAGINAZIONE DA LIBRO ANTICO IN FRAKTUR
   Tavolo in noce scuro a lume di candela, pergamena piegata in tre,
   incisione calcografica, ceralacca fusa 3D, epigrafe centrale e firma.
   ========================================================================== */

:root {
  --walnut-deep: #0d0806;
  --walnut-mid: #1b110b;
  --walnut-warm: #2b1a10;

  --paper-base: #efe3c8;
  --paper-light: #f7efdc;
  --paper-edge: #dcc79e;
  --paper-stain: rgba(138, 96, 48, 0.14);

  --ink-iron: #21160f;
  --ink-muted: #523d2d;
  --ink-crimson: #6e1b20;
  --gold-ink: #b88736;
  --rule-color: rgba(88, 61, 36, 0.28);

  --font-letter: 'UnifrakturMaguntia', Georgia, serif;
  --font-epigraph: 'IM Fell English', 'Cormorant Garamond', Georgia, serif;
}

/* Modalità lettura serale a lume di candela ravvicinato */
body.evening-mode {
  --paper-base: #231a13;
  --paper-light: #2b2017;
  --paper-edge: #19120d;
  --paper-stain: rgba(0, 0, 0, 0.25);

  --ink-iron: #ecdcc0;
  --ink-muted: #bfa682;
  --ink-crimson: #d46b68;
  --rule-color: rgba(212, 170, 98, 0.26);
}

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

.svg-defs {
  position: absolute;
  width: 0;
  height: 0;
  pointer-events: none;
}

html, body {
  width: 100%;
  min-height: 100%;
  background-color: var(--walnut-deep);
  color: var(--ink-iron);
  font-family: 'IM Fell English', 'Cormorant Garamond', Georgia, serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px 16px;
  position: relative;
}

/* Piano in legno di noce scuro con venature sottili + luce calda di candela */
.walnut-desk {
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    repeating-linear-gradient(
      92deg,
      rgba(255, 215, 170, 0.014) 0px,
      rgba(255, 215, 170, 0.014) 2px,
      rgba(0, 0, 0, 0.05) 3px,
      rgba(0, 0, 0, 0.02) 9px
    ),
    repeating-linear-gradient(
      89deg,
      rgba(48, 28, 16, 0.28) 0px,
      rgba(22, 13, 8, 0.34) 18px,
      rgba(38, 22, 13, 0.25) 37px
    ),
    radial-gradient(ellipse at 24% 16%, #362114 0%, var(--walnut-mid) 46%, var(--walnut-deep) 100%);
}

.candle-vignette {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(circle at 22% 14%, rgba(255, 186, 92, 0.14) 0%, rgba(255, 150, 56, 0.04) 36%, transparent 65%),
    radial-gradient(ellipse at 50% 50%, transparent 42%, rgba(5, 3, 2, 0.78) 100%);
  animation: candleBreath 6.5s ease-in-out infinite alternate;
}

@keyframes candleBreath {
  0% { opacity: 0.92; }
  50% { opacity: 1; }
  100% { opacity: 0.95; }
}

#dust-motes {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  pointer-events: none;
}

/* Barra mittente (?stampa=1) */
.sender-bar {
  position: relative;
  z-index: 15;
  width: 100%;
  max-width: 480px;
  background: rgba(24, 17, 13, 0.95);
  border: 1px solid rgba(201, 156, 82, 0.65);
  color: #f3e6ce;
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 18px;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 13px;
  line-height: 1.45;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.65);
}

.sender-bar strong {
  color: #e4b660;
}

.sender-url {
  margin-top: 4px;
  word-break: break-all;
  font-size: 12px;
  opacity: 0.9;
}

.sender-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.sender-btn {
  background: #c79846;
  color: #17100b;
  border: none;
  border-radius: 5px;
  padding: 7px 12px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

.sender-btn.secondary {
  background: transparent;
  color: #f3e6ce;
  border: 1px solid rgba(201, 156, 82, 0.5);
}

/* Palco e Foglio di Pergamena Piegata in Tre */
.parchment-stage {
  position: relative;
  z-index: 5;
  width: 100%;
  max-width: 480px;
  perspective: 1200px;
}

.parchment-sheet {
  position: relative;
  width: 100%;
  min-height: 610px;
  background:
    radial-gradient(ellipse at 32% 22%, var(--paper-light) 0%, var(--paper-base) 58%, var(--paper-edge) 100%);
  border-radius: 3px 4px 3px 5px;
  padding: 44px 38px 38px;
  box-shadow:
    0 2px 5px rgba(0, 0, 0, 0.62),
    14px 26px 54px rgba(0, 0, 0, 0.78),
    inset 0 0 42px rgba(112, 75, 34, 0.24),
    inset 0 1px 0 rgba(255, 250, 238, 0.48);
  border: 1px solid rgba(120, 86, 46, 0.36);
  overflow: hidden;
  transition: background 0.55s ease, color 0.55s ease, box-shadow 0.55s ease;
}

.parchment-fiber {
  position: absolute;
  inset: 0;
  filter: url(#paper-grain);
  opacity: 0.75;
  pointer-events: none;
  z-index: 1;
}

body.evening-mode .parchment-fiber {
  opacity: 0.25;
}

.parchment-patina {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  background:
    radial-gradient(circle at 12% 8%, var(--paper-stain) 0%, transparent 28%),
    radial-gradient(circle at 92% 15%, var(--paper-stain) 0%, transparent 24%),
    radial-gradient(circle at 86% 88%, var(--paper-stain) 0%, transparent 32%),
    radial-gradient(circle at 8% 92%, var(--paper-stain) 0%, transparent 25%);
}

/* Due pieghe orizzontali realistiche da busta */
.fold-crease {
  position: absolute;
  left: 0;
  right: 0;
  height: 3px;
  pointer-events: none;
  z-index: 2;
}

.fold-top {
  top: 32.5%;
  background: linear-gradient(
    to bottom,
    rgba(65, 42, 20, 0.13) 0%,
    rgba(255, 252, 244, 0.38) 55%,
    transparent 100%
  );
}

.fold-bottom {
  top: 67.5%;
  background: linear-gradient(
    to bottom,
    rgba(65, 42, 20, 0.11) 0%,
    rgba(255, 252, 244, 0.34) 55%,
    transparent 100%
  );
}

body.evening-mode .fold-top,
body.evening-mode .fold-bottom {
  opacity: 0.22;
}

/* Filigrana astronomica centrale */
.astral-watermark {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 330px;
  height: 330px;
  transform: translate(-50%, -50%);
  color: var(--ink-iron);
  opacity: 0.042;
  pointer-events: none;
  z-index: 1;
}

body.evening-mode .astral-watermark {
  opacity: 0.055;
}

/* Doppia filettatura interna lungo il margine */
.parchment-inner-rule {
  position: absolute;
  inset: 14px;
  border: 1px solid var(--rule-color);
  pointer-events: none;
  z-index: 2;
}

.parchment-inner-rule::after {
  content: "";
  position: absolute;
  inset: 3px;
  border: 0.5px solid var(--rule-color);
  opacity: 0.55;
}

.parchment-content {
  position: relative;
  z-index: 4;
}

/* ==========================================================================
   SCHERMATA 0: BUSTA CHIUSA CON SIGILLO IN CERALACCA (RICHIESTA NOME)
   ========================================================================== */

.envelope-gate {
  width: 100%;
  max-width: 454px;
  margin: 0 auto;
}

.envelope-shell {
  position: relative;
  width: 100%;
  min-height: 430px;
  border-radius: 3px 4px 4px 5px;
  perspective: 1400px;
  box-shadow:
    0 3px 7px rgba(0, 0, 0, 0.65),
    14px 28px 56px rgba(0, 0, 0, 0.82);
  transition: opacity 0.4s ease, transform 0.45s ease;
}

.envelope-back {
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: 3px 4px 4px 5px;
  background: radial-gradient(ellipse at 50% 25%, #cbb284 0%, #b79b6c 70%, #a58758 100%);
  border: 1px solid rgba(110, 78, 42, 0.42);
  box-shadow: inset 0 18px 36px rgba(42, 24, 10, 0.28);
  overflow: hidden;
}

.envelope-fiber {
  position: absolute;
  inset: 0;
  filter: url(#paper-grain);
  opacity: 0.72;
  pointer-events: none;
}

/* Foglio di pergamena che fuoriesce dalla tasca della busta all'apertura */
.envelope-emerging-letter {
  position: absolute;
  left: 20px;
  right: 20px;
  top: 22px;
  height: 270px;
  z-index: 3;
  padding: 26px 22px 14px;
  border-radius: 2px 3px 2px 2px;
  background: radial-gradient(ellipse at 32% 22%, var(--paper-light) 0%, var(--paper-base) 65%, var(--paper-edge) 100%);
  border: 1px solid rgba(120, 86, 46, 0.36);
  box-shadow:
    0 -2px 12px rgba(24, 14, 6, 0.22),
    inset 0 0 28px rgba(112, 75, 34, 0.16);
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transform: translateY(22px);
}

.emerging-inner-rule {
  position: absolute;
  inset: 10px;
  border: 1px solid var(--rule-color);
  pointer-events: none;
}

.emerging-owl {
  margin-bottom: 6px;
}

.emerging-owl svg {
  width: 118px;
  height: 52px;
  margin: 0 auto;
}

.emerging-eyebrow {
  font-size: 9.5px;
  margin-bottom: 5px;
}

.emerging-title {
  font-family: 'IM Fell English', 'Cormorant Garamond', Georgia, serif;
  font-size: 22px;
  line-height: 1.2;
  color: var(--ink-iron);
}

/* Tasca frontale della busta (lembi laterali + inferiore piegato) */
.envelope-pocket-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 4;
  border-radius: 3px 4px 4px 5px;
  pointer-events: none;
}

/* Lembo superiore triangolare apribile in 3D */
.envelope-flap {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 200px;
  z-index: 6;
  transform-origin: top center;
  transform-style: preserve-3d;
  transform: rotateX(0deg);
  pointer-events: none;
}

.envelope-flap.flap-behind {
  z-index: 2;
}

.envelope-flap-front,
.envelope-flap-back {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.envelope-flap-back {
  transform: rotateX(180deg);
}

.envelope-flap-svg {
  width: 100%;
  height: 100%;
  display: block;
}

.envelope-flap-header {
  position: absolute;
  top: 24px;
  left: 34px;
  right: 34px;
  text-align: center;
}

.envelope-title {
  font-size: 23px;
  margin-bottom: 0;
}

/* Sigillo 3D in ceralacca bordeaux sul vertice del lembo */
.envelope-wax-seal {
  position: absolute;
  left: 50%;
  bottom: -14px;
  transform: translateX(-50%);
  pointer-events: none;
  user-select: none;
}

.gate-wax-svg {
  width: 78px;
  height: 78px;
  display: block;
  transform: rotate(-3deg);
}

/* Modulo accesso posizionato sulla tasca inferiore della busta */
.envelope-front-form {
  position: relative;
  z-index: 8;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 224px 36px 28px;
  transition: opacity 0.24s ease, transform 0.24s ease;
}

.gate-subtitle {
  font-family: 'IM Fell English', 'Cormorant Garamond', Georgia, serif;
  font-style: italic;
  font-size: 16.5px;
  line-height: 1.4;
  color: var(--ink-muted);
  max-width: 290px;
  margin-bottom: 14px;
}

.gate-form {
  width: 100%;
  max-width: 266px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 11px;
}

.gate-input {
  width: 100%;
  padding: 9px 14px;
  background: rgba(252, 247, 236, 0.78);
  border: 1px solid rgba(110, 78, 42, 0.42);
  border-radius: 4px;
  box-shadow: inset 0 1px 4px rgba(62, 38, 16, 0.1);
  font-family: 'IM Fell English', 'Cormorant Garamond', Georgia, serif;
  font-size: 17.5px;
  letter-spacing: 0.03em;
  color: var(--ink-iron);
  text-align: center;
  outline: none;
  transition: border-color 0.25s ease, box-shadow 0.25s ease, background-color 0.25s ease;
}

.gate-input::placeholder {
  color: rgba(82, 61, 45, 0.56);
  font-style: italic;
}

.gate-input:focus {
  background: rgba(254, 250, 242, 0.96);
  border-color: rgba(154, 108, 42, 0.78);
  box-shadow:
    inset 0 1px 4px rgba(62, 38, 16, 0.08),
    0 0 14px rgba(216, 158, 60, 0.28);
}

.gate-input.is-error {
  border-color: rgba(110, 27, 32, 0.75);
  box-shadow: 0 0 12px rgba(110, 27, 32, 0.2);
}

.gate-submit-btn {
  width: 100%;
  padding: 9.5px 18px;
  border-radius: 4px;
  border: 1px solid #4a0e12;
  background: linear-gradient(180deg, #882127 0%, #68141a 100%);
  color: #f4e6c8;
  font-family: 'Cinzel', Georgia, serif;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow:
    0 3px 10px rgba(32, 8, 10, 0.28),
    inset 0 1px 0 rgba(255, 224, 200, 0.22);
  transition: transform 0.18s ease, box-shadow 0.22s ease, filter 0.22s ease;
}

.gate-submit-btn:hover {
  filter: brightness(1.07);
  box-shadow:
    0 5px 14px rgba(32, 8, 10, 0.34),
    0 0 16px rgba(216, 158, 60, 0.22),
    inset 0 1px 0 rgba(255, 224, 200, 0.28);
}

.gate-submit-btn:active {
  transform: translateY(1px);
}

.gate-error {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-style: italic;
  font-size: 14.5px;
  line-height: 1.35;
  color: var(--ink-crimson);
  margin-top: 1px;
}

.gate-shake {
  animation: gateShake 0.38s ease;
}

@keyframes gateShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  45% { transform: translateX(6px); }
  70% { transform: translateX(-4px); }
  85% { transform: translateX(3px); }
}

/* Sequenza di apertura 3D della busta ed emersione della lettera */
.envelope-gate.is-opening .envelope-front-form {
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
}

.envelope-gate.is-opening .envelope-wax-seal {
  opacity: 0;
  transform: translateX(-50%) scale(1.14);
  filter: drop-shadow(0 0 12px rgba(238, 184, 78, 0.85));
  transition: opacity 0.32s ease, transform 0.32s ease, filter 0.32s ease;
}

.envelope-gate.is-opening .envelope-flap {
  transform: rotateX(174deg);
  transition: transform 0.68s cubic-bezier(0.32, 0.08, 0.24, 1) 0.18s;
}

.envelope-gate.is-opening .envelope-emerging-letter {
  opacity: 1;
  transform: translateY(-138px);
  transition:
    opacity 0.28s ease 0.45s,
    transform 0.72s cubic-bezier(0.22, 1, 0.36, 1) 0.48s;
}

.envelope-gate.is-opening .envelope-shell {
  opacity: 0;
  transform: translateY(28px) scale(0.975);
  transition:
    opacity 0.42s ease 1.06s,
    transform 0.45s ease 1.04s;
}

.parchment-sheet.sheet-emerging {
  animation: sheetEmerge 0.64s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes sheetEmerge {
  0% {
    opacity: 0;
    transform: translateY(-18px) scale(0.965);
    filter: blur(1px);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0px);
  }
}

/* ==========================================================================
   SCHERMATA 1: PERGAMENA CHIUSA
   ========================================================================== */

.seal-face {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 522px;
  padding-bottom: 14px;
}

.owl-engraving {
  color: var(--ink-iron);
  opacity: 0.84;
  margin-bottom: 10px;
  mix-blend-mode: multiply;
}

body.evening-mode .owl-engraving {
  mix-blend-mode: normal;
}

.owl-engraving svg {
  width: 146px;
  height: 64px;
  display: block;
}

.eyebrow {
  font-family: 'Cinzel', Georgia, serif;
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--ink-muted);
  text-align: center;
  margin-bottom: 8px;
}

.seal-title {
  font-family: 'IM Fell English', 'Cormorant Garamond', Georgia, serif;
  font-weight: 400;
  font-size: 27px;
  line-height: 1.22;
  letter-spacing: 0.015em;
  color: var(--ink-iron);
  text-align: center;
  margin-bottom: 24px;
  text-shadow: 0 0.4px 0.6px rgba(33, 22, 15, 0.18);
}

/* Area QR + Incantesimo Aparecium (NESSUN INGRANDIMENTO) */
.qr-sanctum {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.qr-frame {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 15px;
  background: rgba(251, 246, 234, 0.88);
  border-radius: 5px;
  box-shadow:
    inset 0 0 12px rgba(122, 86, 42, 0.16),
    0 3px 12px rgba(28, 18, 10, 0.08);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  transition: box-shadow 0.3s ease, background-color 0.3s ease;
}

.qr-frame.holding {
  background: rgba(253, 248, 236, 0.95);
  box-shadow:
    inset 0 0 18px rgba(212, 158, 62, 0.28),
    0 0 26px rgba(226, 174, 78, 0.34);
}

.qr-frame canvas#qr-canvas {
  display: block;
  border-radius: 2px;
}

.spark-canvas {
  position: absolute;
  inset: -18px;
  width: calc(100% + 36px);
  height: calc(100% + 36px);
  pointer-events: none;
  z-index: 5;
}

.aparecium-border {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 4;
}

.aparecium-base {
  stroke: rgba(110, 78, 42, 0.38);
  stroke-width: 1.1;
}

.aparecium-trace {
  stroke: #d89e3c;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  filter: drop-shadow(0 0 4px rgba(238, 184, 78, 0.85));
}

.seal-subtitle {
  margin-top: 16px;
  font-family: 'IM Fell English', 'Cormorant Garamond', Georgia, serif;
  font-style: italic;
  font-size: 17.5px;
  color: var(--ink-muted);
  text-align: center;
  letter-spacing: 0.02em;
}

.reopen-note {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--rule-color);
  max-width: 300px;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-style: italic;
  font-size: 14.5px;
  line-height: 1.48;
  color: var(--ink-muted);
  text-align: center;
}

.local-note {
  margin-top: 14px;
  max-width: 310px;
  padding: 7px 11px;
  border-radius: 4px;
  background: rgba(120, 86, 46, 0.1);
  border: 1px solid rgba(120, 86, 46, 0.2);
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 11px;
  line-height: 1.4;
  color: var(--ink-muted);
  text-align: center;
}

/* Sigillo 3D in ceralacca bordeaux nell'angolo in basso a destra (NON CLICCABILE) */
.wax-seal-wrap {
  align-self: flex-end;
  margin-top: 14px;
  margin-right: 4px;
  pointer-events: none;
  user-select: none;
}

.wax-seal-svg {
  width: 74px;
  height: 74px;
  display: block;
  transform: rotate(-4deg);
}

.wax-letter {
  font-family: 'Cinzel', Georgia, serif;
  font-size: 27px;
  font-weight: 600;
  fill: #cfa063;
  filter: drop-shadow(0 1px 1px rgba(32, 4, 6, 0.85));
}

/* Dissolvenza inchiostro Aparecium tra Schermata 1 e Schermata 2 */
.vanish-ink {
  animation: inkVanish 0.5s ease forwards;
}

@keyframes inkVanish {
  0% {
    opacity: 1;
    filter: blur(0px);
  }
  100% {
    opacity: 0;
    filter: blur(2.5px);
  }
}

.appear-ink {
  animation: inkAppear 0.82s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes inkAppear {
  0% {
    opacity: 0;
    filter: blur(2px);
    transform: translateY(4px);
  }
  100% {
    opacity: 1;
    filter: blur(0px);
    transform: translateY(0);
  }
}

/* ==========================================================================
   SCHERMATA 2: IMPAGINAZIONE DA LIBRO ANTICO IN CARATTERE FRAKTUR
   ========================================================================== */

.letter-face {
  padding: 2px 4px 0;
}

.letter-topbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 8px;
}

.ambient-btn {
  background: transparent;
  border: 1px solid var(--rule-color);
  border-radius: 99px;
  padding: 3px 11px;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 13px;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
  cursor: pointer;
  transition: background 0.25s ease, color 0.25s ease;
}

.ambient-btn:hover {
  background: rgba(120, 86, 46, 0.1);
  color: var(--ink-iron);
}

.letter-header {
  text-align: center;
  margin-bottom: 22px;
}

.letter-date {
  font-family: var(--font-letter);
  font-size: 18px;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
  margin-bottom: 6px;
}

.letter-title {
  font-family: var(--font-letter);
  font-weight: 400;
  font-size: 32px;
  line-height: 1.24;
  letter-spacing: 0.02em;
  color: var(--ink-iron);
  margin-bottom: 10px;
  text-shadow: 0 0.5px 0.8px rgba(33, 22, 15, 0.22);
}

.ink-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 8px 0 4px;
  color: var(--ink-crimson);
  font-size: 11px;
  opacity: 0.82;
}

.ink-divider::before,
.ink-divider::after {
  content: "";
  height: 1px;
  width: 72px;
  background: linear-gradient(90deg, transparent, var(--rule-color), transparent);
}

.letter-salutation {
  font-family: var(--font-letter);
  font-size: 22.5px;
  color: var(--ink-iron);
  margin-bottom: 16px;
  letter-spacing: 0.015em;
}

.letter-body p {
  font-family: var(--font-letter);
  font-size: 20.5px;
  line-height: 1.76;
  letter-spacing: 0.018em;
  word-spacing: 0.06em;
  color: var(--ink-iron);
  margin-bottom: 18px;
  text-align: left;
  text-shadow: 0 0.35px 0.55px rgba(33, 22, 15, 0.16);
}

.letter-body p:last-child {
  margin-bottom: 8px;
}

/* Capolettera miniato bordeaux sulla "A" iniziale del primo paragrafo */
.letter-body p:first-child::first-letter {
  float: left;
  font-family: var(--font-letter);
  font-size: 56px;
  line-height: 0.82;
  padding-right: 11px;
  padding-top: 5px;
  color: var(--ink-crimson);
}

/* Epigrafe centrale in inglese incorniciata da filetti sottili e stellina */
.letter-epigraph {
  position: relative;
  margin: 26px auto 24px;
  max-width: 92%;
  padding: 16px 14px 18px;
  text-align: center;
}

.letter-epigraph::before,
.letter-epigraph::after {
  content: "";
  position: absolute;
  left: 8%;
  right: 8%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--rule-color) 20%, var(--rule-color) 80%, transparent);
}

.letter-epigraph::before {
  top: 0;
}

.letter-epigraph::after {
  bottom: 0;
}

.epigraph-ornament {
  font-size: 10.5px;
  line-height: 1;
  color: var(--ink-crimson);
  opacity: 0.85;
  margin-bottom: 8px;
}

.letter-quote {
  font-family: var(--font-epigraph);
  font-style: italic;
  font-size: 18.5px;
  line-height: 1.58;
  letter-spacing: 0.015em;
  color: var(--ink-muted);
}

/* Galleria Foto Opzionale */
.photo-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin: 22px 0;
}

.photo-frame {
  background: rgba(252, 247, 236, 0.78);
  padding: 9px 9px 13px;
  border-radius: 3px;
  border: 1px solid var(--rule-color);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.14);
}

.photo-frame img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 2px;
}

.photo-caption {
  margin-top: 8px;
  text-align: center;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 15.5px;
  font-style: italic;
  color: var(--ink-muted);
}

/* Bottoni Media Opzionali (Video / Canzone) */
.media-links {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 20px 0;
}

.media-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  padding: 10px 16px;
  border-radius: 4px;
  border: 1px solid var(--rule-color);
  background: rgba(120, 86, 46, 0.09);
  color: var(--ink-iron);
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.03em;
  transition: background 0.2s ease, transform 0.2s ease;
}

.media-btn:hover {
  background: rgba(120, 86, 46, 0.18);
  transform: translateY(-1px);
}

.video-player {
  width: 100%;
  border-radius: 4px;
  border: 1px solid var(--rule-color);
  margin-top: 6px;
}

.letter-ps {
  margin-top: 18px;
  font-family: var(--font-letter);
  font-size: 18px;
  line-height: 1.6;
  color: var(--ink-muted);
}

/* Firma su due livelli in basso a destra con "Maximillian" più marcato sotto */
.letter-signature {
  margin-top: 28px;
  padding-right: 4px;
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
}

.sig-greeting {
  font-family: var(--font-letter);
  font-size: 20px;
  line-height: 1.35;
  color: var(--ink-muted);
}

.sig-name {
  font-family: var(--font-letter);
  font-size: 26px;
  line-height: 1.25;
  letter-spacing: 0.02em;
  color: var(--ink-iron);
  text-shadow: 0 0.5px 0.8px rgba(33, 22, 15, 0.22);
}

.letter-footer {
  margin-top: 30px;
  padding-top: 14px;
  border-top: 1px solid var(--rule-color);
  text-align: center;
}

.reclose-btn {
  background: none;
  border: none;
  padding: 4px 12px;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 15px;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  cursor: pointer;
  opacity: 0.82;
  transition: color 0.2s ease, opacity 0.2s ease;
}

.reclose-btn:hover {
  color: var(--ink-iron);
  opacity: 1;
}

.hidden {
  display: none !important;
}

@media (max-width: 430px) {
  .parchment-sheet {
    padding: 34px 24px 30px;
    min-height: 560px;
  }
  .envelope-shell {
    min-height: 396px;
  }
  .envelope-flap {
    height: 178px;
  }
  .envelope-flap-header {
    top: 18px;
    left: 22px;
    right: 22px;
  }
  .envelope-title {
    font-size: 20px;
  }
  .gate-wax-svg {
    width: 68px;
    height: 68px;
  }
  .envelope-front-form {
    padding: 198px 24px 24px;
  }
  .seal-face {
    min-height: 492px;
  }
  .seal-title {
    font-size: 24px;
  }
  .letter-title {
    font-size: 27.5px;
  }
  .letter-body p {
    font-size: 19px;
    line-height: 1.7;
  }
  .letter-quote {
    font-size: 17px;
  }
  .sig-name {
    font-size: 24px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .candle-vignette,
  .vanish-ink,
  .appear-ink,
  .sheet-emerging,
  .gate-shake {
    animation: none !important;
  }
}
