/* =========================================================
   Todo · 极简多设备样式（参考 Microsoft To Do）
   ========================================================= */
:root {
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --accent: #6e7eff;
  --accent-strong: #5b6cff;
  --amber: #f5a524;
  --green: #30c75e;
  --red: #ff5a5f;
  --sb-w: 236px;
  --sb-mini: 56px;
}

/* 亮色模式 */
:root, [data-theme="light"] {
  color-scheme: light;
  --bg: #f4f5f8;
  --sb-bg: #eceef3;
  --card: #ffffff;
  --card-hover: #fafbfe;
  --surface: #ffffff;
  --surface-2: #e9ecf2;
  --hover: rgba(15, 23, 42, .055);
  --active: rgba(91, 108, 255, .13);
  --text: #1c1e24;
  --text-2: #525766;
  --muted: #8a90a0;
  --border: rgba(15, 23, 42, .08);
  --card-border: rgba(15, 23, 42, .06);
  --check-border: #8f96a8;
  --title-color: #4f5fff;
  --shadow: 0 12px 36px rgba(15, 23, 42, .12), 0 2px 6px rgba(15, 23, 42, .05);
  --card-shadow: 0 1px 2px rgba(15, 23, 42, .04);
  --toast-bg: #1e2028;
}

/* 暗色模式（参考 Microsoft To Do 深色质感） */
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #18191c;
  --sb-bg: #1e2025;
  --card: #25272d;
  --card-hover: #2c2f37;
  --surface: #25272d;
  --surface-2: #31343d;
  --hover: rgba(255, 255, 255, .06);
  --active: rgba(110, 126, 255, .18);
  --text: #f0f1f5;
  --text-2: #b9becb;
  --muted: #858a99;
  --border: rgba(255, 255, 255, .075);
  --card-border: rgba(255, 255, 255, .04);
  --check-border: #9197a6;
  --title-color: #7c8cff;
  --shadow: 0 18px 48px rgba(0, 0, 0, .55), 0 2px 8px rgba(0, 0, 0, .3);
  --card-shadow: 0 1px 2px rgba(0, 0, 0, .2);
  --toast-bg: #323540;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
input:focus-visible, textarea:focus-visible, [contenteditable]:focus-visible { outline: none; }
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }

.ic { width: 18px; height: 18px; flex: none; }
.spacer { flex: 1; }
kbd {
  font-family: inherit; font-size: 11px; line-height: 1;
  min-width: 18px; height: 18px; padding: 0 5px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 5px; background: var(--surface-2); color: var(--muted);
  border: 1px solid var(--border);
}
kbd + kbd { margin-left: 3px; }

/* ---------- 主体布局（右侧详情采用挤出式，无遮罩弹窗） ---------- */
.app {
  display: grid;
  grid-template-columns: var(--sb-w) minmax(0, 1fr) 0px;
  height: 100vh; height: 100dvh;
  transition: grid-template-columns .22s var(--ease);
}
.app.sb-collapsed {
  grid-template-columns: var(--sb-mini) minmax(0, 1fr) 0px;
}
.app.detail-open {
  grid-template-columns: var(--sb-w) minmax(0, 1fr) 292px;
}
.app.sb-collapsed.detail-open {
  grid-template-columns: var(--sb-mini) minmax(0, 1fr) 292px;
}

/* ---------- 左侧边栏（展开/收起按钮在侧边栏内） ---------- */
.sidebar {
  background: var(--sb-bg);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  min-width: 0; overflow: hidden;
  padding: 12px 10px 10px;
}
.sb-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 6px; padding: 2px 2px 14px 4px; min-height: 38px;
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 680; font-size: 15px; min-width: 0; overflow: hidden; }
.brand-icon { width: 24px; height: 24px; border-radius: 6px; flex: none; object-fit: cover; }

.app.sb-collapsed .sidebar { padding-left: 8px; padding-right: 8px; }
.app.sb-collapsed .sb-head { justify-content: center; padding: 2px 0 14px; }
.app.sb-collapsed .brand,
.app.sb-collapsed .sb-text,
.app.sb-collapsed .nav-item .count,
.app.sb-collapsed .sb-section-head .sb-text { display: none; }
.app.sb-collapsed .nav-item { justify-content: center; padding: 0; }
.app.sb-collapsed .sb-section-head { justify-content: center; padding: 0; }
.app.sb-collapsed .sb-foot { flex-direction: column; gap: 6px; padding-top: 8px; }
.app.sb-collapsed .sync { justify-content: center; padding: 0; width: 32px; flex: none; }

