/* =================================================================
   DM-SP — Interface
   Design : dark glass, gradients aurora, accents purple/cyan
================================================================= */

:root {
  --bg-base: #060814;
  --bg-card: rgba(20, 22, 38, 0.72);
  --bg-card-hover: rgba(28, 32, 52, 0.82);
  --bg-active: rgba(45, 55, 100, 0.65);
  --bg-input: rgba(8, 10, 22, 0.6);
  --line: rgba(255, 255, 255, 0.06);
  --line-strong: rgba(255, 255, 255, 0.12);
  --text: #f1f3fb;
  --text-mute: #8a93a8;
  --text-soft: #b9c0d3;
  --purple: #8b3dff;
  --purple-2: #6d2ad6;
  --cyan: #18d8ff;
  --pink: #ff4d8a;
  --green: #2ee77c;
  --red: #ff476f;
  /* Accents par défaut (violet) — surchargés par chaque thème (themes.css).
     Définis ici pour que --gradient marche même sans data-theme. */
  --accent1: #8b3dff;  --accent1-rgb: 139, 61, 255;
  --accent2: #18d8ff;  --accent2-rgb: 24, 216, 255;
  /* Les dégradés suivent le thème → chaque thème change vraiment l'ambiance. */
  --gradient: linear-gradient(135deg, var(--accent1) 0%, var(--accent2) 100%);
  --gradient-soft: linear-gradient(135deg, rgba(var(--accent1-rgb), 0.22), rgba(var(--accent2-rgb), 0.18));
  --shadow-deep: 0 20px 60px rgba(0,0,0,0.55);
  --radius: 14px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  font-family: 'Inter', -apple-system, 'Segoe UI', system-ui, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg-base);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Aurora background */
#bg-aurora {
  position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(circle at 12% 18%, rgba(var(--accent1-rgb), 0.30), transparent 48%),
    radial-gradient(circle at 88% 78%, rgba(var(--accent2-rgb), 0.24), transparent 48%),
    radial-gradient(circle at 50% 50%, rgba(var(--accent1-rgb), 0.08), transparent 65%),
    var(--bg-base);
}

button { cursor: pointer; font-family: inherit; outline: none; border: 0; color: inherit; }
input, textarea { font-family: inherit; outline: none; }
::selection { background: rgba(var(--accent1-rgb), 0.4); }

/* Scrollbars */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(var(--voile), 0.08); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: rgba(var(--voile), 0.16); }

/* =================================================================
   Layout principal
================================================================= */
#app {
  display: grid;
  grid-template-columns: 240px 340px minmax(0, 1fr);
  height: 100vh;
  gap: 0;
  overflow: hidden;
}

aside, section {
  background: var(--bg-card);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;       /* permet aux enfants flex:1 de shrink */
  overflow: hidden;
}
section:last-child { border-right: 0; }

/* =================================================================
   Headers de colonne
================================================================= */
.col-hdr {
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

#convo-list { flex: 1 1 0; min-height: 0; overflow-y: auto; }
#account-list { flex: 1 1 0; min-height: 0; overflow-y: auto; }
.col-hdr-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.col-hdr h2 {
  margin: 0; font-size: 16px; font-weight: 700; letter-spacing: -0.01em;
}

#btn-refresh {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: 8px;
  background: rgba(var(--voile), 0.05);
  color: var(--text-soft);
  transition: background 0.18s, color 0.18s;
}
#btn-refresh:hover { background: rgba(var(--voile), 0.10); color: var(--text); }
#btn-refresh.busy { color: var(--cyan); animation: spin 1.4s linear infinite; }
@keyframes spin { 0%{transform:rotate(0)} 100%{transform:rotate(360deg)} }

.search-wrap {
  position: relative; display: flex; align-items: center;
}
.search-icon {
  position: absolute; left: 12px; color: var(--text-mute); pointer-events: none;
}
#search-input {
  width: 100%;
  padding: 10px 12px 10px 36px;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--line);
  font-size: 13px;
  transition: border-color 0.15s, background 0.15s;
}
#search-input:focus { border-color: var(--purple); background: var(--bg-input); }
#search-input::placeholder { color: var(--text-mute); }

