/* =====================================================
   习惯打卡 - 全局样式
   说明：颜色/圆角等统一走 CSS 变量；主题通过 data-theme 切换
   ===================================================== */

/* ---------- 极简（默认） ---------- */
:root {
  --bg: #f5f5f7;
  --page-grad: linear-gradient(180deg, #f7f7f8 0%, #f1f1f3 100%);
  --surface: #ffffff;
  --surface-2: #fafafb;
  --ink: #1a1a1c;
  --ink-2: #6e6e73;
  --ink-3: #a1a1a6;
  --line: #e8e8eb;
  --line-strong: #d8d8dd;
  --accent: #a67c52;
  --accent-strong: #8a6542;
  --accent-soft: rgba(166, 124, 82, .12);
  --accent-faint: rgba(166, 124, 82, .08);
  --on-accent: #ffffff;
  --btn-add: #1c1c1e;
  --btn-add-hover: #000000;
  --on-btn-add: #ffffff;
  --hover-bg: #efeff2;
  --row-done: #f4f4f5;
  --track-bg: #ececef;
  --fill-grad: linear-gradient(90deg, #bd9a6b 0%, #a67c52 100%);
  --card-grad: linear-gradient(180deg, #ffffff 0%, #fdfdfe 100%);
  --mask: rgba(20, 20, 24, .48);
  --danger: #c94f4f;
  --check-shadow: 0 3px 10px rgba(166, 124, 82, .32);
  --shadow-sm: 0 1px 2px rgba(16, 16, 20, .05), 0 10px 28px rgba(16, 16, 20, .05);
  --shadow-md: 0 2px 6px rgba(16, 16, 20, .06), 0 18px 44px rgba(16, 16, 20, .14);
  --r-lg: 18px;
  --r-md: 12px;
  --r-sm: 9px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
}

/* ---------- 粉色 ---------- */
html[data-theme="cute"] {
  --bg: #fdf6f3;
  --page-grad: linear-gradient(180deg, #fdf8f6 0%, #fbeef0 100%);
  --surface: #ffffff;
  --surface-2: #fff6f4;
  --ink: #4a3538;
  --ink-2: #9a7f84;
  --ink-3: #c4aeb2;
  --line: #f6e2df;
  --line-strong: #eccfc9;
  --accent: #e88795;
  --accent-strong: #d96f80;
  --accent-soft: rgba(232, 135, 149, .14);
  --accent-faint: rgba(232, 135, 149, .09);
  --on-accent: #3f2930;
  --btn-add: #e88795;
  --btn-add-hover: #d96f80;
  --on-btn-add: #ffffff;
  --hover-bg: #fdeeec;
  --row-done: #fdeeec;
  --track-bg: #f6e2df;
  --fill-grad: linear-gradient(90deg, #f2a6b1 0%, #e88795 100%);
  --card-grad: linear-gradient(180deg, #ffffff 0%, #fffbfa 100%);
  --mask: rgba(122, 74, 82, .42);
  --danger: #dd5f74;
  --check-shadow: 0 3px 10px rgba(232, 135, 149, .35);
  --shadow-sm: 0 1px 2px rgba(214, 122, 136, .08), 0 10px 26px rgba(214, 122, 136, .10);
  --shadow-md: 0 2px 6px rgba(214, 122, 136, .10), 0 18px 44px rgba(214, 122, 136, .16);
  --r-lg: 24px;
  --r-md: 16px;
  --r-sm: 12px;
}

/* 粉色：底色极淡圆点纹理（唯一装饰） */
html[data-theme="cute"] body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image: radial-gradient(rgba(232, 135, 149, .10) 1.2px, transparent 1.2px);
  background-size: 26px 26px;
}

/* ---------- 暗黑 / 护眼 ---------- */
html[data-theme="dark"] {
  --bg: #17171a;
  --page-grad: linear-gradient(180deg, #19191c 0%, #141417 100%);
  --surface: #202024;
  --surface-2: #26262b;
  --ink: #ececee;
  --ink-2: #9c9ca4;
  --ink-3: #6d6d74;
  --line: #2d2d32;
  --line-strong: #3b3b42;
  --accent: #c9a26b;
  --accent-strong: #d8b78a;
  --accent-soft: rgba(201, 162, 107, .16);
  --accent-faint: rgba(201, 162, 107, .10);
  --on-accent: #17171a;
  --btn-add: #ececee;
  --btn-add-hover: #ffffff;
  --on-btn-add: #17171a;
  --hover-bg: #28282d;
  --row-done: #1d1d21;
  --track-bg: #2c2c31;
  --fill-grad: linear-gradient(90deg, #d9b88a 0%, #c9a26b 100%);
  --card-grad: linear-gradient(180deg, #232327 0%, #202024 100%);
  --mask: rgba(0, 0, 0, .62);
  --danger: #f28482;
  --check-shadow: 0 3px 10px rgba(201, 162, 107, .30);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
  --shadow-md: 0 10px 40px rgba(0, 0, 0, .5);
  --r-lg: 18px;
  --r-md: 12px;
  --r-sm: 9px;
}

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

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

body {
  font-family: var(--font);
  background: var(--page-grad);
  color: var(--ink);
  padding: 30px 16px 64px;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.container { max-width: 720px; margin: 0 auto; }

[hidden] { display: none !important; }

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.brand { font-size: 24px; font-weight: 800; letter-spacing: .02em; }

.top-actions { position: relative; }
.theme-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: border-color .15s ease, color .15s ease;
}
.theme-btn:hover { border-color: var(--accent); color: var(--ink); }
.theme-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 1px var(--line);
}
.theme-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 150px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
  padding: 6px;
  z-index: 30;
}
.theme-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: none;
  border-radius: 8px;
  background: none;
  color: var(--ink-2);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
}
.theme-menu button:hover { background: var(--hover-bg); color: var(--ink); }
.theme-menu button.on { color: var(--ink); font-weight: 600; }
.opt-dot { width: 12px; height: 12px; border-radius: 50%; }
.dot-minimal { background: #a67c52; }
.dot-cute { background: #e88795; }
.dot-dark { background: #c9a26b; }

/* ---------- 主导航 ---------- */
.main-nav {
  display: flex;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 4px;
  margin-bottom: 20px;
}
.nav-item {
  flex: 1;
  text-align: center;
  padding: 9px 0;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-2);
  text-decoration: none;
  transition: background .15s ease, color .15s ease;
}
.nav-item:hover { color: var(--ink); }
.nav-item.active { background: var(--btn-add); color: var(--on-btn-add); }

.view[hidden] { display: none; }

/* ---------- 卡片与通用标题 ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
  overflow: hidden;
}
.card-title {
  font-size: 13px;
  color: var(--ink-2);
  font-weight: 600;
  letter-spacing: .08em;
  padding: 20px 24px 12px;
}
.eyebrow {
  font-size: 12px;
  color: var(--ink-3);
  font-weight: 600;
  letter-spacing: .08em;
}

/* 今日标记（签名元素） */
.day-chip {
  display: inline-flex;
  align-items: center;
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .02em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.day-chip.big { font-size: 15px; padding: 9px 18px; }

/* ---------- 今日进度 ---------- */
.progress-card { padding: 22px 24px 24px; background: var(--card-grad); }
.progress-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.progress-num { text-align: right; }
.progress-label {
  display: block;
  font-size: 11px;
  color: var(--ink-3);
  font-weight: 600;
  letter-spacing: .1em;
  margin-bottom: 3px;
}
.progress-text {
  font-size: 34px;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.01em;
}
.progress-track { height: 6px; background: var(--track-bg); border-radius: 999px; overflow: hidden; }
.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--fill-grad);
  border-radius: 999px;
  transition: width .6s cubic-bezier(.22, .61, .36, 1);
}

/* 整行可点打卡 */
.habit-item { cursor: pointer; }
.habit-actions { cursor: default; }
.modal-item.clickable { cursor: pointer; }
.modal-item.clickable:hover { background: var(--surface-2); }

/* ---------- 习惯列表 ---------- */
.habit-list { list-style: none; padding: 4px 0; }
.habit-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 15px 24px;
  transition: background .25s ease;
}
.habit-item + .habit-item { border-top: 1px solid var(--line); }
.habit-item:hover { background: var(--surface-2); }
.habit-item.done { background: var(--row-done); }

.habit-main { flex: 1; min-width: 0; }
.habit-name {
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color .25s ease;
}
.habit-item.done .habit-name {
  color: var(--ink-3);
  text-decoration: line-through;
  text-decoration-color: var(--line-strong);
}
.habit-stats { font-size: 12px; color: var(--ink-3); margin-top: 4px; font-variant-numeric: tabular-nums; }
.habit-item.done .habit-stats { opacity: .75; }

/* 打勾按钮 */
.check-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1.5px solid var(--line-strong);
  background: var(--surface);
  cursor: pointer;
  flex-shrink: 0;
  color: transparent;
  font-size: 14px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: border-color .2s ease, background .2s ease, color .2s ease, box-shadow .2s ease, transform .15s ease;
}
.check-btn:hover { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-faint); }
.check-btn:active { transform: scale(.9); }
.habit-item.done .check-btn {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
  box-shadow: var(--check-shadow);
}
.check-btn.small { width: 24px; height: 24px; font-size: 13px; }
.check-btn.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

/* 行内图标按钮 */
.habit-actions { display: flex; gap: 2px; flex-shrink: 0; }
.icon-btn {
  border: none;
  background: none;
  cursor: pointer;
  color: var(--ink-3);
  width: 30px;
  height: 30px;
  border-radius: var(--r-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: background .15s ease, color .15s ease;
}
.icon-btn:hover { background: var(--hover-bg); color: var(--ink-2); }

.rename-input {
  width: 100%;
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  color: var(--ink);
  border: 1.5px solid var(--accent);
  border-radius: 8px;
  padding: 5px 9px;
  outline: none;
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--accent-faint);
}

/* ---------- 添加习惯 ---------- */
.add-form {
  display: flex;
  gap: 10px;
  padding: 15px 24px 20px;
  border-top: 1px solid var(--line);
}
.add-form input {
  flex: 1;
  min-width: 0;
  padding: 11px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  font-size: 14px;
  font-family: inherit;
  color: var(--ink);
  background: var(--surface-2);
  outline: none;
  transition: border-color .2s ease, background .2s ease, box-shadow .2s ease;
}
.add-form input::placeholder { color: var(--ink-3); }
.add-form input:focus {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--accent-faint);
}
.btn-add {
  background: var(--btn-add);
  color: var(--on-btn-add);
  border: none;
  padding: 0 22px;
  border-radius: var(--r-sm);
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: background .2s ease, transform .1s ease;
}
.btn-add:hover { background: var(--btn-add-hover); }
.btn-add:active { transform: scale(.98); }

.empty-tip { text-align: center; color: var(--ink-3); padding: 30px 20px 14px; font-size: 14px; }

/* ---------- 日历 ---------- */
.calendar-card { padding-bottom: 18px; }
.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px 0;
}
.cal-header .card-title { padding: 0; }
.cal-nav {
  border: 1px solid transparent;
  background: none;
  font-size: 20px;
  color: var(--ink-2);
  width: 34px;
  height: 34px;
  border-radius: var(--r-sm);
  cursor: pointer;
  line-height: 1;
  transition: background .15s ease, color .15s ease;
}
.cal-nav:hover { background: var(--hover-bg); color: var(--ink); }
.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  padding: 12px 20px 6px;
}
.cal-weekdays span {
  text-align: center;
  font-size: 11px;
  color: var(--ink-3);
  font-weight: 500;
  letter-spacing: .06em;
}
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  padding: 4px 20px 12px;
}
.cal-day {
  aspect-ratio: 1 / 1;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px solid transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: border-color .15s ease, background .15s ease;
}
.cal-day:hover:not(.blank):not(.future) { border-color: var(--accent); }
.cal-day.blank { cursor: default; background: transparent; }
.cal-day.future { color: var(--ink-3); cursor: default; background: transparent; opacity: .55; }
.cal-day.today { box-shadow: inset 0 0 0 1.5px var(--accent); }
.cal-num { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.cal-frac {
  font-size: 10px;
  color: var(--accent-strong);
  margin-top: 1px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed;
  inset: 0;
  background: var(--mask);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
  backdrop-filter: blur(4px);
}
.modal {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-md);
  overflow: hidden;
  animation: modal-in .22s cubic-bezier(.22, .61, .36, 1);
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(8px) scale(.98); }
  to { opacity: 1; transform: none; }
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
}
.modal-head h3 { font-size: 15px; font-weight: 700; }
.modal-close {
  border: none;
  background: none;
  font-size: 24px;
  color: var(--ink-3);
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
  border-radius: 6px;
}
.modal-close:hover { color: var(--ink); }
.modal-list { list-style: none; padding: 6px 0; max-height: 60vh; overflow-y: auto; }
.modal-item { display: flex; align-items: center; gap: 14px; padding: 13px 22px; }
.modal-item .habit-name { flex: 1; font-size: 15px; }
.modal-item.done .habit-name {
  color: var(--ink-3);
  text-decoration: line-through;
  text-decoration-color: var(--line-strong);
}

/* ================= 笔记页 ================= */

