/* 移动端 H5 样式 */
:root {
  --primary: #4f6ef7;
  --primary-dark: #3b54d6;
  --bg: #f2f4f8;
  --card: #fff;
  --text: #1f2430;
  --muted: #8a91a3;
  --border: #e6e9f0;
  --green: #2fbf71;
  --orange: #f0a83d;
  --red: #e5534b;
  --radius: 14px;
}

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

html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  max-width: 520px;
  margin: 0 auto;
  position: relative;
}
#app { position: relative; height: 100%; display: flex; flex-direction: column; }
input, textarea, select, button { font-family: inherit; font-size: 16px; color: inherit; }

.hidden { display: none !important; }

/* ---------- 顶栏 ---------- */
#topbar {
  position: sticky; top: 0; z-index: 50; flex-shrink: 0;
  display: flex; justify-content: space-between; align-items: center;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 16px 12px;
  background: var(--primary);
  color: #fff;
  font-size: 18px; font-weight: 600;
}
.icon-btn { background: none; border: none; color: #fff; font-size: 20px; position: relative; padding: 4px 6px; cursor: pointer; }
.topbar-left { display: flex; align-items: center; gap: 2px; }
.back-btn { font-size: 30px; padding: 0 4px 2px; line-height: 1; }
.profile-btn {
  width: 34px; height: 34px; border-radius: 50%;
  background: rgba(255, 255, 255, .16);
  color: #fff;
  font-size: 19px; display: inline-flex; align-items: center; justify-content: center;
  padding: 0;
}
body.subpage #bottomNav { display: none; }
body.subpage #view { padding-bottom: 12px; }
@keyframes pagein { from { transform: translateX(100%); } to { transform: none; } }
body.subpage #view { animation: pagein .22s ease; }
.badge {
  position: absolute; top: -4px; right: -4px;
  background: var(--red); color: #fff;
  border-radius: 10px; font-size: 11px; padding: 1px 5px; min-width: 16px; text-align: center;
}

/* ---------- 底部导航 ---------- */
#bottomNav {
  position: fixed; bottom: 0; left: 0; right: 0;
  margin: 0 auto; max-width: 520px;
  display: flex; background: var(--card);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  z-index: 50;
}
#bottomNav button {
  flex: 1; border: none; background: none;
  padding: 8px 0; font-size: 12px; color: var(--muted); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
}
#bottomNav button span { font-size: 20px; line-height: 1; padding: 3px 16px; border-radius: 12px; transition: background .2s, color .2s; }
#bottomNav button.active { color: var(--primary); font-weight: 600; }
#bottomNav button.active span { background: rgba(79, 110, 247, .14); }

#view {
  flex: 1; min-height: 0;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 12px 12px calc(env(safe-area-inset-bottom, 0px) + 76px);
}

