:root {
  --paper: #f2ece0;
  --paper-2: #f8f4ec;
  --paper-3: #e7dcc8;
  --ink: #1c1a17;
  --ink-2: #4a443c;
  --muted: #8a8175;
  --line: rgba(28, 26, 23, .12);
  --shu: #d2452b;
  --shu-d: #b73720;
  --serif: 'Instrument Serif', 'Times New Roman', serif;
  --sans: 'Space Grotesk', system-ui, sans-serif;
  --mono: 'Space Mono', ui-monospace, monospace;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --env-w: min(300px, 76vw);
  --env-h: calc(var(--env-w) * .64);
  --env-top: 24svh;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
body {
  background-color: var(--paper);
  background-image:
    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 .35 0 0 0 0 .27 0 0 0 0 .18 0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"),
    radial-gradient(120% 80% at 50% 0%, #f7f2e8 0%, var(--paper) 55%, #ebe2d1 100%);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
}
button, input, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
em { font-style: italic; }
.mono { font-family: var(--mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; }

#gl { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 1; pointer-events: none; }
main { position: relative; z-index: 2; }

/* ---------- screens ---------- */
.screen {
  position: fixed; inset: 0; height: 100svh;
  display: flex; flex-direction: column;
  opacity: 0; pointer-events: none; visibility: hidden;
  transform: translateY(14px);
  transition: opacity .55s ease, transform .7s cubic-bezier(.2, .8, .2, 1), visibility 0s .55s;
}
.screen.on { opacity: 1; pointer-events: auto; visibility: visible; transform: none; transition: opacity .55s ease .1s, transform .7s cubic-bezier(.2, .8, .2, 1) .1s, visibility 0s; }

.corner { position: absolute; top: calc(18px + env(safe-area-inset-top, 0px)); z-index: 3; color: var(--ink-2); }
.corner.tl { left: 20px; }
.corner.tr { right: 16px; top: calc(10px + env(safe-area-inset-top, 0px)); }

.icon-btn { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: var(--ink); }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

.btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  height: 54px; padding: 0 26px; border-radius: 16px;
  background: var(--ink); color: var(--paper-2);
  font-weight: 500; font-size: 17px; letter-spacing: .01em;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .15) inset, 0 10px 24px -12px rgba(28, 26, 23, .6);
  transition: transform .15s ease, background .2s ease, opacity .2s;
}
.btn:active { transform: translateY(2px) scale(.99); }
.btn.big { width: 100%; height: 58px; font-size: 18px; }
.btn.shu { background: var(--shu); box-shadow: 0 1px 0 rgba(255, 255, 255, .2) inset, 0 12px 26px -12px rgba(183, 55, 32, .75); }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--ink); }
.btn:disabled { opacity: .35; pointer-events: none; }
.link { display: block; margin: 12px auto 0; padding: 6px 10px; color: var(--ink-2); font-size: 15px; text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 1px; }

h1, h2 { font-family: var(--serif); font-weight: 400; letter-spacing: -.01em; }
h1 em, h2 em { color: var(--shu); }
.sub { color: var(--muted); margin-top: 6px; }

