/* =========================================================
   Rayor Chat — feuille de styles
   Thème sombre par défaut, thème clair via [data-theme="light"]
   ========================================================= */
:root {
    --bg-app:      #0b1320;
    --bg-side:     #0e1726;
    --bg-panel:    #0a111d;
    --bg-elev:     #16233a;
    --bg-hover:    rgba(255, 255, 255, .045);
    --bg-active:   rgba(59, 130, 246, .16);
    --border:      rgba(255, 255, 255, .07);
    --border-soft: rgba(255, 255, 255, .05);
    --text:        #e7edf5;
    --text-dim:    #8b9bb4;
    --text-faint:  #5f6f86;
    --accent:      #3b82f6;
    --accent-2:    #38bdf8;
    --bubble-out:  linear-gradient(135deg, #2563eb, #3b82f6);
    --bubble-in:   #1b2942;
    --online:      #22c55e;
    --danger:      #ef4444;
    --shadow:      0 18px 50px rgba(0, 0, 0, .45);
    --radius:      16px;
}

[data-theme="light"] {
    --bg-app:      #e9edf2;
    --bg-side:     #ffffff;
    --bg-panel:    #f2f5f9;
    --bg-elev:     #ffffff;
    --bg-hover:    #f3f5f9;
    --bg-active:   #e7f0ff;
    --border:      #e4e8ef;
    --border-soft: #edf0f5;
    --text:        #0f1828;
    --text-dim:    #5a6b82;
    --text-faint:  #93a1b6;
    --accent:      #2563eb;
    --accent-2:    #2563eb;
    --bubble-out:  linear-gradient(135deg, #2563eb, #3b82f6);
    --bubble-in:   #ffffff;
    --online:      #16a34a;
    --shadow:      0 18px 50px rgba(20, 40, 80, .18);
}

* { box-sizing: border-box; }

/* l'attribut hidden doit toujours l'emporter sur les règles d'affichage auteur */
[hidden] { display: none !important; }

html, body {
    margin: 0;
    height: 100%;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg-app);
    color: var(--text);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

/* ---------------- structure générale ---------------- */
.app {
    display: grid;
    grid-template-columns: clamp(248px, 26vw, 340px) 1fr;
    grid-template-rows: minmax(0, 1fr);   /* la ligne ne dépasse jamais le viewport -> messages scrollables, composer collé en bas */
    height: 100dvh;
    width: 100%;
    overflow: hidden;
    background: var(--bg-panel);
}

/* ===================== Sidebar ===================== */
.sidebar {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    background: var(--bg-side);
    border-right: 1px solid var(--border);
}

.side-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 14px 9px;
}

.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand-logo {
    width: 34px; height: 34px;
    flex: 0 0 34px;
    border-radius: 10px;
    display: grid; place-items: center;
    background: var(--bubble-out);
    color: #fff;
    font-size: 15px;
    box-shadow: 0 6px 16px rgba(37, 99, 235, .35);
}
.brand-txt { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.brand-txt strong { font-size: 14.5px; font-weight: 700; }
.brand-txt small { font-size: 11px; color: var(--text-faint); letter-spacing: .3px; }

.side-actions { display: flex; gap: 4px; }

.icon-btn {
    width: 33px; height: 33px;
    flex: 0 0 33px;
    border: none;
    background: transparent;
    color: var(--text-dim);
    border-radius: 9px;
    cursor: pointer;
    display: grid; place-items: center;
    font-size: 14px;
    text-decoration: none;
    transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }

.search {
    position: relative;
    margin: 0 14px 10px;
}
.search i {
    position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
    color: var(--text-faint); font-size: 13px;
}
.search input {
    width: 100%;
    padding: 11px 14px 11px 38px;
    border: 1px solid transparent;
    background: var(--bg-hover);
    border-radius: 11px;
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color .15s, background .15s;
}
.search input:focus { border-color: var(--accent); background: var(--bg-app); }

.conv-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px 8px 8px;
}

.conv-skeleton {
    height: 64px;
    margin: 4px 0;
    border-radius: 12px;
    background: linear-gradient(90deg, var(--bg-hover) 25%, transparent 37%, var(--bg-hover) 63%);
    background-size: 400% 100%;
    animation: shimmer 1.4s infinite;
}
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

.conv-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 10px;
    border-radius: 11px;
    cursor: pointer;
    transition: background .12s;
}
.conv-item:hover { background: var(--bg-hover); }
.conv-item.active { background: var(--bg-active); }

