/* ==========================================================================
   消息生成器 — 样式表
   分两大部分：① 左侧编辑面板 UI  ② 右侧手机预览（WeChat 仿真，供 html2canvas 导出）
   注意：手机预览区域（.device 内部）刻意避开 flex 的 gap / row-reverse，
        改用 margin 与 DOM 顺序控制间距与左右排布，以保证 html2canvas 还原准确。
   ========================================================================== */

/* ---------- 0. reset & tokens ---------- */
* { box-sizing: border-box; }

:root {
  --ui-bg:        #eef1f5;
  --ui-panel:     #ffffff;
  --ui-panel-2:   #f6f7f9;
  --ui-border:    #e3e6eb;
  --ui-border-2:  #d6dae1;
  --ui-text:      #1f2430;
  --ui-text-2:    #6b7280;
  --ui-text-3:    #9aa1ad;
  --ui-accent:    #07c160;
  --ui-accent-d:  #06ad56;
  --ui-danger:    #ef4444;
  --ui-radius:    10px;
  --ui-font:      -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
                  "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

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

body {
  font-family: var(--ui-font);
  font-size: 14px;
  color: var(--ui-text);
  background: var(--ui-bg);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }

/* ---------- 1. 布局 ---------- */
.app {
  display: flex;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* ---------- 1b. 左侧功能导航 ---------- */
.rail {
  display: flex;
  flex-direction: column;
  flex: 0 0 78px;
  width: 78px;
  padding: 12px 8px;
  gap: 2px;
  background: #15181d;
  overflow-y: auto;
  scrollbar-width: none;
}
.rail::-webkit-scrollbar { width: 0; }

.rail__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  flex: none;
  padding: 8px 2px 10px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: #838b99;
  font-size: 11px;
  line-height: 1;
  letter-spacing: .2px;
  transition: color .15s;
}
.rail__item:hover { color: #cfd5df; }

/* 图标坐在一块圆角方块上。选中时方块填品牌绿 ——
   整个导航里唯一的重色块，一眼能看出当前在哪 */
.rail__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 32px;
  border-radius: 9px;
  background: rgba(255, 255, 255, .06);
  transition: background .15s;
}
.rail__icon svg { display: block; }
.rail__item:hover .rail__icon { background: rgba(255, 255, 255, .13); }
.rail__item.is-active { color: #fff; }
.rail__item.is-active .rail__icon { background: var(--ui-accent); }

.rail__label {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- 1c. 功能区容器 ---------- */
.workspace {
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
}

/* 同一时刻只显示一个功能；未激活的连布局都不参与 */
.feature { display: none; }
.feature.is-active {
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
}

.panel {
  display: flex;
  flex-direction: column;
  flex: 0 0 380px;
  width: 380px;
  min-width: 0;
  background: var(--ui-panel);
  border-right: 1px solid var(--ui-border);
}

.panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: none;
  padding: 14px 16px;
  border-bottom: 1px solid var(--ui-border);
}

.panel__title { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: .2px; }
.panel__sub   { margin: 3px 0 0; font-size: 12px; color: var(--ui-text-3); }

.panel__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-bottom: 8px;
}

.panel__foot {
  flex: none;
  padding: 12px 16px 14px;
  border-top: 1px solid var(--ui-border);
  background: var(--ui-panel-2);
}

.panel__foot .row { margin-top: 8px; }

/* ---------- 2. 面板内通用控件 ---------- */
.sec { border-bottom: 1px solid var(--ui-border); }
.sec:last-child { border-bottom: 0; }

.sec > summary,
.sec__title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ui-text-2);
  letter-spacing: .6px;
  list-style: none;
}

