:root {
  --primary: #5b8def;
  --primary-2: #7c5cff;
  --bg: #f5f7fb;
  --card: #ffffff;
  --text: #1f2430;
  --muted: #8a93a6;
  --line: #e8ecf4;
  --green: #34c77b;
  --red: #f05d5e;
  --orange: #ffab40;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(31, 36, 48, 0.06);
}
* { 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', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: 96px;
}

/* header */
.app-header {
  position: sticky; top: 0; z-index: 20;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff; padding: 16px 16px 40px;
  border-radius: 0 0 22px 22px;
  box-shadow: 0 4px 16px rgba(91, 141, 239, 0.35);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; max-width: 640px; margin: 0 auto; }
.app-title { font-size: 18px; font-weight: 700; letter-spacing: 0.5px; }
.today-short { font-size: 13px; opacity: 0.92; background: rgba(255,255,255,0.22); padding: 4px 12px; border-radius: 20px; }

main { max-width: 640px; margin: -18px auto 0; padding: 0 14px; }

/* panes */
.tab-pane { display: none; animation: fade 0.18s ease; }
.tab-pane.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* date bar */
.date-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 6px 0 12px; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 12px; border: none; background: var(--card);
  color: var(--primary); font-size: 22px; line-height: 1; box-shadow: var(--shadow); cursor: pointer;
}
.date-mid { flex: 1; text-align: center; }
.date-label { font-size: 15px; font-weight: 600; }
.mini-btn {
  border: none; background: rgba(91,141,239,0.12); color: var(--primary); border-radius: 20px;
  padding: 5px 12px; font-size: 12px; cursor: pointer; margin-top: 4px;
}
.mini-btn.on { background: var(--orange); color: #fff; }

/* section */
.section-head { display: flex; align-items: center; justify-content: space-between; margin: 16px 2px 10px; }
.section-title { font-size: 15px; font-weight: 700; }
.progress-chip { font-size: 12px; color: var(--primary); background: rgba(91,141,239,0.1); padding: 4px 12px; border-radius: 20px; font-weight: 600; }
.progress-chip.done { color: var(--green); background: rgba(52,199,123,0.12); }

/* goals summary cards (today) */
.goals-summary { display: flex; flex-direction: column; gap: 10px; }
.goal-mini {
  background: var(--card); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 12px;
}
.goal-mini .gm-body { flex: 1; min-width: 0; }
.gm-title { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.gm-title .tag { font-size: 11px; padding: 2px 8px; border-radius: 12px; background: rgba(91,141,239,0.12); color: var(--primary); }
.gm-title .tag.red { background: rgba(240,93,94,0.12); color: var(--red); }
.gm-sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.gm-bar { height: 6px; border-radius: 4px; background: var(--line); margin-top: 8px; overflow: hidden; }
.gm-bar i { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--primary), var(--primary-2)); }
.gm-right { text-align: right; flex-shrink: 0; }
.gm-day { font-size: 13px; font-weight: 700; color: var(--primary); }
.gm-quota { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* task list */
.task-list { display: flex; flex-direction: column; gap: 10px; }
.task {
  background: var(--card); border-radius: var(--radius); padding: 13px 14px; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 12px; cursor: pointer; border: 2px solid transparent;
}
.task.done { opacity: 0.62; }
.task.done .t-content { text-decoration: line-through; color: var(--muted); }
.task.busy { border-color: var(--orange); background: #fff8ef; }
.t-check {
  width: 24px; height: 24px; border-radius: 50%; border: 2px solid #c9d2e4; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 13px; color: #fff;
  transition: 0.15s;
}
.task.done .t-check { background: var(--green); border-color: var(--green); }
.t-body { flex: 1; min-width: 0; }
.t-content { font-size: 14px; line-height: 1.4; word-break: break-all; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.t-badge { font-size: 11px; background: rgba(91,141,239,0.12); color: var(--primary); padding: 2px 8px; border-radius: 10px; flex-shrink: 0; }
.t-meta { font-size: 11px; color: var(--muted); margin-top: 3px; display: flex; gap: 8px; }
.t-edit { font-size: 18px; color: var(--muted); padding: 0 4px; flex-shrink: 0; }

.add-btn {
  width: 100%; margin: 12px 0 6px; padding: 12px; border: 2px dashed #c9d2e4; background: transparent;
  color: var(--primary); font-size: 14px; border-radius: var(--radius); cursor: pointer;
}
.ghost-btn {
  width: 100%; margin: 8px 0 6px; padding: 11px; border: none; background: var(--card);
  color: var(--text); font-size: 14px; border-radius: var(--radius); box-shadow: var(--shadow); cursor: pointer;
}
.ghost-btn.danger { color: var(--red); }
.primary-btn {
  width: 100%; margin: 8px 0 6px; padding: 12px; border: none; border-radius: var(--radius);
  background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff;
  font-size: 15px; font-weight: 600; cursor: pointer;
}

/* plan week grid */
.week-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin: 4px 0 12px; }
.wk-cell {
  background: var(--card); border-radius: 12px; padding: 8px 2px; text-align: center; box-shadow: var(--shadow);
  cursor: pointer; border: 2px solid transparent; position: relative;
}
.wk-cell.sel { border-color: var(--primary); }
.wk-cell.today .wk-dow { color: var(--primary); font-weight: 700; }
.wk-cell.busy { background: #fff8ef; border-color: var(--orange); }
.wk-dow { font-size: 10px; color: var(--muted); }
.wk-day { font-size: 15px; font-weight: 700; margin: 2px 0; }
.wk-dot { font-size: 10px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wk-dot.remain { color: var(--primary); font-weight: 600; }

/* goal list */
.goal-list { display: flex; flex-direction: column; gap: 12px; }
.goal-card { background: var(--card); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.gc-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.gc-title { font-size: 15px; font-weight: 700; }
.gc-actions { display: flex; gap: 6px; flex-shrink: 0; }
.gc-actions button { border: none; background: rgba(91,141,239,0.1); color: var(--primary); border-radius: 8px; padding: 4px 8px; font-size: 12px; cursor: pointer; }
.gc-actions button.red { background: rgba(240,93,94,0.1); color: var(--red); }
.gc-state { font-size: 12px; color: var(--muted); margin-top: 6px; display: flex; gap: 14px; flex-wrap: wrap; }
.gc-state b { color: var(--text); }
.gc-state .red { color: var(--red); }
.gc-bar { height: 8px; border-radius: 5px; background: var(--line); margin-top: 10px; overflow: hidden; }
.gc-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), var(--primary-2)); border-radius: 5px; }
.gc-bar i.over { background: linear-gradient(90deg, #ffab40, var(--red)); }
.gc-note { font-size: 12px; color: var(--muted); margin-top: 8px; }
.gc-off { opacity: 0.55; }

/* settings */
.card { background: var(--card); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); margin-bottom: 12px; }
.sec-title { font-size: 14px; font-weight: 700; margin-bottom: 10px; }
.input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  font-size: 14px; background: #fff; color: var(--text); outline: none; margin: 6px 0;
}
.input:focus { border-color: var(--primary); }
.input.tall { min-height: 72px; resize: vertical; }
.input.big { font-size: 20px; letter-spacing: 4px; text-align: center; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; font-size: 13px; color: var(--muted); }
.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; }
.row { display: flex; align-items: center; justify-content: space-between; font-size: 13px; color: var(--text); padding: 6px 0; }
.row input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--primary); }
.hint { font-size: 11px; color: var(--muted); line-height: 1.5; margin: 4px 2px; }
.center-h { text-align: center; }
.btn-row { display: flex; gap: 8px; margin-top: 10px; }
.btn-row button { margin: 0; }
.center-row { justify-content: center; }