.nav { display: flex; flex-direction: column; gap: 1px; }
.nav-item {
  display: flex; align-items: center; gap: 9px;
  width: 100%; height: 32px; padding: 0 9px;
  border-radius: 7px; font-size: 13px; color: var(--text-2); text-align: left; white-space: nowrap;
  transition: background .14s, color .14s;
}
.nav-item .ic { width: 16px; height: 16px; }
.nav-item:hover { background: var(--hover); color: var(--text); }
.nav-item.active { background: var(--active); color: var(--text); font-weight: 600; }
.nav-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.nav-item .count { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.nav-item.drop-target { background: var(--active); box-shadow: inset 0 0 0 1.5px var(--accent); }
.nav-item.dragging { opacity: .4; }
.nav-item.drop-before { box-shadow: inset 0 2px 0 var(--accent); }
.nav-item.drop-after { box-shadow: inset 0 -2px 0 var(--accent); }
.nav-item.editing { background: var(--hover); }
.nav-item.editing input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; height: 100%; }

.ic-today { color: #7c8cff; }
.ic-all { color: #6495ed; }
.ic-important { color: #f5a524; }
.ic-monthly { color: #4dc4a8; }
.nav-item .count.warn {
  background: var(--red); color: #fff;
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 99px; font-size: 11px; font-weight: 650;
  display: inline-flex; align-items: center; justify-content: center;
}
.list-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); flex: none; margin: 0 4px; }

.sb-sep { height: 1px; background: var(--border); margin: 12px 4px; }
.sb-section { flex: 1; min-height: 0; overflow-y: auto; }

/* 侧边栏分组（参考 Microsoft To Do） */
.sb-group { display: flex; flex-direction: column; margin-bottom: 1px; }
.sb-group-head {
  display: flex; align-items: center; gap: 7px;
  height: 30px; padding: 0 5px 0 9px;
  border-radius: 7px; color: var(--text-2); cursor: pointer;
  transition: background .14s, color .14s;
}
.sb-group-head:hover { background: var(--hover); color: var(--text); }
.sb-group-head.drop-target { background: var(--active); box-shadow: inset 0 0 0 1.5px var(--accent); }
.sb-group-head .ic-folder { width: 16px; height: 16px; color: var(--muted); flex: none; transition: color .14s; }
.sb-group.open .sb-group-head .ic-folder { color: var(--title-color); }
.sb-group-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; font-weight: 500; }
.sb-group-acts { display: flex; align-items: center; gap: 1px; opacity: 0; transition: opacity .14s; }
.sb-group-head:hover .sb-group-acts { opacity: 1; }
.sb-group-body { display: none; flex-direction: column; gap: 1px; padding-left: 14px; margin-top: 1px; }
.sb-group.open .sb-group-body { display: flex; }

.app.sb-collapsed .sb-group-head { justify-content: center; padding: 0; }
.app.sb-collapsed .sb-group-name,
.app.sb-collapsed .sb-group-acts,
.app.sb-collapsed .sb-group-head .chev,
.app.sb-collapsed .sb-group-body { display: none !important; }

/* 侧边栏底部：新建列表 + 新建分组 */
.sb-create {
  display: flex; align-items: center; gap: 4px;
  padding: 6px 0; border-top: 1px solid var(--border);
}
.create-list-btn {
  flex: 1; height: 34px; padding: 0 10px; border-radius: 8px;
  display: flex; align-items: center; gap: 10px;
  font-size: 13.5px; color: var(--text-2); white-space: nowrap;
  transition: background .14s, color .14s;
}
.create-list-btn:hover { background: var(--hover); color: var(--text); }
.create-list-btn .ic { width: 16px; height: 16px; }
.app.sb-collapsed .sb-create { flex-direction: column; gap: 4px; }
.app.sb-collapsed .create-list-btn { justify-content: center; padding: 0; width: 32px; flex: none; }

.ic-list-item { color: var(--list-color, var(--title-color)); width: 17px; height: 17px; }

.sb-foot {
  display: flex; align-items: center; gap: 6px;
  padding-top: 8px; border-top: 1px solid var(--border);
}
.sync {
  display: flex; align-items: center; gap: 7px; flex: 1; height: 32px; padding: 0 8px;
  border-radius: 8px; font-size: 12px; color: var(--muted); white-space: nowrap; text-align: left;
  transition: background .14s, color .14s;
}
.sync:hover { background: var(--hover); color: var(--text); }
.sync .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); flex: none; }
.sync[data-state="ok"] .dot { background: var(--green); }
.sync[data-state="syncing"] .dot { background: var(--accent); animation: pulse 1s infinite; }
.sync[data-state="error"] .dot { background: var(--red); }
@keyframes pulse { 50% { opacity: .25; } }

