* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: #111;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #111;
}

.phone {
  width: 430px;
  height: 94vh;
  max-height: 920px;
  background: #ededed;
  display: flex;
  flex-direction: column;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 12px 48px rgba(0,0,0,.55);
  position: relative;
}

.jump-bottom {
  position: absolute;
  right: 0;
  bottom: 66px;
  z-index: 5;
  border: none;
  border-radius: 19px 0 0 19px;
  background: #fff;
  color: #07c160;
  font-size: 14px;
  padding: 8px 12px 8px 13px;
  box-shadow: 0 2px 10px rgba(0,0,0,.12);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.jump-bottom svg { width: 14px; height: 14px; }


.titlebar {
  height: 50px;
  background: #ededed;
  display: flex;
  align-items: center;
  padding: 0 10px;
  gap: 6px;
  flex-shrink: 0;
}
.title-wrap { flex: 1; min-width: 0; text-align: center; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.titlebar .title { font-size: 17px; font-weight: 500; color: #000; line-height: 22px; }
.app-status { color: #c55; font-size: 10px; line-height: 12px; }
.nav-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: #000;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
}
.nav-btn svg { width: 22px; height: 22px; }

.chat {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px 18px;
  background: #ededed;
}
.chat::-webkit-scrollbar { width: 0; }

/* 时间戳和系统提示使用裸灰字，不使用底色胶囊；两侧间距保持固定。 */
.time-sep, .system-tip {
  width: fit-content;
  max-width: 82%;
  margin: 22px auto 22px;
  padding: 0;
  background: transparent;
  color: #b2b2b2;
  font-size: 13px;
  line-height: 18px;
  text-align: center;
}
.system-tip { color: #a8a8a8; }

.load-older {
  text-align: center;
  color: #999;
  font-size: 12px;
  padding: 6px 0 2px;
}

.row {
  display: flex;
  margin-bottom: 16px;
  align-items: flex-start;
  animation: msgIn .12s ease-out;
}
@keyframes msgIn { from { transform: translateY(4px); opacity: .4; } to { transform: translateY(0); opacity: 1; } }
.row.me { flex-direction: row-reverse; }

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 5px;
  flex-shrink: 0;
  object-fit: cover;
  background: #ddd;
}
.row.her .avatar { margin-right: 10px; }
.row.me  .avatar { margin-left: 10px; }

.bubble-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  max-width: calc(100% - 62px);
}
.row.me .bubble-wrap { align-items: flex-end; }

.bubble {
  max-width: 300px;
  min-height: 24px;
  padding: 9px 13px;
  border-radius: 6px;
  font-size: 17px;
  line-height: 1.4;
  word-break: break-word;
  white-space: pre-wrap;
  position: relative;
}
.row.her .bubble { background: #fff; color: #181818; }
.row.me  .bubble { background: #95ec69; color: #181818; }

.row.her .bubble::before {
  content: "";
  position: absolute;
  left: -5px; top: 15px;
  border: 5px solid transparent;
  border-right-color: #fff;
  border-left: 0;
}
.row.me .bubble::before {
  content: "";
  position: absolute;
  right: -5px; top: 15px;
  border: 5px solid transparent;
  border-left-color: #95ec69;
  border-right: 0;
}

.inline-emoji-token {
  display: inline-block;
  color: #6b6b6b;
  background: rgba(0,0,0,.06);
  border-radius: 3px;
  padding: 0 3px;
  margin: 0 1px;
}

.inline-unicode-emoji {
  display: inline-block;
  margin: 0 1px;
  font-size: 1.12em;
  vertical-align: -1px;
}

.bubble-sticker, .bubble-image {
  padding: 0 !important;
  background: transparent !important;
  box-shadow: none;
  max-width: 170px;
}
.bubble-sticker::before, .bubble-image::before { display: none; }
.sticker-img {
  display: block;
  max-width: 148px;
  max-height: 148px;
  object-fit: contain;
  border-radius: 4px;
}
.sticker-fallback {
  padding: 14px 16px;
  border-radius: 8px;
  background: #fff;
  color: #777;
  font-size: 14px;
}
.chat-img {
  display: block;
  max-width: 190px;
  max-height: 240px;
  object-fit: cover;
  border-radius: 5px;
}

.bubble-voice {
  height: 40px;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.voice-space { flex: 1; }
.voice-duration { font-size: 16px; color: #191919; }

/* 语音播放图标由三条同心弧组成，播放时依次点亮。 */
.voice-arcs {
  position: relative;
  width: 17px;
  height: 20px;
  flex-shrink: 0;
}
.voice-arcs i {
  position: absolute;
  top: 50%;
  left: 0;
  transform: translateY(-50%);
  border: 1.6px solid #4a4a4a;
  border-radius: 50%;
  clip-path: inset(-2px -2px -2px 55%);
}
.voice-arcs i:nth-child(1) { width: 4px;  height: 4px;  border-width: 2px; }
.voice-arcs i:nth-child(2) { width: 11px; height: 11px; left: -3px; }
.voice-arcs i:nth-child(3) { width: 18px; height: 18px; left: -6px; }
.voice-arcs.flip { transform: scaleX(-1); }
.bubble-voice.playing .voice-arcs i:nth-child(2) { animation: voiceArc2 1.2s infinite; }
.bubble-voice.playing .voice-arcs i:nth-child(3) { animation: voiceArc3 1.2s infinite; }
@keyframes voiceArc2 { 0%, 32% { opacity: 0; } 33%, 100% { opacity: 1; } }
@keyframes voiceArc3 { 0%, 65% { opacity: 0; } 66%, 100% { opacity: 1; } }

/* 未播放语音的提示点。 */
.bubble-wrap { position: relative; }
.voice-dot {
  position: absolute;
  top: 15px;
  right: -13px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fa5151;
}
.voice-transcript-ui {
  margin-top: 8px;
  padding-top: 7px;
  border-top: 1px solid rgba(0, 0, 0, .08);
  min-width: 140px;
  max-width: 220px;
  color: #666;
  font-size: 13px;
  line-height: 18px;
  white-space: normal;
}
.transcript-toggle {
  margin-top: 4px;
  padding: 0;
  border: none;
  background: transparent;
  color: #7b7b7b;
  font-size: 11px;
  line-height: 16px;
  cursor: pointer;
}

/* 反馈按钮悬浮在气泡右侧，不占用消息行高。 */
.msg-actions {
  position: absolute;
  left: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  gap: 4px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s;
  white-space: nowrap;
}
.bubble-wrap:hover .msg-actions { opacity: 1; pointer-events: auto; }
.msg-actions button {
  border: none;
  background: rgba(0,0,0,.08);
  color: #666;
  border-radius: 3px;
  padding: 1px 5px;
  font-size: 11px;
}
.send-status {
  min-height: 18px;
  margin-top: 2px;
  color: #b34;
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.retry-btn {
  border: none;
  background: transparent;
  color: #576b95;
  font-size: 11px;
  padding: 0 2px;
}
.retry-btn:disabled { color: #999; }

.hidden { display: none !important; }

.inputbar {
  min-height: 55px;
  background: #f7f7f7;
  border-top: 1px solid rgba(0,0,0,.06);
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
}
.icon-btn {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: #1a1a1a;
  padding: 3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.icon-btn svg { width: 27px; height: 27px; }
.inputbar .chat-input {
  flex: 1;
  min-width: 0;
  border-radius: 6px;
  background: #fff;
  padding: 8px 10px;
  font-size: 16px;
  outline: none;
  line-height: 22px;
  min-height: 38px;
  max-height: 92px;
  overflow-y: auto;
  word-break: break-word;
  cursor: text;
}
/* 表情面板打开时键盘已收，使用伪元素保留输入框的光标提示。 */
.inputbar .chat-input.show-caret::after {
  content: "";
  display: inline-block;
  width: 2px;
  height: 19px;
  background: #07c160;
  vertical-align: -4px;
  margin-left: 1px;
  animation: caretBlink 1s steps(1) infinite;
}
@keyframes caretBlink { 50% { opacity: 0; } }
.hold-voice {
  flex: 1;
  border: none;
  border-radius: 6px;
  background: #fff;
  height: 38px;
  color: #111;
  font-size: 15px;
}
.hold-voice.recording {
  background: #dedede;
  color: #000;
}
#send {
  border: none;
  border-radius: 4px;
  background: #07c160;
  color: #fff;
  height: 34px;
  padding: 0 13px;
  font-size: 14px;
}
#send:disabled { background: #9be6bc; cursor: default; }
.icon-btn.active { background: #e2e2e2; }

.panel {
  background: #f7f7f7;
  border-top: 1px solid #e3e3e3;
  flex-shrink: 0;
}
.emoji-panel {
  position: relative;
  height: 244px;
  display: flex;
  flex-direction: column;
  padding: 0 0 env(safe-area-inset-bottom);
}
.emoji-drag-bar {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: #d9d9d9;
  margin: 6px auto 0;
  flex-shrink: 0;
}
.emoji-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 4px 10px 56px;
}
.emoji-group-title {
  font-size: 12px;
  color: #999;
  padding: 8px 4px 4px;
}
.emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
}
.emoji-option-btn {
  border: none;
  background: transparent;
  border-radius: 6px;
  padding: 5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.emoji-option-btn:active, .emoji-option-btn:hover, .emoji-option-btn.pressed { background: #e0e0e0; }
.emoji-option-btn { font-size: 25px; line-height: 1; transition: transform .06s; }
.emoji-option-btn.pressed { transform: scale(.88); }

.emoji-actions {
  position: absolute;
  right: 12px;
  bottom: calc(26px + env(safe-area-inset-bottom));
  display: flex;
  gap: 8px;
  z-index: 2;
}
.emoji-backspace {
  width: 52px;
  height: 38px;
  border: none;
  border-radius: 8px;
  background: #fff;
  color: #333;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,.12);
  cursor: pointer;
}
.emoji-backspace svg { width: 22px; height: 22px; }
.emoji-backspace { transition: transform .06s, background .06s; }
.emoji-backspace:active, .emoji-backspace.pressed { background: #e2e2e2; transform: scale(.94); }
.emoji-send {
  min-width: 64px;
  height: 38px;
  border: none;
  border-radius: 8px;
  background: #07c160;
  color: #fff;
  font-size: 15px;
  box-shadow: 0 2px 8px rgba(0,0,0,.12);
  cursor: pointer;
}
.emoji-send:disabled { background: #c7ead6; color: #fff; cursor: default; box-shadow: none; }
.emoji-send { transition: transform .06s, background .06s; }
.emoji-send:not(:disabled):active, .emoji-send:not(:disabled).pressed { background: #06ad56; transform: scale(.94); }

.plus-panel {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 18px 18px 22px;
}
.plus-item {
  border: none;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: #59616d;
  cursor: pointer;
  min-width: 64px;
}
.plus-icon {
  width: 54px;
  height: 54px;
  border-radius: 14px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 1px rgba(0,0,0,.02);
}
.plus-lucide {
  width: 25px;
  height: 25px;
  display: block;
  filter: invert(33%) sepia(12%) saturate(767%) hue-rotate(178deg) brightness(95%) contrast(92%);
}
.plus-item.danger { color: #bf4a4a; }
.plus-item.danger .plus-lucide {
  filter: invert(43%) sepia(21%) saturate(1665%) hue-rotate(314deg) brightness(92%) contrast(88%);
}
.plus-item:active .plus-icon { transform: scale(.94); background: #f8f8f8; }

.feedback-panel {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 20;
}
.feedback-card {
  width: min(430px, 100vw);
  background: #fff;
  border-radius: 16px 16px 0 0;
  padding: 16px;
  box-shadow: 0 -10px 30px rgba(0,0,0,.2);
}
.feedback-title { font-size: 16px; font-weight: 600; margin-bottom: 10px; }
.feedback-card select,
.feedback-card textarea {
  width: 100%;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 14px;
  padding: 9px;
  margin-bottom: 10px;
  outline: none;
}
.feedback-card textarea { height: 92px; resize: none; line-height: 1.45; }
.feedback-actions { display: flex; justify-content: flex-end; gap: 8px; }
.feedback-actions button {
  border: none;
  border-radius: 7px;
  padding: 8px 14px;
  font-size: 14px;
}
#feedback-cancel { background: #eee; color: #333; }
#feedback-submit { background: #07c160; color: #fff; }

.install-guide {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0,0,0,.42);
}
.install-guide-card {
  width: min(430px, 100vw);
  padding: 20px 20px calc(18px + env(safe-area-inset-bottom));
  border-radius: 18px 18px 0 0;
  background: #fff;
  box-shadow: 0 -12px 38px rgba(0,0,0,.22);
}
.install-guide-card > img {
  float: left;
  width: 58px;
  height: 58px;
  margin: 0 14px 14px 0;
  border-radius: 13px;
}
.install-guide-card h2 { margin: 3px 0 5px; font-size: 19px; font-weight: 600; }
.install-guide-card p { margin: 0; color: #777; font-size: 13px; line-height: 1.55; }
.install-guide-card ol {
  clear: both;
  margin: 18px 0;
  padding: 14px 14px 14px 34px;
  border-radius: 12px;
  background: #f6f6f6;
  color: #333;
  font-size: 14px;
  line-height: 1.8;
}
.share-symbol { color: #1677ff; font-weight: 600; white-space: nowrap; }
.install-guide-card button {
  width: 100%;
  min-height: 46px;
  border: 0;
  border-radius: 10px;
  background: #07c160;
  color: #fff;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
}

@media (max-width: 520px) {
  body {
    background: #ededed;
    min-height: 100vh;
    min-height: 100dvh;
    /* 键盘弹出时 .phone 变矮,必须顶对齐:居中会把界面挤到屏幕中部,输入栏沉进键盘底下 */
    align-items: flex-start;
  }
  .phone {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    height: var(--vvh, 100dvh); /* 可视视口实际高度,键盘弹出时由 JS 实时写入 */
    max-height: none;
    border-radius: 0;
    box-shadow: none;
  }
  .bubble { max-width: 68vw; }
}
