/* Espace web d'Ernest (T11.1). Fluide sous Firefox : aucun flou, d'arrière-plan ou de filtre (refusés par
   verifier.sh), ni ombre ou animation sur de nombreux éléments ; polices du système, rien de chargé ailleurs. */
:root {
  --fond: #ffffff;
  --barre: #f5f5f2;
  --releve: #efefeb;
  --trait: #e3e2dd;
  --texte: #1d1d1b;
  --texte2: #5b5a55;
  --texte3: #85847e;
  --accent: #2f5fd0;
  --bulle: #f0f0ed;
  --robokafe: #a35d26;
  --beitea: #2c8660;
  --general: #7b7a75;
  --bon: #1f7a3a;
  --bon-fond: #e4f3e8;
  --alerte: #8f5d00;
  --alerte-fond: #fbf0d9;
  --mauvais: #c0352d;
  --police: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fond: #1a1a19; --barre: #131312; --releve: #262624; --trait: #34342f;
    --texte: #ecebe6; --texte2: #b4b3ac; --texte3: #8a8983; --accent: #85a6f2; --bulle: #2a2a27;
    --robokafe: #d38d54; --beitea: #57b88c; --general: #9c9b95;
    --bon: #62c47f; --bon-fond: #1b3123; --alerte: #e2a845; --alerte-fond: #382c14; --mauvais: #f08077;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--fond); color: var(--texte); font: 15px/1.5 var(--police); -webkit-text-size-adjust: 100%; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, a:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h3 { margin: 0; line-height: 1.25; text-wrap: balance; }

.marque { width: 32px; height: 32px; border-radius: 9px; background: var(--texte); color: var(--fond);
  display: grid; place-items: center; font-weight: 700; flex: none; }
.sous { color: var(--texte3); font-size: 13px; margin: 0; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--trait);
  background: var(--fond); border-radius: 10px; padding: 8px 14px; font-weight: 600; font-size: 14px; text-decoration: none; color: var(--texte); }
.btn.primaire { background: var(--texte); color: var(--fond); border-color: var(--texte); }
.btn.grand { padding: 12px 20px; font-size: 15px; }
.btn:disabled { opacity: .5; cursor: default; }
.icone { border: 0; background: none; width: 36px; height: 36px; border-radius: 50%; display: inline-grid; place-items: center; color: var(--texte2); flex: none; }
.lien-discret { border: 0; background: none; color: var(--texte3); font-size: 13px; padding: 4px; margin-left: auto; }
.lien-discret:hover { color: var(--texte); }
.point { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; background: var(--general); }
.point.robokafe { background: var(--robokafe); }
.point.beitea { background: var(--beitea); }

/* Connexion */
.connexion { min-height: 100%; display: grid; place-items: center;
  padding: max(24px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
.connexion-carte { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; max-width: 360px; }
.connexion-carte .marque { width: 56px; height: 56px; border-radius: 16px; font-size: 26px; }
.connexion-carte h1 { font-size: 28px; }
.connexion-carte .btn { margin-top: 12px; }
.note { color: var(--mauvais); font-size: 14px; min-height: 1.5em; margin: 0; }

/* Mise en page */
.app { display: grid; grid-template-columns: 272px minmax(0, 1fr); height: 100vh; height: 100dvh; }
.barre { background: var(--barre); border-right: 1px solid var(--trait); display: flex; flex-direction: column; gap: 8px; min-height: 0;
  padding: max(12px, env(safe-area-inset-top)) 10px max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)); }
.entete-barre { display: flex; align-items: center; gap: 10px; padding: 4px 6px 6px; }
.entete-barre .nom { font-weight: 650; }
.nouvelle { display: flex; align-items: center; gap: 8px; width: 100%; border: 1px solid var(--trait); background: var(--fond);
  border-radius: 10px; padding: 9px 10px; font-weight: 550; }
.nouvelle:hover { background: var(--releve); }
.liste { flex: 1; overflow-y: auto; min-height: 0; display: flex; flex-direction: column; gap: 1px; padding-top: 4px; }
.liste .quand { font-size: 12px; color: var(--texte3); padding: 12px 10px 3px; }
.liste button { display: flex; align-items: center; gap: 9px; border: 0; background: none; border-radius: 8px; padding: 8px 10px;
  text-align: left; min-width: 0; }
.liste button span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.liste button:hover, .liste button[aria-current="true"] { background: var(--releve); }
.liste .vide { color: var(--texte3); font-size: 13px; padding: 10px; }
.moi { display: flex; align-items: center; gap: 10px; border-top: 1px solid var(--trait); padding: 10px 6px 0; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--releve); display: grid; place-items: center; font-size: 13px; font-weight: 650; flex: none; }
.moi-nom { font-weight: 600; }

