:root {
  --accent: #5C8B7D;
  --accent-soft: #E3EDE9;
  --bg: #F6F8F7;
  --card: #FFFFFF;
  --text: #2E3A36;
  --text-2: #6B7A74;
  --text-3: #9AA8A2;
  --border: rgba(46, 58, 54, 0.14);
  --border-2: rgba(46, 58, 54, 0.28);
  --pri-high: #C26B5E;
  --pri-med: #C99A4E;
  --pri-low: #6E94B0;
  --radius: 12px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; }

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

button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; }

#app {
  display: flex;
  gap: 16px;
  max-width: 1000px;
  margin: 0 auto;
  padding: 20px 16px 60px;
  align-items: flex-start;
}

/* ---------- Sidebar ---------- */
.sidebar {
  width: 224px;
  flex-shrink: 0;
  background: var(--card);
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 16px;
  position: sticky;
  top: 20px;
}
.brand { font-size: 16px; font-weight: 600; margin: 0 0 2px; letter-spacing: 2px; }
.brand-sub { font-size: 12px; color: var(--text-3); margin: 0 0 18px; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--text-2); font-size: 13px; cursor: pointer;
  border: none; background: transparent; width: 100%; text-align: left;
}
.nav-item:hover { background: rgba(92, 139, 125, 0.08); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 500; }
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.nav-item .count { margin-left: auto; font-size: 12px; color: var(--text-3); }
.nav-item.active .count { color: var(--accent); }

