:root {
  --line: #111111;
  --frame: #ffffff;
  --frame-line: #d9d9d9;
  --board-gap: 4px;
  --radius: 10px;
  --paper: #fbf7f1;
  --paper-line: #e7ddd0;
  --text-soft: #6f655d;
}

@font-face {
  font-family: "Tanker";
  src: url("Tanker-Regular.otf") format("opentype");
  font-weight: 400;
  font-style: normal;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

section[id] {
  scroll-margin-top: 88px;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Manrope", Arial, Helvetica, sans-serif;
  background: #ffffff;
  color: #111111;
}

body.locked {
  overflow: hidden;
}

.site-lock {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(180deg, rgba(255, 250, 244, 0.96), rgba(243, 232, 221, 0.98));
}

.site-lock[hidden] {
  display: none;
}

.site-lock-card {
  width: min(420px, 100%);
  padding: 28px;
  border: 1px solid rgba(17, 17, 17, 0.1);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 24px 46px rgba(0, 0, 0, 0.1);
}

.site-lock-kicker {
  margin: 0 0 8px;
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-soft);
}

.site-lock-card h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3rem);
  line-height: 0.95;
}

.site-lock-copy {
  margin: 14px 0 18px;
  line-height: 1.6;
  color: var(--text-soft);
}

.site-lock-input {
  width: 100%;
  margin-bottom: 12px;
  padding: 14px 16px;
  border: 1px solid rgba(17, 17, 17, 0.14);
  border-radius: 16px;
  font: inherit;
  font-size: 1.05rem;
  letter-spacing: 0.18em;
  text-align: center;
}

.site-lock-button {
  width: 100%;
  padding: 14px 16px;
  border: 0;
  border-radius: 999px;
  background: #111111;
  color: #fffaf5;
  font: inherit;
  cursor: pointer;
}

.site-lock-error {
  margin: 12px 0 0;
  color: #9d3448;
  font-size: 0.92rem;
}

.story-shell {
  position: relative;
}

.page-shell {
  position: relative;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  min-height: 100vh;
  padding: 6px;
}

.home-shell {
  height: 100vh;
  overflow: hidden;
}

.home-intro {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  pointer-events: none;
  text-align: center;
}

.home-intro::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(760px, calc(100vw - 48px));
  min-height: 220px;
  transform: translate(-50%, -50%);
  border-radius: 28px;
  background: rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(4px);
  box-shadow: 0 20px 42px rgba(0, 0, 0, 0.14);
}

.home-intro-kicker {
  position: relative;
  z-index: 1;
  margin: 0;
  font-size: 0.92rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(255, 247, 240, 0.86);
}

.home-intro h1 {
  position: relative;
  z-index: 1;
  margin: 0;
  padding: 0 28px;
  font-family: "Tanker", "Cormorant Garamond", serif;
  font-size: clamp(3.4rem, 8vw, 7.4rem);
  line-height: 0.88;
  font-weight: 400;
  letter-spacing: 0.02em;
  color: #fffaf5;
  text-shadow: 0 6px 20px rgba(0, 0, 0, 0.28);
}

.home-scroll {
  position: absolute;
  left: 50%;
  bottom: 30px;
  transform: translateX(-50%);
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: #fffaf5;
  text-decoration: none;
  pointer-events: auto;
  z-index: 1;
}

.home-scroll span:first-child {
  font-size: 0.8rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 247, 240, 0.82);
}

.home-scroll-arrow {
  width: 22px;
  height: 22px;
  border-right: 2px solid #fffaf5;
  border-bottom: 2px solid #fffaf5;
  transform: rotate(45deg);
  animation: home-bounce 1.8s ease-in-out infinite;
}

@keyframes home-bounce {
  0%,
  100% {
    transform: rotate(45deg) translate(0, 0);
  }

  50% {
    transform: rotate(45deg) translate(6px, 6px);
  }
}

.menu-toggle {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 20;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: 1px solid rgba(17, 17, 17, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  color: #111111;
  padding: 11px 15px;
  font: inherit;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.08);
}

.menu-toggle-lines {
  position: relative;
  width: 16px;
  height: 12px;
  display: inline-block;
}

.menu-toggle-lines::before,
.menu-toggle-lines::after {
  content: "";
  position: absolute;
  left: 0;
  width: 16px;
  height: 1.5px;
  background: #111111;
  transition: transform 180ms ease, top 180ms ease;
}

