/* =========================================================================
   views/tasks.css — Tasks (admin to-dos) — quick-add, grouped list, detail panel, mentions
   Split from the old monolithic styles/views.css. LOAD ORDER MATTERS:
   the <link> order in Magnet CRM.html / Client App.html reproduces the
   original file order, so the cascade is unchanged — add new rules to the
   matching feature file, not the end of the list.
   ========================================================================= */
/* ====================================================================== */
/* Tasks (admin to-dos) — quick-add, grouped list, detail panel, mentions */
/* ====================================================================== */
.ctasks { display: flex; align-items: flex-start; gap: var(--space-5); min-height: 100%; }
#viewScroll > .ctasks { padding: 20px var(--space-6) var(--space-6); }
.ctasks-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: var(--space-5); }
.ctasks-loading { padding: var(--space-6); text-align: center; color: var(--text-soft); font-size: var(--text-sm); }
/* skeleton placeholder while the task list loads (mirrors .ctasks-body spacing) */
.ctasks-skel { display: flex; flex-direction: column; gap: var(--space-5); pointer-events: none; }
.task-row--skel { cursor: default; pointer-events: none; }
/* deliverables list skeleton (rows are direct children of .cdeliv-list, so its gap applies) */
.cdeliv-row--skel { cursor: default; pointer-events: none; }
.cdeliv-skel-title { flex: 1; min-width: 0; padding: 0 6px; }
/* files + notes card skeletons (reuse the real card classes for geometry) */
.cfile-card--skel, .note-card--skel { cursor: default; pointer-events: none; }

/* quick-add capture bar (mirrors the lead drawer's .dw-todo-field) */
.task-qa { display: flex; align-items: center; gap: var(--space-2); min-height: 44px; padding: 6px 8px 6px 12px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); box-shadow: var(--btn-shadow); transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease); }
.task-qa:focus-within { border-color: var(--primary-400); box-shadow: var(--ring-primary); }
.task-qa-ico { display: inline-flex; flex-shrink: 0; color: var(--text-soft); }
.task-qa-ico svg { width: 16px; height: 16px; }
.task-qa-input { flex: 1; min-width: 0; font-size: var(--text-md); color: var(--text); outline: none; line-height: 1.5; padding: 2px 0; }
.task-qa-input:empty::before { content: attr(data-placeholder); color: var(--text-soft); pointer-events: none; }
/* the CONTAINER carries the focus ring (:focus-within) — kill the inner
   contenteditable's own :focus-visible outline so it doesn't double up */
.task-qa-input:focus, .task-qa-input:focus-visible { outline: none; box-shadow: none; }
.task-qa-date { flex-shrink: 0; display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 9px; border-radius: var(--radius-full); background: color-mix(in srgb, var(--primary-600) 10%, var(--surface)); color: var(--primary-600); font-size: var(--text-xs); font-weight: var(--fw-semibold); white-space: nowrap; transition: background var(--dur-fast) var(--ease); }
@media (hover: hover) and (pointer: fine) {
  .task-qa-date:hover { background: color-mix(in srgb, var(--primary-600) 18%, var(--surface)); }
}
.task-qa-date[hidden] { display: none; }
.task-qa-date svg { width: 13px; height: 13px; }
/* the parsed date phrase lights up inline — same accent + tint as the crumb
   count badge, square corners */
.task-qa-hl { color: var(--primary-600); background: color-mix(in srgb, var(--primary-600) 12%, var(--surface)); border-radius: 0; }
.task-qa-kbd { flex-shrink: 0; }
.task-qa-kbd kbd { display: inline-flex; align-items: center; height: 22px; padding: 0 7px; border: 1px solid var(--border); border-radius: var(--radius-xs); background: var(--gray-50); color: var(--text-soft); font-family: var(--font-sans); font-size: var(--text-2xs); font-weight: var(--fw-semibold); letter-spacing: 0.02em; }

/* leads mobile kebab (⋮ — Status/Sort/View overflow) — mobile-only chrome,
   shown by responsive.css once relocated into the topbar */
.leads-tools-dd { display: none; }

/* mobile quick-add composer (TickTick-style) — opened by the tasks FAB,
   pinned above the software keyboard (quickAddSheet.js sets translateY from
   visualViewport). Sits under the due-date popover (+4) / @mention menu (+5). */
.qadd-scrim { position: fixed; inset: 0; z-index: calc(var(--z-popover) + 3); background: var(--sheet-scrim); }
.qadd {
  position: fixed; left: 0; right: 0; bottom: 0;
  z-index: calc(var(--z-popover) + 3);
  background: var(--surface); border-top: 1px solid var(--border);
  border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
  box-shadow: var(--shadow-lg);
  padding: var(--space-4) max(var(--space-4), var(--safe-right))
           calc(var(--space-3) + var(--safe-bottom)) max(var(--space-4), var(--safe-left));
  will-change: padding-bottom, transform, opacity;
  overflow: visible;
  opacity: 0;
}
.qadd.is-ready { opacity: 1; }
/* The composer itself rides the keyboard by transform. A background extension
   sits behind the keyboard, so iOS rounded keyboard corners reveal sheet
   surface instead of the app backdrop without stretching the composer tall. */
