/* ============================================================
   Cipher 密链 v3.1 · 微信式贴边布局 / 对话框归集
   参考：微信会话列表、会话页、右下角 + 功能面板
   原则：无外框、无圆角卡片、无四周留白；所有附加能力归集到右下角 +
   本文件最后加载，覆盖 styles / redesign / vault / immersive
   ============================================================ */

:root {
  --wx-bg: #EDEDED;
  --wx-bar: #F7F7F7;
  --wx-line: rgba(0, 0, 0, .075);
  --wx-mine: #95EC69;
  --wx-paper: #FFFFFF;
  --wx-ink: #191919;
  --wx-sub: #9A9A9A;
}
html[data-theme="dark"] {
  --wx-bg: #191B20;
  --wx-bar: #1C1F25;
  --wx-line: rgba(255, 255, 255, .08);
  --wx-mine: #3E7C55;
  --wx-paper: #282C34;
  --wx-ink: #ECEFF5;
  --wx-sub: #8B93A1;
}

/* ---------- 1. 全站去外框 / 去留白 ---------- */
html, body { width: 100%; }
.view-root { padding: 0 !important; }
.view,
html[data-immersive="1"] .view {
  padding: 0 !important;
  margin: 0 !important;
  max-width: none !important;
  width: 100% !important;
}
.view-root > .view,
html[data-immersive="1"] .view-root > .view {
  max-width: none !important;
  width: 100% !important;
  margin: 0 !important;
}
.view-head {
  margin: 0 !important;
  padding: 14px 16px 13px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  border-radius: 0;
}
.view-head h1 { font-size: 19px; }
.view-head p { margin-top: 3px; }
.section-label { margin: 0; padding: 14px 16px 6px; }
.card,
html[data-immersive="1"] .card {
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.card-head { margin-bottom: 10px; }
.card-foot { border-top: 1px solid var(--border); }
.kpi-grid, .wallet-top, .v2-pulse, .im-grid, .im-stats { gap: 1px !important; }
.v2-pulse, .demo-tag { border-radius: 0 !important; }
/* 各业务页的卡片 / 横幅 / 磁贴统一贴边：去圆角、去浮起阴影 */
.view [class*="card"], .view [class*="hero"], .view [class*="banner"], .view [class*="tile"],
.view [class*="kpi"], .view [class*="quick"], .view [class*="pulse"], .view [class*="stat"],
.view .qa, .view .qa-ic {
  border-radius: 0 !important;
  box-shadow: none !important;
}
#chat-pane .pay-card, #chat-pane .pay-top { border-radius: 6px !important; }

/* 全局工具条：主 Tab 只保留页面自己的标题栏，去掉第二层顶栏与悬浮 FAB */
html:not([data-immersive="1"]):not([data-page="1"]) .topbar { display: none !important; }
.topbar { border-radius: 0 !important; border-bottom: 1px solid var(--border) !important; }
html:not([data-immersive="1"]):not([data-page="1"]) .v2-fab-fixed { display: none !important; }

/* ---------- 2. 沉浸式页面贴边 ---------- */
.im-pbody { padding: 0 0 72px !important; }
.im-pbody > * { max-width: none !important; margin-left: 0 !important; margin-right: 0 !important; }
.im-pfoot { padding: 12px 16px !important; }
.im-pfoot > * { max-width: none !important; }
.im-phead { border-radius: 0 !important; padding: 0 14px !important; }
.im-head { border-radius: 0 !important; padding: 0 14px !important; }
.im-sec { margin: 0 0 16px !important; }
.im-sec-h { padding: 10px 16px !important; margin: 0 !important; background: var(--surface-2); border-radius: 0 !important; }
.im-card {
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  border-bottom: 1px solid var(--border);
}
.im-card.pad { padding: 14px 16px !important; }
.im-card + .im-card { margin-top: 0 !important; }
.im-row { padding: 13px 16px !important; border-radius: 0 !important; }
.im-row-ic { border-radius: 8px !important; }
.im-tile,
.im-stat,
.im-hero,
.im-note,
.im-empty,
.im-bubble {
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  border-bottom: 1px solid var(--border);
}
.im-tile { padding: 14px 16px !important; }
.im-tile:hover { transform: none !important; box-shadow: none !important; }
.im-stat { padding: 14px 16px !important; }
.im-hero { padding: 18px 16px !important; }
.im-hero .im-avatar { border-radius: 8px !important; }
.im-note { padding: 13px 16px !important; margin: 0 0 14px !important; }
.im-search { border: 0 !important; border-radius: 0 !important; padding: 0 16px !important; height: 48px !important; border-bottom: 1px solid var(--border) !important; margin: 0 0 12px !important; }
.im-chips { padding: 10px 16px !important; margin: 0 0 8px !important; }
.im-chip { border-radius: 6px !important; }
.im-grid.g2, .im-grid.g3, .im-grid.g4 { gap: 1px !important; }
.im-empty { padding: 34px 16px !important; }
.im-extra { padding: 14px 0 0 !important; }
.im-extra-h { padding: 0 16px 10px !important; }
.im-camera, .im-qr-box { border-radius: 0 !important; }

/* ---------- 3. 弹窗 / 对话框统一归集（贴边、无外框） ---------- */
.modal-root { padding: 0 !important; align-items: center !important; }
.modal {
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  width: 100% !important;
  max-width: 560px !important;
  padding: 18px !important;
  max-height: 88vh !important;
}
.modal.wide { max-width: 720px !important; }
.modal-head { padding: 0 0 14px !important; border-bottom: 1px solid var(--border); margin-bottom: 14px !important; }
.v2-sheet { border: 0 !important; border-radius: 0 !important; box-shadow: none !important; padding: 14px !important; }
.v2-msg-menu { border-radius: 8px !important; }
@media (max-width: 767px) {
  .modal-root { align-items: flex-end !important; }
  .modal { max-width: none !important; width: 100% !important; max-height: 82vh !important; padding: 16px !important; }
  .v2-sheet { left: 0 !important; right: 0 !important; width: 100% !important; }
}

/* ---------- 4. 会话列表：微信单标题栏 ---------- */
.chat-layout,
html[data-immersive="1"] .chat-layout {
  border: 0 !important;
  border-radius: 0 !important;
  overflow: hidden;
  background: var(--surface) !important;
}
.conv-panel,
html[data-immersive="1"] .conv-panel { border-right: 0 !important; background: var(--surface) !important; }
#view-chat > .im-launch,
#conv-panel .panel-head,
#conv-panel .im-chatbar,
#conv-panel .im-folder-chips,
#conv-filters { display: none !important; }

.wx-titlebar {
  height: 52px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  background: var(--wx-bar);
  border-bottom: 1px solid var(--wx-line);
}
.wx-titlebar h1 { font-size: 17px; font-weight: 600; letter-spacing: .5px; }
.wx-tb-acts { position: absolute; right: 12px; top: 0; height: 100%; display: flex; align-items: center; gap: 12px; }
.wx-tb-btn {
  width: 30px; height: 30px; border: 0; background: transparent; color: var(--wx-ink);
  display: flex; align-items: center; justify-content: center; padding: 0; cursor: pointer;
}
.wx-tb-btn:hover { color: var(--brand); }
.wx-tb-btn svg { width: 22px; height: 22px; }
.wx-tb-btn.plus svg { width: 25px; height: 25px; }
.wx-device {
  flex: none; display: flex; align-items: center; gap: 8px; padding: 9px 14px;
  font-size: 11.5px; color: var(--text-3); background: var(--surface-2);
  border-bottom: 1px solid var(--wx-line); cursor: pointer;
}
.wx-device svg { width: 15px; height: 15px; flex: none; }
.wx-device span { flex: 1; min-width: 0; }
.wx-device em { font-style: normal; font-size: 10.5px; color: var(--text-3); }
.wx-menu {
  position: absolute; z-index: 60; top: 48px; right: 10px; min-width: 172px;
  background: var(--wx-paper); border: 1px solid var(--wx-line);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .14); padding: 5px 0; border-radius: 4px;
}
.wx-menu button {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 14px;
  border: 0; background: transparent; color: var(--wx-ink); font-size: 13px; text-align: left; cursor: pointer;
}
.wx-menu button:hover { background: var(--surface-2); }
.wx-menu svg { width: 17px; height: 17px; flex: none; }

