/* Application de chat (plein écran). Les couleurs de la palette et des sexes
   viennent de /css/palette.css, généré par le serveur. */

:root {
  --bg: #eef1f7;
  --surface: #ffffff;
  --surface-2: #f6f8fc;
  --text: #1b2230;
  --muted: #5b6577;
  --border: #d7dce6;
  --accent: #8a3ffc;
  --accent-text: #ffffff;
  --accent-soft: #f1e9ff;
  --mention: #fff4d6;
  --mention-border: #e8b200;
  --system: #b3261e;
  --notice: #1e7b43;
  --danger: #b3261e;
  --radius: 8px;
  --members-width: 230px;
  color-scheme: light dark;
}

/* Thème (J3c) : voir theme.js. « Automatique » suit l'appareil. */
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12151c;
    --surface: #1b2029;
    --surface-2: #161a22;
    --text: #e6e9ef;
    --muted: #9aa3b5;
    --border: #313848;
    --accent: #a570ff;
    --accent-text: #1b1233;
    --accent-soft: #2a2145;
    --mention: #3a3217;
    --mention-border: #c99a00;
    --system: #ff8a80;
    --notice: #7fd69b;
    --danger: #ffb4ab;
  }
}

:root[data-theme="dark"] {
  --bg: #12151c;
  --surface: #1b2029;
  --surface-2: #161a22;
  --text: #e6e9ef;
  --muted: #9aa3b5;
  --border: #313848;
  --accent: #a570ff;
  --accent-text: #1b1233;
  --accent-soft: #2a2145;
  --mention: #3a3217;
  --mention-border: #c99a00;
  --system: #ff8a80;
  --notice: #7fd69b;
  --danger: #ffb4ab;
}

*, *::before, *::after { box-sizing: border-box; }

/* L'attribut hidden l'emporte toujours, même sur les éléments qui fixent display. */
[hidden] { display: none !important; }

html, body { height: 100%; }

/* Préférences locales d'affichage (layoutprefs.js) : la taille du texte met à l'échelle tout ce qui est en rem. */
html[data-font="xsmall"] { font-size: 12.5px; }
html[data-font="small"] { font-size: 14px; }
html[data-font="large"] { font-size: 18px; }
html[data-font="xlarge"] { font-size: 20px; }
html[data-density="compact"] { --pad-msg: 0; --pad-member: 0.05rem; --line: 1.3; }
html[data-density="airy"] { --pad-msg: 0.3rem; --pad-member: 0.45rem; --line: 1.65; }

body.chat-app {
  margin: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 0.9375rem/var(--line, 1.45) system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overflow: hidden;
}

button, input, select { font: inherit; color: inherit; }
a { color: var(--accent); }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------------------------------------------------------------- En-tête */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.4rem 0.75rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 0.5rem; color: var(--text); font-weight: 700; text-decoration: none; }
.topbar-right { display: flex; align-items: center; gap: 0.75rem; }
.topbar select {
  padding: 0.3rem 0.4rem; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-2);
}
.logout { margin: 0; }
/* Bouton « Donner son avis » : une seule présentation à la fois, choisie par le super-admin
   (body[data-feedback], posé par feedback.js). */
.fb { display: none; font: inherit; cursor: pointer; color: var(--text); }
body[data-feedback="badge"] .fb[data-fb="badge"],
body[data-feedback="button"] .fb[data-fb="button"],
body[data-feedback="mood"] .fb[data-fb="mood"] { display: inline-flex; align-items: center; gap: 0.3rem; }
body[data-feedback="link"] .fb[data-fb="link"] { display: inline; }
body[data-feedback="tab"] .fb[data-fb="tab"],
body[data-feedback="float"] .fb[data-fb="float"] { display: block; }
.fb-badge {
  margin-right: auto; padding: 0.15rem 0.6rem; border: 1px dashed var(--accent); border-radius: 999px;
  background: var(--accent-soft); font-size: 0.8rem;
}
.fb-badge:hover { background: var(--surface-2); }
.fb-button { padding: 0.25rem 0.65rem; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-2); font-size: 0.85rem; }
.fb-button:hover { border-color: var(--accent); }
.fb-mood { padding: 0.1rem 0.5rem; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-2); font-size: 0.8rem; }
.fb-mood button { padding: 0.1rem 0.2rem; border: 0; background: none; font-size: 1.05rem; line-height: 1; cursor: pointer; border-radius: 6px; }
.fb-mood button:hover { background: var(--accent-soft); }
.fb-tab {
  position: fixed; right: 0; top: 40%; z-index: 30; writing-mode: vertical-rl; padding: 0.7rem 0.35rem;
  border: 0; border-radius: 8px 0 0 8px; background: var(--accent); color: var(--accent-text); font-size: 0.8rem; font-weight: 600;
}
.fb-float {
  position: fixed; right: 1rem; bottom: 5.5rem; z-index: 30; width: 2.6rem; height: 2.6rem; padding: 0;
  border: 0; border-radius: 50%; background: var(--accent); color: var(--accent-text); font-size: 1.3rem;
}
.fb-textlink, .fb-menu { padding: 0; border: 0; background: none; color: var(--muted); font-size: 0.8rem; text-decoration: underline; }
.fb-textlink:hover, .fb-menu:hover { color: var(--accent); }
.fb-textlink { margin: 0.2rem 0 0.4rem; }
/* Le lien du menu ⋯ ne sert que sur téléphone, où la liste des membres est repliée. */
.fb-menu { display: none !important; }
@media (max-width: 720px) {
  .fb-badge .fb-label, .fb-button .fb-label, .fb-mood .fb-label { display: none; }
  body[data-feedback="link"] .fb-menu { display: block !important; }
  .fb-float { bottom: 4.5rem; right: 0.6rem; }
}
.conn-state { font-size: 0.85rem; color: var(--muted); }
.conn-state.offline { color: var(--danger); font-weight: 600; }
button.link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; text-decoration: underline; }

/* ---------------------------------------------------------------- Onglets */
.tabs {
  display: flex; gap: 2px; align-items: flex-end;
  padding: 0.4rem 0.5rem 0;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  overflow-x: auto; scrollbar-width: thin;
}
.tab {
  display: flex; align-items: center; gap: 0.35rem; flex: none;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border); border-bottom: 0;
  border-radius: var(--radius) var(--radius) 0 0;
  background: var(--surface-2); color: var(--muted);
  cursor: pointer; white-space: nowrap; max-width: 14rem;
}
.tab[aria-selected="true"] { background: var(--surface); color: var(--text); font-weight: 600; margin-bottom: -1px; padding-bottom: calc(0.4rem + 1px); }
.tab .tab-label { overflow: hidden; text-overflow: ellipsis; }
.tab.unread { color: var(--accent); }
.tab.mention { color: var(--system); font-weight: 700; }
.tab .badge-count {
  min-width: 1.3rem; padding: 0 0.3rem; border-radius: 999px;
  background: var(--accent); color: var(--accent-text); font-size: 0.75rem; text-align: center;
}
.tab.mention .badge-count { background: var(--system); }
.tab .tab-close {
  border: 0; background: none; padding: 0 0.15rem; color: var(--muted); cursor: pointer; border-radius: 4px;
}
.tab .tab-close:hover { background: var(--border); color: var(--text); }

/* La présentation actuelle garde la rangée d'origine. Les autres dispositions
   déplacent seulement les groupes d'onglets ; les panneaux restent identiques. */
.presentation-picker { display: flex; align-items: center; gap: 0.4rem; font-size: 0.85rem; }
.presentation-picker select { max-width: 15rem; }
.topbar { flex-wrap: wrap; }
.topbar-right { flex-wrap: wrap; min-width: 0; }
.topbar-menu { display: contents; }
.topbar-menu-toggle { display: none; }
.tab-tools, .tab-conversations, .tab-rooms, .tab-pvs { display: contents; }

