.keepsake {
  --keepsake-ink: #4c382b;
  --keepsake-muted: #86735e;
  --keepsake-paper: #f5ecd7;
  --keepsake-green: #6a7760;
  box-sizing: border-box;
  width: 100%;
  color: var(--keepsake-ink);
  font-family: inherit;
}

.keepsake *, .keepsake *::before, .keepsake *::after { box-sizing: border-box; }
.keepsake-intro, .keepsake-footnote { text-align: center; }
.keepsake-intro { margin: 0 0 26px; font-size: 14px; line-height: 1.8; letter-spacing: .08em; }
.keepsake-footnote { margin: 18px 0 0; color: var(--keepsake-muted); font-size: 12px; line-height: 1.8; }
.keepsake-icon { flex: 0 0 auto; width: 19px; height: 19px; }
.keepsake-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 15px;
  border: 1px solid #9f8c6a70;
  border-radius: 4px;
  background: #f7efdf;
  color: var(--keepsake-ink);
  font: inherit;
  font-size: 13px;
  letter-spacing: .04em;
  cursor: pointer;
  transition: background 160ms, transform 160ms, border-color 160ms;
}
.keepsake-button:hover:not(:disabled) { background: #ece0c7; border-color: #9f8c6a; }
.keepsake-button:active:not(:disabled) { transform: translateY(1px); }
.keepsake-button:focus-visible { outline: 3px solid #778467; outline-offset: 4px; }
.keepsake-button:disabled { opacity: .45; cursor: default; }

/* Cloth cover, curved paper, and a physical leaf keep the album a book. */
.album-stage { padding: 10px 7px 22px; perspective: 1600px; }
.album-book {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  width: min(100%, 700px);
  margin: 0 auto;
  border: 8px solid #756846;
  border-top-width: 6px;
  border-bottom-width: 10px;
  border-radius: 7px 9px 9px 7px;
  background: #756846;
  box-shadow: 0 3px 0 #4d442f, 0 7px 0 -2px #b4a27b, 0 12px 0 -6px #685738, 1px 21px 25px -11px #3d2b2a55;
  transform-style: preserve-3d;
}
.album-book::after {
  content: '';
  position: absolute;
  inset: 0 auto 0 50%;
  z-index: 3;
  width: 2px;
  background: #6d553f4d;
  pointer-events: none;
}
.album-page-slot { min-width: 0; }
.album-page {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 290px;
  padding: 29px 23px 35px;
  background-color: var(--keepsake-paper);
  border-bottom: 2px solid #d1bda0;
}
.album-page--left { background-image: linear-gradient(90deg, #fcf5e8 0%, #f6edda 87%, #aa92793b 100%); border-radius: 3px 0 0 4px; }
.album-page--right { background-image: linear-gradient(90deg, #aa92793b 0%, #f6edda 12%, #fbf3e3 100%); border-radius: 0 4px 4px 0; }
.album-photo { width: 100%; margin: 0; padding: 10px 10px 13px; background: #fffcf3; box-shadow: 0 2px 6px #51432d1a; transform: rotate(-3deg); }
.album-page--right .album-photo { transform: rotate(3deg); }
.album-photo-frame { width: 100%; aspect-ratio: 4 / 4.3; background: #e5dfcf; }
.album-image { display: block; width: 100%; height: 100%; object-fit: cover; }
.album-photo-placeholder { display: flex; height: 100%; min-height: 100px; align-items: center; justify-content: center; flex-direction: column; gap: 12px; color: #887e67; background: linear-gradient(150deg, #e2ddcc, #eee8d9); }
.album-photo-placeholder .keepsake-icon { width: 32px; height: 32px; opacity: .65; stroke-width: 1; }
.album-placeholder-title { font-size: 12px; letter-spacing: .12em; }
.album-caption { min-height: 34px; padding-top: 12px; text-align: center; color: #7b6853; font-size: 12px; line-height: 1.65; overflow-wrap: anywhere; white-space: pre-wrap; }
.album-page-number { position: absolute; bottom: 12px; color: #ad9a7c; font-size: 10px; letter-spacing: .12em; }
.album-bookmark { position: absolute; right: 27px; bottom: -27px; z-index: 0; width: 16px; height: 34px; background: #975746; clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 78%, 0 100%); }
.album-navigation { display: flex; align-items: center; justify-content: center; gap: 20px; margin-top: 8px; }
.album-page-count { min-width: 86px; text-align: center; color: #8c775c; font-size: 12px; font-variant-numeric: tabular-nums; letter-spacing: .04em; }
.album-nav-button { min-width: 106px; }
.album-hint { margin-top: 12px; }
.album-turning-leaf { position: absolute; top: 0; bottom: 0; z-index: 5; width: 50%; transform-style: preserve-3d; pointer-events: none; }
.album-turning-leaf--next { left: 50%; transform-origin: left center; animation: album-turn-next 660ms cubic-bezier(.4, .04, .2, 1) both; }
.album-turning-leaf--previous { left: 0; transform-origin: right center; animation: album-turn-previous 660ms cubic-bezier(.4, .04, .2, 1) both; }
.album-leaf-face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.album-leaf-back { transform: rotateY(180deg); }
.album-leaf-face .album-page { box-shadow: 0 1px 6px #5e4c4133; }
@keyframes album-turn-next { to { transform: rotateY(-180deg); } }
@keyframes album-turn-previous { to { transform: rotateY(180deg); } }

/* A folded sheet of paper, with enough room for a real letter. */
.keepsake--letter { padding: 6px 8px 0; }
.letter-paper {
  position: relative;
  width: min(100%, 630px);
  margin: 0 auto;
  padding: 34px clamp(25px, 6vw, 58px) 48px;
  background: #faf1df;
  background-image: linear-gradient(90deg, transparent 49.7%, #80643c08 50%, transparent 50.3%), linear-gradient(transparent 49.8%, #80643c06 50%, transparent 50.2%);
  box-shadow: 0 2px 5px #6d4f2712, 0 16px 30px -18px #65442566;
  border: 1px solid #cfb79155;
  transform: rotate(-.7deg);
}
.letter-paper::before { content: ''; position: absolute; inset: 10px; border: 1px solid #bca57f40; pointer-events: none; }
.letter-paper-date { display: block; margin-bottom: 33px; text-align: right; color: #a49175; font-size: 11px; letter-spacing: .1em; }
.letter-salutation { position: relative; margin: 0 0 20px; font: inherit; font-size: 20px; line-height: 1.7; font-weight: 500; white-space: pre-wrap; overflow-wrap: anywhere; }
.letter-body { position: relative; font-size: 15px; line-height: 2.15; letter-spacing: .025em; }
.letter-body p { margin: 0 0 17px; white-space: pre-wrap; overflow-wrap: anywhere; }
.letter-empty { color: #8d7b63; }
.letter-signature { position: relative; margin: 31px 0 0; text-align: right; font-size: 18px; line-height: 1.7; white-space: pre-wrap; overflow-wrap: anywhere; }
.letter-seal { display: grid; place-items: center; width: 42px; height: 42px; margin-top: 5px; border: 3px double #be7762; border-radius: 50%; color: #b66a56; font-size: 21px; line-height: 1; font-style: italic; opacity: .7; transform: rotate(-17deg); overflow: hidden; }
.letter-draft { font-size: 11px; }

/* The reels rotate only in response to the actual audio playing event. */
.keepsake--tape { text-align: center; padding: 17px 0 0; }
.tape-cassette {
  position: relative;
  width: min(100%, 420px);
  aspect-ratio: 1.6;
  margin: 0 auto 35px;
  padding: 20px 23px 43px;
  border: 2px solid #504e3d;
  border-radius: 12px;
  background: repeating-linear-gradient(0deg, #717060 0, #717060 1px, #757365 1px, #757365 3px);
  box-shadow: inset 0 2px 1px #c7c1a157, inset 0 -7px 0 #46493a55, 0 15px 20px -11px #34291f77;
  transform: rotate(-4deg);
}
.tape-label { position: relative; z-index: 1; height: 100%; padding: 12px 16px 8px; border: 1px solid #b5a37f; border-radius: 8px 8px 27px 27px; background: #efe5c8; box-shadow: 0 1px 3px #1e211b44; }
.tape-label-top { display: flex; align-items: center; gap: 9px; color: #5e6951; }
.tape-side { display: grid; place-items: center; width: 22px; height: 22px; border: 1px solid currentColor; font-family: Georgia, serif; font-size: 17px; }
.tape-label-note { font-size: 10px; letter-spacing: .08em; }
.tape-title { display: block; margin: 7px 0 10px; padding-bottom: 5px; border-bottom: 1px solid #b5a37f; font-size: clamp(13px, 2.5vw, 19px); letter-spacing: .12em; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
.tape-window { display: flex; position: relative; align-items: center; justify-content: space-between; width: 88%; height: 54px; margin: auto; padding: 0 9px; border: 4px solid #93917c; border-radius: 22px; background: #444b40; box-shadow: inset 0 2px 4px #20231f88; }
.tape-reel { position: relative; z-index: 1; width: 36px; height: 36px; flex: 0 0 auto; border: 7px solid #dfd9c5; border-radius: 50%; background: repeating-conic-gradient(#484b3e 0deg 35deg, #d1cbb5 35deg 60deg); box-shadow: 0 0 0 2px #373e36; animation: tape-reel-spin 3s linear infinite; animation-play-state: paused; }
.tape-reel::after { content: ''; position: absolute; inset: 6px; border-radius: 50%; background: #3b4237; }
.tape-track { width: 45%; height: 22px; border: 2px solid #3b3b32; background: repeating-linear-gradient(0deg, #6c533d 0, #6c533d 1px, #4d4031 1px, #4d4031 3px); }
.tape-cassette--playing .tape-reel { animation-play-state: running; }
.tape-label-footer { display: block; margin-top: 9px; color: #7b7b61; font-family: Georgia, serif; font-size: 8px; letter-spacing: .19em; white-space: nowrap; overflow: hidden; }
.tape-screw { position: absolute; z-index: 2; width: 6px; height: 6px; border: 1px solid #3c4033; border-radius: 50%; background: linear-gradient(45deg, #9b9c84 40%, #414638 42%, #414638 55%, #9b9c84 57%); }
.tape-screw--tl { top: 8px; left: 8px; } .tape-screw--tr { top: 8px; right: 8px; } .tape-screw--bl { bottom: 9px; left: 8px; } .tape-screw--br { bottom: 9px; right: 8px; }
.tape-lower { display: flex; position: absolute; align-items: center; justify-content: space-between; left: 25%; right: 25%; bottom: 2px; height: 27px; padding: 0 17px; border: 1px solid #4c5141; background: #656857; clip-path: polygon(10% 0, 90% 0, 100% 100%, 0 100%); }
.tape-hole { width: 10px; height: 10px; border: 1px solid #a8a990; border-radius: 50%; background: #353b31; }
.tape-recording-title { margin: 0; font: inherit; font-size: 20px; font-weight: 500; letter-spacing: .08em; overflow-wrap: anywhere; }
.tape-status { min-height: 24px; margin: 12px 0 22px; color: var(--keepsake-muted); font-size: 13px; line-height: 1.8; }
.tape-play { min-width: 170px; color: #faf1dc; border-color: #67705b; background: #737e64; }
.tape-play:hover:not(:disabled) { background: #616d55; border-color: #56634c; }
.tape-play:disabled { opacity: .7; }
.tape-audio { display: block; width: min(100%, 360px); height: 36px; margin: 22px auto 0; }
@keyframes tape-reel-spin { to { transform: rotate(360deg); } }

.keepsake--mystery { text-align: center; padding: 10px 0 14px; }
.keepsake-gift { position: relative; width: 215px; height: 196px; margin: 16px auto 34px; transform: rotate(-5deg); }
.keepsake-gift-box { position: absolute; left: 13px; right: 13px; bottom: 0; height: 135px; border: 1px solid #a89066; border-radius: 0 0 4px 4px; background: repeating-linear-gradient(45deg, transparent 0 12px, #fcf5d91f 12px 13px), #c5ae7c; box-shadow: inset 0 13px 9px -10px #59442f77, 4px 15px 20px -10px #6542254d; }
.keepsake-gift-ribbon { position: absolute; top: 0; bottom: 0; left: 42%; width: 30px; background: #6c785e; border-right: 2px solid #899078; border-left: 2px solid #899078; }
.keepsake-gift-lid { position: absolute; top: 55px; left: 3px; right: 3px; height: 26px; border: 1px solid #a98f60; border-radius: 2px; background: linear-gradient(90deg, #d6c28e 42%, #7a8569 42%, #7a8569 57%, #d6c28e 57%); box-shadow: 0 4px 4px #6e5a3933; }
.keepsake-gift-bow { position: absolute; left: 48%; top: 6px; width: 4px; height: 60px; }
.keepsake-gift-bow::after { content: ''; position: absolute; top: 40px; left: -6px; z-index: 2; width: 21px; height: 15px; border-radius: 4px; background: #626e50; }
.keepsake-gift-loop { position: absolute; top: 0; width: 57px; height: 37px; border: 10px solid #7e896a; border-radius: 70% 80% 40% 80%; box-shadow: inset 0 0 3px #49543e44; }
.keepsake-gift-loop--left { right: -2px; transform: rotate(35deg); transform-origin: bottom right; }
.keepsake-gift-loop--right { left: 0; transform: rotate(-39deg) scaleX(-1); transform-origin: bottom left; }
.keepsake-gift-tag { position: absolute; right: 20px; top: 25px; display: grid; place-items: center; width: 39px; height: 53px; background: #f2e8cb; color: #7d7157; box-shadow: 2px 2px 2px #6e573e22; font-family: Georgia, serif; font-size: 24px; transform: rotate(13deg); clip-path: polygon(0 13%, 50% 0, 100% 13%, 100% 100%, 0 100%); overflow: hidden; }
.keepsake-mystery-message { max-width: 420px; margin: 0 auto; font: inherit; font-size: clamp(20px, 3vw, 26px); line-height: 1.9; letter-spacing: .06em; overflow-wrap: anywhere; }
.keepsake-mystery-note { margin: 18px 0 0; color: #7e6d57; font-size: 14px; line-height: 1.9; }

@media (max-width: 520px) {
  .keepsake-intro { margin-bottom: 18px; font-size: 12px; }
  .album-stage { padding: 6px 0 18px; }
  .album-book { border-width: 5px; border-bottom-width: 7px; }
  .album-page { min-height: 220px; padding: 24px 10px 31px; }
  .album-photo { padding: 5px 5px 8px; }
  .album-photo-frame { aspect-ratio: 3 / 4; }
  .album-caption { padding-top: 9px; font-size: 10px; min-height: 40px; }
  .album-photo-placeholder { min-height: 105px; gap: 9px; }
  .album-placeholder-title { font-size: 10px; letter-spacing: 0; }
  .album-photo-placeholder .keepsake-icon { width: 25px; height: 25px; }
  .album-navigation { gap: 7px; }
  .album-nav-button { min-width: 86px; padding: 9px 8px; font-size: 12px; gap: 4px; }
  .album-page-count { min-width: 68px; font-size: 10px; }
  .album-bookmark { right: 16px; width: 12px; }
  .keepsake--letter { padding: 2px 3px 0; }
  .letter-paper { padding: 27px 25px 32px; }
  .letter-paper-date { margin-bottom: 25px; font-size: 10px; }
  .letter-salutation { font-size: 18px; }
  .letter-body { font-size: 14px; line-height: 2.05; }
  .letter-signature { font-size: 17px; }
  .tape-cassette { width: 92%; min-width: 0; padding: 15px 17px 34px; }
  .tape-label { padding: 8px 10px 7px; }
  .tape-label-top { gap: 6px; }
  .tape-side { width: 17px; height: 17px; font-size: 13px; }
  .tape-label-note { font-size: 8px; }
  .tape-title { margin: 5px 0 7px; font-size: 14px; }
  .tape-window { height: 42px; border-width: 3px; padding: 0 6px; }
  .tape-reel { width: 28px; height: 28px; border-width: 5px; }
  .tape-reel::after { inset: 5px; }
  .tape-track { height: 17px; }
  .tape-label-footer { margin-top: 6px; font-size: 6px; }
  .tape-lower { height: 23px; }
  .tape-recording-title { font-size: 18px; }
  .tape-status { font-size: 12px; }
  .keepsake-mystery-message { font-size: 20px; }
  .keepsake-mystery-note { font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .keepsake *, .keepsake *::before, .keepsake *::after { animation: none !important; transition: none !important; }
}