.qadd.is-kb { padding-bottom: var(--space-3); }
.qadd::after {
  content: "";
  position: absolute;
  left: 0; right: 0;
  bottom: calc(-1 * var(--keyboard-offset, 0px));
  height: var(--keyboard-offset, 0px);
  background: var(--surface);
  pointer-events: none;
}
.qadd.is-closing {
  opacity: 0;
  transform: translateY(calc(100% - var(--keyboard-offset, 0px)));
}
.qadd-input {
  min-height: 44px; max-height: 30dvh; overflow-y: auto;
  font-size: var(--text-base); line-height: 1.5; color: var(--text-strong);
  outline: none; padding: 2px;
}
.qadd-input:empty::before { content: attr(data-placeholder); color: var(--text-soft); pointer-events: none; }
/* the sheet itself is the focus affordance — kill the global focus ring */
.qadd-input:focus, .qadd-input:focus-visible { outline: none; box-shadow: none; }
.qadd-row { display: flex; align-items: center; gap: var(--space-2); margin-top: var(--space-2); }
.qadd-row .spacer { flex: 1; }
.qadd-chip {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px;
  border-radius: var(--radius-full);
  background: color-mix(in srgb, var(--primary-600) 12%, transparent);
  color: var(--primary-600); font-size: var(--text-sm); font-weight: var(--fw-semibold);
  transition: background var(--dur) var(--ease);
}
.qadd-chip svg { width: 15px; height: 15px; }
.qadd-chip:active { background: color-mix(in srgb, var(--primary-600) 20%, transparent); }
.qadd-send {
  width: 42px; height: 42px; flex-shrink: 0; border-radius: var(--radius-full);
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--primary-600); color: var(--on-primary);
  transition: opacity var(--dur) var(--ease), transform var(--dur-fast) var(--ease);
}
.qadd-send svg { width: 20px; height: 20px; }
.qadd-send:disabled { opacity: 0.4; }
.qadd-send:active:not(:disabled) { transform: scale(0.94); }

/* toolbar view switch — icon + label pills, same treatment as the client tabs */
.tasks-viewseg button { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.tasks-viewseg button svg { width: 15px; height: 15px; }
/* mobile-only kebab counterpart (moved into the topbar by applyMobileLeadTools;
   shown by responsive.css ≤640px) — hidden wherever the segmented is visible */
.tasks-viewdd { display: none; }
.tasks-viewdd .filter-opt > span:first-child { display: inline-flex; align-items: center; gap: 8px; }
.tasks-viewdd .filter-opt > span:first-child svg { width: 16px; height: 16px; margin-left: 0; color: var(--text-soft); }
.tasks-viewdd .filter-opt.active > span:first-child svg { color: var(--primary-600); }

/* grouped sections */
.ctasks-body { display: flex; flex-direction: column; gap: var(--space-5); }
.task-sec-head { display: flex; align-items: center; gap: var(--space-2); padding: 2px 2px; cursor: pointer; user-select: none; }
.task-sec-chev { display: inline-flex; color: var(--text-soft); transition: transform var(--dur) var(--ease); }
.task-sec-chev svg { width: 15px; height: 15px; }
.task-sec.collapsed .task-sec-chev { transform: rotate(-90deg); }
.task-sec.collapsed .task-sec-body { display: none; }
.task-sec-title { font-size: var(--text-sm); font-weight: var(--fw-bold); color: var(--text-strong); }
.task-sec-title.is-overdue { color: var(--danger-600); }
.task-sec-count { font-size: var(--text-xs); font-weight: var(--fw-semibold); color: var(--text-soft); }
.task-sec-act { flex-shrink: 0; font-size: var(--text-sm); font-weight: var(--fw-semibold); color: var(--primary-600); padding: 2px 6px; border-radius: var(--radius-xs); transition: background var(--dur-fast) var(--ease); }
@media (hover: hover) and (pointer: fine) {
  .task-sec-act:hover { background: var(--surface-hover); }
}
.task-sec-body { display: flex; flex-direction: column; gap: 6px; margin-top: var(--space-2); position: relative; }
.task-sec-empty { padding: var(--space-4); text-align: center; color: var(--text-soft); font-size: var(--text-sm); border: 1px dashed var(--border); border-radius: var(--radius-md); }

/* task rows */
.task-row { display: flex; align-items: center; gap: var(--space-3); padding: 10px 12px; background: var(--surface); border: 1px solid var(--border-faint); border-radius: var(--radius-md); cursor: pointer; transition: border-color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease), transform 200ms var(--ease); }
/* swipe-left quick actions (mobile) — Change date + Delete sit BEHIND the
   row; the row translates left to reveal them (TasksView pointer gestures) */
