/* Mes agents : visages, bulles en haut à droite, accueil d'une conversation avec un agent,
   cartes de « Mes agents » et fenêtre « Recruter un agent ». Mêmes variables que style.css ;
   --hue est la couleur de l'agent. */

.agent-face {
  --hue: #4a5568;
  flex: none;
  display: inline-block;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
  background: color-mix(in srgb, var(--hue) 16%, var(--bg));
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 3.5px color-mix(in srgb, var(--hue) 70%, transparent);
}
.agent-face svg { display: block; width: 100%; height: 100%; }
/* Visage prédéfini : portrait recadré, plein cadre dans le rond. */
.agent-face img { display: block; width: 100%; height: 100%; object-fit: cover; pointer-events: none; user-select: none; }
.agent-face.xs { width: 18px; height: 18px; box-shadow: 0 0 0 1.5px color-mix(in srgb, var(--hue) 70%, transparent); }
.agent-face.sm { width: 24px; height: 24px; box-shadow: 0 0 0 1.5px color-mix(in srgb, var(--hue) 70%, transparent); }
.agent-face.lg { width: 48px; height: 48px; }
.agent-face.xl { width: 88px; height: 88px; box-shadow: 0 0 0 3px var(--bg), 0 0 0 6px var(--hue); }

/* --- Bulles --- */
/* Une bulle : .agent-avatar (anneau, visage, pastille), qui se secoue pour un message, et
   l'infobulle à côté. L'état vient de data-state (markBubbles, agent-tasks.js), comme la maquette :
   au travail, anneau bleu qui tourne ; attend votre validation, anneau ambre qui respire ; a
   quelque chose à vous dire, secousse régulière et pastille rouge ; disponible, bulle calme.
   Animations en transform et opacity seulement (aucun reflow) : dix bulles animées sans à-coup. */
.agent-bubble {
  --hue: var(--t2);
  position: relative;
  display: block;
  flex: none;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  background: none;
  color: var(--t1);
  transition: transform .15s ease;
}
.agent-bubble:hover { background: none; transform: translateY(-1px) scale(1.05); }
.agent-avatar { position: absolute; inset: 0; border-radius: 50%; }
.agent-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--hue) 70%, transparent);
}
.agent-bubble .agent-face { position: absolute; inset: 4px; width: auto; height: auto; box-shadow: none; }
.agent-bubble.active .agent-ring { border-width: 3px; border-color: var(--hue); }

/* Au travail : deux arcs bleus qui tournent (dégradé conique découpé en anneau par un masque). */
.agent-bubble[data-state="travaille"] .agent-ring {
  border: 0;
  background: conic-gradient(var(--run) 0 30%, transparent 30% 50%, var(--run) 50% 80%, transparent 80%);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 3px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 3px));
  animation: agent-spin 1.4s linear infinite;
}
/* Attend votre validation : anneau ambre, et un halo qui s'étend et revient (il respire). */
.agent-bubble[data-state="attend"] .agent-ring { border: 3px solid var(--wait); }
.agent-bubble[data-state="attend"] .agent-avatar::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--wait);
  opacity: 0;
  animation: agent-breathe 1.8s ease-in-out infinite;
}
/* A quelque chose à vous dire : anneau rouge et petite secousse régulière. */
.agent-bubble[data-state="message"] .agent-ring { border: 3px solid var(--alert); }
.agent-bubble[data-state="message"] .agent-avatar { animation: agent-buzz 3.2s ease-in-out infinite; }

@keyframes agent-spin { to { transform: rotate(360deg); } }
@keyframes agent-breathe {
  0%, 100% { opacity: .5; transform: scale(1); }
  50% { opacity: 0; transform: scale(1.36); }
}
@keyframes agent-buzz {
  0%, 82%, 100% { transform: rotate(0); }
  84% { transform: rotate(-11deg); }
  86% { transform: rotate(10deg); }
  88% { transform: rotate(-8deg); }
  90% { transform: rotate(6deg); }
  92% { transform: rotate(-3deg); }
  94% { transform: rotate(0); }
}

/* Pastille : comptes rendus non lus (rouge) ou cartes à valider (ambre) ; sans rien à compter, un
   point d'état (bleu au travail, gris disponible). */
.agent-count {
  position: absolute;
  top: -3px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  box-sizing: border-box;
  border-radius: 999px;
  background: var(--wait);
  color: var(--badge-fg);
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  box-shadow: 0 0 0 2px var(--bg);
  pointer-events: none;
}
.agent-count.unread { background: var(--alert); color: #fff; }
.agent-dot {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--idle);
  box-shadow: 0 0 0 2px var(--bg);
  pointer-events: none;
}
.agent-dot.travaille { background: var(--run); }

/* « +N » : les autres agents (vue Équipe), avec l'état le plus pressant d'entre eux. */
.agent-more .agent-ring { border-color: transparent; }
.agent-more-n {
  position: absolute;
  inset: 3px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--bg2);
  font-size: 12.5px;
  font-weight: 600;
}
.agent-more:hover .agent-more-n { background: color-mix(in srgb, var(--t1) 9%, var(--bg2)); }
/* Survol : le prénom et le métier, sous la bulle. */
.agent-tip {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 5;
  display: grid;
  gap: 1px;
  width: max-content;
  max-width: 220px;
  padding: 7px 10px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--surface-border);
  box-shadow: var(--surface-shadow);
  color: var(--t1);
  font-size: 12.5px;
  text-align: left;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-3px);
  transition: opacity .12s, transform .12s;
}
.agent-tip strong { font-size: 14px; }
.agent-tip > span { color: var(--t2); }
.agent-bubble:hover .agent-tip, .agent-bubble:focus-visible .agent-tip { opacity: 1; transform: none; }
@media (hover: none) { .agent-tip { display: none; } }
/* Animations réduites : rien ne bouge ; l'état se lit à la couleur de l'anneau et à la pastille. */
@media (prefers-reduced-motion: reduce) {
  .agent-bubble, .agent-tip { transition: none; }
  .agent-bubble:hover { transform: none; }
  .agent-ring, .agent-avatar, .agent-avatar::before { animation: none !important; }
}


