/* ── Reset & 基础 ─────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

:root {
  /* 浅色底 + 蓝色强调主题 */
  --accent:         #3B78E7;   /* 强调蓝：文字/链接/图标 */
  --accent-solid:   #3B78E7;   /* 实心按钮主色 */
  --accent-solid-hover: #2F66D5;
  --accent-glow:    rgba(59, 120, 231, 0.25);
  --accent-tint:    rgba(59, 120, 231, 0.12);
  --orange:         #FF8C42;   /* 产品语义橙：仅用于“今天”标记与选中日期 */
  --orange-lt:      #FFF0E6;   /* 选中日期淡橙底 */
  --bg:             #FFFFFF;
  --surface:        #F5F7FA;
  --surface-hover:  #EEF1F6;
  --surface-active: #E6EAF1;
  --text1:          #1F2329;
  --text2:          #5F6B7A;
  --text3:          #9AA3AF;
  --divider:        #E5EAF0;
  --sunday:         #D32F2F;
  --saturday:       #1565C0;
  --error:          #D32F2F;
  --mode-color:     #3B78E7;
  --label-text:     #333333;   /* pastel 标签/chip 上的深色文字 */
  --radius-lg:   16px;
  --radius-md:   10px;
  --radius-sm:   6px;
}

body {
  font-family: 'Inter', -apple-system, 'PingFang SC', 'Helvetica Neue', sans-serif;
  background: #E9EBEF;
  height: 100dvh;
  overflow: hidden;
  color: var(--text1);
}

.share-preview-image {
  position: fixed;
  width: 1px;
  height: 1px;
  left: 0;
  top: 0;
  opacity: 0;
  pointer-events: none;
  z-index: -1;
}

/* ── 外层容器（桌面居中模拟手机）────────────────────── */
#app-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100dvh;
  background: linear-gradient(135deg, #E9EBEF 0%, #F3F4F7 100%);
  padding: 0;
}

/* ── App 主体 ─────────────────────────────────────────── */
#app {
  position: relative;
  width: 100%;
  max-width: 390px;
  height: 100dvh;
  max-height: 844px;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 8px 48px rgba(0,0,0,0.12), 0 0 0 1px rgba(0,0,0,0.06);
}

/* 独立滚动容器：内容区单独滚动，底部导航作为 flex 固定行不随内容移动 */
#app-scroll {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
}

#app-scroll::-webkit-scrollbar { width: 3px; }
#app-scroll::-webkit-scrollbar-thumb { background: var(--divider); border-radius: 2px; }

/* 桌面端显示圆角，模拟 Android 手机 */
@media (min-height: 860px) and (min-width: 440px) {
  #app { border-radius: 44px; }
}

/* ── 分隔线 ───────────────────────────────────────────── */
.divider {
  height: 0.5px;
  background: var(--divider);
  flex-shrink: 0;
}

/* ─────────────────────────────────────────────────────── */
/* ── 顶部导航栏 ────────────────────────────────────────── */
/* ─────────────────────────────────────────────────────── */
#topbar {
  position: sticky;
  top: 0;
  z-index: 12;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 2px 7px;
  flex-shrink: 0;
  background: var(--bg);
}

#month-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.icon-btn {
  background: none;
  border: none;
  font-size: 30px;
  color: var(--text2);
  cursor: pointer;
  padding: 2px 10px;
  line-height: 1;
  border-radius: var(--radius-sm);
  transition: background 0.15s, color 0.15s;
  user-select: none;
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text1); }
.icon-btn:active { background: var(--surface-active); }

.menu-trigger {
  position: absolute;
  left: 8px;
  font-size: 23px;
  width: 42px;
  padding: 4px 6px;
  color: var(--mode-color);
}

/* 顶栏选中模式图标组：全部选中模式以叠放小圆标展示，
   数量越多单个越小、重叠越多，整体宽度封顶，绝不挤压中间月份导航 */