/* 分区页签 */
.notes-tabs {
  display: inline-flex;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px;
  margin-bottom: 16px;
}
.notes-tab {
  border: none;
  background: none;
  padding: 7px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  color: var(--ink-2);
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.notes-tab:hover { color: var(--ink); }
.notes-tab.active { background: var(--accent); color: var(--on-accent); }

/* 全部笔记：双栏 */
.notes-layout {
  display: grid;
  grid-template-columns: 250px 1fr;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  min-height: 440px;
}
.note-side { border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.note-side-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--line);
}
.btn-new {
  border: none;
  background: var(--accent);
  color: var(--on-accent);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s ease;
}
.btn-new:hover { background: var(--accent-strong); }
.note-list { list-style: none; padding: 8px; overflow-y: auto; max-height: 520px; }
.note-list-item {
  padding: 10px 12px;
  border-radius: var(--r-md);
  cursor: pointer;
  margin-bottom: 2px;
}
.note-list-item:hover { background: var(--hover-bg); }
.note-list-item.active { background: var(--accent-soft); }
.note-item-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.note-list-item .note-item-title.empty { color: var(--ink-3); font-weight: 500; }
.note-item-meta { font-size: 11px; color: var(--ink-3); margin-top: 3px; font-variant-numeric: tabular-nums; }
.note-list-empty { color: var(--ink-3); text-align: center; padding: 24px 12px; font-size: 13px; }

.note-main { display: flex; flex-direction: column; min-width: 0; }
.note-empty-hint {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-3);
  text-align: center;
  padding: 40px;
  font-size: 14px;
}

/* 编辑器 */
.note-editor { display: flex; flex-direction: column; height: 100%; padding: 18px 22px 20px; }
.editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 10px;
}
.editor-title {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  color: var(--ink);
  font-size: 20px;
  font-weight: 700;
  font-family: inherit;
  padding: 2px 0;
}
.editor-title::placeholder { color: var(--ink-3); }
/* 阅读模式：标题像普通标题，正文不可编辑 */
.editor-title.viewing {
  font-size: 20px;
  font-weight: 700;
  cursor: default;
}
.rich-body.viewing {
  cursor: default;
  user-select: text;
}
.editor-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.editor-status { font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.text-btn {
  border: none;
  background: none;
  cursor: pointer;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  padding: 8px 10px;
  border-radius: 8px;
  transition: background .15s ease, color .15s ease;
}
.text-btn:hover { background: var(--hover-bg); color: var(--ink); }
.text-btn.danger { color: var(--danger); }
.text-btn.danger:hover { background: rgba(201, 79, 79, .10); }

/* 富文本工具栏 */
.toolbar {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.tool-btn {
  min-width: 30px;
  height: 30px;
  padding: 0 6px;
  border: none;
  background: none;
  border-radius: 8px;
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.tool-btn:hover { background: var(--hover-bg); color: var(--ink); }

/* 正文编辑区 */
.rich-body {
  flex: 1;
  min-height: 240px;
  padding: 12px 2px 8px;
  outline: none;
  font-size: 15px;
  line-height: 1.8;
  color: var(--ink);
  overflow-y: auto;
  max-height: 60vh;
}
.rich-body:empty::before { content: attr(data-placeholder); color: var(--ink-3); pointer-events: none; }
.rich-body h2 { font-size: 20px; margin: 18px 0 8px; line-height: 1.4; }
.rich-body h3 { font-size: 17px; margin: 14px 0 6px; line-height: 1.4; }
.rich-body p { margin: 0 0 10px; }
.rich-body ul, .rich-body ol { margin: 0 0 10px; padding-left: 24px; }
.rich-body li { margin-bottom: 3px; }
.rich-body hr { border: none; border-top: 1px solid var(--line-strong); margin: 14px 0; }
.rich-body a { color: var(--accent-strong); }
/* 正文里的图片：自适应宽度、独立成块，避免撑破编辑框 */
.rich-body img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 10px auto;
  border-radius: 8px;
}

/* 日记 */
.diary-pane { }
.diary-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 10px;
}
.day-nav {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition: border-color .15s ease, color .15s ease, background .15s ease;
}
.day-nav:hover { border-color: var(--accent); color: var(--accent-strong); background: var(--surface-2); }
.diary-today-row {
  display: flex;
  justify-content: center;
  margin-bottom: 14px;
  min-height: 24px;
}
.diary-card { padding: 0; }
.diary-body { min-height: 300px; }

/* ---------- 键盘焦点 ---------- */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input:focus-visible, .rich-body:focus-visible { outline: none; }

/* ---------- 动效偏好 ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* ---------- 小屏适配 ---------- */
@media (max-width: 620px) {
  body { padding: 22px 12px 48px; }
  .habit-item { padding: 14px 18px; }
  .add-form, .progress-card, .note-editor { padding-left: 18px; padding-right: 18px; }
  .cal-grid, .cal-weekdays, .card-title { padding-left: 18px; padding-right: 18px; }
  .notes-layout { grid-template-columns: 1fr; }
  .note-side { border-right: none; border-bottom: 1px solid var(--line); }
  .note-list { max-height: 180px; }
  .progress-text { font-size: 30px; }
}

/* 工具栏分隔线 */
.tool-sep { width: 1px; height: 18px; background: var(--line); margin: 0 6px; align-self: center; flex-shrink: 0; }

/* ================= 粉色主题修饰 / 日记空状态 ================= */

/* 品牌：标志位与文字对齐 */
.brand { display: inline-flex; align-items: center; gap: 8px; }
.brand-mark { display: none; color: var(--accent); flex-shrink: 0; }
/* 进度卡需要相对定位以容纳角标 */
.progress-card { position: relative; }

/* 日记：空状态卡片 */
.diary-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 52px 20px;
  text-align: center;
}
.diary-empty-icon { font-size: 30px; line-height: 1; color: var(--accent); }
.diary-empty-text { font-size: 16px; font-weight: 700; color: var(--ink); }
.diary-empty-sub { font-size: 13px; color: var(--ink-3); margin-bottom: 8px; }

/* ============ 粉色主题专属修饰 ============ */
html[data-theme="cute"] .brand-mark { display: block; animation: cat-in .5s ease both; }
@keyframes cat-in { from { transform: scale(.6) rotate(-8deg); opacity: 0; } to { transform: none; opacity: 1; } }

/* 日期徽标前加一颗心 */
html[data-theme="cute"] .day-chip::before {
  content: "♥";
  margin-right: 6px;
  font-size: .85em;
}
/* 卡片小标题后加一颗空心爱心 */
html[data-theme="cute"] .card-title::after {
  content: " ♡";
  color: var(--accent);
  font-weight: 400;
  opacity: .75;
}
/* 空状态上方加爱心 */
html[data-theme="cute"] .empty-tip::before,
html[data-theme="cute"] .note-empty-hint p::before {
  content: "♡";
  display: block;
  font-size: 26px;
  color: var(--accent);
  opacity: .6;
  margin-bottom: 10px;
}
/* 进度卡右下角小爱心角标 */
html[data-theme="cute"] .progress-card::after {
  content: "♥";
  position: absolute;
  right: 18px;
  bottom: 14px;
  font-size: 14px;
  color: var(--accent);
  opacity: .45;
}
/* 日记空状态图标：粉色主题用爱心代替铅笔 */
html[data-theme="cute"] .diary-empty-icon {
  color: transparent;
}
html[data-theme="cute"] .diary-empty-icon::before {
  content: "♡";
  font-size: 34px;
  color: var(--accent);
}
/* 粉色主题：打勾后圆圈内保留 ✓，但完成行加一点腮红般的柔光 */
html[data-theme="cute"] .habit-item.done .check-btn {
  box-shadow: 0 3px 12px rgba(232, 135, 149, .45);
}

/* ================= 夜晚粉色主题 ================= */
html[data-theme="cute-dark"] {
  --bg: #22171a;
  --page-grad: linear-gradient(180deg, #261a1e 0%, #1e1417 100%);
  --surface: #2b1e22;
  --surface-2: #332428;
  --ink: #f3e9ea;
  --ink-2: #b79aa0;
  --ink-3: #7e5f66;
  --line: #3a292d;
  --line-strong: #4a3439;
  --accent: #e88795;
  --accent-strong: #f0a3ad;
  --accent-soft: rgba(232, 135, 149, .18);
  --accent-faint: rgba(232, 135, 149, .11);
  --on-accent: #2a1a1e;
  --btn-add: #e88795;
  --btn-add-hover: #f0a3ad;
  --on-btn-add: #2a1a1e;
  --hover-bg: #332428;
  --row-done: #24181b;
  --track-bg: #3a292d;
  --fill-grad: linear-gradient(90deg, #f0a3ad 0%, #e88795 100%);
  --card-grad: linear-gradient(180deg, #2f2125 0%, #2b1e22 100%);
  --mask: rgba(0, 0, 0, .62);
  --danger: #f2849a;
  --check-shadow: 0 3px 10px rgba(232, 135, 149, .35);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-md: 0 10px 40px rgba(0, 0, 0, .55);
  --r-lg: 22px;
  --r-md: 15px;
  --r-sm: 11px;
}
html[data-theme="cute-dark"] body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image: radial-gradient(rgba(232, 135, 149, .08) 1.2px, transparent 1.2px);
  background-size: 26px 26px;
}

/* ================= 粉色/夜晚粉色 通用修饰 ================= */
html[data-theme="cute-dark"] .brand-mark { display: block; }
html[data-theme="cute-dark"] .day-chip::before { content: "♥"; margin-right: 6px; font-size: .85em; }
html[data-theme="cute-dark"] .card-title::after { content: " ♡"; color: var(--accent); font-weight: 400; opacity: .75; }
html[data-theme="cute-dark"] .empty-tip::before,
html[data-theme="cute-dark"] .note-list-empty::before { content: "♡"; display: block; font-size: 26px; color: var(--accent); opacity: .6; margin-bottom: 10px; }
html[data-theme="cute-dark"] .progress-card::after { content: "♥"; position: absolute; right: 18px; bottom: 14px; font-size: 14px; color: var(--accent); opacity: .45; }
html[data-theme="cute-dark"] .diary-empty-icon { color: transparent; }
html[data-theme="cute-dark"] .diary-empty-icon::before { content: "♡"; font-size: 34px; color: var(--accent); }
html[data-theme="cute-dark"] .habit-item.done .check-btn { box-shadow: 0 3px 12px rgba(232, 135, 149, .45); }

/* 主题菜单稍宽以容纳更多选项 */
.theme-menu { min-width: 176px; }

/* 自动主题圆点：半色 */
.dot-auto { background: linear-gradient(90deg, #a67c52 0 50%, #c9a26b 50% 100%); }
.dot-auto-cute { background: linear-gradient(90deg, #e88795 0 50%, #b35a6c 50% 100%); }

/* ================= 全屏编辑弹窗（新建笔记 / 写日记） ================= */
.compose { display: flex; flex-direction: column; max-width: 620px; width: 100%; max-height: 82vh; }
.compose-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 18px 22px 8px; border-bottom: 1px solid var(--line); }
.compose-title-area { flex: 1; min-width: 0; display: flex; align-items: center; }
.compose .editor-title { font-size: 20px; }
.compose .toolbar { border: none; border-bottom: 1px solid var(--line); padding: 8px 22px; }
.compose .rich-body { padding: 14px 22px; min-height: 240px; }
.compose-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 22px 16px;
  border-top: 1px solid var(--line);
}
.compose-foot .editor-status { margin-right: auto; }
.compose-foot .btn-add { border-radius: 999px; padding: 0 22px; height: 34px; }

/* ================= 全部笔记：仅列表卡片 ================= */
.notes-list-card { display: flex; flex-direction: column; }
.notes-list-card .note-list { max-height: 60vh; }

/* ================= 日记：空状态 / 已记录 ================= */
.diary-empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 52px 20px; text-align: center; }
.diary-empty-icon { font-size: 30px; line-height: 1; color: var(--accent); }
.diary-empty-text { font-size: 16px; font-weight: 700; }
.diary-empty-sub { font-size: 13px; color: var(--ink-3); margin-bottom: 8px; }
.diary-has {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 46px 20px;
  text-align: center;
}
.diary-has-icon { font-size: 30px; line-height: 1; color: var(--accent); }
.diary-has-text { font-size: 16px; font-weight: 700; }
.diary-has-meta { font-size: 13px; color: var(--ink-3); }
.diary-has-actions { display: flex; gap: 10px; align-items: center; margin-top: 10px; }
/* 日记阅读区：复用富文本样式，但去掉编辑器的尺寸限制 */
.diary-view.rich-body {
  flex: none;
  align-self: stretch;
  width: 100%;
  min-height: 0;
  max-height: none;
  overflow: visible;
  padding: 2px 0 0;
  text-align: left;
  overflow-wrap: anywhere;
}
.diary-view.rich-body img { margin-left: 0; margin-right: 0; }

/* 全部笔记：头部操作 + 按日期浏览 */
.note-side-actions { display: flex; align-items: center; gap: 8px; }
.notes-date-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}
.notes-date-bar .day-chip { padding: 6px 12px; font-size: 12px; cursor: default; }
.day-nav.sm { width: 28px; height: 28px; font-size: 15px; }
.text-btn.on { color: var(--accent-strong); background: var(--accent-soft); }
.note-list-empty { padding: 30px 12px; }


/* 夜晚粉色主题圆点颜色（与“自动·粉色”右半侧一致） */
.dot-cute-dark { background: #b35a6c; }


/* ================= 日期选择弹窗 ================= */
.picker { width: 100%; max-width: 330px; padding-bottom: 8px; }
.picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 4px;
}
.picker-head h3 { font-size: 15px; font-weight: 700; }
.picker .cal-weekdays { padding: 8px 16px 4px; }
.picker .cal-grid { padding: 2px 16px 8px; }
.picker .cal-day { font-size: 13px; }
.picker-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 14px 8px;
}

/* 可点击的日期徽标（笔记/日记） */
button.day-chip { cursor: pointer; transition: transform .1s ease, box-shadow .15s ease; }
button.day-chip:hover { box-shadow: 0 0 0 3px var(--accent-faint); }
button.day-chip:active { transform: scale(.96); }


/* 日期选择弹窗：当前选中日期 */
.cal-day.sel {
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 700;
}
.cal-day.sel .cal-num { color: inherit; }


/* ================= 顶栏：日夜切换 + 菜单按钮 ================= */
.top-actions { display: flex; align-items: center; gap: 8px; }
.mode-btn, .menu-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: border-color .15s ease, color .15s ease, background .15s ease;
}
.mode-btn:hover, .menu-btn:hover { border-color: var(--accent); color: var(--ink); background: var(--surface-2); }