.sec > summary { cursor: pointer; user-select: none; }
.sec > summary::-webkit-details-marker { display: none; }
.sec > summary::after {
  content: "";
  width: 7px;
  height: 7px;
  margin-left: 8px;
  border-right: 1.5px solid var(--ui-text-3);
  border-bottom: 1.5px solid var(--ui-text-3);
  transform: rotate(45deg) translate(-2px, -2px);
  transition: transform .18s ease;
}
.sec[open] > summary::after { transform: rotate(-135deg) translate(-2px, -2px); }

.sec__title--row { padding-bottom: 8px; }
.sec__actions { display: flex; gap: 6px; }
.sec__body { padding: 0 16px 16px; }
.sec--grow .sec__body { padding-bottom: 20px; }

.field { margin-bottom: 12px; }
.field:last-child { margin-bottom: 0; }

.field--row { display: flex; margin-left: -6px; margin-right: -6px; }
.field--row > .field__col { flex: 1 1 0; min-width: 0; padding: 0 6px; }

.field__label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--ui-text-2);
}

.field__label .val {
  float: right;
  font-weight: 600;
  color: var(--ui-accent-d);
  font-variant-numeric: tabular-nums;
}

.hint { color: var(--ui-text-3); font-weight: 400; }

.input {
  display: block;
  width: 100%;
  height: 34px;
  padding: 0 10px;
  background: var(--ui-panel-2);
  border: 1px solid var(--ui-border);
  border-radius: 8px;
  outline: none;
  transition: border-color .15s, background .15s;
}
.input:focus { border-color: var(--ui-accent); background: #fff; }
textarea.input { height: auto; padding: 8px 10px; resize: vertical; line-height: 1.5; }

/* 消息上限数字输入框：窄一点，避免撑满整行 */
.input--num { width: 88px; }
.msg-sep { opacity: .5; margin: 0 1px; }
.msg-limit { margin-bottom: 10px; }

.select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}

.range {
  display: block;
  width: 100%;
  height: 20px;
  margin: 0;
  appearance: none;
  background: transparent;
  outline: none;
}
.range::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: var(--ui-border-2);
}
.range::-webkit-slider-thumb {
  appearance: none;
  width: 15px;
  height: 15px;
  margin-top: -5.5px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid var(--ui-border-2);
  box-shadow: 0 1px 3px rgba(16, 24, 40, .22);
  cursor: pointer;
}
.range:focus::-webkit-slider-thumb { border-color: var(--ui-accent); }

.color {
  display: block;
  width: 100%;
  height: 34px;
  padding: 3px;
  background: var(--ui-panel-2);
  border: 1px solid var(--ui-border);
  border-radius: 8px;
  cursor: pointer;
}
.color::-webkit-color-swatch-wrapper { padding: 0; }
.color::-webkit-color-swatch { border: 0; border-radius: 5px; }

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--ui-text-2);
  cursor: pointer;
}
.check:last-child { margin-bottom: 0; }
.check input { width: 15px; height: 15px; accent-color: var(--ui-accent); cursor: pointer; }

.divider { height: 1px; margin: 14px 0; background: var(--ui-border); }

.row { display: flex; gap: 8px; }

/* 分段控件 */
.segmented {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--ui-panel-2);
  border: 1px solid var(--ui-border);
  border-radius: 9px;
}
.segmented > button {
  flex: 1 1 0;
  height: 28px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ui-text-2);
  font-size: 13px;
  transition: background .15s, color .15s, box-shadow .15s;
}
.segmented > button:hover { color: var(--ui-text); }
.segmented > button.is-active {
  background: #fff;
  color: var(--ui-text);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .1);
}
.segmented--sm > button { height: 26px; font-size: 12.5px; }