#topbar-mode-icons {
  position: absolute;
  left: 54px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  pointer-events: none;  /* 纯展示，不遮挡任何点击区域 */
}
.topbar-mode-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1.5px solid var(--bg);  /* 白圈分隔叠放的相邻图标 */
  box-sizing: border-box;
  font-size: 11px;
  line-height: 1;
  background: color-mix(in srgb, var(--item-color) 16%, white);
}
.topbar-mode-icon + .topbar-mode-icon { margin-left: -8px; }
/* 1-2 个时图标更大更舒展；3 个以上逐步加重重叠，整组宽度最多约 60px */
#topbar-mode-icons[data-count="1"] .topbar-mode-icon { width: 26px; height: 26px; font-size: 15px; }
#topbar-mode-icons[data-count="2"] .topbar-mode-icon { width: 22px; height: 22px; font-size: 13px; }
#topbar-mode-icons[data-count="2"] .topbar-mode-icon + .topbar-mode-icon { margin-left: -6px; }
#topbar-mode-icons[data-count="3"] .topbar-mode-icon + .topbar-mode-icon { margin-left: -9px; }
#topbar-mode-icons[data-count="4"] .topbar-mode-icon + .topbar-mode-icon,
#topbar-mode-icons[data-count="5"] .topbar-mode-icon + .topbar-mode-icon { margin-left: -10px; }

#month-title {
  flex: 0 0 104px;
  text-align: center;
  font-size: 19px;
  font-weight: 700;
  color: var(--text1);
  letter-spacing: 0.5px;
  user-select: none;
}

#btn-today {
  position: absolute;
  right: 0;
  background: none;
  border: none;
  color: var(--orange);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 16px;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
  font-family: inherit;
  white-space: nowrap;
}
#btn-today:hover { background: var(--orange-lt); }
#btn-today:active { opacity: 0.8; }

/* ─────────────────────────────────────────────────────── */
/* ── 星期标题行 ────────────────────────────────────────── */
/* ─────────────────────────────────────────────────────── */
#calendar-panel {
  display: flex;
  flex-direction: column;
  flex: 0 0 auto;
  overflow: hidden;
}

#week-header {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  padding: 5px 0 4px;
  flex-shrink: 0;
  background: var(--bg);
}

.wlabel {
  text-align: center;
  font-size: 12px;
  color: var(--text2);
  font-weight: 500;
  user-select: none;
}
.wlabel.sun { color: var(--sunday); }
.wlabel.sat { color: var(--saturday); }

/* ─────────────────────────────────────────────────────── */
/* ── 月历网格 ──────────────────────────────────────────── */
/* ─────────────────────────────────────────────────────── */
#month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-auto-rows: 78px;
  flex: 0 0 auto;
  min-height: 0;
  overflow: hidden;
}

.day-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2px 2px 3px;
  cursor: pointer;
  border-bottom: 0.5px solid var(--divider);
  overflow: hidden;
  transition: background 0.12s;
  user-select: none;
  box-sizing: border-box;
}
.day-cell:hover       { background: var(--surface-hover); }
.day-cell.selected    { background: var(--orange-lt); }
.day-cell.other-month { opacity: 0.25; cursor: pointer; }

/* 日期数字圆圈 */
.day-num {
  width: 22px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text1);
  flex-shrink: 0;
  line-height: 1;
  transition: background 0.15s, color 0.15s;
}
.day-num.is-today    { color: var(--orange); font-weight: 700; }
.day-num.is-selected:not(.is-today) { outline: none; }
.day-num.is-today.is-selected { background: transparent; color: var(--orange); outline: none; }
.day-num.is-sunday:not(.is-today)   { color: var(--sunday); }
.day-num.is-saturday:not(.is-today) { color: var(--saturday); }

/* 任务标签（pastel 浅色底，文字保持深色） */
.task-label {
  width: calc(100% - 2px);
  padding: 0 4px;
  border-radius: 3px;
  font-size: 9px;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
  color: var(--label-text);
  margin-top: 1px;
  flex-shrink: 0;
  font-weight: 500;
}

.task-label.completed {
  opacity: 0.42;
  text-decoration: line-through;
}

.day-cell.task-count-1 .task-label {
  padding: 2px 5px;
  font-size: 11px;
  line-height: 1.55;
  margin-top: 3px;
}

/* 当文本超过3个字符时，使用统一的较小字号 */
.day-cell.task-count-1 .task-label.text-long {
  font-size: 9px;
  line-height: 1.35;
  padding: 0 4px;
  margin-top: 1px;
}

.day-cell.task-count-2 .task-label,
.day-cell.task-count-3 .task-label {
  padding: 1px 5px;
  font-size: 10px;
  line-height: 1.45;
  margin-top: 2px;
}

.day-cell.task-count-2 .task-label.text-long,
.day-cell.task-count-3 .task-label.text-long {
  font-size: 9px;
  line-height: 1.35;
  padding: 0 4px;
  margin-top: 1px;
}

.day-cell.task-count-4 .task-label,
.day-cell.task-count-5 .task-label,
.day-cell.task-count-6 .task-label,
.day-cell.task-count-7 .task-label,
.day-cell.task-count-8 .task-label {
  padding: 0 4px;
  font-size: 9px;
  line-height: 1.35;
  margin-top: 1px;
}

