
    .im-layout {
      display: flex;
      flex: 1;
      height: 100%;
      min-height: 0;
      border: 1px solid #e9ecef;
      border-radius: 10px;
      overflow: hidden;
      background: #fff;
    }

    .im-sidebar {
      width: 320px;
      min-width: 280px;
      border-right: 1px solid #e9ecef;
      display: flex;
      flex-direction: column;
      background: #fafbfc;
      flex-shrink: 0;
    }

    .im-sidebar-head {
      padding: 14px 14px 10px;
      border-bottom: 1px solid #eef0f2;
      background: #fff;
    }

    .im-search {
      width: 100%;
      height: 38px;
      padding: 0 14px 0 36px;
      border: 1px solid #e8e8e8;
      border-radius: 8px;
      background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%23999' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85zm-5.242.656a5 5 0 1 1 0-10 5 5 0 0 1 0 10z'/%3E%3C/svg%3E") no-repeat 12px center;
      font-size: 14px;
      color: #333;
      outline: none;
      box-sizing: border-box;
    }

    .im-search:focus {
      border-color: #0d6efd;
      box-shadow: 0 0 0 3px rgba(13, 110, 253, .12);
    }

    .im-list-scroll {
      flex: 1;
      overflow-y: auto;
    }

    .im-list {
      list-style: none;
      margin: 0;
      padding: 0;
    }

    .im-item {
      border-bottom: 1px solid #f0f0f0;
    }

    .im-item:last-child {
      border-bottom: none;
    }

    .im-item.is-hidden {
      display: none;
    }

    .im-link {
      display: flex;
      align-items: center;
      gap: 12px;
      width: 100%;
      padding: 14px 16px;
      border: none;
      background: transparent;
      text-align: left;
      color: inherit;
      cursor: pointer;
      transition: background .15s;
    }

    .im-link:hover,
    .im-item.is-active .im-link {
      background: #eef4ff;
    }

    .im-item.is-active .im-link {
      box-shadow: inset 3px 0 0 #0d6efd;
    }

    .im-avatar {
      width: 44px;
      height: 44px;
      border-radius: 8px;
      object-fit: cover;
      flex-shrink: 0;
      background: #eee;
    }

    .im-body {
      flex: 1;
      min-width: 0;
    }

    .im-title-row {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
      margin-bottom: 4px;
    }

    .im-name {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      min-width: 0;
      font-size: 14px;
      font-weight: 600;
      color: #222;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .im-admin-tag {
      display: inline-flex;
      align-items: center;
      flex-shrink: 0;
      padding: 1px 8px;
      border-radius: 999px;
      background: #e7f1ff;
      color: #0d6efd;
      font-size: 11px;
      font-weight: 600;
      line-height: 1.4;
      text-transform: lowercase;
    }

    .im-time {
      font-size: 12px;
      color: #aaa;
      white-space: nowrap;
      flex-shrink: 0;
    }

    .im-preview {
      font-size: 13px;
      color: #888;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      line-height: 1.4;
    }

    .im-empty,
    .im-loading {
      text-align: center;
      padding: 48px 20px;
      color: #999;
      font-size: 14px;
    }

    .im-empty i {
      display: block;
      font-size: 42px;
      color: #ddd;
      margin-bottom: 12px;
    }

    .im-empty p {
      margin: 0;
      color: #666;
    }

    .im-chat-panel {
      flex: 1;
      min-width: 0;
      min-height: 0;
      display: flex;
      flex-direction: column;
      background: #f5f6f8;
      overflow: hidden;
    }

    .im-chat-placeholder {
      flex: 1;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      color: #aaa;
      padding: 40px 24px;
      text-align: center;
    }

    .im-chat-placeholder i {
      font-size: 56px;
      color: #ddd;
      margin-bottom: 16px;
    }

    .im-chat-placeholder p {
      margin: 0;
      font-size: 15px;
      color: #888;
    }

    .im-chat-header {
      display: flex;
      align-items: center;
      gap: 12px;
      padding: 14px 20px;
      border-bottom: 1px solid #eef0f2;
      background: #fff;
      flex-shrink: 0;
    }

    .im-chat-back {
      display: none;
      width: 34px;
      height: 34px;
      border: none;
      border-radius: 8px;
      background: #f3f4f6;
      color: #555;
      cursor: pointer;
      flex-shrink: 0;
    }

    .im-chat-back:hover {
      background: #e9ecef;
    }

    .im-chat-header-name-row {
      display: flex;
      align-items: center;
      gap: 8px;
      flex-wrap: wrap;
    }

    .im-chat-header-name {
      font-size: 16px;
      font-weight: 600;
      color: #222;
    }

    .im-chat-header-meta {
      font-size: 12px;
      color: #999;
      margin-top: 2px;
    }

    .im-messages {
      flex: 1;
      min-height: 0;
      overflow-x: hidden;
      overflow-y: auto;
      background: #f5f6f8;
      overscroll-behavior: contain;
      -webkit-overflow-scrolling: touch;
    }

    .im-messages-inner {
      min-height: 100%;
      display: flex;
      flex-direction: column;
      justify-content: flex-end;
      padding: 16px 20px;
      box-sizing: border-box;
    }

    .im-msg-time-divider {
      display: flex;
      align-items: center;
      justify-content: center;
      margin: 4px 0 10px;
      flex-shrink: 0;
    }

    .im-msg-time-divider span {
      display: inline-block;
      padding: 4px 12px;
      border-radius: 999px;
      background: rgba(0, 0, 0, 0.06);
      color: #888;
      font-size: 12px;
      line-height: 1.4;
      white-space: nowrap;
    }

    .im-msg {
      display: flex;
      margin-bottom: 14px;
    }

    .im-msg.is-self {
      justify-content: flex-end;
    }

    .im-msg-bubble {
      max-width: 68%;
      padding: 10px 14px;
      border-radius: 12px;
      font-size: 14px;
      line-height: 1.5;
      word-break: break-word;
    }

    .im-msg.is-other .im-msg-bubble {
      background: #fff;
      color: #333;
      border: 1px solid #e8eaed;
      border-bottom-left-radius: 4px;
    }

    .im-msg.is-self .im-msg-bubble {
      background: #fff;
      color: #333;
      border: 1px solid #e8eaed;
      border-bottom-right-radius: 4px;
    }

    .im-msg.is-self .im-msg-bubble.is-image {
      background: #fff;
      border: 1px solid #e8eaed;
      border-bottom-right-radius: 4px;
    }

    .im-msg-time {
      font-size: 11px;
      color: #aaa;
      margin-top: 4px;
      text-align: right;
    }

    .im-msg.is-other .im-msg-time {
      text-align: left;
    }

    .im-msg-image {
      display: block;
      max-width: 220px;
      max-height: 220px;
      border-radius: 8px;
    }

    .im-msg-file {
      color: inherit;
      text-decoration: underline;
    }

    .im-msg.is-self .im-msg-file {
      color: #333;
    }

    .im-messages-empty,
    .im-messages-loading {
      min-height: 100%;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      color: #bbb;
      font-size: 14px;
      box-sizing: border-box;
      padding: 16px 20px;
    }

    .im-messages-empty i {
      font-size: 36px;
      margin-bottom: 10px;
    }

    .im-composer {
      padding: 12px 16px 14px;
      border-top: 1px solid #eef0f2;
      background: #fff;
      flex-shrink: 0;
    }

    .im-composer-toolbar {
      display: flex;
      align-items: center;
      gap: 6px;
      margin-bottom: 8px;
    }

    .im-composer-tool {
      width: 34px;
      height: 34px;
      border: none;
      border-radius: 8px;
      background: #f3f4f6;
      color: #666;
      cursor: pointer;
      display: inline-flex;
      align-items: center;
      justify-content: center;
    }

    .im-composer-tool:hover {
      background: #e9ecef;
      color: #333;
    }

    .im-composer-tool.is-active {
      background: #eef4ff;
      color: #0d6efd;
    }

    .im-composer-tool.is-idle {
      background: #f8f9fa;
      color: #c5c9cf;
    }

    .im-composer-tool.is-idle:hover {
      background: #f0f1f3;
      color: #adb5bd;
    }

