:root {
  --ink: #2a2a2a;
  --blue: #24479b;
  --red: #c8352f;
  --cream: #f6f1e4;
  --sheet: #fbf8f0;
  --desk: #c9d3d8;
  --muted: #5a6478;
  --line: 32px;
  --airmail: repeating-linear-gradient(45deg, var(--red) 0 14px, var(--cream) 14px 21px, var(--blue) 21px 35px, var(--cream) 35px 42px);
  --noise: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .25 0 0 0 0 .28 0 0 0 0 .32 0 0 0 .35 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
* { box-sizing: border-box; }
html, body { margin: 0; overflow-x: hidden; }
body {
  min-height: 100vh;
  color: var(--ink);
  font-family: 'Special Elite', 'Courier New', monospace;
  font-size: 17px;
  background: var(--noise), radial-gradient(ellipse at 50% 0%, #dfe6e9, var(--desk) 55%, #aebac1);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}
::selection { background: rgba(36, 71, 155, .2); }
.hidden { display: none !important; }
.hand { font-family: 'Caveat', cursive; }

/* ---------- envelope / lock ---------- */
.stage { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr); place-items: center; padding: 32px 16px; }
.envelope-wrap { width: min(540px, 100%); }
.envelope {
  position: relative;
  aspect-ratio: 1.6;
  width: 100%;
  background: var(--noise), var(--cream);
  border: 12px solid transparent;
  border-image: var(--airmail) 12;
  box-shadow: 0 26px 60px rgba(30, 40, 60, .38), 0 2px 5px rgba(30, 40, 60, .2);
  transition: transform .9s cubic-bezier(.6, .05, .3, 1), opacity .9s ease;
}
.envelope.open { transform: translateY(40px) rotate(-4deg) scale(.92); opacity: 0; }
.par-avion {
  position: absolute; left: 8%; top: 10%;
  color: var(--red); letter-spacing: .2em; font-size: clamp(11px, 2.6vw, 14px);
}
.par-avion small { display: block; color: var(--blue); letter-spacing: .12em; font-size: .8em; margin-top: 2px; }
.stamp {
  position: absolute; top: 8%; right: 6%;
  width: 18%; aspect-ratio: .84;
  background: var(--blue);
  outline: 3px dotted var(--cream); outline-offset: -3px;
  box-shadow: inset 0 0 0 5px var(--blue), inset 0 0 0 6px rgba(246, 241, 228, .55);
  color: var(--cream);
  display: grid; place-items: center;
  font-size: clamp(20px, 5vw, 30px);
  transform: rotate(4deg);
}
.postmark {
  position: absolute; top: 12%; right: 19%;
  width: 22%; aspect-ratio: 1;
  border: 2px solid rgba(36, 71, 155, .55);
  border-radius: 50%;
  display: grid; place-items: center; text-align: center;
  color: rgba(36, 71, 155, .7);
  font-size: clamp(8px, 1.8vw, 11px); line-height: 1.25;
  transform: rotate(-14deg);
}
.postmark::after {
  content: '';
  position: absolute; left: -55%; right: -55%; top: 50%;
  height: 16px; margin-top: -8px;
  background: repeating-linear-gradient(transparent 0 3px, rgba(36, 71, 155, .45) 3px 5px);
  z-index: -1;
}
.address {
  position: absolute; left: 22%; bottom: 16%; right: 8%;
  font-family: 'Caveat', cursive;
  font-size: clamp(22px, 5.4vw, 32px);
  line-height: 1.3;
  color: var(--blue);
}
.address span { display: block; border-bottom: 1px solid rgba(36, 71, 155, .25); }
.address span + span { padding-left: 1.2em; }

.lock-form { margin: 34px auto 0; text-align: center; color: #2a3a55; transition: opacity .4s; }
.lock-form label { display: block; font-size: 14px; letter-spacing: .14em; text-transform: uppercase; margin-bottom: 8px; }
.pin {
  font-family: 'Special Elite', monospace;
  font-size: 28px;
  letter-spacing: .45em;
  text-align: center;
  width: min(280px, 90%);
  padding: 8px 0 8px .45em;
  background: transparent;
  color: #1d2a44;
  border: none;
  border-bottom: 1.5px solid rgba(42, 58, 85, .55);
  outline: none;
  border-radius: 0;
}
.pin:focus { border-bottom-color: var(--blue); }
.pin::placeholder { color: rgba(42, 58, 85, .3); }
.btn {
  display: inline-block;
  margin-top: 22px;
  font-family: 'Special Elite', monospace;
  font-size: 16px;
  letter-spacing: .12em;
  text-transform: uppercase;
  padding: 11px 26px;
  border: 1.5px solid #2a3a55;
  background: transparent;
  color: #1d2a44;
  cursor: pointer;
  transition: background .2s, color .2s;
}
.btn:hover { background: #2a3a55; color: var(--cream); }
.btn:disabled { opacity: .5; cursor: wait; }
.btn.solid { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.solid:hover { background: #1b367a; }
.err { min-height: 1.6em; color: var(--red); font-size: 15px; margin-top: 12px; }
.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }

/* ---------- sheet (lined airmail paper) ---------- */
.sheet {
  position: relative;
  background:
    repeating-linear-gradient(transparent 0 calc(var(--line) - 1px), rgba(36, 71, 155, .13) calc(var(--line) - 1px) var(--line)),
    var(--sheet);
  background-position: 0 14px;
  box-shadow: 0 22px 50px rgba(30, 40, 60, .3), 0 1px 3px rgba(30, 40, 60, .2);
}
.sheet::before {
  content: '';
  position: absolute; top: 0; bottom: 0; left: 54px;
  border-left: 1.5px solid rgba(200, 53, 47, .35);
  pointer-events: none;
}
.sheet::after {
  content: '';
  position: absolute; inset: 0;
  background: var(--noise);
  opacity: .35;
  mix-blend-mode: multiply;
  pointer-events: none;
}
.sheet > * { position: relative; z-index: 1; }

.letter-view { opacity: 0; transform: translateY(24px); transition: opacity .9s ease, transform .9s ease; padding: 48px 16px 80px; }
.letter-view.show { opacity: 1; transform: none; }
.letter {
  max-width: 740px;
  width: 100%;
  margin: 0 auto;
  padding: 46px 56px 60px 84px;
  line-height: var(--line);
  border-top: 8px solid transparent;
  border-image: var(--airmail) 8;
  border-image-width: 8px 0 0 0;
}
.date { text-align: right; color: var(--muted); font-size: 15px; height: var(--line); }
.title { font-family: 'Special Elite', monospace; font-weight: 400; font-size: 22px; letter-spacing: .06em; text-transform: uppercase; margin: var(--line) 0 0; line-height: var(--line); }
.greeting { font-family: 'Caveat', cursive; font-size: 38px; color: var(--blue); line-height: calc(var(--line) * 2); margin: 0; }
.body { font-size: 17px; }
.body p { margin: 0 0 var(--line); }
.signoff { margin-top: var(--line); text-align: right; font-family: 'Caveat', cursive; font-size: 34px; line-height: calc(var(--line) * 1.25); color: var(--blue); white-space: pre-line; }
.unwritten { color: var(--muted); padding: var(--line) 0 0; }
.unwritten .big { font-family: 'Caveat', cursive; font-size: 36px; color: var(--blue); display: block; line-height: calc(var(--line) * 2); }
.flourish { text-align: center; color: var(--red); opacity: .55; margin: var(--line) 0 0; font-size: 14px; letter-spacing: .5em; }

/* ---------- board ---------- */
.board { max-width: 980px; margin: 76px auto 0; }
.board h2 { font-family: 'Special Elite', monospace; font-weight: 400; color: #1d2a44; text-align: center; font-size: 20px; letter-spacing: .2em; text-transform: uppercase; margin: 0 0 6px; }
.board .sub { text-align: center; color: var(--muted); margin: 0 0 40px; font-size: 15px; }
.pins { display: flex; flex-wrap: wrap; justify-content: center; gap: 40px 30px; padding: 10px 0 20px; }
.polaroid {
  position: relative;
  width: 250px;
  background: #fdfbf5;
  padding: 12px 12px 14px;
  box-shadow: 0 12px 26px rgba(30, 40, 60, .32), 0 1px 3px rgba(30, 40, 60, .2);
  transition: transform .25s ease;
}
.polaroid:hover, .note:hover { transform: rotate(0deg) scale(1.03) !important; z-index: 5; }
.polaroid img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; background: #dfe3e3; cursor: zoom-in; }
.polaroid .cap { font-family: 'Caveat', cursive; font-size: 23px; line-height: 1.2; margin-top: 10px; color: #2b2b3a; text-align: center; word-wrap: break-word; }
.note {
  position: relative;
  width: 250px;
  min-height: 180px;
  padding: 34px 22px 30px;
  background: repeating-linear-gradient(transparent 0 29px, rgba(36, 71, 155, .14) 29px 30px), #fff;
  background-position: 0 30px;
  box-shadow: 0 12px 24px rgba(30, 40, 60, .28);
  font-family: 'Caveat', cursive;
  font-size: 24px;
  line-height: 30px;
  color: #2b2b3a;
  white-space: pre-wrap;
  word-wrap: break-word;
  transition: transform .25s ease;
}
.note.her, .polaroid.her .cap { color: var(--blue); }
.pushpin { /* tape strip */
  position: absolute;
  top: -12px; left: 50%;
  width: 86px; height: 26px;
  margin-left: -43px;
  background: rgba(200, 53, 47, .5);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .12);
  transform: rotate(-3deg);
  z-index: 2;
  clip-path: polygon(2% 0, 98% 4%, 100% 100%, 0 96%);
}
.her .pushpin { background: rgba(36, 71, 155, .45); transform: rotate(3deg); }
.who { position: absolute; bottom: 6px; right: 12px; font-family: 'Special Elite', monospace; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: rgba(40, 40, 60, .45); }
.del { position: absolute; top: 8px; right: 8px; border: none; background: none; cursor: pointer; font-size: 20px; color: rgba(40, 40, 60, .35); z-index: 3; }
.del:hover { color: var(--red); }

/* ---------- reply form ---------- */
.reply { max-width: 640px; margin: 64px auto 0; padding: 40px 40px 36px 80px; line-height: var(--line); transform: rotate(.4deg); }
.reply h3 { font-family: 'Special Elite', monospace; font-weight: 400; font-size: 20px; letter-spacing: .14em; text-transform: uppercase; margin: 0; }
.reply .sub { color: var(--muted); margin: 0 0 var(--line); font-size: 15px; }
.field { display: block; margin-bottom: 16px; }
.field > span { display: block; color: var(--muted); font-size: 13px; letter-spacing: .1em; text-transform: uppercase; }
.field textarea, .field input[type=text], .field input[type=password] {
  width: 100%;
  font-family: 'Caveat', cursive;
  font-size: 26px;
  line-height: var(--line);
  color: var(--blue);
  background: transparent;
  border: none;
  outline: none;
  resize: vertical;
  padding: 0 2px;
}
.field textarea { min-height: calc(var(--line) * 5); }
.dropzone {
  display: grid; place-items: center; text-align: center;
  border: 1.5px dashed rgba(36, 71, 155, .45);
  background: rgba(255, 255, 255, .55);
  padding: 20px;
  cursor: pointer;
  color: var(--blue);
  font-size: 15px;
  line-height: 1.5;
  transition: background .2s;
}
.dropzone:hover, .dropzone.over { background: rgba(36, 71, 155, .07); }
.dropzone input { display: none; }
.previews { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.previews img { width: 74px; height: 74px; object-fit: cover; box-shadow: 0 2px 6px rgba(0, 0, 0, .25); border: 4px solid #fff; }
.reply .btn { width: 100%; }
.status { text-align: center; color: var(--muted); min-height: 1.5em; margin-top: 10px; font-size: 15px; line-height: 1.5; }

/* ---------- lightbox ---------- */
.lightbox { position: fixed; inset: 0; background: rgba(20, 26, 38, .88); display: grid; place-items: center; z-index: 50; padding: 24px; cursor: zoom-out; }
.lightbox figure { margin: 0; background: #fdfbf5; padding: 14px 14px 18px; max-width: 92vw; box-shadow: 0 20px 60px rgba(0, 0, 0, .6); }
.lightbox img { display: block; max-width: calc(92vw - 28px); max-height: 78vh; object-fit: contain; }
.lightbox figcaption { font-family: 'Caveat', cursive; font-size: 26px; text-align: center; margin-top: 10px; color: #2b2b3a; }

footer.end { text-align: center; color: var(--muted); margin-top: 60px; font-size: 13px; letter-spacing: .2em; text-transform: uppercase; }

@media (max-width: 640px) {
  :root { --line: 28px; }
  body { font-size: 15px; }
  .letter { padding: 30px 20px 40px 52px; }
  .sheet::before { left: 38px; }
  .body { font-size: 15px; }
  .greeting { font-size: 32px; }
  .signoff { font-size: 29px; }
  .title { font-size: 18px; }
  .reply { padding: 30px 18px 26px 52px; transform: none; }
  .polaroid, .note { width: 44vw; min-width: 150px; }
  .polaroid { padding: 8px 8px 10px; }
  .polaroid .cap { font-size: 19px; }
  .note { font-size: 20px; line-height: 26px; min-height: 130px; padding: 26px 12px 22px; background-size: auto; }
  .pushpin { width: 64px; margin-left: -32px; height: 22px; }
  .pins { gap: 32px 12px; }
  .envelope { border-width: 9px; }
}
.polaroid:has(.who) { padding-bottom: 28px; }
