/* ------------------------------------------------------------------ *
 * LordVi — thème inspiré de WhatsApp Web (clair et sombre)
 * ------------------------------------------------------------------ */

:root {
  --brand: #00a884;
  --brand-dark: #008069;
  --tick-read: #53bdeb;

  --bg-app: #d1d7db;
  --bg-panel: #ffffff;
  --bg-panel-alt: #f0f2f5;
  --bg-hover: #f5f6f6;
  --bg-active: #f0f2f5;
  --bg-chat: #efeae2;
  --bubble-in: #ffffff;
  --bubble-out: #d9fdd3;
  --text: #111b21;
  --text-muted: #667781;
  --text-faint: #8696a0;
  --border: rgba(17, 27, 33, 0.1);
  --shadow: 0 1px 2px rgba(11, 20, 26, 0.16);
  --overlay: rgba(11, 20, 26, 0.75);

  --sidebar-width: 30%;
  --sidebar-min: 340px;
  --header-height: 60px;
  --radius-bubble: 8px;
}

[data-theme='dark'] {
  --bg-app: #0b141a;
  --bg-panel: #111b21;
  --bg-panel-alt: #202c33;
  --bg-hover: #202c33;
  --bg-active: #2a3942;
  --bg-chat: #0b141a;
  --bubble-in: #202c33;
  --bubble-out: #005c4b;
  --text: #e9edef;
  --text-muted: #8696a0;
  --text-faint: #667781;
  --border: rgba(233, 237, 239, 0.12);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

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

html,
body {
  height: 100%;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', sans-serif;
  font-size: 15px;
  color: var(--text);
  background: var(--bg-app);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button,
input,
textarea {
  font: inherit;
  color: inherit;
}

button {
  background: none;
  border: none;
  cursor: pointer;
}

svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

a {
  color: var(--tick-read);
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-thumb {
  background: rgba(134, 150, 160, 0.5);
  border-radius: 3px;
}

/* ------------------------------------------------------------------ *
 * Authentification
 * ------------------------------------------------------------------ */

.auth-screen {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: linear-gradient(180deg, var(--brand-dark) 0 220px, var(--bg-app) 220px);
  overflow: auto;
  z-index: 40;
}

.auth-card {
  width: min(440px, 100%);
  background: var(--bg-panel);
  border-radius: 6px;
  box-shadow: 0 4px 20px rgba(11, 20, 26, 0.18);
  padding: 28px;
}

.auth-brand {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 22px;
}

.auth-brand h1 {
  font-size: 22px;
  font-weight: 600;
}

.auth-brand p {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

.auth-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-panel-alt);
  border-radius: 8px;
  padding: 4px;
  margin-bottom: 20px;
}

.auth-tab {
  flex: 1;
  padding: 9px;
  border-radius: 6px;
  font-size: 14px;
  color: var(--text-muted);
}

.auth-tab.is-active {
  background: var(--bg-panel);
  color: var(--text);
  box-shadow: var(--shadow);
}

.auth-form {
  display: grid;
  gap: 14px;
}

.auth-form label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
}

.auth-form input {
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-panel);
  outline: none;
}

.auth-form input:focus {
  border-color: var(--brand);
}

.btn-primary {
  margin-top: 6px;
  padding: 12px;
  border-radius: 24px;
  background: var(--brand);
  color: #fff;
  font-weight: 500;
  transition: background 0.15s;
}

.btn-primary:hover {
  background: var(--brand-dark);
}

.auth-hint {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-top: -4px;
}

.label-optional {
  font-size: 11.5px;
  font-style: italic;
  color: var(--text-faint);
}

.auth-server {
  margin-top: 14px;
  font-size: 12.5px;
  color: var(--text-muted);
  text-align: center;
  word-break: break-all;
}

.auth-build {
  margin-top: 8px;
  font-size: 11.5px;
  color: var(--text-muted);
  text-align: center;
  opacity: 0.75;
}

/* Paquet plus ancien que le code en service : l'avertissement doit se voir. */
.auth-build.is-outdated {
  color: #d17c00;
  opacity: 1;
  font-weight: 500;
}

