:root {
	--accent: #3A6DF0;
	--rose: #E11D63;
	--star: #F5B300;
	--muted: #8E8E93;
	--hairline: #E5E5EA;
	--bg: #fff;
	--search-bg: #EFEFF4;
	--text: #1C1C1E;
	--text-secondary: #8E8E93;
	--inbox-color: #3A6DF0;
	--today-color: #F5B300;
	--upcoming-color: #E11D63;
	--anytime-color: #34C759;
	--someday-color: #C49A3A;
	--logbook-color: #34C759;
	--area-color: #8E8E93;
	--fs-xs: 14px;
	--fs-sm: 16px;
	--fs-md: 18px;
	--fs-base: 20px;
	--fs-lg: 22px;
	--fs-xl: 34px;
	--fw-normal: 400;
	--fw-medium: 500;
	--fw-bold: 600;
}
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body { font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Noto Sans SC", sans-serif; background: var(--bg); color: var(--text); font-size: var(--fs-base); font-weight: var(--fw-normal); }
.hidden { display: none !important; }

/* ===== Token 门 ===== */
.gate { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: #f7f7f8; z-index: 100; }
.gate-card { width: 280px; padding: 28px 22px; background: #fff; border-radius: 14px; box-shadow: 0 6px 24px rgba(0,0,0,.08); text-align: center; }
.gate-card h1 { font-size: var(--fs-lg); font-weight: var(--fw-bold); margin-bottom: 18px; }
.gate-card input { width: 100%; border: 1.5px solid var(--hairline); border-radius: 10px; padding: 10px 12px; font-size: var(--fs-md); font-weight: var(--fw-normal); outline: none; }
.gate-card input:focus { border-color: var(--accent); }
.gate-card button { width: 100%; margin-top: 12px; background: var(--accent); color: #fff; border: none; border-radius: 10px; padding: 11px; font-size: var(--fs-md); font-weight: var(--fw-bold); }
.gate-error { color: var(--rose); font-size: var(--fs-xs); font-weight: var(--fw-medium); margin-top: 10px; min-height: 16px; }

/* ===== 页面容器 ===== */
.app { position: relative; width: 100%; min-height: 100vh; overflow: hidden; }
.page {
	position: fixed; inset: 0;
	background: var(--bg);
	transition: transform .3s cubic-bezier(.25,.46,.45,.94);
	will-change: transform;
}
.nav-page { z-index: 1; transform: translateX(0); }
.list-page { z-index: 2; transform: translateX(100%); }
.app.show-list .nav-page { transform: translateX(-30%); }
.app.show-list .list-page { transform: translateX(0); }

/* ===== 一级导航页 ===== */
.nav-content {
	min-height: 100vh;
	padding: calc(12px + env(safe-area-inset-top)) 0 calc(100px + env(safe-area-inset-bottom));
	overflow-y: auto;
}

/* 搜索栏 */
.nav-search {
	display: none;
}

/* 导航区块 */
.nav-section { padding: 0 8px; }
.nav-item {
	display: flex; align-items: center; gap: 12px;
	padding: 9px 10px; border-radius: 8px; cursor: pointer;
	color: var(--text); font-size: var(--fs-base); font-weight: var(--fw-medium);
	position: relative; user-select: none;
}
.nav-item:active { background: var(--search-bg); }
.nav-item .nav-icon { width: 24px; height: 24px; flex: none; display: flex; align-items: center; justify-content: center; }
.nav-item .nav-icon svg { width: 24px; height: 24px; }
.nav-item .nav-title { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-item .nav-count { font-size: var(--fs-sm); color: var(--text-secondary); font-weight: var(--fw-normal); flex: none; }
.nav-item .nav-badge {
	display: inline-flex; align-items: center; justify-content: center;
	min-width: 22px; height: 22px; padding: 0 7px;
	background: var(--rose); color: #fff; border-radius: 11px;
	font-size: var(--fs-xs); font-weight: var(--fw-bold); flex: none;
}

/* 智能列表图标颜色 */
.nav-icon.inbox, .view-icon.inbox { color: var(--inbox-color); }
.nav-icon.today, .view-icon.today { color: var(--today-color); }
.nav-icon.upcoming, .view-icon.upcoming { color: var(--upcoming-color); }
.nav-icon.anytime, .view-icon.anytime { color: var(--anytime-color); }
.nav-icon.someday, .view-icon.someday { color: var(--someday-color); }
.nav-icon.logbook, .view-icon.logbook { color: var(--logbook-color); }

.nav-item.today-row .nav-count { margin-left: 4px; }

/* 分割线 */
.nav-divider { height: 1px; background: var(--hairline); margin: 10px 16px; }

/* Area 折叠 */
.area-header {
	display: flex; align-items: center; gap: 12px;
	padding: 9px 10px; border-radius: 8px; cursor: pointer;
	font-size: var(--fs-base); font-weight: var(--fw-bold); color: var(--text);
	user-select: none;
}
.area-header:active { background: var(--search-bg); }
.area-header .area-icon { width: 24px; height: 24px; flex: none; color: var(--area-color); }
.area-header .area-icon svg { width: 24px; height: 24px; }
.area-header .area-title { flex: 1; }
.area-header .chevron {
	width: 18px; height: 18px; flex: none; color: var(--text-secondary);
	transition: transform .2s;
}
.area-header.collapsed .chevron { transform: rotate(-90deg); }

/* 项目行 */
.project-item {
	display: flex; align-items: center; gap: 12px;
	padding: 9px 10px; border-radius: 8px; cursor: pointer;
	font-size: var(--fs-base); font-weight: var(--fw-medium); color: var(--text); user-select: none;
}
.project-item:active { background: var(--search-bg); }
.project-item .progress-ring { width: 24px; height: 24px; flex: none; }
.project-item .project-title { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.project-item .project-count { font-size: var(--fs-sm); font-weight: var(--fw-normal); color: var(--text-secondary); flex: none; }

.area-projects.collapsed { display: none; }

/* ===== 二级列表页 ===== */
.list-page { display: flex; flex-direction: column; }

.header {
	display: flex; align-items: center; gap: 8px;
	padding: calc(10px + env(safe-area-inset-top)) 18px 10px;
	position: sticky; top: 0; background: rgba(255,255,255,.92);
	backdrop-filter: blur(8px); z-index: 5; flex: none;
}
.back-btn {
	width: 32px; height: 32px; border: none; background: none;
	color: var(--accent); display: flex; align-items: center; justify-content: center;
	border-radius: 8px; cursor: pointer; flex: none;
	margin-left: -6px;
}
.back-btn svg { width: 24px; height: 24px; }
.back-btn:active { background: var(--search-bg); }
.view-icon { width: 26px; height: 26px; flex: none; display: flex; align-items: center; justify-content: center; }
.view-icon svg { width: 26px; height: 26px; }
.header h1 { font-size: var(--fs-xl); font-weight: var(--fw-bold); letter-spacing: -0.5px; }
.sync-dot { margin-left: auto; width: 8px; height: 8px; border-radius: 50%; background: #34c759; flex: none; }
.sync-dot.err { background: var(--rose); }

.list { flex: 1; overflow-y: auto; padding-bottom: calc(100px + env(safe-area-inset-bottom)); }
.list-page.editing { background: #F9FAFB; transition: background .2s; }
.list-page.editing .header { background: #F9FAFB; backdrop-filter: none; }
/* 编辑模式下，未展开任务行背景透明，露出页面灰色；只有展开卡片为白色 */
.list-page.editing .task-swipe { background: transparent; }
.list-page.editing .task.expanded .task-swipe { background: #fff; }
/* 编辑模式下隐藏所有左滑按钮 */
.list-page.editing .swipe-actions { display: none; }

/* ===== 任务行 ===== */
.task {
	position: relative;
	display: flex; flex-direction: column;
	padding: 0;
	overflow: hidden;
}
.task-swipe {
	position: relative; z-index: 1;
	background: var(--bg);
	transition: transform .25s ease;
	touch-action: pan-y;
}
.task.swiped .task-swipe { transform: translateX(-160px); }
.task.swiping .task-swipe { transition: none; user-select: none; -webkit-user-select: none; }

.swipe-actions {
	position: absolute; top: 0; right: 0; bottom: 0;
	display: flex; z-index: 0;
}
.swipe-btn {
	width: 80px; border: none; color: #fff; font-size: var(--fs-sm);
	font-family: inherit; font-weight: var(--fw-bold); cursor: pointer;
	display: flex; align-items: center; justify-content: center;
}
.swipe-btn.complete-btn { background: var(--accent); }
.swipe-btn.delete-btn { background: var(--rose); }
.swipe-btn:active { opacity: .8; }

.task-row { display: flex; align-items: flex-start; gap: 12px; width: 100%; padding: 11px 18px; }
.task .check {
	width: 22px; height: 22px; border: 1.5px solid #C7C7CC; border-radius: 5px;
	flex: none; margin-top: -1px; display: flex; align-items: center; justify-content: center;
	color: #fff; transition: all .15s; background: #fff; cursor: pointer;
	padding: 0;
}
.task .check svg { width: 14px; height: 14px; }
.task.done .check { border-color: var(--accent); background: var(--accent); }
.task .check:active { transform: scale(.9); }
.task .body { flex: 1; min-width: 0; }
.task .title { font-size: var(--fs-md); font-weight: var(--fw-medium); overflow: hidden; text-overflow: ellipsis; line-height: 1.35; }
.task .title-input {
	font-size: var(--fs-md); font-weight: var(--fw-medium); border: none; outline: none;
	background: transparent; color: var(--text); width: 100%;
	padding: 0; font-family: inherit; line-height: 1.35;
	-webkit-user-modify: read-write-plaintext-only;
	white-space: pre-wrap; word-break: break-word;
}
.detail-notes-trigger {
	display: block; width: 100%; border: none; background: none; text-align: left;
	padding: 4px 0; font-size: var(--fs-sm); font-weight: var(--fw-normal);
	color: var(--text-secondary); font-family: inherit; cursor: text;
}
.detail-notes-trigger:active { opacity: .7; }
.task.done .title, .task.done .title-input { text-decoration: line-through; color: var(--text-secondary); }
.task .meta { font-size: var(--fs-sm); font-weight: var(--fw-normal); color: var(--text-secondary); margin-top: 2px; }
.task-right { display: flex; align-items: center; gap: 6px; flex: none; align-self: center; }
.task .pill {
	font-size: var(--fs-xs); background: #FFE3E8; color: var(--rose);
	border-radius: 10px; padding: 2px 8px; flex: none; font-weight: var(--fw-bold);
}
.task-indicator { width: 16px; height: 16px; color: var(--text-secondary); display: flex; align-items: center; justify-content: center; }
.task-indicator svg { width: 16px; height: 16px; }
.task.expanded .task-swipe {
	background: #fff;
	border-radius: 14px;
	margin: 6px 12px;
	box-shadow: 0 1px 4px rgba(0,0,0,.06), 0 0 0 0.5px rgba(0,0,0,.04);
}
.task.expanded { border-bottom: none; }
.task.expanded .task-row { padding: 14px 16px 4px; }
.task.expanded .meta { display: none; }
.task.expanded .task-right { display: none; }
.task.expanded .swipe-actions { display: none; }

/* 详情面板：卡片内 */
.task-detail {
	padding: 0 16px 14px;
	display: flex; flex-direction: column; gap: 0;
}

/* Notes 区域 */
.detail-notes-label {
	font-size: var(--fs-sm); color: var(--text-secondary); font-weight: var(--fw-medium);
	padding: 8px 0 4px;
}
.detail-notes {
	width: 100%; min-height: 32px; border: none;
	padding: 4px 0; font-size: var(--fs-sm); font-weight: var(--fw-normal);
	font-family: inherit; resize: none; outline: none; color: var(--text);
	background: transparent; line-height: 1.4;
}
.detail-notes::placeholder { color: var(--text-secondary); }

/* 底部工具栏 */
.detail-toolbar {
	display: flex; align-items: center; justify-content: space-between;
	padding-top: 12px; margin-top: 8px; border-top: 0.5px solid var(--hairline);
}
.detail-when {
	display: flex; align-items: center; gap: 6px;
	border: none; background: none; cursor: pointer;
	font-size: var(--fs-sm); font-weight: var(--fw-bold); color: var(--text);
	font-family: inherit; padding: 4px 6px; border-radius: 6px;
}
.detail-when:active { background: var(--search-bg); }
.detail-when .when-icon { width: 18px; height: 18px; display: flex; align-items: center; justify-content: center; }
.detail-when .when-icon svg { width: 18px; height: 18px; }

.detail-toolbar-right { display: flex; align-items: center; gap: 4px; }
.detail-icon-btn {
	width: 36px; height: 36px; border: none; background: none;
	cursor: pointer; border-radius: 8px; display: flex;
	align-items: center; justify-content: center; color: var(--text-secondary);
	padding: 0;
}
.detail-icon-btn:active { background: var(--search-bg); }
.detail-icon-btn svg { width: 20px; height: 20px; }
.detail-icon-btn.active { color: var(--accent); }

/* 展开的编辑区 */
.detail-extra {
	padding: 10px 0 2px;
	display: flex; flex-direction: column; gap: 8px;
	animation: fadeIn .15s ease;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }
.detail-extra-label {
	font-size: var(--fs-xs); font-weight: var(--fw-bold); color: var(--text-secondary);
	text-transform: uppercase; letter-spacing: 0.5px;
}
.when-chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.tag-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
	border: 1px solid var(--hairline); background: #fff; color: var(--text);
	border-radius: 14px; padding: 5px 12px; font-size: var(--fs-sm); font-weight: var(--fw-medium); cursor: pointer;
	font-family: inherit; transition: all .15s;
}
.chip:active { transform: scale(.96); }
.chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.muted-hint { color: var(--text-secondary); font-size: var(--fs-sm); font-weight: var(--fw-normal); }
.when-date, .detail-deadline {
	border: 1px solid var(--hairline); border-radius: 8px; padding: 5px 8px;
	font-size: var(--fs-sm); font-weight: var(--fw-normal); font-family: inherit; color: var(--text); background: #fff;
}
.clear-deadline {
	border: none; background: none; color: var(--text-secondary); font-size: var(--fs-md);
	cursor: pointer; padding: 0 4px; line-height: 1;
}
.detail-project {
	border: 1px solid var(--hairline); border-radius: 8px; padding: 6px 10px;
	font-size: var(--fs-sm); font-weight: var(--fw-normal); font-family: inherit; color: var(--text); background: #fff;
	width: 100%;
}
.detail-actions { padding-top: 8px; }
.detail-delete {
	border: none; background: none; color: var(--rose); font-size: var(--fs-sm);
	cursor: pointer; padding: 6px 0; font-family: inherit; font-weight: var(--fw-medium);
}
.detail-delete:active { opacity: .7; }

/* 分组标题 */
.section-head {
	display: flex; align-items: center; gap: 6px;
	padding: 20px 18px 6px; color: var(--text); font-weight: var(--fw-bold); font-size: var(--fs-lg);
}
.heading-item {
	padding: 16px 18px 4px; font-size: var(--fs-base); font-weight: var(--fw-bold);
	color: var(--text); border-bottom: none;
}

/* 项目进度条 */
.project-progress { padding: 12px 18px 16px; }
.project-progress-bar {
	height: 6px; background: var(--hairline); border-radius: 3px; overflow: hidden;
}
.project-progress-fill {
	height: 100%; background: var(--accent); border-radius: 3px; transition: width .3s;
}
.project-progress-text {
	font-size: var(--fs-xs); font-weight: var(--fw-normal); color: var(--text-secondary); margin-top: 6px;
}

/* 空状态 */
.empty-state {
	display: flex; flex-direction: column; align-items: center; justify-content: center;
	padding: 80px 20px; color: var(--text-secondary); text-align: center;
}
.empty-state .empty-icon { width: 48px; height: 48px; margin-bottom: 12px; opacity: .4; }
.empty-state .empty-icon svg { width: 48px; height: 48px; }
.empty-state p { font-size: var(--fs-md); font-weight: var(--fw-normal); }

/* ===== FAB ===== */
.fab {
	position: fixed; right: 22px; bottom: calc(22px + env(safe-area-inset-bottom));
	width: 52px; height: 52px; background: var(--accent); color: #fff;
	border: none; border-radius: 50%; display: flex; align-items: center; justify-content: center;
	box-shadow: 0 4px 14px rgba(58,109,240,.4); cursor: pointer; z-index: 10;
}
.fab svg { width: 24px; height: 24px; }
.fab:active { transform: scale(.95); }

/* ===== 底部抽屉（新建 / 编辑共用） ===== */
.sheet-backdrop {
	position: fixed; inset: 0; background: rgba(0,0,0,.35);
	z-index: 100; opacity: 0; transition: opacity .25s;
}
.sheet-backdrop.visible { opacity: 1; }
.sheet {
	position: fixed; left: 0; right: 0; bottom: 0;
	max-width: 640px; margin: 0 auto; background: #fff;
	border-radius: 16px 16px 0 0;
	padding: 8px 20px calc(24px + env(safe-area-inset-bottom));
	z-index: 101; transform: translateY(100%);
	transition: transform .3s cubic-bezier(.32,.72,0,1);
	max-height: 70vh; overflow-y: auto;
}
.sheet.visible { transform: translateY(0); }
.sheet-handle { width: 36px; height: 5px; border-radius: 3px; background: #D1D1D6; margin: 0 auto 14px; }
.sheet-title {
	font-size: var(--fs-xs); font-weight: var(--fw-bold); color: var(--text-secondary);
	text-transform: uppercase; letter-spacing: 0.5px;
	margin-bottom: 14px; text-align: center;
}
.sheet .new-title {
	width: 100%; border: none; outline: none; font-size: var(--fs-base); font-weight: var(--fw-medium);
	font-family: inherit; padding: 8px 0; color: var(--text);
	border-bottom: 1px solid var(--hairline);
	-webkit-user-modify: read-write-plaintext-only;
	white-space: pre-wrap; word-break: break-word;
	min-height: 1.35em;
}
.sheet .new-title:empty::before {
	content: attr(data-placeholder);
	color: var(--text-secondary);
}
.sheet .new-note {
	width: 100%; border: none; outline: none; font-size: var(--fs-sm); font-weight: var(--fw-normal);
	font-family: inherit; padding: 8px 0; color: var(--text-secondary);
	resize: none; min-height: 1.4em;
}
.sheet-submit {
	position: absolute; right: 18px; bottom: calc(22px + env(safe-area-inset-bottom));
	width: 42px; height: 42px; border-radius: 50%; border: none;
	background: var(--accent); color: #fff; font-size: var(--fs-md); font-weight: var(--fw-bold); cursor: pointer;
	display: flex; align-items: center; justify-content: center;
}
.sheet-submit:disabled { opacity: .75; }
.sheet-submit.loading { font-size: 0; }
.sheet-submit.loading::after {
	content: ""; display: inline-block; width: 18px; height: 18px;
	border: 2px solid rgba(255,255,255,.35); border-top-color: #fff;
	border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* 抽屉内编辑控件 */
.sheet .when-chips, .sheet .tag-chips {
	display: flex; gap: 8px; flex-wrap: wrap; padding: 4px 0 8px;
}
.sheet .chip {
	border: 1px solid var(--hairline); background: #fff; color: var(--text);
	border-radius: 16px; padding: 8px 16px; font-size: var(--fs-sm); font-weight: var(--fw-medium); cursor: pointer;
	font-family: inherit; transition: all .15s;
}
.sheet .chip:active { transform: scale(.96); }
.sheet .chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.sheet .when-date, .sheet .sheet-date {
	border: 1px solid var(--hairline); border-radius: 10px; padding: 10px 14px;
	font-size: var(--fs-sm); font-weight: var(--fw-normal); font-family: inherit; color: var(--text); background: #fff;
	width: 100%; margin-top: 4px;
}
.sheet .sheet-select {
	border: 1px solid var(--hairline); border-radius: 10px; padding: 10px 14px;
	font-size: var(--fs-sm); font-weight: var(--fw-normal); font-family: inherit; color: var(--text); background: #fff;
	width: 100%;
}
.sheet .sheet-clear {
	display: block; width: 100%; margin-top: 10px;
	border: 1px solid var(--hairline); background: #fff; color: var(--rose);
	border-radius: 10px; padding: 10px; font-size: var(--fs-sm); font-weight: var(--fw-medium); cursor: pointer;
	font-family: inherit;
}

/* ===== 安装按钮 ===== */
.install-btn {
	position: fixed; left: 50%; transform: translateX(-50%);
	bottom: calc(env(safe-area-inset-bottom, 0px) + 84px); z-index: 100;
	padding: 9px 18px; background: var(--accent); color: #fff;
	border: none; border-radius: 999px; font-size: var(--fs-sm); font-weight: var(--fw-bold);
	box-shadow: 0 4px 14px rgba(58,109,240,.4);
}
