/* messaging.css — Écran Messagerie (repris du handoff design_handoff_messagerie).
   Les polices réutilisent celles déjà en place sur le site (--mm-font-*),
   aucune police externe n'est ajoutée. */

:root {
  --indigo-50:  oklch(97.5% 0.012 280);
  --indigo-100: oklch(94%   0.025 280);
  --indigo-200: oklch(88%   0.045 280);
  --indigo-400: oklch(68%   0.13  280);
  --indigo-500: oklch(58%   0.165 280);
  --indigo-600: oklch(50%   0.18  280);
  --indigo-700: oklch(42%   0.17  280);

  --msg-ink:       oklch(18% 0.025 280);
  --msg-ink-2:     oklch(32% 0.025 280);
  --msg-muted:     oklch(52% 0.018 280);
  --msg-muted-2:   oklch(72% 0.012 280);
  --msg-hairline:  oklch(91% 0.008 280);
  --msg-surface:   oklch(99.2% 0.004 90);
  --msg-surface-2: oklch(97% 0.008 88);
  --msg-surface-3: oklch(94% 0.012 88);
  --msg-white:     #ffffff;

  --msg-radius:    14px;
  --msg-radius-lg: 20px;
  --msg-radius-xl: 28px;

  --msg-shadow-sm: 0 1px 2px oklch(20% 0.05 280 / 0.06);

  /* Polices : on garde celles du site (définies via main-menu.js) */
  --msg-font-display: var(--mm-font-display, "Plus Jakarta Sans", system-ui, sans-serif);
  --msg-font-ui:      var(--mm-font-ui, "Plus Jakarta Sans", system-ui, sans-serif);
  --msg-font-mono:    var(--mm-font-mono, "JetBrains Mono", ui-monospace, monospace);
}

body {
  font-family: var(--msg-font-ui);
  background: #f0f2f5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  color: var(--msg-ink);
  /* Coupe le scroll-chaining global : le geste de scroll d'un panneau interne
     (fil, liste) ne déclenche pas de scroll/rebond de la page dans la WebView. */
  overscroll-behavior: none;
}

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(102, 126, 234, 0.3); border-radius: 3px; }

/* ===== PAGE WRAPPER ===== */
.msg-page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.25rem;
}

/* ============================================================
   SHELL
   ============================================================ */
.msg-shell {
  display: grid;
  grid-template-columns: 340px 1fr;
  /* minmax(0,1fr) : la ligne ne peut pas dépasser la hauteur du shell,
     sinon un long fil de discussion pousse le composer hors de la zone visible. */
  grid-template-rows: minmax(0, 1fr);
  /* viewport - topnav - fil d'Ariane - padding de .msg-page.
     --app-vh : hauteur réelle du viewport injectée en px par messaging.html
     (window.innerHeight). Indispensable car dans la WebView Android, 100vh/100dvh
     CSS calculent à 0 → le shell retombait sur min-height (480px), coupait le fil
     et empêchait de scroller la conversation. Fallback vh pour un navigateur
     classique servi sans le script (ordre : le dernier valide gagne). */
  height: calc(100vh - 62px - 42px - 2.5rem);
  height: calc(100dvh - 62px - 42px - 2.5rem);
  height: calc(var(--app-vh, 100vh) - 62px - 42px - 2.5rem);
  min-height: 480px;
  border: 1px solid var(--msg-hairline);
  border-radius: var(--msg-radius-xl);
  overflow: hidden;
  background: var(--msg-white);
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.msg-sidebar {
  display: flex; flex-direction: column;
  border-right: 1px solid var(--msg-hairline);
  background: var(--msg-surface-2);
  min-height: 0;
  min-width: 0;
}
.msg-sidebar-head {
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--msg-hairline);
}
.msg-sidebar-head h2 {
  font-family: var(--msg-font-display);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 12px;
  color: var(--msg-ink);
}
.msg-sidebar-head .btn-primary { width: 100%; justify-content: center; }

/* Search */
.msg-search { position: relative; padding: 12px 14px 0; }
.msg-search .input {
  width: 100%;
  padding: 10px 14px 10px 38px;
  font-size: 14px;
  background: var(--msg-white);
  border: 1px solid var(--msg-hairline);
  border-radius: 10px;
  outline: none;
  font-family: inherit;
  color: var(--msg-ink);
  box-sizing: border-box;
}
.msg-search .input:focus {
  border-color: var(--indigo-400);
  box-shadow: 0 0 0 4px color-mix(in oklab, var(--indigo-500), transparent 88%);
}
.msg-search .input-icon {
  position: absolute;
  left: 28px;
  top: 50%;
  transform: translateY(calc(-50% + 6px));
  color: var(--msg-muted);
  pointer-events: none;
}

