/* ============================================================================
   Impact Vision — charte graphique
   Tirée du logo et de l'affiche : bleu nuit profond, or éclatant, bleu électrique.
   Thème sombre par défaut (celui de la marque) ; thème clair et réglage automatique au choix de chacun
   (attribut data-theme posé par assets/js/theme.js). Aucun style en ligne dans les pages (la CSP l'interdit).
   ========================================================================= */

@font-face {
    font-family: 'Orbitron';
    src: url('../fonts/orbitron.woff2') format('woff2');
    font-weight: 500 900; font-style: normal; font-display: swap;
}
@font-face {
    font-family: 'Dancing Script';
    src: url('../fonts/dancing-script.woff2') format('woff2');
    font-weight: 600; font-style: normal; font-display: swap;
}

/* --- Thème sombre (marque) ------------------------------------------------------------------ */
:root {
    color-scheme: dark;
    --fond: #050b1a;
    --fond-2: #081634;
    --carte: #0b1830;
    --carte-verre: rgba(10, 22, 46, .86);
    --texte: #e8eefc;
    --discret: #9db0d3;
    --bord: #1d315c;
    --bord-or: rgba(227, 173, 62, .32);
    --champ: #08142e;
    --bleu: #3aa3ff;
    --bleu-fonce: #1f6fe0;
    --bleu-doux: #102a56;
    --or: #e3ad3e;
    --or-clair: #f7da86;
    --or-fonce: #b9801a;
    --or-texte: #1b1304;
    --or-doux: #2b220f;
    --degrade-or: linear-gradient(180deg, #f9e19a 0%, #e3ad3e 55%, #b9801a 100%);
    --degrade-bleu: linear-gradient(180deg, #8fd8ff 0%, #3aa3ff 55%, #1f6fe0 100%);
    --bulle-moi: linear-gradient(160deg, #2b7df2, #1450b8);
    --erreur: #ff9d96;
    --erreur-doux: #3b1719;
    --code-fond: #0f2147;
    --bulle-autre: #122650;
    --halo-bleu: rgba(58, 163, 255, .22);
    --halo-or: rgba(227, 173, 62, .15);
    --ombre: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 30px rgba(0, 0, 0, .35);
    --ombre-forte: 0 2px 6px rgba(0, 0, 0, .5), 0 18px 44px rgba(0, 0, 0, .55);
    --lueur-or: 0 0 22px rgba(227, 173, 62, .28);
    --lueur-bleue: 0 0 26px rgba(58, 163, 255, .28);
    --rayon: 16px;
    --rapide: .16s;
    --doux: .28s;
}

/* --- Thème clair ------------------------------------------------------------------------------ */
:root[data-theme="clair"] {
    color-scheme: light;
    --fond: #edf1f9;
    --fond-2: #e0e8f6;
    --carte: #ffffff;
    --carte-verre: rgba(255, 255, 255, .94);
    --texte: #0d1a35;
    --discret: #52627f;
    --bord: #d2dbee;
    --bord-or: rgba(185, 128, 26, .38);
    --champ: #f5f8fe;
    --bleu: #1c5dd0;
    --bleu-fonce: #154aa9;
    --bleu-doux: #e3ecfc;
    --or: #c98a14;
    --or-clair: #f1cf7a;
    --or-fonce: #a8700f;
    --or-texte: #1b1304;
    --or-doux: #fbf0d6;
    --degrade-or: linear-gradient(180deg, #e8b535 0%, #c98a14 60%, #a8700f 100%);
    --degrade-bleu: linear-gradient(180deg, #3b86f0 0%, #1c5dd0 60%, #154aa9 100%);
    --bulle-moi: linear-gradient(160deg, #2b7df2, #1450b8);
    --erreur: #b3261e;
    --erreur-doux: #fbe9e7;
    --code-fond: #e8eefb;
    --bulle-autre: #e8eefb;
    --halo-bleu: rgba(28, 93, 208, .14);
    --halo-or: rgba(201, 138, 20, .12);
    --ombre: 0 1px 2px rgba(13, 26, 53, .07), 0 8px 24px rgba(13, 26, 53, .09);
    --ombre-forte: 0 2px 4px rgba(13, 26, 53, .1), 0 14px 34px rgba(13, 26, 53, .16);
    --lueur-or: 0 0 18px rgba(201, 138, 20, .22);
    --lueur-bleue: 0 0 20px rgba(28, 93, 208, .18);
}

/* --- Réglage automatique : suit le thème du téléphone ou de l'ordinateur -------------------------- */
@media (prefers-color-scheme: light) {
    :root[data-theme="auto"] {
        color-scheme: light;
        --fond: #edf1f9;
        --fond-2: #e0e8f6;
        --carte: #ffffff;
        --carte-verre: rgba(255, 255, 255, .94);
        --texte: #0d1a35;
        --discret: #52627f;
        --bord: #d2dbee;
        --bord-or: rgba(185, 128, 26, .38);
        --champ: #f5f8fe;
        --bleu: #1c5dd0;
        --bleu-fonce: #154aa9;
        --bleu-doux: #e3ecfc;
        --or: #c98a14;
        --or-clair: #f1cf7a;
        --or-fonce: #a8700f;
        --or-texte: #1b1304;
        --or-doux: #fbf0d6;
        --degrade-or: linear-gradient(180deg, #e8b535 0%, #c98a14 60%, #a8700f 100%);
        --degrade-bleu: linear-gradient(180deg, #3b86f0 0%, #1c5dd0 60%, #154aa9 100%);
        --bulle-moi: linear-gradient(160deg, #2b7df2, #1450b8);
        --erreur: #b3261e;
        --erreur-doux: #fbe9e7;
        --code-fond: #e8eefb;
        --bulle-autre: #e8eefb;
        --halo-bleu: rgba(28, 93, 208, .14);
        --halo-or: rgba(201, 138, 20, .12);
        --ombre: 0 1px 2px rgba(13, 26, 53, .07), 0 8px 24px rgba(13, 26, 53, .09);
        --ombre-forte: 0 2px 4px rgba(13, 26, 53, .1), 0 14px 34px rgba(13, 26, 53, .16);
        --lueur-or: 0 0 18px rgba(201, 138, 20, .22);
        --lueur-bleue: 0 0 20px rgba(28, 93, 208, .18);
    }
}

* { box-sizing: border-box; }

/* Un élément reçoit souvent un « display » (flex…) qui ignorerait l'attribut hidden : celui-ci doit toujours gagner. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
    margin: 0;
    padding: 28px 16px 48px;
    color: var(--texte);
    font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background:
        radial-gradient(900px 520px at 10% -8%, var(--halo-bleu), transparent 70%),
        radial-gradient(800px 480px at 100% 102%, var(--halo-or), transparent 70%),
        linear-gradient(180deg, var(--fond), var(--fond-2));
    background-attachment: fixed;
    min-height: 100vh;
}

/* --- Cartes et titres -------------------------------------------------------------------------- */

.carte {
    position: relative;
    max-width: 780px;
    margin: 0 auto;
    padding: 28px;
    background: var(--carte-verre);
    border: 1px solid var(--bord);
    border-radius: 26px;
    box-shadow: var(--ombre);
    -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
    animation: monter var(--doux) ease-out both;
}
/* Filet doré en haut de chaque carte. */
.carte::before {
    content: ''; position: absolute; top: -1px; left: 12%; right: 12%; height: 2px; border-radius: 2px;
    background: linear-gradient(90deg, transparent, var(--or), transparent); opacity: .8;
}

h1, h2, h3 { line-height: 1.2; letter-spacing: -.01em; }

/* Titre = logo + nom de la marque : IMPACT en or, VISION en bleu, comme sur le logo. */
.carte > h1 {
    display: flex; align-items: center; margin: 0;
    font-family: 'Orbitron', system-ui, sans-serif; font-size: 1.35rem; font-weight: 800; letter-spacing: .09em; text-transform: uppercase;
}
.carte > h1::before {
    content: ''; flex: none; width: 58px; height: 58px; margin-right: 14px;
    background: url('../images/logo-96.png') center / contain no-repeat;
    filter: drop-shadow(0 0 10px rgba(58, 163, 255, .4)) drop-shadow(0 0 6px rgba(227, 173, 62, .35));
}
.mot-impact, .mot-vision { -webkit-background-clip: text; background-clip: text; color: transparent; }
.mot-impact { margin-right: .45em; }
.mot-impact { background-image: var(--degrade-or); }
.mot-vision { background-image: var(--degrade-bleu); }

h2 { margin: 0 0 12px; font-size: 1.22rem; }
h3 { margin: 20px 0 8px; font-size: 1.05rem; }
.sous-titre { margin: 6px 0 20px; color: var(--discret); }
.slogan { margin: 0 0 4px; font-family: 'Dancing Script', cursive; font-size: 1.35rem; font-weight: 600; color: var(--or); }

a { color: var(--bleu); text-underline-offset: 3px; }
a:hover { color: var(--or); }
code { font-family: ui-monospace, Consolas, monospace; font-size: .9em; }

.note { color: var(--discret); font-size: .9rem; }
.erreur { color: var(--erreur); font-weight: 600; }
p.erreur:not([hidden]) { padding: 8px 12px; border-radius: 10px; background: var(--erreur-doux); font-size: .92rem; }
.centre { text-align: center; }

/* --- Affiche de présentation (page de connexion et d'inscription) ------------------------------------ */

.hero {
    display: block; width: 100%; height: auto; margin: 0 0 20px; aspect-ratio: 3 / 2; object-fit: cover;
    border-radius: 20px; border: 1px solid var(--bord-or); box-shadow: var(--ombre-forte), var(--lueur-bleue);
    animation: fondu .6s ease-out both;
}
/* Sur l'écran de connexion, l'affiche remplace le titre (elle contient déjà le logo et la signature). */
main[data-ecran="ecran-connexion"] > h1, main[data-ecran="ecran-connexion"] > .slogan { display: none; }

/* --- Formulaires ---------------------------------------------------------------------------------------- */

label { display: block; margin: 16px 0 6px; font-weight: 700; font-size: .93rem; }

input, select, textarea {
    width: 100%; padding: 12px 14px; font: inherit; color: var(--texte);
    background: var(--champ); border: 1.5px solid var(--bord); border-radius: 12px;
    transition: border-color var(--rapide), box-shadow var(--rapide), background var(--rapide);
}
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--bleu) 50%, var(--bord)); }
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--bleu); box-shadow: 0 0 0 4px color-mix(in srgb, var(--bleu) 24%, transparent);
}
::placeholder { color: color-mix(in srgb, var(--discret) 70%, transparent); }

label.case { display: flex; align-items: center; gap: 12px; margin-top: 18px; font-weight: 500; cursor: pointer; }
label.case input { width: 22px; height: 22px; margin: 0; accent-color: var(--or); flex: none; }
label.case + .note { margin: 4px 0 0 34px; }

/* Curseur de teinte (arc-en-ciel) pour la couleur du pseudo. */
input[type=range].teinte {
    -webkit-appearance: none; appearance: none; height: 18px; padding: 0; border: 0; border-radius: 9px; cursor: pointer;
    background: linear-gradient(90deg, hsl(0 70% 52%), hsl(45 80% 50%), hsl(90 60% 45%), hsl(150 60% 42%), hsl(200 70% 50%), hsl(250 65% 58%), hsl(300 60% 55%), hsl(359 70% 52%));
}
input[type=range].teinte::-webkit-slider-thumb {
    -webkit-appearance: none; width: 28px; height: 28px; border-radius: 50%; background: #fff;
    border: 3px solid var(--or); box-shadow: var(--ombre); transition: transform var(--rapide);
}
input[type=range].teinte::-moz-range-thumb { width: 24px; height: 24px; border-radius: 50%; background: #fff; border: 3px solid var(--or); }
input[type=range].teinte:active::-webkit-slider-thumb { transform: scale(1.15); }

/* --- Boutons ------------------------------------------------------------------------------------------------ */

/* Bouton principal : or, comme le lettrage « IMPACT ». */
button {
    position: relative; overflow: hidden;
    width: 100%; margin-top: 18px; padding: 13px 16px;
    font: inherit; font-weight: 800; letter-spacing: .02em;
    color: var(--or-texte);
    background: linear-gradient(180deg, var(--or-clair), var(--or) 55%, var(--or-fonce));
    border: 0; border-radius: 14px; cursor: pointer;
    box-shadow: 0 2px 10px rgba(227, 173, 62, .35), inset 0 1px 0 rgba(255, 255, 255, .4);
    transition: transform var(--rapide), box-shadow var(--rapide), filter var(--rapide), background var(--rapide);
    -webkit-tap-highlight-color: transparent;
}
button:hover { filter: brightness(1.07); box-shadow: 0 6px 20px rgba(227, 173, 62, .45), inset 0 1px 0 rgba(255, 255, 255, .45); transform: translateY(-1px); }
button:active { transform: translateY(0) scale(.98); box-shadow: 0 1px 4px rgba(227, 173, 62, .4); }
button:focus-visible { outline: 3px solid color-mix(in srgb, var(--bleu) 70%, transparent); outline-offset: 2px; }
button:disabled { opacity: .55; cursor: progress; transform: none; box-shadow: none; filter: none; }

/* Bouton secondaire : contour bleu électrique. */
button.secondaire {
    color: var(--bleu); background: transparent; box-shadow: none; font-weight: 700;
    border: 1.5px solid color-mix(in srgb, var(--bleu) 75%, transparent);
}
button.secondaire:hover { background: var(--bleu-doux); box-shadow: var(--lueur-bleue); filter: none; }
button.danger { background: linear-gradient(180deg, #e0463b, #b3261e); color: #fff; box-shadow: 0 2px 10px rgba(179, 38, 30, .4); }
button.petit { width: auto; margin: 0; padding: 8px 14px; font-size: .92rem; border-radius: 12px; }
button.lien {
    width: auto; margin: 0; padding: 3px 6px; overflow: visible;
    color: var(--discret); background: transparent; border: 0; box-shadow: none; font-weight: 600; font-size: .8rem;
}
button.lien:hover { color: var(--or); background: transparent; box-shadow: none; transform: none; filter: none; }

/* Onde au clic (créée par outils.js). */
.ondulation {
    position: absolute; border-radius: 50%; pointer-events: none; transform: scale(0);
    background: rgba(255, 255, 255, .5); animation: onde .6s ease-out forwards;
}
button.secondaire .ondulation { background: color-mix(in srgb, var(--bleu) 35%, transparent); }

/* --- Blocs, listes ---------------------------------------------------------------------------------------------- */

.bloc { margin-top: 28px; padding-top: 22px; border-top: 1px solid var(--bord); }

.liste { list-style: none; margin: 0; padding: 0; }
.liste > li { padding: 14px 8px; border-bottom: 1px solid var(--bord); border-radius: 14px; transition: background var(--rapide); }
.liste > li:last-child { border-bottom: 0; }
.liste > li:hover { background: color-mix(in srgb, var(--bleu-doux) 70%, transparent); }
.liste input { margin-top: 10px; }
.liste > li.traite { opacity: .6; }
.liste > li.ligne-annuaire { display: grid; grid-template-columns: 64px 1fr; column-gap: 14px; align-items: start; }
.ligne-annuaire > .avatar { grid-row: 1; }
.ligne-annuaire > .texte-annuaire { grid-column: 2; min-width: 0; overflow-wrap: anywhere; }
.ligne-annuaire > .actions, .ligne-annuaire > .erreur, .ligne-annuaire > .note { grid-column: 1 / -1; }

.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.actions button { margin-top: 10px; flex: 1 1 140px; }

details > summary { cursor: pointer; font-weight: 700; padding: 6px 0; }
details.bloc > summary { font-size: 1.05rem; color: var(--or); }
details[open] > summary { margin-bottom: 8px; }
details.permissions { margin-top: 10px; }
details.permissions label.case { margin-top: 8px; }

.encart { margin: 12px 0; padding: 14px; background: var(--code-fond); border: 1px solid var(--bord); border-radius: 14px; }
.encart p { margin: 4px 0; }
.bandeau { margin: 10px 0; padding: 8px 12px; border-radius: 12px; background: var(--or-doux); border: 1px solid var(--bord-or); color: var(--texte); font-size: .86rem; }

.cle-secours, .cle-publique, .identifiant {
    padding: 14px; background: var(--code-fond); border: 1px solid var(--bord); border-radius: 14px;
    font-family: ui-monospace, Consolas, monospace; overflow-wrap: anywhere;
}
.cle-secours { font-size: 1.15rem; letter-spacing: .05em; text-align: center; color: var(--or); }
.identifiant { font-size: 1.3rem; text-align: center; font-weight: 700; }
.qr { display: block; margin: 8px 0; border-radius: 12px; background: #fff; max-width: 100%; }
.codes-secours { columns: 2; font-family: ui-monospace, Consolas, monospace; font-size: 1.05rem; }

/* --- Onglets ---------------------------------------------------------------------------------------------------------- */

.onglets {
    display: flex; gap: 6px; margin: 14px 0 10px; padding: 5px; overflow-x: auto;
    background: var(--code-fond); border: 1px solid var(--bord); border-radius: 18px; scrollbar-width: none;
}
.onglets::-webkit-scrollbar { display: none; }
.onglet {
    flex: 1 0 auto; width: auto; margin: 0; padding: 10px 16px; white-space: nowrap;
    color: var(--discret); background: transparent; border-radius: 13px; box-shadow: none; font-weight: 700;
}
.onglet:hover { background: color-mix(in srgb, var(--carte) 70%, transparent); color: var(--texte); box-shadow: none; filter: none; transform: none; }
.onglet.actif { color: var(--or); background: var(--carte); box-shadow: var(--ombre), inset 0 -2px 0 var(--or); }
.panneau { padding-top: 8px; animation: fondu var(--doux) ease-out both; }

/* --- Avatars ------------------------------------------------------------------------------------------------------------ */

.avatar {
    --t: 40px;
    position: relative; flex: none; display: inline-flex; align-items: center; justify-content: center; vertical-align: middle;
    width: var(--t); height: var(--t); border-radius: 50%; overflow: hidden;
    color: #fff; font-weight: 800; font-size: calc(var(--t) * .42); line-height: 1; text-transform: uppercase;
    box-shadow: 0 0 0 2px var(--bord-or), 0 2px 8px rgba(0, 0, 0, .35);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar img.photo-superposee { position: absolute; inset: 0; }
.entete-profil { display: flex; align-items: center; gap: 12px; }
.profil-apercu { display: flex; align-items: center; gap: 14px; margin-bottom: 6px; }
.profil-exemple { margin: 8px 0 0; font-size: 1.15rem; font-weight: 800; }

/* --- Messagerie ------------------------------------------------------------------------------------------------------------- */

.bloc-demande { margin-bottom: 4px; }
.ligne-saisie { display: flex; gap: 8px; }
.ligne-saisie input { flex: 1; min-width: 0; }
.ligne-saisie button { width: auto; margin: 0; flex: none; }

.ligne-conversation { display: flex; justify-content: space-between; align-items: center; gap: 12px; cursor: pointer; }
.ligne-conversation .gauche { display: flex; align-items: center; gap: 14px; min-width: 0; }
.ligne-conversation .gauche > div { min-width: 0; }
.ligne-conversation strong { transition: color var(--rapide); }
.ligne-conversation:hover strong { color: var(--or); }
.ligne-conversation:active { transform: scale(.995); }
.cote { text-align: right; flex-shrink: 0; }
.pastille {
    display: inline-block; min-width: 24px; padding: 1px 8px; margin-top: 4px;
    border-radius: 12px; background: var(--degrade-or); color: var(--or-texte);
    font-size: .8rem; font-weight: 800; text-align: center; box-shadow: var(--lueur-or);
    animation: pulsation 2.4s ease-in-out infinite;
}

#vue-liste, #vue-conversation { animation: fondu var(--doux) ease-out both; }

.entete-conversation {
    position: sticky; top: 0; z-index: 10;
    display: flex; align-items: center; gap: 10px; margin: 0 -8px; padding: 10px 8px;
    background: color-mix(in srgb, var(--carte) 90%, transparent);
    -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--bord-or);
    transition: padding var(--doux), background var(--doux);
}
/* Boutons d'action groupés à gauche : le nom de la conversation garde toute la place restante. */
.entete-actions { display: flex; gap: 6px; flex: none; }
.titre-conversation { flex: 1; min-width: 0; cursor: pointer; border-radius: 10px; padding: 2px 6px; transition: background var(--rapide); }
.titre-conversation:hover { background: var(--bleu-doux); }
.titre-conversation strong {
    display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2;
    overflow: hidden; font-size: 1.05rem; line-height: 1.2; overflow-wrap: anywhere;
}
.titre-conversation strong::after { content: ' ▾'; font-size: .75em; color: var(--or); }
.titre-conversation .note { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
button.icone-seule { padding: 8px 11px; line-height: 1; flex: none; }

/* En-tête réduit : il ne reste qu'une petite pastille pour le redéplier. */
.entete-conversation.reduit {
    justify-content: flex-end; margin: 0; padding: 4px 0; background: transparent; border-bottom: 0;
    -webkit-backdrop-filter: none; backdrop-filter: none; pointer-events: none;
}
.entete-conversation.reduit > :not(#bouton-replier) { display: none; }
.entete-conversation.reduit #bouton-replier {
    pointer-events: auto; border-radius: 50%; width: 38px; height: 38px; padding: 0;
    background: var(--carte); border-color: var(--or); color: var(--or); box-shadow: var(--ombre-forte), var(--lueur-or);
}

@media (max-width: 560px) {
    .entete-actions .libelle { display: none; }
    .entete-actions button { padding: 8px 12px; }
}

.titre-conversation .note, .note.champ-identifiant { color: var(--discret); }

.fil {
    list-style: none; margin: 10px 0; padding: 6px 4px;
    height: min(62vh, 600px); overflow-y: auto; scroll-behavior: smooth;
    display: flex; flex-direction: column; gap: 8px;
}

.bulle { max-width: 82%; padding: 9px 14px; border-radius: 20px; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); }
.bulle.autre { align-self: flex-start; background: var(--bulle-autre); border: 1px solid var(--bord); border-bottom-left-radius: 6px; }
.bulle.moi {
    align-self: flex-end; color: #fff; border-bottom-right-radius: 6px; background: var(--bulle-moi);
    box-shadow: 0 2px 12px rgba(31, 111, 224, .35);
}
.bulle.apparait { animation: bulle var(--doux) cubic-bezier(.2, .9, .3, 1.2) both; }
.bulle .texte { white-space: pre-wrap; overflow-wrap: anywhere; }
.bulle .texte.supprime { font-style: italic; opacity: .7; }
.bulle .citation {
    margin-bottom: 5px; padding: 5px 10px; border-left: 3px solid var(--or); border-radius: 4px;
    background: rgba(0, 0, 0, .18); opacity: .9; font-size: .88rem; white-space: pre-wrap; overflow-wrap: anywhere;
}
.bulle .meta { margin-top: 3px; font-size: .74rem; opacity: .75; }
.bulle .actions-message { display: flex; flex-wrap: wrap; gap: 2px; margin-top: 2px; opacity: .85; }
.bulle.moi button.lien { color: #dbe8ff; }
.bulle.moi button.lien:hover { color: #fff; }
.bulle .auteur { display: flex; align-items: center; gap: 6px; margin-bottom: 3px; font-size: .82rem; font-weight: 800; color: var(--or); }
.bulle .auteur.badge-moderation { display: inline-block; padding: 0 8px; border-radius: 8px; background: var(--degrade-or); color: var(--or-texte); }

.zone-reponse {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 8px 12px; background: var(--bleu-doux); border-radius: 12px; font-size: .9rem;
    border-left: 4px solid var(--or); animation: monter var(--rapide) ease-out both;
}
.enregistrement { color: #ff6a5e; font-weight: 800; animation: pulsation 1.2s ease-in-out infinite; }

.outils-message { display: flex; align-items: center; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.outils-message button { font-size: .95rem; }
.composeur { display: flex; gap: 8px; align-items: flex-end; margin-top: 8px; }
.composeur textarea { flex: 1; min-width: 0; resize: vertical; min-height: 48px; max-height: 200px; border-radius: 16px; }
.composeur button { width: auto; margin: 0; flex: none; }

.reglages-conversation { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 8px 0; font-size: .85rem; color: var(--discret); }
.reglages-conversation select { width: auto; padding: 4px 10px; font-size: .85rem; border-radius: 10px; }
.reglage { display: inline-flex; align-items: center; gap: 4px; margin: 0; font-weight: 500; }

.piece { margin: 4px 0; }
.piece img.miniature { display: block; max-width: 240px; max-height: 240px; height: auto; border-radius: 14px; cursor: zoom-in; background: rgba(0, 0, 0, .15); transition: transform var(--rapide); }
.piece img.miniature:hover { transform: scale(1.02); }
.piece audio { max-width: 100%; }
.bulle.moi .lien-fichier { color: #fff; }

.visionneuse {
    position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center;
    background: rgba(2, 6, 16, .92); cursor: zoom-out; animation: fondu var(--doux) ease-out both;
}
.visionneuse img { max-width: 96vw; max-height: 92vh; border-radius: 10px; box-shadow: var(--ombre-forte); }

.reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.puce-reaction {
    width: auto; margin: 0; padding: 1px 9px; font-size: .85rem; font-weight: 600; box-shadow: none;
    color: var(--texte); background: var(--carte); border: 1px solid var(--bord); border-radius: 12px;
}
.puce-reaction:hover { transform: scale(1.08); box-shadow: none; filter: none; }
.puce-reaction.mienne { border-color: var(--or); background: var(--or-doux); }

.selecteur-emojis, .emojis-tous { display: flex; flex-wrap: wrap; gap: 2px; margin-top: 4px; }
.selecteur-emojis { padding: 4px 6px; background: var(--carte); border: 1px solid var(--bord-or); border-radius: 999px; box-shadow: var(--ombre); animation: monter var(--rapide) ease-out both; }
.emojis-tous { width: 100%; }
button.emoji { width: auto; margin: 0; padding: 4px 6px; font-size: 1.3rem; background: transparent; border: 0; color: inherit; box-shadow: none; }
button.emoji:hover { background: var(--code-fond); border-radius: 8px; transform: scale(1.2); box-shadow: none; filter: none; }

.statistiques { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.tuile { padding: 14px; background: var(--code-fond); border: 1px solid var(--bord); border-radius: 16px; transition: transform var(--rapide), box-shadow var(--rapide), border-color var(--rapide); }
.tuile:hover { transform: translateY(-2px); box-shadow: var(--ombre), var(--lueur-bleue); border-color: var(--bord-or); }
.tuile .valeur { font-family: 'Orbitron', system-ui, sans-serif; font-size: 1.45rem; font-weight: 800; color: var(--or); }
.texte-cite { white-space: pre-wrap; overflow-wrap: anywhere; }

/* --- Liste des discussions : fenêtre défilante, tri, actions rapides toujours visibles ------------------ */

.demandes-recues { max-height: 32vh; overflow-y: auto; margin-top: 0; padding-right: 4px; }

.entete-discussions { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.entete-discussions h2 { margin: 0; }
.tri { display: flex; align-items: center; gap: 6px; }
.tri select { width: auto; max-width: 54vw; padding: 8px 10px; font-size: .9rem; border-radius: 12px; }

.fenetre-discussions {
    height: var(--hauteur-liste, clamp(240px, 50vh, 560px));
    margin: 10px 0 0; padding: 4px 6px; overflow-y: auto; overscroll-behavior: contain;
    border: 1px solid var(--bord); border-bottom: 0; border-radius: 16px 16px 0 0;
    background: color-mix(in srgb, var(--champ) 55%, transparent);
    scrollbar-width: thin; scrollbar-color: var(--or) transparent;
}
.fenetre-discussions::-webkit-scrollbar { width: 8px; }
.fenetre-discussions::-webkit-scrollbar-thumb { background: var(--or-fonce); border-radius: 4px; }
.fenetre-discussions::-webkit-scrollbar-track { background: transparent; }

/* Poignée de réglage de la hauteur (fonctionne à la souris et au doigt). */
.poignee-redim {
    display: flex; align-items: center; justify-content: center; height: 24px; cursor: ns-resize; touch-action: none;
    border: 1px solid var(--bord); border-top: 0; border-radius: 0 0 16px 16px; background: var(--code-fond);
}
.poignee-redim span { width: 46px; height: 4px; border-radius: 2px; background: var(--or); opacity: .75; transition: opacity var(--rapide), box-shadow var(--rapide); }
.poignee-redim:hover span, .poignee-redim:focus-visible span { opacity: 1; box-shadow: var(--lueur-or); }
.poignee-redim:focus-visible { outline: 2px solid var(--bleu); outline-offset: 2px; }

/* Actions rapides : toujours visibles en bas de l'écran tant qu'on est sur la liste. */
.barre-actions {
    position: sticky; bottom: 0; z-index: 12; display: flex; gap: 8px; margin: 14px -8px 0;
    padding: 10px 8px calc(10px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--carte) 93%, transparent);
    -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
    border-top: 1px solid var(--bord-or);
}
.barre-actions button {
    flex: 1 1 0; min-width: 0; width: auto; margin: 0; padding: 9px 6px;
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    font-size: .8rem; line-height: 1.15; white-space: normal; text-align: center;
}
.barre-actions .icone { font-size: 1.2rem; line-height: 1; }
@media (min-width: 600px) {
    .barre-actions button { flex-direction: row; justify-content: center; gap: 8px; font-size: .92rem; padding: 12px 10px; }
}

/* Feuilles (panneaux qui montent du bas) : découvrir, créer un groupe, nouvelle discussion. */
.voile { position: fixed; inset: 0; z-index: 60; background: rgba(2, 6, 16, .65); animation: fondu .2s ease-out both; }
.feuille {
    position: fixed; z-index: 61; left: 50%; bottom: 0; transform: translateX(-50%);
    width: min(100%, 780px); max-height: 88vh; overflow-y: auto; overscroll-behavior: contain;
    padding: 18px 18px calc(22px + env(safe-area-inset-bottom));
    background: var(--carte); border: 1px solid var(--bord-or); border-bottom: 0; border-radius: 24px 24px 0 0;
    box-shadow: var(--ombre-forte); animation: feuille-monte .3s cubic-bezier(.2, .9, .3, 1) both;
}
.entete-feuille { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.entete-feuille h2 { margin: 0; }
body.feuille-ouverte { overflow: hidden; }
@keyframes feuille-monte { from { transform: translate(-50%, 100%); } to { transform: translate(-50%, 0); } }

/* Sécurité des connexions */
.alerte-securite {
    margin: 12px 0; padding: 12px 14px; border-radius: 14px; font-weight: 700;
    color: var(--erreur); background: var(--erreur-doux); border: 1px solid var(--erreur);
    animation: pulsation 2.4s ease-in-out infinite;
}
.tuile.alerte { border-color: var(--erreur); }
.tuile.alerte .valeur { color: var(--erreur); }
.etiquette { display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 8px; font-size: .75rem; font-weight: 800; background: var(--erreur-doux); color: var(--erreur); }

/* --- Notifications à l'écran (toasts) --------------------------------------------------------------------------------- */

.toasts {
    position: fixed; left: 50%; bottom: 22px; z-index: 80; transform: translateX(-50%);
    display: flex; flex-direction: column; align-items: center; gap: 8px; width: min(92vw, 420px); pointer-events: none;
}
.toast {
    padding: 11px 18px; border-radius: 14px; color: var(--texte); font-weight: 600; font-size: .94rem;
    background: var(--carte); border: 1px solid var(--bord-or); border-left: 4px solid var(--or);
    box-shadow: var(--ombre-forte), var(--lueur-or); animation: toast-entree .3s cubic-bezier(.2, .9, .3, 1.2) both;
}
.toast.erreur-toast { border-color: var(--erreur); border-left-color: var(--erreur); }
.toast.sortie { animation: toast-sortie .25s ease-in forwards; }

/* --- Chargement ------------------------------------------------------------------------------------------------------------ */

#ecran-chargement .sous-titre::before {
    content: ''; display: inline-block; width: 18px; height: 18px; margin-right: 10px; vertical-align: -3px;
    border: 3px solid var(--bord); border-top-color: var(--or); border-radius: 50%; animation: tourner .8s linear infinite;
}

.texte-long { max-width: 760px; }
.texte-long h2 { margin-top: 26px; }

/* --- Animations ------------------------------------------------------------------------------------------------------------------- */

@keyframes monter { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes fondu { from { opacity: 0; } to { opacity: 1; } }
@keyframes bulle { from { opacity: 0; transform: translateY(10px) scale(.94); } to { opacity: 1; transform: none; } }
@keyframes onde { to { transform: scale(4); opacity: 0; } }
@keyframes pulsation { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.12); } }
@keyframes tourner { to { transform: rotate(360deg); } }
@keyframes toast-entree { from { opacity: 0; transform: translateY(16px) scale(.95); } to { opacity: 1; transform: none; } }
@keyframes toast-sortie { to { opacity: 0; transform: translateY(10px); } }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}

/* --- Petits écrans -------------------------------------------------------------------------------------------------------------------- */

@media (max-width: 520px) {
    body { padding: 10px 8px 40px; }
    .carte { padding: 18px 14px; border-radius: 22px; }
    .carte > h1 { font-size: 1.1rem; letter-spacing: .07em; }
    .carte > h1::before { width: 48px; height: 48px; }
    .bulle { max-width: 92%; }
    .fil { height: min(58vh, 520px); }
    .onglet { padding: 9px 12px; font-size: .92rem; }
}

@media print {
    body { background: #fff; color: #000; }
    body * { visibility: hidden; }
    .imprimable, .imprimable * { visibility: visible; }
    .imprimable { position: absolute; top: 40px; left: 0; right: 0; font-size: 20pt; }
}

/* --- Mes Fichiers ---------------------------------------------------------------------------------------------------------- */
.quota-barre { height: 12px; border-radius: 8px; background: var(--champ); border: 1px solid var(--bord); overflow: hidden; }
.quota-barre > span { display: block; height: 100%; width: 0; background: var(--degrade-bleu); transition: width var(--doux); }
.quota-barre > span.presque-plein { background: linear-gradient(180deg, #ff9d96, #e0463b); }
.barre-fichiers { display: flex; gap: 8px; align-items: center; margin: 12px 0 8px; }
.barre-fichiers input { flex: 1 1 auto; margin: 0; min-width: 0; }
.barre-fichiers select { flex: 0 0 auto; width: auto; margin: 0; }
.chemin { margin: 8px 0; font-weight: 600; overflow-wrap: anywhere; }
.lien-chemin { display: inline; width: auto; margin: 0; padding: 2px 4px; background: none; border: 0; box-shadow: none; color: var(--bleu); font: inherit; font-weight: 700; cursor: pointer; }
.lien-chemin:hover { background: none; box-shadow: none; text-decoration: underline; }
.separateur-chemin { color: var(--discret); }
.tags-fichier { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.etiquette { width: auto; margin: 0; padding: 4px 12px; border-radius: 999px; font-size: .88rem; font-weight: 700; background: var(--bleu-doux); color: var(--texte); border: 1px solid var(--bord); box-shadow: none; }
.etiquette.petite { padding: 1px 8px; font-size: .78rem; font-weight: 600; }
.etiquette.active { background: var(--degrade-or); color: var(--or-texte); border-color: var(--or); }
.etiquette:hover { filter: none; box-shadow: none; }
.ligne-fichier .entete-fichier { display: flex; align-items: center; gap: 12px; }
.ligne-fichier .entete-fichier.cliquable { cursor: pointer; }
.icone-fichier { font-size: 1.8rem; flex: none; }
.texte-fichier { min-width: 0; overflow-wrap: anywhere; }
.menu-objet { margin-top: 6px; }
.menu-objet > summary { font-size: .88rem; color: var(--discret); font-weight: 600; }
.menu-objet .actions button { flex: 0 1 auto; margin-top: 6px; }
.envoi-fichier { padding: 10px 8px; }
.envoi-fichier progress { display: block; width: 100%; height: 10px; margin: 6px 0; accent-color: var(--or); }
#fichiers-contenu.depot { outline: 2px dashed var(--or); outline-offset: 6px; border-radius: 14px; }
.champ-quota { width: 110px; margin: 0; padding: 6px 10px; }
.ligne-quota { display: flex; align-items: center; gap: 10px; margin: 6px 0 0 34px; }
dialog.dialogue-fichiers {
    width: min(92vw, 460px); padding: 18px; color: var(--texte); background: var(--carte);
    border: 1px solid var(--bord-or); border-radius: 20px; box-shadow: var(--ombre-forte);
}
dialog.dialogue-fichiers::backdrop { background: rgba(2, 6, 16, .7); }
dialog.dialogue-fichiers h2 { margin: 0 0 10px; font-size: 1.1rem; overflow-wrap: anywhere; }
dialog.dialogue-fichiers input, dialog.dialogue-fichiers select { width: 100%; margin: 4px 0; }
