/* =================================================================
   Connexion, administration, et les quelques ajouts de l'app
   multi-utilisateurs. Reprend les variables definies dans app.css.
================================================================= */

/* ── Pages autonomes (connexion / administration) ────────────────── */
body.page {
  overflow: auto;
  min-height: 100dvh;
}
.page-wrap {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 18px;
}
.page-wrap.top { align-items: flex-start; padding-top: 40px; }

.card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-card);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line-strong);
  border-radius: 20px;
  box-shadow: var(--shadow-deep);
  padding: 34px 30px;
}
.card.wide { max-width: 760px; }

.logo-row {
  display: flex; align-items: center; gap: 13px;
  margin-bottom: 26px;
}
.logo-mark {
  width: 46px; height: 46px; border-radius: 14px;
  background: var(--gradient);
  display: grid; place-items: center;
  font-weight: 800; font-size: 20px; color: #fff;
  box-shadow: 0 6px 20px rgba(var(--accent1-rgb), 0.4);
}
.logo-title { font-size: 19px; font-weight: 700; letter-spacing: -0.02em; }
.logo-sub   { font-size: 13px; color: var(--text-mute); margin-top: 2px; }

.field { display: block; margin-bottom: 16px; }
.field span {
  display: block; margin-bottom: 7px;
  font-size: 12px; font-weight: 600; letter-spacing: 0.03em;
  color: var(--text-soft); text-transform: uppercase;
}
.field input {
  display: block; width: 100%;
  padding: 13px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--bg-input);
  color: var(--text);
  font-size: 16px;                 /* 16px : empeche le zoom auto sur iOS */
  font-weight: 500;
  transition: border-color 0.15s, background 0.15s;
}
.field input:focus {
  border-color: rgba(var(--accent1-rgb), 0.55);
  background: var(--bg-input);
}

