* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC",
    "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
  background: #f2f3f5;
  color: #1a1a1a;
}

.layout {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  padding: 16px 24px 40px;
}

/* ===== 控制面板 ===== */
.panel {
  width: 720px;
  flex: none;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  align-items: start;
}
/* 两列：左列 B（设置类）/ 右列 A（操作类），各自竖向排列 */
.col { min-width: 0; }

.card {
  background: #fff;
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  margin-bottom: 14px;
}
.card h3 {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 600;
}
.card h3 .count {
  color: #999;
  font-weight: 400;
  font-size: 13px;
}

.tpl-grid {
  display: flex;
  gap: 10px;
}
.tpl-item {
  flex: 1;
  border: 1.5px solid #e3e5e8;
  border-radius: 10px;
  padding: 12px 0;
  text-align: center;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.15s;
  user-select: none;
}
.tpl-item input { display: none; }
.tpl-item.active {
  border-color: #07c160;
  background: #eafaf0;
  color: #07c160;
  font-weight: 600;
}

/* 模式切换 */
.mode-tabs { display: flex; gap: 10px; }
.mode-tab {
  flex: 1;
  border: 1.5px solid #e3e5e8;
  border-radius: 10px;
  padding: 10px 0;
  text-align: center;
  cursor: pointer;
  font-size: 14px;
  user-select: none;
  transition: all 0.15s;
}
.mode-tab input { display: none; }
.mode-tab.active {
  border-color: #07c160;
  background: #eafaf0;
  color: #07c160;
  font-weight: 600;
}

/* 群成员 */
.member-list { list-style: none; margin: 0 0 10px; padding: 0; }
.member-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 4px;
  border-bottom: 1px solid #f0f1f3;
}
.avatar-prev.sm { width: 36px; height: 36px; border-radius: 6px; flex: none; }
.mem-name {
  flex: 1;
  min-width: 0;
  padding: 6px 8px;
  border: 1px solid #dcdfe3;
  border-radius: 8px;
  font-size: 13px;
}
.btn-file.sm { padding: 6px 10px; font-size: 12px; }
.add-member { display: flex; gap: 8px; margin-top: 6px; }
.add-member input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid #dcdfe3;
  border-radius: 8px;
  font-size: 13px;
}

/* 表情面板 */
.emoji-picker {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
  margin-top: 10px;
  max-height: 190px;
  overflow: auto;
  padding: 8px;
  background: #f7f8fa;
  border-radius: 8px;
}
.emoji-item {
  font-size: 22px;
  line-height: 1;
  padding: 4px 0;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 6px;
}
.emoji-item:hover { background: #e9eaec; }

.field {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}
.field > span {
  width: 48px;
  flex: none;
  font-size: 13px;
  color: #555;
}
.field input,
.row select,
.draft-time {
  flex: 1;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #dcdfe3;
  border-radius: 8px;
  font-size: 14px;
  outline: none;
}
.field input:focus,
.row select:focus,
.draft-time:focus,
.draft-text:focus {
  border-color: #07c160;
}

.bat-slider {
  flex: 1;
  accent-color: #07c160;
}
.bat-val {
  width: 46px;
  flex: none;
  text-align: right;
  font-size: 13px;
  color: #555;
  font-variant-numeric: tabular-nums;
}
.bat-val.low {
  color: #ff3b30;
  font-weight: 700;
}
/* 状态栏附加图标开关行 */
.sw-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  font-size: 13px;
  color: #555;
}
.sw-row input {
  width: 16px;
  height: 16px;
  accent-color: #07c160;
}

.avatar-row {
  display: flex;
  align-items: center;
  gap: 14px;
}
.avatar-prev {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  object-fit: cover;
  background: #eee;
  flex: none;
}
.avatar-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn-file {
  display: inline-block;
  background: #07c160;
  color: #fff;
  font-size: 13px;
  padding: 7px 14px;
  border-radius: 8px;
  cursor: pointer;
}
.btn-file input { display: none; }
.btn-file.block { display: block; text-align: center; margin-top: 10px; }

.btn-ghost {
  background: #f2f3f5;
  color: #555;
  border: 1px solid #e3e5e8;
  font-size: 13px;
  padding: 7px 12px;
  border-radius: 8px;
  cursor: pointer;
}
.btn-ghost.block { display: block; width: 100%; margin-top: 12px; }
.btn-ghost:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: #07c160;
  color: #fff;
  border: none;
  font-size: 14px;
  padding: 9px 18px;
  border-radius: 8px;
  cursor: pointer;
}
.btn-primary.block { display: block; width: 100%; margin-top: 12px; }

.row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.row-label {
  width: 48px;
  flex: none;
  font-size: 13px;
  color: #555;
}
.row select { flex: 1; }

.draft-text {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #dcdfe3;
  border-radius: 8px;
  font-size: 14px;
  resize: vertical;
  font-family: inherit;
}
.draft-img-prev {
  display: block;
  max-width: 100%;
  max-height: 160px;
  margin: 10px auto 0;
  border-radius: 8px;
}