.link-button {
  color: var(--brand);
  text-decoration: underline;
  font-size: inherit;
}

.auth-error {
  margin-top: 16px;
  padding: 10px 12px;
  border-radius: 6px;
  background: rgba(241, 92, 109, 0.12);
  color: #d32f4a;
  font-size: 13px;
}

/* ------------------------------------------------------------------ *
 * Structure de l'application
 * ------------------------------------------------------------------ */

.app {
  display: flex;
  height: 100%;
  max-width: 1600px;
  margin: 0 auto;
  background: var(--bg-panel);
  box-shadow: 0 6px 30px rgba(11, 20, 26, 0.06);
}

.app::before {
  content: '';
  position: fixed;
  inset: 0 0 auto;
  height: 127px;
  background: var(--brand-dark);
  z-index: -1;
}

[data-theme='dark'] .app::before {
  background: var(--bg-panel);
}

.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-min);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--bg-panel);
}

.sidebar-header {
  height: var(--header-height);
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--bg-panel-alt);
}

.sidebar-actions {
  display: flex;
  gap: 2px;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s;
}

.icon-button:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.icon-button.is-active {
  color: var(--brand);
}

.avatar-button {
  border-radius: 50%;
}

.avatar {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 50%;
  background: var(--brand);
  background-size: cover;
  background-position: center;
  color: #fff;
  font-size: 15px;
  font-weight: 500;
  overflow: hidden;
  user-select: none;
}

.avatar.avatar-lg {
  width: 96px;
  height: 96px;
  font-size: 34px;
}

.avatar.avatar-sm {
  width: 34px;
  height: 34px;
  font-size: 13px;
}

.sidebar-search {
  flex: none;
  padding: 7px 12px;
  border-bottom: 1px solid var(--border);
}

.search-field {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  border-radius: 8px;
  background: var(--bg-panel-alt);
}

.search-field svg {
  width: 18px;
  height: 18px;
  color: var(--text-faint);
}

.search-field input {
  flex: 1;
  padding: 9px 0;
  border: none;
  background: none;
  outline: none;
}

