/* Palabre — interface web
   Palette « indigo » : la teinture à l'indigo et les motifs adire servent de fil conducteur. */
:root {
  --nuit: #1D2557;
  --nuit-2: #2A3470;
  --indigo: #3447C4;
  --indigo-soft: #DCE2FF;
  --indigo-wash: #EEF1FF;
  --souci: #E9A100;
  --encre: #161A2E;
  --gris: #5F6680;
  --gris-2: #8C92A8;
  --ligne: #DFE3EE;
  --surface: #FFFFFF;
  --fond: #F4F5FA;
  --mur: #E7EAF3;
  --danger: #C2352B;
  --ok: #1F8A5B;

  --av0: #3447C4; --av1: #B5487A; --av2: #1F8A5B; --av3: #C4661A;
  --av4: #6A4BC4; --av5: #0E7C90; --av6: #9A3B3B; --av7: #5C6B1F;

  --font-ui: 'Figtree', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-brand: 'Bricolage Grotesque', 'Figtree', system-ui, sans-serif;
  --radius-bubble: 14px;
  --side-w: 400px;
  --adire: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='96' height='96' viewBox='0 0 96 96'%3E%3Cg fill='none' stroke='%231D2557' stroke-opacity='.07' stroke-width='1.6'%3E%3Ccircle cx='24' cy='24' r='11'/%3E%3Ccircle cx='24' cy='24' r='5.5'/%3E%3Cpath d='M0 74l8-8 8 8 8-8 8 8 8-8 8 8'/%3E%3Cpath d='M72 58l14 14-14 14-14-14z'/%3E%3Cpath d='M72 65l7 7-7 7-7-7z'/%3E%3Cpath d='M58 10v28M86 10v28'/%3E%3C/g%3E%3Cg fill='%231D2557' fill-opacity='.075'%3E%3Ccircle cx='24' cy='24' r='1.8'/%3E%3Ccircle cx='72' cy='16' r='2'/%3E%3Ccircle cx='72' cy='24' r='2'/%3E%3Ccircle cx='72' cy='32' r='2'/%3E%3Ccircle cx='8' cy='52' r='1.6'/%3E%3Ccircle cx='40' cy='52' r='1.6'/%3E%3C/g%3E%3C/svg%3E");
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.4;
  color: var(--encre);
  background: var(--fond);
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: var(--indigo); }
:focus-visible { outline: 2px solid var(--souci); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.icon { width: 22px; height: 22px; display: inline-block; flex: none; }
.icon svg { width: 100%; height: 100%; display: block; }

/* ---------------------------------------------------------------- Boutons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 42px; padding: 0 18px; border-radius: 10px;
  font-weight: 600; background: var(--indigo); color: #fff;
  transition: background .15s;
}
.btn:hover { background: #2a3aa8; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.secondary { background: var(--indigo-wash); color: var(--indigo); }
.btn.secondary:hover { background: var(--indigo-soft); }
.btn.danger { background: transparent; color: var(--danger); padding: 0 10px; }
.btn.danger:hover { background: #fbecea; }
.btn.small { height: 34px; padding: 0 12px; font-size: 14px; border-radius: 8px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%;
  display: inline-grid; place-items: center; color: var(--gris);
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: rgba(29, 37, 87, .07); color: var(--encre); }
.icon-btn.on-dark { color: #C9CFF0; }
.icon-btn.on-dark:hover { background: rgba(255, 255, 255, .1); color: #fff; }

.field { display: grid; gap: 6px; margin-bottom: 14px; align-content: start; }
.field label { font-size: 13px; font-weight: 600; color: var(--gris); }
.field .hint { font-size: 12.5px; color: var(--gris-2); }
.input {
  width: 100%; height: 44px; padding: 0 14px; border-radius: 10px;
  border: 1.5px solid var(--ligne); background: #fff; outline: none;
  transition: border-color .15s;
}
.input:focus { border-color: var(--indigo); }
textarea.input { height: auto; min-height: 80px; padding: 10px 14px; resize: vertical; }
.form-error { color: var(--danger); font-size: 14px; min-height: 20px; margin: 4px 0 10px; }

/* ---------------------------------------------------------------- Avatars */
.avatar {
  --c: var(--av0);
  width: 48px; height: 48px; border-radius: 50%; flex: none;
  display: grid; place-items: center; position: relative;
  background: var(--c); color: #fff; font-weight: 700; font-size: 17px; letter-spacing: .02em;
}
.avatar .icon { width: 50%; height: 50%; }
.avatar.sm { width: 40px; height: 40px; font-size: 15px; }
.avatar.xs { width: 32px; height: 32px; font-size: 13px; }
.avatar.xl { width: 112px; height: 112px; font-size: 38px; }
.avatar.group { border-radius: 30%; }
.avatar .online-dot {
  position: absolute; right: 1px; bottom: 1px; width: 12px; height: 12px; border-radius: 50%;
  background: #2DBE7C; border: 2px solid #fff;
}
.avatar .biz-mark {
  position: absolute; right: -2px; bottom: -2px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--souci); color: var(--nuit); border: 2px solid #fff;
  display: grid; place-items: center; font-size: 10px; font-weight: 800;
}