/* =================================================================
   Brand (sidebar comptes)
================================================================= */
.brand {
  display: flex; align-items: center; gap: 12px;
  padding: 22px 18px 20px;
  border-bottom: 1px solid var(--line);
}
.brand-logo {
  width: 40px; height: 40px; border-radius: 12px;
  background: var(--gradient);
  display: grid; place-items: center;
  font-weight: 800; font-size: 20px; color: white;
  box-shadow: 0 6px 20px rgba(var(--accent1-rgb), 0.4);
}
.brand-name { font-weight: 800; font-size: 15px; letter-spacing: -0.01em; }
.brand-sub { font-size: 11px; color: var(--text-mute); margin-top: 1px; }

/* =================================================================
   Liste des comptes
================================================================= */
#account-list {
  list-style: none; margin: 0; padding: 8px;
  flex: 1; overflow-y: auto;
}
#account-list li {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  margin-bottom: 2px;
  transition: background 0.12s;
  position: relative;
}
#account-list li:hover { background: var(--bg-card-hover); }
#account-list li.active {
  background: var(--gradient-soft);
  box-shadow: inset 0 0 0 1px rgba(var(--accent1-rgb), 0.35);
}
#account-list li .avatar { width: 30px; height: 30px; font-size: 13px; }
#account-list li .name {
  flex: 1; font-weight: 600; font-size: 13px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#account-list li .del {
  width: 22px; height: 22px;
  display: grid; place-items: center;
  border-radius: 6px;
  background: transparent; color: var(--text-mute);
  opacity: 0; transition: opacity 0.15s, background 0.15s, color 0.15s;
  font-size: 16px; line-height: 1;
}
#account-list li:hover .del { opacity: 1; }
#account-list li .del:hover { background: rgba(255,71,111,0.18); color: var(--red); }

.add-btn {
  margin: 8px 12px 14px; padding: 11px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: var(--radius-sm);
  background: rgba(var(--voile), 0.05);
  color: var(--text-soft);
  font-weight: 600; font-size: 13px;
  border: 1px dashed var(--line-strong);
  transition: background 0.18s, color 0.18s, border-color 0.18s;
}
.add-btn:hover {
  background: var(--gradient-soft);
  color: var(--text);
  border-color: rgba(var(--accent1-rgb), 0.4);
}
.add-btn .plus {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--gradient);
  display: grid; place-items: center;
  font-weight: 700; color: white; font-size: 14px; line-height: 1;
}

/* =================================================================
   Avatars (initiales colorées)
================================================================= */
.avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 700; font-size: 14px; color: white;
  flex-shrink: 0;
  background: var(--gradient);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  box-shadow: 0 2px 8px rgba(var(--ombre), 0.25);
}
.avatar-lg { width: 44px; height: 44px; font-size: 16px; }