.task-swipe { position: relative; }
.task-swipe .task-row { position: relative; z-index: 1; }
.task-row-actions {
  position: absolute; top: 0; bottom: 0; right: 0; width: 132px;
  display: none; z-index: 0;
  border-radius: var(--radius-md); overflow: hidden;
}
.task-row-actions button { flex: 1 1 0; display: inline-flex; align-items: center; justify-content: center; color: #fff; }
.task-row-actions svg { width: 19px; height: 19px; }
.trs-date { background: var(--primary-600); }
.trs-del { background: var(--danger-600); }
@media (max-width: 640px) {
  .task-row-actions { display: flex; }
  /* horizontal pans belong to the swipe gesture; vertical stays native scroll */
  .task-row { touch-action: pan-y; }
  /* taller rows = bigger touch targets for tapping, dragging and the checkbox */
  .task-row { min-height: 52px; padding: 12px 14px; gap: var(--space-3); }
  .task-check { padding: 4px; margin: -4px; }   /* enlarge the checkbox hit area without resizing the box */
}
@media (hover: hover) and (pointer: fine) {
  .task-row:hover { border-color: var(--border); background: var(--gray-25); }
}
.task-row.sel { border-color: var(--border-faint); background: var(--surface-hover-strong); }
.task-row:focus-visible { outline: none; border-color: var(--primary-400); box-shadow: var(--ring-primary); }
.task-check { display: inline-flex; flex-shrink: 0; cursor: pointer; }
.task-row-title { flex: 1; min-width: 0; font-size: var(--text-md); font-weight: var(--fw-medium); color: var(--text-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-row.is-done .task-row-title { color: var(--text-soft); text-decoration: line-through; }
.task-row-untitled { color: var(--text-soft); font-weight: var(--fw-regular); }
.task-row-meta { display: flex; align-items: center; gap: var(--space-2); flex-shrink: 0; }
.task-row-client { display: inline-flex; }
.task-row-shared { display: inline-flex; color: var(--info-600); }
.task-row-shared svg { width: 14px; height: 14px; }
/* tagged-teammate avatar(s) in the row meta — the pfp of who the task is shared
   with, in place of a generic people icon. Up to 3, slightly overlapped. */
.task-row-people { display: inline-flex; align-items: center; flex-shrink: 0; }
.task-row-avatar {
  width: 18px; height: 18px; flex-shrink: 0;
  border-radius: 50%; overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-field); color: var(--text-soft);
  font-size: 9px; font-weight: var(--fw-bold); line-height: 1;
  box-shadow: 0 0 0 1.5px var(--surface);   /* ring so stacked avatars read apart */
}
.task-row-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.task-row-avatar + .task-row-avatar { margin-left: -6px; }
.task-row-due { font-size: var(--text-xs); font-weight: var(--fw-medium); color: var(--primary-600); white-space: nowrap; }
.task-row-due.overdue { color: var(--danger-600); }

/* drag-to-reorder (TasksView long-press lift; taskListDrag.js).
   The dragged .task-swipe stays in the DOM as a dimmed placeholder while a
   fixed-position clone follows the pointer; a primary insertion line marks
   where it will land, and rows FLIP to open the gap. */
.task-swipe.dragging .task-row { opacity: 0.32; }
/* the placeholder row is dimmed — hide the swipe gutter (Change date / Delete)
   sitting behind it so it can't bleed through while dragging on mobile */
.task-swipe.dragging .task-row-actions { display: none; }
.task-drag-overlay {
  position: fixed; z-index: 80; left: 0; top: 0; margin: 0;
  pointer-events: none; will-change: transform, left, top;
  transform: scale(1.025); transform-origin: center;
}
.task-drag-overlay .task-row {
  background: var(--surface-hover-strong); border-color: var(--primary-400);
  box-shadow: var(--shadow-lg); cursor: grabbing;
}
.task-drop-line {
  position: absolute; left: 0; right: 0; height: 2px; z-index: 4;
  background: var(--primary-500); border-radius: 2px; pointer-events: none;
}
.task-drop-line::before {
  content: ""; position: absolute; left: -1px; top: -3px;
  width: 8px; height: 8px; border-radius: 50%; background: var(--primary-500);
}
.task-drop-line[hidden] { display: none; }
body.tasks-dragging { cursor: grabbing; user-select: none; -webkit-user-select: none; }
body.tasks-dragging * { cursor: grabbing !important; }
@media (prefers-reduced-motion: reduce) {
  .task-drag-overlay { transform: none; }
}

/* inline @client mention chip (titles + descriptions) */
.task-mention { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px 1px 3px; margin: 0 1px; border-radius: var(--radius-full); background: color-mix(in srgb, var(--primary-600) 10%, var(--surface)); color: var(--primary-600); font-size: 0.92em; font-weight: var(--fw-semibold); white-space: nowrap; cursor: pointer; vertical-align: middle; transition: background var(--dur-fast) var(--ease); }
@media (hover: hover) and (pointer: fine) {
  .task-mention:hover { background: color-mix(in srgb, var(--primary-600) 18%, var(--surface)); }
}
.task-mention .proj-logo.xs { width: 16px; height: 16px; font-size: 9px; border-radius: var(--radius-full); }
/* Keep a long mention from overflowing its line — the chip caps at the container
   width and its name clips with an ellipsis instead of running off the edge. */
.task-mention { max-width: 100%; min-width: 0; }
.task-mention .tm-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.task-mention .proj-logo.xs, .task-mention .mention-avatar { flex-shrink: 0; }
.task-mention-menu { width: 264px; }

/* admin/teammate mention — a distinct accent so @teammate (shares the task) reads
   differently from @client (links a business). */
.task-mention-admin { background: color-mix(in srgb, var(--info-600) 12%, var(--surface)); color: var(--info-600); }
@media (hover: hover) and (pointer: fine) {
  .task-mention-admin:hover { background: color-mix(in srgb, var(--info-600) 20%, var(--surface)); }
}
.mention-avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; border-radius: var(--radius-full);
  background: var(--info-600); color: #fff; font-size: 9px; font-weight: var(--fw-bold);
  line-height: 1; overflow: hidden; flex-shrink: 0;
}
.mention-avatar img { width: 100%; height: 100%; object-fit: cover; }
/* "Teammate" tag in the @ menu rows */
.slash-meta { margin-left: auto; font-size: var(--text-2xs); font-weight: var(--fw-semibold); color: var(--info-600); background: color-mix(in srgb, var(--info-600) 12%, var(--surface)); padding: 1px 6px; border-radius: var(--radius-full); flex-shrink: 0; }

/* detail panel (desktop inline card; mobile rides the shared drawer sheet) */
.ctasks-detail {
  width: clamp(420px, 34vw, 520px); flex-shrink: 0; display: flex; overflow: hidden;
  position: sticky; top: 0;
  height: calc(100dvh - var(--shell-header-height) - var(--shell-toolbar-height));
  margin: -20px calc(-1 * var(--space-6)) calc(-1 * var(--space-6)) 0;
  background: var(--surface);
  border: 0; border-left: 1px solid var(--border); border-radius: 0;
}
/* drag handle riding the sheet's left border */
.ctasks-resizer { position: absolute; left: -4px; top: 0; bottom: 0; width: 8px; cursor: col-resize; z-index: 2; touch-action: none; }
.ctasks-resizer::after { content: ""; position: absolute; left: 3px; top: 0; bottom: 0; width: 2px; background: transparent; transition: background var(--dur-fast) var(--ease); }
body.is-col-resizing .ctasks-resizer::after { background: var(--primary-400); }
@media (hover: hover) and (pointer: fine) {
  .ctasks-resizer:hover::after { background: var(--primary-400); }
}
body.is-col-resizing { cursor: col-resize; user-select: none; }
.ctasks-detail[hidden] { display: none; }
.ctasks-detail-empty { flex: 1; min-width: 0; display: flex; align-items: center; justify-content: center; padding: var(--space-6); }
.task-detail { display: flex; flex-direction: column; flex: 1; min-width: 0; min-height: 0; }
.td-head { display: flex; align-items: center; gap: var(--space-1); padding: var(--space-6); border-bottom: 1px solid var(--border-faint); flex-shrink: 0; }
/* checkbox + date group — transparent on desktop (renders inline); on mobile it
   drops to its own row above the title (see the mobile block) */
.td-head-when { display: contents; }
/* .spacer has no global flex rule — scope it for the tasks surfaces */
.task-detail .spacer, .task-sec-head .spacer { flex: 1; }
.td-done { margin-right: 2px; }
.td-done .checkbox { width: 20px; height: 20px; }
.td-head-sep { width: 1px; height: 20px; background: var(--border); margin: 0 6px; flex-shrink: 0; }
.td-due { display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 10px; border-radius: var(--radius-sm); font-size: var(--text-md); font-weight: var(--fw-medium); color: var(--primary-600); transition: background var(--dur-fast) var(--ease); }
@media (hover: hover) and (pointer: fine) {
  .td-due:hover { background: var(--surface-hover); }
}
.td-due svg { width: 17px; height: 17px; }
.td-due--empty { color: var(--text-soft); }
.td-due.overdue { color: var(--danger-600); }
.td-flag-btn, .td-x { width: 30px; height: 30px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--radius-sm); color: var(--text-soft); transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease); }
@media (hover: hover) and (pointer: fine) {
  .td-flag-btn:hover, .td-x:hover { background: var(--nav-hover-bg); color: var(--text-strong); }
}
/* desktop inline panel: no close button (click the selected row to close);
   the mobile sheet keeps it — mountDrawer requires a .drawer-close */