.chat-list {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.list-section-title {
  padding: 14px 16px 6px;
  font-size: 13px;
  color: var(--brand);
  font-weight: 500;
}

.chat-row {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 10px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  transition: background 0.12s;
}

.chat-row:hover {
  background: var(--bg-hover);
}

.chat-row.is-active {
  background: var(--bg-active);
}

.chat-row-main {
  flex: 1;
  min-width: 0;
}

.chat-row-top,
.chat-row-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.chat-row-name {
  font-size: 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-row-stamp {
  flex: none;
  font-size: 12px;
  color: var(--text-muted);
}

.chat-row.has-unread .chat-row-stamp {
  color: var(--brand);
}

.chat-row-preview {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  font-size: 14px;
  color: var(--text-muted);
}

.chat-row-preview span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge {
  flex: none;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--brand);
  color: #fff;
  font-size: 12px;
  line-height: 20px;
  text-align: center;
}

.empty-hint {
  padding: 30px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

/* ------------------------------------------------------------------ *
 * Zone de conversation
 * ------------------------------------------------------------------ */

.chat {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  background: var(--bg-chat);
}

.chat-empty {
  flex: 1;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  text-align: center;
  padding: 30px;
  background: var(--bg-panel-alt);
  border-bottom: 6px solid var(--brand);
  color: var(--text-muted);
}

.chat-empty h2 {
  font-size: 28px;
  font-weight: 300;
  color: var(--text);
}

.chat-empty p {
  font-size: 14px;
  line-height: 1.6;
}

.chat-view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.chat-header {
  height: var(--header-height);
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  background: var(--bg-panel-alt);
  border-left: 1px solid var(--border);
}

.chat-header-identity {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  text-align: left;
}

/* Les boutons se rangent en ligne. Sans cette règle ils s'empilent — invisible
   tant qu'il n'y en avait qu'un, mais les suivants débordaient alors des
   soixante pixels de l'en-tête et disparaissaient. */
.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: none;
}

.chat-header-text {
  display: grid;
  min-width: 0;
}

.chat-header-text strong {
  font-size: 16px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-header-text small {
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-header-text small.is-typing {
  color: var(--brand);
}

.back-button {
  display: none;
}

.messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 12px 6%;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background-color: var(--bg-chat);
  background-image: url('/img/wallpaper.svg');
  background-size: 420px;
  background-repeat: repeat;
}

/* Le motif du fond est tracé en sombre : il lui faut sa variante claire. */
[data-theme='dark'] .messages {
  background-image: url('/img/wallpaper-dark.svg');
}

.day-separator {
  align-self: center;
  margin: 12px 0;
  padding: 5px 12px;
  border-radius: 8px;
  background: var(--bg-panel-alt);
  box-shadow: var(--shadow);
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
}

.system-message {
  align-self: center;
  margin: 6px 0;
  padding: 5px 12px;
  border-radius: 8px;
  background: var(--bg-panel-alt);
  box-shadow: var(--shadow);
  font-size: 12.5px;
  color: var(--text-muted);
}

.bubble-row {
  display: flex;
  max-width: 100%;
}

.bubble-row.is-out {
  justify-content: flex-end;
}

.bubble-row.is-grouped {
  margin-top: 0;
}

.bubble-row:not(.is-grouped) {
  margin-top: 10px;
}

.bubble {
  position: relative;
  max-width: min(65%, 560px);
  padding: 6px 9px 8px;
  border-radius: var(--radius-bubble);
  background: var(--bubble-in);
  box-shadow: var(--shadow);
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

.bubble-row.is-out .bubble {
  background: var(--bubble-out);
}

.bubble-row:not(.is-grouped) .bubble::before {
  content: '';
  position: absolute;
  top: 0;
  width: 8px;
  height: 13px;
  background: inherit;
}

.bubble-row:not(.is-grouped):not(.is-out) .bubble::before {
  left: -7px;
  clip-path: polygon(100% 0, 100% 100%, 0 0);
}

.bubble-row.is-out:not(.is-grouped) .bubble::before {
  right: -7px;
  clip-path: polygon(0 0, 100% 0, 0 100%);
}

.bubble-author {
  display: block;
  margin-bottom: 2px;
  font-size: 12.8px;
  font-weight: 500;
}

.bubble-body {
  font-size: 14.2px;
  line-height: 1.42;
  white-space: pre-wrap;
  padding-right: 62px;
}

.bubble-body code {
  font-family: ui-monospace, 'SFMono-Regular', Consolas, monospace;
  font-size: 13px;
  background: rgba(11, 20, 26, 0.08);
  padding: 1px 4px;
  border-radius: 3px;
}

[data-theme='dark'] .bubble-body code {
  background: rgba(233, 237, 239, 0.12);
}

.bubble-deleted {
  font-style: italic;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.bubble-meta {
  position: absolute;
  right: 9px;
  bottom: 5px;
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  color: var(--text-faint);
  line-height: 1;
}

.bubble-meta svg {
  width: 16px;
  height: 16px;
}

.bubble-meta .tick-read {
  color: var(--tick-read);
}

.bubble-quote {
  display: block;
  margin-bottom: 4px;
  padding: 5px 8px;
  border-left: 4px solid var(--brand);
  border-radius: 4px;
  background: rgba(11, 20, 26, 0.06);
  font-size: 13px;
  cursor: pointer;
}

[data-theme='dark'] .bubble-quote {
  background: rgba(233, 237, 239, 0.08);
}

.bubble-quote strong {
  display: block;
  color: var(--brand);
  font-size: 12.8px;
}

.bubble-quote span {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--text-muted);
}

.bubble-image {
  display: block;
  max-width: 100%;
  max-height: 340px;
  border-radius: 6px;
  margin-bottom: 3px;
  cursor: zoom-in;
}

.bubble-file {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px;
  border-radius: 6px;
  background: rgba(11, 20, 26, 0.06);
  color: inherit;
  text-decoration: none;
  margin-bottom: 3px;
  min-width: 220px;
}

[data-theme='dark'] .bubble-file {
  background: rgba(233, 237, 239, 0.08);
}

.bubble-file-name {
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bubble-file-size {
  font-size: 12px;
  color: var(--text-muted);
}

/* ------------------------------------------------------------------ *
 * Notes vocales
 * ------------------------------------------------------------------ */

.bubble-audio {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 220px;
  padding: 4px 2px 6px;
}

.audio-play {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
}

.audio-play svg {
  width: 20px;
  height: 20px;
}

.audio-track {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: rgba(11, 20, 26, 0.18);
  cursor: pointer;
  /* La barre est fine : on élargit la zone cliquable sans l'épaissir. */
  padding: 12px 0;
  background-clip: content-box;
}

[data-theme='dark'] .audio-track {
  background: rgba(233, 237, 239, 0.22);
  background-clip: content-box;
}

.audio-progress {
  height: 100%;
  width: 0;
  border-radius: 2px;
  background: var(--brand);
  transition: width 0.1s linear;
}

.audio-time {
  flex: none;
  min-width: 40px;
  text-align: right;
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------------ *
 * Enregistrement en cours
 * ------------------------------------------------------------------ */

.recorder {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  padding: 0 6px;
}

.recorder-dot {
  width: 10px;
  height: 10px;
  flex: none;
  border-radius: 50%;
  background: #f15c6d;
  animation: recorder-pulse 1.2s ease-in-out infinite;
}

@keyframes recorder-pulse {
  50% {
    opacity: 0.25;
  }
}

@media (prefers-reduced-motion: reduce) {
  .recorder-dot {
    animation: none;
  }
}

.recorder-time {
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.recorder-hint {
  flex: 1;
  font-size: 13px;
  color: var(--text-muted);
}

.bubble-actions {
  position: absolute;
  top: 2px;
  right: 2px;
  opacity: 0;
  transition: opacity 0.12s;
}

.bubble:hover .bubble-actions,
.bubble-actions:focus-within {
  opacity: 1;
}

/* Sans souris, il n'y a pas de survol : le bouton resterait introuvable. */
@media (hover: none) {
  .bubble-actions {
    opacity: 0.5;
  }
}

.bubble-actions .icon-button {
  width: 26px;
  height: 26px;
}

.bubble-actions svg {
  width: 18px;
  height: 18px;
}

.bubble-highlight {
  animation: flash 1.4s ease-out;
}

@keyframes flash {
  0%,
  40% {
    background-color: rgba(0, 168, 132, 0.35);
  }
}

.context-menu {
  position: fixed;
  z-index: 30;
  min-width: 180px;
  padding: 6px 0;
  border-radius: 6px;
  background: var(--bg-panel);
  box-shadow: 0 4px 16px rgba(11, 20, 26, 0.3);
}

.context-menu button {
  display: block;
  width: 100%;
  padding: 10px 20px;
  text-align: left;
  font-size: 14px;
}

.context-menu button:hover {
  background: var(--bg-hover);
}

.context-menu button.is-danger {
  color: #f15c6d;
}

.typing-bar {
  flex: none;
  padding: 2px 6% 6px;
  font-size: 13px;
  color: var(--brand);
  background: var(--bg-chat);
}

.reply-bar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  background: var(--bg-panel-alt);
  border-top: 1px solid var(--border);
}

.reply-preview {
  flex: 1;
  min-width: 0;
  border-left: 4px solid var(--brand);
  padding-left: 8px;
}

.reply-author {
  display: block;
  font-size: 13px;
  color: var(--brand);
  font-weight: 500;
}

.reply-text {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.composer {
  flex: none;
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 8px 16px;
  background: var(--bg-panel-alt);
}

.composer-input {
  flex: 1;
  display: flex;
  align-items: center;
  padding: 0 12px;
  border-radius: 8px;
  background: var(--bg-panel);
}

.composer-input textarea {
  flex: 1;
  max-height: 140px;
  padding: 11px 0;
  border: none;
  background: none;
  outline: none;
  resize: none;
  line-height: 1.4;
  font-size: 15px;
}

.send-button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 50%;
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s;
}

.send-button:hover {
  background: var(--bg-hover);
  color: var(--brand);
}

.emoji-panel {
  position: absolute;
  left: 16px;
  bottom: 72px;
  width: min(340px, calc(100% - 32px));
  max-height: 260px;
  overflow-y: auto;
  padding: 10px;
  border-radius: 10px;
  background: var(--bg-panel);
  box-shadow: 0 6px 24px rgba(11, 20, 26, 0.28);
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  z-index: 12;
}

.emoji-panel button {
  width: 38px;
  height: 38px;
  border-radius: 6px;
  font-size: 22px;
  line-height: 1;
}

.emoji-panel button:hover {
  background: var(--bg-hover);
}

/* ------------------------------------------------------------------ *
 * Tiroir latéral
 * ------------------------------------------------------------------ */

.drawer {
  width: 380px;
  flex: none;
  display: flex;
  flex-direction: column;
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
}

.drawer-header {
  height: var(--header-height);
  flex: none;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 16px;
  background: var(--bg-panel-alt);
}

.drawer-header h2 {
  font-size: 16px;
  font-weight: 500;
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 24px;
}

.drawer-hero {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 24px 20px;
  background: var(--bg-panel);
}

.drawer-hero h3 {
  font-size: 20px;
  font-weight: 400;
}

.drawer-hero p {
  font-size: 14px;
  color: var(--text-muted);
}

.drawer-field {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}

.drawer-field label {
  display: block;
  font-size: 13px;
  color: var(--brand);
  margin-bottom: 8px;
}

.drawer-field input,
.drawer-field textarea {
  width: 100%;
  padding: 8px 0;
  border: none;
  border-bottom: 2px solid var(--border);
  background: none;
  outline: none;
  resize: none;
}

.drawer-field input:focus,
.drawer-field textarea:focus {
  border-color: var(--brand);
}

.drawer-note {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-top: 6px;
}

.drawer-list {
  margin: 6px 0 0 18px;
  font-size: 13.5px;
  color: var(--text-muted);
  line-height: 1.7;
}

/* Sélecteur renforcé : `.drawer-field label` est plus spécifique par défaut. */
.drawer-field label.drawer-checkbox {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
}

.drawer-checkbox input {
  width: auto;
  margin-top: 3px;
  accent-color: var(--brand);
}

.drawer-actions {
  padding: 16px 20px;
  display: grid;
  gap: 10px;
}

.btn-outline {
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text);
}

.btn-outline:hover {
  background: var(--bg-hover);
}

.btn-danger {
  padding: 10px;
  border-radius: 20px;
  color: #f15c6d;
}

.btn-danger:hover {
  background: rgba(241, 92, 109, 0.1);
}

.user-row {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 10px 20px;
  text-align: left;
}

.user-row:hover {
  background: var(--bg-hover);
}

.user-row-main {
  flex: 1;
  min-width: 0;
}

.user-row-main strong {
  display: block;
  font-size: 15px;
  font-weight: 400;
}

.user-row-main small {
  font-size: 13px;
  color: var(--text-muted);
}

.user-row .presence-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--brand);
  flex: none;
}

.selected-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 20px;
}

.chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 4px;
  border-radius: 16px;
  background: var(--bg-panel-alt);
  font-size: 13px;
}

