/* Piko CRM · styles of crm-collab.js (and of what crm-tasks.js / crm-members.js add for working
   together). Scope every rule under .crm-root; use the tokens in crm.css. */

/* ---- who: the assignee badge / button ------------------------------------------------------------- */
.crm-root .crm-who { flex: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 0; max-width: 100%; border-radius: 999px; font-size: var(--t-sub); color: var(--secondary); }
.crm-root .crm-who-button { min-width: var(--ctl-s); min-height: var(--ctl-s); padding: 2px; transition: background-color var(--hover), transform .28s var(--m-release); }
.crm-root .crm-who-button:active { transform: scale(var(--press)); }
.crm-root .crm-who:has(.crm-who-name) { padding-right: 10px; }
@media (hover: hover) { .crm-root .crm-who-button:hover { background: var(--wash); color: var(--ink); } }
.crm-root .crm-who-name { min-width: 0; max-width: 9em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crm-root .crm-who-none { flex: none; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; border: 1px dashed var(--tertiary); color: var(--secondary); }
.crm-root .crm-who-none[data-size="36"] { width: 36px; height: 36px; }
.crm-root .crm-who-none .crm-icon { width: 15px; height: 15px; }
.crm-root .crm-menu-item > .crm-badge { margin-left: -2px; }

/* ---- 讨论: comments ---------------------------------------------------------------------------------- */
.crm-root .crm-thread-count { margin-left: 6px; color: var(--secondary); font-weight: 400; font-variant-numeric: tabular-nums; }
.crm-root .crm-thread { display: flex; flex-direction: column; }
.crm-root .crm-comment { position: relative; display: flex; align-items: flex-start; gap: 12px; padding: 12px 8px 14px 16px; transition: opacity var(--hover); }
.crm-root .crm-thread > .crm-comment + .crm-comment::before { content: ""; position: absolute; top: 0; left: 56px; right: 0; height: var(--hair); background: var(--line); }
.crm-root .crm-comment[data-pending="true"] { opacity: .55; }
.crm-root .crm-comment > .crm-badge { margin-top: 1px; }
.crm-root .crm-comment-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.crm-root .crm-comment-head { display: flex; align-items: center; gap: 8px; min-height: 30px; min-width: 0; }
.crm-root .crm-comment-author { min-width: 0; font-size: var(--t-body); font-weight: 600; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crm-root .crm-comment-time, .crm-root .crm-comment-edited { flex: none; white-space: nowrap; }
.crm-root .crm-comment-more { margin: -8px 0 -8px auto; color: var(--secondary); }
.crm-root .crm-comment-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: var(--t-body); line-height: 1.5; padding-right: 8px; max-width: 38em; }
.crm-root .crm-mention { padding: 1px 5px; margin: 0 1px; border-radius: 6px; background: var(--elevated); font-weight: 500; white-space: nowrap; }
.crm-root .crm-mention[data-me="true"] { background: color-mix(in srgb, var(--ink) 13%, transparent); font-weight: 600; }
.crm-root .crm-talk, .crm-root .crm-comment-edit { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.crm-root .crm-comment-edit { padding: 2px 8px 0 0; }
.crm-root .crm-talk-end { display: flex; align-items: center; gap: 10px; min-width: 0; }
.crm-root .crm-comment-edit .crm-talk-end { justify-content: flex-end; gap: 6px; }
.crm-root .crm-talk-hint { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crm-root:not([data-form="desk"]) .crm-talk-hint { visibility: hidden; }
.crm-root .crm-talk-at { flex: none; display: grid; place-items: center; width: var(--ctl-s); height: var(--ctl-s); border-radius: 50%; background: var(--elevated); color: var(--ink);
  font-size: 15px; font-weight: 600; line-height: 1; transition: background-color var(--hover), transform .28s var(--m-release); }
.crm-root .crm-talk-at:active { transform: scale(.92); }
@media (hover: hover) { .crm-root .crm-talk-at:hover { background: color-mix(in srgb, var(--ink) 9%, var(--elevated)); } }
.crm-root .crm-talk-send { min-height: var(--ctl-s); }
.crm-root:not([data-form="desk"]) .crm-talk-send { min-height: var(--ctl); }
.crm-root .crm-mention-pop { z-index: 30; min-width: 220px; max-width: min(320px, calc(100% - 16px)); max-height: 296px; overflow-y: auto; overscroll-behavior: contain; }
.crm-root .crm-mention-option { cursor: pointer; }
.crm-root:not([data-form="desk"]) .crm-mention-option { min-height: 54px; padding-block: 6px; }
.crm-root .crm-mention-option .crm-menu-text { gap: 2px; line-height: 1.25; }
.crm-root .crm-mention-option[aria-selected="true"] { background: var(--elevated); }
@media (hover: hover) { .crm-root .crm-mention-option[aria-selected="false"]:hover { background: none; } }

/* ---- the bell and its panel ---------------------------------------------------------------------------- */
.crm-root .crm-bell { position: relative; }
.crm-root .crm-bell-count { --badge: 16px; --badge-font: 10px; position: absolute; top: -3px; right: -5px; box-shadow: 0 0 0 2px var(--canvas); pointer-events: none; }
.crm-root:not([data-form="desk"]) .crm-head .crm-bell { background: var(--surface); box-shadow: 0 0 0 var(--hair) var(--line); }
.crm-root:not([data-form="desk"]) .crm-bell-count { --badge: 18px; --badge-font: 11px; top: -1px; right: -1px; }
.crm-root .crm-bell-panel { width: 400px; max-width: calc(100% - 16px); max-height: min(620px, calc(100% - 76px)); padding: 0; border-radius: 16px; display: flex; flex-direction: column; overflow: hidden; }
.crm-root .crm-bell-head { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 48px; padding: 6px 8px 0 16px; }
.crm-root .crm-bell-title { font-size: var(--t-headline); font-weight: 600; }
.crm-root .crm-bell-list { flex: 1; min-height: 132px; overflow-y: auto; overscroll-behavior: contain; padding: 0 6px 6px; }
.crm-root .crm-bell-more { flex: none; display: flex; align-items: center; justify-content: center; gap: 4px; min-height: 44px; border-top: var(--rule); font-size: var(--t-body); font-weight: 500; transition: background-color var(--hover); }
.crm-root .crm-bell-more .crm-icon { width: 13px; height: 13px; color: var(--secondary); }
@media (hover: hover) { .crm-root .crm-bell-more:hover { background: var(--wash); } }
.crm-root .crm-bell-sheet { gap: 4px; }
.crm-root .crm-bell-sheet .crm-bell-list { padding: 0; margin: 0 -8px; min-height: 200px; }
.crm-root .crm-bell-sheet .crm-bell-more { border-top: 0; border-radius: 12px; background: var(--elevated); margin-top: 8px; }
.crm-root .crm-bell-tools { display: flex; justify-content: flex-end; min-height: 0; }
.crm-root .crm-bell-tools:not(:has(> :not([hidden]))) { display: none; }

/* ---- a notification row (bell, inbox, my work) ---------------------------------------------------------- */
.crm-root .crm-ping-day { padding: 12px 10px 4px; font-size: var(--t-foot); font-weight: 500; color: var(--secondary); line-height: 1.3; }
.crm-root .crm-ping { position: relative; display: flex; align-items: center; min-width: 0; }
.crm-root .crm-ping-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; min-height: var(--row-h); padding: 8px 10px 8px 4px; border-radius: 12px; text-align: left; transition: background-color var(--hover); }
@media (hover: hover) { .crm-root .crm-ping-main:hover { background: var(--wash); } }
.crm-root .crm-ping-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; }
.crm-root .crm-ping[data-unread="true"] .crm-ping-dot { background: var(--ink); }
.crm-root .crm-ping-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.crm-root .crm-ping-line { font-size: var(--t-body); line-height: 1.38; overflow-wrap: anywhere; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; }
.crm-root .crm-ping[data-unread="false"] .crm-ping-line { color: var(--secondary); }
.crm-root .crm-ping-actor { font-weight: 600; }
.crm-root .crm-ping-title { font-weight: 500; }
.crm-root .crm-ping[data-unread="true"] .crm-ping-title, .crm-root .crm-ping[data-unread="true"] .crm-ping-actor { color: var(--ink); }
.crm-root .crm-ping-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crm-root .crm-ping-space { font-weight: 500; }
.crm-root .crm-ping-end { flex: none; display: flex; align-items: center; gap: 6px; padding-left: 4px; }
.crm-root .crm-ping-state { padding: 0 8px; white-space: nowrap; }
.crm-root .crm-ping-read { color: var(--secondary); }

/* ---- 收件箱 ------------------------------------------------------------------------------------------------ */
.crm-root .crm-inbox-tools { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.crm-root .crm-filters { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; min-width: 0; }
/* The type filter is a row of the shared filter chips (.crm-fchip, crm.css). */
.crm-root[data-form="phone"] .crm-filters { flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto; scrollbar-width: none; margin-inline: calc(-1 * var(--pad)); padding-inline: var(--pad); }
.crm-root[data-form="phone"] .crm-filters::-webkit-scrollbar { display: none; }
.crm-root .crm-inbox { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.crm-root .crm-inbox-day { gap: 6px; }
.crm-root .crm-inbox-day .crm-ping-day { padding: 0 4px; }
.crm-root .crm-ping-row { padding: 0 8px 0 6px; }
.crm-root .crm-card > .crm-ping-row + .crm-ping-row::before { content: ""; position: absolute; top: 0; left: 74px; right: 0; height: var(--hair); background: var(--line); }
.crm-root .crm-ping-row .crm-ping-main { padding-left: 10px; }
@container col (max-width: 479px) {
  .crm-root .crm-ping-row:has(.crm-btn) { flex-wrap: wrap; }
  .crm-root .crm-ping-row:has(.crm-btn) .crm-ping-main { flex-basis: 100%; }
  .crm-root .crm-ping-row:has(.crm-btn) .crm-ping-end { margin-left: auto; padding-bottom: 8px; }
}

/* ---- 我的待办 ---------------------------------------------------------------------------------------------- */
.crm-root .crm-mine { container: mine / inline-size; }
.crm-root .crm-mine-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
@container mine (min-width: 560px) {
  .crm-root .crm-mine-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .crm-root .crm-mine-grid[data-count="1"], .crm-root .crm-mine-grid[data-empty="true"], .crm-root .crm-mine-grid:not([data-count]) { grid-template-columns: minmax(0, 1fr); }
  .crm-root .crm-mine-grid[data-count="3"] > :first-child { grid-row: span 2; }
}
@container mine (min-width: 900px) {
  .crm-root .crm-mine-grid[data-count="3"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .crm-root .crm-mine-grid[data-count="3"] > :first-child { grid-row: auto; }
  .crm-root .crm-mine-grid[data-count="4"] { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
.crm-root .crm-mine-card { display: flex; flex-direction: column; min-width: 0; padding: 4px 0 8px; border-radius: 16px; }
.crm-root .crm-mine-wait, .crm-root .crm-mine-none { border-radius: 16px; }
.crm-root .crm-mine-wait { padding: 4px; }
.crm-root .crm-mine-head { display: flex; align-items: center; gap: 6px; min-height: 40px; padding: 2px 6px 0 16px; }
.crm-root .crm-mine-title { font-size: var(--t-headline); font-weight: 500; line-height: 1.3; }
.crm-root .crm-mine-count { font-size: var(--t-sub); color: var(--secondary); font-variant-numeric: tabular-nums; }
.crm-root .crm-mine-all { margin-left: auto; display: inline-flex; align-items: center; gap: 2px; min-height: var(--ctl-s); padding: 0 6px 0 10px; border-radius: 8px; font-size: var(--t-sub); color: var(--secondary); transition: color var(--hover), background-color var(--hover); }
.crm-root .crm-mine-all .crm-icon { width: 12px; height: 12px; }
@media (hover: hover) { .crm-root .crm-mine-all:hover, .crm-root .crm-mine-rest:hover { color: var(--ink); } .crm-root .crm-mine-open:hover { background: var(--wash); } }
.crm-root .crm-mine-rows { display: flex; flex-direction: column; padding: 0 6px; min-width: 0; }
.crm-root .crm-mine-row { display: flex; align-items: center; min-width: 0; min-height: 48px; }
.crm-root .crm-mine-open { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; min-height: 48px; padding: 6px 10px; border-radius: 10px; text-align: left; transition: background-color var(--hover); }
.crm-root .crm-mine-tick { flex: none; width: 38px; height: 44px; margin-left: 2px; }
.crm-root .crm-mine-tick + .crm-mine-open { padding-left: 4px; }
.crm-root .crm-mine-bullet { flex: none; width: 6px; height: 6px; margin: 0 6px 0 12px; border-radius: 50%; background: var(--tertiary); }
.crm-root .crm-mine-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.crm-root .crm-mine-main { font-size: var(--t-body); font-weight: 500; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crm-root .crm-mine-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crm-root .crm-mine-end { flex: none; font-size: var(--t-sub); font-variant-numeric: tabular-nums; }
.crm-root .crm-mine-flag { color: var(--secondary); }
.crm-root .crm-mine-rest { align-self: flex-start; min-height: 32px; margin: 2px 16px 0; font-size: var(--t-sub); color: var(--secondary); transition: color var(--hover); }
.crm-root .crm-mine-notice .crm-ping-main { min-height: 48px; padding: 6px 8px 6px 6px; border-radius: 10px; }
.crm-root .crm-mine-notice .crm-badge { width: 28px; height: 28px; font-size: 11px; }
.crm-root .crm-mine-notice .crm-ping-line { -webkit-line-clamp: 2; }

/* ---- 任务: filters, the assignee on a row, the task sheet ----------------------------------------------------- */
.crm-root .crm-task-bar { flex-wrap: wrap; gap: 8px 12px; }
.crm-root .crm-task-open { display: block; min-width: 0; text-align: left; border-radius: 6px; }
/* Touch: the title's target reaches 44 without making the row taller. */
.crm-root:not([data-form="desk"]) .crm-task-open { padding: 14px 0 7px; margin: -14px 0 -7px; }
@media (hover: hover) { .crm-root .crm-task-open:hover .crm-task-title { text-decoration: underline; text-decoration-color: var(--tertiary); text-underline-offset: 3px; } }
.crm-root .crm-task[data-done="true"] .crm-task-open:hover .crm-task-title { text-decoration: line-through; }
.crm-root .crm-task > .crm-who { margin: 0 2px; }
@container col (max-width: 519px) { .crm-root .crm-task > .crm-who .crm-who-name { display: none; } .crm-root .crm-task > .crm-who { padding-right: 2px; } }
.crm-root .crm-task-card { display: flex; flex-direction: column; gap: 4px; min-width: 0; padding: 10px 10px 8px 12px; }
.crm-root .crm-task-card .crm-task-title { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; }
.crm-root .crm-task-card[data-done="true"] .crm-task-title { color: var(--secondary); font-weight: 400; text-decoration: line-through; text-decoration-color: var(--tertiary); }
.crm-root .crm-task-card-parent { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crm-root .crm-task-card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 28px; }
.crm-root .crm-task-sheet { gap: 16px; }
.crm-root .crm-task-sheet .crm-task-name { font-size: var(--t-title3); font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; padding: 0 4px; }
.crm-root .crm-task-sheet .crm-task-name[data-done="true"] { color: var(--secondary); text-decoration: line-through; text-decoration-color: var(--tertiary); }
.crm-root .crm-task-sheet .crm-facts { background: var(--canvas); }
.crm-root .crm-task-sheet .crm-task-fact { justify-content: flex-end; }
@container col (max-width: 479px) { .crm-root .crm-task-sheet .crm-task-fact { justify-content: flex-start; } .crm-root .crm-task-sheet .crm-fact-value .crm-trigger { padding: 0 10px 0 0; } }
.crm-root .crm-task-sheet .crm-fact-value .crm-trigger { width: auto; max-width: 100%; min-height: var(--ctl-s); background: none; box-shadow: none; padding: 0 0 0 10px; justify-content: flex-end; }
.crm-root .crm-task-sheet .crm-fact-value .crm-trigger .crm-trigger-text { flex: 0 1 auto; }
.crm-root .crm-task-sheet .crm-thread { background: var(--canvas); }
.crm-root .crm-task-sheet .crm-thread .crm-badge { background: var(--surface); }
.crm-root .crm-task-sheet .crm-section-head { padding: 0 4px; }
.crm-root .crm-task-parent { align-self: flex-start; padding: 0 4px; }

/* ---- 成员 --------------------------------------------------------------------------------------------------- */
.crm-root .crm-member-load { color: var(--secondary); font-variant-numeric: tabular-nums; }

@media (prefers-reduced-motion: reduce) {
  .crm-root .crm-who-button:active, .crm-root .crm-talk-at:active { transform: none; }
}