.btn-primary {
  width: 100%;
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  background: var(--gradient);
  color: #fff;
  font-size: 15px; font-weight: 700;
  box-shadow: 0 6px 20px rgba(var(--accent1-rgb), 0.35);
  transition: transform 0.12s, box-shadow 0.12s, opacity 0.12s;
}
.btn-primary:hover  { transform: translateY(-1px); box-shadow: 0 8px 26px rgba(var(--accent1-rgb), 0.5); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

.alert {
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  font-size: 13.5px; font-weight: 500;
  margin-bottom: 18px;
  border: 1px solid transparent;
}
.alert.err  { background: rgba(255,71,111,0.12); border-color: rgba(255,71,111,0.35); color: #ffb3c4; }
.alert.info { background: rgba(var(--accent2-rgb), 0.10); border-color: rgba(var(--accent2-rgb), 0.28); color: #a9ecff; }

.page-foot {
  margin-top: 22px; text-align: center;
  font-size: 12px; color: var(--text-mute);
}

/* ── Bandeau « qui suis-je » dans la colonne des comptes ─────────── */
.me-bar {
  flex-shrink: 0;
  border-top: 1px solid var(--line);
  padding: 12px 14px;
  display: flex; flex-direction: column; gap: 8px;
}
.me-who { display: flex; align-items: center; gap: 8px; min-width: 0; }
.me-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--green); flex-shrink: 0;
  box-shadow: 0 0 8px rgba(46, 231, 124, 0.7);
}
.me-name {
  font-size: 13px; font-weight: 600; color: var(--text-soft);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.me-links { display: flex; gap: 12px; }
.me-link {
  font-size: 12px; color: var(--text-mute);
  text-decoration: none; font-weight: 600;
}
.me-link:hover { color: var(--cyan); }

/* En mode colonne etroite (900px), app.css masque les libelles :
   on masque aussi les notres pour rester coherent. */
@media (max-width: 900px) and (min-width: 821px) {
  .me-bar .me-name, .me-bar .me-links { display: none; }
}

/* ── Etat « aucun compte » ───────────────────────────────────────── */
.first-run { padding: 46px 26px !important; }
.first-run-icon  { font-size: 34px; margin-bottom: 12px; }
.first-run-title { font-size: 15px; font-weight: 700; color: var(--text-soft); margin: 0 0 6px; }
.first-run-sub   { font-size: 13.5px; line-height: 1.5; margin: 0 0 10px; }
.first-run-hint  { font-size: 12px; color: var(--text-mute); margin: 0; display: none; }
@media (max-width: 820px) { .first-run-hint { display: block; } }

/* ── Administration ──────────────────────────────────────────────── */
.admin-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; flex-wrap: wrap; margin-bottom: 22px;
}
.admin-head h1 { font-size: 20px; font-weight: 700; margin: 0; letter-spacing: -0.02em; }
.admin-head .sub { font-size: 13px; color: var(--text-mute); margin-top: 3px; }

.u-table { width: 100%; border-collapse: collapse; }
.u-table th {
  text-align: left; font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--text-mute);
  padding: 0 10px 10px; font-weight: 700;
}
.u-table td {
  padding: 12px 10px;
  border-top: 1px solid var(--line);
  font-size: 14px; vertical-align: middle;
}
.u-name { font-weight: 600; display: flex; align-items: center; gap: 8px; }
.tag {
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.04em;
  padding: 3px 7px; border-radius: 999px; text-transform: uppercase;
}
.tag.admin { background: rgba(var(--accent1-rgb), 0.22); color: #d3b4ff; }
.tag.off   { background: rgba(255,71,111,0.16); color: #ffa9bd; }
.u-meta { font-size: 12px; color: var(--text-mute); }
.u-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }

.btn-s {
  padding: 7px 11px; border-radius: 9px;
  background: var(--bg-input); border: 1px solid var(--line-strong);
  color: var(--text-soft); font-size: 12.5px; font-weight: 600;
}
.btn-s:hover  { background: var(--bg-card-hover); color: var(--text); }
.btn-s.danger { color: #ffa9bd; border-color: rgba(255,71,111,0.3); }
.btn-s.danger:hover { background: rgba(255,71,111,0.14); }

.new-user {
  display: flex; gap: 10px; margin-bottom: 22px; flex-wrap: wrap;
}
.new-user input {
  flex: 1; min-width: 180px;
  padding: 12px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--bg-input);
  color: var(--text); font-size: 16px; font-weight: 500;
}
.new-user button { width: auto; padding: 12px 20px; }

/* Encart du mot de passe genere — visible une seule fois */
.cred {
  margin-bottom: 20px; padding: 16px 18px;
  border-radius: var(--radius);
  background: rgba(var(--accent2-rgb), 0.08);
  border: 1px solid rgba(var(--accent2-rgb), 0.3);
}
.cred h4 { margin: 0 0 4px; font-size: 14px; font-weight: 700; color: #a9ecff; }
.cred .warn { margin: 0 0 12px; font-size: 12.5px; color: var(--text-soft); }
.cred-box {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: rgba(8, 10, 22, 0.6);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.cred-box code {
  font-family: 'Consolas', 'SFMono-Regular', monospace;
  font-size: 15px; font-weight: 600; color: var(--text);
  letter-spacing: 0.04em; word-break: break-all;
}
.cred-box .lbl { font-size: 11px; color: var(--text-mute); text-transform: uppercase; letter-spacing: 0.05em; }
.cred-row { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 130px; }

@media (max-width: 620px) {
  .card { padding: 26px 20px; border-radius: 16px; }
  .u-table thead { display: none; }
  .u-table td { display: block; border-top: 0; padding: 3px 0; }
  .u-table tr {
    display: block; padding: 14px 0;
    border-top: 1px solid var(--line);
  }
  .u-actions { justify-content: flex-start; margin-top: 10px; }
}

/* ── Repli <dialog> pour les navigateurs qui ne gerent pas showModal ── */
dialog.poly-open {
  display: block;
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  z-index: 200;
  margin: 0;
}
body.poly-lock::before {
  content: ""; position: fixed; inset: 0;
  background: rgba(var(--ombre), 0.6); backdrop-filter: blur(8px);
  z-index: 199;
}
/* Message d'erreur de la fenetre : bien visible, jamais tronque */
#add-error {
  margin-top: 12px; font-size: 13px; line-height: 1.45;
  color: #ffb3c4; word-wrap: break-word;
}

/* ── Bandeau « Installer l'application » ─────────────────────────── */
.pwa-banner {
  position: fixed;
  left: 12px; right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  z-index: 300;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(20, 22, 38, 0.94);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-deep);
  animation: pwa-monte 0.35s cubic-bezier(0.2, 0.9, 0.3, 1);
}
@keyframes pwa-monte {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: none; }
}
.pwa-ico {
  width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0;
}
.pwa-txt {
  flex: 1; min-width: 0;
  font-size: 13px; line-height: 1.45; color: var(--text-soft);
}
.pwa-txt b { color: var(--text); font-weight: 700; }
.pwa-share {
  display: inline-flex; vertical-align: -3px;
  color: var(--cyan); margin: 0 1px;
}
.pwa-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.pwa-go {
  padding: 9px 15px; border-radius: 10px;
  background: var(--gradient); color: #fff;
  font-size: 13px; font-weight: 700; white-space: nowrap;
  box-shadow: 0 4px 14px rgba(var(--accent1-rgb), 0.35);
}
.pwa-no {
  width: 30px; height: 30px; border-radius: 8px;
  background: transparent; color: var(--text-mute);
  font-size: 15px; line-height: 1;
}
.pwa-no:hover { background: var(--bg-input); color: var(--text); }

/* Sur grand ecran, le bandeau se pose en bas a droite */
@media (min-width: 821px) {
  .pwa-banner { left: auto; right: 20px; bottom: 20px; max-width: 400px; }
}

/* ── Bouton cloche (notifications) ───────────────────────────────── */
#btn-notifs {
  width: 30px; height: 30px; border-radius: 9px;
  display: grid; place-items: center; flex-shrink: 0;
  background: transparent; color: var(--text-mute);
  transition: color 0.15s, background 0.15s;
}
#btn-notifs:hover { background: var(--bg-input); color: var(--text-soft); }
#btn-notifs.on { color: var(--green); }
#btn-notifs:disabled { opacity: 0.4; }
.col-hdr-row { gap: 6px; }

/* ── Bouton sonnerie ─────────────────────────────────────────────── */
#btn-son {
  width: 30px; height: 30px; border-radius: 9px;
  display: grid; place-items: center; flex-shrink: 0;
  background: transparent; color: var(--cyan);
  transition: color 0.15s, background 0.15s;
}
#btn-son:hover { background: var(--bg-input); }
#btn-son.off { color: var(--text-mute); }

