/* AVIN Messenger inside the CRM — «کشوی پیام» (3 Dec 2026). Tokens from avin3.css («آوین ۳»): brand yellow only for the
   main action. Owner's rule: nothing ever scrolls sideways — rows wrap or cut with «…». */
:root { --mx-rail: 232px; }
@media (max-width: 1200px) and (min-width: 761px) { :root { --mx-rail: 92px; } }
#mx-root { position: relative; z-index: 70; }
#mx-root *, .mx-demo * { min-width: 0; }
.mx-pf { width: 16px; height: 16px; border-radius: 4px; object-fit: cover; flex: none; vertical-align: middle; }

/* ---- the tile above the clock (dark rail) ---- */
.side .mx-tile { display: grid; gap: 6px; margin: var(--space-3) var(--space-3) 0; padding: 10px 12px; text-align: start; width: auto;
  background: #26282c; border: 1px solid #3a3c41; border-radius: var(--radius-lg); color: var(--rail-ink); font: inherit; cursor: pointer; }
.side .mx-tile:hover, .side .mx-tile.on { border-color: var(--brand); }
.side .mx-tile.on { box-shadow: inset 0 0 0 1px var(--brand); }
.mx-tile-h { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.mx-tile-h .i { width: 18px; height: 18px; color: var(--brand); }
.mx-tile-h b { flex: 1; font-weight: 800; }
.mx-n { display: inline-grid; place-items: center; flex: none; min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--radius-full);
  background: var(--brand); color: var(--on-brand); font-style: normal; font-size: 11.5px; font-weight: 800; }
.mx-tile-pf { display: flex; gap: 6px; }
.mx-tile-pf span { position: relative; opacity: .55; }
.mx-tile-pf span.hot { opacity: 1; }
.mx-tile-pf span.hot::after { content: ""; position: absolute; top: -3px; inset-inline-start: -3px; width: 7px; height: 7px; border-radius: 50%; background: var(--brand); box-shadow: 0 0 0 2px #26282c; }
.mx-tile-pf .mx-pf { width: 18px; height: 18px; }
.mx-tile-s { font-size: 12px; color: var(--rail-muted); }
@media (max-width: 1200px) and (min-width: 761px) {
  .side .mx-tile { margin: var(--space-2); padding: 8px 4px; justify-items: center; }
  .mx-tile-h { flex-direction: column; gap: 2px; font-size: 11.5px; position: relative; }
  .mx-tile-h .mx-n { position: absolute; top: -6px; inset-inline-start: -2px; }
  .mx-tile-pf, .mx-tile-s { display: none; }
}

/* ---- small marks ---- */
.mx-sla { display: inline-flex; align-items: center; gap: 3px; padding: 1px 8px; border-radius: var(--radius-full); font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.mx-sla .i { width: 13px; height: 13px; }
.mx-sla.ok { background: var(--success-soft); color: var(--success); }
.mx-sla.soon { background: var(--warning-soft); color: var(--warning); }
.mx-sla.late { background: var(--danger-soft); color: var(--danger); }
.mx-st { font-size: 11.5px; font-weight: 700; padding: 1px 8px; border-radius: var(--radius-full); white-space: nowrap; }
.mx-st.ok { background: var(--success-soft); color: var(--success); } .mx-st.draft { background: var(--surface-2); color: var(--muted); }
.mx-mu { color: var(--muted); font-size: 13px; line-height: 21px; margin: 0; }
.mx-empty { color: var(--muted); padding: var(--space-6) var(--space-4); text-align: center; margin: 0; }
.mx-role { font-size: 11.5px; padding: 1px 8px; border-radius: var(--radius-full); background: var(--surface-2); color: var(--muted); font-weight: 700; white-space: nowrap; }
.mx-who { padding: 0 7px; border-radius: var(--radius-full); border: 1px solid var(--line); font-size: 11px; font-weight: 700; color: var(--ink); line-height: 18px; white-space: nowrap; }
.mx-who.own { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.mx-hid { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; font-weight: 700; color: var(--danger); white-space: nowrap; }
.mx-hid .i, .mx-pinned .i { width: 13px; height: 13px; }
.mx-pinned { display: inline-flex; color: var(--muted); }
.mx-ib { display: inline-grid; place-items: center; flex: none; width: 36px; height: 36px; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--ink); cursor: pointer; }
.mx-ib:hover { background: var(--surface-2); }
.mx-ib .i { width: 20px; height: 20px; }

/* ---- drawer ---- */
.mx-scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 70; }
.mx-scrim.clear { background: transparent; z-index: 73; }
.mx-drawer { position: fixed; z-index: 71; top: 0; bottom: 0; inset-inline-start: var(--mx-rail); width: min(480px, calc(100vw - var(--mx-rail))); background: var(--surface); color: var(--ink);
  display: flex; flex-direction: column; overflow: hidden; border-inline-end: 1px solid var(--line); box-shadow: var(--shadow-overlay); }
.mx-drawer.enter { animation: mx-in .18s ease-out; }
@keyframes mx-in { from { transform: translateX(24px); opacity: 0; } }
@keyframes mx-up { from { transform: translateY(16px); opacity: 0; } }
.mx-ph { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--line); min-height: 56px; }
.mx-ph > b { display: flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 800; flex: 1; }
.mx-ph > b .i { width: 20px; height: 20px; }
.mx-find { display: flex; align-items: center; gap: 6px; margin: var(--space-3) var(--space-4) 0; padding: 0 12px; height: 38px; border: 1px solid var(--control-border); border-radius: var(--radius-full); }
.mx-find input { flex: 1; border: 0; background: transparent; font: inherit; font-size: 13.5px; color: var(--ink); outline: none; }
.mx-find .i { width: 16px; height: 16px; color: var(--muted); flex: none; }
.mx-seg { display: flex; gap: 4px; padding: var(--space-2) var(--space-4); flex-wrap: wrap; }
.mx-seg button { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: var(--radius-full); border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.mx-seg button.on { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.mx-seg button b { min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--radius-full); background: var(--brand); color: var(--on-brand); font-size: 11px; display: inline-grid; place-items: center; }
#mx-listwrap { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* ---- list ---- */
.mx-list { flex: 1; overflow-y: auto; overflow-x: hidden; }
.mx-lh { margin: 0; padding: var(--space-3) var(--space-4) 4px; font-size: 12px; color: var(--muted); }
.mx-row { display: flex; align-items: flex-start; border-bottom: 1px solid var(--line); position: relative; }
.mx-row:hover, .mx-row:focus-within { background: var(--surface-2); }
.mx-row.on { background: var(--brand-soft); }
.mx-row-main, button.mx-row { flex: 1; display: flex; gap: 10px; align-items: flex-start; padding: 10px var(--space-4); border: 0; background: transparent; color: inherit; font: inherit; text-align: start; cursor: pointer; }
button.mx-row { width: 100%; border-bottom: 1px solid var(--line); align-items: center; }
.mx-row-main { padding-inline-end: 4px; }
.mx-row > .mx-more { margin: 8px 6px 0 0; opacity: .45; }
.mx-row:hover > .mx-more, .mx-row > .mx-more:focus-visible { opacity: 1; }
.mx-row.un .mx-row-t b { font-weight: 900; }
.mx-av { position: relative; flex: none; width: 40px; height: 40px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--line); display: grid; place-items: center; font-weight: 800; }
.mx-av-pf { position: absolute; bottom: -2px; inset-inline-start: -2px; width: 16px; height: 16px; border-radius: 50%; box-shadow: 0 0 0 2px var(--surface); }
.mx-row-b { flex: 1; display: grid; gap: 3px; }
.mx-row-t { display: flex; gap: 6px; align-items: center; }
.mx-row-t b { flex: 1; font-weight: 700; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mx-row-t time { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.mx-row-m { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mx-row-w { display: flex; gap: 5px; align-items: center; flex-wrap: wrap; font-size: 11.5px; color: var(--muted); }
.mx-row-main > .mx-n { margin-top: 20px; }
.mx-go { display: inline-flex; align-items: center; gap: 4px; flex: none; padding: 0 10px; height: 30px; border-radius: var(--radius-full); border: 1px solid var(--control-border); font-size: 12.5px; font-weight: 700; }
.mx-go .i { width: 15px; height: 15px; }

/* ---- conversation ---- */
.mx-thread { display: flex; flex-direction: column; min-height: 0; flex: 1; position: relative; }
.mx-thread.drop::after { content: "فایل را همین‌جا رها کنید"; position: absolute; inset: 8px; z-index: 5; display: grid; place-items: center; border: 2px dashed var(--ink); border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--surface) 88%, transparent); font-weight: 800; pointer-events: none; }
.mx-th { display: flex; align-items: center; gap: 4px; padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--line); }
.mx-th-n { flex: 1; display: grid; padding-inline-start: 4px; }
.mx-th-n b { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mx-th-n small { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mx-people { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; padding: 8px var(--space-4) 0; }
.mx-pp { display: inline-flex; align-items: center; gap: 5px; min-height: 26px; padding: 0 9px; border-radius: var(--radius-full); border: 1px solid var(--line); font-size: 12.5px; font-weight: 700; }
.mx-pp small { font-weight: 500; color: var(--muted); font-size: 11.5px; }
.mx-pp.own { background: var(--ink); border-color: var(--ink); color: var(--surface); } .mx-pp.own small { color: var(--surface); opacity: .75; }
.mx-pp button { display: inline-grid; place-items: center; border: 0; background: transparent; color: var(--danger); font: inherit; font-size: 11.5px; font-weight: 700; cursor: pointer; padding: 0 2px; min-height: 24px; }
.mx-pp button .i { width: 14px; height: 14px; }
.mx-add { display: inline-flex; align-items: center; gap: 4px; min-height: 26px; padding: 0 9px; border-radius: var(--radius-full); border: 1px dashed var(--control-border); background: transparent; color: var(--ink); font: inherit; font-size: 12.5px; cursor: pointer; }
.mx-add .i { width: 14px; height: 14px; }
.mx-via { display: flex; gap: 6px; padding: 8px var(--space-4); border-bottom: 1px solid var(--line); flex-wrap: wrap; align-items: center; }
.mx-via::before { content: "ارسال با"; font-size: 12px; color: var(--muted); margin-inline-end: 2px; }
.mx-via button { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border-radius: var(--radius-full); border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-size: 12.5px; cursor: pointer; }
.mx-via button.on { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); font-weight: 700; }
.mx-fresh { margin: var(--space-3) var(--space-4) 0; padding: var(--space-3); border-radius: var(--radius-md); background: var(--brand-soft); display: grid; gap: 6px; font-size: 13.5px; }
.mx-fresh div { display: flex; gap: 6px; flex-wrap: wrap; }
.mx-pins { display: grid; gap: 1px; background: var(--line); border-bottom: 1px solid var(--line); max-height: 112px; overflow-y: auto; overflow-x: hidden; }
.mx-pins > div { display: flex; align-items: center; gap: 8px; padding: 4px var(--space-4); background: var(--surface-2); }
.mx-pins > div > .i { width: 15px; height: 15px; flex: none; color: var(--muted); }
.mx-pins p { flex: 1; margin: 0; font-size: 13px; line-height: 20px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.mx-pins small { color: var(--muted); font-size: 11.5px; margin-inline-start: 6px; }
.mx-pins .mx-ib { width: 28px; height: 28px; } .mx-pins .mx-ib .i { width: 15px; height: 15px; }
.mx-msgs { flex: 1; min-height: 100px; overflow-y: auto; overflow-x: hidden; padding: var(--space-3) var(--space-3); display: flex; flex-direction: column; gap: 6px; background: var(--ground); }
.mx-day { display: flex; justify-content: center; margin: 6px 0 2px; }
.mx-day span { padding: 1px 12px; border-radius: var(--radius-full); background: var(--surface); border: 1px solid var(--line); font-size: 11.5px; font-weight: 700; color: var(--muted); }
.mx-sys { align-self: center; font-size: 11.5px; color: var(--muted); text-align: center; }
.mx-m { display: flex; gap: 4px; align-items: flex-end; max-width: 92%; }
.mx-m.in { align-self: flex-start; }
.mx-m.out, .mx-m.inote { align-self: flex-end; flex-direction: row-reverse; }
.mx-m.hid .mx-b { opacity: .6; border-style: dashed; }
.mx-m > .mx-more { width: 28px; height: 28px; opacity: 0; align-self: center; }
.mx-m:hover > .mx-more, .mx-m > .mx-more:focus-visible { opacity: 1; }
.mx-src { margin-bottom: 4px; }
.mx-b { padding: 8px 12px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); display: grid; gap: 4px; }
.mx-m.out .mx-b { background: var(--brand-soft); border-color: transparent; }
.mx-m.inote .mx-b { background: var(--surface); border: 1px dashed var(--control-border); }
.mx-note-h, .mx-note-l { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 800; color: var(--info); }
.mx-note-h .i, .mx-note-l .i { width: 13px; height: 13px; }
.mx-b p { margin: 0; font-size: 14px; line-height: 23px; white-space: pre-wrap; overflow-wrap: anywhere; }
.mx-b small { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 11px; color: var(--muted); }
.mx-by { padding: 0 7px; border-radius: var(--radius-full); background: var(--ink); color: var(--surface); font-weight: 700; line-height: 17px; }
.mx-auto { padding: 0 7px; border-radius: var(--radius-full); border: 1px solid var(--control-border); font-weight: 700; line-height: 16px; }
.mx-demo-t { font-style: italic; }
.mx-at { font-weight: 800; color: var(--info); }
.mx-re { padding: 2px 8px; border-inline-start: 3px solid var(--control-border); font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mx-img { max-width: 100%; max-height: 220px; border-radius: 8px; display: block; }
.mx-file, .mx-card { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--line); font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
.mx-file .i, .mx-card .i { width: 18px; height: 18px; flex: none; }
.mx-card span { display: grid; } .mx-card small { font-weight: 500; }

/* ---- writing: suggestions (one row, never scrolls), shortcut buttons, the box ---- */
.mx-comp { display: grid; gap: 6px; padding: var(--space-2) var(--space-3) var(--space-3); border-top: 1px solid var(--line); background: var(--surface); }
.mx-replying, .mx-pend { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.mx-replying { padding: 2px 8px; border-inline-start: 3px solid var(--ink); }
.mx-replying span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mx-replying .i { width: 15px; height: 15px; flex: none; } .mx-replying .mx-ib { width: 26px; height: 26px; }
.mx-pend span { display: inline-flex; align-items: center; gap: 5px; max-width: 100%; padding: 3px 8px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); }
.mx-pend img { width: 28px; height: 28px; object-fit: cover; border-radius: 4px; } .mx-pend .i { width: 16px; height: 16px; }
.mx-pend bdi { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 160px; }
.mx-pend button { display: inline-grid; border: 0; background: transparent; color: var(--danger); cursor: pointer; padding: 0; } .mx-pend button .i { width: 14px; height: 14px; }
.mx-sug { display: flex; gap: 6px; align-items: center; height: 32px; overflow: hidden; }
.mx-sug:empty { height: 0; }
.mx-sug button { flex: 0 1 auto; height: 30px; padding: 0 12px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); font: inherit; font-size: 13.5px; font-weight: 600;
  cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mx-sug button.on { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.mx-sug button.phrase { flex: 1 1 0; font-weight: 500; }
.mx-sug button.mine { border-color: var(--control-border); }
.mx-note-l { flex: 1 1 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mx-comp.isnote .mx-line textarea { border-style: dashed; border-color: var(--info); }
.mx-tools { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.mx-tools > button { display: inline-flex; align-items: center; gap: 5px; height: 30px; padding: 0 9px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; }
.mx-tools > button:hover { border-color: var(--ink); }
.mx-tools > button .i { width: 16px; height: 16px; }
.mx-keys { position: relative; margin-inline-start: auto; }
.mx-keys .pop { display: none; top: auto !important; bottom: 26px; inset-inline-start: auto !important; inset-inline-end: 0; }
.mx-keys:hover .pop, .mx-keys:focus-within .pop { display: block; }
.mx-line { display: flex; align-items: flex-end; gap: 6px; }
.mx-line textarea { flex: 1; overflow-y: hidden; min-height: 42px; max-height: 132px; resize: none; padding: 9px 14px; border-radius: 20px; border: 1px solid var(--control-border); background: var(--surface); color: var(--ink); font: inherit; font-size: 14.5px; line-height: 23px; }
.mx-send { flex: none; width: 42px; height: 42px; padding: 0; border: 0; border-radius: 50%; display: grid; place-items: center; background: var(--brand); color: var(--on-brand); cursor: pointer; }
.mx-send:hover { background: var(--brand-strong); }
.mx-send .i { width: 18px; height: 18px; transform: scaleX(-1); }

/* ---- pickers (invoice, pre-invoice, pay link, product, pinned note): a sheet over the lower part of the conversation ---- */
.mx-sheet { position: absolute; z-index: 6; inset-inline: 0; bottom: 0; max-height: 72%; display: flex; flex-direction: column; background: var(--surface); border-top: 1px solid var(--ink);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0; box-shadow: 0 -14px 30px -18px rgba(0,0,0,.4); }
.mx-sheet.enter { animation: mx-up .16s ease-out; }
.mx-sheet > header { display: flex; align-items: center; padding: var(--space-2) var(--space-3) 0 var(--space-4); }
.mx-sheet > header b { flex: 1; font-size: 15px; }
.mx-sheet .mx-find { margin-top: var(--space-2); }
.mx-sheet .mx-chk, .mx-sheet > .mx-mu { margin: var(--space-2) var(--space-4) 0; }
.mx-sheet-l { overflow-y: auto; overflow-x: hidden; padding: var(--space-2) var(--space-3) var(--space-3); display: grid; gap: 6px; }
.mx-sheet-l textarea { width: 100%; padding: 10px 12px; border-radius: var(--radius-md); border: 1px solid var(--control-border); background: var(--surface); color: var(--ink); font: inherit; font-size: 14px; resize: vertical; }
.mx-doc { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius-md); border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; text-align: start; cursor: pointer; }
.mx-doc:hover { border-color: var(--ink); }
.mx-doc > span:first-child { flex: 1; display: grid; gap: 2px; }
.mx-doc b { font-size: 14px; overflow-wrap: anywhere; } .mx-doc small { font-size: 12px; color: var(--muted); }
.mx-doc-e { display: grid; justify-items: end; gap: 3px; flex: none; }
.mx-chk { display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; cursor: pointer; }
.mx-chk .i { width: 18px; height: 18px; }

/* ---- right-click menu ---- */
.mx-menu { position: fixed; z-index: 74; width: 240px; padding: 6px; display: grid; gap: 1px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); box-shadow: var(--shadow-overlay); }
.mx-menu button { display: flex; align-items: center; gap: 10px; min-height: 38px; padding: 0 10px; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--ink); font: inherit; font-size: 13.5px; text-align: start; cursor: pointer; }
.mx-menu button:hover, .mx-menu button:focus-visible { background: var(--surface-2); }
.mx-menu button .i { width: 17px; height: 17px; flex: none; color: var(--muted); }

/* ---- notifications: rise next to the tile, just above the clock ---- */
.mx-toasts { position: fixed; z-index: 72; bottom: 16px; inset-inline-start: calc(var(--mx-rail) + 12px); display: grid; gap: 8px; width: min(360px, calc(100vw - 24px)); pointer-events: none; }
.mx-toasts.beside { inset-inline-start: calc(var(--mx-rail) + min(480px, 100vw - var(--mx-rail)) + 16px); width: min(360px, calc(100vw - var(--mx-rail) - 480px - 32px)); }
.mx-toast { pointer-events: auto; display: grid; grid-template-columns: auto 1fr; gap: 6px 10px; padding: 12px; border-radius: var(--radius-lg); background: var(--rail); color: var(--rail-ink);
  box-shadow: 0 14px 32px -12px rgba(0,0,0,.55); animation: mx-up .22s ease-out; }
.mx-toast .mx-pf { width: 28px; height: 28px; border-radius: 8px; }
.mx-toast > span { display: grid; gap: 1px; }
.mx-toast small { color: var(--rail-muted); font-size: 11.5px; }
.mx-toast p { margin: 4px 0 0; font-size: 13.5px; line-height: 21px; overflow-wrap: anywhere; }
.mx-toast > div { grid-column: 2; display: flex; gap: 6px; }
.mx-toast .btn.ghost { color: var(--rail-ink); }

/* ---- phone: no rail; a round button above the bottom bar, the drawer full screen ---- */
.mx-fab { display: none; }
@media (max-width: 760px) {
  :root { --mx-rail: 0px; }
  .mx-fab { display: grid; place-items: center; position: fixed; z-index: 69; bottom: calc(76px + env(safe-area-inset-bottom)); inset-inline-end: 16px; width: 52px; height: 52px;
    border-radius: 50%; border: 0; background: var(--rail); color: var(--brand); box-shadow: 0 10px 24px -10px rgba(0,0,0,.6); cursor: pointer; }
  .mx-fab .i { width: 24px; height: 24px; }
  .mx-fab b { position: absolute; top: -2px; inset-inline-start: -2px; min-width: 20px; height: 20px; border-radius: var(--radius-full); background: var(--brand); color: var(--on-brand); font-size: 11px; display: grid; place-items: center; }
  .mx-fab b[hidden] { display: none; }
  .mx-drawer { inset: 0; width: 100%; border: 0; }
  .mx-toasts { inset-inline: 12px; bottom: calc(140px + env(safe-area-inset-bottom)); width: auto; }
  .mx-toasts.beside { display: none; }
  .mx-row > .mx-more, .mx-m > .mx-more { opacity: .6; }
  .mx-tools > button span { display: none; }
  .mx-tools > button { width: 40px; height: 36px; justify-content: center; padding: 0; }
}
@media (max-width: 900px) and (min-width: 761px) { .mx-toasts.beside { display: none; } }

/* ---- real conversations: states, files, small pieces ---- */
.mx-fab[hidden] { display: none !important; }
.mx-pf-t { display: inline-grid; place-items: center; background: var(--ink); color: var(--surface); font-size: 10px; font-weight: 800; }
.mx-scope { display: inline-flex; margin-inline-start: auto; border: 1px solid var(--line); border-radius: var(--radius-full); overflow: hidden; }
.mx-seg .mx-scope button { border: 0; border-radius: 0; height: 30px; }
.mx-by.in { background: var(--surface-2); color: var(--ink); border: 1px solid var(--line); }
.mx-state { font-weight: 700; } .mx-state.failed { color: var(--danger); } .mx-state.held { color: var(--warning); }
.mx-ticks { color: var(--info); font-weight: 800; letter-spacing: -2px; }
.mx-m.del .mx-b p { text-decoration: line-through; color: var(--muted); }
.mx-older { align-self: center; height: 30px; padding: 0 14px; border-radius: var(--radius-full); border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-size: 12.5px; cursor: pointer; }
.mx-hint { margin: 0; font-size: 12px; color: var(--warning); }
.mx-get { margin-inline-start: auto; height: 26px; padding: 0 10px; border-radius: var(--radius-full); border: 1px solid var(--control-border); background: var(--surface); color: var(--ink); font: inherit; font-size: 12px; cursor: pointer; }
a.mx-file { color: inherit; text-decoration: none; } a.mx-file:hover { border-color: var(--ink); }
.mx-file small { margin-inline-start: auto; color: var(--muted); font-weight: 500; }
.mx-audio { width: 100%; max-width: 260px; height: 36px; }
.mx-mnote { display: flex; align-items: center; gap: 5px; font-size: 12.5px; padding: 3px 8px; border-radius: var(--radius-sm); background: var(--surface-2); overflow-wrap: anywhere; }
.mx-mnote .i { width: 13px; height: 13px; flex: none; } .mx-mnote small { margin-inline-start: auto; color: var(--muted); }
.mx-amount { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.mx-amount input { height: 40px; padding: 0 12px; border-radius: var(--radius-md); border: 1px solid var(--control-border); background: var(--surface); color: var(--ink); font: inherit; font-size: 15px; }
.mx-keys > button { width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--control-border); background: var(--surface); color: var(--muted); font: inherit; font-size: 12px; font-weight: 800; cursor: pointer; }
.mx-keys .pop { position: absolute; z-index: 8; width: min(300px, 78vw); padding: var(--space-3); border-radius: var(--radius-md); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-overlay);
  font-size: 12.5px; line-height: 21px; color: var(--ink); text-align: start; }

/* ---- Settings ← پیام‌رسان: AVIN's messenger accounts and signing them in ---- */
.mxa { display: grid; gap: var(--space-4); }
.mxa-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3) var(--space-6); }
.mxa-sum { display: grid; } .mxa-sum b { font-size: 26px; line-height: 1.1; } .mxa-sum span { color: var(--muted); font-size: 13px; }
.mxa-phone { display: grid; gap: 4px; margin-inline-start: auto; min-width: min(100%, 300px); }
.mxa-phone label { font-size: 12.5px; font-weight: 700; color: var(--muted); }
.mxa-phone div { display: flex; gap: 6px; } .mxa-phone input { flex: 1; min-width: 0; }
.mxa-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); gap: var(--space-3); }
.mxa-card { display: grid; gap: var(--space-2); align-content: start; border-inline-start: 4px solid var(--line); }
.mxa-card.online { border-inline-start-color: var(--success); }
.mxa-card.needs_login, .mxa-card.limited { border-inline-start-color: var(--warning); }
.mxa-card.offline { border-inline-start-color: var(--danger); }
.mxa-card > header { display: flex; align-items: center; gap: 10px; }
.mxa-card h3 { margin: 0; flex: 1; font-size: 16px; }
.mxa-icon { width: 30px !important; height: 30px !important; border-radius: 8px !important; }
.mxa-meta { margin: 0; font-size: 12.5px; color: var(--muted); line-height: 20px; }
.mxa-err { margin: 0; font-size: 12.5px; color: var(--danger); overflow-wrap: anywhere; }
.mxa-act { display: flex; flex-wrap: wrap; gap: 6px; } .mxa-act p { margin: 0; }
.mxa-switch { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.mxa-log { list-style: none; margin: 0; padding: 0; display: grid; }
.mxa-log li { display: grid; grid-template-columns: minmax(90px, auto) minmax(0, 1fr) minmax(0, 1.4fr); gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.mxa-log time { color: var(--muted); white-space: nowrap; }
@media (max-width: 560px) { .mxa-log li { grid-template-columns: 1fr; gap: 0; } }
.mxa-scrim { position: fixed; inset: 0; z-index: 90; background: var(--scrim); display: grid; place-items: center; padding: 16px; }
.mxa-dlg { width: min(560px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; overflow-x: hidden; background: var(--surface); color: var(--ink);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-overlay); padding: var(--space-4) var(--space-6); display: grid; gap: var(--space-3); }
.mxa-dlg > header { display: flex; align-items: center; gap: 10px; } .mxa-dlg h2 { margin: 0; flex: 1; font-size: 18px; }
.mxa-dlg > footer { display: flex; justify-content: space-between; gap: 8px; padding-top: var(--space-2); border-top: 1px solid var(--line); }
.mxa-dlg p { margin: 0; line-height: 25px; }
.mxa-steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; counter-reset: s; }
.mxa-steps li { counter-increment: s; display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); padding-top: 6px; border-top: 3px solid var(--line); }
.mxa-steps li::before { content: counter(s, persian); display: inline-grid; place-items: center; flex: none; width: 20px; height: 20px; border-radius: 50%; background: var(--surface-2); font-weight: 800; font-size: 11px; }
.mxa-steps li.done { color: var(--success); border-top-color: var(--success); } .mxa-steps li.done::before { content: "✓"; background: var(--success-soft); }
.mxa-steps li.now { color: var(--ink); font-weight: 700; border-top-color: var(--ink); } .mxa-steps li.now::before { background: var(--ink); color: var(--surface); }
.mxa-note { padding: 8px 12px; border-radius: var(--radius-md); background: var(--info-soft); color: var(--ink); font-size: 13.5px; line-height: 23px; }
.mxa-in { display: flex; gap: 6px; } .mxa-in input { flex: 1; min-width: 0; font-size: 16px; }
.mxa-code { font-size: 34px; font-weight: 800; letter-spacing: 6px; text-align: center; padding: 10px; border-radius: var(--radius-md); background: var(--surface-2); font-family: ui-monospace, monospace; overflow-wrap: anywhere; }
.mxa-keys { display: flex; flex-wrap: wrap; gap: 6px; }
.mxa-wait, .mxa-ok, .mxa-bad { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; padding: var(--space-3); border-radius: var(--radius-md); }
.mxa-wait { background: var(--surface-2); color: var(--muted); }
.mxa-ok { background: var(--success-soft); color: var(--success); } .mxa-ok span { color: var(--ink); font-size: 13px; }
.mxa-bad { background: var(--danger-soft); color: var(--danger); } .mxa-bad span { flex: 1; color: var(--ink); }
.mxa-ok .i, .mxa-bad .i { width: 22px; height: 22px; flex: none; }
.mxa-spin { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--ink); animation: mxa-r .8s linear infinite; }
@keyframes mxa-r { to { transform: rotate(360deg); } }
#mxa-pic { display: grid; grid-template-columns: minmax(0, 1fr); place-items: center; }
#mxa-shot.qr { display: block; height: auto; width: 264px; max-width: 100%; aspect-ratio: 1; image-rendering: pixelated; background: #fff; padding: 8px; border-radius: var(--radius-md); }
#mxa-shot.mxa-live { display: block; height: auto; width: 100%; max-width: 100%; cursor: crosshair; border: 1px solid var(--line); border-radius: var(--radius-md); }
.mxa-dlg.wide { width: min(1000px, 100%); }
.mxa-dlg.wide #mxa-shot.mxa-live { max-height: calc(100vh - 330px); object-fit: contain; }
.mxa-head .tag, .mxa-card .tag { white-space: normal; line-height: 20px; height: auto; padding-block: 2px; }

