:root {
  --ink: #3b2a46;
  --ink-soft: #7c6a89;
  --rose: #e0658c;
  --gold: #eab14e;
  --paper: rgba(255, 255, 255, .66);
  --line: rgba(120, 90, 130, .16);
  --display: "Kaiti SC", "STKaiti", "Kaiti", "Songti SC", "Noto Serif SC", "Songti TC", serif;
  --sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }

body {
  min-height: 100dvh;
  font-family: var(--sans);
  color: var(--ink);
  background: #f1e7f3;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---------- 背景：流动的晨曦 ---------- */
.aurora {
  position: fixed;
  inset: -22%;
  z-index: -2;
  background:
    radial-gradient(38% 48% at 20% 16%, #ffe1ec 0%, transparent 60%),
    radial-gradient(44% 54% at 84% 12%, #fdf0d6 0%, transparent 62%),
    radial-gradient(56% 60% at 78% 84%, #e2ddf8 0%, transparent 60%),
    radial-gradient(52% 56% at 14% 86%, #f7dcef 0%, transparent 60%),
    linear-gradient(158deg, #fdeef4 0%, #eee7f7 58%, #e6e6f6 100%);
  filter: saturate(1.05);
  animation: drift 24s ease-in-out infinite alternate;
}
@keyframes drift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to   { transform: translate3d(0, -2.5%, 0) scale(1.07); }
}

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

/* ---------- 舞台 ---------- */
.stage {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 30px 20px calc(30px + env(safe-area-inset-bottom));
}

.panel {
  width: 100%;
  max-width: 480px;
  background: var(--paper);
  -webkit-backdrop-filter: blur(16px) saturate(1.25);
  backdrop-filter: blur(16px) saturate(1.25);
  border: 1px solid rgba(255, 255, 255, .72);
  border-radius: 26px;
  box-shadow:
    0 32px 70px -30px rgba(90, 50, 90, .5),
    inset 0 1px 0 rgba(255, 255, 255, .85);
  padding: clamp(28px, 6vw, 44px);
}

.enter { animation: rise .75s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes rise {
  from { opacity: 0; transform: translateY(22px) scale(.975); }
  to   { opacity: 1; transform: none; }
}
.gate.leaving { animation: sink .42s ease forwards; }
@keyframes sink {
  to { opacity: 0; transform: translateY(-14px) scale(.97); }
}

/* ---------- 第一幕：门 ---------- */
.eyebrow {
  margin: 0 0 18px;
  font-family: var(--mono);
  font-size: 12.5px;
  letter-spacing: .04em;
  color: var(--ink-soft);
  opacity: .85;
}
.title {
  margin: 0 0 12px;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(31px, 9vw, 44px);
  line-height: 1.14;
  letter-spacing: .03em;
}
.dots { color: var(--rose); }
.lead {
  margin: 0 0 28px;
  line-height: 1.85;
  font-size: 15.5px;
  color: var(--ink-soft);
}

.fields { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-soft);
}
.field-label em {
  font-family: var(--mono);
  font-style: normal;
  font-size: 11px;
  letter-spacing: .06em;
  color: var(--rose);
}
.field input {
  width: 100%;
  padding: 14px 16px;
  font-family: var(--sans);
  font-size: 16px;
  color: var(--ink);
  background: rgba(255, 255, 255, .7);
  border: 1.5px solid var(--line);
  border-radius: 14px;
  outline: none;
  transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}
.field input::placeholder { color: #b8a8c1; }
.field input:focus {
  border-color: var(--rose);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(224, 101, 140, .16);
}

.btn {
  margin-top: 6px;
  width: 100%;
  padding: 15px 22px;
  font-family: var(--sans);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: .08em;
  color: #fff;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  background: linear-gradient(135deg, #f0808a, #e0658c 55%, #cf63a6);
  box-shadow: 0 16px 30px -12px rgba(207, 99, 166, .6);
  transition: transform .15s ease, filter .2s ease, opacity .2s ease;
}
.btn:hover { transform: translateY(-2px); filter: brightness(1.03); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .65; cursor: default; transform: none; }

.nudge {
  margin: 12px 2px 0;
  min-height: 1.1em;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--rose);
}

/* ---------- 第二幕：信 ---------- */
.letter-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px dashed var(--line);
}
.mono { font-family: var(--mono); font-size: 12px; letter-spacing: .04em; }
.status { color: var(--gold); }
.status.done { color: #3fa06a; }
.counter { color: var(--ink-soft); }

.letter-body {
  font-family: var(--display);
  white-space: pre-wrap;
  word-break: break-word;
  font-size: clamp(19px, 5.4vw, 23px);
  line-height: 2;
  letter-spacing: .02em;
  color: var(--ink);
  min-height: 9em;
}
.caret {
  display: inline-block;
  width: .5em;
  height: 1.1em;
  vertical-align: -.18em;
  margin-left: 3px;
  border-radius: 2px;
  background: linear-gradient(var(--gold), #f3c873);
  box-shadow: 0 0 10px rgba(234, 177, 78, .7);
  animation: blink 1.05s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }
.caret.gone { display: none; }

.letter-foot {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px dashed var(--line);
  animation: rise .6s ease both;
}
.gift { margin: 0; line-height: 1.95; font-size: 15px; }
.gift b { color: var(--rose); }
.gift .muted { color: var(--ink-soft); font-size: 13.5px; }

.link-btn {
  display: inline-block;
  margin: 16px 0 0;
  padding: 0;
  background: none;
  border: none;
  color: var(--ink-soft);
  cursor: pointer;
  text-decoration: underline dotted;
  text-underline-offset: 3px;
}
.how {
  margin: 12px 0 0;
  padding-left: 18px;
  line-height: 1.85;
  font-size: 14px;
  color: var(--ink-soft);
}
.how li { margin-bottom: 4px; }
.how a {
  color: var(--rose);
  text-decoration: none;
  border-bottom: 1px solid rgba(224, 101, 140, .4);
}

.resign {
  margin: 24px 0 0;
  text-align: center;
  font-family: var(--display);
  font-size: 18px;
  line-height: 1.7;
}
.from {
  font-family: var(--sans);
  font-size: 12.5px;
  color: var(--ink-soft);
}

@media (prefers-reduced-motion: reduce) {
  .aurora { animation: none; }
  .enter, .letter-foot { animation: none; }
  .caret { animation: none; }
}
