.chat-task-context {
  display: contents;
}

.chat-task-context .context-head {
  flex: 0 0 auto;
}

.chat-task-context .context-head .count {
  margin-right: auto;
  margin-left: 0;
}

.chat-task-context .context-head strong {
  font-weight: 500;
}

.context-new-task {
  display: inline-flex;
  min-width: 0;
  height: 30px;
  align-items: center;
  gap: 5px;
  padding: 0 9px;
  color: var(--accent-dark);
  background: color-mix(in srgb, var(--accent-soft) 76%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 18%, var(--line));
  border-radius: var(--radius-8);
  font-size: 9px;
  font-weight: 500;
  white-space: nowrap;
}

.context-new-task:hover,
.context-new-task:focus-visible,
.context-new-task[aria-expanded="true"] {
  color: var(--ink);
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 34%, var(--line));
}

.context-new-task .icon {
  width: 14px;
  height: 14px;
}

.context-filters {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 5px;
  margin: -7px 0 12px;
}

/* Две оси очереди — «Мои/Все» и «Открытые/Все» — стоят над списком ПОСТОЯННО,
   и плитами их рисовать нельзя: четыре кнопки с фоном и рамкой перевешивали
   сам список. Теперь это тихий текст, активное — цветом и тонкой чертой под
   ним (решение Эдварда 08.09). Разделитель между осями — точка, чтобы два
   «Все» подряд не читались одним переключателем. */
.workspace-scope-switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 0;
  background: transparent;
  border: 0;
}

.workspace-scope-switch + .workspace-scope-switch {
  margin-left: 4px;
  padding-left: 14px;
  border-left: 1px solid var(--line);
}

.workspace-scope-switch button {
  min-width: 0;
  height: 20px;
  padding: 0;
  color: var(--muted-2, var(--muted));
  background: transparent;
  border-radius: 0;
  font-size: 11px;
  font-weight: 500;
}

.workspace-scope-switch button:hover {
  color: var(--ink);
}

.workspace-scope-switch button.active {
  color: var(--ink);
  background: transparent;
  box-shadow: inset 0 -1px 0 0 var(--accent, currentColor);
}

.workspace-scope-switch.compact {
  flex: 0 0 auto;
}

.workspace-scope-switch.compact button {
  min-width: 0;
  height: 20px;
  padding: 0;
  font-size: 11px;
}

.context-filter-button {
  display: inline-flex;
  min-width: 30px;
  height: 30px;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 8px;
  color: var(--muted);
  background: color-mix(in srgb, var(--surface) 42%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius-8);
  font-size: 9px;
  cursor: pointer;
}

.context-filter-button.active {
  color: var(--accent-dark);
  background: var(--accent-soft);
  border-color: rgba(232, 79, 53, .24);
}

.context-filter-button .icon {
  width: 13px;
  height: 13px;
}

.context-filter-panel {
  flex: 0 0 auto;
  margin: -4px 0 12px;
  padding: 11px;
  background: color-mix(in srgb, var(--surface) 72%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius-12);
}

.context-admin-filters {
  max-height: min(430px, 54vh);
  overflow-y: auto;
  scrollbar-width: thin;
}

.context-admin-filter-toggle {
  flex: 0 0 auto;
  padding: 0;
}

.context-date-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.context-date-fields label {
  color: var(--muted);
  font-size: 9px;
}

.context-date-fields input {
  width: 100%;
  height: 31px;
  margin-top: 4px;
  padding: 0 5px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-8);
  font: inherit;
  font-size: 9px;
}

.context-filter-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 9px;
}

