/* Workbench — one stylesheet, no build step, no framework.
   Layout: [sidebar | main | detail-drawer]. Theme: dark, calm, high-contrast labels. */

:root {
  --bg: #14161a;
  --bg-soft: #1b1e24;
  --bg-card: #21252c;
  --line: #2c313a;
  --text: #e7ebf0;
  --muted: #939cab;
  --accent: #5b8def;
  --accent-soft: rgba(91, 141, 239, 0.16);
  --danger: #ef5b6b;
  --ok: #35c07f;
  --radius: 10px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  --vh: 100vh;
  color-scheme: dark;
  accent-color: var(--accent);
  scrollbar-color: #3a404b transparent;
}
@supports (height: 100dvh) {
  :root { --vh: 100dvh; }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: clip;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.tiny { font-size: 11px; }
.spacer { flex: 1; }

button { font: inherit; cursor: pointer; touch-action: manipulation; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
input, select, textarea {
  font: inherit;
  color: var(--text);
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 9px;
  width: 100%;
  transition: border-color 0.12s ease;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
input[type="range"] { padding: 0; border: none; background: none; }
textarea { resize: vertical; }
button.primary {
  background: var(--accent);
  border: 1px solid var(--accent);
  color: #fff;
  border-radius: 8px;
  padding: 7px 14px;
  font-weight: 500;
}
button.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 6px 10px;
}
button.ghost.icon { padding: 4px 11px; font-size: 18px; line-height: 1.2; }
button.ghost.danger { color: var(--danger); border-color: rgba(239, 91, 107, 0.4); }
button:active { transform: translateY(1px); }
@media (hover: hover) {
  button.primary:hover { filter: brightness(1.08); }
  button.ghost:hover { background: var(--bg-card); }
}
button.link {
  background: none;
  border: none;
  color: var(--accent);
  padding: 4px 0;
  font-size: 12px;
}

/* ---------------- login ---------------- */
.login { display: grid; place-items: center; min-height: var(--vh); padding: 16px; }
.login-card {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 28px;
  width: min(340px, 90vw);
  box-shadow: var(--shadow);
  display: grid;
  gap: 10px;
}
.login-card h1 { margin: 0; font-size: 20px; }
.login-card .error { color: var(--danger); min-height: 18px; margin: 0; font-size: 12px; }

/* ---------------- layout ---------------- */
.layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: var(--vh); }
.layout:has(.detail.open) { grid-template-columns: 240px minmax(0, 1fr) minmax(380px, 30vw); }

.sidebar {
  border-right: 1px solid var(--line);
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--bg-soft);
  position: sticky;
  top: 0;
  height: var(--vh);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}
