/* Chat : fil, saisie, cartes d'outils, volets (lot « chat » de la phase 14). */

/* ---- en-tête : titre lisible, état en pastille, boutons avec libellé ---- */
.chat { position: relative; }
.chat-head { position: relative; z-index: 20; flex-wrap: nowrap; gap: 6px; padding: 6px 10px; }
.chat-title { display: grid; gap: 2px; min-width: 0; }
.chat-title .title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-sub { display: flex; align-items: center; gap: 8px; min-width: 0; }
.chat-sub .cwd { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.85em; }
.chat-state { flex: none; padding: 1px 10px; border-radius: 99px; font-size: 0.8em; font-weight: 600; white-space: nowrap;
  background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--fg); }
.chat-state[data-state="permission"] { background: color-mix(in srgb, var(--warning) 30%, transparent); }
.chat-state[data-state="busy"] { background: color-mix(in srgb, var(--success) 22%, transparent); }
.chat-actions { display: flex; gap: 2px; flex: none; }
.chat-actions .act { min-height: 44px; white-space: nowrap; }
.phone-only { display: none; }
.chat-menu { position: absolute; top: 100%; right: 8px; z-index: 30; min-width: 200px; display: grid; background: var(--card);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 4px; }
.chat-menu .menu-item { background: transparent; justify-content: flex-start; text-align: left; min-height: 44px; }
.chat-menu[hidden] { display: none; }

/* ---- saisie ---- */
.composer { position: relative; }
.composer-row .icon { min-width: 44px; padding: 0 8px; }
.composer-foot .stop { flex: none; margin-left: 4px; }
.composer-foot { display: flex; align-items: center; gap: 8px; min-height: 36px; }
.composer-foot .opt { gap: 8px; min-width: 0; max-width: 100%; }
.composer-foot .opt-summary { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.composer-foot .opt::after { content: "▾"; }
.composer-foot .opt[aria-expanded="true"]::after { content: "▴"; }
.composer-foot .context { margin-left: auto; white-space: nowrap; }
.chat-bar select { flex: 1 1 140px; min-height: 44px; }

.complete { position: absolute; left: 8px; right: 8px; bottom: 100%; z-index: 25; display: grid; background: var(--card);
  border-radius: var(--radius); box-shadow: var(--shadow); max-height: 50vh; overflow-y: auto; }
.complete[hidden] { display: none; }
.complete .choice { display: flex; gap: 10px; align-items: baseline; justify-content: flex-start; text-align: left;
  background: transparent; border-radius: 0; min-height: 44px; }
.complete .choice.current { background: color-mix(in srgb, var(--accent) 18%, transparent); }
.complete .choice .subtle { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

/* ---- notes, liens, recherche ---- */
.notice { display: flex; gap: 10px; align-items: center; justify-content: center; flex-wrap: wrap; }
.file-link { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.file-link code { color: inherit; }
.findbar { display: flex; align-items: center; gap: 4px; padding: 4px 8px; border-bottom: 1px solid var(--line); background: var(--bg); }
.findbar[hidden] { display: none; }
.findbar input { flex: 1; min-width: 0; }
.find-count { white-space: nowrap; font-size: 0.85em; }
.hit { outline: 2px solid color-mix(in srgb, var(--warning) 55%, transparent); outline-offset: 2px; border-radius: 6px; }
.hit-current { outline: 3px solid var(--warning); }

/* ---- diff des modifications ---- */
.tool.edit summary .path, .change summary .path { overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 1; direction: rtl; text-align: left; }
.stat { font-family: var(--mono); font-size: 0.85em; font-weight: 700; flex: none; }
.stat.add, .dl.add .sign { color: var(--success); }
.stat.del, .dl.del .sign { color: var(--error); }
pre.diff { margin: 6px 0; padding: 0; font-family: var(--mono); font-size: 0.85em; overflow: auto; max-height: 360px; white-space: pre; background: var(--bg); border-radius: 8px; }
.dl { display: block; padding: 0 8px; min-width: max-content; }
.dl .sign { display: inline-block; width: 1.4em; user-select: none; }
.dl.add { background: color-mix(in srgb, var(--success) 18%, transparent); }
.dl.del { background: color-mix(in srgb, var(--error) 16%, transparent); }
.dl.hunk { color: var(--subtle); background: var(--soft); font-style: italic; }
.tool-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.tool.shell .path { font-family: var(--mono); }

/* ---- messages enregistrés, changements ---- */
dialog.sheet p { white-space: pre-line; overflow-wrap: anywhere; max-height: 40vh; overflow-y: auto; }
dialog.saved { width: min(520px, calc(100vw - 24px)); }
.saved-list { display: grid; gap: 6px; max-height: 45vh; overflow-y: auto; }
.saved-item { display: flex; align-items: center; gap: 6px; }
.saved-pick { flex: 1; min-width: 0; display: grid; justify-items: start; text-align: left; background: var(--soft); gap: 2px; padding: 8px 12px; height: auto; }
.saved-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.saved-new { display: grid; gap: 6px; margin-top: 12px; }
.changes { display: grid; gap: 8px; }
.change { background: var(--soft); border-radius: 10px; padding: 6px 10px; }
.change summary { cursor: pointer; display: flex; align-items: center; gap: 8px; min-height: 44px; }
.kind { font-size: 0.8em; padding: 1px 8px; border-radius: 99px; background: var(--soft); }
.point { display: flex; align-items: center; gap: 8px; padding: 4px 0; border-bottom: 1px solid var(--line); }
.point-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 719px) {
  .desk-only { display: none; }
  .phone-only { display: inline-flex; }
  .chat-head .chat-sub .cwd { display: none; }
  .composer-row .icon { min-width: 40px; }
  .complete { left: 0; right: 0; }
}
@media (min-width: 720px) {
  .chat-menu { display: none; }
}

/* « Claude travaille… » en bas à gauche, au-dessus de la saisie (comme au bureau). */
.working { display: flex; align-items: center; gap: 8px; font-size: 0.85em; color: var(--subtle); }
.working[hidden] { display: none; }
.working .spinner { width: 12px; height: 12px; border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; animation: working-spin 0.8s linear infinite; }
@keyframes working-spin { to { transform: rotate(360deg); } }

/* Bloc de code : barre (langue, Copier) au-dessus du code. */
.code-wrap { margin: 8px 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--soft); }
.code-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 2px 4px 2px 12px;
  border-bottom: 1px solid var(--line); font-size: 0.78em; color: var(--subtle); }