#settingsBtn .ic { width: 15px; height: 15px; }
.icon-btn {
  width: 32px; height: 32px; flex: none;
  display: inline-grid; place-items: center;
  border-radius: 8px; color: var(--muted);
  transition: background .14s, color .14s;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.sm { width: 24px; height: 24px; }
.icon-btn.sm .ic { width: 16px; height: 16px; }
.icon-btn.danger:hover { color: var(--red); }
.icon-btn.star.on { color: var(--amber); }
.icon-btn.star.on .ic { fill: currentColor; }

/* ---------- 右侧主内容区（Microsoft To Do 极简卡片风格） ---------- */
.main {
  display: flex; flex-direction: column;
  min-width: 0; min-height: 0;
  background: var(--view-bg, var(--bg));
  transition: background .2s var(--ease);
}
.main.has-grad .task-inner,
.main.has-grad .composer,
.main.has-grad .done-toggle,
.main.has-grad .head-btn {
  background: color-mix(in srgb, var(--card) 86%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.main.has-grad .task-inner:hover,
.main.has-grad .composer:focus-within,
.main.has-grad .head-btn:hover {
  background: color-mix(in srgb, var(--card-hover) 92%, transparent);
}
.page-head {
  flex: none;
  display: flex; align-items: center; gap: 10px;
  padding: 24px 28px 16px;
}
.page-title-wrap { display: flex; align-items: center; gap: 10px; min-width: 0; }
h1 {
  font-size: 26px; font-weight: 700; letter-spacing: -.015em;
  color: var(--title-color);
  border-radius: 6px; padding: 0 4px; margin-left: -4px; outline: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
h1[contenteditable]:hover, h1[contenteditable]:focus { background: var(--hover); }
.head-actions { display: flex; align-items: center; gap: 6px; flex: none; }
.head-btn {
  width: 34px; height: 32px; border-radius: 7px;
  display: inline-grid; place-items: center;
  background: var(--card); color: var(--text-2);
  border: 1px solid var(--card-border);
  transition: background .14s, color .14s;
}
.head-btn:hover { background: var(--card-hover); color: var(--text); }
.mobile-only { display: none; }

.main-scroll { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 0 28px 16px; }
.main-inner { width: 100%; }

/* 任务卡片条（图 1 风格） */
.task-stack { display: flex; flex-direction: column; gap: 4px; }
.task {
  position: relative; border-radius: 7px; overflow: hidden;
}
.task-inner {
  position: relative; display: flex; align-items: center; gap: 11px;
  min-height: 38px; padding: 7px 12px;
  border-radius: 6px;
  background: var(--card);
  border: 1px solid var(--card-border);
  box-shadow: var(--card-shadow);
  touch-action: pan-y; cursor: default;
}
.task.selected .task-inner {
  background: color-mix(in srgb, var(--accent) 16%, var(--card));
  border-color: color-mix(in srgb, var(--accent) 32%, transparent);
}

.check {
  width: 16px; height: 16px; flex: none;
  border-radius: 50%; border: 1.5px solid var(--check-border);
  display: grid; place-items: center; color: transparent;
  transition: background .15s, border-color .15s, color .15s;
}
.check .ic { width: 10px; height: 10px; stroke-width: 2.9; }
.check:hover { border-color: var(--accent); color: color-mix(in srgb, var(--accent) 55%, transparent); }
.task.done .check, .check.is-done {
  background: var(--accent-strong); border-color: var(--accent-strong); color: #fff;
}

.task-body { flex: 1; min-width: 0; }
.task-title { font-size: 13.5px; line-height: 1.38; color: var(--text); word-break: break-word; }
.task.done .task-title {
  color: var(--muted);
  text-decoration: line-through;
  text-decoration-color: color-mix(in srgb, var(--muted) 75%, transparent);
}
.task-sub {
  display: flex; align-items: center; gap: 10px;
  margin-top: 2px; font-size: 12px; color: var(--muted);
}
.task-sub > span { display: inline-flex; align-items: center; gap: 4px; }
.task-sub .ic { width: 12px; height: 12px; }
.task-sub .list-dot { width: 7px; height: 7px; margin: 0; }

.star-btn {
  width: 24px; height: 24px; flex: none;
  display: grid; place-items: center; border-radius: 6px;
  color: var(--muted); transition: color .14s;
}
.star-btn .ic { width: 15px; height: 15px; }
.star-btn:hover { color: var(--amber); transform: scale(1.08); }
.star-btn.on { color: var(--amber); }
.star-btn.on .ic { fill: currentColor; }

.task.just-added .task-inner { animation: slideIn .25s var(--ease); }
@keyframes slideIn { from { opacity: 0; transform: translateY(-6px); } }
.task.dragging { opacity: .4; }
.task.drop-before { box-shadow: inset 0 2px 0 var(--accent); }
.task.drop-after { box-shadow: inset 0 -2px 0 var(--accent); }

/* 移动端滑动背景 */
.swipe-bg { position: absolute; inset: 0; display: none; align-items: center; gap: 8px; padding: 0 20px; color: #fff; font-weight: 600; font-size: 14px; }
.swipe-done { background: var(--green); justify-content: flex-start; }
.swipe-del { background: var(--red); justify-content: flex-end; }
.task.sw-right .swipe-done, .task.sw-left .swipe-del { display: flex; }

/* 已完成折叠组 */
.done-section { margin-top: 16px; }
.done-bar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 6px;
}
.done-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 9px;
  border-radius: 6px; background: var(--card); border: 1px solid var(--card-border);
  font-size: 12px; font-weight: 550; color: var(--text-2);
  transition: background .14s;
}
.done-toggle:hover { background: var(--card-hover); }
.done-toggle .count { color: var(--muted); }
.done-toggle .chev { width: 13px; height: 13px; transition: transform .2s var(--ease); }
.done-section.open .chev { transform: rotate(90deg); }
.clear-done-btn {
  display: inline-flex; align-items: center; gap: 4px;
  height: 26px; padding: 0 8px; border-radius: 6px;
  font-size: 12px; color: var(--muted);
  transition: background .14s, color .14s;
}
.clear-done-btn .ic { width: 13px; height: 13px; }
.clear-done-btn:hover { background: var(--hover); color: var(--red); }

.empty {
  text-align: center; padding: 72px 20px; color: var(--muted);
  font-size: 13.5px;
}

/* ---------- 底部固定添加任务栏（参考 Microsoft To Do：默认 +，聚焦变 ○） ---------- */
.bottom-bar {
  flex: none;
  padding: 10px 28px 20px;
}
.composer {
  display: flex; align-items: center; gap: 11px;
  height: 40px; padding: 0 13px;
  border-radius: 6px;
  background: var(--card);
  border: 1px solid var(--card-border);
  box-shadow: var(--card-shadow);
  transition: background .14s, border-color .14s;
}
.composer:focus-within {
  background: var(--card-hover);
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
}
.composer-icon {
  width: 16px; height: 16px; flex: none;
  display: grid; place-items: center;
  color: var(--title-color);
}
.composer-icon .c-plus { display: grid; place-items: center; }
.composer-icon .c-plus .ic { width: 16px; height: 16px; stroke-width: 1.8; }
.composer-icon .c-circle {
  display: none;
  width: 16px; height: 16px;
  border-radius: 50%; border: 1.5px solid var(--title-color);
}
.composer:focus-within .c-plus { display: none; }
.composer:focus-within .c-circle { display: block; }
.composer-input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: none;
  font-size: 13.5px; color: var(--text);
}
.composer-input::placeholder { color: var(--title-color); opacity: .9; }
.composer-day {
  flex: none; height: 26px; padding: 0 8px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text-2); font-size: 12px; font-weight: 500;
  outline: 0; cursor: pointer;
}
.composer-day:hover { color: var(--text); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }

/* ---------- 每月循环视图 & 5天到期告警 ---------- */
.monthly-alert-banner {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 9px 12px; margin-bottom: 10px;
  border-radius: 8px; text-align: left;
  background: color-mix(in srgb, var(--amber) 14%, var(--card));
  border: 1px solid color-mix(in srgb, var(--amber) 34%, transparent);
  color: var(--text); font-size: 12.5px;
  transition: background .14s, transform .14s;
}
.monthly-alert-banner:hover {
  background: color-mix(in srgb, var(--amber) 20%, var(--card));
}
.monthly-alert-banner.overdue {
  background: color-mix(in srgb, var(--red) 14%, var(--card));
  border-color: color-mix(in srgb, var(--red) 35%, transparent);
}
.monthly-alert-banner.overdue:hover {
  background: color-mix(in srgb, var(--red) 20%, var(--card));
}
.monthly-alert-banner .ic-alert { width: 16px; height: 16px; flex: none; color: var(--amber); }
.monthly-alert-banner.overdue .ic-alert { color: var(--red); }
.monthly-alert-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.monthly-alert-go {
  flex: none; display: inline-flex; align-items: center; gap: 2px;
  font-size: 12px; font-weight: 600; color: var(--amber);
}
.monthly-alert-banner.overdue .monthly-alert-go { color: var(--red); }
.monthly-alert-go .ic { width: 13px; height: 13px; }

.monthly-summary {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; margin-bottom: 10px;
  border-radius: 8px; background: var(--card);
  border: 1px solid var(--card-border);
  font-size: 12.5px; color: var(--text-2);
}
.monthly-summary strong { color: var(--text); font-weight: 650; }
.monthly-bar {
  flex: 1; height: 6px; border-radius: 99px;
  background: var(--surface-2); overflow: hidden;
}
.monthly-bar-fill {
  height: 100%; border-radius: 99px;
  background: var(--accent-strong);
  transition: width .25s var(--ease);
}

.task.m-overdue .task-inner {
  box-shadow: inset 3px 0 0 var(--red), var(--card-shadow);
}
.task.m-warn .task-inner {
  box-shadow: inset 3px 0 0 var(--amber), var(--card-shadow);
}
.m-badge {
  flex: none; padding: 2px 8px; border-radius: 99px;
  font-size: 11.5px; font-weight: 550; line-height: 1.4;
  white-space: nowrap; font-variant-numeric: tabular-nums;
  background: var(--surface-2); color: var(--muted);
}
.m-badge.overdue {
  background: color-mix(in srgb, var(--red) 18%, transparent);
  color: var(--red);
}
.m-badge.warn {
  background: color-mix(in srgb, var(--amber) 18%, transparent);
  color: var(--amber);
}
.m-badge.done {
  background: color-mix(in srgb, var(--green) 16%, transparent);
  color: var(--green);
}

/* 详情栏：近 6 个月打卡记录 */
.dt-months {
  border-top: 1px solid var(--border);
  padding: 12px 2px;
}
.dt-months-title {
  font-size: 12px; color: var(--muted); margin-bottom: 8px;
  display: flex; justify-content: space-between; align-items: center;
}
.dt-months-grid {
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 5px;
}
.dt-month-pill {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 6px 2px; border-radius: 7px;
  background: var(--surface-2); color: var(--muted);
  font-size: 11px; transition: background .12s, color .12s;
}
.dt-month-pill:hover { background: var(--hover); color: var(--text); }
.dt-month-pill .m-dot {
  width: 16px; height: 16px; border-radius: 50%;
  border: 1.5px solid var(--check-border);
  display: grid; place-items: center; color: transparent;
}
.dt-month-pill .m-dot .ic { width: 9px; height: 9px; stroke-width: 3; }
.dt-month-pill.done {
  background: color-mix(in srgb, var(--green) 15%, transparent);
  color: var(--green); font-weight: 600;
}
.dt-month-pill.done .m-dot {
  background: var(--green); border-color: var(--green); color: #fff;
}
.dt-month-pill.cur {
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 55%, transparent);
}
.tab { position: relative; }
.tab-badge {
  position: absolute; top: 1px; right: calc(50% - 16px);
  min-width: 15px; height: 15px; padding: 0 4px;
  border-radius: 99px; background: var(--red); color: #fff;
  font-size: 10px; font-weight: 700; line-height: 15px; text-align: center;
}