/* ─────────────────────────────────────────────────────── */
/* ── 选中日期任务面板 ────────────────────────────────── */
/* ─────────────────────────────────────────────────────── */
#day-panel {
  display: flex;
  flex-direction: column;
  flex: 0 0 auto;
  min-height: 0;
  overflow: visible;
  background: var(--surface);
}

#day-header {
  position: sticky;
  top: 52px;
  z-index: 11;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  padding: 12px 16px 10px;
  border-bottom: 0.5px solid var(--divider);
  flex-shrink: 0;
}

#day-title {
  flex: 1;
  min-width: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text1);
  user-select: none;
}

#task-list {
  flex: 0 0 auto;
  min-height: 0;
  overflow: visible;
  background: var(--surface);
  padding-bottom: 32px;
}

.task-group {
  background: var(--bg);
  border-bottom: 0.5px solid var(--divider);
}

.task-row:last-child .task-divider { display: none; }
.task-row {
  transform: translateY(0) scale(1);
  transform-origin: center;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-radius 0.18s ease;
}

/* 任务条目 */
.task-item {
  display: flex;
  align-items: center;
  padding-left: 16px;
  transition: background 0.12s;
  gap: 8px;
}
.task-row.dragging {
  position: relative;
  z-index: 3;
  overflow: hidden;
  border-radius: 10px;
  background: var(--bg);
  box-shadow:
    0 12px 30px rgba(0, 0, 0, 0.12),
    0 2px 8px rgba(59, 120, 231, 0.15);
  outline: 1px solid rgba(59, 120, 231, 0.2);
  transform: translateY(-3px) scale(0.985);
  will-change: transform;
}
.task-row.dragging .task-item { background: var(--bg); }
.task-row.dragging .task-divider { visibility: hidden; }

.task-dragging { cursor: grabbing; user-select: none; }
.task-dragging .task-item { cursor: grabbing; }
.task-complete {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--text3);
  background: var(--bg);
  color: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  transition: transform 0.12s, background 0.12s, color 0.12s;
}

.task-complete:hover { transform: scale(1.08); }
.task-complete:active { transform: scale(0.92); }
.task-complete[aria-pressed="true"] {
  background: var(--accent-solid);
  border-color: var(--accent-solid);
  color: #fff;
}

.task-edit-button {
  min-width: 0;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px 12px 0;
  border: none;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
}

@media (hover: hover) {
  .task-item:hover { background: var(--surface-hover); }
}

.task-item:has(.task-edit-button:active),
.task-item:has(.task-complete:active) {
  background: var(--surface-hover);
}

.task-row.dragging .task-item,
.task-row.dragging .task-edit-button {
  background: var(--bg);
}

.task-bar {
  width: 4px;
  height: 42px;
  border-radius: 2px;
  flex-shrink: 0;
}

.task-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.task-subject {
  font-size: 15px;
  font-weight: 600;
  color: var(--text1);
}
.task-demo-badge {
  display: inline-flex;
  align-items: center;
  height: 17px;
  margin-right: 6px;
  padding: 0 5px;
  border-radius: 5px;
  background: color-mix(in srgb, var(--mode-color) 13%, white);
  color: color-mix(in srgb, var(--mode-color) 82%, #273142);
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  vertical-align: 1px;
}
.demo-task-label { outline: 1px dashed color-mix(in srgb, currentColor 32%, transparent); }

.task-title-text {
  font-size: 13px;
  color: var(--text2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.task-note-text {
  font-size: 11px;
  color: var(--text3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.task-item.completed .task-subject,
.task-item.completed .task-title-text,
.task-item.completed .task-note-text {
  color: var(--text3);
  text-decoration: line-through;
}

.task-item.completed .task-bar { opacity: 0.38; }

.task-arrow {
  font-size: 22px;
  color: var(--text3);
  line-height: 1;
  flex-shrink: 0;
}

.task-divider {
  height: 0.5px;
  background: var(--divider);
  margin-left: 50px;
}

.task-complete:focus-visible,
.task-edit-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* 空状态 */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 190px;
  gap: 8px;
  padding: 20px;
}

.empty-main { font-size: 14px; color: var(--text2); }
.empty-hint { font-size: 12px; color: var(--text3); }

/* ─────────────────────────────────────────────────────── */
/* ── 悬浮按钮 FAB ──────────────────────────────────────── */
/* ─────────────────────────────────────────────────────── */
#fab {
  position: fixed;
  bottom: max(72px, calc(env(safe-area-inset-bottom) + 72px));
  right: max(20px, calc((100vw - 390px) / 2 + 20px));
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--accent-solid);
  color: #fff;
  font-size: 30px;
  line-height: 1;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 18px var(--accent-glow);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow 0.15s, background 0.15s;
  z-index: 20;
  user-select: none;
}
#fab:hover {
  transform: scale(1.1);
  background: var(--accent-solid-hover);
  box-shadow: 0 6px 24px var(--accent-glow);
}
#fab:active {
  transform: scale(0.93);
  box-shadow: 0 2px 10px var(--accent-glow);
}