.context-users-head,
.context-create-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.context-users-head strong,
.context-create-head strong {
  font-size: 10px;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.context-users-head button,
.context-create-head button {
  padding: 3px;
  color: var(--muted);
  font-size: 9px;
}

.context-users-head .icon,
.context-create-head .icon {
  width: 13px;
  height: 13px;
}

.context-designers-head {
  margin: 11px 2px 3px;
}

.context-designers-head > span {
  color: var(--muted);
  font-size: 9px;
}

.context-deleted-toggle {
  display: flex;
  min-height: 32px;
  align-items: center;
  gap: 7px;
  margin-top: 8px;
  padding: 5px 6px;
  color: var(--muted);
  border-radius: var(--radius-8);
  font-size: 10px;
}

.context-deleted-toggle:hover {
  color: var(--ink-2);
  background: var(--surface-2);
}

.context-deleted-toggle input,
.context-users-list input {
  accent-color: var(--accent);
}

.context-filter-note {
  margin: 9px 2px 0;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.4;
}

.context-users-list {
  display: grid;
  max-height: 168px;
  gap: 2px;
  overflow: auto;
}

.context-users-list label {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px;
  border-radius: var(--radius-8);
  font-size: 10px;
}

.context-users-list label:hover {
  background: var(--surface-2);
}

.context-users-list input {
  accent-color: var(--accent);
}

.context-users-list p {
  margin: 8px 0;
  color: var(--muted);
  font-size: 10px;
}

.context-create-head > div {
  display: grid;
  gap: 2px;
}

.context-create-head span {
  color: var(--muted);
  font-size: 9px;
}

.context-create-modes {
  display: grid;
  gap: 3px;
}

.context-create-modes > button {
  display: grid;
  width: 100%;
  grid-template-columns: 24px minmax(0, 1fr) 12px;
  align-items: center;
  gap: 7px;
  padding: 7px;
  color: var(--ink-2);
  border-radius: var(--radius-8);
  text-align: left;
}

.context-create-modes > button:hover {
  background: var(--surface-2);
}

.context-create-modes > button > .icon:first-child {
  width: 15px;
  height: 15px;
  color: var(--accent);
}

.context-create-modes > button > .icon:last-child {
  width: 10px;
  height: 10px;
  color: var(--muted-2);
}

.context-create-modes span {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.context-create-modes strong {
  font-size: 10px;
}

.context-create-modes small {
  overflow: hidden;
  color: var(--muted);
  font-size: 8px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.standalone-create-panel {
  flex: 0 0 auto;
  margin: -4px 0 12px;
  padding: 10px;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius-12);
  transform-origin: top;
  animation: context-project-reveal 180ms ease both;
}

.standalone-create-panel[hidden] {
  display: none;
}

.context-chat-list {
  min-width: 0;
}

.context-chat-wrap.foreign .row-title {
  color: var(--accent-dark);
}

.context-chat-wrap.deleted {
  opacity: .66;
}

.context-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 18px 8px;
  color: var(--muted);
  font-size: 11px;
}

.context-loading span {
  width: 13px;
  height: 13px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: chat-context-spin 900ms linear infinite;
}

@keyframes chat-context-spin {
  to {
    transform: rotate(1turn);
  }
}

.project-group {
  min-width: 0;
  margin-bottom: 1px;
}

.project-row {
  display: grid;
  min-width: 0;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
}

.project-row,
.context-chat-wrap {
  position: relative;
}

.project-row .context-row {
  min-width: 0;
  padding-right: 7px;
}

/* Шеврон стоит СЛЕВА от названия — там, где его ищут в любом дереве, — и
   раскрывает ветку. Справа он путался с «+»: две накладки у одного края
   означали два разных действия, а выглядели одинаково. Появляется только под
   курсором. Решение Эдварда 08.09 обратное: шеврон есть только там, где есть
   что раскрыть, и раз он есть — виден всегда. Прятать его до наведения значило
   прятать сам факт, что у задачи есть работы; мышь по колонке ради этого не
   водят. Фона нет — он рисовал плитку там, где ничего не нажимается. Место под
   него отведено ВСЕГДА (отступ строки), поэтому названия не съезжают у задач
   без работ, где шеврона нет вовсе. */
.project-collapse-toggle {
  position: absolute;
  z-index: 1;
  top: 50%;
  left: 4px;
  display: grid;
  width: 16px;
  height: 16px;
  padding: 0;
  place-items: center;
  color: var(--muted-2, var(--muted));
  background: transparent;
  border-radius: var(--radius-4);
  transform: translateY(-50%);
  transition: color 150ms ease;
}

.project-row:hover .project-collapse-toggle,
.project-collapse-toggle:focus-visible {
  color: var(--muted);
}

.project-collapse-toggle:hover {
  color: var(--ink);
}

.project-collapse-toggle .icon {
  width: 12px;
  height: 12px;
  transition: transform 150ms ease;
}

.project-group.expanded .project-collapse-toggle .icon {
  transform: rotate(90deg);
}

/* «+» всплывает поверх правого края и не отбирает у названия место:
   колонкой он укорачивал строку на каждом наведении. У правого края он теперь
   один: шеврон уехал влево, к названию. */
.project-new-chat {
  position: absolute;
  top: 50%;
  right: 4px;
  display: grid;
  /* Размер общий с шевроном слева: две накладки в одной строке обязаны быть
     одного роста, иначе строка выглядит перекошенной. */
  width: 22px;
  height: 22px;
  padding: 0;
  place-items: center;
  color: var(--muted);
  background: var(--surface);
  border-radius: var(--radius-8);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-50%);
  transition: opacity 150ms ease, color 150ms ease, background 150ms ease;
  /* Длинное название уходит под кнопку растворяясь, а не обрываясь в упор. */
  box-shadow: -18px 0 12px -6px var(--paper);
}

