/* Hallmark · checked: 2026-11-27 · shape: app screen · direction: B Instrument · modes: light+dark */
/* Styles des onglets (onglets-discussion) : refonte « Instrument », 27/11/2026. Utiliser les jetons et composants de style.css. */
/* =====================================================================================================================
   Discussion (#tab-chat) : un fil de travail à lire, pas une messagerie décorée.
   - Ses réponses : texte libre sur le fond, sans bulle, largeur de lecture ~70 caractères ; en-tête « Elle · 14:43 ».
   - Les messages de la propriétaire : bulle teintée (--me) alignée à droite, en-tête aligné à droite.
   - Pièces jointes : bouton trombone dans la saisie, puces d'envoi (vignette, nom, progression, erreur) au-dessus.
   - « Ce qu'elle a fait » : reçu compact repliable sous la réponse (icônes d'outil, compte, étapes en liste à filet).
   - Bulle provisoire : cadre en tirets (provisoire), statut accent, derniers outils ; elle cède la place à la réponse.
   - Saisie collée en bas, sur toute la largeur, colonne alignée sur celle du fil ; 44 px sur mobile (jeton --h-ctl).
   Le fil occupe tout le cadre de <main> (sans sa marge) : seul l'intérieur défile, la saisie reste visible.
   ===================================================================================================================== */
#app > main:has(> #tab-chat.active) { padding: 0; overflow: hidden; }
#tab-chat.active { display: flex; flex-direction: column; height: 100%; max-width: none; }
#tab-chat { --chat-col: 46rem; --chat-read: 33rem; --chat-pad: max(var(--s6), calc((100% - var(--chat-col)) / 2)); }