/* ── 日期多选：圈选高亮与底部操作条 ───────────────────── */
.day-cell.range-selected { background: color-mix(in srgb, var(--mode-color) 15%, white); }
.day-cell.range-anchor   { background: color-mix(in srgb, var(--mode-color) 26%, white); }
.day-cell.range-selected .day-num { font-weight: 600; }

#date-select-bar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: max(76px, calc(env(safe-area-inset-bottom) + 76px));
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 8px 8px 16px;
  background: var(--bg);
  border-radius: 999px;
  box-shadow: 0 8px 28px rgba(31, 35, 41, 0.16);
  z-index: 25;
}
#date-select-count { font-size: 14px; color: var(--text2); white-space: nowrap; }
#btn-date-select-add {
  border: none;
  border-radius: 999px;
  padding: 8px 16px;
  background: var(--accent-solid);
  color: #fff;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
}
#btn-date-select-add:hover { background: var(--accent-solid-hover); }
#btn-date-select-cancel {
  border: none;
  background: none;
  padding: 8px 10px;
  color: var(--text2);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
}
/* 多选期间隐藏 FAB，避免与操作条混淆 */
body.date-selecting #fab { display: none; }

/* ─────────────────────────────────────────────────────── */
/* ── 遮罩层 ────────────────────────────────────────────── */
/* ─────────────────────────────────────────────────────── */
#overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.38);
  z-index: 100;
  backdrop-filter: blur(1px);
  -webkit-backdrop-filter: blur(1px);
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ─────────────────────────────────────────────────────── */
/* ── 底部弹窗（新增/编辑）─────────────────────────────── */
/* ─────────────────────────────────────────────────────── */
#task-sheet {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%) translateY(102%);
  width: 100%;
  max-width: 390px;
  background: var(--bg);
  border-radius: 22px 22px 0 0;
  z-index: 200;
  transition: transform 0.32s cubic-bezier(0.32, 0.72, 0, 1);
  max-height: 88vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: 0 -4px 32px rgba(0,0,0,0.14);
}

#task-sheet.visible {
  transform: translateX(-50%) translateY(0);
}

/* 隐藏弹窗滚动条 */
#task-sheet::-webkit-scrollbar { display: none; }

.sheet-drag-bar {
  width: 38px;
  height: 4px;
  background: var(--divider);
  border-radius: 2px;
  margin: 12px auto 4px;
}

#sheet-content {
  padding: 12px 20px 48px;
}

#sheet-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text1);
  margin-bottom: 22px;
}

/* ── 表单 ─────────────────────────────────────────────── */
.form-section {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: 13px;
  color: var(--text2);
  font-weight: 500;
  margin-bottom: 9px;
}

/* 科目 Chips */
#subject-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 10px;
}

.subject-chip {
  padding: 6px 13px;
  border-radius: 20px;
  border: 1px solid var(--divider);
  background: transparent;
  font-size: 13px;
  color: var(--text2);
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  font-weight: 500;
  line-height: 1;
}
.subject-chip:hover { border-color: var(--text3); color: var(--text1); }
.subject-chip.selected {
  border-color: transparent;
  color: var(--label-text);
  font-weight: 600;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.08);
}

/* 输入框 */
input[type="text"],
input[type="number"],
textarea {
  width: 100%;
  border: 1.5px solid var(--divider);
  border-radius: var(--radius-md);
  padding: 11px 14px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text1);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  resize: none;
  background: var(--surface);
  -webkit-appearance: none;
}
input[type="text"]::placeholder,
input[type="number"]::placeholder,
textarea::placeholder { color: var(--text3); }

input[type="text"]:focus,
input[type="number"]:focus,
textarea:focus {
  border-color: var(--mode-color);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--mode-color) 14%, transparent);
}