.project-row:hover .project-new-chat,
.project-new-chat:focus-visible,
.project-new-chat[aria-expanded="true"] {
  color: var(--accent-dark);
  background: var(--accent-soft);
  opacity: 1;
  pointer-events: auto;
}

.project-new-chat .icon {
  width: 12px;
  height: 12px;
}

/* Отступ — единственное, чем видно, что работы принадлежат задаче. Раньше
   названия задачи и работы начинались почти на одной вертикали (точка съедала
   разницу), и список читался плоским. Направляющей больше нет: линия занимала
   ровно то место, которого не хватало подсветке строки. */
.project-chats {
  position: relative;
  margin: 0 0 7px;
  padding-left: 6px;
  transform-origin: top;
}

/* Проявление играет РОВНО при раскрытии ветки, а не при каждой перерисовке.
   Опрос перестраивает строку задачи на любой мелочи — сменился таймер,
   счётчик непрочитанных, дата — и ветка вместе с ней рождалась заново, а
   значит анимация запускалась снова. Со стороны это выглядело как список,
   который дёргается сам по себе. Класс вешает JS уже после вставки, поэтому в
   разметку он не попадает и лишней перестановки узла не вызывает. */
.project-chats.context-enter,
.project-create-panel.context-enter {
  animation: context-project-reveal 180ms ease both;
}

.project-group.context-enter {
  transform-origin: top;
  animation: context-project-reveal 160ms ease both;
}

.project-create-panel {
  margin: 3px 0 9px 24px;
  padding: 5px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius-12);
}

/* Список задач живёт по тем же правилам, что список диалогов ассистента:
   строка — это точка и название, больше ничего. Этап, автор, число работ и
   дата ушли в подсказку: в колонке 292 пикселя они превращали навигацию в
   таблицу, которую читают по слогам вместо того, чтобы найти нужное. */
/* Поле слева — ВНУТРИ строки, а не перед ней: коробка подсветки остаётся во
   всю ширину колонки, вправо уезжает только содержимое. Иначе фон активной
   строки начинался ровно на первой букве и выглядел обрубленным. */
.project-row .context-row,
.project-chats .context-row,
.context-chat-wrap .context-row {
  min-height: 34px;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding: 5px 7px 5px 8px;
  border-radius: var(--radius-8);
}


/* Работа съезжает на то же поле поверх своего отступа вложенности: ступенька
   между задачей и работой обязана остаться прежней, иначе поле у родителя
   съело бы иерархию. Ширина подсветки работы при этом не меняется. */