.menu-toggle-lines::before {
  top: 3px;
}

.menu-toggle-lines::after {
  top: 8px;
}

.menu-open .menu-toggle-lines::before {
  top: 5.5px;
  transform: rotate(45deg);
}

.menu-open .menu-toggle-lines::after {
  top: 5.5px;
  transform: rotate(-45deg);
}

.menu-toggle-text {
  font-size: 0.96rem;
}

.menu-backdrop {
  position: fixed;
  inset: 0;
  z-index: 17;
  border: 0;
  background: rgba(255, 255, 255, 0.42);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.menu-open .menu-backdrop {
  opacity: 1;
  pointer-events: auto;
}

.memory-board,
.side-nav {
  border: 3px solid var(--line);
  background: #ffffff;
}

.memory-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: var(--board-gap);
  padding: 4px;
}

.memory-card,
.postcard-card {
  min-width: 0;
}

.photo-card {
  position: relative;
  min-height: 0;
}

.photo-frame {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border: 1px solid var(--frame-line);
  border-radius: var(--radius);
  background: var(--frame);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.08);
  cursor: pointer;
}

.photo-preview,
.empty-state {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.photo-preview {
  display: none;
  inset: 1px;
  width: calc(100% - 2px);
  height: calc(100% - 2px);
  object-fit: cover;
  object-position: center;
  border-radius: 9px;
  background: #ffffff;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.photo-card.has-image .photo-preview {
  display: block;
}

.photo-card.dragging .photo-preview {
  cursor: grabbing;
}

.photo-card.has-image .empty-state {
  display: none;
}

.empty-state {
  background: #ffffff;
}

.empty-state-special,
.special-empty {
  border: 2px dashed #cfcfcf;
  border-radius: 10px;
  inset: 3px;
  width: auto;
  height: auto;
}

.empty-state-special::before,
.empty-state-special::after,
.special-empty::before,
.special-empty::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  background: #c0c0c0;
  transform: translate(-50%, -50%);
}

.empty-state-special::before,
.special-empty::before {
  width: 42px;
  height: 2px;
}

.empty-state-special::after,
.special-empty::after {
  width: 2px;
  height: 42px;
}

.postcard-empty {
  background: linear-gradient(180deg, #ffffff, #fbf7f2);
}

.photo-frame input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.photo-card.has-image .photo-frame input {
  pointer-events: none;
}

.tilt-left {
  transform: rotate(-1deg);
}

.tilt-right {
  transform: rotate(1deg);
}

.tilt-left-soft {
  transform: rotate(-0.55deg);
}

.tilt-right-soft {
  transform: rotate(0.55deg);
}

.replace-button,
.reset-button {
  position: absolute;
  bottom: 12px;
  width: 18px;
  height: 18px;
  border: 0;
  border-radius: 50%;
  background: rgba(17, 17, 17, 0.08);
  opacity: 0;
  pointer-events: none;
  cursor: pointer;
  z-index: 3;
}

.replace-button {
  right: 36px;
}

.reset-button {
  right: 12px;
}

.replace-button::before,
.reset-button::before {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(17, 17, 17, 0.38);
}

.photo-card.has-image:hover .replace-button,
.photo-card.has-image:focus-within .replace-button,
.shared-card.has-image:hover .reset-button,
.shared-card.has-image:focus-within .reset-button {
  opacity: 1;
  pointer-events: auto;
}

.side-nav {
  position: fixed;
  top: 18px;
  right: 18px;
  width: 240px;
  z-index: 18;
  border: 1px solid rgba(17, 17, 17, 0.1);
  border-radius: 24px;
  padding: 0;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(16px);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.1);
  transform: translateX(calc(100% + 12px));
  transition: transform 180ms ease;
}

.menu-open .side-nav {
  transform: translateX(0);
}

.side-nav nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 18px;
}

.side-nav-kicker {
  margin: 0 0 8px;
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-soft);
}

.side-nav a {
  color: #111111;
  text-decoration: none;
  font-size: 0.95rem;
  line-height: 1.35;
  padding: 10px 12px;
  border-radius: 12px;
  transition: background 160ms ease, transform 160ms ease;
}

.side-nav a:hover,
.side-nav a:focus-visible {
  background: rgba(17, 17, 17, 0.05);
  transform: translateX(2px);
  outline: none;
}

