:root{
  --imz-primary: var(--mb-color-primary,#d81bff);
  --imz-primary-dark: var(--mb-color-primary-hover,#b600da);
  --imz-bg:#f4f5fb;
  --imz-card:#fff;
  --imz-border:rgba(29,33,41,.08);
  --imz-text:#101828;
  --imz-muted:#667085;
  --imz-soft:#eef1f8;
  --imz-shadow:0 18px 40px rgba(17,24,39,.08);
}
.im-button-green{background:var(--imz-primary);color:#fff!important;border:none;box-shadow:none;display:inline-flex;align-items:center;justify-content:center;gap:8px}
.im-button-green:hover{background:var(--imz-primary-dark);color:#fff!important}
.imz-page-wrap{padding:24px 0 34px}
.imz-page-head{display:flex;align-items:flex-end;justify-content:space-between;gap:12px;margin-bottom:18px}
.imz-page-head h1{font-size:32px;line-height:1.1;margin:0 0 6px;color:var(--imz-text)}
.imz-page-head p{margin:0;color:var(--imz-muted)}
.imz-page-actions{display:flex;align-items:center;gap:10px;flex-wrap:wrap}
.imz-page-pill{padding:10px 14px;border-radius:999px;background:#fff;border:1px solid var(--imz-border);text-decoration:none;color:var(--imz-text);font-weight:700}
button.imz-page-pill{cursor:pointer}

.imz-app{display:grid;grid-template-columns:360px minmax(0,1fr);gap:18px;min-height:76vh}
.imz-sidebar,.imz-chat-panel{background:var(--imz-card);border:1px solid var(--imz-border);border-radius:28px;box-shadow:var(--imz-shadow);overflow:hidden}
.imz-sidebar{display:flex;flex-direction:column;min-height:0}
.imz-sidebar-head{display:flex;align-items:center;justify-content:space-between;padding:18px 20px;border-bottom:1px solid var(--imz-border)}
.imz-sidebar-head h2{margin:0 0 4px;font-size:20px;color:var(--imz-text)}
.imz-sidebar-head span{font-size:13px;color:var(--imz-muted)}
.imz-mobile-close-list,.imz-mobile-back,.imz-mobile-open-list{display:none}
.imz-search-box{padding:14px 16px;border-bottom:1px solid var(--imz-border);background:linear-gradient(180deg,#fff,#fafbff)}
.imz-search-box input{width:100%;height:46px;border:1px solid var(--imz-border);border-radius:16px;background:var(--imz-bg);padding:0 16px;font:inherit}
.imz-thread-list{display:flex;flex-direction:column;overflow:auto;max-height:calc(76vh - 126px)}
.imz-thread-row{display:flex;align-items:center;gap:12px;padding:14px 16px;border-bottom:1px solid rgba(0,0,0,.04);text-decoration:none;color:inherit;transition:.2s ease;background:#fff}
.imz-thread-row:hover{background:#fafaff}
.imz-thread-row.active{background:linear-gradient(180deg,rgba(216,27,255,.09),rgba(216,27,255,.04))}
.imz-thread-row.im-unread .im-title{font-weight:800}
.imz-avatar img,.imz-chat-user>img{width:52px;height:52px;border-radius:50%;object-fit:cover;display:block;box-shadow:0 8px 16px rgba(0,0,0,.08)}
.imz-thread-main{flex:1;min-width:0;text-align:right}
.imz-thread-top{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-bottom:6px}
.imz-thread-top strong{font-size:14px;color:var(--imz-text)}
.im-time{font-size:12px;color:var(--imz-muted);white-space:nowrap}
.imz-thread-item-row{display:flex;flex-direction:row-reverse;align-items:center;justify-content:flex-start;gap:10px;min-width:0}
.imz-thread-item-thumb{width:34px;height:34px;border-radius:12px;object-fit:cover;flex:0 0 auto;border:1px solid rgba(0,0,0,.06);background:#eef2f7}
.imz-thread-item-texts{min-width:0;flex:1}
.imz-thread-item{font-size:13px;font-weight:700;color:#374151;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.im-from-to{font-size:12px;color:var(--imz-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin-top:2px}
.imz-badge{min-width:24px;height:24px;padding:0 7px;border-radius:999px;background:var(--imz-primary);color:#fff;font-size:12px;font-weight:800;display:flex;align-items:center;justify-content:center}
.imz-empty-side{padding:42px 24px;color:var(--imz-muted);text-align:center}

.imz-chat-panel{display:flex;flex-direction:column;min-width:0;background:linear-gradient(180deg,#fff,#fdfdff)}
.imz-chat-head{display:flex;align-items:center;justify-content:space-between;gap:14px;padding:16px 18px;border-bottom:1px solid var(--imz-border);background:rgba(255,255,255,.94);backdrop-filter:blur(8px)}
.imz-chat-user-wrap,.imz-chat-user,.imz-chat-user-meta{display:flex;align-items:center;gap:12px;min-width:0}
.imz-chat-user{flex-direction:row-reverse}.imz-chat-user-meta{flex-direction:column;align-items:flex-start;gap:6px;text-align:right}
.imz-chat-user strong{display:block;font-size:16px;color:var(--imz-text);line-height:1.2}
.imz-chat-item-card{display:flex;flex-direction:row-reverse;align-items:center;gap:10px;min-width:0;max-width:340px;background:#f8fafc;border:1px solid var(--imz-border);padding:7px 10px;border-radius:16px}
.imz-chat-item-thumb{width:38px;height:38px;border-radius:12px;object-fit:cover;flex:0 0 auto;border:1px solid rgba(0,0,0,.06);background:#eef2f7}
.imz-chat-item-card span{font-size:13px;color:var(--imz-muted);line-height:1.45;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
.imz-chat-actions{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
.imz-open-item,.imz-mobile-open-list,.imz-mobile-back,.imz-mobile-close-list{padding:10px 14px;border-radius:999px;background:var(--imz-soft);text-decoration:none;font-weight:700;color:var(--imz-text);border:none;cursor:pointer}
.imz-open-item:hover,.imz-mobile-open-list:hover,.imz-mobile-back:hover,.imz-mobile-close-list:hover{background:#e8ebf4}

.imz-messages{flex:1;display:flex;flex-direction:column;gap:10px;overflow:auto;padding:22px;background:radial-gradient(circle at top left,rgba(216,27,255,.08),transparent 24%),radial-gradient(circle at bottom right,rgba(65,105,225,.08),transparent 22%),linear-gradient(180deg,#fafbff 0%,#f3f5fb 100%);min-height:360px;max-height:calc(76vh - 240px)}
.imz-bubble-row{display:flex}
.imz-bubble-row.mine{justify-content:flex-end}
.imz-bubble-row.theirs{justify-content:flex-start}
.imz-bubble{max-width:min(74%,780px);padding:12px 14px;border-radius:24px;background:#fff;color:var(--imz-text);box-shadow:0 10px 24px rgba(17,24,39,.06);border:1px solid rgba(0,0,0,.03)}
.imz-bubble-row.mine .imz-bubble{background:linear-gradient(180deg,var(--imz-primary),var(--imz-primary-dark));color:#fff;border-bottom-right-radius:8px}
.imz-bubble-row.theirs .imz-bubble{border-bottom-left-radius:8px}
.imz-bubble-text{font-size:14px;line-height:1.75;word-break:break-word;text-align:right}
.imz-bubble-actions{display:flex;justify-content:flex-start;margin-top:8px}.imz-report-btn{display:inline-flex;align-items:center;gap:6px;padding:5px 10px;border-radius:999px;border:1px solid rgba(217,45,32,.16);background:#fff;color:#b42318;font-size:11px;font-weight:800;cursor:pointer;touch-action:manipulation;box-shadow:0 4px 10px rgba(17,24,39,.05)}.imz-report-btn .imz-report-flag{font-size:12px;line-height:1}
.imz-report-btn:hover{background:#fff7f7}.imz-report-btn.is-loading{opacity:.72;cursor:progress}.imz-report-btn.is-done{background:#ecfdf3;border-color:rgba(18,183,106,.18);color:#027a48;cursor:default}
.imz-bubble-meta{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-top:8px}
.imz-bubble-time{font-size:11px;opacity:.82}
.imz-read-state{font-size:11px;font-weight:700;opacity:.95}
.imz-read-state.read{opacity:1}
.imz-read-state.sent{opacity:.82}
.imz-bubble-row.theirs .imz-read-state{display:none}

.imz-attachments{display:flex;flex-direction:column;gap:8px;margin-top:8px}
.imz-attachment-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}
.imz-attachment-grid.count-1{grid-template-columns:1fr}
.imz-attachment-image{display:block;border-radius:16px;overflow:hidden;background:rgba(255,255,255,.12)}
.imz-attachment-image img{display:block;width:100%;height:220px;object-fit:cover}

.imz-composer{padding:16px 18px;border-top:1px solid var(--imz-border);background:#fff;display:flex;flex-direction:column;gap:10px}
.imz-composer-top{display:flex;align-items:center;justify-content:space-between;gap:10px;flex-wrap:wrap}
.imz-attach-btn{display:inline-flex;align-items:center;gap:10px;padding:10px 14px;border-radius:16px;background:var(--imz-soft);color:var(--imz-text);cursor:pointer;font-weight:700}
.imz-attach-btn em{font-style:normal;color:var(--imz-muted);font-weight:600}
.imz-attach-hint{font-size:12px;color:var(--imz-muted)}
#imzAttachmentInput{display:none}
.imz-attachment-preview{display:flex;flex-wrap:wrap;gap:8px}
.imz-preview-chip{display:inline-flex;align-items:center;gap:8px;padding:10px 12px;border-radius:14px;background:#f5f7fb;border:1px solid var(--imz-border);font-size:12px;max-width:100%}
.imz-preview-chip img{width:34px;height:34px;border-radius:10px;object-fit:cover}
.imz-preview-chip strong{max-width:180px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.imz-composer-main{display:grid;grid-template-columns:minmax(0,1fr) 122px;gap:12px;align-items:end}
.imz-composer textarea{resize:none;min-height:54px;max-height:180px;padding:16px 18px;border:1px solid var(--imz-border);border-radius:22px;background:var(--imz-bg);font:inherit;line-height:1.6;color:var(--imz-text)}
.imz-composer button[type=submit]{min-height:54px;border-radius:20px;font-weight:800}

.imz-empty-panel,.imz-empty-chat{display:flex;align-items:center;justify-content:center;flex-direction:column;text-align:center;color:var(--imz-muted)}
.imz-empty-panel{height:100%;padding:50px 24px}
.imz-empty-chat{min-height:180px;padding:18px}
.imz-empty-panel .icon{font-size:48px;margin-bottom:14px}
.imz-empty-panel h2{margin:0 0 10px;color:var(--imz-text)}
.imz-empty-panel p{max-width:420px;margin:0 0 16px}

.imz-thread-list::-webkit-scrollbar,.imz-messages::-webkit-scrollbar{width:8px;height:8px}
.imz-thread-list::-webkit-scrollbar-thumb,.imz-messages::-webkit-scrollbar-thumb{background:rgba(152,162,179,.55);border-radius:999px}

html[mode="dark"] .imz-sidebar,html[mode="dark"] .imz-chat-panel,html[mode="dark"] .imz-page-pill,html[mode="dark"] .imz-search-box input,html[mode="dark"] .imz-composer textarea,html[mode="dark"] .imz-preview-chip,html[mode="dark"] .imz-chat-item-card{background:#1d1f26;color:#fff;border-color:rgba(255,255,255,.08)}
html[mode="dark"] .imz-page-head h1,html[mode="dark"] .imz-thread-top strong,html[mode="dark"] .imz-chat-user strong,html[mode="dark"] .imz-thread-item,html[mode="dark"] .imz-open-item,html[mode="dark"] .imz-mobile-open-list,html[mode="dark"] .imz-mobile-back,html[mode="dark"] .imz-mobile-close-list{color:#fff}
html[mode="dark"] .imz-page-head p,html[mode="dark"] .im-time,html[mode="dark"] .im-from-to,html[mode="dark"] .imz-chat-item-card span,html[mode="dark"] .imz-sidebar-head span,html[mode="dark"] .imz-attach-hint,html[mode="dark"] .imz-attach-btn em{color:#b5bcc8}
html[mode="dark"] .imz-messages{background:linear-gradient(180deg,#14161b 0%,#1b1f26 100%)}
html[mode="dark"] .imz-bubble-row.theirs .imz-bubble{background:#242934;color:#fff}
html[mode="dark"] .imz-chat-head,html[mode="dark"] .imz-sidebar-head,html[mode="dark"] .imz-search-box,html[mode="dark"] .imz-composer{background:#1a1d24;border-color:rgba(255,255,255,.06)}
html[mode="dark"] .imz-thread-row{background:#1d1f26;border-color:rgba(255,255,255,.04)}
html[mode="dark"] .imz-thread-row:hover,html[mode="dark"] .imz-thread-row.active{background:#252933}

@media (max-width:980px){
  .imz-page-head{flex-direction:column;align-items:flex-start}
  .imz-app{grid-template-columns:1fr;min-height:auto;position:relative}
  .imz-sidebar,.imz-chat-panel{border-radius:24px}
  .imz-thread-list{max-height:none}
  .imz-messages{max-height:58vh;min-height:46vh;padding:16px}
  .imz-composer-main{grid-template-columns:1fr}
  .imz-composer button[type=submit]{width:100%}
  .imz-mobile-open-list,.imz-mobile-back,.imz-mobile-close-list{display:inline-flex;align-items:center;justify-content:center}
  .imz-app.has-thread.mobile-chat .imz-sidebar{display:none}
  .imz-app.has-thread.mobile-chat .imz-chat-panel{display:flex}
  .imz-app.has-thread .imz-chat-panel{display:flex}
  .imz-app.has-thread:not(.mobile-chat) .imz-chat-panel{display:none}
  .imz-app.no-thread .imz-sidebar{display:flex}
  .imz-bubble{max-width:88%}
  .imz-chat-head{padding:14px;align-items:flex-start}
  .imz-chat-user-wrap{flex:1;min-width:0}
  .imz-chat-user{align-items:flex-start;flex-direction:row-reverse}
  .imz-chat-user>img{width:48px;height:48px}
  .imz-chat-user-meta{min-width:0;flex:1}
  .imz-chat-item-card{max-width:100%;padding:6px 8px;border-radius:14px}
  .imz-chat-item-thumb{width:30px;height:30px;border-radius:10px}
  .imz-chat-item-card span{font-size:12px;-webkit-line-clamp:2}
  .imz-chat-actions{width:auto;flex:0 0 auto}
  .imz-open-item{padding:9px 12px;font-size:13px}
}

@media (max-width:640px){
  .imz-page-wrap{padding-top:14px}
  .imz-page-head h1{font-size:26px}
  .imz-page-pill{padding:9px 12px}
  .imz-sidebar-head,.imz-search-box{padding-inline:12px}
  .imz-thread-row{padding:12px;align-items:flex-start}
  .imz-avatar img{width:44px;height:44px}
  .imz-thread-top{gap:6px;align-items:flex-start}
  .imz-thread-main{overflow:hidden}
  .imz-thread-item-thumb{width:28px;height:28px;border-radius:9px}
  .imz-attachment-image img{height:160px}
  .imz-bubble{padding:12px}
}

.imz-admin-messages{scrollbar-width:thin;overscroll-behavior:contain}
.imz-admin-thread-list,.imz-admin-reports-list{scrollbar-width:thin;overscroll-behavior:contain}