/* ================= 设置侧边栏（左侧抽屉） ================= */
.drawer-mask {
  position: fixed;
  inset: 0;
  background: var(--mask);
  z-index: 60;
}
.drawer {
  position: fixed;
  top: 0;
  left: 0;
  height: 100%;
  width: min(300px, 85vw);
  background: var(--surface);
  border-right: 1px solid var(--line);
  box-shadow: var(--shadow-md);
  z-index: 61;
  display: flex;
  flex-direction: column;
  transform: translateX(-102%);
  transition: transform .26s cubic-bezier(.22, .61, .36, 1);
}
.drawer.open { transform: none; }
.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 12px;
  border-bottom: 1px solid var(--line);
}
.drawer-head h2 { font-size: 17px; font-weight: 700; }
.drawer-close {
  border: none;
  background: none;
  font-size: 24px;
  color: var(--ink-3);
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
  border-radius: 6px;
}
.drawer-close:hover { color: var(--ink); }
.drawer-body { padding: 6px 20px 24px; overflow-y: auto; }
.set-title {
  font-size: 12px;
  color: var(--ink-3);
  font-weight: 600;
  letter-spacing: .1em;
  margin: 18px 0 6px;
}
.set-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.set-label { font-size: 14px; font-weight: 500; }
.set-hint { font-size: 12px; color: var(--ink-3); line-height: 1.6; margin-top: 12px; }

/* 分段选择（日间/夜间主题） */
.seg {
  display: inline-flex;
  gap: 3px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
}
.seg button {
  border: none;
  background: none;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  color: var(--ink-2);
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.seg button:hover { color: var(--ink); }
.seg button.active { background: var(--accent); color: var(--on-accent); }

/* 跟随系统开关 */
.switch {
  position: relative;
  width: 46px;
  height: 26px;
  border: none;
  border-radius: 999px;
  background: var(--line-strong);
  cursor: pointer;
  transition: background .2s ease;
  flex-shrink: 0;
}
.switch .knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
  transition: left .2s ease;
}
.switch.on { background: var(--accent); }
.switch.on .knob { left: 23px; }


/* ================= 顶栏：按钮靠左 + 可自定义标题 ================= */
.topbar { display: flex; align-items: center; gap: 8px; }
.top-actions { gap: 6px; }
.brand {
  margin-left: 4px;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* 名称输入框 */
.set-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  font-size: 14px;
  font-family: inherit;
  color: var(--ink);
  background: var(--surface-2);
  outline: none;
  transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}
.set-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-faint);
  background: var(--surface);
}


/* 按钮式日期徽标：去掉浏览器默认边框/外观，跟随主题更干净 */
button.day-chip {
  -webkit-appearance: none;
  appearance: none;
  border: none;
  font-family: inherit;
}
button.day-chip:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}


/* 粉色主题：日记空状态爱心居中对齐（隐藏原铅笔字符占位） */
html[data-theme="cute"] .diary-empty-icon,
html[data-theme="cute-dark"] .diary-empty-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: transparent;
  font-size: 0;
  line-height: 1;
}
html[data-theme="cute"] .diary-empty-icon::before,
html[data-theme="cute-dark"] .diary-empty-icon::before {
  content: "♡";
  display: inline-block;
  font-size: 34px;
  line-height: 1;
  color: var(--accent);
}


/* ================= 富文本工具栏：分组、按钮与下拉 ================= */
.tool-btn {
  min-width: 36px;
  height: 32px;
  padding: 0 8px;
  border-radius: 8px;
  font-size: 13px;
}
.tool-btn.tb-bold { font-weight: 800; }
.tool-btn.tb-italic { font-style: italic; font-family: Georgia, "Times New Roman", serif; }
.tool-btn.tb-underline { text-decoration: underline; text-underline-offset: 2px; }
.tool-select {
  height: 30px;
  min-width: 68px;
  max-width: 108px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  outline: none;
}
.tool-select:hover { color: var(--ink); }
.tool-select:focus { border-color: var(--accent); }

/* “更多格式”菜单：低频格式收起来，工具栏更简洁 */
.tool-more { position: relative; display: inline-flex; }
.tool-btn.tb-more { font-size: 17px; font-weight: 700; padding-bottom: 6px; }
/* 拍照按钮：仅触屏设备显示（电脑上没有意义） */
.tool-btn.tb-camera { display: none; }
@media (hover: none) and (pointer: coarse) {
  .tool-btn.tb-camera { display: inline-flex; align-items: center; justify-content: center; }
}
.tool-more-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 30;
  min-width: 140px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.tool-more-item {
  border: none;
  background: none;
  text-align: left;
  padding: 6px 10px;
  border-radius: var(--r-sm);
  color: var(--ink);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
}
.tool-more-item:hover { background: var(--hover-bg); }

/* execCommand fontSize 生成的 <font size> 大小映射 */
.rich-body font[size="1"] { font-size: 12px; }
.rich-body font[size="2"] { font-size: 14px; }
.rich-body font[size="3"] { font-size: 16px; }
.rich-body font[size="4"] { font-size: 18px; }
.rich-body font[size="5"] { font-size: 20px; }
.rich-body font[size="6"] { font-size: 24px; }
.rich-body font[size="7"] { font-size: 26px; }


/* ================= 移动端防聚焦放大 ================= */
/* iOS 在聚焦字号 <16px 的输入框/编辑区时会自动放大页面；
   把手机端的正文与输入字号提到 16px，即可避免（仍保留手动缩放） */
@media (max-width: 900px) {
  .rich-body { font-size: 16px; line-height: 1.8; }
  .add-form input { font-size: 16px; }
  .set-input { font-size: 16px; }
  .editor-title { font-size: 18px; }

  /* 编辑弹窗：内容保持屏幕居中；键盘弹出时居中区域自动上移 */
  #composeModal {
    align-items: center;
    padding: 12px;
    padding-bottom: calc(12px + var(--kb, 0px));
  }
  #composeModal .compose {
    width: 100%;
    max-width: none;
    max-height: calc(100vh - var(--kb, 0px) - 24px);
    max-height: calc(100dvh - var(--kb, 0px) - 24px);
    margin-bottom: 0;
    border-radius: var(--r-lg);
  }
  /* 字体工具栏放在编辑小窗内部底部：键盘弹出时显示，收起时隐藏 */
  #composeModal .compose .rich-body { order: 2; }
  #composeModal .compose .toolbar {
    order: 3;
    display: none;
    position: relative;
    left: auto;
    right: auto;
    bottom: auto;
    z-index: 1;
    border-top: 1px solid var(--line);
    border-bottom: none;
    padding: 8px 12px;
    background: var(--surface);
    box-shadow: none;
  }
  #composeModal .compose .compose-foot { order: 4; }
  #composeModal.kb-open .compose .toolbar { display: flex; }
  /* 手机端“更多”菜单：显示在工具栏上方 */
  #composeModal .tool-more-menu {
    position: absolute;
    left: auto;
    right: 6px;
    top: auto;
    bottom: calc(100% + 6px);
    width: 148px;
    max-height: 40vh;
    overflow-y: auto;
    padding: 4px;
  }
}


/* ================= 深色模式手机白边修复 ================= */
/* 手机上下拉动时露出的最外层背景跟随主题，避免深色下露白边 */
html { background-color: var(--bg); }
body { background-color: var(--bg); }


/* ================= 主题切换边缘颜色修复 ================= */
/* 背景统一放到最外层 html（fixed），body 透出，避免上下露不同色 */
html {
  background-color: var(--bg);
  background-image: var(--page-grad);
  background-attachment: fixed;
}
body {
  background: none;
}
/* 刘海屏 / 底部手势条安全区 */
body {
  padding-top: calc(30px + env(safe-area-inset-top, 0px));
  padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
}
@media (max-width: 620px) {
  body {
    padding-top: calc(22px + env(safe-area-inset-top, 0px));
    padding-bottom: calc(48px + env(safe-area-inset-bottom, 0px));
  }
}