/* ── Réglage du volume de la sonnerie ────────────────────────────── */
.vol-pop {
  position: fixed;
  z-index: 400;
  width: 232px;
  padding: 14px 16px 12px;
  border-radius: 14px;
  background: rgba(20, 22, 38, 0.97);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-deep);
  animation: vol-apparait 0.16s ease-out;
}
@keyframes vol-apparait {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: none; }
}
.vol-titre {
  font-size: 11px; font-weight: 700; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--text-mute);
  margin-bottom: 12px;
}
.vol-ligne { display: flex; align-items: center; gap: 11px; }
.vol-val {
  font-size: 13px; font-weight: 700; color: var(--text);
  min-width: 42px; text-align: right; font-variant-numeric: tabular-nums;
}
.vol-note {
  margin-top: 10px; font-size: 11px; color: var(--text-mute); line-height: 1.4;
}

.vol-range {
  flex: 1; height: 4px; padding: 0;
  -webkit-appearance: none; appearance: none;
  background: rgba(var(--voile), 0.14);
  border-radius: 999px; outline: none;
}
.vol-range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--gradient);
  box-shadow: 0 2px 8px rgba(var(--accent1-rgb), 0.5);
  cursor: pointer; border: 0;
}
.vol-range::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--purple); border: 0; cursor: pointer;
  box-shadow: 0 2px 8px rgba(var(--accent1-rgb), 0.5);
}
/* Sur téléphone, une cible plus grosse pour le doigt */
@media (max-width: 820px) {
  .vol-pop { width: min(280px, calc(100vw - 24px)); padding: 16px 18px 14px; }
  .vol-range { height: 6px; }
  .vol-range::-webkit-slider-thumb { width: 22px; height: 22px; }
  .vol-range::-moz-range-thumb { width: 22px; height: 22px; }
}

/* ═══════ Vocaux dans les conversations MSP ═══════════════════════ */

/* Bouton micro, à gauche du bouton d'envoi */
#btn-vocal {
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center; flex-shrink: 0;
  background: var(--bg-input); color: var(--text-soft);
  border: 1px solid var(--line-strong);
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
#btn-vocal:hover { background: var(--bg-card-hover); color: var(--text); }
#btn-vocal.inactif { opacity: 0.35; }
#btn-vocal.envoi   { opacity: 0.5; }
#btn-vocal.rec {
  background: linear-gradient(135deg, #ff4d8a, #ff8a5c);
  border-color: transparent; color: #fff;
  animation: vc-pulse 1.4s ease-in-out infinite;
}
@keyframes vc-pulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(255, 77, 138, 0.18); }
  50%      { box-shadow: 0 0 0 10px rgba(255, 77, 138, 0.04); }
}

/* Barre d'enregistrement, à la place du champ de saisie */
#vc-barre {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 12px;
  padding: 11px 15px; border-radius: var(--radius);
  background: rgba(255, 77, 138, 0.10);
  border: 1px solid rgba(255, 77, 138, 0.3);
}
.vc-point {
  width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0;
  background: var(--red); animation: vc-clignote 1s infinite;
}
@keyframes vc-clignote { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }
#vc-chrono {
  font-size: 13.5px; font-weight: 700; color: var(--text);
  font-variant-numeric: tabular-nums; flex-shrink: 0;
}
.vc-ondes { flex: 1; display: flex; align-items: center; gap: 3px; height: 20px; }
.vc-ondes i {
  flex: 1; max-width: 3px; border-radius: 2px;
  background: rgba(255, 77, 138, 0.75);
  animation: vc-danse 1s ease-in-out infinite;
}
.vc-ondes i:nth-child(2) { animation-delay: 0.12s; }
.vc-ondes i:nth-child(3) { animation-delay: 0.24s; }
.vc-ondes i:nth-child(4) { animation-delay: 0.36s; }
.vc-ondes i:nth-child(5) { animation-delay: 0.10s; }
.vc-ondes i:nth-child(6) { animation-delay: 0.30s; }
.vc-ondes i:nth-child(7) { animation-delay: 0.18s; }
@keyframes vc-danse { 0%, 100% { height: 5px; } 50% { height: 18px; } }
#vc-annuler {
  background: transparent; color: var(--text-mute);
  font-size: 15px; padding: 0 2px; flex-shrink: 0;
}
#vc-annuler:hover { color: var(--red); }

/* La bulle qui porte un vocal */
.msg.msg-vocal .body {
  display: flex; align-items: center; gap: 10px; min-width: 170px;
}
.vc-play {
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center; flex-shrink: 0;
  background: rgba(var(--sur-accent), 0.2); color: inherit;
}
.msg.them .vc-play { background: rgba(var(--voile), 0.1); }
.vc-play:hover { background: rgba(var(--sur-accent), 0.32); }
.msg-vocal.joue .vc-play { background: rgba(var(--sur-accent), 0.42); }
.vc-onde {
  flex: 1; min-width: 60px; height: 4px; border-radius: 999px;
  background: rgba(var(--sur-accent), 0.24); overflow: hidden; display: block;
}
.msg.them .vc-onde { background: rgba(var(--voile), 0.13); }
.vc-prog {
  display: block; height: 100%; width: 0;
  background: currentColor; transition: width 0.1s linear;
}
.vc-duree {
  font-size: 12px; font-weight: 600; opacity: 0.9;
  font-variant-numeric: tabular-nums; flex-shrink: 0;
}

@media (max-width: 820px) {
  #btn-vocal { width: 46px; height: 46px; }
}

