* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
:root {
  --primary: #f49b5e;
  --primary-dark: #e07f3f;
  --bg: #fff8f2;
  --card: #ffffff;
  --text: #4a3f35;
  --text-light: #a08d7d;
  --border: #f0e4d8;
  --accent: #7fb069;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
}
.hidden { display: none !important; }

/* ===== 开屏欢迎页 ===== */
.splash {
  position: fixed; inset: 0; background: var(--bg); z-index: 200;
  display: flex; align-items: center; justify-content: center;
}
.welcome { text-align: center; padding: 24px; width: 100%; max-width: 340px; }
.splash-logo { font-size: 56px; margin-bottom: 10px; }
.splash-text { font-size: 26px; color: var(--primary-dark); letter-spacing: 6px; font-weight: 700; }
.splash-slogan { font-size: 15px; color: var(--text-light); margin-top: 14px; line-height: 1.8; }
.splash-stage { margin: 24px 0; }
.welcome-btn { margin-top: 8px; }
.splash.done { opacity: 0; pointer-events: none; transition: opacity .35s; }

/* ===== 登录/注册页（身份层） ===== */
.login-hero { text-align: center; padding: 56px 0 12px; }
.login-hero .logo { font-size: 52px; }
.login-hero h1 { font-size: 30px; color: var(--primary-dark); margin: 10px 0 6px; letter-spacing: 2px; }
.login-hero .subtitle { color: var(--text-light); font-size: 15px; }
.login-card { margin: 20px 16px 8px; }
.auth-tabs { display: flex; gap: 8px; margin-bottom: 18px; }
.auth-tab {
  flex: 1; text-align: center; padding: 10px; border-radius: 12px;
  font-size: 15px; color: var(--text-light); cursor: pointer;
  background: #f6efe6; transition: all .15s;
}
.auth-tab.active { background: var(--primary); color: #fff; font-weight: 600; }
.auth-btn { width: 100%; margin-top: 6px; }
.auth-error { color: #e05252; font-size: 13px; margin-top: 10px; text-align: center; min-height: 18px; }
.auth-note { font-size: 12px; color: var(--text-light); margin-top: 8px; line-height: 1.6; }
.login-foot { text-align: center; color: var(--text-light); font-size: 13px; padding: 18px 0 30px; }
.page#page-login { display: flex; flex-direction: column; min-height: 100vh; background: linear-gradient(180deg, #fffaf3, #fff); }

/* ===== 建档页 ===== */
.page { padding-bottom: 76px; }
.create-hero { text-align: center; padding: 56px 24px 24px; }
.logo { font-size: 52px; margin-bottom: 12px; }
.create-hero h1 { font-size: 30px; color: var(--primary-dark); letter-spacing: 2px; }
.create-hero .subtitle { color: var(--text-light); font-size: 14px; margin-top: 8px; }
.create-card { margin: 16px; padding: 24px 20px; }
.field { margin-bottom: 18px; }
.field label { display: block; font-size: 13px; color: var(--text-light); margin-bottom: 6px; }
.field input {
  width: 100%; padding: 12px; border: 1.5px solid var(--border);
  border-radius: 12px; font-size: 16px; background: #fffdfa;
  color: var(--text); outline: none;
}
.field input:focus { border-color: var(--primary); }
.btn-primary {
  width: 100%; padding: 14px; border: none; border-radius: 14px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff; font-size: 17px; font-weight: 600; cursor: pointer;
  letter-spacing: 2px; box-shadow: 0 4px 14px rgba(240,155,94,.35);
}
.btn-primary:active { transform: scale(.97); }
.hint { text-align: center; font-size: 12px; color: var(--text-light); margin-top: 12px; }

/* ===== 人生阶段选择 ===== */
.stage-select { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.stage-option {
  padding: 10px 4px; border-radius: 12px; border: 1.5px solid var(--border);
  text-align: center; cursor: pointer; background: #fffdfa;
  transition: all .15s; font-size: 12px; color: var(--text);
}
.stage-option .stage-emoji { font-size: 22px; display: block; margin-bottom: 4px; }
.stage-option span { display: block; }
.stage-option.selected {
  border-color: var(--primary); background: #fff0e0;
  color: var(--primary-dark); font-weight: 600;
}

/* ===== 拍照记 ===== */
.card-title { font-size: 16px; font-weight: 700; margin-bottom: 6px; }
.card-desc { font-size: 13px; color: var(--text-light); line-height: 1.6; margin-bottom: 12px; }
.upload-area { text-align: center; }
.upload-box {
  border: 2px dashed var(--border); border-radius: 14px; padding: 30px 12px;
  color: var(--text-light); font-size: 15px; cursor: pointer;
  transition: all .15s; background: #fffdfa;
}
.upload-box:hover, .upload-box.active { border-color: var(--primary); color: var(--primary-dark); }
.preview { width: 100%; border-radius: 12px; margin-top: 10px; max-height: 320px; object-fit: contain; }
.btn-ocr { margin-top: 12px; }
.ocr-result { margin-top: 12px; padding: 12px; border-radius: 12px; background: #f0faf0; border: 1px solid #d4eccb; font-size: 13px; line-height: 1.7; }
.ocr-result .or-title { font-weight: 600; color: var(--accent); margin-bottom: 8px; }
.ocr-result textarea { margin-bottom: 8px; font-size: 14px; }
.or-date-row { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.or-date-row label { font-size: 13px; color: var(--text-light); }
.or-date-row input[type="date"] {
  padding: 8px; border: 1.5px solid var(--border); border-radius: 10px;
  font-size: 14px; background: #fffdfa; color: var(--text); outline: none; flex: 1; min-width: 130px;
}
.or-date-hint { font-size: 12px; color: var(--text-light); }
.or-btns { display: flex; gap: 10px; }
.or-btns .btn-primary { flex: 1; padding: 10px; font-size: 14px; letter-spacing: 1px; }
.or-btns .btn-ghost { flex: 1; padding: 10px; font-size: 14px; }
.btn-add-note { margin-top: 10px; }
.notes-list .tl-item { margin-bottom: 12px; }

/* ===== 卡片 ===== */
.card {
  background: var(--card); border-radius: 16px; padding: 16px;
  box-shadow: 0 2px 12px rgba(74,63,53,.06); margin: 12px;
}

/* ===== 顶栏 ===== */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 16px 8px;
}
.person-info { display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 48px; height: 48px; border-radius: 50%;
  background: linear-gradient(135deg, #ffe0c2, #ffd0a8);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
}
.person-name { font-size: 18px; font-weight: 700; }
.person-meta { font-size: 12px; color: var(--text-light); }
.switch-btn {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--card); border: 1.5px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: var(--text-light); cursor: pointer;
}

/* ===== 快速标签 ===== */
.quick-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.quick-tag {
  padding: 6px 12px; border-radius: 20px; background: #fff3e6;
  color: var(--primary-dark); font-size: 13px; cursor: pointer;
  border: 1px solid transparent; transition: all .15s;
}
.quick-tag.selected { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ===== 记录区 ===== */
textarea {
  width: 100%; padding: 12px; border: 1.5px solid var(--border);
  border-radius: 12px; font-size: 16px; resize: none; outline: none;
  background: #fffdfa; color: var(--text); line-height: 1.6;
}
textarea:focus { border-color: var(--primary); }
.record-row { display: flex; gap: 10px; margin-top: 12px; align-items: center; }
.record-row input[type="datetime-local"] {
  flex: 1; padding: 10px; border: 1.5px solid var(--border); border-radius: 12px;
  font-size: 14px; color: var(--text); background: #fffdfa; outline: none;
}
.btn-record { width: auto; padding: 12px 22px; letter-spacing: 1px; font-size: 15px; flex-shrink: 0; }
.relate-row, .or-relate-row { display: flex; align-items: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.relate-row label, .or-relate-row label { font-size: 13px; color: var(--text-light); white-space: nowrap; }
.relate-row select, .or-relate-row select {
  flex: 1; min-width: 120px; padding: 8px; border: 1.5px solid var(--border); border-radius: 10px;
  font-size: 13px; background: #fffdfa; color: var(--text); outline: none;
}
.relate-hint { font-size: 12px; color: var(--text-light); }

/* ===== 语音输入 ===== */
.voice-row { display: flex; align-items: center; gap: 12px; margin-top: 14px; }
.voice-btn {
  width: 48px; height: 48px; border-radius: 50%; border: none; flex-shrink: 0;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff; font-size: 22px; cursor: pointer;
  box-shadow: 0 4px 12px rgba(240,155,94,.3); transition: all .15s;
}
.voice-btn:active { transform: scale(.94); }
.voice-btn.recording { background: #e05252; animation: voicePulse 1.2s infinite; }
@keyframes voicePulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(224,82,82,.25); }
  50% { box-shadow: 0 0 0 9px rgba(224,82,82,.15); }
}
.voice-status { font-size: 13px; color: var(--text-light); flex: 1; line-height: 1.5; }
.voice-status.working { color: var(--primary-dark); font-weight: 600; }
.voice-status.ok { color: var(--accent); }
.record-result {
  margin-top: 12px; padding: 12px; border-radius: 12px;
  background: #f0faf0; border: 1px solid #d4eccb; font-size: 14px;
}
.record-result .rr-title { font-weight: 600; color: var(--accent); margin-bottom: 4px; }
.record-result .rr-badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.record-result .badge {
  padding: 3px 10px; border-radius: 14px; background: #e6f2e0; color: #4f7d3a; font-size: 12px;
}

/* ===== 时间轴 ===== */
.timeline { padding: 12px 0; position: relative; }
.tl-item {
  display: flex; gap: 12px; margin: 0 12px 16px; position: relative;
}
.tl-dot {
  width: 12px; height: 12px; border-radius: 50%; background: var(--primary);
  margin-top: 6px; flex-shrink: 0; box-shadow: 0 0 0 4px #ffe9d4;
}
.tl-body { flex: 1; }
.tl-time { font-size: 12px; color: var(--text-light); margin-bottom: 4px; }
.tl-card { background: var(--card); border-radius: 12px; padding: 12px; box-shadow: 0 1px 8px rgba(74,63,53,.05); font-size: 15px; line-height: 1.6; }
.tl-from { display: inline-block; font-size: 12px; color: #a0804a; background: #f3ead9; border-radius: 6px; padding: 2px 8px; margin-bottom: 6px; }
.tl-card .tl-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.tl-card .tl-tag {
  padding: 2px 8px; border-radius: 10px; background: #f3ead9; color: #a0804a; font-size: 11px;
}
.tl-card .tl-tag.milestone { background: #ffe3c9; color: var(--primary-dark); }

/* ===== 里程碑 ===== */
.milestone-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 12px; }
.milestone-item {
  background: var(--card); border-radius: 14px; padding: 14px;
  box-shadow: 0 2px 10px rgba(74,63,53,.06); text-align: center;
}
.milestone-item .m-emoji { font-size: 30px; margin-bottom: 8px; }
.milestone-item .m-label { font-size: 14px; font-weight: 600; color: var(--text); }
.milestone-item .m-date { font-size: 12px; color: var(--text-light); margin-top: 6px; }
.milestone-item .m-note { font-size: 12px; color: var(--accent); margin-top: 4px; }

/* ===== 空状态 ===== */
.empty { text-align: center; color: var(--text-light); font-size: 14px; padding: 48px 24px; line-height: 1.8; }

/* ===== 底部 Tab ===== */
.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px;
  background: rgba(255,255,255,.96); backdrop-filter: blur(10px);
  display: flex; border-top: 1px solid var(--border); padding: 8px 0 12px;
}
.tab-item {
  flex: 1; text-align: center; font-size: 12px; color: var(--text-light);
  cursor: pointer; padding: 4px 0; transition: color .15s;
}
.tab-item .tab-icon { font-size: 20px; }
.tab-item.active { color: var(--primary-dark); font-weight: 600; }

/* ===== 弹窗 ===== */
.modal {
  position: fixed; inset: 0; background: rgba(74,63,53,.4);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal-box {
  width: 300px; background: #fff; border-radius: 18px; padding: 20px;
  box-shadow: 0 8px 30px rgba(0,0,0,.2);
}
.modal-box h3 { font-size: 17px; margin-bottom: 14px; text-align: center; }
.person-row {
  display: flex; align-items: center; gap: 10px; padding: 10px;
  border-radius: 10px; cursor: pointer; margin-bottom: 6px;
}
.person-row:hover { background: #fff5eb; }
.person-row .p-avatar { font-size: 22px; }
.person-row .p-name { font-size: 15px; }
.person-row .p-date { font-size: 12px; color: var(--text-light); }
.btn-ghost {
  width: 100%; padding: 10px; border: 1.5px dashed var(--border);
  border-radius: 10px; background: transparent; color: var(--primary-dark);
  font-size: 14px; cursor: pointer; margin-top: 6px;
}
.btn-close {
  width: 100%; padding: 10px; border: none; border-radius: 10px;
  background: #f5efe8; color: var(--text); font-size: 14px; cursor: pointer; margin-top: 8px;
}
.btn-logout { color: #c05a5a; }

/* 加载动画 */
@keyframes spin { to { transform: rotate(360deg); } }
.loading { display: inline-block; width: 14px; height: 14px; border: 2px solid #fff; border-top-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; vertical-align: middle; margin-right: 6px; }