/* ---------- 过滤器 ---------- */
.filters { margin-bottom: 10px; }
.seg { display: flex; background: var(--card); border-radius: 10px; padding: 3px; border: 1px solid var(--border); }
.seg button {
  flex: 1; border: none; background: none; padding: 7px 0;
  border-radius: 8px; font-size: 14px; color: var(--muted); cursor: pointer;
}
.seg button.active { background: var(--primary); color: #fff; font-weight: 500; }
.chips { display: flex; gap: 8px; margin-top: 8px; overflow-x: auto; padding-bottom: 2px; }
.chip {
  flex-shrink: 0; border: 1px solid var(--border); background: var(--card);
  border-radius: 16px; padding: 5px 14px; font-size: 13px; color: var(--muted); cursor: pointer;
}
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.chip:disabled { opacity: .35; cursor: not-allowed; }
.progress-btns { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.progress-btns .chip { flex: 1; min-width: 0; text-align: center; padding: 8px 0; font-size: 14px; }

/* ---------- 列表 ---------- */
.list { display: flex; flex-direction: column; gap: 10px; }
.card {
  background: var(--card); border-radius: var(--radius);
  padding: 14px; box-shadow: 0 1px 3px rgba(20, 30, 60, .06);
}
.task { cursor: pointer; }
.task-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.task-title { font-size: 16px; font-weight: 600; line-height: 1.4; }
.task-meta { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 12px; color: var(--muted); margin-top: 8px; align-items: center; }
.progress { height: 6px; background: #eef0f6; border-radius: 3px; margin-top: 10px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--primary); border-radius: 3px; transition: width .3s; }
.deadline { color: var(--red); }

.badge { position: static; display: inline-block; padding: 2px 8px; border-radius: 8px; font-size: 12px; font-weight: 500; }
.status-todo { background: #eef0f6; color: #666; }
.status-in_progress { background: #e3ebff; color: var(--primary); }
.status-done { background: #ddf5e8; color: var(--green); }
.status-cancelled { background: #fdeceb; color: var(--red); }
.prio { font-size: 11px; padding: 1px 7px; border-radius: 8px; }
.prio-low { background: #eef0f6; color: #666; }
.prio-med { background: #fff3e0; color: var(--orange); }
.prio-high { background: #fdeceb; color: var(--red); }

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

/* ---------- 悬浮按钮 ---------- */
.fab {
  position: fixed; right: 20px; bottom: 84px; z-index: 40;
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--primary); color: #fff; border: none;
  font-size: 26px; box-shadow: 0 4px 12px rgba(79, 110, 247, .4); cursor: pointer;
}

/* ---------- 表单 ---------- */
.page { display: flex; flex-direction: column; gap: 12px; }
.page h2 { font-size: 18px; }
input[type="text"], input[type="password"], input[type="date"], input[type="datetime-local"], textarea, select {
  width: 100%; padding: 12px; border: 1px solid var(--border);
  border-radius: 10px; background: var(--card); font-size: 16px;
}
textarea { min-height: 80px; resize: vertical; }
label { font-size: 14px; color: var(--muted); }
.primary-btn {
  width: 100%; padding: 13px; border: none; border-radius: 10px;
  background: var(--primary); color: #fff; font-size: 16px; font-weight: 600; cursor: pointer;
}
.danger-btn {
  padding: 12px; border: 1px solid var(--red); border-radius: 10px;
  background: none; color: var(--red); font-size: 15px; cursor: pointer; width: 100%;
}
.link-btn { background: none; border: none; color: var(--primary); font-size: 14px; cursor: pointer; padding: 4px 0; }
.row { display: flex; gap: 10px; }
.muted { color: var(--muted); font-size: 12px; }
.error { color: var(--red); font-size: 14px; text-align: center; min-height: 18px; }

.voice-row { display: flex; gap: 8px; align-items: stretch; }
.big-input { display: block; width: 100%; font-size: 18px; padding: 15px 16px; font-weight: 500; height: 56px; }
.voice-row .mic-btn { width: 56px; height: 56px; }
.mic-btn {
  flex-shrink: 0; width: 48px; height: 48px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--card); font-size: 20px; cursor: pointer;
}
.mic-btn.listening { background: var(--red); color: #fff; border-color: var(--red); animation: pulse 1s infinite; }
.mic-btn.loading { background: var(--orange); color: #fff; border-color: var(--orange); }
.mic-line {
  width: 100%; margin-top: 8px; padding: 10px;
  border: 1px dashed var(--border); border-radius: 10px;
  background: var(--card); color: var(--muted); font-size: 14px; cursor: pointer;
}
.mic-line.listening { background: var(--red); color: #fff; border-color: var(--red); animation: pulse 1s infinite; }
.mic-line.loading { background: var(--orange); color: #fff; border-color: var(--orange); }
@keyframes pulse { 50% { transform: scale(1.1); } }

/* ---------- 任务详情 ---------- */
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.detail-meta { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 12px; color: var(--muted); }
.detail-content { background: var(--card); border-radius: var(--radius); padding: 14px; font-size: 15px; line-height: 1.6; white-space: pre-wrap; }
.block { background: var(--card); border-radius: var(--radius); padding: 14px; }
.block-title { font-size: 14px; color: var(--muted); margin-bottom: 10px; }
.block-title b { color: var(--primary); font-size: 18px; }
input[type="range"] { width: 100%; accent-color: var(--primary); margin: 6px 0; }
.status-btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.thumb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 8px; margin-bottom: 10px; }
.thumb-wrap { position: relative; }
.thumb { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; cursor: pointer; }
.thumb-remove {
  position: absolute; top: -6px; right: -6px;
  width: 22px; height: 22px; border-radius: 50%;
  background: rgba(20, 25, 40, .75); color: #fff; border: none;
  font-size: 14px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.thumb-add {
  aspect-ratio: 1; border: 1.5px dashed var(--border); border-radius: 8px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--muted); font-size: 22px; cursor: pointer; gap: 2px; background: var(--card);
}
.thumb-add span { font-size: 11px; }
.file-input.hidden { display: none; }
.tl-item { border-left: 2px solid var(--border); padding-left: 10px; margin: 8px 0; }
.tl-head { font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.tl-body { font-size: 14px; line-height: 1.5; }

/* ---------- 日志 ---------- */
#logList { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.log-head { font-size: 15px; font-weight: 600; }
.log-summary { font-size: 13px; margin: 6px 0; }
.log-details { padding-left: 18px; font-size: 13px; color: #4a5164; }
.log-details li { margin: 4px 0; }

/* ---------- 成员 ---------- */
.member { display: flex; align-items: center; gap: 12px; }
.member-avatar {
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 18px;
}

/* ---------- 通知面板 ---------- */
#notifPanel {
  position: fixed; top: calc(env(safe-area-inset-top, 0px) + 54px); right: 10px;
  width: min(340px, 92vw); max-height: 60vh; overflow-y: auto;
  background: var(--card); border-radius: var(--radius);
  box-shadow: 0 8px 30px rgba(0, 0, 0, .15); z-index: 60;
}
.notif-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--border); font-weight: 600; }
.notif-item { padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: 14px; cursor: pointer; }
.notif-item.unread { background: #f0f4ff; }
.notif-item .muted { margin-top: 3px; }

/* ---------- 登录 ---------- */
#login {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.login-box { width: 100%; max-width: 380px; background: var(--card); border-radius: 16px; padding: 28px 22px; box-shadow: 0 4px 20px rgba(20, 30, 60, .08); }
.login-box h1 { text-align: center; font-size: 22px; margin-bottom: 20px; }
.login-box form { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
.login-box input {
  width: 100%; height: 46px; padding: 0 14px;
  border: 1px solid var(--border); border-radius: 10px;
  font-size: 16px; background: #fafbfd; color: var(--text); outline: none;
  box-sizing: border-box;
}
.login-box input:focus { border-color: var(--primary); background: #fff; }
.login-box #loginSeg button { height: 42px; padding: 0; font-size: 15px; }
.login-box .primary-btn { height: 46px; padding: 0; }

/* ---------- 长按操作面板 ---------- */
#actionSheet {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(10, 15, 30, .45);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  width: 100%; max-width: 520px;
  background: var(--card); border-radius: 16px 16px 0 0;
  padding: 6px 12px calc(env(safe-area-inset-bottom, 0px) + 10px);
}
.sheet-title { text-align: center; font-size: 14px; color: var(--muted); padding: 10px 0 4px; word-break: break-all; }
.sheet-btn {
  display: block; width: 100%; padding: 13px; margin-top: 8px;
  border: none; border-radius: 10px; background: var(--bg);
  font-size: 16px; color: var(--text); cursor: pointer;
}
.sheet-btn.highlight { background: var(--green); color: #fff; font-weight: 600; }
.sheet-btn.danger { background: var(--red); color: #fff; }
.sheet-cancel {
  display: block; width: 100%; padding: 13px; margin-top: 8px;
  border: none; border-radius: 10px; background: var(--border);
  font-size: 16px; color: var(--text); cursor: pointer;
}

/* ---------- 个人中心 ---------- */
.profile-card { display: flex; align-items: center; gap: 14px; background: var(--card); border-radius: var(--radius); padding: 16px; box-shadow: 0 1px 3px rgba(20, 30, 60, .06); }
.profile-avatar { width: 56px; height: 56px; font-size: 24px; }
.profile-name { font-size: 18px; font-weight: 600; }
.logout-btn {
  width: 100%; padding: 13px; margin-top: 4px;
  background: var(--red); color: #fff; border: none; border-radius: 12px;
  font-size: 16px; font-weight: 600; cursor: pointer;
}
.logout-btn:active { filter: brightness(.92); }

/* ---------- 统计看板 ---------- */
.stat-cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 4px 0 12px; }
.stat-card { background: var(--card); border-radius: var(--radius); padding: 14px; text-align: center; box-shadow: 0 1px 3px rgba(20, 30, 60, .06); }
.stat-card b { display: block; font-size: 26px; color: var(--text); }
.stat-card.green b { color: var(--green); }
.stat-card.blue b { color: var(--primary); }
.stat-card.orange b { color: var(--orange); }
.stat-card span { font-size: 12px; color: var(--muted); }
.stat-row { display: flex; align-items: center; gap: 10px; margin: 8px 0; font-size: 13px; }
.stat-row > span { width: 52px; color: var(--muted); flex-shrink: 0; }
.stat-row > b { width: 46px; text-align: right; font-size: 13px; flex-shrink: 0; }
.bar { flex: 1; height: 8px; border-radius: 5px; background: var(--bg); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 5px; transition: width .3s; }
.bar-fill.todo { background: var(--orange); }
.bar-fill.in_progress { background: var(--primary); }
.bar-fill.done { background: var(--green); }
.bar-fill.cancelled { background: #c3c8d4; }
.bar-fill.prio-high { background: var(--red); }
.bar-fill.prio-medium { background: var(--orange); }
.bar-fill.prio-low { background: var(--green); }

/* ---------- 截止时间快捷键 ---------- */
.deadline-shortcuts { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }

/* ---------- 指派列表 ---------- */
.assign-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px 12px; margin-top: 6px; }
.assign-list .check-row { margin: 0; }
.assign-list .chip { flex-shrink: 1; }

/* ---------- 表单 checkbox ---------- */
.check-row { display: flex; align-items: center; gap: 8px; margin: 10px 0; font-size: 15px; cursor: pointer; }
.check-row input { width: 20px; height: 20px; accent-color: var(--primary); }

/* ---------- 完成报告 ---------- */
.report-head h2 { margin-bottom: 6px; }

/* ---------- 完成任务 ---------- */
.complete-btn {
  width: 100%; padding: 14px; margin: 6px 0 10px;
  background: var(--green); color: #fff; border: none; border-radius: 12px;
  font-size: 17px; font-weight: 600; cursor: pointer;
}
.complete-btn:active { filter: brightness(.92); }
.complete-done {
  width: 100%; padding: 12px; margin: 6px 0 10px; text-align: center;
  background: rgba(47, 191, 113, .12); color: var(--green);
  border-radius: 12px; font-size: 15px; font-weight: 600;
}
.reopen-btn {
  width: 100%; padding: 13px; margin: 0 0 10px;
  background: var(--primary); color: #fff; border: none; border-radius: 12px;
  font-size: 16px; font-weight: 600; cursor: pointer;
}
.reopen-btn:active { filter: brightness(.92); }

/* ---------- 灯箱 ---------- */
#lightbox {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .92); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 10px;
}
#lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; }

/* ---------- Toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%);
  background: rgba(20, 25, 40, .9); color: #fff; padding: 10px 18px;
  border-radius: 20px; font-size: 14px; z-index: 200; max-width: 88vw; text-align: center;
}