/* ---------- Fil ---------- */
.thread { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.messages { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; display: flex; flex-direction: column; gap: var(--s5);
  padding: var(--s6) var(--chat-pad) var(--s6); overscroll-behavior: contain; }

/* Séparateur de jour : filets de part et d'autre, libellé discret. */
.day-sep { display: flex; align-items: center; gap: var(--s3); margin: var(--s2) 0 calc(-1 * var(--s1)); color: var(--ink-3); font-size: var(--t-meta); font-weight: 500; }
.day-sep::before, .day-sep::after { content: ""; flex: 1; height: 1px; background: var(--rule); }
.day-sep span { white-space: nowrap; }

/* Message : en-tête (auteur · heure · canal), corps, pied. */
.msg { min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
.msg .meta { margin: 0 0 var(--s1); font-size: var(--t-meta); line-height: 1.4; color: var(--ink-3); }
.msg-author { font-size: var(--t-small); font-weight: 600; color: var(--ink); }
.msg-time { font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.msg .meta .via { color: var(--ink-2); }
.msg .md { line-height: 1.6; }
.msg .md p, .msg .md ul, .msg .md ol, .msg .md pre, .msg .md blockquote, .msg .md table { margin: 0 0 var(--s3); }
.msg .md > :last-child { margin-bottom: 0; }
.msg .md ul, .msg .md ol { padding-left: 1.25em; }
.msg .md li + li { margin-top: 2px; }
.msg .md h1, .msg .md h2, .msg .md h3, .msg .md h4 { margin: var(--s4) 0 var(--s2); font-size: var(--t-body); font-weight: 600; text-wrap: balance; }
.msg .md > h1:first-child, .msg .md > h2:first-child, .msg .md > h3:first-child { margin-top: 0; }
.msg .md a { color: var(--accent-text); }
.msg .md pre { max-width: 100%; padding: var(--s2) var(--s3); background: var(--sunk); border-radius: var(--r-ctl); font-size: var(--t-small); }
.msg .md pre code { padding: 0; background: none; }
.msg .md blockquote { margin-left: 0; padding-left: var(--s4); color: var(--ink-2); font-style: italic; }
.msg .md table { display: block; max-width: 100%; overflow-x: auto; font-size: var(--t-small); }
.msg .md th, .msg .md td { border: 1px solid var(--rule); padding: var(--s1) var(--s2); }
.msg .md hr { border: 0; border-top: 1px solid var(--rule); margin: var(--s4) 0; }

/* Ses réponses : pas de bulle, colonne de lecture. */
.msg.ia { align-self: stretch; }
.msg.ia .msg-body, .msg.ia .activity-log { max-width: var(--chat-read); }

/* Messages de la propriétaire : bulle teintée à droite. */
.msg.me { align-self: flex-end; max-width: min(34rem, 85%); }
.msg.me .meta { text-align: right; }
.msg.me .msg-body { padding: var(--s2) var(--s3); background: var(--me); border-radius: var(--r-box); }
.msg.me .md { line-height: 1.5; }

/* Mention « Vocal transcrit » au-dessus d'une transcription. */
.msg-voice { display: flex; align-items: center; gap: var(--s1); margin: 0 0 var(--s1); font-size: var(--t-meta); color: var(--ink-2); }

/* Pièces jointes d'un message : une ligne compacte, ouvrable quand le fichier est lisible dans la page. */
.attachment { display: flex; align-items: center; gap: var(--s2); max-width: 100%; min-height: var(--h-ctl); margin: 0 0 var(--s2); padding: var(--s1) var(--s2);
  border: 1px solid var(--rule-2); border-radius: var(--r-ctl); background: var(--panel); color: var(--ink); font-size: var(--t-small); text-decoration: none; }
.attachment:only-child, .attachment:last-child { margin-bottom: 0; }
a.attachment:hover { border-color: var(--accent); }
a.attachment:active { background: var(--sunk); }
a.attachment:hover .file { text-decoration: underline; text-underline-offset: 2px; }
.attachment svg.i { color: var(--ink-2); }
.attachment-kind { color: var(--ink-2); }
.attachment .file { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.attachment-size { flex: none; color: var(--ink-3); font-size: var(--t-meta); }

/* Médias (envoyés par l'IA ou joints par la propriétaire) : lecteur intégré, proportions conservées (shorts verticaux compris). */
.msg-media-wrap { margin-top: var(--s3); }
.msg-media-wrap:first-child { margin-top: 0; }
video.msg-media { display: block; max-width: 100%; max-height: min(70vh, 34rem); border-radius: var(--r-box); background: var(--media); }
audio.msg-media { display: block; width: min(100%, 26rem); height: 40px; }
.msg-media-link { display: inline-block; max-width: 100%; border-radius: var(--r-box); }
img.msg-media { display: block; max-width: 100%; max-height: 24rem; border: 1px solid var(--rule); border-radius: var(--r-box); background: var(--sunk); }
.attachment-caption { margin: var(--s1) 0 var(--s2); font-size: var(--t-meta); overflow-wrap: anywhere; }
.attachment-caption:empty { display: none; }

/* ---------- « Ce qu'elle a fait » : reçu compact ---------- */
.activity-log { margin-top: var(--s3); border-top: 1px solid var(--rule); font-size: var(--t-small); }
.activity-log summary { display: flex; align-items: center; gap: var(--s2); min-height: var(--h-ctl); padding: var(--s1) var(--s1) var(--s1) 0; color: var(--ink-2);
  cursor: pointer; list-style: none; user-select: none; border-radius: var(--r-ctl); }
.activity-log summary::-webkit-details-marker { display: none; }
.activity-log summary:hover { color: var(--ink); }
.activity-log summary:hover .activity-title { text-decoration: underline; text-underline-offset: 2px; }
.activity-chev { color: var(--ink-3); transition: transform .15s ease-out; }
.activity-log[open] .activity-chev { transform: rotate(90deg); }
.activity-title { font-weight: 500; color: var(--ink); }
.activity-count { color: var(--ink-3); }
.activity-failed { color: var(--ko); }
.activity-icons { display: flex; align-items: center; gap: var(--s2); margin-left: auto; padding-left: var(--s3); color: var(--ink-3); overflow: hidden; }
.activity-log[open] .activity-icons { visibility: hidden; }
.activity-list { list-style: none; margin: 0 0 var(--s1); padding: 0; }
.activity-item { display: grid; grid-template-columns: 16px minmax(0, 1fr) auto; column-gap: var(--s3); align-items: start; padding: var(--s2) 0; border-top: 1px solid var(--rule); }
.activity-item:first-child { border-top: 0; padding-top: var(--s1); }
.activity-icon { display: flex; padding-top: 2px; color: var(--ink-2); }
.activity-body { display: flex; flex-direction: column; min-width: 0; }
.activity-label { color: var(--ink); }
.activity-detail { color: var(--ink-3); font-size: var(--t-meta); overflow-wrap: anywhere; }
.activity-flag { grid-column: 3; align-self: center; display: inline-flex; align-items: center; height: 20px; padding: 0 var(--s2); border-radius: var(--r-ctl);
  background: var(--sunk); color: var(--ink-2); font-size: var(--t-meta); font-weight: 500; white-space: nowrap; }
.activity-item.is-error .activity-icon { color: var(--ko); }
.activity-item.is-error .activity-flag { background: var(--ko-soft); color: var(--ko); }
.activity-item.is-refused .activity-flag { background: var(--attn-soft); color: var(--attn); }

/* ---------- Bulle provisoire (pendant qu'elle travaille) ---------- */
.msg.live { align-self: stretch; animation: live-in .2s ease-out; transition: opacity .25s ease-out; }
.msg.live .msg-body { max-width: var(--chat-read); padding: var(--s3) var(--s4); border: 1px dashed var(--rule-2); border-radius: var(--r-box); }
.msg.live .msg-body:has(> .live-text[hidden] + .live-steps[hidden]) { display: none; }
.msg.live.leaving { opacity: 0; }
.msg.live .live-status { color: var(--accent-text); font-weight: 500; }
.live-text { white-space: pre-wrap; color: var(--ink-2); font-size: var(--t-small); line-height: 1.55; overflow-wrap: anywhere; }
.live-steps { list-style: none; margin: 0; padding: 0; font-size: var(--t-meta); color: var(--ink-3); }
.live-text:not([hidden]) + .live-steps { margin-top: var(--s2); padding-top: var(--s2); border-top: 1px solid var(--rule); }
.live-step { display: flex; align-items: center; gap: var(--s2); min-width: 0; padding: 2px 0; }
.live-step svg.i { color: var(--ink-2); }
.live-step-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live-step-text { color: var(--ink-2); }
.live-step-detail { color: var(--ink-3); }
.live-step:last-child .live-step-text { color: var(--ink); }
.typing { display: inline-flex; gap: var(--s1); margin-left: var(--s2); vertical-align: middle; }
.typing i { width: 4px; height: 4px; border-radius: var(--r-round); background: var(--accent); opacity: .3; animation: typing 1.2s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
@keyframes typing { 0%, 60%, 100% { opacity: .25; } 30% { opacity: 1; } }
@keyframes live-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .typing i, .msg.live { animation: none; } .typing i { opacity: .7; } .activity-chev { transition: none; } }

/* ---------- Retour en bas, état vide ---------- */
.scroll-bottom { position: absolute; right: var(--chat-pad); bottom: var(--s4); z-index: 1; width: 40px; height: 40px; min-height: 0; padding: 0; border-radius: var(--r-round);
  background: var(--panel); color: var(--ink-2); border: 1px solid var(--rule-2); box-shadow: var(--shadow-pop); }
.scroll-bottom:hover { background: var(--panel); color: var(--ink); border-color: var(--accent); filter: none; }
.scroll-bottom.has-new { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.chat-empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--s1); padding: var(--s6) var(--s4); text-align: center; }
.chat-empty h2 { margin: var(--s2) 0 0; font-size: var(--t-title); }
.chat-empty p { max-width: 32rem; margin: 0 0 var(--s4); }
.chat-suggestions { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--s2); max-width: 36rem; }
.chat-suggestion:hover { border-color: var(--accent); }

/* ---------- Bandeau « Activer les notifications » (en tête du fil) ---------- */
.chat-notif { flex: none; display: flex; align-items: center; flex-wrap: wrap; gap: var(--s2) var(--s3); padding: var(--s2) var(--chat-pad); background: var(--accent-soft); border-bottom: 1px solid var(--rule); font-size: var(--t-small); }
.chat-notif > svg.i { color: var(--accent-text); }
.chat-notif-text { flex: 1 1 14rem; margin: 0; min-width: 0; overflow-wrap: anywhere; }
.chat-notif .icon-btn { color: var(--ink-2); }

/* ---------- Saisie ---------- */
.composer { flex: none; padding: var(--s3) var(--chat-pad) var(--s2); border-top: 1px solid var(--rule); background: var(--panel); }
.composer-row { display: flex; align-items: flex-end; gap: var(--s2); }
#chat-input { flex: 1; min-width: 0; min-height: 40px; padding: var(--s2) var(--s3); background: var(--canvas); line-height: 1.5; resize: none; overflow-y: hidden; }
#chat-input:focus-visible { background: var(--panel); }
.composer-send { flex: none; min-height: 40px; padding: 0 var(--s4); }
.composer-attach { flex: none; width: 40px; min-height: 40px; border: 1px solid var(--rule-2); color: var(--ink-2); }
.composer-attach:hover { color: var(--accent-text); border-color: var(--accent); }
/* Pièces jointes en attente d'envoi : puces (vignette ou icône, nom, taille, progression ou erreur, retirer). */
.attach-list { list-style: none; display: flex; flex-wrap: wrap; gap: var(--s2); margin: 0 0 var(--s2); padding: 0; }
.attach-chip { display: flex; align-items: center; gap: var(--s2); max-width: min(100%, 20rem); min-width: 0; padding: var(--s1) var(--s1) var(--s1) var(--s2); border: 1px solid var(--rule-2); border-radius: var(--r-box); background: var(--canvas); font-size: var(--t-small); }
.attach-chip.is-error { border-color: var(--ko); background: var(--ko-soft); }
.attach-chip.is-ready { border-color: var(--ok-fill); }
.attach-thumb { flex: none; width: 36px; height: 36px; object-fit: cover; border-radius: var(--r-ctl); background: var(--sunk); }
.attach-icon { flex: none; display: grid; place-items: center; width: 36px; height: 36px; border-radius: var(--r-ctl); background: var(--sunk); color: var(--ink-2); }
.attach-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.attach-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.attach-meta { font-size: var(--t-meta); color: var(--ink-3); overflow-wrap: anywhere; }
.attach-err { color: var(--ko); }
.attach-ok { display: inline-flex; align-items: center; gap: 2px; color: var(--ok); }
.attach-ok svg.i { width: 12px; height: 12px; }
.attach-meter { height: 4px; }
.attach-remove { flex: none; }
.composer-hint { margin: var(--s1) 0 0; font-size: var(--t-meta); color: var(--ink-3); }
.composer-hint kbd { font-size: 11px; }

/* ---------- Téléphone et tablette (sous 960 px : barre d'onglets en bas) ---------- */
@media (max-width: 960px) {
  #tab-chat { --chat-pad: var(--s4); }
  .messages { padding-top: var(--s4); padding-bottom: var(--s4); gap: var(--s4); }
  .msg.me { max-width: 88%; }
  .composer-attach { width: 44px; min-height: 44px; }
  .attach-chip { max-width: 100%; flex: 1 1 100%; }
  .chat-notif { padding: var(--s2) var(--s4); }
  .attachment { min-height: 44px; }
  .activity-log summary { min-height: 44px; }
  .activity-icons { display: none; }
  .composer { padding: var(--s2) var(--s3); }
  /* 16 px : pas de zoom automatique du navigateur au focus (iOS). */
  #chat-input { min-height: 44px; padding-top: var(--s2); padding-bottom: var(--s2); font-size: 1rem; line-height: 1.5; }
  .composer-send { width: 44px; min-height: 44px; padding: 0; }
  .composer-send svg.i { width: 20px; height: 20px; }
  .composer-send-label, .composer-hint { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .scroll-bottom { right: var(--s4); width: 44px; height: 44px; }
  .chat-suggestion { white-space: normal; }
}