.chip .avatar {
  width: 24px;
  height: 24px;
  font-size: 11px;
}

/* ------------------------------------------------------------------ *
 * Divers
 * ------------------------------------------------------------------ */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 40px;
  background: var(--overlay);
}

.lightbox img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 4px;
}

.lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  color: #fff;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translateX(-50%);
  z-index: 60;
  padding: 12px 20px;
  border-radius: 6px;
  background: #202c33;
  color: #e9edef;
  font-size: 14px;
  box-shadow: 0 6px 24px rgba(11, 20, 26, 0.4);
}

[hidden] {
  display: none !important;
}

/* ------------------------------------------------------------------ *
 * Application native : encoche, barre système, clavier
 * ------------------------------------------------------------------ */

/*
 * `viewport-fit=cover` fait passer la page sous l'encoche et sous la barre de
 * navigation : les en-têtes et la zone de saisie doivent s'en écarter d'eux-mêmes.
 */
.sidebar-header,
.chat-header,
.drawer-header {
  padding-top: env(safe-area-inset-top);
  height: calc(var(--header-height) + env(safe-area-inset-top));
}

.auth-screen {
  padding-top: calc(20px + env(safe-area-inset-top));
  padding-bottom: calc(20px + env(safe-area-inset-bottom));
}

.composer {
  padding-bottom: calc(8px + env(safe-area-inset-bottom));
}

