/* =====================================================================
   ASIN Connect — design system v3 « Aurore »
   Nuit indigo + verre + dégradé aurore (vert ASIN → cyan → indigo).
   Thème sombre par défaut, thème clair via [data-theme="light"].
   ===================================================================== */
:root {
    --night: #0A1230;
    --night-2: #0E1840;
    --surface: rgba(138, 160, 255, .07);
    --surface-2: rgba(138, 160, 255, .12);
    --surface-solid: #131E4A;
    --line: rgba(160, 180, 255, .14);
    --line-strong: rgba(160, 180, 255, .26);
    --text: #EAF0FF;
    --text-2: #B9C4E8;
    --muted: #8591BD;
    --green: #00C389;
    --cyan: #18B7E8;
    --indigo: #6C7BFF;
    --gold: #FCD116;
    --red: #FF4D6A;
    --aurora: linear-gradient(135deg, #00C389 0%, #18B7E8 52%, #6C7BFF 100%);
    --aurora-soft: linear-gradient(135deg, rgba(0,195,137,.22), rgba(24,183,232,.18) 52%, rgba(108,123,255,.22));
    --bubble-in: rgba(138, 160, 255, .11);
    --bubble-in-text: #EAF0FF;
    --bubble-out-text: #04152A;
    --glow: 0 0 0 1px rgba(24,183,232,.35), 0 8px 30px rgba(24,183,232,.22);
    --shadow: 0 18px 50px rgba(2, 6, 25, .55);
    --blur: blur(22px) saturate(140%);
    --r-sm: 10px;
    --r-md: 16px;
    --r-lg: 24px;
    --font: "IBM Plex Sans", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
    --display: "Sora", "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
    color-scheme: dark;
}
:root[data-theme="light"] {
    --night: #EEF2FB;
    --night-2: #E3E9F8;
    --surface: rgba(255, 255, 255, .72);
    --surface-2: rgba(255, 255, 255, .92);
    --surface-solid: #FFFFFF;
    --line: rgba(20, 35, 90, .10);
    --line-strong: rgba(20, 35, 90, .18);
    --text: #0E1636;
    --text-2: #34406A;
    --muted: #6B7699;
    --gold: #C99A00;
    --bubble-in: #FFFFFF;
    --bubble-in-text: #0E1636;
    --bubble-out-text: #03182B;
    --glow: 0 0 0 1px rgba(24,183,232,.35), 0 8px 24px rgba(24,120,232,.15);
    --shadow: 0 18px 50px rgba(30, 45, 110, .14);
    color-scheme: light;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.45;
    color: var(--text);
    background-color: var(--night);
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}
/* Ciel de fond : deux halos + une trame très discrète */
body::before {
    content: ''; position: fixed; inset: 0; z-index: -1; pointer-events: none;
    background:
        radial-gradient(60vmax 50vmax at 8% -10%, rgba(0,195,137,.20), transparent 60%),
        radial-gradient(55vmax 45vmax at 105% 110%, rgba(108,123,255,.24), transparent 60%),
        radial-gradient(40vmax 30vmax at 70% 10%, rgba(24,183,232,.10), transparent 60%),
        var(--night);
}
body::after {
    content: ''; position: fixed; inset: 0; z-index: -1; pointer-events: none; opacity: .5;
    background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px);
    background-size: 44px 44px;
    -webkit-mask-image: radial-gradient(ellipse at 50% 0%, #000 0%, transparent 70%);
    mask-image: radial-gradient(ellipse at 50% 0%, #000 0%, transparent 70%);
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
a { color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; border-radius: 6px; }
::selection { background: rgba(24,183,232,.35); }
h1, h2, h3, .display { font-family: var(--display); letter-spacing: -.01em; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 9px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

.glass {
    background: var(--surface);
    -webkit-backdrop-filter: var(--blur);
    backdrop-filter: var(--blur);
    border: 1px solid var(--line);
}

/* ------------------------------------------------------------ Éléments communs */
.avatar, .avatar-sm {
    border-radius: 50%; flex-shrink: 0; color: #fff; font-family: var(--display); font-weight: 600; letter-spacing: .02em;
    display: inline-flex; align-items: center; justify-content: center; user-select: none;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.18);
}
.avatar-group { border-radius: 30%; }
.avatar-dept { border-radius: 30%; background: rgba(252,209,22,.16) !important; color: var(--gold); box-shadow: inset 0 0 0 1px rgba(252,209,22,.35); }
/* Anneau "en ligne" en dégradé aurore */
.presence { position: relative; display: inline-flex; border-radius: 50%; flex-shrink: 0; }
.presence::before {
    content: ''; position: absolute; inset: -3px; border-radius: 50%; padding: 2px;
    background: var(--aurora);
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor; mask-composite: exclude;
    opacity: 0; transform: scale(.9); transition: opacity .35s, transform .35s;
}
.presence.on::before { opacity: 1; transform: none; }
.presence.on::after {
    content: ''; position: absolute; right: 0; bottom: 0; width: 12px; height: 12px; border-radius: 50%;
    background: var(--green); border: 2px solid var(--night);
}

.icon-btn {
    position: relative; width: 40px; height: 40px; border-radius: 12px; color: var(--text-2);
    display: inline-flex; align-items: center; justify-content: center; text-decoration: none; flex-shrink: 0;
    transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn:active { transform: scale(.95); }
.icon-btn.danger:hover { color: var(--red); }
.icon-badge {
    position: absolute; top: 4px; right: 3px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px;
    background: var(--gold); color: #1A1400; font-size: 10.5px; font-weight: 700; display: flex; align-items: center; justify-content: center;
    box-shadow: 0 0 0 2px var(--night);
}

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 18px; border-radius: 14px;
    font-weight: 600; font-size: 15px; text-decoration: none; transition: transform .1s, box-shadow .2s, background .2s; white-space: nowrap;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--aurora); color: #031424; box-shadow: 0 8px 26px rgba(24,183,232,.28); }
.btn-primary:hover { box-shadow: 0 10px 34px rgba(24,183,232,.42); }
.btn-ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--line); }
.btn-ghost:hover { border-color: var(--line-strong); }
.btn-danger { background: rgba(255,77,106,.12); color: var(--red); border: 1px solid rgba(255,77,106,.3); }
.btn-danger:hover { background: rgba(255,77,106,.2); }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: default; }

