/* ==========================================================================
   كيان ون — الدردشة (المراسلات، 2026-12-05): تطبيق مراسلات داخل النظام.
   المحادثات يمينًا والمحادثة يسارًا؛ رسائلي يسارًا بنيلي فاتح ورسائله يمينًا بالأبيض؛
   الذهبي لزر الإرسال وحده. نفس التطبيق في النافذة العائمة وفي صفحة /Messages/Chat.
   الأنماط الثلاثة من متغيرات --ch-* (النهاري هنا، الليلي والداكن في الأسفل).
   ========================================================================== */
:root {
  --ch-surface: #fff; --ch-side: #fff; --ch-wall: #edf0f8; --ch-dot: rgba(57,73,171,.075);
  --ch-line: #e5e8f2; --ch-text: #1c2340; --ch-muted: #646d8f; --ch-head: #1d2b64;
  --ch-hover: #f3f5fb; --ch-on: #e7ebfb; --ch-field: #f3f5fb;
  --ch-mine: #dfe5fa; --ch-mine-text: #142057; --ch-theirs: #fff;
  --ch-accent: #3949ab; --ch-read: #2563eb; --ch-red: #e5484d;
  --ch-strip-bg: #fff6dc; --ch-strip-text: #7a5900; --ch-banner-bg: #eef2ff; --ch-banner-text: #2b3a8f;
  --ch-shadow: 0 1px 1.5px rgba(16,24,64,.10), 0 1px 0 rgba(16,24,64,.03);
  --ch-float: 0 28px 70px -18px rgba(17,26,68,.42), 0 0 0 1px rgba(17,26,68,.07);
}

/* ---------------------------------------------------------------- the top-bar icon */
.chat-top { position: relative; width: 40px; height: 40px; border-radius: 12px; border: 0; background: #eef1fb; color: var(--k-primary);
            display: grid; place-items: center; flex: none; text-decoration: none; transition: background .15s, transform .15s; }