.msg-list {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 8px 8px 16px;
}
.msg-list-section {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--msg-muted-2);
  padding: 14px 12px 6px;
}

/* Conversation row */
.msg-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
  transition: background .12s, box-shadow .12s, transform .12s, border-color .12s;
  border: 1px solid transparent;
  background: transparent;
  width: 100%;
  text-align: left;
  font-family: inherit;
  color: inherit;
}
.msg-row:hover {
  background: var(--msg-white);
  border-color: var(--msg-hairline);
  box-shadow: var(--msg-shadow-sm);
}
.msg-row.is-active {
  background: var(--indigo-50);
  border-color: color-mix(in oklab, var(--indigo-400), transparent 60%);
}
.msg-row.is-active:hover { background: var(--indigo-100); }

.msg-row .av {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, oklch(68% 0.13 280), oklch(42% 0.17 280));
  color: white;
  display: grid; place-items: center;
  font-weight: 700;
  font-size: 15px;
  flex-shrink: 0;
  position: relative;
  font-family: var(--msg-font-display);
}
.msg-row .av img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.msg-row .av .status {
  position: absolute;
  bottom: -1px; right: -1px;
  width: 12px; height: 12px;
  border-radius: 50%;
  border: 2px solid var(--msg-surface-2);
  background: var(--msg-muted-2);
}
.msg-row.is-active .av .status { border-color: var(--indigo-50); }
.msg-row .av .status.online { background: oklch(70% 0.16 150); }

.msg-row .body { flex: 1; min-width: 0; }
.msg-row .top-line {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 8px;
}
.msg-row .name {
  font-weight: 700;
  font-size: 14px;
  color: var(--msg-ink);
  white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.msg-row .time {
  font-size: 11px;
  color: var(--msg-muted);
  font-family: var(--msg-font-mono);
  flex-shrink: 0;
}
.msg-row.has-unread .time { color: var(--indigo-600); font-weight: 700; }
.msg-row .preview {
  font-size: 13px;
  color: var(--msg-muted);
  white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
  margin-top: 2px;
}
.msg-row.has-unread .preview { color: var(--msg-ink-2); font-weight: 600; }
.msg-row .preview .me { color: var(--msg-muted-2); font-weight: 500; }

.msg-row .badge-count {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--indigo-600);
  color: white;
  font-size: 11px;
  font-weight: 700;
  margin-left: 8px;
  flex-shrink: 0;
}
.msg-row .badge-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--indigo-600);
  margin-left: 8px;
  flex-shrink: 0;
}

.msg-list-empty {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--msg-muted);
}
.msg-list-empty .emoji { font-size: 2.5rem; }
.msg-list-empty h3 { font-family: var(--msg-font-display); color: var(--msg-ink-2); margin: 0.5rem 0 0.25rem; font-size: 1rem; }
.msg-list-empty p { font-size: 0.85rem; margin: 0; }

/* ============================================================
   CHAT PANE
   ============================================================ */
.msg-chat {
  display: flex; flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--msg-white);
}

.msg-chat-head {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--msg-hairline);
  background: var(--msg-white);
  flex-shrink: 0;
}
.msg-chat-back {
  display: none;
  width: 36px; height: 36px;
  border-radius: 10px;
  border: 1px solid var(--msg-hairline);
  background: var(--msg-surface-2);
  color: var(--msg-ink);
  align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.msg-chat-head .av {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, oklch(68% 0.13 280), oklch(42% 0.17 280));
  color: white;
  display: grid; place-items: center;
  font-family: var(--msg-font-display);
  font-weight: 700;
  font-size: 15px;
  flex-shrink: 0;
  position: relative;
}
.msg-chat-head .av img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.msg-chat-head .av .status {
  position: absolute;
  bottom: -1px; right: -1px;
  width: 12px; height: 12px;
  border-radius: 50%;
  border: 2px solid var(--msg-white);
  background: var(--msg-muted-2);
}
.msg-chat-head .av .status.online { background: oklch(70% 0.16 150); }