.amount-input-wrap {
  display: flex;
  align-items: center;
  border: 1.5px solid var(--divider);
  border-radius: var(--radius-md);
  padding-left: 14px;
  background: var(--surface);
}
.amount-input-wrap:focus-within { border-color: var(--mode-color); }
.amount-prefix { color: var(--text2); font-size: 16px; font-weight: 600; }
.amount-input-wrap input[type="number"] {
  border: none;
  border-radius: var(--radius-md);
  box-shadow: none;
}

/* 错误提示 */
.error-text {
  display: block;
  font-size: 12px;
  color: var(--error);
  margin-top: 5px;
}

/* 保存按钮 */
#btn-save {
  width: 100%;
  height: 50px;
  background: var(--accent-solid);
  color: #fff;
  border: none;
  border-radius: var(--radius-lg);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s, background 0.15s;
  font-family: inherit;
  margin-bottom: 10px;
  letter-spacing: 0.3px;
}
#btn-save:hover  { background: var(--accent-solid-hover); }
#btn-save:active { transform: scale(0.98); opacity: 0.88; }

/* 删除按钮 */
#btn-delete {
  width: 100%;
  height: 46px;
  background: none;
  color: var(--error);
  border: none;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  border-radius: var(--radius-md);
  transition: background 0.15s;
}
#btn-delete:hover { background: #FFF5F5; }

/* ─────────────────────────────────────────────────────── */
/* ── 删除确认对话框 ─────────────────────────────────────── */
/* ─────────────────────────────────────────────────────── */
#delete-dialog {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  animation: fadeIn 0.18s ease;
}

#dialog-box {
  background: var(--bg);
  border-radius: var(--radius-lg);
  padding: 26px 24px 20px;
  width: 290px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  animation: dialogIn 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes dialogIn {
  from { transform: scale(0.88); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}

#dialog-box h3 {
  font-size: 17px;
  font-weight: 700;
  color: var(--text1);
  margin-bottom: 8px;
}

#dialog-box p {
  font-size: 14px;
  color: var(--text2);
  line-height: 1.6;
  margin-bottom: 22px;
}

.dialog-actions {
  display: flex;
  gap: 10px;
}

.dialog-actions button {
  flex: 1;
  height: 46px;
  border-radius: var(--radius-md);
  border: none;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.15s;
}
.dialog-actions button:hover  { opacity: 0.88; }
.dialog-actions button:active { opacity: 0.75; }

#btn-cancel-delete  { background: var(--surface); color: var(--text1); }
#btn-confirm-delete { background: var(--error);   color: #fff; }

/* ─────────────────────────────────────────────────────── */
/* ── 通用工具类 ─────────────────────────────────────────── */
/* ─────────────────────────────────────────────────────── */
/* ── 月份切换滑入动画 ──────────────────────── */
@keyframes slideFromLeft {
  from { transform: translateX(-22px); opacity: 0; }
  to   { transform: translateX(0);     opacity: 1; }
}
@keyframes slideFromRight {
  from { transform: translateX(22px);  opacity: 0; }
  to   { transform: translateX(0);     opacity: 1; }
}
#month-grid.slide-from-left  { animation: slideFromLeft  0.22s cubic-bezier(0.25, 0.46, 0.45, 0.94); }
#month-grid.slide-from-right { animation: slideFromRight 0.22s cubic-bezier(0.25, 0.46, 0.45, 0.94); }

/* ── 弹窗日期副标题 ────────────────────── */
.sheet-date-label {
  font-size: 13px;
  color: var(--orange);
  font-weight: 600;
  margin-top: -16px;
  margin-bottom: 20px;
  letter-spacing: 0.2px;
}

.hidden { display: none !important; }

