/* Tâches (docs/taches.md) : le panneau des tâches à droite du fil et la fenêtre d'une tâche
   (tasks.js), les tâches planifiées et la bulle de planification (planned-ai.js), les cartes des
   tâches d'une conversation (chat-tasks.js). Aussi : l'heure des messages, les lignes du
   fil, le bandeau de diagnostic (debug.js) et l'ordre des entrées de la barre latérale (app.js). */

/* Couleurs d'état, lisibles en clair comme en sombre : au travail en orange, à valider en bleu,
   alerte en rouge, terminé en vert. */
:root { --run: #d97a00; --run-soft: #fdf1d0; --run-text: #8a4b00; --wait: #2f6fde; --wait-soft: #dfe9fb; --wait-text: #1f4fa8; --alert: #d0322b; --done: #1a7f46; --idle: #8a95a6; --badge-fg: #fff; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --run: #f0a83a; --run-soft: #3a2a0c; --run-text: #f7c977; --wait: #6aa1ff; --wait-soft: #172a4a; --wait-text: #9cc0ff; --alert: #ff5e57; --done: #5fd08e; --idle: #7d8796; --badge-fg: #1c1c1c; }
}
:root[data-theme="dark"] { --run: #f0a83a; --run-soft: #3a2a0c; --run-text: #f7c977; --wait: #6aa1ff; --wait-soft: #172a4a; --wait-text: #9cc0ff; --alert: #ff5e57; --done: #5fd08e; --idle: #7d8796; --badge-fg: #1c1c1c; }

/* Les messages à lire et les actions à valider, sur le bouton qui ouvre le panneau des tâches (écran étroit). */
.tasks-count {
  flex: none;
  min-width: 18px;
  height: 18px;
  margin-left: auto;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--alert); /* une notification : en rouge */
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.tasks-count[hidden] { display: none; }

/* Des tâches de fond travaillent pour la conversation : le point respire lentement. */
.conv-dot.tasks { background: var(--run); animation: conv-pulse 2.4s ease-in-out infinite alternate; }

/* --- Le panneau des tâches, à droite du fil (tasks.js) --- */
/* Le fil et la zone de saisie lui laissent sa largeur (--tasks-w), réglable en glissant son bord
   gauche. */
#app.tasks-side-on { --tasks-w: min(var(--tasks-pref, 360px), var(--tasks-max, 560px)); }
#app.tasks-side-on .chat > :is(.messages, .empty) { margin-right: var(--tasks-w); }
#app.tasks-side-on .composer { right: var(--tasks-w); width: auto; }
.tasks-side {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 3;
  display: none;
  flex-direction: column;
  gap: 20px;
  width: var(--tasks-w);
  padding: 16px 16px calc(24px + env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
  overscroll-behavior-y: contain;
  scrollbar-gutter: stable; /* la barre de défilement qui apparaît ne décale rien */
  border-left: 1px solid var(--line);
  background: var(--side);
}
#app.tasks-side-on .tasks-side { display: flex; }
/* Pas la place à côté du fil : par-dessus, à la demande. */
.tasks-side.over { display: flex; z-index: 7; width: min(400px, 100%); box-shadow: var(--surface-shadow); animation: tasks-side-in .24s cubic-bezier(.22, 1, .36, 1); }
@keyframes tasks-side-in { from { opacity: 0; transform: translateX(24px); } }
@media (prefers-reduced-motion: reduce) { .tasks-side.over { animation: none; } }
/* Son bord gauche : la même poignée que la barre latérale (style.css), sur sa ligne de séparation. */
.tasks-resize { display: none; right: calc(var(--tasks-w) - 7px); left: auto; }
#app.tasks-side-on .tasks-resize { display: block; }
/* Toujours affiché à côté du fil : pas de « ✕ », sauf par-dessus le fil sur un écran étroit, où il
   le referme (en haut à droite, au-dessus des sections). */
.tasks-side-close { position: absolute; top: 10px; right: 10px; z-index: 2; /* au-dessus de la barre d'icônes, dont la marge passe sous lui */ display: none; place-items: center; width: 30px; height: 30px; padding: 0; border-radius: 50%; background: none; color: var(--t2); }
/* Par-dessus le fil, une ligne est réservée en haut au ✕ (--over-top : sa hauteur depuis le bord,
   l'encoche comprise sur téléphone) ; « ‹ » de la page d'un automatisme ou d'une tâche y prend place. */
.tasks-side.over { --over-top: 10px; padding-top: calc(var(--over-top) + 38px); }
.tasks-side.over .tasks-side-close { display: grid; top: var(--over-top); }
.tasks-side.over .act-back { margin-top: -37px; }
/* Le retour et les icônes de la page ; par-dessus le fil, la place du ✕ reste libre. */
.act-topbar { display: flex; align-items: center; gap: 2px; margin: -6px 0 -4px; }
.act-topbar .act-back { margin: 0 auto 0 -8px; }
.act-topbar .act-add { margin-left: 0; }
/* Sur la ligne du premier titre, en haut à droite : à la même place, quelle que soit la première section. */
.act-hometools { position: absolute; top: 0; right: 0; z-index: 1; margin: 0; }
.tasks-home { position: relative; }
/* Par-dessus le fil (téléphone) : le titre sur la ligne du ✕, les icônes à sa gauche. */
.tasks-side.over .tasks-home { margin-top: -37px; }
.tasks-side.over .act-topbar.act-hometools { margin-top: 0; }
.tasks-side.over .act-topbar { margin-top: -37px; padding-right: 38px; }
.tasks-side.over .act-topbar .act-back { margin-top: 0; }
.tasks-side-close svg { width: 16px; height: 16px; }
.tasks-side-close:hover { background: color-mix(in srgb, var(--t1) 7%, transparent); color: var(--t1); }
.tasks-side:focus { outline: none; }

/* --- Le panneau, par activité (tasks.js) ---
   L'accueil : des sections au titre discret (« À valider » précédé d'un point rouge), le « + » à
   droite ; une ligne par automatisme et par tâche planifiée, comme les contacts d'une messagerie :
   la tuile, le nom, l'heure, le dernier message sur deux lignes, le nombre de non lus en rouge. La
   page d'un automatisme ou d'une tâche arrive en glissant depuis la droite, l'accueil revient de la
   gauche. */
.tasks-home, .tasks-page { display: flex; flex-direction: column; gap: 22px; min-width: 0; }
.tasks-page { gap: 16px; }
:is(.tasks-home, .tasks-page)[hidden] { display: none; }
.slide-in { animation: act-in .28s cubic-bezier(.22, 1, .36, 1); }
.slide-back { animation: act-back .28s cubic-bezier(.22, 1, .36, 1); }
@keyframes act-in { from { opacity: 0; transform: translateX(26px); } }
@keyframes act-back { from { opacity: 0; transform: translateX(-26px); } }
:is(.tasks-status, .act-status)[hidden] { display: none; }

.act-section { display: grid; gap: 6px; min-width: 0; }
.act-section[hidden] { display: none; }
.act-heading { display: flex; align-items: center; gap: 7px; min-height: 28px; margin: 0 2px; font-size: 13px; font-weight: 600; color: var(--t2); }
.act-add { display: grid; place-items: center; width: 28px; height: 28px; margin-left: auto; padding: 0; border-radius: 8px; background: none; color: var(--t2); }
.act-add svg { width: 17px; height: 17px; }
.act-add:hover { background: color-mix(in srgb, var(--t1) 7%, transparent); color: var(--t1); }

.act-list, .act-notices { display: grid; gap: 1px; margin: 0 -6px; padding: 0; list-style: none; }
.act-row { display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; gap: 1px 11px; padding: 9px 8px; border-radius: 13px; cursor: pointer; transition: background .15s; }
.act-row:hover { background: color-mix(in srgb, var(--t1) 5%, transparent); }
.act-row.current { background: var(--conv-active); }
:is(.act-row, .act-notice):focus-visible { outline: 2px solid color-mix(in srgb, var(--t1) 35%, transparent); outline-offset: -2px; }
.act-row > .act-tile { grid-row: span 2; }
.act-tile { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; background: var(--bg2); color: var(--t2); }
.act-tile svg { width: 19px; height: 19px; }
.act-tile:is(.auto, .new) { background: var(--wait-soft); color: var(--wait-text); }
.act-tile.planned { background: var(--run-soft); color: var(--run-text); }
.act-tile.done { background: color-mix(in srgb, var(--done) 15%, transparent); color: var(--done); }
.act-tile:is(.err, .failed) { background: color-mix(in srgb, var(--alert) 13%, transparent); color: var(--alert); }
.act-tile.paused { background: var(--bg2); color: color-mix(in srgb, var(--t2) 70%, transparent); }
.act-name { min-width: 0; padding-top: 1px; overflow: hidden; font-size: 14px; font-weight: 600; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }
.act-time { padding-top: 2px; font-size: 12px; color: var(--t2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.act-text { grid-column: 2; display: -webkit-box; min-width: 0; overflow: hidden; font-size: 13px; line-height: 1.42; color: var(--t2); -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.act-badge { grid-column: 3; grid-row: 2; align-self: center; justify-self: end; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--alert); color: #fff; font-size: 11.5px; font-weight: 700; line-height: 20px; text-align: center; font-variant-numeric: tabular-nums; }
.act-row.unread .act-text { color: var(--t1); }
.act-row.unread .act-time { color: var(--alert); font-weight: 600; }
.act-row.err .act-text { color: var(--alert); font-weight: 500; }
/* Un tour travaille dans une de ses réponses : le point vert qui respire (orange : à valider), comme
   dans la liste de gauche, devant « Réponse en cours… ». */
.act-row:is(.turn-running, .turn-waiting) .act-text { color: var(--t1); }
.act-row:is(.turn-running, .turn-waiting) .act-text::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%;
  vertical-align: 1px; background: #1f9d55; animation: conv-pulse 1.4s ease-in-out infinite alternate; }
.act-row.turn-waiting .act-text::before { background: #d97706; }
@media (prefers-reduced-motion: reduce) { .act-row .act-text::before { animation: none; } }
.act-row.paused .act-name { color: var(--t2); }
:is(.act-row, .act-notice).arrive { animation: act-arrive 1.6s ease-out; }
@keyframes act-arrive { 0%, 30% { background: color-mix(in srgb, var(--alert) 12%, transparent); } }
.act-none { margin: 0 6px; padding: 4px 2px; font-size: 13px; line-height: 1.45; color: var(--t2); list-style: none; }

/* Rien encore : deux tuiles penchées, une phrase, trois exemples à demander. */
.act-empty { display: grid; justify-items: center; gap: 4px; padding: 40px 6px 0; text-align: center; }
.act-empty[hidden] { display: none; }
.act-empty-art { display: flex; gap: 10px; margin-bottom: 14px; }
.act-empty-art .act-tile { width: 52px; height: 52px; border-radius: 16px; }
.act-empty-art .act-tile svg { width: 25px; height: 25px; }
.act-empty-art .act-tile:first-child { transform: rotate(-6deg); }
.act-empty-art .act-tile:last-child { transform: rotate(6deg); }
.act-empty-title { font-size: 15px; }
.act-empty p { margin: 0 0 12px; font-size: 13.5px; color: var(--t2); }
.act-ideas { display: grid; gap: 8px; width: 100%; }
.act-ideas button { padding: 10px 14px; border: 1px solid var(--line); border-radius: 13px; background: var(--raised); color: var(--t1); font-size: 13.5px; text-align: left; }
.act-ideas button:hover { background: color-mix(in srgb, var(--t1) 5%, var(--raised)); }

/* La page : « ‹ Automatismes », l'en-tête (tuile, nom, état, interrupteur), ce qu'il fait, un
   bandeau s'il demande quelque chose, ses réglages, puis ses notifications, par jour. */
.act-back { display: inline-flex; align-items: center; gap: 2px; align-self: flex-start; margin: -6px 0 -4px -8px; padding: 5px 10px 5px 4px; border-radius: 9px; background: none; color: var(--t2); font-size: 13px; font-weight: 600; }
.act-back svg { width: 18px; height: 18px; }
.act-back:hover { background: color-mix(in srgb, var(--t1) 6%, transparent); color: var(--t1); }
.act-head { display: grid; grid-template-columns: 46px minmax(0, 1fr) auto; gap: 12px; align-items: center; }
.act-head .act-tile { width: 46px; height: 46px; border-radius: 14px; }
.act-head .act-tile svg { width: 22px; height: 22px; }
.act-who { display: grid; gap: 3px; min-width: 0; }
.act-title { margin: 0; font-size: 16.5px; font-weight: 700; line-height: 1.3; overflow-wrap: anywhere; }
.act-desc { margin: 0; font-size: 14px; line-height: 1.5; overflow-wrap: anywhere; }
.act-prompt { display: -webkit-box; overflow: hidden; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.act-facts { margin: -8px 0 0; font-size: 13px; line-height: 1.5; color: var(--t2); }
.act-banner { display: grid; gap: 4px; padding: 12px 14px; border-radius: 13px; background: var(--wait-soft); font-size: 13.5px; line-height: 1.45; }
.act-banner.err { background: color-mix(in srgb, var(--alert) 11%, transparent); }
.act-banner.err strong { color: var(--alert); }
.act-banner span { color: var(--t2); }
.act-banner-acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.act-status { margin: -6px 0 0; }
.act-list-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 6px 2px 0; font-size: 13px; font-weight: 600; color: var(--t2); }
.act-list-head .link { padding: 0; font-size: 12.5px; }
.act-day { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 10px 8px 2px; font-size: 12px; font-weight: 600; color: var(--t2); list-style: none; }
.act-day .link { font-size: 12px; font-weight: 500; }
.act-day:first-child { margin-top: 2px; }
.act-day > span { display: inline-block; }
.act-day > span::first-letter { text-transform: uppercase; }
.act-notice { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; padding: 9px 8px 9px 24px; border-radius: 12px; cursor: pointer; transition: background .15s; }
.act-notice:hover { background: color-mix(in srgb, var(--t1) 5%, transparent); }
.act-notice.current { background: var(--conv-active); }
.act-notice::before { content: ""; position: absolute; top: 16px; left: 10px; width: 7px; height: 7px; border-radius: 50%; background: var(--line); }
.act-notice.unread::before { background: var(--alert); }
.act-notice.failed::before { background: color-mix(in srgb, var(--alert) 45%, transparent); }
.act-notice.turn-running::before { background: #1f9d55; animation: conv-pulse 1.4s ease-in-out infinite alternate; }
.act-notice.turn-waiting::before { background: #d97706; animation: conv-pulse 1.4s ease-in-out infinite alternate; }
.act-notice-text { display: -webkit-box; min-width: 0; overflow: hidden; font-size: 13.5px; line-height: 1.45; color: var(--t2); -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.act-notice.unread .act-notice-text { color: var(--t1); font-weight: 500; }
.act-notice time { padding-top: 1px; font-size: 12px; color: var(--t2); font-variant-numeric: tabular-nums; }
.act-notice.unread time { color: var(--alert); font-weight: 600; }
.act-loading { padding: 6px 8px; list-style: none; }
@media (prefers-reduced-motion: reduce) { :is(.slide-in, .slide-back, .act-row.arrive, .act-notice.arrive, .act-notice[class*="turn-"]::before) { animation: none; } }

/* Une tâche de fond en cours (taskRow) : sa tuile dit son état (au travail : un cercle qui tourne ;
   à valider ; programmée), ■ l'arrête, une fine barre suit son avancement. La petite tuile : le
   retour d'une tâche dans la conversation (reportRow). */
.act-tile.sm { width: 30px; height: 30px; border-radius: 10px; }
.act-tile.sm svg { width: 15px; height: 15px; }
.act-tile.run { background: var(--run-soft); }
.act-tile.wait { background: var(--wait-soft); color: var(--wait-text); }
.act-tile.later { background: var(--bg2); color: var(--t2); }
.act-ring { width: 18px; height: 18px; border: 2.2px solid color-mix(in srgb, var(--run) 28%, transparent); border-top-color: var(--run); border-radius: 50%; animation: act-spin .9s linear infinite; }
.act-tile.sm .act-ring { width: 15px; height: 15px; border-width: 2px; }
@keyframes act-spin { to { transform: rotate(360deg); } }
.run-row .act-stop { grid-column: 3; grid-row: 1 / span 2; align-self: center; }
.act-stop { display: grid; place-items: center; width: 30px; height: 30px; padding: 0; border-radius: 50%; background: var(--bg2); color: var(--t2); }
.act-stop svg { width: 12px; height: 12px; }
:where(.act-stop):hover { background: color-mix(in srgb, var(--alert) 12%, transparent); color: var(--alert); }
.run-row.wait .act-text { color: var(--wait-text); font-weight: 500; }
.task-progress.act-progress { grid-column: 2 / 4; height: 4px; margin-top: 7px; }
@media (prefers-reduced-motion: reduce) { .act-ring { animation: none; } }
/* Tout juste lancée (la réponse de Clik'Pilote « c'est lancé ») : elle descend à sa place, éclairée
   d'orange un instant. */
.run-row.launched { animation: act-launch .55s cubic-bezier(.2, .8, .2, 1), act-launch-glow 2.2s ease-out .15s; }
@keyframes act-launch { from { opacity: 0; transform: translateY(-12px) scale(.96); } }
@keyframes act-launch-glow { 0%, 35% { background: var(--run-soft); box-shadow: 0 0 0 1.5px color-mix(in srgb, var(--run) 45%, transparent); } }
@media (prefers-reduced-motion: reduce) { .run-row.launched { animation: none; } }

/* Dans le fil : la ligne « Nouveau message » avant le premier non lu, et les nouveaux marqués de rouge. */
.msg.assistant.is-new:not(.report-msg) { padding-left: 12px; box-shadow: inset 3px 0 0 var(--alert); }
.msg.assistant.report-msg.is-new { border-color: color-mix(in srgb, var(--alert) 45%, var(--line)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--alert) 10%, transparent); }

/* Notification à l'écran quand un message arrive (en bas à droite) : un clic ouvre son fil. */
.task-toasts { position: fixed; right: 16px; bottom: 16px; z-index: 60; display: grid; gap: 8px; width: min(360px, calc(100vw - 32px)); pointer-events: none; }
.task-toast { display: flex; align-items: flex-start; gap: 10px; width: 100%; padding: 12px 14px; border: 1px solid color-mix(in srgb, var(--alert) 30%, var(--surface-border)); border-radius: 14px; background: var(--surface); box-shadow: var(--surface-shadow); color: var(--t1); font: inherit; text-align: left; cursor: pointer; pointer-events: auto; animation: toast-in .35s cubic-bezier(.2, .8, .2, 1); }
.task-toast:hover { background: var(--surface); border-color: color-mix(in srgb, var(--alert) 55%, var(--surface-border)); }
.task-toast.out { animation: toast-out .25s ease-in forwards; }
.task-toast-icon { display: inline-grid; place-items: center; flex: none; width: 28px; height: 28px; border-radius: 8px; background: color-mix(in srgb, var(--alert) 14%, transparent); color: var(--alert); }
.task-toast-icon svg { width: 16px; height: 16px; }
.task-toast.run { border-color: color-mix(in srgb, var(--run) 35%, var(--surface-border)); }
.task-toast.run .task-toast-icon { background: var(--run-soft); color: var(--run-text); }
.task-toast.done .task-toast-icon { background: color-mix(in srgb, var(--done) 16%, transparent); color: var(--done); }
.task-toast-text { display: grid; gap: 2px; min-width: 0; font-size: 13.5px; line-height: 1.4; }
.task-toast-text strong { overflow: hidden; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.task-toast-text span { display: -webkit-box; overflow: hidden; color: var(--t2); -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(.98); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px); } }
@media (prefers-reduced-motion: reduce) { .task-toast, .task-toast.out { animation: none; } }
@media (max-width: 720px) { .task-toasts { top: max(10px, env(safe-area-inset-top)); bottom: auto; right: 16px; } }
/* Les cartes à valider tiennent dans la largeur du panneau. */
.tasks-side .task-card .card-actions { flex-wrap: wrap; }
/* L'avis du haut (double authentification…) se centre sur le fil, pas sous le panneau. */
#app.tasks-side-on .chat > .notice { margin-right: var(--tasks-w); }
/* Une page à la place du fil (Applications, Mes fichiers) : seule son entrée reste en surbrillance. */
.app:is(.apps-open, .files-open) .conv.active { background: none; }
/* Le panneau caché (écran étroit), ou par-dessus le fil : le bouton en haut à droite le rouvre. */
.tasks-peek {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  z-index: 4;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--surface-border);
  border-radius: 12px;
  background: var(--surface);
}
.tasks-peek[hidden] { display: none; }
.tasks-peek svg { width: 20px; height: 20px; color: var(--t1); }
.tasks-peek:hover { background: var(--surface); box-shadow: 0 0 0 1px color-mix(in srgb, var(--t1) 14%, transparent); }
.tasks-peek .tasks-count { position: absolute; top: -6px; right: -6px; margin: 0; box-shadow: 0 0 0 2px var(--bg); }

/* Les cartes à valider. */
.room-cards { display: grid; gap: 10px; width: 100%; max-width: 760px; }

/* La barre d'avancement d'une tâche (sa fenêtre). */
.task-progress { height: 6px; overflow: hidden; border-radius: 999px; background: var(--bg2); }
/* La barre avance par transform (--p, de 0 à 1) : pas de reflow. */
.task-progress i { display: block; height: 100%; border-radius: inherit; background: var(--run); transform: scaleX(var(--p, 0)); transform-origin: left; transition: transform .6s ease; }
@media (prefers-reduced-motion: reduce) { .task-progress i { transition: none; } }

/* Cartes à valider d'une tâche : la carte de validation du chat, en bleu « à valider ». */
.task-card { margin: 0; max-width: none; box-sizing: border-box; background: var(--wait-soft); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--wait) 45%, transparent); }
.task-card dt { color: var(--wait-text); }
.task-card .card-actions { justify-content: flex-end; }
.task-card.decided { background: var(--bg2); box-shadow: none; }
.task-card.decided.autorisee .card-status { color: var(--done); }
/* Au bas du fil d'une conversation. */
.chat-task-cards { margin: 6px auto 14px; }

/* Compte rendu : fichiers, raison d'un arrêt, suite. */
.said-reason { font-size: 13px; color: var(--t2); }
.said-files { display: flex; flex-wrap: wrap; gap: 6px; }
.said-next { font-size: 13.5px; }

/* Messages écrits par une tâche : le cadre du travail seul, l'issue des cartes, les comptes rendus
   (taskMessage). */
.msg.user .task-frame { margin-top: 6px; font-size: 12.5px; line-height: 1.45; color: var(--t2); }
.msg.user.task-note { display: grid; gap: 4px; background: var(--wait-soft); font-size: 14px; line-height: 1.5; }
.msg.user.task-note strong { font-size: 12.5px; color: var(--wait-text); }
/* Le retour des tâches de fond dans la conversation : une ligne par tâche, au dessin du panneau, sur
   toute la largeur du fil (ce n'est pas un message de l'utilisateur). */
.msg.user.task-report-note { display: grid; gap: 6px; align-self: center; width: 100%; max-width: 760px; margin: 0 auto; padding: 0; background: none; }
.task-report-row { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; align-items: center; gap: 0 10px; padding: 8px 8px 8px 10px;
  border-radius: 14px; background: var(--raised); box-shadow: 0 0 0 1px var(--line); }
.task-report-text { display: grid; min-width: 0; line-height: 1.35; }
.task-report-text strong { font-size: 12.5px; font-weight: 600; color: var(--done); }
.task-report-row.failed .task-report-text strong { color: var(--alert); }
.task-report-name { overflow: hidden; font-size: 13.5px; color: var(--t1); text-overflow: ellipsis; white-space: nowrap; }
.task-report-row .pill-button { height: 28px; padding: 0 12px; font-size: 13px; }
/* Ouverte depuis la tâche, dans le panneau : la ligne s'éclaire un instant. */
/* Le liseré vert s'allume quand le fil arrive sur la ligne (après le glissement), puis s'éteint
   doucement. */
.task-report-row.report-hit { animation: report-hit 2.6s ease-in-out; }
@keyframes report-hit {
  0% { box-shadow: 0 0 0 1px var(--line); }
  20%, 55% { box-shadow: 0 0 0 2px color-mix(in srgb, var(--done) 55%, transparent), 0 0 0 6px color-mix(in srgb, var(--done) 12%, transparent); }
  100% { box-shadow: 0 0 0 1px var(--line); }
}
/* Ouvert depuis une tâche du panneau : le fil apparaît en fondu. */
#messages.thread-in > * { animation: thread-in .3s ease-out both; }
@keyframes thread-in { from { opacity: 0; transform: translateY(6px); } }
@media (prefers-reduced-motion: reduce) { .task-report-row.report-hit, #messages.thread-in > * { animation: none; } }
/* Message d'un automatisme, compte rendu d'une tâche planifiée, dans leur fil (chat-tasks.js) : une
   carte de notification ; en tête, son icône, son nom (qui ouvre sa fenêtre) et l'heure. */
.msg.assistant.report-msg { position: relative; display: grid; gap: 8px; padding: 12px 16px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--raised); box-shadow: 0 1px 2px rgb(0 0 0 / .04); }
.report-head { display: flex; align-items: center; gap: 8px; min-width: 0; padding-right: 52px; font-size: 13px; line-height: 22px; color: var(--t2); }
.report-icon { display: inline-grid; place-items: center; flex: none; width: 22px; height: 22px; border-radius: 7px; background: var(--wait-soft); color: var(--wait-text); }
.report-icon svg { width: 14px; height: 14px; }
.report-name { min-width: 0; overflow: hidden; padding: 0; border: 0; background: none; color: var(--t1); font: inherit; font-weight: 600; text-align: left; text-overflow: ellipsis; white-space: nowrap; }
button.report-name { cursor: pointer; }
button.report-name:hover { background: none; text-decoration: underline; text-underline-offset: 2px; }
.report-state { flex: none; padding: 0 8px; border-radius: 999px; background: color-mix(in srgb, var(--alert) 14%, transparent); color: var(--alert); font-size: 12px; font-weight: 600; }
.report-body { min-width: 0; }
.report-body > :first-child { margin-top: 0; }
.report-body > :last-child { margin-bottom: 0; }
.msg.report-msg > .msg-time { position: absolute; top: 15px; right: 16px; margin: 0; }

/* --- Tâches planifiées (planned-ai.js) --- */
.routine-note { margin: 0; color: var(--wait-text); }
.routine-label, .routine-field label { font-size: 13px; font-weight: 600; color: var(--t2); }
.routine-form { display: grid; gap: 10px; }
.routine-field { display: grid; gap: 4px; min-width: 0; }
.routine-field[hidden] { display: none; }
.routine-field textarea { width: 100%; min-height: 64px; resize: vertical; }
.routine-field input { width: 100%; min-width: 0; }
.routine-time { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 6px; }
.routine-days { display: flex; flex-wrap: wrap; gap: 6px; }
.routine-day { width: 36px; height: 36px; padding: 0; border-radius: 50%; background: var(--bg2); color: var(--t1); font-weight: 600; }
.routine-day:hover:not(:disabled) { background: color-mix(in srgb, var(--t1) 9%, var(--bg2)); }
.routine-day[aria-pressed="true"], .routine-day[aria-pressed="true"]:hover { background: var(--accent); color: var(--accent-fg); }
.routine-preview { margin: 0; font-size: 13.5px; overflow-wrap: anywhere; }
.routine-preview.error { color: var(--error); }
.routine-links { display: flex; flex-wrap: wrap; gap: 14px; }
.routine-links .link { padding: 0; font-size: 13.5px; }
.drawer-task-foot { align-items: center; justify-content: space-between; flex-wrap: nowrap; gap: 10px; }
.drawer-task-foot .pill-button { flex: none; }
/* Ses droits : une ligne par action, l'interrupteur à droite ; puis le sort du reste. */
.routine-rights-box { display: grid; gap: 10px; }
.routine-rights-box > .hint { margin: 0; font-size: 13px; line-height: 1.45; }
.routine-rights-list { display: grid; gap: 2px; margin: 0 -10px; padding: 0; list-style: none; }
.routine-rights-list .switch { flex-direction: row-reverse; justify-content: space-between; width: 100%; padding: 8px 10px; border-radius: 10px; font-size: 14px; }
.routine-rights-list .switch:hover { background: color-mix(in srgb, var(--t1) 4%, transparent); }
.routine-rest { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 14px; font-size: 13.5px; font-weight: 600; color: var(--t2); }

/* --- La bulle de planification (planned-ai.js) --- */
/* Au centre de l'écran, elle se déplie ; une fois enregistrée, elle vient se poser sur la tâche
   planifiée du panneau, qui s'éclaire un instant. */
.plan-pop {
  position: fixed;
  z-index: 40;
  max-height: calc(100dvh - 90px);
  overflow-y: auto;
  padding: 16px;
  border: 1px solid var(--surface-border);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--surface-shadow);
}
.plan-pop[hidden] { display: none; }
.plan-pop.in { animation: plan-pop-in .22s cubic-bezier(.2, .8, .2, 1); }
@keyframes plan-pop-in { from { opacity: 0; transform: scale(.9) translateY(-6px); } }
.act-row.just-added { animation: plan-landed 1.2s ease; }
@keyframes plan-landed { 0%, 30% { box-shadow: 0 0 0 2px var(--run); background: color-mix(in srgb, var(--run) 10%, var(--raised)); } }
@media (prefers-reduced-motion: reduce) { .plan-pop.in, .act-row.just-added { animation: none; } }
/* Le formulaire apparaît en fondu dans la bulle. */
.plan-pop .routine-form { animation: plan-step-in .25s ease; }
@keyframes plan-step-in { from { opacity: 0; transform: translateY(4px); } }
@media (prefers-reduced-motion: reduce) { .plan-pop .routine-form { animation: none; } }
/* Téléphone : un voile clair estompe la page derrière la bulle. */
.plan-veil { position: fixed; inset: 0; z-index: 39; background: color-mix(in srgb, var(--bg) 70%, transparent); opacity: 0; pointer-events: none; transition: opacity .22s ease; }
@media (max-width: 720px), (pointer: coarse) and (max-height: 500px) and (max-width: 1000px) {
  .plan-open .plan-veil { opacity: 1; pointer-events: auto; }
}
@media (prefers-reduced-motion: reduce) { .plan-veil { transition: none; } }

/* --- Une tâche en grand (tasks.js, planned-ai.js, planned-script.js) --- */
/* La fenêtre des Paramètres (style.css : fondu, léger zoom), plus étroite. */
dialog.task-modal[open] { display: flex; flex-direction: column; }
/* À la hauteur de son contenu (fit-content, comme le navigateur par défaut : une fenêtre modale est
   ancrée en haut et en bas de l'écran, et « auto » l'étirait jusqu'à sa hauteur maximale, un grand
   vide sous le compte rendu) ; sur téléphone, plein écran (style.css). */
dialog.task-modal { width: min(680px, calc(100% - 32px)); height: fit-content; max-height: min(760px, calc(100% - 32px)); }
.task-modal-head { position: relative; display: flex; align-items: flex-start; gap: 14px; padding: 18px 60px 16px 22px; border-bottom: 1px solid var(--line); }
.task-modal-head .close { top: 12px; }
.task-modal-who { display: grid; gap: 6px; min-width: 0; }
.task-modal-title { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; min-width: 0; font-size: 14px; color: var(--t2); }
.task-modal-title strong { color: var(--t1); font-weight: 600; }
.task-modal-heading { display: -webkit-box; margin: 0; overflow: hidden; font-size: 16px; font-weight: 600; line-height: 1.35; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
/* grid-auto-rows : chaque bloc garde sa hauteur et la fenêtre défile ; une grille de hauteur fixe
   comprimerait sinon ses blocs qui coupent leur contenu. */
.task-modal-body { flex: 1; min-height: 0; overflow-y: auto; display: grid; grid-auto-rows: max-content; align-content: start; gap: 22px; padding: 20px 22px 24px; }
.task-modal-progress { display: grid; gap: 6px; }
.task-modal-progress small { font-size: 13px; color: var(--t2); }
.task-modal-section { display: grid; gap: 10px; min-width: 0; }
.task-modal-section h3 { margin: 0; font-size: 12.5px; font-weight: 600; color: var(--t2); }
.task-modal-report { display: grid; gap: 12px; font-size: 14.5px; line-height: 1.6; }
.task-modal-report p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.task-modal-foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding: 12px 22px; border-top: 1px solid var(--line); }
.pill-button.danger { color: var(--error); }
/* Le compte rendu d'abord, la consigne ensuite, discrète. */
.task-modal-ask { display: grid; gap: 6px; min-width: 0; }
.task-modal-report + .task-modal-ask { padding-top: 16px; border-top: 1px solid var(--line); }
.task-modal-prompt { margin: 0; font-size: 13.5px; line-height: 1.5; color: var(--t2); white-space: pre-wrap; overflow-wrap: anywhere; }
/* La consigne : un titre qui la déplie (repliée une fois le travail rendu), puis le texte entier sur
   un fond doux, et les droits de la tâche s'ils sortent de l'ordinaire. */
.task-ask-toggle { display: inline-flex; justify-self: start; align-items: center; gap: 4px; margin-left: -2px; padding: 2px 6px 2px 2px; border-radius: 7px;
  background: none; color: var(--t2); font-size: 12.5px; font-weight: 600; }
:where(.task-ask-toggle):hover { background: color-mix(in srgb, var(--t1) 6%, transparent); color: var(--t1); }
.task-ask-toggle svg { width: 15px; height: 15px; transform: rotate(90deg); transition: transform .2s ease; }
.task-modal-ask.folded .task-ask-toggle svg { transform: none; }
.task-ask-body { display: grid; gap: 8px; padding: 12px 14px; border-radius: 12px; background: var(--bg2); }
.task-modal-ask.folded .task-ask-body { display: none; }
.task-ask-rights { margin: 0; font-size: 12.5px; line-height: 1.45; color: var(--t2); }
/* En tête de la fenêtre d'une tâche : la tuile de son état, comme dans le panneau. */
.task-head { align-items: center; }
.task-head > .act-tile { flex: none; width: 42px; height: 42px; border-radius: 13px; }
.task-head > .act-tile svg { width: 21px; height: 21px; }
.task-head .task-modal-who { flex: 1; gap: 3px; }
.auto-state.run i { background: var(--run); box-shadow: 0 0 0 3px color-mix(in srgb, var(--run) 22%, transparent); }
/* Un fichier cité dans le compte rendu : son nom en gras dans la phrase, sa carte dessous. */
.said-file-name { font-weight: 600; overflow-wrap: anywhere; }
.task-modal-said { overflow-wrap: anywhere; }
.task-modal-said > :first-child { margin-top: 0; }
.task-modal-said > :last-child { margin-bottom: 0; }
.task-modal-said p, .task-modal-said ul, .task-modal-said ol, .task-modal-said blockquote, .task-modal-said .table { margin: 0 0 10px; }
.task-modal-said ul, .task-modal-said ol { padding-left: 22px; }
.task-modal-said li + li { margin-top: 6px; }
.task-modal-said h1, .task-modal-said h2, .task-modal-said h3, .task-modal-said h4 { margin: 16px 0 6px; font-size: 1em; font-weight: 600; }
.task-modal-report .task-modal-said p { white-space: normal; }
.task-modal-said .table { margin: 4px 0 14px; overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
.task-modal-said table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.task-modal-said th { position: sticky; top: 0; padding: 8px 12px; text-align: left; font-weight: 600; color: var(--t2); background: var(--bg2); border-bottom: 1px solid var(--line); }
.task-modal-said td { padding: 7px 12px; border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent); vertical-align: top; }
.task-modal-said tr:last-child td { border-bottom: 0; }
.task-modal-said tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--t1) 2.5%, transparent); }

