:root {
  --bg: #f4f5f8;
  --card: #ffffff;
  --text: #191b24;
  --muted: #6c7080;
  --line: #e7e8ee;
  --accent: #4b57d1;
  --accent-soft: #e8eafb;
  --danger: #d23c3c;
  --bar-bg: #eaebf0;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1014;
    --card: #1b1d24;
    --text: #e9eaf0;
    --muted: #8e92a2;
    --line: #2b2e38;
    --accent: #8b95ff;
    --accent-soft: #232745;
    --danger: #f06a6a;
    --bar-bg: #2b2e38;
    --shadow: none;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", sans-serif;
  -webkit-text-size-adjust: 100%;
}
body.locked { overflow: hidden; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
h1, h2, h3 { margin: 0; }
h1 { font-size: 24px; font-weight: 700; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }

#view {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 12px) 16px calc(env(safe-area-inset-bottom) + 96px);
}

.muted { color: var(--muted); }
.small { font-size: 13px; }
.pad { padding: 0 4px; }
.late { color: var(--danger) !important; }

.page-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin: 4px 0 12px; min-height: 44px;
}
.page-head small { color: var(--muted); font-size: 13px; }
.page-head h1 { flex: 1; }
.page-head .icon-btn + h1 { text-align: center; font-size: 20px; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center; font-size: 28px; color: var(--accent);
}
.text-btn { color: var(--accent); font-size: 15px; padding: 6px 2px; }
.text-btn.strong { font-weight: 600; }

.card {
  display: block;
  background: var(--card);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.card.flush { padding: 0; }
.card.link:active { opacity: .7; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.mid { font-size: 20px; font-weight: 650; font-variant-numeric: tabular-nums; }
.grid2 { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }

.notice {
  display: block; padding: 10px 14px; margin: 0 0 12px; border-radius: 12px;
  background: var(--accent-soft); color: var(--accent); font-size: 14px;
}
.sec-head { display: flex; justify-content: space-between; align-items: center; margin: 18px 4px 8px; scroll-margin-top: calc(env(safe-area-inset-top) + 12px); }
.sec-head h3 { font-weight: 600; }
.sec-head small { font-weight: 400; }
.sec-head .text-btn { padding: 0 2px; font-size: 14px; }
.sec-head .text-btn.small { font-size: 13px; }
.empty { text-align: center; color: var(--muted); padding: 36px 0; }

/* 进度环 */
.ring { width: 46px; height: 46px; flex: none; }
.ring circle { fill: none; stroke-width: 3.5; }
.ring-bg { stroke: var(--bar-bg); }
.ring-fg { stroke: var(--accent); stroke-linecap: round; transition: stroke-dasharray .3s; }
.ring text { font-size: 9px; font-weight: 600; fill: var(--text); font-variant-numeric: tabular-nums; }

/* 快速添加 */
.quick {
  display: flex; align-items: center; gap: 8px; background: var(--card); border-radius: 12px;
  padding: 0 14px; box-shadow: var(--shadow); min-height: 46px;
}
.quick-plus { color: var(--accent); font-size: 20px; }
.quick input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text);
  font: inherit; font-size: 16px; padding: 12px 0;
}
.quick-hint { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 4px 0; font-size: 12.5px; color: var(--muted); }
.quick-hint:empty { display: none; }
.quick-hint > span { background: var(--card); border-radius: 8px; padding: 2px 8px; }
.quick-hint .a-tag { padding: 0; background: none; }

