:root {
  --blue: #2563eb;
  --green: #16a34a;
  --bg: #f5f7fb;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #94a3b8;
  --line: #e8edf3;
  --danger: #ef4444;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40' opacity='0.06' fill='%232563eb'%3E%3Cellipse cx='20' cy='26' rx='9' ry='8'/%3E%3Ccircle cx='11' cy='14' r='3.4'/%3E%3Ccircle cx='20' cy='10' r='3.6'/%3E%3Ccircle cx='29' cy='14' r='3.4'/%3E%3C/svg%3E");
  background-repeat: repeat;
  color: var(--text);
  max-width: 520px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: 72px;
  -webkit-font-smoothing: antialiased;
}

/* 顶部 */
.app-header {
  position: sticky; top: 0; z-index: 10;
  background: var(--blue);
  color: #fff;
  padding: calc(env(safe-area-inset-top) + 14px) 18px 14px;
  display: flex; align-items: baseline; justify-content: space-between;
}
.app-header h1 { font-size: 19px; margin: 0; font-weight: 700; }
.header-date { font-size: 13px; opacity: 0.9; }

/* 视图容器 */
.view { padding: 16px 14px 0; }

/* 进度卡 */
.progress-card {
  display: flex; align-items: center; gap: 18px;
  background: var(--card); border-radius: 16px; padding: 18px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.04); margin-bottom: 18px;
}
.progress-ring {
  position: relative; width: 92px; height: 92px; border-radius: 50%; flex: 0 0 auto;
  background: conic-gradient(var(--blue) calc(var(--p) * 1%), #e5e7eb 0);
  display: flex; align-items: center; justify-content: center;
}
.progress-ring::before { content: ''; position: absolute; width: 70px; height: 70px; border-radius: 50%; background: #fff; }
.progress-num { position: relative; font-weight: 800; font-size: 20px; color: var(--blue); }
.progress-meta { display: flex; flex-direction: column; gap: 6px; }
.streak { font-size: 16px; font-weight: 700; }
.done-count { font-size: 13px; color: var(--muted); }

/* 分类标题 */
.cat-title { font-size: 15px; margin: 18px 4px 10px; color: #475569; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.cat-title .conan { flex-shrink: 0; }

/* 任务列表 */
.task-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.task {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border-radius: 14px; padding: 14px 14px;
  box-shadow: 0 1px 6px rgba(0,0,0,0.04);
  cursor: pointer; transition: transform .08s, background .15s;
}
.task:active { transform: scale(0.98); }
.task .check {
  width: 26px; height: 26px; border-radius: 50%; flex: 0 0 auto;
  border: 2px solid #cbd5e1; display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 15px; font-weight: 700;
}
.task.done { background: #f0fdf4; }
.task.done .check { background: var(--green); border-color: var(--green); }
.task.done .tname { color: #16a34a; text-decoration: line-through; text-decoration-color: #86efac; }
.tname { flex: 1; font-size: 15px; }
.ttime { font-size: 12px; color: var(--muted); }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 999px; color: #fff; }
.badge.exercise { background: var(--blue); }
.badge.study { background: var(--green); }
.empty { color: var(--muted); text-align: center; padding: 16px; background: var(--card); border-radius: 12px; }

/* 管理 */
.add-form { display: flex; flex-wrap: wrap; gap: 8px; background: var(--card); padding: 12px; border-radius: 14px; margin-bottom: 8px; }
.add-form input, .add-form select { flex: 1 1 120px; min-width: 0; padding: 9px 10px; border: 1px solid var(--line); border-radius: 9px; font-size: 14px; }
.add-form button { flex: 0 0 auto; padding: 9px 16px; border: none; border-radius: 9px; background: var(--blue); color: #fff; font-weight: 600; }
.task.edit { flex-wrap: wrap; cursor: default; }
.task.edit input, .task.edit select { padding: 7px 8px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; }
.task.edit .e-name { flex: 1 1 100%; }
.task.edit .e-cat { flex: 1; }
.task.edit .e-time { flex: 1; }
.task.edit button { padding: 7px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-size: 13px; }
.mini { padding: 5px 9px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-size: 13px; }
.mini.danger { color: var(--danger); border-color: #fecaca; }

/* 星期筛选条（管理视图顶部） */
.dayfilter { display: flex; gap: 6px; overflow-x: auto; padding: 4px 2px 10px; margin-bottom: 4px; -webkit-overflow-scrolling: touch; }
.dfchip { flex: 0 0 auto; padding: 7px 14px; border: 1px solid var(--line); border-radius: 999px; background: #fff; font-size: 13px; color: var(--muted); cursor: pointer; }
.dfchip.active { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 700; }

/* 星期多选（添加/编辑表单内） */
.daypick { display: flex; flex-wrap: wrap; gap: 6px; flex: 1 1 100%; margin-top: 2px; }
.dchip { padding: 7px 0; width: 38px; text-align: center; border: 1px solid var(--line); border-radius: 9px; background: #fff; font-size: 13px; color: var(--text); cursor: pointer; }
.dchip.active { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 700; }

/* 星期标签（任务行） */
.badge.days { background: #eef2ff; color: #4f46e5; }

/* 今日/管理 空状态 */
.manage-empty { margin-top: 18px; background: var(--card); border-radius: 16px; padding: 26px 16px; }

/* 统计 */
.stat-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.scard { background: var(--card); border-radius: 14px; padding: 14px; text-align: center; box-shadow: 0 1px 6px rgba(0,0,0,0.04); }
.scard .snum { font-size: 22px; font-weight: 800; margin-bottom: 4px; }
.scard div:last-child { font-size: 12px; color: var(--muted); }
.chart-card { background: var(--card); border-radius: 14px; padding: 12px 8px; box-shadow: 0 1px 6px rgba(0,0,0,0.04); }

/* 设置 */
.set-row { margin-bottom: 12px; }
.set-row button, .filebtn {
  display: block; width: 100%; padding: 13px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--card); font-size: 15px; text-align: center; cursor: pointer;
}
.filebtn input { display: none; }
.set-row button.danger { color: var(--danger); border-color: #fecaca; }
.notice { display: flex; align-items: center; justify-content: space-between; background: var(--card); padding: 12px 14px; border-radius: 12px; }
.notice .switch { font-size: 14px; display: flex; align-items: center; gap: 8px; }
.notice input[type=time] { border: 1px solid var(--line); border-radius: 8px; padding: 6px; font-size: 14px; }
.hint { font-size: 12px; color: var(--muted); line-height: 1.6; margin: 6px 2px 0; }

/* 底部 Tab */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  max-width: 520px; margin: 0 auto;
  display: flex; background: #fff; border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1; border: none; background: none; padding: 9px 0; font-size: 12px; color: #94a3b8;
  display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer;
}
.tab span { font-size: 20px; }
.tab.active { color: var(--blue); font-weight: 700; }

/* 名侦探柯南贴纸 —— 独立透明 PNG */
.conan { display: inline-block; vertical-align: middle; }
.conan-mascot    { width: 42px; height: 42px; animation: wave 2.4s ease-in-out infinite; transform-origin: center bottom; }
.conan-cat       { width: 26px; height: 26px; flex-shrink: 0; }
.conan-celebrate { width: 104px; height: 104px; }
.conan-empty     { width: 88px; height: 88px; opacity: 0.9; }
.conan-about     { width: 120px; height: 120px; display: block; margin: 2px auto 10px; }

@keyframes wave { 0%, 100% { transform: rotate(-6deg) scale(1); } 50% { transform: rotate(10deg) scale(1.06); } }

/* 吉祥物 & 装饰 */
.brand { display: flex; align-items: center; gap: 8px; }
.mascot { display: inline-flex; align-items: center; justify-content: center; }
.celebrate {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  background: var(--card); border-radius: 16px; padding: 18px; margin-bottom: 16px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.04); text-align: center;
}
.cele-text { font-weight: 800; font-size: 16px; color: var(--text); }
.cele-text small { display: block; margin-top: 4px; font-weight: 400; font-size: 12px; color: var(--muted); }
.empty { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }

/* 关于页 */
.about-card {
  background: linear-gradient(135deg, #0a3d8f 0%, #1565d8 100%);
  border-radius: 14px; padding: 20px; text-align: center; margin-top: 6px;
  box-shadow: 0 2px 10px rgba(10,61,143,0.25);
}
.about-card .hint { color: #e0ecff; }

/* Toast */
#toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%) translateY(10px);
  background: rgba(17,24,39,0.92); color: #fff; padding: 10px 18px; border-radius: 999px;
  font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 50;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