/* Annonces aux lecteurs d'écran (un agent attend, a quelque chose à dire) : invisibles à l'écran. */
.agent-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* L'avis du haut (double authentification, IA à paramétrer) passe sous les bulles, qui flottent
   par-dessus le fil (et sous le bouton menu sur téléphone). */
.notice { margin-top: 62px; }
.messages { padding-top: 62px; }

/* --- Conversation avec un agent --- */
.agent-hidden { display: none !important; }
.agent-intro { display: grid; justify-items: center; gap: 6px; }
.agent-intro .agent-face { margin-bottom: 8px; }
.agent-intro-name { margin: 0; font-size: 26px; line-height: 1.25; font-weight: 600; }
.agent-intro-job { margin: 0; color: var(--t2); font-size: 15px; }
.agent-chip {
  display: flex;
  align-items: center;
  gap: 7px;
  width: fit-content;
  margin: 0 0 8px 8px;
  padding: 3px 4px 3px 6px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--surface-border);
  font-size: 13px;
  color: var(--t1);
}
.agent-chip-close { display: grid; place-items: center; width: 20px; height: 20px; padding: 0; border-radius: 50%; background: none; color: var(--t2); }
.agent-chip-close svg { width: 12px; height: 12px; }
.agent-chip-close:hover { background: color-mix(in srgb, var(--t1) 10%, transparent); color: var(--t1); }
.agent-who {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 760px;
  width: 100%;
  margin: 4px auto -6px;
  font-size: 13.5px;
  color: var(--t1);
}
.agent-who span { color: var(--t2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv .agent-face.xs { margin-right: 4px; }

/* --- Recruter, modifier un agent : à la place du contenu de la page Agents --- */
.agents-home.editing > :not(.agent-editor) { display: none !important; }
.agent-editor { display: grid; gap: 16px; width: 100%; max-width: 720px; }
.agent-editor[hidden] { display: none; }


.template-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.template-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--t1) 3.5%, transparent);
  border: 1px solid transparent;
  color: var(--t1);
  text-align: left;
}
.template-card:hover { background: color-mix(in srgb, var(--hue, var(--t1)) 8%, transparent); border-color: color-mix(in srgb, var(--hue, var(--t1)) 30%, transparent); }
.template-text { display: grid; gap: 3px; min-width: 0; font-size: 13px; color: var(--t2); line-height: 1.45; }
.template-text strong { font-size: 14.5px; color: var(--t1); }
.template-missing { color: #b45309; font-size: 12px; }
.blank-face { display: grid !important; place-items: center; font-size: 22px; color: var(--t2); box-shadow: inset 0 0 0 1.5px var(--line); }
.blank-face svg { width: 22px; height: 22px; }

.agent-form { display: grid; gap: 16px; }
.agent-card input, .agent-card textarea { background: var(--raised); }
.agent-identity { display: flex; align-items: center; gap: 22px; }
.agent-identity-fields { flex: 1; display: grid; gap: 10px; min-width: 0; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch {
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 50%;
  background: var(--swatch);
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / .12);
}
.swatch:hover { background: var(--swatch); transform: scale(1.08); }
.swatch.active { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--t1); }

.agent-tools { display: grid; gap: 2px; }
.agent-tool {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  color: var(--t1);
  cursor: pointer;
}
.agent-tool:hover { background: color-mix(in srgb, var(--t1) 4%, transparent); }
.agent-tool .switch { margin-left: auto; flex: none; }
.agent-tool .tool-icon { display: inline-flex; flex: none; }
.agent-tool .tool-icon svg { width: 18px; height: 18px; }
.agent-tool .tool-icon.plain { color: var(--t2); }
.agent-tool-text { display: grid; min-width: 0; font-size: 13px; color: var(--t2); line-height: 1.4; }
.agent-tool-text strong { font-size: 14px; color: var(--t1); font-weight: 500; }
.agent-tool.gone .agent-tool-text { opacity: .7; }
.agent-form-foot { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 10px; }

@media (max-width: 720px), (pointer: coarse) and (max-height: 500px) and (max-width: 1000px) {
  /* Sur téléphone : les bulles en haut à droite, en face du bouton menu. */
  /* Applications, Agents, Mes fichiers (apps.css) : le titre passe sous les bulles, qui ne le recouvrent plus. */
  .apps-home { padding-top: calc(58px + env(safe-area-inset-top)); }
  .apps-title { padding-left: 0; }
  .agent-bubble { width: 38px; height: 38px; }
  .agent-identity { gap: 16px; }
  .agent-face.xl { width: 72px; height: 72px; }
  .template-grid { grid-template-columns: 1fr; }
}