.msg-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.msg-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 6px;
  border-bottom: 1px solid #f0f1f3;
  font-size: 13px;
}
.msg-list li:last-child { border-bottom: none; }
.tag {
  flex: none;
  font-size: 11px;
  color: #fff;
  border-radius: 4px;
  padding: 2px 6px;
}
.tag.other { background: #5b8ff9; }
.tag.me { background: #07c160; }
.prev {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #333;
}
.ops { display: flex; gap: 4px; flex: none; }
.ops button {
  border: 1px solid #e3e5e8;
  background: #fff;
  border-radius: 6px;
  width: 26px;
  height: 26px;
  cursor: pointer;
  font-size: 12px;
  color: #555;
}
.ops button:hover { background: #f2f3f5; }
.hint { color: #999; font-size: 13px; margin: 4px 0; }

/* ===== 预览舞台 ===== */
.stage {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
}
.toolbar {
  display: flex;
  gap: 12px;
  justify-content: center;
  align-items: flex-start;
}

/* 生成图片预览层：手机端长按图片触发系统默认“保存相册” */
.img-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.62);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 100;
}
.img-card {
  background: #fff;
  border-radius: 14px;
  max-width: 340px;
  width: 100%;
  padding: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}
.img-prev {
  width: 100%;
  border-radius: 8px;
  display: block;
  background: #ededed;
  -webkit-touch-callout: default; /* 关键：允许 iOS 长按弹出“保存图片”菜单 */
  -webkit-user-select: auto;
  user-select: auto;
}
.img-tip {
  font-size: 13px;
  color: #666;
  line-height: 1.55;
  margin: 12px 0 0;
  text-align: center;
}
.img-close {
  display: block;
  width: 100%;
  margin-top: 12px;
  border: none;
  background: #f2f3f5;
  color: #1a1a1a;
  font-size: 16px;
  padding: 12px 0;
  border-radius: 10px;
  cursor: pointer;
}
.img-close:active { background: #e6e7e9; }
/* 页脚免责声明（位于导出区域之外，不会进入截图） */
.site-footer {
  max-width: 1000px;
  margin: 24px auto 30px;
  padding: 0 20px;
  text-align: center;
}
.site-footer p {
  margin: 0;
  font-size: 12px;
  line-height: 1.7;
  color: #9aa0a6;
}

.phone-wrap {
  width: 100%;
  max-width: 460px;
  background: #ffffff;
  border: 1px solid #eceef1;
  border-radius: 20px;
  box-shadow: 0 10px 40px rgba(17, 24, 39, 0.08);
  padding: 10px;
  margin: 0;
}

/* 手机外壳（实际截图无边框，这里仅作透明容器，不影响导出） */
.phone-frame {
  width: 390px;
}
.phone {
  background: transparent;
  border-radius: 0;
  padding: 0;
  box-shadow: none;
  transform-origin: top left;
}
.screen {
  width: 390px;
  background: #ededed;
  border-radius: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 780px;
}

/* 顶部（状态栏 + 微信导航） */
.wx-top {
  background: #07c160;
  color: #fff;
  position: relative;
}
.statusbar {
  height: 48px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
}
.sb-time {
  font-weight: 600;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}
.sb-icons {
  display: flex;
  align-items: center;
  color: #fff;
}
.sb-ico {
  height: 12px;
  width: auto;
  display: block;
  margin-left: 6px;
  flex: none;
}
/* 电池：纯 CSS 绘制，避免 html2canvas 对 inline SVG 渲染截断 */
.battery {
  position: relative;
  width: 23px;
  height: 13px;
  border: 1px solid #111;
  border-radius: 3px;
  box-sizing: border-box;
  margin-left: 6px;
  flex: none;
}
.battery .b-fill {
  position: absolute;
  left: 2px;
  top: 2px;
  height: 7px;
  background: #111;
  border-radius: 1px;
}
.battery::after {
  content: "";
  position: absolute;
  right: -3px;
  top: 4px;
  width: 2px;
  height: 5px;
  background: #111;
  border-radius: 1px;
}
.battery.low { border-color: #ff3b30; }
.battery.low .b-fill { background: #ff3b30; }
.battery.low::after { background: #ff3b30; }

.wx-nav {
  height: 46px;
  display: flex;
  align-items: center;
  padding: 0 12px;
}

/* 4G 网络标识 */
.sb-net {
  font-size: 10px;
  font-weight: 500;
  margin-left: 1px;
  letter-spacing: 0.2px;
}

/* 未读消息徽标 */
.wx-nav-left { position: relative; }
.unread-badge {
  position: absolute;
  top: 50%;
  left: 16px;
  transform: translateY(-50%);
  min-width: 17px;
  height: 17px;
  line-height: 17px;
  padding: 0 4px;
  border-radius: 9px;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  box-sizing: border-box;
}
/* 未读消息徽标：灰色胶囊（Android 风格，贴合参考图） */
.tpl-huawei .unread-badge { background: #dcdcdc; color: #555; border-radius: 10px; }

/* 华为机型：顶部浅色，与参考图一致 */
.tpl-huawei .wx-top { background: #f7f7f7; color: #111; }
.tpl-huawei .sb-icons { color: #111; }
.tpl-huawei .sb-time { color: #111; }
.tpl-huawei .wx-nav-left,
.tpl-huawei .wx-nav-right { color: #111; }
.tpl-huawei .wx-nav-title { color: #111; }
.tpl-huawei .wx-nav { border-bottom: 1px solid #e5e5e5; }

/* 底部输入栏（灰底 + 白色圆角输入框 + 线性图标） */
.wx-inputbar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #f7f7f7;
  padding: 9px 12px;
}
.ib-btn {
  width: 34px;
  height: 34px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: #1f1f1f;
  cursor: pointer;
  padding: 0;
}
/* 语音按钮：黑圆环 + 左向三角 + 声波（图形由 SVG 自带，透明底） */
.ib-voice { width: 34px; height: 34px; }
.ib-field {
  flex: 1;
  display: flex;
  align-items: center;
  background: #fff;
  border: 1px solid #e6e6e6;
  border-radius: 18px;
  padding: 8px 12px;
  min-height: 36px;
}
.ib-ph {
  flex: 1;
  font-size: 15px;
  color: #9a9a9a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ib-mic {
  flex: none;
  margin-left: 8px;
  color: #9a9a9a;
  display: flex;
}
.ib-plus { color: #2b2b2b; }

/* 系统导航条样式已移除 */
.wx-nav-left,
.wx-nav-right {
  width: 44px;
  flex: none;
  display: flex;
  align-items: center;
  color: #fff;
}
.wx-nav-right {
  justify-content: flex-end;
  font-size: 22px;
  letter-spacing: 1px;
}
.wx-nav-title {
  flex: 1;
  text-align: center;
  font-size: 17px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.group-count {
  font-size: 13px;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.9);
  margin-left: 4px;
}

.chat {
  background: #ededed;
  padding: 8px 0 18px;
  flex: 1;
}
.empty {
  text-align: center;
  color: #b0b0b0;
  font-size: 13px;
  margin-top: 40px;
}

.msg {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin: 14px 12px;
}
.msg.me { flex-direction: row-reverse; }
.avatar {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  flex: none;
  object-fit: cover;
  background: #ddd;
}
.msg-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
  max-width: 72%;
}
.msg.other .msg-body { align-items: flex-start; }
.msg.me .msg-body { align-items: flex-end; }
.sender-name {
  font-size: 12px;
  color: #888;
  margin: 0 2px 4px;
}
.bubble {
  max-width: 100%;
  margin: 0;
  padding: 9px 12px;
  border-radius: 6px;
  font-size: 16px;
  line-height: 1.45;
  position: relative;
  word-break: break-word;
  white-space: pre-wrap;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}
.msg.other .bubble { background: #fff; }
.msg.me .bubble { background: #95ec69; }
.msg.other .bubble::before {
  content: "";
  position: absolute;
  left: -6px;
  top: 10px;
  width: 0;
  height: 0;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-right: 10px solid #fff;
}
.msg.me .bubble::before {
  content: "";
  position: absolute;
  right: -6px;
  top: 10px;
  width: 0;
  height: 0;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-left: 10px solid #95ec69;
}
.bubble.img {
  padding: 3px;
  background: transparent !important;
  box-shadow: none !important;
}
.bubble.img::before { display: none; }
.bubble.img img {
  display: block;
  max-width: 180px;
  border-radius: 6px;
}
.emoji-bubble {
  background: transparent !important;
  border-radius: 0;
  padding: 0;
  font-size: 60px;
  line-height: 1;
  max-width: 80%;
  box-shadow: none !important;
}
.emoji-bubble::before { display: none; }

.time-divider {
  text-align: center;
  margin: 16px 0;
}
.time-divider span {
  color: #9a9a9a;
  font-size: 12px;
  padding: 0 8px;
}

/* 导出图脚注角标：随截图生成，提示“对话为虚构”（位于 .screen 内，会进入导出图） */
.capture-badge {
  text-align: right;
  font-size: 9px;
  line-height: 1;
  color: #c4c4c4;
  letter-spacing: 0.3px;
  padding: 4px 12px 8px;
  user-select: none;
  -webkit-user-select: none;
}

/* 弹窗 */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
}
.modal-box {
  background: #fff;
  padding: 18px;
  border-radius: 12px;
  max-width: 92vw;
  max-height: 92vh;
  overflow: auto;
  text-align: center;
}
.modal-box h3 { margin: 0 0 12px; font-size: 16px; }
.modal-box img {
  max-width: 100%;
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}
.modal-ops {
  margin-top: 16px;
  display: flex;
  gap: 12px;
  justify-content: center;
}

/* 响应式：窄屏纵向排列 */
@media (max-width: 900px) {
  .layout { flex-direction: column; align-items: stretch; }
  .panel { width: 100%; grid-template-columns: 1fr; }
  .stage { width: 100%; margin-top: 14px; }
  .toolbar { width: 100%; margin-top: 14px; }
  .phone-wrap { max-width: 100%; }
}
