:root {
  --fond: #f4f3f7; --carte: #ffffff; --texte: #1d1b26; --texte-2: #5d5a6b; --ligne: #e3e0ea;
  --accent: #6a4fd8; --accent-doux: #efeafd; --ok: #1f8a52; --ok-doux: #e5f5ec; --att: #b8660b; --att-doux: #fdf1e2;
  --mauvais: #c0392b; --bulle-fan: #eceaf1; --bulle-elle: #6a4fd8; --bulle-eleve: #fff6d9;
  --rayon: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fond: #15141a; --carte: #1f1d26; --texte: #ecebf1; --texte-2: #a7a3b5; --ligne: #34313f;
    --accent: #9d86ff; --accent-doux: #2b2544; --ok: #4cc287; --ok-doux: #1b3326; --att: #f0a54a; --att-doux: #3a2b18;
    --mauvais: #ff7b6b; --bulle-fan: #2c2a35; --bulle-elle: #5a43c2; --bulle-eleve: #3a3420;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--fond); color: var(--texte); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }

.carte { background: var(--carte); border: 1px solid var(--ligne); border-radius: var(--rayon); padding: 14px; margin-bottom: 12px; }
.ecran-connexion { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.connexion { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 12px; }
.connexion h1 { margin: 0; font-size: 22px; }
.sous { margin: 0; color: var(--texte-2); }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--texte-2); }
input, select, textarea { background: var(--fond); border: 1px solid var(--ligne); border-radius: 8px; padding: 9px 10px; width: 100%; }
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 0; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 14px; min-height: 42px; border-radius: 9px; border: 1px solid var(--ligne); background: var(--carte); cursor: pointer; font-weight: 600; text-decoration: none; color: var(--texte); }
.btn:hover { border-color: var(--accent); }
.btn.primaire { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.ok { background: var(--ok-doux); color: var(--ok); border-color: var(--ok); }
.btn.attention { background: var(--att-doux); color: var(--att); border-color: var(--att); }
.btn.discret-btn { color: var(--texte-2); }
.btn.petit { min-height: 32px; padding: 5px 10px; font-size: 13px; font-weight: 500; }
.lien { background: none; border: none; color: var(--texte-2); cursor: pointer; text-decoration: underline; padding: 4px; }
.erreur { color: var(--mauvais); margin: 6px 0 0; min-height: 1em; }
.discret { color: var(--texte-2); font-weight: 400; }
.aide { color: var(--texte-2); font-size: 13px; margin: 4px 0 8px; }

.barre { position: sticky; top: 0; z-index: 5; background: var(--carte); border-bottom: 1px solid var(--ligne); display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 8px 16px; }
.marque { font-weight: 700; }
.onglets { display: flex; gap: 4px; overflow-x: auto; flex: 1 1 auto; order: 3; width: 100%; }
.onglet { background: none; border: none; padding: 8px 12px; border-radius: 8px; cursor: pointer; color: var(--texte-2); white-space: nowrap; font-weight: 600; }
.onglet.actif { background: var(--accent-doux); color: var(--accent); }
.pastille:not(:empty) { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 4px; border-radius: 10px; background: var(--accent); color: #fff; font-size: 12px; text-align: center; }
.moi { margin-left: auto; font-size: 13px; color: var(--texte-2); display: flex; align-items: center; gap: 6px; }
@media (min-width: 760px) { .onglets { order: 0; width: auto; } }

main { padding: 12px 16px 40px; max-width: 1600px; margin: 0 auto; }
.vide { text-align: center; padding: 48px 16px; }

.grille { display: grid; grid-template-columns: 1fr; gap: 12px; }
.grille .carte { margin: 0; min-width: 0; }
@media (min-width: 1100px) {
  .grille { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr) minmax(0, 0.9fr); align-items: start; }
  .col { position: sticky; top: 64px; max-height: calc(100vh - 80px); overflow-y: auto; }
  .col-conv { display: flex; flex-direction: column; }
  .col-conv .fil { flex: 1; max-height: none; }
}
.col-titre { font-weight: 700; margin-bottom: 8px; }

.etat { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.etat-item { background: var(--accent-doux); color: var(--accent); border-radius: 20px; padding: 3px 10px; font-size: 12.5px; }

.fil { display: flex; flex-direction: column; gap: 8px; max-height: 60vh; overflow-y: auto; padding-right: 4px; }
.col-pro .fil { max-height: none; }
.msg { display: flex; flex-direction: column; max-width: 88%; gap: 4px; }
.msg-fan { align-self: flex-start; }
.msg-elle { align-self: flex-end; align-items: flex-end; }
.bulle { padding: 8px 12px; border-radius: 14px; white-space: pre-wrap; word-break: break-word; }
.msg-fan .bulle { background: var(--bulle-fan); border-bottom-left-radius: 4px; }
.msg-elle .bulle { background: var(--bulle-elle); color: #fff; border-bottom-right-radius: 4px; }
.msg-pro .bulle { outline: 2px solid var(--ok); outline-offset: 1px; }
.meta { font-size: 11.5px; color: var(--texte-2); }
.carte-evt { font-size: 13px; padding: 6px 10px; border-radius: 9px; border: 1px dashed var(--ligne); background: var(--carte); }
.carte-photo { border-color: var(--accent); color: var(--accent); }
.carte-pack { border-color: var(--att); color: var(--att); }
.carte-achat { border-color: var(--ok); color: var(--ok); border-style: solid; }
.carte-cadeau { border-color: var(--ok); color: var(--ok); }
.separateur { text-align: center; font-size: 12px; color: var(--texte-2); border-top: 1px solid var(--ligne); padding-top: 6px; margin-top: 4px; }

.reponse { border: 1px solid var(--ligne); border-radius: 10px; padding: 10px; margin-bottom: 10px; }
.reponse-titre { font-weight: 700; font-size: 13px; margin-bottom: 6px; }
.etiquette { font-size: 11px; letter-spacing: .06em; font-weight: 700; color: var(--texte-2); margin-top: 6px; }
.bulle-eleve { background: var(--bulle-eleve); }
.action { font-weight: 600; padding: 4px 0; }
.reflexion summary { cursor: pointer; color: var(--texte-2); font-size: 13px; margin-top: 8px; }
.reflexion-texte { white-space: pre-wrap; font-size: 13px; color: var(--texte-2); max-height: 320px; overflow-y: auto; padding: 6px 0; }
.consigne-vue { background: var(--att-doux); border-left: 3px solid var(--att); border-radius: 8px; padding: 8px 10px; margin: 0 0 10px; white-space: pre-wrap; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.actions .btn { flex: 1 1 auto; }
.zone-consigne { margin-top: 12px; }
.zone-consigne label { font-weight: 700; color: var(--texte); font-size: 14px; }

.tuiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 12px; }
@media (min-width: 760px) { .tuiles { grid-template-columns: repeat(4, 1fr); } }
.tuile { margin: 0; text-align: center; }
.tuile-v { font-size: 28px; font-weight: 700; }
.tuile-l { color: var(--texte-2); font-size: 13px; }
.tableau-defile { overflow-x: auto; }
.tableau { border-collapse: collapse; width: 100%; font-size: 13.5px; }
.tableau th, .tableau td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--ligne); white-space: nowrap; }
.tableau th { color: var(--texte-2); font-weight: 600; }

.ligne-form { display: flex; flex-wrap: wrap; gap: 8px; }
.ligne-form input, .ligne-form select { flex: 1 1 180px; width: auto; }
.resultat { margin: 8px 0 0; word-break: break-all; }
.resultat code { background: var(--accent-doux); padding: 2px 6px; border-radius: 5px; font-size: 15px; }
.compte { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--ligne); }
.compte.inactif { opacity: .6; }
.compte-actions { display: flex; gap: 6px; }