/* --- Tâches confiées, tiroir de l'agent, file « À valider » (agent-tasks.js) --- */
/* Couleurs d'état, lisibles en clair comme en sombre : au travail en orange, à valider en bleu,
   message en rouge, disponible (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; }



/* Le tiroir : un panneau à droite, plein écran sur téléphone. */
dialog.agent-drawer {
  position: fixed;
  inset: 0 0 0 auto;
  width: min(440px, 100%);
  max-width: 100%;
  height: 100%;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  border-left: 1px solid var(--surface-border);
  background: var(--bg);
  color: var(--t1);
  box-shadow: var(--surface-shadow);
  overflow: hidden;
}
dialog.agent-drawer[open] { display: flex; flex-direction: column; }
dialog.agent-drawer::backdrop { background: rgb(0 0 0 / .3); }
.drawer-head {
  --hue: var(--t2); /* la file commune ; le tiroir d'un agent prend sa couleur */
  display: grid;
  gap: 10px;
  padding: calc(18px + env(safe-area-inset-top, 0px)) 20px 14px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, color-mix(in srgb, var(--hue) 14%, transparent), transparent);
}
.drawer-who { display: flex; align-items: center; gap: 12px; min-width: 0; }
.drawer-title { flex: 1; min-width: 0; }
.drawer-title h2 { margin: 0; font-size: 21px; line-height: 1.25; overflow-wrap: anywhere; }
.drawer-title p { margin: 2px 0 0; color: var(--t2); font-size: 14px; overflow-wrap: anywhere; }
.drawer-head .close { align-self: flex-start; display: grid; place-items: center; flex: none; width: 34px; height: 34px; padding: 0; border-radius: 50%; background: none; color: var(--t2); }
.drawer-head .close svg { width: 18px; height: 18px; }
.drawer-head .close:hover { background: var(--bg2); color: var(--t1); }
/* En-tête du tiroir d'un agent : portrait cerclé de sa couleur, outils en étiquettes, autonomie et état. */
.agent-face.portrait { width: 64px; height: 64px; box-shadow: 0 0 0 3px var(--bg), 0 0 0 5.5px var(--hue); }
.drawer-tools { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.drawer-tools li {
  padding: 2px 8px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--t1) 7%, transparent);
  font: 12px/18px ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color: var(--t1);
}
.drawer-tools li.none { font-family: inherit; color: var(--t2); }
.drawer-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin: 0; font-size: 13px; color: var(--t2); overflow-wrap: anywhere; }
.drawer-actions { justify-content: flex-start; gap: 8px; }
.drawer-body {
  flex: 1;
  overflow-y: auto;
  display: grid;
  align-content: start;
  gap: 22px;
  padding: 16px 20px calc(28px + env(safe-area-inset-bottom, 0px));
}
.drawer-section h4 { margin: 0 0 8px; font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--t2); }
.drawer-task { display: grid; gap: 8px; }
.drawer-task textarea { width: 100%; box-sizing: border-box; min-height: 72px; resize: vertical; }
.drawer-task-foot { align-items: center; justify-content: space-between; flex-wrap: nowrap; gap: 10px; }
.drawer-task-foot .hint { margin: 0; font-size: 12.5px; }
.drawer-task-foot .pill-button { flex: none; }
.drawer-empty { margin: 0; }

/* Cartes à valider : la carte de validation du chat, en ambre. */
.drawer-cards { display: grid; gap: 12px; }
.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); }
.card-actions { justify-content: flex-end; }
.task-card.decided { background: var(--bg2); box-shadow: none; }
.task-card.decided.autorisee .card-status { color: var(--done); }

/* Ce qu'il vous dit : les comptes rendus récents. */
.drawer-said { display: grid; gap: 10px; }
.said {
  display: grid;
  gap: 6px;
  padding: 10px 12px;
  border-left: 3px solid var(--hue, var(--t2));
  border-radius: 0 12px 12px 0;
  background: color-mix(in srgb, var(--t1) 3.5%, transparent);
  font-size: 14.5px;
}
.said p { margin: 0; overflow-wrap: anywhere; }
.said time { overflow: hidden; font-size: 12px; color: var(--t2); text-overflow: ellipsis; white-space: nowrap; }
.said-reason { font-size: 13px; color: var(--t2); }
.said-labels, .said-files { display: flex; flex-wrap: wrap; gap: 6px; }
.said-labels span { padding: 1px 8px; border-radius: 6px; background: var(--bg2); font-size: 12px; color: var(--t2); }
.said-next { font-size: 13.5px; }
.said .link, .task-actions .link { justify-self: start; padding: 0; font-size: 13px; }

/* Ses tâches. */
.drawer-tasks { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.task-item { display: grid; gap: 6px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; font-size: 14px; }
.task-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; min-width: 0; }
.task-prompt { display: -webkit-box; min-width: 0; overflow: hidden; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.task-item small { font-size: 12.5px; color: var(--t2); }
.task-chip { flex: none; padding: 2px 9px; border-radius: 999px; background: var(--bg2); color: var(--t2); font-size: 12px; font-weight: 600; white-space: nowrap; }
.task-chip.run { background: var(--run-soft); color: var(--run-text); }
.task-chip.wait { background: var(--wait-soft); color: var(--wait-text); }
.task-chip.done { background: color-mix(in srgb, var(--done) 16%, transparent); color: var(--done); }
.task-chip.fail { background: color-mix(in srgb, var(--alert) 14%, transparent); color: var(--alert); }
.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; }
.task-actions { display: flex; flex-wrap: wrap; gap: 14px; }
.task-actions .link.armed { color: var(--error); font-weight: 600; }
@media (prefers-reduced-motion: reduce) { .task-progress i { transition: none; } }

