/* ============================================================
   THABIT MESSAGERIE — CSS Mobile-first
   ============================================================ */

:root {
  --primary:    #1B2E5E;
  --accent:     #2563EB;
  --online:     #25D366;
  --danger:     #DC2626;
  --bg:         #F0F2F5;
  --bg-chat:    #EBE5DC;
  --surface:    #FFFFFF;
  --border:     #E9EDEF;
  --text:       #111827;
  --muted:      #6B7280;
  --bubble-out: #D1F4CC;
  --bubble-in:  #FFFFFF;
  --header:     #1B2E5E;
  --nav-h:      60px;
  --hdr-h:      56px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, sans-serif;
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

/* ─── App Shell ─────────────────────────────────────────────── */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  background: var(--surface);
  position: relative;
  overflow: hidden;
  box-shadow: 0 0 40px rgba(0,0,0,.12);
}

/* ─── Header ────────────────────────────────────────────────── */
.app-header {
  background: var(--header);
  color: #fff;
  height: var(--hdr-h);
  display: flex;
  align-items: center;
  padding: 0 4px 0 8px;
  gap: 4px;
  flex-shrink: 0;
  z-index: 10;
}
.app-header h1 {
  flex: 1;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: .2px;
  padding-left: 4px;
}
.app-header .subtitle {
  font-size: 12px;
  opacity: .75;
  font-weight: 400;
  display: block;
}
.hdr-btn {
  background: none;
  border: none;
  color: #fff;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background .15s;
}
.hdr-btn:hover { background: rgba(255,255,255,.12); }
.hdr-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ─── Content area ──────────────────────────────────────────── */
.app-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  min-height: 0;
}

/* ─── Notification banner ───────────────────────────────────── */
.notif-banner {
  display: none;
  align-items: center;
  gap: 10px;
  background: #EFF6FF;
  border-bottom: 1px solid #BFDBFE;
  padding: 8px 12px;
  font-size: 13px;
  color: #1e40af;
  flex-shrink: 0;
}
.notif-banner.show { display: flex; }
.notif-banner span { flex: 1; }
.notif-banner-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.notif-banner-close {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 0 2px;
}

/* ─── Bottom Nav ────────────────────────────────────────────── */
.app-nav {
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  height: var(--nav-h);
  flex-shrink: 0;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--muted);
  text-decoration: none;
  font-size: 11px;
  font-weight: 500;
  transition: color .15s;
  position: relative;
}
.nav-item.active { color: var(--primary); }
.nav-item.active .nav-icon { background: rgba(27,46,94,.08); border-radius: 14px; }
.nav-icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.nav-icon svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.nav-badge {
  position: absolute;
  top: -4px;
  right: -6px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 17px;
  height: 17px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

/* ─── Avatar ────────────────────────────────────────────────── */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
  overflow: hidden;
  object-fit: cover;
}
.avatar-sm { width: 36px; height: 36px; font-size: 13px; }
.avatar-md { width: 46px; height: 46px; font-size: 17px; }
.avatar-lg { width: 64px; height: 64px; font-size: 24px; }
.avatar-xl { width: 86px; height: 86px; font-size: 32px; }
.online-dot {
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 11px;
  height: 11px;
  background: var(--online);
  border: 2px solid var(--surface);
  border-radius: 50%;
}