/* log */
.log-list { display: flex; flex-direction: column; gap: 6px; max-height: 260px; overflow-y: auto; }
.log-item { font-size: 12px; padding: 8px 10px; background: var(--bg); border-radius: 8px; line-height: 1.5; }
.log-item b { color: var(--text); }
.log-item .st { font-weight: 700; }
.log-item .st.ok { color: var(--green); }
.log-item .st.fail { color: var(--red); }
.log-item .ts { color: var(--muted); float: right; font-size: 11px; }

/* bottom nav */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: var(--card); border-top: 1px solid var(--line);
  display: flex; padding: 6px 0 calc(8px + env(safe-area-inset-bottom));
  box-shadow: 0 -2px 12px rgba(31,36,48,0.05);
}
.nav-btn {
  flex: 1; border: none; background: none; color: var(--muted); font-size: 11px;
  display: flex; flex-direction: column; align-items: center; gap: 3px; cursor: pointer; padding: 6px 0;
}
.nav-btn .ico { font-size: 20px; }
.nav-btn.active { color: var(--primary); font-weight: 600; }
.footer-pad { height: 20px; }

/* modal */
.modal-mask {
  position: fixed; inset: 0; z-index: 50; background: rgba(20,26,40,0.45);
  display: flex; align-items: flex-end; justify-content: center; backdrop-filter: blur(2px);
}
.modal {
  background: #fff; width: 100%; max-width: 560px; border-radius: 18px 18px 0 0;
  padding: 18px 18px calc(22px + env(safe-area-inset-bottom)); max-height: 88vh; overflow-y: auto;
  animation: slideUp 0.22s ease;
}
@keyframes slideUp { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal.center { text-align: center; }
.modal-title { font-size: 16px; font-weight: 700; margin-bottom: 14px; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 110px; transform: translateX(-50%); z-index: 99;
  background: rgba(31,36,48,0.92); color: #fff; padding: 10px 18px; border-radius: 24px;
  font-size: 13px; max-width: 82vw; box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}
.toast.ok { background: rgba(52,199,123,0.95); }
.toast.err { background: rgba(240,93,94,0.95); }
.hidden { display: none !important; }

/* empty */
.empty { text-align: center; color: var(--muted); font-size: 13px; padding: 24px 0; }

@media (min-width: 560px) {
  .modal { border-radius: 18px; margin: 10vh auto; }
  .modal-mask { align-items: center; }
}