/* 任务中心 · 手机优先，大字大按钮（新手友好），Mac 宽屏居中 */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
:root {
  --blue: #2f6df6; --blue-dark: #1f56d4;
  --bg: #f6f7f9; --card: #ffffff; --line: #e8eaee;
  --text: #1c1f26; --sub: #7a8190;
  --green: #16a34a; --red: #e0332c; --orange: #d97706;
  --radius: 14px;
}
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", sans-serif;
  background: var(--bg); color: var(--text); font-size: 16px; line-height: 1.5;
}
.hidden { display: none !important; }

#app { max-width: 640px; margin: 0 auto; padding: 12px 14px calc(84px + env(safe-area-inset-bottom)); min-height: 100%; }

/* ===== 顶栏 ===== */
.topbar { display: flex; align-items: center; gap: 10px; padding: 10px 2px 14px; position: sticky; top: 0; background: var(--bg); z-index: 5; }
.topbar h1 { font-size: 22px; font-weight: 700; flex: 1; }
.topbar .back { font-size: 16px; color: var(--blue); background: none; border: none; padding: 6px 8px 6px 0; cursor: pointer; }

/* ===== 通用控件 ===== */
button.primary {
  display: block; width: 100%; padding: 14px; border: none; border-radius: var(--radius);
  background: var(--blue); color: #fff; font-size: 17px; font-weight: 600; cursor: pointer;
}
button.primary:active { background: var(--blue-dark); }
button.primary:disabled { opacity: .5; }
button.ghost {
  display: inline-block; padding: 10px 16px; border: 1.5px solid var(--line); border-radius: 12px;
  background: var(--card); color: var(--text); font-size: 15px; cursor: pointer;
}
button.danger-ghost { border-color: #f3c9c7; color: var(--red); background: #fff; }
input[type=text], input[type=password], input[type=datetime-local], textarea, select {
  width: 100%; padding: 13px 14px; border: 1.5px solid var(--line); border-radius: 12px;
  font-size: 16px; background: var(--card); color: var(--text); font-family: inherit;
  -webkit-appearance: none; appearance: none;
}
textarea { min-height: 88px; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--blue); }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 14px; color: var(--sub); margin-bottom: 6px; }
.card { background: var(--card); border-radius: var(--radius); padding: 16px; border: 1px solid var(--line); }
.muted { color: var(--sub); font-size: 14px; }
.spacer { height: 14px; }

/* ===== 登录 ===== */
.login-wrap { max-width: 380px; margin: 0 auto; padding-top: 12vh; }
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo .mark { width: 74px; height: 74px; border-radius: 20px; background: var(--blue); color: #fff; font-size: 40px; display: inline-flex; align-items: center; justify-content: center; margin-bottom: 12px; }
.login-logo h1 { font-size: 26px; }
.login-logo p { color: var(--sub); margin-top: 4px; font-size: 14px; }

/* ===== 底部 tab ===== */
#tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  display: flex; background: rgba(255,255,255,.94); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
#tabbar button {
  flex: 1; padding: 8px 0 6px; background: none; border: none; font-size: 11px; color: var(--sub);
  display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; position: relative;
}
#tabbar button .tab-icon { font-size: 22px; }
#tabbar button.active { color: var(--blue); font-weight: 600; }
.badge {
  position: absolute; top: 2px; right: calc(50% - 26px); background: var(--red); color: #fff;
  font-size: 11px; font-style: normal; min-width: 17px; height: 17px; line-height: 17px;
  border-radius: 9px; padding: 0 4px; text-align: center;
}

