﻿/* ==========================================================
   官网客服 · 共享样式
   纯前端零依赖，file:// 直接打开即可运行
   ========================================================== */

:root {
  --brand: #3b6cf6;
  --brand-dark: #2a51d0;
  --brand-soft: #eaf0ff;
  --bg: #f3f5fa;
  --panel: #ffffff;
  --line: #e7eaf3;
  --line-soft: #f0f2f8;
  --text: #1b2233;
  --text-2: #4a5468;
  --muted: #8b95a9;
  --danger: #f5455c;
  --ok: #12b76a;
  --warn: #f79009;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 6px 26px rgba(22, 38, 74, 0.08);
  --shadow-sm: 0 2px 8px rgba(22, 38, 74, 0.06);
  --sidebar: #182036;
  --sidebar-2: #212b45;
  --topbar-h: 58px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button {
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

input, textarea, select {
  font-family: inherit;
  font-size: 14px;
  color: inherit;
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb {
  background: #cdd3e2;
  border-radius: 99px;
}
::-webkit-scrollbar-thumb:hover { background: #b3bbcd; }
::-webkit-scrollbar-track { background: transparent; }

.hidden { display: none !important; }

/* -------------------------------------------------- 通用组件 */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border-radius: 9px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text-2);
  font-weight: 500;
  white-space: nowrap;
  transition: all 0.15s;
}
.btn:hover { border-color: #c9d2e8; color: var(--brand); background: #fbfcff; }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  box-shadow: 0 4px 12px rgba(59, 108, 246, 0.28);
}
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: #fff1f3; border-color: #ffd3d9; color: var(--danger); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 13px; border-radius: 7px; }
/* 「消息提醒」按钮：未开启是普通灰态，点一下就能开；
   开启后常亮蓝并轻微呼吸，让访客知道提醒是生效的。 */
#btnNotify.on {
  background: #1677ff;
  border-color: #1677ff;
  color: #fff;
  animation: notifyPulse 2.4s ease-in-out infinite;
}
@keyframes notifyPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(22, 119, 255, .35); }
  50% { box-shadow: 0 0 0 5px rgba(22, 119, 255, 0); }
}
@media (prefers-reduced-motion: reduce) {
  #btnNotify.on { animation: none; }
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.tag {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 7px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 500;
}
.tag-waiting { background: #fff4e5; color: #d97706; }
.tag-active { background: #e7f8f0; color: #0e9f6e; }
.tag-closed { background: #f0f2f7; color: var(--muted); }

.avatar {
  flex: none;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  color: #fff;
  font-weight: 600;
  font-size: 15px;
  user-select: none;
}
.avatar.sm { width: 32px; height: 32px; border-radius: 10px; font-size: 13px; }
.avatar.lg { width: 52px; height: 52px; border-radius: 15px; font-size: 19px; }

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  flex: none;
}
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px rgba(18, 183, 106, 0.16); }
.dot.off { background: #b6bdcb; }
/* 连接不畅：黄色，和「客服离线」的灰色区分开。
   客户看到灰色会以为客服不在，看到黄色才知道是自己的网络在抖。 */
.dot.idle {
  background: #f5a623;
  box-shadow: 0 0 0 3px rgba(245, 166, 35, 0.18);
  animation: dot-idle 1.4s ease-in-out infinite;
}
@keyframes dot-idle {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.badge {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 99px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  display: grid;
  place-items: center;
  flex: none;
}

.toast-wrap {
  position: fixed;
  left: 50%;
  top: 72px;
  transform: translateX(-50%);
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}
.toast {
  padding: 9px 16px;
  border-radius: 10px;
  background: rgba(24, 32, 54, 0.92);
  color: #fff;
  font-size: 13px;
  box-shadow: var(--shadow);
  animation: toast-in 0.22s ease;
  max-width: 80vw;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
/* 退场交给 CSS。以前是用 JS 逐条改 opacity/transform，
   一帧内要写三次 style，看着像闪一下。 */
.toast.out { opacity: 0; transform: translateY(-8px); }
.toast.err { background: rgba(219, 45, 70, 0.95); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: none; }
}

/* 弹窗 */
dialog {
  border: none;
  border-radius: 16px;
  padding: 0;
  width: min(520px, 92vw);
  box-shadow: 0 24px 70px rgba(15, 25, 50, 0.3);
  color: var(--text);
}
dialog::backdrop { background: rgba(17, 24, 43, 0.45); }

/* 扫码监控窗：比默认的 520px 宽得多，否则左边的二维码卡片
   和右边的实时列表挤在一起，两边都没法看 */
.dlg-wide { width: min(1080px, 94vw); }
.dlg-head-right { display: flex; align-items: center; gap: 8px; }
/* iframe 自己有滚动条，外层就别再套一层，免得出现双滚动条 */
.dlg-body-flush { padding: 0; max-height: none; overflow: hidden; }
.scan-frame {
  display: block;
  width: 100%;
  height: min(74vh, 720px);
  border: 0;
  background: var(--bg);
}
.dlg-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
}

/* ---- 域名池（抽签式）----
   不铺开 50 个域名：客服用不上「挑」这个动作，铺开只是让他
   在紧急换域名时多花时间找。默认 520px 的弹窗就够用。 */
.dom-lead {
  margin: 0 0 4px;
  font-size: 12px;
  color: var(--muted);
}
.dom-cur {
  margin: 0 0 14px;
  padding: 9px 12px;
  background: #f2f6ff;
  border: 1px solid #d6e2ff;
  border-radius: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  font-weight: 600;
  color: var(--brand, #2f6bff);
  word-break: break-all;
  line-height: 1.5;
}
.dom-stat {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}
.dom-num {
  flex: 1;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  text-align: center;
  background: #fff;
}
.dom-num b {
  display: block;
  font-size: 26px;
  line-height: 1.2;
  color: #22a06b;
}
.dom-num span {
  display: block;
  margin-top: 2px;
  font-size: 11.5px;
  color: var(--muted);
}
/* 已发放的那格压暗：它是「弹药已经打出去」的量，不该跟剩余的一样显眼 */
.dom-num.dim b { color: #9aa4b8; }
.dom-num.dim { background: #fafbfd; }
.dom-note {
  margin: 0 0 14px;
  padding: 10px 12px;
  background: #fff8e6;
  border: 1px solid #ffe0a3;
  border-radius: 10px;
  font-size: 12px;
  line-height: 1.7;
  color: #6b4c00;
}
.dom-note.warn {
  background: #fff0f0;
  border-color: #ffc9c9;
  color: #9a2b2b;
}
.dom-actions { display: flex; gap: 10px; }
.dom-actions .btn-lg {
  flex: 1;
  padding: 12px 16px;
  font-size: 15px;
}

/* ================= 数据面板 ================= */
.st-range { display: flex; gap: 0; margin-right: 8px; }
.st-range-b {
  padding: 5px 11px;
  font-size: 12.5px;
  color: #5b6478;
  background: #f4f6fa;
  border: 1px solid var(--line);
  cursor: pointer;
  font-family: inherit;
}
.st-range-b:first-child { border-radius: 8px 0 0 8px; }
.st-range-b:last-child { border-radius: 0 8px 8px 0; }
.st-range-b + .st-range-b { border-left: 0; }
.st-range-b.on { background: var(--brand, #2f6bff); border-color: var(--brand, #2f6bff); color: #fff; }

.st-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.st-card {
  padding: 13px 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fafbfd;
}
.st-card b { display: block; font-size: 25px; line-height: 1.15; color: #1f2430; }
.st-card span { font-size: 12px; color: #6b7280; }
.st-card small { display: block; font-size: 11px; color: #9aa0ad; margin-top: 3px; }
.st-card.hi { background: #eefaf1; border-color: #c4e9cf; }
.st-card.hi b { color: #17663a; }

.st-block { margin-bottom: 18px; }
.st-sub { font-size: 13px; color: #41485a; margin-bottom: 8px; font-weight: 600; }
.st-legend { display: flex; gap: 16px; font-size: 12px; color: #6b7280; margin-bottom: 6px; }
.st-legend i { display: inline-block; width: 10px; height: 3px; border-radius: 2px; margin-right: 5px; vertical-align: middle; }
.st-d.st-reception { background: #8ab4ff; }
.st-d.st-effective { background: #2f6bff; }
.st-d.st-reply { background: #21a366; }

#stCanvas { width: 100%; display: block; }

/* 表格不再自带 max-height/overflow：外面 .dlg-body 已经在滚了，
   再套一层会出现双滚动条（细的那个还得用鼠标悬停才出现，很难发现）。
   thead 的 sticky 依然生效 —— 它是相对最近的滚动祖先（.dlg-body）定位的。 */
.st-table-wrap { border: 1px solid var(--line); border-radius: 10px; }
.st-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.st-table th, .st-table td { padding: 7px 10px; text-align: right; border-bottom: 1px solid var(--line); }
.st-table th:first-child, .st-table td:first-child { text-align: left; }
.st-table thead th { position: sticky; top: 0; background: #f7f9fc; font-weight: 600; color: #41485a; z-index: 1; }
.st-table tbody tr:last-child td { border-bottom: 0; }
.st-table td.zero { color: #b6bcc8; }

.st-rules summary { cursor: pointer; font-size: 13px; color: #41485a; font-weight: 600; }
.st-rules .field, .st-rules .switch, .st-rules .btn, .st-rules .desc { margin-top: 10px; }
.st-rules input[type=number] { width: 110px; height: 32px; padding: 0 9px; border: 1px solid var(--line); border-radius: 8px; font-family: inherit; font-size: 13px; }

@media (max-width: 640px) {
  .st-cards { grid-template-columns: repeat(2, 1fr); }
  .st-range-b { padding: 5px 8px; font-size: 12px; }
}

/* ================= 额度与卡密 ================= */
.q-redeem { display: flex; gap: 8px; align-items: center; }
.q-redeem input {
  flex: 1; height: 34px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: 8px;
  font-family: inherit; font-size: 13px;
  letter-spacing: .4px;   /* 卡密是分组大写，等宽一点点好核对 */
}
.q-switch { margin-top: 14px; }
.q-gen { margin-top: 14px; padding: 12px; background: #fafbfd; border: 1px solid var(--line); border-radius: 10px; }
.q-gen-row { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }
.q-gen-row + .q-gen-row { margin-top: 9px; }
.q-gen-l { font-size: 12.5px; color: #5b6478; }
.q-gen input {
  width: 82px; height: 30px; padding: 0 8px;
  border: 1px solid var(--line); border-radius: 7px;
  font-family: inherit; font-size: 13px;
}
.q-gen .desc { margin-top: 10px; }

.q-cards { margin-top: 14px; }
.q-sub { font-size: 12.5px; color: #41485a; margin-bottom: 7px; font-weight: 600; }
.q-table-wrap { max-height: 240px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
.q-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.q-table th, .q-table td { padding: 7px 9px; text-align: left; border-bottom: 1px solid var(--line); }
.q-table thead th { position: sticky; top: 0; background: #f7f9fc; font-weight: 600; color: #41485a; z-index: 1; }
.q-table tbody tr:last-child td { border-bottom: 0; }
.q-table tr.used td { color: #9aa0ad; }
.q-code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .3px; }
.q-state { font-size: 11.5px; padding: 2px 7px; border-radius: 20px; display: inline-block; }
.q-state.free { background: #eefaf1; color: #17663a; }
.q-state.used { background: #f1f2f5; color: #6b7280; }

/* 每个账号的额度条 */
.q-bar { display: flex; flex-direction: column; gap: 3px; width: 100%; }
.q-bar-row { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: #5b6478; }
.q-bar-track { flex: 1; height: 5px; background: #eef1f6; border-radius: 3px; overflow: hidden; min-width: 40px; }
.q-bar-fill { height: 100%; background: #2f6bff; border-radius: 3px; }
.q-bar-fill.warn { background: #e8a33d; }
.q-bar-fill.over { background: #d64545; }
.q-bar-row b { font-weight: 600; color: #41485a; min-width: 52px; }
.q-link-row { display: flex; align-items: center; gap: 6px; width: 100%; }
.q-link {
  flex: 1; font-size: 11.5px; color: #2f6bff; cursor: pointer;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.q-link:hover { text-decoration: underline; }
.q-qr { border: 0; padding: 0; background: #fff; cursor: pointer; line-height: 0; }
.q-qr img, .q-qr canvas { width: 42px; height: 42px; display: block; }

/* 一次性展示（密码 / 卡密）沿用 acc-once 的样式 */
#cardOnceBox .acc-once { margin-top: 12px; }

@media (max-width: 640px) {
  .q-table-wrap { max-height: 200px; }
}

/* ================= 账号管理 ================= */
.acc-me {
  margin: 0 0 9px;
  padding: 7px 10px;
  background: #eef4ff;
  border: 1px solid #cfe0ff;
  border-radius: 8px;
  font-size: 12.5px;
  color: #1c4f9e;
}
.acc-create {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}
.acc-create input {
  flex: 1 1 130px;
  min-width: 0;
  height: 32px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
}
.acc-create select {
  height: 32px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  background: #fff;
}
.acc-create .btn { flex: none; }

.acc-list { margin: 10px 0 0; padding: 0; list-style: none; }
.acc-item {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px 10px;
  background: #fafbfd;
  border: 1px solid var(--line);
  border-radius: 9px;
  margin-bottom: 6px;
}
.acc-item.off { background: #f6f6f7; opacity: .75; }
.acc-item.expired { background: #fff8e6; }
.acc-u {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  font-weight: 600;
  color: #1f2430;
}
.acc-note {
  flex: 1 1 100%;
  font-size: 12px;
  color: #6b7280;
  word-break: break-all;
}
/* 状态标签：正常 / 已停用 / 已到期 */
.acc-tag {
  flex: none;
  padding: 1px 7px;
  border-radius: 9px;
  font-size: 11px;
  white-space: nowrap;
  border: 1px solid transparent;
}
.acc-tag.ok { background: #eefaf1; border-color: #c4e9cf; color: #17663a; }
.acc-tag.off { background: #f0f1f3; border-color: #dcdfe4; color: #6b7280; }
.acc-tag.exp { background: #fff8e6; border-color: #ffdf9e; color: #8a5a00; }
.acc-meta { flex: none; font-size: 11px; color: #9aa0ad; }
.acc-acts { flex: none; display: flex; gap: 5px; margin-left: auto; }
.acc-item input.acc-edit {
  flex: 1 1 110px;
  min-width: 0;
  height: 26px;
  padding: 0 7px;
  border: 1px solid var(--line);
  border-radius: 7px;
  font-size: 12px;
  font-family: inherit;
}
/* 新建后弹出的那一次密码，必须显眼 —— 复制走就永远看不到了 */
.acc-once {
  margin: 10px 0 0;
  padding: 10px 12px;
  background: #eefaf1;
  border: 1px solid #b9e3c8;
  border-radius: 9px;
  font-size: 12.5px;
  line-height: 1.7;
  color: #14532b;
  word-break: break-all;
}
.acc-once code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13.5px;
  font-weight: 600;
  background: #fff;
  padding: 2px 6px;
  border-radius: 5px;
  user-select: all;
}
.acc-empty { font-size: 12px; color: #9aa0ad; padding: 8px 0; }

/* 登录框多了一个账号输入框 */
.lock-box input { display: block; }

/* 已作废域名明细：默认收起，展开后逐条列出来。   域名本身是长串，按钮靠右固定宽度，免得每行按钮位置都在跳。 */
.dom-used {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.dom-used-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  padding: 7px 2px;
  background: none;
  border: 0;
  font: inherit;
  font-size: 13px;
  color: var(--text-2, #5b6478);
  cursor: pointer;
  text-align: left;
}
.dom-used-toggle:hover { color: var(--text-1, #1f2430); }
.dom-caret {
  display: inline-block;
  width: 10px;
  font-size: 11px;
  color: #9aa4b8;
}
.dom-used-n {
  margin-left: 2px;
  padding: 1px 7px;
  background: #f0f2f7;
  border-radius: 9px;
  font-size: 12px;
  color: #5b6478;
}
.dom-used-list {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}
.dom-used-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  background: #fafbfd;
  border: 1px solid var(--line);
  border-radius: 9px;
  margin-bottom: 6px;
}
.dom-used-item:last-child { margin-bottom: 0; }
/* 长域名会撑破窄屏，截断而不是换行 —— 换行会让每行高度不一致，
   一眼看过去对不齐。title 里有完整值，鼠标悬停能看到。 */
.dom-used-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12.5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: #5b6478;
}
/* 标签成组：域名名 + 一串状态 + 一串按钮，三段各自不换行。 */
.dom-used-tags { flex: none; display: flex; gap: 4px; }
.dom-used-acts { flex: none; display: flex; gap: 6px; }
.dom-used-tag {
  flex: none;
  padding: 1px 7px;
  border-radius: 9px;
  font-size: 11px;
  white-space: nowrap;
  border: 1px solid transparent;
}
.dom-used-tag.use   { background: #e8f4ff; border-color: #c3e0ff; color: #1a5fb4; }
.dom-used-tag.block { background: #fff1f3; border-color: #ffc9d2; color: #a5203a; }
.dom-used-tag.hot   { background: #fff8e6; border-color: #ffdf9e; color: #8a5a00; }
.dom-used-item .btn { flex: none; }
/* 置灰时不该看起来还能点：默认 disabled 样式太淡，这里压到和文字同色。 */
.dom-used-item .btn[disabled] { opacity: .45; cursor: not-allowed; }
/* 窄屏（微信里横竖屏都可能）先把域名让出去，按钮和标签换到第二行，
   否则 3 个标签 + 2 个按钮会把域名挤成一个点。 */
@media (max-width: 560px) {
  .dom-used-item { flex-wrap: wrap; }
  .dom-used-name { flex: 1 0 100%; }
  .dom-used-tags { margin-right: auto; }
}
/* 删掉之后那一行淡出再消失。列表马上重画的话会「跳」，先给 0.9s 的过渡。 */
.dom-used-item.gone {
  opacity: .35;
  text-decoration: line-through;
  transition: opacity .5s, background .5s;
}
/* 弹窗内的状态行。toast 挂在 body 上、会被 showModal 的遮罩压住看不见，
   删除这种要等好几秒的操作必须有个弹窗里能看见的进度。 */
.dom-status {
  margin: 10px 0 0;
  padding: 9px 12px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #f4f6fa;
  font-size: 12.5px;
  line-height: 1.6;
  color: #41485a;
  word-break: break-all;
}
.dom-status.busy { background: #eef4ff; border-color: #cfe0ff; color: #1c4f9e; }
.dom-status.ok   { background: #eefaf1; border-color: #c4e9cf; color: #17663a; }
.dom-status.err  { background: #fff1f3; border-color: #ffc9d2; color: #9a2038; }
.dom-note.small { font-size: 11.5px; margin: 10px 0 0; }
.dlg-body { padding: 18px 20px; max-height: 62vh; overflow: auto; }
.dlg-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  background: #fafbfe;
  border-radius: 0 0 16px 16px;
}
.field { margin-bottom: 16px; }
.field > label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 6px;
}
.field .desc { font-size: 12px; color: var(--muted); margin-top: 5px; }
.field input[type="text"],
.field textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field textarea { resize: vertical; min-height: 72px; line-height: 1.6; }
.field input:focus, .field textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(59, 108, 246, 0.12);
}
.switch { display: flex; align-items: center; gap: 9px; cursor: pointer; user-select: none; }
.switch input { width: 16px; height: 16px; accent-color: var(--brand); }

/* -------------------------------------------------- 消息气泡（两端共用） */

.msgs-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  position: relative;
}

.msgs {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px 22px 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  scroll-behavior: smooth;
}

.day-sep {
  align-self: center;
  margin: 12px 0 10px;
  padding: 3px 11px;
  border-radius: 99px;
  background: rgba(0, 0, 0, 0.05);
  color: var(--muted);
  font-size: 12px;
  user-select: none;
}

.sys-msg {
  align-self: center;
  max-width: 76%;
  margin: 6px 0;
  padding: 4px 12px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.045);
  color: var(--muted);
  font-size: 12.5px;
  text-align: center;
}

.row {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  max-width: 74%;
  margin-top: 9px;
}
.row.me { align-self: flex-end; flex-direction: row-reverse; }
.row .avatar { margin-top: 2px; }

/* 撤回按钮：默认藏起来，悬停自己那条才出现，不打扰阅读 */
.msg-recall {
  align-self: center; flex: none; margin: 0 -2px;
  padding: 3px 8px; border-radius: 7px; cursor: pointer;
  border: 1px solid var(--line); background: #fff; color: var(--muted);
  font-size: 12px; font-family: inherit; opacity: 0;
  transition: opacity .12s;
}
.row:hover .msg-recall, .msg-recall:focus-visible { opacity: 1; }
.msg-recall:hover { border-color: var(--danger); color: var(--danger); }
.msg-recall[disabled] { opacity: 0 !important; pointer-events: none; }

/* 撤回后的占位气泡 */
.bubble.recalled {
  background: #f1f3f7; color: #98a2b3;
  font-size: 12.5px; font-style: italic;
  box-shadow: none; border: 1px solid var(--line);
}
.bubble.recalled .meta { color: #b6bdc9; }
@media (hover: none) {
  /* 触屏没有悬停，直接常显 */
  .msg-recall { opacity: 1; }
}

.bubble {
  position: relative;
  padding: 9px 13px;
  border-radius: 13px;
  background: #fff;
  box-shadow: var(--shadow-sm);
  word-break: break-word;
  white-space: pre-wrap;
  min-width: 42px;
}
.row:not(.me) .bubble { border-top-left-radius: 4px; }
.row.me .bubble {
  background: var(--brand);
  color: #fff;
  border-top-right-radius: 4px;
}
.bubble .txt { word-break: break-word; }
.bubble .meta {
  margin-top: 3px;
  font-size: 11px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 5px;
}
.row.me .bubble .meta { justify-content: flex-end; color: rgba(255, 255, 255, 0.72); }
.bubble .auto-flag {
  display: inline-block;
  margin-bottom: 4px;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(245, 69, 92, 0.12);
  color: var(--danger);
  font-size: 11px;
}

.bubble img.msg-img {
  display: block;
  max-width: 230px;
  max-height: 230px;
  border-radius: 9px;
  cursor: zoom-in;
  background: #f0f2f7;
}

.typing {
  align-self: flex-start;
  display: none;
  align-items: center;
  gap: 8px;
  margin: 8px 0 0 41px;
  padding: 7px 13px;
  border-radius: 13px 13px 13px 4px;
  background: #fff;
  box-shadow: var(--shadow-sm);
  color: var(--muted);
  font-size: 13px;
}
.typing.on { display: inline-flex; }
.typing i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #b6bdcb;
  animation: bounce 1.1s infinite;
}
.typing i:nth-child(2) { animation-delay: 0.15s; }
.typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.scroll-bottom {
  position: absolute;
  right: 18px;
  bottom: 14px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow);
  color: var(--muted);
  display: none;
  place-items: center;
  z-index: 5;
}
.scroll-bottom.on { display: grid; }

/* -------------------------------------------------- 输入区（两端共用） */

.composer {
  flex: none;
  border-top: 1px solid var(--line);
  background: var(--panel);
  padding: 9px 14px 12px;
  position: relative;
}
.composer-tools {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 6px;
}
.tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 28px;
  padding: 0 9px;
  border-radius: 7px;
  color: var(--muted);
  font-size: 13px;
  transition: 0.15s;
}
.tool-btn:hover { background: var(--brand-soft); color: var(--brand); }
.composer-tools .hint {
  margin-left: auto;
  font-size: 12px;
  color: #b3bbcd;
}
.composer textarea {
  width: 100%;
  min-height: 42px;
  max-height: 140px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fafbfe;
  resize: none;
  outline: none;
  line-height: 1.65;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.composer textarea:focus {
  border-color: var(--brand);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(59, 108, 246, 0.1);
}
.composer-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}
.composer-foot .tip { font-size: 12px; color: #b3bbcd; }
.send-btn {
  margin-left: auto;
  height: 34px;
  padding: 0 22px;
  border-radius: 9px;
  background: var(--brand);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(59, 108, 246, 0.28);
  transition: 0.15s;
}
.send-btn:hover { background: var(--brand-dark); }
.send-btn:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }

/* 待发送图片预览条 */
.pending {
  display: none;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px;
  margin-bottom: 8px;
  border: 1px dashed #cfd8ee;
  border-radius: 10px;
  background: #fafbff;
  max-height: 130px;
  overflow: auto;
}
.pending.on { display: flex; }
.pending .item {
  position: relative;
  width: 74px;
  height: 74px;
  border-radius: 9px;
  overflow: hidden;
  background: #eef1f8;
}
.pending .item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pending .item .x {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 12px;
  line-height: 19px;
  text-align: center;
}
.pending .item .x:hover { background: var(--danger); }
.pending .item .loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.75);
  font-size: 11px;
  color: var(--brand);
}

/* 表情面板 */
.emoji-panel {
  position: absolute;
  left: 12px;
  bottom: 100%;
  margin-bottom: 6px;
  width: 306px;
  max-height: 232px;
  overflow: auto;
  padding: 8px;
  display: none;
  grid-template-columns: repeat(10, 1fr);
  gap: 2px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  z-index: 30;
}
.emoji-panel.on { display: grid; }
.emoji-panel button {
  height: 28px;
  border-radius: 6px;
  font-size: 17px;
  line-height: 1;
}
.emoji-panel button:hover { background: var(--brand-soft); }

/* -------------------------------------------------- 登录遮罩 / 网络状态 */

.lock {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: grid;
  place-items: center;
  padding: 20px;
  background: linear-gradient(150deg, #1b2440, #26325a);
}
.lock-box {
  width: min(360px, 100%);
  background: #fff;
  border-radius: 18px;
  padding: 30px 26px 24px;
  text-align: center;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
}
.lock-logo {
  width: 54px; height: 54px; border-radius: 17px; margin: 0 auto 16px;
  background: linear-gradient(135deg, #4b7cff, #7c5cf6);
  color: #fff; display: grid; place-items: center; font-size: 26px;
  box-shadow: 0 8px 22px rgba(76, 92, 246, 0.45);
}
.lock-box h2 { margin: 0 0 7px; font-size: 18px; }
.lock-box p { margin: 0 0 20px; font-size: 13px; color: var(--muted); line-height: 1.7; }
.lock-box input {
  width: 100%; height: 42px; padding: 0 14px; margin-bottom: 12px;
  border: 1px solid var(--line); border-radius: 10px; background: #fafbfe;
  text-align: center; outline: none; transition: .15s; font-size: 15px;
  letter-spacing: 2px;
}
.lock-box input:focus { border-color: var(--brand); background: #fff; box-shadow: 0 0 0 3px rgba(59,108,246,.12); }
.lock-box button {
  width: 100%; height: 42px; border-radius: 10px; font-weight: 600; font-size: 15px;
  background: var(--brand); color: #fff; box-shadow: 0 6px 18px rgba(59,108,246,.32);
}
.lock-box button:hover { background: var(--brand-dark); }
.lock-box button:disabled { opacity: .6; cursor: not-allowed; }
.lock-tip { margin: 14px 0 0; font-size: 12.5px; color: var(--danger); min-height: 18px; }

.netbar {
  flex: none;
  display: flex; align-items: center; gap: 9px;
  padding: 8px 16px;
  background: #fff7e6; color: #b45309; font-size: 13px;
  border-bottom: 1px solid #fde68a;
}.netbar .spin {
  width: 13px; height: 13px; flex: none;
  border: 2px solid #f0c98a; border-top-color: #b45309;
  border-radius: 50%; animation: spin .8s linear infinite;
}
.netbar.off { background: #fff1f3; color: #b42318; border-bottom-color: #fecdd3; }
.netbar.off .spin { display: none; }

/* 微信内置浏览器的提示条：聊天照常用，只是提前说清楚语音通话要换浏览器 */
/* 微信提示条：必须是「整行一条」的横条。
   之前它被插进了 .msgs-wrap（display:flex），于是变成和消息列表并排的
   横向 flex 项，把聊天区挤变形。这里 width:100% + align-self:stretch 兜底，
   就算插入位置不对，也不会再变成并排的两块。 */
.wechat-tip {
  flex: none;
  align-self: stretch;
  width: 100%;
  box-sizing: border-box;
  padding: 9px 16px;
  background: #eef4ff; color: #1e40af;
  font-size: 13px; line-height: 1.55;
  border-bottom: 1px solid #c7d8fb;
}
.wechat-tip b { color: #1d4ed8; }
@keyframes spin { to { transform: rotate(360deg); } }

/* 二维码弹窗：左右两栏
   左栏卡片原尺寸完整显示，右栏编辑项自己滚。

   为什么必须两栏：上下排的话，卡片和编辑区抢同一份垂直高度，
   而卡片是「不许收缩」的那一方 —— 窗口一矮就必然被裁掉底栏
   （或者反过来把编辑区挤到压住底栏按钮）。
   两栏各占一边，谁也不用跟谁抢。

   注意 display 只能写在 [open] 上。
   UA 样式表里是 dialog:not([open]) { display:none }，用来让未打开的弹窗隐藏。
   而作者样式优先级恒高于 UA 样式，所以只要写成
       .dlg-qr { display: flex }
   就等于把那条 display:none 顶掉了 —— 弹窗关着的时候照样显示，
   以普通流的形式压在工作台上：没有遮罩、内容互相重叠、
   而 openQr() 里画二维码的代码压根没执行（因为从没 open 过）。 */
.dlg-qr { width: min(920px, 96vw); max-height: 92vh; }
.dlg-qr[open] { display: flex; flex-direction: column; }
.dlg-qr .dlg-body {
  max-height: none;
  padding: 0;                       /* 两栏各自控制内边距 */
  display: flex;
  flex-direction: row;              /* 横向：左卡片 右编辑 */
  overflow: hidden;
  min-height: 0;
}
.qr-stage {
  flex: none;
  width: 420px;
  padding: 16px 20px;
  border-right: 1px solid var(--line);
  background: #fff;
  overflow-y: auto;                 /* 极窄窗口下兜底：宁可这里滚，不裁卡片 */
  min-height: 0;
}
.qr-edit {
  flex: 1 1 auto;
  overflow-y: auto;
  min-height: 0;
  margin: 0;
  padding: 16px 18px;
  max-width: none;
}

/* 窄屏放不下两栏，退回上下排。
   这时两栏要抢高度，所以卡片允许收缩（由 JS 量准后缩放，
   最坏是被压扁，也不会把编辑区顶穿、不会盖住底栏）。 */
@media (max-width: 760px) {
  .dlg-qr .dlg-body { flex-direction: column; }
  .qr-stage {
    width: auto;
    border-right: none;
    border-bottom: 1px solid var(--line);
    flex: 0 1 auto;
  }
}

/* 二维码 */
.qr-dialog { text-align: center; }
.qr-lead { margin: 0 0 10px; font-size: 13px; color: var(--muted); }
.qr-holder {
  display: inline-block; padding: 10px; background: #fff;
  border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-sm);
  line-height: 0;
}
/* 画布的显示尺寸由 drawQR 按卡片比例设置（style.width/height），
   这里不写死宽高，否则会覆盖掉。缩小时保持边缘锐利。 */
.qr-holder canvas { display: block; image-rendering: -webkit-optimize-contrast; }
.qr-hint { font-size: 12px; color: var(--muted); line-height: 1.6; }
.qr-hint.err { color: var(--danger); }

/* ---- 二维码编辑区 ----
   之前这一整块（.qe-*）一行样式都没有，全靠浏览器默认样式顶着：
   模板选择器是一排挤在一起的默认按钮，分不清选中哪个，
   输入框也没有标签对齐。现在补齐。 */
.qr-edit { text-align: left; }
.qe-row { margin-bottom: 14px; }
.qe-row > label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--muted);
}
.qe-row > input[type="text"] {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  font-size: 14px;
  background: #fff;
  color: var(--text);
}
.qe-row > input[type="text"]:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(47, 107, 255, .12);
}
.qe-row > input[type="color"] {
  width: 46px;
  height: 32px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  vertical-align: middle;
  cursor: pointer;
}

/* 模板选择器：卡片式小按钮，选中态一眼能看出来 */
.qe-templates {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
}
.qe-tpl-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 9px 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  font-size: 12.5px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  min-width: 0;
}
.qe-tpl-btn:hover { border-color: #b9cdf5; background: #f7faff; }
.qe-tpl-btn.on {
  border-color: var(--brand);
  background: #eef4ff;
  color: var(--brand);
  font-weight: 600;
  box-shadow: 0 0 0 2px rgba(47, 107, 255, .12);
}
/* 色板缩略图：上半截是底色，中间一条模拟二维码，下半截是底栏色 */
.qe-swatch {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  width: 100%;
  height: 54px;
  padding: 5px;
  border: 1px solid rgba(0, 0, 0, .06);
  border-radius: 8px;
}
.qe-swatch i {
  display: block;
  width: 30px;
  height: 30px;
  background:
    repeating-conic-gradient(#0b1220 0 25%, #fff 0 50%) 50% / 8px 8px;
  border-radius: 2px;
}
.qe-swatch b {
  display: block;
  width: 100%;
  height: 5px;
  border-radius: 2px;
}
.qe-avatar { display: flex; align-items: center; gap: 10px; }
.qe-thumb {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 2px solid var(--line);
  background: #f4f6fb center/cover no-repeat;
  flex: none;
}
.link-box {
  padding: 10px 12px;
  background: #f6f8fc;
  border: 1px solid var(--line);
  border-radius: 9px;
  font-size: 12.5px;
  word-break: break-all;
  color: var(--text);
  text-align: left;
}

/* 拖拽遮罩 */
.dropzone {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  background: rgba(59, 108, 246, 0.08);
  border: 2px dashed var(--brand);
  border-radius: 12px;
  margin: 10px;
  color: var(--brand);
  font-size: 15px;
  font-weight: 600;
  z-index: 40;
  pointer-events: none;
}
.dropzone.on { display: grid; }

/* 图片查看器 */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: none;
  place-items: center;
  background: rgba(10, 14, 26, 0.86);
  cursor: zoom-out;
  padding: 40px;
}
.lightbox.on { display: grid; }
.lightbox img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

/* ---------- 语音/视频通话 ---------- */
.call-layer {
  position: fixed;
  inset: 0;
  z-index: 800;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(12, 18, 34, 0.55);
  backdrop-filter: blur(3px);
}

.call-card {
  width: min(400px, 100%);
  background: var(--panel);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 24px 70px rgba(10, 18, 40, 0.4);
  display: flex;
  flex-direction: column;
}
.call-top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 15px 16px 13px;
}
.call-peer { font-size: 16px; font-weight: 700; color: var(--text); }
.call-state { font-size: 13px; color: var(--muted); margin-top: 3px; }
.call-timer {
  margin-left: auto;
  flex: none;
  font-family: ui-monospace, Consolas, Menlo, monospace;
  font-size: 15px;
  font-weight: 600;
  color: var(--ok);
  background: #e7f8f0;
  padding: 4px 11px;
  border-radius: 99px;
}

.call-stage {
  position: relative;
  margin: 0 16px;
  border-radius: 14px;
  background: linear-gradient(160deg, #223052, #101728);
  min-height: 196px;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.call-avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 34px;
  font-weight: 700;
  animation: callPulse 2.2s ease-in-out infinite;
}
@keyframes callPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.16); }
  50% { box-shadow: 0 0 0 24px rgba(255, 255, 255, 0); }
}
/* 对方的声音：只用耳朵听，这个元素不参与布局 */
.call-audio { display: none; }

/* 最小化：隐藏整个通话卡，只留一条可拖小药丸条，不再盖住聊天窗 */
.call-layer.min .call-card { display: none; }
.call-layer.min { pointer-events: none; background: transparent; backdrop-filter: none; }
.call-layer.min .call-minbar { pointer-events: auto; display: inline-flex; }
.call-minbar {
  position: fixed; left: 12px; bottom: 12px; z-index: 812;
  display: none; align-items: center; gap: 6px;
  padding: 9px 12px; border-radius: 99px;
  background: rgba(20, 28, 45, 0.92); color: #fff;
  font-size: 13px; box-shadow: 0 8px 22px rgba(0, 0, 0, 0.35);
  touch-action: none; cursor: move; user-select: none;
}
.call-minbar-btn {
  border: none; border-radius: 99px; background: rgba(255, 255, 255, 0.18);
  color: #fff; font-size: 12px; padding: 3px 9px; cursor: pointer;
}
.call-btn.min { min-width: 56px; }

.call-status {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 12px;
  text-align: center;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.8);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
}

.call-acts {
  display: flex;
  gap: 10px;
  padding: 16px;
  justify-content: center;
  flex-wrap: wrap;
}
.call-btn {
  min-width: 112px;
  height: 42px;
  padding: 0 18px;
  border: 0;
  border-radius: 99px;
  cursor: pointer;
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 600;
  background: var(--brand-soft);
  color: var(--brand-dark);
  transition: filter .15s, opacity .15s;
}
.call-btn:hover { filter: brightness(0.97); }
.call-btn:active { filter: brightness(0.94); }
.call-btn.danger { background: var(--danger); color: #fff; }
.call-btn.ok { background: var(--ok); color: #fff; }
.call-btn.off { background: #eceff5; color: var(--muted); }

@media (max-width: 520px) {
  .call-layer { padding: 0; }
  .call-card { border-radius: 0; height: 100%; justify-content: center; }
  .call-btn { min-width: 96px; }
}
