:root {
  --qq: #12b7f5;
  --qq-deep: #0aa1db;
  --qq-dark: #1f2329;
  --bubble-me: #cceeff;
  --bubble-peer: #fff;
  --chat-bg: #ebebeb;
  --list-bg: #fff;
  --line: #e8e8e8;
  --ink: #1a1a1a;
  --muted: #999;
  --danger: #fa5151;
  --wechat-head: #ededed;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --app-h: 100dvh;
  --vv-top: 0px;
  --kb-offset: 0px;
  --composer-bottom: 0px;
  --vv-h: 100dvh;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  color-scheme: only light;
  background: #ffffff;
}
body {
  font-family: var(--font);
  color: var(--ink);
  background: #ffffff;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
/* 键盘弹出：页面保持全屏，只上移输入条 */
html.kb-open,
html.kb-open body {
  background: var(--chat-bg);
  overflow: hidden !important;
}
html.kb-open .composer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: var(--composer-bottom, 0px);
  z-index: 100;
  flex-shrink: 0;
  padding-bottom: calc(10px + var(--safe-b));
  background: #f5f5f5;
  border-top: 1px solid #e0e0e0;
}
html.kb-open .input-row textarea {
  max-height: 40px !important;
  min-height: 40px !important;
  height: 40px !important;
}
html.kb-open #messages {
  padding-bottom: calc(72px + var(--composer-bottom, 0px));
}
.error { color: var(--danger); font-size: 13px; margin: 8px 0 0; }
.empty {
  text-align: center; color: var(--muted); font-size: 13px;
  padding: 40px 16px; margin: 0;
}