/* 任务 */
.tasks { list-style: none; margin: 0 0 12px; }
.task { display: flex; align-items: flex-start; gap: 12px; padding: 12px 16px 12px 14px; transition: opacity .18s; }
.task + .task { border-top: 1px solid var(--line); }
.check {
  flex: none; width: 24px; height: 24px; margin-top: 1px; border-radius: 50%;
  border: 2px solid var(--muted); opacity: .7; position: relative;
}
.check::before { content: ""; position: absolute; inset: -10px; }
.task.imp .check { border-color: var(--danger); opacity: 1; }
.task.done .check, .task.ticking .check { background: var(--accent); border-color: var(--accent); opacity: 1; }
.task.done .check::after, .task.ticking .check::after {
  content: ""; position: absolute; left: 6px; top: 2px; width: 6px; height: 11px;
  border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.task.ticking { opacity: .45; }
.t-main { flex: 1; min-width: 0; cursor: pointer; }
.t-main b { display: block; font-weight: 500; word-break: break-word; }
.task.imp:not(.done) .t-main b::after { content: " !"; color: var(--danger); font-weight: 700; }
.task.done .t-main b { color: var(--muted); text-decoration: line-through; }
.t-main small { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 3px; color: var(--muted); font-size: 12.5px; }
.a-tag { color: var(--c); font-weight: 500; white-space: nowrap; }

.fold { color: var(--muted); font-size: 14px; padding: 14px 4px 8px; }

/* 计划页的一周 */
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin: 14px 0 4px; }
.wk {
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 7px 0 6px; border-radius: 12px; background: var(--card); box-shadow: var(--shadow);
}
.wk span { font-size: 11px; color: var(--muted); }
.wk b { font-size: 16px; font-weight: 650; }
.wk small { font-size: 11px; color: var(--accent); font-weight: 600; min-height: 15px; }
.wk.free small { color: var(--muted); font-weight: 400; }
.wk.today { background: var(--accent); }
.wk.today span, .wk.today b, .wk.today small { color: #fff; }

/* 分类 */
.area-card { display: flex; flex-direction: column; gap: 2px; margin: 0; border-left: 4px solid var(--c); }
.area-emoji { font-size: 24px; }
.area-card b { font-size: 16px; }

/* 我的 */
.breakdown { margin-top: 8px; }
.bd-row { display: grid; grid-template-columns: 96px 1fr 28px; align-items: center; gap: 10px; padding: 4px 0; font-size: 14px; }
.bd-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bd-bar { height: 8px; background: var(--bar-bg); border-radius: 4px; overflow: hidden; }
.bd-bar i { display: block; height: 100%; border-radius: 4px; }
.bd-val { font-variant-numeric: tabular-nums; text-align: right; }

.habits { list-style: none; margin: 8px 0 0; padding: 0; }
.habits li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 7px 0; cursor: pointer; }
.habits li + li { border-top: 1px solid var(--line); }
.h-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
.dots7 { display: flex; gap: 5px; }
.dots7 i { width: 12px; height: 12px; border-radius: 50%; background: var(--bar-bg); }
.dots7 i.on { background: var(--accent); }
.habits + .row, .card > .row + .small { margin-top: 4px; }

.advice-sum { margin: 8px 0 4px; font-weight: 600; }
.advice { margin: 6px 0 10px; padding-left: 20px; font-size: 14px; }
.advice li { margin: 5px 0; }

.wide-btn {
  display: block; width: 100%; text-align: center; padding: 12px; margin: 0 0 12px;
  border-radius: 12px; background: var(--accent); color: #fff; font-weight: 600; cursor: pointer;
}
.wide-btn.ghost { background: var(--accent-soft); color: var(--accent); }
.wide-btn.danger { background: transparent; color: var(--danger); margin-top: 8px; }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.btn-row .wide-btn { margin: 0; }
.card .btn-row + .small { margin-bottom: 0; }

.switch-btn { width: 50px; height: 30px; border-radius: 15px; background: var(--bar-bg); position: relative; transition: .2s; flex: none; }
.switch-btn i { position: absolute; left: 3px; top: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: .2s; }
.switch-btn.on { background: var(--accent); }
.switch-btn.on i { left: 23px; }

/* 底部导航 */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
  padding: 6px 8px calc(env(safe-area-inset-bottom) + 6px);
  background: color-mix(in srgb, var(--card) 88%, transparent);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
}
.tabbar a { display: flex; flex-direction: column; align-items: center; font-size: 11px; color: var(--muted); padding: 2px 0; }
.tabbar a .ti { font-size: 20px; filter: grayscale(1); opacity: .6; }
.tabbar a.on { color: var(--accent); }
.tabbar a.on .ti { filter: none; opacity: 1; }
.add-btn {
  justify-self: center; width: 52px; height: 52px; border-radius: 50%; margin-top: -18px;
  background: var(--accent); color: #fff; font-size: 30px; line-height: 1;
  box-shadow: 0 4px 12px rgba(75, 87, 209, .35);
}