.code-lang { font-family: var(--mono); text-transform: lowercase; }
.code-wrap > pre { margin: 0; border-radius: 0; background: transparent; }
.copy-code { display: inline-flex; align-items: center; gap: 6px; min-height: 28px; padding: 2px 10px; border: 0; border-radius: 6px;
  background: transparent; color: var(--subtle); font-size: 1em; font-weight: 500; cursor: pointer; }
.copy-code:hover { background: color-mix(in srgb, var(--fg, currentColor) 8%, transparent); color: inherit; }
.copy-code.done { color: var(--success); }

/* Actions d'un message (« Répondre ») : au survol sur un écran à souris ; sur un écran tactile, on
   touche le message et la rangée s'ouvre dessous, avec le libellé à côté de l'icône. */
.msg { position: relative; }
.msg-actions { display: none; gap: 2px; margin-top: 2px; user-select: none; -webkit-user-select: none; }
.msg.user .msg-actions { justify-content: flex-end; }
.msg.picked .msg-actions { display: flex; }
.msg-act { min-height: 36px; min-width: 40px; padding: 0 10px; border-radius: 8px; background: transparent; color: var(--subtle);
  font-size: 0.85em; font-weight: 500; }
.msg-act::after { content: attr(data-label); }
.msg-act:hover, .msg-act:focus-visible { background: var(--soft); color: inherit; filter: none; }
@media (hover: hover) {
  /* Flottante sous le message : elle ne décale rien. Le bas du fil lui garde sa place, pour
     qu'elle ne soit pas coupée sous le dernier message. */
  .thread { padding-bottom: 30px; }
  .msg-actions { display: flex; position: absolute; top: 100%; left: 0; z-index: 2; margin-top: -6px; padding: 2px;
    border: 1px solid var(--line); border-radius: 10px; background: var(--bg); box-shadow: var(--shadow);
    opacity: 0; pointer-events: none; transition: opacity 0.12s; }
  .msg.user .msg-actions { left: auto; right: 0; }
  .msg:hover .msg-actions, .msg:focus-within .msg-actions { opacity: 1; pointer-events: auto; }
  .msg-act { min-height: 26px; min-width: 32px; padding: 0 8px; }
  .msg-act::after { content: none; }
}