/* Fil d'une tâche : le cadre du travail seul, et l'issue des cartes (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); }

/* --- Tâches planifiées (agent-routines.js) : dans le tiroir, la liste et le formulaire --- */
.routine-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.routine-list:empty { display: none; }
.routine-item { display: grid; gap: 6px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; font-size: 14px; }
.routine-item.paused { background: color-mix(in srgb, var(--t1) 3%, transparent); }
.routine-item small { font-size: 12.5px; color: var(--t2); }
.routine-when { display: flex; align-items: center; gap: 6px; min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.routine-icon { display: inline-grid; flex: none; width: 16px; height: 16px; color: var(--hue, var(--t2)); }
.routine-icon svg { width: 100%; height: 100%; }
.routine-prompt { display: -webkit-box; margin: 0; overflow: hidden; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.routine-item .routine-note { color: var(--wait-text); }
.routine-add { justify-content: flex-start; }
.routine-section .drawer-empty + .routine-add, .routine-list + .drawer-empty { margin-top: 0; }
.routine-section { display: grid; gap: 10px; }
.routine-section h4 { margin-bottom: -2px; }
.routine-planner { display: grid; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.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 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-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 11em); gap: 10px; }
.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-source { margin: 0; padding: 8px 10px; border-radius: 8px; background: var(--wait-soft); color: var(--wait-text); font-size: 13px; }
.routine-preview { margin: 0; font-size: 13.5px; overflow-wrap: anywhere; }
.routine-preview.error { color: var(--error); }
.routine-hint { margin: 0; font-size: 12.5px; }
.routine-links { display: flex; flex-wrap: wrap; gap: 14px; }
.routine-links .link { padding: 0; font-size: 13.5px; }
/* Dans les listes de tâches : celles qu'une routine a lancées. */
.task-routine { padding: 0 6px; border-radius: 6px; background: color-mix(in srgb, var(--hue, var(--t2)) 14%, transparent); font-size: 11.5px; font-weight: 600; color: var(--t2); }
/* --- Chef d'équipe (A6, agent-tasks.js) --- */
.lead-chip { display: inline-block; padding: 0 7px; border-radius: 6px; background: color-mix(in srgb, var(--hue, var(--t2)) 16%, transparent); color: var(--t1); font-size: 12px; font-weight: 600; white-space: nowrap; }
.lead-switch { margin-top: 6px; }
/* Sous la tâche d'un chef : ses sous-tâches, une ligne par agent. */
.task-team { display: grid; gap: 6px; margin: 2px 0 0; padding: 8px 0 0 10px; border-left: 2px solid color-mix(in srgb, var(--hue, var(--t2)) 40%, transparent); list-style: none; }
.task-team-item { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; column-gap: 8px; row-gap: 4px; font-size: 13px; }
.task-team-item .agent-face.xs { grid-column: 1; }
.task-team-text { grid-column: 2; min-width: 0; overflow: hidden; color: var(--t2); text-overflow: ellipsis; white-space: nowrap; }
.task-team-text strong { color: var(--t1); font-weight: 600; }
.task-team-item .task-chip { grid-column: 3; }
.task-team-item .task-progress, .task-team-item small { grid-column: 1 / -1; }
/* Compte rendu regroupé : l'issue de chaque sous-tâche. */
.said-team { display: grid; gap: 8px; margin: 2px 0 0; padding: 0; list-style: none; }
.said-team li { display: grid; gap: 3px; min-width: 0; }
.said-team-who { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 13.5px; }
.said-team-who strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.said-team p { margin: 0 0 0 24px; font-size: 13.5px; color: var(--t2); overflow-wrap: anywhere; }

/* Recruter, Modifier : à la place du fil (agents-page.js). */
.app.agents-open .chat > :not(.topbar, .agents-home) { display: none !important; }

@media (max-width: 720px), (pointer: coarse) and (max-height: 500px) and (max-width: 1000px) {
  /* Plein écran : les marges écartent l'encoche sur le côté en paysage (style.css), le ✕ du tiroir
     la barre d'état. */
  dialog.agent-drawer { width: 100%; border-left: 0; }
  .drawer-head, .drawer-body { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
  .drawer-head .close { top: calc(14px + env(safe-area-inset-top)); right: max(14px, env(safe-area-inset-right)); }
  .drawer-task-foot { flex-wrap: wrap; }
  .routine-grid { grid-template-columns: minmax(0, 1fr); }
  .routine-planner { padding: 10px; }
}
/* Écran tactile (voir style.css) : bulles et ✕ gardent leur dessin, leur zone de toucher
   déborde autour jusqu'à 44 × 44 px. */
@media (pointer: coarse) {
  :is(.agent-bubble, .drawer-head .close, .editor-back)::before {
    content: "";
    position: absolute;
    inset: min(0px, calc(50% - 22px));
  }
}

/* --- Fiche de poste : visage, prénom déjà pris --- */
.agent-identity-face { flex: none; display: grid; justify-items: center; gap: 4px; }
/* Prénom déjà pris par un autre agent : signalé sous le champ Prénom. */
.name-taken { margin: -4px 0 0; line-height: 1.45; }
.name-taken[hidden] { display: none; }
.name-taken .link { display: inline; padding: 0; color: var(--t1); text-decoration: underline; text-underline-offset: 2px; font-size: inherit; }
/* Mention « Agent IA », près du visage (AI Act : transparence). */
.ai-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  margin-top: 5px;
  padding: 0 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--t2);
  font-size: 11.5px;
  font-weight: 600;
  line-height: 18px;
  white-space: nowrap;
}
.agent-intro .ai-badge { margin: -4px 0 2px; }



/* --- Fiche d'un agent : même grille que les cartes des Paramètres --- */
.agent-editor { max-width: 760px; gap: 20px; margin-inline: auto; justify-self: center; }
/* En-tête : lien « ← Agents » cliquable en entier, puis le titre de l'écran. */
.agent-editor-head { display: grid; justify-items: start; gap: 6px; }
.editor-back { display: inline-flex; align-items: center; gap: 4px; line-height: 1; height: 32px; margin-left: -10px; padding: 0 12px 0 6px; border-radius: 999px; background: none; color: var(--t2); font-size: 14px; font-weight: 500; }
.editor-back:hover { background: var(--bg2); color: var(--t1); }
.editor-back-icon { display: inline-flex; }
.editor-back > span:last-child { line-height: 1; }
.editor-back-icon svg { display: block; width: 18px; height: 18px; }
.editor-title { margin: 0; font-size: 24px; line-height: 1.25; font-weight: 600; color: var(--t1); outline: none; }
.agent-form { gap: 14px; }
.agent-card { gap: 14px; padding: 18px 20px; }
.agent-card h3.settings-row-title { margin: 0; font-size: 15px; }
.agent-card .settings-card-head { min-height: 0; }
.agent-card .card-hint { margin: -8px 0 0; font-size: 13px; }
/* Identité : visage, puis prénom et métier côte à côte, couleur en dessous. */
.agent-identity { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: start; gap: 24px; }
.agent-identity .agent-face.xl { width: 72px; height: 72px; }
.agent-identity-face { gap: 8px; padding-top: 4px; }
.agent-identity-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.agent-field { display: grid; gap: 6px; min-width: 0; font-size: 12.5px; color: var(--t2); }
.agent-field-wide { grid-column: 1 / -1; }
.agent-field input { height: 38px; font-size: 14px; color: var(--t1); }
.agent-color-row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px 16px; }
.agent-color-row .swatch { width: 24px; height: 24px; }
/* Consignes : compteur discret, à droite sous le champ. */
.agent-card textarea { min-height: 150px; padding: 12px 14px; font-size: 14px; line-height: 1.55; resize: vertical; }
.agent-card textarea + .hint { justify-self: end; margin: -6px 0 0; font-size: 12px; }
/* Outils : lignes séparées, interrupteur aligné. */
.agent-card .agent-tools { gap: 0; margin: 0 -10px; }
.agent-card .agent-tool { padding: 10px; }
.agent-card .agent-tool + .agent-tool { border-top: 1px solid color-mix(in srgb, var(--line) 70%, transparent); border-radius: 0; }
.agent-card .field { display: grid; gap: 8px; padding-top: 14px; border-top: 1px solid var(--line); }
.agent-card .field .hint { margin: 0; font-size: 13px; }
.agent-form-foot { padding-top: 0; }
.agent-form-foot .pill-button { height: 38px; padding: 0 20px; font-size: 14px; }
@media (max-width: 720px) {
  .agent-identity { grid-template-columns: 1fr; gap: 16px; }
  .agent-identity-face { justify-items: start; }
  .agent-identity-fields { grid-template-columns: 1fr; }
  .agent-card { padding: 16px; }
}
/* Sur un grand écran : Identité puis Consignes à gauche, Outils et autonomie à droite. */
@media (min-width: 1100px) {
  .agent-editor { max-width: 1180px; }
  /* Consignes prend la hauteur qui reste à gauche : pas de trou sous Identité. */
  .agent-form { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); grid-template-rows: auto 1fr; align-items: start; }
  .agent-form > :not(.agent-card) { grid-column: 1 / -1; }
  .agent-form > .agent-card:nth-child(1) { grid-column: 1; grid-row: 1; }
  .agent-form > .agent-card:nth-child(2) { grid-column: 1; grid-row: 2; align-self: stretch; grid-template-rows: auto auto minmax(220px, 1fr) auto; }
  .agent-form > .agent-card:nth-child(3) { grid-column: 2; grid-row: 1 / span 2; align-self: stretch; align-content: start; }
  .agent-form > .agent-card:nth-child(2) textarea { height: 100%; min-height: 220px; resize: none; }
  /* Prénom, métier et couleur l'un sous l'autre : le métier n'est plus coupé. */
  .agent-identity-fields { grid-template-columns: minmax(0, 1fr); }
}