/* Место под шеврон отведено ВСЕГДА, даже когда его нет: иначе названия задач
   с работами и без стояли бы на разных вертикалях. Правило идёт ПОСЛЕ
   шортката padding выше — иначе тот сбрасывает отступ обратно на 8. */
.project-row .context-row {
  padding-left: 24px;
}

.project-chats .context-row {
  /* Ступенька между задачей и работой прежняя (14 пикселей): 6 у контейнера
     плюс 32 здесь против 24 у задачи. */
  padding-left: 32px;
}

/* В колонке навигации наведение ничего не сообщает: строк два десятка, и
   каждая под курсором меняла фон и уезжала вправо. Достаточно того, что в
   начале названия проявляется шеврон, а справа — «+». Активная строка живёт
   своим фоном и никуда не девается. */
.chat-task-context .context-row:hover {
  background: transparent;
  transform: none;
}

/* Названия прижаты к краю, и полоска активной строки легла бы прямо на первую
   букву. Активное состояние читается фоном. */
.chat-task-context .context-row.active::before {
  content: none;
}

/* Вся колонка — нежирная (решение Эдварда 22.08): заголовки задач и чатов
   одним обычным весом, вложенность читается отступом. */
.chat-task-context .context-row .row-title {
  overflow: hidden;
  font-size: var(--font-size-sm, 13px);
  font-weight: 400;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-task-context .context-row .row-tail {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  align-self: center;
  justify-content: flex-end;
  gap: 5px;
}

.chat-task-context .context-row .row-date {
  display: block;
  overflow: hidden;
  line-height: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-task-context .context-project-timer {
  color: var(--accent-dark);
  font-variant-numeric: tabular-nums;
}

.chat-task-context .context-row .row-tail > .icon {
  width: 12px;
  height: 12px;
  color: var(--muted);
}

.context-chat-wrap[draggable="true"],
.project-group[draggable="true"] {
  cursor: grab;
}

.context-chat-wrap.dragging,
.project-group.dragging {
  opacity: .42;
}

.context-chat-wrap.drop-target,
.project-group.drop-target {
  background: color-mix(in srgb, var(--accent-soft) 72%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 35%, var(--line));
}

.context-row-actions {
  position: absolute;
  z-index: 3;
  top: 50%;
  right: 4px;
  display: none;
  height: 26px;
  align-items: center;
  gap: 1px;
  padding: 0;
  background: var(--surface);
  border-radius: var(--radius-8);
  box-shadow: -18px 0 12px -6px var(--paper);
  transform: translateY(-50%);
}

.context-row-actions > span {
  padding: 0 5px;
  color: var(--muted);
  font-size: 9px;
  white-space: nowrap;
}

.context-chat-wrap:hover .context-row-actions,
.context-chat-wrap:focus-within .context-row-actions {
  display: flex;
}

.context-row-actions button {
  display: grid;
  width: 24px;
  height: 26px;
  place-items: center;
  color: var(--muted);
  background: transparent;
  border-radius: var(--radius-8);
}

.context-row-actions button:hover {
  color: var(--ink);
  background: var(--surface-2);
}

.context-row-actions button:last-child:hover {
  color: var(--accent-dark);
  background: var(--accent-soft);
}

.context-row-actions .icon {
  width: 12px;
  height: 12px;
}

.context-delete-menu {
  display: grid;
  gap: 8px;
  margin: -3px 4px 9px 25px;
  padding: 10px;
  color: var(--ink-2);
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 16%, var(--line));
  border-radius: var(--radius-12);
  transform-origin: top;
}

.context-delete-menu > strong {
  font-size: 10px;
}

.context-purge-toggle {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr);
  align-items: start;
  gap: 7px;
  padding: 6px;
  color: var(--muted);
  border-radius: var(--radius-8);
  font-size: 9px;
  line-height: 1.35;
  text-align: left;
}

.context-purge-toggle:hover {
  color: var(--ink-2);
  background: var(--surface-2);
}

.context-checkmark {
  display: grid;
  width: 14px;
  height: 14px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-4);
}

