:root {
  --pink-50: #fff5f8;
  --pink-100: #ffe4ec;
  --pink-200: #ffd3e0;
  --pink-300: #ffb7cd;
  --pink-400: #ff9ab8;
  --pink-500: #ff7ba0;
  --pink-600: #f25c8a;
  --rose: #b3436a;
  --rose-deep: #8c2f4d;
  --cream: #fffafc;
  --gold: #f3b467;
  --text-main: #6b3350;
  --text-soft: #a8708a;
  --shadow: 0 10px 30px rgba(242, 92, 138, 0.18);
  --shadow-soft: 0 4px 16px rgba(242, 92, 138, 0.12);
  --radius: 18px;
  --radius-lg: 24px;
}

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  color: var(--text-main);
  background: linear-gradient(165deg, #fff0f6 0%, var(--pink-100) 45%, var(--pink-200) 100%);
  overflow: hidden;
  overscroll-behavior-y: none;
}

button { font-family: inherit; cursor: pointer; }
input, textarea { font-family: inherit; }

/* ---------- 背景漂浮爱心 ---------- */
.bg-hearts {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
.bg-hearts .h {
  position: absolute;
  bottom: -40px;
  animation: floatUp linear infinite;
  opacity: 0;
  will-change: transform, opacity;
}
@keyframes floatUp {
  0%   { transform: translateY(0) rotate(0deg) scale(0.6); opacity: 0; }
  10%  { opacity: 0.5; }
  100% { transform: translateY(-110vh) rotate(25deg) scale(1.15); opacity: 0; }
}

/* ---------- 屏幕切换 ---------- */
.screen {
  position: fixed;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  transform: translateY(14px);
  transition: opacity 0.35s ease, transform 0.35s ease, visibility 0s linear 0.35s;
  overflow: hidden;
}
.screen.active {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition: opacity 0.35s ease, transform 0.35s ease;
}

/* ---------- 门禁 ---------- */
#screen-gate { align-items: center; justify-content: center; z-index: 20; }
.gate-inner {
  text-align: center;
  padding: 40px 32px;
  width: 100%;
  max-width: 400px;
  animation: popIn 0.6s cubic-bezier(0.22, 1.2, 0.36, 1) both;
}
.gate-heart {
  font-size: 64px;
  display: inline-block;
  animation: heartbeat 1.6s ease-in-out infinite;
  filter: drop-shadow(0 8px 18px rgba(242, 92, 138, 0.45));
}
@keyframes heartbeat {
  0%, 100% { transform: scale(1); }
  12% { transform: scale(1.15); }
  24% { transform: scale(1); }
  36% { transform: scale(1.12); }
}
@keyframes popIn {
  from { opacity: 0; transform: translateY(24px) scale(0.95); }
  to   { opacity: 1; transform: none; }
}
.logo {
  margin: 14px 0 4px;
  font-family: "Segoe Script", "Brush Script MT", "Comic Sans MS", cursive;
  font-size: 40px;
  font-weight: 700;
  letter-spacing: 0.5px;
  background: linear-gradient(120deg, var(--rose) 0%, var(--pink-600) 55%, var(--gold) 110%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: none;
}
.logo.small { font-size: 24px; margin: 0; }
.gate-sub { color: var(--text-soft); margin: 0 0 28px; font-size: 15px; letter-spacing: 2px; }
.pin-box { display: flex; gap: 12px; justify-content: center; margin-bottom: 24px; }
.pin {
  width: 54px;
  height: 64px;
  border: 2px solid var(--pink-300);
  border-radius: 14px;
  background: var(--cream);
  text-align: center;
  font-size: 26px;
  font-weight: 700;
  color: var(--rose);
  outline: none;
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
}
.pin:focus {
  border-color: var(--pink-600);
  box-shadow: 0 0 0 4px rgba(242, 92, 138, 0.15);
  transform: translateY(-2px);
}
.pin-box.shake { animation: shake 0.4s; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}
.gate-hint { color: var(--text-soft); font-size: 13px; margin-top: 16px; min-height: 18px; }

/* ---------- 通用按钮 ---------- */
.btn {
  border: none;
  border-radius: 999px;
  padding: 13px 26px;
  font-size: 16px;
  font-weight: 600;
  transition: transform 0.15s ease, box-shadow 0.2s ease, opacity 0.2s;
  user-select: none;
}
.btn:active { transform: scale(0.95); }
.btn-primary {
  color: #fff;
  background: linear-gradient(120deg, var(--pink-500), var(--pink-600));
  box-shadow: 0 8px 22px rgba(242, 92, 138, 0.4);
}
.btn-primary:active { box-shadow: 0 4px 12px rgba(242, 92, 138, 0.35); }
.btn-play {
  color: #fff;
  background: linear-gradient(120deg, #f79d5c, #ef5f8a);
  box-shadow: 0 8px 22px rgba(239, 95, 138, 0.4);
}
.btn-soft {
  color: var(--rose);
  background: rgba(255, 255, 255, 0.75);
  border: 1.5px solid var(--pink-300);
  box-shadow: var(--shadow-soft);
}
.btn-danger { color: #fff; background: #e05a6f; box-shadow: 0 6px 16px rgba(224, 90, 111, 0.35); }
.btn-gate { min-width: 160px; margin-top: 4px; }
.btn-big {
  display: block;
  width: 100%;
  padding: 17px;
  font-size: 17px;
  letter-spacing: 1px;
  border-radius: 22px;
}
.btn-big + .btn-big { margin-top: 14px; }
.icon-btn {
  border: none;
  background: rgba(255, 255, 255, 0.7);
  color: var(--rose);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 20px;
  box-shadow: var(--shadow-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s;
}
.icon-btn:active { transform: scale(0.9); }

/* ---------- 顶栏 / 底部导航 ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(env(safe-area-inset-top, 0px) + 14px) 18px 10px;
  z-index: 2;
}
.topbar-title { font-size: 18px; font-weight: 700; color: var(--rose); }
.tabbar {
  display: flex;
  justify-content: space-around;
  padding: 8px 12px calc(env(safe-area-inset-bottom, 0px) + 12px);
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid rgba(255, 183, 205, 0.5);
  z-index: 2;
}
.tab {
  border: none;
  background: none;
  color: var(--text-soft);
  font-size: 15px;
  font-weight: 600;
  padding: 8px 22px;
  border-radius: 999px;
  transition: color 0.2s, background 0.2s;
}
.tab.active { color: #fff; background: linear-gradient(120deg, var(--pink-500), var(--pink-600)); box-shadow: 0 6px 14px rgba(242, 92, 138, 0.35); }

/* ---------- 首页 ---------- */
#screen-home .home-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 26px calc(env(safe-area-inset-bottom, 0px) + 20px);
}
.hero { text-align: center; margin-bottom: 40px; animation: popIn 0.5s 0.05s both; }
.hero-heart {
  font-size: 72px;
  display: inline-block;
  animation: heartbeat 1.8s ease-in-out infinite;
  filter: drop-shadow(0 10px 20px rgba(242, 92, 138, 0.4));
}
.hero-label { color: var(--text-soft); margin: 18px 0 6px; font-size: 15px; letter-spacing: 1px; }
.hero-days {
  margin: 0;
  font-size: 72px;
  font-weight: 800;
  line-height: 1;
  background: linear-gradient(120deg, var(--rose), var(--pink-600) 60%, var(--gold));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero-unit { margin: 4px 0 0; color: var(--rose); font-weight: 700; font-size: 18px; }
.hero-sub { color: var(--text-soft); font-size: 14px; margin: 14px 0 0; }
.home-actions { animation: popIn 0.5s 0.18s both; }

/* ---------- 时间轴 ---------- */
.timeline-wrap { flex: 1; overflow-y: auto; padding: 8px 16px 90px; -webkit-overflow-scrolling: touch; }
.timeline { position: relative; padding-left: 26px; }
.timeline::before {
  content: "";
  position: absolute;
  left: 9px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: linear-gradient(180deg, var(--pink-400), var(--pink-300));
  border-radius: 2px;
}
.tl-item { position: relative; margin-bottom: 18px; animation: popIn 0.45s both; }
.tl-item::before {
  content: "";
  position: absolute;
  left: -22px;
  top: 22px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--cream);
  border: 3px solid var(--pink-500);
  box-shadow: 0 0 0 4px rgba(242, 92, 138, 0.18);
}
.tl-card {
  background: rgba(255, 255, 255, 0.82);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-soft);
  border: 1px solid rgba(255, 183, 205, 0.45);
}
.tl-date {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(120deg, var(--pink-400), var(--pink-600));
  padding: 4px 12px;
  border-radius: 999px;
  margin-bottom: 8px;
}
.tl-title { margin: 0 0 6px; font-size: 17px; font-weight: 700; color: var(--rose-deep); }
.tl-desc { margin: 0 0 8px; font-size: 14px; line-height: 1.65; color: var(--text-main); white-space: pre-wrap; word-break: break-word; }
.tl-place { font-size: 13px; color: var(--text-soft); margin-bottom: 10px; }
.tl-photos { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; -webkit-overflow-scrolling: touch; }
.tl-photo {
  width: 96px;
  height: 96px;
  flex-shrink: 0;
  border-radius: 12px;
  object-fit: cover;
  border: 1px solid var(--pink-200);
  background: var(--pink-100);
}
.tl-actions { display: flex; gap: 10px; margin-top: 12px; }
.tl-act {
  border: none;
  background: none;
  color: var(--text-soft);
  font-size: 13px;
  padding: 4px 10px;
  border-radius: 999px;
  transition: background 0.2s, color 0.2s;
}
.tl-act:hover { background: var(--pink-100); color: var(--rose); }
.timeline-empty { text-align: center; padding: 80px 30px; color: var(--text-soft); }
.empty-heart { font-size: 56px; margin-bottom: 12px; animation: heartbeat 1.8s infinite; }
.empty-sub { font-size: 13px; }

.fab {
  position: fixed;
  right: 20px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 84px);
  width: 58px;
  height: 58px;
  border: none;
  border-radius: 50%;
  font-size: 30px;
  color: #fff;
  background: linear-gradient(135deg, var(--pink-500), var(--pink-600));
  box-shadow: 0 10px 24px rgba(242, 92, 138, 0.45);
  z-index: 5;
  transition: transform 0.15s;
}
.fab:active { transform: scale(0.9) rotate(90deg); }

/* ---------- 编辑表单 ---------- */
.editor-body { flex: 1; overflow-y: auto; padding: 6px 18px calc(env(safe-area-inset-bottom, 0px) + 30px); -webkit-overflow-scrolling: touch; }
.field { display: block; margin-bottom: 18px; }
.field-label { display: block; font-size: 14px; font-weight: 700; color: var(--rose); margin-bottom: 8px; }
.field-label em { font-style: normal; font-weight: 400; color: var(--text-soft); }
.field input[type="text"],
.field input[type="date"],
.field input[type="datetime-local"],
.field textarea {
  width: 100%;
  border: 1.5px solid var(--pink-300);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.85);
  padding: 13px 15px;
  font-size: 15px;
  color: var(--text-main);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.field input:focus, .field textarea:focus {
  border-color: var(--pink-600);
  box-shadow: 0 0 0 4px rgba(242, 92, 138, 0.12);
}
.field textarea { resize: vertical; min-height: 96px; line-height: 1.6; }
.input-with-icon { position: relative; }
.input-with-icon input { padding-left: 42px; }
.input-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); font-size: 17px; }
.field-note { font-size: 12px; color: var(--text-soft); margin: 8px 2px 0; line-height: 1.6; }
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 10px; }
.photo-cell {
  position: relative;
  aspect-ratio: 1;
  border-radius: 14px;
  overflow: hidden;
  border: 1.5px solid var(--pink-200);
  background: var(--pink-100);
}
.photo-cell img { width: 100%; height: 100%; object-fit: cover; }
.photo-cell .del {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 13px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-add-photo { width: 100%; border-radius: 14px; padding: 12px; }
.btn-save { padding: 10px 18px; font-size: 14px; border-radius: 14px; }
.btn-locate { margin-top: 8px; padding: 9px 16px; font-size: 13px; border-radius: 12px; }
.btn-locate:disabled { opacity: 0.6; }

/* ---------- 放映模式 ---------- */
#screen-playback { background: linear-gradient(160deg, #fff0f6, var(--pink-200)); z-index: 10; }
.pb-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 16px 8px;
  z-index: 3;
}
.pb-icon { background: rgba(255, 255, 255, 0.85); }
.pb-progress { flex: 1; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.7); overflow: hidden; }
.pb-progress i { display: block; height: 100%; width: 0; border-radius: 3px; background: linear-gradient(90deg, var(--pink-500), var(--gold)); transition: width 0.6s ease; }
.pb-stage {
  flex: 1;
  overflow-y: auto;
  padding: 10px 14px 6px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.pb-stage::-webkit-scrollbar { display: none; }
.pb-page { display: none; animation: pageIn 0.5s cubic-bezier(0.22, 1.1, 0.36, 1) both; }
.pb-page.on { display: flex; flex-direction: column; gap: 14px; }
.pb-page.on .pb-card { animation: cardPop 0.5s cubic-bezier(0.22, 1.2, 0.36, 1) both; }
@keyframes pageIn { from { opacity: 0; transform: translateX(48px); } to { opacity: 1; transform: none; } }
@keyframes cardPop { from { opacity: 0; transform: translateY(22px) scale(0.96); } to { opacity: 1; transform: none; } }

.pb-card {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
  background: var(--cream);
  border: 1px solid rgba(255, 183, 205, 0.6);
}
.pb-card.photo { padding: 0; }
.pb-card.photo > img { display: block; width: 100%; height: auto; }
.pb-card.photo .pb-shade {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0.05) 30%, rgba(80, 15, 40, 0.55) 100%);
}
.pb-card.photo .pb-time {
  position: absolute;
  top: 12px;
  left: 12px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--rose);
  font-size: 12px;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 999px;
  box-shadow: var(--shadow-soft);
}
.pb-card.photo .pb-caption {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 12px;
  color: #fff;
  text-shadow: 0 1px 6px rgba(0,0,0,0.35);
}
.pb-card.photo .pb-caption h3 { margin: 0 0 3px; font-size: 17px; line-height: 1.25; }
.pb-card.photo .pb-caption .pb-place { font-size: 12px; opacity: 0.95; }