/* ---------------------------------------------------------------- Écran de connexion */
.auth {
  min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(360px, 1fr);
  background: var(--fond);
}
.auth-art {
  position: relative; overflow: hidden; background: var(--nuit); color: #fff;
  display: flex; flex-direction: column; justify-content: flex-end; padding: 56px;
}
.auth-art::before {
  content: ''; position: absolute; inset: 0; background-image: var(--adire); background-size: 120px;
  filter: invert(1); opacity: .9;
}
.auth-art > * { position: relative; }
.wordmark {
  font-family: var(--font-brand); font-weight: 800; letter-spacing: -.035em; line-height: .86;
  font-size: clamp(64px, 10vw, 148px); margin: 0;
}
.wordmark .dot { color: var(--souci); }
.auth-art p { max-width: 30ch; font-size: 19px; color: #C9CFF0; margin: 22px 0 0; }
.auth-panel { display: grid; place-items: center; padding: 40px 24px; }
.auth-card { width: min(400px, 100%); }
.auth-card h2 { font-family: var(--font-brand); font-size: 30px; letter-spacing: -.02em; margin: 0 0 6px; }
.auth-card .lead { color: var(--gris); margin: 0 0 26px; }
.auth-card .btn { width: 100%; margin-top: 4px; }
.auth-switch { margin-top: 18px; color: var(--gris); font-size: 14px; text-align: center; }
.auth-switch button { color: var(--indigo); font-weight: 600; }

/* ---------------------------------------------------------------- Mise en page principale */
.app { height: 100dvh; display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); overflow: hidden; }
.side { position: relative; display: flex; flex-direction: column; background: var(--surface); border-right: 1px solid var(--ligne); min-height: 0; }
.main { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--mur); }

.side-head {
  height: 64px; padding: 0 10px 0 14px; display: flex; align-items: center; gap: 10px;
  background: var(--nuit); color: #fff; flex: none;
}
.side-head .brand { font-family: var(--font-brand); font-weight: 800; font-size: 23px; letter-spacing: -.03em; margin-right: auto; }
.side-head .brand .dot { color: var(--souci); }
.side-head .me { border-radius: 50%; }

.search { padding: 10px 12px; border-bottom: 1px solid var(--ligne); flex: none; }
.search-box { display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px; border-radius: 10px; background: var(--fond); color: var(--gris-2); }
.search-box input { flex: 1; border: 0; outline: none; background: transparent; min-width: 0; color: var(--encre); }
.search-box .icon { width: 18px; height: 18px; }