/* ================= 移动端缩放锁定 ================= */
/* 关闭双指缩放与双击缩放（iPhone 浏览器 / 添加到桌面后的独立窗口） */
html, body {
  touch-action: pan-x pan-y;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* 工具栏按钮：激活（当前文字处于该样式）高亮 */
.tool-btn.active {
  background: var(--accent);
  color: var(--on-accent);
}


/* 导航按钮（替代链接，避免外跳浏览器） */
button.nav-item { border: none; font-family: inherit; cursor: pointer; }


/* 删除确认小弹窗 */
.confirm-modal { max-width: 360px; padding: 24px 22px 18px; text-align: center; }
.confirm-text { font-size: 15px; line-height: 1.7; color: var(--ink); margin-bottom: 20px; }
.confirm-actions { display: flex; justify-content: center; gap: 10px; }
.confirm-actions .text-btn { padding: 8px 18px; border-radius: 999px; font-size: 14px; }
.btn-danger {
  border: none;
  background: var(--danger);
  color: #fff;
  padding: 8px 22px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: filter .15s ease;
}
.btn-danger:hover { filter: brightness(1.08); }


/* 删除确认框置顶：避免被编辑小方框等遮住 */
#confirmModal { z-index: 90; }


/* 设置：更新区样式 */
.set-value { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.set-row.column { flex-direction: column; align-items: flex-start; gap: 8px; }
.set-row.column .btn-new { align-self: flex-start; }
#updateStatus { word-break: break-word; }

/* =====================================================
   视觉升级：纸上刻度
   方向：安静的每日仪式。日期与数字用衬线，进度条做成刻度尺。
   仅调整外观，不改动结构与功能。
   ===================================================== */

/* ---------- 令牌精修：极简（默认） ---------- */
:root {
  --bg: #f4f4f6;
  --page-grad: radial-gradient(1100px 560px at 50% -12%, #fbfbfc 0%, #f4f4f6 58%, #efeff2 100%);
  --surface: #ffffff;
  --surface-2: #f8f8fa;
  --ink: #17171a;
  --ink-2: #5f5f68;
  --ink-3: #6f6f78;
  --line: #e6e6ea;
  --line-strong: #d4d4db;
  --accent: #a1733d;
  --accent-strong: #7d5628;
  --accent-soft: rgba(161, 115, 61, .12);
  --accent-faint: rgba(161, 115, 61, .07);
  --hover-bg: #f0f0f3;
  --row-done: #f5f5f6;
  --track-bg: #eaeaee;
  --fill-grad: linear-gradient(90deg, #bb8f5c 0%, #a1733d 100%);
  --card-grad: linear-gradient(180deg, #ffffff 0%, #fdfdfe 100%);
  --shadow-sm: 0 1px 2px rgba(18, 18, 22, .04), 0 8px 20px rgba(18, 18, 22, .045);
  --shadow-md: 0 2px 4px rgba(18, 18, 22, .05), 0 18px 40px rgba(18, 18, 22, .12);
  --r-lg: 16px;
  --r-md: 12px;
  --r-sm: 8px;
  --font-display: "Songti SC", "STSong", "Noto Serif CJK SC", "Source Han Serif SC", "SimSun", Georgia, serif;
  --focus-ring: 0 0 0 3px var(--accent-soft);
  --danger: #c04a4a;
}

/* ---------- 令牌精修：粉色 / 暗黑 / 夜晚粉色 ---------- */
html[data-theme="cute"] {
  --bg: #fbf3f4;
  --page-grad: radial-gradient(1000px 520px at 50% -10%, #fff9f9 0%, #fbf3f4 60%, #f8ecef 100%);
  --surface-2: #fff7f7;
  --ink: #43303a;
  --ink-2: #7f666f;
  --ink-3: #8f757e;
  --line: #f0dfe3;
  --line-strong: #e3cbd2;
  --accent: #dd7f92;
  --accent-strong: #b3566d;
  --accent-soft: rgba(221, 127, 146, .14);
  --accent-faint: rgba(221, 127, 146, .08);
  --btn-add: #b3566d;
  --btn-add-hover: #9d4a60;
  --danger: #c04a60;
  --fill-grad: linear-gradient(90deg, #eda3b1 0%, #dd7f92 100%);
  --shadow-sm: 0 1px 2px rgba(176, 92, 110, .06), 0 8px 20px rgba(176, 92, 110, .07);
  --shadow-md: 0 2px 4px rgba(176, 92, 110, .08), 0 18px 38px rgba(176, 92, 110, .13);
  --r-lg: 18px;
  --r-md: 13px;
  --r-sm: 9px;
}
html[data-theme="dark"] {
  --bg: #151518;
  --page-grad: radial-gradient(1000px 520px at 50% -10%, #1c1c21 0%, #161619 58%, #121215 100%);
  --surface: #1e1e22;
  --surface-2: #242429;
  --ink: #ececef;
  --ink-2: #a0a0a8;
  --ink-3: #74747c;
  --line: #2c2c33;
  --line-strong: #3a3a43;
  --accent: #c8a066;
  --accent-strong: #dcb684;
  --accent-soft: rgba(200, 160, 102, .16);
  --accent-faint: rgba(200, 160, 102, .09);
  --track-bg: #2a2a30;
  --row-done: #1b1b1f;
  --card-grad: linear-gradient(180deg, #222227 0%, #1e1e22 100%);
  --shadow-sm: 0 1px 0 rgba(255, 255, 255, .02), 0 10px 24px rgba(0, 0, 0, .3);
  --shadow-md: 0 2px 6px rgba(0, 0, 0, .4), 0 22px 48px rgba(0, 0, 0, .5);
  --focus-ring: 0 0 0 3px rgba(200, 160, 102, .22);
}
html[data-theme="cute-dark"] {
  --bg: #1d1417;
  --page-grad: radial-gradient(900px 480px at 50% -10%, #292025 0%, #1e1518 58%, #191114 100%);
  --surface: #251b1f;
  --surface-2: #2d2126;
  --ink: #f2e8ea;
  --ink-2: #b2959d;
  --ink-3: #9a7b83;
  --line: #37262b;
  --line-strong: #49343a;
  --accent: #e392a3;
  --accent-strong: #f0aeb9;
  --accent-soft: rgba(227, 146, 163, .18);
  --accent-faint: rgba(227, 146, 163, .1);
  --track-bg: #38272c;
  --row-done: #201619;
  --card-grad: linear-gradient(180deg, #2a1f23 0%, #251b1f 100%);
  --shadow-sm: 0 1px 0 rgba(255, 255, 255, .02), 0 10px 24px rgba(0, 0, 0, .32);
  --shadow-md: 0 2px 6px rgba(0, 0, 0, .42), 0 22px 48px rgba(0, 0, 0, .52);
  --r-lg: 18px;
  --r-md: 13px;
  --r-sm: 9px;
  --focus-ring: 0 0 0 3px rgba(227, 146, 163, .24);
}

/* ---------- 排版：日期与数字有性格 ---------- */
.day-chip,
.progress-text,
.editor-title,
#calTitle {
  font-family: var(--font-display);
}
.progress-text { font-size: 36px; font-weight: 700; letter-spacing: .01em; }
.progress-label,
.set-title,
.eyebrow { letter-spacing: .14em; }
.day-chip {
  border: 1px solid color-mix(in srgb, var(--accent) 26%, transparent);
  letter-spacing: .02em;
}

/* ---------- 签名元素：进度刻度尺 ---------- */
.progress-track {
  height: 8px;
  background-color: var(--track-bg);
  background-image:
    linear-gradient(var(--line-strong), var(--line-strong)),
    linear-gradient(var(--line-strong), var(--line-strong)),
    linear-gradient(var(--line-strong), var(--line-strong));
  background-size: 1px 42%;
  background-position: 25% 50%, 50% 50%, 75% 50%;
  background-repeat: no-repeat;
  border-radius: 999px;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .02);
}
.progress-fill { box-shadow: 0 0 10px color-mix(in srgb, var(--accent) 34%, transparent); }

/* ---------- 容器与导航 ---------- */
.card {
  background: var(--card-grad);
  border-color: var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.main-nav {
  border-radius: 12px;
  padding: 3px;
  box-shadow: var(--shadow-sm);
}
.nav-item {
  border-radius: 9px;
  letter-spacing: .02em;
}
.nav-item.active { box-shadow: 0 1px 2px rgba(0, 0, 0, .18); }

/* ---------- 习惯列表 ---------- */
.habit-item { gap: 14px; padding: 14px 22px; }
.habit-name { letter-spacing: .005em; }
.habit-stats { letter-spacing: .02em; }
.check-btn {
  width: 30px;
  height: 30px;
  transition: transform .16s ease, box-shadow .2s ease, background .2s ease, border-color .2s ease;
}
.check-btn:hover { transform: scale(1.05); }
.habit-item.done .habit-name { text-decoration-thickness: 1px; text-underline-offset: 3px; }

/* ---------- 日历 ---------- */
.cal-day { border-radius: 9px; transition: background .16s ease; }
.cal-day:not(.blank):hover { background: var(--hover-bg); }
.cal-day.today { box-shadow: inset 0 0 0 1.5px var(--accent); }

/* ---------- 笔记与编辑器 ---------- */
.note-list-item { border-radius: 10px; padding: 11px 12px; }
.note-item-title { letter-spacing: .01em; }
.note-item-meta { letter-spacing: .03em; }
.editor-title { letter-spacing: .015em; }
.compose .rich-body { font-size: 15.5px; line-height: 1.85; }

/* ---------- 设置抽屉 ---------- */
.drawer { box-shadow: var(--shadow-md); }
.set-row { padding: 12px 0; }

/* 笔记标题是无边框输入框，聚焦时不要出现方框 */
.editor-title,
.editor-title:focus,
.editor-title:focus-visible {
  box-shadow: none;
  outline: none;
}

/* ---------- 通用细节 ---------- */
.btn-add,
.btn-new,
.text-btn { letter-spacing: .02em; }
.btn-add,
.btn-new { transition: background .18s ease, transform .12s ease, box-shadow .18s ease; }
.btn-add:active,
.btn-new:active { transform: translateY(1px); }
.empty-tip,
.note-list-empty { letter-spacing: .02em; }
:where(button, input, select, [contenteditable="true"]):focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* =====================================================
   去掉所有聚焦方框与焦点环
   ===================================================== */
:focus-visible { outline: none; }
button.day-chip:focus-visible { outline: none; }
.add-form input:focus,
.set-input:focus,
.tool-select:focus,
.tool-select:focus-visible,
.tool-btn:focus,
.tool-btn:focus-visible,
button:focus,
button:focus-visible,
input:focus,
input:focus-visible,
select:focus,
select:focus-visible,
[contenteditable="true"]:focus,
[contenteditable="true"]:focus-visible {
  outline: none;
  box-shadow: none;
}

/* 聚焦反馈：不画方框，改为背景加深 */
.editor-title:focus,
.editor-title:focus-visible,
.add-form input:focus,
.add-form input:focus-visible,
.set-input:focus,
.set-input:focus-visible,
.tool-select:focus,
.tool-select:focus-visible,
.tool-btn:focus-visible,
button.day-chip:focus-visible {
  background-color: var(--hover-bg);
  border-radius: 8px;
  transition: background-color .16s ease;
}

/* ================= 每日心情 ================= */
.mood-card { padding: 18px 22px; }
.mood-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.mood-current { font-size: 12px; color: var(--accent-strong); font-weight: 600; }
.mood-row { display: flex; gap: 8px; }
.mood-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 10px 4px 8px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--ink-2);
  cursor: pointer;
  font-family: inherit;
  transition: background .16s ease, color .16s ease, border-color .16s ease, transform .12s ease;
}
.mood-btn:hover { background: var(--hover-bg); color: var(--ink); }
.mood-btn:active { transform: translateY(1px); }
.mood-btn svg { display: block; }
.mood-label { font-size: 11px; letter-spacing: .02em; }
.mood-btn.active {
  color: var(--mood-color, var(--accent));
  border-color: color-mix(in srgb, var(--mood-color, var(--accent)) 46%, transparent);
  background: color-mix(in srgb, var(--mood-color, var(--accent)) 10%, var(--surface));
}
.mood-hint { margin-top: 10px; font-size: 12px; color: var(--ink-3); text-align: center; }
.mood-row.small { gap: 6px; }
.mood-btn.small { flex: 0 0 auto; width: 38px; height: 34px; padding: 5px 0 0; border-radius: 10px; }

/* 日历格右下角的心情小图标 */
.cal-mood {
  position: absolute;
  right: 3px;
  bottom: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
}

/* 日历弹窗里的心情行 */
.modal-mood {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 10px 22px 12px;
  border-bottom: 1px solid var(--line);
}
.modal-mood-title { font-size: 12px; color: var(--ink-3); letter-spacing: .1em; }

/* 设置里的心情文案输入框 */
.set-row .mood-input { width: 132px; flex: 0 0 auto; text-align: right; }
/* ================= 子页面：菜单 / 设置 / 名称与文案 ================= */
.subpage-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.subpage-title {
  flex: 1;
  text-align: center;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: .01em;
}
.subpage-spacer { width: 34px; }
.back-btn {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: background .16s ease;
}
.back-btn:hover { background: var(--hover-bg); }
.menu-list { display: flex; flex-direction: column; gap: 10px; }
.menu-entry {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 15px 18px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: background .16s ease;
}
.menu-entry:hover { background: var(--hover-bg); }
.menu-entry-text { flex: 1; }
.menu-entry-arrow { color: var(--ink-3); font-size: 18px; }
#settingsBody .set-group,
#namesBody .set-group {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 4px 18px 10px;
  margin-bottom: 16px;
}
#settingsBody .set-title,
#namesBody .set-title { margin-top: 12px; }

/* 菜单页里的紧凑日历 */
.calendar-card.compact {
  max-width: 360px;
  margin: 16px auto 0;
  padding-bottom: 10px;
}
.calendar-card.compact .cal-header { padding: 8px 12px 0; }
.calendar-card.compact .cal-header .card-title { font-size: 14px; }
.calendar-card.compact .cal-nav { width: 28px; height: 28px; font-size: 17px; }
.calendar-card.compact .cal-weekdays { gap: 3px; padding: 8px 10px 4px; }
.calendar-card.compact .cal-weekdays span { font-size: 10px; }
.calendar-card.compact .cal-grid { gap: 3px; padding: 2px 10px 8px; }
.calendar-card.compact .cal-num { font-size: 11px; }
.calendar-card.compact .cal-frac { font-size: 8px; margin-top: 0; }
.calendar-card.compact .cal-mood { right: 2px; bottom: 1px; }
.calendar-card.compact .cal-mood svg { width: 11px; height: 11px; }
/* 菜单抽屉内的紧凑日历与设置入口 */
#dayModal { z-index: 70; }
.drawer-body .calendar-card.compact {
  max-width: 100%;
  margin: 14px 0 0;
}
.drawer-body .menu-list {
  margin-top: 16px;
}
.drawer-body .menu-entry {
  border-radius: var(--r-md);
}

/* 抽屉头部：齿轮设置按钮 + 关闭 */
.drawer-head-actions { display: flex; align-items: center; gap: 8px; }
.drawer-icon-btn {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink-2);
  font-size: 17px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background .16s ease, color .16s ease;
}
.drawer-icon-btn:hover { background: var(--hover-bg); color: var(--ink); }
.drawer-close {
  width: 34px;
  height: 34px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  transition: background .16s ease, color .16s ease;
}
.drawer-close:hover { background: var(--hover-bg); color: var(--ink); }
.drawer-section-label {
  margin: 4px 0 0;
  font-size: 11px;
  letter-spacing: .14em;
  color: var(--ink-3);
}
.drawer-body .calendar-card.compact { margin-top: 10px; }
/* 品牌小图标已隐藏（所有主题都不显示） */
.brand-mark { display: none !important; }

/* 日历格：有心情时，完成数放左下、心情放右下，避免重叠 */
.cal-day.has-mood .cal-frac {
  position: absolute;
  left: 4px;
  bottom: 2px;
}
.cal-day.has-mood .cal-num { transform: translateY(-2px); }
.calendar-card.compact .cal-day.has-mood .cal-frac { left: 3px; bottom: 1px; }
.calendar-card.compact .cal-mood svg { width: 10px; height: 10px; }
.calendar-card.compact .cal-day.has-mood .cal-mood { right: 1px; bottom: 1px; }
/* 抽屉与日历放大一档 */
.drawer { width: min(380px, 92vw); }
.drawer-body { padding: 6px 14px 24px; }
.calendar-card.compact .cal-header { padding: 10px 12px 0; }
.calendar-card.compact .cal-header .card-title { font-size: 15px; }
.calendar-card.compact .cal-nav { width: 30px; height: 30px; font-size: 18px; }
.calendar-card.compact .cal-weekdays { gap: 4px; padding: 8px 8px 4px; }
.calendar-card.compact .cal-weekdays span { font-size: 11px; }
.calendar-card.compact .cal-grid { gap: 4px; padding: 2px 8px 10px; }
.calendar-card.compact .cal-num { font-size: 12px; }
.calendar-card.compact .cal-frac { font-size: 9px; }
.calendar-card.compact .cal-mood svg { width: 12px; height: 12px; }

/* 紧凑日历信息压缩：只显示完成数 + 心情，底色表示比例 */
.drawer { width: min(330px, 88vw); }
.cal-frac b { font-weight: 700; }
.cal-frac i { font-style: normal; opacity: .75; }
.calendar-card.compact .cal-frac i { display: none; }
.calendar-card.compact .cal-day.has-mood .cal-frac { left: 4px; bottom: 2px; }
.calendar-card.compact .cal-day.has-mood .cal-mood { right: 2px; bottom: 2px; }

/* 日历心情图标加底托，更醒目 */
.cal-mood {
  padding: 1px;
  border-radius: 50%;
  background: color-mix(in srgb, currentColor 16%, var(--surface));
  box-shadow: 0 0 0 1px color-mix(in srgb, currentColor 40%, transparent);
}
.calendar-card.compact .cal-mood svg { width: 14px; height: 14px; }
.calendar-card.compact .cal-day.has-mood .cal-mood { right: 1px; bottom: 1px; }
.mood-btn.active {
  border-color: color-mix(in srgb, var(--mood-color, var(--accent)) 60%, transparent);
  background: color-mix(in srgb, var(--mood-color, var(--accent)) 14%, var(--surface));
}

/* ================= 安卓安全区适配 ================= */
:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}
/* 安卓 App：系统状态栏 / 手势条高度兜底（WebView 的 env() 有时为 0） */
html.android-app {
  --safe-top: max(env(safe-area-inset-top, 0px), 28px);
  --safe-bottom: max(env(safe-area-inset-bottom, 0px), 14px);
}
/* 抽屉头部（齿轮 / ×）避开状态栏 */
.drawer-head { padding-top: calc(18px + var(--safe-top)); }
.drawer-body { padding-bottom: calc(24px + var(--safe-bottom)); }
/* 所有弹窗避开状态栏与手势条 */
.modal-mask {
  padding-top: calc(20px + var(--safe-top));
  padding-bottom: calc(20px + var(--safe-bottom));
}
/* 手机端编辑小窗 */
#composeModal {
  padding-top: calc(12px + var(--safe-top));
  padding-bottom: calc(12px + var(--kb, 0px) + var(--safe-bottom));
}
/* 安卓 App 页面主体顶部 / 底部 */
html.android-app body {
  padding-top: calc(30px + var(--safe-top));
  padding-bottom: calc(64px + var(--safe-bottom));
}
@media (max-width: 620px) {
  html.android-app body {
    padding-top: calc(22px + var(--safe-top));
    padding-bottom: calc(48px + var(--safe-bottom));
  }
}
/* 横向挖孔 / 摄像头在侧边时，左右也自动避开 */
html.android-app body {
  padding-left: calc(12px + var(--safe-left));
  padding-right: calc(12px + var(--safe-right));
}
.drawer-head {
  padding-left: calc(20px + var(--safe-left));
  padding-right: calc(20px + var(--safe-right));
}
.modal-mask {
  padding-left: calc(20px + var(--safe-left));
  padding-right: calc(20px + var(--safe-right));
}
#composeModal {
  padding-left: calc(12px + var(--safe-left));
  padding-right: calc(12px + var(--safe-right));
}
/* ================= 日期选择器内容预览 ================= */
.picker-preview {
  margin: 8px 20px 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-2);
}
.picker-preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.picker-preview-head strong { font-size: 13px; color: var(--ink); }
.picker-preview-text {
  margin-top: 6px;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--ink-2);
  max-height: 76px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  white-space: pre-wrap;
}
/* 有内容的日子加一个小圆点 */
.picker .cal-day.has-entry::after {
  content: "";
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
}
.picker .cal-day.sel-preview { box-shadow: inset 0 0 0 1.5px var(--accent); }

/* 未保存提示弹窗层级 */
#unsavedModal { z-index: 95; }
/* ================= 打卡计划：⋮ 按钮与弹窗 ================= */
.plan-more-btn {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.plan-more-btn:hover { background: var(--hover-bg); color: var(--ink); }
.plan-modal { max-width: 460px; }
.plan-tabs { display: flex; gap: 6px; padding: 10px 22px 0; }
.plan-tab {
  flex: 1;
  padding: 8px 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--ink-2);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.plan-tab.active {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 40%, transparent);
  color: var(--accent-strong);
}
.plan-pane { padding: 12px 22px 18px; }
.plan-hint { font-size: 12px; color: var(--ink-3); margin-bottom: 10px; }
.plan-list { max-height: 300px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.plan-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  cursor: pointer;
}
.plan-item.on { border-color: color-mix(in srgb, var(--accent) 50%, transparent); background: var(--accent-soft); }
.plan-item input { width: 16px; height: 16px; accent-color: var(--accent); }
.plan-item span { font-size: 14px; color: var(--ink); }
.plan-empty { font-size: 13px; color: var(--ink-3); text-align: center; padding: 16px 0; }
.plan-add { display: flex; gap: 8px; margin-top: 10px; }
.plan-add input {
  flex: 1;
  min-width: 0;
  padding: 9px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--ink);
  font-family: inherit;
  font-size: 14px;
}
.plan-actions { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 14px; }
.plan-weekdays { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.plan-weekday {
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 12px;
  cursor: pointer;
}
.plan-weekday.on { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
/* ================= 更新日志 ================= */
.changelog-modal { max-width: 520px; }
.changelog-body { max-height: 62vh; overflow-y: auto; padding: 14px 22px 20px; }
.changelog-item { padding: 12px 0; border-bottom: 1px solid var(--line); }
.changelog-item:last-child { border-bottom: none; }
.changelog-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.changelog-version { font-size: 15px; font-weight: 700; color: var(--ink); }
.changelog-date { font-size: 11px; color: var(--ink-3); }
.changelog-list { margin: 0; padding-left: 20px; }
.changelog-list li { font-size: 13.5px; line-height: 1.7; color: var(--ink-2); }


/* ================= 移动端按压反馈 ================= */
/* 去掉 Android WebView 默认的蓝色点击高亮 */
html,
body,
button,
.btn-add,
.btn-new,
.nav-item,
.icon-btn,
.theme-btn,
.mode-btn,
.menu-btn,
.modal-close,
.drawer-icon-btn,
.drawer-close,
.cal-nav,
.day-nav,
.seg button,
.plan-tab,
.plan-weekday,
.mood-btn,
.text-btn,
.tool-btn,
.switch,
.check-btn,
.note-list-item {
  -webkit-tap-highlight-color: transparent;
}

/* 按下时只让原有颜色略微加深，保留主题本身的质感 */
button:not(:disabled):active,
.btn-add:active,
.btn-new:active,
.nav-item:active,
.icon-btn:active,
.theme-btn:active,
.mode-btn:active,
.menu-btn:active,
.modal-close:active,
.drawer-icon-btn:active,
.drawer-close:active,
.cal-nav:active,
.day-nav:active,
.seg button:active,
.plan-tab:active,
.plan-weekday:active,
.mood-btn:active,
.text-btn:active,
.tool-btn:active,
.switch:active,
.check-btn:active,
.note-list-item:active {
  filter: brightness(.93);
}

/* 夜间主题下改为略微提亮，避免深色按钮压黑 */
html[data-theme="dark"] button:not(:disabled):active,
html[data-theme="dark"] .btn-add:active,
html[data-theme="dark"] .btn-new:active,
html[data-theme="dark"] .nav-item:active,
html[data-theme="dark"] .icon-btn:active,
html[data-theme="dark"] .theme-btn:active,
html[data-theme="dark"] .mode-btn:active,
html[data-theme="dark"] .menu-btn:active,
html[data-theme="dark"] .modal-close:active,
html[data-theme="dark"] .drawer-icon-btn:active,
html[data-theme="dark"] .drawer-close:active,
html[data-theme="dark"] .cal-nav:active,
html[data-theme="dark"] .day-nav:active,
html[data-theme="dark"] .seg button:active,
html[data-theme="dark"] .plan-tab:active,
html[data-theme="dark"] .plan-weekday:active,
html[data-theme="dark"] .mood-btn:active,
html[data-theme="dark"] .text-btn:active,
html[data-theme="dark"] .tool-btn:active,
html[data-theme="dark"] .switch:active,
html[data-theme="dark"] .check-btn:active,
html[data-theme="dark"] .note-list-item:active {
  filter: brightness(1.09);
}

html[data-theme="cute-dark"] button:not(:disabled):active,
html[data-theme="cute-dark"] .btn-add:active,
html[data-theme="cute-dark"] .btn-new:active,
html[data-theme="cute-dark"] .nav-item:active,
html[data-theme="cute-dark"] .icon-btn:active,
html[data-theme="cute-dark"] .theme-btn:active,
html[data-theme="cute-dark"] .mode-btn:active,
html[data-theme="cute-dark"] .menu-btn:active,
html[data-theme="cute-dark"] .modal-close:active,
html[data-theme="cute-dark"] .drawer-icon-btn:active,
html[data-theme="cute-dark"] .drawer-close:active,
html[data-theme="cute-dark"] .cal-nav:active,
html[data-theme="cute-dark"] .day-nav:active,
html[data-theme="cute-dark"] .seg button:active,
html[data-theme="cute-dark"] .plan-tab:active,
html[data-theme="cute-dark"] .plan-weekday:active,
html[data-theme="cute-dark"] .mood-btn:active,
html[data-theme="cute-dark"] .text-btn:active,
html[data-theme="cute-dark"] .tool-btn:active,
html[data-theme="cute-dark"] .switch:active,
html[data-theme="cute-dark"] .check-btn:active,
html[data-theme="cute-dark"] .note-list-item:active {
  filter: brightness(1.07);
}


/* ================= 本地修正：按钮对齐与移动端留白 ================= */
/* 让 ⋮ 按钮与“添加”按钮同高，视觉基线一致 */
.add-form { align-items: stretch; }
.plan-more-btn {
  width: 48px;
  height: auto;
  min-height: 42px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

@media (max-width: 620px) {
  /* 页面内容整体向中间收一点，避免边框和文字贴边 */
  body {
    padding-left: 18px;
    padding-right: 18px;
  }
  html.android-app body {
    padding-left: calc(18px + var(--safe-left));
    padding-right: calc(18px + var(--safe-right));
  }
  .add-form,
  .progress-card,
  .mood-card,
  .note-editor {
    padding-left: 20px;
    padding-right: 20px;
  }
  .cal-grid,
  .cal-weekdays,
  .card-title {
    padding-left: 20px;
    padding-right: 20px;
  }
}

/* Android 前置摄像头避让：设置页标题略向下移 */
html.android-app .subpage-head {
  padding-top: 8px;
}


/* ================= 日记：横向月份信封 ================= */
.diary-stack-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  margin: 2px 0 10px;
}
.diary-stack-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.diary-stack-title {
  font-size: 21px;
  font-weight: 800;
  letter-spacing: .01em;
  color: var(--ink);
}
.diary-month-scroll {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  overflow-x: auto;
  padding: 8px 2px 20px;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
}
.diary-month-scroll::-webkit-scrollbar,
.diary-day-scroll::-webkit-scrollbar { display: none; }
.diary-month-card {
  position: relative;
  flex: 0 0 154px;
  min-height: 190px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 18px 18px 14px 14px;
  background: transparent;
  box-shadow: none;
  color: var(--ink);
  overflow: hidden;
  transition: flex-basis .28s cubic-bezier(.22,.61,.36,1), box-shadow .2s ease, opacity .2s ease;
}
.diary-month-card::before,
.diary-month-card::after {
  content: "";
  position: absolute;
  z-index: 0;
  left: 8px;
  right: 8px;
  height: 14px;
  border: 1px solid var(--line);
  border-radius: 10px 10px 0 0;
  background: var(--surface-2);
  pointer-events: none;
}
.diary-month-card::before { top: -5px; left: 14px; right: 14px; opacity: .78; }
.diary-month-card::after { top: -11px; left: 22px; right: 22px; opacity: .5; }
.diary-month-card.is-open {
  flex-basis: min(84vw, 500px);
  box-shadow: none;
}
.diary-month-card.is-empty { opacity: .72; }
.diary-month-card.is-empty .diary-month-flap { background: var(--line); }
.diary-month-card.is-current { border-color: color-mix(in srgb, var(--accent) 48%, var(--line)); }
.diary-month-toggle {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  min-height: 188px;
  padding: 18px 16px 16px;
  border: none;
  background: transparent;
  color: inherit;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
}
.diary-month-flap {
  width: 48px;
  height: 26px;
  margin-bottom: 16px;
  border-radius: 3px 3px 14px 14px;
  background: var(--accent-soft);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
}
.diary-month-title {
  display: block;
  max-width: 100%;
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: .02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.diary-month-meta {
  display: block;
  margin-top: 7px;
  color: var(--ink-3);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.diary-day-scroll {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 0 14px 16px;
  scroll-snap-type: x proximity;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
}
.diary-day-card {
  flex: 0 0 118px;
  min-height: 132px;
  padding: 12px 11px;
  border: 1px solid var(--line);
  border-radius: 13px 13px 10px 10px;
  background: var(--surface-2);
  color: var(--ink);
  font-family: inherit;
  text-align: left;
  scroll-snap-align: start;
  cursor: pointer;
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.diary-day-card:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  box-shadow: var(--focus-ring);
  transform: translateY(-1px);
}
.diary-day-card.has-note { background: color-mix(in srgb, var(--accent-soft) 52%, var(--surface)); }
.diary-day-card.is-today { border-style: dashed; }
.diary-day-number {
  display: block;
  font-size: 15px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.diary-day-week {
  display: block;
  margin-top: 4px;
  color: var(--ink-3);
  font-size: 11px;
}
.diary-day-preview {
  display: -webkit-box;
  margin-top: 11px;
  overflow: hidden;
  color: var(--ink-2);
  font-size: 12px;
  line-height: 1.55;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.diary-month-empty {
  align-self: center;
  min-width: 150px;
  padding: 24px 10px;
  color: var(--ink-3);
  font-size: 12px;
  text-align: center;
}
.diary-month-gap {
  position: relative;
  display: inline-flex;
  align-self: center;
  flex: 0 0 18px;
  width: 18px;
  height: 86px;
  opacity: .62;
}
.diary-month-gap::before {
  content: "";
  position: absolute;
  top: 8px;
  bottom: 8px;
  left: 50%;
  width: 1px;
  background: repeating-linear-gradient(to bottom, var(--line-strong) 0 4px, transparent 4px 8px);
  transform: translateX(-50%);
}
.diary-month-gap::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 4px var(--accent-faint);
}

/* 日记内容卡 */
.diary-content-modal { max-width: 520px; }
.diary-content-heading { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.diary-content-heading h3 { font-size: 18px; }
.diary-content-body {
  max-height: min(62vh, 560px);
  overflow-y: auto;
  padding: 20px 22px;
  text-align: left;
}
.diary-content-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 22px 18px;
  border-top: 1px solid var(--line);
}
.diary-content-actions .btn-new { border-radius: 999px; }

@media (max-width: 620px) {
  .diary-stack-header { margin-left: 4px; margin-right: 4px; }
  .diary-stack-title { font-size: 19px; }
  .diary-month-scroll { padding-left: 1px; padding-right: 1px; }
  .diary-month-card.is-open { flex-basis: min(84vw, 420px); }
  .diary-content-body { padding-left: 20px; padding-right: 20px; }
}
@media (prefers-reduced-motion: reduce) {
  .diary-month-card,
  .diary-day-card { transition: none; }
}

/* 日期信封：后面的新信封压住前一个，露出左侧日期和边缘 */
.diary-day-scroll {
  gap: 0;
  padding-left: 18px;
  padding-right: 34px;
  scroll-snap-type: none;
}
.diary-day-card {
  flex: 0 0 126px;
  position: relative;
  margin-left: -48px;
  transform: translateY(var(--stack-y, 0px));
  box-shadow: 0 6px 14px rgba(18,18,22,.08);
}
.diary-day-card:first-child { margin-left: 0; }
.diary-day-card:hover { transform: translateY(calc(var(--stack-y, 0px) - 2px)); }
.diary-day-card.has-note { box-shadow: 0 7px 16px rgba(18,18,22,.13); }
html[data-theme="dark"] .diary-day-card.has-note,
html[data-theme="cute-dark"] .diary-day-card.has-note { box-shadow: 0 8px 18px rgba(0,0,0,.38); }

/* 日期信封必须使用不透明底色，叠压时不能透出下层内容 */
.diary-day-card,
.diary-day-card.has-note,
.diary-day-card.is-today {
  opacity: 1 !important;
  background-color: var(--surface-2) !important;
  background-image: none !important;
  mix-blend-mode: normal;
}
.diary-day-card.has-note {
  background-image: linear-gradient(var(--accent-faint), var(--accent-faint)) !important;
}

/* 按标注修正：去掉额外外框，日期信封统一对齐 */
.diary-month-card {
  border: 0;
}
.diary-month-card.is-current {
  border-color: transparent;
}
.diary-day-card {
  height: 132px;
  min-height: 132px;
  transform: translateY(0);
}
.diary-day-card:hover {
  transform: translateY(-2px);
}

/* 去掉月份卡片上方的装饰性方框线 */
.diary-month-card::before,
.diary-month-card::after {
  display: none;
}

/* 月信封与页面背景做颜色区分，但不恢复外框 */
.diary-month-card {
  background-color: var(--surface);
  background-image: linear-gradient(var(--accent-faint), var(--accent-faint));
  border: 0;
  box-shadow: none;
}
.diary-month-card.is-empty {
  background-color: var(--surface-2);
  background-image: linear-gradient(var(--accent-faint), var(--accent-faint));
}

/* ================= 每日笔记与收藏夹 ================= */
.diary-month-scroll { gap: 0; padding-left: 18px; padding-right: 42px; }
.diary-month-card { margin-left: -28px; }
.diary-month-card:first-child { margin-left: 0; }
.diary-month-card { background-image: linear-gradient(135deg, color-mix(in srgb, var(--accent-soft) 72%, transparent), transparent 48%, color-mix(in srgb, var(--accent-faint) 100%, transparent)); }
html[data-theme="cute"] .diary-month-card { background-image: linear-gradient(135deg, rgba(232,135,149,.18), rgba(255,255,255,0) 50%, rgba(232,135,149,.09)); }
html[data-theme="dark"] .diary-month-card { background-image: linear-gradient(135deg, rgba(201,162,107,.17), rgba(201,162,107,0) 52%, rgba(201,162,107,.08)); }
html[data-theme="cute-dark"] .diary-month-card { background-image: linear-gradient(135deg, rgba(227,146,163,.19), rgba(227,146,163,0) 52%, rgba(227,146,163,.1)); }
.diary-day-marker { position:absolute; top:6px; right:7px; width:7px; height:7px; border-radius:50%; background:#e5484d; box-shadow:0 0 0 3px color-mix(in srgb, #e5484d 16%, transparent); z-index:6; }
.diary-day-notes { max-height:min(58vh,520px); overflow-y:auto; padding:14px 18px 4px; }
.daily-note-item { display:flex; flex-direction:column; gap:6px; width:100%; padding:13px 14px; margin-bottom:9px; border:1px solid var(--line); border-radius:13px; background:var(--surface-2); color:var(--ink); font-family:inherit; text-align:left; cursor:pointer; }
.daily-note-item:hover { background:var(--hover-bg); border-color:color-mix(in srgb, var(--accent) 34%, var(--line)); }
.daily-note-head { display:flex; align-items:center; gap:7px; min-width:0; }
.daily-note-head strong { min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:15px; }
.daily-note-pin { flex:0 0 auto; padding:1px 6px; border-radius:999px; color:var(--accent-strong); background:var(--accent-soft); font-size:10px; }
.daily-note-mark { flex:0 0 auto; width:7px; height:7px; border-radius:50%; background:#e5484d; box-shadow:0 0 0 3px color-mix(in srgb, #e5484d 15%, transparent); }
.daily-note-preview { display:-webkit-box; overflow:hidden; color:var(--ink-2); font-size:13px; line-height:1.6; -webkit-box-orient:vertical; -webkit-line-clamp:2; }
.daily-note-meta { color:var(--ink-3); font-size:11px; }
.daily-note-empty, .collection-empty { padding:24px 8px; color:var(--ink-3); text-align:center; font-size:13px; }
.collections-modal, .folder-modal, .collection-picker-modal { max-width:520px; }
.collection-create-row { display:flex; gap:8px; padding:12px 18px 4px; border-top:1px solid var(--line); }
.collection-create-row input { flex:1; min-width:0; padding:9px 12px; border:1px solid var(--line-strong); border-radius:var(--r-sm); background:var(--surface-2); color:var(--ink); font-family:inherit; font-size:14px; outline:none; }
.collection-list, .collection-picker-list, .folder-note-list { max-height:min(60vh,520px); overflow-y:auto; padding:12px 18px 16px; }
.collection-row { display:flex; align-items:center; gap:7px; padding:9px 0; border-bottom:1px solid var(--line); }
.collection-row:last-child { border-bottom:none; }
.collection-open { display:flex; align-items:center; justify-content:space-between; flex:1; min-width:0; padding:7px 0; border:none; background:none; color:var(--ink); font-family:inherit; font-size:15px; text-align:left; cursor:pointer; }
.collection-name { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.collection-count { color:var(--ink-3); font-size:11px; }
.collection-check { display:flex; align-items:center; gap:9px; padding:10px 0; border-bottom:1px solid var(--line); font-size:14px; }
.collection-check:last-child { border-bottom:none; }
.collection-check input { width:17px; height:17px; accent-color:var(--accent); }
.diary-collection-envelope { position:relative; display:flex; flex-direction:column; align-items:flex-start; width:min(100%,360px); margin:6px 0 18px; padding:18px 18px 16px; border:1px solid var(--line); border-radius:18px 18px 14px 14px; background-color:var(--surface); background-image:linear-gradient(135deg, color-mix(in srgb, var(--accent-soft) 70%, transparent), transparent 55%, color-mix(in srgb, var(--accent-faint) 100%, transparent)); color:var(--ink); font-family:inherit; text-align:left; cursor:pointer; box-shadow:none; }
.diary-collection-envelope::before { content:""; position:absolute; top:-7px; left:16px; width:48px; height:14px; border-radius:8px 8px 0 0; background:color-mix(in srgb, var(--accent) 22%, var(--surface)); }
.diary-collection-title { margin-top:14px; font-size:17px; font-weight:800; }
.diary-collection-meta { margin-top:6px; color:var(--ink-3); font-size:12px; }
.folder-toolbar { display:flex; align-items:center; gap:10px; padding:12px 18px 2px; }
.folder-toolbar .text-btn { margin-left:auto; }
.folder-toolbar .text-btn.danger { margin-left:0; }
.diary-content-actions { justify-content:flex-end; }
@media (max-width:620px) { .collection-create-row { padding-left:16px; padding-right:16px; } .collection-list,.collection-picker-list,.folder-note-list { padding-left:16px; padding-right:16px; } }

#collectionsModal, #folderModal { z-index: 85; }
#collectionPickerModal { z-index: 110; }

/* ================= 每日笔记细节重设计 ================= */
/* 保持原有结构，只收敛卡片高度、层级、阴影和纸张质感 */
.diary-pane {
  --diary-paper: color-mix(in srgb, var(--surface) 95%, var(--accent) 5%);
  --diary-paper-2: color-mix(in srgb, var(--surface-2) 93%, var(--accent) 7%);
  --diary-rule: color-mix(in srgb, var(--line-strong) 78%, transparent);
  --diary-shadow: 0 1px 1px rgba(20, 20, 24, .05), 0 5px 12px rgba(20, 20, 24, .06);
}

html[data-theme="dark"] .diary-pane,
html[data-theme="cute-dark"] .diary-pane {
  --diary-paper: color-mix(in srgb, var(--surface) 94%, var(--accent) 6%);
  --diary-paper-2: color-mix(in srgb, var(--surface-2) 92%, var(--accent) 8%);
  --diary-rule: color-mix(in srgb, var(--line-strong) 88%, transparent);
  --diary-shadow: 0 1px 1px rgba(0, 0, 0, .28), 0 5px 13px rgba(0, 0, 0, .16);
}

.diary-stack-header {
  align-items: center;
  gap: 12px;
  margin: 0 2px 12px;
}
.diary-stack-title {
  font-size: 20px;
  font-weight: 780;
  letter-spacing: -.015em;
}

/* 月份：缩短留白，把小三角改成纸张折页 */
.diary-month-scroll {
  align-items: flex-start;
  gap: 0;
  padding: 4px 2px 18px;
}
.diary-month-card {
  flex-basis: 148px;
  min-height: 166px;
  border: 1px solid var(--diary-rule);
  border-radius: 16px 16px 12px 12px;
  background-color: var(--diary-paper);
  background-image: linear-gradient(135deg, color-mix(in srgb, var(--accent) 9%, transparent), transparent 56%, color-mix(in srgb, var(--accent) 4%, transparent));
  box-shadow: none;
  overflow: hidden;
}
.diary-month-card.is-open {
  flex-basis: min(86vw, 520px);
}
.diary-month-card.is-current {
  border-color: color-mix(in srgb, var(--accent) 42%, var(--diary-rule));
}
.diary-month-card.is-empty {
  opacity: .82;
  background-color: color-mix(in srgb, var(--surface-2) 96%, var(--accent) 4%);
}
.diary-month-toggle {
  min-height: 164px;
  padding: 14px 15px 12px;
}
.diary-month-flap {
  width: 34px;
  height: 9px;
  margin-bottom: 12px;
  border-radius: 0 0 7px 7px;
  background: color-mix(in srgb, var(--accent) 30%, var(--surface-2));
  clip-path: none;
  opacity: .9;
}
.diary-month-title {
  font-size: 16px;
  font-weight: 780;
  letter-spacing: .01em;
}
.diary-month-meta {
  margin-top: 5px;
  font-size: 11px;
}

/* 日期：统一尺寸、对齐和叠压距离，保留信封感 */
.diary-day-scroll {
  gap: 0;
  padding: 0 14px 14px;
  scroll-snap-type: none;
}
.diary-day-card {
  flex: 0 0 120px;
  height: 124px;
  min-height: 124px;
  margin-left: -42px;
  padding: 11px 10px;
  border: 1px solid var(--diary-rule);
  border-radius: 12px 12px 9px 9px;
  background-color: var(--diary-paper-2) !important;
  background-image: none !important;
  box-shadow: var(--diary-shadow);
  transform: translateY(0);
}
.diary-day-card:first-child { margin-left: 0; }
.diary-day-card:hover {
  border-color: color-mix(in srgb, var(--accent) 38%, var(--diary-rule));
  box-shadow: 0 2px 3px rgba(20, 20, 24, .07), 0 8px 16px rgba(20, 20, 24, .08);
  transform: translateY(-2px);
}
.diary-day-card.has-note {
  background-color: color-mix(in srgb, var(--diary-paper-2) 92%, var(--accent) 8%) !important;
  background-image: none !important;
  box-shadow: var(--diary-shadow);
}
.diary-day-card.is-today {
  border-style: solid;
  border-color: color-mix(in srgb, var(--accent) 48%, var(--diary-rule));
  box-shadow: inset 0 0 0 1px var(--accent-faint), var(--diary-shadow);
}
.diary-day-number {
  font-size: 15px;
  font-weight: 780;
  letter-spacing: -.01em;
}
.diary-day-week {
  margin-top: 3px;
  color: var(--ink-3);
  font-size: 10px;
}
.diary-day-preview {
  margin-top: 9px;
  color: var(--ink-2);
  font-size: 11.5px;
  line-height: 1.5;
}
.diary-day-marker {
  top: 7px;
  right: 7px;
  width: 6px;
  height: 6px;
  box-shadow: 0 0 0 2px color-mix(in srgb, #e5484d 14%, transparent);
}

/* 收藏夹：改成更薄的索引卡，不再重复月份信封造型 */
.diary-collection-envelope {
  width: min(100%, 360px);
  min-height: 92px;
  margin: 8px 0 20px;
  padding: 14px 16px 13px 17px;
  border: 1px solid var(--diary-rule);
  border-radius: 14px;
  background-color: var(--diary-paper);
  background-image: linear-gradient(135deg, color-mix(in srgb, var(--accent) 8%, transparent), transparent 58%, color-mix(in srgb, var(--accent) 3%, transparent));
  box-shadow: var(--diary-shadow);
}
.diary-collection-envelope::before {
  top: -5px;
  left: 18px;
  width: 38px;
  height: 10px;
  border-radius: 6px 6px 2px 2px;
  background: color-mix(in srgb, var(--accent) 28%, var(--surface-2));
}
.diary-collection-title {
  margin-top: 8px;
  font-size: 15px;
  font-weight: 780;
}
.diary-collection-meta {
  margin-top: 4px;
  font-size: 11px;
}

/* 每日笔记列表：和纸张卡片使用同一套层级 */
.daily-note-item {
  gap: 5px;
  padding: 12px 13px;
  margin-bottom: 8px;
  border-color: var(--diary-rule);
  border-radius: 12px;
  background: var(--diary-paper-2);
  box-shadow: var(--diary-shadow);
}
.daily-note-head strong {
  font-size: 14px;
  font-weight: 760;
}
.daily-note-preview {
  font-size: 12px;
  line-height: 1.55;
}
.daily-note-meta {
  font-size: 10px;
}
.daily-note-pin {
  padding: 1px 5px;
  font-size: 9px;
}
.daily-note-mark {
  width: 6px;
  height: 6px;
  box-shadow: 0 0 0 2px color-mix(in srgb, #e5484d 14%, transparent);
}
.collection-create-row input {
  border-color: var(--diary-rule);
  border-radius: 10px;
  background: var(--diary-paper-2);
}
.collection-row {
  padding: 8px 0;
  border-color: var(--diary-rule);
}
.collection-open {
  padding: 6px 0;
  font-size: 14px;
}
.collection-count {
  font-size: 10px;
}

@media (max-width: 620px) {
  .diary-month-card.is-open { flex-basis: min(84vw, 420px); }
  .diary-month-toggle { min-height: 156px; padding: 13px 14px 12px; }
  .diary-day-card { flex-basis: 118px; height: 122px; min-height: 122px; }
  .diary-collection-envelope { min-height: 88px; padding: 13px 15px 12px 16px; }
}

/* 收藏标识固定在日期卡片上沿，叠压后仍然可见 */
.diary-day-marker {
  left: 50%;
  right: auto;
  top: 5px;
  transform: translateX(-50%);
}

/* ================= 月份与日期统一堆叠 ================= */
/* 月份卡片使用和日期卡片相同的叠压逻辑：后一个月压住前一个月，但保留前一个月的标题与边缘 */
.diary-pane {
  --diary-month-grad: linear-gradient(135deg, #ffffff 0%, #f8f1ea 52%, #f1e7dc 100%);
  --diary-day-grad: linear-gradient(145deg, #ffffff 0%, #fbf5ef 100%);
  --diary-day-note-grad: linear-gradient(145deg, #f8eee6 0%, #fffaf6 100%);
  --diary-collection-grad: linear-gradient(135deg, #fffdfb 0%, #f6ede5 100%);
  --diary-note-item-grad: linear-gradient(145deg, #ffffff 0%, #faf4ee 100%);
}
html[data-theme="cute"] .diary-pane {
  --diary-month-grad: linear-gradient(135deg, #ffffff 0%, #fff1f2 54%, #fbe5e7 100%);
  --diary-day-grad: linear-gradient(145deg, #ffffff 0%, #fff5f4 100%);
  --diary-day-note-grad: linear-gradient(145deg, #fff0f2 0%, #fff9f7 100%);
  --diary-collection-grad: linear-gradient(135deg, #fffdfd 0%, #fbeaec 100%);
  --diary-note-item-grad: linear-gradient(145deg, #ffffff 0%, #fff2f2 100%);
}
html[data-theme="dark"] .diary-pane,
html[data-theme="cute-dark"] .diary-pane {
  --diary-month-grad: linear-gradient(135deg, #2d2a27 0%, #232228 55%, #1f1f24 100%);
  --diary-day-grad: linear-gradient(145deg, #2b2a30 0%, #222227 100%);
  --diary-day-note-grad: linear-gradient(145deg, #302a26 0%, #25242a 100%);
  --diary-collection-grad: linear-gradient(135deg, #2b2928 0%, #202025 100%);
  --diary-note-item-grad: linear-gradient(145deg, #29282e 0%, #222227 100%);
}
html[data-theme="cute-dark"] .diary-pane {
  --diary-month-grad: linear-gradient(135deg, #34282e 0%, #262127 55%, #211f25 100%);
  --diary-day-grad: linear-gradient(145deg, #30272e 0%, #241f26 100%);
  --diary-day-note-grad: linear-gradient(145deg, #38282f 0%, #292129 100%);
  --diary-collection-grad: linear-gradient(135deg, #30262c 0%, #211f25 100%);
  --diary-note-item-grad: linear-gradient(145deg, #2d252c 0%, #231f25 100%);
}

.diary-month-scroll {
  gap: 0;
  padding-left: 18px;
  padding-right: 38px;
  align-items: flex-start;
}
.diary-month-card {
  flex: 0 0 116px;
  min-height: 150px;
  margin-left: -34px;
  border: 0 !important;
  border-radius: 15px 15px 11px 11px;
  background-color: transparent !important;
  background-image: var(--diary-month-grad) !important;
  box-shadow: var(--diary-shadow);
  overflow: hidden;
}
.diary-month-card:first-child { margin-left: 0; }
.diary-month-card.is-open {
  flex-basis: min(84vw, 430px);
  margin-left: -34px;
}
.diary-month-card.is-open:first-child { margin-left: 0; }
.diary-month-toggle {
  min-height: 148px;
  padding: 13px 12px 11px;
}
.diary-month-card:not(.is-open) .diary-month-title {
  font-size: 14px;
  letter-spacing: -.01em;
}
.diary-month-card:not(.is-open) .diary-month-meta {
  font-size: 10px;
}
.diary-month-flap {
  width: 32px;
  height: 8px;
  margin-bottom: 11px;
  background: color-mix(in srgb, var(--accent) 24%, transparent);
}
html[data-theme="dark"] .diary-month-flap,
html[data-theme="cute-dark"] .diary-month-flap {
  background: color-mix(in srgb, var(--accent) 34%, transparent);
}

/* 日期卡片取消边框，使用渐变表达纸张层次 */
.diary-day-card {
  border: 0 !important;
  background-color: transparent !important;
  background-image: var(--diary-day-grad) !important;
  box-shadow: var(--diary-shadow);
}
.diary-day-card.has-note {
  background-color: transparent !important;
  background-image: var(--diary-day-note-grad) !important;
}
.diary-day-card.is-today {
  border: 0 !important;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 36%, transparent), var(--diary-shadow);
}
.diary-day-card:hover {
  border: 0 !important;
  box-shadow: 0 5px 14px rgba(20, 20, 24, .12);
}

/* 收藏夹与笔记列表同步取消边框，保持统一渐变 */
.diary-collection-envelope {
  border: 0 !important;
  background-color: transparent !important;
  background-image: var(--diary-collection-grad) !important;
  box-shadow: var(--diary-shadow);
}
.daily-note-item {
  border: 0;
  background: var(--diary-note-item-grad);
}

/* 修正：叠压中的旧月份只露标签与标题，不再显示整块方框 */
.diary-month-card:not(.is-open) {
  background-color: transparent !important;
  background-image: none !important;
  box-shadow: none !important;
}
.diary-month-card:not(.is-open) .diary-month-toggle {
  background: transparent;
}
.diary-month-card.is-open {
  border-radius: 18px;
}

/* 收藏夹小标签与月份小标签保持同一左对齐位置 */
.diary-collection-envelope::before {
  left: 12px;
}

/* 修正：旧月份恢复完整圆角渐变卡片，保持与其他月份一致 */
.diary-month-card:not(.is-open) {
  background-color: transparent !important;
  background-image: var(--diary-month-grad) !important;
  box-shadow: var(--diary-shadow) !important;
  border-radius: 20px 20px 16px 16px;
}
.diary-month-card:not(.is-open) .diary-month-toggle {
  background: transparent;
}

/* 收藏夹顶部小矩形改为红色小锦旗 */
.diary-collection-envelope::before {
  content: "";
  top: -8px;
  left: 13px;
  width: 18px;
  height: 23px;
  border-radius: 2px 2px 1px 1px;
  background: #e5484d;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 74%, 0 100%);
  box-shadow: 0 3px 7px rgba(229, 72, 77, .24);
}
.diary-collection-envelope::after {
  content: "";
  position: absolute;
  top: -10px;
  left: 11px;
  width: 2px;
  height: 29px;
  border-radius: 2px;
  background: color-mix(in srgb, var(--ink-3) 62%, transparent);
}

/* 旧月份卡片改为无边框、无阴影的柔光块，避免出现外圈方框 */
.diary-month-card:not(.is-open) {
  background-color: transparent !important;
  background-image: radial-gradient(135% 120% at 18% 4%, color-mix(in srgb, var(--accent) 17%, var(--surface)) 0%, color-mix(in srgb, var(--accent) 7%, transparent) 48%, transparent 78%) !important;
  box-shadow: none !important;
}

/* 收藏夹只保留红色锦旗，去掉旧的小棕块和旗杆 */
.diary-collection-envelope > .diary-month-flap {
  display: none !important;
}
.diary-collection-envelope::after {
  display: none !important;
}

/* 去掉旧月份卡片左侧露出的窄边：背景从左侧柔和渐显，文字内容保持不变 */
.diary-month-card:not(.is-open) {
  background-color: transparent !important;
  background-image: none !important;
  box-shadow: none !important;
}
.diary-month-card:not(.is-open)::before {
  content: "";
  display: block;
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(135% 120% at 18% 4%, color-mix(in srgb, var(--accent) 17%, var(--surface)) 0%, color-mix(in srgb, var(--accent) 7%, transparent) 48%, transparent 78%);
  -webkit-mask-image: linear-gradient(90deg, transparent 0 20px, #000 20px 100%);
  mask-image: linear-gradient(90deg, transparent 0 20px, #000 20px 100%);
}
.diary-month-card:not(.is-open) .diary-month-toggle {
  z-index: 1;
}

/* 左侧窄边改为真正柔和消失，不再留下新的直线边界 */
.diary-month-card:not(.is-open)::before {
  -webkit-mask-image: linear-gradient(90deg, transparent 0, transparent 8px, rgba(0,0,0,.18) 24px, #000 52px);
  mask-image: linear-gradient(90deg, transparent 0, transparent 8px, rgba(0,0,0,.18) 24px, #000 52px);
}

/* 月份卡片统一：前后卡片同一渐变、同一圆角、同一阴影 */
.diary-month-card,
.diary-month-card:not(.is-open),
.diary-month-card.is-open {
  background-color: transparent !important;
  background-image: var(--diary-month-grad) !important;
  border-radius: 18px !important;
  box-shadow: var(--diary-shadow) !important;
}
.diary-month-card:not(.is-open)::before,
.diary-month-card:not(.is-open)::after {
  display: none !important;
}

/* 取消“按日期收好”标题，仅隐藏文字，不改变下方月份卡片结构 */
.diary-stack-title {
  display: none !important;
}

/* 最终主题渐变色：四个主题分别使用不同色系 */
html[data-theme="minimal"] .diary-pane {
  --diary-month-grad: linear-gradient(135deg, #ffffff 0%, #f8f1e9 50%, #eee1d3 100%);
  --diary-day-grad: linear-gradient(145deg, #ffffff 0%, #faf3eb 100%);
  --diary-day-note-grad: linear-gradient(145deg, #f6e9dc 0%, #fffaf6 100%);
  --diary-collection-grad: linear-gradient(135deg, #fffdfa 0%, #f4e8dc 100%);
  --diary-note-item-grad: linear-gradient(145deg, #ffffff 0%, #f8f0e8 100%);
}
html[data-theme="cute"] .diary-pane {
  --diary-month-grad: linear-gradient(135deg, #ffffff 0%, #fff0f3 48%, #fbdbe2 100%);
  --diary-day-grad: linear-gradient(145deg, #ffffff 0%, #fff1f3 100%);
  --diary-day-note-grad: linear-gradient(145deg, #ffe3e8 0%, #fff8f7 100%);
  --diary-collection-grad: linear-gradient(135deg, #fffdfd 0%, #fbe2e7 100%);
  --diary-note-item-grad: linear-gradient(145deg, #ffffff 0%, #ffedf0 100%);
}
html[data-theme="dark"] .diary-pane {
  --diary-month-grad: linear-gradient(135deg, #302c27 0%, #25242a 52%, #1e1e23 100%);
  --diary-day-grad: linear-gradient(145deg, #2e2c31 0%, #222227 100%);
  --diary-day-note-grad: linear-gradient(145deg, #352c24 0%, #27242a 100%);
  --diary-collection-grad: linear-gradient(135deg, #302c2a 0%, #202025 100%);
  --diary-note-item-grad: linear-gradient(145deg, #2c2a2f 0%, #222227 100%);
}
html[data-theme="cute-dark"] .diary-pane {
  --diary-month-grad: linear-gradient(135deg, #3c2632 0%, #2b202b 52%, #1f1e25 100%);
  --diary-day-grad: linear-gradient(145deg, #342630 0%, #241f28 100%);
  --diary-day-note-grad: linear-gradient(145deg, #442a36 0%, #2d202b 100%);
  --diary-collection-grad: linear-gradient(135deg, #392530 0%, #211f25 100%);
  --diary-note-item-grad: linear-gradient(145deg, #33252e 0%, #231f27 100%);
}

/* 月份卡片 FLIP、日期卡片和弹窗的统一丝滑动画 */
.diary-month-card {
  transform-origin: top left;
}
.diary-month-card.is-flipping {
  will-change: transform;
  z-index: 200 !important;
  pointer-events: none;
}

@keyframes diary-card-in {
  from { opacity: 0; transform: translateY(8px) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.diary-day-card {
  animation: diary-card-in .34s cubic-bezier(.22, .61, .36, 1) both;
}
.diary-collection-envelope {
  animation: diary-card-in .38s cubic-bezier(.22, .61, .36, 1) both;
}

@keyframes modal-smooth-in {
  from { opacity: 0; transform: translateY(8px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal {
  animation: modal-smooth-in .28s cubic-bezier(.22, .61, .36, 1) both;
}
@keyframes compose-smooth-in {
  from { opacity: 0; transform: translateY(10px) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
#composeModal .compose {
  animation: compose-smooth-in .3s cubic-bezier(.22, .61, .36, 1) both;
}

@media (prefers-reduced-motion: reduce) {
  .diary-day-card,
  .diary-collection-envelope,
  .modal,
  #composeModal .compose {
    animation: none !important;
  }
}

/* FLIP 过程中让新展开卡片始终位于最上层，其余卡片保留叠压关系 */
.diary-month-card.is-flipping.is-open {
  z-index: 210 !important;
}
.diary-month-card.is-flipping:not(.is-open) {
  z-index: 190 !important;
}

/* 修复：动画中的月份卡片不能盖住查看、编辑和其他弹窗 */
#diaryViewModal,
#composeModal,
#collectionsModal,
#folderModal,
#collectionPickerModal,
#datePickerModal,
#planModal,
#changelogModal,
#dayModal,
#confirmModal,
#unsavedModal {
  z-index: 300 !important;
}
#composeModal { z-index: 320 !important; }
#collectionPickerModal { z-index: 340 !important; }
#confirmModal,
#unsavedModal { z-index: 360 !important; }

/* 修复：菜单抽屉要高于月份卡片，但仍低于各种弹窗 */
.drawer-mask {
  z-index: 250 !important;
}
.drawer {
  z-index: 251 !important;
}

/* 固定层级令牌：以后新增浮层只从这里取值 */
:root {
  --layer-month-card: 200;
  --layer-month-flip: 210;
  --layer-drawer-mask: 250;
  --layer-drawer: 251;
  --layer-modal: 300;
  --layer-compose: 320;
  --layer-picker: 340;
  --layer-confirm: 360;
}
.diary-month-card.is-open {
  z-index: var(--layer-month-card) !important;
}
.diary-month-card.is-flipping.is-open {
  z-index: var(--layer-month-flip) !important;
}
.diary-month-card.is-flipping:not(.is-open) {
  z-index: var(--layer-month-card) !important;
}
.drawer-mask { z-index: var(--layer-drawer-mask) !important; }
.drawer { z-index: var(--layer-drawer) !important; }
#diaryViewModal,
#collectionsModal,
#folderModal,
#datePickerModal,
#planModal,
#changelogModal,
#dayModal { z-index: var(--layer-modal) !important; }
#composeModal { z-index: var(--layer-compose) !important; }
#collectionPickerModal { z-index: var(--layer-picker) !important; }
#confirmModal,
#unsavedModal { z-index: var(--layer-confirm) !important; }

/* 笔记视频与实况照片 */
.note-video-wrap {
  position: relative;
  display: block;
  width: min(100%, 520px);
  margin: 12px auto;
  line-height: 0;
}
.rich-body video.note-video {
  display: block;
  width: 100%;
  max-height: 420px;
  border-radius: 14px;
  background: #000;
  object-fit: contain;
}
.note-live-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2;
  padding: 3px 7px;
  border-radius: 999px;
  background: rgba(0, 0, 0, .62);
  color: #fff;
  font-size: 10px;
  line-height: 1.2;
  letter-spacing: .04em;
  pointer-events: none;
}
@media (max-width: 620px) {
  .note-video-wrap { margin-left: 0; margin-right: 0; }
}

/* ================= 记账本 ================= */
.ledger-entry {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 14px;
  margin: 4px 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}
.ledger-entry:hover { background: var(--hover-bg); }
.ledger-entry-icon { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 9px; background: var(--accent-soft); color: var(--accent-strong); font-size: 16px; }
.ledger-entry-text { flex: 1; }
.ledger-entry-badge { min-width: 20px; padding: 2px 6px; border-radius: 999px; background: #e5484d; color: #fff; font-size: 10px; text-align: center; }
.ledger-page { padding-bottom: 30px; }
.ledger-head { align-items: center; }
.ledger-tabs { display: flex; gap: 4px; padding: 4px; margin: 2px 0 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.ledger-tab { flex: 1; padding: 9px 0; border: 0; border-radius: 10px; background: transparent; color: var(--ink-2); font-family: inherit; font-size: 13px; font-weight: 700; cursor: pointer; }
.ledger-tab.active { background: var(--ink); color: var(--surface); }
.ledger-pane { display: flex; flex-direction: column; gap: 14px; }
.ledger-summary-card { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; overflow: hidden; border-radius: var(--r-lg); background: var(--line); box-shadow: var(--shadow-sm); }
.ledger-summary-item { display: flex; flex-direction: column; gap: 6px; padding: 16px 12px; background: var(--surface); }
.ledger-summary-item span { color: var(--ink-3); font-size: 11px; }
.ledger-summary-item strong { font-size: 16px; font-variant-numeric: tabular-nums; }
.ledger-summary-item strong.income { color: #4f9a72; }
.ledger-summary-item strong.expense { color: #c06b6b; }
.ledger-toolbar { display: flex; align-items: center; gap: 9px; }
.ledger-toolbar strong { flex: 1; text-align: center; font-size: 15px; }
.ledger-month-btn { width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink-2); font-size: 20px; cursor: pointer; }
.ledger-filter-row { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 6px; }
.ledger-filter-row input, .ledger-filter-row select { min-width: 0; padding: 9px 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); font-family: inherit; font-size: 12px; }
.ledger-list { display: flex; flex-direction: column; gap: 12px; }
.ledger-day-group { overflow: hidden; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow-sm); }
.ledger-day-label { padding: 9px 13px; border-bottom: 1px solid var(--line); color: var(--ink-3); font-size: 11px; font-weight: 700; }
.ledger-row { display: flex; align-items: center; gap: 8px; padding: 11px 12px; border-bottom: 1px solid var(--line); }
.ledger-row:last-child { border-bottom: 0; }
.ledger-row-main { display: flex; flex: 1; flex-direction: column; min-width: 0; gap: 3px; }
.ledger-row-main strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.ledger-row-main span { overflow: hidden; color: var(--ink-3); text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.ledger-row-amount { flex: 0 0 auto; font-size: 13px; font-weight: 800; font-variant-numeric: tabular-nums; }
.ledger-row-amount.income { color: #4f9a72; }
.ledger-row-amount.expense { color: #c06b6b; }
.ledger-row-amount.transfer { color: var(--accent-strong); }
.ledger-row-more { flex: 0 0 auto; padding: 4px; border: 0; background: none; color: var(--ink-3); font-family: inherit; font-size: 11px; cursor: pointer; }
.ledger-row-more.danger { color: var(--danger); }
.ledger-empty { padding: 30px 8px; color: var(--ink-3); text-align: center; font-size: 13px; }

.ledger-net-card { display: flex; align-items: center; gap: 12px; padding: 18px 16px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow-sm); }
.ledger-net-card span { color: var(--ink-3); font-size: 12px; }
.ledger-net-card strong { flex: 1; font-size: 24px; font-variant-numeric: tabular-nums; }
.ledger-section { overflow: hidden; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow-sm); }
.ledger-section h3 { padding: 13px 14px 8px; color: var(--ink-2); font-size: 13px; }
.ledger-budget-head { display: flex; align-items: center; justify-content: space-between; padding: 5px 12px 5px 0; }
.ledger-budget-head h3 { flex: 1; }
.ledger-account-row { display: flex; align-items: center; gap: 9px; padding: 12px 13px; border-top: 1px solid var(--line); }
.ledger-account-row > div { display: flex; flex: 1; flex-direction: column; min-width: 0; gap: 3px; }
.ledger-account-row strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.ledger-account-row small { color: var(--ink-3); font-size: 11px; }
.ledger-account-row b { font-size: 14px; font-variant-numeric: tabular-nums; }
.ledger-account-dot { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; width: 30px; height: 30px; border-radius: 10px; color: #fff; font-size: 12px; }
.ledger-budget-row, .ledger-recurring-row { display: flex; align-items: center; gap: 8px; padding: 12px 13px; border-top: 1px solid var(--line); }
.ledger-budget-row > div, .ledger-recurring-row > div { display: flex; flex: 1; flex-direction: column; min-width: 0; gap: 5px; }
.ledger-budget-row strong, .ledger-recurring-row strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.ledger-budget-row small, .ledger-recurring-row small { color: var(--ink-3); font-size: 11px; }
.ledger-progress { height: 6px; overflow: hidden; border-radius: 999px; background: var(--track-bg); }
.ledger-progress i { display: block; height: 100%; border-radius: inherit; background: var(--fill-grad); }
.ledger-modal { max-width: 560px; }
.ledger-modal-body { max-height: min(72vh, 680px); overflow-y: auto; padding: 16px 18px 18px; }
.ledger-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ledger-form-grid label { display: flex; flex-direction: column; gap: 5px; color: var(--ink-2); font-size: 12px; }
.ledger-form-grid input, .ledger-form-grid select { width: 100%; min-width: 0; padding: 10px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); color: var(--ink); font-family: inherit; font-size: 14px; }
.ledger-note-field { grid-column: 1 / -1; }
.ledger-form-actions { display: flex; justify-content: flex-end; gap: 14px; margin-top: 16px; }
.ledger-settings { display: flex; flex-direction: column; }
.ledger-setting-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.ledger-setting-row:last-child { border-bottom: 0; }
.ledger-setting-row small { color: var(--ink-3); font-size: 11px; }
#ledgerModal { z-index: 300 !important; }
@media (max-width: 620px) {
  .ledger-filter-row { grid-template-columns: 1fr 1fr; }
  .ledger-search { grid-column: 1 / -1; }
  .ledger-summary-item { padding: 13px 8px; }
  .ledger-summary-item strong { font-size: 14px; }
  .ledger-form-grid { grid-template-columns: 1fr; }
  .ledger-note-field { grid-column: auto; }
}

/* 账本弹窗：统一为细腻的表单面板，移除原生类型下拉的突兀白色弹层 */
.ledger-modal {
  max-width: 520px;
  border: 0;
  border-radius: 22px;
  background: var(--surface);
  box-shadow: 0 16px 44px rgba(0, 0, 0, .28);
}
.ledger-modal .modal-head {
  padding: 18px 20px 10px;
  border-bottom: 0;
}
.ledger-modal .modal-head h3 { font-size: 18px; font-weight: 800; }
.ledger-modal .modal-close { color: var(--ink-3); font-size: 22px; }
.ledger-modal-body { padding: 8px 18px 20px; }
.ledger-form-grid { grid-template-columns: 1fr; gap: 12px; }
.ledger-form-grid label, .ledger-field { display: flex; flex-direction: column; gap: 7px; color: var(--ink-2); font-size: 12px; }
.ledger-field-label { color: var(--ink-2); font-size: 12px; }
.ledger-form-grid input, .ledger-form-grid select {
  min-height: 44px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background-color: var(--surface-2);
  color: var(--ink);
  font-family: inherit;
  font-size: 14px;
}
.ledger-form-grid select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 34px;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%), linear-gradient(135deg, var(--ink-3) 50%, transparent 50%);
  background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
.ledger-type-segment {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-2);
}
.ledger-type-segment button {
  min-height: 40px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink-2);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.ledger-type-segment button.active {
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: var(--check-shadow);
}
.ledger-form-actions {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.ledger-form-actions .btn-add { min-width: 92px; }
.ledger-form-actions .text-btn { padding-left: 12px; padding-right: 12px; }

/* 账本表单底部操作固定在滚动区域底部 */
.ledger-form-actions {
  position: sticky;
  bottom: -20px;
  z-index: 2;
  margin-left: -18px;
  margin-right: -18px;
  padding: 14px 18px 20px;
  background: var(--surface);
}
