/* Workspace Tasks is a lightweight outliner. CRM remains the structured,
   operational task surface; this view prioritizes quick thinking and grouping. */

body[data-view="tasks"] .todo-page {
  grid-template-columns: minmax(210px, 245px) minmax(520px, 1fr) minmax(300px, 350px);
  gap: 10px;
}

body[data-view="tasks"] .todo-sidebar,
body[data-view="tasks"] .todo-main,
body[data-view="tasks"] .todo-detail {
  border-radius: 10px;
  box-shadow: 0 8px 26px rgba(15, 35, 64, 0.06);
}

body[data-view="tasks"] .todo-commandbar {
  grid-template-columns: minmax(0, 1fr) minmax(190px, 0.48fr);
  width: 100%;
  min-width: 0;
  padding: 8px 10px;
}

body[data-view="tasks"] .todo-commandbar > *,
body[data-view="tasks"] .todo-quick-add,
body[data-view="tasks"] .todo-toolbar {
  min-width: 0;
}

body[data-view="tasks"] .todo-quick-add {
  grid-template-columns: 34px minmax(72px, 88px) minmax(0, 1fr);
  gap: 6px;
}

body[data-view="tasks"] #todo-quick-type {
  width: 100%;
  min-width: 0;
}

body[data-view="tasks"] .todo-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(92px, auto);
  gap: 6px;
}

body[data-view="tasks"] #todo-status-filter {
  width: 100%;
  min-width: 92px;
  max-width: 120px;
}

body[data-view="tasks"] .todo-quick-add .icon-button {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  font-size: 20px;
  box-shadow: none;
}

body[data-view="tasks"] .todo-quick-add input,
body[data-view="tasks"] .todo-quick-add select,
body[data-view="tasks"] .todo-toolbar input,
body[data-view="tasks"] .todo-toolbar select {
  min-height: 34px;
  border-radius: 8px;
}

body[data-view="tasks"] .todo-stats article {
  padding-block: 7px;
}

body[data-view="tasks"] .todo-list {
  padding: 0 12px 18px;
  background: var(--panel);
}

.task-assignee-picker {
  position: relative;
  display: grid;
  gap: 7px;
  margin: 5px 0 14px;
}

.task-assignee-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.task-assignee-chips:empty {
  display: none;
}

.task-assignee-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line));
  border-radius: 999px;
  padding: 3px 5px 3px 10px;
  background: color-mix(in srgb, var(--accent) 8%, var(--panel));
  color: var(--ink);
  font-size: 13px;
  font-weight: 750;
}

.task-assignee-chip small {
  color: var(--accent);
  font-size: 10px;
  font-weight: 850;
  text-transform: uppercase;
}

.task-assignee-chip button {
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.task-assignee-options {
  display: grid;
  max-height: 190px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel);
}

.task-assignee-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 9px 11px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.task-assignee-option:last-child {
  border-bottom: 0;
}

.task-assignee-option:hover,
.task-assignee-option.selected {
  background: color-mix(in srgb, var(--accent) 8%, var(--panel));
}

.task-assignee-option span:first-child {
  display: grid;
  gap: 2px;
}

.task-assignee-option small {
  color: var(--muted);
  font-size: 11px;
}

body[data-view="tasks"] .todo-list-controls {
  position: sticky;
  z-index: 3;
  top: 0;
  flex-wrap: wrap;
  justify-content: flex-start;
  min-height: 48px;
  padding: 7px 8px;
  background: color-mix(in srgb, var(--panel) 94%, transparent);
  backdrop-filter: blur(12px);
}

body[data-view="tasks"] .todo-list-summary {
  min-width: 145px;
  margin-right: auto;
}

body[data-view="tasks"] .todo-list-summary span {
  font-size: 10px;
}

body[data-view="tasks"] .todo-sort-label {
  gap: 5px;
}

body[data-view="tasks"] .todo-sort-label span {
  font-size: 10px;
}

body[data-view="tasks"] .todo-sort-select {
  min-height: 30px;
  max-width: 165px;
  border-radius: 7px;
  padding-inline: 8px;
  font-size: 12px;
}

body[data-view="tasks"] .todo-outline-help {
  width: 100%;
  padding-left: 4px;
  font-size: 11px;
}