body[data-presentation="levels"] .tabs,
body[data-presentation="rows"] .tabs {
  flex-direction: column; align-items: stretch; padding: 0; gap: 0; overflow: hidden;
}
body[data-presentation="levels"] .tab-tools,
body[data-presentation="rows"] .tab-tools {
  display: flex; flex: none; gap: 2px; overflow-x: auto; padding: 0.4rem 0.5rem;
  border-bottom: 1px solid var(--border); background: var(--surface-2);
}
body[data-presentation="levels"] .tab-conversations {
  display: flex; gap: 8px; overflow-x: auto; padding: 0.4rem 0.5rem 0;
}
body[data-presentation="levels"] .tab-rooms,
body[data-presentation="levels"] .tab-pvs {
  display: flex; flex: none; gap: 2px;
}
body[data-presentation="levels"] .tab-pvs:not(:empty) {
  border-left: 1px solid var(--border); padding-left: 8px;
}
body[data-presentation="rows"] .tab-conversations { display: flex; flex-direction: column; }
body[data-presentation="rows"] .tab-rooms,
body[data-presentation="rows"] .tab-pvs {
  display: flex; gap: 2px; overflow-x: auto; padding: 0.4rem 0.5rem 0;
}
body[data-presentation="rows"] .tab-rooms:empty,
body[data-presentation="rows"] .tab-pvs:empty { display: none; }
body[data-presentation="rows"] .tab-rooms:not(:empty)::before,
body[data-presentation="rows"] .tab-pvs:not(:empty)::before {
  color: var(--muted); font-size: 0.85rem; align-self: center; padding: 0 0.4rem;
}
body[data-presentation="rows"] .tab-rooms:not(:empty)::before { content: "Salons"; }
body[data-presentation="rows"] .tab-pvs:not(:empty)::before { content: "Privés"; }

body[data-presentation="side"], body[data-presentation="rail"] {
  display: grid; grid-template-columns: 190px minmax(0, 1fr);
  grid-template-rows: auto auto auto minmax(0, 1fr);
}
body[data-presentation="side"] { grid-template-areas: "header header" "tools tools" "announce announce" "navigation workspace"; }
body[data-presentation="rail"] { grid-template-areas: "header header" "announce announce" "tools conversations" "tools workspace"; }
body[data-presentation="side"] .topbar,
body[data-presentation="rail"] .topbar { grid-area: header; }
body[data-presentation="side"] .announce,
body[data-presentation="rail"] .announce { grid-area: announce; }
body[data-presentation="side"] .workspace,
body[data-presentation="rail"] .workspace { grid-area: workspace; min-width: 0; }
body[data-presentation="side"] .tabs,
body[data-presentation="rail"] .tabs { display: contents; }
body[data-presentation="side"] .tab-tools {
  grid-area: tools; display: flex; gap: 2px; overflow-x: auto;
  padding: 0.4rem 0.5rem; background: var(--surface-2); border-bottom: 1px solid var(--border);
}
body[data-presentation="side"] .tab-conversations,
body[data-presentation="rail"] .tab-tools {
  display: flex; flex-direction: column; gap: 4px; padding: 0.5rem;
  overflow-y: auto; min-height: 0; min-width: 0;
  background: var(--surface-2); border-right: 1px solid var(--border);
}
body[data-presentation="side"] .tab-conversations { grid-area: navigation; }
body[data-presentation="rail"] .tab-tools { grid-area: tools; }
body[data-presentation="side"] .tab-rooms,
body[data-presentation="side"] .tab-pvs { display: flex; flex-direction: column; gap: 4px; }
body[data-presentation="side"] .tab-rooms:not(:empty)::before,
body[data-presentation="side"] .tab-pvs:not(:empty)::before {
  color: var(--muted); font-size: 0.85rem; padding: 0.4rem;
}
body[data-presentation="side"] .tab-rooms:not(:empty)::before { content: "Salons ouverts"; }
body[data-presentation="side"] .tab-pvs:not(:empty)::before { content: "Messages privés"; }
body[data-presentation="rail"] .tab-conversations {
  grid-area: conversations; display: flex; gap: 8px; overflow-x: auto; min-width: 0;
  padding: 0.4rem 0.5rem 0; background: var(--bg); border-bottom: 1px solid var(--border);
}
body[data-presentation="side"] .tab-conversations .tab,
body[data-presentation="rail"] .tab-tools .tab {
  border: 0; border-radius: var(--radius); margin-bottom: 0; padding: 0.5rem;
  max-width: none; min-width: 0; background: transparent;
}
body[data-presentation="side"] .tab-conversations .tab[aria-selected="true"],
body[data-presentation="rail"] .tab-tools .tab[aria-selected="true"] {
  background: var(--accent-soft); box-shadow: inset 3px 0 var(--accent);
}
body[data-presentation="side"] .tab-conversations .tab-close { margin-left: auto; }
body:not([data-presentation="classic"]) .tab-tools .tab {
  border: 0; border-radius: 6px; margin-bottom: 0;
}

/* Une colonne latérale ou le panneau Jeux peut réduire le dialogue même sur
   ordinateur : les options de saisie restent accessibles via le bouton +. */
body:not([data-presentation="classic"]) .dialog { container: chat-dialog / inline-size; }
@container chat-dialog (max-width: 560px) {
  .composer-more { display: inline-block; }
  .composer-options {
    display: none; position: absolute; left: 0.6rem; bottom: 3.4rem; z-index: 10;
    flex-direction: column; padding: 0.5rem; background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 4px 20px rgb(0 0 0 / 0.2);
  }
  .composer.options-open .composer-options { display: flex; }
}

/* Sur téléphone, les colonnes reviennent à deux rangées défilantes. La
   préférence choisie reste mémorisée et reprend sa disposition sur ordinateur. */
