:root {
  --fond: #14120f; --fond2: #1c1a17; --carte: #24211d; --carte2: #2d2924; --ligne: #3a352e;
  --texte: #eee8df; --doux: #a59d90; --accent: #d97757; --accent-doux: #d9775726; --danger: #e5534b; --ok: #4fbf7f;
  --rayon: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--fond); color: var(--texte); font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
button, input, textarea, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.bouton { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; border: 0; border-radius: 10px; background: var(--accent); color: #fff; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; }
.bouton:hover { filter: brightness(1.08); }
.bouton:disabled { opacity: .5; cursor: default; }
.bouton.secondaire { background: var(--carte2); border: 1px solid var(--ligne); color: var(--texte); }
.bouton.danger { background: var(--danger); }
.bouton.plein { width: 100%; }
.bouton.petit { padding: 5px 10px; font-size: 13px; }
.bouton.google { background: #fff; color: #1f2937; }
.icone { background: none; border: 0; color: var(--doux); font-size: 18px; width: 34px; height: 34px; border-radius: 8px; cursor: pointer; flex: none; }
.icone:hover { background: var(--carte2); color: var(--texte); }
input[type=text], input[type=email], select, textarea { background: var(--fond2); border: 1px solid var(--ligne); border-radius: 10px; padding: 9px 12px; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-doux); }

/* Page de connexion */
.porte { display: grid; place-items: center; padding: 16px; }
.carte-porte { background: var(--fond2); border: 1px solid var(--ligne); border-radius: 18px; padding: 34px; max-width: 420px; width: 100%; text-align: center; }
.carte-porte h1 { margin: 14px 0 6px; font-size: 24px; }
.carte-porte p { color: var(--doux); }
.erreur { color: var(--danger) !important; }

/* Structure */
.appli { display: grid; grid-template-columns: 290px 1fr; height: 100vh; height: 100dvh; }
.lateral { background: var(--fond2); border-right: 1px solid var(--ligne); display: flex; flex-direction: column; gap: 12px; padding: 14px; min-height: 0; }
.marque { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; padding: 2px 4px 6px; }
.projets { flex: 1; overflow-y: auto; margin: 0 -6px; padding: 0 6px; }
.projet { margin-bottom: 4px; }
.entete-projet { display: flex; align-items: center; gap: 4px; padding: 6px 6px; border-radius: 8px; cursor: pointer; color: var(--texte); font-weight: 600; }
.entete-projet:hover { background: var(--carte); }
.entete-projet .fleche { width: 14px; color: var(--doux); font-size: 11px; transition: transform .15s; }
.projet.ouvert .fleche { transform: rotate(90deg); }
.entete-projet .nom { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entete-projet .icone { width: 26px; height: 26px; font-size: 15px; }
.conversations { display: none; padding-left: 14px; }
.projet.ouvert .conversations { display: block; }
.conv { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-radius: 8px; cursor: pointer; color: var(--doux); font-size: 14px; }
.conv:hover { background: var(--carte); color: var(--texte); }
.conv.active { background: var(--accent-doux); color: var(--texte); }
.conv .titre { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv .point { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: pulse 1.2s infinite; flex: none; }
.conv .etoile { color: #e9b44c; flex: none; }
.conv.vide { cursor: default; font-style: italic; }
@keyframes pulse { 50% { opacity: .3; } }
.pied-lateral { display: flex; align-items: center; gap: 8px; border-top: 1px solid var(--ligne); padding-top: 10px; }
.pied-lateral form { margin: 0; }
.avatar { border-radius: 50%; background: var(--carte2); object-fit: cover; }
.nom-utilisateur { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; color: var(--doux); }

.principal { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.barre { display: flex; align-items: center; gap: 12px; padding: 10px 18px; border-bottom: 1px solid var(--ligne); min-height: 56px; }
.barre .menu { display: none; }
.titres { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.projet-actif { font-size: 12px; color: var(--doux); }
.conv-active { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.onglets { display: flex; background: var(--fond2); border: 1px solid var(--ligne); border-radius: 10px; padding: 3px; }
.onglets button { background: none; border: 0; padding: 6px 14px; border-radius: 7px; cursor: pointer; color: var(--doux); }
.onglets button.actif { background: var(--carte2); color: var(--texte); }
.vue { flex: 1; display: flex; flex-direction: column; min-height: 0; }

/* Accueil */
#vue-accueil { align-items: center; justify-content: center; padding: 24px; text-align: center; }
#vue-accueil h1 { margin: 12px 0 4px; }
#vue-accueil p { color: var(--doux); max-width: 560px; }
.carte-info { background: var(--fond2); border: 1px solid var(--ligne); border-radius: 16px; padding: 22px; max-width: 560px; margin-top: 18px; }

/* Conversation */
.fil { flex: 1; overflow-y: auto; padding: 22px max(18px, calc((100% - 860px) / 2)); }
.msg { margin: 0 0 16px; }
.msg.utilisateur { display: flex; justify-content: flex-end; }
.bulle { background: var(--carte2); border: 1px solid var(--ligne); border-radius: 16px 16px 4px 16px; padding: 10px 14px; max-width: 85%; white-space: pre-wrap; overflow-wrap: anywhere; }
.bulle .par { display: block; font-size: 11px; color: var(--doux); margin-bottom: 2px; }
.texte-ia { overflow-wrap: anywhere; }
.texte-ia > :first-child { margin-top: 0; }
.texte-ia > :last-child { margin-bottom: 0; }
.texte-ia pre { background: #0d0c0a; border: 1px solid var(--ligne); border-radius: 10px; padding: 12px; overflow-x: auto; font-size: 13px; }
.texte-ia code { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: .92em; }
.texte-ia :not(pre) > code { background: var(--carte2); padding: 1px 5px; border-radius: 5px; }
.texte-ia table { border-collapse: collapse; display: block; overflow-x: auto; }
.texte-ia th, .texte-ia td { border: 1px solid var(--ligne); padding: 5px 9px; }
.en-cours-texte { white-space: pre-wrap; }
.outil { border: 1px solid var(--ligne); border-radius: 10px; background: var(--fond2); margin: 8px 0; font-size: 13px; }
.outil summary { display: flex; gap: 8px; align-items: center; padding: 7px 10px; cursor: pointer; list-style: none; color: var(--doux); }
.outil summary::-webkit-details-marker { display: none; }
.outil .nom-outil { color: var(--texte); font-weight: 600; flex: none; }
.outil .resume { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: ui-monospace, Consolas, monospace; }
.outil .etat { margin-left: auto; flex: none; }
.outil.erreur .etat { color: var(--danger); }
.outil pre { margin: 0; padding: 8px 10px; border-top: 1px solid var(--ligne); max-height: 340px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 12px; color: #cfc7ba; }
.info { text-align: center; color: var(--doux); font-size: 13px; margin: 10px 0; }
.info.erreur { color: var(--danger); }
.reflexion { color: var(--doux); font-size: 14px; display: flex; align-items: center; gap: 8px; }
.reflexion::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); animation: pulse 1s infinite; }
.saisie { display: flex; gap: 10px; align-items: flex-end; padding: 12px max(18px, calc((100% - 860px) / 2)) 16px; border-top: 1px solid var(--ligne); }
.saisie textarea { flex: 1; resize: none; max-height: 220px; min-height: 44px; }

/* Fichiers */
.outils-fichiers { display: flex; gap: 10px; align-items: center; padding: 12px 18px; border-bottom: 1px solid var(--ligne); flex-wrap: wrap; }
.chemin { flex: 1; display: flex; gap: 4px; flex-wrap: wrap; align-items: center; min-width: 0; }
.chemin button { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 2px 4px; }
.liste-fichiers { flex: 1; overflow-y: auto; padding: 8px 18px; }
.ligne-fichier { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.ligne-fichier:hover { background: var(--carte); }
.ligne-fichier .nom { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ligne-fichier .meta { color: var(--doux); font-size: 13px; white-space: nowrap; }
.ligne-fichier a { font-size: 13px; }
.apercu { border-top: 1px solid var(--ligne); max-height: 50%; display: flex; flex-direction: column; min-height: 0; }
.entete-apercu { display: flex; align-items: center; gap: 10px; padding: 8px 18px; }
.entete-apercu span { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.apercu pre { margin: 0; overflow: auto; padding: 10px 18px 18px; font-size: 12.5px; white-space: pre; }

/* Dialogues */
.dialogue { background: var(--fond2); color: var(--texte); border: 1px solid var(--ligne); border-radius: 16px; padding: 0; width: min(640px, 94vw); max-height: 88vh; }
.dialogue::backdrop { background: rgb(0 0 0 / .6); }
.petit-dialogue { width: min(320px, 90vw); padding: 8px; }
.ligne-menu { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 10px 12px; border-radius: 8px; cursor: pointer; }
.ligne-menu:hover { background: var(--carte2); }
.ligne-menu.danger { color: var(--danger); }
.entete-dialogue { display: flex; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--ligne); }
.entete-dialogue h2 { flex: 1; margin: 0; font-size: 17px; }
#reglages-contenu { padding: 16px 18px 20px; overflow-y: auto; }
#reglages-contenu h3 { margin: 18px 0 8px; font-size: 15px; }
#reglages-contenu h3:first-child { margin-top: 0; }
.ligne-reglage { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.compte { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--ligne); }
.compte .email { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.pastille { font-size: 12px; padding: 1px 8px; border-radius: 99px; border: 1px solid var(--ligne); color: var(--doux); }
.pastille.ok { color: var(--ok); border-color: #2f6b49; }
.pastille.ko { color: var(--danger); border-color: #7a2c28; }
.terminal-dialogue { width: min(1000px, 96vw); }
.terminal-zone { height: min(560px, 70vh); padding: 8px; background: #000; }
.doux { color: var(--doux); font-size: 14px; }

@media (max-width: 860px) {
  .appli { grid-template-columns: 1fr; }
  .lateral { position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw); z-index: 20; transform: translateX(-100%); transition: transform .2s; }
  .appli.lateral-ouvert .lateral { transform: none; }
  .voile { display: none; }
  .appli.lateral-ouvert .voile { display: block; position: fixed; inset: 0; background: rgb(0 0 0 / .5); z-index: 10; }
  .barre .menu { display: block; }
  .barre { padding: 8px 10px; gap: 6px; }
  .onglets button { padding: 6px 9px; }
  .ligne-fichier .meta.date { display: none; }
}
