/* ============ 基础 ============ */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #0d0f22;
  --card: rgba(255, 255, 255, 0.055);
  --card-border: rgba(255, 255, 255, 0.1);
  --text: #eef0ff;
  --text-dim: #9aa0c8;
  --accent-1: #ff5e7e;
  --accent-2: #ffb347;
  --accent-3: #3ddc97;
  --accent-4: #4da3ff;
  --accent-5: #b06bff;
  --danger: #ff5470;
  --radius: 18px;
}

html, body { height: 100%; }

body {
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input { font-family: inherit; }
.hidden { display: none !important; }

/* ============ 背景：流动极光 + 网格 ============ */
.bg { position: fixed; inset: 0; z-index: 0; overflow: hidden; background: radial-gradient(1200px 800px at 20% -10%, #1b1f45 0%, transparent 60%), radial-gradient(1000px 700px at 110% 20%, #2a1a4a 0%, transparent 55%), var(--bg); }

.blob { position: absolute; border-radius: 50%; filter: blur(70px); opacity: 0.55; will-change: transform; }
.blob-1 { width: 480px; height: 480px; background: #6a3dff; top: -120px; left: -80px; animation: drift1 22s ease-in-out infinite alternate; }
.blob-2 { width: 420px; height: 420px; background: #ff5e7e; bottom: -140px; right: -60px; animation: drift2 26s ease-in-out infinite alternate; }
.blob-3 { width: 320px; height: 320px; background: #16c8a0; top: 40%; left: 55%; opacity: 0.35; animation: drift3 30s ease-in-out infinite alternate; }

@keyframes drift1 { to { transform: translate(120px, 90px) scale(1.2); } }
@keyframes drift2 { to { transform: translate(-100px, -80px) scale(1.15); } }
@keyframes drift3 { to { transform: translate(-140px, 120px) scale(1.3); } }

.grid-overlay {
  position: absolute; inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, 0.06) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: radial-gradient(ellipse at center, rgba(0,0,0,0.9), transparent 75%);
}

/* 特效画布 */
#fx-canvas { position: fixed; inset: 0; z-index: 40; pointer-events: none; }

/* ============ 布局 ============ */
.app { position: relative; z-index: 10; max-width: 620px; margin: 0 auto; padding: 40px 18px 60px; }

/* ============ 头部卡片 ============ */
.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

.hero { padding: 26px 26px 22px; animation: heroIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both; }
@keyframes heroIn { from { opacity: 0; transform: translateY(-16px) scale(0.96); } }

.hero-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.title {
  font-size: 28px; font-weight: 800; letter-spacing: 0.5px;
  background: linear-gradient(100deg, var(--accent-1), var(--accent-2) 45%, var(--accent-4) 90%);
  background-size: 200% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: shimmer 5s linear infinite;
  white-space: nowrap;
}
@keyframes shimmer { to { background-position: 200% 0; } }

.hero-actions { display: flex; gap: 8px; flex-shrink: 0; }

.icon-btn, .ghost-btn {
  height: 38px; padding: 0 14px; border-radius: 12px; font-size: 14px;
  background: rgba(255, 255, 255, 0.07); border: 1px solid var(--card-border);
  transition: transform 0.15s ease, background 0.2s ease, box-shadow 0.2s ease;
}
.icon-btn:hover, .ghost-btn:hover { background: rgba(255, 255, 255, 0.13); transform: translateY(-1px); }
.icon-btn:active, .ghost-btn:active { transform: scale(0.94); }
.icon-btn.off { filter: grayscale(1) opacity(0.6); }
.ghost-btn { color: var(--text-dim); }
.ghost-btn:hover { color: var(--text); box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.2); }

.subtitle { margin-top: 8px; color: var(--text-dim); font-size: 13.5px; }

/* ============ 进度条 ============ */
.progress-wrap { margin-top: 22px; }
.progress-track {
  height: 14px; border-radius: 999px; overflow: hidden;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.08);
  position: relative;
}
.progress-fill {
  position: relative; width: 0%; height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-3), var(--accent-4), var(--accent-5));
  background-size: 200% 100%;
  transition: width 0.5s cubic-bezier(0.34, 1.3, 0.64, 1);
  overflow: hidden;
}
.stripes {
  position: absolute; inset: 0;
  background-image: repeating-linear-gradient(45deg, rgba(255,255,255,0.22) 0 10px, transparent 10px 20px);
  animation: stripes 1.2s linear infinite;
}
@keyframes stripes { to { transform: translateX(28px); } }
.progress-glow {
  position: absolute; inset: 0; border-radius: 999px;
  box-shadow: 0 0 18px rgba(77, 163, 255, 0.55), 0 0 40px rgba(61, 220, 151, 0.35);
  animation: glowPulse 1.8s ease-in-out infinite;
}
@keyframes glowPulse { 50% { opacity: 0.55; } }

.progress-meta { display: flex; justify-content: space-between; margin-top: 8px; font-size: 13px; color: var(--text-dim); }
#progress-text { font-weight: 800; color: var(--text); font-variant-numeric: tabular-nums; }

/* ============ 输入框 ============ */
.add-form { display: flex; gap: 10px; margin-top: 20px; }
#new-todo {
  flex: 1; height: 50px; padding: 0 18px; border-radius: 14px;
  background: rgba(255, 255, 255, 0.06); border: 1px solid var(--card-border);
  color: var(--text); font-size: 15px; outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}