.chat-top:hover { background: #e1e6f9; color: var(--k-primary); }
.chat-top[aria-expanded="true"] { background: var(--k-primary); color: #fff; }
.chat-top svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.chat-top-n { position: absolute; top: -6px; inset-inline-end: -6px; min-width: 19px; height: 19px; padding: 0 5px; border-radius: 10px; background: var(--ch-red);
              color: #fff; font-size: .68rem; font-weight: 700; font-style: normal; display: grid; place-items: center; box-shadow: 0 0 0 2px #fff; line-height: 1; }
.chat-top-n[hidden] { display: none; }
.m-chat { margin-inline-start: auto; margin-inline-end: 8px; }
@media (min-width: 992px) { .m-chat { display: none; } }
body.chat-panel-open .ai-fab { opacity: 0; pointer-events: none; transform: scale(.6); }

/* ---------------------------------------------------------------- the floating panel and the page */
.chat-panel { position: fixed; z-index: 1050; top: 68px; left: 20px; width: 880px; max-width: calc(100vw - 40px); height: min(660px, calc(100vh - 88px));
              border-radius: 20px; overflow: hidden; background: var(--ch-surface); box-shadow: var(--ch-float); transform-origin: top left; animation: chat-in .2s ease-out; }
.chat-panel[hidden] { display: none; }
.chat-panel [data-chat-root], .chat-page { container: kchat / inline-size; }
.chat-panel [data-chat-root] { height: 100%; }
.chat-page { height: calc(100vh - 150px); min-height: 520px; border-radius: 20px; overflow: hidden; box-shadow: 0 10px 40px -22px rgba(17,26,68,.35), 0 0 0 1px var(--ch-line); background: var(--ch-surface); }
@keyframes chat-in { from { opacity: 0; transform: translateY(-8px) scale(.985); } to { opacity: 1; transform: none; } }
@media (max-width: 899.98px) {
  .chat-panel { inset: 0; top: 0; left: 0; width: 100%; max-width: none; height: 100%; height: 100dvh; border-radius: 0; z-index: 1085; animation: chat-up .2s ease-out; }
  body.chat-panel-open { overflow: hidden; }
  .chat-page { height: calc(100dvh - 150px); min-height: 420px; border-radius: 16px; }
}
@keyframes chat-up { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .chat-panel { animation: none; } }

/* ---------------------------------------------------------------- the app */
.chat-app { position: relative; display: grid; grid-template-columns: minmax(280px, 340px) 1fr; height: 100%; background: var(--ch-surface); color: var(--ch-text);
            overflow: hidden; font-size: .92rem; }
.chat-app svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.chat-app [hidden] { display: none !important; }
.chat-app button { font: inherit; cursor: pointer; }
.chat-app :focus-visible { outline: 2px solid var(--ch-accent); outline-offset: 2px; }

.chat-side { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--ch-side); border-inline-end: 1px solid var(--ch-line); }
.chat-newp { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.chat-side-head { display: flex; align-items: center; gap: 6px; padding: 14px 14px 8px 10px; }
.chat-side-head h2 { flex: 1; margin: 0; font-size: 1.18rem; font-weight: 700; color: var(--ch-head); }
.chat-hbtns { display: flex; gap: 2px; align-items: center; }
.chat-hbtn { width: 38px; height: 38px; border-radius: 11px; border: 0; background: transparent; color: var(--ch-muted); display: grid; place-items: center; text-decoration: none; transition: background .15s, color .15s; }
.chat-hbtn:hover { background: var(--ch-hover); color: var(--ch-head); }
.chat-hbtn.is-on { color: var(--ch-accent); }
.chat-search { display: flex; align-items: center; gap: 8px; margin: 2px 12px 8px; padding: 0 12px; border-radius: 12px; background: var(--ch-field); color: var(--ch-muted);
               border: 1px solid transparent; transition: border-color .15s, background .15s; }
.chat-search:focus-within { border-color: var(--ch-accent); background: var(--ch-surface); }
.chat-search svg { width: 18px; height: 18px; }
.chat-search input { flex: 1; min-width: 0; height: 40px; border: 0; background: transparent; outline: none; color: var(--ch-text); font-size: .88rem; }
.chat-list { flex: 1; min-height: 0; overflow-y: auto; padding: 0 8px 14px; overscroll-behavior: contain; }
.chat-sec { padding: 12px 10px 4px; font-size: .72rem; font-weight: 700; color: var(--ch-muted); }
.chat-list-empty { display: flex; flex-direction: column; gap: 4px; padding: 30px 18px; text-align: center; color: var(--ch-muted); font-size: .84rem; }
.chat-list-empty b { color: var(--ch-text); font-size: .92rem; }

.chat-row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 10px; border: 0; border-radius: 14px; background: transparent; color: inherit;
            text-align: start; transition: background .12s; }
.chat-row:hover { background: var(--ch-hover); }
.chat-row.is-on { background: var(--ch-on); }
.chat-row-mid { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.chat-row-top, .chat-row-bot { display: flex; align-items: center; gap: 6px; min-width: 0; }
.chat-row-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; color: var(--ch-head); font-size: .92rem; }
.chat-row-time { flex: none; font-size: .72rem; color: var(--ch-muted); }
.chat-row-line { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .72rem; color: var(--ch-muted); }
.chat-row-pv { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ch-muted); font-size: .84rem; display: flex; align-items: center; gap: 3px; }
.chat-row.is-unread .chat-row-name { font-weight: 700; }
.chat-row.is-unread .chat-row-time { color: var(--ch-red); font-weight: 700; }
.chat-row.is-unread .chat-row-pv { color: var(--ch-text); font-weight: 500; }
.chat-row-muted svg { width: 15px; height: 15px; color: var(--ch-muted); }
.chat-badge { flex: none; min-width: 21px; height: 21px; padding: 0 6px; border-radius: 11px; background: var(--ch-red); color: #fff; font-size: .72rem; font-weight: 700;
              display: grid; place-items: center; line-height: 1; }
.chat-badge.is-muted { background: #9aa1b9; }
.chat-chip { flex: none; font-size: .66rem; padding: 1px 7px; border-radius: 999px; background: var(--ch-hover); color: var(--ch-muted); }
.chat-person .chat-row-name { font-weight: 600; }

.chat-av { width: 46px; height: 46px; border-radius: 50%; flex: none; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: .95rem;
           box-shadow: inset 0 0 0 2px rgba(255,255,255,.22), 0 2px 6px -2px rgba(17,26,68,.35); user-select: none; }
.chat-av-md { width: 40px; height: 40px; font-size: .86rem; }

/* ---------------------------------------------------------------- the conversation side */
.chat-main { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; background-color: var(--ch-wall);
             background-image: radial-gradient(var(--ch-dot) 1.1px, transparent 1.3px); background-size: 20px 20px; }
.chat-empty { margin: auto; max-width: 320px; padding: 24px; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; color: var(--ch-muted); font-size: .86rem; }
.chat-empty b, .chat-card b { color: var(--ch-head); font-size: 1.06rem; }
.chat-empty-ic { width: 74px; height: 74px; border-radius: 24px; display: grid; place-items: center; margin-bottom: 6px; color: #fff;
                 background: linear-gradient(135deg, #4a5cc4, #1d2b64); box-shadow: 0 16px 34px -14px rgba(29,43,100,.7); }
.chat-empty-ic svg { width: 34px; height: 34px; }
.chat-thread { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.chat-th-head { display: flex; align-items: center; gap: 10px; padding: 9px 12px; background: var(--ch-surface); border-bottom: 1px solid var(--ch-line); }
.chat-back { display: none; }
.chat-th-who { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.chat-th-who b { color: var(--ch-head); font-size: .96rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-th-who small { color: var(--ch-muted); font-size: .74rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-strip { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 5px 12px; font-size: .72rem; background: var(--ch-strip-bg); color: var(--ch-strip-text); text-align: center; }
.chat-strip svg { width: 13px; height: 13px; }
.chat-banner { padding: 6px 14px; font-size: .78rem; background: var(--ch-banner-bg); color: var(--ch-banner-text); border-bottom: 1px solid var(--ch-line); }
.chat-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 10px 6% 10px; overscroll-behavior: contain; }
.chat-msgs { display: flex; flex-direction: column; }
.chat-day { position: sticky; top: 4px; z-index: 1; align-self: center; margin: 12px 0 6px; padding: 4px 12px; border-radius: 999px; font-size: .72rem; font-weight: 600;
            color: var(--ch-muted); background: var(--ch-surface); box-shadow: var(--ch-shadow); }
.chat-start { align-self: center; margin: 6px 0 2px; font-size: .72rem; color: var(--ch-muted); }
.chat-older { text-align: center; padding: 6px; }

.chat-msg { display: flex; flex-direction: column; max-width: min(76%, 540px); margin-top: 8px; }
.chat-msg.is-grouped { margin-top: 2px; }
.chat-msg.is-theirs { align-self: flex-start; }
.chat-msg.is-mine { align-self: flex-end; align-items: flex-end; }
.chat-bubble { position: relative; padding: 6px 11px 6px; border-radius: 16px; box-shadow: var(--ch-shadow); line-height: 1.6; overflow-wrap: anywhere; min-width: 64px; }
.chat-bubble::after { content: ''; display: block; clear: both; }
.is-theirs .chat-bubble { background: var(--ch-theirs); color: var(--ch-text); border-start-start-radius: 5px; }
.is-mine .chat-bubble { background: var(--ch-mine); color: var(--ch-mine-text); border-start-end-radius: 5px; }
.is-grouped.is-theirs .chat-bubble { border-start-start-radius: 16px; }
.is-grouped.is-mine .chat-bubble { border-start-end-radius: 16px; }
.chat-text { display: inline; white-space: pre-wrap; }
.chat-meta { float: left; display: inline-flex; align-items: center; gap: 4px; margin-top: 8px; margin-inline-start: 14px; font-size: .67rem; line-height: 1; color: var(--ch-muted); white-space: nowrap; }
.is-mine .chat-meta { color: #5a648e; }
.chat-edited { font-style: italic; }
.chat-tick { display: inline-flex; color: var(--ch-muted); font-style: normal; }
.chat-tick svg { width: 16px; height: 11px; stroke-width: 1.7; }
.chat-tick.is-read { color: var(--ch-read); }
.chat-tick.is-fail { color: var(--ch-red); font-weight: 800; }
.chat-meta .chat-tick svg[viewBox="0 0 16 16"] { width: 12px; height: 12px; }
.chat-row-pv .chat-tick svg { width: 15px; height: 10px; }
.chat-more { position: absolute; top: 3px; inset-inline-end: 3px; width: 26px; height: 26px; border-radius: 50%; border: 0; display: grid; place-items: center; color: var(--ch-muted);
             background: radial-gradient(circle, var(--ch-theirs) 55%, transparent 72%); opacity: 0; transition: opacity .12s; }
.is-mine .chat-more { background: radial-gradient(circle, var(--ch-mine) 55%, transparent 72%); }
.chat-more svg { width: 16px; height: 16px; }
.chat-bubble:hover .chat-more, .chat-more:focus-visible { opacity: 1; }
@media (hover: none) { .chat-more { opacity: .55; } }
.chat-quote { display: block; width: 100%; min-width: 160px; margin: 2px 0 5px; padding: 5px 9px; border: 0; border-inline-start: 3px solid var(--ch-accent); border-radius: 8px;
              background: rgba(57,73,171,.08); text-align: start; color: inherit; font-size: .78rem; line-height: 1.45; }
.chat-quote.is-mine { border-inline-start-color: #c48f00; background: rgba(196,143,0,.09); }
.chat-quote b { display: block; color: var(--ch-accent); font-size: .74rem; }
.chat-quote.is-mine b { color: #9a6f00; }
.chat-quote span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; color: var(--ch-muted); }
.chat-img { display: block; margin: 0 -7px 4px; }
.chat-img img { display: block; width: 100%; max-width: 280px; max-height: 340px; min-height: 80px; object-fit: cover; border-radius: 12px; background: var(--ch-hover); }
.chat-img-gone { font-size: .8rem; color: var(--ch-muted); padding: 4px 0; }
.chat-retry { border: 0; background: none; padding: 2px 4px; font-size: .72rem; color: var(--ch-red); font-weight: 600; }
.chat-msg.is-failed .chat-bubble { opacity: .75; }
.chat-msg.is-flash .chat-bubble { animation: chat-flash 1.2s ease; }
@keyframes chat-flash { 0%, 60% { box-shadow: 0 0 0 3px rgba(248,188,24,.65); } 100% { box-shadow: var(--ch-shadow); } }
.chat-jump { position: absolute; bottom: 86px; left: 50%; transform: translateX(-50%); z-index: 3; display: flex; align-items: center; gap: 6px; padding: 7px 14px 7px 12px;
             border: 0; border-radius: 999px; background: var(--ch-accent); color: #fff; font-size: .78rem; font-weight: 600; box-shadow: 0 8px 20px -8px rgba(29,43,100,.7); }
.chat-jump svg { width: 16px; height: 16px; }

/* composing */
.chat-compose { padding: 8px 10px 10px; background: var(--ch-surface); border-top: 1px solid var(--ch-line); }
.chat-ctx { display: flex; align-items: center; gap: 8px; margin: 0 4px 8px; padding: 6px 6px 6px 10px; border-radius: 11px; background: var(--ch-hover); border-inline-start: 3px solid var(--ch-accent); }
.chat-ctx.is-edit { border-inline-start-color: #e9a90b; }
.chat-ctx-t { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.chat-ctx-t b { font-size: .74rem; color: var(--ch-accent); }
.chat-ctx.is-edit .chat-ctx-t b { color: #9a6f00; }
.chat-ctx-t span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .8rem; color: var(--ch-muted); }
.chat-ctx .chat-hbtn { width: 30px; height: 30px; }
.chat-cbar { display: flex; align-items: flex-end; gap: 8px; }
.chat-attach { width: 44px; height: 44px; flex: none; border-radius: 50%; display: grid; place-items: center; color: var(--ch-muted); cursor: pointer; margin: 0; transition: background .15s, color .15s; }
.chat-attach:hover { background: var(--ch-hover); color: var(--ch-head); }
.chat-attach svg { width: 22px; height: 22px; }
.chat-cbar textarea { flex: 1; min-width: 0; resize: none; max-height: 140px; padding: 10px 16px; border: 1px solid var(--ch-line); border-radius: 22px; background: var(--ch-field);
                      color: var(--ch-text); font: inherit; font-size: .92rem; line-height: 1.45; outline: none; transition: border-color .15s, background .15s, box-shadow .15s; }
.chat-cbar textarea:focus { border-color: var(--ch-accent); background: var(--ch-surface); box-shadow: 0 0 0 3px rgba(57,73,171,.12); }
.chat-cbar textarea::placeholder { color: var(--ch-muted); }
.chat-send { width: 44px; height: 44px; flex: none; border: 0; border-radius: 50%; display: grid; place-items: center; color: #1d2b64;
             background: linear-gradient(135deg, #fbd35c, #e9a90b); box-shadow: 0 8px 18px -8px rgba(233,169,11,.9); transition: transform .15s, box-shadow .15s, background .15s; }
.chat-send svg { width: 20px; height: 20px; fill: currentColor; stroke: currentColor; stroke-width: 1.2; }
.chat-send:not(:disabled):hover { transform: scale(1.06); }
.chat-send:not(:disabled):active { transform: scale(.94); }
.chat-send:disabled { background: var(--ch-hover); color: #a3a9c2; box-shadow: none; cursor: default; }
.chat-ro { padding: 12px 16px; text-align: center; font-size: .82rem; color: var(--ch-muted); background: var(--ch-surface); border-top: 1px solid var(--ch-line); }

/* consent, off, menu, toast */
.chat-cover { position: absolute; inset: 0; z-index: 6; display: grid; place-items: center; padding: 20px; overflow-y: auto; background-color: var(--ch-wall);
              background-image: radial-gradient(var(--ch-dot) 1.1px, transparent 1.3px); background-size: 20px 20px; }
.chat-card { max-width: 440px; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 28px 26px 22px; border-radius: 22px; text-align: center;
             background: var(--ch-surface); color: var(--ch-muted); box-shadow: 0 24px 56px -24px rgba(17,26,68,.4), 0 0 0 1px var(--ch-line); font-size: .86rem; }
.chat-consent ul { margin: 4px 0 8px; padding-inline-start: 18px; text-align: start; color: var(--ch-text); font-size: .86rem; line-height: 1.7; }
.chat-consent li::marker { color: var(--ch-accent); }
.chat-consent .btn-primary { min-width: 180px; }
.chat-menu { position: absolute; z-index: 10; min-width: 196px; padding: 6px; border-radius: 14px; background: var(--ch-surface); box-shadow: 0 18px 44px -14px rgba(17,26,68,.4), 0 0 0 1px var(--ch-line); animation: chat-in .12s ease-out; }
.chat-mi { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: 0; border-radius: 9px; background: transparent; color: var(--ch-text); font-size: .86rem; text-align: start; }
.chat-mi:hover, .chat-mi:focus-visible { background: var(--ch-hover); }
.chat-mi svg { width: 18px; height: 18px; color: var(--ch-muted); }
.chat-mi.is-danger, .chat-mi.is-danger svg { color: var(--ch-red); }
.chat-toast { position: absolute; bottom: 92px; left: 50%; z-index: 12; max-width: 90%; padding: 9px 16px; border-radius: 12px; background: #1d2b64; color: #fff; font-size: .82rem;
              opacity: 0; transform: translate(-50%, 16px); pointer-events: none; transition: opacity .2s, transform .2s; box-shadow: 0 12px 28px -12px rgba(17,26,68,.6); }
.chat-toast.is-on { opacity: 1; transform: translate(-50%, 0); }
.chat-dots { display: inline-flex; gap: 4px; }
.chat-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--ch-muted); opacity: .4; animation: chat-dot 1s infinite; }
.chat-dots i:nth-child(2) { animation-delay: .15s; } .chat-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes chat-dot { 50% { opacity: 1; transform: translateY(-2px); } }

/* one pane under 760 px of width: the list, or the conversation with «رجوع» */
.chat-only-narrow { display: none; }
@container kchat (max-width: 759px) {
  .chat-app { grid-template-columns: 1fr; }
  .chat-app[data-view="thread"] .chat-side { display: none; }
  .chat-app:not([data-view="thread"]) .chat-main { display: none; }
  .chat-side { border: 0; }
  .chat-back { display: grid; }
  .chat-only-wide { display: none; }
  .chat-only-narrow { display: grid; }
  .chat-scroll { padding: 8px 10px; }
  .chat-msg { max-width: 86%; }
  .chat-hbtn { width: 42px; height: 42px; }
}

/* ---------------------------------------------------------------- night (warm) and dark (operations room) */
:root[data-theme="night"] {
  --ch-surface: var(--t-surface); --ch-side: var(--t-surface); --ch-wall: var(--t-bg-2); --ch-dot: rgba(255,232,200,.045);
  --ch-line: var(--t-line); --ch-text: var(--t-text); --ch-muted: var(--t-muted); --ch-head: var(--t-head);
  --ch-hover: var(--t-surface-2); --ch-on: var(--t-raise); --ch-field: var(--t-surface-2);
  --ch-mine: #3b3424; --ch-mine-text: #FFF5E4; --ch-theirs: var(--t-surface-2);
  --ch-accent: #F0C870; --ch-read: #8DB8FF;
  --ch-strip-bg: rgba(240,200,112,.10); --ch-strip-text: #E9CF96; --ch-banner-bg: rgba(185,194,242,.10); --ch-banner-text: #C9D0F5;
  --ch-shadow: 0 1px 1.5px rgba(0,0,0,.35);
}
:root[data-theme="dark"] {
  --ch-surface: var(--t-surface); --ch-side: var(--t-surface); --ch-wall: var(--t-bg-2); --ch-dot: rgba(140,160,255,.06);
  --ch-line: var(--t-line); --ch-text: var(--t-text); --ch-muted: var(--t-muted); --ch-head: var(--t-head);
  --ch-hover: var(--t-surface-2); --ch-on: var(--t-raise); --ch-field: var(--t-surface-2);
  --ch-mine: #243373; --ch-mine-text: #FFFFFF; --ch-theirs: var(--t-surface-2);
  --ch-accent: #A6B3FF; --ch-read: #7FD3FF;
  --ch-strip-bg: rgba(166,179,255,.09); --ch-strip-text: #C6CFFC; --ch-banner-bg: rgba(166,179,255,.10); --ch-banner-text: #D3DAFF;
  --ch-shadow: 0 1px 1.5px rgba(0,0,0,.45);
}
:root[data-theme="night"] .chat-top, :root[data-theme="dark"] .chat-top { background: var(--t-surface-2); color: var(--t-text); }
:root[data-theme="night"] .chat-top:hover, :root[data-theme="dark"] .chat-top:hover { background: var(--t-raise); color: var(--t-head); }
:root[data-theme="night"] .chat-top-n, :root[data-theme="dark"] .chat-top-n { box-shadow: 0 0 0 2px var(--t-surface); }
:root[data-theme="night"] .is-mine .chat-meta, :root[data-theme="dark"] .is-mine .chat-meta { color: rgba(255,255,255,.62); }
:root[data-theme="night"] .chat-quote, :root[data-theme="dark"] .chat-quote { background: rgba(255,255,255,.06); }
:root[data-theme="night"] .chat-quote.is-mine b, :root[data-theme="night"] .chat-ctx.is-edit .chat-ctx-t b { color: #F0C870; }
:root[data-theme="dark"] .chat-quote.is-mine b, :root[data-theme="dark"] .chat-ctx.is-edit .chat-ctx-t b { color: #F8D36A; }
:root[data-theme="night"] .chat-send:disabled, :root[data-theme="dark"] .chat-send:disabled { color: var(--t-muted); }
:root[data-theme="night"] .chat-cbar textarea:focus, :root[data-theme="dark"] .chat-cbar textarea:focus { box-shadow: 0 0 0 3px rgba(166,179,255,.14); }
:root[data-theme="dark"] .chat-toast, :root[data-theme="night"] .chat-toast { background: var(--t-raise); color: var(--t-head); }

/* ---------------------------------------------------------------- settings and the general manager's review */
.chat-opt { align-items: flex-start; }
.chat-opt input { margin-top: 5px; }
.chat-opt span { display: flex; flex-direction: column; gap: 2px; }
.chat-opt small { color: #5B6275; line-height: 1.6; }
.chat-review { max-width: 760px; margin-inline: auto; display: flex; flex-direction: column; padding: 14px 6%; border-radius: 16px; background-color: var(--ch-wall);
               background-image: radial-gradient(var(--ch-dot) 1.1px, transparent 1.3px); background-size: 20px 20px; }
.chat-review .chat-msg { max-width: 82%; }
.chat-review .chat-who { font-size: .72rem; font-weight: 700; color: var(--ch-accent); margin-bottom: 2px; }
.chat-review .chat-orig { margin-top: 4px; padding-top: 4px; border-top: 1px dashed rgba(100,109,143,.35); font-size: .78rem; color: var(--ch-muted); white-space: pre-wrap; }
.chat-review .chat-meta { float: none; margin: 4px 0 0; }
.chat-review-head { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; padding: 10px 14px; border-radius: 12px; background: var(--ch-strip-bg); color: var(--ch-strip-text); font-size: .84rem; margin-bottom: 12px; }
.chat-list, .chat-scroll, .chat-cbar textarea { scrollbar-width: thin; scrollbar-color: rgba(100,109,143,.35) transparent; }

/* ---------------------------------------------------------------- voice notes (2026-12-05) */
.chat-send.is-mic { background: var(--ch-accent); color: #fff; box-shadow: 0 8px 18px -8px rgba(57,73,171,.8); }
.chat-send.is-mic svg { fill: none; stroke: currentColor; stroke-width: 2; }
.chat-rec { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.chat-rec-x { color: var(--ch-red); }
.chat-rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ch-red); flex: none; animation: chat-pulse 1s ease-in-out infinite; }
.chat-rec-t { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--ch-text); min-width: 3em; }
.chat-rec-wave { flex: 1; min-width: 0; display: flex; align-items: center; gap: 3px; height: 26px; overflow: hidden; }
.chat-rec-wave i { flex: none; width: 3px; border-radius: 2px; background: var(--ch-accent); opacity: .7; height: 30%; animation: chat-wave 1s ease-in-out infinite; }
.chat-rec-wave i:nth-child(3n) { animation-delay: .2s; } .chat-rec-wave i:nth-child(3n+1) { animation-delay: .45s; } .chat-rec-wave i:nth-child(4n) { animation-delay: .7s; }
.chat-rec-hint { font-size: .7rem; color: var(--ch-muted); white-space: nowrap; }
@keyframes chat-pulse { 50% { opacity: .25; } }
@keyframes chat-wave { 50% { height: 95%; } }
@container kchat (max-width: 520px) { .chat-rec-hint { display: none; } }
@media (prefers-reduced-motion: reduce) { .chat-rec-dot, .chat-rec-wave i { animation: none; } }
.chat-voice { display: flex; align-items: center; gap: 10px; min-width: 210px; padding: 2px 0 4px; }
.chat-voice-b { width: 38px; height: 38px; flex: none; border: 0; border-radius: 50%; display: grid; place-items: center; color: #fff; background: var(--ch-accent);
                box-shadow: 0 4px 10px -4px rgba(57,73,171,.7); }
.chat-voice-b svg { width: 18px; height: 18px; fill: currentColor; stroke: none; }
.chat-voice-bar { position: relative; flex: 1; height: 6px; border-radius: 3px; background: rgba(100,109,143,.22); cursor: pointer; overflow: hidden; }
.chat-voice-bar i { position: absolute; inset-block: 0; inset-inline-start: 0; width: 0; border-radius: 3px; background: var(--ch-accent); transition: width .2s linear; }
.chat-voice-t { font-size: .72rem; color: var(--ch-muted); font-variant-numeric: tabular-nums; min-width: 2.6em; }
:root[data-theme="night"] .chat-voice-b, :root[data-theme="dark"] .chat-voice-b, :root[data-theme="night"] .chat-send.is-mic, :root[data-theme="dark"] .chat-send.is-mic { color: #141a33; }

/* ---------------------------------------------------------------- the small alert of a new message (2026-12-05) */
.chat-pop { position: fixed; z-index: 1090; left: 20px; bottom: 24px; max-width: min(360px, calc(100vw - 40px)); display: flex; align-items: center; gap: 12px;
            padding: 12px 16px 12px 14px; border: 0; border-radius: 16px; background: var(--ch-surface); color: var(--ch-text); text-align: start;
            box-shadow: 0 18px 44px -14px rgba(17,26,68,.45), 0 0 0 1px var(--ch-line); border-inline-start: 4px solid var(--ch-accent);
            opacity: 0; transform: translateY(16px); pointer-events: none; transition: opacity .25s, transform .25s; cursor: pointer; }
.chat-pop.is-on { opacity: 1; transform: none; pointer-events: auto; }
.chat-pop-ic { width: 40px; height: 40px; flex: none; border-radius: 12px; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, #4a5cc4, #1d2b64); }
.chat-pop-ic svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.chat-pop-t { min-width: 0; display: flex; flex-direction: column; }
.chat-pop-t b { color: var(--ch-head); font-size: .9rem; }
.chat-pop-t span { color: var(--ch-muted); font-size: .82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 991.98px) { .chat-pop { left: 12px; right: 12px; max-width: none; bottom: auto; top: 12px; transform: translateY(-16px); } }
/* user trial 2026-12-05: the card shows even with the panel open (it may be on another conversation, or the person elsewhere) */

/* ---------------------------------------------------------------- «تنبيه» (2026-12-05) */
.chat-nudge { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px; border: 0; border-radius: 999px; font-weight: 600; font-size: .82rem;
              color: #7a4a00; background: #fff1cc; transition: background .15s, transform .15s; }
.chat-nudge:hover:not(:disabled) { background: #ffe3a1; transform: translateY(-1px); }
.chat-nudge:disabled { opacity: .55; cursor: default; }
.chat-nudge svg { width: 18px; height: 18px; }
@container kchat (max-width: 420px) { .chat-nudge span { display: none; } .chat-nudge { width: 40px; padding: 0; justify-content: center; } }
.chat-nudge-line { align-self: center; display: inline-flex; align-items: center; gap: 6px; margin: 10px 0 4px; padding: 5px 14px; border-radius: 999px; font-size: .76rem;
                   font-weight: 600; color: #7a4a00; background: #fff1cc; box-shadow: var(--ch-shadow); }
.chat-nudge-line svg { width: 15px; height: 15px; }
.chat-nudge-line small { font-weight: 400; opacity: .8; }
.chat-notif { display: flex; align-items: center; gap: 8px; margin: 0 10px 10px; padding: 8px 10px; border-radius: 12px; background: var(--ch-banner-bg); color: var(--ch-banner-text); font-size: .76rem; }
.chat-notif span { flex: 1; }
.chat-pop.is-nudge { border-inline-start-color: #e9a90b; animation: chat-shake .5s ease-in-out 3; }
.chat-pop.is-nudge .chat-pop-ic { background: linear-gradient(135deg, #fbd35c, #e9a90b); color: #1d2b64; }
@keyframes chat-shake { 25% { transform: rotate(-2deg); } 75% { transform: rotate(2deg); } }
@media (prefers-reduced-motion: reduce) { .chat-pop.is-nudge { animation: none; } }
:root[data-theme="night"] .chat-nudge, :root[data-theme="dark"] .chat-nudge, :root[data-theme="night"] .chat-nudge-line, :root[data-theme="dark"] .chat-nudge-line { background: rgba(248,188,24,.16); color: #F8D36A; }
.chat-pop.is-nudge { cursor: default; align-items: flex-start; }
.chat-pop.is-ringing .chat-pop-ic { animation: chat-shake .5s ease-in-out infinite; }
.chat-pop-btns { display: flex; gap: 8px; margin-top: 8px; }
.chat-pop-ack { background: #fff1cc; color: #7a4a00; font-weight: 600; border: 0; }
.chat-pop-ack:hover { background: #ffe3a1; color: #7a4a00; }
.chat-nudge-ack { color: #17714A; font-weight: 700 !important; opacity: 1 !important; }
:root[data-theme="night"] .chat-nudge-ack, :root[data-theme="dark"] .chat-nudge-ack { color: #7BE0A8; }

/* ---------------------------------------------------------------- «متصل الآن» (2026-12-05) */
.chat-av { position: relative; }
.chat-online { position: absolute; bottom: 0; inset-inline-end: 0; width: 13px; height: 13px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 2.5px var(--ch-surface); }
.chat-av-md .chat-online { width: 11px; height: 11px; }
.chat-th-who small.is-online { color: #15803d; font-weight: 600; }
:root[data-theme="night"] .chat-th-who small.is-online, :root[data-theme="dark"] .chat-th-who small.is-online { color: #6EE7A0; }
.chat-pop-muted { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; padding: 8px 10px; border-radius: 10px; background: #fdecea; color: #8a1c14; font-size: .74rem; line-height: 1.6; }
.chat-pop-sound { align-self: flex-start; background: #e5484d; color: #fff; border: 0; font-weight: 600; }
.chat-pop-sound:hover { background: #c93c40; color: #fff; }
.chat-pop-t .chat-pop-muted span { white-space: normal; overflow: visible; text-overflow: clip; color: #8a1c14; font-size: .74rem; }
.chat-pop-t .chat-pop-btns + .chat-pop-muted { margin-top: 10px; }

/* ---------------------------------------------------------------- «جاهزية التنبيه على هذا الجهاز» (2026-12-05) */
.chat-ready { flex-direction: column; align-items: stretch; gap: 6px; padding: 10px 10px 8px; background: var(--ch-surface); color: var(--ch-text);
              box-shadow: 0 0 0 1px var(--ch-line), 0 10px 24px -16px rgba(17,26,68,.4); max-height: 58%; overflow-y: auto; }
.chat-ready-h { display: flex; align-items: center; justify-content: space-between; }
.chat-ready-h b { color: var(--ch-head); font-size: .84rem; }
.chat-ready-h .chat-hbtn { width: 28px; height: 28px; }
.chat-ready-r { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; background: var(--ch-hover); }
.chat-ready-r.is-ok { background: #e7f6ee; } .chat-ready-r.is-bad { background: #fdecea; }
.chat-ready-i { font-size: 1.1rem; flex: none; }
.chat-ready-t { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.45; }
.chat-ready-t b { font-size: .8rem; color: var(--ch-head); }
.chat-ready-t small { font-size: .72rem; color: var(--ch-muted); }
.chat-ready-b { background: var(--ch-on); color: var(--ch-accent); border: 0; font-weight: 600; flex: none; }
.chat-ready-r .btn { flex: none; }
:root[data-theme="night"] .chat-ready-r.is-ok, :root[data-theme="dark"] .chat-ready-r.is-ok { background: rgba(34,197,94,.12); }
:root[data-theme="night"] .chat-ready-r.is-bad, :root[data-theme="dark"] .chat-ready-r.is-bad { background: rgba(229,72,77,.14); }

/* ---------------------------------------------------------------- 2026-12-05: quick replies, reactions, pin, search, forward, smart links */
.chat-quick { display: flex; gap: 6px; overflow-x: auto; padding: 0 4px 8px; scrollbar-width: none; }
.chat-quick::-webkit-scrollbar { display: none; }
.chat-chip-q { flex: none; border: 1px solid var(--ch-line); background: var(--ch-on); color: var(--ch-accent); border-radius: 999px; padding: 5px 12px;
               font-size: .78rem; font-weight: 600; white-space: nowrap; transition: background .15s, transform .15s; }
.chat-chip-q:hover { background: var(--ch-accent); color: #fff; transform: translateY(-1px); }
:root[data-theme="night"] .chat-chip-q:hover, :root[data-theme="dark"] .chat-chip-q:hover { color: #141a33; }

.chat-mi-reacts { display: flex; justify-content: space-between; gap: 2px; padding: 2px 2px 6px; margin-bottom: 4px; border-bottom: 1px solid var(--ch-line); }
.chat-mi-react { width: 34px; height: 34px; border: 0; border-radius: 50%; background: transparent; font-size: 1.15rem; line-height: 1; transition: transform .12s, background .12s; }
.chat-mi-react:hover { transform: scale(1.2); background: var(--ch-hover); }
.chat-mi-react.is-on { background: var(--ch-on); box-shadow: inset 0 0 0 2px var(--ch-accent); }
.chat-reacts { display: flex; flex-wrap: wrap; gap: 4px; margin-top: -6px; padding: 0 8px; position: relative; z-index: 1; }
.is-mine .chat-reacts { justify-content: flex-end; }
.chat-react { border: 0; border-radius: 999px; padding: 1px 8px; font-size: .78rem; background: var(--ch-surface); color: var(--ch-text);
              box-shadow: 0 1px 3px rgba(16,24,64,.18), 0 0 0 1px var(--ch-line); }
.chat-react.is-mine { box-shadow: 0 1px 3px rgba(16,24,64,.18), 0 0 0 1.5px var(--ch-accent); }

.chat-fwd-from { font-size: .72rem; color: var(--ch-muted); font-style: italic; margin-bottom: 2px; }

.chat-refs { display: flex; flex-direction: column; gap: 5px; margin-top: 6px; clear: both; }
.chat-refs:empty { display: none; }
.chat-ref { display: flex; flex-direction: column; gap: 1px; padding: 7px 10px; border-radius: 10px; text-decoration: none; color: var(--ch-text);
            background: rgba(255,255,255,.65); border-inline-start: 3px solid var(--ch-accent); min-width: 200px; transition: background .15s; }
.chat-ref:hover { background: rgba(255,255,255,.95); color: var(--ch-text); }
.chat-ref-k { font-size: .68rem; font-weight: 700; color: var(--ch-accent); }
.chat-ref b { font-size: .82rem; color: var(--ch-head); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-ref small { font-size: .7rem; color: var(--ch-muted); }
.chat-ref-memo { border-inline-start-color: #c48f00; } .chat-ref-memo .chat-ref-k { color: #9a6f00; }
.chat-ref-circular { border-inline-start-color: #17714A; } .chat-ref-circular .chat-ref-k { color: #17714A; }
:root[data-theme="night"] .chat-ref, :root[data-theme="dark"] .chat-ref { background: rgba(255,255,255,.06); }
:root[data-theme="night"] .chat-ref:hover, :root[data-theme="dark"] .chat-ref:hover { background: rgba(255,255,255,.11); }

.chat-pin { display: flex; align-items: center; gap: 8px; padding: 4px 6px 4px 12px; background: var(--ch-surface); border-bottom: 1px solid var(--ch-line);
            font-size: .8rem; cursor: pointer; color: var(--ch-text); }
.chat-pin span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-pin .chat-hbtn { width: 28px; height: 28px; }
.chat-pin:hover { background: var(--ch-hover); }
.chat-find { position: relative; display: flex; align-items: center; gap: 6px; padding: 6px 8px; background: var(--ch-surface); border-bottom: 1px solid var(--ch-line); }
.chat-find .chat-search { flex: 1; margin: 0; }
.chat-find-res { position: absolute; top: 100%; left: 8px; right: 8px; z-index: 8; max-height: 280px; overflow-y: auto; border-radius: 12px; background: var(--ch-surface);
                 box-shadow: 0 16px 40px -14px rgba(17,26,68,.4), 0 0 0 1px var(--ch-line); }
.chat-find-res:empty { display: none; }
.chat-find-hit { display: flex; gap: 10px; width: 100%; padding: 9px 12px; border: 0; background: transparent; text-align: start; color: var(--ch-text); font-size: .82rem; border-bottom: 1px solid var(--ch-line); }
.chat-find-hit span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-find-hit time { color: var(--ch-muted); font-size: .72rem; flex: none; }
.chat-find-hit:hover { background: var(--ch-hover); }
.chat-find-none { padding: 12px; text-align: center; color: var(--ch-muted); font-size: .8rem; }

.chat-fwd { position: absolute; inset: 0; z-index: 9; display: grid; place-items: center; padding: 16px; background: rgba(17,26,68,.35); }
.chat-fwd-card { width: min(380px, 100%); max-height: 80%; display: flex; flex-direction: column; border-radius: 18px; background: var(--ch-surface);
                 box-shadow: 0 24px 56px -20px rgba(17,26,68,.6); overflow: hidden; }
.chat-fwd-h { display: flex; align-items: center; justify-content: space-between; padding: 12px 12px 4px 16px; }
.chat-fwd-h b { color: var(--ch-head); }
.chat-fwd-card .chat-search { margin: 4px 12px 8px; }
.chat-fwd-card .chat-list { max-height: 360px; }

.chat-main.is-drop::after { content: 'أفلت الصورة لإرسالها'; position: absolute; inset: 8px; z-index: 7; display: grid; place-items: center; border-radius: 16px;
                            border: 2.5px dashed var(--ch-accent); background: rgba(57,73,171,.08); color: var(--ch-accent); font-weight: 700; pointer-events: none; }
.chat-th-who small.is-away { color: #9a6f00; font-weight: 600; }
:root[data-theme="night"] .chat-th-who small.is-away, :root[data-theme="dark"] .chat-th-who small.is-away { color: #F0C870; }