@media (max-width: 720px) {
  /* En-tête compact sur une seule ligne ; le reste passe dans le menu ⋯. */
  .topbar { flex-wrap: nowrap; gap: 0.4rem; position: relative; padding: 0.25rem 0.5rem; }
  .topbar-right { flex-wrap: nowrap; gap: 0.4rem; min-width: 0; margin-left: auto; }
  .brand img { width: 24px; height: 24px; }
  .conn-state:empty { display: none; }
  .conn-state { max-width: 6rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar select { min-height: 2.25rem; max-width: 9rem; }
  .topbar-menu-toggle { display: inline-block; font-size: 1.4rem; min-width: 44px; font-weight: 700; }
  .topbar-menu {
    display: none; position: absolute; right: 0.5rem; top: calc(100% + 4px); z-index: 50;
    min-width: 14rem; flex-direction: column; align-items: stretch; gap: 0.2rem; padding: 0.4rem;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: 0 6px 24px rgb(0 0 0 / 0.25);
  }
  .topbar-menu.open { display: flex; }
  .topbar-menu .presentation-picker { flex-direction: column; align-items: stretch; gap: 0.2rem; padding: 0.3rem 0.4rem; }
  .topbar-menu .presentation-picker select { max-width: none; width: 100%; }
  .topbar-menu .link, .topbar-menu button.link {
    display: block; width: 100%; text-align: left; padding: 0.65rem 0.5rem; border-radius: 6px;
    min-height: 44px; text-decoration: none; font: inherit; color: var(--text);
  }
  .topbar-menu .link:hover { background: var(--surface-2); }
  .topbar-menu .logout { width: 100%; border-top: 1px solid var(--border); padding-top: 0.2rem; }
  .topbar-menu .games-open[hidden] { display: none; }
  /* Navigation mobile, quelle que soit la présentation choisie : les outils
     (Salons, Messages, Connectés…) forment une barre fixe en bas, les salons et
     conversations ouverts une rangée défilante sous l'en-tête. */
  body.chat-app[data-presentation] { display: flex; flex-direction: column; }
  body.chat-app[data-presentation] .tabs { display: contents; }
  body.chat-app .topbar { order: 0; }
  body.chat-app .tab-conversations { order: 1; }
  body.chat-app .announce { order: 2; }
  body.chat-app .workspace { order: 3; }
  body.chat-app .tab-tools { order: 4; }
  body.chat-app[data-presentation] .tab-conversations {
    display: flex; flex-direction: row; gap: 8px; flex: none; min-width: 0; overflow-x: auto; overflow-y: hidden;
    padding: 0.35rem 0.5rem 0; background: var(--bg); border: 0; border-bottom: 1px solid var(--border);
    scrollbar-width: none;
  }
  body.chat-app[data-presentation] .tab-conversations:not(:has(.tab)) { display: none; }
  body.chat-app[data-presentation] .tab-rooms,
  body.chat-app[data-presentation] .tab-pvs { display: flex; flex-direction: row; flex: none; gap: 2px; border: 0; padding: 0; }
  body.chat-app[data-presentation] .tab-rooms::before,
  body.chat-app[data-presentation] .tab-pvs::before { display: none; }
  body.chat-app[data-presentation] .tab-conversations .tab {
    flex: none; max-width: 12rem; min-height: 40px; margin-bottom: 0;
    border: 1px solid var(--border); border-bottom: 0; border-radius: var(--radius) var(--radius) 0 0;
    background: var(--surface-2); box-shadow: none;
  }
  body.chat-app[data-presentation] .tab-conversations .tab[aria-selected="true"] {
    background: var(--surface); margin-bottom: -1px; padding-bottom: calc(0.4rem + 1px);
  }
  body.chat-app[data-presentation] .tab-conversations .tab-close { margin-left: 0; min-width: 28px; min-height: 28px; text-align: center; }

  body.chat-app[data-presentation] .tab-tools {
    display: flex; flex-direction: row; flex: none; gap: 0; padding: 0 0 env(safe-area-inset-bottom); overflow: hidden;
    background: var(--surface); border: 0; border-top: 1px solid var(--border);
  }
  /* Le clavier à l'écran prend la place : la barre se retire pendant la saisie. */
  body.chat-app:has(.composer-input:focus) .tab-tools { display: none; }
  body.chat-app[data-presentation] .tab-tools .tab {
    flex: 1 1 0; min-width: 0; max-width: none; min-height: 54px; position: relative;
    flex-direction: column; justify-content: center; gap: 0.1rem; padding: 0.3rem 0.1rem;
    border: 0; border-radius: 0; margin: 0; background: transparent; box-shadow: none;
    font-size: 0.7rem; color: var(--muted);
  }
  body.chat-app[data-presentation] .tab-tools .tab[aria-selected="true"] {
    color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 2px 0 var(--accent); font-weight: 700;
  }
  .tab-tools .tab::before { font-size: 1.3rem; line-height: 1; }
  .tab-tools .tab[data-tab="status"]::before { content: "👤"; }
  .tab-tools .tab[data-tab="rooms"]::before { content: "💬"; }
  .tab-tools .tab[data-tab="messages"]::before { content: "✉️"; }
  .tab-tools .tab[data-tab="online"]::before { content: "🟢"; }
  .tab-tools .tab[data-tab="contacts"]::before { content: "👥"; }
  .tab-tools .tab[data-tab="moderation"]::before { content: "🛡️"; }
  .tab-tools .tab .tab-label { max-width: 100%; }
  .tab-tools .tab .badge-count { position: absolute; top: 3px; left: calc(50% + 4px); font-size: 0.65rem; min-width: 1.1rem; }

  /* Les actions d'un membre passent par la feuille : le pied de liste les masque. */
  .members .member-actions { display: none; }
}

/* ---------------------------------------------------------------- Panneaux */
.workspace { display: flex; flex: 1; min-height: 0; }
.panels { position: relative; flex: 1; min-width: 0; min-height: 0; background: var(--surface); }

/* Jeux : panneau latéral sur ordinateur, plein écran sur mobile. */
.games-dock {
  display: flex; flex-direction: column; flex: none; width: min(480px, 44vw);
  background: var(--surface); border-left: 1px solid var(--border);
}
.games-dock[hidden] { display: none; }
.games-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.3rem 0.6rem; background: var(--surface-2); border-bottom: 1px solid var(--border);
}
.games-head-actions { display: flex; gap: 0.25rem; }
.games-frame { flex: 1; min-height: 0; width: 100%; border: 0; background: var(--surface); }
@media (max-width: 720px) {
  .games-dock { position: fixed; inset: 0; width: auto; z-index: 40; border-left: 0; }
}
.panel { height: 100%; }
.panel[hidden] { display: none !important; }
.panel-page { overflow-y: auto; padding: 1rem; }
.page-card { max-width: 40rem; margin: 0 auto; }
.page-card h2 { margin-top: 0.25rem; }
.page-head { display: flex; align-items: center; justify-content: space-between; }
.me-line { font-size: 1.1rem; }
label.inline { display: flex; align-items: center; gap: 0.5rem; margin: 0.35rem 0; }