/* 弹出表单 */
.sheet { position: fixed; inset: 0; z-index: 20; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .35); }
.sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 92vh; overflow-y: auto;
  max-width: 560px; margin: 0 auto;
  background: var(--bg); border-radius: 18px 18px 0 0;
  padding: 8px 16px calc(env(safe-area-inset-bottom) + 20px);
  animation: up .22s ease-out;
}
@keyframes up { from { transform: translateY(40px); opacity: .4; } }
.sheet-head { display: flex; justify-content: space-between; align-items: center; padding: 6px 0 12px; }

.title-box { background: var(--card); border-radius: 14px; padding: 4px 16px; margin-bottom: 12px; }
.title-box input {
  width: 100%; border: 0; outline: 0; background: transparent; color: var(--text);
  font: inherit; font-size: 18px; font-weight: 600; padding: 12px 0;
}
.area-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.achip {
  padding: 6px 12px; border-radius: 16px; background: var(--card); font-size: 14px; color: var(--muted);
  border: 1.5px solid transparent;
}
.achip.on { border-color: var(--c); color: var(--text); background: color-mix(in srgb, var(--c) 15%, var(--card)); }

.chips { display: flex; gap: 8px; margin: 0 0 10px; overflow-x: auto; scrollbar-width: none; }
.chip { padding: 6px 14px; border-radius: 16px; background: var(--card); color: var(--muted); font-size: 14px; white-space: nowrap; }
.chip.on { background: var(--accent); color: #fff; }

.field {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--card); border-radius: 12px; padding: 4px 16px; margin-bottom: 8px; min-height: 48px;
}
.field > span { flex: none; color: var(--muted); font-size: 14px; }
.field input:not([type="checkbox"]), .field select {
  flex: 1; min-width: 0; text-align: right; border: 0; outline: 0; background: transparent; color: var(--text);
  font-family: inherit; font-size: 16px; padding: 10px 0; -webkit-appearance: none; appearance: none;
}
.field input[type="date"], .field input[type="time"] { display: flex; justify-content: flex-end; }
.field select { direction: rtl; }
.field select option { direction: ltr; }
.field .text-btn { flex: none; }

input.switch {
  -webkit-appearance: none; appearance: none; margin: 0;
  width: 50px; height: 30px; border-radius: 15px; background: var(--bar-bg); position: relative; transition: .2s; cursor: pointer;
}
input.switch::after {
  content: ""; position: absolute; left: 3px; top: 3px; width: 24px; height: 24px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: .2s;
}
input.switch:checked { background: var(--danger); }
input.switch:checked::after { left: 23px; }

.note, .paste {
  display: block; width: 100%; border: 0; border-radius: 12px; padding: 12px 16px; margin-bottom: 12px;
  background: var(--card); color: var(--text); font: inherit; font-size: 16px; resize: vertical; outline: 0;
}
.note { min-height: 88px; }
.paste { min-height: 240px; }

.area-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.area-row input {
  border: 0; outline: 0; background: var(--card); color: var(--text); border-radius: 12px;
  font: inherit; font-size: 16px; padding: 12px 14px;
}
.emoji-in { width: 56px; text-align: center; }
.name-in { flex: 1; min-width: 0; }
.small-x { color: var(--danger); flex: none; }

.picks { list-style: none; margin: 0 0 12px; }
.picks li + li { border-top: 1px solid var(--line); }
.picks label { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; }
.picks input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--accent); flex: none; }
.picks b { display: block; font-weight: 500; }
.picks small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px; }

.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 90px); z-index: 30;
  transform: translate(-50%, 10px); opacity: 0; pointer-events: none;
  display: flex; align-items: center; gap: 14px; white-space: nowrap;
  background: rgba(24, 26, 34, .9); color: #fff; padding: 9px 16px; border-radius: 20px; font-size: 14px;
  transition: .2s; max-width: 90vw;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.show.actionable { pointer-events: auto; }