body[data-view="tasks"] .todo-item {
  position: relative;
  display: grid;
  grid-template-columns: 20px 26px minmax(0, 1fr) 28px;
  gap: 6px;
  align-items: center;
  min-height: 38px;
  margin-top: 0;
  margin-left: calc(var(--task-depth, 0) * 24px);
  padding: 5px 6px;
  border-width: 0 0 1px;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

body[data-view="tasks"] .todo-item:hover {
  background: color-mix(in srgb, var(--accent) 5%, var(--panel));
}

body[data-view="tasks"] .todo-item.selected {
  border-color: var(--line);
  background: color-mix(in srgb, var(--accent) 9%, var(--panel));
  box-shadow: inset 3px 0 0 var(--accent);
}

body[data-view="tasks"] .todo-item[data-depth]:not([data-depth="0"])::before {
  content: "";
  position: absolute;
  left: -13px;
  top: 0;
  width: 12px;
  height: 52%;
  border-left: 1px solid color-mix(in srgb, var(--muted) 34%, transparent);
  border-bottom: 1px solid color-mix(in srgb, var(--muted) 34%, transparent);
  border-bottom-left-radius: 5px;
  pointer-events: none;
}

body[data-view="tasks"] .todo-item.item-heading {
  min-height: 42px;
  margin-top: 8px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--accent) 4%, var(--panel));
}

body[data-view="tasks"] .todo-item.item-heading .todo-item-title strong {
  font-size: 14px;
  font-weight: 900;
}

body[data-view="tasks"] .todo-item.item-note {
  border-style: solid;
  background: color-mix(in srgb, #f4b740 3%, var(--panel));
}

body[data-view="tasks"] .todo-item.item-note .todo-item-title strong {
  color: var(--muted);
  font-weight: 700;
}

body[data-view="tasks"] .todo-page.note-selected {
  grid-template-columns: minmax(210px, 245px) minmax(320px, 0.72fr) minmax(520px, 1.28fr);
}

body[data-view="tasks"] .todo-page.note-selected .todo-detail {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 132px);
  max-height: calc(100vh - 132px);
  overflow: hidden;
}

body[data-view="tasks"] .todo-page.note-focus {
  grid-template-columns: minmax(0, 1fr);
}

body[data-view="tasks"] .todo-page.note-focus .todo-sidebar,
body[data-view="tasks"] .todo-page.note-focus .todo-main {
  display: none;
}

body[data-view="tasks"] .todo-page.note-focus .todo-detail {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: min(1120px, 100%);
  height: calc(100vh - 132px);
  max-height: calc(100vh - 132px);
  min-height: calc(100vh - 190px);
  margin-inline: auto;
  overflow: hidden;
}

.task-note-header,
.task-note-header-actions,
.task-note-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.task-note-header {
  flex: 0 0 auto;
  padding: 13px 15px 3px;
}

.task-note-header .todo-star {
  opacity: 1;
}

.task-note-title {
  width: calc(100% - 34px);
  flex: 0 0 auto;
  margin: 0 17px 9px;
  padding: 4px 0 6px;
  border: 0;
  border-bottom: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 20px;
  font-weight: 850;
}

.task-note-title:focus {
  outline: 0;
  border-bottom-color: var(--accent);
}

.task-note-toolbar {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
  padding: 6px 13px;
  border-block: 1px solid var(--line);
  background: var(--panel);
}

.task-note-toolbar button {
  display: grid;
  place-items: center;
  min-width: 24px;
  min-height: 24px;
  padding: 2px 5px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  font-weight: 850;
  cursor: pointer;
}

.task-note-toolbar button:hover,
.task-note-toolbar button:focus-visible {
  border-color: var(--line);
  background: var(--panel);
}

.task-note-toolbar .task-note-preview-button {
  width: 32px;
  margin-left: auto;
  padding: 3px 6px;
  border-color: var(--line);
  background: color-mix(in srgb, var(--panel) 90%, var(--muted) 10%);
}

.task-note-preview-button svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
}

.task-note-heading-menu {
  position: relative;
}

.task-note-heading-menu > summary {
  display: grid;
  min-width: 38px;
  min-height: 24px;
  padding: 2px 5px;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  list-style: none;
}

.task-note-heading-menu > summary::-webkit-details-marker {
  display: none;
}

.task-note-heading-menu > summary:hover,
.task-note-heading-menu[open] > summary {
  border-color: var(--line);
  background: color-mix(in srgb, var(--panel) 88%, var(--muted) 12%);
}

.task-note-heading-menu > div {
  position: absolute;
  z-index: 8;
  top: calc(100% + 5px);
  left: 0;
  display: grid;
  width: 132px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 10px 28px rgba(15, 35, 64, 0.16);
}

.task-note-heading-menu > div button {
  display: flex;
  width: 100%;
  padding-inline: 8px;
  justify-content: flex-start;
}

.task-note-editor,
.task-note-preview {
  flex: 1 1 auto;
  min-height: 0;
  padding: 14px;
  overflow: auto;
  background: var(--panel);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.3;
}

.task-note-editor:focus {
  outline: 0;
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--accent) 30%, transparent);
}