.ctasks-detail .td-x { display: none; }
.td-x svg { width: 16px; height: 16px; }
.td-flag { display: inline-flex; color: var(--gray-400); }
.td-flag svg { width: 16px; height: 16px; }
.td-flag.pri-high { color: var(--pri-high-fg); }
.td-flag.pri-medium { color: var(--pri-medium-fg); }
.td-flag.pri-low { color: var(--pri-low-fg); }
/* set priorities show a FILLED flag; "none" stays outline */
.td-flag.pri-high svg path, .td-flag.pri-medium svg path, .td-flag.pri-low svg path { fill: currentColor; }
/* overscroll-behavior: contain — keep the scroll self-contained at its top/bottom
   boundary. Without it the overscroll chains up to the document and the iOS shell's
   scroll-lock yanks it back, which read as the scroll "stalling" at the bottom. */
.td-scroll { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 20px var(--space-6) var(--space-6); display: flex; flex-direction: column; gap: var(--space-4); }
/* The scroller's children must never flex-shrink: an explicit min-height (e.g.
   .td-desc--ck's 24px) overrides flexbox's content-size minimum, so a long
   description's BOX gets crushed while its text keeps painting — straight over
   the checklist rows below. Overflow belongs to .td-scroll, not to shrinking. */
.td-scroll > * { flex-shrink: 0; }
/* NB: we deliberately do NOT set touch-action on the contenteditable editors.
   pan-y there fought iOS's text-selection gesture (selection "wigged out") without
   reliably enabling scroll-on-text anyway — iOS reserves a drag on focused editable
   text for the caret/selection. So text drags select/caret (normal), and scrolling
   happens on the scroller's non-text areas (.td-scroll keeps pan-y). */
