:root {
  --gold: #f6c453;
  --radius: 18px;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  -webkit-text-size-adjust: 100%;
}

body[data-theme="tree"] {
  --bg1: #0a1730;
  --bg2: #1a3f78;
  --panel: #141d38;
  --ink: #f4f7ff;
  --muted: #b9c6e2;
  --card: rgba(255, 255, 255, 0.08);
  --card-strong: rgba(255, 255, 255, 0.16);
  --line: rgba(255, 255, 255, 0.16);
  --accent: #d8392f;
  --accent-2: #ff6f5e;
  --on-accent: #fff;
}

body[data-theme="wall"] {
  --bg1: #3f0608;
  --bg2: #9a1616;
  --panel: #4a0a0c;
  --ink: #fff7e8;
  --muted: #f2cfa6;
  --card: rgba(255, 214, 120, 0.08);
  --card-strong: rgba(255, 214, 120, 0.18);
  --line: rgba(246, 196, 83, 0.3);
  --accent: #e0a51e;
  --accent-2: #ffd060;
  --on-accent: #5a0d0d;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body {
  background: radial-gradient(120% 90% at 50% -10%, var(--bg2), var(--bg1) 72%) fixed, var(--bg1);
  color: var(--ink);
  line-height: 1.5;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
[hidden] { display: none !important; }
.loading { padding: 40vh 0; text-align: center; color: var(--muted); }
.muted { color: var(--muted); font-size: 13px; }

/* ---------- 布局 ---------- */
.bar {
  display: flex; justify-content: space-between; align-items: center;
  max-width: 520px; margin: 0 auto; padding: 12px 16px;
  padding-top: calc(12px + env(safe-area-inset-top));
}
/* 祝福墙顶部挂着灯笼，标题和返回键让出这一行 */
body[data-theme="wall"] .bar { padding-top: calc(62px + env(safe-area-inset-top)); }
body[data-theme="wall"] .home-head { padding-top: 74px; }
.back { text-decoration: none; font-size: 15px; opacity: .85; padding: 8px 4px; }
.share-ic {
  width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--card); font-size: 17px;
}
.wrap { position: relative; max-width: 520px; margin: 0 auto; padding: 0 16px calc(32px + env(safe-area-inset-bottom)); }
.wrap-home { max-width: 440px; }

/* ---------- 按钮 ---------- */
.btn-primary, .btn-ghost {
  display: block; width: 100%; padding: 15px; border-radius: var(--radius);
  font-size: 17px; font-weight: 700; transition: transform .1s, opacity .2s;
}
.btn-primary {
  border: 0; color: var(--on-accent);
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  box-shadow: 0 8px 20px rgba(0, 0, 0, .28);
}
.btn-ghost { border: 1.5px solid var(--line); background: rgba(0, 0, 0, .12); font-weight: 600; }
.btn-primary:active, .btn-ghost:active { transform: scale(.98); }
.btn-primary:disabled, .btn-ghost:disabled { opacity: .55; cursor: default; }
.btn-small {
  display: block; padding: 12px; border-radius: 14px; border: 1.5px solid var(--line);
  background: rgba(0, 0, 0, .18); font-size: 15px; text-align: center; text-decoration: none; color: var(--ink);
}
.danger { color: #ffb4ad; border-color: rgba(255, 120, 110, .5); }

/* ---------- 表单 ---------- */
.field { display: block; font-size: 14px; color: var(--muted); }
.field input, .field textarea {
  display: block; width: 100%; margin-top: 6px; padding: 14px;
  border-radius: 14px; border: 1.5px solid var(--line);
  background: rgba(0, 0, 0, .2); color: var(--ink); font-size: 16px; outline: none;
}
.field input:focus, .field textarea:focus { border-color: var(--accent-2); }
.field textarea { resize: none; }
.field.has-count textarea { padding-bottom: 30px; }
.field.has-count { position: relative; }
.count { position: absolute; right: 12px; bottom: 10px; font-size: 12px; color: var(--muted); }
input[type="date"] { color-scheme: dark; }
input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(1); opacity: .7; }

/* ---------- 首页 ---------- */
.home-head { text-align: center; padding: 26px 0 18px; }
.logo { margin: 0; font-size: 36px; font-weight: 800; letter-spacing: .14em; line-height: 1.2; }
.tagline { margin: 12px 0 0; color: var(--muted); font-size: 15px; }

