/* 每日任务 P1 · 单一 CSS · 浅色主题
   设计约束（沿用阿锋偏好）：工具栏简洁、控件不要太长、按钮可并排 */

:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --line: #e5e7eb;
  --line-soft: #f0f1f3;
  --text: #1f2328;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-soft: #eff6ff;
  --urgent: #dc2626;
  --urgent-bg: #fef2f2;
  --normal: #d97706;
  --ok: #16a34a;
  --ok-bg: #f0fdf4;
  --blocked: #b45309;
  --blocked-bg: #fffbeb;
  --radius: 10px;
}

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

/* 关键：HTML hidden 属性会被任何显式 display 覆盖，必须强制回压，
   否则"任务详情"抽屉会在未打开时就显示出来（2026-10-23 阿锋截图抓到） */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

/* ── 顶栏 ── */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 14px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { font-weight: 600; font-size: 16px; white-space: nowrap; }
.brand-ver { font-weight: 400; font-size: 11px; color: var(--muted); margin-left: 6px; }
.topbar-right { display: flex; align-items: center; gap: 8px; flex: 1; justify-content: flex-end; }

.me-box, .search {
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 0 8px;
  font-size: 14px;
}
.me-box { display: inline-flex; align-items: center; max-width: 140px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search { flex: 1; max-width: 220px; min-width: 80px; }

/* ── 按钮：并列不换行 ── */
.btn {
  height: 32px; padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff; color: var(--text);
  font-size: 14px; cursor: pointer; white-space: nowrap;
}
.btn:active { opacity: .75; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-soft { background: var(--primary-soft); border-color: #dbeafe; color: var(--primary); }
.btn-wide { width: 100%; height: 38px; font-size: 15px; }
.btn-danger { color: var(--urgent); border-color: #fecaca; background: var(--urgent-bg); }

/* ── 统计条 ── */
.statbar {
  display: flex; flex-wrap: wrap; gap: 8px;
  padding: 10px 14px 0;
}
.stat {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 8px; padding: 6px 10px; font-size: 13px; color: var(--muted);
  font-family: inherit; cursor: pointer;
}
.stat:hover { border-color: var(--primary); }
.stat b { color: var(--text); font-size: 15px; margin-left: 4px; }
.stat.is-active { border-color: var(--primary); background: var(--primary-bg, #e6f1fb); color: var(--primary); }
.stat.is-active b { color: var(--primary); }
.stat.is-alert { border-color: #fecaca; background: var(--urgent-bg); color: var(--urgent); }
.stat.is-alert b { color: var(--urgent); }

/* ── 列表 ── */
.list { padding: 12px 14px 90px; }
.group-title {
  display: flex; align-items: center; gap: 6px;
  margin: 14px 0 8px; font-size: 13px; color: var(--muted); font-weight: 600;
}
.group-title:first-child { margin-top: 4px; }

.item {
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 11px 12px; margin-bottom: 8px; cursor: pointer;
}
.item:active { background: var(--line-soft); }
.item.is-urgent { border-left: 3px solid var(--urgent); }
.item.is-blocked { border-left: 3px solid var(--blocked); background: var(--blocked-bg); }
/* 待确认整行染绿（2026-10-26 阿锋：待确认混在列表里不显眼）。
   与「已完成-待确认」徽章同一个绿色系，行和徽章互相对得上，不出现两套口径。
   状态配色全貌：红边=卡住，绿边=待确认，黄边=紧急，灰底=已收尾 */
.item.is-wait { border-left: 3px solid var(--ok); background: var(--ok-bg); }
.item.is-done {
  opacity: 1;
  background: #f3f4f6;              /* 灰底：一眼分清这是收尾的，不是活任务 */
  border-color: #e5e7eb;
}
.item.is-done .item-title { color: var(--muted); text-decoration: line-through; text-decoration-color: #cbd5e1; }
.item.is-done .item-meta { opacity: .7; }

/* 列表缩略图（2026-10-25 阿锋：任务带了图，列表上一眼看不到就得点进去翻）。
   点击放大复用详情面板的 .viewer，这里只负责"看得见 + 知道有几张" */
.item-thumb-wrap { position: relative; flex: none; }
.item-thumb {
  width: 56px; height: 56px; object-fit: cover;
  border-radius: 8px; border: 1px solid var(--line);
  display: block; background: #f6f6f6; cursor: zoom-in;
}
.thumb-n {
  position: absolute; right: -5px; bottom: -5px;
  background: #444441; color: #fff; font-size: 11px; line-height: 1;
  border-radius: 10px; padding: 3px 6px;
}

/* 悬停预览大图（2026-10-25 阿锋：不用点，鼠标放上去就看大图，移走就收）。
   pointer-events:none 是关键 —— 预览不接鼠标，鼠标不会"移到预览上"造成闪烁。
   点击放大依然保留：手机没有悬停，触屏只能靠点。 */
.hover-preview {
  position: fixed; z-index: 80; display: none;
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: 6px; pointer-events: none;
}
.hover-preview.is-on { display: block; }
.hover-preview img {
  display: block; width: 100%; max-height: calc(100vh - 52px); object-fit: contain;
  border-radius: 6px; background: #f6f6f6;
}

/* 日期下拉：长得和统计徽章一致，但能装下任意多的历史日期 */
.stat-select {
  appearance: none; -webkit-appearance: none;
  padding-right: 22px;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23888780' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center;
}

/* 分组框 v2 见下方 .grp-box（旧的 done-divider 分隔线已被分组框取代，2026-10-28 清理） */

/* 分组框 v2（2026-10-28 阿锋反馈"装了框还是不明显"）：
   v1 的框底色跟页面背景几乎同色、组头是行小灰字 —— 等于没框。
   v2：组头升级为**通栏彩色色带**（每组不同浅色底 + 深色组名 + 深底计数徽章），
   框边加深、组间距拉开。行卡颜色依然一个不动 —— 颜色预算仍归状态
   （红=紧急 / 绿=待确认 / 黄=卡住 / 灰=已收尾），彩色只出现在组头带上。 */
.grp-box {
  background: var(--line-soft);
  border: 1px solid #dcdfe4;
  border-radius: 14px;
  padding: 0 9px 9px;
  margin-bottom: 16px;
  overflow: hidden;
}
.grp-head {
  display: flex; align-items: center; gap: 8px;
  margin: 0 -9px 9px;
  padding: 8px 12px;
  font-size: 13px; font-weight: 500;
}
.grp-head i { flex: none; width: 4px; height: 13px; border-radius: 2px; background: currentColor; }
.grp-head b {
  font-weight: 400; font-size: 12px; line-height: 17px;
  color: #fff; border-radius: 10px; padding: 0 7px;
}
.grp-assign .grp-head { background: #eeedfe; color: #3c3489; }
.grp-assign .grp-head b { background: #534ab7; }
.grp-mine .grp-head { background: #e6f1fb; color: #0c447c; }
.grp-mine .grp-head b { background: #185fa5; }
.grp-other .grp-head { background: #f1efe8; color: #444441; }
.grp-other .grp-head b { background: #5f5e5a; }
.grp-done .grp-head { background: #eceef1; color: #5f6368; }
.grp-done .grp-head b { background: #888780; }
.grp-filter .grp-head { background: #e6f1fb; color: #0c447c; }
.grp-filter .grp-head b { background: #185fa5; }
.grp-box .item:last-child { margin-bottom: 0; }

/* 占位提示一律淡灰（阿锋 2026-10-30：默认色太深，看着像已经写了字）。
   透明度压到 45%，"微微显示"即可 */
::placeholder { color: #9a9a97; opacity: 1; }
input::placeholder, textarea::placeholder { color: #a5a5a2; opacity: 0.55; }

.item-main { flex: 1; min-width: 0; }
.item-title { font-size: 15px; font-weight: 500; word-break: break-word; }
.item-meta {
  display: flex; flex-wrap: wrap; gap: 6px 10px;
  margin-top: 5px; font-size: 12px; color: var(--muted);
}
.item-ref {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: var(--line-soft); padding: 1px 5px; border-radius: 4px;
}
/* 行首任务编号（阿锋 2026-10-28：详情里有「任务 #71」，列表上也想直接看到）。
   淡色小字不抢标题；点击复制（与单号同一委托），不打开详情 */
.item-no {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 15px; font-weight: 600; color: var(--text);
  margin-right: 7px; cursor: copy; user-select: none;
}

/* 主页直接显示同事最后一条回复（2026-10-26 阿锋：待确认/卡住的任务，
   要在列表上就看到对方说了什么，不用点进去）。只给这两种状态显示 ——
   它们才是"等我行动"的，其余状态不加，免得列表变吵。
   贴右边、超长截断；点它 = 点行 = 开详情，不额外造按钮。 */
.item-reply {
  flex: 0 1 auto; min-width: 0; max-width: 45%;
  display: flex; align-items: baseline; gap: 6px;
  padding: 5px 9px; margin-left: 2px;
  background: var(--line-soft); border-radius: 8px;
  font-size: 13px; line-height: 1.5; color: var(--text);
}
/* 有回复气泡的行：标题区不再吃满整行 → 气泡紧跟标题，右边自然留白
   （阿锋 2026-10-26：气泡别顶到最右边，往前挪一点，跟标题保持一段距离就行）。
   只作用于有气泡的行，没气泡的行标题照旧撑满，不受影响。 */
.item.has-reply .item-main { flex: 0 1 auto; max-width: 56%; }
.item.has-reply .item-reply { margin-left: 12px; }
.item-reply svg.reply-arrow { flex: none; width: 20px; height: 20px; margin-top: 2px; }
.item-reply .reply-who { flex: none; color: var(--muted); }
.item-reply .reply-text {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.badge {
  display: inline-block; padding: 1px 7px; border-radius: 20px;
  font-size: 12px; line-height: 18px; white-space: nowrap;
}
.badge-urgent { background: var(--urgent-bg); color: var(--urgent); }
.badge-normal { background: #fffbeb; color: var(--normal); }
.badge-someday { background: var(--line-soft); color: var(--muted); }
.badge-pending { background: var(--line-soft); color: var(--muted); }
.badge-doing { background: var(--primary-soft); color: var(--primary); }
.badge-done_wait { background: var(--ok-bg); color: var(--ok); }
.badge-blocked { background: var(--blocked-bg); color: var(--blocked); }
.badge-closed { background: var(--ok-bg); color: var(--ok); }
.badge-cancelled { background: var(--line-soft); color: var(--muted); }

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

/* ── 面板 ── */
.sheet-mask {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .35); z-index: 40;
}
.sheet {
  position: fixed; z-index: 50;
  background: var(--card);
  display: flex; flex-direction: column;
}
/* 新建：手机上从底部升起；电脑上居中（详情面板同样居中，不搞右侧抽屉 —— 阿锋：不符合平时习惯） */
.sheet {
  left: 0; right: 0; bottom: 0;
  max-height: 88vh;
  border-radius: 14px 14px 0 0;
}

@media (min-width: 720px) {
  .sheet {
    top: 50%; left: 50%; right: auto; bottom: auto;
    transform: translate(-50%, -50%);
    width: 560px; max-height: 86vh;
    border-radius: 14px;
  }
}

.sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-bottom: 1px solid var(--line);
  font-weight: 600;
}
.sheet-body { padding: 14px; overflow: auto; flex: 1; }
.sheet-foot {
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  display: flex; gap: 8px;
}
/* 详情面板回执区：纵向堆叠（大输入框→图片→发送→状态按钮），宽度拉满 */
#detailFoot { flex-direction: column; align-items: stretch; }
#detailFoot .up-row { align-items: center; }

/* ── 表单 ── */
.field { margin-top: 10px; }
.field:first-child { margin-top: 0; }
/* 电脑端：「指派给」和「优先级」并排一行；手机窄屏还原上下排 */
.field-row { display: flex; gap: 20px; margin-top: 10px; }
.field-row .field { flex: 1; margin-top: 0; }
.field-row:first-child { margin-top: 0; }
@media (max-width: 720px) {
  .field-row { flex-direction: column; gap: 0; margin-top: 8px; }
}
.field label {
  display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px;
}
.hint { color: var(--muted); font-weight: 400; margin-left: 6px; font-size: 12px; }

.f-title {
  width: 100%; padding: 8px 12px;
  border: 1px solid var(--line); border-radius: 8px;
  font-size: 16px; background: #fff; color: var(--text);
  font-family: inherit; line-height: 1.45;
  resize: none;               /* 内容框固定两行，不出现拖拽角 */
  display: block;
}
.f-ref, .f-detail {
  width: 100%; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 8px;
  font-size: 14px; background: #fff; color: var(--text);
  font-family: inherit;
}
.f-detail { resize: vertical; }

/* 登录面板输入框 —— font-size 必须 ≥16px：iOS 上更小的输入框被聚焦时会把整页放大，
   而 standalone（加到主屏幕）模式下没有缩小整页的手势，页面就一直保持放大状态 */
#loginPass { font-size: 16px; }

/* 选择片：点一下即选中，状态一眼可见 */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  height: 30px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: 20px;
  background: #fff; color: var(--text); font-size: 13px; cursor: pointer;
}
.chip.is-on { border-width: 2px; font-weight: 600; }
.chip-urgent.is-on { border-color: var(--urgent); background: var(--urgent-bg); color: var(--urgent); }
.chip-normal.is-on { border-color: var(--normal); background: #fffbeb; color: var(--normal); }
.chip-someday.is-on { border-color: #9ca3af; background: var(--line-soft); color: var(--text); }
.chip-user.is-on { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }

/* ── 图片上传 ── */
.up-row { display: flex; align-items: center; gap: 8px; }
.thumbs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.thumb { position: relative; width: 62px; height: 62px; }
.thumb img { width: 100%; height: 100%; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); cursor: zoom-in; }
.thumb button {
  position: absolute; top: -6px; right: -6px;
  width: 20px; height: 20px; line-height: 18px; text-align: center;
  border-radius: 50%; border: 1px solid var(--line);
  background: #fff; color: var(--urgent); cursor: pointer; padding: 0; font-size: 14px;
}

/* ── 时间线 ── */
.tl { position: relative; padding-left: 18px; }
.tl::before {
  content: ''; position: absolute; left: 4px; top: 6px; bottom: 6px;
  width: 2px; background: var(--line);
}
.tl-item { position: relative; margin-bottom: 14px; }
.tl-dot {
  position: absolute; left: -18px; top: 5px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--muted); border: 2px solid #fff;
}
.tl-dot.is-create { background: var(--muted); }
.tl-dot.is-start { background: var(--primary); }
.tl-dot.is-done { background: var(--ok); }
.tl-dot.is-blocked { background: var(--blocked); }
.tl-dot.is-close { background: var(--ok); }
.tl-dot.is-comment { background: #9ca3af; }
.tl-dot.is-reassign { background: var(--primary); }
.tl-dot.is-cancel { background: #9ca3af; }

.tl-who { font-size: 13px; color: var(--muted); }
.tl-who b { color: var(--text); font-weight: 600; }
.tl-when { font-size: 12px; color: var(--muted); margin-left: 6px; }
.tl-text { font-size: 14px; margin-top: 2px; white-space: pre-wrap; word-break: break-word; }
.tl-imgs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.tl-imgs img {
  width: 84px; height: 84px; object-fit: cover;
  border-radius: 6px; border: 1px solid var(--line); cursor: zoom-in;
}

/* ── 详情头部 ── */
.d-head { margin-bottom: 16px; }
.d-title { font-size: 17px; font-weight: 600; word-break: break-word; }
.d-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.d-line { font-size: 13px; color: var(--muted); margin-top: 6px; }

/* ── 新任务提醒条 ──
   轮询发现"指派给我的新任务"时从顶栏下方滑出，15 秒自动收起。
   fixed + 居中：滚到列表底部也看得见。top 由 JS 按真实顶栏高度设置，避免压住身份下拉。 */
.notify-bar {
  position: fixed;
  left: 12px; right: 12px; top: 60px;      /* JS 会按实际顶栏高度覆写 top */
  max-width: 720px; margin: 0 auto;
  z-index: 28;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: #fff7ed;
  border: 1px solid #fed7aa;
  box-shadow: 0 6px 18px rgba(180, 83, 9, .14);
  font-size: 14px; color: #7c2d12;
  transform: translateY(-10px); opacity: 0;
  transition: transform .22s ease, opacity .22s ease;
}
.notify-bar.is-in { transform: translateY(0); opacity: 1; }
.nb-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nb-btn {
  flex: none; cursor: pointer;
  border: 1px solid #fdba74; background: #fff; color: #9a3412;
  border-radius: 8px; padding: 4px 10px; font-size: 13px;
}
.nb-go { background: #ea580c; border-color: #ea580c; color: #fff; }
.nb-x { border-color: transparent; background: transparent; font-size: 15px; padding: 4px 6px; }

/* ── 下拉刷新 ── */
.ptr {
  height: 0; overflow: hidden; text-align: center;
  font-size: 12px; color: var(--muted);
  background: var(--bg);
  transition: height .18s ease;
}
.ptr.is-loading { height: 40px; line-height: 40px; }

/* ── 悬浮新建按钮 ── */
.fab {
  display: none;                 /* 电脑端顶栏放得下，不需要 */
  position: fixed; right: 16px;
  bottom: calc(20px + env(safe-area-inset-bottom));
  width: 58px; height: 58px; border-radius: 50%;
  background: var(--primary); color: #fff;
  font-size: 30px; line-height: 1; border: none;
  box-shadow: 0 4px 16px rgba(37, 99, 235, .45);
  cursor: pointer; z-index: 30;
}
.fab:active { transform: scale(.94); }

/* 顶栏「＋ 新建」：电脑端的主要入口（悬浮球只给手机） */
.btn-new { background: var(--primary); color: #fff; border: none; }
.btn-new:hover { filter: brightness(1.08); }

/* 手机端：加大点按区域（手指点击 vs 鼠标） */
@media (max-width: 720px) {
  .fab { display: block; }
  .btn-new { display: none; }   /* 窄屏顶栏放不下 → 新建走右下角悬浮球 */

  /* 顶栏四个控件在窄屏一行放不下 → 折成两行 */
  .topbar { flex-wrap: wrap; row-gap: 8px; }
  .topbar-right { width: 100%; flex: none; }
  .brand { font-size: 15px; }

  .btn { height: 38px; padding: 0 16px; font-size: 15px; }
  .up-row .btn { height: 42px; padding: 0 20px; font-size: 15px; }
  .f-title { font-size: 17px; }
  .f-ref, .f-detail { font-size: 16px; }   /* ≥16px 可避免 iOS 聚焦时自动放大页面 */
  .chip { height: 32px; padding: 0 12px; font-size: 13px; }
  .me-box, .search { height: 36px; }
  .search { max-width: none; min-width: 60px; }

  /* 窄屏放不下"标题 + 回复"两栏 → 回复整行换到下面，且不再截断
     （手机上宁可多占一行，也要把同事说的话看全） */
  .item { flex-wrap: wrap; }
  .item-reply { flex: 1 0 100%; max-width: 100%; margin: 7px 0 0; }
  .item-reply .reply-text { white-space: normal; overflow: visible; }
  /* 窄屏气泡整行换到下面了，标题区就放它撑满 */
  .item.has-reply .item-main { max-width: 100%; }
  /* 紧凑：指派给/优先级两块少占屏幕 */
  .field { margin-top: 8px; }
  .field label { margin-bottom: 3px; }
}

/* 电脑端悬浮钮不出现（顶栏已有「+ 新建」） */

/* 自动更新后的短暂提示（不挡操作，3 秒自己消失） */
.upd-toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  top: calc(12px + env(safe-area-inset-top));
  z-index: 60; padding: 8px 16px; border-radius: 999px;
  background: var(--primary); color: #fff; font-size: 13px;
  box-shadow: 0 4px 14px rgba(37, 99, 235, .35);
  opacity: 1; transition: opacity .5s ease; pointer-events: none;
}
.upd-toast.out { opacity: 0; }

/* ── 成员管理 ── */
.m-row {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 0;
}
.m-row.is-off .m-name { color: var(--muted); text-decoration: line-through; }
.m-row .m-name { flex: 1; }
.m-toggle {
  display: flex; align-items: center; gap: 4px;
  font-size: 13px; color: var(--text); cursor: pointer; white-space: nowrap;
}
.m-toggle input { width: 16px; height: 16px; accent-color: var(--primary); }

/* ── 图片查看器 ── */
.viewer {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(0, 0, 0, .9);
  display: flex; align-items: center; justify-content: center;
}
.viewer img { max-width: 100%; max-height: 100%; object-fit: contain; }