/* =================================================================
   Liste des conversations
================================================================= */
#convo-list {
  flex: 1; overflow-y: auto; padding: 6px 8px 10px;
}
#convo-list .empty {
  padding: 60px 24px; text-align: center;
  color: var(--text-mute); font-size: 13px; line-height: 1.5;
}
.convo-item {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  margin-bottom: 2px;
  transition: background 0.12s;
  position: relative;
}
.convo-item:hover { background: var(--bg-card-hover); }
.convo-item.active {
  background: var(--gradient-soft);
  box-shadow: inset 0 0 0 1px rgba(var(--accent1-rgb), 0.35);
}
.convo-body { flex: 1; min-width: 0; }
.convo-row1 {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
}
.convo-name {
  font-weight: 600; font-size: 13.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--text);
}
.convo-ts {
  font-size: 11px; color: var(--text-mute); flex-shrink: 0;
}
.convo-row2 {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin-top: 3px;
}
.convo-preview {
  flex: 1; min-width: 0;
  font-size: 12.5px; color: var(--text-mute);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.convo-badge {
  background: var(--gradient);
  color: white;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px; font-weight: 700;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(var(--accent1-rgb), 0.4);
  min-width: 20px; text-align: center;
}
.convo-item.unread .convo-name { color: var(--text); font-weight: 700; }
.convo-item.unread .convo-preview { color: var(--text-soft); font-weight: 500; }

/* =================================================================
   Header thread
================================================================= */
.thread-hdr {
  padding: 16px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.thread-info { display: flex; align-items: center; gap: 14px; flex: 1; min-width: 0; }
.thread-action {
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid var(--border, rgba(var(--voile), .12));
  background: rgba(255,170,80,.10);
  color: #ffb060;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, color .15s;
}
.thread-action:hover:not(:disabled) { background: rgba(255,170,80,.20); color: #ffd090; }
.thread-action:disabled { opacity: .55; cursor: progress; }

/* Bouton d'appel dans l'en-tete de conversation */
#btn-appel {
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center; flex-shrink: 0;
  background: rgba(46,231,124,.14);
  border: 1px solid rgba(46,231,124,.35);
  color: #2ee77c;
  transition: background .15s, transform .1s;
}
#btn-appel:hover { background: rgba(46,231,124,.24); }
#btn-appel:active { transform: scale(.94); }
#btn-appel[hidden] { display: none !important; }
.thread-meta { flex: 1; min-width: 0; }
#thread-title {
  margin: 0; font-size: 16px; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.thread-sub {
  font-size: 12px; color: var(--text-mute); margin-top: 2px;
}

/* =================================================================
   Messages (thread)
================================================================= */
#messages {
  flex: 1 1 0;
  min-height: 0;              /* flex shrink fix : empêche que ça pousse le composer hors champ */
  overflow-y: auto;
  padding: 22px;
  display: flex; flex-direction: column; gap: 4px;
}
#messages .empty {
  margin: auto; text-align: center; padding: 40px;
  color: var(--text-mute); font-size: 14px;
}
.day-sep {
  align-self: center;
  font-size: 11px; font-weight: 600;
  color: var(--text-mute);
  text-transform: uppercase; letter-spacing: 0.06em;
  padding: 10px 14px; margin: 14px 0 6px;
  background: rgba(var(--voile), 0.04);
  border-radius: 999px;
}
.msg {
  max-width: 70%;
  padding: 10px 14px;
  border-radius: 18px;
  word-wrap: break-word;
  position: relative;
  font-size: 14px;
  line-height: 1.45;
}
.msg.new { animation: pop-in 0.22s ease-out; }
@keyframes pop-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
.msg.me {
  align-self: flex-end;
  background: var(--gradient);
  color: white;
  border-bottom-right-radius: 6px;
  box-shadow: 0 4px 14px rgba(var(--accent1-rgb), 0.35);
}
.msg.them {
  align-self: flex-start;
  background: rgba(var(--voile), 0.06);
  border: 1px solid var(--line);
  border-bottom-left-radius: 6px;
}
.msg .who {
  font-size: 11px; font-weight: 700;
  margin-bottom: 3px;
  color: var(--cyan);
  letter-spacing: 0.02em;
}
.msg .body { white-space: pre-wrap; }
.msg .ts {
  font-size: 10px; opacity: 0.6; margin-top: 4px;
}
.msg.me .ts { color: rgba(var(--sur-accent), 0.85); }
.msg.them .ts { color: var(--text-mute); }
.msg.sending { opacity: 0.5; }
.msg.failed {
  background: linear-gradient(135deg, #b03a4a, #6d1c2c) !important;
  color: white;
  box-shadow: 0 4px 14px rgba(255,71,111,0.4) !important;
}
.msg.failed .ts { color: #ffd2dc; }

/* Group consecutive messages from same sender */
.msg.grouped { margin-top: 1px; }
.msg.grouped.me { border-top-right-radius: 8px; border-bottom-right-radius: 6px; }
.msg.grouped.them { border-top-left-radius: 8px; border-bottom-left-radius: 6px; }
.msg.grouped .who { display: none; }

/* =================================================================
   Composer
================================================================= */
#composer {
  flex-shrink: 0;             /* le composer reste toujours visible */
  display: flex; gap: 10px; align-items: flex-end;
  padding: 14px 18px 18px;
  border-top: 1px solid var(--line);
  background: var(--bg-card);
}
#composer-text {
  flex: 1;
  resize: none;
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  background: var(--bg-input);
  color: var(--text);
  padding: 12px 14px;
  font-size: 14px;
  line-height: 1.4;
  max-height: 140px;
  transition: border-color 0.15s, background 0.15s;
}
#composer-text::placeholder { color: var(--text-mute); }
#composer-text:focus {
  border-color: rgba(var(--accent1-rgb), 0.5);
  background: var(--bg-input);
}
#btn-send {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--gradient);
  color: white;
  display: grid; place-items: center;
  flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(var(--accent1-rgb), 0.35);
  transition: transform 0.12s, box-shadow 0.12s;
}
#btn-send:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(var(--accent1-rgb), 0.5); }
#btn-send:active { transform: translateY(0); }
#btn-send:disabled { opacity: 0.5; cursor: not-allowed; }