/* ---------- 右侧详情栏（Microsoft To Do 挤出式，无弹窗遮罩） ---------- */
.detail {
  background: var(--sb-bg);
  border-left: 1px solid transparent;
  display: flex; flex-direction: column;
  min-width: 0; min-height: 0; overflow: hidden;
  opacity: 0; transition: opacity .18s var(--ease), border-color .18s;
}
.app.detail-open .detail {
  opacity: 1;
  border-left-color: var(--border);
}
.scrim { position: fixed; inset: 0; z-index: 35; background: rgba(0, 0, 0, .35); opacity: 0; pointer-events: none; transition: opacity .22s; }

.dt-body { flex: 1; overflow-y: auto; padding: 24px 16px 16px; min-width: 260px; }
.dt-title-row { display: flex; align-items: flex-start; gap: 11px; padding-bottom: 14px; }
.dt-title-row .check { margin-top: 3px; }
.dt-title { flex: 1; min-width: 0; border: 0; outline: 0; background: none; resize: none; font-size: 15px; font-weight: 600; line-height: 1.4; color: var(--text); }
.task-done-title { color: var(--muted); text-decoration: line-through; }

.dt-row {
  display: flex; align-items: center; gap: 12px;
  width: 100%; min-height: 44px; padding: 6px 2px;
  border-top: 1px solid var(--border);
  font-size: 13px; color: var(--text-2); text-align: left;
  transition: color .14s;
}
.dt-row:hover { color: var(--text); }
.dt-row.active { color: var(--title-color); }
.dt-row .ic { width: 16px; height: 16px; color: inherit; opacity: .85; }
.dt-row .field {
  margin-left: auto; height: 26px; border: 0; outline: 0;
  border-radius: 6px; background: transparent; color: var(--text-2);
  font-size: 12.5px; cursor: pointer;
}
.dt-row .field:focus { background: var(--surface-2); padding: 0 6px; }
.dt-date-row { position: relative; cursor: pointer; }
.dt-date-val { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dt-date-clear {
  width: 22px; height: 22px; border-radius: 5px;
  display: inline-grid; place-items: center; color: var(--muted);
  margin-left: auto; flex: none; transition: background .12s, color .12s;
}
.dt-date-clear:hover { background: var(--hover); color: var(--text); }
.dt-date-clear .ic { width: 12px; height: 12px; }
.dt-row.overdue { color: var(--red); }

.dt-notes-wrap { border-top: 1px solid var(--border); padding-top: 12px; }
.dt-notes {
  width: 100%; min-height: 140px; border: 0; outline: 0; resize: none;
  background: none; font-size: 13px; line-height: 1.6; color: var(--text);
}
.dt-notes::placeholder { color: var(--muted); }

.dt-foot {
  flex: none; display: flex; align-items: center; justify-content: space-between;
  height: 42px; padding: 0 10px; min-width: 260px;
  border-top: 1px solid var(--border); font-size: 12px; color: var(--muted);
}

/* ---------- 右上角菜单 & 弹窗 ---------- */
.popover {
  position: fixed; right: 24px; top: 62px; z-index: 55;
  width: 210px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: var(--shadow);
  opacity: 0; transform: translateY(-6px); pointer-events: none;
  transition: opacity .14s, transform .14s var(--ease);
}
.popover.show { opacity: 1; transform: none; pointer-events: auto; }
.settings-pop {
  right: auto; top: auto; left: 12px; bottom: 52px; width: 226px;
  transform: translateY(6px);
}
.more-pop { width: 216px; }
.more-pop .pop-label { padding: 6px 10px 6px; }
.theme-picker {
  display: grid;
  grid-template-columns: repeat(4, 28px);
  justify-content: space-between;
  row-gap: 10px;
  padding: 4px 10px 8px;
}
.theme-swatch {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--sw);
  border: 0; padding: 0;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .14);
  display: grid; place-items: center; color: #fff;
  transition: transform .14s var(--ease), box-shadow .14s;
}
[data-theme="light"] .theme-swatch { box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .1); }
.theme-swatch:hover { transform: scale(1.1); }
.theme-swatch.active {
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px var(--sw-ring, var(--accent));
}
.theme-swatch .ic { width: 13px; height: 13px; stroke-width: 3; opacity: 0; }
.theme-swatch.active .ic { opacity: 1; }