/* ── Logo de l'application (remplace l'ancien carré au « M ») ─────── */
img.brand-logo, img.logo-mark {
  object-fit: cover;
  background: none;          /* l'image porte déjà son dégradé */
  padding: 0;
  display: block;
  flex-shrink: 0;
}
img.logo-mark {
  width: 46px; height: 46px; border-radius: 13px;
  box-shadow: 0 6px 20px rgba(var(--accent1-rgb), 0.4);
}
img.brand-logo { width: 32px; height: 32px; border-radius: 9px; }

/* ── Bouton photo, à côté du micro ───────────────────────────────── */
#btn-photo {
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center; flex-shrink: 0;
  background: var(--bg-input); color: var(--text-soft);
  border: 1px solid var(--line-strong);
  transition: background 0.15s, color 0.15s, opacity 0.15s;
}
#btn-photo:hover { background: var(--bg-card-hover); color: var(--text); }
#btn-photo.inactif { opacity: 0.35; }
#btn-photo.envoi { opacity: 0.5; animation: ph-attente 1s ease-in-out infinite; }
@keyframes ph-attente { 0%, 100% { opacity: 0.5; } 50% { opacity: 0.8; } }

/* ── Bulle photo ─────────────────────────────────────────────────── */
.msg.msg-photo { padding: 5px; max-width: min(320px, 72%); }
.msg.msg-photo .body { display: block; }
.ph-img {
  display: block; width: 100%; height: auto;
  max-height: 340px; object-fit: cover;
  border-radius: 13px; cursor: zoom-in;
  background: rgba(var(--voile), 0.06);
}
.msg.msg-photo .ts { padding: 0 6px 3px; }

/* ── Photo en plein écran ────────────────────────────────────────── */
.ph-plein {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(var(--ombre), 0.92);
  display: grid; place-items: center;
  padding: 24px; cursor: zoom-out;
  animation: ph-ouvre 0.15s ease-out;
}
@keyframes ph-ouvre { from { opacity: 0; } to { opacity: 1; } }
.ph-plein img {
  max-width: 100%; max-height: 100%;
  border-radius: 8px; box-shadow: var(--shadow-deep);
}
.ph-fermer {
  position: absolute;
  top: calc(16px + env(safe-area-inset-top)); right: 16px;
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(var(--sur-accent), 0.14); color: #fff;
  font-size: 17px; line-height: 1;
}
.ph-fermer:hover { background: rgba(var(--sur-accent), 0.26); }

@media (max-width: 820px) {
  #btn-photo { width: 46px; height: 46px; }
  .msg.msg-photo { max-width: 78%; }
  #composer { gap: 8px; }
}

/* ═══════ Composeur : mise à l'échelle de la rangée du bas ═══════════ */

/* Pendant l'enregistrement, la barre rouge occupe seule la largeur.
   Piloté par une classe : déterministe, rien ne peut le contredire. */
#composer.enregistre #composer-text,
#composer.enregistre #btn-photo,
#composer.enregistre #btn-send { display: none !important; }
#composer:not(.enregistre) #vc-barre { display: none !important; }
#composer.enregistre #vc-barre { display: flex !important; }

/* Rien à envoyer tant que le champ est vide : on récupère la place. */
#composer.vide:not(.enregistre) #btn-send { display: none; }

/* Le champ doit pouvoir rétrécir, sinon il pousse les boutons hors écran
   et son propre texte se coupe. */
#composer-text { min-width: 0; }

@media (max-width: 820px) {
  #composer {
    gap: 8px;
    padding: 10px 12px calc(12px + env(safe-area-inset-bottom));
    align-items: center;
  }
  #composer-text {
    padding: 10px 14px;
    font-size: 16px;          /* anti-zoom iOS : à ne pas baisser */
    max-height: 96px;
  }
  /* Trois ronds de 46 px ne tiennent pas à côté d'un champ lisible. */
  #btn-photo, #btn-vocal, #btn-send { width: 42px; height: 42px; }
  #btn-photo svg, #btn-vocal svg { width: 18px; height: 18px; }

  /* Barre d'enregistrement : compacte, mais le chrono reste lisible. */
  #vc-barre { padding: 9px 12px; gap: 9px; }
  .vc-ondes { min-width: 40px; }
}

/* Écrans très étroits : on sacrifie les ondes animées, pas les boutons. */
@media (max-width: 380px) {
  #composer { gap: 6px; padding-left: 10px; padding-right: 10px; }
  #btn-photo, #btn-vocal, #btn-send { width: 40px; height: 40px; }
  .vc-ondes { display: none; }
}

/* Bulle photo : cadre plus fin, l'image doit primer sur le contour. */
.msg.msg-photo { padding: 3px; }
.msg.msg-photo .ph-img { border-radius: 15px; }
.msg.msg-photo .ts { padding: 1px 7px 2px; }

/* ═══════════════ Page des paramètres ════════════════════════════════ */
.param-bloc { margin-top: 8px; }
.param-titre {
  font-size: 12px; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--text-mute);
  margin: 0 0 6px;
}
.param-aide {
  font-size: 13px; color: var(--text-mute); line-height: 1.5;
  margin: 0 0 18px;
}

.theme-grille {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
}
.theme-carte {
  display: flex; flex-direction: column; align-items: stretch; gap: 8px;
  padding: 10px; border-radius: var(--radius);
  background: var(--bg-input);
  border: 1.5px solid var(--line-strong);
  text-align: left; cursor: pointer;
  transition: border-color 0.15s, transform 0.12s, background 0.15s;
}
.theme-carte:hover { background: var(--bg-card-hover); transform: translateY(-1px); }
.theme-carte.choisi {
  border-color: var(--accent1);
  background: var(--gradient-soft);
}
.theme-carte.verrouille { opacity: 0.6; cursor: not-allowed; }
.theme-carte.verrouille:hover { transform: none; }

