:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #f0f1f6;
  --border: #e3e5ee;
  --text: #1f2430;
  --text-soft: #6b7180;
  --primary: #4f6ef7;
  --primary-soft: #eaeefe;
  --danger: #e5484d;
  --shadow: 0 1px 3px rgba(20, 25, 40, 0.06), 0 8px 24px rgba(20, 25, 40, 0.06);
  --radius: 14px;
}

[data-theme="dark"] {
  --bg: #14161c;
  --surface: #1d2029;
  --surface-2: #262a35;
  --border: #2f333f;
  --text: #e8eaf0;
  --text-soft: #9aa0b0;
  --primary: #6b85ff;
  --primary-soft: #232a45;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 22px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo { font-size: 28px; }
.brand-text h1 { font-size: 18px; margin: 0; line-height: 1.1; }
.brand-text p { margin: 2px 0 0; font-size: 12px; color: var(--text-soft); }

.search-wrap { flex: 1; max-width: 460px; }
#searchInput {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  outline: none;
}
#searchInput:focus { border-color: var(--primary); }

.topbar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }

/* ---------- Buttons ---------- */
.btn {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 9px 14px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
  color: var(--text);
  background: var(--surface-2);
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost { background: transparent; border-color: var(--border); }
.btn.ghost:hover { background: var(--surface-2); }

/* ---------- Filters ---------- */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px 22px 4px;
}
.chip {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-soft);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}
.chip:hover { border-color: var(--primary); color: var(--text); }
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ---------- Grid ---------- */
.content { padding: 16px 22px 40px; }
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
}

.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 14px 14px;
  text-align: center;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.card:hover { transform: translateY(-3px); border-color: var(--primary); }
.card .icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-size: 28px;
  overflow: hidden;
  background: var(--surface-2);
}
.card .icon img { width: 100%; height: 100%; object-fit: contain; }
.card .name {
  font-size: 14px;
  font-weight: 600;
  word-break: break-word;
  line-height: 1.3;
}
.card .url {
  font-size: 11px;
  color: var(--text-soft);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card .cat-tag {
  position: absolute;
  top: 8px;
  left: 8px;
  font-size: 10px;
  color: var(--text-soft);
  background: var(--surface-2);
  padding: 2px 7px;
  border-radius: 6px;
}
.card .card-menu {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 26px;
  height: 26px;
  border: none;
  background: transparent;
  color: var(--text-soft);
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.12s, background 0.12s;
}
.card:hover .card-menu { opacity: 1; }
.card .card-menu:hover { background: var(--surface-2); color: var(--text); }

/* ---------- Empty state ---------- */
.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-soft);
}
.empty-emoji { font-size: 48px; }
.empty-state h2 { margin: 14px 0 6px; color: var(--text); }
.empty-state p { margin: 0; font-size: 14px; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 250; place-items: center; }
.modal[hidden] { display: none; }
.modal:not([hidden]) { display: grid; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(10, 12, 20, 0.45); }
.modal-card {
  position: relative;
  width: min(440px, 92vw);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 24px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.modal-card h2 { margin: 0 0 18px; font-size: 18px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: 13px; color: var(--text-soft); }
.field em { color: var(--danger); font-style: normal; }
.field-label { display: flex; flex-direction: row; align-items: center; gap: 4px; }
.field input, .field select {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  outline: none;
}
.field input:focus, .field select:focus { border-color: var(--primary); }
.field select {
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
[data-theme="dark"] .field select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23aaa' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
}
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }
.icon-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 100%;
}
.icon-input-row input {
  flex: 1 1 auto;
  min-width: 0;
  width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.icon-input-row button { flex: 0 0 auto; }
.icon-preview {
  width: 34px; height: 34px; flex: 0 0 34px;
  border-radius: 10px; display: grid; place-items: center;
  font-size: 18px; overflow: hidden;
  background: var(--surface-2);
}
.icon-preview img { width: 100%; height: 100%; object-fit: contain; }
.btn.small { padding: 6px 10px; font-size: 12px; }
.color-row { display: flex; gap: 8px; flex-wrap: wrap; }
.color-dot {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
}
.color-dot.active { border-color: var(--text); transform: scale(1.1); }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-soft); margin-bottom: 18px; }
.check input { width: 16px; height: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 14px;
  z-index: 1600;
  box-shadow: var(--shadow);
  max-width: min(90vw, 420px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.toast[onclick],
.toast[style*="cursor: pointer"] {
  border-bottom: 2px solid var(--accent, #3b82f6);
}

/* ---------- Context menu ---------- */
.ctx-menu {
  position: fixed;
  z-index: 80;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 6px;
  min-width: 140px;
}
.ctx-menu button {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  color: var(--text);
  padding: 9px 12px;
  border-radius: 7px;
  font-size: 13px;
  cursor: pointer;
}
.ctx-menu button:hover { background: var(--surface-2); }
.ctx-menu button.danger { color: var(--danger); }

@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; }
  .search-wrap { order: 3; max-width: 100%; flex-basis: 100%; }
  .topbar-actions { margin-left: 0; }
}

/* ---------- Auth (登录 / 注册) ---------- */
.auth-view {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--bg);
  z-index: 200;
}
/* hidden 属性必须能真正隐藏登录遮罩（否则 display:grid 会顶掉 [hidden]） */
.auth-view[hidden] { display: none; }
.auth-card {
  width: min(360px, 92vw);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 32px 28px;
  box-shadow: var(--shadow);
  text-align: center;
}
.auth-logo { font-size: 44px; }
.auth-card h1 { margin: 8px 0 4px; font-size: 22px; }
.auth-sub { margin: 0 0 22px; color: var(--text-soft); font-size: 13px; }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-form[hidden] { display: none; }
.auth-form input {
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  outline: none;
}
.auth-form input:focus { border-color: var(--primary); }
.auth-form .btn.block { width: 100%; padding: 11px; }
.auth-toggle { margin: 4px 0 0; font-size: 13px; color: var(--text-soft); }
.auth-toggle a { color: var(--primary); cursor: pointer; text-decoration: none; }
.auth-error { margin-top: 12px; color: var(--danger); font-size: 13px; }