.principal { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.haut { display: flex; align-items: center; gap: 10px; min-height: 54px; border-bottom: 1px solid var(--trait);
  padding: max(8px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 8px max(16px, env(safe-area-inset-left)); }
.haut .menu { display: none; }
.haut .titre { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.societe { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--texte2); white-space: nowrap; }

.fil { flex: 1; overflow-y: auto; min-height: 0; overscroll-behavior: contain;
  padding: 20px max(16px, env(safe-area-inset-right)) 12px max(16px, env(safe-area-inset-left)); }
.fil-interieur { max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; }

/* Messages */
.equipe { align-self: flex-end; background: var(--bulle); border-radius: 18px; padding: 9px 15px; max-width: 82%;
  white-space: pre-wrap; overflow-wrap: anywhere; }
.ernest { display: flex; gap: 12px; align-items: flex-start; }
.ernest .marque { width: 28px; height: 28px; border-radius: 8px; font-size: 13px; margin-top: 2px; }
.ernest .corps { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 10px; overflow-wrap: anywhere; }
.texte p { margin: 0 0 .6em; }
.texte p:last-child { margin-bottom: 0; }
.texte ul, .texte ol { margin: 0 0 .6em; padding-left: 1.3em; }
.texte h3 { font-size: 16px; margin: .4em 0; }
.texte code { font-family: var(--mono); font-size: .9em; background: var(--releve); border-radius: 4px; padding: 1px 4px; }
.texte pre { background: var(--releve); border-radius: 8px; padding: 10px 12px; overflow-x: auto; margin: 0 0 .6em; }
.texte pre code { background: none; padding: 0; }
.texte a { color: var(--accent); }
.brut { white-space: pre-wrap; }
.statut { color: var(--texte3); font-size: 13px; }
.points { display: inline-flex; gap: 4px; padding: 6px 0; }
.points i { width: 6px; height: 6px; border-radius: 50%; background: var(--texte3); animation: clignote 1s infinite; }
.points i:nth-child(2) { animation-delay: .15s; }
.points i:nth-child(3) { animation-delay: .3s; }
@keyframes clignote { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }
.erreur { color: var(--mauvais); font-size: 14px; }

.carte { border: 1px solid var(--trait); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; max-width: 560px; }
.carte .etiquette { align-self: flex-start; font-size: 12px; font-weight: 650; border-radius: 999px; padding: 2px 9px; background: var(--alerte-fond); color: var(--alerte); }
.carte.validee .etiquette { background: var(--bon-fond); color: var(--bon); }
.carte .contenu { white-space: pre-wrap; font-size: 14px; }
.carte .actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Nouvelle discussion */
.accueil { max-width: 680px; margin: 8vh auto 0; display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; }
.accueil h1 { font-size: 26px; font-weight: 650; }
.choix { display: inline-flex; background: var(--releve); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; justify-content: center; }
.choix button { border: 0; background: none; border-radius: 8px; padding: 6px 12px; font-size: 14px; color: var(--texte2); display: inline-flex; align-items: center; gap: 7px; }
.choix button[aria-pressed="true"] { background: var(--fond); color: var(--texte); font-weight: 600; }
.suggestions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; width: 100%; margin-top: 10px; }
.suggestions button { text-align: left; border: 1px solid var(--trait); background: var(--fond); border-radius: 12px; padding: 12px 14px; }
.suggestions button:hover { background: var(--releve); }

/* Saisie */
.saisie { margin: 0; padding: 8px max(16px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
.champ { max-width: 760px; margin: 0 auto; border: 1px solid var(--trait); border-radius: 22px; background: var(--fond);
  padding: 8px 8px 8px 16px; display: flex; align-items: flex-end; gap: 8px; }
.champ textarea { flex: 1; border: 0; resize: none; background: none; color: var(--texte); font: inherit; font-size: 16px; outline: none;
  min-height: 24px; max-height: 200px; padding: 6px 0; }
.envoyer { background: var(--texte); color: var(--fond); }
.envoyer:disabled { opacity: .35; cursor: default; }
.aide { max-width: 760px; margin: 6px auto 0; text-align: center; font-size: 12px; color: var(--texte3); }

.voile { position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 20; }

@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .barre { position: fixed; top: 0; bottom: 0; left: 0; width: min(300px, 86vw); z-index: 25; transform: translateX(-100%); transition: transform .2s ease; }
  .barre.ouverte { transform: none; }
  .haut .menu { display: inline-grid; }
  .suggestions { grid-template-columns: minmax(0, 1fr); }
  .equipe { max-width: 92%; }
  .accueil { margin-top: 4vh; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