/* Détail du travail d'une tâche : lecture seule, un bandeau à la place de la zone de saisie. */
.composer.read-only > :not(.task-thread-bar) { display: none; }
.task-thread-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px 14px; margin: 0 0 8px; padding: 12px 16px; border-radius: 14px; background: color-mix(in srgb, var(--t1) 4%, transparent); font-size: 13.5px; color: var(--t2); }
.task-thread-bar[hidden] { display: none; }

/* Lignes du fil : « Nouveau message », et la conversation repliée au contexte maximum du modèle
   (foldLine, app.js), en discret. */
.unread-line { display: flex; align-items: center; gap: 12px; width: 100%; max-width: 760px; margin: 4px auto; color: var(--alert); font-size: 12.5px; font-weight: 600; }
.unread-line::before, .unread-line::after { content: ""; flex: 1; height: 1px; background: color-mix(in srgb, var(--alert) 45%, transparent); }
.unread-line.fold-line { color: var(--t2); font-weight: 500; text-align: center; }
.unread-line.fold-line::before, .unread-line.fold-line::after { background: var(--line); }

/* --- Barre latérale : les entrées se réordonnent en les faisant glisser (app.js) --- */
.side-block { display: grid; gap: 2px; }
.side-nav > [data-block] { position: relative; border-radius: 10px; transition: transform .15s ease; }
.side-nav > [data-block].dragging { z-index: 2; transition: none; background: var(--side); box-shadow: 0 6px 20px rgb(0 0 0 / .14); cursor: grabbing; }
.side-nav.reordering { user-select: none; }
.side-nav.reordering > [data-block]:not(.dragging) { transition: transform .15s ease; }

