:root {
  --paper: #f7f1e3;
  --card: #fffdf6;
  --ink: #3d322a;
  --ink-soft: #8d7d6c;
  --line: #e6d9c0;
  --rose: #a94e42;
  --rose-deep: #8c3d33;
  --gold: #a8833f;
  --shadow: 0 10px 30px rgba(93, 70, 45, 0.1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "STSong", "SimSun", serif;
  color: var(--ink);
  line-height: 1.7;
  min-height: 100vh;
  background:
    radial-gradient(1100px 460px at 50% -120px, rgba(169, 78, 66, 0.07), transparent 60%),
    var(--paper);
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.05;
  z-index: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)' opacity='0.6'/%3E%3C/svg%3E");
}

.app { position: relative; z-index: 1; }

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

@keyframes floaty {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

/* ---------- 按钮 ---------- */

.btn-primary {
  background: var(--rose);
  color: #fff6ea;
  border: none;
  border-radius: 10px;
  padding: 12px 24px;
  font: inherit;
  font-size: 14px;
  letter-spacing: 0.12em;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(169, 78, 66, 0.3);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn-primary:active { transform: translateY(1px); }

.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 22px;
  font: inherit;
  font-size: 13px;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.btn-ghost:hover { border-color: var(--gold); color: var(--ink); }

/* ---------- 首页 ---------- */

.hero {
  text-align: center;
  padding: 58px 20px 8px;
  animation: rise 0.7s ease both;
}

.hero-date {
  font-family: Georgia, "Times New Roman", serif;
  font-style: italic;
  letter-spacing: 0.18em;
  color: var(--gold);
  font-size: 13px;
  margin-bottom: 16px;
}

.hero-title {
  font-size: clamp(34px, 8vw, 52px);
  font-weight: 700;
  letter-spacing: 0.14em;
}

.hero-sub {
  color: var(--ink-soft);
  font-size: 14px;
  margin-top: 10px;
  letter-spacing: 0.22em;
}

.hero-days {
  display: inline-block;
  margin-top: 20px;
  padding: 7px 20px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  box-shadow: var(--shadow);
  font-size: 13px;
  color: var(--ink-soft);
  letter-spacing: 0.08em;
}

.hero-days b {
  color: var(--rose);
  font-size: 16px;
  margin: 0 3px;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
  max-width: 720px;
  margin: 36px auto 0;
  padding: 0 20px 64px;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 28px 12px 18px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  text-decoration: none;
  color: var(--ink);
  box-shadow: 0 6px 18px rgba(93, 70, 45, 0.07);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
  animation: rise 0.6s ease both;
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 26px rgba(93, 70, 45, 0.14);
  border-color: var(--gold);
}

.card-month { font-size: 16px; font-weight: 700; letter-spacing: 0.06em; }

.card-num { font-size: 12px; color: var(--gold); letter-spacing: 0.22em; }

.card-status { font-size: 11px; color: var(--ink-soft); letter-spacing: 0.04em; }

.card.open .card-status { color: var(--rose); }

/* 信封 */
.env {
  width: 66px;
  height: 46px;
  border-radius: 8px;
  position: relative;
  background: linear-gradient(135deg, #f2e6cf, #e9d9bb);
  border: 1px solid #dcc9a4;
  margin-bottom: 6px;
}

.env::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 62%;
  background: linear-gradient(to bottom, #e2cda6, #e9d9bb);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
}

.env::after {
  content: attr(data-seal);
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -46%);
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #c25e50, var(--rose) 60%, var(--rose-deep));
  color: #fdf4e6;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.18);
}

.card.open .env::after {
  background: radial-gradient(circle at 35% 30%, #b5a487, #9c8a6b 60%, #85744f);
}

/* ---------- 信件页 ---------- */

.letter-wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 26px 16px 70px;
}

.back {
  display: inline-block;
  font-size: 13px;
  color: var(--ink-soft);
  text-decoration: none;
  margin-bottom: 20px;
  letter-spacing: 0.06em;
  transition: color 0.15s ease;
}

.back:hover { color: var(--rose); }

.letter {
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 6px 6px 20px 20px;
  box-shadow: var(--shadow);
  padding: 44px 26px 40px;
  animation: rise 0.5s ease both;
}

.letter::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0 27px,
    rgba(61, 50, 42, 0.045) 27px 28px
  );
}

