:root {
  --bg: #f4efe7;
  --card: #ffffff;
  --card-soft: #faf7f2;
  --text: #2c2722;
  --text-soft: #8a8074;
  --text-faint: #b5ab9c;
  --accent: #b0543c;
  --accent-deep: #8f4330;
  --accent-soft: #f3e6de;
  --line: #e7e0d3;
  --shadow-sm: 0 1px 2px rgba(60, 45, 30, 0.05), 0 4px 12px rgba(60, 45, 30, 0.05);
  --shadow: 0 1px 2px rgba(60, 45, 30, 0.04), 0 12px 32px rgba(60, 45, 30, 0.08);
  --serif: "Noto Serif SC", "Songti SC", "STZhongsong", "SimSun", Georgia, serif;
  --sans: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  --header-h: 56px;
}

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

html, body { height: 100%; }

body {
  font-family: var(--sans);
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
  -webkit-font-smoothing: antialiased;
}

/* 极淡的顶部暖光，营造呼吸感 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: radial-gradient(1100px 460px at 50% -120px, rgba(176, 84, 60, 0.06), transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* ===== 顶部 ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 20px;
  background: rgba(244, 239, 231, 0.88);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand {
  font-family: var(--serif);
  font-size: 18px;
  letter-spacing: 3px;
  color: var(--text);
  font-weight: 500;
}
.brand .heart, .names .heart { color: var(--accent); font-style: normal; }

/* ===== 导航 ===== */
.tabs {
  position: sticky;
  top: var(--header-h);
  z-index: 19;
  display: flex;
  justify-content: center;
  gap: 36px;
  padding: 10px 16px 0;
  background: rgba(244, 239, 231, 0.88);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.tab {
  border: none;
  background: none;
  color: var(--text-soft);
  font-size: 15px;
  letter-spacing: 2px;
  padding: 8px 2px 12px;
  cursor: pointer;
  position: relative;
  transition: color .2s;
}
.tab::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 2px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: center;
  transition: transform .25s ease;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); font-weight: 600; }
.tab.active::after { transform: scaleX(1); }

main {
  position: relative;
  z-index: 1;
  max-width: 900px;
  margin: 0 auto;
  padding: 28px 16px 60px;
}

.page { display: none; animation: fadeIn .3s ease; }
.page.active { display: block; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== 卡片 ===== */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 28px 22px;
  box-shadow: var(--shadow);
}

/* ===== 首页计时器 ===== */
.timer-card { text-align: center; padding: 48px 24px 40px; }
.greeting {
  font-size: 13px;
  color: var(--text-soft);
  letter-spacing: 4px;
  margin-bottom: 30px;
}
.names {
  font-family: var(--serif);
  font-size: 30px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 6px;
  margin-bottom: 12px;
}
.names .heart { font-size: 22px; }
.sub-label {
  font-size: 13px;
  color: var(--text-soft);
  letter-spacing: 8px;
  margin-bottom: 40px;
}
.countup {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-bottom: 34px;
}
.unit {
  min-width: 80px;
  padding: 18px 8px 14px;
  border-radius: 12px;
  background: var(--card-soft);
  border: 1px solid var(--line);
}
.unit span {
  display: block;
  font-family: var(--serif);
  font-size: 36px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.unit label {
  display: block;
  font-size: 11px;
  color: var(--text-soft);
  letter-spacing: 3px;
  margin-top: 10px;
}
.since {
  font-size: 13px;
  color: var(--text-soft);
  letter-spacing: 1px;
  margin-bottom: 6px;
}
.since b { color: var(--accent); font-weight: 600; }
.blessing {
  font-family: var(--serif);
  font-style: italic;
  font-size: 16px;
  color: var(--text-soft);
  letter-spacing: 1px;
  margin-top: 28px;
  min-height: 24px;
}

/* ===== 按钮 ===== */
.primary-btn {
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  letter-spacing: 2px;
  padding: 13px 30px;
  border-radius: 999px;
  cursor: pointer;
  transition: background .2s, transform .15s;
}
.primary-btn:hover { background: var(--accent-deep); transform: translateY(-1px); }
.primary-btn:active { transform: translateY(0); }

/* ===== 照片墙 ===== */
.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.page-tip {
  font-size: 14px;
  color: var(--text-soft);
  flex: 1;
  min-width: 200px;
  letter-spacing: 1px;
}
.board {
  position: relative;
  height: 70vh;
  min-height: 420px;
  border-radius: 16px;
  overflow: hidden;
  background: var(--card-soft);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}
.board-hint {
  text-align: center;
  font-size: 13px;
  color: var(--text-faint);
  letter-spacing: 1px;
  margin-top: 14px;
}

.photo-card {
  position: absolute;
  width: 150px;
  background: #fff;
  padding: 9px 9px 24px;
  border-radius: 3px;
  border: 1px solid #eae3d6;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05), 0 10px 28px rgba(60, 45, 30, 0.13);
  cursor: grab;
  touch-action: none;
  user-select: none;
  transition: box-shadow .15s;
  will-change: transform;
}
.photo-card:hover { box-shadow: 0 2px 4px rgba(0,0,0,0.06), 0 14px 34px rgba(60, 45, 30, 0.18); }
.photo-card.dragging { cursor: grabbing; box-shadow: 0 4px 8px rgba(0,0,0,0.08), 0 22px 50px rgba(60, 45, 30, 0.25); z-index: 50; }
.photo-card img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  display: block;
  border-radius: 2px;
  pointer-events: none;
}
.photo-card .pin {
  position: absolute;
  top: 7px; left: 50%;
  transform: translateX(-50%);
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #a89c8c;
  box-shadow: inset 0 1px 1px rgba(255,255,255,0.6), 0 1px 2px rgba(0,0,0,0.4);
  pointer-events: none;
}
.photo-card .p-delete {
  position: absolute;
  top: 6px; right: 6px;
  width: 22px; height: 22px;
  border: none;
  border-radius: 50%;
  background: rgba(44, 39, 34, 0.5);
  color: #fff;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s;
}
.photo-card:hover .p-delete { opacity: 1; }
@media (hover: none) {
  .photo-card .p-delete { opacity: 1; }
}
.photo-card .p-rotate {
  position: absolute;
  bottom: 5px; right: 7px;
  width: 20px; height: 20px;
  border: none;
  border-radius: 50%;
  background: rgba(44, 39, 34, 0.4);
  color: #fff;
  font-size: 11px;
  cursor: pointer;
}