.context-purge-toggle[aria-pressed="true"] .context-checkmark {
  background: var(--accent);
  border-color: var(--accent);
}

.context-purge-toggle[aria-pressed="true"] .context-checkmark::after {
  width: 6px;
  height: 3px;
  border-bottom: 1.5px solid white;
  border-left: 1.5px solid white;
  content: "";
  transform: translateY(-1px) rotate(-45deg);
}

.context-delete-actions {
  display: flex;
  justify-content: flex-end;
  gap: 5px;
}

.context-delete-actions button {
  min-height: 26px;
  padding: 0 8px;
  color: var(--muted);
  border-radius: var(--radius-8);
  font-size: 9px;
}

.context-delete-actions button:hover {
  color: var(--ink);
  background: var(--surface-2);
}

.context-delete-actions .danger {
  color: var(--accent-dark);
  background: var(--accent-soft);
}

.context-empty {
  display: grid;
  place-items: center;
  padding: 34px 16px;
  color: var(--muted-2);
  text-align: center;
}

.context-empty > .icon {
  width: 22px;
  height: 22px;
}

.context-empty p {
  margin: 8px 0 0;
  font-size: 11px;
}

.project-chat-empty,
.context-inline-error {
  display: block;
  width: 100%;
  margin: 0;
  padding: 9px 10px;
  color: var(--muted-2);
  font-size: 10px;
  text-align: left;
}

.context-inline-error {
  color: var(--accent-dark);
  border-radius: var(--radius-8);
}

.context-inline-error:hover {
  background: var(--accent-soft);
}

.project-chat-skeleton {
  display: grid;
  gap: 7px;
  padding: 7px 5px 9px;
}

.project-chat-skeleton span {
  display: block;
  height: 46px;
  background: linear-gradient(100deg, var(--surface-2) 22%, var(--surface) 42%, var(--surface-2) 62%);
  background-size: 240% 100%;
  border-radius: var(--radius-8);
  animation: context-chat-shimmer 1.2s linear infinite;
}

.context-inline-edit {
  display: grid;
  min-height: 52px;
  grid-template-columns: minmax(0, 1fr) 28px 28px;
  align-items: center;
  gap: 4px;
  padding: 7px 4px 7px 12px;
}

.context-inline-edit input {
  width: 100%;
  min-width: 0;
  height: 34px;
  padding: 0 9px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: var(--radius-8);
  outline: none;
}

.context-inline-edit button {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  color: var(--muted);
  border-radius: var(--radius-8);
}

.context-inline-edit button:hover {
  color: var(--ink);
  background: var(--surface-2);
}

.context-inline-edit .icon {
  width: 13px;
  height: 13px;
}

@keyframes context-project-reveal {
  from {
    opacity: 0;
    transform: translateY(-5px) scaleY(.96);
  }
}

@keyframes context-chat-shimmer {
  to {
    background-position: -240% 0;
  }
}

.context-more,
.context-new-chat {
  width: 100%;
}

.chat-context-modal {
  width: min(560px, 100%);
  padding: 26px;
}

.chat-context-modal h2 {
  margin: 8px 0 24px;
  font-family: var(--serif);
  font-size: clamp(25px, 3vw, 38px);
  font-weight: 500;
  line-height: 1.08;
}

.chat-context-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.chat-context-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 22px;
}

@media (max-width: 720px) {
  .context-new-task {
    min-height: 32px;
  }

  .context-row-actions {
    display: flex;
  }

  .context-chat-wrap .context-row {
    padding-right: 86px;
  }

  .chat-context-modal {
    padding: 22px 16px calc(22px + env(safe-area-inset-bottom));
  }

  .chat-context-modal-actions .btn {
    flex: 1;
  }
}

/* На касании наведения не бывает: там шеврон обязан быть виден всегда, иначе
   свернуть задачу нечем. */
@media (prefers-reduced-motion: reduce) {
  .context-loading span,
  .project-chat-skeleton span,
  .project-chats,
  .project-group.context-enter {
    animation: none;
  }
}