.msg-chat-head .who { flex: 1; min-width: 0; }
.msg-chat-head .who .name {
  font-family: var(--msg-font-display);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.015em;
  line-height: 1.1;
  color: var(--msg-ink);
}
.msg-chat-head .who .meta {
  font-size: 12px;
  color: var(--msg-muted);
  margin-top: 4px;
  display: flex; align-items: center; gap: 6px;
  flex-wrap: wrap;
}
.msg-chat-head .who .meta .online-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: oklch(70% 0.16 150);
  display: inline-block;
}
.msg-chat-head .who .meta a {
  color: var(--indigo-600);
  font-weight: 600;
  text-decoration: none;
}
.msg-chat-head .who .meta a:hover { text-decoration: underline; }
.msg-chat-head .actions { display: flex; gap: 6px; }

.icon-btn {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: 10px;
  background: var(--msg-surface-2);
  border: 1px solid var(--msg-hairline);
  color: var(--msg-ink-2);
  cursor: pointer;
}
.icon-btn:hover { background: var(--msg-surface-3); }

/* ============================================================
   THREAD
   ============================================================ */
.msg-thread {
  flex: 1;
  overflow-y: auto;
  /* contain : le scroll ne « remonte » pas au body de la page dans la WebView
     Android (sinon, arrivé en haut du fil, le geste de remontée est happé par
     la page et on ne peut plus scroller le fil). touch : inertie fluide. */
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 22px 28px 16px;
  display: flex; flex-direction: column;
  gap: 4px;
  background: var(--msg-surface);
}

.msg-day {
  align-self: center;
  display: inline-flex;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--msg-surface-2);
  border: 1px solid var(--msg-hairline);
  font-size: 11px;
  font-weight: 700;
  color: var(--msg-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin: 18px auto 12px;
}
.msg-day:first-child { margin-top: 0; }

.msg-line {
  display: flex; align-items: flex-end; gap: 8px;
  max-width: 78%;
}
.msg-line.is-me {
  align-self: flex-end;
  flex-direction: row-reverse;
}
.msg-line.is-other { align-self: flex-start; }
.msg-line .av {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, oklch(68% 0.13 280), oklch(42% 0.17 280));
  color: white;
  display: grid; place-items: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
  overflow: hidden;
}
.msg-line .av img { width: 100%; height: 100%; object-fit: cover; }
.msg-line .av.hidden { visibility: hidden; }

/* Bubble */
.bubble {
  padding: 9px 14px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--msg-ink);
  background: var(--msg-white);
  border: 1px solid var(--msg-hairline);
  word-wrap: break-word;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  position: relative;
  max-width: 100%;
}
.msg-line.is-me .bubble {
  background: linear-gradient(135deg, var(--indigo-500), var(--indigo-700));
  color: white;
  border-color: transparent;
  border-bottom-right-radius: 6px;
}
.msg-line.is-other .bubble { border-bottom-left-radius: 6px; }
.bubble a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: color-mix(in oklab, currentColor, transparent 60%);
  text-underline-offset: 2px;
}

/* Wrapper d'une ligne contenant bulle + preview */
.msg-line .stack {
  display: flex; flex-direction: column; gap: 2px;
  min-width: 0;
}
.msg-line.is-me .stack { align-items: flex-end; }

/* Link preview card */
.link-preview {
  width: 320px;
  max-width: 100%;
  border-radius: 14px;
  overflow: hidden;
  background: var(--msg-white);
  border: 1px solid var(--msg-hairline);
  margin-top: 2px;
  display: block;
  text-decoration: none;
  color: inherit;
}
.link-preview .cover-art {
  aspect-ratio: 16/9;
  overflow: hidden;
  position: relative;
  background: var(--msg-surface-3);
}
.link-preview .cover-art img { width: 100%; height: 100%; object-fit: cover; display: block; }
.link-preview-body { padding: 12px 14px; }
.link-preview .source {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: var(--msg-muted);
}
.link-preview .ttl {
  font-family: var(--msg-font-display);
  font-weight: 700;
  font-size: 14px;
  margin-top: 4px;
  color: var(--msg-ink);
  letter-spacing: -0.01em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.link-preview .desc {
  font-size: 12px;
  color: var(--msg-muted);
  margin-top: 4px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Timestamps */
.msg-time {
  font-size: 11px;
  color: var(--msg-muted-2);
  margin: 4px 4px 8px;
  display: flex; align-items: center; gap: 4px;
}
.msg-time.is-me { align-self: flex-end; }
.msg-time.is-other { align-self: flex-start; margin-left: 40px; }
.msg-time .read-check { color: oklch(60% 0.18 230); display: inline-flex; }

/* Bouton supprimer un message (au survol) */
.msg-line .msg-del {
  border: 0;
  background: transparent;
  color: var(--msg-muted-2);
  cursor: pointer;
  font-size: 13px;
  padding: 2px;
  opacity: 0;
  transition: opacity .12s, color .12s;
  align-self: center;
  flex-shrink: 0;
}
.msg-line:hover .msg-del { opacity: 1; }
.msg-line .msg-del:hover { color: oklch(58% 0.2 25); }

/* Typing indicator */
.typing {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 9px 14px;
  background: var(--msg-white);
  border: 1px solid var(--msg-hairline);
  border-radius: 18px;
  border-bottom-left-radius: 6px;
}
.typing .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--msg-muted);
  animation: typing-bounce 1.2s infinite ease-in-out;
}
.typing .dot:nth-child(2) { animation-delay: .15s; }
.typing .dot:nth-child(3) { animation-delay: .3s; }
@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* ============================================================
   COMPOSER
   ============================================================ */