.travels-section {
  padding: 28px 20px 44px;
  background: linear-gradient(180deg, #ffffff 0%, #fcfaf7 100%);
}

.timeline-section {
  padding: 36px 20px 60px;
  background: #ffffff;
}

.things-section {
  padding: 36px 20px 70px;
  background: linear-gradient(180deg, #fffdf9 0%, #f6efe6 100%);
}

.letter-section {
  padding: 40px 20px 90px;
  background: linear-gradient(180deg, #fffdf9 0%, #f4ece2 100%);
}

.travels-header {
  max-width: 920px;
  margin: 0 auto 28px;
}

.timeline-header {
  max-width: 920px;
  margin: 0 auto 34px;
}

.things-header {
  max-width: 920px;
  margin: 0 auto 30px;
}

.letter-header {
  max-width: 920px;
  margin: 0 auto 4px;
}

.travels-kicker,
.postcard-place,
.timeline-kicker,
.timeline-date,
.things-kicker,
.thing-label {
  margin: 0 0 10px;
  font-size: 0.82rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-soft);
}

.letter-kicker {
  margin: 0 0 10px;
  font-size: 0.82rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-soft);
}

.travels-header h1,
.postcard-copy h2,
.timeline-header h1,
.things-header h1,
.thing-card h2 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.6rem);
  line-height: 0.95;
  font-weight: 600;
}

.letter-header h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.6rem);
  line-height: 0.95;
  font-weight: 600;
}

.travels-copy,
.postcard-copy p,
.timeline-copy,
.timeline-body p,
.things-copy,
.thing-card p {
  margin: 14px 0 0;
  max-width: 720px;
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text-soft);
}

.envelope-scene {
  position: relative;
  max-width: 980px;
  height: 720px;
  margin: -40px auto 0;
}

.letter-sheet {
  position: absolute;
  left: 50%;
  bottom: 180px;
  width: min(760px, calc(100vw - 80px));
  transform: translateX(-50%) translateY(260px);
  opacity: 0;
  transition: transform 320ms cubic-bezier(0.22, 1, 0.36, 1), opacity 240ms ease;
  z-index: 1;
}

.letter-page {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 24px;
  padding: 34px;
  height: min(540px, 68vh);
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.86), rgba(251, 246, 239, 0.98)),
    #fff;
  box-shadow: 0 28px 50px rgba(65, 42, 26, 0.16);
  border: 1px solid #eadfcf;
  overflow: hidden;
}

.letter-copy {
  font-size: 1rem;
  line-height: 1.8;
  color: #443730;
  overflow-y: auto;
  padding-right: 10px;
  scrollbar-width: thin;
}

.letter-copy::-webkit-scrollbar {
  width: 8px;
}

.letter-copy::-webkit-scrollbar-thumb {
  background: rgba(111, 101, 93, 0.35);
  border-radius: 999px;
}

.letter-copy p {
  margin: 0 0 16px;
}

.letter-intro,
.letter-signoff {
  font-size: 1.15rem;
  color: #1d1613;
}

.letter-polaroid {
  align-self: start;
  padding: 10px 10px 16px;
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 18px 28px rgba(0, 0, 0, 0.12);
  transform: rotate(4deg);
}

.polaroid-frame {
  aspect-ratio: 0.92 / 1;
}

.polaroid-caption {
  margin: 12px 4px 0;
  font-size: 0.95rem;
  color: #6f655d;
}

.envelope {
  position: absolute;
  left: 50%;
  bottom: 36px;
  width: min(820px, calc(100vw - 80px));
  height: 420px;
  transform: translateX(-50%);
  z-index: 2;
}

.envelope-back,
.envelope-left,
.envelope-right,
.envelope-bottom,
.envelope-flap {
  position: absolute;
  inset: 0;
}

.envelope-back {
  border-radius: 28px;
  background: #f1dfca;
  box-shadow: 0 26px 40px rgba(94, 59, 34, 0.12);
}

.envelope-bottom {
  clip-path: polygon(0 100%, 50% 42%, 100% 100%);
  background: #f5e7d4;
  border-bottom-left-radius: 28px;
  border-bottom-right-radius: 28px;
}

.envelope-left {
  clip-path: polygon(0 0, 52% 50%, 0 100%);
  background: #ead2b8;
  border-top-left-radius: 28px;
  border-bottom-left-radius: 28px;
}

