/* ---------- 基础 ---------- */
:root {
  --bg: #FFF7F3;
  --bg-soft: #FDEEE9;
  --card: #FFFFFF;
  --ink: #3B2F33;
  --ink-2: #7A6A6F;
  --ink-3: #A99A9E;
  --rose: #E4758E;
  --rose-soft: #FCE8EC;
  --gold: #D8A24A;
  --line: rgba(59, 47, 51, 0.08);
  --shadow-sm: 0 2px 10px rgba(180, 120, 130, 0.08);
  --shadow-md: 0 8px 28px rgba(180, 120, 130, 0.14);
  --radius: 20px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --tabbar-h: 62px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

body {
  background:
    radial-gradient(680px 420px at 92% -8%, #FFE3E8 0%, rgba(255, 227, 232, 0) 62%),
    radial-gradient(560px 380px at -10% 8%, #FFF1DA 0%, rgba(255, 241, 218, 0) 60%),
    var(--bg);
  background-attachment: fixed;
  min-height: 100vh;
}

button { font-family: inherit; border: none; background: none; color: inherit; cursor: pointer; }
input, textarea { font-family: inherit; font-size: 15px; color: inherit; }

.app {
  max-width: 540px;
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
  padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + 28px);
}

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  padding-top: env(safe-area-inset-top, 0px);
  background: rgba(255, 247, 243, 0.82);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
}
.topbar-inner {
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
}
.topbar-title {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.icon-btn {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 50%;
  color: var(--ink-3);
}
.icon-btn:active { background: var(--bg-soft); }
.icon-btn svg { width: 18px; height: 18px; }

/* ---------- 视图容器 ---------- */
.view {
  padding: 6px 18px 0;
  animation: fadeUp 0.32s ease both;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 22px 2px 12px;
}
.section-title h2 {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
  letter-spacing: 0.03em;
}
.section-title span {
  font-size: 12px;
  color: var(--ink-3);
}

/* ---------- 主页大卡片 ---------- */
.hero {
  margin-top: 8px;
  padding: 22px 22px 20px;
  border-radius: 26px;
  background: linear-gradient(150deg, #FFDDE2 0%, #FFEDE4 48%, #FFF6EC 100%);
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}
.hero::after {
  content: "";
  position: absolute;
  right: -32px; top: -40px;
  width: 150px; height: 150px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.75), rgba(255, 255, 255, 0));
}
.hero-hi {
  font-size: 13px;
  color: #A06E76;
  letter-spacing: 0.08em;
  margin: 0 0 6px;
}
.hero-days {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin: 0;
}
.hero-days b {
  font-size: 46px;
  line-height: 1;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  color: #8E4C58;
}
.hero-days em {
  font-style: normal;
  font-size: 14px;
  color: #A06E76;
}
.hero-foot {
  margin: 10px 0 0;
  font-size: 13px;
  color: #A06E76;
  display: flex;
  align-items: center;
  gap: 6px;
}
.hero-foot .dot { opacity: 0.45; }

/* ---------- 空状态 ---------- */
.empty {
  padding: 46px 20px 54px;
  text-align: center;
  color: var(--ink-3);
  font-size: 13.5px;
}
.empty .emoji { font-size: 34px; display: block; margin-bottom: 10px; opacity: 0.85; }

/* ---------- 时光轴 ---------- */
.timeline { position: relative; padding-left: 26px; }
.timeline::before {
  content: "";
  position: absolute;
  left: 7px; top: 10px; bottom: 10px;
  width: 1.5px;
  background: linear-gradient(180deg, rgba(228, 117, 142, 0.35), rgba(228, 117, 142, 0.06));
}
.entry { position: relative; margin-bottom: 16px; }
.entry::before {
  content: "";
  position: absolute;
  left: -22px; top: 22px;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: #fff;
  border: 2.2px solid var(--rose);
  box-shadow: 0 0 0 3px rgba(228, 117, 142, 0.12);
}
.entry-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 15px 16px 14px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--line);
}
.entry-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.entry-mood { font-size: 17px; line-height: 1; }
.entry-date {
  font-size: 12px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.entry-author {
  margin-left: auto;
  font-size: 11.5px;
  color: var(--rose);
  background: var(--rose-soft);
  padding: 2px 9px;
  border-radius: 20px;
  white-space: nowrap;
}
.entry-text {
  margin: 0;
  font-size: 14.5px;
  line-height: 1.78;
  white-space: pre-wrap;
  word-break: break-word;
  color: #4A3C40;
}
.entry-photos {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  margin-top: 11px;
}
.entry-photos img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 12px;
  background: var(--bg-soft);
}
.entry-photos.grid-1 { grid-template-columns: 1fr; }
.entry-photos.grid-1 img { aspect-ratio: 4 / 3; }
.entry-photos.grid-2 { grid-template-columns: repeat(2, 1fr); }

.entry-del {
  position: absolute;
  right: 10px; bottom: 8px;
  font-size: 11.5px;
  color: var(--ink-3);
  padding: 4px 8px;
  border-radius: 10px;
  opacity: 0;
  transition: opacity 0.2s;
}
.entry-card:hover .entry-del, .entry-del.show { opacity: 1; }
@media (hover: none) { .entry-del { opacity: 0.55; } }