.theme-apercu {
  display: grid; place-items: center;
  height: 58px; border-radius: var(--radius-sm);
  box-shadow: inset 0 0 0 1px rgba(var(--voile), 0.10);
}
.theme-cadenas { font-size: 19px; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5)); }
.theme-nom { font-size: 13.5px; font-weight: 700; color: var(--text); }
.theme-note {
  font-size: 11px; color: var(--text-mute); line-height: 1.35;
  margin-top: -4px;
}
.theme-carte.choisi .theme-nom::after {
  content: " ✓"; color: var(--accent1); font-weight: 800;
}

@media (max-width: 620px) {
  .theme-grille { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
  .theme-apercu { height: 48px; }
}
.tag.vip { background: rgba(255, 215, 94, 0.20); color: #ffd75e; }
.tag.testeur { background: rgba(24, 216, 255, 0.18); color: #8ef0ff; }
.sel-statut {
  padding: 6px 9px; border-radius: 9px;
  background: var(--bg-input); border: 1px solid var(--line-strong);
  color: var(--text-soft); font-size: 12.5px; font-weight: 600;
  font-family: inherit; cursor: pointer;
}
.sel-statut:hover { color: var(--text); }

/* ── Paramètres : lignes, choix, listes ──────────────────────────── */
.param-ligne {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  padding: 14px 0; border-top: 1px solid var(--line);
}
.param-ligne:first-of-type { border-top: 0; }
.param-libelle { flex: 1; min-width: 190px; }
.param-nom { font-size: 14px; font-weight: 600; color: var(--text); }
.param-detail { font-size: 12.5px; color: var(--text-mute); margin-top: 3px; line-height: 1.45; }

.choix { display: flex; gap: 4px; padding: 3px; border-radius: 11px;
         background: var(--bg-input); border: 1px solid var(--line-strong); }
.choix button {
  padding: 7px 13px; border-radius: 8px; background: transparent;
  color: var(--text-mute); font-size: 12.5px; font-weight: 600;
}
.choix button:hover { color: var(--text); }
.choix button.actif { background: var(--gradient); color: #fff; }

.param-liste { display: flex; flex-direction: column; gap: 8px; }
.param-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--bg-input); border: 1px solid var(--line-strong);
}
.param-item-corps { min-width: 0; }
.param-vide { font-size: 13px; color: var(--text-mute); padding: 6px 0; }

/* ── Mes profils (switcher) ──────────────────────────────────────── */
.profil-item { justify-content: flex-start; gap: 12px; transition: border-color .15s; }
.profil-item:hover { border-color: var(--line); }
.profil-item.actif { border-color: var(--accent1); background: var(--gradient-soft); }
.profil-av {
  width: 42px; height: 42px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center;
  font-size: 17px; font-weight: 800; color: var(--text);
  background-color: var(--bg-card-hover);
  background-size: cover; background-position: center;
}
.profil-actif-tag { margin-left: auto; color: var(--accent1); font-weight: 800; font-size: 17px; }

.param-form { max-width: 340px; }
.param-form .field { margin-bottom: 12px; }
.param-bloc + .param-bloc { margin-top: 26px; padding-top: 22px; border-top: 1px solid var(--line); }

/* ── Sourdine ────────────────────────────────────────────────────── */
#btn-muet {
  width: 30px; height: 30px; border-radius: 9px;
  display: grid; place-items: center; flex-shrink: 0;
  background: transparent; color: var(--text-mute);
  transition: color 0.15s, background 0.15s;
}
#btn-muet:hover { background: var(--bg-input); color: var(--text-soft); }
#btn-muet.muet { color: var(--accent1); }
.convo-item.en-sourdine .convo-name::after {
  content: " 🔕"; font-size: 10px; opacity: 0.65;
}
.convo-item.en-sourdine .convo-badge { opacity: 0.45; }

/* ── Résultats de recherche dans les messages ────────────────────── */
#rech-res {
  flex-shrink: 0; max-height: 46%; overflow-y: auto;
  padding: 4px 8px 10px; border-bottom: 1px solid var(--line);
}
.rech-titre {
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--text-mute);
  padding: 10px 6px 8px;
}
.rech-vide { font-size: 12.5px; color: var(--text-mute); padding: 2px 6px 8px; }
.rech-item {
  padding: 9px 10px; margin-bottom: 3px;
  border-radius: var(--radius-sm); cursor: pointer;
  transition: background 0.12s;
}
.rech-item:hover { background: var(--bg-card-hover); }
.rech-haut { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 3px; }
.rech-qui { font-size: 12.5px; font-weight: 700; color: var(--text-soft); }
.rech-quand { font-size: 10.5px; color: var(--text-mute); flex-shrink: 0; }
.rech-txt { font-size: 12.5px; color: var(--text-mute); line-height: 1.4; }
.rech-txt mark {
  background: rgba(var(--accent2-rgb), 0.28); color: var(--text);
  border-radius: 3px; padding: 0 1px;
}

/* ── Enregistrer une photo ───────────────────────────────────────── */
.ph-garder {
  position: absolute;
  bottom: calc(22px + env(safe-area-inset-bottom));
  left: 50%; transform: translateX(-50%);
  padding: 11px 22px; border-radius: 999px;
  background: rgba(var(--sur-accent), 0.16); color: #fff;
  font-size: 14px; font-weight: 600;
  backdrop-filter: blur(10px);
}
.ph-garder:hover { background: rgba(var(--sur-accent), 0.28); }
.ph-garder:disabled { opacity: 0.6; }

