:root {
  --bg: #F6F5F1; --surface: #FCFBF8; --surface-2: #EFF1EC; --line: #DEDBD2; --fg: #15212B; --muted: #56626C; --faint: #7D8890;
  --accent: #0B7480; --accent-ink: #FFFFFF; --accent-soft: #E3F0F1; --accent-line: #9CC9CE;
  --warn: #A64F0E; --warn-soft: #F9ECE3; --warn-line: #E5C4AE;
  --ok: #2C7650; --ok-soft: #E4F1E9; --ok-line: #B3D6C0;
  --ink: #0E2A38; --ink-fg: #F3F1EA;
  --font-display: "Space Grotesk", "Segoe UI", system-ui, sans-serif;
  --font-body: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --rayon: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0E181E; --surface: #14222A; --surface-2: #1A2C35; --line: #2A3E48; --fg: #E6ECEE; --muted: #A5B5BB; --faint: #7F9198;
    --accent: #5DBDC8; --accent-ink: #06191D; --accent-soft: #143840; --accent-line: #2E6670;
    --warn: #F0A36C; --warn-soft: #38251A; --warn-line: #6A4229;
    --ok: #7ACB9C; --ok-soft: #163128; --ok-line: #2E5C45;
    --ink: #091319; --ink-fg: #E6ECEE;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--font-body); font-size: 15px; line-height: 1.5;
  -webkit-font-smoothing: antialiased; display: flex; flex-direction: column; }