.lightbox-close {
  top: calc(16px + env(safe-area-inset-top));
}

/* Le clavier logiciel réduit la fenêtre : Capacitor le signale par cette classe. */
body.keyboard-is-open .composer {
  padding-bottom: 8px;
}

/* Pas de surlignage bleu au toucher, ni de sélection intempestive. */
.app button,
.app .chat-row,
.app .user-row {
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

/* ------------------------------------------------------------------ *
 * Responsive : une seule colonne visible sur mobile
 * ------------------------------------------------------------------ */

@media (max-width: 900px) {
  .app::before {
    display: none;
  }

  .sidebar {
    width: 100%;
    min-width: 0;
  }

  .chat {
    display: none;
  }

  .drawer {
    position: fixed;
    inset: 0;
    width: 100%;
    z-index: 20;
  }

  body.is-chat-open .sidebar {
    display: none;
  }

  body.is-chat-open .chat {
    display: flex;
  }

  .back-button {
    display: grid;
  }

  .messages {
    padding: 10px 12px;
  }

  .bubble {
    max-width: 85%;
  }

  .typing-bar {
    padding-inline: 12px;
  }
}

/* ------------------------------------------------------------------ *
 * Appels
 * ------------------------------------------------------------------ */

.call-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  background: linear-gradient(160deg, #0b3b32, #051b17 60%);
  color: #fff;
  /* Encoche et barre système du mobile : l'écran d'appel est plein cadre. */
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}

/* En audio, aucune image à montrer : la vidéo distante reste hors du flux. */
.call-remote {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
  display: none;
}

.call-overlay.is-video .call-remote {
  display: block;
}

.call-local {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 16px);
  right: 16px;
  width: 108px;
  border-radius: 10px;
  object-fit: cover;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.45);
  /* L'aperçu de sa propre caméra est inversé, comme un miroir. */
  transform: scaleX(-1);
  z-index: 2;
}