/* ── Photo de profil dans les paramètres ─────────────────────────── */
.avatar-zone { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.avatar-apercu {
  width: 76px; height: 76px; border-radius: 50%;
  background: var(--gradient); color: #fff;
  display: grid; place-items: center;
  font-size: 28px; font-weight: 800;
  background-size: cover; background-position: center;
  flex-shrink: 0; border: 2px solid var(--line-strong);
}
.avatar-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Choix du fond, par conversation ─────────────────────────────── */
#btn-fond {
  width: 30px; height: 30px; border-radius: 9px;
  display: grid; place-items: center; flex-shrink: 0;
  background: transparent; color: var(--text-mute);
  transition: color 0.15s, background 0.15s;
}
#btn-fond:hover { background: var(--bg-input); color: var(--text-soft); }

.fond-pop {
  position: fixed; z-index: 400; width: 210px;
  padding: 12px; border-radius: 14px;
  background: var(--bg-card); backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line-strong); box-shadow: var(--shadow-deep);
  animation: fond-apparait 0.16s ease-out;
}
@keyframes fond-apparait {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: none; }
}
.fond-titre {
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--text-mute); margin-bottom: 10px;
}
.fond-liste { display: flex; flex-direction: column; gap: 3px; }
.fond-choix {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 8px; border-radius: 9px;
  background: transparent; color: var(--text-soft);
  font-size: 13px; font-weight: 600; text-align: left;
}
.fond-choix:hover { background: var(--bg-card-hover); color: var(--text); }
.fond-choix.actif { background: var(--gradient-soft); color: var(--text); }
.fond-choix.actif::after { content: "✓"; margin-left: auto; color: var(--accent1); }

/* Aperçus miniatures : les mêmes motifs, en petit */
.fond-vignette {
  width: 30px; height: 22px; border-radius: 5px; flex-shrink: 0;
  background-color: var(--bg-input);
  border: 1px solid var(--line-strong);
}
.fond-vignette[data-f="trame"] {
  background-image:
    linear-gradient(rgba(var(--voile), 0.22) 1px, transparent 1px),
    linear-gradient(90deg, rgba(var(--voile), 0.22) 1px, transparent 1px);
  background-size: 6px 6px;
}
.fond-vignette[data-f="bulles"] {
  background-image:
    radial-gradient(circle at 30% 35%, rgba(var(--accent1-rgb), 0.5) 0 3px, transparent 4px),
    radial-gradient(circle at 70% 70%, rgba(var(--accent2-rgb), 0.45) 0 4px, transparent 5px);
}
.fond-vignette[data-f="degrade"] {
  background-image: linear-gradient(160deg,
    rgba(var(--accent1-rgb), 0.5), transparent 55%, rgba(var(--accent2-rgb), 0.45));
}
.fond-vignette[data-f="ardoise"] {
  background-image: repeating-linear-gradient(45deg,
    rgba(var(--voile), 0.2) 0 2px, transparent 2px 5px);
}
.fond-vignette[data-f="papier"] {
  background-image: repeating-linear-gradient(0deg,
    rgba(var(--voile), 0.25) 0 1px, transparent 1px 5px);
}
.fond-vignette-img {
  background-size: cover; background-position: center;
  box-shadow: inset 0 0 0 1.5px rgba(255,205,90,.7);
}

/* Actions VIP (photo perso) sous la liste de fonds */
.fond-actions-vip {
  margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 6px;
}
.fond-up, .fond-del {
  width: 100%; padding: 8px 10px; border-radius: 9px; font-size: 12.5px;
  font-weight: 700; text-align: center;
}
.fond-up {
  background: linear-gradient(135deg, rgba(255,215,120,.22), rgba(255,180,60,.14));
  color: #d9a441; border: 1px solid rgba(255,205,90,.5);
}
.fond-del { background: var(--bg-input); color: var(--text-mute); }
.fond-del:hover { color: #e5484d; }

/* ═══════════════ Bandeau d'observation ══════════════════════════════
   Volontairement voyant : on ne doit jamais oublier qu'on regarde le
   compte de quelqu'un d'autre.
==================================================================== */
#obs-bandeau {
  position: fixed; top: 0; left: 0; right: 0; z-index: 600;
  height: 46px; padding: 0 14px;
  padding-top: env(safe-area-inset-top);
  height: calc(46px + env(safe-area-inset-top));
  display: flex; align-items: center; gap: 10px;
  background: linear-gradient(90deg, #b45309, #d97706);
  color: #fff; font-size: 13px; font-weight: 600;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
}
.obs-oeil { font-size: 16px; flex-shrink: 0; }
.obs-txt {
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.obs-txt b { font-weight: 800; }
#obs-fin {
  flex-shrink: 0; padding: 7px 13px; border-radius: 9px;
  background: rgba(255, 255, 255, 0.22); color: #fff;
  font-size: 12.5px; font-weight: 700; white-space: nowrap;
}
#obs-fin:hover { background: rgba(255, 255, 255, 0.34); }
#obs-fin:disabled { opacity: 0.6; }

/* On décale l'application sous le bandeau */
body.observe #app {
  margin-top: calc(46px + env(safe-area-inset-top));
  height: calc(100vh - 46px - env(safe-area-inset-top));
}
@supports (height: 100dvh) {
  body.observe #app { height: calc(100dvh - 46px - env(safe-area-inset-top)); }
}
body.observe .page-wrap { padding-top: calc(70px + env(safe-area-inset-top)); }

