:root {
  --bg: #0f1115;
  --panel: #171a21;
  --me: #2b5cff;
  --her: #22262f;
  --text: #e8ecf4;
  --muted: #8b93a5;
  --line: #262b36;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.45 -apple-system, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  overscroll-behavior: none;
}
#app { display: flex; flex-direction: column; height: 100dvh; }

#top {
  display: flex; align-items: center; gap: 10px; padding: calc(env(safe-area-inset-top) + 10px) 14px 10px;
  background: rgba(23,26,33,.92); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5;
}
.avatar {
  width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-size: 20px;
  background: radial-gradient(circle at 35% 30%, #4a7dff, #1b3fb8);
}
.who { flex: 1; min-width: 0; }
.name { font-weight: 600; letter-spacing: .5px; }
.sub { font-size: 12px; color: var(--muted); }
.icon {
  border: 0; background: transparent; color: var(--text); font-size: 19px; padding: 6px 8px;
  border-radius: 10px; line-height: 1;
}
.icon:active { background: #ffffff14; }

#list { flex: 1; overflow-y: auto; padding: 14px 12px 6px; display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; gap: 8px; align-items: flex-end; }
.row.me { flex-direction: row-reverse; }
.bubble {
  max-width: 76vw; padding: 9px 12px; border-radius: 16px; white-space: pre-wrap; word-break: break-word;
  background: var(--her); border: 1px solid #ffffff0a;
}
.row.me .bubble { background: var(--me); border-color: transparent; border-bottom-right-radius: 6px; }
.row.her .bubble { border-bottom-left-radius: 6px; }
.bubble.meta { background: #1a1d24; color: var(--muted); font-size: 13px; }
.bubble a { color: #cfe0ff; }
.thumb { max-width: 60vw; max-height: 40vh; border-radius: 12px; display: block; }
.file {
  display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text);
  background: #ffffff0d; padding: 8px 10px; border-radius: 10px; margin-top: 4px;
}
audio { max-width: 62vw; height: 36px; }
.sticker-img { width: 120px; height: 120px; object-fit: contain; }
.time { font-size: 11px; color: #8b93a5; }
#typing { align-self: flex-start; margin: 0 14px 6px; display: flex; gap: 4px; }
#typing span { width: 6px; height: 6px; border-radius: 50%; background: #6d7690; animation: b 1.2s infinite; }
#typing span:nth-child(2) { animation-delay: .15s; }
#typing span:nth-child(3) { animation-delay: .3s; }
@keyframes b { 0%,60%,100% { transform: translateY(0); opacity: .45 } 30% { transform: translateY(-4px); opacity: 1 } }
.hidden { display: none !important; }

#composer { border-top: 1px solid var(--line); background: var(--panel); padding: 8px 8px calc(env(safe-area-inset-bottom) + 8px); }
.bar { display: flex; align-items: flex-end; gap: 2px; }
#input {
  flex: 1; resize: none; max-height: 120px; min-height: 38px; padding: 9px 12px; border-radius: 18px;
  border: 1px solid var(--line); background: #10131a; color: var(--text); font: inherit; outline: none;
}
#input:focus { border-color: #3357c9; }
.send {
  border: 0; background: var(--me); color: #fff; font: inherit; padding: 8px 14px; border-radius: 18px; margin-left: 2px;
}
.send:disabled { opacity: .4; }
.rec-hint { text-align: center; font-size: 12px; color: var(--muted); padding: 4px 0; }

.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; background: var(--panel); border-top: 1px solid var(--line);
  border-radius: 18px 18px 0 0; padding: 8px 10px calc(env(safe-area-inset-bottom) + 10px); z-index: 20;
  max-height: 60vh; overflow-y: auto;
}
.sheet-head { display: flex; justify-content: space-between; align-items: center; padding: 4px 4px 8px; color: var(--muted); }
.grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.grid img { width: 100%; aspect-ratio: 1; object-fit: contain; background: #0e1117; border-radius: 10px; }

/* ---------- QQ 风语音条 ---------- */
.bubble.voice-bubble { padding: 7px 10px; background: var(--me); border-color: transparent; min-width: 96px; }
.row.her .bubble.voice-bubble { background: var(--her); }
.voice { display: flex; align-items: center; gap: 8px; color: #fff; }
.row.her .voice { color: var(--text); }
.vplay {
  width: 26px; height: 26px; flex: 0 0 26px; border: 0; border-radius: 50%;
  background: #ffffff33; color: inherit; font-size: 11px; line-height: 1; display: grid; place-items: center;
}
.vplay:active { transform: scale(.94); }
.vwave { display: flex; align-items: center; gap: 3px; height: 22px; flex: 1; min-width: 46px; }
.vwave i { display: block; width: 3px; border-radius: 2px; background: currentColor; opacity: .8; transform-origin: center; }
.voice.playing .vwave i { animation: vpulse .9s ease-in-out infinite; }
.voice.playing .vwave i:nth-child(2n) { animation-delay: .12s; }
.voice.playing .vwave i:nth-child(3n) { animation-delay: .24s; }
.voice.playing .vwave i:nth-child(4n) { animation-delay: .36s; }
@keyframes vpulse { 0%,100% { transform: scaleY(.45) } 50% { transform: scaleY(1) } }
.vdur { font-size: 12px; opacity: .92; min-width: 22px; text-align: right; }
.bubble audio { display: none; }

/* ---------- 按住说话（QQ 风） ---------- */
.bar.hidden { display: none; }
.voice-pad { padding: 10px 12px 4px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.vp-hint { font-size: 13px; color: var(--muted); letter-spacing: .5px; }
.vp-mic {
  width: 92px; height: 92px; border-radius: 50%; border: 0; color: #fff;
  background: radial-gradient(circle at 38% 32%, #5b8bff, #2b5cff 68%, #1b3fb8);
  font-size: 34px; line-height: 1; display: grid; place-items: center;
  box-shadow: 0 10px 26px #2b5cff59; transition: transform .12s ease, box-shadow .15s ease, background .15s ease;
  touch-action: none; user-select: none; -webkit-user-select: none;
}
.vp-mic.rec { transform: scale(1.08); box-shadow: 0 0 0 12px #2b5cff2e, 0 10px 30px #2b5cff66; }
.vp-mic.cancel { background: radial-gradient(circle at 38% 32%, #ff8a8a, #e04040 70%, #a52020); box-shadow: 0 0 0 12px #e0404033; }
.vp-glyph { pointer-events: none; }
.vp-foot { display: flex; align-items: center; gap: 10px; height: 26px; }
.vp-timer { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }