* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: #EDEDED;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #181818;
  font-size: 16px;
}
#app { display: flex; flex-direction: column; height: 100dvh; position: relative; }

#bar { background: #EDEDED; border-bottom: 1px solid rgba(0,0,0,.08); padding-top: env(safe-area-inset-top); flex: none; }
.bar-inner { height: 48px; display: flex; align-items: center; padding: 0 8px; }
.bar-side { width: 48px; font-size: 24px; color: #181818; text-align: center; }
.bar-title { flex: 1; text-align: center; line-height: 1.2; }
#title { font-size: 17px; font-weight: 500; }
.sub { display: block; font-size: 11px; color: #8a8a8a; margin-top: 2px; }

#list { flex: 1; overflow-y: auto; padding: 12px 12px 4px; -webkit-overflow-scrolling: touch; }

.row { display: flex; margin-bottom: 14px; align-items: flex-start; }
.row.me { flex-direction: row-reverse; }
.avatar {
  width: 40px; height: 40px; border-radius: 5px; flex: none;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 15px; font-weight: 500;
}
.bubblewrap { max-width: calc(100% - 108px); margin: 0 10px; }
.row.me .bubblewrap { text-align: right; }
.nick { font-size: 11px; color: #9a9a9a; margin: 0 0 4px 2px; }
.bubble {
  display: inline-block; text-align: left;
  background: #fff; border-radius: 6px; padding: 9px 12px;
  font-size: 16px; line-height: 1.45; white-space: pre-wrap; word-break: break-word;
  position: relative;
}
.bubble::before {
  content: ""; position: absolute; top: 12px; left: -5px;
  border: 5px solid transparent; border-right-color: #fff; border-left: 0;
}
.row.me .bubble { background: #95EC69; }
.row.me .bubble::before { left: auto; right: -5px; border-right: 0; border-left-color: #95EC69; }

.sticker { font-size: 1.3em; line-height: 1; vertical-align: -0.12em; padding: 0 1px; display: inline; }
.sticker-cap { display: none; }

.sys { text-align: center; margin: 8px auto 14px; }
.sys span { display: inline-block; background: rgba(0,0,0,.12); color: #fff; font-size: 12px; padding: 3px 8px; border-radius: 4px; line-height: 1.4; max-width: 80%; }

#typing { flex: none; height: 20px; padding: 0 16px; font-size: 12px; color: #8a8a8a; }

#foot {
  flex: none; background: #F7F7F7; border-top: 1px solid rgba(0,0,0,.08);
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  display: flex; gap: 8px; align-items: center;
}
#input {
  flex: 1; height: 38px; border: 0; border-radius: 5px; padding: 0 12px;
  font-size: 16px; background: #fff; outline: none; font-family: inherit;
}
#send {
  height: 38px; padding: 0 16px; border: 0; border-radius: 5px;
  background: #07C160; color: #fff; font-size: 15px; font-family: inherit;
}
#send:disabled { background: #b9e8c8; }
button.icon { width: 38px; height: 38px; flex: none; border: 0; border-radius: 5px; background: #fff; font-size: 20px; line-height: 1; color: #555; }

#emopanel { flex: none; height: 200px; background: #F7F7F7; border-top: 1px solid rgba(0,0,0,.08); overflow-y: auto; }
.emo-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; padding: 8px; }
.emo-cell { aspect-ratio: 1; display: flex; align-items: center; justify-content: center; background: #fff; border-radius: 6px; }
.emo-cell:active { background: #E8E8E8; }
.emo-cell img { width: 76%; height: 76%; }
.emo-cell span { font-size: 11px; color: #666; text-align: center; padding: 2px; line-height: 1.1; }

.sticker-img { height: 3em; width: auto; display: inline-block; vertical-align: -1em; border-radius: 4px; }
.emo-char { font-size: 27px; line-height: 1; }
.photo-img { max-width: 218px; width: 100%; border-radius: 6px; display: block; cursor: zoom-in; }

#badge { display: none; background: #FA5151; color: #fff; font-size: 11px; border-radius: 9px; padding: 1px 6px; margin-left: 6px; vertical-align: 2px; }
#badge.on { display: inline-block; }
.at { color: #576B95; }

.hidden { display: none !important; }
#mask { position: absolute; inset: 0; background: rgba(0,0,0,.35); z-index: 20; }
#panel {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 30;
  background: #fff; border-radius: 14px 14px 0 0; max-height: 84%; overflow-y: auto;
}
.panel-inner { padding: 16px 16px calc(20px + env(safe-area-inset-bottom)); }
.panel-inner h3 { font-size: 14px; font-weight: 500; color: #6b6b6b; margin: 16px 0 8px; }
.pbody h3:first-child { margin-top: 4px; }

/* 设置面板分栏 */
.ptabs { display: flex; gap: 8px; margin: 2px 0 6px; }
.ptab { flex: 1; text-align: center; padding: 9px 0; border-radius: 8px; background: #f2f2f2; color: #666; font-size: 15px; transition: background .15s, color .15s; }
.ptab.on { background: #07C160; color: #fff; font-weight: 500; }
.segs { display: flex; gap: 8px; }
.seg {
  flex: 1; text-align: center; padding: 10px 4px; font-size: 14px;
  background: #F2F2F2; border-radius: 8px; color: #333;
}
.seg.on { background: #07C160; color: #fff; }
.hint { font-size: 12px; color: #9a9a9a; line-height: 1.5; margin: 8px 0 0; }
.rowline { display: flex; gap: 8px; align-items: center; font-size: 14px; color: #666; }
.rowline select { flex: 1; height: 36px; border: 1px solid #ddd; border-radius: 6px; background: #fff; font-size: 15px; padding: 0 8px; }
.chk { display: block; margin-top: 10px; font-size: 14px; color: #333; }
.chk input { transform: scale(1.2); margin-right: 6px; }
button.ghost { flex: 1; height: 36px; border: 1px solid #ddd; background: #fff; border-radius: 6px; font-size: 14px; color: #333; font-family: inherit; }
button.primary { width: 100%; height: 44px; margin-top: 20px; border: 0; border-radius: 8px; background: #07C160; color: #fff; font-size: 16px; font-family: inherit; }
button.wide { width: 100%; flex: none; margin-top: 8px; }
button.danger { width: 100%; height: 40px; margin-top: 24px; border: 1px solid #F0B4B4; background: #fff; border-radius: 8px; color: #E24B4A; font-size: 15px; font-family: inherit; }

.role-item { display: flex; align-items: center; gap: 10px; padding: 10px 4px; border-bottom: 1px solid rgba(0,0,0,.06); }
.role-item .avatar { width: 38px; height: 38px; font-size: 15px; }
.role-item .ri-name { flex: 1; font-size: 15px; color: #333; }
.role-item .ri-sub { font-size: 12px; color: #9a9a9a; margin-top: 2px; }
.role-item .ri-go { color: #b5b5b5; font-size: 18px; }

#editor { position: absolute; inset: 0; z-index: 40; background: #fff; display: flex; flex-direction: column; }
.ed-bar { flex: none; display: flex; align-items: center; justify-content: space-between; height: 50px; padding: 0 14px; border-bottom: 1px solid rgba(0,0,0,.07); background: #EDEDED; }
.ed-back { font-size: 15px; color: #576B95; }
.ed-title { font-size: 16px; color: #111; }
.ed-save { font-size: 15px; color: #07C160; font-weight: 500; }
.ed-tabs { flex: none; display: flex; border-bottom: 1px solid rgba(0,0,0,.07); }
.ed-tab { flex: 1; text-align: center; padding: 11px 0; font-size: 14px; color: #666; }
.ed-tab.on { color: #07C160; border-bottom: 2px solid #07C160; }
.ed-body { flex: 1; overflow-y: auto; padding: 14px 14px calc(30px + env(safe-area-inset-bottom)); }
.ed-body label { display: block; font-size: 12px; color: #8a8a8a; margin: 12px 0 5px; }
.ed-body input, .ed-body textarea {
  width: 100%; box-sizing: border-box; border: 1px solid #e2e2e2; border-radius: 7px;
  background: #fff; padding: 9px 10px; font-size: 15px; color: #222; font-family: inherit; line-height: 1.55;
}
.ed-body textarea { resize: vertical; }
.ed-body input:focus, .ed-body textarea:focus { outline: none; border-color: #07C160; }
.ed-2 { display: flex; gap: 10px; }
.ed-2 label { flex: 1; }
.ed-body input[type=color] { height: 40px; padding: 3px; }
#edjson { font-family: ui-monospace, Consolas, monospace; font-size: 13px; line-height: 1.5; }
#edtoast {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: 60px; z-index: 60;
  background: rgba(0,0,0,.78); color: #fff; font-size: 14px; padding: 9px 16px; border-radius: 8px;
}

/* ---------- v1.2：时间提示 + @ 选人面板 ---------- */
.timediv {
  text-align: center; color: #9a9a9a; font-size: 11.5px;
  margin: 14px 0 8px; user-select: none;
}
.at-panel {
  position: absolute; left: 0; right: 0; bottom: calc(52px + env(safe-area-inset-bottom));
  background: #fff; border-top: 1px solid #ececec; z-index: 45;
  max-height: 260px; overflow-y: auto; padding: 6px 0;
  box-shadow: 0 -6px 18px rgba(0,0,0,.06);
}
.at-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 16px; font-size: 15px; color: #222; cursor: pointer;
}
.at-item:active { background: #f5f5f5; }
.at-item .avatar { width: 36px; height: 36px; font-size: 15px; }
.at-item small { color: #9a9a9a; font-size: 12px; }
#atbtn { font-weight: 600; font-size: 18px; }

/* ---------- v1.3：会话列表（仿微信首页） ---------- */
#convlist { display: flex; flex-direction: column; height: 100dvh; }
#convlist #bar { flex: none; }
#convitems { flex: 1; overflow-y: auto; background: #fff; }
#convtitle { font-size: 17px; font-weight: 500; color: #181818; text-align: center; }
.conv-item {
  display: flex; align-items: center; gap: 11px;
  padding: 12px 14px; cursor: pointer; border-bottom: 1px solid #f3f3f3;
}
.conv-item:active { background: #f5f5f5; }
.conv-avw { position: relative; flex: none; }
.conv-avw .avatar { width: 46px; height: 46px; font-size: 18px; border-radius: 6px; }
.conv-badge {
  position: absolute; top: -5px; right: -7px; min-width: 17px; height: 17px;
  background: #FA5151; color: #fff; font-size: 11px; line-height: 17px;
  text-align: center; border-radius: 9px; padding: 0 4px; box-sizing: border-box;
}
.conv-mid { flex: 1; min-width: 0; }
.conv-name { font-size: 15.5px; color: #181818; font-weight: 500; }
.conv-prev {
  font-size: 13px; color: #9a9a9a; margin-top: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.conv-time { flex: none; font-size: 11.5px; color: #b5b5b5; align-self: flex-start; margin-top: 3px; }
#chatview { display: flex; flex-direction: column; height: 100dvh; }
#chatview #bar { flex: none; }
#backbtn { cursor: pointer; font-size: 24px; color: #181818; }

.conv-prev.conv-new { color: #576B95; }

/* ---------- 成长日志卡片 ---------- */
.gcard {
  background: #fff; border-radius: 10px; padding: 12px 14px;
  margin-bottom: 10px; box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.ghead { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.gkind {
  flex: none; font-size: 11px; color: #07C160; background: #E8F7EF;
  border-radius: 4px; padding: 2px 6px;
}
.gtitle { flex: 1; min-width: 0; font-size: 14.5px; color: #181818; font-weight: 500; }
.gwhen { flex: none; font-size: 11.5px; color: #b5b5b5; }
.gdetail { font-size: 12.5px; color: #8a8a8a; margin-top: 6px; line-height: 1.5; }
.gops { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.gbtn {
  border: none; border-radius: 6px; padding: 6px 14px; font-size: 13px;
  cursor: pointer; font-family: inherit;
}
.gbtn.ok { background: #07C160; color: #fff; }
.gbtn.no { background: #f2f2f2; color: #666; }
.gbtn:active { opacity: .8; }
.gstatus { font-size: 12px; margin-left: auto; }
.gstatus.on { color: #07C160; }
.gstatus.off { color: #b5b5b5; }
.gstatus.pending { color: #FA9D3B; }

/* 加载更早消息 */
#loadmore { cursor: pointer; }
