:root {
  --c: #307AE8;
  --c-dark: #1f5fc4;
  --bg: #eef2f6;
  --ink: #1f2a37;
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
}
.im {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 100%;
  background: #fff;
}
.im-head {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  background: linear-gradient(180deg, var(--c), var(--c-dark));
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 1px 0 rgba(0,0,0,.06);
}
.im-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,.22);
  overflow: hidden;
  flex-shrink: 0;
  border: 2px solid rgba(255,255,255,.45);
}
.im-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.im-head-text { flex: 1; min-width: 0; }
.im-head-text b { display: block; font-size: 16px; font-weight: 600; }
.im-head-text small { opacity: .9; font-size: 12px; }
.im-head-text small.offline { opacity: .95; }
.im-head-actions { display: flex; gap: 4px; }
.im-icon {
  width: 32px;
  height: 32px;
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  border-radius: 6px;
}
.im-icon:hover { background: rgba(255,255,255,.16); }
.im-body {
  flex: 1;
  overflow: auto;
  padding: 16px 14px 8px;
  background: #eef2f6;
}
.msg {
  display: flex;
  gap: 8px;
  margin: 14px 0;
  align-items: flex-end;
}
.msg.mine { flex-direction: row-reverse; }
.face {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--c);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 12px;
  flex-shrink: 0;
  overflow: hidden;
}
.face img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.msg.mine .face { background: #94a3b8; }
.msg .bubble {
  max-width: 74%;
  padding: 10px 12px;
  border-radius: 4px 12px 12px 12px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(16,24,40,.06);
  white-space: pre-wrap;
  word-break: break-word;
}
.msg.mine .bubble {
  background: var(--c);
  color: #fff;
  border-radius: 12px 4px 12px 12px;
}
.msg.system { justify-content: center; }
.msg.system .bubble {
  background: transparent;
  box-shadow: none;
  color: #667085;
  font-size: 12px;
  max-width: 90%;
  padding: 0;
}
.msg time { display: block; font-size: 11px; opacity: .55; margin-top: 4px; }
.im-quick {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px 12px;
  background: #fff;
  border-top: 1px solid #e6ebf0;
}
.im-quick button {
  border: 1px solid #d0d5dd;
  background: #fff;
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
  color: var(--c);
}
.im-quick button:hover { background: #f5f8ff; }
.im-form {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 10px;
  background: #fff;
  border-top: 1px solid #e6ebf0;
}
.im-form textarea {
  flex: 1;
  resize: none;
  border: 1px solid #d0d5dd;
  border-radius: 8px;
  padding: 10px;
  font: inherit;
  max-height: 96px;
  min-height: 40px;
  outline: none;
}
.im-form textarea:focus { border-color: var(--c); }
.im-form button[type="submit"] {
  background: var(--c);
  color: #fff;
  border: 0;
  border-radius: 8px;
  padding: 10px 16px;
  font-weight: 700;
  cursor: pointer;
  height: 40px;
}
.im-form button:disabled { opacity: .5; }
.im-attach {
  width: 40px;
  height: 40px;
  border: 1px solid #d0d5dd;
  background: #fff;
  border-radius: 8px;
  cursor: pointer;
  color: #667085;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.im-attach:hover { background: #f5f8ff; color: var(--c); border-color: var(--c); }
.file-img { display: block; }
.file-img img {
  max-width: 220px;
  max-height: 180px;
  border-radius: 6px;
  display: block;
  background: #fff;
}
.file-meta { font-size: 11px; opacity: .7; margin-top: 4px; }
.file-card {
  display: flex;
  gap: 8px;
  align-items: center;
  text-decoration: none;
  color: inherit;
  background: rgba(15, 23, 42, .06);
  border-radius: 8px;
  padding: 8px 10px;
  max-width: 240px;
}
.msg.mine .file-card { background: rgba(255,255,255,.16); }
.file-card b, .file-card small { display: block; }
.file-card small { opacity: .7; font-size: 11px; }
.file-icon { font-size: 18px; }
.im-body.drop { outline: 2px dashed var(--c); outline-offset: -8px; }
.im-foot {
  text-align: center;
  font-size: 11px;
  color: #98a2b3;
  padding: 6px 0 10px;
  background: #fff;
}
body.embedded .im-close { display: inline-grid; }
.im-close { display: none; }