.pb-card.text {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.pb-card.text .pb-time {
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(120deg, var(--pink-400), var(--pink-600));
  align-self: flex-start;
  padding: 4px 12px;
  border-radius: 999px;
}
.pb-card.text h3 { margin: 4px 0 0; font-size: 18px; color: var(--rose-deep); }
.pb-card.text p { margin: 0; font-size: 14px; line-height: 1.65; color: var(--text-main); white-space: pre-wrap; word-break: break-word; }
.pb-card.text .pb-place { font-size: 13px; color: var(--text-soft); }
.pb-card.text .pb-dots { font-size: 12px; color: var(--pink-500); letter-spacing: 4px; }

.pb-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px calc(env(safe-area-inset-bottom, 0px) + 16px);
  z-index: 3;
}
.pb-hint { color: var(--text-soft); font-size: 13px; letter-spacing: 1px; animation: pulse 2.2s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }
.pb-heart-next {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: #fff;
  background: linear-gradient(135deg, var(--pink-500), var(--pink-600));
  box-shadow: 0 8px 20px rgba(242, 92, 138, 0.45);
  animation: heartbeat 1.6s ease-in-out infinite;
  transition: transform 0.15s;
}
.pb-heart-next:active { transform: scale(0.88); }

.pb-end {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 30px;
  animation: popIn 0.6s both;
}
.pb-end .big { font-size: 72px; animation: heartbeat 1.6s infinite; }
.pb-end h2 { margin: 16px 0 8px; font-size: 26px; color: var(--rose-deep); font-family: "Segoe Script", cursive; }
.pb-end p { color: var(--text-soft); margin: 0 0 26px; }