#new-todo::placeholder { color: #6f75a3; }
#new-todo:focus {
  border-color: rgba(255, 179, 71, 0.7);
  box-shadow: 0 0 0 3px rgba(255, 179, 71, 0.18), 0 0 24px rgba(255, 94, 126, 0.18);
}
#new-todo.shake { animation: shake 0.4s ease; border-color: var(--danger); }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-7px); }
  50% { transform: translateX(6px); }
  75% { transform: translateX(-4px); }
}

.add-btn {
  width: 50px; height: 50px; border-radius: 14px; flex-shrink: 0;
  font-size: 24px; color: #fff; line-height: 1;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  box-shadow: 0 8px 24px rgba(255, 94, 126, 0.4);
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}
.add-btn:hover { transform: translateY(-2px) scale(1.05); box-shadow: 0 12px 30px rgba(255, 94, 126, 0.55); }
.add-btn:active { transform: scale(0.88); }

/* ============ 连击 & 全完成 ============ */
.combo {
  margin: 18px auto 0; width: fit-content; padding: 8px 22px;
  font-size: 20px; font-weight: 900; border-radius: 999px;
  color: #fff; letter-spacing: 1px;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  box-shadow: 0 6px 24px rgba(255, 94, 126, 0.5);
  transform-origin: center;
  animation: comboPop 0.35s cubic-bezier(0.34, 1.8, 0.64, 1);
  text-align: center;
}
.combo.pop { animation: comboPop 0.35s cubic-bezier(0.34, 1.8, 0.64, 1); }
@keyframes comboPop {
  0% { transform: scale(0.3) rotate(-8deg); opacity: 0; }
  55% { transform: scale(1.25) rotate(3deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); }
}

.big-done {
  position: fixed; left: 50%; top: 42%; z-index: 60;
  transform: translate(-50%, -50%);
  font-size: 34px; font-weight: 900; letter-spacing: 4px; padding: 20px 40px;
  border-radius: 20px; color: #fff; text-align: center;
  background: linear-gradient(135deg, var(--accent-3), var(--accent-4));
  box-shadow: 0 0 0 4px rgba(255,255,255,0.25), 0 20px 60px rgba(61, 220, 151, 0.6);
  animation: bigDone 2s ease forwards;
  pointer-events: none;
}
@keyframes bigDone {
  0% { transform: translate(-50%, -50%) scale(0.2); opacity: 0; }
  18% { transform: translate(-50%, -50%) scale(1.15); opacity: 1; }
  30% { transform: translate(-50%, -50%) scale(1); }
  78% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -58%) scale(0.9); opacity: 0; }
}

/* ============ 任务列表 ============ */
.todo-list { list-style: none; margin-top: 18px; display: flex; flex-direction: column; gap: 10px; }

