/* ============================================================
   KECH-BOOK — feuille de style REFONDUE (2026-07-23)
   Réécrite à partir de zéro pour être fidèle à la maquette
   validée (artifact « Proposition d'interface »), conçue avec
   le skill UI/UX Pro Max. Identité : logo, crème, vert profond,
   terracotta. Sécurité, données et logique inchangées.
   ============================================================ */

/* ---------- Polices locales (aucun CDN) ---------- */
@font-face {
  font-family: 'Calistoga'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('/fonts/calistoga.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2013-2014, U+2018-201A, U+201C-201E, U+2026, U+20AC;
}
@font-face {
  font-family: 'Calistoga'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('/fonts/calistoga-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+1E00-1EFF, U+2113, U+A720-A7FF;
}
@font-face {
  font-family: 'Inter'; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url('/fonts/inter.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2013-2014, U+2018-201A, U+201C-201E, U+2026, U+20AC;
}
@font-face {
  font-family: 'Inter'; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url('/fonts/inter-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+1E00-1EFF, U+2113, U+A720-A7FF;
}

/* ---------- Tokens (maquette) ---------- */
:root {
  --bg: #F7F2EA;            /* crème du logo */
  --bg-2: #FDFAF4;          /* crème clair (barres) */
  --card: #FFFFFF;
  --line: #E5D9C5;          /* beige doré */
  --line-soft: #EFE7D8;
  --txt: #2B2A24;           /* encre */
  --muted: #6F6754;         /* sable, contraste ≥ 4,5:1 */
  --accent: #2E4A3B;        /* vert profond : marque & navigation */
  --accent-2: #243B2F;
  --vert-pale: #EAF0EC;
  --primary: #C05A28;       /* terracotta : AGIR */
  --terra-pale: #F7E8DE;
  --ocre: #A8763E;
  --danger: #C0392B;
  --ok: #2E7D32;
  --warn: #B7791F;
  --on-accent: #FFFFFF;
  --radius: 12px;
  --ombre: 0 1px 2px rgba(74,58,42,.06), 0 4px 16px -6px rgba(74,58,42,.12);
  --disp: 'Calistoga', Georgia, serif;
  --body-f: 'Inter', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
img, video, canvas, audio { max-width: 100%; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--txt);
  font-family: var(--body-f); font-size: 16px; line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}
body.scroll-locked { position: fixed; left: 0; right: 0; width: 100%; overflow: hidden; }
a { color: var(--primary); }
code { background: rgba(46,74,59,.08); padding: 1px 6px; border-radius: 6px; font-size: .9em; }
h1 { font-family: var(--disp); font-weight: 400; font-size: 1.7rem; letter-spacing: .005em; margin: .2em 0 .4em; }
h2 { font-family: var(--disp); font-weight: 400; letter-spacing: .005em; }
input, textarea, select {
  font: inherit; font-size: 16px; /* 16px : pas de zoom iOS */
  width: 100%; background: var(--card); color: var(--txt);
  border: 1.5px solid var(--line); border-radius: var(--radius); padding: 11px 13px;
  transition: border-color .18s ease, box-shadow .18s ease;
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
}
textarea { resize: vertical; }
input[type="date"], input[type="datetime-local"] { color-scheme: light; }

/* ---------- Boutons ---------- */
button { font: inherit; cursor: pointer; }
button.primary {
  background: var(--primary); color: var(--on-accent); border: 0;
  border-radius: var(--radius); padding: 11px 18px; font-weight: 700;
  box-shadow: 0 4px 14px -4px rgba(192,90,40,.5);
}
button.primary:hover { filter: brightness(1.05); transform: translateY(-1px); }
button.primary:active { transform: scale(.98); }
button.primary.small { padding: 8px 13px; font-size: .88rem; }
button.ghost {
  background: var(--card); color: var(--txt); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 9px 13px; font-weight: 600;
}
button.ghost:hover { border-color: var(--accent); color: var(--accent); }
button.ghost.small { padding: 7px 11px; font-size: .85rem; }
button.danger {
  background: transparent; color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 45%, transparent);
  border-radius: var(--radius); padding: 7px 11px; font-size: .85rem; font-weight: 600;
}
button.danger:hover { background: color-mix(in srgb, var(--danger) 8%, transparent); }
button:disabled { opacity: .5; cursor: not-allowed; transform: none !important; }
.ico-btn { display: inline-flex; align-items: center; gap: 6px; }
.ico-btn svg, button svg { flex: 0 0 auto; vertical-align: middle; pointer-events: none; }
button, .tab, .set-item, .chat-row, .cat-row, .member, .dash-action, .tool-pill, .sub-tab {
  transition: background .18s ease, color .18s ease, border-color .18s ease,
              transform .15s ease, box-shadow .18s ease, filter .15s ease;
}
button:focus-visible, .tab:focus-visible, .set-item:focus-visible, a:focus-visible,
.chat-row:focus-visible, .cat-row:focus-visible {
  outline: 2px solid var(--primary); outline-offset: 2px;
}

/* ---------- Utilitaires ---------- */
.hint { color: var(--muted); font-size: .88rem; margin: 6px 0; }
.hint-strong { color: var(--txt); font-weight: 600; }
.empty { color: var(--muted); text-align: center; padding: 30px 14px; }
.brand { font-family: var(--disp); font-weight: 400; font-size: 1.15rem; display: flex; align-items: center; gap: 8px; }
.logo-img { width: 30px; height: 30px; border-radius: 8px; object-fit: cover; }
.logo-img.sm { width: 24px; height: 24px; }
.alert { background: color-mix(in srgb, var(--danger) 8%, transparent); border: 1px solid var(--danger); color: #922B21; padding: 10px 12px; border-radius: var(--radius); font-size: .9rem; }
.okbox { background: rgba(46,125,50,.10); border: 1px solid #7BAE7F; color: #1B5E20; padding: 10px 12px; border-radius: var(--radius); font-size: .9rem; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--vert-pale); color: var(--accent); padding: 4px 11px; border-radius: 999px; font-size: .85rem; font-weight: 600; }
.chip button { background: transparent; border: 0; color: var(--accent); font-weight: 700; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.chips.selectable .chip { cursor: pointer; user-select: none; background: var(--card); color: var(--muted); border: 1px solid var(--line); }
.chips.selectable .chip.on { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.mini-chip { font-size: .72rem; background: var(--vert-pale); color: var(--accent); padding: 1px 8px; border-radius: 999px; font-weight: 700; }
.mini-chip.always { background: var(--terra-pale); color: #A34A1F; border: 1px solid rgba(192,90,40,.35); }
.count-pill { background: var(--accent); color: var(--on-accent); border-radius: 999px; padding: 1px 11px; font-size: .82rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.search-input { border-radius: 999px; padding: 10px 16px; max-width: 260px; }
.search-input.wide { max-width: 420px; width: 100%; margin: 6px 0 10px; }
form.inline { display: flex; gap: 8px; }
form.inline input { flex: 1; }
.stat-n, .cr-n, .st-n, .pc-n, .ch-when, .count, .h-date, .dash-clocks, .m-sub, .rec-sub {
  font-variant-numeric: tabular-nums;
}

/* ---------- Connexion ---------- */
.login-wrap { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.login-card {
  width: 100%; max-width: 380px; background: var(--card);
  border: 1px solid var(--line-soft); border-radius: 16px; box-shadow: var(--ombre);
  padding: 30px 26px; display: flex; flex-direction: column; gap: 14px;
}
.login-card .brand { justify-content: center; }
.logo-login { width: 96px; height: 96px; border-radius: 20px; object-fit: cover; display: block; margin: 0 auto 4px; }
.login-card .subtitle { color: var(--muted); margin: -6px 0 6px; text-align: center; }
.login-card label, .login-card .stack label { display: flex; flex-direction: column; gap: 6px; font-size: .9rem; color: var(--muted); font-weight: 600; }
.login-card button[type="submit"], .login-card .stack button {
  background: var(--primary); color: var(--on-accent); border: 0; border-radius: var(--radius);
  padding: 13px; font-weight: 700; box-shadow: 0 4px 14px -4px rgba(192,90,40,.5);
}
.login-card .stack { display: flex; flex-direction: column; gap: 14px; }
.forgot-link { color: var(--muted); font-size: .85rem; text-align: center; text-decoration: none; margin-top: 4px; }
.forgot-link:hover { color: var(--primary); }
.wa-fallback {
  display: block; text-align: center; background: var(--accent); color: var(--on-accent);
  border-radius: var(--radius); padding: 12px; font-weight: 700; text-decoration: none;
}

/* Mot de passe : œil + jauge + bulle */
.pw-wrap { position: relative; display: block; }
.pw-wrap input { padding-right: 44px; }
.pw-eye {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  background: none; border: 0; padding: 8px; border-radius: 9px; color: var(--muted);
  display: inline-flex; align-items: center;
}
.pw-eye:hover { background: var(--vert-pale); color: var(--accent); }
.pw-eye .ic-eye-off { display: none; }
.pw-eye.shown .ic-eye { display: none; }
.pw-eye.shown .ic-eye-off { display: inline; }
.pw-meter-track { height: 6px; background: var(--line-soft); border-radius: 999px; overflow: hidden; }
.pw-meter { height: 100%; width: 0; border-radius: 999px; transition: width .25s ease, background .25s ease; }
.pw-meter-label { min-height: 1em; }
.pw-bulle { background: var(--terra-pale); border: 1px solid rgba(192,90,40,.4); color: #7A3B18; padding: 10px 12px; border-radius: var(--radius); font-size: .88rem; }

/* ---------- Coquille : barre latérale (bureau) ---------- */
.shell { display: flex; min-height: 100vh; min-height: 100dvh; }
.side {
  width: 224px; flex: 0 0 auto; position: sticky; top: 0; align-self: flex-start;
  height: 100vh; height: 100dvh; display: flex; flex-direction: column;
  background: var(--bg-2); border-right: 1px solid var(--line);
  padding: 18px 12px calc(14px + env(safe-area-inset-bottom));
}
.side .brand { padding: 0 8px 16px; }
.side .tabs { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.tab {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: transparent; color: var(--muted); border: 0;
  padding: 11px 12px; border-radius: var(--radius); font-weight: 600; font-size: .95rem;
  position: relative;
}
.tab:hover { background: var(--card); color: var(--txt); }
.tab.active { background: var(--accent); color: var(--on-accent); }
.tab .t-ico { line-height: 0; display: inline-flex; }
.tab .t-ico svg { width: 18px; height: 18px; }
.tab.tab-hidden { display: none !important; }
.side-foot { display: flex; flex-direction: column; gap: 8px; padding: 10px 8px 0; border-top: 1px solid var(--line); }
.side-user { color: var(--muted); font-size: .88rem; display: inline-flex; align-items: center; gap: 6px; }
.side-foot form { margin: 0; }
.side-foot .ghost { width: 100%; justify-content: center; }
.content { flex: 1; min-width: 0; }
main { max-width: 860px; margin: 0 auto; padding: 20px 18px 60px; }
.panel { display: none; }
.panel.active { display: block; animation: fadein .22s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.h-actions, .head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.page-back {
  background: none; border: none; color: var(--accent); font-weight: 700;
  font-size: .95rem; padding: 4px 0 10px; cursor: pointer; display: none;
}
.m-topbar { display: none; }

/* Badge numérique « nouveaux messages » (maquette) */
.tab.has-new::after { content: none; }
.tab-badge {
  position: absolute; top: 4px; right: 8px; min-width: 17px; height: 17px;
  border-radius: 999px; background: var(--primary); color: #fff;
  font-size: 10px; font-weight: 700; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center; padding: 0 4px;
  font-variant-numeric: tabular-nums; pointer-events: none;
}

/* ---------- Accueil (maquette) ---------- */
.dash-head { padding: 4px 0 0; }
#dash-hello { margin-bottom: 2px; }
.dash-date { font-size: .85rem; color: var(--muted); margin: 0 0 2px; text-transform: capitalize; }
.dash-clocks { font-size: .85rem; color: var(--muted); }
.dash-clocks strong { color: var(--accent); }
.wa-chip, .dash-banner {
  display: inline-flex; align-items: center; gap: 7px; margin: 12px 0 4px;
  font-size: .84rem; font-weight: 600; padding: 6px 13px; border-radius: 999px;
}
.wa-chip.on { background: var(--vert-pale); border: 1px solid rgba(46,74,59,.18); color: var(--accent); }
.wa-chip.off, .dash-banner.warn { background: var(--terra-pale); border: 1px solid rgba(192,90,40,.4); color: #8A3D14; }
.wa-chip i { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; }
.wa-chip.on i { background: var(--ok); box-shadow: 0 0 0 3px rgba(46,125,50,.15); }
.wa-chip.off i { background: var(--warn); animation: pulse 1.2s infinite; }
.dash-banner a { font-weight: 700; }
.dash-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 14px 0 18px; }
.stat-card {
  display: flex; flex-direction: column; gap: 2px;
  background: var(--card); border: 1px solid var(--line-soft); border-radius: var(--radius);
  padding: 14px; box-shadow: var(--ombre); cursor: default;
}
.stat-i { color: var(--muted); line-height: 0; }
.stat-i svg { width: 16px; height: 16px; }
.stat-n { font-family: var(--disp); font-weight: 400; font-size: 1.85rem; line-height: 1.1; color: var(--txt); }
.stat-card.t-accent .stat-n { color: var(--primary); }
.stat-l { font-size: .78rem; color: var(--muted); font-weight: 500; }
/* Carrés indicateurs colorés — palette KECH-BOOK */
.stat-card.st-vert  { background: var(--vert-pale);  border-color: rgba(46,74,59,.28); }
.stat-card.st-vert .stat-n,  .stat-card.st-vert .stat-i  { color: var(--accent); }
.stat-card.st-ocre  { background: rgba(168,118,62,.14); border-color: rgba(168,118,62,.35); }
.stat-card.st-ocre .stat-n,  .stat-card.st-ocre .stat-i  { color: var(--ocre); }
.stat-card.st-terra { background: var(--terra-pale); border-color: rgba(192,90,40,.35); }
.stat-card.st-terra .stat-n, .stat-card.st-terra .stat-i { color: var(--primary); }
.stat-card.st-sable { background: var(--line-soft);  border-color: var(--line); }
.stat-card.st-sable .stat-n, .stat-card.st-sable .stat-i { color: var(--muted); }
.stat-card.st-vert .stat-l, .stat-card.st-ocre .stat-l,
.stat-card.st-terra .stat-l, .stat-card.st-sable .stat-l { color: var(--txt); opacity: .75; }
.dash-actions { display: flex; flex-direction: column; gap: 8px; margin-bottom: 22px; }
.dash-action {
  display: flex; align-items: center; gap: 13px; text-align: left; width: 100%;
  background: var(--card); border: 1px solid var(--line-soft); border-radius: var(--radius);
  padding: 13px 14px; color: var(--txt); font-size: .95rem; font-weight: 600;
  box-shadow: var(--ombre);
}
.dash-action:hover { transform: translateY(-1px); border-color: var(--line); }
.dash-action > svg { width: 38px; height: 38px; padding: 9px; border-radius: 11px; box-sizing: border-box; flex: 0 0 auto; }
.dash-action span { display: flex; flex-direction: column; gap: 2px; }
.dash-action small { color: var(--muted); font-size: .8rem; font-weight: 500; }
.dash-action .chev { margin-left: auto; color: var(--line); font-size: 1.2rem; flex: 0 0 auto; }
.dash-action[data-goto="discussions"] > svg { background: var(--vert-pale); color: var(--accent); }
.dash-action[data-goto="membres"] > svg { background: rgba(168,118,62,.12); color: var(--ocre); }
.dash-action[data-goto="historique"] > svg { background: var(--line-soft); color: var(--muted); }
.dash-action.primary-action, .dash-action[data-goto="diffuser"] {
  background: var(--primary); border-color: var(--primary); color: var(--on-accent);
  box-shadow: 0 4px 14px -4px rgba(192,90,40,.5);
}
.dash-action[data-goto="diffuser"] > svg { background: rgba(255,255,255,.16); color: #fff; }
.dash-action[data-goto="diffuser"] small { color: rgba(255,255,255,.85); }
.dash-action[data-goto="diffuser"] .chev { color: rgba(255,255,255,.6); }
.dash-action[data-goto="diffuser"]:hover { filter: brightness(1.05); }
.dash-sub { font-family: var(--disp); font-weight: 400; font-size: 1.15rem; margin: 4px 0 10px; display: flex; align-items: center; gap: 8px; }

/* ---------- Diffuser ---------- */
.diff-templates { display: flex; flex-direction: column; gap: 10px; margin: 6px 0 18px; }
.tpl-card {
  display: flex; align-items: center; gap: 12px; text-align: left;
  background: var(--card); border: 1.5px solid var(--line-soft); border-radius: var(--radius);
  padding: 16px 15px; box-shadow: var(--ombre); cursor: pointer;
}
.tpl-card:hover { transform: translateY(-2px); border-color: var(--line); }
.tpl-card:active { transform: none; }
.tpl-ic {
  width: 46px; height: 46px; border-radius: 13px; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
}
.tpl-ic svg { width: 22px; height: 22px; }
#tpl-recherche .tpl-ic { background: rgba(168,118,62,.14); color: var(--ocre); }
#tpl-propose .tpl-ic { background: var(--vert-pale); color: var(--accent); }
.tpl-lbl { flex: 1; font-weight: 700; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tpl-card .chev { color: var(--line); font-size: 1.2rem; flex: 0 0 auto; }
#tpl-libre .tpl-ic { background: var(--primary); color: #fff; }
.tpl-txt { display: flex; flex-direction: column; gap: 1px; }
.tpl-txt strong { font-size: 1rem; }
.tpl-txt small { color: var(--muted); font-size: .82rem; }
.diff-libre { text-align: center; margin: 0 0 18px; }
.lien-libre {
  background: none; border: none; color: var(--muted); font-size: .9rem;
  font-weight: 600; cursor: pointer; padding: 8px 12px; border-radius: 9px;
}
.lien-libre:hover { color: var(--accent); background: var(--vert-pale); }

/* Parcours en 3 étapes (stepper maquette) */
.diff-progress { display: flex; align-items: center; gap: 6px; margin: 0 2px 16px; }
.dp-item { display: inline-flex; align-items: center; gap: 6px; font-size: .84rem; font-weight: 600; color: var(--muted); white-space: nowrap; cursor: default; }
.dp-item i {
  width: 24px; height: 24px; border-radius: 50%; font-style: normal; font-size: .76rem; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--line-soft); color: var(--muted);
  transition: background .2s, color .2s;
}
.dp-item.on { color: var(--txt); }
.dp-item.on i { background: var(--accent); color: var(--on-accent); }
.dp-item.done { color: var(--accent); cursor: pointer; }
.dp-item.done i { background: var(--vert-pale); color: var(--accent); }
.dp-sep { flex: 1; height: 2px; background: var(--line-soft); border-radius: 2px; min-width: 8px; }
.diff-step { margin-bottom: 24px; }
.step-head { font-size: 1.02rem; font-weight: 700; margin-bottom: 10px; display: flex; align-items: center; gap: 9px; }
.step-head .step-n {
  width: 26px; height: 26px; border-radius: 50%; flex: 0 0 auto; font-size: .82rem; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent); color: var(--on-accent);
}
.diff-card {
  background: var(--card); border: 1px solid var(--line-soft); border-radius: var(--radius);
  box-shadow: var(--ombre); padding: 16px;
}
.diff-card > .hint:first-child { margin-top: 0; }
.step-nav { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; }
.step-nav .step-next { margin-left: auto; }
.step-next, .step-prev { padding: 13px 22px; border-radius: var(--radius); font-size: .95rem; font-weight: 700; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: .88rem; color: var(--muted); font-weight: 600; margin-bottom: 6px; }
.field input, .field select, .field textarea { font-weight: 400; color: var(--txt); }

/* Interrupteurs (maquette) pour les cases à bascule */
.chk-line { display: flex; gap: 10px; align-items: center; font-size: .92rem; margin: 8px 0; cursor: pointer; }
.chk-line input[type="checkbox"] {
  appearance: none; -webkit-appearance: none;
  width: 38px; height: 22px; border-radius: 999px; flex: 0 0 auto;
  background: var(--line); border: none; margin: 0; cursor: pointer;
  position: relative; transition: background .18s ease; padding: 0;
}
.chk-line input[type="checkbox"]::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25);
  transition: left .18s ease;
}
.chk-line input[type="checkbox"]:checked { background: var(--accent); }
.chk-line input[type="checkbox"]:checked::after { left: 18px; }
.chk-line input[type="checkbox"]:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.schedule-toggle { margin: 10px 0 4px; }
.chk-line.bilingue { margin: 8px 0 2px; }

/* Outils de composition */
#msg-body { min-height: 110px; }
.msg-tools { display: flex; gap: 7px; margin: 10px 0 2px; flex-wrap: wrap; }
.tool-pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 8px 13px; font-size: .84rem; font-weight: 600; border-radius: 999px;
  background: var(--bg-2); border: 1px solid var(--line-soft); color: var(--muted);
}
.tool-pill:hover { color: var(--accent); border-color: var(--accent); }
.tool-pill svg { width: 14px; height: 14px; }
#mic-btn.recording { background: color-mix(in srgb, var(--danger) 14%, transparent); border-color: var(--danger); color: var(--danger); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .45; } }
.tip-nom { margin-top: 12px; font-size: .82rem; }

/* Aperçus médias joints */
.voice-preview {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  background: var(--vert-pale); border: 1px solid rgba(46,74,59,.2);
  border-radius: var(--radius); padding: 12px 14px; margin-top: 12px;
}
.voice-preview > .ico-btn { font-size: .88rem; color: var(--accent); }
.voice-preview audio { flex: 1; min-width: 200px; }
.photo-gallery, .video-gallery { width: 100%; display: flex; gap: 8px; flex-wrap: wrap; }
.pg-item { position: relative; width: 76px; height: 76px; }
.pg-item img, .pg-item video { width: 100%; height: 100%; object-fit: cover; border-radius: 10px; border: 1.5px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.14); }
.pg-del {
  position: absolute; top: -7px; right: -7px; width: 22px; height: 22px; line-height: 20px;
  border-radius: 50%; background: var(--danger); color: #fff; border: 0; font-size: 14px;
  box-shadow: 0 1px 4px rgba(0,0,0,.3); padding: 0;
}
.vg-item .preview-video { max-width: 210px; border-radius: var(--radius); box-shadow: 0 2px 8px rgba(0,0,0,.16); }
.tpl-media { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Darija */
#darija-zone { margin-top: 14px; padding: 14px; border-radius: var(--radius); background: var(--vert-pale); border: 1px solid rgba(46,74,59,.22); }
#darija-zone .field { font-weight: 700; color: var(--accent); }
#msg-darija { font-size: 1.05rem; line-height: 1.7; }
.send-lang { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; margin-top: 10px; font-size: .9rem; color: var(--muted); }
.send-lang label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.send-lang input { width: auto; accent-color: var(--accent); }
.trad-btn { align-self: flex-start; }
.trad-out { background: var(--vert-pale); border: 1px solid rgba(46,74,59,.35); color: var(--accent); border-radius: 10px; padding: 8px 10px; font-size: .95rem; }
.trad-out.auto { margin-top: 6px; font-size: .9rem; opacity: .95; }

/* Destinataires : catégories + panier + recherche */
.cat-search-row { margin: 10px 0 8px; }
.cat-list {
  display: flex; flex-direction: column; gap: 0; margin-bottom: 14px;
  border: 1px solid var(--line-soft); border-radius: var(--radius); overflow: hidden; background: var(--card);
  box-shadow: var(--ombre);
}
.cat-row {
  display: flex; align-items: center; gap: 11px; width: 100%; text-align: left;
  background: transparent; border: none; border-bottom: 1px solid var(--line-soft);
  padding: 12px 14px; color: var(--txt); font-size: .95rem; cursor: pointer;
}
.cat-row:last-child { border-bottom: none; }
.cat-row:hover { background: var(--bg-2); }
.cr-box {
  width: 21px; height: 21px; flex: 0 0 auto; border-radius: 6px;
  border: 1.5px solid var(--line); background: var(--card);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .8rem; font-weight: 800; color: #fff; line-height: 1;
}
.cat-row.on .cr-box { background: var(--accent); border-color: var(--accent); }
.cat-row.partiel .cr-box { background: color-mix(in srgb, var(--accent) 45%, transparent); border-color: var(--accent); }
.cr-dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; background: var(--muted); opacity: .55; }
.cat-row.on .cr-dot { opacity: 1; }
.tous-dot { background: linear-gradient(135deg, var(--primary), var(--accent)); opacity: 1; }
.cat-row.nocat .cr-dot { background: transparent; border: 1.5px dashed var(--muted); }
.cr-nom { flex: 1; }
.cr-n { color: var(--muted); font-size: .85rem; background: var(--line-soft); border-radius: 999px; padding: 1px 9px; }
.cat-row.on .cr-n { background: var(--vert-pale); color: var(--accent); }
.cat-row.tous { background: color-mix(in srgb, var(--accent) 4%, transparent); }
.cat-row.effacer { color: var(--danger); font-weight: 600; }
.cat-row.effacer .cr-box { border-style: dashed; }
.cat-list .empty { padding: 14px; }
.basket {
  border: 1.5px dashed var(--line); border-radius: var(--radius); padding: 12px; min-height: 48px;
  display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; background: var(--bg-2);
}
.basket-empty { color: var(--muted); font-size: .88rem; }
.bk-chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--card); border: 1px solid var(--line); border-radius: 999px;
  padding: 4px 6px 4px 11px; font-size: .84rem;
}
.bk-chip.always { border-color: rgba(192,90,40,.5); }
.bk-chip button { background: transparent; border: 0; color: var(--muted); font-size: 1.1rem; line-height: 1; padding: 0 4px; }
.bk-chip button:hover { color: var(--danger); }
.rec-search-row { margin: 6px 0; }
.recipients { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; max-height: 44vh; overflow: auto; }
.rec {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 10px 12px;
}
.rec input[type="checkbox"] { width: 20px; height: 20px; flex: 0 0 auto; accent-color: var(--accent); }
.rec-main { flex: 1; min-width: 0; }
.rec-name { font-weight: 600; }
.rec-sub { color: var(--muted); font-size: .82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.rec-tags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 2px; }

/* Envoi */
.salut-info {
  display: flex; align-items: flex-start; gap: 10px; margin-top: 4px; padding: 12px 14px;
  border-radius: var(--radius); font-size: .9rem; line-height: 1.45;
  background: var(--vert-pale); border: 1px solid rgba(46,74,59,.2);
}
.salut-info:empty { display: none; }
.si-ico { font-size: 1.1rem; line-height: 1.2; }
.salut-info small { color: var(--muted); display: block; margin-top: 2px; }
.send-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; flex-wrap: wrap; }
.count { color: var(--muted); font-size: .9rem; }
#open-all { background: var(--primary); color: var(--on-accent); padding: 14px 26px; font-size: 1rem; border-radius: var(--radius); font-weight: 700; border: 0; box-shadow: 0 4px 14px -4px rgba(192,90,40,.5); }
#open-all:hover { filter: brightness(1.05); }
#schedule-zone { margin: 8px 0; }
.prog-track { height: 12px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 999px; overflow: hidden; margin: 14px 0 8px; }
.prog-fill { height: 100%; background: var(--accent); border-radius: 999px; transition: width .5s; }
#upload-progress { margin: 8px 0; }

/* Pages des modèles (Je recherche / Je propose) */
.tpl-head { margin-bottom: 16px; }
.tpl-head h1 { margin: 6px 0 2px; }
.tpl-head .hint { margin: 0; max-width: 55ch; }
.tpl-form .diff-card { display: flex; flex-direction: column; gap: 14px; }
.tpl-form .date-row, .date-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.type-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 2px; }
.type-chip {
  border: 1.5px solid var(--line); background: var(--card); color: var(--txt);
  border-radius: 999px; padding: 9px 15px; font-size: .9rem; font-weight: 600;
}
.type-chip:hover { border-color: var(--accent); color: var(--accent); }
.type-chip.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

/* ---------- Sous-onglets ---------- */
.sub-tabs { display: flex; gap: 6px; margin: 4px 0 14px; border-bottom: 1.5px solid var(--line); }
.sub-tab {
  display: inline-flex; align-items: center; gap: 7px; background: none; border: none;
  padding: 11px 14px; font-size: .92rem; font-weight: 600; color: var(--muted);
  border-bottom: 2.5px solid transparent; margin-bottom: -1.5px; cursor: pointer;
}
.sub-tab:hover { color: var(--txt); }
.sub-tab.on { color: var(--accent); border-bottom-color: var(--accent); }
.sub-tab svg { width: 16px; height: 16px; }
.st-n { background: var(--primary); color: #fff; border-radius: 999px; padding: 1px 8px; font-size: .74rem; font-weight: 800; }

/* Segments de filtre par catégorie (maquette) */
.seg { display: flex; gap: 6px; overflow-x: auto; margin: 10px 0 12px; padding-bottom: 2px; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg button {
  flex: 0 0 auto; font-size: .84rem; font-weight: 650; padding: 7px 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--card); color: var(--muted); cursor: pointer;
}
.seg button.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.seg button .n { opacity: .7; font-variant-numeric: tabular-nums; margin-left: 3px; }

/* ---------- Discussions : liste (maquette) ---------- */
.chat-search-row { margin: 0 0 12px; }
.chat-list { border: 1px solid var(--line-soft); border-radius: 14px; overflow: hidden; background: var(--card); box-shadow: var(--ombre); }
.chat-row {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  background: transparent; border: none; border-bottom: 1px solid var(--line-soft);
  padding: 12px 13px; cursor: pointer; color: var(--txt);
}
.chat-row:last-child { border-bottom: none; }
.chat-row:hover { background: var(--bg-2); }
.ch-av, .th-av {
  width: 42px; height: 42px; flex: 0 0 auto; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .92rem; color: #fff; letter-spacing: .02em;
  background: linear-gradient(135deg, var(--primary), var(--ocre));
}
.ch-av.alt { background: linear-gradient(135deg, #5b7a68, var(--accent)); }
.ch-mid { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.ch-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.ch-nom { font-weight: 650; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cat-tag {
  display: inline-block; font-size: .68rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  padding: 1px 7px; border-radius: 999px; margin-left: 6px; vertical-align: 1px;
  background: var(--vert-pale); color: var(--accent);
}
.ch-when { color: var(--muted); font-size: .76rem; flex: 0 0 auto; }
.ch-last { color: var(--muted); font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 4px; }
.ch-last svg { width: 13px; height: 13px; flex: 0 0 auto; }
.ch-last mark { background: var(--terra-pale); color: inherit; border-radius: 3px; padding: 0 2px; }
.ch-del { flex: 0 0 auto; color: var(--muted); opacity: 0; padding: 8px; border-radius: 9px; background: none; border: 0; }
.chat-row:hover .ch-del { opacity: 1; }
.ch-del:hover { color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); }
@media (hover: none) { .ch-del { opacity: .5; } }
.chat-sep { font-size: .78rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 14px 2px 6px; }

/* Conversation ouverte */
.thread-head {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; margin-bottom: 12px;
  background: var(--card); border: 1px solid var(--line-soft); border-radius: var(--radius);
  position: sticky; top: 0; z-index: 5; box-shadow: var(--ombre);
}
.th-back {
  width: 38px; height: 38px; flex: 0 0 auto; border-radius: 50%; border: none;
  background: var(--vert-pale); color: var(--accent);
  font-size: 1.5rem; line-height: 1; display: inline-flex; align-items: center; justify-content: center;
}
.th-back:hover { background: color-mix(in srgb, var(--accent) 18%, transparent); }
.th-av { width: 40px; height: 40px; font-size: .9rem; }
.th-id { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.th-id strong { font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.th-id small { color: var(--muted); font-size: .8rem; }
.th-del { flex: 0 0 auto; background: none; border: none; color: var(--muted); padding: 8px; border-radius: 9px; }
.th-del:hover { color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); }
/* Bouton d'appel (comme WhatsApp) : rond vert dans l'en-tête de conversation */
.th-call {
  flex: 0 0 auto; width: 38px; height: 38px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent); color: var(--on-accent); text-decoration: none;
}
.th-call:hover { filter: brightness(1.08); }
.thread {
  display: flex; flex-direction: column; gap: 8px;
  background: var(--card); border: 1px solid var(--line-soft); border-radius: var(--radius);
  padding: 14px; max-height: 55vh; overflow-y: auto; box-shadow: var(--ombre);
}
.bubble { max-width: 78%; padding: 9px 12px; border-radius: 14px; font-size: .95rem; white-space: pre-wrap; word-break: break-word; }
.bubble.in { background: var(--bg-2); border: 1px solid var(--line-soft); align-self: flex-start; border-bottom-left-radius: 4px; }
.bubble.out { background: #E4F2DC; border: 1px solid #C8E0B8; color: #23331F; align-self: flex-end; border-bottom-right-radius: 4px; }
.bubble-meta { color: #7C8B74; font-size: .72rem; margin-top: 3px; display: flex; align-items: center; gap: 6px; justify-content: flex-end; }
.bubble-del { background: none; border: 0; color: inherit; opacity: .55; padding: 2px; }
.bubble-del svg { width: 12px; height: 12px; }
.bubble-del:hover { opacity: 1; color: var(--danger); }
.bubble-img { max-width: 240px; border-radius: 10px; display: block; cursor: zoom-in; }
.bubble-video { max-width: 260px; border-radius: 10px; display: block; }
.bubble-doc {
  display: flex; align-items: center; gap: 8px; background: rgba(46,74,59,.05);
  border-radius: 9px; padding: 8px 10px; text-decoration: none; color: inherit; font-size: .88rem;
}
.bubble-body a { color: var(--primary); }
.voice-note { min-width: 220px; }
.tick { font-weight: 700; }
.tick.read, .read-badge { color: var(--ok); }
.media-dl { display: flex; align-items: center; gap: 10px; padding: 6px 2px; min-width: 0; }
.media-dl svg { flex: 0 0 auto; opacity: .75; }
.media-dl-info { font-size: .92em; opacity: .85; max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-dl .dl-btn { flex: 0 0 auto; white-space: nowrap; }

/* Barre de réponse */
.thread-reply { display: flex; gap: 6px; align-items: center; margin-top: 10px; flex-wrap: wrap; position: relative; }
.thread-reply input:not([type]), .thread-reply input[type="text"] { flex: 1; min-width: 160px; border-radius: 999px; padding: 11px 16px; }
.round-btn, .tool-btn, .voice-btn {
  width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--card); color: var(--muted); flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center; font-size: 1rem; padding: 0;
}
.round-btn:hover, .tool-btn:hover, .voice-btn:hover { border-color: var(--accent); color: var(--accent); }
.round-btn.send-btn, .rec-send-btn { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.round-btn.send-btn:hover { color: var(--on-accent); filter: brightness(1.05); }
.send-ico { display: inline-flex; align-items: center; justify-content: center; }
.attach-toggle.open { background: var(--accent); color: var(--on-accent); border-color: var(--accent); transform: rotate(45deg); }
.attach-menu {
  display: flex; flex-direction: column; gap: 4px; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--ombre);
  padding: 6px; position: absolute; bottom: 52px; left: 0; z-index: 10; min-width: 180px;
}
.attach-opt { display: flex; align-items: center; gap: 9px; background: none; border: 0; padding: 9px 11px; border-radius: 9px; text-align: left; font-size: .92rem; }
.attach-opt:hover { background: var(--vert-pale); color: var(--accent); }
.ao-ic {
  width: 40px; height: 40px; border-radius: 50%; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center; color: #fff;
}
.ao-ic svg { width: 20px; height: 20px; }
.ao-photo { background: var(--primary); }
.ao-doc { background: var(--accent); }
.ao-voice { background: var(--ocre); }
.emoji-panel {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(34px, 1fr)); gap: 2px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--ombre); padding: 8px; max-height: 200px; overflow-y: auto; margin: 8px 0;
}
.emoji { background: none; border: 0; font-size: 1.25rem; padding: 4px; border-radius: 7px; }
.emoji:hover { background: var(--bg); }

/* Enregistreur vocal */
#recorder-bar {
  position: fixed; left: 14px; right: 14px; bottom: 20px; z-index: 60;
  display: flex; align-items: center; gap: 10px;
  background: var(--card); border: 1px solid var(--line); border-radius: 999px;
  padding: 10px 12px; box-shadow: 0 14px 40px rgba(43,42,36,.3);
  max-width: 640px; margin: 0 auto;
}
.rec-dot { width: 12px; height: 12px; border-radius: 999px; background: var(--danger); animation: pulse 1s infinite; flex: 0 0 auto; }
#rec-time { font-variant-numeric: tabular-nums; font-weight: 700; min-width: 42px; text-align: center; }
#rec-wave { flex: 1; min-width: 0; height: 40px; display: block; }
.rec-cancel {
  background: transparent; border: 1px solid var(--line); color: var(--danger);
  border-radius: 999px; width: 42px; height: 42px; font-size: 1.05rem; flex: 0 0 auto;
}
.rec-cancel:hover { border-color: var(--danger); }
.rec-send-btn { border: 0; border-radius: 999px; width: 46px; height: 46px; font-size: 1.1rem; flex: 0 0 auto; box-shadow: 0 4px 14px rgba(46,74,59,.35); }

/* Corbeille des discussions */
.corb-bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 10px 0 8px; padding: 10px 12px;
  border: 1px solid var(--line-soft); border-radius: var(--radius); background: var(--bg-2);
}
.corb-all { display: flex; align-items: center; gap: 8px; font-size: .9rem; cursor: pointer; }
.corb-info { font-size: .85rem; color: var(--muted); }
.corb-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.corb-actions button { display: inline-flex; align-items: center; gap: 6px; }
.corb-list .corb-row { cursor: default; }
.corb-row { display: flex; align-items: center; gap: 12px; }
.corb-case { width: 18px; height: 18px; flex: 0 0 auto; cursor: pointer; accent-color: var(--accent); }

/* Envois programmés */
.prog-card {
  background: var(--card); border: 1px solid var(--line-soft); border-radius: var(--radius);
  padding: 16px; margin-bottom: 14px; box-shadow: var(--ombre);
}
.pc-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.pc-when { display: inline-flex; align-items: center; gap: 7px; font-weight: 700; color: var(--accent); text-transform: capitalize; font-size: .95rem; }
.pc-when svg { width: 15px; height: 15px; }
.pc-n { background: var(--vert-pale); color: var(--accent); border-radius: 999px; padding: 2px 11px; font-size: .8rem; font-weight: 700; }
.pc-body { white-space: pre-wrap; line-height: 1.5; padding: 12px 14px; border-radius: 10px; background: var(--bg-2); border: 1px solid var(--line-soft); font-size: .93rem; }
.pc-media { margin-top: 8px; font-size: .84rem; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.pc-media svg { width: 14px; height: 14px; }
.pc-dest { margin-top: 10px; font-size: .86rem; color: var(--muted); line-height: 1.45; }
.pc-dest strong { color: var(--txt); }
.pc-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.danger-txt { color: var(--danger); }

/* ---------- Collaborateurs ---------- */
.menu-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 4px 0 8px; }
.menu { position: relative; }
.menu-btn {
  background: var(--card); border: 1px solid var(--line); color: var(--txt);
  border-radius: var(--radius); padding: 9px 13px; font-weight: 600;
}
.menu-btn:hover { border-color: var(--accent); }
.caret { font-size: .75em; opacity: .6; }
.menu-panel {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 40; min-width: 240px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--ombre); padding: 6px; display: flex; flex-direction: column; gap: 2px;
  max-height: 60vh; overflow-y: auto;
}
.menu-item {
  display: flex; align-items: center; gap: 9px; background: none; border: 0;
  padding: 10px 11px; border-radius: 9px; text-align: left; font-size: .92rem; width: 100%;
}
.menu-item:hover { background: var(--vert-pale); color: var(--accent); }
.menu-sep { height: 1px; background: var(--line-soft); margin: 4px 6px; }
.mi-dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; }
.mi-label { flex: 1; }
.mi-count { background: var(--vert-pale); color: var(--accent); font-size: .78rem; border-radius: 999px; padding: 1px 8px; font-variant-numeric: tabular-nums; }
.members { display: flex; flex-direction: column; gap: 10px; }
.member {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--line-soft); border-radius: var(--radius);
  padding: 11px 13px; box-shadow: var(--ombre);
}
.member .ch-av { width: 40px; height: 40px; font-size: .85rem; }
.m-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.m-name { font-weight: 650; }
.m-sub { color: var(--muted); font-size: .8rem; font-family: var(--mono); }
.m-actions { display: flex; gap: 8px; }
.fab {
  display: none; position: fixed; right: 18px; z-index: 25;
  bottom: calc(84px + env(safe-area-inset-bottom));
  width: 56px; height: 56px; border-radius: 50%; border: none;
  background: var(--primary); color: #fff; font-size: 26px; line-height: 1;
  box-shadow: 0 8px 20px -6px rgba(192,90,40,.6);
  align-items: center; justify-content: center;
}
.fab:active { transform: scale(.96); }
@media (max-width: 720px) { #tab-membres .fab { display: flex; } }
@media (min-width: 721px) { .fab { display: none !important; } }

/* Catégories : cartes, éditeur, palette, drag */
.tag-tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.cat-card, .cat-editor {
  background: var(--card); border: 1px solid var(--line-soft); border-radius: var(--radius);
  padding: 14px; box-shadow: var(--ombre); margin: 8px 0;
}
.cat-name { font-weight: 700; }
.cat-sub, .cat-info { color: var(--muted); font-size: .85rem; }
.cat-mini { font-size: .78rem; color: var(--muted); }
.cat-drag { cursor: grab; }
.cat-drag.dragging, .dragging { opacity: .55; }
.cat-palette, .color-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.cat-swatch, .color-dot {
  width: 30px; height: 30px; border-radius: 50%; border: 2px solid transparent; padding: 0; background-clip: padding-box;
}
.cat-swatch.on, .color-dot.on, .cat-swatch.sel, .color-dot.sel { border-color: var(--txt); box-shadow: 0 0 0 2px #fff inset; }
.color-dot.none { background: var(--bg); color: var(--muted); border: 1px dashed var(--line); font-size: .8rem; }
.cat-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.cat-btn {
  --cat: var(--accent);
  display: inline-flex; align-items: center; gap: 7px;
  border: 1.5px solid var(--line); background: var(--card); color: var(--txt);
  border-radius: 999px; padding: 8px 14px; font-size: .9rem; font-weight: 600;
}
.cat-btn:hover { transform: translateY(-1px); border-color: var(--cat); }
.cat-btn.on { background: var(--cat); border-color: var(--cat); color: #fff; }
.cat-btn.nocat { --cat: #8a8a8a; border-style: dashed; color: var(--muted); }
.cat-btn.nocat.on { color: #fff; border-style: solid; }
.cat-choose { display: flex; gap: 8px; flex-wrap: wrap; }
/* Pilules de catégorie de l'écran d'importation (retour visuel de sélection) */
.cat-pick {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--card); border: 1.5px solid var(--line); color: var(--txt);
  border-radius: 999px; padding: 9px 14px; font-weight: 600; font-size: .9rem;
}
.cat-pick .cp-dot { width: 11px; height: 11px; border-radius: 50%; flex: 0 0 auto; }
.cat-pick.on { background: var(--cat, var(--accent)); border-color: var(--cat, var(--accent)); color: #fff; }
.cat-pick.on .cp-dot { background: #fff !important; }
.tag-menu { position: relative; }
.tagm-cb { accent-color: var(--accent); width: 18px; height: 18px; }
.quick-cats { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 12px; }

/* Import */
.import-sources { display: flex; flex-direction: column; gap: 8px; }
.import-src {
  display: flex; align-items: center; gap: 12px; text-align: left; width: 100%;
  background: var(--card); border: 1px solid var(--line-soft); border-radius: var(--radius);
  padding: 13px 14px; box-shadow: var(--ombre); font-weight: 600;
}
.import-src:hover { transform: translateY(-1px); border-color: var(--line); }
.import-src small { display: block; color: var(--muted); font-weight: 500; font-size: .8rem; }
.import-toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 10px 0; }
.import-selrow { display: flex; align-items: center; gap: 8px; }
.imp-cb { width: 19px; height: 19px; accent-color: var(--accent); }
.imp-cats { display: flex; gap: 6px; flex-wrap: wrap; }
.import-selrow #imp-count { flex: 1; color: var(--muted); font-size: .85rem; }
#link-modal textarea { word-break: break-all; }
.danger-src { border-color: color-mix(in srgb, var(--danger) 40%, transparent); }

/* ---------- Historique ---------- */
.history { display: flex; flex-direction: column; gap: 12px; margin-top: 10px; }
.hist { background: var(--card); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--ombre); }
.hist.sched { border-left: 3px solid var(--primary); }
.h-date { color: var(--muted); font-size: .82rem; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.h-body { white-space: pre-wrap; margin: 6px 0 10px; }
.h-recips { display: flex; flex-wrap: wrap; gap: 6px; }
.h-recip { font-size: .78rem; padding: 2px 9px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.h-recip.envoye { background: rgba(46,125,50,.12); color: #1B5E20; border-color: transparent; }
.h-recip.echec { background: color-mix(in srgb, var(--danger) 10%, transparent); color: #922B21; border-color: transparent; }
.h-recip.lu { background: rgba(46,125,50,.12); }
.h-recip.en_attente { color: var(--muted); }
.h-photo, .h-video { max-width: 130px; border-radius: 10px; margin-top: 6px; }
.h-voice { margin-top: 6px; }
.h-trash { opacity: .8; }

/* ---------- Paramètres ---------- */
.set-menu { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.set-item {
  display: flex; align-items: center; gap: 13px; width: 100%; text-align: left;
  background: var(--card); border: 1px solid var(--line-soft); border-radius: var(--radius);
  padding: 14px; color: var(--txt); box-shadow: var(--ombre); font-size: .95rem;
}
.set-item:hover { transform: translateY(-1px); border-color: var(--line); }
.set-item > svg { color: var(--accent); flex: 0 0 auto; }
.sm-label { flex: 1; display: flex; flex-direction: column; gap: 1px; }
.sm-label small { color: var(--muted); font-size: .8rem; }
.set-item .chev { color: var(--line); font-size: 1.2rem; }
.set-item.danger-item > svg { color: var(--danger); }
.set-logout { margin-top: 6px; }
.set-page { animation: fadein .22s ease; }
.set-back {
  background: none; border: none; color: var(--accent); font-weight: 700;
  font-size: .95rem; padding: 4px 0 10px; cursor: pointer;
}
.set-back:hover { text-decoration: underline; }
.legal-body { max-height: 60vh; overflow-y: auto; }
.legal-body h3 { font-size: .95rem; margin: 14px 0 4px; }

/* WhatsApp */
.wa-card { background: var(--card); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 14px; box-shadow: var(--ombre); }
.wa-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.wa-txt { flex: 1; min-width: 200px; font-size: .92rem; color: var(--muted); }
.wa-txt strong { color: var(--txt); }
.wa-dot { width: 12px; height: 12px; border-radius: 999px; background: var(--line); flex: 0 0 auto; }
.wa-dot.on { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.wa-dot.wait { background: var(--warn); animation: pulse 1.2s infinite; }
.qr-box { text-align: center; }
.qr-img { width: 280px; max-width: 82vw; background: #fff; padding: 10px; border-radius: 6px; image-rendering: pixelated; border: 1px solid var(--line-soft); }
.qr-steps { text-align: left; margin: 12px auto 0; max-width: 300px; }
.pair-code { font-family: var(--mono); font-size: 1.5rem; letter-spacing: .2em; font-weight: 700; color: var(--accent); }

/* ---------- Modales ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(43,42,36,.45);
  display: grid; place-items: center; padding: 16px; z-index: 20;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  width: 100%; max-width: 460px; background: var(--card);
  border: 1px solid var(--line-soft); border-radius: 16px; box-shadow: var(--ombre); padding: 22px;
  max-height: 90vh; max-height: 90dvh; overflow: auto;
}
.modal.modal-lg { max-width: 640px; }
.modal h2 { margin: 0 0 18px; }
.modal fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin: 0; }
.modal legend { padding: 0 6px; color: var(--muted); font-size: .85rem; font-weight: 600; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }
/* Fiche collaborateur : propre et aérée */
#member-form { display: flex; flex-direction: column; gap: 16px; }
#member-form .field { margin-bottom: 0; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-hint { color: var(--muted); font-size: .8rem; font-weight: 400; }
.field .opt { font-weight: 400; color: var(--muted); }
.modal-actions .primary, .modal-actions .ghost { padding: 12px 20px; }

/* ---------- Toast + visite guidée ---------- */
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 90;
  background: var(--accent); color: #EAF3EC; border: 1px solid var(--accent-2);
  border-radius: 999px; padding: 10px 20px; font-weight: 600; font-size: .92rem;
  box-shadow: var(--ombre); max-width: 90vw;
}
.onb-backdrop { position: fixed; inset: 0; background: rgba(43,42,36,.5); backdrop-filter: blur(2px); z-index: 100; display: grid; place-items: center; padding: 20px; }
.onb-card {
  background: var(--card); border: 1px solid var(--line-soft); border-radius: 16px;
  padding: 26px 22px; max-width: 380px; width: 100%; text-align: center; box-shadow: var(--ombre);
}
.onb-logo { width: 72px; height: 72px; border-radius: 16px; object-fit: cover; margin-bottom: 10px; }
.onb-card h2 { margin: 4px 0 8px; }
.onb-card p { color: var(--muted); font-size: .95rem; margin: 0 0 16px; }
.onb-dots { display: flex; gap: 6px; justify-content: center; margin-bottom: 18px; }
.onb-dots span { width: 8px; height: 8px; border-radius: 999px; background: var(--line); }
.onb-dots span.on { background: var(--accent); width: 22px; }
.onb-actions { display: flex; gap: 10px; }
.onb-actions button { flex: 1; }

/* ---------- Divers hérités (tiroir retiré, classes conservées par sûreté) ---------- */
.drawer-hidden, .topbar { display: none !important; }
.tab.tab-desktop { display: flex; }
.toi-chip { background: var(--terra-pale); color: #A34A1F; border-radius: 999px; padding: 1px 8px; font-size: .74rem; font-weight: 700; }
.chrome-btn { display: inline-flex; }

/* ============================================================
   MOBILE (≤ 720 px) — fidèle au téléphone de la maquette
   ============================================================ */
@media (max-width: 720px) {
  .shell { display: block; }
  .side { position: static; width: auto; height: auto; padding: 0; border: 0; background: transparent; display: block; }
  .side .brand, .side-foot { display: none; }

  /* Entête mobile */
  .m-topbar {
    display: flex; align-items: center; justify-content: center;
    padding: 10px 14px; background: var(--bg-2); border-bottom: 1px solid var(--line);
    position: sticky; top: 0; z-index: 20;
  }
  .m-topbar .brand { font-size: 1rem; }
  .menu-toggle { display: none; }

  /* Barre de navigation FIXE EN BAS (maquette) — toujours collée au bord,
     y compris pendant le rebond de défilement et clavier ouvert */
  .side .tabs {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
    display: flex; flex-direction: row; justify-content: space-around; gap: 0;
    background: var(--bg-2); border-top: 1px solid var(--line);
    padding: 8px 4px calc(8px + env(safe-area-inset-bottom));
    box-shadow: 0 -4px 16px rgba(74,58,42,.12);
    transform: translateZ(0);
  }
  html, body { overscroll-behavior-y: none; }
  .side .tab {
    flex: 1; width: auto; min-width: 0;
    flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    padding: 5px 2px; border-radius: var(--radius); font-size: .65rem; font-weight: 600;
    position: relative;
  }
  .side .tab .t-ico svg { width: 21px; height: 21px; }
  .side .tab .t-lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
  .side .tab.active { background: transparent; color: var(--accent); }
  .side .tab.active::before {
    content: ""; position: absolute; top: -8px; left: 50%; transform: translateX(-50%);
    width: 26px; height: 3px; border-radius: 0 0 3px 3px; background: var(--accent);
  }
  .tab.tab-desktop { display: none !important; }
  .tab-badge { top: 0; right: 18%; }

  /* Contenu : marges réduites + place pour la barre du bas */
  main { max-width: 100%; padding: 12px 12px calc(88px + env(safe-area-inset-bottom)); }
  h1 { font-size: 1.35rem; }
  .page-back { display: inline-block; }

  /* Accueil : tuiles 2×2 comme la maquette */
  .dash-stats { grid-template-columns: repeat(2, 1fr); }

  /* Diffuser */
  .send-bar { flex-direction: column-reverse; align-items: stretch; }
  .send-bar .count { text-align: center; }
  #open-all { width: 100%; padding: 14px; font-size: 1rem; }
  .step-nav { flex-direction: column-reverse; }
  .step-nav .step-next, .step-nav .step-prev { width: 100%; text-align: center; margin-left: 0; }
  .dp-item { font-size: .78rem; }
  .date-row, .tpl-form .date-row { grid-template-columns: 1fr; }

  /* Discussions */
  .thread { max-height: calc(100vh - 320px); max-height: calc(100dvh - 320px); }
  .bubble { max-width: 86%; }
  .bubble-img { max-width: 200px; }
  .thread-head { gap: 8px; }

  /* ===== Conversation ouverte = écran WhatsApp superposé, TOUT est fixe =====
     La conversation recouvre l'application en plein écran : plus aucun
     défilement de page. Trois zones : en-tête cloué en haut, messages
     (seule zone qui défile), barre d'écriture clouée en bas. */
  body.in-thread { overflow: hidden; }
  body.in-thread .side .tabs { display: none; }
  body.in-thread #chats-view {
    position: fixed; inset: 0; z-index: 45;
    background: var(--bg);
    display: flex; flex-direction: column;
  }
  body.in-thread .thread-head {
    position: static; flex: 0 0 auto; margin: 0; border-radius: 0;
    border-left: none; border-right: none; border-top: none;
    padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
  }
  body.in-thread .thread {
    flex: 1 1 auto; min-height: 0; max-height: none; height: auto;
    overflow-y: auto; border: none; box-shadow: none; border-radius: 0;
    background: transparent; padding: 10px 12px; margin: 0;
  }
  body.in-thread .thread-reply {
    position: static; flex: 0 0 auto; margin: 0;
    background: var(--bg-2); border-top: 1px solid var(--line);
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  }
  body.in-thread .emoji-panel { flex: 0 0 auto; margin: 0 10px; max-height: 160px; }
  body.in-thread #recorder-bar { bottom: calc(8px + env(safe-area-inset-bottom)); z-index: 60; }
  #recorder-bar { bottom: calc(84px + env(safe-area-inset-bottom)); left: 8px; right: 8px; }
  .toast { bottom: calc(84px + env(safe-area-inset-bottom)); }

  /* Listes */
  .member { flex-wrap: wrap; }
  .member .m-actions { width: 100%; justify-content: flex-end; }
  .recipients { max-height: 38vh; }
  .search-input, .search-input.wide { max-width: none; width: 100%; }
  .menu-panel { position: fixed; left: 10px; right: 10px; top: auto; margin-top: 6px; min-width: 0; }
  .panel-head .primary, .head-actions button { padding: 8px 12px; font-size: .88rem; }
}

/* ---------- Accessibilité ---------- */
@media (pointer: coarse) {
  .tool-pill, .sub-tab, button.ghost.small, .cat-btn, .type-chip,
  .ch-del, .th-del, .pw-eye, .lien-libre, .page-back, .set-back { min-height: 44px; }
  .menu-btn, .menu-item, .set-item, .cat-row, .chat-row, .seg button, .import-src { min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important; scroll-behavior: auto !important;
  }
}

/* Sélecteur d'indicatif pays dans la fiche collaborateur */
.phone-row { display: flex; gap: 8px; }
.phone-row select { flex: 0 0 46%; min-width: 0; }
.phone-row input { flex: 1; min-width: 0; }

/* Page fiche collaborateur (remplace la fenêtre) */
#member-page { max-width: 560px; animation: fadein .22s ease; }
#member-page h2 { margin: 4px 0 16px; }
#member-page .cat-list { margin-bottom: 0; }

/* Fiche collaborateur : présentation téléphone — Retour bien en haut, titre net */
#member-page .set-back { display: inline-flex; align-items: center; font-size: 1rem; padding: 10px 0 6px; }
#member-page h2 { font-size: 1.45rem; margin: 0 0 18px; }
@media (max-width: 720px) {
  #member-page { max-width: none; }
  #member-page .modal-actions { flex-direction: column-reverse; }
  #member-page .modal-actions button { width: 100%; padding: 14px; }
  #member-page .field-row { grid-template-columns: 1fr 1fr; }
}

/* ============================================================
   COQUILLE NON-DÉFILANTE (mobile) — la fenêtre ne bouge JAMAIS.
   La barre d'adresse du navigateur ne se replie plus, donc la
   barre du bas ne peut physiquement plus tressauter : seule la
   zone de contenu <main> défile, entre l'entête et la barre.
   ============================================================ */
@media (max-width: 720px) {
  html, body { height: 100dvh; overflow: hidden; overscroll-behavior: none; }
  .shell, .content { height: 100dvh; display: flex; flex-direction: column; min-height: 0; }
  .side { flex: 0 0 auto; }
  .m-topbar { flex: 0 0 auto; position: static; }
  main {
    flex: 1 1 auto; min-height: 0; overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: calc(96px + env(safe-area-inset-bottom));
  }
}

/* ---- Bouton WhatsApp par collaborateur (page Collaborateurs, 2026-07-24) ---- */
.m-wa {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; flex-shrink: 0;
  border: 1.5px solid var(--line); border-radius: 10px;
  background: var(--card); color: var(--accent);
}
.m-wa:hover { border-color: var(--accent); }
.m-wa:active { transform: scale(.96); }
.m-wa:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 2px; }
@media (pointer: coarse) { .m-wa { width: 44px; height: 44px; } }

/* ---- Accueil « pouce d'abord » + action dominante (propositions 01+05, 2026-07-24) ---- */
/* Safe-area : l'entête mobile ne passe plus sous l'encoche en PWA plein écran */
@media (max-width: 720px) {
  .m-topbar { padding-top: calc(10px + env(safe-area-inset-top)); }
}
/* CTA vert de la maquette 01 (surcharge la variante terracotta de .dash-action[data-goto=diffuser]) */
#dash-cta.dash-action {
  background: var(--accent); border-color: var(--accent); color: #F7F2EA;
  box-shadow: 0 4px 14px -4px rgba(46,74,59,.5);
  margin: 10px 0 4px; min-height: 56px; width: 100%;
}
#dash-cta.dash-action > svg { background: rgba(255,255,255,.16); color: #F7F2EA; }
#dash-cta.dash-action small { color: rgba(247,242,234,.85); }
#dash-cta.dash-action .chev { color: rgba(247,242,234,.6); }
#dash-cta.dash-action:active { transform: scale(.98); }
/* Tuiles indicateurs = boutons raccourcis, blanches (maquette 01) */
.stat-btn { position: relative; cursor: pointer; text-align: left; }
.stat-btn .chev { position: absolute; top: 10px; right: 12px; color: var(--line); font-size: 1.05rem; line-height: 1; }
.stat-btn:hover { border-color: var(--line); }
.stat-btn:active { transform: scale(.965); }
.stat-btn:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 2px; }
.stat-card.st-unread .stat-n, .stat-card.st-unread .stat-i { color: #9E4A20; }
@media (pointer: coarse) { .stat-btn { min-height: 64px; } }
/* Chip WhatsApp entière cliquable (affichée seulement si non connecté) */
button.wa-chip { cursor: pointer; }
button.wa-chip .chev { color: #B07A54; font-size: 1rem; margin-left: 2px; }
/* Lien vers l'historique (onglet masqué de la barre du bas en mobile) */
.dash-histlink {
  display: block; margin: 14px auto 0; padding: 12px 18px; background: none; border: none;
  color: #9E4A20; font-weight: 600; font-size: .92rem;
  text-decoration: underline; text-underline-offset: 3px;
}
.dash-histlink:active { opacity: .7; }
.dash-histlink:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 2px; border-radius: 8px; }

/* ---- Historique : segments, carte « 1 regard », états (propositions 01+02+03, 2026-07-24) ---- */
#tab-historique .page-back { margin-bottom: 2px; }
#hist-search-row { margin: 2px 0 12px; }
.h-when { color: var(--txt); font-weight: 600; }
.h-body.clamp {
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden; margin-bottom: 2px;
}
.h-more {
  background: none; border: none; padding: 6px 0; margin-bottom: 4px;
  color: #9E4A20; font-weight: 600; font-size: .85rem;
  text-decoration: underline; text-underline-offset: 2px;
}
.h-gauge {
  display: flex; height: 6px; border-radius: 4px; overflow: hidden;
  background: var(--line-soft); margin: 10px 0 8px;
}
.h-gauge i { background: var(--accent); }
.h-gauge em { background: rgba(46,74,59,.35); }
.h-gauge u { background: var(--primary); }
.h-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }
.h-badge {
  font-size: .78rem; font-weight: 700; padding: 3px 11px; border-radius: 999px;
  background: var(--line-soft); color: var(--txt); font-variant-numeric: tabular-nums;
}
.h-badge.lu { background: var(--accent); color: #F7F2EA; }
.h-badge.recu { background: var(--vert-pale); color: var(--accent); }
.h-badge.echec { background: var(--terra-pale); color: #8A3D14; }
.h-fold summary {
  cursor: pointer; color: var(--muted); font-weight: 600; font-size: .85rem;
  padding: 8px 0 4px; list-style: none; display: flex; align-items: center; gap: 6px;
  min-height: 32px;
}
.h-fold summary::-webkit-details-marker { display: none; }
.h-fold summary::before { content: '\203A'; transition: transform .15s; font-size: 1rem; color: var(--muted); }
.h-fold[open] summary::before { transform: rotate(90deg); }
.h-fold .h-recips { padding: 4px 0 2px; }
.hist .h-video { max-width: 100%; }
.hist audio { width: 100%; max-width: 280px; }
.err-band {
  background: var(--terra-pale); border: 1px solid rgba(192,90,40,.4); color: #7C2D12;
  border-radius: var(--radius); padding: 12px 14px;
  display: flex; align-items: center; gap: 10px; justify-content: space-between; flex-wrap: wrap;
}
@media (prefers-reduced-motion: reduce) { .h-fold summary::before { transition: none; } }

/* ---------- Contrôle des doublons (import + saisie de collaborateurs) ---------- */
.imp-warn {
  background: var(--terra-pale); border: 1px solid rgba(192,90,40,.4); color: #7C2D12;
  border-radius: var(--radius); padding: 10px 14px; margin: 0 0 10px;
  font-size: .88rem; line-height: 1.45;
}
.rec-dup {
  display: block; margin-top: 2px;
  color: #8A3D14; font-size: .8rem; font-weight: 600;
}

/* ─────────────────── Journal d'activité (Paramètres → Journal) ─────────── */
.logs-filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 12px; }
.log-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--card); color: var(--txt);
  border: 1.5px solid var(--line); border-radius: 999px;
  padding: 7px 13px; font-weight: 600; font-size: .9rem;
  cursor: pointer; min-height: 38px; line-height: 1;
}
.log-chip.on { background: var(--accent); color: var(--on-accent, #fff); border-color: var(--accent); }
.log-chip .log-n {
  font-variant-numeric: tabular-nums; font-weight: 700; font-size: .78rem;
  background: color-mix(in srgb, var(--muted) 18%, transparent); color: var(--muted);
  border-radius: 999px; padding: 1px 7px; min-width: 18px; text-align: center;
}
.log-chip.on .log-n { background: rgba(255,255,255,.22); color: #fff; }
.logs-tools { display: flex; gap: 8px; margin-bottom: 12px; }
.logs-search {
  flex: 1; background: var(--card); color: var(--txt);
  border: 1.5px solid var(--line); border-radius: var(--radius);
  padding: 10px 13px; font-size: 16px;
}
.logs-list { display: flex; flex-direction: column; gap: 8px; }
.log-row {
  display: flex; align-items: flex-start; gap: 11px;
  background: var(--card); border: 1px solid var(--line-soft);
  border-left: 4px solid var(--line); border-radius: 10px;
  padding: 10px 13px;
}
.log-row .log-ico { font-size: 1.1rem; line-height: 1.4; flex: 0 0 auto; }
.log-row .log-body { flex: 1; min-width: 0; }
.log-row .log-msg { font-weight: 600; color: var(--txt); line-height: 1.35; }
.log-row .log-sub {
  margin-top: 3px; color: var(--muted); font-size: .84rem;
  line-height: 1.35; word-break: break-word;
}
.log-row .log-time {
  flex: 0 0 auto; color: var(--muted); font-size: .8rem;
  font-variant-numeric: tabular-nums; white-space: nowrap; padding-top: 1px;
}
/* Couleur du liseré gauche selon le niveau de gravité */
.log-row.lvl-success { border-left-color: #2E7D46; }
.log-row.lvl-warn { border-left-color: #C77A18; }
.log-row.lvl-error { border-left-color: var(--danger); }
.log-row.lvl-info { border-left-color: var(--accent); }

/* ── Historique : détail par destinataire + causes d'échec (2026-07-28) ── */
.h-causes { font-size: .85rem; font-weight: 600; color: #8A3D14; margin: 2px 0 4px; }
.h-drows { display: flex; flex-direction: column; gap: 2px; padding: 4px 0 2px; }
.h-drow {
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
  font-size: .85rem; padding: 6px 10px; border-radius: 8px; min-height: 32px;
}
.h-drow:nth-child(even) { background: color-mix(in srgb, var(--accent) 4%, transparent); }
.h-drow.ko { background: color-mix(in srgb, var(--danger) 8%, transparent); }
.h-dtick { min-width: 1.6em; text-align: center; }
.h-drow .tick.fail { color: var(--danger); }
.tick.warn { color: var(--warn); font-weight: 700; }
.h-dname { font-weight: 600; }
.h-dphone, .h-dtime { color: var(--muted); font-variant-numeric: tabular-nums; }
.h-dtime { margin-left: auto; }
.h-dcause { flex-basis: 100%; color: #922B21; padding-left: calc(1.6em + 8px); }

/* ---- Badge d'environnement (page de connexion, site de test uniquement) ---- */
.env-badge {
  display: block; width: fit-content; margin: 0 auto 4px;
  background: var(--accent); color: var(--on-accent);
  border-radius: 999px; padding: 4px 14px;
  font-size: .82rem; font-weight: 700; letter-spacing: .04em;
}

/* ===== Discussions : bulles propres + bouton copier (2026-07-29) =====
   Séparateurs de jour, heure seule (plus de date répétée sur chaque bulle),
   bulles groupées par expéditeur, actions discrètes (copier / effacer). */
.thread { gap: 0; overscroll-behavior: contain; }
.day-sep { align-self: center; margin: 14px 0 6px; }
.day-sep span {
  display: inline-block; background: var(--vert-pale); color: var(--accent);
  font-size: .72rem; font-weight: 600; letter-spacing: .03em;
  padding: 4px 12px; border-radius: 999px;
}
.day-sep span::first-letter { text-transform: uppercase; }
.bubble { margin-top: 8px; padding: 8px 11px 4px; box-shadow: 0 1px 1px rgba(46, 74, 59, .07); }
.bubble.suite { margin-top: 2px; }
.bubble.in.suite { border-top-left-radius: 14px; }
.bubble.out.suite { border-top-right-radius: 14px; }
.bubble-meta { margin-top: 1px; gap: 0; font-size: .7rem; }
.bubble.out .bubble-meta { color: #52684A; }
.bubble-time { padding-right: 4px; }
.bubble-act {
  background: none; border: 0; color: inherit; opacity: .45; padding: 0;
  min-width: 32px; min-height: 32px; margin: -6px -2px -4px;
  display: inline-flex; align-items: center; justify-content: center; border-radius: 9px;
}
.bubble-act + .bubble-act { margin-left: 6px; }
.bubble-act svg { width: 14px; height: 14px; }
.bubble-act:hover { opacity: 1; background: rgba(46, 74, 59, .08); }
.bubble-act.bubble-del:hover { color: var(--danger); }
.bubble-act.copied { opacity: 1; color: var(--ok); }
@media (hover: none) { .bubble-act { opacity: .5; } }

/* ===== Discussions : contenu des bulles (2026-07-29, passe 2) =====
   Icônes en pastille, hiérarchie titre/sous-titre, médias bord à bord,
   légendes et traductions clairement séparées du message. */
.md-ic {
  width: 38px; height: 38px; border-radius: 50%; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--vert-pale); color: var(--accent);
}
.md-ic svg { width: 17px; height: 17px; opacity: 1; }
.bubble.out .md-ic { background: rgba(46, 74, 59, .13); }
.md-info { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; }
.md-info strong { font-size: .9rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.md-info small { opacity: .65; font-size: .75rem; }

/* Carte « média à télécharger » et carte document : mêmes proportions */
.media-dl { display: flex; align-items: center; gap: 10px; padding: 2px 0; min-width: 230px; max-width: 100%; }
.media-dl .dl-btn { flex: 0 0 auto; white-space: nowrap; min-height: 36px; }
.bubble-doc {
  display: flex; align-items: center; gap: 10px; min-height: 46px; min-width: 210px;
  background: rgba(46, 74, 59, .06); border-radius: 12px; padding: 6px 12px 6px 6px;
  text-decoration: none; color: inherit; font-size: inherit;
}
.bubble-doc:hover { background: rgba(46, 74, 59, .11); }

/* Vocaux : pastille micro + lecteur compact */
.voice-msg { display: flex; align-items: center; gap: 8px; }
.voice-msg audio { width: 210px; max-width: 56vw; height: 38px; }

/* Photos / vidéos : bord à bord dans la bulle, légende en dessous */
.bubble.has-media { padding: 4px 4px 3px; }
.bubble.has-media .bubble-img, .bubble.has-media .bubble-video { width: 100%; max-width: 300px; border-radius: 12px; }
.bubble-video { background: #000; }
.bubble.has-media .bubble-meta, .bubble.has-media .bubble-caption { padding: 2px 7px 0; }
.bubble-caption { padding-top: 4px; font-size: .93em; }

/* Traduction : bloc rattaché au message, libellé discret (plus d'emoji drapeau) */
.trad-lbl {
  display: block; font-size: .66rem; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase; opacity: .6; margin-bottom: 2px;
}

/* Correctif majeur : pre-wrap était posé sur TOUTE la bulle, donc les retours
   à la ligne du gabarit HTML (indentation du code) créaient de grands vides
   au-dessus et en dessous du texte. Il ne s'applique qu'au texte du message. */
.bubble { white-space: normal; }
.bubble-body { white-space: pre-wrap; }

/* Bulles reçues en blanc : elles se détachaient mal du fond crème de la page
   (même famille de teinte). Blanc = lisibilité immédiate, comme WhatsApp. */
.bubble.in { background: var(--card); border-color: rgba(46, 74, 59, .10); }
/* Bulle média : sa largeur épouse la photo, la légende reste alignée dessous */
.bubble.has-media { max-width: min(86%, 308px); }
.bubble.has-media .bubble-img, .bubble.has-media .bubble-video { max-width: none; }

/* Zone d'écriture multi-lignes des discussions : le texte passe à la ligne et
   la zone grandit (jusqu'à ~5 lignes) au lieu de défiler vers la droite. */
.thread-reply textarea {
  flex: 1; min-width: 160px; resize: none; overflow-y: auto;
  border-radius: 20px; padding: 11px 16px; max-height: 132px;
  font: inherit; font-size: 16px; line-height: 1.4;
}

/* Bouton « Traduire » : pastille compacte DANS la bulle, ne déborde plus */
.bubble .trad-btn {
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: 6px; padding: 5px 12px; max-width: 100%;
  background: var(--vert-pale); color: var(--accent);
  border: none; border-radius: 999px;
  font-size: .8rem; font-weight: 600; min-height: 32px;
}
.bubble .trad-btn:hover { background: color-mix(in srgb, var(--accent) 18%, transparent); }
.bubble .trad-btn svg { width: 13px; height: 13px; flex: 0 0 auto; }
/* Bloc traduction : jamais plus large que la bulle, coupe les mots très longs */
.bubble .trad-out { max-width: 100%; overflow-wrap: anywhere; box-sizing: border-box; }

/* Drapeaux de traduction sous les messages reçus : 🇫🇷 🇬🇧 🇲🇦 */
.trad-row { display: flex; gap: 6px; margin-top: 6px; }
.trad-flag {
  min-width: 38px; min-height: 32px; padding: 2px 9px; border-radius: 999px;
  border: 1px solid rgba(46, 74, 59, .18); background: var(--card);
  font-size: 1.05rem; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
}
.trad-flag.on { background: var(--vert-pale); border-color: var(--accent); }
.trad-flag:disabled { opacity: .5; }
.trad-flag:hover { border-color: var(--accent); }
.bubble .trad-out[dir="rtl"] { text-align: right; }
.bubble .trad-out[dir="rtl"] .trad-lbl { text-align: right; }

/* Libellé devant les drapeaux de traduction */
.trad-cap {
  align-self: center; margin-right: 2px;
  font-size: .68rem; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; opacity: .55;
}

/* Visionneuse d'image intégrée (plein écran dans le logiciel) */
#lightbox {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(20, 24, 20, .92);
  display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 12px;
  padding: 16px; padding-top: calc(16px + env(safe-area-inset-top));
}
#lightbox[hidden] { display: none; }
#lb-img { max-width: 96vw; max-height: 82vh; max-height: 82dvh; border-radius: 10px; object-fit: contain; }
#lb-close {
  position: absolute; top: calc(10px + env(safe-area-inset-top)); right: 12px;
  width: 44px; height: 44px; border-radius: 50%; border: none;
  background: rgba(255, 255, 255, .14); color: #fff; font-size: 1.25rem; line-height: 1;
}
#lb-close:hover { background: rgba(255, 255, 255, .26); }
#lb-open {
  color: #fff; opacity: .8; font-size: .85rem; text-decoration: underline;
  min-height: 44px; display: inline-flex; align-items: center;
}

/* Drapeaux SVG (remplacent les drapeaux emoji, absents sur certains téléphones) */
.trad-flag .flag { width: 23px; height: 15px; border-radius: 2.5px; display: block; box-shadow: 0 0 0 1px rgba(0, 0, 0, .08); }
.trad-lbl .flag { width: 17px; height: 11px; border-radius: 2px; display: inline-block; vertical-align: -1px; margin-left: 3px; }

/* « Traduction » plus foncé (demande Lucas : libellés trop pâles) */
.trad-cap { opacity: 1; color: var(--accent); font-weight: 700; }
.bubble .trad-lbl { opacity: 1; color: var(--accent); }

/* Menu « Traduire en » avant envoi : rangée horizontale au-dessus de la barre */
.attach-menu.trad-send { flex-direction: row; align-items: center; gap: 8px; padding: 10px 14px; min-width: 0; }
.ao-trad { background: var(--accent); }

/* Bouton COPIER mis en valeur sur chaque message (demande Lucas) :
   pastille verte bien visible, coche de confirmation après copie. */
.bubble-act[data-copy-msg] {
  opacity: 1; color: var(--accent); background: var(--vert-pale);
  border-radius: 50%; min-width: 30px; min-height: 30px;
  margin: -4px 0 -3px 6px;
}
.bubble-act[data-copy-msg] svg { width: 15px; height: 15px; }
.bubble-act[data-copy-msg]:hover { background: color-mix(in srgb, var(--accent) 20%, transparent); }
.bubble.out .bubble-act[data-copy-msg] { background: rgba(46, 74, 59, .14); }
.bubble-act[data-copy-msg].copied { background: var(--ok); color: #fff; }
@media (hover: none) { .bubble-act[data-copy-msg] { opacity: 1; } }

/* Traduction mise en valeur (comme le bouton copier) : drapeaux plus grands
   sur fond vert pâle, drapeau actif bien marqué, copie de la traduction. */
.trad-flag { background: var(--vert-pale); border-color: rgba(46, 74, 59, .22); min-width: 44px; min-height: 36px; }
.trad-flag .flag { width: 27px; height: 18px; }
.trad-flag.on { background: #FFFFFF; border: 2px solid var(--accent); }
.trad-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 2px; }
.trad-head .trad-lbl { margin-bottom: 0; }
.bubble-act.trad-copy {
  opacity: 1; color: var(--accent); background: rgba(46, 74, 59, .10);
  border-radius: 50%; min-width: 28px; min-height: 28px; margin: 0; flex: 0 0 auto;
}
.bubble-act.trad-copy svg { width: 14px; height: 14px; }
.bubble-act.trad-copy.copied { background: var(--ok); color: #fff; }
.trad-out[dir="rtl"] .trad-head { flex-direction: row-reverse; }

/* ===== Conversation ouverte sur ORDINATEUR : écran fixe façon WhatsApp Web =====
   (le mobile a déjà son écran superposé plus haut). En-tête en haut, messages
   qui défilent au milieu, barre d'écriture collée en bas : écrire plusieurs
   lignes ne fait plus descendre la page. */
body.in-thread #tab-discussions > h1,
body.in-thread #disc-tabs,
body.in-thread #pane-chats > .hint { display: none; }
@media (min-width: 721px) {
  body.in-thread main { padding-bottom: 16px; }
  body.in-thread #chats-view {
    display: flex; flex-direction: column;
    height: calc(100vh - 40px); height: calc(100dvh - 40px);
    min-height: 0;
  }
  body.in-thread #chats-view .thread-head { flex: 0 0 auto; }
  body.in-thread #chats-view .thread {
    flex: 1 1 auto; min-height: 0; max-height: none;
  }
  body.in-thread #chats-view .emoji-panel { flex: 0 0 auto; max-height: 180px; overflow-y: auto; }
  body.in-thread #chats-view .thread-reply { flex: 0 0 auto; }
}

/* Jetons API (Paramètres → Mon compte) */
.tok-title { margin: 26px 0 4px; border-top: 1px solid var(--line-soft); padding-top: 18px; }
.tok-list { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.tok-row {
  display: flex; align-items: center; gap: 10px; justify-content: space-between;
  background: var(--bg-2); border: 1px solid var(--line-soft); border-radius: 10px; padding: 10px 12px;
}
.tok-main { display: flex; flex-direction: column; min-width: 0; }
.tok-main small { color: var(--muted); font-size: .78rem; }
.tok-create { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.tok-create input { flex: 1; min-width: 180px; }
.tok-new {
  margin-top: 12px; background: var(--vert-pale); border: 1px solid rgba(46, 74, 59, .3);
  border-radius: 10px; padding: 12px 14px; font-size: .9rem;
}
.tok-value { display: flex; align-items: center; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
.tok-value code { word-break: break-all; white-space: normal; }

/* ---------- Partage de contacts entre comptes (2026-08-07) ---------- */
#share-inbox { display: grid; gap: 8px; margin: 0 0 12px; }
.share-card {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--card); border: 1.5px solid var(--line); border-left: 4px solid var(--primary);
  border-radius: var(--radius); padding: 10px 12px; flex-wrap: wrap;
}
.share-card .sc-main { font-size: .92rem; }
.share-card .sc-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.share-card.out { border-left-color: var(--line); color: var(--muted); }
.share-card.out.accepted { border-left-color: var(--accent); }
.share-card.out.refused { border-left-color: #A33333; }

/* ---------- Bulles de notification typées (2026-08-07) ---------- */
.toast { display: inline-flex; align-items: center; gap: 8px; }
.toast .toast-ic { display: inline-flex; flex: 0 0 auto; }
.toast-warn { background: var(--primary); border-color: #A34A1F; color: #fff; }
.toast-err { background: #A33333; border-color: #7E2626; color: #fff; }