/* ---------- 自定义日期选择弹层 ---------- */
.date-pop {
  right: auto; top: auto; width: 256px; padding: 8px;
  border-radius: 12px;
}
.dp-presets { display: flex; flex-direction: column; gap: 2px; }
.dp-preset {
  display: flex; align-items: center; gap: 9px;
  width: 100%; height: 32px; padding: 0 8px;
  border-radius: 7px; font-size: 13px; color: var(--text-2);
  transition: background .12s, color .12s;
}
.dp-preset:hover { background: var(--hover); color: var(--text); }
.dp-preset.active { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--title-color); font-weight: 550; }
.dp-preset .ic { width: 15px; height: 15px; opacity: .85; }
.dp-preset-sub { margin-left: auto; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.dp-sep { height: 1px; background: var(--border); margin: 6px 4px; }
.dp-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 2px 4px 6px;
}
.dp-month {
  font-size: 13px; font-weight: 600; color: var(--text);
  padding: 3px 6px; border-radius: 6px; transition: background .12s;
}
.dp-month:hover { background: var(--hover); }
.dp-navs { display: flex; align-items: center; gap: 2px; }
.dp-nav {
  width: 26px; height: 26px; border-radius: 6px;
  display: inline-grid; place-items: center; color: var(--muted);
  transition: background .12s, color .12s;
}
.dp-nav:hover { background: var(--hover); color: var(--text); }
.dp-nav .ic { width: 14px; height: 14px; }
.dp-nav.prev .ic { transform: rotate(180deg); }
.dp-wk {
  display: grid; grid-template-columns: repeat(7, 1fr);
  text-align: center; font-size: 11px; color: var(--muted);
  margin-bottom: 4px; user-select: none;
}
.dp-grid {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 2px; justify-items: center;
}
.dp-day {
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 12.5px; font-variant-numeric: tabular-nums;
  color: var(--text); transition: background .12s, color .12s;
}
.dp-day:hover { background: var(--hover); }
.dp-day.out { color: var(--muted); opacity: .45; }
.dp-day.today {
  box-shadow: inset 0 0 0 1.2px var(--accent);
  color: var(--title-color); font-weight: 600;
}
.dp-day.sel {
  background: var(--accent-strong);
  color: #fff; font-weight: 600;
  box-shadow: none;
}
.dp-day.sel:hover { filter: brightness(1.06); }
.dp-clear {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%; height: 30px; margin-top: 6px;
  border-radius: 7px; font-size: 12.5px; color: var(--red);
  transition: background .12s;
}
.dp-clear:hover { background: color-mix(in srgb, var(--red) 12%, transparent); }
.dp-clear .ic { width: 14px; height: 14px; }
.pop-label { padding: 6px 8px 5px; font-size: 11.5px; color: var(--muted); font-weight: 550; }
.seg { display: flex; padding: 2px; margin: 0 4px 6px; border-radius: 8px; background: var(--surface-2); }
.seg button { flex: 1; height: 26px; border-radius: 6px; font-size: 12.5px; color: var(--text-2); transition: background .14s, color .14s; }
.seg button.active { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .18); font-weight: 550; }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; height: 33px; padding: 0 9px; border-radius: 7px; font-size: 13px; color: var(--text-2); }
.menu-item .ic { width: 16px; height: 16px; color: var(--muted); }
.menu-item:hover { background: var(--hover); color: var(--text); }
.menu-item.danger { color: var(--red); }
.menu-item.danger .ic { color: var(--red); }
.menu-sep { height: 1px; margin: 4px 6px; background: var(--border); }

