/* ====================================================================
   VFJah Messenger — feuille de style rétro
   MSN Messenger 6/7 (chrome bleu, dégradés, biseaux) croisé avec
   l'esthétique Skyblog/IRC années 2000 (couleurs vives, glitter, blink).
   Responsive : desktop = fenêtres flottantes ; mobile = plein écran.
   ==================================================================== */

:root {
  --msn-blue: #2a6fc9;
  --msn-blue-2: #4d9de0;
  --msn-grad: linear-gradient(180deg, #5aa9f0 0%, #2a6fc9 45%, #1d5bb0 100%);
  --bevel-light: #ffffff;
  --bevel-dark: #7a9cc6;
  --panel: #eaf2fb;
  --panel-2: #d6e6f8;
  --ink: #11335c;
  --sky-pink: #ff5fa2;
  --sky-green: #7ed957;
  --sky-yellow: #ffe14d;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

/* Session existante — pas de flash écran accueil avant app.js */
html.session-resume #login { display: none !important; }
html.session-resume #app { display: block !important; }

.boot-reconnect {
  position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 9000;
  margin: 0; padding: 8px 16px; font-size: 12px; font-weight: bold;
  color: var(--ink); background: var(--panel); border: 1px solid var(--bevel-dark);
  border-radius: 6px; box-shadow: 0 4px 16px rgba(0,0,0,.25);
}

body {
  margin: 0;
  font-family: "Trebuchet MS", "Segoe UI", Tahoma, sans-serif;
  font-size: 13px;
  color: var(--ink);
  background: #1a3a6b;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* fond ciel étoilé Skyblog */
.sky-bg {
  position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(2px 2px at 20% 30%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 70% 60%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 40% 80%, #ffe14d 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 85% 25%, #ff5fa2 50%, transparent 51%),
    linear-gradient(160deg, #16356a 0%, #0d2147 60%, #1d1040 100%);
  background-size: 300px 300px, 250px 250px, 200px 200px, 350px 350px, cover;
  animation: drift 60s linear infinite;
}
@keyframes drift { to { background-position: 300px 0, -250px 200px, 200px -200px, -350px 100px, 0 0; } }

/* Cirque digital TADC — fond bleu sky-bg, sous les fenêtres MSN */
#digital-circus-stage {
  position: fixed; inset: 0; z-index: 0;
  pointer-events: none; overflow: hidden;
}
#digital-circus-stage canvas {
  width: 100%; height: 100%; display: block;
  image-rendering: pixelated;
}
#app { position: relative; z-index: 1; }
#login { position: relative; z-index: 2; }

@keyframes blinkk { 50% { opacity: .25; } }
.blink { animation: blinkk 1.1s steps(2) infinite; }

/* ---------------- Chrome de fenêtre MSN ---------------- */
.msn-window {
  background: var(--panel);
  border: 2px solid var(--msn-blue);
  border-radius: 8px 8px 6px 6px;
  box-shadow: 0 6px 22px rgba(0,0,0,.45), inset 0 0 0 1px var(--bevel-light);
  overflow: hidden;
  position: relative;
}
.msn-window > .title-bar { position: relative; z-index: 3; }
.msn-window > .resize-grip { z-index: 4; }

.title-bar {
  display: flex; align-items: center; gap: 6px;
  background: var(--msn-grad);
  color: #fff;
  padding: 4px 8px;
  font-weight: bold;
  text-shadow: 0 1px 1px rgba(0,0,0,.4);
  cursor: default;
  user-select: none;
}
.title-bar-icon { font-size: 14px; }
.title-bar-text { flex: 1; letter-spacing: .3px; }
.title-bar-controls { display: flex; gap: 4px; }
.title-bar-controls > span {
  width: 18px; height: 16px; line-height: 14px; text-align: center;
  background: rgba(255,255,255,.25);
  border: 1px solid rgba(255,255,255,.6);
  border-radius: 3px; cursor: pointer; font-size: 11px;
}
.title-bar-controls > span:hover { background: rgba(255,255,255,.5); }

/* ---------------- Écran de connexion ---------------- */
.login-window {
  width: 340px; margin: 6vh auto 0;
}
.login-body { padding: 18px 22px 24px; background: var(--panel); }
.login-logo { text-align: center; margin-bottom: 14px; }
.butterfly { font-size: 46px; filter: drop-shadow(0 0 6px var(--msn-blue-2)); animation: flap 3s ease-in-out infinite; }
@keyframes flap { 50% { transform: rotate(-8deg) translateY(-4px); } }
.login-logo h1 { margin: 4px 0 0; font-size: 26px; color: var(--msn-blue); }
.login-logo h1 span { color: var(--sky-pink); }
.tagline { color: #6b4aa0; font-size: 11px; margin: 4px 0 0; }

form label { display: block; margin: 10px 0 2px; font-weight: bold; }
form input, form select, .personal-msg, #search-contacts {
  width: 100%; padding: 6px 8px; font-family: inherit; font-size: 13px;
  border: 1px solid var(--bevel-dark); border-radius: 4px;
  background: #fff; box-shadow: inset 1px 1px 2px rgba(0,0,0,.12);
}
.status-pick { margin-top: 10px; }

.big-btn {
  width: 100%; margin-top: 16px; padding: 9px;
  font-weight: bold; font-size: 14px; color: #fff; cursor: pointer;
  background: var(--msn-grad);
  border: 1px solid #1d5bb0; border-radius: 6px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.5);
}
.big-btn:hover { filter: brightness(1.08); }
.big-btn:active { transform: translateY(1px); }
.link-btn { width: 100%; margin-top: 8px; background: none; border: 0; color: var(--msn-blue); cursor: pointer; text-decoration: underline; }
.register-lead { text-align: center; color: #6b4aa0; font-size: 12px; margin: 0 0 10px; line-height: 1.4; }
.auth-hint, .field-hint { font-size: 11px; color: #6b4aa0; margin: 8px 0 0; line-height: 1.35; }
.field-hint { font-weight: normal; opacity: 0.85; }
.avatar-register-details { margin: 8px 0; font-size: 12px; color: var(--msn-blue); }
.avatar-register-details summary { cursor: pointer; }
.avatar-register { margin-bottom: 12px; }
.register-avatar-preview {
  width: 72px; height: 72px; margin: 0 auto 10px; font-size: 42px; line-height: 72px;
  text-align: center; border-radius: 10px;
  background: linear-gradient(180deg, #fff 0%, #e8eef8 100%);
  border: 2px solid var(--bevel-dark); box-shadow: inset 0 1px 0 #fff;
}
.avatar-picker {
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px;
  max-height: 160px; overflow-y: auto; padding: 4px;
  background: rgba(255,255,255,.6); border-radius: 6px; border: 1px solid var(--bevel-dark);
}
.avatar-pick {
  font-size: 22px; line-height: 1; padding: 6px 0; cursor: pointer;
  border: 2px solid transparent; border-radius: 6px; background: #fff;
}
.avatar-pick:hover { border-color: var(--msn-blue-2); background: #f0f6ff; }
.avatar-pick.selected { border-color: var(--sky-pink); background: #fff8e0; box-shadow: 0 0 0 1px var(--sky-pink); }
.error { color: #c0203a; font-weight: bold; text-align: center; margin-top: 10px; }

/* ---------------- Application ---------------- */
#app { display: flex; gap: 14px; padding: 14px; align-items: flex-start; flex-wrap: wrap; position: relative; min-height: calc(100vh - 28px); min-height: calc(100dvh - 28px); }

.mobile-nav { display: none !important; }

.contact-window { width: 300px; flex: 0 0 auto; position: relative; }
.contact-window.floating { position: absolute; flex: none; max-height: none; display: flex; flex-direction: column; }
.contact-window.floating .contacts-scroll { flex: 1; max-height: none; min-height: 0; overflow-y: auto; }
.contact-window .resize-grip { position: absolute; right: 2px; bottom: 2px; }

.me-card {
  display: flex; gap: 10px; align-items: flex-end;
  padding: 10px; background: rgba(248, 251, 255, 0.88);
  border-bottom: 1px solid var(--bevel-dark);
}
.me-avatar { cursor: pointer; touch-action: manipulation; }
.me-avatar:hover { filter: brightness(1.08); box-shadow: 0 0 0 2px var(--sky-yellow); }

.avatar-menu {
  position: fixed; z-index: 10050; min-width: 200px;
  background: #fff; border: 2px solid var(--msn-blue); border-radius: 8px;
  padding: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.35);
}
.avatar-menu p { margin: 0 0 8px; font-weight: bold; color: var(--msn-blue); font-size: 12px; }
.avatar-emojis { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.avatar-emo-btn { font-size: 22px; padding: 4px; cursor: pointer; border: 1px solid var(--bevel-dark); border-radius: 6px; background: var(--panel); }
.avatar-emo-btn:hover { background: var(--sky-yellow); }
#avatar-photo-btn, #avatar-menu-close {
  font-size: 12px; padding: 4px 8px; margin-right: 6px; cursor: pointer;
  border: 1px solid var(--bevel-dark); border-radius: 5px; background: var(--panel-2);
}

.add-contact-dialog {
  position: fixed; inset: 0; z-index: 70;
  display: flex; align-items: center; justify-content: center;
  background: rgba(13, 33, 71, 0.55);
}
.add-contact-dialog[hidden] { display: none !important; }
.add-contact-dialog .msn-window { width: min(360px, 94vw); max-height: 80vh; display: flex; flex-direction: column; }
.add-contact-body { padding: 10px; background: var(--panel); display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.add-contact-list { flex: 1; min-height: 180px; max-height: 42vh; overflow-y: auto; background: #fff; border: 1px solid var(--bevel-dark); border-radius: 4px; }
.add-contact-row {
  display: flex; align-items: center; gap: 8px; padding: 7px 10px; cursor: pointer; border-bottom: 1px solid var(--panel-2);
}
.add-contact-row:hover { background: var(--sky-yellow); }
.add-contact-row .c-handle { font-size: 10px; color: var(--msn-blue); }
.add-contact-manual { display: flex; gap: 6px; }
.add-contact-manual input { flex: 1; padding: 6px; border: 1px solid var(--bevel-dark); border-radius: 4px; }
.add-contact-manual button { padding: 6px 12px; cursor: pointer; font-weight: bold; background: var(--msn-grad); color: #fff; border: 1px solid #1d5bb0; border-radius: 5px; }
.add-contact-hint { margin: 0; font-size: 11px; color: #8a6fb0; }
.add-contact-empty { padding: 16px; text-align: center; color: #8a6fb0; font-style: italic; }

.idea-list .idea-row {
  display: flex; align-items: flex-start; gap: 6px;
  padding: 8px 10px; border-bottom: 1px solid var(--panel-2); font-size: 12px; line-height: 1.35;
}
.idea-list .idea-row b { color: var(--msn-blue); }
.idea-list .idea-row-main { flex: 1; min-width: 0; }
.idea-list .idea-row-editing { background: #eef4ff; outline: 1px solid var(--msn-blue); }
.idea-row-actions { display: flex; gap: 2px; flex-shrink: 0; }
.idea-row-btn {
  padding: 2px 5px; cursor: pointer; font-size: 13px; line-height: 1;
  border: 1px solid var(--bevel-dark); border-radius: 3px; background: var(--panel-2);
}
.idea-row-btn:hover { background: #fff; }
.idea-row-btn-danger:hover { background: #ffe8ec; border-color: #c0203a; }
.idea-actions { display: flex; gap: 8px; align-items: center; }
.idea-submit-btn { flex: 1; margin-top: 0; }
.idea-secondary-btn {
  padding: 8px 10px; cursor: pointer; font-weight: bold;
  border: 1px solid var(--bevel-dark); border-radius: 5px; background: var(--panel-2); color: var(--msn-blue);
}
#idea-text { width: 100%; padding: 8px; font-family: inherit; font-size: 13px; resize: vertical;
  border: 1px solid var(--bevel-dark); border-radius: 4px; background: #fff; min-height: 72px; }
#idea-tags { width: 100%; padding: 6px 8px; border: 1px solid var(--bevel-dark); border-radius: 4px; }
.idea-status { margin: 0; font-size: 11px; min-height: 1.2em; }
.idea-status.ok { color: #1b7a3a; font-weight: bold; }
.idea-status.err { color: #c0203a; font-weight: bold; }

.gif-library-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 8px;
  max-height: 220px; overflow-y: auto; margin-bottom: 10px; padding: 4px;
  border: 1px solid var(--bevel-dark); border-radius: 4px; background: #fff;
}
.gif-lib-item { position: relative; }
.gif-lib-pick {
  display: block; width: 100%; padding: 0; border: 1px solid var(--bevel-dark); border-radius: 4px;
  background: var(--panel-2); cursor: pointer; overflow: hidden; aspect-ratio: 1;
}
.gif-lib-pick:hover { outline: 2px solid var(--msn-blue); }
.gif-lib-pick img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gif-lib-remove {
  position: absolute; top: 2px; right: 2px; width: 18px; height: 18px; padding: 0; line-height: 16px;
  font-size: 10px; cursor: pointer; border: 1px solid var(--bevel-dark); border-radius: 3px;
  background: rgba(255,255,255,.92); color: #c0203a;
}
.gif-add-row { display: flex; gap: 6px; }
.gif-add-row input { flex: 1; padding: 6px 8px; border: 1px solid var(--bevel-dark); border-radius: 4px; }

.patchnotes-mode-bar {
  display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 4px;
}
.patchnotes-mode-bar .filter-chip { flex: 1; min-width: 120px; text-align: center; padding: 6px 8px; font-size: 11px; }

.patchnotes-window { width: min(420px, 94vw); }
.patchnotes-body { max-height: 70vh; }
.patchnotes-current { margin: 0; font-size: 12px; font-weight: bold; color: var(--msn-blue); }
.patchnotes-scroll {
  flex: 1; min-height: 200px; max-height: 58vh; overflow-y: auto;
  background: #fff; border: 1px solid var(--bevel-dark); border-radius: 4px; padding: 8px 10px;
}
.patchnotes-release { margin-bottom: 14px; padding-bottom: 10px; border-bottom: 1px dashed var(--bevel-dark); }
.patchnotes-release:last-child { border-bottom: 0; margin-bottom: 0; }
.patchnotes-release h3 { margin: 0 0 6px; font-size: 14px; color: var(--msn-blue); }
.patchnotes-date { font-weight: normal; font-size: 11px; color: #8a6fb0; }
.patchnotes-section { margin: 6px 0; }
.patchnotes-section h4 { margin: 0 0 4px; font-size: 12px; color: #6b4aa0; }
.patchnotes-section ul { margin: 0; padding-left: 18px; font-size: 12px; line-height: 1.45; }
.patchnotes-section li { margin: 3px 0; }
.patchnotes-section code { font-size: 11px; background: var(--panel-2); padding: 0 3px; border-radius: 3px; }

.toolbar button.has-patchnotes,
.link-btn.has-patchnotes { position: relative; }
.toolbar button.has-patchnotes::after,
.link-btn.has-patchnotes::after {
  content: '';
  position: absolute;
  top: 2px;
  right: 2px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--sky-pink);
  border: 1px solid #fff;
  box-shadow: 0 0 4px rgba(255, 95, 162, 0.8);
}

.me-avatar, .peer-avatar {
  width: 88px; height: 72px; min-width: 88px; display: flex; align-items: flex-end; justify-content: center;
  font-size: 24px; background: #fff; border: 2px solid var(--msn-blue);
  border-radius: 6px; box-shadow: 0 0 0 2px #fff, 0 2px 5px rgba(0,0,0,.25);
  overflow: visible; padding: 0;
}
.me-avatar.pixel-avatar-wrap, .peer-avatar.pixel-avatar-wrap { background: transparent; border: none; box-shadow: none; }
.me-info { flex: 1; min-width: 0; }
.me-name-row { display: flex; gap: 6px; align-items: center; }
.me-name { font-weight: bold; font-size: 14px; color: var(--msn-blue); flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status-select, .status-pick select { padding: 4px; border-radius: 4px; border: 1px solid var(--bevel-dark); background: #fff; }
.status-select { font-size: 11px; max-width: 110px; }
.personal-msg { margin-top: 5px; font-style: italic; color: #6b4aa0; flex: 1; min-width: 0; }
.personal-row { display: flex; gap: 4px; align-items: center; width: 100%; }
.me-personal-color { width: 24px; height: 24px; padding: 0; border: 1px solid var(--bevel-dark); border-radius: 4px; background: transparent; cursor: pointer; flex: none; }
.personal-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-wizz-badge { display: block; margin-top: 2px; font-size: 11px; color: #888; min-height: 14px; }

.mob-only { display: none !important; }
.room-only { display: none; }
.chat-window.is-room .room-only { display: inline-block; }
.chat-window.is-room .dm-only { display: none !important; }
.chat-window.is-room .peer-avatar { font-size: 18px; }
.room-members { margin-left: auto; font-size: 11px; color: #8a6fb0; white-space: nowrap; }

.toolbar { display: flex; gap: 4px; padding: 8px; border-bottom: 1px solid var(--bevel-dark); flex-wrap: wrap; align-items: center; background: rgba(248, 251, 255, 0.88); }
.room-topic-input {
  flex: 1; min-width: 72px; max-width: 110px; padding: 5px 6px; font-size: 12px;
  border: 1px solid var(--bevel-dark); border-radius: 4px; background: #fff;
}
#search-contacts { flex: 1; min-width: 80px; }

.group-head-rooms { background: linear-gradient(90deg, #5a7fc9, var(--msn-blue-2)); }

.room-row.contact-style {
  display: flex; align-items: center; gap: 8px; padding: 6px 10px; cursor: pointer;
  border-bottom: 1px solid var(--panel-2);
}
.room-row.contact-style:hover { background: var(--sky-yellow); }
.room-row .room-icon {
  font-weight: bold; color: var(--msn-blue); font-size: 16px; background: var(--panel-2);
}
.room-row.joined .room-hash::after { content: " ✓"; color: var(--sky-green); font-size: 10px; }
.room-row.browse { opacity: .88; }
.room-row.browse .room-hash { color: #6b4aa0; }
.room-preview {
  display: block; font-size: 11px; font-style: italic; color: #6b4aa0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px;
}
.room-row .room-action {
  flex-shrink: 0; padding: 2px 6px; font-size: 14px; cursor: pointer;
  background: var(--panel-2); border: 1px solid var(--bevel-dark); border-radius: 4px;
}
.room-row .room-action:hover { background: var(--sky-yellow); }

.toolbar button {
  white-space: nowrap; padding: 5px 8px; cursor: pointer;
  background: linear-gradient(#fff, var(--panel-2));
  border: 1px solid var(--bevel-dark); border-radius: 5px; font-weight: bold; color: var(--ink);
}
.toolbar button:hover { background: var(--sky-yellow); }
#search-contacts { flex: 1; }

.contacts-scroll { max-height: 50vh; overflow-y: auto; padding: 4px 0; background: rgba(255, 255, 255, 0.78); }

.group-head {
  padding: 4px 10px; font-weight: bold; color: #fff;
  background: linear-gradient(90deg, var(--sky-pink), var(--msn-blue-2));
  cursor: pointer; margin-top: 2px;
}
.group-head::before { content: "▼ "; font-size: 9px; }
.group-head.collapsed::before { content: "► "; }

.contact-row {
  display: flex; align-items: center; gap: 8px; padding: 5px 10px; cursor: pointer;
}
.contact-row:hover { background: var(--sky-yellow); }
.contact-row .dot { width: 9px; height: 9px; border-radius: 50%; box-shadow: 0 0 4px currentColor; }
.dot.online { background: var(--sky-green); color: var(--sky-green); }
.dot.away, .dot.brb, .dot.lunch { background: var(--sky-yellow); color: var(--sky-yellow); }
.dot.busy, .dot.phone { background: #ff4d4d; color: #ff4d4d; }
.dot.invisible, .dot.offline { background: #b8b8b8; color: #b8b8b8; }
.contact-row .c-avatar { font-size: 18px; flex-shrink: 0; width: 64px; height: 58px; display: flex; align-items: flex-end; justify-content: center; overflow: visible; }
.pixel-avatar-wrap {
  position: relative; image-rendering: pixelated;
  filter: contrast(1.08) saturate(1.05);
  display: flex; align-items: flex-end; justify-content: center;
}
.pixel-avatar-wrap.pixel-avatar-sm { width: 36px; height: 34px; }
.pixel-avatar-wrap.pixel-avatar-md { width: 64px; height: 58px; }
.pixel-avatar-wrap.pixel-avatar-lg { width: 88px; height: 72px; }
/* photo de profil avatar = emoji/image rond · modèle 3D = canvas isométrique en dessous */
.pixel-avatar-wrap.has-profile-photo .pixel-avatar-canvas {
  position: absolute; bottom: 0; left: 50%;
  transform: translateX(-50%);
  width: 58%; height: 44%;
}
.profile-photo-avatar {
  position: absolute; top: -4px; left: 50%;
  transform: translateX(-50%);
  line-height: 1; z-index: 2; pointer-events: none;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4));
}
.pixel-avatar-md .profile-photo-avatar { font-size: 1.82rem; }
.pixel-avatar-lg .profile-photo-avatar { font-size: 2.38rem; }
.pixel-avatar-sm .profile-photo-avatar { font-size: 1.05rem; }
.pixel-avatar-wrap::after {
  content: ""; pointer-events: none; position: absolute; inset: 0;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,0.12) 0 1px, transparent 1px 3px);
  mix-blend-mode: multiply; opacity: 0.35;
}
.pixel-avatar-canvas, .pixel-avatar-photo {
  width: 100%; height: 100%; display: block; image-rendering: pixelated;
}
.pixel-avatar-photo { object-fit: cover; object-position: center top; }
.contact-row .c-name { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.contact-row .c-display { font-weight: bold; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.contact-row .c-handle { font-size: 10px; color: var(--msn-blue); background: transparent; padding: 0; }
.contact-row.offline { opacity: .55; }
.contact-row .c-personal { font-size: 11px; font-style: italic; color: #8a6fb0; }

.bridges-bar {
  display: flex; gap: 6px; padding: 6px 10px; flex-wrap: wrap;
  background: rgba(248, 251, 255, 0.88); border-top: 1px solid var(--bevel-dark); min-height: 26px;
}
.bridge-pill {
  font-size: 11px; padding: 2px 8px; border-radius: 10px; font-weight: bold;
  background: #fff; border: 1px solid var(--bevel-dark);
}
.bridge-pill.on { background: var(--sky-green); color: #0a3d0a; }
.bridge-pill.off { opacity: .6; }

/* ---------------- Fenêtres de chat ---------------- */
#chats { position: relative; flex: 1; min-width: 280px; min-height: 70vh; }
.chat-window { width: 360px; display: flex; flex-direction: column; max-height: 78vh; position: relative; }
.chat-window.floating { position: absolute; max-height: none; box-shadow: 0 8px 28px rgba(0,0,0,.5); }
.chat-window.floating .messages { flex: 1; min-height: 120px; }
.chat-window[data-theme] {
  border-color: var(--win-accent);
  box-shadow: 0 6px 22px rgba(0,0,0,.45), inset 0 0 0 1px var(--bevel-light), 0 0 0 1px var(--win-accent);
}
.chat-window[data-theme] .title-bar {
  background: linear-gradient(180deg, var(--win-accent-2) 0%, var(--win-accent) 45%, var(--win-accent-dark) 100%);
}
.chat-window[data-theme] .chat-peer { background: var(--win-panel-2); }
.chat-window[data-theme] .messages {
  background: repeating-linear-gradient(0deg, var(--win-panel), var(--win-panel) 22px, var(--win-panel-2) 22px, var(--win-panel-2) 23px);
}
.chat-window[data-theme] .peer-name { color: var(--win-accent-dark); }
.chat-window[data-theme] .msg.them .who { color: var(--win-accent-dark); }
.chat-window[data-theme] .composer,
.chat-window[data-theme] .emote-bar-wrap,
.chat-window[data-theme] .emote-bar { background: var(--win-panel-2); }
.chat-window[data-theme] .resize-grip {
  background: linear-gradient(135deg, transparent 45%, var(--win-accent) 46%);
}
.color-btn {
  font-size: 12px; line-height: 14px; font-family: inherit; color: inherit;
  padding: 0; touch-action: manipulation;
}
.title-bar-controls .color-btn {
  width: 18px; height: 16px; line-height: 14px;
  background: rgba(255,255,255,.25);
  border: 1px solid rgba(255,255,255,.6);
  border-radius: 3px; cursor: pointer;
}
.contact-color-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
  border: 1px solid rgba(0,0,0,.15); box-shadow: inset 0 0 0 1px rgba(255,255,255,.4);
  cursor: pointer; touch-action: manipulation;
}
.contact-color-dot::after {
  content: ''; position: absolute; inset: -10px;
}
.contact-row .contact-color-dot { position: relative; }
.contact-color-dot.contact-color-add {
  width: auto; height: auto; border: 0; box-shadow: none; background: transparent;
  font-size: 10px; line-height: 1; opacity: .75;
}
.contact-row.has-color { border-left: 3px solid var(--row-accent, var(--msn-blue)); padding-left: 7px; }
.color-picker-pop {
  position: fixed; z-index: 10050; top: auto; right: auto; margin-top: 0;
  padding: 8px; background: #fff; border: 2px solid var(--msn-blue); border-radius: 6px;
  box-shadow: 0 6px 18px rgba(0,0,0,.35); min-width: 168px;
}
.color-picker-pop[hidden] { display: none !important; }
.color-picker-pop p { margin: 0 0 6px; font-size: 11px; font-weight: bold; color: var(--msn-blue); }
.color-swatches { display: flex; flex-wrap: wrap; gap: 5px; }
.color-swatch {
  width: 22px; height: 22px; border-radius: 4px; cursor: pointer;
  border: 2px solid rgba(0,0,0,.12); padding: 0;
}
.color-swatch:hover { transform: scale(1.08); border-color: var(--ink); }
.color-swatch.selected { border-color: var(--ink); box-shadow: 0 0 0 1px #fff; }
.color-swatch.reset { background: var(--msn-grad); font-size: 10px; color: #fff; font-weight: bold; }
.resize-grip {
  position: absolute; right: 2px; bottom: 2px; width: 14px; height: 14px;
  cursor: nwse-resize; opacity: .7;
  background: linear-gradient(135deg, transparent 45%, var(--msn-blue) 46%);
}

.chat-peer {
  display: flex; gap: 10px; align-items: flex-end; padding: 8px 10px;
  background: rgba(243, 248, 255, 0.88); border-bottom: 1px solid var(--bevel-dark);
}
.peer-meta { display: flex; flex-direction: column; min-width: 0; }
.peer-name { color: var(--msn-blue); }
.peer-personal { font-size: 11px; color: #8a6fb0; }

.messages {
  flex: 1; min-height: 200px; overflow-y: auto; padding: 8px 10px;
  background: rgba(255, 255, 255, 0.72);
}
.msg { margin: 6px 0; line-height: 1.4; }
.load-more-history {
  display: block; width: 100%; margin: 4px 0 8px; padding: 4px 8px;
  font-size: 11px; color: #6b7a8f; background: #eef4fc; border: 1px solid var(--bevel-dark);
  border-radius: 4px; cursor: pointer;
}
.load-more-history:hover:not(:disabled) { background: #dfeaf8; }
.load-more-history:disabled { opacity: 0.6; cursor: wait; }
.msg-body { white-space: pre-line; }
.msg .who { font-weight: bold; }
.msg.me .who { color: var(--sky-pink); }
.msg.them .who { color: var(--msn-blue); }
.msg .time { color: #9aa7b8; font-size: 10px; margin-left: 4px; }
.msg-img { max-width: min(280px, 100%); border-radius: 6px; border: 1px solid var(--bevel-dark); vertical-align: middle; }
.chat-link { font-weight: bold; text-decoration: underline; cursor: pointer; }
.chat-link-user { color: #6b4aa0; }
.chat-link-user.who { cursor: pointer; }
.chat-link-user.who:hover { color: var(--sky-pink); }
.chat-link-room { color: var(--msn-blue); }
.chat-link-room:hover { color: var(--sky-pink); background: rgba(255,225,77,.35); border-radius: 3px; }
.chat-link-url { color: #0d6b3a; word-break: break-all; }
.chat-link-url:hover { color: #094d2a; background: rgba(144,238,180,.35); border-radius: 3px; }
.msg-gif { max-width: min(240px, 100%); max-height: 200px; border-radius: 6px; border: 1px solid var(--bevel-dark); vertical-align: middle; display: block; margin: 4px 0; }
.chat-link-gif { display: inline-block; }
.gif-embed-wrap { display: inline-block; position: relative; max-width: 100%; }
.gif-save-btn {
  position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; padding: 0;
  font-size: 12px; line-height: 20px; cursor: pointer; border: 1px solid var(--bevel-dark);
  border-radius: 4px; background: rgba(255,255,255,.9); opacity: 0.85;
}
.gif-embed-wrap:hover .gif-save-btn { opacity: 1; }
.emote-bar-scroll {
  max-height: 88px;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
.emote-bar-wrap {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: rgba(243, 248, 255, 0.9);
  border-top: 1px solid var(--bevel-dark);
}
.emote-bar-toggle {
  align-self: flex-start;
  margin: 4px 8px 0;
  padding: 3px 10px;
  font-size: 11px;
  font-family: inherit;
  font-weight: bold;
  cursor: pointer;
  border: 1px solid var(--bevel-dark);
  border-radius: 6px;
  background: linear-gradient(180deg, #fff 0%, #f0f4ff 100%);
  color: var(--msn-blue);
  touch-action: manipulation;
}
.emote-bar-toggle:hover { background: var(--sky-yellow); }
.emote-bar-wrap.collapsed .emote-bar { display: none; }
.emote-bar-wrap.collapsed .emote-bar-toggle { margin-bottom: 4px; }
.gif-btn { padding: 4px 8px; cursor: pointer; border: 1px solid var(--bevel-dark); border-radius: 4px; background: #fff8e0; font-weight: bold; font-size: 11px; color: var(--msn-blue); }

.maintenance-overlay {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  background: rgba(13, 33, 71, 0.82);
  padding: 20px;
}
.maintenance-overlay[hidden] { display: none !important; }
body.maint-mode #login, body.maint-mode #app { filter: blur(2px); pointer-events: none; }
.maint-box { width: min(340px, 94vw); }
.maint-body { padding: 24px 20px; text-align: center; background: var(--panel); }
.maint-body h2 { margin: 8px 0; color: var(--msn-blue); }
.maint-hint { font-size: 11px; color: #6b4aa0; margin-top: 12px; }

.maint-evolution {
  position: relative;
  width: 72px;
  height: 72px;
  margin: 0 auto 10px;
}
.maint-stage {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  opacity: 0;
  animation: maint-evolve 9s ease-in-out infinite;
}
.maint-caterpillar { animation-delay: 0s; }
.maint-cocoon {
  animation-delay: 3s;
}
.maint-cocoon::before {
  content: '';
  width: 30px;
  height: 46px;
  border-radius: 48% 48% 42% 42%;
  background: linear-gradient(145deg, #e8d4a8 0%, #a67c3d 45%, #6b4f28 100%);
  box-shadow: inset -4px -4px 8px rgba(0,0,0,.22), inset 3px 3px 6px rgba(255,255,255,.28);
  display: block;
}
.maint-butterfly {
  animation-delay: 6s;
  filter: drop-shadow(0 0 6px var(--msn-blue-2));
}
@keyframes maint-evolve {
  0%, 5% { opacity: 0; transform: scale(0.88) translateY(4px); }
  8%, 28% { opacity: 1; transform: scale(1) translateY(0); }
  33%, 100% { opacity: 0; transform: scale(0.92) translateY(-3px); }
}

.sidebar-filters {
  display: flex; flex-wrap: wrap; gap: 4px; padding: 6px 8px;
  border-bottom: 1px solid var(--bevel-dark); background: rgba(248, 251, 255, 0.88);
}
.filter-chip {
  font-size: 10px; padding: 4px 8px; border-radius: 12px; cursor: pointer;
  border: 1px solid var(--bevel-dark); background: #fff; opacity: 0.65;
}
.filter-chip.on { opacity: 1; background: var(--sky-yellow); font-weight: bold; }
.filter-chip:hover { filter: brightness(1.05); }
.foot-quick-bar {
  display: flex; flex-wrap: wrap; gap: 4px; padding: 6px 8px;
  background: linear-gradient(180deg, #e8f5e9 0%, #dceee0 100%);
  border-top: 1px solid var(--bevel-dark); border-bottom: 1px solid var(--bevel-dark);
}
.foot-cmd-btn {
  flex: 1 1 auto; min-width: 72px; padding: 4px 6px; font-size: 11px; font-family: inherit;
  cursor: pointer; border: 1px solid #2e7d4a; border-radius: 5px;
  background: linear-gradient(180deg, #fff 0%, #c8e6c9 100%);
  color: #1b5e20; font-weight: bold;
}
.foot-cmd-btn:hover { filter: brightness(1.05); background: #fff; }
.foot-cmd-btn:active { transform: translateY(1px); }

.mcp-quick-bar {
  display: flex; flex-wrap: wrap; gap: 4px; padding: 6px 8px;
  background: linear-gradient(180deg, #e3f2fd 0%, #d4e8fb 100%);
  border-top: 1px solid var(--bevel-dark); border-bottom: 1px solid var(--bevel-dark);
}
.mcp-chat-btn, .mcp-action-btn {
  flex: 1 1 auto; min-width: 68px; padding: 4px 6px; font-size: 11px; font-family: inherit;
  cursor: pointer; border: 1px solid #1565c0; border-radius: 5px;
  background: linear-gradient(180deg, #fff 0%, #bbdefb 100%);
  color: #0d47a1; font-weight: bold;
}
.mcp-chat-btn:hover, .mcp-action-btn:hover { filter: brightness(1.05); background: #fff; }
.mcp-window { width: min(460px, 96vw); }
.mcp-body-wrap { max-height: 78vh; display: flex; flex-direction: column; gap: 8px; }
.mcp-status { margin: 0; font-size: 11px; }
.mcp-status.mcp-ready { color: #2e7d32; font-weight: bold; }
.mcp-quick-actions { display: flex; flex-wrap: wrap; gap: 4px; }
.mcp-search-row { display: flex; gap: 6px; }
.mcp-search-row input { flex: 1; }
.mcp-scroll {
  flex: 1; min-height: 120px; max-height: 48vh; overflow: auto;
  border: 1px inset var(--bevel-dark); border-radius: 6px; padding: 8px; background: #fafcff;
}
.mcp-card-head h3 { margin: 4px 0; font-size: 15px; color: var(--msn-blue); }
.mcp-summary { margin: 0 0 8px; font-size: 12px; color: #444; }
.mcp-scope {
  display: inline-block; font-size: 10px; font-weight: bold; padding: 2px 6px; border-radius: 4px;
  background: #e8eaf6; color: #3949ab; margin-bottom: 4px;
}
.mcp-scope-feed { background: #e0f2f1; color: #00695c; }
.mcp-scope-vfg { background: #fff3e0; color: #e65100; }
.mcp-health-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: 6px; margin: 8px 0; }
.mcp-pill {
  padding: 6px 8px; border-radius: 6px; font-size: 11px; border: 1px solid rgba(0,0,0,.08);
  display: flex; flex-direction: column; gap: 2px;
}
.mcp-pill b { font-size: 10px; text-transform: uppercase; opacity: .85; }
.mcp-pill.ok { background: #e8f5e9; border-color: #81c784; color: #1b5e20; }
.mcp-pill.warn { background: #fff8e1; border-color: #ffca28; color: #e65100; }
.mcp-pill.bad { background: #ffebee; border-color: #e57373; color: #b71c1c; }
.mcp-pill.muted { background: #f5f5f5; color: #666; }
.mcp-lines { margin: 6px 0; padding-left: 18px; font-size: 12px; line-height: 1.45; }
.mcp-hit { margin: 8px 0; padding: 6px 8px; background: #fff; border: 1px dashed #90caf9; border-radius: 5px; }
.mcp-hit code { font-size: 11px; color: #1565c0; }
.mcp-hit p { margin: 4px 0 0; font-size: 11px; color: #333; }
.mcp-md, .mcp-raw pre {
  font-size: 11px; line-height: 1.4; white-space: pre-wrap; word-break: break-word;
  background: #f3f6fb; border-radius: 5px; padding: 8px; max-height: 220px; overflow: auto;
}
.mcp-foot { margin-top: 8px; font-size: 10px; }
.mcp-inline {
  margin-top: 4px; padding: 8px 10px; border-radius: 8px;
  background: linear-gradient(135deg, #f3f8ff 0%, #eef7f5 100%);
  border: 1px solid #90caf9; max-width: 100%;
}
.mcp-inline-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.mcp-inline-badge { font-weight: bold; font-size: 12px; color: var(--msn-blue); }
.mcp-inline-summary { margin: 6px 0 4px; font-size: 12px; }
.mcp-inline-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.mcp-chip {
  font-size: 10px; padding: 2px 6px; border-radius: 4px; background: rgba(255,255,255,.8);
  border: 1px solid #b3d9ff; color: #333;
}
.mcp-open-inline {
  font-size: 11px; padding: 3px 8px; cursor: pointer; border-radius: 5px;
  border: 1px solid #1565c0; background: #fff; color: #0d47a1; font-weight: bold;
}
.mcp-open-inline:hover { background: #e3f2fd; }
.msg.them .mcp-inline { box-shadow: 0 1px 3px rgba(21,101,192,.15); }

.chat-link:hover { text-decoration: underline; }
.msg.system { text-align: center; color: #8a6fb0; font-style: italic; font-size: 11px; }
.msg.nudge {
  text-align: center; font-weight: bold; color: #c0203a;
  background: #ffe9ef; border: 1px dashed var(--sky-pink); border-radius: 6px; padding: 4px;
}
.msg.bridge .who::after { content: " 🌐"; }
@keyframes shake {
  0%,100% { transform: translate(0,0); }
  20% { transform: translate(-6px, 3px); } 40% { transform: translate(6px, -3px); }
  60% { transform: translate(-5px, -2px); } 80% { transform: translate(5px, 2px); }
}
.shaking { animation: shake .5s ease-in-out 2; }

.typing-line { padding: 2px 10px; font-size: 11px; font-style: italic; color: #8a6fb0; }

.emote-bar {
  display: flex; flex-wrap: wrap; gap: 4px; padding: 6px 8px;
  background: var(--panel-2);
}
.emote-bar button {
  font-size: 18px; background: #fff; border: 1px solid var(--bevel-dark); border-radius: 6px;
  cursor: pointer; padding: 4px 8px; min-width: 40px; min-height: 36px; line-height: 1;
  touch-action: manipulation;
}
.emote-bar button:hover { background: var(--sky-yellow); }
.emote-bar button.emote-locked { opacity: .35; filter: grayscale(1); cursor: not-allowed; }
.emote-bar button.emote-locked:hover { background: #fff; }
.emote-lulu-sep { display: inline-block; padding: 0 4px; opacity: .6; font-size: 12px; user-select: none; vertical-align: middle; }
.contact-row .c-affinity { font-size: 14px; margin-left: 3px; flex-shrink: 0; transition: color 0.3s; }

/* Barre de progression affinité */
.c-affinity-bar {
  position: relative; width: 100%; margin-top: 3px; border-radius: 4px;
  background: rgba(0, 0, 0, 0.12); overflow: hidden; height: 8px;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.12);
  transition: width 0.4s ease;
}
.c-affinity-bar:hover { height: 10px; }
.c-affinity-fill {
  height: 100%; border-radius: 4px;
  background: linear-gradient(90deg, var(--aff-fill, currentColor), var(--sky-pink, #ff5fa2));
  opacity: 0.9; transition: width 0.4s ease, opacity 0.3s;
  box-shadow: 0 0 6px rgba(255, 95, 162, 0.35);
}
.c-affinity-bar:hover .c-affinity-fill { opacity: 1; }
.c-affinity-label {
  display: block; font-size: 10px; font-weight: bold; color: #555;
  margin-top: 1px; line-height: 1.2;
}

/* Avatar tier color classes */
.avatar-tier-1 { filter: drop-shadow(0 0 2px #fbbf24); }
.avatar-tier-2 { filter: drop-shadow(0 0 3px #38bdf8); }
.avatar-tier-3 { filter: drop-shadow(0 0 4px #a78bfa); }
.avatar-tier-1, .avatar-tier-2, .avatar-tier-3 { transition: filter 0.3s; }

.avatar-tier-1 .profile-photo-avatar,
.avatar-tier-2 .profile-photo-avatar,
.avatar-tier-3 .profile-photo-avatar {
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4)) drop-shadow(0 0 3px currentColor);
}

@keyframes avatar-flash {
  0% { filter: brightness(1); }
  30% { filter: brightness(1.8) drop-shadow(0 0 6px currentColor); }
  100% { filter: brightness(1); }
}
.avatar-flash {
  animation: avatar-flash 0.4s ease-out;
  animation-composition: accumulate;
}

@media (max-width: 640px) {
  .c-affinity-bar { height: 6px; }
  .c-affinity-bar:hover { height: 8px; }
  .chat-affinity-bar { height: 6px; }
  .chat-affinity-label, .c-affinity-label { font-size: 9px; }
}

/* Emotes MSN animées — uniquement dans le corps des messages (pas la barre d'emotes). */
.msg-body .msn-emote { display: inline-block; line-height: 1; vertical-align: -0.12em; font-size: 1.2em; }
.msg-body .msn-emote-fan {
  display: inline-flex; align-items: flex-end; gap: 0.02em;
  vertical-align: -0.15em; margin: 0 0.05em;
}
.msg-body .msn-emote-fan > .msn-emote {
  transform: rotate(var(--fan-angle, 0deg));
  animation-delay: var(--fan-delay, 0s);
}
.msg-body .msn-emote-clown { animation: msn-wobble 0.55s ease-in-out infinite; }
.msg-body .msn-emote-wizard { animation: msn-sparkle 1.1s ease-in-out infinite; }
.msg-body .msn-emote-alien { animation: msn-float 1.6s ease-in-out infinite; }
.msg-body .msn-emote-dino { animation: msn-stomp 0.65s ease-in-out infinite; }
.msg-body .msn-emote-robot { animation: msn-glitch 0.35s steps(2) infinite; }
.msg-body .msn-emote-acid { animation: msn-acid 2.2s linear infinite; }
.msg-body .msn-emote-heart { animation: msn-pulse 0.9s ease-in-out infinite; }
@keyframes msn-wobble {
  0%, 100% { transform: rotate(-10deg) scale(1); }
  50% { transform: rotate(10deg) scale(1.12); }
}
@keyframes msn-sparkle {
  0%, 100% { transform: translateY(0) scale(1); filter: brightness(1); }
  50% { transform: translateY(-4px) scale(1.08); filter: brightness(1.35) drop-shadow(0 0 4px #b8a0ff); }
}
@keyframes msn-float {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-6px) rotate(8deg); }
}
@keyframes msn-stomp {
  0%, 100% { transform: translateY(0) scaleY(1); }
  35% { transform: translateY(3px) scaleY(0.82); }
  55% { transform: translateY(-5px) scaleY(1.12); }
}
@keyframes msn-glitch {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(-2px, 1px); }
  75% { transform: translate(2px, -1px); }
}
@keyframes msn-acid {
  0% { transform: rotate(0deg) scale(1); filter: hue-rotate(0deg) saturate(1.4); }
  50% { transform: rotate(180deg) scale(1.15); filter: hue-rotate(180deg) saturate(2); }
  100% { transform: rotate(360deg) scale(1); filter: hue-rotate(360deg) saturate(1.4); }
}
@keyframes msn-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.18); }
}

.composer { display: flex; gap: 6px; padding: 8px; background: rgba(248, 251, 255, 0.9); align-items: center; flex-wrap: wrap; flex-shrink: 0; }
.typing-line, .foot-quick-bar { flex-shrink: 0; }
.wizz-btn {
  flex: 0 0 auto; padding: 6px 10px; min-height: 36px; min-width: 72px;
  font-weight: bold; font-size: 13px; font-family: inherit; cursor: pointer;
  color: #8a1030; background: linear-gradient(180deg, #fff5a8 0%, #ffd54f 55%, #ffb300 100%);
  border: 2px solid #c0203a; border-radius: 8px; box-shadow: 0 2px 0 #a01830;
}
.wizz-btn:hover { filter: brightness(1.06); background: #fff8c0; }
.wizz-btn:active { transform: translateY(1px); box-shadow: 0 1px 0 #a01830; }
.wizz-btn:disabled { opacity: 0.55; cursor: not-allowed; filter: none; transform: none; }
.wizz-deny {
  position: fixed; left: 50%; top: 42%; z-index: 120;
  transform: translate(-50%, -50%) scale(var(--wizz-deny-scale, 1));
  font-size: clamp(2rem, 8vw, 4.5rem); font-weight: 900; letter-spacing: 0.08em;
  color: #fff; text-shadow: 0 0 12px #c0203a, 0 4px 0 #8a1030, 0 8px 24px rgba(0,0,0,.45);
  pointer-events: none; opacity: 0; transition: opacity 0.12s ease, transform 0.12s ease;
}
.wizz-deny.visible { opacity: 1; }
.file-btn { padding: 4px 8px; cursor: pointer; border: 1px solid var(--bevel-dark); border-radius: 4px; background: #fff; }
.pending-requests { padding: 8px; background: var(--sky-yellow); font-size: 12px; }
.pending-row { margin: 4px 0; }
.pending-row button { margin-left: 6px; padding: 2px 8px; cursor: pointer; }
.msg-input { flex: 1; resize: none; padding: 6px; border: 1px solid var(--bevel-dark); border-radius: 5px; font-family: inherit; font-size: 13px; }
.send-btn { padding: 0 14px; font-weight: bold; color: #fff; background: var(--msn-grad); border: 1px solid #1d5bb0; border-radius: 6px; cursor: pointer; }
.send-btn:hover { filter: brightness(1.08); }

/* ---------------- Toasts "X vient de se connecter" ---------------- */
#toasts { position: fixed; right: 12px; bottom: 12px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast {
  width: 220px; padding: 8px 10px; color: #fff; font-size: 12px;
  background: var(--msn-grad); border: 1px solid #1d5bb0; border-radius: 6px;
  box-shadow: 0 4px 14px rgba(0,0,0,.4); animation: slidein .3s ease;
}
.toast b { color: var(--sky-yellow); }
@keyframes slidein { from { transform: translateX(120%); } }

/* ---------------- Mobile : navigation single-pane ---------------- */
@media (max-width: 760px) {
  #app { flex-direction: column; padding: 0; gap: 0; min-height: 100dvh; }
  .mob-only { display: inline-block !important; }
  .contact-window, .chat-window { width: 100vw; border-radius: 0; max-height: none; border-left: 0; border-right: 0; }
  .login-window { width: 100vw; margin: 0; min-height: 100dvh; border-radius: 0; }
  #chats { width: 100%; min-height: 0; flex: 1; }
  .chat-window { min-height: 100dvh; display: none; }
  .chat-window.mobile-active { display: flex; }
  .contact-window { display: none; flex: 1; min-height: 100dvh; }
  .contact-window.mobile-active { display: flex; flex-direction: column; }
  .contact-window.floating, .chat-window.floating { position: relative; left: auto !important; top: auto !important; width: 100vw !important; height: auto !important; }
  .contacts-scroll { max-height: none; flex: 1; }
  .room-topic-input { max-width: none; flex: 1; }
  .toolbar button, .send-btn, .wizz-btn, .emote-bar button { min-height: 40px; min-width: 40px; font-size: 14px; }
  .msg-input { font-size: 16px; min-height: 44px; }
  .contact-row, .room-row { padding: 8px 10px; }
  .contact-row .c-personal, .contact-row .c-handle { display: none; }
  .contact-row .c-avatar { width: 56px; height: 52px; }
  .me-card { padding: 8px; align-items: flex-end; }
  .me-avatar, .peer-avatar { width: 80px; height: 66px; min-width: 80px; }
  .pixel-avatar-wrap.pixel-avatar-lg { width: 80px; height: 66px; }
  .pixel-avatar-wrap.pixel-avatar-md { width: 56px; height: 52px; }
  .pixel-avatar-md .profile-photo-avatar { font-size: 1.54rem; }
  .pixel-avatar-lg .profile-photo-avatar { font-size: 2.1rem; }
  .bridges-bar { display: none; }
  .sidebar-filters { display: flex !important; }
  .group-head { padding: 6px 10px; font-size: 12px; }
  .room-preview { max-width: 70vw; }
  .title-bar { padding: 8px 10px; }
  .title-bar-controls > span,
  .title-bar-controls > button { width: 32px; height: 28px; line-height: 26px; font-size: 14px; }
  .title-bar-controls .color-btn { width: 32px; height: 28px; line-height: 26px; }
  .contact-color-dot { width: 12px; height: 12px; }
  #toasts { left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); }
  .toast { width: auto; max-width: 100%; }
  .resize-grip { display: none; }
}

/* Tablette tactile : fenêtres flottantes déplaçables (comme desktop) */
@media (max-width: 760px) {
  html.touch-floating #app {
    position: relative;
    flex-direction: row;
    flex-wrap: wrap;
    padding: 8px;
    gap: 8px;
    min-height: 100dvh;
    overflow: hidden;
  }
  html.touch-floating #app #chats {
    position: absolute;
    inset: 0;
    pointer-events: none;
    width: 100%;
    height: 100%;
    min-height: 0;
  }
  html.touch-floating #app .contact-window.floating,
  html.touch-floating #app .chat-window.floating {
    position: absolute !important;
    display: flex !important;
    left: auto !important;
    top: auto !important;
    width: auto !important;
    height: auto !important;
    min-height: 260px;
    max-height: 88vh;
    pointer-events: auto;
    border-radius: 8px;
  }
  html.touch-floating #app .contact-window {
    display: flex !important;
    flex: none;
    min-height: 280px;
  }
  html.touch-floating #app .chat-window {
    display: flex !important;
    min-height: 0;
  }
  html.touch-floating #app .chat-window.mobile-active {
    display: flex !important;
  }
  html.touch-floating #app .resize-grip { display: block; }
  html.touch-floating .title-bar { touch-action: none; }
  html.touch-floating .title-bar.dragging { cursor: grabbing; }
  .emote-bar.emote-bar-scroll {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    max-height: none;
    padding-bottom: 4px;
    touch-action: pan-x;
    scroll-snap-type: x proximity;
  }
  .emote-bar.emote-bar-scroll button {
    flex: 0 0 auto;
    scroll-snap-align: start;
  }
  .emote-bar-toggle { min-height: 36px; }
}

.call-overlay {
  position: fixed; inset: 0; z-index: 9500; display: flex; align-items: center; justify-content: center;
  background: rgba(10, 30, 70, 0.55); padding: 16px;
}
.call-window { width: min(360px, 94vw); }
.call-body { padding: 14px 16px 18px; background: var(--panel); }
.call-status { margin: 0 0 12px; font-weight: bold; text-align: center; color: var(--msn-blue); }
.call-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.call-accept-btn { flex: 1; min-width: 120px; }
.title-bar-controls .call-audio-btn,
.title-bar-controls .call-video-btn { cursor: pointer; padding: 0 4px; }

.chat-window.in-call .chat-peer { border-bottom-color: var(--msn-blue); }
.call-strip {
  flex-shrink: 0; border-bottom: 1px solid var(--bevel-dark); background: linear-gradient(180deg, #e8f0ff, #dce8ff);
}
.call-strip-videos {
  position: relative;
  width: 100%;
  height: 180px;
  min-height: 88px;
  max-height: min(72vh, 520px);
  background: #0a1628;
  overflow: hidden;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.call-strip-videos.audio-mode {
  height: 0 !important;
  min-height: 0;
  border-bottom: 0;
}
.call-video-stage {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}
.call-strip-remote {
  display: block;
  background: #000;
}
.call-strip-remote.audio-only {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  clip: rect(0, 0, 0, 0);
}
.call-strip-remote.has-video {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  opacity: 1;
  clip: auto;
}
.call-strip-local {
  position: absolute;
  right: 8px;
  bottom: 8px;
  width: 28%;
  max-width: 112px;
  aspect-ratio: 4 / 3;
  max-height: 32%;
  border: 2px solid #fff;
  border-radius: 4px;
  object-fit: contain;
  background: #000;
  z-index: 2;
}
.call-video-resize {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 24px;
  height: 24px;
  cursor: nwse-resize;
  z-index: 4;
  touch-action: none;
  background: linear-gradient(135deg, transparent 45%, rgba(100, 160, 255, 0.9) 45%);
}
.call-strip-videos.resizing .call-video-resize {
  background: linear-gradient(135deg, transparent 45%, rgba(255, 220, 80, 0.95) 45%);
}
.call-strip-bar {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 6px 8px; font-size: 11px;
}
.call-strip-status { flex: 1; min-width: 100px; font-weight: bold; color: var(--msn-blue); }
.call-ctrl-btn {
  padding: 4px 8px; cursor: pointer; border: 1px solid var(--bevel-dark);
  border-radius: 4px; background: var(--panel); font-size: 14px; line-height: 1;
}
.call-ctrl-btn.active { background: #e8f4ff; border-color: var(--msn-blue); }
.call-screen-btn.active { background: #e8ffe8; border-color: #308030; }
.call-pitch-btn.active { background: #fff0f6; border-color: #d6336c; }
.call-vol-label {
  display: inline-flex; align-items: center; gap: 4px; font-size: 12px;
}
.call-volume { width: 72px; vertical-align: middle; accent-color: var(--msn-blue); }

/* --- Appels de salon (multi-parties) --- */
.room-call-banner {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 6px 8px; font-size: 12px;
  background: #fff8e1; border-bottom: 1px solid var(--bevel-dark);
}
.room-call-banner-join {
  margin-left: auto; cursor: pointer; padding: 3px 10px;
  border: 1px solid var(--msn-blue); border-radius: 4px;
  background: var(--msn-blue); color: #fff; font-weight: bold;
}
.room-call-strip { border-bottom: 1px solid var(--bevel-dark); background: var(--panel); }
.room-call-grid {
  display: grid; gap: 4px; padding: 6px;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
}
.room-call-tile {
  position: relative; background: #000; border-radius: 6px; overflow: hidden;
  aspect-ratio: 4 / 3; display: flex; align-items: center; justify-content: center;
}
.room-call-tile video { width: 100%; height: 100%; object-fit: cover; }
.room-call-tile.audio-only video { display: none; }
.room-call-tile.audio-only::before {
  content: '🎙️'; font-size: 28px; opacity: 0.85;
}
.room-call-tile-name {
  position: absolute; left: 4px; bottom: 3px;
  font-size: 10px; color: #fff; background: rgba(0, 0, 0, 0.55);
  padding: 1px 5px; border-radius: 3px; max-width: 90%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Boutons d'action sur une vidéo (tuiles salon + stage DM) */
.room-call-tile-actions, .call-video-actions {
  position: absolute; top: 4px; right: 4px; display: flex; gap: 3px;
  opacity: 0; transition: opacity 0.15s; z-index: 3;
}
.room-call-tile:hover .room-call-tile-actions,
.call-video-stage:hover .call-video-actions,
.room-call-tile-actions:focus-within, .call-video-actions:focus-within { opacity: 1; }
.tile-act {
  cursor: pointer; border: none; border-radius: 4px; line-height: 1;
  background: rgba(0, 0, 0, 0.55); color: #fff; font-size: 13px; padding: 3px 5px;
}
.tile-act:hover { background: rgba(0, 0, 0, 0.8); }
.tile-act.active { background: var(--msn-blue); }
.call-video-stage { position: relative; }
/* Toujours accessibles au tactile (pas de hover) */
@media (hover: none) {
  .room-call-tile-actions, .call-video-actions { opacity: 1; }
}

/* Épinglage / spotlight : la tuile épinglée passe en grand, les autres en vignettes */
.room-call-grid.has-pin { display: flex; flex-wrap: wrap; align-content: flex-start; }
.room-call-grid.has-pin .room-call-tile { flex: 0 0 84px; aspect-ratio: 4 / 3; }
.room-call-grid.has-pin .room-call-tile.pinned {
  flex: 1 1 100%; aspect-ratio: 16 / 9; order: -1;
}

/* Barre d'affinité dans la fenêtre de discussion */
.chat-affinity-bar {
  margin-top: 3px; height: 7px; border-radius: 4px; background: rgba(0, 0, 0, 0.08);
  overflow: hidden; width: 110px; position: relative;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.1);
  transition: width 0.4s ease;
}
.chat-affinity-fill {
  height: 100%; border-radius: 4px; opacity: 0.95;
  background: linear-gradient(90deg, var(--aff-fill, currentColor), var(--sky-pink, #ff5fa2));
  transition: width 0.4s ease, opacity 0.3s;
  box-shadow: 0 0 6px rgba(255, 95, 162, 0.3);
}
.chat-affinity-bar:hover .chat-affinity-fill { opacity: 1; }
.chat-affinity-label {
  display: block; font-size: 10px; font-weight: bold; margin-top: 1px;
}