.color-grid { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.color-grid button {
  width: 2.1rem; height: 2.1rem; border-radius: 50%;
  border: 2px solid transparent; cursor: pointer;
}
.color-grid button[aria-checked="true"] { border-color: var(--text); box-shadow: 0 0 0 2px var(--surface) inset; }

.room-list { list-style: none; margin: 0; padding: 0; }
.room-list li {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.6rem 0.25rem; border-bottom: 1px solid var(--border);
}
.room-list .room-info { flex: 1; min-width: 0; }
.room-list .room-topic { color: var(--muted); font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-list .room-head { padding: 0; border-bottom: 0; }
.room-list .room-head-toggle {
  flex: 1; text-align: left; border: 0; background: var(--surface-2); color: inherit; cursor: pointer;
  padding: 0.4rem 0.5rem; border-radius: 6px; font-weight: 600;
}
.room-list .room-head.depth-0 { margin-top: 0.5rem; }
.room-list .room-head.depth-0 .room-head-toggle { font-size: 1.05rem; background: transparent; border-bottom: 2px solid var(--border); border-radius: 0; }
.room-list .room-head.depth-2 { padding-left: 1rem; }
.room-list .room-count { color: var(--muted); font-size: 0.9rem; white-space: nowrap; }
.room-list .room-star, .room-list .room-home {
  border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 1.15rem; line-height: 1;
  padding: 0.25rem; border-radius: 6px;
}
.room-list .room-star.on { color: #e0a800; }
.room-list .room-home { opacity: 0.45; }
.room-list .room-home.on { opacity: 1; }
.room-list .room-star:hover, .room-list .room-home:hover { background: var(--surface-2); }

.button {
  display: inline-block; padding: 0.5rem 1rem; border: 0; border-radius: 6px;
  background: var(--accent); color: var(--accent-text); font-weight: 600; cursor: pointer;
}
.button.small { padding: 0.3rem 0.7rem; font-size: 0.9rem; }
.button.secondary { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.button:disabled { opacity: 0.5; cursor: default; }
.icon-button {
  border: 0; background: none; cursor: pointer; padding: 0.3rem 0.45rem; border-radius: 6px; line-height: 1;
}
.icon-button:hover { background: var(--surface-2); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------------------------------------------------------------- Salon */
.room {
  display: grid;
  grid-template-columns: var(--members-width) 6px 1fr;
  min-height: 0;
}

.members {
  display: flex; flex-direction: column; min-height: 0;
  background: var(--surface-2); border-right: 1px solid var(--border);
}
.members-head { display: flex; align-items: center; justify-content: space-between; padding: 0.4rem 0.6rem; }
.members-title { font-weight: 600; font-size: 0.9rem; color: var(--muted); }
.members-close { display: none; }
.member-list { list-style: none; margin: 0; padding: 0.2rem 0; overflow-y: auto; flex: 1; }
.member {
  display: flex; align-items: center; gap: 0.4rem;
  padding: var(--pad-member, 0.2rem) 0.6rem; cursor: pointer; user-select: none;
}
.member:hover { background: var(--accent-soft); }
.member[aria-selected="true"] { background: var(--accent-soft); outline: 1px solid var(--accent); outline-offset: -1px; }
.member .nick { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member.me .nick::after { content: " (moi)"; font-weight: 400; color: var(--muted); }
.member .state { margin-left: auto; font-size: 0.75rem; }
.role-badge {
  font-size: 0.65rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em;
  padding: 0.05rem 0.3rem; border-radius: 4px; background: var(--accent); color: var(--accent-text);
}
.role-badge.role-moderator { background: #1e7b43; color: #fff; }
.role-badge.role-admin, .role-badge.role-superadmin { background: #b3261e; color: #fff; }
.sex-icon { width: 1rem; text-align: center; font-weight: 700; }
.members-foot { padding: 0.4rem 0.6rem; border-top: 1px solid var(--border); font-size: 0.85rem; }
.member-count { margin: 0 0 0.25rem; color: var(--muted); }
.member-sort label { margin-left: 0.3rem; }
.member-actions { margin-top: 0.4rem; }
/* La liste garde la place : le pied défile au lieu de la réduire, et les actions n'apparaissent que pour un membre choisi. */
@media (min-width: 721px) {
  .members-foot { max-height: 40%; overflow-y: auto; flex: none; }
  .members:not(.has-selection) .member-actions { display: none !important; }
  .members .member-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .members .member-actions .button { padding: 0.2rem 0.3rem; line-height: 1.2; }
}

/* Liste des membres à droite (préférence locale) ; sur téléphone, la liste garde son tiroir habituel. */
@media (min-width: 721px) {
  html[data-members="right"] .room { grid-template-columns: minmax(0, 1fr) 6px var(--members-width); }
  html[data-members="right"] .dialog { order: 1; }
  html[data-members="right"] .splitter { order: 2; }
  html[data-members="right"] .members { order: 3; border-right: 0; border-left: 1px solid var(--border); }
}

.splitter { cursor: col-resize; background: var(--border); opacity: 0.4; }
.splitter:hover, .splitter.dragging { opacity: 1; }

.dialog { display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; }
.dialog-head {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.35rem 0.75rem; border-bottom: 1px solid var(--border);
}
.members-toggle { display: none; }
.room-switch { display: none; }
.room-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-topic { color: var(--muted); }

.star-shower { position: fixed; overflow: hidden; pointer-events: none; z-index: 40; }
.star-shower span { position: absolute; animation: 3s linear both; }
@keyframes star-fall {
  to { transform: translateY(calc(var(--h) + 3rem)) rotate(360deg); opacity: 0.6; }
}
@keyframes star-snow {
  25% { transform: translate(1.2rem, calc(var(--h) * 0.25)); }
  50% { transform: translate(-1.2rem, calc(var(--h) * 0.5)); }
  75% { transform: translate(1.2rem, calc(var(--h) * 0.75)); }
  to { transform: translate(0, calc(var(--h) + 3rem)); }
}
@keyframes star-shoot {
  to { transform: translate(calc(var(--h) * -0.9), calc(var(--h) + 3rem)); opacity: 0.4; }
}
@keyframes star-twinkle {
  0%, 100% { opacity: 0; transform: scale(0.2) rotate(0); }
  50% { opacity: 1; transform: scale(1.3) rotate(90deg); }
}
@keyframes star-burst {
  0% { opacity: 1; transform: translate(0, 0) scale(0.3); }
  55% { opacity: 1; transform: translate(var(--dx), var(--dy)) scale(1); }
  to { opacity: 0; transform: translate(var(--dx), calc(var(--dy) + 4rem)) scale(0.8); }
}
.messages { flex: 1; overflow-y: auto; padding: 0.4rem 0.75rem; overscroll-behavior: contain; }
.message-list { list-style: none; margin: 0; padding: 0; }
.load-older {
  display: block; margin: 0.25rem auto 0.5rem; border: 1px solid var(--border); background: var(--surface-2);
  border-radius: 999px; padding: 0.2rem 0.8rem; cursor: pointer; color: var(--muted);
}
.msg { padding: var(--pad-msg, 0.12rem) 0.3rem; border-radius: 4px; overflow-wrap: anywhere; }
.msg .text { white-space: pre-wrap; } /* conserve les espaces multiples du message */
.msg .author { font-weight: 700; cursor: pointer; }
.msg .author:hover { text-decoration: underline; }
.msg .to { font-weight: 600; }
.msg .time { color: var(--muted); font-size: 0.8rem; margin-right: 0.35rem; display: none; }
.show-time .msg .time { display: inline; }
.msg.action .text { font-style: italic; }
.msg .at { font-weight: 600; color: var(--system); }
.msg .at.me { background: var(--mention); box-shadow: 0 0 0 1px var(--mention-border); border-radius: 3px; padding: 0 0.15rem; }
.msg.mention { background: var(--mention); box-shadow: inset 3px 0 0 var(--mention-border); }
.msg.deleted .text { color: var(--muted); font-style: italic; }
.msg.pending { opacity: 0.6; }
.msg.system { color: var(--system); }
.msg.notice { color: var(--notice); }
.msg.welcome { color: var(--system); font-weight: 500; }
.msg .emoji { font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif; }
.msg a { overflow-wrap: anywhere; }

.new-messages {
  position: absolute; left: 50%; bottom: 4.2rem; transform: translateX(-50%);
  border: 0; border-radius: 999px; padding: 0.35rem 0.9rem;
  background: var(--accent); color: var(--accent-text); font-weight: 600; cursor: pointer;
  box-shadow: 0 2px 8px rgb(0 0 0 / 0.25);
}

/* ---------------------------------------------------------------- Saisie */
.composer {
  position: relative;
  display: flex; align-items: center; gap: 0.4rem;
  padding: 0.5rem 0.6rem;
  border-top: 1px solid var(--border); background: var(--surface);
}
.composer-options { display: flex; gap: 0.4rem; }
.composer select, .composer-field {
  border: 1px solid var(--border); border-radius: 6px; background: var(--surface-2);
}
.composer select { padding: 0.45rem 0.3rem; }
.composer-field { flex: 1; display: flex; align-items: center; min-width: 0; }
.composer-input.answer-mode { background: var(--accent-soft); }
.composer-input { flex: 1; min-width: 0; border: 0; background: transparent; padding: 0.55rem 0.6rem; outline: none; }
.composer-field:focus-within { outline: 2px solid var(--accent); outline-offset: 0; }
.recipient {
  display: inline-flex; align-items: center; gap: 0.2rem; margin-left: 0.35rem;
  padding: 0.1rem 0.2rem 0.1rem 0.5rem; border-radius: 999px;
  background: var(--accent-soft); font-weight: 600; white-space: nowrap;
}
.reply-chip {
  display: inline-flex; align-items: center; gap: 0.2rem; margin-left: 0.35rem;
  padding: 0.1rem 0.2rem 0.1rem 0.5rem; border-radius: 999px;
  background: var(--accent-soft); font-weight: 600; white-space: nowrap;
}
.reply-clear { border: 0; background: none; cursor: pointer; padding: 0 0.25rem; }
.msg .reply-ref {
  display: inline-block; max-width: 100%; margin-right: 0.35rem; padding: 0 0.4rem; border-left: 3px solid var(--accent);
  color: var(--muted); font-size: 0.85rem; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  vertical-align: bottom;
}
.msg .reply-ref:hover { text-decoration: underline; }
.msg .reactions { display: inline-flex; flex-wrap: wrap; gap: 0.25rem; margin-left: 0.5rem; vertical-align: middle; }
.reaction {
  border: 1px solid var(--border, #ccc); border-radius: 999px; background: transparent; cursor: pointer;
  padding: 0 0.45rem; font-size: 0.85rem; line-height: 1.5;
}
.reaction.mine { background: var(--accent-soft); border-color: var(--accent); }
.msg-tools { position: relative; }
.reaction-menu {
  position: absolute; right: 0; top: 100%; z-index: 20; display: flex; gap: 0.15rem; padding: 0.25rem;
  background: var(--bg, #fff); border: 1px solid var(--border, #ccc); border-radius: 0.5rem; box-shadow: 0 2px 8px #0003;
}
.reaction-menu button { border: 0; background: none; cursor: pointer; font-size: 1.2rem; padding: 0.15rem 0.25rem; border-radius: 0.3rem; }
.reaction-menu button:hover { background: var(--accent-soft); }
/* Recherche dans un salon : panneau au-dessus de la liste des messages. */
.room-search { padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--border, #ccc); max-height: 45%; overflow: auto; }
.room-search[hidden] { display: none; }
.room-search-form { display: flex; gap: 0.4rem; }
.room-search-input { flex: 1; min-width: 0; }
.room-search-status { margin: 0.35rem 0; }
.room-search-results { list-style: none; margin: 0; padding: 0; }
.room-search-results .msg { cursor: pointer; }
.msg.flash { animation: msg-flash 1.6s ease-out; }
@keyframes msg-flash { from { background: var(--mention); } to { background: transparent; } }
.recipient-clear { border: 0; background: none; cursor: pointer; padding: 0 0.25rem; }
.composer-more { display: none; }
.send { min-height: 2.4rem; }

.emoji-picker {
  position: absolute; right: 0.6rem; bottom: 3.4rem; z-index: 10;
  display: flex; flex-direction: column; gap: 0.3rem; width: 19.4rem; max-width: calc(100vw - 1.2rem);
  padding: 0.4rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 4px 20px rgb(0 0 0 / 0.2);
}
.emoji-img { height: 1.25em; width: 1.25em; vertical-align: -0.25em; }
.emoji-grid .emoji-img { height: 1.6rem; width: 1.6rem; vertical-align: middle; }
.emoji-search { width: 100%; box-sizing: border-box; }
.emoji-tabs { display: flex; gap: 0.1rem; border-bottom: 1px solid var(--border); padding-bottom: 0.2rem; }
.emoji-picker .emoji-tab { flex: 1; font-size: 1.1rem; height: 2rem; }
.emoji-picker .emoji-tab[aria-selected="true"] { background: var(--surface-2); }
.emoji-grid { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 0.15rem; height: 11.5rem; overflow-x: hidden; overflow-y: auto; align-content: start; }
.emoji-grid button { padding: 0; min-width: 0; }
.emoji-empty { grid-column: 1 / -1; margin: 0.5rem; font-size: 0.85rem; opacity: 0.7; }
.emoji-picker button { font-size: 1.3rem; border: 0; background: none; border-radius: 6px; cursor: pointer; height: 2.2rem; }
.emoji-picker button:hover { background: var(--surface-2); }
.nick-suggest {
  position: absolute; left: 0.6rem; bottom: 3.4rem; z-index: 10; margin: 0; padding: 0.25rem;
  list-style: none; max-height: 12rem; overflow-y: auto; min-width: 10rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 4px 20px rgb(0 0 0 / 0.2);
}
.nick-suggest[hidden] { display: none; }
.nick-suggest li { padding: 0.3rem 0.6rem; border-radius: 6px; cursor: pointer; }
.nick-suggest li:hover, .nick-suggest li.active { background: var(--accent-soft); }

/* ---------------------------------------------------------------- Mobile */
@media (max-width: 720px) {
  .topbar .brand span { display: none; }
  .room { grid-template-columns: 1fr; }
  .splitter { display: none; }
  .members {
    position: absolute; inset: 0 auto 0 0; z-index: 20; width: min(80vw, 300px);
    transform: translateX(-100%); transition: transform 0.2s ease;
    box-shadow: 4px 0 20px rgb(0 0 0 / 0.25);
  }
  /* Deux vues plein écran : liste des membres, ou contenu du salon. */
  .room { display: flex; flex-direction: column; }
  .room-switch { display: flex; gap: 0.5rem; padding: 0.4rem 0.5rem; flex: none; background: var(--surface-2); border-bottom: 1px solid var(--border); }
  .room-switch button {
    flex: 1; min-height: 44px; border: 1px solid var(--border); border-radius: 6px;
    background: var(--surface); color: inherit; font: inherit; cursor: pointer;
  }
  .room-switch button { white-space: nowrap; padding: 0 0.3rem; font-size: 0.92rem; }
  .chat-badge {
    display: inline-block; min-width: 1.3rem; padding: 0 0.35rem; border-radius: 999px; line-height: 1.3rem;
    background: var(--accent); color: var(--accent-text); font-size: 0.8rem; font-weight: 700;
  }
  .chat-badge[hidden] { display: none; }
  .chat-badge.mention { background: #b3261e; color: #fff; }
  .room-switch button[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 700; }
  .members { display: none; position: static; width: auto; transform: none; box-shadow: none; border-right: 0; flex: 1; min-height: 0; }
  .room.members-open .members { display: flex; }
  .room.members-open .dialog { display: none; }
  .dialog { flex: 1; }
  .members-head, .members-close, .members-toggle { display: none; }
  .members-foot { max-height: 45%; overflow-y: auto; background: var(--surface-2); }
  .composer-more { display: inline-block; }
  .composer-options {
    display: none; position: absolute; left: 0.6rem; bottom: 3.4rem; z-index: 10;
    flex-direction: column; padding: 0.5rem; background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 4px 20px rgb(0 0 0 / 0.2);
  }
  .composer.options-open .composer-options { display: flex; }
  .send { padding: 0.5rem 0.7rem; }
  .emoji-grid { grid-template-columns: repeat(7, minmax(0, 1fr)); }
  .tab, .icon-button, .member { min-height: 44px; }
}

/* ---------------------------------------------------------------- J2a : PV, contacts, connectés */
.muted { color: var(--muted); font-weight: 400; }
.pv { display: grid; grid-template-columns: 1fr; min-height: 0; position: relative; }
.pv .dialog-head { justify-content: space-between; }
.pv-actions { display: flex; gap: 0.4rem; }
.pv.with-side { grid-template-columns: minmax(0, 1fr) 17rem; }
.pv-side {
  min-height: 0; overflow-y: auto; padding: 0.8rem; border-left: 1px solid var(--border);
  background: var(--surface); display: flex; flex-direction: column; gap: 0.5rem;
}
.pv-side[hidden] { display: none; }
.pv-side .profile-head img { width: 48px; height: 48px; }
.pv-side .pv-side-status { margin: 0; font-size: 0.9rem; }
.pv-side .detail-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.game-menu { width: 100%; }
.game-menu summary { display: inline-block; cursor: pointer; list-style: none; }
.game-menu summary::-webkit-details-marker { display: none; }
.game-menu ul { list-style: none; margin: 0.3rem 0 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.game-choice {
  width: 100%; text-align: left; padding: 0.3rem 0.5rem; border: 0; border-radius: 6px;
  background: transparent; color: inherit; font: inherit; cursor: pointer;
}
.game-choice:hover, .game-choice:focus-visible { background: var(--surface-2); }
@media (max-width: 760px) {
  /* Écran étroit : le bloc d'infos passe au-dessus de la conversation, borné en hauteur ;
     la zone de saisie reste toujours visible. */
  .pv.with-side { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .pv-side { order: -1; max-height: 35vh; border-left: 0; border-bottom: 1px solid var(--border); }
}
.typing { margin: 0; padding: 0 0.9rem 0.2rem; font-size: 0.85rem; color: var(--muted); font-style: italic; }
.tab.pv-tab .tab-label::before { content: "✉ "; }
/* Membres d'autres tchats reliés au salon (pont) : listés, sans compte ; seule l'interpellation est possible. */
.member.external .nick { font-style: italic; color: var(--muted); }
.member.external { cursor: pointer; }
.member.blocked { opacity: 0.45; }
.member.blocked .nick { text-decoration: line-through; }
.member .nopv { font-size: 0.75rem; }
.member-actions { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.member-actions .button { padding: 0.25rem 0.5rem; font-size: 0.8rem; }
.nopv-toggle { display: flex; align-items: center; gap: 0.3rem; white-space: nowrap; font-size: 0.9rem; }
.filters { display: flex; gap: 0.5rem; margin: 0.5rem 0 0.75rem; }
.filters input, .filters select {
  padding: 0.45rem 0.6rem; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-2);
}
.filters input { flex: 1; min-width: 0; }
.people-list, .plain-list { list-style: none; margin: 0 0 1rem; padding: 0; }
.people-list li {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.45rem 0.25rem; border-bottom: 1px solid var(--border);
}
.people-list .who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.people-list .nick { font-weight: 600; }
.people-list .actions { display: flex; gap: 0.3rem; }
/* Onglet Messages : une ligne par conversation (ouvrir) et un bouton pour la masquer. */
.conv-list { list-style: none; margin: 0 0 1rem; padding: 0; }
.conv { display: flex; align-items: center; gap: 0.4rem; border-bottom: 1px solid var(--border); }
.conv-open {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 0.5rem; padding: 0.55rem 0.25rem;
  border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; border-radius: 6px;
}
.conv-open:hover { background: var(--surface-2); }
.conv-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.conv-top { display: flex; align-items: baseline; gap: 0.3rem; }
.conv-top .nick { font-weight: 600; }
.conv-date { margin-left: auto; font-size: 0.8rem; flex: none; }
.conv-preview { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.conv.unread .conv-preview { color: var(--text); font-weight: 600; }
.conv .badge-count {
  min-width: 1.3rem; padding: 0 0.3rem; border-radius: 999px; flex: none;
  background: var(--accent); color: var(--accent-text); font-size: 0.75rem; text-align: center;
}
.conv-hide { flex: none; }
.plain-list li { display: flex; align-items: center; justify-content: space-between; padding: 0.3rem 0; }
.status-dot { width: 0.6rem; height: 0.6rem; border-radius: 50%; background: var(--muted); flex: none; }
.status-dot.online { background: #2e9d57; }
.status-dot.away { background: #e69500; }
.status-dot.busy { background: #d93025; }
.toast {
  position: fixed; left: 50%; bottom: 1.2rem; transform: translateX(-50%); z-index: 50;
  padding: 0.6rem 1rem; border-radius: 8px; background: var(--text); color: var(--surface);
  box-shadow: 0 4px 16px rgb(0 0 0 / 0.3); max-width: min(90vw, 30rem);
}
.toast .button { margin-left: 0.6rem; }
.toast-close {
  margin-left: 0.5rem; padding: 0 0.3rem; border: 0; background: none; color: inherit;
  font-size: 1.3rem; line-height: 1; cursor: pointer; opacity: 0.7; vertical-align: middle;
}
.toast-close:hover { opacity: 1; }

/* ---------------------------------------------------------------- J2b : modération */
.button.danger { background: var(--danger); color: #fff; }
.announce {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.45rem 0.75rem; background: var(--mention); border-bottom: 1px solid var(--mention-border);
  font-weight: 600;
}
.announce-text { flex: 1; overflow-wrap: anywhere; }
.msg.bot { background: var(--accent-soft); }
.msg.whisper { border-left: 3px dashed var(--accent); }
.msg.whisper::before { content: "🔒 "; font-size: 0.8rem; }
.msg.bot .author { cursor: default; color: var(--accent); }
.msg.bot .author:hover { text-decoration: none; }
.msg.announce { color: var(--text); background: var(--mention); font-weight: 600; }
.msg.announce::before { content: "📢 "; }

.muted-notice {
  margin: 0; padding: 0.4rem 0.75rem; background: var(--surface-2); border-top: 1px solid var(--border);
  color: var(--danger); font-weight: 600; font-size: 0.9rem;
}
.room-lock { margin-right: 0.2rem; }
.room-settings { margin-left: auto; }
.stack { display: flex; flex-direction: column; align-items: flex-start; gap: 0.5rem; }
.stack textarea { width: 100%; }
textarea, .modal input, .modal select {
  font: inherit; color: inherit; padding: 0.45rem 0.6rem;
  border: 1px solid var(--border); border-radius: 6px; background: var(--surface-2);
}
.modal {
  width: min(92vw, 30rem); padding: 1.1rem 1.25rem; border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface); color: var(--text); box-shadow: 0 10px 40px rgb(0 0 0 / 0.35);
}
.modal::backdrop { background: rgb(0 0 0 / 0.45); }
.modal h2 { margin: 0 0 0.6rem; font-size: 1.2rem; }
.modal .field { display: flex; flex-direction: column; gap: 0.25rem; margin: 0 0 0.7rem; border: 0; padding: 0; }
.modal fieldset.field { border: 1px solid var(--border); border-radius: 8px; padding: 0.5rem 0.7rem; }
.modal-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: flex-end; margin-top: 0.8rem; }
.modal-actions .spacer { flex: 1; }
.form-error { color: var(--danger); font-weight: 600; margin: 0.3rem 0; }
.modal:not(.is-admin) .admin-only { display: none; }
.modal:not(.is-private) .private-only { display: none; }
.modal.is-private .official-only { display: none; }
.row-actions { display: flex; gap: 0.4rem; }
.room-kind { font-size: 0.7rem; font-weight: 700; padding: 0 0.3rem; border-radius: 4px; border: 1px solid var(--border); margin-right: 0.3rem; }
.act-invite { margin-top: 0.4rem; width: 100%; }

/* ---------------------------------------------------------------- J2b-2 : signalements, file de modération */
.act-call { margin-top: 0.5rem; width: 100%; }

#panel-moderation.panel-page { padding: 0.75rem; }
.mod-layout { display: grid; grid-template-columns: minmax(16rem, 24rem) 1fr; gap: 1rem; height: 100%; min-height: 0; }
.mod-queue, .mod-detail { overflow-y: auto; min-height: 0; }
.mod-detail { border-left: 1px solid var(--border); padding-left: 1rem; }
.mod-list li { cursor: pointer; align-items: flex-start; flex-direction: column; gap: 0.15rem; }
.mod-list li[aria-selected="true"] { background: var(--accent-soft); }
.mod-list .line { display: flex; gap: 0.4rem; align-items: center; width: 100%; }
.mod-list .when { margin-left: auto; color: var(--muted); font-size: 0.8rem; }
.kind-badge {
  font-size: 0.7rem; font-weight: 700; padding: 0.05rem 0.35rem; border-radius: 4px;
  background: var(--surface-2); border: 1px solid var(--border); white-space: nowrap;
}
.kind-badge.mod_call { background: var(--danger); color: #fff; border-color: transparent; }
.state-badge { font-size: 0.75rem; color: var(--muted); }
.snapshot { list-style: none; margin: 0.5rem 0; padding: 0.4rem; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 8px; max-height: 22rem; overflow-y: auto; }
.snapshot li { padding: 0.1rem 0.3rem; border-radius: 4px; overflow-wrap: anywhere; }
.snapshot li.reported { background: var(--mention); box-shadow: inset 3px 0 0 var(--mention-border); }
.snapshot li.deleted .text { text-decoration: line-through; color: var(--muted); }
.snapshot .t { color: var(--muted); font-size: 0.8rem; margin-right: 0.3rem; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.75rem 0; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 0.2rem 0.8rem; margin: 0.5rem 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; min-width: 0; }
.small { font-size: 0.85rem; }
.sound-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem 1rem; margin: 0.5rem 0 0.75rem; }
.sound-row label { display: flex; align-items: center; gap: 0.4rem; }
.sound-row select { padding: 0.3rem 0.4rem; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-2); }
.theme-choice { border: 0; padding: 0; margin: 0 0 0.25rem; }
.avatar { width: 20px; height: 20px; border-radius: 50%; object-fit: cover; flex: none; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(6rem, 1fr)); gap: 0.4rem; margin: 0.5rem 0; }
.gallery figure { margin: 0; position: relative; }
.gallery img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); cursor: zoom-in; }
.gallery .status { position: absolute; left: 4px; bottom: 4px; font-size: 0.7rem; background: var(--surface); border-radius: 4px; padding: 0 0.25rem; }
.gallery .photo-report { position: absolute; right: 4px; top: 4px; border: 0; border-radius: 4px; background: var(--surface); cursor: pointer; font-size: 0.75rem; }
.photo-view { max-width: 100%; max-height: 70vh; display: block; margin: 0 auto; border-radius: 8px; }
.profile-head { display: flex; align-items: center; gap: 0.6rem; }
.profile-head img { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; }
.mod-views { display: flex; gap: 0.4rem; margin-bottom: 0.5rem; }
.mod-views button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); }
.photo-queue { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr)); gap: 0.75rem; }
.photo-queue li { border: 1px solid var(--border); border-radius: 8px; padding: 0.4rem; display: flex; flex-direction: column; gap: 0.3rem; }
.photo-queue img { width: 100%; border-radius: 6px; }
.bio { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--surface-2); border-radius: 8px; padding: 0.6rem 0.8rem; }
#profile-title .role-badge { font-size: 0.7rem; vertical-align: middle; }
button.link.nick { font-weight: 600; text-decoration: none; }
button.link.nick:hover { text-decoration: underline; }
.modal-wide { width: min(94vw, 44rem); max-height: 90vh; }
.mini-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; margin: 0.3rem 0 0.8rem; }
.mini-table th, .mini-table td { text-align: left; padding: 0.25rem 0.4rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.mini-table .inactive { color: var(--muted); }
@media (max-width: 720px) {
  .mod-layout { grid-template-columns: 1fr; }
  .mod-detail { border-left: 0; padding-left: 0; border-top: 1px solid var(--border); padding-top: 0.75rem; }
}

/* Menu contextuel sur un pseudo (clic droit) */
.user-menu { position: fixed; z-index: 1000; margin: 0; padding: 4px; list-style: none; min-width: 160px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 6px 20px rgba(0, 0, 0, .25); }
.user-menu-title { padding: 4px 10px; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.user-menu button { display: block; width: 100%; text-align: left; padding: 6px 10px; border: 0; border-radius: 4px;
  background: none; color: inherit; font: inherit; cursor: pointer; }
.user-menu button:hover, .user-menu button:focus-visible { background: var(--accent-soft); outline: none; }

/* ---------------------------------------------------------------- Feuille d'actions */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 1100; display: flex; align-items: flex-end; justify-content: center;
  background: rgb(0 0 0 / 0.45); animation: sheet-fade 0.15s ease;
}
.sheet {
  width: min(100%, 28rem); max-height: 85dvh; overflow-y: auto; padding: 0.4rem 0.75rem calc(0.75rem + env(safe-area-inset-bottom));
  background: var(--surface); color: var(--text); border-radius: 16px 16px 0 0;
  box-shadow: 0 -4px 24px rgb(0 0 0 / 0.3); animation: sheet-up 0.2s ease;
}
.sheet-grip { width: 2.5rem; height: 4px; margin: 0.2rem auto 0.5rem; border-radius: 2px; background: var(--border); }
.sheet-head { display: flex; align-items: baseline; gap: 0.5rem; padding: 0.2rem 0.25rem 0.6rem; font-size: 1.1rem; }
.sheet-actions { display: flex; flex-direction: column; gap: 2px; }
.sheet-action {
  width: 100%; min-height: 48px; padding: 0.6rem 0.75rem; border: 0; border-radius: 8px; text-align: left;
  background: transparent; color: inherit; font: inherit; cursor: pointer;
}
.sheet-action:hover, .sheet-action:focus-visible { background: var(--accent-soft); }
.sheet-action.danger { color: var(--danger); }
.sheet-cancel { margin-top: 0.4rem; text-align: center; font-weight: 600; background: var(--surface-2); }
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: none; } }
@keyframes sheet-fade { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .sheet, .sheet-backdrop { animation: none; } }

/* ---------------------------------------------------------------- Sélecteur rapide (Ctrl+K) */
.quickswitch-open {
  display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.3rem 0.6rem; cursor: pointer;
  border: 1px solid var(--border); border-radius: 6px; background: var(--surface-2); color: var(--muted);
}
.quickswitch-open kbd { font: inherit; font-size: 0.75rem; padding: 0 0.3rem; border: 1px solid var(--border); border-radius: 4px; background: var(--surface); }
@media (max-width: 720px) { .quickswitch-open { min-height: 2.25rem; padding: 0.3rem 0.5rem; } }
@media (max-width: 720px), (pointer: coarse) { .quickswitch-open kbd { display: none; } }
.qs-backdrop {
  position: fixed; inset: 0; z-index: 1200; display: flex; justify-content: center; align-items: flex-start;
  padding: 12vh 0.75rem 0; background: rgb(0 0 0 / 0.45);
}
.qs-box {
  width: min(100%, 34rem); max-height: 70dvh; display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 12px 40px rgb(0 0 0 / 0.35);
}
.qs-input { width: 100%; padding: 0.85rem 1rem; border: 0; border-bottom: 1px solid var(--border); background: transparent; font-size: 1.05rem; outline: none; }
.qs-list { list-style: none; margin: 0; padding: 0.3rem; overflow-y: auto; }
.qs-item { display: flex; align-items: center; gap: 0.6rem; padding: 0.5rem 0.7rem; border-radius: 8px; cursor: pointer; min-height: 44px; }
.qs-item.active { background: var(--accent-soft); box-shadow: inset 3px 0 var(--accent); }
.qs-kind { flex: none; width: 4.2rem; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); }
.qs-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.qs-hint { flex: none; font-size: 0.85rem; max-width: 9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qs-item .badge-count { min-width: 1.3rem; padding: 0 0.3rem; border-radius: 999px; background: var(--accent); color: var(--accent-text); font-size: 0.75rem; text-align: center; }
.qs-item .badge-count.mention { background: var(--system); }
.qs-empty { padding: 0.8rem 1rem; }
.qs-foot { margin: 0; padding: 0.4rem 0.8rem; border-top: 1px solid var(--border); font-size: 0.8rem; }

/* ---------------------------------------------------------------- Recherche et groupes (membres) */
.member-search-row { padding: 0 0.6rem 0.35rem; flex: none; }
.member-search {
  width: 100%; padding: 0.4rem 0.6rem; border: 1px solid var(--border); border-radius: 6px; background: var(--surface);
}
.member-group {
  position: sticky; top: 0; z-index: 1; padding: 0.25rem 0.6rem; background: var(--surface-2);
  border-bottom: 1px solid var(--border); font-size: 0.75rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted);
}
.member-empty { padding: 0.6rem; }
@media (max-width: 720px) { .member-search { min-height: 44px; font-size: 16px; } }

/* ---------------------------------------------------------------- Barre d'actions d'un message */
.msg { position: relative; }
.msg-tools {
  position: absolute; right: 0.25rem; top: -0.45rem; z-index: 2; display: none; gap: 1px; padding: 2px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 2px 8px rgb(0 0 0 / 0.2);
  white-space: nowrap;
}
.msg:hover .msg-tools, .msg:focus-within .msg-tools, .msg.tools-open .msg-tools { display: inline-flex; }
.msg-tool {
  min-width: 1.9rem; height: 1.7rem; padding: 0 0.3rem; border: 0; border-radius: 6px; background: none;
  color: var(--text); font-size: 0.95rem; line-height: 1; cursor: pointer;
}
.msg-tool:hover, .msg-tool:focus-visible { background: var(--accent-soft); }
.msg-report { color: var(--muted); }
@media (pointer: coarse) {
  .msg:hover:not(.tools-open) .msg-tools:not(:focus-within) { display: none; }
  .msg-tool { min-width: 2.6rem; height: 2.4rem; font-size: 1.1rem; }
}

/* Mode découverte : visiteur sans compte, lecture seule. */
.visitor-actions { display: none; gap: 0.4rem; align-items: center; }
body[data-spectator] .visitor-actions, body[data-visitor] .visitor-actions { display: inline-flex; }
body[data-spectator] .presence, body[data-visitor] .presence,
body[data-spectator] #quickswitch-open, body[data-visitor] #quickswitch-open,
body[data-spectator] #topbar-menu-toggle, body[data-visitor] #topbar-menu-toggle,
body[data-spectator] .topbar-menu, body[data-visitor] .topbar-menu { display: none; }
.spectator-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.8rem;
  padding: 0.6rem 0.8rem;
  border-top: 1px solid var(--border); background: var(--accent-soft);
}
.visitor-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem 0.8rem;
  padding: 0.4rem 0.8rem; font-size: 0.9rem;
  border-top: 1px solid var(--border); background: var(--accent-soft);
}
.visitor-bar.nudge { background: var(--mention); border-top-color: var(--mention-border); }
.room.visitor .member-actions,
.room.visitor .act-invite,
.room.visitor .room-settings,
.room.visitor .member-sort,
.room.visitor .composer-more,
.room.visitor .composer-options,
.room.visitor .msg-reply,
.room.visitor .msg-quote { display: none; }
.room.spectator .msg-tools,
.room.spectator .member-actions,
.room.spectator .act-call,
.room.spectator .act-invite,
.room.spectator .room-settings,
.room.spectator .member-sort { display: none; }

/* Inviter un ami (onglet Statut) */
.invite-row { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; }
.invite-row input { flex: 1 1 14rem; min-width: 0; padding: 0.45rem 0.6rem; border: 1px solid var(--border);
  border-radius: 6px; background: var(--surface-2); color: var(--text); }

/* Pseudo actif (principal ou alias) */
.identity-picker select { max-width: 11rem; text-overflow: ellipsis; }
.identity-choices { display: flex; flex-direction: column; gap: 0.4rem; margin: 0.6rem 0; }
.identity-choice { display: flex; align-items: center; gap: 0.5rem; padding: 0.55rem 0.7rem; min-height: 44px;
  border: 1px solid var(--border); border-radius: 8px; cursor: pointer; }
.identity-choice:has(input:checked) { border-color: var(--accent, currentColor); }
.identity-choice .nick { font-weight: 600; }
@media (max-width: 600px) { .identity-picker select { max-width: 7.5rem; } }

/* ---------------------------------------------------------------- Style des onglets
   Choisi par chacun (ou imposé par l'administration) : voir theme.js, attribut data-tabstyle
   sur <html>. Ordinateur seulement : sur téléphone, la barre du bas et la rangée défilante gardent
   leur forme. Trois styles :
     folder    (par défaut) le classeur d'origine, l'onglet actif porte un liseré d'accent ;
     underline un trait épais d'accent sous l'onglet actif, sans cadre ;
     pills     l'onglet actif est une pastille pleine. */
@media (min-width: 721px) {
  .tab:not([aria-selected="true"]):hover { color: var(--text); }

  /* Classeur : trois variantes de l'onglet actif (folder : fond teinté et gros liseré ;
     folder-solid : onglet plein couleur ; folder-frame : cadre d'accent, texte coloré). */
  html[data-tabstyle|="folder"] body.chat-app[data-presentation="classic"] .tab:not([aria-selected="true"]):hover,
  html[data-tabstyle|="folder"] body.chat-app[data-presentation="levels"] .tab:not([aria-selected="true"]):hover,
  html[data-tabstyle|="folder"] body.chat-app[data-presentation="rows"] .tab:not([aria-selected="true"]):hover {
    background: var(--surface);
  }
  html[data-tabstyle|="folder"] body.chat-app[data-presentation="classic"] .tab[aria-selected="true"],
  html[data-tabstyle|="folder"] body.chat-app[data-presentation="levels"] .tab-conversations .tab[aria-selected="true"],
  html[data-tabstyle|="folder"] body.chat-app[data-presentation="rows"] .tab-conversations .tab[aria-selected="true"] {
    border-color: var(--accent) var(--accent) transparent; border-top-width: 4px;
    background: var(--accent-soft); color: var(--text); font-weight: 600; padding-top: calc(0.4rem - 3px);
  }
  html[data-tabstyle|="folder"] body.chat-app[data-presentation="levels"] .tab-tools .tab[aria-selected="true"],
  html[data-tabstyle|="folder"] body.chat-app[data-presentation="rows"] .tab-tools .tab[aria-selected="true"] {
    background: var(--accent-soft); color: var(--text); font-weight: 600; box-shadow: inset 0 4px 0 var(--accent);
  }
  html[data-tabstyle="folder-solid"] body.chat-app[data-presentation] .tabs .tab[aria-selected="true"] {
    background: var(--accent); color: var(--accent-text); border-color: var(--accent); border-top-width: 1px; box-shadow: none;
    padding-top: 0.4rem;
  }
  html[data-tabstyle="folder-solid"] body.chat-app[data-presentation] .tabs .tab[aria-selected="true"] .badge-count {
    background: var(--accent-text); color: var(--accent);
  }
  html[data-tabstyle="folder-solid"] body.chat-app[data-presentation] .tabs .tab[aria-selected="true"] .tab-close { color: inherit; }
  html[data-tabstyle="folder-frame"] body.chat-app[data-presentation] .tabs .tab[aria-selected="true"] {
    background: var(--surface); color: var(--accent); border: 2px solid var(--accent); border-bottom: 0; box-shadow: none;
    padding-top: calc(0.4rem - 1px);
  }
  html[data-tabstyle="folder-frame"] body.chat-app[data-presentation="levels"] .tab-tools .tab[aria-selected="true"],
  html[data-tabstyle="folder-frame"] body.chat-app[data-presentation="rows"] .tab-tools .tab[aria-selected="true"] {
    border-bottom: 2px solid var(--accent); border-radius: 6px;
  }

  /* Soulignement */
  html[data-tabstyle="underline"] body.chat-app .tab {
    background: transparent; border: 0; border-radius: 0; margin-bottom: 0; box-shadow: none;
    padding: 0.45rem 0.8rem;
  }
  html[data-tabstyle="underline"] body.chat-app .tab:hover { background: var(--accent-soft); }
  html[data-tabstyle="underline"] body.chat-app .tab[aria-selected="true"] {
    background: transparent; color: var(--text); font-weight: 600; box-shadow: inset 0 -3px 0 var(--accent);
  }
  html[data-tabstyle="underline"] body.chat-app[data-presentation="side"] .tab[aria-selected="true"],
  html[data-tabstyle="underline"] body.chat-app[data-presentation="rail"] .tab[aria-selected="true"] {
    box-shadow: inset 3px 0 0 var(--accent); background: var(--accent-soft);
  }

  /* Pilules */
  html[data-tabstyle="pills"] body.chat-app[data-presentation="classic"] .tabs { align-items: center; padding-bottom: 0.4rem; }
  html[data-tabstyle="pills"] body.chat-app .tab {
    background: transparent; border: 0; border-radius: 999px; margin-bottom: 0; box-shadow: none;
    padding: 0.35rem 0.85rem;
  }
  html[data-tabstyle="pills"] body.chat-app .tab:hover { background: var(--accent-soft); }
  html[data-tabstyle="pills"] body.chat-app .tab.unread { background: var(--accent-soft); }
  html[data-tabstyle="pills"] body.chat-app .tab.mention { background: var(--mention); color: var(--text); }
  html[data-tabstyle="pills"] body.chat-app .tab[aria-selected="true"] {
    background: var(--accent); color: var(--accent-text); font-weight: 600; box-shadow: none;
  }
  html[data-tabstyle="pills"] body.chat-app .tab[aria-selected="true"] .badge-count {
    background: var(--accent-text); color: var(--accent);
  }
  html[data-tabstyle="pills"] body.chat-app .tab-tools,
  html[data-tabstyle="pills"] body.chat-app .tab-conversations { padding-bottom: 0.4rem; }
  html[data-tabstyle="pills"] body.chat-app[data-presentation="side"] .tab-conversations,
  html[data-tabstyle="pills"] body.chat-app[data-presentation="rail"] .tab-tools { padding-bottom: 0.5rem; }
}