.td-title-row { display: flex; align-items: flex-start; gap: var(--space-2); }
.td-title { flex: 1; min-width: 0; font-size: var(--text-2xl); font-weight: var(--fw-bold); line-height: 1.25; letter-spacing: -0.01em; color: var(--text-strong); outline: none; }
.td-checklist-btn { width: 28px; height: 28px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--radius-sm); color: var(--text-soft); transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease); }
@media (hover: hover) and (pointer: fine) {
  .td-checklist-btn:hover { background: var(--nav-hover-bg); color: var(--text-strong); }
}
.td-checklist-btn svg { width: 16px; height: 16px; }
.td-title:empty::before { content: attr(data-placeholder); color: var(--gray-400); pointer-events: none; }
.td-title:focus, .td-title:focus-visible { outline: none; box-shadow: none; }
.td-desc:focus, .td-desc:focus-visible { outline: none; box-shadow: none; }
.task-detail.is-done .td-title { color: var(--text-soft); text-decoration: line-through; }
.td-meta { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.td-meta:empty { display: none; }
/* linked-client tag + its unlink × form one connected pill (× attached on the right) */
.td-client-chip { display: inline-flex; align-items: stretch; }
.td-client { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 6px 0 10px; border-radius: var(--radius-full) 0 0 var(--radius-full); background: var(--gray-100); font-size: var(--text-sm); font-weight: var(--fw-medium); color: var(--text); transition: background var(--dur-fast) var(--ease); }
@media (hover: hover) and (pointer: fine) {
  .td-client:hover { background: var(--surface-hover-strong); }
}
.td-client .proj-logo.xs { width: 16px; height: 16px; font-size: 9px; }
.td-client-x { width: 26px; height: 28px; padding-right: 3px; display: inline-flex; align-items: center; justify-content: center; background: var(--gray-100); border-radius: 0 var(--radius-full) var(--radius-full) 0; color: var(--text-soft); transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease); }
@media (hover: hover) and (pointer: fine) {
  .td-client-x:hover { background: var(--danger-bg); color: var(--danger-600); }
}
.td-client-x svg { width: 13px; height: 13px; }
/* tagged-teammate chip reuses the client-chip frame; its avatar is the @mention
   blue circle, and the name isn't a button so it shouldn't look clickable */
.td-admin { cursor: default; }
.td-admin .mention-avatar { width: 16px; height: 16px; }
@media (hover: hover) and (pointer: fine) { .td-admin-chip .td-admin:hover { background: var(--gray-100); } }
/* "By <owner>" attribution on a shared task — matches the teammate-mention accent */
.td-by { display: inline-flex; align-items: center; height: 24px; padding: 0 9px; border-radius: var(--radius-full); background: color-mix(in srgb, var(--info-600) 10%, var(--surface)); color: var(--info-600); font-size: var(--text-xs); font-weight: var(--fw-semibold); white-space: nowrap; }
.td-desc { min-height: 140px; font-size: var(--text-md); position: relative; }
/* checklist mode: the description is a single-line notes area sitting just above
   the items — tight like TickTick (no dead space, ~12px to the first row) */
.td-desc.td-desc--ck { min-height: 24px; }
.td-desc.td-desc--ck + .td-checklist { margin-top: calc(-1 * var(--space-4) + 12px); }
/* keep the placeholder visible until real text is typed — a focused empty
   contenteditable holds a stray <br>, so :empty alone would hide it (.is-blank
   is text-aware, set in JS). Absolutely positioned so it sits OUT of the text
   flow — otherwise the inline placeholder pushes the caret to its end. */
.td-desc.is-blank::before { content: attr(data-placeholder); color: var(--gray-400); pointer-events: none; position: absolute; left: 0; top: 0; }
/* iOS native-editor hand-off: the field isn't inline-editable — a tap opens the
   native UITextView — so present it as a tappable text surface, not a caret. */
.td-desc--native { cursor: text; -webkit-user-select: none; user-select: none; }
/* TickTick-style checklist ROWS — scoped to the task panel so the Notes
   editor keeps its own checklist look */
.td-desc .ne-todo { margin: 0; }
.td-desc .ne-todo-item { position: relative; align-items: center; gap: 10px; margin: 0; padding: 9px 28px 9px 0; border-bottom: 1px solid var(--border-faint); }
.td-desc .ne-check { margin-top: 0; }
.td-desc .ne-todo-text { flex: 1; min-width: 0; }
.td-desc .ne-todo-del { position: absolute; right: 0; top: 50%; transform: translateY(-50%); width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--radius-xs); color: var(--text-soft); opacity: 0; transition: opacity var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease); }
@media (hover: hover) and (pointer: fine) {
  .td-desc .ne-todo-item:hover .ne-todo-del { opacity: 1; }
  .td-desc .ne-todo-del:hover { color: var(--danger-600); background: var(--danger-bg); }
}
.td-desc .ne-todo-del svg { width: 14px; height: 14px; }
.td-foot { display: flex; align-items: center; gap: var(--space-2); padding: 8px var(--space-6); border-top: 1px solid var(--border-faint); flex-shrink: 0; }
.td-list-chip { display: inline-flex; align-items: center; gap: 6px; font-size: var(--text-xs); font-weight: var(--fw-medium); color: var(--text-soft); }
.td-list-chip svg { width: 14px; height: 14px; }

/* checklist mode (kind=CHECKLIST): structured TickTick-style rows */
.td-checklist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.td-checklist[hidden], .td-desc[hidden] { display: none; }
.td-checklist .tdc-row { position: relative; display: flex; align-items: flex-start; gap: 8px; margin: 0; padding: 5px 28px 5px 0; background: transparent; border: 0; border-bottom: 1px solid var(--border-faint); border-radius: 0; overflow: visible; }
.td-checklist .tdc-row .task-check { margin-top: 6px; }
@media (hover: hover) and (pointer: fine) {
  .td-checklist .tdc-row:hover { background: transparent; border-color: transparent; border-bottom-color: var(--border-faint); }
}
/* the focused row's divider turns brand-accent, like TickTick's active row
   (after the hover rule so a focused+hovered row still reads as active) */
