/* 访客 H5 样式 */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body {
  margin: 0; padding: 0; height: 100%; overflow-x: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #EEF0F6;
}
body { display: flex; align-items: center; justify-content: center; }
button, input, textarea { font-family: inherit; }

.phone {
  width: 100%; max-width: 420px; height: 100%; max-height: 880px;
  background: #F4F5F9; display: flex; flex-direction: column; position: relative; overflow: hidden;
}
@media (min-width: 520px) {
  .phone { height: 90vh; border-radius: 20px; box-shadow: 0 12px 48px rgba(28,30,45,.18); }
}

header {
  flex: none; display: flex; align-items: center; gap: 10px;
  padding: calc(12px + env(safe-area-inset-top)) 14px 12px;
  background: linear-gradient(160deg, #7C6CF0, #6C5CE7); color: #fff;
}
.avatar {
  width: 40px; height: 40px; border-radius: 50%; flex: none; overflow: hidden;
  background: rgba(255,255,255,.22); display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 600;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.who { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.who b { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who span { font-size: 11px; opacity: .88; display: flex; align-items: center; gap: 4px; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: #4ADE80; display: inline-block; }
.dot.off { background: #FBBF24; }
.my-avatar {
  flex: none; width: 38px; height: 38px; border-radius: 50%; border: 2px solid rgba(255,255,255,.5);
  background: rgba(255,255,255,.18); color: #fff; padding: 0; position: relative; overflow: hidden;
}
.my-avatar span {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600;
}
.my-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.my-avatar em {
  position: absolute; right: 0; bottom: 0; font-style: normal; font-size: 9px; line-height: 12px;
  width: 14px; height: 14px; border-radius: 50%; background: rgba(0,0,0,.35); text-align: center;
}

main {
  flex: 1; overflow-y: auto; padding: 14px 12px 10px;
  display: flex; flex-direction: column; gap: 10px; -webkit-overflow-scrolling: touch;
}

.closed-screen { flex: 1; display: flex; align-items: center; justify-content: center; padding: 26px 20px; }
.closed-card {
  width: 100%; max-width: 300px; text-align: center; background: #fff;
  border-radius: 16px; padding: 30px 22px; box-shadow: 0 8px 28px rgba(28,30,45,.08);
}
.closed-icon {
  width: 46px; height: 46px; border-radius: 50%; margin: 0 auto 14px;
  background: #FEE2E2; color: #B91C1C; font-size: 22px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}
.closed-card b { display: block; font-size: 16px; margin-bottom: 8px; }
.closed-card p { margin: 0 0 14px; font-size: 12px; line-height: 1.7; color: #8B90A4; }
.closed-card span { font-size: 11px; color: #A6ABBD; }
.day-tip, .time-tip {
  align-self: center; font-size: 11px; color: #9AA0B4;
  background: rgba(0,0,0,.045); padding: 3px 10px; border-radius: 999px;
}
.time-tip { background: none; padding: 0; font-size: 10px; }

.row { display: flex; gap: 8px; align-items: flex-start; max-width: 86%; }
.row.out { align-self: flex-end; flex-direction: row-reverse; }
.mini {
  width: 30px; height: 30px; border-radius: 50%; flex: none; overflow: hidden;
  display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600;
}
.mini img { width: 100%; height: 100%; object-fit: cover; display: block; }
.row.in .mini { background: #E4E1FB; color: #5B4BD6; }
.row.out .mini { background: #6C5CE7; color: #fff; }
.stack { display: flex; flex-direction: column; gap: 3px; min-width: 0; align-items: flex-start; }
.row.out .stack { align-items: flex-end; }
.bubble {
  padding: 9px 13px; font-size: 15px; line-height: 1.5;
  word-break: break-word; white-space: pre-wrap; text-align: left;
}
.row.in .bubble {
  background: #fff; color: #22252E; border-radius: 14px 14px 14px 4px;
  box-shadow: 0 1px 2px rgba(28,30,45,.06);
}
.row.out .bubble { background: #6C5CE7; color: #fff; border-radius: 14px 14px 4px 14px; }
.bubble.pic { padding: 0; background: none !important; box-shadow: none; }
.bubble.pic img { display: block; max-width: 190px; border-radius: 12px; cursor: zoom-in; }
.meta { font-size: 10px; color: #A6ABBD; display: flex; gap: 6px; }
.sys { align-self: center; font-size: 11px; color: #9AA0B4; background: rgba(0,0,0,.045); padding: 3px 10px; border-radius: 999px; }

.file-bubble {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 12px;
  text-decoration: none; color: inherit; min-width: 160px;
  background: #fff; box-shadow: 0 1px 2px rgba(28,30,45,.06);
}
.row.out .file-bubble { background: #6C5CE7; color: #fff; }
.file-bubble .ficon { font-size: 20px; }
.file-bubble .fmeta { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.file-bubble .fname { font-size: 12px; font-weight: 500; max-width: 165px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-bubble .fsize { font-size: 10px; opacity: .65; }

.voice-bubble {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 12px;
  background: #fff; box-shadow: 0 1px 2px rgba(28,30,45,.06);
}
.row.out .voice-bubble { background: #6C5CE7; color: #fff; }
.voice-bubble button {
  width: 26px; height: 26px; border-radius: 50%; border: none;
  background: rgba(108,92,231,.12); color: #5B4BD6; font-size: 11px;
}
.row.out .voice-bubble button { background: rgba(255,255,255,.22); color: #fff; }
.voice-bubble .dur { font-size: 11px; opacity: .7; }
.voice-bubble .wave { display: flex; align-items: center; gap: 2px; height: 14px; }
.voice-bubble .wave i { width: 2px; background: currentColor; opacity: .45; border-radius: 1px; }
.voice-bubble.playing .wave i { animation: wave .9s infinite ease-in-out; }
.voice-bubble.playing .wave i:nth-child(2) { animation-delay: .1s; }
.voice-bubble.playing .wave i:nth-child(3) { animation-delay: .2s; }
.voice-bubble.playing .wave i:nth-child(4) { animation-delay: .3s; }
@keyframes wave { 0%,100% { transform: scaleY(.4); } 50% { transform: scaleY(1); } }

.typing-tip {
  flex: none; font-size: 11px; color: #9AA0B4; padding: 4px 16px 0;
  display: flex; align-items: center; gap: 3px;
}
.typing-tip[hidden] { display: none; }
.typing-tip i { width: 4px; height: 4px; border-radius: 50%; background: #B7BBCB; animation: blink 1s infinite; }
.typing-tip i:nth-child(2) { animation-delay: .15s; }
.typing-tip i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%,100% { opacity: .25; } 50% { opacity: 1; } }

footer {
  flex: none; display: flex; align-items: flex-end; gap: 7px;
  padding: 9px 10px calc(9px + env(safe-area-inset-bottom));
  background: #fff; border-top: 1px solid #E6E8F0;
}
.icon-btn {
  flex: none; width: 36px; height: 36px; border: none; border-radius: 50%;
  background: #F2F3F8; color: #6C5CE7; font-size: 17px;
  display: flex; align-items: center; justify-content: center;
}
#input {
  flex: 1; min-width: 0; min-height: 36px; max-height: 96px; resize: none;
  border: none; outline: none; background: #F2F3F8; border-radius: 18px;
  padding: 8px 14px; font-size: 15px; line-height: 20px; color: #22252E;
}
#send {
  flex: none; height: 36px; padding: 0 16px; border: none; border-radius: 18px;
  background: #6C5CE7; color: #fff; font-size: 14px; font-weight: 500;
}
#send:disabled { background: #C9C6E8; }

.emoji-panel, .plus-panel {
  flex: none; background: #fff; border-top: 1px solid #F0F1F6; padding: 8px 10px;
}
.emoji-panel { display: flex; flex-wrap: wrap; gap: 2px; max-height: 160px; overflow-y: auto; }
.emoji-panel[hidden], .plus-panel[hidden] { display: none; }
.emoji-panel button { border: none; background: transparent; font-size: 22px; width: 38px; height: 38px; border-radius: 8px; }
.emoji-panel button:active { background: #F2F3F8; }
.plus-panel { display: flex; gap: 10px; }
.plus-panel[hidden] { display: none; }
.plus-panel button {
  flex: 1; border: none; background: #F7F7FC; border-radius: 10px; padding: 12px 0;
  font-size: 12px; color: #52525B; display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.plus-panel button span { font-size: 22px; }

.rec-bar {
  flex: none; display: flex; align-items: center; gap: 9px; padding: 9px 14px;
  background: #FFF4F4; border-top: 1px solid #FFE0E0;
}
.rec-bar[hidden] { display: none; }
.rec-dot { width: 8px; height: 8px; border-radius: 50%; background: #EF4444; animation: blink .9s infinite; }
.rec-bar #recTime { font-size: 12px; color: #B91C1C; width: 34px; }
.rec-bar .rec-tip { flex: 1; font-size: 11px; color: #9AA0B4; }
.rec-bar button { border: none; border-radius: 8px; padding: 6px 12px; font-size: 12px; background: #EF4444; color: #fff; }
.rec-bar button.ghost { background: #fff; color: #52525B; border: 1px solid #E2E4EE; }

.lightbox {
  position: fixed; inset: 0; z-index: 30; background: rgba(10,11,16,.85);
  display: flex; align-items: center; justify-content: center;
}
.lightbox[hidden] { display: none; }
.lightbox img { max-width: 92vw; max-height: 86vh; border-radius: 6px; }

/* 首次进入：设置昵称与头像 */
.profile-mask {
  position: fixed; inset: 0; z-index: 40; background: rgba(17,18,24,.45);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.profile-mask[hidden] { display: none !important; }
.profile-card {
  width: 100%; max-width: 330px; background: #fff; border-radius: 18px;
  padding: 22px 20px; text-align: center; box-shadow: 0 24px 70px rgba(17,18,24,.28);
}
.profile-card h4 { margin: 0 0 5px; font-size: 17px; }
.profile-sub { margin: 0 0 14px; font-size: 11px; color: #9AA0B4; }
.profile-avatar {
  width: 72px; height: 72px; border-radius: 50%; margin: 0 auto 12px;
  overflow: hidden; background: #F2F3F8; color: #9AA0B4;
  display: flex; align-items: center; justify-content: center; font-size: 24px;
}
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.profile-presets { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.profile-presets button {
  width: 44px; height: 44px; padding: 0; border-radius: 50%; border: 2px solid transparent;
  overflow: hidden; background: none;
}
.profile-presets button.on { border-color: #6C5CE7; }
.profile-presets img { width: 100%; height: 100%; display: block; }
.upload-btn {
  border: none; background: #F4F2FF; color: #5B4BD6; border-radius: 999px;
  padding: 7px 14px; font-size: 12px; margin-bottom: 14px;
}
#profileName {
  width: 100%; border: 1px solid #E2E4EE; border-radius: 10px; outline: none;
  padding: 10px 12px; font-size: 14px; text-align: center; color: #22252E;
}
#profileName:focus { border-color: #6C5CE7; }
#profileName.shake { border-color: #EF4444; animation: shakeX .4s; }
@keyframes shakeX { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
.profile-actions { display: flex; gap: 10px; margin-top: 16px; }
.profile-actions button {
  flex: 1; height: 40px; border: none; border-radius: 10px;
  background: #6C5CE7; color: #fff; font-size: 14px;
}
.profile-actions button.ghost { background: #F2F3F8; color: #52525B; }