@media (max-width: 620px) {
  .obs-txt { font-size: 12px; }
  #obs-fin { padding: 6px 10px; font-size: 11.5px; }
}

/* ═══════════════ Barre de navigation (Fil / Messages / Profil) ══════ */
#barre-nav {
  position: fixed; z-index: 90;
  display: flex;
  background: var(--bg-card);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.nav-onglet {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 8px 0; text-decoration: none;
  color: var(--text-mute); font-size: 10.5px; font-weight: 600;
  transition: color 0.15s;
}
.nav-onglet:hover { color: var(--text-soft); }
.nav-onglet.actif { color: var(--accent1); }
.nav-ico { position: relative; display: grid; place-items: center; }
.nav-nom { line-height: 1; }
.nav-pastille {
  position: absolute; top: -4px; right: -7px;
  min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 999px; background: var(--red); color: #fff;
  font-size: 10px; font-weight: 800; line-height: 16px; text-align: center;
  box-shadow: 0 0 0 2px var(--bg-card);
}

/* Téléphone : barre fixe en bas */
@media (max-width: 820px) {
  #barre-nav {
    left: 0; right: 0; bottom: 0;
    border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
  }
  body.avec-nav #app,
  body.avec-nav #fil-page,
  body.avec-nav .page-wrap {
    padding-bottom: calc(62px + env(safe-area-inset-bottom));
  }
  /* La messagerie gère sa propre hauteur : on la raccourcit d'autant. */
  body.avec-nav #app {
    height: calc(100dvh - 62px - env(safe-area-inset-bottom));
    padding-bottom: 0;
  }
  /* Conversation ouverte (mobile) : on cache la barre de nav — comme les groupes
     la cachent déjà — et le fil de discussion prend toute la hauteur. */
  #app.m-thread ~ #barre-nav { display: none !important; }
  body.avec-nav #app.m-thread { height: 100dvh; }
}

/* Grand écran : rail vertical à gauche */
@media (min-width: 821px) {
  #barre-nav {
    top: 0; left: 0; bottom: 0; width: 78px;
    flex-direction: column; justify-content: flex-start; gap: 6px;
    padding: 18px 0; border-right: 1px solid var(--line);
  }
  .nav-onglet { flex: 0 0 auto; padding: 12px 0; font-size: 11px; }
  body.avec-nav #app { margin-left: 78px; width: calc(100vw - 78px); }
  body.avec-nav #fil-page { padding-left: 78px; box-sizing: border-box; }
  body.avec-nav .page-wrap { padding-left: 78px; }
  /* En observation, le bandeau passe au-dessus du rail */
  body.observe #barre-nav { top: calc(46px + env(safe-area-inset-top)); }
}

/* ── Paramètres : sections repliables (accordéon) ────────────────── */
.param-acc {
  border: 1px solid var(--line-strong); border-radius: 14px;
  background: var(--bg-input); margin-bottom: 12px; overflow: hidden;
}
.param-acc-tete {
  list-style: none; cursor: pointer; user-select: none;
  padding: 15px 16px; font-size: 15px; font-weight: 700; color: var(--text);
  display: flex; align-items: center; gap: 10px;
}
.param-acc-tete::-webkit-details-marker { display: none; }
.param-acc-tete::after {
  content: '⌄'; margin-left: auto; font-size: 18px; color: var(--text-mute);
  transition: transform 0.2s; line-height: 1;
}
.param-acc[open] > .param-acc-tete::after { transform: rotate(180deg); }
.param-acc[open] > .param-acc-tete { border-bottom: 1px solid var(--line); }
.param-acc-tete:hover { background: var(--bg-card-hover); }
.param-acc-corps { padding: 8px 16px 16px; }
.param-acc-corps .param-bloc { margin: 0; }
.param-acc-corps .param-bloc + .param-bloc {
  margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line);
}

/* Interrupteurs (notifications / confidentialité) */
.reg-liste { display: flex; flex-direction: column; }
.reg-ligne { display: flex; align-items: center; gap: 14px; padding: 11px 2px; cursor: pointer; }
.reg-ligne + .reg-ligne { border-top: 1px solid var(--line); }
.reg-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.reg-txt b { font-size: 14px; font-weight: 600; color: var(--text); }
.reg-txt small { font-size: 12.5px; color: var(--text-mute); line-height: 1.4; }
.reg-toggle {
  appearance: none; -webkit-appearance: none; flex-shrink: 0;
  width: 46px; height: 28px; border-radius: 999px; cursor: pointer;
  background: var(--bg-card-hover); border: 1px solid var(--line-strong);
  position: relative; transition: background 0.18s, border-color 0.18s;
}
.reg-toggle::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 22px; height: 22px; border-radius: 50%; background: #fff;
  transition: transform 0.18s; box-shadow: 0 1px 3px rgba(0,0,0,.35);
}
.reg-toggle:checked { background: var(--gradient); border-color: transparent; }
.reg-toggle:checked::after { transform: translateX(18px); }