/* —— 登录 —— */
.auth {
  min-height: 100%;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 20px 16px calc(20px + var(--safe-b));
  background:
    radial-gradient(800px 420px at 15% 0%, #9ad8ff 0%, transparent 55%),
    linear-gradient(165deg, #6ec0f2 0%, #b7e3ff 45%, #eaf7ff 100%);
}
.qq-win {
  width: min(400px, 100%);
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(30, 90, 140, .22);
  overflow: visible;
  padding-bottom: 6px;
}
.qq-titlebar {
  height: 34px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 12px; position: relative; z-index: 2; border-radius: 12px 12px 0 0; background: #fff;
}
.qq-title { font-size: 13px; color: #666; font-weight: 600; }
.qq-winbtns { display: flex; gap: 7px; }
.qq-winbtns span { width: 11px; height: 11px; border-radius: 50%; background: #e5e5e5; }
.qq-winbtns .close { background: #ff605c; }
.qq-banner {
  height: 130px; margin-top: -34px; border-radius: 12px 12px 0 0;
  background:
    linear-gradient(135deg, rgba(255,255,255,.28), transparent 42%),
    linear-gradient(180deg, #4eb8f5, #12b7f5 70%);
  position: relative; overflow: hidden;
}
.qq-banner::before {
  content: ""; position: absolute; width: 160px; height: 160px; right: -36px; top: -48px;
  border-radius: 50%; background: rgba(255,255,255,.14);
}
.qq-avatar-wrap { display: flex; justify-content: center; margin-top: -46px; position: relative; z-index: 3; }
.qq-avatar {
  width: 92px; height: 92px; border-radius: 50%; background: #fff;
  box-shadow: 0 4px 14px rgba(0,0,0,.12); display: grid; place-items: center; border: 3px solid #fff;
  overflow: hidden;
}
.qq-avatar img {
  width: 100%; height: 100%; object-fit: contain; display: block; border-radius: 50%;
  image-rendering: -webkit-optimize-contrast;
}
.qq-body { padding: 16px 28px 20px; }
.qq-field { border-bottom: 1px solid #e6e6e6; }
.qq-field input {
  width: 100%; border: 0; outline: none; background: transparent;
  padding: 14px 2px; font-size: 16px; color: #222;
}
.qq-field input::placeholder { color: #b0b0b0; }
.qq-opts {
  display: flex; gap: 16px; margin: 14px 0 16px; font-size: 12px; color: #999;
}
.qq-opts label { display: flex; align-items: center; gap: 4px; }
.qq-opts input { accent-color: var(--qq); }
.qq-login {
  width: 100%; border: 0; border-radius: 4px;
  background: linear-gradient(180deg, #3fc0ff, #12b7f5);
  color: #fff; font-size: 16px; letter-spacing: 6px; padding: 12px 0;
  cursor: pointer; box-shadow: 0 4px 12px rgba(18,183,245,.35);
}
.qq-login:disabled { opacity: .7; }
.qq-links {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 14px; font-size: 12px; color: #aaa;
}
.qq-link { border: 0; background: none; color: var(--qq); font-size: 12px; cursor: pointer; padding: 0; }
#auth-error { min-height: 18px; display: none; margin-top: 8px; text-align: center; }

/* —— 主壳：手机单栏 / 电脑双栏 —— */
.app {
  display: none;
  height: 100%;
  min-height: 100dvh;
}
.app:not([hidden]) { display: block; }

/* 手机/PWA：flex 撑满全屏，底栏贴底 */
@media (max-width: 859px) {
  html, body {
    max-height: none;
    min-height: -webkit-fill-available;
  }
  .app:not([hidden]) {
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    height: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    min-height: -webkit-fill-available;
    max-height: none;
  }
  .shell {
    flex: 1 1 0;
    min-height: 0;
    max-height: none;
    display: flex;
  }
  .list-pane {
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }
  .app.show-chat .chat-pane {
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }
  .panel,
  .messages {
    flex: 1 1 0;
    min-height: 0;
  }
  .tabbar,
  .composer {
    flex-shrink: 0;
    margin-top: auto;
  }
}

.shell {
  height: 100%;
  max-height: 100%;
  max-width: 1100px;
  margin: 0 auto;
  background: #fff;
  position: relative;
  display: flex;
  box-shadow: 0 0 0 1px rgba(0,0,0,.06);
  overflow: hidden;
}

.list-pane {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--list-bg);
  min-height: 0;
}
.chat-pane {
  display: none;
  flex: 1;
  min-width: 0;
  flex-direction: column;
  background: var(--chat-bg);
  min-height: 0;
  position: relative;
}

/* 手机：进入聊天后隐藏列表 */
.app.show-chat .list-pane { display: none; }
.app.show-chat .chat-pane { display: flex; }

.qq-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--wechat-head);
  color: #111;
  border-bottom: 1px solid #e5e5e5;
}
.qq-top-user { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar {
  width: 42px; height: 42px; border-radius: 8px;
  display: grid; place-items: center; color: #fff; font-weight: 600; flex-shrink: 0;
}
.avatar.round { border-radius: 50%; border: 1px solid rgba(0,0,0,.06); }
.avatar.clickable,
.me-name.clickable { cursor: pointer; }
.me-name.clickable:hover { text-decoration: underline; }
.avatar.clickable { position: relative; overflow: hidden; }
.avatar.clickable:active { transform: scale(0.96); }
.avatar.has-img {
  background-size: cover !important;
  background-position: center !important;
  background-repeat: no-repeat !important;
  color: transparent !important;
  text-shadow: none;
}
.me-name { font-size: 16px; font-weight: 600; color: #111; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-sub { font-size: 11px; color: #888; opacity: 1; margin-top: 2px; }
.top-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }
.top-link {
  border: 0; background: transparent; color: #576b95;
  border-radius: 4px; padding: 5px 10px; font-size: 14px; cursor: pointer;
}
.top-link.install-top { background: #07c160; color: #fff; font-weight: 600; border-radius: 4px; }

.search-wrap {
  padding: 8px 12px;
  background: #f5f6f7;
  display: flex;
  gap: 8px;
  align-items: center;
}
.search {
  flex: 1;
  border: 0;
  background: #fff;
  border-radius: 6px;
  padding: 9px 12px;
  font-size: 14px;
  outline: none;
}
.btn-new-group {
  border: 0;
  background: var(--qq);
  color: #fff;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

.group-tag {
  display: inline-block;
  font-size: 10px;
  color: #fff;
  background: #12b7f5;
  border-radius: 3px;
  padding: 0 4px;
  margin-left: 6px;
  vertical-align: middle;
}
.bubble-name {
  font-size: 12px;
  color: #12b7f5;
  margin-bottom: 3px;
  font-weight: 500;
}
.row.mine .bubble-name { display: none; }
.row.system-row {
  justify-content: center;
  margin-bottom: 10px;
}
.system-tip {
  font-size: 12px;
  color: #999;
  background: rgba(0,0,0,.05);
  border-radius: 4px;
  padding: 4px 10px;
  max-width: 80%;
  text-align: center;
}
.msg-time-sep {
  display: block;
  text-align: center;
  font-size: 12px;
  color: #b2b2b2;
  margin: 12px 0 10px;
  line-height: 1.4;
  user-select: none;
}

.modal {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(0,0,0,.45);
  display: grid; place-items: center;
  padding: 16px;
}
.modal[hidden] { display: none !important; }
.modal-card {
  width: min(400px, 100%);
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; background: linear-gradient(180deg, #3fc0ff, #12b7f5); color: #fff;
}
.modal-x {
  border: 0; background: transparent; color: #fff; font-size: 24px; cursor: pointer; line-height: 1;
}
.modal-body { padding: 14px 16px; overflow-y: auto; flex: 1; }
.modal-body input[type="text"] {
  width: 100%; border: 1px solid #e5e5e5; border-radius: 6px;
  padding: 10px 12px; font-size: 15px; outline: none; margin-bottom: 10px;
}
.modal-tip { margin: 0 0 8px; font-size: 13px; color: #888; }
.pick-list { list-style: none; margin: 0; padding: 0; }
.pick-list li {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 4px; border-bottom: 1px solid #f2f2f2;
}
.pick-list .avatar { width: 36px; height: 36px; border-radius: 50%; font-size: 14px; }
.modal-foot { padding: 12px 16px 16px; }
.modal-foot .qq-login { letter-spacing: 4px; }

.help-card { width: min(480px, 100%); max-height: 88vh; }
.help-body { font-size: 14px; line-height: 1.55; color: #333; }
.help-badge {
  display: inline-block; margin: 0 0 8px;
  padding: 3px 8px; border-radius: 999px;
  background: #f0f7fc; color: #0aa1db; font-size: 12px; font-weight: 600;
}
.help-body h3 { margin: 8px 0 8px; font-size: 16px; }
.help-body p { margin: 0 0 12px; color: #555; }
.help-steps { margin: 0 0 16px; padding-left: 18px; }
.help-steps li { margin: 0 0 10px; }
.help-steps b { display: block; color: #111; margin-bottom: 2px; }
.help-body code {
  font-family: inherit; background: #f4f6f8; padding: 1px 5px; border-radius: 4px;
}
.help-list { margin: 0; padding-left: 18px; color: #555; }
.help-list li { margin: 0 0 8px; }

.panel { flex: 1; overflow-y: auto; min-height: 0; -webkit-overflow-scrolling: touch; }
.list { list-style: none; margin: 0; padding: 0; }
.item {
  display: flex; gap: 12px; align-items: center;
  padding: 12px 14px; cursor: pointer; border-bottom: 1px solid #f2f2f2;
}
.item:active, .item.active { background: #f0f7fc; }
.item .avatar { width: 46px; height: 46px; border-radius: 50%; font-size: 17px; }
.item-body { flex: 1; min-width: 0; }
.item-top { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.item-name { font-size: 16px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-time { font-size: 11px; color: #b2b2b2; flex-shrink: 0; }
.item-bottom { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.item-preview {
  font-size: 13px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1;
}
.badge {
  min-width: 18px; height: 18px; padding: 0 5px;
  background: #f74c31; color: #fff; border-radius: 9px;
  font-size: 11px; line-height: 18px; text-align: center; flex-shrink: 0;
}
.online-dot {
  width: 8px; height: 8px; border-radius: 50%; background: #15d173;
  display: inline-block; margin-left: 5px; vertical-align: middle;
}
.tag-online { font-size: 11px; color: var(--qq); }

.tabbar {
  display: flex;
  border-top: 1px solid var(--line);
  background: #fff;
  padding: 6px 0 calc(6px + var(--safe-b));
  flex-shrink: 0;
  /* 盖住底部安全区，避免透出页面底色 */
  margin-bottom: 0;
  position: relative;
  z-index: 5;
}
.tab {
  flex: 1; border: 0; background: transparent; padding: 4px 0 2px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 11px; color: #888; cursor: pointer;
}
.tab.active { color: var(--qq); font-weight: 600; }
.tab-ico { font-size: 20px; line-height: 1.2; }

/* 聊天 */
.chat-empty {
  flex: 1; display: grid; place-items: center; color: var(--muted); text-align: center;
}
.chat-empty[hidden],
#chat-empty[hidden] {
  display: none !important;
}
.empty-logo {
  font-size: 28px; font-weight: 700; color: var(--qq); letter-spacing: 2px; margin-bottom: 8px;
}
#chat-active { display: flex; flex-direction: column; height: 100%; min-height: 0; }
#chat-active[hidden] { display: none !important; }

.chat-head {
  display: flex; align-items: center; gap: 4px;
  padding: 8px 8px 10px;
  background: var(--wechat-head);
  color: #111;
  border-bottom: 1px solid #e5e5e5;
  flex-shrink: 0;
}
.back {
  border: 0; background: none; color: #111; font-size: 28px; line-height: 1;
  cursor: pointer; padding: 0 6px 2px; width: 40px; flex-shrink: 0;
}
.chat-head-info { min-width: 0; flex: 1; }
.peer-name { font-size: 17px; font-weight: 600; color: #111; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.peer-status { font-size: 11px; color: #888; opacity: 1; margin-top: 2px; }
.ttl-head {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  margin-left: auto;
  padding-right: 4px;
  font-size: 12px;
  color: #666;
}
.ttl-head label { color: #666; white-space: nowrap; }
.ttl-head select {
  border: 1px solid #ddd;
  background: #fff;
  color: #222;
  border-radius: 4px;
  padding: 4px 6px;
  font: inherit;
  font-size: 12px;
  max-width: 88px;
  outline: none;
}

.messages {
  flex: 1; overflow-y: auto; padding: 14px 12px; min-height: 0;
  -webkit-overflow-scrolling: touch;
}
.row {
  display: flex; gap: 8px; margin-bottom: 14px; align-items: flex-start;
  animation: fadein .18s ease;
}
.row.mine { flex-direction: row-reverse; }
.row .avatar { width: 36px; height: 36px; border-radius: 50%; font-size: 14px; }
.bubble {
  max-width: min(72%, 420px);
  padding: 9px 11px;
  border-radius: 8px;
  font-size: 15px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: 0 1px 1px rgba(0,0,0,.04);
  position: relative;
}
.row.mine .bubble { background: var(--bubble-me); }
.row.peer .bubble { background: var(--bubble-peer); }
.bubble-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  font-size: 11px;
  line-height: 1.2;
  flex-wrap: wrap;
}
.row.mine .bubble-meta { justify-content: flex-end; }
.bubble-meta:empty { display: none; }
.read-tag { font-size: 11px; }
.read-tag.read { color: #12b7f5; }
.read-tag.unread { color: #b0b0b0; }
.msg-menu {
  position: fixed;
  z-index: 70;
  display: flex;
  gap: 0;
  background: rgba(40, 40, 40, .92);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 6px 20px rgba(0,0,0,.25);
  min-width: 120px;
}
.msg-menu[hidden] { display: none !important; }
.msg-menu button {
  flex: 1;
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 14px;
  padding: 10px 18px;
  cursor: pointer;
  white-space: nowrap;
}
.msg-menu button:active { background: rgba(255,255,255,.12); }
.msg-menu button[hidden] { display: none !important; }
.msg-menu button + button { border-left: 1px solid rgba(255,255,255,.15); }
.ttl-tag { color: #fa9d3b; font-variant-numeric: tabular-nums; }
.ttl-tag.waiting { color: #999; }
.bubble.media { padding: 4px; background: transparent !important; box-shadow: none; }
.bubble img.chat-img {
  display: block; max-width: min(220px, 62vw); max-height: 280px;
  border-radius: 6px; cursor: zoom-in;
}
.bubble video.chat-vid {
  display: block; max-width: min(240px, 70vw); max-height: 220px;
  border-radius: 6px; background: #000;
}
.file-card {
  display: flex; align-items: center; gap: 10px; min-width: 170px; max-width: 250px;
  padding: 10px 12px; border-radius: 8px; background: #fff; text-decoration: none; color: inherit;
}
.row.mine .file-card { background: var(--bubble-me); }
.file-ico {
  width: 36px; height: 36px; border-radius: 6px; background: #fff;
  display: grid; place-items: center; font-size: 11px; font-weight: 700; color: var(--qq); flex-shrink: 0;
}
.file-name {
  font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px;
}
.file-size { font-size: 11px; color: var(--muted); margin-top: 2px; }

.composer {
  background: #f5f5f5;
  border-top: 1px solid #e0e0e0;
  flex-shrink: 0;
  padding-bottom: calc(10px + var(--safe-b));
  position: relative;
  z-index: 4;
}
.input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  min-height: 56px;
  box-sizing: border-box;
}
.input-row textarea {
  flex: 1;
  resize: none;
  border: 0;
  border-radius: 8px;
  padding: 10px 14px;
  font: inherit;
  font-size: 16px;
  max-height: 120px;
  outline: none;
  background: #fff;
  line-height: 1.35;
  min-height: 40px;
  box-sizing: border-box;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .06);
}
.input-row textarea::placeholder { color: #b0b0b0; }
.tool {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .08);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  line-height: 1;
  padding: 0;
  cursor: pointer;
  flex-shrink: 0;
  color: #444;
  -webkit-tap-highlight-color: transparent;
}
.tool-ico {
  display: block;
  color: currentColor;
}
.tool:active { background: #ececec; }
.tool.active {
  background: #e8f7fe;
  box-shadow: 0 0 0 1px rgba(18, 183, 245, .45);
  color: var(--qq);
}
.send-btn {
  border: 0;
  background: var(--qq);
  color: #fff;
  border-radius: 8px;
  padding: 0 14px;
  font-size: 15px;
  font-weight: 600;
  height: 40px;
  min-width: 56px;
  cursor: pointer;
  flex-shrink: 0;
}
.send-btn[hidden] { display: none !important; }
.send-err {
  margin: 0;
  padding: 0 12px 8px;
  text-align: right;
  display: none;
  font-size: 12px;
}

.plus-panel {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px 8px;
  padding: 16px 14px 10px; background: #ededed;
}
.plus-panel[hidden] { display: none !important; }
.plus-item {
  border: 0; background: transparent; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  color: #666; font-size: 12px;
}
.plus-item .ico {
  width: 54px; height: 54px; border-radius: 12px; background: #fff;
  display: grid; place-items: center; font-size: 22px;
  box-shadow: 0 1px 1px rgba(0,0,0,.05); font-style: normal;
}

.calc-pad {
  background: #ededed;
  padding: 8px 8px 6px;
}
.calc-pad[hidden] { display: none !important; }
.calc-lcd {
  display: none; /* 去掉计算器风格顶栏，更接近微信表情面板 */
}
.calc-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px 4px;
  margin-bottom: 6px;
  /* 先露出约 4 行，其余上滑查看 */
  max-height: 168px;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}
.calc-grid button {
  border: 0;
  background: transparent;
  color: #111;
  border-radius: 6px;
  height: 40px;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  box-shadow: none;
  -webkit-tap-highlight-color: transparent;
}
.calc-grid button:active {
  background: rgba(0, 0, 0, .06);
}
.calc-keys { display: grid; grid-template-columns: 1fr 1fr 1.4fr; gap: 6px; }
.calc-keys button {
  border: 0; height: 38px; border-radius: 6px; font-size: 14px; font-weight: 700; cursor: pointer;
}
.key-ac { background: #f0a030; color: #fff; }
.key-del { background: #6b7380; color: #fff; }
.key-eq { background: var(--qq); color: #fff; }

.lightbox {
  position: fixed; inset: 0; background: rgba(0,0,0,.88);
  display: grid; place-items: center; z-index: 50; cursor: zoom-out;
}
.lightbox img { max-width: 94vw; max-height: 90vh; }

@keyframes fadein {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

/* —— 电脑自适应：列表 + 聊天并排 —— */
@media (min-width: 860px) {
  body { background: #b7dcf2; padding: 16px; height: 100%; }
  .app:not([hidden]) {
    display: block;
    height: calc(100% - 0px);
  }
  .shell {
    height: calc(100dvh - 32px);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 12px 40px rgba(30, 80, 120, .2);
  }
  .list-pane {
    width: 340px;
    flex: 0 0 340px;
    border-right: 1px solid var(--line);
    display: flex !important;
  }
  .chat-pane {
    display: flex !important;
  }
  .app.show-chat .list-pane { display: flex !important; }
  .back { display: none; }
  .qq-top,
  .chat-head {
    height: 62px;
    padding: 0 14px;
    box-sizing: border-box;
    align-items: center;
  }
  .chat-head { padding-right: 12px; }
  .qq-top {
    position: relative;
    z-index: 1;
    margin-right: -1px;
    border-right: 1px solid #e5e5e5;
  }
  .tabbar,
  .composer {
    box-sizing: border-box;
    min-height: 56px;
    padding-bottom: 0;
    border-top: 1px solid var(--line);
    background: #fafafa;
  }
  .tabbar {
    height: 56px;
    align-items: center;
  }
  .composer {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
  }
  .input-row {
    min-height: 55px;
    padding: 10px 12px;
    align-items: center;
    box-sizing: border-box;
  }
  .input-row textarea {
    min-height: 34px;
  }
  .calc-grid {
    grid-template-columns: repeat(8, 1fr);
    max-height: 168px;
  }
}

@media (max-width: 380px) {
  .calc-grid {
    grid-template-columns: repeat(7, 1fr);
    max-height: 168px;
  }
  .qq-body { padding: 14px 20px 18px; }
}

/* —— 宝石消消乐伪装（Jeweled 全屏 iframe） —— */
html.disguise-boot,
html.disguise-boot body,
html.disguise-active,
html.disguise-active body {
  background: #0e0a1f !important;
  color-scheme: dark;
}
/* 伪装启动：盖过白 splash / 蓝 auth，避免刷新连闪 */
html.disguise-boot #app-splash,
html.disguise-boot #auth,
html.disguise-boot #app {
  display: none !important;
}
html.disguise-boot #disguise,
html.disguise-boot #disguise[hidden] {
  display: flex !important;
  visibility: visible !important;
  z-index: 10000;
}
.disguise {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  flex-direction: column;
  padding: 0;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: #0e0a1f;
  color-scheme: dark;
}
.disguise[hidden] { display: none !important; }
html.disguise-boot .disguise[hidden] { display: flex !important; }
.disguise-game {
  flex: 1;
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 0;
  display: block;
  background: #0e0a1f;
  color-scheme: dark;
  /* 加载完成前透明，由外层深色兜底，避免白闪 */
  transition: opacity .12s ease;
}
.disguise-opt {
  margin-top: 4px;
  justify-content: flex-start;
}
.disguise-setting {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 0 6px;
  font-size: 14px;
}
.help-disguise-note {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
  margin: 0 0 8px;
}

/* —— APP 壳 / 安装 —— */
.app-splash {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  /* PWA 冷启动：与 manifest background_color 一致，避免先黑/先蓝再白 */
  background: #ffffff;
  transition: opacity .28s ease, visibility .28s ease;
}
/* App 壳用原生 Splash，隐藏网页启动图标，避免启动时两个图标 */
html.native-shell .app-splash {
  display: none !important;
}
html.native-shell,
html.native-shell body {
  background: var(--wechat-head) !important;
}
html.native-shell .app,
html.native-shell .tabbar {
  background: #ffffff;
}
/* 状态栏与页头同色融为一体 */
html.native-shell .qq-top,
html.native-shell .chat-head {
  padding-top: calc(10px + var(--safe-t));
  background: var(--wechat-head);
}
html.native-shell .chat-pane {
  background: var(--chat-bg);
}
.app-splash.hide {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.splash-logo {
  text-align: center;
  color: #333;
}
.splash-logo img {
  display: block;
  margin: 0 auto 14px;
  border-radius: 22px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .18);
}
.splash-name {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 6px;
}

.install-btn {
  display: block;
  width: 100%;
  margin-top: 14px;
  border: 1px solid rgba(18, 183, 245, .45);
  background: #f0faff;
  color: var(--qq-deep);
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 14px;
  cursor: pointer;
}
.install-btn:active { background: #e4f5ff; }
.install-btn[hidden],
.install-top[hidden] { display: none !important; }

/* 安装成应用后：全屏壳，更像原生小应用 */
html.standalone,
html.standalone body {
  background: #fff !important;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
}
html.standalone input,
html.standalone textarea {
  user-select: text;
  -webkit-user-select: text;
}
/* 只在页头垫顶部安全区，与状态栏同色融合 */
html.standalone .app {
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  padding-top: 0;
  background: #fff;
  height: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  min-height: -webkit-fill-available;
  max-height: none;
}
html.standalone .shell {
  flex: 1 1 0;
  min-height: 0;
  max-width: none;
  max-height: none;
  box-shadow: none;
  background: #fff;
}
html.standalone .list-pane,
html.standalone .chat-pane {
  flex: 1 1 0;
  min-height: 0;
}
html.standalone .list-pane {
  background: #f5f6f8;
}
html.standalone .panel {
  background: #f5f6f8;
  padding: 6px 0 8px;
}
html.standalone .item {
  margin: 0 12px 8px;
  padding: 12px 14px;
  background: #fff;
  border: 0;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .04);
}
html.standalone .item:active,
html.standalone .item.active {
  background: #f0f7fc;
}
html.standalone .search-wrap {
  background: #fff;
  border-bottom: none;
  padding: 10px 12px 8px;
  gap: 8px;
}
html.standalone .search {
  background: #f0f2f5;
  border: 0;
  border-radius: 10px;
}
html.standalone .qq-top {
  padding: calc(10px + var(--safe-t)) 14px 12px;
  background: var(--wechat-head);
  box-shadow: none;
}
html.standalone .chat-head {
  padding: calc(10px + var(--safe-t)) 8px 12px;
  background: var(--wechat-head);
}
html.standalone .tabbar {
  background: #fff;
  border-top: 1px solid #e8e8e8;
  padding: 8px 0 calc(8px + var(--safe-b));
  box-shadow: 0 -1px 8px rgba(0, 0, 0, .04);
  margin-top: auto;
}
html.standalone .auth {
  background: #ffffff;
  padding: calc(12px + var(--safe-t)) 16px calc(16px + var(--safe-b));
  box-sizing: border-box;
}
html.standalone .qq-win {
  width: 100%;
  max-width: 420px;
  border-radius: 16px;
  box-shadow: 0 18px 40px rgba(0, 40, 80, .2);
}
html.standalone .qq-winbtns { display: none; }
html.standalone .install-btn,
html.standalone .install-top { display: none !important; }

@media (display-mode: standalone), (display-mode: fullscreen) {
  .install-btn,
  .install-top { display: none !important; }
  .app {
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    padding-top: 0;
    background: #fff;
    height: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    min-height: -webkit-fill-available;
    max-height: none;
  }
  .qq-top {
    padding-top: calc(10px + var(--safe-t));
    background: var(--wechat-head);
  }
  .chat-head {
    padding-top: calc(10px + var(--safe-t));
    background: var(--wechat-head);
  }
  .shell {
    flex: 1 1 0;
    min-height: 0;
    max-width: none;
    max-height: none;
    box-shadow: none;
  }
  .list-pane,
  .chat-pane {
    flex: 1 1 0;
    min-height: 0;
  }
  .list-pane {
    background: #f5f6f8;
  }
  .panel {
    background: #f5f6f8;
    padding: 6px 0 8px;
  }
  .item {
    margin: 0 12px 8px;
    background: #fff;
    border: 0;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .04);
  }
  .tabbar {
    background: #fff;
    box-shadow: 0 -1px 8px rgba(0, 0, 0, .04);
    padding: 8px 0 calc(8px + var(--safe-b));
    margin-top: auto;
  }
}

/* —— PWA 诊断面板 —— */
.diag-panel {
  position: fixed;
  inset: 0;
  z-index: 9500;
  background: rgba(0, 0, 0, .45);
  display: grid;
  place-items: end;
  padding: 12px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
}
.diag-panel[hidden] { display: none !important; }
.diag-card {
  width: min(480px, 100%);
  max-height: min(78vh, 620px);
  background: #fff;
  border-radius: 14px 14px 12px 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .18);
}
.diag-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  background: #12b7f5;
  color: #fff;
}
.diag-x {
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}
.diag-body {
  padding: 12px 14px;
  overflow-y: auto;
  flex: 1;
}
.diag-tip {
  margin: 0 0 10px;
  font-size: 12px;
  line-height: 1.55;
  color: #666;
}
.diag-list { font-size: 13px; }
.diag-row {
  display: flex;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid #f0f0f0;
  align-items: flex-start;
}
.diag-row:last-child { border-bottom: 0; }
.diag-tag {
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 999px;
}
.diag-tag.ok { background: #e8f8ef; color: #07c160; }
.diag-tag.warn { background: #fff7e6; color: #fa8c16; }
.diag-tag.bad { background: #ffecec; color: #fa5151; }
.diag-name { font-weight: 600; }
.diag-detail { color: #888; margin-top: 2px; word-break: break-all; font-size: 12px; }
.diag-foot {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  padding: 10px 12px 12px;
  border-top: 1px solid #eee;
}
.diag-btn {
  border: 0;
  border-radius: 8px;
  background: #12b7f5;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  padding: 10px 6px;
}
.diag-btn.sec { background: #f5f6f8; color: #333; }