/* ── 首次使用引导 ─────────────────────────────────────── */
#onboarding { position: fixed; inset: 0; z-index: 600; pointer-events: none; }
.onboarding-shade { position: absolute; inset: 0; background: transparent; animation: fadeIn 220ms ease both; }
.onboarding-target {
  z-index: 610 !important;
  border-radius: 12px;
  pointer-events: none;
}
.day-cell.onboarding-target { position: relative; }
.onboarding-spotlight {
  position: fixed;
  z-index: 615;
  box-sizing: border-box;
  pointer-events: none;
  animation: onboardingSpotlightPulse 1.6s ease-in-out infinite;
}
.onboarding-card {
  position: absolute; z-index: 620; left: 50%; bottom: max(28px, env(safe-area-inset-bottom));
  width: min(calc(100vw - 32px), 358px); padding: 20px; border-radius: 20px;
  background: var(--bg); box-shadow: 0 18px 50px rgba(0,0,0,0.2); pointer-events: auto;
  opacity: 0; transform: translate(-50%, 14px) scale(0.98);
  transition: opacity 180ms ease, transform 220ms cubic-bezier(0.22, 1, 0.36, 1);
}
.onboarding-card.is-visible { opacity: 1; transform: translate(-50%, 0) scale(1); }
#onboarding[data-step="4"] .onboarding-card { bottom: max(108px, calc(env(safe-area-inset-bottom) + 88px)); }
.onboarding-progress { display: flex; gap: 5px; margin-bottom: 18px; }
.onboarding-progress span { width: 18px; height: 4px; border-radius: 4px; background: #E7E7E7; transition: width 220ms ease, background 220ms ease; }
.onboarding-progress span.active { width: 32px; background: var(--mode-color); }
.onboarding-kicker { margin-bottom: 7px; color: var(--mode-color); font-size: 12px; font-weight: 700; }
.onboarding-card h2 { margin-bottom: 8px; font-size: 20px; line-height: 1.3; }
.onboarding-card > p:not(.onboarding-kicker) { color: var(--text2); font-size: 14px; line-height: 1.65; }
.onboarding-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 20px; }
.onboarding-actions button { border: 0; border-radius: 10px; padding: 11px 16px; font: inherit; font-size: 14px; cursor: pointer; }
#btn-skip-tour { background: transparent; color: var(--text2); }
#btn-next-tour { min-width: 100px; background: var(--mode-color); color: white; font-weight: 600; }
@keyframes onboardingSpotlightPulse {
  0%, 100% {
    box-shadow:
      0 0 0 4px rgba(255, 255, 255, 0.98),
      0 0 0 9px color-mix(in srgb, var(--mode-color) 88%, transparent),
      0 0 22px 13px color-mix(in srgb, var(--mode-color) 76%, transparent),
      0 0 0 9999px rgba(0, 0, 0, 0.58);
  }
  50% {
    box-shadow:
      0 0 0 5px #fff,
      0 0 0 11px color-mix(in srgb, var(--mode-color) 94%, transparent),
      0 0 34px 19px color-mix(in srgb, var(--mode-color) 68%, transparent),
      0 0 0 9999px rgba(0, 0, 0, 0.58);
  }
}
@media (prefers-reduced-motion: reduce) {
  .onboarding-spotlight {
    animation: none;
    box-shadow:
      0 0 0 4px #fff,
      0 0 0 10px color-mix(in srgb, var(--mode-color) 90%, transparent),
      0 0 28px 15px color-mix(in srgb, var(--mode-color) 72%, transparent),
      0 0 0 9999px rgba(0, 0, 0, 0.58);
  }
  .onboarding-card, .onboarding-progress span { transition: none; }
}

/* ── 左侧模式菜单 ─────────────────────────────────────── */
#mode-overlay {
  position: fixed;
  inset: 0;
  z-index: 400;
  background: rgba(0, 0, 0, 0.32);
  opacity: 0;
  transition: opacity 220ms ease;
  backdrop-filter: blur(1px);
  -webkit-backdrop-filter: blur(1px);
}
#mode-overlay.visible { opacity: 1; }
#mode-overlay.fade-out { opacity: 0; }