/* ---- forward / share window: search a contact, choose the messenger («خودکار» = the last conversation with them) ---- */
#mx-fwd-slot .mx-scrim { z-index: 75; }
.mx-fwd { position: fixed; z-index: 76; top: 50%; left: 50%; transform: translate(-50%, -50%); width: min(500px, calc(100vw - 24px)); max-height: min(720px, calc(100vh - 32px));
  display: flex; flex-direction: column; overflow: hidden; background: var(--surface); color: var(--ink); border-radius: var(--radius-lg); box-shadow: var(--shadow-overlay); }
.mx-fwd .mx-ph > b .i { width: 20px; height: 20px; transform: scaleX(-1); }
.mxf-what { margin: var(--space-3) var(--space-4) 0; padding: 8px 12px; border-inline-start: 3px solid var(--ink); background: var(--surface-2); border-radius: var(--radius-sm); font-size: 13px; line-height: 21px; overflow-wrap: anywhere; }
.mxf-list { flex: 1; min-height: 120px; overflow-y: auto; overflow-x: hidden; margin-top: var(--space-2); }
.mxf-list .mx-row.on { background: var(--brand-soft); }
.mxf-foot { display: grid; gap: var(--space-2); padding: var(--space-3) var(--space-4); border-top: 1px solid var(--line); background: var(--surface-2); }
.mxf-foot > b { font-size: 14px; }
.mxf-via { padding: 0; border: 0; }
.mxf-via::before { content: none; }
.mxf-via button .i { width: 15px; height: 15px; }
.mxf-via button[disabled] { opacity: .45; cursor: not-allowed; }
.mxf-act { display: flex; justify-content: flex-end; gap: 6px; }
@media (max-width: 760px) { .mx-fwd { inset: 0; top: 0; left: 0; transform: none; width: 100%; max-height: none; height: 100%; border-radius: 0; } }