/* Fiche : le visage est un bouton ; le panneau des visages (filtres, grille) se déplie sous l'identité. */
.face-pick { position: relative; display: block; padding: 0; border: 0; border-radius: 50%; background: none; cursor: pointer; }
.face-pick:hover { background: none; }
.face-pick:focus-visible { outline: 2px solid var(--t1); outline-offset: 8px; }
.face-pick-edit {
  position: absolute; right: -2px; bottom: -2px; display: grid; place-items: center; width: 26px; height: 26px;
  border-radius: 50%; background: var(--surface); color: var(--t1); box-shadow: 0 0 0 2px var(--bg), 0 1px 3px rgb(0 0 0 / .18);
}
.face-pick-edit svg { width: 14px; height: 14px; }
.face-pick-hint {
  position: absolute; inset: 0; display: grid; place-items: center; border-radius: 50%;
  background: rgb(0 0 0 / .45); color: #fff; font-size: 12px; font-weight: 600; opacity: 0; transition: opacity .15s;
}
.face-pick:hover .face-pick-hint, .face-pick:focus-visible .face-pick-hint { opacity: 1; }
.face-panel { display: grid; gap: 12px; padding: 14px; border-radius: 12px; background: var(--bg2); }
.face-panel[hidden] { display: none; }
.face-panel-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.face-filters { display: flex; flex-wrap: wrap; gap: 6px; }
.face-filter {
  height: 28px; padding: 0 12px; border: 0; border-radius: 999px; font-size: 12.5px;
  background: var(--bg); color: var(--t2); box-shadow: inset 0 0 0 1px var(--line); cursor: pointer;
}
.face-filter:hover { background: var(--bg); color: var(--t1); }
.face-filter[aria-pressed="true"] { background: var(--t1); color: var(--bg); box-shadow: none; }
.face-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); gap: 10px; justify-items: center;
  max-height: 320px; overflow-y: auto; padding: 4px; overscroll-behavior: contain;
}
.face-option[hidden] { display: none; }
.face-option {
  width: 56px; height: 56px; padding: 0; border: 0; border-radius: 50%; overflow: hidden;
  background: var(--bg); box-shadow: inset 0 0 0 1px var(--line); cursor: pointer; transition: transform .12s;
}
.face-option:hover { background: var(--bg); transform: scale(1.06); }
.face-option.active { box-shadow: 0 0 0 2px var(--bg2), 0 0 0 4px var(--t1); }
.face-option:focus-visible { outline: 2px solid var(--t1); outline-offset: 2px; }
.face-option img { display: block; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
@media (prefers-reduced-motion: reduce) { .face-pick-hint, .face-option { transition: none; } }

/* --- Page d'un agent (agent-tasks.js) : son fil, façon messagerie, et ses tâches à droite --- */
#app:is(.agent-room, .room-leaving) { --room-w: var(--room-pref, 340px); } /* room-leaving : le temps que l'en-tête et le panneau s'en aillent */
/* En-tête en verre : il flotte par-dessus le fil, qui défile dessous, flouté. Le fil lui garde sa
   place en haut (--room-head-h, mesurée par agent-tasks.js). */
.room-head {
  order: -1;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  position: absolute;
  top: 0;
  left: 0;
  right: var(--room-w);
  z-index: 5;
  padding: 12px 20px;
  border-bottom: 1px solid color-mix(in srgb, var(--t1) 8%, transparent);
  background: color-mix(in srgb, var(--bg) 68%, transparent);
  -webkit-backdrop-filter: blur(18px) saturate(1.8);
  backdrop-filter: blur(18px) saturate(1.8);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) { .room-head { background: var(--bg); } }
.agent-room .messages { padding-top: calc(var(--room-head-h, 69px) + 20px); }
/* Téléphone : le bouton menu flottant (style.css, .topbar) reste au-dessus de l'en-tête en verre. */
.agent-room .topbar { z-index: 6; }
.room-head .agent-face { flex: none; width: 44px; height: 44px; box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--hue); }
.room-who { flex: 1; min-width: 0; }
.room-who h2 { margin: 0; font-size: 16px; line-height: 1.3; }
.room-name { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.room-who p { margin: 1px 0 0; font-size: 13px; color: var(--t2); overflow-wrap: anywhere; }
.room-tools { display: flex; align-items: center; gap: 4px; }
.room-tools .icon-btn { color: var(--t2); }
.room-tools .icon-btn:hover { background: color-mix(in srgb, var(--t1) 7%, transparent); }
.room-toggle { display: none; height: 30px; font-size: 12.5px; }
.agent-room .agent-chip, .agent-room .agent-who { display: none; }
.agent-room .messages, .agent-room .empty { margin-right: var(--room-w); }
.agent-room .composer { right: var(--room-w); width: auto; }
/* Messagerie : les réponses de l'agent en bulles à gauche, les vôtres à droite. */
.agent-room .msg.assistant {
  align-self: flex-start;
  width: auto;
  max-width: min(680px, 85%);
  margin-left: max(0px, calc((100% - 760px) / 2));
  padding: 10px 14px;
  border: 1px solid var(--surface-border);
  border-radius: 4px 14px 14px 14px;
  background: var(--surface);
}
.agent-room .msg.user { border-radius: 14px 4px 14px 14px; }
.room-cards { display: grid; gap: 10px; width: 100%; max-width: 760px; margin: 0 auto; }
/* Le panneau des tâches. */
.room-side {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  gap: 18px;
  width: var(--room-w);
  padding: 16px;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  border-left: 1px solid var(--line);
  background: var(--side);
}
.room-side-head { display: none; justify-content: flex-end; margin-bottom: -10px; }
.room-tools .pill-button { height: 30px; padding: 0 14px; font-size: 12.5px; }
.room-close { display: none; }
.room-section { display: grid; gap: 8px; min-width: 0; }
.room-section h3, .room-side .routine-section h4 { margin: 0; font-size: 12.5px; font-weight: 600; color: var(--t2); }
.room-tasks { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.room-tasks .task-item { background: var(--raised); }
.room-none { padding: 4px 0; font-size: 13.5px; }
.room-result { display: -webkit-box; margin: 0; overflow: hidden; font-size: 13px; line-height: 1.45; color: var(--t2); -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.room-side .routine-section { padding: 0; border: 0; }
/* Écran étroit : le panneau s'ouvre par-dessus le fil, avec le bouton « Tâches ». */
@media (max-width: 1000px) {
  #app:is(.agent-room, .room-leaving) { --room-w: 0px; }
  .room-toggle { display: inline-flex; }
  .room-side { display: none; width: min(380px, 100%); box-shadow: var(--surface-shadow); }
  .room-side.open { display: flex; }
  .room-side-head { display: flex; }
  .room-close { display: grid; position: static; }
}
@media (max-width: 720px) {
  .room-head { padding: 10px 16px; padding-left: 60px; } /* le bouton du menu reste à gauche */
  .room-side { width: 100%; border-left: 0; }
}
/* Ses réponses : son visage à gauche de la première bulle, à la place de l'étiquette « IA » (la
   mention « Agent IA » est dans l'en-tête). --room-face et --hue : posés sur le fil (agent-tasks.js). */
.agent-room .msg.assistant { position: relative; margin-left: calc(max(0px, (100% - 760px) / 2) + 44px); max-width: min(680px, calc(85% - 44px)); }
.agent-room .msg.assistant.ai-label::before {
  content: "" / "Réponse de l'agent IA";
  position: absolute;
  top: 0;
  left: -44px;
  width: 34px;
  height: 34px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--room-face) center / cover no-repeat, color-mix(in srgb, var(--hue) 16%, var(--bg));
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 3.5px color-mix(in srgb, var(--hue) 70%, transparent);
}
.room-who .ai-badge { margin: 0; }
/* Comme avec un collègue : ses messages seulement. Ses étapes (outils, réflexion, résultats
   montrés) restent cachées ; pendant qu'il travaille, seule la dernière dit ce qu'il fait. */
.agent-room .messages > .activity, .agent-room .messages > .shown-result { display: none; }
.agent-room.turn-busy .messages > .activity:last-child { display: block; margin-left: max(0px, calc((100% - 760px) / 2)); }
/* Bord gauche du panneau des tâches : la même poignée que la barre latérale (style.css), posée sur
   sa ligne de séparation. */
.room-resize { display: none; right: calc(var(--room-w) - 7px); left: auto; }
.agent-room .room-resize { display: block; }
@media (max-width: 1000px) { .agent-room .room-resize { display: none; } }

/* Une tâche en grand : la fenêtre des Paramètres (style.css : fondu, léger zoom), plus étroite. */
.room-task { cursor: pointer; transition: box-shadow .15s; }
.room-task:hover { box-shadow: 0 0 0 1px color-mix(in srgb, var(--t1) 18%, transparent); }
.room-task:focus-visible { outline: 2px solid color-mix(in srgb, var(--t1) 35%, transparent); outline-offset: 2px; }
dialog.task-modal[open] { display: flex; flex-direction: column; }
dialog.task-modal { width: min(680px, calc(100% - 32px)); height: auto; max-height: min(760px, calc(100% - 32px)); }
.task-modal-head { position: relative; display: flex; align-items: center; gap: 10px; padding: 16px 60px 14px 20px; border-bottom: 1px solid var(--line); }
.task-modal-title { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; min-width: 0; font-size: 13.5px; color: var(--t2); }
.task-modal-head .close { top: 12px; }
.task-modal-body { flex: 1; min-height: 0; overflow-y: auto; display: grid; align-content: start; gap: 18px; padding: 20px; }
.task-modal-prompt { margin: 0; font-size: 18px; font-weight: 600; line-height: 1.4; white-space: pre-wrap; overflow-wrap: anywhere; }
.task-modal-dates { display: flex; flex-wrap: wrap; gap: 4px 18px; margin: -8px 0 0; font-size: 13px; color: var(--t2); }
.task-modal-dates dt { font-weight: 600; }
.task-modal-dates dt::after { content: " :"; }
.task-modal-dates dd { margin: 0 0 0 -14px; }
.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: 10px; padding: 14px 16px; border-radius: 12px; background: color-mix(in srgb, var(--t1) 3.5%, transparent); font-size: 14.5px; line-height: 1.55; }
.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: 14px 20px; border-top: 1px solid var(--line); }
.pill-button.danger { color: var(--error); }
/* « Nouveau message » : la ligne avant les comptes rendus pas encore lus (agent-tasks.js). */
.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); }
/* En-tête de la page d'un agent : « Chef d'équipe » à côté du nom (l'état est sur le visage, « agent IA » sous le nom). */
.room-name > .lead-chip {
  display: inline-flex;
  align-items: center;
  margin: 0;
  padding: 2px 9px;
  border: 0;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  line-height: 18px;
  background: color-mix(in srgb, var(--hue) 16%, transparent);
  color: var(--t1);
}