.toast button { color: #a9b1ff; font-weight: 600; }

/* 目标 */
.goal-strip { display: flex; gap: 10px; overflow-x: auto; margin: 0 -16px 8px; padding: 2px 16px 4px; scrollbar-width: none; scroll-snap-type: x mandatory; }
.goal-strip::-webkit-scrollbar { display: none; }
.goal-mini {
  flex: none; width: 150px; scroll-snap-align: start; display: flex; flex-direction: column; gap: 1px;
  padding: 10px 12px; border-radius: 14px; box-shadow: var(--shadow);
  background: linear-gradient(135deg, var(--accent-soft), var(--card));
}
.goal-mini:only-child { width: 100%; }
.gm-emoji { font-size: 20px; }
.goal-mini b { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.goal-mini small { font-size: 11.5px; color: var(--accent); }
.motto { margin: 2px 4px 12px; font-size: 13px; color: var(--muted); font-style: italic; }
.motto span { font-style: normal; white-space: nowrap; }

.goal-card, .goal-hero { background: linear-gradient(135deg, var(--accent-soft), var(--card) 70%); }
.goal-card.achieved, .goal-hero.achieved { background: linear-gradient(135deg, color-mix(in srgb, #f5b300 18%, var(--card)), var(--card) 70%); }
.goal-emoji { font-size: 28px; }
.goal-emoji.big { font-size: 40px; }
.goal-title { display: block; font-size: 18px; font-weight: 700; margin-top: 4px; }
.goal-hero .goal-title { font-size: 22px; }
.goal-why { margin: 6px 0 2px; font-size: 14px; color: var(--muted); white-space: pre-line; }
.goal-foot { margin-top: 10px; }
.goal-next { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; color: var(--accent); }
.pill { font-size: 12px; color: var(--accent); background: var(--card); padding: 3px 10px; border-radius: 10px; white-space: nowrap; }
.goal-empty { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 22px 16px; border: 1.5px dashed var(--line); background: transparent; box-shadow: none; }
.goal-empty span { font-size: 32px; }
.goal-done-btn { margin-top: 20px; }
.g-tag { color: var(--accent); white-space: nowrap; }
.bar { height: 8px; border-radius: 4px; background: var(--bar-bg); overflow: hidden; margin-top: 10px; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 4px; transition: width .3s; }

.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 40; overflow: hidden; }
.confetti i { position: absolute; top: -12px; width: 8px; height: 12px; border-radius: 2px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(105vh) rotate(720deg); opacity: .6; } }

/* 事项 */
.p-area { margin: 14px 4px 6px; font-size: 13px; font-weight: 600; color: var(--c); }
.projs { list-style: none; margin: 0 0 4px; }
.projs li + li { border-top: 1px solid var(--line); }
.proj { display: block; padding: 12px 16px; }
.proj:active { background: var(--bar-bg); }
.proj-head { display: flex; align-items: center; gap: 8px; }
.proj-head b { font-size: 16px; }
.proj-head .pill, .proj-hero .pill { background: var(--bar-bg); color: var(--muted); }
.p-note { margin: 4px 0 0; font-size: 13px; color: var(--muted); white-space: pre-line;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.p-now, .p-idle, .p-later { margin: 5px 0 0; font-size: 13.5px; }
.p-now { color: var(--accent); font-weight: 500; }
.p-idle { color: var(--muted); }
.p-later { color: var(--muted); font-size: 12.5px; }
.projs + .btn-row { margin-top: 14px; }
.btn-row + .text-btn { display: block; margin: 6px auto 0; }
.proj-chips { margin: 10px 0 0; }
.proj-chips .chip { color: var(--accent); }
.proj-hero .row { justify-content: flex-start; }
.p-note-edit {
  display: block; width: 100%; margin-top: 10px; border: 0; outline: 0; resize: none; overflow: hidden;
  background: transparent; color: var(--text); font: inherit; font-size: 15px; line-height: 1.5; padding: 0; min-height: 3em;
}
.review-bar {
  position: fixed; left: 12px; right: 12px; bottom: calc(env(safe-area-inset-bottom) + 72px); z-index: 11;
  max-width: 536px; margin: 0 auto;
  display: flex; align-items: center; gap: 12px; padding: 8px 8px 8px 16px; border-radius: 16px;
  background: var(--text); color: var(--bg); box-shadow: 0 6px 20px rgba(0,0,0,.2);
}
.review-bar span { flex: 1; font-size: 14px; }
.review-bar .text-btn { color: var(--bg); opacity: .7; }
.review-next { background: var(--accent); color: #fff; padding: 9px 16px; border-radius: 12px; font-weight: 600; }
.end-proj { display: block; margin: 24px auto 0; color: var(--muted); }
.review-space { height: 64px; }