/* --- Paramètres avancés (debug.js) --- */
/* Barre de diagnostic au-dessus de la zone de saisie, et la dernière requête au modèle en grand. */
.debug-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  width: fit-content;
  max-width: calc(100% - 16px);
  margin: 0 auto 8px;
  padding: 3px 4px 3px 10px;
  border-radius: 999px;
  background: var(--run-soft);
  border: 1px solid color-mix(in srgb, var(--run) 40%, transparent);
  font-size: 12px;
  color: var(--t1); /* le texte en clair sur la bulle orange, en thème sombre comme en clair */
  font-variant-numeric: tabular-nums;
}
.debug-bar[hidden] { display: none; }
.debug-item { white-space: nowrap; }
.debug-item.muted { color: inherit; }
.debug-item + .debug-item::before { content: "·"; margin: 0 7px; opacity: .6; }
.debug-size strong { font-weight: 700; }
.debug-item.folded { font-weight: 600; }
.debug-see { margin-left: 8px; padding: 2px 9px; border: 0; border-radius: 999px; background: color-mix(in srgb, var(--run) 18%, transparent); font: inherit; font-size: 12px; font-weight: 600; color: var(--t1); cursor: pointer; }
.debug-see:hover { background: color-mix(in srgb, var(--run) 28%, transparent); }
.debug-bar:not(:has(.debug-item)) { padding-left: 4px; }
.debug-bar:not(:has(.debug-item)) .debug-see { margin-left: 0; }
/* Une ligne par option, l'interrupteur à droite. */
.setting-toggle { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; text-align: left; }
.setting-toggle > div { display: grid; justify-items: start; gap: 4px; min-width: 0; flex: 1; }
.setting-toggle .settings-row-title { display: block; margin: 0; }
.setting-toggle .hint { margin: 0; line-height: 1.45; }
.setting-toggle .switch-track { margin-top: 1px; }
.debug-part { display: grid; gap: 8px; min-width: 0; }
.debug-part-head { justify-self: start; padding: 0; border: 0; background: none; font: inherit; font-size: 13px; font-weight: 600; color: var(--t2); cursor: pointer; }
.debug-part-head::before { content: "▸ "; }
.debug-part.open .debug-part-head::before { content: "▾ "; }
.debug-part:not(.open) > :not(.debug-part-head) { display: none; }
.debug-pre { margin: 0; padding: 10px 12px; border-radius: 8px; background: color-mix(in srgb, var(--t1) 4%, transparent); font-size: 12px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 420px; overflow-y: auto; }
.debug-msgs { display: grid; gap: 10px; }
.debug-msg { display: grid; gap: 4px; }
.debug-role { font-size: 11.5px; font-weight: 700; color: var(--t2); text-transform: uppercase; letter-spacing: .03em; }
.debug-msg.user .debug-role { color: var(--wait-text); }
.debug-msg.tool .debug-pre { max-height: 200px; }
dialog.debug-modal { width: min(900px, calc(100% - 32px)); }