button, input, textarea { font: inherit; color: inherit; }
.visuellement-cache { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.entete { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 20px;
  border-bottom: 1px solid var(--line); background: var(--surface); }
.marque h1 { margin: 0; font-family: var(--font-display); font-size: 20px; font-weight: 600; letter-spacing: -.01em; }
.marque .fin { color: var(--muted); font-weight: 500; }
.sous-titre { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.entete-actions { display: flex; align-items: center; gap: 10px; }
.badge { font-size: 12px; padding: 3px 9px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); }

.grille { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(260px, 340px) minmax(0, 1fr); gap: 16px; padding: 16px 20px; }
.grille.avec-coulisses { grid-template-columns: minmax(260px, 340px) minmax(0, 1fr) minmax(280px, 380px); }
.volet { background: var(--surface); border: 1px solid var(--line); border-radius: var(--rayon); min-height: 0; }
.volet-avatar { padding: 14px; display: flex; flex-direction: column; gap: 10px; overflow: auto; }
.volet-conversation { display: flex; flex-direction: column; min-height: 0; }
.volet-coulisses { padding: 14px; overflow: auto; font-size: 13px; }

.ecran { position: relative; aspect-ratio: 3 / 4; background: var(--ink); border-radius: 10px; overflow: hidden; }
.ecran video { width: 100%; height: 100%; object-fit: cover; display: block; }
.ecran-repos { position: absolute; inset: 0; display: grid; place-items: center; padding: 20px; text-align: center; color: var(--ink-fg); font-size: 14px; }
.ecran.actif .ecran-repos { display: none; }
.sous-titres { position: absolute; left: 8px; right: 8px; bottom: 8px; margin: 0; padding: 6px 10px; border-radius: 8px;
  background: rgba(9, 19, 25, .72); color: #F3F1EA; font-size: 13px; line-height: 1.4; display: none; }
.sous-titres.visible { display: block; }
.etat-avatar { margin: 0; font-size: 13px; color: var(--muted); }
.commandes { display: flex; gap: 8px; }
.commandes .bouton { flex: 1; }
.aide { margin: 0; font-size: 12px; color: var(--faint); }

.bouton { border: 1px solid var(--line); background: var(--surface); padding: 8px 14px; border-radius: 9px; cursor: pointer; font-weight: 500; }
.bouton:hover:not(:disabled) { border-color: var(--accent-line); }
.bouton:disabled { opacity: .5; cursor: not-allowed; }
.bouton:focus-visible, textarea:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.bouton.principal { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.bouton.discret { background: transparent; }
.bouton.parler { width: 100%; padding: 12px; }
.bouton.parler.enregistre { background: var(--warn); border-color: var(--warn); color: #fff; }

.fil { flex: 1; overflow: auto; padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.message { max-width: 760px; }
.message.utilisateur { align-self: flex-end; background: var(--accent-soft); border: 1px solid var(--accent-line); padding: 10px 14px; border-radius: 12px 12px 2px 12px; }
.message.agent { align-self: flex-start; width: 100%; }
.message.agent > * + * { margin-top: 10px; }
.message.accueil p { margin: 0; color: var(--muted); }
.bloc { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; background: var(--surface); }
.bloc h3 { margin: 0 0 6px; font-family: var(--font-display); font-size: 14px; font-weight: 600; }
.bloc p { margin: 0 0 8px; } .bloc p:last-child { margin-bottom: 0; }
.bloc ul { margin: 0 0 8px; padding-left: 18px; } .bloc li { margin: 4px 0; }
.mention { display: block; width: fit-content; max-width: 100%; font-size: 12px; line-height: 1.4; padding: 3px 9px; border-radius: 7px; margin-bottom: 8px; }
.mention.validee { background: var(--ok-soft); color: var(--ok); border: 1px solid var(--ok-line); }
.mention.redigee { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.mention.experimental { background: var(--warn-soft); color: var(--warn); border: 1px solid var(--warn-line); }
.bloc.alerte { background: var(--warn-soft); border-color: var(--warn-line); }
.bloc.alerte p { color: var(--fg); }
.ref { font-family: var(--font-mono); font-size: 11px; color: var(--accent); background: none; border: 0; padding: 0 1px; cursor: pointer; vertical-align: super; }
.sources { margin: 10px 0 0; padding: 10px 0 0; border-top: 1px dashed var(--line); list-style: none; font-size: 13px; }
.sources li { display: flex; gap: 8px; margin: 3px 0; }
.sources .n { font-family: var(--font-mono); color: var(--accent); flex: none; }
.sources button { background: none; border: 0; padding: 0; text-align: left; color: var(--fg); cursor: pointer; text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; }
.sources-texte { font-size: 12px; color: var(--muted); margin-top: 6px; white-space: pre-line; }
.pied-message { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12px; color: var(--faint); }
.pied-message .bouton { padding: 3px 9px; font-size: 12px; }
.pied-message .bouton.choisi { border-color: var(--accent); color: var(--accent); }
.relais { border: 1px solid var(--accent-line); background: var(--accent-soft); border-radius: 10px; padding: 12px 14px; }
.relais p { margin: 0 0 8px; }
.relais .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.relais form { display: grid; gap: 8px; margin-top: 8px; }
.relais label { font-size: 13px; font-weight: 500; }
.relais input[type=text], .relais input[type=email] { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.relais .consentement { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; }
.attente { color: var(--muted); font-size: 14px; display: flex; gap: 8px; align-items: center; }
.attente::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); animation: pulse 1s infinite ease-in-out; }
@keyframes pulse { 50% { opacity: .25; } }

.saisie { display: flex; gap: 10px; padding: 12px; border-top: 1px solid var(--line); }
.saisie textarea { flex: 1; resize: none; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--bg); }

.coulisses-entete { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.coulisses-entete h2 { margin: 0; font-family: var(--font-display); font-size: 15px; }
.volet-coulisses h3 { font-size: 13px; margin: 14px 0 4px; font-family: var(--font-display); }
.volet-coulisses table { width: 100%; border-collapse: collapse; }
.volet-coulisses td, .volet-coulisses th { text-align: left; padding: 3px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
.volet-coulisses code { font-family: var(--font-mono); font-size: 11px; word-break: break-all; }
.ecartee { color: var(--warn); }

dialog { border: 1px solid var(--line); border-radius: var(--rayon); background: var(--surface); color: var(--fg); max-width: min(720px, 92vw); width: 100%; padding: 16px 18px; }
dialog::backdrop { background: rgba(9, 19, 25, .5); }
.fenetre-entete { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.fenetre-entete h2 { margin: 0; font-family: var(--font-display); font-size: 16px; }
#fenetre-contenu { white-space: pre-wrap; font-size: 14px; max-height: 70vh; overflow: auto; }
#fenetre-contenu .meta { color: var(--muted); font-size: 12px; white-space: normal; }

.acces { position: fixed; inset: 0; background: var(--bg); display: grid; place-items: center; padding: 16px; z-index: 10; }
.acces-carte { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: var(--rayon); padding: 22px; display: grid; gap: 10px; }
.acces-carte h2 { margin: 0; font-family: var(--font-display); }
.acces-carte p { margin: 0; color: var(--muted); }
.acces-carte input { padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.erreur { color: var(--warn); font-size: 13px; }

@media (max-width: 900px) {
  html, body { height: auto; }
  .grille, .grille.avec-coulisses { display: flex; flex-direction: column; padding: 10px 16px; gap: 10px; }
  .volet-avatar { flex: none; }
  .ecran { aspect-ratio: 4 / 3; max-height: 42vh; }
  .volet-conversation { min-height: 75vh; }
  .entete { padding: 10px 16px; }
  .sous-titre { display: none; }
  .marque h1 { font-size: 17px; }
}