/* Citation : dans la bulle d'un message qui répond à un autre, et au-dessus de la saisie. */
.quoted { margin: 0 0 6px; padding: 4px 10px; border-left: 3px solid var(--accent); border-radius: 6px;
  background: color-mix(in srgb, var(--fg, currentColor) 7%, transparent); font-size: 0.9em; cursor: pointer; }
.quoted::before { content: attr(data-author); display: block; font-size: 0.9em; font-weight: 700; color: var(--accent); }
.quoted-text { white-space: pre-wrap; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 4; line-clamp: 4; overflow: hidden; }
.quoted.open .quoted-text { display: block; }
/* Passage rendu (Markdown) : replié par la hauteur, les blocs serrés. */
.quoted-text.rendered { white-space: normal; display: block; max-height: 6em; overflow: hidden; }
.quoted.open .quoted-text.rendered { max-height: none; }
.quoted-text.rendered > * { margin: 0 0 4px; }
.quoted-text.rendered > :last-child { margin-bottom: 0; }
.quoted-text.rendered ul, .quoted-text.rendered ol { padding-left: 20px; }
.quoted-text.rendered pre { padding: 4px 8px; white-space: pre-wrap; }
.quoted-text.rendered table { border-collapse: collapse; display: block; overflow-x: auto; }
.quoted-text.rendered th, .quoted-text.rendered td { border: 1px solid var(--line); padding: 2px 6px; }
.quoted-text.rendered blockquote { padding-left: 8px; border-left: 2px solid var(--line); }
.quoted-text.rendered h1, .quoted-text.rendered h2, .quoted-text.rendered h3, .quoted-text.rendered h4 { font-size: 1em; }
.quote-bar { display: flex; align-items: center; gap: 6px; padding: 2px 2px 2px 10px; border-left: 3px solid var(--accent);
  border-radius: 8px; background: var(--soft); font-size: 0.9em; }
.quote-bar-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quote-bar-text::before { content: attr(data-author); display: block; font-size: 0.9em; font-weight: 700; color: var(--accent); }
.quote-bar button { min-height: 36px; min-width: 36px; padding: 0 8px; }

/* Étiquettes : pastilles sous un message, feuille « Étiqueter », volet « Étiquettes ». */
.msg-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.msg.user .msg-tags { justify-content: flex-end; }
.tag-chip { min-height: 26px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--soft);
  color: var(--accent); font-size: 0.85em; font-weight: 600; filter: none; }
.tag-chip:hover, .tag-chip:focus-visible { border-color: var(--accent); }
.tag-suggest { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.tag-excerpt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag-sheet .field { display: grid; gap: 4px; }
.tags-panel { display: grid; gap: 8px; padding: 8px; }
.tag-group > summary { cursor: pointer; padding: 6px 2px; }
.tag-items { display: grid; gap: 4px; }
.tag-item { display: grid; gap: 2px; text-align: left; padding: 8px 10px; border-radius: 8px; background: var(--soft);
  color: inherit; min-height: 44px; filter: none; }
.tag-item:hover, .tag-item:focus-visible { background: var(--line); }
.tag-who { font-size: 0.8em; }
.tag-text { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.msg.flash { animation: msg-flash 1.6s ease-out; }
@keyframes msg-flash { 0%, 40% { background: color-mix(in srgb, var(--accent) 18%, transparent); } 100% { background: transparent; } }