/* --- Téléphone --- */
@media (max-width: 720px), (pointer: coarse) and (max-height: 500px) and (max-width: 1000px) {
  /* Le panneau par-dessus le fil, sur toute la largeur ; les marges écartent l'encoche et la barre
     d'état (style.css). */
  .tasks-side.over { --over-top: max(10px, env(safe-area-inset-top)); width: 100%; border-left: 0;
    padding: calc(var(--over-top) + 38px) max(16px, env(safe-area-inset-right)) calc(24px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
  dialog.task-modal { height: 100%; max-height: none; } /* plein écran, comme les Paramètres */
  .task-modal-head { padding: 16px 56px 14px 16px; }
  .task-modal-body { padding: 16px 16px 20px; }
  .task-modal-foot { padding: 12px 16px; }
}
/* Écran tactile (voir style.css) : le ✕ du panneau garde son dessin, sa zone de toucher déborde
   autour jusqu'à 44 × 44 px. */
@media (pointer: coarse) {
  .tasks-side-close::before { content: ""; position: absolute; inset: min(0px, calc(50% - 22px)); }
}

.tasks-peek.arrive { animation: peek-arrive .6s ease-out; }
@keyframes peek-arrive { 40% { transform: scale(1.15); } }

/* Clik'Pilote porte la tâche au panneau (carryTask, tasks.js) : lui, sorti du fil le temps du voyage,
   et la tâche qu'il tient sous lui. */
.pilot-hold { display: inline-block; flex: none; margin-left: -4px; }
.pilot-flier { position: fixed; z-index: 60; pointer-events: none; display: flex; flex-direction: column; align-items: flex-start; }
.pilot-flier .pilot { margin: 0; }
.task-parcel {
  display: flex; align-items: center; gap: 6px; max-width: 180px; margin: -6px 0 0 10px; padding: 4px 9px 4px 6px;
  border-radius: 9px; background: var(--raised); color: var(--t1); font-size: 12.5px; font-weight: 600; line-height: 1.2;
  box-shadow: 0 6px 18px rgb(0 0 0 / .14), 0 0 0 1px var(--line);
}
.task-parcel-icon { display: grid; place-items: center; width: 18px; height: 18px; flex: none; color: var(--t2); }
.task-parcel-icon svg { width: 15px; height: 15px; }
.task-parcel-name { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

/* Une note « Tâche terminée » qui arrive pendant qu'on lit (messages:rendered, tasks.js) : elle se déplie
   et glisse en place, au lieu d'apparaître d'un coup. */
.msg.user.task-report-note.report-arrive { animation: report-arrive .6s cubic-bezier(.2, .8, .2, 1) both; overflow: hidden; }
@keyframes report-arrive {
  from { max-height: 0; opacity: 0; transform: translateY(8px); margin-top: -8px; }
  60% { opacity: 1; }
  to { max-height: 240px; transform: none; }
}
@media (prefers-reduced-motion: reduce) { .msg.user.task-report-note.report-arrive { animation: none; } }
/* Une réponse arrivée déjà écrite pendant qu'on lit : elle glisse en place après la note. */
#messages > .msg.msg-arrive { animation: msg-arrive .5s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes msg-arrive { from { opacity: 0; transform: translateY(10px); } }
@media (prefers-reduced-motion: reduce) { #messages > .msg.msg-arrive { animation: none; } }

/* Tuile d'une tâche avec l'icône choisie par l'IA (--icon-c, tasks.js iconTile) : comme une app. */
.act-tile.glyph:not(.paused) { --icon-c: #475569; background: color-mix(in srgb, var(--icon-c) 15%, transparent); color: color-mix(in srgb, var(--icon-c) 82%, var(--t1)); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .act-tile.glyph:not(.paused) { background: color-mix(in srgb, var(--icon-c) 30%, transparent); color: color-mix(in srgb, var(--icon-c) 62%, #fff); }
}
:root[data-theme="dark"] .act-tile.glyph:not(.paused) { background: color-mix(in srgb, var(--icon-c) 30%, transparent); color: color-mix(in srgb, var(--icon-c) 62%, #fff); }

/* Historique (les tâches finies), à côté du « + » ; un point s'il y a des comptes rendus non lus. */
.act-history { position: relative; }
.act-history[hidden] { display: none; }
.act-history + .act-add { margin-left: 0; }
.act-history.unread::after { content: ""; position: absolute; top: 5px; right: 5px; width: 7px; height: 7px; border-radius: 50%; background: var(--alert); box-shadow: 0 0 0 2px var(--bg); }
.tasks-home { flex: 1 0 auto; }
/* Où en est une tâche, sur deux lignes si besoin : le point reste en face de la première. */
.act-who .auto-state { align-items: flex-start; }
.act-who .auto-state i { margin-top: 5px; }
