:root {
	--text: #2c2c2b;
	--muted: #7d7a75;
	--canvas: #ffffff;
	--soft: #f9f8f7;
	--surface: #f0efed;
	--border: #e6e5e3;
	--blue: #2783de;
	--blue-soft: #e5f2fc;
	--green: #46a171;
	--green-soft: #e8f1ec;
	--orange: #d5803b;
	--orange-soft: #fbebde;
	--red: #e56458;
	--red-soft: #fce9e7;
	--purple: #9a6dd7;
	--radius: 8px;
	--shadow: 0 1px 2px rgba(0, 0, 0, 0.05), 0 4px 12px rgba(0, 0, 0, 0.04);
}

@media (prefers-color-scheme: dark) {
	:root {
		--text: #ffffff;
		--muted: rgba(255, 255, 255, 0.65);
		--canvas: #191919;
		--soft: #202020;
		--surface: #262625;
		--border: rgba(255, 255, 255, 0.2);
		--blue: #5e9fe8;
		--blue-soft: rgba(94, 159, 232, 0.12);
		--green: #72bc8f;
		--green-soft: rgba(114, 188, 143, 0.12);
		--orange: #de9255;
		--orange-soft: rgba(222, 146, 85, 0.12);
		--red: #e97366;
		--red-soft: rgba(233, 115, 102, 0.12);
		--purple: #b692e0;
		--shadow: none;
	}
}

* {
	box-sizing: border-box;
}

[hidden] {
	display: none !important;
}

html,
body {
	margin: 0;
	padding: 0;
}

body {
	background: var(--canvas);
	color: var(--text);
	font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
		"Microsoft YaHei", "Noto Sans SC", sans-serif;
	-webkit-font-smoothing: antialiased;
}

button,
input,
select {
	font: inherit;
	color: inherit;
}

button {
	cursor: pointer;
}

:focus-visible {
	outline: 2px solid var(--blue);
	outline-offset: 2px;
}

.muted {
	color: var(--muted);
}
.small {
	font-size: 14px;
}
.error {
	color: var(--red);
	font-size: 14px;
	margin: 4px 0 0;
}

/* ---------------- 登录 ---------------- */

.login {
	min-height: 100dvh;
	display: grid;
	place-items: center;
	padding: 24px;
	background: var(--soft);
}

.login-card {
	width: 100%;
	max-width: 360px;
	background: var(--canvas);
	border: 1px solid var(--border);
	border-radius: 12px;
	padding: 32px 24px;
	box-shadow: var(--shadow);
}

.login-card h1 {
	font-size: 24px;
	margin: 0 0 4px;
}

.login-card p {
	margin: 0 0 16px;
	font-size: 14px;
}

.login-card input {
	width: 100%;
	height: 44px;
	padding: 0 12px;
	margin-bottom: 12px;
	background: var(--canvas);
	border: 1px solid var(--border);
	border-radius: var(--radius);
}

.login-card .btn-primary {
	width: 100%;
}

/* ---------------- 布局 ---------------- */

.app {
	max-width: 760px;
	margin: 0 auto;
	padding: 32px 24px 96px;
}

@media (max-width: 560px) {
	.app {
		padding: 20px 16px 72px;
	}
}

.topbar {
	display: flex;
	align-items: flex-end;
	justify-content: space-between;
	gap: 16px;
	flex-wrap: wrap;
	margin-bottom: 24px;
}

.title {
	font-size: 28px;
	line-height: 1.2;
	margin: 0;
	letter-spacing: -0.01em;
}

.subtitle {
	margin: 4px 0 0;
	font-size: 14px;
	color: var(--muted);
}

.tabs {
	display: flex;
	gap: 4px;
	background: var(--surface);
	padding: 4px;
	border-radius: 10px;
}

.tab {
	border: 0;
	background: transparent;
	color: var(--muted);
	padding: 8px 14px;
	min-height: 36px;
	border-radius: 7px;
	font-size: 14px;
}

.tab.is-active {
	background: var(--canvas);
	color: var(--text);
	box-shadow: var(--shadow);
}

.view {
	display: none;
}
.view.is-active {
	display: block;
}

/* ---------------- 录入区 ---------------- */

.composer,
.filters,
.inline-form {
	display: flex;
	gap: 8px;
	align-items: center;
	flex-wrap: wrap;
}

.composer-input {
	flex: 1 1 260px;
	min-width: 0;
	height: 48px;
	padding: 0 14px;
	background: var(--soft);
	border: 1px solid var(--border);
	border-radius: var(--radius);
}

.composer-input:focus {
	background: var(--canvas);
}

.composer-actions {
	display: flex;
	gap: 8px;
	flex: 0 0 auto;
}

.select {
	height: 48px;
	padding: 0 10px;
	background: var(--canvas);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	max-width: 150px;
}

.btn-primary,
.btn-secondary {
	height: 48px;
	min-width: 88px;
	padding: 0 16px;
	border-radius: var(--radius);
	border: 1px solid transparent;
	font-size: 15px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	text-decoration: none;
}

.btn-primary {
	background: var(--blue);
	color: #fff;
	font-weight: 500;
}

.btn-secondary {
	background: var(--canvas);
	border-color: var(--border);
	color: var(--text);
}

.hint {
	margin: 10px 0 28px;
	font-size: 13px;
	color: var(--muted);
}

/* ---------------- 任务分组 ---------------- */

.group {
	margin-bottom: 28px;
}

.group-header {
	display: flex;
	align-items: center;
	gap: 8px;
	width: 100%;
	background: transparent;
	border: 0;
	padding: 6px 0;
	text-align: left;
}