/* ---------- 相册 ---------- */
.album-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.album-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: 14px;
  overflow: hidden;
  background: var(--bg-soft);
  box-shadow: var(--shadow-sm);
}
.album-item img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.4s ease;
}
.album-item:active img { transform: scale(1.04); }
.album-cap {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 14px 8px 6px;
  font-size: 11px;
  color: #fff;
  background: linear-gradient(transparent, rgba(60, 40, 46, 0.55));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- 纪念日 ---------- */
.aniversary-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--line);
  margin-bottom: 11px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.aniversary-card .emo {
  width: 42px; height: 42px;
  border-radius: 14px;
  display: grid; place-items: center;
  font-size: 20px;
  background: var(--bg-soft);
  flex: 0 0 auto;
}
.aniversary-main { flex: 1; min-width: 0; }
.aniversary-main h3 {
  margin: 0 0 2px;
  font-size: 14.5px;
  font-weight: 600;
}
.aniversary-main p {
  margin: 0;
  font-size: 12px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.aniversary-num {
  text-align: right;
  flex: 0 0 auto;
}
.aniversary-num b {
  display: block;
  font-size: 25px;
  line-height: 1.1;
  font-weight: 600;
  color: var(--rose);
  font-variant-numeric: tabular-nums;
}
.aniversary-num small { font-size: 11px; color: var(--ink-3); }
.aniversary-card.today .aniversary-num b { color: var(--gold); }
.aniversary-card.today {
  background: linear-gradient(120deg, #FFF4E4, #FFFDF9);
}

/* ---------- 悄悄话 ---------- */
body.notes-mode .app { padding-bottom: 0; }
.notes-wrap { padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + 78px); }
.note-row { display: flex; margin-bottom: 12px; }
.note-row.me { justify-content: flex-end; }
.note {
  max-width: 80%;
  padding: 11px 14px 9px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: var(--shadow-sm);
}
.note-row.her .note {
  background: var(--card);
  border-bottom-left-radius: 6px;
  border: 1px solid var(--line);
}
.note-row.me .note {
  background: linear-gradient(135deg, #FFD7DF, #FFE8DC);
  color: #6E3B46;
  border-bottom-right-radius: 6px;
}
.note-meta {
  font-size: 10.5px;
  color: var(--ink-3);
  margin-top: 5px;
  display: flex;
  gap: 6px;
  align-items: center;
}
.note-row.me .note-meta { justify-content: flex-end; }
.note-del { font-size: 10.5px; color: var(--ink-3); opacity: 0.6; }

.note-bar {
  position: fixed;
  left: 0; right: 0;
  bottom: calc(var(--tabbar-h) + var(--safe-b));
  z-index: 45;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 9px 14px;
  background: rgba(255, 247, 243, 0.9);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  max-width: 540px;
  margin: 0 auto;
}
.note-bar textarea {
  flex: 1;
  min-height: 40px;
  max-height: 110px;
  resize: none;
  padding: 10px 14px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: #fff;
  outline: none;
  line-height: 1.5;
}
.note-bar textarea:focus { border-color: rgba(228, 117, 142, 0.45); }
.send-btn {
  width: 40px; height: 40px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--rose);
  color: #fff;
  display: grid; place-items: center;
  box-shadow: 0 4px 12px rgba(228, 117, 142, 0.35);
}
.send-btn:disabled { opacity: 0.4; box-shadow: none; }
.send-btn svg { width: 18px; height: 18px; }

/* ---------- 底部导航 ---------- */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 50;
  max-width: 540px;
  margin: 0 auto;
  height: calc(var(--tabbar-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: rgba(255, 252, 250, 0.92);
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  border-top: 1px solid var(--line);
}
.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--ink-3);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  transition: color 0.2s;
}
.tab svg { width: 21px; height: 21px; transition: transform 0.22s ease; }
.tab.active { color: var(--rose); }
.tab.active svg { transform: translateY(-1px) scale(1.06); }

/* ---------- 悬浮按钮 ---------- */
.fab {
  position: fixed;
  right: max(18px, calc((100vw - 540px) / 2 + 18px));
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 20px);
  z-index: 48;
  width: 52px; height: 52px;
  border-radius: 50%;
  background: linear-gradient(140deg, #F0879C, #E0657F);
  color: #fff;
  display: grid; place-items: center;
  box-shadow: 0 8px 22px rgba(224, 101, 127, 0.4);
  transition: transform 0.18s ease;
}
.fab:active { transform: scale(0.93); }
.fab svg { width: 22px; height: 22px; }
.fab[hidden] { display: none; }

