:root {
  --bg: #f8f4f0;
  --card: #ffffff;
  --text: #4a4540;
  --text2: #a39b92;
  --accent: #e8a598;
  --accent-deep: #ce7b6b;
  --taupe: #d8c3a5;
  --olive: #c8d6b9;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-font-smoothing: antialiased; }

[hidden] { display: none !important; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC",
    "Inter", "HarmonyOS Sans", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  -webkit-tap-highlight-color: transparent;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding: calc(32px + env(safe-area-inset-top)) 20px
    calc(96px + env(safe-area-inset-bottom));
}

/* ---- 备案号 ---- */
.icp-footer {
  text-align: center;
  font-size: 11px;
  color: var(--text2);
  margin-top: 20px;
  padding-bottom: 4px;
}
.icp-footer a { color: var(--text2); text-decoration: none; }

/* ---- 顶部 ---- */
.nav { text-align: center; margin-bottom: 24px; animation: rise 0.6s ease both; }

.title { font-size: 30px; font-weight: 300; letter-spacing: 2px; }

.subtitle { color: var(--text2); font-size: 14px; font-weight: 300; margin-top: 6px; letter-spacing: 0.5px; }

/* ---- 手绘时间轴 ---- */
.timeline-wrap { position: relative; }

.timeline-line {
  position: absolute;
  left: 50%; top: 0;
  transform: translateX(-50%);
  width: 60px;
  pointer-events: none;
  z-index: 0;
}
.timeline-line path {
  fill: none;
  stroke: #c0a583;
  stroke-width: 3;
  stroke-linecap: round;
  opacity: 0.85;
}

.timeline { position: relative; z-index: 1; display: flex; flex-direction: column; }

.t-entry {
  position: relative;
  width: 50%;
  box-sizing: border-box;
  padding-bottom: 28px;
  animation: rise 0.55s ease both;
}
.t-entry.left  { padding-right: 26px; }
.t-entry.right { margin-left: 50%; padding-left: 26px; }

.t-node {
  position: absolute;
  top: 22px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 1px 3px rgba(74, 69, 64, 0.25);
  z-index: 2;
}
.t-entry.left  .t-node { right: -6px; }
.t-entry.right .t-node { left: -6px; }

.t-photo {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 14px;
  overflow: hidden;
  background: #f0e9e0;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(74, 69, 64, 0.08);
  transform: rotate(var(--rot, 0deg));
}
.t-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.t-photo svg { width: 42%; height: 42%; color: #8a6b5c; }

.tint-terracotta { background: linear-gradient(135deg, #f2ccc2, #e8a598); }
.tint-taupe      { background: linear-gradient(135deg, #eadbc3, #d8c3a5); }
.tint-olive      { background: linear-gradient(135deg, #dde5cf, #c8d6b9); }

.t-words { font-size: 15px; font-weight: 300; line-height: 1.5; margin-top: 10px; word-break: break-word; }

.t-time { color: var(--text2); font-size: 12px; font-weight: 300; margin-top: 4px; display: block; }

/* ---- 日历 ---- */
.calendar {
  background: var(--card);
  border-radius: 20px;
  padding: 14px 10px 12px;
  box-shadow: 0 2px 10px rgba(74, 69, 64, 0.06);
  animation: rise 0.55s ease 0.05s both;
}

.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 11px;
  font-weight: 300;
  color: var(--text2);
  margin-bottom: 8px;
}

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

.cal-cell {
  position: relative;
  aspect-ratio: 1 / 1.12;
  background: #faf6f1;
  border-radius: 10px;
  padding: 4px 3px 3px;
  display: flex;
  flex-direction: column;
}

.cal-day {
  font-size: 11px;
  color: var(--text2);
  width: 18px; height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.cal-cell.today .cal-day {
  background: var(--accent);
  color: #fff;
  font-weight: 400;
}

.cal-cell.other { background: #f4efe9; }
.cal-cell.other .cal-day { color: #cbc3b8; }

.cal-stack { position: relative; flex: 1; margin-top: 2px; }

.cal-photo {
  position: absolute;
  left: 50%; top: 50%;
  width: 34px; height: 34px;
  border-radius: 8px;
  overflow: hidden;
  background: #f0e9e0;
  box-shadow: 0 1px 3px rgba(74, 69, 64, 0.22);
  transform: translate(-50%, -50%) rotate(var(--r)) translate(var(--x), var(--y));
  display: flex;
  align-items: center;
  justify-content: center;
}
.cal-photo img { width: 100%; height: 100%; object-fit: cover; }
.cal-photo svg { width: 62%; height: 62%; color: #8a6b5c; }

/* ---- 长按删除确认 ---- */
.confirm-mask {
  position: fixed;
  inset: 0;
  background: rgba(74, 69, 64, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 55;
  animation: fade 0.2s ease both;
}
.confirm-box {
  background: #fff;
  width: 78%;
  max-width: 320px;
  border-radius: 20px;
  padding: 24px 20px 18px;
  text-align: center;
  animation: slideUp 0.25s ease both;
}
.confirm-text { font-size: 16px; font-weight: 300; color: var(--text); margin-bottom: 18px; }
.confirm-actions { display: flex; gap: 12px; }
.btn-danger {
  background: linear-gradient(135deg, #e58a7a, var(--accent-deep));
  color: #fff;
  box-shadow: 0 4px 12px rgba(206, 123, 107, 0.3);
}

.t-photo, .t-photo img, .cal-photo, .cal-photo img, .t-entry {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}
.t-photo img, .cal-photo img { -webkit-user-drag: none; }

/* ---- 底部导航 ---- */
.tabbar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: 480px;
  background: rgba(255, 253, 250, 0.9);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid #ece3d8;
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  z-index: 40;
}

.tab {
  flex: 1;
  border: none;
  background: transparent;
  color: #b6ada2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  font-family: inherit;
  cursor: pointer;
}
.tab.active { color: var(--accent-deep); }
.tab svg { width: 24px; height: 24px; }

.cam-btn {
  width: 52px; height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(206, 123, 107, 0.35);
  transition: transform 0.15s;
}
.cam-btn:active { transform: scale(0.92); }
.cam-btn svg { width: 26px; height: 26px; }

/* ---- 记下浮层 ---- */
.sheet-mask {
  position: fixed;
  inset: 0;
  background: rgba(74, 69, 64, 0.35);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
  animation: fade 0.2s ease both;
}

.sheet {
  background: #fff;
  width: 100%;
  max-width: 480px;
  border-radius: 24px 24px 0 0;
  padding: 14px 20px calc(20px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: slideUp 0.3s cubic-bezier(0.22, 0.9, 0.35, 1) both;
}

.sheet-handle { width: 40px; height: 5px; border-radius: 3px; background: #e6ddd3; margin: 0 auto 2px; }

.sheet-preview { width: 100%; max-height: 260px; object-fit: cover; border-radius: 16px; background: #f0e9e0; }

.sheet-input {
  border: none; outline: none; resize: none;
  font-family: inherit; font-size: 16px; font-weight: 300;
  color: var(--text);
  background: #f6f1ea;
  border-radius: 14px;
  padding: 14px;
}
.sheet-input::placeholder { color: #b6ada2; }

.sheet-tools { display: flex; gap: 10px; }
.tool-btn {
  flex: 1;
  border: 1px solid #e6ddd3;
  background: #faf6f1;
  color: var(--text);
  border-radius: 999px;
  padding: 10px;
  font-size: 14px;
  font-weight: 300;
  font-family: inherit;
  cursor: pointer;
}
.tool-btn:active { background: #f0e9e0; }
.tool-btn:disabled { opacity: 0.55; cursor: default; }

.sheet-actions { display: flex; gap: 12px; }

.btn-ghost, .btn-solid {
  flex: 1;
  border: none;
  border-radius: 999px;
  padding: 14px;
  font-size: 16px;
  font-family: inherit;
  cursor: pointer;
}
.btn-ghost { background: #f0e9e0; color: var(--text); }
.btn-solid {
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  color: #fff;
  box-shadow: 0 4px 12px rgba(206, 123, 107, 0.28);
}

/* ---- 提示 ---- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 110px;
  transform: translateX(-50%);
  background: rgba(74, 69, 64, 0.9);
  color: #fff;
  font-size: 14px;
  font-weight: 300;
  padding: 10px 20px;
  border-radius: 999px;
  white-space: nowrap;
  z-index: 60;
}

/* ---- 动效 ---- */
@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}