#conv-panel .search-inline {
  display: none;
  margin: 0 !important;
  height: 44px;
  border-radius: 0 !important;
  padding: 0 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--wx-line);
}
#conv-panel.wx-search .search-inline { display: flex !important; }
.conv-list { padding: 0 !important; }
.conv {
  width: 100% !important;
  border-radius: 0 !important;
  padding: 11px 14px !important;
  margin: 0 !important;
  gap: 12px !important;
  border: 0 !important;
  border-bottom: 0 !important;
  background: var(--surface) !important;
  box-shadow: none !important;
  position: relative;
}
/* 微信式分隔线：从头像右侧（文字起点）开始，不横穿头像 */
.conv::after {
  content: ''; position: absolute; left: 73px; right: 0; bottom: 0;
  height: 1px; background: var(--wx-line); pointer-events: none;
}
.conv:hover { background: var(--surface-2) !important; }
.conv.active { background: var(--surface-2) !important; box-shadow: none !important; }
.conv .avatar { width: 47px; height: 47px; border-radius: 7px !important; font-size: 16px; flex: none; }
.conv-main { min-width: 0; flex: 1; }
.conv-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.conv-top strong { font-size: 15px; font-weight: 500; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-top span { font-size: 11px; color: var(--wx-sub); flex: none; }
.conv-sub { font-size: 12.5px; color: var(--wx-sub); margin-top: 5px; }
.conv-sub .txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv .badge { background: #F04B3F; color: #fff; font-size: 10px; min-width: 18px; height: 18px; border-radius: 9px; }
.v2-conv-more { display: none !important; }
.v2-conv-flags { display: none !important; }

/* ---------- 5. 会话页：返回 / 居中标题 / … ---------- */
.chat-pane,
html[data-immersive="1"] .chat-pane {
  background: var(--wx-bg) !important;
  border: 0 !important;
  border-radius: 0 !important;
  overflow: hidden;
}
.chat-head {
  height: 52px !important;
  flex: none;
  background: var(--wx-bar) !important;
  border-bottom: 1px solid var(--wx-line) !important;
  justify-content: center !important;
  padding: 0 12px !important;
  position: relative;
  gap: 0 !important;
}
.chat-head #chat-back { position: absolute; left: 8px; top: 10px; width: 32px; height: 32px; color: var(--wx-ink); }
.chat-head #chat-back svg { width: 22px; height: 22px; }
.chat-head #chat-avatar,
.chat-head #chat-info,
.chat-head #chat-status { display: none !important; }
.chat-head .chat-peer { flex: none !important; align-items: center; text-align: center; max-width: 62%; }
.chat-head .chat-peer strong { font-size: 16px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-head #chat-more { position: absolute; right: 8px; top: 10px; width: 32px; height: 32px; color: var(--wx-ink); }
.chat-head #chat-more svg { width: 22px; height: 22px; }
@media (min-width: 768px) { .chat-head #chat-back { display: none; } }
html[data-force="phone"] .chat-head #chat-back { display: flex !important; }

/* 所有外露工具条归集到 + 面板 */
.v2-chat-tools,
.e2ee-banner,
.v2-composer-extra,
.im-more-tools,
.composer-tools { display: none !important; }

.msg-scroll { background: var(--wx-bg) !important; padding: 16px 12px !important; gap: 14px !important; }
.day-sep {
  background: transparent !important; border: 0 !important; box-shadow: none !important;
  color: var(--wx-sub) !important; font-size: 11px !important; padding: 2px 0 !important; margin: 0 0 2px !important;
  border-radius: 0 !important;
}
.msg-row { max-width: 100% !important; gap: 9px; }
.msg-row .avatar { width: 40px; height: 40px; border-radius: 6px !important; font-size: 14px; align-self: flex-start !important; }
.msg-body { max-width: 76%; }
.bubble {
  background: var(--wx-paper) !important;
  color: var(--wx-ink) !important;
  border: 0 !important;
  box-shadow: none !important;
  border-radius: 5px !important;
  padding: 10px 13px !important;
  font-size: 14.5px !important;
  line-height: 1.5 !important;
  max-width: 100% !important;
}
.msg-row.mine .bubble { background: var(--wx-mine) !important; color: #14200F !important; }
html[data-theme="dark"] .msg-row.mine .bubble { color: #F2FFF0 !important; }
.msg-time { color: var(--wx-sub) !important; opacity: .8; }
.msg-row.mine .msg-time { justify-content: flex-end; }
.v2-quote { border-radius: 4px !important; }
.pay-card { border-radius: 6px !important; border: 0 !important; }
.pay-top { border-radius: 6px 6px 0 0; }
.v2-msg-actions { border-radius: 6px !important; }
.v2-recalled { color: var(--wx-sub) !important; }

/* ---------- 6. 输入栏：语音 / 文本 / 表情 / 右下角 + ---------- */
.composer {
  flex: none;
  border-top: 1px solid var(--wx-line) !important;
  background: var(--wx-bar) !important;
  padding: 8px 10px !important;
  gap: 7px !important;
  align-items: center !important;
  border-radius: 0 !important;
}
#msg-input {
  flex: 1; min-width: 0; height: 40px; min-height: 40px; max-height: 96px;
  background: var(--wx-paper) !important; color: var(--wx-ink) !important;
  border: 1px solid var(--wx-line) !important; border-radius: 5px !important;
  padding: 9px 11px !important; font-size: 14px !important; line-height: 1.4 !important;
  resize: none; box-shadow: none !important;
}
#msg-input::placeholder { color: var(--wx-sub); }
.wx-cbtn {
  width: 31px; height: 31px; flex: none; padding: 0; border: 0; background: transparent;
  color: var(--wx-ink); display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.wx-cbtn:hover { color: var(--brand); }
.wx-cbtn svg { width: 25px; height: 25px; }
.wx-cbtn.plus { border: 1.7px solid currentColor; border-radius: 50%; width: 29px; height: 29px; }
.wx-cbtn.plus svg { width: 19px; height: 19px; }
.wx-cbtn.on { color: var(--brand); }
#send-btn { border-radius: 6px !important; height: 36px !important; width: 52px !important; flex: none; }
.composer:not(.wx-typing) #send-btn { display: none !important; }
.composer.wx-typing #wx-plus { display: none !important; }

/* ---------- 7. 右下角 + 实用功能面板 ---------- */
.wx-panel {
  flex: none; display: none; flex-direction: column;
  height: 246px; background: var(--wx-bar);
  border-top: 1px solid var(--wx-line); padding: 14px 4px 4px;
  overflow: hidden;
}
.wx-panel.on { display: flex; }
.wx-pages { flex: 1; display: flex; overflow: hidden; }
.wx-page {
  flex: none; width: 100%; display: none;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: repeat(2, 96px);
  gap: 4px 0; align-content: start;
}
.wx-page.on { display: grid; }
.wx-item {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  border: 0; background: transparent; color: var(--text-2);
  font-size: 11.5px; cursor: pointer; padding: 0;
}
.wx-item i {
  width: 56px; height: 56px; border-radius: 13px; background: var(--wx-paper);
  display: flex; align-items: center; justify-content: center; color: var(--wx-ink);
  font-style: normal; box-shadow: 0 1px 2px rgba(0, 0, 0, .04);
}
.wx-item i svg { width: 26px; height: 26px; }
.wx-item:hover i { background: var(--brand-soft); color: var(--brand); }
.wx-item:hover { color: var(--brand); }
.wx-dots { display: flex; justify-content: center; align-items: center; gap: 7px; height: 20px; flex: none; }
.wx-dots button { width: 16px; height: 12px; padding: 0; border: 0; background: transparent; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.wx-dots b { width: 6px; height: 6px; border-radius: 50%; background: #C6C9CF; display: block; }
.wx-dots button.on b { background: #7D838F; }
.wx-panel-foot { display: none; }

/* ---------- 8. 响应式 ---------- */
@media (max-width: 767px) {
  .chat-head { height: 50px !important; }
  .wx-panel { height: 232px; }
  .wx-page { grid-template-rows: repeat(2, 90px); }
  .wx-item i { width: 54px; height: 54px; }
  .wx-item { font-size: 11px; }
  .view-head { padding: 12px 14px 11px; }
  .im-phead, .im-head { padding: 0 12px !important; }
  .im-row, .im-card.pad, .im-tile, .card { padding-left: 14px !important; padding-right: 14px !important; }
}
