/* ============================================================
   反诈互动馆 — 聊天风格整体样式
   （参考本地移动端适配思路，纯静态无外部依赖）
   ============================================================ */

:root {
  --wx-green: #087f3f;
  --wx-bubble-me: #95ec69;
  --wx-bg: #ededed;
  --wx-nav: #ededed;
  --wx-text: #191919;
  --wx-sub: #888;
  --wx-red: #fa5151;
  --gold: #e2b442;
  --link: #576b95;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: #ededed;
  color: var(--wx-text);
  overflow: hidden;
  user-select: none;
}

.app-shell {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- 屏幕切换 ---------- */
.screen {
  position: absolute; inset: 0;
  display: none;
  flex-direction: column;
  background: var(--wx-bg);
}
.screen.active { display: flex; }

/* ---------- 顶栏 ---------- */
.wx-nav {
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--wx-nav);
  border-bottom: 0.5px solid #ddd;
  flex-shrink: 0;
  padding: 0 6px;
  position: relative;
  z-index: 10;
}
.wx-nav .nav-title {
  font-size: 17px;
  font-weight: 600;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  max-width: 60%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-btn {
  width: 40px; height: 40px;
  border: 0; background: none;
  font-size: 24px; color: #111;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.nav-btn:disabled, .send-btn:disabled, .judge-btn:disabled { opacity: 0.55; cursor: wait; }
.nav-right { width: 44px; }
/* 顶栏右侧占位（保持标题居中） */
.nav-btn.spacer { visibility: hidden; }

/* ---------- 聊天列表 ---------- */
.list {
  flex: 1;
  overflow-y: auto;
  background: #fff;
}
.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 0.5px solid #eee;
  cursor: pointer;
  position: relative;
}
.list-item:active { background: #ececec; }
.list-item .avatar-wrap { position: relative; flex-shrink: 0; }
.list-item .meta { flex: 1; min-width: 0; }
.list-item .name-row {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 4px;
}
.list-item .name { font-size: 16px; font-weight: 500; }
.list-item .time { font-size: 12px; color: #666; }
.list-item .preview {
  font-size: 13px; color: #666;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.badge-unread {
  position: absolute; right: -6px; top: -6px;
  min-width: 18px; height: 18px;
  padding: 0 4px;
  border: 2px solid #fff;
  background: #f43530; color: #fff;
  font-size: 10px; line-height: 14px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  z-index: 1;
}
.mark {
  width: 22px; height: 22px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; color: #fff; flex-shrink: 0;
}
.mark.gold { background: var(--gold); }
.mark.ok { background: var(--wx-green); }
.mark.locked { background: #ccc; }

/* ---------- 主导航 ---------- */
.wx-tabbar {
  display: flex;
  flex-shrink: 0;
  height: 56px;
  padding: 4px 0 env(safe-area-inset-bottom);
  background: #f7f7f7;
  border-top: 0.5px solid #d9d9d9;
}
.tab-item {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: #888;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font: inherit;
  font-size: 11px;
  line-height: 1.2;
  cursor: default;
}
.tab-item.active { color: var(--wx-green); }
.tab-icon { font-size: 22px; line-height: 1; }

/* ---------- 头像 ---------- */
.avatar {
  width: 48px; height: 48px;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; color: #fff; font-weight: 600;
  flex-shrink: 0;
  overflow: hidden;
}
.avatar.sm { width: 40px; height: 40px; font-size: 16px; border-radius: 5px; }
.avatar.me {
  background: var(--wx-green);
  font-size: 12px;
}
.avatar .letter { /* 色块占位头像：中文首字 */ }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ---------- 聊天页 ---------- */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px 8px;
  background: var(--wx-bg);
}
.time-chip {
  text-align: center;
  font-size: 12px; color: #666;
  margin: 8px 0 12px;
}
.msg {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  align-items: flex-start;
}
.msg.me { flex-direction: row-reverse; }
.bubble {
  max-width: 74%;
  padding: 10px 12px;
  font-size: 16px; line-height: 1.45;
  border-radius: 6px;
  position: relative;
  word-break: break-word;
  user-select: text;
}
.msg.them .bubble { background: #fff; }
.msg.me .bubble { background: var(--wx-bubble-me); }
.bubble .tail {
  position: absolute; top: 12px; width: 0; height: 0;
  border-top: 5px solid transparent; border-bottom: 5px solid transparent;
}
.msg.them .tail { left: -6px; border-right: 6px solid #fff; }
.msg.me .tail { right: -6px; border-left: 6px solid var(--wx-bubble-me); }

/* 等待对方回复：保持气泡尺寸稳定并显示输入中动画 */
.bubble.streaming {
  min-width: 52px;
  min-height: 40px;
  display: flex;
  align-items: center;
  padding: 10px 14px;
}
.bubble.streaming .tail { top: 15px; }
.bubble.streaming .bubble-content {
  display: flex;
  align-items: center;
  min-height: 20px;
}
.typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 12px;
}
.typing-dots span {
  display: block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #999;
  animation: blink 1.2s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

/* 语音消息样式 */
.bubble.voice { min-width: 90px; display: flex; align-items: center; gap: 6px; }
.bubble.voice .vwave { letter-spacing: -2px; font-weight: 700; color: #333; }

/* 系统消息（道具使用等） */
.msg.sys {
  justify-content: center;
}
.msg.sys .sys-chip {
  font-size: 12px; color: #666;
  background: rgba(0,0,0,0.04);
  padding: 4px 10px; border-radius: 4px;
}

/* ---------- 输入区 ---------- */
.toolbar {
  display: flex;
  gap: 8px;
  padding: 6px 10px 2px;
  background: var(--wx-bg);
  flex-wrap: wrap;
  flex-shrink: 0;
}
.preset-replies {
  display: flex;
  gap: 8px;
  padding: 2px 10px 6px;
  background: var(--wx-bg);
  flex-wrap: wrap;
  flex-shrink: 0;
}
.preset-btn {
  border: 1px solid #d8d8d8;
  background: #fff;
  border-radius: 14px;
  padding: 5px 10px;
  font-size: 12px;
  color: #444;
  cursor: pointer;
}
.preset-btn:active { background: #f0f0f0; }
.preset-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.item-btn {
  border: 1px solid #ddd;
  background: #fff;
  border-radius: 16px;
  padding: 4px 12px;
  font-size: 12px;
  color: #333;
  cursor: pointer;
  display: flex; align-items: center; gap: 4px;
}
.item-btn.used {
  opacity: 0.35;
  text-decoration: line-through;
  pointer-events: none;
}
.item-btn.armed {
  border-color: var(--wx-green);
  color: var(--wx-green);
  background: #f0fbef;
}
.item-btn:disabled { cursor: not-allowed; }
.input-bar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 10px;
  background: var(--wx-bg);
  border-top: 0.5px solid #e0e0e0;
  flex-shrink: 0;
}
.chat-input {
  flex: 1;
  min-width: 0;
  height: 38px;
  border: 0; border-radius: 6px;
  padding: 0 12px;
  font-size: 16px;
  background: #fff;
  outline: none;
}
.send-btn {
  height: 38px;
  padding: 0 16px;
  border: 0; border-radius: 6px;
  background: var(--wx-green); color: #fff;
  font-size: 15px; cursor: pointer;
  flex-shrink: 0;
}
.send-btn:active { background: #066b35; }

.judge-btn {
  height: 38px;
  padding: 0 10px;
  border: 1px solid #d0d0d0; border-radius: 6px;
  background: #fff; color: #333;
  font-size: 13px; cursor: pointer;
  flex-shrink: 0;
}
.judge-btn:active { background: #f0f0f0; }

/* ---------- 弹层（人物卡/提交判断共用样式） ---------- */
.sheet-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.45);
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 40;
}
.sheet-backdrop.show { opacity: 1; pointer-events: auto; }

.sheet {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  background: #fff;
  border-radius: 16px 16px 0 0;
  transform: translateY(110%);
  visibility: hidden;
  transition: transform 0.28s ease, visibility 0s linear 0.28s;
  z-index: 41;
  padding: 10px 18px calc(18px + env(safe-area-inset-bottom));
  max-height: 80%;
  overflow-y: auto;
}
.sheet.show { transform: none; visibility: visible; transition-delay: 0s; }

.sheet-handle {
  width: 36px; height: 4px;
  background: #ddd; border-radius: 2px;
  margin: 4px auto 12px;
}

.sheet-close {
  position: absolute;
  top: 8px;
  right: 12px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: #f4f4f4;
  color: #777;
  font-size: 25px;
  line-height: 1;
  cursor: pointer;
}
.sheet-close:active { background: #e9e9e9; }

/* 人物卡 */
.profile-head {
  display: flex; align-items: center; gap: 14px;
  padding: 6px 0 14px;
  border-bottom: 0.5px solid #eee;
  margin-bottom: 12px;
}
.profile-head .avatar { width: 60px; height: 60px; font-size: 26px; border-radius: 8px; }
.profile-name { font-size: 18px; font-weight: 600; }
.profile-role { font-size: 13px; color: #666; margin-top: 4px; }
.mem-item {
  font-size: 14px; line-height: 1.55;
  padding: 10px 12px;
  background: #f7faf8;
  border-left: 3px solid var(--wx-green);
  margin-top: 10px;
  border-radius: 0 8px 8px 0;
  color: #333;
}
.profile-tip {
  margin-top: 14px;
  font-size: 12px; color: #666;
  line-height: 1.6;
}

/* 提交判断 */
.judge-hd { font-size: 16px; font-weight: 600; text-align: center; margin-bottom: 12px; }
.judge-options { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.judge-opt {
  border: 1px solid #e5e5e5;
  background: #fafafa;
  border-radius: 10px;
  padding: 12px 8px;
  font-size: 14px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.judge-opt:active { border-color: var(--wx-green); background: #f0fbef; }
.judge-custom { margin-top: 12px; }
.judge-custom textarea {
  width: 100%;
  border: 1px solid #e5e5e5; border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
  resize: none; outline: none;
  font-family: inherit;
}
.judge-custom-btn {
  width: 100%; height: 40px;
  margin-top: 8px;
  border: 0; border-radius: 8px;
  background: var(--wx-green); color: #fff;
  font-size: 15px; cursor: pointer;
}

/* ---------- 通关动画层 ---------- */
.victory-layer {
  position: absolute; inset: 0;
  display: none;
  align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, rgba(7,193,96,0.25), rgba(2,20,10,0.88));
  z-index: 60;
  overflow: hidden;
}
.victory-layer.show { display: flex; }
.victory-card {
  width: 84%;
  max-width: 360px;
  background: rgba(255,255,255,0.97);
  border-radius: 20px;
  padding: 28px 22px 22px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
  animation: cardIn 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.2) both;
  position: relative;
  z-index: 2;
}
@keyframes cardIn {
  from { transform: translateY(60px) scale(0.85); opacity: 0; }
  to { transform: none; opacity: 1; }
}
.stars { display: flex; justify-content: center; gap: 14px; margin-bottom: 12px; }
.star {
  font-size: 44px;
  color: #ccc;
  opacity: 0;
  transform: scale(0.2) rotate(-30deg);
}
.star.earn {
  color: var(--gold);
  animation: starPop 0.55s cubic-bezier(0.2, 2.2, 0.4, 1) forwards;
  text-shadow: 0 0 18px rgba(226,180,66,0.7);
}
.star:nth-child(1).earn { animation-delay: 0.15s; }
.star:nth-child(2).earn { animation-delay: 0.45s; }
.star:nth-child(3).earn { animation-delay: 0.75s; }
@keyframes starPop {
  0% { opacity: 0; transform: scale(0.2) rotate(-30deg); }
  60% { opacity: 1; transform: scale(1.3) rotate(8deg); }
  100% { opacity: 1; transform: scale(1) rotate(0); }
}
.victory-title { font-size: 22px; font-weight: 700; margin-bottom: 6px; }
.victory-sub { font-size: 14px; color: var(--wx-sub); margin-bottom: 14px; }
.victory-knowledge {
  background: #f7faf8;
  border-left: 3px solid var(--wx-green);
  border-radius: 0 8px 8px 0;
  padding: 10px 12px;
  text-align: left;
  font-size: 13px; line-height: 1.6; color: #444;
  margin-bottom: 16px;
}
.victory-btns { display: flex; flex-direction: column; gap: 8px; }
.v-btn {
  height: 44px;
  border: 0; border-radius: 10px;
  font-size: 16px; font-weight: 600;
  cursor: pointer;
}
.v-btn.primary { background: var(--wx-green); color: #fff; }
.v-btn.ghost { background: #f2f2f2; color: #333; }

/* ---------- Toast ---------- */
.toast {
  position: absolute;
  left: 50%; bottom: 120px;
  transform: translateX(-50%) translateY(8px);
  background: rgba(0,0,0,0.78);
  color: #fff;
  font-size: 13px;
  padding: 10px 18px;
  border-radius: 8px;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 80;
  max-width: 82%;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%); }

/* ---------- 加载中 ---------- */
.typing {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 2px 0 10px 44px;
  font-size: 12px; color: #999;
}
.typing.show { display: flex; }
.typing .dots span {
  display: inline-block;
  width: 6px; height: 6px;
  background: #999; border-radius: 50%;
  margin-right: 3px;
  animation: blink 1.2s infinite;
}
.typing .dots span:nth-child(2) { animation-delay: 0.2s; }
.typing .dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%,80%,100% { opacity: 0.3; } 40% { opacity: 1; } }

/* 星星粒子（通关背景） */
.particle {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  animation: floatUp linear forwards;
}
@keyframes floatUp {
  0% { transform: translateY(0) scale(1); opacity: 1; }
  100% { transform: translateY(-120vh) scale(0.4); opacity: 0; }
}

/* 烟花星轨（简单光点） */
.spark {
  position: absolute;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--gold);
  pointer-events: none;
  animation: sparkFly ease-out forwards;
}
@keyframes sparkFly {
  0% { transform: translate(0,0) scale(1); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(0); opacity: 0; }
}

/* 响应式 */
@media (min-width: 640px) {
  body { display: flex; justify-content: center; }
  .app-shell { max-width: 420px; margin: 0 auto; box-shadow: 0 0 40px rgba(0,0,0,0.12); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
