/* Le composer (planches 3 · Icônes et 5 · La machine travaille).
   Boutons de 40 px dans une zone tactile de 44, sans bordure : le composer
   est déjà un cadre. L'envoi vide est ÉTEINT plutôt que vert — le bouton dit
   quand il peut servir ; pendant un run, la même place devient l'arrêt,
   rouge plein, avec le chrono à côté (il reste visible quand le fil défile).
   Au téléphone, une seule place principale : le micro quand le champ est
   vide, l'envoi dès qu'on écrit, l'arrêt pendant le travail. */

#composer {
  flex: none;
  padding: 0 var(--gutter) calc(var(--sp-4) + env(safe-area-inset-bottom));
}
#chat-form {
  position: relative;
  max-width: 712px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-4);
  box-shadow: var(--shadow-rest);
  padding: 12px 10px 8px 16px;
  transition: border-color var(--dur-in), background var(--dur-in);
}
#chat-form:focus-within, #chat-form.ready { border-color: var(--line-strong); }
#composer-buttons {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: -8px;
}
.composer-spacer { flex: 1; }
#input {
  flex: 1;
  min-width: 0; /* autorise le rétrécissement : sans ça, les boutons débordent */
  resize: none;
  border: none;
  background: none;
  color: var(--ink);
  /* < 16px, iOS Safari zoome au focus et ne revient pas : jamais moins. */
  font-size: 16px;
  line-height: 24px;
  padding: 6px 0;
  max-height: 9rem;
  outline: none;
}
#input::placeholder { color: var(--ink-3); }

#attach, #mic, #send {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: var(--r-full);
  background: transparent;
  color: var(--ink-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  transition: background var(--dur-press), color var(--dur-press), transform var(--dur-press);
}
@media (hover: hover) {
  #attach:hover, #mic:hover, .chip-face:hover { background: var(--paper-sunk); color: var(--ink); }
}
#attach:active, #mic:active, .chip-face:active { background: var(--paper-sunk); }
#attach.busy { animation: pp-live 1.3s ease-in-out infinite; cursor: default; }
#attach.failed { color: var(--danger); }

#send { background: var(--accent); color: var(--on-accent); }
#send:disabled { background: var(--paper-sunk); color: var(--ink-4); cursor: default; }
#send:active:not(:disabled) { transform: scale(.92); }
@media (hover: hover) {
  #send:not(:disabled):not(.running):hover { background: var(--accent-strong); }
}
/* En cours de run, le même bouton devient STOP : rouge plein, carré plein,
   sans ambiguïté avec l'envoi (qui reste vert). */
#send.running { background: var(--danger-solid); color: var(--on-danger); }
#send.running .ic { width: 16px; height: 16px; }
.run-clock {
  font: 500 12.5px/1 var(--font-machine);
  color: var(--ink-3);
  margin-right: 8px;
}
.run-clock[hidden] { display: none; }

/* Le cadran « Modèle & raisonnement » : l'aiguille montre le niveau choisi,
   on lit le réglage sans ouvrir la boîte. */
.chip-face {
  height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  border-radius: var(--r-full);
  background: transparent;
  color: var(--ink-2);
  font: 500 13px/1 var(--font-ui);
  padding: 0 12px 0 10px;
  white-space: nowrap;
  cursor: pointer;
}
.chip-face .chip-label { max-width: 10rem; overflow: hidden; text-overflow: ellipsis; }
.chip-face.boosted { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }

/* --- Modifier le dernier message : le composer le dit, et se laisse
   annuler. --- */
.edit-banner {
  display: none;
  align-items: center;
  gap: 8px;
  font: 500 13px/1.3 var(--font-ui);
  color: var(--accent-text);
}
#chat-form.editing .edit-banner { display: flex; }
#chat-form.editing { border-color: var(--accent-line); }
.edit-banner .mi-label { flex: 1; }
.edit-banner button {
  border: 0;
  background: transparent;
  color: var(--ink-2);
  font: 600 13px/1 var(--font-ui);
  text-decoration: underline;
  text-underline-offset: 3px;
  min-height: 32px;
  cursor: pointer;
}

@media (max-width: 760px) {
  #composer { padding: 8px 12px calc(12px + env(safe-area-inset-bottom)); }
  #chat-form { padding: 10px 6px 6px 14px; gap: 4px; }
  #attach, #mic { width: var(--hit); height: var(--hit); }
  .chip-face { height: var(--hit); padding: 0 10px; }
  /* Le micro passe à droite, à la place de l'envoi. */
  .composer-spacer { order: 3; }
  .run-clock { order: 4; }
  #mic { order: 5; }
  #send { order: 6; }
  #send, #chat-form.empty:not(.running) #mic {
    width: 48px;
    height: 48px;
    background: var(--accent);
    color: var(--on-accent);
  }
  #chat-form.empty:not(.running) #mic .ic { width: 22px; height: 22px; stroke-width: 2.1; }
  /* Une seule place principale : micro au repos, envoi dès qu'on écrit. */
  #chat-form.empty:not(.running) #send { display: none; }
  #chat-form:not(.empty) #mic, #chat-form.running #mic { display: none; }
  #send.running { background: var(--danger-solid); color: var(--on-danger); }
}
@media (max-width: 480px) {
  .chip-face .chip-label { max-width: 5.5rem; }
}