.call-panel {
  position: relative;
  z-index: 3;
  display: grid;
  gap: 6px;
  justify-items: center;
  padding: 32px 20px 44px;
  text-align: center;
}

.call-overlay.is-video .call-panel {
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.6));
}

/* En audio, le nom occupe le centre de l'écran plutôt que le bas. */
.call-overlay:not(.is-video) .call-panel {
  margin-bottom: auto;
  margin-top: auto;
}

.call-peer {
  font-size: 24px;
  font-weight: 500;
}

.call-state {
  font-size: 15px;
  color: rgba(255, 255, 255, 0.75);
  font-variant-numeric: tabular-nums;
  min-height: 22px;
}

.call-actions {
  display: flex;
  gap: 18px;
  margin-top: 26px;
}

.call-button {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  transition: background 0.15s, transform 0.1s;
}

.call-button:active {
  transform: scale(0.94);
}

.call-button svg {
  width: 26px;
  height: 26px;
}

.call-button.is-off {
  background: #fff;
  color: #0b3b32;
}

.call-button.is-accept {
  background: #25d366;
}

.call-button.is-refuse {
  background: #f15c6d;
}

/* Le bouton « raccrocher » reprend l'icône de décrochage, retournée. */
.call-button.is-refuse svg {
  transform: rotate(135deg);
}

/* Pendant un appel, l'application ne défile pas derrière l'écran plein cadre. */
body.is-calling {
  overflow: hidden;
}