#mode-drawer {
  position: fixed;
  z-index: 410;
  top: 0;
  bottom: 0;
  /* 桌面端跟随居中的手机模拟框，移动端自动贴合屏幕左侧 */
  left: max(0px, calc(50% - 195px));
  width: min(78vw, 300px);
  max-width: 390px;
  background: var(--bg);
  transform: translateX(-100%);
  transition:
    transform 280ms cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 280ms ease;
  box-shadow: 8px 0 32px rgba(0, 0, 0, 0);
  display: flex;
  flex-direction: column;
  padding: max(22px, env(safe-area-inset-top)) 18px 20px;
}
#mode-drawer.visible {
  transform: translateX(0);
  box-shadow: 8px 0 32px rgba(0, 0, 0, 0.12);
}
.drawer-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 26px; }
.drawer-brand { font-size: 22px; font-weight: 700; letter-spacing: 0.5px; }
.drawer-close { font-size: 28px; padding: 2px 8px; }
.drawer-caption { color: var(--text3); font-size: 12px; margin: 0 8px 8px; }
.mode-list { display: flex; flex-direction: column; gap: 5px; }
.mode-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 48px;
  padding: 0 12px;
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text1);
  font-family: inherit;
  font-size: 15px;
  text-align: left;
  cursor: pointer;
}
.mode-item:hover { background: var(--surface-hover); }
.mode-item.selected { background: color-mix(in srgb, var(--item-color) 13%, white); font-weight: 600; }
.mode-item.selected::before { content: ''; width: 3px; height: 24px; margin-left: -12px; background: var(--item-color); border-radius: 0 3px 3px 0; }
.mode-item.selected::after { content: '✓'; margin-left: auto; color: var(--item-color); font-size: 15px; }
@keyframes modeItemShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  50% { transform: translateX(4px); }
  75% { transform: translateX(-2px); }
}
.mode-item.shake { animation: modeItemShake 0.28s ease; }
.mode-icon { width: 24px; text-align: center; font-size: 19px; }
/* “全部”行：选中态使用强调蓝而非某个模式色，下方细分线与具体模式隔开 */
.mode-item-all { --item-color: var(--accent); }
.mode-list-divider { height: 1px; background: var(--divider); margin: 3px 8px 8px; }
.drawer-footer { margin-top: auto; padding-top: 18px; border-top: 1px solid var(--divider); display: grid; gap: 4px; }
.drawer-action { border: none; background: none; text-align: left; padding: 11px 8px; color: var(--text2); font: inherit; cursor: pointer; border-radius: var(--radius-sm); }
.drawer-action:hover { background: var(--surface-hover); color: var(--text1); }
.drawer-action span { display: inline-block; width: 25px; text-align: center; margin-right: 6px; }

/* ── 添加模式 ─────────────────────────────────────────── */
#add-mode-dialog {
  position: fixed;
  inset: 0;
  z-index: 460;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  animation: fadeIn 0.18s ease;
}

.mode-dialog-box {
  width: min(100%, 330px);
  padding: 24px 22px 20px;
  border-radius: 20px;
  background: var(--bg);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
  animation: dialogIn 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}

.mode-dialog-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  margin-bottom: 16px;
  border-radius: 13px;
  background: color-mix(in srgb, var(--mode-color) 14%, white);
  color: var(--mode-color);
  font-size: 25px;
  line-height: 1;
}

.mode-dialog-box h2 {
  margin-bottom: 6px;
  color: var(--text1);
  font-size: 19px;
  line-height: 1.3;
}

.mode-dialog-box > p {
  margin-bottom: 20px;
  color: var(--text2);
  font-size: 13px;
  line-height: 1.5;
}

.mode-dialog-box .form-label { margin-bottom: 8px; }
.mode-dialog-box .error-text { min-height: 18px; margin-top: 6px; }

.mode-dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1.35fr;
  gap: 10px;
  margin-top: 18px;
}

.mode-dialog-actions button {
  height: 44px;
  border: none;
  border-radius: var(--radius-md);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}

.mode-dialog-actions button:hover { opacity: 0.9; }
.mode-dialog-actions button:active { opacity: 0.78; transform: scale(0.98); }
#btn-cancel-add-mode { background: var(--surface); color: var(--text1); }
#btn-confirm-add-mode { background: var(--mode-color); color: white; }

/* ── 模式管理 ─────────────────────────────────────────── */
#mode-manager {
  position: fixed;
  inset: 0;
  z-index: 450;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.4);
}
.manager-box { width: min(100%, 360px); max-height: 82vh; overflow: auto; background: var(--bg); border-radius: var(--radius-lg); padding: 20px; box-shadow: 0 10px 40px rgba(0,0,0,0.18); }
.manager-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.manager-header h2 { font-size: 18px; }
.managed-mode-list { display: grid; gap: 8px; }
.managed-mode-item { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 8px; border-bottom: 1px solid var(--divider); }
.managed-mode-icon { width: 24px; text-align: center; }
.managed-mode-name { flex: 1; font-size: 14px; }
.mode-edit, .mode-move-up, .mode-move-down, .mode-toggle, .mode-delete { border: none; background: var(--surface); color: var(--text2); border-radius: var(--radius-sm); padding: 6px 7px; font: inherit; font-size: 12px; cursor: pointer; }
.mode-delete { color: var(--error); background: #FFF5F5; }
.manager-actions { margin-top: 18px; }
#btn-manager-done { width: 100%; height: 44px; border: none; border-radius: var(--radius-md); background: var(--mode-color); color: white; font: inherit; font-weight: 600; cursor: pointer; }
.finance-marker { color: var(--mode-color); font-size: 13px; }
.finance-amount { color: var(--mode-color); font-weight: 600; }

/* ── 底部导航 ─────────────────────────────────────────── */
#page-calendar,
#page-profile {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
#page-calendar[hidden],
#page-profile[hidden] { display: none; }

#bottom-nav {
  display: flex;
  flex-shrink: 0;
  height: calc(56px + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--bg);
  border-top: 1px solid var(--divider);
  box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.06);
}

