:root {
  color-scheme: light;
  --paper: #f9f1e6;
  --card: #fffaf2;
  --ink: #3d2530;
  --muted: #715660;
  --accent: #923247;
  --accent-dark: #742638;
  --line: #e8d7ca;
  --serif: Georgia, "Batang", "AppleMyungjo", serif;
  --sans: "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  min-height: 100svh;
  margin: 0;
  color: var(--ink);
  font-family: var(--sans);
  background: radial-gradient(ellipse at 8% 8%, #f5dfd2 0, transparent 54%), var(--paper);
}
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .46; }
:focus-visible { outline: 3px solid #95314b; outline-offset: 4px; }
h1[tabindex], h2[tabindex] { outline: none; }
p { margin: 0; }
svg, img { display: block; }

.shell {
  width: min(calc(100% - 64px), 1120px);
  min-height: 100svh;
  margin: auto;
  display: flex;
  flex-direction: column;
}
.masthead, .foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.masthead {
  min-height: 86px;
  justify-content: flex-end;
  border-bottom: 1px solid var(--line);
}
.masthead-date, .eyebrow, .cover-index, .cover-note, .carousel-count, .tile-number {
  font: 700 11px/1.3 var(--sans);
  letter-spacing: .19em;
}
.masthead-date {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
}
.masthead-date i { width: 6px; height: 6px; border-radius: 50%; background: #ad5060; }
.foot {
  min-height: 67px;
  margin-top: auto;
  color: var(--muted);
  border-top: 1px solid var(--line);
  font-size: 12px;
}
.foot .signature { text-align: right; }
#scene { padding: 40px 0 42px; }
.loading { min-height: 490px; display: grid; place-items: center; color: var(--muted); }

.layout {
  min-height: 532px;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  border: 1px solid var(--line);
  border-radius: 25px;
  overflow: hidden;
  background: var(--card);
  box-shadow: 0 22px 44px #57212d0c;
}
.cover {
  position: relative;
  display: grid;
  align-items: center;
  padding: 35px 32px;
  color: var(--accent-dark);
  background:
    repeating-linear-gradient(125deg, transparent 0 4px, #8e3d4e09 4px 5px, transparent 5px 8px),
    radial-gradient(ellipse at 49% 47%, #f9ddc5 0, #efbcb0 100%);
}
.cover::before {
  content: "";
  position: absolute;
  inset: 18px;
  border: 1px solid #a7535d65;
  border-radius: 13px;
  pointer-events: none;
}
.cover-art { width: min(100%, 445px); justify-self: center; }
.heart-art { width: 100%; height: auto; overflow: visible; }
.cover-index, .cover-note {
  position: absolute;
  inset-inline: 35px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 11px;
}
.cover-index { top: 37px; }
.cover-note { bottom: 36px; }
.cover-note i, .progress i { height: 1px; flex: 1; background: currentColor; opacity: .32; }
.letter { align-self: center; padding: 52px clamp(28px, 5.4vw, 76px); }
.letter-meta { display: flex; align-items: center; justify-content: space-between; }
.envelope {
  width: 45px;
  height: 45px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  background: #f5e2dc;
  color: var(--accent);
}
.envelope svg { width: 25px; stroke: currentColor; stroke-width: 1.5; }
.progress {
  display: flex;
  align-items: center;
  width: 73px;
  gap: 8px;
  font: bold 12px var(--serif);
  color: var(--accent);
}
.eyebrow { color: var(--accent); margin-bottom: 12px; }
.letter .eyebrow { margin-top: 26px; }
h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(34px, 4.5vw, 56px);
  line-height: 1.16;
  letter-spacing: -.045em;
  word-break: keep-all;
}
h1 span { color: var(--accent); }
.intro { margin-top: 13px; color: var(--muted); font-size: 15px; line-height: 1.7; word-break: keep-all; }
.private-note {
  margin-top: 28px;
  padding: 15px 17px;
  background: #f7eee4;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--accent-dark);
  font-size: 14px;
}
.private-note p { margin-top: 6px; font-size: 13px; color: var(--muted); line-height: 1.6; }
.retry { margin-top: 15px; }
.letter form { margin-top: 29px; }
label { display: block; margin-bottom: 8px; font-size: 13px; font-weight: 750; }
input {
  width: 100%;
  min-height: 49px;
  padding: 11px 14px;
  background: #fffdf9;
  color: var(--ink);
  border: 1px solid #d7b9ad;
  border-radius: 9px;
}
input::placeholder { color: #795f65; }
input[aria-invalid] { border-color: var(--accent); }
.feedback { color: var(--accent-dark); font-size: 13px; line-height: 1.6; }
.letter .feedback { min-height: 29px; padding-top: 4px; }
.primary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  width: 100%;
  min-height: 47px;
  padding: 10px 15px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: var(--accent);
  color: #fff7ed;
  font-weight: 750;
  font-size: 14px;
}
.primary:hover:enabled { background: var(--accent-dark); }
.primary span { font-size: 19px; line-height: 1; }
.quiet-button {
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid transparent;
  border-radius: 9px;
  color: var(--accent-dark);
  background: transparent;
  font-size: 14px;
  font-weight: 750;
}
.quiet-button:hover { background: #f1dfd7; }
.quiet-button span { margin-inline: 4px; }

.portal, .gallery, .detail {
  min-height: 532px;
  border: 1px solid var(--line);
  border-radius: 25px;
  background: var(--card);
  box-shadow: 0 22px 44px #57212d0c;
}
.portal {
  position: relative;
  display: grid;
  justify-items: center;
  align-content: center;
  padding: 38px 18px 25px;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 62%, #f6d5bc, #f5dfd3 56%, #fff5e8);
}
.portal h1 { text-align: center; }
.portal-art {
  width: min(390px, 90vw);
  margin-top: -10px;
  margin-bottom: -26px;
  transform-origin: 50% 56%;
  animation: through-door 2.35s cubic-bezier(.54, 0, .55, 1) both;
  pointer-events: none;
}
.portal .quiet-button { position: relative; }
.portal .door-panel {
  transform-origin: 0 50%;
  transform-box: fill-box;
  animation: door-opens 1.1s .46s ease-in-out both;
}
@keyframes door-opens {
  0%, 16% { transform: scaleX(1); }
  100% { transform: scaleX(.12) skewY(-11deg); }
}
@keyframes through-door {
  0% { opacity: .25; transform: scale(.9); }
  26%, 52% { opacity: 1; transform: scale(1); }
  94%, 100% { opacity: 1; transform: scale(13); }
}

.gallery { padding: 37px 0 25px; text-align: center; background: #fff5e7; }
.gallery > :is(h1, p) { padding-inline: 16px; }
.carousel {
  --tile: 188px;
  position: relative;
  display: flex;
  gap: 16px;
  overflow-x: auto;
  margin-top: 19px;
  padding: 10px max(18px, calc((100% - var(--tile)) / 2));
  scroll-snap-type: x mandatory;
  overscroll-behavior-inline: contain;
  scrollbar-width: none;
}
.carousel::-webkit-scrollbar { display: none; }
.tile {
  flex: 0 0 var(--tile);
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 5px;
  padding: 14px 12px 16px;
  border: 1px solid #e7d2c0;
  border-radius: 15px;
  scroll-snap-align: center;
  color: var(--ink);
  background: #fffcf6;
}
.tile:hover, .tile:focus-visible { border-color: var(--accent); background: #fff9ee; }
.tile-number { justify-self: start; color: var(--muted); font-size: 9px; }
.tile .box-art { width: 126px; margin-block: -1px -3px; }
.tile-label { font-weight: 800; font-size: 15px; }
.tile-status { font-size: 12px; color: var(--accent-dark); }
.carousel-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 7px;
  color: var(--accent-dark);
}
.carousel-nav button {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fffcf6;
  color: inherit;
  font-size: 18px;
}
.carousel-nav button:hover:enabled { border-color: var(--accent); }

.detail { padding: 21px clamp(16px, 4vw, 50px) 29px; background: #fff5e7; }
.detail-layout {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  min-height: 425px;
  align-items: center;
  gap: clamp(20px, 4vw, 50px);
}
.tear-zone {
  min-height: 400px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  overflow: hidden;
  border-radius: 16px;
  background: #f5e0d1;
  touch-action: pan-y pinch-zoom;
  user-select: none;
  cursor: ew-resize;
}
.tear-zone .box-art {
  width: min(59%, 234px);
  overflow: visible;
  pointer-events: none;
  animation: box-zoom .35s ease-out both;
}
.tear-arrow {
  display: grid;
  place-items: center;
  width: 31px;
  height: 31px;
  border: 1px solid #d9acaa;
  border-radius: 50%;
  color: var(--accent-dark);
  font-size: 15px;
  pointer-events: none;
}
.detail-copy { padding: 10px 0; }
.detail .primary { max-width: 300px; margin-top: 20px; }
.detail .feedback:not(:empty) { padding-top: 8px; }
.box-inner-sticks { transform: translateY(10px); transition: transform .52s ease-out; }
.box-flap { transition: transform .15s ease-out; }
.pull-left .box-flap { transform: translateX(-6px) rotate(-2deg); }
.pull-right .box-flap { transform: translateX(6px) rotate(2deg); }
.is-open .box-inner-sticks { transform: translateY(-32px); }
.is-open .tear-zone { cursor: default; }
.is-open .tear-arrow { visibility: hidden; }
.opened-left .box-flap { animation: tear-left .52s ease-in both; }
.opened-right .box-flap { animation: tear-right .52s ease-in both; }
.message {
  position: relative;
  margin-top: 16px;
  padding: 19px 20px 21px;
  border: 1px solid #e6c9bf;
  border-radius: 13px;
  background: #fffcf6;
  animation: paper-appears .32s ease-out both;
}
.message-mark { position: absolute; top: 15px; right: 18px; color: var(--accent); font-size: 22px; }
.message h2 { margin: 0 25px 9px 0; color: var(--accent-dark); font: bold 21px var(--serif); }
.message p { line-height: 1.85; overflow-wrap: anywhere; white-space: pre-wrap; }
@keyframes box-zoom { from { transform: scale(.72); opacity: .6; } to { transform: scale(1); opacity: 1; } }
@keyframes tear-left { to { transform: translate(-58px, -36px) rotate(-13deg); opacity: 0; } }
@keyframes tear-right { to { transform: translate(58px, -36px) rotate(13deg); opacity: 0; } }
@keyframes paper-appears { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

@media (max-width: 700px) {
  .shell { width: calc(100% - 32px); }
  .masthead { min-height: 62px; }
  .masthead-date { font-size: 9px; gap: 4px; }
  #scene { padding: 19px 0 26px; }
  .layout, .detail-layout { grid-template-columns: 1fr; }
  .layout, .portal, .gallery, .detail { min-height: 0; border-radius: 17px; }
  .cover { min-height: 207px; padding: 12px 19px; }
  .cover::before { inset: 10px; border-radius: 9px; }
  .cover-index, .cover-note { inset-inline: 20px; font-size: 8px; }
  .cover-index { top: 21px; }
  .cover-note { bottom: 20px; }
  .cover-art { width: 208px; }
  .letter { padding: 23px 22px 25px; }
  .letter .eyebrow { margin-top: 17px; }
  .letter form { margin-top: 17px; }
  .envelope { width: 36px; height: 36px; border-radius: 10px; }
  .envelope svg { width: 21px; }
  h1 { font-size: clamp(29px, 7vw, 40px); }
  .intro { margin-top: 8px; font-size: 14px; }
  .foot { min-height: 52px; }
  .portal { min-height: 464px; }
  .gallery { padding-top: 27px; }
  .carousel { --tile: 168px; gap: 12px; }
  .tile .box-art { width: 114px; }
  .detail { padding: 10px 13px 17px; }
  .detail-layout { min-height: 0; gap: 13px; }
  .tear-zone { min-height: 255px; }
  .tear-zone .box-art { width: min(58%, 166px); }
  .detail-copy { padding: 4px 6px 8px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  .portal-art, .portal .door-panel { animation: none; }
}
