:root {
  --navy-950: #0A1F26;
  --navy-900: #0F2A32;
  --navy-800: #16394370;
  --teal-700: #1B4F5A;
  --teal-500: #2C7A8C;
  --coral-500: #FF6B4A;
  --coral-600: #F0552F;
  --cream-50: #FBF8F3;
  --cream-100: #F3EEE4;
  --ink-900: #1B2126;
  --ink-500: #5B6670;
  --line: #E7E1D6;
  --white: #FFFFFF;
  --font-display: 'Sora', sans-serif;
  --font-body: 'Inter', sans-serif;
}

[data-theme="dark"] {
  --cream-50: #16232A;
  --cream-100: #1C2B33;
  --ink-900: #EDEFF0;
  --ink-500: #9AAAB0;
  --line: #2A3C44;
  --white: #223138;
  --navy-950: #0A161B;
}
[data-theme="dark"] body { background: var(--cream-50); }
[data-theme="dark"] .msg-row.theirs .bubble { background: var(--white); color: var(--ink-900); }
[data-theme="dark"] .auth-card { background: var(--cream-50); }
[data-theme="dark"] .auth-form input { background: var(--white); color: var(--ink-900); border-color: var(--line); }

* { box-sizing: border-box; }

html, body {
  margin: 0;
  overflow-x: hidden;
  max-width: 100vw;
}
body {
  font-family: var(--font-body);
  color: var(--ink-900);
  background: var(--cream-50);
  transition: background-color .2s, color .2s;
}

/* ============ AUTH PAGES ============ */
.auth-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 20% 20%, #1B4F5A 0%, transparent 45%),
    radial-gradient(circle at 80% 80%, #FF6B4A 0%, transparent 40%),
    var(--navy-950);
  padding: 20px;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--cream-50);
  border-radius: 20px;
  padding: 40px 36px;
  box-shadow: 0 30px 60px rgba(0,0,0,0.35);
}

.auth-logo {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.3px;
  color: var(--teal-700);
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.auth-card h1 {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 800;
  margin: 0 0 20px;
  color: var(--ink-900);
}

.auth-error {
  background: #FDE8E4;
  color: var(--coral-600);
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 14px;
  margin-bottom: 16px;
}

.auth-form { display: flex; flex-direction: column; gap: 16px; }

.auth-form label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-500);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.auth-form input {
  font-family: var(--font-body);
  font-size: 15px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1.5px solid var(--line);
  background: var(--white);
  outline: none;
  transition: border-color .15s;
}
.auth-form input:focus { border-color: var(--teal-500); }

.btn-primary {
  margin-top: 6px;
  background: linear-gradient(135deg, var(--coral-500), var(--coral-600));
  color: white;
  border: none;
  padding: 13px;
  border-radius: 10px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  transition: transform .1s, box-shadow .15s;
}
.btn-primary:hover { box-shadow: 0 8px 20px rgba(255,107,74,0.35); transform: translateY(-1px); }

.auth-switch { text-align: center; font-size: 14px; color: var(--ink-500); margin-top: 22px; }
.auth-switch a { color: var(--teal-500); font-weight: 600; text-decoration: none; }

/* ============ APP LAYOUT ============ */
#app {
  display: grid;
  grid-template-columns: 340px 1fr;
  height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
  background: var(--navy-950);
  color: var(--cream-50);
  display: flex;
  flex-direction: column;
  border-right: 1px solid #0000;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 18px 14px;
}

.me { display: flex; align-items: center; gap: 10px; min-width: 0; }
.me-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.avatar {
  border-radius: 50%;
  background: linear-gradient(135deg, var(--coral-500), var(--teal-500));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  flex-shrink: 0;
}
.avatar-sm { width: 38px; height: 38px; font-size: 15px; }
.avatar-md { width: 46px; height: 46px; font-size: 18px; }

