/* =========================================================================
   base.css — reset + 排版 + 通用组件（手账风）
   依赖 tokens.css 的 CSS 变量
   ========================================================================= */
*, *::before, *::after { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--ff-body);
  background-color: var(--bg);
  color: var(--ink);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  /* 给底部 tab 留空间 */
  padding-bottom: calc(84px + env(safe-area-inset-bottom));
  /* R3 移动端：vh 在 iOS Safari 地址栏伸缩时取最大值致底部 tabbar 多滚；用 dvh，vh 作 fallback。
     overflow-x 兜底防长无空格 URL 撑出横向滚动（与 pre-wrap overflow-wrap:anywhere 配合）。 */
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
}

h1, h2, h3, p, ul, ol { margin: 0; }
ul, ol { padding-left: 0; list-style: none; }

a { color: var(--m); text-decoration: none; }

/* —— 顶部标题区 —— */
.app-header {
  text-align: center;
  padding: var(--s-6) var(--s-4) var(--s-4);
}
.app-header h1 {
  font-family: var(--ff-title);
  font-size: 28px;
  font-weight: 650;
  color: var(--ink);
  letter-spacing: 0;
}
.app-header p { color: var(--muted); font-size: 13px; margin-top: var(--s-1); }

/* —— 头像 / 设置入口（右上角） —— */
.avatar {
  position: absolute; top: var(--s-4); right: var(--s-4);
  width: 34px; height: 34px; border-radius: var(--r-pill);
  background: var(--card); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; cursor: pointer; box-shadow: var(--sh-paper); padding: 0;
}
/* 移动端 tap target：avatar 本体放大到 44×44（无障碍最小标准），并留出更大点击区。
   用伪元素扩展触控范围而不撑大视觉，避免和状态条/标题挤撞。 */
.avatar::before {
  content: ""; position: absolute; inset: -6px; border-radius: var(--r-pill);
}
.avatar .dot { width: 10px; height: 10px; border-radius: var(--r-pill); }
.avatar .dot.male { background: var(--m); }
.avatar .dot.female { background: var(--f); }

/* —— 主内容容器 —— */
.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 var(--s-4); }
.view { display: none; }
.view.active { display: block; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* —— 页面工具栏 / 空状态 —— */
.view-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-4);
  margin-bottom: var(--s-5); padding-bottom: var(--s-3); border-bottom: 1px solid var(--line);
}
.view-toolbar.compact { margin-bottom: var(--s-4); }
.view-toolbar > div { min-width: 0; display: flex; flex-direction: column; }
.view-toolbar strong { font-size: 16px; font-weight: 650; }
.view-toolbar span { color: var(--muted); font-size: 12px; }
.toolbar-action {
  flex: none; border: 1px solid var(--m); background: var(--m); color: #fff;
  min-height: 38px; padding: 7px 14px; border-radius: var(--r-pill);
  font: 13px var(--ff-body); cursor: pointer;
}
.empty-state {
  min-height: 260px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: var(--s-7) var(--s-4); color: var(--muted);
}
.empty-state .empty-symbol { font-size: 34px; margin-bottom: var(--s-3); filter: saturate(.75); }
.empty-state strong { color: var(--ink); font-size: 16px; margin-bottom: var(--s-1); }
.empty-state p { max-width: 320px; font-size: 13px; margin-bottom: var(--s-4); }

/* —— 通用卡片 —— */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--s-5) var(--s-5);
  box-shadow: var(--sh-card);
  margin-bottom: var(--s-4);
  transition: transform var(--dur-card) var(--ease-out), box-shadow var(--dur-card) var(--ease-out), border-color var(--dur-card) var(--ease-out);
}
.card:hover { transform: translateY(-2px) scale(1.01); box-shadow: var(--sh-lift); }
.card:active { transform: translateY(0); }

/* —— 天数计时（首页视觉中心） —— */
.days-card { text-align: center; padding: var(--s-7) var(--s-5); }
.days-card .num {
  font-family: var(--ff-title);
  font-size: 64px; line-height: 1; color: var(--ink);
}
.days-card .label { color: var(--muted); font-size: 14px; margin-top: var(--s-2); }

/* —— 首页关系概览 —— */
.home-hero {
  margin: 0 calc(0px - var(--s-4)) var(--s-5);
  padding: var(--s-6) var(--s-5) var(--s-7);
  background: var(--card-2); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.home-hero-top { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-4); }
