:root {
  --bg: #f2f4f9;
  --card: #ffffff;
  --text: #1e2233;
  --muted: #8b93a7;
  --line: #eceef4;
  --brand: #4f7cff;
  --brand-soft: #eaf0ff;
  --danger: #ef4444;
  --radius: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 520px;
  margin: 0 auto;
  padding: 0 14px calc(78px + var(--safe-b));
  min-height: 100vh;
}

/* ---------- 通用 ---------- */
.hidden { display: none !important; }
.muted { color: var(--muted); font-weight: 400; font-size: 13px; }

.hd { padding: 22px 4px 12px; }
.hd h1 { margin: 0; font-size: 24px; font-weight: 700; letter-spacing: -0.3px; }
.hd-sub { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: 0 1px 2px rgba(30, 34, 51, 0.04);
}

.row-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 10px;
}

.link-btn {
  background: none; border: none; padding: 0;
  color: var(--brand); font-size: 13px; font-weight: 500;
}

.text-input, .date-input {
  width: 100%;
  border: 1px solid var(--line);
  background: #fafbfe;
  border-radius: 12px;
  padding: 11px 12px;
  font-size: 15px;
  color: var(--text);
  font-family: inherit;
  outline: none;
}
.text-input:focus, .date-input:focus { border-color: var(--brand); background: #fff; }
.date-input { min-height: 44px; }

.primary-btn {
  width: 100%;
  border: none;
  background: var(--brand);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  padding: 14px;
  border-radius: 14px;
  margin-bottom: 12px;
  font-family: inherit;
}
.primary-btn:active { opacity: 0.85; }
.primary-btn.ghost { background: var(--brand-soft); color: var(--brand); }

/* ---------- 快捷日期 ---------- */
.quick-dates { display: flex; gap: 8px; margin-top: 10px; }
.quick-dates button {
  flex: 1;
  border: 1px solid var(--line);
  background: #fafbfe;
  border-radius: 10px;
  padding: 7px 0;
  font-size: 13px;
  color: var(--muted);
  font-family: inherit;
}
.quick-dates button.on { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }

/* ---------- 项目选择 ---------- */
.proj-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.proj-item {
  border: 1.5px solid var(--line);
  background: #fafbfe;
  border-radius: 12px;
  padding: 12px 4px;
  text-align: center;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-height: 68px;
  justify-content: center;
}
.proj-item .dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.proj-item.on { border-color: currentColor; }
.proj-item .name { line-height: 1.25; word-break: break-all; }

/* ---------- 时长 chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.chips button {
  border: 1px solid var(--line);
  background: #fafbfe;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  color: var(--muted);
  font-family: inherit;
}
.chips button.on { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }

/* ---------- 记录行 ---------- */
.rec {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.rec:last-child { border-bottom: none; }
.rec .bar { width: 4px; height: 30px; border-radius: 3px; flex: none; }
.rec .info { flex: 1; min-width: 0; }
.rec .t1 { font-size: 14px; font-weight: 600; }
.rec .t2 { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rec .del {
  border: none; background: none; color: var(--muted);
  font-size: 13px; padding: 4px 6px; font-family: inherit;
}
.empty { color: var(--muted); font-size: 13px; text-align: center; padding: 16px 0; }

/* ---------- 日历 ---------- */
.cal-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-title { font-size: 16px; font-weight: 700; }
.nav-btn {
  border: none; background: #f3f5fb; color: var(--text);
  width: 32px; height: 32px; border-radius: 10px; font-size: 18px; line-height: 1;
  font-family: inherit;
}
.cal-week {
  display: grid; grid-template-columns: repeat(7, 1fr);
  font-size: 12px; color: var(--muted); text-align: center; margin-bottom: 4px;
}
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-cell {
  aspect-ratio: 1 / 1.05;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 13px;
  border: none;
  background: none;
  font-family: inherit;
  color: var(--text);
  padding: 0;
}
.cal-cell.out { color: #cfd4e0; }
.cal-cell.today { background: var(--brand-soft); font-weight: 700; color: var(--brand); }
.cal-cell:active { background: #eef1f8; }
.cal-cell.sel { background: var(--brand); color: #fff; font-weight: 700; }
.cal-cell.sel .cal-dots i { box-shadow: 0 0 0 1.5px rgba(255, 255, 255, 0.85); }
.cal-cell.sel .cal-dots .more { color: rgba(255, 255, 255, 0.9); box-shadow: none; }
.cal-dots { display: flex; gap: 2px; height: 6px; align-items: center; }
.cal-dots i { width: 5px; height: 5px; border-radius: 50%; display: block; }
.cal-dots .more { font-size: 9px; color: var(--muted); font-style: normal; width: auto; height: auto; line-height: 1; }

/* ---------- 日历下方：当日详情 + 内联添加 ---------- */
.day-panel { border: 1.5px solid var(--brand-soft); }
.day-panel .row-label { margin-bottom: 6px; }

.add-entry {
  width: 100%;
  border: 1px dashed #c8d3f5;
  background: #fafbff;
  color: var(--brand);
  border-radius: 12px;
  padding: 11px;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  margin-top: 8px;
}
.add-entry:active { background: var(--brand-soft); }

.inline-form {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  animation: fadeIn 0.18s ease;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(-4px); } }
.inline-form .row-label.mt { margin-top: 14px; }

.form-btns { display: flex; gap: 10px; margin-top: 14px; }
.sub-btn {
  flex: 1;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  border-radius: 12px;
  padding: 11px;
  font-size: 15px;
  font-family: inherit;
}
.sub-btn.main { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.sub-btn:active { opacity: 0.85; }

/* ---------- 统计 ---------- */
.stat-row { display: flex; gap: 10px; margin-bottom: 12px; }
.stat {
  flex: 1; background: var(--card); border-radius: var(--radius);
  padding: 14px 6px; text-align: center;
  box-shadow: 0 1px 2px rgba(30, 34, 51, 0.04);
}
.stat b { display: block; font-size: 20px; font-weight: 700; }
.stat span { font-size: 12px; color: var(--muted); }

.ms-row { display: flex; align-items: center; gap: 8px; padding: 7px 0; font-size: 14px; }
.ms-row .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.ms-row .n { flex: 1; }
.ms-row .v { color: var(--muted); font-size: 13px; }

/* ---------- 项目管理 ---------- */
.proj-row {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 0; border-bottom: 1px solid var(--line);
}
.proj-row:last-child { border-bottom: none; }
.proj-row .dot { width: 14px; height: 14px; border-radius: 50%; flex: none; }
.proj-row .n { flex: 1; font-size: 15px; }
.proj-row button {
  border: 1px solid var(--line); background: #fff; border-radius: 8px;
  padding: 5px 10px; font-size: 13px; color: var(--muted); font-family: inherit; margin-left: 6px;
}
.proj-row button.danger { color: var(--danger); border-color: #fde2e2; }

/* ---------- 底部导航 ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b);
  max-width: 520px; margin: 0 auto;
}
.tab {
  flex: 1; border: none; background: none; padding: 8px 0 7px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--muted); font-size: 11px; font-family: inherit;
}
.tab i { font-style: normal; font-size: 18px; line-height: 1.1; }
.tab.active { color: var(--brand); }

/* ---------- 弹层 ---------- */
.sheet-mask {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(20, 24, 40, 0.4);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  width: 100%; max-width: 520px;
  background: var(--card);
  border-radius: 20px 20px 0 0;
  padding: 16px 14px calc(16px + var(--safe-b));
  max-height: 82vh; overflow-y: auto;
  animation: up 0.2s ease;
}
@keyframes up { from { transform: translateY(30px); opacity: 0.6; } }
.sheet-hd { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.sheet-hd b { font-size: 17px; }
.close-btn { border: none; background: #f3f5fb; width: 28px; height: 28px; border-radius: 50%; color: var(--muted); font-family: inherit; }
.sheet-bd { margin-bottom: 12px; }

.color-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; margin-top: 4px; }
.color-grid button {
  aspect-ratio: 1; border-radius: 50%; border: 2px solid transparent; padding: 0;
}
.color-grid button.on { border-color: var(--text); }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%);
  background: rgba(30, 34, 51, 0.9); color: #fff;
  padding: 9px 18px; border-radius: 999px; font-size: 14px; z-index: 60;
  max-width: 80%; text-align: center;
}

/* 小屏（iPhone SE 等）适配 */
@media (max-width: 360px) {
  body { font-size: 14px; }
  .proj-item { font-size: 12px; min-height: 62px; }
  .chips button { padding: 6px 11px; }
}