/* =================================================================
   Modale "Ajouter un compte"
================================================================= */
dialog {
  background: var(--bg-card);
  backdrop-filter: blur(10px);
  color: var(--text);
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  padding: 26px 28px;
  min-width: 360px;
  box-shadow: var(--shadow-deep);
}
dialog::backdrop { background: rgba(var(--ombre), 0.6); backdrop-filter: blur(8px); }
dialog h3 {
  margin: 0 0 4px; font-size: 18px; font-weight: 700; letter-spacing: -0.01em;
}
.dlg-sub { color: var(--text-mute); font-size: 13px; margin: 0 0 18px; }
dialog label {
  display: block; margin-bottom: 12px;
  font-size: 12px; font-weight: 600; color: var(--text-soft);
  letter-spacing: 0.02em;
}
dialog input {
  display: block; width: 100%; margin-top: 6px;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--bg-input);
  color: var(--text);
  font-size: 14px; font-weight: 500;
  transition: border-color 0.15s;
}
dialog input:focus { border-color: var(--purple); }
dialog .row {
  display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px;
}
dialog button {
  padding: 10px 18px; border-radius: 10px; font-weight: 700;
  font-size: 13px; transition: background 0.15s, color 0.15s, transform 0.1s;
}
dialog button.ghost {
  background: rgba(var(--voile), 0.06); color: var(--text-soft);
}
dialog button.ghost:hover { background: rgba(var(--voile), 0.12); color: var(--text); }
dialog button.primary {
  background: var(--gradient); color: white;
  box-shadow: 0 4px 14px rgba(var(--accent1-rgb), 0.35);
}
dialog button.primary:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(var(--accent1-rgb), 0.5); }

.err {
  color: #ff8a9c; font-size: 13px;
  margin-top: 12px; min-height: 18px;
  padding-left: 4px;
}

/* =================================================================
   Etats vides / loading
================================================================= */
/* =================================================================
   Responsive
================================================================= */
@media (max-width: 900px) {
  #app { grid-template-columns: 60px 280px minmax(0, 1fr); }
  .brand { padding: 18px 8px; justify-content: center; }
  .brand-text { display: none; }
  .add-btn { padding: 11px 6px; }
  .add-btn span:not(.plus) { display: none; }
  #account-list li { justify-content: center; padding: 8px; }
  #account-list li .name { display: none; }
  #account-list li .del { position: absolute; top: -2px; right: -2px; background: var(--bg-card); }
}
@media (max-width: 640px) {
  #app { grid-template-columns: 0 240px minmax(0, 1fr); }
  #accounts { display: none; }
}

.skeleton {
  display: flex; flex-direction: column; gap: 8px; padding: 8px;
}
.skeleton .row {
  height: 56px; border-radius: var(--radius-sm);
  background: linear-gradient(90deg, rgba(var(--voile), 0.04) 0%, rgba(var(--voile), 0.08) 50%, rgba(var(--voile), 0.04) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.6s ease-in-out infinite;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Mentions @ ───────────────────────────────────────────────────── */
.mention { color: var(--accent1); font-weight: 600; text-decoration: none; }
.mention:hover { text-decoration: underline; }

.ment-pop {
  position: fixed; z-index: 600;
  background: var(--bg-card); border: 1px solid var(--line-strong);
  border-radius: 12px; box-shadow: 0 10px 34px rgba(0,0,0,0.45);
  overflow-y: auto; max-height: 232px; padding: 4px;
}
.ment-pop[hidden] { display: none; }
.ment-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 9px; cursor: pointer;
}
.ment-item.sel, .ment-item:hover { background: var(--bg-input); }
.ment-av { width: 30px; height: 30px; font-size: 13px; flex-shrink: 0; }
.ment-nom { font-size: 14px; font-weight: 600; color: var(--text); }

/* Accusé de lecture « Vu » sous mon dernier message MSP */
.msg-vu {
  align-self: flex-end; text-align: right;
  font-size: 11px; font-weight: 600; color: var(--text-mute);
  margin: 1px 6px 3px 0;
}

/* Bulle de l'autre cliquable vers son profil (quand il a l'appli) */
#messages.peut-profil .msg.them { cursor: pointer; }

/* Bannière « nouvelle version dispo » (mise à jour PWA) */
#maj-banniere {
  position: fixed; left: 50%; top: calc(10px + env(safe-area-inset-top));
  transform: translateX(-50%); z-index: 9999;
  background: var(--gradient); color: #fff; font-size: 12.5px; font-weight: 700;
  padding: 9px 16px; border-radius: 999px; cursor: pointer;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4); max-width: calc(100vw - 28px);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  animation: maj-in .3s ease-out;
}
@keyframes maj-in { from { opacity: 0; transform: translate(-50%, -8px); } to { opacity: 1; transform: translateX(-50%); } }