.group-dot {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	flex: 0 0 auto;
}

.group-name {
	font-size: 15px;
	font-weight: 600;
}

.group-count {
	font-size: 13px;
	color: var(--muted);
}

.chev {
	width: 0;
	height: 0;
	border-left: 5px solid transparent;
	border-right: 5px solid transparent;
	border-top: 6px solid currentColor;
	color: var(--muted);
	transition: transform 0.15s ease;
}

.group-header .chev {
	margin-left: auto;
}

.group.is-collapsed .chev {
	transform: rotate(-90deg);
}

.group.is-collapsed .group-items {
	display: none;
}

.group-items {
	list-style: none;
	margin: 4px 0 0;
	padding: 0;
	border-top: 1px solid var(--border);
}

/* ---------------- 任务行 ---------------- */

.task {
	display: flex;
	align-items: flex-start;
	gap: 12px;
	padding: 12px 4px;
	border-bottom: 1px solid var(--border);
}

.task-check {
	appearance: none;
	-webkit-appearance: none;
	flex: 0 0 auto;
	width: 20px;
	height: 20px;
	margin: 2px 0 0;
	border: 1.5px solid var(--muted);
	border-radius: 4px;
	background: var(--canvas);
	position: relative;
	cursor: pointer;
}

.task-check:checked {
	background: var(--blue);
	border-color: var(--blue);
}

.task-check:checked::after {
	content: "";
	position: absolute;
	left: 6px;
	top: 2px;
	width: 5px;
	height: 10px;
	border: solid #fff;
	border-width: 0 2px 2px 0;
	transform: rotate(45deg);
}

.task-body {
	flex: 1 1 auto;
	min-width: 0;
}

.task-title {
	display: block;
	width: 100%;
	border: 0;
	background: transparent;
	padding: 0;
	font-size: 15px;
	line-height: 1.45;
	word-break: break-word;
}

.task-title:focus {
	outline: none;
	border-bottom: 1px solid var(--blue);
}

.task-meta {
	margin-top: 3px;
	font-size: 12px;
	color: var(--muted);
	display: flex;
	gap: 8px;
	flex-wrap: wrap;
}

.badge-stale {
	color: var(--orange);
	background: var(--orange-soft);
	border-radius: 4px;
	padding: 0 5px;
}

.task-del {
	flex: 0 0 auto;
	width: 32px;
	height: 32px;
	border: 0;
	background: transparent;
	color: var(--muted);
	border-radius: 6px;
	font-size: 18px;
	line-height: 1;
	opacity: 0;
}

.task:hover .task-del,
.task:focus-within .task-del {
	opacity: 1;
}

@media (hover: none) {
	.task-del {
		opacity: 1;
	}
}

.task-del:hover {
	background: var(--red-soft);
	color: var(--red);
}

.task.is-done .task-title {
	color: var(--muted);
	text-decoration: line-through;
}

/* ---------------- 已完成区 ---------------- */

.done-block {
	margin-top: 40px;
	border-top: 1px solid var(--border);
	padding-top: 12px;
}

.done-header {
	display: flex;
	align-items: center;
	gap: 8px;
	width: 100%;
	min-height: 44px;
	background: transparent;
	border: 0;
	padding: 0 4px;
	color: var(--muted);
	font-size: 14px;
	text-align: left;
}

.done-header[aria-expanded="false"] .chev {
	transform: rotate(-90deg);
}

.done-header .chev {
	margin-left: auto;
	transition: transform 0.15s ease;
}

.done-list {
	padding-top: 4px;
}

/* ---------------- 历史 / 设置 ---------------- */

.history-list {
	margin-top: 20px;
}

.panel {
	border: 1px solid var(--border);
	border-radius: 12px;
	padding: 20px;
	margin-bottom: 16px;
	background: var(--soft);
}

.panel h2 {
	margin: 0 0 14px;
	font-size: 17px;
}

.panel-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	padding: 12px 0;
	border-top: 1px solid var(--border);
	flex-wrap: wrap;
}

.row-title {
	margin: 0;
	font-size: 15px;
}

.panel-row p.muted {
	margin: 2px 0 0;
}

.cat-list {
	list-style: none;
	margin: 16px 0 0;
	padding: 0;
}

.cat-item {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 10px 0;
	border-top: 1px solid var(--border);
}

.cat-item .cat-input {
	flex: 1 1 auto;
	min-width: 0;
	height: 40px;
	padding: 0 10px;
	background: var(--canvas);
	border: 1px solid transparent;
	border-radius: 6px;
}

.cat-item .cat-input:focus {
	border-color: var(--blue);
}

.cat-color {
	height: 40px;
	padding: 0 6px;
	border: 1px solid var(--border);
	border-radius: 6px;
	background: var(--canvas);
}

.icon-btn {
	width: 40px;
	height: 40px;
	border: 1px solid var(--border);
	background: var(--canvas);
	border-radius: 6px;
	color: var(--muted);
}

.icon-btn:hover {
	color: var(--red);
	border-color: var(--red);
}

.empty {
	padding: 48px 16px;
	text-align: center;
	color: var(--muted);
	font-size: 14px;
	border: 1px dashed var(--border);
	border-radius: 12px;
}

/* ---------------- 提示 ---------------- */

.toast {
	position: fixed;
	left: 50%;
	bottom: 24px;
	transform: translateX(-50%);
	background: var(--text);
	color: var(--canvas);
	padding: 10px 16px;
	border-radius: 8px;
	font-size: 14px;
	z-index: 50;
	max-width: calc(100% - 32px);
}

@media (prefers-reduced-motion: reduce) {
	* {
		transition: none !important;
	}
}