/* ---------- intro ---------- */
#intro { align-items: stretch; }
.intro-stage { position: relative; flex: 1; min-height: 200px; margin-top: 48px; }
.sun {
  position: fixed; z-index: 0; left: var(--sun-x, 50%); top: var(--sun-y, 35%);
  width: var(--sun-d, 60vw); aspect-ratio: 1; border-radius: 50%; pointer-events: none;
  transform: translate(-50%, -50%) scale(.2);
  background: radial-gradient(circle at 38% 34%, #e15a3d 0%, var(--shu) 55%, #b9381f 100%);
  opacity: 0;
  transition: transform 1.6s cubic-bezier(.16, 1, .3, 1) .2s, opacity 1s ease .2s;
}
body[data-screen="intro"] .sun { transform: translate(-50%, -50%) scale(1); opacity: 1; }
.sun { translate: var(--par-x, 0) var(--par-y, 0); box-shadow: inset -18px -24px 60px rgba(120, 20, 5, .28), inset 14px 16px 40px rgba(255, 190, 150, .25); }
body[data-screen="intro"] .sun { animation: sunBreath 7s ease-in-out 2s infinite; }
@keyframes sunBreath { 50% { filter: saturate(1.12) brightness(1.04); } }

/* ink-wash landscape behind the sun (intro only); fades out before the title */
.scenery {
  position: fixed; z-index: 0; left: 0; top: 0; width: 100%; height: var(--land-h, 60svh); pointer-events: none; overflow: hidden;
  opacity: 0; transition: opacity 1s ease;
}
body[data-screen="intro"] .scenery { opacity: 1; }
.scenery svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.scenery svg.defs { width: 0; height: 0; }
.scenery .layer { position: absolute; inset: 0; will-change: transform, opacity; transform: translateY(60px); opacity: 0; transition: transform 2.2s cubic-bezier(.16, 1, .3, 1) var(--d), opacity 1.6s ease var(--d); translate: calc(var(--par-x, 0px) * var(--k) * -2.4) 0; }
.scenery.risen .layer { transform: none; opacity: 1; }
.scenery .haze { animation: haze 8s ease-in-out infinite; transform-origin: center; transform-box: fill-box; }
@keyframes haze { 50% { opacity: .6; transform: scale(1.06); } }
.scenery .mist { fill: #fbf7ef; opacity: .75; animation: mist 46s linear infinite; }
.scenery .mist.m2 { animation-duration: 64s; animation-direction: reverse; opacity: .6; }
@keyframes mist { to { transform: translateX(calc(var(--W) * -0.75)); } }
.scenery .bird path { fill: none; stroke: #2a2520; stroke-width: 1.4; stroke-linecap: round; animation: flap .7s ease-in-out infinite alternate; transform-box: fill-box; transform-origin: center; }
.scenery .bird { animation: fly 34s linear infinite; animation-delay: calc(var(--b) * -8.5s); }
.scenery .bird:nth-child(2n) path { animation-duration: .55s; }
@keyframes flap { to { transform: scaleY(-.6); } }
@keyframes fly { from { transform: translate(-40px, var(--by)) scale(.9); } 50% { transform: translate(calc(var(--W) * .5), calc(var(--by) - 26px)) scale(1); } to { transform: translate(calc(var(--W) + 40px), calc(var(--by) + 8px)) scale(.8); } }
.petals { position: absolute; left: 0; right: 0; top: 96px; bottom: 18%; overflow: hidden; }
.petals i {
  position: absolute; top: -20px; left: var(--x); width: calc(9px * var(--s)); height: calc(6px * var(--s));
  background: #f2c4c4; border-radius: 80% 0 80% 0; opacity: .85; box-shadow: inset -1px -1px 0 rgba(180, 70, 90, .3);
  animation: petal calc(13s + var(--p) * 1.3s) linear infinite; animation-delay: calc(var(--p) * -2.1s);
}
@keyframes petal {
  0% { transform: translate(0, 0) rotate(0); opacity: 0; }
  10% { opacity: .85; }
  25% { transform: translate(30px, calc(var(--land-h, 60svh) * .18)) rotate(120deg); }
  50% { transform: translate(-10px, calc(var(--land-h, 60svh) * .36)) rotate(220deg); }
  75% { transform: translate(40px, calc(var(--land-h, 60svh) * .52)) rotate(320deg); opacity: .8; }
  100% { transform: translate(10px, calc(var(--land-h, 60svh) * .7)) rotate(420deg); opacity: 0; }
}

/* paper-cut sea inside the sun */
.sun { overflow: hidden; }
.wv { position: absolute; left: -60%; width: 220%; background-repeat: repeat-x; background-size: 11.111% 100%; will-change: transform; }
.w1 { bottom: 13%; height: 22%; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 100' preserveAspectRatio='none'%3E%3Cpath d='M0 50 C 25 28 75 28 100 50 C 125 63.2 175 63.2 200 50 L200 100 L0 100Z' fill='%23b9381f'/%3E%3C/svg%3E"); filter: drop-shadow(0 -3px 4px rgba(90, 20, 5, .35)); animation: drift 22s linear infinite; opacity: .9; }
.w2 { bottom: 3%; height: 22%; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 100' preserveAspectRatio='none'%3E%3Cpath d='M0 50 C 25 24 75 24 100 50 C 125 65.6 175 65.6 200 50 L200 100 L0 100Z' fill='%23e9b79b'/%3E%3C/svg%3E"); filter: drop-shadow(0 -4px 6px rgba(90, 20, 5, .4)); animation: drift 16s linear infinite reverse; }
.w3 { bottom: -8%; height: 24%; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 100' preserveAspectRatio='none'%3E%3Cpath d='M0 50 C 25 26 75 26 100 50 C 125 64.4 175 64.4 200 50 L200 100 L0 100Z' fill='%23f4ebdc'/%3E%3C/svg%3E"); filter: drop-shadow(0 -5px 8px rgba(90, 30, 10, .45)); animation: drift 12s linear infinite; }
@keyframes drift { to { transform: translateX(-33.33%); } }
.wv { translate: 0 120%; transition: translate 1.6s cubic-bezier(.16, 1, .3, 1); }
body[data-screen="intro"] .w1 { translate: 0 0; transition-delay: .5s; }
body[data-screen="intro"] .w2 { translate: 0 0; transition-delay: .65s; }
body[data-screen="intro"] .w3 { translate: 0 0; transition-delay: .8s; }

/* hand-painted ensō ring around the sun */
.enso {
  position: fixed; z-index: 0; pointer-events: none;
  left: var(--sun-x, 50%); top: var(--sun-y, 35%);
  width: calc(var(--sun-d, 60vw) * 1.3); height: calc(var(--sun-d, 60vw) * 1.3);
  transform: translate(-50%, -50%) rotate(-12deg);
  translate: calc(var(--par-x, 0) * -0.6) calc(var(--par-y, 0) * -0.6);
  opacity: 0; transition: opacity .6s ease;
}
.enso path { fill: none; stroke: var(--ink); stroke-linecap: round; stroke-dasharray: 1; stroke-dashoffset: 1; }
.enso-a { stroke-width: 4.6; opacity: .85; }
.enso-b { stroke-width: 1.6; opacity: .5; }
body[data-screen="intro"] .enso { opacity: 1; }
body[data-screen="intro"] .enso path { animation: ensoDraw 1.9s cubic-bezier(.65, 0, .25, 1) .5s forwards; }
body[data-screen="intro"] .enso-b { animation-delay: .62s; }
@keyframes ensoDraw { to { stroke-dashoffset: 0; } }

/* title letters unfold like paper flaps */
#intro .intro-copy > h1 { opacity: 1; transform: none; }
#intro h1 .ch { display: inline-block; transform-origin: 50% 0; opacity: 0; transform: perspective(500px) rotateX(-100deg); }
#intro.on h1 .ch { animation: unfoldCh 1s cubic-bezier(.2, .9, .25, 1.15) forwards; animation-delay: calc(1.25s + var(--i) * 60ms); }
@keyframes unfoldCh { 0% { opacity: 0; transform: perspective(500px) rotateX(-100deg); filter: brightness(.6); } 35% { opacity: 1; } 100% { opacity: 1; transform: none; filter: none; } }
.intro-copy { padding: 8px 24px calc(58px + var(--safe-b)); text-align: center; }
.intro-copy .eyebrow { color: var(--ink-2); margin-bottom: 8px; }
.intro-copy h1 { font-size: clamp(46px, 13.4vw, 84px); line-height: .95; white-space: nowrap; }
.intro-copy .lede { margin: 10px auto 22px; max-width: 300px; color: var(--ink-2); font-size: 16px; line-height: 1.4; }
.intro-copy > * { opacity: 0; transform: translateY(16px); }
#intro.on .intro-copy > * { opacity: 1; transform: none; transition: opacity .8s ease, transform .9s cubic-bezier(.2, .8, .2, 1); }
#intro.on .intro-copy > :nth-child(1) { transition-delay: 1.2s; }
#intro.on .intro-copy > :nth-child(2) { transition-delay: 1.35s; }
#intro.on .intro-copy > :nth-child(3) { transition-delay: 2.2s; }
#intro.on .intro-copy > :nth-child(4) { transition-delay: 2.45s; }
#intro.on .intro-copy > :nth-child(5) { transition-delay: 2.6s; }
@media (max-height: 700px) { .intro-copy .eyebrow { display: none; } .intro-stage { margin-top: 36px; } }

/* ---------- bars ---------- */
.bar { display: flex; align-items: center; justify-content: space-between; padding: calc(10px + env(safe-area-inset-top, 0px)) 12px 0 18px; height: calc(62px + env(safe-area-inset-top, 0px)); flex: none; }
.bar-r { display: flex; align-items: center; gap: 4px; }
.wordmark { font-family: var(--serif); font-size: 24px; }
.wordmark em { color: var(--shu); }
.pill { display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 8px 0 14px; border-radius: 999px; box-shadow: inset 0 0 0 1.3px var(--ink); font-weight: 500; font-size: 15px; transition: transform .2s; }
.pill svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; }
.pill b { min-width: 26px; height: 26px; border-radius: 999px; background: var(--ink); color: var(--paper-2); display: grid; place-items: center; font-size: 13px; font-weight: 500; padding: 0 7px; }
.pill.bump { animation: bump .5s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes bump { 40% { transform: scale(1.14); } }
.back { display: flex; align-items: center; gap: 2px; height: 40px; padding: 0 12px 0 0; font-size: 16px; font-weight: 500; }
.back svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- studio ---------- */
.stage { flex: 1; min-height: 140px; position: relative; touch-action: none; cursor: grab; }
.caption { text-align: center; display: flex; gap: 10px; justify-content: center; align-items: baseline; padding: 0 20px 12px; }
.caption .mono { color: var(--shu); }
.caption #capName { font-family: var(--serif); font-style: italic; font-size: 21px; }
.panel {
  flex: none; background: var(--paper-2);
  border-radius: 26px 26px 0 0;
  padding: 14px 0 calc(58px + var(--safe-b));
  box-shadow: 0 -1px 0 var(--line), 0 -18px 40px -24px rgba(60, 40, 20, .35);
}
.row-label { color: var(--muted); padding: 0 20px 8px; }
.swatches, .shapes { display: flex; gap: 10px; overflow-x: auto; padding: 4px 20px 14px; scrollbar-width: none; scroll-snap-type: x proximity; }
.swatches::-webkit-scrollbar, .shapes::-webkit-scrollbar { display: none; }
.sw {
  flex: none; width: 46px; height: 46px; border-radius: 6px;
  background-size: cover; background-position: center;
  box-shadow: 0 1px 2px rgba(60, 40, 20, .25), 0 6px 12px -8px rgba(60, 40, 20, .5);
  position: relative; scroll-snap-align: center;
  transition: transform .25s cubic-bezier(.3, 1.5, .5, 1);
}
.sw::after { /* dog-eared corner */
  content: ''; position: absolute; right: 0; top: 0; width: 12px; height: 12px;
  background: linear-gradient(225deg, var(--paper-2) 0 50%, rgba(255, 255, 255, .85) 50% 60%, #ddd2bf 60%);
  border-bottom-left-radius: 3px;
  box-shadow: -1px 1px 2px rgba(60, 40, 20, .2);
}
.sw.on { transform: translateY(-4px) rotate(-4deg); outline: 2px solid var(--ink); outline-offset: 3px; }
.sh {
  flex: none; width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center;
  box-shadow: inset 0 0 0 1.2px var(--line); scroll-snap-align: center;
  transition: background .2s, color .2s, transform .25s;
}
.sh svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.sh.on { background: var(--ink); color: var(--paper-2); box-shadow: none; transform: translateY(-2px); }
.panel .btn { width: calc(100% - 40px); margin: 2px 20px 0; }

.how {
  position: absolute; right: 16px; top: 4px; z-index: 2; display: flex; align-items: center; gap: 7px;
  height: 38px; padding: 0 14px 0 11px; border-radius: 999px; background: var(--paper-2);
  box-shadow: inset 0 0 0 1.2px var(--ink), 0 6px 14px -8px rgba(60, 40, 20, .5); font-weight: 500; font-size: 14px; cursor: pointer;
}
.how svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; }

/* ---------- how to fold: a printed instruction sheet ---------- */
.step-count { color: var(--muted); padding-right: 8px; }
.learn-title { font-size: clamp(30px, 9vw, 40px); line-height: 1; padding: 0 20px 12px; flex: none; }
.sheet {
  flex: 1; min-height: 0; overflow-y: auto; margin: 0 14px; padding: 14px 14px 18px; border-radius: 18px;
  background: var(--paper-2);
  box-shadow: 0 1px 2px rgba(60, 40, 20, .15), 0 18px 36px -22px rgba(60, 40, 20, .5);
  scrollbar-width: none; overscroll-behavior: contain; user-select: text; -webkit-user-select: text;
}
.sheet::-webkit-scrollbar { display: none; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; padding: 0 2px 12px; margin-bottom: 12px; font-size: 9.5px; color: var(--ink-2); border-bottom: 1px solid var(--line); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend svg { width: 26px; height: 8px; overflow: visible; }
.steps { list-style: none; display: grid; grid-template-columns: 1fr 1fr; gap: 18px 12px; counter-reset: st; }
.steps li { counter-increment: st; position: relative; }
.steps li::before {
  content: counter(st); position: absolute; left: 0; top: 0; z-index: 1;
  width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
  background: var(--shu); color: #fff; font-family: var(--mono); font-size: 11px;
}
.steps .fig {
  aspect-ratio: 1; border-radius: 10px; border: 1px solid var(--line);
  background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 14px 14px; background-position: center;
  display: grid; place-items: center; padding: 6px;
}
.steps .fig svg { width: 100%; height: 100%; overflow: visible; }
.steps p { margin-top: 7px; font-size: 13.5px; line-height: 1.32; color: var(--ink); }
.steps li.done .fig { background: none; border-style: dashed; padding: 0; }
.steps li.done img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 10px 10px rgba(60, 40, 20, .25)); }
.steps li.done p { font-family: var(--serif); font-style: italic; font-size: 19px; color: var(--shu); }
.pp { stroke: var(--ink); stroke-width: .7; stroke-linejoin: round; }
.ln { fill: none; stroke-linecap: round; }
.valley { fill: none; stroke: var(--shu); stroke-width: 1.2; stroke-dasharray: 3.2 2.2; }
.mountain { fill: none; stroke: var(--ink); stroke-width: 1.2; stroke-dasharray: 4 1.6 .6 1.6; }
.crease { fill: none; stroke: rgba(28, 26, 23, .3); stroke-width: .5; }
.cut { fill: none; stroke: var(--shu); stroke-width: 1.3; stroke-dasharray: 1.4 1.8; }
.arr { fill: none; stroke: var(--ink); stroke-width: 1.4; stroke-linecap: round; }
.head { fill: var(--ink); }
.flip text { font-family: var(--mono); font-size: 5px; letter-spacing: .12em; fill: var(--shu); }
.learn-nav { flex: none; padding: 14px 20px calc(58px + var(--safe-b)); }
@media (min-width: 700px) { .steps { grid-template-columns: repeat(3, 1fr); } .sheet, .learn-title, .learn-nav { max-width: 760px; width: 100%; margin-left: auto; margin-right: auto; } .sheet { width: calc(100% - 28px); } }

/* ---------- shelf ---------- */
.shelf-head { display: flex; align-items: baseline; justify-content: space-between; padding: 0 20px 10px; flex: none; }
.shelf-head h2 { font-size: 44px; line-height: 1; }
.shelf-head .mono { color: var(--muted); }
.shelf-box { flex: 1; min-height: 0; overflow-y: auto; margin: 0 12px; position: relative; scrollbar-width: none; overscroll-behavior: contain; }
.shelf-box::-webkit-scrollbar { display: none; }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); }
.cell { position: relative; aspect-ratio: 1 / 1.1; border-right: 1px solid var(--line); }
.cell:nth-child(3n) { border-right: 0; }
.cell::after { /* the shelf ledge */
  content: ''; position: absolute; left: -1px; right: -1px; bottom: 0; height: 8px;
  background: linear-gradient(#e2d4bb, #d3c2a3);
  box-shadow: 0 7px 10px -6px rgba(60, 40, 20, .45);
}
.cell .num { position: absolute; left: 8px; bottom: 14px; font-family: var(--mono); font-size: 9.5px; letter-spacing: .12em; color: var(--muted); }
.cell .x { position: absolute; top: 6px; right: 6px; width: 30px; height: 30px; border-radius: 50%; background: var(--ink); color: var(--paper-2); display: none; place-items: center; z-index: 2; }
.cell .x svg { width: 14px; height: 14px; stroke: currentColor; stroke-width: 2; fill: none; stroke-linecap: round; }
.cell.sel { background: rgba(210, 69, 43, .06); }
.cell.sel .x { display: grid; }
.cell .from { position: absolute; left: 8px; top: 6px; font-family: var(--serif); font-style: italic; font-size: 13px; color: var(--ink-2); max-width: 55%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.empty { position: absolute; inset: 0; display: none; place-items: center; text-align: center; color: var(--muted); font-family: var(--serif); font-style: italic; font-size: 26px; }
.shelf-box.is-empty .empty { display: grid; }
.actions { flex: none; padding: 14px 20px calc(58px + var(--safe-b)); }

/* ---------- send ---------- */
.send-form { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 14px; padding: 0 24px calc(58px + var(--safe-b)); max-width: 460px; width: 100%; margin: 0 auto; }
.send-form h2 { font-size: 42px; line-height: 1; }
.send-form .sub { margin: -4px 0 8px; }
.send-form label { display: block; border-bottom: 1.5px solid var(--ink); padding-bottom: 4px; }
.send-form label .mono { display: block; color: var(--muted); font-size: 10px; }
.send-form input, .send-form textarea {
  width: 100%; border: 0; background: none; outline: none; resize: none;
  font-family: var(--serif); font-style: italic; font-size: 26px; line-height: 1.2; padding: 2px 0;
  user-select: text; -webkit-user-select: text;
}
.send-form textarea { font-size: 21px; }
.send-form ::placeholder { color: #b9ae9d; }
.send-form .btn { margin-top: 10px; }

/* ---------- sent ---------- */
#sent { justify-content: flex-end; }
.sent-copy { padding: 0 24px calc(58px + var(--safe-b)); text-align: center; max-width: 460px; width: 100%; margin: 0 auto; }
.sent-copy h2 { font-size: 40px; line-height: 1.05; }
.sent-copy .sub { margin: 8px 0 20px; }
.sent-copy .btn + .btn { margin-top: 10px; width: 100%; }
.sent-copy > * { opacity: 0; transform: translateY(14px); transition: opacity .6s, transform .7s cubic-bezier(.2, .8, .2, 1); }
body.wrapped .sent-copy > * { opacity: 1; transform: none; }
body.wrapped .sent-copy > :nth-child(2) { transition-delay: .1s; }
body.wrapped .sent-copy > :nth-child(3) { transition-delay: .2s; }
body.wrapped .sent-copy > :nth-child(4) { transition-delay: .28s; }
body.wrapped .sent-copy > :nth-child(5) { transition-delay: .34s; }

/* ---------- gift ---------- */
.gift-area { position: absolute; left: 12px; right: 12px; top: calc(56px + env(safe-area-inset-top, 0px)); bottom: calc(306px + var(--safe-b)); pointer-events: none; }
.gift-copy { margin-top: auto; padding: 0 24px calc(58px + var(--safe-b)); text-align: center; transition: opacity .5s, transform .6s; }
.gift-copy h2 { font-size: clamp(36px, 11vw, 52px); line-height: 1; overflow-wrap: anywhere; }
.gift-copy .sub { margin: 8px 0 22px; }
.gift-open { position: absolute; left: 0; right: 0; bottom: 0; padding: 0 24px calc(58px + var(--safe-b)); text-align: center; opacity: 0; transform: translateY(24px); pointer-events: none; transition: opacity .7s ease .5s, transform .8s cubic-bezier(.2, .8, .2, 1) .5s; max-width: 460px; margin: 0 auto; }
body.gift-opened .gift-copy { opacity: 0; transform: translateY(20px); pointer-events: none; }
body.gift-opened .gift-open { opacity: 1; transform: none; pointer-events: auto; }
.note-card {
  position: relative; margin: 0 auto 18px; padding: 18px 20px 16px; max-width: 330px; text-align: left;
  background: var(--paper-2); border-radius: 4px; transform: rotate(-1.4deg);
  box-shadow: 0 1px 2px rgba(60, 40, 20, .2), 0 16px 30px -18px rgba(60, 40, 20, .55);
}
.note-card::before { /* washi tape */
  content: ''; position: absolute; top: -10px; left: 50%; width: 74px; height: 20px; transform: translateX(-50%) rotate(3deg);
  background: repeating-linear-gradient(90deg, rgba(210, 69, 43, .55) 0 6px, rgba(210, 69, 43, .38) 6px 12px);
}
.note-card p { font-family: var(--serif); font-size: 22px; line-height: 1.2; }
.note-card span { display: block; margin-top: 8px; font-family: var(--serif); font-style: italic; font-size: 18px; color: var(--shu); text-align: right; }

/* ---------- envelope ---------- */
.env {
  position: fixed; left: 50%; top: var(--env-top);
  width: var(--env-w); height: var(--env-h);
  transform: translateX(-50%) translateY(40px) scale(.9);
  opacity: 0; pointer-events: none;
  transition: opacity .6s ease, transform .8s cubic-bezier(.2, .8, .2, 1), top .8s cubic-bezier(.2, .8, .2, 1);
}
.env-under { z-index: 0; }
.env-over { z-index: 3; perspective: 900px; }
body.env-show .env { opacity: 1; transform: translateX(-50%); }
body.env-gone .env { opacity: 0; transform: translateX(-50%) translateY(60px) scale(.9); }
.env-back {
  position: absolute; inset: 0; border-radius: 6px;
  background: linear-gradient(#d9c8ab, #e4d6be 60%);
  box-shadow: 0 30px 40px -28px rgba(60, 40, 20, .6);
}
.env-flap-open {
  position: absolute; left: 0; right: 0; bottom: 100%; height: 56%;
  background: linear-gradient(0deg, #dccbad, #e9dcc6);
  clip-path: polygon(0 100%, 50% 0, 100% 100%);
  opacity: 0; transition: opacity .2s;
}
body.env-open .env-flap-open { opacity: 1; }
.env-pocket {
  position: absolute; inset: 0; border-radius: 6px;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 .4 0 0 0 0 .3 0 0 0 0 .2 0 0 0 .12 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"),
    linear-gradient(170deg, #f3e9d8, #eadcc4);
  clip-path: polygon(0 0, 50% 46%, 100% 0, 100% 100%, 0 100%);
}
.env-pocket::before { /* side seams */
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(to top right, transparent 49.6%, rgba(120, 90, 50, .14) 50%, transparent 50.6%), linear-gradient(to top left, transparent 49.6%, rgba(120, 90, 50, .14) 50%, transparent 50.6%);
}
.env-label { position: absolute; left: 0; right: 0; bottom: 9%; padding: 0 14px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.env-to { display: block; font-family: var(--serif); font-size: clamp(22px, 7vw, 30px); line-height: 1.05; overflow: hidden; text-overflow: ellipsis; }
.env-to em { color: var(--shu); }
.env-from { display: block; margin-top: 4px; color: var(--muted); font-size: 9.5px; }
.env-flap {
  position: absolute; left: 0; right: 0; top: 0; height: 46%;
  background: linear-gradient(#efe3cf, #e3d4ba);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: top center; transform: rotateX(0deg);
  filter: drop-shadow(0 2px 2px rgba(60, 40, 20, .2));
  transition: transform .7s cubic-bezier(.5, 0, .3, 1), opacity .1s;
}
body.env-open .env-flap { transform: rotateX(180deg); opacity: 0; transition: transform .7s cubic-bezier(.5, 0, .3, 1), opacity .05s .32s; }
.stamp { position: absolute; left: 50%; top: 44%; width: 52px; height: 52px; margin: -26px 0 0 -26px; opacity: 0; transform: scale(2.6) rotate(-30deg); transition: opacity .2s, transform .35s cubic-bezier(.5, 0, .7, 1.4); }
.stamp svg { width: 100%; height: 100%; filter: drop-shadow(0 2px 2px rgba(120, 30, 10, .35)); }
.stamp circle { fill: var(--shu); }
.stamp circle.in { fill: none; stroke: #f6dfd2; stroke-width: 1.4; stroke-dasharray: 2 3; }
.stamp text { font-family: var(--serif); font-style: italic; font-size: 30px; fill: #fbeee6; }
body.env-stamped .stamp { opacity: 1; transform: scale(1) rotate(-8deg); }
body.env-open .stamp { opacity: 0; transform: scale(1.3) translateY(-30px) rotate(20deg); transition: opacity .3s, transform .4s; }

body[data-screen="sent"] { --env-top: 30svh; }
body.wrapped[data-screen="sent"] { --env-top: max(72px, 13svh); }
body[data-screen="gift"] { --env-top: 30svh; }
body.gift-opened { --env-top: 64svh; }

/* ---------- toast ---------- */
.toast { position: fixed; left: 50%; bottom: calc(120px + var(--safe-b)); transform: translate(-50%, 20px); background: var(--ink); color: var(--paper-2); padding: 12px 18px; border-radius: 999px; font-size: 15px; opacity: 0; pointer-events: none; z-index: 10; transition: opacity .3s, transform .4s cubic-bezier(.2, .8, .2, 1); white-space: nowrap; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- no WebGL fallback ---------- */
.fb { display: none; }
body.no-gl .fb { display: grid; place-items: center; position: absolute; inset: 18% 22% 26%; border-radius: 6px; background-size: cover; box-shadow: 0 8px 16px -10px rgba(60, 40, 20, .6); }
body.no-gl .fb svg { width: 60%; height: 60%; fill: rgba(255, 255, 255, .7); stroke: var(--ink); stroke-width: 1.2; stroke-linejoin: round; }
body.no-gl .stage .fb { inset: 15% 30%; }

@media (min-width: 700px) {
  .panel { max-width: 560px; margin: 0 auto; width: 100%; }
  .shelf-box, .shelf-head, .actions { max-width: 600px; width: 100%; margin-left: auto; margin-right: auto; }
  .grid { grid-template-columns: repeat(4, 1fr); }
  .cell:nth-child(3n) { border-right: 1px solid var(--line); }
  .cell:nth-child(4n) { border-right: 0; }
  .actions { max-width: 460px; }
}
@media (prefers-reduced-motion: reduce) { * { transition-duration: .01s !important; animation-duration: .01s !important; } }
.intro-copy .btn, .gift-copy .btn, .sent-copy .btn { max-width: 420px; margin-left: auto; margin-right: auto; }