.user-name {
  font-size: 13px;
  color: var(--text-soft);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- 头像 ---------- */
.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 18px;
  overflow: hidden;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  flex-shrink: 0;
  user-select: none;
}
.avatar.sm { width: 36px; height: 36px; font-size: 16px; }
.avatar.lg { width: 64px; height: 64px; font-size: 28px; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-btn {
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  border-radius: 50%;
  line-height: 0;
  flex-shrink: 0;
}
.avatar-btn:hover .avatar { border-color: var(--primary); }
.profile-username {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  font-size: 14px;
  word-break: break-all;
}

/* ---------- 好友聊天抽屉 ---------- */
.chat-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: min(560px, 100vw);
  height: 100vh;
  display: flex;
  flex-direction: row;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -8px 0 30px rgba(20, 25, 40, 0.12);
  z-index: 150;
  animation: chatSlideIn 0.18s ease-out;
}
.chat-panel[hidden] { display: none; }

/* ---------- 设置抽屉（风格类似聊天弹窗，右侧滑入）---------- */
.settings-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: min(400px, 100vw);
  height: 100vh;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -8px 0 30px rgba(20, 25, 40, 0.12);
  z-index: 150;
  display: flex;
  flex-direction: column;
  animation: settingsSlideIn 0.18s ease-out;
}
.settings-panel[hidden] { display: none; }
.settings-content { display: flex; flex-direction: column; height: 100%; }
.settings-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px; border-bottom: 1px solid var(--border);
}
.settings-title { font-size: 16px; font-weight: 600; color: var(--text); }
.settings-x {
  background: transparent; border: none; color: var(--text-2);
  font-size: 18px; line-height: 1; cursor: pointer; padding: 4px 8px; border-radius: 8px;
}
.settings-x:hover { background: var(--surface-2); color: var(--text); }
.settings-body { padding: 18px; overflow-y: auto; }
.settings-section { margin-bottom: 8px; }
.settings-section-title {
  font-size: 12px; font-weight: 600; color: var(--text-2);
  text-transform: uppercase; letter-spacing: .04em; margin-bottom: 12px;
}
.settings-panel .btn.block { display: block; width: 100%; margin-bottom: 10px; text-align: left; }
.settings-hint { font-size: 12px; color: var(--text-2); line-height: 1.5; margin: 6px 0 0; }
.auth-lang { display: flex; gap: 8px; justify-content: center; margin: 10px 0 2px; }
.lang-switch { display: flex; gap: 8px; }
.lang-switch .lang-btn { flex: 1; }
.lang-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
@keyframes settingsSlideIn {
  from { transform: translateX(24px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* 聊天面板左侧拖拽手柄（调整宽度） */
.chat-resizer {
  position: absolute;
  top: 0;
  left: 0;
  width: 6px;
  height: 100%;
  cursor: col-resize;
  z-index: 20;
  background: transparent;
}
.chat-resizer::after {
  content: "";
  position: absolute;
  top: 0;
  left: 2px;
  width: 2px;
  height: 100%;
  background: var(--primary);
  opacity: 0;
  transition: opacity 0.12s;
}
.chat-resizer:hover::after,
.chat-resizer.active::after { opacity: 0.7; }
body.resizing { user-select: none; cursor: col-resize; }

/* 侧边栏右侧拖拽手柄（调整列表页宽度） */
.sidebar-resizer {
  position: absolute;
  top: 0;
  right: 0;
  width: 6px;
  height: 100%;
  cursor: col-resize;
  z-index: 6;
  background: transparent;
}
.sidebar-resizer::after {
  content: "";
  position: absolute;
  top: 0;
  right: 2px;
  width: 2px;
  height: 100%;
  background: var(--primary);
  opacity: 0;
  transition: opacity 0.12s;
}
.sidebar-resizer:hover::after { opacity: 0.7; }
@keyframes chatSlideIn {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

/* 左侧好友栏 */
.chat-sidebar {
  position: relative;
  width: 220px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--surface-2);
  overflow: hidden;
}
.chat-tabs {
  display: flex;
  gap: 2px;
  padding: 6px 8px 0;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.chat-tab {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 0;
  border: none;
  background: transparent;
  color: var(--text-soft);
  font-size: 12px;
  padding: 9px 4px 11px;
  cursor: pointer;
  border-radius: 8px 8px 0 0;
  transition: background 0.12s, color 0.12s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-tab:hover { background: var(--surface); }
.chat-tab.active {
  color: var(--primary);
  font-weight: 600;
  background: var(--surface);
  box-shadow: inset 0 -2px 0 var(--primary);
}
.tab-badge {
  position: absolute;
  top: 3px;
  right: 2px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--danger, #ff4d4f);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  line-height: 16px;
  text-align: center;
}
.tab-badge[hidden] { display: none; }
.tab-panel {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 6px 0;
}
.tab-panel[hidden] { display: none; }
.chat-sidebar-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 14px 10px;
}
.chat-sidebar-head .chat-title { flex: 1; }
.friend-add {
  display: flex;
  gap: 6px;
  padding: 0 12px 10px;
}
.friend-add input {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  outline: none;
}
.friend-add input:focus { border-color: var(--primary); }
.friend-add .btn { padding: 8px 10px; font-size: 13px; }

.friend-requests { padding: 4px 10px; }
.friend-requests[hidden] { display: none; }
.req-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 8px;
  border-radius: 9px;
  background: var(--primary-soft);
  margin-bottom: 6px;
}
.req-row .req-name {
  flex: 1;
  font-size: 12px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.req-row .btn.small { padding: 5px 9px; font-size: 12px; }

.friend-list { padding: 6px 8px; }
.friend-empty {
  padding: 20px 14px;
  font-size: 12px;
  color: var(--text-soft);
  text-align: center;
  line-height: 1.6;
}
.friend-empty[hidden] { display: none; }
.friend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.12s;
}
.friend-row:hover { background: var(--surface); }
.friend-row.active { background: var(--primary-soft); }
.friend-row .avatar-wrap {
  position: relative;
  flex-shrink: 0;
}
.friend-row .dot {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 2px solid var(--surface-2);
  box-sizing: content-box;
}
.friend-row .dot.on { background: #12a594; box-shadow: 0 0 0 3px rgba(18, 165, 148, 0.18); }
.friend-row .dot.off { background: #b9bdc9; }
.friend-row .fname {
  flex: 1;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.friend-row .friend-remove {
  border: none;
  background: transparent;
  color: var(--text-soft);
  font-size: 13px;
  cursor: pointer;
  line-height: 1;
  padding: 3px 5px;
  border-radius: 6px;
  opacity: 0;
  transition: opacity 0.12s, background 0.12s, color 0.12s;
}
.friend-row:hover .friend-remove { opacity: 1; }
.friend-row .friend-remove:hover { background: var(--surface-2); color: var(--danger); }
/* 未读消息红点提醒 */
.friend-row .unread-badge {
  flex-shrink: 0;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  margin-left: 4px;
  border-radius: 9px;
  background: var(--danger, #ff4d4f);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  line-height: 18px;
  text-align: center;
  box-sizing: border-box;
  box-shadow: 0 0 0 2px var(--surface-2);
}

/* 顶栏 💬 按钮上的未读总数徽标（抽屉关闭时仍始终可见） */
#chatBtn { position: relative; }
.nav-badge {
  position: absolute;
  top: -7px;
  right: -7px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--danger, #ff4d4f);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  box-sizing: border-box;
  box-shadow: 0 0 0 2px var(--surface-2);
  pointer-events: none;
}

/* 右侧会话区 */
.chat-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  position: relative;
}
.chat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.chat-title {
  font-size: 15px;
  font-weight: 600;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-status {
  font-size: 12px;
  color: var(--text-soft);
  margin-left: auto;
  flex-shrink: 0;
  max-width: 170px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-status.ok { color: #12a594; }
.chat-status.warn { color: #f5a623; }
.chat-x {
  border: none;
  background: transparent;
  color: var(--text-soft);
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
  padding: 4px 6px;
  border-radius: 8px;
}
.chat-x:hover { background: var(--surface-2); color: var(--text); }

/* 移动端聊天单栏：返回条（默认隐藏，仅窄屏“已进会话/详情”时显示） */
.chat-mobile-back { display: none; }
.chat-back-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; padding: 0;
  border: none; background: transparent; color: var(--text);
  font-size: 24px; line-height: 1; cursor: pointer; border-radius: 8px; flex-shrink: 0;
}
.chat-back-btn:hover { background: var(--surface-2); }

/* 聊天主区域三种视图：聊天 / 好友详情 / 群组详情 */
#chatView { display: flex; flex-direction: column; flex: 1; min-height: 0; }
#chatView[hidden] { display: none; }
.detail-view {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding: 22px 20px;
  gap: 16px;
}
.detail-view[hidden] { display: none; }
.detail-head { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 8px 0 4px; }
.detail-name-row { display: flex; align-items: center; gap: 6px; }
.detail-name { font-size: 18px; font-weight: 600; }
.detail-name-edit {
  font-size: 16px; font-weight: 600; text-align: center; width: 70%;
  padding: 4px 8px; border: 1px solid var(--primary); border-radius: 8px;
  background: var(--surface); color: var(--text); outline: none;
}
.icon-edit {
  flex: 0 0 auto; border: none; background: transparent; color: var(--text-soft);
  cursor: pointer; font-size: 14px; line-height: 1; padding: 3px 5px; border-radius: 6px;
}
.icon-edit:hover { background: var(--surface); color: var(--primary); }
.detail-sub { font-size: 13px; color: var(--text-soft); }
.detail-section-title { font-size: 13px; font-weight: 600; color: var(--text-soft); margin-top: 4px; }
.detail-actions { display: flex; flex-direction: column; gap: 10px; margin-top: auto; padding-top: 8px; }
.detail-call-row { display: flex; gap: 10px; }
.detail-call-row .call-action { flex: 1; justify-content: center; }
.call-action { display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  color: var(--primary); border: 1px solid var(--primary); background: transparent; }
.call-action:hover { background: var(--primary); color: #fff; }
.btn.danger { color: var(--danger, #ff4d4f); border-color: var(--danger, #ff4d4f); }
.btn.danger:hover { background: var(--danger, #ff4d4f); color: #fff; }
.member-list { display: flex; flex-direction: column; gap: 2px; }
.member-row { display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 9px; }
.member-row:hover { background: var(--surface); }
.member-row .mname { flex: 1; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-row .owner-tag { font-size: 11px; color: var(--primary); font-weight: 600; }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.chat-empty {
  margin: auto;
  text-align: center;
  color: var(--text-soft);
  font-size: 13px;
  padding: 20px;
}
.chat-msg-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 82%;
}
.chat-msg-row.me { align-self: flex-end; flex-direction: row-reverse; }
.chat-msg-row.peer { align-self: flex-start; }
.chat-msg-avatar {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-soft);
  font-size: 14px;
  font-weight: 600;
  user-select: none;
}
.chat-msg-avatar.sm { width: 30px; height: 30px; font-size: 13px; }
.chat-msg-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.chat-msg {
  min-width: 0;
  max-width: 100%;
  padding: 9px 12px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.45;
  word-break: break-word;
  white-space: pre-wrap;
}
.chat-msg.me {
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-msg.peer {
  background: var(--surface-2);
  color: var(--text);
  border-bottom-left-radius: 4px;
}
.chat-msg .meta {
  display: block;
  font-size: 10px;
  opacity: 0.7;
  margin-top: 4px;
}
.chat-date-sep {
  align-self: center;
  margin: 6px 0;
  padding: 3px 12px;
  font-size: 11px;
  color: var(--text-soft);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  user-select: none;
  white-space: nowrap;
}

.chat-input-row {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  align-items: flex-end;
}
.chat-input-row textarea {
  flex: 1;
  resize: none;
  max-height: 120px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  line-height: 1.4;
}
.chat-input-row textarea:focus { border-color: var(--primary); }
.chat-input-row textarea:disabled { opacity: 0.6; }

/* ---------- 内嵌 iframe 查看器（多页面常驻，最小化收纳到 dock） ---------- */
/* dock 容器：固定底部居中，作为所有页面实例的固定父节点 */
.iframe-dock[hidden] { display: none !important; }
.iframe-dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 18px;
  z-index: 1001;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 10px;
  padding: 0 20px;
  /* 容器本身不拦截点击，避免全宽条挡住底部内容；仅卡片自身可点 */
  pointer-events: none;
}
/* 每个页面实例：默认（最小化）即 dock 小卡片；iframe 仍常驻运行，仅视觉隐藏 */
.iframe-page {
  width: 240px;
  height: 52px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.28);
  overflow: hidden;
  cursor: pointer;
  pointer-events: auto; /* 受 dock 的 pointer-events:none 影响，这里单独恢复可点 */
}
.iframe-page .iframe-frame { display: none; }
/* 按钮按状态显隐：默认隐藏“最大化”（单页全屏已是最大，无需）；分屏/卡片才显示 */
.iframe-max { display: none; }
.iframe-page.split .iframe-max { display: inline-block; }                       /* 分屏：最大化当前页 */
.iframe-page:not(.active):not(.split) .iframe-max { display: inline-block; }    /* 卡片：打开 */
.iframe-page:not(.active):not(.split) .iframe-min { display: none; }            /* 卡片已最小化，隐藏“最小化” */
.iframe-page.split .iframe-newtab { display: none; }                            /* 分屏态精简为 最大化/最小化/关闭 三按钮 */
/* 最小化态（卡片）：隐藏「新标签页」与网址，仅留标题 + 最大化/关闭 */
.iframe-page:not(.active):not(.split) .iframe-newtab { display: none; }
.iframe-page:not(.active):not(.split) .iframe-url { display: none; }
/* 网址隐藏后没有 flex:1 元素把操作按钮推到右侧，这里用 margin-left:auto 让 □/✕ 靠右 */
.iframe-page:not(.active):not(.split) .iframe-actions { margin-left: auto; }
/* 最小化卡片（dock 收纳态）浮在激活/分屏页面之上，避免被全屏内嵌页盖住、点不到 */
.iframe-page:not(.active):not(.split) { z-index: 1003; cursor: grab; }
.iframe-page:not(.active):not(.split):active { cursor: grabbing; }
/* 拖拽页面到屏幕左/右半释放 → 分屏：半屏高亮提示（不拦截鼠标，drop 落在 document） */
.iframe-drop-hint {
  position: fixed;
  top: 0; bottom: 0;
  width: 50%;
  z-index: 1002;
  pointer-events: none;
  display: none;
  background: rgba(99, 102, 241, 0.16);
  border: 2px dashed rgba(99, 102, 241, 0.7);
  box-sizing: border-box;
}
.iframe-drop-hint.left { left: 0; }
.iframe-drop-hint.right { right: 0; }
/* 激活态：全屏浮层（节点不移动、src 不变，故 iframe 保持常驻运行） */
.iframe-page.active {
  position: fixed;
  inset: 0;
  width: auto;
  height: auto;
  z-index: 1000;
  border-radius: 0;
  border: none;
  cursor: default;
  background: var(--surface);
}
/* 分屏态：左右并排的两个窗口（定位/宽度由 JS 按 splitRatio 设置，故不写死 inset） */
.iframe-page.split {
  position: fixed;
  top: 0;
  bottom: 0;
  width: auto;
  height: auto;
  z-index: 1000;
  border-radius: 0;
  border: none;
  cursor: default;
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--border);
}
/* 半屏态：单页占据一侧（左半），留出空区域，dock 仍可见，便于打开另一页凑分屏 */
.iframe-page.half {
  position: fixed;
  top: 0;
  bottom: 0;
  width: auto;
  height: auto;
  z-index: 1000;
  border-radius: 0;
  border: none;
  cursor: default;
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--border);
}
.iframe-page.half .iframe-frame { display: block; flex: 1; }
.iframe-page.half .iframe-resizer { display: none; }   /* 半屏无分隔条，隐藏边缘拖拽 */
.iframe-page.half .iframe-newtab { display: none; }    /* 半屏精简为 最大化/最小化/关闭 */
.iframe-page.half .iframe-max { display: inline-block; } /* 半屏显示“最大化（铺满）” */
/* 聊天窗口打开时，放大的内嵌页右侧留出聊天面板的宽度，不被其覆盖 */
body.chat-open .iframe-page.active { right: min(560px, 100vw); }
.iframe-page.active .iframe-frame,
.iframe-page.split .iframe-frame { display: block; flex: 1; }
.iframe-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  flex-shrink: 0;
}
.iframe-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}
.iframe-url {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  color: var(--text-soft);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.iframe-url:hover { text-decoration: underline; }
.iframe-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.iframe-x {
  width: 32px; height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  cursor: pointer;
  line-height: 1;
}
.iframe-x:hover { background: var(--surface-2); }
.iframe-frame {
  flex: 1;
  width: 100%;
  border: 0;
  background: #fff;
}
/* 内嵌页左右边缘拖拽条：仅激活态（全屏浮层）显示，拖动改变左/右边界以调整宽度 */
.iframe-resizer {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 6px;
  cursor: col-resize;
  z-index: 3;
  display: none;
}
.iframe-resizer.left { left: 0; }
.iframe-resizer.right { right: 0; }
.iframe-page.active .iframe-resizer { display: block; }
/* 分屏态用中间分隔条调整占比，页面自身的边缘拖拽条隐藏 */
.iframe-page.split .iframe-resizer { display: none; }
.iframe-resizer::after {
  content: "";
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  left: 2px;
  width: 2px;
  height: 44px;
  border-radius: 2px;
  background: var(--accent);
  opacity: 0;
  transition: opacity 0.15s;
}
.iframe-resizer.right::after { left: auto; right: 2px; }
.iframe-resizer:hover::after,
.iframe-resizer.active::after { opacity: 0.85; }
/* 分屏分隔条：位于两页中间，可拖动调整左右占比 */
.iframe-divider {
  position: fixed;
  top: 0;
  bottom: 0;
  width: 6px;
  margin-left: -3px;
  cursor: col-resize;
  z-index: 1002;
  background: transparent;
}
.iframe-divider::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 2px;
  transform: translateY(-50%);
  width: 2px;
  height: 48px;
  border-radius: 2px;
  background: var(--accent);
  opacity: 0;
  transition: opacity 0.15s;
}
.iframe-divider:hover::after,
.iframe-divider.active::after { opacity: 0.85; }
/* 拖拽中禁用 iframe 指针事件，避免鼠标移到 iframe 上方丢 mousemove */
body.resizing .iframe-frame { pointer-events: none !important; }
/* 收起/展开内嵌栏按钮：常驻于 dock 内（非 .iframe-page 子节点，隐藏卡片后仍能点） */
.iframe-dock-toggle {
  pointer-events: auto; /* 受 dock 容器 pointer-events:none 影响，单独恢复 */
  z-index: 1005;
  display: inline-flex;
  align-items: center;
  height: 34px;
  padding: 0 12px;
  flex-shrink: 0;
  font-size: 13px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0,0,0,0.22);
}
.iframe-dock-toggle:hover { border-color: var(--accent); }
/* 隐藏态：仅收起底部那排最小化卡片；激活/分屏页不受影响（它们是 dock 的全屏子节点） */
.iframe-dock.dock-hidden .iframe-page:not(.active):not(.split) { display: none; }

/* ===== 群聊分区 ===== */
.group-section {
  border-top: 1px solid var(--border);
  padding-top: 6px;
  margin-top: 4px;
}
.group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 10px 2px;
}
.group-title { font-size: 13px; font-weight: 600; color: var(--text-soft); }
.group-head .btn.small { padding: 3px 8px; font-size: 12px; }
.group-list { padding: 2px 8px; }
.group-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.12s;
}
.group-row:hover { background: var(--surface); }
.group-row.active { background: var(--primary-soft); }
.group-row .avatar { flex-shrink: 0; }
.group-row .gname {
  flex: 1;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.group-row .gmeta {
  font-size: 11px;
  color: var(--text-soft);
  margin-left: 2px;
}
.group-row .unread-badge {
  flex-shrink: 0;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  margin-left: 4px;
  border-radius: 9px;
  background: var(--danger, #ff4d4f);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  line-height: 18px;
  text-align: center;
}
.group-row .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #b9bdc9; flex-shrink: 0;
}
.group-row .dot.on { background: #12a594; box-shadow: 0 0 0 3px rgba(18,165,148,0.18); }

/* 会话分区（私聊 + 群聊 统一列表）*/
.conv-section {
  border-top: 1px solid var(--border);
  padding-top: 6px;
  margin-top: 4px;
}
.conv-head { padding: 2px 10px; }
.conv-title { font-size: 13px; font-weight: 600; color: var(--text-soft); }
.conv-list { padding: 2px 8px; }
.conv-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 8px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.12s;
}
.conv-row:hover { background: var(--surface); }
.conv-row.active { background: var(--primary-soft); }
.conv-row .avatar-wrap { position: relative; flex-shrink: 0; }
.conv-row .avatar-wrap .dot {
  position: absolute; right: -1px; bottom: -1px;
  width: 11px; height: 11px; border-radius: 50%;
  border: 2px solid var(--surface-2); box-sizing: content-box;
}
.conv-row .avatar-wrap .dot.on { background: #12a594; box-shadow: 0 0 0 3px rgba(18,165,148,0.18); }
.conv-row .avatar-wrap .dot.off { background: #b9bdc9; }
.conv-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.conv-name {
  font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.conv-preview {
  font-size: 12px; color: var(--text-soft); overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.conv-top { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; min-width: 0; }
.conv-top .conv-name { flex: 1; min-width: 0; }
.conv-time { flex-shrink: 0; font-size: 11px; color: var(--text-soft); margin-left: 4px; }
.conv-row .unread-badge {
  flex-shrink: 0;
  min-width: 18px; height: 18px; padding: 0 5px; margin-left: 4px;
  border-radius: 9px; background: var(--danger, #ff4d4f); color: #fff;
  font-size: 11px; font-weight: 600; line-height: 18px; text-align: center;
}
.conv-close {
  border: none; background: transparent; color: var(--text-soft);
  font-size: 13px; cursor: pointer; line-height: 1; padding: 3px 5px;
  border-radius: 6px; opacity: 0; transition: opacity 0.12s, background 0.12s, color 0.12s;
  flex-shrink: 0;
}
.conv-row:hover .conv-close { opacity: 1; }
.conv-close:hover { background: var(--surface-2); color: var(--danger); }

/* 群聊头部操作按钮 */
.chat-group-actions { display: flex; gap: 6px; margin-left: auto; flex-shrink: 0; }
.chat-group-actions[hidden] { display: none; }
.chat-group-actions .btn { white-space: nowrap; }

/* 成员选择器 */
.member-picker {
  max-height: 240px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px;
  background: var(--surface-2);
}
.member-pick-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 8px;
  cursor: pointer;
}
.member-pick-row:hover { background: var(--surface); }
.member-pick-row input { width: 16px; height: 16px; cursor: pointer; }
.member-pick-row .mp-name { flex: 1; font-size: 14px; }
.member-pick-row .mp-add {
  border: none; background: var(--primary); color: #fff;
  border-radius: 7px; padding: 4px 10px; font-size: 12px; cursor: pointer;
}
.member-pick-row .mp-add:hover { filter: brightness(1.05); }
.member-pick-row.added { opacity: 0.55; cursor: default; }
.member-pick-empty { padding: 12px; text-align: center; color: var(--text-soft); font-size: 13px; }

/* 群消息：发送者名 */
.chat-msg-sender {
  font-size: 11px;
  color: var(--text-soft);
  margin: 0 0 2px 2px;
  font-weight: 600;
}

/* ===================== 语音 / 视频通话 ===================== */
.chat-call-btn {
  flex: 0 0 auto;
  width: 34px; height: 34px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 9px;
  font-size: 16px; line-height: 1;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background 0.12s, border-color 0.12s, transform 0.12s;
}
.chat-call-btn:hover { background: var(--primary); color: #fff; border-color: var(--primary); transform: translateY(-1px); }
.chat-call-btn[hidden] { display: none; }
/* 群聊头部的“📹 会议”按钮：需要容纳图标+文字，不能复用 34x34 小方块 */
#groupMeetingBtn {
  width: auto;
  min-width: 60px;
  padding: 0 10px;
  font-size: 12px;
  white-space: nowrap;
  gap: 3px;
}

/* 通话面板：覆盖聊天主区域 */
.call-panel {
  position: fixed;
  inset: 0;
  z-index: 1100;
  background: #0b0d12;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.call-panel[hidden] { display: none; }

.call-remote-wrap { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.call-video {
  width: 100%; height: 100%;
  object-fit: contain;
  background: #000;
}
.call-video[hidden] { display: none; }
/* 共享屏幕时：远端/本端视频完整显示（contain，不裁切），覆盖默认 cover */
.call-video.screen, .call-local-video.screen { object-fit: contain; background: #000; }
/* 本端共享屏幕时取消镜像（否则屏幕文字会被翻转） */
.call-local-video.screen { transform: none; }

/* 全屏：整个通话面板占满视口，远端视频完整显示（contain 避免裁切） */
.call-panel:fullscreen, .call-panel:-webkit-full-screen {
  width: 100vw; height: 100vh;
  max-width: none; max-height: none;
  background: #000;
}
.call-panel:fullscreen .call-video, .call-panel:-webkit-full-screen .call-video {
  object-fit: contain;
}
.call-remote-avatar {
  width: 110px; height: 110px; font-size: 46px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 30px rgba(0,0,0,0.4);
}
.call-remote-avatar[hidden] { display: none; }

.call-remote-name {
  position: absolute;
  left: 16px; bottom: 86px;
  color: #fff; font-size: 15px; font-weight: 600;
  text-shadow: 0 1px 4px rgba(0,0,0,0.6);
  max-width: 60%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.call-state {
  position: absolute;
  left: 16px; bottom: 64px;
  color: rgba(255,255,255,0.78); font-size: 12px;
  text-shadow: 0 1px 4px rgba(0,0,0,0.6);
}

/* 本端小窗（画中画） */
.call-local-video {
  position: absolute;
  right: 16px; bottom: 86px;
  width: 132px; height: 99px;
  object-fit: cover;
  border-radius: 12px;
  background: #000;
  border: 2px solid rgba(255,255,255,0.18);
  box-shadow: 0 6px 24px rgba(0,0,0,0.45);
  transform: scaleX(-1); /* 镜像，更符合自拍直觉 */
  z-index: 2;
}

/* 通话主体：远端视频 + 本端小窗（聊天打开时一起右移让位） */
.call-body {
  position: absolute;
  inset: 0;
  transition: right 0.18s ease;
}
.call-panel.chat-open .call-body { right: 320px; }
.call-panel.chat-open .call-remote-wrap { right: 0; }
.call-panel.chat-open .call-local-video { right: 336px; }

/* ============ 通话内聊天抽屉 ============ */
.call-chat {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 320px;
  max-width: 86vw;
  display: flex;
  flex-direction: column;
  background: #11141c;
  border-left: 1px solid rgba(255,255,255,0.08);
  overflow: hidden;
  z-index: 4;
}
.call-chat[hidden] { display: none; }
.call-chat-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  background: rgba(255,255,255,0.04);
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.call-chat-close {
  border: none;
  background: transparent;
  color: #b9c0cc;
  font-size: 15px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
  line-height: 1;
}
.call-chat-close:hover { background: rgba(255,255,255,0.1); color: #fff; }
.call-chat-list {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.call-chat-empty {
  margin: auto;
  text-align: center;
  font-size: 12px;
  color: #7b8494;
  padding: 0 16px;
  line-height: 1.6;
}
.call-chat-msg {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-width: 88%;
  align-self: flex-start;
}
.call-chat-msg.me {
  align-self: flex-end;
  align-items: flex-end;
}
.call-chat-meta {
  display: flex;
  gap: 6px;
  align-items: baseline;
  font-size: 11px;
  color: #8a93a3;
}
.call-chat-name { font-weight: 600; color: #aeb6c4; }
.call-chat-time { color: #6b7384; }
.call-chat-text {
  background: rgba(255,255,255,0.08);
  color: #eef1f6;
  padding: 7px 10px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.45;
  word-break: break-word;
  white-space: pre-wrap;
}
.call-chat-msg.me .call-chat-text {
  background: var(--primary);
  color: #fff;
}
.call-chat-input {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.02);
}
.call-chat-input textarea {
  flex: 1 1 auto;
  resize: none;
  min-height: 38px;
  max-height: 120px;
  padding: 9px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.12);
  background: #0c0f16;
  color: #eef1f6;
  font: inherit;
  font-size: 13px;
  line-height: 1.4;
  outline: none;
}
.call-chat-input textarea:focus { border-color: var(--primary); }
.call-chat-send {
  flex: 0 0 auto;
  align-self: flex-end;
  padding: 9px 14px;
  border: none;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  font-size: 13px;
  cursor: pointer;
}
.call-chat-send:hover { filter: brightness(1.08); }

/* 控制条 */
.call-controls {
  position: absolute;
  left: 50%; bottom: 22px;
  transform: translateX(-50%);
  display: flex; gap: 14px;
  z-index: 3;
}
.call-ctrl {
  width: 52px; height: 52px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.14);
  color: #fff;
  font-size: 20px; line-height: 1;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  backdrop-filter: blur(6px);
  transition: background 0.12s, transform 0.12s;
}
.call-ctrl:hover { background: rgba(255,255,255,0.26); transform: translateY(-1px); }
.call-ctrl.off { background: rgba(255,80,80,0.85); border-color: rgba(255,80,80,0.9); }
.call-ctrl.active { background: var(--primary); border-color: var(--primary); box-shadow: 0 0 0 2px rgba(255,255,255,0.5); }
.call-ctrl.hangup { background: #e23b3b; border-color: #e23b3b; }
.call-ctrl.hangup:hover { background: #c92f2f; }
.call-ctrl.accept { background: #1faa59; border-color: #1faa59; }
.call-ctrl.accept:hover { background: #178a49; }

/* 来电弹窗 */
.call-incoming {
  position: fixed;
  inset: 0;
  z-index: 1100;
  background: rgba(8, 10, 16, 0.55);
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(3px);
}
.call-incoming[hidden] { display: none; }
.call-incoming-card {
  width: 260px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 26px 22px 22px;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  box-shadow: 0 18px 50px rgba(0,0,0,0.4);
  animation: callPop 0.18s ease-out;
}
@keyframes callPop {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.call-incoming-avatar {
  width: 84px; height: 84px; font-size: 34px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text);
  display: flex; align-items: center; justify-content: center;
  animation: callRing 1.1s ease-in-out infinite;
}
@keyframes callRing {
  0%, 100% { box-shadow: 0 0 0 0 rgba(31,170,89,0.5); }
  50% { box-shadow: 0 0 0 10px rgba(31,170,89,0); }
}
.call-incoming-name { font-size: 17px; font-weight: 600; color: var(--text); }
.call-incoming-type { font-size: 13px; color: var(--text-soft); margin-bottom: 6px; }
.call-incoming-actions { display: flex; gap: 16px; margin-top: 6px; }
.call-incoming-actions .call-ctrl { position: static; transform: none; }
.call-incoming-actions .call-ctrl:hover { transform: translateY(-1px); }

/* ============ 群会议面板（多人视频网格） ============ */
.meeting-panel {
  position: fixed;
  inset: 0;
  z-index: 1100;
  background: #0b0d12;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.meeting-panel[hidden] { display: none; }

.meeting-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(255,255,255,0.04);
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.meeting-title { font-size: 15px; font-weight: 600; color: #fff; }
.meeting-count {
  font-size: 12px; color: #b9c0cc;
  background: rgba(255,255,255,0.1);
  padding: 2px 8px; border-radius: 999px;
}
.meeting-leave {
  margin-left: auto;
  font-size: 13px;
  color: #fff;
  background: #e23b3b;
  border: 1px solid #e23b3b;
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
  transition: background 0.12s;
}
.meeting-leave:hover { background: #c92f2f; }

.meeting-grid {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  grid-auto-rows: 1fr;
  gap: 10px;
  padding: 12px;
  overflow: auto;
  align-content: center;
  justify-content: center;
}

.meeting-tile {
  position: relative;
  background: #1b1f2a;
  border-radius: 12px;
  overflow: hidden;
  min-height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255,255,255,0.06);
}
.meeting-tile.self { border-color: var(--primary); }

.meeting-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
  display: block;
}
.meeting-panel[data-type="audio"] .meeting-video { display: none; }

.meeting-name {
  position: absolute;
  left: 8px; bottom: 8px;
  max-width: calc(100% - 16px);
  font-size: 12px;
  color: #fff;
  background: rgba(0,0,0,0.55);
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
/* 语音会议时，视频元素隐藏（瓦片由 .meeting-avatar 显示头像占位，见下） */
/* 已离开会议状态：隐藏视频网格与控制条，显示“重新加入”状态条 */
.meeting-panel.left .meeting-grid,
.meeting-panel.left .call-controls { display: none; }
.meeting-panel.left {
  background: #0b0d12;
  align-items: center;
  justify-content: center;
}
.meeting-left-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 28px 32px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px;
}
.meeting-left-bar[hidden] { display: none; }

/* 会议主体：视频网格 + 聊天抽屉 横向排布 */
.meeting-body {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
  position: relative;
}

/* ============ 会议内聊天抽屉 ============ */
.meeting-chat {
  flex: 0 0 320px;
  width: 320px;
  max-width: 86vw;
  display: flex;
  flex-direction: column;
  background: #11141c;
  border-left: 1px solid rgba(255,255,255,0.08);
  overflow: hidden;
}
.meeting-chat[hidden] { display: none; }
.meeting-chat-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  background: rgba(255,255,255,0.04);
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.meeting-chat-close {
  border: none;
  background: transparent;
  color: #b9c0cc;
  font-size: 15px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
  line-height: 1;
}
.meeting-chat-close:hover { background: rgba(255,255,255,0.1); color: #fff; }
.meeting-chat-list {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.meeting-chat-empty {
  margin: auto;
  text-align: center;
  font-size: 12px;
  color: #7b8494;
  padding: 0 16px;
  line-height: 1.6;
}
.meeting-chat-msg {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-width: 88%;
  align-self: flex-start;
}
.meeting-chat-msg.me {
  align-self: flex-end;
  align-items: flex-end;
}
.meeting-chat-meta {
  display: flex;
  gap: 6px;
  align-items: baseline;
  font-size: 11px;
  color: #7b8494;
}
.meeting-chat-name { font-weight: 600; color: #9aa3b2; }
.meeting-chat-text {
  font-size: 13px;
  line-height: 1.5;
  color: #e8ebf0;
  background: #1d2230;
  padding: 7px 10px;
  border-radius: 10px;
  word-break: break-word;
  white-space: pre-wrap;
}
.meeting-chat-msg.me .meeting-chat-text {
  background: var(--primary);
  color: #fff;
}
.meeting-chat-input {
  flex: 0 0 auto;
  display: flex;
  gap: 6px;
  padding: 8px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.meeting-chat-input input {
  flex: 1 1 auto;
  min-width: 0;
  background: #0e1118;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  color: #e8ebf0;
  font-size: 13px;
  padding: 8px 10px;
  outline: none;
}
.meeting-chat-input input:focus { border-color: var(--primary); }
.meeting-chat-input .call-ctrl.accept { flex: 0 0 auto; }

/* 软离开（left）状态：隐藏视频网格/控制条，也隐藏聊天抽屉 */
.meeting-panel.left .meeting-chat { display: none; }
.meeting-left-text {
  font-size: 17px;
  font-weight: 600;
  color: #fff;
  letter-spacing: 0.5px;
}
.meeting-left-actions {
  display: flex;
  gap: 12px;
}
.meeting-left-actions .call-ctrl {
  width: auto;
  min-width: 96px;
  height: 40px;
  border-radius: 999px;
  font-size: 14px;
  padding: 0 18px;
}

/* 会议头部：全屏按钮 + 退出聚焦按钮 */
.meeting-full {
  margin-left: 8px;
  width: 34px; height: 34px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.08);
  color: #fff;
  font-size: 16px; line-height: 1;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.meeting-full:hover { background: rgba(255,255,255,0.18); }
.meeting-full.active { background: var(--primary); border-color: var(--primary); }

.meeting-spot-exit {
  margin-left: 8px;
  font-size: 13px;
  color: #fff;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.22);
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
  transition: background 0.12s;
}
.meeting-spot-exit:hover { background: rgba(255,255,255,0.24); }
.meeting-spot-exit[hidden] { display: none; }

/* 任意瓦片可点击聚焦 */
.meeting-tile { cursor: pointer; }
.meeting-tile.spotlight { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary); }
/* 共享屏幕的瓦片：完整显示屏幕内容（不裁切，黑边留白） */
.meeting-tile.screen .meeting-video { object-fit: contain; background: #000; }

/* 无视频（摄像头关闭且未共享屏幕）时：隐藏黑屏视频，居中显示头像占位 */
.meeting-avatar {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2;
  pointer-events: none;
}
.meeting-avatar img,
.meeting-avatar .avatar-letter {
  width: 72px; height: 72px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; font-weight: 700;
}
.meeting-tile.no-video .meeting-video { visibility: hidden; }
.meeting-tile.no-video .meeting-avatar { display: flex; }
/* 胶片条里的小窗头像略小 */
.meeting-filmstrip .meeting-avatar img,
.meeting-filmstrip .meeting-avatar :not(img) { width: 48px; height: 48px; font-size: 20px; }

/* 聚焦模式：主网格只放大被聚焦者，其余进入底部胶片条（横向滚动一排） */
.meeting-panel.spotlight .meeting-grid {
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
  grid-auto-rows: 1fr;
  align-content: stretch;
  justify-content: stretch;
  padding: 10px;
}
.meeting-panel.spotlight .meeting-tile.spotlight {
  grid-column: 1;
  grid-row: 1;
  min-height: 0;
}

.meeting-filmstrip {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
  padding: 8px 10px;
  overflow-x: auto;
  background: rgba(255,255,255,0.03);
  border-top: 1px solid rgba(255,255,255,0.08);
}
.meeting-filmstrip[hidden] { display: none; }
.meeting-filmstrip .meeting-tile {
  flex: 0 0 auto;
  width: 150px;
  height: 92px;
  min-height: 0;
}

/* ============================================================
   移动端 / 平板适配（不改动桌面端规则，仅在小屏生效）
   ============================================================ */

/* 平板 / 大屏手机：顶栏换行、网格 2~3 列、聊天侧栏收窄 */
@media (max-width: 768px) {
  .topbar {
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px 14px;
  }
  .search-wrap {
    order: 3;
    flex-basis: 100%;
    max-width: 100%;
  }
  .topbar-actions {
    margin-left: 0;
    flex-wrap: wrap;
    flex: 1 1 100%;
    justify-content: flex-start;
  }
  .content { padding: 12px 14px 36px; }
  .filters { padding: 12px 14px 4px; }
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 14px;
  }
  .chat-panel { height: 100dvh; width: 100vw !important; max-width: 100vw !important; }
  /* 移动端单栏：列表态仅显示会话列表，进入会话/详情后全屏显示聊天并隐藏列表 */
  .chat-sidebar { width: 100% !important; max-width: 100% !important; flex: 1 1 auto; display: flex !important; }
  .chat-main { display: none !important; }
  .chat-panel.mobile-conversation .chat-sidebar { display: none !important; }
  .chat-panel.mobile-conversation .chat-main { display: flex !important; }
  .chat-panel.mobile-conversation .chat-mobile-back { display: flex !important; align-items: center; padding: 6px 10px; border-bottom: 1px solid var(--border); background: var(--surface); }
  .chat-header { flex-wrap: wrap; gap: 8px; padding: 12px; }
  .chat-status { display: none; }
  .chat-input-row { padding: 12px; }
  .modal-card { width: min(520px, 94vw); }
  .settings-panel { width: 100vw; }
}

/* 手机：顶栏操作区改为单行横向滚动，网格固定 2 列，弹窗限高可滚动 */
@media (max-width: 480px) {
  .topbar { padding: 10px 12px; gap: 8px; }
  .brand { flex: 0 0 auto; }
  .brand-text p { display: none; }            /* 隐藏“X 个应用”副标题，省空间 */
  .user-name { display: none; }               /* 顶栏不显示用户名 */

  /* 操作按钮保持一行，超出则横向滚动，避免占满多行竖向空间 */
  .topbar-actions {
    flex: 1 1 auto;
    min-width: 0;
    margin-left: 0;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
  }
  .topbar-actions::-webkit-scrollbar { display: none; }
  .topbar-actions .btn { flex: 0 0 auto; padding: 8px 11px; font-size: 13px; }
  .search-wrap { order: 3; }

  .content { padding: 12px; }
  .filters { padding: 10px 12px 4px; gap: 6px; }

  /* 卡片固定 2 列，触控目标更大 */
  .grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .card { padding: 16px 10px 12px; gap: 8px; }
  .card .icon { width: 50px; height: 50px; font-size: 26px; }
  .card .name { font-size: 13px; }

  /* 弹窗：限制高度可滚动，避免长表单（添加应用）超出视口 */
  .modal-card {
    width: 94vw;
    max-height: 90vh;
    overflow-y: auto;
    padding: 18px;
  }
  .modal-actions { flex-wrap: wrap; }
  .modal-actions .btn { flex: 1 1 auto; }

  /* 聊天面板：窄屏单栏（规则由 ≤768 媒体查询统一提供，此处仅补充会话态细节） */
  .chat-panel { height: 100dvh; width: 100vw !important; max-width: 100vw !important; }

  .chat-header { flex-wrap: wrap; gap: 6px; padding: 10px 12px; }
  .chat-call-btn { padding: 7px 10px; font-size: 13px; }
  .chat-group-actions { flex-wrap: wrap; }
  .chat-group-actions .btn { padding: 7px 10px; font-size: 13px; }
  .chat-input-row { padding: 10px 12px; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  .chat-msg-row { max-width: 88%; }
  .chat-tabs { padding: 6px 4px 0; gap: 1px; }
  .chat-tab { font-size: 12px; padding: 7px 4px; }

  /* iframe 卡片收窄，避免超出小屏 */
  .iframe-page { width: 190px; }

  /* 通话/会议底部控制条避开刘海与底部安全区 */
  .call-controls { bottom: max(20px, env(safe-area-inset-bottom)); gap: 10px; }
  .call-ctrl { width: 48px; height: 48px; font-size: 18px; }

  /* 登录卡片铺满 */
  .auth-view { padding: 16px; }
  .auth-card { width: 100%; }

  /* toast 不超屏 */
  .toast { max-width: 90vw; }
}


