/* ==========================================================================
   Раздел «Задачи» (public/tasks.js)
   Страница задачи пользуется общими классами .task-steps, .task-layout,
   .task-ready, .task-msg из style.css — здесь только своё: метки, полоса
   хода, карточки списка, банк задач, форма постановки.
   ========================================================================== */

/* Метки: срочная — красная, важная — жёлтая, долговременная — серая.
   Те же цвета, что у эмодзи 🔴 🟡 ⚪ в уведомлениях и Telegram */
.tsk-mark {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px;
  border-radius: var(--pill); font-size: 12.5px; font-weight: 800; white-space: nowrap;
}
.tsk-mark::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.tsk-mark.urgent { background: var(--red-soft); color: var(--red); }
.tsk-mark.important { background: var(--amber-soft); color: var(--amber); }
.tsk-mark.important::before { background: #e0a400; }
.tsk-mark.long { background: var(--surface-inset); color: var(--text-2); }
.tsk-mark.long::before { background: #a3aa97; }

.tsk-status.st-new { background: var(--blue-soft); color: var(--blue); }
.tsk-status.st-progress { background: var(--accent-soft); color: var(--accent-ink); }
.tsk-status.st-review { background: var(--amber-soft); color: var(--amber); }
.tsk-status.st-done { background: var(--green-soft); color: var(--green); }
.tsk-status.st-declined { background: var(--red-soft); color: var(--red); }
.tsk-status.st-cancelled { background: var(--surface-inset); color: var(--text-3); }

/* Полоса хода */
.tsk-bar { flex: 1; height: 8px; border-radius: 4px; background: var(--surface-inset); overflow: hidden; }
.tsk-bar i { display: block; height: 100%; border-radius: 4px; background: var(--brand); transition: width .3s var(--ease-out); }
.tsk-bar.late i { background: #d98a1e; }

/* ---------- Список ---------- */
.tsk-head-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.tsk-chip-badge {
  min-width: 20px; height: 20px; margin-left: 6px; padding: 0 6px; border-radius: var(--pill);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 800; background: var(--badge); color: #fff;
}
.tsk-list { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.tsk-card {
  display: flex; flex-direction: column; gap: 8px; width: 100%; padding: 16px 20px;
  text-align: left; font-family: inherit; color: var(--text); cursor: pointer;
  background: var(--surface); border: 1px solid transparent; border-radius: var(--r-lg);
  box-shadow: var(--shadow-xs); transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.tsk-card:hover { border-color: var(--separator-strong); box-shadow: var(--shadow-sm); }
.tsk-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tsk-card.overdue { border-color: #e9b4b8; }
.tsk-card.waiting { border-color: var(--accent-2); box-shadow: 0 0 0 3px var(--accent-2-soft); }
.tsk-card.archived { background: var(--surface-2); box-shadow: none; }
.tsk-card-top { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.tsk-card-marks { display: contents; }
.tsk-card-title { font-size: 16px; font-weight: 800; line-height: 1.3; }
.tsk-card-wait {
  display: inline-flex; align-items: center; gap: 6px; align-self: flex-start;
  font-size: 14px; font-weight: 700; color: var(--accent-2);
}
.tsk-card-wait .icon { width: 15px; height: 15px; }
.tsk-card-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13.5px; color: var(--text-3); }
.tsk-card-meta .hot { color: var(--red); font-weight: 700; }
.tsk-card-progress { display: flex; align-items: center; gap: 10px; }
.tsk-card-progress b { min-width: 38px; font-size: 13px; font-weight: 800; text-align: right; }

.tsk-decide-block { margin: 16px 0 26px; padding: 18px; border-radius: var(--r-lg); background: var(--accent-2-soft); }
.tsk-decide-block h2 { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 17px; color: var(--orange); }
.tsk-decide-block h2 .icon { width: 18px; height: 18px; }
.tsk-decide-block .tsk-card.waiting { box-shadow: none; border-color: transparent; }

.tsk-foot { margin-top: 26px; }
.tsk-person-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin: 6px 0 4px; }
.tsk-person-bar h2 { flex: 1; margin: 0; font-size: 20px; }
.tsk-person-bar .btn-back { margin: 0; }

/* ---------- Банк задач ---------- */
.tsk-bank-tools { display: flex; gap: 10px; margin: 6px 0 14px; }
.tsk-bank-group { margin-top: 18px; }
.tsk-bank-group h2 { margin: 0 0 12px; font-size: 15px; font-weight: 800; color: var(--text-2); }
.tsk-bank-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 14px; }
.tsk-person {
  display: flex; flex-direction: column; gap: 14px; padding: 18px;
  background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-xs);
  border: 1px solid transparent;
}
.tsk-person.attention { border-color: #f0c9a8; }
.tsk-person-head { display: flex; align-items: center; gap: 12px; min-width: 0; }
.tsk-person-head .mini-avatar { width: 42px; height: 42px; font-size: 15px; }
.tsk-person-name { display: flex; flex-direction: column; min-width: 0; }
.tsk-person-name b { font-size: 15.5px; font-weight: 800; }
.tsk-person-name span { font-size: 13px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tsk-counts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.tsk-count {
  display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 8px 4px;
  border-radius: 12px; font-size: 11.5px; font-weight: 700; text-align: center;
}
.tsk-count b { font-size: 20px; font-weight: 800; line-height: 1.1; }
.tsk-count.urgent { background: var(--red-soft); color: var(--red); }
.tsk-count.important { background: var(--amber-soft); color: var(--amber); }
.tsk-count.long { background: var(--surface-inset); color: var(--text-2); }
.tsk-count.late { background: var(--orange-soft); color: var(--orange); }
.tsk-count.zero { background: var(--surface-2); color: var(--text-3); }
.tsk-person-load { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-3); }
.tsk-person-load .tsk-bar { flex: none; }
.tsk-person-actions { display: flex; gap: 8px; margin-top: auto; }
.tsk-person-actions .btn { flex: 1; min-height: 40px; }
.tsk-bank-note { margin-top: 18px; }

/* ---------- Страница задачи ---------- */
.tsk-steps { overflow-x: auto; }
.tsk-steps .task-step { min-width: 64px; }
.tsk-move .tsk-next { width: 100%; min-height: 52px; font-size: 16px; font-weight: 800; white-space: normal; }
.tsk-links { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; margin-top: 14px; font-size: 14px; }
.link-btn {
  min-height: 32px; padding: 0; border: none; background: none; cursor: pointer;
  font-family: inherit; font-size: 14px; font-weight: 700; color: var(--accent-ink);
  text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--accent-soft-2);
}
.link-btn:hover { text-decoration-color: currentColor; }
.link-btn.danger { color: var(--red); text-decoration-color: var(--red-soft); }
.tsk-jump { color: var(--text-2); }
.tsk-decide { background: var(--accent-2-soft); }
.tsk-decide p { color: var(--text); }
.tsk-decide .task-actions { flex-direction: row; flex-wrap: wrap; }
.tsk-decide .task-actions .btn { flex: 1; min-height: 44px; }
.tsk-hr { margin: 16px 0; border: none; border-top: 1px solid rgba(154, 52, 9, .18); }
.task-msg.tsk-msg-flag { background: var(--accent-2-soft); }
.task-msg.system b { font-weight: 800; color: var(--text-2); }
.tsk-msg-files { display: flex; flex-direction: column; gap: 4px; margin: 4px 0 2px; }
.tsk-msg-files .task-file { gap: 8px; }
.tsk-msg-files .task-file .muted { margin-left: 0; }
.tsk-msg-files .icon-btn { width: 30px; height: 30px; }
.tsk-attach { flex: none; cursor: pointer; }

/* ---------- Форма постановки ---------- */
.tsk-flags { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.tsk-flag {
  position: relative; display: flex; align-items: center; gap: 10px; margin: 0; padding: 12px 14px;
  border: 2px solid var(--separator); border-radius: var(--r-md); cursor: pointer;
  transition: border-color .15s var(--ease), background .15s var(--ease);
}
.tsk-flag input { width: 20px; height: 20px; margin: 0; flex: none; }
.tsk-flag span { display: flex; flex-direction: column; }
.tsk-flag b { font-size: 15px; font-weight: 800; }
.tsk-flag small { font-size: 12.5px; font-weight: 500; color: var(--text-3); }
.tsk-flag.urgent:has(input:checked) { border-color: var(--red); background: var(--red-soft); }
.tsk-flag.important:has(input:checked) { border-color: #e0a400; background: var(--amber-soft); }
.tsk-hint {
  margin: -4px 0 14px; padding: 10px 14px; border-radius: var(--r-md);
  background: var(--surface-2); font-size: 13.5px; line-height: 1.5; color: var(--text-2);
}
.tsk-hint:empty { display: none; }
.tsk-hint b { color: var(--text); }
.tsk-watch { margin-bottom: 14px; }
.tsk-watch summary { min-height: 40px; display: flex; align-items: center; gap: 6px; cursor: pointer; font-size: 14px; font-weight: 700; }
.tsk-filter { margin-bottom: 8px; }

/* ---------- Настройки уведомлений ---------- */
.tsk-set { margin-bottom: 18px; padding: 16px; border-radius: var(--r-md); background: var(--surface-2); }
.tsk-set h3 { display: flex; align-items: center; gap: 8px; margin: 0 0 6px; font-size: 15px; font-weight: 800; }
.tsk-set h3 .icon { width: 17px; height: 17px; color: var(--accent); }
.tsk-set p { margin: 0 0 12px; }
.tsk-set .task-actions { margin: 0; }
.tsk-set-line { align-items: flex-start; margin-bottom: 14px; }
.tsk-set-line input { margin-top: 3px; }
.tsk-set-line span { display: flex; flex-direction: column; gap: 2px; }

@media (max-width: 560px) {
  /* Семь шагов в ширину телефона: кружки остаются все, подпись — только
     у текущего, остальное и так сказано меткой состояния над заголовком */
  .tsk-steps { overflow: visible; padding: 16px 10px 14px; }
  .tsk-steps .task-step { min-width: 0; font-size: 12px; }
  .tsk-steps .task-step:not(.now) span { visibility: hidden; }
  .tsk-steps .task-step.now span { white-space: nowrap; }
  .tsk-card { padding: 14px 16px; }
  .tsk-flags { grid-template-columns: 1fr; }
  .tsk-head-actions { width: 100%; }
  .tsk-head-actions .btn-primary { flex: 1; }
  .tsk-bank-grid { grid-template-columns: 1fr; }
}


/* ---------- Выбор людей плитками: «Кому» и наблюдатели ----------
   Флажок спрятан, плитка — его подпись. Выбранная плитка зелёная
   с галочкой в углу, как выбранный пункт меню */
.who-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.who-count { font-size: 13px; font-weight: 800; color: var(--accent-ink); }
.who-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(185px, 1fr)); gap: 8px;
  max-height: 292px; overflow-y: auto; margin: 6px 0 16px; padding: 2px;
}
.who-tile.check-line {
  position: relative; display: flex; align-items: center; gap: 10px; margin: 0;
  min-height: 56px; padding: 8px 30px 8px 10px; border-radius: 14px; cursor: pointer;
  background: var(--surface-2); box-shadow: inset 0 0 0 1.5px var(--separator);
  transition: background .15s var(--ease), box-shadow .15s var(--ease);
}
.who-tile:hover { box-shadow: inset 0 0 0 1.5px var(--separator-strong); }
.who-tile input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.who-tile:has(input:focus-visible) { outline: 3px solid var(--brand); outline-offset: 2px; }
.who-tile:has(input:checked) { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }
.who-ava {
  width: 34px; height: 34px; flex: none; border-radius: 50%; overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800; color: #fff; background: var(--accent);
}
.who-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.who-text b {
  font-size: 14px; font-weight: 800; color: var(--text); overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.who-text small { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who-check {
  position: absolute; top: 6px; right: 6px; width: 20px; height: 20px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent); color: #fff; opacity: 0; transform: scale(.6);
  transition: opacity .15s var(--ease), transform .15s var(--ease-out);
}
.who-check .icon { width: 12px; height: 12px; stroke-width: 3; }
.who-tile:has(input:checked) .who-check { opacity: 1; transform: none; }
.who-tile.hidden { display: none !important; }
@media (max-width: 560px) {
  .who-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); max-height: 260px; }
  .who-tile.check-line { min-height: 52px; padding: 6px 26px 6px 8px; gap: 8px; }
  .who-ava { width: 30px; height: 30px; font-size: 12px; }
}