/* ---------- 底部弹层 ---------- */
.scrim {
  position: fixed;
  inset: 0;
  background: rgba(48, 34, 38, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.26s ease;
  z-index: 60;
  backdrop-filter: blur(2px);
}
.scrim.show { opacity: 1; pointer-events: auto; }

.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 70;
  max-width: 540px;
  margin: 0 auto;
  background: #FFFCFA;
  border-radius: 24px 24px 0 0;
  padding: 10px 20px calc(18px + var(--safe-b));
  transform: translateY(102%);
  transition: transform 0.32s cubic-bezier(0.22, 0.9, 0.3, 1);
  box-shadow: 0 -8px 34px rgba(120, 80, 90, 0.16);
  max-height: 88vh;
  overflow-y: auto;
}
.sheet.show { transform: none; }
.sheet-grip {
  width: 38px; height: 4px;
  border-radius: 4px;
  background: #E6DCDA;
  margin: 0 auto 14px;
}
.sheet h3 {
  margin: 0 0 16px;
  font-size: 16.5px;
  font-weight: 600;
  text-align: center;
  letter-spacing: 0.03em;
}
.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 12px;
  color: var(--ink-3);
  margin: 0 0 6px 2px;
  letter-spacing: 0.04em;
}
.field textarea, .field input[type="text"], .field input[type="date"], .field input[type="email"], .field input[type="password"] {
  width: 100%;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fff;
  outline: none;
  transition: border-color 0.2s;
}
.field textarea {
  min-height: 108px;
  resize: vertical;
  line-height: 1.7;
}
.field textarea:focus, .field input:focus { border-color: rgba(228, 117, 142, 0.45); }

.mood-row { display: flex; gap: 8px; flex-wrap: wrap; }
.mood-chip {
  padding: 6px 12px;
  border-radius: 20px;
  background: #fff;
  border: 1px solid var(--line);
  font-size: 13px;
  transition: all 0.18s;
}
.mood-chip.on {
  background: var(--rose-soft);
  border-color: rgba(228, 117, 142, 0.5);
  color: var(--rose);
}

.file-drop {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 84px;
  border-radius: 16px;
  border: 1.5px dashed #EBDCDB;
  background: #FFF9F7;
  color: var(--ink-3);
  font-size: 13px;
  width: 100%;
}
.file-drop:active { background: var(--bg-soft); }
.file-drop span { font-size: 20px; }
.preview-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.preview-row .pv {
  width: 68px; height: 68px;
  border-radius: 12px;
  position: relative;
  overflow: hidden;
  background: var(--bg-soft);
}
.preview-row img { width: 100%; height: 100%; object-fit: cover; }
.preview-row .pv button {
  position: absolute;
  top: 2px; right: 2px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 12px;
  line-height: 1;
  display: grid; place-items: center;
}

.btn-primary {
  width: 100%;
  height: 48px;
  border-radius: 16px;
  background: linear-gradient(140deg, #F0879C, #E0657F);
  color: #fff;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.06em;
  box-shadow: 0 6px 18px rgba(224, 101, 127, 0.32);
  margin-top: 4px;
}
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { opacity: 0.6; box-shadow: none; }

/* ---------- 图片查看 ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(28, 20, 23, 0.94);
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 20px;
}
.lightbox.show { display: flex; }
.lightbox img {
  max-width: 100%;
  max-height: 78vh;
  border-radius: 12px;
  object-fit: contain;
}
.lightbox p {
  color: rgba(255, 255, 255, 0.82);
  font-size: 13px;
  margin: 16px 0 0;
  text-align: center;
}

/* ---------- 登录 ---------- */
.login {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px;
  background: var(--bg);
  background-image:
    radial-gradient(600px 400px at 88% -6%, #FFE0E6 0%, rgba(255, 224, 230, 0) 62%),
    radial-gradient(500px 360px at -6% 6%, #FFF0D9 0%, rgba(255, 240, 217, 0) 60%);
}
.login.show { display: flex; }
.login-box { width: 100%; max-width: 330px; }
.login-heart { font-size: 42px; text-align: center; margin-bottom: 10px; }
.login h1 {
  font-size: 21px;
  font-weight: 600;
  text-align: center;
  margin: 0 0 4px;
  letter-spacing: 0.06em;
}
.login .sub {
  text-align: center;
  font-size: 12.5px;
  color: var(--ink-3);
  margin: 0 0 26px;
}
.login .field input { background: #fff; }
.login-alt {
  text-align: center;
  font-size: 12.5px;
  color: var(--ink-3);
  margin-top: 16px;
}
.login-alt button { color: var(--rose); text-decoration: underline; font-size: 12.5px; }
.login-err {
  color: #D4485F;
  font-size: 12.5px;
  text-align: center;
  min-height: 18px;
  margin-top: 10px;
}

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 84px);
  transform: translate(-50%, 12px);
  background: rgba(59, 47, 51, 0.9);
  color: #fff;
  font-size: 13px;
  padding: 9px 16px;
  border-radius: 20px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.26s ease;
  z-index: 120;
  max-width: 80vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 淡入 ---------- */
.loading {
  text-align: center;
  padding: 60px 0;
  color: var(--ink-3);
  font-size: 13px;
}
.skeleton {
  height: 92px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, #FDF0EC 25%, #FFF7F3 37%, #FDF0EC 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
  margin-bottom: 12px;
}
@keyframes shimmer {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}