.nav-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 10.5px;
  font-weight: 500;
  color: var(--text3);
  cursor: pointer;
  transition: color 0.15s;
}
.nav-tab svg { width: 22px; height: 22px; }
.nav-tab.active { color: var(--accent); font-weight: 600; }

/* FAB 只在月历页显示 */
#app.tab-profile #fab { display: none; }

/* ── 我的页 ───────────────────────────────────────────── */
#page-profile { background: var(--surface); }

#profile-header {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px 16px 12px;
  background: var(--bg);
  flex-shrink: 0;
}
#profile-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text1);
  user-select: none;
}

#profile-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px;
}

.profile-card {
  background: var(--bg);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}
.profile-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 48px;
  padding: 0 16px;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 14px;
  color: var(--text1);
  text-align: left;
  cursor: pointer;
  transition: background 0.12s;
}
.profile-row + .profile-row { border-top: 0.5px solid var(--divider); }
.profile-row:hover { background: var(--surface-hover); }
.profile-row:active { background: var(--surface-active); }
.profile-chevron { color: var(--text3); font-size: 18px; line-height: 1; }

/* ── 关于弹窗 ─────────────────────────────────────────── */
#about-dialog {
  position: fixed;
  inset: 0;
  z-index: 460;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  animation: fadeIn 0.18s ease;
}
.about-box { text-align: center; width: min(100%, 352px); }
#btn-close-about {
  width: 100%;
  height: 44px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--accent-solid);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
#btn-close-about:hover { background: var(--accent-solid-hover); }

/* ── 账号卡片与退出登录 ────────────────────────────────── */
.profile-card + .profile-card { margin-top: 12px; }
.account-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  padding: 0 16px;
}
.account-label { font-size: 14px; color: var(--text2); flex-shrink: 0; }
.account-email {
  font-size: 14px;
  font-weight: 600;
  color: var(--text1);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.logout-text { color: var(--error); }

/* ── 登录页 ───────────────────────────────────────────── */
#login-page {
  position: fixed;
  inset: 0;
  z-index: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, #E9EBEF 0%, #F3F4F7 100%);
}
.login-card {
  width: min(100%, 358px);
  padding: 28px 24px 24px;
  border-radius: 20px;
  background: var(--bg);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.12);
}
.login-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--text1);
  text-align: center;
}
.login-subtitle {
  margin: 6px 0 24px;
  font-size: 13px;
  color: var(--text2);
  text-align: center;
}
.login-primary {
  width: 100%;
  height: 48px;
  margin-top: 14px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--accent-solid);
  color: #fff;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}
.login-primary:hover:not(:disabled) { background: var(--accent-solid-hover); }
.login-primary:disabled { opacity: 0.55; cursor: default; }
.login-secondary {
  width: 100%;
  height: 44px;
  margin-top: 10px;
  border: 1px solid var(--divider);
  border-radius: var(--radius-md);
  background: var(--bg);
  color: var(--accent);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}
.login-secondary:hover:not(:disabled) { background: var(--surface-hover); }
.login-secondary:disabled { color: var(--text3); cursor: default; }
.login-back {
  width: 100%;
  margin-top: 10px;
  border: none;
  background: none;
  color: var(--text2);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  padding: 6px;
}
.login-hint {
  margin-top: 14px;
  font-size: 12px;
  color: var(--text3);
  text-align: center;
}
.login-sent-hint {
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--text2);
  line-height: 1.5;
}
.login-dev {
  margin-top: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--accent-tint);
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 1px;
  text-align: center;
}

/* ── 游客写操作登录提示 ─────────────────────────────────── */
#guest-login-dialog {
  position: fixed;
  inset: 0;
  z-index: 460;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  animation: fadeIn 0.18s ease;
}
#btn-guest-continue { background: var(--surface); color: var(--text1); }
#btn-guest-login { background: var(--accent-solid); color: #fff; }
#btn-guest-login:hover { background: var(--accent-solid-hover); }
.login-text { color: var(--accent); font-weight: 600; }

/* 移动端适配 */
@media (max-width: 439px) {
  #app {
    border-radius: 0;
    max-height: 100dvh;
  }
  #app-wrapper {
    background: var(--bg);
  }
}

/* 隐藏模式对话框中的加号图标（保留 DOM，方便恢复） */
.mode-dialog-icon {
  display: none !important;
}