.td-checklist .tdc-row:focus-within { border-bottom-color: var(--primary-600); }
.tdc-row .drag-handle { position: absolute; left: -22px; top: 10px; transform: none; margin: 0; width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center; opacity: 0; }
@media (hover: hover) and (pointer: fine) {
  .tdc-row:hover .drag-handle { opacity: 1; }
}
.tdc-input { flex: 1; min-width: 0; min-height: 30px; border: 0; outline: 0; background: transparent; padding: 4px 0; font-family: var(--font-sans); font-size: var(--text-md); line-height: 22px; color: var(--text-strong); white-space: pre-wrap; overflow-wrap: break-word; }
.tdc-input:focus, .tdc-input:focus-visible { outline: none; box-shadow: none; }
.tdc-input:empty::before { content: attr(data-placeholder); color: var(--text-soft); pointer-events: none; }
.tdc-row.is-done .tdc-input { color: var(--text-soft); text-decoration: line-through; }
.tdc-del { position: absolute; right: 0; top: 7px; transform: none; width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--radius-xs); color: var(--text-soft); opacity: 0; transition: opacity var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease); }
.tdc-row:focus-within .tdc-del { opacity: 1; }
@media (hover: hover) and (pointer: fine) {
  .tdc-row:hover .tdc-del { opacity: 1; }
  .tdc-del:hover { color: var(--danger-600); background: var(--danger-bg); }
}
.tdc-del svg { width: 14px; height: 14px; }
.tdc-row--new .drag-handle, .tdc-row--new .tdc-del { visibility: hidden; }
/* the "Press Enter" hint only shows when the row is focused — or when the
   checklist has no items yet (the trailing row IS the first input) */
.tdc-row--new .tdc-input:empty::before { content: ""; }
.tdc-row--new:first-child .tdc-input:empty::before,
.tdc-row--new .tdc-input:focus:empty::before { content: attr(data-placeholder); }
.tdc-row--new .checkbox { opacity: 0.5; pointer-events: none; }
.task-row-subs { font-size: var(--text-2xs); font-weight: var(--fw-semibold); color: var(--text-soft); white-space: nowrap; }

/* due-date popover (quick-add chip + detail panel) */
.td-due-menu { position: fixed; z-index: calc(var(--z-popover) + 4); width: 256px; padding: 6px; }
/* quick-action row: icon shortcuts (Today / Tomorrow / Next week / Next month /
   No date) with hover tooltips, in the app theme */
.td-due-quick { display: flex; gap: 4px; margin-bottom: 6px; }
.td-due-quick button { position: relative; flex: 1; height: 36px; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--radius-md); color: var(--text-soft); background: var(--gray-50); border: 1px solid var(--border-faint); transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease); }
.td-due-quick button svg { width: 18px; height: 18px; }
@media (hover: hover) and (pointer: fine) {
  .td-due-quick button:hover { background: var(--gray-100); color: var(--text-strong); border-color: var(--border); }
}
/* footer: "No date" (clear) + tick (Done/close) */
.td-due-foot { display: flex; gap: 4px; margin-top: 6px; }
.td-due-foot .td-due-clear { flex: 1; height: 32px; border-radius: var(--radius-md); font-size: var(--text-sm); font-weight: var(--fw-medium); color: var(--text-soft); background: var(--gray-50); border: 1px solid var(--border-faint); transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease); }
.td-due-foot .td-due-done { flex: 1; height: 32px; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--radius-md); font-size: var(--text-sm); font-weight: var(--fw-semibold); color: #fff; background: var(--primary-600); border: 1px solid var(--primary-600); transition: background var(--dur-fast) var(--ease); }
@media (hover: hover) and (pointer: fine) {
  .td-due-foot .td-due-clear:hover { background: var(--gray-100); color: var(--text); }
  .td-due-foot .td-due-done:hover { background: var(--primary-700); }
}
/* the calendar "+7" badge on Next week */
.td-due-quick .tdq-week { position: relative; }
.td-due-quick .tdq-badge { position: absolute; right: 6px; bottom: 5px; font-size: 8px; font-weight: var(--fw-bold); line-height: 1; color: currentColor; background: var(--gray-50); padding: 0 1px; border-radius: 2px; }
@media (hover: hover) and (pointer: fine) { .td-due-quick .tdq-week:hover .tdq-badge { background: var(--gray-100); } }
/* hover tooltip (label below the icon), themed light/dark */
.td-due-quick button::after { content: attr(aria-label); position: absolute; top: calc(100% + 5px); left: 50%; transform: translateX(-50%); padding: 3px 7px; border-radius: var(--radius-sm); background: var(--text-strong); color: var(--surface); font-size: var(--text-xs); font-weight: var(--fw-medium); white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity var(--dur-fast) var(--ease); z-index: 6; box-shadow: var(--shadow-md); }
@media (hover: hover) and (pointer: fine) { .td-due-quick button:hover::after { opacity: 1; } }

/* "Time" button under the calendar + the scrollable time-range view it swaps to */
.td-due-menu .td-due-time { display: none; }
.td-due-menu.is-time .td-due-cal { display: none; }
.td-due-menu.is-time .td-due-time { display: flex; flex-direction: column; }

.td-due-time-btn { display: flex; align-items: center; gap: var(--space-2); width: 100%; margin-bottom: 6px; padding: 0 8px; height: 32px; border-radius: var(--radius-sm); font-size: var(--text-sm); font-weight: var(--fw-medium); color: var(--text); background: var(--gray-50); border: 1px solid var(--border-faint); transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease); }
.td-due-time-btn svg { width: 15px; height: 15px; color: var(--text-soft); flex: none; }
.td-due-time-btn .tdt-label { flex: 1; text-align: left; }
.td-due-time-btn:not(.is-set) .tdt-label { color: var(--text-soft); }
.td-due-time-btn.is-set { color: var(--primary-700); border-color: var(--primary-300); background: var(--primary-50); }
.td-due-time-btn.is-set svg:first-child { color: var(--primary-600); }
.td-due-time-btn svg:last-child { margin-left: auto; }
@media (hover: hover) and (pointer: fine) {
  .td-due-time-btn:hover { background: var(--gray-100); border-color: var(--border); }
}