/* ---- select several messages ---- */
.mx-tick { flex: none; align-self: center; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--control-border); background: var(--surface); display: grid; place-items: center; padding: 0; cursor: pointer; color: var(--on-brand); }
.mx-m.picked .mx-tick { background: var(--brand); border-color: var(--brand-strong); }
.mx-tick .i { width: 14px; height: 14px; }
.mx-m.picked .mx-b { box-shadow: 0 0 0 2px var(--brand); }
.mx-selbar { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; padding: var(--space-3); border-top: 1px solid var(--line); background: var(--surface); }
.mx-selbar b { flex: 1; font-size: 14px; }

/* 3 Dec 2026 (stability batch): CRM name first, merge, open/close for colleagues, older messages */
.mx-msgs { overflow-anchor: none; }   /* the scroll is kept by hand when older messages come in above */
.mx-aka { flex: 0 1 auto; min-width: 0; max-width: 45%; font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mx-older.wait, .mx-older.end { border-style: dashed; cursor: default; color: var(--muted); display: inline-flex; align-items: center; margin: 0; }
.mx-fresh .btn .i { width: 15px; height: 15px; }
.mx-acc { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-md); border: 1px solid var(--line); background: var(--surface); min-width: 0; }
.mx-acc > span:not(.mx-st):not(.mx-tick) { flex: 1; min-width: 0; display: grid; }
.mx-acc b { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mx-acc small { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mx-acc .mx-st { white-space: normal; text-align: center; max-width: 52%; }
.mx-acc .mx-pf { width: 22px; height: 22px; }
.mx-tick.off { visibility: hidden; }
.mx-acc-f { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: var(--space-2) var(--space-3) var(--space-3); border-top: 1px solid var(--line); }
.mx-acc-f label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.mx-acc-f select { height: 30px; border-radius: var(--radius-sm); border: 1px solid var(--control-border); background: var(--surface); color: var(--ink); font: inherit; font-size: 13px; }
.mxf-merge { display: grid; gap: 6px; }
.mxf-merge .mx-find { margin: 0; }
.mxf-mrows { display: flex; flex-wrap: wrap; gap: 6px; }
.mxa-keepers { display: flex; flex-wrap: wrap; gap: 10px 18px; margin-top: var(--space-2); }
.mx-acc .mx-tick[aria-checked="true"] { background: var(--brand); border-color: var(--brand-strong); }

/* ---- where a messenger-only contact belongs, and who holds a conversation (owner, 4 Dec 2026) ---- */
.mx-lane { display: inline-flex; align-items: center; gap: 3px; padding: 0 7px; border-radius: var(--radius-full); font-size: 11px; font-weight: 700; line-height: 18px; white-space: nowrap; background: var(--brand-soft); color: var(--ink); }
.mx-lane .i { width: 12px; height: 12px; }
.mx-lane.finance, .mx-lane-b.finance.on { background: var(--success-soft); color: var(--success); }
.mx-lane.supply, .mx-lane-b.supply.on { background: var(--warning-soft); color: var(--warning); }
.mx-lane.spam, .mx-lane.service, .mx-lane-b.spam.on { background: var(--danger-soft); color: var(--danger); }
.mx-lanebar { margin: var(--space-2) var(--space-4) 0; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 13px; }
.mx-held { font-weight: 700; }
.mx-lanes { margin: var(--space-2) var(--space-4) 0; padding: var(--space-3); border-radius: var(--radius-md); border: 1px dashed var(--line); display: grid; gap: 8px; font-size: 13px; }
.mx-lane-row { display: flex; gap: 6px; flex-wrap: wrap; }
.mx-lane-b { display: inline-flex; align-items: center; gap: 5px; min-height: 34px; padding: 0 12px; border-radius: var(--radius-full); border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; }
.mx-lane-b .i { width: 15px; height: 15px; }
.mx-lane-b:hover { border-color: var(--ink); }
.mx-lane-b.on { border-color: currentColor; box-shadow: 0 0 0 1px currentColor; background: var(--brand-soft); }
.mx-lane-q { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 10px; border-radius: var(--radius-md); background: var(--brand-soft); }
.mx-lane-q span { flex: 1 1 220px; }
.mx-undo { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: var(--space-2) var(--space-3); padding: 8px 12px; border-radius: var(--radius-md); background: var(--ink); color: var(--surface); font-size: 13px; }
.mx-undo .btn { background: var(--surface); color: var(--ink); }
.mx-role { width: 118px; min-height: 30px; font-size: 12.5px; }
.mx-finding { margin: var(--space-2) var(--space-4) 0; display: flex; align-items: center; gap: 6px; color: var(--ink); }
.mx-finding .i { width: 14px; height: 14px; }
.mxa-book .mxa-steps-l { margin: 8px 0; padding-inline-start: 20px; display: grid; gap: 4px; }
.mxa-book .mono { font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
.mxa-pw { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 8px 0; padding: 10px 12px; border-radius: var(--radius-md); background: var(--warning-soft); }
.mxa-book-act { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mx-ready-add { display: flex; gap: 6px; flex-wrap: wrap; padding: 8px 0 2px; border-top: 1px dashed var(--line); margin-top: 6px; }
.mx-ready-add .input { flex: 1 1 160px; min-height: 32px; }

/* ---- the rail's messenger panel (owner, 4 Dec 2026): minimal; the newest messages like a phone's notifications ---- */
/* the panel takes the rail's remaining height and shows only whole messages: a row that does not fit wraps into a hidden second column */
.side .mx-tile { position: relative; display: flex; flex-direction: column; flex-wrap: wrap; align-content: stretch; flex: 0 1 auto; min-height: 76px; overflow: hidden;
    gap: 2px; margin: var(--space-3) var(--space-3) 0; padding: 4px; border-radius: 14px;
    background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.08);
    -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); box-shadow: none; text-align: start; }
.side .mx-tile.on { border-color: var(--brand); box-shadow: none; }
.side .mx-tile > button { width: 100%; font: inherit; color: inherit; background: none; border: 0; text-align: start; cursor: pointer; border-radius: 10px; }
.side .mx-tile > button:hover { background: rgba(255,255,255,.06); }
.side .mx-tile-h { display: flex; align-items: center; gap: 6px; padding: 6px 8px; }
.side .mx-tile-h b { flex: 1; font-size: 13px; font-weight: 800; }
.side .mx-tile-h .i { width: 15px; height: 15px; color: var(--brand); }
.side .mx-tile > * { flex: none; width: 100%; box-sizing: border-box; min-width: 0; }
.mx-tile-row { display: grid; gap: 0; padding: 4px 8px; line-height: 1.35; }
.mx-tile-top { display: flex; align-items: center; gap: 6px; min-width: 0; }
.mx-tile-top .mx-tile-pfx { flex: none; width: 14px; height: 14px; }
.mx-tile-top b { flex: 1; min-width: 0; font-size: 12.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mx-tile-top time { flex: none; font-size: 10.5px; color: var(--rail-muted); }
.mx-tile-msg { font-size: 11.5px; color: var(--rail-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mx-tile-row.un .mx-tile-top b { color: #fff; }
.mx-tile-row.un .mx-tile-top time { color: var(--brand); font-weight: 800; }
.mx-tile-row.un .mx-tile-msg { color: #d9d7d2; }
.mx-tile-none { margin: 0; padding: 2px 8px 6px; font-size: 11.5px; color: var(--rail-muted); }
@media (max-width: 1200px) and (min-width: 761px) {
    .side .mx-tile { margin: var(--space-2); padding: 2px; min-height: 0; } .mx-tile-row, .mx-tile-none, .side .mx-tile-h b { display: none; } .side .mx-tile-h { justify-content: center; position: relative; }
    .side .mx-tile-h .mx-n { position: absolute; inset-block-start: -2px; inset-inline-start: 4px; }
}