.picker { display: grid; gap: 10px; }
.tpl {
  display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 12px;
  width: 100%; padding: 14px; text-align: left;
  border-radius: var(--radius); border: 1.5px solid var(--line); background: var(--card);
  transition: border-color .2s, background .2s, transform .1s;
}
.tpl:active { transform: scale(.985); }
.tpl.is-on {
  border-color: var(--accent-2); background: var(--card-strong);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-2) 25%, transparent);
}
.tpl-art { font-size: 34px; text-align: center; }
.tpl-body b { display: block; font-size: 17px; }
.tpl-body small { display: block; margin-top: 2px; color: var(--muted); font-size: 13px; }
.tpl-days {
  padding: 4px 8px; border-radius: 999px; background: rgba(0, 0, 0, .22);
  font-size: 12px; font-weight: 700; white-space: nowrap;
}

.create { display: grid; gap: 14px; margin-top: 18px; }
.reveal-row { display: grid; gap: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; }
.chip input { position: absolute; inset: 0; opacity: 0; margin: 0; }
.chip span {
  display: block; padding: 8px 14px; border-radius: 999px;
  border: 1.5px solid var(--line); background: rgba(0, 0, 0, .2); font-size: 14px; color: var(--ink);
}
.chip input:checked + span { border-color: var(--accent-2); background: var(--card-strong); font-weight: 700; }

.sec { margin-top: 28px; }
.sec h2 { margin: 0 0 10px; color: var(--muted); font-size: 14px; font-weight: 600; letter-spacing: .08em; }
.list { display: grid; gap: 8px; }
.rowlink {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 12px 14px; border-radius: 14px; text-decoration: none;
  border: 1px solid var(--line); background: var(--card); font-size: 15px;
}
.rowlink:active { background: var(--card-strong); }
.rowlink .muted { white-space: nowrap; }
.demo {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 10px 10px 10px 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); font-size: 15px;
}
.demo-links { display: flex; gap: 8px; }
.demo-links a {
  padding: 6px 12px; border-radius: 999px; text-decoration: none; font-size: 13px;
  border: 1px solid var(--line); background: rgba(0, 0, 0, .22);
}

/* ---------- 日历页 ---------- */
.title { margin: 4px 0 0; text-align: center; font-size: 28px; font-weight: 800; line-height: 1.25; }
.title-of { margin-left: 4px; font-size: 18px; font-weight: 600; color: var(--muted); }
.title-sm { margin: 8px 0 4px; text-align: center; font-size: 20px; }
.status { margin: 6px 0 4px; text-align: center; color: var(--muted); font-size: 14px; }
.peek-banner {
  margin-top: 10px; padding: 8px; border-radius: 12px; text-align: center; font-size: 13px;
  border: 1px dashed var(--gold); background: rgba(246, 196, 83, .14);
}
.empty-hint { margin: 4px 0 0; text-align: center; color: var(--muted); font-size: 14px; }

.stage { position: relative; margin: 0 auto; }
.stage svg.tree { display: block; width: 100%; max-width: 440px; height: auto; margin: 0 auto; overflow: visible; }
.missing { padding-top: 20vh; text-align: center; display: grid; gap: 14px; justify-items: center; }
.missing .btn-primary { max-width: 260px; }

.cta { display: grid; gap: 10px; margin-top: 14px; }
.cta .btn-ghost { text-align: center; text-decoration: none; }
.cta-hint { margin: 0; text-align: center; color: var(--muted); font-size: 13px; }

