.tasks-layout > * { min-width: 0; }
.tasks-layout > .tasks-side { align-self: stretch; }

/* Panneau Tâches : filtres et listes en pastilles au-dessus de la liste (même forme à toutes les tailles). */
.tasks-layout {
  display: flex;
  flex-direction: column;
  gap: 18px;
  max-width: 1080px;
  margin: 0 auto;
}

/* --- Filtres et listes --- */

.tasks-side {
  position: sticky;
  top: 28px;
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-top: 4px;
}
.side-group { display: flex; flex-direction: column; gap: 1px; }
.side-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 18px 0 2px;
  padding-left: 10px;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-3);
}
.side-link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  padding: 0 10px;
  border-radius: 10px;
  color: var(--text-2);
  font-size: 14px;
  text-decoration: none;
}
.side-link:hover { background: color-mix(in srgb, var(--text) 6%, transparent); color: var(--text); text-decoration: none; }
.side-link > .icon { color: var(--accent); }
.side-link.is-active { background: color-mix(in srgb, var(--text) 9%, transparent); color: var(--text); font-weight: 600; }
.side-link__label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-link__count { font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.side-link--danger .side-link__count { color: var(--danger); font-weight: 650; }
.side-link--danger > .icon { color: var(--danger); }
.dot--lg { width: 12px; height: 12px; }

@media all {
  .tasks-side {
    position: static;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    margin: 0 -8px;
    padding: 4px 8px 6px;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .tasks-side::-webkit-scrollbar { display: none; }
  .side-group { flex-direction: row; gap: 6px; }
  .side-heading { margin: 0; padding: 0; order: 1; }
  .side-heading > span { display: none; }
  .side-link {
    flex: none;
    min-height: 34px;
    padding: 0 14px;
    border: 0;
    border-radius: 999px;
    background: var(--surface);
    box-shadow: var(--shadow-sm), 0 0 0 1px color-mix(in srgb, var(--text) 5%, transparent);
    white-space: nowrap;
  }
  .side-link__label { overflow: visible; }
  .side-link.is-active { background: var(--accent-fill); color: var(--accent-on); box-shadow: none; }
  .side-link.is-active > .icon, .side-link.is-active .side-link__count { color: inherit; }
}

/* --- En-tête --- */

.sort-select { display: inline-flex; align-items: center; gap: 6px; color: var(--text-3); }
.sort-select .input { width: auto; min-height: 36px; padding-block: 5px; border: 0; border-radius: 999px; background-color: var(--fill); font-size: 14px; font-weight: 500; }

/* --- Saisie rapide --- */

.quick-add {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  padding: 5px 5px 5px 16px;
  border: 0;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm), 0 0 0 1px color-mix(in srgb, var(--text) 5%, transparent);
  color: var(--accent);
  transition: box-shadow var(--dur-fast) var(--ease);
}
.quick-add:focus-within { box-shadow: var(--shadow-sm), 0 0 0 1px var(--accent), var(--focus); }
.quick-add .input { flex: 1; min-width: 0; border: 0; background: transparent; box-shadow: none; padding-inline: 0; }

/* --- Tâches --- */

/* Liste groupée (inset grouped) : un seul bloc, séparateurs fins. */
.task-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.tasks-main > .task-list:not(:empty), .tasks-done .task-list {
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm), 0 0 0 1px color-mix(in srgb, var(--text) 5%, transparent);
}

.task {
  position: relative;
  background: var(--surface);
  transition: background-color var(--dur-fast) var(--ease), box-shadow var(--dur) var(--ease);
}
.task + .task::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  left: 48px;
  border-top: 1px solid var(--border);
}
.task:hover { background: color-mix(in srgb, var(--surface) 96%, var(--text)); }
.task__row { display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px 12px 16px; min-height: 48px; }
.task__row > .check { margin-top: -1px; }