/* ===== 任务列表 ===== */
.seg { display: flex; background: #eceef2; border-radius: 12px; padding: 3px; margin-bottom: 14px; }
.seg button { flex: 1; border: none; background: none; padding: 9px 0; border-radius: 10px; font-size: 15px; color: var(--sub); cursor: pointer; }
.seg button.active { background: #fff; color: var(--text); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.group-title { font-size: 14px; color: var(--sub); margin: 18px 4px 8px; font-weight: 600; }
.task-item {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; margin-bottom: 10px; cursor: pointer; display: block; width: 100%; text-align: left;
}
.task-item:active { background: #fafbfc; }
.task-line1 { display: flex; align-items: center; gap: 8px; }
.task-title { font-size: 16.5px; font-weight: 600; flex: 1; word-break: break-all; }
.task-item.is-done .task-title { color: var(--sub); text-decoration: line-through; font-weight: 500; }
.task-meta { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-top: 8px; font-size: 13.5px; color: var(--sub); align-items: center; }
.chip { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 12.5px; font-weight: 600; }
.chip.urgent { background: #fdeceb; color: var(--red); }
.chip.todo { background: #eef0f4; color: #5b6472; }
.chip.doing { background: #e7efff; color: var(--blue); }
.chip.done { background: #e5f6ec; color: var(--green); }
.due-warn { color: var(--red); font-weight: 600; }
.due-soon { color: var(--orange); font-weight: 600; }
.fab {
  position: fixed; right: 18px; bottom: calc(78px + env(safe-area-inset-bottom)); z-index: 9;
  width: 56px; height: 56px; border-radius: 50%; border: none; background: var(--blue); color: #fff;
  font-size: 30px; line-height: 56px; box-shadow: 0 6px 16px rgba(47,109,246,.4); cursor: pointer;
}
.empty { text-align: center; color: var(--sub); padding: 48px 0; font-size: 15px; }
.empty .big { font-size: 44px; margin-bottom: 10px; }

/* ===== 任务详情 ===== */
.detail-title { font-size: 21px; font-weight: 700; word-break: break-all; }
.detail-desc { margin-top: 10px; white-space: pre-wrap; word-break: break-all; }
.kv { display: flex; gap: 10px; margin-top: 10px; font-size: 14.5px; }
.kv .k { color: var(--sub); flex-shrink: 0; }
.status-actions { display: flex; gap: 10px; margin-top: 16px; }
.status-actions button { flex: 1; padding: 13px; font-size: 16px; font-weight: 600; border-radius: 12px; border: none; cursor: pointer; }
.btn-start { background: var(--blue); color: #fff; }
.btn-done { background: var(--green); color: #fff; }
.btn-reopen { background: #eef0f4; color: var(--text); }

/* ===== 留言/聊天共用 ===== */
.comment { display: flex; gap: 10px; margin-bottom: 14px; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; background: #d8e2f8; color: var(--blue-dark);
  font-size: 15px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.comment-body { flex: 1; min-width: 0; }
.comment-head { font-size: 13px; color: var(--sub); margin-bottom: 3px; }
.comment-text { background: var(--card); border: 1px solid var(--line); border-radius: 4px 14px 14px 14px; padding: 10px 12px; white-space: pre-wrap; word-break: break-all; display: inline-block; max-width: 100%; }

.composer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: rgba(255,255,255,.97); border-top: 1px solid var(--line);
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
}
.composer-inner { max-width: 640px; margin: 0 auto; display: flex; gap: 8px; align-items: flex-end; }
.composer textarea {
  flex: 1; min-height: 42px; max-height: 120px; padding: 10px 12px; border-radius: 12px; font-size: 16px;
}
.composer .attach-btn, .composer .send-btn {
  height: 42px; border: none; border-radius: 12px; font-size: 15px; cursor: pointer; flex-shrink: 0;
}
.composer .attach-btn { width: 42px; background: #eef0f4; font-size: 20px; }
.composer .send-btn { padding: 0 18px; background: var(--blue); color: #fff; font-weight: 600; }
.composer .send-btn:disabled { opacity: .45; }
.pending-files { max-width: 640px; margin: 0 auto 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.pending-files .pf { background: #eef0f4; border-radius: 8px; padding: 4px 10px; font-size: 13px; display: flex; gap: 6px; align-items: center; }
.pending-files .pf b { cursor: pointer; color: var(--sub); }

/* ===== 聊天 ===== */
.conv-item { display: flex; gap: 12px; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 13px 14px; margin-bottom: 10px; cursor: pointer; width: 100%; text-align: left; }
.conv-item .avatar { width: 46px; height: 46px; font-size: 17px; }
.conv-item .avatar.group { background: #dcf1e3; color: var(--green); }
.conv-main { flex: 1; min-width: 0; }
.conv-title { font-weight: 600; font-size: 16px; }
.conv-last { color: var(--sub); font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.conv-side { text-align: right; flex-shrink: 0; }
.conv-time { font-size: 12px; color: var(--sub); }
.conv-unread { display: inline-block; margin-top: 5px; background: var(--red); color: #fff; font-size: 11.5px; min-width: 18px; height: 18px; line-height: 18px; border-radius: 9px; padding: 0 5px; text-align: center; }

.msg-list { padding-bottom: 90px; }
.msg-row { display: flex; gap: 8px; margin-bottom: 12px; align-items: flex-end; }
.msg-row.mine { flex-direction: row-reverse; }
.msg-col { min-width: 0; max-width: 76%; }
.msg-row.mine .msg-col { text-align: right; }
.msg-bubble { display: inline-block; text-align: left; padding: 10px 13px; border-radius: 16px 16px 16px 4px; background: var(--card); border: 1px solid var(--line); white-space: pre-wrap; word-break: break-all; font-size: 16px; }
.msg-row.mine .msg-bubble { background: var(--blue); border-color: var(--blue); color: #fff; border-radius: 16px 16px 4px 16px; }
.msg-sender { font-size: 12px; color: var(--sub); margin: 0 46px 3px; }
.msg-time-divider { text-align: center; color: var(--sub); font-size: 12px; margin: 14px 0 10px; }

/* ===== 附件展示 ===== */
.att-img { max-width: 220px; max-height: 220px; border-radius: 12px; display: block; margin-top: 6px; cursor: pointer; border: 1px solid var(--line); }
.att-file { display: flex; gap: 8px; align-items: center; background: #f2f4f8; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; margin-top: 6px; font-size: 14px; color: var(--text); text-decoration: none; max-width: 240px; }
.att-file .ico { font-size: 20px; }
.att-file .fname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-file .fsize { color: var(--sub); font-size: 12px; flex-shrink: 0; }
.msg-row.mine .att-file { background: rgba(255,255,255,.92); }

/* ===== 我的 ===== */
.me-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.me-head .avatar { width: 60px; height: 60px; font-size: 24px; }
.me-name { font-size: 20px; font-weight: 700; }
.me-role { color: var(--sub); font-size: 14px; }
.list-row { display: flex; align-items: center; gap: 10px; padding: 13px 2px; border-bottom: 1px solid var(--line); }
.list-row:last-child { border-bottom: none; }
.list-row .grow { flex: 1; min-width: 0; }
.section-title { font-size: 15px; font-weight: 700; margin: 22px 4px 10px; }
.help-box { background: #eef4ff; border: 1px solid #d5e3ff; border-radius: var(--radius); padding: 13px 14px; font-size: 14px; color: #2c4a8a; line-height: 1.7; }
.help-box b { display: block; margin-bottom: 2px; }
.tag { font-size: 12px; padding: 1px 8px; border-radius: 999px; background: #eef0f4; color: var(--sub); }
.tag.admin { background: #fdf0e0; color: var(--orange); }
.tag.disabled { background: #fdeceb; color: var(--red); }

/* ===== toast ===== */
#toast {
  position: fixed; left: 50%; bottom: calc(110px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: rgba(28,31,38,.92); color: #fff; padding: 11px 18px; border-radius: 12px; font-size: 15px;
  z-index: 99; max-width: 86vw; text-align: center;
}

/* ===== 图片大图预览 ===== */
#lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.88); z-index: 100; display: flex; align-items: center; justify-content: center; }
#lightbox img { max-width: 96vw; max-height: 92vh; border-radius: 8px; }

/* Mac 宽屏微调 */
@media (min-width: 700px) {
  body { font-size: 15.5px; }
  #tabbar { max-width: 640px; left: 50%; transform: translateX(-50%); border: 1px solid var(--line); border-radius: 18px 18px 0 0; }
}
