:root {
  --bg: #f5f6fa;
  --panel: #ffffff;
  --sidebar: #f1f3f9;
  --text: #1f2430;
  --muted: #7a8194;
  --line: #e5e8f0;
  --accent: #4f46e5;
  --accent-dark: #4338ca;
  --accent-soft: #eef2ff;
  --danger: #dc2626;
  --ok: #16a34a;
  --bubble-in: #ffffff;
  --bubble-out: #4f46e5;
  --shadow: 0 10px 30px rgba(31, 36, 48, 0.08);
  --topbar: #1f2430;
  --card: #fbfcfe;
  --card-soft: #f8fafc;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
}
button { font: inherit; cursor: pointer; }
input, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--danger); font-size: 13px; margin: 8px 0 0; }

/* ---------- login ---------- */
.login-view {
  height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(1200px 500px at 20% -10%, #e0e7ff 0%, transparent 60%),
    radial-gradient(900px 500px at 110% 10%, #e0f2fe 0%, transparent 55%),
    var(--bg);
  padding: 24px;
}
.login-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 28px;
}
.brand { display: flex; gap: 14px; align-items: center; margin-bottom: 20px; }
.brand h1 { font-size: 22px; margin: 0; }
.brand p { margin: 4px 0 0; font-size: 13px; }
.logo {
  width: 34px; height: 34px; border-radius: 10px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff; font-weight: 800;
}
.logo.big { width: 48px; height: 48px; border-radius: 14px; font-size: 24px; }
.field { display: block; margin-bottom: 14px; font-size: 13px; color: var(--muted); }
.field input {
  width: 100%; margin-top: 6px; padding: 11px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: #fbfcfe;
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); background: #fff; }
.field.compact { margin-bottom: 12px; }
.login-actions { display: flex; gap: 10px; margin-top: 18px; }
.login-actions .primary { flex: 1; }
.hint { margin: 14px 0 0; font-size: 12px; color: var(--muted); }

/* ---------- buttons ---------- */
.primary {
  background: var(--accent); color: #fff; border: 0; border-radius: 10px;
  padding: 11px 16px; font-weight: 600; transition: background .15s;
}
.primary:hover { background: var(--accent-dark); }
.primary.small, .ghost.small { padding: 7px 11px; font-size: 13px; border-radius: 8px; }
.ghost {
  background: #fff; border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; padding: 11px 16px;
}
.ghost:hover { border-color: #cfd5e4; background: #fafbff; }
.ghost.danger, .danger { color: var(--danger); }
.ghost.light { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.18); color: #eef0f6; }
.ghost.light:hover { background: rgba(255,255,255,.16); }
.icon {
  background: transparent; border: 0; font-size: 16px; color: var(--muted);
  padding: 6px 8px; border-radius: 8px;
}
.icon:hover { background: var(--accent-soft); color: var(--accent); }

/* ---------- app shell ---------- */
.app-view { height: 100vh; display: flex; flex-direction: column; }
.topbar {
  height: 58px; background: var(--topbar); color: #eef0f6;
  display: flex; align-items: center; gap: 16px; padding: 0 16px;
  flex: 0 0 auto; position: relative; z-index: 30;
}
.brand-small { display: flex; align-items: center; gap: 9px; font-weight: 700; letter-spacing: .2px; }
.conn { display: flex; align-items: center; gap: 7px; font-size: 12px; color: #b9c0d0; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.dot.off { background: #9aa3b5; }
.dot.warn { background: #f59e0b; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.me-chip {
  background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.15);
  padding: 6px 10px; border-radius: 999px; font-size: 12px; max-width: 180px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.layout { flex: 1; display: flex; min-height: 0; }
.sidebar {
  width: 300px; flex: 0 0 300px; background: var(--sidebar);
  border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0;
}
.tabs { display: flex; padding: 10px 10px 0; gap: 6px; }
.tab {
  flex: 1; border: 0; background: transparent; padding: 9px 10px;
  border-radius: 9px; color: var(--muted); font-weight: 600;
}
.tab.active { background: #fff; color: var(--accent); box-shadow: 0 1px 3px rgba(31,36,48,.06); }
.pane { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.sidebar-tools { display: flex; gap: 6px; padding: 10px 10px 4px; }
.sidebar-tools input {
  flex: 1; border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; background: #fff;
}
.conv-list { flex: 1; overflow-y: auto; padding: 6px; }
.conv-item {
  display: flex; gap: var(--imkit-conv-avatar-gap, 10px);
  padding: var(--imkit-conv-pad-y, 10px) var(--imkit-conv-pad-x, 16px);
  border-radius: 12px; cursor: pointer; border: 1px solid transparent;
  min-height: var(--imkit-conv-row-height, 72px); box-sizing: border-box;
}
.conv-item:hover { background: #fff; border-color: var(--line); }
.conv-item.active { background: #fff; border-color: #dfe3ef; box-shadow: 0 1px 4px rgba(31,36,48,.05); }
.avatar {
  width: 40px; height: 40px; border-radius: 12px; flex: 0 0 40px;
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 15px;
}
.conv-main { flex: 1; min-width: 0; }
.conv-top { display: flex; align-items: center; gap: 6px; }
.conv-title { font-weight: 600; font-size: var(--imkit-conv-title-size, 15px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pin-mark { font-size: 11px; color: var(--accent); background: var(--accent-soft); padding: 1px 6px; border-radius: 999px; }
.conv-time { margin-left: auto; font-size: var(--imkit-conv-time-size, 11px); color: var(--muted); flex: 0 0 auto; }
.conv-bottom { display: flex; align-items: center; gap: 8px; margin-top: 3px; }
.conv-preview {
  flex: 1; font-size: var(--imkit-conv-preview-size, 12px); color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.badge {
  background: var(--danger); color: #fff; font-size: 11px; min-width: 18px;
  height: 18px; padding: 0 5px; border-radius: 999px; display: grid; place-items: center;
}
.empty.small { padding: 18px; text-align: center; font-size: 12px; color: var(--muted); }
.contact-box { padding: 14px; }
.row { display: flex; gap: 8px; align-items: center; }
.row input { flex: 1; margin-top: 0 !important; }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
.contact-result { margin-top: 8px; font-size: 12px; min-height: 16px; }
.presence-list { margin-top: 10px; font-size: 12px; }

/* ---------- chat ---------- */
.chat { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--bg); }
.chat-empty { flex: 1; display: grid; place-content: center; text-align: center; padding: 24px; }
.empty-emoji { font-size: 46px; margin-bottom: 8px; }
.chat-empty h2 { margin: 6px 0; font-size: 18px; }
.chat-empty p { margin: 0; font-size: 13px; }
.chat-main { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.chat-header {
  height: var(--imkit-nav-height, 64px); background: var(--panel); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; padding: 0 18px; flex: 0 0 auto;
}
.chat-header h2 { margin: 0; font-size: var(--imkit-nav-title-size, 17px); line-height: 24px; }
.chat-header .sub { margin: 2px 0 0; font-size: var(--imkit-nav-subtitle-size, 12px); line-height: 16px; }
.chat-actions { display: flex; gap: 8px; }
.message-list { flex: 1; overflow-y: auto; padding: 18px 20px 8px; }
.day-sep { text-align: center; font-size: var(--imkit-msg-time-size, 11px); color: var(--muted); margin: var(--imkit-msg-time-margin, 14px) 0; }
.msg-time-sep { text-align: var(--imkit-time-align, center); font-size: var(--imkit-msg-time-size, 11px); color: var(--muted); margin: var(--imkit-msg-time-margin, 14px) 0 6px; }
.message-item {
  display: flex; gap: var(--imkit-bubble-avatar-gap, 10px);
  margin-bottom: var(--imkit-bubble-row-gap, 14px); align-items: flex-start;
}
.message-item.outgoing { flex-direction: row-reverse; }
.msg-avatar {
  width: 34px; height: 34px; border-radius: 10px; flex: 0 0 34px;
  display: grid; place-items: center; color: #fff; font-size: 13px; font-weight: 700;
}
.msg-body {
  max-width: min(var(--imkit-bubble-max-px, 560px), calc(var(--imkit-bubble-max-ratio, 0.68) * 100%));
  display: flex; flex-direction: column; gap: 4px;
}
.message-item.outgoing .msg-body { align-items: flex-end; }
.msg-sender { font-size: 11px; color: var(--muted); padding: 0 4px; }
.bubble {
  background: var(--bubble-in); border: 1px solid var(--line);
  border-radius: var(--imkit-bubble-radius, 8px);
  padding: var(--imkit-bubble-pad-y, 12px) var(--imkit-bubble-pad-x, 12px);
  font-size: var(--imkit-bubble-font-size, 14px);
  line-height: var(--imkit-bubble-line-height, 21px);
  word-break: break-word; box-shadow: 0 1px 2px rgba(31,36,48,.04);
}
.message-item.outgoing .bubble { background: var(--bubble-out); color: #fff; border-color: transparent; }
.msg-meta { font-size: 11px; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.msg-recall { color: var(--muted); font-style: italic; }
.bubble img.msg-image { max-width: 260px; max-height: 220px; border-radius: 10px; display: block; cursor: zoom-in; }
.msg-file { display: flex; gap: 10px; align-items: center; text-decoration: none; color: inherit; }
.msg-file .file-icon { font-size: 22px; }
.msg-file .file-meta { display: flex; flex-direction: column; }
.msg-file .file-name { font-weight: 600; }
.message-item.outgoing .msg-file, .message-item.outgoing .file-meta { color: #fff; }
.msg-actions { display: none; gap: 6px; margin-top: 2px; }
.message-item:hover .msg-actions { display: flex; }
.msg-actions button {
  border: 1px solid var(--line); background: #fff; border-radius: 7px;
  font-size: 11px; padding: 2px 7px; color: var(--muted);
}
.msg-actions button:hover { color: var(--accent); border-color: var(--accent); }
.msg-read { font-size: 11px; color: var(--accent); }
.message-item.outgoing .msg-read { color: rgba(255,255,255,.85); }

/* ---------- rev12: message reaction / expansion ---------- */
.demo-extras {
  display: flex; flex-direction: column; gap: 4px; align-items: flex-start;
  margin-top: 4px; position: relative;
}
.message-item.outgoing .demo-extras { align-items: flex-end; }
.demo-actions-row { display: none; gap: 6px; align-items: center; }
.message-item:hover .demo-actions-row,
.demo-extras:focus-within .demo-actions-row { display: flex; }
.demo-action {
  border: 1px solid var(--line); background: #fff; border-radius: 7px;
  font-size: 11px; padding: 2px 8px; color: var(--muted); line-height: 18px;
}
.demo-action:hover { color: var(--accent); border-color: var(--accent); }
.demo-action.primary { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.demo-action.danger { color: var(--danger); border-color: #fecaca; }
.reaction-picker {
  display: inline-flex; gap: 2px; padding: 4px 6px; border-radius: 999px;
  background: #fff; border: 1px solid var(--line); box-shadow: var(--shadow);
}
.reaction-option {
  border: 0; background: transparent; border-radius: 999px;
  font-size: 18px; line-height: 24px; padding: 2px 6px; cursor: pointer;
}
.reaction-option:hover { background: var(--accent-soft); transform: translateY(-1px); }
.reaction-option.active { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }
.reaction-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.reaction-chip {
  display: inline-flex; align-items: center; gap: 3px;
  border: 1px solid var(--line); background: #fff; border-radius: 999px;
  padding: 1px 8px 1px 6px; font-size: 12px; color: var(--muted); cursor: pointer;
}
.reaction-chip:hover { border-color: var(--accent); background: var(--accent-soft); }
.reaction-chip.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.reaction-chip .reaction-emoji { font-size: 14px; line-height: 18px; }
.reaction-chip .reaction-count { font-weight: 600; font-size: 11px; }
.expansion-badge {
  display: inline-flex; align-items: center; gap: 4px;
  border: 1px solid #a5b4fc; background: #e0e7ff; color: #3730a3;
  border-radius: 8px; padding: 3px 10px; font-size: 12px; font-weight: 600;
}
.expansion-picker {
  display: flex; flex-wrap: wrap; gap: 6px; padding: 6px;
  border: 1px solid var(--line); background: #fff; border-radius: 10px; box-shadow: var(--shadow);
}
.reaction-users-popover {
  position: fixed; z-index: 70; width: 280px; max-height: 360px;
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 18px 40px rgba(15, 23, 42, .22); display: flex; flex-direction: column;
}
.reaction-users-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; border-bottom: 1px solid var(--line); font-weight: 600; font-size: 13px;
}
.reaction-users-head .modal-close { border: 0; background: transparent; cursor: pointer; color: var(--muted); }
.reaction-users-list { overflow: auto; padding: 6px 8px; display: flex; flex-direction: column; gap: 4px; }
.reaction-user-row { display: flex; align-items: center; gap: 8px; padding: 4px 2px; }
.reaction-user-main { min-width: 0; }
.reaction-user-name { font-size: 12px; font-weight: 600; }
.reaction-users-foot {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; border-top: 1px solid var(--line); gap: 8px;
}

.composer {
  background: var(--panel); border-top: 1px solid var(--line);
  padding: 6px 14px; flex: 0 0 auto;
  display: flex; flex-wrap: wrap; align-items: flex-end;
  box-sizing: border-box; gap: var(--imkit-input-panel-gap, 8px);
  min-height: var(--imkit-input-bar-height, 54px);
}
.composer > .quote-bar { flex: 0 0 100%; }
.composer-tools { display: flex; gap: var(--imkit-input-btn-gap, 6px); align-items: center; flex: 0 0 auto; }
.tool {
  border: 1px solid var(--line); background: #fff; border-radius: 8px;
  padding: 5px 9px; font-size: 12px; color: var(--muted);
  display: inline-flex; align-items: center; justify-content: center;
  width: var(--imkit-input-btn-size, 34px); height: var(--imkit-input-btn-size, 34px);
  padding: 0; overflow: hidden; flex: 0 0 auto;
}
.tool .tool-text { display: none; }
.tool .tool-ico { font-size: 15px; line-height: 1; }
.tool:hover { color: var(--accent); border-color: var(--accent); }
.composer-hint { margin-left: auto; font-size: 11px; }
#composer-input {
  flex: 1 1 auto; min-width: 0; width: auto; resize: none; border: 1px solid var(--line);
  border-radius: var(--imkit-input-radius, 18px);
  padding: var(--imkit-input-pad-y, 8px) var(--imkit-input-pad-x, 12px);
  min-height: var(--imkit-input-min-height, 38px);
  max-height: var(--imkit-input-max-height, 120px);
  outline: none; background: #fbfcfe; box-sizing: border-box;
}
#composer-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); background: #fff; }
.composer-send { flex: 0 0 auto; display: flex; justify-content: flex-end; align-items: center; gap: 8px; }
.composer-send .primary {
  width: var(--imkit-send-width, 41px); height: var(--imkit-send-height, 34px);
  border-radius: var(--imkit-send-radius, 8px); padding: 0; box-sizing: border-box;
  font-size: 14px; line-height: 1; display: inline-flex; align-items: center; justify-content: center;
}

/* ---------- modals ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .38);
  backdrop-filter: blur(2px); z-index: 40;
}
.modal {
  position: fixed; z-index: 50; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(520px, calc(100vw - 32px)); max-height: 86vh; overflow: auto;
  background: #fff; border-radius: 16px; box-shadow: 0 24px 60px rgba(15,23,42,.25);
  display: flex; flex-direction: column;
}
.modal.wide { width: min(760px, calc(100vw - 32px)); }
.modal-head, .modal-foot {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--line);
}
.modal-foot { border-top: 1px solid var(--line); border-bottom: 0; justify-content: flex-end; gap: 8px; }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 16px 18px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.section-title { margin: 8px 0; font-size: 13px; color: var(--muted); }
.manage-members { display: flex; flex-direction: column; gap: 6px; }
.member-row { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; }
.member-name { font-weight: 600; font-size: 13px; }
.role-tag { font-size: 10px; padding: 1px 6px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.role-tag.muted { background: #fef2f2; color: var(--danger); }
.search-results { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; max-height: 48vh; overflow: auto; }
.search-hit { padding: 9px 10px; border: 1px solid var(--line); border-radius: 9px; cursor: pointer; }
.search-hit:hover { border-color: var(--accent); background: var(--accent-soft); }
.search-hit .hit-meta { font-size: 11px; color: var(--muted); }
.toasts { position: fixed; right: 18px; bottom: 118px; z-index: 80; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast {
  background: #1f2430; color: #fff; padding: 10px 14px; border-radius: 10px;
  font-size: 13px; box-shadow: var(--shadow); max-width: 340px;
}
.toast.error { background: #7f1d1d; }

@media (max-width: 860px) {
  .sidebar { width: 240px; flex-basis: 240px; }
  .grid2 { grid-template-columns: 1fr; }
  .msg-body { max-width: 84%; }
}

/* ---------- v1.8: mentions / typing / read users ---------- */
.mention {
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 4px;
  padding: 0 3px;
  font-weight: 600;
}
.message-item.outgoing .mention { background: rgba(255,255,255,.22); color: #fff; }
.mention-badge {
  background: #f59e0b; color: #fff; font-size: 10px; font-weight: 700;
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  display: grid; place-items: center;
}
.typing-bar {
  padding: 4px 20px 0; font-size: 12px; color: var(--accent); min-height: 18px;
}
.mention-members { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; max-height: 44vh; overflow: auto; }
.mention-row {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 10px; cursor: pointer;
}
.mention-row.checked { border-color: var(--accent); background: var(--accent-soft); }
.mention-row input { accent-color: var(--accent); }
.mention-actions { display: flex; align-items: center; gap: 10px; }
.read-list { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; max-height: 46vh; overflow: auto; }
.read-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; }
.read-main { min-width: 0; flex: 1 1 auto; }
.read-state { flex: 0 0 auto; font-size: 11px; color: var(--muted); }
.read-row[data-read="true"] .read-state { color: var(--accent); }
.read-row[data-read="false"] .read-state { color: var(--danger, #dc2626); }
.read-time { flex: 0 0 auto; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.read-group { display: flex; flex-direction: column; gap: 6px; }
.read-group-head {
  display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--muted);
}
.read-group-head span {
  display: inline-flex; align-items: center; justify-content: center; min-width: 16px; height: 16px;
  padding: 0 5px; border-radius: 999px; font-size: 10px; background: var(--accent-soft); color: var(--accent);
}
.msg-read { cursor: pointer; }
.msg-read:hover { text-decoration: underline; }

/* ---------- v1.9: voice / location / quote / group notice ---------- */
.notice-bar {
  margin: 0 20px 8px; padding: 8px 12px; border-radius: 10px;
  background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412;
  font-size: 12px; white-space: pre-wrap; word-break: break-word;
}
.quote-bar {
  display: flex; align-items: center; gap: 8px; padding: 6px 20px 0;
  font-size: 12px; color: var(--muted);
}
.quote-bar .quote-label { color: var(--accent); font-weight: 600; }
#quote-preview { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quote-block {
  border-left: 3px solid var(--accent); background: var(--accent-soft);
  padding: 4px 8px; border-radius: 6px; margin-bottom: 6px;
  font-size: 12px; color: var(--muted); max-width: 420px;
}
.quote-block .quote-label { color: var(--accent); font-weight: 600; margin-right: 4px; }
.voice-player { display: flex; align-items: center; gap: 8px; min-width: 180px; }
.voice-player audio { height: 32px; max-width: 240px; }
.voice-duration { font-size: 12px; color: var(--muted); }
.msg-location { display: flex; flex-direction: column; gap: 2px; min-width: 200px; }
.msg-location .loc-address { font-weight: 600; }
.msg-location .loc-coords { font-size: 12px; color: var(--muted); }
.tool.recording { background: #fee2e2; color: #b91c1c; border-color: #fca5a5; }

/* ---------- v1.10: friend relations ---------- */
.contact-section { margin-bottom: 12px; }
.contact-title { font-size: 12px; font-weight: 600; color: var(--muted); margin: 8px 0 6px; display: flex; align-items: center; gap: 6px; }
.friend-results, .friend-requests, .friend-list { display: flex; flex-direction: column; gap: 6px; max-height: 220px; overflow: auto; }
.friend-row {
  display: flex; align-items: center; gap: 8px; padding: 7px 8px;
  border: 1px solid var(--line); border-radius: 10px;
}
.friend-main { flex: 1; min-width: 0; }
.friend-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.friend-actions { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.friend-actions button { padding: 2px 6px; font-size: 11px; }

/* v1.10 layout fix: friend rows stack vertically in narrow sidebar */
.friend-row { flex-wrap: wrap; align-items: center; }
.friend-main { flex: 1 1 calc(100% - 52px); min-width: 0; }
.friend-actions { flex: 1 1 100%; justify-content: flex-start; }
.friend-name { max-width: 100%; }

/* ---------- v2.0: IMKit 组件宿主布局 ---------- */
/* #conv-list 是 IMKit ConversationListView 的挂载宿主；内部 .conv-list 才是滚动容器 */
#conv-list {
  display: flex; flex-direction: column; min-height: 0;
  overflow: hidden; padding: 0;
}
#conv-list > .conv-list { flex: 1; overflow-y: auto; padding: 6px; }
#conv-list .mute-mark { font-size: 11px; opacity: .75; }
#chat-main { overflow: hidden; }
.imkit-chat-host {
  flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative;
}
.imkit-chat-host > .imkit-chat-view {
  flex: 1; min-height: 0; display: flex; flex-direction: column;
}
.imkit-chat-host .message-list { min-height: 0; }
.imkit-chat-host .composer { flex: 0 0 auto; }
.imkit-chat-host .new-messages-tip {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: 128px; z-index: 8;
  background: var(--accent); color: #fff; border: 0; border-radius: 999px;
  padding: 5px 12px; font-size: 12px; box-shadow: var(--shadow); cursor: pointer;
}
.imkit-chat-host .msg-time-sep { text-align: center; font-size: 11px; color: var(--muted); margin: 6px 0; }
.imkit-chat-host .system-message { text-align: center; margin: 10px 0; }
.imkit-chat-host .system-message .system-text {
  display: inline-block; font-size: 12px; color: var(--muted);
  background: rgba(122, 129, 148, .12); padding: 4px 10px; border-radius: 999px;
}
.imkit-chat-host .msg-status { font-size: 11px; color: var(--muted); }
.imkit-chat-host .msg-status-sending { display: inline-flex; align-items: center; gap: 4px; }
.imkit-chat-host .msg-status-failed { color: var(--danger); cursor: pointer; }
.imkit-chat-host .msg-spinner {
  display: inline-block; width: 9px; height: 9px; border: 2px solid currentColor;
  border-top-color: transparent; border-radius: 50%; animation: imkit-spin .7s linear infinite;
}
@keyframes imkit-spin { to { transform: rotate(360deg); } }

/* ---------- 登录页 UIUX 增强（演示环境标识 / 快速填充 / 产品链导航） ---------- */

.env-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 2px 0 12px;
  padding: 7px 10px;
  border: 1px solid rgba(93, 106, 255, 0.28);
  background: rgba(93, 106, 255, 0.08);
  border-radius: 8px;
}

.env-badge {
  flex: none;
  padding: 1px 8px;
  border-radius: 999px;
  background: #5d6aff;
  color: #fff;
  font-size: 11px;
  letter-spacing: .04em;
}

.env-note {
  color: #6b7280;
  font-size: 12px;
  line-height: 1.5;
}

.quick-login {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin: 2px 0 12px;
}

.quick-label {
  color: #9aa3b2;
  font-size: 12px;
  margin-right: 2px;
}

.chip {
  padding: 4px 11px;
  border: 1px solid #dfe3ea;
  border-radius: 999px;
  background: #fff;
  color: #4a5261;
  font-size: 12.5px;
  font-family: inherit;
  cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
}

.chip:hover {
  border-color: #5d6aff;
  color: #5d6aff;
  background: rgba(93, 106, 255, 0.06);
}

.login-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed #e5e8ef;
  font-size: 12.5px;
}

.login-foot a {
  color: #6b7280;
}

.login-foot a:hover {
  color: #5d6aff;
}

/* ---------- demo parity: 弱网/重连横幅 ---------- */

.net-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 18px;
  font-size: 12.5px;
  border-bottom: 1px solid transparent;
  background: #fff7ed;
  color: #9a3412;
  border-bottom-color: #fed7aa;
}

.net-banner.warn {
  background: #fffbeb;
  color: #92400e;
  border-bottom-color: #fde68a;
}

.net-banner.danger {
  background: #fef2f2;
  color: #b91c1c;
  border-bottom-color: #fecaca;
}

.net-banner-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: 0 0 8px;
  background: currentColor;
  animation: net-pulse 1.4s ease-in-out infinite;
}

.net-banner #btn-net-retry {
  margin-left: auto;
  padding: 4px 10px;
  font-size: 12px;
  color: inherit;
  border-color: currentColor;
  background: transparent;
}

@keyframes net-pulse {
  0%, 100% { opacity: .35; }
  50% { opacity: 1; }
}

/* ---------- demo parity: 会话设置抽屉 ---------- */

.settings-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .32);
  z-index: 45;
}

.settings-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(380px, 92vw);
  background: #fff;
  border-left: 1px solid var(--line);
  box-shadow: -18px 0 42px rgba(15, 23, 42, .18);
  z-index: 46;
  display: flex;
  flex-direction: column;
}

.settings-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

.settings-head h3 {
  margin: 0;
  font-size: 16px;
}

.settings-body {
  padding: 16px 18px 22px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.settings-target {
  display: flex;
  align-items: center;
  gap: 12px;
}

.settings-target .avatar {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  font-size: 16px;
  border-radius: 12px;
}

.settings-target-main { min-width: 0; }
.settings-title { font-weight: 700; font-size: 15px; }
.settings-section h4 {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .04em;
  color: var(--muted);
  text-transform: uppercase;
}

.setting-option {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-bottom: 6px;
  font-size: 13px;
  cursor: pointer;
}

.setting-option:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.setting-option input { accent-color: var(--accent); }

.settings-action {
  display: block;
  width: 100%;
  text-align: left;
  margin-bottom: 6px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  font-size: 13px;
  color: #384054;
  cursor: pointer;
}

.settings-action:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.settings-action:disabled {
  opacity: .55;
  cursor: not-allowed;
  background: #f8fafc;
}

.settings-section #settings-gap {
  margin-top: 6px;
  line-height: 1.6;
}

/* ---------- demo parity: 输入区表情 / 扩展面板 ---------- */

.demo-panel-trigger.active,
.tool.active {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}

.composer-panels {
  flex: 0 0 auto; border-top: 1px solid var(--line); background: var(--panel);
  padding: 10px 14px 12px;
}
#extension-panel { min-height: var(--imkit-ext-panel-height, 282px); box-sizing: border-box; }

.panel-title {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 8px;
}

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(var(--imkit-emoji-columns, 7), var(--imkit-emoji-cell-size, 46px));
  gap: 4px; justify-content: start;
}

.emoji-option {
  border: 1px solid transparent; border-radius: 8px; background: transparent;
  font-size: 19px; line-height: 1;
  width: var(--imkit-emoji-cell-size, 46px); height: var(--imkit-emoji-cell-size, 46px);
  padding: 0; cursor: pointer;
}

.emoji-option:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.extension-grid {
  display: grid;
  grid-template-columns: repeat(var(--imkit-ext-columns, 4), var(--imkit-ext-item-width, 76px));
  gap: var(--imkit-ext-gap, 8px); justify-content: start;
}

.extension-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; padding: 10px 4px;
  border: 1px solid var(--line);
  border-radius: var(--imkit-ext-item-radius, 12px);
  background: #fff; font-size: 12px; color: #384054; cursor: pointer;
  width: var(--imkit-ext-item-width, 76px); height: var(--imkit-ext-item-height, 88px);
  box-sizing: border-box;
}

.extension-item:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.extension-icon { font-size: var(--imkit-ext-icon-size, 32px); line-height: 1; }

/* ---------- demo parity: custom（订单卡片）消息 ---------- */

.custom-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 220px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(93, 106, 255, .08);
  border: 1px solid rgba(93, 106, 255, .35);
  text-align: left;
}

.message-item.outgoing .custom-card {
  background: rgba(255, 255, 255, .16);
  border-color: rgba(255, 255, 255, .4);
  color: #fff;
}

.custom-card-head { font-weight: 700; font-size: 13px; }
.custom-card-amount { font-size: 18px; font-weight: 700; }
.custom-card-meta { font-size: 11px; opacity: .78; }

/* ---------- demo parity: form / bubble readability fixes ---------- */

.field textarea {
  width: 100%;
  margin-top: 6px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
  font-size: 13px;
  line-height: 1.5;
  color: inherit;
  background: #fbfcfe;
  outline: none;
  resize: vertical;
}

.field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  background: #fff;
}

.message-item.outgoing .msg-recall { color: rgba(255, 255, 255, .92); }

/* ================================================================== */
/* rev18 · M05 / M09 / M15 / M17 / M18 / M19 演示样式                    */
/* ================================================================== */

/* ---- 通用小部件 ---- */
.badge.warn { background: #fef3c7; color: #92400e; }
.badge.ok { background: #dcfce7; color: #166534; }
.inline-field { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.inline-field select,
.inline-field input { padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: #fbfcfe; }
.input-narrow { width: 84px; }
.ghost.active,
.tool.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* ---- M15 流式开关（输入区） ---- */
.stream-status {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px;
  border-radius: 999px; background: var(--accent-soft); color: var(--accent-dark);
  font-size: 11px; white-space: nowrap;
}
.stream-status[data-state="streaming"] { background: #fee2e2; color: #991b1b; }
.stream-status[data-state="streaming"]::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor;
  animation: demo-pulse 1s ease-in-out infinite;
}
@keyframes demo-pulse { 50% { opacity: .25; } }

/* ---- M17 翻译结果（气泡正下方内联） ---- */
.demo-translation {
  margin-top: 5px; padding: 6px 9px; border-radius: 9px; font-size: 12px; line-height: 1.5;
  background: #eef2ff; border: 1px dashed rgba(79, 70, 229, .45); color: #312e81;
  max-width: 420px; word-break: break-word;
}
.demo-translation[data-status="error"],
.demo-translation[data-status="unconfigured"],
.demo-translation[data-status="unavailable"] {
  background: #fff7ed; border-color: rgba(217, 119, 6, .45); color: #92400e;
}

/* ---- M17 长按菜单 ---- */
.msg-action-sheet {
  position: fixed; z-index: 60; width: 280px; padding: 10px 12px 12px;
  background: #fff; border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 18px 40px rgba(31, 36, 48, .22);
}
.msg-action-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.msg-action-title {
  font-size: 12px; font-weight: 600; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.msg-action-body { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 8px; }
.msg-action {
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px;
  background: #fbfcfe; text-align: left; font-size: 13px;
}
.msg-action:hover { border-color: var(--accent); background: var(--accent-soft); }
.msg-action-result {
  margin-top: 8px; padding: 7px 9px; border-radius: 8px; background: #f8fafc;
  border: 1px solid var(--line); max-height: 150px; overflow: auto; line-height: 1.5;
}

/* ---- M09 多选 / 合并转发 ---- */
.selection-bar {
  display: flex; align-items: center; gap: 10px; padding: 8px 14px;
  background: #eef2ff; border-top: 1px solid #dbe2ff; border-bottom: 1px solid #dbe2ff;
}
.selection-count { font-size: 13px; font-weight: 600; color: var(--accent-dark); }
.message-item.selectable { cursor: pointer; padding: 0 30px; }
.message-item.selectable:hover { background: rgba(79, 70, 229, .05); }
.message-item.selected { background: rgba(79, 70, 229, .12); box-shadow: inset 3px 0 0 var(--accent); }
.demo-select-check {
  position: absolute; top: 8px; left: 4px; width: 22px; height: 22px; border-radius: 7px;
  border: 1px solid #c7cde0; background: #fff; color: #fff; font-size: 13px; line-height: 1;
  display: grid; place-items: center; z-index: 4;
}
.message-item.outgoing .demo-select-check { left: auto; right: 4px; }
.message-item { position: relative; }
.demo-select-check[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); }
.combine-preview { margin: 12px 0 0; padding: 10px 12px; background: #f8fafc; border: 1px solid var(--line); border-radius: 12px; }
.combine-preview-list { margin: 8px 0 0; padding-left: 20px; max-height: 180px; overflow: auto; font-size: 12px; line-height: 1.7; color: var(--muted); }

/* IMKit combine 气泡在浅色气泡里对比度修正（SDK 默认按深色气泡取白色叠加） */
.msg-combine .combine-summary { background: rgba(31, 36, 48, .06); }
.msg-combine .combine-items { background: rgba(31, 36, 48, .05); }
.msg-combine .combine-toggle { border-color: rgba(31, 36, 48, .3); }
.message-item.outgoing .combine-summary { background: rgba(255, 255, 255, .18); }
.message-item.outgoing .combine-items { background: rgba(255, 255, 255, .12); }
.message-item.outgoing .combine-toggle { border-color: rgba(255, 255, 255, .45); }

/* ---- M18 机器人 ---- */
.bot-list { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.bot-row {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px;
  border: 1px solid var(--line); border-radius: 12px; background: #fbfcfe;
}
.bot-main { min-width: 0; flex: 1; }
.bot-name { font-size: 13px; font-weight: 600; }
.bot-actions { display: flex; gap: 6px; }
.bot-events { margin-top: 6px; display: flex; flex-direction: column; gap: 6px; max-height: 220px; overflow: auto; }
.bot-event { padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: #f8fafc; }
.bot-event-head { font-size: 12px; font-weight: 600; color: #334155; }
.bot-event-reply { margin-top: 4px; font-size: 12px; color: #166534; white-space: pre-wrap; }

/* ---- M19 审核 ---- */
.audit-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 14px; margin-top: 10px; }
.audit-list, .audit-events { display: flex; flex-direction: column; gap: 8px; max-height: 360px; overflow: auto; }
.audit-task { padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: #fbfcfe; }
.audit-task[data-status="pending"] { border-color: #fcd34d; background: #fffbeb; }
.audit-task[data-status="rejected"] { border-color: #fca5a5; background: #fef2f2; }
.audit-task-head { font-size: 12px; font-weight: 700; color: #334155; }
.audit-task-text { margin: 5px 0; font-size: 13px; line-height: 1.5; word-break: break-word; }
.audit-task-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.audit-task-actions { margin-top: 8px; display: flex; gap: 6px; }
.audit-event { padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: #f8fafc; }
.audit-event[data-decision="reject"] { border-color: #fca5a5; background: #fef2f2; }
.audit-event[data-decision="approve"] { border-color: #86efac; background: #f0fdf4; }
.audit-event-head { font-size: 12px; font-weight: 600; }

/* ---- M05 聊天室增强 ---- */
.chatroom-summary { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 6px 0 10px; }
.room-name { font-weight: 700; font-size: 14px; }
.kv-list { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; max-height: 180px; overflow: auto; }
.kv-row {
  display: flex; align-items: center; gap: 8px; padding: 7px 10px;
  border: 1px solid var(--line); border-radius: 10px; background: #fbfcfe; font-size: 12px;
}
.kv-key { flex: 0 0 auto; font-weight: 600; }
.kv-value { flex: 1 1 auto; min-width: 0; word-break: break-word; color: var(--muted); }
.audit-grid .section-title, .modal-body .section-title { margin-top: 16px; }

/* =====================================================================
   rev19 · M13 多端 / M14 推送 / M16 超级群 / M07 本地搜索 / M12 事件 / M21 主题
   ===================================================================== */

/* ---- M21 深色主题（调色板覆盖；组件沿用同一批 CSS 变量） ---- */
body[data-theme="dark"] {
  --bg: #0a1120;
  --panel: #121b2e;
  --sidebar: #0e1728;
  --text: #e6ebf5;
  --muted: #93a1ba;
  --line: #22304a;
  --danger: #f87171;
  --ok: #34d399;
  --bubble-in: #182742;
  --shadow: 0 12px 34px rgba(0, 0, 0, 0.5);
  --topbar: #070d18;
  --card: #101a2c;
  --card-soft: #0f1a2c;
  color-scheme: dark;
}
body[data-theme="dark"] .topbar { background: var(--topbar); }
body[data-theme="dark"] .brand-small .logo,
body[data-theme="dark"] .logo { box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06); }
body[data-theme="dark"] .ghost { background: #142138; border-color: var(--line); color: var(--text); }
body[data-theme="dark"] .ghost:hover { background: #1b2b45; border-color: #33456b; }
body[data-theme="dark"] .ghost.light { background: rgba(255, 255, 255, 0.08); border-color: rgba(255, 255, 255, 0.18); color: #eef0f6; }
body[data-theme="dark"] .field input,
body[data-theme="dark"] .field textarea,
body[data-theme="dark"] .modal-body input,
body[data-theme="dark"] .modal-body select,
body[data-theme="dark"] .modal-body textarea,
body[data-theme="dark"] .sidebar-tools input,
body[data-theme="dark"] .contact-box input,
body[data-theme="dark"] .friend-results,
body[data-theme="dark"] .event-presence input,
body[data-theme="dark"] .popover input {
  background: #0d1728; border-color: var(--line); color: var(--text);
}
body[data-theme="dark"] .field input:focus { background: #101c30; }
body[data-theme="dark"] .modal,
body[data-theme="dark"] .settings-drawer,
body[data-theme="dark"] .more-menu,
body[data-theme="dark"] .popover,
body[data-theme="dark"] .msg-action-sheet,
body[data-theme="dark"] .login-card { background: var(--panel); border-color: var(--line); }
body[data-theme="dark"] .modal-head,
body[data-theme="dark"] .modal-foot,
body[data-theme="dark"] .settings-head { border-color: var(--line); }
body[data-theme="dark"] .bot-row,
body[data-theme="dark"] .audit-task,
body[data-theme="dark"] .audit-event,
body[data-theme="dark"] .bot-event,
body[data-theme="dark"] .kv-row,
body[data-theme="dark"] .combine-preview,
body[data-theme="dark"] .search-hit,
body[data-theme="dark"] .friend-row,
body[data-theme="dark"] .device-card,
body[data-theme="dark"] .level-card,
body[data-theme="dark"] .push-channel,
body[data-theme="dark"] .type-notify-row,
body[data-theme="dark"] .local-result,
body[data-theme="dark"] .event-item,
body[data-theme="dark"] .event-presence,
body[data-theme="dark"] .sg-member,
body[data-theme="dark"] .m13-receipts .receipt-row { background: var(--card); border-color: var(--line); }
body[data-theme="dark"] .seg button { background: #0d1728; border-color: var(--line); color: var(--text); }
body[data-theme="dark"] .seg button[aria-pressed="true"] { background: var(--accent); color: #fff; border-color: var(--accent); }
body[data-theme="dark"] .push-test-result { background: var(--card-soft); border-color: var(--line); }
body[data-theme="dark"] .msg-action { background: #0d1728; border-color: var(--line); color: var(--text); }
body[data-theme="dark"] .msg-action:hover { background: rgba(129, 140, 248, 0.14); }
body[data-theme="dark"] .selection-bar { background: rgba(129, 140, 248, 0.12); border-color: #2b3c60; }
body[data-theme="dark"] .message-item.selectable:hover { background: rgba(129, 140, 248, 0.08); }
body[data-theme="dark"] .msg-combine .combine-summary,
body[data-theme="dark"] .msg-combine .combine-items { background: rgba(255, 255, 255, 0.08); }
body[data-theme="dark"] .demo-select-check { background: #0d1728; border-color: #3a4c70; }
body[data-theme="dark"] .settings-action { background: #0d1728; border-color: var(--line); color: var(--text); }
body[data-theme="dark"] .settings-drawer .setting-option { color: var(--text); }
body[data-theme="dark"] .login-view {
  background:
    radial-gradient(1200px 500px at 20% -10%, #1e2a55 0%, transparent 60%),
    radial-gradient(900px 500px at 110% 10%, #0c2d3d 0%, transparent 55%),
    var(--bg);
}
body[data-theme="dark"] .empty,
body[data-theme="dark"] .chat-empty h2 { color: var(--text); }
body[data-theme="dark"] .conv-item:hover,
body[data-theme="dark"] .conv-item.active { background: #16233a; border-color: #2c3e60; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4); }

/* ---- M21 主题/语言 弹层 ---- */
.menu-anchor { position: relative; display: inline-flex; }
.more-menu {
  position: absolute; top: calc(100% + 8px); right: 0; width: 340px; padding: 8px;
  background: #fff; border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 18px 40px rgba(31, 36, 48, 0.22); z-index: 90; display: flex; flex-direction: column; gap: 4px;
}
.more-menu button {
  display: flex; align-items: center; gap: 10px; text-align: left; padding: 9px 10px;
  border: 0; border-radius: 10px; background: transparent; color: var(--text); width: 100%;
}
.more-menu button:hover, .more-menu button:focus-visible { background: var(--accent-soft); outline: none; }
.more-menu .menu-emoji { font-size: 18px; flex: 0 0 auto; }
.more-menu .menu-text { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; }
.more-menu .menu-text b { font-size: 13px; }
.more-menu .menu-text small { color: var(--muted); font-size: 11px; line-height: 1.35; }
.more-menu em { font-style: normal; font-size: 10px; color: var(--muted); border: 1px solid var(--line); padding: 2px 5px; border-radius: 6px; }
.popover {
  position: absolute; top: calc(100% + 8px); right: 0; width: 300px; padding: 12px 14px;
  background: #fff; border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 18px 40px rgba(31, 36, 48, 0.22); z-index: 90;
}
.popover-section { margin-bottom: 12px; }
.popover-title { font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
.popover-note { margin: 4px 0 0; font-size: 11px; line-height: 1.5; color: var(--muted); }
.seg { display: flex; gap: 6px; }
.seg button {
  flex: 1 1 0; padding: 7px 8px; font-size: 12px; border-radius: 9px;
  border: 1px solid var(--line); background: #fbfcfe; color: var(--text);
}
.seg button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.swatches { display: flex; gap: 10px; }
.swatches button {
  width: 28px; height: 28px; border-radius: 50%; border: 2px solid transparent;
  box-shadow: 0 0 0 1px var(--line);
}
.swatches button[data-accent="indigo"] { background: #4f46e5; }
.swatches button[data-accent="teal"] { background: #0d9488; }
.swatches button[data-accent="rose"] { background: #e11d48; }
.swatches button[data-accent="amber"] { background: #b45309; }
.swatches button[aria-pressed="true"] { border-color: var(--text); box-shadow: 0 0 0 2px var(--panel), 0 0 0 3px var(--text); }

/* ---- 通用宽度 / 徽标 ---- */
.modal.xwide { width: min(1120px, calc(100vw - 24px)); max-height: 93vh; overflow: hidden; }
/* 大面板：头/脚固定，仅 body 滚动（截图里标题与关闭按钮始终可见） */
.modal.xwide .modal-head,
.modal.xwide .modal-foot { flex: 0 0 auto; }
.modal.xwide .modal-body { overflow: auto; flex: 1 1 auto; padding: 14px 18px; min-height: 0; }
/* 新面板里的状态徽标不是未读计数：用中性底色，语义色只在 .ok/.warn/.bad 上出现 */
.modal.xwide .badge { background: var(--accent-soft); color: var(--text); border: 1px solid var(--line); }
.modal.xwide .badge.ok { background: rgba(22, 163, 74, 0.14); color: #15803d; border-color: rgba(22, 163, 74, 0.32); }
.modal.xwide .badge.warn { background: rgba(245, 158, 11, 0.16); color: #b45309; border-color: rgba(245, 158, 11, 0.36); }
.modal.xwide .badge.bad { background: rgba(220, 38, 38, 0.14); color: #b91c1c; border-color: rgba(220, 38, 38, 0.32); }
body[data-theme="dark"] .modal.xwide .badge.ok { color: #6ee7b7; }
body[data-theme="dark"] .modal.xwide .badge.warn { color: #fcd34d; }
body[data-theme="dark"] .modal.xwide .badge.bad { color: #fca5a5; }
body[data-theme="dark"] .device-msg,
body[data-theme="dark"] .m13-compose select,
body[data-theme="dark"] .m13-compose input,
body[data-theme="dark"] .event-presence input { background: #0d1728; border-color: var(--line); color: var(--text); }
.field select { width: 100%; margin-top: 6px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--text); }
body[data-theme="dark"] .field select { background: #0d1728; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
.badge.ok { background: rgba(22, 163, 74, 0.12); color: #15803d; border-color: rgba(22, 163, 74, 0.3); }
body[data-theme="dark"] .badge.ok { color: #6ee7b7; }
.badge.warn { background: rgba(245, 158, 11, 0.14); color: #b45309; border-color: rgba(245, 158, 11, 0.35); }
.badge.bad { background: rgba(220, 38, 38, 0.12); color: #b91c1c; border-color: rgba(220, 38, 38, 0.3); }
body[data-theme="dark"] .badge.bad { color: #fca5a5; }

/* ---- M13 多端 ---- */
.m13-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 12px; }
.device-card { border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; background: var(--card); display: flex; flex-direction: column; min-width: 0; }
.device-head { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.device-head b { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.device-dot { width: 9px; height: 9px; border-radius: 50%; background: #9aa3b5; flex: 0 0 auto; }
.device-dot.online { background: var(--ok); box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.18); }
.device-sub { margin: 6px 0 8px; word-break: break-all; }
.m13-compose { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; margin-bottom: 8px; }
.m13-compose select, .m13-compose input { padding: 7px 9px; border-radius: 9px; border: 1px solid var(--line); background: #fff; font-size: 12px; }
.m13-unread { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.device-msgs { border: 1px dashed var(--line); border-radius: 10px; padding: 8px; min-height: 150px; max-height: 230px; overflow: auto; display: flex; flex-direction: column; gap: 6px; }
.device-msg { border: 1px solid var(--line); border-radius: 9px; background: #fff; padding: 6px 8px; font-size: 12px; line-height: 1.45; }
.device-msg.direction-send { border-left: 3px solid var(--accent); }
.device-msg.direction-receive { border-left: 3px solid var(--ok); }
.device-msg-meta { color: var(--muted); font-size: 10px; margin-top: 2px; word-break: break-all; }
.m13-receipts { margin-top: 8px; display: flex; flex-direction: column; gap: 5px; max-height: 90px; overflow: auto; }
.receipt-row { border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; font-size: 11px; background: var(--card); color: var(--muted); }
.m13-actions { margin-top: 12px; flex-wrap: wrap; align-items: center; }
.m13-levels { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.level-card { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: var(--card); }
.level-card.ok { border-left: 4px solid var(--ok); }
.level-card.absent { border-left: 4px solid #f59e0b; }
.level-card b { font-size: 12px; }
.level-card ul { margin: 5px 0 0; padding-left: 18px; font-size: 11.5px; line-height: 1.5; color: var(--muted); }

/* ---- M14 推送 ---- */
.push-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 10px; }
.push-channel { border: 1px solid var(--line); border-radius: 12px; padding: 10px; background: var(--card); display: flex; flex-direction: column; gap: 6px; }
.push-channel[data-configured="true"] { border-color: rgba(22, 163, 74, 0.45); }
.push-channel-head { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.push-fields { display: flex; flex-direction: column; gap: 3px; font-size: 11px; color: var(--muted); }
.push-field { display: flex; gap: 6px; justify-content: space-between; word-break: break-all; }
.push-field b { color: var(--text); font-weight: 600; }
.push-test-result { margin-top: 10px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; background: var(--card-soft); white-space: pre-wrap; word-break: break-word; }
.push-test-result[data-implemented="false"] { border-color: rgba(245, 158, 11, 0.5); background: rgba(245, 158, 11, 0.08); color: #92400e; }
body[data-theme="dark"] .push-test-result[data-implemented="false"] { color: #fcd34d; }
.type-notify { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.type-notify-row { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 10px; padding: 7px 10px; background: var(--card); font-size: 12px; }
.type-notify-row .type-name { flex: 0 0 140px; font-weight: 600; }
.type-notify-row .seg { flex: 1 1 auto; }
.type-notify-row .seg button { padding: 5px 6px; font-size: 11px; }
.m14-notes { margin-top: 14px; padding: 10px 12px; border: 1px dashed var(--line); border-radius: 10px; font-size: 12px; line-height: 1.6; color: var(--muted); }
.m14-notes b { color: var(--text); }
.m14-notes ul { margin: 6px 0 0; padding-left: 18px; }

/* ---- M16 超级群 ---- */
.sg-summary { margin: 8px 0; }
.sg-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.sg-members { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin-top: 8px; max-height: 240px; overflow: auto; }
.sg-member { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 9px; padding: 6px 9px; background: var(--card); font-size: 12px; }
.sg-member .role { margin-left: auto; font-size: 10px; color: var(--muted); border: 1px solid var(--line); padding: 1px 5px; border-radius: 6px; }

/* ---- M07 本地搜索 ---- */
.local-results { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; max-height: 420px; overflow: auto; }
.local-result {
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; background: var(--card);
  text-align: left; width: 100%; cursor: pointer; font-size: 13px; line-height: 1.45;
}
.local-result:hover, .local-result:focus-visible { border-color: var(--accent); background: var(--accent-soft); outline: none; }
.local-result[aria-selected="true"] { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.local-result mark { background: rgba(245, 158, 11, 0.35); color: inherit; border-radius: 3px; padding: 0 1px; }
.local-result-meta { margin-top: 3px; font-size: 11px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; }
.local-scope-chip { border: 1px solid var(--line); border-radius: 6px; padding: 0 5px; }

/* ---- M12 事件日志抽屉 ---- */
body.events-open .layout { margin-right: 404px; }
.event-drawer {
  position: fixed; top: 58px; right: 0; bottom: 0; width: 404px; z-index: 35;
  background: var(--panel); border-left: 1px solid var(--line); box-shadow: -14px 0 34px rgba(15, 23, 42, 0.12);
  display: flex; flex-direction: column; min-height: 0;
}
.event-head { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px 8px; border-bottom: 1px solid var(--line); }
.event-head h3 { margin: 0 0 3px; font-size: 14px; }
.event-head p { margin: 0; line-height: 1.4; }
.event-actions { margin-left: auto; display: flex; gap: 6px; align-items: center; flex: 0 0 auto; flex-wrap: nowrap; }
.event-actions .ghost { white-space: nowrap; }
.event-head > div:first-child { min-width: 0; }
.event-filters { display: flex; flex-wrap: wrap; gap: 4px 8px; padding: 8px 14px; border-bottom: 1px solid var(--line); }
.event-filter { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; color: var(--muted); }
.event-filter input { accent-color: var(--accent); }
.event-presence { margin: 10px 14px 0; padding: 9px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--card-soft); }
.event-presence .row { margin-top: 6px; flex-wrap: wrap; }
.event-presence .row input { flex: 1 1 100%; }
.event-presence .row button { white-space: nowrap; }
.event-presence input { flex: 1 1 auto; min-width: 0; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; font-size: 12px; }
.event-stats { display: flex; flex-wrap: wrap; gap: 5px; padding: 8px 14px; }
.event-stat { font-size: 10px; border: 1px solid var(--line); border-radius: 999px; padding: 1px 7px; color: var(--muted); }
.event-stat b { color: var(--text); }
.event-list { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 0 14px 14px; display: flex; flex-direction: column; gap: 6px; }
.event-item { border: 1px solid var(--line); border-left-width: 3px; border-radius: 9px; padding: 6px 8px; background: var(--card); }
.event-item[data-kind="system"] { border-left-color: #64748b; }
.event-item[data-kind="message"] { border-left-color: var(--accent); }
.event-item[data-kind="receipt"] { border-left-color: var(--ok); }
.event-item[data-kind="chatroom"] { border-left-color: #8b5cf6; }
.event-item[data-kind="typing"] { border-left-color: #f59e0b; }
.event-item[data-kind="error"] { border-left-color: var(--danger); }
.event-item-head { display: flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; }
.event-item-head time { margin-left: auto; font-weight: 400; color: var(--muted); font-size: 10px; }
.event-item-payload { margin-top: 3px; font-size: 10px; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; line-height: 1.45; word-break: break-all; }
.event-item[data-paused="true"] { opacity: 0.55; }
.paused-flag { color: #b45309; font-size: 10px; border: 1px solid rgba(245, 158, 11, 0.5); border-radius: 6px; padding: 1px 5px; }

/* ---- rev24：IMKit ChannelSwitcher 宿主（组件样式由 sdk/web/imkit.mjs 注入） ---- */
.imkit-chat-channel-host { flex: 0 0 auto; }

/* ==========================================================================
   parity-v2：SealTalk 四模块（会话 / 通讯录 / 发现 / 我的）
   规格来源：docs/reports/demo-parity-v2/baseline/baseline-ui.md（SealTalk iOS）
   - 模块入口行 56px 高、图标 40×40、分割线从 56px 处内缩（iOS separator inset）
   - 我的资料卡头像 40×40
   ========================================================================== */
.tabs { gap: 4px; padding: 8px 8px 0; }
.tab { padding: 8px 4px; font-size: 13px; border-radius: 8px; }

.contact-box { padding: 0 0 14px; }
.module-rows { display: flex; flex-direction: column; background: var(--panel); }
.module-row {
  display: flex; align-items: center; gap: 12px; width: 100%;
  min-height: var(--imkit-module-row-height, 56px);
  padding: 8px 16px; border: 0; border-bottom: var(--imkit-divider-width, 1px) solid var(--line);
  background: transparent; color: var(--text); font: inherit; font-size: 15px;
  text-align: left; cursor: pointer; box-sizing: border-box;
}
.module-row:last-child { border-bottom: 0; }
.module-row:hover { background: var(--card-soft); }
.module-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.module-row.danger .module-label { color: var(--danger); }
.module-icon {
  flex: 0 0 var(--imkit-contact-avatar-size, 40px);
  width: var(--imkit-contact-avatar-size, 40px);
  height: var(--imkit-contact-avatar-size, 40px); border-radius: 10px;
  display: grid; place-items: center; font-size: 19px; color: #fff;
}
.module-label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.module-chevron { flex: 0 0 auto; color: #c3c9d6; font-size: 19px; line-height: 1; }
.badge.mini { min-width: 18px; height: 18px; padding: 0 5px; font-size: 11px; }
#pane-contacts .contact-section { padding: 12px 16px 0; }
#pane-contacts .contact-section .contact-title { margin-bottom: 8px; }
#pane-contacts hr { margin: 14px 16px 0; border: 0; border-top: 1px solid var(--line); }
#pane-contacts .field.compact { margin: 12px 16px 0; }
#pane-contacts .contact-result { margin: 6px 16px 0; }
#pane-contacts > .contact-box > .muted.small { padding: 10px 16px 0; }
#pane-discover .contact-box > p.muted { padding: 12px 16px 0; }
.square-head { padding: 14px 16px 8px; font-size: 12px; font-weight: 600; color: var(--muted); background: var(--sidebar); border-bottom: 1px solid var(--line); }

.me-card {
  display: flex; align-items: center; gap: 12px; padding: 18px 16px;
  border-bottom: 1px solid var(--line); background: var(--panel);
}
.me-avatar { width: 40px; height: 40px; flex: 0 0 40px; border-radius: 10px; font-size: 15px; }
.me-main { min-width: 0; }
.me-name { font-size: 16px; font-weight: 600; line-height: 22px; }
#pane-me #me-profile-editor { padding: 0 16px; }
#pane-me #me-profile-editor hr { margin: 14px 0 0; border: 0; border-top: 1px solid var(--line); }
#pane-me #me-profile-editor .field.compact { margin: 12px 0 0; }
#pane-me #me-about { padding: 12px 16px 0; line-height: 1.5; }

body[data-theme="dark"] .module-row { border-color: var(--line); }
body[data-theme="dark"] .module-row:hover { background: #1b2b45; }
body[data-theme="dark"] .module-chevron { color: #4b5b7a; }
body[data-theme="dark"] .me-card { background: var(--panel); }

/* 通讯录「群聊」分区行（40×40 头像 + 56px 行高，与模块入口行一致） */
.group-row {
  display: flex; align-items: center; gap: 12px; width: 100%;
  min-height: 56px; padding: 8px 0; border: 0; border-bottom: 1px solid var(--line);
  background: transparent; color: var(--text); font: inherit; text-align: left;
  cursor: pointer; box-sizing: border-box;
}
.group-row:last-child { border-bottom: 0; }
.group-row:hover { background: var(--card-soft); }
.group-row .avatar { background: var(--accent); }
.group-main { display: flex; flex-direction: column; gap: 2px; flex: 1 1 auto; min-width: 0; }
.group-name { font-size: 15px; line-height: 21px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.group-row .muted { font-size: 12px; }
#pane-contacts .contact-section:first-of-type { padding-top: 12px; }
#friend-requests.flash { animation: parity-flash 1.2s ease-in-out; }
@keyframes parity-flash {
  0%, 100% { background: transparent; }
  20%, 60% { background: var(--accent-soft); }
}