.task--high .check:not(:checked) { border-color: var(--prio-high); }
.task--low .check:not(:checked) { border-color: color-mix(in srgb, var(--prio-low) 55%, var(--border-strong)); }

.task__grip {
  display: grid;
  place-items: center;
  width: 20px;
  height: 22px;
  margin-left: -6px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: none;
  color: var(--text-3);
  cursor: grab;
  touch-action: none;
  opacity: .55;
}
.task:hover .task__grip, .task__grip:focus-visible { opacity: 1; }
.task__grip:active { cursor: grabbing; }

.task__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
}
.task__title { overflow-wrap: anywhere; line-height: 1.4; }
.task.is-done .task__title { color: var(--text-3); text-decoration: line-through; }
.task__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.task__meta .badge--plain { font-size: 12.5px; color: var(--text-3); }
.task__meta .prio-high { color: var(--prio-high); }
.task__meta .prio-low { color: var(--text-3); }
.task__expand { margin: -4px -2px -4px 0; }
.task__title { font-size: 15px; }

@media (pointer: coarse) {
  .task__grip { width: 28px; height: 44px; margin: -11px -4px -11px -10px; }
  .task__expand { width: 44px; min-height: 44px; margin: -11px -10px -11px 0; }
  .subtask__label { min-height: 44px; }
}
@media (max-width: 767px) {
  .task__title { font-size: 17px; }
}

.task.is-dragging { z-index: 2; border-radius: 12px; box-shadow: var(--shadow-lg); transform: scale(1.015); }
.task.is-dragging::before, .task.is-dragging + .task::before { display: none; }
.is-sorting { user-select: none; -webkit-user-select: none; cursor: grabbing; }

.subtasks { list-style: none; margin: 0; padding: 0 12px 10px 44px; display: flex; flex-direction: column; gap: 2px; }
.subtask__label { display: flex; align-items: center; gap: 8px; padding: 3px 0; font-size: 14px; cursor: pointer; }
.subtask.is-done span { color: var(--text-3); text-decoration: line-through; }

.task--compact { background: none; }
.task--compact:hover { background: none; }
.task--compact + .task--compact::before { left: 34px; }
.task--compact .task__row { padding: 10px 0; min-height: 0; }
.task-list:has(.task--compact) { gap: 0; }

.tasks-done { margin-top: 16px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.tasks-done .task-list { width: 100%; }

/* --- Formulaire --- */

.prio-dot { width: 8px; height: 8px; border-radius: 50%; }
.prio-dot--high { background: var(--prio-high); }
.prio-dot--medium { background: var(--prio-medium); }
.prio-dot--low { background: var(--prio-low); }

.subtask-editor { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.subtask-editor:empty { display: none; }
.subtask-editor__row { display: flex; align-items: center; gap: 6px; }

.linked-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.linked-list a { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; }

.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { position: relative; }
.swatch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.swatch span {
  display: block;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--swatch);
  box-shadow: inset 0 0 0 2px color-mix(in srgb, #000 10%, transparent);
}
.swatch input:checked + span { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--swatch); }
.swatch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 4px; }

/* Balayage des lignes (tactile) : le fond révèle l'action. */
@media (pointer: coarse) {
  .task__row { touch-action: pan-y; }
}
.task__row { position: relative; z-index: 1; background: inherit; }
.task.is-swiping { overflow: hidden; }
.task[data-swipe="done"] { background: var(--accent-fill); }
.task[data-swipe="delete"] { background: var(--badge); }
.task[data-swipe]::after {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  color: #fff;
  font-size: 15px;
  font-weight: 650;
  opacity: .6;
  transition: opacity var(--dur-fast);
}
.task[data-swipe="done"]::after { content: "Terminer"; left: 20px; }
.task[data-swipe="delete"]::after { content: "Supprimer"; right: 20px; }
.task.is-swipe-armed::after { opacity: 1; }
.task[data-swipe] .task__row { background: var(--surface); box-shadow: var(--shadow-md); }