.home-eyebrow { display: block; color: var(--faint); font: 10px var(--ff-mono); }
.home-hero h2 { font-family: var(--ff-title); font-size: 22px; font-weight: 400; margin-top: 2px; }
.icon-action {
  width: 36px; height: 36px; flex: none; border: 1px solid var(--line); border-radius: var(--r-pill);
  background: var(--card); color: var(--muted); cursor: pointer; font-size: 17px;
}
.days-display { display: flex; align-items: flex-end; justify-content: center; gap: var(--s-2); margin-top: var(--s-4); }
.days-display strong { font-family: var(--ff-title); font-size: 72px; font-weight: 400; line-height: .95; }
.days-display span { color: var(--muted); font-size: 15px; margin-bottom: 8px; }
.days-caption { text-align: center; color: var(--ink); font-size: 14px; margin-top: var(--s-3); }
.relationship-since { display: block; text-align: center; color: var(--faint); font: 11px var(--ff-mono); margin-top: var(--s-1); }
.home-setup { text-align: center; padding: var(--s-6) 0 var(--s-2); }
.home-setup strong { display: block; font-size: 20px; margin-bottom: var(--s-1); }
.home-setup p { color: var(--muted); font-size: 13px; margin: 0 auto var(--s-4); max-width: 340px; }

.home-quick-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s-2); margin-bottom: var(--s-6); }
/* R3 F3: 首页总量统计四 tile——纯展示聚合，默认 4 列，移动端 2 列 */
.home-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s-2); margin-bottom: var(--s-6); }
.home-stat {
  min-width: 0; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--card);
  color: var(--ink); padding: var(--s-3) var(--s-2); cursor: pointer; font-family: var(--ff-body);
  text-align: center; display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.home-stat strong { font-family: var(--ff-title); font-size: 24px; font-weight: 650; line-height: 1.1; }