.envelope-right {
  clip-path: polygon(100% 0, 48% 50%, 100% 100%);
  background: #e2c4a5;
  border-top-right-radius: 28px;
  border-bottom-right-radius: 28px;
}

.envelope-flap {
  transform-origin: top center;
  clip-path: polygon(0 0, 50% 72%, 100% 0);
  background: #f8ecd9;
  border-top-left-radius: 28px;
  border-top-right-radius: 28px;
  transition: transform 320ms cubic-bezier(0.22, 1, 0.36, 1);
}

.envelope-open-button {
  position: absolute;
  left: 50%;
  bottom: 190px;
  transform: translateX(-50%);
  z-index: 3;
  width: 96px;
  height: 96px;
  border: 0;
  border-radius: 50%;
  background: radial-gradient(circle at top left, #ffffff, #edd4b8);
  box-shadow: 0 14px 28px rgba(85, 52, 25, 0.18);
  font: inherit;
  color: #2f221d;
  cursor: pointer;
}

.envelope-open-button::before {
  content: "";
  position: absolute;
  inset: 12px;
  border: 1px solid rgba(77, 54, 39, 0.16);
  border-radius: 50%;
}

.envelope-scene.is-open .letter-sheet {
  transform: translateX(-50%) translateY(-130px);
  opacity: 1;
  z-index: 4;
}

.envelope-scene.is-open .envelope-flap {
  transform: rotateX(180deg);
}

.envelope-scene.is-open .envelope-left,
.envelope-scene.is-open .envelope-right,
.envelope-scene.is-open .envelope-bottom {
  z-index: 2;
}

.envelope-scene.is-open .envelope-back {
  z-index: 1;
}

.envelope-scene.is-open .envelope-flap {
  z-index: 5;
}

@media (max-width: 980px) {
  .letter-page {
    grid-template-columns: 1fr;
    height: auto;
  }

  .letter-polaroid {
    max-width: 280px;
  }

  .letter-copy {
    max-height: 360px;
  }
}

.things-board {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px;
  border: 1px solid #e5dacb;
  border-radius: 34px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.08) 1px, transparent 1px),
    linear-gradient(180deg, #d8b08d 0%, #c99671 100%);
  background-size: 28px 28px, 28px 28px, auto;
  box-shadow: inset 0 0 0 8px rgba(255, 255, 255, 0.08), 0 18px 40px rgba(72, 39, 18, 0.08);
}

.thing-note {
  position: relative;
  min-height: 132px;
  padding: 18px 18px 20px;
  border-radius: 6px;
  box-shadow: 0 16px 24px rgba(0, 0, 0, 0.14);
  transform-origin: center center;
  transition: transform 240ms cubic-bezier(0.22, 1, 0.36, 1), box-shadow 240ms cubic-bezier(0.22, 1, 0.36, 1), min-height 240ms cubic-bezier(0.22, 1, 0.36, 1);
  overflow: hidden;
}

.thing-note::before {
  content: "";
  position: absolute;
  top: 10px;
  left: 50%;
  width: 54px;
  height: 14px;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid rgba(170, 170, 170, 0.35);
  transform: translateX(-50%) rotate(-3deg);
  transition: transform 240ms cubic-bezier(0.22, 1, 0.36, 1), opacity 200ms ease;
}

.thing-note h2 {
  margin: 6px 0 0;
  font-size: 1.55rem;
  line-height: 1.02;
  max-width: 12ch;
}

.thing-note-head {
  position: relative;
  z-index: 2;
}

.thing-note-body {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transform: translateY(14px);
  transition: max-height 280ms cubic-bezier(0.22, 1, 0.36, 1), opacity 220ms ease, transform 240ms cubic-bezier(0.22, 1, 0.36, 1), margin-top 220ms ease;
}

.thing-note-body p {
  margin-top: 0;
}

.thing-note:hover,
.thing-note:focus-within {
  min-height: 320px;
}

.thing-note:hover,
.thing-note:focus-within {
  transform: translateY(-8px) scale(1.04) rotate(0deg);
  box-shadow: 0 28px 40px rgba(0, 0, 0, 0.22);
  z-index: 4;
}

.thing-note:hover::before,
.thing-note:focus-within::before {
  transform: translateX(-50%) translateY(-1px) rotate(0deg) scale(1.04);
  opacity: 0.92;
}