.tools { margin-top: 18px; padding: 0 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
.tools summary { display: flex; justify-content: space-between; align-items: center; padding: 14px 0; color: var(--muted); font-size: 14px; cursor: pointer; list-style: none; }
.tools summary::-webkit-details-marker { display: none; }
.tools summary::after { content: "›"; font-size: 20px; line-height: 1; transition: transform .2s; }
.tools[open] summary::after { transform: rotate(-90deg); }
.tools-body { display: grid; gap: 10px; padding: 0 0 14px; font-size: 14px; }
.tools-body p { margin: 0; color: var(--muted); }
.foot { margin-top: 18px; text-align: center; color: var(--muted); font-size: 12px; opacity: .85; }

/* 圣诞树 */
.swing {
  transform-box: fill-box; transform-origin: 50% 0;
  animation: swing 2.8s ease-in-out infinite alternate; animation-delay: var(--d, 0s);
}
@keyframes swing { from { transform: rotate(-6deg); } to { transform: rotate(6deg); } }
@keyframes swing-lit { from { transform: rotate(-3deg); } to { transform: rotate(3deg); } }
.orn { cursor: pointer; outline: none; }
.orn-string { stroke: #e9d9a6; stroke-width: 1.2; }
.orn-emoji { font-size: 21px; pointer-events: none; }
.hit { fill: transparent; }
.orn-name {
  font-size: 9.5px; fill: #fff; pointer-events: none;
  paint-order: stroke; stroke: rgba(0, 0, 0, .55); stroke-width: 2.5px; stroke-linejoin: round;
}
.orn:hover .swing, .orn:focus-visible .swing { filter: brightness(1.2) drop-shadow(0 0 5px rgba(255, 255, 255, .6)); }
.is-open .orn-emoji { filter: drop-shadow(0 0 7px rgba(246, 196, 83, .9)); }
.is-open .swing { animation-name: swing-lit; }
.orn.is-new .swing { animation: pop .5s cubic-bezier(.2, 1.4, .4, 1) both, swing 2.8s ease-in-out .5s infinite alternate; }
@keyframes pop { from { transform: scale(0); } to { transform: scale(1); } }
.garland { fill: none; stroke: #e9d9a6; stroke-width: 1; opacity: .45; }
.light { fill: #ffe08a; transform-box: fill-box; transform-origin: center; animation: blink 2.4s ease-in-out infinite; animation-delay: var(--d, 0s); }
@keyframes blink { 0%, 100% { opacity: .3; } 50% { opacity: 1; } }
#star { transform-box: fill-box; transform-origin: center; }
.is-lit #star { animation: star-pulse 1.8s ease-in-out infinite; }
@keyframes star-pulse { 0%, 100% { transform: scale(1); opacity: .92; } 50% { transform: scale(1.12); opacity: 1; } }
.presents { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 10px; margin-top: 4px; }
.gift { display: grid; justify-items: center; gap: 1px; padding: 0; border: 0; background: none; }
.gift span { font-size: 26px; }
.gift b { font-size: 11px; font-weight: 500; color: var(--muted); }
.gift.is-new { animation: pop .5s cubic-bezier(.2, 1.4, .4, 1) both; }

/* 祝福墙 */
.wall-rope { border-top: 2px solid #c9962f; }
.wall { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px 8px; padding: 6px 0 4px; }
@media (min-width: 480px) { .wall { grid-template-columns: repeat(4, 1fr); } }
.env {
  display: flex; flex-direction: column; align-items: center; padding: 0; border: 0; background: none;
  transform-origin: 50% 0; animation: sway 3.4s ease-in-out infinite alternate; animation-delay: var(--d, 0s);
}
@keyframes sway { from { transform: rotate(-2.4deg); } to { transform: rotate(2.4deg); } }
.env.is-new { animation: drop .55s cubic-bezier(.2, 1.3, .4, 1) both, sway 3.4s ease-in-out .55s infinite alternate; }
@keyframes drop { from { transform: translateY(-40px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.string { display: block; width: 2px; height: var(--h, 24px); background: linear-gradient(#f6c453, #b9851c); }
.env-body {
  position: relative; display: block; width: min(100%, 88px); aspect-ratio: 3 / 4; border-radius: 8px;
  background: linear-gradient(170deg, #ef4a3f, #b8161c 70%);
  box-shadow: 0 6px 14px rgba(0, 0, 0, .35), inset 0 0 0 1px rgba(255, 215, 130, .35);
  transition: box-shadow .3s;
}
.env:active .env-body { transform: scale(.96); }
.env-card, .env-flap { position: absolute; display: block; }
.env-card {
  left: 7px; right: 7px; top: -14px; height: 44px; border-radius: 5px; background: #fff5d6; z-index: 1;
  opacity: 0; transform: translateY(16px);
  transition: transform .45s cubic-bezier(.2, .9, .3, 1.2), opacity .3s;
}
.env-flap {
  left: 0; right: 0; top: 0; height: 37%; z-index: 2;
  background: linear-gradient(#ff7163, #e4392f); clip-path: polygon(0 0, 100% 0, 50% 100%);
}
.env-seal {
  position: absolute; left: 50%; top: 37%; z-index: 3; transform: translate(-50%, -50%);
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  font-size: 18px; background: radial-gradient(circle at 35% 30%, #ffe08a, #d99a17);
  box-shadow: 0 0 0 2px rgba(120, 50, 0, .18);
}
.env-name {
  position: absolute; left: 0; right: 0; bottom: 9%; z-index: 3; padding: 0 6px;
  text-align: center; font-size: 12px; font-weight: 700; color: #ffe9a8;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.env.is-open .env-card { opacity: 1; transform: translateY(0); }
.env.is-open .env-body { box-shadow: 0 0 18px rgba(255, 208, 96, .55), inset 0 0 0 1px rgba(255, 215, 130, .6); }
.env.is-ghost { animation: none; }
.env.is-ghost .string { background: var(--line); }
.env.is-ghost .env-body { background: transparent; border: 1.5px dashed var(--line); box-shadow: none; }
.env.is-ghost .env-name { color: var(--muted); font-weight: 500; }

/* ---------- 背景 ---------- */
.scene { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.flake {
  position: absolute; top: -4vh; left: var(--x); width: var(--s); height: var(--s); border-radius: 50%;
  background: #fff; opacity: .7;
  animation: fall var(--t) linear infinite; animation-delay: calc(var(--t) * var(--p) * -1);
}
@keyframes fall { to { transform: translate3d(6vw, 108vh, 0); } }
.blob {
  position: absolute; left: var(--x); top: var(--y); width: var(--s); height: var(--s); border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 208, 96, .28), transparent 70%);
  animation: drift 9s ease-in-out infinite alternate; animation-delay: calc(var(--d) * -1);
}
@keyframes drift { to { transform: translate(14px, -22px); } }
.lantern {
  position: absolute; top: -6px; left: var(--x); font-size: var(--s); line-height: 1.2;
  transform-origin: 50% 0; animation: sway 4s ease-in-out infinite alternate; animation-delay: var(--d);
}

/* ---------- 弹层 ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 50; display: flex; padding: 20px; overflow: auto;
  background: rgba(0, 0, 0, .55); opacity: 0; transition: opacity .22s;
}
.overlay.is-in { opacity: 1; }
.panel {
  width: 100%; max-width: 400px; margin: auto; padding: 22px 20px;
  border: 1px solid var(--line); border-radius: 24px; background: var(--panel);
  box-shadow: 0 20px 50px rgba(0, 0, 0, .4);
  transform: translateY(12px) scale(.98); transition: transform .25s cubic-bezier(.2, .9, .3, 1.1);
}
.overlay.is-in .panel { transform: none; }
.modal-emoji { font-size: 44px; text-align: center; line-height: 1; }
.panel h2 { margin: 12px 0 4px; text-align: center; font-size: 20px; }
.panel p { margin: 0 0 18px; text-align: center; color: var(--muted); font-size: 15px; }
.panel-actions { display: grid; gap: 10px; }
.sheet-title { margin-top: 0 !important; }
.sheet-sub { margin-bottom: 4px !important; }
.composer .field { margin-top: 14px; }
.icons { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; margin: 14px 0 4px; }
.icon-pick { position: relative; }
.icon-pick input { position: absolute; inset: 0; margin: 0; opacity: 0; }
.icon-pick span {
  display: grid; place-items: center; aspect-ratio: 1; border-radius: 12px; font-size: 24px;
  border: 1.5px solid var(--line); background: var(--card);
  transition: transform .15s, border-color .15s, background .15s;
}
.icon-pick input:checked + span { border-color: var(--accent-2); background: var(--card-strong); transform: scale(1.1); }
.panel-actions { margin-top: 16px; }

.note-icon {
  width: 64px; height: 64px; margin: 0 auto; border-radius: 50%; display: grid; place-items: center;
  font-size: 32px; background: radial-gradient(circle at 35% 30%, var(--accent-2), var(--accent));
  box-shadow: 0 8px 18px rgba(0, 0, 0, .3);
}
.note-from { margin-top: 12px; text-align: center; font-weight: 700; font-size: 17px; }
.note-text { margin: 12px 0 6px !important; color: var(--ink) !important; font-size: 18px !important; line-height: 1.6 !important; word-break: break-word; }
.note time { display: block; margin-bottom: 4px; text-align: center; font-size: 12px; color: var(--muted); }
.danger-link { padding: 8px; border: 0; background: none; color: #ffb4ad; font-size: 14px; text-decoration: underline; }
.copy-field {
  width: 100%; margin-bottom: 14px; padding: 12px; border-radius: 12px;
  border: 1px solid var(--line); background: rgba(255, 255, 255, .06); color: var(--ink); font-size: 14px;
}

.toast {
  position: fixed; left: 50%; bottom: calc(28px + env(safe-area-inset-bottom)); z-index: 60;
  max-width: 86vw; padding: 10px 16px; border-radius: 999px;
  background: rgba(0, 0, 0, .82); color: #fff; font-size: 14px; text-align: center;
  opacity: 0; visibility: hidden; transform: translate(-50%, 20px); pointer-events: none;
  transition: opacity .2s, transform .2s, visibility .2s;
}
.toast.is-in { opacity: 1; visibility: visible; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  .swing, .env, .light, .flake, .blob, .lantern, #star, .gift.is-new { animation: none !important; }
}