.letter-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 8px;
  border-bottom: 1px dashed var(--line);
  padding-bottom: 16px;
  margin-bottom: 28px;
}

.letter-kicker {
  font-size: 13px;
  color: var(--rose);
  letter-spacing: 0.28em;
}

.letter-stamp {
  font-family: Georgia, "Times New Roman", serif;
  font-style: italic;
  color: var(--gold);
  font-size: 12px;
  letter-spacing: 0.14em;
  line-height: 1.5;
}

.letter-body {
  font-size: 17px;
  line-height: 2.05;
  word-break: break-word;
}

.letter-body p { margin: 0 0 1em; }

.letter-body h1, .letter-body h2, .letter-body h3 {
  font-weight: 700;
  letter-spacing: 0.06em;
  margin: 1.5em 0 0.7em;
}

.letter-body h1 { font-size: 22px; }
.letter-body h2 { font-size: 20px; }
.letter-body h3 { font-size: 18px; }

.letter-body img {
  max-width: 100%;
  border-radius: 10px;
  margin: 1.2em 0;
  box-shadow: 0 6px 18px rgba(93, 70, 45, 0.12);
}

.letter-body blockquote {
  border-left: 3px solid var(--rose);
  padding: 2px 0 2px 14px;
  color: var(--ink-soft);
  margin: 1.2em 0;
}

.letter-body ul, .letter-body ol {
  margin: 0 0 1em;
  padding-left: 1.5em;
}

.letter-body li { margin: 0.3em 0; }

.letter-body hr {
  border: none;
  border-top: 1px dashed var(--line);
  margin: 2.2em auto;
  width: 60%;
}

.letter-body a { color: var(--rose); }

.letter-body code {
  background: #f3ead8;
  border-radius: 4px;
  padding: 0.1em 0.4em;
  font-size: 0.9em;
}

.letter-body pre {
  background: #f3ead8;
  border-radius: 10px;
  padding: 14px;
  overflow-x: auto;
  margin: 1em 0;
}

.letter-body pre code { background: none; padding: 0; }

.letter-body table {
  border-collapse: collapse;
  margin: 1.2em 0;
  font-size: 0.95em;
}

.letter-body th, .letter-body td {
  border: 1px solid var(--line);
  padding: 6px 12px;
}

.letter-foot {
  margin-top: 44px;
  text-align: right;
  font-family: Georgia, "Times New Roman", serif;
  font-style: italic;
  color: var(--ink-soft);
  font-size: 12px;
  letter-spacing: 0.16em;
}

/* ---------- 未解锁 ---------- */

.locked {
  text-align: center;
  padding: 64px 24px 60px;
  max-width: 440px;
  margin: 0 auto;
  animation: rise 0.6s ease both;
}

.locked-env {
  width: 150px;
  height: 104px;
  border-radius: 14px;
  position: relative;
  margin: 0 auto 36px;
  background: linear-gradient(135deg, #f2e6cf, #e9d9bb);
  border: 1px solid #dcc9a4;
  box-shadow: 0 14px 34px rgba(93, 70, 45, 0.16);
  animation: floaty 3.6s ease-in-out infinite;
}

.locked-env::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 62%;
  background: linear-gradient(to bottom, #e2cda6, #e9d9bb);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
}

.locked-env .seal {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -46%);
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #c25e50, var(--rose) 60%, var(--rose-deep));
  color: #fdf4e6;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.22);
}

.locked h2 {
  font-size: 24px;
  letter-spacing: 0.12em;
}

.locked-time {
  margin-top: 14px;
  color: var(--ink-soft);
  font-size: 15px;
  letter-spacing: 0.04em;
}