/* Section « Agents » de la barre latérale (agents.js) : son titre et « + » (recruter), puis une
   ligne par agent, comme une conversation : visage (anneau d'état, pastille) et prénom. */

.side-section { margin: 0; }
/* Le titre de la section : une entrée comme les autres (icône, libellé, survol) qui recrute un
   agent ; le « + » au bout n'est qu'un repère. */
.side-link.side-section-head { padding-right: 6px; }
.side-section-head > span:not(.side-add) { flex: 1; }
.side-link .side-add { flex: none; display: grid; place-items: center; width: 24px; height: 24px; color: var(--t2); }
.side-add svg { width: 16px !important; height: 16px !important; }
.side-agents { display: grid; gap: 2px; margin-top: 2px; } /* le même écart qu'entre les entrées du menu */
.side-agent { position: relative; border-radius: 10px; }
.side-agent:hover { background: color-mix(in srgb, var(--t1) 6%, transparent); }
.side-agent.active { background: var(--conv-active); }
.side-agent-open {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 36px;
  padding: 0 10px 0 9px;
  border-radius: inherit;
  background: none;
  color: var(--t1);
  font: normal 400 14px/20px system-ui, -apple-system, "Segoe UI", sans-serif;
  text-align: left;
}
:where(.side-agent-open):hover { background: none; }
.side-agent .agent-bubble { width: 24px; height: 24px; }
.side-agent .agent-bubble:hover { transform: none; }
.side-agent .agent-bubble .agent-face { inset: 3px; }
.side-agent .agent-ring { border-width: 1.5px; }
.side-agent .agent-bubble[data-state] .agent-ring { border-width: 2px; }
.side-agent .agent-count { top: -5px; right: -7px; min-width: 16px; height: 16px; padding: 0 4px; font-size: 10px; line-height: 16px; box-shadow: 0 0 0 2px var(--side); }
.side-agent .agent-dot { width: 8px; height: 8px; box-shadow: 0 0 0 2px var(--side); }
.side-agent .agent-bubble[data-state="repos"] .agent-dot { display: none; }
.side-agent-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-agent.has-unread .side-agent-name { font-weight: 600; }
.agent-form-links { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px; margin-right: auto; }
/* Page d'un agent : son visage ouvre sa fiche ; au survol, un voile sombre et un crayon au centre. */
.room-face { position: relative; flex: none; display: block; width: 44px; height: 44px; padding: 0; border-radius: 50%; background: none; line-height: 0; }
.room-face .agent-face { display: block; width: 100%; height: 100%; }
/* L'état de l'agent : un point en bas à droite de son visage, comme dans la barre latérale (agent-tasks.js, stateDot). */
.room-state { position: absolute; right: 0; bottom: 0; width: 9px; height: 9px; border-radius: 50%; background: var(--done); box-shadow: 0 0 0 2px var(--bg); pointer-events: auto; }
.room-state.travaille { background: var(--run); animation: room-state-pulse 1.8s ease-in-out infinite; }
.room-state.attend { background: var(--wait); }
.room-state.message { background: var(--alert); }
@keyframes room-state-pulse { 50% { box-shadow: 0 0 0 2px var(--bg), 0 0 0 5px color-mix(in srgb, var(--run) 30%, transparent); } }
@media (prefers-reduced-motion: reduce) { .room-state.travaille { animation: none; } }
:where(.room-face):hover { background: none; }
.room-face:focus-visible { outline: 2px solid var(--t1); outline-offset: 4px; }
.room-face-edit {
  position: absolute; inset: 0; display: grid; place-items: center; border-radius: 50%;
  background: rgb(0 0 0 / .5); color: #fff; opacity: 0; transition: opacity .15s;
}
.room-face-edit svg { width: 18px; height: 18px; }
.room-face:hover .room-face-edit, .room-face:focus-visible .room-face-edit { opacity: 1; }
/* Recruter : chaque carte teintée de la couleur de son métier, plus marquée au survol. */
.template-card { background: color-mix(in srgb, var(--hue, var(--t1)) 7%, var(--bg2)); transition: background .15s, border-color .15s, transform .15s; }
:where(.template-card):hover { background: color-mix(in srgb, var(--hue, var(--t1)) 12%, var(--bg2)); border-color: color-mix(in srgb, var(--hue, var(--t1)) 35%, transparent); transform: translateY(-1px); }
.template-card .agent-face { flex: none; }
.template-card.blank { --hue: var(--t2); }
@media (prefers-reduced-motion: reduce) { .template-card, .template-card:hover { transition: none; transform: none; } }
/* Heure des messages : dans chaque bulle, en bas à droite, en petit (agent-tasks.js). */
.msg > .msg-time { display: block; margin: 2px -4px -4px 16px; text-align: right; font-size: 11px; line-height: 14px; color: var(--t2); white-space: nowrap; user-select: none; }
/* Heure d'un message qui vient d'arriver : en fondu, la bulle grandit en douceur (sa marge part de
   moins sa hauteur). */
