/* ============ 悦耳 · 悦心 · 悦尽人间清欢 ============ */
:root {
  --pink: #ff8fab;
  --pink-deep: #ff6b95;
  --lavender: #c8a2ff;
  --peach: #ffd6e0;
  --cream: #fff9fb;
  --ink: #6d4c5d;
  --ink-soft: #a1788a;
  --card-shadow: 0 6px 18px rgba(255, 118, 158, 0.18);
  --radius-lg: 22px;
  --radius-md: 16px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

/* 关键：防止 display:flex 等样式覆盖 hidden 属性，导致蒙版/灯箱在初始时误显示 */
[hidden] { display: none !important; }

html { height: 100%; }

body {
  min-height: 100%;
  font-family: "PingFang SC", "HarmonyOS Sans SC", "MiSans", "PingFang", "Microsoft YaHei", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 110% -8%, #ffe3ec 0%, transparent 55%),
    radial-gradient(900px 420px at -15% 12%, #f3e8ff 0%, transparent 50%),
    linear-gradient(168deg, #fff5f8 0%, #ffeede 48%, #f6ecff 100%);
  background-attachment: fixed;
  overflow-x: hidden;
  padding-bottom: calc(110px + var(--safe-bottom));
}

/* ============ 漂浮爱心 ============ */
#float-hearts {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  overflow: hidden;
}
#float-hearts span {
  position: absolute;
  bottom: -40px;
  opacity: 0;
  animation: floatUp linear forwards;
  filter: drop-shadow(0 2px 4px rgba(255, 118, 158, 0.25));
}
@keyframes floatUp {
  0%   { transform: translateY(0) rotate(0deg) scale(0.7); opacity: 0; }
  12%  { opacity: 0.85; }
  85%  { opacity: 0.5; }
  100% { transform: translateY(-115vh) rotate(38deg) scale(1.1); opacity: 0; }
}

/* ============ 顶部 ============ */
.app-header {
  position: relative;
  z-index: 2;
  text-align: center;
  padding: calc(26px + env(safe-area-inset-top, 0px)) 20px 10px;
}

.couple { display: flex; justify-content: center; align-items: center; gap: 14px; }

.avatar {
  width: 58px; height: 58px;
  display: grid; place-items: center;
  font-size: 30px;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 4px 14px rgba(255, 118, 158, 0.3);
  animation: bob 3.2s ease-in-out infinite;
}
.avatar-a { background: linear-gradient(135deg, #ffd9e3, #ffc7d6); animation-delay: 0s; }
.avatar-b { background: linear-gradient(135deg, #e6dcff, #d4c5ff); animation-delay: 0.6s; }
@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.heart-beat { font-size: 26px; animation: beat 1.15s ease-in-out infinite; }
@keyframes beat {
  0%, 100% { transform: scale(1); }
  25% { transform: scale(1.28); }
  40% { transform: scale(0.95); }
  60% { transform: scale(1.18); }
}

.app-title {
  margin-top: 10px;
  font-size: 44px;
  line-height: 1.1;
  letter-spacing: 2px;
  font-weight: 800;
  background: linear-gradient(92deg, #ff6b95 10%, #ff9a76 45%, #b28aff 90%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 2px 14px rgba(255, 130, 170, 0.25);
}

.app-slogan {
  margin-top: 7px;
  font-size: 13px;
  letter-spacing: 5px;
  color: var(--ink-soft);
  opacity: 0.9;
}

.days-counter {
  margin-top: 6px;
  display: inline-block;
  font-size: 14px;
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.75);
  border: 1.5px dashed #ffb6c9;
  padding: 5px 16px;
  border-radius: 999px;
  backdrop-filter: blur(6px);
}

.backup-flag {
  margin-top: 8px;
  font-size: 12px;
  color: #8d7bd8;
  background: rgba(255, 255, 255, 0.8);
  padding: 3px 12px;
  border-radius: 999px;
  display: inline-block;
}

/* ============ 上传进度 ============ */
.upload-progress {
  position: sticky;
  top: 8px;
  z-index: 5;
  margin: 8px 16px 0;
  background: rgba(255, 255, 255, 0.92);
  border-radius: 999px;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--card-shadow);
  font-size: 13px;
  color: var(--ink-soft);
}
.upload-progress-bar {
  flex: 1;
  height: 8px;
  background: var(--peach);
  border-radius: 999px;
  overflow: hidden;
}
.upload-progress-bar i {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #ff9a9e, #ff6b95, #b28aff);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
  transition: width 0.35s ease;
}
@keyframes shimmer {
  0% { background-position: 0% 0; }
  100% { background-position: 200% 0; }
}

/* ============ 安装横幅 ============ */
.install-banner {
  position: sticky;
  top: 8px;
  z-index: 5;
  margin: 10px 16px 0;
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(92deg, #fff0f5, #f3ecff);
  border: 1.5px solid #ffd0dd;
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 13px;
  box-shadow: var(--card-shadow);
}
.install-banner span { flex: 1; }
#btn-install {
  border: none;
  background: linear-gradient(135deg, #ff8fab, #ff6b95);
  color: #fff;
  font-weight: 700;
  padding: 7px 18px;
  border-radius: 999px;
  cursor: pointer;
}
.install-close {
  border: none;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  font-size: 14px;
}

/* ============ 照片墙 ============ */
.gallery-wrap { position: relative; z-index: 2; padding: 14px 0 20px; }

.masonry {
  columns: 2;
  column-gap: 12px;
  padding: 0 14px;
  max-width: 720px;
  margin: 0 auto;
}

/* 拍立得卡片 */
.card {
  break-inside: avoid;
  margin-bottom: 14px;
  background: #fff;
  border-radius: var(--radius-md);
  padding: 9px 9px 10px;
  box-shadow: var(--card-shadow);
  transform: rotate(var(--r, 0deg));
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  cursor: pointer;
  animation: popIn 0.4s ease backwards;
}
.card:active { transform: scale(0.97); }
@keyframes popIn {
  from { opacity: 0; transform: translateY(14px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.photo-wrap {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  background: linear-gradient(135deg, #ffeef4, #f6efff);
}
.photo-wrap img {
  display: block;
  width: 100%;
  min-height: 60px;
  object-fit: cover;
}

.owner-badge {
  position: absolute;
  top: 8px; left: 8px;
  width: 26px; height: 26px;
  display: grid; place-items: center;
  font-size: 13px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.14);
}
.owner-badge.a { background: #ffd9e3; }
.owner-badge.b { background: #dcd2ff; }

.sync-flag {
  position: absolute;
  top: 8px; right: 8px;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  color: #b09ac0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

figcaption {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 4px 0;
  font-size: 12px;
  color: var(--ink-soft);
}
.cap-owner { font-weight: 700; color: var(--pink-deep); }

/* ============ 空状态 ============ */
.empty-state {
  text-align: center;
  padding: 60px 34px 30px;
  max-width: 420px;
  margin: 0 auto;
}
.empty-emoji { font-size: 64px; animation: bob 3s ease-in-out infinite; }
.empty-title { margin-top: 18px; font-size: 18px; font-weight: 700; }
.empty-sub { margin-top: 8px; color: var(--ink-soft); font-size: 14px; }
.empty-tip {
  margin-top: 22px;
  font-size: 12.5px;
  color: #9a86c8;
  background: rgba(255, 255, 255, 0.7);
  border: 1.5px dashed #d9c8ff;
  border-radius: var(--radius-md);
  padding: 12px 14px;
  line-height: 1.7;
}

/* ============ 底部操作栏 ============ */
.fab-bar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(20px + var(--safe-bottom));
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  padding: 12px 20px;
  border-radius: 999px;
  box-shadow: 0 10px 30px rgba(255, 118, 158, 0.32);
  border: 1.5px solid rgba(255, 214, 226, 0.9);
}

.fab {
  width: 48px; height: 48px;
  border: none;
  border-radius: 50%;
  font-size: 21px;
  cursor: pointer;
  background: linear-gradient(135deg, #fff3f7, #ffeaf1);
  box-shadow: inset 0 0 0 1.5px #ffd6e2;
  transition: transform 0.18s ease;
}
.fab:active { transform: scale(0.9); }

.main-fab {
  width: 62px; height: 62px;
  font-size: 28px;
  background: linear-gradient(135deg, #ff9a9e 0%, #ff6b95 60%, #ff5f8f 100%);
  box-shadow: 0 8px 20px rgba(255, 95, 143, 0.45);
  animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 8px 20px rgba(255, 95, 143, 0.45); }
  50% { box-shadow: 0 8px 26px rgba(255, 95, 143, 0.7); }
}

/* ============ 灯箱 ============ */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(46, 26, 38, 0.92);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.22s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

#lb-img {
  max-width: 94vw;
  max-height: 78vh;
  border-radius: 14px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.5);
  touch-action: pinch-zoom;
}

.lb-close, .lb-delete {
  position: absolute;
  top: calc(14px + env(safe-area-inset-top, 0px));
  width: 42px; height: 42px;
  border: none;
  border-radius: 50%;
  font-size: 17px;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}
.lb-close { right: 16px; }
.lb-delete { left: 16px; }

.lb-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 46px; height: 46px;
  border: none;
  border-radius: 50%;
  font-size: 26px;
  line-height: 1;
  color: #fff;
  background: rgba(255, 255, 255, 0.14);
  cursor: pointer;
}
.lb-prev { left: 10px; }
.lb-next { right: 10px; }

.lb-caption {
  position: absolute;
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  left: 0; right: 0;
  text-align: center;
  color: #ffd9e3;
  font-size: 13.5px;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.lb-heart-burst { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.lb-heart-burst span {
  position: absolute;
  left: 50%;
  bottom: 26%;
  font-size: 26px;
  animation: burst 1.1s ease-out forwards;
}
@keyframes burst {
  0% { transform: translate(-50%, 0) scale(0.5); opacity: 1; }
  100% { transform: translate(calc(-50% + var(--dx, 0px)), -46vh) scale(1.35) rotate(var(--rot, 20deg)); opacity: 0; }
}

/* ============ 弹层 & 面板 ============ */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 55; /* 高于灯箱(50)，确保删除确认等弹窗不被大图遮挡 */
  background: rgba(80, 46, 62, 0.4);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

.panel {
  width: 100%;
  max-width: 560px;
  max-height: 86vh;
  overflow-y: auto;
  background: var(--cream);
  border-radius: 26px 26px 0 0;
  padding: 24px 22px calc(26px + var(--safe-bottom));
  box-shadow: 0 -12px 40px rgba(120, 52, 84, 0.28);
  animation: slideUp 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes slideUp { from { transform: translateY(60px); opacity: 0.4; } to { transform: translateY(0); opacity: 1; } }

.settings-panel h2 { font-size: 20px; margin-bottom: 18px; text-align: center; }

/* 开关 */
.switch-row {
  display: flex;
  align-items: center;
  gap: 14px;
  background: #fff;
  border-radius: var(--radius-md);
  padding: 14px;
  box-shadow: var(--card-shadow);
  margin-bottom: 14px;
}
.switch-text { flex: 1; }
.switch-text strong { font-size: 15px; display: block; }
.switch-text small { font-size: 12px; color: var(--ink-soft); line-height: 1.6; display: block; margin-top: 4px; }

.switch { position: relative; display: inline-block; width: 54px; height: 30px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #ecdfe5;
  transition: 0.28s;
  cursor: pointer;
}
.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.18);
  transition: 0.28s;
}
.switch input:checked + .slider { background: linear-gradient(90deg, #ff9a9e, #ff6b95); }
.switch input:checked + .slider::before { transform: translateX(24px); }

/* 表单 */
.form-row { margin-bottom: 14px; }
.form-row label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 6px;
}
.form-row input[type="text"],
.form-row input[type="date"],
.form-row input[type="password"],
.form-row select {
  width: 100%;
  border: 1.5px solid #f2d7e0;
  border-radius: 12px;
  background: #fff;
  padding: 10px 14px;
  font-size: 14px;
  color: var(--ink);
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
}
.form-row input:focus, .form-row select:focus { border-color: var(--pink); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* 按钮 */
.btn-ghost, .btn-primary {
  border: none;
  border-radius: 999px;
  padding: 12px 30px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.15s ease;
}
.btn-ghost:active, .btn-primary:active { transform: scale(0.95); }
.btn-ghost { background: #f6e6ec; color: var(--pink-deep); }
.btn-primary { background: linear-gradient(135deg, #ff9a9e, #ff6b95); color: #fff; box-shadow: 0 6px 16px rgba(255, 95, 143, 0.35); }

.panel-btns { text-align: center; margin-top: 18px; }

/* 确认弹窗 */
.confirm-panel { max-width: 420px; margin: 0 18px; align-self: center; border-radius: 24px; padding-bottom: 22px; }
#confirm-text { font-size: 15px; line-height: 1.8; text-align: center; padding: 6px 2px 4px; white-space: pre-line; }
.confirm-btns { display: flex; gap: 14px; justify-content: center; margin-top: 18px; }

/* ============ Toast ============ */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(104px + var(--safe-bottom));
  transform: translateX(-50%);
  z-index: 60;
  max-width: 86vw;
  background: rgba(77, 46, 62, 0.92);
  color: #ffeef4;
  font-size: 13.5px;
  line-height: 1.5;
  padding: 11px 20px;
  border-radius: 999px;
  box-shadow: 0 8px 24px rgba(77, 46, 62, 0.35);
  text-align: center;
  animation: toastIn 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes toastIn { from { transform: translate(-50%, 14px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }

/* ============ 小屏适配 ============ */
@media (min-width: 560px) {
  .masonry { columns: 3; }
}
@media (min-width: 900px) {
  .masonry { columns: 4; }
}