/* 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--ui-border);
  border-radius: 8px;
  background: #fff;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: #f2f4f7; }
.btn:active { transform: translateY(.5px); }
.btn--sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn--block { width: 100%; }
.btn--primary {
  background: var(--ui-accent);
  border-color: var(--ui-accent);
  color: #fff;
  font-weight: 600;
}
.btn--primary:hover { background: var(--ui-accent-d); border-color: var(--ui-accent-d); }
.btn--ghost { background: var(--ui-panel-2); }
.btn--ghost:hover { background: #eef0f4; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--ui-border);
  border-radius: 8px;
  background: var(--ui-panel-2);
  color: var(--ui-text-2);
  font-size: 15px;
  line-height: 1;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: #eef0f4; color: var(--ui-text); }
.icon-btn--sm { width: 26px; height: 26px; font-size: 14px; }

/* 头像编辑 */
.avatar-field { display: flex; align-items: center; gap: 10px; }
.avatar-field__preview {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 6px;
  object-fit: cover;
  background: #dfe3e8;
  border: 1px solid var(--ui-border);
}
.avatar-field__actions { display: flex; flex-wrap: wrap; gap: 6px; }

/* 群成员 */
.members { list-style: none; margin: 0 0 8px; padding: 0; }
.members__item {
  padding: 8px;
  margin-bottom: 6px;
  background: var(--ui-panel-2);
  border: 1px solid var(--ui-border);
  border-radius: 9px;
}
.members__row {
  display: flex;
  align-items: center;
  gap: 8px;
}
/* 和单聊的头像栏一致：上传 / 图片地址 / 默认 */
.members__actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}
.members__actions .btn { flex: 1 1 0; }
.members__avatar {
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 5px;
  object-fit: cover;
  background: #dfe3e8;
  cursor: pointer;
}
.members__name {
  flex: 1 1 auto;
  min-width: 0;
  height: 30px;
  padding: 0 8px;
  background: #fff;
  border: 1px solid var(--ui-border);
  border-radius: 7px;
  outline: none;
}
.members__name:focus { border-color: var(--ui-accent); }
.members__del {
  flex: none;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ui-text-3);
  font-size: 15px;
  line-height: 1;
}
.members__del:hover { background: #fee2e2; color: var(--ui-danger); }

/* 添加成员按钮：达上限时禁用态 */
.btn:disabled,
.btn[disabled] {
  opacity: .5;
  cursor: not-allowed;
  background: var(--ui-panel-2);
}
.btn:disabled:hover { background: var(--ui-panel-2); }

/* @ 成员联想弹层 */
.mention-pop {
  position: fixed;
  z-index: 1000;
  max-height: 220px;
  overflow-y: auto;
  padding: 4px;
  background: #fff;
  border: 1px solid var(--ui-border-2);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(16, 24, 40, .18);
  scrollbar-width: thin;
}
.mention-pop[hidden] { display: none; }
.mention-pop__item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 13px;
  color: var(--ui-text);
  white-space: nowrap;
}
.mention-pop__item:hover { background: var(--ui-panel-2); }
.mention-pop__item.is-active { background: #f0fdf4; }
.mention-pop__avatar {
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 5px;
  object-fit: cover;
  background: #dfe3e8;
}
.mention-pop__name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 快捷添加 */
.quickadd { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.quickadd > button {
  height: 28px;
  padding: 0 11px;
  border: 1px dashed var(--ui-border-2);
  border-radius: 14px;
  background: #fff;
  color: var(--ui-text-2);
  font-size: 12.5px;
  transition: all .15s;
}
.quickadd > button:hover {
  border-style: solid;
  border-color: var(--ui-accent);
  color: var(--ui-accent-d);
  background: #f0fdf4;
}

/* 消息卡片列表 */
.msgs { list-style: none; margin: 0; padding: 0; }

.msg-card {
  position: relative;
  padding: 10px 11px;
  margin-bottom: 8px;
  background: var(--ui-panel-2);
  border: 1px solid var(--ui-border);
  border-radius: 10px;
  transition: border-color .15s, box-shadow .15s, opacity .15s;
}
.msg-card:hover { border-color: var(--ui-border-2); }
.msg-card.is-dragging { opacity: .45; }
.msg-card.is-drop-before { box-shadow: 0 -2px 0 var(--ui-accent); }
.msg-card.is-drop-after  { box-shadow: 0 2px 0 var(--ui-accent); }

.msg-card__head {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}
.msg-card__handle {
  flex: none;
  width: 16px;
  color: var(--ui-text-3);
  font-size: 13px;
  letter-spacing: -1px;
  cursor: grab;
  user-select: none;
}
.msg-card__handle:active { cursor: grabbing; }
.msg-card__idx {
  flex: none;
  min-width: 20px;
  font-size: 11px;
  font-weight: 600;
  color: var(--ui-text-3);
  font-variant-numeric: tabular-nums;
}
.msg-card__sender,
.msg-card__type {
  height: 26px;
  padding: 0 6px;
  background: #fff;
  border: 1px solid var(--ui-border);
  border-radius: 6px;
  font-size: 12px;
  outline: none;
}
.msg-card__sender { flex: 1 1 auto; min-width: 0; }
.msg-card__type   { flex: none; }
.msg-card__sender:focus, .msg-card__type:focus { border-color: var(--ui-accent); }

.msg-card__tools { flex: none; display: flex; gap: 2px; margin-left: auto; }
.msg-card__tools button {
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ui-text-3);
  font-size: 13px;
  line-height: 1;
  transition: background .12s, color .12s;
}
.msg-card__tools button:hover { background: #e7eaef; color: var(--ui-text); }
.msg-card__tools button[data-act="del"]:hover { background: #fee2e2; color: var(--ui-danger); }

.msg-card__body .input { background: #fff; }
.msg-card__body .field { margin-bottom: 8px; }
.msg-card__body .field:last-child { margin-bottom: 0; }
.msg-card__body textarea.input { min-height: 60px; }
.msg-card__inline { display: flex; align-items: center; gap: 8px; }
.msg-card__inline .input { flex: 1 1 auto; }
.msg-card__suffix { flex: none; font-size: 12px; color: var(--ui-text-3); }

.msg-card__thumb {
  display: block;
  max-width: 100%;
  max-height: 96px;
  margin-top: 8px;
  border-radius: 6px;
  border: 1px solid var(--ui-border);
  object-fit: cover;
}
.msg-card__thumb[hidden] { display: none; }

.msg-card .check { margin-bottom: 0; }

.empty {
  margin: 4px 0 0;
  padding: 22px 12px;
  text-align: center;
  font-size: 12.5px;
  color: var(--ui-text-3);
  background: var(--ui-panel-2);
  border: 1px dashed var(--ui-border-2);
  border-radius: 10px;
}

/* ---------- 3. 右侧舞台 ---------- */
.stage {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-width: 0;
  background:
    radial-gradient(1200px 600px at 50% -10%, #ffffff 0%, rgba(255,255,255,0) 60%),
    var(--ui-bg);
}

.stage__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: none;
  height: 49px;
  padding: 0 18px;
  border-bottom: 1px solid var(--ui-border);
  background: rgba(255,255,255,.72);
  backdrop-filter: saturate(180%) blur(12px);
}
.stage__label { font-size: 12px; font-weight: 600; color: var(--ui-text-2); letter-spacing: .6px; }

/* 微信工具页左上角的「返回 portal」链接 */
.stage__back {
  flex: none;
  font-size: 13px;
  font-weight: 500;
  color: var(--ui-accent-d);
  text-decoration: none;
  white-space: nowrap;
}
.stage__back:hover { color: var(--ui-accent); }

.zoom { display: flex; align-items: center; gap: 6px; }
.zoom__val {
  min-width: 46px;
  text-align: center;
  font-size: 12px;
  color: var(--ui-text-2);
  font-variant-numeric: tabular-nums;
}

.stage__canvas {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 28px 20px 48px;
}
.stage__canvas > .device-wrap { margin: 0 auto; }

/* ---------- 4. 手机设备框 ---------- */
.device-wrap {
  width: 375px;
  transform-origin: center top;
  transition: transform .12s ease-out;
}

.device {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 375px;
  height: 812px;
  overflow: hidden;
  border-radius: 10px;
  background: #ededed;
  /* 不画手机外壳，只留一层浅投影把屏幕从背景里托起来 */
  box-shadow:
    0 16px 40px rgba(16, 24, 40, .16),
    0 2px 6px rgba(16, 24, 40, .06);
  /* 主题变量（由 theme.js 覆盖） */
  --font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-size: 16px;
  --line-height: 1.45;
  --bubble-me: #95ec69;
  --bubble-other: #ffffff;
  --bubble-me-text: #191919;
  --bubble-other-text: #191919;
  --chat-bg: #ededed;
  --chat-bg-image: none;
  --bar-bg: #ededed;
  --bar-text: #191919;
  --divider-text: #a6a6a6;
  --name-text: #9b9b9b;
  --inputbar-bg: #f7f7f7;
  --inputbar-border: #dcdcdc;
}

/* 两套系统现在只有高度不同，外观一致 —— 外壳已经不画了 */
.device[data-os="android"] { height: 780px; }

.device[data-appearance="dark"] {
  background: #111111;
  --chat-bg: #111111;
  --bar-bg: #1e1e1e;
  --bar-text: #f2f2f2;
  --divider-text: #6f6f6f;
  --name-text: #7d7d7d;
  --bubble-other: #2c2c2c;
  --bubble-me: #3eb575;
  --bubble-me-text: #0a0a0a;
  --bubble-other-text: #d5d5d5;
  --inputbar-bg: #1e1e1e;
  --inputbar-border: #2b2b2b;
}

/* 刘海 / 挖孔
   既然不画手机外壳，这块硬件开孔也不该出现 —— 预览要保持和导出的长图一致。
   几何尺寸保留着，想让刘海回来，删掉下面这条 display: none 即可。 */
.device__notch {
  display: none;
  position: absolute;
  top: 0;
  left: 50%;
  z-index: 3;
  width: 162px;
  height: 30px;
  margin-left: -81px;
  background: #1c1e22;
  border-radius: 0 0 20px 20px;
}
.device[data-os="android"] .device__notch {
  top: 9px;
  width: 10px;
  height: 10px;
  margin-left: -5px;
  border-radius: 50%;
  background: #08090b;
}

/* ---------- 5. 状态栏 ---------- */
.statusbar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: none;
  height: 44px;
  padding: 0 22px 0 26px;
  color: var(--bar-text);
  background: var(--bar-bg);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .2px;
}
.device[data-os="android"] .statusbar {
  height: 26px;
  padding: 0 14px;
  font-size: 12px;
  font-weight: 500;
}

.statusbar__time { font-variant-numeric: tabular-nums; }

.statusbar__right { display: flex; align-items: center; }

.statusbar__carrier {
  margin-right: 6px;
  font-size: 12px;
  font-weight: 500;
  opacity: .92;
}
.device[data-os="android"] .statusbar__carrier { font-size: 11px; }

/* iOS 状态栏中间是刘海，真实机型本来就不显示运营商；留着会被刘海压住 */
.device[data-os="ios"] .statusbar__carrier { display: none; }

/* 信号格 */
.signal {
  display: flex;
  align-items: flex-end;
  height: 11px;
  margin-right: 6px;
}
.signal i {
  display: block;
  width: 3px;
  margin-right: 1.5px;
  border-radius: 1px;
  background: currentColor;
}
.signal i:nth-child(1) { height: 4px; }
.signal i:nth-child(2) { height: 6px; }
.signal i:nth-child(3) { height: 8.5px; }
.signal i:nth-child(4) { height: 11px; }
.signal i.is-off { opacity: .28; }

/* 网络标识 */
.statusbar__net {
  display: flex;
  align-items: center;
  height: 12px;
  margin-right: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .3px;
}
.statusbar__net svg { display: block; }

/* 电池 */
.battery {
  position: relative;
  display: block;
  width: 25px;
  height: 12px;
  padding: 1px;
  border: 1.1px solid currentColor;
  border-radius: 3.5px;
  opacity: .95;
}
.battery::after {
  content: "";
  position: absolute;
  top: 3.2px;
  right: -3px;
  width: 1.6px;
  height: 4.4px;
  border-radius: 0 2px 2px 0;
  background: currentColor;
  opacity: .55;
}
.battery__level {
  display: block;
  height: 100%;
  width: 80%;
  border-radius: 1.5px;
  background: currentColor;
  transition: width .2s;
}
.battery.is-charging .battery__level { background: #34c759; }
.battery.is-low .battery__level { background: #ff3b30; }

/* ---------- 6. 导航栏 ---------- */
.navbar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  flex: none;
  height: 44px;
  padding: 0 12px;
  background: var(--bar-bg);
  color: var(--bar-text);
  border-bottom: .5px solid rgba(0, 0, 0, .08);
}
.device[data-appearance="dark"] .navbar { border-bottom-color: rgba(255, 255, 255, .08); }
.device[data-os="android"] .navbar { height: 46px; }

.navbar__back,
.navbar__more {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 34px;
  height: 34px;
  color: var(--bar-text);
}
.navbar__title {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0 4px;
  text-align: center;
  font-size: 17px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- 7. 聊天区 ---------- */
.chat {
  position: relative;
  z-index: 1;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  background-color: var(--chat-bg);
  background-image: var(--chat-bg-image);
  background-size: cover;
  background-position: center;
  scrollbar-width: none;
}
.chat::-webkit-scrollbar { width: 0; height: 0; }

.chat__inner {
  min-height: 100%;
  padding: 14px 12px 18px;
}

/* 时间分割 */
.msg-time {
  margin: 6px 0 16px;
  text-align: center;
  font-size: 12px;
  color: var(--divider-text);
  letter-spacing: .3px;
}

/* 系统提示 */
.msg-system {
  margin: 4px 24px 16px;
  text-align: center;
  font-size: 12px;
  line-height: 1.5;
  color: var(--divider-text);
}

/* 消息行 —— 用 margin 而非 gap，右侧用 DOM 顺序而非 row-reverse */
.msg {
  display: flex;
  align-items: flex-start;
  margin-bottom: 18px;
}
.msg--right { justify-content: flex-end; }
.msg:last-child { margin-bottom: 4px; }

.msg__avatar {
  display: block;
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 4px;
  object-fit: cover;
  background: #cfd4da;
}
.msg--left  .msg__avatar { margin-right: 10px; }
.msg--right .msg__avatar { margin-left: 10px; }

.msg__body {
  display: flex;
  flex-direction: column;
  max-width: 232px;
  min-width: 0;
}
.msg--right .msg__body { align-items: flex-end; }

.msg__sender {
  margin: 0 2px 5px;
  /* 跟着正文字号一起缩放，避免出现「正文 24px 昵称还是 12px」的割裂感 */
  font-size: calc(var(--font-size) * 0.75);
  line-height: 1.2;
  color: var(--name-text);
}

/* 气泡 */
.bubble {
  position: relative;
  max-width: 100%;
  padding: 9px 12px;
  border-radius: 5px;
  font-family: var(--font-family);
  font-size: var(--font-size);
  line-height: var(--line-height);
  word-break: break-word;
  overflow-wrap: anywhere;
  color: var(--bubble-other-text);
  background: var(--bubble-other);
  --bubble-bg: var(--bubble-other);
}
.msg--right .bubble {
  color: var(--bubble-me-text);
  background: var(--bubble-me);
  --bubble-bg: var(--bubble-me);
}

/* 气泡小尖角 */
.bubble::before {
  content: "";
  position: absolute;
  top: 13px;
  width: 0;
  height: 0;
  border: 5px solid transparent;
}
.msg--left  .bubble::before { left: -9px;  border-right-color: var(--bubble-bg); }
.msg--right .bubble::before { right: -9px; border-left-color: var(--bubble-bg); }

.bubble--text { white-space: pre-wrap; }

.mention { color: #576b95; }
.device[data-appearance="dark"] .mention { color: #7d90b8; }
.msg--right .mention { color: #3a5b8c; }

/* 图片消息 */
.msg-image {
  display: block;
  max-width: 200px;
  border-radius: 4px;
  background: #dfe3e8;
  object-fit: cover;
}
.msg-image--placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 160px;
  height: 120px;
  border-radius: 4px;
  background: #dfe3e8;
  color: #8b929c;
  font-size: 12px;
}

/* 语音消息 */
.bubble--voice {
  display: flex;
  align-items: center;
  min-height: 40px;
  padding: 9px 12px;
}
.msg--right .bubble--voice { flex-direction: row-reverse; }
.voice__wave { flex: none; display: flex; align-items: center; color: currentColor; }
.msg--left  .voice__wave { margin-right: 8px; }
.msg--right .voice__wave { margin-left: 8px; }
.voice__dur {
  flex: none;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  opacity: .85;
}

/* 红包 / 转账
   写成 .bubble.bubble--x 是为了压过 .msg--right .bubble（同为两个类，
   但这条在后面，同特异性下后写的赢），否则右侧的红包会被气泡色染绿。 */
.bubble.bubble--redpacket,
.bubble.bubble--transfer {
  display: flex;
  align-items: center;
  min-width: 210px;
  padding: 12px 14px;
  background: #fa9d3b;
  --bubble-bg: #fa9d3b;
  color: #fff;
  border-radius: 5px;
}
.bubble.bubble--redpacket.is-done,
.bubble.bubble--transfer.is-done {
  background: #f3c295;
  --bubble-bg: #f3c295;
  color: #8a5a2b;
}

.pay__icon {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  margin-right: 11px;
}
.pay__icon svg { display: block; }

/* 转账图标里的 ¥ —— 用 HTML 文本而非 SVG <text>，保证 html2canvas 能画出来 */
.pay__yuan {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .26);
  color: inherit;
  font-size: 19px;
  font-style: normal;
  font-weight: 700;
  line-height: 1;
}

.pay__main { flex: 1 1 auto; min-width: 0; }
.pay__title {
  margin-bottom: 5px;
  font-size: 15px;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pay__sub {
  font-size: 11px;
  line-height: 1.2;
  font-weight: 400;
  opacity: .82;
}

/* ---------- 8. 底部输入栏 ---------- */
.inputbar {
  display: flex;
  align-items: center;
  flex: none;
  height: 50px;
  padding: 0 10px;
  background: var(--inputbar-bg);
  border-top: .5px solid var(--inputbar-border);
  color: #5c6470;
}
.device[data-appearance="dark"] .inputbar { color: #8b929c; }
.inputbar.is-hidden { display: none; }

.inputbar__ico {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  margin: 0 3px;
}
.inputbar__field {
  flex: 1 1 auto;
  height: 34px;
  margin: 0 6px;
  border-radius: 5px;
  background: #fff;
}
.device[data-appearance="dark"] .inputbar__field { background: #2c2c2c; }

/* ---------- 9. 导出态 ---------- */
.device.is-exporting {
  height: auto !important;
  /* 消息少时也要保留整屏手机的高度，导出才是「完整的图」；
     消息多时 height:auto 会自然撑高，整段对话不裁切 */
  min-height: 812px;
  overflow: visible;
  border-radius: 0;
  box-shadow: none;
}
.device[data-os="android"].is-exporting { min-height: 780px; }
.device.is-exporting .chat {
  /* 保持 flex:1 去填充剩余高度（把输入栏顶到底部），
     同时 overflow 放开让长对话一次性铺开 */
  min-height: 0;
  overflow: visible;
}
.device.is-exporting .chat__inner { min-height: 0; padding-bottom: 16px; }

/* 预览本身已经就是「一块屏幕」，导出时只需去掉圆角与投影 */
.device.is-exporting .device__notch { display: none; }

/* ---------- 9b. 分屏导出态 ----------
   保持整屏固定高度（不撑高），聊天区按屏幕裁切，
   逐屏滚动截取，得到一张张「单屏截图」式图片 */
.device.is-exporting.is-exporting--split {
  height: 812px !important;
  min-height: 0 !important;
  overflow: hidden;
}
.device[data-os="android"].is-exporting.is-exporting--split { height: 780px !important; }
.device.is-exporting.is-exporting--split .chat {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;   /* 只显示当前这一屏，超出部分截到下一张 */
}

/* ---------- 10. Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  z-index: 999;
  transform: translateX(-50%);
  max-width: min(80vw, 520px);
  padding: 10px 16px;
  border-radius: 10px;
  background: rgba(24, 28, 36, .94);
  color: #fff;
  font-size: 13px;
  line-height: 1.5;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .22);
  animation: toast-in .2s ease-out;
}
.toast[hidden] { display: none; }
.toast.is-error { background: rgba(190, 30, 40, .95); }
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* ---------- 11. 响应式 ----------
   宽度分档：>1400 舒展 / 1100–1400 收紧 / 900–1100 压缩 / 720–900 紧凑 / <720 上下堆叠。
   高度不用断点 —— 预览区由 fitZoom() 同时按可用宽高缩放，任何窗口高度都装得下。 */

@media (max-width: 1400px) {
  .panel { flex-basis: 350px; width: 350px; }
}

@media (max-width: 1100px) {
  .panel { flex-basis: 320px; width: 320px; }
  .stage__canvas { padding: 22px 16px 36px; }
}

@media (max-width: 900px) {
  .rail { flex-basis: 68px; width: 68px; padding: 10px 6px; }
  .rail__icon { width: 42px; height: 29px; }
  .panel { flex-basis: 290px; width: 290px; }

  /* 面板变窄后消息卡片头部一行放不下，让它换行 */
  .msg-card__head { flex-wrap: wrap; }
  .msg-card__sender { flex: 1 1 100px; min-width: 100px; }

  .stage__bar { padding: 0 12px; }
  .stage__canvas { padding: 18px 12px 30px; }
}

@media (max-width: 720px) {
  body { overflow: auto; }
  .app { flex-direction: column; height: auto; min-height: 100dvh; overflow: visible; }

  /* 导航条从左侧竖排转成顶部横排 */
  .rail {
    flex: none;
    flex-direction: row;
    width: 100%;
    padding: 8px 10px;
    gap: 6px;
    overflow-x: auto;
    overflow-y: hidden;
  }
  .rail__item { min-width: 74px; padding: 6px 8px 8px; }
  .rail__icon { width: 42px; height: 28px; }

  .workspace { flex-direction: column; }
  .feature.is-active { flex-direction: column; }

  .panel {
    flex: none;
    width: 100%;
    border-right: 0;
    border-bottom: 1px solid var(--ui-border);
  }
  .panel__body { max-height: none; overflow: visible; }

  .stage { min-height: 72vh; }
  .stage__bar { height: 44px; }
  .stage__canvas { padding: 16px 10px 32px; }
}

/* 矮窗口（比如笔记本合上外接屏前的 1280×620）：
   面板顶部标题栏和底部操作区适当压缩，把纵向空间尽量留给内容 */
@media (max-height: 700px) {
  .panel__head { padding: 10px 16px; }
  .panel__foot { padding: 10px 16px 12px; }
  .stage__canvas { padding-top: 16px; }
}