.thing-note:hover .thing-note-body,
.thing-note:focus-within .thing-note-body {
  max-height: 520px;
  opacity: 1;
  transform: translateY(0);
  margin-top: 14px;
}

.note-yellow {
  background: #f8e58c;
}

.note-rose {
  background: #f3c9c7;
}

.note-ivory {
  background: #fff4d7;
}

.note-sand {
  background: #ead7b8;
}

.note-blue {
  background: #cfe2f2;
}

.note-cream {
  background: #f8efde;
}

.timeline-track {
  position: relative;
  max-width: 1120px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  padding: 84px 0 0;
}

.timeline-track::before {
  content: "";
  position: absolute;
  top: 96px;
  left: 24px;
  right: 24px;
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(90deg, #111111 0%, #3d3d3d 25%, #949494 70%, #d9d9d9 100%);
}

.timeline-stop {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 240px;
  z-index: 1;
}

.timeline-bubble {
  position: absolute;
  left: 50%;
  top: 0;
  width: min(250px, calc(100vw - 48px));
  padding: 18px 18px 22px;
  border: 1px solid #e4ddd4;
  border-radius: 20px;
  background: #ffffff;
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.08);
  opacity: 0;
  pointer-events: none;
  z-index: 3;
  transform: translate(-50%, -12px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.timeline-bubble::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -10px;
  width: 18px;
  height: 18px;
  background: #ffffff;
  border-right: 1px solid #e4ddd4;
  border-bottom: 1px solid #e4ddd4;
  transform: translateX(-50%) rotate(45deg);
}

.timeline-date {
  margin: 0;
  padding-top: 0;
}

.timeline-bubble h2 {
  margin: 0;
  font-size: 1.3rem;
  line-height: 1.08;
  font-weight: 600;
}

.timeline-dot {
  margin: 0;
  margin-top: 83px;
  width: 26px;
  height: 26px;
  border: 4px solid #111111;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 0 0 10px #ffffff;
  cursor: pointer;
  z-index: 1;
}

.timeline-label {
  margin: 20px 0 0;
  max-width: 150px;
  text-align: center;
  font-size: 1rem;
  line-height: 1.3;
  font-weight: 600;
  color: #111111;
}

.timeline-stamp {
  margin: 8px 0 0;
  max-width: 150px;
  text-align: center;
  font-size: 0.8rem;
  line-height: 1.35;
  letter-spacing: 0.04em;
  color: var(--text-soft);
}

.timeline-stop:hover .timeline-bubble,
.timeline-stop:focus-within .timeline-bubble,
.timeline-stop.is-active .timeline-bubble {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0);
}

.timeline-stop:hover .timeline-dot,
.timeline-stop:focus-within .timeline-dot,
.timeline-stop.is-active .timeline-dot {
  background: #111111;
}

.postcards-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 26px;
  max-width: 1280px;
  margin: 0 auto;
}

.postcard-card {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(240px, 0.85fr);
  gap: 18px;
  padding: 18px;
  border: 1px solid var(--paper-line);
  border-radius: 28px;
  background: var(--paper);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.04);
}

.postcard-stack {
  position: relative;
  height: 360px;
  isolation: isolate;
  overflow: visible;
}

.postcard-photo {
  position: relative;
  height: 100%;
  min-height: 0;
  z-index: 4;
}

.fan-thumb {
  position: absolute;
  inset: 34px 44px 34px 44px;
  min-height: 0;
  z-index: 1;
  opacity: 0;
  pointer-events: none;
  transition: transform 220ms ease, opacity 220ms ease;
}

.fan-thumb .photo-frame {
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.08);
}

.fan-thumb:hover,
.fan-thumb:focus-within {
  z-index: 6;
}

.fan-thumb:hover .photo-frame,
.fan-thumb:focus-within .photo-frame {
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.16);
}

.fan-thumb-1 {
  z-index: 3;
  transform: translate(-18px, -14px) rotate(-6deg);
}

.fan-thumb-2 {
  z-index: 2;
  transform: translate(-34px, -4px) rotate(-12deg);
}

.fan-thumb-3 {
  z-index: 1;
  transform: translate(-46px, 8px) rotate(-18deg);
}

.fan-thumb.has-image {
  opacity: 1;
  pointer-events: auto;
}

.postcard-card:hover .fan-thumb,
.postcard-card:focus-within .fan-thumb,
.postcard-card.is-open .fan-thumb {
  opacity: 1;
  pointer-events: auto;
}