.im-composer-tool.is-disabled,
.im-composer-tool:disabled {
  background: #f8f9fa;
  color: #d0d4da;
  opacity: 1;
  cursor: not-allowed;
  pointer-events: none;
}

.im-composer-tool-textbook:not(:disabled) {
  background: #eef4ff;
  color: #0d6efd;
}

.im-composer-tool-textbook:not(:disabled):hover {
  background: #dbe7ff;
  color: #0b5ed7;
}

.im-composer-tool.is-hidden {
  display: none;
}

    .im-composer-file-name {
      flex: 1;
      min-width: 0;
      font-size: 12px;
      color: #888;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .im-composer-row {
      display: flex;
      align-items: flex-end;
      gap: 10px;
    }

    .im-composer-input {
      flex: 1;
      min-height: 42px;
      max-height: 120px;
      padding: 10px 14px;
      border: 1px solid #e0e0e0;
      border-radius: 10px;
      font-size: 14px;
      line-height: 1.45;
      resize: none;
      outline: none;
      font-family: inherit;
      box-sizing: border-box;
    }

    .im-composer-input:focus {
      border-color: #0d6efd;
      box-shadow: 0 0 0 3px rgba(13, 110, 253, .1);
    }

    .im-composer-send {
      height: 42px;
      padding: 0 18px;
      border: none;
      border-radius: 10px;
      background: #0d6efd;
      color: #fff;
      font-size: 14px;
      font-weight: 500;
      cursor: pointer;
      flex-shrink: 0;
    }

    .im-composer-send:hover {
      background: #0b5ed7;
    }

    .im-composer-send:disabled {
      background: #b6d4fe;
      cursor: not-allowed;
    }

    .im-composer-pending {
      font-size: 12px;
      color: #888;
      margin-top: 8px;
    }

    .im-composer-pending.is-hidden {
      display: none;
    }

    #im_send_form.is-hidden {
      display: none !important;
    }

    .im-composer.is-text-disabled .im-composer-input:disabled {
      background: #f5f6f8;
      color: #aaa;
      border-color: #e8eaed;
      cursor: not-allowed;
    }

    .im-composer.is-text-disabled .im-composer-input:disabled:focus {
      border-color: #e8eaed;
      box-shadow: none;
    }

    .im-composer.is-text-disabled .im-composer-send:disabled {
      background: #e9ecef;
      color: #adb5bd;
    }

    .im-chat-body {
      flex: 1;
      min-height: 0;
      display: flex;
      flex-direction: column;
    }

    .im-chat-body.is-hidden {
      display: none;
    }

    @media (max-width: 768px) {
      .im-page-root {
        height: calc(100vh - 180px);
      }

      .im-sidebar {
        width: 100%;
        border-right: none;
      }

      .im-layout.has-chat .im-sidebar {
        display: none;
      }

      .im-layout.has-chat .im-chat-panel {
        display: flex;
      }

      .im-chat-back {
        display: inline-flex;
        align-items: center;
        justify-content: center;
      }
    }
  