.home-stat small { color: var(--muted); font-size: 11px; }
.home-quick-actions button {
  min-width: 0; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--card);
  color: var(--ink); padding: var(--s-3); cursor: pointer; font-family: var(--ff-body); text-align: left;
  display: grid; grid-template-columns: 24px 1fr; column-gap: var(--s-2); align-items: center;
}
.home-quick-actions button > span { grid-row: 1 / 3; color: var(--m); font-size: 20px; text-align: center; }
.home-quick-actions strong { font-size: 13px; white-space: nowrap; }
.home-quick-actions small { color: var(--faint); font-size: 10px; white-space: nowrap; }
.home-milestone { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) 0; border-bottom: 1px solid var(--line); }
.home-milestone > span { color: var(--muted); font-size: 12px; }
.home-milestone strong { font-size: 14px; }
.home-milestone em { margin-left: auto; color: var(--f); font-family: var(--ff-title); font-size: 18px; font-style: normal; }
/* R3 F1: 纪念日管理入口——小字号 ghost 链接 */
.home-milestone-manage {
  flex: none; border: 1px solid var(--line); background: var(--card); cursor: pointer;
  font-family: var(--ff-body); font-size: 12px; color: var(--muted);
  padding: 4px 12px; border-radius: var(--r-pill); transition: border-color .16s, color .16s, background .16s;
}
.home-milestone-manage:hover { border-color: var(--m); color: var(--m); background: var(--m-soft); }
/* R3-issue5: 首页纪念日区块的空状态——em 作为轻提示，弱化倒计时强色 */
.home-milestone-empty em { color: var(--faint); font-size: 13px; font-family: var(--ff-body); }
.home-section { margin: var(--s-6) 0; }
.home-section-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-3); }
.home-section-head h2 { font-size: 15px; font-weight: 650; }
.home-section-head > span { color: var(--faint); font-size: 11px; }
.home-attention { border-top: 1px solid var(--line); }
.home-task {
  width: 100%; min-height: 62px; display: grid; grid-template-columns: 36px 1fr 20px; align-items: center; gap: var(--s-3);
  background: transparent; border: 0; border-bottom: 1px solid var(--line); color: var(--ink);
  padding: var(--s-3) 0; text-align: left; font-family: var(--ff-body); cursor: pointer;
}
.home-task-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: var(--r-pill); background: var(--card-2); color: var(--m); }
.home-task > span:nth-child(2) { min-width: 0; display: flex; flex-direction: column; }
.home-task strong { font-size: 13px; }
.home-task small { color: var(--muted); font-size: 11px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.home-task-arrow { color: var(--faint); }
.home-all-clear { min-height: 70px; display: flex; align-items: center; gap: var(--s-3); border-bottom: 1px solid var(--line); }
.home-all-clear > span { width: 34px; height: 34px; display: grid; place-items: center; border-radius: var(--r-pill); background: var(--ok-bg); color: var(--ok); }
.home-all-clear div { display: flex; flex-direction: column; }
.home-all-clear strong { font-size: 13px; }
.home-all-clear small { color: var(--muted); font-size: 11px; }
.home-memory {
  width: 100%; display: grid; grid-template-columns: 70px 1fr 20px; align-items: center; gap: var(--s-3);
  border: 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  background: transparent; color: var(--ink); padding: var(--s-4) 0; text-align: left; font-family: var(--ff-body); cursor: pointer;
}
.home-memory-date { color: var(--m); font: 12px var(--ff-mono); }
.home-memory > span:nth-child(2) { min-width: 0; display: flex; flex-direction: column; }
.home-memory strong { font-size: 14px; }
.home-memory small { color: var(--muted); font-size: 12px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

@media (max-width: 420px) {
  .home-quick-actions button { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 2px; padding: var(--s-3) var(--s-1); }
  .home-quick-actions button > span { font-size: 18px; }
  .home-quick-actions small { display: none; }
  .home-stats { grid-template-columns: repeat(2, 1fr); }
}

/* —— 小标题 —— */
.section-title {
  font-size: 15px; color: var(--muted); margin: var(--s-5) var(--s-2) var(--s-3);
  display: flex; align-items: center; gap: var(--s-2);
}
.section-title::before { content: ""; width: 14px; height: 2px; background: var(--tape); }

/* —— 沟通簿状态条（首页情绪平衡） —— */
.status-strip {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3) var(--s-4); border-radius: var(--r-md);
  background: var(--card-2); font-size: 14px; color: var(--ink);
  width: 100%; border: 0; font-family: var(--ff-body); text-align: left;
  margin-bottom: var(--s-2);
}
.status-strip.urgent {
  background: var(--m-soft); cursor: pointer;
}
.status-strip.status-link { cursor: pointer; }
.status-strip .chev { margin-left: auto; color: var(--faint); }

/* —— 沟通簿列表 —— */
.filters {
  display: flex; gap: var(--s-2); overflow-x: auto; flex-wrap: nowrap;
  padding: var(--s-2) 0 var(--s-4); -webkit-overflow-scrolling: touch;
}
.filters button {
  border: 1px solid var(--line); background: var(--card);
  padding: 6px 14px; border-radius: var(--r-pill); cursor: pointer;
  font-size: 13px; color: var(--ink); white-space: nowrap;
  font-family: var(--ff-body); transition: transform .12s, background .12s;
}
.filters button:hover { border-color: var(--m); }
.filters button.active {
  background: var(--m); color: #fff; border-color: var(--m);
  transform: rotate(-1deg);
}

/* —— 单条沟通簿卡片 —— */
.entry {
  position: relative; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: var(--s-5) var(--s-5) var(--s-4);
  margin-bottom: var(--s-4); box-shadow: var(--sh-card);
  transition: transform var(--dur-card) var(--ease-out), box-shadow var(--dur-card) var(--ease-out), border-color var(--dur-card) var(--ease-out);
}
.entry:hover { transform: translateY(-2px) scale(1.01); box-shadow: var(--sh-lift); }
.entry:active { transform: translateY(0); }
.entry::before {  /* 顶部和纸胶带 */
  content: ""; position: absolute; top: -8px; left: 50%;
  transform: translateX(-50%) rotate(-2deg);
  width: 72px; height: 18px; background: var(--tape);
  border-radius: 2px; box-shadow: 0 1px 1px var(--tape-edge);
}

.entry-head { display: flex; align-items: baseline; gap: var(--s-2); flex-wrap: wrap; margin-bottom: var(--s-3); }
.entry-id { font-family: var(--ff-mono); font-size: 12px; color: var(--faint); }
.entry-title { font-size: 17px; font-weight: 600; }
.entry-date { font-size: 12px; color: var(--muted); }
.entry-who { font-size: 12px; padding: 2px 10px; border-radius: var(--r-pill); color: #fff; }
.entry-who.male { background: var(--m); }
.entry-who.female { background: var(--f); }

/* —— 状态贴纸戳（右上角微旋） —— */
.status {
  position: absolute; top: 10px; right: 12px; transform: rotate(6deg);
  padding: 4px 12px; font-size: 11px; font-weight: 700;
  border: 2px solid currentColor; border-radius: var(--r-chip);
  box-shadow: var(--sh-paper); font-family: var(--ff-body);
}
.status.待沟通 { color: var(--pend-ink); background: var(--pend-bg); }
.status.沟通中 { color: var(--talk-ink); background: var(--talk-bg); }
.status.待确认 { color: var(--review-ink); background: var(--review-bg); }
.status.已和解 { color: var(--ok-ink); background: var(--ok-bg); }
.status.已搁置 { color: var(--hold-ink); background: var(--hold-bg); }

/* —— 双栏视角便签 —— */
.views { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3); margin-top: var(--s-2); }
.view-note {
  border-radius: var(--r-md); padding: var(--s-3) var(--s-4);
  border: var(--line-dashed); font-size: 14px;
}
.view-note.m { background: var(--m-soft); transform: rotate(var(--rot-m)); }
.view-note.f { background: var(--f-soft); transform: rotate(var(--rot-f)); }
.view-note .vlabel { font-size: 11px; font-weight: 700; margin-bottom: var(--s-2); display: block; }
.view-note.m .vlabel { color: var(--m); }
.view-note.f .vlabel { color: var(--f); }
.view-note .vtext { white-space: pre-wrap; word-break: break-word; opacity: .92; line-height: 1.75; font-weight: 400; }
.view-note .vempty { color: var(--faint); font-style: italic; font-size: 13px; }

@media (max-width: 640px) {
  .views { grid-template-columns: 1fr; }
  .view-note.m, .view-note.f { transform: none; }
}

/* —— 结果区（agreement / notes / 确认） —— */
.result {
  margin-top: var(--s-4); padding: var(--s-4) var(--s-5);
  background: var(--card-2); border-radius: var(--r-md);
  position: relative;
}
.result .rlabel { font-size: 11px; font-weight: 700; color: var(--muted); margin-bottom: var(--s-1); display: block; }
.result .rtext { font-family: var(--ff-serif); white-space: pre-wrap; overflow-wrap: anywhere; color: var(--ink); }
.result .rsub { margin-top: var(--s-3); }
.result .rsub .rlabel { font-size: 11px; }
.result .rsub .rtext { font-family: var(--ff-body); font-size: 13px; color: var(--muted); }
.result .ph { color: var(--faint); font-size: 13px; font-style: italic; }

/* 确认状态行 */
.confirms {
  margin-top: var(--s-4); display: flex; flex-direction: column; gap: var(--s-2);
}
.confirm-row {
  display: flex; align-items: center; gap: var(--s-2); font-size: 13px;
  padding: var(--s-2) var(--s-3); border-radius: var(--r-sm); background: var(--card);
}
.confirm-row.m { border-left: 3px solid var(--m); }
.confirm-row.f { border-left: 3px solid var(--f); }
.confirm-row .who { font-weight: 600; }
.confirm-row.done { color: var(--ok); }
.confirm-row.done .ck::before { content: "✓ "; }
.confirm-row.pending .ck::before { content: "○ "; color: var(--faint); }
.confirm-row .at { margin-left: auto; font-size: 12px; color: var(--faint); font-family: var(--ff-mono); }

/* 和解印章 */
.seal {
  position: absolute; bottom: -6px; right: 14px;
  width: 64px; height: 64px; border-radius: var(--r-pill);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--ff-title); font-size: 18px; color: var(--ok);
  border: 2.5px solid var(--ok); transform: rotate(-12deg) scale(1.05);
  opacity: .85; background: rgba(255,255,255,.4);
}
.seal.placeholder { color: var(--faint); border-style: dashed; opacity: .5; font-size: 14px; }