.todo-item {
  position: relative; display: flex; align-items: center; gap: 14px;
  padding: 15px 18px; border-radius: 16px;
  background: var(--card); border: 1px solid var(--card-border);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  animation: itemIn 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  transition: background 0.25s ease, border-color 0.25s ease, transform 0.2s ease;
}
@keyframes itemIn {
  from { opacity: 0; transform: translateY(20px) scale(0.9); }
}
.todo-item:hover { background: rgba(255, 255, 255, 0.09); transform: translateX(3px); }

/* 勾选框 */
.check {
  width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
  border: 2px solid rgba(255, 255, 255, 0.35);
  display: grid; place-items: center;
  transition: border-color 0.2s ease, transform 0.15s ease;
  position: relative;
}
.check:hover { border-color: var(--accent-3); transform: scale(1.12); }
.check:active { transform: scale(0.85); }
.check svg { width: 15px; height: 15px; display: block; }
.check svg path {
  fill: none; stroke: #fff; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 22; stroke-dashoffset: 22;
  transition: stroke-dashoffset 0.28s ease 0.1s;
}

/* 完成任务 */
.todo-item.done {
  background: rgba(61, 220, 151, 0.07);
  border-color: rgba(61, 220, 151, 0.35);
}
.todo-item.done .check {
  background: linear-gradient(135deg, var(--accent-3), var(--accent-4));
  border-color: transparent;
  box-shadow: 0 0 16px rgba(61, 220, 151, 0.65);
  animation: checkPop 0.4s cubic-bezier(0.34, 1.8, 0.64, 1);
}
@keyframes checkPop {
  0% { transform: scale(1); }
  45% { transform: scale(1.4) rotate(-8deg); }
  100% { transform: scale(1); }
}
.todo-item.done .check svg path { stroke-dashoffset: 0; }

.todo-item .title {
  flex: 1; font-size: 15.5px; line-height: 1.45; word-break: break-word;
  background: none; -webkit-background-clip: initial; background-clip: initial; color: var(--text);
  position: relative; transition: color 0.25s ease;
}
.todo-item.done .title { color: #7f86ad; }
.todo-item.done .title::after {
  content: ""; position: absolute; left: 0; top: 55%; height: 2px; width: 0;
  background: linear-gradient(90deg, var(--accent-3), var(--accent-4));
  border-radius: 2px;
  animation: strike 0.35s ease 0.08s forwards;
}
@keyframes strike { to { width: 100%; } }

/* 删除按钮 */
.del {
  width: 30px; height: 30px; border-radius: 10px; flex-shrink: 0;
  font-size: 14px; color: var(--text-dim); display: grid; place-items: center;
  opacity: 0; transform: scale(0.7);
  transition: opacity 0.2s ease, transform 0.2s ease, background 0.2s ease, color 0.2s ease;
}
.todo-item:hover .del { opacity: 1; transform: scale(1); }
.del:hover { background: rgba(255, 84, 112, 0.15); color: var(--danger); }

/* 准备删除（摇晃确认） */
.todo-item.arming {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(255, 84, 112, 0.2), 0 0 24px rgba(255, 84, 112, 0.25);
  animation: shake 0.45s ease;
  background: rgba(255, 84, 112, 0.08);
}
.todo-item.arming .del { opacity: 1; transform: scale(1); background: var(--danger); color: #fff; }

/* 删除消散 */
.todo-item.dying { animation: dying 0.32s ease forwards; }
@keyframes dying { to { opacity: 0; transform: scale(0.65) rotate(5deg); filter: blur(5px); } }

/* ============ 空状态 & 页脚 ============ */
.empty-state { text-align: center; padding: 48px 0; color: var(--text-dim); }
.empty-icon { font-size: 46px; margin-bottom: 12px; animation: bob 2.4s ease-in-out infinite; display: inline-block; }
@keyframes bob { 50% { transform: translateY(-8px) rotate(6deg); } }

.footer { text-align: center; margin-top: 30px; color: #5c628c; font-size: 12px; }

/* ============ 飘字 & Toast ============ */
.float-text {
  position: fixed; z-index: 60; font-weight: 900; font-size: 20px;
  transform: translate(-50%, 0); text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
  animation: floatUp 1s ease-out forwards; pointer-events: none;
}
@keyframes floatUp {
  to { transform: translate(-50%, -64px); opacity: 0; }
}

.toast {
  position: fixed; left: 50%; bottom: 36px; z-index: 70;
  transform: translateX(-50%);
  padding: 12px 22px; border-radius: 12px; font-size: 14px; color: #fff;
  background: rgba(30, 32, 60, 0.92); border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  animation: toastIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 16px); } }

/* ============ 分类栏 ============ */
.cat-bar { display: flex; align-items: center; gap: 8px; margin-top: 16px; }
.cat-chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 8px; scrollbar-width: none; }
.cat-chips::-webkit-scrollbar { display: none; }
.cat-chips:empty { display: none; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; border-radius: 999px; white-space: nowrap;
  font-size: 13px; color: var(--text-dim);
  background: var(--card); border: 1px solid var(--card-border);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  transition: transform 0.15s ease, background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  flex-shrink: 0;
}
.chip:hover { background: rgba(255, 255, 255, 0.12); transform: translateY(-1px); }
.chip.active {
  color: #fff; border-color: transparent;
  background: linear-gradient(135deg, var(--accent-4), var(--accent-5));
  box-shadow: 0 4px 16px rgba(176, 107, 255, 0.45);
}
.chip-count { font-size: 11px; font-weight: 700; opacity: 0.85; font-variant-numeric: tabular-nums; }