.task-note-editor > div,
.task-note-editor > h1,
.task-note-editor > h2,
.task-note-preview > div,
.task-note-preview > h1,
.task-note-preview > h2 {
  min-height: 20px;
  margin: 0;
}

.task-note-editor > h1,
.task-note-preview > h1 {
  margin-block: 8px 3px;
  font-size: 25px;
  line-height: 1.3;
}

.task-note-editor > h2,
.task-note-preview > h2 {
  margin-block: 7px 2px;
  font-size: 20px;
  line-height: 1.35;
}

.task-note-marker,
.task-note-preview-check {
  display: inline-block;
  width: 20px;
  margin-right: 1px;
  color: var(--muted);
  font-weight: 800;
  text-align: center;
  user-select: none;
}

.task-note-marker.checklist {
  color: var(--ink);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.task-note-editor [data-note-line="checklist"],
.task-note-preview [data-note-line="checklist"] {
  min-height: 28px;
  line-height: 28px;
}

.task-note-editor [data-note-line="checklist"][data-note-checked="true"] {
  color: var(--muted);
  text-decoration: line-through;
}

.task-note-editor [data-note-line="checklist"][data-note-checked="true"] .task-note-marker {
  text-decoration: none;
}

.task-note-footer {
  flex: 0 0 auto;
  padding: 9px 13px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

#task-note-save-status[data-state="saved"] { color: #16834b; font-weight: 800; }
#task-note-save-status[data-state="failed"] { color: #b42318; font-weight: 800; }

#task-note-save-status[data-state="saved"]::before {
  content: "✓";
  display: inline-grid;
  width: 14px;
  height: 14px;
  margin-right: 5px;
  place-items: center;
  border-radius: 999px;
  background: #2bbf61;
  color: #fff;
  font-size: 10px;
}

.task-note-options {
  flex: 0 0 auto;
  max-height: 42%;
  overflow: auto;
  border-top: 1px solid var(--line);
  background: var(--panel);
}

.task-note-options summary {
  padding: 9px 13px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 850;
  cursor: pointer;
}

@media (max-width: 1100px) {
  body[data-view="tasks"] .todo-page.note-selected .todo-detail {
    height: auto;
    max-height: none;
  }
}

.todo-convert-note {
  display: grid;
  gap: 8px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, #f4b740 7%, var(--panel));
}

.todo-convert-note p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.todo-convert-note .ghost-button {
  justify-self: start;
}

.task-toggle-field {
  display: grid;
  gap: 7px;
}

.task-toggle-row {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
}

.task-toggle-row input {
  width: 18px;
  height: 18px;
}

body[data-view="tasks"] .todo-item-body {
  gap: 2px;
}

body[data-view="tasks"] .todo-item-title-row {
  align-items: center;
}

body[data-view="tasks"] .todo-item-title {
  display: flex;
  align-items: baseline;
  width: 100%;
  min-width: 0;
  gap: 8px;
}

body[data-view="tasks"] .todo-item-title strong {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  font-size: 14px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body[data-view="tasks"] .todo-meta {
  display: flex;
}

body[data-view="tasks"] .todo-chip {
  min-height: 18px;
  padding: 1px 6px;
  font-size: 9px;
}

body[data-view="tasks"] .todo-check {
  width: 19px;
  height: 19px;
  justify-self: center;
  border-width: 1.5px;
}

body[data-view="tasks"] .todo-item-glyph {
  width: 22px;
  min-height: 22px;
  font-size: 12px;
}

body[data-view="tasks"] .todo-disclosure,
body[data-view="tasks"] .todo-disclosure-spacer {
  display: grid;
  place-items: center;
  width: 20px;
  height: 24px;
}

body[data-view="tasks"] .todo-disclosure {
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

body[data-view="tasks"] .todo-disclosure:hover {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  color: var(--accent-dark);
}

body[data-view="tasks"] .todo-star {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  font-size: 16px;
}

body[data-view="tasks"] .todo-drag-handle {
  padding: 3px 5px;
  border-radius: 5px;
  font-size: 14px;
  opacity: 0.35;
}

body[data-view="tasks"] .todo-item:hover .todo-drag-handle,
body[data-view="tasks"] .todo-item:focus-within .todo-drag-handle {
  background: color-mix(in srgb, var(--muted) 9%, transparent);
  opacity: 1;
}

body[data-view="tasks"] .todo-item.drop-target {
  background: color-mix(in srgb, var(--accent) 7%, var(--panel));
  box-shadow: none;
}

body[data-view="tasks"] .todo-item.drop-before::after,
body[data-view="tasks"] .todo-item.drop-after::after {
  content: "";
  position: absolute;
  z-index: 4;
  right: 0;
  left: 0;
  height: 3px;
  border-radius: 999px;
  background: var(--accent);
  pointer-events: none;
}

body[data-view="tasks"] .todo-item.drop-before::after {
  top: -2px;
}

body[data-view="tasks"] .todo-item.drop-after::after {
  bottom: -2px;
}

body[data-view="tasks"] .todo-inline-add-form {
  display: grid;
  grid-template-columns: 20px 78px minmax(0, 1fr) 28px;
  gap: 6px;
  align-items: center;
  min-height: 38px;
  margin-left: calc(var(--task-depth, 0) * 24px);
  padding: 4px 6px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--accent) 5%, var(--panel));
  box-shadow: inset 3px 0 0 var(--accent);
}

body[data-view="tasks"] .todo-inline-connector {
  color: var(--accent);
  font-weight: 900;
  text-align: center;
}

body[data-view="tasks"] .todo-inline-add-type,
body[data-view="tasks"] .todo-inline-add-input {
  min-width: 0;
  min-height: 29px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  padding-inline: 8px;
  font: inherit;
  font-size: 12px;
}

body[data-view="tasks"] .todo-inline-cancel {
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
}

body[data-theme="dark"][data-view="tasks"] .todo-list-controls {
  background: rgba(13, 23, 40, 0.94);
}

body[data-theme="dark"][data-view="tasks"] .todo-inline-add-type,
body[data-theme="dark"][data-view="tasks"] .todo-inline-add-input {
  border-color: rgba(148, 169, 202, 0.34);
  background: #0a1322;
  color: #e8eef8;
}

@media (max-width: 1100px) {
  body[data-view="tasks"] .todo-page {
    grid-template-columns: minmax(210px, 235px) minmax(0, 1fr);
  }

  body[data-view="tasks"] .todo-detail {
    position: fixed;
    z-index: 92;
    top: 88px;
    right: 12px;
    bottom: 12px;
    width: min(360px, calc(100vw - 24px));
    max-height: none;
    visibility: hidden;
    pointer-events: none;
    opacity: 0;
    transform: translateX(calc(100% + 32px));
    box-shadow: 0 22px 64px rgba(15, 35, 64, 0.24);
    transition: opacity 160ms ease, transform 180ms ease, visibility 0s linear 180ms;
  }

  body[data-view="tasks"] .todo-page.detail-open .todo-detail {
    visibility: visible;
    pointer-events: auto;
    opacity: 1;
    transform: translateX(0);
    transition-delay: 0s;
  }

  body[data-view="tasks"] .todo-page.note-selected .todo-detail {
    width: min(620px, 46vw, calc(100vw - 24px));
  }
}

@media (max-width: 900px) {
  body[data-view="tasks"] .todo-page.detail-open {
    grid-template-columns: minmax(0, 1fr);
  }

  body[data-view="tasks"] .todo-page.detail-open .todo-sidebar {
    display: none;
  }
}

@media (max-width: 900px) {
  body[data-view="tasks"] .todo-commandbar {
    grid-template-columns: 1fr;
  }

  body[data-view="tasks"] .todo-list-controls {
    align-items: flex-end;
  }

  body[data-view="tasks"] .todo-outline-help {
    display: none;
  }
}

@media (max-width: 900px) {
  body[data-view="tasks"] .todo-page.note-selected .todo-detail {
    inset: 12px;
    width: auto;
  }
}

@media (max-width: 760px) {
  body[data-view="tasks"] .todo-page {
    grid-template-columns: 1fr;
  }

  body[data-view="tasks"] .todo-sidebar {
    position: static;
    max-height: 210px;
  }

  body[data-view="tasks"] .todo-detail,
  body[data-view="tasks"] .todo-page.note-selected .todo-detail {
    inset: 12px;
    width: auto;
  }

  body[data-view="tasks"] .todo-filter-button {
    flex: 1 1 0;
    min-width: 100px;
  }

  body[data-view="tasks"] .todo-item,
  body[data-view="tasks"] .todo-item.child,
  body[data-view="tasks"] .todo-inline-add-form {
    margin-left: calc(var(--task-depth, 0) * 12px);
  }

  body[data-view="tasks"] .todo-item-title span,
  body[data-view="tasks"] .todo-item p.todo-source-line {
    display: none;
  }

  body[data-view="tasks"] .todo-inline-add-form {
    grid-template-columns: 18px 68px minmax(0, 1fr) 26px;
  }
}
.tasks-client-switch {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line, #dce3ea);
  border-radius: 11px;
  background: var(--panel-soft, #f5f7fa);
}

.tasks-client-switch .text-button {
  min-height: 30px;
  padding: 5px 10px;
  border-radius: 8px;
}

.tasks-client-switch .text-button.is-active,
.tasks-client-switch .text-button[aria-pressed="true"] {
  color: #fff;
  background: var(--accent, #246bce);
}
