* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --rose: #e489a5;
  --rose-deep: #cf6a8e;
  --rose-soft: #fbd7e2;
  --rose-light: #fdeef4;
  --bg: #fff8fb;
  --card: #ffffff;
  --text: #4b3441;
  --muted: #a18493;
  --line: #f3dce4;
  --shadow: 0 8px 28px rgba(207, 106, 142, 0.12);
  --radius: 20px;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", -apple-system,
    BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(1100px 500px at 85% -80px, #ffe4ee 0%, rgba(255, 228, 238, 0) 60%),
    radial-gradient(900px 420px at -80px 30%, #fff0f6 0%, rgba(255, 240, 246, 0) 55%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

.bg-hearts {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.bg-hearts::before,
.bg-hearts::after {
  content: "💗";
  position: absolute;
  font-size: 120px;
  opacity: 0.06;
  filter: blur(2px);
}

.bg-hearts::before {
  top: 18%;
  right: -30px;
  transform: rotate(18deg);
}

.bg-hearts::after {
  bottom: 8%;
  left: -30px;
  font-size: 90px;
  transform: rotate(-14deg);
}

.container {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 16px;
  position: relative;
  z-index: 1;
}

/* ---------- 顶部 ---------- */
.topbar {
  background: linear-gradient(135deg, #ffb3c6 0%, #f48fb1 60%, #ee7ea6 100%);
  color: #fff;
  padding: 20px 0 64px;
  border-radius: 0 0 34px 34px;
  box-shadow: 0 10px 30px rgba(238, 126, 166, 0.28);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-heart {
  font-size: 34px;
  filter: drop-shadow(0 2px 6px rgba(255, 255, 255, 0.45));
}

.brand h1 {
  font-size: 22px;
  letter-spacing: 1px;
}

.subtitle {
  font-size: 13px;
  opacity: 0.92;
}

.stats {
  display: flex;
  gap: 10px;
}

.stat {
  background: rgba(255, 255, 255, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 16px;
  padding: 8px 16px;
  min-width: 88px;
  text-align: center;
  backdrop-filter: blur(4px);
}

.stat b {
  display: block;
  font-size: 20px;
  line-height: 1.2;
}

.stat span {
  font-size: 11.5px;
  opacity: 0.92;
}

/* ---------- 标签页 ---------- */
.tabs {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin: -42px auto 22px;
  position: relative;
  z-index: 5;
  flex-wrap: wrap;
}

.tab {
  border: none;
  background: #fff;
  color: var(--text);
  font-size: 14.5px;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: all 0.2s;
  font-family: inherit;
}

.tab:hover {
  transform: translateY(-1px);
}

.tab.active {
  background: linear-gradient(135deg, #f79cb9, #ee7ea6);
  color: #fff;
}

/* ---------- 视图 ---------- */
.view {
  display: none;
  animation: fadeUp 0.3s ease;
}

.view.active {
  display: block;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.view-head {
  margin: 4px 0 18px;
}

.view-head h2 {
  font-size: 21px;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}

/* ---------- 日历 ---------- */
.calendar-card {
  margin-bottom: 22px;
}

.cal-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.cal-head h2 {
  font-size: 18px;
  flex: 1;
}

.icon-btn {
  border: none;
  background: var(--rose-light);
  color: var(--rose-deep);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  font-size: 19px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.18s;
  font-family: inherit;
}

.icon-btn:hover {
  background: var(--rose-soft);
  transform: scale(1.05);
}

.today-btn {
  margin-left: auto;
}

.ghost-btn {
  border: 1.5px solid var(--rose);
  background: #fff;
  color: var(--rose-deep);
  font-size: 13.5px;
  font-weight: 600;
  padding: 9px 18px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.18s;
  font-family: inherit;
}

.ghost-btn:hover {
  background: var(--rose-light);
}

.primary-btn {
  border: none;
  background: linear-gradient(135deg, #f79cb9, #ee7ea6);
  color: #fff;
  font-size: 14.5px;
  font-weight: 600;
  padding: 11px 22px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(238, 126, 166, 0.35);
  transition: all 0.18s;
  font-family: inherit;
}

.primary-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(238, 126, 166, 0.45);
}

.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  color: var(--muted);
  font-size: 12.5px;
  margin-bottom: 6px;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}

.cal-cell {
  border: none;
  background: #fff;
  min-width: 0;
  padding: 2px 0;
  aspect-ratio: 1;
  border-radius: 13px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  position: relative;
  transition: all 0.15s;
  font-family: inherit;
}

.cal-cell:not(.empty):hover {
  background: var(--rose-light);
  transform: scale(1.04);
}

.cal-cell.empty {
  cursor: default;
}

.cal-num {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text);
}

.cal-heart {
  font-size: 11px;
  line-height: 1;
}

.cal-count {
  position: absolute;
  top: 3px;
  right: 4px;
  background: var(--rose-soft);
  color: var(--rose-deep);
  font-size: 9.5px;
  font-weight: 700;
  min-width: 15px;
  height: 15px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
}

.cal-cell.today .cal-num {
  color: var(--rose-deep);
}

.cal-cell.today {
  outline: 2px solid var(--rose);
  outline-offset: -2px;
}

.cal-cell.selected {
  background: linear-gradient(135deg, #f79cb9, #ee7ea6);
  box-shadow: 0 5px 14px rgba(238, 126, 166, 0.4);
}

.cal-cell.selected .cal-num {
  color: #fff;
}

.cal-cell.selected .cal-count {
  background: rgba(255, 255, 255, 0.35);
  color: #fff;
}

.cal-hint {
  text-align: right;
  margin-top: 10px;
  font-size: 12px;
}

/* ---------- 当天记录 ---------- */
.day-panel {
  margin-bottom: 40px;
}

.day-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.day-head h2 {
  font-size: 18px;
}

.empty {
  text-align: center;
  padding: 46px 20px;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.empty-icon {
  font-size: 42px;
  margin-bottom: 10px;
}

.empty p {
  margin-bottom: 4px;
}

.empty .primary-btn {
  margin-top: 14px;
}

/* ---------- 日记卡片 ---------- */
.entry-card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  margin-bottom: 14px;
  border-left: 4px solid var(--rose-soft);
}

.entry-top {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.author-badge {
  background: var(--rose-light);
  color: var(--rose-deep);
  font-size: 12.5px;
  font-weight: 700;
  padding: 3px 12px;
  border-radius: 999px;
}

.mood,
.weather {
  font-size: 15px;
}

.entry-time {
  margin-left: auto;
  font-size: 12px;
}

.entry-actions {
  display: flex;
  gap: 6px;
}

.mini-btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  padding: 4px 11px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}

.mini-btn:hover {
  border-color: var(--rose);
  color: var(--rose-deep);
  background: var(--rose-light);
}

.entry-title {
  font-size: 16.5px;
  margin-bottom: 6px;
}

.entry-content {
  font-size: 14.5px;
  color: #5f4452;
  white-space: pre-line;
}

.entry-tags {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  background: #fff0f5;
  color: #c26a8b;
  font-size: 12px;
  padding: 2px 10px;
  border-radius: 999px;
}

.card-photo {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.card-photo img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 13px;
  cursor: zoom-in;
  transition: transform 0.18s;
}

.card-photo img:hover {
  transform: scale(1.03);
}

/* ---------- 时间轴 ---------- */
#timelineList {
  position: relative;
  padding-left: 22px;
  border-left: 2px dashed #f3c4d3;
}

.tl-month {
  margin: 4px 0 12px -22px;
}

.tl-month span {
  display: inline-block;
  background: linear-gradient(135deg, #f79cb9, #ee7ea6);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  padding: 5px 16px;
  border-radius: 999px;
  box-shadow: 0 4px 10px rgba(238, 126, 166, 0.3);
}

.tl-item {
  position: relative;
}

.tl-item::before {
  content: "💗";
  position: absolute;
  left: -31px;
  top: 16px;
  font-size: 14px;
  background: var(--bg);
  line-height: 1;
}

.tl-item .entry-time {
  margin-left: 0;
}

/* ---------- 相册 ---------- */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}

.g-item {
  border: none;
  padding: 0;
  background: none;
  cursor: zoom-in;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.g-item img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
  transition: transform 0.25s;
}

.g-item:hover img {
  transform: scale(1.06);
}

/* ---------- 设置 ---------- */
.settings-card {
  margin-bottom: 18px;
}

.settings-card h2 {
  font-size: 17px;
  margin-bottom: 14px;
}

.form-row {
  margin-bottom: 14px;
}

.form-row > label {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
}

.form-row .label {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  display: block;
  margin-bottom: 6px;
}

.hint {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
  margin-left: 4px;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

input[type="text"],
input[type="date"],
input[type="date"],
select,
textarea {
  width: 100%;
  margin-top: 6px;
  border: 1.5px solid var(--line);
  background: #fffafc;
  color: var(--text);
  font-size: 14.5px;
  font-family: inherit;
  padding: 11px 14px;
  border-radius: 13px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--rose);
  box-shadow: 0 0 0 3px rgba(228, 137, 165, 0.15);
}

textarea {
  resize: vertical;
}

.btn-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.danger-zone {
  border: 1.5px dashed #f3b3b3;
}

.danger-btn {
  border: none;
  background: #fdecec;
  color: #d45757;
  font-size: 14px;
  font-weight: 600;
  padding: 11px 20px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.18s;
  font-family: inherit;
}

.danger-btn:hover {
  background: #f7d5d5;
}

/* ---------- 解锁界面 ---------- */
.login-modal {
  max-width: 360px;
  text-align: center;
}

.login-icon {
  font-size: 44px;
  margin-bottom: 8px;
}

.login-modal input {
  margin: 14px 0 4px;
  text-align: center;
}

.login-error {
  min-height: 20px;
  color: #d45757;
  margin-top: 6px;
}

.login-btn {
  width: 100%;
  margin-top: 8px;
}

/* ---------- 弹窗 ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(60, 32, 46, 0.45);
  backdrop-filter: blur(3px);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal {
  background: #fff;
  width: 100%;
  max-width: 620px;
  max-height: 92vh;
  overflow-y: auto;
  border-radius: 24px;
  padding: 24px;
  box-shadow: 0 24px 60px rgba(60, 20, 40, 0.3);
  animation: modalIn 0.25s ease;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.modal-head h2 {
  font-size: 19px;
}

.emoji-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.emoji-opt {
  border: 1.5px solid var(--line);
  background: #fff;
  font-size: 19px;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}

.emoji-opt:hover {
  transform: scale(1.1);
  border-color: var(--rose);
}

.emoji-opt.selected {
  background: linear-gradient(135deg, #f79cb9, #ee7ea6);
  border-color: transparent;
  box-shadow: 0 4px 10px rgba(238, 126, 166, 0.35);
}

.photo-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.photo-thumb-box {
  position: relative;
}

.photo-thumb-box img {
  width: 84px;
  height: 84px;
  object-fit: cover;
  border-radius: 13px;
  display: block;
}

.photo-remove {
  position: absolute;
  top: -7px;
  right: -7px;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  background: #fff;
  color: #d45757;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.upload-btn {
  display: inline-block;
  border: 1.5px dashed var(--rose);
  background: var(--rose-light);
  color: var(--rose-deep);
  font-size: 13.5px;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 13px;
  cursor: pointer;
  transition: all 0.15s;
}

.upload-btn:hover {
  background: var(--rose-soft);
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.hidden {
  display: none !important;
}

/* ---------- 照片查看器 ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(20, 10, 16, 0.9);
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

.lightbox img {
  max-width: 88vw;
  max-height: 78vh;
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.lightbox-caption {
  color: #f3dce4;
  font-size: 14px;
  margin-top: 12px;
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  width: 46px;
  height: 46px;
  font-size: 24px;
}

.lightbox-prev {
  left: 18px;
}

.lightbox-next {
  right: 18px;
}

.lightbox-close {
  position: absolute;
  top: 18px;
  right: 18px;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

/* ---------- 提示条 ---------- */
.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(74, 44, 60, 0.92);
  color: #fff;
  font-size: 14px;
  padding: 11px 24px;
  border-radius: 999px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s;
  z-index: 80;
  white-space: nowrap;
  max-width: 90vw;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---------- 响应式 ---------- */
@media (max-width: 640px) {
  .topbar {
    padding: 16px 0 58px;
    border-radius: 0 0 26px 26px;
  }

  .brand h1 {
    font-size: 18px;
  }

  .stat {
    padding: 6px 10px;
    min-width: 70px;
  }

  .stat b {
    font-size: 16px;
  }

  .stat span {
    font-size: 10.5px;
  }

  .tabs {
    margin-top: -36px;
  }

  .tab {
    font-size: 13px;
    padding: 9px 14px;
  }

  .card {
    padding: 16px;
  }

  .cal-cell {
    border-radius: 10px;
  }

  .cal-num {
    font-size: 13px;
  }

  .two-col {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  }

  .lightbox-nav {
    width: 38px;
    height: 38px;
    font-size: 20px;
  }
}