.ddt-im-overlay {
  position: fixed;
  inset: 0;
  z-index: 10050;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.ddt-im-overlay.is-hidden { display: none; }
.ddt-im-panel {
  width: min(960px, 100%);
  height: min(720px, calc(100vh - 32px));
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 16px 48px rgba(0,0,0,.18);
}
.ddt-im-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid #eef0f2;
  flex-shrink: 0;
}
.ddt-im-panel-title { font-size: 16px; font-weight: 600; color: #222; }
.ddt-im-panel-close {
  width: 34px; height: 34px; border: none; border-radius: 8px;
  background: #f3f4f6; color: #555; cursor: pointer; font-size: 20px; line-height: 1;
}
.ddt-im-panel-body { flex: 1; min-height: 0; padding: 0; display: flex; flex-direction: column; overflow: hidden; }
.ddt-im-root {
  position: relative;
  flex: 1;
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.ddt-im-panel-body .im-layout { height: 100%; min-height: 0; flex: 1; border: none; border-radius: 0; }
.ddt-im-float {
  position: fixed; right: 20px; bottom: 24px; z-index: 10040;
}
.ddt-im-float-btn {
  width: 52px; height: 52px; border: none; border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff; cursor: pointer; box-shadow: 0 8px 24px rgba(102,126,234,.45);
  display: flex; align-items: center; justify-content: center; font-size: 22px; position: relative;
}
.ddt-im-float-btn:hover { filter: brightness(1.05); }
.ddt-im-float-badge {
  position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px;
  padding: 0 5px; border-radius: 9px; background: #f03e3e; color: #fff;
  font-size: 11px; font-weight: 600; line-height: 18px; text-align: center;
}
.ddt-im-float-badge.is-hidden { display: none; }
.im-page-root {
  height: calc(100vh - 220px);
  min-height: 480px;
  display: flex;
  flex-direction: column;
}
.im-page-root .im-layout { height: 100%; min-height: 0; flex: 1; }

.im-msg-bubble.is-card { padding: 12px 14px; width: 100%; max-width: 300px; white-space: normal; }
.im-msg-card-title { font-size: 15px; font-weight: 600; color: #222; margin-bottom: 6px; }
.im-msg-card-desc { font-size: 13px; color: #666; margin-top: 8px; line-height: 1.5; }
.im-msg-card-params { border-top: 1px solid #eef0f2; padding-top: 8px; margin-top: 8px; }
.im-msg-card-row { display: flex; gap: 8px; font-size: 13px; line-height: 1.6; margin-bottom: 4px; }
.im-msg-card-row:last-child { margin-bottom: 0; }
.im-msg-card-label { color: #888; flex-shrink: 0; }
.im-msg-card-value { color: #333; word-break: break-word; }
.im-msg-card-link { display: block; color: inherit; text-decoration: none; }
.im-msg-card-footer { border-top: 1px solid #eef0f2; margin-top: 10px; padding-top: 8px; display: flex; justify-content: flex-end; }
.im-msg-card-arrow { color: #bbb; font-size: 14px; }
.im-unread-badge { flex-shrink: 0; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: #f03e3e; color: #fff; font-size: 11px; font-weight: 600; line-height: 18px; text-align: center; }
.im-preview-row { display: flex; align-items: center; gap: 8px; }
.im-preview { flex: 1; min-width: 0; }
.im-msg-avatar { width: 36px; height: 36px; border-radius: 6px; object-fit: cover; flex-shrink: 0; background: #eee; }
.im-msg-avatar.is-placeholder { visibility: hidden; }
.im-msg.is-other { justify-content: flex-start; align-items: flex-start; gap: 10px; }
.im-msg-inner { max-width: 68%; min-width: 0; }

.im-textbook-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  background: rgba(15, 23, 42, .42);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.im-textbook-overlay.is-hidden { display: none; }
.im-textbook-dialog {
  width: min(420px, 100%);
  max-height: min(560px, calc(100% - 32px));
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 16px 48px rgba(0, 0, 0, .18);
}
.im-textbook-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid #eef0f2;
  flex-shrink: 0;
}
.im-textbook-head-title {
  flex: 1;
  font-size: 15px;
  font-weight: 600;
  color: #222;
  text-align: center;
}
.im-textbook-back,
.im-textbook-close {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: #f3f4f6;
  color: #555;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.im-textbook-back.is-hidden { visibility: hidden; pointer-events: none; }
.im-textbook-close { font-size: 20px; line-height: 1; }
.im-textbook-back:hover,
.im-textbook-close:hover { background: #e9ecef; }
.im-textbook-step {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}
.im-textbook-step.is-hidden { display: none; }
.im-textbook-search-wrap { padding: 12px 14px 0; flex-shrink: 0; }
.im-textbook-search {
  width: 100%;
  height: 38px;
  padding: 0 14px 0 36px;
  border: 1px solid #e8e8e8;
  border-radius: 8px;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%23999' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85zm-5.242.656a5 5 0 1 1 0-10 5 5 0 0 1 0 10z'/%3E%3C/svg%3E") no-repeat 12px center;
  font-size: 14px;
  color: #333;
  outline: none;
  box-sizing: border-box;
}
.im-textbook-search:focus {
  border-color: #0d6efd;
  box-shadow: 0 0 0 3px rgba(13, 110, 253, .12);
}
.im-textbook-list,
.im-textbook-level-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 14px 14px;
}
.im-textbook-category {
  margin-bottom: 14px;
}
.im-textbook-category:last-child {
  margin-bottom: 0;
}
.im-textbook-category-title {
  font-size: 12px;
  font-weight: 600;
  color: #666;
  letter-spacing: .02em;
  padding: 2px 2px 8px;
  border-bottom: 1px solid #eef0f2;
  margin-bottom: 8px;
}
.im-textbook-loading,
.im-textbook-empty {
  text-align: center;
  color: #999;
  font-size: 14px;
  padding: 28px 12px;
}
.im-textbook-book-item,
.im-textbook-level-item {
  width: 100%;
  border: 1px solid #eef0f2;
  border-radius: 10px;
  background: #fff;
  padding: 10px 12px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.im-textbook-book-item:hover,
.im-textbook-level-item:hover {
  background: #f8fbff;
  border-color: #cfe2ff;
}
.im-textbook-book-cover {
  width: 42px;
  height: 58px;
  border-radius: 6px;
  object-fit: cover;
  background: #f3f4f6;
  flex-shrink: 0;
}
.im-textbook-book-meta,
.im-textbook-selected-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.im-textbook-book-title {
  font-size: 14px;
  font-weight: 600;
  color: #222;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.im-textbook-book-subtitle {
  font-size: 12px;
  color: #888;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.im-textbook-book-tag {
  display: inline-flex;
  align-self: flex-start;
  margin-top: 2px;
  padding: 1px 8px;
  border-radius: 999px;
  background: #f3f4f6;
  color: #666;
  font-size: 11px;
}
.im-textbook-book-arrow { color: #bbb; flex-shrink: 0; }
.im-textbook-selected { padding: 12px 14px 0; flex-shrink: 0; }
.im-textbook-selected-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid #eef0f2;
  border-radius: 10px;
  background: #fafbfc;
}
.im-textbook-level-name {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
  color: #222;
}
.im-textbook-level-action {
  font-size: 12px;
  font-weight: 600;
  color: #0d6efd;
}

.swal2-container.ddt-im-swal-container {
  z-index: 10100 !important;
}