/* ===== 时光相册 ===== */
.photo-timeline { margin-top: 6px; }
.day-group { margin-bottom: 30px; }
.day-title {
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 2px;
  margin-bottom: 14px;
  padding-left: 12px;
  border-left: 2px solid var(--accent);
}
.photo-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.photo-grid .thumb {
  width: 118px;
  height: 118px;
  object-fit: cover;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform .15s, box-shadow .15s;
}
.photo-grid .thumb:hover {
  transform: scale(1.03);
  box-shadow: var(--shadow);
}
.empty-tip {
  text-align: center;
  color: var(--text-soft);
  letter-spacing: 1px;
  padding: 40px 0;
  font-size: 15px;
}

/* ===== 灯箱 ===== */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(25, 20, 16, 0.92);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn .2s ease;
}
.lightbox-inner { position: relative; max-width: 92vw; max-height: 92vh; }
.lightbox-inner img {
  max-width: 92vw;
  max-height: 88vh;
  border-radius: 6px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
  object-fit: contain;
}
.lightbox-close {
  position: absolute;
  top: -16px; right: -16px;
  width: 38px; height: 38px;
  border-radius: 50%;
  border: none;
  background: #fff;
  color: var(--text);
  font-size: 16px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,0.3);
}
.lightbox[hidden] { display: none; }

/* ===== 首页里程碑 ===== */
.section-title {
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 600;
  color: var(--text-soft);
  letter-spacing: 3px;
  margin: 30px 4px 14px;
}
.milestone-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.milestone-card {
  flex: 1 1 150px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px 12px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}
