:root {
  --bg1: #fff1f2; --bg2: #ffe4e6; --rose: #e11d48; --rose-soft: #fda4af;
  --ink: #4c0519; --muted: #9f1239; --card: rgba(255,255,255,.75);
}
* { box-sizing: border-box; }
body {
  margin: 0; min-height: 100vh; color: var(--ink);
  font-family: "Playfair Display", Georgia, serif;
  background: linear-gradient(160deg, var(--bg1), var(--bg2));
  display: flex; justify-content: center; padding: 24px 14px 60px;
}
main { width: 100%; max-width: 560px; }
h1 { font-family: "Dancing Script", cursive; font-size: 2.6rem; text-align: center; margin: 8px 0 4px; color: var(--rose); }
.sub { text-align: center; color: var(--muted); margin: 0 0 18px; font-style: italic; }
.card { background: var(--card); backdrop-filter: blur(6px); border-radius: 20px; padding: 18px; box-shadow: 0 10px 30px rgba(225,29,72,.12); }
.nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.nav h2 { margin: 0; font-size: 1.3rem; }
button { font: inherit; cursor: pointer; }
.nav button { background: none; border: 0; font-size: 1.5rem; color: var(--rose); padding: 4px 12px; border-radius: 10px; }
.nav button:hover { background: var(--bg2); }
.grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.dow { text-align: center; font-size: .75rem; color: var(--muted); padding-bottom: 4px; }
.day { aspect-ratio: 1; border: 0; border-radius: 12px; background: rgba(255,255,255,.6); color: var(--ink); position: relative; font-size: .95rem; }
.day.empty { background: none; cursor: default; }
.day.future { opacity: .4; cursor: default; }
.day.has { background: #fff; box-shadow: inset 0 0 0 1.5px var(--rose-soft); }
.day.has::after { content: "♥"; position: absolute; bottom: 3px; left: 0; right: 0; font-size: .7rem; color: var(--rose); }
.day.has:hover { transform: translateY(-2px); box-shadow: inset 0 0 0 1.5px var(--rose), 0 4px 10px rgba(225,29,72,.2); }
.day.today { background: var(--rose); color: #fff; }
.day.today.has::after { color: #fff; }
.today-btn { display: block; margin: 16px auto 0; padding: 10px 20px; border: 0; border-radius: 999px; background: var(--rose); color: #fff; box-shadow: 0 6px 16px rgba(225,29,72,.3); }
.count { text-align: center; color: var(--muted); font-size: .85rem; margin-top: 14px; }
dialog { border: 0; border-radius: 22px; padding: 26px; max-width: 480px; width: calc(100% - 32px); background: #fff8f8; color: var(--ink); box-shadow: 0 20px 60px rgba(76,5,25,.35); }
dialog::backdrop { background: rgba(76,5,25,.4); backdrop-filter: blur(3px); }
dialog h3 { font-family: "Dancing Script", cursive; color: var(--rose); font-size: 1.6rem; margin: 0 0 12px; }
dialog p { white-space: pre-wrap; line-height: 1.7; font-size: 1.05rem; margin: 0 0 18px; }
dialog button { background: var(--rose); color: #fff; border: 0; padding: 8px 18px; border-radius: 999px; }
/* write page */
label { display: block; font-size: .85rem; color: var(--muted); margin: 12px 0 4px; }
input, textarea { width: 100%; font: inherit; padding: 10px 12px; border: 1.5px solid var(--rose-soft); border-radius: 12px; background: #fff; color: var(--ink); }
textarea { min-height: 160px; resize: vertical; }
.primary { margin-top: 14px; padding: 10px 22px; border: 0; border-radius: 999px; background: var(--rose); color: #fff; }
.status { margin-top: 10px; min-height: 1.2em; font-size: .9rem; color: var(--muted); }
.list { margin-top: 18px; display: grid; gap: 8px; }
.item { background: #fff; border-radius: 12px; padding: 10px 12px; display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.item span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .9rem; }
.item button { background: none; border: 0; color: var(--rose); }
[hidden]{display:none!important}
/* header icon */
.cal-icon { display: block; margin: 0 auto; background: none; border: 0; padding: 4px; border-radius: 16px; transition: transform .2s; animation: float 3.5s ease-in-out infinite; }
.cal-icon:hover { transform: scale(1.08) rotate(-3deg); }
@keyframes float { 50% { transform: translateY(-4px); } }
/* envelope reveal */
dialog { overflow: visible; }
dialog:has(.env:not([hidden])) { background: transparent; box-shadow: none; padding: 0; }
.env { position: relative; width: 280px; height: 190px; margin: 40px auto; cursor: pointer; perspective: 800px; }
.env-back { position: absolute; inset: 0; background: #f9a8b8; border-radius: 10px; box-shadow: 0 14px 34px rgba(76,5,25,.4); }
.env::before { content: ""; position: absolute; inset: 0; z-index: 2; border-radius: 10px; background: linear-gradient(135deg, #fb7d96 50%, transparent 50%), linear-gradient(225deg, #fb7d96 50%, transparent 50%); }
.flap { position: absolute; top: 0; left: 0; right: 0; height: 100px; z-index: 3; background: #e11d48; clip-path: polygon(0 0, 100% 0, 50% 100%); transform-origin: top; transition: transform .7s ease, z-index 0s .35s; }
.seal { position: absolute; z-index: 4; left: 50%; top: 82px; transform: translateX(-50%); width: 46px; height: 46px; border-radius: 50%; background: #9f1239; color: #fff; display: grid; place-items: center; font-size: 1.4rem; box-shadow: 0 3px 8px rgba(0,0,0,.35); animation: beat 1.4s ease-in-out infinite; transition: opacity .3s; }
@keyframes beat { 50% { transform: translateX(-50%) scale(1.12); } }
.hint { position: absolute; bottom: -32px; width: 100%; text-align: center; color: #fff; font-style: italic; margin: 0; }
.env.opening .flap { transform: rotateX(180deg); z-index: 1; }
.env.opening .seal, .env.opening .hint { opacity: 0; animation: none; }
.env.opening { animation: lift .5s .7s ease-in forwards; }
@keyframes lift { to { transform: translateY(30px) scale(.9); opacity: 0; } }
.letter { animation: rise .8s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(60px) scale(.9); } }
#dlgText p { margin: 0 0 .6em; opacity: 0; animation: fadein .9s ease forwards; white-space: pre-wrap; line-height: 1.7; font-size: 1.05rem; }
@keyframes fadein { to { opacity: 1; } }
/* floating hearts + confetti */
#hearts { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.fheart { position: absolute; bottom: -40px; color: var(--rose-soft); opacity: 0; animation: floatup linear forwards; }
@keyframes floatup { 10% { opacity: .7; } to { transform: translateY(-110vh) translateX(30px) rotate(25deg); opacity: 0; } }
main { position: relative; z-index: 1; transition: opacity 1.2s ease, transform 1.2s ease; }
body.intro-active main { opacity: 0; transform: scale(.95); }
body.intro-active { overflow: hidden; }
.piece { position: fixed; z-index: 99999; pointer-events: none; font-size: 16px; animation: pop 1.5s ease-out forwards; }
@keyframes pop { to { transform: translate(var(--dx), calc(var(--dy) + 140px)) rotate(var(--rot)); opacity: 0; } }
/* intro */
#intro { position: fixed; inset: 0; z-index: 1000; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 36px; text-align: center; padding: 24px;
  background: radial-gradient(circle at 50% 40%, #4c0519 0%, #1c0109 60%, #000 100%); color: #fff; transition: opacity 1.1s ease, transform 1.1s ease; }
#intro::before { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .6;
  background-image: radial-gradient(2px 2px at 20% 30%, #fff, transparent), radial-gradient(1.5px 1.5px at 70% 20%, #fda4af, transparent), radial-gradient(2px 2px at 40% 75%, #fff, transparent), radial-gradient(1.5px 1.5px at 85% 65%, #fda4af, transparent), radial-gradient(1px 1px at 10% 80%, #fff, transparent), radial-gradient(1.5px 1.5px at 60% 50%, #fff, transparent);
  animation: twinkle 3s ease-in-out infinite; }
@keyframes twinkle { 50% { opacity: .15; } }
#intro.out { opacity: 0; transform: scale(1.35); pointer-events: none; }
#introLine { position: relative; margin: 0; min-height: 3.2em; font-family: "Dancing Script", cursive; font-size: clamp(1.8rem, 7vw, 2.8rem); line-height: 1.3; opacity: 0; filter: blur(8px); transition: opacity 1s ease, filter 1s ease; }
#introLine.show { opacity: 1; filter: blur(0); }
.skip { position: absolute; top: 18px; right: 18px; background: none; border: 0; color: rgba(255,255,255,.45); font-size: .85rem; }
.skip:hover { color: #fff; }
.unlock { position: relative; background: none; border: 0; color: #fda4af; display: flex; flex-direction: column; align-items: center; gap: 6px; font-style: italic; touch-action: none; user-select: none; -webkit-user-select: none; animation: appear 1.2s ease both; }
@keyframes appear { from { opacity: 0; transform: scale(.7); } }
.unlock svg { filter: drop-shadow(0 0 16px rgba(251,113,133,.6)); animation: beat2 1.3s ease-in-out infinite; }
@keyframes beat2 { 50% { transform: scale(1.07); } }
.ring-bg { fill: none; stroke: rgba(255,255,255,.15); stroke-width: 5; }
.ring { fill: none; stroke: #fb7185; stroke-width: 5; stroke-linecap: round; stroke-dasharray: 327; stroke-dashoffset: 327; transform: rotate(-90deg); transform-origin: 60px 60px; transition: stroke-dashoffset .25s ease; }
.unlock.holding .ring { stroke-dashoffset: 0; transition: stroke-dashoffset 1.8s linear; }
.unlock.holding svg { animation-duration: .4s; }
/* polaroid photo in letter */
.polaroid { display: block; max-width: 100%; max-height: 260px; margin: 0 auto 16px; padding: 8px 8px 22px; background: #fff; border-radius: 4px; box-shadow: 0 6px 18px rgba(76,5,25,.25); transform: rotate(-2deg); animation: rise .9s ease-out; }
.sign { text-align: right; font-family: "Dancing Script", cursive; font-size: 1.4rem; color: var(--rose); }
@media (prefers-reduced-motion: reduce) { .fheart, .cal-icon, .seal, .unlock svg { animation: none; } }
.ghost { margin-top: 12px; padding: 6px 14px; border: 1.5px solid var(--rose-soft); border-radius: 999px; background: #fff; color: var(--rose); }
.ghost:hover { background: var(--bg2); }