.conv-avatar { width: 42px; height: 42px; font-size: 15px; }
.conv-main { flex: 1; min-width: 0; }
.conv-row { display: flex; align-items: baseline; gap: 8px; }
.conv-name {
    font-weight: 600; font-size: 13.5px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    flex: 1; min-width: 0;
}
.conv-time { font-size: 11.5px; color: var(--text-faint); flex: 0 0 auto; }
.conv-sub { display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.conv-preview {
    flex: 1; min-width: 0;
    font-size: 13px; color: var(--text-dim);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.conv-preview .me-prefix { color: var(--text-faint); }

.badge {
    flex: 0 0 auto;
    min-width: 20px; height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    background: var(--accent);
    color: #fff;
    font-size: 11.5px; font-weight: 700;
    display: grid; place-items: center;
}

/* avatar générique */
.avatar {
    border-radius: 50%;
    background-position: center;
    background-size: cover;
    display: grid; place-items: center;
    color: #fff;
    font-weight: 600;
    flex: 0 0 auto;
    position: relative;
    user-select: none;
}
.avatar.online::after {
    content: '';
    position: absolute; right: 0; bottom: 0;
    width: 11px; height: 11px;
    border-radius: 50%;
    background: var(--online);
    border: 2px solid var(--bg-side);
}

.me-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 13px;
    border-top: 1px solid var(--border);
}
.me-avatar { width: 32px; height: 32px; font-size: 13px; }
.me-info { flex: 1; min-width: 0; line-height: 1.15; }
.me-info strong { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-info small { font-size: 11.5px; color: var(--text-faint); font-family: ui-monospace, monospace; }

/* ===================== Zone chat ===================== */
.chat {
    position: relative;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: var(--bg-panel);
    background-image:
        radial-gradient(circle at 18% 12%, rgba(59, 130, 246, .07), transparent 32%),
        radial-gradient(circle at 82% 78%, rgba(56, 189, 248, .06), transparent 32%);
}

.chat-empty {
    position: absolute; inset: 0;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 8px; text-align: center; padding: 24px;
}
.empty-badge {
    width: 68px; height: 68px;
    border-radius: 22px;
    display: grid; place-items: center;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    color: var(--accent);
    font-size: 28px;
    margin-bottom: 10px;
}
.chat-empty h2 { margin: 0; font-size: 19px; }
.chat-empty p { margin: 0 0 14px; color: var(--text-dim); font-size: 14px; }

.chat-pane { display: flex; flex-direction: column; height: 100%; min-height: 0; }

.chat-head {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 15px;
    background: var(--bg-side);
    border-bottom: 1px solid var(--border);
    flex: 0 0 auto;
}
.chat-head-avatar { width: 37px; height: 37px; font-size: 14px; }
.chat-head-info { flex: 1; min-width: 0; line-height: 1.2; }
.chat-head-info strong { font-size: 14.5px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-head-info small { font-size: 12.5px; color: var(--text-dim); }
.chat-head-info small.is-online { color: var(--online); }
.back-btn { display: none; }

.messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 12px max(16px, calc((100% - 900px) / 2));
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.day-sep {
    align-self: center;
    margin: 14px 0 10px;
    padding: 4px 13px;
    border-radius: 20px;
    background: var(--bg-elev);
    border: 1px solid var(--border-soft);
    color: var(--text-dim);
    font-size: 12px; font-weight: 500;
}

.msg-group {
    display: flex;
    gap: 8px;
    max-width: 74%;
    margin-top: 7px;
}
.msg-group.out { align-self: flex-end; flex-direction: row-reverse; }
.msg-group.in  { align-self: flex-start; }
.group-avatar { width: 26px; height: 26px; font-size: 11px; align-self: flex-end; }
.bubbles { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.sender-name { font-size: 12px; font-weight: 600; margin: 0 0 2px 11px; }

.bubble {
    position: relative;
    padding: 6px 11px 6px;
    font-size: 13.5px;
    line-height: 1.4;
    border-radius: 14px;
    word-wrap: break-word;
    overflow-wrap: anywhere;
    box-shadow: 0 1px 1px rgba(0, 0, 0, .08);
    max-width: 100%;
}
.bubble.their {
    background: var(--bubble-in);
    border: 1px solid var(--border-soft);
    border-bottom-left-radius: 5px;
    color: var(--text);
}
.bubble.mine {
    background: var(--bubble-out);
    color: #fff;
    border-bottom-right-radius: 5px;
}
.bubbles .bubble:not(:last-child).their { border-bottom-left-radius: 16px; }
.bubbles .bubble:not(:last-child).mine  { border-bottom-right-radius: 16px; }

.bubble a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.bubble .text { white-space: pre-wrap; }

.meta {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    float: right;
    margin: 6px 0 -2px 10px;
    font-size: 10.5px;
    line-height: 1;
    opacity: .8;
}
.bubble.their .meta { color: var(--text-faint); }
.bubble.mine .meta { color: rgba(255, 255, 255, .85); }
.bubble.pending { opacity: .65; }
.ticks { font-size: 13px; margin-left: 3px; display: inline-flex; vertical-align: middle; }
/* non lu : une seule coche, atténuée */
.bubble.mine .ticks { color: rgba(255, 255, 255, .55); }
/* lu : double coche, vert vif (forme + couleur nettement différentes) */
.bubble.mine .ticks.read { color: #4ade80; }

.composer {
    position: relative;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 8px max(14px, calc((100% - 900px) / 2)) 10px;
    background: var(--bg-side);
    border-top: 1px solid var(--border);
    flex: 0 0 auto;
}
.composer .icon-btn { align-self: center; }
.composer textarea {
    flex: 1;
    resize: none;
    max-height: 130px;
    padding: 9px 14px;
    border: 1px solid var(--border);
    border-radius: 13px;
    background: var(--bg-app);
    color: var(--text);
    font-family: inherit;
    font-size: 13.5px;
    line-height: 1.4;
    outline: none;
    transition: border-color .15s;
}
.composer textarea:focus { border-color: var(--accent); }
.send-btn {
    width: 40px; height: 40px;
    flex: 0 0 40px;
    border: none;
    border-radius: 50%;
    background: var(--bubble-out);
    color: #fff;
    font-size: 15px;
    cursor: pointer;
    display: grid; place-items: center;
    box-shadow: 0 6px 16px rgba(37, 99, 235, .4);
    transition: transform .12s, opacity .15s;
}
.send-btn:hover { transform: scale(1.05); }
.send-btn:disabled { opacity: .45; cursor: default; transform: none; box-shadow: none; }

/* panneau emoji */
.emoji-panel {
    position: absolute;
    bottom: 62px;
    left: 14px;
    width: 318px;
    max-height: 260px;
    overflow-y: auto;
    padding: 8px;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow);
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
    z-index: 25;
}
.emoji-panel button {
    border: none;
    background: none;
    cursor: pointer;
    font-size: 21px;
    line-height: 1;
    padding: 6px 0;
    border-radius: 8px;
}
.emoji-panel button:hover { background: var(--bg-hover); }

/* ===================== Boutons & modales ===================== */
.btn-primary {
    border: none;
    padding: 11px 18px;
    border-radius: 11px;
    background: var(--bubble-out);
    color: #fff;
    font-family: inherit;
    font-size: 14px; font-weight: 600;
    cursor: pointer;
    display: inline-flex; align-items: center; gap: 8px;
    box-shadow: 0 6px 16px rgba(37, 99, 235, .3);
    transition: transform .12s;
}
.btn-primary:hover { transform: translateY(-1px); }
.btn-ghost {
    border: 1px solid var(--border);
    padding: 11px 18px;
    border-radius: 11px;
    background: transparent;
    color: var(--text-dim);
    font-family: inherit; font-size: 14px; font-weight: 500;
    cursor: pointer;
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }

.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(2, 6, 16, .66);
    backdrop-filter: blur(6px);
    display: grid; place-items: center;
    z-index: 100;
    padding: 20px;
    animation: fade .15s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
    width: 100%;
    max-width: 420px;
    background: var(--bg-side);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    animation: pop .18s ease;
}
@keyframes pop { from { transform: translateY(12px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }
.modal h3 { margin: 0 0 6px; font-size: 18px; display: flex; align-items: center; gap: 9px; }
.modal h3 i { color: var(--accent); }
.modal p { margin: 12px 0 7px; font-size: 13px; color: var(--text-dim); }
.modal-input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: var(--bg-app);
    color: var(--text);
    font-family: inherit; font-size: 14px;
    outline: none;
}
.modal-input:focus { border-color: var(--accent); }
.modal-error {
    margin-top: 10px;
    color: var(--danger);
    font-size: 13px;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* ===================== Responsive ===================== */
@media (max-width: 820px) {
    .app { grid-template-columns: 1fr; }
    .sidebar { grid-column: 1; }
    .chat {
        position: fixed; inset: 0;
        transform: translateX(100%);
        transition: transform .26s ease;
        z-index: 30;
    }
    .app[data-view="chat"] .chat { transform: translateX(0); }
    .back-btn { display: grid; }
    .messages { padding: 14px 14px; }
    .msg-group { max-width: 86%; }
}

/* ===================== Pied de page légal (sidebar) ===================== */
.side-legal {
    padding: 8px 14px 12px;
    font-size: 11px;
    color: var(--text-faint);
    text-align: center;
    border-top: 1px solid var(--border-soft);
}
.side-legal a { color: inherit; text-decoration: none; }
.side-legal a:hover { color: var(--text-dim); text-decoration: underline; }

/* ===================== Pages légales ===================== */
.legal-wrap { max-width: 760px; margin: 0 auto; padding: 30px 18px 70px; height: 100dvh; overflow-y: auto; }
.legal-card {
    background: var(--bg-side);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: clamp(24px, 5vw, 48px);
    box-shadow: var(--shadow);
}
.legal-head { text-align: center; border-bottom: 1px solid var(--border); padding-bottom: 22px; margin-bottom: 26px; }
.legal-back {
    display: inline-flex; align-items: center; gap: 7px;
    color: var(--accent); text-decoration: none; font-size: 13.5px; font-weight: 500;
    margin-bottom: 18px;
}
.legal-back:hover { text-decoration: underline; }
.legal-head h1 { font-size: 26px; margin: 0 0 6px; letter-spacing: -.02em; }
.legal-date { color: var(--text-faint); font-size: 13px; }
.legal-body h2 { font-size: 17px; margin: 28px 0 10px; }
.legal-body p, .legal-body li { font-size: 14.5px; line-height: 1.7; color: var(--text-dim); }
.legal-body strong { color: var(--text); }
.legal-body ul { padding-left: 20px; }
.legal-body li { margin-bottom: 7px; }
.legal-body a { color: var(--accent); }
.legal-infobox {
    background: var(--bg-app); border: 1px solid var(--border);
    border-radius: 12px; padding: 16px 18px; margin: 12px 0;
}
.legal-infobox div { font-size: 14px; margin: 4px 0; color: var(--text-dim); }
.legal-todo {
    background: rgba(245, 158, 11, .14); color: #f59e0b;
    padding: 1px 7px; border-radius: 6px; font-weight: 600; font-size: 13px; white-space: nowrap;
}
.legal-foot {
    text-align: center; border-top: 1px solid var(--border);
    margin-top: 32px; padding-top: 20px; font-size: 12.5px; color: var(--text-faint);
}
.legal-foot a { color: inherit; text-decoration: none; }
.legal-foot a:hover { text-decoration: underline; color: var(--text-dim); }
.legal-foot span { display: block; margin-top: 6px; opacity: .85; }

/* ===================== Barre compte (bouton) ===================== */
.me-bar {
    width: 100%;
    border: none;
    background: transparent;
    text-align: left;
    font-family: inherit;
    cursor: pointer;
    color: var(--text);
}
.me-bar:hover { background: var(--bg-hover); }
.me-gear { color: var(--text-faint); font-size: 14px; }

/* ===================== Réglages / compte ===================== */
.settings-card {
    display: flex; align-items: center; gap: 14px;
    padding: 14px; margin-bottom: 14px;
    background: var(--bg-app); border: 1px solid var(--border); border-radius: 12px;
}
.settings-avatar { width: 54px; height: 54px; font-size: 20px; }
.settings-id { min-width: 0; }
.settings-id strong { font-size: 16px; display: block; }
.settings-email { font-size: 13px; color: var(--text-dim); }
.settings-rid { font-size: 12px; color: var(--text-faint); font-family: ui-monospace, monospace; margin-top: 2px; }
.settings-row {
    width: 100%;
    display: flex; align-items: center; gap: 12px;
    padding: 13px 14px; margin-top: 8px;
    border: 1px solid var(--border); border-radius: 11px;
    background: transparent; color: var(--text);
    font-family: inherit; font-size: 14px; text-align: left; text-decoration: none;
    cursor: pointer;
}
.settings-row span { flex: 1; }
.settings-row > i:first-child { width: 18px; text-align: center; color: var(--text-dim); }
.settings-row .chev { color: var(--text-faint); font-size: 12px; }
.settings-row:hover { background: var(--bg-hover); }
.settings-row.danger { color: var(--danger); }
.settings-row.danger > i:first-child { color: var(--danger); }
.settings-legal {
    text-align: center; margin-top: 16px;
    font-size: 12px; color: var(--text-faint);
}
.settings-legal a { color: inherit; text-decoration: none; }
.settings-legal a:hover { text-decoration: underline; }

/* ===================== Pièces jointes ===================== */
.bubble.media { padding: 3px; }
.att-img {
    display: block;
    max-width: min(300px, 64vw);
    max-height: 360px;
    border-radius: 13px;
    cursor: zoom-in;
}
.bubble.media .meta {
    position: absolute; right: 11px; bottom: 10px;
    margin: 0; padding: 2px 7px; border-radius: 10px;
    background: rgba(0, 0, 0, .55); color: #fff !important;
}
.file-chip {
    display: flex; align-items: center; gap: 11px;
    min-width: 200px; max-width: 280px;
}
.file-ic {
    width: 40px; height: 40px; flex: 0 0 40px;
    border-radius: 10px; display: grid; place-items: center;
    background: rgba(255, 255, 255, .14); color: #fff; font-size: 17px;
}
.bubble.their .file-ic { background: var(--bg-app); color: var(--accent); }
.file-meta { min-width: 0; flex: 1; }
.file-name { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-size { font-size: 11.5px; opacity: .8; }
.file-dl { color: inherit; font-size: 15px; opacity: .85; text-decoration: none; }

.bubble.deleted {
    background: transparent !important;
    border: 1px dashed var(--border);
    color: var(--text-faint);
    font-style: italic;
}
.bubble.deleted .meta { color: var(--text-faint); }

/* bouton supprimer (au survol de son propre message) */
.bubble.mine .msg-del {
    position: absolute; top: 50%; left: -34px; transform: translateY(-50%);
    width: 27px; height: 27px; border-radius: 50%;
    border: 1px solid var(--border); background: var(--bg-elev);
    color: var(--text-dim); font-size: 12px; cursor: pointer;
    display: grid; place-items: center; opacity: 0; transition: opacity .12s;
}
.bubble.mine:hover .msg-del { opacity: 1; }
.bubble.mine .msg-del:hover { color: var(--danger); border-color: var(--danger); }

/* upload en cours */
.upload-row { align-self: flex-end; display: flex; align-items: center; gap: 9px; margin-top: 8px;
    padding: 10px 14px; border-radius: 14px; background: var(--bubble-in); color: var(--text-dim); font-size: 13px; }
.upload-row .spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===================== Lightbox image ===================== */
.lightbox {
    position: fixed; inset: 0; z-index: 200;
    background: rgba(0, 0, 0, .9);
    display: grid; place-items: center; padding: 30px;
}
.lightbox img { max-width: 94vw; max-height: 90vh; border-radius: 10px; }
.lightbox-close {
    position: absolute; top: 20px; right: 22px;
    width: 44px; height: 44px; border-radius: 50%;
    border: none; background: rgba(255, 255, 255, .12); color: #fff;
    font-size: 20px; cursor: pointer;
}
.lightbox-close:hover { background: rgba(255, 255, 255, .22); }

/* ===================== Bannière (install / notifications) ===================== */
.app-banner {
    position: fixed;
    left: 50%; bottom: 18px; transform: translateX(-50%);
    z-index: 60;
    display: flex; align-items: center; gap: 13px;
    width: calc(100% - 28px); max-width: 460px;
    padding: 11px 12px;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow);
    animation: bannerin .25s ease;
}
@keyframes bannerin { from { opacity: 0; transform: translate(-50%, 14px); } to { opacity: 1; transform: translate(-50%, 0); } }
.ab-ic {
    width: 40px; height: 40px; flex: 0 0 40px;
    border-radius: 11px; display: grid; place-items: center;
    background: var(--bubble-out); color: #fff; font-size: 17px;
}
.ab-txt { flex: 1; min-width: 0; }
.ab-txt strong { display: block; font-size: 13.5px; }
.ab-txt span { font-size: 12px; color: var(--text-dim); }
.ab-actions { display: flex; gap: 6px; align-items: center; flex: 0 0 auto; }
.ab-btn {
    border: none; background: var(--bubble-out); color: #fff;
    font-family: inherit; font-size: 12.5px; font-weight: 600;
    padding: 8px 13px; border-radius: 9px; cursor: pointer; white-space: nowrap;
}
.ab-x {
    border: none; background: transparent; color: var(--text-faint);
    font-size: 15px; cursor: pointer; width: 30px; height: 30px; border-radius: 8px;
}
.ab-x:hover { background: var(--bg-hover); }

/* ===================== Tiroir réglages de conversation ===================== */
.conv-drawer {
    position: absolute; top: 0; right: 0; bottom: 0;
    width: min(330px, 86%);
    background: var(--bg-side);
    border-left: 1px solid var(--border);
    box-shadow: -14px 0 40px rgba(0, 0, 0, .25);
    display: flex; flex-direction: column;
    transform: translateX(101%);
    transition: transform .24s ease;
    z-index: 40;
}
.conv-drawer.open { transform: translateX(0); }
.drawer-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 14px; border-bottom: 1px solid var(--border); flex: 0 0 auto;
}
.drawer-head strong { font-size: 15px; display: flex; align-items: center; gap: 9px; }
.drawer-head strong i { color: var(--accent); }
.drawer-body { flex: 1; overflow-y: auto; padding: 4px 0 14px; }
.set-row {
    display: flex; align-items: center; justify-content: space-between; gap: 14px;
    padding: 13px 16px; border-bottom: 1px solid var(--border-soft);
}
.set-row > div { min-width: 0; }
.set-row strong { display: block; font-size: 13.5px; font-weight: 600; }
.set-row small { font-size: 11.5px; color: var(--text-dim); }
.set-select {
    flex: 0 0 auto; border: 1px solid var(--border); background: var(--bg-app);
    color: var(--text); border-radius: 9px; padding: 7px 9px; font-family: inherit; font-size: 12.5px; cursor: pointer;
}
.drawer-export { width: calc(100% - 32px); margin: 16px; justify-content: center; display: flex; align-items: center; gap: 8px; }

/* interrupteur */
.switch { position: relative; width: 42px; height: 24px; flex: 0 0 42px; display: inline-block; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch i { position: absolute; inset: 0; background: var(--border); border-radius: 20px; transition: background .2s; }
.switch i::after {
    content: ''; position: absolute; width: 18px; height: 18px; border-radius: 50%;
    background: #fff; top: 3px; left: 3px; transition: transform .2s; box-shadow: 0 1px 3px rgba(0, 0, 0, .35);
}
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(18px); }

@media (max-width: 820px) {
    .conv-drawer { width: 100%; }
}

/* ===================== Appels (WebRTC) ===================== */
.call-overlay {
    position: fixed; inset: 0; z-index: 200;
    background: #07101f;
    display: flex; align-items: center; justify-content: center;
}
.call-remote {
    position: absolute; inset: 0; width: 100%; height: 100%;
    object-fit: cover; background: #07101f;
}
.call-local {
    position: absolute; right: 16px; bottom: 96px;
    width: clamp(96px, 22vw, 180px); aspect-ratio: 3/4; object-fit: cover;
    border-radius: 14px; border: 2px solid rgba(255,255,255,.2);
    background: #0b1320; z-index: 2; box-shadow: 0 8px 24px rgba(0,0,0,.5);
}
.call-info {
    position: relative; z-index: 2; text-align: center; color: #fff;
    display: flex; flex-direction: column; align-items: center; gap: 8px;
    text-shadow: 0 2px 12px rgba(0,0,0,.6);
}
.call-avatar { width: 96px; height: 96px; font-size: 34px; }
.call-info strong { font-size: 22px; }
.call-info span { font-size: 14px; color: rgba(255,255,255,.8); }
.call-incoming, .call-controls {
    position: absolute; bottom: 30px; left: 0; right: 0; z-index: 3;
    display: flex; justify-content: center; gap: 22px;
}
.call-btn {
    width: 60px; height: 60px; border-radius: 50%; border: none; cursor: pointer;
    color: #fff; font-size: 22px; display: grid; place-items: center;
    background: rgba(255,255,255,.16); transition: background .15s, transform .12s;
}
.call-btn:hover { transform: scale(1.06); }
.call-btn.accept { background: #22c55e; }
.call-btn.reject, .call-btn.hangup { background: #ef4444; }
.call-btn.off { background: #fff; color: #07101f; }

/* ===================== Photo à vue unique ===================== */
.icon-btn.active { color: var(--accent); background: var(--bg-active); }
.once-ph {
    display: flex; align-items: center; gap: 10px;
    min-width: 170px; padding: 4px 2px; cursor: pointer;
    border: none; background: none; color: inherit; font: inherit;
}
.once-ph.disabled { cursor: default; opacity: .8; }
.once-ic {
    width: 38px; height: 38px; flex: 0 0 38px; border-radius: 50%;
    display: grid; place-items: center; font-size: 16px;
    background: rgba(255,255,255,.16);
}
.bubble.their .once-ic { background: var(--bg-app); color: var(--accent); }
.once-txt { text-align: left; line-height: 1.2; }
.once-txt strong { display: block; font-size: 13.5px; }
.once-txt small { font-size: 11.5px; opacity: .8; }

/* ===================== Message vocal ===================== */
.voice-msg { display: flex; align-items: center; gap: 10px; min-width: 200px; }
.voice-play {
    width: 36px; height: 36px; flex: 0 0 36px; border: none; border-radius: 50%;
    cursor: pointer; background: rgba(255, 255, 255, .18); color: #fff;
    display: grid; place-items: center; font-size: 13px;
}
.bubble.their .voice-play { background: var(--accent); color: #fff; }
.voice-bar { flex: 1; height: 4px; border-radius: 3px; background: rgba(255, 255, 255, .25); overflow: hidden; min-width: 56px; }
.bubble.their .voice-bar { background: var(--border); }
.voice-fill { height: 100%; width: 0; background: #fff; }
.bubble.their .voice-fill { background: var(--accent); }
.voice-time { font-size: 11px; opacity: .85; min-width: 34px; font-variant-numeric: tabular-nums; }
.voice-speed {
    border: none; background: rgba(255, 255, 255, .16); color: inherit; font: inherit;
    font-size: 11px; font-weight: 700; padding: 3px 7px; border-radius: 8px; cursor: pointer;
}
.bubble.their .voice-speed { background: var(--bg-app); }

/* ===================== Barre d'enregistrement ===================== */
.rec-bar {
    position: absolute; inset: 0; background: var(--bg-side);
    display: flex; align-items: center; gap: 12px; padding: 8px 14px; z-index: 6;
}
.rec-spacer { flex: 1; }
.rec-dot { width: 11px; height: 11px; border-radius: 50%; background: var(--danger); animation: recpulse 1s infinite; }
@keyframes recpulse { 50% { opacity: .25; } }
#recTime { font-variant-numeric: tabular-nums; font-size: 14px; }

/* ===================== Aperçu photo (avant envoi) ===================== */
.photo-preview {
    position: fixed; inset: 0; z-index: 150;
    background: rgba(2, 6, 16, .7); backdrop-filter: blur(6px);
    display: grid; place-items: center; padding: 20px;
}
.pp-card {
    background: var(--bg-side); border: 1px solid var(--border); border-radius: 16px;
    padding: 14px; max-width: 440px; width: 100%; box-shadow: var(--shadow);
}
.pp-card img { width: 100%; max-height: 60vh; object-fit: contain; border-radius: 12px; background: var(--bg-app); }
.pp-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.pp-once { display: flex; align-items: center; gap: 9px; font-size: 13.5px; cursor: pointer; }
.pp-btns { display: flex; gap: 10px; }

/* ===================== Caméra in-app (façon Snap) ===================== */
.cam-overlay { position: fixed; inset: 0; z-index: 160; background: #000; display: flex; align-items: center; justify-content: center; }
#camVideo { width: 100%; height: 100%; object-fit: cover; }
.cam-close {
    position: absolute; top: 18px; right: 18px; width: 44px; height: 44px; border-radius: 50%;
    border: none; background: rgba(255, 255, 255, .18); color: #fff; font-size: 20px; cursor: pointer;
}
.cam-controls { position: absolute; bottom: 32px; left: 0; right: 0; display: flex; align-items: center; justify-content: center; gap: 50px; }
.cam-shutter {
    width: 72px; height: 72px; border-radius: 50%; border: 5px solid #fff;
    background: rgba(255, 255, 255, .25); cursor: pointer; transition: transform .1s;
}
.cam-shutter:active { transform: scale(.92); }
.cam-side {
    width: 50px; height: 50px; border-radius: 50%; border: none; cursor: pointer;
    background: rgba(255, 255, 255, .16); color: #fff; font-size: 19px; display: grid; place-items: center;
}

/* appareil photo rapide dans la liste de conversations */
.conv-cam {
    flex: 0 0 auto; width: 30px; height: 30px; border: none; background: transparent;
    color: var(--text-dim); border-radius: 8px; cursor: pointer; opacity: 0;
    transition: opacity .12s, background .12s, color .12s; align-self: center;
}
.conv-item:hover .conv-cam { opacity: 1; }
.conv-cam:hover { background: var(--bg-hover); color: var(--accent); }
@media (hover: none) { .conv-cam { opacity: .5; } }

/* ===================== Édition photo (texte) ===================== */
.pp-card { text-align: center; }
.pp-stage { position: relative; display: inline-block; max-width: 100%; }
#ppImg { display: block; max-width: 100%; max-height: 58vh; width: auto; height: auto; border-radius: 12px; background: var(--bg-app); }
.pp-text {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    color: #fff; font-weight: 800; font-size: 26px; line-height: 1.2;
    text-shadow: 0 2px 8px rgba(0, 0, 0, .7); outline: none; max-width: 88%;
    text-align: center; white-space: pre-wrap; cursor: text;
}
.pp-tools { display: flex; gap: 8px; justify-content: center; margin-top: 10px; }
.pp-tool {
    width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--border);
    background: var(--bg-app); color: var(--text); font-weight: 800; font-size: 15px; cursor: pointer;
}
.pp-tool.active { border-color: var(--accent); color: var(--accent); }

/* ===================== Réponse à un message ===================== */
.reply-bar {
    display: flex; align-items: center; gap: 10px; flex: 0 0 auto;
    padding: 8px 16px; background: var(--bg-side); border-top: 1px solid var(--border-soft);
}
.reply-bar > i { color: var(--accent); }
.reply-bar-txt { flex: 1; min-width: 0; border-left: 3px solid var(--accent); padding-left: 9px; line-height: 1.25; }
.reply-bar-txt strong { display: block; font-size: 12.5px; color: var(--accent); }
.reply-bar-txt span { font-size: 12.5px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
/* citation dans la bulle */
.bubble .quote {
    display: block; border-left: 3px solid currentColor; padding: 3px 8px; margin-bottom: 5px;
    border-radius: 5px; background: rgba(255, 255, 255, .12); font-size: 12.5px; line-height: 1.25; opacity: .92;
}
.bubble.their .quote { background: rgba(0, 0, 0, .06); }
[data-theme="light"] .bubble.their .quote { background: rgba(0, 0, 0, .05); }
.bubble .quote b { display: block; font-weight: 600; }
.bubble .quote span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: .85; }
/* bouton répondre (au survol) */
.msg-reply {
    position: absolute; top: 50%; transform: translateY(-50%);
    width: 27px; height: 27px; border-radius: 50%; border: 1px solid var(--border);
    background: var(--bg-elev); color: var(--text-dim); font-size: 12px; cursor: pointer;
    display: grid; place-items: center; opacity: 0; transition: opacity .12s;
}
.bubble:hover .msg-reply { opacity: 1; }
.msg-reply:hover { color: var(--accent); border-color: var(--accent); }
.bubble.their .msg-reply { right: -34px; }
.bubble.mine .msg-reply { left: -34px; }
.bubble.mine .msg-del { left: -66px; }
.bubble.flash { animation: bflash .9s ease; }
@keyframes bflash { 0% { box-shadow: 0 0 0 0 rgba(59,130,246,0); } 35% { box-shadow: 0 0 0 4px rgba(59,130,246,.55); } 100% { box-shadow: 0 0 0 0 rgba(59,130,246,0); } }

/* ===================== Éditeur photo (dessin / stickers / texte) ===================== */
#ppDraw { position: absolute; inset: 0; pointer-events: none; touch-action: none; }
.pp-el {
    position: absolute; color: #fff; font-weight: 800; line-height: 1.15;
    text-shadow: 0 2px 8px rgba(0, 0, 0, .7); outline: none; cursor: move;
    white-space: pre-wrap; max-width: 90%; user-select: none; touch-action: none; padding: 2px 4px;
}
.pp-eltext { font-size: 26px; min-width: 22px; }
.pp-elstick { font-size: 46px; text-shadow: none; }
.pp-el:focus { cursor: text; user-select: text; }
.pp-stickers { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; margin-top: 8px; max-height: 130px; overflow-y: auto; }
.pp-stick { border: none; background: var(--bg-app); border-radius: 8px; font-size: 22px; width: 38px; height: 38px; cursor: pointer; }
.pp-stick:hover { background: var(--bg-hover); }

/* Badge Rayor Plus devant les pseudos */
.plus-ic{width:.92em;height:.92em;vertical-align:-2px;margin-right:3px;flex:0 0 auto;filter:drop-shadow(0 1px 1px rgba(0,0,0,.25))}
.sender-name{display:inline-flex;align-items:center}