.modal {
  position: fixed; inset: 0; z-index: 60;
  display: flex; justify-content: center; align-items: flex-start; padding-top: 12vh;
  background: rgba(0, 0, 0, .4); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  opacity: 0; pointer-events: none; transition: opacity .15s;
}
.modal.show { opacity: 1; pointer-events: auto; }
.modal-panel {
  width: min(480px, 92vw); background: var(--surface);
  border: 1px solid var(--border); border-radius: 13px; box-shadow: var(--shadow);
  overflow: hidden; transform: scale(.97); transition: transform .16s var(--ease);
}
.modal.show .modal-panel { transform: none; }
.modal-title { display: flex; justify-content: space-between; align-items: center; padding: 14px 12px 0 18px; font-weight: 650; font-size: 15px; }
.sync-body { padding: 12px 18px 18px; display: flex; flex-direction: column; gap: 12px; }
.sync-banner { padding: 10px 12px; border-radius: 8px; font-size: 12.5px; background: var(--surface-2); color: var(--text-2); }
.sync-banner.ok { background: color-mix(in srgb, var(--green) 15%, transparent); color: var(--green); }
.sync-banner.err { background: color-mix(in srgb, var(--red) 15%, transparent); color: var(--red); }
.sync-desc { font-size: 12.5px; color: var(--muted); line-height: 1.55; }
.form-label { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; font-weight: 550; color: var(--text-2); }
.form-input { width: 100%; padding: 9px 11px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); font-size: 13px; color: var(--text); outline: 0; }
.form-input:focus { border-color: var(--accent); }
.sync-quick { display: flex; flex-wrap: wrap; gap: 8px; }
.btn-chip {
  height: 30px; padding: 0 11px; border-radius: 7px;
  border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text-2); font-size: 12.5px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 6px;
}
.btn-chip:hover { background: var(--hover); color: var(--text); }
.btn-chip .ic { width: 14px; height: 14px; }
.sync-actions { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.btn-primary { height: 34px; padding: 0 16px; border-radius: 8px; background: var(--accent-strong); color: #fff; font-weight: 600; font-size: 13px; }
.btn-ghost { height: 34px; padding: 0 12px; border-radius: 8px; color: var(--text-2); font-size: 13px; }
.btn-ghost:hover { background: var(--hover); color: var(--text); }

.sc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 24px; padding: 12px 18px 18px; }
.sc-row { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; font-size: 13px; color: var(--text-2); border-bottom: 1px solid var(--border); }

/* 每日打卡热力图 */
.hm-panel { width: min(500px, 92vw); }
.hm-body { padding: 14px 18px 20px; display: flex; flex-direction: column; gap: 16px; }
.hm-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.hm-stat {
  padding: 10px 12px; border-radius: 9px;
  background: var(--bg); border: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 2px;
}
.hm-num { font-size: 20px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.hm-lbl { font-size: 11.5px; color: var(--muted); }
.hm-grid-wrap { overflow-x: auto; padding-bottom: 2px; }
.hm-grid {
  display: grid; grid-template-rows: repeat(7, 13px); grid-auto-flow: column;
  grid-auto-columns: 13px; gap: 4px; width: max-content; margin: 0 auto;
}
.hm-cell {
  width: 13px; height: 13px; border-radius: 3px;
  background: var(--surface-2);
}
.hm-cell[data-lv="1"] { background: color-mix(in srgb, var(--green) 32%, var(--surface-2)); }
.hm-cell[data-lv="2"] { background: color-mix(in srgb, var(--green) 58%, var(--surface-2)); }
.hm-cell[data-lv="3"] { background: color-mix(in srgb, var(--green) 82%, var(--surface-2)); }
.hm-cell[data-lv="4"] { background: var(--green); }
.hm-legend {
  display: flex; align-items: center; justify-content: flex-end; gap: 4px;
  font-size: 11px; color: var(--muted);
}
.hm-legend .hm-cell { width: 10px; height: 10px; border-radius: 2px; }

/* 今日清空彩蛋画布 */
.confetti-canvas {
  position: fixed; inset: 0; z-index: 80;
  pointer-events: none; width: 100%; height: 100%;
}

/* 侧边栏右键菜单 */
.ctx-menu {
  position: fixed; z-index: 75; min-width: 156px; padding: 5px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 9px; box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transform: scale(.96);
  transform-origin: top left; transition: opacity .12s, transform .12s var(--ease);
}
.ctx-menu.show { opacity: 1; pointer-events: auto; transform: none; }

.toast {
  position: fixed; left: 50%; bottom: 78px; z-index: 70;
  display: flex; align-items: center; gap: 12px; max-width: 92vw;
  padding: 9px 10px 9px 16px; border-radius: 10px;
  background: var(--toast-bg); color: #fff; font-size: 13px; box-shadow: var(--shadow);
  opacity: 0; transform: translate(-50%, 14px); pointer-events: none;
  transition: opacity .22s var(--ease), transform .22s var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast button { padding: 3px 8px; border-radius: 6px; color: #9eaaff; font-weight: 600; }

/* ---------- iOS / 移动端 ---------- */
.mobile-menu-btn { position: relative; }
.menu-warn-dot {
  position: absolute; top: 5px; right: 5px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--red);
}
.mobile-sync-btn .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--muted); display: block;
}
.mobile-sync-btn[data-state="ok"] .dot { background: var(--green); }
.mobile-sync-btn[data-state="syncing"] .dot { background: var(--accent); animation: pulse 1s infinite; }
.mobile-sync-btn[data-state="error"] .dot { background: var(--red); }

@media (max-width: 767px) {
  body { font-size: 15px; }
  .app, .app.sb-collapsed, .app.detail-open, .app.sb-collapsed.detail-open { grid-template-columns: minmax(0, 1fr); }
  .mobile-only { display: inline-grid; }
  .sb-toggle { display: none; }

  /* 防止 iOS Safari 聚焦输入框时页面自动放大 */
  .composer-input, .form-input, .dt-title, .dt-notes, .dt-row .field, .composer-day,
  .nav-item.editing input { font-size: 16px; }

  .detail {
    position: fixed; top: 0; right: 0; bottom: 0; z-index: 40;
    width: min(340px, 90vw); opacity: 1; box-shadow: var(--shadow);
    border-left: 1px solid var(--border);
    transform: translateX(105%); transition: transform .24s var(--ease);
  }
  .app.detail-open .detail { transform: none; }
  .app.detail-open .scrim { opacity: 1; pointer-events: auto; }
  .dt-body { padding: calc(16px + env(safe-area-inset-top)) 16px 16px; min-width: 0; }
  .dt-foot {
    min-width: 0;
    height: calc(46px + env(safe-area-inset-bottom));
    padding: 0 12px env(safe-area-inset-bottom);
  }

  .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 40;
    width: min(290px, 84vw);
    padding: calc(14px + env(safe-area-inset-top)) 12px calc(14px + env(safe-area-inset-bottom));
    transform: translateX(-105%); transition: transform .25s var(--ease);
    box-shadow: var(--shadow);
  }
  .app.drawer-open .sidebar { transform: none; }
  .app.drawer-open .scrim { opacity: 1; pointer-events: auto; }
  .nav-item { height: 42px; font-size: 15px; }
  .sb-group-head { height: 38px; }
  .sb-group-name { font-size: 14px; }
  .sb-group-acts { opacity: 1; }
  .create-list-btn { height: 40px; font-size: 15px; }

  .page-head { padding: calc(12px + env(safe-area-inset-top)) 14px 10px; gap: 8px; }
  h1 { font-size: 23px; }
  .head-btn { width: 36px; height: 34px; }
  .main-scroll { padding: 0 14px 12px; }

  .task-inner { min-height: 46px; padding: 10px 12px; gap: 11px; flex-wrap: wrap; }
  .check { width: 20px; height: 20px; }
  .check .ic { width: 12px; height: 12px; }
  .task-title { font-size: 15.5px; line-height: 1.4; }
  .star-btn { width: 28px; height: 28px; }
  .star-btn .ic { width: 17px; height: 17px; }
  .m-badge { order: 3; margin-left: 31px; margin-top: 2px; font-size: 11.5px; }
  .monthly-summary { flex-direction: column; align-items: stretch; gap: 8px; padding: 10px 12px; }
  .monthly-bar { flex: none; width: 100%; }
  .monthly-alert-banner { padding: 10px 12px; }

  .bottom-bar { padding: 8px 14px calc(12px + env(safe-area-inset-bottom)); }
  .composer { height: 46px; padding: 0 12px; border-radius: 10px; }
  .composer-day { height: 30px; font-size: 13px; max-width: 116px; }

  .popover { top: calc(52px + env(safe-area-inset-top)); right: 14px; }
  .settings-pop { left: 12px; right: auto; top: auto; bottom: calc(60px + env(safe-area-inset-bottom)); }
  .date-pop { width: min(296px, calc(100vw - 24px)); }

  .modal {
    align-items: flex-start; overflow-y: auto;
    padding: calc(16px + env(safe-area-inset-top)) 12px calc(24px + env(safe-area-inset-bottom));
  }
  .modal-panel { width: 100%; }
  .sync-actions { flex-wrap: wrap; }

  .toast { bottom: calc(74px + env(safe-area-inset-bottom)); }
  .sc-grid { grid-template-columns: 1fr; }
}

/* ---------- macOS 原生独立窗口标题栏适配 ---------- */
html.is-macos-app .sidebar { padding-top: 38px; }
html.is-macos-app .page-head { padding-top: 32px; }
html.is-macos-app .dt-body { padding-top: 36px; }
html.is-macos-app .popover { top: 72px; }
@media (max-width: 767px) {
  html.is-macos-app .page-head { padding-left: 16px; padding-top: 32px; }
  html.is-macos-app .sidebar { padding-top: 44px; }
}
