/* ============================================
   Rayna · 暖象牙白 × 墨蓝 · 极简高级感
   ============================================ */

:root {
  --ivory: #F7F2E9;
  --paper: #FDFAF3;
  --ink: #1B3A5C;
  --ink-soft: #33567E;
  --mist: #8CA3C0;
  --gold: #C2A06B;
  --hairline: rgba(27, 58, 92, 0.14);
  --shadow: 0 1px 2px rgba(27, 58, 92, 0.04), 0 8px 28px rgba(27, 58, 92, 0.07);
  --serif: "Cormorant Garamond", "Noto Serif SC", "Songti SC", "STSong", Georgia, serif;
  --sans: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
}

/* ---------- 夜信纸 ---------- */
body.dark {
  --ivory: #101F31;
  --paper: #1B3A5C;
  --ink: #F1EAD9;
  --ink-soft: #D8CDB6;
  --mist: #7E93AF;
  --hairline: rgba(241, 234, 217, 0.16);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.2), 0 8px 28px rgba(0, 0, 0, 0.3);
}
body, .modal-paper, .entry-card, .anni-card, .me-card, .partner-card, .envelope, .bottombar, .letter-hint, .msg-bubble, .btn-ink, .login-user-btn, .photo-item, .wish-check {
  transition: background-color .4s ease, color .4s ease, border-color .4s ease;
}
.theme-btn { font-size: 16px; padding: 6px; line-height: 1; opacity: .75; }
.theme-btn:hover { opacity: 1; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
body.dark .msg-row.mine .msg-bubble { background: #E9E1CD; color: #16293E; }
body.dark .btn-ink { background: #E9E1CD; color: #16293E; }
body.dark .btn-ink:hover { background: #F7F2E9; }
body.dark .login-user-btn.active { background: #E9E1CD; color: #16293E; border-color: #E9E1CD; }
body.dark .wish-item.done .wish-check { background: #E9E1CD; border-color: #E9E1CD; color: #16293E; }
body.dark .modal { background: rgba(5, 12, 20, 0.5); }
body.dark .modal-paper { box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5); }
body.dark .check-row input { accent-color: #E9E1CD; }

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: var(--sans);
  background: var(--ivory);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; background: none; border: none; color: inherit; }
input, textarea {
  font-family: inherit; font-size: 15px; color: var(--ink);
  background: transparent; border: none; outline: none;
  border-bottom: 1px solid var(--hairline);
  padding: 10px 2px; transition: border-color .3s;
}
input:focus, textarea:focus { border-bottom-color: var(--ink); }
textarea { resize: vertical; line-height: 1.8; }
::placeholder { color: var(--mist); }

/* ---------- 按钮 ---------- */
.btn-ink {
  background: var(--ink); color: var(--paper);
  padding: 12px 30px; letter-spacing: .15em; font-size: 14px;
  transition: background .3s, transform .2s;
}
.btn-ink:hover { background: var(--ink-soft); }
.btn-ink:active { transform: scale(.98); }
.btn-outline {
  border: 1px solid var(--hairline); color: var(--ink);
  padding: 8px 20px; font-size: 13px; letter-spacing: .1em;
  transition: all .3s;
}
.btn-outline:hover { border-color: var(--ink); background: var(--paper); }
.btn-text {
  color: var(--mist); font-size: 13px; letter-spacing: .08em; padding: 8px 4px;
  transition: color .3s;
}
.btn-text:hover { color: var(--ink); }

/* ---------- 登录 ---------- */
#login-view {
  min-height: 100%; display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.login-wrap {
  width: 340px; text-align: center;
  animation: rise .8s ease both;
}
.login-eyebrow {
  font-size: 11px; letter-spacing: .4em; color: var(--gold); margin-bottom: 18px;
}
.login-wordmark {
  font-family: var(--serif); font-weight: 500; font-size: 44px;
  letter-spacing: .06em; color: var(--ink);
}
.login-rule {
  width: 42px; height: 1px; background: var(--gold); margin: 22px auto 30px;
}
.login-users { display: flex; gap: 12px; justify-content: center; margin-bottom: 22px; }
.login-user-btn {
  flex: 1; padding: 13px 0; font-family: var(--serif); font-size: 17px;
  letter-spacing: .1em; color: var(--mist);
  border: 1px solid var(--hairline); background: var(--paper);
  transition: all .3s;
}
.login-user-btn.active { color: var(--paper); background: var(--ink); border-color: var(--ink); }
#login-view input { width: 100%; text-align: center; letter-spacing: .2em; margin-bottom: 20px; }
#login-btn { width: 100%; }
.login-error { color: #A4606C; font-size: 13px; margin-top: 14px; min-height: 20px; }

/* ---------- 框架 ---------- */
#app-view { min-height: 100%; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  max-width: 960px; width: 100%; margin: 0 auto;
  padding: 22px 28px 18px;
  border-bottom: 1px solid var(--hairline);
}
.wordmark { font-family: var(--serif); font-size: 22px; letter-spacing: .08em; }
.topnav { display: flex; gap: 26px; }
.nav-item {
  font-size: 14px; letter-spacing: .12em; color: var(--mist);
  padding: 4px 0; border-bottom: 1px solid transparent; transition: all .3s;
}
.nav-item:hover { color: var(--ink); }
.nav-item.active { color: var(--ink); border-bottom-color: var(--gold); }

.page {
  flex: 1; width: 100%; max-width: 960px; margin: 0 auto;
  padding: 40px 28px 80px;
}
.panel { animation: fade .5s ease both; }

.panel-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 14px; }
.panel-title {
  font-family: var(--serif); font-weight: 600; font-size: 26px; letter-spacing: .08em;
}
.panel-sub { color: var(--mist); font-size: 13px; margin-bottom: 26px; }

/* ---------- 序章 ---------- */
.hero { text-align: center; padding: 48px 0 40px; }
.hero-names {
  font-family: var(--serif); font-size: 20px; letter-spacing: .18em; color: var(--ink-soft);
}
.hero-names .amp { color: var(--gold); font-style: italic; margin: 0 6px; }
.hero-eyebrow { margin-top: 44px; font-size: 13px; letter-spacing: .3em; color: var(--mist); }
.hero-days {
  font-family: var(--serif); color: var(--ink);
  display: flex; align-items: baseline; justify-content: center; gap: 14px;
}
#days-num { font-size: 118px; line-height: 1.1; font-weight: 500; font-variant-numeric: tabular-nums; }
.hero-days-unit { font-size: 22px; letter-spacing: .2em; color: var(--ink-soft); }
.hero-since { margin-top: 6px; font-size: 13px; letter-spacing: .22em; color: var(--mist); }
.hero-rule { width: 42px; height: 1px; background: var(--gold); margin: 34px auto; }
.hero-greeting { font-family: var(--serif); font-size: 17px; letter-spacing: .12em; color: var(--ink-soft); }
.hero-presence { margin-top: 12px; font-size: 12px; letter-spacing: .14em; color: var(--mist); }
.hero-presence .on { color: var(--gold); }
.hero-status {
  margin-top: 8px; font-size: 13px; letter-spacing: .1em; color: var(--ink-soft);
  cursor: pointer; transition: color .3s;
}
.hero-status:hover { color: var(--ink); }
.hero-status.empty { color: var(--mist); font-size: 12px; }
.status-edit {
  margin-top: 8px; display: flex; align-items: center; justify-content: center; gap: 10px;
}
.status-edit input { width: 240px; text-align: center; font-size: 13px; padding: 6px 2px; }

.letter-hint {
  max-width: 420px; margin: 0 auto 40px;
  display: flex; align-items: center; justify-content: center; gap: 12px;
  padding: 14px 20px; background: var(--paper); box-shadow: var(--shadow);
  font-size: 14px; color: var(--ink-soft); letter-spacing: .06em;
  animation: rise .6s ease both;
}
.letter-hint-seal {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--gold); flex: none;
}

.entry-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px;
  max-width: 880px; margin: 0 auto;
}
.entry-card {
  background: var(--paper); box-shadow: var(--shadow);
  padding: 26px 22px 24px; text-align: left;
  display: flex; flex-direction: column; gap: 8px;
  transition: transform .35s ease, box-shadow .35s ease;
}
.entry-card:hover { transform: translateY(-4px); box-shadow: 0 2px 4px rgba(27,58,92,.05), 0 16px 40px rgba(27,58,92,.1); }
.entry-num {
  font-family: var(--serif); font-size: 13px; letter-spacing: .2em; color: var(--gold);
}
.entry-title { font-family: var(--serif); font-size: 19px; letter-spacing: .1em; color: var(--ink); }
.entry-desc { font-size: 12px; color: var(--mist); letter-spacing: .05em; }

/* ---------- 聊天 ---------- */
.chat-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 20px; }
.chat-presence { font-size: 12px; letter-spacing: .14em; color: var(--mist); }
.chat-presence .on { color: var(--gold); }
.chat-list {
  height: calc(100vh - 320px); min-height: 300px;
  overflow-y: auto; padding: 8px 2px;
  display: flex; flex-direction: column; gap: 14px;
}
.msg-day {
  display: flex; align-items: center; gap: 14px;
  font-family: var(--serif); font-size: 12px; letter-spacing: .2em; color: var(--mist);
  margin: 14px 0 2px;
}
.msg-day::before, .msg-day::after { content: ""; flex: 1; height: 1px; background: var(--hairline); }
.msg-row { display: flex; }
.msg-row.mine { justify-content: flex-end; }
.msg-body { max-width: 68%; }
.msg-bubble {
  padding: 11px 16px; font-size: 15px; line-height: 1.7;
  word-break: break-word; white-space: pre-wrap;
}
.msg-row.mine .msg-bubble { background: var(--ink); color: var(--paper); }
.msg-row.theirs .msg-bubble { background: var(--paper); color: var(--ink); box-shadow: var(--shadow); }
.msg-time { font-size: 11px; color: var(--mist); margin-top: 5px; letter-spacing: .08em; }
.msg-row.mine .msg-time { text-align: right; }
.typing-hint { font-size: 12px; color: var(--mist); letter-spacing: .1em; padding: 6px 2px; }
.chat-bar { display: flex; gap: 14px; align-items: center; margin-top: 10px; }
.chat-bar input { flex: 1; }

/* ---------- 时光信 ---------- */
.letter-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.envelope {
  background: var(--paper); box-shadow: var(--shadow);
  padding: 26px 24px; position: relative; text-align: left;
  display: flex; flex-direction: column; gap: 10px;
  transition: transform .35s ease;
  width: 100%;
}
.envelope:hover { transform: translateY(-3px); }
.envelope-seal {
  position: absolute; top: 22px; right: 22px;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--gold); opacity: .85;
}
.envelope.opened .envelope-seal { background: transparent; border: 1px solid var(--hairline); }
.envelope-title { font-family: var(--serif); font-size: 19px; letter-spacing: .08em; color: var(--ink); padding-right: 30px; }
.envelope-meta { font-size: 12px; color: var(--mist); letter-spacing: .1em; }
.envelope-status { font-size: 13px; letter-spacing: .08em; }
.envelope-status.locked { color: var(--mist); }
.envelope-status.ready { color: var(--gold); }
.empty-hint {
  text-align: center; color: var(--mist); font-size: 14px; padding: 48px 0;
  letter-spacing: .1em; grid-column: 1 / -1;
}