.postcard-card:hover .fan-thumb-1,
.postcard-card:focus-within .fan-thumb-1,
.postcard-card.is-open .fan-thumb-1 {
  transform: translate(-86px, -40px) rotate(-10deg);
}

.postcard-card:hover .fan-thumb-2,
.postcard-card:focus-within .fan-thumb-2,
.postcard-card.is-open .fan-thumb-2 {
  transform: translate(-126px, -8px) rotate(-18deg);
}

.postcard-card:hover .fan-thumb-3,
.postcard-card:focus-within .fan-thumb-3,
.postcard-card.is-open .fan-thumb-3 {
  transform: translate(-156px, 30px) rotate(-25deg);
}

.postcard-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 8px 6px;
}

.postcard-copy h2 {
  font-size: clamp(1.6rem, 2vw, 2.3rem);
}

.editable-label {
  margin: 0 0 6px;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-soft);
}

.editable-line,
.editable-text {
  width: 100%;
  border: 1px solid rgba(17, 17, 17, 0.1);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.8);
  color: #111111;
  font: inherit;
  padding: 12px 14px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.editable-line {
  margin: 0 0 12px;
}

.editable-text {
  min-height: 132px;
  resize: vertical;
  line-height: 1.6;
}

.postcard-place-input {
  font-size: 0.82rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-soft);
}

.postcard-title-input {
  font-size: clamp(1.35rem, 2vw, 2rem);
  line-height: 1.05;
  font-weight: 600;
}

.editable-line:focus,
.editable-text:focus {
  outline: 2px solid rgba(17, 17, 17, 0.12);
  border-color: rgba(17, 17, 17, 0.18);
}

@media (max-width: 980px) {
  .page-shell {
    gap: 10px;
    min-height: auto;
  }

  .home-shell {
    height: auto;
    overflow: visible;
  }

  .home-intro {
    position: relative;
    inset: auto;
    padding: 48px 16px 18px;
    margin-bottom: 8px;
  }

  .home-intro::before {
    top: 46%;
    width: calc(100% - 20px);
    min-height: 180px;
  }

  .home-scroll {
    position: static;
    transform: none;
  }

  .home-intro h1 {
    max-width: 10ch;
  }

  .menu-toggle {
    top: 12px;
    right: 12px;
  }

  .memory-board {
    border-right: 3px solid var(--line);
  }

  .side-nav {
    top: 12px;
    right: 12px;
    width: min(240px, calc(100vw - 24px));
  }

  .side-nav nav {
    padding: 16px;
  }

  .postcards-grid {
    grid-template-columns: 1fr;
  }

  .timeline-track {
    grid-template-columns: 1fr 1fr;
    row-gap: 24px;
    padding-top: 84px;
  }

  .timeline-track::before {
    top: 96px;
  }

  .things-board {
    grid-template-columns: 1fr 1fr;
  }

  .thing-note:hover,
  .thing-note:focus-within {
    min-height: 300px;
  }

  .envelope-scene {
    height: 760px;
  }

  .site-lock-card {
    padding: 22px;
  }
}

