/* Hexablock Cockpit - theme sombre, accent olive, Lora/Poppins avec repli systeme */
:root {
  --fond: #14161a;
  --tuile: #1c1f25;
  --bord: #2a2e36;
  --texte: #d9dbe0;
  --sourdine: #8b9099;
  --olive: #8a9a5b;
  --olive-fonce: #5f6b3f;
  --rouge: #b05252;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background: var(--fond);
  color: var(--texte);
  font-family: Poppins, "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
  min-height: 100vh;
}
h1, h2 { font-family: Lora, Georgia, serif; font-weight: 600; }

header {
  display: flex; align-items: center; gap: 24px;
  padding: 14px 22px;
  border-bottom: 2px solid var(--olive);
  background: var(--tuile);
  position: sticky; top: 0; z-index: 10;
}
header h1 { font-size: 20px; letter-spacing: 1px; }
header h1 span { color: var(--olive); }
#recherche {
  flex: 1; max-width: 520px;
  background: var(--fond); color: var(--texte);
  border: 1px solid var(--bord); border-radius: 6px;
  padding: 8px 12px; font-family: inherit;
}
#recherche:focus { outline: none; border-color: var(--olive); }

.grille {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 16px; padding: 18px;
}
.tuile {
  background: var(--tuile);
  border: 1px solid var(--bord);
  border-radius: 10px;
  padding: 16px;
  min-height: 120px;
}
.tuile.large { grid-column: span 2; }
@media (max-width: 800px) { .tuile.large { grid-column: span 1; } }
.tuile h2 {
  font-size: 15px; color: var(--olive);
  margin-bottom: 12px; display: flex; align-items: center; gap: 8px;
  cursor: grab; user-select: none;
}
.tuile h2 .repli {
  margin-left: auto; background: none; border: none; color: var(--sourdine);
  cursor: pointer; font-size: 14px; padding: 0 4px;
}
.tuile h2 .repli:hover { color: var(--texte); }
.tuile.repliee > *:not(h2) { display: none; }
.tuile.repliee { min-height: 0; }
.tuile.fantome { opacity: .35; border-style: dashed; }
.tuile.survol-drop { border-color: var(--olive); }

/* Blocs agents individuels */
.agent-bloc { border-top: 3px solid var(--accent, var(--olive)); }
.agent-bloc h2 { color: var(--accent, var(--olive)); text-transform: capitalize; }
.agent-bloc .stat { color: var(--sourdine); font-size: 12px; margin-bottom: 8px; }
.agent-bloc .fichiers .ligne { font-size: 12.5px; }
.agent-bloc .actions-agent { margin-top: 8px; display: flex; gap: 8px; flex-wrap: wrap; }

/* Moteurs LLM */
.moteur { display: flex; justify-content: space-between; align-items: center; padding: 6px 8px; border: 1px solid var(--bord); border-radius: 6px; margin-bottom: 6px; }
.moteur .canal { color: var(--sourdine); font-size: 11.5px; }
.statut { font-size: 11px; border-radius: 4px; padding: 1px 7px; }
.statut.actif { background: var(--olive-fonce); color: #fff; }
.statut.inactif { background: var(--bord); color: var(--sourdine); }
.routage { margin-top: 12px; }
.routage .classe { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.routage .pastille { width: 10px; height: 10px; border-radius: 50%; }
.routage select {
  background: var(--fond); color: var(--texte); border: 1px solid var(--bord);
  border-radius: 6px; padding: 4px 8px; font-family: inherit; flex: 1;
}
.routage .libelle { width: 190px; font-size: 12px; color: var(--sourdine); }

/* Securite */
.securite-ligne { display: flex; justify-content: space-between; padding: 5px 0; border-bottom: 1px solid var(--bord); font-size: 13px; }
.securite-ligne .val { color: var(--olive); }
.securite-ligne .val.alerte { color: var(--rouge); }
#zone-securite input[type=password] {
  background: var(--fond); color: var(--texte); border: 1px solid var(--bord);
  border-radius: 6px; padding: 6px 10px; font-family: inherit; width: 100%; margin: 10px 0 8px;
}
.badge {
  background: var(--olive-fonce); color: #fff;
  border-radius: 10px; padding: 1px 8px; font-size: 12px; font-family: Poppins, sans-serif;
}
.vide { color: var(--sourdine); font-style: italic; }
.legende { color: var(--sourdine); font-size: 12px; margin-top: 8px; }

/* Agents */
.agent {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 10px; border-radius: 6px; cursor: pointer;
}
.agent:hover { background: var(--bord); }
.agent .nom { text-transform: capitalize; font-weight: 500; }
.agent .meta { color: var(--sourdine); font-size: 12px; }

/* InBox + recherche */
.ligne { padding: 6px 10px; border-radius: 6px; display: flex; justify-content: space-between; gap: 10px; }
.ligne:hover { background: var(--bord); cursor: pointer; }
.ligne .meta { color: var(--sourdine); font-size: 12px; white-space: nowrap; }
#resultats-recherche {
  position: fixed; top: 62px; left: 22px; right: 22px; z-index: 20;
  background: var(--tuile); border: 1px solid var(--olive); border-radius: 10px;
  max-height: 60vh; overflow-y: auto; padding: 10px;
  box-shadow: 0 10px 40px rgba(0,0,0,.6);
}