/* Confirmation du changement de mot de passe (paramètres) */
#mdp-msg { margin-top: 12px; padding: 11px 14px; border-radius: 12px;
  font-size: 13.5px; font-weight: 600; line-height: 1.4; animation: maj-in .25s ease-out; }
#mdp-msg.mdp-ok { background: rgba(46,231,124,.14); color: #2ee77c; border: 1px solid rgba(46,231,124,.4); }
#mdp-msg.mdp-err { background: rgba(255,77,109,.14); color: #ff6b81; border: 1px solid rgba(255,77,109,.4); }
#mdp-msg[hidden] { display: none; }

/* =================================================================
   GIF (GIPHY) — bouton du composeur + panneau de recherche
================================================================= */
#btn-gif {
  width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0;
  font-weight: 800; font-size: 12px; letter-spacing: 0.02em;
  color: var(--text-soft); background: var(--bg-input);
  border: 1px solid var(--line-strong);
  display: grid; place-items: center;
  transition: background 0.15s, color 0.15s;
}
#btn-gif:hover { background: var(--bg-card-hover); color: var(--text); }
#btn-gif:active { transform: translateY(1px); }

#thread { position: relative; }               /* ancre du panneau GIF */

#gif-pop {
  position: absolute; left: 10px; right: 10px; bottom: 78px; z-index: 40;
  height: min(46vh, 320px); display: flex; flex-direction: column;
  background: var(--bg-card); border: 1px solid var(--line-strong);
  border-radius: 16px; box-shadow: var(--shadow-deep);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  overflow: hidden;
}
#gif-pop[hidden] { display: none; }
.gif-tete { display: flex; gap: 8px; padding: 10px; border-bottom: 1px solid var(--line); }
#gif-q {
  flex: 1; border: 1px solid var(--line-strong); background: var(--bg-input);
  color: var(--text); border-radius: 10px; padding: 9px 12px; font-size: 14px;
}
#gif-q:focus { border-color: var(--purple); outline: none; }
.gif-tete #gif-x {
  width: 38px; border-radius: 10px; background: var(--bg-input);
  border: 1px solid var(--line-strong); color: var(--text-soft); font-size: 15px;
}
#gif-grid {
  flex: 1; overflow-y: auto; padding: 8px;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; align-content: start;
}
.gif-item {
  width: 100%; height: 96px; object-fit: cover; border-radius: 8px; cursor: pointer;
  background: var(--bg-input); transition: transform 0.1s;
}
.gif-item:hover { transform: scale(1.03); }
.gif-info { grid-column: 1 / -1; color: var(--text-mute); font-size: 13px; padding: 18px; text-align: center; }
.gif-attr { padding: 6px 10px; font-size: 10.5px; color: var(--text-mute); text-align: right; border-top: 1px solid var(--line); }

/* GIF — variante composeur de groupe (réutilise .gif-tete/.gif-item/.gif-info/.gif-attr) */
#gv-gif {
  width: 42px; height: 42px; border-radius: 50%; flex-shrink: 0;
  font-weight: 800; font-size: 12px; letter-spacing: 0.02em;
  color: var(--text-soft); background: var(--bg-input);
  border: 1px solid var(--line-strong);
  display: grid; place-items: center; transition: background 0.15s, color 0.15s;
}
#gv-gif:hover { background: var(--bg-card-hover); color: var(--text); }
#gvgif-pop {
  position: absolute; left: 10px; right: 10px; bottom: 78px; z-index: 130;
  height: min(46vh, 320px); display: flex; flex-direction: column;
  background: var(--bg-card); border: 1px solid var(--line-strong);
  border-radius: 16px; box-shadow: var(--shadow-deep);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); overflow: hidden;
}
#gvgif-pop[hidden] { display: none; }
#gvgif-q {
  flex: 1; border: 1px solid var(--line-strong); background: var(--bg-input);
  color: var(--text); border-radius: 10px; padding: 9px 12px; font-size: 14px;
}
#gvgif-q:focus { border-color: var(--purple); outline: none; }
.gif-tete button {
  width: 38px; border-radius: 10px; background: var(--bg-input);
  border: 1px solid var(--line-strong); color: var(--text-soft); font-size: 15px;
}
#gvgif-grid {
  flex: 1; overflow-y: auto; padding: 8px;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; align-content: start;
}