@media (max-width: 720px) {
  .memory-board {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(4, 200px);
  }

  .menu-toggle {
    top: 10px;
    right: 10px;
    padding: 10px 13px;
    gap: 8px;
  }

  .menu-toggle-text {
    font-size: 0.9rem;
  }

  .side-nav {
    top: 10px;
    right: 10px;
    left: 10px;
    width: auto;
  }

  .side-nav nav {
    padding: 14px;
  }

  .travels-section,
  .timeline-section,
  .things-section,
  .letter-section {
    padding-left: 12px;
    padding-right: 12px;
  }

  .travels-header,
  .timeline-header,
  .things-header,
  .letter-header {
    margin-bottom: 18px;
  }

  .travels-header h1,
  .timeline-header h1,
  .things-header h1,
  .letter-header h1 {
    font-size: clamp(2.2rem, 11vw, 3.2rem);
    line-height: 0.98;
  }

  .travels-copy,
  .timeline-copy,
  .things-copy,
  .postcard-copy p {
    font-size: 0.98rem;
    line-height: 1.55;
  }

  .home-intro {
    padding: 28px 10px 8px;
  }

  .home-intro::before {
    top: 44%;
    min-height: 138px;
    width: calc(100% - 10px);
  }

  .home-intro-kicker {
    font-size: 0.75rem;
    letter-spacing: 0.16em;
  }

  .home-intro h1 {
    max-width: 8ch;
    font-size: clamp(2.8rem, 12vw, 4.4rem);
    line-height: 0.9;
  }

  .home-scroll span:first-child {
    font-size: 0.72rem;
  }

  .home-scroll {
    display: none;
  }

  .photo-preview {
    cursor: default;
    touch-action: auto;
  }

  .postcard-card {
    grid-template-columns: 1fr;
    gap: 14px;
    padding: 14px;
  }

  .postcard-stack {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    height: auto;
  }

  .postcard-photo {
    height: 280px;
  }

  /* Mobile: solo foto principale visibile. Le 3 secondarie appaiono in riga al tap. */
  .fan-thumb {
    position: relative;
    inset: auto;
    display: none;
    opacity: 1;
    pointer-events: auto;
    transform: none !important;
  }

  /* Quando la card è aperta: griglia 3 colonne — foto principale in riga 1, 3 thumb in riga 2 */
  .postcard-card.is-open .postcard-stack {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .postcard-card.is-open .postcard-photo.fan-main {
    grid-column: 1 / -1;
  }

  .postcard-card.is-open .fan-thumb {
    display: block;
    height: 130px;
  }

  .fan-thumb .photo-frame {
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.08);
  }

  /* Badge "altre foto" sulla foto principale quando ci sono secondarie caricate */
  .postcard-stack:has(.fan-thumb.has-image) .postcard-photo.fan-main::after {
    content: "altre foto";
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.52);
    color: #fff;
    font-size: 0.7rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    padding: 5px 10px;
    border-radius: 999px;
    pointer-events: none;
    z-index: 2;
  }

  .postcard-card.is-open .postcard-photo.fan-main::after {
    display: none;
  }

  .postcard-copy {
    padding: 0;
  }

  .editable-text {
    min-height: 112px;
  }

  .timeline-track {
    grid-template-columns: 1fr;
    row-gap: 16px;
    padding-top: 20px;
  }

  .timeline-track::before {
    display: none;
  }

  .timeline-stop {
    align-items: flex-start;
    min-height: auto;
    padding-left: 28px;
  }

  .timeline-bubble {
    position: relative;
    left: 0;
    top: 0;
    width: 100%;
    transform: none;
    opacity: 1;
    pointer-events: auto;
    margin-bottom: 10px;
    border-radius: 16px;
    padding: 16px 16px 18px;
  }

  /* Il selettore desktop .timeline-stop.is-active .timeline-bubble applica
     translate(-50%, 0) — va azzerato qui con pari specificità ma ordine successivo */
  .timeline-stop.is-active .timeline-bubble,
  .timeline-stop:hover .timeline-bubble,
  .timeline-stop:focus-within .timeline-bubble {
    transform: none;
  }

  .timeline-bubble h2 {
    font-size: 1.18rem;
  }

  .timeline-dot {
    position: absolute;
    left: 0;
    top: 22px;
    margin-top: 0;
    width: 16px;
    height: 16px;
    box-shadow: 0 0 0 5px #ffffff;
    pointer-events: none;
  }

  .timeline-label {
    margin-top: 0;
    max-width: none;
    text-align: left;
    font-size: 0.95rem;
  }

  .timeline-stamp {
    max-width: none;
    text-align: left;
    font-size: 0.78rem;
  }

  .things-board {
    grid-template-columns: 1fr;
  }

  .thing-note {
    min-height: 120px;
  }

  .thing-note:hover,
  .thing-note:focus-within {
    min-height: 0;
    transform: none;
  }

  .thing-note-body {
    max-height: 520px;
    opacity: 1;
    transform: none;
    margin-top: 12px;
  }

  .letter-section {
    padding: 28px 12px 48px;
  }

  /* Layout busta mobile: grid con lettera nella riga 1 e busta+bottone nella riga 2 */
  .envelope-scene {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: auto 220px;
    height: auto;
    margin-top: 20px;
    gap: 16px;
  }

  /* Lettera: nascosta con max-height, si apre con transizione */
  .letter-sheet {
    grid-row: 1;
    grid-column: 1;
    position: relative;
    left: auto;
    bottom: auto;
    width: 100%;
    transform: none;
    opacity: 0;
    max-height: 0;
    overflow: hidden;
    margin-bottom: 0;
    transition: max-height 500ms cubic-bezier(0.22, 1, 0.36, 1), opacity 320ms ease;
  }

  .envelope-scene.is-open .letter-sheet {
    transform: none;
    opacity: 1;
    max-height: 900px;
    z-index: auto;
  }

  .letter-page {
    height: auto;
    overflow: visible;
    padding: 18px;
    border-radius: 22px;
  }

  .letter-copy {
    max-height: 260px;
    overflow-y: auto;
    padding-right: 6px;
    font-size: 0.98rem;
    line-height: 1.68;
  }

  .letter-polaroid {
    max-width: 200px;
    margin: 16px auto 0;
    padding: 8px 8px 14px;
  }

  /* Busta: nella riga 2 del grid */
  .envelope {
    grid-row: 2;
    grid-column: 1;
    position: relative;
    left: auto;
    bottom: auto;
    width: 100%;
    height: 220px;
    transform: none;
  }

  /* Bottone centrato sulla busta: stessa riga del grid, align-self center */
  .envelope-open-button {
    grid-row: 2;
    grid-column: 1;
    position: relative;
    left: auto;
    bottom: auto;
    transform: none;
    align-self: center;
    justify-self: center;
    width: 84px;
    height: 84px;
    z-index: 3;
  }

  .site-lock {
    padding: 14px;
  }

  .site-lock-card {
    padding: 18px;
    border-radius: 22px;
  }
}