/* Validations */
.validation {
  border: 1px solid var(--bord); border-left: 3px solid var(--olive);
  border-radius: 6px; padding: 10px; margin-bottom: 10px;
}
.validation .quoi { font-weight: 500; margin-bottom: 4px; }
.validation .detail { color: var(--sourdine); font-size: 12.5px; white-space: pre-wrap; margin-bottom: 8px; max-height: 140px; overflow-y: auto; }
.validation .actions { display: flex; gap: 8px; }

/* Kanban */
.kanban { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
@media (max-width: 800px) { .kanban { grid-template-columns: repeat(2, 1fr); } }
.colonne { background: var(--fond); border-radius: 8px; padding: 8px; min-height: 140px; }
.colonne h3 { font-size: 12.5px; color: var(--sourdine); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 8px; font-family: Poppins, sans-serif; }
.carte {
  background: var(--tuile); border: 1px solid var(--bord); border-radius: 6px;
  padding: 8px; margin-bottom: 8px; font-size: 13px;
}
.carte .tags { margin-top: 4px; }
.tag { display: inline-block; background: var(--olive-fonce); color: #fff; border-radius: 4px; padding: 0 6px; font-size: 11px; margin-right: 4px; }
.carte .nav { display: flex; gap: 6px; margin-top: 6px; }
.mini { background: none; border: 1px solid var(--bord); color: var(--sourdine); border-radius: 4px; cursor: pointer; font-size: 11px; padding: 1px 6px; }
.mini:hover { border-color: var(--olive); color: var(--texte); }
.ajout-carte { width: 100%; background: none; border: 1px dashed var(--bord); color: var(--sourdine); border-radius: 6px; padding: 6px; cursor: pointer; }
.ajout-carte:hover { border-color: var(--olive); color: var(--texte); }

/* Veille accordeon */
details { border: 1px solid var(--bord); border-radius: 6px; margin-bottom: 8px; }
details summary { padding: 8px 10px; cursor: pointer; }
details pre { padding: 10px; white-space: pre-wrap; font-family: inherit; font-size: 13px; color: var(--sourdine); border-top: 1px solid var(--bord); max-height: 260px; overflow-y: auto; }

/* Boutons */
.btn {
  background: var(--bord); color: var(--texte); border: none;
  border-radius: 6px; padding: 7px 14px; cursor: pointer; font-family: inherit;
}
.btn.olive { background: var(--olive-fonce); color: #fff; }
.btn.olive:hover { background: var(--olive); }
.btn.rouge { background: var(--rouge); color: #fff; }

/* Editeur */
.cache { display: none !important; }
#editeur {
  position: fixed; inset: 0; background: rgba(0,0,0,.7); z-index: 30;
  display: flex; align-items: center; justify-content: center;
}
.editeur-boite {
  width: min(920px, 94vw); height: min(680px, 88vh);
  background: var(--tuile); border: 1px solid var(--olive); border-radius: 10px;
  display: flex; flex-direction: column;
}
.editeur-titre { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--bord); color: var(--olive); }
#editeur-texte {
  flex: 1; background: var(--fond); color: var(--texte);
  border: none; resize: none; padding: 14px;
  font-family: Consolas, monospace; font-size: 13.5px; line-height: 1.5;
}
#editeur-texte:focus { outline: none; }
canvas { width: 100%; background: radial-gradient(ellipse at center, #191c22 0%, #121419 100%); border-radius: 8px; }

/* Dictaphone + journal */
.meta-titre { color: var(--sourdine); font-size: 11.5px; font-family: Poppins, sans-serif; font-weight: 400; }
.dicta-controles { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
#dicta-bouton.enregistre { background: var(--rouge); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .6; } }
#liste-audio .ligne { align-items: center; }
#liste-audio audio { height: 28px; max-width: 200px; }
#journal-texte, #idee-texte {
  width: 100%; background: var(--fond); color: var(--texte);
  border: 1px solid var(--bord); border-radius: 6px; padding: 10px;
  font-family: inherit; font-size: 13px; resize: vertical; margin-bottom: 10px;
}
#journal-texte:focus, #idee-texte:focus { outline: none; border-color: var(--olive); }

/* Idees : actions de developpement */
.idee-item { border-bottom: 1px solid var(--bord); padding-bottom: 6px; margin-bottom: 6px; }
.idee-actions { display: flex; gap: 6px; padding: 2px 10px 4px; }

/* Chantiers */
.chantier-fichiers { padding: 4px 8px 8px; }
.chantier-fichiers .ligne { font-size: 12.5px; }

/* ===== v2 : accueil "une boite, un fil" ===== */
.colonne-unique { max-width: 820px; margin: 0 auto; padding: 22px 16px; }
.etat-cerveau { display: flex; align-items: center; gap: 8px; color: var(--sourdine); font-size: 13px; margin-left: auto; }
.voyant { width: 11px; height: 11px; border-radius: 50%; background: var(--sourdine); }
.voyant.vert { background: #5fae5f; box-shadow: 0 0 8px #5fae5f88; }
.voyant.orange { background: #cfa14f; box-shadow: 0 0 8px #cfa14f88; animation: pulse 1.4s infinite; }
.voyant.rouge { background: var(--rouge); box-shadow: 0 0 8px #b0525288; }
header a.btn { text-decoration: none; }

.zone-confie { background: var(--tuile); border: 1px solid var(--olive-fonce); border-radius: 12px; padding: 14px; margin-bottom: 18px; }
#confie-texte { width: 100%; background: var(--fond); color: var(--texte); border: 1px solid var(--bord); border-radius: 8px; padding: 12px; font-family: inherit; font-size: 14.5px; resize: vertical; }
#confie-texte:focus { outline: none; border-color: var(--olive); }
.confie-barre { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
#micro-bouton.enregistre { background: var(--rouge); color: #fff; animation: pulse 1.2s infinite; }

.carte-attente { background: var(--tuile); border: 1px solid var(--olive); border-left: 4px solid var(--olive); border-radius: 10px; padding: 12px; margin-bottom: 12px; }
.carte-attente .quoi { font-weight: 600; margin-bottom: 6px; }
.carte-attente .detail { color: var(--sourdine); font-size: 13px; white-space: pre-wrap; max-height: 150px; overflow-y: auto; margin-bottom: 8px; }
.carte-attente .detail.question { color: var(--texte); border-left: 2px solid var(--olive); padding-left: 8px; }
.carte-attente .actions { display: flex; gap: 8px; }

.fil { display: flex; flex-direction: column; gap: 8px; padding-bottom: 40px; }
.bulle { max-width: 85%; padding: 9px 13px; border-radius: 12px; font-size: 13.5px; line-height: 1.45; position: relative; white-space: pre-wrap; }
.bulle .heure { color: var(--sourdine); font-size: 11px; margin-right: 8px; }
.bulle.toi { align-self: flex-end; background: var(--olive-fonce); color: #fff; border-bottom-right-radius: 3px; }
.bulle.toi .heure { color: #ffffff99; }
.bulle.double { align-self: flex-start; background: var(--tuile); border: 1px solid var(--bord); border-bottom-left-radius: 3px; }
.bulle.systeme { align-self: center; background: none; border: none; color: var(--sourdine); font-size: 12px; }
.bulle a.ouvrir { color: var(--olive); margin-left: 8px; }

/* ===== Vue Projets : pipeline structurel ===== */
.pipeline { max-width: 1100px; margin: 0 auto; padding: 20px 16px; display: flex; flex-direction: column; gap: 20px; }
.phase h2 { font-size: 15px; color: var(--sourdine); margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.phase.decision h2 { color: var(--olive); }
.projet { background: var(--tuile); border: 1px solid var(--bord); border-radius: 10px; padding: 14px; margin-bottom: 10px; }
.phase.decision .projet { border-left: 4px solid var(--olive); }
.projet-titre { font-family: Lora, Georgia, serif; font-size: 16px; cursor: pointer; }
.projet-action { color: var(--sourdine); font-size: 13px; margin-top: 4px; }
.projet-bloque { display: inline-block; background: var(--olive-fonce); color: #fff; border-radius: 6px; padding: 2px 10px; font-size: 12px; margin-top: 8px; }
.projet-detail { margin-top: 12px; border-top: 1px solid var(--bord); padding-top: 12px; }
.decision { margin-bottom: 14px; }
.decision .question { font-weight: 600; margin-bottom: 8px; }
.decision .options { display: flex; flex-wrap: wrap; gap: 8px; }
.prises { margin: 10px 0; }
.prise { font-size: 13px; color: var(--sourdine); padding: 3px 0; }
.livrables { margin-top: 10px; font-size: 13px; }
.livrables a { color: var(--olive); }

/* Pieces jointes dans le fil */
.fil-img { max-width: 280px; max-height: 220px; border-radius: 8px; margin-top: 6px; display: block; border: 1px solid var(--bord); cursor: zoom-in; }
.chip-piece { background: var(--olive-fonce); color: #fff; border-radius: 12px; padding: 3px 10px; font-size: 12px; cursor: pointer; }

/* ===== v3 : la messagerie d'Ava (accueil redessine, PWA) ===== */
body.v3 { display: flex; flex-direction: column; min-height: 100dvh; background: linear-gradient(180deg, #14161a 0%, #101216 100%); }
.entete-v3 {
  display: flex; align-items: center; gap: 14px; padding: 10px 16px;
  background: rgba(20,22,26,.85); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--bord); position: sticky; top: 0; z-index: 20;
}
.marque { display: flex; align-items: center; gap: 10px; }
.logo-ava { width: 34px; height: 34px; border-radius: 50%; box-shadow: 0 0 14px #5f6b3f66; }
.nom-ava { font-family: Lora, Georgia, serif; font-size: 20px; font-weight: 600; letter-spacing: .5px; }
.nav-v3 { margin-left: auto; display: flex; gap: 6px; }
.nav-v3 a {
  color: var(--sourdine); text-decoration: none; font-size: 12.5px;
  padding: 7px 12px; border-radius: 8px; transition: all .15s;
}
.nav-v3 a:hover { color: var(--texte); background: var(--bord); }
body.v3 .etat-cerveau { margin-left: 0; }

.scene { flex: 1; width: 100%; max-width: 780px; margin: 0 auto; padding: 18px 14px 8px; }
.fil-v3 { display: flex; flex-direction: column; gap: 10px; }
.fil-v3 .bulle { animation: apparait .25s ease-out; box-shadow: 0 2px 10px rgba(0,0,0,.25); }
@keyframes apparait { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.fil-v3 .bulle.toi { background: linear-gradient(135deg, #5f6b3f, #4d5733); }
.fil-v3 .bulle.double { background: #1e2128; border-color: #2e323b; }
.fichier-chip {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 6px;
  background: #14161a; border: 1px solid var(--bord); border-radius: 8px;
  padding: 6px 12px; color: var(--olive); text-decoration: none; font-size: 12.5px;
}
.fichier-chip:hover { border-color: var(--olive); }

.composeur {
  position: sticky; bottom: 0; z-index: 20;
  background: rgba(16,18,22,.92); backdrop-filter: blur(14px);
  border-top: 1px solid var(--bord);
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
}
.composeur #attentes { max-width: 780px; margin: 0 auto; }
.composeur .carte-attente { margin-bottom: 10px; box-shadow: 0 -4px 24px rgba(138,154,91,.12); }
.zone-confie-v3 {
  max-width: 780px; margin: 0 auto; display: flex; align-items: flex-end; gap: 8px;
  background: #1c1f25; border: 1px solid var(--bord); border-radius: 22px; padding: 8px 10px;
  transition: border-color .15s;
}
.zone-confie-v3:focus-within { border-color: var(--olive); box-shadow: 0 0 0 3px #8a9a5b22; }
.zone-confie-v3 textarea {
  flex: 1; background: none; border: none; color: var(--texte);
  font-family: inherit; font-size: 15px; line-height: 1.45; resize: none;
  max-height: 160px; padding: 6px 8px;
}
.zone-confie-v3 textarea:focus { outline: none; }
.boutons-confie { display: flex; gap: 6px; }
.rond {
  width: 38px; height: 38px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--bord); color: var(--texte); font-size: 16px;
  display: flex; align-items: center; justify-content: center; transition: all .15s;
}
.rond:hover { background: #353a44; transform: scale(1.06); }
.rond.envoyer { background: var(--olive-fonce); color: #fff; }
.rond.envoyer:hover { background: var(--olive); }
.rond.enregistre { background: var(--rouge); color: #fff; animation: pulse 1.2s infinite; }
.sous-composeur { max-width: 780px; margin: 6px auto 0; display: flex; align-items: center; gap: 10px; min-height: 18px; }
@media (max-width: 640px) {
  .nav-v3 a { padding: 7px 9px; font-size: 12px; }
  .nom-ava { font-size: 18px; }
  #etat-texte { display: none; } /* sur mobile, le voyant seul suffit */
}
