/* ═══════════ 基础 ═══════════ */
:root {
  --primary: #4f6ef7;
  --primary-weak: #eef2ff;
  --bg: #f5f6fa;
  --card: #ffffff;
  --text: #1a1a1a;
  --text-2: #666;
  --text-3: #999;
  --line: #ececf1;
  --danger: #e5484d;
  --ok: #18a058;
  --radius: 14px;
  --nav-h: 58px;
  --ab-h: 64px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 16px;
  overscroll-behavior-y: none;
}
button { font-family: inherit; border: none; background: none; cursor: pointer; color: inherit; }
textarea, input { font-family: inherit; }

/* ═══════════ 统一按钮组件（全站仅3种） ═══════════ */
.btn-primary {
  background: var(--primary); color: #fff; border: none;
  font-weight: 700; border-radius: 10px; padding: 7px 16px;
  font-size: 14px; cursor: pointer;
}
.btn-primary:active { transform: scale(.96); filter: brightness(.92); }
.btn-primary:disabled { opacity: .5; }
.btn-secondary {
  background: var(--card); color: var(--text-2);
  border: 1px solid var(--line); border-radius: 10px;
  font-size: 14px; padding: 7px 14px; cursor: pointer;
  transition: all .15s;
}
.btn-secondary:active { transform: scale(.96); background: var(--bg); }
.btn-icon {
  background: transparent; color: var(--text-3);
  border: 1px solid var(--line); border-radius: 8px;
  width: 28px; height: 28px; padding: 0; font-size: 14px;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; flex: none;
}
.btn-icon:active { transform: scale(.96); background: var(--primary); color: #fff; border-color: var(--primary); }

/* ═══════════ 扩展 modifier（从散落 class 收敛而来） ═══════════ */
.btn-danger { background: #fdecec; color: var(--danger); border: none; }
.btn-danger:active { transform: scale(.96); background: #f5d0d0; }
.btn-wide { flex: 1; height: 44px; font-size: 15px; font-weight: 600; border-radius: 12px; }
/* tall 变体：flex-direction column（图标在上，文字在下，用于分享页底部） */
.btn-tall { flex-direction: column; gap: 2px; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; }
.btn-tall span:first-child { font-size: 20px; }

/* ═══════════ 视图切换 ═══════════ */
.view {
  display: none;
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 100dvh;                        /* ★ dvh 随键盘弹出自动缩小 */
  flex-direction: column;
  overflow: hidden;                       /* 内部 flex 布局，不滚动 */
}
.view.active { display: flex; padding-bottom: var(--kb-inset, 0); }  /* iOS 键盘遮挡：底部元素上移 */
.flex-spacer { flex: 1; }

/* ═══════════ 顶栏 ═══════════ */
.topbar {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: calc(40px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 16px 0;
  background: var(--bg);
}
.topbar-title { font-size: 20px; font-weight: 700; }
.app-ver { font-size: 0.6em; opacity: 0.45; font-weight: 500; vertical-align: middle; }
.topbar-date { font-size: 15px; color: var(--text-2); padding: 4px 6px; border-radius: 6px; transition: opacity .12s; -webkit-tap-highlight-color: transparent; }
button.topbar-date { cursor: pointer; touch-action: manipulation; }
button.topbar-date:active { opacity: .6; }
.topbar-tools { display: flex; align-items: center; gap: 10px; }
/* 记录页：类别+已选标签胶囊栏（一行横向滚动） */
.tag-picker { position: relative; flex: none; z-index: 50; }
.tag-chips {
  display: flex; gap: 8px; padding: 4px 16px;
  overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.tag-chips::-webkit-scrollbar { display: none; }
.tag-tab {
  flex: none; font-size: 14px; padding: 9px 14px; border-radius: 999px;
  background: var(--card); color: var(--text-2); border: 1px solid var(--line);
  cursor: pointer; transition: all .15s; white-space: nowrap;
}
.tag-tab:active { transform: scale(.97); }
.tag-tab.active {
  background: var(--primary); border-color: var(--primary);
  color: #fff; font-weight: 600;
}
/* 已选标签胶囊（蓝色 + 右侧小 ✕ 清标签） */
.tag-chip-tag {
  flex: none; font-size: 13px; padding: 7px 22px 7px 14px; border-radius: 999px;
  background: var(--primary-weak, #eef2ff); color: var(--primary); border: 1px solid var(--primary);
  white-space: nowrap; position: relative; font-weight: 600;
}
.tag-chip-tag .clear {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  font-size: 11px; opacity: .7; cursor: pointer; width: 16px; height: 16px;
  border: none; background: transparent; color: var(--primary); border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.tag-chip-tag .clear:active { opacity: 1; background: rgba(79,110,247,.15); }

/* 类别标签下拉浮层 */
.tag-dropdown {
  position: absolute; left: 16px; right: 16px; top: 40px;
  display: flex; flex-wrap: wrap; gap: 8px;
  max-height: 230px; overflow-y: auto;
  padding: 12px; background: var(--card);
  border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 10px 28px rgba(0,0,0,.16);
}
.tag-dropdown[hidden] { display: none; }
.dd-item {
  flex: none; font-size: 14px; padding: 8px 14px; border-radius: 999px;
  background: var(--bg); color: var(--text-2); border: 1px solid var(--line);
  cursor: pointer; transition: all .15s;
}
.dd-item:active { transform: scale(.96); }
.dd-item.selected { background: var(--primary); border-color: var(--primary); color: #fff; }
.dd-item.add { color: var(--primary); border-style: dashed; background: transparent; }

/* 统一三页 AI 风格 select */
.ai-style-select {
  font-size: 12px; padding: 4px 6px; border-radius: 6px;
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  max-width: 96px;
}
.icon-btn { font-size: 22px; padding: 4px 8px; }

/* ═══════════ 自定义月历（有日记日期画圈） ═══════════ */
.cal-backdrop {
  position: fixed; inset: 0; z-index: 90; background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn .15s ease-out;
}
.cal-card {
  width: min(86vw, 340px); background: var(--card);
  border-radius: 18px; overflow: hidden;
  animation: calPop .18s ease-out;
}
@keyframes calPop { from { transform: scale(.92); opacity: 0; } }
.cal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 12px 4px; }
.cal-nav {
  width: 36px; height: 36px; border: none; background: transparent;
  font-size: 20px; line-height: 1; color: var(--text); border-radius: 50%;
}
.cal-nav:active { background: var(--bg); }
.cal-title { font-weight: 700; font-size: 16px; color: var(--text); }
.cal-week { display: grid; grid-template-columns: repeat(7, 1fr); padding: 4px 12px 0; }
.cal-week span { text-align: center; font-size: 12px; color: var(--text-3); padding: 6px 0; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; padding: 6px 12px 14px; }
.cal-day {
  aspect-ratio: 1; border: none; background: transparent; padding: 0;
  font-size: 15px; font-family: inherit; color: var(--text);
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
}
.cal-day.blank { visibility: hidden; }
.cal-day.today { font-weight: 700; }
/* 有日记：主色画圈 */
.cal-day.marked { color: var(--primary); font-weight: 700; box-shadow: inset 0 0 0 1.6px var(--primary); }
.cal-day:active { background: var(--primary-weak); }
/* 选中：实心填充；选中且有日记：白圈内环 + 主色外环 */
.cal-day.sel { background: var(--primary); color: #fff; font-weight: 700; }
.cal-day.sel.marked { box-shadow: inset 0 0 0 1.6px #fff, 0 0 0 2px var(--primary); }
.cal-foot { display: flex; border-top: 1px solid var(--line); }
.cal-foot button {
  flex: 1; padding: 13px 0; border: none; background: transparent;
  font-size: 15px; font-family: inherit; color: var(--primary);
}
.cal-foot button + button { border-left: 1px solid var(--line); }
.cal-foot .cal-clear { color: var(--text-3); }

/* ═══════════ 记录页 ═══════════ */
/* 统一文本框 + 语音按钮包裹层（吃剩余高度，textarea 撑满） */
.entry-input-wrap {
  position: relative; flex: 1 1 auto; display: flex;
  margin: 8px 16px 0; min-height: 140px;
}
.entry-input-wrap #entryText { flex: 1 1 auto; margin: 0; }
/* 麦克风按钮暂屏蔽（hidden）；将来启用时删除本规则并恢复上一行 padding-right:44px */
.mic-btn[hidden] { display: none; }
.mic-btn {
  position: absolute; right: 8px; top: 8px; z-index: 2;
  width: 32px; height: 32px; border: none; border-radius: 50%;
  background: var(--primary); color: #fff; font-size: 16px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.mic-btn:active { transform: scale(.94); }

/* ═══════════ 操作栏 ═══════════ */

.entry-title-input {
  flex: none; margin: 1px 16px 0; padding: 10px 14px; height: 46px; box-sizing: border-box;
  border: 1px solid var(--line); border-radius: 9px;
  background: var(--card); font-size: 17px; font-weight: 600;
  outline: none;
}
.entry-title-input:focus { border-color: var(--primary); }

#entryText {
  flex: none; margin: 8px 16px 0; padding: 14px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--card); font-size: 16px; line-height: 1.6;
  resize: none; outline: none;
}
#entryText:focus { border-color: var(--primary); }
/* 选标签后自动填入的示例模板：浅色提示，点进文本框即清空 */
#entryText.tpl-filled { color: var(--text-3, #9aa0a6); }

/* ═══════════ 记录页 textarea 自适应键盘（覆盖 #entryText 默认） ═══════════
 * 配合 Manifest 的 android:windowSoftInputMode="adjustResize"：
 *   - 键盘弹出时 WebView 高度自动缩小
 *   - textarea flex:1 吃剩余空间；actionbar+拍照按钮+Tab栏永远在键盘上方
 */
#view-record { min-height: 100dvh; }
#view-record .flex-spacer { display: none; }
#view-record #entryText {
  flex: 1 1 auto; min-height: 120px;
}

.pending-photos {
  flex: none; display: flex; gap: 10px; padding: 12px 16px 0;
  overflow-x: auto; scrollbar-width: none; touch-action: pan-y;
}
.pending-photos:empty { display: none; }
.pending-photos::-webkit-scrollbar { display: none; }
.pp-item { position: relative; flex: none; width: 84px; touch-action: pan-y; will-change: transform; }
.pp-item.dragging {
  transform: scale(1.08); opacity: .7; z-index: 10;
  box-shadow: 0 6px 18px rgba(0,0,0,.2);
  transition: transform .15s, box-shadow .15s;
}
.pp-item img { width: 84px; height: 84px; object-fit: cover; border-radius: 10px; display: block; }
.pp-del {
  position: absolute; top: -6px; right: -6px; width: 22px; height: 22px;
  border-radius: 50%; background: rgba(0,0,0,.65); color: #fff;
  font-size: 13px; line-height: 22px; text-align: center;
}
.pp-cap {
  position: absolute; bottom: 4px; right: 4px; width: 24px; height: 24px;
  border-radius: 50%; background: rgba(0,0,0,.6);
  font-size: 12px; line-height: 24px; text-align: center; padding: 0;
}
.pp-cap.has { background: var(--primary); }
.pp-captext {
  width: 84px; box-sizing: border-box; margin-top: 4px;
  border: 1px dashed var(--line); border-radius: 6px;
  padding: 3px 6px; font-size: 11px; line-height: 1.3;
  color: var(--text-3); background: var(--card);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pp-captext.has { border-style: solid; border-color: rgba(79,110,247,.35); color: var(--text-2); }

/* ═══════════ 底部操作栏 ═══════════ */
.actionbar {
  flex: none; display: flex; gap: 10px;
  padding: 10px 16px calc(env(safe-area-inset-bottom) + 12px);
  background: var(--bg);
}
/* REQ-010: 拍照入口列 + 小字提示 */
/* REQ-001: 汇总页已选择计数 */
.ai-count { font-size: 12px; color: var(--text-2); flex: none; white-space: nowrap; margin-right: auto; }
/* ═══════════ 时间线 ═══════════ */
.timeline { flex: 1; overflow-y: auto; padding: 0 16px 20px; }
.tl-card {
  position: relative; overflow: hidden;
  background: var(--card); border-radius: 12px;
  margin-bottom: 10px; box-shadow: 0 2px 8px rgba(0,0,0,.06);
}
.tl-day-start { margin-top: 14px; }
/* 首组紧贴搜索框：搜索框底→日期标签 = 8px，与分享页搜索框→首卡一致 */
.timeline > .tl-day-start:first-child { margin-top: 0; }
.tl-day-start::before {
  content: attr(data-day);
  display: block; font-size: 11px; font-weight: 600; color: var(--text-3);
  padding: 0 0 4px; letter-spacing: .3px;
}
.tl-card-inner {
  position: relative; z-index: 2;
  background: var(--card); border-radius: var(--radius);
  padding: 12px 14px;
  transition: transform .2s ease;
  touch-action: pan-y;
}
.tl-card.open .tl-card-inner { transform: translateX(-80px); }
.tl-swipe-del {
  position: absolute; right: 0; top: 0; bottom: 0; width: 80px;
  background: var(--danger); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 700; z-index: 1;
  border-radius: 0 12px 12px 0;
  cursor: pointer;
  opacity: 0; transition: opacity .15s;
}
.tl-card.open .tl-swipe-del { opacity: 1; }
.tl-swipe-del:active { background: #d13f44; }
.tl-time { font-weight: 700; font-variant-numeric: tabular-nums; }
.tl-tag {
  font-size: 12px; padding: 2px 9px; border-radius: 999px;
  background: var(--primary-weak); color: var(--primary);
}
.tl-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tl-head-info { display: flex; align-items: center; gap: 8px; min-width: 0; flex-wrap: wrap; }
.tl-head-actions { display: flex; align-items: center; gap: 6px; flex: none; }
.tl-head-actions .btn-icon { width: 26px; height: 26px; font-size: 13px; }
/* 头部 AI 五态按钮与「改」同高（覆盖 .m-ai-btn 的 32px） */
.tl-head-actions .tl-card-ai { height: 26px; min-width: 38px; padding: 0 7px; border-radius: 7px; }
.tl-sent { font-size: 12px; color: var(--ok); display: inline-flex; align-items: center; gap: 4px; }
.st-sent { font-size: 11px; color: var(--ok); font-weight: 700; display: inline-flex; align-items: center; gap: 3px; }
/* 已发状态绿色小圆点 */
.sent-dot {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--ok); flex: none;
}
/* hook classes — styling via .btn-icon base + compound overrides */
.si-edit.btn-icon { margin-left: auto; width: 28px; height: 24px; border-radius: 6px; font-size: 13px; }
/* REQ-003: 删除 X 触摸热区扩大 44px（视觉仍 28px）*/
.tl-del.btn-icon.btn-danger {
  margin-left: auto; border-radius: 50%; border: none; background: transparent;
  color: var(--danger); position: relative; width: 28px; height: 28px; z-index: 3;
}
.tl-del.btn-icon.btn-danger::before {
  content: ''; position: absolute; top: -8px; right: -8px; bottom: -8px; left: -8px;
}
.tl-del.btn-icon.btn-danger:active { background: rgba(229,72,77,.12); transform: scale(1.15); }
.tl-title { font-size: 15px; font-weight: 700; color: var(--primary); margin: 6px 0 2px; line-height: 1.4; }
.tl-expect { font-size: 14px; color: #8a6d3b; margin: 2px 0; line-height: 1.5; }
.tl-kind { font-size: 15px; font-weight: 700; margin: 6px 0 2px; line-height: 1.4; }
.tl-kind-gain { color: #2e7d32; }
.tl-kind-obstacle { color: #b26a00; }
.tl-kind-expectation { color: #8a6d3b; }
.tl-text { margin: 8px 0 0; font-size: 15px; line-height: 1.55; color: var(--text);
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.tl-text.empty-text { color: var(--text-3); font-style: italic; }
.tl-thumbs { display: flex; gap: 6px; margin-top: 8px; }
.tl-thumbs img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; }
.tl-empty { text-align: center; color: var(--text-3); padding: 60px 0; font-size: 15px; }

/* ═══════════ 汇总页 ═══════════ */
.sum-search { padding: 0 16px 8px; min-height: 36px; display: flex; align-items: center; }
.sum-search input {
  flex: 1; min-width: 0; box-sizing: border-box; height: 46px; margin-top: 1px;
  font-size: 13px; padding: 0 14px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--card); color: var(--text);
}
.sum-search input:focus { border-color: var(--primary); outline: none; }

/* 时间线页第二行：标语，行几何与分享页 .ai-bar 一致（42px） */
.tl-slogan { display: flex; align-items: center; padding: 0 16px 2px; height: 42px; box-sizing: border-box; font-size: 13px; color: var(--text-3); }

/* 时间线页搜索行：输入框与分享页 .sum-search input 完全同款（46px），位于第三行同位置 */
.tl-search { display: flex; align-items: center; padding: 0 16px 8px; min-height: 36px; box-sizing: border-box; }
.tl-search input {
  width: 100%; box-sizing: border-box; height: 46px; margin-top: 1px;
  font-size: 13px; padding: 0 14px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--card); color: var(--text);
}
.tl-search input:focus { border-color: var(--primary); outline: none; }
.sum-list { flex: 1.1; overflow-y: auto; padding: 0 16px 10px; min-height: 90px; }
.sum-item {
  display: flex; align-items: center; gap: 10px;
  background: var(--card); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px;
  cursor: pointer; touch-action: pan-y; /* 允许纵向原生滚动（列表超屏时）；长按激活拖拽后 touchmove preventDefault 接管 */
}
.sum-item.dragging {
  transform: scale(1.04); opacity: .72; z-index: 10;
  box-shadow: 0 6px 18px rgba(0,0,0,.18);
  transition: transform .12s ease-out, box-shadow .12s ease-out;
  will-change: transform;
}
.sum-item input[type="checkbox"] { width: 19px; height: 19px; accent-color: var(--primary); flex: none; }
.si-main { flex: 1; min-width: 0; }
.si-line1 { display: flex; gap: 8px; align-items: center; font-size: 14px; font-weight: 600; }
.si-text { font-size: 13px; color: var(--text-2); margin-top: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.si-text.no-photo-note { color: var(--text-3); font-style: italic; }
.sum-empty { text-align: center; color: var(--text-3); padding: 26px 0; font-size: 14px; }
/* 汇总明细平铺模式（设置→显示模式：Prefs.sumListMode = tile）
   卡片 JS 结构与列表模式完全相同（.sum-card 一套），仅此处收窄为紧凑双列小卡。
   宽度 calc(50% - 4px) 配合 gap:8px：两卡 + 间隙正好 100% */
.sum-list.tile { display: flex; flex-wrap: wrap; gap: 8px; align-content: flex-start; }
.sum-list.tile .sum-empty { width: 100%; }
.sum-list.tile .sum-card { width: calc(50% - 4px); margin-bottom: 0; }
.sum-list.tile .sum-card-inner { padding: 8px 10px; }
/* 顶行收窄：时间/标签缩字号，标签超长省略，选中开关 26→22；已发只留圆点 */
.sum-list.tile .sum-card-header { font-size: 12px; gap: 4px; margin-bottom: 3px; }
.sum-list.tile .sc-head-info { gap: 4px; }
.sum-list.tile .sc-tag {
  padding: 0 6px; font-size: 11px; max-width: 72px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sum-list.tile .sc-sent { font-size: 0; }
.sum-list.tile .card-toggle { width: 22px; height: 22px; font-size: 11px; }
/* 标题/正文：标题 14px 单行省略，正文 3 行省略 */
.sum-list.tile .sc-title { font-size: 14px; }
.sum-list.tile .sum-card-body { font-size: 12px; line-height: 1.45; -webkit-line-clamp: 3; }
/* 照片：单张 48px 方图 + 右下角 +N */
.sum-list.tile .sum-card-thumbs { margin-top: 5px; }
.sum-list.tile .sum-card-thumbs img,
.sum-list.tile .sum-card-thumbs .thumb-more { width: 48px; height: 48px; }
/* 底行：拖拽手柄 / AI 钮缩小 */
.sum-list.tile .drag-handle { width: 28px; height: 28px; font-size: 15px; }
.sum-list.tile .sum-card-actions { margin-top: 2px; }
.sum-list.tile .sum-card-actions .card-ai { height: 26px; min-width: 38px; font-size: 11px; padding: 0 6px; }

.tabs { flex: none; display: flex; gap: 8px; padding: 4px 16px; }
.tab {
  flex: 1; height: 36px; border-radius: 10px; font-size: 14px;
  background: var(--card); border: 1px solid var(--line); color: var(--text-2);
}
.tab.active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.tab-action {
  flex: none; height: 36px; padding: 0 14px; border-radius: 10px; font-size: 14px; font-weight: 600;
  background: var(--primary-weak); border: 1px solid var(--primary); color: var(--primary);
  white-space: nowrap;
}
.tab-action:disabled { opacity: 0.6; }

.sum-preview {
  flex: 1.4; margin: 8px 16px 0; border-radius: var(--radius);
  background: var(--card); border: 1px solid var(--line);
  overflow: auto; padding: 10px; min-height: 110px;
}
.sum-preview pre {
  margin: 0; white-space: pre-wrap; word-break: break-word;
  font-family: inherit; font-size: 14px; line-height: 1.65;
}
.sum-preview canvas { width: 100%; display: block; border-radius: 8px; }
.sum-preview .pv-empty { color: var(--text-3); font-size: 14px; text-align: center; padding: 30px 0; }

/* ═══════════ 汇总页：搜索行侧按钮（排序 / AI 工具） ═══════════ */
.sum-side-btn {
  flex: none; display: flex; align-items: center; justify-content: center; gap: 4px;
  height: 40px; margin-left: 8px; padding: 0 10px; box-sizing: border-box;
  border-radius: 9px; border: 1px solid var(--line);
  background: var(--card); color: var(--text-2);
  font-size: 13px; white-space: nowrap;
}
.sum-side-btn:active { opacity: .7; }
.sum-sort-btn { padding: 0 10px; font-size: 14px; font-weight: 600; touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.sum-viewmode-btn { padding: 0 10px; font-size: 14px; font-weight: 600; }
.sum-sort-btn.is-active, .sum-viewmode-btn.is-active { color: var(--primary); border-color: var(--primary); }
.sum-bottom-bar .sum-sel-btn:disabled { opacity: .45; pointer-events: none; }
.ai-tools-btn.is-open { color: var(--primary); border-color: var(--primary); }
.ai-tools-badge {
  font-size: 10px; font-weight: 700; line-height: 1;
  color: #fff; background: #1a7f4b; border-radius: 8px;
  min-width: 16px; height: 16px; padding: 0 4px;
  display: inline-flex; align-items: center; justify-content: center;
}

/* AI 工具弹开的工具条（点击 AI 工具按钮显示，文档流下推列表） */
.ai-tools-panel {
  flex: none; display: flex; align-items: center; justify-content: flex-end; gap: 6px;
  padding: 0 16px 4px; height: 42px;
}

/* ═══════════ 汇总页：底部操作栏 ═══════════ */
.sum-bottom-bar {
  flex: none; display: flex; align-items: center; gap: 10px;
  padding: 10px 16px calc(env(safe-area-inset-bottom) + 10px);
  background: var(--bg); border-top: 1px solid var(--line);
}
.sum-sel-btn { flex: none; padding: 8px 14px; font-size: 13px; touch-action: manipulation; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.sum-sel-count { flex: 1; text-align: center; font-size: 13px; color: var(--text-2); }
.sum-share-btn {
  flex: none; padding: 10px 28px; font-size: 15px; font-weight: 700;
  border-radius: 12px; min-width: 100px;
}

/* ═══════════ 汇总页：新卡片样式 ═══════════ */
.sum-card {
  position: relative; overflow: hidden;
  background: var(--card); border-radius: 12px;
  margin-bottom: 8px;
  cursor: pointer; touch-action: pan-y;
}
.sum-card-inner {
  position: relative; z-index: 2;
  background: var(--card); border-radius: 12px;
  padding: 12px 14px;
  border: 2px solid transparent;
  transition: transform .2s ease, border-color .15s, background .15s;
  touch-action: pan-y;
}
.sum-card.open .sum-card-inner { transform: translateX(-80px); }
.sum-swipe-del {
  position: absolute; right: 0; top: 0; bottom: 0; width: 80px;
  background: var(--danger, #e54545); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 700; z-index: 1;
  border-radius: 0 12px 12px 0;
  cursor: pointer; opacity: 0; transition: opacity .15s;
}
.sum-card.open .sum-swipe-del { opacity: 1; }
.sum-swipe-del:active { background: #d13f44; }
.sum-card.selected .sum-card-inner {
  border-color: var(--primary); background: var(--primary-weak);
}
.sum-card.dragging {
  transform: scale(1.04); opacity: .72; z-index: 10;
  box-shadow: 0 6px 18px rgba(0,0,0,.18);
  transition: transform .12s ease-out, box-shadow .12s ease-out;
}
/* 顶行：时间+标签+已发 左  选中开关 右 */
.sum-card-header {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-size: 13px; font-weight: 500; margin-bottom: 4px;
}
.sc-head-info { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1 1 auto; overflow: hidden; }
.sc-time { color: var(--text-3); font-weight: 500; }
.sc-title { font-weight: 700; color: var(--text-1); font-size: 15px; margin-bottom: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sc-tag { /* 标签胶囊 */ background: var(--chip-bg, #f0f0f2); color: var(--chip-fg, #555); padding: 1px 8px; border-radius: 10px; font-size: 12px; font-weight: 500; flex: none; }
/* 顶行右侧选中开关（默认空心，选中变蓝色填充） */
.card-toggle {
  flex: none; width: 26px; height: 26px; border-radius: 50%;
  border: 1.5px solid var(--line); background: transparent;
  color: transparent; font-size: 13px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; padding: 0;
}
.card-toggle:active { transform: scale(.9); }
.sum-card.selected .card-toggle {
  background: var(--primary); border-color: var(--primary); color: #fff;
}
.sum-card-body {
  font-size: 13px; color: var(--text-2); line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical;
  overflow: hidden; text-overflow: ellipsis;
}
.sum-card-body.expanded { -webkit-line-clamp: unset; }
.sum-card-thumbs {
  display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap;
}
.sum-card-thumbs img {
  width: 56px; height: 56px; object-fit: cover; border-radius: 8px;
}
.sum-card-thumbs .thumb-more {
  width: 56px; height: 56px; border-radius: 8px;
  background: var(--bg); display: flex; align-items: center; justify-content: center;
  font-size: 12px; color: var(--text-3);
}
.sum-card-actions {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 4px;
}
/* 底行 AI 按钮：恢复默认高度，空间宽松不挤 */
.sum-card-actions .card-ai { height: 28px; min-width: 42px; }
.drag-handle {
  color: var(--text-3); font-size: 16px;
  width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
  cursor: grab; touch-action: none; user-select: none;
}
.drag-handle:active { cursor: grabbing; }
.drag-handle.disabled { opacity: .28; cursor: default; touch-action: pan-y; }

/* ═══════════ 分享底部面板 ═══════════ */
.share-options {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  margin-top: 8px;
}
.share-opt-btn {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 16px 8px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card);
  font-size: 13px; color: var(--text); cursor: pointer;
  transition: all .15s;
}
.share-opt-btn:active { transform: scale(.96); background: var(--primary-weak); border-color: var(--primary); }
.share-opt-btn .share-opt-icon { font-size: 24px; }
.preview-text-content {
  max-height: 60vh; overflow-y: auto; padding: 12px;
  background: var(--bg); border-radius: 8px; margin: 12px;
  font-size: 13px; line-height: 1.6; white-space: pre-wrap; word-break: break-word;
}
.preview-image-container { padding: 12px; text-align: center; }
.preview-image-loading { padding: 40px 12px; text-align: center; color: var(--text-2); font-size: 14px; }

/* ═══════════ 长按操作菜单 ═══════════ */
.action-menu-item {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 4px; font-size: 15px; border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.action-menu-item:active { background: var(--primary-weak); }
.action-menu-item:last-child { border-bottom: none; }
.action-menu-item.danger { color: var(--danger); }

/* ═══════════ 成长手册（profile） ═══════════ */
.profile-content {
  flex: 1; overflow-y: auto; padding: 12px 16px 16px;
  -webkit-overflow-scrolling: touch;
}
.profile-section { margin-bottom: 20px; }
.p-sec-title {
  font-size: 15px; font-weight: 700; color: var(--text-1); margin-bottom: 10px;
  display: flex; align-items: center; gap: 6px;
}
.p-sec-sub { font-size: 13px; font-weight: 500; color: var(--text-3); margin-left: 6px; }

/* 统计卡（3 张横排） */
.p-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.p-stat-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 8px; text-align: center; display: flex; flex-direction: column; gap: 2px;
}
.p-stat-card.hi { border-color: var(--primary); background: var(--primary-weak); }
.p-stat-big { font-size: 26px; font-weight: 800; color: var(--primary); line-height: 1.1; }
.p-stat-card.hi .p-stat-big { color: var(--primary); }
.p-stat-label { font-size: 12px; font-weight: 600; color: var(--text-2); }
.p-stat-sub { font-size: 11px; color: var(--text-3); }

/* 热力图：30 格（6 列 × 5 行） */
.p-hm-wrap { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.p-hm-grid {
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px;
}
.p-hm-cell {
  aspect-ratio: 1; border-radius: 4px; background: #e8e8e8;
  min-width: 0; /* 防止 grid item 撑开 */
}
.p-hm-cell.on { background: var(--primary); }
.p-hm-cell.today { outline: 2px solid var(--primary); outline-offset: -2px; }
.p-hm-cell.today.on { box-shadow: 0 0 0 2px var(--card); }
.p-hm-legend { font-size: 12px; color: var(--text-3); margin-top: 10px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.p-hm-dot { width: 10px; height: 10px; border-radius: 2px; background: #e8e8e8; display: inline-block; }
.p-hm-dot.on { background: var(--primary); }
.p-hm-today { margin-left: auto; }

/* 标签分布（横条） */
.p-tag-list { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.p-tag-row {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px;
  margin-bottom: 8px;
}
.p-tag-row:last-child { margin-bottom: 0; }
.p-tag-name { font-size: 13px; color: var(--text-1); white-space: nowrap; max-width: 80px; overflow: hidden; text-overflow: ellipsis; }
.p-tag-bar { background: #e8e8e8; border-radius: 4px; height: 8px; overflow: hidden; }
.p-tag-fill { background: var(--primary); height: 100%; border-radius: 4px; transition: width .3s; }
.p-tag-count { font-size: 12px; color: var(--text-3); min-width: 20px; text-align: right; }

/* 成就徽章 */
.p-badge-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
}
.p-badge {
  background: var(--card); border: 1.5px solid var(--primary); border-radius: 12px;
  padding: 12px 8px; text-align: center; position: relative; cursor: pointer;
  transition: transform .15s, box-shadow .15s;
}
.p-badge:active { transform: scale(.96); }
.p-badge.locked { border-color: var(--line); background: #f9f9f9; opacity: .55; cursor: default; }
.p-badge.locked:active { transform: none; }
.p-badge-icon { font-size: 28px; line-height: 1; margin-bottom: 4px; }
.p-badge.locked .p-badge-icon { filter: grayscale(1); }
.p-badge-name { font-size: 13px; font-weight: 700; color: var(--text-1); }
.p-badge.locked .p-badge-name { color: var(--text-3); }
.p-badge-desc { font-size: 11px; color: var(--text-2); margin-top: 2px; }
.p-badge.locked .p-badge-desc { color: var(--text-3); }
.p-badge-lock { position: absolute; top: 6px; right: 8px; font-size: 12px; }

/* 空态 */
.profile-loading, .profile-empty {
  text-align: center; padding: 60px 20px; color: var(--text-3); font-size: 14px;
}
.profile-empty-emoji { font-size: 48px; margin-bottom: 12px; }
.profile-empty-text { font-size: 16px; font-weight: 600; color: var(--text-1); }
.profile-empty-hint { margin-top: 4px; font-size: 13px; }

/* ═══════════ 底部导航 ═══════════
 * static 放进 view flex 末尾，随 adjustResize 自动上移（不被键盘盖住）
 */
.bottom-nav {
  flex: none; height: var(--nav-h);
  background: var(--card); border-top: 1px solid var(--line);
  display: flex; z-index: 30;
  padding-bottom: env(safe-area-inset-bottom);
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
}
.nav-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1px; font-size: 12px; color: var(--text-3); transition: transform .15s ease;
}
.nav-ico { font-size: 20px; }
.nav-btn.active { color: var(--primary); font-weight: 600; transform: scale(1.08); }

/* ═══════════ 相机全屏层 ═══════════ */
.camera-overlay {
  position: fixed; inset: 0; z-index: 100; background: #000;
  display: none;
}
.camera-overlay.show { display: block; }
#cameraVideo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.camera-grid { position: absolute; inset: 0; pointer-events: none; }
.camera-grid i { position: absolute; background: rgba(255,255,255,.28); }
.camera-grid .v1 { left: 33.33%; top: 0; bottom: 0; width: 1px; }
.camera-grid .v2 { left: 66.66%; top: 0; bottom: 0; width: 1px; }
.camera-grid .h1 { top: 33.33%; left: 0; right: 0; height: 1px; }
.camera-grid .h2 { top: 66.66%; left: 0; right: 0; height: 1px; }
.camera-flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.camera-flash.active { animation: flashAnim .25s ease-out; }
@keyframes flashAnim { 0% { opacity: .9; } 100% { opacity: 0; } }
.camera-top {
  position: absolute; top: calc(env(safe-area-inset-top) + 12px); left: 16px; right: 16px;
  display: flex; align-items: center; justify-content: flex-end; z-index: 5;
}
.camera-count {
  background: rgba(0,0,0,.45); color: #fff; font-size: 14px;
  padding: 7px 14px; border-radius: 999px;
}
.camera-bottom {
  position: absolute; bottom: calc(env(safe-area-inset-bottom) + 30px);
  left: 0; right: 0; display: flex; justify-content: center; z-index: 5;
}
.camera-shutter {
  width: 74px; height: 74px; border-radius: 50%;
  background: #fff; border: 5px solid rgba(255,255,255,.35);
  box-shadow: 0 0 0 2px rgba(0,0,0,.25);
}
.camera-shutter:active { transform: scale(.96); }
.camera-loading {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 15px; background: #000; z-index: 6;
}
.camera-loading.hide { display: none; }

/* ── 相机红色选择框（可移动 + 8 手柄缩放） ── */
.cam-rect {
  position: absolute; z-index: 4;
  border: 2px solid #ff3b3b;
  pointer-events: auto;
  touch-action: none;          /* ★ 关键：阻止浏览器拦截触摸做滚动 */
  box-shadow: 0 0 0 9999px rgba(0,0,0,.35) inset;
  left: 15%; top: 20%; width: 70%; height: 60%;
  cursor: move;
  box-sizing: border-box;
}
.cam-handle {
  position: absolute;
  width: 16px; height: 16px;
  background: #fff; border: 2px solid #ff3b3b;
  border-radius: 2px;          /* ★ 方角比圆形更好命中 */
  touch-action: none;          /* ★ 阻止浏览器拦截 */
  z-index: 2;
}
/* ★ 扩大触摸热区：::before 加 24px 透明环绕，手指容易按到 */
.cam-handle::before {
  content: ''; position: absolute; inset: -12px; background: transparent;
}
.cam-handle.nw { left: -8px;  top: -8px;    cursor: nwse-resize; }
.cam-handle.n  { left: 50%;   top: -8px;    transform: translateX(-50%); cursor: ns-resize; }
.cam-handle.ne { right: -8px; top: -8px;    cursor: nesw-resize; }
.cam-handle.w  { left: -8px;  top: 50%;     transform: translateY(-50%); cursor: ew-resize; }
.cam-handle.e  { right: -8px; top: 50%;     transform: translateY(-50%); cursor: ew-resize; }
.cam-handle.sw { left: -8px;  bottom: -8px; cursor: nesw-resize; }
.cam-handle.s  { left: 50%;   bottom: -8px; transform: translateX(-50%); cursor: ns-resize; }
.cam-handle.se { right: -8px; bottom: -8px; cursor: nwse-resize; }

/* ── 相机底部三按钮 ── */
.camera-bottom {
  gap: 16px;
}
.cam-act-btn {
  height: 48px; padding: 0 20px; min-width: 90px;
  background: rgba(255,255,255,.18); color: #fff;
  border: 1px solid rgba(255,255,255,.5); border-radius: 24px;
  font-size: 15px; font-weight: 600; backdrop-filter: blur(6px);
}
.cam-act-btn.primary {
  background: #fff; color: #111; border-color: #fff;
}
.cam-act-btn:active { transform: scale(.96); opacity: .85; }

/* ═══════════ 弹层 / 弹窗 ═══════════ */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 80; background: rgba(0,0,0,.45);
  display: flex; align-items: flex-end; justify-content: center;
  padding-bottom: var(--kb-inset, 0);  /* iOS 键盘遮挡：sheet 整体上移到键盘上方 */
  animation: fadeIn .15s ease-out;
}
.modal-sheet {
  width: 100%; max-height: 92%;
  background: var(--card); border-radius: 20px 20px 0 0;
  padding: 10px 16px calc(env(safe-area-inset-bottom) + 12px);
  overflow-y: auto; animation: slideUp .2s ease-out;
  /* 套用 CaptionEditor 同机制（hard-rules「同机制实现约束」）：
   * flex 列 + 子元素 flex 分配 = 底部按钮 flex:none 永远在键盘上方，不依赖 overflow 滚动。
   * 无 textarea 的 Modal（错误提示/背景选择/文本预览等）子元素默认 flex:0 1 auto 自然高度，不受影响。 */
  display: flex; flex-direction: column;
}
/* 详情 Modal 子元素 flex 分配：标题/输入框/标签/图片区固定高度，textarea 吃剩余，按钮永远在底 */
.modal-sheet > .m-head,
.modal-sheet > .m-titleinput,
.modal-sheet > .m-block-label,
.modal-sheet > .m-img-header,
.modal-sheet > .m-images,
.modal-sheet > .detail-btns,
.modal-sheet > .m-row,
.modal-sheet > #mPolWrap { flex: none; }
.modal-sheet > .m-text,
.modal-sheet > .m-pol-text { flex: 1 1 auto; min-height: 80px; }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes slideUp { from { transform: translateY(40%); } }
.m-title { font-size: 17px; font-weight: 700; margin-bottom: 12px; }
/* 详情弹窗顶行：只有标题，左对齐 */
.m-head {
  display: flex; align-items: center;
  gap: 10px; margin-bottom: 4px;
}
.m-head .m-title { margin-bottom: 0; flex: 1 1 auto; min-width: 0; line-height: 32px; display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.m-titleinput {
  display: block; width: 100%; box-sizing: border-box;
  margin: 0 0 10px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); font-size: 15px; font-weight: 600; outline: none;
}
.m-titleinput:focus { border-color: var(--primary); }
.m-text {
  width: 100%; box-sizing: border-box;
  border: 1px solid var(--line); border-radius: 12px;
  padding: 12px; font-size: 15px; line-height: 1.6;
  resize: none; overflow-y: auto; outline: none;
}
#mText { height: 144px; }        /* 原文：5 行固定高 */
#mPolText { height: 120px; }     /* 润色结果：4 行固定高 */
/* 图片区 header：左侧"图片"标签 + 右侧相册/快拍/相机小按钮 */
.m-img-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 10px; margin-bottom: 6px;
}
.m-img-header .m-block-label { margin: 0; }
.m-img-add-btns { display: flex; gap: 6px; flex: none; }
.m-img-add {
  font-size: 12px; padding: 5px 10px; border-radius: 7px;
}
.m-images {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 10px;
  touch-action: none;     /* ← 关键：禁浏览器默认手势抢占，让 touchmove 完整派发至 JS */
  user-select: none;      /* 禁长按文字选择 */
  -webkit-user-drag: none;
}
.m-imgwrap { position: relative; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.m-imgbox { position: relative; }
.m-imgbox img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; display: block; }
.m-imgwrap.mark-del .m-imgbox img { opacity: .35; }
.m-imgnote-bar {
  width: 100%; box-sizing: border-box; min-width: 0;
  border: 1px dashed var(--line); border-radius: 5px;
  padding: 3px 5px; font-size: 10px; line-height: 1.3;
  color: var(--text-3); background: var(--card);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  cursor: pointer;
}
.m-imgnote-bar.has {
  border-style: solid; border-color: rgba(79,110,247,.35); color: var(--text-2);
}
.m-imgwrap.mark-del::after {
  content: "将删除"; position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--danger); font-size: 13px; font-weight: 700;
}
.m-imgdel {
  position: absolute; top: 2px; right: 2px; width: 18px; height: 18px; border-radius: 50%;
  background: rgba(0,0,0,.6); color: #fff; font-size: 11px; line-height: 18px; text-align: center;
}
/* 详情弹窗：添加图片格子 —— 和图片同格、同大、同 grid 末尾；点=快拍、长按=选相册/相机 */
.m-add-cell {
  grid-column: auto; aspect-ratio: 1;    /* 和图片同大的正方形格子 */
  border: 1.5px dashed var(--line); background: var(--card);
  border-radius: 8px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; color: var(--text-3);
  padding: 0; margin: 0;
}
.m-add-ic { font-size: 22px; line-height: 1; }
.m-add-tip { font-size: 10px; color: var(--text-3); opacity: .8; }
.m-add-cell:active { transform: scale(.96); background: var(--bg); }
/* 详情弹窗底部四按钮：AI润色 / 删除 / 保存 / 退出（统一灰色等分） */
.detail-btns {
  display: flex; gap: 8px; margin-top: 14px; padding-bottom: 4px;
}
.detail-btns .cap-bbtn { flex: 1; font-size: 15px; padding: 10px 0; }
/* 删除只染文字红色给出危险暗示，不加二次确认（撤销条兜底） */
.cap-bbtn.cap-danger { color: #e11d48; border-color: #f3c6d2; }
.cap-bbtn.cap-danger:active { background: #fef2f3; }
.detail-btns .cap-bbtn.primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.m-imgwrap.dragging {
  transform: scale(1.08); opacity: .7; z-index: 10;
  box-shadow: 0 6px 18px rgba(0,0,0,.2);
  transition: transform .15s, box-shadow .15s;
}
.m-row { display: flex; gap: 10px; margin-top: 16px; }

/* 其他页面用的 AI 状态按钮（分享页卡片、记录页等）—— 完整尺寸+颜色 */
.m-ai-btn {
  flex: none; height: 32px; min-width: 40px; padding: 0 8px;
  border-radius: 8px; font-size: 12px; font-weight: 700;
  border: 1px solid var(--line); background: var(--card); color: var(--text-3);
  cursor: pointer; -webkit-user-select: none; user-select: none;
}
.m-ai-btn.idle { color: #6b7280; background: #f3f4f6; border-color: #d1d5db; }
.m-ai-btn.waiting { color: #b45309; background: #fef3c7; border-color: #fcd34d; }
.m-ai-btn.applied { color: #fff; background: var(--primary); border-color: var(--primary); }
.m-ai-btn.err { color: #fff; background: #e11d48; border-color: #e11d48; }
.m-ai-btn.run { color: #b45309; background: #fef3c7; border-color: #fcd34d; animation: aiPulse 1s ease-in-out infinite; }

/* 详情弹窗底部 AI 按钮颜色状态 —— 尺寸由 .cap-bbtn 控制（flex:1 / font-size:15px 等） */
.ai-state { color: var(--text-2); }
.ai-state.waiting { color: #b45309; background: #fef3c7; border-color: #fcd34d; }
.ai-state.applied { color: #fff; background: var(--primary); border-color: var(--primary); }
.ai-state.err { color: #fff; background: #e11d48; border-color: #e11d48; }
.ai-state.run { color: #b45309; background: #fef3c7; border-color: #fcd34d; animation: aiPulse 1s ease-in-out infinite; }

/* AI 操作菜单 / 方案选择（小卡片居中） */
.ai-pop-mask {
  position: fixed; inset: 0; z-index: 120;
  background: rgba(0,0,0,.35);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.ai-menu-card {
  width: min(78vw, 300px);
  background: var(--card); border-radius: 14px; padding: 8px;
  box-shadow: 0 8px 32px rgba(0,0,0,.18);
}
.ai-menu-title { font-size: 13px; color: var(--text-3); text-align: center; padding: 8px 0 6px; font-weight: 600; }
.ai-menu-item {
  display: block; width: 100%; box-sizing: border-box;
  padding: 12px 10px; margin: 2px 0; border: none; border-radius: 10px;
  background: transparent; color: var(--text); font-size: 15px; cursor: pointer;
}
.ai-menu-item:active { background: rgba(0,0,0,.06); }
.ai-menu-item.primary { color: var(--primary); font-weight: 700; }
.ai-menu-item.cancel { color: var(--text-3); font-size: 14px; }
.ai-menu-item.cur { color: var(--primary); font-weight: 700; background: rgba(99,102,241,.08); }
.ai-menu-item.cur::after { content: ' ✓'; }

/* 排序方式菜单：两行式选项（名称 + 灰色说明） */
.sort-item { text-align: left; }
.sort-opt { display: flex; flex-direction: column; gap: 2px; }
.sort-desc { font-size: 12px; font-weight: 400; color: var(--text-3); }
.ai-menu-item.cur .sort-desc { color: var(--primary); opacity: .75; }

/* 原文 / 润色结果 分区标签 */
.m-block-label {
  font-size: 12px; color: var(--text-3); font-weight: 600;
  margin: 8px 2px 5px;
}
#mPolWrap .m-block-label { color: var(--primary); }
.m-pol-text { background: #f7f8ff; }

/* 设置弹窗 */
.set-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 2px; border-bottom: 1px solid var(--line); font-size: 15px;
}
.set-item:last-of-type { border-bottom: none; }
.set-desc { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.set-do { color: var(--primary); font-weight: 600; }

/* AI 润色（设置页） */
.ai-key-row { display: flex; gap: 8px; align-items: center; }
.ai-key-row .pref-input { flex: 1; min-width: 0; }
.ai-eye { flex: none; border: none; background: transparent; font-size: 18px; padding: 4px 6px; cursor: pointer; line-height: 1; }

/* 设置页分页标签（PageControl：通用 / AI设置） */
.seg-tabs { display: flex; gap: 8px; padding: 10px 16px 12px; }

/* AI 润色方案管理（M2） */
.ai-layout-row { display: flex; gap: 8px; align-items: center; margin: 2px 0 10px; }
.seg-mini { display: flex; gap: 2px; background: var(--bg); border-radius: 9px; padding: 3px; }
.seg-mini button {
  border: none; background: transparent; padding: 6px 14px;
  font-size: 13px; font-weight: 600; color: var(--text-2); border-radius: 7px; cursor: pointer;
}
.seg-mini button.active { background: var(--card); color: var(--primary); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.ai-style-list { display: flex; flex-direction: column; gap: 8px; }
.ai-style-item {
  border: 1.5px solid var(--line); border-radius: 12px;
  padding: 10px 12px; background: var(--card); cursor: pointer;
}
.ai-style-item.dft { border-color: var(--primary); }
.ai-style-name { font-size: 14px; font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 6px; }
.ai-dft-badge { font-size: 11px; color: #fff; background: var(--primary); border-radius: 5px; padding: 1px 6px; font-weight: 600; flex: none; }
.ai-style-prompt {
  font-size: 12px; color: var(--text-3); margin-top: 4px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ai-style-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ai-style-grid .ai-style-item { padding: 12px; }
.ai-style-grid .ai-style-prompt {
  white-space: normal; display: -webkit-box;
  -webkit-line-clamp: 3; -webkit-box-orient: vertical;
}

/* 润色方案编辑弹层（独立 overlay，z-index 130 > CaptionEditor 120） */
.ase-backdrop {
  position: fixed; inset: 0; z-index: 130; background: rgba(0,0,0,.45);
  display: flex; align-items: flex-end; justify-content: center;
}
.ase-sheet {
  width: 100%; box-sizing: border-box; max-height: 92%; overflow-y: auto;
  background: var(--card); border-radius: 20px 20px 0 0;
  padding: 18px 16px calc(env(safe-area-inset-bottom) + 16px);
  animation: slideUp .2s ease-out;
}
.ase-title { font-size: 16px; font-weight: 700; margin-bottom: 12px; }
.ase-label { font-size: 12px; color: var(--text-3); margin: 8px 0 5px; }
.ase-input {
  width: 100%; box-sizing: border-box;
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
  font-size: 15px; background: var(--bg); color: var(--text); outline: none;
}
.ase-input:focus { border-color: var(--primary); }
.ase-tools { display: flex; gap: 6px; align-items: center; margin-bottom: 8px; }
.ase-tip { font-size: 12px; color: var(--text-3); }
.ase-chip {
  border: 1px solid var(--primary); color: var(--primary); background: var(--primary-weak);
  font-size: 12px; border-radius: 999px; padding: 4px 10px; cursor: pointer;
}
.ase-text {
  width: 100%; box-sizing: border-box; min-height: 180px;
  border: 1px solid var(--line); border-radius: 12px; padding: 12px;
  font-size: 13px; line-height: 1.6; font-family: inherit;
  background: var(--bg); color: var(--text); resize: vertical; outline: none;
}
.ase-text:focus { border-color: var(--primary); }
.ase-note { font-size: 11px; color: var(--text-3); margin-top: 6px; line-height: 1.5; }
.ase-btns { display: flex; gap: 8px; align-items: center; margin-top: 14px; }
.ase-btn {
  border: 1px solid var(--line); background: var(--card); color: var(--text-2);
  font-size: 14px; font-weight: 600; padding: 9px 16px; border-radius: 10px; cursor: pointer;
}
.ase-btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.ase-btn.danger { color: #e84c6a; border-color: #f4b9c6; }

/* 汇总页 AI 润色条（M3） */
.ai-bar { display: flex; align-items: center; justify-content: flex-end; gap: 6px; padding: 0 16px 2px; height: 42px; }
.ai-run {
  flex: none; border: none;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff; font-size: 13px; font-weight: 700;
  padding: 8px 14px; border-radius: 999px; cursor: pointer;
  transition: transform .15s, filter .15s;
}
.ai-run:active { transform: scale(.96); filter: brightness(.92); }
.ai-run:disabled { opacity: .55; }
.ai-preview-btn {
  flex: none; border: 1px solid var(--line);
  background: var(--card); color: var(--text-2);
  font-size: 12px; padding: 6px 10px; border-radius: 999px;
  cursor: pointer; transition: all .15s;
}
.ai-preview-btn:active { transform: scale(.96); background: var(--primary-weak); color: var(--primary); border-color: var(--primary); }
.ai-apply {
  flex: none; border: 1px solid var(--line); margin-right: auto;
  background: var(--card);
  color: var(--text-2); font-size: 14px;
  padding: 7px 14px; border-radius: 999px; cursor: pointer;
  transition: all .15s;
}
.ai-apply:active { transform: scale(.96); }
.ai-apply:disabled { opacity: .55; }
@keyframes aiPulse { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }

/* M4 应用撤销条（位于操作栏上方，6 秒自动消失） */
.ai-undo {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--nav-h) + 96px); z-index: 85;
  display: flex; align-items: center; gap: 12px;
  max-width: 86vw; padding: 10px 16px;
  background: #2b2f36; color: #fff; font-size: 13px;
  border-radius: 10px; box-shadow: 0 4px 14px rgba(0, 0, 0, .28);
}
.ai-undo button {
  border: none; background: none; color: #7fd4a8;
  font-size: 13px; font-weight: 700; cursor: pointer; padding: 0;
}

/* 设置页（独立视图） */
.settings-scroll { flex: 1; overflow-y: auto; padding: 0 16px 20px; }
.set-group-title {
  font-size: 13px; font-weight: 600; color: var(--text-3);
  margin: 18px 4px 8px;
}
.set-card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: 0 1px 4px rgba(0,0,0,.05);
  padding: 2px 16px; overflow: hidden;
}
.pref-item {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 14px 0;
  border-bottom: 1px solid var(--line); font-size: 15px; cursor: pointer;
}
.pref-item:last-of-type { border-bottom: none; }
.pref-item input[type="checkbox"] {
  flex: none; width: 22px; height: 22px;
  accent-color: var(--primary); margin: 0;
}
/* 文本/数字/下拉类设置项 */
.pref-col { flex-direction: column; align-items: stretch; gap: 8px; cursor: default; }
.pref-input, .pref-num, .pref-select {
  box-sizing: border-box;
  border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; font-size: 14px; font-family: inherit;
  background: var(--card); color: var(--text);
}
.pref-input { width: 100%; }
.pref-input-sender { width: 140px; flex: none; }
.pref-num { width: 88px; flex: none; }
.pref-select { width: 112px; flex: none; }
.pref-input:focus, .pref-num:focus, .pref-select:focus {
  border-color: var(--primary); outline: none;
}

/* ═══════════ 自定义月历（有日记日期画圈） ═══════════ */
.viewer {
  position: fixed; inset: 0; z-index: 110; background: rgba(0,0,0,.92);
  display: flex; align-items: center; justify-content: center;
}
.viewer img { max-width: 100%; max-height: 100%; object-fit: contain; }

/* ═══════════ 设置页 分隔图风格缩略图网格 ═══════════ */
.deco-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 6px;
}
.deco-grid .deco-cell {
  display: flex; align-items: center; gap: 10px;
  border: 1.5px solid var(--line); border-radius: 10px;
  padding: 8px 10px; background: var(--bg);
  cursor: pointer; transition: border-color .15s, box-shadow .15s;
}
.deco-grid .deco-cell.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,110,247,.15);
}
.deco-grid .deco-canvas {
  flex: none; background: var(--card); border-radius: 6px;
}
.deco-grid .deco-name {
  font-size: 13px; color: var(--text-2); font-weight: 500;
}
.cap-backdrop {
  position: fixed; inset: 0; z-index: 120; background: rgba(0,0,0,.45);
  display: flex; align-items: flex-end; justify-content: center;
  padding-bottom: var(--kb-inset, 0);  /* iOS 键盘遮挡统一处理 */
}
/* 图片批注弹窗：flex column 自适应高度，键盘弹起时先压图片、再缩文本，底部按钮永远可见 */
.cap-sheet {
  width: 100%; box-sizing: border-box;
  max-height: 80vh;  /* 给键盘留 ~20vh 空间，比原来 90% 保守 */
  background: var(--card); border-radius: 20px 20px 0 0;
  padding: 18px 16px calc(env(safe-area-inset-bottom) + 16px);
  display: flex; flex-direction: column;
  animation: slideUp .2s ease-out;
}
.cap-img {
  flex: none; width: 100%;
  max-height: clamp(100px, 28vh, 32vh);  /* 键盘弹起时自动压到 28vh 上限 */
  object-fit: contain;
  border-radius: 12px; background: var(--bg); display: block;
  margin: 4px 0 12px;
}
.cap-text {
  flex: 1 1 auto; min-height: 80px; max-height: 240px;
  width: 100%; box-sizing: border-box;
  border: 1px solid var(--line); border-radius: 12px;
  padding: 12px; font-size: 15px; line-height: 1.6;
  font-family: inherit; background: var(--bg); color: var(--text);
  resize: none; outline: none; overflow-y: auto;
}
.cap-text:focus { border-color: var(--primary); }
/* 底部按钮行固定末尾 */
.cap-sheet .m-row { flex: none; margin-top: 12px; }
/* 图片批注弹窗：顶部标题行（左标题 + 右"存/退"按钮） */
.cap-top {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 4px;
}
.cap-top .m-title { margin-bottom: 0; }
.cap-top-btns { display: flex; gap: 10px; }
.cap-tbtn {
  font-size: 17px; font-weight: 600; line-height: 1;
  padding: 6px 14px; border-radius: 20px; border: 1px solid var(--line);
  background: var(--card); color: var(--text-2); cursor: pointer;
}
.cap-tbtn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.cap-tbtn:active { transform: scale(.96); }
/* 底部按钮（清除/取消）：字号与标题一致 */
.cap-bbtn {
  flex: 1; font-size: 17px; font-weight: 500;
  padding: 10px 0; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); color: var(--text-2); cursor: pointer;
}
.cap-bbtn:active { transform: scale(.96); background: var(--bg); }
.cap-bbtn.primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }

/* ═══════════ Toast ═══════════ */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 26px);
  transform: translateX(-50%);
  background: rgba(20,20,28,.88); color: #fff;
  font-size: 14px; padding: 10px 18px; border-radius: 999px;
  z-index: 200; max-width: 82vw; text-align: center;
  animation: fadeIn .15s ease-out;
}
/* 鼓励文案：绿色系，弱动效 */
.toast.encourage {
  background: #e8f5e9; color: #2e7d32;
  border: 1px solid #a5d6a7; font-weight: 500;
  animation: fadeIn .2s ease-out;
}

/* ═══════════ REQ-009: 星光加载动画 ═══════════ */
.ai-err-detail {
  white-space: pre-wrap; word-break: break-all;
  background: #f6f6f8; border-radius: 8px; padding: 10px 12px;
  font-size: 12px; line-height: 1.55; color: #b00020;
  max-height: 52vh; overflow: auto; margin: 10px 0;
  user-select: text; -webkit-user-select: text;
}
@keyframes starSpin {
  0% { transform: rotate(0deg) scale(.6); opacity: .4; }
  50% { transform: rotate(180deg) scale(1); opacity: 1; }
  100% { transform: rotate(360deg) scale(.6); opacity: .4; }
}
.star-spin {
  display: inline-block; animation: starSpin 1.2s ease-in-out infinite;
}

/* 渐变主按钮 — 用于 AI 类按钮（蓝紫渐变统一） */
.btn-gradient {
  background: linear-gradient(135deg, #6366f1, #8b5cf6) !important;
  border: none; color: #fff;
}
.btn-gradient:active { filter: brightness(.92); }

/* ═══════════ 成长小记背景图片（设置-汇总明细） ═══════════ */
body.has-app-bg {
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}
/* 有背景时：底色容器透明化，让背景透出（白色内容卡片保持不透明） */
body.has-app-bg .topbar,
body.has-app-bg .actionbar,
body.has-app-bg .sum-bottom-bar { background: transparent; }

/* 有背景时：底部按钮（白底描边款）也透明化，与顶栏日期行一致 */
body.has-app-bg .actionbar .btn-secondary,
body.has-app-bg .sum-bottom-bar .btn-secondary {
  background: rgba(255,255,255,.55); backdrop-filter: blur(6px);
}

/* 有背景时：记录页输入控件半透明化（标题框/文本框/标签chip/select/润色按钮） */
body.has-app-bg .entry-title-input,
body.has-app-bg #entryText,
body.has-app-bg .chip,
body.has-app-bg .ai-style-select,
body.has-app-bg .ai-apply,
body.has-app-bg .tl-search input,
body.has-app-bg .sum-search input,
body.has-app-bg .sum-side-btn,
body.has-app-bg .tab,
body.has-app-bg .pref-input,
body.has-app-bg .pref-num,
body.has-app-bg .pref-select,
body.has-app-bg .deco-cell {
  background: rgba(255,255,255,.55); backdrop-filter: blur(6px);
}
/* 时间线卡片 / 分享汇总卡片 / 设置卡片：略高不透明度，保证内容可读 */
body.has-app-bg .tl-card,
body.has-app-bg .tl-card-inner,
body.has-app-bg .sum-card,
body.has-app-bg .sum-card-inner,
body.has-app-bg .sum-item,
body.has-app-bg .sum-preview,
body.has-app-bg .set-card {
  background: rgba(255,255,255,.7); backdrop-filter: blur(6px);
}
body.has-app-bg .ai-run { opacity: .88; }

/* 背景选择弹层：横滑缩略图行 */
.bg-row {
  display: flex; gap: 10px;
  overflow-x: auto; scrollbar-width: none;
  padding: 2px 2px 12px;
  touch-action: pan-x;   /* 横向滚动容器：允许浏览器处理横向手势 */
}
.bg-row::-webkit-scrollbar { display: none; }
.bg-thumb {
  flex: none; width: 88px; height: 156px;
  border-radius: 10px; border: 2px solid var(--line);
  object-fit: cover; background: var(--bg);
  display: block; cursor: pointer;
}
.bg-thumb.sel { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-weak); }
.bg-thumb-none {
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; color: var(--text-2); background: var(--bg);
}
.bg-thumb-custom {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; font-size: 12px; color: var(--text-2); overflow: hidden;
  background: var(--bg);
}

/* ═══════════ PC/鼠标适配（pointer:fine 限定，触摸设备零影响） ═══════════ */
/* 禁止鼠标原生拖起幽灵图（仅鼠标设备；不影响手机长按图片的系统菜单） */
@media (pointer: fine) {
  img { -webkit-user-drag: none; user-select: none; }
}

/* 宽屏 + 鼠标（浏览器宽窗 / 拉大 Electron 窗口；手机竖屏/横屏均为 coarse 不触发）：手机列居中 */
@media (min-width: 560px) and (pointer: fine) {
  body { background: #1f1f23; }
  .view {
    left: 0; right: 0; margin-inline: auto;
    max-width: 480px;
    box-shadow: 0 0 28px rgba(0,0,0,.45);
  }
  /* fixed inset:0 的全屏层同步收窄居中，遮罩不铺满宽屏 */
  .cal-backdrop, .camera-overlay, .modal-backdrop,
  .ai-pop-mask, .ase-backdrop, .viewer, .cap-backdrop {
    left: 50%; right: auto;
    width: 100%; max-width: 480px;
    transform: translateX(-50%);
  }
  #toast { max-width: 440px; }
}
.bg-thumb-custom img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
}
.bg-thumb-custom span { position: relative; z-index: 1; text-shadow: 0 0 4px #fff; }