/* Touch device fixes (pointer: coarse = touchscreen) */
@media (pointer: coarse) {
  /* Bottoni replace/reset sempre visibili su touch (non dipendono da :hover) */
  .photo-card.has-image .replace-button,
  .shared-card.has-image .reset-button {
    opacity: 1;
    pointer-events: auto;
  }

  .replace-button,
  .reset-button {
    width: 32px;
    height: 32px;
    bottom: 8px;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  }

  .replace-button { right: 48px; }
  .reset-button { right: 8px; }

  .replace-button::before,
  .reset-button::before {
    width: 12px;
    height: 12px;
  }

  /* Previene lo zoom automatico su iOS (richiede font-size >= 16px) */
  .postcard-place-input {
    font-size: 1rem;
    letter-spacing: 0.06em;
  }

  /* Note sempre espanse su touch — non c'è hover */
  .thing-note-body {
    max-height: 520px;
    opacity: 1;
    transform: none;
    margin-top: 12px;
  }

  .thing-note:hover,
  .thing-note:focus-within {
    min-height: 0;
    transform: none;
    box-shadow: 0 16px 24px rgba(0, 0, 0, 0.14);
  }
}

@media (max-width: 460px) {
  .page-shell {
    padding: 4px;
  }

  .home-intro {
    padding: 20px 8px 6px;
  }

  .home-intro::before {
    width: calc(100% - 8px);
    min-height: 128px;
    border-radius: 22px;
  }

  .home-intro h1 {
    font-size: clamp(2.25rem, 12vw, 3.4rem);
  }

  .home-scroll {
    display: none;
  }

  .memory-board {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(4, 155px);
  }

  .travels-section {
    padding: 18px 10px 24px;
  }

  .timeline-section {
    padding: 18px 10px 26px;
  }

  .things-section {
    padding: 18px 10px 26px;
  }

  .letter-section {
    padding: 18px 10px 30px;
  }

  .envelope-scene {
    height: auto;
    grid-template-rows: auto 200px;
    gap: 12px;
  }

  .letter-page {
    height: auto;
  }

  .envelope-scene.is-open .letter-sheet {
    transform: none;
  }

  .postcard-card {
    padding: 12px;
    gap: 12px;
  }

  .postcard-stack {
    grid-template-columns: 1fr;
    gap: 8px;
    height: auto;
  }

  .postcard-photo {
    height: 220px;
  }

  .postcard-card.is-open .fan-thumb {
    height: 100px;
  }

  .timeline-bubble {
    padding: 14px;
    border-radius: 16px;
  }

  .timeline-bubble h2 {
    font-size: 1.08rem;
  }

  .things-board {
    padding: 14px;
    border-radius: 24px;
  }

  .thing-note {
    min-height: 120px;
    padding: 16px;
  }

  .thing-note h2 {
    font-size: 1.35rem;
  }
}
