:root {
  color-scheme: light;
  --paper: #fbf8f4;
  --base: #f3ebe4;
  --ink: #2c2022;
  --muted: #664f50;
  --line: #d7c6bd;
  --accent: #772e42;
  --accent-strong: #5d1f32;
  --display: "Songti SC", "Noto Serif SC", STSong, SimSun, serif;
  --text: system-ui, "Microsoft YaHei", sans-serif;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 24px; }
body { margin: 0; color: var(--ink); background: var(--paper); font: 1rem/1.6 var(--text); }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .6; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
h1, h2, h3, p, figure { margin: 0; }
.container { width: min(1160px, calc(100% - 88px)); margin-inline: auto; }
.skip { position: absolute; transform: translateY(-150%); background: var(--paper); padding: 12px; z-index: 2; }
.skip:focus { transform: none; }
.top { border-bottom: 1px solid var(--line); }
.top-inner { min-height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.brand { text-decoration: none; font-family: var(--display); font-size: 1.13rem; font-weight: bold; white-space: nowrap; }
.brand-mark { color: var(--accent); margin-right: 5px; }
nav { display: flex; flex-wrap: wrap; align-items: center; gap: clamp(10px, 3vw, 30px); }
nav a, .text-button { text-decoration: none; min-height: 44px; display: inline-flex; align-items: center; font-size: .92rem; }
nav a:hover, .text-button:hover, .footer a:hover { text-decoration: underline; text-underline-offset: 5px; }
.text-button { background: transparent; border: 0; padding: 0; color: inherit; }
.accent { color: var(--accent); }
.cover { display: grid; grid-template-columns: .84fr 1.16fr; align-items: center; gap: clamp(30px, 7vw, 90px); padding-block: 55px 56px; }
.cover-copy { display: grid; gap: 22px; justify-items: start; }
.dateline { font-size: .87rem; color: var(--accent); font-weight: 600; min-height: 1.4em; }
h1 { font: 700 clamp(3.1rem, 7.5vw, 6.5rem)/1.05 var(--display); letter-spacing: -.05em; overflow-wrap: anywhere; }
.title-period { color: var(--accent); }
.cover-caption { color: var(--muted); max-width: 28em; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 46px; border-radius: 5px; padding: 8px 17px; border: 1px solid transparent; text-decoration: none; }
.primary { background: var(--accent); color: white; }
.primary:hover:not(:disabled) { background: var(--accent-strong); }
.outline { border-color: var(--line); background: var(--paper); color: var(--ink); }
.outline:hover { background: var(--base); }
.cover-frame { position: relative; background: var(--base); padding: 9px 9px 0; box-shadow: 0 9px 25px #4e253718; transform: rotate(1.25deg); border: 1px solid #ebded3; }
.cover-frame img { display: block; width: 100%; height: auto; aspect-ratio: 1.37; object-fit: cover; }
.cover-frame figcaption { color: var(--muted); text-align: right; font-size: .8rem; padding: 6px 4px; }
.cover.special { border-bottom-color: var(--accent); }
.cover.special .cover-frame { animation: arrival 650ms cubic-bezier(.21,.72,.32,1) both; }
.cover[data-theme="birthday"] .cover-frame { box-shadow: 0 0 40px #9a462a45; }
.cover[data-theme="birthday"] .cover-frame::before {
  content: ""; position: absolute; z-index: 1; width: 12px; height: 20px;
  inset: auto 22px 52px auto; border-radius: 65% 45% 55% 45%;
  background: #ffe0a9; box-shadow: 0 0 17px 5px #ff9b57b3;
  transform: rotate(11deg); transition: opacity .35s ease;
}
.cover[data-theme="birthday"] .cover-frame::after {
  content: ""; position: absolute; width: 9px; height: 24px; inset: auto 24px 28px auto;
  background: repeating-linear-gradient(35deg, #f8d5ce 0 4px, #c46d75 4px 8px);
}
.cover.candle-out .cover-frame::before { opacity: 0; }
.cover[data-theme="trip"] .cover-frame { border: 2px dashed var(--line); }
@keyframes arrival { from { transform: translateY(9px) rotate(-2deg); } to { transform: translateY(0) rotate(1.25deg); } }
.timeline, .mail-room { border-top: 1px solid var(--line); padding-block: 30px 44px; }
.section-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px 22px; margin-bottom: 20px; }
h2 { font: 700 clamp(1.45rem, 3.2vw, 2rem)/1.25 var(--display); }
h3 { font: 700 1.25rem/1.4 var(--display); overflow-wrap: anywhere; }
.empty, .hint, .optional, .notice { color: var(--muted); }
.empty { font-size: .95rem; }
.notice { font-size: .9rem; overflow-wrap: anywhere; }
.notice:empty { display: none; }
#site-status:not(:empty) { padding-bottom: 16px; }
.same-day { padding: 12px 16px; background: var(--base); border-left: 3px solid var(--accent); margin-bottom: 16px; }
.memory-row { display: grid; grid-template-columns: minmax(92px, .27fr) 1fr; gap: 10px 24px; border-bottom: 1px solid var(--line); padding: 16px 0; }
.memory-row time, .mail-row time { color: var(--muted); font-size: .9rem; }
.memory-photo { width: min(100%, 490px); object-fit: cover; max-height: 390px; display: block; margin-top: 10px; border-radius: 5px; }
.memory-back { max-width: 36rem; padding: 14px; margin-bottom: 10px; background: var(--base); border-radius: 5px; white-space: pre-wrap; overflow-wrap: anywhere; }
.mail-tabs { display: flex; gap: 18px; margin-bottom: 12px; }
.mail-tabs button { background: transparent; border: 0; border-bottom: 2px solid transparent; color: var(--muted); min-height: 44px; padding: 4px 6px; }
.mail-tabs button[aria-pressed="true"] { border-bottom-color: var(--accent); color: var(--accent); font-weight: 600; }
.mail-row, .occasion-row { display: flex; justify-content: space-between; align-items: center; gap: 8px 20px; flex-wrap: wrap; border-bottom: 1px solid var(--line); padding: 12px 0; }
.mail-row p { color: var(--muted); font-size: .9rem; }
.row-actions { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.footer { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 22px; border-top: 1px solid var(--line); padding-block: 16px 28px; color: var(--muted); font-size: .87rem; }
.footer a { text-decoration: none; }
dialog { color: var(--ink); background: var(--paper); width: min(520px, calc(100% - 28px)); max-height: calc(100dvh - 22px); padding: clamp(18px, 4vw, 28px); border: 1px solid var(--line); border-radius: 9px; }
dialog::backdrop { background: #28191fb8; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 18px; margin-bottom: 12px; }
.close { width: 44px; height: 44px; flex: none; font-size: 1.6rem; border: 0; border-radius: 5px; color: var(--ink); background: var(--base); }
form, form [data-fields] { display: grid; gap: 13px; justify-items: start; }
form [data-fields], form label { width: 100%; }
form label { display: grid; gap: 4px; font-size: .9rem; }
form label.check { display: flex; align-items: center; }
form input:not([type="checkbox"]), form select, form textarea { min-width: 0; min-height: 44px; width: 100%; border: 1px solid var(--line); border-radius: 5px; background: #fffdfb; color: var(--ink); padding: 7px 9px; font-size: 1rem; }
form input[type="checkbox"] { accent-color: var(--accent); width: 20px; height: 20px; margin-right: 7px; }
form textarea { resize: vertical; }
.hint, .optional { font-size: .85rem; }
#occasion-list { margin-top: 16px; }
.envelope-scene { position: relative; isolation: isolate; overflow: hidden; display: grid; place-items: center; min-height: 158px; background: var(--base); margin-bottom: 15px; border-radius: 5px; }
.envelope { display: block; position: relative; width: 137px; aspect-ratio: 1.5; transform: rotate(-7deg); transition: transform .48s ease; background: #c28278; border-radius: 4px; box-shadow: 0 6px 13px #59283830; }
.envelope::before, .envelope::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.envelope::before { background: #dea197; clip-path: polygon(0 100%, 50% 40%, 100% 100%); }
.envelope::after { background: #f0bdb1; clip-path: polygon(0 0, 100% 0, 50% 61%); }
.sheet { position: absolute; inset: 10px; background: repeating-linear-gradient(#fff6e8 0 13px, #eac7a4 13px 14px); transition: transform .48s ease; }
.seal { z-index: 1; display: grid; place-items: center; position: absolute; inset: 42% auto auto 50%; transform: translateX(-50%); border-radius: 48%; width: 29px; height: 29px; background: var(--accent); color: #fff3ef; }
.spark { color: var(--accent); position: absolute; visibility: hidden; }
.spark-left { top: 23%; left: 22%; }
.spark-right { top: 32%; right: 20%; }
.opened .envelope { transform: translateY(13px) rotate(-3deg); }
.opened .envelope::after { opacity: 0; }
.opened .sheet { transform: translateY(-42%); }
.opened .spark { visibility: visible; animation: spark .6s ease-out both; }
@keyframes spark { from { transform: translateY(10px) scale(.4); opacity: 0; } to { transform: none; opacity: 1; } }
.letter-body { white-space: pre-wrap; overflow-wrap: anywhere; padding: 8px 0 16px; }
#letter-status { margin-bottom: 10px; }
.login-page { display: grid; align-items: center; min-height: 100dvh; padding: 30px 16px; background: var(--base); }
.login-sheet { width: min(100%, 480px); margin-inline: auto; padding: clamp(24px, 7vw, 49px); border: 1px solid var(--line); border-radius: 9px; background: var(--paper); }
.login-sheet h1 { font-size: clamp(2.8rem, 11vw, 4.5rem); margin-block: 7px 12px; }
.login-mark, .login-feedback { color: var(--accent); }
.login-mark { font-size: 1.4rem; }
.login-form { margin-top: 22px; }
.login-feedback { font-size: .9rem; }
.persona-picker { width: 100%; min-width: 0; margin: 0; padding: 0; border: 0; }
.persona-picker legend { margin-bottom: 5px; padding: 0; font-size: .9rem; }
.persona-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.login-form .persona-choice { position: relative; cursor: pointer; }
.login-form .persona-choice input { position: absolute; width: 1px; height: 1px; min-height: 0; padding: 0; margin: 0; opacity: 0; }
.persona-card { display: grid; justify-items: center; gap: 4px; padding: 10px 6px 8px; border: 1px solid var(--line); border-radius: 5px; background: #fffdfb; }
.persona-card:hover, .persona-choice input:checked + .persona-card { border-color: var(--accent); background: var(--base); color: var(--accent); }
.persona-choice input:focus-visible + .persona-card { outline: 2px solid var(--accent); outline-offset: 3px; }
.persona-drawing { width: 54px; height: 54px; color: var(--accent); }
.active-persona { display: inline-flex; align-items: center; gap: 5px; }
.active-persona svg { width: 23px; height: 23px; color: var(--accent); }
@media(max-width: 800px) {
  .container { width: calc(100% - 40px); }
  .cover { gap: 35px; }
}
@media(max-width: 600px) {
  .container { width: calc(100% - 32px); }
  .top-inner { min-height: 65px; gap: 6px; }
  nav { gap: 12px; }
  nav a, nav .text-button { font-size: .82rem; }
  .brand { font-size: .94rem; }
  .brand-mark { margin-right: 1px; }
  .cover { grid-template-columns: 1fr; gap: 25px; padding-block: 25px 28px; }
  .cover-copy { gap: 13px; }
  h1 { font-size: clamp(2.9rem, 10vw, 4rem); }
  h1 br { display: none; }
  .cover-frame img { aspect-ratio: 1.65; }
  .memory-row { grid-template-columns: 1fr; gap: 4px; }
  .timeline, .mail-room { padding-block: 22px 28px; }
}
@media(max-width: 360px) {
  .top-inner { flex-wrap: wrap; gap: 0; padding-top: 8px; }
  .brand { width: 100%; }
}
@media(prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
}
