/* ═══════════════════════════════════════════════════════════════════════════
   MaliSMS — style.css
   Design system: dark, premium, glassmorphism + subtle gradients
════════════════════════════════════════════════════════════════════════════ */

/* ── RESET & BASE ────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Palette */
  --bg:           #0d1117;
  --surface-1:    #161b22;
  --surface-2:    #1c2333;
  --surface-3:    #21262d;
  --border:       #30363d;
  --border-subtle:#21262d;

  --text:         #e6edf3;
  --text-muted:   #8b949e;
  --text-faint:   #484f58;

  --primary:      #6366f1;
  --primary-end:  #8b5cf6;
  --primary-glow: color-mix(in srgb, var(--primary) 25%, transparent);

  --sent-bg:      linear-gradient(135deg, color-mix(in srgb, var(--primary) 88%, #000), color-mix(in srgb, var(--primary-end) 85%, #000));
  --recv-bg:      #1c2333;

  --unread-badge: #ef4444;
  --online:       #22c55e;
  --notif-color:  #64748b;

  /* Sizes */
  --sidebar-w:    360px;
  --header-h:     68px;
  --radius:       14px;
  --radius-sm:    8px;
  --radius-msg:   18px;

  /* Motion */
  --ease:         cubic-bezier(.4,0,.2,1);
  --ease-bounce:  cubic-bezier(.34,1.56,.64,1);
}

html, body {
  height: 100%;
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── SCROLLBAR ───────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

/* ── SPINNER ─────────────────────────────────────────────────────────────── */
.spinner {
  width: 24px; height: 24px;
  border: 2.5px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ══════════════════════════════════════════════════════════════════════════
   LOADER
══════════════════════════════════════════════════════════════════════════ */
.loader {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 40%, #0f1428 0%, #0d1117 70%);
  transition: opacity .5s var(--ease), visibility .5s var(--ease);
}
.loader.fade-out { opacity: 0; visibility: hidden; pointer-events: none; }

.loader__inner {
  display: flex; flex-direction: column; align-items: center; gap: 20px;
  animation: loaderIn .6s var(--ease-bounce) both;
}
@keyframes loaderIn {
  from { opacity: 0; transform: translateY(24px) scale(.95); }
  to   { opacity: 1; transform: none; }
}

.loader__logo { display: flex; flex-direction: column; align-items: center; gap: 16px; }

.loader__icon {
  width: 80px; height: 80px;
  filter: drop-shadow(0 0 32px color-mix(in srgb, var(--primary) 50%, transparent));
  animation: pulse-icon 2s ease-in-out infinite;
}
.loader__icon svg { width: 100%; height: 100%; }
@keyframes pulse-icon {
  0%,100% { filter: drop-shadow(0 0 24px color-mix(in srgb, var(--primary) 40%, transparent)); }
  50%      { filter: drop-shadow(0 0 48px color-mix(in srgb, var(--primary-end) 70%, transparent)); }
}

.loader__app-name {
  font-size: 2.2rem; font-weight: 700; letter-spacing: -.03em;
  background: linear-gradient(135deg, #a5b4fc, #c4b5fd, #818cf8);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}

.loader__tagline { color: var(--text-muted); font-size: .88rem; letter-spacing: .02em; }

.loader__bar-wrap {
  width: 200px; height: 3px;
  background: var(--surface-2); border-radius: 99px; overflow: hidden;
}
.loader__bar {
  height: 100%; width: 0;
  background: linear-gradient(90deg, var(--primary), var(--primary-end));
  border-radius: 99px;
  animation: loadBar 2s var(--ease) forwards;
}
@keyframes loadBar { 0% { width:0 } 40% { width:55% } 70% { width:80% } 100% { width:100% } }

/* ══════════════════════════════════════════════════════════════════════════
   APP LAYOUT
══════════════════════════════════════════════════════════════════════════ */
.app {
  display: flex;
  width: 100vw; height: 100vh;
  transition: opacity .4s var(--ease);
}
.app.hidden { opacity: 0; pointer-events: none; }

/* ══════════════════════════════════════════════════════════════════════════
   SIDEBAR
══════════════════════════════════════════════════════════════════════════ */
.sidebar {
  width: var(--sidebar-w); min-width: var(--sidebar-w);
  height: 100vh;
  background: var(--surface-1);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  transition: transform .3s var(--ease);
}

/* Sidebar Header */
.sidebar__header {
  height: var(--header-h);
  display: flex; align-items: center;
  padding: 0 20px;
  border-bottom: 1px solid var(--border-subtle);
  gap: 12px;
}
.sidebar__logo {
  display: flex; align-items: center; gap: 10px; flex: 1;
}
.sidebar__logo-text {
  font-size: 1.1rem; font-weight: 700; letter-spacing: -.02em;
  background: linear-gradient(135deg, #a5b4fc, #c4b5fd);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}

.sidebar__badge-wrap { display: flex; align-items: center; }
.global-badge {
  background: var(--unread-badge);
  color: #fff; font-size: .72rem; font-weight: 700;
  padding: 2px 7px; border-radius: 99px;
  min-width: 20px; text-align: center;
  animation: badgePop .25s var(--ease-bounce);
  box-shadow: 0 0 12px rgba(239,68,68,.4);
}
@keyframes badgePop { from { transform: scale(0); } to { transform: scale(1); } }

/* Sidebar search */
.sidebar__search { padding: 12px 16px; border-bottom: 1px solid var(--border-subtle); }
.search-box {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px 12px;
  transition: border-color .2s, box-shadow .2s;
}
.search-box:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}
.search-box__icon { color: var(--text-muted); flex-shrink: 0; width: 16px; height: 16px; }
.search-box__input {
  background: none; border: none; outline: none; color: var(--text);
  font-family: inherit; font-size: .88rem; width: 100%;
}
.search-box__input::placeholder { color: var(--text-faint); }

/* Section label */
.sidebar__label {
  padding: 14px 20px 6px;
  font-size: .72rem; font-weight: 600; letter-spacing: .08em;
  text-transform: uppercase; color: var(--text-faint);
}

/* Conversation list */
.conv-list {
  flex: 1; overflow-y: auto;
  display: flex; flex-direction: column;
}
.conv-list__loading {
  display: flex; align-items: center; justify-content: center;
  gap: 10px; color: var(--text-muted);
  padding: 40px 0; font-size: .85rem;
}

/* Conversation item */
.conv-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; cursor: pointer;
  border-radius: 12px; margin: 2px 8px;
  transition: background .15s, transform .12s;
  position: relative; animation: convIn .3s var(--ease-bounce) both;
}
.conv-item:hover { background: var(--surface-2); }
.conv-item.active {
  background: linear-gradient(135deg, color-mix(in srgb, var(--primary) 15%, transparent), color-mix(in srgb, var(--primary-end) 8%, transparent));
  border: 1px solid color-mix(in srgb, var(--primary) 25%, transparent);
}
@keyframes convIn {
  from { opacity:0; transform: translateX(-10px); }
  to   { opacity:1; transform: none; }
}

/* Avatar */
.avatar {
  width: 46px; height: 46px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .85rem; font-weight: 700; color: #fff;
  flex-shrink: 0; position: relative; letter-spacing: .02em;
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
.avatar--lg { width: 40px; height: 40px; font-size: .82rem; }
.avatar .online-dot {
  position: absolute; bottom: 1px; right: 1px;
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--online); border: 2px solid var(--surface-1);
}

/* Conv item content */
.conv-item__body { flex: 1; min-width: 0; }
.conv-item__top  { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; }

.conv-item__name {
  font-size: .9rem; font-weight: 400; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: color .15s;
}
.conv-item.has-unread .conv-item__name { font-weight: 700; }

.conv-item__time {
  font-size: .72rem; color: var(--text-muted); flex-shrink: 0;
}
.conv-item.has-unread .conv-item__time { color: var(--primary); font-weight: 600; }

.conv-item__bottom { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: 3px; }

.conv-item__preview {
  font-size: .82rem; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1;
}
.conv-item.has-unread .conv-item__preview { color: var(--text); font-weight: 500; }

/* Unread badge */
.unread-badge {
  background: var(--unread-badge); color: #fff;
  font-size: .68rem; font-weight: 700;
  padding: 2px 6px; border-radius: 99px;
  min-width: 18px; text-align: center; flex-shrink: 0;
  box-shadow: 0 0 8px rgba(239,68,68,.35);
}

/* Notification type indicator */
.conv-item__lock {
  color: var(--text-faint); flex-shrink: 0;
}

/* ══════════════════════════════════════════════════════════════════════════
   CHAT PANEL
══════════════════════════════════════════════════════════════════════════ */
.chat-panel {
  flex: 1; display: flex; flex-direction: column;
  background: var(--bg); position: relative; overflow: hidden;
  background-image:
    radial-gradient(ellipse at 80% 10%, color-mix(in srgb, var(--primary) 4%, transparent) 0%, transparent 60%),
    radial-gradient(ellipse at 20% 90%, color-mix(in srgb, var(--primary-end) 4%, transparent) 0%, transparent 60%);
}

/* Empty state */
.chat-empty {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 16px;
  animation: fadeIn .4s var(--ease);
}
@keyframes fadeIn { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:none; } }

.chat-empty__icon { width: 80px; height: 80px; }
.chat-empty__title { font-size: 1.15rem; font-weight: 600; color: var(--text-muted); }
.chat-empty__sub   { font-size: .85rem; color: var(--text-faint); }

/* Chat view */
.chat-view {
  display: flex; flex-direction: column; height: 100%;
  overflow: hidden;          /* critical: prevents textarea growth from shifting layout */
  animation: slideIn .25s var(--ease);
}
@keyframes slideIn { from { opacity:0; transform: translateX(16px); } to { opacity:1; transform:none; } }

/* Chat header */
.chat-header {
  height: var(--header-h); min-height: var(--header-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px;
  background: rgba(22,27,34,.85);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}

.chat-header__back {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); padding: 6px;
  border-radius: 8px; display: none; /* hidden on desktop */
  transition: color .15s, background .15s;
}
.chat-header__back:hover { color: var(--text); background: var(--surface-2); }

.chat-header__avatar { flex-shrink: 0; }

.chat-header__info { flex: 1; min-width: 0; }
.chat-header__name {
  font-size: .97rem; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-header__sub { font-size: .78rem; color: var(--text-muted); }
.chat-header__sub.online { color: var(--online); font-weight: 500; }

.chat-header__actions { display: flex; align-items: center; gap: 4px; }
.icon-btn {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); width: 38px; height: 38px;
  border-radius: 10px; display: flex; align-items: center; justify-content: center;
  transition: color .15s, background .15s;
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:hover { color: var(--text); background: var(--surface-2); }

/* Messages area */
.messages-area {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px 20px 12px;
  display: flex; flex-direction: column; gap: 4px;
  /* Always stay scrollable — content never pushes this area out */
  min-height: 0;
}
.messages-loading {
  flex: 1; display: flex; align-items: center; justify-content: center;
}

/* Date separator */
.date-separator {
  display: flex; align-items: center; gap: 12px;
  margin: 12px 0;
}
.date-separator__line { flex: 1; height: 1px; background: var(--border-subtle); }
.date-separator__label {
  font-size: .72rem; color: var(--text-faint); font-weight: 500;
  padding: 3px 10px; background: var(--surface-1);
  border-radius: 99px; border: 1px solid var(--border-subtle);
  white-space: nowrap;
}

/* Message bubbles */
.msg-group { display: flex; flex-direction: column; margin-bottom: 2px; }

.msg-row {
  display: flex; align-items: flex-end; gap: 8px;
  animation: msgIn .25s var(--ease-bounce) both;
}
.msg-row--mine   { flex-direction: row-reverse; }
.msg-row--theirs { flex-direction: row; }
@keyframes msgIn {
  from { opacity:0; transform: translateY(10px) scale(.96); }
  to   { opacity:1; transform: none; }
}

/* Small avatar in message row (for received messages) */
.msg-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .62rem; font-weight: 700; color: #fff; flex-shrink: 0;
  align-self: flex-end; margin-bottom: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,.3);
}
/* Hide avatar for consecutive messages from same sender */
.msg-avatar.invisible { opacity: 0; }

.msg-bubble {
  max-width: 62%; padding: 10px 14px;
  border-radius: var(--radius-msg);
  word-break: break-word; line-height: 1.55;
  font-size: .875rem; position: relative;
}

/* Sent (mine) */
.msg-row--mine .msg-bubble {
  background: var(--sent-bg);
  color: #fff;
  border-bottom-right-radius: 5px;
  box-shadow: 0 4px 16px color-mix(in srgb, var(--primary) 25%, transparent);
}

/* Received (theirs) */
.msg-row--theirs .msg-bubble {
  background: var(--recv-bg);
  color: var(--text);
  border-bottom-left-radius: 5px;
  border: 1px solid var(--border-subtle);
}

.msg-meta {
  display: flex; align-items: center; gap: 4px;
  margin-top: 4px;
  font-size: .68rem; color: var(--text-faint);
}
.msg-row--mine  .msg-meta { justify-content: flex-end; }
.msg-row--theirs .msg-meta { justify-content: flex-start; }

/* Read tick */
.msg-tick { display: flex; align-items: center; }
.msg-tick svg { width: 14px; height: 14px; }
.msg-tick--read  { color: #60a5fa; }
.msg-tick--sent  { color: var(--text-faint); }

/* ── NO-REPLY NOTICE ─────────────────────────────────────────────────────── */
.no-reply-notice {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 14px 20px;
  background: rgba(100,116,139,.08);
  border-top: 1px solid var(--border);
  color: var(--text-muted); font-size: .82rem;
  flex-shrink: 0;  /* never squish */
}
.no-reply-notice svg { color: var(--notif-color); flex-shrink: 0; }

/* ── REPLY BAR ───────────────────────────────────────────────────────────── */
.reply-bar {
  padding: 10px 16px 14px;
  background: rgba(22,27,34,.9);
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  flex-shrink: 0;   /* CRITICAL: never let messages area push this out */
}
.reply-bar__inner {
  display: flex; align-items: flex-end; gap: 10px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 8px 10px;
  transition: border-color .2s, box-shadow .2s;
}
.reply-bar__inner:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.reply-bar__attach {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); padding: 4px;
  border-radius: 8px; flex-shrink: 0; display: flex;
  transition: color .15s;
}
.reply-bar__attach svg { width: 18px; height: 18px; }
.reply-bar__attach:hover { color: var(--primary); }

.reply-bar__input {
  flex: 1; background: none; border: none; outline: none;
  color: var(--text); font-family: inherit; font-size: .88rem;
  resize: none;
  min-height: 22px;    /* exactly one line */
  max-height: 120px;   /* ~5 lines max */
  height: 22px;        /* initial height */
  line-height: 1.5;
  padding: 4px 0;
  overflow-y: auto;    /* scroll inside textarea once max-height reached */
  word-break: break-word;
}
.reply-bar__input::placeholder { color: var(--text-faint); }

.reply-bar__send {
  background: linear-gradient(135deg, var(--primary), var(--primary-end));
  border: none; cursor: pointer; color: #fff;
  width: 36px; height: 36px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: opacity .15s, transform .15s;
  box-shadow: 0 4px 12px color-mix(in srgb, var(--primary) 35%, transparent);
}
.reply-bar__send svg { width: 16px; height: 16px; }
.reply-bar__send:hover  { opacity: .85; transform: scale(1.05); }
.reply-bar__send:active { transform: scale(.95); }
.reply-bar__send:disabled { opacity: .4; cursor: not-allowed; transform: none; }

/* ── UTILITIES ───────────────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── RESPONSIVE — mobile ─────────────────────────────────────────────────── */
@media (max-width: 700px) {
  .sidebar {
    position: fixed; inset: 0; z-index: 10;
    width: 100%; transform: translateX(0);
  }
  .sidebar.slide-out { transform: translateX(-100%); transition: transform .3s var(--ease); }
  .chat-panel { width: 100%; position: fixed; inset: 0; z-index: 11; transform: translateX(100%); transition: transform .3s var(--ease); }
  .chat-panel.slide-in { transform: translateX(0); }
  .chat-header__back { display: flex !important; }
  .msg-bubble { max-width: 82%; }
}

/* ══════════════════════════════════════════════════════════════════════════
   SIGN IN
══════════════════════════════════════════════════════════════════════════ */
.signin {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  background: radial-gradient(ellipse at 50% 40%, #0f1428 0%, var(--bg) 70%);
}
.signin__card {
  width: 100%; max-width: 360px;
  display: flex; flex-direction: column; gap: 8px;
  padding: 28px 24px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.signin__title { font-size: 1.2rem; font-weight: 700; text-align: center; }
.signin__sub { color: var(--text-muted); font-size: .82rem; text-align: center; margin-bottom: 10px; }
.signin__label { color: var(--text-muted); font-size: .78rem; font-weight: 500; margin-top: 6px; }
.signin__input {
  width: 100%; padding: 11px 14px;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font: inherit; font-size: 1rem; outline: none;
}
.signin__input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }
.signin__error { color: #f87171; font-size: .82rem; text-align: center; }
.signin__button {
  margin-top: 12px; padding: 12px;
  border: 0; border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--primary), var(--primary-end));
  color: #fff; font: inherit; font-weight: 600; cursor: pointer;
}
.signin__button:disabled { opacity: .6; cursor: default; }
.sidebar__badge-wrap { gap: 6px; }
.sidebar__badge-wrap .icon-btn svg { width: 18px; height: 18px; }
.msg-bubble { overflow-wrap: break-word; }

/* ══════════════════════════════════════════════════════════════════════════
   POP-UP NOTIFICATIONS — same cards as the EMPAWA wallet (copied from Mali/styles.css)
══════════════════════════════════════════════════════════════════════════ */
.notification-card {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  align-items: start;
  gap: 12px;
  overflow: hidden;
  padding: 14px;
  border: 1px solid #e7e8eb;
  border-radius: 10px;
  background: #fff;
  color: #111;
  touch-action: pan-y;
  user-select: none;
  transition: transform 260ms cubic-bezier(0.22, 0.61, 0.36, 1), opacity 220ms ease;
  will-change: transform, opacity;
}

.notification-brand-icon {
  display: grid;
  width: 64px;
  aspect-ratio: 1;
  place-items: center;
}

.notification-brand-icon img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%; /* round logo on notifications */
}

.notification-card-content {
  min-width: 0;
}

.notification-card-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.notification-card-heading strong {
  color: #111;
  font-size: 13px;
  font-weight: 700;
}

.notification-card-heading time {
  color: #6b7280;
  font-size: 10px;
  text-align: right;
}

.notification-card p {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

@media (max-width: 520px) {
  .notification-card {
    grid-template-columns: 52px minmax(0, 1fr);
    gap: 10px;
    padding: 12px;
  }

  .notification-brand-icon {
    width: 52px;
  }
}

.notification-card[data-dismissing="true"] {
  opacity: 0.55;
}

.notification-toast-stack {
  position: fixed;
  z-index: 30;
  top: calc(12px + env(safe-area-inset-top));
  left: 50%;
  display: grid;
  gap: 10px;
  width: min(520px, calc(100vw - 24px));
  max-height: calc(100vh - 24px - env(safe-area-inset-top));
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-bottom: 2px;
  transform: translateX(-50%);
  pointer-events: none;
}

.notification-toast-stack:empty {
  display: none;
}

.notification-toast {
  padding-top: 16px;
  box-shadow: 0 12px 34px rgb(0 0 0 / 28%);
  pointer-events: auto;
  transition: transform 320ms cubic-bezier(0.22, 0.61, 0.36, 1), opacity 260ms ease;
}

.notification-toast.is-entering {
  transform: translateY(-120%);
  opacity: 0;
  transition: none;
}

.notification-toast.is-auto-exiting {
  transform: translateX(calc(100vw + 24px));
  opacity: 0;
  pointer-events: none;
}
.notification-underline {
  text-decoration: underline;
  text-underline-offset: 2px;
}
.notification-toast { cursor: pointer; font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; }
.notification-brand-letter {
  display: grid; width: 100%; aspect-ratio: 1; place-items: center;
  border-radius: 50%; color: #fff; font-weight: 700; font-size: 1.1rem;
}
.notification-toast.is-dismissed { transform: translateX(var(--dismiss-distance, 110%)); opacity: 0; pointer-events: none; }

/* After the first load the list re-arranges by sliding (no entrance animation on every refresh). */
.conv-list--settled .conv-item { animation: none; }
.conv-item.is-new-message { animation: convBump .6s var(--ease-bounce); }
@keyframes convBump { 0% { transform: scale(.97); background: color-mix(in srgb, var(--primary) 22%, transparent); } 100% { transform: none; } }
.notification-toast-stack { z-index: 10000; }

/* Back arrow (phones): the icon had no size, so it shrank to nothing. */
.chat-header__back { width: 40px; height: 40px; margin-left: -8px; align-items: center; justify-content: center; flex-shrink: 0; }
.chat-header__back svg { width: 24px; height: 24px; }
@media (max-width: 700px) {
  .chat-header { padding: 0 12px; gap: 10px; }
  .chat-header__actions { display: none; }
}

/* ══════════════════════════════════════════════════════════════════════════
   LIGHT MODE (the sun/moon button switches; the choice is remembered on this device)
══════════════════════════════════════════════════════════════════════════ */
:root[data-theme="light"] {
  --bg:           #f4f6fb;
  --surface-1:    #ffffff;
  --surface-2:    #eef1f7;
  --surface-3:    #e6e9f2;
  --border:       #dde1ea;
  --border-subtle:#e8ebf2;
  --text:         #111827;
  --text-muted:   #5b6474;
  --text-faint:   #9aa3b2;
  --recv-bg:      #ffffff;
  --primary-glow: color-mix(in srgb, var(--primary) 18%, transparent);
  color-scheme: light;
}
:root[data-theme="dark"] { color-scheme: dark; }
:root[data-theme="light"] .loader,
:root[data-theme="light"] .signin { background: radial-gradient(ellipse at 50% 40%, #e9ecff 0%, var(--bg) 70%); }
:root[data-theme="light"] .chat-header { background: rgba(255,255,255,.9); }
:root[data-theme="light"] .reply-bar { background: rgba(255,255,255,.92); }
:root[data-theme="light"] .loader__app-name,
:root[data-theme="light"] .sidebar__logo-text { background: linear-gradient(135deg, color-mix(in srgb, var(--primary) 85%, #000), color-mix(in srgb, var(--primary-end) 85%, #000)); -webkit-background-clip: text; background-clip: text; }
:root[data-theme="light"] .msg-row--theirs .msg-bubble { border: 1px solid var(--border); box-shadow: 0 1px 2px rgba(15,23,42,.06); }
:root[data-theme="light"] .avatar,
:root[data-theme="light"] .msg-avatar { box-shadow: 0 1px 4px rgba(15,23,42,.15); }
:root[data-theme="light"] .notification-toast { border-color: #d7dbe4; }
:root[data-theme="light"] .signin__error { color: #dc2626; }

.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
.signin .theme-toggle { position: fixed; top: 12px; right: 12px; }

/* Message width: the limit sits on the bubble's wrapper (a share of the chat area), so text runs along
   the whole line and only wraps once the bubble reaches its maximum width. */
.msg-row > div:not(.msg-avatar) { max-width: 70%; min-width: 0; display: flex; flex-direction: column; }
.msg-row--mine > div:not(.msg-avatar) { align-items: flex-end; }
.msg-row--theirs > div:not(.msg-avatar) { align-items: flex-start; }
.msg-bubble { max-width: 100%; }
@media (max-width: 700px) {
  .msg-row > div:not(.msg-avatar) { max-width: 82%; }
  .msg-bubble { max-width: 100%; }
}

/* Message search results */
.conv-item__preview mark { background: rgba(250,204,21,.35); color: inherit; border-radius: 3px; padding: 0 1px; }
:root[data-theme="light"] .conv-item__preview mark { background: #fde68a; }
.msg-row--found .msg-bubble { box-shadow: 0 0 0 3px #facc15; transition: box-shadow .3s; }
/* Pop-ups handle sideways swipes themselves, so the browser must not take the gesture over. */
.notification-toast { touch-action: none; }

/* No scrollbars anywhere in the app (it still scrolls, like a phone app) */
* { scrollbar-width: none; }
*::-webkit-scrollbar { display: none; width: 0; height: 0; }
