:root {
  --bg: #eef2f7;
  --surface: #fbfcfe;
  --text: #3c4658;
  --text-2: #68748a;
  --text-3: #9aa5b8;
  --border: #dce3ee;
  --primary: #7d8ba6;
  --primary-50: #e9edf5;
  --green: #6fae8f;
  --green-50: #eaf3ee;
  --amber: #c99a3a;
  --amber-50: #faf3e2;
  --red: #d98282;
  --red-50: #fbecec;
  --blue: #7a9cb8;
  --blue-50: #eaf0f6;
  --work: #f7e08b;
  --work-50: #fbf1cf;
  --work-text: #8a6d1a;
  --life: #f7c8d8;
  --life-50: #fce8ef;
  --life-text: #a34d68;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}

.app { max-width: 860px; margin: 0 auto; padding: 0 12px 40px; }

.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 4px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 40px; height: 40px; border-radius: 10px;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 14px;
}
.brand h1 { font-size: 16px; margin: 0; font-weight: 600; }
.brand .sub { margin: 0; font-size: 12px; color: var(--text-3); }
.topbar-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.tabs {
  display: flex; gap: 4px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 4px; margin-bottom: 16px;
}
.tab {
  flex: 1; padding: 8px 0; border: none; background: transparent;
  border-radius: 9px; cursor: pointer; font-size: 14px; color: var(--text-2);
  font-weight: 500;
}
.tab.active { background: var(--primary); color: #fff; }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.btn {
  padding: 8px 14px; border-radius: 9px; border: 1px solid var(--border);
  background: var(--surface); cursor: pointer; font-size: 13px; color: var(--text);
  transition: all .15s;
}
.btn:hover { border-color: var(--primary); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { opacity: .92; }
.btn-ghost { background: transparent; }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }

/* ---- 周视图 ---- */
.week-nav {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.week-title { font-weight: 600; font-size: 15px; }

.week-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  margin-bottom: 12px;
}
.week-col-head {
  text-align: center; padding: 8px 0; border-left: 1px solid var(--border);
  border-bottom: 1px solid var(--border); cursor: pointer;
}
.week-col-head:first-child { border-left: none; }
.week-col-head .wd { font-size: 12px; color: var(--text-3); }
.week-col-head .dn { font-size: 16px; font-weight: 600; }
.week-col-head.today { background: var(--primary-50); }
.week-col-head.today .dn {
  background: var(--primary); color: #fff; border-radius: 50%;
  width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center;
  margin-top: 2px;
}
.week-col-head.weekend .wd { color: var(--red); }
.week-col-head.friday { background: #f5f1e4; }

.week-col {
  min-height: 220px;
  border-left: 1px solid var(--border);
  padding: 4px;
  display: flex; flex-direction: column; gap: 4px;
  cursor: pointer;
}
.week-col:first-child { border-left: none; }
.week-col.today { background: #f2f6fb; }
.week-col.friday { background: #fbf8ef; }
.col-empty { flex: 1; min-height: 60px; }

.week-event {
  border-radius: 5px; padding: 4px 6px;
  font-size: 11px; line-height: 1.3; cursor: pointer;
  display: flex; flex-direction: column; gap: 1px;
  border: 1px solid transparent;
}
.week-event.work { background: var(--work); color: var(--work-text); border-color: #ecd271; }
.week-event.life { background: var(--life); color: var(--life-text); border-color: #f0afc5; }
.week-event.done { opacity: .5; }
.week-event.done .ev-title { text-decoration: line-through; }
.week-event .ev-time { font-size: 10px; opacity: .8; font-weight: 500; }
.week-event .ev-title { word-break: break-all; font-weight: 500; }

/* ---- 图例 ---- */
.legend {
  display: flex; gap: 16px; align-items: center; margin-bottom: 12px;
  flex-wrap: wrap;
}
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; }
.legend-dot.work { background: var(--work); }
.legend-dot.life { background: var(--life); }

/* ---- 详情 ---- */
.day-detail { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.day-detail-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.day-detail-head h2 { font-size: 15px; margin: 0; font-weight: 600; }

.day-list { display: flex; flex-direction: column; gap: 8px; }
.empty { color: var(--text-3); font-size: 13px; text-align: center; padding: 20px 0; }

.work-item {
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px;
  cursor: pointer; display: flex; gap: 10px; align-items: flex-start;
  background: var(--surface); border-left: 4px solid var(--border);
}
.work-item.work { border-left-color: var(--work); }
.work-item.life { border-left-color: var(--life); }
.work-item:hover { border-color: var(--primary); }
.work-item.done { opacity: .62; }
.work-item .body { flex: 1; min-width: 0; }
.work-item .title { font-weight: 500; }
.work-item.done .title { text-decoration: line-through; }
.work-item .meta { font-size: 12px; color: var(--text-3); }
.work-item .note { font-size: 12px; color: var(--text-2); background: var(--primary-50); border-radius: 6px; padding: 4px 8px; margin-top: 4px; }
.cat-badge { font-size: 11px; padding: 1px 7px; border-radius: 5px; white-space: nowrap; }
.cat-badge.work { background: var(--work-50); color: var(--work-text); }
.cat-badge.life { background: var(--life-50); color: var(--life-text); }
.badge { font-size: 11px; padding: 1px 6px; border-radius: 5px; white-space: nowrap; }
.badge.high { background: var(--red-50); color: var(--red); }
.badge.mid { background: var(--amber-50); color: var(--amber); }
.badge.low { background: var(--green-50); color: var(--green); }
.cal-flag, .remind-flag { margin-left: 4px; font-size: 11px; }
.checkbox {
  width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid var(--text-3);
  flex-shrink: 0; margin-top: 2px; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.checkbox.checked { background: var(--green); border-color: var(--green); }
.checkbox.checked::after { content: "✓"; color: #fff; font-size: 12px; }

/* ---- 周报 ---- */
.week-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; flex-wrap: wrap; gap: 8px; }
.week-head h2 { font-size: 16px; margin: 0; }
.week-controls { display: flex; align-items: center; gap: 8px; }
.week-range { font-size: 13px; font-weight: 500; min-width: 150px; text-align: center; }

.report-filters { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.report-filters .chip.work.active { background: var(--work-50); border-color: var(--work); color: var(--work-text); }
.report-filters .chip.life.active { background: var(--life-50); border-color: var(--life); color: var(--life-text); }

.report-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.report-toolbar { padding: 12px 16px; border-bottom: 1px solid var(--border); display: flex; gap: 8px; flex-wrap: wrap; }
.report-text {
  margin: 0; padding: 16px; font-family: inherit; font-size: 13px; white-space: pre-wrap;
  word-break: break-word; min-height: 260px; line-height: 1.7;
}
.tip { font-size: 12px; color: var(--text-3); padding: 0 4px; }

/* ---- 列表 ---- */
.list-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.list-head h2 { font-size: 16px; margin: 0; }
.filters { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.chip {
  padding: 5px 12px; border-radius: 16px; border: 1px solid var(--border);
  background: var(--surface); font-size: 13px; cursor: pointer;
}
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.filters .chip.work.active { background: var(--work-50); border-color: var(--work); color: var(--work-text); }
.filters .chip.life.active { background: var(--life-50); border-color: var(--life); color: var(--life-text); }
.filters .chip.done.active { background: var(--green-50); border-color: var(--green); color: var(--green); }
.list-container { display: flex; flex-direction: column; gap: 8px; }

/* ---- 今日对话 ---- */
.chat-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.chat-panel h2 { font-size: 16px; margin: 0 0 12px; }
.chat-bubbles { display: flex; flex-direction: column; gap: 10px; }
.bubble {
  max-width: 82%; padding: 9px 13px; border-radius: 12px; font-size: 13px; line-height: 1.5;
}
.bubble.assistant {
  align-self: flex-start; background: var(--surface); border: 1px solid var(--border);
  border-top-left-radius: 4px;
}
.bubble.user {
  align-self: flex-end; background: var(--primary); color: #fff;
  border-top-right-radius: 4px;
}
.bubble .b-time { font-size: 11px; opacity: .7; margin-top: 2px; }
.bubble.work-bubble { background: var(--work-50); border-color: var(--work); color: var(--work-text); }
.bubble.life-bubble { background: var(--life-50); border-color: var(--life); color: var(--life-text); }

/* ---- 对话输入区 ---- */
.chat-input-bar {
  display: flex; gap: 8px; margin-top: 14px; padding-top: 12px;
  border-top: 1px solid var(--border);
}
.chat-input-bar input {
  flex: 1; padding: 10px 12px; border: 1px solid var(--border); border-radius: 20px;
  font-size: 14px; font-family: inherit; background: var(--bg); color: var(--text);
}
.chat-input-bar input:focus { outline: none; border-color: var(--primary); background: var(--surface); }
.chat-input-bar .btn { border-radius: 20px; padding: 10px 18px; }

/* 对话中「已添加」结果气泡 */
.bubble.chat-result {
  background: var(--primary-50); border-color: var(--primary);
  display: flex; flex-direction: column; gap: 6px; max-width: 88%;
}
.bubble.chat-result .b-time { color: var(--text-2); opacity: 1; }
.chat-undo {
  align-self: flex-start; padding: 2px 10px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface);
  font-size: 11px; color: var(--text-2); cursor: pointer;
}
.chat-undo:hover { border-color: var(--red); color: var(--red); }

/* ---- 弹窗 ---- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.35);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px;
}
.modal {
  background: var(--surface); border-radius: var(--radius); width: 100%; max-width: 460px;
  max-height: 90vh; overflow-y: auto;
}
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px 0; }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 12px 20px 20px; display: flex; flex-direction: column; gap: 6px; }
.modal-body label { font-size: 12px; color: var(--text-2); margin-top: 8px; }
.modal-body input[type="text"], .modal-body input[type="datetime-local"], .modal-body input[type="time"], .modal-body textarea {
  width: 100%; padding: 9px 10px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px; font-family: inherit; background: var(--surface); color: var(--text);
}
.modal-body input:focus, .modal-body textarea:focus { outline: none; border-color: var(--primary); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cat-group { display: flex; gap: 16px; }
.cat { display: flex; align-items: center; gap: 5px; font-size: 13px; cursor: pointer; padding: 6px 12px; border-radius: 8px; border: 1px solid var(--border); }
.cat.work.sel { background: var(--work-50); border-color: var(--work); color: var(--work-text); }
.cat.life.sel { background: var(--life-50); border-color: var(--life); color: var(--life-text); }
.prio-group { display: flex; gap: 16px; }
.prio { display: flex; align-items: center; gap: 4px; font-size: 13px; cursor: pointer; }
.check-line { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; margin-top: 8px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 0 20px 20px; }
.modal-foot .btn-danger { margin-right: auto; }

.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%);
  background: #2c2c2a; color: #fff; padding: 9px 18px; border-radius: 20px;
  font-size: 13px; z-index: 200; white-space: nowrap;
}

.hidden { display: none !important; }

@media (max-width: 560px) {
  .week-grid { grid-template-columns: repeat(7, 1fr); }
  .row2 { grid-template-columns: 1fr; }
  .week-col-head .dn { font-size: 14px; }
  .week-col { padding: 2px; gap: 3px; }
  .week-event { padding: 3px 4px; font-size: 10px; }
  .week-event .ev-time { font-size: 9px; }
}