/* ═══════════════ Carte VIP (paramètres) ═══════════════════════════ */
#vip-carte {
  position: relative; overflow: hidden;
  display: flex; align-items: center; gap: 14px; width: 100%;
  margin: 4px 0 18px; padding: 15px 16px; border-radius: 16px;
  text-align: left; cursor: pointer;
  color: #3a2a05;
  background: linear-gradient(135deg, #ffe9a8 0%, #f7c860 45%, #e8a93c 100%);
  border: 1px solid rgba(180,130,20,.5);
  box-shadow: 0 8px 24px -8px rgba(230,170,60,.65);
}
#vip-carte:hover { transform: translateY(-1px); box-shadow: 0 12px 30px -8px rgba(230,170,60,.8); }
#vip-carte:active { transform: translateY(0); }
.vip-sheen {
  position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(115deg, transparent 35%, rgba(255,255,255,.65) 50%, transparent 65%);
  transform: translateX(-120%);
  animation: vip-sheen 4.5s ease-in-out infinite;
}
@keyframes vip-sheen {
  0%, 60% { transform: translateX(-120%); }
  85%, 100% { transform: translateX(120%); }
}
@media (prefers-reduced-motion: reduce) { .vip-sheen { animation: none; opacity: 0; } }
.vip-crown { font-size: 30px; flex-shrink: 0; filter: drop-shadow(0 2px 3px rgba(120,80,0,.4)); }
.vip-textes { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.vip-titre { font-size: 16px; font-weight: 800; letter-spacing: -.01em; }
.vip-sous { font-size: 12.5px; font-weight: 600; opacity: .8; }
.vip-fleche { font-size: 26px; font-weight: 700; opacity: .55; flex-shrink: 0; }

/* Modale des avantages */
#dlg-vip {
  border: none; border-radius: 20px; padding: 0; width: min(460px, calc(100vw - 24px));
  max-height: 88vh; overflow: hidden; color: var(--text);
  background: var(--bg-card); box-shadow: var(--shadow-deep);
}
#dlg-vip::backdrop { background: rgba(0,0,0,.6); backdrop-filter: blur(3px); }
.vip-modal-tete {
  display: flex; align-items: center; gap: 12px; padding: 18px 18px 16px;
  background: linear-gradient(135deg, #ffe9a8 0%, #f2be55 55%, #e0a038 100%);
  color: #3a2a05;
}
.vip-modal-crown { font-size: 32px; flex-shrink: 0; }
.vip-modal-tete h3 { margin: 0; font-size: 19px; font-weight: 800; }
.vip-modal-tete p { margin: 2px 0 0; font-size: 12.5px; font-weight: 600; opacity: .8; }
.vip-modal-tete .ghost { margin-left: auto; flex-shrink: 0; color: #3a2a05; font-weight: 700; }
.vip-perks { padding: 8px 16px 14px; overflow-y: auto; max-height: calc(88vh - 150px); }
.vip-perk-grp {
  font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
  color: var(--accent1); margin: 16px 0 8px;
}
.vip-perk-grp:first-child { margin-top: 6px; }
.vip-perk { display: flex; align-items: flex-start; gap: 12px; padding: 8px 0; }
.vip-perk-ic {
  font-size: 18px; flex-shrink: 0; width: 34px; height: 34px; border-radius: 10px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, rgba(255,215,120,.22), rgba(255,180,60,.12));
  box-shadow: inset 0 0 0 1px rgba(255,205,90,.4);
}
.vip-perk div { display: flex; flex-direction: column; min-width: 0; }
.vip-perk b { font-size: 14px; font-weight: 700; }
.vip-perk span { font-size: 12.5px; color: var(--text-soft); line-height: 1.35; }
.vip-modal-pied {
  padding: 14px 18px; font-size: 13px; font-weight: 700; text-align: center;
  color: #2e7d46; background: rgba(46,125,70,.10); border-top: 1px solid var(--line);
}
.vip-acheter {
  display: block; width: calc(100% - 32px); margin: 12px 16px 16px;
  padding: 13px; border-radius: 13px; font-size: 15px; font-weight: 800;
  color: #3a2a05; background: linear-gradient(135deg, #ffe08a, #eeb24a);
  box-shadow: 0 6px 18px -6px rgba(230,170,60,.7);
}
.vip-acheter:disabled { opacity: .7; }

/* ═══════════════ Demande d'accès / écran d'attente ═══════════════ */
.lien-clair { color: var(--accent1); font-weight: 700; text-decoration: none; }
.lien-clair:hover { text-decoration: underline; }
.rejoindre-intro {
  font-size: 13.5px; line-height: 1.5; color: var(--text-soft); margin: 0 0 18px;
}
.rejoindre-sep { border: 0; border-top: 1px solid var(--line); margin: 4px 0 16px; }

.attente-emoji { font-size: 46px; margin-bottom: 8px; }
.attente-titre { font-size: 20px; font-weight: 800; letter-spacing: -0.02em; margin: 0 0 12px; }
.attente-txt { font-size: 14px; line-height: 1.55; color: var(--text-soft); margin: 0 0 18px; }
.attente-etat {
  font-size: 13px; font-weight: 700; color: var(--text-soft);
  background: var(--bg-input); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px; margin-bottom: 18px;
}
.attente-actions { display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
.attente-actions .btn-s { text-align: center; text-decoration: none; padding: 10px; }

/* Compteur public de membres (login / demande d'accès) — ton promotionnel */
.compteur-pub {
  margin: 0 0 18px; padding: 11px 14px; border-radius: 12px; text-align: center;
  font-size: 13.5px; font-weight: 600; color: var(--text);
  background: var(--gradient-soft);
  border: 1px solid rgba(var(--accent1-rgb), .35);
}
.compteur-pub b { font-weight: 800; }