.avatar-c0 { background: linear-gradient(135deg, #FF6B4A, #F0552F); }
.avatar-c1 { background: linear-gradient(135deg, #2C7A8C, #1B4F5A); }
.avatar-c2 { background: linear-gradient(135deg, #C97B3D, #8C5A2B); }
.avatar-c3 { background: linear-gradient(135deg, #6E7FB5, #3F4E85); }
.avatar-c4 { background: linear-gradient(135deg, #4FA98A, #2C7A5E); }
.avatar-c5 { background: linear-gradient(135deg, #C9598E, #8C3A61); }
.avatar-lg { width: 84px; height: 84px; font-size: 30px; }

/* ---- Appels ---- */
.call-header-btn { background: var(--cream-100); color: var(--coral-600); margin-left: auto; display: none; }

.call-modal {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(10, 31, 38, 0.88);
  display: flex; align-items: center; justify-content: center;
}
.call-modal.hidden { display: none; }

.call-modal-card {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  color: white;
  text-align: center;
  padding: 20px;
}
.call-modal-name { font-family: var(--font-display); font-weight: 700; font-size: 20px; margin-top: 8px; }
.call-modal-sub { font-size: 14px; color: #B9C6C9; animation: pulse-dot 1.4s infinite; }

.call-modal-actions { display: flex; gap: 28px; margin-top: 26px; }
.call-action-btn {
  width: 60px; height: 60px;
  border-radius: 50%;
  border: none;
  font-size: 24px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: white;
}
.call-action-btn.accept { background: #3ECF8E; }
.call-action-btn.decline { background: #E24B4A; transform: rotate(135deg); }

.active-call-bar {
  position: fixed;
  top: 12px; left: 50%; transform: translateX(-50%);
  z-index: 90;
  display: flex; align-items: center; gap: 10px;
  background: var(--navy-950);
  color: white;
  padding: 8px 14px 8px 8px;
  border-radius: 999px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}
.active-call-bar.hidden { display: none; }
.active-call-info { margin-right: 6px; }
.active-call-name { font-size: 13px; font-weight: 600; line-height: 1.2; }
.active-call-status { font-size: 11px; color: #9FB0B5; line-height: 1.2; }

.call-bar-btn {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: none;
  background: #ffffff1f;
  color: white;
  font-size: 14px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.call-bar-btn.muted { background: var(--coral-500); }
.call-bar-btn.hangup { background: #E24B4A; transform: rotate(135deg); }

.sidebar-actions { display: flex; gap: 6px; }
.icon-btn {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: none;
  background: #ffffff14;
  color: var(--cream-50);
  font-size: 15px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s;
}
.icon-btn:hover { background: #ffffff28; }

.search-panel { padding: 0 18px 14px; }
.search-panel.hidden { display: none; }
#search-input {
  width: 100%;
  padding: 11px 14px;
  border-radius: 10px;
  border: none;
  background: #ffffff14;
  color: var(--cream-50);
  font-size: 14px;
  outline: none;
}
#search-input::placeholder { color: #9FB0B5; }

.search-results { margin-top: 8px; max-height: 220px; overflow-y: auto; }
.search-result-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 6px;
  border-radius: 8px;
  cursor: pointer;
}
.search-result-item:hover { background: #ffffff14; }
.search-result-name { font-size: 14px; font-weight: 600; }
.search-result-username { font-size: 12px; color: #9FB0B5; }
.search-add-btn {
  margin-left: auto;
  background: var(--coral-500);
  color: white;
  border: none;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 10px;
  cursor: pointer;
}

.contact-list { flex: 1; overflow-y: auto; padding: 6px 8px 14px; }
.empty-state { color: #9FB0B5; text-align: center; padding: 30px 14px; font-size: 13.5px; }

.contact-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border-radius: 12px;
  cursor: pointer;
  transition: background .15s;
  position: relative;
}
.contact-item:hover { background: #ffffff0f; }
.contact-item.active { background: linear-gradient(135deg, #1B4F5A80, #ffffff10); }

.contact-item-avatar-wrap { position: relative; flex-shrink: 0; }
.online-dot {
  position: absolute; bottom: 0; right: 0;
  width: 11px; height: 11px;
  border-radius: 50%;
  background: #3ECF8E;
  border: 2px solid var(--navy-950);
}

.contact-item-body { min-width: 0; flex: 1; }
.contact-item-name {
  font-weight: 600; font-size: 14.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.contact-item-preview {
  font-size: 12.5px; color: #93A5AA;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-top: 2px;
}
.contact-item-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; flex-shrink: 0; }
.contact-item-time { font-size: 11px; color: #7C8D92; }
.unread-badge {
  background: var(--coral-500);
  color: white;
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
  min-width: 18px;
  height: 18px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 5px;
}

.contact-delete-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px; height: 28px;
  border: none;
  border-radius: 50%;
  background: var(--navy-950);
  color: #9FB0B5;
  font-size: 13px;
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s, background .15s, color .15s;
  display: flex; align-items: center; justify-content: center;
}
.contact-item:hover .contact-delete-btn { opacity: 1; }
.contact-delete-btn:hover { background: var(--coral-500); color: white; }

/* ---- Chat area ---- */
.chat-area { background: var(--cream-100); position: relative; display: flex; flex-direction: column; }

.chat-empty {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--ink-500);
}
.chat-empty-icon { font-size: 46px; margin-bottom: 10px; }
.chat-window.hidden, .chat-empty.hidden { display: none; }
.chat-window { display: flex; flex-direction: column; height: 100%; }

.chat-header {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 22px;
  background: var(--cream-50);
  border-bottom: 1px solid var(--line);
}
.chat-header-info { flex: 1; min-width: 0; }
.chat-header-name {
  font-family: var(--font-display); font-weight: 700; font-size: 15.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-header-status {
  font-size: 12.5px; color: var(--ink-500); margin-top: 1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 22px 6% 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.msg-row { display: flex; margin-bottom: 6px; }
.msg-row.mine { justify-content: flex-end; }
.msg-row.theirs { justify-content: flex-start; }

.bubble {
  max-width: 62%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14.5px;
  line-height: 1.42;
  position: relative;
  word-wrap: break-word;
}
.msg-row.mine .bubble {
  background: linear-gradient(135deg, var(--coral-500), var(--coral-600));
  color: white;
  border-bottom-right-radius: 4px;
}
.msg-row.theirs .bubble {
  background: var(--white);
  color: var(--ink-900);
  border: 1px solid var(--line);
  border-bottom-left-radius: 4px;
}

.bubble img, .bubble video {
  max-width: 260px;
  border-radius: 10px;
  display: block;
  margin-bottom: 4px;
}

.bubble-deleted {
  opacity: 0.65;
  font-style: italic;
}

.msg-delete-btn {
  position: absolute;
  top: -10px;
  right: -10px;
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--ink-500);
  font-size: 11px;
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s;
  display: flex; align-items: center; justify-content: center;
}
.msg-row.mine { position: relative; }
.bubble { position: relative; }
.msg-row.mine:hover .msg-delete-btn { opacity: 1; }

.bubble-meta {
  font-size: 10.5px;
  opacity: 0.75;
  margin-top: 3px;
  text-align: right;
}

.message-form {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  background: var(--cream-50);
  border-top: 1px solid var(--line);
}

.attach-btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--cream-100);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  font-size: 17px;
  flex-shrink: 0;
}

#message-input {
  flex: 1;
  padding: 12px 16px;
  border-radius: 22px;
  border: 1.5px solid var(--line);
  background: var(--white);
  font-size: 14.5px;
  outline: none;
  font-family: var(--font-body);
}
#message-input:focus { border-color: var(--teal-500); }

.btn-send {
  width: 42px; height: 42px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--coral-500), var(--coral-600));
  color: white;
  font-size: 16px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}

#btn-voice {
  border: none;
  user-select: none;
  touch-action: none;
}
#btn-voice.recording {
  background: var(--coral-500);
  color: white;
}

.voice-recording {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 20px 14px;
  font-size: 13px;
  color: var(--coral-600);
  background: var(--cream-50);
}
.voice-recording.hidden { display: none; }
.voice-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--coral-500);
  animation: pulse-dot 1s infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.voice-player {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 200px;
  padding: 2px 2px 2px 0;
}
.voice-play-btn {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: none;
  flex-shrink: 0;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px;
  padding: 0;
}
.msg-row.mine .voice-play-btn { background: rgba(255,255,255,0.25); color: white; }
.msg-row.theirs .voice-play-btn { background: var(--cream-100); color: var(--coral-600); }

.voice-progress {
  flex: 1;
  height: 4px;
  border-radius: 999px;
  cursor: pointer;
  position: relative;
}
.msg-row.mine .voice-progress { background: rgba(255,255,255,0.3); }
.msg-row.theirs .voice-progress { background: var(--cream-100); }

.voice-progress-fill {
  height: 100%;
  border-radius: 999px;
  width: 0%;
  transition: width .1s linear;
}
.msg-row.mine .voice-progress-fill { background: white; }
.msg-row.theirs .voice-progress-fill { background: var(--coral-500); }

.voice-time {
  font-size: 11px;
  flex-shrink: 0;
  min-width: 36px;
  opacity: 0.85;
}

.upload-progress {
  padding: 6px 20px 12px;
  font-size: 12.5px;
  color: var(--ink-500);
  background: var(--cream-50);
}
.upload-progress.hidden { display: none; }

/* ---- Recherche dans la conversation ---- */
.search-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px;
  background: var(--cream-50);
  border-bottom: 1px solid var(--line);
}
.search-bar.hidden { display: none; }
#search-in-conv {
  flex: 1;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1.5px solid var(--line);
  background: var(--white);
  color: var(--ink-900);
  font-size: 13.5px;
  outline: none;
}
.search-count { font-size: 12px; color: var(--ink-500); white-space: nowrap; }
.bubble.search-match { outline: 2px solid var(--coral-500); }
.bubble.search-match-active { outline: 2px solid var(--coral-500); background: #FFE3D8 !important; color: var(--ink-900) !important; }

/* ---- Indicateur "en train d'écrire" ---- */
.typing-indicator {
  display: flex; align-items: center; gap: 4px;
  padding: 0 6% 6px;
  height: 18px;
}
.typing-indicator.hidden { display: none; }
.typing-indicator span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--ink-500);
  opacity: 0.5;
  animation: typing-bounce 1.2s infinite ease-in-out;
}
.typing-indicator span:nth-child(2) { animation-delay: .15s; }
.typing-indicator span:nth-child(3) { animation-delay: .3s; }
@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* ---- Réponse à un message ---- */
.reply-preview {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 16px;
  background: var(--cream-100);
  border-top: 1px solid var(--line);
}
.reply-preview.hidden { display: none; }
.reply-preview-bar { width: 3px; align-self: stretch; background: var(--coral-500); border-radius: 2px; }
.reply-preview-body { flex: 1; min-width: 0; }
.reply-preview-name { font-size: 12.5px; font-weight: 700; color: var(--coral-600); }
.reply-preview-text {
  font-size: 12.5px; color: var(--ink-500);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.quoted-reply {
  display: flex; gap: 8px;
  padding: 6px 8px;
  margin-bottom: 6px;
  border-left: 3px solid var(--coral-500);
  border-radius: 6px;
  background: rgba(0,0,0,0.05);
  cursor: pointer;
}
.msg-row.mine .quoted-reply { background: rgba(255,255,255,0.18); border-left-color: white; }
.quoted-reply-body { min-width: 0; }
.quoted-reply-name { font-size: 11.5px; font-weight: 700; opacity: 0.9; }
.quoted-reply-text {
  font-size: 12px; opacity: 0.8;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 220px;
}

.msg-reply-btn {
  position: absolute;
  top: -10px;
  right: 22px;
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--ink-500);
  font-size: 11px;
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s;
  display: flex; align-items: center; justify-content: center;
}
.msg-row.theirs { position: relative; }
.msg-row.theirs .msg-reply-btn { right: -10px; }
.msg-row:hover .msg-reply-btn { opacity: 1; }
@media (hover: none) { .msg-reply-btn { opacity: 0.55; } }

/* ---- Sélecteur d'émojis ---- */
.emoji-picker {
  position: absolute;
  bottom: 76px;
  left: 16px;
  width: 300px;
  max-height: 280px;
  overflow-y: auto;
  background: var(--cream-50);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.18);
  padding: 10px;
  z-index: 50;
}
.emoji-picker.hidden { display: none; }
.emoji-picker-category { font-size: 11px; font-weight: 700; color: var(--ink-500); margin: 6px 4px 4px; text-transform: uppercase; }
.emoji-picker-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; }
.emoji-btn {
  border: none; background: none;
  font-size: 20px;
  padding: 4px;
  border-radius: 6px;
  cursor: pointer;
}
.emoji-btn:hover { background: var(--cream-100); }

/* Scrollbars discrets */
.contact-list::-webkit-scrollbar, .messages::-webkit-scrollbar { width: 6px; }
.contact-list::-webkit-scrollbar-thumb { background: #ffffff20; border-radius: 4px; }
.messages::-webkit-scrollbar-thumb { background: #00000020; border-radius: 4px; }

.back-btn { display: none; background: var(--cream-100); color: var(--ink-900); }

/* Appareils tactiles : pas de hover, donc on garde les boutons de suppression visibles mais discrets */
@media (hover: none) {
  .contact-delete-btn { opacity: 0.45; }
  .msg-delete-btn { opacity: 0.55; }
}

/* Animation légère à l'arrivée d'un nouveau message */
.msg-row {
  animation: msg-in .18s ease-out;
}
@keyframes msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Responsive mobile : sidebar plein écran, chat plein écran quand ouvert */
@media (max-width: 760px) {
  #app { grid-template-columns: 1fr; height: 100dvh; overflow: hidden; }
  .sidebar {
    display: flex;
    padding-top: env(safe-area-inset-top);
    height: 100dvh;
  }
  .chat-area {
    position: fixed; inset: 0; z-index: 10; display: none;
    padding-top: env(safe-area-inset-top);
    height: 100dvh;
  }
  .chat-area.mobile-open { display: flex; }
  #app.chat-active .sidebar { display: none; }
  .back-btn { display: flex; flex-shrink: 0; }

  .chat-header { padding: 10px 12px; gap: 8px; }
  .chat-window { height: 100%; }

  /* Cibles tactiles plus grandes (min. 44px recommandé), mais compactes pour tenir sur l'écran */
  .icon-btn { width: 38px; height: 38px; font-size: 16px; flex-shrink: 0; }
  .attach-btn, #btn-voice { width: 40px; height: 40px; font-size: 18px; flex-shrink: 0; }
  .btn-send { width: 42px; height: 42px; flex-shrink: 0; }
  .contact-item { padding: 12px 8px; gap: 10px; }
  .avatar-md { width: 46px; height: 46px; font-size: 17px; }
  .contact-item-time { font-size: 10px; }

  /* Empêche le zoom automatique iOS Safari sur focus (nécessite 16px min) */
  #message-input, #search-input, #search-in-conv, .auth-form input { font-size: 16px; }

  .message-form {
    padding: 10px 10px calc(10px + env(safe-area-inset-bottom));
    gap: 6px;
  }
  #message-input { padding: 10px 14px; min-width: 0; }

  .bubble { max-width: 80%; }
  .messages { padding: 16px 3% 8px; }

  .auth-card { padding: 30px 22px; max-width: 100%; }
  .search-bar { padding: 8px 10px; gap: 6px; }
  .active-call-bar { max-width: 92vw; }
  .voice-recording { font-size: 12px; padding: 6px 12px 10px; flex-wrap: wrap; }

  .contact-delete-btn, .msg-delete-btn { opacity: 0.5; }
  .call-header-btn { width: 40px; height: 40px; }
  .call-action-btn { width: 66px; height: 66px; font-size: 26px; }
  .active-call-bar { top: env(safe-area-inset-top, 12px); }
  .emoji-picker { width: 88vw; left: 6vw; bottom: 80px; }
  .search-bar { flex-wrap: wrap; }
}

/* Très petits écrans (iPhone SE et similaires) */
@media (max-width: 380px) {
  .sidebar-header { padding: 14px 12px 10px; }
  .me-name { font-size: 13px; }
  .sidebar-actions { gap: 4px; }
  .icon-btn { width: 34px; height: 34px; font-size: 14px; }
  .contact-item-name { font-size: 13.5px; }
  .contact-item-preview { font-size: 11.5px; }
  .chat-header-name { font-size: 14px; }
  .attach-btn, #btn-voice { width: 36px; height: 36px; font-size: 16px; }
  .btn-send { width: 38px; height: 38px; }
  #message-input { padding: 8px 12px; font-size: 16px; }
  .message-form { gap: 4px; padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); }
  .bubble { max-width: 85%; font-size: 13.5px; }
}