.section-title { font-size: 12px; color: var(--text-3); margin: 18px 0 6px; }
.section-title .add-link { float: right; color: var(--accent); cursor: pointer; font-size: 12px; }
.section-title .add-link:hover { text-decoration: underline; }
.ctx-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; border-radius: var(--radius-sm);
  font-size: 13px; color: var(--text-2); cursor: pointer;
}
.ctx-item:hover { background: rgba(92, 139, 125, 0.08); }
.ctx-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* 可管理行：情境/协同对象 */
.mng-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; border-radius: var(--radius-sm);
  font-size: 13px; color: var(--text-2);
}
.mng-item:hover { background: rgba(92, 139, 125, 0.08); }
.mng-name { flex: 1; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mng-acts { display: flex; gap: 4px; flex-shrink: 0; opacity: 0; transition: opacity .12s; }
.mng-item:hover .mng-acts { opacity: 1; }
.mng-btn {
  font-size: 11px; padding: 2px 7px; border: 0.5px solid var(--border);
  border-radius: 6px; background: var(--card); color: var(--text-3); cursor: pointer;
}
.mng-btn:hover { border-color: var(--accent); color: var(--accent); }
.mng-btn[data-act="del"]:hover { border-color: var(--pri-high); color: var(--pri-high); }

/* 项目视图头部 */
.proj-head { margin-bottom: 14px; display: flex; justify-content: flex-start; }


/* ---------- Main ---------- */
.main { flex: 1; min-width: 0; }
.quick-add {
  display: flex; gap: 8px; margin-bottom: 14px;
}
.quick-add input {
  flex: 1; padding: 10px 12px; border: 0.5px solid var(--border);
  border-radius: var(--radius-sm); background: var(--card); color: var(--text); font-size: 14px;
}
.quick-add input:focus { outline: none; border-color: var(--accent); }
.btn {
  padding: 9px 16px; border: 0.5px solid var(--border-2); border-radius: var(--radius-sm);
  background: var(--card); color: var(--text); font-size: 13px;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn-primary { background: var(--accent); color: #fff; border: none; }
.btn-primary:hover { background: #4f7a6e; color: #fff; }
.btn-danger { color: var(--pri-high); border-color: rgba(194,107,94,0.4); }
.btn-ghost { border: none; background: transparent; color: var(--text-3); }

.ctx-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.chip {
  font-size: 12px; padding: 4px 12px; border-radius: 999px;
  border: 0.5px solid var(--border); background: var(--card); color: var(--text-2); cursor: pointer;
}
.chip.active { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

.view-title { font-size: 15px; font-weight: 600; margin: 4px 0 14px; }

/* ---------- Task card ---------- */
.task-list { display: flex; flex-direction: column; gap: 10px; }
.task-card {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px 14px; border: 0.5px solid var(--border); border-radius: var(--radius-sm);
  background: var(--card); cursor: pointer;
}
.task-card:hover { border-color: var(--border-2); }
.check {
  width: 18px; height: 18px; border: 1px solid var(--border-2); border-radius: 5px;
  margin-top: 1px; flex-shrink: 0; flex-shrink: 0; cursor: pointer; background: var(--card);
}
.check:hover { border-color: var(--accent); }
.task-body { flex: 1; min-width: 0; }
.task-title { font-size: 14px; font-weight: 500; margin: 0 0 7px; }
.task-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.meta {
  font-size: 12px; padding: 2px 9px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
}
.meta-plain { font-size: 12px; color: var(--text-2); display: inline-flex; align-items: center; gap: 5px; }
.avatar {
  width: 16px; height: 16px; border-radius: 50%; background: var(--accent-soft); color: var(--accent);
  display: inline-flex; align-items: center; justify-content: center; font-size: 9px;
}
.pri-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

.empty { text-align: center; color: var(--text-3); padding: 40px 0; font-size: 13px; }

/* ---------- Drawer ---------- */
.drawer-mask {
  position: fixed; inset: 0; background: rgba(46,58,54,0.28); display: none;
  align-items: stretch; justify-content: flex-end; z-index: 20;
}
.drawer-mask.open { display: flex; }
.drawer {
  width: 460px; max-width: 92vw; background: var(--card); height: 100%;
  padding: 22px 24px; overflow-y: auto; box-shadow: -2px 0 20px rgba(46,58,54,0.08);
}
.drawer h2 { font-size: 14px; font-weight: 600; margin: 0; }
.drawer-head { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; }
.drawer input.title-input {
  width: 100%; font-size: 15px; font-weight: 500; padding: 9px 11px;
  border: 0.5px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 16px; color: var(--text);
}
.drawer input.title-input:focus { outline: none; border-color: var(--accent); }
.field { margin-bottom: 14px; }
.field > label { font-size: 12px; color: var(--text-3); display: block; margin-bottom: 5px; }
.field select, .field input[type=date], .field input[type=text] {
  width: 100%; padding: 8px 10px; border: 0.5px solid var(--border);
  border-radius: var(--radius-sm); background: var(--card); color: var(--text); font-size: 13px;
}
.field select:focus, .field input:focus { outline: none; border-color: var(--accent); }
.seg { display: flex; gap: 4px; }
.seg button {
  flex: 1; font-size: 12px; padding: 6px 0; border: 0.5px solid var(--border);
  border-radius: var(--radius-sm); background: var(--card); color: var(--text-2);
}
.seg button.on { background: var(--accent-soft); color: var(--accent); border-color: transparent; font-weight: 500; }
textarea.notes {
  width: 100%; padding: 8px 10px; border: 0.5px solid var(--border); border-radius: var(--radius-sm);
  font-size: 13px; color: var(--text-2); resize: vertical; min-height: 56px;
}
.checklist { display: flex; flex-direction: column; gap: 8px; }
.cl-item { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); }
.cl-item .check { width: 16px; height: 16px; }
.cl-item.done span { text-decoration: line-through; color: var(--text-3); }
.cl-add { font-size: 13px; padding: 6px 10px; border: 0.5px solid var(--border); border-radius: var(--radius-sm); color: var(--text-2); background: var(--card); }
.drawer-foot { display: flex; gap: 8px; border-top: 0.5px solid var(--border); padding-top: 14px; margin-top: 6px; }

/* ---------- Token modal ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(46,58,54,0.32);
  display: flex; align-items: center; justify-content: center; z-index: 40;
}
.modal {
  background: var(--card); padding: 26px 28px; border-radius: var(--radius); width: 360px; max-width: 90vw;
  border: 0.5px solid var(--border);
}
.modal h1 { font-size: 17px; font-weight: 600; margin: 0 0 4px; letter-spacing: 2px; }
.modal p { font-size: 13px; color: var(--text-2); margin: 0 0 16px; }
.modal input {
  width: 100%; padding: 10px 12px; border: 0.5px solid var(--border); border-radius: var(--radius-sm);
  font-size: 14px; margin-bottom: 14px; color: var(--text);
}
.modal input:focus { outline: none; border-color: var(--accent); }

/* ---------- Responsive ---------- */
.menu-btn { display: none; }
@media (max-width: 760px) {
  #app { flex-direction: column; padding: 12px; gap: 12px; }
  .sidebar { width: 100%; position: static; padding: 12px; }
  .nav { flex-direction: row; flex-wrap: wrap; gap: 4px; }
  .nav-item { width: auto; }
  .nav-item .count { margin-left: 4px; }
  .ctx-chips { display: flex; overflow-x: auto; }
  /* 移动端触屏无 hover：管理按钮常显 */
  .mng-acts { opacity: 1; }
}

/* ---------- 同步飞书日历 开关 ---------- */
.switch { position: relative; display: inline-block; width: 40px; height: 22px; vertical-align: middle; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; cursor: pointer; inset: 0; background: #cfd8d4; border-radius: 22px; transition: .2s; }
.switch .slider::before { content: ''; position: absolute; height: 16px; width: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(18px); }
.hint { display: block; font-size: 12px; color: var(--text-3); margin-top: 4px; }