.msg-composer {
  padding: 14px 22px 18px;
  border-top: 1px solid var(--msg-hairline);
  background: var(--msg-white);
  flex-shrink: 0;
  position: relative;
}
.composer-row {
  display: flex; align-items: flex-end; gap: 10px;
  background: var(--msg-surface-2);
  border: 1px solid var(--msg-hairline);
  border-radius: 22px;
  padding: 6px 6px 6px 16px;
  transition: border-color .15s, box-shadow .15s;
}
.composer-row:focus-within {
  border-color: var(--indigo-400);
  box-shadow: 0 0 0 4px color-mix(in oklab, var(--indigo-500), transparent 88%);
}
.composer-row .composer-area {
  flex: 1;
  min-width: 0;
  width: 100%;
  min-height: 24px;
  max-height: 160px;
  padding: 9px 0;
  font-size: 14px;
  border: 0; outline: 0; resize: none;
  background: transparent;
  color: var(--msg-ink);
  font-family: inherit;
  line-height: 1.4;
  box-sizing: border-box;
}
.composer-row .composer-area::placeholder { color: var(--msg-muted); }

.composer-actions { display: flex; align-items: center; gap: 4px; }
.composer-icon-btn {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: transparent;
  border: 0;
  display: grid; place-items: center;
  color: var(--msg-muted);
  cursor: pointer;
}
.composer-icon-btn:hover { background: var(--msg-surface-3); color: var(--msg-ink); }

.composer-send {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--indigo-600);
  color: white;
  border: 0;
  display: grid; place-items: center;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: 0 4px 14px -4px var(--indigo-500);
  transition: transform .15s, background .15s;
}
.composer-send:hover { background: var(--indigo-700); transform: scale(1.05); }
.composer-send:disabled {
  background: var(--msg-muted-2);
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.composer-hint {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 8px;
  font-size: 11px;
  color: var(--msg-muted);
  padding: 0 4px;
}
.composer-hint kbd {
  font-family: var(--msg-font-mono);
  font-size: 10px;
  padding: 2px 5px;
  border-radius: 4px;
  background: var(--msg-surface-2);
  border: 1px solid var(--msg-hairline);
  border-bottom-width: 2px;
  color: var(--msg-ink-2);
}

/* ===== EMOJI PICKER ===== */
.emoji-picker {
  display: none;
  position: absolute;
  bottom: 100%;
  right: 22px;
  margin-bottom: 8px;
  width: 320px;
  max-width: calc(100% - 44px);
  background: var(--msg-white);
  border: 1px solid var(--msg-hairline);
  border-radius: 16px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.16);
  z-index: 20;
  overflow: hidden;
}
.emoji-picker.active { display: block; }
.emoji-categories {
  display: flex;
  gap: 2px;
  padding: 8px;
  border-bottom: 1px solid var(--msg-hairline);
}
.emoji-category-btn {
  flex: 1;
  border: 0;
  background: transparent;
  font-size: 18px;
  padding: 6px 0;
  border-radius: 8px;
  cursor: pointer;
}
.emoji-category-btn:hover { background: var(--msg-surface-2); }
.emoji-category-btn.active { background: var(--indigo-50); }
.emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  padding: 8px;
  max-height: 220px;
  overflow-y: auto;
}
.emoji-item {
  border: 0;
  background: transparent;
  font-size: 20px;
  padding: 4px 0;
  border-radius: 8px;
  cursor: pointer;
}
.emoji-item:hover { background: var(--msg-surface-2); }

/* ============================================================
   EMPTY STATE (chat)
   ============================================================ */