/* ---------- 纪念日 ---------- */
.anni-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.anni-card {
  background: var(--paper); box-shadow: var(--shadow);
  padding: 22px 24px; display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.anni-name { font-family: var(--serif); font-size: 17px; letter-spacing: .06em; }
.anni-date { font-size: 12px; color: var(--mist); margin-top: 4px; letter-spacing: .1em; }
.anni-count { text-align: right; flex: none; }
.anni-count .num { font-family: var(--serif); font-size: 30px; color: var(--ink); line-height: 1.1; }
.anni-count .label { font-size: 11px; color: var(--mist); letter-spacing: .12em; }
.anni-del { color: var(--mist); font-size: 13px; padding: 6px; align-self: flex-start; }
.anni-del:hover { color: #A4606C; }

/* ---------- 时间线 ---------- */
.timeline { position: relative; padding-left: 28px; margin-top: 10px; }
.timeline::before {
  content: ""; position: absolute; left: 5px; top: 8px; bottom: 8px;
  width: 1px; background: var(--hairline);
}
.tl-item { position: relative; padding: 0 0 30px 8px; animation: fade .5s ease both; }
.tl-item::before {
  content: ""; position: absolute; left: -27px; top: 9px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--gold);
}
.tl-item.major::before { width: 11px; height: 11px; left: -29px; top: 7px; background: var(--ink); }
.tl-date { font-size: 12px; letter-spacing: .16em; color: var(--mist); }
.tl-text { font-family: var(--serif); font-size: 17px; letter-spacing: .05em; color: var(--ink); margin-top: 3px; }
.tl-note { font-size: 13px; color: var(--ink-soft); margin-top: 3px; }
.tl-del { color: var(--mist); font-size: 12px; margin-left: 10px; }
.tl-del:hover { color: #A4606C; }

/* ---------- 照片 ---------- */
.photo-grid { columns: 3 220px; column-gap: 16px; }
.photo-item {
  break-inside: avoid; margin-bottom: 16px; background: var(--paper);
  padding: 8px 8px 10px; box-shadow: var(--shadow); cursor: zoom-in;
  transition: transform .35s ease;
}
.photo-item:hover { transform: translateY(-3px); }
.photo-item img { width: 100%; display: block; }
.photo-cap { font-size: 12px; color: var(--mist); padding: 8px 4px 0; letter-spacing: .05em; }

/* ---------- 头像 ---------- */
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  background: var(--ink); color: var(--paper);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--serif); font-size: 15px; letter-spacing: 0;
  overflow: hidden; user-select: none;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.xl { width: 84px; height: 84px; font-size: 32px; }
.avatar.hero-av { width: 40px; height: 40px; font-size: 17px; box-shadow: var(--shadow); }

.msg-row .avatar { align-self: flex-end; margin-bottom: 2px; }
.msg-row.mine .avatar { margin-left: 10px; order: 2; }
.msg-row.theirs .avatar { margin-right: 10px; }
.hero-names { display: flex; align-items: center; justify-content: center; gap: 16px; }

/* ---------- 我的 ---------- */
.me-card {
  display: flex; gap: 36px; align-items: flex-start;
  background: var(--paper); box-shadow: var(--shadow); padding: 32px;
}
.me-avatar-col { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.me-fields { flex: 1; display: flex; flex-direction: column; gap: 12px; }
.me-row { display: flex; align-items: center; gap: 12px; }
.me-row input { flex: 1; }
.me-hint { font-size: 12px; color: var(--gold); min-height: 18px; letter-spacing: .06em; }
.partner-card {
  display: flex; gap: 20px; align-items: center;
  background: var(--paper); box-shadow: var(--shadow); padding: 24px 32px;
}
.partner-name { font-family: var(--serif); font-size: 20px; letter-spacing: .08em; }
.partner-sub { font-size: 12px; color: var(--mist); letter-spacing: .1em; margin-top: 4px; }

/* ---------- 心愿单 ---------- */
.wish-input-row { display: flex; gap: 14px; align-items: center; margin-bottom: 30px; }
.wish-input-row input { flex: 1; }
.wish-list { display: flex; flex-direction: column; }
.wish-item {
  display: flex; align-items: center; gap: 16px;
  padding: 16px 2px; border-bottom: 1px solid var(--hairline);
  animation: fade .4s ease both;
}
.wish-check {
  width: 20px; height: 20px; flex: none; border-radius: 50%;
  border: 1px solid var(--mist); transition: all .3s;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; color: var(--paper);
}
.wish-item.done .wish-check { background: var(--ink); border-color: var(--ink); }
.wish-text { flex: 1; font-size: 15px; letter-spacing: .03em; transition: color .3s; }
.wish-item.done .wish-text { color: var(--mist); text-decoration: line-through; text-decoration-color: var(--hairline); }
.wish-meta { font-size: 11px; color: var(--mist); letter-spacing: .1em; flex: none; }
.wish-del { color: var(--mist); font-size: 13px; padding: 4px; }
.wish-del:hover { color: #A4606C; }

/* ---------- 弹窗 ---------- */
.modal {
  position: fixed; inset: 0; z-index: 30;
  background: rgba(27, 58, 92, 0.28);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  animation: fade .3s ease both;
}
.modal-paper {
  background: var(--paper); width: 400px; max-width: 100%;
  padding: 36px 34px; box-shadow: 0 24px 64px rgba(27, 58, 92, 0.2);
  display: flex; flex-direction: column; gap: 16px;
  animation: rise .4s ease both;
  max-height: 88vh; overflow-y: auto;
}
.modal-title { font-family: var(--serif); font-size: 22px; letter-spacing: .1em; font-weight: 600; }
.field-label { font-size: 12px; letter-spacing: .14em; color: var(--mist); margin-bottom: -10px; }
.check-row { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--ink-soft); }
.check-row input { accent-color: var(--ink); }
.modal-actions { display: flex; justify-content: flex-end; align-items: center; gap: 14px; margin-top: 8px; }
.photo-preview { max-height: 220px; object-fit: contain; border: 1px solid var(--hairline); }

/* 读信 */
.read-paper { width: 460px; padding: 44px 42px; }
.read-from { font-size: 12px; letter-spacing: .2em; color: var(--gold); }
.read-title { font-family: var(--serif); font-size: 24px; letter-spacing: .08em; font-weight: 600; }
.read-rule { width: 34px; height: 1px; background: var(--gold); }
.read-body { font-size: 15px; line-height: 2; color: var(--ink-soft); white-space: pre-wrap; }
.read-date { font-size: 12px; color: var(--mist); letter-spacing: .14em; text-align: right; }

/* ---------- 大图 ---------- */
.lightbox {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(18, 32, 48, 0.92);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  animation: fade .3s ease both;
}
.lightbox img { max-width: 90vw; max-height: 78vh; animation: rise .4s ease both; }
.lightbox-caption { color: rgba(253, 250, 243, .8); font-size: 14px; letter-spacing: .08em; }
.lightbox-close { position: absolute; top: 22px; right: 26px; color: rgba(253,250,243,.7); font-size: 22px; }
.lightbox-close:hover { color: #fff; }
.lightbox-delete {
  position: absolute; bottom: 26px; right: 26px;
  color: rgba(253,250,243,.6); font-size: 13px; letter-spacing: .1em;
  border-bottom: 1px solid transparent; transition: all .3s;
}
.lightbox-delete:hover { color: #E8B4BC; border-bottom-color: #E8B4BC; }

/* ---------- 底部导航（移动端） ---------- */
.bottombar {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  background: var(--paper); border-top: 1px solid var(--hairline);
  padding: 10px 0 calc(10px + env(safe-area-inset-bottom));
}
.bnav-item {
  flex: 1; font-size: 12px; letter-spacing: .1em; color: var(--mist);
  padding: 4px 0; transition: color .3s;
}
.bnav-item.active { color: var(--ink); }

/* ---------- 戳一下 ---------- */
.poke-btn {
  margin-top: 14px; font-size: 12px; letter-spacing: .16em; color: var(--mist);
  border-bottom: 1px solid transparent; padding: 4px 2px; transition: all .3s;
}
.poke-btn:hover { color: var(--gold); border-bottom-color: var(--gold); }
.poke-toast {
  position: fixed; top: 72px; left: 50%; transform: translateX(-50%);
  z-index: 50; background: var(--paper); box-shadow: var(--shadow);
  padding: 12px 28px; font-family: var(--serif); font-size: 15px; letter-spacing: .1em;
  color: var(--ink); animation: pokeIn .5s ease both;
}
@keyframes pokeIn {
  0% { opacity: 0; transform: translate(-50%, -10px); }
  100% { opacity: 1; transform: translate(-50%, 0); }
}
.poke-toast.bye { animation: pokeOut .5s ease both; }
@keyframes pokeOut {
  0% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -10px); }
}
.hero-names.wiggle { animation: wiggle .6s ease; }
@keyframes wiggle {
  0%, 100% { transform: none; }
  25% { transform: rotate(-1.2deg) scale(1.02); }
  75% { transform: rotate(1.2deg) scale(1.02); }
}

/* ---------- 每周回顾 ---------- */
.digest-card {
  margin-top: 28px; background: var(--paper); box-shadow: var(--shadow);
  padding: 28px 32px; text-align: center;
}
.digest-eyebrow { font-size: 11px; letter-spacing: .4em; color: var(--gold); margin-bottom: 14px; }
.digest-content {
  font-family: var(--serif); font-size: 16px; line-height: 2; letter-spacing: .05em;
  color: var(--ink-soft); max-width: 560px; margin: 0 auto 10px; white-space: pre-wrap;
}

/* ---------- 信件照片 ---------- */
.letter-photo-row { display: flex; align-items: center; gap: 12px; }
.letter-photo-preview { max-height: 72px; border: 1px solid var(--hairline); }
.read-photo { max-width: 100%; border: 1px solid var(--hairline); }
.envelope-has-photo { font-size: 11px; color: var(--gold); letter-spacing: .1em; }

/* ---------- 相框入口 ---------- */
.frame-link-wrap { text-align: center; margin-top: 36px; }
.frame-link {
  font-size: 12px; letter-spacing: .16em; color: var(--mist); text-decoration: none;
  border-bottom: 1px solid transparent; transition: all .3s;
}
.frame-link:hover { color: var(--gold); border-bottom-color: var(--gold); }

/* ---------- 动效 ---------- */
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-thumb { background: var(--hairline); }

/* ---------- 响应式 ---------- */
@media (max-width: 760px) {
  .topnav { display: none; }
  .bottombar { display: flex; }
  .page { padding: 28px 20px 110px; }
  .entry-grid { grid-template-columns: repeat(2, 1fr); }
  .letter-list, .anni-list { grid-template-columns: 1fr; }
  #days-num { font-size: 88px; }
  .chat-list { height: calc(100vh - 300px); }
  .msg-body { max-width: 82%; }
  .photo-grid { columns: 2 150px; column-gap: 12px; }
}
