*{box-sizing:border-box}
:root{
 --navy:#0b1220;--navy2:#132037;--orange:#ff8a00;--bg:#f4f6f9;
 --card:#fff;--line:#e3e8ef;--ink:#172033;--muted:#748095;--green:#22c55e;--red:#dc2626;
 --viewport-height:100vh;
}
html,body{margin:0;min-height:100%;font-family:"DM Sans",Arial,sans-serif;color:var(--ink);background:var(--bg)}
body{font-size:16px}
button,input,textarea{font:inherit}
button{cursor:pointer}
a{text-decoration:none;color:inherit}
.auth-page{min-height:100vh;display:grid;place-items:center;padding:20px;background:linear-gradient(135deg,#eef2f7,#f9fbfd)}
.auth-shell{width:min(100%,430px)}
.auth-card{padding:28px;border:1px solid var(--line);border-radius:22px;background:#fff;box-shadow:0 24px 70px #09101f14}
.brand{display:inline-flex;align-items:center;gap:9px}
.brand-mark{display:grid;place-items:center;width:40px;height:40px;border-radius:12px;color:#fff;background:linear-gradient(135deg,#ff9e24,#f06a00);font-weight:800}
.brand-name{font-size:14px;font-weight:800}.brand-name b{color:var(--orange)}
.eyebrow{display:inline-flex;margin-top:28px;padding:6px 8px;border-radius:999px;background:#fff3e4;color:#a85700;font-size:9px;font-weight:800}
.auth-card h1{margin:12px 0 6px;font:800 25px Manrope}.lead{margin:0 0 22px;color:var(--muted);font-size:14px;line-height:1.5}
.auth-card label{display:block;margin:0 0 7px;font-size:13px;font-weight:800}
.input-wrap{display:flex;align-items:center;gap:9px;height:50px;padding:0 12px;border:1px solid var(--line);border-radius:12px}.input-wrap:focus-within{border-color:#ff8a0070;box-shadow:0 0 0 4px #ff8a0010}.input-wrap i{color:var(--muted)}.input-wrap input{min-width:0;flex:1;border:0;outline:0;font-size:16px}
.help{margin:7px 0 0;color:var(--muted);font-size:11px}.error-box{margin-top:11px;padding:9px;border-radius:10px;color:#b91c1c;background:#fff1f2;font-size:12px;line-height:1.45}
.primary-btn{width:100%;height:50px;margin-top:18px;border:0;border-radius:12px;color:#fff;background:var(--orange);font-size:14px;font-weight:800}.primary-btn:disabled{opacity:.6}
.btn-loading{display:inline-flex;align-items:center;gap:6px}.spin{animation:spin 1s linear infinite}@keyframes spin{to{transform:rotate(360deg)}}
.privacy-box{display:flex;gap:8px;margin-top:15px;padding:11px;border-radius:11px;color:#486070;background:#f3f7fa;font-size:11px;line-height:1.45}.privacy-box i{color:#16a34a}
.admin-link{display:flex;justify-content:center;gap:6px;margin-top:15px;color:#697789;font-size:12px}.admin-link:hover{color:var(--orange)}

.messenger-page{min-height:100vh;background:var(--bg)}
.topbar{position:sticky;top:0;z-index:30;height:64px;display:flex;align-items:center;justify-content:space-between;gap:15px;padding:0 18px;color:#fff;background:linear-gradient(180deg,var(--navy),var(--navy2))}
.topbar .brand-name{color:#fff}.topbar .brand-name b{color:#ffb15a}
.top-actions{display:flex;align-items:center;gap:7px}.online-pill{display:flex;align-items:center;gap:6px;padding:7px 9px;border-radius:999px;background:#ffffff0d;color:#dfe6f0;font-size:11px}.dot{width:7px;height:7px;border-radius:50%;background:var(--green)}
.icon-btn{width:38px;height:38px;display:grid;place-items:center;border:1px solid #ffffff12;border-radius:11px;color:#fff;background:#ffffff08}.icon-btn:hover{background:#ffffff14}
.messenger-shell{display:grid;grid-template-columns:minmax(0,1fr) 300px;max-width:1400px;margin:0 auto;min-height:calc(var(--viewport-height) - 64px)}
.chat-panel{position:relative;min-width:0;display:flex;flex-direction:column;min-height:calc(var(--viewport-height) - 64px);background:#fff;border-right:1px solid var(--line)}
.chat-header{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:14px 16px;border-bottom:1px solid var(--line);background:#fff}
.room-identity{display:flex;align-items:center;gap:10px;min-width:0}.room-header-avatar{width:46px;height:46px;display:grid;place-items:center;overflow:hidden;border-radius:14px;color:var(--orange);background:#fff3e4;font-size:20px;flex:0 0 auto}.room-photo{padding:0}.room-header-avatar img{width:100%;height:100%;object-fit:cover}
.room-title-wrap{min-width:0}.room-title-wrap h1{margin:0;font:800 18px Manrope;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.room-title-wrap p{display:flex;align-items:center;gap:5px;margin:3px 0 0;color:var(--muted);font-size:12px}.live-dot{width:6px;height:6px;border-radius:50%;background:var(--green)}
.room-online-summary{color:var(--muted);font-size:11px;white-space:nowrap}
.room-tabs{display:flex;gap:7px;padding:8px;border-bottom:1px solid var(--line);background:#fff;overflow:auto;scrollbar-width:none}.room-tabs::-webkit-scrollbar{display:none}
.room-tab{flex:1 0 auto;min-width:120px;height:44px;display:flex;align-items:center;justify-content:center;gap:7px;border:1px solid transparent;border-radius:11px;color:var(--muted);background:#f7f8fa;font-size:13px;font-weight:800}.room-tab.active{color:#a45500;background:#fff3e4;border-color:#ff8a0050}.room-tab.locked{opacity:.55}
.room-description{padding:8px 15px;border-bottom:1px solid var(--line);color:var(--muted);font-size:13px;line-height:1.5}.room-description[hidden]{display:none}
.room-media-card{margin:8px 12px 0;border:1px solid var(--line);border-radius:16px;overflow:hidden;background:#fff}.room-media-card[hidden]{display:none}.room-media-card img{display:block;width:100%;max-height:320px;object-fit:cover}.room-media-caption{display:flex;align-items:center;gap:7px;padding:10px 12px;border-top:1px solid var(--line);color:var(--muted);font-size:13px}.room-media-caption i{color:var(--orange)}
.status-banner{display:flex;align-items:center;gap:10px;padding:10px 13px;background:#fff7ed;border-bottom:1px solid #fed7aa;color:#9a4d00;font-size:12px}.status-banner strong{display:block}.status-banner span{display:block;margin-top:2px;font-size:11px}.status-banner[hidden]{display:none}
.messages-wrap{position:relative;flex:1;min-height:200px;overflow:auto;background:#fbfcfe;overscroll-behavior:contain}.messages{padding:16px}.message{display:flex;margin-bottom:20px}.message.other{justify-content:flex-start}.message.mine{justify-content:flex-end}.message-inner{max-width:min(760px,82%)}.message-name{margin:0 0 5px;color:#68758a;font-size:14px;font-weight:800}.mine .message-name{text-align:right}
.message-image{display:block;width:min(520px,82vw);max-width:100%;max-height:520px;object-fit:cover;border:1px solid var(--line);border-radius:15px;background:#fff;cursor:pointer;box-shadow:0 8px 24px #09101f0c}.mine .message-image{border-color:#ffd39a}.message-image-link{display:block;line-height:0}.message-image-link:hover{opacity:.96}.bubble{display:inline-block;padding:12px 15px;border:1px solid var(--line);border-radius:6px 17px 17px 17px;background:#fff;font-size:16px;line-height:1.55;overflow-wrap:anywhere}.mine .bubble{border-color:#ffd39a;background:#fff8ef;border-top-right-radius:6px;border-top-left-radius:17px}
.message-meta{display:flex;align-items:center;justify-content:flex-end;gap:6px;margin-top:5px;color:#8e99aa;font-size:11px}.delete-own{margin-top:3px;border:0;background:none;color:#b91c1c;font-size:11px;padding:0}.delete-own:hover{text-decoration:underline}
.audio-card{display:flex;align-items:center;gap:10px;width:min(430px,82vw);padding:11px;border:1px solid var(--line);border-radius:15px;background:#fff}.audio-play,.voice-play{width:42px;height:42px;display:grid;place-items:center;border:0;border-radius:50%;color:#fff;background:var(--orange);flex:0 0 auto;font-size:17px}.audio-content,.voice-track-wrap{min-width:0;flex:1}.audio-title{display:flex;justify-content:space-between;gap:8px;font-size:12px}.audio-title span{color:var(--muted);font-size:10px}.audio-progress,.voice-track{height:7px;margin:8px 0 4px;border-radius:999px;overflow:hidden;background:#e7ebef;cursor:pointer}.audio-progress span,.voice-track span{display:block;width:0;height:100%;border-radius:inherit;background:var(--orange)}.audio-time,.voice-times{display:flex;justify-content:space-between;color:var(--muted);font-size:10px}
.typing-bar{display:flex;align-items:center;gap:8px;min-height:38px;padding:6px 12px;border-top:1px solid var(--line);background:#fff;color:var(--muted);font-size:12px}.typing-bar[hidden]{display:none}.typing-dots{display:flex;gap:3px}.typing-dots i{width:5px;height:5px;border-radius:50%;background:#94a0b2;animation:b 1s infinite}.typing-dots i:nth-child(2){animation-delay:.12s}.typing-dots i:nth-child(3){animation-delay:.24s}@keyframes b{0%,60%,100%{transform:translateY(0);opacity:.4}30%{transform:translateY(-3px);opacity:1}}
.new-bar{position:sticky;bottom:10px;display:flex;justify-content:center;z-index:5}.new-bar button{display:inline-flex;align-items:center;gap:7px;padding:8px 11px;border:1px solid var(--line);border-radius:999px;color:var(--ink);background:#fff;box-shadow:0 7px 20px #09101f14;font-size:11px;font-weight:800}
.composer-area{padding:9px 11px calc(9px + env(safe-area-inset-bottom));border-top:1px solid var(--line);background:#fff}.composer{display:flex;align-items:flex-end;gap:7px}.composer textarea{min-height:48px;max-height:160px;flex:1;resize:none;padding:12px 13px;border:1px solid var(--line);border-radius:14px;outline:0;background:#fbfcfe;font-size:16px;line-height:1.45}.composer textarea:focus{border-color:#ff8a0060;box-shadow:0 0 0 3px #ff8a0010}.composer-icon,.send-btn{width:46px;height:46px;display:grid;place-items:center;border:0;border-radius:13px;flex:0 0 auto}.composer-icon{color:var(--ink);background:#eef1f5}.send-btn{color:#fff;background:var(--orange)}.composer-icon.recording{color:#fff;background:var(--red)}
.recording-bar{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:9px 11px;border-top:1px solid var(--line);background:#fff8ef;color:#9a4d00;font-size:12px}.recording-bar[hidden]{display:none}.recording-main,.record-actions{display:flex;align-items:center;gap:8px}.recording-led{width:8px;height:8px;border-radius:50%;background:var(--red);animation:p 1s infinite}@keyframes p{50%{opacity:.35}}
.voice-preview{padding:10px 12px;border-top:1px solid var(--line);background:#fff}.voice-preview[hidden]{display:none}.voice-preview-head{display:flex;align-items:center;justify-content:space-between;font-size:12px}.voice-preview-head strong i{color:var(--orange)}.voice-preview-player{display:flex;align-items:center;gap:10px;margin-top:10px}.voice-preview-actions{display:flex;gap:8px;margin-top:10px}.secondary-btn,.primary-mini{height:46px;flex:1;border:0;border-radius:11px;font-size:12px;font-weight:800}.secondary-btn{color:var(--ink);background:#eef1f5}.primary-mini{color:#fff;background:var(--orange)}.primary-mini.icon-only{width:40px;flex:0 0 auto}.small-danger{width:38px;height:38px;display:grid;place-items:center;border:0;border-radius:10px;color:#b91c1c;background:#fff0f1}
.members-panel{padding:16px;background:#fff}.members-head{display:flex;justify-content:space-between;align-items:flex-start;gap:10px}.members-head h2{margin:0;font:800 17px Manrope}.members-head p{margin:4px 0;color:var(--muted);font-size:11px}.room-chip{display:inline-grid;place-items:center;min-width:30px;height:25px;padding:0 7px;border-radius:8px;color:#a45500;background:#fff3e4;font-size:9px;font-weight:800}.members-list{display:grid;gap:8px;margin-top:14px}.member-row{display:flex;align-items:center;gap:9px;padding:8px;border-radius:11px}.member-row:hover{background:#f7f8fa}.member-avatar{position:relative;width:38px;height:38px;display:grid;place-items:center;border-radius:12px;color:#49566b;background:#eef2f6;font-size:11px;font-weight:800}.member-dot{position:absolute;right:-1px;bottom:-1px;width:10px;height:10px;border:2px solid #fff;border-radius:50%}.member-dot.on{background:var(--green)}.member-dot.off{background:#cbd5e1}.member-row strong{display:block;font-size:14px}.member-row small{display:block;margin-top:2px;color:var(--muted);font-size:11px}.you{margin-left:5px;color:var(--orange);font-size:10px}.loading,.empty,.locked-state{min-height:100%;display:grid;place-items:center;padding:40px;text-align:center;color:var(--muted)}.empty i{font-size:30px;color:var(--orange)}.empty h3,.locked-card h2{margin:10px 0 5px;color:var(--ink);font:800 17px Manrope}.empty p,.locked-card p{margin:0;font-size:12px;line-height:1.5}.locked-card{max-width:400px;padding:24px;border:1px solid var(--line);border-radius:18px;background:#fff;box-shadow:0 12px 40px #09101f0c}.locked-icon{width:54px;height:54px;display:grid;place-items:center;margin:auto;border-radius:15px;background:#fff7ed;color:#a45500;font-size:22px}.toast{position:fixed;left:50%;bottom:22px;z-index:100;transform:translateX(-50%) translateY(20px);padding:10px 13px;border-radius:11px;color:#fff;background:#111827;opacity:0;pointer-events:none;transition:.2s;font-size:12px}.toast.show{opacity:1;transform:translateX(-50%) translateY(0)}.toast.error{background:#b91c1c}

@media(max-width:900px){.messenger-shell{grid-template-columns:1fr}.members-panel{display:none}}
@media(max-width:700px){
  .topbar{height:58px;padding:0 9px}.topbar .brand-name{font-size:12px}.online-pill{font-size:10px}.icon-btn{width:36px;height:36px}
  .messenger-shell{min-height:calc(var(--viewport-height) - 58px)}.chat-panel{min-height:calc(var(--viewport-height) - 58px)}
  .chat-header{padding:11px 10px}.room-header-avatar{width:42px;height:42px}.room-title-wrap h1{font-size:17px}.room-title-wrap p{font-size:11px}.room-online-summary{display:none}
  .room-tab{min-width:105px;height:42px;font-size:12px}.room-description{font-size:13px}.room-media-card{margin:7px 8px 0}.room-media-card img{max-height:270px}.room-media-caption{font-size:13px}
  .messages{padding:12px 9px}.message{margin-bottom:18px}.message-inner{max-width:90%}.message-name{font-size:14px}.bubble{font-size:16px;line-height:1.55;padding:11px 13px}.message-meta{font-size:11px}.composer textarea{font-size:17px;min-height:50px}.composer-icon,.send-btn{width:48px;height:48px}.typing-bar{font-size:12px}
}
@media(min-width:1400px){.messenger-shell{grid-template-columns:minmax(0,1fr) 320px}.bubble{font-size:16px}}



/* ============================================================
   MF ACADEMY MESSENGER — LAYOUT STABLE MULTI-ÉCRAN
   ============================================================ */

:root{
  --app-height:100vh;
}

html,
body{
  width:100%;
  min-width:0;
  margin:0;
  padding:0;
}

/*
  L'application prend exactement la hauteur visible du navigateur.
  Sur mobile, JS met à jour --app-height avec visualViewport.height
  quand le clavier ou les barres du navigateur changent la zone visible.
*/
body.messenger-page{
  overflow:hidden;
  display:flex;
  flex-direction:column;
  height:var(--app-height);
  min-height:var(--app-height);
  max-height:var(--app-height);
  background:var(--bg);
}

/* Le header reste dans le flux : aucun fixed/scroll indépendant. */
body.messenger-page .topbar{
  position:relative;
  top:auto;
  left:auto;
  right:auto;
  flex:0 0 64px;
  height:64px;
  min-height:64px;
  width:100%;
  z-index:100;
}

body.messenger-page .messenger-shell{
  position:relative;
  top:auto;
  right:auto;
  bottom:auto;
  left:auto;
  flex:1 1 auto;
  width:100%;
  max-width:1400px;
  height:auto;
  min-height:0;
  margin:0 auto;
  overflow:hidden;
  grid-template-columns:minmax(0,1fr) 300px;
}

body.messenger-page .chat-panel{
  position:relative;
  width:100%;
  height:100%;
  min-width:0;
  min-height:0;
  overflow:hidden;
}

body.messenger-page .members-panel{
  width:100%;
  height:100%;
  min-width:0;
  min-height:0;
  overflow-y:auto;
  overscroll-behavior:contain;
}

/* Les entêtes et la zone de saisie ne défilent jamais. */
body.messenger-page .chat-header,
body.messenger-page .room-tabs,
body.messenger-page .room-description,
body.messenger-page .room-media-card,
body.messenger-page .status-banner,
body.messenger-page .typing-bar,
body.messenger-page .recording-bar,
body.messenger-page .voice-preview,
body.messenger-page .composer-area{
  flex:0 0 auto;
}

/* Une seule zone de défilement : les messages. */
body.messenger-page .messages-wrap{
  flex:1 1 auto;
  width:100%;
  min-width:0;
  min-height:0;
  overflow-x:hidden;
  overflow-y:auto;
  overscroll-behavior-y:contain;
  -webkit-overflow-scrolling:touch;
}

body.messenger-page .messages{
  width:100%;
  min-height:100%;
  overflow:visible;
}

/*
  IMPORTANT : la barre de composition reste dans le flux flex.
  Elle n'est jamais positionnée en fixed sur téléphone.
*/
body.messenger-page .composer-area{
  position:relative;
  width:100%;
  margin:0;
  z-index:30;
}

body.messenger-page .composer{
  width:100%;
  display:flex;
  align-items:flex-end;
  gap:7px;
}

body.messenger-page #messageInput{
  min-width:0;
  flex:1 1 auto;
  width:100%;
  -webkit-appearance:none;
  appearance:none;
  touch-action:manipulation;
}

body.messenger-page .composer-icon,
body.messenger-page .send-btn{
  flex:0 0 48px;
  touch-action:manipulation;
}

@media(max-width:900px){
  body.messenger-page .messenger-shell{
    grid-template-columns:1fr;
  }

  body.messenger-page .members-panel{
    display:none;
  }
}

@media(max-width:700px){
  body.messenger-page .topbar{
    flex-basis:58px;
    height:58px;
    min-height:58px;
  }

  body.messenger-page .messenger-shell{
    min-height:0;
  }

  body.messenger-page .chat-panel{
    min-height:0;
  }

  body.messenger-page .messages-wrap{
    min-height:0;
  }

  body.messenger-page .messages{
    padding:12px 9px 18px;
  }

  body.messenger-page .composer-area{
    padding:8px 8px calc(8px + env(safe-area-inset-bottom));
  }

  body.messenger-page #messageInput{
    min-height:50px;
    max-height:130px;
    font-size:17px;
    line-height:1.45;
  }

  body.messenger-page .composer-icon,
  body.messenger-page .send-btn{
    width:48px;
    height:48px;
    flex-basis:48px;
  }
}

@media(max-width:380px){
  body.messenger-page #messageInput{
    font-size:16px;
  }

  body.messenger-page .composer-icon,
  body.messenger-page .send-btn{
    width:46px;
    height:46px;
    flex-basis:46px;
  }
}

@media(min-width:1400px){
  body.messenger-page .messenger-shell{
    grid-template-columns:minmax(0,1fr) 320px;
  }

  body.messenger-page .bubble{
    font-size:16px;
  }
}