.msg > .msg-time.time-in { animation: time-in .3s cubic-bezier(.22, 1, .36, 1); }
@keyframes time-in { from { opacity: 0; margin-top: -14px; } }
@media (prefers-reduced-motion: reduce) { .msg > .msg-time.time-in { animation: none; } }
/* Sans la marge du dernier paragraphe : l'heure suit le texte, sans ligne vide entre les deux. */
.msg:has(> .msg-time) > :nth-last-child(2), .msg:has(> .msg-time) > :nth-last-child(2) > :last-child { margin-bottom: 0; }
/* Une page à la place du fil (Recruter, Applications, Mes fichiers) : seule son entrée reste en
   surbrillance, pas la conversation ni l'agent ouverts avant. */
.app:is(.agents-open, .apps-open, .files-open) :is(.conv.active, .side-agent.active) { background: none; }
/* Écran étroit : le visage de l'agent plus petit, les bulles prennent la largeur. */
@media (max-width: 720px) {
  .agent-room .msg.assistant { margin-left: 34px; max-width: calc(100% - 34px); }
  .agent-room .msg.assistant.ai-label::before { left: -34px; width: 26px; height: 26px; }
  .agent-room .msg.user { max-width: 85%; }
}
/* Boutons de l'en-tête de la page d'un agent : libellé sur ordinateur, icône seule sur téléphone. */
.room-tools .pill-button { gap: 6px; }
.room-btn-icon { display: none; }
.room-btn-icon svg { display: block; width: 18px; height: 18px; }
@media (max-width: 720px) {
  .room-head { gap: 10px; padding: 10px 12px 10px 60px; }
  .room-head .room-face { width: 38px; height: 38px; }
  .room-name { flex-wrap: nowrap; gap: 6px; min-width: 0; }
  .room-name h2 { flex: 0 1 auto; min-width: 0; overflow: hidden; font-size: 15px; text-overflow: ellipsis; white-space: nowrap; }
  .room-name > .lead-chip { display: none; } /* la place manque : le nom d'abord */
  .room-who p { overflow: hidden; font-size: 12.5px; text-overflow: ellipsis; white-space: nowrap; }
  .room-tools { gap: 6px; }
  .room-tools .pill-button { width: 36px; height: 36px; padding: 0; justify-content: center; }
  .room-btn-icon { display: block; }
  .room-btn-label { display: none; }
}
/* 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; }

/* Bulle de planification (agent-routines.js) : à côté du bouton, elle se déplie depuis lui ; 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); } }
.plan-pop .routine-planner { padding: 0; border: 0; background: none; }
.routine-item.just-added { animation: plan-landed 1.2s ease; }
@keyframes plan-landed { 0%, 30% { box-shadow: 0 0 0 2px var(--hue, var(--run)); background: color-mix(in srgb, var(--hue, var(--run)) 10%, var(--raised)); } }
@media (prefers-reduced-motion: reduce) { .plan-pop.in, .routine-item.just-added { animation: none; } }
/* « Interpréter » pendant que l'IA lit la phrase : le bouton tourne, la phrase s'estompe ; le
   formulaire qui suit apparaît en fondu. */