.td-time-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); margin-bottom: 6px; }
.td-time-back { display: inline-flex; align-items: center; gap: 2px; padding: 4px 6px 4px 2px; border-radius: var(--radius-sm); font-size: var(--text-sm); font-weight: var(--fw-medium); color: var(--text); }
.td-time-back svg { width: 16px; height: 16px; }
@media (hover: hover) and (pointer: fine) { .td-time-back:hover { background: var(--gray-100); } }
.td-time-fmt { flex: none; }
.td-time-list { max-height: 244px; overflow-y: auto; display: flex; flex-direction: column; gap: 0; padding-right: 2px; scrollbar-width: thin; }
.td-time-slot { flex: none; height: 30px; padding: 0 10px; text-align: left; font-size: var(--text-sm); color: var(--text); background: transparent; border: 1px solid transparent; transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease); }
@media (hover: hover) and (pointer: fine) {
  .td-time-slot:hover { background: var(--primary-50); border-color: var(--primary-100); border-radius: var(--radius-sm); }
}
/* slots already occupied by another task on this day — a yellow indicator only
   (you can still stack a task on the same time); selection (blue) overrides it */
.td-time-slot.busy { background-color: color-mix(in srgb, var(--warning-600) 20%, var(--surface)); background-image: repeating-linear-gradient(-45deg, color-mix(in srgb, var(--warning-600) 40%, transparent) 0 1px, transparent 1px 7px); border-radius: var(--radius-sm); }
.td-time-slot.in-range { background: var(--primary-50); color: var(--primary-700); }
.td-time-slot.is-start, .td-time-slot.is-end { background: var(--primary-600); color: #fff; font-weight: var(--fw-semibold); }
.td-time-slot.is-start { border-top-left-radius: var(--radius-sm); border-top-right-radius: var(--radius-sm); }
.td-time-slot.is-end { border-bottom-left-radius: var(--radius-sm); border-bottom-right-radius: var(--radius-sm); }
.td-time-slot.is-single { border-radius: var(--radius-sm); }
.td-time-clear { margin-top: 6px; height: 30px; border-radius: var(--radius-sm); font-size: var(--text-sm); font-weight: var(--fw-medium); color: var(--text-soft); background: var(--gray-50); border: 1px solid var(--border-faint); }
@media (hover: hover) and (pointer: fine) { .td-time-clear:hover { background: var(--gray-100); color: var(--text); } }

/* priority popover */
.td-pri-menu { position: fixed; z-index: calc(var(--z-popover) + 4); min-width: 168px; padding: 6px; display: flex; flex-direction: column; gap: 1px; }
.td-pri-menu [data-pri] { display: flex; align-items: center; gap: var(--space-3); padding: 7px 8px; border-radius: var(--radius-sm); font-size: var(--text-sm); color: var(--text); text-align: left; transition: background var(--dur-fast) var(--ease); }
@media (hover: hover) and (pointer: fine) {
  .td-pri-menu [data-pri]:hover { background: var(--gray-100); }
}
.td-pri-menu [data-pri] > svg { width: 15px; height: 15px; margin-left: auto; color: var(--primary-600); }

/* "Linked tasks" section on the client Deliverables tab */
.cltasks { display: flex; flex-direction: column; gap: var(--space-4); margin-top: var(--space-2); }
.cltasks-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-4); }
.cltasks-title { font-size: var(--text-lg); font-weight: var(--fw-bold); color: var(--text-strong); margin: 0 0 4px; letter-spacing: -0.01em; }
.cltasks-sub { color: var(--text-soft); font-size: var(--text-sm); margin: 0; }
.cltasks-list { display: flex; flex-direction: column; gap: var(--space-2); }

/* "Scheduled content" — the client's posts + status chips (reuses .task-row).
   The cover runs edge to edge on the row's left with a media-count badge —
   the Content Shares card treatment, scaled down to a row. */