.chip-mini { width: 34px; height: 4px; border-radius: 99px; background: rgba(255, 255, 255, 0.18); overflow: hidden; }
.chip-mini-fill { display: block; height: 100%; border-radius: 99px; background: var(--accent-3); }

.chip-del {
  display: grid; place-items: center; width: 16px; height: 16px; border-radius: 50%;
  font-size: 10px; line-height: 1; color: var(--text-dim); margin-left: 2px;
  opacity: 0; transform: scale(0.6);
  transition: opacity 0.2s ease, transform 0.2s ease, background 0.2s ease, color 0.2s ease;
}
.chip:hover .chip-del { opacity: 1; transform: scale(1); }
.chip-del:hover { background: var(--danger); color: #fff; }

.cat-add {
  flex-shrink: 0; padding: 7px 12px; border-radius: 999px;
  font-size: 13px; color: var(--text-dim);
  background: rgba(255, 255, 255, 0.06); border: 1px dashed rgba(255, 255, 255, 0.25);
  transition: transform 0.15s ease, color 0.2s ease, border-color 0.2s ease;
}
.cat-add:hover { color: var(--text); border-color: var(--accent-2); transform: translateY(-1px); }
.cat-add:active { transform: scale(0.94); }

/* ============ 分类分组 ============ */
.list-container { margin-top: 8px; }
.cat-group { margin-top: 20px; }

.group-header {
  display: flex; align-items: center; gap: 12px;
  padding: 0 4px 8px; font-size: 14px;
}
.group-name { font-weight: 800; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.group-bar { flex: 1; height: 5px; border-radius: 99px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.group-bar-fill {
  display: block; height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, var(--accent-3), var(--accent-4));
  box-shadow: 0 0 8px rgba(61, 220, 151, 0.5);
  transition: width 0.5s cubic-bezier(0.34, 1.3, 0.64, 1);
}
.group-meta { color: var(--text-dim); font-size: 12px; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* 任务项内：标题 + 日期 */
.todo-item .item-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.todo-item .title { flex: none; }
.todo-item .meta {
  font-size: 11.5px; color: #777da8;
  font-variant-numeric: tabular-nums;
  transition: color 0.25s ease;
}
.todo-item.done .meta { color: #5f6690; }

/* 新任务高亮 */
.todo-item.flash {
  box-shadow: 0 0 0 2px rgba(255, 179, 71, 0.55), 0 0 26px rgba(255, 179, 71, 0.35);
  animation: flashIn 0.9s ease;
}
@keyframes flashIn { 50% { background: rgba(255, 179, 71, 0.14); } }

/* ============ 响应式 ============ */
@media (max-width: 520px) {
  .app { padding: 24px 12px 50px; }
  .title { font-size: 22px; }
  .hero { padding: 20px 18px 18px; }
}