/* =================================================================
   Verrouillage portrait (mobile) + anti-grossissement de texte iOS
================================================================= */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
#rotate-lock { display: none; }
@media (orientation: landscape) and (max-height: 520px) {
  #app, #barre-nav, #obs-bandeau, #groupe-vue { display: none !important; }
  #rotate-lock {
    display: flex; position: fixed; inset: 0; z-index: 100000;
    flex-direction: column; align-items: center; justify-content: center; gap: 16px;
    background: var(--bg-base); color: var(--text); text-align: center; padding: 32px;
  }
  #rotate-lock svg { width: 54px; height: 54px; color: var(--purple); }
  #rotate-lock .rl-t { font-weight: 800; font-size: 18px; }
  #rotate-lock .rl-s { color: var(--text-mute); font-size: 14px; max-width: 260px; line-height: 1.5; }
}

/* =================================================================
   Fluidité — réactivité tactile, moins de reflows, moins de peinture.
================================================================= */
/* Enlève le flash gris iOS au tap (on donne notre propre retour via :active). */
* { -webkit-tap-highlight-color: transparent; }

/* Supprime le délai de ~300ms et le double-tap-zoom sur les éléments tactiles. */
button, a, label, summary, [role="button"],
.convo-item, .look-case, .gens-item, .param-item, .profil-item,
.ord-btn, .btn-ic, .btn-profil, .pub-av, .case-av,
.pub-btn-react, .pub-epingler, .gif-item, .m-tab {
  touch-action: manipulation;
}

/* Retour visuel instantané au toucher (transform = compositeur, gratuit). */
button:active, .convo-item:active, .gens-item:active,
.param-item:active, .profil-item:active, .btn-profil:active, .btn-ic:active,
.pub-av:active {
  transform: scale(0.97);
}

/* (content-visibility retiré des .pub : avec des posts de hauteurs variables,
   il provoquait des sauts de défilement dans le fil.) */

/* Respecte le réglage système « réduire les animations ». */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* =================================================================
   Écran de lancement (splash) + transitions de page douces