.clsched-row { cursor: pointer; padding: 0 12px 0 0; overflow: hidden; min-height: 54px; }
.clsched-cover { position: relative; width: 84px; align-self: stretch; flex: 0 0 auto; background: var(--gray-200); box-shadow: 8px 0 18px -6px rgba(0, 0, 0, .18); }
.clsched-cover img, .clsched-cover video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.clsched-play { position: absolute; inset: 0; margin: auto; width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; background: rgba(0, 0, 0, .5); color: #fff; pointer-events: none; }
.clsched-play svg { width: 11px; height: 11px; fill: currentColor; }
.clsched-cover--icon { display: inline-flex; align-items: center; justify-content: center; color: var(--text-soft); }
.clsched-cover--icon svg { width: 16px; height: 16px; }
.clsched-count { position: absolute; right: 4px; top: 4px; display: inline-flex; align-items: center; gap: 3px; padding: 1px 5px; border-radius: var(--radius-xs); background: rgba(0, 0, 0, .55); color: #fff; font-size: var(--text-2xs); font-weight: var(--fw-semibold); }
.clsched-count svg { width: 10px; height: 10px; }
.clsched-title { display: inline-flex; align-items: center; gap: 6px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clsched-note-mark { display: inline-flex; color: var(--danger-600); flex: 0 0 auto; }
.clsched-note-mark svg { width: 13px; height: 13px; }
.clsched-badges { display: inline-flex; gap: 3px; align-items: center; }
.clsched-badges svg { width: 14px; height: 14px; }
.clsched-chip { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px; font-size: var(--text-2xs); font-weight: var(--fw-semibold); white-space: nowrap; }
.clsched-chip.is-ok { background: color-mix(in srgb, var(--success-600, #16a34a) 12%, var(--surface)); color: var(--success-700, #15803d); }
.clsched-chip.is-warn { background: color-mix(in srgb, #b45309 12%, var(--surface)); color: #b45309; }
.clsched-chip.is-bad { background: color-mix(in srgb, var(--danger-600) 10%, var(--surface)); color: var(--danger-600); }
.clsched-chip.is-idle { background: var(--surface-2, var(--gray-100)); color: var(--text-muted); }
/* phones: the caption gets the row to itself, the chip drops beneath it —
   platform badges + a dated chip won't fit beside a title at this width */
@media (max-width: 640px) {
  .clsched-row { flex-wrap: wrap; padding-bottom: 8px; row-gap: 6px; }
  .clsched-cover { width: 62px; align-self: stretch; }
  .clsched-title { flex: 1 1 auto; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .clsched-row .task-row-meta { flex: 1 0 100%; justify-content: flex-start; padding-left: 74px; }
}

/* tablet: keep the list usable beside the fixed detail panel */
@media (max-width: 1024px) {
  .ctasks-detail { width: 340px; }
}

/* mobile */
@media (max-width: 640px) {
  #viewScroll > .ctasks { padding: var(--space-4) max(var(--space-4), var(--safe-left)) 0 max(var(--space-4), var(--safe-right)); }
  .ctasks-detail { display: none; }
  .task-qa-kbd { display: none; }
  .task-row { padding: 12px; }
  /* Sit the whole editor above the keyboard: shrink the detail by the keyboard
     height (border-box → the flex children, incl. .td-scroll, shrink to fit) so the
     scroller ends AT the keyboard top instead of behind it. Then scrolling with the
     keyboard up behaves exactly like keyboard-down (which works) — every line is
     reachable. --app-keyboard-height is set live by keyboardAvoidance; 0 when down. */
  .task-drawer .task-detail { height: 100%; padding-bottom: var(--app-keyboard-height, 0px); }
  .task-drawer .td-foot { padding-bottom: calc(8px + var(--safe-bottom, 0px)); background: var(--surface); }
  /* the footer is also the keyboard accessory bar (taskDetail pins it to the
     keyboard's top edge) — finger-sized toggle, no safe-bottom while riding */
  .task-drawer .td-foot .td-checklist-btn { width: 40px; height: 40px; }
  .task-drawer .td-foot .td-checklist-btn svg { width: 18px; height: 18px; }
  .task-drawer .td-foot.is-kb { padding-bottom: 8px; }
  /* TickTick top chrome: row 1 is back · flag + kebab; the checkbox + date drop
     to their own row below it (above the title). The X goes (swipe down / scrim). */
  .task-drawer .td-x { display: none; }
  .task-drawer .td-head { flex-wrap: wrap; column-gap: var(--space-1); row-gap: 8px; padding-top: 4px; padding-bottom: 12px; }
  .task-drawer .td-head-when { display: flex; align-items: center; gap: var(--space-1); order: 10; flex-basis: 100%; }
  .task-drawer .td-head-sep { display: none; }
  /* Inbox/list chip is dropped from the mobile task sheet (the header leads with
     the checkbox + due date instead — see taskDetail.js). */
  /* the Inbox chip is hoisted into the header (top-left) on mobile, so hide any
     copy left in the footer; give the header one comfortable text size */
  .task-drawer .td-foot .td-list-chip { display: none; }
  .task-drawer .td-head .td-list-chip { font-size: var(--text-sm); color: var(--text-soft); }
  .task-drawer .td-head .td-list-chip svg { width: 16px; height: 16px; }
  .task-drawer .td-head .kebab { width: 40px; height: 40px; }
  /* the done-toggle + due date now live in the header; give them comfortable taps */
  .task-drawer .td-head .td-due { height: 40px; }

  /* iOS "liquid glass" header controls — the back chevron (top-left), the flag,
     and the kebab (top-right) read as frosted system buttons, like the round
     buttons that flank the iOS keyboard. Translucent + backdrop blur so the
     sheet content tints through; colours come from the theme-aware --glass-*
     tokens, so they track light/dark automatically. */
  .task-drawer.sheet:not(.peek) .td-back,
  .task-drawer .td-head .kebab.td-more,
  .task-drawer .td-head .td-flag-btn {
    width: 40px; height: 40px; flex-shrink: 0;
    border-radius: var(--radius-full);
    background: var(--glass-btn-bg);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    backdrop-filter: blur(20px) saturate(180%);
    border: 0.5px solid var(--glass-btn-border);
    box-shadow: var(--glass-btn-shadow);
    color: var(--text-strong);
    transition: background var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
  }
  /* the kebab carries a default border + fill from .kebab — clear them so only
     the glass treatment shows */
  .task-drawer .td-head .kebab.td-more { border: 0.5px solid var(--glass-btn-border); }
  .task-drawer .td-head .td-flag-btn svg, .task-drawer .td-head .kebab.td-more svg { width: 18px; height: 18px; }
  /* press feedback — a subtle darken + scale, like the keyboard keys */
  .task-drawer.sheet:not(.peek) .td-back:active,
  .task-drawer .td-head .kebab.td-more:active,
  .task-drawer .td-head .td-flag-btn:active {
    background: var(--glass-btn-active);
    transform: scale(0.92);
  }
}
