/* LINE_ALL — unified inbox web app */
:root {
  --bg: #0f1115;
  --bg-2: #171a21;
  --bg-3: #1e222b;
  --bg-hover: #232833;
  --line: #2a2f3a;
  --text: #e6e9ef;
  --text-dim: #9aa3b2;
  --text-faint: #6b7280;
  --green: #06c755;
  --green-dark: #04a548;
  --accent: #3b82f6;
  --danger: #ef4444;
  --warn: #f59e0b;
  --bubble-in: #242a35;
  --bubble-out: #06c755;
  --radius: 12px;
  --shadow: 0 6px 24px rgba(0,0,0,.35);
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, "Noto Sans Thai", Tahoma, sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px;
  overflow: hidden;
}
button { font-family: inherit; cursor: pointer; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #333a47; border-radius: 6px; }
::-webkit-scrollbar-track { background: transparent; }

/* Layout */
.app { display: grid; grid-template-rows: auto 1fr; height: 100vh; }
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 16px; background: var(--bg-2); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 16px; letter-spacing: .3px; display: flex; align-items: center; gap: 8px; }
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--green); box-shadow: 0 0 10px var(--green); }
.topbar .spacer { flex: 1; }
.health {
  display: flex; align-items: center; gap: 8px; padding: 5px 10px;
  background: var(--bg-3); border: 1px solid var(--line); border-radius: 20px; font-size: 12.5px;
}
.health .status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--text-faint); }
.health.ok .status-dot { background: var(--green); box-shadow: 0 0 8px var(--green); }
.health.bad .status-dot { background: var(--danger); box-shadow: 0 0 8px var(--danger); }
.btn {
  border: 1px solid var(--line); background: var(--bg-3); color: var(--text);
  padding: 7px 13px; border-radius: 8px; font-size: 13px; transition: .15s;
}
.btn:hover { background: var(--bg-hover); }
.btn.primary { background: var(--green); border-color: var(--green); color: #05231a; font-weight: 600; }
.btn.primary:hover { background: var(--green-dark); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.user { display: flex; align-items: center; gap: 8px; color: var(--text-dim); font-size: 13px; }

.main { display: grid; grid-template-columns: 340px 1fr; min-height: 0; }

/* Sidebar */
.sidebar { background: var(--bg-2); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.oa-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.chip {
  padding: 5px 11px; border-radius: 16px; font-size: 12.5px; border: 1px solid var(--line);
  background: var(--bg-3); color: var(--text-dim); transition: .15s;
}
.chip:hover { background: var(--bg-hover); }
.chip.active { background: var(--green); color: #05231a; border-color: var(--green); font-weight: 600; }
.chip .cnt { opacity: .7; margin-left: 4px; }
.status-filter { display: flex; flex-wrap: wrap; gap: 5px; padding: 8px 12px 0; }
.sf-btn { padding: 4px 10px; font-size: 12px; border: 1px solid var(--line); background: var(--bg-3); color: var(--text-dim); border-radius: 14px; cursor: pointer; }
.sf-btn:hover { background: var(--bg-hover); }
.sf-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.hdr-flag { padding: 6px 9px; font-size: 14px; line-height: 1; opacity: .6; }
.hdr-flag:hover { opacity: 1; }
.hdr-flag.on { opacity: 1; background: var(--green); border-color: var(--green); }
.search { padding: 10px 12px; border-bottom: 1px solid var(--line); }
.search input {
  width: 100%; padding: 9px 12px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); font-size: 13px; outline: none;
}
.search input:focus { border-color: var(--green); }
.inbox { overflow-y: auto; flex: 1; min-height: 0; }
.chat-item {
  display: flex; gap: 11px; padding: 11px 12px; border-bottom: 1px solid var(--bg-3);
  cursor: pointer; transition: .12s; align-items: center;
}
.chat-item:hover { background: var(--bg-3); }
.inbox-load-more {
  display: block; width: 100%; padding: 12px; margin: 0; border: none; border-top: 1px solid var(--bg-3);
  background: var(--bg-2); color: var(--text-dim); font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.inbox-load-more:hover { background: var(--bg-3); color: var(--text); }
.chat-item.active { background: var(--bg-hover); border-left: 3px solid var(--green); padding-left: 9px; }
.avatar {
  width: 42px; height: 42px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-weight: 700; color: #fff; font-size: 16px;
}
.chat-meta { flex: 1; min-width: 0; }
.chat-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.chat-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-time { font-size: 11px; color: var(--text-faint); flex-shrink: 0; }
.chat-last { color: var(--text-dim); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.oa-tag { font-size: 10.5px; padding: 1px 7px; border-radius: 10px; color: #fff; margin-top: 4px; display: inline-block; }
.channel-badge { font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 8px; color: #fff; margin-top: 4px; margin-left: 4px; display: inline-block; letter-spacing: .3px; }
.channel-badge.ch-line { background: #06c755; }
.channel-badge.ch-web { background: #3b82f6; }
.chat-item.unread .chat-name { font-weight: 800; }
.chat-item.unread .chat-last { color: var(--text); font-weight: 600; }
.unread-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); box-shadow: 0 0 8px rgba(239,68,68,.7); flex-shrink: 0; margin-left: 6px; }
.avatar-wrap { position: relative; flex-shrink: 0; }
.avatar-wrap .badge-dot { position: absolute; top: -2px; right: -2px; width: 12px; height: 12px; border-radius: 50%; background: var(--danger); border: 2px solid var(--bg-2); }
.avatar-ch { width: 42px; text-align: center; font-size: 8px; font-weight: 800; letter-spacing: .4px; margin-top: 3px; padding: 1px 0; border-radius: 4px; color: #fff; }
.avatar-ch.ch-line { background: #06c755; }
.avatar-ch.ch-web { background: #3b82f6; }
.chip .unread-badge { background: var(--danger); color: #fff; border-radius: 10px; padding: 0 6px; font-size: 11px; margin-left: 5px; font-weight: 700; }

/* Conversation */
.conv { display: flex; min-height: 0; background: var(--bg); }
.conv > .empty { flex: 1; }
.conv-main { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }

/* Right sidebar: profile / note / hotkey */
.conv-side { width: 296px; flex-shrink: 0; border-left: 1px solid var(--line); background: var(--bg-2); overflow-y: auto; display: flex; flex-direction: column; }
.side-profile { padding: 18px 16px; text-align: center; border-bottom: 1px solid var(--line); }
.side-avatar { width: 72px; height: 72px; font-size: 28px; margin: 0 auto 10px; }
.side-name { font-weight: 700; font-size: 15px; }
.side-status { font-size: 12px; color: var(--text-dim); margin-top: 4px; }
.side-oa { margin-top: 8px; }
.side-copy { margin-top: 12px; font-size: 12px; padding: 6px 12px; }
.side-block { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.side-h { font-weight: 700; font-size: 13px; margin-bottom: 8px; display: flex; align-items: center; justify-content: space-between; }
.side-note { width: 100%; min-height: 78px; resize: vertical; padding: 9px 11px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font-size: 13px; font-family: inherit; outline: none; }
.side-note:focus { border-color: var(--green); }
.side-note-status { font-size: 11px; margin-top: 4px; min-height: 14px; }
.side-hotkey { flex: 1; }

/* Customer/Wallet Bridge card */
.bridge-card { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.bridge-row { display: flex; justify-content: space-between; align-items: center; font-size: 12.5px; }
.bridge-credit { color: var(--green); font-size: 14px; }
.bridge-tx { display: flex; gap: 10px; margin-top: 8px; }
.bridge-tx-col { flex: 1; min-width: 0; }
.bridge-tx-row { display: flex; justify-content: space-between; gap: 6px; font-size: 11.5px; padding: 2px 0; }
.bridge-tx-amt { font-weight: 700; }
.bridge-tx-amt.deposit { color: var(--green); }
.bridge-tx-amt.withdraw { color: var(--danger); }
.bridge-unbind { width: 100%; margin-top: 10px; font-size: 12px; padding: 6px; color: var(--danger); }
.bridge-search { display: flex; gap: 6px; }
.bridge-search input { flex: 1; padding: 7px 9px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font-size: 12.5px; font-family: inherit; outline: none; }
.bridge-search input:focus { border-color: var(--green); }
.bridge-search button { font-size: 12px; padding: 7px 12px; }
.bridge-result { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; margin-top: 6px; background: var(--bg-3); font-size: 12.5px; }
.bridge-result button { font-size: 11.5px; padding: 4px 10px; }
.hk-manage { padding: 3px 9px; font-size: 12px; }
.hk-list { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.hk-btn { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; padding: 7px 9px; border: 1px solid var(--line); background: var(--bg-3); color: var(--text); border-radius: 8px; cursor: pointer; text-align: left; }
.hk-btn:hover { background: var(--bg-hover); border-color: var(--green); }
.hk-key { font-size: 10px; background: var(--bg); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; color: var(--accent); font-weight: 700; }
.hk-lbl { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.hk-form { display: flex; gap: 8px; }
.hk-mgr-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 6px; background: var(--bg-3); }
.hk-mgr-body { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.hk-edit { padding: 5px 10px; font-size: 12.5px; }

/* Auto-reply rules */
.ar-item .hk-mgr-body { display: block; } /* stack name/meta/scope/preview lines, unlike hotkey's single-line layout */
.ar-row-top { display: flex; align-items: center; gap: 8px; margin-bottom: 3px; }
.ar-toggle { display: inline-flex; }
.ar-toggle input { width: 34px; height: 18px; accent-color: var(--green); cursor: pointer; }
.ar-sched-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 8px; }
.ar-sched-row .set-inp { margin-bottom: 0; }
@media (max-width: 1100px) { .conv-side { display: none; } }
.conv-header {
  display: flex; align-items: center; gap: 12px; padding: 12px 18px;
  background: var(--bg-2); border-bottom: 1px solid var(--line);
}
.conv-header .conv-name { font-weight: 700; font-size: 15px; }
.conv-header .conv-sub { color: var(--text-dim); font-size: 12px; }
.conv-title { flex-shrink: 0; }
.tags-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-left: 16px; max-width: 48%; }
.tags-bar .tags-label { font-size: 12px; color: var(--text-faint); margin-right: 2px; }
.tag-chip { display: inline-flex; align-items: center; gap: 5px; background: var(--accent); color: #fff; font-size: 12px; padding: 2px 4px 2px 9px; border-radius: 12px; }
.tag-chip button { background: rgba(255,255,255,.25); border: none; color: #fff; border-radius: 50%; width: 15px; height: 15px; font-size: 10px; cursor: pointer; line-height: 1; padding: 0; }
.tag-chip button:hover { background: rgba(255,255,255,.45); }
.tag-add { background: transparent; border: 1px dashed var(--line); color: var(--text-dim); font-size: 12px; padding: 3px 10px; border-radius: 12px; cursor: pointer; }
.tag-add:hover { border-color: var(--green); color: var(--green); }
.tag-input { background: var(--bg); border: 1px solid var(--green); color: var(--text); border-radius: 12px; padding: 3px 10px; font-size: 12px; font-family: inherit; outline: none; width: 180px; }
.mini-tag { display: inline-block; background: var(--accent); color: #fff; font-size: 10px; padding: 1px 7px; border-radius: 9px; margin-left: 4px; margin-top: 4px; }
.messages { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.msg { max-width: 68%; padding: 9px 13px; border-radius: 14px; font-size: 13.5px; line-height: 1.45; word-wrap: break-word; white-space: pre-wrap; }
.msg .t { display: block; font-size: 10px; margin-top: 4px; opacity: .65; }
.msg-tel-row { display: flex; align-items: center; gap: 6px; margin-top: 6px; padding-top: 6px; border-top: 1px solid rgba(0,0,0,.1); flex-wrap: wrap; }
.msg-tel-num { font-size: 12px; font-weight: 700; white-space: nowrap; }
.msg-tel-btn { padding: 3px 8px; font-size: 11.5px; white-space: nowrap; }
.msg-agent { display: inline-block; font-size: 10px; font-weight: 700; margin-top: 4px; padding: 1px 7px; border-radius: 8px; letter-spacing: .2px; }
.msg.out .msg-agent { background: rgba(5,35,26,.85); color: #fff; }
.msg.in .msg-agent { background: rgba(255,255,255,.12); color: var(--text); }
.msg.in { align-self: flex-start; background: var(--bubble-in); border-bottom-left-radius: 4px; }
.msg.out { align-self: flex-end; background: var(--bubble-out); color: #05231a; border-bottom-right-radius: 4px; }
.msg.non-text { font-style: italic; opacity: .85; }
.msg.media { padding: 4px; background: transparent !important; max-width: 300px; }
.msg.media .t { padding: 0 6px 2px; opacity: .8; }
.msg-img { max-width: 280px; max-height: 360px; border-radius: 10px; display: block; cursor: pointer; object-fit: cover; background: var(--bg-3); min-height: 40px; }
.msg-img:hover { opacity: .92; }
.msg.sticker { background: transparent !important; padding: 2px; }
.msg-sticker { width: 130px; height: 130px; object-fit: contain; }
.msg-video { max-width: 280px; max-height: 360px; border-radius: 10px; display: block; background: #000; min-height: 40px; }
.day-sep { align-self: center; font-size: 11px; color: var(--text-faint); background: var(--bg-2); padding: 3px 12px; border-radius: 12px; margin: 6px 0; }
.load-more { align-self: center; margin: 4px auto 10px; font-size: 12.5px; opacity: .9; }
.load-more:hover { opacity: 1; }
.composer { display: flex; gap: 10px; padding: 12px 16px; background: var(--bg-2); border-top: 1px solid var(--line); align-items: flex-end; }
.composer textarea {
  flex: 1; resize: none; min-height: 42px; max-height: 140px; padding: 10px 13px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text); font-size: 13.5px; font-family: inherit; outline: none;
}
.composer textarea:focus { border-color: var(--green); }
.composer .attach { align-self: flex-end; padding: 9px 11px; font-size: 16px; line-height: 1; }
.attach-preview { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--bg-2); border-top: 1px solid var(--line); }
.attach-preview img, .attach-preview video { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); background: #000; }
.attach-preview .pi-meta { flex: 1; font-size: 13px; line-height: 1.4; }
.attach-preview .pi-x { padding: 4px 11px; }

/* Quick-media (gif/mp4) attach UI — shared by hotkey manager + canned-reply manager */
.qm-attach-row { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.qm-preview { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; padding: 8px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; }
.qm-preview video { width: 90px; height: 90px; object-fit: cover; border-radius: 6px; background: #000; }
.qm-thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; background: #000; flex-shrink: 0; }

/* Modal + settings */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; z-index: 60; }

/* Full-size image viewer (click a chat image) */
.img-view-overlay { background: rgba(0,0,0,.85); cursor: zoom-out; }
.img-view-img { max-width: 92vw; max-height: 92vh; object-fit: contain; border-radius: 6px; box-shadow: var(--shadow); cursor: default; }
.img-view-close { position: fixed; top: 18px; right: 22px; width: 40px; height: 40px; padding: 0; font-size: 18px; border-radius: 50%; background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.3); color: #fff; }
.img-view-close:hover { background: rgba(255,255,255,.25); }
.modal { width: 640px; max-width: 94vw; max-height: 86vh; background: var(--bg-2); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--bg-3); }
.modal-head .tabs { display: flex; gap: 4px; }
.modal-head .tab { padding: 8px 14px; border: none; background: transparent; color: var(--text-dim); border-radius: 8px; font-size: 13.5px; font-weight: 600; }
.modal-head .tab:hover { background: var(--bg-hover); color: var(--text); }
.modal-head .tab.active { background: var(--green); color: #05231a; }
.modal-x { padding: 6px 11px; }
.modal-body { padding: 16px 18px; overflow-y: auto; }
.set-sec { margin-bottom: 22px; }
.set-sec h3 { margin: 0 0 10px; font-size: 14px; }
.set-inp { width: 100%; padding: 9px 11px; margin-bottom: 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font-size: 13.5px; font-family: inherit; outline: none; }
.set-inp:focus { border-color: var(--green); }
textarea.set-inp { min-height: 70px; resize: vertical; }
.set-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.set-scope { margin: 6px 0 10px; }
.scope-all { display: flex; gap: 7px; align-items: center; font-size: 13px; margin-bottom: 6px; cursor: pointer; }
.scope-oas { display: flex; gap: 14px; flex-wrap: wrap; padding: 8px 10px; background: var(--bg-3); border-radius: 8px; }
.scope-oas label { display: flex; gap: 6px; align-items: center; font-size: 13px; cursor: pointer; }
.cp-badge { font-size: 10.5px; background: var(--bg-hover); color: var(--text-dim); padding: 1px 7px; border-radius: 9px; margin-left: 4px; }
.canned-mgr .cm-item, .user-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; margin-bottom: 8px; background: var(--bg-3); }
.cm-body { flex: 1; min-width: 0; }
.cm-title { font-weight: 600; font-size: 13.5px; }
.cm-text { color: var(--text-dim); font-size: 12.5px; margin: 3px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cm-scope { margin-top: 3px; }
.user-info { flex: 1; font-size: 13.5px; }
.user-acts { display: flex; gap: 6px; }
.user-acts .btn, .canned-mgr .cp-del, .user-acts .cp-del, .canned-mgr .cp-edit { padding: 5px 10px; font-size: 12.5px; }
.cp-del { border: 1px solid var(--line); background: var(--bg); color: var(--danger); border-radius: 7px; cursor: pointer; }
.cp-edit { border: 1px solid var(--line); background: var(--bg); color: var(--green); border-radius: 7px; cursor: pointer; }
.cp-del:hover { background: var(--bg-hover); }

/* Broadcast */
.bc-lbl { display: block; font-size: 13px; color: var(--text-dim); margin: 10px 0 5px; }
.bc-targets { display: flex; gap: 20px; margin-bottom: 4px; }
.bc-targets label { display: flex; align-items: center; gap: 7px; font-size: 13.5px; cursor: pointer; }
.bc-imgrow { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.bc-deepsync-row { display: flex; align-items: center; gap: 10px; margin: 10px 0 4px; }
.bc-deepsync-row .btn { font-size: 12.5px; padding: 6px 12px; }
.bc-range-box { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin: 4px 0 8px; }
.bc-range-quick { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.bc-range-quick .btn { font-size: 12px; padding: 5px 10px; }
.bc-range-custom { display: flex; gap: 14px; flex-wrap: wrap; }
.bc-range-custom label { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-dim); }
.bc-range-custom input[type=date] { padding: 5px 8px; font-size: 12.5px; }
.bc-redeem-toggle { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-dim); cursor: pointer; margin: 10px 0 5px; }
.bc-delay-mode { display: flex; gap: 18px; margin: 2px 0 6px; }
.bc-delay-mode label { display: flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
.bc-delay-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-dim); }
.bc-bar { height: 14px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.bc-bar-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--green), var(--green-dark)); transition: width .3s; }
.bc-progress h3 { margin: 0 0 10px; }
#bcStats { margin-top: 8px; font-size: 13px; }
.bc-job { padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 7px; background: var(--bg-3); position: relative; }
.bc-job-del { position: absolute; top: 7px; right: 9px; padding: 2px 7px; font-size: 12px; }
.bc-jobs-tabs { display: flex; gap: 8px; margin: 4px 0 8px; }
.bc-jobs-tabs .bc-jt { font-size: 12px; padding: 5px 12px; }
.bc-jobs-tabs .bc-jt.active { background: var(--green); border-color: var(--green); color: #05231a; font-weight: 600; }

/* Sticker picker */
.sticker-panel { position: fixed; bottom: 74px; left: 356px; width: 360px; max-height: 340px; overflow-y: auto;
  background: var(--bg-3); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); z-index: 40; padding: 10px; }
.sticker-panel .sp-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.sticker-panel .sp-item { width: 100%; aspect-ratio: 1; object-fit: contain; border-radius: 8px; cursor: pointer; padding: 4px; background: var(--bg-2); }
.sticker-panel .sp-item:hover { background: var(--bg-hover); transform: scale(1.06); }

/* Canned replies panel */
.canned-panel { position: fixed; bottom: 74px; left: 356px; width: 360px; max-height: 60vh; display: flex; flex-direction: column;
  background: var(--bg-3); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); z-index: 40; overflow: hidden; }
.canned-panel .cp-head { display: flex; align-items: center; justify-content: space-between; padding: 11px 13px; border-bottom: 1px solid var(--line); font-weight: 600; }
.canned-panel .cp-add { padding: 4px 10px; font-size: 12.5px; }
.canned-panel .cp-list { overflow-y: auto; flex: 1; }
.canned-panel .cp-item { display: flex; align-items: center; gap: 8px; padding: 9px 13px; border-bottom: 1px solid var(--bg-2); }
.canned-panel .cp-item:hover { background: var(--bg-hover); }
.canned-panel .cp-body { flex: 1; min-width: 0; cursor: pointer; }
.canned-panel .cp-title { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.canned-panel .cp-text { color: var(--text-dim); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.canned-panel .cp-del { background: transparent; border: none; color: var(--text-faint); font-size: 14px; cursor: pointer; padding: 4px 6px; border-radius: 6px; }
.canned-panel .cp-del:hover { color: var(--danger); background: var(--bg-2); }
.canned-panel .cp-form { padding: 11px 13px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.canned-panel .cp-form input, .canned-panel .cp-form textarea { width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font-size: 13px; font-family: inherit; outline: none; }
.canned-panel .cp-form textarea { min-height: 64px; resize: vertical; }
.canned-panel .cp-form input:focus, .canned-panel .cp-form textarea:focus { border-color: var(--green); }
.canned-panel .cp-form-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* Empty / centered states */
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; color: var(--text-faint); gap: 10px; text-align: center; padding: 24px; }
.empty .big { font-size: 40px; }
.muted { color: var(--text-dim); }
.spin { width: 16px; height: 16px; border: 2px solid var(--line); border-top-color: var(--green); border-radius: 50%; animation: sp 0.7s linear infinite; display: inline-block; }
@keyframes sp { to { transform: rotate(360deg); } }

/* Toast + notifications (top-right, stacking downward) */
#toasts { position: fixed; top: 66px; right: 18px; display: flex; flex-direction: column; gap: 10px; z-index: 55; max-width: 360px; }
.toast { background: var(--bg-3); border: 1px solid var(--line); box-shadow: var(--shadow); padding: 10px 14px; border-radius: 10px; font-size: 13px; min-width: 220px; animation: slidein .22s; }
.toast.ok { border-left: 3px solid var(--green); }
.toast.err { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--accent); }
@keyframes slidein { from { transform: translateX(24px); opacity: 0; } }

/* Prominent incoming-message card */
.msg-notif {
  display: flex; align-items: center; gap: 12px; width: 340px; padding: 12px 14px;
  background: var(--bg-3); border: 2px solid var(--green); border-left: 6px solid var(--green);
  border-radius: 12px; box-shadow: 0 10px 30px rgba(6,199,85,.28), var(--shadow);
  cursor: pointer; animation: notif-in .25s ease; position: relative;
}
.msg-notif:hover { background: var(--bg-hover); }
.msg-notif .avatar { flex-shrink: 0; }
.msg-notif .mn-body { flex: 1; min-width: 0; }
.msg-notif .mn-name { font-weight: 700; font-size: 13.5px; display: flex; align-items: center; gap: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-notif .mn-text { color: var(--text-dim); font-size: 12.5px; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.msg-notif .mn-x { position: absolute; top: 6px; right: 8px; background: transparent; border: none; color: var(--text-faint); font-size: 13px; cursor: pointer; padding: 2px 5px; border-radius: 6px; }
.msg-notif .mn-x:hover { color: var(--text); background: var(--bg-2); }
@keyframes notif-in { from { transform: translateX(30px) scale(.96); opacity: 0; } }

@media (max-width: 820px) {
  .main { grid-template-columns: 1fr; }
  .sidebar.hide-mobile { display: none; }
  .conv.hide-mobile { display: none; }
}