.milestone-card .m-name {
  font-size: 13px;
  color: var(--text-soft);
  letter-spacing: 1px;
  margin-bottom: 10px;
}
.milestone-card .m-days {
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 600;
  color: var(--text);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.milestone-card .m-days small {
  font-family: var(--sans);
  font-size: 11px;
  color: var(--text-soft);
  font-weight: 400;
  letter-spacing: 1px;
  margin-left: 3px;
}
.milestone-card .m-date {
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 10px;
  letter-spacing: 1px;
  font-variant-numeric: tabular-nums;
}

/* ===== 故事 / 留言 通用块 ===== */
.block { margin-bottom: 20px; }
.block-title {
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 2px;
  margin-bottom: 18px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}
.inline-form input,
.note-form textarea {
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 14px;
  color: var(--text);
  background: var(--card-soft);
  font-family: inherit;
  outline: none;
  transition: border-color .2s;
}
.inline-form input { flex: 1 1 150px; }
.inline-form input:focus,
.note-form textarea:focus { border-color: var(--accent); }

/* 纪念日列表 */
.ms-list { list-style: none; }
.ms-item {
  display: flex;
  align-items: baseline;
  gap: 14px;
  padding: 14px 2px;
  border-bottom: 1px dashed var(--line);
}
.ms-item:last-child { border-bottom: none; }
.ms-item .ms-date {
  font-family: var(--serif);
  font-size: 15px;
  color: var(--accent);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.ms-item .ms-body { flex: 1; min-width: 0; }
.ms-item .ms-title { font-size: 15px; font-weight: 600; color: var(--text); }
.ms-item .ms-note { font-size: 13px; color: var(--text-soft); margin-top: 2px; word-break: break-word; }
.ms-item .ms-count { font-size: 12px; color: var(--text-faint); white-space: nowrap; }
.ms-item .ms-del,
.place-item .pl-del,
.note-card .n-del {
  border: none; background: none;
  color: var(--text-faint);
  font-size: 14px;
  cursor: pointer;
  padding: 2px;
}
.ms-item .ms-del:hover,
.place-item .pl-del:hover,
.note-card .n-del:hover { color: var(--accent); }
.ms-item .ms-img {
  width: 52px;
  height: 52px;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
  border: 1px solid var(--line);
}
.inline-form input[type="file"] {
  flex: 1 1 160px;
  font-size: 13px;
  padding: 9px;
  color: var(--text-soft);
}
.inline-form input[type="file"]::file-selector-button {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 8px;
  padding: 6px 12px;
  margin-right: 10px;
  cursor: pointer;
  color: var(--text);
  font-family: inherit;
}

/* 足迹：打卡盖章墙 */
.place-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
}
.place-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 128px;
  height: 128px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  background: var(--card);
  text-align: center;
  padding: 16px;
  position: relative;
  box-shadow: inset 0 0 0 4px var(--card), inset 0 0 0 5px var(--accent-soft);
}
.place-item .pl-name {
  font-family: var(--serif);
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  line-height: 1.3;
  word-break: break-word;
}
.place-item .pl-date {
  font-size: 11px;
  color: var(--text-soft);
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
}
.place-item .pl-note {
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 2px;
  max-height: 30px;
  overflow: hidden;
  word-break: break-word;
}
.place-item .pl-del {
  position: absolute;
  top: 10px; right: 12px;
  font-size: 12px;
}
.inline-form select {
  flex: 1 1 150px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 14px;
  color: var(--text);
  background: var(--card-soft);
  font-family: inherit;
  outline: none;
}
.china-map {
  width: 100%;
  height: 440px;
  margin-bottom: 22px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
}
.map-back {
  display: block;
  margin: 0 0 10px;
  border: 1px solid var(--line);
  background: var(--card-soft);
  color: var(--accent);
  font-size: 13px;
  letter-spacing: 1px;
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
}
.map-back:hover { background: var(--accent-soft); }
.map-back[hidden] { display: none; }

/* 留言板 */
.note-form { margin-bottom: 24px; }
.author-row { display: flex; gap: 8px; margin-bottom: 12px; }
.author-btn {
  border: 1px solid var(--line);
  background: var(--card-soft);
  color: var(--text-soft);
  font-size: 14px;
  letter-spacing: 1px;
  padding: 9px 22px;
  border-radius: 999px;
  cursor: pointer;
  transition: all .2s;
}
.author-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.note-form textarea {
  width: 100%;
  resize: vertical;
  margin-bottom: 12px;
}
.note-wall { display: flex; flex-wrap: wrap; gap: 12px; }
.note-card {
  flex: 1 1 240px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  position: relative;
}
.note-card:nth-child(5n+1) { background: #fbf3e2; }
.note-card:nth-child(5n+2) { background: #f8e8e7; }
.note-card:nth-child(5n+3) { background: #e8f1e9; }
.note-card:nth-child(5n+4) { background: #e9eff7; }
.note-card:nth-child(5n+5) { background: #f2ecf6; }
.note-card .n-author {
  font-size: 12px;
  color: var(--accent);
  letter-spacing: 1px;
  margin-bottom: 6px;
}
.note-card .n-content {
  font-size: 15px;
  line-height: 1.7;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}
.note-card .n-time {
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 10px;
  font-variant-numeric: tabular-nums;
}
.note-card .n-del {
  position: absolute;
  top: 8px; right: 10px;
}

/* ===== 移动端 ===== */
@media (max-width: 520px) {
  .countup { gap: 6px; }
  .unit { min-width: 58px; padding: 14px 4px 12px; }
  .unit span { font-size: 26px; }
  .unit label { letter-spacing: 1px; }
  .names { font-size: 24px; letter-spacing: 4px; }
  .sub-label { letter-spacing: 6px; }
  .board { height: 62dvh; min-height: 340px; }
  .photo-card { width: 120px; }
  .photo-card img { height: 96px; }
  .tab { font-size: 14px; letter-spacing: 1px; }
  .tabs { gap: 18px; overflow-x: auto; }
  .topbar { padding-top: env(safe-area-inset-top); }
  main { padding-bottom: calc(60px + env(safe-area-inset-bottom)); }
  .page-head { flex-direction: column; align-items: stretch; }
  .page-head .primary-btn { width: 100%; padding: 14px 24px; }
  .photo-grid { gap: 8px; }
  .photo-grid .thumb { width: calc((100% - 16px) / 3); height: auto; aspect-ratio: 1; }
  .milestone-card { flex: 1 1 45%; }
  .inline-form input { flex: 1 1 100%; }
  .inline-form select { flex: 1 1 100%; }
  .note-wall { flex-direction: column; }
  .china-map { height: 320px; }
}