.pill-button.busy:disabled { opacity: 1; cursor: default; gap: 8px; }
.spinner { flex: none; width: 13px; height: 13px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: agent-spin .7s linear infinite; }
.drawer-task.thinking textarea { opacity: .55; transition: opacity .2s; }
.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) { .spinner { animation-duration: 2s; } .plan-pop .routine-form { animation: none; } }
/* Téléphone, bulle de planification ouverte : le clavier remonterait la zone de saisie du fil sous
   la bulle ; elle s'efface en fondu le temps de planifier, et un voile clair estompe le reste. */
.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) {
  .chat > :is(.composer, #empty, .messages) { transition: opacity .22s ease; }
  .plan-open .chat > :is(.composer, #empty, .messages) { opacity: 0; pointer-events: none; }
  .plan-open .plan-veil { opacity: 1; pointer-events: auto; }
}
@media (prefers-reduced-motion: reduce) { .plan-veil, .chat > :is(.composer, #empty, .messages) { transition: none; } }


/* Arrivée sur la page d'un agent depuis une conversation normale (agent-tasks.js, renderRoom) :
   l'en-tête descend en fondu, le panneau des tâches glisse depuis la droite. */
.room-head.room-head-in { animation: room-head-in .34s cubic-bezier(.22, 1, .36, 1); }
@keyframes room-head-in { from { opacity: 0; transform: translateY(-8px); } }
.room-side.room-side-in { animation: room-side-in .38s cubic-bezier(.22, 1, .36, 1); }
/* Le panneau part de 24 px à droite : ce qui dépasse est coupé, sans barre de défilement horizontale. */
:is(.agent-room, .room-leaving) main.chat { overflow-x: clip; }
/* Et la barre de défilement du fil attend que le panneau soit arrivé (room-switch, 0,4 s), puis
   apparaît en fondu : sa couleur passe par --scroll-thumb, animable (une barre de défilement ne s'anime
   pas d'elle-même). Seulement transparente, elle garde sa place : retirée, elle décalait le fil. */
@property --scroll-thumb { syntax: "<percentage>"; inherits: true; initial-value: 16%; }
#app .messages { --scroll-thumb: 16%; transition: opacity .18s ease, --scroll-thumb .4s ease; } /* le fondu d'opacité du fil (style.css) gardé */
#app.room-switch .messages { --scroll-thumb: 0%; transition: opacity .18s ease; }
#app .messages::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--t1) var(--scroll-thumb), transparent) padding-box; }
#app .messages::-webkit-scrollbar-thumb:hover { background-color: var(--scroll-hover); }
@supports not selector(::-webkit-scrollbar) { #app .messages { scrollbar-color: color-mix(in srgb, var(--t1) var(--scroll-thumb), transparent) transparent; } }
@media (prefers-reduced-motion: reduce) { #app .messages, #app.room-switch .messages { transition: none; } }
@keyframes room-side-in { from { opacity: 0; transform: translateX(24px); } }
@media (prefers-reduced-motion: reduce) {
  .room-head.room-head-in, .room-side.room-side-in { animation: none; }
}
/* Retour à une conversation normale : l'en-tête remonte, le panneau repart à droite, en fondu. */
.room-head.room-head-out { animation: room-head-out .15s ease-in forwards; pointer-events: none; }
@keyframes room-head-out { to { opacity: 0; transform: translateY(-8px); } }
.room-side.room-side-out { animation: room-side-out .17s ease-in forwards; pointer-events: none; }
@keyframes room-side-out { to { opacity: 0; transform: translateX(24px); } }
@media (prefers-reduced-motion: reduce) { .room-head.room-head-out, .room-side.room-side-out { animation: none; opacity: 0; } }
