:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1f2328;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #2563eb;
  --accent: #7c3aed;
  --danger: #dc2626;
  --radius: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 14px 80px;
}

/* 顶栏 */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0 10px;
  background: var(--bg);
}
.topbar h1 { font-size: 20px; margin: 0; }
.link-btn {
  background: none; border: none; color: var(--muted);
  font-size: 13px; cursor: pointer; padding: 6px;
}
.link-btn:hover { color: var(--danger); }

/* 快速输入 */
.quick-input {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
}
.quick-input textarea {
  width: 100%;
  border: none;
  resize: none;
  font-size: 15px;
  font-family: inherit;
  line-height: 1.5;
  color: var(--text);
  outline: none;
  background: transparent;
}
.quick-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}
.quick-actions .spacer { flex: 1; }

.btn {
  border: none;
  border-radius: 9px;
  padding: 9px 14px;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  transition: opacity .15s;
}
.btn:active { opacity: .7; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-ghost { background: #eef0f3; color: var(--text); }
.btn-accent {
  background: linear-gradient(135deg, #7c3aed, #4f46e5);
  color: #fff;
  font-weight: 600;
}
.btn-primary { background: var(--primary); color: #fff; font-weight: 600; }
.listening { background: #fecaca !important; color: #7f1d1d !important; }

/* AI 解析预览 */
.parse-preview {
  margin-top: 12px;
  border-top: 1px dashed var(--border);
  padding-top: 10px;
}
.pp-header { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.pp-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 7px 4px;
  border-radius: 8px;
}
.pp-item input { margin-top: 3px; }
.pp-content { flex: 1; font-size: 14px; line-height: 1.4; }
.pp-meta { font-size: 12px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.pp-actions { display: flex; gap: 8px; margin-top: 10px; }
.pp-empty { font-size: 13px; color: var(--muted); padding: 8px 4px; }

/* 过滤 */
.filters {
  display: flex;
  gap: 6px;
  margin: 14px 0 8px;
}
.filter {
  flex: 1;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 7px 10px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
}
.filter span { opacity: .7; }
.filter.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* 任务列表 */
.task-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.task-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 10px;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
  transition: transform .1s;
}
.task-item.drag-over { border-color: var(--primary); }
.task-item.done { opacity: .55; }
.task-item.done .task-content { text-decoration: line-through; }

.drag-handle {
  cursor: grab;
  color: #c4c9d1;
  font-size: 16px;
  padding: 2px;
  user-select: none;
  touch-action: none;
}
.drag-handle:active { cursor: grabbing; }

.check { position: relative; display: flex; align-items: center; cursor: pointer; }
.check input {
  position: absolute; opacity: 0; width: 0; height: 0;
}
.checkmark {
  width: 22px; height: 22px;
  border: 2px solid #cbd5e1;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
  transition: all .15s;
}
.check input:checked + .checkmark {
  background: var(--primary);
  border-color: var(--primary);
}
.check input:checked + .checkmark::after {
  content: '';
  display: block;
  width: 5px; height: 10px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  margin: 3px 0 0 7px;
}

.task-main { flex: 1; min-width: 0; }
.task-content { font-size: 15px; line-height: 1.45; word-break: break-word; }
.task-meta { display: flex; align-items: center; gap: 8px; margin-top: 5px; flex-wrap: wrap; }

.chip {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 12px;
  background: #eff6ff;
  color: #2563eb;
}
.chip.overdue { background: #fef2f2; color: var(--danger); }

.prio-dot {
  border: none;
  border-radius: 12px;
  padding: 2px 8px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  background: color-mix(in srgb, var(--pc) 12%, white);
  color: var(--pc);
}

.task-actions { display: flex; gap: 2px; }
.icon-btn {
  background: none; border: none;
  font-size: 16px; cursor: pointer;
  color: var(--muted);
  padding: 6px 8px; border-radius: 8px;
}
.icon-btn:hover { background: #f1f3f5; }
.icon-btn.danger:hover { color: var(--danger); }

/* 编辑表单 */
.edit-form { flex: 1; }
.edit-form input[type=text], .edit-form input[type=date], .edit-form input[type=time] {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
  font-family: inherit;
  margin-bottom: 6px;
}
.edit-row { display: flex; gap: 6px; }
.edit-row input[type=date], .edit-row input[type=time] { flex: 1; }
.edit-row select {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
}
.edit-actions { display: flex; gap: 8px; margin-top: 4px; }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 40px 20px;
  font-size: 14px;
}
.loading {
  text-align: center;
  color: var(--muted);
  padding: 30px;
  font-size: 14px;
}