.brand { font-size: 16px; font-weight: 600; margin-bottom: 6px; display: flex; align-items: center; gap: 8px; }
.menu-btn, .menu-close { display: none; background: none; border: 1px solid var(--line); color: var(--text); border-radius: 8px; padding: 6px 10px; }
.menu-close { margin-left: auto; font-size: 12px; padding: 2px 8px; }
.chip-focus { color: #f4c542; border-color: rgba(244, 197, 66, 0.5); }
.chip-private { color: #ff96a0; border-color: rgba(239, 91, 107, 0.5); }
.chip-stale { color: #d1a45b; border-color: rgba(209, 164, 91, 0.5); }
.chip-thin { color: #c58de0; border-color: rgba(197, 141, 224, 0.5); }
.chip-handoff { color: #6fc7d8; border-color: rgba(111, 199, 216, 0.5); }
.chip-unread { color: #7fb3ff; border-color: rgba(127, 179, 255, 0.55); }
.stat.unread .stat-value { color: #7fb3ff; }
.stat.done .stat-value { color: #8bd17c; }
/* 可复制的 ID 标签（PN-42 / PR-17） */
.key-chip { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; line-height: 1.5;
  padding: 0 5px; border: 1px solid var(--line); border-radius: 5px; background: transparent; color: var(--muted);
  cursor: pointer; letter-spacing: 0.02em;
  /* 手机剪贴板 API 常不可用：让整个 ID 能被长按一次性选中 */
  -webkit-user-select: all; user-select: all; -webkit-touch-callout: default; }
.key-chip:hover { border-color: var(--accent); color: inherit; }
/* 剪贴板被挡时的兜底输入框（已自动选中，Ctrl/⌘+C 即可） */
.copy-box { display: none; position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  z-index: 60; align-items: center; gap: 8px; padding: 10px 12px; border: 1px solid var(--accent);
  border-radius: 10px; background: var(--panel); box-shadow: 0 8px 24px rgba(0,0,0,0.35); font-size: 12px; }
.copy-box.on { display: flex; }
.copy-box input { width: 190px; font-family: ui-monospace, Menlo, monospace; }
.chip-target { color: #8bd17c; border-color: rgba(139, 209, 124, 0.5); }
.stat.thin .stat-value { color: #c58de0; }

/* PR 追踪视图 */
.pr-head { display: flex; align-items: center; gap: 10px; margin: 4px 0 12px; }
.pr-head h1 { font-size: 18px; margin: 0; }
.pr-scopes { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; align-items: center; }
.pr-scopes .seg-btn.tiny { font-size: 11px; padding: 2px 7px; }
.pr-groupby { margin-left: 4px; }
/* 创建者筛选条 */
.pr-authors { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.pr-author-chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel); color: inherit;
  border-radius: 999px; padding: 3px 10px 3px 4px; font-size: 12px; cursor: pointer; }
.pr-author-chip:hover { border-color: var(--accent); }
.pr-author-chip.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, var(--panel)); }
/* 头像 */
.pr-ava, .pr-ava-sm, .pr-ava-xs { border-radius: 50%; object-fit: cover; background: var(--line); display: inline-block; flex: none; }
.pr-ava { width: 22px; height: 22px; margin-top: 3px; }
.pr-ava-sm { width: 18px; height: 18px; }
.pr-ava-xs { width: 14px; height: 14px; }
.pr-ava-empty { border-radius: 50%; background: var(--line); }
/* 分组 */
.pr-group { margin-bottom: 14px; }
.pr-group-head { display: flex; align-items: center; gap: 8px; padding: 4px 2px 6px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.pr-group-name { font-weight: 600; font-size: 13px; }
.pr-num { font-variant-numeric: tabular-nums; }
/* PR 讨论线程（留言/指派） */
.pr-thread { margin: 2px 0 10px 30px; padding: 10px 12px; border: 1px dashed var(--line); border-radius: 10px; background: color-mix(in srgb, var(--panel) 92%, transparent); }
.pr-thread .comment { margin-bottom: 8px; }
.pr-thread-box { margin-top: 6px; }
.pr-thread-box textarea { width: 100%; box-sizing: border-box; }
.pr-thread-btn { margin-left: auto; }
.pr-row.is-open { border-color: var(--accent); }
.pr-list { display: flex; flex-direction: column; gap: 6px; }
.pr-row { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.pr-row:hover { border-color: var(--accent); }
.pr-star { background: none; border: none; color: #f4c542; font-size: 15px; cursor: pointer; padding: 0 2px; line-height: 1.4; opacity: 0.55; }
.pr-star.on { opacity: 1; }
.pr-main { min-width: 0; flex: 1; }
.pr-title-line { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.pr-repo { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; color: var(--muted); white-space: nowrap; }
.pr-title { color: var(--text); text-decoration: none; font-size: 13.5px; }
.pr-title:hover { text-decoration: underline; }
.pr-meta { margin-top: 3px; }
.pr-note { color: #d1a45b; }
.pr-draft { color: #8a93a3; }
.pr-ok { color: #6bd08a; border-color: rgba(107, 208, 138, 0.45); }
.pr-bad { color: #ff8b96; border-color: rgba(239, 91, 107, 0.45); }
.pr-wait { color: #f4c542; border-color: rgba(244, 197, 66, 0.4); }
.pr-merged { color: #a06bf4; border-color: rgba(160, 107, 244, 0.45); }
.pr-closed { color: #8a93a3; }
.stat.stale .stat-value { color: #d1a45b; }
.stat.p0 .stat-value { color: #ff8b96; }
.stat.priv .stat-value { color: #ff96a0; }

/* tag = the sub-classification inside a project (文档 / 模板 / 节点实现 …) */
.tag-list { display: flex; flex-wrap: wrap; gap: 5px; }
.tag-chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--bg-card); border: 1px solid var(--line); color: var(--text);
  border-radius: 20px; padding: 3px 9px; font-size: 11px;
}
.tag-chip.on { background: var(--accent-soft); border-color: var(--accent); color: #fff; }
.tag-count { color: var(--muted); font-size: 10px; }
.tag-chip.on .tag-count { color: #cdd9f5; }
.chip.tag { cursor: pointer; }
.active-tags { font-size: 11px; color: var(--muted); }
.active-tags b { color: var(--accent); font-weight: 600; }
.focus-group { border: 1px solid rgba(244, 197, 66, 0.32); background: rgba(244, 197, 66, 0.04); border-radius: 12px; padding: 10px 12px; }
.focus-group h2 { color: #f4c542; }
.sidebar h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 14px 0 4px;
}
.views { display: flex; gap: 6px; }
.view-btn {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 7px 8px;
}
.view-btn.on { background: var(--accent-soft); border-color: var(--accent); }

.side-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.side-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 7px;
  background: none;
  border: none;
  color: var(--text);
  border-radius: 7px;
  padding: 6px 8px;
  text-align: left;
  font-size: 13px;
}
.side-item.on { background: var(--accent-soft); color: #fff; }
.side-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-count { color: var(--muted); font-size: 12px; }
.side-note { color: var(--muted); font-size: 11px; max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-item.handoff { flex-direction: column; align-items: flex-start; gap: 0; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.sidebar-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); display: grid; gap: 4px; }

/* ---------------- main ---------------- */
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: rgba(20, 22, 26, 0.92);
  backdrop-filter: blur(6px);
  z-index: 5;
}
.topbar #search { max-width: 340px; }
.view { padding: 16px 18px 60px; }

/* stats strip */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; margin-bottom: 18px; }
.stat {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 14px;
  min-width: 0;
  display: grid;
  gap: 2px;
  text-align: left;
  color: var(--text);
}
.stat.active { border-color: var(--accent); background: var(--accent-soft); }
.stat-value { font-size: 20px; font-weight: 600; }
.stat-label { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat.bad .stat-value { color: var(--danger); }
.stat.warn .stat-value { color: #f4a340; }

/* groups + rows */
.group { margin-bottom: 22px; }
.group h2 {
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px;
  color: var(--muted);
  font-weight: 600;
}
.group-count { color: var(--muted); font-weight: 400; }
.group-kind { margin-left: auto; font-size: 11px; opacity: 0.6; }
.rows { display: grid; gap: 6px; }
.row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 120px;
  gap: 12px;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-left: 3px solid transparent;
  border-radius: var(--radius);
  padding: 10px 12px;
  cursor: pointer;
  transition: border-color 0.12s ease, background-color 0.12s ease;
}
.row.is-done { opacity: 0.5; }
.row-title { font-size: 14px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.row-meta { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 5px; }
.row-updated { color: var(--muted); font-size: 11px; margin-left: auto; }
.row-progress { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); }
.bar { flex: 1; height: 5px; background: var(--line); border-radius: 4px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); }

/* chips + pills */
.prio {
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  border-radius: 6px;
  padding: 4px 0;
}
.pr-1 { background: rgba(239, 91, 107, 0.18); color: #ff8b96; }
.pr-2 { background: rgba(244, 163, 64, 0.16); color: #f4a340; }
.pr-3 { background: rgba(91, 141, 239, 0.16); color: #8fb4f7; }
.pr-4 { background: rgba(147, 156, 171, 0.14); color: var(--muted); }
.prio-dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; margin-right: 5px; }

.pill {
  font-size: 11px;
  border-radius: 20px;
  padding: 2px 9px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
}
.st-todo { border-color: #4a5464; color: #a8b4c4; }
.st-doing { border-color: var(--accent); color: #9dbcff; background: var(--accent-soft); }
.st-blocked { border-color: rgba(239, 91, 107, 0.5); color: #ff96a0; }
.st-waiting { border-color: rgba(244, 163, 64, 0.45); color: #f4bb78; }
.st-done { border-color: rgba(53, 192, 127, 0.45); color: #6cd7a4; }
.pill.on { background: var(--accent-soft); border-color: var(--accent); }

.chip { font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; }
.chip-src { color: var(--accent); border-color: rgba(91, 141, 239, 0.4); }
.chip-agent { color: var(--ok); border-color: rgba(53, 192, 127, 0.4); }
.chip-handoff { color: #f4a340; border-color: rgba(244, 163, 64, 0.45); }
.chip-project { color: var(--text); }

.due { font-size: 11px; }
.due-over { color: var(--danger); font-weight: 600; }
.due-today { color: #f4a340; font-weight: 600; }
.due-soon { color: #f4bb78; }
.due-far, .due-none { color: var(--muted); }

.empty { text-align: center; padding: 60px 0; color: var(--muted); }

/* ---------------- calendar ---------------- */
.cal-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.cal-nav { display: flex; align-items: center; gap: 6px; }
.cal-tools { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.cal-title { font-size: 15px; margin-left: 8px; white-space: nowrap; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg-btn { background: transparent; border: none; color: var(--muted); padding: 6px 11px; font-size: 12px; white-space: nowrap; }
.seg-btn.on { background: var(--accent-soft); color: #fff; }
.cal-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 11px; color: var(--muted); margin-bottom: 10px; }
.legend-item { display: inline-flex; align-items: center; }
.legend-item i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 5px; }

.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-dow { font-size: 11px; color: var(--muted); text-align: center; padding-bottom: 4px; }
.cal-cell {
  min-height: 104px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 5px;
}
.cal-cell.outside { opacity: 0.38; }
.cal-cell.weekend:not(.today) { background: #171a1f; }
.cal-cell.today { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent-soft); }
.cal-date { font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.cal-cell.today .cal-date { color: var(--accent); font-weight: 700; }
.cal-items { display: grid; gap: 3px; }
.cal-item {
  font-size: 11px;
  text-align: left;
  border: 1px solid var(--line);
  border-left: 3px solid transparent;
  border-radius: 6px;
  padding: 3px 6px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cal-item.done { text-decoration: line-through; opacity: 0.55; }
.cal-more { background: none; border: none; color: var(--accent); font-size: 11px; padding: 2px; text-align: left; }

/* week view */
.cal-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.week-col { background: var(--bg-soft); border: 1px solid var(--line); border-radius: 8px; padding: 6px; min-height: 340px; }
.week-col.today { border-color: var(--accent); }
.week-head {
  display: flex; align-items: center; gap: 6px;
  width: 100%; background: none; border: none; color: var(--text);
  font-size: 12px; padding: 2px 2px 8px; border-bottom: 1px solid var(--line); margin-bottom: 6px;
}
.week-col.today .week-head { color: var(--accent); }
.week-count { margin-left: auto; color: var(--muted); font-size: 11px; }
.week-items { display: grid; gap: 5px; }

/* cards (week + day) */
.cal-card {
  display: grid; gap: 5px; text-align: left; width: 100%;
  border: 1px solid var(--line); border-left: 3px solid transparent;
  border-radius: 8px; padding: 7px 9px; color: var(--text);
}
.cal-card.done { opacity: 0.55; }
.cal-card-title { font-size: 13px; }
.cal-card-meta { display: flex; gap: 5px; align-items: center; flex-wrap: wrap; }

/* day view */
.day-summary { margin-bottom: 10px; }
.day-list { display: grid; gap: 6px; }

.cal-undated { margin-top: 18px; }
.cal-undated h3 { font-size: 12px; color: var(--muted); }
.undated-list { display: flex; gap: 6px; flex-wrap: wrap; }
.undated-item {
  border: 1px solid var(--line);
  border-left: 3px solid transparent;
  border-radius: 20px;
  color: var(--text);
  padding: 4px 10px;
  font-size: 12px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------------- links ---------------- */
.checklist { margin-bottom: 16px; }
.checklist h3 { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.checklist ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.checklist li { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.checklist li.done .check-label { color: var(--muted); text-decoration: line-through; }
.checklist .check-label { flex: 1; }
.check-box { background: none; border: none; padding: 0; font-size: 14px; line-height: 1; }

/* 分类体系：项目树缩进 + 标签分组 + 任务关联 */
.side-item.depth-1 { padding-left: 20px; font-size: 12.5px; }
.side-item.depth-2 { padding-left: 32px; font-size: 12px; }
.side-item.depth-1 .dot { width: 6px; height: 6px; }
.tag-group { margin-bottom: 8px; }
.tag-group h4 {
  margin: 6px 0 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--muted);
  text-transform: none;
  display: flex;
  gap: 6px;
  align-items: center;
}
.rel-list { display: grid; gap: 5px; margin-bottom: 8px; }
.rel {
  display: flex; align-items: center; gap: 7px;
  background: var(--bg-card); border: 1px solid var(--line); border-radius: 8px; padding: 6px 9px;
  font-size: 12.5px;
}
.rel-title { flex: 1; cursor: pointer; }
.rel-kind { font-size: 10px; color: var(--muted); border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; }
.rel-kind.blocks { color: #ff96a0; border-color: rgba(239, 91, 107, 0.45); }
.rel-kind.duplicate { color: #f4a340; border-color: rgba(244, 163, 64, 0.45); }
.link-add { display: flex; gap: 6px; margin-bottom: 18px; }
.link-add select { flex: 1; }
.link-add button { white-space: nowrap; }

.chip-link { color: var(--accent); border-color: rgba(91, 141, 239, 0.45); text-decoration: none; }
.link-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.link-pill {
  display: inline-flex; align-items: center; gap: 4px;
  color: var(--accent); border: 1px solid rgba(91, 141, 239, 0.45);
  border-radius: 20px; padding: 3px 10px; font-size: 12px; text-decoration: none;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* ---------------- detail drawer ---------------- */
.detail {
  border-left: 1px solid var(--line);
  background: var(--bg-soft);
  height: var(--vh);
  position: sticky;
  top: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  padding: 0;
  display: none;
}
.detail.open { display: block; }
.detail > * { margin: 0 18px; }
.detail > .detail-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 14px;
  padding: 12px 18px 10px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 3;
  background: rgba(27, 30, 36, 0.94);
  backdrop-filter: blur(6px);
}
.detail-badges { display: flex; gap: 6px; margin-left: auto; }
.detail-title {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 10px !important;
  width: calc(100% - 36px);
}
.quick-status { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.detail-grid label { font-size: 11px; color: var(--muted); display: grid; gap: 4px; }
.detail-grid .span { grid-column: span 2; }
.block { display: grid; gap: 4px; font-size: 11px; color: var(--muted); margin-bottom: 12px; }
.detail > .detail-actions {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  margin: 0 0 18px;
  padding: 10px 18px;
  position: sticky;
  bottom: 0;
  z-index: 2;
  background: rgba(27, 30, 36, 0.94);
  backdrop-filter: blur(6px);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.detail-actions .muted { flex: 1 1 140px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread h3, .activity h3 { font-size: 12px; color: var(--muted); margin-bottom: 8px !important; }
.comments { display: grid; gap: 8px; margin-bottom: 12px; }
.comment {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
}
.comment.from-agent { border-left: 3px solid var(--ok); }
.comment.handled { opacity: 0.7; }
.comment-head { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-bottom: 4px; }
.comment-body { white-space: pre-wrap; font-size: 13px; }
.comment-box { display: grid; gap: 6px; margin-bottom: 20px; }
.comment-controls { display: flex; align-items: center; gap: 10px; }
.check { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.check input { width: auto; }
.activity ul { list-style: none; margin: 0 0 40px; padding: 0; display: grid; gap: 4px; font-size: 12px; }

.scrim { display: none; }

.toast {
  position: fixed;
  bottom: calc(20px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(100vw - 32px);
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 16px;
  box-shadow: var(--shadow);
  z-index: 50;
}

/* 只在真有鼠标的设备上加 hover，触屏点一下不会「粘住」高亮 */
@media (hover: hover) {
  .side-item:hover { background: var(--bg-card); }
  .tag-chip:hover { border-color: var(--accent); }
  .chip.tag:hover { border-color: var(--accent); color: var(--accent); }
  .row:hover { border-color: var(--accent); background: #232831; }
  .seg-btn:hover { background: var(--bg-card); }
  .cal-item:hover { filter: brightness(1.25); }
  .cal-card:hover { border-color: var(--accent); }
  .rel-title:hover { color: var(--accent); }
  .chip-link:hover, .link-pill:hover { background: var(--accent-soft); }
}

/* ---------------- 手机 ---------------- */
@media (max-width: 820px) {
  /* iOS 输入框字号小于 16px 会在聚焦时自动放大页面 */
  input, select, textarea { font-size: 16px; }
  .hide-sm { display: none; }

  .layout, .layout:has(.detail.open) { grid-template-columns: minmax(0, 1fr); }
  body:has(.sidebar.open), body:has(.detail.open) { overflow: hidden; }

  .menu-btn { display: block; flex: none; }
  .menu-close { display: block; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(82vw, 300px);
    padding-top: calc(16px + env(safe-area-inset-top));
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
    transform: translateX(-102%);
    transition: transform 0.2s ease;
    z-index: 30;
    box-shadow: var(--shadow);
  }
  .sidebar.open { transform: none; }
  .side-item { padding: 9px 8px; }
  .layout:has(.sidebar.open) .scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 29;
    background: rgba(0, 0, 0, 0.5);
  }

  .topbar {
    padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
    gap: 8px;
  }
  .topbar #search { max-width: none; flex: 1; min-width: 0; }
  .topbar .new-task { flex: none; padding: 5px 13px; font-size: 18px; line-height: 1.3; }
  .active-tags { display: none; }
  .view { padding: 12px 12px calc(60px + env(safe-area-inset-bottom)); }

  /* 统计条：横向滑动，贴边，不出现滚动条 */
  .stats {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
    margin: 0 -12px 14px;
    padding: 0 12px;
  }
  .stats::-webkit-scrollbar { display: none; }
  .stat { flex: none; min-width: 82px; padding: 8px 12px; scroll-snap-align: start; }
  .stat-value { font-size: 18px; }

  .focus-group { padding: 8px; }
  .group-kind { display: none; }
  .row { grid-template-columns: auto minmax(0, 1fr); align-items: start; gap: 10px; padding: 10px; }
  .row .prio { padding: 2px 6px; margin-top: 1px; }
  .row-progress { display: none; }

  /* 月视图：七列塞进屏宽，任务画成色条，点格子进日视图 */
  .cal-head { gap: 8px; }
  .cal-nav { width: 100%; }
  .cal-title { margin-left: auto; }
  .cal-tools { width: 100%; margin-left: 0; }
  .cal-tools .seg:first-child { flex: 0 0 120px; }
  .cal-tools .seg:last-child { flex: 1; }
  .seg-btn { flex: 1; padding: 7px 6px; }
  .cal-legend {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    white-space: nowrap;
    margin: 0 -12px 10px;
    padding: 0 12px;
  }
  .cal-legend::-webkit-scrollbar { display: none; }
  .cal { gap: 3px; }
  .cal-dow { font-size: 10px; }
  .cal-cell { min-height: 60px; padding: 4px 3px; border-radius: 6px; cursor: pointer; }
  .cal-date { font-size: 12px; text-align: center; margin-bottom: 4px; }
  .cal-items { gap: 3px; }
  .cal-item {
    font-size: 0;
    height: 4px;
    padding: 0;
    border: none;
    border-radius: 2px;
    background: var(--c, var(--muted)) !important;
    pointer-events: none;
  }
  .cal-more { font-size: 10px; padding: 0; text-align: center; }

  /* 周视图：七天竖排 */
  .cal-week { grid-template-columns: minmax(0, 1fr); }
  .week-col { min-height: 0; }

  /* 任务抽屉：全屏，顶部关闭栏和底部保存栏常驻 */
  .detail { position: fixed; inset: 0; z-index: 25; width: 100%; height: auto; }
  .detail > * { margin: 0 14px; }
  .detail > .detail-head { padding: calc(10px + env(safe-area-inset-top)) 14px 10px; }
  .detail > .detail-actions { padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); }
  .detail-title { width: calc(100% - 28px); }
  .quick-status .pill { padding: 5px 11px; font-size: 12px; }
  .link-add { flex-wrap: wrap; }
  .link-add select:first-child { flex-basis: 100%; }
}