/* ─── Conversation List ─────────────────────────────────────── */
.conv-list { list-style: none; }
.conv-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  text-decoration: none;
  color: var(--text);
  transition: background .1s;
  position: relative;
}
.conv-item:active { background: #f5f5f5; }
.conv-avatar { position: relative; }
.conv-body { flex: 1; min-width: 0; }
.conv-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.conv-name { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-time { font-size: 12px; color: var(--muted); flex-shrink: 0; }
.conv-bottom { display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.conv-preview { color: var(--muted); font-size: 13px; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-badge {
  background: var(--online);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  min-width: 19px;
  height: 19px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  flex-shrink: 0;
}

/* ─── Tabs ──────────────────────────────────────────────────── */
.tabs {
  display: flex;
  background: var(--primary);
  border-bottom: 2px solid rgba(255,255,255,.1);
}
.tab-btn {
  flex: 1;
  background: none;
  border: none;
  color: rgba(255,255,255,.65);
  font-size: 13px;
  font-weight: 600;
  padding: 10px;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: all .15s;
  letter-spacing: .5px;
}
.tab-btn.active {
  color: #fff;
  border-bottom-color: #fff;
}

/* ─── Chat body wrapper (fills remaining space below header) ── */
.chat-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.chat-footer {
  flex-shrink: 0;
}

/* ─── Chat Area ─────────────────────────────────────────────── */
.chat-bg {
  background: var(--bg-chat);
  min-height: 0;
  padding: 8px 4px;
}
.date-sep {
  text-align: center;
  margin: 8px 0;
}
.date-sep span {
  background: rgba(255,255,255,.85);
  color: var(--muted);
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(0,0,0,.1);
}

/* ─── Message Bubble ────────────────────────────────────────── */
.msg-row {
  display: flex;
  margin-bottom: 2px;
  padding: 0 8px;
}
.msg-row.out { justify-content: flex-end; }
.msg-row.in  { justify-content: flex-start; }

.msg-row.in .msg-sender-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 2px;
  padding-left: 2px;
}

.bubble {
  max-width: 78%;
  padding: 6px 10px 4px;
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(0,0,0,.1);
  position: relative;
  word-wrap: break-word;
  min-width: 80px;
}
.msg-row.out .bubble {
  background: var(--bubble-out);
  border-bottom-right-radius: 2px;
}
.msg-row.in .bubble {
  background: var(--bubble-in);
  border-bottom-left-radius: 2px;
}
.bubble-text {
  font-size: 14.5px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}
.bubble-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 3px;
  margin-top: 2px;
}
.bubble-time {
  font-size: 11px;
  color: var(--muted);
}
.check-icon { width: 15px; height: 15px; fill: none; stroke: #4fc3f7; stroke-width: 2; }
.check-icon.delivered { stroke: var(--muted); }

/* Reply quote */
.reply-quote {
  border-left: 3px solid var(--accent);
  padding: 4px 8px;
  margin-bottom: 4px;
  background: rgba(0,0,0,.04);
  border-radius: 0 4px 4px 0;
}
.reply-quote-name { font-size: 12px; font-weight: 600; color: var(--accent); }
.reply-quote-text { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Deleted message */
.deleted-msg { color: var(--muted); font-style: italic; font-size: 13px; }

/* File attachment */
.file-bubble {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 4px;
  min-width: 200px;
}
.file-icon-wrap {
  width: 40px;
  height: 40px;
  background: rgba(37,99,235,.1);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.file-info { flex: 1; min-width: 0; }
.file-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-size { font-size: 11px; color: var(--muted); }
.file-dl { color: var(--accent); font-size: 20px; }

/* Image bubble */
.img-bubble {
  max-width: 100%;
  border-radius: 6px;
  display: block;
  cursor: pointer;
  max-height: 280px;
  object-fit: cover;
}

/* Audio bubble */
.audio-player {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 180px;
}
.audio-play-btn {
  width: 36px; height: 36px;
  background: var(--accent);
  border: none;
  border-radius: 50%;
  color: #fff;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.audio-wave {
  flex: 1;
  height: 28px;
  background: rgba(0,0,0,.06);
  border-radius: 14px;
  position: relative;
  overflow: hidden;
}
.audio-progress {
  height: 100%;
  background: rgba(37,99,235,.3);
  border-radius: 14px;
  transition: width .1s;
}
.audio-dur { font-size: 11px; color: var(--muted); white-space: nowrap; }

/* Reactions on bubble */
.bubble-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}
.reaction-chip {
  background: rgba(255,255,255,.85);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 13px;
  padding: 1px 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 3px;
}
.reaction-chip.mine { border-color: var(--accent); background: rgba(37,99,235,.08); }

/* ─── Typing indicator ──────────────────────────────────────── */
.typing-indicator {
  padding: 4px 16px 2px;
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
  min-height: 20px;
  flex-shrink: 0;
}
.typing-dots { display: inline-flex; gap: 3px; vertical-align: middle; }
.typing-dots span {
  width: 5px; height: 5px;
  background: var(--muted);
  border-radius: 50%;
  animation: bounce .8s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: .15s; }
.typing-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%,60%,100% { transform: translateY(0); } 30% { transform: translateY(-4px); } }

/* ─── Message Input ─────────────────────────────────────────── */
.msg-input-area {
  background: var(--bg);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0));
  display: flex;
  align-items: flex-end;
  gap: 6px;
  flex-shrink: 0;
}
.msg-input-wrap {
  flex: 1;
  background: var(--surface);
  border-radius: 22px;
  display: flex;
  align-items: flex-end;
  padding: 6px 10px;
  gap: 6px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.msg-input-wrap textarea {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  font-size: 15px;
  font-family: inherit;
  background: transparent;
  max-height: 120px;
  line-height: 1.4;
  padding: 0;
  color: var(--text);
}
.input-icon-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color .15s;
}
.input-icon-btn:hover { color: var(--accent); }
.input-icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.send-btn {
  width: 46px; height: 46px;
  background: var(--primary);
  border: none;
  border-radius: 50%;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .15s, transform .1s;
}
.send-btn:active { transform: scale(.9); }
.send-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.mic-btn { background: var(--primary); }

/* Reply bar */
.reply-bar {
  display: none;
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding: 6px 12px;
  gap: 10px;
  align-items: center;
  font-size: 13px;
}
.reply-bar.active { display: flex; }
.reply-bar-content { flex: 1; }
.reply-bar-name { color: var(--accent); font-weight: 600; font-size: 12px; }
.reply-bar-text { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reply-bar-close { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 18px; }

/* ─── Contacts ──────────────────────────────────────────────── */
.contact-section-header {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  background: var(--bg);
  padding: 6px 16px;
  letter-spacing: .5px;
}
.contact-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  text-decoration: none;
  color: var(--text);
}
.contact-item:active { background: #f5f5f5; }
.contact-info { flex: 1; }
.contact-name { font-weight: 600; font-size: 15px; }
.contact-role { font-size: 12px; color: var(--muted); }
.contact-status { width: 8px; height: 8px; border-radius: 50%; background: var(--border); flex-shrink: 0; }
.contact-status.online { background: var(--online); }

/* ─── Search bar ────────────────────────────────────────────── */
.search-bar {
  background: var(--bg);
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}
.search-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 8px 14px 8px 36px;
  font-size: 14px;
  outline: none;
  color: var(--text);
  transition: border-color .15s;
}
.search-input:focus { border-color: var(--accent); }
.search-wrap { position: relative; }
.search-wrap svg {
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  width: 16px; height: 16px;
  fill: none; stroke: var(--muted);
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}

/* ─── Settings ──────────────────────────────────────────────── */
.settings-profile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 24px 16px 20px;
  background: var(--surface);
  border-bottom: 8px solid var(--bg);
}
.settings-name { font-size: 18px; font-weight: 700; }
.settings-email { font-size: 13px; color: var(--muted); }
.settings-role { font-size: 12px; background: var(--bg); padding: 3px 10px; border-radius: 12px; color: var(--primary); font-weight: 600; }
.settings-section { margin-bottom: 8px; }
.settings-section-label { font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: .5px; padding: 10px 16px 4px; }
.settings-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.settings-row svg { width: 20px; height: 20px; fill: none; stroke: var(--primary); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.settings-row-label { flex: 1; font-size: 15px; }
.settings-row-chevron { color: var(--muted); font-size: 18px; }
.logout-btn {
  width: calc(100% - 32px);
  margin: 16px;
  padding: 13px;
  background: #FEE2E2;
  color: var(--danger);
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

/* ─── Login Page ────────────────────────────────────────────── */
.login-page {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  padding: 24px 20px;
}
.login-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 28px 24px 24px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 12px 40px rgba(0,0,0,.25);
}
.login-logo {
  text-align: center;
  margin-bottom: 24px;
}
.login-logo img { height: 50px; }
.login-logo h2 { font-size: 18px; color: var(--primary); margin-top: 10px; font-weight: 700; }
.login-logo p { font-size: 13px; color: var(--muted); }

.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 5px; }
.form-control {
  width: 100%;
  padding: 11px 13px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color .15s;
  color: var(--text);
  background: var(--surface);
}
.form-control:focus { border-color: var(--accent); }
.btn-primary {
  width: 100%;
  padding: 13px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 6px;
  transition: opacity .15s;
}
.btn-primary:hover { opacity: .9; }
.btn-primary:disabled { opacity: .6; }
.alert-error {
  background: #FEE2E2;
  color: var(--danger);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 12px;
}