.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 7px; }
.field small { display: block; font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.input, .field input, .field textarea, .field select {
    width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line-strong);
    background: rgba(5, 10, 35, .35); color: var(--text); font-size: 15px; outline: none; transition: border-color .15s, box-shadow .15s;
}
:root[data-theme="light"] .input, :root[data-theme="light"] .field input, :root[data-theme="light"] .field textarea, :root[data-theme="light"] .field select { background: #fff; }
.input:focus, .field input:focus, .field textarea:focus, .field select:focus { border-color: var(--cyan); box-shadow: 0 0 0 4px rgba(24,183,232,.16); }
.field textarea { resize: vertical; min-height: 84px; }
.field select option { background: var(--surface-solid); color: var(--text); }
::placeholder { color: var(--muted); opacity: 1; }

.alert { padding: 11px 14px; border-radius: 12px; font-size: 14px; margin-bottom: 16px; border: 1px solid; }
.alert-ok { background: rgba(0,195,137,.12); border-color: rgba(0,195,137,.35); color: var(--green); }
.alert-err { background: rgba(255,77,106,.10); border-color: rgba(255,77,106,.35); color: var(--red); }
.alert-info { background: rgba(24,183,232,.10); border-color: rgba(24,183,232,.35); color: var(--cyan); }

/* Toast */
.toast {
    position: fixed; bottom: calc(96px + env(safe-area-inset-bottom)); left: 50%; transform: translate(-50%, 12px); max-width: calc(100% - 32px);
    background: var(--surface-solid); color: var(--text); border: 1px solid var(--line-strong); padding: 11px 18px; border-radius: 14px;
    font-size: 14px; z-index: 3000; opacity: 0; transition: opacity .25s, transform .25s; pointer-events: none; text-align: center; box-shadow: var(--shadow);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { border-color: rgba(255,77,106,.5); color: var(--red); }

/* ------------------------------------------------------------ Coquille : 2 panneaux */
.layout { display: flex; height: 100vh; height: 100dvh; gap: 14px; padding: 14px; max-width: 1480px; margin: 0 auto; }
.sidebar { width: 380px; flex-shrink: 0; border-radius: var(--r-lg); display: flex; flex-direction: column; overflow: hidden; position: relative; }
.main { flex: 1; min-width: 0; border-radius: var(--r-lg); display: flex; flex-direction: column; overflow: hidden; position: relative; }
@media (max-width: 899px) {
    .layout { padding: 0; gap: 0; }
    .sidebar, .main { border-radius: 0; border-left: 0; border-right: 0; }
    .layout.is-home .main { display: none; }
    .layout.is-home .sidebar { width: 100%; }
    .layout.is-conv .sidebar { display: none; }
}

.side-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 16px 12px 10px 18px; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark {
    width: 40px; height: 40px; border-radius: 13px; background: var(--aurora); display: flex; align-items: center; justify-content: center; flex-shrink: 0;
    box-shadow: 0 6px 20px rgba(24,183,232,.35);
}
.brand-mark span { font-family: var(--display); font-weight: 700; font-size: 14px; color: #031424; }
.brand-name { font-family: var(--display); font-weight: 700; font-size: 18px; letter-spacing: -.02em; }
.brand-user { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px rgba(0,195,137,.2); flex-shrink: 0; }
.side-actions { display: flex; align-items: center; }

.side-search { position: relative; margin: 6px 14px 10px; }
.side-search svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.side-search input {
    width: 100%; padding: 11px 14px 11px 38px; border-radius: 14px; border: 1px solid var(--line); background: rgba(5,10,35,.3);
    outline: none; font-size: 14.5px; color: var(--text);
}
:root[data-theme="light"] .side-search input { background: rgba(255,255,255,.8); }
.side-search input:focus { border-color: var(--cyan); box-shadow: 0 0 0 4px rgba(24,183,232,.14); }

.seg-tabs { position: relative; display: grid; grid-template-columns: repeat(3, 1fr); margin: 0 14px 8px; padding: 4px; border-radius: 14px; background: rgba(5,10,35,.3); border: 1px solid var(--line); }
:root[data-theme="light"] .seg-tabs { background: rgba(20,35,90,.05); }
.seg-tabs button { position: relative; z-index: 1; padding: 8px 4px; border-radius: 10px; font-size: 13.5px; font-weight: 600; color: var(--muted); display: flex; align-items: center; justify-content: center; gap: 6px; transition: color .2s; }
.seg-tabs button.active { color: var(--text); }
.seg-indicator { position: absolute; z-index: 0; top: 4px; bottom: 4px; left: 4px; width: calc((100% - 8px) / 3); border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line-strong); transition: transform .3s cubic-bezier(.2,.8,.2,1); }
.tab-count { min-width: 19px; height: 19px; padding: 0 5px; border-radius: 10px; background: var(--green); color: #022014; font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }

.side-lists { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 4px 8px 100px; }
.conv-item { display: flex; align-items: center; gap: 13px; padding: 10px; border-radius: 16px; text-decoration: none; color: var(--text); position: relative; transition: background .15s; }
.conv-item:hover { background: var(--surface); }
.conv-item.active { background: var(--aurora-soft); box-shadow: inset 0 0 0 1px rgba(24,183,232,.3); }
.conv-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.conv-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.conv-name { flex: 1; min-width: 0; font-weight: 600; font-size: 15.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-time { font-size: 12px; color: var(--muted); flex-shrink: 0; }
.conv-last { flex: 1; min-width: 0; font-size: 13.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-item.has-unread .conv-last, .conv-item.group-unread .conv-last { color: var(--text-2); font-weight: 500; }
.conv-item.has-unread .conv-time { color: var(--green); font-weight: 600; }
.conv-item .typing-line { color: var(--green); font-style: italic; }
.badge { min-width: 22px; height: 22px; padding: 0 7px; border-radius: 11px; background: var(--aurora); color: #031424; font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--aurora); flex-shrink: 0; display: none; }
.conv-item.group-unread .dot { display: block; }
.ticks { font-size: 12px; letter-spacing: -3px; padding-right: 5px; color: var(--muted); }
.ticks.read { color: var(--cyan); }
.no-result { text-align: center; padding: 30px; color: var(--muted); font-size: 14px; }
.empty-state { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; padding: 56px 24px; color: var(--muted); }
.empty-state b { color: var(--text); font-family: var(--display); font-size: 16px; font-weight: 600; }
.empty-state em { font-style: normal; color: var(--green); font-weight: 700; }
.empty-orb { width: 72px; height: 72px; border-radius: 50%; background: var(--aurora-soft); display: flex; align-items: center; justify-content: center; font-size: 30px; margin-bottom: 8px; box-shadow: inset 0 0 0 1px var(--line-strong); }

/* Bouton + (speed-dial) */
.fab-wrap { position: absolute; right: 18px; bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 20; display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.fab-option { display: flex; align-items: center; gap: 10px; opacity: 0; transform: translateY(10px) scale(.9); pointer-events: none; transition: all .2s cubic-bezier(.2,.8,.2,1); text-decoration: none; }
.fab-wrap.open .fab-option { opacity: 1; transform: none; pointer-events: auto; }
.fab-wrap.open .fab-option:nth-child(2) { transition-delay: .03s; }
.fab-wrap.open .fab-option:nth-child(1) { transition-delay: .06s; }
.fab-option-label { background: var(--surface-solid); color: var(--text); border: 1px solid var(--line-strong); padding: 7px 12px; border-radius: 10px; font-size: 13.5px; font-weight: 600; white-space: nowrap; box-shadow: var(--shadow); }
.fab-option-btn { width: 44px; height: 44px; border-radius: 14px; background: var(--surface-solid); color: var(--cyan); border: 1px solid var(--line-strong); display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow); }
.fab-main { width: 58px; height: 58px; border-radius: 19px; background: var(--aurora); color: #031424; display: flex; align-items: center; justify-content: center; box-shadow: 0 10px 30px rgba(24,183,232,.4); transition: transform .25s cubic-bezier(.2,.8,.2,1); }
.fab-wrap.open .fab-main { transform: rotate(45deg); }

/* Accueil (grand écran) : panneau de bienvenue */
.welcome { margin: auto; text-align: center; padding: 40px 28px; max-width: 460px; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.welcome-orb { width: 132px; height: 132px; border-radius: 40px; background: var(--aurora); display: flex; align-items: center; justify-content: center; box-shadow: 0 30px 80px rgba(24,183,232,.35); transform: rotate(-8deg); margin-bottom: 14px; }
.welcome-orb span { font-family: var(--display); font-weight: 700; font-size: 40px; color: #031424; transform: rotate(8deg); }
.welcome h1 { font-size: 28px; font-weight: 700; }
.welcome p { color: var(--text-2); max-width: 46ch; }
.welcome .chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 6px; }
.welcome .chip { font-size: 13px; color: var(--text-2); padding: 7px 12px; border-radius: 20px; border: 1px solid var(--line); background: var(--surface); }

/* ------------------------------------------------------------ Conversation */
.conv-header { display: flex; align-items: center; gap: 6px; padding: 10px 10px 10px 8px; border-bottom: 1px solid var(--line); flex-shrink: 0; min-height: 68px; background: var(--surface); }
.conv-header .who { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; text-decoration: none; color: var(--text); padding: 4px 6px; border-radius: 14px; }
.conv-header a.who:hover { background: var(--surface); }
.conv-header .who-text { min-width: 0; }
.conv-header h1 { font-size: 16.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-header .sub { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: color .2s; }
.conv-header .sub.online { color: var(--green); }
.conv-header .sub.typing { color: var(--cyan); }
.header-actions { display: flex; align-items: center; gap: 2px; }
.back-btn { display: none; }
@media (max-width: 899px) { .back-btn { display: inline-flex; } }

.chat-area { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior-y: contain; -webkit-overflow-scrolling: touch; padding: 14px 18px 20px; display: flex; flex-direction: column; }
#msgList { display: flex; flex-direction: column; }
.load-older { align-self: center; margin: 4px 0 12px; background: var(--surface-2); border: 1px solid var(--line); color: var(--text-2); font-size: 13px; font-weight: 600; padding: 8px 16px; border-radius: 20px; }
.load-older:hover { color: var(--text); border-color: var(--line-strong); }
.chat-loading, .chat-empty { margin: auto; color: var(--muted); font-size: 14.5px; text-align: center; padding: 30px; }
.chat-empty .big { font-size: 38px; margin-bottom: 10px; }
.skeleton { display: flex; flex-direction: column; gap: 10px; padding-top: 20px; }
.skeleton i { display: block; height: 40px; border-radius: 16px; background: linear-gradient(90deg, var(--surface), var(--surface-2), var(--surface)); background-size: 200% 100%; animation: shimmer 1.3s infinite linear; }
.skeleton i:nth-child(odd) { width: 52%; } .skeleton i:nth-child(even) { width: 38%; align-self: flex-end; }
@keyframes shimmer { to { background-position: -200% 0; } }

.date-divider { display: flex; justify-content: center; margin: 16px 0 10px; position: sticky; top: 4px; z-index: 5; pointer-events: none; }
.date-label { background: var(--surface-solid); color: var(--text-2); font-size: 12px; font-weight: 500; padding: 5px 12px; border-radius: 10px; border: 1px solid var(--line); }
.date-label::first-letter { text-transform: uppercase; }

.message {
    max-width: min(76%, 560px); padding: 8px 12px 7px; border-radius: 18px; margin-top: 3px; position: relative;
    font-size: 15px; line-height: 1.45; overflow-wrap: anywhere;
    animation: pop .22s cubic-bezier(.2,.8,.2,1) both;
}
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.98); } }
.message::after { content: ''; display: block; clear: both; }
.message.first { margin-top: 12px; }
.message.received { background: var(--bubble-in); color: var(--bubble-in-text); align-self: flex-start; border: 1px solid var(--line); }
.message.sent { background: var(--aurora); color: var(--bubble-out-text); align-self: flex-end; box-shadow: 0 6px 20px rgba(24,183,232,.18); }
.message.received.first { border-top-left-radius: 6px; }
.message.sent.first { border-top-right-radius: 6px; }
.message.pending { opacity: .7; }
.message.failed { background: rgba(255,77,106,.14); color: var(--text); box-shadow: none; border: 1px solid rgba(255,77,106,.4); }
.message.flash { animation: flash 1.3s ease; }
.message.has-reactions { margin-bottom: 14px; }
@keyframes flash { 0%, 40% { box-shadow: 0 0 0 3px var(--gold); } 100% { box-shadow: none; } }

.msg-text { white-space: pre-wrap; }
.msg-text a { color: inherit; text-decoration: underline; text-underline-offset: 2px; word-break: break-all; }
.message.received .msg-text a { color: var(--cyan); }
.call-link { display: inline-flex; align-items: center; gap: 6px; background: rgba(3,20,36,.85); color: #fff; padding: 6px 12px; border-radius: 12px; font-weight: 600; text-decoration: none; word-break: normal; }
.message.received .call-link { background: var(--aurora); color: #031424; }
.msg-text a:has(.call-link) { text-decoration: none; }
.sender-name { font-size: 13px; font-weight: 600; margin-bottom: 2px; font-family: var(--display); }

.media-content { display: block; max-width: 100%; max-height: 320px; border-radius: 12px; margin: 2px 0 5px; background: rgba(0,0,0,.15); }
img.media-content { cursor: zoom-in; min-width: 120px; min-height: 80px; object-fit: cover; }
.file-chip { display: flex; align-items: center; gap: 11px; padding: 10px; margin: 2px 0 5px; border-radius: 12px; text-decoration: none; background: rgba(0,0,0,.12); min-width: 210px; color: inherit; }
.message.received .file-chip { background: var(--surface-2); }
.file-chip .ext { width: 38px; height: 46px; border-radius: 8px; background: rgba(3,20,36,.85); color: #fff; font-size: 10px; font-weight: 700; display: flex; align-items: flex-end; justify-content: center; padding-bottom: 6px; flex-shrink: 0; }
.message.received .file-chip .ext { background: var(--aurora); color: #031424; }
.file-chip .meta { min-width: 0; flex: 1; }
.file-chip .meta b { display: block; font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-chip .meta span { font-size: 12px; opacity: .75; }

/* Message vocal */
.voice { display: flex; align-items: center; gap: 10px; min-width: 230px; padding: 3px 0 4px; }
.voice-play { width: 38px; height: 38px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; background: rgba(3,20,36,.85); color: #fff; }
.message.received .voice-play { background: var(--aurora); color: #031424; }
.voice-wave { flex: 1; height: 28px; display: flex; align-items: center; gap: 2px; cursor: pointer; }
.voice-wave i { flex: 1; border-radius: 2px; background: currentColor; opacity: .35; min-height: 3px; }
.voice-wave i.on { opacity: 1; }
.voice-time { font-size: 12px; opacity: .8; min-width: 34px; text-align: right; font-variant-numeric: tabular-nums; }

.meta-line { float: right; display: inline-flex; align-items: center; gap: 3px; margin: 7px 0 -3px 10px; font-size: 11px; opacity: .72; white-space: nowrap; font-variant-numeric: tabular-nums; }
.message .ticks { color: inherit; opacity: .7; font-size: 13px; }
.message .ticks.read { color: #0A3D91; opacity: 1; }
.message.received .ticks.read { color: var(--cyan); }
.progress { font-size: 11px; }
.retry-note { font-size: 12px; color: var(--red); margin-top: 3px; }

.quote-box { background: rgba(0,0,0,.12); border-left: 3px solid currentColor; border-radius: 10px; padding: 6px 9px; margin: 1px 0 6px; cursor: pointer; }
.message.received .quote-box { background: var(--surface-2); border-left-color: var(--cyan); }
.quote-sender { font-size: 12.5px; font-weight: 700; }
.message.received .quote-sender { color: var(--cyan); }
.quote-content { font-size: 13px; opacity: .85; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.forwarded-tag { font-size: 12px; opacity: .75; font-style: italic; margin-bottom: 2px; }

/* Réactions */
.reactions { position: absolute; bottom: -13px; display: flex; gap: 3px; z-index: 2; }
.message.sent .reactions { left: 10px; }
.message.received .reactions { left: 10px; }
.reaction-chip {
    display: inline-flex; align-items: center; gap: 3px; height: 24px; padding: 0 7px; border-radius: 12px; font-size: 13px;
    background: var(--surface-solid); border: 1px solid var(--line-strong); color: var(--text); box-shadow: 0 3px 10px rgba(0,0,0,.2);
}
.reaction-chip b { font-size: 11.5px; font-weight: 600; color: var(--text-2); }
.reaction-chip.mine { border-color: var(--cyan); box-shadow: 0 0 0 1px var(--cyan), 0 3px 10px rgba(0,0,0,.2); }

.msg-menu-btn {
    position: absolute; top: -9px; right: -9px; width: 26px; height: 26px; border-radius: 50%;
    background: var(--surface-solid); color: var(--text-2); border: 1px solid var(--line-strong); font-size: 15px; line-height: 1;
    box-shadow: 0 3px 10px rgba(0,0,0,.25);
    display: flex; align-items: center; justify-content: center; opacity: 0; transition: opacity .15s; z-index: 3;
}
.message:hover .msg-menu-btn, .msg-menu-btn:focus-visible { opacity: 1; }
@media (hover: none) { .msg-menu-btn { opacity: .55; } }

.msg-menu { position: fixed; display: none; z-index: 600; min-width: 220px; padding: 6px; border-radius: 16px; background: var(--surface-solid); border: 1px solid var(--line-strong); box-shadow: var(--shadow); }
.msg-menu.show { display: block; animation: menuIn .16s ease-out; }
@keyframes menuIn { from { opacity: 0; transform: scale(.96); } }
.react-row { display: flex; justify-content: space-between; gap: 2px; padding: 4px 4px 8px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
.react-row button { width: 34px; height: 34px; border-radius: 50%; font-size: 19px; display: flex; align-items: center; justify-content: center; transition: transform .12s, background .12s; }
.react-row button:hover { background: var(--surface-2); transform: scale(1.18); }
.react-row button.mine { background: var(--aurora-soft); box-shadow: inset 0 0 0 1px var(--cyan); }
.msg-menu .act { display: flex; align-items: center; gap: 11px; width: 100%; text-align: left; padding: 10px 12px; border-radius: 10px; font-size: 14.5px; color: var(--text); }
.msg-menu .act:hover { background: var(--surface-2); }
.msg-menu .act svg { color: var(--muted); flex-shrink: 0; }
.msg-menu .act.danger { color: var(--red); }
.msg-menu .act.danger svg { color: var(--red); }

.typing-bubble { align-self: flex-start; display: none; align-items: center; gap: 8px; margin-top: 10px; padding: 10px 14px; border-radius: 18px; border-top-left-radius: 6px; background: var(--bubble-in); border: 1px solid var(--line); font-size: 12.5px; color: var(--muted); }
.typing-bubble.show { display: inline-flex; }
.typing-dots { display: inline-flex; gap: 4px; }
.typing-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--cyan); animation: blink 1.2s infinite ease-in-out; }
.typing-dots i:nth-child(2) { animation-delay: .15s; background: var(--green); }
.typing-dots i:nth-child(3) { animation-delay: .3s; background: var(--indigo); }
@keyframes blink { 0%, 80%, 100% { transform: translateY(0); opacity: .4; } 40% { transform: translateY(-4px); opacity: 1; } }

.new-msg-pill {
    position: absolute; right: 20px; bottom: 92px; z-index: 20; display: none; align-items: center; gap: 6px;
    background: var(--surface-solid); color: var(--text); border: 1px solid var(--cyan); border-radius: 20px; padding: 8px 14px; font-size: 13px; font-weight: 600; box-shadow: var(--glow);
}
.new-msg-pill.show { display: inline-flex; }

/* Zone de saisie */
.composer-extra { display: none; align-items: center; gap: 10px; padding: 9px 14px; border-top: 1px solid var(--line); flex-shrink: 0; background: var(--surface); }
.composer-extra.show { display: flex; animation: menuIn .16s ease-out; }
.composer-extra .bar { flex: 1; min-width: 0; border-left: 3px solid var(--cyan); padding-left: 10px; }
.composer-extra .bar b { display: block; font-size: 13px; color: var(--cyan); }
.composer-extra .bar span { display: block; font-size: 13px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.composer-extra img { height: 54px; max-width: 90px; object-fit: cover; border-radius: 10px; }
.close-x { width: 34px; height: 34px; border-radius: 50%; color: var(--muted); font-size: 22px; line-height: 1; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.close-x:hover { background: var(--surface-2); color: var(--text); }

.input-area { position: relative; display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); flex-shrink: 0; border-top: 1px solid var(--line); }
.input-wrapper { flex: 1; min-width: 0; display: flex; align-items: flex-end; gap: 2px; padding: 4px; border-radius: 22px; background: rgba(5,10,35,.35); border: 1px solid var(--line-strong); transition: border-color .15s, box-shadow .15s; }
:root[data-theme="light"] .input-wrapper { background: #fff; }
.input-wrapper:focus-within { border-color: var(--cyan); box-shadow: 0 0 0 4px rgba(24,183,232,.14); }
.tool-btn { width: 40px; height: 40px; border-radius: 50%; color: var(--muted); display: flex; align-items: center; justify-content: center; flex-shrink: 0; cursor: pointer; transition: color .15s, background .15s; }
.tool-btn:hover, .tool-btn.active { color: var(--cyan); background: var(--surface-2); }
.message-input { flex: 1; min-width: 0; border: 0; outline: none; resize: none; font-size: 16px; line-height: 22px; padding: 9px 4px; max-height: 150px; background: transparent; color: var(--text); }
.send-btn { width: 50px; height: 50px; border-radius: 17px; background: var(--aurora); color: #031424; display: flex; align-items: center; justify-content: center; flex-shrink: 0; box-shadow: 0 8px 22px rgba(24,183,232,.32); transition: transform .12s, box-shadow .2s; }
.send-btn:hover { box-shadow: 0 10px 30px rgba(24,183,232,.48); }
.send-btn:active { transform: scale(.93); }
.send-btn:disabled { opacity: .5; cursor: default; }
.send-btn .ic-mic { display: none; }
.send-btn.mic .ic-mic { display: block; }
.send-btn.mic .ic-send { display: none; }

/* Enregistrement vocal */
.recorder { display: none; position: absolute; inset: 0; z-index: 5; align-items: center; gap: 12px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: var(--surface-solid); border-top: 1px solid var(--line); }
.recorder.show { display: flex; }
.rec-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 0 rgba(255,77,106,.6); animation: recPulse 1.4s infinite; flex-shrink: 0; margin-left: 6px; }
@keyframes recPulse { 70% { box-shadow: 0 0 0 12px rgba(255,77,106,0); } 100% { box-shadow: 0 0 0 0 rgba(255,77,106,0); } }
.rec-time { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 46px; }
.rec-bars { flex: 1; height: 32px; display: flex; align-items: center; gap: 2px; overflow: hidden; color: var(--cyan); }
.rec-bars i { width: 3px; border-radius: 2px; background: currentColor; flex-shrink: 0; }

/* Sélecteur d'emojis */
.emoji-panel { display: none; position: absolute; left: 12px; bottom: calc(100% + 8px); z-index: 30; width: min(340px, calc(100% - 24px)); padding: 10px; border-radius: 18px; background: var(--surface-solid); border: 1px solid var(--line-strong); box-shadow: var(--shadow); }
.emoji-panel.show { display: block; animation: menuIn .16s ease-out; }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; max-height: 220px; overflow-y: auto; }
.emoji-grid button { height: 38px; border-radius: 10px; font-size: 22px; }
.emoji-grid button:hover { background: var(--surface-2); }

/* Modales, visionneuse, tiroirs */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(3,7,25,.6); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); z-index: 1000; justify-content: center; align-items: center; padding: 16px; }
.modal-overlay.show { display: flex; animation: fade .18s ease-out; }
@keyframes fade { from { opacity: 0; } }
.modal-box { background: var(--surface-solid); border: 1px solid var(--line-strong); border-radius: 22px; width: 100%; max-width: 400px; max-height: 78vh; display: flex; flex-direction: column; overflow: hidden; box-shadow: var(--shadow); }
.modal-header { padding: 16px 10px 10px 20px; display: flex; justify-content: space-between; align-items: center; font-family: var(--display); font-weight: 600; font-size: 17px; }
.modal-search { padding: 4px 16px 12px; }
.modal-list { overflow-y: auto; padding: 0 8px 10px; }
.modal-section { padding: 10px 12px 6px; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.modal-contact { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 12px; width: 100%; text-align: left; font-size: 15px; }
.modal-contact:hover { background: var(--surface-2); }
.modal-empty { padding: 24px; text-align: center; color: var(--muted); font-size: 14px; }

.lightbox { position: fixed; inset: 0; background: rgba(3,7,25,.94); z-index: 1500; display: none; align-items: center; justify-content: center; padding: 20px; }
.lightbox.show { display: flex; animation: fade .18s ease-out; }
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 10px; box-shadow: 0 30px 80px rgba(0,0,0,.5); }
.lightbox .lb-actions { position: absolute; top: 14px; right: 14px; display: flex; gap: 8px; }
.lightbox .lb-actions a, .lightbox .lb-actions button { width: 44px; height: 44px; border-radius: 14px; background: rgba(255,255,255,.12); color: #fff; display: flex; align-items: center; justify-content: center; text-decoration: none; font-size: 22px; }

.drawer-overlay { position: fixed; inset: 0; z-index: 1200; background: rgba(3,7,25,.45); opacity: 0; pointer-events: none; transition: opacity .2s; }
.drawer-overlay.show { opacity: 1; pointer-events: auto; }
.drawer {
    position: fixed; top: 0; right: 0; bottom: 0; width: min(400px, 100%); z-index: 1201; display: flex; flex-direction: column;
    background: var(--surface-solid); border-left: 1px solid var(--line-strong); box-shadow: var(--shadow);
    transform: translateX(105%); transition: transform .3s cubic-bezier(.2,.8,.2,1);
}
.drawer.show { transform: none; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 18px 12px 12px 20px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { font-size: 19px; font-weight: 600; }
.drawer-body { flex: 1; overflow-y: auto; padding: 10px; }
.drawer-foot { padding: 12px; border-top: 1px solid var(--line); display: flex; gap: 8px; }

.notif-item { display: flex; gap: 12px; padding: 12px; border-radius: 14px; text-decoration: none; color: var(--text); position: relative; }
.notif-item:hover { background: var(--surface-2); }
.notif-item.unread::before { content: ''; position: absolute; left: 3px; top: 50%; width: 5px; height: 5px; border-radius: 50%; background: var(--gold); transform: translateY(-50%); }
.notif-item .n-body { flex: 1; min-width: 0; }
.notif-item .n-title { font-weight: 600; font-size: 14.5px; display: flex; gap: 8px; }
.notif-item .n-title span:first-child { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notif-item .n-time { font-size: 12px; color: var(--muted); font-weight: 400; flex-shrink: 0; }
.notif-item .n-text { font-size: 13.5px; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.setting { display: flex; align-items: center; gap: 14px; padding: 14px 12px; border-radius: 14px; }
.setting + .setting { border-top: 1px solid var(--line); border-radius: 0; }
.setting .s-text { flex: 1; min-width: 0; }
.setting .s-text b { display: block; font-weight: 600; font-size: 15px; }
.setting .s-text span { display: block; font-size: 13px; color: var(--muted); margin-top: 2px; }
.switch { position: relative; width: 48px; height: 28px; flex-shrink: 0; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 14px; background: var(--line-strong); transition: background .2s; }
.switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.3); transition: transform .2s cubic-bezier(.2,.8,.2,1); }
.switch input:checked + span { background: var(--aurora); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 2px solid var(--cyan); outline-offset: 2px; }
.theme-pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 6px 12px 14px; }
.theme-pick button { padding: 10px 6px; border-radius: 12px; border: 1px solid var(--line-strong); font-size: 13.5px; font-weight: 600; color: var(--text-2); display: flex; flex-direction: column; align-items: center; gap: 6px; }
.theme-pick button i { width: 34px; height: 22px; border-radius: 7px; display: block; border: 1px solid var(--line-strong); }
.theme-pick button.active { border-color: var(--cyan); color: var(--text); box-shadow: 0 0 0 3px rgba(24,183,232,.18); }
.perm-card { margin: 4px 12px 10px; padding: 14px; border-radius: 16px; background: var(--aurora-soft); border: 1px solid var(--line-strong); display: flex; flex-direction: column; gap: 10px; }
.perm-card p { font-size: 13.5px; color: var(--text-2); }
.group-title { padding: 14px 12px 4px; font-size: 13px; font-weight: 600; color: var(--muted); }

/* Bannières de notification dans l'application */
.notif-stack { position: fixed; top: calc(14px + env(safe-area-inset-top)); right: 14px; z-index: 2500; display: flex; flex-direction: column; gap: 10px; width: min(380px, calc(100% - 28px)); pointer-events: none; }
.notif-card {
    pointer-events: auto; display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 14px; border-radius: 18px; text-decoration: none; color: var(--text);
    background: var(--surface-solid); border: 1px solid var(--line-strong); box-shadow: var(--shadow), 0 0 0 1px rgba(252,209,22,.08);
    position: relative; overflow: hidden; animation: slideIn .35s cubic-bezier(.2,.8,.2,1) both;
}
.notif-card::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--aurora); }
.notif-card.leaving { animation: slideOut .25s ease-in forwards; }
.notif-card .n-body { flex: 1; min-width: 0; }
.notif-card b { display: block; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notif-card .n-text { font-size: 13.5px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notif-card .n-close { width: 30px; height: 30px; border-radius: 50%; color: var(--muted); font-size: 19px; flex-shrink: 0; }
.notif-card .n-close:hover { background: var(--surface-2); color: var(--text); }
.notif-card .n-bar { position: absolute; left: 0; bottom: 0; height: 2px; background: var(--gold); animation: bar 6s linear forwards; }
@keyframes slideIn { from { opacity: 0; transform: translateX(30px) scale(.97); } }
@keyframes slideOut { to { opacity: 0; transform: translateX(30px) scale(.97); } }
@keyframes bar { from { width: 100%; } to { width: 0; } }
@media (max-width: 600px) { .notif-stack { left: 14px; right: 14px; width: auto; } @keyframes slideIn { from { opacity: 0; transform: translateY(-20px); } } }

.net-banner { position: fixed; left: 50%; top: 10px; transform: translate(-50%, -80px); z-index: 2600; padding: 8px 14px; border-radius: 12px; background: var(--surface-solid); border: 1px solid rgba(252,209,22,.5); color: var(--gold); font-size: 13.5px; font-weight: 600; transition: transform .3s; box-shadow: var(--shadow); }
.net-banner.show { transform: translate(-50%, 0); }

/* ------------------------------------------------------------ Pages simples (formulaires, membres...) */
.page { max-width: 640px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; padding: 14px; display: flex; flex-direction: column; gap: 14px; }
.topbar { display: flex; align-items: center; gap: 10px; padding: 10px 12px 10px 8px; border-radius: 20px; }
.topbar .t-text { flex: 1; min-width: 0; }
.topbar h1 { font-size: 18px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .t-sub { font-size: 13px; color: var(--muted); }
.panel { border-radius: 20px; padding: 18px; }
.panel-title { font-family: var(--display); font-size: 15px; font-weight: 600; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.panel-title .count { color: var(--muted); font-weight: 500; }
.panel p.hint { font-size: 13.5px; color: var(--muted); }
.inline-form { display: flex; gap: 8px; }
.inline-form .input { flex: 1; min-width: 0; }
.form-msg { font-size: 13.5px; margin-top: 10px; }
.form-msg.ok { color: var(--green); }
.form-msg.err { color: var(--red); }
.member-item { display: flex; align-items: center; gap: 12px; padding: 9px 8px; border-radius: 14px; text-decoration: none; color: var(--text); }
a.member-item:hover, .member-item:has(a.member-link:hover) { background: var(--surface); }
.member-link { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; text-decoration: none; color: inherit; }
.member-name { font-weight: 600; font-size: 15px; }
.member-me { font-size: 12.5px; color: var(--muted); font-weight: 400; }
.member-role { font-size: 12.5px; color: var(--green); font-weight: 600; }
.remove-btn { font-size: 12.5px; font-weight: 600; padding: 6px 11px; border-radius: 10px; color: var(--red); border: 1px solid rgba(255,77,106,.3); flex-shrink: 0; }
.remove-btn:hover { background: rgba(255,77,106,.12); }
.stack { display: flex; flex-direction: column; gap: 10px; }

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