/* ---------- 大图查看 ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(20, 5, 12, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.25s;
}
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,0.5); }
.lb-close {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 16px);
  right: 16px;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  color: #fff;
  font-size: 18px;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(60, 15, 35, 0.45);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn 0.25s;
}
.modal {
  width: 100%;
  max-width: 480px;
  background: var(--cream);
  border-radius: 26px 26px 0 0;
  padding: 24px 22px calc(env(safe-area-inset-bottom, 0px) + 22px);
  animation: slideUp 0.35s cubic-bezier(0.22, 1.1, 0.36, 1);
  max-height: 82vh;
  overflow-y: auto;
}
.modal-sm { border-radius: 26px; margin-bottom: 0; }
@keyframes slideUp { from { transform: translateY(60px); opacity: 0.6; } to { transform: none; opacity: 1; } }
.modal-title { font-size: 19px; font-weight: 800; color: var(--rose-deep); margin-bottom: 16px; }
.confirm-text { color: var(--text-main); font-size: 15px; line-height: 1.7; margin: 0 0 20px; }
.modal-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 20px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; }
.switch { position: relative; display: inline-block; width: 52px; height: 30px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: var(--pink-300);
  transition: background 0.25s;
}
.slider::before {
  content: "";
  position: absolute;
  width: 24px;
  height: 24px;
  left: 3px;
  top: 3px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  transition: transform 0.25s;
}
.switch input:checked + .slider { background: linear-gradient(120deg, var(--pink-500), var(--pink-600)); }
.switch input:checked + .slider::before { transform: translateX(22px); }

/* ---------- 轻提示 ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 90px);
  transform: translateX(-50%);
  background: rgba(80, 25, 45, 0.92);
  color: #fff;
  font-size: 14px;
  padding: 12px 20px;
  border-radius: 999px;
  z-index: 50;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  white-space: nowrap;
  max-width: 86vw;
  overflow: hidden;
  text-overflow: ellipsis;
  animation: toastIn 0.3s;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------- 点击星星动效 ---------- */
.tap-stars-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 60;
  overflow: hidden;
}
.tap-star {
  position: absolute;
  text-shadow: 0 0 8px rgba(255, 225, 170, 0.95), 0 0 16px rgba(242, 92, 138, 0.8);
  animation: starBurst 0.7s ease-out forwards;
  will-change: transform, opacity;
  user-select: none;
}
@keyframes starBurst {
  0%   { transform: translate(-50%, -50%) scale(0.3) rotate(0deg); opacity: 1; }
  100% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.35) rotate(120deg); opacity: 0; }
}

/* ---------- 隐藏 ---------- */
[hidden] { display: none !important; }

@media (min-width: 520px) {
  .screen { left: 0; right: 0; margin: 0 auto; max-width: 520px; transform: translateY(14px); box-shadow: 0 0 60px rgba(150, 60, 100, 0.15); }
  .screen.active { transform: translateY(0); }
  #screen-gate { left: auto; right: auto; margin: 0; max-width: none; box-shadow: none; }
  .modal { border-radius: 26px; margin-bottom: 40px; }
}