/* FAB 右下角加号 */
.fab {
  position: fixed; right: 20px; bottom: calc(96px + env(safe-area-inset-bottom)); z-index: 50;
  width: 52px; height: 52px; border-radius: var(--r-pill);
  background: var(--m); color: #fff; border: none; font-size: 26px;
  box-shadow: var(--sh-sticky); cursor: pointer; line-height: 1;
}

/* —— 空状态 / 占位 —— */
.empty, .placeholder-card {
  text-align: center; color: var(--muted); padding: var(--s-7) var(--s-4);
  font-size: 14px;
}
.placeholder-card {
  background: var(--card-2); border: 1px dashed var(--line);
  border-radius: var(--r-md); margin-bottom: var(--s-4);
  transform: rotate(-.3deg);
}

/* —— 底部 tab —— */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 60;
  display: flex; background: var(--glass-bg); border-top: 1px solid var(--line);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  max-width: var(--wrap); margin: 0 auto;
  box-shadow: 0 -2px 12px rgba(15, 23, 42, .05);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar button {
  flex: 1; background: none; border: none; cursor: pointer;
  padding: var(--s-3) 0 var(--s-2); color: var(--muted);
  font-family: var(--ff-body); font-size: 11px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.tabbar button .ico { font-size: 18px; }
.tabbar button.active { color: var(--m); }
.tabbar button.active .ico { transform: translateY(-1px) scale(1.08); }

footer.app-foot { text-align: center; color: var(--faint); font-size: 12px; padding: var(--s-5) 0; }

.home-card-link {
  width: 100%; color: inherit; font-family: var(--ff-body); text-align: left; cursor: pointer;
}

/* —— 时间线 —— */
.tl-list { position: relative; padding-left: var(--s-3); margin-top: var(--s-3); }
.tl-list::before {
  content: ""; position: absolute; left: 5px; top: 6px; bottom: 6px;
  width: 0; border-left: var(--line-dashed);
}
.tl-item { position: relative; padding: 0 0 var(--s-6) var(--s-5); }
.tl-dot {
  position: absolute; left: -6px; top: 4px; width: 12px; height: 12px;
  border-radius: var(--r-pill); background: var(--tape);
  border: 2px solid var(--card); box-shadow: var(--sh-paper);
}
.tl-date { font-size: 12px; color: var(--m); font-family: var(--ff-mono); }
.tl-title { font-size: 16px; font-weight: 650; margin: var(--s-1) 0; }
.tl-desc { font-size: 14px; color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; }
.tl-by { margin-top: var(--s-2); font-size: 11px; color: var(--faint); }

/* —— 留言 —— */
.msg { position: relative; border-left: 3px solid var(--f); }
.msg.mine { border-left-color: var(--m); }
.msg-meta { display: flex; align-items: center; gap: var(--s-2); font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.msg-from { font-weight: 700; color: var(--ink); }
.msg-to { color: var(--f); font-weight: 600; }
.msg-arrow { color: var(--faint); }
.msg-mood { background: var(--card-2); padding: 1px 8px; border-radius: var(--r-pill); }
.msg-pin { color: var(--review-ink); background: var(--review-bg); padding: 1px 7px; border-radius: var(--r-pill); }
/* R4 F4: 置顶切换按钮——小字号 ghost 胶囊，与纪念日管理入口同家族风格 */
.msg-pin-btn {
  flex: none; border: 1px solid var(--line); background: var(--card); cursor: pointer;
  font: 12px var(--ff-body); color: var(--muted);
  padding: 2px 10px; border-radius: var(--r-pill); transition: border-color .16s, color .16s, background .16s;
}
.msg-pin-btn:hover { border-color: var(--review); color: var(--review-ink); background: var(--review-bg); }
.msg-date { margin-left: auto; font-family: var(--ff-mono); }
/* R5-s2: 置顶留言视觉浮起——统一 review 色背景/边色 + sticky 投影，与 .msg-pin 标签同族。
   删 .msg.mine.pinned 覆盖：mine 侧置顶前 border-color 已是 var(--m)，旧规则置顶后仍 var(--m)
   毫无差异；改 review 色后 mine/theirs 置顶都浮起明显。叠加 .unread 时其 box-shadow 优先级更高
   会盖掉 sticky 投影，但 background 仍在不被覆盖，置顶态视觉不丢失。 */
.msg.pinned { border-color: var(--review); background: var(--review-bg); box-shadow: var(--sh-sticky); }
.msg-text { margin-top: var(--s-3); font-family: var(--ff-serif); font-size: 16px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.8; }
/* R2-4: 未读留言视觉——对方发给本侧且未读时，左侧主色描边 + 正文加粗 + 小圆点角标 */
.msg.unread { border-left-color: var(--f); box-shadow: 0 0 0 1px var(--f-soft) inset, var(--sh-paper); }
.msg.unread .msg-from { font-weight: 700; }
.msg.unread .msg-text { font-weight: 600; }
.msg-unread-dot { display: inline-block; width: 7px; height: 7px; border-radius: var(--r-pill); background: var(--f); flex: none; }

/* —— 照片墙 polaroid —— */
.wall { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: var(--s-4); padding: var(--s-3) 0; }
.polaroid {
  border: 0; color: var(--ink); font-family: var(--ff-body); cursor: pointer;
  background: #fff; padding: 8px 8px 6px; box-shadow: var(--sh-card);
  transition: transform var(--dur-card) var(--ease-out), box-shadow var(--dur-card) var(--ease-out), border-color var(--dur-card) var(--ease-out);
}
.polaroid:hover { transform: translateY(-4px) scale(1.03); box-shadow: var(--sh-sticky); }
.polaroid:active { transform: scale(.99); }
.polaroid img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: var(--card-2); }
.polaroid .cap { display: block; font-family: var(--ff-title); text-align: center; padding: 7px 0 2px; font-size: 13px; color: var(--ink); }
.polaroid time { display: block; text-align: center; color: var(--faint); font-size: 10px; }

/* 照片查看器遮罩：比 .modal-mask 略深 + 更强毛玻璃，让照片浮出；用复合选择器
   盖过同文件靠后的 .modal-mask 兜底（该元素同时挂 modal-mask photo-viewer-mask）。 */
.modal-mask.photo-viewer-mask {
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.photo-viewer {
  position: relative; max-width: min(94vw, 1400px); padding: 0; overflow: hidden;
  background: #111; border-radius: var(--r-md);
}
.photo-viewer > img { display: block; width: 100%; max-height: 78vh; object-fit: contain; }
.photo-viewer-close {
  position: absolute; z-index: 2; top: 10px; right: 10px; width: 40px; height: 40px;
  border: 0 !important; border-radius: var(--r-pill) !important; background: rgba(0,0,0,.5) !important;
  color: #fff; font-size: 22px !important; padding: 0 !important;
}
.photo-viewer-caption { display: flex; justify-content: space-between; gap: var(--s-3); padding: var(--s-3) var(--s-4); color: #fff; }
.photo-viewer-caption time { color: rgba(255,255,255,.65); font-size: 12px; }
/* R3 F5: 照片查看器左右切换按钮，复用 close 的半透明圆形样式 */
.photo-viewer-nav {
  position: absolute; z-index: 2; top: 50%; transform: translateY(-50%);
  width: 44px; height: 44px; border: 0; border-radius: var(--r-pill);
  background: rgba(0,0,0,.45); color: #fff; font-size: 28px; line-height: 1;
  cursor: pointer; display: grid; place-items: center; padding: 0;
  transition: background .16s;
}
.photo-viewer-nav.prev { left: 12px; }
.photo-viewer-nav.next { right: 12px; }
.photo-viewer-nav:hover { background: rgba(0,0,0,.7); }
/* R3-issue4: 照片元数据损坏/原图丢失占位——灰底 + 替代文案，避免破图标 */
.photo-broken {
  background: var(--card-2);
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font: 13px var(--ff-body); text-align: center;
  min-height: 200px; width: 100%;
}
.photo-viewer .photo-broken { color: rgba(255,255,255,.6); background: transparent; min-height: 60vh; }
@media (max-width: 480px) {
  .photo-viewer-nav { width: 40px; height: 40px; font-size: 24px; }
}

/* —— T3 子 tab —— */
.subtabs { display: flex; gap: var(--s-2); margin-bottom: var(--s-4); }
.subtabs button {
  border: none; background: none; cursor: pointer; font-family: var(--ff-body);
  font-size: 14px; color: var(--muted); padding: var(--s-1) var(--s-3);
  border-bottom: 2px solid transparent;
}
.subtabs button.active { color: var(--m); border-color: var(--m); }

/* —— 全屏提示 modal（静态版写操作引导） —— */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: var(--s-4);
}
.modal {
  background: var(--card); border-radius: var(--r-lg); padding: var(--s-6);
  max-width: 460px; width: 100%; box-shadow: var(--sh-panel);
  font-size: 14px; line-height: 1.7;
  max-height: calc(100dvh - 32px); overflow-y: auto; overscroll-behavior: contain;
}
.modal h3 { font-family: var(--ff-title); font-size: 20px; margin-bottom: var(--s-3); font-weight: 400; }
.modal pre {
  background: var(--card-2); padding: var(--s-3); border-radius: var(--r-sm);
  font-family: var(--ff-mono); font-size: 12px; overflow-x: auto; white-space: pre-wrap;
  max-height: 220px; overflow-y: auto; color: var(--ink);
}
.modal .btns { display: flex; gap: var(--s-2); margin-top: var(--s-4); justify-content: flex-end; }
.modal button {
  border: 1px solid var(--line); background: var(--card); padding: 8px 16px;
  border-radius: var(--r-pill); cursor: pointer; font-family: var(--ff-body); font-size: 13px;
}
.modal button.primary { background: var(--m); color: #fff; border-color: var(--m); }

body.modal-open { overflow: hidden; }

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
[role="button"]:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--m);
  outline-offset: 2px;
}

@media (max-width: 480px) {
  .modal-mask { align-items: flex-end; padding: var(--s-2); }
  .modal { padding: var(--s-5); max-height: calc(100dvh - 16px); }
  .modal .btns { flex-wrap: wrap; }
  .view-toolbar { align-items: flex-end; }
  .toolbar-action { min-height: 40px; }
  .wall { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-3); }
  .photo-viewer { padding: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* —— 视觉统一层 —— */
body {
  text-rendering: optimizeLegibility;
  background-attachment: fixed;
  background-size: 100% 100%;
}

button { -webkit-tap-highlight-color: transparent; }

.app-header {
  position: relative;
  max-width: var(--wrap);
  min-height: 94px;
  margin: 0 auto;
  padding: 25px 52px 18px;
}
.app-header h1 { font-size: 27px; font-weight: 600; letter-spacing: 0; line-height: 1.25; }
.app-header p { margin-top: 5px; line-height: 1.4; }
.avatar {
  top: 24px; right: var(--s-4); width: 38px; height: 38px;
  transition: border-color .16s, background .16s, transform .16s;
}
.avatar:hover { border-color: var(--m); background: var(--m-soft); }
.avatar:active { transform: scale(.96); }

.view-toolbar { margin-bottom: var(--s-5); padding-bottom: var(--s-4); }
.view-toolbar strong { font-size: 17px; letter-spacing: 0; }
.toolbar-action {
  border-radius: var(--r-md); min-height: 40px; font-weight: 650;
  box-shadow: var(--sh-accent);
  transition: filter .16s, transform .16s, box-shadow .16s;
}
.toolbar-action:hover { filter: brightness(.96); transform: translateY(-1px); box-shadow: var(--sh-accent-strong); }
.toolbar-action:active { transform: translateY(0); box-shadow: var(--sh-paper); }

.card { border-radius: var(--r-md); box-shadow: var(--sh-paper); }

.home-hero {
  padding: var(--s-6) var(--s-5) var(--s-7);
  background: var(--card);
  border-color: var(--line);
  box-shadow: inset 4px 0 0 var(--m);
}
.home-eyebrow { color: var(--m); font-weight: 700; letter-spacing: 0; }
.home-hero h2 { font-size: 23px; font-weight: 600; letter-spacing: 0; }
.icon-action { transition: border-color .16s, color .16s, background .16s, transform .16s; }
.icon-action:hover { border-color: var(--m); color: var(--m); background: var(--m-soft); }
.icon-action:active { transform: scale(.95); }
.days-display { margin-top: var(--s-5); }
.days-display strong { color: var(--m); font-size: 70px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: 0; }
.days-caption { font-weight: 650; }
.relationship-since { letter-spacing: 0; }

.home-quick-actions { gap: var(--s-3); }
.home-quick-actions button {
  min-height: 66px; border-radius: var(--r-md); box-shadow: var(--sh-paper);
  transition: border-color var(--dur-card) var(--ease-out), background var(--dur-card) var(--ease-out), transform var(--dur-card) var(--ease-out), box-shadow var(--dur-card) var(--ease-out);
}
.home-quick-actions button:nth-child(2) > span { color: var(--f); }
.home-quick-actions button:nth-child(3) > span { color: var(--ok); }
.home-quick-actions button:hover { border-color: var(--m); background: var(--m-soft); transform: translateY(-2px) scale(1.02); box-shadow: var(--sh-lift); }
.home-quick-actions button:active { transform: translateY(0); }
.home-quick-actions strong { font-weight: 700; }
.home-stat { min-height: 62px; box-shadow: var(--sh-paper); transition: border-color var(--dur-card) var(--ease-out), background var(--dur-card) var(--ease-out), transform var(--dur-card) var(--ease-out), box-shadow var(--dur-card) var(--ease-out); }
.home-stat:hover { border-color: var(--m); background: var(--m-soft); transform: translateY(-2px) scale(1.02); box-shadow: var(--sh-lift); }
.home-stat:active { transform: translateY(0); }
.home-milestone { border-top: 1px solid var(--line); padding: var(--s-4) 0; }
.home-milestone em { color: var(--f); font-weight: 600; letter-spacing: 0; }
.home-section-head h2 { font-size: 16px; }
.home-task, .home-memory { transition: background .16s, padding .16s; }
.home-task:hover, .home-memory:hover { background: var(--card); padding-left: var(--s-3); padding-right: var(--s-3); }
.home-task-icon { border-radius: var(--r-md); }

.filters { gap: var(--s-2); scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.filters button { min-height: 34px; transition: border-color .16s, background .16s, color .16s; }
.filters button.active { transform: none; box-shadow: var(--sh-accent); }

.fab {
  width: 54px; height: 54px; font-size: 25px;
  box-shadow: var(--sh-accent-strong);
  transition: filter .16s, transform .16s, box-shadow .16s;
}
.fab:hover { filter: brightness(.96); transform: translateY(-2px); box-shadow: var(--sh-accent-strong); }
.fab:active { transform: scale(.96); }

.tabbar {
  min-height: 68px;
  box-shadow: 0 -8px 28px rgba(15, 23, 42, .06);
}
.tabbar button { min-width: 0; padding: 9px 0 7px; gap: 3px; transition: color .16s, background .16s; }
.tabbar button .ico {
  width: 32px; height: 27px; display: grid; place-items: center;
  border-radius: var(--r-md); transition: background .16s, transform .16s;
}
.tabbar button:hover { background: var(--card-2); }
.tabbar button.active { font-weight: 700; }
.tabbar button.active .ico { background: var(--m-soft); }

.tl-list::before { border-left-style: solid; }
.tl-dot { background: var(--m); box-shadow: 0 0 0 3px var(--m-soft); }
.tl-date, .relationship-since, .home-memory-date, .msg-date { font-variant-numeric: tabular-nums; letter-spacing: 0; }
.msg { border-left-width: 4px; box-shadow: var(--sh-paper); }
.msg-text { line-height: 1.75; }

.polaroid {
  border: 1px solid var(--line); border-radius: var(--r-sm);
  transition: transform var(--dur-card) var(--ease-out), box-shadow var(--dur-card) var(--ease-out), border-color var(--dur-card) var(--ease-out);
}
.polaroid:hover { border-color: var(--m); }
.polaroid .cap { font-weight: 600; letter-spacing: 0; }

/* 列表项 fade-up 入场：只落在不订阅轮询的列表（.tl-item 时光 / .polaroid 相册），
   进 tab 或切筛选时重建一次，3s 轮询触达不到 —— 零重放风险。
   用独立 `translate` 属性 keyframe，避开 .polaroid 的 transform:hover(scale)
   与旋转；终止态==base 态，全局 reduced-motion 块归零时长即 snap 到可见态（a11y 安全）。 */
@keyframes rise {
  from { opacity: 0; translate: 0 10px; }
  to   { opacity: 1; translate: 0 0; }
}
.tl-item, .polaroid { animation: rise 420ms cubic-bezier(0.22, 1, 0.36, 1) both; }

.modal-mask { background: rgba(15, 23, 42, .52); backdrop-filter: blur(3px); }
.modal { border: 1px solid var(--line); border-radius: var(--r-md); }
.modal h3 { font-weight: 600; letter-spacing: 0; }
.modal button { border-radius: var(--r-md); min-height: 38px; transition: border-color .16s, background .16s, transform .16s; }
.modal button:hover { border-color: var(--m); }
.modal button:active { transform: scale(.98); }
.modal .subtabs {
  width: fit-content; max-width: 100%; flex-wrap: wrap; gap: 3px;
  padding: 3px; border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--card-2);
}
.modal .subtabs button {
  min-height: 34px; padding: 5px 12px; border: 0;
  border-radius: 5px; background: transparent; color: var(--muted);
}
.modal .subtabs button.active {
  color: var(--m); background: var(--card); box-shadow: var(--sh-paper); font-weight: 650;
}

@media (max-width: 480px) {
  .app-header { min-height: 88px; padding-top: 22px; padding-bottom: 16px; }
  .avatar { top: 18px; width: 44px; height: 44px; }
  .avatar .dot { width: 12px; height: 12px; }
  .home-hero { padding-left: var(--s-4); padding-right: var(--s-4); }
  .days-display strong { font-size: 64px; }
  .tabbar button { font-size: 10px; }
}

/* —— 首次身份选择屏（轻量，非鉴权）—— */
.picker-screen {
  min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: var(--s-4);
}
.picker-card {
  max-width: 360px; width: 100%; text-align: center;
  background: var(--card); border-radius: var(--r-lg);
  padding: var(--s-6) var(--s-5);
  box-shadow: var(--sh-panel);
}
.picker-card h1 { font-family: var(--ff-title); margin-bottom: var(--s-3); }
.picker-hint { color: var(--muted); font-size: 14px; margin-bottom: var(--s-5); }
.picker-choices { display: flex; flex-direction: column; gap: var(--s-3); }
.picker-choice {
  display: flex; align-items: center; justify-content: center; gap: var(--s-2);
  padding: var(--s-4); border-radius: var(--r-md);
  border: 2px solid var(--line); background: var(--card-2);
  cursor: pointer; font-family: var(--ff-body); font-size: 16px; color: var(--ink);
  transition: border-color .12s, transform .12s;
}
.picker-choice:hover { transform: translateY(-1px); }
.picker-choice.male:hover { border-color: var(--m); }
.picker-choice.female:hover { border-color: var(--f); }
.picker-choice .dot { width: 12px; height: 12px; }
.picker-foot { color: var(--faint); font-size: 12px; margin-top: var(--s-4); }

/* —— D1 桌面宽屏断点：>=1200px 放宽 .wrap / .app-header / .tabbar 内容容器，
      消除 1440/1920 大屏左右死白（"手机拉伸到桌面"短板）。.app-header / .tabbar
      原本都引用 var(--wrap) 封顶 920px，此处一并放宽以与正文同宽，保持顶/底栏对齐。
      移动端零影响（断点 1200px 以上才触发）。—— */
@media (min-width: 1200px) {
  .wrap { max-width: var(--wrap-wide); }
  .app-header { max-width: var(--wrap-wide); }
  .tabbar { max-width: var(--wrap-wide); }
  /* D2: 大屏照片查看器抬升纵向利用率（小屏仍走 78vh，避免顶到浏览器边） */
  .photo-viewer > img { max-height: 84vh; }
}

/* —— M1 移动端状态筛选 chip：34px 低于 44px 触控最小值，也低于项目自定 40px 基线
      （editor.css 的 R3 注释已把 .seg/.mode-switch 提到 40px，却漏了同等场景的 .filters）。
      <=520px 横向滑动点选，bump 到 40px 与家族对齐。—— */
@media (max-width: 520px) {
  .filters button { min-height: 40px; padding: 8px 14px; }
}