/* ─── PIN Page ──────────────────────────────────────────────── */
.pin-page {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  padding: 24px 20px;
}
.pin-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 32px 24px 24px;
  width: 100%;
  max-width: 340px;
  box-shadow: 0 12px 40px rgba(0,0,0,.25);
  text-align: center;
}
.pin-title { font-size: 20px; font-weight: 700; color: var(--primary); margin-bottom: 6px; }
.pin-subtitle { font-size: 14px; color: var(--muted); margin-bottom: 24px; }
.pin-dots {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-bottom: 28px;
}
.pin-dot {
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--bg);
  transition: all .1s;
}
.pin-dot.filled { background: var(--primary); border-color: var(--primary); }
.pin-dot.error  { background: var(--danger);  border-color: var(--danger); animation: shake .3s; }
@keyframes shake { 0%,100% {transform:translateX(0)} 25% {transform:translateX(-5px)} 75% {transform:translateX(5px)} }
.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.key-btn {
  aspect-ratio: 1;
  background: var(--bg);
  border: none;
  border-radius: 50%;
  font-size: 22px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: background .1s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.key-btn:active { background: var(--border); }
.key-btn.del { font-size: 20px; color: var(--muted); }
.key-btn:empty { visibility: hidden; }

/* ─── PIN Lock Overlay ──────────────────────────────────────── */
#pin-lock-overlay {
  position: fixed;
  inset: 0;
  background: var(--primary);
  z-index: 9999;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
#pin-lock-overlay.show { display: flex; }
.pin-lock-user { color: rgba(255,255,255,.75); font-size: 14px; margin-bottom: 4px; }
.pin-lock-name { color: #fff; font-size: 20px; font-weight: 700; margin-bottom: 32px; }
.pin-lock-dots {
  display: flex;
  gap: 16px;
  margin-bottom: 32px;
}
.pin-lock-dot {
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,.4);
  background: transparent;
  transition: background .1s;
}
.pin-lock-dot.filled { background: #fff; border-color: #fff; }
.pin-lock-dot.error  { background: #f87171; border-color: #f87171; animation: shake .3s; }
.lock-keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: 260px;
}
.lock-key {
  aspect-ratio: 1;
  background: rgba(255,255,255,.12);
  border: none;
  border-radius: 50%;
  font-size: 24px;
  font-weight: 400;
  color: #fff;
  cursor: pointer;
  transition: background .1s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lock-key:active { background: rgba(255,255,255,.25); }
.lock-key.del { font-size: 22px; }
.pin-error-msg { color: #f87171; font-size: 13px; margin-top: 16px; min-height: 20px; }

/* ─── FAB ───────────────────────────────────────────────────── */
.fab {
  position: fixed;
  bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom, 0));
  right: 20px;
  width: 54px; height: 54px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 50%;
  box-shadow: 0 4px 16px rgba(0,0,0,.25);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .1s;
  z-index: 100;
}
.fab:active { transform: scale(.92); }
.fab svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }

/* ─── Empty state ───────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  color: var(--muted);
  text-align: center;
  gap: 12px;
}
.empty-state svg { width: 52px; height: 52px; opacity: .35; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.empty-state p { font-size: 14px; }

/* ─── Group info header ─────────────────────────────────────── */
.group-header-info {
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.group-header-info .name { font-size: 16px; font-weight: 600; line-height: 1.2; }
.group-header-info .meta { font-size: 12px; opacity: .75; }

/* ─── Context menu on long press ────────────────────────────── */
.ctx-menu {
  position: fixed;
  background: var(--surface);
  border-radius: 10px;
  box-shadow: 0 6px 24px rgba(0,0,0,.2);
  z-index: 1000;
  min-width: 180px;
  overflow: hidden;
  display: none;
}
.ctx-menu.show { display: block; }
.ctx-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  font-size: 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.ctx-item:last-child { border-bottom: none; }
.ctx-item:active { background: var(--bg); }
.ctx-item.danger { color: var(--danger); }
.ctx-item svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ─── Modal overlay ─────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 500;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.modal-sheet {
  background: var(--surface);
  border-radius: 16px 16px 0 0;
  padding: 20px 20px calc(20px + env(safe-area-inset-bottom, 0));
  width: 100%;
  max-width: 480px;
}
.modal-title { font-size: 17px; font-weight: 700; margin-bottom: 16px; }
.modal-input {
  width: 100%;
  padding: 11px 13px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  font-family: inherit;
  outline: none;
  margin-bottom: 12px;
}
.modal-input:focus { border-color: var(--accent); }
.modal-btns { display: flex; gap: 10px; }
.modal-btn {
  flex: 1;
  padding: 12px;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.modal-btn.cancel { background: var(--bg); color: var(--muted); }
.modal-btn.confirm { background: var(--primary); color: #fff; }

/* ─── Announcement card ─────────────────────────────────────── */
.ann-card {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 16px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  cursor: pointer;
  text-decoration: none;
  color: var(--text);
}
.ann-icon {
  width: 42px; height: 42px;
  background: rgba(37,99,235,.1);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.ann-body { flex: 1; min-width: 0; }
.ann-title { font-weight: 600; font-size: 15px; }
.ann-preview { font-size: 13px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ann-time { font-size: 11px; color: var(--muted); margin-top: 4px; }

/* ─── Spinner ───────────────────────────────────────────────── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Toast notification ────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: calc(var(--nav-h) + 12px);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #323232;
  color: #fff;
  padding: 10px 18px;
  border-radius: 24px;
  font-size: 13px;
  opacity: 0;
  transition: all .3s;
  z-index: 999;
  white-space: nowrap;
  pointer-events: none;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ─── Swipe-to-reply hint ───────────────────────────────────── */
.msg-row { transition: transform .1s; }

/* ─── Desktop: full screen ───────────────────────────────────── */
@media (min-width: 520px) {
  .app {
    max-width: 100%;
    width: 100%;
    margin: 0;
    height: 100vh;
    height: 100dvh;
    border-radius: 0;
    box-shadow: none;
  }
  .fab { right: 24px; bottom: calc(var(--nav-h) + 16px); }
}

/* ─── Scrollbar styling ─────────────────────────────────────── */
.app-content::-webkit-scrollbar { width: 4px; }
.app-content::-webkit-scrollbar-track { background: transparent; }
.app-content::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ─── Actualités (social feed) ───────────────────────────────── */
.actu-compose {
  flex-shrink: 0;
  background: var(--surface);
  border-bottom: 8px solid var(--bg);
  padding: 12px 14px;
}
.actu-compose-inner {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.actu-compose-body { flex: 1; min-width: 0; }
.actu-textarea {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  outline: none;
  color: var(--text);
  background: var(--bg);
  line-height: 1.45;
  max-height: 140px;
  transition: border-color .15s;
}
.actu-textarea:focus { border-color: var(--accent); background: var(--surface); }
.actu-compose-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
}
.actu-attach-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  padding: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  border-radius: 6px;
  transition: color .15s;
}
.actu-attach-btn:hover { color: var(--accent); }
.actu-attach-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.actu-post-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 20px;
  padding: 7px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s;
}
.actu-post-btn:disabled { opacity: .6; }
.actu-media-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
.preview-item {
  position: relative;
  display: inline-flex;
}
.preview-item img, .preview-item video {
  max-height: 90px;
  max-width: 120px;
  border-radius: 8px;
  object-fit: cover;
}
.preview-item button {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--danger);
  color: #fff;
  border: none;
  font-size: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* Post card */
.actu-post {
  background: var(--surface);
  border-bottom: 8px solid var(--bg);
  padding: 14px 14px 10px;
}
.actu-post-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.actu-post-avatar { position: relative; flex-shrink: 0; }
.actu-post-meta { flex: 1; min-width: 0; }
.actu-post-name { font-weight: 600; font-size: 14px; }
.actu-post-role { font-size: 11px; color: var(--accent); font-weight: 600; }
.actu-post-time { font-size: 12px; color: var(--muted); }
.actu-post-del {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 16px;
  padding: 4px 8px;
  border-radius: 6px;
  flex-shrink: 0;
}
.actu-post-del:hover { color: var(--danger); background: #FEE2E2; }
.actu-post-content {
  font-size: 14.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  margin-bottom: 10px;
  color: var(--text);
}

/* Media grid */
.actu-media-grid {
  display: grid;
  gap: 3px;
  margin-bottom: 10px;
  border-radius: 10px;
  overflow: hidden;
}
.actu-media-1 { grid-template-columns: 1fr; }
.actu-media-2 { grid-template-columns: 1fr 1fr; }
.actu-media-3 { grid-template-columns: 1fr 1fr; }
.actu-media-3 .actu-media-item:first-child { grid-column: 1 / -1; }
.actu-media-item { cursor: pointer; overflow: hidden; aspect-ratio: 16/9; }
.actu-media-item img, .actu-media-item video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.actu-post-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
}
.actu-dm-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 13px;
  cursor: pointer;
  color: var(--primary);
  font-weight: 500;
  transition: background .15s;
}
.actu-dm-btn:hover { background: var(--bg); }
.actu-dm-btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.actu-load-more {
  display: block;
  width: calc(100% - 32px);
  margin: 16px;
  padding: 11px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  color: var(--primary);
}

/* Image viewer overlay */
#img-viewer {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.92);
  z-index: 9998;
  display: none;
  align-items: center;
  justify-content: center;
}
#img-viewer.show { display: flex; }