.msg-empty {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 40px;
  text-align: center;
  background: var(--msg-surface);
}
.msg-empty .emoji { font-size: 64px; margin-bottom: 16px; opacity: 0.7; }
.msg-empty h3 {
  font-family: var(--msg-font-display);
  font-size: 22px;
  letter-spacing: -0.02em;
  margin: 0 0 8px;
  color: var(--msg-ink);
}
.msg-empty p { color: var(--msg-muted); margin: 0; max-width: 360px; line-height: 1.5; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  padding: 9px 16px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 14px;
  border: 1px solid transparent;
  background: var(--msg-surface-3);
  color: var(--msg-ink);
  display: inline-flex; align-items: center; gap: 8px;
  cursor: pointer;
  font-family: inherit;
}
.btn-primary {
  background: var(--indigo-600);
  color: white;
  box-shadow: 0 1px 0 0 var(--indigo-700) inset,
              0 6px 20px -8px var(--indigo-500);
}
.btn-primary:hover { background: var(--indigo-700); }

/* ============================================================
   MODAL nouvelle conversation
   ============================================================ */
.modal {
  display: none;
  position: fixed; inset: 0;
  background: rgba(15, 10, 30, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 1000;
  place-items: center;
  padding: 24px 16px;
}
.modal.active { display: grid; }
.modal-content {
  background: var(--msg-white);
  border: 1px solid var(--msg-hairline);
  border-radius: var(--msg-radius-xl);
  width: 100%;
  max-width: 440px;
  /* Pas de 100vh/100dvh : se calcule à 0 en WebView Android → sheet écrasée
     et page figée. % seul (le parent est fixed;inset:0, hauteur = viewport). */
  max-height: 90%;
  display: flex; flex-direction: column;
  overflow: hidden;
  box-shadow: 0 30px 60px -25px rgba(20,16,40,0.35);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--msg-hairline);
  background: var(--msg-surface);
}
.modal-header h3 {
  font-family: var(--msg-font-display);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.015em;
  margin: 0;
  color: var(--msg-ink);
}
.modal-close {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 1px solid var(--msg-hairline);
  background: var(--msg-surface-2);
  color: var(--msg-muted);
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
  display: grid; place-items: center;
}
.modal-close:hover { background: var(--msg-surface-3); color: var(--msg-ink); }
.modal-body {
  padding: 14px;
  overflow-y: auto;
}

.friends-list { display: flex; flex-direction: column; gap: 4px; }
.friend-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
  transition: background .12s;
  border: 1px solid transparent;
}
.friend-item:hover { background: var(--msg-surface-2); border-color: var(--msg-hairline); }
.friend-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, oklch(68% 0.13 280), oklch(42% 0.17 280));
  color: white;
  display: grid; place-items: center;
  font-weight: 700;
  font-family: var(--msg-font-display);
  flex-shrink: 0;
  overflow: hidden;
}
.friend-avatar img { width: 100%; height: 100%; object-fit: cover; }
.friend-name { font-weight: 600; font-size: 14px; color: var(--msg-ink); }

.modal-empty {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--msg-muted);
}
.modal-empty .emoji { font-size: 2.5rem; }
.modal-empty h3 { font-family: var(--msg-font-display); color: var(--msg-ink-2); margin: 0.5rem 0 0.25rem; font-size: 1rem; }
.modal-empty p { font-size: 0.85rem; margin: 0; }

.msg-loading { padding: 2rem; text-align: center; color: var(--msg-muted); font-size: 0.9rem; }

/* ============================================================
   RESPONSIVE — single pane on mobile
   ============================================================ */
@media (max-width: 720px) {
  .msg-page { padding: 0.6rem; }
  .msg-shell {
    grid-template-columns: minmax(0, 1fr);
    /* --app-vh (window.innerHeight) fiable en WebView ; vh/dvh en fallback. */
    height: calc(100vh - 56px - 38px - 1.2rem);
    height: calc(100dvh - 56px - 38px - 1.2rem);
    height: calc(var(--app-vh, 100vh) - 56px - 38px - 1.2rem);
    border-radius: var(--msg-radius-lg);
  }
  .msg-shell[data-pane="list"] .msg-chat { display: none; }
  .msg-shell[data-pane="chat"] .msg-sidebar { display: none; }
  .msg-chat-back { display: inline-flex; }
  .msg-chat-head { padding: 12px 14px; }
  .msg-thread { padding: 16px 14px 12px; }
  .msg-line { max-width: 86%; }
  .link-preview { width: 100%; }
  .msg-composer { padding: 12px 12px 16px; }
  .composer-hint { display: none; }
  .emoji-picker { right: 12px; }
}