.locked-time b {
  color: var(--rose);
  font-weight: 700;
}

.locked-hint {
  margin-top: 6px;
  font-size: 13px;
  color: var(--ink-soft);
  opacity: 0.85;
}

.locked .btn-ghost { margin-top: 30px; }

/* ---------- 骨架屏 ---------- */

.loading {
  text-align: center;
  padding: 96px 24px;
  animation: rise 0.6s ease both;
}

.loading-text {
  margin-top: 26px;
  color: var(--ink-soft);
  font-size: 14px;
  letter-spacing: 0.24em;
}

/* ---------- 入口 ---------- */

.entry {
  text-align: center;
  padding: 92px 24px;
  max-width: 400px;
  margin: 0 auto;
  animation: rise 0.6s ease both;
}

.entry h2 {
  font-size: 24px;
  letter-spacing: 0.14em;
}

.entry-hint {
  margin-top: 10px;
  font-size: 14px;
  color: var(--ink-soft);
}

.entry-form {
  display: flex;
  gap: 10px;
  margin-top: 28px;
  flex-wrap: wrap;
}

.entry-form input {
  flex: 1;
  min-width: 0;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  font: inherit;
  font-size: 15px;
  color: var(--ink);
  outline: none;
}

.entry-form input:focus { border-color: var(--gold); }

/* ---------- 错误 ---------- */

.error-box {
  text-align: center;
  padding: 90px 24px;
}

.error-box h2 {
  font-size: 22px;
  letter-spacing: 0.1em;
}

.error-box p {
  margin-top: 10px;
  color: var(--ink-soft);
  font-size: 14px;
}

.error-box .btn-primary { margin-top: 30px; }

/* ---------- 后台 ---------- */

.admin {
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px 16px 60px;
}

.admin-head {
  display: flex;
  align-items: baseline;
  gap: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.admin-head h1 {
  font-size: 18px;
  letter-spacing: 0.14em;
}

.admin-sub {
  font-size: 12px;
  color: var(--ink-soft);
}

.admin-body {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.admin-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1 1 170px;
  min-width: 0;
}

.admin-nav button {
  text-align: left;
  font: inherit;
  font-size: 14px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  transition: border-color 0.15s ease;
}

.admin-nav button:hover { border-color: var(--gold); }

.admin-nav button.on {
  border-color: var(--rose);
  background: #fdf3ea;
  color: var(--rose-deep);
}

.admin-nav .st {
  font-size: 11px;
  color: var(--ink-soft);
  flex-shrink: 0;
}

.admin-editor {
  flex: 3 1 480px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.admin-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
  flex-wrap: wrap;
}

.admin-count, .admin-status {
  font-size: 12px;
  color: var(--ink-soft);
}

.admin-status.dirty { color: var(--rose); }

.admin-editor textarea {
  width: 100%;
  min-height: 340px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  font: inherit;
  font-size: 15px;
  line-height: 1.9;
  resize: vertical;
  background: var(--card);
  color: var(--ink);
  outline: none;
}

.admin-editor textarea:focus { border-color: var(--gold); }

.admin-preview {
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 18px 22px 10px;
  background: var(--card);
}

.admin-preview h4 {
  color: var(--ink-soft);
  font-weight: normal;
  font-size: 12px;
  letter-spacing: 0.24em;
  margin-bottom: 8px;
}

.admin-preview .letter-body {
  font-size: 15px;
  line-height: 1.9;
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 40px;
  transform: translate(-50%, 16px);
  background: rgba(61, 50, 42, 0.92);
  color: #f7f1e3;
  font-size: 13px;
  letter-spacing: 0.06em;
  padding: 10px 22px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 50;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- 移动端 ---------- */

@media (max-width: 480px) {
  .hero { padding-top: 44px; }
  .letter { padding: 36px 20px 32px; }
  .letter-body { font-size: 16px; }
  .admin-nav {
    flex-direction: row;
    flex-wrap: wrap;
    flex-basis: 100%;
  }
  .admin-nav button { flex: 1 1 140px; }
}