================================================================= */
#splash {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  background: var(--bg-base);
  transition: opacity 0.35s ease, visibility 0.35s;
}
#splash.parti { opacity: 0; visibility: hidden; pointer-events: none; }
#splash img {
  width: 84px; height: 84px; border-radius: 22px;
  box-shadow: 0 10px 40px rgba(0,0,0,.5);
  animation: splash-pop 0.5s cubic-bezier(.2,.9,.3,1);
}
#splash .splash-nom {
  font-size: 15px; font-weight: 800; letter-spacing: .05em; color: var(--text-soft);
}
@keyframes splash-pop { from { transform: scale(.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* Fondu doux du contenu à l'arrivée + transitions inter-pages (Chrome/Android).
   NB : on N'anime PAS #app (messagerie) — l'animation y créait un contexte
   d'empilement qui piégeait le panneau des comptes derrière son voile. */
body.avec-nav #fil-page,
body.avec-nav #profil-page,
body.avec-nav #activite-page { animation: page-in 0.22s ease-out both; }
@keyframes page-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@view-transition { navigation: auto; }

/* Splash : uniquement au lancement de l'app, pas à chaque navigation interne.
   La classe `deja-lance` est posée (avant peinture) dès la 2e page de la session. */
html.deja-lance #splash { display: none !important; }

/* Message d'aide dans le panneau des comptes */
.acct-aide { font-size: 12px; color: var(--text-mute); line-height: 1.45; padding: 4px 14px 10px; margin: 0; }

/* ── Menu ⋯ des publications + mini-questionnaire de signalement ──── */
.pub { position: relative; }
.pub-menu {
  position: absolute; top: 46px; right: 12px; z-index: 50; min-width: 168px;
  background: var(--bg-card); border: 1px solid var(--line-strong); border-radius: 12px;
  box-shadow: var(--shadow-deep); overflow: hidden; animation: pub-menu-in .12s ease-out;
}
@keyframes pub-menu-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.pub-menu button {
  display: block; width: 100%; text-align: left; padding: 12px 15px;
  font-size: 14px; font-weight: 600; color: var(--text); background: transparent; cursor: pointer;
}
.pub-menu button:hover { background: var(--bg-card-hover); }
.pub-menu button.rouge { color: var(--red); }

.signal-dlg { max-width: 400px; width: calc(100vw - 28px); min-width: 0; }
.signal-dlg h3 { margin: 0 0 4px; font-size: 17px; font-weight: 800; }
.signal-sub { margin: 0 0 14px; font-size: 13.5px; color: var(--text-mute); }
.signal-motifs { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.signal-opt {
  display: flex; align-items: center; gap: 11px; padding: 11px 13px; cursor: pointer;
  border-radius: 11px; background: var(--bg-input); border: 1px solid var(--line-strong);
  font-size: 14px; color: var(--text);
}
.signal-opt input { accent-color: var(--accent1); width: 18px; height: 18px; flex-shrink: 0; }
.signal-opt:has(input:checked) { border-color: var(--accent1); background: var(--gradient-soft); }
.signal-dlg textarea {
  width: 100%; border-radius: 10px; border: 1px solid var(--line-strong);
  background: var(--bg-input); color: var(--text); padding: 10px 12px;
  font-family: inherit; font-size: 14px; resize: none;
}
@media (max-width: 640px) { .signal-dlg textarea { font-size: 16px; } }
.signal-row { display: flex; gap: 10px; justify-content: flex-end; margin-top: 14px; }
.signal-row button { padding: 10px 18px; border-radius: 10px; font-weight: 700; font-size: 14px; cursor: pointer; }
.signal-row .ghost { background: var(--bg-input); color: var(--text-soft); border: 1px solid var(--line-strong); }
.signal-row .primary { background: var(--gradient); color: #fff; }
#signal-msg.alert { margin-top: 12px; }

/* Post ciblé par un lien direct (modération) : surbrillance temporaire */
.pub-surligne { animation: pub-surligne 3s ease; }
@keyframes pub-surligne {
  0%, 100% { box-shadow: none; }
  15%, 65% { box-shadow: 0 0 0 2px var(--accent1), 0 0 26px rgba(var(--accent1-rgb), .5); }
}

/* Vidéo dans une publication */
.pub-video-wrap { margin: 0 -14px 10px; background: #000; overflow: hidden; }
.pub-video { display: block; width: 100%; height: 100%; object-fit: cover; background: #000; }

/* Vignette vidéo (lecture au tap) — remplit le cadre standard du post */
.pub-video-poster {
  position: relative; width: 100%; height: 100%; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  background: linear-gradient(135deg, #14121f, #1e1033);
}
.pub-video-play {
  width: 58px; height: 58px; border-radius: 50%;
  display: grid; place-items: center; font-size: 22px; color: #fff; padding-left: 4px;
  background: rgba(255,255,255,.14); border: 2px solid rgba(255,255,255,.65);
  box-shadow: 0 6px 20px rgba(0,0,0,.4); transition: transform .12s, background .12s;
}
.pub-video-poster:hover .pub-video-play { transform: scale(1.08); background: rgba(255,255,255,.24); }
.pub-video-lbl { font-size: 12px; font-weight: 700; color: rgba(255,255,255,.7); letter-spacing: .04em; }

/* Bouton son (mute/unmute) sur les vidéos en lecture auto */
.pub-video-wrap { position: relative; }
.pub-video-son {
  position: absolute; bottom: 10px; right: 10px; z-index: 2;
  width: 38px; height: 38px; border-radius: 50%; font-size: 16px; cursor: pointer;
  background: rgba(0,0,0,.55); color: #fff; border: none;
  display: grid; place-items: center; backdrop-filter: blur(4px);
}

/* ── Look VIP : pseudo doré + anneau d'avatar ────────────────────── */
.nom-vip {
  background: linear-gradient(92deg, #f7d98a 0%, #e6a92e 42%, #fff3c4 55%, #e6a92e 70%, #f7d98a 100%);
  -webkit-background-clip: text; background-clip: text;
  color: #e6a92e; -webkit-text-fill-color: transparent;
  font-weight: 800;
}
.av-vip {
  box-shadow: 0 0 0 2px #e6a92e, 0 0 9px rgba(230,169,46,.55);
}

/* ═══════════════ Sondages (fil + groupes) ═══════════════════════════ */
.sondage {
  margin: 10px 0 2px; padding: 12px 14px; border-radius: 14px;
  background: var(--bg-input); border: 1px solid var(--line);
}
.sond-q { font-weight: 700; font-size: 14px; margin-bottom: 10px; line-height: 1.3; }
.sond-opts { display: flex; flex-direction: column; gap: 7px; }
.sond-opt {
  position: relative; overflow: hidden; width: 100%; text-align: left;
  padding: 10px 12px; border-radius: 10px;
  background: var(--bg-card); border: 1px solid var(--line-strong);
  font-size: 13.5px; font-weight: 600; color: var(--text);
  display: flex; align-items: center; gap: 8px;
  transition: border-color .15s;
}
.sond-opt:not(.vote):hover { border-color: rgba(var(--accent1-rgb), .55); }
.sond-bar {
  position: absolute; left: 0; top: 0; bottom: 0; width: 0; z-index: 0;
  background: var(--gradient-soft); transition: width .45s ease;
}
.sond-txt { position: relative; z-index: 1; flex: 1; min-width: 0; }
.sond-pct {
  position: relative; z-index: 1; font-size: 12.5px; font-weight: 700;
  color: var(--text-soft); font-variant-numeric: tabular-nums;
}
.sond-opt.choisi { border-color: var(--accent1); }
.sond-opt.choisi .sond-txt::after { content: ' ✓'; color: var(--accent1); font-weight: 800; }
.sond-total { margin-top: 9px; font-size: 11.5px; color: var(--text-mute); }

/* ═══════════════ Bandeau d'avertissement (lecture seule) ═════════════ */
#avert-bandeau {
  position: fixed; left: 12px; right: 12px; z-index: 300;
  bottom: calc(74px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 11px;
  padding: 12px 15px; border-radius: 14px;
  background: linear-gradient(135deg, #ffab40, #ff6b6b);
  color: #3a1e00; font-size: 13px; font-weight: 700; line-height: 1.35;
  box-shadow: 0 12px 34px -8px rgba(0,0,0,.55);
  animation: avert-pop .25s ease-out;
}
#avert-bandeau .avert-ic { font-size: 22px; flex-shrink: 0; }
#avert-bandeau .avert-reste { font-variant-numeric: tabular-nums; }
@keyframes avert-pop { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@media (min-width: 821px) {
  #avert-bandeau { left: 92px; right: auto; bottom: 16px; max-width: 460px; }
}

/* ═══════════════ Œil « afficher le mot de passe » ═══════════════════ */
.mdp-wrap { position: relative; display: block; }
.mdp-wrap > input { width: 100%; padding-right: 44px !important; }
.mdp-oeil {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 34px; height: 34px; display: grid; place-items: center;
  background: transparent; color: var(--text-mute); border-radius: 8px;
  -webkit-tap-highlight-color: transparent;
}
.mdp-oeil:hover { color: var(--text-soft); }

/* ═══════════ Guide d'installation iOS (étapes) ═══════════════════════ */
#pwa-steps {
  position: fixed; inset: 0; z-index: 500; display: grid; place-items: center;
  padding: 20px; background: rgba(0,0,0,.6); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}
.pwa-steps-carte {
  width: 100%; max-width: 360px; text-align: center;
  background: var(--bg-card); border: 1px solid var(--line-strong);
  border-radius: 20px; padding: 24px 22px; box-shadow: var(--shadow-deep);
}
.pwa-steps-ico { width: 58px; height: 58px; border-radius: 14px; margin-bottom: 10px; }
.pwa-steps-carte h3 { margin: 0 0 4px; font-size: 18px; font-weight: 800; }
.pwa-steps-sous { margin: 0 0 16px; font-size: 13px; color: var(--text-mute); }
.pwa-steps-liste {
  text-align: left; margin: 0 0 18px; padding-left: 20px;
  font-size: 14px; line-height: 1.7; color: var(--text-soft);
}
.pwa-steps-liste b { color: var(--text); }
.pwa-steps-liste .pwa-share {
  display: inline-grid; place-items: center; width: 24px; height: 24px;
  border-radius: 6px; background: var(--bg-input); vertical-align: middle; color: var(--accent2);
}
.pwa-steps-ok {
  width: 100%; padding: 12px; border-radius: 12px;
  background: var(--gradient); color: #fff; font-size: 15px; font-weight: 700;
}