.chat-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.chat-item {
  display: flex; gap: 12px; align-items: center; padding: 10px 14px; cursor: pointer;
  border-bottom: 1px solid #F0F2F7; width: 100%; text-align: left;
}
.chat-item:hover { background: var(--fond); }
.chat-item.active { background: var(--indigo-wash); }
.chat-item .body { flex: 1; min-width: 0; }
.chat-item .row1, .chat-item .row2 { display: flex; align-items: center; gap: 8px; }
.chat-item .name { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-item .time { font-size: 12px; color: var(--gris-2); flex: none; }
.chat-item.unread .time { color: var(--souci); font-weight: 700; }
.chat-item .preview { flex: 1; min-width: 0; color: var(--gris); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: 4px; }
.chat-item .preview .txt { overflow: hidden; text-overflow: ellipsis; }
.chat-item .preview.typing { color: var(--indigo); font-weight: 600; }
.badge { min-width: 21px; height: 21px; padding: 0 6px; border-radius: 11px; background: var(--souci); color: var(--nuit); font-size: 12px; font-weight: 800; display: grid; place-items: center; flex: none; }
.empty-list { padding: 40px 28px; text-align: center; color: var(--gris); }
.empty-list .btn { margin-top: 14px; }

/* ---------------------------------------------------------------- Tiroirs latéraux */
.drawer {
  position: absolute; inset: 0; z-index: 20; background: var(--surface);
  display: flex; flex-direction: column; animation: drawer-in .2s ease-out;
}
@keyframes drawer-in { from { transform: translateX(-24px); opacity: 0; } }
.drawer-head { height: 64px; display: flex; align-items: center; gap: 8px; padding: 0 10px; background: var(--nuit); color: #fff; flex: none; }
.drawer-head h3 { font-size: 18px; font-weight: 600; margin: 0; }
.drawer-body { flex: 1; overflow-y: auto; padding: 18px; }
.drawer-foot { padding: 14px 18px; border-top: 1px solid var(--ligne); }
.pick-list { list-style: none; margin: 0 -18px; padding: 0; }
.pick-item { display: flex; align-items: center; gap: 12px; padding: 9px 18px; cursor: pointer; width: 100%; text-align: left; }
.pick-item:hover { background: var(--fond); }
.pick-item .meta { flex: 1; min-width: 0; }
.pick-item .meta .n { font-weight: 600; }
.pick-item .meta .s { font-size: 13px; color: var(--gris); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-item .check { width: 22px; height: 22px; border-radius: 6px; border: 2px solid var(--ligne); display: grid; place-items: center; color: #fff; }
.pick-item.selected .check { background: var(--indigo); border-color: var(--indigo); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 10px; border-radius: 99px; background: var(--indigo-wash); color: var(--indigo); font-size: 13px; font-weight: 600; }
.chip button { width: 18px; height: 18px; display: grid; place-items: center; border-radius: 50%; }
.chip button:hover { background: var(--indigo-soft); }
.section-title { font-size: 13px; font-weight: 700; color: var(--indigo); margin: 18px 0 8px; }
.profile-top { display: grid; justify-items: center; gap: 10px; padding: 10px 0 18px; text-align: center; }
.profile-top .n { font-family: var(--font-brand); font-size: 24px; font-weight: 600; }
.profile-top .s { color: var(--gris); }

/* ---------------------------------------------------------------- Écran vide */
.empty-main { flex: 1; display: grid; place-items: center; padding: 32px; background-image: var(--adire); background-size: 120px; }
.empty-main .inner { text-align: center; max-width: 440px; background: rgba(244, 245, 250, .92); padding: 36px 32px; border-radius: 20px; }
.empty-main h2 { font-family: var(--font-brand); font-size: 34px; letter-spacing: -.02em; margin: 0 0 10px; }
.empty-main p { color: var(--gris); margin: 0 0 20px; }
.empty-main .actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ---------------------------------------------------------------- Conversation */
.convo-head {
  height: 64px; display: flex; align-items: center; gap: 12px; padding: 0 8px 0 12px;
  background: var(--surface); border-bottom: 1px solid var(--ligne); flex: none; z-index: 2;
}
.convo-head .who { flex: 1; min-width: 0; cursor: pointer; display: flex; align-items: center; gap: 12px; }
.convo-head .who .t { min-width: 0; }
.convo-head .title { font-weight: 700; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.convo-head .subtitle { font-size: 13px; color: var(--gris); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.convo-head .subtitle.live { color: var(--indigo); font-weight: 600; }
.convo-head .back { display: none; }

.messages {
  flex: 1; overflow-y: auto; padding: 14px 6% 10px;
  background-color: var(--mur); background-image: var(--adire); background-size: 120px;
  display: flex; flex-direction: column;
}
.messages .spacer { flex: 1; }
.day-sep { align-self: center; margin: 12px 0 8px; padding: 5px 12px; border-radius: 8px; background: rgba(255, 255, 255, .92); color: var(--gris); font-size: 12.5px; font-weight: 600; box-shadow: 0 1px 1px rgba(22, 26, 46, .06); }
.sys { align-self: center; margin: 6px 0; padding: 5px 12px; border-radius: 8px; background: #FFF6DC; color: #6B5310; font-size: 12.5px; text-align: center; max-width: 80%; }
.biz-banner { align-self: center; margin: 4px 0 10px; padding: 8px 14px; border-radius: 10px; background: #FFF6DC; color: #6B5310; font-size: 13px; text-align: center; max-width: 460px; }

.row { display: flex; flex-direction: column; margin-top: 2px; max-width: min(72%, 560px); position: relative; }
.row.first { margin-top: 10px; }
.row.in { align-self: flex-start; align-items: flex-start; }
.row.out { align-self: flex-end; align-items: flex-end; }
.bubble {
  position: relative; padding: 6px 9px 7px; border-radius: var(--radius-bubble);
  background: var(--surface); box-shadow: 0 1px 1px rgba(22, 26, 46, .08);
  min-width: 84px; max-width: 100%; overflow-wrap: anywhere;
}
.row.out .bubble { background: var(--indigo-soft); }
.row.in.first .bubble { border-top-left-radius: 4px; }
.row.out.first .bubble { border-top-right-radius: 4px; }
.bubble::after { content: ''; display: block; clear: both; }
.bubble .sender { font-size: 13px; font-weight: 700; margin-bottom: 2px; }
.bubble .text { white-space: pre-wrap; }
.bubble .text code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13.5px; background: rgba(29, 37, 87, .06); padding: 1px 4px; border-radius: 4px; }
.bubble .meta { float: right; display: inline-flex; align-items: center; gap: 3px; margin: 6px 0 -4px 10px; font-size: 11.5px; color: var(--gris-2); white-space: nowrap; position: relative; top: 3px; }
.bubble .meta.over { position: absolute; right: 8px; bottom: 8px; top: auto; margin: 0; padding: 1px 6px; border-radius: 8px; background: rgba(22, 26, 46, .45); color: #fff; }
.bubble .deleted { font-style: italic; color: var(--gris); }
.tick { width: 17px; height: 11px; display: inline-block; color: var(--gris-2); }
.tick.read { color: var(--indigo); }
.tick.failed { color: var(--danger); width: 14px; height: 14px; }
.meta.over .tick { color: #fff; }

.quote {
  display: flex; gap: 8px; margin: 0 0 5px; padding: 6px 8px; border-radius: 8px;
  background: rgba(29, 37, 87, .06); border-left: 4px solid var(--indigo); cursor: pointer; min-width: 0;
}
.quote .qt { min-width: 0; flex: 1; }
.quote .qn { font-size: 12.5px; font-weight: 700; color: var(--indigo); }
.quote .qp { font-size: 13px; color: var(--gris); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; white-space: normal; }
.quote img { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; }

.media-img { display: block; max-width: 100%; width: 320px; max-height: 360px; object-fit: cover; border-radius: 10px; cursor: zoom-in; background: var(--fond); }
.media-video { display: block; width: 320px; max-width: 100%; border-radius: 10px; background: #000; }
.media-wrap { position: relative; margin: -2px -5px 0; }
.caption { margin-top: 5px; white-space: pre-wrap; }
.sticker { width: 150px; height: 150px; object-fit: contain; }
.row.sticker-row .bubble { background: transparent; box-shadow: none; padding: 0; }

.audio { display: flex; align-items: center; gap: 8px; min-width: 260px; }
.audio audio { width: 230px; height: 38px; }
.audio .icon { color: var(--indigo); }

.doc { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; background: rgba(29, 37, 87, .05); min-width: 240px; text-decoration: none; color: inherit; }
.doc .icon { color: var(--indigo); width: 30px; height: 30px; }
.doc .dn { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 260px; }
.doc .ds { font-size: 12.5px; color: var(--gris); }

.loc { display: block; text-decoration: none; color: inherit; min-width: 240px; }
.loc .map { height: 120px; border-radius: 10px; display: grid; place-items: center; color: var(--danger); background-color: #DDE6D5; background-image: linear-gradient(90deg, rgba(255,255,255,.55) 2px, transparent 2px), linear-gradient(rgba(255,255,255,.55) 2px, transparent 2px), linear-gradient(35deg, transparent 46%, #F4E1A6 46%, #F4E1A6 54%, transparent 54%); background-size: 38px 38px, 38px 38px, 100% 100%; }
.loc .map .icon { width: 36px; height: 36px; }
.loc .ln { font-weight: 600; margin-top: 6px; }
.loc .la { font-size: 13px; color: var(--gris); }

.contact-card { display: flex; align-items: center; gap: 10px; min-width: 230px; padding: 4px 0; }
.contact-card + .contact-card { border-top: 1px solid var(--ligne); }
.contact-card .cn { font-weight: 600; }
.contact-card .cp { font-size: 13px; color: var(--gris); }

/* Messages interactifs (boutons, listes, modèles) */
.ix-header { font-weight: 700; margin-bottom: 4px; }
.ix-header-media { margin: -2px -5px 6px; }
.ix-footer { font-size: 13px; color: var(--gris-2); margin-top: 4px; clear: both; }
.ix-actions { display: grid; gap: 4px; margin-top: 6px; width: 100%; }
.ix-btn {
  display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 6px 12px;
  border-radius: 10px; background: var(--surface); color: var(--indigo); font-weight: 600; text-decoration: none;
  box-shadow: 0 1px 1px rgba(22, 26, 46, .08); transition: background .15s;
}
.ix-btn:hover { background: var(--indigo-wash); }
.ix-btn .icon { width: 18px; height: 18px; }
.ix-btn:disabled { color: var(--gris-2); cursor: default; }
.reply-title { font-weight: 500; }
.reply-desc { font-size: 13px; color: var(--gris); }

.reactions {
  display: inline-flex; gap: 2px; align-items: center; margin-top: -6px; padding: 2px 6px; z-index: 1;
  background: var(--surface); border-radius: 99px; box-shadow: 0 1px 3px rgba(22, 26, 46, .18); font-size: 14px; cursor: pointer;
}
.row.out .reactions { margin-right: 8px; }
.row.in .reactions { margin-left: 8px; }
.reactions .count { font-size: 12px; color: var(--gris); margin-left: 2px; }

.msg-menu-btn {
  position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center; color: var(--gris); background: inherit; opacity: 0; transition: opacity .1s;
}
.bubble:hover .msg-menu-btn, .msg-menu-btn:focus-visible { opacity: 1; }
.msg-menu-btn .icon { width: 18px; height: 18px; }
.row.flash .bubble { animation: flash 1.2s ease-out; }
@keyframes flash { 0%, 40% { box-shadow: 0 0 0 4px rgba(233, 161, 0, .55); } }

.scroll-down {
  position: absolute; right: 24px; bottom: 84px; width: 44px; height: 44px; border-radius: 50%;
  background: var(--surface); color: var(--gris); box-shadow: 0 2px 8px rgba(22, 26, 46, .2); display: grid; place-items: center; z-index: 3;
}
.scroll-down[hidden] { display: none; }
.scroll-down .badge { position: absolute; top: -6px; right: -4px; }

/* Barre de réponse et composeur */
.reply-bar { display: flex; align-items: center; gap: 8px; padding: 8px 12px 0; background: var(--fond); }
.reply-bar .quote { flex: 1; margin: 0; background: var(--surface); }
.composer { display: flex; align-items: flex-end; gap: 4px; padding: 8px 10px; background: var(--fond); flex: none; position: relative; }
.composer textarea {
  flex: 1; resize: none; border: 0; outline: none; border-radius: 22px; padding: 11px 16px;
  max-height: 140px; min-height: 44px; line-height: 22px; background: var(--surface);
  box-shadow: 0 1px 1px rgba(22, 26, 46, .06);
}
.composer .send { width: 44px; height: 44px; border-radius: 50%; background: var(--indigo); color: #fff; display: grid; place-items: center; flex: none; }
.composer .send:hover { background: #2a3aa8; }
.composer .send .icon { width: 21px; height: 21px; }
.composer .icon-btn { height: 44px; width: 42px; }
.recording { flex: 1; display: flex; align-items: center; gap: 12px; height: 44px; padding: 0 14px; border-radius: 22px; background: var(--surface); }
.recording .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: pulse 1s infinite alternate; }
@keyframes pulse { to { opacity: .25; } }
.recording .timer { font-variant-numeric: tabular-nums; font-weight: 600; }
.recording .lbl { color: var(--gris); flex: 1; }

/* Popovers */
.popover {
  position: fixed; z-index: 60; min-width: 200px; padding: 6px; border-radius: 12px;
  background: var(--surface); box-shadow: 0 10px 30px rgba(22, 26, 46, .22), 0 0 0 1px rgba(22, 26, 46, .05);
  animation: pop .12s ease-out;
}
@keyframes pop { from { transform: scale(.96); opacity: 0; } }
.popover .menu-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 12px; border-radius: 8px; text-align: left; }
.popover .menu-item:hover { background: var(--fond); }
.popover .menu-item .icon { width: 19px; height: 19px; color: var(--gris); }
.popover .menu-item.danger { color: var(--danger); }
.popover .menu-item.danger .icon { color: var(--danger); }
.react-row { display: flex; gap: 2px; padding: 2px 2px 6px; border-bottom: 1px solid var(--ligne); margin-bottom: 4px; }
.react-row button { width: 38px; height: 38px; border-radius: 50%; font-size: 22px; transition: transform .1s; }
.react-row button:hover { background: var(--fond); transform: scale(1.15); }
.react-row button.mine { background: var(--indigo-soft); }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 36px); gap: 2px; padding: 4px; }
.emoji-grid button { height: 36px; font-size: 22px; border-radius: 8px; }
.emoji-grid button:hover { background: var(--fond); }

/* Fenêtres modales */
.modal-back { position: fixed; inset: 0; z-index: 70; background: rgba(22, 26, 46, .45); display: grid; place-items: center; padding: 20px; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.modal { width: min(420px, 100%); max-height: 86vh; overflow: auto; background: var(--surface); border-radius: 16px; padding: 20px; box-shadow: 0 20px 50px rgba(22, 26, 46, .3); }
.modal h3 { margin: 0 0 14px; font-size: 18px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.list-option { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid #F0F2F7; cursor: pointer; }
.list-option input { accent-color: var(--indigo); width: 18px; height: 18px; }
.list-option .lt { font-weight: 600; }
.list-option .ld { font-size: 13px; color: var(--gris); }
.lightbox { position: fixed; inset: 0; z-index: 80; background: rgba(10, 12, 24, .92); display: grid; place-items: center; padding: 30px; cursor: zoom-out; animation: fade .15s; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 6px; }

/* Panneau d'info de groupe (à droite) */
.info-panel {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(380px, 100%); z-index: 15;
  background: var(--surface); border-left: 1px solid var(--ligne); display: flex; flex-direction: column;
  animation: panel-in .2s ease-out;
}
@keyframes panel-in { from { transform: translateX(24px); opacity: 0; } }
.info-panel .drawer-head { background: var(--surface); color: var(--encre); border-bottom: 1px solid var(--ligne); }
.role-tag { font-size: 11.5px; font-weight: 700; color: var(--ok); background: #E4F4EC; padding: 2px 8px; border-radius: 99px; }

/* Toasts */
#toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 90; display: grid; gap: 8px; justify-items: center; pointer-events: none; }
.toast { padding: 10px 16px; border-radius: 10px; background: var(--encre); color: #fff; font-size: 14px; box-shadow: 0 6px 20px rgba(22, 26, 46, .3); animation: pop .15s; max-width: 90vw; }
.toast.error { background: var(--danger); }

/* ---------------------------------------------------------------- Console développeur */
.console { flex: 1; overflow-y: auto; background: var(--fond); }
.console-inner { max-width: 940px; margin: 0 auto; padding: 28px 28px 60px; }
.console-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 22px; }
.console-head h2 { font-family: var(--font-brand); font-size: 30px; letter-spacing: -.02em; margin: 0 0 6px; }
.console-head p { margin: 0; color: var(--gris); max-width: 62ch; }
.console-head .back { display: none; }
.number-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.number-tab { display: flex; align-items: center; gap: 10px; padding: 8px 14px 8px 8px; border-radius: 12px; background: var(--surface); border: 1.5px solid var(--ligne); }
.number-tab.active { border-color: var(--indigo); background: var(--indigo-wash); }
.number-tab .nt-name { font-weight: 600; }
.number-tab .nt-num { font-size: 12.5px; color: var(--gris); }
.panel { background: var(--surface); border-radius: 14px; border: 1px solid var(--ligne); padding: 20px 22px; margin-bottom: 18px; }
.panel h3 { margin: 0 0 4px; font-size: 17px; }
.panel .desc { margin: 0 0 16px; color: var(--gris); font-size: 14px; }
.kv { display: grid; grid-template-columns: 170px minmax(0, 1fr) auto; gap: 10px 14px; align-items: center; }
.kv .k { font-size: 13.5px; color: var(--gris); font-weight: 600; }
.kv .v { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: var(--fond); padding: 7px 10px; border-radius: 8px; }
.kv .acts { display: flex; gap: 4px; }
.kv .acts .icon-btn { width: 34px; height: 34px; }
.kv .acts .icon { width: 18px; height: 18px; }
.webhook-form { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 0 12px; }
.webhook-form .full { grid-column: 1 / -1; }
.status-line { display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; font-weight: 600; }
.status-line.ok { color: var(--ok); }
.status-line.off { color: var(--gris); }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.code {
  position: relative; margin: 8px 0 14px; padding: 14px 16px; border-radius: 10px;
  background: #161A2E; color: #E3E6F5; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; line-height: 1.55;
  white-space: pre; overflow-x: auto;
}
.code .copy-code { position: absolute; top: 8px; right: 8px; padding: 4px 10px; border-radius: 6px; background: rgba(255, 255, 255, .1); color: #fff; font-family: var(--font-ui); font-size: 12px; font-weight: 600; }
.code .copy-code:hover { background: rgba(255, 255, 255, .2); }
.example-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.example-tabs button { padding: 6px 12px; border-radius: 8px; font-size: 13.5px; font-weight: 600; color: var(--gris); }
.example-tabs button.active { background: var(--indigo-wash); color: var(--indigo); }
.log { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.log th { text-align: left; font-size: 12.5px; color: var(--gris); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--ligne); }
.log td { padding: 8px; border-bottom: 1px solid #F0F2F7; vertical-align: top; }
.log tr.clickable { cursor: pointer; }
.log tr.clickable:hover td { background: var(--fond); }
.log .ok { color: var(--ok); font-weight: 700; }
.log .ko { color: var(--danger); font-weight: 700; }
.log .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.log-detail td { background: var(--fond); }
.log-detail .code { margin: 0; }
.muted { color: var(--gris); }

/* ---------------------------------------------------------------- Appels */
.btn.accept { background: var(--ok); }
.btn.accept:hover { background: #18734b; }
.call-banner {
  display: flex; align-items: center; gap: 10px; padding: 8px 14px; flex: none;
  background: #E4F4EC; color: #145C3C; border-bottom: 1px solid #CDE9DA; font-weight: 600; font-size: 14px;
}
.call-banner .icon { width: 20px; height: 20px; }
.call-banner .cb-text { flex: 1; }
.call-bubble { display: flex; align-items: center; gap: 10px; min-width: 230px; padding: 2px 0; white-space: normal; }
.call-icon { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: rgba(29, 37, 87, .08); color: var(--indigo); flex: none; }
.call-icon.bad { background: #FBECEA; color: var(--danger); }
.call-icon .icon { width: 20px; height: 20px; }
.cb-body { flex: 1; min-width: 0; }
.cb-title { font-weight: 600; }
.cb-sub { font-size: 13px; color: var(--gris); }
.cb-sub.bad { color: var(--danger); }
.call-bubble .btn { margin-left: 6px; }

.ring-card {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 88;
  width: min(440px, calc(100vw - 24px)); display: flex; align-items: center; gap: 14px;
  padding: 14px 16px; border-radius: 18px; background: var(--nuit); color: #fff;
  box-shadow: 0 16px 40px rgba(22, 26, 46, .35); animation: ring-in .25s ease-out;
}
@keyframes ring-in { from { transform: translate(-50%, -16px); opacity: 0; } }
.ring-avatar { position: relative; }
.ring-avatar::after { content: ''; position: absolute; inset: -5px; border-radius: 50%; border: 2px solid var(--souci); animation: ring-pulse 1.4s ease-out infinite; }
@keyframes ring-pulse { from { transform: scale(.9); opacity: 1; } to { transform: scale(1.25); opacity: 0; } }
.ring-text { flex: 1; min-width: 0; }
.ring-name { font-weight: 700; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ring-sub { font-size: 13.5px; color: #C9CFF0; }
.ring-btn { width: 50px; height: 50px; border-radius: 50%; display: grid; place-items: center; color: #fff; flex: none; transition: transform .1s; }
.ring-btn:hover { transform: scale(1.06); }
.ring-btn .icon { width: 24px; height: 24px; }
.ring-btn.accept { background: var(--ok); }
.ring-btn.decline { background: var(--danger); }
.ring-btn.small { width: 40px; height: 40px; }
.ring-btn.small .icon { width: 20px; height: 20px; }

.call-stage { position: fixed; inset: 0; z-index: 85; display: flex; flex-direction: column; background: #10142B; color: #fff; }
.stage-bar { display: flex; align-items: center; gap: 12px; padding: 10px 14px; background: var(--nuit); flex: none; }
.stage-title { flex: 1; min-width: 0; }
.st-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-status { font-size: 13px; color: #C9CFF0; font-variant-numeric: tabular-nums; }
.stage-frame { flex: 1; min-height: 0; position: relative; }
.stage-frame iframe { border: 0; display: block; }
.stage-wait { position: absolute; inset: 0; display: grid; place-content: center; gap: 14px; text-align: center; padding: 24px; color: #C9CFF0; }

/* ---------------------------------------------------------------- Mobile */
@media (max-width: 860px) {
  :root { --side-w: 100%; }
  .app { grid-template-columns: 1fr; }
  .app .main { display: none; }
  .app.show-main .side { display: none; }
  .app.show-main .main { display: flex; }
  .convo-head .back, .console-head .back { display: inline-grid; }
  .messages { padding: 10px 10px; }
  .row { max-width: 86%; }
  .auth { grid-template-columns: 1fr; }
  .auth-art { min-height: 260px; padding: 32px 24px; }
  .auth-art p { font-size: 16px; }
  .console-inner { padding: 18px 14px 40px; }
  .kv { grid-template-columns: 1fr auto; }
  .kv .k { grid-column: 1 / -1; margin-bottom: -6px; }
  .webhook-form { grid-template-columns: 1fr; }
}

/* Écrans tactiles : appui long sur une bulle pour ouvrir le menu du message. */
@media (hover: none) {
  .msg-menu-btn { display: none; }
  .bubble { -webkit-touch-callout: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
